Intel® Fortran Compiler 16.0 User and Reference Guide

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. A function must end with END FUNCTION and a subroutine must end with END SUBROUTINE.

The subprogram 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. It can also contain the prefix MODULE before FUNCTION or SUBROUTINE to indicate a separate module procedure.

name-list

Is the name of one or more procedures or module 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 are not given in interface blocks, but are assumed from the module subprogram definitions.

If the prefix MODULE appears in interface-body, you can only specify one name.

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.

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:

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:

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
...

See Also