XL Fortran for AIX 8.1

Language Reference



An END statement indicates the end of a program unit or procedure.


        +-BLOCK DATA--+-----------------+-+
        |             '-BLOCK_DATA_name-' |
        |           '-FUNCTION_name-'     |
        |         '-MODULE_name-'         |
        |          '-PROGRAM_name-'       |


The END statement is the only required statement in a program unit.

For an internal subprogram or module subprogram, you must specify the FUNCTION or SUBROUTINE keyword on the END statement. For block data program units, external subprograms, the main program, modules and interface bodies, the corresponding keyword is optional.

The program name can be included in the END PROGRAM statement only if the optional PROGRAM statement is used and if the name is identical to the program name specified in the PROGRAM statement.

The block data name can be included in the END BLOCK DATA statement only if it is provided in the BLOCK DATA statement and if the name is identical to the block data name specified in the BLOCK DATA statement.

If a name is specified in an END MODULE, END FUNCTION, or END SUBROUTINE statement, it must be identical to the name specified in the corresponding MODULE, FUNCTION, or SUBROUTINE statement, respectively.

The END, END FUNCTION, END PROGRAM, and END SUBROUTINE statements are executable statements that can be branched to. In both fixed source form and Fortran 90 free source form formats, no other statement may follow the END statement on the same line. In fixed source form format, you cannot continue a program unit END statement, nor can a statement whose initial line appears to be a program unit END statement be continued.

The END statement of a main program terminates execution of the program. The END statement of a function or subroutine has the same effect as a RETURN statement. An inline comment can appear on the same line as an END statement. Any comment line appearing after an END statement belongs to the next program unit.


END SUBROUTINE ! Reference to subroutine name SUB is optional END PROGRAM TEST

Related Information

Chapter 7, Program Units and Procedures

[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]