Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-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.
Replies continue below

Recommended for you

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.
Back
Top