The intrinsic and external statements were introduced into FORTRAN to give the programmers the flexibility to pass functions and subroutines as arguments in an argument list to other program units. The intrinsic statement is used whenever the procedure to be passed is an intrinsic function or intrinsic subroutine while the external statement is used if the procedure to be passed is one written by the programmer. A program unit will identify a given dummy argument as function or subroutine either by the context of its use, or because you include the dummy argument name in and EXTERNAL statement. Since the intrinsic statement is a non-executable statement, it needs to appear at the beginning of a program before the executable statements begin. However, it must come after certain other non-executable statements such as program, implicit and use. For instance, look at how it is used in the following block of code.
program example use global_data implicit none real x,y,z integer i,j intrinsic sin g=1.34 y=x(sin,z) stop end function x(trigfunc,g) external trigfunc x = trigfunc(g) return stop
From that example you should be able to get an idea of how and where to use the intrinsic statement. There is one other thing that you should be made aware of in the above example. Notice that in the function x, sin is declared to be external even though it is an intrinsic procedure. The reason for this is that in FORTRAN the called procedure ( in this case the function x ) doesn't care whether the dummy argument is an intrinsic or user defined function, and might be called in the same program with both intrinsic and user defined subprogram names as arguments. Both are accessed in the same way by the subprogram, and FORTRAN syntax requires that only the EXTERNAL statement be used when declaring a dummy argument to be a subprogram name..
lecture twenty nine
Written by Jason Wehr : firstname.lastname@example.org and Maintained by John Mahaffy : email@example.com