The INCLUDE statement directs the compiler to stop reading statements from the current file and read statements in an included file or text module.
The INCLUDE statement takes one of the following forms:
The form of the file name must be acceptable to the operating system, as described in your system documentation.
On Tru64 UNIX, Linux, WNT, and W9* systems, you can only use /[NO]LIST if you specify the compiler option that sets OpenVMS defaults.
The form of the file name must be acceptable to the operating system, as described in your system documentation.
An INCLUDE statement can appear anywhere within a scoping unit. The statement can span more than one source line, but no other statement can appear on the same line. The source line cannot be labeled.
An included file or text module cannot begin with a continuation line, and each Fortran statement must be completely contained within a single file.
An included file or text module can contain any source text, but it cannot begin or end with an incomplete Fortran statement.
The included statements, when combined with the other statements in the compilation, must satisfy the statement-ordering restrictions shown in Figure 2-1.
Included files or text modules can contain additional INCLUDE statements, but they must not be recursive. INCLUDE statements can be nested until system resources are exhausted.
When the included file or text module completes execution, compilation resumes with the statement following the INCLUDE statement.
Examples
In Example 14-1, a file named COMMON.FOR (in the current working directory) is included and read as input.
Example 14-1 Including Text from a File
Main Program File COMMON.FOR File
PROGRAM
INCLUDE 'COMMON.FOR' INTEGER, PARAMETER :: M=100
REAL, DIMENSION(M) :: Z REAL, DIMENSION(M) :: X, Y
CALL CUBE COMMON X, Y
DO I = 1, M
Z(I) = X(I) + SQRT(Y(I))
...
END DO
END
SUBROUTINE CUBE
INCLUDE 'COMMON.FOR'
DO I=1,M
X(I) = Y(I)**3
END DO
RETURN
END
The file COMMON.FOR defines a named constant M, and defines arrays X and Y as part of blank common.
For More Information: