The EXTERNAL attribute allows an external or dummy procedure to be used as an actual argument. (To specify intrinsic procedures as actual arguments, use the INTRINSIC attribute.)
The EXTERNAL attribute can be specified in a type declaration statement or an EXTERNAL statement, and takes one of the following forms:
Type Declaration Statement:
Rules and Behavior
In a type declaration statement, only functions can be declared EXTERNAL. However, you can use the EXTERNAL statement to declare subroutines and block data program units, as well as functions, to be external.
The name declared EXTERNAL is assumed to be the name of an external procedure, even if the name is the same as that of an intrinsic procedure. For example, if SIN is declared with the EXTERNAL attribute, all subsequent references to SIN are to a user-supplied function named SIN, not to the intrinsic function of the same name.
You can include the name of a block data program unit in the EXTERNAL statement to force a search of the object module libraries for the block data program unit at link time. However, the name of the block data program unit must not be used in a type declaration statement.
The following example shows type declaration statements specifying the EXTERNAL attribute:
PROGRAM TEST ... INTEGER, EXTERNAL :: BETA LOGICAL, EXTERNAL :: COS ... CALL SUB(BETA) ! External function BETA is an actual argument
You can use a name specified in an EXTERNAL statement as an actual argument to a subprogram, and the subprogram can then use the corresponding dummy argument in a function reference or a CALL statement; for example:
EXTERNAL FACET CALL BAR(FACET) SUBROUTINE BAR(F) EXTERNAL F CALL F(2)
Used as an argument, a complete function reference represents a value, not a subprogram; for example, FUNC(B) represents a value in the following statement:
CALL SUBR(A, FUNC(B), C)
For More Information: