Searching for Include and .mod Files

Include files are brought into the program with the #include preprocessor directive or the INCLUDE statement. To locate such included files, the compiler searches by default for the standard include files in the directories specified in the INCLUDE environment variable. In addition, you can specify the compiler options, -I and -X.

Specifying and Removing Include Directory Search: -I, -X

You can use the -I option to indicate the location of include files and .mod files. To prevent the compiler from searching the default path specified by the INCLUDE environment variable, use -X option.

You can specify these options in the configuration files, ifc.cfg for IA-32 or efc.cfg for ItaniumŪ-based applications or on the command line.

Specifying an Include Directory, -Idir

Included files are brought into the program with a #include preprocessor directive or a Fortran INCLUDE statement. Use the -Idir option to specify an alternative directory to search for include files.

Files included by the Fortran INCLUDE statement are normally referenced in the same directory as the file being compiled. The -I option may be used more than once to extend the search for an INCLUDE file into other directories.

Directories are searched for include files in this order:

Compiling an Input File from a Different Directory

If you need to compile an input file that resides in a directory other than default (that is, the directory where you issue a compilation command) and if your code contains an INCLUDE statement, you must use the -Idir option on your command line. For example:

IA-32 applications:

prompt>ifc -Idir dir/file.f90

ItaniumŪ-based applications:

prompt>efc -Idir dir/file.f90

where dir is the directory path where the file, file.f90 , you need to compile resides.

Specifying the .mod Files Directory

The programs that require modules located in multiple directories can be compiled using the -Idir option to locate the .mod files (modules) that should be included in the program.  For specifying the directory to locate .mod files, see Searching and Locating the .mod Files in Large-Scale Projects.

Removing Include Directories, -X

Use the -X option to prevent the compiler from searching the default path specified by the INCLUDE environment variable.

You can use the -X option with the -I option to prevent the compiler from searching the default path for include files and direct it to use an alternate path. For example, to direct the compiler to search the path /alt/include instead of the default path, do the following:

IA-32 applications:

prompt>ifc -X -I/alt/include newmain.f

Itanium-based applications:

prompt>efc -X -I/alt/include newmain.f