INTERFACE statement

Standard: F77 F90 F95 F2003 F2008 Example program


<Syntax>

[ ABSTRACT ] INTERFACE [ generic-spec ]

generic-spec ::= name
| ASSIGNMENT (=)
| OPERATOR (operator)
| read-or-write (form)

read-or-write ::= READ | WRITE
form ::= FORMATTED | UNFORMATTED

Fortran 2003 allows the ABSTRACT keyword; if this is present, generic-spec must not be present. Fortran 2003 also allows specification of defined input/output (of derived type).

The INTERFACE statement is the first statement of an interface block. The syntax of an interface block is as follows.

interface-stmt
      [ interface-spec ]...

end-interface-stmt

interface-spec ::= interface-body
| module-procedure-stmt

interface-body ::= function-stmt
specification-part
end-function-stmt
| subroutine-stmt
specification-part
end-subroutine-stmt

The module-procedure-stmt can only be used in an interface block whose INTERFACE statement has a generic-spec.

<Semantics>

The INTERFACE statement introduces an interface block, which may be an abstract interface block, a specific interface block or a generic interface block.

In Fortran 2003, an abstract interface block starts with the ABSTRACT keyword, and declares abstract interfaces (not actual procedures). These abstract interfaces may be used to declare actual procedures using the PROCEDURE declaration statement, or to declare deferred type-bound procedures.

A specific interface block starts with an INTERFACE statement with no generic-spec. It specifies the EXTERNAL attribute and an explicit interface for the procedures it describes, which must be dummy procedures or external procedures.

A generic interface block starts with an INTERFACE statement with a generic-spec. It adds the procedures it describes (in interface bodies) or lists (in module procedure statements) to the set of specific procedures for that generic identifier. If it contains any interface bodies, it also specifies the EXTERNAL attribute and an explicit interface for those procedures. An explicit interface is automatically provided for internal, intrinsic and module procedures; for external and dummy procedures, an explicit interface is required if the procedure

An explicit interface is also needed to be able to reference a procedure with an argument keyword, or in a context that requires it to be pure.

<Related>

END INTERFACE statement, EXTERNAL attribute, GENERIC statement, INTERFACE ASSIGNMENT statement, INTERFACE OPERATOR statement, MODULE PROCEDURE statement