HP Fortran Programmer's Reference (September 2007)

Program units and procedures
Arguments
Chapter 7174
Pointer dummy argument
If the dummy argument has the POINTER attribute, the actual argument must also have the
POINTER attribute. Furthermore, they must match in kind, type, and rank. If the dummy
argument does not have the POINTER attribute but the actual argument is a pointer, the
argument association behaves as if the pointer actual argument were replaced by its target at
the time of the procedure reference.
Procedure dummy argument
If a dummy argument is a procedure, the actual argument must be the name of an
appropriate subprogram, and its name must have been declared as EXTERNAL in the calling
unit or defined in an interface block (see “Procedure interface” on page 181). Internal
procedures, statement functions, and generic names may
not
be passed as actual arguments.
If the actual argument is an intrinsic procedure, the appropriate specific name must be used
in the reference. It must have the INTRINSIC attribute.
The following example, intrinsic_arg.f90, declares the intrinsics QSIN and QCOS with the
INTRINSIC attribute so that they can be passed as arguments to the user-defined subroutine
call_int_arg. Note that the dummy argument, trig_func, is declared in the subroutine
with the EXTERNAL attribute to indicate that it is a dummy procedure. This declaration does
not conflict with the declaration of the actual arguments in the main program unit because
each occurs in different scoping units.
Example 7-4 intrinsic_arg.f90
PROGRAM main
! declare the intrinsics QSIN and QCOS with the INTRINSIC
! attribute to allow them to be passed as arguments
REAL(16), INTRINSIC :: QSIN, QCOS
CALL call_int_arg(QSIN)
CALL call_int_arg(QCOS)
END PROGRAM main
SUBROUTINE call_int_arg(trig_func)
! trig_func is an intrinsic function--see the declarations
! of the actual arguments in the main program. trig_func
! is declared here as EXTERNAL to indicate that it is a
! dummy procedure.
REAL(16), EXTERNAL :: trig_func
REAL(16), PARAMETER :: pi=3.1415926
INTEGER :: i
DO i = 0, 360, 45
! Convert degrees to radians (i*pi/180) and call the