Searching for Include and .mod Files

Include files are brought into a program with the #include preprocessor directive or a Fortran INCLUDE statement.

Directories are searched for include files in this order:

  1. Directory of the source file that contains the include

  2. Directories specified by the -Idir options

  3. Current working directory

  4. Directories specified with the FPATH environment variable

The locations of directories to be searched are known as the include file path. More than one directory can be specified in the include file path.

A module (.mod) file is specified in a program by a USE statement. Module files can be located in multiple directories.

Directories are searched for .mod files in this order:

  1. Directory of the source file that contains the USE statement

  2. Directories specified by the -module path option

  3. Directories specified by the -Idir option

  4. Current working directory

  5. Directories specified with the FPATH environment variable

Specifying and Removing an Include File Path

You can use the  -Idir option to indicate the location of include files and module files.

To prevent the compiler from searching the default path specified by the FPATH environment variable, use the -X option.

You can specify these options in the configuration file, ifort.cfg, or on the command line.

For example, to direct the compiler to search the path /alt/include instead of the default path, use the following command line:

ifort -X -I /alt/include newmain.f