FORTRAN Reference Manual

Program Units
FORTRAN Reference Manual528615-001
4-9
Saving Values Computed in Procedure Subprograms
The following statements declare a subroutine, RATE, in which the third and fourth
dummy arguments are the labels of executable statements; and a CALL statement that
invokes the RATE subroutine:
CALL rate (tonnage, distance, *500, *600)
500 CONTINUE
C -- Arrive here if more than 1000 tons
. . .
600 CONTINUE
C -- Arrive here if less than or equal 1000 tons
END
SUBROUTINE RATE( tons, dist, *, * )
IF (tons .GT. 1000) iexp = 1
iexp = 2
. . .
RETURN iexp
END
IEXP must be an integer expression. In the preceding example, if the argument TONS
is greater than 1000, RATE transfers control to the statement labeled 500; if TONS is
less than or equal to 1000, RATE transfers control to the statement labeled 600. If
IEXP is not equal to 1 or 2, RATE returns to the statement following the CALL
statement.
Saving Values Computed in Procedure Subprograms
Executing a RETURN or END statement normally terminates the association of actual
arguments with dummy arguments in a subroutine or external function subprogram,
and causes the subprogram’s local variables and arrays to become undefined.
However, entities in common blocks and local entities named in DATA statements or
SAVE statements remain defined, also after a subprogram returns.
The SAVE statement cannot include dummy argument names, procedure names, or
names of entities in common blocks.
If you use a SAVE statement without specifying any names, FORTRAN saves the
values of all allowable entities in the subprogram.