Intel® Fortran Compiler 17.0 Developer Guide and Reference
Statement: Identifies the program unit as a main program and gives it a name.
[PROGRAM name]
[specification-part]
[execution-part]
[CONTAINS
internal-subprogram-part]
END[PROGRAM [name]]
name |
Is the name of the program. |
specification-part |
Is one or more specification statements, except for the following:
An automatic object must not appear in a specification statement. If a SAVE statement is specified, it has no effect. |
execution-part |
Is one or more executable constructs or statements, except for ENTRY or RETURN statements. |
internal-subprogram-part |
Is one or more internal subprograms (defining internal procedures). The internal-subprogram-part is preceded by a CONTAINS statement. |
The PROGRAM statement is optional. Within a program unit, a PROGRAM statement can be preceded only by comment lines or an OPTIONS statement.
The END statement is the only required part of a program. If a name follows the END statement, it must be the same as the name specified in the PROGRAM statement.
The program name is considered global and must be unique. It cannot be the same as any local name in the main program or the name of any other program unit, external procedure, or common block in the executable program.
A main program must not reference itself (either directly or indirectly).
The following is an example of a main program:
PROGRAM TEST
INTEGER C, D, E(20,20) ! Specification part
CALL SUB_1 ! Executable part
...
CONTAINS
SUBROUTINE SUB_1 ! Internal subprogram
...
END SUBROUTINE SUB_1
END PROGRAM TEST
The following shows another example:
PROGRAM MyProg
PRINT *, 'hello world'
END