HP Fortran Programmer's Guide (B3908-90031; September 2011)

Compiling and linking
Special-purpose compilations
Chapter 294
$ a.out
Enter a real number: 3
The value of x in main: 3.0
The value of x in double_it: 3.0
x = 6.0
The next command line does not use the -D option, so that DEBUG is undefined, causing cpp to remove the
PRINT statements 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 f90 command discards the source text as processed by cpp after compilation. However, you
can preserve this text by compiling with the +cpp_keep option. If the source file has the .F or .f
extension, the output from cpp is written to a file with the same name but with the .i extension. If the
source file extension is .f90, the output file has the .i90 extension.
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 PRINT statements 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