Fortran Programming Guide
|
|
The Sun Studio Fortran 95 compiler, f95, described here and in the companion Fortran User's Guide, is available under the Solaris operating environment on SPARC®, UltraSPARC®, and x86 platforms. The compiler conforms to published Fortran language standards, and provides many extended features, including multiprocessor parallelization, sophisticated optimized code compilation, and mixed C/Fortran language support.
The f95 compiler also provides a Fortran 77 compatibility mode that accepts most legacy Fortran 77 source codes. A separate Fortran 77 compiler is no longer included. See Chapter 5 of the Fortran User's Guide for information on FORTRAN 77 compatibility and migration issues.
1.1 Standards Conformance
- f95 was designed to be compatible with the ANSI X3.198-1992, ISO/IEC 1539:1991, and ISO/IEC 1539:1997 standards documents.
- Floating-point arithmetic is based on IEEE standard 754-1985, and international standard IEC 60559:1989.
- f95 provides support for the optimization-exploiting features of SPARC V8, and SPARC V9, including the UltraSPARC implementation. These features are defined in the SPARC Architecture Manuals, Version 8 (ISBN 0-13-825001-4), and Version 9 (ISBN 0-13-099227-5), published by Prentice-Hall for SPARC International.
- In this document, "Standard" means conforming to the versions of the standards listed above. "Non-standard" or "Extension" refers to features that go beyond these versions of these standards.
The responsible standards bodies may revise these standards from time to time. The versions of the applicable standards to which these compilers conform may be revised or replaced, resulting in features in future releases of the Sun Fortran compilers that create incompatibilities with earlier releases.
1.2 Features of the Fortran 95 Compiler
The Sun Studio Fortran 95 compiler provides the following features and extensions:
- Global program checking across routines for consistency of arguments, commons, parameters, and the like.
- Optimized automatic and explicit loop parallelization for multiprocessor systems.
- VAX/VMS Fortran extensions, including:
- Structures, records, unions, maps
- Recursion
- OpenMP parallelization directives.
- Cray-style parallelization directives, including TASKCOMMON.
- Global, peephole, and potential parallelization optimizations produce high performance applications. Benchmarks show that optimized applications can run significantly faster when compared to unoptimized code.
- Common calling conventions on Solaris systems permit routines written in C or C++ to be combined with Fortran programs.
- Support for 64-bit enabled Solaris environments on UltraSPARC platforms.
- Call-by-value using %VAL.
- Compatibility between Fortran 77 and Fortran 95 programs and object binaries.
- Interval Arithmetic programming.
- Some "Fortran 2000" features, including Stream I/O.
See Appendix B of the Fortran User's Guide for details on new and extended features added to the compiler with each software release.
1.3 Other Fortran Utilities
The following utilities provide assistance in the development of software programs in Fortran:
- Sun Studio Performance Analyzer -- In depth performance analysis tool for single threaded and multi-threaded applications. See analyzer(1).
- asa -- This Solaris utility is a Fortran output filter for printing files that have Fortran carriage-control characters in column one. Use asa to transform files formatted with Fortran carriage-control conventions into files formatted according to UNIX line-printer conventions. See asa(1).
- fdumpmod -- A utility to display the names of modules contained in a file or archive. See fdumpmod(1).
- fpp -- A Fortran source code preprocessor. See fpp(1).
- fsplit -- This utility splits one Fortran file of several routines into several files, each with one routine per file. Use fsplit on FORTRAN 77 or Fortran 95 source files. See fsplit(1)
1.4 Debugging Utilities
The following debugging utilities are available:
- -Xlist -- A compiler option to check across routines for consistency of arguments, COMMON blocks, and so on.
- Sun Studio dbx--Provides a robust and feature-rich runtime and static debugger, and includes a performance data collector.
1.5 Sun Performance Library
The Sun Performance Library is a library of optimized subroutines and functions for computational linear algebra and Fourier transforms. It is based on the standard libraries LAPACK, BLAS1, BLAS2, BLAS3, FFTPACK, VFFTPACK, and LINPACK generally available through Netlib (www.netlib.org).
Each subprogram in the Sun Performance Library performs the same operation and has the same interface as the standard library versions, but is generally much faster and accurate and can be used in a multiprocessing environment.
See the performance_library README file, and the Sun Performance Library User's Guide for details. (Man pages for the performance library routines are in section 3P.)
1.6 Interval Arithmetic
The Fortran 95 compiler provides the compiler flags -xia and -xinterval to enable new language extensions and generate the appropriate code to implement interval arithmetic computations.
See the Fortran 95 Interval Arithmetic Programming Reference for details.
1.7 Man Pages
Online manual (man) pages provide immediate documentation about a command, function, subroutine, or collection of such things. See the Preface for the proper setting of the MANPATH environment variable for accessing Sun Studio man pages.)
You can display a man page by running the command:
Throughout the Fortran documentation, man page references appear with the topic name and man section number: f95(1) is accessed with man f95. Other sections, denoted by ieee_flags(3M) for example, are accessed using the -s option on the man command:
demo% man -s 3M ieee_flags
|
The Fortran library routines are documented in the man page section 3F.
The following lists man pages of interest to Fortran users:
f95(1)
|
The Fortran 95 command-line options
|
analyzer(1)
|
Sun Studio Performance Analyzer
|
asa(1)
|
Fortran carriage-control print output post-processor
|
dbx(1)
|
Command-line interactive debugger
|
fpp(1)
|
Fortran source code pre-processor
|
cpp(1)
|
C source code pre-processor
|
fdumpmod(1)
|
Display contents of a MODULE (.mod) file.
|
fsplit(1)
|
Pre-processor splits Fortran source routines into single files
|
ieee_flags(3M)
|
Examine, set, or clear floating-point exception bits
|
ieee_handler(3M)
|
Handle floating-point exceptions
|
matherr(3M)
|
Math library error handling routine
|
ild(1)
|
Incremental link editor for object files
|
ld(1)
|
Link editor for object files
|
1.8 README Files
The READMEs directory contains files that describe new features, software incompatibilities, bugs, and information that was discovered after the manuals were printed. The location of this directory depends on where your software was installed. The path is: /opt/SUNWspro/READMEs/.
TABLE 1-1 READMEs of Interest
README File
|
Describes...
|
fortran_95
|
new and changed features, known limitations, documentation errata for this release of the Fortran 95 compiler, f95.
|
fpp_readme
|
overview of fpp features and capabilities
|
interval_arithmetic
|
overview of the interval arithmetic features in f95
|
math_libraries
|
optimized and specialized math libraries available.
|
profiling_tools
|
using the performance profiling tools, prof, gprof, and tcov.
|
runtime_libraries
|
libraries and executables that can be redistributed under the terms of the End User License.
|
performance_library
|
overview of the Sun Performance Library
|
The README file for each compiler is easily viewed by the -xhelp=readme command-line option. For example, the command:
will display the fortran_95 README file directly.
1.9 Command-Line Help
You can view very brief descriptions of the f95 command line options by invoking the compiler's -help option as shown below:
%f95 -help=flags
Items within [ ] are optional. Items within < > are variable parameters.
Bar | indicates choice of literal values.
-someoption[={yes|no}] implies -someoption is equivalent to -someoption=yes
_______________________________________________________________
-a Collect data for tcov basic block profiling
-aligncommon[=<a>] Align common block elements to the specified boundary requirement; <a>={1|2|4|8|16}
-ansi Report non-ANSI extensions.
-autopar Enable automatic loop parallelization
-Bdynamic Allow dynamic linking
-Bstatic Require static linking
-C Enable runtime subscript range checking
-c Compile only; produce .o files but suppress linking
...etc.
|
Fortran Programming Guide
|
817-6694-10
|
|
Copyright © 2004, Sun Microsystems, Inc. All rights reserved.