0
votes

I am trying to compile a file with pgf90 or pgfortran(that can handle all kinds of source files i.e. f90 or f77) that is written with fortran 77 constructs(i.e. has a .f extension). The question I have is with line continuation.

open(10,file='/home/adaba/original/potentialenergy/vorticity/data/run/fort.10')

So this line clearly goes beyond column 72. Here is what I tried. I tried breaking this up into two lines by using the '&' character at column 6 in the new line and compiled it. It compiles fine but when I run the program I get an error saying no such file found because it interprets the line continuation as an extra space between run and fort.10 and it reports file not found.

So I kept the code in one line and then added -Mextend which is pgi specific instruction for line extension. Now it seems to add some weird characters to the end of another file name much later in a subroutine. It does open fort.10 properly but it fails to open another file much later in the code and adds some weird characters to end of that file(in binary). In Emacs which is my editor I can see only purple color after the fort.10 statement (indicating that something is not right).

Can somebody with pgi fortran experience help ?

UPDATE

open(10,file='/home/adabas/originalPV/potentialenergy/vorticity/' // &
 &     'data/run/fort.10')

I get a pgf90-s-0034 syntax error at or near &(on the upper line)

The pgf version is 17.0.4 64 bit

2
How exactly did you break it into two lines? Also, it's likely a different error is causing the problem when -Mextend is added. - Ross

2 Answers

1
votes

Off the top of my head, there's a couple things I would try first.

You can request the compiler to allow fixed format (.f) files to be longer than 72 characters. In PGI this is done with the -Mextend compiler flag.

Alternatively, you should be able to construct the filename by splitting it in two lines. Something like:

 open(10,file='/home/adaba/original/' //
& 'potentialenergy/vorticity/data/run/fort.10')

where // is the operator to combine strings. There's other ways to do this, too - you could define a character string as fname first, for example.

1
votes

Expanding on @Ross answer above: In free format Fortran standard, there is another way: you can use STRING continuation syntax like the following:

open(10,file = "/home/adaba/original/& &potentialenergy/vorticity/data/run/fort.10" )

Here there is only one single string split and continued in two lines. The white space between the two ampersands is completely ignored. But anything before the first and after the second ampersands, even white space, counts as part of the string.