HP Fortran Programmer's Guide (September 2007)
Compiling and linking
Special-purpose compilations
Chapter 282
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 f90 options to
compile successfully (see Table on page 23 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 f90 command 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 .mod file
with the interface information. Later, when the compiler processes a file that uses the module,
it reads the .mod file and checks that module entities that are referenced in the using file
correctly match the information in the .mod file.
To make the .mod files 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 any
USE statements that reference the module. This requirement allows the compiler to generate
the .mod file first, so that it can resolve the references in any USE statements.
This section discusses the following topics: