Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

What is the different between "return 1" and "return"? 1

Status
Not open for further replies.

magicking

Mechanical
Joined
May 5, 2004
Messages
10
Location
CA
What is the different between "return 1" and "return"?
 
The simple RETURN just returns from the subroutine to whatever followed the CALL statement in the calling program. RETURN 1 returns to the first alternate return point designated in the CALL statement argument list. For each alternate return possible from the called subroutine (not from a function subprogram), there is an asterisk character ('*') in the dummy argument list. In the calling program, the corresponding return points are inserted in the CALL statement in the form: '*n' where the "n" are the statement labels of the statements to which control may be passed when the RETURN n occurs. For example:

Calling program:

...
CALL SUB1(X,Y,*10)
Y= ....
...
10 Z= ....


SUBROUTINE SUB1(ARG1,ARG2,*)
...
ARG2 = ...
IF(ARG2.LE.0)THEN
...
RETURN 1
ELSE
...
RETURN
END IF
...


The subroutine will specify the alternate return (to statement labeled 10 in the calling program) if ARG2 is not positive. Otherwise return is made to the line after the CALL.

All of this is found in any good Fortran reference, available in textbook form or online.

RAR
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top