02.07.2013 Views

HP Fortran Programmer's Reference

HP Fortran Programmer's Reference

HP Fortran Programmer's Reference

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>HP</strong> <strong>Fortran</strong> statements<br />

RETURN<br />

RETURN<br />

Returns control from a subprogram.<br />

Syntax<br />

RETURN [scalar-integer-expression]<br />

scalar-integer-expression<br />

Description<br />

418<br />

is an optional scalar integer expression that is evaluated when the RETURN<br />

statement is executed. It determines which alternate return is used.<br />

A RETURN statement can appear only in a subprogram.<br />

An expression may appear in a RETURN statement only if alternate returns (one or more<br />

asterisks) are specified as dummy arguments in the relevant FUNCTION, SUBROUTINE, orENTRY<br />

statement of the subprogram. An expression with a value i in the range will return to the ith<br />

asterisk argument (specified as *label) in the actual argument list. A normal return is<br />

executed if i is not in the range 1 to n, wheren is the number of dummy argument alternate<br />

returns specified.<br />

Examples<br />

SUBROUTINE calc (y, z)<br />

! Subroutine calc checks the range of y. If<br />

! it exceeds the permitted range, it calls<br />

! an error handler and stops the program<br />

IF (y > ymax) GO TO 303<br />

RETURN<br />

! It returns to the caller of calc if the<br />

! calculation proceeds to normal completion.<br />

303 CALL err (3, ”OUT OF RANGE”)<br />

STOP 303<br />

END<br />

Related statements<br />

SUBROUTINE and FUNCTION<br />

Chapter 10

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!