Compaq Fortran 77
Language Reference Manual

Order Number: AA-PU45C-TK

April 1999

This manual contains the complete description of the Compaq Fortran 77 (formerly DEC Fortran) programming language. It contains information on language syntax and semantics, on adherence to various Fortran standards, and on extensions to those standards.

Revision /Update Information This revised manual supersedes all previous DEC Fortran and VAX FORTRAN language reference manuals.

Compaq Computer Corporation
Houston, Texas

©Compaq Computer Corporation 1999. All Rights Reserved.

Contents

Preface

1 Introduction

1.1 Language Standards

1.2 Language Compatibility

1.3 Elements of Source Programs

1.3.1 Program Units

1.3.2 Statements

1.3.3 Symbolic Names

1.3.4 Comments

1.4 Character Set

1.5 Coding Rules

1.5.1 Fixed-Format Lines

1.5.2 Tab-Format Lines

1.5.3 Statement Label Field

1.5.3.1 Comment Indicator

1.5.3.2 Debugging Statement Indicator

1.5.4 Continuation Indicator Field

1.5.5 Statement Field

1.5.6 Sequence Number Field

1.6 Compilation Control Statements

1.6.1 DICTIONARY Statement (VMS only)

1.6.2 INCLUDE Statement

1.6.3 OPTIONS Statement

2 Data Types, Data Items, and Expressions

2.1 Data Types

2.2 Data Items

2.2.1 Constants

2.2.1.1 Integer Constants

2.2.1.2 Real Constants

2.2.1.3 Complex Constants

2.2.1.4 Bit Constants

2.2.1.5 Logical Constants

2.2.1.6 Character Constants

2.2.1.7 Hollerith Constants

2.2.2 Variables

2.2.2.1 Data Type by Specification

2.2.2.2 Data Type by Implication

2.2.3 Arrays

2.2.3.1 Array Declarators

2.2.3.2 Array Subscripts

2.2.3.3 Arrangement of Array Elements in Storage

2.2.3.4 Data Type of an Array

2.2.3.5 Referencing Arrays Without Subscripts

2.2.3.6 Classes of Arrays

2.2.4 Character Substrings

2.2.5 Records

2.2.5.1 Arrangement of Records in Storage

2.2.5.2 References to Record Fields

2.2.6 Terminology Referring to Data Items

2.3 Expressions

2.3.1 Arithmetic Expressions

2.3.1.1 Using Parentheses

2.3.1.2 Data Type of an Arithmetic Expression

2.3.2 Character Expressions

2.3.3 Relational Expressions

2.3.4 Logical Expressions

3 Assignment Statements

3.1 Arithmetic Assignment Statement

3.2 Logical Assignment Statement

3.3 Character Assignment Statement

3.4 Aggregate Assignment Statement

3.5 ASSIGN Statement

4 Specification Statements

4.1 AUTOMATIC and STATIC Statements

4.2 BLOCK DATA Statement

4.3 COMMON Statement

4.4 DATA Statement

4.5 Type Declaration Statements

4.5.1 Numeric Type Declaration Statements

4.5.2 Character Type Declaration Statements

4.6 DIMENSION Statement

4.7 EQUIVALENCE Statement

4.7.1 Making Arrays Equivalent

4.7.2 Making Substrings Equivalent

4.7.3 EQUIVALENCE and COMMON Interaction

4.8 EXTERNAL Statement

4.9 IMPLICIT Statement

4.10 INTRINSIC Statement

4.11 NAMELIST Statement

4.12 PARAMETER Statement

4.13 POINTER Statement

4.14 PROGRAM Statement

4.15 RECORD Statement

4.16 SAVE Statement

4.17 Structure Declarations

4.17.1 Type Declarations in Structure Declarations

4.17.2 Substructure Declarations in Structure Declarations

4.17.3 Union Declarations in Structure Declarations

4.18 VOLATILE Statement

5 Control Statements

5.1 CALL Statement

5.2 CASE Construct (Alpha only)

5.3 CONTINUE Statement

5.4 DO Constructs

5.4.1 Indexed DO Constructs

5.4.1.1 DO Iteration Control

5.4.1.2 Nested DO Loops

5.4.1.3 Control Transfers in DO Loops

5.4.1.4 Extended Range

5.4.2 DO WHILE Constructs

5.4.3 CYCLE Statement (Alpha only)

5.4.4 EXIT Statement (Alpha only)

5.5 END Statement

5.6 GO TO Statements

5.6.1 Unconditional GO TO Statement

5.6.2 Computed GO TO Statement

5.6.3 Assigned GO TO Statement

5.7 IF Statements and Constructs

5.7.1 Arithmetic IF Statement

5.7.2 Logical IF Statement

5.7.3 IF Constructs

5.7.3.1 Statement Blocks

5.7.3.2 Examples of IF Constructs

5.7.3.3 Nested IF Constructs

5.8 PAUSE Statement

5.9 RETURN Statement

5.10 STOP Statement

6 Subprograms: Subroutines and Functions

6.1 Subprogram Arguments

6.1.1 Actual Argument and Dummy Argument Association

6.1.1.1 Adjustable Arrays

6.1.1.2 Assumed-Size Arrays

6.1.1.3 Automatic Arrays (Alpha only)

6.1.1.4 Passed-Length Character Arguments

6.1.1.5 Hollerith and Character Constants as Actual Arguments

6.1.1.6 Alternate Return Arguments

6.1.2 Built-In Functions

6.1.2.1 Argument List Built-In Functions

6.1.2.2 %LOC Built-In Function

6.2 User-Written Subprograms

6.2.1 Statement Functions

6.2.2 Function Subprograms

6.2.2.1 Logical and Numeric Functions

6.2.2.2 Character Functions

6.2.2.3 Function Reference

6.2.3 Subroutine Subprograms: SUBROUTINE Statement

6.2.4 ENTRY Statement

6.2.4.1 ENTRY Statements in Function Subprograms

6.2.4.2 ENTRY Statements in Subroutine Subprograms

6.3 Fortran Intrinsic Functions

6.3.1 Intrinsic Function References

6.3.1.1 Generic References to Intrinsic Functions

6.3.1.2 Using Intrinsic Function Names

6.3.2 Character and Lexical Comparison Intrinsic Functions

6.3.2.1 Character Functions

6.3.2.2 Lexical Comparison Functions

7 I/O Statements

7.1 Components of I/O Statements

7.1.1 Control List

7.1.1.1 Rules for Control-List Parameters

7.1.1.2 Logical Unit Specifier

7.1.1.3 Internal File Specifier

7.1.1.4 Format Specifier

7.1.1.5 Namelist Specifier

7.1.1.6 Record Specifier

7.1.1.7 Key-Field-Value Specifier (VMS only)

7.1.1.8 Key-of-Reference Specifier (VMS only)

7.1.1.9 I/O Status Specifier

7.1.1.10 Transfer-of-Control Specifiers

7.1.2 I/O List

7.1.2.1 Simple List Elements

7.1.2.2 Implied-DO Lists in I/O Statements

7.2 READ Statements

7.2.1 Sequential READ Statements

7.2.1.1 Formatted Sequential READ Statement

7.2.1.2 List-Directed Sequential READ Statement

7.2.1.3 Namelist Sequential READ Statement

7.2.1.4 Unformatted Sequential READ Statement

7.2.2 Direct Access READ Statements

7.2.2.1 Formatted Direct Access READ Statement

7.2.2.2 Unformatted Direct Access READ Statement

7.2.3 Indexed READ Statements (VMS only)

7.2.3.1 Formatted Indexed READ Statement (VMS only)

7.2.3.2 Unformatted Indexed READ Statement (VMS only)

7.2.4 Internal READ Statement

7.2.4.1 Formatted Internal READ Statement

7.2.4.2 List-Directed Internal READ Statement

7.3 WRITE Statements

7.3.1 Sequential WRITE Statements

7.3.1.1 Formatted Sequential WRITE Statement

7.3.1.2 List-Directed Sequential WRITE Statement

7.3.1.3 Namelist Sequential WRITE Statement

7.3.1.4 Unformatted Sequential WRITE Statement

7.3.2 Direct Access WRITE Statements

7.3.2.1 Formatted Direct Access WRITE Statement

7.3.2.2 Unformatted Direct Access WRITE Statement

7.3.3 Indexed WRITE Statements (VMS only)

7.3.3.1 Formatted Indexed WRITE Statement (VMS only)

7.3.3.2 Unformatted Indexed WRITE Statement (VMS only)

7.3.4 Internal WRITE Statement

7.3.4.1 Formatted Internal WRITE Statement

7.3.4.2 List-Directed Internal WRITE Statement

7.4 REWRITE Statements

7.4.1 Formatted REWRITE Statement

7.4.2 Unformatted REWRITE Statement

7.5 ACCEPT Statements

7.6 TYPE and PRINT Statements

8 I/O Formatting

8.1 FORMAT Statement Syntax

8.1.1 Field Descriptor Syntax

8.1.2 Edit Descriptor Syntax

8.1.3 FORMAT Codes

8.2 General Rules for Writing FORMAT Statements

8.2.1 General Input Rules for FORMAT Statements

8.2.2 General Output Rules for FORMAT Statements

8.3 Field Descriptors

8.3.1 Integer Editing

8.3.1.1 I Field Descriptor

8.3.1.2 O Field Descriptor

8.3.1.3 Z Field Descriptor

8.3.2 Real and Complex Editing

8.3.2.1 F Field Descriptor

8.3.2.2 E Field Descriptor

8.3.2.3 D Field Descriptor

8.3.2.4 G Field Descriptor

8.3.2.5 Complex Editing

8.3.3 Logical Editing - the L Field Descriptor

8.3.4 Character Editing - the A Field Descriptor

8.3.5 Default Field Descriptor Parameters

8.3.6 Repeat Counts and Group Repeat Counts

8.3.7 Variable Format Expressions

8.4 Edit Descriptors

8.4.1 Positional Editing

8.4.1.1 T Edit Descriptor

8.4.1.2 TL Edit Descriptor

8.4.1.3 TR Edit Descriptor

8.4.1.4 X Edit Descriptor

8.4.2 Sign Editing

8.4.2.1 SP Edit Descriptor

8.4.2.2 SS Edit Descriptor

8.4.2.3 S Edit Descriptor

8.4.3 Blank Editing

8.4.3.1 BN Edit Descriptor

8.4.3.2 BZ Edit Descriptor

8.4.4 Scale Factor Editing - the P Edit Descriptor

8.4.5 Character String Editing

8.4.5.1 H Edit Descriptor

8.4.5.2 Character Constants

8.5 Additional Edit Descriptors

8.5.1 Colon Edit Descriptor

8.5.2 Dollar Sign Edit Descriptor

8.5.3 Q Edit Descriptor

8.6 Carriage Control

8.7 Format Specification Separators

8.8 External Field Separators

8.9 Run-Time Formats

8.10 Format Control Interaction with I/O Lists

9 Auxiliary I/O Statements on OpenVMS Systems

9.1 BACKSPACE Statement

9.2 CLOSE Statement

9.3 DELETE Statement

9.4 ENDFILE Statement

9.5 INQUIRE Statement

9.5.1 ACCESS Specifier

9.5.2 BLANK Specifier

9.5.3 CARRIAGECONTROL Specifier

9.5.4 CONVERT Specifier

9.5.5 DIRECT Specifier

9.5.6 ERR Specifier

9.5.7 EXIST Specifier

9.5.8 FORM Specifier

9.5.9 FORMATTED Specifier

9.5.10 IOSTAT Specifier

9.5.11 KEYED Specifier

9.5.12 NAME Specifier

9.5.13 NAMED Specifier

9.5.14 NEXTREC Specifier

9.5.15 NUMBER Specifier

9.5.16 OPENED Specifier

9.5.17 ORGANIZATION Specifier

9.5.18 RECL Specifier

9.5.19 RECORDTYPE Specifier

9.5.20 SEQUENTIAL Specifier

9.5.21 UNFORMATTED Specifier

9.6 OPEN Statement

9.6.1 ACCESS Keyword

9.6.2 ASSOCIATEVARIABLE Keyword

9.6.3 BLANK Keyword

9.6.4 BLOCKSIZE Keyword

9.6.5 BUFFERCOUNT Keyword

9.6.6 CARRIAGECONTROL Keyword

9.6.7 CONVERT Keyword

9.6.8 DEFAULTFILE Keyword

9.6.9 DISPOSE Keyword

9.6.10 ERR Keyword

9.6.11 EXTENDSIZE Keyword

9.6.12 FILE Keyword

9.6.13 FORM Keyword

9.6.14 INITIALSIZE Keyword

9.6.15 IOSTAT Keyword

9.6.16 KEY Keyword

9.6.17 MAXREC Keyword

9.6.18 NAME Keyword

9.6.19 NOSPANBLOCKS Keyword

9.6.20 ORGANIZATION Keyword

9.6.21 READONLY Keyword

9.6.22 RECL Keyword

9.6.23 RECORDSIZE Keyword

9.6.24 RECORDTYPE Keyword

9.6.25 SHARED Keyword

9.6.26 STATUS Keyword

9.6.27 TYPE Keyword

9.6.28 UNIT Keyword

9.6.29 USEROPEN Keyword

9.7 REWIND Statement

9.8 UNLOCK Statement

10 Auxiliary I/O Statements on Tru64 UNIX Systems

10.1 BACKSPACE Statement

10.2 CLOSE Statement

10.3 DELETE Statement

10.4 ENDFILE Statement

10.5 INQUIRE Statement

10.5.1 ACCESS Specifier

10.5.2 BLANK Specifier

10.5.3 CARRIAGECONTROL Specifier

10.5.4 CONVERT Specifier

10.5.5 DIRECT Specifier

10.5.6 ERR Specifier

10.5.7 EXIST Specifier

10.5.8 FORM Specifier

10.5.9 FORMATTED Specifier

10.5.10 IOSTAT Specifier

10.5.11 NAME Specifier

10.5.12 NAMED Specifier

10.5.13 NEXTREC Specifier

10.5.14 NUMBER Specifier

10.5.15 OPENED Specifier

10.5.16 ORGANIZATION Specifier

10.5.17 RECL Specifier

10.5.18 RECORDTYPE Specifier

10.5.19 SEQUENTIAL Specifier

10.5.20 UNFORMATTED Specifier

10.6 OPEN Statement

10.6.1 ACCESS Keyword

10.6.2 ASSOCIATEVARIABLE Keyword

10.6.3 BLANK Keyword

10.6.4 BLOCKSIZE Keyword

10.6.5 BUFFERCOUNT Keyword

10.6.6 CARRIAGECONTROL Keyword

10.6.7 CONVERT Keyword

10.6.8 DEFAULTFILE Keyword

10.6.9 DISPOSE Keyword

10.6.10 ERR Keyword

10.6.11 FILE Keyword

10.6.12 FORM Keyword

10.6.13 IOSTAT Keyword

10.6.14 MAXREC Keyword

10.6.15 NAME Keyword

10.6.16 ORGANIZATION Keyword

10.6.17 READONLY Keyword

10.6.18 RECL Keyword

10.6.19 RECORDSIZE Keyword

10.6.20 RECORDTYPE Keyword

10.6.21 STATUS Keyword

10.6.22 TYPE Keyword

10.6.23 UNIT Keyword

10.6.24 USEROPEN Keyword

10.7 REWIND Statement

10.8 UNLOCK Statement

11 Compiler Directives

11.1 General Rules for Compiler Directives

11.2 General Directives

11.2.1 ALIAS Directive

11.2.2 ASSERT Directive (VAX only)

11.2.3 IDENT Directive

11.2.4 INIT_DEP_FWD Directive (VAX only)

11.2.5 NOVECTOR Directive (VAX only)

11.2.6 OPTIONS Directive (Alpha only)

11.2.7 PSECT Directive

11.2.8 TITLE and SUBTITLE Directives

11.3 Parallel Directives (VAX only)

11.3.1 CONTEXT_SHARED Directive (VAX only)

11.3.2 CONTEXT_SHARED_ALL Directive (VAX only)

11.3.3 DO_PARALLEL Directive (VAX only)

11.3.4 LOCKON and LOCKOFF Directives (VAX only)

11.3.5 PRIVATE Directive (VAX only)

11.3.6 PRIVATE_ALL Directive (VAX only)

11.3.7 SHARED Directive (VAX only)

11.3.8 SHARED_ALL Directive (VAX only)

11.3.9 Parallel Directive Examples (VAX only)

A Additional Language Features

A.1 DEFINE FILE Statement

A.2 ENCODE and DECODE Statements

A.3 FIND Statement

A.4 NOF77 Interpretation of the EXTERNAL Statement

A.5 Octal Notation for Integer Constants

A.6 PARAMETER Statement

A.7 VIRTUAL Statement

A.8 Intrinsic Functions

A.9 Alternative Syntax for Bit Constants

A.10 C-Style Escape Sequences (Alpha only)

A.11 Alternative Syntax for a Record Specifier

A.12 Alternative Syntax for the DELETE Statement

A.13 Alternative Syntax for Character Constants (Alpha only)

B Character Sets

B.1 Fortran Character Set

B.2 ASCII and DEC Multinational Character Sets

B.3 Radix-50 Constants and Character Set (VAX only)

C Expression Operators and Intrinsic Procedures

C.1 Expression Operators

C.2 Intrinsic Functions

C.2.1 Mathematical Intrinsic Functions

C.2.2 Numeric Intrinsic Functions

C.2.3 Bit Manipulation Intrinsic Functions

C.2.4 Character Intrinsic Functions

C.2.5 Miscellaneous Intrinsic Functions

C.3 Basic Linear Algebraic Routines (VAX only)

C.3.1 Basic Set (VAX only)

C.3.2 Extended Set (VAX only)

D System Subprograms and Bit Manipulation Functions

D.1 System Subprogram Summary

D.1.1 DATE Subroutine

D.1.2 EXIT Subroutine

D.1.3 IDATE Subroutine

D.1.4 MVBITS Subroutine

D.1.5 RAN Function

D.1.6 SECNDS Function

D.1.7 TIME Subroutine

D.2 Bit Manipulation Functions

D.2.1 Bit Position

D.2.2 Bit Function Arguments

E Summary of Language Extensions

E.1 Platform-Independent Extensions

E.2 Platform-Specific Extensions

E.3 Summary of Data Types and Characteristics

E.4 Platform-Specific Compiler Options

Glossary

Index

Examples

1-1 Using INCLUDE Within a Program

6-1 Using and Redefining an Intrinsic Function Name

8-1 Interaction Between an I/O List and a FORMAT Statement

11-1 Using the LOCKON and LOCKOFF Directives (VAX only)

11-2 Using the SHARED, CONTEXT_SHARED, and PRIVATE Directives (VAX only)

A-1 Using the NOF77 EXTERNAL Statement

Figures

1-1 Required Order of Statements and Lines

1-2 Line Formatting Example

2-1 Array Storage

2-2 Memory Diagram of REC for Packed Records

2-3 Memory Diagram of REC for Naturally Aligned Records (Alpha only)

2-4 Memory Diagram of AREC for Packed Records

2-5 Memory Diagram of AREC for Naturally Aligned Records (Alpha only)

2-6 Memory Diagram of NRD for Packed Records

2-7 Memory Diagram of NRD for Naturally Aligned Records (Alpha only)

2-8 Memory Diagram of Mapped Fields

3-1 Conversion Rules for Assignment Statements

4-1 Equivalence of Substrings

4-2 Equivalence of Character Arrays

4-3 A Valid Extension of a Common Block

4-4 An Invalid Extension of a Common Block

4-5 Memory Map of Structure DATE

4-6 Memory Map of Structure APPOINTMENT

4-7 Memory Map of Structure WORDS_LONG

5-1 Flow of Control in CASE Constructs (Alpha only)

5-2 Nested DO Loops

5-3 Control Transfers and Extended Range

5-4 Examples of IF Constructs

5-5 Example of Nested IF Construct

8-1 Example of a Group Repeat Count

B-1 Graphical Representation of the ASCII Character Set

B-2 Graphical Representation of the DEC Multinational Extension to the ASCII Character Set

Tables

1 Conventions Used in This Manual

1-1 Entities Identified by Symbolic Names

2-1 Data Type Storage Requirements

4-1 Equivalence of Array Storage

4-2 Equivalence of Arrays with Nonunity Lower Bounds

6-1 Argument List Built-In Functions and Defaults

6-2 Types of User-Written Subprograms

6-3 Summary of Generic Intrinsic Function Names

7-1 List-Directed Default Output Formats

8-1 FORMAT Code Summary

8-2 Effect of Data Magnitude on G Format Conversions

8-3 Size Limit of Numeric Elements Using the A Field Descriptor

8-4 Default Field Descriptor Values

8-5 Carriage Control Characters

9-1 OPEN Statement Keyword Values on OpenVMS Systems

9-2 Record Size (RECL) Limits on OpenVMS Systems

9-3 Record Size (RECL) Default Values on OpenVMS Systems

10-1 OPEN Statement Keyword Values on Tru64 UNIX Systems

10-2 Record Size (RECL) Limits on Tru64 UNIX Systems

10-3 Record Size (RECL) Default Values on Tru64 UNIX Systems

11-1 Common Block Default Attributes and PSECT Modification

B-1 Radix-50 Character Set with Comparative Values (VAX only)

C-1 Expression Operators

C-2 Mathematical Intrinsic Functions

C-3 Numeric Intrinsic Functions

C-4 Bit Manipulation Intrinsic Functions

C-5 Character Intrinsic Functions

C-6 Miscellaneous Intrinsic Functions

C-7 BLAS Basic Set Routines (VAX only)

C-8 BLAS Extended Set Routines (VAX only)

E-1 Intrinsic Data Types and Numeric Ranges

E-2 Compiler Option Names in This Manual


(no previous page) Next Page Table of Contents