HP HP-UX 11i v1, HP-UX 11i v2, HP-UX 11 User's Guide

HP Fortran Programmer Guide

HP-UX 11i v1, HP-UX 11i v2, and HP-UX 11i v3
Abstract
The HP Fortran Programmer Guide describes how to use the different features of HP Fortran to develop, compile, debug, and optimize programs in HP 9000 systems, and Integrity systems. It also describes how to migrate HP FORTRAN 77 programs to the current HP Fortran compiler and how to use the different compiler features for porting programs written for other vendors’ Fortran to HP Fortran. If you have any problems with the software, please contact your local Hewlett-Packard Sales Office or Customer Service Center.
HP Fortran for Integrity systems is a part of the HP-UX PA-RISC Fortran product. HP Fortran is source compatible between the HP 9000 and Integrity systems. However, HP Fortran for Integrity systems will not run on PA-RISC based systems.
HP Part Number: 766160-001 Published: March 2014 Edition: 12
© Copyright 2010, 2014 Hewlett-Packard Development Company, L.P.
Confidential computer software. Valid license from HP required for possession, use or copying. Consistent with FAR 12.211 and 12.212, Commercial Computer Software, Computer Software Documentation, and Technical Data for Commercial Items are licensed to the U.S. Government under vendor's standard commercial license.
The information contained in this document is subject to change without notice. The only warranties for HP products and services are set forth in the express warranty statements accompanying such products and services. Nothing herein should be construed as constituting an additional warranty. HP shall not be liable for technical or editorial errors or omissions contained herein.
Intel and Itanium are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States and other countries.
UNIX is a registered trademark of The Open Group.

Contents

HP secure development lifecycle......................................................................7
1 An overview of HP Fortran...........................................................................8
The HP Fortran compiler environment...........................................................................................8
Driver......................................................................................................................................9
C preprocessor.......................................................................................................................10
Front-end...............................................................................................................................11
Back-end...............................................................................................................................13
Linker....................................................................................................................................15
Tools.....................................................................................................................................17
HP-UX operating system...........................................................................................................17
2 Compiling and linking..............................................................................18
Compiling with the f90 command.............................................................................................18
f90 command syntax..........................................................................................................18
Command-line options............................................................................................................19
Commonly-used options......................................................................................................20
Command-line options by category......................................................................................20
Option descriptions............................................................................................................21
Symbol binding options...........................................................................................................37
Using optimization options.......................................................................................................38
Reviewing general optimization options.....................................................................................38
Fine-tuning optimization options...............................................................................................40
Filenames..............................................................................................................................49
Linking HP Fortran programs....................................................................................................50
Linking with f90 vs. ld.........................................................................................................50
Linking to libraries..............................................................................................................51
Linking to nondefault libraries.........................................................................................52
Linking HP Fortran 90 routines........................................................................................52
Additional HP Fortran libraries........................................................................................53
Linking to shared libraries...............................................................................................53
Library search rules.......................................................................................................54
Special-purpose compilations...................................................................................................54
Compiling programs with modules.......................................................................................54
Examples.....................................................................................................................56
Compiling with make.....................................................................................................57
Managing .mod files.....................................................................................................58
Compiling for different PA-RISC machines..............................................................................58
Creating shared libraries....................................................................................................59
Compiling with +pic......................................................................................................59
Linking with -b..............................................................................................................60
Examples.....................................................................................................................60
Using the C preprocessor........................................................................................................60
Processing cpp directives....................................................................................................61
Saving the cpp output file...................................................................................................62
Creating demand-loadable executables.....................................................................................62
Creating shared executables....................................................................................................62
Compiling in 64-bit mode........................................................................................................63
Using environment variables.....................................................................................................63
F90ROOT environment variable...........................................................................................64
ST_F90COM[64] environment variable.................................................................................64
HP_F90OPTS environment variable......................................................................................64
Contents 3
LPATH environment variable.................................................................................................65
MP_NUMBER_OF_THREADS environment variable.................................................................65
Floating installation.................................................................................................................65
Setting up floating installation..............................................................................................66
3 Controlling data storage............................................................................67
Disabling implicit typing..........................................................................................................67
Automatic and static variables..................................................................................................67
Increasing the precision of constants.........................................................................................69
Increasing default data sizes....................................................................................................70
Increasing default data sizes...............................................................................................70
Sharing data among programs.................................................................................................72
Modules vs. common blocks.....................................................................................................74
4 Debugging..............................................................................................76
Using the HP WDB debugger..................................................................................................76
Stripping debugging information..............................................................................................76
Handling runtime exceptions....................................................................................................77
Bus error exception............................................................................................................78
Floating-point exceptions.....................................................................................................78
Illegal instruction exception.................................................................................................79
Segmentation violation exception.........................................................................................79
Bad argument exception.....................................................................................................80
Using debugging lines............................................................................................................80
5 Using the ON statement............................................................................81
Exceptions handled by the ON statement..................................................................................81
Actions specified by ON.........................................................................................................82
Terminating program execution............................................................................................83
Ignoring errors...................................................................................................................83
Calling a trap procedure....................................................................................................84
Trapping floating-point exceptions...................................................................................84
Trapping integer overflow exceptions...............................................................................84
Trapping +Ctrl-C trap interrupts................................................................................................85
Allowing core dumps..............................................................................................................85
6 Performance and optimization ...................................................................87
Using profilers........................................................................................................................87
HP Caliper........................................................................................................................87
Invoking HP Caliper with the compiler to optimize your program.........................................88
Comparing Program Performance....................................................................................88
Using Options to Control Data Collection.........................................................................89
Specifying PBO file names and locations..........................................................................89
gprof................................................................................................................................89
prof.................................................................................................................................90
Using options to control optimization.........................................................................................90
Using +O to set optimization levels......................................................................................90
Using the optimization options.............................................................................................91
Conservative vs. aggressive optimization...................................................................................99
Parallelizing HP Fortran programs...........................................................................................100
Compiling for parallel execution........................................................................................100
Performance and parallelization.........................................................................................101
Profiling parallelized programs..........................................................................................101
Conditions inhibiting loop parallelization............................................................................101
Calling routines with side effects parallellization .............................................................101
Indeterminate iteration counts.......................................................................................102
Data dependences......................................................................................................102
4 Contents
Vectorization........................................................................................................................103
Using the +Ovectorize option............................................................................................103
Controlling vectorization locally.........................................................................................104
Calling BLAS library routines.............................................................................................105
Controlling code generation for performance...........................................................................106
7 Writing HP-UX applications......................................................................107
Accessing command-line arguments........................................................................................107
Calling HP-UX system and library routines................................................................................108
Using HP-UX file I/O.............................................................................................................108
Stream I/O using FSTREAM..............................................................................................108
Performing I/O using HP-UX system calls.............................................................................108
Establishing a connection to a file......................................................................................108
Obtaining an HP-UX file descriptor.....................................................................................109
8 Calling C routines from HP Fortran............................................................110
Data types...........................................................................................................................110
Unsigned integers............................................................................................................111
Logicals..........................................................................................................................111
Complex numbers............................................................................................................112
Derived types..................................................................................................................113
Pointers...........................................................................................................................113
Argument-passing conventions................................................................................................113
Case sensitivity.....................................................................................................................114
Arrays.................................................................................................................................116
Memory layout of a two-dimensional array in Fortran and C..................................................116
C strings..............................................................................................................................118
C null-terminated string.....................................................................................................118
Fortran hidden length argument.........................................................................................118
Passing a string...............................................................................................................118
File handling........................................................................................................................120
Sharing data........................................................................................................................122
9 Using Fortran directives...........................................................................123
Directive syntax....................................................................................................................123
Using HP Fortran directives....................................................................................................123
$HP$ ALIAS....................................................................................................................124
$HP$ CHECK_OVERFLOW...............................................................................................126
$HP$ LIST.......................................................................................................................127
$HP$ OPTIMIZE..............................................................................................................127
Compatibility directives.........................................................................................................128
Controlling vectorization...................................................................................................128
Controlling parallelization.................................................................................................129
Controlling dependence checks.........................................................................................129
Controlling checks for side effects.......................................................................................129
10 Migrating to HP Fortran.........................................................................131
Incompatibilities with HP FORTRAN 77...................................................................................131
Compiler limits................................................................................................................131
Command-line options not supported..................................................................................131
Format field widths...........................................................................................................132
Floating-point constants.....................................................................................................132
Intrinsic functions.............................................................................................................132
Procedure calls and definitions..........................................................................................133
Data types and constants..................................................................................................133
Input/output....................................................................................................................134
Directives........................................................................................................................134
Contents 5
Miscellaneous ................................................................................................................135
Migration issues...................................................................................................................135
Source code issues...........................................................................................................135
Directives...................................................................................................................136
Intrinsic functions.........................................................................................................137
Command-line option issues..............................................................................................137
Object code issues...........................................................................................................138
Data file issues................................................................................................................138
Approaches to migration.......................................................................................................139
HP-supplied migration tools...............................................................................................139
HP FORTRAN 77 compiler...........................................................................................139
HP Fortran compiler.....................................................................................................139
Lintfor........................................................................................................................139
Fortran incompatibilities detector...................................................................................139
11 Porting to HP Fortran..............................................................................141
Compatibility extensions........................................................................................................141
Compiler directives..........................................................................................................142
Intrinsic procedures..........................................................................................................143
Using porting options............................................................................................................144
Uninitialized variables......................................................................................................144
Large word size...............................................................................................................145
One-trip DO loops...........................................................................................................145
Name conflicts................................................................................................................146
Names with appended underscores...................................................................................147
Source formats................................................................................................................147
Escape sequences............................................................................................................148
Porting from Tru64 to HP Fortran.............................................................................................148
+cfc...............................................................................................................................148
Enhancements.................................................................................................................149
New options...................................................................................................................149
12 Fortran 2003 Features...........................................................................151
Interoperability with C...........................................................................................................151
Input/output enhancements...............................................................................................151
Miscellaneous enhancements.............................................................................................151
Data enhancements.........................................................................................................152
Object orientation features................................................................................................152
13 Documentation Feedback.......................................................................153
Glossary..................................................................................................154
Index.......................................................................................................159
6 Contents

HP secure development lifecycle

Starting with HP-UX 11i v3 March 2013 update release, HP secure development lifecycle provides the ability to authenticate HP-UX software. Software delivered through this release has been digitally signed using HP's private key. You can now verify the authenticity of the software before installing the products, delivered through this release.
To verify the software signatures in signed depot, the following products must be installed on your system:
B.11.31.1303 or later version of SD (Software Distributor)
A.01.01.07 or later version of HP-UX Whitelisting (WhiteListInf)
To verify the signatures, run: /usr/sbin/swsign -v –s <depot_path>. For more information, see Software Distributor documentation at http://www.hp.com/go/sd-docs.
NOTE: Ignite-UX software delivered with HP-UX 11i v3 March 2014 release or later supports
verification of the software signatures in signed depot or media, during cold installation. For more information, see Ignite-UX documentation at http://www.hp.com/go/ignite-ux-docs.

1 An overview of HP Fortran

When you use the f90 command to compile a Fortran program, the command invokes a number of components—and not just the compiler—to create the executable. By default, f90 invokes different components to parse the source files for syntax errors, produce an intermediate code, optimize the intermediate code, produce object code, search a set of library files for any additional object code that may be required, and link all of the object code into an executable file that you run without further processing.
For example, consider a program that consists of three source files: x.f90, y.f90, and z.f90. The following command line will process the source files and, if they are syntactically correct, produce an executable file with the default name a.out:
$ f90 x.f90 y.f90 z.f90
After compilation is complete, you can execute the program by invoking the name of the executable, as follows:
$ a.out
However, it is likely that you’ll want to control what components act on your program and what they do to it. For example, you may want to give the executable a name other than a.out or to link in other libraries than the default ones. The HP Fortran compiler supports a variety of command-line options that enable you to control the compilation process. This chapter provides an overview of the process and of the options that enable you to control the different components invoked by the f90 command.
NOTE: To get a summary listing of all f90 options, refer to the f90(1) manpage or use the
command, as shown here:
$ f90 +usage
For a full description of the options, see the most current version of the Parallel Programming Guide for HP-UX Systems.

The HP Fortran compiler environment

The HP Fortran compiler environment illustrates the compilation process, showing the different components of the HP Fortran compiler environment; active processes are unshaded and data elements are shaded. With the exception of the performance analysis tools and the debugger (WDB), all components are invoked by the f90 command. The C preprocessor and linker can also be separately invoked by the cpp and ld commands; see the cpp(1)and ld(1) manpages, respectively, for more information. The remaining sections in this chapter briefly describe the different components and the command-line options that control them. Included in each section are references to other parts of this manual for more detailed information.
8 An overview of HP Fortran
Driver
Figure 1 HP Fortran compiler environment
The driver parses the f90 command line by which you invoke the compiler, calls each subprocess as needed to complete the compilation, and retains control throughout the compilation process.
Command-line options that control driver functions enable you to do the following:
Call subprocesses that you want to substitute for those that f90 calls by default
Pass arguments to a subprocess
Get a summary listing of all options supported by the compiler
Display information about the version of f90 you are using
Control the level of information that the driver displays about the compilation process
Table 1 (page 9) lists and briefly describes the options that control the driver
Table 1 Options for controlling the f90 driver
FunctionOption
-c
+dryrun
-o
+pre_include=file
Suppress the link phase and produce an object file (.o) from each source file on the command line.
Generate sub-process information for a given f90 command-line without running the sub-processes.
Name the output file outfile instead of the default file name (a.out or filename.o). If linking has been suppressed, the front end uses this option to name the object file.
Process contents of file before all source files specified on the command line. The command line can have multiple occurrences of this option, each specifying a different file; they are processed in the specified order.
-tx,name
Substitute a private version (name) of one or more subprocesses (x) of the compilation. The values for x are:
a Assembler c Compiler l Linker p C preprocessor s Startup file (crt0.o library) e Debug file (end.o library)
Driver 9
Table 1 Options for controlling the f90 driver (continued)
FunctionOption
If you compile and link separately and specify +tl on the compile line, you must also specify it on the link line.
List and briefly describe all f90 options.+usage
-v
+version
-Wx,name]

C preprocessor

HP Fortran source files can include directives that the C preprocessor (cpp) reads and expands before the program is passed to the compiler. Among other things, cpp directives enable you to code parts of your program for conditional compilation. By default, the f90 command passes source files ending in the .F extension to the C preprocessor.
Table 2 (page 10) lists and briefly describes the options for controlling the preprocessor, including
the +cpp option, which overrides the default behavior and passes all source files on the command line to the preprocessor. For additional information, see and the cpp(1) manpage.
Print verbose information to standard output as program is compiled.
Write compiler version information to standard output, without compiling.
Pass arg1 through argN to a subprocess of the compilation, identified by x. The values for x are:
a Assembler c Compiler l Linker p C preprocessor
If you compile and link separately and specify +Wl on the compile line, you must also specify it on the link line.
Table 2 Options for controlling the C preprocessor
+cpp={yes|no|default}
+[no]cpp_keep
-Dname[=def]
-Idirectory
-M
FunctionOption
Invoke the C preprocessor. +cpp=yes passes all source files to the preprocessor. +cpp=default passes only files ending in the .F extension. +cpp=no suppresses passing any files. The default is +cpp=default.
Retain [discard] output from the C preprocessor. If the source filename is file.f or file.F, output is stored in file.i; if the source filename is file.f90, the output filename is file.i90. The default, +nocpp_keep, is to discard the output.
Define the symbol name to the preprocessor. If def is specified, name is defined to that value.
Add directory to the list of directories searched for files specified in include directives. The command line can have multiple occurrences of this option, each specifying a different directory.
Generate the make rule corresponding to the compilation, the output is redirected to the stdout or user specified file. The rule describes the dependencies of the source file, containing the object file name for that source file, a colon, and the names of all the included files.
-Uname
10 An overview of HP Fortran
Remove any initial definition of name, a reserved symbol that is predefined by the preprocessor.

Front-end

The front-end is responsible for parsing the source code and issuing warning and error messages when the parse fails. Command-line options enable you to control the front end’s assumptions about the source code, including whether the source is in fixed or free format, uses implicit or explicit typing, and contains extensions. Other front-end options control the level of error messages and their language (Native Language Support), default data sizes, and search rules for .mod files. For a list of the options that control the front end, see Table 3 (page 11).
Table 3 Options for controlling the front end
FunctionOption
+[no]autodbl
+[no]autodbl4
+check={all|none}
+[no]dlines
Promote [do not promote] all integer, logical, and real items to 8 bytes, and all double-precision and complex items to 16 bytes. The default is +noautodbl.
nl
For information about using this option, see “Increasing
default data sizes” (page 70).
Promote [do not promote] all integer, logical, and real items to 8 bytes, and complex items to 16 bytes. The +autodbl4 option does not promote the size of double-precision and double-complex items. The default is +noautodbl4.
nl
For information about using this option, see “Increasing
default data sizes” (page 70).
Enable (+check=all) or disable (+check=none) compile-time range checking of array subscripts and uninitialized stack variables at runtime. The default is +check=none.
nl
For information about using this option, see “Segmentation
violation exception” (page 79).
Compile debug lines as source statements [comments]. Source lines must be in fixed format. The default, +nodlines, is to treat source lines with a D or d in column 1 as comments.
nl
For information on using this option, see “Using debugging
lines” (page 80).
+[no]escape
+[no]extend_source
+f2003allocassign
-Idirectory
Treat the backslash character (\) as a C-like escape [literal] character. The default is +noescape.
nl
For information on using this option when porting, see
“Escape sequences” (page 148).
Allow [do not allow] up to 254 characters on a single source line. The default, +noextend_source, is 72 characters for fixed format and 132 for free format.
nl
For information on using this option when porting, see
“Source formats” (page 147).
Enable compiling of Fortran 2003 standard code.+f2003
Enables automatic allocation or re-allocation of arrays when an assignment happens to an allocatable array that is part of F2003 standard.
Add directory to the list of directories searched for files specified inINCLUDE lines and include directives, and for .mod files. The command line can have multiple instances of this option, each specifying a different directory.
nl
For information about using this option, see “Managing
.mod files” (page 58).
Front-end 11
Table 3 Options for controlling the front end (continued)
FunctionOption
+[no]implicit_none
+langlvl={90|default}
+[no]list
+moddir=directory
+moduleoptimize
+nls=lang
+[no]onetrip
Cause the types of identifiers to be implicitly undefined [defined]. The default is implicit typing (+noimplicit_none).
nl
For information about using this option, see “Disabling
implicit typing” (page 67).
Issue warnings for all extensions to the Fortran standard (+langlvl=90). The default, +langlvl=default, allows extensions.
nl
For information about using this option, see Chapter 11,
“Porting to HP Fortran” (page 141).
Write [suppress] a program listing to standard output during compilation. The default is +nolist.
Write .mod files to directory. The default is to write .mod files to the current directory.
nl
For information about using this option, see “The HP Fortran
compiler environment” (page 8).
Creates optimized module files by discarding redundant information. This reduces the compilation time and memory requirement of the compiler for nested or hierarchical modules.
Enable 16-bit Native Language Support (NLS) in strings and comments in the language specified by lang.
Execute any counter-controlled DO loop at least once (+onetrip). The default is +noonetrip.
nl
For information about using this option when porting, see
“One-trip DO loops” (page 145).
+[no]ppu
+real_constant={single|double}
+source={fixed|free| default}
+[no]uppercase
Postpend [do not postpend] underscores at the end of definitions of and references to externally visible symbols.
nl
For Itanium architecture, the default is +ppu. For PA-RISC 64-bit architecture, the default is +ppu. For PA-RISC 32-bit architecture, the default is +noppu.
nl
For information about using this option when porting, see
“Names with appended underscores” (page 147).
Treat all single-precision real and complex constants as either single-precision (+real_constant=single) or double-precision (+real_constant=double). The default is +real_constant=single. This option has no effect on constants that are explicitly sized or when the +autodbl or +autodbl4 option is specified.
nl
For information about using this option, see “Increasing
the precision of constants” (page 69).
Accept source files in fixed format (+source=fixed) or free format (+source=free). The default,
+source=default, is free for .f90 files and fixed for .f and .F source files.
nl
For information about using this option, see “Source
formats” (page 147).
Use uppercase [lowercase] for all external names. The default is +nouppercase.
nl
For information about using this option, see “Case
sensitivity” (page 114).
12 An overview of HP Fortran
Table 3 Options for controlling the front end (continued)
Suppress warning messages.-w
FunctionOption
+w

Back-end

The two main functions of the back-end are:
To optimize your program for faster performance
To generate the code that goes into the object file
Optimization is performed by two subcomponents of the compiler’s back end:
The High-Level Optimizer (HLO), which performs large-scale, high-semantic-level analyses and
The low-level optimizer, which performs traditional optimizations (such as common
Options for controlling optimization form the largest group of the command-line options. These options enable you to do the following:
To set the level of optimization that is applied to your program
To apply a package of optimizations that meet certain requirements of your application—for
Warn about all questionable constructs and issue remarks about coding styles and performance. Without the +w option, the compiler issues warnings only about constructs that are almost certainly problems.
transformations to increase performance.
subexpression elimination and dead-code removal) as well as machine-specific optimizations.
example, optimizations that favor compile-time speed over performance
To apply specific optimization technologies to your program, or to specific parts of your
program, for fine-tuning performance
Table 4 (page 90) lists (in summary form) the options that control optimization. For information
about how to use these options, see
NOTE: If you use the f90 command to compile and link on separate command lines, many of
the optimization options must appear on both the command line and the link line; see “Performance
and optimization ” (page 87). For information about using f90 to compile and link, see “Linking with f90 vs. ld” (page 50).
Table 4 Options for controlling optimization
FunctionOption
+check=uninit
+DC7200
-O[optlevel]
+Ooptlevel
Check the use of stack variables before it is defined at runtime.
Perform memory hierarchy optimizations for the PA7200 processor.
Optimize program, where optlevel is 0 (no optimization), 1, 2, 3, or 4 (the highest level). If optlevel is not specified, the program is optimized at level 2 (-O2).
This option has the same meaning as the -O[optlevel] option, except that optlevel must be specified. It is provided for compatibility with makefiles.
Back-end 13
Table 4 Options for controlling optimization (continued)
FunctionOption
+O[no]info
Provide [do not provide] feedback information about the optimization process. This option is most useful at optimization level 3 and higher. The default is +Onoinfo.
+O[no]optimization
Enable [disable] optimization, a predefined string that indicates a category of optimizations (for example, those that do not increase code size) or a specific optimization technology (for example, inlining). See the HP Fortran Programmer’s Reference, for the different values for optimization.
The other component of the back end is the code generator (CodeGen), which you can control by using the command-line options in Table 1.5. These options allow you to specify (among other things) that the output file include debugging or profiling information or that local variables be saved in static memory.
Table 5 Options for controlling code generation
FunctionOption
+[no]asm
+DAmodel
Compile the named source files and leave [do not leave] the assembly language output in corresponding files whose names are suffixed with .s. The default is +noasm.
Generate code for a specific version of the PA-RISC architecture. model can be one of the following:
PA-RISC version number (1.1 or 2.0).
A model number (for example, 750 or 870).
One of the PA-RISC processor names (for example,
PA7000, PA7100, or PA8000).
The word portable to generate code compatible
across all PA-RISC 1.1 and 2.0 workstations and servers.
nl
For information about using this option, see “Compiling
for different PA-RISC machines” (page 58).
+DSmodel
14 An overview of HP Fortran
Perform instruction scheduling appropriate for a specific implementation of the PA-RISC architecture. model can be one of the following:
PA-RISC version number (1.1 or 2.0).
A model number (for example, 750 or 870).
One of the PA-RISC processor names (for example,
PA7000, PA7100, or PA8000).
nl
For information about using this option, see “Compiling
for different PA-RISC machines” (page 58).
On Itanium processor family architecture, the defined values for model are:
blended: tune for best performance on a combination
of processors (i.e., Itanium or Itanium 2 processor). This is the Itanium architecture default.
itanium: tune for best performance on an Itanium
processor.
itanium2: tune for best performance on an Itanium 2
processor.
native: tune for best performance on the processor on
which the compiler is running.
Table 5 Options for controlling code generation (continued)
FunctionOption
-g
+[no]gprof
+k
+pic={short|long|no}
Generate debugging information needed by the debugger. This option is compatible with optimization levels 0, 1, and
2. If you compile and link separately and specify -g on the command line, you must also specify it on the link line.
nl
For information about using this option to prepare programs for the debugger, see “Using the HP WDB debugger”
(page 76).
Prepare [do not prepare] object files for profiling with
gprof; see the gprof(1) manpage. The default is +nogprof. If you compile and link separately and specify +gprof on the command line, you must also specify it on
the link line.
nl
For information about using this option to profile programs with gprof, see “gprof” (page 89).
Generate code for programs that reference a very large number of shared data items. The linker will issue a diagnostic message in the rare cases when this option is needed.
NOTE: This option is valid only on the PA-RISC systems.
Generate Position Independent Code (PIC) with short displacements (+pic=short) or long displacements (+pic=long) for use in shared libraries. The default is +pic=no.
nl
For information about using this option when creating shared libraries, see “Compiling with +pic” (page 59).

Linker

+[no]prof
Prepare [do not prepare] object files for profiling with prof; see the prof(1) manpage. The default is +noprof. If you compile and link separately and specify +prof on the command line, you must also specify it on the link line.
nl
For information about using this option to profile programs with prof, see “gprof” (page 89).
+[no]save
Save [do not save] all local variables in all subprograms.
nl
For information about using this option when porting, see
“Uninitialized variables” (page 144).
The linker (ld) builds an executable program from the object files produced by the back end and the libraries. An important group of options for controlling the linker specify what libraries the linker should search and where it should search for them. Other options control the type of information that the linker should or should not include in its output file, such as symbol table information used by the debugger or marks identifying the output file as shareable or demand loadable. Table 1-6 lists and briefly describes options that control the linker.
NOTE: If you use the f90 command to compile and link on separate command lines and compile
with any of the options (except -c) listed in Table 1-6, you must specify the same options on the link line as well.
Table 6 Options for controlling the Linker
+[no]demand_load
FunctionOption
Suppress linking; produce object files only.-c
Mark [do not mark] the output file from the linker demand load. If you compile and link separately and specify
Linker 15
Table 6 Options for controlling the Linker (continued)
FunctionOption
+demand_load on the command line, you must also specify it on the link line. The default is +nodemand_load.
nl
For information about using this option, see “Creating
demand-loadable executables” (page 62).
+FPflags
+[no]fp_exceptions
-Ldirectory
-lx
Specify how the runtime environment for trapping floating-point exceptions should be initialized at program startup. If you compile and link separately and specify +FP on the command line, you must also specify it on the link line with the identical set of flags. The default is that all traps are disabled. See the ld(1) manpage for specific values for flags.
nl
For information using this option, see “Floating-point
exceptions” (page 78).
Enable [disable] floating-point exceptions. Enabling floating-point exceptions also causes the running program to issue a procedure traceback for runtime errors. The default is +nofp_exceptions.
nl
For information using this option, see “Floating-point
exceptions” (page 78).
Add directory to the front of the library search path. This option applies only to libraries specified by the -l option (see below). If you compile and link separately and specify -L on the command line, you must also specify it on the link line.
nl
For information about using this option, see “Library search
rules” (page 54).
Link the library libx.a or libx.sl to the executable program. If you compile and link separately and specify
-l on the command line, you must also specify it on the link line.
nl
For information about using this option, see “Linking to
nondefault libraries” (page 52)and the ld(1) manpage.
-ooutfile
+[no]shared
+[no]strip
+[no]ttybuf
+[no]U77
Name the output file outfile instead of the default a.out. If linking is suppressed (-c), this option is used instead to name the object files.
Cause the output file from the linker to be marked shared [unshared]. If you compile and link separately and specify +shared on the command line, you must also specify it on the link line. The default is +shared. For information about using this option, see “Creating shared executables”
(page 62).
Strip [do not strip] symbol table information from the linker output. For more information, see the ld(1)) and strip(1) manpages. This option is not compatible with -g. If you compile and link separately and specify +strip on the command line, you must also specify it on the link line. The default is +nostrip.
nl
For information about using this option, see “Stripping
debugging information” (page 76).
Use buffered [unbuffered] output to the terminal. The default is +ttybuf.
Invoke [do not invoke] support for the libU77 library (BSD 3f). If you compile and link separately and specify +U77 on the compile line, you must also specify it on the link line. The default is +noU77.
nl
16 An overview of HP Fortran
Table 6 Options for controlling the Linker (continued)
FunctionOption
For information about the libU77 library, see “Additional
HP Fortran libraries” (page 53)and the HP Fortran
Programmer’s Reference.
-Wl,options

Tools

The HP Fortran compiler environment includes a high-level language debugger and performance analysis tools. The debugger is HP WDB, which includes a graphical user interface. To prepare a program for debugging, you must compile it with the -g option. For information about this option, see “Using the HP WDB debugger” (page 76).
The performance analysis tools include the standard UNIX utilities, prof and gprof. To use prof and gprof, you must compile with the +prof and +gprof options, respectively. For more information about all of the performance analysis tools, see “Using profilers” (page 87)and the CXperf(1), prof(1), gprof(1), and ttv(1) manpages.

HP-UX operating system

Although the HP-UX operating system does not appear Figure 1-1 on page 3 , it provides a variety of resources for programs executing within HP-UX. For example, HP-UX captures the command line you use to invoke an executable program, breaks it up into arguments, and makes them available to your program.
HP-UX also has many callable system routines that provide low-level access to kernel-level resources. For example, your program can call HP-UX file-processing routines as alternatives to Fortran I/O.
“Writing HP-UX applications” (page 107) discusses how HP Fortran programs can take advantage
of HP-UX resources. For a full description of HP-UX system routines, see the HP-UX Reference.
Pass a comma-separated list of options to the linker.
nl
For information about options supported by the linker, see the ld(1) manpage.
Tools 17

2 Compiling and linking

This chapter discusses how to compile and link HP Fortran programs and covers the following topics:
Compiling with the f90 command
Linking HP Fortran programs
Special-purpose compilations
Using environment variables

Compiling with the f90 command

The default behavior of the f90 command is to compile source files listed on the command line and, if the compilation is successful, to pass the resulting object files to the linker. If the link stage is successful, the linker produces an executable program with the default name a.out.
Consider, for example, the program hello.f90:
Example 1 hello.f90
PROGRAM main CALL hello() END PROGRAM main SUBROUTINE hello() PRINT *, 'Hello, I must be going.' END SUBROUTINE hello
When compiled with the command line:
$ f90 hello.f90 f90 produces two files, hello.o (object code) and a.out(the executable program).
If the command line contains only an object file, as in the following:
$ f90 hello.o f90passes the object file to the linker, which (if successful produces the executable program a.out.
Here is a sample run of the executable program:
$ a.out Hello, I must be going.
This section provides more detailed information about using the f90command, including:
Command-line syntax
Command-line options
Filenames recognized by f90

f90 command syntax

The default behavior of the f90 command is to compile source files listed on the command line and, if the compilation is successful, to pass the resulting object files to the linker. If the link stage is successful, the linker produces an executable program with the default name a.out.
Consider, for example, the program hello.f90:
18 Compiling and linking
Example 2 hello.f90
PROGRAM main CALL hello() END PROGRAM main SUBROUTINE hello() PRINT *, 'Hello, I must be going.' END SUBROUTINE hello
When compiled with the command line:
$ f90 hello.f90 f90 produces two files, hello.o (object code) and a.out(the executable program).
If the command line contains only an object file, as in the following:
$ f90 hello.o f90passes the object file to the linker, which (if successful produces the executable program a.out.
Here is a sample run of the executable program:
$ a.out Hello, I must be going.
This section provides more detailed information about using the f90 command, including:
Command-line syntax
Command-line options
Filenames recognized by f90
f90 command syntax
The syntax for using the f90command is:
f90 [options][files]
where options is a list of one or more command-line options andfilesis a list of one or more files containing HP Fortran source code to be compiled or object code to be linked. Items in options and files can be interspersed on the command line, separated by spaces. However, some options are order-sensitive. For example, the -l option, which is used to specify a library for linking, must follow the program file to which it will be linked.
For information about using the-l option, see “Linking to nondefault libraries” (page 52). For more information about the f90command line, see HP Fortran Programmer’s Reference.

Command-line options

Command-line options enable you to override the default behavior of the f90command. Some options affect how files are compiled or linked; for example, the -Ooption requests optimization. Other options may cause the f90 command to skip a process entirely; for example, the -coption compiles without linking. And still others invoke processes other than the default ones; for example, the +cpp=yes option causes the f90 command to send source files to the C preprocessor (cpp) before compiling. (For information about using cpp, see “Using the C preprocessor” (page 60).)
Command-line options enable you to override the default behavior of the f90 command. Some options affect how files are compiled or linked; for example, the -Ooption requests optimization. Other options may cause the f90command to skip a process entirely; for example, the -coption compiles without linking. And still others invoke processes other than the default ones; for example, the +cpp=yes option causes the f90 command to send source files to the C preprocessor (cpp) before compiling. (For information about using cpp, see “Using the C preprocessor” (page 60).)
Many options are of the form +[no]option, where +option enables the option’s functionality and +nooption disables it. Other options have more than just an on or off state; these are of the
Command-line options 19
form +option=arg. You can cause f90 to list the values for arg on stderr by specifying just the option name without an argument. For example, given the command line:
$ f90 +langlvl= prog.f90
f90 will issue the following message:
f90: The '+langlvl=' option requires one of s
Still other options take a name as an argument. For example, the -oname option specifies the name you want to give to the output file. If you misspell an option on the f90 command line, the driver looks for options that are similar to the one you entered and lists them as possible alternatives on stderr. It meanwhile compiles the program without the option in question.
For detailed information about the syntax of all the options, see the HP Fortran Programmer’s Reference. For a brief descriptive list of the options, use the command line:
$ f90 +usage

Commonly-used options

Table 2-1 identifies commonly-used command-line options for when you want to change the compiler’s default behavior. For a complete and full description of all HP Fortran command-line options, see “Option descriptions” (page 21)
Table 7 Commonly-used options
FunctionOption
-c
-g
-Ldirectory
-O
+save
-ooutfile
-v
Compile without linking. Use this option to compile and link in separate steps.
Prepare program for debugging. Use this option to prepare your program for debugging.
Specify where to look for libraries; applies only to succeeding -l options. Be careful about using this option if the LPATH environment variable is set.
Specify a library. Use this option to link in library routines.-lx
Optimize. Use this option to optimize your program at the default level of optimization.
Give the SAVE attribute to local variables. Use this option when porting older Fortran programs that may contain uninitialized variables.
Name the output file outfile. Use this option to name the executable or object file.
List all compile-line options currently supported by f90.+usage
Enable verbose mode. Use this option to get a report on the compilation process.
Set include file and module search path.-Idirectory
Specify that the arg has to be passed by a linker option.-Wl,arg

Command-line options by category

Table 2-2 categorizes the f90 command-line options. For detailed information about each of the options, see “Option descriptions” (page 21).
20 Compiling and linking
Table 8 Options listed by category
OptionsCategory
Compatibility and porting
Data storage
Debugging
Language features
Linking
+autodbl, +autodbl4, +charlit77 +[no]es, +extend_source, gformat77, +i8, +io77, +langlvl, +multi_open, +nocheckuf, +nopadsharedcommon, +onetrip, +ppu, +r8, +save, +[no]signedzero, and +U77
-t and -WCompiler configuration
+autodbl, +autodbl4, +hugecommon, +hugesize, +i8, +indirectcommonlist=file, +nopadsharedcommon, +r8, +real_constant, and +save
+U77, -I, -L, -l, and +moddirDirectory, module, and library search path
+check, +dlines,+fp_exception, -g, +initheap_complex, +initheap_integer, +initheap_real and +initheap_set
+FP and +fp_exceptionError control
+O[no]openmpIndustry standardized extensions
+escape, +extend_source, +escape, +f2003, +implicit_none, +langlvl, +[no]signedzero, and +source
+demand_load, -dynamic, +FP, +k, -L, -l, +shared, +sharedlibF90, +strip, and +uppercase
Listing and messages
Performance and optimization
Miscellaneous

Option descriptions

The following alphabetical list describes each of the command-line options recognized by HP Fortran. The +usage option also lists and briefly describes all of the currently supported options.
+A
+noalign64bitpointers
+asm, +dryrun, +langlvl=90, +list, -v, +version, +what, and -w
+nlsNative language support
+cat,+DA, +DC, +DO, +DS, +fastallocatable, +O, and -O +Oparallel_intrinsics
+cpp, +cpp_keep, -D, and -UPreprocessor
+gprof, +prof, +pa, +palProfiling
+asm, -c, +getarg0, +getarg1, +noalign64bitpointers, -o, +pic, +pre_include, +ttybuf, and +usage, +Z, +z
Set the alignment of data items within FORTRAN STRUCTUREs, COMMONblocks, and EQUIVALENCEclasses. Specifying +Awithout any arguments aligns data on 2-byte boundaries;
therefore, it is slightly different than the f77 +A.
Disables the correct alignment of pointers in derived types when compiling for wide mode (+DA2.0W).
NOTE: This option is only valid on the PA-RISC systems.
+allow_ivdep
Allows the IVDEPdirective. The IVDEPdirective assists the compiler’s dependence analysis. It can only be applied to
iterative DO loops and is only honored when the +allow_ivdepcompiler flag is used. The IVDEPdirective takes the following form:
Command-line options 21
C$DIR IVDEP
Rules and behavior: The IVDEPdirective is an assertion to the compiler’s optimizer about the order of memory
references inside a DOloop. The IVDEPdirective tells the compiler to begin dependence analysis by assuming all
dependences occur in the same forward direction as their appearance in the normal scalar execution order. This contrasts with normal compiler behavior, which is for the dependence analysis to make no initial assumptions about the direction of a dependence.
The IVDEPdirective must precede the DOstatement for each DOloop it affects. No source code lines, other than the following.
The IVDEPdirective is applied to a DOloop in which the user knows that dependences are in lexical order. For example, if two memory references in the loop touch the same memory location and one of them modifies the memory location, then the first reference to touch the location has to be the one that appears earlier lexically in the program source code. This assumes that the right-hand side of an assignment statement is earlier than the left-hand side.
The IVDEPdirective informs the compiler that the program would behave correctly if the statements were executed in certain orders other than the sequential execution order, such as executing the first statement or block to completion of all iterations, then the next statement or block for all iterations, and so forth. The optimizer can use this information, along with whatever else it can prove about the dependences, to choose other execution orders.
Example 3 EXAMPLE:
In the following example, the IVDEP directive provides more information about the dependences within the loop, which may enable loop transformations to occur:
C$DIR IVDEP DO I+1, N A(INDARR(I)) = A(INDARR(I)) + B(I) END DO
+[no]asm
+[no]autodbl
In this case, the scalar execution order follows:
Retrieve INDARR(I)
Use the result from Step 1 to retrieve A(INDARR(I));
Retrieve B(I);
Add the results from Steps 2 and 3 ;
Store the results from Step 4 into the location indicated by A(INDARR(I))from Step1.
IVDEPdirects the compiler to initially assume that when Steps 1 and 5 access a common memory location, Step 1 always accesses the location first because Step 1 occurs earlier in the execution sequence. This approach lets the compiler reorder instructions, as long as it chooses an instruction schedule that maintains the relative order of the array references.
Relaxes the natural data type rules for alignment.+allow_unaligned
+asm compiles the named programs and leaves the assembler-language output in corresponding files whose names have the extension. The assembler-language output produced by this option is not supported as input to the assembler. The default is +noasm. The -Soption can be used to perform the same function as +asm.
+autodblincreases the default size of integer, logical, and real items to 8 bytes; see Table 2-3. It also increases the default size of double precision and complex items to 16 bytes. This option does not increase the size of the following:
Items of character type
Items declared with the BYTEstatement
Items declared with the DOUBLE COMPLEXstatement
Explicitly sized items
For example, the following are unaffected by +autodbl: INTEGER(KIND=4)
INTEGER(4) J
REAL*8 D
22 Compiling and linking
3.1416_4, 113_4 Note, however, that constants specified with an exponent—for example, 4.0E0and
2.3D0—are doubled.
Items promoted include constants, scalar variables, arrays, components of derived types, and record fields. This option also promotes intrinsics as well as the results and arguments of user-defined functions to the proper precision. Types specified in ONstatements are also promoted.
The entire program should be compiled with this option, not just selected files. This option is useful when porting programs that depend on the increased precision of 8 and
16 bytes. If you want to promote only single-precision items, use the +autodbl4option. (REAL(KIND=16)arithmetic is slow.)
The default is +noautodbl.
Table 9 Data type sizes and +autodbl[4]
Sizes in bytes of intrinsic types
ComplexDouble precisionInteger, logical, and real
884Default sizes
16168+autodbl
1688+autodbl4
+[no]autodbl4
-Boption
-c
Like +autodbl, +auotdbl4 increases the default size of integer, logical, and real items to 8 bytes, and the default size of complex items to 16 bytes; see Table 2-3. Unlike +autodbl, it does not increase the default size of double precision. This option does not increase the size of the following:
INTEGER(KIND=4)
INTEGER(4) J
REAL*8 D
3.1416_4, 113_4
Note, however, that constants specified with an exponent—for example, 4.0E0and 2.3D0—are doubled.
Items promoted include constants, scalar variables, arrays, components of derived types, and record fields. This option also promotes intrinsics as well as the results and arguments of user-defined functions to the proper precision. Types specified in ON statements are also promoted.
The entire program should be compiled with this option, not just selected files. Use this option when you want to promote only the single-precision items.
The default is +noautodbl4.
NOTE: The +autodbl4option causes items declared as REAL, INTEGER, and DOUBLE
PRECISION all to have the same size. This violates the Fortran Standard.
This option can be specified to invoke ld with -bto create a shared library.-b
The -Boptions are recognized by HP Fortran to specify whether references to global symbols may be resolved to symbols defined in the current translation unit, or whether they must be assumed to be potentially resolved to symbols defined in another load module. The -Boptions are only supported on HP-UX version 11i and later. See “Symbol binding options” (page 37).
-c compiles the specified source files but does not link them. The compiler produces a relocatable file (.o) for each file in the files list (these may include.f90, .f, .F, .i, .i90and .sfiles). When using -cand -otogether, you may specify only one source file on the command line; the resulting object file is renamed.
Command-line options 23
-C
+charlit77
+check={
}
Performs run-time error checking of array subscripts. This option is deprecated and replaced by the +check=alloption.
+charlit77 causes character literals to be placed in writable static storage. This allows character strings passed as actual arguments to be modified by the called routine.
all|
none|
uninit|
bounds|
bounds:array|
bounds:all|
bounds:none|
-check_bounds
+check=all
enables compile-time range checking for array subscripts. The +check=all option will also cause an executing program to halt with a runtime error if any of the following is detected:
Integer overflow
Use of uninitialized stack variable
Out-of-bounds subscripts
Out-of-bounds substrings
enables run-time checks for use of uninitialized stack variables.+check=uninit
enables run-time checks for out-of-bounds references to array variables.+check=bounds
enables run-time checks for out-of-bounds references to array variables.+check=bounds:arrary
+check=bounds:all
-check_bounds
+[no]cfc
+cpp={yes|no|default}
+cpp=yes
+cpp=default
+cpp=no
Enable or Disable Compaq/DEC F90 language mode.
tells the compiler to pass the source files specified on the command line to the C preprocessor before passing them on to the compiler. This option does not apply to .i and .i90 files.
The default, , is to apply the C preprocessor to files that end in the .F extension but not to files that end in .f or .f90.
Specifying tells the compiler not to invoke the C preprocessor for all files on the command line, including those ending in .F.
enables run-time checks for both +check=bounds:array and +check=uninit.
disables out-of-bounds run-time check.+check=bounds:none
performs run-time error checking; promote compile-time bound violations to errors.
If you want to keep the output from the C preprocessor, use the +cpp_keepoption.
+[no]cpp_keep
24 Compiling and linking
+cpp_ keep causes the compiler to retain the output from the C preprocessor. If the source filename is file.for file.F, the output filename is file.i; if the source filename is file.f90, the output filename is file.i90. The compiler will accept source files with the.i and .i90 extensions.
The default,+nocpp_keep , is to discard the output file.
Note that this option does not pass source files to the C preprocessor. To do that, you must also specify the +cpp=yes option.
-D name[=def]
+DAmodel
-Ddefines a symbol name (name)to the C preprocessor. If you do not provide a
definition (def) for the symbol name, name is defined as 1. This option applies only to files that are passed to the C preprocessor.
+DA generates object code for a particular version of the PA-RISC architecture. By default, the compiler generates code for the machine model you are compiling on. With this option, you can override the default, causing the compiler to generate code for the machine on which the program will execute rather than for the machine on which it is compiled.
modelcan be one of the following:
A PA-RISC version number (1.1or2.0™)
A model number (for example, 750or870)
One of the PA-RISC processor names (for example, PA7000, PA7100, or PA8000)
The word portable, which causes the compiler to generate code that is compatible
across all PA-RISC 1.1 and 2.0 systems
For best performance, use +DA with the model number or architecture of the machine on which you plan to execute the program.
The +DA option also specifies the appropriate search path for HP-UX math libraries. If your program calls mathematical functions,+DA2.0 links in the PA2.0 version of the math library, while +DA1.1 links in the PA1.1 library version. (For more information about using math libraries, see the HP-UX Floating-Point Guide.)
With +DA2.0W, memory addresses are 64-bit values. This allows common blocks and dynamically allocated memory to exceed 32-bit address limits. This feature is restricted by the available virtual memory on the system where the application is run.
NOTE: You must specify +DA2.OW to generate 64-bit code. At PA64, all data types
remain the same size as at PA32 except for pointers. Fortran pointers are hidden from the user and cannot be directly manipulated
+DA2.OW
+DC
+DDdatamodel
+[no]demand_load
+dfname
Changes the default size of a Cray pointer. It will become the large of a default-sized integer and a C pointer (8-bytes), rather than the 4-byte default.
Specifies cache values to the compiler. The syntax is +DC <a>:<b>:<c>: where <a> is the total cache size in bytes where <b> is the cache line size in bytes; and <c> cache associativity.
+DC7200performs memory hierarchy optimizations for the PA7200 processor.+DC7200
Generate code using either the ILP32or LP64data model. Defined values for datamodelare:
32
64
The default is +DD32.
+demand_load causes the output file from the linker to be marked demand load. When a process is marked demand load, its pages are brought into physical memory only when they are accessed. The default, +nodemand_ load, causes the output file from the linker not to be marked demand load. The -q option performs the same function as +demand_load, and the -Qoption performs the same function as +nodemand_load.
Specify profile database file name for profile-based optimizations. +dfrequires the specification of +P.
This option is a synonym for +Oprofile=use: filename. This option is only valid on the Itanium® processor family architecture. The default is flow.dataif a name is not specified.
Use the ILP32data model. The sizes of the int, long, and pointer data types are 32-bits.
Use the LP64data model. The size of the int data type is 32-bits, and the sizes of the long and pointer data types are 64-bits. Defines LP64 to the preprocessor.
Command-line options 25
+[no]dlines
+dlines treats source lines with a “D” or “d” in column 1 as statements to be
compiled. The default, +nodlines, treats lines beginning with “D” or “d” in column 1 as comments.
The +dlines option must be used only with source files in fixed-format.
+DOosname
+dryrun
+DSmodel
+[no]escape
+[no]es
-exec
+DOosname sets the target operating system for the compiler, and is intended for
enabling optimizations that are not backward compatible. PA-RISC— based system recognized values for osnameare 11.0 and 11.0EP9806. Itanium®— based system recognized values for osnameare 11.20, 11.22, and
11.23. +DOosname can be used at any level of optimization. The default value for osname
is the operating system version of the computer on which the compiler is invoked.
+dryrun option generates sub-process information for a given f90 command line without running the sub-processes.
It is useful in the development process to obtain command lines of compiler sub-processes to run the commands manually or to use them with other tools.
+DS specifies an instruction scheduling algorithm for a particular implementation of the PA-RISC architecture, as specified by model.
A PA-RISC version number (1.1or 2.0)
A model number (for example, 750or 870)
One of the PA-RISC processor names (for example, PA7000, PA7100, or PA8000)
Itanium® values as defined below.
For example, specifying +DS750 performs instruction scheduling tuned for one implementation of PA-RISC 1.1Specifying +DS 2.0 or +DS 1.1 performs scheduling
for a representative PA-RISC 2.0™or1.1 system, respectively. To improve performance on a particular model, use +DSwith that model number.
Object code with scheduling tuned for a particular model will execute on other systems, although possibly less efficiently.
If you do not use this option, the compiler uses the argument specified with the +DAoption. If you use neither +DSor +DA, the default instruction scheduling is for the system on which you are compiling.
On Itanium®-based architectures, the defined values for model are:
blended
itanium
itanium2
native
-dynamic is used to generate dynamically-bound executables.-dynamic
+escape treats the backslash character (\) as a C-like escape character. The default, +noescape, treats the backslash character as a literal character.
+[no]es is similar to +[no]extend_source except that character literals and
hollerith constants continued across a line boundary are not padded. This option provides compatibility with FORTRAN 77’s +es option.
Indicates that any object files created will be used to create an executable file. Constants with a protected or hidden export class are placed in the read-only data section. This option also implies -Bprotected_def.
Tune for best performance on a combination of processors (i.e., Itanium or Itanium® 2 processor).
Tune for best performance on an Itanium® processor.
Tune for best performance on an Itanium® 2 processor.
Tune for best performance on the processor on which the compiler is running.
26 Compiling and linking
+[no]extend_source
+extend_source allows extended source lines, which may contain up to 254
characters. The default, +noextend_source, restricts fixed-format source lines to 72 characters and free-format source lines to 132 characters.
Programs that depend on the compiler’s ignoring characters past column 72 will not compile correctly with the +extend_source option.
+externals=file
+fastallocatable
+fltconst_strict
+FPflags
Specifies a file that contains a list of procedure names to be considered external as opposed to intrinsic. Using this option causes the routines whose names appear in file to be treated as if they were declared with theEXTERNAL attribute.
+f2003 enables FORTRAN 2003 features supported by the compiler.+f2003
+fastallocatable enables a different representation for allocatable arrays in the
object code produced by the compiler. This alternate representation avoids problems in optimizing code containing allocatable array references. Additionally, this alternate representation for allocatable arrays is binary compatible with the old representation.
Uses a strict power table for converting floating constants with exponents. Use of strict power table provides a more accurate floating point representation.
+FP initializes the flagsthat specify how runtime floating-point exceptions should be trapped; uppercase flags enable traps, lowercase flags disable traps. flags can be concatenated to specify a desired behavior and may not contain spaces or tabs. Valid values for flags are identified in Table 2-4.
By default, all traps are disabled. However, you can specifically disable a behavior either by excluding the upper-case letter from flags or by including the equivalent lower-case letter (v,z,o,u,i,d) in flags. For example, the following command lines are equivalent:
$ f90 +FPvZI test.f90
$ f90 +FPZI test.f90
If you are using PA1.1 libraries, you can dynamically change these settings at run time by using thefpsetdefaults or fpsetmask routines. For more information about these routines, see the fpgetround (3M) man page and the HP-UX Floating-Point Guide.
Enabling sudden underflow may cause the same program to compute different results on different implementations of the PA-RISC 1.1and 2.0architectures. This is because some hardware implementations have sudden underflow available, while others do not. The +FPDoption enables the hardware to flush denormalized values to zero, but it does not require that it do so.
Table 10 Values for the +FP option
MeaningValue
Trap on invalid floating-point operations. Examples of invalid floating-point operations include the following:V
Arithmetic operation on NaNs
Operations such as (+inf) + (-inf) and (+inf) - (+inf)
Multiplication of 0 and infinity
Division operations 0/0 and inf/inf
Certain floating-point remainder operations
Square root of a negative value
Certain kinds of comparisons of unordered values Z
Trap on floating-point divide by zero.Z
Trap on floating-point overflow.O
Trap on floating-point underflow.U
Command-line options 27
Table 10 Values for the +FP option (continued)
MeaningValue
I
D
+[no]fp_exception
Trap on floating-point operations that produce inexact results. Inexact result traps may occur whenever roundoff is necessary to produce the result. For example, the fraction 1.0/3.0 produces an inexact trap because there is no exact floating-point representation for this fraction.
Enable sudden underflow (flush to zero) of denormalized values on those PA-RISC systems greater than version
1.0 that have implemented sudden underflow. (That is, +FPD enables sudden underflow only if it is available on the processor that is used at run time.) Denormalized values are those values whose absolute value is very close to zero. For IEEE single precision data types, the largest denormalized value is approximately equal to 2-126. For IEEE double precision data types, such values are approximately equal to 2 -1022. Sudden underflow will cause some floating-point applications to run faster, with a possible loss of numerical accuracy on numbers very close to zero.
+fp_exceptionis a compile time flag. It causes a descriptive message and a procedure traceback to be issued to standard error when the HP-UX signals listed in Table 2-5 are generated.
For a description of these signals, see signal(2) and signal(5) in the HP-UX Reference. For information about floating-point exceptions and error handling, see the HP-UX Floating-Point Guide.
You can also use the ON statement to write your own trap procedures. For information about the syntax of the ON statement, see “Using the ON statement” (page 81).
The default,+nofp_exception , disables traceback information.
Table 11 Signals recognized by the +fp_exception option
MeaningSignal
Illegal instructionSIGILL
-g
-G
gformat77
+[no]gprof
+hugecommon
Floating-point exceptionSIGFPE
Bus error instructionSIGBUS
Segmentation violationSIGSEGV
Bad argument to system callSIGSYS
-g causes the compiler to generate information for use by the HP WDB debugger. The -goption can be used to prepare code for debugging that has been compiled with optimization options-O,-O1/+O1, , but not O3/+O3or higher.
+getarg0and +getarg1control the behavior of the getarg intrinsic subroutine. +getarg0 requests the industry standard behavior for getarg, where an index value of zero causes the program name to be returned. HP’s FORTRAN 77 getarg intrinsic also implements this industry standard convention. +getarg1is used to request non-standard behavior, where an index value of one causes the program name to be returned (older releases of HP Fortran behaved in this manner). The default is +getarg0.
gformat77 requests the FORTRAN 77 style of formatting a value of zero with the G edit descriptor. Fortran 90 uses an F edit descriptor when the value being written is zero, while FORTRAN 77 uses an E edit descriptor.
+gprof prepares object code files for profiling with gprof. The default is +nogprof. gprofis provided as part of the “HP-UX General Programming Tools” product; see gprof(1). The
-Goption can be used to perform the same function as +gprof.
+hugecommon instructs the compiler to place the specified COMMON block into a huge data segment. The format for this option is: +hugecommon=name
where name is the name of a COMMON block. By default, only COMMON blocks larger than 2 gigabytes are placed into huge data segments.
For example:
28 Compiling and linking
Example 4 % f90 +hugecommon=results pcvals.f90
places the COMMON block named results into a huge data segment. +hugecommonis especially useful when a program contains several different COMMON blocks that together occupy more than two gigabytes but individually occupy less than two gigabytes. In this situation, the largest COMMON blocks could be placed in a huge data segment when the program is compiled by specifying their names in multiple +hugecommon options.
If a common block is specified as huge in one object file, it must be specified huge in all object files. If it is not, the program will fail to link.
NOTE: PA2.0W objects cannot be combined with 32-bit object files. 64-bit applications will
only execute on PA8000-based systems.
+hugesize
+i2
+i8
+hugesize instructs the compiler to place COMMON blocks that are
larger than the specified size into a huge data segment. The format for this option is: +hugesize=n
where n is the size in kilobytes (1024 bytes). The default is to place COMMON blocks larger than two gigabytes
(2147483648 bytes) into huge data segments; that is, +hugesize=2097152 is the default.
For example: % f90 +hugesize=1024 hello.f90 specifies that COMMON blocks larger than 1048576 bytes (1
megabyte) should be placed into a huge data segment. If a common block is specified as huge in one object file, it must be
specified huge in all object files. If it is not, the program will fail to link. PA2.0W objects cannot be combined with 32-bit object files. 64-bit
applications will only execute on PA8000-based systems.
NOTE: +hugesizeand +hugecommon options are not valid on HP
Itanium ®-based systems.
+i2 changes 4-byte integer and logical constants, intrinsics, and user variables to 2-byte integers (rather than the 4-byte default).
+i8 changes 4-byte integer and logical constants, intrinsics, and user variables to 8-byte integers (rather than the 4-byte default).
Specifies incremental linking. This option is valid only for 64-bit links.+ild If the output file does not exist, or if it was created without the +ild option,
the linker performs an initial incremental link. The output file produced is suitable for subsequent incremental links. The incremental link option is valid for both executable and shared library links. It is not valid for relocatable links, options (or tools) that strip the output module, and certain optimization options. See ld(1)for more information.
+ildrelink
-Idirectory
Perform an initial incremental link, regardless of the output load module. This option is valid only for 64-bit links.
In certain situations during incremental linking (for example, internal padding space is exhausted), the incremental linker is forced to perform an initial incremental link. The +ildrelinkoption allows you to avoid such unexpected initial incremental links by periodically rebuilding the output file.
-I specifies a directory where .mod files and files named in the INCLUDE line or in #include directives may be found if their name is a relative pathname—that is, does not begin with a slash (/). Directories are searched in the following order:
The current source directory—that is, the directory containing the file
with the INCLUDEline or #include.
Directories specified by the -Ioption, in the order specified
Command-line options 29
The current working directory
The /usr/include directory
+[no]implicit_none
+indirectcommonlist=file
+initheap_complex=rval:ival
+implicit none forces the types of identifiers to be implicitly undefined.
This is equivalent to specifying IMPLICIT NONE for each program unit in each file in the files list. The source code that is to be compiled with this option may contain other IMPLICIT statements; the statements will be honored. The default, +noimplicit_none, allows identifiers to be implicitly defined.
The common blocks listed in file (one per line, no enclosing ‘ / ‘s) are treated as shared common blocks, but are not attached. The user must attach or otherwise allocate storage for such common blocks before they are referenced.
A C language program would typically be used to either attach a shared memory segment, or malloc a block of memory, and store that address into the external symbol for the common block. All Fortran code that references such a common block will indirect through the address in the external symbol for that indirect common block.
All source files that reference variables in such a common block must be compiled with the +indirectcommonlist flag, and that common block name must appear in the named file.
Default initialization of heap variables (mentioned in +initheap_set option) of type complex. rval is real part and ival is imaginary part of complex number. Valid values for rval and ival are normal real numbers, nan , snan.
The numbers represented by rval/ival are mentioned in below table.
Table 12
+initheap_integer=ival
+initheap_real=rval
+initheap_set=var
NumVal
quiet NaNnan
Signaling NaNsnan
snan is supported at default optimization level only.
Default initialization of heap variables (mentioned in +initheap_set option) of type integer. Valid values of ival are integer values of the form decimal, octal (starting with 0) and hexadecimal (starting with 0x).
Default initialization of heap variables (mentioned in +initheap_set option) of type real. Valid values for rval are normal real numbers, nan, snan.
Table 13
NumVal
Quiet NaNnan
Signaling NaNsnan
snan is supported at default optimization level only.
Default Initialization of heap variables is done for the variables specified by var.
The defined values for var are:
Table 14
30 Compiling and linking
allocatable
all heap variablesall
variables having allocatable attribute
variables in common blockcommon
variables in modulemodule
Loading...
+ 129 hidden pages