HP Fortran Programmer's Guide (September 2007)

Using Fortran directives
Using HP Fortran directives
Chapter 9206
Example 9-1 pr_str.c
void c_rout(char *s)
{
printf(“%s\n”, s);
}
The ALIAS directive in the following program enables the string to be passed to c_rout:
Example 9-2 pass_str.f90
PROGRAM main
!$HP$ ALIAS c_rout(%REF)
CHARACTER(LEN=10) name
name = 'Charlie'
! Append a null to the string so that C can handle it properly
CALL c_rout(name//char(0))
END PROGRAM main
Here are the command lines to compile and link both files, and to execute the program, along
with the output from a sample run:
$ cc -Aa -c pr_str.c
$ f90 pass_str.f90 pr_str.o
$ a.out
Charlie
For more information
For detailed information about the %REF and %VAL built-in functions, see the HP Fortran
Programmer’s Reference.
$HP$ CHECK_OVERFLOW
The $HP$ CHECK_OVERFLOW directive generates code to trap when an overflow occurs in
integer arithmetic. By default, integer overflow is ignored.
Syntax
!$HP$ CHECK_OVERFLOW INTEGER [ON | OFF]
ON causes the compiler to generate code to trap integer overflow exceptions.
OFF causes the compiler not to generate code to trap integer overflow exceptions.