HP Fortran Programmer Guide (766160-001, March 2014)
The value of x in double_it: 3.0
x = 6.0
The next command line does not use the-D option, so that DEBUGis undefined, causing cpp to
remove the PRINTstatements from the source text that is passed to the compiler:
$ f90 +cpp=yes cpp_direct.f90
Here is the output from the nondebugging version of the program:
$ a.out
Enter a real number: 3.3
x = 6.6
Saving the cpp output file
By default, the f90command discards the source text as processed by cpp after compilation.
However, you can preserve this text by compiling with the +cpp_keepoption. If the source file
has the .For .fextension, the output from cppis written to a file with the same name but with the
.iextension. If the source file extension is .f90, the output file has the .i90extension.
Here is the previous command line to preprocess and compile cpp_direct.f90, with the addition
of the +cpp_keep option:
$ f90 +cpp_keep +cpp=yes cpp_direct.f90
After the PRINTstatements have been removed, the resulting output file looks like this:
$ cat cpp_direct.i90
# 1 "cpp_direct.f90"
PROGRAM main
REAL :: x
WRITE (6, FMT='(A)', ADVANCE='NO') 'Enter a real number:'
READ *, x
PRINT *, 'x =', double_it(x)
END PROGRAM main
REAL FUNCTION double_it(arg)
REAL :: arg
double_it = 2.0 * arg
END FUNCTION double_it
Compiling
Creating demand-loadable executables
By default, the loader loads the entire code for an executable program into virtual memory. For
very large programs, this can increase startup time. You can override this default by causing the
linker to mark your program demand load. A demand-loadable program is loaded into memory
a page at a time, as it is accessed.
Use the +demand_loadoption to make your program demand loadable, as follows:
$ f90 +demand_load prog.f90
The f90 command passes this option to the linker, which marks the executable program demand
load.
Demand loading allows a program to start up faster because page loading can be spread across
the execution of the program. The disadvantage of demand loading is that it can degrade
performance throughout execution.
Creating shared executables
By default, the linker marks an executable program as shared. A shared executable is shareable
by all processes that use the program. The first process to run the program loads its code into
virtual memory. If the program is already loaded by another process, then a process shares the
code with the other process.
62 Compiling and linking