Additional source text may be included in the processing of
the source file via the
The source text to be included is identified by filename, which is a literal GNU Fortran character constant. The meaning and interpretation of filename depends on the implementation, but typically is a filename.
g77 treats it as a filename that it searches for
in the current directory and/or directories specified
-I command-line option.)
The effect of the
INCLUDE directive is as if the
included text directly replaced the directive in the source
file prior to interpretation of the program.
Included text may itself use
The depth of nested
INCLUDE references depends on
the implementation, but typically is a positive integer.
This virtual replacement treats the statements and
directives in the included text as syntactically distinct from
those in the including text.
Therefore, the first non-comment line of the included text
must not be a continuation line.
The included text must therefore have, after the non-comment
lines, either an initial line (statement), an
directive, or nothing (the end of the included text).
Similarly, the including text may end the
directive with a semicolon or the end of the line, but it
cannot follow an
INCLUDE directive at the end of its
line with a continuation line.
Thus, the last statement in an included text may not be
Any statements between two
INCLUDE directives on the
same line are treated as if they appeared in between the
respective included texts.
INCLUDE 'A'; PRINT *, 'B'; INCLUDE 'C'; END PROGRAM
If the text included by
INCLUDE 'A' constitutes
PRINT *, 'A' statement and the text included by
INCLUDE 'C' constitutes a
PRINT *, 'C' statement,
then the output of the above sample program would be
A B C
(with suitable allowances for how an implementation defines its handling of output).
Included text must not include itself directly or indirectly, regardless of whether the filename used to reference the text is the same.
INCLUDE is not a statement.
As such, it is neither a non-executable or executable
However, if the text it includes constitutes one or more
executable statements, then the placement of
is subject to effectively the same restrictions as those
on executable statements.
INCLUDE directive may be continued across multiple
lines as if it were a statement.
This permits long names to be used for filename.