The current directory is /somewhere and you want to compile a file in the
directory /anywhere/foo.f90.  The foo.f90 file looks like

PROGRAM foo

INCLUDE 'bar.inc'

WRITE(*,*) 'Hello world'

END PROGRAM foo

The file bar.inc is located in /somewhere, the current directory.  You attempt
to compile the file with the command

gfortran -o test /anywhere/foo.f90

The compiler exits with the error that bar.inc cannot be found.  The solution
for the build to occur is to either

a) Place bar.inc into /anywhere
b) Specify -I. when compiling

Why this may be a bug:

- The behaviour for the USE statement is different--gfortran will search both
the current directory and the source file directory.

- If you compare this behaviour to the Intel Fortran compiler (for comparison
purposes only), the behaviour for both the USE and INCLUDE is the same and
matches the behaviour that gfortran has for the USE statement.

This behaviour causes problems if you perform a VPATH style build.


-- 
           Summary: gfortran does not search current directory for INCLUDE
                    files
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jim at dishaw dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27653

Reply via email to