Visible to Intel only — GUID: GUID-2673616E-E0F2-4668-B13E-8DE111BA8E98
Visible to Intel only — GUID: GUID-2673616E-E0F2-4668-B13E-8DE111BA8E98
ABSTRACT INTERFACE
Statement: Defines an abstract interface.
ABSTRACT INTERFACE
[interface-body]...
END INTERFACE
interface-body |
Is one or more function or subroutine subprograms or a procedure pointer. The interface body must not contain a statement function or a DATA, ENTRY, or FORMAT statement; an entry name can be used as a procedure name. The subprogram can contain a USE statement to import entities and types defined in a module. The subprogram can contain in IMPORT statement to make entities from the interfaces host scoping unit accessible to the interface body. Executable code and specification statements that are not used to specify characteristics of the subprogram or its dummy arguments in an interface body are ignored. |
Description
An abstract interface block defines an interface whose name can be used in a PROCEDURE declaration statement to declare subprograms with identical arguments and characteristics or to define interfaces of type bound procedures.
An abstract interface block cannot contain a PROCEDURE statement or a MODULE PROCEDURE statement.
Interface blocks can appear in the specification part of the program unit that invokes the external or dummy procedure.
An interface block must not appear in a block data program unit.
An interface block comprises its own scoping unit, and does not inherit anything from its host through host association.
The function or subroutine named in the interface-body cannot have the same name as a keyword that specifies an intrinsic type.
To make an interface block available to multiple program units (through a USE statement), place the interface block in a module.
Example
Previously, within an interface block, you needed to individually declare subroutines and functions that had the same argument keywords and characteristics. For example:
INTERFACE
SUBROUTINE SUB_ONE (X)
REAL, INTENT(IN) :: X
END SUBROUTINE SUB_ONE
SUBROUTINE SUB_TWO (X)
REAL, INTENT(IN) :: X
END SUBROUTINE SUB_TWO
...
END INTERFACE
Now you can use an abstract interface to specify a subprogram name for these identical arguments and characteristics. For example:
ABSTRACT INTERFACE
SUBROUTINE MY_INTERFACE (X)
REAL, INTENT(IN) :: X
END SUBROUTINE MY_INTERFACE
END INTERFACE
You can then use the subprogram in the abstract interface as a template in a PROCEDURE statement to declare procedures. For example:
PROCEDURE (MY_INTERFACE) :: SUB_ONE, SUB_TWO, ...