Visible to Intel only — GUID: GUID-5E1DBB61-B299-4D41-872D-1FC9D627911F
Visible to Intel only — GUID: GUID-5E1DBB61-B299-4D41-872D-1FC9D627911F
INTERFACE
Statement: Defines an explicit interface for an external or dummy procedure. It can also be used to define a generic name for procedures, a new operator for functions, and a new form of assignment for subroutines.
INTERFACE [generic-spec]
[interface-body]...
[[MODULE]PROCEDURE [::]name-list]...
END INTERFACE [generic-spec]
generic-spec |
(Optional) Is one of the following:
|
interface-body |
Is one or more function or subroutine subprograms or a procedure pointer. An interface body must not contain a DATA, ENTRY, statement function, or FORMAT statement. An entry name can be used as a procedure name. The subprogram can contain a USE statement. It can also contain the prefix MODULE before FUNCTION or SUBROUTINE to indicate a separate module procedure. The subprogram can contain an 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. |
name-list |
Is the name of one or more nonintrinsic procedures that are accessible in the host. The MODULE keyword is only allowed if the interface block specifies a generic-spec and has a host that is a module, or accesses a module by use association. The characteristics of module procedures or internal procedures are not given in interface blocks, but are assumed from the module subprogram definitions or the USE associated interfaces. |
Description
Interface blocks can appear in the specification part of the program unit that invokes the external or dummy procedure.
A generic-spec can only appear in the END INTERFACE statement if one appears in the INTERFACE statement; they must be identical.
The characteristics specified for the external or dummy procedure must be consistent with those specified in the procedure's definition.
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 unless an IMPORT statement appears in an interface body.
Internal, module, and intrinsic procedures are all considered to have explicit interfaces. External procedures have implicit interfaces by default; when you specify an interface block for them, their interface becomes explicit. A procedure must not have more than one explicit interface in a given scoping unit. This means that you cannot include internal, module, or intrinsic procedures in an interface block, unless you want to define a generic name for them.
The function or subroutine named in the interface-body cannot have the same name as a keyword that specifies an intrinsic type.
A interface block containing generic-spec specifies a generic interface for the following procedures:
The procedures within the interface block
Any generic name, defined operator, or equals symbol that appears is a generic identifier for all the procedures in the interface block. For the rules on how any two procedures with the same generic identifier must differ, see Unambiguous Generic Procedure References.
The module procedures listed in the MODULE PROCEDURE statement
The module procedures must be accessible by a USE statement.
To make an interface block available to multiple program units (through a USE statement), place the interface block in a module.
The following rules apply to interface blocks containing pure procedures:
The interface specification of a pure procedure must declare the INTENT of all dummy arguments except pointer and procedure arguments.
A procedure that is declared pure in its definition can also be declared pure in an interface block. However, if it is not declared pure in its definition, it must not be declared pure in an interface block.
Example
The following example shows a simple procedure interface block with no generic specification:
SUBROUTINE SUB_B (B, FB)
REAL B
...
INTERFACE
FUNCTION FB (GN)
REAL FB, GN
END FUNCTION
END INTERFACE
The following shows another example:
!An interface to an external subroutine SUB1 with header:
!SUBROUTINE SUB1(I1,I2,R1,R2)
!INTEGER I1,I2
!REAL R1,R2
INTERFACE
SUBROUTINE SUB1(int1,int2,real1,real2)
INTEGER int1,int2
REAL real1,real2
END SUBROUTINE SUB1
END INTERFACE
INTEGER int
...