Documentation Home
> Sun Studio 12: Fortran Programming Guide
Sun Studio 12: Fortran Programming Guide
Book Information
Index
Numbers and Symbols
A
B
C
D
E
F
G
H
I
L
M
N
O
P
R
S
T
U
V
W
X
Y
Z
Preface
Chapter 1 Introduction
1.1 Standards Conformance
1.2 Features of the Fortran 95 Compiler
1.3 Other Fortran Utilities
1.4 Debugging Utilities
1.5 Sun Performance Library
1.6 Interval Arithmetic
1.7 Man Pages
1.8 README Files
1.9 Command-Line Help
Chapter 2 Fortran Input/Output
2.1 Accessing Files From Within Fortran Programs
2.1.1 Accessing Named Files
2.1.2 Opening Files Without a Name
2.1.2.1 Opened as Scratch
2.1.2.2 Already Open
2.1.2.3 Preconnected or Implicitly Named Units
2.1.3 Opening Files Without an OPEN Statement
2.1.4 Passing File Names to Programs
2.1.4.1 Via Runtime Arguments and GETARG
2.1.4.2 Via Environment Variables and GETENV
2.1.4.3 Command-Line I/O Redirection and Piping
2.2 Direct I/O
2.3 Binary I/O
2.4 Stream I/O
2.5 Internal Files
2.6 Binary I/O Between Big-Endian and Little-Endian Platforms
2.7 Legacy I/O Considerations
Chapter 3 Program Development
3.1 Facilitating Program Builds With the make Utility
3.1.1 The Makefile
3.1.2 make Command
3.1.3 Macros
3.1.4 Overriding Macro Values
3.1.5 Suffix Rules in make
3.1.6 .KEEP_STATE and Special Dependency Checking
3.2 Version Tracking and Control With SCCS
3.2.1 Controlling Files With SCCS
3.2.1.1 Creating the SCCS Directory
3.2.1.2 Inserting SCCS ID Keywords
3.2.1.3 Creating SCCS Files
3.2.2 Checking Files Out and In
Chapter 4 Libraries
4.1 Understanding Libraries
4.2 Specifying Linker Debugging Options
4.2.1 Generating a Load Map
4.2.2 Listing Other Information
4.2.3 Consistent Compiling and Linking
4.3 Setting Library Search Paths and Order
4.3.1 Search Order for Standard Library Paths
4.3.1.1 Static Linking
4.3.1.2 Dynamic Linking
4.3.2 LD_LIBRARY_PATH Environment Variable
4.3.3 Library Search Path and Order—Static Linking
4.3.3.1 Command-Line Order for -llibrary Options
4.3.3.2 Command-Line Order for -Ldir Options
4.3.4 Library Search Path and Order—Dynamic Linking
4.3.4.1 Specifying Dynamic Libraries at Build Time
4.3.4.2 Specifying Dynamic Libraries at Runtime
4.3.4.3 Fixing Errors During Dynamic Linking
4.4 Creating Static Libraries
4.4.1 Tradeoffs for Static Libraries
4.4.2 Creation of a Simple Static Library
4.4.2.1 Replacement in a Static Library
4.4.2.2 Ordering Routines in a Static Library
4.5 Creating Dynamic Libraries
4.5.1 Tradeoffs for Dynamic Libraries
4.5.2 Position-Independent Code and –xcode
4.5.3 Binding Options
4.5.3.1 –Bdynamic | -Bstatic
4.5.3.2 –dy | -dn
4.5.3.3 Binding in 64-Bit Environments
4.5.4 Naming Conventions
4.5.5 A Simple Dynamic Library
4.5.6 Initializing Common Blocks
4.6 Libraries Provided With Sun Fortran Compilers
4.7 Shippable Libraries
Chapter 5 Program Analysis and Debugging
5.1 Global Program Checking (-Xlist)
5.1.1 GPC Overview
5.1.2 How to Invoke Global Program Checking
5.1.2.1 Screen Output
5.1.2.2 Default Output Features
5.1.2.3 File Types
5.1.3 Some Examples of -Xlist and Global Program Checking
5.1.4 Suboptions for Global Checking Across Routines
5.1.4.1 Suboption Syntax
5.1.4.2 -Xlist and its Suboptions
5.2 Special Compiler Options
5.2.1 Subscript Bounds (–C)
5.2.2 Undeclared Variable Types (–u)
5.2.3 Compiler Version Checking (–V)
5.3 Debugging With dbx
Chapter 6 Floating-Point Arithmetic
6.1 Introduction
6.2 IEEE Floating-Point Arithmetic
6.2.1 –ftrap=mode Compiler Options
6.2.2 Floating-Point Exceptions
6.2.2.1 Retrospective Summary
6.2.3 Handling Exceptions
6.2.4 Trapping a Floating-Point Exception
6.2.5 Nonstandard Arithmetic
6.3 IEEE Routines
6.3.1 Flags and ieee_flags()
6.3.1.1 Turning Off All Warning Messages With ieee_flags
6.3.1.2 Detecting an Exception With ieee_flags
6.3.2 IEEE Extreme Value Functions
6.3.3 Exception Handlers and ieee_handler()
6.3.3.1 Establishing an Exception Handler Function
6.3.3.2 Writing User Exception Handler Functions
Detecting an Exception by Handler
Locating an Exception by Handler
6.4 Debugging IEEE Exceptions
6.5 Further Numerical Adventures
6.5.1 Avoiding Simple Underflow
6.5.2 Continuing With the Wrong Answer
6.5.3 Excessive Underflow
6.6 Interval Arithmetic
Chapter 7 Porting
7.1 Carriage-Control
7.2 Working With Files
7.3 Porting From Scientific Mainframes
7.4 Data Representation
7.5 Hollerith Data
7.6 Nonstandard Coding Practices
7.6.1 Uninitialized Variables
7.6.2 Aliasing and the -xalias Option
7.6.2.1 Aliasing Through Dummy Arguments and Global Variables
7.6.2.2 Aliasing Introduced With Cray Pointers
7.6.2.3 Aliasing Introduced With Fortran 95 Pointers
7.6.2.4 Aliasing By Overindexing
7.6.2.5 Aliasing By Actual Arguments
7.6.2.6 -xalias Defaults
7.6.3 Obscure Optimizations
7.6.3.1 Strip-Mining
7.6.3.2 Loop Unrolling
7.7 Time and Date Functions
7.8 Troubleshooting
7.8.1 Results Are Close, but Not Close Enough
7.8.2 Program Fails Without Warning
Chapter 8 Performance Profiling
8.1 Sun Studio Performance Analyzer
8.2 The time Command
8.2.1 Multiprocessor Interpretation of time Output
8.3 The tcov Profiling Command
8.3.1 Enhanced tcov Analysis
Chapter 9 Performance and Optimization
9.1 Choice of Compiler Options
9.1.1 Performance Options
9.1.1.1 -fast
9.1.1.2 -On
9.1.1.3 PRAGMA OPT=n
9.1.1.4 Optimization With Runtime Profile Feedback
9.1.1.5 -dalign
9.1.1.6 -depend
9.1.1.7 -fsimple=2
9.1.1.8 -unroll=n
9.1.1.9 -xtarget=platform
UltraSPARC-III and UltraSPARC-IV Support
64-Bit x86 Platform Support
9.1.1.10 Interprocedural Optimization With -xipo
9.1.1.11 Add PRAGMA ASSUME Assertions
9.1.2 Other Performance Strategies
9.1.3 Using Optimized Libraries
9.1.4 Eliminating Performance Inhibitors
9.1.4.1 Removing I/O From Key Loops
9.1.4.2 Eliminating Subprogram Calls
9.1.4.3 Rationalizing Tangled Code
9.1.5 Viewing Compiler Commentary
9.2 Further Reading
Chapter 10 Parallelization
10.1 Essential Concepts
10.1.1 Speedups—What to Expect
10.1.2 Steps to Parallelizing a Program
10.1.3 Data Dependence Issues
10.1.3.1 Data Dependent Loops
10.1.3.2 Recurrence
10.1.3.3 Reduction
10.1.3.4 Indirect Addressing
10.1.4 Compiling for Parallelization
10.1.5 Number of Threads
10.1.6 Stacks, Stack Sizes, and Parallelization
10.2 Automatic Parallelization
10.2.1 Loop Parallelization
10.2.2 Arrays, Scalars, and Pure Scalars
10.2.3 Automatic Parallelization Criteria
10.2.3.1 Apparent Dependencies
10.2.3.2 Inhibitors to Automatic Parallelization
10.2.3.3 Nested Loops
10.2.4 Automatic Parallelization With Reduction Operations
10.2.4.1 Recognized Reduction Operations
10.2.4.2 Numerical Accuracy and Reduction Operations
10.3 Explicit Parallelization
10.3.1 Parallelizable Loops
10.3.1.1 Scoping Rules: Private and Shared
10.3.1.2 Subprogram Call in a Loop
10.3.1.3 Inhibitors to Explicit Parallelization
10.3.1.4 I/O With Explicit Parallelization
10.3.2 OpenMP Parallelization Directives
10.4 Environment Variables
10.5 Debugging Parallelized Programs
10.5.1 First Steps at Debugging
10.6 Further Reading
Chapter 11 C-Fortran Interface
11.1 Compatibility Issues
11.1.1 Function or Subroutine?
11.1.2 Data Type Compatibility
11.1.3 Case Sensitivity
11.1.4 Underscores in Routine Names
11.1.5 Argument-Passing by Reference or Value
11.1.6 Argument Order
11.1.7 Array Indexing and Order
11.1.7.1 Array Indexing
11.1.7.2 Array Order
11.1.8 File Descriptors and stdio
11.1.9 Libraries and Linking With the f95 Command
11.2 Fortran Initialization Routines
11.3 Passing Data Arguments by Reference
11.3.1 Simple Data Types
11.3.2 COMPLEX Data
11.3.3 Character Strings
11.3.4 One-Dimensional Arrays
11.3.5 Two-Dimensional Arrays
11.3.6 Structures
11.3.7 Pointers
11.4 Passing Data Arguments by Value
11.5 Functions That Return a Value
11.5.1 Returning a Simple Data Type
11.5.2 Returning COMPLEX Data
11.5.2.1 32-bit Platforms
11.5.2.2 64–bit SPARC Platforms
11.5.3 Returning a CHARACTER String
11.6 Labeled COMMON
11.7 Sharing I/O Between Fortran and C
11.8 Alternate Returns
11.9 Fortran 2003 Interoperability With C
© 2010, Oracle Corporation and/or its affiliates