HP Fortran Programmer Guide (766160-001, March 2014)

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
EXTERNALstatement, 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=90option. 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 EXTERNALstatement.
The following are programs that illustrate the preceding concepts.
Example 34 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=90option, the compiler will assume that
the reference is to the HP intrinsic named INT1and 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
11 Lines Compiled
$ a.out
j = 4
If the program is recompiled with the +langlvl=90option, the compiler flags the name of what
it assumes to be a nonstandard intrinsic as well as the nonstandard source format:
$ f90 +langlvl=90 clash.f90
program CLASH
i = 4
^
Warning 4 at (3:clash.f90) : Tab characters are an extension to
standard Fortran-90
j = int1(i)
^
Warning 39 at (5:clash.f90) : This intrinsic function is an
extension to standard Fortran-90
external function INT1
int1 = i+1
^
Warning 4 at (10:clash.f90) : Tab characters are an extension to
standard Fortran-90
11 Lines Compiled
Once you have identified the names of your routines that clash with intrinsic names, you can edit
the source code to declare each procedure with the EXTERNALstatement, as follows:
EXTERNAL int1
Now when you compile and execute, you will get the expected behavior:
146 Porting to HP Fortran