Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 3/22/2024
Public
Document Table of Contents

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

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.

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 TEMPLATE (X)
  REAL, INTENT(IN) :: X
END SUBROUTINE TEMPLATE
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 (TEMPLATE) :: SUB_ONE, SUB_TWO, ...