directive. The %REFfunction tells Fortran that its argument is to be passed by reference (as when passing an array or pointer in C), and the %VALfunction tells Fortran that its argument is to be passed by value (the default case in C).
Consider a C function having the following prototype declaration:
void foo(int *ptr, int iarray[100], int i);
In Fortran, the actual arguments to be passed to would be declared as follows:
INTEGER :: ptr, i
INTEGER, DIMENSION(100) :: iarray
The call from Fortran to the C function (using the %VAL and
CALL foo(%REF(ptr), %REF(iarray), %VAL(i))
If the Fortran program were to make numerous calls to foo at different call sites, you might find it more convenient to use the $HP$ ALIAS directive with the %VALand
!$HP$ ALIAS foo(%REF, %REF, %VAL)
Note that the functions are used here without arguments; their positions in the argument list indicate the parameters to which each applies.
You can also use the $HP$ ALIAS directive to handle
For detailed information about the $HP$ ALIAS directive and the and %REF
Case sensitivity
Unlike HP Fortran, C is a
If case sensitivity is an issue when calling a C function from an HP Fortran program, you have two choices:
•Compile the Fortran program with the +uppercaseoption, which forces Fortran to use uppercase for external names.
•Use the $HP$ ALIAS directive to specify the case that Fortran should use when calling an external name.
It is unusual that all names in the C source file would be uppercase, which would be the only case justifying the use of the +uppercase option. Therefore, we recommend using the $HP$ ALIAS directive. This directive enables you to associate an external name with an external name, even if the external name uses uppercase characters.
114 Calling C routines from HP Fortran