HP Fortran Programmer's Reference (September 2007)

Program units and procedures
Arguments
Chapter 7178
In the following code, the data object a is available to the subroutine as a consequence of
argument association and host association. The direct reference to a in the subroutine is
illegal.
PROGRAM p
CALL s (a,b)
CONTAINS
SUBROUTINE s (c,d)
c = 22.01 ! valid definition of a through the dummy
! argument
d = 3.0*a ! direct reference to a is ILLEGAL
...
END SUBROUTINE
END PROGRAM
INTENT attribute
To enable additional compile-time checking of arguments and to avoid possibly unwanted side
effects, the INTENT attribute can be declared for each dummy argument, which may be
specified as INTENT(IN), INTENT(OUT) or INTENT(INOUT).
The values that may be specified for the INTENT attribute have the following significance:
IN is used if the argument is not to be modified within the subprogram.
OUT implies that the actual argument must not be used within the subprogram before it is
assigned a value.
INOUT (the form IN OUT is also permitted) implies that the actual argument must be
defined on entry and is definable within the subprogram.
See “INTENT (statement and attribute)” on page 388 for more information about the INTENT
attribute.
%VAL and %REF built-in functions
By default, HP Fortran passes noncharacter arguments by reference. Instead of passing the
value of the actual argument to the referenced procedure, Fortran passes its address, with
which the name of the dummy argument becomes associated—as explained in “Argument
association” on page 171. When HP Fortran passes character arguments, it includes a hidden
length parameter along with the address of the actual argument.
However, it is possible to change the way arguments are passed by using the %VAL and %REF
built-in functions, which HP Fortran provides as extensions: