HP Fortran Programmer's Guide (March 2010)

Using Fortran directives
Using HP Fortran directives
Chapter 9218
It provides a way to associate the name used by your program when referring to a
subroutine, function, entry, or common block with a distinct external name. This feature
is especially useful when you want to access a variety of different graphics device drivers
from the same source code so that different hardware configurations can be supported.
When used in conjunction with the %VAL and %REF built-in functions, it provides a way to
direct the compiler to use the appropriate parameter passing conventions to communicate
with routines written in other high-level languages.
external-name should never conflict with the name of an HP-UX system routine (described
in sections 2 and 3 of the HP-UX Reference) or with a Fortran library routine (for example,
OPEN, READ, or CLOSE). The $HP$ ALIAS directive applies to subroutines, entries, and
functions that are used externally. It does not apply to the main program unit.
%VAL is a built-in function that specifies that the value of the actual argument is to be passed
to the called procedure. You can use this parameter with all types of arguments. However,
when used with a procedure name, it has no effect; a pointer to the procedure is still passed.
%REF specifies that the address of the actual argument is to be passed to the called procedure.
For non-character arguments, this is the default. For character arguments, %REF disables the
passing of the hidden length parameter.
When %VAL and %REF are used with the CALL statement, they override the specification in the
$HP$ ALIAS directive. For detailed information about these built-in functions and their use in
the CALL statement, see the HP Fortran Programmer’s Reference..
Note the following restrictions:
Attempts to redefine $HP$ ALIAS names generate warning messages.
The compiler always uses external-name exactly as it is entered. No case
transformations occur, and no underscore is appended. The +ppu and +uppercase
command-line options do not apply to external names specified by the $HP$ ALIAS
directive.
Local and global usage
The $HP$ ALIAS directive can be used either locally or globally, as follows:
•The $HP$ ALIAS directive has local application only—that is, its effect is limited to a
particular program unit—if it appears within the boundaries of that program unit. To
have local application only, the directive must appear after any PROGRAM, SUBROUTINE, or
FUNCTION statement and before the first occurrence of name in the target program unit.
•The $HP$ ALIAS directive has global application—that is, it applies to all subsequent
program units—if it appears outside and before the boundaries of those program units to
which it is to apply.