7.9 RETURN Statement

The RETURN statement transfers control from a subprogram to the calling program unit.

The RETURN statement takes the following form:

RETURN [expr]

Is a scalar expression that is converted to an integer value if necessary.

The expr is only allowed in subroutines; it indicates an alternate return. (An alternate return is an obsolescent feature in Fortran 95 and Fortran 90.)

Rules and Behavior

When a RETURN statement is executed in a function subprogram, control is transferred to the referencing statement in the calling program unit.

When a RETURN statement is executed in a subroutine subprogram, control is transferred to the first executable statement following the CALL statement that invoked the subroutine, or to the alternate return (if one is specified).


The following shows how alternate returns can be used in a subroutine:

   CALL CHECK(A, B, *10, *20, C)
10 ...
20 ...
50   IF (X) 60, 70, 80
70   RETURN 1
80   RETURN 2

The value of X determines the return, as follows:

Note that an asterisk (*) specifies the alternate return. An ampersand (&) can also specify an alternate return in a CALL statement, but not in a subroutine's dummy argument list.

For More Information:

Previous Page Next Page Table of Contents