Note the following restrictions:
•Attempts to redefine $HP$ ALIAS names generate warning messages.
•The compiler always uses
Local and global usage
The $HP$ ALIAS directive can be used either locally or globally, as follows:
•The$HP$ ALIAS directive has local application
•The $HP$ ALIAS directive has global
Example 30 Examples
The $HP$ ALIAS directive is especially useful when calling a routine in a language that uses different conventions than Fortran. The following examples illustrate how to use the $HP$ ALIAS directive to resolve differences with:
•Case sensitivity
•
•Strings
Case sensitivity
Names in HP Fortran are not case sensitive; that is, the compiler converts all names to lowercase. This means that if you reference a routine in a language that is case sensitive and the routine name contains uppercase letters, a call to that routine in HP Fortran will result in an unresolved
!$HP$ ALIAS printnames = 'PrintNames'
By default, HP Fortran assumes that all parameters in a subroutine or function call are passed by reference; that is, the call passes the addresses of the parameters, not their values. On the other hand, C code assumes that parameters are passed by value; that is, the current value of the actual parameter is passed to the called routine. Without the $HP$ ALIAS directive, it would be difficult to call a C routine from a Fortran program.
For example, suppose you want to call the system routine calloc(see themalloc (3C) man page) to obtain dynamic memory. The man page describes the calling sequence as:
char *calloc(unsigned nelem, unsigned elsize);
It would be difficult, using standard Fortran constructs, to provide actual parameters corresponding to nelem and elsizebecause HP Fortran always passes addresses. The $HP$ ALIAS directive can solve this problem by directing the compiler to generate
!$HP$ ALIAS calloc(%VAL, %VAL)
Using HP Fortran directives 125