The INTRINSIC attribute allows the specific name of an intrinsic procedure to be used as an actual argument. (Not all specific names can be used as actual arguments. For more information, see Table 9-1.)
The INTRINSIC attribute can be specified in a type declaration statement or an INTRINSIC statement, and takes one of the following forms:
Type Declaration Statement:
Statement:
In a type declaration statement, only functions can be declared INTRINSIC. However, you can use the INTRINSIC statement to declare subroutines, as well as functions, to be intrinsic.
The name declared INTRINSIC is assumed to be the name of an intrinsic procedure. If a generic intrinsic function name is given the INTRINSIC attribute, the name retains its generic properties.
Examples
The following example shows a type declaration statement specifying the INTRINSIC attribute:
PROGRAM EXAMPLE
...
REAL(8), INTRINSIC :: DACOS
...
CALL TEST(X, DACOS) ! Intrinsic function DACOS is an actual argument
The following example shows an INTRINSIC statement:
Main Program | Subprogram |
---|---|
EXTERNAL CTN | SUBROUTINE
TRIG(X,F,Y) |
INTRINSIC
SIN, COS | Y = F(X) |
. . . | RETURN
|
END
| |
CALL TRIG(ANGLE,SIN,SINE)
| |
. . . | FUNCTION CTN(X) |
CTN = COS(X)/SIN(X) |
|
CALL TRIG(ANGLE,COS,COSINE) |
RETURN |
. . . | END |
CALL
TRIG(ANGLE,CTN,COTANGENT) |
Note that when TRIG is called with a second argument of SIN or COS, the function reference F(X) references the Fortran 95/90 library functions SIN and COS; but when TRIG is called with a second argument of CTN, F(X) references the user function CTN.
For More Information: