Top: f77 Up: 13 - Statements
Previous: 13,60,4 - PARAMETER_Statements Next: 13,62 - TYPE
Section 13,61: SUBROUTINE
Begins a subroutine subprogram and names the dummy arguments. The
CALL statement transfers control to a subroutine subprogram; a
RETURN or END statement returns control to the calling program
unit. Statement format:
SUBROUTINE nam [([p[,p]...])]
nam Is a symbolic name for the subroutine. The name must
be unique among all global names in the program.
p Is an unsubscripted variable name specifying a dummy argument.
An asterisk (*) as a dummy argument specifies that the
actual argument is an alternate return argument.
The arguments must agree in order, number, and type with the actual
arguments of the statement invoking the subroutine. A dummy
argument must not be defined as an array with more elements than
the actual argument holds. When control transfers to the
subroutine, the values of any actual arguments in the CALL
statement are associated with any corresponding dummy arguments in
the SUBROUTINE statement. The statements in the subprogram are
then executed.
The SUBROUTINE statement must be the first statement of a
subroutine, unless an OPTIONS statement is specified.
A subroutine subprogram cannot contain a FUNCTION statement, a
BLOCK DATA statement, a PROGRAM statement, or another SUBROUTINE
statement.
ENTRY statements are allowed to specify multiple entry points in
the subroutine.
The array declarator for a dummy argument can itself contain
integer values that are dummy arguments or are references to a
common block, providing for adjustable size arrays in subroutines.
The upper bound of the array declarator for a dummy argument can be
specified as an asterisk, in which case the upper bound of the
dummy argument assumes the size of the upper bound of the actual
argument. The size in a character string declarator for a dummy
argument can be specified as an asterisk in parentheses, in which
case the size of the actual argument is passed to the dummy
argument.
The values of the actual arguments in the invoking program unit
become the values of the dummy arguments in the function. If you
modify a dummy argument, the corresponding actual argument in the
invoking program unit is also modified; the actual argument must be
a variable if it is to be modified.
If the actual argument is a character constant, the dummy argument
can be either character or numeric in type, unless the name of the
subprogram being invoked is a dummy argument in the invoking
program unit. If the actual argument is a Hollerith constant, the
dummy argument must be numeric.
Top: f77 Up: 13 - Statements
Previous: 13,60,4 - PARAMETER_Statements Next: 13,62 - TYPE