HP Fortran Programmer's Guide (B3908-90031; September 2011)

Porting to HP Fortran
Using porting options
Chapter 11246
the PRINT statement will never execute because the initial loop count is higher than the final loop count. To
force the loop to execute at least once, compile it with the command line:
$ f90 +onetrip test_loop.f90
When you run the program now, it produces the output:
$ a.out
Should never happen in standard Fortran 90.
Name conflicts
A common problem in porting Fortran programs is name conflicts: a user-written procedure may have the
same name as an intrinsic procedure on the implementation to which you are porting, and the compiler
selects the name of the intrinsic when you are expecting it to call the user-written procedure. For example,
HP Fortran provides the nonstandard intrinsic FLUSH. If your program contains an external procedure with
the same name and the procedure is not declared with the EXTERNAL statement, the HP Fortran compiler
will assume that the reference is to the intrinsic.
One way to identify user routines that have the same names as HP-specific intrinsics is to compile the
program with the +langlvl=90 option. This option causes the compiler to issue warnings for all HP
extensions in the source code, including nonstandard intrinsics. You can then edit the source file to declare
the procedure that the compiler assumes is an intrinsic with the EXTERNAL statement.
The following are programs that illustrate the preceding concepts.
Example 11-1 clash.f90
PROGRAM clash
i = 4
j = int1(i)
PRINT *, 'j =', j
END PROGRAM clash
FUNCTION int1(i)
int1 = i+1
END FUNCTION int1
If this is compiled as coded and without the +langlvl=90 option, the compiler will assume that the
reference is to the HP intrinsic named INT1 and not to the external function. Executing the program will
produce unexpected results, as appears in the following sample run:
$ f90 clash.f90
clash.f90
program CLASH
external function INT1