Visible to Intel only — GUID: GUID-BCA7A394-29A5-4464-B18E-FBF8A8D8CF9F
Visible to Intel only — GUID: GUID-BCA7A394-29A5-4464-B18E-FBF8A8D8CF9F
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:
A named pointer (described below)
A derived-type component (See Procedure Pointers as Derived-Type Components.)
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.