Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 3/31/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

Procedure Pointers

A procedure pointer has the POINTER attribute and points to a procedure instead of a data object. It can be associated with an external procedure, a module procedure, an intrinsic procedure, or a dummy procedure that is not a procedure pointer. It can have an implicit or explicit interface, but the interface cannot be generic or elemental.

A procedure pointer can be one of the following:

Procedure Pointers as Named Pointers

You can declare a procedure pointer in a procedure declaration statement by including the POINTER attribute. For example:

PROCEDURE(QUARK), POINTER :: Q => NULL()

The above declares Q to be a procedure pointer with interface QUARK; it also initializes Q to be a disassociated pointer.

A named procedure pointer can also be declared by specifying the POINTER attribute in addition to the normal procedure declaration.

The following example uses a type declaration statement to declare a procedure pointer:

POINTER :: MyP
INTERFACE
  SUBROUTINE MyP(c,d)
    REAL, INTENT(INOUT) :: c
    REAL, INTENT(IN) :: d
  END SUBROUTINE MyP
END INTERFACE
REAL, EXTERNAL, POINTER :: MyR

The above specifies that MyP is a pointer to a subroutine with an explicit interface. It also specifies that MyR is a pointer to a scalar REAL function with an implicit interface.

Note that in a type declaration statement, you must specify the EXTERNAL attribute as well as the POINTER attribute when declaring the procedure pointer.