The ENTRY statement defines an alternate entry point within a subprogram.
|Symbolic name of an entry point in a function or subroutine subprogram|
|Formal argument--it can be a variable name, array name, formal procedure name, or an asterisk specifying an alternate return label.|
Note these nuances for the ENTRY statement:
An ENTRY name used in a subroutine subprogram is treated like a subroutine and can be referenced with a CALL statement. Similarly, the ENTRY name used in a function subprogram is treated like a function and can be referenced as a function reference.
An entry name can be specified in an EXTERNAL statement and used as an actual argument. It cannot be used as a dummy argument.
Execution of an ENTRY subprogram (subroutine or function) begins with the first executable statement after the ENTRY statement.
The ENTRY statement is a nonexecutable statement.
The entry name cannot be used in the executable statements that physically precede the appearance of the entry name in an ENTRY statement.
The formal arguments of an ENTRY statement need not be the same in order, number, type, and name as those for FUNCTION, SUBROUTINE, and other ENTRY statements in the same subprogram. Each reference to a function, subroutine, or entry must use an actual argument list that agrees in order, number, type, and name with the dummy argument list in the corresponding FUNCTION, SUBROUTINE, or ENTRY statement.
Alternate return arguments in ENTRY statements can be specified by placing asterisks in the dummy argument list. Ampersands are valid alternates. @ ENTRY statements that specify alternate return arguments can be used only in subroutine subprograms, not functions.
An ENTRY statement cannot be used within a block IF construct or a DO loop.
If an ENTRY statement appears in a character function subprogram, it must be defined as type CHARACTER with the same length as that of a function subprogram.
SUBROUTINE FIN( A, B, C ) INTEGER A, B CHARACTER C*4 ... RETURN ENTRY HLEP( A, B, C ) ... RETURN ENTRY MOOZ ... RETURN END
In the above example, the subroutine FIN has two alternate entries: the entry HLEP has an argument list; the entry MOOZ has no argument list.
INTEGER A, B CHARACTER C*4 ... CALL FIN( A, B, C ) ... CALL MOOZ ... CALL HLEP( A, B, C ) ...
In the above example, the order of the call statements need not match the order of the entry statements.
REAL FUNCTION F2 ( X ) F2 = 2.0 * X RETURN ENTRY F3 ( X ) F3 = 3.0 * X RETURN ENTRY FHALF ( X ) FHALF = X / 2.0 RETURN END