The RETURN statement transfers control from a subprogram to the calling program unit.
The RETURN statement takes the following form:
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 ... SUBROUTINE CHECK(X, Y, *, *, C) ... 50 IF (X) 60, 70, 80 60 RETURN 70 RETURN 1 80 RETURN 2 END
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: