Purpose
The RETURN statement:
+-------------------------------IBM Extension--------------------------------+
+----------------------------End of IBM Extension----------------------------+
Format
>>-RETURN--+-----------------+--------------------------------->< | (1) | '-arith_expr------'
Notes:
|
+-------------------------------IBM Extension--------------------------------+
+----------------------------End of IBM Extension----------------------------+
Rules
arith_expr can be specified in a subroutine subprogram only, and it specifies an alternate return point. Letting m be the value of arith_expr, if 1 <= m <= the number of asterisks in the SUBROUTINE or ENTRY statement, the mth asterisk in the dummy argument list is selected. Control then returns to the invoking procedure at the statement whose statement label is specified as the mth alternate return specifier in the CALL statement. For example, if the value of m is 5, control returns to the statement whose statement label is specified as the fifth alternate return specifier in the CALL statement.
If arith_expr is omitted or if its value (m) is not in the range 1 through the number of asterisks in the SUBROUTINE or ENTRY statement, a normal return is executed. Control returns to the invoking procedure at the statement following the CALL statement.
Executing a RETURN statement terminates the association between the dummy arguments of the subprogram and the actual arguments supplied to that instance of the subprogram. All entities local to the subprogram become undefined, except as noted under Events Causing Undefinition.
A subprogram can contain more than one RETURN statement, but it does not require one. An END statement in a function or subroutine subprogram has the same effect as a RETURN statement.
Examples
CALL SUB(A,B) CONTAINS SUBROUTINE SUB(A,B) INTEGER :: A,B IF (A.LT.B) RETURN ! Control returns to the calling procedure ELSE
·
·
·
END IF END SUBROUTINE END
Related Information