Fortran's alternate returns mechanism is obsolescent and should not be used if portability is an issue. There is no equivalent in C to alternate returns, so the only concern would be for a C routine calling a Fortran routine with alternate returns.
The Sun Fortran implementation returns the int value of the expression on the RETURN statement. This is implementation dependent and its use should be avoided.
Table 11-17 Alternate Returns
C calls Fortran |
Running the Example |
---|---|
int altret_ ( int * ); main () { int k, m ; k =0; m = altret_( &k ) ; printf( "%d %d\n", k, m); } ------------------------------ SUBROUTINE ALTRET( I, *, *) INTEGER I I = I + 1 IF(I .EQ. 0) RETURN 1 IF(I .GT. 0) RETURN 2 RETURN END
|
demo% cc -c tst.c demo% f77 -o alt alt.f tst.o alt.f: altret: demo% alt 1 2
The C routine receives the return value 2 from the Fortran routine because it executed the RETURN 2 statement. |