# 4.8 EXTERNAL Statement

The EXTERNAL statement lets you use the names of external procedures as arguments to other subprograms.

The subprograms specified in an EXTERNAL statement must be user- written functions, subroutines, or block data subprograms. (If you want to specify Fortran intrinsic procedure names as arguments, use the INTRINSIC statement.)

The EXTERNAL statement takes the following form:

    EXTERNAL v [,v] . . .

v
  Is the symbolic name of a user-supplied subprogram or the name of a dummy argument associated with the name of a subprogram.

Rules and Behavior

The EXTERNAL statement declares each symbolic name v 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 specified in an EXTERNAL statement (EXTERNAL SIN), all subsequent references to SIN are to a user-supplied function named SIN, not to the intrinsic function of the same name.

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 FOO

    CALL BAR (FOO)

    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)

You can include the name of a block data subprogram in the EXTERNAL statement to force a search of the object module libraries for the block data subprogram at link time. However, the name of the block data subprogram must not be used in a type declaration statement.

For More Information:

- On the INTRINSIC statement, see Section 4.10.

- On using intrinsic procedure names, see Section 6.3.1.2.

- On the CALL statement, see Section 5.1.

- On using the EXTERNAL statement, see the example (Section 4.10.

- On an alternative interpretation of the EXTERNAL statement, see Appendix A.

Previous Page Next Page Table of Contents