Passing an alternate return code from Fortran to C
You can pass an alternate return code to a C routine from a Fortran subroutine by specifying the called Fortran subroutine in the #pragma linkage directive. The Fortran subroutine will produce an alternate return code when alternate returns are specified as dummy arguments on the SUBROUTINE statement.
CALL FSUB (ARG1, *22, ARG2, *66)
SUBROUTINE FSUB (DARG1, DARG2, *, *)
RETURN 2
There is no alternate return point feature in C. However, if you specify the RETURNCODE suboption on the #pragma linkage directive in your C routine, you can use the fortrc() function to get the alternate return code from the RETURN statement in the Fortran subroutine. The fortrc() function reference applies to the call to Fortran immediately preceding it; you must not have any C code between the Fortran subroutine and the fortrc() function reference.
#includes <stdlib.h>
#pragma linkage (fsub, FORTRAN, RETURNCODE)
void fsub (float, float);
int rc:
⋮
fsub(1.0,2.0);
rc=fortrc();
⋮
The RETURNCODE suboption is optional. It indicates to the C compiler that fsub is a Fortran routine returning an alternate return code. You cannot pass return code values from a called C function to a calling Fortran routine.