A.4 NOF77 Interpretation of the EXTERNAL Statement

If you specify the compiler option NOF77, you get an interpretation of the EXTERNAL statement that facilitates compatibility with older versions of Fortran. (The FORTRAN-77 interpretation is incompatible with the previous standard and previous Compaq (or DIGITAL) implementations.)

The NOF77 interpretation of the EXTERNAL statement combines the functionality of the INTRINSIC Statement with that of the EXTERNAL statement discussed in Section 4.8.

The NOF77 EXTERNAL statement lets you use subprograms as arguments to other subprograms. The subprograms to be used as arguments can be either user-supplied procedures or Fortran library functions.

The NOF77 EXTERNAL statement takes the following form:

EXTERNAL [*]v [,[*]v] . . .
v
Is the symbolic name of a subprogram or the name of a dummy argument associated with the symbolic name of a subprogram.
*
Specifies that a user-supplied function is to be used instead of a Fortran library function having the same name.

Rules and Behavior

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

However, 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). It is not, therefore, defined in an EXTERNAL statement (as would be the incomplete reference SQRT).

Example

Example A-1 shows the NOF77 EXTERNAL statement.

Example A-1 Using the NOF77 EXTERNAL Statement


Main Program                        Subprograms

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

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 library. The function TAN is also supplied in the library, but the asterisk (*) before its name in the EXTERNAL statement indicates that a user-supplied function should be used instead of the library function. The function SINDEG is also a user-supplied function, but no asterisk is required since no library function has the same name.

For More Information:

For details on Fortran library intrinsic functions, see Section 6.3.


Previous Page Next Page Table of Contents