fortran 77 reference manual - bull

426
FORTRAN 77 Reference Manual DPS7000/XTA NOVASCALE 7000 Languages: FORTRAN REFERENCE 47 A2 15ULA02

Upload: others

Post on 04-Nov-2021

32 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: FORTRAN 77 Reference Manual - Bull

FORTRAN 77

Reference Manual

DPS

7000/XTA

NO

VASC

ALE

7000

Languages: FORTRAN

REFERENCE47 A2 15ULA02

Page 2: FORTRAN 77 Reference Manual - Bull
Page 3: FORTRAN 77 Reference Manual - Bull

DPS7000/XTANOVASCALE 7000

FORTRAN 77Reference Manual

Languages: FORTRAN

July 1991

BULL CEDOC

357 AVENUE PATTON

B.P.20845

49008 ANGERS CEDEX 01

FRANCE

REFERENCE47 A2 15ULA02

Page 4: FORTRAN 77 Reference Manual - Bull

The following copyright notice protects this book under Copyright laws which prohibit such actions as, but notlimited to, copying, distributing, modifying, and making derivative works.

Copyright Bull SAS 1991

Printed in France

Suggestions and criticisms concerning the form, content, and presentation of thisbook are invited. A form is provided at the end of this book for this purpose.

To order additional copies of this book or other Bull Technical Publications, youare invited to use the Ordering Form also provided at the end of this book.

Trademarks and Acknowledgements

We acknowledge the right of proprietors of trademarks mentioned in this book.

Intel® and Itanium® are registered trademarks of Intel Corporation.

Windows® and Microsoft® software are registered trademarks of Microsoft Corporation.

UNIX® is a registered trademark in the United States of America and other countries licensed exclusively throughthe Open Group.

Linux® is a registered trademark of Linus Torvalds.

The information in this document is subject to change without notice. Bull will not be liable for errors containedherein, or for incidental or consequential damages in connection with the use of this material.

Page 5: FORTRAN 77 Reference Manual - Bull

47 A2 15UL Rev02 iii

Preface

OBJECTIVES

This manual has been prepared for users of the BULL DPS7, operating under releaseGCOS7. It contains information about Fortran 77 and the full specification of thelanguage as implemented with GCOS7.

INTENDED READERS

This manual is intended for Fortran 77 programmers who want to use Fortran 77 underGCOS7.

If the reader has suggestions concerning the form, content, and purpose of this manual,there is a Technical Publications Remarks Form provided at the back of this document.

Comments are also welcomed about the following features:

• usefulness of the extensions to ANSI 77 offered by DPS 7 FORTRAN 77

• additional facilities you would like to access with DPS 7 FORTRAN 77.

Your recommendations will be investigated by Research and Development personneland, if possible, taken into account for future releases.

Page 6: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

iv 47 A2 15UL Rev02

ASSOCIATED DOCUMENTS

The following manuals are referred to in conjunction with the present manual:

• For GCOS7 JCL functions

JCL Reference Manual .................................................................................... 47 A2 11UJJCL User Guide................................................................................................ 47 A2 12UJ

• For GCOS7 interactive (GCL) functions

IOF Terminal User's Reference Manual (GCOS7-V3):Part I : Introduction to IOF.............................................................................. 47 A2 01UJPart II : GCOS Command Language .............................................................. 47 A2 02UJPart III : Processor commands......................................................................... 47 A2 03UJPart IV : Appendices ....................................................................................... 47 A2 04UJ

IOF Terminal User's Reference Manual (GCOS7-V5):Part I : Introduction to IOF.............................................................................. 47 A2 21UJPart II : GCL Commands (VBO)...................................................................... 47 A2 22UJPart II : GCL Commands (FBO) ...................................................................... 47 A2 23UJPart III : Directives and General Processor commands ................................... 47 A2 24UJPart IV : Appendices ....................................................................................... 47 A2 25UJ

• For manipulations during compilation and linking

Library Maintenance Reference manual ..........................................................47 A2 01UPLibrary Maintenance User's Guide...................................................................47 A2 02UPLinker User's Guide..........................................................................................47 A2 10UP

• For more information on the Fortran Language

DPS7 FORTRAN 77 User Guide .....................................................................47 A2 16ULMathematical Library........................................................................................47 A2 99UL

System Overview ............................................................................................ 47 A2 04UGProgram Checkout Facility ...............................................................................47 A2 15UP

Page 7: FORTRAN 77 Reference Manual - Bull

Preface

47 A2 15UL Rev02 v

SYNTAX NOTATION

The commands use the following syntax:

ITEM An item in upper case is a name or keyword and is enteredliterally as shown. The upper case is merely a convention;in practice you can specify the item in upper or lower case.

item An item in lower case indicates that a user-supplied value isexpected.

In most cases it gives the type and maximum length of the value:

char105 a string of up to 105 alphanumeric charactersname31 a name of up to 31 characterslib78 a library name of up to 78 charactersfile78 a file name of up to 78 characters

a means a single alphabetic characternnn means a 3-digit numberhh.mm means a time in hours and minutes

In other cases, it is simply descriptive of the value:device-classconditionany-characters

{ item }{ item }{ item } A list of items enclosed in braces indicates a choice of

values . Only one can be selected. Sometimes the list ispresented horizontally, with each item separated by avertical bar, i.e.

{item|item|item}[item] An item enclosed in square brackets is optional.

ITEM An underlined item is a default value. It is the valueassumed if none is specified.

<item> Angle brackets indicate a single key on the micro computer.

= , ; $ * / \ . Enter these special non-alphabetic characters as shown.

Page 8: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

vi 47 A2 15UL Rev02

Examples

(1)

{ } { { IMMED } } { WHEN={ [dd.mm.yy.]hh.mm } } { { +nnnn{W|D|H|M}item } } { }

This means you can specify:

1. Nothing at all, in which case WHEN=IMMED applies.

2. WHEN=IMMED (the same as nothing at all).

3. WHEN=22.30 to specify a time (and today's date).

4. WHEN=10.11.87.22.30 to specify a date and time.

5. WHEN=+0002W to specify 2 weeks from now.

6. WHEN=+0021D to specify 21 days from now.

7. WHEN=+005H to specify 5 hours from now.

8. WHEN=+0123M to specify 123 minutes from now.

(2)

PAGES={dec4|(dec4[-dec4][,dec4]...)}

Indicates that PAGES must be specified. Valid entries are a single value or a list ofvalues, enclosed in parentheses. The list can consist of single values seperated by acomma, a range of values separated by a hyphen, or a combination of both. Forexample:

PAGES=(2,4,10-25,33-36,78,83)

(3) <enter> refers to the return key (the enter key) on thealphanumeric keypad<transmit> refers to the transmission key on the numerickeypad<F10> refers to the F10 key<shift> refers to the shift key<shift F10> indicates that you should press the shift key andthe F10 key simultaneously (in other manuals sometimesdenoted as <shift>+<F10>).

Page 9: FORTRAN 77 Reference Manual - Bull

47 A2 15UL Rev02 vii

Table of Contents

1. Introduction ........................................................................................................... 1-1

1.1 PURPOSE AND NOTES............................................................................................. 1-1

1.1.1 Before You Begin ...................................................................................................... 1-11.1.2 Legend for Tables Containing Additions or Precisions ........................................ 1-21.1.3 Purpose ...................................................................................................................... 1-2

1.2 SCOPE........................................................................................................................ 1-4

1.2.1 Inclusions ................................................................................................................... 1-41.2.2 Exclusions ................................................................................................................. 1-4

1.3 NOTATION AND TERMINOLOGY USED IN THIS MANUAL ................................... 1-5

1.3.1 Terminology ............................................................................................................... 1-51.3.2 Notation ...................................................................................................................... 1-5

Page 10: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

viii 47 A2 15UL Rev02

2. FORTRAN Terms and Concepts ................................................................... 2-1

2.1 SEQUENCE ................................................................................................................ 2-1

2.2 SYNTACTIC ITEMS .................................................................................................... 2-2

2.3 STATEMENTS, COMMENTS, AND LINES ............................................................... 2-3

2.3.1 Classes of Statements .............................................................................................. 2-3

2.4 PROGRAM UNITS AND PROCEDURES ................................................................... 2-4

2.4.1 Procedures ................................................................................................................. 2-42.4.2 Executable Program .................................................................................................. 2-4

2.5 VARIABLE .................................................................................................................. 2-5

2.6 ARRAY ........................................................................................................................ 2-6

2.6.1 Array Elements .......................................................................................................... 2-6

2.7 SUBSTRING ............................................................................................................... 2-7

2.8 DUMMY ARGUMENT ................................................................................................. 2-7

2.9 SCOPE OF SYMBOLIC NAMES AND STATEMENT LABELS ................................ 2-8

2.10 LIST............................................................................................................................. 2-9

2.11 DEFINITION STATUS ................................................................................................ 2-9

2.12 REFERENCE .............................................................................................................. 2-10

2.13 STORAGE ................................................................................................................... 2-11

2.14 ASSOCIATION ............................................................................................................ 2-12

Page 11: FORTRAN 77 Reference Manual - Bull

Table of Contents

47 A2 15UL Rev02 ix

3. Characters, Lines, and Execution Sequence .......................................... 3-1

3.1 FORTRAN CHARACTER SET ................................................................................... 3-1

3.1.1 Letters ........................................................................................................................ 3-13.1.2 Digits .......................................................................................................................... 3-23.1.3 Alphanumeric Characters ......................................................................................... 3-23.1.4 Special Characters .................................................................................................... 3-23.1.5 Collating Sequence and Graphics ........................................................................... 3-33.1.6 Blank Character ......................................................................................................... 3-3

3.2 LINES .......................................................................................................................... 3-4

3.2.1 Comment Line ........................................................................................................... 3-43.2.2 Initial Line ................................................................................................................... 3-43.2.3 Continuation Line ...................................................................................................... 3-5

3.3 STATEMENTS ............................................................................................................ 3-6

3.4 STATEMENT LABELS ............................................................................................... 3-7

3.5 ORDER OF STATEMENTS AND LINES ................................................................... 3-8

3.6 NORMAL EXECUTION SEQUENCE AND TRANSFER OF CONTROL ................... 3-11

4. Data Types and Constants .............................................................................. 4-1

4.1 DATA TYPES .............................................................................................................. 4-1

4.1.1 Data Type of a Name ................................................................................................. 4-14.1.2 Type Rules for Data and Procedure Identifiers ...................................................... 4-24.1.3 Data Type Properties ................................................................................................ 4-2

4.2 CONSTANTS .............................................................................................................. 4-3

4.2.1 Data Type of a Constant ........................................................................................... 4-34.2.2 Blanks in Constants .................................................................................................. 4-34.2.3 Arithmetic Constants ................................................................................................ 4-34.2.3.1 Signs of Constants ...................................................................................................... 4-3

4.3 INTEGER TYPE .......................................................................................................... 4-4

4.3.1 Integer Constant ........................................................................................................ 4-4

Page 12: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

x 47 A2 15UL Rev02

4.4 REAL TYPE ................................................................................................................ 4-5

4.4.1 Basic Real Constant ................................................................................................. 4-54.4.2 Real Exponent ........................................................................................................... 4-54.4.3 Real Constant ............................................................................................................ 4-5

4.5 DOUBLE PRECISION TYPE ...................................................................................... 4-7

4.5.1 Double Precision Exponent ..................................................................................... 4-74.5.2 Double Precision Constant ...................................................................................... 4-7

4.6 COMPLEX TYPE ........................................................................................................ 4-9

4.6.1 Complex Constant .................................................................................................... 4-9

4.7 LOGICAL TYPE .......................................................................................................... 4-10

4.7.1 Logical Constant ....................................................................................................... 4-10

4.8 CHARACTER TYPE ................................................................................................... 4-11

4.8.1 Character Constant ................................................................................................... 4-11

4.9 SHORT INTEGER TYPE ............................................................................................ 4-12

4.10 SHORT LOGICAL TYPE ............................................................................................ 4-13

4.11 QUADRUPLE PRECISION TYPE .............................................................................. 4-14

4.11.1 Quadruple Precision Exponent ................................................................................ 4-144.11.2 Quadruple Precision Constant ................................................................................ 4-14

4.12 COMPLEX DOUBLE PRECISION TYPE ................................................................... 4-16

4.12.1 Complex Double Precision Constant ...................................................................... 4-16

4.13 HEXADECIMAL CONSTANTS ................................................................................... 4-16

4.14 HOLLERITH CONSTANT ........................................................................................... 4-18

Page 13: FORTRAN 77 Reference Manual - Bull

Table of Contents

47 A2 15UL Rev02 xi

5. Arrays and Substrings ...................................................................................... 5-1

5.1 ARRAY DECLARATOR .............................................................................................. 5-2

5.1.1 Form of an Array Declarator ..................................................................................... 5-25.1.1.1 Form of a Dimension Declaration................................................................................ 5-25.1.1.2 Value of Dimension Bounds........................................................................................ 5-2

5.1.2 Kinds and Occurrences of Array Declarators ........................................................ 5-35.1.2.1 Actual Array Declaration.............................................................................................. 5-35.1.2.2 Dummy Array Declaration ........................................................................................... 5-3

5.2 PROPERTIES OF AN ARRAY ................................................................................... 5-4

5.2.1 Data Type of an Array and an Array Element ......................................................... 5-45.2.2 Dimensions of an Array ............................................................................................ 5-45.2.3 Size of an Array ......................................................................................................... 5-55.2.4 Array Element Ordering ............................................................................................ 5-55.2.5 Array Storage Sequence ........................................................................................... 5-5

5.3 ARRAY ELEMENT NAME .......................................................................................... 5-6

5.4 SUBSCRIPT................................................................................................................ 5-7

5.4.1 Form of a Subscript .................................................................................................. 5-75.4.2 Subscript Expression ............................................................................................... 5-75.4.3 Subscript Value ......................................................................................................... 5-8

5.5 DUMMY AND ACTUAL ARRAYS .............................................................................. 5-10

5.5.1 Adjustable Arrays and Adjustable Dimensions ...................................................... 5-10

5.6 USE OF ARRAY NAMES ........................................................................................... 5-11

5.7 CHARACTER SUBSTRING ....................................................................................... 5-12

5.7.1 Substring Name ......................................................................................................... 5-125.7.2 Substring Expression ............................................................................................... 5-12

Page 14: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

xii 47 A2 15UL Rev02

6. Expressions .......................................................................................................... 6-1

6.1 ARITHMETIC EXPRESSIONS ................................................................................... 6-1

6.1.1 Arithmetic Operators ................................................................................................ 6-16.1.2 Form and Interpretation of Arithmetic Expressions .............................................. 6-26.1.2.1 Primaries ..................................................................................................................... 6-36.1.2.2 Factor .......................................................................................................................... 6-36.1.2.3 Term............................................................................................................................ 6-46.1.2.4 Arithmetic Expression ................................................................................................. 6-4

6.1.3 Arithmetic Constant Expression .............................................................................. 6-56.1.3.1 Integer Constant Expression....................................................................................... 6-5

6.1.4 Type and Interpretation of Arithmetic Expressions ............................................... 6-56.1.5 Integer Division ......................................................................................................... 6-10

6.2 CHARACTER EXPRESSIONS ................................................................................... 6-11

6.2.1 Character Operator ................................................................................................... 6-116.2.2 Form and Interpretation of Character Expressions ............................................... 6-116.2.2.1 Character Primaries .................................................................................................... 6-126.2.2.2 Character Expression.................................................................................................. 6-12

6.2.3 Character Constant Expression .............................................................................. 6-12

6.3 RELATIONAL EXPRESSIONS ................................................................................... 6-13

6.3.1 Relational Operators ................................................................................................. 6-136.3.2 Arithmetic Relational Expression ............................................................................ 6-136.3.3 Interpretation of Arithmetic Relational Expressions ............................................. 6-146.3.4 Character Relational Expression ............................................................................. 6-146.3.5 Interpretation of Character Relational Expressions .............................................. 6-15

6.4 LOGICAL EXPRESSIONS ......................................................................................... 6-16

6.4.1 Logical Operators ..................................................................................................... 6-166.4.2 Form and Interpretation of Logical Expressions ................................................... 6-176.4.2.1 Logical Primaries......................................................................................................... 6-186.4.2.2 Logical Factor.............................................................................................................. 6-186.4.2.3 Logical Term ............................................................................................................... 6-186.4.2.4 Logical Disjunctive....................................................................................................... 6-196.4.2.5 Logical Expression ...................................................................................................... 6-19

6.4.3 Value of Logical Factors, Terms, Disjuncts, and Expressions ............................. 6-206.4.4 Logical Constant Expression ................................................................................... 6-20

6.5 PRECEDENCE OF OPERATORS.............................................................................. 6-21

6.5.1 Summary of Interpretation Rules ............................................................................ 6-21

Page 15: FORTRAN 77 Reference Manual - Bull

Table of Contents

47 A2 15UL Rev02 xiii

6.6 EVALUATION OF EXPRESSIONS ............................................................................ 6-22

6.6.1 Evaluation of Operands ............................................................................................ 6-236.6.2 Order of Evaluation or Functions ............................................................................ 6-236.6.3 Integrity of Parentheses ........................................................................................... 6-236.6.4 Evaluation of Arithmetic Expressions .................................................................... 6-246.6.5 Evaluation of Character Expressions ..................................................................... 6-266.6.6 Evaluation of Relational Expressions ..................................................................... 6-266.6.7 Evaluation of Logical Expressions .......................................................................... 6-26

6.7 CONSTANT EXPRESSIONS...................................................................................... 6-27

7. Executable and Nonexecutable Statement Classification ................ 7-1

7.1 EXECUTABLE STATEMENTS ................................................................................... 7-1

7.2 NONEXECUTABLE STATEMENTS .......................................................................... 7-2

8. Specification Statements ................................................................................. 8-1

8.1 DIMENSION STATEMENT ......................................................................................... 8-2

8.2 EQUIVALENCE STATEMENT ................................................................................... 8-4

8.2.1 Form of an EQUIVALENCE Statement .................................................................... 8-48.2.2 Equivalence Association .......................................................................................... 8-48.2.3 Equivalence of Character Entities ........................................................................... 8-48.2.4 Array Names and Array Element Names ................................................................. 8-58.2.5 Restrictions on EQUIVALENCE Statements ........................................................... 8-5

8.3 COMMON STATEMENT ............................................................................................ 8-6

8.3.1 Form of a COMMON Statement ............................................................................... 8-68.3.2 Common Block Storage Sequence ......................................................................... 8-78.3.3 Size of a Common Block .......................................................................................... 8-78.3.4 Common Association ............................................................................................... 8-78.3.5 Differences Between Named Common and Blank Common ................................ 8-78.3.6 Restrictions on Common and Equivalence ............................................................ 8-8

8.4 TYPE-STATEMENTS ................................................................................................. 8-9

8.4.1 Type Statements (except CHARACTER) ................................................................. 8-108.4.2 CHARACTER Type-Statement .................................................................................. 8-11

Page 16: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

xiv 47 A2 15UL Rev02

8.5 IMPLICIT STATEMENT .............................................................................................. 8-14

8.6 PARAMETER STATEMENT ....................................................................................... 8-17

8.7 EXTERNAL STATEMENT .......................................................................................... 8-19

8.8 INTRINSIC STATEMENT ........................................................................................... 8-21

8.9 SAVE STATEMENT .................................................................................................... 8-23

8.10 NAMELIST STATEMENT ........................................................................................... 8-26

9. Data Statement ..................................................................................................... 9-1

9.1 FORM OF A DATA STATEMENT .............................................................................. 9-1

9.2 DATA STATEMENT RESTRICTIONS ....................................................................... 9-2

9.3 IMPLIED-DO IN A DATA STATEMENT ..................................................................... 9-4

9.4 CHARACTER CONSTANT IN A DATA STATEMENT ............................................... 9-5

9.5 HOLLERITH CONSTANT IN A DATA STATEMENT ................................................. 9-6

10. Assignment Statements ................................................................................... 10-1

10.1 ARITHMETIC ASSIGNMENT STATEMENT .............................................................. 10-1

10.2 LOGICAL ASSIGNMENT STATEMENT .................................................................... 10-4

10.3 STATEMENT LABEL ASSIGNMENT (ASSIGN) STATEMENT ................................ 10-6

10.4 CHARACTER ASSIGNMENT STATEMENT .............................................................. 10-8

Page 17: FORTRAN 77 Reference Manual - Bull

Table of Contents

47 A2 15UL Rev02 xv

11. Control Statements ............................................................................................ 11-1

11.1 UNCONDITIONAL GOTO STATEMENT ................................................................... 11-2

11.2 COMPUTED GOTO STATEMENTS .......................................................................... 11-3

11.3 ASSIGNED GOTO STATEMENT ............................................................................... 11-4

11.4 ARITHMETIC IF STATEMENT ................................................................................... 11-5

11.5 LOGICAL IF STATEMENT ......................................................................................... 11-6

11.6 BLOCK IF STATEMENT ............................................................................................ 11-7

11.6.1 IF-Level ....................................................................................................................... 11-711.6.2 IF-Block ...................................................................................................................... 11-711.6.3 Execution of a Block IF Statement .......................................................................... 11-8

11.7 ELSE IF STATEMENT ................................................................................................ 11-9

11.7.1 ELSE IF-Block ............................................................................................................ 11-911.7.2 Execution of an ELSE IF Statement ........................................................................ 11-9

11.8 ELSE STATEMENT .................................................................................................... 11-10

11.8.1 ELSE-Block ................................................................................................................ 11-1011.8.2 Execution of an ELSE Statement ............................................................................. 11-10

11.9 END IF STATEMENT ................................................................................................. 11-11

11.10 DO STATEMENT ........................................................................................................ 11-12

11.10.1 Range of a DO-Loop ................................................................................................. 11-1211.10.2 Active and Inactive DO-Loops ................................................................................. 11-1311.10.3 Executing a DO Statement ....................................................................................... 11-1311.10.4 Loop Control Processing ......................................................................................... 11-1411.10.5 Execution of the Range ............................................................................................ 11-1411.10.6 Terminal Statement Execution ................................................................................. 11-1411.10.7 Incrementation Processing ...................................................................................... 11-1511.10.8 Transfer into the Range of a DO-Loop .................................................................... 11-16

11.11 CONTINUE STATEMENT .......................................................................................... 11-17

Page 18: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

xvi 47 A2 15UL Rev02

11.12 STOP STATEMENT ................................................................................................... 11-18

11.13 PAUSE STATEMENT ................................................................................................. 11-19

11.14 END STATEMENT ...................................................................................................... 11-20

12. INPUT/OUTPUT Statements ............................................................................ 12-1

12.1 RECORDS .................................................................................................................. 12-2

12.1.1 Formatted Record ..................................................................................................... 12-212.1.2 Unformatted Record ................................................................................................. 12-212.1.3 Endfile Record ........................................................................................................... 12-3

12.2 FILES .......................................................................................................................... 12-4

12.2.1 File Existence ............................................................................................................ 12-412.2.2 File Properties ........................................................................................................... 12-412.2.3 File Position ............................................................................................................... 12-712.2.4 File Access ................................................................................................................. 12-712.2.4.1 Sequential Access....................................................................................................... 12-812.2.4.2 Direct Access .............................................................................................................. 12-9

12.2.5 Internal Files .............................................................................................................. 12-1012.2.5.1 Internal File Properties ................................................................................................ 12-1012.2.5.2 Internal File Restrictions.............................................................................................. 12-11

12.3 UNITS.......................................................................................................................... 12-13

12.3.1 Unit Existence ............................................................................................................ 12-1312.3.2 Connection of a Unit ................................................................................................. 12-1312.3.3 Unit Specifier and Identifier ..................................................................................... 12-17

12.4 FORMAT SPECIFIER AND IDENTIFIER ................................................................... 12-18

12.5 INPUT/OUTPUT RECORD, RECORD LENGTH, BYTE SPECIFIERS ..................... 12-20

12.5.1 Record Specifier ........................................................................................................ 12-2012.5.2 Byte Specifier ............................................................................................................ 12-2012.5.3 Processed Length Specifier ..................................................................................... 12-21

12.6 ERROR AND END-OF-FILE CONDITIONS ............................................................... 12-23

Page 19: FORTRAN 77 Reference Manual - Bull

Table of Contents

47 A2 15UL Rev02 xvii

12.7 INPUT/OUTPUT STATUS, ERROR, AND END-OF-FILE SPECIFIERS ................... 12-24

12.7.1 Error Specifier ........................................................................................................... 12-2412.7.2 End-of-File Specifier ................................................................................................. 12-25

12.8 READ, WRITE, PRINT AND PUNCH STATEMENTS ................................................ 12-26

12.8.1 Control Information List ........................................................................................... 12-2612.8.2 Input/Output_List ...................................................................................................... 12-2812.8.2.1 INPUT List Items ......................................................................................................... 12-2912.8.2.2 OUTPUT List Items..................................................................................................... 12-2912.8.2.3 Implied-DO List ........................................................................................................... 12-29

12.9 EXECUTION OF A DATA TRANSFER INPUT/OUTPUT STATEMENT ................... 12-30

12.9.1 Direction of Data Transfer ........................................................................................ 12-3012.9.2 Identifying a Unit ....................................................................................................... 12-3012.9.3 Establishing a Format ............................................................................................... 12-3112.9.4 File Position Prior to Data Transfer ......................................................................... 12-3112.9.4.1 Sequential Access....................................................................................................... 12-3112.9.4.2 Direct Access .............................................................................................................. 12-31

12.9.5 DATA TRANSFER ...................................................................................................... 12-3212.9.5.1 Unformatted Data Transfer ......................................................................................... 12-3212.9.5.2 Formatted Data Transfer............................................................................................. 12-33

12.9.6 File Position After Data Transfer ............................................................................. 12-3512.9.7 Input/Output Status Specifier Definition ................................................................. 12-35

12.10 AUXILIARY INPUT/OUTPUT STATEMENTS ............................................................ 12-36

12.10.1 OPEN Statement ........................................................................................................ 12-3612.10.1.1 Open of a Connected Unit........................................................................................... 12-46

12.10.2 CLOSE Statement ..................................................................................................... 12-4912.10.2.1 Implicit Close at Termination of Execution.................................................................. 12-50

12.10.3 INQUIRE Statement ................................................................................................... 12-5012.10.3.1 Inquire by File .............................................................................................................. 12-5112.10.3.2 Inquire by Unit ............................................................................................................. 12-5112.10.3.3 Inquiry Specifiers......................................................................................................... 12-52

12.10.4 File Positioning Statements ..................................................................................... 12-5812.10.4.1 Backspace Statement ................................................................................................. 12-5912.10.4.2 Endfile Statement ........................................................................................................ 12-5912.10.4.3 Rewind Statement ....................................................................................................... 12-59

12.11 RESTRICTIONS ON FUNCTION REFERENCES AND LIST ITEMS ........................ 12-60

12.12 RESTRICTION ON INPUT/OUTPUT STATEMENTS ................................................ 12-60

Page 20: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

xviii 47 A2 15UL Rev02

13. Format Specification ......................................................................................... 13-1

13.1 FORMAT SPECIFICATION METHODS ..................................................................... 13-1

13.1.1 FORMAT Statement .................................................................................................. 13-113.1.2 Character Format Specification ............................................................................... 13-2

13.2 FORM OF A FORMAT SPECIFICATION ................................................................... 13-3

13.2.1 Edit Descriptors ......................................................................................................... 13-4

13.3 INTERACTION BETWEEN INPUT/OUTPUT LIST AND FORMAT ........................... 13-6

13.3.1 Correspondence Between Edit Descriptors and Item Types ................................ 13-913.3.2 Quantity Replacements ............................................................................................ 13-10

13.4 POSITIONING BY FORMAT CONTROL ................................................................... 13-13

13.4.1 Formats_without_Length_Specification ................................................................. 13-1313.4.2 The Comma Separator in Input mode ..................................................................... 13-1413.4.3 Length of Input Record ............................................................................................. 13-14

13.5 EDITING...................................................................................................................... 13-15

13.5.1 Apostrophe Editing ................................................................................................... 13-1513.5.2 H Editing ..................................................................................................................... 13-1513.5.3 Positional Editing ...................................................................................................... 13-1613.5.3.1 T, TL, and TR Editing .................................................................................................. 13-1613.5.3.2 X Editing ...................................................................................................................... 13-16

13.5.4 Slash Editing .............................................................................................................. 13-1713.5.5 Colon Editing ............................................................................................................. 13-1713.5.6 S, SP, and SS Editing ................................................................................................ 13-1913.5.7 P Editing ..................................................................................................................... 13-1913.5.8 BN and BZ Editing ..................................................................................................... 13-2013.5.9 Numeric Editing ......................................................................................................... 13-2113.5.9.1 Integer Editing ............................................................................................................. 13-2113.5.9.2 Real, Double Precision, and Quadruple Precision Editing .......................................... 13-22

13.5.10 L Editing ..................................................................................................................... 13-2813.5.11 A Editing ..................................................................................................................... 13-2813.5.12 R Editing ..................................................................................................................... 13-2913.5.13 Z Editing ..................................................................................................................... 13-30

13.6 LIST-DIRECTED FORMATTING ................................................................................ 13-32

13.6.1 List-Directed Input .................................................................................................... 13-3213.6.2 List-Directed Output ................................................................................................. 13-35

Page 21: FORTRAN 77 Reference Manual - Bull

Table of Contents

47 A2 15UL Rev02 xix

13.7 NAMELIST EDITING .................................................................................................. 13-37

14. Main Program ....................................................................................................... 14-1

14.1 PROGRAM STATEMENT .......................................................................................... 14-2

14.2 MAIN PROGRAM RESTRICTIONS ........................................................................... 14-3

15. Functions and Subroutines ............................................................................ 15-1

15.1 CATEGORIES OF FUNCTIONS AND SUBROUTINES ............................................ 15-1

15.1.1 Procedures ................................................................................................................. 15-115.1.2 External Functions .................................................................................................... 15-215.1.3 Subroutines ............................................................................................................... 15-215.1.4 Dummy Procedure .................................................................................................... 15-2

15.2 REFERENCING A FUNCTION ................................................................................... 15-3

15.2.1 Form of a Function Reference ................................................................................. 15-415.2.2 Execution of a Function Reference ......................................................................... 15-4

15.3 INTRINSIC FUNCTIONS ............................................................................................ 15-5

15.3.1 Specific Names and Generic Names ....................................................................... 15-515.3.2 Referencing an Intrinsic Function ........................................................................... 15-615.3.3 Intrinsic Function Restrictions ................................................................................ 15-7

15.4 STATEMENT FUNCTION........................................................................................... 15-8

15.4.1 Form of a Statement Function Statement ............................................................... 15-815.4.2 Referencing a Statement Function .......................................................................... 15-1015.4.3 Statement Function Restrictions ............................................................................. 15-11

15.5 EXTERNAL FUNCTIONS ........................................................................................... 15-12

15.5.1 Function Subprogram and FUNCTION Statement ................................................. 15-1215.5.2 Referencing an External Function ........................................................................... 15-1315.5.2.1 Execution of an External Function Reference............................................................. 15-1315.5.2.2 Actual Arguments for an External Function................................................................. 15-14

15.5.3 Function Subprogram Restrictions ......................................................................... 15-15

Page 22: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

xx 47 A2 15UL Rev02

15.6 SUBROUTINES .......................................................................................................... 15-17

15.6.1 Subroutine Subprogram and SUBROUTINE Statement ........................................ 15-1715.6.2 Subroutine Reference ............................................................................................... 15-1815.6.2.1 Form of a Call Statement ............................................................................................ 15-1815.6.2.2 Execution of a Call Statement..................................................................................... 15-1815.6.2.3 Actual Arguments for a Subroutine ............................................................................. 15-19

15.6.3 Subroutine Subprogram Restrictions ..................................................................... 15-19

15.7 ENTRY STATEMENT ................................................................................................. 15-20

15.7.1 Form of an ENTRY Statement .................................................................................. 15-2015.7.2 Referencing External Procedure by Entry Name ................................................... 15-2115.7.3 Entry Association ...................................................................................................... 15-2115.7.4 ENTRY Statement Restrictions ................................................................................ 15-22

15.8 RETURN STATEMENT .............................................................................................. 15-23

15.8.1 Form of a RETURN Statement ................................................................................. 15-2315.8.2 Execution of a RETURN Statement ......................................................................... 15-2415.8.3 Alternate Return ........................................................................................................ 15-2415.8.4 Definition Status ........................................................................................................ 15-25

15.9 ARGUMENTS AND COMMON BLOCKS .................................................................. 15-26

15.9.1 Dummy Arguments ................................................................................................... 15-2615.9.2 Actual Arguments ...................................................................................................... 15-2715.9.3 Association of Dummy and Actual Arguments ...................................................... 15-2815.9.3.1 Length of Character Dummy and Actual Arguments .................................................. 15-2915.9.3.2 Variables as Dummy Arguments................................................................................. 15-2915.9.3.3 Arrays as Dummy Arguments ..................................................................................... 15-3015.9.3.4 Procedures as Dummy Arguments ............................................................................. 15-3215.9.3.5 Asterisks as Dummy Arguments................................................................................. 15-3315.9.3.6 Restrictions on Association of Entities ........................................................................ 15-34

15.9.4 Common Blocks ........................................................................................................ 15-35

15.10 TABLE OF INTRINSIC FUNCTIONS ......................................................................... 15-36

15.10.1 Restrictions on Range of Arguments and Results ................................................ 15-68

16. Block Data Subprogram ................................................................................... 16-1

16.1 BLOCK DATA STATEMENT ...................................................................................... 16-1

16.2 BLOCK DATA SUBPROGRAM RESTRICTIONS ..................................................... 16-2

Page 23: FORTRAN 77 Reference Manual - Bull

Table of Contents

47 A2 15UL Rev02 xxi

17. Association and Definition .............................................................................. 17-1

17.1 STORAGE AND ASSOCIATION ................................................................................ 17-1

17.1.1 Storage Sequence ..................................................................................................... 17-117.1.2 Association of Storage Sequences ......................................................................... 17-217.1.3 Association of Entities .............................................................................................. 17-3

17.2 EVENTS THAT CAUSE ENTITIES TO BECOME DEFINED ..................................... 17-5

17.3 EVENTS THAT CAUSE ENTITIES TO BECOME UNDEFINED ................................ 17-6

18. Scope and Classes of Symbolic Names ................................................... 18-1

18.1 SCOPE OF SYMBOLIC NAMES ................................................................................ 18-1

18.1.1 Global Entities ........................................................................................................... 18-218.1.1.1 Classes of Global Entities ........................................................................................... 18-2

18.1.2 Local Entities ............................................................................................................. 18-318.1.2.1 Classes of Local Entities ............................................................................................. 18-3

18.2 CLASSES OF SYMBOLIC NAMES ........................................................................... 18-4

18.2.1 Common block .......................................................................................................... 18-418.2.2 External Function ...................................................................................................... 18-518.2.3 Subroutine ................................................................................................................. 18-618.2.4 Main Program ............................................................................................................ 18-618.2.5 Block Data Subprogram ........................................................................................... 18-618.2.6 Array ........................................................................................................................... 18-718.2.7 Variable ...................................................................................................................... 18-718.2.8 Constant ..................................................................................................................... 18-818.2.9 Statement Function ................................................................................................... 18-818.2.10 Intrinsic Function ...................................................................................................... 18-818.2.11 Dummy Procedure .................................................................................................... 18-9

Page 24: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

xxii 47 A2 15UL Rev02

19. Package Units ....................................................................................................... 19-1

19.1 AUTOMATIC PACKAGING ........................................................................................ 19-2

19.2 CLOSE AUTOMATIC PACKAGE ............................................................................... 19-3

19.3 OPEN AUTOMATIC PACKAGE ................................................................................. 19-3

19.4 MANUAL PACKAGING .............................................................................................. 19-4

19.5 PACKAGE STATEMENT ........................................................................................... 19-4

19.6 EXTROUTINE STATEMENT ...................................................................................... 19-5

19.7 EXTCOMMON STATEMENT ..................................................................................... 19-6

19.8 ENDPACKAGE STAT EMENT .................................................................................... 19-8

20. Compile Time Directives .................................................................................. 20-1

20.1 INCLUDE STATEMENT ............................................................................................. 20-1

20.2 PAGE STATEMENT ................................................................................................... 20-2

20.3 SKIPEND STATEMENT ............................................................................................. 20-2

20.4 ERROR STATEMENT ................................................................................................ 20-2

Page 25: FORTRAN 77 Reference Manual - Bull

Table of Contents

47 A2 15UL Rev02 xxiii

Appendices

A. Collating Sequenc e ............................................................................................ A-1

B. GCOS 1E FORTRAN: Modification s ............................................................ B-1

B.1 FEATURES NO LONGER SUPPORTED................................................................... B-1

B.2 FEATURES SUPPORTED AND FLAGGE D .............................................................. B-4

B.3 FEATURES NOT SUPPORTED BY DPS7 ................................................................ B-7

C. SIRIS 8 FORTRAN Feature s ............................................................................ C-1

C.1 DPS7 FORTRAN 77 FEATURES AND SIRIS 8 FORTRA N ...................................... C-1

C.2 NON-ANSI 77 FORTRAN 77 FEATURE S.................................................................. C-5

D. Values of the Iostat Specifier of INPUT/OUTPUT Statement s ......... D-1

Page 26: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

xxiv 47 A2 15UL Rev02

Illustrations

Figures

3-1 Required Order of Statements and Comment Lines................................................... 3-913-1 Input Examples ........................................................................................................... 13-2513-2 F Output Examples ..................................................................................................... 13-2513-3 G Output Examples..................................................................................................... 13-27

Tables

3-1 FORTRAN Special Characters ................................................................................... 3-25-1 Subscript Value ........................................................................................................... 5-86-1 Type and Interpretation of Result for x 1 + x 2 ............................................................ 6-66-2 Type and Interpretation of Result for x1 ** x2 ............................................................. 6-710-1 Arithmetic Conversion and Assignment of e to v ........................................................ 10-212-1 Preconnection ............................................................................................................. 12-1512-2 Specifiers in the Control Information List .................................................................... 12-2815-1 ntrinsic Functions (1/21).............................................................................................. 15-3715-1 Intrinsic Functions (2/21)............................................................................................. 15-3815-1 Intrinsic Functions (3/21)............................................................................................. 15-3915-1 Intrinsic Functions (4/21)............................................................................................. 15-4015-1 Intrinsic Functions (5/21)............................................................................................. 15-4115-1 Intrinsic Functions (6/21)............................................................................................. 15-4215-1 Intrinsic Functions (7/21)............................................................................................. 15-4315-1 Intrinsic Functions (8/21)............................................................................................. 15-4415-1 Intrinsic Functions (9/21)............................................................................................. 15-4515-1 Intrinsic Functions (10/21)........................................................................................... 15-4615-1 Intrinsic Functions (11/21)........................................................................................... 15-4715-1 Intrinsic Functions (12/21)........................................................................................... 15-4815-1 Intrinsic Functions (13/21)........................................................................................... 15-4915-1 Intrinsic Functions (14/21)........................................................................................... 15-5015-1 Intrinsic Functions (15/21)........................................................................................... 15-5115-1 Intrinsic Functions (16/21)........................................................................................... 15-5215-1 Intrinsic Functions (17/21)........................................................................................... 15-5315-1 Intrinsic Functions (18/21)........................................................................................... 15-5415-1 Intrinsic Functions (19/21)........................................................................................... 15-5515-1 Intrinsic Functions (20/21)........................................................................................... 15-5615-1 Intrinsic Functions (21/21)........................................................................................... 15-57A-1 EBCDIC (DPS 7) Character Set (1/4) ......................................................................... A-2A-1 EBCDIC (DPS 7) Character Set(2/4) .......................................................................... A-3A-1 EBCDIC (DPS 7) Character Set(3/4) .......................................................................... A-4A-1 EBCDIC (DPS 7) Character Set (4/4) ......................................................................... A-5

Page 27: FORTRAN 77 Reference Manual - Bull

47 A2 15UL Rev02 1-1

1. Introduction

1.1 PURPOSE AND NOTES

1.1.1 Before You Begin

As you read this document, you will notice that much of the text is tagged. These tagsmark the beginning and ending of certain text and are as follows:

BEGINNING TAGS ENDING TAGS

! PROCESSOR-DEPENDENT [

text text ].PROCESSOR-DEPENDENT.!

[ NEW ANSI77 [ text text ].NEW ANSI77. ]# OLD ANSI77 [ text text ].OLD ANSI77.#

These markings indicate that the text contains additions or precisions to ANSI 77. Eachsection that contains an addition or precision starts with one of the beginning tags andfinishes with one of the ending tags.

The meanings of these tags are as follows:

! PROCESSOR-DEPENDENT [ ].PROCESSOR-DEPENDENT.!

is a precision. For instance, features defined asprocessor-dependant by ANSI 77 are given a specification.

[ NEW ANSI77 [ ].NEW ANSI77. ]

(new) is a DPS7 FORTRAN 77 extension to ANSI 77which is expected to remain in the next releases.].PROCESSOR-DEPENDENT.!

# OLD ANSI77 [ ].OLD ANSI77.#

(old) is a DPS7 FORTRAN 77 extension to ANSI 77 whichhas been made for compatibility with GCOS 1EFORTRAN, or SIRIS 8 FORTRAN, but is expected todisappear in a future release. This feature must not beused to program new applications. Use of such a featuremay result in a warning # by the compiler. ].OLDANSI77.#

Page 28: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

1-2 47 A2 15UL Rev02

1.1.2 Legend for Tables Containing Additions or Precisions

When a table contains text that has an addition or precision in it, the text is highlighted,as follows:

! PROCESSOR-DEPENDENT [ . . . ] .PROCESSOR-DEPEND E

[ NEW ANSI77 [ ... ] .NEW ANSI77. ]

# OLD ANSI77 [ ... ] .OLD ANSI77.#

W hen the text w ithin a table is highlighted in th is w ay it is a prec ision.

W hen the text w ith in a table is h ighlighted in th is w ay it is a new D P S7 FO R TR A N 77 extension to A N S I 77.

W hen the text w ithin a table is highlighted in th is w ay it is an old D P S 7 FO R TR A N 77 extension to A N S I 77.

1.1.3 Purpose

! PROCESSOR-DEPENDENT [ This manual specifies the form and interpretation ofprograms expressed in the FORTRAN 77 language, for the BULL DPS7 under theGCOS operating system. This language is abbreviated as DPS7 FORTRAN 77throughout this manual.

DPS7 FORTRAN 77 is a superset of the ANSI/ISO FORTRAN 77 standard (ANSI X3.9 -1978), abbreviated as ANSI 77 throughout this manual. Superset means that there arefeatures in DPS7 FORTRAN 77 that are not in ANSI 77. Some features that areprohibited by ANSI 77 are allowed by DPS7 FORTRAN 77.

This superset includes the features of FORTRAN described by the Reference Manual forthe BULL Series 60 (Level 64) GCOS FORTRAN, Release 1E, except for a fewmodifications listed in Appendix B. This language is generally abbreviated as GCOS 1EFORTRAN throughout this manual. ].PROCESSOR-DEPENDENT.!

# OLD ANSI77 [ In a few cases, the implementation of DPS7 FORTRAN 77 results in #different semantics than for GCOS 1E FORTRAN. To obtain GCOS 1E FORTRANsemantics with DPS7 FORTRAN 77, you may use the LEVEL=GCOS1E option of theFOR77 JCL statement. The effect of this option is documented in Appendix B. ].OLDANSI77.#

Page 29: FORTRAN 77 Reference Manual - Bull

Introduction

47 A2 15UL Rev02 1-3

! PROCESSOR-DEPENDENT [ The DPS7 FORTRAN 77 superset also includesfeatures of the FORTRAN described by the Operations Manual for the BULL Series10070, and Series IRIS 80 FORTRAN IV under SIRIS 7/SIRIS 8. This language isabbreviated as SIRIS 8 FORTRAN throughout this manual. In several cases, SIRIS 8FORTRAN features have been included, after syntactic modifications, to achievehomogeneity with ANSI 77; however, the same semantics apply. These cases are listedin Appendix C. ].PROCESSOR-DEPENDENT.!

# OLD ANSI77 [ There are cases where the syntax or semantics of SIRIS 8 FORTRAN# conflict with the ANSI 77 standard. Some of the most useful of these features may beused with DPS7 FORTRAN by specifying the LEVEL=SIRIS8 parameter in the FOR77JCL statement (refer to the FORTRAN 77 User Guide). Such features are surroundedwith a rectangle in this manual, with the mention LEVEL=SIRIS8. This option isdocumented in Appendix C. ].OLD ANSI77.#

! PROCESSOR-DEPENDENT [ Text that contains additions or precisions to ANSI 77 ismarked. Each section that contains additions or precsions begins with a horizontal line,indicating the type of addition or precision is beginning, and ends with a horizontal line,indicating the type of addition or precision is ending. The horizontal lines are as follows:

Appendix D gives the values of the IOSTAT specifier of input/output statements.

Page 30: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

1-4 47 A2 15UL Rev02

1.2 SCOPE

1.2.1 Inclusions

! PROCESSOR-DEPENDENT [ This manual specifies:

1. The form of a program written in the FORTRAN language

2. Rules for interpreting the meaning of such a program and its data

3. The form of writing input data to be processed by such a program operating on dataprocessing systems

4. The form of the output data resulting from the use of such a program on dataprocessing systems.

1.2.2 Exclusions

This manual does not specify:

1. The mechanism by which programs are transformed for use on DPS7 dataprocessing systems

2. The method of transcription of programs or their input or output data to or fromDPS7 data processing medium

3. The operations required for setup and control of the use of programs on DPS7 dataprocessing systems

4. The results when the rules of this standard fail to establish an interpretation.

5. The size or complexity of a program and its data that will exceed the capacity of aDPS7 processing system or the capability of a particular DPS7

6. The range or precision of numeric quantities and the method of rounding ofnumeric results

7. The original properties of input/output records, files, and units

8. The physical properties and implementation of storage

This information is given in the DPS7 FORTRAN 77 User's Guide. ].PROCESSOR-DEPENDENT.!

Page 31: FORTRAN 77 Reference Manual - Bull

Introduction

47 A2 15UL Rev02 1-5

1.3 NOTATION AND TERMINOLOGY USED IN THIS MANUAL

1.3.1 Terminology

The combination of GCOS, DPS7, and the FORTRAN 77 compiler by which programsare transformed for use on the DPS7 system is called a processor in this manual.

! PROCESSOR-DEPENDENT [ In this manual 'must' is to be interpreted as arequirement; conversely, 'must not' is to be interpreted as a prohibition. ].PROCESSOR-DEPENDENT.!

1.3.2 Notation

In describing the form of FORTRAN statements or constructs, the followingmetalanguage conventions and symbols are used:

1. Special characters from the FORTRAN character set, uppercase letters, anduppercase words are to be written as shown, except where otherwise noted.

2. Lowercase letters and lowercase words indicate general entities for which specificentities must be substituted in actual statements. Once a given lowercase letter orword is used in a syntactic specification to represent an entity, all subsequentoccurrences of that letter or word represent the same entity until that letter or wordis used in a subsequent syntactic specification to represent a different entity.

3. Brackets, [ ], are used to indicate optional items.

4. An ellipsis, ..., indicates that the preceding optional items may appear one or moretimes in succession.

5. Blanks are used to improve readability, but unless otherwise noted have nosignificance.

6. Words or groups of words that have special significance are underlined where theirmeaning is described. Titles and the metalanguage symbols described in 1.3.2 arealso underlined.

Page 32: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

1-6 47 A2 15UL Rev02

An example illustrates the metalanguage. Given a description of the form of a statementas:

CALL sub [( [a [,a]...] )]

the following forms are allowed:

CALL subCALL sub ()CALL sub (a)CALL sub (a, a)CALL sub (a, a, a)etc

When an actual statement is written, specific entities are substituted for sub and each a;for example:

CALL ABCD (X,1.0)

Page 33: FORTRAN 77 Reference Manual - Bull

47 A2 15UL Rev02 2-1

2. FORTRAN Terms and Concepts

This section introduces basic terminology and concepts, some of which are clarifiedfurther in later sections. Many terms and concepts of more specialized meaning are alsointroduced in later sections.

2.1 SEQUENCE

A sequence is a set ordered by a one-to-one correspondence with the numbers 1, 2,through n. The number of elements in the sequence is n. A sequence may be empty, inwhich case it contains no elements.

The elements of a sequence are the first element, second element, etc. The nthelement, where n is the number of elements in the sequence, is called the last element.An empty sequence has no first or last element.

Page 34: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

2-2 47 A2 15UL Rev02

2.2 SYNTACTIC ITEMS

Letters, digits, and special characters of the FORTRAN character set (3.1) are used toform the syntactic items of the FORTRAN language. The basic syntactic items of theFORTRAN language are constants, symbolic names, statement labels, keywords,operators, and special characters.

The form of a constant is described in Section 4.

[ NEW ANSI77 [ A symbolic name takes the form of a sequence of one to eightcharacters made up of letters, digits or underscores, the first of which must be a letter.].NEW ANSI77. ]

Classification of symbolic names and restrictions on their use are described in Section18.

A Statement_label is a sequence of one to five digits, one of which must be nonzero andis used to identify a statement (3.4)

keyword

A keyword is a specified sequence of letters. The keywords that are significant in theFORTRAN language are described in Sections 7 through 16. In many instances, akeyword or a portion of a keyword also meets the requirements for a symbolic name.Whether a particular sequence of characters identifies a keyword or a symbolic name isimplied by context. There is no sequence of characters that is reserved in all contexts inFORTRAN.

The set of special characters is described in 3.1.4. A special character may be anoperator or part of a constant or have some other special meaning. The interpretation isimplied by context.

Page 35: FORTRAN 77 Reference Manual - Bull

FORTRAN Terms and Concepts

47 A2 15UL Rev02 2-3

2.3 STATEMENTS, COMMENTS, AND LINES

A FORTRAN statement is a sequence of syntactic items, as described in Sections 7through 16. Except for assignment and statement function statements, each statementbegins with a keyword. In this manual, the keyword or keywords that begin the statementare used to identify that statement. For example, a DATA statement begins with thekeyword DATA.

A statement is written in one or more lines, the first of which is called an initial_line(3.2.2); succeeding lines, if any, are called continuation lines (3.2.3).

There is also a line called a comment_line (3.2.1), which is not part of any statement andis intended to provide documentation.

2.3.1 Classes of Statements

Each statement is classified as executable or nonexecutable (Section 7). Executablestatements specify actions. Nonexecutable statements describe the characteristics,arrangement, and initial values of data, contain editing information, specify statementfunctions, classify program units, and specify entry points within subprograms.

Page 36: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

2-4 47 A2 15UL Rev02

2.4 PROGRAM UNITS AND PROCEDURES

main program

A program_unit consists of a sequence of statements and optional comment lines. Aprogram unit is either a main program or a subprogram.

A main_program is a program unit that does not have a FUNCTION, SUBROUTINE, orBLOCK DATA statement as its first statement; it may have a PROGRAM statement asits first statement.

A subprogram is a program unit that has a FUNCTION, SUBROUTINE, or BLOCKDATA statement as its first statement. A subprogram whose first statement is aFUNCTION statement is called a function_subprogram. A subprogram whose firststatement is a SUBROUTINE statement is called a subroutine subprogram. Functionsubprograms and subroutine subprograms are called procedure_subprograms. Asubprogram whose first statement is a BLOCK DATA statement is called ablock_data_subprogram.

[ NEW ANSI77 [ One or several program units, with at most one main program andwithout any block data subprograms, may be grouped into a package unit (Section 19).].NEW ANSI77. ]

2.4.1 Procedures

Subroutines, (15.6), external functions, (15.5), statement functions (15.4), and theintrinsic functions (15.3) are called procedures. Subroutines and external functions arecalled external_procedures. Function subprograms and subroutine subprograms mayspecify one or more external functions, and subroutines, respectively (15.7). Externalprocedures may also be specified by means other than FORTRAN subprograms.

2.4.2 Executable Program

executable program

An executable_program is a collection of program units that consists of exactly one mainprogram and any number, including none, of subprograms and external procedures.

Page 37: FORTRAN 77 Reference Manual - Bull

FORTRAN Terms and Concepts

47 A2 15UL Rev02 2-5

2.5 VARIABLE

A variable is an entity that has both a name and a type. A variable name is a symbolicname of a datum. Such a datum may be identified, defined (2.11) and referenced (2.12).Note that the usage in this manual of the word 'variable' is more restricted than itsnormal usage, in that it does not include array elements.

The type of a variable is optionally specified by the appearance of the variable name in atype-statement (8.4). If it is not so specified, the type of a variable is implied by the firstletter of the variable name to be integer or real (4.1.2), unless the initial letter typeimplication is changed by the use of an IMPLICIT statement (8.5).

At any given time during the execution of an executable program, a variable is eitherdefined or undefined (2.11).

Page 38: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

2-6 47 A2 15UL Rev02

2.6 ARRAY

An array is a nonempty sequence of data that has a name and a type. The name of anarray is a symbolic name.

2.6.1 Array Elements

Each of the elements of an array is called an array_element. An array name qualified bya subscript is an array element name and identifies a particular element of the array(5.3). Such a datum may be identified, defined (2.11), and referenced (2.12). Thenumber of array elements in an array is specified by an array_declarator (15.1).

An array element has a type. The type of all array elements within an array is the same,and is optionally specified by the appearance of the array name in a type-statement(8.4). If it is not so specified, the type of an array element is implied by the first letter ofthe array name to be integer or real (4.1.2), unless the initial letter type implication ischanged by the use of an IMPLICIT statement (8.5).

At any given time during the execution of an executable program, an array element iseither defined or undefined (2.11).

Page 39: FORTRAN 77 Reference Manual - Bull

FORTRAN Terms and Concepts

47 A2 15UL Rev02 2-7

2.7 SUBSTRING

A character datum is a nonempty sequence of characters. A substring is a contiguousportion of a character datum. The form of a substring name used to identify, define(2.11), or reference (2.12) a substring is described in (5.7.1).

At any given time during the execution of an executable program, a substring is eitherdefined or undefined (2.11).

2.8 DUMMY ARGUMENT

A dummy argument in a procedure is either a symbolic name or an asterisk. A symbolicname dummy argument identifies a variable, array, or procedure that becomesassociated (2.14) with an actual argument of each reference (2.12) to the procedure(15.2, 15.4.2, 15.5.2 and 15.6.2). An asterisk dummy argument indicates that thecorresponding actual argument is an alternate return specifier (15.6.2.3, 15.8.3 and15.9.3.5).

Each dummy argument name that is classified as a variable, array, or dummy proceduremay appear whenever an actual name of the same class (Section 18) and type mayappear, except where explicitly prohibited.

Page 40: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

2-8 47 A2 15UL Rev02

2.9 SCOPE OF SYMBOLIC NAMES AND STATEMENT LABELS

[ NEW ANSI77 [ The scope of a symbolic name (18.1) is an executable program, apackage unit, a program unit, a statement function statement, or an implied-DO list in aDATA statement. ].NEW ANSI77. ]

The name of the main program and the names of block data subprograms have a scopeof an executable program.

[ NEW ANSI77 [ The names of external functions and subroutines that are defined by aprogram unit not contained into a package unit have a scope of an executable program.

The names of external functions and subroutines specified in a FUNCTION,SUBROUTINE or ENTRY statement of a program unit contained into a package unithave a scope of an executable program if they are specified in the PACKAGE orEXTROUTINE statement (19) of the package unit. They have a scope of that packageunit if they are not specified in the PACKAGE or EXTROUTINE statement.

The names of external functions or subroutines specified in a package unit, but notspecified in a FUNCTION, SUBROUTINE or ENTRY statement have a scope of anexecutable program.

The names of common blocks specified in a COMMON statement of a program unit, [NEW ANSI77 [ not contained into a package unit, ].NEW ANSI77. ] have a scope of anexecutable program.

[ NEW ANSI77 [ The names of common blocks specified in a COMMON statement of apackage unit (inside a program unit) have a scope of an executable program if they arealso specified in an EXTCOMMON statement. They have a scope of the package unit ifthey are not also specified in an EXTCOMMON statement.

The names of variables or arrays of a program unit not contained into a package unithave a scope of the program unit. ].NEW ANSI77. ]

The names of constants, statement functions, intrinsic functions and dummy procedureshave a scope of a program unit.

The names of variables that appear as dummy arguments in a statement functionstatement have a scope of that statement.

The names of variables that appear as the DO-variable of an implied-DO in a DATAstatement have a scope of the implied-DO list. Statement labels labelling a statement ofa program unit have a scope of that program unit.

Page 41: FORTRAN 77 Reference Manual - Bull

FORTRAN Terms and Concepts

47 A2 15UL Rev02 2-9

2.10 LIST

A list is a nonempty sequence (2.1) of syntactic entities separated by commas. Theentities in the list are called list_items.

2.11 DEFINITION STATUS

At any given time during the execution of an executable program, the definition_status ofeach variable, array element, or substring is either defined or undefined (Section 17).

A defined entity has a value. The value of a defined entity does not change until theentity becomes undefined or is redefined with a different value.

If a variable, array element, or substring is undefined, it does not have a predictablevalue.

A previously defined variable or array element may become undefined. Subsequentdefinition of a defined variable or array element is permitted, except where it is explicitlyprohibited.

A character variable, character array element, or character substring is defined if everysubstring of length one of the entity is defined. Note that if a string is defined, everysubstring of the string is defined, and if any substring of the string is undefined, the stringis undefined. Defining any substring does not cause any other string or substring tobecome undefined.

An entity is initially_defined if it is assigned a value in a DATA statement (Section 9).Initially defined entities are in the defined state at the beginning of execution of anexecutable program. All variables and array elements not initially defined, or associated(2.14) with an initially defined entity, are undefined at the beginning of execution of anexecutable program.

An entity must be defined at the time a reference to it is executed.

Page 42: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

2-10 47 A2 15UL Rev02

2.12 REFERENCE

A variable, array element, or substring reference is the appearance of a variable, arrayelement, or substring name, respectively, in a statement in a context requiring the valueof that entity to be used during the execution of the executable program. When areference to an entity is executed, its current value is available. In this manual, the act ofdefining an entity is not considered a reference to that entity.

A procedure reference is the appearance of a procedure name in a statement in acontext that requires the actions specified by the procedure to be executed during theexecution of the executable program. When a procedure reference is executed, theprocedure must be available.

Page 43: FORTRAN 77 Reference Manual - Bull

FORTRAN Terms and Concepts

47 A2 15UL Rev02 2-11

2.13 STORAGE

storagenumeric unit

A storage_sequence is a sequence of storage units. A storage_unit is either a numericstorage unit or a character storage unit.

! PROCESSOR-DEPENDENT [ A numeric storage unit is made of four bytes (oneword). ].PROCESSOR-DEPENDENT.!

A character storage unit is made of one byte. A byte is made of eight bits.

An integer, real, or logical datum has one numeric_storage_unit in a storage sequence.A double precision or complex datum has two numeric c storage units in a storagesequence. A character datum has one character storage_unit in a storage sequence foreach character in the datum.

[ NEW ANSI77 [ A quadruple precision or complex double precision datum has fournumeric storage units in a storage sequence. A short integer datum has half a numericstorage unit (two bytes). A short logical datum has one character storage unit. ].NEWANSI77. ]

# OLD ANSI77 [ A Hollerith datum has one character storage unit in a storagesequence for each character in the datum. ].OLD ANSI77.#

If a datum requires more than one storage unit in a storage sequence, those storageunits are consecutive.

The concept of a storage sequence is used to describe relationships that exist amongvariables, array elements, arrays, substrings, and common blocks.

Page 44: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

2-12 47 A2 15UL Rev02

2.14 ASSOCIATION

Association of entities exists if the same datum may be identified by different symbolicnames in the same program unit, or by the same name or a different name in differentprogram units of the same executable program (17.1).

Entities may become associated by the following:

1. Common association (8.3.4)

2. Equivalence association (8.2.2)

3. Argument association (15.9.3)

4. Entry association (15.7.3)

Page 45: FORTRAN 77 Reference Manual - Bull

47 A2 15UL Rev02 3-1

3. Characters, Lines, and ExecutionSequence

3.1 FORTRAN CHARACTER SET

[ NEW ANSI77 [ The FORTRAN character set consists of fifty-two letters, ten digits, andseventeen special characters. ].NEW ANSI77. ]

3.1.1 Letters

A letter is one of the twenty-six uppercase characters in the alphabet:

A B C D E F G H

I J K L M N O P

Q R S T U V W X

Y Z

[ NEW ANSI77 [ or one of the twenty-six lowercase characters:

a b c d e f g h

i j k l m n o p

q r s t u v w x

y z

Lowercase letters are converted to the corresponding uppercase letters, except if theyoccur in character constants.

For instance, the two symbols:

AB ab

are correct and represent the same symbol AB ].NEW ANSI77. ]

Page 46: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

3-2 47 A2 15UL Rev02

3.1.2 Digits

A digit is one of the ten characters:

0 1 2 3 4 5 6 7 8 9

A string of digits is interpreted in the decimal base number system when a numericinterpretation is appropriate.

3.1.3 Alphanumeric Characters

An alphanumeric_character is a letter or a digit.

3.1.4 Special Characters

A special_character is one of the seventeen characters shown in Table 3-1.

Table 3-1. FORTRAN Special Characters

Character Name of character

=+-*/(),.$':_<>;

B lankEqualPlusMinusAster iskSlashLef t ParenthesisRight ParenthesisC o m m aDecimal PointCurrency SymbolApost ropheColonU nderscoreLess ThanG reater ThanSemico lon

Page 47: FORTRAN 77 Reference Manual - Bull

Characters, Lines, and Execution Sequence

47 A2 15UL Rev02 3-3

3.1.5 Collating Sequence and Graphics

The order in which the letters are listed in (3.1.1) specifies the collating sequence for theletters; A is less than Z. The order in which the digits are listed in (3.1.2) specifies thecollating sequence for the digits; 0 is less than 9. The digits and letters must not beintermixed in the collating sequence; all of the digits must precede A or all of the digitsmust follow Z. The character blank is less than the letter A and less than the digit 0. Theorder in which the special characters are listed in (3.1.4) does not imply a collatingsequence.

! PROCESSOR-DEPENDENT [ The collating sequence for all the characters is given inAppendix A. ].PROCESSOR-DEPENDENT.!

Except for the currency symbol, the graphics used for the seventy-nine characters mustbe as given in (3.1.1, 3.1.2 and 3.1.4). However, the style of any graphic is not specified.

3.1.6 Blank Character

With the exception of the uses specified (3.2.2, 3.2.3, 3.3, 4.8, 4.8.1, 13.5.1 and 13.5.2),a blank character within a program unit has no meaning and may be used to improve theappearance of the program unit, subject to the restriction on the number of consecutivecontinuation lines (3.3).

Page 48: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

3-4 47 A2 15UL Rev02

3.2 LINES

[ NEW ANSI77 [ A line in a program unit is a sequence of 7 to 255 (instead of 72according to ANSI/ISO) characters. ].NEW ANSI77. ]

All characters must be from the FORTRAN character set, except as described in (3.2.1,4.8, 12.2.2, and 13.2.1).

The character positions in a line are called columns and are numbered consecutively 1,2, through [ NEW ANSI77 [ 255. ].NEW ANSI77. ] The number indicates thesequential position of a character in the line, beginning at the left and proceeding to theright. Lines are ordered by the sequence in which they are presented to the processor.Thus, a program unit consists of a totally ordered set of characters.

3.2.1 Comment Line

A comment_line is any line that contains a C or an asterisk in column 1, or contains onlyblank characters in columns 1 through [ NEW ANSI77 [ 255. ].NEW ANSI77. ] Acomment line that contains a C or an asterisk in column 1 may contain any charactercapable of representation in the processor in columns 2 through [ NEW ANSI77 [ 255.].NEW ANSI77. ]

A comment line does not affect the executable program in any way and may be used toprovide documentation.

Comment lines may appear anywhere in the program unit. Comment lines may precedethe initial line of the first statement of any program unit. Comment lines may appearbetween an initial line and its first continuation line or between two continuation lines.

3.2.2 Initial Line

An initial_line is any line that is not a comment line and contains the character blank orthe digit 0 in column 6. Columns 1 through 5 may contain a statement label (3.4), oreach of the columns 1 through 5 must contain the character blank.

Page 49: FORTRAN 77 Reference Manual - Bull

Characters, Lines, and Execution Sequence

47 A2 15UL Rev02 3-5

3.2.3 Continuation Line

A continuation_line is any line that contains any character of the FORTRAN characterset other than the character blank or the digit 0 in column 6 and contains only blankcharacters in columns 1 through 5.

[ NEW ANSI77 [ A statement must not have more than one hundred continuation linesassuming the initial and continuation lines have 72 characters each. For lines not having72 characters the number of continuation lines is such that the total number ofcharacters of the initial line, plus the characters starting from the seventh of thecontinuation lines, does not exceed 6672. ].NEW ANSI77. ]

Page 50: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

3-6 47 A2 15UL Rev02

3.3 STATEMENTS

The statements of the FORTRAN language are described in Sections 7 through 16 andare used to form program units.

[ NEW ANSI77 [ Each statement is written in columns 7 through 255 of an initial lineand as many as 100 continuation lines. An END statement is written only in columns 7through 255 of an initial line. No other statement in a program unit may have an initialline that appears to be an END statement. ].NEW ANSI77. ]

Note that a statement must contain no more than 6672 characters. Except as part of alogical IF statement (11.5), no statement may begin on a line that contains any part ofthe previous statement.

Blank characters preceding, within, or following a statement do not change theinterpretation of the statement, except when they appear within the datum strings ofcharacter constants or the H or apostrophe edit descriptors in FORMAT statements.However, blank characters do count as characters in the limit of total characters allowedin any one statement.

[ NEW ANSI77 [ More than one statement may appear on a line. The statements areseparated by semicolons (;) and only the first statement of an initial line may be labelled.The last statement of any line may be followed by a semicolon. ].NEW ANSI77. ]

Example 3-1:

! PROCESSOR-DEPENDENT [ The following is an example of how statements can beused.

IF (A.GE.10.E-70) THEN B = C/A ELSE B = 0. ENDIF**C the following statements are equivalent to the above IF (A.GE.10.E-70) THEN; B = C/A; ELSE; B = 0.; ENDIF;C this is a use of continuation lines.C the character * is in column 6 DATA ARRAY /C first element value *1.0,C second element value *2.0,C third element value *3.0 / ].PROCESSOR-DEPENDENT.!

Page 51: FORTRAN 77 Reference Manual - Bull

Characters, Lines, and Execution Sequence

47 A2 15UL Rev02 3-7

3.4 STATEMENT LABELS

Statement labels provide a means of referring to individual statements. Any statementmay be labelled, but only labelled executable statements and FORMAT statements maybe referred to by the use of statement labels. The form of a statement label is asequence of one to five digits, one of which must be nonzero. The statement label maybe placed anywhere in columns 1 through 5 of the initial line of the statement. The samestatement label must not be given to more than one statement in a program unit. Blanksand leading zeros are not significant in distinguishing between statement labels.

Page 52: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

3-8 47 A2 15UL Rev02

3.5 ORDER OF STATEMENTS AND LINES

A PROGRAM statement may appear only as the first statement of a main program. Thefirst statement of a subprogram must be either a FUNCTION, SUBROUTINE, or BLOCKDATA statement.

[ NEW ANSI77 [ Within a program unit that permits the statements:

1. FORMAT statements may appear anywhere;

2. All specification statements must precede all statement function statements, andexecutable statements;

3. All statement function statements must precede all executable statements;

4. DATA statements may appear anywhere after the implicit statements; and ].NEWANSI77. ]

5. ENTRY statements may appear anywhere except between a block IF statementand its corresponding END IF statement, or between a DO statement and theterminal statement of its DO-loop.

Within the specification statements of a program unit, IMPLICIT statements mustprecede all other specification statements except PARAMETER statements. Anyspecification statement that specifies the type of a symbolic name of a constant mustprecede the PARAMETER statement that defines that particular symbolic name of aconstant; the PARAMETER statement must precede all other statements containing thesymbolic names of constants that are defined in the PARAMETER statement.

Page 53: FORTRAN 77 Reference Manual - Bull

Characters, Lines, and Execution Sequence

47 A2 15UL Rev02 3-9

The last line of a program unit must be an END statement.

P A R A M E TE RS tatem ents

IM P LIC ITS tatem ents

O ther S pec ificationS tatem ents

C om m entLines

PROGRAM, FUNCTION, SUBROUTINE, o r BLOCK DATA S ta tement

D A T AStatements

StatementFunct ion

Statements

Executab leStatements

END Sta tement

FO R M A Tand

E N TR YS tatem ents

Figure 3-1. Required Order of Statements and Comment Lines

Figure 3-1 is a diagram of the required order of statements and comment lines for aprogram unit. Vertical lines delineate varieties of statements that may be interspersed.For example, FORMAT statements may be interspersed with statement functionstatements and executable statements. Horizontal lines delineate varieties of statementsthat must not be interspersed. For example, statement function statements must not beinterspersed with executable statements. Note that an END statement is also anexecutable statement and must appear only as the last statement of a program unit.

Page 54: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

3-10 47 A2 15UL Rev02

[ NEW ANSI77 [ Program units may be grouped into a package unit (Section 19). ABLOCKDATA subprogram may not be in a package unit. ].NEW ANSI77. ]

Example:

! PROCESSOR-DEPENDENT [ The following is a sample FORTRAN program.

This program checks the accuracy of the single precision sine bycomparing it to the double precision sine (expected to be moreaccurate). This program can be run on several 32 bit computers,and the results compared.

PROGRAM E020 C maximum of relative error: RRF = 0. C number of measures: IMAX = 10000 C interval of measure -2PI, + 2PI. C progression after each measure: STEP = 8.D0 * DACOS(0.D0)/DBLE(IMAX) C starting value of the argument: -2PI X = -4.D0 * DACOS (0.D0) DO 10 I = 1, IMAX C absolute error, computed in double precision. AR = DABS(DSIN(DBLE(X))-DBLE(SIN(X))) C relative error computed, if division is possible C (*in column 6) RR = 0. IF(DABS(DSIN(DBLE(X))).GT.1.D-30) *RR = DABS(DBLE(AR)/DSIN(DBLE(X))) RRF = MAX (RRF,RR)10 X = X + STEP C printing of the largest relative error found. PRINT 20,RRF20 FORMAT (5H RRF=, E14.7) STOP END ].PROCESSOR-DEPENDENT.!

Page 55: FORTRAN 77 Reference Manual - Bull

Characters, Lines, and Execution Sequence

47 A2 15UL Rev02 3-11

3.6 NORMAL EXECUTION SEQUENCE AND TRANSFER OF CONTROL

Normal_execution_sequence is the execution of executable statements in the order inwhich they appear in a program unit. Execution of an executable program begins withthe execution of the first executable statement of the main program. When an externalprocedure specified in a subprogram is referenced, execution begins with the firstexecutable statement that follows the FUNCTION, SUBROUTINE, or ENTRY statementthat specifies the referenced procedure as the name of a procedure.

A transfer_of_control is an alteration of the normal execution sequence. Statements thatmay cause a transfer of control are:

1. GO TO

2. Arithmetic IF

3. RETURN

4. STOP

5. An input/output statement containing an error specifier or end-of-file specifier

6. CALL with an alternate return specifier

7. A logical IF statement containing any of the above forms

8. Block IF and ELSE IF

9. The last statement, if any, of an IF-block or ELSE IF-block

10. DO

11. The terminal statement of a DO-loop

12. END

The effect of these statements on the execution sequence is described in Sections 11,12, and 15.

The normal execution sequence is not affected by the appearance of nonexecutablestatements or comment lines between executable statements. Execution of a functionreference or a CALL statement is not considered a transfer of control in the program unitthat contains the reference, except when control is returned to a statement identified byan alternate return specifier in a CALL statement. Execution of a RETURN or ENDstatement in a referenced procedure, an execution of a transfer of control within areferenced procedure, is not considered a transfer of control in the program unit thatcontains the reference.

In the execution of an executable program, a procedure subprogram must not bereferenced a second time without the prior execution of a RETURN or END statement inthat procedure.

Page 56: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

3-12 47 A2 15UL Rev02

Page 57: FORTRAN 77 Reference Manual - Bull

47 A2 15UL Rev02 4-1

4. Data Types and Constants

4.1 DATA TYPES

[ NEW ANSI77 [The ten types of data are: ].NEW ANSI77. ]

1. Integer

2. Real

3. Double precision

4. Complex

5. Logical

6. Character

[ NEW ANSI77 [7. Short integer

8. Short logical

9. Quadruple precision

10. Complex double precision ].NEW ANSI77. ]

Each type is different and may have a different internal representation. The type mayaffect the interpretation of the operations involving the datum.

4.1.1 Data Type of a Name

The name employed to identify a datum or a function also identifies its data type. Asymbolic name representing a constant, variable, array, or function (except a genericfunction) must have only one type for each program unit. Once a particular name isidentified with a particular type in a program unit, that type is implied for any usage of thename in the program unit that requires a type.

Page 58: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

4-2 47 A2 15UL Rev02

4.1.2 Type Rules for Data and Procedure Identifiers

A symbolic name that identifies a constant, variable, array, external function, orstatement function may have its type specified in a type-statement (8.4) as integer, real,double precision, complex, logical, character short integer, short logical, quadrupleprecision or complex double precision. In the absence of an explicit declaration in a type-statement, the type is implied by the first letter of the name. A first letter of I, J, K, L, M,or N implies type integer and any other letter implies type real, unless an IMPLICITstatement (8.5) is used to change the default implied type.

The data type of an array element name is the same as the type of its array name.

The data type of a function name specifies the type of the datum supplied by the functionreference in an expression.

A symbolic name that identifies a specific intrinsic function in a program unit has a typeas specified in 15.10. An explicit type-statement is not required; however, it is permitted.A generic function name does not have a predetermined type: the result of a genericfunction reference assumes a type that depends on the type of the argument, asspecified in 15.10. If a generic function name appears in a type-statement, such anappearance is not sufficient by itself to remove the generic properties from that function.

In a program unit that contains an external function reference, the type of the function isdetermined in the same manner as for variables and arrays.

The type of an external function is specified implicitly by its name, explicitly in aFUNCTION statement, or explicitly in a type-statement. Note that an IMPLICIT statementwithin a function subprogram may affect the type of the external function specified in thesubprogram.

A symbolic name that identifies a main program, subroutine, common block, or blockdata subprogram has no data type.

4.1.3 Data Type Properties

The mathematical and representation properties for each of the data types are specifiedin the following sections. For real, double precision, quadruple precision and integerdata, the value zero is considered neither positive nor negative.

! PROCESSOR-DEPENDENT [ The value of a signed zero is the same as the value ofan unsigned zero. (For implementation information about data types, refer to the Fortran77 User's Guide.) ].PROCESSOR-DEPENDENT.!

Page 59: FORTRAN 77 Reference Manual - Bull

Data Types and Constants

47 A2 15UL Rev02 4-3

4.2 CONSTANTS

A constant is an arithmetic constant, logical constant, character constant, orhexadecimal constant. [ NEW ANSI77 [ The value of a constant does not change,except for hexadecimal constants whose value is given by the context. Within anexecutable program, all constants that have the same form have the same value, exceptfor hexadecimal constants. ].NEW ANSI77. ]

4.2.1 Data Type of a Constant

The form of the string representing a constant specifies both its value and data type [NEW ANSI77 [ except for hexadecimal constants. ].NEW ANSI77. ]

A PARAMETER statement (8.6) allows a constant to be given a symbolic name. Thesymbolic name of a constant must not be used to form part of another constant.

4.2.2 Blanks in Constants

Blank characters occurring in a constant, except in a character constant, [ NEW ANSI77[ or hexadecimal constant, ].NEW ANSI77. ] have no effect on the value of theconstant.

4.2.3 Arithmetic Constants

[ NEW ANSI77 [ Integer, real, double precision, complex, quadruple precision andcomplex double precision constants are arithmetic constants. ].NEW ANSI77. ]

4.2.3.1 Signs of Constants

An unsigned constant is a constant without a leading sign. A signed constant is aconstant with a leading plus or minus sign. An optionally signed constant is a constantthat may be either signed or unsigned. Integer, real, double precision and quadrupleprecision constants may be optionally signed constants, except where specifiedotherwise.

Page 60: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

4-4 47 A2 15UL Rev02

4.3 INTEGER TYPE

An integer datum is always an exact representation of an integer value. It may assume apositive, negative, or zero value, within the range: ! PROCESSOR-DEPENDENT [2,147,483,648 through +2,147,483,647. ].PROCESSOR-DEPENDENT.! It may assumeonly an integral value. An integer datum has one numeric storage unit in a storagesequence.

4.3.1 Integer Constant

The form of an integer constant is an optional sign followed by a nonempty string ofdigits.

The digit string is interpreted as a decimal number, ! PROCESSOR-DEPENDENT [ andmust be within the range:

0 through 2,147,483,647. ].PROCESSOR-DEPENDENT.!

Example:

The following are examples of INTEGER constants:

0 58 000 0064593

Page 61: FORTRAN 77 Reference Manual - Bull

Data Types and Constants

47 A2 15UL Rev02 4-5

4.4 REAL TYPE

A real datum is a processor approximation to the value of a real number. It may assumea positive negative, or zero value. If not zero, the absolute value of a real datum is in therange 16 ** (-64) through (1 - 16 ** (-6)) * (16 ** 63), or approximately 2 * 10 ** (-78)through 7 * 10 ** 75. Refer also to the examples of DATA statement for these values(9.5). ].PROCESSOR-DEPENDENT.!

A real datum has one numeric storage unit in a storage sequence.

A variation of one unit on the least significant digit of a single precision datum implies arelative variation which is always less than 0.96 E-6. A single precision datum has thusat least 6 exact significant digits (Refer to the Fortran 77 User's Guide).

4.4.1 Basic Real Constant

The form of a basic real constant is an optional sign, an integer part, a decimal point,and a fractional part, in that order. Both the integer part and the fractional part are stringsof digits; either of these parts may be omitted but not both. A basic real constant may bewritten with more digits than a processor will use to approximate the value of theconstant. A basic real constant is interpreted as a decimal number.

4.4.2 Real Exponent

The form of a real exponent is the letter E followed by an optionally signed integerconstant. A real exponent denotes a power of ten.

4.4.3 Real Constant

The forms of a real_constant are:

1. Basic real constant

2. Basic real constant followed by a real exponent

3. Integer constant followed by a real exponent

Page 62: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

4-6 47 A2 15UL Rev02

The value of a real constant that contains a real exponent is the product of the constantthat precedes the E and the power of ten indicated by the integer following the E. Theinteger constant part of form (3) may be written with more digits than a processor will useto approximate the value of the constant.

! PROCESSOR-DEPENDENT [

Example:

The following are examples of REAL constants

.86 3095. 9.6543 0.5

2.0E2 (which means 2.0 x 10 2)

9E-3 (which means 9.0 x 10 -3) ].PROCESSOR-DEPENDENT.!

Page 63: FORTRAN 77 Reference Manual - Bull

Data Types and Constants

47 A2 15UL Rev02 4-7

4.5 DOUBLE PRECISION TYPE

A double precision datum is a processor approximation to the value of a real number. Adouble precision datum may assume a positive, negative, or zero value.

! PROCESSOR-DEPENDENT [ If not zero, the absolute value of a double precisiondatum is in the range 16 ** (-64) through (1 - 16 ** (-14)) * (16 ** 63), or approximately 2* 10 ** (-78) through 7 * 10 ** 75. ].PROCESSOR-DEPENDENT.!

A double precision datum has two consecutive numeric storage units in a storagesequence.

A variation of one unit on the least significant digit of a double precision datum implies arelative variation which is always less than 0.23 E-15. A double precision datum has thusat least 15 exact significant digits (Refer to the Fortran 77 User's Guide).

4.5.1 Double Precision Exponent

The form of a double precision exponent is the letter D followed by an optionally signedinteger constant. A double precision exponent denotes a power of ten. Note that the formand interpretation of a double precision exponent are identical to those of a realexponent, except that the letter D is used instead of the letter E.

4.5.2 Double Precision Constant

The forms of a double_precision_constant are:

1. Basic real constant followed by a double precision exponent

2. Integer constant followed by a double precision exponent

Page 64: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

4-8 47 A2 15UL Rev02

The value of a double precision constant is the product of the constant that precedes theD and the power of ten indicated by the integer following the D. The integer constant partof form (2) may be written with more digits than a processor will use to approximate thevalue of the constant.

! PROCESSOR-DEPENDENT [

Example:

The following are examples of DOUBLE PRECISION constants:

8.0563D0 .987 D0

3.0D6 (which means 3.0 x 10 6 )

5D-2 (which means 5.0 x 10 -2 )

0.123456789 D0 ].PROCESSOR-DEPENDENT.!

Page 65: FORTRAN 77 Reference Manual - Bull

Data Types and Constants

47 A2 15UL Rev02 4-9

4.6 COMPLEX TYPE

A complex datum is a processor approximation to the value of a complex number. Therepresentation of a complex datum is in the form of an ordered pair of real data. The firstof the pair represents the real part of a complex datum and the second represents theimaginary part. Each part has the same degree of approximation as for a real datum. Acomplex datum has two consecutive numeric storage units in a storage sequence; thefirst storage unit is the real part and the second storage unit is the imaginary part.

4.6.1 Complex Constant

The form of a complex constant is a left parenthesis followed by an ordered pair of realor integer constants separated by a comma, and followed by a right parenthesis. Thefirst constant of the pair is the real part of the complex constant and the second is theimaginary part.

! PROCESSOR-DEPENDENT [

Example:

The following are examples of COMPLEX constants:

(23.6,5.43) is equivalent to 23.6 + 5.43i(88.32,-0.0) is equivalent to 88.32 - 0.0i(-9.3E2,.003E-2) is equivalent to -930.0 + 0.00003i

where i is the square root of -1. ].PROCESSOR-DEPENDENT.!

Page 66: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

4-10 47 A2 15UL Rev02

4.7 LOGICAL TYPE

A logical datum may assume only the values true or false. A logical datum has onenumeric storage unit in a storage sequence.

4.7.1 Logical Constant

The forms and values of a logical_constant are:

Form | Value .TRUE. | true .FALSE. | false

Page 67: FORTRAN 77 Reference Manual - Bull

Data Types and Constants

47 A2 15UL Rev02 4-11

4.8 CHARACTER TYPE

A character datum is a string of characters. The string may consist of any characterscapable of representation in the processor. The blank character is valid and significant ina character datum. The length of a character datum is the number of characters in thestring. A character datum has one character storage unit in a storage sequence for eachcharacter in the string.

Each character in the string has a character position that is numbered consecutively 1, 2,3, etc. The number indicates the sequential position of a character in the string,beginning at the left and proceeding to the right.

4.8.1 Character Constant

The form of a character constant is an apostrophe followed by a nonempty string ofcharacters followed by an apostrophe. The string may consist of any characters capableof representation in the processor. Note that the delimiting apostrophes are not part ofthe datum represented by the constant. An apostrophe within the datum string isrepresented by two consecutive apostrophes with no intervening blanks. In a characterconstant, blanks embedded between the delimiting apostrophes are significant.

The length of a character constant is the number of characters between the delimitingapostrophes, except that each pair of consecutive apostrophes counts as a singlecharacter. The delimiting apostrophes are not counted. The length of a characterconstant must be greater than zero.

! PROCESSOR-DEPENDENT [

Example:

The following are examples of CHARACTER constants:

'FORTRAN PROGRAM' (15 characters)'DON''T FORGET APOSTROPHES' (24 characters) ].PROCESSOR-DEPENDENT.!

Page 68: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

4-12 47 A2 15UL Rev02

4.9 SHORT INTEGER TYPE

A short integer datum is always an exact representation of an integer value. [ NEWANSI77 [ It may assume a positive, negative, or zero value, within the range -32,768through +32,767.

Note that an integer constant is always of integer type, not short integer type.

Each time the context implies that the integer constant will be used as a short integer, animplicit conversion occurs.

In case the use is external to the program unit and so is unknown to the program unit, aswhen passing a short integer datum as an actual argument, the HFIX intrinsic functionmust be used, or a symbolic constant must be used.

Example:

PROGRAM P INTEGER * 2 HALF PARAMETER (HALF = 1) CALL SUB (HALF, HFIX (2)) END SUBROUTINE SUB (X, Y) INTEGER * 2 X, Y END ].NEW ANSI77. ]

Page 69: FORTRAN 77 Reference Manual - Bull

Data Types and Constants

47 A2 15UL Rev02 4-13

4.10 SHORT LOGICAL TYPE

[ NEW ANSI77 [

A short logical datum may assume only the values true or false. A short logical datumhas one character storage unit in a storage sequence.

Note that a logical constant is always of logical type, not short logical type. Each time thecontext implies that the logical constant will be used as a short logical constant, animplicit conversion occurs.

In case the use is external to the program unit and so is unknown, like when passing ashort logical constant datum as an actual argument, a symbolic constant must be used.].NEW ANSI77. ]

For example:

! PROCESSOR-DEPENDENT [

PROGRAM P LOGICAL * 1 BYTE PARAMETER (BYTE = .TRUE.) CALL SUB (BYTE) END SUBROUTINE SUB (X) LOGICAL * 1 X END ].PROCESSOR-DEPENDENT.!

Page 70: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

4-14 47 A2 15UL Rev02

4.11 QUADRUPLE PRECISION TYPE

[ NEW ANSI77 [

A quadruple precision datum is a processor approximation to the value of a real number.A quadruple precision datum may assume a positive, negative, or zero value.

If not zero, the absolute value of a quadruple precision datum is in the range 16 ** (-64)through (1 - 16 ** (-28)) * (16 ** 63), or approximately 2 * 10 ** (-78) through 7 * 10 ** 75.

A quadruple precision datum has four consecutive numeric storage units in a storagesequence. ].NEW ANSI77. ]

A variation of one digit on the least significant digit of a quadruple precision datumimplies a relative variation which is always less than 0.31 E-32. A quadruple precisiondatum has thus at least 32 exact significant digits (Refer to the Fortran 77 User's Guide).

4.11.1 Quadruple Precision Exponent

[ NEW ANSI77 [

The form of a quadruple precision exponent is the letter Q followed by an optionallysigned integer constant. A quadruple precision exponent denotes a power of ten. Notethat the form and interpretation of a quadruple precision exponent are identical to thoseof a real exponent, except that the letter Q is used instead of the letter E. ].NEWANSI77. ]

4.11.2 Quadruple Precision Constant

[ NEW ANSI77 [

The forms of a quadruple precision constant are:

1. Basic real constant followed by a quadruple precision exponent

2. Integer constant followed by a quadruple precision exponent

Page 71: FORTRAN 77 Reference Manual - Bull

Data Types and Constants

47 A2 15UL Rev02 4-15

The value of a quadruple precision constant is the product of the constant that precedesthe Q and the power of ten indicated by the integer following the Q. The integer constantpart of form (2) may be written with more digits than a processor will use to approximatethe value of the constant. ].NEW ANSI77. ]

! PROCESSOR-DEPENDENT [

Example:

The following are examples of QUADRUPLE PRECISION constants:

2.1 Q4 (which means 2.1 x 10 -4)

7Q-1 (which means 7 x 10 -1)

0. 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 Q 0 ].PROCESSOR-DEPENDENT.!

Page 72: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

4-16 47 A2 15UL Rev02

4.12 COMPLEX DOUBLE PRECISION TYPE

[ NEW ANSI77 [

A complex double precision datum is a processor approximation of a value of a complexnumber. The representation of a complex double precision datum is in the form of anordered pair of double precision data. The first of the pair represents the real part of thecomplex double precision datum and the second represents the imaginary part. Eachpart has the same degree of approximation as for a double precision datum. A complexdouble precision datum has four consecutive numeric storage units in a storagesequence; the first two storage units are the real part and the second two storage unitsare the imaginary part.

4.12.1 Complex Double Precision Constant

The form of a complex double precision constant is a left parenthesis followed by anordered pair of double precision constants separated by a comma, and followed by aright parenthesis. The first constant of the pair is the real part of the complex doubleprecision constant and the second is the imaginary part. ].NEW ANSI77. ]

Example:

! PROCESSOR-DEPENDENT [ The following is an example of a COMPLEX DOUBLEPRECISION constant:

(7.46D1, -6.83D-1) is equivalent to 74.6 - 0.683i

Where i is the square root of -1. ].PROCESSOR-DEPENDENT.!

[ NEW ANSI77 [

4.13 HEXADECIMAL CONSTANTS

A hexadecimal constant is a string of from 1 through 510 digits, enclosed in apostrophesand followed by the character Z. The string can include any of the hexadecimal digits 0through 9 and A through F. Blanks within the string are ignored. If the number of digits inthe string is not even, a hexadecimal zero is added to the right of the string. ].NEWANSI77. ]

# OLD ANSI77 [ The following are examples of hexadecimal constants:

'0AF32B'Z'C19EA206BF'Z

Page 73: FORTRAN 77 Reference Manual - Bull

Data Types and Constants

47 A2 15UL Rev02 4-17

Hexadecimal constants may appear wherever a CHARACTER constant may appear, acharacter being equivalent to two hexadecimal digits. Hexadecimal constants may alsobe used in DATA statements to initialize any type of variable, except logical and shortlogical. Hexadecimal constants may also be used in PARAMETER statements to givethe value of a symbolic constant of any type, except logical or short logical.In a PARAMETER statement, the constant expression at the right of the equal sign mustonly be made of the hexadecimal constant, if any, without operators.

The number of digits of a hexadecimal constant must agree with the type of the datumwhich receives the value:eight digits for an integer, real or logical datum, sixteen digits for a double precision orcomplex datum, thirty-two digits for a quadruple precision or complex double precisiondatum, four digits for a short integer datum, 2 * N digits for a character # datum of Ncharacters. ].OLD ANSI77.#

Page 74: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

4-18 47 A2 15UL Rev02

4.14 HOLLERITH CONSTANT

# OLD ANSI77 [

The form of a Hollerith constant is a nonzero, unsigned, integer constant n less than 256followed by the letter H, followed by a string of exactly n contiguous characters. Thestring may consist of any characters capable of representation in the processor. Thestring of n characters is the Hollerith datum.

In a Hollerith constant, blanks are significant only in the n characters following the letterH. Hollerith constants may appear in DATA statements and as actual argument in asubroutine or function reference (15.9.2), except as actual argument of an intrinsicfunction reference. In particular, the IHOL intrinsic function converts a hollerith constantof four characters into the # corresponding integer value.

This provides a means of program conversion from FORTRAN standards where ahollerith constant was allowed in integer assignment statements.

Example:

I = 4HABCD

to be replaced by: I = IHOL (4HABCD)

The following are examples of Hollerith constants:

4HNAME10HVALUE OF X

Their value is the same as that of the following character constants, except their type isdifferent (Hollerith and not character)

'NAME''VALUE OF X' ].OLD ANSI77.#

Page 75: FORTRAN 77 Reference Manual - Bull

47 A2 15UL Rev02 5-1

5. Arrays and Substrings

An array is a nonempty sequence of data. An array element is one member of thesequence of data. An array name is the symbolic name of an array. An array elementname is an array name qualified by a subscript (5.3).

An array name not qualified by a subscript identifies the entire sequence of elements ofthe array in certain forms where such use is permitted (5.6); however, in anEQUIVALENCE statement, an array name not qualified by a subscript identifies the firstelement of the array (8.2.4).

An array element name identifies one element of the sequence. The subscript value(Table 5-1) specifies the element of the array being identified. A different array elementmay be identified by changing the subscript value of the array element name.

An array name is local to a program unit (18.1.2).

A substring is a contiguous portion of a character datum.

Page 76: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

5-2 47 A2 15UL Rev02

5.1 ARRAY DECLARATOR

An array declarator specifies a symbolic name that identifies an array within a programunit and specifies certain properties of the array. Only one array declarator for an arrayname is permitted in a program unit.

5.1.1 Form of an Array Declarator

The form of an array declarator is:

a (d [,d]...)

where: a is the symbolic name of the arrayd is the dimension declarator

The number of dimensions of the array is the number of dimension declarators in thearray declarator. The minimum number of dimensions is one and the maximum is seven.

5.1.1.1 Form of a Dimension Declaration

The form of a dimension declarator is:

[d 1 :] d 2

where: d 1 is the lower dimension boundd 2 is the upper dimension bound

The lower and upper dimension bounds are arithmetic expressions, called dimensionbound expressions, in which all constants, symbolic names of constants, and variablesare of type integer. The upper dimension bound of the last dimension may be an asteriskin assumed-size array declarators (5.1.2). A dimension bound expression must notcontain a function or array element reference. Integer variables may appear in dimensionbound expressions only in adjustable array declarators (5.1.2).

If the symbolic name of a constant or variable that appears in a dimension boundexpression is not of default implied integer type (4.1.2), it must be specified as integer byan IMPLICIT statement or a type-statement prior to its appearance in a dimension boundexpression.

5.1.1.2 Value of Dimension Bounds

The value of either dimension bound may be positive, negative, or zero; however, thevalue of the upper dimension bound must be greater than or equal to the value of thelower dimension bound. If only the upper dimension bound is specified, the value of thelower dimension bound is one. An upper dimension bound of an asterisk is alwaysgreater than or equal to the lower dimension bound.

Page 77: FORTRAN 77 Reference Manual - Bull

Arrays and Substrings

47 A2 15UL Rev02 5-3

5.1.2 Kinds and Occurrences of Array Declarators

Each array declarator is either a constant array declarator, an adjustable arraydeclarator, or an assumed-size array declarator. A constant array declarator is an arraydeclarator in which each of the dimension bound expressions is an integer constantexpression (6.1.3.1). An adjustable array declarator is an array declarator that containsone or more variables. An assumed-size array declarator is a constant array declaratoror an adjustable array declarator, except that the upper dimension bound of the lastdimension is an asterisk.

Each array declarator is either an actual array declarator or a dummy array declarator.

5.1.2.1 Actual Array Declaration

An actual array declarator is an array declarator in which the array name is not a dummyargument. Each actual array declarator must be a constant array declarator. An actualarray declarator is permitted in a DIMENSION statement, type-statement, or COMMONstatement (Section 8).

5.1.2.2 Dummy Array Declaration

A dummy array declarator is an array declarator in which the array name is a dummyargument. A dummy array declarator may be either a constant array declarator, anadjustable array declarator, or an assumed-size array declarator. A dummy arraydeclarator is permitted in a DIMENSION statement or a type-statement but not in aCOMMON statement. A dummy array declarator may appear only in a function orsubroutine subprogram.

Page 78: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

5-4 47 A2 15UL Rev02

5.2 PROPERTIES OF AN ARRAY

The following properties of an array are specified by the array declarator: the number ofdimensions of the array, the size and bounds of each dimension, and therefore thenumber of array elements.

The properties of an array in a program unit are specified by the array declarator for thearray in that program unit.

5.2.1 Data Type of an Array and an Array Element

An array name has a data type (4.1.1). An array element name has the same data typeas the array name.

5.2.2 Dimensions of an Array

The number of dimensions of an array is equal to the number of dimension declaratorsin the array declarator.

The size of a dimension is the value:

d 2 - d 1 + 1

where: d 1 is the value of the lower dimension boundd 2 is the value of the upper dimension bound

NOTE: if the value of the lower dimension bound is one, the size of the dimension is d2.

The size of a dimension whose upper bound is an asterisk is not specified.

The number and size of dimensions in one array declarator may be different from thenumber and size of dimensions in another array declarator that is associated bycommon, equivalence, or argument association.

Page 79: FORTRAN 77 Reference Manual - Bull

Arrays and Substrings

47 A2 15UL Rev02 5-5

5.2.3 Size of an Array

The size of an array is equal to the number of elements in the array. The size of an arrayis equal to the product of the sizes of the dimensions specified by the array declarator forthat array name. The size of an assumed-size dummy array (5.5) is determined asfollows:

1. If the actual argument corresponding to the dummy array is a noncharacter arrayname, the size of the dummy array is the size of the actual argument array.

2. If the actual argument corresponding to the dummy array name is a noncharacterarray element name with a subscript value of r in an array of size x, the size of thedummy array is as follows:

x + 1 - r.

3. If the actual argument is a character array name, character array element name, orcharacter array element substring name and begins at character storage unit t of anarray with c character storage units, then the size of the dummy array is as follows:

INT((c + 1 - t) / ln)

where ln is the length of an element of the dummy array.

If an assumed-size dummy array has n dimensions, the product of the sizes of the first n- 1 dimensions must be less than or equal to the size of the array, as determined by oneof the immediately preceding rules.

5.2.4 Array Element Ordering

The elements of an array are ordered in a sequence (2.1). An array element namecontains a subscript (5.4.1) whose subscript value (5.4.3) determines which element ofthe array is identified by the array element name. The first element of the array has asubscript value of one; the second element has a subscript value of two; the last elementhas a subscript value equal to the size of the array.

Whenever an array name unqualified by a subscript is used to designate the whole array(5.6), the appearance of the array name implies that the number of values to beprocessed is equal to the number of elements in the array and that the elements of thearray are to be taken in sequential order.

5.2.5 Array Storage Sequence

An array has a storage sequence consisting of the storage sequences of the arrayelements in the order determined by the array element ordering. The number of storageunits in an array is x*z, where x is the number of the elements in the array and z is thenumber of storage units for each array element.

Page 80: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

5-6 47 A2 15UL Rev02

5.3 ARRAY ELEMENT NAME

The form of an array element name is:

a (s [,s]...)

where: a is the array name(s [,s]...) is a subscript (5.4.1)s is a subscript expression (5.4.2)

The number of subscript expressions must be equal to the number of dimensions in thearray declarator for the array name.

Page 81: FORTRAN 77 Reference Manual - Bull

Arrays and Substrings

47 A2 15UL Rev02 5-7

5.4 SUBSCRIPT

5.4.1 Form of a Subscript

The form of a subscript is:

(s [,s]...)

where s is a subscript expression.

Note that the term "subscript" includes the parentheses that delimit the list of subscriptexpressions.

5.4.2 Subscript Expression

A subscript expression is an integer expression. A subscript expression may containarray element references and function references. Note that a restriction in theevaluation of expressions (6.6) prohibits certain side effects. In particular, evaluation ofa function must not alter the value of any other subscript expression within the samesubscript.

Within a program unit, the value of each subscript expression must be greater than orequal to the corresponding lower dimension bound in the array declarator for the array.The value of each subscript expression must not exceed the corresponding upperdimension bound declared for the array in the program unit. If the upper dimensionbound is an asterisk, the value of the corresponding subscript expression must be suchthat the subscript value does not exceed the size of the dummy array.

Page 82: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

5-8 47 A2 15UL Rev02

5.4.3 Subscript Value

The subscript value of a subscript is specified in Table 5-1. The subscript valuedetermines which array element is identified by the array element name. Within aprogram unit, the subscript value depends on the values of the subscript expressions inthe subscript and on the dimensions of the array specified in the array declarator for thearray in the program unit. If the subscript value is r, the rth element of the array isidentified.

Table 5-1. Subscript Value

Dimension Declarator Subscr ipt Subscr ipt Valuen

(s ) 11

2

3

(j : k ) 1 1

(j : k ,j : k ) 1 1 2 2 (s , s )

1 21+(s - j ) 1 1 +(s - j )*d 2 2 1

1+(s - j ) 1 1 +(s - j )*d 2 2 1 +(s - j )*d * d 3 3 2 1

n (s ,..., s ) 1 n

.

.

.

.

.

.

.

.

.

.

.

.

(j : k ,j : k , j : k ) 1 1 2 2 3 3 (s , s , s )

1 2 3

(j : k ,..., j : k ) 1 1 n n

1+(s - j ) 1 1

1+(s - j ) 1 1

+(s - j )*d 2 2 1

+(s - j )*d * d 3 3 2 1

+...

+(s - j )*d n n n-1

*d *...*d n-2 1

Page 83: FORTRAN 77 Reference Manual - Bull

Arrays and Substrings

47 A2 15UL Rev02 5-9

Notes for Table 5-1:

1. n is the number of dimensions, 1 <= n <= 7.

2. j i is the value of the lower bound of the ith dimension.

3. k i is the value of the upper bound of the ith dimension.

4. If only the upper bound is specified, then j i = 1.

5. s i is the integer value of the ith subscript expression.

6. d i = k i - j i + 1 is the size of the ith dimension. If the value of the lower bound is 1,then d i = k i.

Note that a subscript of the form (j 1 ,...,j n ) has a subscript value of one and identifiesthe first element of the array. A subscript of the form (k 1 ,...,k n ) identifies the lastelement of the array; its subscript value is equal to the number of elements in the array.

The subscript value and the subscript expression value are not necessarily the same,even for a one-dimensional array. In the example:

DIMENSION A(-1:8),B(10,10)A(2) = B(1,2)

A(2) identifies the fourth element of A, the subscript is (2) with a subscript value of four,and the subscript expression is 2 with a value of two. B(1,2) identifies the eleventhelement of B, the subscript is (1,2) with a subscript value of eleven, and the subscriptexpressions are 1 and 2 with values of one and two.

Page 84: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

5-10 47 A2 15UL Rev02

5.5 DUMMY AND ACTUAL ARRAYS

A dummy array is an array for which the array declarator is a dummy array declarator.An assumed-size dummy array is a dummy array for which the array declarator is anassumed-size array declarator. A dummy array is permitted only in a function orsubroutine subprogram (Section 15).

An actual array is an array for which the array declarator is an actual array declarator.Each array in the main program is an actual array and must have a constant arraydeclarator. A dummy array may be used as an actual argument.

5.5.1 Adjustable Arrays and Adjustable Dimensions

An adjustable array is an array for which the array declarator is an adjustable arraydeclarator. In an adjustable array declarator, those dimension declarators that contain avariable name are called adjustable dimensions.

An adjustable array declarator must be a dummy array declarator. At least one dummyargument list of the subprogram must contain the name of the adjustable array. Avariable name that appears in a dimension bound expression of an array must alsoappear as a name either in every dummy argument list that contains the array name orin a common block in that subprogram.

At the time of execution of a reference to a function or subroutine containing anadjustable array in its dummy argument list, each actual argument that corresponds to adummy argument appearing in a dimension bound expression for the array and eachvariable in common appearing in a dimension bound expression for the array must bedefined with an integer value. The values of those dummy arguments or variables incommon, together with any constants and symbolic names of constants appearing in thedimension bound expression, determine the size of the corresponding adjustabledimension for the execution of the subprogram. The sizes of the adjustable dimensionsand of any constant dimensions appearing in an adjustable array declarator determinethe number of elements in the array and the array element ordering. The execution ofdifferent references to a subprogram or different executions of the same referencedetermine possibly different properties (size of dimensions, dimension bounds, numberof elements, and array element ordering) for each adjustable array in the subprogram.These properties depend on the values of any actual arguments and variables incommon that are referenced in the adjustable dimension expressions in the subprogram.

During the execution of an external procedure in a subprogram containing an adjustablearray, the array properties of dimension size, lower and upper dimension bounds, andarray size (number of elements in the array) do not change. However, the variablesinvolved in an adjustable dimension may be redefined or become undefined duringexecution of the external procedure with no effect on the above-mentioned properties.

Page 85: FORTRAN 77 Reference Manual - Bull

Arrays and Substrings

47 A2 15UL Rev02 5-11

5.6 USE OF ARRAY NAMES

In a program unit, each appearance of an array name must be in an array element nameexcept in the following cases:

1. In a list of dummy arguments

2. In a COMMON statement

3. In a type-statement

4. In an array declarator. Note that although the form of an array declarator may beidentical to that of an array element name, an array declarator is not an arrayelement name.

5. In an EQUIVALENCE statement

6. In a DATA statement

7. In the list of actual arguments in a reference to an external procedure.

8. In the list of an input/output statement if the array is not an assumed-size dummyarray.

9. As a unit identifier for an internal file in an input/output statement if the array is notan assumed-size dummy array.

10. As the format identifier in an input/output statement if the array is not an assumed-size dummy array.

11. In a SAVE statement

Page 86: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

5-12 47 A2 15UL Rev02

5.7 CHARACTER SUBSTRING

A character substring is a contiguous portion of a character datum and is of typecharacter. A character substring is identified by a substring name and may be assignedvalues and referenced.

5.7.1 Substring Name

The forms of a substring name are:

v ([e 1] : [e 2 ])

a (s [,s]...) ([e 1]:[e 2])

where: v is a character variable namea (s [,s]...) is a character array element namee1 and e2 are each an integer expression and are calledsubstring expressions

The value e 1 specifies the leftmost character position of the substring, and the value e 2specifies the rightmost character position. For example, A(2:4) specifies characters inpositions two through four of the character variable A, and B(4,3)(1:6) specifiescharacters in positions one through six of the character array element B(4,3).

The values of e 1 and e 2 must be such that:

1 <= e 1 <= e 2 <= len

where len is the length of the character variable or array element (8.4.2). If e 1 isomitted, a value of one is implied for e 1. If e 2 is omitted, a value of len is implied for e a. Both e 1 and e 2 may be omitted; for example, the form v(:) is equivalent to v, and theform a(s [,s]...)(:) is equivalent to a(s [,s]...). The length of a character substring is e 2 - e1 + 1.

5.7.2 Substring Expression

A substring expression may be any integer expression. A substring expression maycontain array element references and function references. Note that a restriction in theevaluation of expressions (6.6) prohibits certain side effects. In particular, evaluation of afunction must not alter the value of any other expression within the same substringname.

Page 87: FORTRAN 77 Reference Manual - Bull

47 A2 15UL Rev02 6-1

6. Expressions

This section describes the formation, interpretation, and evaluation rules for arithmetic,character, relational, and logical expressions. An expression is formed from operands,operators, and parentheses.

6.1 ARITHMETIC EXPRESSIONS

An arithmetic expression is used to express a numeric computation. Evaluation of anarithmetic expression produces a numeric value.

The simplest form of an arithmetic expression is an unsigned arithmetic constant,symbolic name of an arithmetic constant, arithmetic variable reference, arithmetic arrayelement reference, or arithmetic function reference. More complicated arithmeticexpressions may be formed by using one or more arithmetic operands together witharithmetic operators and parentheses.

[ NEW ANSI77 [ Arithmetic operands must identify values of type integer, real, doubleprecision, complex, short integer, quadruple precision, or complex double precision.].NEW ANSI77. ]

6.1.1 Arithmetic Operators

The five arithmetic operators are:

Operator | Representing ** | Exponentiation / | Division * | Multiplication - | subtraction or Negation + | Addition or Identity

Each of the operators **,/, and * operates on a pair of operands and is written betweenthe two operands. Each of the operators + and - either:

1. operates on a pair of operands and is written between the two operands, or

2. operates on a single operand and is written preceding that operand.

Page 88: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

6-2 47 A2 15UL Rev02

6.1.2 Form and Interpretation of Arithmetic Expressions

The interpretation of the expression formed with each of the arithmetic operators in eachform of use is as follows:

Use of Operator | Interpretation x 1 ** x 2 | Exponentiate x 1 to the power x 2

x 1 / x 2 | Divide x 1 by x 2

x 1 * x 2 | Multiply x 1 and x 2

x 1 - x 2 | 1Subtract x 2 from x 1

- x 2 | Negate x 2

x 1 + x 2 | Add x 1 and x 2

+ x 2 | Same as x 2

where: x 1 denotes the operand to the left of the operatorx 2 denotes the operand to the right of the operator

The interpretation of a division may depend on the data types of the operands (6.1.5).

A set of formation rules is used to establish the interpretation of an arithmetic expressionthat contains two or more operators.

There is a precedence among the arithmetic operators, which determines the order inwhich the operands are to be combined unless the order is changed by the use ofparentheses. The precedence of the arithmetic operators is as follows:

Operator | Precedence ** | Highest * and / | Intermediate + and - | Lowest

For example, in the expressionlc- A ** 2

the exponent operator (**) has precedence over the negation operator (-); therefore, theoperands of the exponent operator are combined to form an expression that is used asthe operand of the negation operator. The interpretation of the above expression is thesame as the interpretation of the expression

- (A ** 2)

Page 89: FORTRAN 77 Reference Manual - Bull

Expressions

47 A2 15UL Rev02 6-3

The arithmetic operands are:

1. Primary

2. Factor

3. Term

4. Arithmetic expression

The formation rules to be applied in establishing the interpretation of arithmeticexpressions are in 6.1.2.1 through 6.1.2.4.

6.1.2.1 Primaries

The primaries are:

1. Unsigned arithmetic constant (4.2.3)

2. Symbolic name of an arithmetic constant (8.6)

3. Arithmetic variable reference (2.5)

4. Arithmetic array element reference (5.3)

5. Arithmetic function reference (15.2)

6. Arithmetic expression enclosed in parentheses (6.1.2.4)

6.1.2.2 Factor

The forms of a factor are:

1. Primary

2. Primary ** factor

Thus, a factor is formed from a sequence of one or more primaries separated by theexponent operator. Form (2) indicates that in interpreting a factor containing two or moreexponent operators, the primaries are combined from right to left. For example, thefactor

2**3**2

has the same interpretation as the factor

2**(3**2)

Page 90: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

6-4 47 A2 15UL Rev02

6.1.2.3 Term

The forms of a term are:

1. Factor

2. Term / factor

3. Term * factor

Thus, a term is formed from a sequence of one or more factors separated by either themultiplication operator or the division operator. Forms (2) and (3) indicate that ininterpreting a term containing two or more multiplication or division operators, the factorsare combined from left to right.

6.1.2.4 Arithmetic Expression

The forms of an arithmetic expression are:

1. Term

2. + term

3. - term

4. Arithmetic expression + term

5. Arithmetic expression - term

Thus, an arithmetic expression is formed from a sequence of one or more termsseparated by either the addition operator or the subtraction operator. The first term in anarithmetic expression may be preceded by the identity or the negation operator. Forms(4) and (5) indicate that in interpreting an arithmetic expression containing two or moreaddition or subtraction operators, the terms are combined from left to right.

Note that these formation rules do not permit expressions containing two consecutivearithmetic operators, such as A**-B or A+-B. However, expressions such as A**(-B) andA+(-B) are permitted.

Page 91: FORTRAN 77 Reference Manual - Bull

Expressions

47 A2 15UL Rev02 6-5

6.1.3 Arithmetic Constant Expression

An arithmetic constant expression is an arithmetic expression in which each primary isan arithmetic constant, the symbolic name of an arithmetic constant, or an arithmeticconstant expression enclosed in parentheses. The exponent operator is not permittedunless the exponent is of type integer. Note that variable, array element, and functionreferences are not allowed.

6.1.3.1 Integer Constant Expression

An integer constant expression is an arithmetic constant expression in which eachconstant or symbolic name of a constant is of type integer, or short integer.

Note that variable, array element, and function references are not allowed.

The following are examples of integer constant expressions:

3-3-3+4

6.1.4 Type and Interpretation of Arithmetic Expressions

The data type of a constant is determined by the form of the constant (4.2.1). The datatype of an arithmetic variable reference, symbolic name of an arithmetic constant,arithmetic array element reference, or arithmetic function reference is determined by thename of the datum or function (4.1.2). The data type of an arithmetic expressioncontaining one or more arithmetic operators is determined from the data types of theoperands.

[ NEW ANSI77 [ An integer expression is an arithmetic expression whose value is oftype integer or short integer. ].NEW ANSI77. ]

Real expressions, double precision expressions, and complex expressions arearithmetic expressions whose values are of type, real, double precision, and complex,respectively.

[ NEW ANSI77 [ Quadruple precision expressions, complex double precisionexpressions are arithmetic expressions whose values are of type quadruple precision,and complex double precision respectively. ].NEW ANSI77. ]

When the operator + or - operates on a single operand, the data type of the resultingexpression is the same as the data type of the operand.

When an arithmetic operator operates on a pair of operands, the data type of theresulting expression is given in Tables 6-1 and 6-2. In these tables, each letter I, R, D orC represents an operand or result of type integer, real, double precision, or complex,respectively.

Page 92: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

6-6 47 A2 15UL Rev02

[ NEW ANSI77 [ Each letter or pair of letters IS, Q, CD represents an operand or resultof type short integer, quadruple precision or complex double precision, respectively.

The type of the result is indicated by the I, R, D, C, IS, Q, or CD that precedes theequals, and the interpretation is indicated by the expression to the right of the equals.REAL, DBLE, CMPLX, QEXT, and DCMPLX are the type-conversion functionsdescribed in 15.10. ].NEW ANSI77. ]

Table 6-1. Type and Interpretation of Result for x 1 + x 2

I 2

x 2

x 1

R 2

I 1

R 2 R = R + REAL(I )

1 2

D 1 D = D + DBLE(I )

1 2

C 1 C=C + CMPLX(REAL(I ),0.)

1 2

R = R + R 1 2

R = REAL(I ) + R 1 2

C = C + CMPLX(R ,0.) 1 2

x 2

x 1

I 1

D 2

C 2

R 1 D = DBLE(R ) + D

1 2

D = DBLE(I ) + D 1 2

C=CMPLX(REAL(I ),0.)+C 1 2

C = CMPLX(R ,0.) + C 1 2

I = I + I 1 2

D = D + DBLE(R ) 1 2

IS 1 I = INT(I ) + I

1 2

Q = Q + QEXT(I ) 1 2

Q 1

CD 1

Q = Q + QEXT(R ) 1 2

CD=CD + DCMPLX(DBLE(R ),0.D0) 1 2

CD=CD + DCMPLX(DBLE(I ),0.D0) 1 2

R = REAL(IS ) + R 1 2

D 1

C 1

IS 1

Q 1

CD 1

D = D + D 1 2

Q = Q + QEXT(D ) 1 2

D = DBLE(IS ) + D 1 2

CD=DCMPLX(C )+DCMPLX(D ,0.D0) 1 2

C = C + C 1 2

C=CMPLX(REAL(IS ),0.) + C 1 2

prohibited

CD=DCMPLX(D ,0.D0)+DCMPLX(C ) 1 2

CD=CD + DCMPLX(D ),0.D0) 1 2

CD=CD + DCMPLX(C ) 1 2

Page 93: FORTRAN 77 Reference Manual - Bull

Expressions

47 A2 15UL Rev02 6-7

Tables giving the type and interpretation of expressions involving -, *, and / may beobtained by replacing all occurrences of + in Table 6-1 by -, *, or /, respectively.

Table 6-2. Type and Interpretation of Result for x1 ** x2

I 2

x 2

x 1

R 2

I 1

D 1

C 1

x 2

x 1

I 1

D 2

C 2

R 1

R 1

I = I ** I 1 2

D = D ** I 1 2

R = R ** I 1 2

C = C ** I 1 2

R = REAL(I ) ** R 1 2

R = R ** R 1 2

D = D ** DBLE(R ) 1 2

C = C ** CMPLX(R ,0.) 1 2

D = DBLE(I ) ** D 1 2

D = DBLE(R ) ** D 1 2

C=CMPLX(REAL(I ),0.)**C 1 2

C = CMPLX(R ,0.) ** C 1 2

IS 1

Q 1

CD 1

IS = IS ** I 1 2

Q = Q ** I 1 2

CD = CD ** I 1 2

R = REAL(IS ) ** R 1 2

Q = Q ** QEXT(R ) 1 2

CD=CD ** DCMPLX(DBLE(R ),0.D0) 1 2

D 1

C 1

IS 1

Q 1

CD 1

prohibited

CD=DCMPLX(D ,0.D0)+DCMPLX(C ) 1 2

D = D ** D 1 2

D = DBLE(IS ) ** D 1 2

Q = Q ** QEXT(D ) 1 2

CD=CD ** DCMPLX(D ),0.D0) 1 2

C = C ** C 1 2

C=CMPLX(REAL(IS ),0.) ** C 1 2

CD=CD ** DCMPLX(C ) 1 2

CD=DCMPLX(C )**DCMPLX(D ,0.D0) 1 2

Page 94: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

6-8 47 A2 15UL Rev02

x 2

x 1

x 2

x 1

IS 1

Q 1

CD 1

IS 2

Q 2

IS = IS + IS 1 2

Q = Q + QEXT(IS ) 1 2

CD=CD + DCMPLX(DBLE(IS ),0.D0) 1 2

Q = QEXT(IS ) + R 2 1

Q = QEXT(D ) + Q 1 2

Q = QEXT(IS ) + Q 1 2

prohibited

prohibited

I 1

D 1

C 1

I = I + INIT(IS ) 1 2

R = R + REAL(IS ) 1 2

D = D + DBLE(IS ) 1 2

C=C + CMPLX(REAL(IS ),0.) 1 2

Q = REAL(I ) + Q 1 2

CD 2

I 1

D 1

C 1

IS 1

Q 1

CD 1

R 1

I 1

D 1

C 1

IS 1

Q 1

CD 1

R 1

CD = DCMPLX(DBLE(I ) 0.D0) + CD 1 2

CD = DCMPLX(DBLE(R ),0.D0)+CD 1 2CD = DCMPLX(D ,0.D0)+CD 1 2

CD = DCMPLX(C ) + CD 1 2

CD = DCMPLX(DBLE(IS ),0.D0)+CD 1 2

CD = CD ** CD 1 2

CD = CD + CD 1 2

prohibited

CD = DCMPLX(DBLE(I ),0.D0)**CD 1 2

CD = DCMPLX(DBLE(R ),0.D0)**CD 1 2

CD = DCMPLX(C )**CD 1 2

DC = DCMPLX(D ,0.D0)**CD 1 2

CD = DCMPLX(DBLE(IS ),0.D0)**CD 1 2

prohibited

R 1

Q = Q + Q 1 2

Page 95: FORTRAN 77 Reference Manual - Bull

Expressions

47 A2 15UL Rev02 6-9

[ NEW ANSI77 [ Several entries in Table 6-2 specify an interpretation to be a complexvalue raised to a complex power, or a complex double ].NEW ANSI77. ] precision valueraised to a complex double precision power.

In these cases, the value of the expression is the "principal value" determined by x 1 ** x 2= EXP(x 2 *LOG(x 1 )), where EXP and LOG are functions described in 15.10.

Except for a value raised to an integer power, Table 6-1 and 6-2 specify that if twooperands are of different type, the operand that differs in type from the result of theoperation is converted to the type of the result and then the operator operates on a pair ofoperands of the same type. [ NEW ANSI77 [ When a primary of type real, doubleprecision, complex, quadruple precision, complex double precision is raised to an integerpower, the integer operand need not be converted. ].NEW ANSI77. ] If the value of I 2 isnegative, the interpretation of I 1 **I 2 is the same as the interpretation of 1/(I 1 **ABS(I 2)), which is subject to the rules for integer division (6.1.5). For example, 2**(-3) has thevalue of 1/(2**3), which is zero.

[ NEW ANSI77 [ The same rule applies for short integer type instead of integer type.].NEW ANSI77. ]

The type and interpretation of an expression that consists of an operator operating oneither a single operand or a pair of operands are independent of the context in which theexpression appears. In particular, the type and interpretation of such an expression areindependent of the type of any other operand of any larger expression in which it appears.For example, if X is of type real, J is of type integer, and INT is the real-to-integerconversion function, the expression INT(X+J) is an integer expression and X+J is a realexpression.

[ NEW ANSI77 [ Another example is, if I is of type short integer, then I + 1 is of typeinteger, but not short integer, and evaluated as such. To evaluate in short integer type, theexpression must be I + HFIX(1) or I + P where P is the symbolic name of a short integersymbolic constant given by:

Example:

INTEGER * 2 P,IPARAMETER (P = 1)I = I + PA similar example is with short logical, but in this case, the only way to evaluate in shortlogical type is to use a symbolic constant:

Example:

LOGICAL * 1 TRUE, A, BPARAMETER (TRUE = .TRUE.)A = B.AND.TRUE ].NEW ANSI77. ]

Page 96: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

6-10 47 A2 15UL Rev02

6.1.5 Integer Division

[ NEW ANSI77 [ One operand of type integer or short integer may be divided by anotheroperand of type integer, or short integer. ].NEW ANSI77. ]

Although the mathematical quotient of two integers is not necessarily an integer, Table 6-1specifies that an expression involving the division operator with two operands of typeinteger is interpreted as an expression of type integer, or short integer. [ NEW ANSI77 [The result of such a division is called an integer quotient and is obtained as follows: if themagnitude of the mathematical quotient is less than one, the integer quotient is zero.].NEW ANSI77. ] Otherwise, the integer quotient is the integer whose magnitude is thelargest integer that does not exceed the magnitude of the mathematical quotient andwhose sign is the same as the sign of the mathematical quotient. For example, the valueof the expression (-8)/3 is (-2).

The following is an example of an arithmetic expression.

Example:

Variables Function reference

A rray elem ent

P arentheses (affec ting order of evaluation)

C onstant

A rithm etic operators

3.5 * ( X - Y ) + MAX (I1,I2) * B (5,1)

Page 97: FORTRAN 77 Reference Manual - Bull

Expressions

47 A2 15UL Rev02 6-11

6.2 CHARACTER EXPRESSIONS

A character expression is used to express a character string. Evaluation of a characterexpression produces a result of type character.

The simplest form of a character expression is a character constant, symbolic name of acharacter constant, character variable reference, character array element reference,character substring reference, or character function reference. More complicatedcharacter expressions may be formed by using one or more character operands togetherwith character operators and parentheses.

6.2.1 Character Operator

The character operator is:

Operator Representing// Concatenation

The interpretation of the expression formed with the character operator is:

Use of Operator Interpretationx 1 // x 2 Concatenate x 1 with x 2where: x 1 denotes the operand to the left of the operator.

x 2 denotes the operand to the right of the operator.

The result of a concatenation operation is a character string whose value is the value ofx1 concatenated on the right with the value of x2 and whose length is the sum of thelengths of x1 and x2. For example, the value of 'AB' // 'CDE' is the string ABCDE.

6.2.2 Form and Interpretation of Character Expressions

A character expression and the operands of a character expression must identify valuesof type character. Except in a character assignment statement (10.4), a characterexpression must not involve concatenation of an operand whose length specification isan asterisk in parentheses (8.4.2) unless the operand is the symbolic name of aconstant.

Page 98: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

6-12 47 A2 15UL Rev02

6.2.2.1 Character Primaries

The character primaries are:

1. Character constant (4.8.1)

2. Symbolic name of a character constant (8.6)

3. Character variable reference (2.5)

4. Character array element reference (5.3)

5. Character substring reference (5.7)

6. Character function reference (15.2)

7. Character expression enclosed in parentheses (6.2.2.2)

6.2.2.2 Character Expression

The forms of a character expression are:

1. Character primary

2. Character expression // character primary

Thus, a character expression is a sequence of one or more character primariesseparated by the concatenation operator. Form (2) indicates that in a characterexpression containing two or more concatenation operators, the primaries are combinedfrom left to right to establish the interpretation of the expression. For example, theformation rules specify that the interpretation of the character expression

'AB' // 'CD' // 'EF'is the same as the interpretation of the character expression

('AB' // 'CD') // 'EF'The value of the character expression in this example is the same as that of the constant'ABCDEF'. Note that parentheses have no effect on the value of a character expression.

6.2.3 Character Constant Expression

A character constant expression is a character expression in which each primary is acharacter constant, the symbolic name of a character constant, or a character constantexpression enclosed in parentheses. Note that variable, array element, substring, andfunction references are not allowed.

Page 99: FORTRAN 77 Reference Manual - Bull

Expressions

47 A2 15UL Rev02 6-13

6.3 RELATIONAL EXPRESSIONS

A relational expression is used to compare the values of two arithmetic expressions ortwo character expressions. A relational expression may not be used to compare thevalue of an arithmetic expression with the value of a character expression.

Relational expressions may appear only within logical expressions.Evaluation of a relational expression produces a result of type logical, with a value of trueor false.

6.3.1 Relational Operators

The relational operators are:

Operator | Representing .LT. | Less than .LE. | Less than or equal to .EQ. | Equal to .NE. | Not equal to .GT. | Greater than .GE. | Greater than or equal to

6.3.2 Arithmetic Relational Expression

The form of an arithmetic relational expression is:

e1 relop e2

where: e1 and e2 are each an integer, real, double precision, orcomplex expression, quadruple precision or complex doubleprecisionrelop is a relational operator

A complex operand or complex double precision operand is permitted only when therelational operator is .EQ. or .NE.

Page 100: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

6-14 47 A2 15UL Rev02

6.3.3 Interpretation of Arithmetic Relational Expressions

An arithmetic relational expression is interpreted as having the logical value true if thevalues of the operands satisfy the relation specified by the operator. An arithmeticrelational expression is interpreted as having the logical value false if the values of theoperands do not satisfy the relation specified by the operator.

If the two arithmetic expressions are of different types, the value of the relationalexpression

e1 relop e2is the value of the expression

((e1 ) - (e2 )) relop 0

where 0 (zero) is of the same type as the expression ((e1 )-(e2 )), and relop is the samerelational operator in both expressions. Note that the comparison of a double precisionvalue and a complex value is not permitted.

! PROCESSOR-DEPENDENT [ The following is an example of a relational expression:

Example:

J + 3 .LT. K-2-L].PROCESSOR-DEPENDENT.!

6.3.4 Character Relational Expression

The form of a character relational expression is:

e1 relop e2

where: e1 and e2 are character expressionsrelop is a relational operator

Page 101: FORTRAN 77 Reference Manual - Bull

Expressions

47 A2 15UL Rev02 6-15

6.3.5 Interpretation of Character Relational Expressions

A character relational expression is interpreted as the logical value true if the values ofthe operands satisfy the relation specified by the operator. A character relationalexpression is interpreted as the logical value false if the values of the operands do notsatisfy the relation specified by the operator.

The character expression e1 is considered to be less than e2 if the value of e1 precedesthe value of e2 in the collating sequence; e1 is greater than e2 if the value of e1 followsthe value of e2 in the collating sequence (3.1.5). Note that the collating sequencedepends partially on the processor; however, the result of the use of the operators .EQ.and .NE. does not depend on the collating sequence. If the operands are of unequallength, the shorter operand is considered as if it were extended on the right with blanksto the length of the longer operand.

Page 102: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

6-16 47 A2 15UL Rev02

6.4 LOGICAL EXPRESSIONS

A logical expression is used to express a logical computation. [ NEW ANSI77 [Evaluation of a logical expression produces a result of type logical, or short logical, witha value of true or false. ].NEW ANSI77. ]

The simplest form of a logical expression is a logical constant, symbolic name of alogical constant, logical variable reference, [ NEW ANSI77 [ logical array elementreference, logical function reference, relational expression, symbolic name of a shortlogical constant, short logical variable reference, short logical array element reference, orshort logical function reference. ].NEW ANSI77. ]

More complicated logical expressions may be formed by using one or more logicaloperands together with logical operators and parentheses.

6.4.1 Logical Operators

The logical operators are:

Operator | Representing .NOT | Logical Negation .AND. | Logical Conjunction .OR. | Logical Inclusive Disjunction .EQV. | Logical Equivalence .NEQV. | Logical Nonequivalence

Page 103: FORTRAN 77 Reference Manual - Bull

Expressions

47 A2 15UL Rev02 6-17

6.4.2 Form and Interpretation of Logical Expressions

A set of formation rules is used to establish the interpretation of a logical expression thatcontains two or more logical operators. There is a precedence among the logicaloperators, which determines the order in which the operands are to be combined unlessthe order is changed by the use of parentheses. The precedence of the logical operatorsis as follows:

Operator | Precedence .NOT. | Highest .AND. | .OR. | .EQV. or .NEQV. | LowestFor example, in the expression

A .OR. B .AND. C

the .AND. operator has higher precedence than the .OR. operator; therefore, theinterpretation of the above expression is the same as the interpretation of the expression

A .OR. (B .AND. C)

The logical operands are:

1. Logical primary

2. Logical factor

3. Logical term

4. Logical disjunctive

5. Logical expression

The formation rules to be applied in establishing the interpretation of a logical expressionare in 6.4.2.1 through 6.4.2.5.

Page 104: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

6-18 47 A2 15UL Rev02

6.4.2.1 Logical Primaries

The logical primaries are:

1. Logical constant (4.7.1)

2. Symbolic name of a logical constant (8.6)

3. Logical variable reference (2.5)

4. Logical array element reference (5.3)

5. Logical function reference (15.2)

6. Relational expression (6.3)

7. Logical expression enclosed in parentheses (6.4.2.5)

[ NEW ANSI77 [

8. Symbolic name of a short logical constant (8.6)

9. short logical variable reference (2.5)

10. short logical array element reference (5.3)

11. short logical function reference (15.2)

].NEW ANSI77. ]

6.4.2.2 Logical Factor

The forms of a logical factor are:

1. Logical primary

2. .NOT. logical primary

6.4.2.3 Logical Term

The forms of a logical term are:

1. Logical factor

2. Logical term .AND. logical factor

Thus, a logical term is a sequence of logical factors separated by the .AND. operator.Form (2) indicates that in interpreting a logical term containing two or more .AND.operators, the logical factors are combined from left to right.

Page 105: FORTRAN 77 Reference Manual - Bull

Expressions

47 A2 15UL Rev02 6-19

6.4.2.4 Logical Disjunctive

The forms of a logical disjunctive are:

1. Logical term

2. Logical disjunctive .OR. logical term

Thus, a logical disjunctive is a sequence of logical terms separated by the .OR. operator.Form (2) indicates that in interpreting a logical disjunctive containing two or more .OR.operators, the logical terms are combined from left to right.

6.4.2.5 Logical Expression

The forms of a logical expression are:

1. Logical disjunctive

2. Logical expression .EQV. logical disjunctive

3. Logical expression .NEQV. logical disjunctive

Thus, a logical expression is a sequence of logical disjunctives separated by either the.EQV. operator or the .NEQV. operator. Forms (2) and (3) indicate that in interpreting alogical expression containing two or more .EQV. or .NEQV. operators, the logicaldisjunctives are combined from left to right.

Page 106: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

6-20 47 A2 15UL Rev02

6.4.3 Value of Logical Factors, Terms, Disjuncts, and Expressions

The value of a logical factor involving .NOT. is shown below:

x2 | .NOT. x2 true | false false | true

The value of a logical term involving .AND. is shown below:

x1 | x2 | x1 .AND. x2 true | true | true true | false | false false | true | false false | false | false

The value of a logical disjunctive involving .OR. is shown below:

x1 | x2 | x1 .OR. x2 true | true | true true | false | true false | true | true false | false | false

The value of a logical expression involving .EQV. is shown below:

x1 | x2 | x1 .EQV. x2 true | true | true true | false | false false | true | false false | false | true

The value of a logical expression involving .NEQV. is shown below:

x1 | x2 | X1 .NEQV. x2 true | true | false true | false | true false | true | true false | false | false

6.4.4 Logical Constant Expression

[ NEW ANSI77 [ A logical constant expression is a logical expression in which eachprimary is a logical constant, the symbolic name of a logical constant, the symbolic nameof a short logical constant, a relational expression in which each primary is a constantexpression, or a logical constant expression enclosed in parentheses. ].NEW ANSI77. ]Note that variable, array element, and function references are not allowed.

Page 107: FORTRAN 77 Reference Manual - Bull

Expressions

47 A2 15UL Rev02 6-21

6.5 PRECEDENCE OF OPERATORS

In 6.1.2 and 6.4.2 precedences have been established among the arithmetic operatorsand the logical operators, respectively. There is only one character operator. Noprecedence has been established among the relational operators. The precedencesamong the various operators are:

Operator | Precedence Arithmetic | Highest Character | Relational | Logical | Lowest

An expression may contain more than one kind of operator. For example, the logicalexpression

L .OR. A + B .GE. C

where A, B, and C are of type real, and L is of type logical, contains an arithmeticoperator, a relational operator, and a logical operator. This expression would beinterpreted the same as the following expression

L .OR. ((A + B) .GE. C)

6.5.1 Summary of Interpretation Rules

The order in which primaries are combined using operators is determined by thefollowing:

1. Use of parentheses

2. Precedence of the operators

3. Right-to-left interpretation of exponents in a factor

4. Left-to-right interpretation of multiplications and divisions in a term

5. Left-to-right interpretation of additions and subtractions in an arithmetic expression

6. Left-to-right interpretation of concatenations in a character expression

7. Left-to-right interpretation of conjunctions in a logical term

8. Left-to-right interpretation of disjunctives in a logical disjunctive

9. Left-to-right interpretation of logical equivalences in a logical expression.

Page 108: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

6-22 47 A2 15UL Rev02

6.6 EVALUATION OF EXPRESSIONS

This section applies to arithmetic, character, relational, and logical expressions.

Any variable, array element, function, or character substring referenced as an operand inan expression must be defined at the time the reference is executed. An integer operandmust be defined with an integer value rather than a statement label value. Note that if acharacter string or substring is referenced, all of the referenced characters must bedefined at the time the reference is executed.

Any arithmetic operation whose result is not mathematically defined is prohibited in theexecution of an executable program. Examples are dividing by zero and raising a zero-valued primary to a zero-valued or negative-valued power. Raising a negative-valuedprimary to a real or double precision power is also prohibited.

The execution of a function reference in a statement may not alter the value of any otherentity within the statement in which the function reference appears. The execution of afunction reference in a statement may not alter the value of any entity in common (8.3)that affects the value of any other function reference in that statement. However,execution of a function reference in the expression e of a logical IF statement (11.5) ispermitted to affect entities in the statement st that is executed when the value of theexpression e is true. If a function reference causes definition of an actual argument ofthe function, that argument or any associated entities must not appear elsewhere in thesame statement.

For example, the statements

A(I) = F(I)

Y = G(X) + X

are prohibited if the reference to F defines I or the reference to G defines X.

The data type of an expression in which a function reference appears does not affect theevaluation of the actual arguments of the function. The data type of an expression inwhich a function reference appears is not affected by the evaluation of the actualarguments of the function, except that the result of a generic function reference assumesa data type that depends on the data type of its arguments as specified in 15.10.

Any execution of an array element reference requires the evaluation of its subscript. Thedata type of an expression in which a subscript appears does not affect, nor is it affectedby, the evaluation of the subscript.

Any execution of a substring reference requires the evaluation of its substringexpressions. The data type of an expression in which a substring name appears doesnot affect, nor is it affected by, the evaluation of the substring expressions.

Page 109: FORTRAN 77 Reference Manual - Bull

Expressions

47 A2 15UL Rev02 6-23

6.6.1 Evaluation of Operands

It is not necessary for a processor to evaluate all of the operands of an expression if thevalue of the expression can be determined otherwise. This principle is most oftenapplicable to logical expressions, but it applies to all expressions. For example, inevaluating the logical expression

X .GT. Y .OR. L(Z)

where X, Y, and Z are real, and L is a logical function, the function reference L(Z) neednot be evaluated if X is greater than Y. If a statement contains a function reference in apart of an expression that need not be evaluated, all entities that would have becomedefined in the execution of that reference become undefined at the completion ofevaluation of the expression containing the function reference. In the example above,evaluation of the expression causes Z to become undefined if L defines its argument.

6.6.2 Order of Evaluation or Functions

If a statement contains more than one function reference, a processor may evaluate thefunctions in any order, except for a logical IF statement and a function argument listcontaining function references. For example, the statement

Y = F(G(X))

where F and G are functions, requires G to be evaluated before F is evaluated.

In a statement that contains more than one function reference, the value provided byeach function reference must be independent of the order chosen by the processor forevaluation of the function references.

6.6.3 Integrity of Parentheses

The sections that follow state certain conditions under which a processor may evaluatean expression different from the one obtained by applying the interpretation rules givenin 6.1 through 6.5.

ANSI 77 norm states that any expression contained in parentheses must be treated asan entity. For example, in evaluating the expression A*(B*C), the product of B and Cmust be evaluated and then multiplied by A; the processor must not evaluate themathematically equivalent expression (A*B)*C.

[ NEW ANSI77 [ This rule has not been applied in GCOS FORTRAN 77, the reasonbeing that this may produce poor optimization, in case parentheses are used forconvenience of formula programming, but not for giving the order of evaluation.

Page 110: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

6-24 47 A2 15UL Rev02

The order of evaluation may be compelled by using the EVALUATE intrinsic function(generic only). The value of the EVALUATE function is the value of its argument. Forexample, EVALUATE (B*C) as the value of B*C. In evaluating the expressionA*EVALUATE (B*C), the product of B and C must be evaluated and then multiplied by A.].NEW ANSI77. ]

However, for conformance reason and despite the optimization argument, the compilermay be forced to apply the rule of integrity of parentheses even though the EVALUATEfunction has not been used, if the PI (parentheses integrity) option is specified in theFOR77 JCL statement (Refer to the Fortran 77 User's Guide).

6.6.4 Evaluation of Arithmetic Expressions

The rules given in 6.1.2 specify the interpretation of an arithmetic expression. Once theinterpretation has been established in accordance with those rules, the processorevaluates any mathematically equivalent expression.

Two arithmetic expressions are mathematically equivalent if, for all possible values oftheir primaries, their mathematical values are equal. However, mathematically equivalentarithmetic expressions may produce different computational results.

The mathematical definition of integer division is given in 6.1.5. The difference betweenthe value of the expression 5/2 and 5./2. is a mathematical difference, not acomputational difference.

The following are examples of expressions, along with allowable alternative forms thatmay be used by the processor in the evaluation of those expressions. A, B, and Crepresent arbitrary real, double precision, or complex operands: I and J representarbitrary integer operands; and X, Y, and Z represent arbitrary arithmetic operands.(Note that Table 6-1 prohibits combinations of double precision and complex data types.)

Example 1:

Expression | Allowable Alternative Form X+Y | Y+X X*Y | Y*X -X+Y | Y-X X+Y+Z | X+(Y+Z) X-Y+Z | X-(Y-Z) X*B/Z | X*(B/Z) X*Y-X*Z | X*(Y-Z) A/B/C | A/(B*C) A/5.0 | 0.2*A I/2 | 0.5*I X*I/J | X*(I/J) I/J/A | I/(J*A) (X*Y)-(X*Z) | X*(Y-Z) X*(Y-Z) | X*Y-X*Z

The following are examples of expressions along with prohibited forms that must not beused by the processor in the evaluation of those expressions.

[ NEW ANSI77 [

Page 111: FORTRAN 77 Reference Manual - Bull

Expressions

47 A2 15UL Rev02 6-25

Example 2:

Expression | Non Allowable Alternative Form I/EVALUATE(-2) | 0.5*I EVALUATE(X*I)/J | X*EVALUATE(I/J) EVALUATE(I/J)/A | I/EVALUATE(J*A) EVALUATE(X*Y)-EVALUATE(X*Z) | *EVALUATE(Y-Z) X*EVALUATE(Y-Z) | EVALUATE(X*Y)-EVALUATE(X*Z) EVALUATE(X+Y).EQ.Y | X.EQ.0

In addition to the parentheses required to establish the desired interpretation, ].NEWANSI77. ] EVALUATE function may be included to restrict the alternative forms that maybe used by the processor in the actual evaluation of the expression. This is useful forcontrolling the magnitude and accuracy of intermediate values developed during theevaluation of an expression. For example, in the expression

A + EVALUATE (B - C)

the term (B-C) must be evaluated and then added to A. [ NEW ANSI77 [ Note that theinclusion of the EVALUATE function may change the mathematical value of anexpression. For example:

L1 = SMALL + BIG .EQ. BIG is changed to

L1 = SMALL.EQ.0, which is false if

SMALL < BIG * 16E - 8 though L1 = EVALUATE

(SMALL + BIG).EQ.BIG will first compare SMALL + BIG

and then compare the result to BIG. ].NEW ANSI77. ]

Each operand of an arithmetic operator has a data type that may depend on the order ofevaluation used by the processor. For example, in the evaluation of the expression

D+R+I

where D, R, and I represent terms of double precision, real, and integer data type,respectively, the data type of the operand that is added to I may be either doubleprecision or real, depending on which pair of operands (D and R, R and I, or D and I) isadded first.

[ NEW ANSI77 [ The main interest of the EVALUATE function is to avoid exceptions:

I = 2 ** 30 + J + K

may be a correct value if J < 0 and K > 2but may not be compiled as 2 ** 30 + K + Jwhich gives an overflow. To ensure the compilation order, one must write:

I = EVALUATE (2 ** 30 + J) + K ].NEW ANSI77. ]

Page 112: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

6-26 47 A2 15UL Rev02

6.6.5 Evaluation of Character Expressions

The rules given in 6.2.2 specify the interpretation of a character expression as a string ofcharacters. A processor needs to evaluate only as much of the character expression asis required by the context in which the expression appears. For example, the statements

CHARACTER*2 C1,C2,C3,CFC1 = C2 // CF(C3)

do not require the function CF to be evaluated, because only the value of C2 is neededto determine the value of C1.

6.6.6 Evaluation of Relational Expressions

The rules given in 6.3.3 and 6.3.5 specify the interpretation of relational expressions.Once the interpretation on an expression has been established in accordance with thoserules, the processor may evaluate any other expression that is relationally equivalent.For example, the processor may choose to evaluate the relational expression

I .GT. J

where I and J are integer variables, as

J - I .LT. 0Two relational expressions are relationally equivalent if their logical values are equal forall possible values of their primaries.

6.6.7 Evaluation of Logical Expressions

The rules given in 6.4.2 specify the interpretation of a logical expression. Once theinterpretation of an expression has been established in accordance with those rules, theprocessor may evaluate any other expression that is logically equivalent, [ NEW ANSI77[ provided that the integrity of the EVALUATE function is not violated. ].NEW ANSI77. ]

For example, the processor may choose to evaluate the logical expression

L1 .AND. L2 .AND. L3

where L1, L2, and L3 are logical variables, as

[ NEW ANSI77 [L1 .AND. EVALUATE (L2 .AND. L3) ].NEW ANSI77. ]

Two logical expressions are logically equivalent if their values are equal for all possiblevalues of their primaries.

Page 113: FORTRAN 77 Reference Manual - Bull

Expressions

47 A2 15UL Rev02 6-27

6.7 CONSTANT EXPRESSIONS

A constant expression is an arithmetic constant expression (6.1.3), a character constantexpression (6.2.3), or a logical constant expression (6.4.4).

Page 114: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

6-28 47 A2 15UL Rev02

Page 115: FORTRAN 77 Reference Manual - Bull

47 A2 15UL Rev02 7-1

7. Executable and Nonexecutable StatementClassification

Each statement is classified as executable or nonexecutable.

Executable statements specify actions and form an execution sequence in anexecutable program. Nonexecutable statements specify characteristics, arrangement,and initial values of data, contain editing information, specify statement functions,classify program units, and specify entry points within subprograms. Nonexecutablestatements are not part of the execution sequence. Nonexecutable statements may belabeled, but such statement labels must not be used to control the execution sequence.

7.1 EXECUTABLE STATEMENTS

The following statements are classified as executable:

1. Arithmetic, logical, statement label (ASSIGN), and character assignmentstatements

2. Unconditional GOTO, assigned GOTO, and computed GOTO statements

3. Arithmetic IF and logical IF statements

4. Block IF, ELSE IF, ELSE, and END IF statements

5. CONTINUE statement

6. STOP and PAUSE statements

7. DO statement

8. READ, WRITE, and PRINT statements

9. REWIND, BACKSPACE, ENDFILE, OPEN, CLOSE, INQUIRE, and PUNCHstatements #

10. CALL and RETURN statements

11. END statement

Page 116: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

7-2 47 A2 15UL Rev02

7.2 NONEXECUTABLE STATEMENTS

The following statements are classified as nonexecutable:

1. PROGRAM, FUNCTION, SUBROUTINE, ENTRY, and BLOCK DATA statements

[ NEW ANSI77 [

2. DIMENSION, COMMON, EQUIVALENCE, IMPLICIT, PARAMETER, EXTERNAL,INTRINSIC, SAVE, and NAMELIST statements

3. INTEGER, REAL, DOUBLE PRECISION, COMPLEX, LOGICAL, andCHARACTER type-statements

4. INTEGER * 2, LOGICAL * 1, QUADRUPLE PRECISION, COMPLEX DOUBLEPRECISION type-statements

].NEW ANSI77. ]

5. FORMAT statement

6. Statement function statement

Page 117: FORTRAN 77 Reference Manual - Bull

47 A2 15UL Rev02 8-1

8. Specification Statements

There are ten kinds of specification statements:

1. DIMENSION

2. EQUIVALENCE

3. COMMON

[ NEW ANSI77 [

4. INTEGER, REAL, DOUBLE PRECISION, COMPLEX, LOGICAL, CHARACTER,INTEGER * 2, LOGICAL * 1, QUADRUPLE PRECISION and COMPLEX DOUBLEPRECISION type-statements

].NEW ANSI77. ]

5. IMPLICIT

6. PARAMETER

7. EXTERNAL

8. INTRINSIC

9. SAVE

10. NAMELIST

All specification statements are nonexecutable.

Page 118: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

8-2 47 A2 15UL Rev02

8.1 DIMENSION STATEMENT

A DIMENSION statement is used to specify the symbolic names and dimensionspecifications of arrays.

The form of a DIMENSION statement is:

DIMENSION a(d) [,a(d)]...

where each a(d) is an array declarator (5.1).

Each symbolic name a appearing in a DIMENSION statement declares a to be an arrayin that program unit. Note that array declarators may also appear in COMMONstatements and type-statements. Only one appearance of a symbolic name as an arrayname in an array declarator in a program unit is permitted.

! PROCESSOR-DEPENDENT [ The following is an example of a DIMENSIONstatement:

Example:

DIMENSION A (5,3)

C This statement causes the 15 elements of A to be storedC consecutively in the following order:C A(1,1), A(2,1), A(3,1), A(4,1), A(5,1), A(1,2), A(2,2), A(3,2),C A(4,2), A(5,2), A(1,3), A(2,3), A(3,3), A(4,3), A(5,3).

DIMENSION B (10,*)

The following is an example of a DIMENSION statement inside a SUBROUTINEsubprogram.

Page 119: FORTRAN 77 Reference Manual - Bull

Specification Statements

47 A2 15UL Rev02 8-3

Example:

SUBROUTINE S (A1, A2, N1, N2, A4) PARAMETER (IP = 10) COMMON /C1/NC

C A1 is an adjustable array

DIMENSION A1 (10,NC+N1,10)

C A2 is an assumed size array

DIMENSION A2 (10,N1+1,*)

C A3 is a constant array declarator

DIMENSION A3 (IP+1)

C A4 is an assumed size array with character elements ofassumedC length

CHARACTER * (*) A4 DIMENSION A4 (*) END].PROCESSOR-DEPENDENT.!

Page 120: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

8-4 47 A2 15UL Rev02

8.2 EQUIVALENCE STATEMENT

An EQUIVALENCE statement specifies the sharing of storage units by two or moreentities in a program unit. This causes association of the entities that share the storageunits.

If the two shared entities are of different data types, the EQUIVALENCE statement doesnot cause type conversion or imply mathematical equivalence. If the EQUIVALENCEstatement specifies a variable and an array, the variable does not have array propertiesand the array does not have the properties of a variable.

8.2.1 Form of an EQUIVALENCE Statement

The form of an EQUIVALENCE statement is:

EQUIVALENCE (nlist) [,(nlist)]...

where each nlist is a list (2.10) of variable names, array element names, array names,and character substring names. Each list must contain at least two names. Names ofdummy arguments of an external procedure in a subprogram must not appear in the list.If a variable name is also a function name (15.5.1), that name must not appear in the list.

Each subscript expression or substring expression in a list nlist must be an integerconstant expression.

8.2.2 Equivalence Association

An EQUIVALENCE statement specifies that the storage sequences of the entities whosenames appear in a list nlist have the same first storage unit. This causes the associationof the entities in the list nlist and may cause association of other entities (17.1).

8.2.3 Equivalence of Character Entities

The EQUIVALENCE statement can specify an entity of type character with other entitiesof type character. [ NEW ANSI77 [ An entity of type character may also beequivalenced with entities of another type. ].NEW ANSI77. ]

The lengths of the entities that are specified equivalent are not required to be the same.

An EQUIVALENCE statement specifies that the storage sequences of the characterentities whose names appear in a list nlist have the same first character storage unit.This causes the association of the entities in the list nlist and may cause association ofother entities (17.1). Any adjacent characters in the associated entities may also havethe same character storage unit and thus may also be associated. In the example:

Page 121: FORTRAN 77 Reference Manual - Bull

Specification Statements

47 A2 15UL Rev02 8-5

Example:

CHARACTER A*4, B*4, C(2)*3EQUIVALENCE (A,C(1)), (B,C(2))

the association of A, B, and C can be graphically illustrated as:

12

8.2.4 Array Names and Array Element Names

If an array element name appears in an EQUIVALENCE statement, the number ofsubscript expressions must be the same as the number of dimensions specified in thearray declarator for the array name.

The use of an array name unqualified by a subscript in an EQUIVALENCE statementhas the same effect as using an array element name that identifies the first element ofthe array.

8.2.5 Restrictions on EQUIVALENCE Statements

An EQUIVALENCE statement must not specify that the same storage unit is to occurmore than once in a storage sequence. For example,

DIMENSION A(2)EQUIVALENCE (A(1),B), (A(2),B)

is prohibited, because it would specify the same storage unit for A(1) and A(2). AnEQUIVALENCE statement must not specify that consecutive storage units are to benonconsecutive. For example, the following is prohibited:

REAL A(2)DOUBLE PRECISION D(2)EQUIVALENCE (A(1),D(1)), (A(2),D(2))

The following is an example of an EQUIVALENCE statement:

! PROCESSOR-DEPENDENT [

Example:

DIMENSION ARRAY1 (100), ARRAY2 (10) EQUIVALENCE (ARRAY1 (91), ARRAY2), (X,Y)

C The 10 elements of ARRAY2 have the same storage as the lastC 10 elements of ARRAY1. X and Y have the same storage. ].PROCESSOR-DEPENDENT.!

Page 122: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

8-6 47 A2 15UL Rev02

8.3 COMMON STATEMENT

COMMON statement

The COMMON statement provides a means of associating entities in different programunits. This allows different program units to define and reference the same data withoutusing arguments, and to share storage units.

8.3.1 Form of a COMMON Statement

The form of a COMMON statement is:

COMMON [/[cb]/] nlist [[,]/[cb]/nlist]...

where: cb is a common block name (18.2.1)

nlist is a list (2.10) of variable names, array names, and arraydeclarators. Only one appearance of a symbolic name as avariable name, array name, or array declarator is permittedin all such lists within a program unit. Names of dummyarguments of an external procedure in a subprogram mustnot appear in the list. If a variable name is also a functionname (15.5.1), that name must not appear in the list.

Each omitted cb specifies the blank common block. If the first cb is omitted, the first twoslashes are optional.

In each COMMON statement, the entities whose names appear in an nlist following ablock name cb are declared to be in common block cb. If the first cb is omitted, allentities whose names appear in the first nlist are specified to be in blank common.Alternatively, the appearance of two slashes with no block name between them declaresthe entities whose names appear in the list nlist that follows to be in blank common.

Any common block name cb or an omitted cb for blank common may occur more thanonce in one or more COMMON statements in a program unit. The list nlist following eachsuccessive appearance of the same common block name is treated as a continuation ofthe list for that common block name.

[ NEW ANSI77 [ If a character variable or character array is in a common block, all ofthe entities in that common block need not be of type character. ].PROCESSOR-DEPENDENT.!

Page 123: FORTRAN 77 Reference Manual - Bull

Specification Statements

47 A2 15UL Rev02 8-7

8.3.2 Common Block Storage Sequence

For each common block, a common block storage sequence is formed as follows:

1. A storage sequence is formed consisting of the storage sequences of all entities inthe lists nlist for the common block. The order of the storage sequence is the sameas the order of the appearance of the lists nlist in the program unit.

2. The storage sequence formed in (1) is extended to include all storage units of anystorage sequence associated with it by equivalence association. The sequencemay be extended only by adding storage units beyond the last storage unit. Entitiesassociated with an entity in a common block are considered to be in that commonblock.

8.3.3 Size of a Common Block

The size of a common block is the size of its common block storage sequence, includingany extensions of the sequence resulting from equivalence association.

Within an executable program, all named common blocks that have the same namemust be the same size. Blank common blocks within an executable program are notrequired to be the same size.

8.3.4 Common Association

Within an executable program, the common block storage sequences of all commonblocks with the same global (18.1.1) name have the same first storage unit. Within anexecutable program, the common block storage sequences of all blank common blockshave the same first storage unit. This results in the association (17.1) of entities indifferent program units.

8.3.5 Differences Between Named Common and Blank Common

A blank common block has the same properties as a named common block, except forthe following:

1. Named common blocks of the same name must be of the same size in all programunits of an executable program in which they appear, but blank common blocksmay be of different sizes.

2. Entities in named common blocks may be initially defined by means of a DATAstatement in a block data subprogram, but entities in blank common must not beinitially defined (Section IX).

Page 124: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

8-8 47 A2 15UL Rev02

8.3.6 Restrictions on Common and Equivalence

An EQUIVALENCE statement must not cause the storage sequences of two differentcommon blocks in the same program unit to be associated. Equivalence associationmust not cause a common block storage sequence to be extended by adding storageunits preceding the first storage unit of the first entity specified in a COMMON statementfor the common block. For example, the following is not permitted:

COMMON /X/AREAL B(2)EQUIVALENCE (A,B(2))

! PROCESSOR-DEPENDENT [ The following is an example of a COMMON statement:

Example:

C W1 AND W2 ARE PLACED IN BLOK1, ARRAY1 IN BLOK2, AND X2 IN ANC UNLABELED COMMON BLOCK

COMMON /BLOK1/W1,W2/BLOK2/ARRAY1//X2

C X, Y, AND Z ARE PLACED IN THE UNLABELED COMMON BLOCKFOLLOWINGC X2, AND ARRAY2 IS DECLARED AND PLACED IN BLOK3

COMMON X,Y,Z/BLOK3/ARRAY2(25,10) ].PROCESSOR-DEPENDENT.!

Page 125: FORTRAN 77 Reference Manual - Bull

Specification Statements

47 A2 15UL Rev02 8-9

8.4 TYPE-STATEMENTS

A type-statement is used to override or confirm implicit typing and may specifydimension information.

The appearance of the symbolic name of a constant, variable, array, external function, orstatement function in a type-statement specifies the data type for that name for allappearances in the program unit. Within a program unit, a name must not have its typeexplicitly specified more than once.

A type-statement that confirms the type of an intrinsic function whose name appears inthe Specific Name column of Table 15.1 is not required, but is permitted. If a genericfunction name appears in a type-statement, such an appearance is not sufficient by itselfto remove the generic properties from that function.

The name of a main program, subroutine, or block data subprogram must not appear ina type-statement.

Page 126: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

8-10 47 A2 15UL Rev02

8.4.1 Type Statements (except CHARACTER)

The following paragraphs describe the following type statements:

[ NEW ANSI77 [

INTEGERCOMPLEXQUADRUPLE PRECISION

REALLOGICAL INTEGER *2COMPLEX DOUBLEPRECISION

DOUBLE PRECISIONLOGICAL *1

].NEW ANSI77. ]

These type statements are of the following form:

typ v [,v] ...

where:

typ is one of INTEGER, REAL, DOUBLE PRECISION,COMPLEX, LOGICAL, INTEGER * 2, LOGICAL * 1,QUADRUPLE PRECISION, OR COMPLEX DOUBLEPRECISION

v is a variable name, array name, array declarator, symbolicname of a constant, function name, or dummy procedurename (18.2.11).

[ NEW ANSI77 [ An INTEGER * 2 type statement specifies that the type of variable v isshort integer. A LOGICAL * 1 type statement specifies that the type of variable v is shortlogical. ].NEW ANSI77. ]

[ # OLD ANSI77 [ Note that for typ the following syntaxes are equivalent:

INTEGER * 4 or INTEGER,REAL * 4 or REAL,REAL * 8 or DOUBLE PRECISION,REAL * 16 or QUADRUPLE PRECISION,COMPLEX * 8 or COMPLEXCOMPLEX * 16 or COMPLEX DOUBLE PRECISION].OLD ANSI77.#

! PROCESSOR-DEPENDENT [ The following are examples of type-statements

Example:

INTEGER * 2 HALFW, SHORT (10,20)INTEGER COUNT, IT (1000)REAL MAXVAL, MATRIX (1000,1000)DOUBLE PRECISION ACCUR (100 000), MINQUADRUPLE PRECISION Q(10,10,10,10,10)COMPLEX C1,C2,C3 (0:9)COMPLEX DOUBLE PRECISION CD(-1000:0)LOGICAL WORDLOGICAL * 1 BYTE (4 000 000)].PROCESSOR-DEPENDENT.!

Page 127: FORTRAN 77 Reference Manual - Bull

Specification Statements

47 A2 15UL Rev02 8-11

8.4.2 CHARACTER Type-Statement

The form of a CHARACTER type-statement is:

CHARACTER [ *len [,]] nam [,nam]...

where: nam is of one of the forms:

v [*len] a [(d)] [*len]

v is a variable name, symbolic name of a constant, functionname, or dummy procedure name

a is an array namea(d) is an array declaratorlen is the length (number of characters) of a character variable,

character array element, character constant that has asymbolic name, or character function, and is called thelength specification. len is one of the following:1. An unsigned, nonzero, integer constant2. An integer constant expression (6.1.3.1) enclosed in

parentheses and with a positive value3. An asterisk in parentheses. (*)

A length len immediately following the word CHARACTER is the length specification foreach entity in the statement not having its own length specification. A length specificationimmediately following an entity is the length specification for only that entity. Note that foran array the length specified is for each array element. If a length is not specified for anentity, its length is one.

An entity declared in a CHARACTER statement must have a length specification that isan integer constant expression, unless that entity is an external function, a dummyargument of an external procedure, or a character constant that has a symbolic name.

If a dummy argument has a len of (*) declared, the dummy argument assumes thelength of the associated actual argument for each reference of the subroutine orfunction. If the associated actual argument is an array name, the length assumed by thedummy argument is the length of an array element in the associated actual argumentarray.

If an external function has a len of (*) declared in a function subprogram, the functionname must appear as the name of a function in a FUNCTION or ENTRY statement inthe same subprogram. When a reference to such a function is executed, the functionassumes the length specified in the referencing program unit.

The length specified for a character function in the program unit that references thefunction must be an integer constant expression and must agree with the lengthspecified in the subprogram that specifies the function. Note that there always isagreement of length if a len of (*) is specified in the subprogram that specifies thefunction.

If a character constant that has a symbolic name has a len of (*) declared, the constantassumes the length of its corresponding constant expression in a PARAMETERstatement.

Page 128: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

8-12 47 A2 15UL Rev02

The length specified for a character statement function or statement function dummyargument of type character must be an integer constant expression.

! PROCESSOR-DEPENDENT [ The following are examples of CHARACTERstatements

Example 1:

CHARACTER * 10 A, B, C * 1000CHARACTER * (*) DCHARACTER ARRAY1 (100,100) * 100CHARACTER *100 ARRAY2 (100,100)CHARACTER * (*) ASSUM (*)

The following is an example of an integer function with character arguments

Example 2:

C This function returns the sum of the length of its arguments INTEGER FUNCTION F(X,Y) CHARACTER *(*) X, Y F = LEN (X // Y) RETURN ENDC These are two calls of the function PROGRAM P CHARACTER * 10 C1, C2 CHARACTER * 20 C3, C4 INTEGER F I = F (C1, C2)C The value of I is 20 I = F (C3, C4)C The value of I is 40 END ].PROCESSOR-DEPENDENT.!

The following is an example of a character function with a character secondary entrypoint

Page 129: FORTRAN 77 Reference Manual - Bull

Specification Statements

47 A2 15UL Rev02 8-13

! PROCESSOR-DEPENDENT [

Example 3:

C this function returns the concatenation of its arguments CHARACTER *(*) FUNCTION F (X, Y) CHARACTER *(*) X, Y, F2 CHARACTER * 3 X2, Y2 F = X // Y RETURNC this entry point returns the concatenation of the three firstC characters of its arguments EN1 TRY F2 (X2, Y2) F2 = X2 // Y2 RETURN ENDC these are two calls of the function PROGRAM P CHARACTER *8 F, F2, C C = F ('ABCD', 'ABCD')C the value of C is 'ABCDABCD' C = F2 ('ABCD', 'ABCD')C the value of C is 'ABCABC ' END

Page 130: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

8-14 47 A2 15UL Rev02

8.5 IMPLICIT STATEMENT

An IMPLICIT statement is used to change or confirm the default implied integer and realtyping.

The form of an IMPLICIT statement is:

IMPLICIT typ (a [,a]...) [typ (a [,a]...)]...

where:

typ is one of INTEGER, REAL, DOUBLE PRECISION,COMPLEX, LOGICAL, CHARACTER [*len], INTEGER * 2,LOGICAL * 1, QUADRUPLE PRECISION, COMPLEXDOUBLE PRECISION

a is either a single letter or a range of single letters inalphabetical order. A range is denoted by the first and lastletter of the range separated by a minus. Writing a range ofletters a1 - a2 has the same effect as writing a list of thesingle letters a1 through a2.

len is the length of the character entities and is one of thefollowing:1. An unsigned, nonzero, integer constant2. An integer constant expression (6.1.3.1) enclosed in

parentheses and with a positive value

If len is not specified, the length is one.

An IMPLICIT statement specifies a type for all variables, arrays, symbolic names ofconstants, external functions, and statement functions that begin with any letter thatappears in the specification, either as a single letter or included in a range of letters.IMPLICIT statements do not change the type of any intrinsic functions. An IMPLICITstatement applies only to the program unit that contains it.

Type specification by an IMPLICIT statement may be overridden or confirmed for anyparticular variable, array, symbolic name of a constant, external function, or statementfunction name by the appearance of that name in a type-statement. An explicit typespecification in a FUNCTION statement overrides an IMPLICIT statement for the nameof that function subprogram. Note that the length is also overridden when a particularname appears in a CHARACTER or CHARACTER FUNCTION statement.

Within the specification statements of a program unit, IMPLICIT statements mustprecede all other specification statements except PARAMETER statements. A programunit may contain more than one IMPLICIT statement.

The same letter must not appear as a single letter, or be included in a range of letters,more than once in all of the IMPLICIT statements in a program unit. ].PROCESSOR-DEPENDENT.!

The following are examples of IMPLICIT statements.

Example 1:

FUNCTION F(X) IMPLICIT INTEGER (A-Y)

C this gives to F on X the type integer

Page 131: FORTRAN 77 Reference Manual - Bull

Specification Statements

47 A2 15UL Rev02 8-15

IMPLICIT CHARACTER * 10 (Z) DIMENSION Z1 (20) REAL Z2

C Z1 is of type CHARACTER, Z2 of type REAL END

Example 2:

The following is an example of an IMPLICIT statement to transform a single precisionprogram unit into a double precision one. If IMPLICIT is omitted all computations areperformed in REAL, if IMPLICIT is present, all computations are performed in DOUBLEPRECISION.

FUNCTION E27 (X, Y) IMPLICIT DOUBLE PRECISION (A-H, O-Z)

C this IMPLICIT has effect on the following variables, symbolicC constants, and arrays, but also on the function type and onC its dummy C arguments type.

PARAMETER (CST = .01D + 0)

C CST has the implicit type REAL if no IMPLICIT, or DOUBLEC PRECISION if IMPLICIT. The numeric constant must be doubleC precision. If CST is REAL it receives the single precisionC approximation, if CST is DOUBLE PRECISION it receives theC DOUBLE PRECISION value. Note that .01 gives the value ofC 1/100 with 2 digits in base10, but with an infinite number ofC digits in the base 16 used by the hardware.C The following gives the same result:

PARAMETER (CST2 = 1.D0/100.D0) A = SIN (CST)

C The generic name of the sin function is used so that, if CSTC is REAL, the single precision SIN * is selected, and if CSTisC DOUBLE PRECISION, the double precision DSIN is selected.

B = D1 + D2 + D3 DATA D1 / .01D0 / DATA D2 / CST / DATA D3 / .01/

C These three DATA statements initialize D1,D2,D3 with the sameC value; 1/100 in single precision if no IMPLICIT, in doubleC precision if IMPLICIT. For D1 and D2, the effect is similarC to PARAMETER (D1 = .01D0) and PARAMETER (D2 = CST)C For D3, the effect is different to PARAMETER (D3 = .01). IfC IMPLICIT is used, D3 is double precision, but the constant.01C is evaluated in double precision (9.2)

WRITE (UNIT=10, FMT=*) D1

C If IMPLICIT is present D1 is written with more digits than ifC it is omitted.

WRITE (UNIT=10,FMT=20) D2 FORMAT (F8.6)

C D2 is written with the same number of digits, IMPLICIT being

Page 132: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

8-16 47 A2 15UL Rev02

C present or not.

END ].PROCESSOR-DEPENDENT.!

Page 133: FORTRAN 77 Reference Manual - Bull

Specification Statements

47 A2 15UL Rev02 8-17

8.6 PARAMETER STATEMENT

A PARAMETER statement is used to give a constant a symbolic name.

The form of a PARAMETER statement is:

PARAMETER (p=e [,p=e]...)

where:

p is a symbolic namee is a constant expression (6.7)

If the symbolic name p is of type integer, real, double precision, or complex, thecorresponding expression e must be an arithmetic constant expression (6.1.3). If thesymbolic name p is of type character or logical, the corresponding expression e must bea character constant expression (6.2.3) or a logical constant expression (6.4.4),respectively.

Each p is the symbolic name of a constant that becomes defined with the valuedetermined from the expression e that appears on the right of the equals, in accordancewith the rules for assignment statements (10.1, 10.2, and 10.4).

Any symbolic name of a constant that appears in an expression e must have beendefined previously in the same or a different PARAMETER statement in the sameprogram unit.

A symbolic name of a constant must not become defined more than once in a programunit.

If a symbolic name of a constant is not of default implied type, its type must be specifiedby a type-statement or IMPLICIT statement prior to its first appearance in aPARAMETER statement. If the length specified for the symbolic name of a constant oftype character is not the default length of one, its length must be specified in a type-statement or IMPLICIT statement prior to the first appearance of the symbolic name ofthe constant. Its length must not be changed by subsequent statements includingIMPLICIT statements.

Once such a symbolic name is defined, that name may appear in that program unit inany subsequent statement as a primary in an expression or in a DATA statement (9.1). Asymbolic name of a constant must not be part of a format specification. A symbolic nameof a constant must not be used to form part of another constant, for example, any part ofa complex constant.

Page 134: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

8-18 47 A2 15UL Rev02

A symbolic name in a PARAMETER statement may identify only the correspondingconstant in that program unit.

! PROCESSOR-DEPENDENT [

Example:

The following are examples of PARAMETER statements in a PROGRAM unit.

PROGRAM P IMPLICIT REAL (A-Z) CHARACTER * 3 C1 CHARACTER *(*) C2, C3 PARAMETER (PI = 3.14159) PARAMETER (TWOPI = PI * 2.0) PARAMETER (C1 = 'AB')

C (This means C1 is a character constant of the threecharactersC A, B, and blanks, in this order.)

PARAMETER (C2 = 'AB')

C (This means C2 is a character constant of the two characters,C A and B, in this order.)

PARAMETER (C3 = C1 // C2)

C This means C3 is a character constant of the five charactersC A, B, blank, A, and B, in this order

END ].PROCESSOR-DEPENDENT.!

Page 135: FORTRAN 77 Reference Manual - Bull

Specification Statements

47 A2 15UL Rev02 8-19

8.7 EXTERNAL STATEMENT

An EXTERNAL statement is used to identify a symbolic name as representing anexternal procedure or dummy procedure, and to permit such a name to be used as anactual argument.

The form of an EXTERNAL statement is:

EXTERNAL proc [,proc]...

where each proc is the name of an external procedure, dummy procedure, or block datasubprogram.

Appearance of a name in an EXTERNAL statement declares that name to be anexternal procedure name, dummy procedure name, or block data subprogram name. Ifan external procedure name or a dummy procedure name is used as an actualargument in a program unit, it must appear in an EXTERNAL statement in that programunit. Note that a statement function name must not appear in an EXTERNAL statement.

If an intrinsic function name appears in an EXTERNAL statement in a program unit, thatname becomes the name of some external procedure and an intrinsic function of thesame name is not available for reference in the program unit.

Only one appearance of a symbolic name in all of the EXTERNAL statements of aprogram unit is permitted.

! PROCESSOR-DEPENDENT [ The following is an example of an EXTERNALstatement

Example 1:

EXTERNAL COTAN

This declares that COTAN is not an intrinsic function. A = COTAN (0.0) END

Page 136: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

8-20 47 A2 15UL Rev02

The following is an example of the used EXTERNAL statements:

Example 2:

EXTERNAL S

C This is useless because there is no ambiguity in the use ofS.

EXTERNAL SUB, FUN

C This is necessary to declare SUB and FUN as procedure insteadC of implicitly declared variables.

END

C SUB and FUN may subsequently be used as follows SUBROUTINE S(X, Y) CALL X(A) B = Y(C) !

END ].PROCESSOR-DEPENDENT.!

Page 137: FORTRAN 77 Reference Manual - Bull

Specification Statements

47 A2 15UL Rev02 8-21

8.8 INTRINSIC STATEMENT

An INTRINSIC statement is used to identify a symbolic name as representing an intrinsicfunction (15.3). It also permits a name that represents a specific intrinsic function to beused as an actual argument.

The form of an INTRINSIC statement is:

INTRINSIC fun [,fun]...

where each fun is an intrinsic function name.

Appearance of a name in an INTRINSIC statement declares that name to be an intrinsicfunction name. If a specific name of an intrinsic function is used as an actual argumentin a program unit, it must appear in an INTRINSIC statement in that program unit. Asindicated in the table of intrinsic functions, the following function names must not beused as actual arguments.

For type conversion:

[ NEW ANSI77 [

INT IFIX IDINT FLOAT SNGLREAL DBLE CMPLX ICHAR CHARIQINT HFIX SNGLQ DFLOAT DBLEQDREAL QEXT QFLOAT QEXTD DCMPLXCSNGL CDBLE CINT CDINT

For lexical relationship:

LGE LGT LLE LLT

For choosing the largest or smallest value

MAX MAX0 AMAX1 DMAX1 AMAX0MAX1 MIN MIN0 AMIN1 DMIN1AMIN0 MIN1 QMAX1 QMAX0 QMIN1QMIN0 ].NEW ANSI77. ]

Intrinsic functions that have generic names but no specific names may not be passed asan argument (15.3.1).

The appearance of a generic function name in an INTRINSIC statement does not causethat name to lose its generic property.

Only one appearance of a symbolic name in all of the INTRINSIC statements of aprogram unit is permitted. Note that a symbolic name must not appear in both anEXTERNAL and an INTRINSIC statement in a program unit.

Page 138: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

8-22 47 A2 15UL Rev02

! PROCESSOR-DEPENDENT [

Example:

The following are examples of INTRINSIC statements:

QUADRUPLE PRECISION Q INTRINSIC QEXT

C This specifies that the DPS7 FORTRAN 77 supplied intrinsic CC function QEXT is voluntarily used.

INTRINSIC SIN

C This specifies that the specific name SIN is used as actualC argument, but SIN may also be use as a generic name. Q = QEXT (-1) CALL INTEGRAL (SIN)

C With this, the specific name SIN is passed. Q = SIN (Q)

C The generic name SIN is used to denote the QSIN function. ENDAn intrinsic function can be used as an argument as follows:

SUBROUTINE INTEGRAL (X)A = X (0.E0)ENDNote that we may have used QSIN instead of X, as follows:

SUBROUTINE INTEGRAL (QSIN)A = QSIN (O.E0)QSIN is not the specific function QSIN, but the specific function C SIN of type singleprecision, according to the CALL.

END].PROCESSOR-DEPENDENT.!

Page 139: FORTRAN 77 Reference Manual - Bull

Specification Statements

47 A2 15UL Rev02 8-23

8.9 SAVE STATEMENT

A SAVE statement is used to retain the definition status of an entity after the execution ofa RETURN or END statement in a subprogram.

Within a function or subroutine subprogram, an entity specified by a SAVE statementdoes not become undefined as a result of the execution of a RETURN or END statementin the subprogram. However, such an entity in a common block may become undefinedor redefined in another program unit.

The form of a SAVE statement is:

SAVE [a [,a]...]

This is where each a is a named common block name preceded and followed by a slash,a variable name, or an array name. Redundant appearances of an item are notpermitted.

Dummy argument names, procedure names, and names of entities in a common blockmust not appear in a SAVE statement.

A SAVE statement without a list is treated as though it contains the names of allallowable items in that program unit.

The appearance of a common block name preceded and followed by a slash in a SAVEstatement has the effect of specifying all the entities in that common block.

If a particular common block name is specified by a SAVE statement in a subprogram ofan executable program, it must be specified by a SAVE statement in every subprogramin which that common block appears.

A SAVE statement is optional in a main program and has no effect.

If a named common block is specified in a SAVE statement in a subprogram, the currentvalues of the entities in the common block storage sequence (8.3.3) at the time aRETURN or END statement is executed are made available to the next program unit thatspecifies that common block name in the execution sequence of an executable program.

If a named common block is specified in the main program unit, the current values of thecommon block storage sequence are made available to each subprogram that specifiesthat named common block; a SAVE statement in the subprogram has no effect.

The definition status of each entity in the named common block storage sequencedepends on the association that has been established for the common block storagesequence (17.2 and 17.3).

If a local entity that is specified by a SAVE statement and is not in a common block is ina defined state at the time a RETURN or END statement is executed in a subprogram,that entity is defined with the same value at the next reference of that subprogram.

Page 140: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

8-24 47 A2 15UL Rev02

The execution of a RETURN statement or an END statement within a subprogramcauses all entities within the subprogram to become undefined except for the following:

1. Entities specified by SAVE statements

2. Entities in blank common

3. Initially defined entities that have neither been redefined nor become undefined

4. Entities in a named common block that appears in the subprogram and appears inat least one other program unit that is referencing, either directly or indirectly, thatsubprogram.

! PROCESSOR-DEPENDENT [ In DPS7 FORTRAN 77:

1. All COMMON variables are assumed specified SAVE.

2. If a variable or array name, not specified in a SAVE statement, is specified asequivalent with a variable or array name specified in a SAVE statement, it has theeffect of specifying it SAVE.

3. If a variable or array name is initially defined by means of a DATA statement, it hasthe effect of specifying it SAVE.

4. If the amount of memory needed by non specified SAVE variables or arrayelements is too large, the compiler may allocate them as SAVE, and notify it by awarning message. This is due to the fact that non SAVE data is dynamicallyallocated on entry in the program unit or package unit, and deallocated on exit.

Page 141: FORTRAN 77 Reference Manual - Bull

Specification Statements

47 A2 15UL Rev02 8-25

Example:

The following is an example of a SAVE statement in a subroutine procedure:

SUBROUTINE INIT SAVE I I = 0 RETURN ENTRY COUNT I = I + 1 RETURN END

C The following is the same but without SAVE statement. J isC allocated on entry to DEFINE or to UNDEFINE, and deallocatedC on RETURN

SUBROUTINE DEFINE J = 0 RETURN ENTRY UNDEFINE J = J + 1 RETURN END

C The following illustrates the use of the SAVE statement PROGRAM P CALL INIT

C The value of I is 0.

CALL COUNT

C The value of I is 1.

CALL DEFINE

C The value of J is undefined.

CALL UNDEFINE

C This call may have produced a fixed point overflow exception.

END ].PROCESSOR-DEPENDENT.!

[ NEW ANSI77 [

Page 142: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

8-26 47 A2 15UL Rev02

8.10 NAMELIST STATEMENT

A NAMELIST statement is used to provide a name for a group of variables and arrays,for the purpose of input/output. The form of a NAMELIST statement is:

NAMELIST /nam/nlist [/nam/nlist]...

where:

nam is a symbolic namelist is a list (2.10) of variables names, and array names

A READ or WRITE statement may specify nam as the format identifier (12.4). In thatcase the READ or WRITE statement uses namelist editing (13.7). ].NEW ANSI77. ]

Page 143: FORTRAN 77 Reference Manual - Bull

47 A2 15UL Rev02 9-1

9. Data Statement

A DATA statement is used to provide initial values for variables, arrays, array elements,and substrings. [ NEW ANSI77 [ A DATA statement is nonexecutable and may appearin a program unit anywhere after the implicit statements, if any. ].NEW ANSI77. ]

All initially defined entities are defined when an executable program begins execution. Allentities not initially defined, or associated with an initially defined entity, are undefined atthe beginning of execution of an executable program.

9.1 FORM OF A DATA STATEMENT

The form of a DATA statement is:

DATA nlist/clist/ [[,] nlist/clist/]...

where:

nlist is a list (2.10) of variable names, array names, arrayelement names, substring names, and implied-DO lists

clist is a list of the form:

a [,a]...

where a is one of the forms:

c r*c

c : is a constant or the symbolic name of a constantr : is a nonzero, unsigned, integer constant or the symbolic

name of such a constant. The r*c form is equivalent to rsuccessive appearances of the constant c.

Page 144: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

9-2 47 A2 15UL Rev02

9.2 DATA STATEMENT RESTRICTIONS

Names of dummy arguments, functions, and entities in blank common (including entitiesassociated with an entity in blank common) must not appear in the list nlist. Names ofentities in a named common block may appear in the list nlist only within a block datasubprogram.

There must be the same number of items specified by each list nlist and itscorresponding list clist. There is a one-to-one correspondence between the itemsspecified by nlist and the constants specified by clist such that the first item of nlistcorresponds to the first constant of clist, etc. By this correspondence, the initial value isestablished and the entity is initially defined. If an array name without a subscript is in thelist, there must be one constant for each element of that array. The ordering of arrayelements is determined by the array element subscript value (5.2.4).

The type of the nlist entity and the type of the corresponding[ clist constant must agreewhen either is of type character, logical, or short logical. [ NEW ANSI77 [ When the nlistentity is of type integer, real, double precision, complex, short integer, quadrupleprecision, or complex double precision, the corresponding clist constant must also be oftype integer, real, double precision, complex, short integer, quadruple precision, orcomplex double precision. ].NEW ANSI77. ]

If necessary, the clist constant is converted to the type of the nlist entity according to therules for arithmetic conversion (Table 10-1).

[ NEW ANSI77 [ Note that if an nlist entity is of type double[ precision, quadrupleprecision or complex double precision and the clist constant is of type real or complex, orif an nlist entity is of type quadruple precision and the clist constant is of type doubleprecision or complex double precision, the processor may supply more precision derivedfrom the constant than can be contained in a real or double precision datum.

A hexadecimal constant is allowed for the clist constant, for any type of nlist variable,provided that the length of the hexadecimal be equal to the number of storage units usedfor the variable. ].NEW ANSI77. ]

Page 145: FORTRAN 77 Reference Manual - Bull

Data Statement

47 A2 15UL Rev02 9-3

Example:

! PROCESSOR-DEPENDENT [

More precision derived from the constant in DATA PROGRAM E325 REAL D5 DOUBLE PRECISION P1,P2,A1,A2,D1,D2,D3,D4 PARAMETER (P1=3.14159 26535) PARAMETER (P2=3.14159 26535 D+0) A1 = 3.14159 26535 A2 = 3.14159 26535 D+0 DATA D1/3.14159 26535/ DATA D2/3.14159 26535 D+0/ DATA D3/P1/ DATA D4/P2/ DATA D5/3.14159 26535/C P1 = A1 = D3 = D5, and this value is less accurate,C relative to PI, than the following:C P2 = A2 = D1 = D2 = D4 END ].PROCESSOR-DEPENDENT.!

Any variable, array element, or substring may be initially defined except for:

1. an entity that is a dummy argument,

2. an entity in blank common, which includes an entity associated with an entity inblank common, or

3. a variable in a function subprogram whose name is also the name of the functionsubprogram or an entry in the function subprogram.

A variable, array element, or substring must not be initially defined more than once in anexecutable program. If two entities are associated, only one may be initially defined in aDATA statement in the same executable program.

Each subscript expression in the list nlist must be an integer constant expression exceptfor implied-DO-variables as noted in 9.3. Each substring expression in the list nlist mustbe an integer constant expression.

Page 146: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

9-4 47 A2 15UL Rev02

9.3 IMPLIED-DO IN A DATA STATEMENT

The form of an implied-DO list in a DATA statement is:

(dlist, i = m1, m2 [,m3 ])

where:

dlist is a list of array element names and implied-DO listsi is the name of an integer variable, called the implied-DO-

variablem1, m2,m3 are each an integer constant expression, except that the

expression may contain implied-DO-variables of otherimplied-DO lists that have this implied-DO list within theirranges.

The range of an implied-DO list is the list dlist. An iteration count and the values of theimplied-DO-variable are established from m1, m2, and m3 exactly as for a DO-loop(11.10), except that the iteration count must be positive. When an implied-DO listappears in a DATA statement, the list items in dlist are specified once for each iterationof the implied-DO list with the appropriate substitution of values for any occurrence of theimplied-DO-variable i. The appearance of an implied-DO-variable name in a DATAstatement does not affect the definition status of a variable of the same name in thesame program unit.

Each subscript expression in the list dlist must be an integer constant expression, exceptthat the expression may contain implied-DO-variables of implied-DO lists that have thesubscript expression within their ranges.

The following is an example of a DATA statement that contains implied-DO lists:

DATA ((X(J,I), I=1,J), J=1,5) / 15*0. /

Page 147: FORTRAN 77 Reference Manual - Bull

Data Statement

47 A2 15UL Rev02 9-5

9.4 CHARACTER CONSTANT IN A DATA STATEMENT

[ NEW ANSI77 [ An entity in the list nlist that corresponds to a character constant mustbe of type character, or integer. ].NEW ANSI77. ]

If the length of the character entity in the list nlist is greater than the length of itscorresponding character constant, the additional rightmost characters in the entity areinitially defined with blank characters.

If the length of the character entity in the list nlist is less than the length of itscorresponding character constant, the additional rightmost characters in the constant areignored.

Note that initial definition of a character entity causes definition of all of the characters inthe entity, and that each character constant initially defines exactly one variable, arrayelement, or substring.

Page 148: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

9-6 47 A2 15UL Rev02

9.5 HOLLERITH CONSTANT IN A DATA STATEMENT

[ NEW ANSI77 [ All data types except for character entity may be initially defined with aHollerith datum by a DATA statement.

A Hollerith constant may appear in the list clist, and the corresponding entity in the listnlist must not be of type character.

For an entity not of type character, the number of characters n in the correspondingHollerith constant must be less than or equal to the number of character storage unitsoccupied by the entity. ].NEW ANSI77. ]

The following are examples of DATA statements:

! PROCESSOR-DEPENDENT [

Example:

C This gives gives the minimum and maximum values of integers. DATA IMIN / '80000000'Z / DATA IMAX / '7FFFFFFF'Z /C This gives the minimum and maximum values of positive reals. DATA RMIN,RMAX /'00100000'Z,'7FFFFFFF'Z/C The following example gives the zero value of reals. DATA ZERO /'00000000'Z/C This gives the minimum and maximum absolute values ofnegativeC reals. DATA RNMIN,RNMAX /'FFFFFFFF'Z,'80100000'Z/C This is a double precision array initially defined with the CC maximum value, with the character & in column 6. DOUBLE PRECISION T (100,100) DATA ((T(J,I), I=1,100), J=1,100) &/10000 * '7FFFFFFFFFFFFFFF'Z/C the following is an example of character truncation andC padding CHARACTER * 3 ARRAY (2) DATA ARRAY / 'ABCD', 'EF'/C the value of ARRAY (1) is 'ABC'C the value of ARRAY (2) is 'EF 'C The same effect would be achieved by the following DATAC statements CHARACTER * 3 ARRAY (2) DATA ARRAY(1)/'ABC'/ DATA ARRAY(2) (1:2)/'AB'/ DATA ARRAY(2) (3:3)/' '/ ].PROCESSOR-DEPENDENT.!

Page 149: FORTRAN 77 Reference Manual - Bull

47 A2 15UL Rev02 10-1

10. Assignment Statements

Completion of execution of an assignment statement causes definition of an entity.

There are four kinds of assignment statements:

1. Arithmetic

2. Logical

3. Statement label (ASSIGN)

4. Character

10.1 ARITHMETIC ASSIGNMENT STATEMENT

The form of an arithmetic assignment statement is:

v = e

[ NEW ANSI77 [

where:

v is the name of a variable or array element of type integer,real, double precision, complex, short integer, quadrupleprecision, or complex double precision. ].NEW ANSI77. ]

e is an arithmetic expression

Execution of an arithmetic assignment statement causes the evaluation of theexpression e by the rules in Section 6, conversion of e to the type of v, and definition andassignment of v with the resulting value, as established by the rules in Table 10-1.

Page 150: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

10-2 47 A2 15UL Rev02

Table 10-1. Arithmetic Conversion and Assignment of e to v

Value Ass igned

! PROCESSOR-DEPENDENT [ The functions in the "Value Assigned" column of Table10-1 are generic functions described in Table 15-1.

Page 151: FORTRAN 77 Reference Manual - Bull

Assignment Statements

47 A2 15UL Rev02 10-3

Example:

The following are examples of arithmetic assignment statements:

INTEGER*2 IS1,IS2 INTEGER I1, I2 (10) REAL R1, R2 (10) DOUBLE PRECISION D COMPLEX CC assignment without conversion IS1 = IS1 + IS2 I2 (1) = I1 R1 = R2(10) + R1C assignment with implicit conversion (note that constant 1 is of type integer) I1 = IS1 I1 = R1 + R2 C = D R = 1 IS1 = 1C Same assignments with explicit conversion by use ofC intrinsic functions. This produces the same results. I1 = INT (IS1) I1 = INT (R1 + R2) C = CMPLX (D)10 R = REAL (1) IS1 = HFIX (1)C instead of writing the assignment labeled 10, it is moreC natural to write: R = 1.0].PROCESSOR-DEPENDENT.!

Page 152: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

10-4 47 A2 15UL Rev02

10.2 LOGICAL ASSIGNMENT STATEMENT

The form of a logical assignment statement is:

v = e

[ NEW ANSI77 [

where:

v is the name of a logical variable, logical array element, shortlogical variable, or short logical array element ].NEWANSI77. ]

e is a logical expression

Expression of a logical assignment statement causes the evaluation of the logicalexpression e and the assignment and definition of v with the value of e. Note that e musthave a value of either true or false.

[ NEW ANSI77 [ If v is of type logical and e of type short logical, or if v is of type shortlogical and e of type logical, the value of e is converted to the type of v beforeassignment.

Note that a relation expression is always of type logical, even if it compares short logicaloperands. ].NEW ANSI77. ]

! PROCESSOR-DEPENDENT [

Page 153: FORTRAN 77 Reference Manual - Bull

Assignment Statements

47 A2 15UL Rev02 10-5

Example:

The following are examples of logical assignments:

LOGICAL L1, L2 (10) INTEGER I1, I2 LOGICAL * 1 SL1, SL2 (10)

C assignment without conversion L1 = L2 (10) .AND. L2 (2) L1 = I1 .EQ. I2C this results with the value .TRUE. for L1 if the values of I1C and I2 are equal, and otherwise with the value FALSE. for L1. L1 = L2(1) .EQV. L2(2)C this results with the value .TRUE. for L1 if the valuesC of L2(1) and L2(2) are equal, and otherwise with the valueC .FALSE. for L2. SL1 = SL2(1) .AND. SL2(2)C assignments with implicit conversion from type short logicalC to C type logical L1 = SL1 L1 = SL2(1) .AND. SL2(2)C assignments with implicit conversion from type logicalC to type short logical (there are no intrinsic functions toC perform this conversion explicitly) SL1 = L1 SL1 = L2(1) .AND. L2(2) SL1 = SL2(1) .EQV. SL2(2) SL1 = .TRUE. SL1 = .FALSE.].PROCESSOR-DEPENDENT.!

Page 154: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

10-6 47 A2 15UL Rev02

10.3 STATEMENT LABEL ASSIGNMENT (ASSIGN) STATEMENT

The form of a statement label assignment statement is:

ASSIGN s TO i

where:

s is a statement labeli is an integer variable name

Execution of an ASSIGN statement causes the statement label s to be assigned to theinteger variable i. The statement label must be the label of a statement that appears inthe same program unit as the ASSIGN statement. The statement label must be the labelof an executable statement or a FORMAT statement.

Execution of a statement label assignment statement is the only way that a variable maybe defined with a statement label value.

A variable must be defined with a statement label value when referenced in an assignedGO TO statement (11.3) or as a format identifier (12.4) in an input/output statement.While defined with a statement label value, the variable must not be referenced in anyother way.

An integer variable defined with a statement label value may be redefined with the sameor a different statement label value or an integer value.

! PROCESSOR-DEPENDENT [

Page 155: FORTRAN 77 Reference Manual - Bull

Assignment Statements

47 A2 15UL Rev02 10-7

Example:

The following are examples of ASSIGN statements:

ASSIGN 10 TO I ASSIGN 20 TO J 20 FORMAT (I5) WRITE (UNIT=6, FMT=J) KC produces the same effect as WRITE (UNIT=6, FMT=20) K

GOTO IC produces the same effect as GOTO 10 10 must be the label of an executable statement 10 RETURN

C The following is correct I = J + 1 T(I) = 1 ASSIGN 10 TO I GOTO I

C the following is not correct I = J + 1 GOTO I

C the following is not correct ASSIGN 10 TO I T(I) = 1].PROCESSOR-DEPENDENT.!

Page 156: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

10-8 47 A2 15UL Rev02

10.4 CHARACTER ASSIGNMENT STATEMENT

The form of a character assignment statement is:

v = e

where:

v is the name of a character variable, character array element,or character substring

e is a character expression

Execution of a character assignment statement causes the evaluation of the expressione and the assignment and definition of v with the value of e. None of the characterpositions being defined in v may be referenced in e. v and e may have different lengths.If the length of v is greater than the length of e, the effect is as though e were extendedto the right with blank characters until it is the same length as v and then assigned. If thelength of v is less than the length of e, the effect is as though e were truncated from theright until it is the same length as v and then assigned.

Only as much of the value of e must be defined as is needed to define v. In the example:

CHARACTER A*2, B*4A=B

the assignment A=B requires that the substring B(1:2) be defined.

It does not require that the substring B(3:4) be defined.

If v is a substring, e is assigned only to be substring. The definition status of substringsnot specified by v is unchanged.

! PROCESSOR-DEPENDENT [

Page 157: FORTRAN 77 Reference Manual - Bull

Assignment Statements

47 A2 15UL Rev02 10-9

Example:

The following are examples of character assignment statements:

CHARACTER * 3 A,B CHARACTER * 4 C,D

C assignments without truncation nor padding: A = '123' B = A C(1:3) = B C(4:4) = '4' D = A//C(4:4)

C as a result, the value of A and B are the threeC characters 1, 2, and 3 in this orderC the value of C and D are the four characters 1, 2, 3, 4C in this order

C assignment with truncation or padding: A = '12' B = A C = B D = '12345'C as a result, the value of A and B are '12 ',C the value of C is '12 'C the value of D is '1234'].PROCESSOR-DEPENDENT.!

Page 158: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

10-10 47 A2 15UL Rev02

Page 159: FORTRAN 77 Reference Manual - Bull

47 A2 15UL Rev02 11-1

11. Control Statements

Control statements may be used to control the execution sequence.

There are sixteen control statements:

1. Unconditional GOTO

2. Computed GOTO

3. Assigned GOTO

4. Arithmetic IF

5. Logical IF

6. Block IF

7. ELSE IF

8. ELSE

9. END IF

10. DO

11. CONTINUE

12. STOP

13. PAUSE

14. END

15. CALL

16. RETURN

The CALL and RETURN statements are described in Section 15.

Page 160: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

11-2 47 A2 15UL Rev02

11.1 UNCONDITIONAL GOTO STATEMENT

The form of an unconditional GOTO statement is:

GOTO s

where s is the statement label of an executable statement that appears in the sameprogram unit as the unconditional GOTO statement.

Execution of an unconditional GOTO statement causes a transfer of control so that thestatement identified by the statement label is executed next.

Example:

! PROCESSOR-DEPENDENT [

The following are examples of unconditional GOTO statements:

GOTO 1010 DO 20 I = 1, N GOTO 3020 CONTINUE30 IF (I .EQ.J) THEN GOTO 40 ENDIF40 CONTINUEC the GOTO may transfer control from a DO or IF blockC to its containing blocks.C a GOTO may not transfer control into a DO or IFC block from its containing blocks.CC the following GOTO statements are forbidden GOTO 50 IF (I.EQ.J) THEN50 A = B ENDIF DO 70 I = 1, N60 T(I) = I70 CONTINUE GOTO 60].PROCESSOR-DEPENDENT.!

Page 161: FORTRAN 77 Reference Manual - Bull

Control Statements

47 A2 15UL Rev02 11-3

11.2 COMPUTED GOTO STATEMENTS

The form of a computed GOTO statement is:

GOTO (s [,s]...)[,]i

[ NEW ANSI77 [

where:

i is an integer, short integer, real, double precision orquadruple precision expression. ].NEW ANSI77. ]

s is the statement label of an executable statement thatappears in the same program unit as the computed GOTOstatement. The same statement label may appear morethan once in the same computed GOTO statement.

Execution of a computed GOTO statement causes evaluation of the expression i. Theevaluation of i is followed by a transfer of control so that the statement identified by theith statement label in the list of statement labels is executed next, provided that 1 < = i <= n, where n is the number of statement labels in the list of statement labels. If i<1 or i>n,the execution sequence continues as though a CONTINUE statement were executed.

Example:

The following are examples of computed GOTO statements

I = 2 GOTO (10,20) IC transfer control to label 20 I = 3 GOTO (10,20) I30 CONTINUEC transfer control to label 30

Page 162: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

11-4 47 A2 15UL Rev02

11.3 ASSIGNED GOTO STATEMENT

The form of an assigned GOTO statement is:

GOTO i [[,] (s [,s]...)]

where:

i is an integer variable names is the statement label of an executable statement that

appears in the same program unit as the assigned GOTOstatement. The same statement label may appear morethan once in the same assigned GOTO statement.

At the time of execution of an assigned GOTO statement, the variable i must be definedwith the value of a statement label of an executable statement that appears in the sameprogram unit.

Note that the variable may be defined with a statement label value only by an ASSIGNstatement (10.3) in the same program unit as the assigned GOTO statement. Theexecution of the assigned GOTO statement causes a transfer of control so that thestatement identified by that statement label is executed next.

If the parenthesized list is present, the statement label assigned to i must be one of thestatement labels in the list.

! PROCESSOR-DEPENDENT [

Example:

The following are examples of assigned GOTO statements:

ASSIGN 10 TO I ASSIGN 20 TO J GOTO IC transfer control to label 1030 GOTO J (10,20)C transfer control to label 20

C the following GOTO's are not correct:40 I = I + 1 GOTO I50 ASSIGN 30 TO J GOTO (10,20) J ].PROCESSOR-DEPENDENT.!

Page 163: FORTRAN 77 Reference Manual - Bull

Control Statements

47 A2 15UL Rev02 11-5

11.4 ARITHMETIC IF STATEMENT

The form of an arithmetic IF statement is:

IF (e) s 1 , s 2 , s 3

[ NEW ANSI77 [

where:

e is an integer, real, double precision, short integer orquadruple precision expression ].NEW ANSI77. ]

s1 , s2 , and s3 are each the statement label of an executable statementthat appears in the same program unit as the arithmetic IFstatement. The same statement label may appear morethan once in the same arithmetic IF statement.

Execution of an arithmetic IF statement causes evaluation of the expression e followedby a transfer of control. The statement identified by s1 , s2 , or s3 is executed next as thevalue of e is less than zero, equal to zero, or greater than zero, respectively.

! PROCESSOR-DEPENDENT [

Example:

The following is an example of an arithmetic IF statement:

READ (UNIT=6, IOSTAT=I) A IF (I) 10, 20, 30C transfer control to label 10 if I is negative (end ofC file), which is the condition in this example, to labelC 20 if I is zero (no error in this example), to label 30C if I is positive (input/output error in this example) ].PROCESSOR-DEPENDENT.!

Page 164: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

11-6 47 A2 15UL Rev02

11.5 LOGICAL IF STATEMENT

The form of a logical IF statement is:

IF (e) st

where:

e is a logical expressionst is any executable statement except a DO, block IF, ELSE

IF, ELSE, END IF, END, or another logical IF statement.

Execution of a logical IF statement causes evaluation of the expression e. If the value ofe is true, statement st is executed.If the value of e is false, statement st is not executed and the execution sequencecontinues as though a CONTINUE statement were executed.

Note that the execution of a function reference in the expression e of a logical IFstatement is permitted to affect entities in the statement st.

! PROCESSOR-DEPENDENT [

Example:

The following is an example of a logical IF statement:

DIMENSION T(N) DO 10 I = 1,N IF (T(I).NE. 0.) T(I) = 1.0/T(I)10 CONTINUE ].PROCESSOR-DEPENDENT.!

Page 165: FORTRAN 77 Reference Manual - Bull

Control Statements

47 A2 15UL Rev02 11-7

11.6 BLOCK IF STATEMENT

The block IF statement is used with the END IF statement and optionally, the ELSE IFand ELSE statements to control the execution sequence.

The form of a block IF statement is:

IF (e) THEN

where:

e is a logical expression.

11.6.1 IF-Level

The IF-level of a statement s is

n1 - n 2

where n1 is the number of block IF statements from the beginning of the program unit upto and including s, and n2 is the number of END IF statements in the program unit up tobut not including s.

The IF-level of every statement must be zero or positive. The IF-level of each block IF,ELSE IF, ELSE, and END IF statement must be positive. The IF-level of the ENDstatement of each program unit must be zero.

11.6.2 IF-Block

An IF-block consists of all of the executable statements that appear following the blockIF statement up to, but not including, the next ELSE IF, ELSE, or END IF statement thathas the same IF-level as the block IF statement. An IF-block may be empty.

Page 166: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

11-8 47 A2 15UL Rev02

11.6.3 Execution of a Block IF Statement

Execution of a block IF statement causes evaluation of the expression e. If the value of eis true, normal execution sequence continues with the first statement of the IF-block. Ifthe value of e is true and the IF-block is empty, control is transferred to the next END IFstatement that has the same IF-level as the block IF statement. If the value of e is false,control is transferred to the next ELSE IF, ELSE, or END IF statement that has the sameIF-level as the block IF statement.

Transfer of control into an IF-block from outside the IF-block is prohibited.

If the execution of the last statement in the IF-block does not result in a transfer ofcontrol, control is transferred to the next END IF statement that has the same IF-level asthe block IF statement that precedes the IF-block.

Page 167: FORTRAN 77 Reference Manual - Bull

Control Statements

47 A2 15UL Rev02 11-9

11.7 ELSE IF STATEMENT

The form of an ELSE IF statement is:

ELSE IF (e) THEN

where:

e is a logical expression.

11.7.1 ELSE IF-Block

An ELSE IF-block consists of all of the executable statements that appear following theELSE IF statement up to, but not including, the next ELSE IF, ELSE, or END IFstatement that has the same IF-level as the ELSE IF statement. An ELSE IF-block maybe empty.

11.7.2 Execution of an ELSE IF Statement

Execution of an ELSE IF statement causes evaluation of the expression e. If the value ofe is true, normal execution sequence continues with the first statement of the ELSE IF-block. If the value of e is true and the ELSE IF-block is empty, control is transferred tothe next END IF statement that has the same IF-level as the ELSE IF-statement. If thevalue of e is false, control is transferred to the next ELSE IF, ELSE, or END IF statementthat has the same IF-level as the ELSE IF statement.

Transfer of control into an ELSE IF-block from outside the ELSE IF-block is prohibited.The statement label, if any, of the ELSE IF statement must not be referenced by anystatement.If execution of the last statement in the ELSE IF-block does not result in a transfer ofcontrol, control is transferred to the next END IF statement that has the same IF-level asthe ELSE IF statement that precedes the ELSE IF-block.

Page 168: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

11-10 47 A2 15UL Rev02

11.8 ELSE STATEMENT

The form of an ELSE statement is:

ELSE

11.8.1 ELSE-Block

An ELSE-block consists of all of the executable statements that appear following theELSE statement up to, but not including, the next END IF statement that has the sameIF-level as the ELSE statement. An ELSE-block may be empty.

An END IF statement of the same IF-level as the ELSE statement must appear beforethe appearance of an ELSE IF or ELSE statement of the same IF-level.

11.8.2 Execution of an ELSE Statement

Execution of an ELSE statement has no effect.Transfer of control into an ELSE-block from outside the ELSE-block is prohibited. Thestatement label, if any, of an ELSE statement must not be referenced by any statement.

Page 169: FORTRAN 77 Reference Manual - Bull

Control Statements

47 A2 15UL Rev02 11-11

11.9 END IF STATEMENT

The form of an END IF statement is:

END IF

Execution of an END IF statement has no effect.

For each block IF statement there must be a corresponding END IF statement in thesame program unit. A corresponding_END_IF statement is the next END IF statementthat has the same IF-level as the block IF statement.

! PROCESSOR-DEPENDENT [

Example:

The following are examples of IF-block statements:

C IF-block to perform usual IF, THEN, ELSE IF (B.NE.0.) THEN Q = A/B ELSE Q = 0. ENDIFC IF block to perform a case of IF (I = 1) THEN A = A1 ELSEIF (I = 2) THEN A = A2 ELSEIF (I = 3) THEN A = A3 ELSE A = 0. ENDIFC the following programming produces the same result as previousC case of, but does not keep the symmetry of the first threeC possibilities IF (I = 1) THEN A = A1 ELSE IF (I = 2) THEN A = A2 ELSE IF (I = 3) THEN A = A3 ELSE A = 0. ENDIF ENDIF ENDIF].PROCESSOR-DEPENDENT.!

Page 170: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

11-12 47 A2 15UL Rev02

11.10 DO STATEMENT

A DO statement is used to specify a loop, called a DO-loop.

The form of a DO statement is:

DO s [,] i = e 1 , e 2 [,e 3]

where:

s is the statement label of an executable statement. Thestatement identified by s, called the terminal_statement of theDO-loop, must follow the DO statement in the sequence ofstatements within the same program unit as the DOstatement.

[ NEW ANSI77 [

i is the name of an integer, real, double precision, shortinteger, or quadruple precision variable, called the DO-variable.

e1, e2 and e3 are each an integer, real, double precision, short integer, orquadruple precision expression. ].NEW ANSI77. ]

The terminal statement of a DO-loop must not be an unconditional GOTO, assignedGOTO, arithmetic IF, block IF, ELSE IF, ELSE, END IF, RETURN, STOP, END, or DOstatement. If the terminal statement of a DO-loop is a logical IF statement, it may containany executable statement except a DO, block IF, ELSE IF, ELSE, END IF, END, oranother logical IF statement.

11.10.1 Range of a DO-Loop

The range_of_a_DO-loop consists of all of the executable statements that appearfollowing the DO statement that specifies the DO-loop, up to and including the terminalstatement of the DO-loop.

If a DO statement appears within the range of a DO-loop, the range of the DO-loopspecified by that DO statement must be contained entirely within the range of the outerDO-loop. More than one DO-loop may have the same terminal statement.

If a DO statement appears within an IF-block, ELSE IF-block, or ELSE-block, the range ofthat DO-loop must be contained entirely within that IF-block, ELSE IF-block, or ELSE-block, respectively.

If a block IF statement appears within the range of a DO-loop, the corresponding END IFstatement must also appear within the range of that DO-loop.

Page 171: FORTRAN 77 Reference Manual - Bull

Control Statements

47 A2 15UL Rev02 11-13

11.10.2 Active and Inactive DO-Loops

A DO-loop is either active or inactive. Initially inactive, a DO-loop becomes active onlywhen its DO statement is executed.

Once active, the DO-loop becomes inactive only when:

1. Its iteration count is tested (11.10.4) and determined to be zero.

2. A RETURN statement is executed within its range.

3. Control is transferred to a statement that is in the same program unit and is outsidethe range of the DO-loop, or

4. Any STOP statement in the executable program is executed, or execution isterminated for any other reason (12.6).

Execution of a function reference or CALL statement that appears in the range of a DO-loop does not cause the DO-loop to become inactive, except when control is returned bymeans of an alternate return specifier in a CALL statement to a statement that is not inthe range of the DO-loop.

When a DO-loop becomes inactive, the DO-variable of the Do-loop retains its last definedvalue.

11.10.3 Executing a DO Statement

The effect of executing a DO statement is to perform the following steps in sequence:

1. The initial_parameter_m1, the terminal_parameter_m2, and theincrementation_parameter_m3 are established by evaluating e1, e2, and e3,respectively, including, if necessary, conversion to the type of the DO-variableaccording to the rules for arithmetic conversion (Table 10-1). If e3 does not appear,m3 has a value of one. m3 must not have a value of zero.

2. The DO-variable becomes defined with the value of the initial parameter m1.

3. The iteration count is established and is the value of the expression

MAX( INT( (m2 - m1 + m3 )/m 3 ), 0)

Note that the iteration count is zero whenever:

m 1 > m 2 and m 3 > 0, or

m 1 < m 2 and m 3 < 0.

At the completion of execution of the DO statement, loop control processing begins.

Page 172: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

11-14 47 A2 15UL Rev02

11.10.4 Loop Control Processing

Loop control processing determines if further execution of the range of the DO-loop isrequired. The iteration count is tested.If it is not zero, execution of the first statement in the range of the DO-loop begins. If theiteration count is zero, the DO-loop becomes inactive. If, as a result, all of the DO-loopssharing the terminal statement of this DO-loop are inactive, normal execution continueswith execution of the next executable statement following the terminal statement.However, if some of the DO-loops sharing the terminal statement are active, executioncontinues with incrementation processing, as described in 11.10.7.

# OLD ANSI77 [ LEVEL = SIRIS8

If the LEVEL = SIRIS8 compilation is used, statements in the range of the DO-loops areexecuted at least one time. ].OLD ANSI77.#

11.10.5 Execution of the Range

Statements in the range of a DO-loop are executed until the terminal statement isreached. Except by the incrementation described in 11.10.7, the DO-variable of the DO-loop may neither be redefined nor become undefined during execution of the range of theDO-loop.

11.10.6 Terminal Statement Execution

Execution of the terminal statement occurs as a result of the normal execution sequenceor as a result of transfer of control, subject to the restrictions in 11.10.8. Unless executionof the terminal statement results in a transfer of control, execution then continues withincrementation processing, as described in 11.10.7.

Page 173: FORTRAN 77 Reference Manual - Bull

Control Statements

47 A2 15UL Rev02 11-15

11.10.7 Incrementation Processing

Incrementation processing has the effect of the following steps performed in sequence:

1. The DO-variable, the iteration count, and the incrementation parameter of theactive DO-loop whose DO statement was most recently executed, are selected forprocessing.

2. The value of the DO-variable is incremented by the value of the incrementationparameter m3.

3. The iteration count is decremented by one.

4. Execution continues with loop control processing (11.10.4) of the same DO-loopwhose iteration count was decremented.

For example:

N=0 DO 100 I=1,10 J=I DO 100 K=1,5 L=K100 N=N+1101 CONTINUE

After execution of these statements and at the execution of the CONTINUE statement,I=11, J=10, K=6, L=5, and N=50.

Also consider the following example:

N=O DO 200 I=1,10 J=I DO 200 K=5,1 L=K200 N=N+1201 CONTINUE

After execution of these statements and at the execution of the CONTINUE statement,I=11, J=10, K=5, and N=0. L is not defined by these statements.

Page 174: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

11-16 47 A2 15UL Rev02

11.10.8 Transfer into the Range of a DO-Loop

Transfer of control into the range of a DO-loop from outside the range is not permitted.

! PROCESSOR-DEPENDENT [

Example:

The following is an example of DO-loops

PARAMETER N = 100 DIMENSION A(N,N), B(N,N), C(N,N) DO 10 I = 1,N DO 10 J = 1,N10 A(J,I) = B(J,I) + C(J,I)C the use of the subscript (refer to paragraph 5.4.1) in theC order C (J,I) and not (I,J) may be important on a DPS7/X0withC a cache memory, as the arrays are stored in the order A(1,1),C A(2,1), C A(3,1), A(4,1), A(5,1) and a fetch to A(1,1) mayC bringalso A(2,1), A(3,1) and A(4,1) in the cache memory.C This feature may improve the execution speed of the program.].PROCESSOR-DEPENDENT.!

Page 175: FORTRAN 77 Reference Manual - Bull

Control Statements

47 A2 15UL Rev02 11-17

11.11 CONTINUE STATEMENT

The form of a CONTINUE statement is:

CONTINUE

Execution of a CONTINUE statement has no effect.

If the CONTINUE statement is the terminal statement of a DO-loop, the next statementexecuted depends on the result of the DO-loop incrementation processing (11.10.7).

Page 176: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

11-18 47 A2 15UL Rev02

11.12 STOP STATEMENT

The form of a STOP statement is:

STOP [n]

[ NEW ANSI77 [ where n is a string of not more than five digits, or is a characterconstant, or is an integer constant, or is an hexadecimal constant. ].NEW ANSI77. ]

Execution of a STOP statement causes termination of execution of the executableprogram. [ NEW ANSI77 [ At the time of termination, the digit string, character constant,integer constant or hexadecimal ].NEW ANSI77. ]

! PROCESSOR-DEPENDENT [ constant is sent to the operator console in batch modeor to the user console in interactive mode. ].PROCESSOR-DEPENDENT.!

Page 177: FORTRAN 77 Reference Manual - Bull

Control Statements

47 A2 15UL Rev02 11-19

11.13 PAUSE STATEMENT

The form of a PAUSE statement is:

PAUSE [n]

where n is a string of not more than five digits, or is a character, hexadecimal or integerconstant.

The PAUSE statement causes the executable program to stop. However, the executioncan be resumed. when the execution ceases, the digit string, character constant,hexadecimal constant, [ NEW ANSI77 [ or integer constant is sent to the operatorconsole in batch mode or to the user console in interactive mode. ].NEW ANSI77. ]

! PROCESSOR-DEPENDENT [ The program is resumed if the character stringRESUME FORTRAN is sent from the operator or user console. Note that there must beone single space between RESUME and FORTRAN.

If execution is resumed, the execution sequence continues as though a CONTINUEstatement were executed.

Example:

The following is an example of a PAUSE statement in batch mode.

PAUSE 'PHASE 1 IS FINISHED'

The following message is sent to the operator:

99/PHASE 1 IS FINISHED

Execution is resumed if the operator responds:

99 RESUME FORTRAN

Note that a more complete dialog may be achieved by using READ/WRITE statementson a unit connected by OPEN (FILE='SPECIAL=... ].PROCESSOR-DEPENDENT.!

Page 178: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

11-20 47 A2 15UL Rev02

11.14 END STATEMENT

The END statement indicates the end of the sequence of statements and comment linesof a program unit (3.5). If executed in a function or subroutine subprogram, it has theeffect of a RETURN statement (15.8). If executed in a main program, it terminates theexecution of the executable program.

The form of an END statement is:

END

An END statement is written only in columns 7 through 72 of an initial line. An ENDstatement must not be continued. No other statement in a program unit may have aninitial line that appears to be an END statement.

The last line of every program unit must be an END statement.

! PROCESSOR-DEPENDENT [ If a comment is found after the END statement, it isassumed to belong to a following program unit, leading to a fatal error if there is no moreprogram unit in the source file. ].PROCESSOR-DEPENDENT.!

Page 179: FORTRAN 77 Reference Manual - Bull

47 A2 15UL Rev02 12-1

12. INPUT/OUTPUT Statements

Input statements provide the means of transferring data from external media to internalstorage or from an internal file to internal storage. This process is called reading. Outputstatements provide the means of transferring data from internal storage to externalmedia or from internal storage to an internal file. This process is called writing. Someinput/output statements specify that editing of the data is to be performed.

In addition to the statements that transfer data, there are auxiliary input/outputstatements to manipulate the external medium, or to inquire about or describe theproperties of the connection to the external medium.

# OLD ANSI77 [

There are ten input/output statements:

1. READ

2. WRITE

3. PRINT

4. OPEN

5. CLOSE

6. INQUIRE

7. BACKSPACE

8. ENDFILE

9. REWIND

10. PUNCH

# ].OLD ANSI77.#

The READ, WRITE, PRINT, # OLD ANSI77 [ and PUNCH ].OLD ANSI77.# statementsare data_transfer input/output_statements (12.8). The OPEN, CLOSE, INQUIRE,BACKSPACE, ENDFILE, and REWIND statements are auxiliary input/output_statements(12.10). The BACKSPACE, ENDFILE, and REWIND statements arefile_positioning_input/output_statements (12.10.4).

Page 180: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

12-2 47 A2 15UL Rev02

12.1 RECORDS

A record is a sequence (2.1) of values or a sequence of characters. For example, apunched card is usually considered to be a record. However, a record does notnecessarily correspond to a physical entity, ! PROCESSOR-DEPENDENT [ an exampleis the ENDFILE record. ].PROCESSOR-DEPENDENT.! There are three kinds ofrecords:

1. Formatted

2. Unformatted

3. Endfile

12.1.1 Formatted Record

A formatted record consists of a sequence of characters that are capable ofrepresentation in the processor. The length of a formatted record is measured incharacters and depends primarily on the number of characters put into the record whenit is written. However, it may depend on the processor and the external medium. Thelength may be zero. Formatted records may be read or written by formatted input/outputstatements (12.8.1).

! PROCESSOR-DEPENDENT [ Formatted records may be prepared or used by somemeans other than FORTRAN; for example, by some manual input device, or by COBOL.].PROCESSOR-DEPENDENT.!

12.1.2 Unformatted Record

An unformatted record consists of a sequence of values in a processor-dependent formand may contain both character and non-character data or may contain no data. Thelength of an unformatted record ! PROCESSOR-DEPENDENT [ is measured incharacter storage units (bytes) ].PROCESSOR-DEPENDENT.! and depends on theoutput list (12.8.2) used when it is written, as well as on the processor and the externalmedium. The length may be zero.

! PROCESSOR-DEPENDENT [ For DPS7 FORTRAN 77, values are transferred to orfrom the file based upon the length of the storage units corresponding to the type of theoutput list elements, without additional control information in the records.].PROCESSOR-DEPENDENT.!

Unformatted records may be read or written by unformatted input/output statements(12.8.1).

Page 181: FORTRAN 77 Reference Manual - Bull

INPUT/OUTPUT Statements

47 A2 15UL Rev02 12-3

[ NEW ANSI77 [ Unformatted records may be prepared or used by some means otherthan FORTRAN; for example by COBOL.

During execution of a FORTRAN executable program, if a file is connected forunformatted data transfer it may only be accessed by unformatted input/outputstatements until it is closed; if a file is connected for formatted data transfer, it may onlybe accessed by formatted input/output statements until it is closed. ].NEW ANSI77. ]

12.1.3 Endfile Record

An endfile record is written by an ENDFILE statement. An endfile record may occur onlyas the last record of a file. An endfile record does not have a length property.

Page 182: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

12-4 47 A2 15UL Rev02

12.2 FILES

A file is a sequence (2.1) of records.

There are two kinds of files:

1. External

2. Internal

12.2.1 File Existence

At any given time, there is a processor-determined set of files that are said to exist for anexecutable program. A file may be known to the processor, yet not exist for anexecutable program at a particular time. For example, security reasons may prevent afile from existing for an executable program. A file may exist and contain no records; anexample is a newly created file not yet written.

To create a file means to cause a file to exist that did not previously exist. To delete a filemeans to terminate the existence of the file.

All input/output statements may refer to files that exist. The INQUIRE, OPEN, CLOSE,WRITE, PRINT, PUNCH and ENDFILE statements may also refer to files that do notexist.

12.2.2 File Properties

At any given time, there is a processor-determined set_of_allowed-access_methods, aprocessor-determined set_of_allowed_forms, and a processor-determinedset_of_allowed_record_lengths for a file.

A file may have a name; a file that has a name is called a named file. The name of anamed file is a character string.

! PROCESSOR-DEPENDENT [ For DPS7 FORTRAN 77, a file has no name in thefollowing cases:

1. the file is preconnected to a system unit (12.3.2)

2. the file is connected by mean of an OPEN statement (12.10) with a STATUS ='SCRATCH' specifier

3. the file is connected by means of an OPEN statement with SPECIAL = spec for thevalue of the FILE = specifier

Page 183: FORTRAN 77 Reference Manual - Bull

INPUT/OUTPUT Statements

47 A2 15UL Rev02 12-5

A file has a name in the following cases:

1. the file is connected by means of an OPEN statement with FILE = specifier, whosevalue is flit (12.10). The name of the file is flit, which is a GCL file literal.

2. the file is connected by means of an OPEN statement with FILE = specifier, whosevalue is IFN=ifn (12.10). The name of the file is a GCL file literal corresponding tothe file assigned with the internal file name ifn.

3. The file is preconnected to a unit (e.g. 10) that is not a system unit. The name ofthe file is a GCL file literal corresponding to the file assigned with the unit as internalfile name.

The following is an example of an unnamed file.

Example 1:

FORTRAN program:

PROGRAM P1 OPEN (UNIT=20,STATUS='SCRATCH') WRITE (UNIT=20) A END

JCL statements:

$STEP P1; $ENDSTEP;

The file connected to unit number 20 has no name for FORTRAN. It is a temporary filefor the time of its connection, and is created by FORTRAN.

The following are examples of named files.

Example 2:

FORTRAN program:

PROGRAM P2 OPEN (UNIT=30, FILE='EFN30$CAT') WRITE (UNIT=30) A END

JCL statements:

$STEP P2; $ENDSTEP;

The file connected to unit 30 has the name EFN30$CAT for FORTRAN.

For GCOS it has the External File Name EFN30 and its device and media are locatedvia the catalog.

Page 184: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

12-6 47 A2 15UL Rev02

Example 3:

FORTRAN program:

PROGRAM P3 WRITE (UNIT=10) A END

JCL statements:

$STEP P3; ASSIGN 10, EFN, DVC=MS/M452, MD=K104; $ENDSTEP;

The file preconnected to unit number 10 has the name EFN:MS/M452:K104

It is a permanent file accessed by FORTRAN. For GCOS it has an Internal File Name10, and an External File Name EFN.

Example 4:

FORTRAN program:

PROGRAM P4 OPEN (UNIT=40, FILE='IFN=HCOBFOR1') CALL COBOL END

JCL statements:

$STEP P4; ASSIGN HCOBFOR1, EFN40, DVC=MS/M452, MD=K104; $ENDSTEP;

The file connected to unit 40 has the name EFN40:MS/M452:K104 for FORTRAN. ForGCOS it has the Internal File Name HCOBFOR1, and the External File Name EFN40.

Note that the use of IFN=ifn, as a value of the FILE = specifier, is useful only in order touse a non numeric Internal File Name.

The internal file names HCOBFOR1, HCOBFOR2, HCOBFOR3, HCOBFOR4,HCOBFOR5 are especially suited for use by other languages (12.10) as they lead tostatic file definitions (FD) allowing linkage with COBOL programs for example.].PROCESSOR-DEPENDENT.!

Page 185: FORTRAN 77 Reference Manual - Bull

INPUT/OUTPUT Statements

47 A2 15UL Rev02 12-7

12.2.3 File Position

A file that is connected to a unit (12.3) has a position property.

Execution of certain input/output statements affects the position of a file. Certaincircumstances can cause the position of a file to become indeterminate.

The initial_point of a file is the position just before the first record. The terminal_point isthe position just after the last record.

If a file is positioned within a record, that record is the current_record; otherwise, there isno current record.

Let n be the number of records in the file. If 1 <i< n and a file is positioned within the ithrecord or between the (i-1)th record and the ith record, the (i-1)the record is thepreceding_record. If n >= 1 and a file is positioned at its terminal point, the precedingrecord is the nth and last record. If n=0 or if a file is positioned at its initial point or withinthe first record, there is no preceding record.

If 1 <= i< n and a file is positioned within the ith record or between the ith and (i+1)threcord is the next_record. If n >= 1 and the file is positioned at its initial point, the firstrecord is the next record. If n=0 or if a file is positioned at its terminal point or within the0nth and last record, there is no next record.

12.2.4 File Access

There are two methods of accessing the records of an external file: sequential anddirect. Some files may have more than one allowed access method; other files may berestricted to one access method. For example, the processor allows only sequentialaccess to a file on magnetic tape. Thus, the set of allowed access methods depends onthe file and the processor.

The method of accessing the file is determined when the file is connected to a unit(12.3.2).

An internal file must be accessed sequentially.

Page 186: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

12-8 47 A2 15UL Rev02

12.2.4.1 Sequential Access

When connected for sequential access, a file has the following properties:

1. The order of the records is the order in which they were written if the direct accessmethod is not a member of the set of allowed access methods for the file. If thedirect access method is also a member of the set of allowed access methods forthe file, the order of the records is the same as that specified for direct access(12.2.4.2). The first record accessed by sequential access is the record whoserecord number is 1 for direct access. The second record accessed by sequentialaccess is the record whose record number is 2 for direct access, etc. A record thathas not been written since the file was created must not be read.

2. The records of the file are either all formatted or all unformatted, except that the lastrecord of the file may be an endfile record.

3. The records of the file must not be read or written by direct access input/outputstatements (12.8.1).

! PROCESSOR-DEPENDENT [

4. The records of the file do not necessarily have the same length. If they have thesame length, the file is said to have a fixed recording_form.

If they do not have the same length, the file is said to have avariable_recording_form.

5. If the file has a fixed recording form the records of the file have a maximum lengththat is equal to the constant record length.

It is not possible to write on a file a record whose length is greater than themaximum length, unless the file can contain spanned_records.A file is known to possibly contain spanned records by the SPANNING=spspecification of the OPEN statement (12.10.1).

Example:

The following is an example of creation of a temporary file, for sequential access, withvariable recording form, and maximum record size equal to 255.

FORTRAN program:

PROGRAM P OPEN (UNIT=50, STATUS='SCRATCH', & RECFORM='VARIABLE', RECL=255, & ACCESS='SEQUENTIAL', FORM='UNFORMATTED') WRITE (UNIT=50) A END

JCL statements:

$STEP P;

$ENDSTEP;].PROCESSOR-DEPENDENT.!

Page 187: FORTRAN 77 Reference Manual - Bull

INPUT/OUTPUT Statements

47 A2 15UL Rev02 12-9

12.2.4.2 Direct Access

When connected for direct access, a file has the following properties:

1. The order of the records is the order of their record numbers.

The records may be read or written in any order.2. The records of the file are either all formatted or all unformatted. If the sequential

access method is also a member of the set of allowed access methods for the file,its endfile record, if any, is not considered to be part of the file while it is connectedfor direct access. If the sequential access method is not a member of the set ofallowed access methods for the file, the file must not contain an endfile record.

3. Reading and writing records is accomplished only by direct access input/outputstatements (12.8.1).

4. All records of the file have the same length.

5. Each record of the file is uniquely identified by a positive integer called therecord_number. The record number of a record is specified when the record iswritten. Once established, the record number of a record can never be changed.Note that a record may not be deleted; however, a record may be rewritten.

6. Records need not be read or written in the order of their record numbers. Anyrecord may be written into the file while it is connected (12.3.2) to a unit. Forexample, it is permissible to write record 3, even though records 1 and 2 have notbeen written.

Any record may be read from the file while it is connected to a unit, provided thatthe record was written since the file was created.

7. The records of the file must not be read or written using list-directed nor namelistformatting.

! PROCESSOR-DEPENDENT [

8. When the file is created by means of an OPEN statement, a maximum recordnumber may be given by the MAXREC=specifier (12.10). If this is the case, eachrecord of the file must have a record number less than or equal to this maximumrecord number.

Page 188: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

12-10 47 A2 15UL Rev02

Example:

The following is an example of the creation of a temporary file for direct access, with arecord length equal to 100 characters, and a maximum record number equal to 200.

FORTRAN program:

PROGRAM P OPEN (UNIT=60, STATUS='SCRATCH', & RECL=100, MAXREC=200, & ACCESS='DIRECT', FORM='UNFORMATTED') WRITE (UNIT=60, REC = 199) A END

JCL statements:

$STEP P; $ENDSTEP;].PROCESSOR-DEPENDENT.!

12.2.5 Internal Files

Internal files provide a means of transferring and converting data from internal storage tointernal storage.

12.2.5.1 Internal File Properties

1. The file is a character variable, character array element, character array, orcharacter substring.

2. A record of an internal file is a character variable, character array element, orcharacter substring.

3. If the file is a character variable, character array element, or character substring, itconsists of a single record whose length is the same as the length of the variable,array element, or substring, respectively. If the file is a character array, it is treatedas a sequence of character array elements.

Each array element is a record of the file. The ordering of the records of the file isthe same as the ordering of the array elements in the array (5.2.4). Every record ofthe file has the same length, which is the length of an array element in the array.

4. The variable, array element, or substring that is the record of the internal filebecomes defined by writing the record. If the number of characters written in arecord is less than the length of the record, the remaining portion of the record isfilled with blanks.

5. A record may be read only if the variable, array element, or substring that is therecord is defined.

Page 189: FORTRAN 77 Reference Manual - Bull

INPUT/OUTPUT Statements

47 A2 15UL Rev02 12-11

6. A variable, array element, or substring that is a record of an internal file maybecome defined (or undefined) by means other than an output statement. Forexample, the variable, array element, or substring may become defined by acharacter assignment statement.

7. An internal file is always positioned at the beginning of the first record prior to datatransfer.

8. The file may be an integer array, [ NEW ANSI77 [ in which case it is treated as asequence of integer elements. ].NEW ANSI77. ]

Each array element is a record of the file. The ordering of records in the file is thesame as the ordering of the array elements in the array. Every record of the file hasa length of four bytes.

12.2.5.2 Internal File Restrictions

An internal file has the following restrictions:

1. Reading and writing records is accomplished only by sequential access [ NEWANSI77 [ formatted ].NEW ANSI77. ] input/output statements (12.8.1) that do notspecify list-directed formatting, nor NAMELIST.

2. An auxiliary input/output statement must not specify an internal file.

! PROCESSOR-DEPENDENT [

The following is an example of use of an Internal File.

CHARACTER * 4 A(3) A(1) = '1111' A(2) = '2222' A(3) = '3333' READ (UNIT = A, FMT=100) I1, I2, I3100 FORMAT (I4/I4/I4) END

After execution, I1 = 1111, I2 = 2222, I3 = 3333

This is because the slashes in format 100 produce a reading of 3 records, in otherwords, 3 elements of array A.

].PROCESSOR-DEPENDENT.!

# OLD ANSI77 [

Page 190: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

12-12 47 A2 15UL Rev02

Note that the effect would be exactly the same if DECODE was used # instead of READ,but READ is preferable as it is ANSI 77.

].OLD ANSI77.#

! PROCESSOR-DEPENDENT [

If the following format had been used instead of format labelled 100:

FORMAT (3I4)

the program would not have been correct, as such a format requires only one record: thefirst element of A, and this record does not satisfy the I/O list.

].PROCESSOR-DEPENDENT.!

Page 191: FORTRAN 77 Reference Manual - Bull

INPUT/OUTPUT Statements

47 A2 15UL Rev02 12-13

12.3 UNITS

A unit is a means of referring to a file.

12.3.1 Unit Existence

At any given time, there is a processor-determined set of units that are said to exist foran executable program.

All input/output statements may refer to units that exist. The INQUIRE and CLOSEstatements may also refer to units that do not exist.

12.3.2 Connection of a Unit

A unit has a property of being connected or not connected. If connected, it refers to afile. A unit may become connected by preconnection or by the execution of an OPENstatement. The property of connection is symmetric: if a unit is connected to a file, thefile is connected to the unit.

! PROCESSOR-DEPENDENT [

Preconnection means that the unit is connected to a file at the beginning of execution ofthe executable program and therefore may be referenced by input/output statementswithout the prior execution of an OPEN statement.

With DPS7 FORTRAN 77, there are two cases of preconnection of units.

1. Assigned_units

There is an ASSIGN statement in the Job Control Language (JCL) of the step, andthe Internal File Name (IFN) specified by the ASSIGN is a string of decimal digitswhose values when considered as an integer constant, is equal to the value of theexternal unit identifier giving the unit in input/output statements. Then the unit ispreconnected to the file specified by the ASSIGN statements.If the Internal File Name has leading zero characters, it may not be used forpreconnection (except if it is constituted by a unique zero character).

2. System_Units

A system_unit is specified in the following cases:- the external unit identifier is an asterisk. An equivalent notation is to use a

Read statement without unit specifier, or to use a PRINT statement.- the statement is a PUNCH statement- the external unit identifier is 5, 6 or 7, and is not preconnected by means of an

ASSIGN statement.

Page 192: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

12-14 47 A2 15UL Rev02

Then the unit is a system_unit and is preconnected to a System File as specified inTable 12-1.Preconnection relies on the fact that the executable program is run in batch orinteractive mode.The unit denoted by an asterisk is preconnected to a file whose Internal File Nameis H_RD for a READ statement, and H_PR for a WRITE statement.The unit denoted by a PUNCH statement is preconnected to a file whose InternalFile Name is H_CP.In Table 12-1, the identity of the preconnected file is obtained as follows:- SYS.OUT is the External File Name of the System Output File.- console is the user terminal in interactive mode.- f(5), f(6), f(7), f(H_RD), f(H_PR) or f(H_CP) is the file, or Input Enclosure,

which is specified in the ASSIGN statement in association to the Internal FileName 5, 6, 7, H_RD, H_PR or H_CP.

- error means that this case leads to an error at execution.

].PROCESSOR-DEPENDENT.!

Page 193: FORTRAN 77 Reference Manual - Bull

INPUT/OUTPUT Statements

47 A2 15UL Rev02 12-15

Table 12-1. Preconnection

WRITE Statement

Unit in I/OStatements

Mode

In JCL there is:

ASSIGN 6

Batch

*

6

*

6

Interactive

ASSIGN H_PR

ASSIGN 6ASSIGN H_PR

SYS.OUT

SYS.OUT

f(H_PR)

f(H_PR)

SYS.OUT

f(6)

f(H_PR)

f(6)

f(H_PR)

f(H_PR)

console

f(6)

f(H_PR)

f(6)

console

console

READ Statement

In JCL there is:

Mode

Unit in I/OStatements

ASSIGN 5

ASSIGN H_RD

ASSIGN 5ASSIGN H_RD

Batch

error

error

error

console

console

f(H_RD)

f(5)

f(H_RD)

f(H_RD)

*

5

*

5

console

f(5)

f(H_RD)

f(H_RD)

Interactive

f(5)

f(H_RD)

f(5)

Page 194: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

12-16 47 A2 15UL Rev02

All input/output statements except OPEN, CLOSE, and INQUIRE must reference a unitthat is connected to a file and thereby make use of or affect that file.

A file may be connected and not exist. An example is a preconnected new file.

A unit must not be connected to more than one file at the same time, and a file must notbe connected to more than one unit at the same time. However, means are provided tochange the status of a unit and to connect a unit to a different file.

After a unit has been disconnected by the execution of a CLOSE statement, it may beconnected again within the same executable program to the same file or a different file.After a file has been disconnected by the execution of a CLOSE statement, it may beconnected again within the same executable program to the same unit or a different unit.Note, however, that the only means to refer to a file that has been disconnected is by itsname in an OPEN or INQUIRE statement. Therefore, there may be no means ofreconnecting an unnamed file once it is disconnected.

! PROCESSOR-DEPENDENT [ The following are examples of preconnected files.

Example 1:

FORTRAN program:

PROGRAM P1 WRITE (UNIT=10) A END

JCL statements:

$STEP P1; ASSIGN 10, EFN10, DVC=MS/M452, MD=K104; $ENDSTEP;

The unit 10 is preconnected to the file whose Internal File Name is 10, and whoseExternal File Name is EFN. The file is located on a device MS/M452 on the media K104.

Example 2:

FORTRAN program:

PROGRAM P2 WRITE (*,*) A END

JCL statements:

$STEP P2 $ENDSTEP

The unit * is preconnected to the user console in interactive mode.

The unit * is preconnected to the system output file SYS.OUT in batch mode.].PROCESSOR-DEPENDENT.!

Page 195: FORTRAN 77 Reference Manual - Bull

INPUT/OUTPUT Statements

47 A2 15UL Rev02 12-17

12.3.3 Unit Specifier and Identifier

The form of a unit_specifier is:

[UNIT =] u

where u is an external unit identifier or an internal file identifier.

An external unit identifier is used to refer to an external file.

An internal file identifier is used to refer to an internal file.

An external_unit_identifier is one of the following:

! PROCESSOR-DEPENDENT [

1. An integer expression i whose value must be zero or positive and less than 10 ** 8.The execution speed of the READ/WRITE statements is reduced if the unit isgreater than 200. ].PROCESSOR-DEPENDENT.!

2. An asterisk, identifying a system unit that is preconnected for formatted sequentialaccess (12.9.2).

The external unit identified by the value of i is the same external unit in all program unitsof the executable program. In the example:

SUBROUTINE A READ (6) X

SUBROUTINE B N=6 REWIND N

the value 6 used in both program units identifies the same external unit.

An external unit identifier in an auxiliary input/output statement (12.10) must not be anasterisk.

An internal_file_identifier is the name of a character variable, character array, characterarray element, or character substring (12.2.5).

If the optional characters UNIT= are omitted from the unit specifier, the unit specifiermust be the first item in a list of specifiers.

Page 196: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

12-18 47 A2 15UL Rev02

12.4 FORMAT SPECIFIER AND IDENTIFIER

The form of a format_specifier is:

[FMT =] f

Where f is a format identifier.

A format_identifier identifies a format. A format identifier must be one of the following:

1. The statement label of a FORMAT statement that appears in the same programunit as the format identifier.

2. An integer variable name that has been assigned the statement label of a FORMATstatement that appears in the same program unit as the format identifier (10.3).

3. A character array name (13.1.2).

4. Any character expression except a character expression involving concatenation ofan operand whose length specification is an asterisk in parentheses unless theoperand is the symbolic name of a constant. Note that a character constant ispermitted.

5. An asterisk, specifying list-directed formatting.

[ NEW ANSI77 [

6. A NAMELIST name that has been specified in a NAMELIST statement.

].NEW ANSI77. ]# OLD ANSI77 [

7. An integer array name, that has been defined with hollerith value.

].OLD ANSI77.#

If the optional characters FMT= are omitted from the format specifier, the formatspecifier must be the second item in the control information list and the first item must bethe unit specifier without the optional characters UNIT=.

The following are examples of format specifiers.

Page 197: FORTRAN 77 Reference Manual - Bull

INPUT/OUTPUT Statements

47 A2 15UL Rev02 12-19

Example:

! PROCESSOR-DEPENDENT [

C all the following cases produce the same result. CHARACTER * 10 C INTEGER I, IT(1), J I = 1C case (1) WRITE (UNIT=10, FMT=20) I20 FORMAT (I6)C case (2) ASSIGN 20 TO J WRITE (UNIT=10, FMT=J) IC case (3) C = '(I6)' WRITE (UNIT=10, FMT=C) IC case (4) WRITE (UNIT=10, FMT='(I6)') IC case (5), equivalent because I6 specifier (13.6.2) ].PROCESSOR-DEPENDENT.!# OLD ANSI77 [ WRITE (UNIT=10, FMT=*) IC case (6)* this must not be used for new programs, since it will not be].OLD ANSI77.#! PROCESSOR-DEPENDENT [* supported by the next release WRITE (10,IT) I DATA IT/4H(I6)/C case (7) does not produce the same edition NAMELIST /N/I WRITE (10,N) ].PROCESSOR-DEPENDENT.!

Page 198: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

12-20 47 A2 15UL Rev02

12.5 INPUT/OUTPUT RECORD, RECORD LENGTH, BYTE SPECIFIERS

12.5.1 Record Specifier

[ NEW ANSI77 [ The form of a record_specifier is:

REC = rn

where rn is an integer expression whose value is positive. It specifies the number of therecord that is to be read or written in a file connected for direct access.

12.5.2 Byte Specifier

The form of a byte specifier is:

BYTE = b

where b is an integer expression, whose value is positive. It may be used only if:

1. The file is connected for direct access.

2. The byte specifier is contained in an unformatted I/O statement.

As opposed to direct access with REC=specifier, the record length of the file may be lessthan the length of the values required by the input/output list. As many records asnecessary are read/written by a READ/WRITE statement with BYTE=specifier.

b specifies a logical address in the file, expressed in character storage units (bytes), atwhich data specified by the input/output list is to be read or written. The first characterstorage unit of the file has an offset value of one.

The data specified by the iolist is not split up into elementary records. Magnitudes areprocessed according to the specifications, but without check words or record limits. Anumber of locations equal to the number of elements in the designated input/output list isused in the file. Knowing the dimensions of the binary elements, the programmer is notobliged to conform to the restrictions of the unformatted READ/WRITE instructions forwhich the data written by a WRITE instruction can be reread only by a single READinstruction.

By analogy, the file can be considered as a one-dimensional array of bytes in which it ispossible to select an element or group of elements in any order.

In a READ instruction, bytes are read and placed in the elements defined by theinput/output list starting at the location defined by b.

Through use of WRITE instructions, the binary values of the elements of the list arewritten into the file starting at the location defined by b. ].NEW ANSI77. ]

Page 199: FORTRAN 77 Reference Manual - Bull

INPUT/OUTPUT Statements

47 A2 15UL Rev02 12-21

Example:

! PROCESSOR-DEPENDENT [ The following is an example for the case of a BYTE =specifier, to some very large arrays on a temporary file, for further use in the program.

PROGRAM P DIMENSION AR (1000,1000) OPEN (UNIT=10, STATUS='SCRATCH', ACCESS='DIRECT',RECL=10000,MAXREC=1000)C ... compute AR ... and save it WRITE (UNIT=10, BYTE=1) ARC ... compute a new version of AR ... and save it WRITE (UNIT=10, BYTE=4000 001) ARC ... restore the first version of AR READ (UNIT=10, BYTE=1) AR END

JCL statements:

$STEP P;$ENDSTEP;

This method of programming may be useful if:

1. the total number of very large arrays exceeds the number of available largesegments of the DPS7 virtual memory.

2. the physical memory of the DPS7 executing the program is large enough to supportthe computation, but the traffic generated by the Virtual Memory Management is notoptimum. ].PROCESSOR-DEPENDENT.!

12.5.3 Processed Length Specifier

[ NEW ANSI77 [ The form of a processed length specifier is:

PROCL = pl

where pl is the name of a variable or array element of type integer, that becomes definedwith the processed length of the record.

On input, if the number of values (unformatted case) or the number of characters(formatted case) required by the input list and format specification (if any), is less than orequal to the number of values or the number of characters in the record, the value of plis the length of the processed part of the record, expressed in bytes.

Note that if additional records have been read (formatted case only), pl is the length ofthe processed part of the last additional record.

Page 200: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

12-22 47 A2 15UL Rev02

On input, if the number of values or the number of characters required by the input listand format specifications (if any) is greater than the number values or the number ofcharacters in the record, no error condition occurs, the remaining list elements becomeundefined, and the value of pl is the length of the whole record, expressed in characterstorage units.Note that if additional records have been read (formatted use only) no further additionalrecord is read, and pl is the length of the whole last processed additional record.

On output, if the number of values or the number of characters required by the output listand format specification (if any), is less than or equal to the maximum number of valuesor the maximum number of characters in the record, the value of pl is the length of thefilled part of the record, expressed in character storage units.Note that if additional records have been written (formatted case only), rl is the length ofthe filled part of the last additional record.On output, if the number of values or the number of characters required by the output listand format specification (if any), is greater than the maximum number of values or themaximum number of characters in the record, no error condition occurs, the processingof the list continues, and the value of pl is the length of the filled part (potentiallytruncated) of the last record, expressed in character storage units.Note that if additional records have been written (formatted case only), additional recordsmay be written after a record has been truncated. ].NEW ANSI77. ]

Example:

! PROCESSOR-DEPENDENT [

PROGRAM P CHARACTER * 32 000 C5 READ (UNIT=1, PROCL=I, END=10) CC I receives the length of the record IF (I.GT.32000) THEN WRITE (*,*) 'TOO LARGE RECORD LENGTH=',I STOP ENDIFC copy the record WRITE (UNIT=2) C (1:I) GOTO 510 STOP END

The JCL statements must assign the Internal File Names 1 and 2 to the appropriatedevices. ].PROCESSOR-DEPENDENT.!

Page 201: FORTRAN 77 Reference Manual - Bull

INPUT/OUTPUT Statements

47 A2 15UL Rev02 12-23

12.6 ERROR AND END-OF-FILE CONDITIONS

The set of input/output error conditions is processor dependent.

An end-of-file condition exists if either of the following events occurs:

1. An endfile record is encountered during the reading of a file connected forsequential access. In this case, the file is positioned after the endfile record.

2. An attempt is made to read a record beyond the end of an internal file.

If an error condition occurs during execution of an input/output statement, execution ofthe input/output statement terminates and the position of the file becomes indeterminate.

If an error condition or an end-of-file condition occurs during execution of a READstatement, execution of the READ statement terminates and the entities specified by theinput list and implied-DO-variables in the input list become undefined. Note that variableand array elements appearing only in subscripts, substring expressions, and implied-DOparameters in an input list do not become undefined when the entities specified by thelist become undefined.

If an error condition occurs during execution of an output statement, execution of theoutput statement terminates and implied-DO-variables in the output list becomeundefined.

If an error condition occurs during execution of an input/output statement that containsneither an input/output status specifier (12.7) nor an error specifier (12.7.1), or if an end-of-file condition occurs during execution of a READ statement that contains neither aninput/output status specifier nor an end-of-file specifier (12.7.2), execution of theexecutable program is terminated.

Page 202: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

12-24 47 A2 15UL Rev02

12.7 INPUT/OUTPUT STATUS, ERROR, AND END-OF-FILE SPECIFIERS

The form of an input/output_status_specifier is:

IOSTAT = ios

where ios is an integer variable or integer array element.

Execution of an input/output statement containing this specifier causes ios to becomedefined:

1. with a zero value if neither an error condition nor an end-of-file condition isencountered by the processor.

2. with a processor-dependent positive integer value if an error condition isencountered. ! PROCESSOR-DEPENDENT [ These values are listed in AppendixD, with the meaning of the error.

Note that this value may be a transformation of a system return code sent byGCOS File Data Management. The exact value of the system return code may beobtained by the KTEST and ITEST intrinsic functions (15.10). ].PROCESSOR-DEPENDENT.!

3. with a negative integer value if an end-of-file condition is encountered and no errorcondition is encountered.

! PROCESSOR-DEPENDENT [ These values are listed in Appendix D.].PROCESSOR-DEPENDENT.!

12.7.1 Error Specifier

The form of an error_specifier is:

ERR = s

where s is the statement label of an executable statement that appears in the sameprogram unit as the error specifier.

If an input/output statement contains an error specifier and the processor encounters anerror condition during execution of the statements:

1. execution of the input/output statement terminates,

2. the position of the file specified in the input/output statement becomesindeterminate,

3. if the input/output statement contains an input/output status specifier (12.7), thevariable or array element ios becomes defined with a processor-dependent positiveinteger value, and

4. execution continues with the statement labelled s.

Page 203: FORTRAN 77 Reference Manual - Bull

INPUT/OUTPUT Statements

47 A2 15UL Rev02 12-25

12.7.2 End-of-File Specifier

The form of an end-of-file_specifier is:

END = s

where s is the statement label of an executable statement that appears in the sameprogram unit as the end-of-file specifier.

If a READ statement contains an end-of-file specifier and the processor encounters anend-of-file condition and no error condition during execution of the statement:

1. execution of the READ statement terminates.

2. if the READ statement contains an input/output status specifier (12.7), the variableor array element ios becomes defined with a processor-dependent negative integervalue, and

3. execution continues with the statement labelled s.

Page 204: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

12-26 47 A2 15UL Rev02

12.8 READ, WRITE, PRINT AND PUNCH STATEMENTS

The READ statement is the data transfer input statement. The WRITE, PRINT, andPUNCH statements are the data transfer output statements. The forms of the datatransfer input/output statements are:

READ (cilist) [iolist]

READ f [,iolist]

WRITE (cilist) [iolist]# OLD ANSI77 [PRINT f [,iolist] ].OLD ANSI77.#PUNCH f [,iolist]

where:

cilist is a control information list (12.8.1) that includes:

1. A reference to the source or destination of the data to be transferred

2. Optional specification of editing processes

3. Optional specifiers that determine the execution sequence on the occurrence ofcertain events

4. Optional specification to identify a record

5. Optional specification to provide the return of the input/output status f is a formatidentifier (12.4) iolist is an input/output list (12.8.2) specifying the data to betransferred.

12.8.1 Control Information List

A control_information_list,_cilist, is a list (2.10) whose list items may be any of thefollowing:

[UNIT =] u [FMT =] f REC = rn IOSTAT = ios ERR = s END = s [ NEW ANSI77 [ BYTE = b PROCL = pl ].NEW ANSI77. ]

Page 205: FORTRAN 77 Reference Manual - Bull

INPUT/OUTPUT Statements

47 A2 15UL Rev02 12-27

A control information list must contain exactly one unit specifier (12.3.3), at most oneformat specifier (12.4), at most one record specifier (12.5), at most one input/outputstatus specifier (12.7), at most one error specifier (12.7.1), at most one end-of-filespecifier (12.7.2), at most one byte specifier (12.5.2), ! PROCESSOR-DEPENDENT [and at most one processed length specifier (12.5.3). ].PROCESSOR-DEPENDENT.!

If the control information list contains a format specifier, the statement is a formattedinput/output statement; otherwise, it is an unformatted input/output statement.

If the control information list contains a record specifier or a byte specifier, the statementis a direct access input/output statement; otherwise, it is a sequential access input/outputstatement.

If the optional characters UNIT= are omitted from the unit specified, the unit specifiermust be the first item in the control information list.

If the optional characters FMT= are omitted from the format specifier, the formatspecifier must be the second item in the control information list and the first item must bethe unit specifier without the optional characters UNIT=.

A control information list must not contain both a record specifier or a byte specifier andan end-of-file specifier.

If the format identifier is an asterisk, the statement is a list-directed input/outputstatement and a record specifier or a byte specifier may not be present.

[ NEW ANSI77 [ If the format identifier is a NAMELIST name, the statement is anamelist input/output statement and a record specifier, or a byte specifier may not bepresent. ].NEW ANSI77. ]

In a WRITE statement, the control information list must not contain an end-of-filespecifier.

If the unit specifier specifies an internal file, the control information list must contain aformat identifier other than an asterisk or [ NEW ANSI77 [ a NAMELIST name ].NEWANSI77. ] and must not contain a record specifier or a byte specifier.

! PROCESSOR-DEPENDENT [ The following table indicates NO if two specifiers maynot be both present in the control information list. ].PROCESSOR-DEPENDENT.!

Page 206: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

12-28 47 A2 15UL Rev02

Table 12-2. Specifiers in the Control Information List

UNIT FMT REC IOSTAT ERR END BYTE PROCL

UNIT

FMT

REC

IOSTAT

ERR

END

BYTE

PROCL

NO

NO

NO

NO

NO

NO

NO NO

NO

NO

NO

NO

NO

NO

NO

NO NO

NO

12.8.2 Input/Output_List

An input/output list, iolist, specifies the entities whose values are transferred by a datatransfer input/output statement.

An input/output list is a list (2.10) of input/output list items and implied-DO lists (12.8.2.3).An input/output list item is either an input list item or an output list item.

If an array name appears as an input/output list item, it is treated as if all of the elementsof the array were specified in the order given by array element ordering (5.2.4). Thename of an assumed-size dummy array must not appear as an input/output list item.

Page 207: FORTRAN 77 Reference Manual - Bull

INPUT/OUTPUT Statements

47 A2 15UL Rev02 12-29

12.8.2.1 INPUT List Items

An input_list_item must be one of the following:

1. A variable name

2. An array element name

3. A character substring name

4. An array name

Only input list items may appear as input/output list items in an input statement.

12.8.2.2 OUTPUT List Items

An output_list_item must be one of the following:

1. A variable name

2. An array element name

3. A character substring name

4. An array name

5. Any other expression except a character expression involving concatenation of anoperand whose length specification is an asterisk in parentheses unless theoperand is the symbolic name of a constant.

Note that a constant, an expression involving operators or function references, or anexpression enclosed in parentheses may appear as an output list item but must notappear as an input list item. (See also 12.11).

12.8.2.3 Implied-DO List

An implied-DO list is of the form:

(dlist, i = e1, e2 [,e3 ])

where:

i, e1, e2, and e3 are as specified for the DO statement (11.10).dlist is an input/output list.

The range of an implied-DO list is the list dlist. Note that dlist may contain implied-DOlists. The iteration count and the values of the DO-variable i are established from e1 , e2, and e3 exactly as for a DO-loop. In an input statement, the DO-variable i, or anassociated entity, must not appear as an input list item in dlist.When and implied-DO list appears in an input/output list, the list items in dlist arespecified once for each iteration of the implied-DO list with appropriate substitution ofvalues for any occurrence of the DO-variable i.

Page 208: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

12-30 47 A2 15UL Rev02

12.9 EXECUTION OF A DATA TRANSFER INPUT/OUTPUT STATEMENT

The effect of executing a data transfer input/output statement must be as if the followingoperations were performed in the order specified:

1. Determine the direction of data transfer

2. Identify the unit

3. Establish the format if any is specified

4. Position the file prior to data transfer

5. Transfer data between the file and the entities specified by the input/output list (ifany)

6. Position the file after data transfer

7. Cause the specified integer variable or array element in the input/output statusspecifier (if any) to become defined.

12.9.1 Direction of Data Transfer

Execution of a READ statement causes values to be transferred from a file to the entitiesspecified by the input list, if one is specified.

Execution of a WRITE, PRINT or PUNCH statement causes values to be transferred toa file from the entities specified by the output list and format specification (if any).Execution of a WRITE, PRINT or PUNCH statement for a file that does not exist createsthe file, unless an error condition occurs.

12.9.2 Identifying a Unit

A data transfer input/output statement that contains a control information list (12.8.1)includes a unit specifier that identifies an external unit or an internal file. A READstatement that does not contain a control information list specifies a particular processor-determined unit, which is the same as the unit identified by an asterisk in a READstatement that contains a control information list. A PRINT statement specifies someother processor-determined unit, which is the same as the unit identified by an asteriskin a WRITE statement. ! PROCESSOR-DEPENDENT [ The file connected to thisprocessor determined unit is given in Table 12-1 (12.3.2). Thus, each data transferinput/output statement identifies an external unit or an internal file. ].PROCESSOR-DEPENDENT.!

The unit identified by a data transfer input/output statement must be connected to a filewhen execution of the statement begins.

Page 209: FORTRAN 77 Reference Manual - Bull

INPUT/OUTPUT Statements

47 A2 15UL Rev02 12-31

12.9.3 Establishing a Format

If the control information list contains a format identifier other than an asterisk, the formatspecification identified by the format identifier is established. If the format identifier is anasterisk, list-directed formatting is established. [ NEW ANSI77 [ If the format identifier isa NAMELIST name, namelist formatting is established. ].NEW ANSI77. ]

On output, if an internal file has been specified, a format specification (13.1) that is in thefile or is associated (17.1) with the file must not be specified.

12.9.4 File Position Prior to Data Transfer

The positioning of the file prior to data transfer depends on the method of access:sequential or direct.

If the file contains an endfile record, the file must not be positioned after the endfilerecord prior to data transfer.

12.9.4.1 Sequential Access

On input, the file is positioned at the beginning of the next record. This record becomesthe current record. On output, a new record is created and becomes the last record ofthe file.

An internal file is always positioned at the beginning of the first record of the file. Thisrecord becomes the current record.

12.9.4.2 Direct Access

For direct access, the file is positioned at the beginning of the record specified by therecord specifier (12.5). This record becomes the current record.

Page 210: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

12-32 47 A2 15UL Rev02

12.9.5 DATA TRANSFER

Data is transferred between records and entities specified by the input/output list. The listitems are processed in the order of the input/output list.

All values needed to determine which entities are specified by an input/output list itemare determined at the beginning of the processing of that item.

All values are transmitted to or from the entities specified by a list item prior to theprocessing of any succeeding list item. In the example,

READ (3) N, A(N)

two values are read; one is assigned to N, and the second is assigned to A(N) for thenew value of N.

An input list item, or an entity associated with it (17.1.3), must not contain any portion ofthe established format specification.

If an internal file has been specified, an input/output list item must not be in the file orassociated with the file.

A DO-variable becomes defined at the beginning of processing of the items thatconstitute the range of an implied-DO list.

On output, every entity whose value is to be transferred must be defined.

On input, an attempt to read a record of a file connected for direct access that has notpreviously been written causes all entities specified by the input list to becomeundefined.

12.9.5.1 Unformatted Data Transfer

During unformatted data transfer, data is transferred without editing between the currentrecord and the entities specified by the input/output list. Exactly one record is read orwritten.

On input, the file must be positioned so that the record read is an unformatted record oran endfile record.

On input, the number of values required by the input list must be less than or equal tothe number of values in the record, [ NEW ANSI77 [ unless a PROCL= specifierappears in the Control Information List (12.5.4), or unless the file is connected by meansof an OPEN statement with a PAD= specifier whose value is YES. ].NEW ANSI77. ]

On input, the type of each value in the record must agree with the type of thecorresponding entity in the input list, except that one complex value may correspond totwo real list entities or two real values may correspond to one complex list entity. If anentity in the input lists if of type character, the length of the character entity must agreewith the length of the character value.

Page 211: FORTRAN 77 Reference Manual - Bull

INPUT/OUTPUT Statements

47 A2 15UL Rev02 12-33

On output to a file connected for direct access, the output list must not specify morevalues than can fit into a record.

On output, if the file is connected for direct access and the values specified by the outputlist do not fill the record, the remainder of the record is undefined.

! PROCESSOR-DEPENDENT [ On output, if the file is an external file connected forsequential access and has a fixed recording form and the values specified by the outputlist do not fill the record, the remainder of the record is undefined. ].PROCESSOR-DEPENDENT.!

If the file is connected for formatted input/output, unformatted data transfer is prohibited.

The unit specified must be an external unit.

12.9.5.2 Formatted Data Transfer

During formatted data transfer, data are transferred with editing between the entitiesspecified by the input/output list and the file. The current record and possibly additionalrecords are read or written.

On input, the file must be positioned so that the record read is a formatted record or anendfile record.

If the file is connected for unformatted input/output, formatted data transfer is prohibited.

USING A FORMAT SPECIFICATION

If a format specification has been established, format control (13.3) is initiated andediting is performed as described in 13.3 through 13.5.

On input, the input list and format specification must not require more characters from arecord than the record contains, [ NEW ANSI77 [ unless a PROCL= specifier appears inthe Control Information List (12.5.4), or unless the file is connected by means of anOPEN statement with a PAD= specifier whose value is YES. ].NEW ANSI77. ]

If the file is connected for direct access, the record number is increased by one as eachsucceeding record is read or written.

On output, if the file is connected for direct access or is an internal file and thecharacters specified by the output list and format do not fill a record, blank charactersare added to fill the record.

! PROCESSOR-DEPENDENT [ On output, if the file is an external file connected forsequential access and has a fixed recording form and the characters specified by theoutput list and format do not fill a record, the remainder of the record is undefined.].PROCESSOR-DEPENDENT.!

Page 212: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

12-34 47 A2 15UL Rev02

On output, in any case: not only if the file is connected for direct access or is an internalfile, the output list and format specification must not specify more characters for a recordthan can fit into the record, [ NEW ANSI77 [ unless a PROCL=specifier appears in theControl Information List (12.5.4), or unless the file is connected by means of an OPENstatement with a PAD=specifier whose value is YES. ].NEW ANSI77. ]

LIST-DIRECTED FORMATTING

If list-directed formatting has been established, editing is performed as described in 13.6.

PRINTING OF FORMATTED RECORDS

The transfer of information in a formatted record to certain devices determined by theprocessor is called printing.

! PROCESSOR-DEPENDENT [ On DPS7 FORTRAN 77, the output device is expectedto perform printing in the following cases:

1. There has been an OPEN statement with PRINT='YES'

2 There has been an OPEN statement with FILE='SYS.OUT'

3. The unit is the system output unit

4. The unit is preconnected by means of a $ASSIGN u, SYS.OUT; JCL statement

5. The unit is preconnected, and there is a $DEFINE u, SYSOUT; JCL statement

6. There has been an OPEN statement with FILE='IFN=ifn' and there is a $ASSIGNifn, SYS.OUT; JCL statement

7. There has been an OPEN statement with FILE='IFN=ifn' and there is a $DEFINEifn, SYSOUT; JCL statement. ].PROCESSOR-DEPENDENT.!

If a formatted record is printed, the first character of the record is not printed. Theremaining characters of the record, if any, are printed in one line beginning at the leftmargin.

The first character of such a record determines vertical spacing as follows:

Character | Vertical Spacing Before Printing Blank | One Line 0 | Two Lines - | Three Lines 1 | To First Line of Next Page + | No Advance

If there are no characters in the record (13.5.4), the vertical spacing is one line and nocharacters other than blank are printed in that line.

A PRINT statement implies that printing will occur, but a WRITE statement does notimply that printing will not occur.

Page 213: FORTRAN 77 Reference Manual - Bull

INPUT/OUTPUT Statements

47 A2 15UL Rev02 12-35

12.9.6 File Position After Data Transfer

If an end-of-file condition exists as a result of reading an endfile record, the file ispositioned after the endfile record.

If no error condition or end-of-file condition exists, the file is positioned after the lastrecord read or written and that record becomes the preceding record. A record written ona file connected for sequential access becomes the last record of the file.

If the file is positioned after the endfile record, execution of a data transfer input/outputstatement is prohibited. However, a BACKSPACE or REWIND statement may be usedto reposition the file.

If an error condition exists, the position of the file is indeterminate.

12.9.7 Input/Output Status Specifier Definition

If the data transfer input/output statement contains an input/output status specifier, theinteger variable or array element ios becomes defined. If no error condition or end-of-filecondition exists, the value of ios is zero. If an error condition exists, the value of ios ispositive. If an end-of-file condition exists and no error condition exists, the value of ios isnegative (see :tc:Appendix D:etc:).

Page 214: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

12-36 47 A2 15UL Rev02

12.10 AUXILIARY INPUT/OUTPUT STATEMENTS

12.10.1 OPEN Statement

An OPEN statement may be used to connect (12.3.2) an existing file to a unit, create afile (12.2.1) that is preconnected, create a file and connect it to a unit, or change certainspecifiers of a connection between a file and a unit.

The form of an OPEN statement is:

OPEN (olist)

where olist is a list (2.10) of specifiers:

[UNIT =] uIOSTAT = iosERR = sFILE = finSTATUS = staACCESS = accFORM = fmRECL = rl[ NEW ANSI77 [BLANK = blnkRECFORM = rfMAXREC = mrSPANNING = spnPRINT = prtDELIM = dlmPAD = padSIZE = szINCRSIZE = incFILEFORM = flmBLOCKL = blNUMBUF = nbfGCOSACCESS = gaccSHARE = shaNORMALEND = nmendABNORMALEND = abendTRANSPARENT = tprtMESSAGE = msgPROMPT = prpt].NEW ANSI77. ]

olist must contain exactly one external unit specifier (12.3.3) and may contain at mostone of each of the other specifiers.

Page 215: FORTRAN 77 Reference Manual - Bull

INPUT/OUTPUT Statements

47 A2 15UL Rev02 12-37

The other specifiers are described as follows:

IOSTAT = ios

is an input/output status specifier (12.7). Execution of an OPEN statement containingthis specifier causes ios to become defined with a zero value if no error condition existsor with a processor-dependent positive integer value if an error condition exists (seeAppendix D).

ERR = s

is an error specifier (12.7.1).

FILE = fin

fin is a character expression whose value when any trailing blanks are removed is thename of the file to be connected to the specified unit. The file name must be a name thatis allowed by the processor. If this specifier is omitted and the unit is not connected to afile, it becomes connected to a processor-determined file. (see also 12.10.1.1).

! PROCESSOR-DEPENDENT [ This processor-determined file is a temporary passedfile whose External File Name (efn) is F7Rnnn, nnn being the decimal stringrepresentation of the unit specifier u.

On DPS7 FORTRAN 77, the forms that the value of the character expression fin mayhave are:

IFN = ifnSPECIAL = specflit

where:

ifn is an Internal File Name, allowable in an ASSIGN statement of the Job ControlLanguage (JCL). An alphanumeric string of less than nine characters is one of thesuitable forms.

Note that the use of IFN=ifn is expected for special cases, as an OPEN statementwithout FILE=specifier may be used with an External Unit Specifier whose value is theone of the Internal File Name of an ASSIGN statement (12.10.1.1).

Example of such special cases is exchange of files with COBOL programs.

The Internal File Names HCOBFOR1, HCOBFOR2, HCOBFOR3, HCOBFOR4,HCOBFOR5 are specially suited, as FORTRAN creates static FD for them to allowlinkage with COBOL programs (Refer to the Fortran 77 User's Guide).

spec is IOF, OPER or GRAPHIC

IOF may be used in interactive mode, to connect the unit to the user terminal.OPER may be used in batch or interactive mode, to connect the unit to the operatorterminal.

Page 216: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

12-38 47 A2 15UL Rev02

GRAPHIC may be used in interactive mode to connect the unit to the user terminal intransparent mode.

The user or the operator terminal, must be connected for sequential access only. It isrecommended practice, but not mandatory, to connect one unit for reading, and one unitfor writing, as for instance READ after WRITE is not allowed for sequential access(12.9.4.1).

flit is a GCL File Literal, which can designate the file and a way to retrieve the device onwhich it is located.The acceptable form of flit for FORTRAN77 is:

efn[..subfile] [:media:device] [ $TEMPRY ] b [ $CAT ] [ $RES ] [ $UNCAT ] [ $NATIVE ] [ $NONE ] [ $NSTD ] [ $MFT ]

].PROCESSOR-DEPENDENT.!

Note that a File Literal used with STATUS='CATNOW' specified must indicate the pathname as efn and the location of the file in media and device. Subsequent references tothe cataloged file must indicate only the path name as efn, optionally followed by $CAT.

! PROCESSOR-DEPENDENT [ where b denotes no, one, or several blank characters.If flit is reduced to efn, then there are two possibilities:

1. efn is the name of a cataloged file, and this file is retrieved

2. efn is not the name of a cataloged file, and this may lead to creation of a file on theresident media. In this case, an observation message is emitted at execution.].PROCESSOR-DEPENDENT.!

STATUS = sta

sta is a character expression whose value, when any trailing blanks are removed, isOLD, NEW, SCRATCH, UNKNOWN, APPEND or CATNOW. If OLD, NEW or CATNOWis specified, a FILE=specifier must be given. If OLD is specified, the file must exist. IfNEW or CATNOW is specified, the file must not exist. Successful execution of an OPENstatement with NEW or CATNOW specified creates the file and changes the status toOLD (12.10.1.1). If CATNOW is specified, the created file becomes cataloged. IfAPPEND is specified, the access method for the connection must be SEQUENTIAL, andthe records created by subsequent WRITE statements are created after the last recordof the file. If SCRATCH is specified with an unnamed file, the file is connected to thespecified unit for use by the executable program but is deleted (12.2.1) at the executionof a CLOSE statement referring to the same unit or at the termination of the executableprogram. SCRATCH must not be specified with a named file. If UNKNOWN is specified,the status is processor dependent:

! PROCESSOR-DEPENDENT [ With DPS7 FORTRAN 77, if the file does not exist priorto the OPEN, status NEW is assumed; if the file exists prior to the OPEN, status OLD isassumed. ].PROCESSOR-DEPENDENT.!

If this specifier is omitted, a value of UNKNOWN is assumed.

Page 217: FORTRAN 77 Reference Manual - Bull

INPUT/OUTPUT Statements

47 A2 15UL Rev02 12-39

ACCESS = acc

acc is a character expression whose value, when any trailing blanks are removed, isSEQUENTIAL or DIRECT. It specifies the access method for the connection of the fileas being sequential or direct (12.2.4). If this specifier is omitted, the assumed value isSEQUENTIAL. For an existing file, the specified access method must be included in theset of allowed access methods for the file (12.2.4). For a new file, the processor createsthe file with a set of allowed access methods that includes the specified method.

! PROCESSOR-DEPENDENT [ Sequential access is normally used with sequentialorganization files. Nevertheless it may be used with indexed organization files, on inputonly; complementary records are ignored.Sequential access may also be used with relative organization files, on input and onoutput; however an error condition occurs if a not created record is attempted to be read.Direct access is normally used with relative organization files.Nevertheless it may be used with sequential organization files, but only with fixedrecording form. This feature enables you to update the records of a sequential file.

Example:

Direct access on a file with a sequential organization for updating

PROGRAM P OPEN (UNIT=27, STATUS='NEW', ACCESS= - 'SEQUENTIAL', RECL=10, RECFORM='FIXED', - FORM='FORMATTED') DO 10 I=1, 1010 WRITE (27,'(I10)') i CLOSE (UNIT=27, STATUS='KEEP') OPEN (UNIT=27, STATUS='OLD', ACCESS='DIRECT', - RECL=10, FORM='FORMATTED') DO 20 K=1, 9999 READ (27,'(I10)', REC=K, ERR=90) I20 WRITE (27,'(I10)', REC=K) I+190 STOP END].PROCESSOR-DEPENDENT.!

FORM = fm

fm is a character expression whose value when any trailing blanks are removed isFORMATTED or UNFORMATTED. It specifies that the file is being connected forformatted or unformatted input/output, respectively. If this specifier is omitted, a value ofUNFORMATTED is assumed if the file is being connected for direct access, and a valueof FORMATTED is assumed if the file is being connected for sequential access. For anexisting file, the specified form must be included in the set of allowed forms for the file(12.2.2). For a new file, the processor creates the file with a set of allowed forms thatincludes the specified form.

! PROCESSOR-DEPENDENT [ With DPS7 FORTRAN 77, formatted and unformattedforms are both allowed for every file: a file created with unformatted form, for example,may be reread (in a subsequent connection), with formatted form. ].PROCESSOR-DEPENDENT.!

Page 218: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

12-40 47 A2 15UL Rev02

RECL = rl

rl is an integer expression whose value must be positive. It specifies the length of eachrecord in a file being connected for direct access.

[ NEW ANSI77 [ For a file being connected for sequential access, it specifies themaximum record size if the value of the RECFORM= specifier is VARIABLE, or thelength of each record if the value of the RECFORM = specifier is FIXED. ].NEWANSI77. ]

If the file is being connected for formatted input/output, the length is the number ofcharacters. If the file is being connected for unformatted input/output, the length ismeasured in processor-dependent units: ! PROCESSOR-DEPENDENT [ characterstorage ].PROCESSOR-DEPENDENT.! unit.

For an existing file, the value of rl must be included in the set of allowed record lengthsfor the file (12.2.2). For a new file, the processor creates the file with a set of allowedrecord lengths that includes the specified value. This specifier [ NEW ANSI77 [ must begiven when a file is being connected for direct access: ].NEW ANSI77. ] otherwise, it isnot mandatory.

BLANK = blnk

blnk is a character expression whose value when any trailing blanks are removed isNULL or ZERO. If NULL is specified, all blank characters in numeric formatted inputfields on the specified unit are ignored, except that a field of all blanks has a value ofzero. If ZERO is specified, all blanks other than leading blanks are treated as zeros. Ifthis specifier is omitted, a value of NULL is assumed. This specifier is permitted only fora file being connected for formatted input/output.

[ NEW ANSI77 [

RECFORM = rf

rf is a character expression whose value, when any trailing blanks are removed, isFIXED or VARIABLE. If FIXED is specified, records of the file have all the same lengthgiven by the RECL= specifier. If VARIABLE is specified, records of the file may havedifferent lengths, the maximum value being given by the RECL= specifier. If this specifieris omitted, a value of FIXED is assumed if the file is being connected for direct access,and a value of VARIABLE is assumed if the file is being connected for sequentialaccess.

For an existing file, the RECFORM = specifier is not useful.However, if it is given, the value of rf must be FIXED if the file was created with arecording form F or FB, and VARIABLE if the file was created with a recording form V orVB by a means other than FORTRAN. If the file was created by FORTRAN, the value ofrf must be the one used at its creation.

MAXREC = mr

mr is an integer expression whose value must be positive. It specifies the maximumrecord number for a file being connected for direct access.This specifier may be specified only for a new file being connected for direct access.If omitted, a default value is assumed. This value corresponds to two tracks.

Page 219: FORTRAN 77 Reference Manual - Bull

INPUT/OUTPUT Statements

47 A2 15UL Rev02 12-41

SPANNING = spn

spn is a character expression whose value when any trailing blanks are removed is YESor NO.

This specification affects the READ and WRITE statements on the corresponding unit.

1. If YES is specified:

- On output (WRITE statements) the number of values or the number ofcharacters required by the output list and format specification (if any), isgreater than the maximum number of values or the maximum number ofcharacters in the record. Several records will be written, the first one, and thelast one with special character strings called "spanning marks".

Note that if the (maximum) record size is enough for that the previous conditiondoes not hold, only one record is written, and the effect is the same as if NO wasspecified.

- On input (READ statement), if spanning marks are recognized, a uniquerecord is reconstituted from the records between the first and the lastspanning mark, but not including the spanning marks themselves.

- On input or output, an eventual PROCL :tc:= pe:etc: specification in a READor WRITE statement on the same unit is ignored.

2. If NO is specified:

- on output, if the numbers of values or the number of characters is greater thanthe maximum number of values or of characters in the record, an errorcondition occurs unless PROCL :tc:= pe:etc: specification is present in theWRITE statement (12.5.3).

- on input, if the number of values or the number of characters is greater thanthe number of values or characters in the record, an error condition occursunless PROCL :tc:= pe:etc: specification is present in the READ statement(12.5.3).

If this specifier is omitted, a value of NO is assumed.This specifier is permitted only for a file being connected for sequential access.The exact content of written records is as follows:first record: *FORTRAN*bBEGINbRECORDb*FORTRAN*m records of length n characters1 record of length p characterslast record: *FORTRAN*bbENDbRECORDbb*FORTRAN*Assuming that the record length required by the output value and the formatspecification, if any, is l character storage units:

Page 220: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

12-42 47 A2 15UL Rev02

1. If the file is made of variable length records of maximum length n characters, with n> 32:

l = m * n + pThe length of the first and last records is 32 characters.

2. If the file is made of variable length records of maximum length < 32 characters, arun time error occurs. ].NEW ANSI77. ]

# OLD ANSI77 [

LEVEL=GCOS1E

The exact content of written records is as follows:

first record: *FORTRAN* BEGIN RECORD *FORTRAN* m records of length ncharacters one record: *FORTRAN* LAST SEGMENT *FORTRAN*

1 record of length p characters

last record: *FORTRAN* END RECORD *FORTRAN*

On input, the two record forms (the one of LEVEL=GCOS1E and the one ofLEVEL=GCOS 7) are accepted, according to the value of the LEVEL=parameter, of the$FOR77 JCL statement.

If the SPANNING=specifier is omitted, a value of NO is assumed

LEVEL=GCOS1E

If the SPANNING=specifier is omitted, a value of YES is assumed

].OLD ANSI77.#

[ NEW ANSI77 [

PRINT = prt

prt is a character expression whose value, when any trailing blanks are removed, is YESor NO.

If YES is specified, the transfer of information is assumed to be printing and thereforethe first character of each record determines vertical spacing. For more information onprinting, see the subsection on printing of formatted records, below.

If NO is specified, the transfer of information is assumed not to be printing.

If this specifier is omitted, NO is assumed, unless the unit is preconnected to a print file,and the FILE=specifier is not included in the OPEN statement (12.10.1.1). This specifieris permitted only for a file being connected for sequential access.

Page 221: FORTRAN 77 Reference Manual - Bull

INPUT/OUTPUT Statements

47 A2 15UL Rev02 12-43

DELIM = dlm

dlm is a character expression whose value, when any trailing blanks are removed, isAPOSTROPHE, NONE or QUOTE. If APOSTROPHE is specified, the apostrophe will beused to delimit character constants written with list-directed or namelist formatting; anyinternal apostrophes will be doubled. If QUOTE is specified, the quotation mark will beused to delimit character constants written with list-directed formatting; any internalquotation marks will be doubled.

If NONE is specified, character constants read with list directed formatting need not beenclosed in apostrophes, but blank, comma and slash may not appear in characterconstants.QUOTE may not be specified to read with list directed formatting.If specifier is omitted or is NONE, the character constant will not be delimited byapostrophes or quotation marks. This specifier is permitted only for a file beingconnected for formatted input/output.

If the file to be connected to the unit is the same as the file to which the unit isconnected, only the BLANK= specifier and the DELIM= specifier may have a valuedifferent from the one currently in effect. Execution of the OPEN statement causes thenew value of the BLANK= specifier and the DELIM= specifier to be in effect. The positionof the file is unaffected.

PAD = pad

pad is a character expression whose value, when any trailing blanks are removed, isYES or NO. If NO is specified, on input the input list and format specification must notrequire more characters from a record than the record contains. If YES is specified, oninput, the input list and format specification may require more characters from a recordthan the record contains.In this case, the elements of the input list are filled with blanks if they are of typecharacter and with zeros otherwise.If this specifier is omitted, a value of NO is assumed.

This specifier is permitted for a file being connected for formatted or unformattedinput/output. ].NEW ANSI77. ]

! PROCESSOR-DEPENDENT [

Example:

Use of the PAD=specifier to read a LIBMAINT member whose records are of unknownand variable size.

PROGRAM E620 CHARACTER *255 C OPEN (UNIT=10, PAD='YES', ACCESS='SEQUENTIAL', FORM='FORMATTED')1 READ (UNIT=10, FMT='(A255)', END=30) C ... processing of C... GOTO 130 STOP END

Page 222: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

12-44 47 A2 15UL Rev02

Note that the length of the record is unknown, but may be obtained by use of a READwith a PROCL= specifier (:tc:12.5.3:etc:, and corresponding example).

$STEP S620;$ASSIGN 10, (MYEFN, DVC=MS/M452, MD=K104), SUBFILE=MYMEMBER;$ENDSTEP; ].PROCESSOR-DEPENDENT.!

[ NEW ANSI77 [

FILEFORM = flm

flm is a character expression whose value, when any trailing blanks are removed, isUFAS or BFAS. If UFAS is specified, the file will be created with Unified File AccessSystem (UFAS) organization. If BFAS is specified, the file will be created with Basic FileAccess System (BFAS) organization. If this specifier is omitted, a value of UFAS isassumed. This specifier is permitted only in case of creation of a new file.

SIZE = sz

sz is an integer expression whose value must be positive. It specifies the initial size ofthe file, expressed in a space allocation unit, for a file that is to be created on a disk. Thespace allocation unit is a track. This specifier is permitted only in case of sequentialaccess.

INCRSIZE = inc

inc is an integer expression whose value must be positive. It specifies the number ofspace allocation units that are added to the file every time an automatic space expansionis performed on a file on which values are transferred by means of a WRITE or PRINTstatement. If the value zero is specified, there is no automatic expansion.

The space allocation unit is the track. This specifier is permitted only in case ofsequential access on disk files.

BLOCKL = bl

bl is an integer expression whose value must be positive. It specifies the value incharacter storage units of the Control Interval Size, for a file being created with UFASspecified by the FILEFORM specifier, or the value in character storage units of the BlockSize, for a file being created with BFAS specified.This specifier is permitted only in case of creation of a new file.

NUMBUF = nbf

nbf is an integer expression whose value must be positive. It specifies the number ofbuffers to be used by GCOS 7 File Data Management, for processing of the file.

GCOSACCESS = gacc

gacc is a character expression whose value, when any trailing blanks are removed, isWRITE, READ, SPWRITE, SPREAD, ALLREAD or RECOVERY.This specifier has the same effect as the ACCESS specifier in a $ASSIGN JCLstatement.The default value is WRITE.

Page 223: FORTRAN 77 Reference Manual - Bull

INPUT/OUTPUT Statements

47 A2 15UL Rev02 12-45

SHARE = sha

sha is a character expression whose value, when any trailing blanks are removed, isNORMAL, ONEWRITE, MONITOR, DIR or FREE.This specifier has the same effect as the SHARE specifier in a $ASSIGN JCL statement.The default value is NORMAL for a file that is not a subfile of a library, DIR for a subfileof a library.

NORMALEND = nmend

nmend is a character expression whose value, when any trailing blanks are removed, isDEASSIGN, PASS, UNLOAD or LEAVE.This specifier has the same effect as the END specifier in a $ASSIGN JCL statement.The default value is PASS for a temporary file that is not a file created withSTATUS='SCRATCH', DEASSIGN in the other cases.

ABNORMALEND = abend

abend is a character expression whose value, when any trailing blanks are removed, isDEASSIGN, PASS, UNLOAD or LEAVE.This specifier has the same effect as the ABEND specifier in a $ASSIGN JCL statement.The default value is PASS for a temporary file that is not a file created withSTATUS='SCRATCH', DEASSIGN in the other cases.

TRANSPARENT = tprt

This specifier is relevant only if the file literal given as FILE=specifier contains TN asdevice class, i.e., when the Terminal Access Method is invoked.

tprt is a character expression whose value, when any trailing blanks are removed, is YESor NO. NO is the default value.When YES is specified, the records will be read/written in transparent mode, i.e. the datagiven will be sent to the terminal without control information. This mode is used forgraphic applications.

MESSAGE = msg

This specifier is relevant only if the file literal given as FILE=specifier contains TN asdevice class, i.e., when the Terminal Access Method is invoked.

msg is a character expression whose value, when any trailing blanks are removed, isYES or NO.YES is the default value.When NO is specified, the asynchronous messages are denied.

PROMPT = prpt

This specifier is relevant only if the file literal given as FILE=specifier contains TN asdevice class, i.e., when the Terminal Access Method is invoked.

prpt is a character expression whose length (blanks included) must not exceed 12characters. On input, the record which is to be entered is prompted with the prptcharacter string. On output, the record which is sent to the terminal is prefixed with theprpt character string.

Page 224: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

12-46 47 A2 15UL Rev02

If PROMPT= is not specified, neither prompt nor prefix are sent to the terminal.

The unit specifier is required to appear; all other specifiers are optional, except in somecases of file creation, if explicitly specified.

Note that some of the specifications have an assumed value if they are omitted.

The unit specified must exist.

A unit may be connected by execution of an OPEN statement in any program unit of anexecutable program and, once connected, may be referenced in any program unit of theexecutable program. ].NEW ANSI77. ]

12.10.1.1 Open of a Connected Unit

If a unit is connected to a file that exists, execution of an OPEN statement for that unit ispermitted. If the FILE= specifier is not included in the OPEN statement, the file to beconnected to the unit is the same as the file to which the unit is connected.

If the file to be connected to the unit does not exist, but is the same as the file to whichthe unit is preconnected, the properties specified by the OPEN statement become a partof the connection.

! PROCESSOR-DEPENDENT [ The following are examples of file connection by meansof OPEN statements. (Examples of file access without OPEN statements are given in(12.3.2)).

Example 1:

Temporary file for the JOB, created by FORTRAN

1st executable program (1st step of the JOB):

PROGRAM P1 OPEN (UNIT=150, IOSTAT=I, ERR=10, * FILE='EFN1', STATUS='NEW', * ACCESS='SEQUENTIAL', * FORM='FORMATTED')C this creates the file name EFN1 WRITE (UNIT=150, FMT=20) A1 ... CLOSE (UNIT=150, IOSTAT=I, ERR=30, * STATUS='KEEP') END

Page 225: FORTRAN 77 Reference Manual - Bull

INPUT/OUTPUT Statements

47 A2 15UL Rev02 12-47

2nd executable program (2nd step of the JOB):

PROGRAM P2 OPEN (UNIT=20, IOSTAT=J, ERR=40, * FILE='EFN1', STATUS='OLD', * ACCESS='SEQUENTIAL', * FORM='FORMATTED') READ (UNIT=20, FMT=50) A2 ... CLOSE (UNIT=20, IOSTAT=I, ERR=60, * STATUS='DELETE') END

Corresponding JCL statements for execution of the JOB:

$JOB... $STEP P1; $ENDSTEP; $STEP P2; $ENDSTEP; $ENDJOB;

Example 2:

Permanent file created by FORTRAN

PROGRAM E670 CHARACTER *(*) CEFN, CDEVICE, CMEDIA PARAMETER (CEFN='Z2BID') PARAMETER (CDEVICE='MS/M452') PARAMETER (CMEDIA='P1231') CALL S670 (CEFN, CDEVICE, CMEDIA) STOP END SUBROUTINE S670 (XE, XD, XM) CHARACTER *(*) XE, XD, XM INTEGER ISIZE, INCR, IUNIT, IRECLC ... these variables are read or computed. OPEN (UNIT=IUNIT, IOSTAT=I, ERR=10, FILE=XE//':'//XM//':'//XD, STATUS='NEW', ACCESS='SEQUENTIAL', RECL=IRECL, RECFORM='VARIABLE', SIZE=ISIZE, INCRSIZE=INCR, FILEFORM='BFAS', BLOCKL=8000,NUMBUF=2) ... CLOSE (UNIT=IUNIT, IOSTAT=I, ERR=20, STATUS='KEEP') END

Corresponding JCL statements for execution of the job:

$JOB... $STEP E670...; $ENDSTEP; $ENDJOB.

Page 226: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

12-48 47 A2 15UL Rev02

Example 3:

Permanent catalogued file accessed by FORTRAN

PROGRAM E680 CHARACTER *(*) EFN PARAMETER (EFN='MYEFN') PARAMETER (IUNIT=1) OPEN (UNIT=IUNIT, IOSTAT=I, ERR=10, FILE=EFN//'$CAT', STATUS='OLD', NUMBUF=2) ... END

Corresponding JCL statements for execution of the job

$JOB... $STEP E680...; $ENDSTEP; $ENDJOB.

Note that $CAT is not mandatory: the Data Management search rules are such that ifthere was FILE=EFN, the catalog would have been searched first, then the residentmedia.

Example 4:

Permanent file preconnected, but with OPEN statement to add properties to theconnection

PROGRAM E690 OPEN (UNIT=40, IOSTAT=I, ERR=10, ACCESS='DIRECT', MAXREC=1000) ... END

Corresponding JCL statements for the step:

$STEP E690; ASSIGN 40, MYFILE, DVC=MS/M452, MD=K104; $ENDSTEP;

Example 5:

Permanent file not preconnected with imposed Internal File Name in the JCL.

PROGRAM E700 OPEN (UNIT=1, FILE='IFN=FILE_A') ... END

Corresponding JCL statements for the step:

$STEP E700; ASSIGN FILE_A, MYFILE, DVC=MS/M452, MD=K104; $ENDSTEP; ].PROCESSOR-DEPENDENT.!

Page 227: FORTRAN 77 Reference Manual - Bull

INPUT/OUTPUT Statements

47 A2 15UL Rev02 12-49

If the file to be connected to the unit is not the same as the file to which the unit isconnected, the effect is as if a CLOSE statement (12.10.2) without a STATUS= specifierhad been executed for the unit immediately prior to the execution of the OPEN statement.

If the file to be connected to the unit is the same as the file to which the unit is connected,only the BLANK=specifier and the [ NEW ANSI77 [ DELIM=specifier ].NEW ANSI77. ]may have a value different from the one currently in effect. Execution of the OPENstatement causes the new value of the BLANK=specifier [ NEW ANSI77 [ and theDELIM=specifier ].NEW ANSI77. ] to be in effect.

The position of the file is unaffected.

If a file is connected to a unit, execution of an OPEN statement on that file and a differentunit is not permitted.

12.10.2 CLOSE Statement

A CLOSE statement is used to terminate the connection of a particular file to a unit.

The form of a CLOSE statement is:

CLOSE (cllist)

where cllist is a list (2.10) of specifiers:

[UNIT =] u IOSTAT = ios ERR = s STATUS = sta

cllist must contain exactly one external unit specifier (12.3.3) and may contain at most oneof each of the other specifiers.

The other specifiers are described as follows:

IOSTAT = ios

is an input/output status specifier (12.7). Execution of a CLOSEstatement containing this specifier causes ios to become defined with a zero value if noerror condition exists or with a processor-dependent positive integer value if an errorcondition exists (see Appendix D).

ERR = s

is an error specifier (12.7.1).

Page 228: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

12-50 47 A2 15UL Rev02

STATUS = sta

sta is a character expression whose value when any trailing blanks are removed is KEEPor DELETE. sta determines the disposition of the file that is connected to the specifiedunit.KEEP must not be specified for a file whose status prior to execution of the CLOSEstatement is SCRATCH. If KEEP is specified for a file that exists, the file continues toexist after the execution of the CLOSE statement. If KEEP is specified for a file that doesnot exist, the file will not exist after the execution of the CLOSE statement. If DELETE isspecified, the file will not exist after execution of the CLOSE statement.If this specifier is omitted, the assumed value is KEEP, unless the file status prior toexecution of the CLOSE statement is SCRATCH, in which case the assumed value isDELETE.

Execution of a CLOSE statement that refers to a unit may occur in any program unit ofan executable program and need not occur in the same program unit as the execution ofan OPEN statement referring to that unit.Execution of a CLOSE statement specifying a unit that does not exist or has no fileconnected to it is permitted and affects no file.

After a unit has been disconnected by execution of a CLOSE statement, it may beconnected again within the same executable program, either to the same file or to adifferent file. After a file has been disconnected by execution of a CLOSE statement, itmay be connected again within the same executable program, either to the same unit orto a different unit, provided that the file still exists.

12.10.2.1 Implicit Close at Termination of Execution

At termination of execution of an executable program for reasons other than an errorcondition, all units that are connected are closed. Each unit is closed with status KEEPunless the file status prior to termination of execution was SCRATCH, in which case theunit is closed with status DELETE. Note that the effect is as though a CLOSE statementwithout a STATUS= specifier were executed on each connected unit.

12.10.3 INQUIRE Statement

An INQUIRE statement may be used to inquire about properties of a particular namedfile or of the connection to a particular unit.There are two forms of the INQUIRE statement: inquire by file and inquire by unit. Allvalue assignments are done according to the rules for assignment statements.

The INQUIRE statement may be executed before, while, or after a file is connected to aunit. All values assigned by the INQUIRE statement are those that are current at the timethe statement is executed.

Page 229: FORTRAN 77 Reference Manual - Bull

INPUT/OUTPUT Statements

47 A2 15UL Rev02 12-51

12.10.3.1 Inquire by File

The form of an INQUIRE by file statement is:

INQUIRE (iflist)

where iflist is a list (2.10) of specifiers that must contain exactly one file specifier andmay contain other inquiry specifiers. The iflist may contain at most one of each of theinquiry specifiers described in 12.10.3.3.

The form of a file specifier is:

FILE = fin

where fin is a character expression whose value when any trailing blanks are removedspecifies the name of the file being inquired about. The named file need not exist or beconnected to a unit.The value of fin must be of a form acceptable to the processor as a file name.

! PROCESSOR-DEPENDENT [ For DPS7 FORTRAN 77, the forms that the value of finmay have are:

IFN = ifnflit

where ifn is an Internal File Name, and flit a GCL File Literal (12.10.1). ].PROCESSOR-DEPENDENT.!

12.10.3.2 Inquire by Unit

The form of an INQUIRE by unit statement is:

INQUIRE (iulist)

where iulist is a list (2.10) of specifiers that must contain exactly one external unitspecifier (12.3.3) and may contain other inquiry specifiers. The iulist may contain at mostone of each of the inquiry specifiers described in 12.10.3.3. The unit specified need notexist or be connected to a file. If it is connected to a file, the inquiry is being made aboutthe connection and about the file connected.

Page 230: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

12-52 47 A2 15UL Rev02

12.10.3.3 Inquiry Specifiers

The following inquiry specifiers may be used in either form of the INQUIRE statement:

IOSTAT = iosERR = sEXIST = exOPENED = odNUMBER = numNAMED = nadNAME = fnACCESS = accSEQUENTIAL = seqDIRECT = dirFORM = fmFORMATTED = fatUNFORMATTED = unfRECL = rclNEXTREC = nr[ NEW ANSI77 [BLANK = blnkRECFORM = rfSPANNING = spnPRINT = prtDELIM = dlm ].NEW ANSI77. ]

The specifiers are described as follows:

IOSTAT = ios

is an input/output status specifier (12.7). Execution of an INQUIRE statement containingthis specifier causes ios to become defined with a zero value if no error condition existsor with a processor-dependent positive integer value if an error condition exists.

ERR = s

is an error specifier (12.7.1).

EXIST = ex

ex is a logical variable or logical array element. Execution of an INQUIRE by filestatement causes ex to be assigned the value true if there exists a file with the specifiedname; otherwise, ex is assigned the value false. Execution of an INQUIRE by unitstatement causes ex to be assigned the value true if the specified unit exists; otherwise,ex is assigned the value false.

OPENED = od

od is a logical variable or logical array element. Execution of an INQUIRE by filestatement causes od to be assigned the value true if the file specified is connected to aunit; otherwise, od is assigned the value false. Execution of an INQUIRE by unitstatement causes od to be assigned the value true if the specified unit is connected to afile; otherwise, od is assigned the value false.

Page 231: FORTRAN 77 Reference Manual - Bull

INPUT/OUTPUT Statements

47 A2 15UL Rev02 12-53

NUMBER = num

num is an integer variable or integer array element that is assigned the value of theexternal unit identifier of the unit that is currently connected to the file. If there is no unitconnected to the file, num becomes undefined.

NAMED = nad

nad is a logical variable or logical array element that is assigned the value true if the filehas a name; otherwise, it is assigned the value false.

NAME = fn

fn is a character variable or character array element that is assigned the value of thename of the file, if the file has a name; otherwise, it becomes undefined.! PROCESSOR-DEPENDENT [ Note that if this specifier appears in an INQUIRE by filestatement, its value is not necessarily the same as the name given in the FILE=specifier. For example, INQUIRE with an IFN = ifn FILE=specifier returns a value of fn,which is the GCL file literal of the file assigned thru the Internal File Name ifn.].PROCESSOR-DEPENDENT.!The value returned is suitable for use as the value of a FILE= specifier in an OPENstatement.

ACCESS = acc

acc is a character variable or character array element that is assigned the valueSEQUENTIAL if the file is connected for sequential access, and DIRECT if the file isconnected for direct access. If there is no connection, acc becomes undefined.

! PROCESSOR-DEPENDENT [ If the file is preconnected to a unit that has not beenreferenced since the beginning of the execution, except possibly by an INQUIREstatement, acc is assigned the value UNKNOWN. ].PROCESSOR-DEPENDENT.!

SEQUENTIAL = seq

seq is a character variable or character array element that is assigned the value YES ifSEQUENTIAL is included in the set of allowed access methods for the file, NO ifSEQUENTIAL is not included in the set of allowed access methods for the file, andUNKNOWN if the processor is unable to determine whether or not SEQUENTIAL isincluded in the set of allowed access methods for the file.

! PROCESSOR-DEPENDENT [ Note that if a file is connected for direct access, seqmay be assigned with the value UNKNOWN, and not NO. This is the case where theprocessor is unable to determine if the file may be connected for sequential access byan OPEN after a CLOSE statement. The ACCESS= specifier gives information about theaccess method used by the executable program, whereas the SEQUENTIAL=, orDIRECT= specifier give information about the file. The value UNKNOWN is due to thefact that in some cases, to determine if it is possible to perform sequential (or direct)access, the processor should have to execute a sequential (or direct) READ. This is notdone because it would modify the state of the file. ].PROCESSOR-DEPENDENT.!

Page 232: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

12-54 47 A2 15UL Rev02

DIRECT = dir

dir is a character variable or character array element that is assigned the value YES ifDIRECT is included in the set of allowed access methods for the file, NO if DIRECT isnot included in the set of allowed access methods for the file, and UNKNOWN if theprocessor is unable to determine whether or not DIRECT is included in the set of allowedaccess methods for the file.

FORM = fm

fm is a character variable or character array element that is assigned the valueFORMATTED if the file is connected for formatted input/output, and is assigned thevalue UNFORMATTED if the file is connected for unformatted input/output. If there is noconnection, fm becomes undefined.

[ NEW ANSI77 [ If the file is preconnected to a unit that has not been referenced sincethe beginning of the execution, except possibly by an INQUIRE statement, fm isassigned the value UNKNOWN. ].NEW ANSI77. ]

FORMATTED = fmt

fmt is a character variable or character array element that is assigned the value YES ifFORMATTED is included in the set of allowed forms for the file, NO if FORMATTED isnot included in the set of allowed forms for the file, and UNKNOWN if the processor isunable to determine whether or not FORMATTED is included in the set of allowed formsfor the file.

! PROCESSOR-DEPENDENT [ For DPS7 FORTRAN 77 there is no information storedin the file to record if its form is formatted or unformatted. If the file exists, fmt isassigned the value YES. ].PROCESSOR-DEPENDENT.!

UNFORMATTED = unf

unf is a character variable or character array element that is assigned the value YES ifUNFORMATTED is included in the set of allowed forms for the file, NO ifUNFORMATTED is not included in the set of allowed forms for the file, and UNKNOWNif the processor is unable to determine whether or not UNFORMATTED is included inthe set of allowed forms for the file.

! PROCESSOR-DEPENDENT [ If the file is exists, unf is assigned the value YES.].PROCESSOR-DEPENDENT.!

RECL = rcl

rcl is an integer variable or integer array element that is assigned the value of the recordlength of the file connected for direct access, [ NEW ANSI77 [ or the maximum value ofthe record length of the file connected for sequential access. ].NEW ANSI77. ]

Page 233: FORTRAN 77 Reference Manual - Bull

INPUT/OUTPUT Statements

47 A2 15UL Rev02 12-55

If the file is connected for formatted input/output, the length is the number of characters.If the file is connected for unformatted input/output, the length is measured in characterstorage units ! PROCESSOR-DEPENDENT [ (bytes of 8 bits). ].PROCESSOR-DEPENDENT.!

! PROCESSOR-DEPENDENT [ If the file is preconnected to a unit that has not beenreferenced since the beginning of execution, except possibly by INQUIRE statements, rclis assigned the value 0. If there is no connection, rcl becomes undefined.].PROCESSOR-DEPENDENT.!

NEXTREC = nr

nr is an integer variable or integer array element that is assigned the value n+1, where nis the record number of the last record read or written on the file connected for directaccess.If the file is connected but no records have been read or written since the connection, nris assigned the value 1. If the file is not connected for direct access or if the position ofthe file is indeterminate because of a previous error condition, nr becomes undefined.

! PROCESSOR-DEPENDENT [ If the file is preconnected to a unit that has not beenreferenced since the beginning of the execution, except possibly by INQUIREstatements, nr is assigned the value 0. ].PROCESSOR-DEPENDENT.!

BLANK = blnk

blnk is a character variable or character array element that is assigned the value NULL ifnull blank control is in effect for the file connected for formatted input/output, and isassigned the value ZERO if zero blank control is in effect for the file connected forformatted input/output. If there is no connection, or if the connection is not for formattedinput/output, blnk becomes undefined.

! PROCESSOR-DEPENDENT [ If the file is preconnected to a unit that has not beenreferenced since the beginning of execution, except possibly by INQUIRE statements,blnk is assigned the value UNKNOWN. ].PROCESSOR-DEPENDENT.!

[ NEW ANSI77 [

RECFORM = rf

rf is a character variable or character array element that is assigned the value FIXED ifthe file is made of fixed length records, or VARIABLE if the file is made of variable lengthrecords.

SPANNING = spn

spn is a character variable or character array element that is assigned the value YES ifthe file is connected by use of an OPEN statement with YES for the value of theSPANNING= specifier; and NO otherwise.

PRINT = prt

prt is a character variable or a character array element that is assigned the value YES ifthe file is such that the first character of each written record determines the verticalspacing, and NO otherwise.

Page 234: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

12-56 47 A2 15UL Rev02

DELIM = dlm

dlm is a character variable or character array element that is assigned the valueAPOSTROPHE if the apostrophe is to be used to delimit character constants written bylist-directed formatting or namelist formatting. If the quotation mark is used to delimitthese constants, the value QUOTE is assigned. If neither the apostrophe nor the quote isused to delimit the character constants, the value NONE is assigned. If there is noconnection, or if the connection is not for formatted input/output, dlm becomesundefined. ].NEW ANSI77. ]

A variable or array element that may become defined or undefined as a result of its useas a specifier in an INQUIRE statement, or any associated entity, must not bereferenced by any other specifier in the same INQUIRE statement.

Execution of an INQUIRE by file statement causes the specifier variables or arrayelements nad, in, seq, dir, fmt, and unf to be assigned values only if the value of fin isacceptable to the processor as a file name and if there exists a file by that name;otherwise, they become undefined. Note that num becomes defined if and only if odbecomes defined with the value true.Note also that the specifier variables or array elements acc, fm, rcl, nr, and blnk maybecome defined only if od becomes defined with the value true.

Execution of an INQUIRE by unit statement causes the specifier variables or arrayelements num, nad, fn, acc, seq, dir, fm, fmt, unf, rcl, nr, and blnk to be assigned valuesonly if the specified unit exists and if a file is connected to the unit: otherwise, theybecome undefined.

If an error condition occurs during execution of an INQUIRE statement, all of the inquiryspecifier variables and array elements except ios become undefined.

Note that the specifier variables or array elements ex and od always become definedunless an error condition occurs.

Page 235: FORTRAN 77 Reference Manual - Bull

INPUT/OUTPUT Statements

47 A2 15UL Rev02 12-57

! PROCESSOR-DEPENDENT [ For DPS7 FORTRAN 77 the following values are givenby an INQUIRE statement. In cases of an existing file, and a connected unit severalvalues may be obtained, as indicated for each specifier (12.10.3.2).

inquire by unit inquire by file

unit is notconnected

file does not exist unit exists file exists

unit is connected

EXIST

OPENED

NUMBER

NAMED

ACCESS

FORM

SEQUENTIAL

DIRECT

NAME

FORMATTED

UNFORMATTED

DELIM

BLANK

NEXTREC

RECFORM

RECL

PRINT

SPAN

unit doesnot exist

file is notconnected

file is connected

unit is pre-connected butnot yetreferenced

file doesnot exist

file is pre-connected butnot yetreferenced

.FALSE. .TRUE.

.FALSE.

-1

.FALSE.

blanks

blanks

blanks

blanks

blanks

blanks

blanks

blanks

blanks

blanks

blanks

blanks

-1

-1

.FALSE.

-1

.FALSE.

blanks

blanks

blanks

blanks

blanks

blanks

blanks

blanks

blanks

blanks

blanks

blanks

-1

-1

.FALSE.

.FALSE.

-1

.FALSE.

blanks

blanks

blanks

blanks

blanks

blanks

blanks

blanks

blanks

blanks

blanks

blanks

-1

-1

.TRUE.

.FALSE.

-1

blanks

blanks

blanks

blanks

blanks

blanks

blanks

-1

-1

.TRUE.

.FALSE.

blanks

-1

-1

unit

.TRUE.

'UNKNOWN'

'YES'

'YES'

'YES'

'UNKNOWN'

'UNKNOWN'

'UNKNOWN'

'UNKNOWN'

'UNKNOWN'

'UNKNOWN'

'UNKNOWN'

.TRUE.

unit

.TRUE.

'YES'

'YES'

'YES'

.FALSE./ .TRUE.

fl/name

'YES'/'NO'

'YES'/'NO'

'YES'/'NO'

-1/1/nextrec

bl/'YES'/'NO'

bl/'QUOTE'/ 'APOSTROPHE'/ 'NONE'

recl

'FIXED'/ 'VARIABLE'

'FORMATTED'/ 'UNFORMATTED'

'SEQUENTIAL'/ 'DIRECT'

name

.TRUE.

-1

-1

unit

.TRUE.

'UNKNOWN'

'YES'

'YES'

'YES'

'UNKNOWN'

'UNKNOWN'

'UNKNOWN'

'UNKNOWN'

'UNKNOWN'

'UNKNOWN'

'UNKNOWN'

.TRUE.

unit

.TRUE.

'YES'

'YES'

'YES'

'YES'/'NO'

'YES'/'NO'

'YES'/'NO'

-1/1/nextrec

bl/'YES'/'NO'

bl/'QUOTE'/ 'APOSTROPHE'/ 'NONE'

recl

'FIXED'/ 'VARIABLE'

'FORMATTED'/ 'UNFORMATTED'

'SEQUENTIAL'/ 'DIRECT'

name name

.TRUE. .TRUE. .TRUE.

'YES'

'YES'

'YES'

'UNKNOWN'

Example 1:

INQUIRE by file, to test if a file is cataloged, or if it is on the resident media.

PROGRAM E730 LOGICAL LEXIST, LOPEN CHARACTER *100 CX INQUIRE (FILE='EFN730', EXIST=LEXIST, IOSTAT=I) IF (LEXIST) THENC the file is cataloged or is on the resident media INQUIRE (FILE='EFN730$CAT', EXIST=LEXIST, ERR=10) IF (LEXIST) THENC the file is cataloged ELSEC the file is on the resident media ENDIF ENDIF END

Page 236: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

12-58 47 A2 15UL Rev02

Example 2:

INQUIRE by unit, to test if a file is preconnected, or assigned

SUBROUTINE E740 LOGICAL LOPENED, LEXIST INQUIRE (UNIT=10, OPENED=LOPENED) IF (OPENED) THENC the unit is preconnected by aC ASSIGN 10 jcl statement ELSE INQUIRE (FILE='IFN=IFN740', EXIST=LEXIST, IOSTAT=IOS) IF (IOS.EQ.0) THENC there is a $ASSIGN IFN740 jcl statement; IF (LEXIST) THENC the assigned file exists ELSEC the assigned file does not exist ENDIF ELSEC an error condition occurred: thereC is no $ASSIGN IFN740 jcl statement ENDIF ].PROCESSOR-DEPENDENT.!

12.10.4 File Positioning Statements

The forms of the file positioning statements are:

BACKSPACE u BACKSPACE (alist)

ENDFILE u ENDFILE (alist)

REWIND u REWIND (alist)

where:

u is an external unit identifier (12.3.3)alist is a list (2.10) of specifiers:

[UNIT =] u IOSTAT = ios ERR = s

A list must contain exactly one external unit specifier (12.3.3) and may contain at mostone of each of the other specifiers.

Page 237: FORTRAN 77 Reference Manual - Bull

INPUT/OUTPUT Statements

47 A2 15UL Rev02 12-59

The external unit specified by a BACKSPACE, ENDFILE, or REWIND statement mustbe connected for sequential access.

Execution of a file positioning statement containing an input/output status specifiercauses ios to become defined with a zero value if no error condition exists or with aprocessor-dependent positive integer value if an error condition exists.

12.10.4.1 Backspace Statement

Execution of a BACKSPACE statement causes the file connected to the specified unit tobe positioned before the preceding record.If there is no preceding record, the position of the file is not changed. Note that if thepreceding record is an endfile record, the file becomes positioned before the endfilerecord.

Backspacing a file that is connected but does not exist is prohibited.

Backspacing over records written using list-directed formatting is prohibited.

12.10.4.2 Endfile Statement

Execution of an ENDFILE statement writes an endfile record as the next record of thefile. The file is then positioned after the endfile record. If the file may also be connectedfor direct access, only those records before the endfile record are considered to havebeen written. Thus, only those records may be read during subsequent direct accessconnections to the file.

After execution of an ENDFILE statement, a BACKSPACE or REWIND statement mustbe used to reposition the file prior to execution of any data transfer input/outputstatement.

Execution of an ENDFILE statement for a file that is connected but does not existcreates the file.

12.10.4.3 Rewind Statement

Execution of a REWIND statement causes the specified file to be positioned at its initialpoint. Note that if the file is already positioned at its initial point, execution of thisstatement has no effect on the position of the file.

Execution of a REWIND statement for a file that is connected but does not exist ispermitted but has no effect.

Page 238: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

12-60 47 A2 15UL Rev02

12.11 RESTRICTIONS ON FUNCTION REFERENCES AND LIST ITEMS

A function must not be referenced within an expression appearing anywhere in aninput/output statement if such a reference causes an input/output statement to beexecuted. Note that a restriction in the evaluation of expressions (6.6) prohibits certainside effects.

12.12 RESTRICTION ON INPUT/OUTPUT STATEMENTS

If a unit, or a file connected to a unit, does not have all of the properties required for theexecution of certain input/output statements, those statements must not refer to the unit.

! PROCESSOR-DEPENDENT [ Especially, use of the BACKSPACE statement isrestricted in mass storage files having a fixed recording form (12.2.4.1).

Note also that input statements may be forbidden on certain files (e.g., a print file), andthat output statements may be forbidden on certain other files (e.g., an input enclosurefile). ].PROCESSOR-DEPENDENT.!

Page 239: FORTRAN 77 Reference Manual - Bull

47 A2 15UL Rev02 13-1

13. Format Specification

A format used in conjunction with formatted input/output statements provides informationthat directs the editing between the internal representation and the character strings of arecord or a sequence of records in the file.

A format specification provides explicit editing information. An asterisk (*) as a formatidentifier in an input/output statement indicates list-directed formatting (13.6).

13.1 FORMAT SPECIFICATION METHODS

Format specifications may be given:

1. In FORMAT statements

2. As values of character arrays, character variables, or other character expressions.

# OLD ANSI77 [

3. As values of integer arrays defined with hollerith data.

].OLD ANSI77.#

13.1.1 FORMAT Statement

The form of a FORMAT statement is:

FORMAT fs

where fs is a format specification, as described in 13.2. # OLD ANSI77 [ The FORMATstatement may be used only if it is labelled. ].OLD ANSI77.#

Page 240: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

13-2 47 A2 15UL Rev02

13.1.2 Character Format Specification

If the format identifier (12.4) in a formatted input/output statement is a character arrayname, character variable name, or other character expression, the leftmost characterposition of the specified entity must be in a defined state with character data thatconstitute a format specification when the statement is executed.

# OLD ANSI77 [ I f the format identifier in a formatted input/output statement is aninteger array name, the leftmost character position of the array must contain hollerithdata that constitutes a format specification when the statement is executed.

The format specification must be of the form described in 13.2. It must begin with a leftparenthesis and must end with a right parenthesis. Data may follow the right parenthesisthat ends the format specification and have no effect. Blank characters may precede theformat specification. ].OLD ANSI77.#

A Hollerith format specification must not contain an apostrophe edit descriptor or an Hedit descriptor.

A character format specification must be of the form described in 13.2. Note that theform begins with a left parenthesis and ends with a right parenthesis. Character datamay follow the right parenthesis that ends the format specification, with no effect on theformat specification. Blank characters may precede the format specification.

If the format identifier is a character array name, the length of the format specificationmay exceed the length of the first element of the array; a character array formatspecification is considered to be a concatenation of all the array elements of the array inthe order given by array element ordering (5.2.4).However, if a character array element name is specified as a format identifier, the lengthof the format specification must not exceed the length of the array element.

Page 241: FORTRAN 77 Reference Manual - Bull

Format Specification

47 A2 15UL Rev02 13-3

13.2 FORM OF A FORMAT SPECIFICATION

The form of a format specification is:

[flist])

where flist is a list (2.10). The forms of the flist items are:

[r] edned[r] fs

where:

ed is a repeatable edit descriptor (13.2.1)ned is a nonrepeatable edit descriptor (13.2.1)fs is a format specification with a nonempty list flistr is a nonzero, unsigned, integer constant called a repeat

specification

The comma used to separate list items in the list flist may be omitted as follows:

1. Between a P edit descriptor and an immediately following F, E, D, Q, or G editdescriptor (13.5.9)

2. After a slash edit descriptor (13.5.4)

3. Before a slash edit descriptor, # OLD ANSI77 [ if it has no repeat specification.].OLD ANSI77.#

4. Before or after a colon edit descriptor (13.5.5).

Page 242: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

13-4 47 A2 15UL Rev02

13.2.1 Edit Descriptors

An edit_descriptor is either a repeatable edit descriptor or a nonrepeatable edit descriptor.

The forms of a repeatable_edit_descriptor are:

IwIw.mFw.dEw.dEw.dEeDw.dGw.dGw.dEeLwA[ NEW ANSI77 [AwQw.dZwRwGw/ ].NEW ANSI77. ]

where:

I, E, D, G, L, A, Q, Z, R, G, [ NEW ANSI77 [ and / ].NEW ANSI77. ] indicate the mannerof editing

w and e are nonzero, unsigned, integer constants

d and m are unsigned integer constants

# OLD ANSI77 [

LEVEL = SIRIS 8

The forms of a repeatable edit descriptor are:

I[w]I[w] [.m]F[w] [.d]E[w] [.d [Ee]]D[w] [.d]G[w] [.d [Ee]]L[w]A[w]Z[w]R[w]Q[w][.d]/Any of the constants r, w, d, e, n, k and c may be replaced by the = character. ].OLDANSI77.#

Page 243: FORTRAN 77 Reference Manual - Bull

Format Specification

47 A2 15UL Rev02 13-5

The forms of a nonrepeatable_edit_descriptor are:

'h 1 h 2 ... h n 'nHh 1 h 2 ... h nTcTLcTRcnX:SSPSSkPBNBZ

where:

apostrophe, H, T, TL, TR, X, slash, colon, S, SP, SS, P, BN, and BZ indicates the mannerof editing

h is one of the characters capable of representation by theprocessor

n and c are nonzero, unsigned, integer constantsk is an optionally signed integer constant

Page 244: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

13-6 47 A2 15UL Rev02

13.3 INTERACTION BETWEEN INPUT/OUTPUT LIST AND FORMAT

The beginning of formatted data transfer using a format specification (12.9.5.2.1) initiatesformat_control. Each action of format control depends on information jointly provided by:

1. the next edit descriptor contained in the format specification, and

2. the next item in the input/output list, if one exists.

If an input/output list specifies at least one list item, at least one repeatable edit descriptormust exist in the format specification. Note that an empty format specification of the form () may be used only if no list items are specified; in this case, one input record is skippedor one output record containing no characters is written. Except for an edit descriptorpreceded by a repeat specification, r ed, and a format specification preceded by a repeatspecification, r(flist), a format specification is interpreted from left to right. A formatspecification or edit descriptor preceded by a repeat specification r is processed as a listof r format specifications or edit descriptors identical to the format specification or editdescriptor without the repeat specification. Note that an omitted repeat specification istreated the same as a repeat specification whose value is one.

To each repeatable edit descriptor interpreter interpreted in a format specification, therecorresponds one item specified by the input/output list (12.8.2), except that a list item oftype complex requires the interpretation of two F, E, D, or G edit descriptors. To each P,X, T, TL, TR, S, SP, SS, H, BN, BZ, slash, colon, or apostrophe edit descriptor, there is nocorresponding item specified by the input/output list, and format control communicatesinformation directly with the record.

Whenever format control encounters a repeatable edit descriptor in a format specification,it determines whether there is a corresponding item specified by the input/output list. Ifthere is such an item, it transmits appropriately edited information between the item andthe record, and then format control proceeds.If there is no corresponding item, format control terminates.

If format control encounters a colon edit descriptor in a format specification and anotherlist item is not specified, format control terminates.

If format control encounters the rightmost parenthesis of a complete format specificationand another list item is not specified, format control terminates. However, if another listitem is specified, the file is positioned at the beginning of the next record and formatcontrol then reverts to the beginning of the format specification terminated by the lastpreceding right parenthesis. If there is no such preceding right parenthesis, format controlreverts to the first left parenthesis of the format specification. If such reversion occurs, thereused portion of the format specification must contain at least one repeatable editdescriptor [ NEW ANSI77 [ different from the / edit descriptor. ].NEW ANSI77. ] If formatcontrol reverts to a parenthesis that is preceded by a repeat specification, the repeatspecification is reused. Reversion of format control, of itself, has no effect on the scalefactor (13.5.7), the S, SP, or SS edit descriptor sign control (13.5.6), or the BN or BZ editdescriptor blank control (13.5.8).

! PROCESSOR-DEPENDENT [

Page 245: FORTRAN 77 Reference Manual - Bull

Format Specification

47 A2 15UL Rev02 13-7

Example:

The following is an example of interaction between Input/OutputList and Format:

COMPLEX C

WRITE (2,100) I, A, B, C

100 FORMAT (I5, F10.3, E10.3, 2G15.7)

END

I is edited with I5 edit descriptor

A -------------- F10.3 ----------------

B -------------- E10.3 ----------------

real part of C -------------- G15.7 ----------------

imaginary part of C -------------- G15.7 ----------------

Example:

The following is an example of format control reversion.

PROGRAM E760 READ (2,100) A, B, C, D

100 FORMAT (1X,(1X,(F10.3),(F10.3,(E10.3))) END

Reversion of format occurs here

This portion of format contains repeatable edit description

"Last preceding right parenthesis"

A is edited with F10.3 edit descriptor

B -------------- F10.3 --------------

C -------------- E10.3 --------------

D -------------- F10.3 --------------

Page 246: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

13-8 47 A2 15UL Rev02

Example:

The following is another example of format control reversion.

PROGRAM E770READ (2,100) A, B, C, D

100 FORMAT (1X,(F10.3,(E10.3)),(10x,(/))) END

Reversion occurs here

"Last preceding right parenthesis"

This portion of format does not contain repeatableedit descriptors different from /

A is edited with F10.3 edit descriptor

B -------------- E10.3 --------------

C -------------- F10.3 --------------

D -------------- E10.3 --------------

Page 247: FORTRAN 77 Reference Manual - Bull

Format Specification

47 A2 15UL Rev02 13-9

13.3.1 Correspondence Between Edit Descriptors and Item Types

The following table figures the edit descriptors which may be used, to edit an input/outputlist item of a given type. The letter P means that it is ANSI77, and N that it is a DPS7FORTRAN 77 extension.

I

Edit descriptor

Integer

Real

Double precision

Complex

Character

Logical

Short integer

F E D Gw.d 1 L A

N P

Item type

Quadruple precision

Complex double

Short Logical

P P

P P P

P

P

P P P

P

R Q Z Gw

P

N

N

N

N

N

N N

N

N

N N

N

N

N

N

N

N

N

N

N

N N

N

N

].PROCESSOR-DEPENDENT.!

Page 248: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

13-10 47 A2 15UL Rev02

13.3.2 Quantity Replacements

# OLD ANSI77 [ LEVEL = SIRIS 8

If a Quantity r, u, d, e, n, k or e is replaced by the Equal Sign = , its value is obtained bythe value of the next I/O list element.

The following rules define how the value = must be specified in a list and the way thesevalues are used.

1. Integers, reals and double precision data can be given as values of =. Non integervalues will be truncated to integer.

2. The resulting value cannot be negative if = replaces k.

3. When = appears one or more times in the same formal specification, its valuesmust appear sequentially in the list and must precede any elements which must betreated by the specification.

Example:

Adjustable FormatsThe list

3,4,1,A,B,C,12,-2,D

and the instruction

3 FORMAT (=E=.=,=x,=P,G14.7)

are equivalent to the list

A,B,C,D

and the instruction

3 FORMAT (3E4.1,12x,-2P,G14.7)

Page 249: FORTRAN 77 Reference Manual - Bull

Format Specification

47 A2 15UL Rev02 13-11

4. Every time a given format specification enclosed in parentheses is used, a valuemust be given for each repetition of the specification in parentheses. The followingtwo examples illustrate the difference resulting from placing a specification inparentheses

7,A,B,C and 3F=.2

is equivalent to

A,B,C and 3F7.2

and

7,A,7,B,7,C and 3(F=.2)

is equivalent to

A,B,C and 3(F7.2)

5. It can be noted in the above example that in the specification 3F=.2, only one singlevalue of = is necessary, independent of the number of repetitions whilst in 3(F=.2),the number of values necessary for = is equal to the number of specifications. Thesame rule can be extended to the case of a number of repetitions of zero values.

- If the number of repetitions of a block which is not between parentheses isreplaced by an = and its value is zero, then all the specifications enclosed bythe parentheses, including the equal signs =, will be ignored.

- If the number of repetitions of a format edit descriptor is replaced by an =, and ifits value is zero, then all the ='s appearing in the interior of the format editdescriptor and the format edit descriptor itself will be ignored.

Example:

0,y and = (C20.=), F8.1 0,y and = G20.=, F8.1

are equivalent to

y and F8.1

In the above two cases, no value is given to the G specification. However, puttingthe specification between parentheses can be done to see if a value must be givento N. The possibility to thus define a zero number of repetitions, allows theprogrammer to select or jump over particular specifications in a FORMATinstruction.

Page 250: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

13-12 47 A2 15UL Rev02

Example:

Adjustable format with = having zero value.

T=0 F=1 IF(BOOL) THEN T=1 F=0 ENDIF PRINT 17, BOOL, T, F17 FORMAT (L1,=(3HRUE,=('ALSE'))

prints TRUE or FALSE, depending on the value of BOOL.

6. The value of = may be given by an expression in an input/output list, however, anexpression used this way for an input list is not considered, as properly belonging tothe input list.

An example using the adjustable format specification is:

READ(101,205)K,K,(A(J),J=1,K),CODE

205 FORMAT (I5,=E10.3,A)

The input value for K does not uniquely define the number of values that must beentered in the table A as it also gives the number of conversions that must be carried outby the E specification. Also the alphanumeric value of CODE can be contiguous to thelast entry zone allocated to the table A, independent of the number of these zones. As aresult, all recordings of following entries can be treated correctly by the precedinginstructions.

bbbb1b65.25E+7bALPHA

bbbb2 - 65.25E+7b - 65.35E+8bALPHA END LEVEL=SIRIS8 ].OLD ANSI77.#

Page 251: FORTRAN 77 Reference Manual - Bull

Format Specification

47 A2 15UL Rev02 13-13

13.4 POSITIONING BY FORMAT CONTROL

After each I, F, E, D, G, L, A, H, Q, R, Z, or apostrophe edit descriptor is processed, thefile is positioned after the last character read or written in the current record.

After each T, TL, TR, X or slash edit descriptor is processed, the file is positioned asdescribed in 13.5.3 and 13.5.4.

If format control reverts as described in 13.3, the file is positioned in a manner identical tothe way it is positioned when a slash edit descriptor is processed (13.5.4).

During a read operation, any unprocessed characters of the record are skipped wheneverthe next record is read.

13.4.1 Formats_without_Length_Specification

# OLD ANSI77 [ LEVEL=SIRIS8

Formats_without_Length_Specification

INPUT

If the format edit description does not contain the length specifications w or is of type I, F,E, D, G, L, or Q then decoding starts at the first non blank character and stops at thecomma or blank space.

The length of a format edit descriptor is defined by: leading blanks, the zone to beconverted and the separator. The procedure is the same as for list directed.

Example:

100 FORMAT (I,F.0) READ(2,100) I,R

Input

|bb20bb,30.| I = 20 R = 30.|-----|----| end of record I F

|bb30bb40| I = 30 R = 40.|---| |--| end of record I R

OUTPUT

If the length w is not specified the format calculates the minimum length of the zone foroutputting the variable and precedes it with a blank.

Page 252: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

13-14 47 A2 15UL Rev02

Example:

FORMAT | value | calculated value of w I | 20 | 3 F.3 | - 1. | 7 L | .TRUE. | 2If the format does not contain the specification d then

d = 0

is the default value.

13.4.2 The Comma Separator in Input mode

In every FORMAT of the type I, F, E, D, Q, G, or L the comma is considered as aseparator.

Example:

FORMAT (I10,E10.3,LT0) READ (2,100) I,R,L

INPUT: 2,3.,T I=2 R=3. L=.TRUE.

13.4.3 Length of Input Record

The record is considered to be of infinite length. Characters past the end marker areassumed to be blank.

END LEVEL=SIRIS8 ].OLD ANSI77.#

Page 253: FORTRAN 77 Reference Manual - Bull

Format Specification

47 A2 15UL Rev02 13-15

13.5 EDITING

Edit descriptors are used to specify the form of a record and to direct the editing betweenthe characters in a record and internal representations of data.

A field is a part of a record that is read on input or written on output when format controlprocesses one I, F, E, D, G, L, A, H, apostrophe, [ NEW ANSI77 [ or Q, R, Z editdescriptor. ].NEW ANSI77. ] The field width is the size in characters of the field.

The internal representation of a datum corresponds to the internal representation of aconstant of the corresponding type (Section 4).

13.5.1 Apostrophe Editing

The apostrophe edit descriptor has the form of a character constant. It causescharacters to be written from the enclosed characters (including blanks) of the editdescriptor itself. An apostrophe edit descriptor must not be used on input.

The width of the field is the number of characters contained in, but not including, thedelimiting apostrophes. Within the field, two consecutive apostrophes with no interveningblanks are counted as a single apostrophe.

13.5.2 H Editing

The nH edit descriptor causes character information to be written from the n characters(including blanks) following the H of the nH edit descriptor in the format specificationitself. An H edit descriptor must not be used on input.

Note that if an H edit descriptor occurs within a character constant and includes anapostrophe, the apostrophe must be represented by two consecutive apostrophes, whichare counted as one character in specifying n.

Page 254: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

13-16 47 A2 15UL Rev02

13.5.3 Positional Editing

The T, TL, TR, and X edit descriptors specify the position at which the next character willbe transmitted to or from the record.

The position specified by a T edit descriptor may be in either direction from the currentposition. On input, this allows portions of a record to be processed more than once,possibly with different editing.

The position specified by an X edit descriptor is forward from the current position. Oninput, a position beyond the last character of the record may be specified if no charactersare transmitted from such positions.

On output, a T, TL, TR, or X edit descriptor does not by itself cause characters to betransmitted and therefore does not by itself affect the length of the record. If charactersare transmitted to positions at or after the position specified by a T, TL, TR, or X editdescriptor, positions skipped and not previously filled are filled with blanks. The result isas if the entire record were initially filled with blanks.

On output, a character in the record may be replaced. However, a T, TL, TR, or X editdescriptor never directly causes a character already placed in the record to be replaced.Such edit descriptors may result in positioning so that subsequent editing causes areplacement.

13.5.3.1 T, TL, and TR Editing

The Tc edit descriptor indicates that the transmission of the next character to or from arecord is to occur at the cth character position.

The TLc edit descriptor indicates that the transmission of the next character to or fromthe record is to occur at the character position c characters backward from the currentposition. However, if the current position is less than or equal to position c, the TLc editdescriptor indicates that the transmission of the next character to or from the record is tooccur at position one of the current record.

The TRc edit descriptor indicates that the transmission of the next character to or fromthe record is to occur at the character position c characters forward from the currentposition.

13.5.3.2 X Editing

The nX edit descriptor indicates that the transmission of the next character to or from arecord is to occur at the position n characters forward from the current position.

Page 255: FORTRAN 77 Reference Manual - Bull

Format Specification

47 A2 15UL Rev02 13-17

13.5.4 Slash Editing

The slash edit descriptor indicates the end of data transfer on the current record.

On input from a file connected for sequential access, the remaining portion of the currentrecord is skipped and the file is positioned at the beginning of the next record. Thisrecord becomes the current record. On output to a file connected for sequential access,a new record is created and becomes the last and current record of the file.

Note that a record that contains no characters may be written on output. If the file is aninternal file or a file connected for direct access, the record is filled with blank characters.Note also that an entire record may be skipped on input.

For a file connected for direct access, the record number is increased by one and the fileis positioned at the beginning of the record that has that record number. This recordbecomes the current record.

13.5.5 Colon Editing

The colon edit descriptor terminates format control if there are no more items in theinput/output list (13.3). The colon edit descriptor has no effect if there are more items inthe input/output list.

Page 256: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

13-18 47 A2 15UL Rev02

Example:

! PROCESSOR-DEPENDENT [

Colon Editing

Assume the following statement:

IARRAY=10 IELEM=0 . . . 10 WRITE(6,1000)IARRAY,IELEM . . . IARRAY=11 IELEM=25 . . . XMIN=-.37E1 XMAX=.249E1 . . . 20 WRITE(6,1000)IARRAY,IELEM,XMIN,XMAX1000 FORMAT('0 TABLE NUMBER',I5,:,'CONTAINS',I5,'ELEMENTS', 1 /'MINIMUM VALUE:',E15.7, 2 /'MAXIMUM VALUE:',E15.7)

The WRITE statement at statement number 10 generates the following:

TABLE NUMBER 10 CONTAINS 0 ELEMENTS

The WRITE statement at statement number 20 generates the following:

TABLE NUMBER 11 CONTAINS 25 ELEMENTS MINIMUM VALUE: -.3700000E+01 MAXIMUM VALUE: .2495000E+03 ].PROCESSOR-DEPENDENT.!

Page 257: FORTRAN 77 Reference Manual - Bull

Format Specification

47 A2 15UL Rev02 13-19

13.5.6 S, SP, and SS Editing

The S, SP, and SS edit descriptors may be used to control optional plus characters innumeric output fields. At the beginning of execution of each formatted output statement,the processor has the option of producing a plus in numeric output fields. If an SP editdescriptor is encountered in a format specification, the processor must produce a plus inany subsequent position that normally contains an optional plus. If an SS edit descriptoris encountered, the processor must not produce a plus in any subsequent position thatnormally contains an optional plus. If an S edit descriptor is encountered, the option ofproducing the plus is restored to the processor.

[ NEW ANSI77 [The S, SP, and SS edit descriptors affect only I, F, E, D, Q, and G editing during theexecution of an output statement. ].NEW ANSI77. ] The S, SP, and SS edit descriptorshave no effect during the execution of an input statement.

Example:

! PROCESSOR-DEPENDENT [

PROGRAM E800

D=20.3E= 8.5F=30.0WRITE(2(1X,F6.2,SP,F6.2,SS,F6.2)')D,E,FEND

this prints the following:

bb20.30b+8.50b30.00].PROCESSOR-DEPENDENT.!

13.5.7 P Editing

A Scale factor is specified by a P edit descriptor, which is of the form:

kP

where k is an optionally signed integer constant, called the scale factor.

The value of the scale factor is zero at the beginning of execution of each input/outputstatement. [ NEW ANSI77 [ It applies to all subsequently interpreted F, E, D, G, and Qedit descriptors until another scale factor is encountered, ].NEW ANSI77. ] and thenthat scale factor is established. Note that reversion of format control (13.3) does notaffect the established scale factor.

Page 258: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

13-20 47 A2 15UL Rev02

The scale factor k affects the appropriate editing in the following manner:

1. [ NEW ANSI77 [ On input, with F, E, D, Q, and G editing (provided that noexponent exists in the field) ].NEW ANSI77. ] and F output editing, the scale factoreffect is that the externally represented number equals the internally representednumber multiplied by 10**k.

[ NEW ANSI77 [

2. On input, with F, E, D, Q, and G editing, the scale factor has no effect if there is anexponent in the field. ].NEW ANSI77. ]

3. On output, with E and D editing, the basic real constant (4.4.1) part of the quantityto be produced is multiplied by 10**k and the exponent is reduced by k.

4. On output, with G editing, the effect of the scale factor is suspended unless themagnitude of the datum to be edited is outside the range that permits the use of Fediting. If the use of E editing is required, the scale factor has the same effect aswith E output editing.

! PROCESSOR-DEPENDENT [

Example:

15 FORMAT(2P,E15.6,F12.3,G15.5,OP,4F14.1)

The 2P scale factor applies to the E15.6 format specification and also to the F12.3 andG15.5 format specifications. The 0P scale factor restores normal scaling for thesubsequent specification 4F14.1. ].PROCESSOR-DEPENDENT.!

13.5.8 BN and BZ Editing

The BN and BZ edit descriptors may be used to specify the interpretation of blanks,other than leading blanks, in numeric input fields. At the beginning of execution of eachformatted input statement, such blank characters are interpreted as zeros or are ignored,depending on the value of the BLANK=specifier (12.10.1) currently in effect for the unit. Ifa BN edit descriptor is encountered in a format specification, all such blank characters insucceeding numeric input fields are ignored.The effect of ignoring blanks is to treat the input field as if blanks had been removed, theremaining portion of the field right-justified, and the blanks replaced as leading blanks.However, a field of all blanks has the value zero. If a BZ edit descriptor is encountered ina format specification, all such blank characters in succeeding numeric input fields aretreated as zeros.

[ NEW ANSI77 [ The BN and BZ edit descriptors affect only I, F, E, D, Q, and G editingduring execution of an input statement. ].NEW ANSI77. ] They have no effect duringexecution of an output statement.

! PROCESSOR-DEPENDENT [ Reversion of format has no effect on the current valueof BN and BZ options. ].PROCESSOR-DEPENDENT.!

Page 259: FORTRAN 77 Reference Manual - Bull

Format Specification

47 A2 15UL Rev02 13-21

13.5.9 Numeric Editing

[ NEW ANSI77 [ The I, F, E, D, Q, and G edit descriptors are used to specifyinput/output of integer, real, double precision, and complex data. ].NEW ANSI77. ]The following general rules apply:

1. On input, leading blanks are not significant. The interpretation of blanks, other thanleading blanks, is determined by a combination of any BLANK=specifier and anyBN or BZ blank control that is currently in effect for the unit (13.5.8). Plus signs maybe omitted. A field of all blanks is considered to be zero.

2. [ NEW ANSI77 [ On input, with F, E, D, Q, and G editing, a decimal pointappearing in the input field overrides the portion of an edit descriptor that specifiesthe decimal point location. ].NEW ANSI77. ] The input field may have more digitsthan the processor uses to approximate the value of the datum.

3. On output, the representation of a positive or zero internal value in the field may beprefixed with a plus, as controlled by the S, SP, and SS edit descriptors (13.5.6) orthe processor. The representation of a negative internal value in the field must beprefixed with a minus. However, the processor does not produce a negative signedzero in a formatted output record.

4. On output, the representation is right-justified in the field.

If the number of characters produced by the editing is smaller than the field width,leading blanks will be inserted in the field.

5. On output, if the number of characters produced exceeds the field width or if anexponent exceeds its specified length using the Ew.dEe or Gw.dEe edit descriptor,the processor will fill the entire field of width w with asterisks. However, theprocessor does not produce asterisks if the field width is not exceeded whenoptional characters are omitted. Note that when an SP edit descriptor is in effect, aplus is not optional (13.5.6).

13.5.9.1 Integer Editing

The Iw and Iw.m edit descriptors indicate that the field to be edited occupies w positions.The specified input/output list item must be of type integer. On input, the specified listitem will become defined with an integer datum. On output, the specified list item mustbe defined with an integer datum.

On input, an Iw.m edit descriptor is treated identically to an Iw edit descriptor.In the input field, the character string must be in the form of an optionally signed integerconstant, except for the interpretation of blanks (13.5.9, first item).

The output for the Iw edit descriptor consists of zero or more leading blanks followed bya minus if the value of the internal datum is negative, or an optional plus otherwise,followed by the magnitude of the internal value in the form of an unsigned integerconstant without leading zeros. Note that an integer constant always consists of at leastone digit.

Page 260: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

13-22 47 A2 15UL Rev02

The output field for the Iw.m edit descriptor is the same as for the Iw edit descriptor,except that the unsigned integer constant consists of at least m digits and, if necessary,has leading zeros. The value of m must not exceed the value of w. If m is zero and thevalue of the internal datum is zero, the output field consists of only blank characters,regardless of the sign control in effect.

13.5.9.2 Real, Double Precision, and Quadruple Precision Editing

[ NEW ANSI77 [ The F, E, D, Q, and G edit descriptors specify the editing of real,double precision, and complex data. ].NEW ANSI77. ]

An input/output list item corresponding to an F, E, D, or G edit descriptor must be real,double precision, or complex. An input list item will become defined with a datum whosetype is the same as that of the list item. An output list item must be defined with a datumwhose type is the same as that of the list item.

E and D Editing

The Ew.d or Dw.d edit descriptor indicates that the field occupies w positions.

Input

The input field consists of an optional sign, followed by a string of digits optionallycontaining a decimal point. If the decimal point is omitted, the rightmost d digits of thestring, with leading zeros assumed if necessary, are interpreted as the fractional part ofthe value represented. The string of digits may contain more digits than a processoruses to approximate the value of the constant. The basic form may be followed by anexponent of one of the following forms:

(1) Signed integer constant.

(2) E followed by zero or more blanks, followed by an optionally signed integerconstant.

(3) D followed by zero or more blanks, followed by an optionally signed integerconstant.

(4) e d Q q followed by zero or more blanks followed by an optionally signed integerconstant.

! PROCESSOR-DEPENDENT [ An exponent containing a D is processed identically toan exponent containing an E.

An exponent containing a e d Q or q is also processed identically to an exponentcontaining an E. If an external decimal point is not provided, d acts as a negative power-of-10 scaling factor.The internal representation of the input quantity is:

(integer subfield) X 10-d X 10 (exponent subfield)

Page 261: FORTRAN 77 Reference Manual - Bull

Format Specification

47 A2 15UL Rev02 13-23

For example, if the specification is E10.8, the input quantity 3267E + 05 is converted andstored as:

3267 X 10 -8 X 10 5 = 3.267.

If an external decimal point is provided, it overrides d; e, if specified, has no effect oninput. An input field consisting entirely of blanks is interpreted as zero.

Valid subfield combinations are as follows:

+1.6327E-04 Integer-fraction-exponent-32.7216 Integer-fraction+328+5 Integer-exponent629E-1 Fraction-exponent+136 Integer only136 Integer only.07628431 Fraction only ].PROCESSOR-

DEPENDENT.!

Output

The width w, must be sufficient to contain digits, plus or minus signs, decimal point, E,the exponent, and blanks. Generally, w>d+6 or w>d+e+4 for negative numbers andw>d+5 or w>d+e+3 for positive numbers. Positive numbers need not reserve a space forthe sign of the number unless an SP specification is in effect. If the field is not wideenough to contain the output value, asterisks are inserted throughout the field. If the fieldis longer then the output value, the quantity is right-justified with blanks on the left.

If the value is non normalized an I is printed in the field instead of the value and awarning is issued.

The values produced by the formats Ew.d and Dw.d

s.a...ae + ee For values where the magnitude of theexponent is less than one hundred

s.a...a (+ or -) eee For values where the magnitude of theexponent exceeds one hundred

s Is a minus sign if the number is negative,and a blank if the number is positive.

a...a Are the most significant digits of the valuecorrectly rounded.

When the specification Ew.dEe is used, the exponent is preceded by E and the numberof digits used for the exponent field not counting the letter and sign is determined by e. Ifw is specified too small for the value being output, the entire field width as specified by wwill be filled with asterisks.

Page 262: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

13-24 47 A2 15UL Rev02

e is a letter which depends upon the precision of the edited real if the variable is prints isa simple precision real

e = E

if it is a double precision real

e = D

if it is a quadruple precision real

e = Q

Q Edit Descriptor

[ NEW ANSI77 [ The Q edit descriptor acts the same way as Dw.d edit descriptor but isreserved for quadruple precision editing ].NEW ANSI77. ]

F Descriptor

The F descriptor specifies conversion between an internal real or double precisionnumber and an external floating-point number without an exponent.

[ NEW ANSI77 [ The F descriptor may specify conversion between an internalquadruple precision real and an external floating point number. ].NEW ANSI77. ]

This descriptor that the form:

Fw.d

Input

On input the F specification is treated identically to the E specification. Some examplesare shown in Figure 13-1.

Output

The F descriptor outputs a real number without a decimal exponent.

The plus sign is suppress for positive numbers. If the field is too short, all asterisksappear in the output field. If the field is longer than required, the number is right-justifiedwith blanks on the left. If the value being converted is not normalized, an I is printed inthe field; if it is out of range (exceeds the capacity of the machine), an R is printed.

The specification Fw.d outputs a number in the following format:

sn.n

n is a field of decimal digits.s is a minus sign if the number is negative, or

a blank if the number is positive (except ifSP option is active).

Page 263: FORTRAN 77 Reference Manual - Bull

Format Specification

47 A2 15UL Rev02 13-25

Some examples of F output are shown in Figure 13-2.

Input Field Specification Converted Value Remarks367.2593 F8.4 367.2593 Integer and fraction field.62543 F6.5 .62543 No integer subfield.62543 F6.2 .62543 Decimal point overrides d

of specification+144.15E-03 F11.2 .14415 Exponents are allowed in F

input50000 F5.2 500.00 No fraction subfield; input

number converted as50 000*10-2

F5.2 0 Blanks in input fieldinterpeted as 0

Figure 13-1. Input Examples

FORMAT Statement Printed Result

10 FORMAT (1H , F6.3) +32.694

+32.694 11 FORMAT (1H , F10.3)

32.694

-32.694

bbbb32.694

PRINT 10,A

PRINT 11,A

.32694 13 FORMAT (1H , F4.3,F6.3)

32.694 14 FORMAT (1H , F6.0)

12 FORMAT (1H , F6.2) PRINT 12,A

PRINT 14,A bbbb33.

******

PRINT 13,A,A .327bb.327

The specification 1H is the carriage control character.

PRINT Statement

Value of A

Figure 13-2. F Output Examples

Page 264: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

13-26 47 A2 15UL Rev02

G Editing

The Gw.d and Gw.dEe edit descriptors indicate that the external field occupies wpositions, the fractional part of which consists of d digits, unless a scale factor greaterthan one is in effect, and the exponent part consists of e digits.

G input editing is the same as for E editing.

The method of representation in the output field depends on the magnitude of the datumbeing edited. Let N be the magnitude of the internal datum. If N < 0.1 or N > 10**d. Gw.doutput editing is the same as kPEw.d output editing and Gw.dEe output editing is thesame as kPEw.dEe output editing, where k is the scale factor currently in effect. If N isgreater than or equal to 0.1 and is less than 10**d, the scale factor has no effect, and thevalue of N determines the editing as follows:

Magnitude of Datum | Equivalent Conversion0.1<N<1 | F(w-n).d. n('b') |1<N<10 | F(w-n).(d-1),n('b') | . | . . | . . | .10**(d-2)<N<10**(d-1) | F(w-n).1, n('b') |10**(d-1)<N<10**d | F(w-n).0, n('b')where:

b is a blankn is 4 Gw.d and e+2 for Gw.dEe

Note that the scale factor has no effect unless the magnitude of the datum to be edited isoutside of the range that permits effective use of F editing.

Y=77.132 WRITE(7,200)Y200 FORMAT(G10.3)

writes the following:

bb77.1bbbb

EXIT=1214635.1 WRITE(4,100)EXIT100 FORMAT(G10.3)

writes the following:

.121E+07

Page 265: FORTRAN 77 Reference Manual - Bull

Format Specification

47 A2 15UL Rev02 13-27

Additional examples of G output are shown in Figure 13-3.

! PROCESSOR-DEPENDENT [

b.14159265E-10

Data Read by READ Statement

Format Option

.1415926535 E-10 E conversion

E conversion F conversion

F conversion

Data Printed

bbb2643383279. bbb.8979323846

bbb-693.9937510 -693.99375bbbb

b.89793238bbbb

b.26433833E+10

READ (5,50) SAMPLE 50 FORMAT (E20.5) . . . WRITE (6,60) SAMPLE60 FORMAT (1X,G14,8)

Figure 13-3. G Output Examples

Complex Editing

A complex datum consists of a pair of separate real data: therefore, the editing isspecified by two successively interpreted F, E, D, or G edit descriptors. The first of the editdescriptors specifies the real part; the second specifies the imaginary part. The two editdescriptors may be different. Note that nonrepeatable edit descriptors may appearbetween the two successive F, E, D, or G edit descriptors.

! PROCESSOR-DEPENDENT [

Example:

COMPLEX C READ (2,100) C PRINT 101,C

100 FORMAT (2E10.3)101 FORMAT ('REAL-PART OF C IS:', F10.2,'IMAGINARY PART-OF C IS:', 1 G10.3) ].PROCESSOR-DEPENDENT.!

Page 266: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

13-28 47 A2 15UL Rev02

13.5.10 L Editing

The Lw edit descriptor indicates that the field occupies w positions. The specifiedinput/output list item must be of type logical. On input, the list item will become definedwith a logical datum. On output, the specified list item must be defined with a logicaldatum.

The input field consists of optional blanks, optionally followed by a decimal point, followedby a T for true or F for false. The T or F may be followed by additional characters in thefield.Note that the logical constants .TRUE. and .FALSE. are acceptable input forms.

! PROCESSOR-DEPENDENT [ t and f are considered respectively as T and a F. Notethat an input consisting of only blank characters is not acceptable. ].PROCESSOR-DEPENDENT.!

The output field consists of w - 1 blanks followed by a T or F, as the value of the internaldatum is true or false, respectively.

! PROCESSOR-DEPENDENT [ If the value of the internal quantity is not normalized (forexample if it has not been initialized) the output field consists of w - 1 blanks followed by aI and a warning is used. ].PROCESSOR-DEPENDENT.!

13.5.11 A Editing

The A[w] edit descriptor is used with an input/output list item of type character. On input,the input list item will become defined with character data. On output, the output list itemmust be defined with character data.

If a field width w is specified with the A edit descriptor, the field consists of w characters. Ifa field width w is not specified with the A edit descriptor, the number of characters in thefield is the length of the character input/output list item.

Let len be the length of the input/output list item. If the specified field width w for A input isgreater than or equal to len, the rightmost len characters will be taken from the input field.If the specified field width is less than len, the w characters will appear left-justified withlen-w trailing blanks in the internal representation.

If the specified field width w for A output is greater than len, the output field will consist ofw-len blanks followed by the len characters from the internal representation. If thespecified field width w is less than or equal to len, the output field will consist of theleftmost w characters from the internal representation.

! PROCESSOR-DEPENDENT [

Page 267: FORTRAN 77 Reference Manual - Bull

Format Specification

47 A2 15UL Rev02 13-29

Example:

INPUT FORMAT VALUE OF A

ABCD ABCDbbbb A10

CHARACTER *8 A READ (2,FORMAT) A

FORMAT VALUE OF A

A10 bbABCDEFGH ABCD

ABCDEFGH

ABCDEFGH

ABCDEFGHIJ CDEFGHIJ A4

A4

OUTPUT

CHARACTER *8 A1 WRITE (2,FORMAT) A

Format A may transmit a variable of type real integer and logical, but not complex.].PROCESSOR-DEPENDENT.!

[ NEW ANSI77 [

13.5.12 R Editing

The Rw edit descriptor is equivalent to Aw except that trailing blanks become leadingblanks.

Let len be the length of the input/output list item. If the field width for input is greater thanor equal to len, the rightmost len characters are taken from the input field. If w is lessthan len, the w characters are right justified and (len-w) leading blanks are added.If the field width for output is greater than len, the output contains (w-len) blanks followedby len characters of data.If w is less than or equal to len, the output field contains the rightmost w characters ofdata.

The Rn edit descriptor may be used with an input/output list item of any data type exceptcomplex data type. [ ].NEW ANSI77. ]

Page 268: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

13-30 47 A2 15UL Rev02

Examples:

INPUT FORMAT VALUE OF A

ABCD

FORMAT VALUE OF A

ABCDEFGHIJ

OUTPUT

R10 R4

FGHIJ

CHARACTER *5 A READ (2,FORMAT) A

bABCD

ABCDE

ABCDE A3 R10

ABC bbbbbABCDE

CHARACTER *5 A WRITE (2,FORMAT) A

[ NEW ANSI77 [

13.5.13 Z Editing

The Zw edit descriptor specifies that the external field occupies w positions. The internalfield is of any type.

On input the external field is transmitted left justified, without any modification, to theinternal field and eventually to the next following fields until w is exhausted. When theright hand end of a field is not reached, the remaining bytes are not modified.

On output, the binary pattern contained in the internal field and the following fieldsgenerates as many hexadecimal characters as can be contained in the external field.

Page 269: FORTRAN 77 Reference Manual - Bull

Format Specification

47 A2 15UL Rev02 13-31

Blanks are not allowed on input: the only values permitted are 0 through 9 and A throughF. ].NEW ANSI77. ]

! PROCESSOR-DEPENDENT [

Examples:

CHARACTER C*5 READ (5,10)C10 FORMAT (Z10) ].PROCESSOR-DEPENDENT.!

NOTE: To edit or fill the last length of the variable, the w-length of Z edit descriptormust be 2 times the length of the variable in internal form. Ex, Integer -> W = 8.

Page 270: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

13-32 47 A2 15UL Rev02

13.6 LIST-DIRECTED FORMATTING

The characters in one or more list-directed records constitute a sequence a values andvalue separators. The end of a record has the same effect as a blank character, unless itis within a character constant. Any sequence of two or more consecutive blanks istreated as a single blank, unless it is within a character constant.

Each value is either a constant, a null value, or of one of the forms:

r*c

r*

where r is an unsigned, nonzero, integer constant. The r*c form is equivalent to rsuccessive appearances of the constant c, and the r* form is equivalent to r successivenull values. Neither of these forms may contain embedded blanks, except wherepermitted within the constant c.

A value_separator is one of the followings:

1. A comma optionally preceded by one or more contiguous blanks and optionallyfollowed by one or more contiguous blanks

2. A slash optionally preceded by one or more contiguous blanks and optionallyfollowed by one or more contiguous blanks

3. One or more contiguous blanks between two constants or following the lastconstant.

13.6.1 List-Directed Input

Input forms acceptable to format specifications for a given type are acceptable for list-directed formatting, except as noted below. The form of the input value must beacceptable for the type of the input list item. Blanks are never used as zeros, andembedded blanks are not permitted in constants, except within character constants andcomplex constants as specified below. Note that the end of a record has the effect of ablank, except when it appears within a character constant.

When the corresponding input list item is of type real double precision or quadrupleprecision the input form is that of a numeric input field. A numeric_input_field is a fieldsuitable for F editing (13.5.9.2) that is assumed to have no fractional digits unless adecimal point appears within the field.

When the corresponding list item is of type complex,[ NEW ANSI77 [ or complexdouble precision ].NEW ANSI77. ] the input form consists of a left parenthesis followedby an ordered pair of numeric input fields separated by a comma, and followed by a rightparenthesis. The first numeric input field is the real part of the complex constant and thesecond is the imaginary part. Each of the numeric input fields may be preceded orfollowed by blanks. The end of a record may occur between the real part and the commaor between the comma and the imaginary part.

When the corresponding list item is of type logical, [ NEW ANSI77 [ or short logical,].NEW ANSI77. ] the input form must not include either slashes or commas among theoptional characters permitted for L editing (13.5.10).

Page 271: FORTRAN 77 Reference Manual - Bull

Format Specification

47 A2 15UL Rev02 13-33

When the corresponding list item is of type character, the input form consists of anonempty string of characters enclosed in apostrophes. Each apostrophe within acharacter constant must be represented by two consecutive apostrophes without anintervening blank or end of record. Character constants may be continued from the endof one record to the beginning of the next record. The end of the record does not causea blank or any other character to become part of the constant. The constant may becontinued on as many records as needed. The characters blank, comma, and slash mayappear in character constants.

Let len be the length of the list item, and let w be the length of the character constant. Iflen is less than or equal to w, the leftmost len characters of the constant are transmittedto the list item. If len is greater than w, the constant is transmitted to the leftmost wcharacters of the list item and the remaining len-w characters of the list item are filledwith blanks. Note that the effect is as though the constant were assigned to the list itemin a character assignment statement (10.4).

A null value is specified by having no characters between successive value separators,no characters preceding the first value separator in the first record read by eachexecution of a list-directed input statement, or the r* form. A null value has no effect onthe definition status of the corresponding input list item. If the input list item is defined, itretains its previous value; if it is undefined, it remains undefined. A null value may not beused as either the real or imaginary part of a complex constant, but a single null valuemay represent an entire complex constant. Note that the end of a record following anyother separator, with or without separating blanks, does not specify a null value.

[ NEW ANSI77 [ A constant c making a value in a list-directed record can be ahexadecimal constant, for example: '12345678'Z for a list item of any type. The length ofthe hexadecimal constant must be equal to the number of storage units used for thevariable.If the list item is of type complex or complex double precision, the correspondingconstant, if hexadecimal, must have a length equal to the number of storage units usedfor the whole list item. ].NEW ANSI77. ]

A slash encountered as a value separator during execution of a list-directed inputstatement causes termination of execution of that input statement after the assignmentof the previous value.If there are additional items in the input list, the effect is as if null values had beensupplied for them.

Note that all blanks in a list-directed input record are considered to be part of some valueseparator except for the following:

1. Blanks embedded in a character constant

2. Embedded blanks surrounding the real or imaginary part of a complex constant

3. Leading blanks in the first record read by each execution of a list-directed inputstatement, unless immediately followed by a slash or comma.

Page 272: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

13-34 47 A2 15UL Rev02

The following are example of list directed input

! PROCESSOR-DEPENDENT [

Example:

PROGRAM LDR READ *, CAT, BIRD, DOG PRINT 10, CAT, BIRD, DOG10 FORMAT(' CAT =', E9.3,/' BIRD =', E9.3,/' DOG = ',E9.3) STOP END

Input: Output:

13.3, -5.2, .01 CAT = .133E+02 BIRD = -.520E+01 DOG = .001E+01

Example:

PROGRAM LDIN100 READ(*,*,END=99)J,K PRINT 1, J, K1 FORMAT (T20,2I5) GO TO 10099 STOP END

Input: Output:

1 2 1 2 ,3 1 3 '' 1 3 2*8 8 8 /9 8 8 2/ 2 8 2*/ 2 8 ].PROCESSOR-DEPENDENT.!

Page 273: FORTRAN 77 Reference Manual - Bull

Format Specification

47 A2 15UL Rev02 13-35

13.6.2 List-Directed Output

The form of the values produced is the same as that required for input, except as notedotherwise. With the exception of character constants, the values are separated by one ormore blanks. Logical output constants are T for the value true and F for the value false.

Output constants are produced with the effect of the following edit descriptors:

! PROCESSOR-DEPENDENT [

Type of List item Edit DescriptorShort integer I6

Integer I6 if absolute value is less than 32767Else, I12

Real SP, 1PE15.7

Double precision SP, 1PD24.17

Quadruple precision SP, 1PQ39.31

Complex SP,'(',1PD15.17,',',1PD15.17,')

Complex double precision SP,'(,1P24.17,',',1 PD24.17,')

Short logical L2

Logical L2

Character A if DELIM is not specified1X,'"',A,'"' if QUOTE Ex "ABCD"1X,'''',A,'''' if APOSTROPHEEx 'ABCD'where NONE, QUOTE, APOSTROPHEis the value of the DELIM=specifier of the OPEN statement.].PROCESSOR-DEPENDENT.!

[ NEW ANSI77 [ If NONE is specified as the value of the DELIM = specifier of theOPEN statement (this is the default value): ].NEW ANSI77. ]

Page 274: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

13-36 47 A2 15UL Rev02

Character constants produced are not delimited by apostrophes, are not preceded orfollowed by a value separator, have each internal apostrophe represented externally byone apostrophe, and have a blank character inserted by the processor for carriagecontrol at the beginning of any record that begins with the continuation of a characterconstant from the preceding record.

[ NEW ANSI77 [ If QUOTE is specified:Internal quotes of character constants are externally represented by two quotes.If APOSTROPHE is specified:Internal apostrophes of character constants are externally represented by twoapostrophes ].NEW ANSI77. ]

Complex constants are enclosed in parentheses, with a comma separating the real andimaginary parts. The end of a record may occur between the comma and the imaginarypart only if the entire constant is as long as, or longer than, an entire record. The onlyembedded blanks permitted within a complex constant are between the comma and theend of a record and one blank at the beginning of the next record, ! PROCESSOR-DEPENDENT [ if printed. ].PROCESSOR-DEPENDENT.!

Page 275: FORTRAN 77 Reference Manual - Bull

Format Specification

47 A2 15UL Rev02 13-37

13.7 NAMELIST EDITING

[ NEW ANSI77 [ The current record must begin with b$NAM or b&NAM where NAM isthe namelist name followed by a value separator (value separators are the same as forlist directed), the following items following name are of the form

• v = n where n is a list of constants coherent with list directed input, except that a slashmust not occur within it.

• v is a variable name which must be declared in namelist statements.

• the final v = n must be followed by '&', '$' ',$' or ',&', n must contain exactly the numberof constant requested to fill v (E.g. 1 for a scalar variable)

i1 * ...*i n for an array declared A(i 1 ,i 2 ,...,in ) if an array A is declared in nameliststatement v may be of the form: A or A(J 1 ,...J n )if v is of the form A(J 1 ,...J n ) then it is considered as a scalar variable if n containsonly one element or as the section of array if n contain 2 or more elements. ].NEWANSI77. ]

! PROCESSOR-DEPENDENT [

Example:

Namelist Editing

NAMELIST/NAME/A,B,C REAL A(10) READ (2,NAME)

INPUT: b$NAME ,A(1)=1bA(2)=2bC=1 B=4,A(3)=8*0.&

WRITE (2,NAME) will output:

b$NAME bA=+.100E+01 +.200E+01 0.000E+00 0.000E+00 0.000E+01 0.000E+00 0.000E+00 0.000E+00 0.000E+00 0.00.E+00

bB = .4000E+01 bC = .1000E+01 b$ ].PROCESSOR-DEPENDENT.!

In this example, the character b is a blank.

Page 276: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

13-38 47 A2 15UL Rev02

Page 277: FORTRAN 77 Reference Manual - Bull

47 A2 15UL Rev02 14-1

14. Main Program

A main_program is a program unit that does not have a FUNCTION, SUBROUTINE, orBLOCK DATA statement as its first statement. It may have a PROGRAM statement asits first statement.

! PROCESSOR-DEPENDENT [ If there is no PROGRAM statement at the beginning ofa main program, this main program is assumed to have the symbolic nameFORTRANMAIN. ].PROCESSOR-DEPENDENT.!

There must be exactly one main program in an executable program.Execution of an executable program begins with the execution of the first executablestatement of the main program.

Page 278: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

14-2 47 A2 15UL Rev02

14.1 PROGRAM STATEMENT

The form of a PROGRAM statement is:

PROGRAM pgm

where pgm is the symbolic name of the main program in which the PROGRAMstatement appears.

A PROGRAM statement is not required to appear in an executable program. If it doesappear, it must be the first statement of the main program.

The symbolic name pgm is global (18.1.1) to the executable program and must not bethe same as the name of an external procedure, block data subprogram, or commonblock in the same executable program. The name pgm must not be the same as anylocal name in the main program.

Page 279: FORTRAN 77 Reference Manual - Bull

Main Program

47 A2 15UL Rev02 14-3

14.2 MAIN PROGRAM RESTRICTIONS

The PROGRAM statement may appear only as the first statement of a main program. Amain program may contain any other statement except a BLOCK DATA, FUNCTION,SUBROUTINE, ENTRY, or RETURN statement. The appearance of a SAVE statementin a main program has no effect.

A main program may not be referenced from a subprogram or from itself.

Page 280: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

14-4 47 A2 15UL Rev02

Page 281: FORTRAN 77 Reference Manual - Bull

47 A2 15UL Rev02 15-1

15. Functions and Subroutines

15.1 CATEGORIES OF FUNCTIONS AND SUBROUTINES

15.1.1 Procedures

Functions and subroutines are procedures. There are four categories of procedures:

1. Intrinsic functions

2. Statement functions

3. External functions

4. Subroutines

Intrinsic functions, statement functions, and external functions are referred to collectivelyas functions.

External functions and subroutines are referred to collectively as external_procedures.

Page 282: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

15-2 47 A2 15UL Rev02

15.1.2 External Functions

functionsexternal

There are two categories of external_functions:

1. External functions specified in function subprograms

2. External functions specified by means other than FORTRAN subprograms.

15.1.3 Subroutines

There are two categories of subroutines:

1. Subroutines specified in subroutine subprograms

2. Subroutines specified by means other than FORTRAN subprograms.

15.1.4 Dummy Procedure

A dummy_procedure is a dummy argument that is identified as a procedure (18.2.11).

Page 283: FORTRAN 77 Reference Manual - Bull

Functions and Subroutines

47 A2 15UL Rev02 15-3

15.2 REFERENCING A FUNCTION

functionsreferencing

A function is referenced in an expression and supplies a value to the expression. Thevalue supplied is the value of the function.

An intrinsic function may be referenced in the main program or in any proceduresubprogram of an executable program.

A statement function may be referenced only in the program unit in which the statementfunction statement appears.

An external function specified by a function subprogram may be referenced within anyother procedure subprogram or the main program of the executable program. Asubprogram must not reference itself, either directly or indirectly.

An external function specified by means other than a subprogram may be referencedwithin any procedure subprogram or the main program of the executable program.

If a character function is referenced in a program unit, the function length specified in theprogram unit must be an integer constant expression.

Page 284: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

15-4 47 A2 15UL Rev02

15.2.1 Form of a Function Reference

A function reference is used to reference an intrinsic function, statement function, orexternal function.

The form of a function reference is:

fun ( [a [,a]...])

where:

fun is the symbolic name of a function or a dummy procedurea is an actual argument

The type of the result of a statement function or external function reference is the sameas the type of the function name.The type is specified in the same manner as for variables and arrays (4.1.2). The type ofthe result of an intrinsic function is specified in Table 15-1 (15.10).

15.2.2 Execution of a Function Reference

A function reference may appear only as a primary in an arithmetic, logical, or characterexpression. Execution of a function reference in an expression causes the evaluation ofthe function identified by fun.

Return of control from a referenced function completes execution of the functionreference. The value of the function is available to the referencing expression.

Page 285: FORTRAN 77 Reference Manual - Bull

Functions and Subroutines

47 A2 15UL Rev02 15-5

15.3 INTRINSIC FUNCTIONS

functionsintrinsic

Intrinsic functions are supplied by the processor and have a special meaning. Thespecific names that identify the intrinsic functions, their generic names, functiondefinitions, type of arguments, and type of results appear in Table 15-1.

An IMPLICIT statement does not change the type of an intrinsic function.

15.3.1 Specific Names and Generic Names

functionsnames

Generic names simplify the referencing of intrinsic functions, because the same functionname may be used with more than one type of argument. Only a specific intrinsicfunction name may be used as an actual argument when the argument is an intrinsicfunction.

If a generic name is used to reference an intrinsic function, the type of the result (exceptfor intrinsic functions performing type conversion, nearest integer, absolute value with acomplex argument, as for DPS7

[ NEW ANSI77 [

but not ANSI77 intrinsic functions)

].NEW ANSI77. ]

is the same as the type of the argument.

[ NEW ANSI77 [

For those intrinsic functions that have more than one argument, all arguments must beof the same type, except for intrinsic functions performing hash code, boolean operation,shift operation, dump, and set run time information.

].NEW ANSI77. ]

If the specific name or generic name of an intrinsic function appears in the dummyargument list of a function or subroutine in a subprogram, that symbolic name does notidentify an intrinsic function in the program unit. The data type identified with thesymbolic name is specified in the same manner as for variables and arrays (4.1.2).

A name in an INTRINSIC statement must be the specific name or generic name of anintrinsic function.

Page 286: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

15-6 47 A2 15UL Rev02

15.3.2 Referencing an Intrinsic Function

An intrinsic function is referenced by using its reference as a primary in an expression.For each intrinsic function described in Table 15-1, execution of an intrinsic functionreference causes the actions specified in Table 15-1, and the result depends on thevalues of the actual arguments. The resulting value is available to the expression thatcontains the function reference.

The actual arguments that constitute the argument list must agree in order, number, andtype with the specification in Table 15-1 and may be any expression of the specifiedtype. An actual argument in an intrinsic function reference may be any expression excepta character expression involving concatenation of an operand whose length specificationis an asterisk in parentheses unless the operand is the symbolic name of a constant.

A specific name of an intrinsic function that appears in an INTRINSIC statement may beused as an actual argument in an external procedure reference; however, the names ofintrinsic functions for type conversion, lexical relationship, and for choosing the largest orsmallest value must not be used as actual arguments. Note that such an appearancedoes not cause the intrinsic function to be classified as an external function (18.2.10).

Page 287: FORTRAN 77 Reference Manual - Bull

Functions and Subroutines

47 A2 15UL Rev02 15-7

15.3.3 Intrinsic Function Restrictions

Arguments for which the result is not mathematically defined or exceeds the numericrange of the processor cause the result of the function to become undefined.

Restrictions on the range of arguments and results for intrinsic functions are described in15.10.1.

! PROCESSOR-DEPENDENT [

Example:

Reference to an intrinsic function

PROGRAM E1200 INTRINSIC ALOG10, SQRTC these are references to the single precision ALOG,C via the generic and specific names A = LOG(2.EO) B = ALOG(2.EO)C these are references to the double precision LOG C = LOG(2.DO) D = DLOG(2.DO)C this is a reference to the single precision intrinsic ALOG,C which is known intrinsic because previous use as function CALL S1200 (ALOG)C these are references to the single precision intrinsicC ALOG10, SQRT . SQRT is the specific name. CALL S1200 (ALOG10) CALL S1200 (SQRT)C this is a reference to the real variable DSQRTC (implicit declaration, as INTRINSIC was not specified, norC a use as function reference) CALL S1200 (DSQRT) STOP END ].PROCESSOR-DEPENDENT.!

Page 288: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

15-8 47 A2 15UL Rev02

15.4 STATEMENT FUNCTION

statementsFUNCTION

A statement function is a procedure specified by a single statement that is similar in formto an arithmetic, logical, or character assignment statement. A statement functionstatement must appear only after the specification statements and before the firstexecutable statement of the program unit in which it is referenced (3.5).

A statement function statement is classified as a nonexecutable statement; it is not apart of the normal execution sequence.

15.4.1 Form of a Statement Function Statement

The form of a statement function statement is:

fun ( [d [,d]...]) = e

where:

fun is the symbolic name of the statement functiond is a statement function dummy argumente is an expression

The relationship between fun and e must conform to the assignment rules in 10.1, 10.2and 10.4. Note that the type of the expression may be different from the type of thestatement function name.

Each d is a variable name called a statement_function_dummy argument. Thestatement function dummy argument list serves only to indicate order, number, and typeof arguments for the statement function. The variable names that appear as dummyarguments of a statement function have a scope of that statement (18.1). A givensymbolic name may appear only once in any statement function dummy argument list.The symbolic name of a statement function dummy argument may be used to identifyother dummy arguments of the same type in different statement function statements.The name may also be used to identify a variable of the same type appearing elsewherein the program unit, including its appearance as a dummy argument in a FUNCTION,SUBROUTINE, or ENTRY statement. The name must not be used to identify any otherentity in the program unit except a common block.

Page 289: FORTRAN 77 Reference Manual - Bull

Functions and Subroutines

47 A2 15UL Rev02 15-9

Each primary of the expression e must be one of the following:

1. A constant

2. The symbolic name of a constant

3. A variable reference

4. An array element reference

5. An intrinsic function reference

6. A reference to a statement function for which the statement function statementappears in preceding lines of the program unit

7. An external function reference

8. A dummy procedure reference

9. An expression enclosed in parentheses that meets all of the requirements specifiedfor the expression e

Each variable reference may be either a reference to a dummy argument of thestatement function or a reference to a variable that appears within the same programunit as the statement function statement.

If a statement function dummy argument name is the same as the name of anotherentity, the appearance of that name in the expression of a statement function statementis a reference to the statement function dummy argument. A dummy argument thatappears in a FUNCTION or SUBROUTINE statement may be referenced in theexpression of a statement function statement within the subprogram. A dummyargument that appears in an ENTRY statement that precedes a statement functionstatement may be referenced in the expression of the statement function statementwithin the subprogram.

Page 290: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

15-10 47 A2 15UL Rev02

15.4.2 Referencing a Statement Function

A statement function is referenced by using its function reference as a primary in anexpression.

Execution of a statement function reference results in:

1. evaluation of actual arguments that are expressions,

2. association of actual arguments with the corresponding dummy arguments,

3. evaluation of the expression e, and

4. conversion, if necessary, of an arithmetic expression value to the type of thestatement function according to the assignment rules in 10.1 or a change, ifnecessary, in the length of a character expression value according to the rules in10.4.

The resulting value is available to the expression that contains the function reference.

The actual arguments, which constitute the argument list, must agree in order, number,and type with the corresponding dummy arguments. An actual argument in a statementfunction reference may be any expression except a character expression involvingconcatenation of an operand whose length specification is an asterisk in parenthesesunless the operand is the symbolic name of a constant.

When a statement function reference is executed, its actual arguments must be defined.

Page 291: FORTRAN 77 Reference Manual - Bull

Functions and Subroutines

47 A2 15UL Rev02 15-11

15.4.3 Statement Function Restrictions

A statement function may be referenced only in the program unit that contains thestatement function statement.

A statement function statement must not contain a reference to another statementfunction that appears following the reference in the sequence of lines in the programunit. The symbolic name used to identify a statement function must not appear as asymbolic name in any specification statement except in a type-statement (to specify thetype of the function) or as the name of a common block in the same program unit.

An external function reference in the expression of a statement function statement mustnot cause a dummy argument of the statement function to become undefined orredefined.

The symbolic name of a statement function is a local name (18.1.2) and must not be thesame as the name of any other entity in the program unit except the name of a commonblock.

The symbolic name of a statement function may not be an actual argument. It must notappear in an EXTERNAL statement.

A statement function statement in a function subprogram must not contain a functionreference to the name of the function subprogram or an entity name in the functionsubprogram.

The length specification of a character statement function or statement function dummyargument of type character must be an integer constant expression.

Page 292: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

15-12 47 A2 15UL Rev02

15.5 EXTERNAL FUNCTIONS

functionsexternal

An external function is specified externally to the program unit that references it. Anexternal function is a procedure and may be specified in a function subprogram or bysome other means.

15.5.1 Function Subprogram and FUNCTION Statement

statementsFUNCTION

A function subprogram specifies one or more external functions (15.7). A functionsubprogram is a program unit that has a FUNCTION statement as its first statement.The form of a function subprogram is as described in 2.4 and 3.5, except as noted in15.5.3 and 15.7.4.

The form of a FUNCTION statement is:

[typ] FUNCTION fun ( [d [,d]...])

where:

typ is one of INTEGER, REAL, DOUBLE PRECISION, QUADRUPLE PRECISION,

[ NEW ANSI77 [

COMPLEX DOUBLE PRECISION, INTEGER *2, LOGICAL *1, COMPLEX, LOGICAL, orCHARACTER [*len] where len is the length specification of the result of the characterfunction.

].NEW ANSI77. ]

µlen may have any of the forms allowed in a CHARACTER statement (8.4.2) except thatan integer constant expression must not include the symbolic name of a constant. If alength is not specified in a CHARACTER FUNCTION statement, the character functionhas a length of one.

fun is the symbolic name of the function subprogram in whichthe FUNCTION statement appears. fun is anexternal_function_name.

d is a variable name, array name, or dummy procedure name.d is a dummy argument.

Page 293: FORTRAN 77 Reference Manual - Bull

Functions and Subroutines

47 A2 15UL Rev02 15-13

The symbolic name of a function subprogram or an associated entry name of the sametype must appear as a variable name in the function subprogram. During everyexecution of the external function, this variable must become defined and, once defined,may be referenced or become redefined. The value of this variable when a RETURN orEND statement is executed in the subprogram is the value of the function. If this variableis a character variable with a length specification that is an asterisk in parentheses, itmust not appear as an operand for concatenation except in a character assignmentstatement (10.4).

An external function in a function subprogram may define one or more of its dummyarguments to return values in addition to the value of the function.

15.5.2 Referencing an External Function

An external function is referenced by using its reference as a primary in an expression.

15.5.2.1 Execution of an External Function Reference

Execution of an external function reference results in:

1. evaluation of actual arguments that are expressions,

2. association of actual arguments with the corresponding dummy arguments, and

3. the actions specified by the referenced function.

The type of the function name in the function reference must be the same as the type ofthe function name in the referenced function. The length of the character function in acharacter function reference must be the same as the length of the character function inthe referenced function.

When an external function reference is executed, the function must be one of theexternal functions in the executable program.

Page 294: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

15-14 47 A2 15UL Rev02

15.5.2.2 Actual Arguments for an External Function

The actual arguments in an external function reference must agree in order, number,and type with the corresponding dummy arguments in the referenced function. The useof a subroutine name as an actual argument is an exception to the rule requiringagreement of type because subroutine names do not have a type.

An actual argument in an external function reference must be one of the following:

1. An expression except a character expression involving concatenation of anoperand whose length specification is an asterisk in parentheses unless theoperand is the symbolic name of a constant

2. An array name

3. An intrinsic function name

4. An external procedure name

5. A dummy procedure name

Note that an actual argument in a function reference may be a dummy argument thatappears in a dummy argument list within the subprogram containing the reference.

Page 295: FORTRAN 77 Reference Manual - Bull

Functions and Subroutines

47 A2 15UL Rev02 15-15

15.5.3 Function Subprogram Restrictions

A FUNCTION statement must appear only as the first statement of a functionsubprogram. A function subprogram may contain any other statement except a BLOCKDATA, SUBROUTINE, or PROGRAM statement.

The symbolic name of an external function is a global name (18.1.1) and must not be thesame as any other global name or any local name, except a variable name, in thefunction subprogram.

Within a function subprogram, the symbolic name of a function specified by aFUNCTION or ENTRY statement must not appear in any other nonexecutablestatement, except a type-statement. In an executable statement, such a name mayappear only as a variable.

If the type of a function is specified in a FUNCTION statement, the function name mustnot appear in a type-statement. Note that a name must not have its type explicitlyspecified more than once in a program unit.

If the name of a function subprogram is of type character, each entry name in thefunction subprogram must be of type character.

If the name of the function subprogram or any entry in the subprogram has a length of (*)declared, all such entities must have a length of (*) declared; otherwise, all such entitiesmust have a length specification of the same integer value.

In a function subprogram, the symbolic name of a dummy argument is local to theprogram unit and must not appear in an EQUIVALENCE, PARAMETER, SAVE,INTRINSIC, DATA, or COMMON statement, except as a common block name.

A character dummy argument whose length specification is an asterisk in parenthesesmust not appear as an operand for concatenation, except in a character assignmentstatement (10.4).

A function specified in a subprogram may be referenced within any other proceduresubprogram or the main program of the executable program. A function subprogrammust not reference itself, either directly or indirectly.

! PROCESSOR-DEPENDENT [

Page 296: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

15-16 47 A2 15UL Rev02

Example:

Function_subprogram

The three following function subprograms return the same results:argument + 1 for main entry point, argument + 2 for secondary entry point.

C implicit types FUNCTION IF1210 (IX) IF1210 = IX + 1 RETURN ENTRY IF1211 (IX1) IE1211 = IX1 + 2 RETURN ENDC implicit types specified by IMPLICIT FUNCTION F1212 (X) IMPLICIT INTEGER (A - Z) F1212 = X + 1 RETURN ENTRY F1213 (X1) F1213 = X1 + 2 RETURN ENDC explicit types specified by type statement FUNCTION F1214 (X) INTEGER F1214, X, F1215, X1 F1214 = X + 1 RETURN ENTRY F1215 (X1) F1215 = X1 + 2 RETURN END ] .PROCESSOR-DEPENDENT.!

Page 297: FORTRAN 77 Reference Manual - Bull

Functions and Subroutines

47 A2 15UL Rev02 15-17

15.6 SUBROUTINES

A subroutine is specified externally to the program unit that references it. A subroutine isa procedure and may be specified in a subroutine subprogram or by some other means.

15.6.1 Subroutine Subprogram and SUBROUTINE Statement

statementsSUBROUTINE

A subroutine subprogram specifies one or more subroutines (15.7).A subroutine subprogram is a program unit that has a SUBROUTINE statement as itsfirst statement. The form of a subroutine subprogram is as described in 2.4 and 3.5,except as noted in 15.6.3 and 15.7.4.

The form of a SUBROUTINE statement is:

SUBROUTINE sub [( [d [,d]...] )]

where:

sub is the symbolic name of the subroutine subprogram in whichthe SUBROUTINE statement appears. sub is asubroutine_name.

d is a variable name, array name, or dummy procedure name,or is an asterisk (15.9.3.5). d is a dummy argument.

Note that if there are no dummy arguments, either of the forms sub or sub() may beused in the SUBROUTINE statement. A subroutine that is specified by either form maybe referenced by a CALL statement of the form CALL sub or CALL sub().

One or more dummy arguments of a subroutine in a subprogram may become definedor redefined to return results.

Page 298: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

15-18 47 A2 15UL Rev02

15.6.2 Subroutine Reference

statementsCALL

A subroutine is referenced by a CALL statement.

15.6.2.1 Form of a Call Statement

The form of a CALL statement is:

CALL sub [( [a [,a]...] )]

where:

sub is the symbolic name of a subroutine or dummy procedurea is an actual argument

15.6.2.2 Execution of a Call Statement

Execution of a CALL statement results in

1. evaluation of actual arguments that are expressions,

2. association of actual arguments with the corresponding dummy arguments, and

3. the actions specified by the referenced subroutine.

Return of control from the referenced subroutine completes execution of the CALLstatement.

A subroutine specified in a subprogram may be referenced within any other proceduresubprogram or the main program of the executable program. A subprogram must notreference itself, either directly or indirectly.

When a CALL statement is executed, the referenced subroutine must be one of thesubroutines specified in subroutine subprograms or by other means in the executableprogram.

Page 299: FORTRAN 77 Reference Manual - Bull

Functions and Subroutines

47 A2 15UL Rev02 15-19

15.6.2.3 Actual Arguments for a Subroutine

The actual arguments in a subroutine reference must agree in order, number, and typewith the corresponding dummy arguments in the dummy argument list of the referencedsubroutine. The use of a subroutine name or an alternate return specifier as an actualargument is an exception to the rule requiring agreement of type.

An actual argument in a subroutine reference must be one of the following:

1. An expression except a character expression involving concatenation of anoperand whose length specification is an asterisk in parentheses unless theoperand is the symbolic name of a constant

2. An array name

3. An intrinsic function name

4. An external procedure name

5. A dummy procedure name

6. An alternate_return_specifier, of the form *s, where s is the statement label of anexecutable statement that appears in the same program unit as the CALLstatement (15.8.3)

Note that an actual argument in a subroutine reference may be a dummy argumentname that appears in a dummy argument list within the subprogram containing thereference. An asterisk dummy argument must not be used as an actual argument in asubprogram reference.

15.6.3 Subroutine Subprogram Restrictions

A SUBROUTINE statement must appear only as the first statement of a subroutinesubprogram. A subroutine subprogram may contain any other statement except aBLOCK DATA, FUNCTION, or PROGRAM statement.

The symbolic name of a subroutine is a global name (18.1.1) and must not be the sameas any other global name or any local name in the program unit.

In a subroutine subprogram, the symbolic name of a dummy argument is local to theprogram unit and must not appear in an EQUIVALENCE, PARAMETER, SAVE,INTRINSIC, DATA, or COMMON statement, except as a common block name.

A character dummy argument whose length specification is an asterisk in parenthesesmust not appear as an operand for concatenation, except in a character assignmentstatement (10.4).

Page 300: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

15-20 47 A2 15UL Rev02

15.7 ENTRY STATEMENT

statementsENTRY

An ENTRY statement permits a procedure reference to begin with a particularexecutable statement within the function or subroutine subprogram in which the ENTRYstatement appears. It may appear anywhere within a function subprogram after theFUNCTION statement or within a subroutine subprogram after the SUBROUTINEstatement, except that an ENTRY statement must not appear between a block IFstatement and its corresponding END IF statement, or between a DO statement and theterminal statement of its DO-loop.

Optionally, a subprogram may have one or more ENTRY statements.

An ENTRY statement is classified as a nonexecutable statement.

15.7.1 Form of an ENTRY Statement

The form of an ENTRY statement is:

ENTRY en [( [d [,d]...] )]

where:

en is the symbolic name of an entry in a function or subroutinesubprogram and is called an entry_name. If the ENTRYstatement appears in a subroutine subprogram, en is asubroutine_name. If the ENTRY statement appears in afunction subprogram, en is an external_function name.

d is a variable name, array name, or dummy procedure name,or is an asterisk. d is a dummy argument. An asterisk ispermitted in an ENTRY statement only in a subroutinesubprogram.

Note that if there are no dummy arguments, either of the forms en or en() may be usedin the ENTRY statement. A function that is specified by either form must be referencedby the form en() (15.2.1). A subroutine that is specified by either form may be referencedby a CALL statement of the form CALL en or CALL en().

The entry name en in a function subprogram may appear in a type-statement.

Page 301: FORTRAN 77 Reference Manual - Bull

Functions and Subroutines

47 A2 15UL Rev02 15-21

15.7.2 Referencing External Procedure by Entry Name

An entry name in an ENTRY statement in a function subprogram identifies an externalfunction within the executable program and may be referenced as an external function(15.5.2). An entry name in an ENTRY statement in a subroutine subprogram identifies asubroutine within the executable program and may be referenced as a subroutine(15.6.2).

When an entry name en is used to reference a procedure, execution of the procedurebegins with the first executable statement that follows the ENTRY statement whose entryname is en.

An entry name is available for reference in any program unit of an executable program,except in the program unit that contains the entry name in an ENTRY statement.

The order, number, type, and names of the dummy arguments in an ENTRY statementmay be different from the order, number, type, and names of the dummy arguments inthe FUNCTION statement or SUBROUTINE statement and other ENTRY statements inthe same subprogram. However, each reference to a function or subroutine must use anactual argument list that agrees in order, number, and type with the dummy argument listin the corresponding FUNCTION, SUBROUTINE, or ENTRY statement. The use of asubroutine name or an alternate return specifier as an actual argument is an exceptionto the rule requiring agreement of type.

15.7.3 Entry Association

Within a function subprogram, all variables whose names are also the names of entriesare associated with each other and with the variable, if any, whose name is also thename of the function subprogram (17.1.3). Therefore, any such variable that becomesdefined causes all associated variables of the same type to become defined and allassociated variables of different type to become undefined. Such variables are notrequired to be of the same type unless the type is character, but the variable whosename is used to reference the function must be in a defined state when a RETURN orEND statement is executed in the subprogram. An associated variable of a different typemust not become defined during the execution of the function reference.

Page 302: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

15-22 47 A2 15UL Rev02

15.7.4 ENTRY Statement Restrictions

Within a subprogram, an entry name must not appear both as an entry name in anENTRY statement and as a dummy argument in a FUNCTION, SUBROUTINE, orENTRY statement and must not appear in an EXTERNAL statement.

In a function subprogram, a variable name that is the same as an entry name must notappear in any statement that precedes the appearance of the entry name in an ENTRYstatement, except in a type-statement.

If an entry name in a function subprogram is of type character, each entry name and thename of the function subprogram must be of type character. If the name of the functionsubprogram or any entry in the subprogram has a length of (*) declared, all such entitiesmust have a length of (*) declared; otherwise, all such entities must have a lengthspecification of the same integer value.

In a subprogram, a name that appears as a dummy argument in an ENTRY statementmust not appear in an executable statement preceding that ENTRY statement unless italso appears in a FUNCTION, SUBROUTINE, or ENTRY statement that precedes theexecutable statement.

In a subprogram, a name that appears as a dummy argument in an ENTRY statementmust not appear in the expression of a statement function statement unless the name isalso a dummy argument of the statement function, appears in a FUNCTION orSUBROUTINE statement, or appears in an ENTRY statement that precedes thestatement function statement.

If a dummy argument appears in an executable statement, the execution of theexecutable statement is permitted during the execution of a reference to the function orsubroutine only if the dummy argument appears in the dummy argument list of theprocedure name referenced. Note that the association of dummy arguments with actualarguments is not retained between references to a function or subroutine.

Page 303: FORTRAN 77 Reference Manual - Bull

Functions and Subroutines

47 A2 15UL Rev02 15-23

15.8 RETURN STATEMENT

A RETURN statement causes return of control to the referencing program unit and mayappear only in a function subprogram or subroutine subprogram.

15.8.1 Form of a RETURN Statement

The form of a RETURN statement in a function subprogram is:

RETURN

The form of a RETURN statement in a subroutine subprogram is:

RETURN [e]

where:

e is an integer expression.

Page 304: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

15-24 47 A2 15UL Rev02

15.8.2 Execution of a RETURN Statement

Execution of a RETURN statement terminates the reference of a function or subroutinesubprogram. Such subprograms may contain more than one RETURN statement;however, a subprogram need not contain a RETURN statement. Execution of an ENDstatement in a function or subroutine subprogram has the same effect as executing aRETURN statement in the subprogram.

In the execution of an executable program, a function or subroutine subprogram mustnot be referenced a second time without the prior execution of a RETURN or ENDstatement in that procedure.

Execution of a RETURN statement in a function subprogram causes return of control tothe currently referencing program unit. The value of the function (15.5) must be definedand is available to the referencing program unit.

Execution of a RETURN statement in a subroutine subprogram causes return of controlto the currently referencing program unit.Return of control to the referencing program unit completes execution of the CALLstatement.

Execution of a RETURN statement terminates the association between the dummyarguments of the external procedure in the subprogram and the current actualarguments.

15.8.3 Alternate RETURN

If e is not specified in a RETURN statement, or if the value of e is less than one orgreater than the number of asterisks in the SUBROUTINE or subroutine ENTRYstatement that specifies the currently referenced name, control returns to the CALLstatement that initiated the subprogram reference and this completes the execution ofthe CALL statement.

If 1 < e < n, where n is the number of asterisks in the SUBROUTINE or subroutineENTRY statement that specifies the currently referenced name, the value of e identifiesthe eth asterisk in the dummy argument list. Control is returned to the statementidentified by the alternate return specifier in the CALL statement that is associated withthe eth asterisk in the dummy argument list of the currently referenced name. Thiscompletes the execution of the CALL statement.

Page 305: FORTRAN 77 Reference Manual - Bull

Functions and Subroutines

47 A2 15UL Rev02 15-25

15.8.4 Definition Status

Execution of a RETURN statement (or END statement) within a subprogram causes allentities within the subprogram to become undefined, except for the following:

1. Entities specified by SAVE statements

2. Entities in blank common

3. Initially defined entities that have neither been redefined or become undefined

4. Entities in a named common block that appears in the subprogram and appears inat least one other program unit that is referencing, either directly or indirectly, thesubprogram.

Note that if a named common block appears in the main program, the entities in thenamed common block do not become undefined at the execution of any RETURNstatement in the executable program.

Page 306: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

15-26 47 A2 15UL Rev02

15.9 ARGUMENTS AND COMMON BLOCKS

Arguments and common blocks provide means of communication between thereferencing program unit and the referenced procedure.

Data may be communicated to a statement function or intrinsic function by an argumentlist. Data may be communicated to and from an external procedure by an argument listor common blocks.Procedure names may be communicated to an external procedure only by an argumentlist.

A dummy argument appears in the argument list of a procedure. An actual argumentappears in the argument list of a procedure reference.

The number of actual arguments must be the same as the number of dummy argumentsin the procedure referenced.

15.9.1 Dummy Arguments

Statement functions, function subprograms, and subroutine subprograms use dummyarguments to indicate the types of actual arguments and whether each argument is asingle value, array of values, procedure, or statement label. Note that a statementfunction dummy argument may be only a variable.

Each dummy argument is classified as a variable, array, dummy procedure, or asterisk.Dummy argument names may appear wherever an actual name of the same class(Section 18) and type may appear, except where they are explicitly prohibited.

! PROCESSOR-DEPENDENT [

Dummy argument names of type integer or short integer may appear in adjustabledimensions in dummy array declarators (5.5.1).

].PROCESSOR-DEPENDENT.!

Dummy argument names must not appear in EQUIVALENCE, DATA, PARAMETER,SAVE, INTRINSIC, or COMMON statements, except as common block names. Adummy argument name must not be the same as the procedure name appearing in aFUNCTION, SUBROUTINE, ENTRY, or statement function statement in the sameprogram unit.

Page 307: FORTRAN 77 Reference Manual - Bull

Functions and Subroutines

47 A2 15UL Rev02 15-27

15.9.2 Actual Arguments

Actual arguments specify the entities that are to be associated with the dummyarguments for a particular reference of a subroutine or function. An actual argumentmust not be the name of a statement function in the program unit containing thereference.Actual arguments may be constants, symbolic names of constants, function references,expressions involving operators, and expressions enclosed in parentheses if and only ifthe associated dummy argument is a variable that is not defined during execution of thereferenced external procedure.

The type of each actual argument must agree with the type of its associated dummyargument, except when the actual argument is a subroutine name (15.9.3.4) or analternate return specifier (15.6.2.3).

# OLD ANSI77 [

An actual argument in a subroutine reference may be a Hollerith constant. Thecorresponding dummy argument must be of type integer. Note that this is an exceptionto the rule that requires that the type of the actual and dummy argument must agree.

].OLD ANSI77.#

! PROCESSOR-DEPENDENT [

As opposed to GCOS 1E FORTRAN, the corresponding dummy argument may not be oftype character, because DPS7 FORTRAN 77 compiler passes character arguments bydescriptor, and hollerith constants or integer datum by reference

. ].PROCESSOR-DEPENDENT.!

Page 308: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

15-28 47 A2 15UL Rev02

15.9.3 Association of Dummy and Actual Arguments

At the execution of a function or subroutine reference, an association is establishedbetween the corresponding dummy and actual arguments. The first dummy argumentbecomes associated with the first actual argument, the second dummy argumentbecomes associated with the second actual argument, etc.

All appearances within a function or subroutine subprogram of a dummy argumentwhose name appears in the dummy argument list of the procedure name referencedbecome associated with the actual argument when a reference to the function orsubroutine is executed.

A valid association occurs only if the type of the actual argument is the same as the typeof the corresponding dummy argument. A subroutine name has no type and must beassociated with a dummy procedure name. An alternate return specifier has no type andmust be associated with an asterisk.

If an actual argument is an expression, it is evaluated just before the association ofarguments takes place.

If an actual argument is an array element name, its subscript is evaluated just before theassociation of arguments takes place.

Note that the subscript value remains constant as long as that association of argumentspersists, even if the subscript contains variables that are redefined during theassociation.

If an actual argument is a character substring name, its substring expressions areevaluated just before the association of arguments takes place. Note that the value ofeach of the substring expressions remains constant as long as that association ofarguments persists, even if the substring expression contains variables that areredefined during the association.

If an actual argument is an external procedure name, the procedure must be available atthe time a reference to it is executed.

If an actual argument becomes associated with a dummy argument that appears in anadjustable dimension (5.5.1), the actual argument must be defined with an integer valueat the time the procedure is referenced.

A dummy argument is undefined if it is not currently associated with an actual argument.An adjustable array is undefined if the dummy argument array is not currently associatedwith an actual argument array or if any variable appearing in the adjustable arraydeclarator is not currently associated with an actual argument and is not in a commonblock.

Argument association may be carried through more than one level of procedurereference. A valid association exists at the last level only if a valid association exists atall intermediate levels. Argument association within a program unit terminates at theexecution of a RETURN or END statement in the program unit. Note that there is noretention of argument association between one reference of a subprogram and the nextreference of the subprogram.

Page 309: FORTRAN 77 Reference Manual - Bull

Functions and Subroutines

47 A2 15UL Rev02 15-29

15.9.3.1 Length of Character Dummy and Actual Arguments

If a dummy argument is of type character, the associated actual argument must be oftype character and the length of the dummy argument must be less than or equal to thelength of the actual argument. If the length len of a dummy argument of type character isless than the length of an associated actual argument, the leftmost len characters of theactual argument are associated with the dummy argument.

If a dummy argument of type character is an array name, the restriction on length is forthe entire array and not for each array element. The length of an array element in thedummy argument array may be different from the length of an array element in anassociated actual argument array, array element, or array element substring, but thedummy argument array must not extend beyond the end of the associated actualargument array.

If an actual argument is a character substring, the length of the actual argument is thelength of the substring. If an actual argument is the concatenation of two or moreoperands, its length is the sum of the lengths of the operands.

15.9.3.2 Variables as Dummy Arguments

A dummy argument that is a variable may be associated with an actual argument that isa variable, array element, substring, or expression.

If the actual argument is a variable name, array element name, or substring name, theassociated dummy argument may be defined or redefined within the subprogram. If theactual argument is a constant, a symbolic name of a constant, a function reference, anexpression involving operators, or an expression enclosed in parentheses, theassociated dummy argument must not be redefined within the subprogram.

Page 310: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

15-30 47 A2 15UL Rev02

Example:

! PROCESSOR-DEPENDENT [Variables_as_dummy_arguments

SUBROUTINE S1220 (X, Y) Y = X + 1.E0 RETURN END PROGRAM E1220 DIMENSION T(10), M(10)C the following actual arguments may be used CALL S1220 (1.E0,B) A = 1.E0 CALL S1220 (A, T(1))C the following actual arguments may not be used10 CALL S1220 (A, 1.E0)20 CALL S1220 (A, M)C at compilation the call labelled 10 is not seen as leading toC an invalid association.C But the call labelled 20 is seen as leading to an invalidC association, and flagged by the compiler. The reason is thatC due to previous calls which pass scalars for the secondC argument, S1220 must not specify Y as a dummy array. STOP END ].PROCESSOR-DEPENDENT.!

15.9.3.3 Arrays as Dummy Arguments

Within a program unit, the array declarator given for an array provides all arraydeclarator information needed for the array in an execution of the program unit. Thenumber and size of dimensions in an actual argument array declarator may be differentfrom the number and size of the dimensions in an associated dummy argument arraydeclarator.

A dummy argument that is an array may be associated with an actual argument that isan array, array element, or array element substring.

If the actual argument is a noncharacter array name, the size of the dummy argumentarray must not exceed the size of the actual argument array, and each actual argumentarray element becomes associated with the dummy argument array element that has thesame subscript value as the actual argument array element. Note that association byarray elements exists for character arrays if there is agreement in length between theactual argument and the dummy argument array elements; if the lengths do not agree,the dummy and actual argument array elements do not consist of the same characters,but an association still exists.

If the actual argument is a noncharacter array element name, the size of the dummyargument array must not exceed the size of the actual argument array plus one minusthe subscript value of the array element. When an actual argument is a noncharacterarray element name with a subscript value of as, the dummy argument array elementwith a subscript value of ds becomes associated with the actual argument array elementthat has a subscript value of as + ds - 1 (Table 5-1, 5.4.3).

Page 311: FORTRAN 77 Reference Manual - Bull

Functions and Subroutines

47 A2 15UL Rev02 15-31

If the actual argument is a character array name, character array element name, orcharacter array element substring name and begins at character storage unit acu of anarray, character storage unit dcu of an associated dummy argument array becomesassociated with character storage unit acu + dcu - 1 of the actual argument array.

! PROCESSOR-DEPENDENT [

Example:

Arrays_as_dummy_arguments

SUBROUTINE S1230 (T, V) DIMENSION T(10), V(10,10) DO 5 I = 1,10 V(I,I) = T(I)C 5 CONTINUE RETURN END PROGRAM E1230 DIMENSION A(100), B(10,100), C(5) the following actual arguments may be used CALL S1230 (A,B) CALL S1230 (A(50), B(5,50)) the following actual arguments may not be used10 CALL S1230 (SCALAR, SCALAR)20 CALL S1230 (A(92), B(2,100))30 CALL S1230 (C,C) at compilation, only the call labelled 10 is known as leading to an invalid association, and flagged by the compiler. The reason is that due to previous calls which pass global arrays, S1230 must not specify V as scalar. STOP END].PROCESSOR-DEPENDENT.!

Page 312: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

15-32 47 A2 15UL Rev02

15.9.3.4 Procedures as Dummy Arguments

A dummy argument that is a dummy procedure may be associated only with an actualargument that is an intrinsic function, external function, subroutine, or another dummyprocedure.

If a dummy argument is used as if it were an external function, the associated actualargument must be an intrinsic function, external function, or dummy procedure. Adummy argument that becomes associated with an intrinsic function never has anyautomatic typing property, even if the dummy argument name appears in Table 15-1, 15-10. Therefore, the type of the dummy argument must agree with the type of the result ofall specific actual arguments that become associated with the dummy argument. If adummy argument name is used as if it were an external function and that name alsoappear in Table 15-1, the intrinsic function corresponding to the dummy argument nameis not available for referencing within the subprogram.

A dummy argument that is used as a procedure name in a function reference and isassociated with an intrinsic function must have arguments that agree in order, number,and type with those specified in Table 15-1 for the intrinsic function.

If a dummy argument appears in a type-statement and an EXTERNAL statement, theactual argument must be the name of an intrinsic function, external function, or dummyprocedure.

If the dummy argument is referenced as a subroutine, the actual argument must be thename of a subroutine or dummy procedure and must not appear in a type-statement orbe referenced as a function.

Note that it may not be possible to determine in a given program unit whether a dummyprocedure is associated with a function or a subroutine. If a procedure name appearsonly in a dummy argument list, an EXTERNAL statement, and an actual argument list, itis not possible to determine whether the symbolic name becomes associated with afunction or subroutine by examination of the subprogram alone.

Page 313: FORTRAN 77 Reference Manual - Bull

Functions and Subroutines

47 A2 15UL Rev02 15-33

15.9.3.5 Asterisks as Dummy Arguments

A dummy argument that is an asterisk may appear only in the dummy argument list of aSUBROUTINE statement or an ENTRY statement in a subroutine subprogram.

A dummy argument that is an asterisk may be associated only with an actual argumentthat is an alternate return specifier in the CALL statement that identifies the currentreferencing name. If a dummy argument is an asterisk, the corresponding actualargument must be an alternate return specifier.

Example:

Procedures_and_asterisks_as_dummy_arguments

C this subroutine receives F and G as dummy proceduresC X as a scalar dummy argument, and a label as last one. SUBROUTINE COMPOSE (F,G,X,*)C apply composition of functions F and G to X XPRIME = F(G(X)) DELTA = ABS (XPRIME - X) ERROR = DELTA/ABS(X) IF (ERROR.GT.1.E-6) THENC return to the received label RETURN 1 ELSEC normal return RETURN END PROGRAM E1240 INTRINSIC ASIN, SIN CALL COMPOSE (ASIN, SIN, 1.5704821,*10) STOP10 WRITE (*,*) ' X=', X STOP END

Page 314: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

15-34 47 A2 15UL Rev02

15.9.3.6 Restrictions on Association of Entities

If a subprogram reference causes a dummy argument in the referenced subprogram tobecome associated with another dummy argument in the referenced subprogram,neither dummy argument may become defined during execution of that subprogram. Forexample, if a subroutine is headed by

SUBROUTINE XYZ (A,B)

and is referenced by

CALL XYZ (C,C)

then the dummy arguments A and B each become associated with the same actualargument C and therefore with each other. Neither A nor B may become defined duringthis execution of subroutine XYZ or by any procedures referenced by XYZ.

If a subprogram reference causes a dummy argument to become associated with anentity in a common block in the referenced subprogram or in a subprogram referencedby the referenced subprogram, neither the dummy argument nor the entity in thecommon block may become defined within the subprogram or within a subprogramreferenced by the referenced subprogram. For example, if a subroutine contains thestatements:

SUBROUTINE XYZ (A)COMMON C

and is referenced by a program unit that contains the statements:

COMMON BCALL XYZ (B)

then the dummy argument A becomes associated with the actual argument B, which isassociated with C, which is in a common block. Neither A nor C may become definedduring execution of the subroutine XYZ or by any procedures referenced by XYZ.

Page 315: FORTRAN 77 Reference Manual - Bull

Functions and Subroutines

47 A2 15UL Rev02 15-35

15.9.4 Common Blocks

A common block provides a means of communication between external procedures orbetween a main program and an external procedure.The variables and arrays in a common block may be defined and referenced in allsubprograms that contain a declaration of that common block. Because association is bystorage rather than by name, the names of the variables and arrays may be different inthe different subprograms. A reference to a datum in a common block is proper if thedatum is in a defined state of the same type as the type of the name used to referencethe datum. However, an integer variable that has been assigned a statement label mustnot be referenced in any program unit other than the one in which it was assigned (10.3).

No difference in data type is permitted between the defined state and the type of thereference, except that either part of a complex datum may be referenced also as a realdatum.

In a subprogram that has declared a named common block, the entities in the blockremain defined after the execution of a RETURN or END statement if a common blockof the same name has been declared in any program unit that is currently referencingthe subprogram, either directly or indirectly. Otherwise, such entities become undefinedat the execution of a RETURN or END statement, except for those that are specified bySAVE statements and those that were initially defined by DATA statements and haveneither been redefined nor become undefined.

! PROCESSOR-DEPENDENT [

On DPS7 FORTRAN 77 all variables in COMMON are assumed specified by a SAVEstatement.

].PROCESSOR-DEPENDENT.!

Execution of a RETURN or END statement does not cause entities in blank common orin any named common block that appears in the main program to become undefined.

Common blocks may be used also to reduce the total number of storage units requiredfor an executable program by causing two or more subprograms to share some of thesame storage units. This sharing of storage is permitted if the rules for defining andreferencing data are not violated.

Page 316: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

15-36 47 A2 15UL Rev02

15.10 TABLE OF INTRINSIC FUNCTIONS

functionsintrinsic

! PROCESSOR-DEPENDENT [ A rectangle around a generic name or specific name means that this name is not part ofANSI 77.A rectangle around a minus in place of a specific name means that this function with thattype of argument is not part of ANSI 77.A rectangle around all the specific names or all minus in place of specific names, meansthat this function is not part of ANSI 77.

A Y in the column at the right of the specific name means that the corresponding specificname may be passed as an actual argument, an N means that it may not. If a genericname is the same as a specific name, passing this name as actual argument means thatthe specific name is passed (if also specified by an INTRINSIC statement).

Example:

INTRINSIC SINCALL S (SIN)ENDSUBROUTINE S(X)A = X(0.)END

A generic name may not be passed as actual argument.

].PROCESSOR-DEPENDENT.!

Page 317: FORTRAN 77 Reference Manual - Bull

Functions and Subroutines

47 A2 15UL Rev02 15-37

Table 15-1. Intrinsic Functions (1/21)

Type of Number of arguments

Definition

Argument

Intrinsic Function

Type Conversion

Specific name

Pass *

Short integer

Integer

Real

Short integer 1 N

Short integer

Short integer

Short integer

Short integer

Short integer

Short integer

Double

Quadruple

Complex

Complex double

Generic name

Function

Integer

Integer

Integer

Integer

Integer

Integer

Integer

Integer

Integer

Real

Short integer

Double

Quadruple

Complex

Complex double

Real

N

N

N

N

N

1 Conversion to Integer INT

INT

IFIX

IDINT

* Y indicates that the specific name can be passed as an actual argument; N indicates the contrary

HFIX

IQINT

See Note 14

See Note 1

int (a)

Conversion to Short Integer

Page 318: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

15-38 47 A2 15UL Rev02

Table 15-1. Intrinsic Functions (2/21)

Argument

Type Conversion

Integer

Real

Short integer 1 N

Double

Quadruple

Complex

Complex double

Function

Integer

Short integer

Double

Quadruple

Complex

Complex double

Real N

N

N

N

N

1

Conversion to real REAL Real

Real

Real

Real

Real

Real

Real

Real

N

N Integer

REAL

FLOAT

SNGL

SNGLQ

Double

Double

Double

Double

Double

Double

Double

Quadruple

Quadruple

Quadruple

Quadruple

Quadruple

Quadruple

Quadruple

Integer

Short integer

Double

Quadruple

Complex

Complex double

Real

N

N DFLOAT

N

DBLE

DREAL

Conversion to Double precision

Conversion to Quadruple precision

QEXT 1

QEXT

QEXTD

DBLEQ

QFLOAT

See Note 3

See Note 2

Page 319: FORTRAN 77 Reference Manual - Bull

Functions and Subroutines

47 A2 15UL Rev02 15-39

Table 15-1. Intrinsic Functions (3/21)

Type of Number of arguments

Definition

Argument

Intrinsic Function

Type Conversion

Specific name

Pass *

Real

Short integer 1 N

Double

Quadruple

Complex

Complex double

Generic name

Function

N

Integer

Integer

Short integer

Double

Quadruple

Complex

Real

N

1

1

1

1

1

1

1

2

Complex

Complex

Complex

Complex

Complex

Complex

Complex

Complex

Complex

Complex

Complex

Complex

Complex

CINT

2

2

2

2

CMPLX

CSNGL

Conversion to Complex

See Note 4

See Note 4

Page 320: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

15-40 47 A2 15UL Rev02

Table 15-1. Intrinsic Functions (4/21)

Type of Number of arguments

Definition Argument

Intrinsic Function

Type Conversion

Specific name

Pass *

Real

Short integer 1 N

Double

Quadruple

Complex

Complex double

Generic name

Function

N

Integer

Integer

Short integer

Double

Quadruple

Real

N

1

1

1

1

1

1

1

2

2

2

2

2

Conversion to Complex double precision

DCMPLX

Complex double

Complex double

Complex double

Complex double

Complex double

Complex double

Complex double

Complex double

Complex double

Complex double

Complex double Complex double

CDBLE

Complex double

Complex double

CDINT

See Note 15

See Note 15

Page 321: FORTRAN 77 Reference Manual - Bull

Functions and Subroutines

47 A2 15UL Rev02 15-41

Table 15-1. Intrinsic Functions (5/21)

Type of Number of arguments

Definition

Argument

Intrinsic Function

Type Conversion

Specific name

Pass *

Real

1 N

Double

Quadruple

Complex

Generic name

Function

N

Integer

N

1

1

IHOL

HCHAR One character

Integer

CHAR

Hollerith

Short integer

1

1 N

N

N

One character

One character

Short integer

Integer

CHAR

KTYPE

Logical

Short Logical

Two characters

Integer

Four characters

ICHAR One character

Four characters

Sixteen characters

One character

Four characters

Sixteen characters

Short integer

Returns as an integer value the binary value of thehollerith string leftjustified, right truncated to four characters, or right padded with blanks to four characters

Complex double

Conversion to character with the same internal binary representation.

Conversion to character

See Note 5

Conversion to Short Integer See Note 5

Eight characters

Eight characters

See Note 5

Conversion to integer.

See Note

Page 322: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

15-42 47 A2 15UL Rev02

Table 15-1. Intrinsic Functions (6/21)

Data Read by READ Statement

Format Option

.1415926535 E-10 E conversion

E conversion

F conversion

F conversion

Data Printed

bbb.8979323846

-693.99375bbbb

b.26433833E+10

READ (5,50) SAMPLE 50 FORMAT (E20.5) . . . WRITE (6,60) SAMPLE60 FORMAT (1X,G14,8)

Page 323: FORTRAN 77 Reference Manual - Bull

Functions and Subroutines

47 A2 15UL Rev02 15-43

Table 15-1. Intrinsic Functions (7/21)

Type of Number of arguments

Definition

Argument

Intrinsic Function Specific name

Pass *

Real

Double

Quadruple

Generic name

Function

Y

Real

Double

Real

Double

Quadruple Y

Real

Double

Quadruple

Real

Double

Quadruple

Integer

Real

Double

Quadruple

Y

Y

Y

Y

Integer

Real

Double

Quadruple

Double

Quadruple

Transfer of sign

Positive difference

Double Precision Product

Quadruple Precision Product

Choosing Largest Value

2

2

2

2

>= 2 MAX

SIGN

DIM

N

N

N

N

N

N

MAX0

AMAX1

QMAX1

DMAX1

QPROD

Y DPROD

max (a , a , ...) 1 2

a * a 1 2

a * a 1 2

IDIM

DDIM

QDIM

DIM

Integer Integer

Short integer Short integer

Y

Y

ISIGN

SIGN

QSIGN

DSIGN

Integer Integer

a - a if a > a 1 2 1 2

0 if a <= a 1 2

- a if a < 0 1 2

Page 324: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

15-44 47 A2 15UL Rev02

Table 15-1. Intrinsic Functions (8/21)

Type of Number of arguments

Definition

Argument

Intrinsic Function Specific

name Pass *

Real

Generic name

Function

Real

Double

Real

Double

Quadruple

Real

Double

Quadruple

Integer Real

Quadruple

Choosing Largest Value

2

2

>= 2

N

N

N

N

N

Y

max (a , a , ...) 1 2

Integer

Integer

Integer

AMAXO

DMAXO

QMAXO

MIN

MIN0

AMIN1

MAX1 N

N

N

N

Integer

Integer

>= 2

>= 2

>= 2

>= 2

DMIN1

QMIN1

Short integer

Real

Double

Quadruple

Integer

Short integer

N

N

N

N Choosing Smallest Value

Length

N

min (a , a , ...) 1 2

AMIN0

DMIN0

Integer

Integer

Integer

>= 2

>= 2

Length of character Entity

Index of a Substring

Hash Code

QMIN0 >= 2

>= 2

1

MIN1

LEN

INDEX

Y Integer

Integer

Integer

Character

IHASH

Character

Location of substring a in string a 1 2

a : Integer 2

a : Character 1

Hash a starting 1 from a 2

See Note 10

See Note 16

Page 325: FORTRAN 77 Reference Manual - Bull

Functions and Subroutines

47 A2 15UL Rev02 15-45

Table 15-1. Intrinsic Functions (9/21/

Type of Number of arguments

Definition

Argument

Intrinsic Function Specific name

Pass *

Generic name

Function

Real

Double

2

Y

N

N

1 Y

Integer

Integer First Different Character

Translate

Imaginary part of Complex Argument

Conjugate of a Complex Argument

KTRANS

Integer

Complex Double

Complex

2

2

3

1 Complex

Complex Double

Complex

Y

a of first character 1 different to charactera 2

a of first character 1

AIMAG

DIMAG

AIMAG

ITRT

DCONJG

CONJG

IPAST

IVERIF

CONJG

a : Character not 1 of * length

a : 256 characters 2

a : one character 3

a : Character 1

a : Character 1

a : one character 2

a : Character 1

a : Character 2

ar, - ai

a i

Y

Complex Double

translation of which

Character of thesame Length as the argument

a : 256 Characters 2

Location in String

Location in String

that is not in String a 2

according to Table a 2

Translation of a 1

Location in String a of the first 1 character the

using Table a , 2 and masked by a , is 3not zero

See Note 17

See Note 18

See Note 19

See Note 6

See Note 6

Page 326: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

15-46 47 A2 15UL Rev02

Table 15-1. Intrinsic Functions (10/21)

Type of Number of arguments

Definition

Argument

Specific name

Pass *

Real

Double

Quadruple

Generic name

Function

Y Real

Double

Quadruple

Y

Real

Double

Quadruple

Y

Y

Y

Y

Real

Double

Quadruple

Y

Y

Y

Square Root

Exponential

Natural Logarithm

Common Logarithm

SQRT

EXP

LOG

1

1

1

1 Y

Y

Y

LOG10

ALOG

Complex Complex

Complex double Complex double

Real

Double

Quadruple

Real

Double

Quadruple

Complex Complex

Complex double Complex double

Real

Double

Quadruple

Real

Double

Quadruple

Complex Complex

Complex double Complex double

Y

DLOG

CLOG

CDLOG

Y

Y

Y

Y

Log (a)

Log 10 (a)

e * * a

1/2 (a)

ALOG10

DLOG10

QLOG10

QLOG

Y

EXP

DEXP

QEXP

CEXP

CDEXP

SQRT

DSQRT

QSQRT

CDSQRT

CSQRT

See Note 13

See Note 13

See Note 13

See Note 13

Page 327: FORTRAN 77 Reference Manual - Bull

Functions and Subroutines

47 A2 15UL Rev02 15-47

Table 15-1. Intrinsic Functions (11/21)

Type of Number of arguments

Definition

Argument

Intrinsic Function Specific name

Pass *

Real

Double

Quadruple

Generic name

Function

Y Real

Double

Quadruple

Y

Real

Double

Quadruple

Y

Y

Y

Y

Real

Double

Quadruple

Y

Y

Y

1

1

1

1 Y

Y

Y

Real

Double

Quadruple

Real

Double

Quadruple

Complex Complex

Complex double Complex double

Real

Double

Quadruple

Real

Double

Quadruple

Y

Y

Y

Y

Y

See Note 13 (page 15-49)

Y

Base 2 Logarithm

Sine

Cosine

SIN

ALOG2

DLOG2

QLOG2

SIND

Log 2 (a)

SIN

DSIN

CSIN

sin (a)with a in radians

CDSIN

QSIN

SIND

DSIND

QSIND

sin (a)with a in degrees

cos (a)with a in radians

COS Real

Double

Quadruple

Real

Double

Quadruple

Complex Complex

Complex double Complex double

Y COS

DCOS

QCOS

CDCOS

CCOS

See Note 13

cos (a)with a in radians

1

DCOSD

QCOSD

COSD

LOG2

See Note 13

See Note 13

See Note 13

COSD

Page 328: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

15-48 47 A2 15UL Rev02

Table 15-1. Intrinsic Functions (12/21)

Type of Number of arguments

Definition

Argument

Intrinsic Function Specific

name Pass *

Generic name

Function

Y

Y Real

Double

Quadruple

Y

Y

Y

Real

Double

Quadruple

Y

Y

Y

1

1

1

Y

Y

Y

Real

Double

Quadruple

Real

Double

Quadruple

Complex Complex

Complex double Complex double

Real

Double

Quadruple

Real

Double

Quadruple

Y

Y

Y

Y

Y

Real

Double

Quadruple

Real

Double

Quadruple

Complex Complex

Complex double Complex double

Tangent

Cotangent

Arcsine

TAN

TAND

tan (a)with a in radians

TAN

DTAN

QTAN

CTAN

CDTAN

1

ASIN

tan (a)with a in degrees

arcsin (a)

COTAN

TAND

DTAND

QTAND

COTAN

DCOTAN

QCOTAN

ASIN

DASIN

QASIN

CASIN

CDASIN

cotan (a)with a in radians

See Note 13

See Note 13

See Note 13

See Note 13

Page 329: FORTRAN 77 Reference Manual - Bull

Functions and Subroutines

47 A2 15UL Rev02 15-49

Table 15-1. Intrinsic Functions (13/21)

Type of Number of arguments

Definition

Argument

Intrinsic Function Specific

name Pass *

Generic name

Function

Y

Y Real

Double

Quadruple

Y

Y

Y

Real

Double

Quadruple

Y

Y

Y

1

1

Y

Y

Real

Double

Quadruple

Real

Double

Quadruple

Complex Complex

Complex double Complex double

Real

Double

Quadruple

Real

Double

Quadruple

Y

Y

Y

Y

Y

Real

Double

Quadruple

Real

Double

Quadruple

Complex Complex

Complex double Complex double

1

Arcosine arccos (a)

Arctangent arctan (a)in radians

ATAN

arctan (a)in degrees

See Note 13

Real

Double

Quadruple

Real

Double

Quadruple

ATAN2D

Y

Y

DATN2D

QATN2D

ATAN2D 2

See Note 13

ATAN2

in degrees

arctan (a /a ) 1 2

See Note 13

arctan (a /a ) 1 2in radians

2

ATAND

QATAND

QATAN2

DATAN2

ATAN2

ATAN

DATAN

CDATAN

Y

Y

ACOS ACOS

DACOS

CDACOS

See Note 13

See Note 13

QACOS

CACOS

QATAN

CATAN

ATAND

DATAND

Page 330: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

15-50 47 A2 15UL Rev02

Table 15-1. Intrinsic Functions (14/21)

Type of Number of arguments

Definition

Argument

Intrinsic Function Specific

name Pass *

Generic name

Function

Y

Y

Y

Y

Y

Y

1 Real

Double

Quadruple

Real

Double

Quadruple

Complex Complex

Complex double Complex double Y

Y

Complex Complex

Complex double Complex double

1 Real

Double

Quadruple

Real

Double

Quadruple

Y

Y

Y

Y

Y

Y

Real

Double

Quadruple

Real

Double

Quadruple

Complex Complex

Complex double Complex double Y

Hyperbolic Sine sinh (a)

Hyperbolic Cosine cosh (a)

SINH

COSH

TANH 1 Hyperbolic Tangent tanh (a)

COSH

DTANH

SINH

DSINH

CTANH

DCOSH

QCOSH

CCOSH

TANH

CDTANH

See Note 13

See Note 13

See Note 13

CSINH

QSINH

QTANH

CDSINH

CDCOSH

Page 331: FORTRAN 77 Reference Manual - Bull

Functions and Subroutines

47 A2 15UL Rev02 15-51

Table 15-1. Intrinsic Functions (15/21)

Type of Number of arguments

Definition

Argument

Intrinsic Function Specific

name Pass *

Generic name

Function

Y

Y

Y

Y

Y

Real

Double

Quadruple

Y

Y

Y

1

1

Y

Real

Double

Quadruple

Real

Double

Quadruple

Complex Complex

Complex double Complex double

Real

Double

Quadruple

Real

Double

Quadruple

Y

Y

Y

1 Real

Double

Quadruple

Real

Double

Quadruple

Y

Y

Hyperbolic Arctangent

Gamma

arctanh (a)

Y Real

Double

Quadruple

Real

Double

Quadruple

Y

Y

gamma (a) GAMMA

ATANH

CATANH

CDATNH

DATANH

QATANH

1 Log (gamma (a)) ALGAMA

FACT Factorial a !

DFACT

FACT

QFACT

Error function erf (a) 1 ERF

DERF

QERF

ERF

DLGAMA

QLGAMA

DGAMMA

Integer

QGAMMA

ALGAMA

GAMMA

ATANH

Integer

Integer

See Note 13

See Note 13

See Note 13

See Note 13

See Note 13

Page 332: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

15-52 47 A2 15UL Rev02

Table 15-1. Intrinsic Functions (16/21)

Type of Number of arguments

Definition

Argument

Intrinsic Function Specific name

Pass *

Generic name

Function

Y

Y

Y

Y

1

1

Real

Double

Quadruple

Real

Double

Quadruple

Real

Real

Double

Quadruple

Y

2

2

Error function

Power of 2

a < a 1 2

1 - erf (a) ERFC ERFC

DERFC

QERFC

STWO a 2

Y

DTWO

QTWO

Lexically GreaterThan or Equal 2

2

Character N LGE

Lexically GreaterThan

Lexically LessThan or Equal

Lexically LessThan

a > a 1 2

2

Character N

Character N

Character N

Logical

Logical

Logical

Logical

Logical

Four Characters

Boolean operation

LGT

LLE

LLT

N Intersection of binary values of

a and a 1 2

a <= a 1 2

a >= a 1 2

IAND

Integer

Integer

Integer

Integer Integer

Integer

Integer

Integer

See Note 13

See Note 13

See Note 12

See Note 12

See Note 12

See Note 12

See Note 20

Page 333: FORTRAN 77 Reference Manual - Bull

Functions and Subroutines

47 A2 15UL Rev02 15-53

Table 15-1. Intrinsic Functions (17/21)

Type of Number of arguments

Definition

Argument Intrinsic Function

Specific name

Pass *

Generic name

Function

2

2

N

N

N

N

Four Characters

Boolean operation

N

IOR

Shift operation

IXOR

2

2

Four Characters

Four Characters

1

Exclusive union ofbinary values of a and a 1 2

Right shift if a < 0 2Left shift if a > 0 2

Logical Complementof binary values of

a by MOD (a ,256) 1 2bit positions

Right shift if a < 0 2Left shift if a > 0 2

Arithmetic shift of a

ICOMPL

a by MOD (a ,256) 1 2bit positions

Circular shift of a

ISHA

ISHC

Real

Logical

Logical

Real

Logical

Real

a 1

a : 1

Four Characters

Real

Logical

a : 2

Integer

Integer

Integer

Integer

Integer

Integer

Integer Integer

Integer

Integer

Integer

Integer

Integer

Integer

Integer

Integer

Integer

Integer Integer

Integer Integer

a : 1

Four Characters

Real

Logical

a : 2

Integer

Integer

Integer Integer

Integer Integer

Union of binaryvalue of a and a 1 2

See Note 13

See Note 20

See Note 20

See Note 21

See Note 22

Page 334: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

15-54 47 A2 15UL Rev02

Table 15-1. Intrinsic Functions (18/21)

Type of Number of arguments

Definition

Argument

Intrinsic Function Specific name

Pass *

Generic name

Function

2

2

N

N

N

N

N

2

2

1

Right shift if a < 0 2Left shift if a > 0 2

a by MOD (a ,256) 1 2bit positions

Logical

a : 1

Four Characters

Real

Logical

a : 2

Integer

Integer

Integer

Integer Integer

Integer

Integer

Shift operation

Bit processing

ISHL

BTEST

IBCLR

IBSET

Logical shift of

See Note 23

Eight Characters

.TRUE. if the bit atposition 0 <= a <= 31 2of a is one. 1.FALSE. if the bit atposition 0 <= a <= 31 2is zeroSee Note 24

See Note 24

value of a with bit at 1 position MOD(a ,32) 2set to zero

Obtain Date or Time Time in millisecondsSee Note 25

0 Time of the day inmillisecondsSee Note 25

One Character

IBCHNG 2 N

Integer

Integer Integer

Integer

See Note 24

value of a with bit at 1 position MOD(a ,32) 2set to one

IFRTIM

KTOD N

value of a with bit at 1 position MOD(a ,32) 2set to one if it is zero in a , set to 1zero if it is one in a 1

Integer

Integer

Integer

Page 335: FORTRAN 77 Reference Manual - Bull

Functions and Subroutines

47 A2 15UL Rev02 15-55

Table 15-1. Intrinsic Functions (19/21)

Type of Number of arguments

Definition

Argument

Intrinsic Function Specific name

Pass *

Generic name

Function

2

N

N

N

N

2

1

Integer

One Character

N

Integer Integer

IntegerInteger

Integer

Integer

Obtain Date or Time

Wait some time

Switches Processing

Test Run Time Information

1

1

KFRTIM

IWAIT

IFRTWT

IFRSWT

KTEST Character

Date

value of switch numbera . Return a negative 1 value if failed.

Characters of length specified in a CHARACTER statement of length 1 otherwise.

Characters of length specified in a CHARACTER statement of length 1 otherwise. Maximum is 4096

Wait during time givenby a expressed in 1 units given by a 2Returns a negative value if failed.See Note 26

See Note 27

Set switch number a 1to value a . Returns 2negative value if failed. See Note 27 JCL option string if a = 'OPTIONS' 'IOF' 1or 'BATCH' if a = 1'MODE' String of last systemReturn Codes if a = 1'SYSTRC'See Note 28

See Note 25

Page 336: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

15-56 47 A2 15UL Rev02

Table 15-1. Intrinsic Functions (20/21)

Type of Number of arguments

Definition

Argument

Intrinsic Function Specific name

Pass *

Real

1 N

Double

Quadruple Complex

Generic name

Function

Integer

N

Integer

Logical Short Logical

Integer

Short integer

Complex double

Test Run Time Information

ITEST Character

0

2

FRERR

2

IPDUMP

Logical

Logical

Set Run Time Information

Dump

a : Character 1

a : Integer 2

Character

Integer

LSETK

LSETI

a : Integer 3i

3*nwith

1<=n<=4

a ,a : 1i 2i

Last Run Timeerror, convertedto 1E FORTRAN value.zero if no error.See Note 30

Length of JCL optionstring if a ='OPTIONS' 1Length of string ofLast System ReturnCodes if a ='SYSTRC' 1Last run time errorif any, zero else,if a = 'LASTEP' 1See Note 29

Let error messagescontrol according to a , a 1 2Returns .FALSE.if failed, elsereturns .TRUE.See Note 32

Print n memoryareas n=max of i.Each memory areastarts at the location of a , 1iand finishes atthe location ofa . The printing 2iis made according to format specifiedby a 3iSee Note 31

Page 337: FORTRAN 77 Reference Manual - Bull

Functions and Subroutines

47 A2 15UL Rev02 15-57

Table 15-1. Intrinsic Functions (21/21)

Type of Number of arguments

Definition

Argument

Intrinsic Function Specific name

Pass *

Real Double

Quadruple Complex

Generic name

Function

Integer

Logical Short Logical

Short integer

Complex double

Logical

Character

Evalute an expression

Pass character actualargument by address

2 LSETS

EVALUTE

LOCF

Characterconstantexpression

1

Argument address 1

1

INTEGER

Real Double

Quadruple

Complex

Integer

Logical Short Logical

Short integer

Complex double

Character

Real Double Quadruple

Complex

Integer

Logical Short Logical

Short integer

Complex double

REFCHARDefault passing modeis by descriptor: using REFCHAR functionenables to pass character strings to COBOL-Like programsSee Note 35

Value of the argumentwith evaluationprior to furtherevaluation ofexpression in whichit is involved. This prevents optimization (6.6.4)

Set Run TimeInformation

Returns a locationthat is an address.See Note 34

Mask or unmask thefloating point underflow.Returns .TRUE.See Note 33

Page 338: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

15-58 47 A2 15UL Rev02

Notes for Table 15-1:

[ NEW ANSI77 [1. For a of type integer or short integer int(a)=a. For a of type real double precision or

quadruple precision there are two cases: ].NEW ANSI77. ]

if |a |< 1, int(a)=0; if |a |>= 1, int(a) is the integer whose magnitude is the largestinteger that does not exceed the magnitude of a and whose sign is the same as thesign of a. For example,

int(-3.7) = -3

For a of[ NEW ANSI77 [type complex, or complex double precision, ].NEW ANSI77. ]int(a) is the value obtained by applying the above rule to the real part of a.

For a of type real, IFIX(a) is the same as INT(a).

For a of type double precision, IDINT (a) is the same as INT(a).

For a of type quadruple precision, IQINT(a) is the same as INT(a).

2. For a of type real, REAL(a) is a. For a of type integer double precision,

[ NEW ANSI77 [

quadruple precision, or short integer

].NEW ANSI77. ]

, REAL(a) is as much precision of the significant part of a as a real datum can contain.For a of type complex, REAL(a) is the real part of a.

[ NEW ANSI77 [For a of type complex double precision, REAL(a) is REAL(CMPLX(a)).

].NEW ANSI77. ]

[ NEW ANSI77 [For a of type integer. FLOAT(a) is the same as REAL(a).For a of type double precision, SNGL(a) is the same as REAL(a).For a of type quadruple precision, SNGLQ(a) is the same as REAL(a).

Page 339: FORTRAN 77 Reference Manual - Bull

Functions and Subroutines

47 A2 15UL Rev02 15-59

3. For a of type double precision, DBLE(a) is a. For a of type integer, real, orquadruple precision, or short integer, DBLE(a) is as much precision of thesignificant part of a as a double precision datum can contain. For a of typecomplex, DBLE(a) is as much precision of the significant part of the real part of aas a double precision datum can contain.

].NEW ANSI77. ]

For a of type complex double precision, DBLE(a) is the real part of a.For a of type integer, DFLOAT(a) is the same as DBLE(a).For a of type quadruple precision, DBLFQ(a) is the same as DBLE(a).For a of type complex double precision, DREAL is the same as DBLE(a).

4. CMPLX may have one or two arguments. If there is one argument, it may be of typeinteger, real, double precision, complex,

[ NEW ANSI77 [

quadruple precision, complex double precision

].NEW ANSI77. ]

, or short integer. If there are two arguments, they must both be of the same type andmay be of type integer, real, double precision,

[ NEW ANSI77 [

quadruple precision, complex double precision

].NEW ANSI77. ]

, or short integer.

For a of type complex, CMPLX(a) is a. For a of type integer,

[ NEW ANSI77 [

real, double precision

].NEW ANSI77. ]

, quadruple precision, or short integer,

CMPLX(a) is the complex value whose real part is REAL(a) and whose imaginarypart is zero.

[ NEW ANSI77 [For a of type complex double precision, CMPLX(a) is the complex value whose realpart is REAL(a) and whose imaginary part is REAL(i), where r and i are the real andimaginary parts of a.

].NEW ANSI77. ]

CMPLX(a1 ,a2) is the complex value whose real part is REAL(a1) and whoseimaginary part is REAL (a2 ).

Page 340: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

15-60 47 A2 15UL Rev02

[ NEW ANSI77 [CINT(a) is the complex value whose real part is AINT(r) and whose imaginary partis AINT(i), where r and i are the real and imaginary parts of a.For a of type complex double precision, CSNGL(a) is the same as CMPLX(a).

].NEW ANSI77. ]

5. ICHAR provides a means of converting from a character to an integer, based onthe position of the character in the processor collating sequence.

! PROCESSOR-DEPENDENT [

The first character in the collating sequence corresponds to position 0 and the last toposition 255 where 256 is the number of characters in the collating sequence.].PROCESSOR-DEPENDENT.!

The value of ICHAR(a) is an integer in the range:! PROCESSOR-DEPENDENT [

0 <= ICHAR(a) <= 255, where a is an argument of type character of length one.].PROCESSOR-DEPENDENT.!

The position of that character in the collating sequence is the value of ICHAR.

! PROCESSOR-DEPENDENT [Note that this means that the binary value of the character a is extended at left withthree characters whose binary value is zero, and that the resulting four charactersis returned as the value of ICHAR(a)

. ].PROCESSOR-DEPENDENT.!

For any characters c1 and c2 , (c1 .LE. c2) is true if and only if (ICHAR(c1) .LE.ICHAR(c2)) is true, and (c1 .EQ. c2 is true if and only if

(ICHAR(c1) .EQ. ICHAR(c2 )) is true.

CHAR(i) returns the character in the ith position of the processor collatingsequence. The value is of type character of length one. i must be an integerexpression whose value must be in the range 0 <= i <= 255.

! PROCESSOR-DEPENDENT [ ICHAR(CHAR( i )) = i for 0 <= i <= 255.

CHAR(ICHAR( c)) = c for any character c.

If i is greater than 255, then CHAR(i) is CHAR(MOD(i, 256)).Note that this means that the binary value of the rightmost byte of i is returned asthe value of CHAR(i)

].PROCESSOR-DEPENDENT.!

Page 341: FORTRAN 77 Reference Manual - Bull

Functions and Subroutines

47 A2 15UL Rev02 15-61

[ NEW ANSI77 [The value of HCHAR(a) is HFIX(ICHAR(a))

The value of KTYPE(a) is the character string with the same length in bytes, andthe same internal representation, as a.For example:

INTEGER I CHARACTER *4 K K = KTYPE (I) produces the same value of K as in the example: INTEGER I, J CHARACTER *4 K EQUIVALENCE (J, K) J = I ].NEW ANSI77. ]

6. A complex value is expressed as an ordered pair of reals, (ar, ai), where ar is thereal part and ai is the imaginary part.

7. All angles are expressed in radians, except specified in degree.

8. The result of a function of type complex is the principal value.

9. All arguments in an intrinsic function reference must be of the same type, exceptotherwise specified.

10. INDEX(a1, a2) returns an integer value indicating the starting position within thecharacter string a 1 of a substring identical to string a2. If a2 occurs more than oncein a1, the starting position of the first occurrence is returned.

If a2, does not occur in a1, the value zero is returned. Note that zero is returned ifLEN(a1) < LEN(a2).

11. The value of the argument of the LEN function need not be defined at the time thefunction reference is executed.

Page 342: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

15-62 47 A2 15UL Rev02

12. LGE(a1, a2) returns the value true if a1 =a2 or if a1 follows a2 in the collatingsequence described in American National Standard Code for InformationInterchange, ANSI X3.4-1977 (ASCII), and otherwise returns the value false.

LGT(a1, a2) returns the value true if a1 follows a2 in the collating sequencedescribed in ANSI X3.4-1977 (ASCII), and otherwise returns the value false.

LLE(a1, a2) returns the value true if a1 =a2 or if a1 precedes a2 in the collatingsequence described in ANSI X3.4-1977 (ASCII), and otherwise returns the valuefalse.

LLT(a1, a2) returns the value true if a1 precedes a2 in the collating sequencedescribed in ANSI X3.4-1977 (ASCII), and otherwise returns the value false.

If the operands for LGE, LGT, LLE, and LLT are of unequal length, the shorteroperand is considered as if it were extended on the right with blanks to the length ofthe longer operand.

If either of the character entities being compared contains a character that is not inthe ASCII character set, the result is processor-dependent.

[ NEW ANSI77 [

13. For more information refer to the document: 64/DPS and DPS7 GCOSMathematical Library.

14. For a of type short integer, HFIX(a) = a.For a of type integer, HFIX(a) = a if the magnitude of a does not exceed the largestshort integer, if it exceeds then HFIX(a) is undefined.For a of other types, HFIX(a) = HFIX(INT(a)).

15. DCMPLX may have one or two arguments. If there is one argument, it may be oftype short integer, integer, real, double precision, quadruple precision, complex, orcomplex double precision. If there are two arguments, they must both be of thesame type and may be one of type short integer, integer, real, double precision orquadruple precision.

For a of type complex double precision, DCMPLX(a) is a. For a of type shortinteger, integer, real, double precision, or quadruple precision, DCMPLX(a) is thecomplex value whose real part is DBLE(a), and whose imaginary part is zero.For a of type complex, DCMPLX(a) is the complex value whose real part isDBLE(r), and whose imaginary part is DBLE(i), where r and i are the real andimaginary parts of a DCMPLX(a1, a2) is the complex value whose real part isDBLE(a1) and whose imaginary part is DBLE(a2).CDINT(a) is the complex value whose real part is DINT(r) and whose imaginarypart is DINT(i), where r and i are the real and imaginary parts of a.For a of type complex, CDBLE(a) is the same as DCMPLX.

16. IHASH(a1, a2) returns a hash code of a1 . The length of character string a1 mustbe less or equal to 256.a2 is the minimal value of the hash code it must be positive or zero. To hashstrings, and obtain a hash code i in the range 0 <= i <= n use:MOD(HASH(a1, a2),n)

17. IPAST(a1, a2) returns zero if all characters of a1 are equal to a2.

Page 343: FORTRAN 77 Reference Manual - Bull

Functions and Subroutines

47 A2 15UL Rev02 15-63

18. KTRANS(a1, a2) returns translation of a1 according to table a2 .The length of a1 must be less than or equal to 256.The algorithm is:

DO 10 I=1, LEN(a 1) J = ICHAR(a 1 (I:I)) + 1 a 1 (I:I) = a 2 (J:J) 10 CONTINUE

19. ITRT(a1, a2, a3) is the classical translate and test function for lexical analysis. Thealgorithm is as follow:

INTEGER FUNCTION ITRT(STRING,TABLE,MASK)C string to scan CHARACTER *(*) STRINGC translation table, usually one bit position in each byteC for each case of lexical unit. CHARACTER A256 TABLEC one mask per set of lexical units to accept, it has bitC position equal to 1 for accepted lexical units, bitpositionsC equal to 0 for others. CHARACTER *1 MASKC translation of current character CHARACTER *1 TRANSC scan the string DO I=1, LEN (STRING)C position in the collating sequence of the current character ICODE = ICHAR (STRING(I:I))C translation of this character TRANS = TABLE (ICODE+1:ICODE+1) ITRANS = ICHAR (TRANS)C mask retyped as integer for IAND on words IMASK = ICHAR (MASK)C is the lexical unit in the set? IF(IAND(ITRANS(IMASK).NE.0) THENC no. Return its position ITRT = I RETURN ENDIFC no. Scan next character10 CONTINUE END

Note that for initializing a2 and a3 by DATA, hexadecimal constants may be used.

20. a1 and a2 may be of different types.

The logical operation is made on the bits contained in the storage unitscorresponding to the arguments (one word of four bytes for each argument).The result is returned as an integer datum having a value corresponding to the bitsof the logical result.

Page 344: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

15-64 47 A2 15UL Rev02

21. All bits representing a1 are shifted a2 places. In the case of a right shift (a2 < 0),zeros are shifted to the left end if a1 is positive or equal to zero and ones areshifted in if a1 is negative. The bits shifted out of the right end are lost. In the caseof a left shift (a2 > 0), zeros are shifted into the right end while the bits shifted out ofthe left end are lost.In a left shift an arithmetic overflow will be indicated whenever the value of the signbit changes. An overflow causes an undefined result.

22. All bits representing a1 are shifted circularly a2 places: the bits shifted out of oneend are shifted into the opposite end.No bits are lost.

23. All bits representing a1 are shifted a2 places. Bits shifted from the left end or theright end, as the case may be, are lost. Zeros are shifted in from the opposite end.

24. Bits are counted from zero to 31 in a word. The rightmost bit of the word is bitnumber zero, the leftmost is bit number 31.

25. IFRTIM(a1 ) - if the value of a1 is T, returns an integer value which is the differencebetween the maximum processor time allowed and the processor time used up tothis call of IFRTIM, expressed in milliseconds. Consequently, it is possible tocalculate the processor time used for the execution of a particular section ofprogram by calling the procedure at the beginning and end of the sectionconsidered, and finding the difference between the two times.- no other values of a1 are presently supported.f the value of a1 is I, returns an integer value in milliseconds of the real time (from0).

KTOD() returns an 8 character value as follows:

date | 0

bit position: 0 52 63

where date is expressed in milliseconds. The difference between two datesobtained by two successive calls of KTOD gives the elapsed time.The strange format of KTOD value is due to the fact that it is the content of ahardware register, extracted by KTOD in only one machine instruction. By furtheruse of substring and bit shift (ISHA) the lower weights of date may be stored into aninteger.

FRTIM(a1 ) returns the date expressed in characters, on a length and with a valueas follows:

- If value of a1 is D, length is 12 characters, value is in the form:

MMMbDD, b19YY

- If value of a1 is B, length is 22 characters, value is in the form:

HH:MM:SS bbMMMbDD,b19YY MMM = JAN/FEB/...

Page 345: FORTRAN 77 Reference Manual - Bull

Functions and Subroutines

47 A2 15UL Rev02 15-65

- If value of a1 is J, length is 5 characters, value is in the form:

YYDDD

26. IWAIT(a1 ,a2 )

a1 is the elapsed time and is >= 0a2 is 0 or 1 for a1 in milliseconds

is 2 for a1 in seconds3 for a1 in minutes

IWAIT returns 0 if delay is spent1 if a1 has not an acceptable value2 if a2 has not an acceptable value

27. For IFRSWT(a1 ,a2 )0 <= a1 <= 31 switch number0 <= a2 <= 1 switch valueThe JCL switches set by IFRSWT may be tested at JCL level to allow the transferof control to a specified label in the job description.

For IFRTWT(a1):0 <= a1 <= 31The value of IFRTWT is 0 or 1.The JCL switch may be set at JCL level.

28. - If value of a1 is the string OPTIONS, then returned string is the string passed tothe $STEP JCL statement, in the OPTIONS parameter.

• If value of a1 is the string MODE, then returned string is IOF if the program isexecuting in interactive mode, or BATCH if it is executing in batch mode.

• If value of a1 is the string SYSTRC, then returned string is a concatenation ofretcod strings of 10 characters each.

Each retcod contains a system return code mnemonic, edited in characters,left justified in retcod, and right padded with blanks.

There are as many retcod as occurred during the last I/O statementprocessing, or during the last intrinsic function processing. The number ofretcod is given by using ITEST ('SYSTRC').

• KTEST is an assumed size character function. Its length is the length cspecified by the calling program unit. The length l that is useful is given by theITEST intrinsic function. If c is greater than l, the useful value is extended tothe right with blank characters up to length c.

If c is less than l, the useful value is truncated from the right, up to length c.

Page 346: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

15-66 47 A2 15UL Rev02

29. If the value of a1 is OPTIONS, then the returned value is the length of the stringpassed to the $STEP JCL statement, in the OPTIONS parameter.

- If the value of a1 is SYSTRC, then the returned value is n + 30 where n is thenumber of retcod strings returned by the KTEST intrinsic function.

- If the value of a1 is LASTER, then the returned value is the number of the lastdetected error during execution of the executable program or zero if there wasno error.

30. This function is for compatibility with GCOS 1E FORTRAN, it returns the number ofthe last detected error during execution of the executable program whencorrespondence exists between error cases detected by 1E FORTRAN and DPS7FORTRAN 77 the error number of 1E FORTRAN is returned. This function shouldnot be used for new programs developed with DPS7 FORTRAN 77 as it is replacedby the ITEST function, or by the IOSTAT= specifier in input/output statement.

31. IPDUMP(a11 ,a21 ,a31 ,a12 ,a22 ,a32 ,...) returns zero if there is no error in theargument list; returns a negative value if there is an error in the argument list.

The output values are sent to the same unit as for a WRITE(UNIT=*) with a formatspecified by a 3i. This format is the one of the list directed formatting, assuming thatall data between a1i and a2i are of the same type, given by the following table:

Value of a 3i Type

0: hexadecimal1: short logical2: logical3: short integer4: integer5: real6: double precision7: complex8: complex double precision9: character

32. In LSETK(a1 ,a2 )

- If the value of a1 is OBSERV, the run time observations (severity 1) are sent ifthe value a2 is YES, or are not sent if the value of a2 is NO. Default value isYES.

- If the value of a1 is WARNING, the run time warnings (severity 2) are sent ifthe value of a2 is YES, or are not sent if the value of a2 is NO. Default value isYES.

- If the value of a1 is ERRPRINT, errors (severity 1 to 4) occurring during aninput output statement with an ERR specifier are sent if the value of a2 is YES,or are not sent if the value of a2 is NO. Default value is YES.

- If the value of a1 is ERROR, the run time errors (severity 1 to 4) are sent as ifthey were output by WRITE(UNIT=*) if the value of a2 is H_PR or are sent tothe JOR (Job Occurrence Report) if the value of a2 is JOR. Default value isH_PR.

- If the value of a1 is SUMMARY, the execution summary is printed if the valueof a2 is YES, or is not printed if the value of a2 is NO. Default value is YES.

- If the value of a1 is RECIO and if the value of a is DELETE, the run time willterminate the current I/O if any is begun.

Page 347: FORTRAN 77 Reference Manual - Bull

Functions and Subroutines

47 A2 15UL Rev02 15-67

It is prohibited to use a function doing I/O as an I/O list argument (cf 12.11)

Ex write (..)(FCI), I = 1,n)

and function f (I) read (...) ...

If the user wishes to print an error message he must write before l = LSETK('RECIO', 'DELETE')

If an I/O is effectively deleted the function may not return to caller.

In LSETI(a 1 ,a 2 )

- If the value of a1 is ERRMAX, the value of a2 gives the maximum number oferrors that may be emitted during execution of the executable program. If thisnumber is exceeded, the step is aborted. The observations (severity 1) are notcounted.

- If the value of a1 is SEV, the value of a2 overrides the severity of the steptermination. Note that the allowed severities ae in the range 0 thru 4.

33. In LSETS(a1 ,a2 )

If the value of a1 is UNDERFLOW, the floating point underflow is masked if thevalue of a2 is MASK, or unmasked if the value of a2 is UNMASK.

When the floating point underflow is masked, a zero result is returned by a floatingpoint operation (addition, multiplication,..., on real, double precision or quadrupleprecision datum) if the result is less than the minimum value acceptable by theprocessor.When the floating point overflow is unmasked, an exception occurs and is reportedin the JOR (Job Occurrence Report) if a floating point operation produces a resultless than the minimum value acceptable by the processor. The result of theoperation is then undefined.Note that a1 and a2 must be constant expressions.

34. LOCF (a1 )

Returns a location that is the address of a1 . The argument a1 can be a variable,array element or substring.

35. REFCHAR (a1)

May be used in CALL statement only. The argument a1 can be any expression, oftype character only. CALL SUB (REFCHAR(a1)) enables to pass a1 actualargument by address, when CALL SUB(a1) passes a1 by descriptor. Note that if acharacter argument is passed by address in a CALL statement, all characterarguments must be passed in the same way. This provides the means for passingcharacter arguments to COBOL-like subprograms without using LEVEL=GCOS1Eoption (see the Fortran 77 User's Guide).

].NEW ANSI77. ]

Page 348: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

15-68 47 A2 15UL Rev02

15.10.1 Restrictions on Range of Arguments and Results

Restrictions on the range of arguments and results for intrinsic functions whenreferenced by their specific names are as follows:

1. Remaindering: The result for

[ NEW ANSI77 [

MOD, AMOD, DMOD and QMOD

].NEW ANSI77. ]

is undefined when the value of the second argument is zero.

2. Transfer of Sign: If the value of the first argument of ISIGN, SIGN, DSIGN orQSIGN is zero, the result is zero,

[ NEW ANSI77 [

which is neither positive or negative (4.1.3).

].NEW ANSI77. ]

[ NEW ANSI77 [

3. Square Root: The value of the argument of SQRT, DSQRT and QSQRT must begreater than or equal to zero. The result or CSQRT and CDSQRT is the principalvalue with the real part greater than or equal to zero.

].NEW ANSI77. ]

When the real part of the result is zero, the imaginary part is greater than or equalto zero.

4. Logarithms: The value of the argument of ALOG, DLOG, QLOG,

[ NEW ANSI77 [

ALOG2, DLOG2,

QLOG2, ALOG10, DLOG10 and QLOG10 must be greater than zero. The value ofthe argument of CLOG, CDLOG must not be (0.,0.)

. ].NEW ANSI77. ]

The range of the imaginary part of the result of CLOG is:

- <= imaginary part <= . The imaginary part of the result is only when the realpart of the argument is less than zero and the imaginary part of the argumentis zero.

Page 349: FORTRAN 77 Reference Manual - Bull

Functions and Subroutines

47 A2 15UL Rev02 15-69

5. Sine, Cosine, and Tangent: The absolute value of the argument of

[ NEW ANSI77 [

SIN, DSIN, COS, DCOS, TAN, DTAN, QSIN, QCOS, QTAN, COTAN, DCOTAN,

].NEW ANSI77. ]

QCOTAN is not restricted to be less than 2.

6. Arcsine: The absolute value of the argument of ASIN, DASIN,

[ NEW ANSI77 [

and QASIN

].NEW ANSI77. ]

must be less than or equal to one. The range of the result is: - /2 <= result <= /2.

7. Arccosine: The absolute value of the argument of ACOS, DACOS,

[ NEW ANSI77 [

and QACOS

].NEW ANSI77. ]

must be less than or equal to one. The range of the result is: 0 <= result <=.

8. Arctangent: The range of the result for ATAN, DATAN,

[ NEW ANSI77 [

and QATAN

].NEW ANSI77. ]

is: - /2 <= result <= /2. If the value of the first argument of ATAN2, DATAN2,

[ NEW ANSI77 [

or QATAN2

].NEW ANSI77. ]

is positive, the result is positive.

If the value of the first argument is zero, the result is zero if the second argument ispositive and s if the second argument is negative. If the value of the first argumentis negative, the result is negative. If the value of the second argument is zero, theabsolute value of the result is /2. The arguments must not both have the value zero.The range of the result for ATAN2, DATAN2,

Page 350: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

15-70 47 A2 15UL Rev02

[ NEW ANSI77 [

and QATAN2

].NEW ANSI77. ]

is - <= result <=.

The above restrictions on arguments and results also apply to the intrinsic functionswhen referenced by their generic names.

Additional information about the range of arguments or results is available in 64/DPSand DPS7 GCOS Mathematical Library.

Page 351: FORTRAN 77 Reference Manual - Bull

47 A2 15UL Rev02 16-1

16. Block Data Subprogram

subprogramblock data

Block data subprograms are used to provide initial values for variables and arrayelements in named common blocks.

A block data subprogram is a program unit that has a BLOCK DATA statement as itsfirst statement. A block data subprogram is nonexecutable. There may be more than oneblock data subprogram in an executable program.

16.1 BLOCK DATA STATEMENT

BLOCK DATA statement

The form of a BLOCK DATA statement is:

BLOCK DATA [sub]

where sub is the symbolic name of the block data subprogram in which the BLOCKDATA statement appears.

The optional name sub is a global name (18.1.1) and must not be the same as the nameof an external procedure, main program, common block, or other block data subprogramin the same executable program. The name sub must not be the same as any localname in the subprogram.

! PROCESSOR-DEPENDENT [

If there is no symbolic name in the BLOCK DATA statement, the symbolic nameFORTRANBLKi is assumed, where i is the number of the unnamed block datasubprogram in the list of program units specified by the SOURCE= parameters of theJCL statement $FOR77.The first unnamed block data has number 0, the second 1, ..., up to the maximum whichis 99.

].PROCESSOR-DEPENDENT.!

Page 352: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

16-2 47 A2 15UL Rev02

16.2 BLOCK DATA SUBPROGRAM RESTRICTIONS

The BLOCK DATA statement must appear only as the first statement of a block datasubprogram. The only other statements that may appear in a block data subprogram areIMPLICIT, PARAMETER, DIMENSION, COMMON, SAVE, EQUIVALENCE, DATA,END, and type-statements. Note that comment lines are permitted.

If an entity in a named common block is initially defined, all entities having storage unitsin the common block storage sequence must be specified even if they are not all initiallydefined. More than one named common block may have entities initially defined in asingle block data subprogram.

Only an entity in a named common block may be initially defined in a block datasubprogram. Note that entities associated with an entity in a common block areconsidered to be in that common block.

The same named common block may not be specified in more than one block datasubprogram in the same executable program.

There must not be more than one unnamed block data subprogram in an executableprogram

[ NEW ANSI77 [

if the block data subprograms are compiled separately.

].NEW ANSI77. ]

A block data subprogram may not be contained in a package unit (see Section 19.).

Page 353: FORTRAN 77 Reference Manual - Bull

47 A2 15UL Rev02 17-1

17. Association and Definition

17.1 STORAGE AND ASSOCIATION

Storage sequences are used to describe relationships that exist among variables, arrayelements, substrings, common blocks, and arguments.

17.1.1 Storage Sequence

A storage_sequence is a sequence (2.1) of storage units. The sizeof_a_storage_sequence is the number of storage units in the storage sequence. Astorage_unit is a character storage unit or a numeric storage unit.

A variable or array element of type integer, real, or logical has a storage sequence ofone numeric storage unit.

A variable or array element of type double precision or complex has a storage sequenceof two numeric storage units. In a complex storage sequence, the real part has the firststorage unit and the imaginary part has the second storage unit.

A variable, array element, or substring of type character has a storage sequence ofcharacter storage units. The number of character storage units in the storage sequenceis the length of the character entity. The order of the sequence corresponds to theordering of character positions (4.8).

[ NEW ANSI77 [

A variable or array element of type quadruple precision or complex double precision hasa storage sequence of four numeric storage units. In a complex double precision storagesequence, the real part has the first two storage units, and the imaginary part has thenext two storage units.

A variable or array element of type short integer has a storage sequence of half anumeric storage unit.

Page 354: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

17-2 47 A2 15UL Rev02

A variable or array element of type short logical has a storage sequence of onecharacter storage unit.

].NEW ANSI77. ]

! PROCESSOR-DEPENDENT [

On DPS7 FORTRAN 77, a numeric storage unit consists of four bytes (one word), half anumeric storage unit consists of two bytes (one half word), a character storage unitconsists of one byte.

The precise structure of numeric storage units is given in the FORTRAN 77 User Guide.

].PROCESSOR-DEPENDENT.!

Each array and common block has a storage sequence (5.2.5 and 8.3.2).

17.1.2 Association of Storage Sequences

Two storage sequences s1 and s2 are associated if the ith storage unit of s1 is the sameas the jth storage unit of s2. This causes the (i+k)th storage unit of s1 to be the same asthe (j+k)th storage unit of s2 , for each integer k such that 1 <= i+k <= size of s1 and 1<= j+k <= size of s2 .

Page 355: FORTRAN 77 Reference Manual - Bull

Association and Definition

47 A2 15UL Rev02 17-3

17.1.3 Association of Entities

Two variables, array elements, or substrings are associated if their storage sequencesare associated. Two entities are totally associated if they have the same storagesequence. Two entities are partially_associated if they are associated but not totallyassociated.

The definition status and value of an entity affects the definition status and value of anyassociated entity. An EQUIVALENCE statement, a COMMON statement, an ENTRYstatement (15.7.3), or a procedure reference (argument association) may causeassociation of storage sequences.

An EQUIVALENCE statement causes association of entities only within one programunit, unless one of the equivalenced entities is also in a common block (8.3).

Arguments and COMMON statements cause entities in one program unit to becomeassociated with entities in another program unit (8.3 and 15.9). Note that associationbetween actual and dummy arguments does not imply association of storage sequencesexcept when the actual argument is the name of a variable, array element, array, orsubstring.

In a function subprogram, an ENTRY statement causes the entry name to becomeassociated with the name of the function subprogram which appears in the FUNCTIONstatement.

Partial association may exist only between two character entities or between a doubleprecision or complex entity and an entity of type integer, real, logical, double precision,complex, short integer,

[ NEW ANSI77 [

quadruple precision, complex double precision

].NEW ANSI77. ]

or short logical.

Except for character entities, partial association may occur only through the use ofCOMMON, EQUIVALENCE, or ENTRY statements.

Partial association must not occur through argument association, except for argumentsof type character.

Page 356: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

17-4 47 A2 15UL Rev02

In the example:

REAL A(4),BCOMPLEX C(2)DOUBLE PRECISION DEQUIVALENCE (C(2),A(2),B) (A,D)

the third storage unit of C, the second storage unit of A, the storage unit of B, and thesecond storage unit of D are specified as the same. The storage sequences may beillustrated as:

storage unit | 1 | 2 | 3 | 4 | 5 | |----C(1)---|---C(2)----| | A(1)| A(2)| A(3)| A(4)| |--B--| |-----D-----|

A(2) and B are totally associated. The following are partially associated: A(1) and C(1),A(2) and C(2), A(3) and C(2), B and C(2), A(1) and D, A(2) and D, B and D, C(1) and D,and C(2) and D.Note that although C(1) and C(2) are each associated with D, C(1) and C(2) are notassociated with each other.

Partial association of character entities occurs when some, but not all, of the storageunits of the entities are the same. In the example:

CHARACTER A*4,B*4,C*3 EQUIVALENCE (A(2:3),B,C)

A, B, and C are partially associated.

Page 357: FORTRAN 77 Reference Manual - Bull

Association and Definition

47 A2 15UL Rev02 17-5

17.2 EVENTS THAT CAUSE ENTITIES TO BECOME DEFINED

Variables, array elements, and substrings become defined as follows:

1. Execution of an arithmetic, logical, or character assignment statement causes theentity that precedes the equals to become defined.

2. As execution of an input statement proceeds, each entity that is assigned a value ofits corresponding type from the input medium becomes defined at the time of suchassignment.

3. Execution of a DO statement causes the DO-variable to become defined.

4. Beginning of execution of action specified by an implied-DO list in an input/outputstatement causes the implied-DO-variable to become defined.

5. A DATA statement causes entities to become initially defined at the beginning ofexecution of an executable program.

6. Execution of an ASSIGN statement causes the variable in the statement to becomedefined with a statement label value.

7. When an entity of a given type becomes defined, all totally associated entities of thesame type become defined except that entities totally associated with the variablein an ASSIGN statement become undefined when the ASSIGN statement isexecuted.

8. A reference to a subprogram causes a dummy argument to become defined if thecorresponding actual argument is defined with a value that is not a statement labelvalue. Note that there must be agreement between the actual argument and thedummy argument (15.9.3).

9. Execution of an input/output statement containing an input/output status specifiercauses the specified integer variable or array element to become defined.

10. Execution of an INQUIRE statement causes any entity that is assigned a valueduring the execution of the statement to become defined if no error condition exists.

11. When a complex entity becomes defined, all partially associated real entitiesbecome defined.

12. When both parts of a complex entity become defined as a result of partiallyassociated real or complex entities becoming defined, the complex entity becomesdefined.

13. When all characters of a character entity become defined, the character entitybecomes defined.

Page 358: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

17-6 47 A2 15UL Rev02

17.3 EVENTS THAT CAUSE ENTITIES TO BECOME UNDEFINED

Variables, array elements, and substrings become undefined as follows:

1. All entities are undefined at the beginning of execution of an executable programexcept those entities initially defined by DATA statements.

2. When an entity of a given type becomes defined, all totally associated entities ofdifferent type become undefined.

3. Execution of an ASSIGN statement causes the variable in the statement to becomeundefined as an integer. Entities that are associated with the variable becomeundefined.

4. When an entity of type other than character becomes defined, all partiallyassociated entities become undefined. However, when an entity of type real ispartially associated with an entity of type complex, the complex entity does notbecome undefined when the real entity becomes defined and the real entity doesnot become undefined when the complex entity becomes defined. When an entityof type complex is partially associated with another entity of type complex, definitionof one entity does not cause the other to become undefined.

5. When the evaluation of a function causes an argument of the function or an entityin common to become defined and if a reference to the function appears in anexpression in which the value of the function is not needed to determine the valueof the expression, then the argument or the entity in common becomes undefinedwhen the expression is evaluated (6.6.1).

6. The execution of a RETURN statement or an END statement within a subprogramcauses all entities within the subprogram to become undefined except for thefollowing:

a. Entities in blank commonb. Initially defined entities that have neither been redefined nor become undefinedc. Entities specified by SAVE statementsd. Entities in a named common block even if the following condition stated by ANSI 77 is not verified: [ NEW ANSI77 [ the named common block that appears in the subprogram and appears in at least one other program unit that is either directly or indirectly referencing the subprogram ].NEW ANSI77. ] ! PROCESSOR-DEPENDENT [e. Entities equivalenced with entities specified by a SAVE statement. ].PROCESSOR-DEPENDENT.!

7. When an error condition or end-of-file condition occurs during execution of an inputstatement, all of the entities specified by the input list of the statement becomeundefined.

8. Execution of a direct access input statement that specifies a record that has notbeen previously written causes all of the entities specified by the input list of thestatement to become undefined.

Page 359: FORTRAN 77 Reference Manual - Bull

Association and Definition

47 A2 15UL Rev02 17-7

9. Execution of an INQUIRE statement may cause entities to become undefined(12.10.3).

10. When any character of a character entity becomes undefined, the character entitybecomes undefined.

11. When an entity becomes undefined as a result of conditions described in (5)through (10), all totally associated entities become undefined and all partiallyassociated entities of type other than character become undefined.

Page 360: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

17-8 47 A2 15UL Rev02

Page 361: FORTRAN 77 Reference Manual - Bull

47 A2 15UL Rev02 18-1

18. Scope and Classes of Symbolic Names

[ NEW ANSI77 [

A symbolic name consists of one to eight alphanumeric characters, the first of whichmust be a letter.

].NEW ANSI77. ]

Some sequences of characters, such as format edit descriptors and keywords thatuniquely identify certain statements, for example, GO TO, READ, FORMAT, etc, are notsymbolic names in such occurrences nor do they form the first characters of symbolicnames in such occurrences.

18.1 SCOPE OF SYMBOLIC NAMES

The scope of a symbolic name is an executable program, a program unit, a statementfunction statement, an implied-DO list in a DATA statement, or a package unit (seeSection 19.).

The name of the main program and the names of block data subprograms, have ascope of an executable program.

[ NEW ANSI77 [

The names of external functions, subroutines and common blocks have a scope of anexecutable program, or of a package unit.

].NEW ANSI77. ]

The names of variables, arrays, constants, statement functions, intrinsic functions, anddummy procedures have a scope of a program unit, or of a package unit.

The names of variables that appear as dummy arguments in a statement functionstatement have a scope of that statement.

The names of variables that appear as the DO-variable of an implied-DO in a DATAstatement have a scope of the implied-DO list.

Page 362: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

18-2 47 A2 15UL Rev02

18.1.1 Global Entities

The main program, common blocks, subprograms, and external procedures are globalentities of an executable program,

[ NEW ANSI77 [

except if they are inside a package unit not specified in EXTROUTINE or EXTCOMMONstatement.

].NEW ANSI77. ]

A symbolic name that identifies a global entity must not be used to identify any otherglobal entity in the same executable program.

18.1.1.1 Classes of Global Entities

A symbolic name in one of the following classes is a global entity in an executableprogram:

1. Common block

- if not inside a package unit

[ NEW ANSI77 [

- or if inside a package unit, but specified in a EXTCOMMON statement.

].NEW ANSI77. ]

2. External function

[ NEW ANSI77 [

- if the function subprogram is not only inside a package unit- or if the function subprogram is inside a package unit, but specified in an- EXTROUTINE statement.

].NEW ANSI77. ]

3. Subroutine

[ NEW ANSI77 [

- if the subroutine subprogram is not only inside a package unit- or if the subroutine subprogram is inside a package unit, but specified in an- EXTROUTINE statement

. ].NEW ANSI77. ]

4. Main program

5. Block data subprogram

Page 363: FORTRAN 77 Reference Manual - Bull

Scope and Classes of Symbolic Names

47 A2 15UL Rev02 18-3

18.1.2 Local Entities

The symbolic name of a local entity identifies that entity in a single program unit. Within aprogram unit, a symbolic name that is in one class of entities local to the program unitmust not also be in another class of entities local to the program unit.

However, a symbolic name that identifies a local entity may, in a different program unit,identify an entity of any class that is either local to that program unit or global to theexecutable program. A symbolic name that identifies a global entity in a program unitmust not be used to identify a local entity in that program unit, except for a commonblock name and an external function name (18.2.1 and 18.2.2).

[ NEW ANSI77 [

The symbolic name of a local entity identifies that entity in a single package unit. Withina package unit, a symbolic name that is in one class of entities local to the package unitmust not also be in another class of entities local to the package unit.

However, a symbolic name that identifies a local entity may, in a different package unit,identify an entity of any class that is either local to that package unit or global to theexecutable program. A symbolic name that identifies a global entity in a package unitmust not be used to identify a local entity in that package unit, except for a commonblock name and an external function name (18.2.1 and 18.2.2)

. ].NEW ANSI77. ]

18.1.2.1 Classes of Local Entities

A symbolic name in one of the following classes is a local entity in a program unit.

1. Array

2. Variable

3. Constant

4. Statement function

5. Intrinsic function

6. Dummy procedure

A symbolic name that is a dummy argument of a procedure is classified as a variable,array, or dummy procedure. The specification and usage must not violate the respectiveclass rules.

Page 364: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

18-4 47 A2 15UL Rev02

[ NEW ANSI77 [

A symbolic name in one of the following classes is a local entity in a package unit.

1. Array, variable: if specified in a specification statement prior to the first program unitof the package unit

2. Constant

3. Common block, if not specified in an EXTCOMMON statement

4. Function subprogram or subroutine subprogram, if not specified in anEXTROUTINE statement

].NEW ANSI77. ]

18.2 CLASSES OF SYMBOLIC NAMES

In a program unit, a symbolic name must not be in more than one class except as notedin the following paragraphs of this section.There are no restrictions on the appearances of the same symbolic name in differentprogram units of an executable program than those noted in this section.

18.2.1 Common block

A symbolic name is the name of a common block if and only if it appears as a blockname in a COMMON statement (8.3).

[ NEW ANSI77 [

A common block name is global to the executable program, or local to a package unit.

].NEW ANSI77. ]

A common block name in a program unit may also be the name of any local entity otherthan a constant, intrinsic function, or a local variable that is also an external function in afunction subprogram. If a name is used for both a common block and a local entity, theappearance of that name in any context other than as a common block name in aCOMMON or SAVE statement identifies only the local entity. Note that an intrinsicfunction name may be a common block name in a program unit that does not referencethe intrinsic function.

Page 365: FORTRAN 77 Reference Manual - Bull

Scope and Classes of Symbolic Names

47 A2 15UL Rev02 18-5

18.2.2 External Function

A symbolic name is the name of an external function if it meets either of the followingconditions:

1. The name appears immediately following the word FUNCTION in a FUNCTIONstatement or the word ENTRY in an ENTRY statement within a functionsubprogram.

2. It is not an array name, character variable name, statement function name, intrinsicfunction name, dummy argument, or subroutine name, and every appearance isimmediately followed by a left parenthesis except in a type-statement, in anEXTERNAL statement, or as an actual argument.

In a function subprogram, the name of a function that appears immediately after theword FUNCTION in a FUNCTION statement or immediately after the word ENTRY in anENTRY statement may also be the name of a variable in that subprogram (15.5.1). Atleast one such function name must be the name of a variable in a function subprogram.

An external function name is global to the executable program

[ NEW ANSI77 [

or local to a package unit.

].NEW ANSI77. ]

Page 366: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

18-6 47 A2 15UL Rev02

18.2.3 Subroutine

A symbolic name is the name of a subroutine if it meets either of the followingconditions:

1. The name appears immediately following the word SUBROUTINE in aSUBROUTINE statement or the word ENTRY in an ENTRY statement within asubroutine subprogram.

2. The name appears immediately following the word CALL in a CALL statement andis not a dummy argument.

A subroutine name is global to the executable program,

[ NEW ANSI77 [

or local to a package unit.

].NEW ANSI77. ]

18.2.4 Main Program

A symbolic name is the name of a main program if and only if it appears in a PROGRAMstatement in the main program.

A main program name is global to the executable program.

18.2.5 Block Data Subprogram

A symbolic name is the name of a block data subprogram if and only if it appears in aBLOCK DATA statement.

A block data subprogram name is global to the executable program.

Page 367: FORTRAN 77 Reference Manual - Bull

Scope and Classes of Symbolic Names

47 A2 15UL Rev02 18-7

18.2.6 Array

A symbolic name is the name of an array if it appears as the array name in an arraydeclarator (5.1) in a DIMENSION, COMMON, or type-statement.

An array name is local to a program unit,

[ NEW ANSI77 [

or to a package unit.

].NEW ANSI77. ]

An array name may be the same as a common block name.

18.2.7 Variable

A symbolic name is the name of a variable if it meets all of the following conditions:

1. It does not appear in a PARAMETER, INTRINSIC, or EXTERNAL statement.

2. It is not the name of an array, subroutine, main program, or block data subprogram.

3. It appears other than as the name of a common block, the name of an externalfunction in a FUNCTION statement, or an entry name in an ENTRY statement in anexternal function.

4. It is never immediately followed by a left parenthesis unless it is immediatelypreceded by the word FUNCTION in a FUNCTION statement, is immediatelypreceded by the word ENTRY in an ENTRY statement, or is at the beginning of acharacter substring name (5.7.1).

A variable name in the dummy argument list of a statement function statement is local tothe statement function statement in which it occurs. Note that the use of a name thatappears in Table 15-1 as a dummy argument of a statement function removes it from theclass of intrinsic functions. A variable name that appears as an implied-DO-variable in aDATA statement is local to the implied-DO list. All other variable names are local to aprogram unit,

[ NEW ANSI77 [

or to a package unit.

].NEW ANSI77. ]

A statement function dummy argument name may also be the name of a variable orcommon block in the program unit. The appearance of the name in any context otherthan as a dummy argument of the statement function identifies the local variable orcommon block.The statement function dummy argument name and local variable name have the sametype and, if of type character, both have the same constant length.

Page 368: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

18-8 47 A2 15UL Rev02

The name of an implied-DO-variable in a DATA statement may also be the name of avariable or common block in the program unit.The appearance of the name in any context other than as an implied-DO-variable in theDATA statement identifies the local variable or common block. The implied-DO-variableand the local variable have the same type.

18.2.8 Constant

A symbolic name is the name of a constant if it appears as a symbolic name in aPARAMETER statement.

The symbolic name of a constant is local to a program unit, or to a package unit.

18.2.9 Statement Function

A symbolic name is the name of a statement function if a statement function statement(15.4) is present for that symbolic name and it is not an array name.

A statement function name is local to a program unit. A statement function name may bethe same as a common block name.

18.2.10 Intrinsic Function

A symbolic name is the name of an intrinsic function if it meets all of the followingconditions:

1. The name appears in the Specific Name column or the Generic Name column ofTable 15-1.

2. It is not an array name, statement function name, subroutine name, or dummyargument name.

3. Every appearance of the symbolic name, except in an INTRINSIC statement, atype-statement, or as an actual argument, is immediately followed by an actualargument list enclosed in parentheses.

An intrinsic function name is local to a program unit.

Page 369: FORTRAN 77 Reference Manual - Bull

Scope and Classes of Symbolic Names

47 A2 15UL Rev02 18-9

18.2.11 Dummy Procedure

A symbolic name is the name of a dummy procedure if the name appears in the dummyargument list of a FUNCTION, SUBROUTINE, or ENTRY statement and meets one ormore of the following conditions:

1. It appears in an EXTERNAL statement.

2. It appears immediately following the word CALL in a CALL statement.

3. It is not an array name or character variable name, and every appearance isimmediately followed by a left parenthesis except in a type-statement in anEXTERNAL statement, in a CALL statement as a dummy argument, as an actualargument, or as a common block name in a COMMON or SAVE statement.

A dummy procedure name is local to a program unit.

Page 370: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

18-10 47 A2 15UL Rev02

Page 371: FORTRAN 77 Reference Manual - Bull

47 A2 15UL Rev02 19-1

19. Package Units

[ NEW ANSI77 [

A package unit is an ordered set of program units (PROGRAM, SUBROUTINE, orFUNCTION) that the processor treats as a whole unit. The processor considers asequence of statements to be a package unit when one of the following exclusive optionconditions is met:

• The compiler is invoked with the option PACKAGE=OPEN or PACKAGE=CLOSE.This condition is called automatic packaging.

• The sequence of statements begins with a PACKAGE statement and ends with anENDPACKAGE statement. This condition is called manual packaging.

Page 372: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

19-2 47 A2 15UL Rev02

19.1 AUTOMATIC PACKAGING

When this compile option is specified, the program must not contain any of the manualpackaging statements, that is, PACKAGE, EXTROUTINE, EXTCOMMON, andENDPACKAGE. The processor treats all the statements as a whole. Compiling acorrect set of statements results in only one compile unit, even though several programunits are encountered in the source program.

A package unit can contain any number of program units, but cannot contain anyBLOCKDATA subprograms. The type of package unit is determined by the type of firstprogram unit. The name of the package unit and the first program unit correspond asfollows:

PACKAGE UNIT NAME TYPE OF FIRST PROGRAM UNITPROGRAM Package main programSUBROUTINE Package SUBROUTINE subprogramFUNCTION Package FUNCTION subprogram

If the first statement of a package unit is not a PROGRAM statement, a SUBROUTINEstatement, or a FUNCTION statement, the processor assumes that it is a main programwith the symbolic name of FORTRANMAIN. Neither an external program unit nor apackage unit can call a package whose first unit is a main program.

If the first statement of a package unit is a SUBROUTINE or a FUNCTION statement,either a CALL statement or a function reference statement can call it from an externalprogram unit.

The first program unit of a package unit can call the subsequent program units of thepackage unit and also the external program units. The subsequent program units of thepackage unit can call any external program units as well as other program units of thepackage unit, except for the first one. Recursive calls are prohibited.

Page 373: FORTRAN 77 Reference Manual - Bull

Package Units

47 A2 15UL Rev02 19-3

19.2 CLOSE AUTOMATIC PAC KAGE

When a package unit is compiled with the option PACKAGE=CLOSE, the externalprogram units can call only the first program unit and secondary entries of the firstprogram unit, if any exist.

The processor associates the common blocks of a close package with the othercommon blocks of the same name in the package unit. However, it does not associatethe common blocks of a close package with those of the external program units orpackage units, even though they have the same name.

19.3 OPEN AUTOMATIC PACKAGE

When the processor compiles a package unit with the option PACKAGE=OPEN, anexternal program unit can call all the program units of the package and any secondaryentries. Do not compile a package unit with the option PACKAGE=OPEN if its firststatement is a PROGRAM statement or is not a program unit specification statement.This is because it must not be called by any other procedure.

The processor associates the common blocks of an open package with the othercommon blocks of the same name in the package unit as well as with those of theexternal program units or open package units.

Page 374: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

19-4 47 A2 15UL Rev02

19.4 MANUAL PACKAGING

Another way of creating packages is to insert special statements among the sourcestatements to be compiled. In this way, the following is possible:

• To compile several package units or unpackaged program units in the same compilersession (this results in several compile units).

• To specify those of the entry points and those of the common blocks that are to beexported with more flexibility than by automatic packaging.

A manual package_unit consists of a sequence of statements and optional commentlines. The statements must be in the following order.

1. A PACKAGE statement

2. Optionally, one or several EXTROUTINE statements, one or severalEXTCOMMON statements and one SAVE statement without list. EXTROUTINE,EXTCOMMON and SAVE statements, if present, may appear in any order.

3. A sequence of program units except BLOCKDATA subprogram. If there is a mainprogram, it must be unique, and have a PROGRAM statement whose symbolicname is also specified in the PACKAGE statement.

4. An ENDPACKAGE statement, not followed by comment lines. The only mandatorystatements of a package unit are: PACKAGE and ENDPACKAGE statements, andthe statements of one program unit.

19.5 PACKAGE STATEMENT

The form of a PACKAGE statement is:

PACKAGE main

where: main is the symbolic name of a main program, subroutine subprogram orfunction subprogram used in a PROGRAM, SUBROUTINE, FUNCTION or ENTRYstatement of the package unit.

Page 375: FORTRAN 77 Reference Manual - Bull

Package Units

47 A2 15UL Rev02 19-5

19.6 EXTROUTINE STATEMENT

The form of an EXTROUTINE statement is:

EXTROUTINE [sub [,sub]...]

where: sub is the symbolic name of a subroutine subprogram or function subprogramused in a SUBROUTINE, FUNCTION or ENTRY statement of the package unit.

Only one appearance of the same symbolic name is permitted in PACKAGE andEXTROUTINE statements.

Appearance of a symbolic name in a PACKAGE or EXTROUTINE statement declare thisname global to the executable program (18.1.1). The symbolic name is subsequentlyreferable from a program unit not belonging to the package unit.

Conversely, if the symbolic name of a procedure belonging to the package unit is notspecified in the EXTROUTINE statement, this name is local to the package unit and maynot be referenced from a program unit not belonging to this package unit.

The symbolic name of a subroutine subprogram or of a function subprogram used in aSUBROUTINE, FUNCTION or ENTRY statement of the package unit, may bereferenced from a CALL statement or function call any program unit of the package unit.This is so if the symbolic name is, or is not, specified in the PACKAGE andEXTROUTINE statements of this package unit.

An EXTROUTINE statement not followed by a list of symbolic names has the sameeffect as if all the names used in SUBROUTINE, FUNCTION or ENTRY statements ofthe package unit, appeared in an EXTROUTINE statement. For entry points, this is thesame effect that automatic packaging has, when PACKAGE=OPEN is specified.

For more information about the PACKAGE=OPEN option, see the subsection on OPENAUTOMATIC PACKAGE in this chapter.

Page 376: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

19-6 47 A2 15UL Rev02

19.7 EXTCOMMON STATEMENT

The form of an EXTCOMMON statement is:

EXTCOMMON [cb [,cb]...]

where: cb is either a common block name used in a COMMON statement of thepackage unit, or two slashes specifying the blank common block, in which case theblank common must be specified by a COMMON statement of the package unit.

Only one appearance of a common block name is permitted in an EXTCOMMONstatement.

Appearance of a common block name in an EXTCOMMON statement declares that thisname is global to the executable program (18.1.1), and that this common block isassociated (8.3.4) with common blocks of the executable program which have alsoglobal names.

Conversely, if a common block name is not specified in an EXTCOMMON statement,that name is local to the package unit, and this common block is associated only withcommon blocks of this package unit, which have the same name.

An EXTCOMMON statement not followed by a list of common block names has thesame effect as if all the common block names of the package unit (including the blankcommon block, if present), appeared in an EXTCOMMON statement. For commonblocks, this is the same effect that automatic packaging has when PACKAGE=OPEN isspecified.

For more information about the PACKAGE=OPEN option, see the subsection on OPENAUTOMATIC PACKAGE in this chapter

. ].NEW ANSI77. ]

! PROCESSOR-DEPENDENT [

Example:1

Package_unit_incorporating_a_small_executable_program.

PACKAGE E900PROGRAM E900COMMON /C/II = 1CALL S900IF (I.EQ.2) THENWRITE (*,*) 'bCORRECTbDOCUMENTATION'ELSEWRITE (*,*) 'bWRONGbDOCUMENTATION'ENDIFSTOPENDSUBROUTINE S900COMMON /C/ITRUE

Page 377: FORTRAN 77 Reference Manual - Bull

Package Units

47 A2 15UL Rev02 19-7

I = 3ITRUE = 2RETURNENDENDPACKAGE

Note that I is local to the program and local to the ubroutine, so that the messageCORRECT DOCUMENTATION must be output.

Example:2

Package unit incorporating a module of an executable program (refer to DPS7FORTRAN 77 User Guide)

PACKAGE S910EXTROUTINE EXPORTEXTCOMMON GLOBAL

C procedures global to the executable program

SUBROUTINE S910(X)CALL LOCAL (X)CALL EXTERNCALL EXPORTENDSUBROUTINE EXPORTCOMMON/GLOBAL/BCOMMON/LOC/W

C data local to the program unit

REAL D, ED = WB = W + EEND

C procedure local to the package unit

SUBROUTINE LOCAL (Y)COMMON/LOC/WW = YENDENDPACKAGE ].PROCESSOR-DEPENDENT.!

Page 378: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

19-8 47 A2 15UL Rev02

19.8 ENDPACKAGE STATEMENT

[ NEW ANSI77 [

The form of an ENDPACKAGE statement is:

ENDPACKAGE

An ENDPACKAGE is written only in columns 7 through 255 of an initial line. AnENDPACKAGE statement must not be continued.No other statement in a package unit may have an initial line that appears to be anENDPACKAGE statement.

The last line of every package unit must be an ENDPACKAGE statement.

].NEW ANSI77. ]

Page 379: FORTRAN 77 Reference Manual - Bull

47 A2 15UL Rev02 20-1

20. Compile Time Directives

[ NEW ANSI77 [

Compile time directives are non-standard statements that are merged with theFORTRAN statements, either to include source text, or for the purpose of listingpresentation, in which case they have no effect on the produced object code.

20.1 INCLUDE STATEMENT

The form of an INCLUDE statement is as follows:

?INCLUDE (source_member_name)

The source_member_name is the name of a member that belongs to the input_library orone of the input_libraries. The following example program uses the INCLUDEstatement:

PROGRAM MYPROGC INSERT COMMON BLOCKS ?INCLUDE (MYCOMMONS) ... CALL SUB END SUBROUTINE SUB ?INCLUDE (MYCOMMONS) ... END

When an INCLUDE statements is encountered, it is replaced by the text to be inserted.If there is no member called source_member_name in the input_libraries, an erroroccurs.

The member whose text is to be inserted can itself contain INCLUDE statements. Themaximum number of nesting included texts is 10.

For more information about input libraries, see the subsection on SOURCE, INFILE,INLIB and INLIBn parameters in the Fortran 77 User's Guide.

Page 380: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

20-2 47 A2 15UL Rev02

20.2 PAGE STATEMENT

The form of a PAGE statement is:

?PAGE

The source line after a PAGE statement is printed at the top of a next page of the sourcelisting.

20.3 SKIPEND STATEMENT

The form of a SKIPEND statement is:

?SKIPEND

It is effective only when present in a PACKAGE unit. It causes source lines immediatelyfollowing subsequent END statements to be printed at the top of a next page of thesource listing, except if the END statement is immediately followed by an ENDPACKAGEstatement.

20.4 ERROR STATEMENT

The form of an ERROR statement is:

?ERROR (ERRNB = ern, SEV = sev)

where: ern is an error message identifier (a letter followed by 1 to 3 digits; for example:C351), and sev is an integer nonnegative constant. This directive changes the severity ofthe error message. It is only allowed if the initial severity is 1 (observe) or 2 (warning),and causes this severity to be decreased or increased. If the severity is decreased to 0,the error message disappears. If the severity is increased to 3, the error becomes aserious error, and the compile unit is not produced if this error occurs.

].NEW ANSI77. ]

Page 381: FORTRAN 77 Reference Manual - Bull

47 A2 15UL Rev02 A-1

A. Collating Sequence

The table below shows the collating sequence, in order of increasing value.

Page 382: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

A-2 47 A2 15UL Rev02

Table A-1. EBCDIC (DPS 7) Character Set (1/4)

GraphicH36

punchHexa-

decimalHexa-

decimalH36

punch

0001020304050607

08090A0B0C0D0E0F

1011121314151617

18191A1B1C1D1E1F

Graphic

2021222324252627

28292A2B2C2D2E2F

3031323334353637

38393A3B3C3D3E3F

12- 0- 1- 8-912- 1-912- 2-912- 3-912- 4-912- 5-912- 6-912- 7-9

12- 8-912- 1- 8-912- 2- 8-912- 3- 8-912- 4- 8-912- 5- 8-912- 6- 8-912- 7- 8-9

12- 11- 1- 8- 911- 1-911- 2-911- 3-911- 4-911- 5-911- 6-911- 7-9

11- 8-911- 1- 8-911- 2- 8-911- 3- 8-911- 4- 8-911- 5- 8-911- 6- 8-911- 7- 8-9

11- 0- 1- 8-90- 1- 90- 2- 90- 3- 90- 4- 90- 5- 90- 6- 90- 7- 9

0- 8- 90- 1- 8- 90- 2- 8- 90- 3- 8- 90- 4- 8- 90- 5- 8- 90- 6- 8- 90- 7- 8- 9

12- 11- 0- 1- 8- 91- 92- 93- 94- 95- 96- 97- 9

8- 91- 8- 92- 8- 93- 8- 94- 8- 95- 8- 96- 8- 97- 8- 9

Page 383: FORTRAN 77 Reference Manual - Bull

Collating Sequence

47 A2 15UL Rev02 A-3

Table A-1. EBCDIC (DPS 7) Character Set (2/4)

GraphicH36

punchHexa-

decimalHexa-

decimalH36

punchGraphic

4041424344454647

48494A4B4C4D4E4F

5051525354555657

58595A5B5C5D5E5F

no punches12-0-1-912-0-2-912-0-3-912-0-4-912-0-5-912-0-6-912-0-7-9

12-0-8-912-1-812-2-812-3-812-4-812-5-812-6-812-7-8

1212-11-1-912-11-2-912-11-3-912-11-4-912-11-5-912-11-6-912-11-7-9

12-11-8-911-1-811-2-811-3-811-4-811-5-811-6-811-7-8

6061626364656667

68696A6B6C6D6E6F

7071727374757677

78797A7B7C7D7E7F

space

c.<(+

&

!$*);

110-111-0-2-911-0-3-911-0-4-911-0-5-911-0-6-911-0-7-9

11-0-8-90-1-812-110-3-80-4-80-5-80-6-80-7-8

12-11-012-11-0-1-912-11-0-2-912-11-0-3-912-11-0-4-912-11-0-5-912-11-0-6-912-11-0-7-9

12-11-0-8-91-82-83-84-85-86-87-8

-/

,%_>?

':#

'="

Page 384: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

A-4 47 A2 15UL Rev02

Table A-1. EBCDIC (DPS 7) Character Set (3/4)

GraphicH36

punchHexa-

decimalHexa-

decimalH36

punchGraphic

8081828384858687

88898A8B8C8D8E8F

9091929394959697

98999A9B9C9D9E9F

11-0-1-811-0-111-0-211-0-311-0-411-0-511-0-611-0-7

11-0-811-0-911-0-2-811-0-3-811-0-4-811-0-5-811-0-6-811-0-7-8

12-11-0-1-812-11-0-112-11-0-212-11-0-312-11-0-412-11-0-512-11-0-612-11-0-7

12-11-0-812-11-0-912-11-0-2-812-11-0-3-812-11-0-4-812-11-0-5-812-11-0-6-812-11-0-7-8

A0A1A2A3A4A5A6A7

A8A9AAABACADAEAF

B0B1B2B3B4B5B6B7

B8B9BABBBCBDBEBF

-stuvwx

yz

abcdefg

hi

jklmnop

qr

12-0-1-812-0-112-0-212-0-312-0-412-0-512-0-612-0-7

12-0-812-0-912-0-2-812-0-3-812-0-4-812-0-5-812-0-6-812-0-7-8

12-11-1-812-11-112-11-212-11-312-11-412-11-512-11-612-11-7

12-11-812-11-912-11-2-812-11-3-812-11-4-812-11-5-812-11-6-812-11-7-8

Page 385: FORTRAN 77 Reference Manual - Bull

Collating Sequence

47 A2 15UL Rev02 A-5

Table A-1. EBCDIC (DPS 7) Character Set (4/4)

GraphicH36

punchHexa-

decimalHexa-

decimalH36

punchGraphic

C0C1C2C3C4C5C6C7

C8C9CACBCCCDCECF

D0D1D2D3D4D5D6D7

D8D9DADBDCDDDEDF

ABCDEFG

HI

JKLMNOP

QR

12-012-112-212-312-412-512-612-7

12-812-912-0-2-8-912-0-3-8-912-0-4-8-912-0-5-8-912-0-6-8-912-0-7-8-9

11-011-111-211-311-411-511-611-7

11-811-912-11-2-8-912-11-3-8-912-11-4-8-912-11-5-8-912-11-6-8-912-11-7-8-9

E0E1E2E3E4E5E6E7

E8E9EAEBECEDEEEF

F0F1F2F3F4F5F6F7

F8F9FAFBFCFDFEFF

0-2-811-0-1-90-20-30-40-50-60-7

0-80-911-0-2-8-911-0-3-8-911-0-4-8-911-0-5-8-911-0-6-8-911-0-7-8-9

01234567

8912-11-0-2-8-912-11-0-3-8-912-11-0-4-8-912-11-0-5-8-912-11-0-6-8-912-11-0-7-8-9

STUVWX

YZ

01234567

89

Page 386: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

A-6 47 A2 15UL Rev02

Page 387: FORTRAN 77 Reference Manual - Bull

47 A2 15UL Rev02 B-1

B. GCOS 1E FORTRAN: Modifications

GCOS 1E FORTRAN is included in DPS7 FORTRAN 77 except for the followingfeatures.

B.1 FEATURES NO LONGER SUPPORTED

The following features, flagged by the 1E compiler with observation or warningmessages, are no longer supported.

Multiple Assignments

Example: A = B = C

Please replace by: B = C A = B

Note that as "=" is an abbreviation for ".EQ." (see section B.2.4), the previous example isunderstood by the compiler as:

A = (B.EQ.C)

which may lead to a surprising error message if A is not logical; or to a very surprisingmessage if A, B, C are logical:

LOGICAL A, B, CA = B.EQ.C is not accepted, butA = B.EQV.C is accepted.

Release 1D Syntax of BACKSPACE, ENDFILE, REWIND, PARAMETER

Example: ENDFILE 10, ERR = 100

Please replace by: ENDFILE (10, ERR = 100)

Page 388: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

B-2 47 A2 15UL Rev02

Release 1D Syntax of CHARACTER

Example: CHARACTER T * 10(20,30)

Please replace by: CHARACTER T(20,30) * 10

Assigned Variables in Computed GOTO or Arithmetic IF

Example: ASSIGN 10 TO I GOTO (I,20,30) J

Please replace by: ASSIGN 10 TO I GOTO (5,20,30) J 5 GOTO I

Absent Label in Arithmetic IF

Example: IF (EXPR) 10, ,30

Please replace by: IF (EXPR) 10,20,30 20 CONTINUE

Character for Exponentiation

Example: A = B C

Please replace by: A = B ** C

GOTO Inside a DO Loop From the Outside (extended range DO)

Example: DO 20 I = 1, N GOTO 30 10 A = B 20 CONTINUE 30 B = 1 GOTO 10

Please replace by: DO 20 I = 1, N B = 1 A = B 20 CONTINUE

Intrinsic Functions Used with Their Specific Name

The following intrinsic functions are used with their specific name and with argumentswhose type does not correspond to the type of the specific name.

Example: A = DSIN (1.)

Please replace by: A = DSIN (1.DO)

Page 389: FORTRAN 77 Reference Manual - Bull

GCOS 1E FORTRAN: Modifications

47 A2 15UL Rev02 B-3

Intrinsic Functions Used with Their Generic or Specific Name

The following intrinsic functions are those used with their generic or specific name, witharguments of type integer, and for which ANSI77 accepts only real or complexarguments(See Table 15-1).

Example: A = SIN (1)

Please replace by: A = SIN (1.)

Page 390: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

B-4 47 A2 15UL Rev02

B.2 FEATURES SUPPORTED AND FLAGGED

The following features, supported by the 1E compiler, are still supported but flagged by awarning.

Hollerith Constants

• Hollerith Constants in Data Statements

Example 1: INTEGER I DATA I /4HABCD/

Hollerith initialization is supported (with warnings) only if I is of integer type. It issuggested that you change the type of I into character, and replace the hollerith constantby a character constant, as follows:

CHARACTER *4 I DATA I /'ABCD'/

This can require further modifications when using I.

Example 2: REAL R DATA R/4HABCD/

If, when you are changing the type into character, you receive a warning, you can alsochange the type of R to integer.

• Hollerith Constants in the CALL Statement or the Function Call

This case shows the difference between character constants and hollerith constants.

Example:

Given the following:

PROGRAM P CALL S (4HABCD) STOP END SUBROUTINE S(I) INTEGER I PRINT 10, I10 FORMAT (1Hb,A4) RETURN END

Page 391: FORTRAN 77 Reference Manual - Bull

GCOS 1E FORTRAN: Modifications

47 A2 15UL Rev02 B-5

You can replace it with the following:

PROGRAM P CALL S('ABCD') STOP END SUBROUTINE S(I) CHARACTER *4 I PRINT 10, I10 FORMAT (1Hb,A4) RETURN END

You must replace 4HABCD by 'ABCD' and replace INTEGER I by CHARACTER *4 I.This is because the character constants are passed by descriptor (refer to theFORTRAN 77 User's Guide ), and the called procedure may test the (passed) length ofthe character dummy argument.

Also, in the previous example, subroutine S can be modified to edit strings of differentlengths:

SUBROUTINE S(I) CHARACTER *(*) I PRINT *, I RETURN END

This example uses an assumed size character variable I printed with list directed editing.Conversely, hollerith constants are passed by address, as with 1E FORTRAN. This isbecause, in the initial example, the following program can call the subroutine S.

PROGRAM P2 INTEGER J DATA J/4HABCD/ CALL S(J) STOP END

In this example, P2 uses an integer actual argument passed by address. As a result, S,which has an integer dummy argument, must assume it is passed by address.

Note that if you accept the warning on hollerith, you can only transform P like P2, withoutchanging S.

.XOR. Operator

This is replaced by the following:

.NEQV.

Page 392: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

B-6 47 A2 15UL Rev02

ENCODE/DECODE Statements (of 1E FORTRAN)

Example: ENCODE (C,10) A,B

This is replaced by the following:

WRITE (C,10) A,B

<, >, <=, >=, = Relational Operators

This is replaced by the following:

.LT., .GT., .LE., .GE., .EQ.

IBM Syntax of Direct Access

Example: READ (UNIT'RECNB) A,B

This is replaced by the following:

READ (UNIT, REC=RECNB) A,B

Note that neither in the initial READ, nor in the replacing one, is there incrementation of aso called associated variable, specified by DEFINE FILE (see Appendix C, 2.9).

Page 393: FORTRAN 77 Reference Manual - Bull

GCOS 1E FORTRAN: Modifications

47 A2 15UL Rev02 B-7

B.3 FEATURES NOT SUPPORTED BY DPS7

The following features, which are supported by GCOS 1E FORTRAN without errormessage, are not supported by DPS7 FORTRAN. They serve other features, and affectyour programs as explained below.

GCOS 1E FORTRAN DPS7 FORTRAN- BTEST,ISHA,ISHC,ISHL are ServiceRoutines Functions

IBTEST,ISHA,ISHC,ISHL, are IntrinsicFunctions

This modification has generally no effect onyour programs, except in error cases if youspecify these functions in the INSTRINSICstatement- FRERR is a service routine function whichreturns the last error detected.

FRERR is an intrinsic function which returnsthe last error detected, with the errornumbers of GCOS 1E FORTRAN if possibleTo improve the speed of the I/Os, DPS7FORTRAN 77 uses different algorithms thanGCOS 1E FORTRAN, so the interpretationof error cases is sometimes different

- FRSWT, is a Service RoutineSubprogram.

IFRSWT,IFRTWT, are Intrinsic

- FRTSWT is a Service Routine function. The modification has been made forhomogeneity, toto suppress the notion ofService Routine, and use the ANSI 77 one ofIntrinsic function with a type integerSee Note 1 of this Appendix C.

- IAND,IOR,IXOR,ICOMPL are specificnames of Intrinsic functions

IAND,IOR,IXOR,ICOMPL are generic namesof Intrinsic functions.This modification has been made to allowthe compiler to perform in line generation ofIAND,IOR,IXOR, and ICOMPL.In any case,a generic name may not be passed as anargument of a CALL. This modification hasno effect on your programs. Refer to Table15-1, Note 30 (Table of Instrinsic Function)

- BCHNG,BCLR,RSET are ServiceRoutines Subprograms

IBCHNG,IBCLR,IBSET are generic namesof Intrinsic functions.The subprograms have been changed intointrinsic functions. This allows the compilerto perform in line generation of IBCHNG,IBCLR, IBSET which improves performanceof your programs. See Note 1.

- FRITME is a Service Routine Subprogram. IFRIM,KTOD,KFRTIM are Intrinsic functions.This modification was necessary becauseFRTIME had arguments of different type,depending on way used. As it was asubroutine, this resulted in compiler warning,even for correct use. Furthermore, IFRTIMand KTOD have been accelerated so thatthe measure is less disturbing.See Note 1.

Page 394: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

B-8 47 A2 15UL Rev02

The names of Service Routines have been changed in the following two cases:

• The service routine was a subprogram subroutine for GCOS 1E FORTRAN and is anintrinsic function for DPS7 FORTRAN 77.

• The service routine was a function subroutine for GCOS 1E FORTRAN but its typehas been changed for DPS7 FORTRAN 77.

NOTE: Because the semantics of these Service Routines has been changed, theirname change was essential. This allows you to keep your source programswithout modification, and add only the definition of the GCOS1E FORTRANsubroutines as external procedures. For example, if you have the following:

Example: CALL BSET (I,N)

You need only add the following subroutine to your executable program:

SUBROUTINE BSET (IX,IY) IX = IBSET (IX,IY) RETURN END

There is no loss of execution speed because BSET was a closed procedure forGCOS1E FORTRAN, whereas IBSET is an open procedure (in line generated) for DPS7FORTRAN 77.

To take advantage of the performance of DPS7 FORTRAN 77, replace: CALL BSET(I,N) by: I = IBSET (I,N)

LEVEL=GCOS 1E

A CALL statement containing one of the GCOS1E FORTRAN service routines BCHNG,BCLR, BSET, FRTIME is flagged by the compiler with a warning.

Page 395: FORTRAN 77 Reference Manual - Bull

47 A2 15UL Rev02 C-1

C. SIRIS 8 FORTRAN Features

C.1 DPS7 FORTRAN 77 FEATURES AND SIRIS 8 FORTRAN

These DPS7 FORTRAN 77 features are neither ANSI 77 nor GCOS 1E FORTRAN, butthey support or allow migration from SIRIS 8 FORTRAN.

Inclusions with the Same Syntax and Semantics

• Intrinsic Functions

CINT CDINT CSNGL CDBLE

The following functions are documented in the manual DPS7 GCOS MathematicalLibrary.

CTAN CDTAN CTANH CDTANH CACOSCDACOS CASIN CDASIN CCOSH CDCOSHCSINH CDSINH ATANH DATANH QATANHCATANH CATAN CDATAN.

LEVEL=SIRIS8

Support of format specifiers without length specification

• Continuation Lines

The Number of Continuation Lines have been extended from 19 to 100.

LEVEL=SIRIS8

The statements in the range of a DO loop are executed at least one time

Page 396: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

C-2 47 A2 15UL Rev02

Inclusions with the Same Semantic but with Syntax like ANSI 77

• Intrinsic function IPDUMP, for PDUMP

SIRIS 8 FORTRAN: CALL PDUMP (V1,V2,I)

DPS7 FORTRAN 77: J = IPDUMP (V1,V2,I)

LEVEL=SIRIS8

Adjustable Formats:

SIRIS 8 FORTRAN: FORMAT (NEN.N)

DPS7 FORTRAN 77: FORMAT (=E=.=)

Note that the symbol N has not been included, because it could conflict withthe B and BN specifiers of future standard ANSI 8X.

• BYTE = Specifier in READ/WRITE Statements, for READ/WRITE DISC

SIRIS 8 FORTRAN: WRITE DISC U, W, A, B

DPS7 FORTRAN 77: WRITE (UNIT=U, BYTE=4*W-3) A,B

Inclusions

The following inclusions are not equivalent to SIRIS 8 FORTRAN features, but facilitatemigration from SIRIS 8 FORTRAN.

• PROCL = specifier in READ/WRITE statement for BUFFER IN/OUT andENCODE/DECODE

a. SIRIS 8 FORTRAN CALL BUFFERIN (U, M, S, W, I, N)

The BUFFERIN subroutine may be defined as follows in DPS7 FORTRAN 77 (theI/O is synchronous and not asynchronous)

SUBROUTINE BUFFERIN (U, M, S, W, I, N) INTEGER U, M, S, W, I, N DIMENSION S(W) READ (U, IOSTAT=I, PROCL=N) S N = N/4 IF (I) 100,101,102 100 I = 4; RETURN 101 I = 2; RETURN 102 I = 3; RETURN END

Page 397: FORTRAN 77 Reference Manual - Bull

SIRIS 8 FORTRAN Features

47 A2 15UL Rev02 C-3

The following difficulties can remain with this subroutine:

• The calling program may require compilation with LEVEL=SIRIS 8, as thisoption ensures that local data is allocated in their order of declaration.

• There may be a linker warning if the type or structuring (array/scalar) of I in thecalling program is not the same as the call BUFFERIN. If all the calls aresimilar, you may change the definition of S in BUFFERIN.

• There may be compiler warnings if, in the same calling program, the actualargument for S is array for one call and scalar for another.

• There may be compiler severity 3 errors if, in the same calling program, theactual arguments for S are of a different type for several calls.

• To solve this, you can program a version of BUFFERIN (with an appropriatename) for each case.

b. Similarly, BUFFEROUT may be defined as follows:

SIRIS 8 FORTRAN: CALL BUFFEROUT (U, M, S, W, I, N) you must suppress theT of BUFFEROUT, as symbol names are limited to eight characters in DPS7FORTRAN 77, and define BUFFEROUT as follows (the I/O is synchronous and notasynchronous).

SUBROUTINE BUFFEROUT(U, M, S, W, I, N) INTEGER U, M, S, W, I, N DIMENSION (S(W) WRITE (U, IOSTAT=I, PROCL=N) S N=N/4 IF (I) 100,101,100 100 I = 3; RETURN 101 I = 2; RETURN END

Note that I is set by BUFFERCHECK in SIRIS 8 FORTRAN, but that by setting it inBUFFER IN/OUT, the call to BUFFERCHECK may be put into a comment.

c. SIRIS 8 FORTRAN: DECODE (C, F, V, N) A,B

The DPS7 FORTRAN 77 ENCODE/DECODE are based on ANSI 77 internalREAD/WRITE, which use a character array instead of V. Therefore there is nodirect translation without modification of your program.If the length C is a constant expression, the DECODE statement may be replacedby the following:

CHARACTER V1 (length of the buffer) *C EQUIVALENCE (V,V1) READ (V1, F, PROCL = N) A, B

If the format and list are such that DECODE produces only one record, theDECODE statement may be replaced by the following:

CHARACTER V1 * 1 EQUIVALENCE (V1, V) READ (V1 (1:1+C), F, PROCL=N) A,B

Page 398: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

C-4 47 A2 15UL Rev02

This must be compiled without the use of the SUBCK option, consequently a substring ofV1 may be greater than one character.

• PACKAGE, ENDPACKAGE Statements For Internal Subroutines

These statements have been added to give you better control of the DPS7 virtualmemory, and also to provide faster execution of CALL statements inside a package unit.

When a SIRIS 8 FORTRAN program is made of several internal subroutines, it issuggested that you transform it into a DPS7 FORTRAN 77 package unit.

SIRIS 8 FORTRAN: SUBROUTINE MAIN CALL LOCAL I = J RETURN SUBROUTINE LOCAL J = k RETURN END

DPS7 FORTRAN 77: PACKAGE MAIN SUBROUTINE MAIN COMMON J I = J RETURN END SUBROUTINE LOCAL COMMON J J = K RETURN END ENDPACKAGE

Note that for SIRIS 8 FORTRAN implicit declarations such as J are global to the wholeprogram unit, consequently J in MAIN and LOCAL represents the same datum. ForDPS7 FORTRAN 77, implicit declarations are local to each program unit of the packageunit, so J must be declared in a common block. The reason for this IMPLICIT declarationrule is that it allows separate compilation of program units for debugging, then groupingthem in a package unit without modification.

Page 399: FORTRAN 77 Reference Manual - Bull

SIRIS 8 FORTRAN Features

47 A2 15UL Rev02 C-5

C.2 NON-ANSI 77 FORTRAN 77 FEATURES

The following SIRIS 8 FORTRAN features are not ANSI 77 but can be translated intoDPS7 FORTRAN 77 by a format manipulation.

Logical IF With Several Statements

SIRIS 8 FORTRAN: IF(COND) I = 1; J = 2 I = 3

DPS7 FORTRAN 77: IF(COND) THEN; I = 1; J = 2; ENDIF I = 3

SIRIS 8 FORTRAN: IF(COND) I = 1; &J = 2 I = 3

DPS7 FORTRAN 77: IF(COND) THEN; I = 1; J = 2 ENDIF I = 3

Set and Test Sense Switches

SIRIS 8 FORTRAN: CALL SSWTCH(NUM, VAL)

DPS7 FORTRAN 77: I = IFRTWT (NUM); IF(I.EQ.0) THEN; VAL = 2; ELSE; VAL = 1;

SIRIS 8 FORTRAN: IF(SENSE SWITCH NUM) 10,20

DPS7 FORTRAN 77: IF(IFRWT (NUM).EQ.1) THEN GOTO 10 ELSE GOTO 20

Logical Exclusion

SIRIS 8 FORTRAN: .EOR.

DPS7 FORTRAN 77: .NEQV.

Conditional Compilation

SIRIS 8 FORTRAN: X in column 6

DPS7 FORTRAN 77: ** in columns 1, 2

Page 400: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

C-6 47 A2 15UL Rev02

Double Complex

SIRIS 8 FORTRAN: DOUBLE COMPLEX CD

DPS7 FORTRAN 77: COMPLEX DOUBLE PRECISION CD

Hexadecimal Constants

SIRIS 8 FORTRAN: DATA X/8Z4110 0000/

DPS7 FORTRAN 77: DATA X/'4110 0000'Z/

Local Entries

SIRIS 8 FORTRAN: SUBROUTINE S1 ENTRY S2 LOCAL ENTRY S3 END

DPS7 FORTRAN 77: PACKAGE S1 EXTROUTINE S2 SUBROUTINE S1 ENTRY S2 ENTRY S3 END ENDPACKAGE

DEFINE FILE Statement

SIRIS 8 FORTRAN: DEFINE FILE U (M, R, E, V)

DPS7 FORTRAN 77: OPEN(UNIT=U, MAXREC=M, RECL=R, FORM='FORMATTED')

Except that the associate variable is not available, so that the record number must beexplicitly incremented in a direct READ/WRITE.

INTEGER Statement With Hollerith Initialization

SIRIS 8 FORTRAN: INTEGER I/4HABCD/

DPS7 FORTRAN 77: INTEGER I DATA I/'ABCD'/

With DPS7 FORTRAN 77, only integer (or character) datum can be initially defined withcharacter constants.

Page 401: FORTRAN 77 Reference Manual - Bull

SIRIS 8 FORTRAN Features

47 A2 15UL Rev02 C-7

Hollerith Assignment of Integer Variables

SIRIS 8 FORTRAN: INTEGER I I = 4HABCD

DPS7 FORTRAN 77:

• In this case, use a character variable instead of an integer one:

CHARACTER *4 I I = 'ABCD'

• A temporary solution is to use the ISHA intrinsic function

INTEGER I I = ISHA ('ABCD',0)

Labels as Alternate Return in CALL

SIRIS 8 FORTRA N: PROGRAM P CALL S(I,10$) 10 CONTINUE END SUBROUTINE S(I,J) RETURN Jthis transfers control to label 10 in program P END

DPS7 FORTRAN 77: PROGRAM P CALL S(I,*10) 10 CONTINUE END SUBROUTINE S(I,*) RETURN 1 END

Page 402: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

C-8 47 A2 15UL Rev02

Page 403: FORTRAN 77 Reference Manual - Bull

47 A2 15UL Rev02 D-1

D. Values of the Iostat Specifier ofINPUT/OUTPUT Statements

Value / Text

1 INPUT MANTISSA FIELD IS TOO LONG (> 36 DIGITS).

2 NON NORMALIZED (PROBABLY NON INITIALIZED) REAL.

3 NON NORMALIZED (PROBABLY NON INITIALIZED) LOGICAL VARIABLE.

4 COMMA AFTER COMMA IN VARIABLE FORMAT.

5 SPECIFICATION DWD OR QND DOES NOT CORRESPOND TO THE TYPE OFTHE REAL VARIABLE.

6 IN LIST DIRECTED INPUT HEXADECIMAL CONSTANT IS GREATER THANTWICE VARIABLE LENGTH.

7 IN LIST DIRECTED CHARACTER STRING USED TO FILL A NON CHARACTERVARIABLE.

8 COMMA AFTER COMMA BETWEEN THE NAMELIST NAME AND THE FIRSTVARIABLE NAME IN NAMELIST INPUT.

9 HEXADECIMAL CONSTANT IS GREATER THAN TWICE VARIABLE LENGTH INNAMELIST INPUT.

10 CHARACTER STRING USED TO FILE A NON CHARACTER VARIABLE INNAMELIST INPUT.

11 INVALID FORMAT EDIT DESCRIPTOR FOR A SHORT INTEGER VARIABLE.

12 INVALID FORMAT EDIT DESCRIPTOR FOR AN INTEGER VARIABLE.

13 INVALID FORMAT EDIT DESCRIPTOR FOR A SIMPLE PRECISION REALVARIABLE.

14 INVALID FORMAT EDIT DESCRIPTOR FOR A DOUBLE PRECISION REALVARIABLE.

15 INVALID FORMAT EDIT DESCRIPTOR FOR A QUADRUPLE PRECISION REALVARIABLE.

Page 404: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

D-2 47 A2 15UL Rev02

16 INVALID FORMAT EDIT DESCRIPTOR FOR A SIMPLE PRECISION COMPLEXVARIABLE.

17 INVALID FORMAT EDIT DESCRIPTOR FOR A DOUBLE PRECISION COMPLEXVARIABLE.

18 INVALID FORMAT EDIT DESCRIPTOR FOR A CHARACTER VARIABLE.

19 INVALID FORMAT EDIT DESCRIPTOR FOR A SHORT LOGICAL VARIABLE.

20 INVALID FORMAT EDIT DESCRIPTOR FOR A LOGICAL VARIABLE.

21 INVALID FORMAT EDIT DESCRIPTOR FOR A SHORT INTEGER VARIABLE.

22 INVALID FORMAT EDIT DESCRIPTOR FOR AN INTEGER VARIABLE.

23 INVALID FORMAT EDIT DESCRIPTOR FOR A SIMPLE PRECISION REALVARIABLE.

24 INVALID FORMAT EDIT DESCRIPTOR FOR A DOUBLE PRECISION REALVARIABLE.

25 INVALID FORMAT EDIT DESCRIPTOR FOR A QUADRUPLE PRECISION REALVARIABLE.

26 INVALID FORMAT EDIT DESCRIPTOR FOR A SIMPLE PRECISION COMPLEXVARIABLE.

27 INVALIDTFORMAT EDIT DESCRIPTOR FOR A DOUBLE PRECISION COMPLEXVARIABLE.

28 INVALID FORMAT EDIT DESCRIPTOR FOR A CHARACTER VARIABLE.

29 INVALID FORMAT EDIT DESCRIPTOR FOR A SHORT LOGICAL VARIABLE.

30 INVALID FORMAT EDIT DESCRIPTOR FOR A LOGICAL VARIABLE.

31 PRINTED RECORD MAY BE UNREADABLE (TOO MANY INTERNAL QUOTESIN A CHARACTER STRING).

32 UNABLE TO PRINT ERROR MESSAGES ON ERROR FILE: THEY ARE SENT TOJOR.

33 MAXIMUM ERROR NUMBER REACHED.

201 INVALIDE DATA IN INPUT FIELD (REAL CONVERSION).

202 NO MANTISSA FOUND (ZERO ASSUMED).

203 NO DIGITS IN EXPONENT FIELD OF INPUT DATA.

204 INVALID EXPONENT FIELD IN INPUT DATA.

205 NUMBER OF SIGNIFICANT DIGITS IS > 255.

206 INPUT VALUE IS > MAXIMUM REPRESENTABLE VALUE (REALCONVERSION).

Page 405: FORTRAN 77 Reference Manual - Bull

Values of the Iostat Specifier of INPUT/OUTPUT Statements

47 A2 15UL Rev02 D-3

207 INPUT VALUE IS > MINIMUM REPRESENTABLE VALUE (REAL CONVERSION).

208 AN IO LIST ARGUMENT IS NOT ACCESSIBLE.

211 INPUT DATA VALUE IS > -2147483647 OR < - 2147483648 IN AN INTEGERCONVERSION.

212 INVALID DATA IN INPUT FIELD (INTEGER CONVERSION).

213 INPUT DATA VALUE IS < - 32368 OR > 32767 IN AN INTEGER CONVERSION.

215 INVALID DATA IN INPUT FIELD (LOGICAL CONVERSION).

218 IN ZW CONVERSION W IS > TWICE VARIABLE LENGTH.

219 INVALID DATA IN INPUT FIELD (HEXADECIMAL CONVERION) NOT: BLANK ISNOT AN HEXADECIMAL CHARACTER.

220 RECORD LENGTH IS TOO SHORT TO DECODE ZW FORMAT.

224 INVALID VALUE OF SCALE FACTOR DURING A REAL EDITION.

227 M IS GREATER THEN N IN A IW.M EDITION.

230 AN IO LIST ARGUMENT IS OUT OF SEGMENT BOUNDS OR NOTACCESSIBLE.

232 LENGTH OF CHARACTER STRING EMBEDDED IN QUOTES > 255.

233 N IS TOO BIG IN A 'NH' EDIT DESCRIPTOR OF A VARIABLE FORMAT.

234 N IS <= 0 IN A NH EDIT DESCRIPTOR OF A VARIABLE FORMAT.

237 FIRST NON BLANK CHARACTER OF VARIABLE FORMAT IS NOT (.

238 NO MATCH BETWEEN RIGHT AND LEFT PARENTHESIS IN VARIABLESFORMAT.

239 INVALID CHARACTER IN A VARIABLE FORMAT.

240 INVALID PLACE OF A '.' IN A VARIABLE FORMAT.

241 NO FIELD WIDTH BEFORE A 'H' 'X' 'P' IN A VARIABLE FORMAT.

242 INVALID PLACE OF SIGN IN A VARIABLE FORMAT.

243 INVALID POSITION OF A QUOTE IN VARIABLE FORMAT.

244 INVALID POSITION OF A RIGHT PARENTHESES IN VARIABLE FORMAT.

245 INVALID POSITION OF A DIGIT IN VARIABLE FORMAT.

246 INVALID POSITION OF A LETTER IN VARIABLE FORMAT.

247 INVALID POSITION OF A LEFT PARENTHESIS IN VARIABLE FORMAT.

Page 406: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

D-4 47 A2 15UL Rev02

248 INVALID POSITION OF A ',' A '/' OR A ':' OR A '=' IN A VARIABLE FORMAT.

249 SIGNED INTEGER CONSTANT IS ONLY ALLOWED WITH P EDITDESCRIPTOR.

250 MORE THAN 50 EMBEDDED PARENTHESIS IN VARIABLE FORMAT.

251 FORMAT IS TOO LONG TO BE SCANNED.

252 W OR E FIELD WIDTH IS <= 0 OR >= 65000 IN A VARIABLE FORMAT.

253 NO MATCH BETWEEN QUOTES INSIDE A VARIABLE FORMAT.

254 APOSTROPHE EDITING IS MEANINGLESS IF STRING IS EMPTY.

255 INVALID POSITION OF 'E' IN VARIABLE FORMAT (NB DW.DEE AND QW.DEEARE FORBIDDEN).

256 WARNING THE GIVEN VARIABLE FORMAT IS PARTIALLY OUT OF SEGMENTBOUNDS.

257 IN FORMATS WITH W.D LENGTH DESCRIPTOR .D IS OPTIONNAL ONLY IFLEVEL=SIRIS.

258 THE GIVEN VARIABLE FORMAT IS NOT ACESSIBLE (PROBABLY OUT OFSEGMENT BOUNDS).

259 IN FORMAT EDIT DESCRIPTOR NX N MUST BE UNSIGNED, USE TL EDITDESCRIPTOR.

262 INVALID POSITION FOR A STRING OF CHARACTERS OR FOR ANHEXADECIMAL CONSTANT IN LIST DIRECTED OR NAMELIST.

263 HEXADECIMAL CONSTANTS OF LENGTH ZERO ARE MEANINGLESS (NILVALUE IS ASSUMED).

264 STRINGS EMBEDDED IN QUOTES MAY NOT BE EMPTY IN LIST DIRECTEDINPUT.

265 A COMPLEX CONSTANT SHOULD BEGIN WITH A LEFT PARENTHESIS INLIST DIRECTED INPUT.

266 A CHARACTER STRING MUST BEGIN WITH A QUOTATION MARK IN LISTDIRECTED INPUT.

267 INVALID CHARACTER IN INPUT.

268 INVALID POSITION OF AN ALPHANUMERICAL CONSTANT OR MISSINGSEPARATOR IN A LIST DIRECTED INPUT.

269 INVALID POSITION OF A SEPARATOR IN LIST DIRECTED INPUT(PARENTHESIS COMMA STAR OR SLASH).

270 INPUT DATA NOT EXHAUSTED AT THE END OF LIST DIRECTED I/O ORINVALID CHARACTER IN INPUT.

Page 407: FORTRAN 77 Reference Manual - Bull

Values of the Iostat Specifier of INPUT/OUTPUT Statements

47 A2 15UL Rev02 D-5

271 REPEAT FACTOR TOO BIG OR INPUT DATA NOT EXHAUSTED AT THE ENDOF LIST DIRECTED I/O.

272 REPEAT FACTOR MUST BE AN UNSIGNED INTEGER IN LIST DIRECTED I/O.

273 INVALID DATA IN INPUT FIELD OF LIST DIRECTED I/O.

276 A COMPLEX CONSTANT SHOULD BEGIN WITH A LEFT PARENTHESIS INNAMELIST INPUT.

277 A CHARACTER STRING MUST BEGIN WITH A QUOTATION MARK INNAMELIST INPUT.

278 INVALID CHARACTER IN A NAMELIST INPUT.

279 INVALID POSITION OF AN ALPHANUMERICAL CONSTANT IN NAMELISTINPUT.

280 VARIABLE IN INPUT STATEMENT NOT DECLARED IN NAMELISTSTATEMENT.

281 INVALID POSITION OF A SEPARATOR IN NAMELIST INPUT ("(" OR ", " OR " *"OR "$" OR "=").

282 'S' or '&' IS NOT THE LAST NON BLANK CHARACTER IN NAMELIST INPUT.

283 NAMELIST INPUT DOES NOT BEGIN WITH REQUESTED NAMELIST NAME.

284 SUBSCRIPTED VARIABLE IN NAMELIST INPUT NOT DECLARED AS ARRAY.

285 NUMBER OF DIMENSIONS OF ARRAY IN NAMELIST INPUT NOT CONSISTENTWITH THOSE DECLARED FOR ARRAY.

286 AN INDEX OF ARRAY IN NAMELIST INPUT INCONSISTENT WITH DECLAREDBOUNDS.

287 INVALID DATA IN INPUT FIELD OF NAMELIST.

288 ATTEMPT TO CONVERT A VARIABE OUT OF ARRAY BOUNDS.

289 REPEAT FACTOR MUST BE AN UNSIGNED INTEGER IN NAMELIST INPUT.

290 STRINGS EMBEDDED IN QUOTES MAY NOT BE EMPTY IN NAMELIST INPUT.

291 PARTIALLY DEFINED VARIABLE IN NAMELIST INPUT.

292 VARIABLE UNDECLARED IN NAMELIST STATEMENT OR ATTEMPT TOCONVERT A VARIABLE OUTSIDE ARRAY BOUNDS.

297 UNABLE TO PRINT A LIST DIRECTED OR NAMELIST OUTPUT: RECORDLENGTH TOO SHORT.

298 CHARACTER STRING LENGTH TO PRINT IS > 255 IN LIST DIRECTED ORNAMELIST OUTPUT.

304 PART OF INTERNAL FILE RECORD IS INACCESSIBLE: NO VARIABLE WILL BEPROCESSED.

Page 408: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

D-6 47 A2 15UL Rev02

306 A PARAMETER OF I/O STATEMENT IS INACCESSIBLE.

307 INTERNAL RECORD IS PARTIALLY IN SEGMENT BOUNDS: IT IS RESTRICTEDTO SIGNIFICANT PART.

308 INTERNAL RECORD IS INACESSIBLE (PROBABLY OUT OF SEGMENTBOUNDS).

311 FORMAT GW IS ALLOWED FOR REAL CONVERSIONS ONLY UNDERLEVEL=SIRIS.

312 FORMAT EDIT DESCRIPTORS WITHOUT W LENGTH DEFINITION AREALLOWED ONLY UNDER LEVEL=SIRIS.

313 RECORD LENGTH TOO LONG (> 65000).

314 INTERNAL FILE RECORD LENGTH IS TOO SHORT.

315 NH EDIT DESCRIPTOR IS FORBIDDEN FOR READ STATEMENTS.

316 WHEN I/O LIST IS NOT EMPTY A CONVERSION MUST BE SPECIFIED IN THEGIVEN FORMAT.

317 INCONSITENT FORMAT EDIT DESCRIPTOR DURING AN INTERNAL WRITEOR READ.

318 INCONSITENT FORMAT EDIT DESCRIPTOR NOT ALLOWED FOR EXTERNALFILES IF RECORD LENGTH IS > 1024.

319 RECORD LENGTH IS TOO SMALL TO DECODE THE INPUT LIST.

320 IT IS ATTEMPT TO READ OR EDIT A COMPLEX VARIABLE WITH A OR RFORMAT.

321 IT IS MEANINGLESS TO READ AN EXPRESSION.

322 IMPLEMENTATION RESTRICTION: RECORD LENGTH TOO SHORT ISFORBIDDEN WHEN W LENGTH OF CORRESPONDING EDIT.

324 '=' CORRESPONDS TO A VARIABLE WHICH IS <0 OR > 65000 IN ANADJUSTABLE FORMAT EDIT DESCRIPTOR.

325 '=' CORRESPONDS TO A VARIABLE WICH IS NEITHER INTEGER NOR REALIN AN ADJUSTABLE FORMAT.

326 '=' FIELD OF AN ADJUSTABLE FORMAT IS INACCESSIBLE.

327 AN '=' CORRESPONDS TO A VARIABLE WHICH IS EITHER NOT NORMALIZEDOR > 2**31.

328 '=' FIELD OF ADJUSTABLE FORMAT MAY NOT BE NULL IF DEFINING A W ORE LENGTH.

329 IT IS ATTEMPT TO PRINT OR READ A SUBSTRING OF ZERO LENGTH.

341 ERRONEOUS FILE LITERAL: EMPTY STRING OR INVALID PARAMETER.

Page 409: FORTRAN 77 Reference Manual - Bull

Values of the Iostat Specifier of INPUT/OUTPUT Statements

47 A2 15UL Rev02 D-7

342 ERRONEOUS FILE LITERAL: INVALID CHARACTER.

343 ERRONEOUS FILE LITERAL: SITE LENGTH > 8.

344 ERRONEOUS FILE LITERAL: EFN LENGTH > 44

345 ERRONEOUS FILE LITERAL: SUBFILE LENGTH > 31.

346 ERRONEOUS FILE LITERAL: MEDIA LIST LONGER THAN 10.

347 ERRONEOUS FILE LITERAL: MEDIA NAME LONGER THAN 6.

348 ERRONEOUS FILE LITERAL: INVALID DEVICE CLASS.

349 ERRONEOUS FILE LITERAL: LOGICAL VOLUME NAME LONGER THAN 33.

350 ERRONEOUS FILE LITERAL: UNKNOWN ATTRIBUTE.

351 ERRONEOUS FILE LITERAL: ATTRIBUTE NOT ALLOWED.

352 ERRONEOUS FILE LITERAL: WRONG VALUE FOR AN ARGUMENT.

353 ERRONEOUS FILE LITERAL: REMOTE FILE NAME LONGER THAN 255 OR = 0.

354 ERRONEOUS FILE LITERAL: INPUT ENCLOSURE NAME LONGER THAN 16.

355 ERRONEOUS FILE LITERAL: UNKNOWN OPTION NAME.

356 ERRONEOUS FILE LITERAL: WORKING DIRECTORY MAY BE USED ONLYWITH CATALOGED FILES.

357 ERRONEOUS FILE LITERAL: WORKING DIRECTORY IS EMPTY.

358 ERRONEOUS FILE LITERAL: CONFLICTING ATTRIBUTES.

363 THIS RUN-TIME VERSION UNDER GCOS 1E IS OBSOLETE NOW; PLEASECONTACT MAINTENANCE.

364 THIS FUNCTIONALITY IS SEPARATELY UNBUNDLED; PLEASE CONTACTMAINTENANCE.

365 A LARGE SEGMENT HAS BEEN CREATED TO RECEIVE THE FORTRANRECORD.

366 NO RESUMPTION OF EXECUTION AFTER A PAUSE STATEMENT.

367 THIS FILE IS CREATED ON A RESIDENT VOLUME.

368 THE DATA MANAGEMENT CANNOT RETURN FILE AND VOLUMEIDENTIFICATION (H_RTVLID).

369 THE VALUE GIVEN TO THE PAD= SPECIFIER IS NOT SUITABLE.

370 THE VALUE GIVEN TO THE INCRSIZE= SPECIFIER IS NOT SUITABLE.

372 THE VALUE GIVEN TO THE BLOCKL= SPECIFIER IS NOT SUITABLE.

Page 410: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

D-8 47 A2 15UL Rev02

373 THE VALUE GIVEN TO THE NUMBUF= SPECIFIER IS NOT SUITABLE.

374 THE VALUE GIVEN TO THE FILEFORM= SPECIFIER IS NOT SUITABLE.

375 ON A SEQUENTIAL ORGANIZATION FILE, DIRECT ACCESS WRITE CAN ONLYBE DONE IF RECORD HAS JUST BEEN

376 A BLANK CHARACTER HAS BEEN INSERTED IN A ZERO LENGTH RECORD.

377 THE DATA MANAGEMENT CANNOT WRITE A DIRECT ACCESS RECORD(H_PUT & H_PUTX).

378 UNDUE EVENT OCCURED WHILE WRITING A RECORD.

379 UNDUE EVENT OCCURED WHILE READING A RECORD.

380 SKIP CHARACTER OTHER THAN " ", "0", "-", "+", "1".

381 THE DELIM= SPECIFIER LENGTH IS TOO SHORT.

382 THE RECFORM= SPECIFIER LENGTH IS TOO SHORT.

383 THE PRINT= SPECIFIER LENGTH IS TOO SHORT.

384 THE SPANNING= SPECIFIER LENGTH IS TOO SHORT.

385 THE DELIM= SPECIFIER MAY BE PRESENT ONLY FOR A SEQUENTIALFORMATTED FILE.

386 THE VALUE GIVEN TO THE SPANNING= SPECIFIER IS NOT SUITABLE.

387 THE VALUE GIVEN TO THE PRINT= SPECIFIER IS NOT SUITABLE.

388 TOO LONG PROMPT= SPECIFIER.

389 A SHORT INTEGER CANNOT RECEIVE THE NUMBER, RECL OR NEXTRECRESULT.

390 SPANNING= YES AND ACCESS= DIRECT MAY NOT BE SPECIFIEDTOGETHER.

391 THE RECORD TO BE WRITTEN IS LONGER THAN THE RECORD LENGTH.

392 THE VALUE GIVEN TO THE DELIM= SPECIFIER IS NOT SUITABLE.

393 THE RECFORM= SPECIFIER, WHEN PRESENT FOR AN EXISTING FILE,SHOULD HAVE THE VALUE GIVEN AT FILE CREAT

394 INCONSISTENT SPANING MARKS.

395 THIS FILE CONTAINS SPANNED RECORDS.

396 A (32) "9" END OF FILE MARK HAS BEEN ENCOUNTERED.

397 A (32) "FE" < END OF FILE MARK HAS BEEN ENCOUNTERED.

Page 411: FORTRAN 77 Reference Manual - Bull

Values of the Iostat Specifier of INPUT/OUTPUT Statements

47 A2 15UL Rev02 D-9

398 TIME VALUE GIVEN TO THE TRANSPARENT= SPECIFIER IS NOT SUITABLE.

399 RECORD NUMBER OUT OF FILE BOUND.

400 END OF FILE IS REACHED.

401 DIRECT ACCESS FILE RECORD HAS NOT PREVIOUSLY BEEN WRITTEN.

402 READING A DUMMY FILE IS NOT ALLOWED.

403 READING AFTER AN ENDFILE RECORD IS NOT ALLOWED.

404 MIXING FORMATTED AND UNFORMATTED RECORDS IS NOT ALLOWED.

405 THE RECORD LENGTH MAY NOT EXCEED THE RECORD SIZE.

406 NOT ALLOWED ON A UNIT CONNECTED FOR SEQUENTIAL ACCESS.

407 RECORD SPECIFIER VALUE MUST BE POSITIVE.

408 ALL RECORDS OF THE FILE MUST HAVE THE SAME LENGTH.

409 NOT ALLOWED ON A UNIT CONNECTED FOR DIRECT ACCESS.

410 NOT ALLOWED ON THE FILE CONNECTED TO THIS UNIT.

411 UNIT IDENTIFIER, IF NOT ASTERISK, MUST BE POSITIVE OR NULL.

412 THE LENGTH OF THE FILE-NAME EXCEEDS THE MAXIMUM ALLOWED.

413 STATUS=SCRATCH MAY NOT BE SPECIFIED WITH A NAMED FILE.

414 THE VALUE GIVEN TO THE STATUS= SPECIFIER IS NOT SUITABLE.

415 THE VALUE GIVEN TO THE ACCESS= SPECIFIER IS NOT SUITABLE.

416 THE VALUE GIVEN TO THE FORM= SPECIFIER IS NOT SUITABLE.

417 THE VALUE GIVEN TO THE BLANK= SPECIFIER IS NOT SUITABLE.

418 THE VALUE GIVEN TO THE RECFORM= SPECIFIER IS NOT SUITABLE.

419 THE VALUE GIVEN TO THE RECL= SPECIFIER IS NOT SUITABLE.

420 THE FILE= SPECIFIER IS REQUIRED WHEN STATUS=NEW OR STATUS=OLDIS SPECIFIED.

421 READ AFTER WRITE IS NOT ALLOWED.

422 READ AFTER ENDFILE IS NOT ALLOWED.

423 WRITE OR ENDFILE AFTER AN ENDFILE RECORD IS NOT ALLOWED.

424 IF STATUS=OLD IS SPECIFIED, THE FILE MUST EXIST.

425 IF STATUS=NEW IS SPECIFIED, THE FILE MAY NOT EXIST.

Page 412: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

D-10 47 A2 15UL Rev02

426 THE UNIT IS NOT CONNECTED: USE JCL ASSIGN OR FORTRAN OPENSTATEMENT.

427 THE BLANK= SPECIFIER MAY NOT BE PRESENT FOR AN UNFORMATTEDFILE.

428 JCL ASSIGN H_RD FOR SYST1 INPUT UNIT IS MANDATORY IN BATCH MODE.

429 STATUS=KEEP MAY NOT BE SPECIFIED FOR A SCRATCH FILE.

430 SYNTAX ERROR ON FILE LETERAL.

431 INVALID FILE NAME: NEITHER IFN, NOR EFN, NOR SPECIAL.

432 IFN FILE NAME MUST BE 1 TO 3 NON BLANK CHARACTERS.

433 THE VALUE GIVEN TO THE MESSAGE= SPECIFIER IS NOT SUITABLE.

434 THE VALUE GIVEN TO THE ABNORMALEND= SPECIFIER IS NOT SUITABLE.

435 THE VALUE GIVEN TO THE NORMALEND= SPECIFIER IS NOT SUITABLE.

436 THE VALUE GIVEN TO THE GCOSACCESS= SPECIFIER IS NOT SUITABLE.

437 THE VALUE GIVEN TO THE SHARE= SPECIFIER IS NOT SUITABLE.

438 ONLY BLANK= AND DELIM= SPACIFIERS MAY BE UPDATED ON ACONNECTED UNITS.

439 IFN OPEN FILE NAME MAY NOT BE A PRCONNECTABLE ONE.

440 OPEN BY IFN REQUIRES A JCL ASSIGN STATEMENT.

441 THE MAXREC= SPECIFIER AY NOT BE PRESENT IF THE FILE NAME IS ANINTERNAL FILE NAME OR A SPECIAL

442 FAILURE OF THE TERMINAL ACCESS METHOD H_TN PRIMITIVE.

443 CONFLICT CAT/NBVOL WITHIN FILE LITERAL.

444 CONFLICT RES/NBVOL WITHIN FILE LITERAL.

445 THE SIZE= AND INCRSIZE= SPECIFIERS MAY NOT BE PRESENT IFACCESS=DIRECT; USE MAXREC= SPECIFIER.

446 ACCESS=DIRECT AND RECFORM=VARIABLE MAY NOB BE SPECIFIEDTOGETHER.

447 THE RECL= SPECIFIER IS MANDATORY IF ACCESS=DIRECT.

448 DEFINE FILE REQUIRED BEFORE FIND.

449 STATUS=NEW OR OLD IS MEANIGLESS FOR AN IOF OR AN OPERATORFILE.

Page 413: FORTRAN 77 Reference Manual - Bull

Values of the Iostat Specifier of INPUT/OUTPUT Statements

47 A2 15UL Rev02 D-11

450 UNIT > 9999999 CANNOT BE CONNECTED.

451 INTERNAL ERROR; PLEASE CONTACT MAINTENANCE(PA_CONNECTED_PTR).

452 INTERNAL ERROR; PLEASE CONTACT MAINTENANCE(PA_DISCONNECTED_PTR).

453 SEGMENT SIZE OVERFLOW: FORTRAN_FD CANNOT BE BUILT.

454 USING UNIT NUMBERS > 200 IS NOT RECOMMENDED.

455 SEGMENT SIZE OVERFLOW: TOO MANY UNITS > 200.

456 THIS FILE CANNOT BE CONNECTED FOR DIRECT ACCESS.

457 READING A PRECONNECTED NEW FILE IS NOT ALLOWED.

458 BACKSPACING A FILE THAT IS CONNECTED BUT DOES NOT EXIST IS NOTALLOWED.

459 THE RECL= SPECIFIER, WHEN PRESENT FOR AN EXISTING FILE, SHOULDHAVE THE VALUE GIVEN AT FILE CREAT

460 SEGMENT SIZE OVERFLOW: TOO LARGE FORTRAN RECORD SIZE.

461 THE NAME= SPECIFIER LENGTH IS INSUFFICIENT.

462 THE ACCESS= SPECIFIER LENGTH IS INSUFFICIENT.

463 THE SEQUENTIAL= SPECIFIER LENGTH IS INSUFFICIENT.

464 THE DIRECT= SPECIFIER LENGTH IS INSUFFICIENT.

465 THE FORM= SPECIFIER LENGTH IS INSUFFICIENT.

466 THE FORMATTED= SPECIFIER LENGTH IS INSUFFICIENT.

467 THE UNFORMATTED= SPECIFIER LENGTH IS INSUFFICIENT.

468 THE BLANK= SPECIFIER LENGTH IS INSUFFICIENT.

469 THE DATA MANAGEMENT CANNOT RE-OPEN THE FILE (H_OPENPMD=INPUT).

470 THE DATA MANAGEMENT CANNOT RE-OPEN THE FILE (H_OPENPMD=OUTPUT).

471 THE DATA MANAGEMENT CANNOT WRITE THE SSF CONTROL RECORD 101(H_PUT).

472 THE DATA MANAGEMENT CANNOT RE-OPEN THE FILE (H_OPENPMD=APPEND).

473 THE DATA MANAGEMENT CANNOT RE-OPEN THE FILE (H_OPENPMD=UPDATE).

Page 414: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

D-12 47 A2 15UL Rev02

474 THE DATA MANAGEMENT CANNOT CLOSE THE FILE (H_CLOSE).

475 THE DATA MANAGEMENT CANNOT POINT TO A FILE ADDRESS (H_POINT).

476 THE DATA MANAGEMENT CANNOT NOTE A FILE ADDRESS (H_NOTE).

477 THE DATA MANAGEMENT CANNOT READ A RECORD (H_GET).

478 THE DATA MANAGEMENT CANNOT WRITE A RECORD (H_PUT).

479 THE DATA MANAGEMENT CANNOT DELETE A FILE DECLARATIONSTRUCTURE (H_DLFD).

480 THE DATA MANAGEMENT CANNOT RETURN THE FILE DECLARATIONPARAMETERS (H_RFLDEF SOURCE).

481 THE DATA MANAGEMENT CANNOT RETURN THE FILE DECLARATIONPARAMETERS (H_RFLDEF OVERRIDE).

482 THE DATA MANAGEMENT CANNOT OVERRIDE THE FILE DECLARATIONPARAMETERS (H_DFLDEF).

483 THE DATA MANAGEMENT CANNOT CREATE A FILE DECLARATIONSTRUCTURE (H_CRFD).

484 THE DATA MANAGEMENT CANNOT OPEN THE FILE (FIRST H_OPENPMD=OUTPUT).

485 THE DATA MANAGEMENT CANNOT ASSIGH THE FILE (H_DFLASG).

486 THE DATA MANAGEMENT CANNOT ALLOCATE THE FILE (H_DYNAL).

487 THE DATA MANAGEMENT CANNOT DEASSIGH THE FILE (H_DDASG).

488 A FUNCTION DOING I/O'S MAY NOT BE SPECIFIED IN AN IOLIST (USEFUNCTION LSETK TO BYPASS THE CHECKING

489 THIS FILE IFN IS PRESENTLY CONNECTED TO A DIFFERENT UNIT.

490 THE VOLUME IS NOT MOUNTED.

491 THE FILE IS BUSY.

492 YOU MAY NOT USE THIS FILE LITERAL FOR A FILE ASSIGNED EITHER BYJCL OR WITH A DIFFERENT FILE LITERAL

493 THE FILE IS NOT ALLOCATED: USE PREALLOC OR ALLOCATE JCLSTATEMENTS.

494 THE FILE CANNOT BE PHYSICALLY SCRATCHED.

495 IF ACCESS=SEQUENTIAL IS SPECIFIED, THE MAXREC= SPECIFIER MAYNOT BE PRESENT.

496 THE VALUE GIVEN TO THE MAXREC= SPECIFIER IS NOT SUITABLE.

Page 415: FORTRAN 77 Reference Manual - Bull

Values of the Iostat Specifier of INPUT/OUTPUT Statements

47 A2 15UL Rev02 D-13

497 IF ACCESS=DIRECT IS SPECIFIED, THE PRINT= SPECIFIER MAY NOT BEPRESENT.

498 THE MAXREC= SPECIFIER MAY NOT BE GIVEN FOR AN EXISTING FILE.

499 THE DATA MANAGEMENT CANNOT ALLOCATE THE FILE (H_PREALLOC).

500 FOR A SCRATCH FILE, SHARE, GCOSACCESS, NORMALEND ANDABNORMALEND= SPECIFIERS MAY NOT BE PRESENT.

501 FOR A TERMINAL FILE, RECL, BLOCKL, NUMBUF, SIZE, INCRSIZE, MAXRECAND FILEFORM= SPECIFIERS MAY NOT

502 FOR A TERMINAL FILE, SHARE, GCOSACCESS, NORMALEND ANDABNORMALEND= SPECIFIERS MAY NOT BE PRESENT.

503 MESSAGE, TRANSPARENT AND PROMPT= SPECIFIERS MAY BE PRESENTONLY IF THE DEVICE-CLASS OF THE FILE-LI

504 FOR A TERMINAL FILE, ACCESS=DIRECT MAY NOT BE SPECIFIED.

505 FOR A TERMINAL FILE, RECFORM=FIXED MAY NOT BE SPECIFIED.

506 RECFORM=VARIABLE AND PAD=YES MAY NOT BE SPECIFIED TOGETHER.

507 TRANSPARENT=YES AND PRINT=YES MAY NOT BE SPECIFIED TOGETHER.

508 TRANSPARENT=YES AND SPANNING=YES MAY NOT BE SPECIFIEDTOGETHER.

509 TRANSPARENT=YES AND PROMPT=YES MAY NOT BE SPECIFIEDTOGETHER.

510 THE FILEFORM= SPECIFIER, THEN PRESENT FOR AN EXISTING FILE,SHOULD HAVE THE VALUE GIVEN AT FILE CR

511 RECFORM=FIXED MAY NOT BE SPECIFIED FOR A SUBFILE OF A LIBRARY.

512 RECL, BLOCKL AND MAXREC= SPECIFIERS MAY NOT BE RPESENT FOR ASUBFILE OF A LIBRARY.

513 FILEFORM=UFAS MAY NOT BE SPECIFIED FOR A SUBFILE OF A LIBRARY.

514 THE MAXREC= SPECIFIER MAY NOT BE PRESENT IF STATUS=OLD.

Page 416: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

D-14 47 A2 15UL Rev02

Page 417: FORTRAN 77 Reference Manual - Bull

47 A2 15UL Rev02 i-1

Index

A

accessdirect, file 12-9sequential, file 12-8

actual array declarator 5-3arguments

actual 15-27arrays 15-30association 15-28asterisks 15-33character length 15-29dummy 2-7, 15-26general definition 15-26Hollerith constant 15-27procedures 15-32variables 15-29

arithmeticassignment statement 10-1constant 4-3constant expression 6-5expression 6-1expression evaluation 6-5, 6-24operands 6-3operator 6-1

ARITHMETIC IF statements 11-5arithmetic relational expressions 6-13arrays

actual 5-10adjustable 5-10declarator 5-2declarator, actual 5-3declarator, constant 5-3declarator, dimension 5-2declarator, dummy 5-3dimensions 5-4dummy 5-10dummy arguments 15-30element 5-1element name 5-6element ordering 5-5

elements 2-6general definition 2-6, 5-1names 5-11properties 5-4size 5-5storage sequence 5-5

ASSIGN statement 10-6ASSIGNED GOTO statement 11-4assignment statements

arithmetic 10-1character 10-8label 10-6logical 10-4

association 2-12automatic packaging 19-2

B

BACKSPACE statement 12-59basic real constant 4-5blank character 3-3BLOCK DATA statement 16-1block data subprogram 2-4BLOCK IF statements 11-7byte specifier 12-20

C

CALL statement 15-18character

assignment statement 10-8blank 3-3collating sequence 3-3, A-1constant 4-11constant expressions 6-12expressions 6-11Fortran setcomment line 3-1line 3-4primaries 6-12

Page 418: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

i-2 47 A2 15UL Rev02

special 3-2substring 5-12

character expressions 6-26character operator 6-11character relational expressions 6-14CHARACTER statement 8-11, 8-14character storage unit 2-11character type 4-11CLOSE statement 12-49collating sequence 3-3, A-1comment line 2-4, 3-4common blocks 18-4

general definition 15-26COMMON statement 8-6complex constant 4-9complex double precision

constant 4-16complex double precision expression 6-5COMPLEX DOUBLE PRECISIONstatement 8-14complex double precision type 4-16complex expression 6-5COMPLEX statement 8-14complex type 4-9COMPUTED GOTO statements 11-3constant

arithmetic 4-3basic real 4-5character 4-11complex 4-9complex double precision 4-16double precision 4-7hexadecimal 4-16Hollerith 4-18, 9-6, C-1integer 4-4logical 4-10quadruple precision 4-14real 4-5

constant array declarator 5-3constant expressions 6-27continuation line 2-3, 3-5CONTINUE statements 11-17control information list 12-26control statements 11-1control transfer 3-11

D

datatransfer 12-32transfer I/O 12-27, 12-30

data statement 9-1data type

statement 8-10data types

name 4-1rules 4-2

DECODE statement B-6definition status 2-9dimension

adjustable 5-10declarator 5-2size 5-4

dimension bound expressions 5-2DIMENSION statement 8-2dlist 12-29DO statements 11-12double precision expression 6-5DOUBLE PRECISION statement 8-14double precision type 4-7dummy arguments 2-7dummy array declarator 5-3dummy procedures 15-2

E

edit descriptors 13-4editing

A 13-28apostrophe 13-15BN, BZ 13-20colon 13-17complex 13-27E, D 13-22F 13-24G 13-26general description 13-15H 13-15integer 13-21L 13-28namelist 13-37numeric 13-21P 13-19positional 13-16Q 13-24R 13-29

S, SP, SS 13-19slash 13-17X 13-16Z 13-30

ELSE statements 11-10ELSE-IF statements 11-9ENCODE statement B-6END IF statements 11-11END statements 11-20end-of-file conditions 12-23end-of-file specifier 12-25ENDFILE statement 12-59

Page 419: FORTRAN 77 Reference Manual - Bull

Index

47 A2 15UL Rev02 i-3

ENDPACKAGE statement 19-8entities

global 18-2local 18-3nlist 9-2

ENTRY statement 15-20EQUIVALENCE statement 8-4error conditions 12-23error specifier 12-24ERROR statement 20-2evaluation of expressions 6-22evaluation of operands 6-23executable program 2-4executable statement 7-1exponent

double precision 4-7quadruple precision 4-14real 4-5

expressionarithmetic constant 6-5logical 6-17, 6-19logical constant 6-20

expressionsarithmetic 6-1character 6-11, 6-26character constant 6-12character relational 6-14complex 6-5complex double precision 6-5constant 6-27dimension bound 5-2double precision 6-5evaluation of 6-5, 6-22integer 6-5integer constant 6-5logical 6-26parentheses 6-23quadruple precision 6-5real 6-5relational 6-13, 6-26substring 5-12

EXTCOMMON statement 19-6external function 15-2, 15-12EXTERNAL statement 8-19EXTROUTINE statement 19-5

F

factor arithmetic operand 6-3file-positioning statement 12-58files

access 12-7direct access 12-9existence 12-4internal 12-10

position 12-7properties 12-4sequential access 12-8units 12-13

formatcontrol 13-6I/O statement 12-27specifier, identifier 12-18

FORMAT statement 13-1Fortran character set 3-1FUNCTION statement 15-12function subprogram 2-4, 15-12functions

external 15-2, 15-12intrinsic 15-5, 15-36names 15-5referencing 15-3

G

GCOS ID FORTRAN B-1GCOS IE FORTRAN B-1global entities 18-2GOTO

assigned 11-4computed 11-3unconditional 11-2

graphics 3-3

H

hexadecimal constant 4-16, 13-6Hollerith constant 4-18, 9-6

in arguments 15-27

I

I/O status specifier 12-24, 12-35IF (ARITHMETIC) statement 11-5IF (BLOCK) statement 11-7IF (LOGICAL) statement 11-6IMPLICIT statement 8-14IMPLIED DO statement 9-4implied-DO list 12-29INCLUDE statement 20-1initial line 2-3, 3-4input list item 12-29input/output

data transfer 12-30list-directed 12-27lists 12-28namelist 12-27

Page 420: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

i-4 47 A2 15UL Rev02

INQUIRE statement 12-50integer

constant 4-4division 6-10editing 13-21

integer constqnt expression 6-5integer expression 6-5INTEGER statement 8-14intrinsic function 15-3, 15-5, 15-36INTRINSIC statement 8-21IOS variable 12-24, 12-35IOSTAT variable 12-24

K

keyword 2-2

L

label assignment statement 10-6line character 3-4list directed

formatting 13-32input 13-32output 13-35

list-directed formatting 12-34lists

dlist 12-29general definition 2-9I/O 12-28implied-DO 12-29input 12-29output 12-29

local entities 18-3logical

constant expression 6-20disjunctive 6-19expression 6-17, 6-19factor 6-18operators 6-17primaries 6-18term 6-18

logical assignment statement 10-4logical constant 4-10logical expressions 6-26LOGICAL IF statements 11-6LOGICAL statement 8-14logical type 4-10

M

main program 2-4

manual packaging 19-4

N

namelist I/O 12-27NAMELIST statement 8-26names

specific and generic 15-5symbolic 18-1symbolic classes 18-4

nlist entity 9-2nonexecutable statement 7-2normal execution sequence 3-11numeric storage unit 2-11

O

Olist 12-36OPEN statement 12-36operands

arithmetic 6-3evaluation of 6-23

operatorarithmetic 6-1character 6-11logical 6-17precedence 6-21relational 6-13

output list item 12-29

P

PACKAGE statement 19-4package unit 2-4packaging

automatic 19-2close automatic 19-3general definition 19-1manual 19-4open automatic 19-3

PAGE statement 20-2PARAMETER statement 8-17parentheses, expressions 6-23PAUSE statements 11-19precedence of operators 6-21primary arithmetic operand 6-3, 6-12PRINT statement 12-26printing 12-34procedures

dummy 15-2dummy arguments 15-32general definition 2-4

Page 421: FORTRAN 77 Reference Manual - Bull

Index

47 A2 15UL Rev02 i-5

processed length specifier 12-21PROGRAM statement 14-2program unit 2-4PUNCH statement 12-26

Q

quadruple precisionconstant 4-14exponent 4-14

quadruple precision expression 6-5QUADRUPLE PRECISION statement 8-14quadruple precision type 4-14

R

READ statement 12-26real constant 4-5real exponent 4-5real expression 6-5REAL statement 8-14real type 4-5record specifier 12-20records

endfile 12-3formatted 12-2unformatted 12-2

relational expressions 6-13, 6-26relational operator 6-13RETURN statement 15-23REWIND statement 12-59

S

SAVE statement 8-23scale factor 13-19short integer type 4-12short logical type 4-13SIRIS-8 FORTRAN features C-1SKIPEND statement 20-2special characters 3-2specifier

byte 12-20end-of-file 12-25error 12-24format 12-18I/O status 12-24, 12-35processed length 12-21record 12-20units 12-17

statementlabel 3-7

STATEMENT FUNCTION statement 15-8statements

arithmetic assignment 10-1ARITHMETIC IF 11-5ASSIGN 10-6ASSIGNED GOTO 11-4BACKSPACE 12-59BLOCK DATA 16-1BLOCK IF 11-7CALL 15-18CHARACTER 8-11, 8-14character assignment 10-8classes 2-3CLOSE 12-49COMMON 8-6COMPLEX 8-14COMPLEX DOUBLE PRECISION 8-14COMPUTED GOTO 11-3CONTINUE 11-17control 11-1DATA 9-1data type 8-10DECODE B-6DIMENSION 8-2DO 11-12DOUBLE PRECISION 8-14ELSE 11-10ELSE-IF 11-9ENCODE B-6END 11-20END IF 11-11ENDFILE 12-59ENDPACKAGE 19-8ENTRY 15-20EQUIVALENCE 8-4ERROR 20-2executable 7-1EXTCOMMON 19-6EXTERNAL 8-19EXTROUTINE 19-5file-positioning 12-58FORMAT 13-1FUNCTION 15-8, 15-12IF (ARITHMETIC) 11-5IF (BLOCK) 11-7IF (LOGICAL) 11-6IMPLICIT 8-14implied-DO 9-4INCLUDE 20-1INQUIRE 12-50INTEGER 8-14INTRINSIC 8-21label assignment 10-6labels 2-2LOGICAL 8-14logical assignment 10-4LOGICAL IF 11-6

Page 422: FORTRAN 77 Reference Manual - Bull

FORTRAN 77 Reference Manual

i-6 47 A2 15UL Rev02

NAMELIST 8-26nonexecutable 7-2OPEN 12-36order 3-8PACKAGE 19-4PAGE 20-2PARAMETER 8-17PAUSE 11-19PRINT 12-26PROGRAM 14-2PUNCH 12-26QUADRUPLE PRECISION 8-14READ 12-26REAL 8-14restrictions 12-60RETURN 15-23REWIND 12-59SAVE 8-23SKIPEND 20-2STOP 11-18SUBROUTINE 15-17unconditional GOTO 11-2WRITE 12-26

STOP statements 11-18storage

array sequence 5-5numeric unit 2-11unit, character 2-11

subprogramblock data 16-1function 15-12

subprogram, block data 2-4SUBROUTINE statement 15-17subroutines

general definition 15-17subprogram 15-17subprograms 2-4

subscripts 5-7substring

character 5-12expressions 5-12general definition 2-7name 5-12

symbolic name 2-2symbolic names 18-1syntactic items 2-2

T

term arithmetic operand 6-4

U

unconditional GOTO statement 11-2unformatted data transfer 12-32units

connection 12-13existence 12-13specifier 12-17

V

variablesgeneral definition 2-5in arguments 15-29IOS 12-24, 12-35IOSTAT 12-24

W

WRITE statement 12-26

Page 423: FORTRAN 77 Reference Manual - Bull

Technical publication remarks form

Title : DPS7000/XTA NOVASCALE 7000 FORTRAN 77 Reference Manual Languages:FORTRAN

Reference Nº : 47 A2 15ULA02 Date: Septembre 1991

ERRORS IN PUBLICATION

SUGGESTIONS FOR IMPROVEMENT TO PUBLICATION

Your comments will be promptly investigated by qualified technical personnel and action will be taken as required.If you require a written reply, please include your complete mailing address below.

NAME : Date :

COMPANY :

ADDRESS :

Please give this technical publication remarks form to your BULL representative or mail to:

Bull - Documentation Dept.

1 Rue de ProvenceBP 20838432 ECHIROLLES [email protected]

Page 424: FORTRAN 77 Reference Manual - Bull

Technical publications ordering form

To order additional publications, please fill in a copy of this form and send it via mail to:

BULL CEDOC357 AVENUE PATTONB.P.2084549008 ANGERS CEDEX 01FRANCE

Phone: +33 (0) 2 41 73 72 66FAX: +33 (0) 2 41 73 70 66E-Mail: [email protected]

CEDOC Reference # Designation Qty

_ _ _ _ _ _ _ _ _ [ _ _ ]

_ _ _ _ _ _ _ _ _ [ _ _ ]

_ _ _ _ _ _ _ _ _ [ _ _ ]

_ _ _ _ _ _ _ _ _ [ _ _ ]

_ _ _ _ _ _ _ _ _ [ _ _ ]

_ _ _ _ _ _ _ _ _ [ _ _ ]

_ _ _ _ _ _ _ _ _ [ _ _ ]

_ _ _ _ _ _ _ _ _ [ _ _ ]

_ _ _ _ _ _ _ _ _ [ _ _ ]

_ _ _ _ _ _ _ _ _ [ _ _ ]

_ _ _ _ _ _ _ _ _ [ _ _ ]

_ _ _ _ _ _ _ _ _ [ _ _ ]

[ _ _ ] : The latest revision will be provided if no revision number is given.

NAME: Date:

COMPANY:

ADDRESS:

PHONE: FAX:

E-MAIL:

For Bull Subsidiaries:

Identification:

For Bull Affiliated Customers:

Customer Code:

For Bull Internal Customers:

Budgetary Section:

For Others: Please ask your Bull representative.

Page 425: FORTRAN 77 Reference Manual - Bull
Page 426: FORTRAN 77 Reference Manual - Bull

BULL CEDOC

357 AVENUE PATTON

B.P.20845

49008 ANGERS CEDEX 01

FRANCE

47 A2 15ULA02REFERENCE