Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP Fortran Compiler for HP-UX: HP Fortran Programmer's Reference > Chapter 10 HP Fortran statements

RETURN

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Glossary

 » Index

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, or ENTRY statement of the subprogram. An expression with a value i in the range will return to the ith 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

Related concepts

For more information about returning from a procedure call, see “Returning from a procedure reference”.

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© Hewlett-Packard Development Company, L.P.