$ f90 clash.f90 clash.f90

program CLASH external function INT1

11 Lines Compiled

$ a.out j = 5

NOTE: The name-conflict problem can occur in Fortran programs that call routines in the libU77.a library. Some implementations link libU77.a by default. HP Fortran does not; to link in this library, you must compile your program with the +U77 option. If you do not compile with this option and your program references a libU77 routine with the same name as an HP Fortran intrinsic, the compiler will wrongly (and sometimes disastrously) assume that the reference is to an intrinsic. If you are not sure if your program referenceslibU77 routines, compile it with the +langlvl=90 option, which will cause the compiler to issue warnings for references to nonstandard routines. For problems that can occur when migrating HP FORTRAN 77 programs that reference libU77 routines, see “Intrinsic functions” (page 137).

Names with appended underscores

In some implementations of Fortran (but not HP Fortran), the compiler automatically appends underscores to external names. If you are porting a mixed-language program from such an implementation (for example, a program consisting of C and Fortran source files), the linker may not be able to find the names in the C code because the names in the Fortran code do not have the appended underscore. The reason is that the C code has explicitly added underscores to match the names of the Fortran procedures in the object code.

Using the +ppuoption causes the HP Fortran compiler to append an underscore to external names (including procedures and common blocks), making them consistent with the name as it appears in the non-Fortran source file. For example, if a Fortran source file contains the procedure proc_array, and a C source file reference this procedure as proc_array_, compiling the Fortran source file with the +ppuoption causes the compiler to use proc_array_as the name of the procedure in the Fortran object file.

For information about how to resolve other name conflicts in mixed-language programs, see “Case sensitivity” (page 114).

Source formats

Standard Fortran 90 permits source code in either fixed or free form, though not both in the same file. Furthermore, if the source is in fixed form, the Standard requires statements not to extend beyond column 72. Also, Standard Fortran 90 does not allow tab formatting.

HP Fortran’s scheme for handling the different formatting possibilities is this:

If the name of the source file ends with the .f90 extension, the file is compiled as free form. The compiler accepts tab characters in the source.

If the name of the source file ends with the .f or.Fextension, the file is compiled as fixed form.

If the file is compiled with the +langlvl=90 option, the interprets the format as either fixed or free form, depending on the filename extension (as described above). However, the compiler issues warnings if it encounters tab characters.

If the file is compiled with the +source=fixed option, the compiler assumes fixed form, regardless of the extension. Tab characters are allowed.

Using porting options 147