Fortran Language Reference Manual, Volume 1


Table of Contents
About This Manual
Related CF90 and MIPSpro 7 Fortran 90 Compiler Publications
CF90 and MIPSpro 7 Fortran 90 Compiler Messages
CF90 and MIPSpro 7 Fortran 90 Compiler Man Pages
Related Fortran Publications
Related Publications
Obtaining Publications
Conventions
BNF Conventions
Reader Comments
1. Introduction
1.1. FORTRAN 77 Compatibility
1.2. Fortran 90 Compatibility
1.2.1. Fortran 95 language standard
1.2.2. Program Conformance
1.2.3. Processor Conformance
1.2.4. Portability
2. Fortran Concepts and Terms
2.1. Scope and Association
2.1.1. Scoping Units
2.1.2. Association
2.2. Program Organization
2.2.1. Program Units
2.2.2. Packaging
2.3. Data Environment
2.3.1. Data Type
2.3.2. Kind
2.3.3. Dimensionality
2.3.4. Dynamic Data
2.4. Program Execution
2.4.1. Execution Sequence
2.4.2. Definition and Undefinition
2.4.3. Dynamic Behavior
2.5. Summary of Forms
2.5.1. Program Units
2.5.2. Main Program
2.5.3. External Subprogram
2.5.4. Module
2.5.5. Block Data
2.5.6. Internal Subprogram
2.5.7. Procedure Headings
2.5.8. Procedure Endings
2.5.9. Specification Constructs
2.5.10. Derived-type Definition
2.5.11. Interface Block
2.5.12. Specification Statements
2.5.13. Type Declaration Statements
2.5.14. Attribute Specifications
2.5.15. Execution Part
2.5.16. Action Statements
2.5.17. CASE Construct
2.5.18. DO Construct
2.5.19. IF Construct
2.5.20. FORALL Construct
2.5.21. WHERE Construct
2.6. Ordering Requirements
2.7. Example Fortran Program
3. Language Elements and Source Form
3.1. CF90 and MIPSpro 7 Fortran 90 Character Set
3.2. Lexical Tokens
3.2.1. Statement Keywords
3.2.2. Names
3.2.3. Constants
3.2.4. Operators
3.2.5. Statement Labels
3.3. Source Form
3.3.1. Free Source Form
3.3.2. Fixed Source Form
3.4. Portable Source Form
3.4.1. Sample Program, Use with Either Source Form
3.5. The INCLUDE Line
3.6. Low-level Syntax
4. Data Types
4.1. Building the Data Environment for a Problem Solution
4.1.1. Choosing the Type and Other Attributes of a Variable
4.1.2. Choosing the Kind of a Variable of Intrinsic Type
4.1.3. Choosing to Define a Type for a Variable
4.2. What Is Meant by type in Fortran
4.2.1. Data Type Names
4.2.2. Data Type Values
4.2.3. Data Type Operations
4.2.4. Forms for Constants and Constructors
4.3. Intrinsic Data Types
4.3.1. Integer Type
4.3.2. Real Type
4.3.3. Complex Type
4.3.4. Logical Type
4.3.5. Character Type
4.3.6. Boolean Type (EXTENSION)
4.3.7. Cray Pointer Type (EXTENSION)
4.3.8. Cray Character Pointer Type (EXTENSION) (UNICOS and UNICOS/mk Systems Only)
4.4. Derived Types
4.4.1. Derived Type Definition
4.4.2. Derived Type Values
4.4.3. Derived Type Operations
4.4.4. Syntax for Specifying Derived-type Constant Expressions
4.5. Structure Constructors
4.6. Array Constructors
5. Declarations
5.1. Type Declaration Statements
5.1.1. Integer
5.1.2. Real
5.1.3. Double Precision
5.1.4. Complex
5.1.5. Logical
5.1.6. Character
5.1.7. Derived Type
5.1.8. Cray Pointer (EXTENSION)
5.1.9. Cray Character Pointer (EXTENSION) (Implementation Deferred on IRIX Systems)
5.2. Implicit Typing
5.3. Array Properties
5.3.1. Array Specifications
5.3.2. DIMENSION Attribute and Statement
5.3.3. ALLOCATABLE Attribute and Statement
5.4. POINTER Properties
5.4.1. POINTER Attribute and Statement
5.4.2. TARGET Attribute and Statement
5.4.3. AUTOMATIC Attribute and Statement (EXTENSION)
5.5. Data Initialization and the DATA Statement
5.5.1. PARAMETER Attribute and Statement
5.6. Object Accessibility and Use
5.6.1. PUBLIC and PRIVATE Attributes and Statements
5.6.2. INTENT Attribute and Statement
5.6.3. OPTIONAL Attribute and Statement
5.6.4. SAVE Attribute and Statement
5.6.5. VOLATILE Attribute and Statement (IRIX Systems Only)
5.7. Procedure Properties
5.7.1. EXTERNAL Attribute and Statement
5.7.2. INTRINSIC Attribute and Statement
5.8. Automatic Data Objects
5.9. NAMELIST Statement
5.10. Storage Association
5.10.1. Storage Units
5.10.2. Storage Sequence
5.10.3. EQUIVALENCE Statement
5.10.4. COMMON Statement
5.10.5. Restrictions on Common and Equivalence
6. Using Data
6.1. Constants and Variables
6.2. Substrings
6.3. Structure Components
6.4. Arrays
6.4.1. Array Terminology
6.4.2. Whole Arrays
6.4.3. Array Elements
6.4.4. Array Sections
6.4.5. Format of Array Elements and Array Sections
6.4.6. Using Array Elements and Array Sections
6.4.7. Array Element Order
6.5. Pointers and Allocatable Arrays
6.5.1. ALLOCATE Statement
6.5.2. NULLIFY Statement
6.5.3. DEALLOCATE Statement
7. Expressions and Assignments
7.1. Introduction to Expressions
7.1.1. Assignment
7.1.2. Expressions
7.2. Formation of Expressions
7.2.1. Operands
7.2.2. Binary and Unary Operations
7.2.3. Intrinsic and Defined Operations
7.2.4. Rules for Forming Expressions
7.2.5. Precedence of Operators
7.2.6. Intrinsic Operations
7.2.7. Defined Operations
7.2.8. Data Type, Type Parameters, and Shape of an Expression
7.2.9. Special Expressions
7.3. Interpretation of Expressions
7.3.1. Interpretation of the Intrinsic Operations
7.3.2. Interpretation of Defined Operations
7.4. Evaluation of Expressions
7.4.1. Possible Alternative Evaluations
7.4.2. Partial Evaluations
7.5. Assignment
7.5.1. Intrinsic Assignment
7.5.2. Defined Assignment
7.5.3. Pointer Assignment
7.5.4. Masked Array Assignment
7.5.5. FORALL Statement and Construct
8. Controlling Execution
8.1. The Execution Sequence
8.2. Blocks and Executable Constructs
8.3. IF Construct and IF Statement
8.3.1. The IF Construct
8.3.2. IF Statement
8.4. CASE Construct
8.4.1. Form of the CASE Construct
8.4.2. Execution of the CASE Construct
8.5. DO Construct
8.5.1. Form of the Block DO Construct
8.5.2. Form of the Nonblock DO Construct
8.5.3. Range of a DO Construct
8.5.4. Active and Inactive DO Constructs
8.5.5. Execution of DO Constructs
8.5.6. Altering the Execution Sequence Within the Range of a DO Construct
8.6. Branching
8.6.1. Use of Labels in Branching
8.6.2. GO TO Statement
8.6.3. Computed GO TO Statement
8.6.4. CONTINUE Statement
8.6.5. STOP Statement
8.7. Arithmetic IF Statement (Obsolescent)
Glossary
Index
List of Tables
1.
2.
3.
2-1.
3-1. CF90 and MIPSpro 7 Fortran 90 special characters
3-2.
3-3.
3-4.
3-5.
4-1. Integer kind values
4-2. Exponent equivalents
4-3.
4-4.
4-5.
4-6.
4-7.
4-8.
4-9. Real and complex kind values
4-10. Exponent equivalents
4-11.
4-12.
4-13. Logical kind values
4-14.
4-15.
4-16.
4-17.
4-18.
5-1.
5-2.
5-3.
5-4.
5-5.
5-6.
5-7.
5-8.
5-9.
5-10.
5-11.
5-12.
5-13.
5-14.
5-15.
5-16.
5-17.
5-18.
5-19.
5-20.
5-21.
5-22.
5-23. Types, attributes, and storage
5-24.
5-25.
6-1.
6-2.
6-3.
6-4.
6-5.
6-6.
6-7.
6-8. Message number identifiers
6-9.
6-10.
6-11. Message number identifiers
7-1. Intrinsic operators and the allowed types of their operands
7-2. The hierarchy of expressions through forms
7-3.
7-4.
7-5.
7-6.
7-7.
7-8.
7-9.
7-10.
7-11.
7-12.
7-13.
7-14.
7-15.
7-16. Categories of operations and relative precedences
7-17. Operand types and results for intrinsic operations
7-18. Type and type parameters of some simple expressions
7-19. Differences and similarities between initialization and specification expressions
7-20. Kinds of expressions and their uses
7-21. Interpretation of the intrinsic operations
7-22. The values of operations involving logical operators
7-23. Equivalent evaluations for numeric intrinsic operations
7-24. Nonequivalent evaluations of numeric expressions
7-25. Equivalent evaluations of other expressions
7-26.
7-27. Types of the variable and expression in an intrinsic assignment
7-28. Conversion performed on an expression before assignment
7-29.
7-30.
7-31.
7-32.
8-1.
8-2.
8-3.
8-4.
8-5.
8-6.
8-7.
8-8.
8-9.
8-10.
8-11.
8-12.
8-13.
8-14.
8-15.
List of Figures
2-1. Program packaging example
2-2. Requirements on statement ordering
2-3. Restrictions on the appearance of statements
4-1. Fortran data types
4-2. Forms of constants and constructors
5-1. Default implicit mapping for a program unit
5-2. Character alignment example
5-3. Numeric array alignment example
5-4. Storage of REUSE in FIRST and SECOND
5-5. Alignment resulting from correct code
5-6. Alignment resulting from incorrect code
6-1. Computation of subscript order value
6-2. States in the lifetime of a pointer
7-1. The hierarchy of expressions by examples
7-2. Example ordering of numeric types on UNICOS systems
7-3. Relationships between the kinds of expressions
8-1. Execution flow for an IF construct
8-2. Execution flow for a CASE construct
8-3. Execution flow for a DO construct