I have Fortran code that uses included modules, and I'm wondering which environment variables really work to set the include path.
To test this, I used one of the NAG code examples.
It works:
$ gfortran e04ucfe.f90 -lnag_nag -I/opt/NAG/fll6a23dfl/nag_interface_blocks
This does not work:
$ export CPATH=/opt/NAG/fll6a23dfl/nag_interface_blocks
$ gfortran e04ucfe.f90 -lnag_nag
e04ucfe.f90:10.37:
USE nag_library, ONLY : nag_wp
1
Fatal Error: Can't open module file 'nag_library.mod' for reading at (1): No such file or directory
However, the GCC / GFortran documentation states that:
The gfortran compiler currently does not use any environment variables to control its operation above and above those that affect the gcc operation.
(see https://gcc.gnu.org/onlinedocs/gfortran/Environment-Variables.html and https://gcc.gnu.org/onlinedocs/gcc/Environment-Variables.html#Environment-Variables )
ltrace - gfortran , (, PATH), CPATH.
:
gfortran e04ucfe.f90 -lnag_nag `echo -I$CPATH | sed -e 's/:/ -I/'`
... ? CPATH gcc, , C/++, gfortran?
-, , CPATH gcc gfortran, -I?
: LIBRARY_PATH , -L/path/to/libs gfortran.