Intel® Fortran Compiler 18.0 Developer Guide and Reference

PROCEDURE

Statement: Declares procedure pointers, dummy procedures, and external procedures.

PROCEDURE ([proc-interface]) [[, proc-attr-spec]... :: ] proc-decl-list

proc-interface

(Optional) Is the name of an interface, an intrinsic type specifier, or a derived-type TYPE statement.

If an interface name is specified, it must be the name of an abstract interface, a procedure that has an explicit interface, or a procedure pointer. It must have been previously declared and it cannot be the same as a keyword that specifies an intrinsic type.

If proc-interface is a type specifier, the declared procedures or procedure pointers are functions that have implicit interfaces and the specified result type. If a type is specified for an external function, its function definition must specify the same result type and type parameters.

proc-attr-spec

(Optional) Is one of the following attributes:

  • PUBLIC

  • PRIVATE

  • BIND (C [, NAME = init-expr])
    This is also called a language-binding-spec. The init-expr is a scalar character constant expression of default character kind. If NAME= is specified, there can only be one proc-decl item, which cannot have the POINTER attribute or be a dummy procedure.

  • INTENT(INOUT)

  • OPTIONAL

  • POINTER

  • PROTECTED

  • SAVE

Each proc-attr-spec gives the corresponding attribute to all procedures declared in that statement.

If a procedure entity has the INTENT attribute or SAVE attribute, it must also have the POINTER attribute.

proc-decl-list

Is one or more of the following:

procedure-name [=> null-init]
where null-init is a reference to intrinsic function NULL with no arguments. If => null-init appears, the procedure must have the POINTER attribute.

Description

A PROCEDURE statement declares procedure pointers, dummy procedures, and external procedures. It specifies the EXTERNAL attribute for all entities in the proc-decl-list.

You cannot use the PROCEDURE statement to identify a BLOCK DATA subprogram.

If => null-init appears, it specifies that the initial association status of the corresponding procedure entity is disassociated. It also implies the SAVE attribute.

You can also declare procedures by using an EXTERNAL statement or a procedure component definition statement.

If the BIND attribute is specified for a procedure, each dummy argument must be:

If the BIND attribute is specified for a function, the function result must be an interoperable scalar variable.

A Fortran procedure is interoperable if it has the BIND attribute; that is, if its interface is specified with a language-binding-spec.

The ALLOCATABLE or POINTER attribute must not be specified for a default-initialized dummy argument of a procedure that has a BIND attribute.

A dummy argument of a procedure that has a BIND attribute must not have both the OPTIONAL and VALUE attributes.

A variable that is a dummy argument of a procedure that has a BIND attribute must be of interoperable type or assumed type.

When a procedure whose interface has the BIND attribute is called, any actual argument corresponding to a dummy argument with the ALLOCATABLE or POINTER attribute is passed by C descriptor. Similarly, if a Fortran procedure with a BIND attribute has such dummy arguments, they are received by C descriptor.

Example

Consider the following:

PROCEDURE (NAME_TEMP) :: NAME37

The above declares NAME37 to be a procedure with an identical interface to that of NAME_TEMP.

The following are equivalent:

PROCEDURE (INTEGER) X
INTEGER, EXTERNAL :: X

Consider the following:

ABSTRACT INTERFACE
  FUNCTION SIM_FUNC (X)
    REAL, INTENT (IN) :: X
    REAL :: SIM_FUNC
  END FUNCTION SIM_FUNC
END INTERFACE

INTERFACE
  SUBROUTINE SUB2 (X)
    REAL, INTENT (IN) :: X
  END SUBROUTINE SUB2
END INTERFACE

The following shows external and dummy procedures with explicit interfaces:

PROCEDURE (SIM_FUNC) :: VMAC, KAPPA
PROCEDURE (SUB2) :: PRINGLES

The following shows procedure pointers with an explicit interface, one initialized to NULL():

PROCEDURE (SIM_FUNC), POINTER :: P1, R1 => NULL()
PROCEDURE (SIM_FUNC), POINTER :: KAPPA_POINTER

The following shows a derived type with a procedure pointer component:

TYPE MEMO_TYPE
  PROCEDURE (SIM_FUNC), POINTER :: COMPONENT
END TYPE MEMO_TYPE

The following shows a variable of the above type:

TYPE (MEMO_TYPE) :: STRUCTA

The following shows an external or dummy function with an implicit interface:

PROCEDURE (INTEGER) :: PHIL0

See Also