Legacy f77 files in f90

How to use f77 common blocks through “include” statements in f90 ? PGI compiler produces an error.

E.g.
file1.cmn


C common blocks
real a,b,c
common / cb1 / a,b,c


cmntest.f90


program test1
! Include the common block here
include “file1.cmn”
!
a = 5.0
b = 1.0
c = a + b
write(,) 'sum of ‘,a,’ and ‘,b, ’ is :’,c

stop
end program test1


%pgf90 -I./file1.cmn cmntest.f90
PGF90-S-0034-Syntax error at or near identifier common (./file1.cmn: 1)
0 inform, 0 warnings, 1 severes, 0 fatal for test1

Whereas if “!” is used as comment in the file1.cmn file, instead of “C” it works and produces correct result.
sum of 5.000000 and 1.000000 is : 6.000000
FORTRAN STOP


Thanks,
Jawahar

Hi Jawahar,

You can’t mix free and fixed format in the same source file. So to include “file1.cmn” in a free format file, you must updated it to free format as well.

Alternatively, you could update the cmntest.f90 to be fixed format. After editing, either change the file name to “cmntest.f” or add the flag “-Mfixed”.

Hope this helps,
Mat

Hi Mat,
Many Thanks for your suggestion.

Just by changing the cmntest.f90 to “fixed format” (i.e all but comment statements start from column 7) and recompiling with -Mfixed resolves this issue.

Many thanks.

Jawahar