g77 include files

by Juliet Kemp

After upgrading to etch recently, I had a plaintive email from a user saying that some Fortran software she had downloaded now wasn't compiling any more (when it had been previously).

The error message was pretty clear that the problem was with g77 not being able to find the relevant include file - but there it was, right in the directory.

It transpired after a little Googling that g77 (at least as of the version in etch) doesn't use the current directory or the source file directory to look for include files in. The problem was readily solved by adding -I. (note the dot!) in the configure file & running make clean;./configure;make.

However, this seems to me to be a strange decision - for my intuition, looking in the current directory and in particular the source file directory for desired files makes sense. I can't offhand find anything explaining why it works this way; and the fact that this code used to work fine implies that it's not "it's always been done this way" (although I've now upgraded all machines to etch so haven't got a sarge box kicking around to test!).

There's a bug report for gfortran stating that it does include files in the current working directory while g77 doesn't (with a patch fixing the problem); but this also states that g77 includes files in the same directory as the source file; which doesn't actually seem to be the case with this version. Curious.

(yes, we do still have people using Fortran here. Lots of people, in fact!)

4 Comments

Kake
2007-06-07 10:24:56
It's consistent with . not being in the default search path for executables. Regarding that, I understand it's a security issue; the choice of command to be executed shouldn't depend on your current working directory. Maybe the thinking here is along the same lines.
Juliet Kemp
2007-06-08 05:52:31
I can understand it with executables, but it doesn't seem as far as I can see to be the same sort of problem with include files. Unless it's just supposed to *match* the executables thing.
Lawrence D'Oliveiro
2007-06-09 00:00:31

In C, there are two different syntaxes:

#include "file"

if you want the search path to begin with the current directory, and

#include <file>

if you don't.

Does Fortran offer two different #include syntaxes too?

kdh8309
2007-06-10 08:39:34
yes