On Saturday, May 23, 2020 at 12:53:54 PM UTC-4, Steve Lionel wrote:
> ..
> Alternate return is not part of the current Fortran language. How it is
> implemented, for compilers that still support it, is "processor-dependent".
> ..
In the above comment, it's unclear what is meant by "Alternate return is not part of the current Fortran language."
Fortran does support alternate returns as part of the current standard even as the standard marks it an obsolescent feature. Alternate returns are actually more useful than some of the more questionable bugs in the standard such as "implied save" that masquerade as features. Owing to the need for conforming processors to have support for alternate returns, the implementations for this facility can likely provide a route to brainstorm and prototype a better and much-needed exception handling system in the language e.g.,
https://github.com/j3-fortran/fortran_proposals/issues/172#issuecomment-628971119
Here's what the 18-007r1 document toward Fortran 2018 states re: the RETURN statement:
19 15.6.2.7 RETURN statement
20 R1542 return-stmt is RETURN [ scalar-int-expr ]
21 C1575 (R1542) The return-stmt shall be in the inclusive scope of a function or subroutine subprogram.
22 C1576 (R1542) The scalar-int-expr is allowed only in the inclusive scope of a subroutine subprogram.
23 1 Execution of the RETURN statement completes execution of the instance of the subprogram in which it appears.
24 If the expression appears and has a value n between 1 and the number of asterisks in the dummy argument list, the CALL statement
25 that invoked the subroutine branches (11.2) to the branch target statement identified by the nth alternate return specifier in the
26 actual argument list of the referenced procedure. If the expression is omitted or has a value outside the required range, there is no
27 transfer of control to an alternate return.
C programming language doesn't really have a concept of "alternate returns".
Besides constraint C1554 in section 15.6.2 Procedures defined by subprograms of the Fortran standard effectively disallows the use of alternate returns in the context of interoperability with C.
11 C1554 If proc-language-binding-spec is specified for a procedure, each of its dummy arguments shall be an inter
12 operable procedure (18.3.6) or a variable that is interoperable (18.3.4, 18.3.5), assumed-shape, assumed
13 rank, assumed-type, of type CHARACTER with assumed length, or that has the ALLOCATABLE or
14 POINTER attribute.