HP Fortran Programmer's Reference (September 2007)

Language elements
INCLUDE line
Chapter 2 53
INCLUDE line
The INCLUDE line is a directive to the compiler, not a Fortran 90 statement. It causes the
compiler to insert text into a program before compilation. The inserted text is substituted for
the INCLUDE line and becomes part of the compilable source text. The format of an INCLUDE
line is:
INCLUDE
char-literal-const
where
char-literal-const
is the name of a file containing the text to be included. The
character literal constant must not have a kind parameter that is a named constant.
If
char-literal-const
is only a filename (in other words, no pathname is specified), the
compiler searches a user-specified path. You can use the -I
dir
option to tell the compiler
where to search for files to be included.
The INCLUDE line must appear on one line with no other text except possibly a trailing
comment. There must be no statement label. This means, for example, that it is not possible to
branch to it, and it cannot be the action statement that is part of an IF statement. Putting a
second INCLUDE or another Fortran 90 statement on the same line using a semicolon as a
separator is not permitted. Continuing an INCLUDE line using an ampersand is also not
permitted.
The text of the included file must consist of complete Fortran 90 statements.
INCLUDE lines may also be nested. That is, a second INCLUDE line may appear within the text
to be included, and the text that it includes may also have an INCLUDE line, and so on. HP
Fortran has a maximum INCLUDE line nesting level of 10. However, the text inclusion must
not be recursive at any level; for example, included text A must not include text B if B
includes text A.
The following are example INCLUDE lines:
INCLUDE ”MY_COMMON_BLOCKS”
INCLUDE ”/usr/include/machine_parameters.h”
In the next example, the INCLUDE line occurs in the executable part of a program and supplies
the code that uses the input value from the preceding READ statement:
READ *, theta
INCLUDE ”FUNCTION_CALCULATION”