Procedure pointers (Fortran 2003)

A procedure pointer is a procedure that has the EXTERNAL and POINTER attribute. A derived type component which has been declared with the PROCEDURE statement can be a procedure pointer.

A procedure pointer points at a procedure rather than a data object. A procedure pointer can be associated in the same way as a dummy procedure with an external procedure, a module procedure, an intrinsic procedure, or a dummy procedure that is not a procedure pointer. Fortran 2008 beginsA procedure pointer can also be associated with an internal procedure. However, an internal procedure cannot be invoked using a procedure pointer after the host instance of the internal procedure completes its execution. Fortran 2008 ends Procedure pointers can have both an explicit and implicit interface, can be structure components and can be associated using procedure pointer assignment.

A dummy procedure with the pointer attribute is a dummy procedure pointer and its associated actual argument is a procedure pointer.

A procedure pointer shall be storage associated only with another procedure pointer; either both interfaces shall be explicit (the characteristics are the same) or both interfaces shall be implicit (both interfaces will be functions or subroutines with the same type and type parameters).

Although both type-bound procedures and procedure pointer components are invoked through an object , the type-bound procedure which is executed depends upon the type of the invoking object whereas procedure pointer components depend upon the value. The PASS attribute defines the passed-object dummy argument of the procedure pointer component

Examples

PROCEDURE(PROC), POINTER :: PTR