HP Fortran Programmer's Reference (September 2007)

HP Fortran statements
RETURN
Chapter 10452
RETURN
Returns control from a subprogram.
Syntax
RETURN [
scalar-integer-expression
]
scalar-integer-expression
is an optional scalar integer expression that is evaluated when the RETURN
statement is executed. It determines which alternate return is used.
Description
A RETURN statement can appear only in a subprogram.
An expression may appear in a RETURN statement only if alternate returns (one or more
asterisks) are specified as dummy arguments in the relevant FUNCTION, SUBROUTINE,orENTRY
statement of the subprogram. An expression with a value
i
in the range will return to the
i
th
asterisk argument (specified as *
label
) in the actual argument list. A normal return is
executed if
i
is not in the range 1 to
n
, where
n
is the number of dummy argument alternate
returns specified.
Examples
SUBROUTINE calc (y, z)
! Subroutine calc checks the range of y. If
! it exceeds the permitted range, it calls
! an error handler and stops the program
IF (y > ymax) GO TO 303
RETURN
! It returns to the caller of calc if the
! calculation proceeds to normal completion.
303 CALL err (3, ”OUT OF RANGE”)
STOP 303
END
Related statements
SUBROUTINE and FUNCTION