If you specify the compiler option indicating FORTRAN-66 semantics, the EXTERNAL statement is interpreted in a way that facilitates compatibility with older versions of Fortran. (The Fortran 95/90 interpretation is incompatible with previous Fortran standards and previous Compaq (or DIGITAL) implementations.)
The FORTRAN-66 interpretation of the EXTERNAL statement combines the functionality of the INTRINSIC statement with that of 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 functions or Fortran 95/90 library functions.
The FORTRAN-66 EXTERNAL statement takes the following form:
Rules and Behavior
The FORTRAN-66 EXTERNAL statement declares that each name in its list is an external function 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). It is not, therefore, defined in an EXTERNAL statement (as would be the incomplete reference SQRT).
The following example demonstrates 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 95/90 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 library function. The function SINDEG is also a user-supplied function. Because no library function has the same name, no asterisk is required.
For More Information:
For details on Fortran 95/90 intrinsic functions, see Chapter 9.