3.5. The INCLUDE Line

Source text can be imported from another file and included within a program file during processing. An INCLUDE line consists of the keyword INCLUDE followed by a character literal constant. The following is an example of an INCLUDE line:

INCLUDE  'MY_COMMON_BLOCKS'

The specified text is substituted for the INCLUDE line during compilation and is treated as if it were part of the original program source text. The Cray Fortran Compiler allows you to specify search path names on the Cray Fortran command line for locating files to be included. For more information on INCLUDE lines, see the Cray Fortran Compiler Commands and Directives Reference Manual.

The INCLUDE line provides a convenient way to include source text that is the same in several program units. For example, the specification of interface blocks or objects in common blocks may constitute a file that is referenced in the INCLUDE line.

The format for an INCLUDE line is as follows:

INCLUDE character_literal_constant

The character_literal_constant used cannot have a kind parameter that is a named constant.

The INCLUDE line is a directive (but not a compiler directive) to the compiler; it is not a Fortran statement.

The INCLUDE line is placed where the included text is to appear in the program.

The INCLUDE line must appear on one line with no other text except possibly a trailing comment. There can be no statement label.

The INCLUDE lines can be nested. That is, a second INCLUDE line may appear within the text to be included. The Fortran standard does not specify the permitted level of nesting, and the Cray Fortran Compiler imposes no limit. The text inclusion cannot be recursive at any level. For example, included text A cannot include text B, which includes text A.

A file intended to be referenced in an INCLUDE line cannot begin or end with an incomplete statement.

An example of a program unit with an INCLUDE line follows:

PROGRAM MATH
REAL, DIMENSION(10,5,79) :: X, ZT!  Some arithmetic
INCLUDE 'FOURIER'!  More arithmetic
   . . .
END

The source text in the file FOURIER in effect replaces the INCLUDE line.