HP Fortran Programmer Guide HP-UX 11i v1, HP-UX 11i v2, and HP-UX 11i v3 (B3908-90032,December 2012)

Special-purpose compilations
The default behavior of the HP Fortran compiler has been designed to handle typical compilations.
Most applications should require no more than a few of the f90options to compile successfully
(see Table on page 25 for a list of commonly used options).
However, the compiler can also meet the needs of more specialized compilations. This section
explains how to use the f90command for the following purposes:
To compile programs that contain Fortran modules.
To compile programs that will execute on different PA-RISC machines.
To create object files for shared libraries.
To process source files that contain C preprocessor directives.
To create demand-loadable programs.
To create shareable executable programs.
To compile 32-bit programs in 64-bit mode.
Compiling programs with modules
One of the features of standard Fortran is the module, a program unit that facilitates shared access
to data and procedures. Modules are fully described in the HP Fortran Programmer’s Reference.
A benefit to using modules is that they provide interface information to the compiler, allowing it to
catch mismatch errors between (for example) dummy arguments and actual arguments. When the
HP Fortran compiler processes a file that defines a module, it generates a .modfile with the interface
information. Later, when the compiler processes a file that uses the module, it reads the .modfile
and checks that module entities that are referenced in the using file correctly match the information
in the.mod file.
To make the .modfiles available to the compiler, you must therefore compile the files that define
modules before the files that use modules. Likewise, if you make changes to a file that defines a
module, you must recompile that file as well as any files that use the module, in that order.
Also, if a module is defined and used in the same file, the definition must lexically precede
anyUSEstatements that reference the module. This requirement allows the compiler to generate the
.modfile first, so that it can resolve the references in any USEstatements.
This section discusses the following topics:
How to compile a program that uses modules
How to design makefiles to work with modules
How to use the -Iand +moddiroptions to manage .modfiles
Special-purpose compilations 53