Syntax of a (non-recursive) subroutine declaration:
SUBROUTINE < procname >[ (< dummy args >) ]< declaration of dummy args >
...
< declaration of local objects >
...
< executable stmts >
...
[ CONTAINS
< internal procedure definitions > ]
END [ SUBROUTINE [< procname > ] ]
SUBROUTINE s may contain internal procedures but only if they themselves are not already internal.
Figure 23: Schematic Diagram of a Subroutine
The structure is similar to that of the main PROGRAM unit except a SUBROUTINE can be parameterised (with arguments) and the type and kind of these must be specified in the declarations section. A SUBROUTINE may include calls to other program units either internal, external or visible by USE association (defined in a module and USE d in the procedure.
Return to corresponding overview page