Developer Guide and Reference

ID 767251
Date 10/31/2024
Public
Document Table of Contents

FORTRAN 66 Interpretation of the EXTERNAL Statement

If you specify compiler option f66, the EXTERNAL statement is interpreted in the way that was specified by the FORTRAN 66 (FORTRAN IV) standard. This interpretation became incompatible with FORTRAN 77 and later revisions of the Fortran standard.

The FORTRAN 66 interpretation of the EXTERNAL statement combines the functionalities of the INTRINSIC statement and the EXTERNAL statement.

This lets you use subprograms as arguments to other subprograms. The subprograms to be used as arguments can be either user-supplied procedures or Fortran intrinsic procedures.

The FORTRAN 66 EXTERNAL statement takes the following form:

EXTERNAL [*]v [, [*]v] ...

*

Specifies that a user-supplied external procedure is to be used instead of a Fortran intrinsic procedure having the same name. This modifier is not standard FORTRAN 66, but was an extension in some FORTRAN 66 compilers, and provides the FORTRAN 77 meaning of EXTERNAL where required.

v

Is the name of a subprogram or the name of a dummy argument associated with the name of a subprogram.

Description

The FORTRAN 66 EXTERNAL statement declares that each name in its list is an external procedure name. Such a name can then be used as an actual argument to a subprogram, which then can use the corresponding dummy argument in a function reference or CALL statement.

However, when used as an argument, a complete function reference represents a value, not a subprogram name; for example, SQRT(B) in CALL SUBR(A, SQRT(B), C). Therefore, it does not need to be defined in an EXTERNAL statement. Note that the incomplete reference SQRT would need to be defined in an EXTERNAL statement.

Examples

The following example, when compiled with compiler option f66, shows the FORTRAN 66 EXTERNAL statement:

Main Program                        Subprograms
EXTERNAL SIN, COS, *TAN, SINDEG     SUBROUTINE TRIG(X,F,Y)
   .                                Y = F(X)
   .                                RETURN
   .                                END
CALL TRIG(ANGLE, SIN, SINE)
   .
   .                                FUNCTION TAN(X)
   .                                TAN = SIN(X)/COS(X)
CALL TRIG(ANGLE, COS, COSINE)       RETURN
   .                                END
   .
   .
CALL TRIG(ANGLE, TAN, TANGNT)       FUNCTION SINDEG(X)/
   .                                SINDEG = SIN(X*3.1459/180)
   .                                RETURN
   .                                END
CALL TRIG(ANGLED, SINDEG, SINE)

The CALL statements pass the name of a function to the subroutine TRIG. The function reference F(X) subsequently invokes the function in the second statement of TRIG. Depending on which CALL statement invoked TRIG, the second statement is equivalent to one of the following:

Y = SIN(X)
Y = COS(X)
Y = TAN(X)
Y = SINDEG(X)

The functions SIN and COS are examples of trigonometric functions supplied in the Fortran intrinsic procedure library. The function TAN is also supplied in the library, but the asterisk (*) in the EXTERNAL statement specifies that the user-supplied function be used, instead of the intrinsic function. The function SINDEG is also a user-supplied function. Because no library function has the same name, no asterisk is required.