Problems with Fortran INCLUDE and Preprocessor
Douglas Vechinski
douglas.vechinski@dynetics.com
Tue Aug 16 16:13:00 GMT 2005
I have been using an older Linux Mandrake 8.1 system with g77
2.96-0.62. I am recenetly trying to compile some fortran code that
worked fine on that system on a newer Redhat FC 3 system with g77
3.4.2-6.fc3 and am encountering problems.
The problem is occurring with some *.F files that are first meant to be
passed through the preprocessor. The preprocessing directives are
simple ones looking for defined values so that certain extra or
different fortran lines can be add. These are not causing the problem.
In these files, some subroutines also have a Fortran INCLUDE. The
compiler stops with an error stating that it cannot find the included
file and the include file does exist. If I manually perform a g77 -E on
the file to get the intermediate .f file and then run g77 on this file,
it works fine.
Example. Create a file call ex.F with the code below:
include 'ex.par'
do i=1,nmax
write(6,*)'i = ',i
enddo
stop
end
Create a file call ex.par with the code below:
parameter (nmax=10)
attempting to compile with g77 -O ex.F results in an error that ex.par
can not be found on the 3.4 version. The older 2.96 version works fine.
However if you first perform g77 -E ex.F > junk.f and then g77 -O junk.f
there are no problems. Does some know what the problem is.
(Yes I realize that this example does not use any C preprocessing
directives but it illustrates the problem for code when I do have some C
prepocessing directives).
More information about the Fortran
mailing list