On 2006-05-17 08:17-0700 Alan W. Irwin wrote:
> On 2006-05-17 02:40-0400 Jim Dishaw wrote:
>> Since I build in a seperate directory from the source directory (taking
>> advantage of VPATH), the Fortran compiler could not find the .mod and
>> include files used in the f95 bindings build process. The solution was
>> simple, -I. needed to get added to FCFLAGS (I also added it to FFLAGS
>> for good measure). I would advocate that -I. gets added by default by
>> autoconf/automake so that the VPATH builds are supported.
> Are you talking about the fortran compilation that occurs in bindings/f95 in
> the build tree? For that case, gfortran does not need a -I. option since
> (a) it generates the *.mod files in the current directory (by default)
> (which is in the build tree so a separated build tree shouldn't matter),
> and (b) assumes the *.mod files that are required by the "use" statement
> are also in the current (build) directory by default so in that case -I.
> is not needed.
I was able to replicate the problem outside of the makefile. The
problem is not with the USE statement (that automatically looks in the
current directory). The problem is with the INCLUDE statement. Here
is the scenario:
Current directory: /somewhere
WRITE(*,*) 'Hello world'
END PROGRAM foo
The location of bar.inc is in the current directory (/somewhere). If
you attempt to compile via the following command:
gfortran -o foo /anywhere/foo.f90
The gfortran compiler will not search the current directory for the
INCLUDE file--it will search the directory that contains the file that
is being compiled (/anywhere in this case). If you want to search the
current directory, -I. needs to be added as a compiler option.
> Are you perhaps talking about the needs of a different compiler which also
> places *.mod files in the current (build) directory by default, but needs
> the -I. option to find them again?
The gfortran compiler exhibits this behaviour with INCLUDE files not
with USE statements. The Intel ifort compiler searches the current
directory and the source file directory for the INCLUDE file.
> If I have interpreted what you said correctly, then the solution is to
> replace the current
> AM_FCFLAGS = -I$(srcdir)
> AM_FCFLAGS = -I$(srcdir) -I.
> in bindings/f95/Makefile.am.
> Does that solve your issue?
That would correct the problem. The question is whether this a design
feature or a bug in the gfortran compiler. I have submitted a bug
report to GCC to see what they say.
> Also, out of curiosity which fortran compiler are you using?
This was with the GNU gfortran (built from CVS 20050510)