Problems with Fortran INCLUDE and Preprocessor
Douglas Vechinski
douglas.vechinski@dynetics.com
Tue Aug 16 16:40:00 GMT 2005
On Tue, 2005-08-16 at 07:56 -0700, Richard E Maine wrote:
> On Aug 16, 2005, at 7:39 AM, Douglas Vechinski wrote:
>
> > The problem is occurring with some *.F files that are first meant to be
> > passed through the preprocessor....
> > In these files, some subroutines also have a Fortran INCLUDE.
>
> Mixing C preprocessing and Fortran includes in ways like this causes
> similar problems on may platforms. It is not g77-specific. Although it
> might work on some compilers, it is not portable to assume that the
> compiler will handle it for you.
>
> > 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.
>
> Approaches like that are the most portable way of handling such mixes.
> (Well, even more portable is to avoid the mix, but there are times when
> it is useful.) One can write rules in a Makefile to avoid the pain of
> needing the manual steps.
>
How is separating the steps manually any different than letting the
compiler do it for you. Because the compiler does it in two steps also,
it call the preprocessor using -E and sends the output to a temp file
and then uses this temp file as input to the fortran frontend. Using a
-v shows the steps.
The g77 man page even says that limiting the preprocessing to #include's
#defines and #ifs. But its the fortran INCLUDE causing the problem in
this case. The simple way I've been using it in the past has worked for
the past 15 years the same way on many platforms. I would be surprised
if this support was suddenly changed.
More information about the Fortran
mailing list