FORTRAN 77 Language Reference

ENTRY

The ENTRY statement defines an alternate entry point within a subprogram.

ENTRY en [([fa[, fa]])]

Parameter 

Description 

en

 Symbolic name of an entry point in a function or subroutine subprogram

fa

 Formal argument--it can be a variable name, array name, formal procedure name, or an asterisk specifying an alternate return label.

Description

Note these nuances for the ENTRY statement:

Procedure References by Entry Names

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.

Argument Correspondence

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.

Restrictions

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.

Examples

Example 1: Multiple entry points in a subroutine


       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.

Example 2: In the calling routine, you can call the above subroutine and entries as follows:


       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.

Example 3: Multiple entry points in a function:


       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