FORTRAN 77 Language Reference


The INCLUDE @ statement inserts a file into the source program.

INCLUDE 'file'




Name of the file to be inserted 

INCLUDE "file"


The contents of the named file replace the INCLUDE statement.

Search Path

If the name referred to by the INCLUDE statement begins with the character /, then it is taken by f77 to mean the absolute path name of the INCLUDE file. Otherwise, f77 looks for the file in the following directories, in this order:

  1. The directory that contains the source file with the INCLUDE statement

  2. The directories that are named in the -Iloc options

  3. The current directory in which the f77 command was issued

  4. The directories in the default list. For a standard install, the default list is:

    /opt/SUNWspro/SC5.0/include/f77 /usr/include

    For a non-standard install to a directory /mydir/, the default list is:

    /mydir/SUNWspro/SC5.0/include/f77 /usr/include

The release number, SC5.0, varies with the release of the set of compilers.

These INCLUDE statements can be nested ten deep.

Preprocessor #include

The paths and order searched for the INCLUDE statement are not the same as those searched for the preprocessor #include directive, described under -I in the Fortran User's Guide. Files included by the preprocessor #include directive can contain #defines and the like; files included with the compiler INCLUDE statement must contain only FORTRAN statements.

VMS Logical File Names in the INCLUDE Statement

f77 interprets VMS logical file names on the INCLUDE statement if:


Example 1: INCLUDE, simple case:

       INCLUDE 'stuff'

The above line is replaced by the contents of the file stuff.

Example 2: INCLUDE, search paths:

For the following conditions:

In this example, f77 seeks const.h in these directories, in the order shown.

For a standard install, f77 searches these directories:

For a non-standard install to a directory /mydir, it searches these directories: