ENTRY

Purpose

A function subprogram or subroutine subprogram has a primary entry point that is established through the SUBROUTINE or FUNCTION statement. The ENTRY statement establishes an alternate entry point for an external subprogram or a module subprogram.

Syntax



>>-ENTRY--entry_name--+-------------------------------+--------->
                      '-(--+---------------------+--)-'
                           '-dummy_argument_list-'
 
   .----------------------------------------------------.
   V                                                    |
>----+------------------------------------------------+-+------><
     +-RESULT--(--result_name--)----------------------+
     '-BIND--(--C--+-----------------------------+--)-'
                   '-,--NAME-- = --binding_label-'
 
 

entry_name
is the name of an entry point in a function subprogram or subroutine subprogram

+------------------------Fortran 2003 Draft Standard-------------------------+

binding_label
is a scalar character initialization expression

+---------------------End of Fortran 2003 Draft Standard---------------------+

Rules

The ENTRY statement cannot appear in a main program, block data program unit, internal subprogram, IF construct, DO construct, CASE construct, derived-type definition, or interface block.

+-------------------------------IBM Extension--------------------------------+

The ENTRY statement cannot appear in a CRITICAL, MASTER, PARALLEL, PARALLEL SECTIONS, SECTIONS, or SINGLE construct.

+----------------------------End of IBM Extension----------------------------+

An ENTRY statement can appear anywhere after the FUNCTION or SUBROUTINE statement (and after any USE statements) of an external or module subprogram, except in a statement block within a control construct, in a derived-type definition, or in an interface block. ENTRY statements are nonexecutable and do not affect control sequencing during the execution of a subprogram.

The result variable is result_name, if specified; otherwise, it is entry_name. If the characteristics of the ENTRY statement's result variable are the same as those of the FUNCTION statement's result variable, the result variables identify the same variable, even though they can have different names. Otherwise, they are storage-associated and must be all nonpointer, nonallocatable scalars of intrinsic (noncharacter) type. result_name can be the same as the result variable name specified for the FUNCTION statement or another ENTRY statement.

The result variable cannot be specified in a COMMON, DATA, integer POINTER, or EQUIVALENCE statement, nor can it have the PARAMETER, INTENT, OPTIONAL, SAVE, or VOLATILE attributes. The STATIC and AUTOMATIC attributes can be specified only when the result variable is not an allocatable object, an array or a pointer, and is not of character or derived type.

If the RESULT keyword is specified, the ENTRY statement must be within a function subprogram, entry_name must not appear in any specification statement in the scope of the function subprogram, and result_name cannot be the same as entry_name.

A result variable must not be initialized in a type declaration statement or DATA statement.

The entry name in an external subprogram is a global entity; an entry name in a module subprogram is not a global entity. An interface for an entry can appear in an interface block only when the entry name is used as the procedure name in an interface body.

At most one RESULT clause and at most one BIND clause may appear. They can appear in any order.

+------------------------Fortran 2003 Draft Standard-------------------------+

The BIND keyword implicitly or explicitly defines a binding label which specifies the name by which an entity is accessed from the C programming language. The result variable, if there is a result, must be a scalar that is interoperable. A binding label cannot be specified for a dummy argument. A dummy argument cannot be zero-sized. A dummy argument for a procedure with the BIND attribute must have interoperable types and type parameters, and cannot have the ALLOCATABLE, OPTIONAL, or POINTER attribute. A dummy argument to a procedure that has the BIND attribute must have interoperable type and type parameters, and cannot have the ALLOCATABLE, OPTIONAL, or POINTER attribute.

+---------------------End of Fortran 2003 Draft Standard---------------------+

In a function subprogram, entry_name identifies a function and can be referenced as a function from the calling procedure. In a subroutine subprogram, entry_name identifies a subroutine and can be referenced as a subroutine from the calling procedure. When the reference is made, execution begins with the first executable statement following the ENTRY statement.

The result variable must be defined prior to exiting from the function, when the function is invoked through that entry.

A name in the dummy_argument_list must not appear in the following places:

The order, number, type, and kind type parameters of the dummy arguments can differ from those of the FUNCTION or SUBROUTINE statement, or other ENTRY statements.

If a dummy argument is used in a specification expression to specify an array bound or character length of an object, you can only specify the object in a statement that is executed during a procedure reference if the dummy argument is present and appears in the dummy argument list of the procedure name referenced.

Recursion

An ENTRY statement can reference itself directly only if the subprogram statement specifies RECURSIVE and the ENTRY statement specifies RESULT. The entry procedure then has an explicit interface within the subprogram. The RESULT clause is not required for an entry to reference itself indirectly.

+---------------------------------Fortran 95---------------------------------+

Elemental subprograms can have ENTRY statements, but the ENTRY statement cannot have the ELEMENTAL prefix. The procedure defined by the ENTRY statement is elemental if the ELEMENTAL prefix is specified in the SUBROUTINE or FUNCTION statement.

+-----------------------------End of Fortran 95------------------------------+

If entry_name is of type character, its length cannot be an asterisk if the function is recursive.

+-------------------------------IBM Extension--------------------------------+

You can also call external procedures recursively when you specify the -qrecur compiler option, although XL Fortran disregards this option if a procedure specifies either the RECURSIVE or RESULT keyword.

+----------------------------End of IBM Extension----------------------------+

Examples

RECURSIVE FUNCTION FNC() RESULT (RES)
     
  ·
  ·
  ·
ENTRY ENT () RESULT (RES) ! The result variable name can be ! the same as for the function  
  ·
  ·
  ·
END FUNCTION

Related Information

IBM Copyright 2003