If a procedure is internal to a program unit (i.e. a program, module or external procedure) then it can be assumed that the compiler will have all the information that is needed to compile that unit. In other words the compiler has the ability to look ahead to the CONTAINS section of the unit and to extract any information that is needed concerning the interface.
If a procedure is defined in a MODULE (see the next topic) then it can be used within a program unit provided that a corresponding USE statement is supplied before the call. A USE statement provides the required interface information.
If a call is made from a program unit to an external procedure, then an INTERFACE statement may be used to supply all the external information that is needed in order to handle the procedure.
Procedures of types 1,2 and 3 are said to have an explicit interface otherwise the interface is implicit.
For implicit procedures, the EXTERNAL statement in the form:
may be used to specify that a procedure is external. The list is simply a list of names without details about the arguments etc. It is necessary to use an external statement if the name is (or might be) the same as that of an intrinsic function. In addition, the return type of an external function must be declared unless the implicit typing rule is used. For implicit procedures, the number, order and type of the dummy arguments are implied from the actual arguments and the compiler simply checks that the various calls to a procedure are consistent.
An INTERFACE statement may be provided in order to make an interface explicit. It is required when a procedure has keyword and/or optional arguments.
An INTERFACE statement takes the form:
The interface body is normally a copy of the procedure header (or a number of them) leaving out variables that are local to the procedure and leaving out the code for the body of the procedure.
An INTERFACE statement can also be used within a MODULE in order to introduce user-defined operators and generic procedures.