Previous topic |
Next topic |
Contents |
Contact z/OS |
Library |
PDF
Passing an alternate return code from Fortran to C++ z/OS Language Environment Writing Interlanguage Communication Applications SA38-0684-00 |
|
You can pass an alternate return code to a C++ routine from a Fortran subroutine by specifying the called Fortran subroutine in the extern "FORTRAN" linkage specification. The Fortran subroutine produces an alternate return code when alternate returns are specified as dummy arguments on the SUBROUTINE statement. In an all-Fortran application, the alternate returns provide a way
to return to a point in the calling program other than to the point
immediately following the CALL statement. The following example illustrates
how a Fortran routine would call a Fortran subroutine to use an alternate
return:
In this example, *22 and *66 specify two
labels (22 and 66) to which control can be passed rather than to the
point following the CALL statement. The corresponding subroutine would
be coded as follows:
When the FSUB subroutine executes the following RETURN statement,
control would pass to the calling program at the second alternate
return, at label 66.
In C++, you can use the fortrc() function and extern "FORTRAN" linkage specification to get the alternate return code from the Fortran RETURN statement of the Fortran call immediately preceding it. You must not have any other C++ code between the Fortran routine call and fortrc(), otherwise the result is undefined. In the following example, the C++ routine calls the subroutine
FSUB, whose SUBROUTINE and RETURN statements are shown above. The fortrc() function returns an alternate return code of 2.
You cannot pass return code values from a called C++ function to a calling Fortran routine. |
Copyright IBM Corporation 1990, 2014
|