HP Fortran Programmer's Guide HP-UX 11i v1, HP-UX 11i v2, and HP-UX 11i v3 Manufacturing Part Number: B3909-90029 September 2007
Print History Eighth Document Number B3909-90029 Released September 2007; document updates Seventh Document Number B3909-90027 Released February 2007; document updates Sixth Document Number B3909-90018 Released December 2004; document updates Fifth Document Number B3909-90014 Released September 2003; document updates Fourth Document Number B3909-90010 Released June 2003; document updates Third Document Number B3909-90009 Released September 2001; document updates Second Document Number B3909-90005 ii
Released June 2001. Added Itanium-based information First Document Number B3909-90002 Released October 1998.
Legal Notices Copyright 2007 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.
Contents 1. An overview of HP Fortran The HP Fortran compiler environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 C preprocessor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Front-end . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Contents Creating shared libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Compiling with +pic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Linking with -b . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Contents Exceptions handled by the ON statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Actions specified by ON . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Terminating program execution. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Ignoring errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Calling a trap procedure. . . . . . . .
Contents 7. Writing HP-UX applications Accessing command-line arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Calling HP-UX system and library routines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using HP-UX file I/O . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Stream I/O using FSTREAM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Contents Controlling parallelization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211 Controlling dependence checks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211 Controlling checks for side effects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212 10. Migrating to HP Fortran Incompatibilities with HP FORTRAN 77 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Contents Uninitialized variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Large word size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . One-trip DO loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Name conflicts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Tables Table 1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xviii Table 1-1. Options for controlling the f90 driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Table 1-2. Options for controlling the C preprocessor . . . . . . . . . . . . . . . . . . . . . . . . . 6 Table 1-3. Options for controlling the front end . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Table 1-4.
Tables Table 10-1. f77 options not supported by f90 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Table 10-2. f77 options replaced by f90 options . . . . . . . . . . . . . . . . . . . . . . . . . . . . Table 10-3. HP FORTRAN 77 directives supported by f90 options. . . . . . . . . . . . . Table 10-4. Conflicting intrinsics and libU77 routine names . . . . . . . . . . . . . . . . . Table 10-5. f77 options supported by f90 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Figures Figure 1-1. HP Fortran compiler environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Figure 3-1. Increasing default data sizes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 Figure 8-1. Memory layout of a two-dimensional array in Fortran and C . . . . . . .
Figures xiv
Preface The HP Fortran Programmer’s Guide describes how to use 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. You need not be familiar with the HP parallel architecture, programming models, or optimization concepts to understand the concepts introduced in this book. HP Fortran for Integrity systems is a part of the HP-UX PA-RISC Fortran product. HP Fortran is source compatible between HP 9000 and Integrity systems.
Scope This guide covers programming methods for the HP Fortran compiler on machines running: • HP-UX 11i v1 and higher on HP 9000 systems • HP-UX 11i v2 and higher on Integrity systems HP Fortran supports an extensive shared-memory programming model. HP-UX 11i v1 and higher includes the required assembler, linker, and libraries.
Notational conventions This section discusses notational conventions used in this book. Table 1 bold monospace In command examples, bold monospace identifies input that must be typed exactly as shown. monospace In paragraph text, monospace identifies command names, system calls, and data structures and types. In command examples, monospace identifies command output, including error messages. italic In paragraph text, italic identifies titles of documents.
Table 1 (Continued) Vertical ellipses Vertical ellipses show that lines of code have been left out of an example. Keycap Keycap indicates the keyboard keys you must press to execute the command example. The directives and pragmas described in this book can be used with the HP Fortran and C compilers, unless otherwise noted. The aC++ compiler does not support the pragmas, but does support the memory classes.
Associated documents The following documents are listed as additional resources to help you use the compilers and associated tools: • HP aC++ Online Programmer’s Guide—Presents reference and tutorial information on aC++. This manual is only available in html format. • HP Fortran Programmer’s Reference — Provides language reference for HP Fortran and describes the language features and requirements.
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.
An overview of HP Fortran 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.
An overview of HP Fortran The HP Fortran compiler environment The HP Fortran compiler environment Figure 1-1 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.
An overview of HP Fortran Driver Driver 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.
An overview of HP Fortran Driver Table 1-1 Options for controlling the f90 driver (Continued) Option -tx,name Function 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) If you compile and link separately and specify +tl on the compile line, you must also specify it on the link line.
An overview of HP Fortran C preprocessor 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.
An overview of HP Fortran Front-end 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.
An overview of HP Fortran Front-end Table 1-3 Options for controlling the front end (Continued) Option +[no]escape Function Treat the backslash character (\) as a C-like escape [literal] character. The default is +noescape. For information on using this option when porting, see “Escape sequences” on page 243. +[no]extend_source 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.
An overview of HP Fortran Front-end Table 1-3 Options for controlling the front end (Continued) Option Function +nls=lang Enable 16-bit Native Language Support (NLS) in strings and comments in the language specified by lang. +[no]onetrip Execute any counter-controlled DO loop at least once (+onetrip). The default is +noonetrip. For information about using this option when porting, see “One-trip DO loops” on page 239.
An overview of HP Fortran Back-end 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 transformations to increase performance.
An overview of HP Fortran Back-end Table 1-4 Options for controlling optimization (Continued) Option Function -O[optlevel] Optimize program, where optlevel is 0 (no optimization), 1, 2, or 3 (the highest level). If optlevel is not specified, the program is optimized at level 2 (-O2). +Ooptlevel This option has the same meaning as the -O[optlevel] option, except that optlevel must be specified. It is provided for compatibility with makefiles.
An overview of HP Fortran Back-end Table 1-5 Options for controlling code generation (Continued) Option +DAmodel Function 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.
An overview of HP Fortran Back-end Table 1-5 Options for controlling code generation (Continued) Option -g Function 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. For information about using this option to prepare programs for the debugger, see “Using the HP WDB debugger” on page 117.
An overview of HP Fortran Linker Linker 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.
An overview of HP Fortran Linker Table 1-6 Options for controlling the Linker (Continued) Option +[no]fp_exceptions Function 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. For information using this option, see “Floating-point exceptions” on page 120. -Ldirectory Add directory to the front of the library search path.
An overview of HP Fortran Linker Table 1-6 Option +[no]strip Options for controlling the Linker (Continued) Function Strip [do not strip] symbol table information from the linker output. For more information, see the ld(1) and strip(1) man pages. 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.
An overview of HP Fortran Tools 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” on page 117. The performance analysis tools include the standard UNIX utilities, prof and gprof.
An overview of HP Fortran HP-UX operating system HP-UX operating system Although the HP-UX operating system does not appear in 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.
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 Chapter 2 19
Compiling and linking • Linking HP Fortran programs • Special-purpose compilations • Using environment variables 20 Chapter 2
Compiling and linking Compiling with the f90 command 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 2-1 hello.
Compiling and linking Compiling with the f90 command where options is a list of one or more command-line options and files is 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.
Compiling and linking Compiling with the f90 command 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” on page 25. Table 2-1 Commonly-used options Option Function -c Compile without linking. Use this option to compile and link in separate steps. -g Prepare program for debugging.
Compiling and linking Compiling with the f90 command 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” on page 25.
Compiling and linking Compiling with the f90 command Table 2-2 Options listed by category (Continued) Category Options Native language support +nls Performance and optimization +cat,+DA, +DC, +DO, +DS, +fastallocatable, +O, and-O +Oparallel_intrinsics Preprocessor +cpp, +cpp_keep, -D, and -U Profiling +gprof, +prof, +pa, +pal Miscellaneous +asm, -c, +getarg0, +getarg1, +noalign64bitpointers, -o, +pic, +pre_include, +ttybuf, and +usage, +Z, +z Option descriptions The following alphabetical lis
Compiling and linking Compiling with the f90 command C$DIR IVDEP Rules and behavior: The IVDEP directive is an assertion to the compiler’s optimizer about the order of memory references inside a DO loop. The IVDEP directive 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.
Compiling and linking Compiling with the f90 command 2. Use the result from Step 1 to retrieve A(INDARR(I)); 3. Retrieve B(I); 4. Add the results from Steps 2 and 3 ; 5. Store the results from Step 4 into the location indicated by A(INDARR(I)) from Step 1. IVDEP directs 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.
Compiling and linking Compiling with the f90 command REAL*8 D 3.1416_4, 113_4 Note, however, that constants specified with an exponent—for example, 4.0E0 and 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.
Compiling and linking Compiling with the f90 command 3.1416_4, 113_4 Note, however, that constants specified with an exponent—for example, 4.0E0 and 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.
Compiling and linking Compiling with the f90 command +charlit77 +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. +check={all|none} +check=all enables compile-time range checking for array subscripts.
Compiling and linking Compiling with the f90 command -D defines 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. +DAmodel +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.
Compiling and linking Compiling with the f90 command 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. +DC Specifies cache values to the compiler. The syntax is +DC:: where is the total cache size in bytes; where is the cache line size in bytes; and is the cache associativity. +DC7200 +DC7200 performs memory hierarchy optimizations for the PA7200 processor.
Compiling and linking Compiling with the f90 command +[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 +DOosname sets the target operating system for the compiler, and is intended for enabling optimizations that are not backward compatible.
Compiling and linking Compiling with the f90 command On Itanium -based architectures, the defined values for model are: blended Tune for best performance on a combination of processors (i.e., Itanium or Itanium 2 processor). 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. -dynamic -dynamic is used to generate dynamically-bound executables.
Compiling and linking Compiling with the f90 command +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.
Compiling and linking Compiling with the f90 command sudden underflow available, while others do not. The +FPD option enables the hardware to flush denormalized values to zero, but it does not require that it do so. Table 2-4 Values for the +FP option Value Meaning V Trap on invalid floating-point operations.
Compiling and linking Compiling with the f90 command Table 2-4 Values for the +FP option (Continued) Value Meaning D 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.
Compiling and linking Compiling with the f90 command Table 2-5 Signals recognized by the +fp_exception option (Continued) Signal Meaning SIGSYS Bad argument to system call -g -g causes the compiler to generate information for use by the HP WDB debugger. The -g option can be used to prepare code for debugging that has been compiled with optimization options -O, -O1/+O1, and -O2/+O2, but not -O3/+O3 or higher. -G Generate code for gprof(1) profiling. This has the same functionality as +gprof.
Compiling and linking Compiling with the f90 command +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: % f90 +hugecommon=results pcvals.f90 places the COMMON block named results into a huge data segment. +hugecommon is especially useful when a program contains several different COMMON blocks that together occupy more than two gigabytes but individually occupy less than two gigabytes.
Compiling and linking Compiling with the f90 command PA2.0W objects cannot be combined with 32-bit object files. 64-bit applications will only execute on PA8000-based systems. +i2 +i2 changes 4-byte integer and logical constants, intrinsics, and user variables to 2-byte integers (rather than the 4-byte default). +i8 +i8 changes 4-byte integer and logical constants, intrinsics, and user variables to 8-byte integers (rather than the 4-byte default). +ild Specifies incremental linking.
Compiling and linking Compiling with the f90 command +[no]implicit_none +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.
Compiling and linking Compiling with the f90 command +k generates code for programs that reference a very large number of shared data items. The linker will issue a diagnostic message in the rare case when this option is needed. By default, the compiler generates short-displacement code sequences for programs that reference global data in shared libraries. For nearly all programs, this is sufficient. -K Use static storage for locals instead of stack storage.
Compiling and linking Compiling with the f90 command Enables attaching multiple FORTRAN UNITs to the same file by allowing the file to be opened in multiple Fortran OPEN statements. -n Mark output from the linker shared. For details and system defaults, see ld(1). -N Mark output from the linker unshared. For details and system defaults, see ld(1). +nls=lang +nls enables 16-bit Native Language Support processing in character strings and comments for the specified language lang.
Compiling and linking Compiling with the f90 command -O[n] -O invokes the optimizer, where n is the level of optimization, 0 - 4. (+O4 is recognized but not supported.) The default is optimization level 2. This option is provided for compatibility and is functionally the same as the +On option. The only difference between the two is that the level number is optional for the -O option. For more information about the levels of optimization, see the +On option.
Compiling and linking Compiling with the f90 command Table 2-6 Levels of optimization (Continued) Level Optimizations 2 Optimizations performed at level 1, plus the following: 3 Chapter 2 • Coloring register allocation • Induction variables and strength reduction • Common subexpression elimination • Loop invariant code motion • Store/copy optimization • Unused definition elimination • Dataflow analysis • Software pipelining • Scalar replacement • Sum reduction optimization Optimi
Compiling and linking Compiling with the f90 command Table 2-6 Level Levels of optimization (Continued) Optimizations 4 Level 4 optimizations are not currently supported by the PA-RISC compiler. If +O4 is specified, the compiler will issue a warning message and compile at optimization level 3. For Itanium applications, performs level 3 as well as doing interprocedural optimizations across translation units (link time optimizations).
Compiling and linking Compiling with the f90 command +noobjdebug can be used at link time to continue to place the debug info into the a.out, even if some objects were compiled with +objdebug. NOTE Object files and archive libraries must be accessible to the debugger if the +objdebug method of storing debug information is used. +[no]onetrip +onetrip generates code that executes any DO loop at least once.
Compiling and linking Compiling with the f90 command NOTE +pa is ignored when the HP Fortran compiler generates position-independent code (PIC). The following options cause +pa to be ignored: +pic=short, +pic=long, +z and +Z. +[no]padsrc Specifies that source records shorter than the statement field width are [are not] to be padded with spaces on the right, out to the end of the statement field. This affects the interpretation of character and Hollerith literals that are continued across source records.
Compiling and linking Compiling with the f90 command The +z option performs the same function as +pic=short, and the +Z option performs the same function as +pic=long. +[no]ppu +ppu appends underscores to external names, including subroutines, functions, and common blocks (for example, int_sum_ rather than the default int_sum). For Itanium and PA-RISC 64-bit architectures,the default is +ppu. For PA-RISC 32-bit architecture, the default is +noppu.
Compiling and linking Compiling with the f90 command Set the precision of real and complex constants to single-precision. This has the same functionality as the +real_constant=single option (the default). -R8 Set the precision of real and complex constants to double-precision. This has the same functionality as the +real_constant=double option. The default is +real_constant=single.
Compiling and linking Compiling with the f90 command +noshared causes the output file from the linker to be marked unshared. The default, +shared, is to mark the output file as shared. The -n option performs the same function as +shared, and the -N option performs the same function as +noshared. +[no]sharedlibF90 +sharedlibF90 allows users to link the shared version of libF90 or libF90_parallel from /usr/lib.
Compiling and linking Compiling with the f90 command +strip causes the linker to strip symbol table information from the executable program. This option is incompatible with the -g option. The default is +nostrip. The -s option can be used to perform the same function as +strip. -tx,path -t looks in path for the subprocess identified by x and substitutes it for the default subprocess. x can be one or more identifiers indicating the subprocesses.
Compiling and linking Compiling with the f90 command The compiler will use more accurate cosd, sind, and tand intrinsics, than the standard ones. While the standard ones have some accuracy problems with the boundary cases (i.e., cosd(90) needs to be 0.0), these new intrinsics get these cases right. +[no]ttybuf +ttybuf controls tty buffering, using buffered output. +nottybuf uses unbuffered output. The default is buffered output (+ttybuf).
Compiling and linking Compiling with the f90 command If you need to control the case of specific names, use the $HP$ ALIAS directive, as described in “$HP$ ALIAS” on page 203. +usage +usage lists and briefly describes all of the command-line options currently supported by the HP Fortran compiler. No compile occurs. -v -v enables the verbose mode, producing a step-by-step description of the compilation process on the standard error output.
Compiling and linking Compiling with the f90 command -Wl,-a,shared Table 2-8 Values for the -W option Value Meaning a Assembler c Compiler l Linker p C preprocessor Chapter 2 55
Compiling and linking Compiling with the f90 command -Y=lang Enable Native Language Support in the given language (lang). This has the same functionality as the +nls option. +z see +pic=short in this chapter. If +z is specified when creating 64-bit code, it instead maps to +Z. +Z see +pic=long in this chapter for a description. Note that when creating 64-bit shared executables (such as when +DA2.0W is specified), the +Z option is on by default.
Compiling and linking Compiling with the f90 command The file indicated by filename contains a list of symbols, separated by spaces or newlines. These symbols are assigned the default export class. -Bextern [=symbol [,symbol...]] The named symbols, or all undefined symbols if no list is provided, are assigned the default export class. Additionally, the compiler will inline the import stub for calls to these symbols. No compile-time binding of these symbols will be done.
Compiling and linking Compiling with the f90 command The file indicated by filename contains a list of symbols, separated by spaces or newlines. These symbols are assigned the hidden export class. -Bprotected [=symbol [,symbol...]] The named symbols, or all symbols if no symbols are specified, are assigned the protected export class.
Compiling and linking Compiling with the f90 command The following subsections describe the options in both categories. For information about the options that control levels of optimization, see the description of the +On option in the “Option descriptions” on page 25. The +O[no]info option, which provides compile-time information about the optimization process, is described in the same section.
Compiling and linking Compiling with the f90 command • +Onofltacc • +Onoinitcheck • +Ovectorize The +Oaggressive option is incompatible with +Oconservative. The default is +Onoaggressive. +O[no]all +Oall performs maximum optimization, including aggressive optimizations and optimizations that can significantly increase compile time and memory usage. The +Oall option automatically invokes the highest level of optimization. The default is +Onoall.
Compiling and linking Compiling with the f90 command +Oconservative causes the optimizer to make conservative assumptions about the code when optimizing it. This option is only effective at optimization level 2 or higher. The +Oconservative option sets the following options: • +Onofltacc • +Onomoveflops • +Oparmsoverlap Use +Oconservative when conservative assumptions are necessary due to the coding style, as with nonstandard-conforming programs. Note that it is incompatible with +Oaggressive.
Compiling and linking Compiling with the f90 command Fine-tuning optimization options The following options allow you to fine-tune the optimization process by providing control over the specific techniques that the optimizer applies to your program. The syntax for using these options is +O[no]optimization where optimization is a parameter that specifies an optimization technique to apply to your program. The different parameters are described below. The prefix no negates the effect of optimization.
Compiling and linking Compiling with the f90 command +O[no]cxlimitedrange Enables [disables] the use of floating point math in the compilation unit. The default is +Onocxlimitedrange. +O[no]cross_region_addressing Enable [disable] the use of cross-region addressing. Cross-region addressing is required if a pointer (such as an array base) points to a different region than the data being addressed. This is usually due to an offset which results in a cross-over into another region.
Compiling and linking Compiling with the f90 command The option can change the behavior of programs that perform exception-handling or that handle asynchronous interrupts. The default is +Onoentrysched. +O[no]failsafe Enable [disable] failsafe optimization.
Compiling and linking Compiling with the f90 command +O[no]fltacc +Onofltacc enables optimizations that follow the rules of algebra but may change the order of expression evaluation. For example, if a, b, and c are floating-point variables, the expressions (a + b) + c and a + (b + c) may give slightly different results due to roundoff. The +Onofltacc option also enables the fusion of adjacent multiply and add operations—resulting in Fused Multiply-Add (FMA).
Compiling and linking Compiling with the f90 command limited—like default, but also allows floating point optimizations which may affect the generation and propogation of infinities, NaNs, and the sign of zero. Also implies +Ocxlimitedrange. relaxed—in addition to the optimizations allowed by limited, permits optimizations, such as reordering of expressions, even if parenthesized, that may affect a rounding error. This is the same as +Onofltacc. Also implies +Ocxlimitedrange.
Compiling and linking Compiling with the f90 command When +Onoinitcheck is specified, the optimizer issues warning messages when it discovers definitely uninitialized variables, but does not initialize them. When this option is unspecified, the optimizer initializes to zero any local, scalar, nonstatic variables that are definitely uninitialized with respect to all paths leading to a use of the variable. This option is only effective at optimization level 2 or higher.
Compiling and linking Compiling with the f90 command Note, however, that the +Oinline_budget option takes precedence over both of these options. This means that you can override the effect of +Onolimit or +Osize option on inlining by specifying the +Oinline_budget option on the same command line. This option is only effective at optimization level 3 or higher. Table 2-10 Values for the +Oinline_budget option Values for n Meaning = 100 Default level of inlining. > 100 More aggressive inlining.
Compiling and linking Compiling with the f90 command The default is +Onolibmerrno. +O[no]loop_block +O[no]loop_block enables or disables blocking of eligible loops for improved cache performance. The +Onoloop_block option disables both automatic and directive-specified loop blocking. +O[no]loop_transform +Oloop_transform enables transformation of eligible loops for improved cache performance.
Compiling and linking Compiling with the f90 command +Omultiprocessor tells the compiler to appropriately optimize several different processes on multiprocessor machines. The optimizations are those appropriate for executables and or shared libraries. +Onomultiprocessor, the default, disables the optimization of more than one process running on a multiprocessor machine. +O[no]openmp +Oopenmp allows users to enable the OpenMP directives. +Onoopenmp will disable the OpenMP directives.
Compiling and linking Compiling with the f90 command +O[no]pipeline +Opipeline enables software pipelining. This option is only effective at optimization level 2 or higher. Use +Onopipeline (disable software pipelining) to conserve code space. The default is +Opipeline. +Oprefetch_latency=num option Applies to loops for which the compiler generates data prefetch instructions.
Compiling and linking Compiling with the f90 command stride—collect stride data. all—collect all types of profile data. This is a synonym for +Oprofile=collect:arc,stride +Oprofile=collect instruments the application for profile-based optimization. This option is only valid for Itanium-based applications. +O[no]promote_indirect_calls Enable [disable} the promotion of indirect calls to direct calls. Indirect calls occur with pointers to functions. This option can be used at optimization levels 3 and 4.
Compiling and linking Compiling with the f90 command size is specified, all data is placed in the short data area. If size is 0, no data will be placed in the short data area, and all data references will use long offsets. The default is +Oshortdata=8. NOTE Using a value that is too big or without the optional size, possibly through +Ofast, may give various linker fixup errors, if there is more than 4Mb of short data.
Compiling and linking Compiling with the f90 command If you link separately from the command line and you compiled with the +Ovectorize option, you must ensure that the link line causes the math library to be searched. +Onovectorize is the default. +O[no]whole_program_mode Assert [do not assert] that only files compiled with this option directly reference any global variables and procedures that are defined in these files.
Compiling and linking Compiling with the f90 command NOTE Chapter 2 The compiler generates a .mod file for each file that defines a Fortran module. It also reads the .mod files when compiling source files that use modules. Do not specify .mod files on the command line. If you do, the compiler will pass them to the linker, which will try (and fail) to link them into the executable. For more information about .mod files, see “Compiling programs with modules” on page 82.
Compiling and linking Linking HP Fortran programs Linking HP Fortran programs This section discusses how to link object files and covers the following topics: • The advantages of using the f90 command for linking as well as for compiling • How to link libraries, including shared libraries • How to establish the search rules used by the linker when it looks for libraries For more information about the linker, refer to Programming on HP-UX and to the ld(1) man page. Linking with f90 vs.
Compiling and linking Linking HP Fortran programs 7 8 LPATH is: /opt/fortran90/lib/pa1.1:/usr/lib/pa1.1: /opt/fortran90/lib:/usr/lib:/opt/langtools/lib /usr/ccs/bin/ld -x /opt/langtools/lib/crt0.o hello.o /opt/fortran90/lib/libF90.a -lcl -lc -lisamstub Line 1 is the f90 command line. Line 2 is the information f90 passes to the compiler, including the full pathname of the compiler, the name of the source file (hello.
Compiling and linking Linking HP Fortran programs The libisamstub library is provided as a tool for migrating HP FORTRAN 77 programs that call ISAM routines. The ISAM library is not available with HP Fortran, but the stub library allows the linker to resolve references to ISAM routines in HP FORTRAN 77 programs. Table 2-13 Libraries linked by default on PA-RISC Library Contents /usr/lib/libcl.a Archive version of HP Fortran runtime library /usr/lib/libcl.
Compiling and linking Linking HP Fortran programs The -l option is order-sensitive: when the linker finds a reference in an object file that it cannot resolve in the default libraries, it searches the libraries (if any) specified after the file on the command line. For example, the following command line tells the linker to look for unresolved references in the math library as well as the default libraries: $ f90 prog.
Compiling and linking Linking HP Fortran programs 64-bit PA-RISC 2.0 code -L/opt/fortran90/lib/pa20_64/ -lF90 -lisamstub Additional HP Fortran libraries HP Fortran provides the following two libraries you can link with Fortran programs: • /opt/fortran90/lib/libU77.a: The BSD 3f (libU77) library, which provides a Fortran interface to some of the libc system routines. Programs that reference routines in this library must be compiled with the +U77 option.
Compiling and linking Linking HP Fortran programs The disadvantage of linking with a shared library is that it creates a dependency between the library and the program; both the shared library and the program must always be installed together on the same system. By contrast, linking with an archive library makes the executable program independent of the library to which it was linked. Also, programs that make frequent calls to library routines may run more slowly when linked to shared libraries.
Compiling and linking Special-purpose compilations 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.
Compiling and linking Special-purpose compilations • How to compile a program that uses modules • How to design makefiles to work with modules • How to use the -I and +moddir options to manage .mod files Examples Consider, for example, a program that consists of three files: main.f90, code.f90, and data.f90. The main program unit is in main.f90, as follows. Example 2-2 main.
Compiling and linking Special-purpose compilations INTEGER :: new_item n_items = n_items +1 item(n_items) = new_item sum = sum + new_item END SUBROUTINE update_db ! get_avg: returns arithmetic mean INTEGER FUNCTION get_avg () get_avg = sum / n_items END FUNCTION get_avg END MODULE stats_code This program unit also begins with a USE statement, which identifies the module it uses as stats_db. This module is defined in data.f90, as follows: Example 2-4 data.
Compiling and linking Special-purpose compilations $ do_stats Enter an integer (hint: Average or better. 77 is current average): 77 If instead of the preceding command line, the program had been compiled as follows: $ f90 -o do_stats main.f90 data.f90 code.f90 the compilation would fail and f90 would print the error message: Error FCE37 : Module STATS_CODE not found The compilation would fail because the compiler cannot process main.f90 without STATS_CODE.mod.
Compiling and linking Special-purpose compilations Managing .mod files By default, the compiler writes .mod files to the current working directory and looks there when it has to read them. The +moddir=directory and -I directory options enable you to specify different directories. The +moddir option causes the compiler to write .mod files in directory, and the -I option causes the compiler to search directory for .mod files to read. (The space character between -I and directory is optional.
Compiling and linking Special-purpose compilations • A PA-RISC version number—1.1, 2.0, or 2.0W. Use +DA2.0W to compile in 64-bit mode; see “Compiling in 64-bit mode” on page 93. • A model number—for example, 750 or 870. • A PA-RISC processor name—for example, PA7100 or PA8000. • portable—code that is compatible across all models. Use +DAportable only if you want to ensure that your program will run on different models.
Compiling and linking Special-purpose compilations Compiling with +pic The +pic option causes the compiler to generate Position- Independent Code (PIC) for use in a shared library. PIC contains no absolute addresses and can therefore be placed anywhere in a process’s address space without addresses having to be relocated. This characteristic of PIC makes it shareable by multiple processes.
Compiling and linking Special-purpose compilations Example 2-6 hi.f90 SUBROUTINE say_hi() PRINT *, 'Hi!' END SUBROUTINE say_hi Example 2-7 bye.f90 SUBROUTINE say_bye() PRINT *, 'Bye!' END SUBROUTINE say_bye Example 2-8 greet.f90 PROGRAM main CALL say_hi() CALL say_bye() END PROGRAM main The following command line creates the PIC object files (the -c option suppresses linking): $ f90 -c +pic=short bye.f90 hi.
Compiling and linking Special-purpose compilations before compilation. But debugging lines are nonstandard, available only in fixed-form source, and not nearly as powerful as the cpp directives. Although cpp directives are not a standard feature of Fortran, cpp is a de facto standard feature of UNIX systems. This section discusses how to do the following: • Invoke cpp from the f90 command line. • Use the -D option to define cpp macros. • Save the preprocessed output generated by cpp.
Compiling and linking Special-purpose compilations The program uses the #ifdef and #endif directives around PRINT statements. If the macro DEBUG is defined, cpp will leave the PRINT statements in the source text that is passed to the compiler; if it is not defined, cpp will remove the statements. You can define the macro in the source text, using the #define directive; or you can define it on the command line, using the -D command-line option.
Compiling and linking Special-purpose compilations 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 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.
Compiling and linking Special-purpose compilations In some circumstances, it may help to debug a program or to improve its runtime performance by making it nonshareable. In general, however, it is not desirable because nonshareable executables place greater demands on memory resources. Compiling in 64-bit mode Compiling HP Fortran programs with the +DA2.0W option (PA-RISC only; for Itanium, use +DD64) causes f90 to produce 64-bit executable programs.
Compiling and linking Using environment variables Using environment variables Environment variables are variables that are defined in the operating environment of the system and are available to various system components. For example, when you run a program, the shell looks at the PATH variable to determine where the program is located. Table 2-14 lists and briefly describes the environment variables that control the way HP Fortran programs are compiled, linked, and run.
Compiling and linking Using environment variables $ f90 -v +list hello.f90 The syntax of the HP_F90OPTS variable allows the bar (|) character to be used to specify that options appearing before | are to be recognized before any options on the command line and that options appearing after | are to be recognized after any options on the command line. For example, the commands: $ export HP_F90OPTS="-O|-lmylib" $ f90 -v hello.f90 are equivalent to: $ f90 -O -v hello.
Compiling and linking Using environment variables MP_NUMBER_OF_THREADS environment variable The MP_NUMBER_OF_THREADS environment variable sets the number of processors that are to execute a program that has been compiled for parallel execution. If you do not set this variable, it defaults to the number of processors on the executing machine.
3 Controlling data storage This chapter describes the use of command-line options, directives, and other language features to control data in HP Fortran programs.
Controlling data storage • Disabling implicit typing • Automatic and static variables • Increasing the precision of constants • Increasing default data sizes • Sharing data among programs • Modules vs. common blocks NOTE 98 For information about how HP Fortran aligns data, refer to the HP Fortran Programmer's Reference.
Controlling data storage Disabling implicit typing Disabling implicit typing By default, HP Fortran uses implicit typing to determine the type of a variable or function that has not been declared with a type declaration statement. That is, the type of an undeclared entity is determined by the first letter of its name: if the letter is in the range I - N, the entity is of type integer; otherwise, it is of type real.
Controlling data storage Automatic and static variables Automatic and static variables By default, HP Fortran allocates stack storage for program variables. Such variables are called automatic variables because they are allocated at each invocation of the program unit in which they are declared. Static variables are allocated storage from static memory when the program is first loaded into memory. They remain allocated for the life of the program.
Controlling data storage Automatic and static variables Example 3-1 recursive.f90 PROGRAM main ! This program calls a recursive internal subroutine. CALL recurse CONTAINS ! This subroutine calls itself four times. ! Each time it is called, it adds 1 to the values in ! stat_val and auto_val and displays the result. ! stat_val has the SAVE attribute and therefore is ! pre-initialized and retains its value between calls.
Controlling data storage Automatic and static variables NOTE HP Fortran provides the AUTOMATIC and STATIC statements as porting extensions. The STATIC statement is functionally the same as the SAVE statement, and the AUTOMATIC statement may be used to declare a variable as automatic. However, such a declaration is generally pointless because variables compiled under HP Fortran are automatic by default.
Controlling data storage Increasing the precision of constants Increasing the precision of constants By default, HP Fortran evaluates all floating-point constants as single-precision. For example, the compiler treats following constant 3.14159265358979323846 as though you had specified: 3.
Controlling data storage Increasing the precision of constants For information about increasing the precision of variables, see “Increasing default data sizes” on page 105. The HP Fortran Programmer’s Reference describes the syntax of the kind parameter and the exponent form and the +real_constant option. For detailed information about how floating-point arithmetic is implemented on HP 9000 computers and how floating-point behavior affects the programmer, refer to the HP-UX Floating-Point Guide.
Controlling data storage Increasing default data sizes Increasing default data sizes The +autodbl and +autodbl4 options enable you to increase the default sizes (that is, the number of storage bytes) for both constants and variables of default numeric and logical types. Unlike the +real_constant option, the +autodbl and +autodbl4 options affect both constants and variables of both real and integer types.
Controlling data storage Increasing default data sizes Figure 3-1 Increasing default data sizes Bytes 0 4 8 16 INTEGER: LOGICAL: REAL: DOUBLE PRECISION: COMPLEX: Key = +noautodbl and +noautodbl4 (the default) = +autodbl = +autodbl4 The following program illustrates the different effects of the +autodbl and +autodbl4 options.
Controlling data storage Increasing default data sizes Example 3-2 precision.f90 PROGRAM main REAL x REAL(KIND=16) y DOUBLE PRECISION z ! Assign a quad-precision constant to a default real: x = 3.14159265358979323846_16 PRINT 10, ‘Stored in x: ‘, x ! Assign a quad-precision constant to a variable that ! has been explicitly sized for quad-precision: y = 3.
Controlling data storage Increasing default data sizes Finally, the program is compiled with the +autodbl4 option. As shown in the output, x is promoted, but z is not: $ f90 +autodbl4 precision2.f90 $ a.out Stored in x: 3.14159265358979310000 Stored in y: 3.14159265358979323846 Stored in z: 3.14159265358979310000 Though useful for increasing the range and precision of numerical data, the +autodbl and +autodbl4 options are especially useful when porting; see “Large word size” on page 239.
Controlling data storage Sharing data among programs Sharing data among programs If you are designing an application that requires multiple threads of control that share the same data, the design can take either of two forms: • The program makes calls to the threads library: /usr/lib/libpthread.sl which creates multiple threads executing in a single process and therefore all sharing the same address space.
Controlling data storage Sharing data among programs The $HP$ SHARED_COMMON directive must appear at the beginning of the specification part of the main program unit of each program sharing the memory segment. Also, the common block specified for sharing must have the same layout in all files in which it is declared. You can use the ipcs -m command both to determine that HP-UX has created a shared memory segment and, after the programs complete execution, to confirm that it has been released.
Controlling data storage Sharing data among programs ! The shared memory segment is destroyed when this program halts. END IMPORTANT In the example above, you must use +U77 to access the correct sleep in the Fortran library. If you use +U77, the line above: CALL sleep (%VAL(1)) should instead read: CALL sleep (1) Example 3-4 wake_up.f90 PROGRAM main ! This program, wake_up.f90, should be run just after its ! companion, go_to_sleep.f90, starts to execute but in a ! separate process.
Controlling data storage Sharing data among programs Run the first program in any process by doing the following: $ go_to_sleep In another process, use the following command line to confirm that a shared memory segment has been created for the program (the last in the list is the newly created one): $ ipcs -m IPC status from /dev/kmem as of Fri Mar 21 15:55:29 1997 T ID KEY MODE OWNER GROUP Shared Memory: m 0 0x4119c72b --rw-rw-rwroot root m 1 0x4e180002 --rw-rw-rwroot root m 2 0x41187bf4 --rw-rw-rwroot ro
Controlling data storage Modules vs. common blocks Modules vs. common blocks The common block has been a mainstay of Fortran programs throughout the evolution of the language, and it continues to be a part of Fortran. The common block provides a convenient means to share data among program units, especially when the program units sharing data do not otherwise communicate with each other.
Controlling data storage Modules vs. common blocks • The USE statement has an ONLY clause that specifies which module variables are accessible to a particular program unit. • The USE statement also has a renaming feature to resolve name clashes between local variables and module variables. Another feature of the module is that it can include procedures. This feature provides a way to package data with the procedures needed to operate on the data.
4 Debugging This chapter describes different HP Fortran features for debugging programs. These features include compile-line options, compiler directives, and programming tools that are useful for locating errors in your program.
Debugging • Using the HP WDB debugger • Stripping debugging information • Handling runtime exceptions • Using debugging lines 116 Chapter 4
Debugging Using the HP WDB debugger Using the HP WDB debugger The HP WDB debugger is the primary tool for debugging HP Fortran programs. The debugger provides such basic debugging functions as program control, process control, program and data monitoring, and expression evaluation. The debugger has both a graphical interface and a line-mode interface.
Debugging Stripping debugging information Stripping debugging information Programs compiled with HP Fortran include minimal debugging information in the executable program. This information consists of a symbol table—a list of all the symbols in your program and their offset addresses. The symbol table provides the information needed to produce a procedure traceback. It is also used by the debugger and by the CXperf performance analysis tool.
Debugging Handling runtime exceptions Handling runtime exceptions Broadly defined, an exception is an error or fault condition that affects a program’s results. Exceptions can range from the relatively benign inexact result condition that occurs in certain floating-point operations to the more severe segmentation violation that occurs when a runaway program attempts to access unallocated memory.
Debugging Handling runtime exceptions • A procedure traceback is displayed on standard error. A procedure traceback lists routine names and their offsets that are helpful in locating the code that triggered the exception. • The program aborts. The following sections discuss each of exceptions listed in Table 4-1. For more information about signals, refer to the signal(2) and signal(5) man pages. NOTE Standard Fortran 90 provides the IOSTAT= and ERR= specifiers for handling I/O runtime errors.
Debugging Handling runtime exceptions HP Fortran provides two compile-line options, +FP and +fp_exception, which enable traps for floating-point exceptions. The differences between the two options are: • The +fp_exception option enables traps for the following IEEE floating-point exceptions: ❏ Invalid operation ❏ Division by zero ❏ Overflow ❏ Underflow The +FP option also enables the trap for the inexact operation exception.
Debugging Handling runtime exceptions This exception can also occur if your program is linked to a bad library, especially if the library contains code that was written in assembler or if it was corrupted during a file transfer. This exception may indicate a compiler error. If you cannot find the cause of this exception in your code, contact your HP support representative.
Debugging Handling runtime exceptions If you suspect that an out-of-bounds array reference is causing the segmentation violation, you can use the +check=all option instead of the +fp_exception option. When compiled with the +check=all option, a program that attempts to reference an array element that is outside the declared array boundary will abort with an error message that gives the line number of where the reference was detected.
Debugging Using debugging lines Using debugging lines An HP Fortran program that has been written in fixed source form can contain debugging lines. These are statements that begin with the letter D or d in column 1. When compiled with the +dlines option, the debugging lines are treated as statements and compiled; otherwise, they are treated as comments and ignored. A program that contains debugging lines must also be compiled for fixed source form; that is, the filename extension must be either .f or .
5 Using the ON statement Whenever a runtime error occurs, the default action of your program depends on the type of the error. If the error results from a floating-point exception, the program will continue to execute. Other errors will cause it to abort.
Using the ON statement As described in “Handling runtime exceptions” on page 119, the +fp_exception and +FP options provide control over how a program behaves when a runtime error occurs. The ON statement provides an additional level of control by enabling your program to handle floating-point and integer exceptions and +Ctrl-C interrupts.
Using the ON statement Exceptions handled by the ON statement Exceptions handled by the ON statement Like the +fp_exception option, the ON statement enables traps for floating-point exceptions (by default, traps for floating-point exceptions are disabled on HP 9000 computers).
Using the ON statement Exceptions handled by the ON statement Table 5-1 Exceptions handled by the ON statement (Continued) Exceptions Overflow Underflow Inexact result Invalid (illegal) operation +Ctrl-C interrupt 128 Exception keywords Alternate keywords REAL(16) DIV 0 (none) INTEGER(2) DIV 0 INTEGER*2 DIV 0 INTEGER(4) DIV 0 INTEGER DIV 0 REAL(4) OVERFLOW REAL OVERFLOW REAL(8) OVERFLOW DOUBLE PRECISION OVERFLOW REAL(16) OVERFLOW (none) INTEGER(2) OVERFLOW INTEGER*2 OVERFLOW INTEGER
Using the ON statement Actions specified by ON Actions specified by ON The action taken after an exception is trapped depends on the action specified by the most recently executed ON statement for that exception. To specify an action, the ON statement must include the keyword ABORT, IGNORE, or CALL. These keywords have the following meanings: • If ABORT is specified, a standard error message is generated and the program is aborted.
Using the ON statement Actions specified by ON ! ON REAL DIV 0 ABORT x = 10.0 y = 0.0 z = x / y PRINT *, y END PROGRAM main Here is the command line and the output from a sample run: $ f90 abort.f90 $ a.out PROGRAM ABORTED : IEEE divide by zero PROCEDURE TRACEBACK: ( 0) 0x0000248c _start + 0x6c [./a.out] The program would have the same result if you were to comment out the ON statement and compile with the +fp_exception option.
Using the ON statement Actions specified by ON z = x/y PRINT *, z END PROGRAM main As defined by the IEEE standard, a floating-point operation that results in a NaN is an exception known as an invalid operation. The example program performs an invalid operation when it passes a negative argument to the LOG intrinsic, causing the intrinsic to return a NaN. The following ON statement: ON REAL INVALID IGNORE causes the program to ignore this exception and continue execution.
Using the ON statement Actions specified by ON Trapping floating-point exceptions The following program, call_fptrap.f90, causes an invalid operation exception and includes an ON statement to handle the exception. The ON statement calls the trap procedure trap_illegal, which assigns a different value to the result argument. The program prints the result. Here is the program listing: Example 5-3 call_fptrap.f90 PROGRAM main REAL :: x, y ON REAL ILLEGAL CALL trap_illegal x = -10.
Using the ON statement Actions specified by ON Example 5-4 call_itrap.
Using the ON statement Trapping +Ctrl-C trap interrupts Trapping +Ctrl-C trap interrupts A +Ctrl-C interrupt can occur during the following circumstances: • When the user enters the interrupt code from the terminal while the program is running or awaiting input • During the execution of a PAUSE statement The trap procedure for a +Ctrl-C interrupt must have no formal arguments. The interrupt code is the character defined by the HP-UX stty(1) command for the intr parameter.
Using the ON statement Allowing core dumps Allowing core dumps If a program includes the ON statement and takes an exception other than the one specified by the exception keywords, the program will abort with a procedure traceback but without a core dump. If you want to allow a core dump for one or more signals for a program that includes the ON statement, you must revise the program for each such signal.
Using the ON statement Allowing core dumps $ f90 +U77 allow_core.f90 $ a.
6 Performance and optimization This chapter describes how to use different features of HP Fortran to tune your program for optimum performance. The most important of these features is the optimizer.
Performance and optimization of optimization to be applied to your program) or the -O option for the default level of optimization (level 2). The -O option is provided for compatibility with the POSIX standard and has the same functionality as the +O2 option. The following command line compiles prog.f90, using the default level of optimization: $ f90 -O prog.f90 For most applications, -O provides effective optimization.
Performance and optimization Using profilers Using profilers A profiler is a tool for sampling a program during execution so that you can determine where your program spends most of its time. After examining the data provided by a profiler, you can decide whether to redesign parts of the program to improve their performance or to re-compile the program with optimization options.
Performance and optimization Using profilers program [program_arguments] HP Caliper automatically runs to generate the flow-data information in a file named flow.data in the current directory. You can repeat this step multiple times with different program_arguments to create aggregated profile information in the flow.data file to improve your program’s optimization. If the flow.data file already exists in the current directory when you run your program, then HP Caliper merges the results into the file.
Performance and optimization Using profilers 4. Run HP Caliper on your +O3 executable with a configuration file such as total_cpu to measure performance. 5. Recompile your program with +O3 optimization and +Oprofile=use to use the profile data collected in Step 2 as input. 6. Run HP Caliper on your fully optimized executable from Step 5 with the same configuration file from Step 4 and compare the report results with the report from Step 4.
Performance and optimization Using profilers For example, if you only want to measure wordplay, you would use these settings: --module-default=none --module-include=wordplay Specifying PBO file names and locations HP Caliper creates two files when doing profile-based optimization: flow.data The file name used to store profile data. flow.log The file name used to log diagnostic messages. You can use the FLOW_DATA and FLOW_LOG environment variables to specify the file names.
Performance and optimization Using profilers 4. Once gprof is finished, you can view the output tables using an ASCII editor. For more information about gprof, see the gprof(1) man page. prof The prof profiler can also be used for profiling. Unlike the gprof profiler, prof does not generate the call graph profile. To use prof, do the following: 1. Compile the program with the +prof option. For example: $ f90 -o prog +prof prog.f90 2. Run the program. This creates a file named mon.
Performance and optimization Using options to control optimization Using options to control optimization HP Fortran includes a rich set of command-line options for controlling optimization. For most applications, we recommend optimizing with -O, which enables the default level of optimization. (For information about the default level of optimization, refer to Table on page 145; look up +O2 in the first column.
Performance and optimization Using options to control optimization where opt-level is an integer in the range 0-2. If you use the -g option at a higher level of optimization, the compiler lowers the level to 2 and compiles for debugging. Table 6-1 Option Optimization levels Optimizations performed Advantages Disadvantages Recommended use +O0 default Constant folding and partial evaluation of test conditions. Compiles fastest; compatible with the debugger option -g. Does very little optimization.
Performance and optimization Using options to control optimization Table 6-1 Option Optimization levels (Continued) Optimizations performed Advantages Disadvantages Recommended use +O3 Level 2 optimizations, plus loop transforms, parallelization, vectorization, cloning, and inlining within a file. Some optimizations may require additional options; see “Using the optimization options” on page 146. Can significantly increase performance over level 2.
Performance and optimization Using options to control optimization The options in both tables can be combined on the same command line, except as noted. For example, the following command line requests aggressive optimizations at level 2 that do not increase code size: $ f90 +02 +Oaggressive +Osize prog.f90 Nearly all of the optimization options can be used to enable or disable an optimization or a package of optimizations.
Performance and optimization Using options to control optimization Table 6-2 Packaged optimization options (Continued) Option Level Function Do [do not] automatically parallelize loops that are deemed safe and profitable by the loop parallelizer. The default is +Onoautopar. The +Oautopar option can be used for programs at optimization levels, +O3 and above. +O[no]autopar If both +Oopenmp and +Oautopar are specified on the command line, the OpenMP directives gain precedence over the +Oautopar option.
Performance and optimization Using options to control optimization Table 6-3 Fine-tuning optimization options Option Level Function +O[no]cache_pad_common +O3 or higher Pad [do not pad] common blocks to avoid cache collisions. The default is +Onocache_pad_common. +O[no]dataprefetch +O2 or higher Insert [do not insert] instructions within innermost loops to explicitly prefetch data from memory into the data cache. The default is +Onodataprefetch.
Performance and optimization Using options to control optimization Table 6-3 Fine-tuning optimization options (Continued) Option Level Function +Oinline_budget=n +O3 or higher Perform more aggressive inlining, as specified by n. The default is +Oinline_budget=100. +O[no]libcalls All Substitute [do not substitute] millicode versions of specific intrinsics. The default is +Olibcalls. +O[no]loop_unroll=n +O2 or higher Unroll [do not unroll] program loops by a factor of n.
Performance and optimization Using options to control optimization Table 6-3 Fine-tuning optimization options (Continued) Option +O[no]vectorize Chapter 6 Level +O32 or higher Function Replace [do not replace] eligible loops with calls to the math library; for more information, see “Using the +Ovectorize option” on page 159. The default is +Onovectorize.
Performance and optimization Conservative vs. aggressive optimization Conservative vs. aggressive optimization At optimization level 2 or higher, the optimizer makes a number of assumptions about the program it is optimizing—for example, that re-ordering an expression for improved instruction scheduling will not change its results. In general, these assumptions relate to how closely the target program conforms to the Fortran 90 Standard.
Performance and optimization Conservative vs.
Performance and optimization Parallelizing HP Fortran programs Parallelizing HP Fortran programs The following sections discuss how to use the +Oparallel option and the parallel directives when preparing and compiling HP Fortran programs for parallel execution. Later sections also discuss reasons why the compiler may not have performed parallelization. The last section describes runtime warning and error messages unique to parallel-executing programs.
Performance and optimization Parallelizing HP Fortran programs Profiling parallelized programs You can profile a program that has been compiled for parallel execution in much the same way as for non-parallel programs: 1. Compile the program with the +gprof option. 2. Run the program to produce profiling data. 3. Run gprof against the program. 4. View the output from gprof. The differences are: • Step 2 produces a gmon.out file with the CPU times for all executing threads.
Performance and optimization Parallelizing HP Fortran programs You can use the DIR$ NO SIDE EFFECTS directive to force the compiler to ignore side effects when determining whether to parallelize the loop. For information about this directive, see . NOTE A subroutine (but not a function) is always expected to have side effects. If you apply this directive to a subroutine call, the optimizer assumes that the call has no effect on program results and can eliminate the call to improve performance.
Performance and optimization Parallelizing HP Fortran programs In this loop, the order of execution does matter. The data used in iteration I is dependent upon the data that was produced in the previous iteration (I-1). The array A would end up with very different data if the order of execution were any other than 2-3-4-5. The data dependence in this loop thus makes it ineligible for parallelization. Not all data dependences inhibit parallelization. The following paragraphs discuss some of the exceptions.
Performance and optimization Parallelizing HP Fortran programs • FPP$ NODEPCHK • VD$ NODEPCHK For more information about these directives, see “Compatibility directives” on page 210.
Performance and optimization Vectorization Vectorization When vectorization is enabled, the optimizer replaces eligible loops with calls to specially tuned routines in the math library. When you compile with the +Ovectorize option, the optimizer vectorizes wherever it determines that it is safe and feasible to do so. However, you can use directives to limit vectorization.
Performance and optimization Vectorization Table 6-5 Vector routines called by +Ovectorize (Continued) Vector routine Description sdot Compute the dot product of two single-precision vectors. vec_damax Find the maximum absolute value in a double-precision vector. vec_dmult_add Multiply a scalar by a vector and add the result to the result vector, using double-precision operands. vec_dsum Sum the elements of a double-precision vector. If your PA2.
Performance and optimization Vectorization END DO !*$* NOVECTORIZE . . . Note that the *$* VECTORIZE directive does not force vectorization. The optimizer vectorizes only if: • The loop performs a vector operation recognized by the optimizer as in its repertoire. • The loop is safe to vectorize. The same conditions that can prevent parallelization—see, for example, “Data dependences” on page 156—can also prevent vectorization.
Performance and optimization Vectorization INTEGER :: i, inc_x, inc_y, dim_num REAL, DIMENSION(5) :: x, y REAL :: b b = 3.0 dim_num = 5 inc_x = 1 inc_y = 1 ! initialize the two arrays x and y DO i = 1, 5 y(i) = i x(i) = i + 3.0 END DO PRINT *, y ! add a scalar multiple of x to y DO i = 1, 5 y(i) = y(i) + b * x(i) END DO PRINT *, y END PROGRAM main The following command lines compile and execute the program, and show the output from a sample run: $ f90 saxpy.f90 $ a.out 1.0 2.0 3.0 4.0 5.0 13.0 17.0 21.
Performance and optimization Vectorization Fortran uses implicit typing by default. Unless a function is explicitly declared as having a certain type, the type is determined by the first character of the BLAS routine. If that character implies a type other than that of the returned value, the result will be meaningless. See the HP Fortran Programmer's Reference for information about the BLAS library.
Performance and optimization Controlling code generation for performance Controlling code generation for performance For optimum performance, the executable program should consist of code that can take advantage of the hardware features of the machine on which the program will run. If your program will run on the same machine as you use to compile it, code generation is not an issue. By default, the HP Fortran compiler generates code for the model of the machine on which you are running the compiler.
7 Writing HP-UX applications This chapter discusses how HP Fortran applications running on the HP-UX operating system can use system resources to do the following: • Accessing command-line arguments Chapter 7 165
Writing HP-UX applications • Calling HP-UX system and library routines • Using HP-UX file I/O 166 Chapter 7
Writing HP-UX applications Accessing command-line arguments Accessing command-line arguments When invoking an HP Fortran executable program, you can include one or more arguments on the command line. The operating system will make these available to your program.
Writing HP-UX applications Accessing command-line arguments $ f90 get_args.f90 $ a.out perambulation of a different sort this program produces the following output: 13 perambulation 5 For more information about the IGETARG and IARGC intrinsics, see the HP Fortran Programmer's Reference. GETARGC is also available as a libU77 routine; see the HP Fortran Programmer's Reference.
Writing HP-UX applications Calling HP-UX system and library routines Calling HP-UX system and library routines System calls provide low-level access to kernel-level resources, such as the write system routine. or example, see “File handling” on page 193 for an example of a program that calls the write routine. For information about system calls, refer to the HP-UX Reference. HP-UX library routines provide many capabilities, such as getting system information and file stream processing.
Writing HP-UX applications Using HP-UX file I/O Using HP-UX file I/O HP-UX file-processing routines can be used as an alternative to Fortran file I/O routines. This section discusses HP-UX stream I/O routines and I/O system calls. Stream I/O using FSTREAM The HP-UX operating system uses the term stream to refer to a file as a contiguous set of bytes. There are a number of HP-UX subroutines for performing stream I/O; see stdio(3S) in the HP-UX Reference.
Writing HP-UX applications Using HP-UX file I/O Establishing a connection to a file HP-UX I/O system calls require an HP-UX file descriptor, which establishes a connection to the file being accessed. A file descriptor is an integer whose function is similar to a Fortran logical unit number. For example, the following open system call (called from a C-language program) opens a file named DATA.DAT for reading and writing, and returns the value of an HP-UX file descriptor: #include
Writing HP-UX applications Using HP-UX file I/O 172 Chapter 7
8 Calling C routines from HP Fortran This section describes language differences between C and HP Fortran that affect calling C routines from an HP Fortran program.
Calling C routines from HP Fortran • Argument-passing conventions • Case sensitivity • Arrays • C strings • File handling • Sharing data 174 Chapter 8
Calling C routines from HP Fortran Data types Data types Table 8-1 lists the corresponding data types for HP Fortran and C when compiled as 32-bit applications.
Calling C routines from HP Fortran Data types Table 8-2 shows the differences between the corresponding data types in HP Fortran and C when compiling in 32-bit mode and in 64-bit mode. Table 8-3 shows the differences when the Fortran program is compiled with the +autodbl option. Notice that Fortran data items that are explicitly sized (for example, INTEGER*4) stay the same size regardless of whether they are compiled in 32-bit mode, in 64-bit mode, or with the +autodbl option.
Calling C routines from HP Fortran Data types • Unsigned integers • Logicals • Complex numbers • Derived types Unsigned integers Unlike Fortran, C allows integer data types (char, int, short, and long) to be declared as either signed or unsigned. If a Fortran program passes a signed integer to a C function that expects an unsigned integer argument, C will interpret the bit pattern as an unsigned value.
Calling C routines from HP Fortran Data types The main subprogram calls sqr_complex, passing in a complex number. The C function squares the number and returns the result. There is no complex data type in C, but this example uses C’s typedef feature to create one. The Fortran source file for such a scenario is shown below in the example pass_complex.f90. Example 8-1 pass_complex.f90 PROGRAM main ! This program passes a complex number to a C function ! that squares it and returns the result.
Calling C routines from HP Fortran Data types float real; float imag; }COMPLEX; /* returns the square of the complex argument */ COMPLEX sqr_complex(COMPLEX cmx_val) { COMPLEX result; float a, b; /* copy both parts of the complex number into locals */ a = cmx_val.real; b = cmx_val.imag; /* square the * the return */ result.imag = a = a * a; b = b * b; result.
Calling C routines from HP Fortran Data types Allocatable arrays may be passed from Fortran to C like any other array, with the precaution about array differences between the two languages. Strings (an array of characters in C) are a different matter; see “C strings” on page 189 for information about passing strings from Fortran to C.
Calling C routines from HP Fortran Argument-passing conventions Argument-passing conventions The important difference between the argument-passing conventions of HP C and HP Fortran is that Fortran passes arguments by reference — that is, it passes the address of the argument — whereas C passes non-array and non-pointer arguments by value — that is, it passes a copy of the argument.
Calling C routines from HP Fortran Argument-passing conventions For detailed information about the $HP$ ALIAS directive and the %VAL and %REF built-in functions, see the HP Fortran Programmer's Reference.
Calling C routines from HP Fortran Case sensitivity Case sensitivity Unlike HP Fortran, C is a case-sensitive language. HP Fortran converts all external names to lowercase, and it disregards the case of internal names. Thus, for example, the names foo and FOO are the same in Fortran. C, however, is a case-sensitive language: foo and FOO are different in C.
Calling C routines from HP Fortran Case sensitivity Before a Fortran program can call this function correctly, it must resolve two issues: 1. The name of the C function contains both uppercase and lowercase letters. 2. The function expects its second argument (the size of the array) to be passed by value.
Calling C routines from HP Fortran Case sensitivity If you use the $HP$ ALIAS directive in many of the Fortran source files in your program, you may find it convenient to define all of the directives in one file and include that file in all of the Fortran source files with the +pre_include=file option. This option takes one argument, file, which is the name of the file you want to include.
Calling C routines from HP Fortran Arrays Arrays There are two differences between HP Fortran and C to consider when passing arrays from Fortran to C: • In HP Fortran, array subscripts start by default at 1, whereas in C they always start at 0 • In HP Fortran, multi-dimensional arrays are laid out differently in memory than they are in C. The difference in subscript-numbering does not result in any size discrepancies: an array of 10 elements in Fortran has 10 elements in C, too.
Calling C routines from HP Fortran Arrays INTEGER, DIMENSION(3,6) :: my_array then the array should be declared in C as follows: int my_array[6][3]; You can change the array declaration in either language, whichever is more convenient. The important point is that, to be conformable, the dimensions must be in reverse order. Below is an example for a three-dimensional array, the first being for a Fortran declaration. REAL, DIMENSION(2,3,4) :: x Below is the same declaration as declared in C.
Calling C routines from HP Fortran Arrays Example 8-6 get_array.c #include /* get_array: displays the contents of the array argument */ void get_array(int a[4][2]) { int i, j; printf("\nHere is the same array as accessed from C:\n\n"); for (i = 0; i < 4; i++) for (j = 0; j < 2; j++) printf(“a[%d][%d] = %d\n”, i, j, a[i][j]); } Here are the command lines to compile, link, and execute the program, followed by the output from a sample run: $ cc -Aa -c get_array.c $ f90 pass_array.f90 get_array.
Calling C routines from HP Fortran C strings C strings C strings differ from Fortran character variables in two important respects: • C expects strings to be null-terminated. • For each character variable or character constant that Fortran passes to a C routine, it also passes a hidden length argument. The following sections discuss these differences and explain how to code for them. The last section includes an example program.
Calling C routines from HP Fortran C strings arguments, however, will come at the end of the list. If more than one string argument is passed, the length arguments will follow the same order as the address arguments, but at the end of the C’s argument list. Note that both C and Fortran both pass strings by reference. This means that, if Fortran passes only string arguments to C, you need not use the %VAL and %REF built-in functions to indicate how the arguments are to be passed.
Calling C routines from HP Fortran C strings ! reference in both languages. There’s no need to use the ! %REF built-in function, so long as the C routine ! provides an extra argument for the "hidden" length ! parameter. To suppress passing that parameter, use %REF. CALL get_string(first_name, last_name) PRINT 20, first_name, last_name 20 FORMAT(/, 'The names passed back to Fortran: ', A, 1X, A) END PROGRAM main Example 8-8 get_string.c #include #include
Calling C routines from HP Fortran C strings $ cc -Aa -c get_string.c $ f90 pass_chars.f90 get_string.o $ a.
Calling C routines from HP Fortran File handling File handling A Fortran unit number cannot be passed to a C routine to perform I/O on the associated file; nor can a C file pointer be used by a Fortran routine. However, a file created by a program written in either language can be used by a program in the other language if the file is declared and opened within the program that uses it. C accesses files using HP-UX I/O subroutines and intrinsics.
Calling C routines from HP Fortran File handling ! a = the character array to write ! 10 = the number of elements (bytes) to write ! the return value, status, is the number of bytes actually ! written; if the write was successful, it should be 10 status=IWRITE(fd, a, 10) CLOSE (1, STATUS=’KEEP’) ! open the file for reading; we want to see if the write was ! successful OPEN (1, FILE='file1', STATUS='UNKNOWN') READ (1, 4) (a(i), i = 1, 10) 4 FORMAT (10A1) CLOSE (1, STATUS='DELETE') DO i = 1, 10 ! if we find a
Calling C routines from HP Fortran Sharing data Sharing data Fortran programmers have traditionally relied on the common block to share large amounts of data among different program units. The convenience offered by the common block is that it can give storage access to program units that don’t otherwise communicate with each other, even when they reside in separate files.
Calling C routines from HP Fortran Sharing data Note that the extern specifier references the name of the common block, globals, not the name of the array. From C’s point of view, the common block is treated as though it were the array. The common block to be shared with a C function can contain more than one data item. To do so, the C source file must declare a structure whose members match the data items in common.
Calling C routines from HP Fortran Sharing data 10 FORMAT(3X, F3.0, 2X, A, 8X, F5.2) END PROGRAM main Example 8-11 shared_struct.c #include #include /* declare a structure whose members match the data items * in the Fortran common block */ struct glob { double num; double nlog_of_num; } globals; /* get_nlog: reads the value in globals.num, passes it * to log() in the math library, and writes the write the * return value to globals.
Calling C routines from HP Fortran Sharing data See the HP Fortran Programmer's Reference for a full description of the COMMON statement.
9 Using Fortran directives Compiler directives are commands within the source program that affect how the program is compiled. They are similar in function to command-line options, but generally provide more local control.
Using Fortran directives formatted. The following sections describe the HP Fortran directives. HP Fortran also recognizes C Preprocessor (cpp) directives. If you compile with the +cpp=yes option or if the name of the source ends in the .F extension, the source files are first passed to the C preprocessor for processing. For information about the C preprocessor, refer to cpp(1).
Using Fortran directives Directive syntax Directive syntax The syntax for specifying directives in HP Fortran source files varies according to the type of directive: C preprocessor directives take the form: #[line]cpp-directive where cpp-directive is ANSI C-conforming except that the line keyword is optional, making it compatible with the HP C compiler.
Using Fortran directives Using HP Fortran directives Using HP Fortran directives HP Fortran provides a number of compiler directives that are useful for controlling certain functions (for example, optimization) within the source file. Table 9-1 lists and briefly describes these directives; they are listed in the order in which they appear in the sections below.
Using Fortran directives Using HP Fortran directives Using the comment character as the directive prefix ensures that, unless the compiler is specifically looking for the directive, it is otherwise treated as a comment and ignored. The following sections describe each of the HP Fortran directives. $HP$ ALIAS The ALIAS directive associates the name of a subroutine, function, entry, or common block with an external name and specifies the parameter-passing conventions of routines written in other languages.
Using Fortran directives Using HP Fortran directives • When used in conjunction with the %VAL and %REF built-in functions, it provides a way to direct the compiler to use the appropriate parameter passing conventions to communicate with routines written in other high-level languages. external-name should never conflict with the name of an HP-UX system routine (described in sections 2 and 3 of the HP-UX Reference) or with a Fortran library routine (for example, OPEN, READ, or CLOSE).
Using Fortran directives Using HP Fortran directives Examples The $HP$ ALIAS directive is especially useful when calling a routine in a language that uses different conventions than Fortran. The following examples illustrate how to use the $HP$ ALIAS directive to resolve differences with: • Case sensitivity • Argument-passing conventions • Strings Case sensitivity Names in HP Fortran are not case sensitive; that is, the compiler converts all names to lowercase.
Using Fortran directives Using HP Fortran directives Example 9-1 pr_str.c void c_rout(char *s) { printf(“%s\n”, s); } The ALIAS directive in the following program enables the string to be passed to c_rout: Example 9-2 pass_str.
Using Fortran directives Using HP Fortran directives Description and restrictions If you use $HP$ CHECK_OVERFLOW with the ON statement, you can cause your program to ignore the overflow, abort on the overflow, or branch to a trap subroutine. If this directive is not used, the ON statement has no effect on integer overflow errors. This directive can appear anywhere in your program. It stays in effect until a subsequent $HP$ CHECK_OVERFLOW directive changes the status.
Using Fortran directives Using HP Fortran directives For more information See “Incompatibilities with HP FORTRAN 77” on page 215 for information about the +list option. $HP$ OPTIMIZE The $HP$ OPTIMIZE directive enables or disables the level of optimization that was specified on the command line. Syntax !$HP$ OPTIMIZE [ON | OFF] ON enables the level of optimization specified on the command line. OFF disables the level of optimization specified on the command line.
Using Fortran directives Using HP Fortran directives !HP$ OPTIMIZE level 1 off !HP$ OPTIMIZE level 0 off !HP$ OPTIMIZE level 2 off !HP$ optimize assume_no_parameters_overlaps on !HP$ optimize assume_no_parameters_overlaps off Chapter 9 209
Using Fortran directives Compatibility directives Compatibility directives HP Fortran supports the compiler directives listed in Table 9-2. These directives are provided for compatibility with programs developed on the platforms listed in the table.
Using Fortran directives Compatibility directives To use the vectorization directive, you must compile and link with the +Ovectorize option. The directive applies to the beginning of the next loop and remains in effect for the rest of the program unit or until superseded by a later directive. For more information about this option, see the Parallel Programming Guide for HP-UX Systems.
Using Fortran directives Compatibility directives NOTE Using these directives to incorrectly assert that a loop has no data dependences can result in the loop producing wrong answers. Other conditions may limit the compiler's efforts to parallelize, such as the presence of the VD$ NOCONCUR directive. Such conditions may prevent parallelization even if you use a directive to disable dependence checking.
10 Migrating to HP Fortran A major feature of HP Fortran is its compatibility with standard-conforming HP FORTRAN 77. Both source files and object files from existing HP FORTRAN 77 applications can be migrated to HP Fortran with comparatively little effort.
Migrating to HP Fortran to be changed to compile and execute correctly under HP Fortran. To smooth the migration path, HP Fortran includes a number of extensions that are compatible with HP FORTRAN 77. HP Fortran also includes extensions that are designed to ease the job of porting applications from other vendors' Fortran dialects. For a summary list of all HP Fortran extensions, see the HP Fortran Programmer's Reference.
Migrating to HP Fortran Incompatibilities with HP FORTRAN 77 Incompatibilities with HP FORTRAN 77 The following sections describe known incompatibilities between HP Fortran and HP FORTRAN 77. These incompatibilities include both source-level and object-code incompatibilities. A subset of these are detected by the HP fid tool, which is described in “Fortran incompatibilities detector” on page 228. Compiler limits HP Fortran supports format field widths up to 32767.
Migrating to HP Fortran Incompatibilities with HP FORTRAN 77 Table 10-2 f77 options replaced by f90 options (Continued) f77 option f90 replacement +B +escape -D +dlines +es +extend_source -F +cpp_keep -L +list -onetrip +onetrip +Q +pre_include +s +langlvla +T +fp_exception +ttyunbuf +nottybuf -U +uppercase -u +implicit_none -V +lista a. Does not fully replace. Format field widths HP Fortran 90 supports format field widths up to 32767.
Migrating to HP Fortran Incompatibilities with HP FORTRAN 77 DOUBLE PRECISION x = 3.1415926535 will initialize x to only 32 bits worth of the constant because it interprets the constant as single precision. Under HP Fortran, a constant must have a D exponent or a KIND suffix to be interpreted as double precision. In programs that use double precision exclusively, you should consider using the +real_constant=double option, which causes real constants to default to double precision.
Migrating to HP Fortran Incompatibilities with HP FORTRAN 77 • In HP Fortran, recursive procedures must be so declared with the RECURSIVE keyword; HP FORTRAN 77 allows recursive procedures by default. Data types and constants The following HP FORTRAN 77 extensions for data types and constants are not supported by HP Fortran: • Double precision as the default storage for floating-point constants; see “Floating-point constants” on page 216. • I and J integer suffixes.
Migrating to HP Fortran Incompatibilities with HP FORTRAN 77 See the HP Fortran Programmer's Reference for information about the REAL intrinsic. Input/output The following I/O specifiers are recognized by the OPEN statement and by other I/O statements in HP FORTRAN 77 but are not supported in HP Fortran: ACCESS=expr1, where expr1 is a constant expression other than DIRECT or SEQUENTIAL.
Migrating to HP Fortran Incompatibilities with HP FORTRAN 77 The syntax and functionality of individual directives has also changed; for detailed information about the HP Fortran directives, see the HP Fortran Programmer's Reference. All unsupported directives should be deleted or replaced by HP Fortran code that results in the same functionality (see Table on page 222).
Migrating to HP Fortran Migration issues Migration issues Migration issues fall into four general categories: • Source code issues • Command-line option issues • Object code issues • Data file issues Source code issues For standard-conforming HP FORTRAN 77 code, migration to HP Fortran can be as simple as recompiling with the f90 command. The f90 command accepts source files with the extensions .f and .F (among others).
Migrating to HP Fortran Migration issues Although most of the HP FORTRAN 77 directives are not supported by HP Fortran, some of their functionality is available through command-line options; see Table 10-3.
Migrating to HP Fortran Migration issues Table 10-3 HP FORTRAN 77 directives supported by f90 options HP FORTRAN 77 directive HP Fortran option Remarks SAVE_LOCALS (ON) +save SAVE_LOCALS OFF +nosave SET -D or -U Use the C preprocessor #define directive. STANDARD_LEVEL ANSI +langlvl=f90 Applies to Fortran 90 instead of FORTRAN 77. SYMDEBUG -g UPPERCASE +[no]uppercase WARNINGS -w Lowercase is the default.
Migrating to HP Fortran Migration issues Table 10-4 GETENV Conflicting intrinsics and libU77 routine names (Continued) LOC TIME Refer to the HP Fortran Programmer's Reference for information about all of the HP Fortran intrinsics and the libU77 routines. Command-line option issues Command-line options can become a migration issue in two ways: • When you compile a program with the HP Fortran compiler, using an f77 command line.
Migrating to HP Fortran Migration issues Table 10-5 f77 options supported by f90 (Continued) f77 option f90 option function -R4 +real_constant=single Make single precision the default for all single-precision constants -R8 +real_constant=double Make double precision the default for all single-precision constants -S +asm Generate assembly listing -s +strip Strip symbol table information from linker output -Y +nls Enable Native Language Support +Z +pic=long Generate position-independent
Migrating to HP Fortran Migration issues If you find object-code incompatibilities, you should change the source code and recompile with the f90 command. Data file issues In general, data files are the easiest files to migrate because the data files produced by the two Fortrans are compatible. However, problems can occur because of misaligned data and data types that are not supported under HP Fortran. For example, HP FORTRAN 77 permits misaligned data, especially when working with the structure extension.
Migrating to HP Fortran Approaches to migration Approaches to migration The most direct (and painstaking) approach to migrating an HP FORTRAN 77 program so that it will compile and execute correctly under HP Fortran is to make a clean sweep through the original source code, removing all extensions and rewriting all nonstandard programming practices to conform to the Fortran 90 standard. The result will be a highly portable program.
Migrating to HP Fortran Approaches to migration The main drawback of f90 as a migration tool is that a clean compilation under f90 does not guarantee that all incompatibilities have been found; some do not manifest themselves until runtime. Also, linking under f90 with f77-generated object files may yield unexpected behavior or incorrect results; see “Object code issues” on page 225 and “Data file issues” on page 226.
Migrating to HP Fortran Approaches to migration Following are examples of the warning messages fid issues when it detects an incompatibility: fid Warning: The command-line option, +800, is both source incompatible and .o incompatible with F90 fid Warning on line 8 of file.f: ON EXTERNAL not supported by F90 fid Warning on line 9 of file.
Migrating to HP Fortran Approaches to migration 230 Chapter 10
11 Porting to HP Fortran The goal of portability is to make it possible to compile and execute a program on different vendors’ platforms, regardless of the platform on which it was written. A portable Fortran 90 program contains no language elements except those mandated by the Standard and adheres to generally accepted coding practices.
Porting to HP Fortran In practice, however, programming is rarely so simple. Many Fortran programs have a long history and were originally coded at a time when portability was not a concern because many programs were written to execute on one platform only. Older Fortran programs—so-called dusty-deck programs—are likely to have passed through different dialects of Fortran, picking up features from each, even after those features have become outmoded.
Porting to HP Fortran Compatibility extensions Compatibility extensions HP Fortran includes a variety of extensions to the Fortran 90 language. Most of these are compatibility extensions—statements, intrinsic routines, and compiler directives that are specific to nonstandard implementations of Fortran 90.
Porting to HP Fortran Compatibility extensions Table 11-1 Statement Compatibility statements (Continued) Implementation Description MAP DEC Defines a union within a structure. POINTER (Cray-style) Cray Declares Cray-style pointers and their objects. RECORD DEC Declares a record of a previously defined structure. STATIC Sun Allocates storage in static memory. STRUCTURE DEC Defines a named structure. TYPE (I/O) DEC Writes to standard output. UNION DEC Defines a union within a structure.
Porting to HP Fortran Compatibility extensions the HP Fortran Programmer’s Reference for detailed descriptions of the directives to check the level of compatibility. For usage information about these directives, see “Controlling vectorization locally” on page 160. As noted in the table, some of the compatibility directives are effective only if the source file is compiled with either the +Oparallel or the +Ovectorize option; otherwise, the directive is treated as a comment and ignored.
Porting to HP Fortran Compatibility extensions that begins with one of these prefixes but does not recognize the directive name, it issues a warning and ignores the directive. A directive takes effect only if the compiler recognizes both its prefix and name—that is, it must be either one of HP’s own directives or one of those listed in Table 11-2.
Porting to HP Fortran Compatibility extensions Table 11-4 Nonstandard intrinsic procedures in HP Fortran (Continued) ATAN2D FSTREAM INT4 MCLOCK SYSTEM ATAND GETARG INT8 OR TAND ATANH GETENV INUM QEXT TIME BADDRESS GRAN IOMSG QFLOAT XOR COSD HFIX IQINT QNUM ZEXT DATE IACHAR IRAND QPROD DCMPLX IADDR IRANP RAN DFLOAT IARGC ISIGN RAND DNUM IDATE ISNAN RNUM HP Fortran also provides nonstandard specific intrinsics that derive from standard generic intrinsics; these nonst
Porting to HP Fortran Using porting options Using porting options HP Fortran provides a number of compile-line options for porting programs. The most important of these is the +langlvl=90 option. Compiling your program with this option will cause the compiler to issue warning messages for all nonstandard features.
Porting to HP Fortran Using porting options As mentioned in “Automatic and static variables” on page 100, saving all variables in static storage can degrade performance. If performance is an issue, consider using the +Oinitcheck option. Unlike the +save option, +Oinitcheck does not “save” variables—it does not move variables into static storage. Instead, it causes the compiler to search for all local, nonarray, nonstatic variables that have not been defined before being used.
Porting to HP Fortran Using porting options PRINT *, 'Should never happen in standard Fortran 90.' 10 CONTINUE END PROGRAM main When compiled with the command line: $ f90 test_loop.f90 the PRINT statement will never execute because the initial loop count is higher than the final loop count. To force the loop to execute at least once, compile it with the command line: $ f90 +onetrip test_loop.f90 When you run the program now, it produces the output: $ a.out Should never happen in standard Fortran 90.
Porting to HP Fortran Using porting options If this is compiled as coded and without the +langlvl=90 option, the compiler will assume that the reference is to the HP intrinsic named INT1 and not to the external function. Executing the program will produce unexpected results, as appears in the following sample run: $ f90 clash.f90 clash.f90 program CLASH external function INT1 11 Lines Compiled $ a.
Porting to HP Fortran Using porting options NOTE The name-conflict problem can occur in Fortran programs that call routines in the libU77.a library. Some implementations link libU77.a by default. HP Fortran does not; to link in this library, you must compile your program with the +U77 option.
Porting to HP Fortran Using porting options • If the name of the source file ends with the .f90 extension, the file is compiled as free form. The compiler accepts tab characters in the source. • If the name of the source file ends with the .f or .F extension, the file is compiled as fixed form. • If the file is compiled with the +langlvl=90 option, the interprets the format as either fixed or free form, depending on the filename extension (as described above).
Porting to HP Fortran Using porting options Porting from Tru64 to HP Fortran Support has been added for options that will assist users in porting applications from Tru64 to HP Fortran. Wherever possible, these options mimic the behavior of their counterparts in the Tru64 Fortran compiler. +cfc The +cfc flag has been added to the Fortran compiler. +cfc allows you access to the newly-implemented Tru64 Fortran options.
Porting to HP Fortran Using porting options Porting from Tru64 to HP Fortran Support has been added for options that will assist users in porting applications from Tru64 to HP Fortran. Wherever possible, these options mimic the behavior of their counterparts in the Tru64 Fortran compiler. +cfc The +cfc flag has been added to the Fortran compiler. +cfc allows you access to the newly-implemented Tru64 Fortran options.
Porting to HP Fortran Using porting options Porting from Tru64 to HP Fortran Support has been added for options that will assist users in porting applications from Tru64 to HP Fortran. Wherever possible, these options mimic the behavior of their counterparts in the Tru64 Fortran compiler. +cfc The +cfc flag has been added to the Fortran compiler. +cfc allows you access to the newly-implemented Tru64 Fortran options.
Porting to HP Fortran Using porting options Porting from Tru64 to HP Fortran Support has been added for options that will assist users in porting applications from Tru64 to HP Fortran. Wherever possible, these options mimic the behavior of their counterparts in the Tru64 Fortran compiler. +cfc The +cfc flag has been added to the Fortran compiler. +cfc allows you access to the newly-implemented Tru64 Fortran options.
Porting to HP Fortran Using porting options Porting from Tru64 to HP Fortran Support has been added for options that will assist users in porting applications from Tru64 to HP Fortran. Wherever possible, these options mimic the behavior of their counterparts in the Tru64 Fortran compiler. +cfc The +cfc flag has been added to the Fortran compiler. +cfc allows you access to the newly-implemented Tru64 Fortran options.
Porting to HP Fortran Using porting options Porting from Tru64 to HP Fortran Support has been added for options that will assist users in porting applications from Tru64 to HP Fortran. Wherever possible, these options mimic the behavior of their counterparts in the Tru64 Fortran compiler. +cfc The +cfc flag has been added to the Fortran compiler. +cfc allows you access to the newly-implemented Tru64 Fortran options.
Porting to HP Fortran Using porting options Porting from Tru64 to HP Fortran Support has been added for options that will assist users in porting applications from Tru64 to HP Fortran. Wherever possible, these options mimic the behavior of their counterparts in the Tru64 Fortran compiler. +cfc The +cfc flag has been added to the Fortran compiler. +cfc allows you access to the newly-implemented Tru64 Fortran options.
Porting to HP Fortran Using porting options Porting from Tru64 to HP Fortran Support has been added for options that will assist users in porting applications from Tru64 to HP Fortran. Wherever possible, these options mimic the behavior of their counterparts in the Tru64 Fortran compiler. +cfc The +cfc flag has been added to the Fortran compiler. +cfc allows you access to the newly-implemented Tru64 Fortran options.
Porting to HP Fortran Using porting options Porting from Tru64 to HP Fortran Support has been added for options that will assist users in porting applications from Tru64 to HP Fortran. Wherever possible, these options mimic the behavior of their counterparts in the Tru64 Fortran compiler. +cfc The +cfc flag has been added to the Fortran compiler. +cfc allows you access to the newly-implemented Tru64 Fortran options.
Porting to HP Fortran Using porting options Porting from Tru64 to HP Fortran Support has been added for options that will assist users in porting applications from Tru64 to HP Fortran. Wherever possible, these options mimic the behavior of their counterparts in the Tru64 Fortran compiler. +cfc The +cfc flag has been added to the Fortran compiler. +cfc allows you access to the newly-implemented Tru64 Fortran options.
Porting to HP Fortran Using porting options Porting from Tru64 to HP Fortran Support has been added for options that will assist users in porting applications from Tru64 to HP Fortran. Wherever possible, these options mimic the behavior of their counterparts in the Tru64 Fortran compiler. +cfc The +cfc flag has been added to the Fortran compiler. +cfc allows you access to the newly-implemented Tru64 Fortran options.
Porting to HP Fortran Using porting options Porting from Tru64 to HP Fortran Support has been added for options that will assist users in porting applications from Tru64 to HP Fortran. Wherever possible, these options mimic the behavior of their counterparts in the Tru64 Fortran compiler. +cfc The +cfc flag has been added to the Fortran compiler. +cfc allows you access to the newly-implemented Tru64 Fortran options.
Porting to HP Fortran Using porting options Porting from Tru64 to HP Fortran Support has been added for options that will assist users in porting applications from Tru64 to HP Fortran. Wherever possible, these options mimic the behavior of their counterparts in the Tru64 Fortran compiler. +cfc The +cfc flag has been added to the Fortran compiler. +cfc allows you access to the newly-implemented Tru64 Fortran options.
Porting to HP Fortran Using porting options Porting from Tru64 to HP Fortran Support has been added for options that will assist users in porting applications from Tru64 to HP Fortran. Wherever possible, these options mimic the behavior of their counterparts in the Tru64 Fortran compiler. +cfc The +cfc flag has been added to the Fortran compiler. +cfc allows you access to the newly-implemented Tru64 Fortran options.
Porting to HP Fortran Using porting options Porting from Tru64 to HP Fortran Support has been added for options that will assist users in porting applications from Tru64 to HP Fortran. Wherever possible, these options mimic the behavior of their counterparts in the Tru64 Fortran compiler. +cfc The +cfc flag has been added to the Fortran compiler. +cfc allows you access to the newly-implemented Tru64 Fortran options.
Porting to HP Fortran Using porting options Porting from Tru64 to HP Fortran Support has been added for options that will assist users in porting applications from Tru64 to HP Fortran. Wherever possible, these options mimic the behavior of their counterparts in the Tru64 Fortran compiler. +cfc The +cfc flag has been added to the Fortran compiler. +cfc allows you access to the newly-implemented Tru64 Fortran options.
Porting to HP Fortran Using porting options Porting from Tru64 to HP Fortran Support has been added for options that will assist users in porting applications from Tru64 to HP Fortran. Wherever possible, these options mimic the behavior of their counterparts in the Tru64 Fortran compiler. +cfc The +cfc flag has been added to the Fortran compiler. +cfc allows you access to the newly-implemented Tru64 Fortran options.
Porting to HP Fortran Using porting options Porting from Tru64 to HP Fortran Support has been added for options that will assist users in porting applications from Tru64 to HP Fortran. Wherever possible, these options mimic the behavior of their counterparts in the Tru64 Fortran compiler. +cfc The +cfc flag has been added to the Fortran compiler. +cfc allows you access to the newly-implemented Tru64 Fortran options.
Porting to HP Fortran Using porting options Porting from Tru64 to HP Fortran Support has been added for options that will assist users in porting applications from Tru64 to HP Fortran. Wherever possible, these options mimic the behavior of their counterparts in the Tru64 Fortran compiler. +cfc The +cfc flag has been added to the Fortran compiler. +cfc allows you access to the newly-implemented Tru64 Fortran options.
Porting to HP Fortran Using porting options Porting from Tru64 to HP Fortran Support has been added for options that will assist users in porting applications from Tru64 to HP Fortran. Wherever possible, these options mimic the behavior of their counterparts in the Tru64 Fortran compiler. +cfc The +cfc flag has been added to the Fortran compiler. +cfc allows you access to the newly-implemented Tru64 Fortran options.
Porting to HP Fortran Using porting options Porting from Tru64 to HP Fortran Support has been added for options that will assist users in porting applications from Tru64 to HP Fortran. Wherever possible, these options mimic the behavior of their counterparts in the Tru64 Fortran compiler. +cfc The +cfc flag has been added to the Fortran compiler. +cfc allows you access to the newly-implemented Tru64 Fortran options.
Porting to HP Fortran Using porting options Porting from Tru64 to HP Fortran Support has been added for options that will assist users in porting applications from Tru64 to HP Fortran. Wherever possible, these options mimic the behavior of their counterparts in the Tru64 Fortran compiler. +cfc The +cfc flag has been added to the Fortran compiler. +cfc allows you access to the newly-implemented Tru64 Fortran options.
Porting to HP Fortran Using porting options Porting from Tru64 to HP Fortran Support has been added for options that will assist users in porting applications from Tru64 to HP Fortran. Wherever possible, these options mimic the behavior of their counterparts in the Tru64 Fortran compiler. +cfc The +cfc flag has been added to the Fortran compiler. +cfc allows you access to the newly-implemented Tru64 Fortran options.
Porting to HP Fortran Using porting options Porting from Tru64 to HP Fortran Support has been added for options that will assist users in porting applications from Tru64 to HP Fortran. Wherever possible, these options mimic the behavior of their counterparts in the Tru64 Fortran compiler. +cfc The +cfc flag has been added to the Fortran compiler. +cfc allows you access to the newly-implemented Tru64 Fortran options.
Porting to HP Fortran Using porting options Porting from Tru64 to HP Fortran Support has been added for options that will assist users in porting applications from Tru64 to HP Fortran. Wherever possible, these options mimic the behavior of their counterparts in the Tru64 Fortran compiler. +cfc The +cfc flag has been added to the Fortran compiler. +cfc allows you access to the newly-implemented Tru64 Fortran options.
Porting to HP Fortran Using porting options Porting from Tru64 to HP Fortran Support has been added for options that will assist users in porting applications from Tru64 to HP Fortran. Wherever possible, these options mimic the behavior of their counterparts in the Tru64 Fortran compiler. +cfc The +cfc flag has been added to the Fortran compiler. +cfc allows you access to the newly-implemented Tru64 Fortran options.
Porting to HP Fortran Using porting options Porting from Tru64 to HP Fortran Support has been added for options that will assist users in porting applications from Tru64 to HP Fortran. Wherever possible, these options mimic the behavior of their counterparts in the Tru64 Fortran compiler. +cfc The +cfc flag has been added to the Fortran compiler. +cfc allows you access to the newly-implemented Tru64 Fortran options.
Porting to HP Fortran Using porting options Porting from Tru64 to HP Fortran Support has been added for options that will assist users in porting applications from Tru64 to HP Fortran. Wherever possible, these options mimic the behavior of their counterparts in the Tru64 Fortran compiler. +cfc The +cfc flag has been added to the Fortran compiler. +cfc allows you access to the newly-implemented Tru64 Fortran options.
Porting to HP Fortran Using porting options Porting from Tru64 to HP Fortran Support has been added for options that will assist users in porting applications from Tru64 to HP Fortran. Wherever possible, these options mimic the behavior of their counterparts in the Tru64 Fortran compiler. +cfc The +cfc flag has been added to the Fortran compiler. +cfc allows you access to the newly-implemented Tru64 Fortran options.
Porting to HP Fortran Using porting options Porting from Tru64 to HP Fortran Support has been added for options that will assist users in porting applications from Tru64 to HP Fortran. Wherever possible, these options mimic the behavior of their counterparts in the Tru64 Fortran compiler. +cfc The +cfc flag has been added to the Fortran compiler. +cfc allows you access to the newly-implemented Tru64 Fortran options.
Porting to HP Fortran Using porting options Porting from Tru64 to HP Fortran Support has been added for options that will assist users in porting applications from Tru64 to HP Fortran. Wherever possible, these options mimic the behavior of their counterparts in the Tru64 Fortran compiler. +cfc The +cfc flag has been added to the Fortran compiler. +cfc allows you access to the newly-implemented Tru64 Fortran options.
Porting to HP Fortran Using porting options Porting from Tru64 to HP Fortran Support has been added for options that will assist users in porting applications from Tru64 to HP Fortran. Wherever possible, these options mimic the behavior of their counterparts in the Tru64 Fortran compiler. +cfc The +cfc flag has been added to the Fortran compiler. +cfc allows you access to the newly-implemented Tru64 Fortran options.
Porting to HP Fortran Using porting options Porting from Tru64 to HP Fortran Support has been added for options that will assist users in porting applications from Tru64 to HP Fortran. Wherever possible, these options mimic the behavior of their counterparts in the Tru64 Fortran compiler. +cfc The +cfc flag has been added to the Fortran compiler. +cfc allows you access to the newly-implemented Tru64 Fortran options.
Porting to HP Fortran Using porting options Porting from Tru64 to HP Fortran Support has been added for options that will assist users in porting applications from Tru64 to HP Fortran. Wherever possible, these options mimic the behavior of their counterparts in the Tru64 Fortran compiler. +cfc The +cfc flag has been added to the Fortran compiler. +cfc allows you access to the newly-implemented Tru64 Fortran options.
Porting to HP Fortran Using porting options Porting from Tru64 to HP Fortran Support has been added for options that will assist users in porting applications from Tru64 to HP Fortran. Wherever possible, these options mimic the behavior of their counterparts in the Tru64 Fortran compiler. +cfc The +cfc flag has been added to the Fortran compiler. +cfc allows you access to the newly-implemented Tru64 Fortran options.