DEC 20 LFRMA D Fortran Reference Manual
DEC-20-LFRMA-D-D Fortran Reference Manual DEC-20-LFRMA-D-D Fortran Reference Manual
User Manual: DEC-20-LFRMA-D-D Fortran Reference Manual
Open the PDF directly: View PDF .
Page Count: 252
Download | |
Open PDF In Browser | View PDF |
FORTRAN Reference Manual Order No. DEC-20-LFRMA-A-D FORTRAN Reference Manual Order No. DEC-20-LFRMA-A-D digital equipment corporation · maynard. massachusetts First Printing, January 1976 The information in this document is subject to change without notice and should not be construed as a commitment by Digital Equipment Corporation. Digital Equipment Corporation assumes no responsibility for any errors that may appear in this document. The software described in this document is furnished under a license and may be used or copied only in accordance with the terms of such license. Digital Equipment Corporation assumes no responsibility for the use or reliability of its software on equipment that is not supplied by DIGITAL. Copyright © 1976 by Digital Equipment Corporation The postage prepaid READER'S COMMENTS form on the last page of this document requests the user's critical evaluation to assist us in preparing future documentation. The following are trademarks of Digital Equipment Corporation: DIGITAL DEC PDP DECUS UNIBUS COMPUTER LABS COMTEX DDT DECCOMM DECsystem-IO DECtape DIBOL EDUSYSTEM FLIP CHIP FOCAL INDAC LAB-8 DECsystem-20 MASSBUS OMNIBUS OS/8 PHA RSTS RSX TYPESET-8 TYPESET-IO TYPESET-l I CONTENTS Page CHAPTER I INTRODUCTION 1.1 INTRODUCTION CHAPTER 2 CHARACTERS AND LINES 2.1 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.3 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.4 CHARACTER SET ................ . STATEMENT, DEFINITION, AND FORMAT Statement Label Field and Statement Numbers Line Continuation Field Statement Field Remarks . . . . . . . . LINE TYPES . . . . . . . . . Initial and Continuation Line Types Multi-Statement Lines Comment Lines and Remarks Debug Lines . . . . . Blank Lines ....... . Line-Sequenced Input ORDERING OF DECSYSTEM-20 FORTRAN STATEMENTS. CHAPTER 3 DA T A TYPES, CONSTANTS, SYMBOLIC NAMES, VARIABLES, AND ARRAYS 3.1 3.5.3 DATA TYPES CONSTANTS Integer Constants Real Constants . Double Precision Constants Complex Constants Octal Constan ts Logical Constants Literal Constants Statement Label Constants SYMBOLIC NAMES VARIABLES . . . . . . . . . ARRAYS ......... . Array Element Subscripts Dimensioning Arrays .. Order of Stored Array Elements CHAPTER 4 EXPRESSIONS 4.1 4.1.1 4.2 4.2.1 4.3 4.3.1 4.3.2 4.3.3 4.3.4 ARITHMETIC EXPRESSIONS Rules for Writing Arithmetic Expressions LOGICAL EXPRESSIONS . . . . . > , Relational Expressions . . . . EVALUATION OF EXPRESSIONS Parenthesized Subexpressions Hierarchy of Operators . . . . Mixed Mode Expressions . . . Use of Logical. Operands in Mixed Mode Expressions 3.2 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.3 3.4 3.5 3.5.1 3.5.2 1-1 2-1 2-3 2-3 2-3 2-3 2-3 2-4 2-4 2-5 2-5 2-6 2-6 2-6 2-6 3-1 3-1 3-2 3-2 3-3 3-4 3-4 3-5 3-5 3-6 3-6 3-6 3-7 3-7 3-8 3-9 iii 4-1 4-2 4-2 4-6 4-8 4-8 4-8 4-9 . 4-10 CONTENTS (Cont) Page CHAPTERS COMPILA TION CONTROL STATEMENTS 5.1 5.2 5.3 5.4 INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . PROGRAM STATEMENT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . INCLUDE STATEMENT . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . END STATEMENT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . CHAPTER 6 SPECIFICATION STATEMENT 6.1 6.2 6.2.1 6.3 6.4 6.5 6.5.1 6.6 6.7 6.8 INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . DIMENSION STATEMENT . . . . . . . . . . . . . . . . . . . . . Adjustable Dimensions . . . . . . . . . . . . . . . . . . . . . TYPE SPECIFICATION STATEMENTS . . . . . . . . . . . . IMPLICIT STATEMENTS . . . . . . . . . . . . . . . . . . . COMMON STATEMENT .................. . Dimensioning Arrays in COMMON Statements .... . EQUIVALENCE STATEMENT . . . . . . . . . . . . . . . . . . . . . . EXTERNAL STATEMENT ...................... . PARAMETER STATEMENT CHAPTER 7 DATA STATEMENT 7.1 INTRODUCTION CHAPTER 8 ASSIGNMENT STATEMENTS 8.1 8.2 8.3 8.4 INTRODUCTION . . . . . . . ARITHMETIC ASSIGNMENT STATEMENT . . . . . . . . . LOGICAL ASSIGNMENT STATEMENTS . . . . . . . . . . . ASSIGN (STATEMENT LABEL) ASSIGNMENT STATEMENT CHAPTER 9 CONTROL STATEMENTS 9.1 9.2 9.2.1 9.2.2 9.2.3 9.3 9.3.1 9.3.2 9.3.3 9.4 9.4.1 9.4.2 9.4.3 9.5 9.6 9.7 9.7.1 INTRODUCTION . . . . . . . . . . . . . . . . . . GO TO CONTROL STATEMENTS . . . . . . . . . Unconditional GO TO Statements . . . . Computed GO TO Statements . . . . . . . . . Assigned GO TO Statements . . . . . . . . . . IF STATEMENTS . . . . . . . . . . . . . . . . . . Arithmetic IF Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Logical IF Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. Logical Two-Branch IF Statements . . . . . . . . . . . . . . . . . . . . . . . . . DO STATEMENT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. Nested DO Statements . . . . . . . . . . . . . . . . . . . . . . . . . . Extend Range . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Permitted Transfer Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . CONTINUE STATEMENT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. STOP STATEMENT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. PAUSE STATEMENT . . . . . . . . . . . . . ................... T (TRACE) Option ........... . . . . . . . . . . . . . . . . . . . . . . . . .. · . . . .. · ..... · . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. iv 5-1 5-1 5-1 5-2 6-1 6-1 6-2 6-3 64 6-5 6-6 6-6 6-7 6-8 7-1 8-1 8-1 8-3 8-3 9-1 9-1 9-2 9-2 9-2 9-3 9-3 94 94 9-5 9-6 9-7 9-8 9-9 9-9 9-10 9-10 CONTENTS (Cont) Page CHAPTER 10 I/O STATEMENTS 10.1 10.2 10.2.1 10.2.2 10.2.3 10.3 10.3.1 10.3.2 10.3.3 10.3.4 10.3.4.1 10.3.5 10.3.6 10.3.7 10.4 10.5 10.5.1 10.5.2 10.5.3 10.5.4 10.5.5 10.5.6 10.6 10.7 10.8 10.8.1 10.8.2 10.8.3 10.8.4 10.8.5 10.8.6 10.9 10.10 10.1 0.1 10.10.2 10.11 10.12 10.13 10.14 10.14.1 10.14.2 10.14.3 10.15 DATA TRANSFER OPERATIONS TRANSFER MODES Sequential Mode . . . Random Access Mode Append Mode . . . . . I/O STATEMENTS, BASIC FORMATS AND COMPONENTS I/O Statement Keywords . . . . . . . . . . . . . . . . . Logical Unit Numbers . . . . . . . . . . . . . . . . . . . FORMAT Statement References .. I/O List ..................... . Implied DO Constructs . . . . . . . . . . . The Specification of Records for Random Access . List-Directed I/O . . . . . . . . . . . . . . . . . . . NAME LIST I/O Lists ............... . OPTIONAL READ/WRITE ERROR EXIT AND END-OF-FILE ARGUMENTS READ STATEMENTS . . . . . . . . . . . . . . . . Sequential Formatted READ Transfers Sequential Unformatted Binary READ Transfers Sequential list-Directed READ Transfers Sequential NAMELIST-Controlled READ Transfers Random Access Formatted READ Transfers . . Random Access Unformatted READ Transfers SUMMARY OF READ STATEMENTS REREAD STATEMENT . . . . . . . . . . . . WRITE STATEMENTS . . . . . . . . . . . . Sequential Formatted WRITE Transfers . Sequential Unformatted WRITE Transfer Sequential list-Directed WRITE Transfers Sequential NAME LIST-Controlled WRITE Transfers Random Access Formatted WRITE Transfers Random Access Unformatted WRITE Transfers SUMMARY OF WRITE STATEMENTS ACCEPT STATEMENT . . . . . . . . . . . . . . Formatted ACCEPT Transfers . . . . . . . . ACCEPT Transfers Into FORMAT Statement PRINT STATEMENT . . . . . . . . TYPE STATEMENT . . . . . . . . . . . . FIND STATEMENT. . . . . . . . . . . . ENCODE AND DECODE STATEMENTS ENCODE Statement . . . . . . . . DECODE Statement . . . . . . . . Example of ENCODE/DECODE Operations SUMMARY OF I/O STATEMENTS . . . . . . . v 10-1 10-1 10-1 10-1 10-2 10-2 10-3 10-3 10-3 10-5 10-5 10-6 10-6 10-8 10-8 10-9 10-9 10-10 10-10 10-11 10-11 10-11 10-11 10-12 10-13 10-13 10-14 10-14 10-14 10-14 10-15 10-15 10-15 10-15 10-16 10-16 10-17 10-17 10-18 10-19 10-19 10-19 10-20 CONTENTS (Cont) Page CHAPTER 11 NAME LIST STATEMENTS 11.1 11.2 11.2.1 11.2.2 INTRODUCTION . . . . . . . . . . . . . . . NAMELIST STATEMENT . . . . . . . . . . NAMELIST-Controlled Input Transfers NAMELIST-Controlled Output Transfers CHAPTER 12 FILE CONTROL STATEMENTS 12.1 12.2 12.2.1 12.2.2 INTRODUCTION . . . . . . . . . . . . . . . OPEN AND CLOSE STATEMENTS . . . . . . Options for OPEN and CLOSE Statements Summary of OPEN/CLOSE Statement Options CHAPTER 13 FORMAT STATEMENT 13.1 13.1.1 13.2 13.2.1 13.2.2 13.2.3 13.2.4 13.2.5 13.2.6 13.2.7 13.2.8 13.2.9 13.2.10 13.2.11 13.3 INTRODUCTION FORMAT Statement, General Form FORMAT DESCRIPTORS . . . . . . . . Numeric Field Descriptors . . . . . Interaction of Field Descriptors With I/O list Variables During Transfer G, General Numeric Conversion Code Numeric Fields with Scale Factors Logical Field Descriptors . . . . . Variable Numeric Field Widths .. Alphanumeric Field Descriptors . Transferring Alphanumeric Data Directly Into or From FORMAT Statements Mixed Numeric and Alphanumeric Fields Multiple Record Specifications . . . . . . . . . . . . . . . . . . . . . Record Formatting Field Descriptors ................ . CARRIAGE CONTROL CHARACTERS FOR PRINTING ASCII RECORDS CHAPTER 14 DEVICE CONTROL STATEMENTS 14.1 14.2 14.3 14.4 14.5 14.6 14.7 14.8 14.9 INTRODUCTION REWIND STATEMENT . . . . UNLOAD STATEMENT . . . . BACKSPACE STATEMENT .. END FILE STATEMENT SKIP RECORD STATEMENT . . . . . . . SKIP FILE STATEMENT BACKFILE STATEMENT . . . . . . . . . SUMMARY OF DEVICE CONTROL STATEMENTS CHAPTER IS SUBPROGRAM STATEMENTS 15.1 15.1.1 15.2 15.3 15.4 15.4.1 15.4.2 INTRODUCTION Dummy and Actual Arguments STATEMENT FUNCTIONS . . . . INTRINSIC FUNCTIONS (DECsystem-20 FORTRAN DEFINED FUNCTIONS) EXTERNAL FUNCTIONS . . . . . . . . . . . . . . . . . . . . . . . . . . . . Basic External Functions (DECsystem-20 FORTRAN Defined Functions) . Generic Function Names . . . . . . . . . . . . . . . . . . . . . . . . . . vi 11-1 11-1 11-2 11-3 12-1 12-1 12-2 . 12-8 13-1 13-1 13-2 134 13-6 13-7 13-7 13-9 13-9 13-10 13-11 13-12 13-13 13-14 13-15 14-1 14-2 14-2 14-2 14-2 14-3 14-3 14-3 14-3 15-1 15-1 15-3 15-3 15-5 15-6 15-6 CONTENTS (Coot) Page 15.5 15.5.1 15.5.2 15.6 15.6.1 15.7 SUBROUTINE SUBPROGRAMS . . . . . . . . . . . . Referencing Subroutines (CALL Statement) .. . DECsystem-20 FORTRAN Supplied Subroutines RETURN STATEMENT AND MULTIPLE RETURNS . . . . Referencing External FUNCTION Subprograms . . . . MULTIPLE SUBPROGRAM ENTRY POINTS (ENTRY STATEMENT) CHAPTER 16 BLOCK DATA SUBPROGRAMS 16.1 16.2 INTRODUCTION . . . . . . . BLOCK DATA STATEMENT .. APPENDIX A ASCII-1968 CHARACTER CODE SET APPENDIX B SPECIfYING DIRECTORY AREAS B.I B.I.1 B.1.2 B.2 B.2.1 8.2.2 USING LOGICAL NAMES . . . . . Giving The DEFINE Command Using The Logical Name . . . . USING PROJECT-PROGRAMMER NUMBERS Running The TRANSL Program . . . . Using The Project-Programmer Number APPENDIX C USING THE COMPILER C.l C.1.I C.1.1.1 C.1.2 C.2 C.3 C.3.1 C.3.2 C.4 RUNNING THE COMPILER Switches Available with DECsystem-20 FORTRAN The /DEBUG Switch . . . . . . . . . LOAD Class Commands . . . . . . . . . . . READING A DECsystem-20 FORTRAN LISTING Compiler Generated Variables .. ERROR REPORTING . . . . . . . . . Fatal Errors and Warning Messages Message Summary . . . . . . . . CREATE A REENTRANT FORTRAN PROGRAM WITH LINK APPENDIX D WRITING USER PROGRAMS 0.1 0.1.1 0.1.2 0.1.3 0.1.4 0.1.5 0.1.6 0.1.7 0.2 0.2.1 0.2.1.1 0.2.1.2 0.2.1.3 0.2.1.4 GENERAL PROGRAMMING CONSIDERATIONS Accuracy and Range of Double Precision Numbers . . . . . . . . Writing FORTRAN Programs for Execution on Non-DEC Machines Using Floating Point DO Loops . . . . . . Computation of DO Loop Iterations . . . . Subroutines - Programming Considerations Reordering of Computations . . . . . . . . Dimensioning of Formal Arrays . . . . . . DECsystem-20 FORTRAN GLOBAL OPTIMIZATION Optimization Techniques . . . . . . . . . . . . Elimination of Redundant Computations . Reduction of Operator Strength . . . . . . Removal of Constant Computation From Loops Constant Folding and Propagation . . . . . . . C.2.1 · 15-7 · 15-9 .15-10 .15-10 .15-12 .15-13 16-1 16-1 vii · B-1 · B-1 . B-2 · B-2 . B-2 . B-2 · · · · · C-l · C-l · C-2 .C-4 · C-5 · C-6 C-10 C-1O C-ll C-l1 · .0-1 .0-1 .0-1 .0-1 .0-1 .0-2 0-2 .0-3 .0-4 .0-4 .0-4 .0-5 .0-6 .0-7 CONTENTS (Cont) Page D.3.7 D.3.7.1 D.3.7.2 Removal of Inaccessible Code Global Register Allocation I/O Optimization . . . . . . Uninitialized Variable Detection Test Replacement . . . . . . . . Improper Function References . . . . . Programming Techniques for Effective Optimization INTERF ACING WITH NON-DECsystem-20 FORTRAN PROGRAMS AND FILES Calling Sequences . Accumulator Usage Argument Lists . . . Argument Types .. Description of Arguments Converting Existing MACRO Libraries for Use with DECsystem-20 FORTRAN . . . . . . . . . . . . . . . . . . . . . . . . . . . Interaction with COBOL . . . . . . . . . . . . . . . . . . . . Calling FORTRAN Subprograms from COBOL Programs Calling COBOL Subroutines from FORTRAN Programs APPENDIX E FOROTS E.I E.2 E.3 E.3.! E.3.2 E.3.2.1 E.3.2.2 EA EA.I EA.2 EA.2.1 EA.3 EA.4 E.S E.S.! E.S.2 E.S.3 E.S.3.1 FEATURES OF FOROTS ERROR PROCESSING . . INPUT /OUTPUT F ACI LlTIES Input/Output Channels Used Internally by FOROTS File Access Modes . . . . . . . Sequential Transfer Mode . . . . . . . . . . . Random Access Mode . . . . . . . . . . . . . ACCEPTABLE TYPES OF DATA FILES AND THEIR FORMATS ASCII Data Files . . . . . . . FORTRAN Binary Data Files Format of Binary Files Mixed Mode Data Files . Image Files . . . . . . USING FOROTS . . . . . . FOROTS Entry Points Calling Sequences MACRO Calls for FOROTS Functions Formatted/Unformatted Transfer Statements, Sequential Access Calling Sequences . . . . . . . . . . . . . . . . . . . . . NAMELIST Data Transfer Statements, Sequential Access Calling Sequences . . . . . . . . . . . . . . . . . Array Offsets and Factoring . . . . . . . . . . . . . Formatted/Unformatted Data Transfer Statements, Random Access Calling Sequences . . . . . . . . Calling Sequences for Statements Which Use Default Devices Calling Sequences for Statements Which Position Magnetic Tape Units . . . . . . . . . . . . . . . List Directed Input/Output Statements . . . . . . . . . . D.2.l.S D.2.1.6 D.2.1.7 D.2.1.8 D.2.1.9 D.2.2 D.2.3 D.3 D.3.1 D.3.2 D.3.3 D.3.4 D.3.S D.3.6 E.S.3.2 E.S.3.3 E.5.3A E.5.3.S E.5.3.6 E.S.3.7 viii .D-7 .D-7 .D-7 .D-8 .D-8 .D-8 .D-8 .D-8 .D-9 · D-IO · D-IO · D-12 · D-12 · · · · D-13 D-18 D-18 D-19 · E-I .E-2 · E-2 · E-2 · E-2 .E-2 · E-3 · E-3 · E-3 · E-3 .E-4 · E-I! · E-II · · · · E-!2 E-12 E-12 E-13 · E-14 · E-IS · E-!6 · E-!7 · E-18 · E-19 · E-20 CONTENTS (Cont) Page E.5.3.8 E.5.3.9 E.5.3.10 E.6 Input/Output Data Lists . . . . . . . . . . . . . . . . . OPEN and CLOSE Statements, Calling Sequences . . . . Software Channel Allocation and De-allocation Routines LOGICAL/PHYSICAL DEVICE ASSIGNMENTS . . . . . . . . . . APPENDIX F FORDDT F.l F.l.1 F.1.2 F.1.3 F.2 F.2.l F.3 FA F.5 F.6 F.7 F.8 F.9 INPUT FORMAT Variables and Arrays . Numeric Conventions Statement Labels and Source Line Numbers NEW USER TUTORIAL . . . . . . . . . . . . . Basic Commands . . . . . . . . . . . . . . FORDDT AND THE FORTRAN /DEBUG SWITCH LOADING AND STARTING FORDDT . . . . SCOPE OF NAME AND LABEL REFERENCES . FORDDT COMMANDS . . . . . ENVIRONMENT CONTROL .. . FORTRAN /OPTIMIZE SWITCH FORDDT MESSAGES . . . . . . APPENDIX G COMPILER MESSAGES APPENDIX H DECsystem-IO COMPATIBILITY ix · · · · E-20 E-23 E-24 E-25 · F-2 · F-2 · F-3 · F-3 · F-3 · F-3 · F-6 · F-7 · F-8 · F-8 · F-16 · F-16 · F-16 TABLES Table No. 1-1 2-1 3-1 3-2 4-1 4-2 4-3 4-4 4-5 4-6 4-7 4-8 8-1 10-1 10-2 10-3 104 12-1 13-1 13-2 13-3 134 13-5 14-1 15-1 15-2 15-3 C-I C-2 D-l D-2 D-3 E-2 F-I Page Title FORTRAN Statement Categories DECsystem-20 FORTRAN Character Set Constants ............ . Use of Symbolic Names ........ . Arithmetic Operations and Operators Type of the Resultant Obtained From Mixed Mode Operations Permitted Base/Exponent Type Combinations Logical Operators .......... . Logical Operations, Truth Table . . . . Binary Logical Operations, Truth Table Relational Operators and Operations . . Hierarchy of FORTRAN Operators Rules for Conversion in Mixed Mode Assignments DECsystem-20 FORTRAN Logical Device Assignments Summary of Read Statements . . . . . . . . . . . . . Summary of WRITE Statements . . . . . . . . . . . . Summary of DECsystem-20 FORTRAN I/O Statements OPEN/CLOSE Statement Arguments DECsystem-20 FORTRAN Conversion Codes Action of Field Descriptors On Sample Data . Numeric Field Codes . . . . . . . . . . . . . Descriptor Conversion of Real and Double Precision Data According to Magnitude . . . . . . . . . . . . . . . . . FORTRAN Print Control Characters . . . . . . . . . . . Summary of DECsystem-20 FORTRAN Device Control Statements Intrinsic Functions (DECsystem-20 FORTRAN Defined Functions) . Basic External Functions (DECsystem-20 FORTRAN Defined Functions) . FORTRAN Library Subroutines . . . . . . . . . . . . . . . . . . FORTRAN Compiler Switches . . . . . . . . . . . . . . . . . . . ....... . Modifiers to /DEBUG Switch ....... . Argument Types and Type Codes Upward Compatibility (FORSE TO FOROTS) Downward Compatibility (FOROTS TO FORSE) FORTRAN Device Table Table of Commands x 1-2 2-1 3-2 3-6 4-1 4-3 44 44 4-5 4-6 4-7 4-9 8-2 104 10-12 10-15 10-21 12-9 13-3 13-5 13-6 13-8 13-14 14-3 · 154 · 15-8 IS-IS · · C-2 C-3 D-12 D-21 D-22 E-27 · F-I PREFACE The DECsystem-20 FORTRAN Reference Manual describes the FORTRAN language as implemented for the DECsystem-20 FORTRAN Language Processing System (referred to as DECsystem-20 FORTRAN). The lanb'Uage manual is intended for reference purposes only; tutorial type text has been minimized. The reader is expected to have some experience in writing FORTRAN programs and to be familiar with the standard FORTRAN language set and terminology as defined in the American National Standard FORTRAN, X3.9-l966. The descriptions of the DECsystem-20 FORTRAN extensions and additions to the standard FORTRAN language set are printed in bold!aceitafictype. Operating procedures and descriptions of the DECsystem-20 programming environment are included in the appendices. xi Introduction CHAYfER 1 DECsystem-20 FORTRAN extensions to the 1966 ANSI standard set are printed in boldface italic type. CHAPTER 1 INTRODUCTION 1.1 INTRODUCTION The DECsystem-20 FORTRAN language set is compatible with and encompasses the standard set described in "American National Standard FORTRAN, X3.9-l966" (referred to as the 1966 ANSI standard set). DECsystem-20 FORTRAN also provides many extensions and additions to the standard set which greatly enhance the usefulness of DECsystem-20 FORTRAN and increases its compatibility with FORTRAN language sets implemented by other major computer manufacturers. In this manual the DECsystem-20 FORTRAN extensions and additions to the 1966 ANSI standard set are printed in boldface italic type. A DECsystem-20 FORTRAN source program consists of a set of statements constructed using the language elements and the syntax described in this manual. A given FORTRAN statement will perform anyone of the following functions: a. It will cause operations such as multiplication, division, and branching to be carried out. b. It will specify the type and format of the data being processed. c. It will specify the characteristics of the source program. FORTRAN statements are comprised of key words (i.e., words which are recognized by the compiler) used with elements of the language set: constants, variables, and expressions. There are two basic types of FORTRAN statements: executable and nonexecutable. Executable statements specify the action of the program; nonexecutable statements describe the characteristics and arrangement of data, editing information, statement functions, and the kind of subprograms that may be included in the program. The compilation of executable statements results in the creation of executable code in the object program. Nonexecutable statements provide information only to the compiler, they do not create executable code. In this manual the FORTRAN statements are grouped into twelve categories, each of which is described in a separate chapter. The name, definition, and chapter reference for each statement category are given in Table 1-1. The basic FORTRAN language elements (i.e., constants, variables, and expreSSions), the character set from which they may be formed, and the rules which govern their construction and use are described in Chapters 2 through 4. 1-1 Statement Categories CHAPTER 1 Table 1-1 FORTRAN Statement Categories Category Name Description Chapter Reference Compilation Control Statements Statements in this category identify programs and indicate their end. 5 Specification Statements Statements in this category declare the properties of variables, arrays, and functions. 6 DATA Statement This statement assigns initial values to variables and array elements. 7 Assignment Statements Statements in this category cause named variables and/or array elements to be replaced by specified (assigned) values. 8 Control Statements Statements in this category determine the order of execution of the object program and terminate its execution. 9 Input/Output Statements Statements in this category transfer data between internal storage and a specified input or output medium. 10 NAMELIST Statement This statement establishes lists that are used with certain input/output statements to transfer data which appears in a special type of record. 11 File Control Statements Statements in this category identify, open and close files and establish parameters for input and output operations between files and the processor. 12 FORMAT Statement This statement is used with certain input/output statements to specify the form in which data appears in a FORTRAN record on a specified input/output medium. 13 Device Control Statements Statements in this category enable the programmer to control the positioning of records or files on certain peripheral devices. 14 SUBPROGRAM Statements Statements in this category enable the programmer to define functions and subroutines and their entry points. 15 BLOCK DATA Statements Statements in this category are used to declare data specification subprograms which may initialize common storage areas. 16 1-2 Character Set CHAPTER 2 DECsystem-20 FORTRAN extensions to the 1966 ANSI standard set are printed in boldface italic type. CHAPTER 2 CHARACTERS AND LINES 2.1 CHARACTER SET The digits, letters, and symbols recognized by DECsystem-20 FORTRAN are listed in Table 2-1. The remainder of the ASCII-I968 character set I, although acceptable within iiteral constants or comment text, causes a fatal error in other contexts. An exception is CTRLjZ which, when used in terminal input, means end-of-file. NOTE Lower case alphabetic characters are treated as upper case outside the context of Hollerith constants, literal strings, and comments. Table 2-1 DECsystem-20 FORTRAN Character Set Letters A,a B,b C,c D,d E,e F,f 1,j K,k L,l M,m N,n e,g P,p Q,q R,r H,h IJ 0,0 S,s T,t U,u V,V W,w X,x Y,y Z,Z ( continued) 1 The complete ASCII-I968 character set is defined in the X3.4-I968 version of the "American National Standard for Information Interchange," and is given in Appendix A. 2-1 CHAPTER 2 Character Set Table 2-1 (Cont) DECsystem-20 FORTRAN Character Set Digits 0 5 6 2 3 4 7 8 9 Symbols " # $ & , ( ) * + Comma Hyphen (Minus) Period (Decimal Point) Slant (slash) Colon Semicolon < Less Than Equals Greater Than > A Circumflex Exclamation Point Quotation Marks Number Sign Dollar Sign Ampersand Apostrophe Opening Parenthesis Closing Parenthesis Asterisk Plus Line Termination Characters Line Feed Form Feed Vertical Tab Line Formatting Characters Carriage Return Horizontal Tab Blank Note that horizontal tabs normally advance the character position pointer to the next position that is an even multiple of 8. An exception to this is the initial tab which is defined as a tab that includes or starts in character position 6. (Refer to Section 2.3.1 for a description of initial and continuation line types.) Tabs within literal specifications count as one character even though they may advance the character position pointer as many as eight places. 2-2 Statement LABEL, CONTINUATION and STATEMENT Fields and Remarks CHAPTER 2 2.2 STATEMENT, DEFINITION, AND FORMAT Source program statements are divided into physical lines. A line is defined as a string of adjacent character positions, terminated by the first occurrence of a line termination character regardless of context. Each line is divided into four fields: I~ Line Character Positions 2 3 4 5 6 7 -------------------....,~~ 70 8 71 72 ~---~y----~/~\~---------~T------------J Statement Label Field Continuation Field Statement Field 73 . . '------r-----' Remarks 2.2.1 Statement Label Field and Statement Numbers A one to five digit number may be placed in the statement label field of an initial line to identify the statement. Any source program statement that is referenced by another statement must have a statement number. Statement numbers may be any number from 1 to 99999; leading zeroes and all blanks in the label field are ignored (e.g., the numbers 00105 and 105 are both accepted as statement number 105). The statement numbers given in a source program may be assigned in any order; however, each statement number must be unique with respect to all other statements in the program. Non executable statements, with the exception of FORMAT statements, cannot be labeled. When source programs are entered into the system via a standard user terminal, an initial tab may be used to skip all or part of the label field. If an initial tab is encountered during compilation, FORTRAN examines the character immediately following the tab to determine the type of line being entered. If the character following the tab is one of the digits 1 through 9, FORTRAN considers the line as a continuation line and the second character after the tab as the first character of the statement field. If the character fol/owing the taq is other than one of the digits 1 through 9, FORTRAN considers the line to be an initial line and the character fol/owing the tab is considered to be the first character of the statement field. The character following the initial tab is considered to be in character position 6 in a continuation line, and in character position 7 in an initial line. 2.2.2 Line Continuation Field Any alphanumeric character (except a blank or a zero) placed in this field (position 6) identifies the line as a continuation line (see Paragraph 2.3.1 for description). Whenever a tab is used to skip all or part of the label field of a continuation line, the next character entered must be one of the digits 1 through 9 to identify the line as a continuation line. 2.2.3 Statement Field Any FORTRAN statement may appear in this field. Blanks (spaces) and tabs do not affect compilation of the statement and may be used freely in this field for appearance purposes, with the exception of textual data given within either a literal or Hollerith specification where blanks and tabs are significant characters. 2.2.4 Remarks In lines comprised of 73 or more character positions, only the first 72 characters are interpreted by FORTRAN. (Note that tabs generally occupy more than one character position, advancing the counter to the next character position that is an even multiple of eight.) All other characters in the line (character positions 73, 74 ... etc.) ar~ treated as remarks and do not affect compilation. 2-3 LINE TYPES Initial and Continuation Lines Note that remarks may also be added to a line in character positions 7 through 72 provided the text of the remark is preceded by the symbol! (refer to Paragraph 2.3.3). 2.3 LINE TYPES A line in a DECsystem-20 FORTRAN source program can be a. an initial line b. a continuation line c. a multi-statement line d. a comment line e. a debug line f. a blank line. Each of the foregoing line types is described in the following paragraphs. 2.3.1 Initial and Continuation Line Types A FORTRAN statement may occupy the statement fields of up to 20 consecutive lines. The first line in a multiline statement group is referred to as the "initial" line; the succeeding lines are referred to as continuation lines. Initial lines may be assigned a statement number and must have either a blank or a zero in their continuation line field (i.e., character position 6). If an initial line is entered via a keyboard input device, an initial tab may be used to skip all or part of the /abel field. An initial tab used for this purpose must be followed immediately by a nonnumeric character (i.e., the first character of the statement field must be nonnumeric). Continuation lines cannot be assigned statement numbers: they are identified by any alphanumeric character (except for a blank or zero) placed in character position 6 of the line (i.e., continuation line field). The label field of a continuation line is treated as remark text. If a continuation line is being entered via a keyboard, an initial tab may be used to skip all or part of the label field; however, the tab must be followed immediately by a numeric character other than zero. The tab-numeric combination identifies the line as a continuation line. Note that blank lines, comments, and debug lines that are treated like comments, i.e., debug lines that are not compiled with the rest of the program (refer to section 2.3.4), terminate a continuation sequence. Following is an example of a four line FORTRAN FORMAT statement using initial tabs: 105 FORMAT <1Hl,17HINITIAL CHARGE = ,FI0.6,10H COULOME,6X, 213HRESISTANCE = ,F9.3,6H OHM/ISH CAPACITANCE = ,F10.6, 38H FARAD,11 X,13HI NDUCTANCE - ,F7.3,8H HENERYIII 421 H II ME CURRENT/7H MS .10X.2HMAIII) t Continuation Line Characters (i.e., 2, 3, and 4) 24 Multi-Statement Comment, and Remark Lines 2.3.2 Multi-Statement Lines More than one FOR TRAN statement may be written in the statement field of one line. The rules for structuring a multi-statement line are: a. successive statements must be separated by a semicolon (;) b. only the first statement in the series can have a statement number c. statements following the first statement cannot be a continuation of the preceding statement d. the lost statement in a line may be continued to the next line if the line ;s made a continuation line. An example of a multi-statement line is: 450 DIST=RATE * TIME ;TIME=TIME+0.05 ;CALL PRIMECTIME,DISn 2.3.3 Comment Lines and Remarks Lines that contain descriptive text only are referred to as comment lines. Comment lines are commonly used to identify and introduce a source program, to describe the purpose of a particular set of statements, and to introduce subprograms. The rules for structuring a comment line are: $,1,*, or ! must be in character position 1 of the line to identify it as a a. One of the characters C (or c), comment line. b. The text may be written into character positions 2 through the end of the line. c. Comment lines may appear anywhere in the source program, but may not precede a continuation line because comments terminate a continuation sequence. d. A large comment may be written as a sequence of any number of lines. However, each line must carry the identifying character (C,$,I, * , or !) in its first character position. The following is an example of a comment that occupies more than one line. CSUBROUTINE - A12 CTHE PURPOSE OF THIS SUBROUTI NE IS CTO FORMAT AND STORE THE RESULTS OF CTEST PROGRAM HEAT TEST-l 101 Comment lines are printed on all listings but are otherwise ignored by the compiler. 2-5 Debug and Blank Lines Line-8equenced Input Ordering of Statements A remork may be added to any statement field, in cluzracter positions 7 through 72, provided the symbol! precedes the text. For example, in the line IF(N.EQ.0)STOP! STOP IF CARD IS BLANK the character group "Stop if ClIrd is blonk" is identified as a remark by the preceding ! symbol. Remarks do not result in the generation of object program code, but they will appear on listings. The symbol !, indicating a remark, must appear outside the context of a literal specification. Note that characters appearing in character positions 73 and beyond are automatically treated as remarks, so that the symbol! need not be used (refer to Paragraph 2.2.4). 2.3.4 Debug Lines As an aid in program debugging a D (or d) in character position 1 of any line causes the line to be interpreted as a comment line, i.e., not compiled with the rest of the program unless the / Include switch appears in the command string. (Refer to Appendix C for a description of the compile switch options.) When the I Include switch is present in the command string the D (or d) in character position 1 is treated as a blank so that the remainder of the line is compiled as an ordinary (noncomment) line. Note that the initial and all continuation lines of a debug statement must contain a D (or d) in character position 1. 2.3.5 Blank Lines Lines consisting of only blanks, tabs, or no characters may be inserted anywhere in a FORTRAN source program except immediately preceding a continuation line, because blank lines are by definition initial lines and as such terminate a continuation sequence. Blank lines are used for formatting purposes only; they cause blank lines to appear in their corresponding positions in object program listings; otherwise, they are ignored by the compiler. 2.3.6 Line-Sequenced Input FORTRAN optionally accepts line-sequenced files as produced by EDIT, the DECsystem-20 editor. These sequence numbers are used in place of the listing line numbers normally generated by FORTRAN. 2.4 ORDERING OF DECSYSTEM-20 FORTRAN STATEMENTS The order in which FORTRAN Statements appear in a program unit is important. That is, certain types of statements have to be processed before others in order to guarantee that compilation takes place as expected. The proper sequence for FORTRAN statements is summarized by the following diagram. 2-6 Ordering of Statements PROGRAM, FUNCTION, Subprogram, or BLOCK DATA Statements IMPLICIT Statements PARAMETER Statements Comment Lines FORMAT Statements DIMENSION, COMMON, EQUIVALENCE, EXTERNAL, NAMELIST, or Type Specification Statements DATA Statements Statement Function Definitions Executable Statements END Statement Horizontal lines indicate the order in which FORTRAN statements must appear. That is, the statements in the horizontal sections cannot be interspersed. For example, all PARAMETER statements must appear after all IMPLICIT statements and before any DATA statements, Le., PARAMETER, IMPLICIT, and DATA statements cannot be interspersed:, Statement function definitions must appear after IMPLICIT statements and before executable statements. Vertical lines indicate the way in which certain types of statements may be interspersed. For example, DATA statements may be interspersed with statement function definitions and executable statements. FORMAT statements may be interspersed with IMPLICIT statements, parameter statements, other specification statements, DATA statements, statement function definitions, and executable statements. The only restrictions on the placement of FORMAT statements are that they must appear after any PROGRAM, FUNCTION, SUBPROGRAM, and BLOCK DATA ~tatements, and before the END statement. Special Cases: a. The placement of an INCLUDE statement is dictated by the types of statements to be INCLUDEd. b. The ENTRY statement is allowed only in functions or subroutines. All executable references to any of the dummy parameters must physically follow the ENTRY statement unless the references appear in the function definition statement, the subroutine, or in a preceding ENTRY statement. c. BLOCK DATA subprograms cannot contain any executable statements, statement functions, FORMAT statements, EXTERNAL statements, or NAMELIST statements. (Refer to section 16.1.) FORTRAN expects users to adhere to the foregoing ordering guidelines and issues warning messages when statements are out of place. 2-7 Data Types, Constants CHAPTER 3 DECsystem-20 FORTRAN extensions to the 1966 ANSI standard set are printed in boldface italic type_ CHAPTER 3 DATA TYPES, CONSTANTS, SYMBOLIC NAMES, VARIABLES, AND ARRAYS 3.1 DATA TYPES The data types permitted in DECsystem-20 FORTRAN source programs are a. integer b. real c. double precision d. complex e. octal f. double octal g- literal h. statement label, and i. logical. The use and format of each of the foregoing data types are discussed in the descriptions of the constant having the same data type (paragraphs 3.2.1 through 3.2.8). 3.2 CONSTANTS Constants are quantities that do not change value during the execution of the object program. The constants permitted in DECsystem-20 FORTRAN are listed in Table 3-1. 3-1 INTEGER and REAL Constants CHAPTER 3 Table 3-1 Constants Constant(s) Types Category Numeric Truth Values Uteral Data Statement Label Integer, real, double precision, complex, and octal Logical Uteral Address of FOR TRAN statement label 3.2.1 In teger Constants An integer constant is a string of from one to eleven digits which represents a whole decimal number (i.e., a n~lllber without a fractional part). Integer constants must be within the range of - 23 5-1 to +2 35 -I (i.e., -34359738367 to +34359738367). Positive integer constants may optionally be signed; negative integer constants must be signed. Decimal points, commas, or other symbols are not permitted on integer constants (except for a preceding sign, + or -). Examples of valid integer constants are: 345 +345 -345 Examples of invalid integer constants are: +345. 3,450 34.5 (use of decimal point) (use of comma) (use of decimal point; not a whole number) 3.2.2 Real Constants A real constant may have any of the following forms: a. A basic real constant: a string of decimal digits followed immediately by a decimal point which may optionally be followed by a fraction (e.g., 1557.00). b. A basic real constant followed immediately by a decimal integer exponent written in E notation (i.e., exponential notation) form (e.g., 1559.E2). c. An integer constant (no decimal point) followed by a decimal integer exponent written in E notation (e.g., 1559E2). Real constants may be of any size; however, each will be rounded to fit the precision of 27 bits (i.e., 7 to 9 decimal digits). Precision for real constants is maintained (approximately) to eight digits. l 1 This is an approximation, the exact precision obtained will depend on the numbers involved. 3-2 DOUBLE PRECISION Constants CHAPTER 3 The exponent field of a real constant written in E notation form cannot be empty (i.e., blank), it must be either a zero or an integer constant. The magnitude of the exponent must be greater than -38 and equal to or less than +38 (i.e., - 3 8 < n ,;;;; 38). The following are examples of valid real constants. -98.765 7.0E+0 .7E-3 5E+5 50115. 50.El (i.e., 7.) (i.e., .0007) (i.e., 500000.) (i.e., 500.) The following are examples of invalid real constants. n.6E75 .375E 500 (exponent is too large) (exponent incorrectly written) (no decimal point given) 3.2.3 Double Precision Constants Constants of this type are similar to real constants written in E notation form; the direct differences between these two constants are: a. Double precision constants depending on their magnitude have precision to 16 or 18 places, rather than the 8-digit precision obtained for real constants. b. Each double precision constant occupies two storage locations. c. The letter D, instead of E, is used in double precision constants to identify a decimal exponent. Both the letter D and an exponent (even of zero) are required in writing a double precision constant. The exponent given need only be signed if it is negative; its magnitude must be greater than - 38 and equal to or less than +38 (i.e., -38 < n';;;; +38). The range of magnitude permitted a double precision constant depends on the type of processor present in the system on which the source program is to be compiled and run. The permitted range is 0.14 X 10- 38 to 3.4 X 10+ 38 . The following are valid examples of double precision constants. 7.9D03 7.9D+03 7.9D-3 79D03 79DO (i.e., 7900) (i.e., 7900) (i.e., .0079) (i.e., 79000) (i.e., 79) The following are invalid examples of double precision constants. 7.9D99 7.9E5 (exponent is too large) (denotes a single precision constant) 3-3 COMPLEX and OCfAL Constants CHAPTER 3 3.2.4 Complex Constants A complex constant can be represented by an ordered pair of integer, real or octal constants written within parentheses and separated by a comma. For example, (.70712, -.70712) and (8.763E3, 2.297) are complex constants. In a complex constant the first (leftmost) real constant of the pair represents the real part of the number, the second real constant represents the imaginary part of the number. Both the real and imaginary parts of a complex constant can be signed. The real constants that represent the real and imaginary parts of a complex constant occupy two consecutive storage locations in the object program. 3.2.5 Octal Constants Octal numbers (radix 8) may be used as constants in arithmetic expressions, logical expressions, and data statements. Octal numbers up to 12 digits in length are considered standard octal constants; they are stored right-justified in one processor storage location. When necessary, standard octal constants are padded with leading zeroes to fill their storage location. If more than 12 digits are specified in an octal number, it is considered a double octal constant. Double octal constants occupy two storage locations and may contain up to 24 right-justified octal digits; zeroes are added to fill OIly unused digits. If a single octal constant is to be assigned to a double precision or complex variable, it is stored, right-justified, in the high order word of the variable. The low order portion of the variable is set to zero. If a double octal constant is to be assigned to a double precision or complex variable, it is stored right-justified starting in the low order (rightmost) word and precedes leftwards into the high order word. All octal constants must be a. preceded by a double quote (") to identify the digits as octal (e.g., "777), and b. signed if negative but optionally signed if positive. The following are examples of valid octal constants: "123456700007 "123456700007 +"12345 -"7777 "-7777 The following are examples of invalid octal constants: "12368 7777 (contains a radix digit) (no identifying double quotes) MIen OIl octal constant is used as an operand in an expression, its form (i.e., bit pattern) is not converted to accommodate it to the type of any other operand. For example, the subexpression (A+"202 400000000) has as its result the sum of A with the floating point number 2.0; while the subexpression (1+"202400000 000) has as its result the sum of I with a large integer. 34 LOGICAL and LITERAL Constants, Statement Labels, Symbolic Names CHAPTER 3 When a double octal constant is combined in an expression with either an integer or real variable, only the contents of the high order location (leftmost) are used. 3.2.6 Logical Constants The Boolean values of truth and falsehood are represented in FORTRAN source programs as the logical constants .TRUE. and .FALSE .. Logical constants are always written enclosed by periods as in the preceding sentence. Logical quantities may be operated on in arithmetic and logical statements. Only the sign bit of a numeric used in a logical IF statement is tested to determine if it is true (sign is negative) or false (sign is positive). 3.2.7 Literal Constants A literal constant may be either of the following: a. A string of alphanumeric and/or special characters contained within apostrophes (e.g., 'TEST#S'). b. A Hollerith literal, which is written as a string of alphanumeric and/or special characters preceded by nH (e.g., nHstring). In the prefix nH, the letter n represents a number which specifies the exact number of characters (including blanks) that follow the letter H; the letter H identifies the literal as a Hollerith literal. The following are examples of Hollerith literals: 2HAB, 14HLOAD TEST #124, 6H#124-A NOTE A tab (+i ) in a Hollerith literal is counted as one character (e.g.,3H-.!AB). Literal constants may be entered into DATA statements as a string of a. up to ten 7-bit ASCII characters for complex or double precision type variables, and b. up to five 7-bit ASCII characters for all other type variables. The 7-bit ASCII characters which comprise a literal constant are stored left-justified (starting in the high order word of a 2-word precision or complex literal) with blanks placed in empty character positions. Literal constants that occupy more than one variable are stored in successive variables in the list. The following example illustrates how the string of characters A LITERAL OF MANY CHARACTERS is stored in a six-element array called A. DIMENSION A (6) DATA A /'A LITERAL OF MANY CHARACTERS'/ A(J) is set to A(2) is set to A(3) is set to A(4) is set to A(S) is set to A (6) is set to 'A_LIT' 'ERAL_' 'O£.MA' 'NY-CH' 'ARACT' 'ERS__' 3-5 Symbolic Names, Variables CHAPTER 3 3.2.8 Statement Label ConstlUlts Statement labels are numeric identifiers that represent program statement numbers. Statement label constlUlts are written as a string of from one to five decimol digits which are preceded by either a dollar sign ($) or an amperslUld (&). For example, either $11992 or &11992 may be used as statement labels. Statement label constlUlts are used only in the argument list of CALL statements to define the statement to return to in a multiple RETURN statement. (Refer to Chapter 15.) 3.3 SYMBOLIC NAMES Symbolic names may consist of any alphanumeric combination of from one to six characters. More than six characters may be given but FORTRAN ignores all but the first six. The first character of a symbolic name must be an alphabetic character. The following are examples of legal symbolic names: Al2345 IAMBIC ABLE The following are examples of illegal symbolic names: #AMBIC lAB (symbol used as first character) (number used as first character) Symbolic names are used to identify specific items of a FORTRAN source program; these items, together with an example of a symbolic name and text reference for each, are listed in Table 3-2. Table 3-2 Use of Symbolic Names Symbolic Names Can Identify 1. A Variable 2. 3. 4. 5. 6. 7. An Array An Array element Functions Subroutines External COMMON Block Names For Example PI, CONST, LIMIT TAX TAX (NAME,INCOME) MYFUNC, V ALFUN CALCSB, SUB2, LOOKUP SIN, ATAN, COSH DATAR, COMDAT For a detailed description See Paragraph 3.4 3.5 3.5.1 15.2 15.5 15.4 6.5 3.4 VARIABLES A variable is a datum (i.e., storage location) that is identified by a symbolic name and is not an array or an array element. Variables specify values which are assigned to them by either arithmetic statements (Chapter 8), DATA statements (Chapter 7), or at run time via I/O references (Chapter 10). Before a variable is assigned a value, it is termed an undefined variable and should not be referenced except to assign a value to it. If an undefined variable is referenced, an unknown value is obtained. 3-6 ARRAYS, ARRAY Element Subscripts CHAPTER 3 The value assigned a variable may be either a constant or the result of a calculation which is performed during the execution of the object program. For example, the statement IAB=5 assigns the constant 5 to the variable lAB; in the statement IAB=5+B, however, the value of lAB at a given time will depend on the value of variable B at the time the statement was last executed. The type of a variable is the type of the contents of the datum which it identifies. Variables may be a. integer b. real c. logical d. double precision, or e. complex. The type of a variable may be declared using either implicit or explicit type declaration statements (Chapter 6). However, if type declaration statements are not used, the following convention is assumed by FORTRAN: a. Variable names which begin with the letters I, J, K, L, M, or N are integer variables. b. Variable names which begin with any letter other than I, J, K, L, M, or N are real variables. Examples of determining the type of a variable according to the foregoing convention are given in the folloWing table. Variable ITEMP OTEMP KA123 AABLE Beginning Letter I 0 K A Assumed Data Type Integer Real Integer Real 3.5 ARRAYS An array is an ordered set of data identified by an array name. Array names are symbolic names and must conform to the rules given in Paragraph 3.3 for writing symbolic names. Each datum within an array is called an array element. Like variables, array elements may be assigned values; before an array element is assigned a value it is considered to be undefined and should not be referenced until it has been assigned a value. If a reference is made to an undefined array element the value of the element will be unknown and unpredictable. Each element of an array is named by using the array name together with a subscript that describes the position of the element within the array. 3.5.1 Array Element Subscripts The subscript of an array element identifier is given, within parentheses, as either one subscript quantity or a set of subscript quantities delimited by commas. The parenthesized subscript is written immediately after the array name. The general form of an array element name is AN (SI, S2, ... Sn), where AN is the array name and SI through Sn represent n number of subscript quantities. Any number of subscript quantities may be used in an element name; however, the number used must always equal the number of dimensions (Paragraph 3.5.2) specified for the array. 3-7 Dimensioning Arrays CHAPTER 3 A subscript can be any compound expression (Chapter 4), for example: a. Subscript quantities may contain arithmetic expressions that involve addition, subtraction, multiplication, division, and exponentiation. For example, (A+B,C*5,D/2) and (A**3, (B/4+C) *E,3) are valid subscripts. b. Arithmetic expressions used in array subscripts may be of any type but noninteger expressions (including complex) are converted to integer when the subscript is evaluated. c. A subscript may contain function references (Chapter 14). For example: TABLE (SIN (A) *B,2, 3) is a valid array element identifier. d. Subscripts may contain array element identifiers nested to any level as subscripts. For example, in the subscript (I(J(K(L»),A+B,C) the first subscript quantity given is a nested 3-level subscript. The following are examples of valid array element subscripts: a. lAB (1,5,3) b. ABLE (A) c. TABLEl (10/C+K**2,A,B) d. MAT(A,AB(2*L),.3*TAB(A,M+l,D),55) 3.5.2 Dimensioning Arrays The size (Le., number of elements) of an array must be declared in order to enable FORTRAN to reserve the needed amount of locations in which to store the array. Arrays are stored as a series of sequential storage locations. Arrays, however, are visualized and referenced as if they were single or multi-dimensional rectilinear matrices, dimensioned on a row, column, and plane basis. For example, the following figure represents a 3-row, 3-column, 2-plane array. 3 ROWS ,<-"" '?-~ '?" 3 COLUMNS 10-1058 The size (Le., number of elements) of an array is specified by an array declarator written as a subscripted array name. In an array declarator, however, each subscript quantity is a dimension of the array and must be either an integer, a variable, or an integer constant. For example, TABLE (I,J,K) and MATRIX (10,7,3,4) are valid array declarators. The total number of elements which comprise an array is the product of the dimension quantities given in its array declarator. For example, the array lAB dimensioned as lAB (2,3,4) has 24 elements (2 X 3 X 4 = 24). 3-8 CHAPTER 3 Dimensioning Arrays, Order of Stored Array Elements Arrays are dimensioned only in the specification statements DIMENSION, COMMON, and type declaration (Chapter 6). Subscripted array names appearing in any of the foregoing statements are array declarators; subscripted array names appearing in any other statements are always array element identifiers. In array declarators the position of a given subscript quantity determines the particular dimension of the array (e.g., row, column, plane) which it represents. The first three subscript positions specify the number of rows, columns, and planes which comprise the named array; each following subscript given then specifies a set comprised of n-number (value of the subscript) of the previously defined sets. For example: The Dimension Declarator Specifies the Array(s) TAB (2) TAB (2,2) TAB (2,2,2) TAB (2,2,2,2) NOTE DECsystem-20 FORTRAN permits any number of dimensions in an array declarator. 3.5.3 Order of Stored Array Elements The elements of an array are arranged in storage in ascending order, with the value of the first subscript quantity varying between its maximum and minimum values most rapidly, and the value of the last given subscript quantity increasing to its maximum value least rapidly. For example, the elements of the array dimensioned as 1(2,3) are stored in the following order: The following list describes the order in which the elements of the three-dimensional array (B(3,3,3» are stored: B (1,1,1) B (2,1,1) B (3,1,1) - "'j --------------------- =~ ~(~2~~ ___B~2~::> ___ ~ ~'':12 ~ J ~- ... B(1,3,1) B(2,3,1) B(3,3,1)-, --------------------- '..... B (1,1,2) B (2,1,2) B (3,1,2) - , ~- ... B (1,3,2) B (2,3,2) B (3,3,2) - "'j B (2,1,3) B (3,1,3) - I --------------------- L_ ... B (1,1,3) =~ ~(~2~~ __ y ~2~,.:! ___ ~ ~'':32. ~ J L.... B (1,3,3) B (2,3,3) 3-9 B (3,3,3) CHAPTER 4 Arithmetic Expressions and Operators DECsystem-20 FORTRAN extensions to the 1966 ANSI standard set are printed in boldface italic type. CHAPTER 4 EXPRESSIONS 4.1 ARITHMETIC EXPRESSIONS Arithmetic expressions may be either simple or compound. Simple arithmetic expressions consist of an operand which may be a. a constant b. a variable c. an array element d. a function reference (see Chapter 14 for description), or e. an arithmetic or logical expression written within parentheses. Operands may be of type integer, real, double precision, complex, octal. or literal. The following are valid examples of simple arithmetic expressions: 105 lAB TABLE (3, 4,5) SIN (X) (A+B) (integer constant) (integer variable) (array element) (function reference) (a parenthesized expression) A compound arithmetic expression consists of two or more operands combined by arithmetic operators. The arithmetic operations permitted in FORTRAN and the operator recognized for each are given in Table 4-1. Table 4-1 Arithmetic Operations and Operators Operation 1. Exponentiation 2. Multiplication 3. Division 4. Addition 5. Subtraction Operator ** or t * I + 4-1 Example A**B or AtB A*B AlB A+B A-B Rules for Arithmetic Expressions, Logical Expressions CHAPfER4 4.1.1 Rules for Writing Arithmetic Expressions The following rules must be observed in structuring compound arithmetic expressions: a. The operands comprising a compound arithmetic expression may be of different types. Table 4-2 illustrates all permitted combinations of data types and the type assigned to the result of each. NOTE Only one combination of data types, double precision with complex, is prohibited in DECsystem-20 FORTRAN. b. An expression cannot contain two adjacent and unseparated operators. For example, the expression A* /B is not permitted. c. All operators must be included, no operation is implied. For example, the expression A(B) does not specify multiplication although this is implied in standard algebraic notation. The expression A* (B) is required to obtain a multiplication of the elements. d. In using exponentiation the base quantity and its exponent may be of different types. For example, the expression ABC** 13 involves a real base and an integer exponent. The permitted base/exponent type combination and the type of the result of each combination is given in Table 4-3. 4.2 LOGICAL EXPRESSIONS Logical expressions may be either simple or compound. Simple logical expressions consist of a logical operand which may be a logical type a. constant b. variable c. array element d. function reference (see Chapter 15), or e. another expression written within parentheses. Compound logical expressions consist of two or more operands combined by logical operators. The logical operators permitted by DECsystem-20 FORTRAN and a description of the operation each provides are given in Table 4-4. 4-2 Table 4-2 Type of the Resultant Obtained From Mixed Mode Operations Type of Ar~lIT11CI1 ( ~ For operators * , Type of operation used 2. Type associated InteHer 1. Integer Real 1. Real 2. Integer ~. 3. Conversion on Argument I 3. None 3. From Integer to Real 4. Conversion on Argument 2 4. None Real Double Precision 1. Double Precision Complex I logical Complex 2. Double Precision 2 Complex 3. From Integer to Double Precision 3 4. :--.lone 4. I , Octal Double Octal Litera Integer J. Integer I Integer I Integer , Intcgn ~ Integer 2 Integer 3 ~{)nc 3. 'one 3 4, 'one 4 4. High order word is used directly~ Integer with result InteReT 4. 'one From Integer to 3 '\one ~one I 4. ~onc I I High order word is used d lrectl y', low order word further words arc ignored. is ignored. Real I. Type of operation used 2. Type associated with result 3. Conversion on Argument I 4. Conversion on Argument 2 ~onc Complex. Valut: used as Real pari 1. Real I. Real I. Double Precision Complex Real ReJl I. Real Real 2. Real 2. Real 2. Doublc Precision Complex KCJl Real Real Real 3. None 3. None 4. hom Integer to 4. Used directly as the high order word; low order word is zero. 4. :-.Jane Real ~one tjsed dirl'ctly a~ the Real part. ImagInary part IS zcro. 4 None 3 1 '\on{' '\onc ~onc 4. None 4. .l ~one lIigh order word is used directly: [ow order word is ignored. 3 ~onc High order,word is used directly; further words .1rp ;crnnr,...-I Logical Operation Truth Table CHAPTER 4 Table 4-5 Logical Operations, Truth Table The result of the expression: Pis: When and Q is: Is: .NOT.P True False (Not Applicable) False True P.AND.Q True True False False True False True False True False False False P.ORQ True True False False True False True False True True True False P.XOR.Q True True False False True False True False False True True False P.EQV.Q True True False False True False True False True False False True Examples Assume the following variables: Type Real Integer Double Precision Logical Complex Variable REAL,RUN I,l,K DP,D L,A,B CPX,C Examples of valid logical expressions comprised of the foregoing variables are: L.AND.B (REAL*1) .XOR (DP+K) L.AND. A .OR .NOT. (I-K) 4-5 Binary Truth Table, Relational Expressions CHAPfER4 Logical functions are performed bit-wise on the full 36-bit binary processor representation of the operands involved. The result of a logical operation is found by performing the specified function, simultaneously, for each of the corresponding bits in each operand. For example, consider the expression A=C.OR.D, where C= "456 and D= "201. The operation performed by the processor and the result is: Word Bits Operand C Operand D Result A o o .24 25 26 0 • 0 0 0 - -•• 0 o0 • 0 o o o o o o 27 1 o 28 29 o o o o 30 1 0 31 0 0 32 1 0 33 1 o 34 1 35 o 0 0 Table 4-6 is a truth table that illustrates all possible logical combinations of two one-bit binary operands (P and Q) and gives the result of each combination. Table 4-6 Binary Logical Operations, Truth Table The result of the expression: Pis: When And Q is: Is: 1 0 - 0 1 P.AND.Q 1 1 0 0 1 0 1 0 1 0 0 0 P.OR.Q 1 1 0 0 1 0 1 0 1 1 1 0 P.XOR.Q I 1 0 0 1 0 1 0 0 1 1 0 P.EQV.Q 1 1 0 0 1 0 1 0 1 0 0 1 .NOT.P - 4.2.1 Relational Expressions Relational expressions are comprised of two expressions combined by a relational operator. The relational operator permits the programmer to test, quantitatively, the relationship between two arithmetic expressions. The result of a relational expression is always a logically true or false value. 4-6 Relational Operators CHAPI'ER4 In FORTRAN, relational operators may be written either as a two-letter mnemonic enclosed within periods (e.g., .GT.) or symbolically using the symbols >, <, = and #. Table 4-7 lists both the mnemonic and symbolic forms of the FORTRAN relational operators and specifies the type of quantitative test performed by each operator. Table 4-7 Relational Operators and Operations Operators Mnemonic Symbolic .GT. .GE. .LT. .LE. .EQ. .NE. Relation Tested > >= < <= Greater than Greater than or equal to Less than Less than or equal to Equal to Not equal to -# Relational expressions are written in the general form Al .OP. A2 , where A represents an arithmetic operand and .OP. is a relational operator. Arithmetic operands of type integer, real, and double precision may be mixed in relational expressions. Complex operands may be compared using only the operators .EQ (= =) and .NE. (#). Complex quantities are equal if the corresponding parts of both words are equal. Examples Assume the following variables: Variables REAL, RON I, J, K DP,D L,A,B CPX,C Type Real Integer Double Precision Logical Complex Examples of valid relational expressions comprised of the foregOing variables are: (REAL) .GT. 10 [==5 C.EQ.CPX Examples of invalid relational expressions comprised of the foregOing variables are: (REAL) .GT 10 (closing period missing from operator) C>CPX (complex operands can only be combined by .EQ. and .NE. operators) 4-7 Evaluation of Expressions CHAPTER 4 Examples of valid expressions in which both logical and relational operators are used to combine the foregoing variables are: (I .GT. 10) .AND. (J< =K) ((I *RON) ==(I/J)) .OR. K (I .AND. K) # ((REAL) .OR. (RON)) C #CPX .OR. RON 4.3 EVALUATION OF EXPRESSIONS The order of computation of a FORTRAN expression is determined by 4.3.1 a. the use of parentheses b. an established hierarchy for the execution of arithmetic, relational, and logical operations and c. the location of operators within an expression. Parenthesized Subexpressions In an expression all subexpressions written within parentheses are evaluated first. When parenthesized subexpressions are nested (one contained within another) the most deeply nested subexpression is evaluated first, the next most deeply nested subexpression is evaluated second and so on, until the value of the final parenthesized expression is computed. When more than one operator is contained by a parenthesized subexpression, the required computations are performed according to the hierarchy assigned operators by FORTRAN (paragraph 4.3.2). Example: The separate computations performed in evaluating the expression A+B/((A/B)tC)-C are: a. A/B =Rl b. R1+C =R2 c. B/R2=R3 d. R3-C =R4 e. A+R4=R5 NOTE Rl through RS represent the interim and final results of the computations performed. 4.3.2 Hierarchy of Operators The following hierarchy (i.e., order of execution) is assigned to the classes of FORTRAN operators: first - arithmetic operators second - relational operators third -logical operators 4-8 Hierarchy of Arithmetic, Relational and Logical Operators, Mixed Mode Expressions CHAYrER4 The precedence assigned to the individual operators of the foregoing classes is specified (from highest to lowest) in Table 4-8. With the exception of integer division and exponentiation, all operations on expressions or subexpressions involving operators of equal precedence are computed in any order that is algebraically correct. A subexpression of a given expression may be computed in any order. For example, in the expression (F(X) + A*B) the function reference may be computed either before or after A*B. Table 4-8 Hierarchy of FORTRAN Operators Class ARITHMETIC RELATIONAL Symbol or Mnemonic Level First Second Third Fourth ** - (unary minus) and + (unary plus) *,/ +, Fifth .GT., .GE., .LT., .LE., .EQ., .NE. >, >=, <. <=, ==, # or LOGICAL Sixth Seventh Eighth Ninth .NOT. .AND. .OR. .EQV., .xOR. Operations specifying integer division are evaluated from left to right. For example, the expression I/J*K is evaluated as if it had been written as (I/J)*K. When a series of exponentiation operations occurs in an expression, they are evaluated in order from right to left. For example, the expression A **2**B is evaluated in the following order: first 2**B = Rl (intermediate result) second A **Rl = R2 (final result). 4.3.3 Mixed Mode Expressions Mixed mode expressions are evaluated on a subexpression by subexpression basis with the type of the results obtained converted and combined with other results or terms according to the conversion procedures described in Table 4·2. Example Assume the following: Variable Type D Double Precision Real Integer X I,J 4·9 CHAPfER4 Mixed Mode Expressions, Using Logical Operands The mixed mode expression D+X* (1/1) is evaluated in the following manner: NOTE RI, R2, and R3 represent the interim and final results of the computations performed. a. (1/1) = Rl Rl is integer b. X*Rl = R2 Rl is converted to type real and is multiplied by X to produce R2 c. D+R2= R3 R2 is converted to type double precision and is added to D to produce R3 4.3.4 Use of Logical Operands in Mixed Mode Expressions When logical operands are used in mixed mode expressions, the value of the logical operand is not converted in any way to accommodate it to the type of the other operands in the expression. For example, in L *R, where L is type logical and R is type real, the expression is evaluated without converting L to type real. 4-10 CHAPfER5 PROGRAM Statement INCLUDE Statement DECsystem-20 FORTRAN extensions to the 1966 ANSI standard se t are prin ted in bold/ace italic type. CHAPTER 5 COMPILATION CONTROL STATEMENTS 5.1 INTRODUCTION Compilation control statements are used to identify DECsystem-20 FORTRAN programs and to specify their termination. Statements of this type do not affect either the operations performed by the object program or the manner in which the object program is executed. The three compilation control statements described in this chapter are: PROGRAM statement, INCLUDE statement, and END statement. 5.2 PROGRAM STATEMENT This statement allows the user to give the main program a name other than "MAIN." The general form of a PROGRAM statement is PROGRAM name where name is a user-formulated symbolic name that begins with an alphabetic character and contains a maximum of six characters. (Refer to section 3.3 for a description of symbolic names.) The following rule governs the use of the PROGRAM statement: The PROGRAM statement must be the first statement in a program unit. (Refer to section 2.4 for a discussion of the ordering of DECsystem-20 FORTRAN statements.) 5.3 INCL UDE STATEMENT This statement allows the user to include code segments or predefined declarations in a program unit without having them reside in the same physical file as the primary program unit. The general form of the INCL UDE statement is INCLUDE dev:filename.typefproj,progf /NOLIST where dev: is a device name. When no device is specified, DSK: is assumed. filename. type is the filename and type of the FOR TRAN statements that the user wishes to include. The name of the file is required; the type is optional. If only the filename is specified, then .FOR (for FORTRAN) is the assumed type. fproj,progj is the project-programmer number. The user s connected directory is assumed if none is specified. (Refer to Appendix B.) 5-1 END Statement /NOLlST is an optional switch that indicates that the included statements are not to be included in the compilation listing. The following rules govern the use of the INCLUDE statement: a. The INCLUDEd file may contain any iegal FORTRAN statement except another INCLUDE statement, or a statement that terminates the current program unit, such as the END, PROGRAM, FUNCTION, SUBROUTINE, or BLOCK DATA statements. b. The proper placement of the INCLUDE statement within a program unit depends upon the types of statements to be INCLUDEd. (Refer to section 2.4 for information on the ordering of DECsystem-20 FORTRAN statements.) Note that an asterisk (*) is appended to the line numbers of the INCLUDEd statements on the compilation listing. 5.4 END STATEMENT This statement is used to signal FORTRAN that the physical end of a source program or subprogram has been reached. END is a nonexecutable statement. The general form of an END statement is END The following rules govern the use of the END statement: a. This statement must be the last physical statement of a source program or subprogram. b. When used in a main program, the END statement implies a STOP statement operation; in a subprogram, END implies a RETURN statement operation. c. An END statement may be labeled. 5-2 DIMENSION Statement CHAPrER6 DECsysrem-20 FORTRAN exrensions to the 1966 ANSI standard set are prinred in boldface italic type. CHAPTER 6 SPECIFICATION STATEMENT 6.1 INTRODUCTION Specification statements are used to specify the type characteristics, storage allocations, and data arrangement. There are seven types of specification statements: a. DIMENSION b. Statements which specify, explicitly, type. c. IMPLICIT d. COMMON e. EQillVALENCE f. EXTERNAL g. PARAMETER Specification statements are nonexecutable and are expected to conform to the ordering guidelines described in section 2.4. 6.2 DIMENSION STATEMENT DIMENSION statements provide FORTRAN with information needed to identify and allocate the space required for source program arrays. Any number of subscripted array names may be specified as array declarators in a DIMENSION statement. The general form of a DIMENSION statement is DIMENSION SI, S2, ... , Sn where Si is an array declarator. Array dec1arators are names of the following form: name (min:max, min:max, ... _min:max) where name is the symbolic name of the array and each min:max value represents the lower and upper bounds of an array dimension. Each min:max value for an array dimension may be either an integer constant or, if the array is a dummy argument to a subprogram, an integer variable. The value given the minimum specification for a dimension must not exceed the value given the maximum specification. Minimum values of 1 with their following colon delimiter may be omitted from a dimension subscript. 6-1 CHAPTER 6 DIMENSION Statements, Specifying Adjustable Dimensions Examples DIMENSION EDGE (-1: 1,4:8),NET(S,IO,4),TABLE(S67) DIMENSION TABLE (lAB:J,K,M,IO:20) (where lAB, J, K, and M are of type integer). Note that a slash may be used in place of a colon as the delimiter between the upper and lower bounds of an array dimension. 6.2.1 Adjustable Dimensions When used within a subprogram, an array declarator may use type integer parameters as dimension subscript quantities. The following rules govern the use of adjustable dimensions in a subprogram: a. For single entry subprograms, the array name and each subscript variable must be given by the calling program when the subprogram is called. The subscript variables may also be in COMMON. b. For multiple entry subprograms in which the array name is a parameter, any subscript variables may be passed. If all subscript variables are not passed or in COMMON, the value of the subscript as passed for a previous entry will be used. c. The type of the array dimension variables cannot be altered within the program. d. If the value of an array dimension variable is altered within the program, the dimensionality of the array will not be affected. e. The original size of the array cannot exceed the array dimensions assigned within a subprogram (i.e., the size of an array is not dynamically expandable). Examples 27 SUBROUTINE SBR (ARRAY,Ml,M2,M3,M4) DIMENSION ARRAY (MI :M2,M3:M4) DO 27 L=M3,M4 DO 27 K=Ml,M2 ARRAY (K,L)=V ALUE CONTINUE END SUBROUTINE SBI (ARR1,M,N) DIMENSION ARRI(M,N) ARRI(M,N)=V ALUE ENTRY SB2(ARRI,M) ENTRY SB3(ARRI,N) ENTRY SB4(ARRI) In the foregoing example, the first call made to the subroutine must be made to SBI. Assuming that the call is made at SBI with the values M=ll and N=13, any succeeding call to SB2 should give M a new value. If a succeeding call is made to SB4, the last values passed through entries SUBI, SUB2, or SUB3 will be used for M and N. 6-2 CHAPfER6 Type Specification Statements Note that for the calling program of the form: CALL SBI(A,II,13) M=I5 CALL SB3(A,13) the value of M used in the dimensionality of the array for the execution of SB3 will be 11 (i.e., the last value passed). 6.3 TYPE SPECIFICATION STATEMENTS Type specification statements declare explicitly the data type of variable, array, or function symbolic names. An array name may be given in a type statement either alone (unsubscripted) to declare the type of all its elements or in a subscripted form to specify both its type and dimensions. Type specification statements are written in the following form: type list where type may be anyone of the following declarators: a. INTEGER b. REAL c. DOUBLE PRECISION d. COMPLEX e. LOGICAL NOTE In order to be compatible with the type statements used by other manufacturers, the data type size modifier, *n, is accepted by DECsystem-20 FORTRAN. This size modifier may be appended to the declarators, causing some to elicit messages warning users of the form of the variable specified by DECsystem-20 FORTRAN: Declarator INTEGER*2 INTEGER*4 LOGICAL*I LOGICAL*4 REAL*4 REAL*8 COMPLEX*8 COMPLEX*16 Form of Variable Specified Full word integer with warning message Full word integer Full word logical with warning message Full word logical Full word real Double precision real Complex Complex with warning message 6-3 CHAPfER6 Statements, IMPLICIT Statements NOTE (Cont) In addition, the data type size modifier may be appended to individual variables, arrays, or function names. Its effect is to override, for the particular element, the size modifier (explicit or implicit) of the primary type. For example, REAL*4 A, 8*8, C*8(10), D A and D are single precision (full word real), and 8 and C are double precision real. The list consists of any number of variable, array, or function names which are to be declared the specified type. The names listed must be separated by commas, and can appear in only one type statement within a program unit. Examples INTEGER A, 8, TABLE, FUNC REAL R, M, ARRA Y (5: 10,1 0: 20,5) NOTE Variables, arrays, and functions of a source program, which are not typed either implicitly or explicitly by a specification statement, are typed by FORTRAN according to the following conventions: a. Variable names, array names, and function names which begin with the letters I, J, K, L, M, or N are type integer. b. Variable names, array names, and function names which begin with any letter other than I, J, K, L, M, or N are type real. If a name that is the same as a FORTRAN defined function name appears in a conflicting type statement, it is assumed that the name refers to a user-defined routine of the given type. Placing a generic FORTRAN defined function name in an explicit type statement causes it to lose its generic properties. 6.4 IMPLICIT STATEMENTS IMPLICIT statements declare the data type of variables and functions according to the first letter of each variable name. IMPLICIT statements are written in the following form: IMPLICIT type(Al.A2, . . . ,An),type(Bl,B2,. . . ,Bn),. . . ,type. .... As shown in the foregoing form statement, an IMPLICIT statement is comprised of one or more type declarators separated by commas. Each type declarator has the form type(A I,A2, . . ..An) where type represents one of the declarators listed in section 6.3, and the parenthesized list represents a list of different letters. Each letter in a type declarator list specifies that each source program variable (not declared in an explicit type specification statement) which starts with that letter is assigned the data type named in the declarator. For example, the IMPLICIT type declarator REAL (R,M,N,O) declares that all names which begin with the letters R, M, N, or 0 are type REAL names, unless declared otherwise in an explicit type statement. 64 COMMON Statement CHAPfER6 NOTE Type declarations given in an explicit type specification override those also given in an IMPLICIT statement. IMPLICIT declarations do not affect the DECsystem-20 FORTRAN supplied functions. A range of letters within the alphabet may be specified by writing the first and last letters of the desired range separated by a dash (e.g., A-E for A,B,C,D,E). For eXllmp1e, the statement IMPLICIT INTEGER (I,L-P) declares that all variables which begin with the letters I,L,M,N,O, and P are INTEGER variables. More than one IMPLICIT statement may be used, but they must appear before any other declaration statement in the program unit. Refer to section 2.4 for a discussion on ordering DECsystem-20 FORTRAN statements. 6.S COMMON STATEMENT The COMMON statement enables the user to establish storage which may be shared by two or more programs and lor subprograms and to name the variables and arrays which are to occupy the common storage. The use of common storage conserves storage and provides a means to implicitly transfer arguments between a calling program and a subprogram. COMMON statements are written in the following form: COMMON/AI /VI ,V2, ... ,Vn ... /An/VI ,V2,... ,Vn where the enclosed letters IAI/, IA2/, and IAnI represent optional name constructs (referred to as common block names when used). The list (i.e., VI,V2 ... ,Vn) appearing after each name construct lists the names of the variables and arrays that are to occupy the common area identified by the construct. The items specified for a common area are ordered within the storage area as they are listed in the COMMON statement. COMMON storage area may be either labeled or blank (unlabeled). If the common area is to be labeled, a symbolic name must be given within slashes immediately before the list of items that are to occupy the names area. For example, the statement COMMON/AREAI/A,B,C/AREA2/TAB(13,3,3) establishes two labeled common areas (i.e., AREAl and AREA2). Common block names bear no relation to internal variables or arrays which have the same name. If a common area is to be declared but is to be unlabeled (i.e., blank) either nothing or two sequential slashes (/ /) is given immediately before the list of items that are to occupy blank common. For example, the statement COMMON/AREAI/A,B,CIITAB(3,3,3) establishes one labeled (AREAl) and one unlabeled (i.e., blank) common area. A given labeled common name may appear more than once in the same COMMON statement and in more than one COMMON statement within the same program or subprogram. Each labeled common area is treated as a separate, specific storage area. The contents of a common area (i.e., variables and array) may be assigned initial values by DATA statements in BLOCK DATA subprograms. Declarations of a given common area in different subprograms must contain the same number, size, and order of variable and array name as the referenced area. 6-5 CHAPTER 6 Dimensioning Arrays In COMMON, EQUIVALENCE Statement Items to be placed in a blank common area may also be given in COMMON statements throughout the source program. During compilation of a source program, DECsystem·20 FORTRAN strings together all items listed for each labeled common area and for blank common in the order in which they appear in the source program statements. For example, the series of source program statements COMMON/STl / A,B,C/ST2/T AB(2,2)/ /C,D,E COMMON/STl/TST(3,4)/ /M,N COMMON/ST2/X,Y,Z//O,P,Q have the same effect as the single statement COMMON/STI/A,B,C,TST(3,4)/ST2/TAB(2,2),X,Y,Z//C,D,E,M,N,O,P,Q All items specified for blank common are placed into one area. Items within blank common are ordered as they are given throughout the source program. Common block names must be unique with respect to all subroutine, function, and entry point names. The largest definition of a given common area must be loaded first. 6.5.1 Dimensioning Arrays in COMMON Statements Subscripted array names may be given in COMMON statements as array dimension declarators. However, variables cannot be used as subscript quantities in a declarator appearing in a COMMON statement; variable dimensioning is not permitted in COMMON. Each array name given in a COMMON statement must be dimensioned either by the COMMON statement or by another dimensioning statement within the program or subprogram which contains the COMMON statement. Example COMMON /A/B(lOO), C(IO,IO) COMMON X(5,15),Y(5) 6.6 EQUN ALENCE STATEMENT The EQUIVALENCE statement enables the user to control the allocation of shared storage within a program or subprogram. This statement causes specific storage locations to be shared by two or more variables of either the same or different types. The EQUIVALENCE statement is written in the following form: EQUIVALENCE(Vl,V2, ... Vn),(WI,W2, ...Wn),(XI,X2, ... ) where each parenthesized list contains the names of variables and array elements which are to share the same storage locations. For example, the statements EQUIVALENCE (A,B,C) EQUNALENCE (LOC,SHARE(l» specify that the variables named A, B, and C are to share the same storage location and the the variable LOC and array element SHARE(l) are to share the same location. 6-6 CHAPTER 6 EQUIVALENCE Statement, EXTERNAL Statement The relationship of equivalence is transitive; for example, the two following statements have the same effect: EQUIVALENCE (A,B), (B,C) EQUIVALENCE (A,B,C) Array elements, when used in EQUIVALENCE statements, must have either as many subscript quantities as dimensions of the array or only one subscript quantity. In either of the foregoing cases, the subscripts must be integer constants. Note that the single case treats the array as a one-dimensional array of the given type. The items given in an EQUIVALENCE list may appear in both the EQUIVALENCE statement and in a COMMON statement providing the following rules are observed: a. No two quantities declared in a COMMON statement can be set equivalent to one another. b. Quantities placed in a common area by means of an EQUIVALENCE statement are permitted to extend the end of the common area forwards. For example, the statements COMMON/R/X,Y,Z DIMENSION A(4) EQUIVALENCE (A,Y) cause the common block R to extend from Z to A(4) arranged as follows: x Y A(I) Z A(2) A(3) A(4) c. (shared location) (shared location) EQUIVALENCE statements that cause the start of a common block to be extended backwards are not allowed. For example, the invalid sequence COMMON/R/X,Y,Z DIMENSION A(4) EQUIV ALENCE(X,A(3» would require A(1) and A(2) to extend the starting location of block R in a backwards direction as illustrated by the following diagram: 1A(I) A(2) X A(3) Y A(4) Z 6.7 EXTERNAL STATEMENT Any subprogram name to be used as an argument to another subprogram must appear in an EXTERNAL statement in the calling subprogram. The EXTERNAL statement declares names to be subprogram names to distinguish them from other variable or array names. The EXTERNAL statement is written in the following form: EXTERNAL name 1,name2, ...,namen 6-7 EXTERNAL Statement PARAMETER Statement CHAPTER 6 where each name listed is declared to be a subprogram name. If desired, these subprogram names may be DECsystem-20 FORTRAN defined functions. It is also possible to utilize DECsystem-20 FORTRAN defined function names for user subprograms by prefixing the names by an asterisk (*) or an ampersand (&) within an EXTERNAL statement. For example, EXTERNAL *SIN, &COS declares SIN and COS to be user subprograms. (If a prefixed name is not a DECsystem-20 FORTRAN defined function, then the prefix is ignored.) Note that specifying a DECsystem-20 FORTRAN defined function in an EXTERNAL statement without a prefix (i.e., EXTERNAL SIN) has no effect upon the usage of the function name outside of actual argument lists. If the name has generic properties, they are retained outside of the actual argument list. (The name has no generic propeties within an argument list.) The names declared in a program EXTERNAL statement are reserved throughout the compilation of the program and cannot be used in any other declarator statement, with the exception of a type statement. 6.8 PARAMETER STATEMENT The PARAMETER statement allows users to define constants symbolically during compilation. The general form of the PARAMETER Statement is as follows: PARAMETER PI=CI,P2=C2,.... where Pi is a standard user-defined identifier (referred to in this section as a parameter name) Ci is any type of constant (including literals) except a label or complex constant. (Refer to Chapter 3 for a description of FORTRAN constants.) During compilation the parameter names are replaced by their associated constants proVided the following rules are observed: a. Parameter names appear only within the statement field of an initial or continuation line type, i.e., not within a comment line or literal text. b. Parameter names are placed only where FORTRAN constants are acceptable. c. Parameter name references appear after the PARAMETER statement definition. d. Parameter names are unique with respect to all other names in the program unit. e. Parameter names are not redefined in subsequent PARAMETER statements. f. Parameter names are not used as part of some larger syntactical construct (such as a Hollerith constant count, or a data type size modifier). 6-8 DATA Statement CHAPTER 7 DECsyslcm-20 FORTRAN extensions to the 1966 ANSI sr.lIIdard set arc printed in boldface italic type. CHAPTER 7 DATA STATEMENT 7.1 INTRODUCTION DATA statements are used to supply the initial values of variables, arrays, array elements, and labeled common.) DATA statements are written in the following form: DATA List IIData II,List 2/Data 2/, . .. ,List nlData nl where the List portion of each ListlDatal pair identifies a set of items to be initialized and the /Datal portion contains the list of values to be assigned the items in the List. For example, the statement DATA IA/S/,IB/IOI,IC/ISI initializes variable IA as the value 5, variable IB as the value 10 and the variable IC as the value IS. The number of storage locations specified in the list of variables must be less than or equal to the number of storage locations specified in its associated list of values. If the list of variables is larger (specifies more storage locations) than its associated value list, a warning message is output. When the value list specifies more storage locations than the variable list the excess values are ignored. The List portion of each ListlDatal set may contain the names of one or more variables, arrays, array elements, or labeled common variables. An entire array (unsubscripted array name) or a portion of an array may be specified in a DATA statement List as an implied DO loop construct (see Paragraph /0.3.4.1 for a description of implied DO loops). For example, the statement DATA (NARY (1).1=1.5}/1.2.3.4.5/ initializes the first five elements of array NARY as NARY(J)=I. NARY(2)=2. NARY(3)=3. NARY(4)=4. NARY(5)=5. When an implied DO loop is used in a DATA statement. the loop index variable must be of type INTEGER and the loop Initial. Terminal. and Increment parameters must also be of type INTEGER. In a DATA statement. references to an array element must be integer expressions in which all terms are either integer constants or indices of embracing implied DO loops. Integer expressions of the foregoing types cannot include the exponentiation operator. 1 Refer to Paragraph 6.5 for a description of labeled common. 7-1 CHAPTER 7 DATA Statement The /Data/ portion of each List/Data/ set may contain one or more numeric, logical, literal, or octal constants and/or alphanumeric strings. Octal constants must be identified as octal by preceding them with a double quote (") symbol (e.g., "777). Literal data may be specified as either a Hollerith specification (e.g., 5HABCDE), or a string enclosed in single quotes (e.g., 'ABCDE'). Each ASCII datum is stored left-justified and is padded with blanks up to the right boundary of the variable being initialized. When the same value is to be assigned to more than one item in List, a repeat specification may be used. The repeat specification is written as N*D where N is an integer that specifies how many times the value of item D is to be used. For example, a /Data/ specification of /3 *20/ specifies that the value 20 is to be assigned to the first three items named in the preceding list. The statement DATA M,N,L/3*20/ assigns the value 20 to the variables M, N, L. In instances where the type of the data specified is Ilot the same as that of the variable to which it is assigned, DECsystem-20 FORTRAN COil verts the datum to the type of the variable. The type conversion is performed using the roles givell for type conversioll ill arithmetic assignmellts (refer to Olapter 8, Table 8-1). Octal, logical, and literal conslallts are Ilot converted. Sample Statement DATA PRINT,I,O/'TEST',30,"77/,TAB(J), J=I,30/30*5 Use The first 30 elements of array TAB are initialized as 5.0. DATA ((A(I,J),I=1 ,5),J=1 ,6)/30* 1.0/ No conversion required. DATA ((A(I,J),I=5,10),J=6,15)/60*2.0/ No conversion required. When a literal string is specified which is longer than one variable can hold, the string will be stored left-justified across as many variables as are needed to hold it. If necessary, the last variable used will be padded with blanks up to its right boundary. Example Assuming that X, Y, and Z are single precision, the statement DATA X,Y,Z/'ABCDEFGHIJKL'/ will cause X to be initialized to 'ABCDE' Y to be initialized to 'FGHIJ' Z to be initialized to 'KL¥¥¥' When a literal string is to be stored in double precision and/or complex variables and the specified string is only one word long, the second word of the variable is padded with blanks. 7-2 CHAPTER 7 DATA Statement Example Assuming that the variable C is complex, the statement DATA C/'ABCDE','FGHIJ'/ will cause the first word of C to be initialized to 'ABCDE' and its second word to be initialized to string 'FGHIJ' is ignored. 7-3 '~~~~~'. The CHAPTERS Arithmetic Assignment Statements DECsystem-20 FORTRAN extensions to the 1966 ANSI standard set are printed in boldface italic type. CHAPTER 8 ASSIGNMENT STATEMENTS 8.1 INTRODUCTION Assignment statements are used to assign a specific value to one or more program variables. There are three kinds of assignment statements: a. Arithmetic assignment statements b. Logical assignment statements c. Statement Label assignment (ASSIGN) statements. 8.2 ARITHMETIC ASSIGNMENT STATEMENT Statements of this type are used to assign specific numeric values to variables and/or array elements. Arithmetic assignment statements are written in the form v=e where v is the name of the variable or array element which is to receive the specified value and e is a simple or compound arithmetic expression. In assignment statements the equals symbol (=) does not imply equality as it would in algebraic expressions; it implies replacement. For example, the expression v=e is correctly interpreted as "the current contents of the location identified as v are to be replaced by the final value of expression e; the current contents of v are lost." When the type of the specified variable or array element name differs from that of its assigned value, FORTRAN converts the value of the type of its assigned variable or array element. The type conversion operations performed by FORTRAN for each possible combination of variable and value types are described in Table 8-1. 8-1 Mixed Mode Conversion Table CHAPTERS Table 8-1 Rules for Conversion in Mixed Mode Assignments Real Integer Variable Type (v) Double Precision Complex Logical REAL D C R,I H,L D INTEGER C D R,C,I H,C,L D COMPLEX R C,R D DOUBLE PRECISION H C,H,L LOGICAL D D OCTAL D LITERAL DOUBLE OCTAL* Expression Type (e) R D H R,I H,L D,H D R,I H,C,L D D,H*** C,H*** D** D** D*** H H D**** D H Legend D = Direct replacement C = Conversion between integer and floating-point with truncation R = Real part only I = Set imaginary part to 0 H = High order only L = Set low order part to 0 Notes * Octal numbers comprised of from 13 to 24 digits are termed double octal. Double octals require two storage locations. They are stored right-justified and are padded with zeroes to fill the locations. ** Use the first two words of the literal. If the literal is only one word long, the second word is padded with blanks. *** Use the first word of the literal. **** To convert double octal numbers to complex, the low order octal digits are assumed to be the imaginary part and the high order digits are assumed to be the real part of the complex value. 8-2 Logical Assignment Statements, ASSIGN Statements CHAPTERS 8.3 LOGICAL ASSIGNMENT STATEMENTS This type of assignment statement is used to assign values to variables and array elements of type logical. The logical assignment statement is written in the form v=e where v is one or more variables and/or array element names and e is a logical expression. Examples Assuming that the variables L, F, M, and G are of type logical, the following statements are valid: Sample Statement L=.TRUE. The contents of L are replaced by logical truth. F=.NOT.G The contents of L are replaced by the logical complement of the contents of G. M=A>T If A is greater than T, the contents of M are replaced by logical truth; if A is less than or equal to T, the contents of Mare replaced by logical false. L=«(I.GT.H).AND.(J < =K» The contents of L is replaced by either the true or false resultant of the expression. 8.4 ASSIGN (STATEMENT LABEL) ASSIGNMENT STATEMENT The ASSIGN statement is used to assign a statement label constant (i.e., a 1- to 5-digit statement number) to a variable name. The ASSIGN statement is written in the following form ASSIGN n TO I where n represents the statement number and I is a variable name. For example, the statement ASSIGN 2000 TO LABEL specifies that the variable LABEL represents the statement number 2000. With the exception of complex and double precision, any type of variable may be used in an ASSIGN statement. Once a variable has been assigned a statement number, FORTRAN considers it a label variable. If a label variable is used in an arithmetic statement, the results are unpredictable. The ASSIGN statement is used in conjunction with assigned GO TO control statements (Chapter 9); it sets up statement label variables which are then referenced in subsequent GO TO control statements. The following sequence illustrates the use of the ASSIGN statement: 8-3 ASSIGN Statement CHAPTERS 555 TAX=(A+B+C)* .05 ASSIGN 555 TO LABEL GO TO LABEL 84 GO TO Statements CHAPTER 9 DEC-system-20 FORTRAN extensions to the 1966 ANSI standard set are printed in boldface italic type. CHAPTER 9 CONTROL STATEMENTS 9.1 INTRODUCTION DECsystem-20 FORTRAN object programs are normally executed statement-by-statement in the order in which they were presented to the compiler. The following source program control statements, however, enable the user to alter the normal sequence of statement execution: a. GO TO b. IF c. DO d. CONTINUE e. STOP f. PAUSE 9.2 GO TO CONTROL STATEMENTS There are three kinds of GO TO statements: a. Unconditional b. Computed c. Assigned. A GO TO control statement causes the statement which it identifies to be executed next, regardless of its position within the program. Each type of GO TO statement is described in the folloWing paragraphs. 9-1 Unconditional, Computed and Assigned GO TO Statements CHAPfER9 9.2.1 Unconditional GO TO Statements GO TO statements of this type are written in the form GOTOn where n is the label (i.e., statement number) of an executable statement (e.g., GO TO 555). When executed, an unconditional GO TO statement causes control of the program to be transferred to the statement which it specifies. An unconditional GO TO statement may be positioned anywhere in the source program except as the terminating statement of a DO loop. 9.2.2 Computed GO TO Statements GO TO statements of this type are written in the form GO TO (Nl,N2, ...,Nk)E where the parenthesized list is a list of statement numbers and E is an arithmetic expression. Any number of statement numbers may be included in the list of this type of GO TO statement; however, each number given must be used as a label within the program or subprogram containing the GO TO statement. NOTE A comma may optionally follow the parenthesized list. The value of the expression E must be reducible to an integer value that is greater than 0 and less than or equal to the number of statement numbers given in the statement's list. If E does not compute within the foregoing range, the next statement is executed. When a computed GO TO statement is executed, the value of its expression (i.e., E) is computed first. The value of E specifies the position within the given list of statement numbers, of the number which identifies the statement to be executed next. For example, in the statement sequence GO TO (20, lO, 5)K CALL XRANGE(K) the variable K acts as a switch causing a transfer to statement 20 ifK=l, to statement 10 ifK=2, or to statement 5 if K=3. The subprogram XRANGE is called if K is less than 1 or greater than 3. 9.2.3 Assigned GO TO Statements GO TO statements of this type may be written in either of the following forms: GOTOK GO TO K, (Ll,L2, ...,Ln) where K is a variable name and the parenthesized list of the second form contains a list of statement labels (i.e., statement numbers). The statement numbers given must be within the program or subprogram containing the GO TO statement. 9-2 Arithmetic IF Statements CHAPTER 9 Assigned GO TO statements of either of the foregoing forms must be logically preceded by an ASSIGN statement that assigns a statement label to the variable name represented by K. The value of the assigned label variable must be in the same program unit as the GO TO statement in which it is used. In statements written in the form GO TO K, (Ll ,L2,... ,Ln) if K is not assigned one of the statement numbers given in the statement's list, then the next sequential statement is executed. Examples GO TO STATl GO TO STATl, (177,207,777) 9.3 IF STATEMENTS There are three kinds of IF statements: arithmetic, logical, and logical two-branch. 9.3.1 Arithmetic IF Statements IF statements of this type are written in the form IF (E) Ll, L2, L3 where (E) is an expression enclosed within parcnthesis and Ll, L2, L3 are the labels (i.e., statement numbers) of three executable statements. This type of IF statement causes control of the program to be transferred to one of the given statements, according to the computed value of the given expressions. If the value of the expression is: a. less than 0, control is transferred to the statement identified by Ll; b. equal to 0, control is transferred to the statement identified by L2; c. greater than 0, control is transferred to the statement identified by L3. All three statement numbers must be given in arithmetic IF statements; the expression given may not compute to a complex valuc. Examples Sample Statement IF (ET A)4, 7, 12 IF (KAPPA - L{10)) 20,14, 14 Transfer control to statement 4 if ETA is negative, to statement 7 if ETA is 0 and to statement 12 if ETA is greater than O. Transfer control to statement 20 if KAPPA is less than the 10th element of array L and to statement 14 if KAPPA is greater than or equal to the 10th element of array L. 9-3 Logical and Logical Two-Branch IF Statements, DO Statements CHAPTER 9 9.3.2 Logical IF Statements IF statements of this type are written in the form IF (E) S where E is any expression enclosed in parentheses and S is a complete executable statement. Logical IF statements cause control of the program to be transferred either to the next sequential executable statement or the statement given in the IF statement (i_e., S) according to the computed logical value of the given expression. If the value of the given logical expression is true (negative), control is given to the executable statement within the IF statement. If the value of the expression is false (positive or zero), control is transferred to the next sequential executable program statement. The statement given in a logical IF statement may be any DECsystem-20 FORTRAN executable statement except a DO statement or another logical IF statement. Examples Sample Statement IF (T.OR.S) X = Y + 1 An arithmetic replacement operation is performed if the result of IF is true. IF (Z.GT.x(K)) CALL SWITCH (S,Y) A subprogram transfer is performed if the result of IF is true. IF (K.EQ.INDEX) GO TO 15 An unconditional transfer is performed if the result of IF is true. 9.33 Logical Two-Branch IF Statements IF statements of this type are written in the form IF (E) NI, N2 where E is any expression enclosed in parentheses and N1 and N2 are statement labels defined within the program unit. Logical two-branch IF statements cause control of the program to be transferred to either statement N1 or N2 depending on the computed value of the given expression. If the value of the given logical expression is true (negative), control is transferred to statement N1. If the value of the expression is false (positive or zero), control is transferred to statement N2. Note that the statement immediately fol/owing the logical two-branch IF must be numbered so that control can later be transferred to the portion of code that mlS skipped. EXIlmples Sample Statement IF (LOGl) 10,20 IF (A.LT.B.AND.A.LT.C) 31,32 Transfer control to statement 10 if LOG1 is negative; otherwise transfer control to statement 20. Transfer control to statement 31 if A is less than both Band C; transfer control to statement 32 if A is greater than or equal to either B or C. 94 DO Statement Parameters, Nested DO's CHAPTER 9 9.4 DO STATEMENT DO statements simplify the coding of iterative procedures; they are written in the following form: Indexing Parameters ~:.7:iZ MI'1'~:~::~:: = label Index Variable Terminal Parameter -;-In~i'-:-ti-:al-- Parameter where a. Terminal Statement Label N is the statement number of the last statement of the DO statement range. The range of a DO statement is defined as the series of statements which follows the DO statement up to and including its specified terminal statement. b. Index Variable I is an unsubscripted variable, the value of which is defined at the start of the DO statement operations. The index variable is available for use throughout each execution of the range of the DO statement but its value should not be altered within this range. It is also made available for use in the program when 1. control is transferred outside the range of the DO loop by a GO TO, IF, or RETURN statement located within the DO range, 2. a CALL is executed from within the DO statement range which uses the index variable as an argument, and 3. if an Input-Output statement with either or both the options END= or ERR= (Chapter 10) appear within the DO statement range. c. Initial Parameter M 1 assigns the index variable, V, its initial value. This parameter may be any variable, array element, or expression. d. Terminal Parameter M2 provides the value which determines how many repetitions of the DO statement range are performed. e. Increment Parameter M3 specifies the value to be added to the initial parameter (M I) on completion of each cycle of the DO loop. An indexing parameter may be any arithmetic expression which should result in either a positive or negative value. The values of the indexing parameters are calculated only once, at the start of each DO-loop operation. The number of times that a DO loop will be executed is specified by the formula: (M2-MI)/M3+1 9-5 CHAFfER 9 DO Statement, Nested DO's Since the count is computed at the start of a DO loop operation, changing the value of the loop index variable within the loop cannot affect the number of times that the loop is executed. At the start of a DO loop operation, the index value is set to the value of the initial parameter (MI) and a count variable (generated by the compiler) is set to the negative of the calculated count. At the end of each DO loop cycle the value of the increment parameter (M3) is added to the index variable and the count variable is incremented. If the number of specified iterations have not been performed, another cycle of the loop is initiated. One execution of a DO loop range is always performed regardless of the initial values of the index variable and the indexing parameters. Exit from a DO loop operation on completion of the number of iterations specified by the loop count is referred to as a normal exit. In a normal exit, control is passed to the first executable statement after the DO loop range terminal statement and the value of the DO statement index variable is considered undefined. Exit from a DO loop may also be accomplished by a transfer of control by a statement within the DO loop range to a statement outside the range of the DO statement (paragraph 9.4.3). ' 9.4.1 Nested DO Statements One or more DO statements may be contained (i.e., nested) within the range of another DO statement. The following rules govern the nesting of DO statements. a. The range of each nested DO statement must be entirely within the range of the containing DO statement. Example Valid Invalid DO 1 DO 1 ~ ~ ~ b. The range of DO 2 is outside that of DO 1. The ranges of nested DO statements cannot overlap. Example Valid Invalid DO 1 DO 1 D02 I D03 D02 ~ 9·6 The ranges of loop DO 2 and DO 3 overlap. DO Statement, Extended Range and Transfer Operations CHAPTER 9 c. More than one DO loop within a nest of DO loops may end on the same statement. When this occurs, the terminal statement is considered to belong to the innennost DO statement that ends on that statement. The statement label 4 of the shared terminal statement cannot be used in any GO TO or arithmetic IF statement that occurs anywhere but within the range of the DO statement to which it belongs. Example D04 All the DO statements share the same terminal statement, however, it belongs to DO 4. D04 D04 D04 I 9.4.2 Extend Range The extended range of a DO statement is defined as the set of statements that are executed between the transfers out of the innermost DO statement of a set of nested DO's and the transfer back into the range of this innermost DO statement. The extended range of a nested DO statement is illustrated as follows: DO I D02 D03 - -....- - (out)--~ Extended Range 9-7 DO Statement Transfers, CONTINUE Statement CHAYfER9 The following rules govern the use of a DO statement extended range: a. The transfer out statement for an extended range operation must be contained by the most deeply nested DO statement that contains the location to which the return transfer is to be made. b. A transfer into the range of a DO statement is permitted only if the transfer is made from the extended range of that DO statement. c. The extended range of a DO statement must not contain another DO statement. d. The extended range of a DO statement cannot change the index variable or indexing parameters of the DO statement. e. The use of and return from a subprogram from within an extended range is permitted. 9.4.3 Permitted Transfer Operations The transfer of program control from within a DO statement range or the ranges of nested DO statements is governed by the following rules: a. A transfer out of the range of any DO loop is permitted at any time. When such a transfer is executed the value of the controlling DO statement's index variable is defined as the current value. b. A transfer into the range of a DO statement is permitted if it is made from the extended range of the DO statement. c. The use of and return from a subprogram from within the range of any DO loop, nested DO loop, or extended range is permitted. The following examples illustrate the transfer operations permitted from within the ranges of nested DO statements. Valid Transfers DI [ D2 . , extended range ;)_.- Invalid Transfers DI 9-8 STOP Statement CHAPTER 9 9.5 CONTINUE STATEMENT CONTINUE statements may be placed anywhere in the source program without affecting the program sequence of execution. CONTINUE statements are commonly used as the last statement of a DO statement range in order to avoid ending with a GO TO, PAUSE, STOP, RETURN, arithmetic IF, another DO statement, or a logical IF statement containing any of the foregoing statements. This statement is written as 12 CONTINUE Example In the following sequence the labeled CONTINUE statement provides a legal termination for the range of the DO loop. 45 DO 45 ITEM=I,lOOO STOCK=NVNTRY (ITEM) CALL UPDATE (STOCK, TALLY) IF (ITEM.EQ.LAST) GO TO 77 CONTINUE 77 PRINT 20, HEADNG,PAGE NO 9.6 STOP STATEMENT When executed, the STOP statement causes the execution of the object program to be terminated and the user returned to command level. A descriptive message may, optionally, be included in the STOP statement to be output to the user's I/O terminal immediately before program execution is terminated. This statement may be written as STOP STOP 'N' or STOPn where 'N' is a string of ASCII characters enclosed by single quotes and n is an octal string up to J2 digits. The string N or the value n is printed at the user's I/O terminal when the STOP statement is executed; it may be of any length, continuation lines may be used for large messages. Examples STOP 'Termination of the Program' or STOP 7777 9-9 CHAPTER 9 PAUSE Statement, TRACE Option 9.7 PAUSE STATEMENT When executed, a PAUSE statement causes a suspension of the execution of the object program and gives the user the option to: a. Continue execution of the program b. Exit c. Initiate a TRACE operation (Paragraph 9.7.1). The permitted forms of the PAUSE statement are: a. PAUSE b. PAUSE 'literal string' c. PAUSE n, where n is an octal string up to 12 digits. The execution of a PAUSE statement of any of the foregoing forms causes the standard instruction: 1YPE G TO CONTINUE, X TO EXIT, T TO TRACE to be printed at the user's terminal. If the form of the PAUSE statement contains either a literal string or an integer constant, the string or constant is printed on a line preceding the standard message. For example, the statement PAUSE 'TEST POINT A' causes the following to be printed at the user's terminal: TEST POINT A 1YPE G TO CONTINUE, X TO EXIT, T TO TRACE The statement PAUSE 1 causes the following to be printed at the user's terminal: PAUSE 000001 1YPE G TO CONTINUE, X TO EXIT, T TO TRACE 9.7.1 T (TRACE) Option The entry of the character T in response to the message output by the execution of a PAUSE statement starts a TRACE routine. This routine causes the printing, at the user's terminal, of a complete history of all subroutine calls made during the execution of the program, up to the execution of the PAUSE statement. The history printed by the TRACE routine consists of: a. The names of all subroutines called, arranged in the reverse order of their call; b. The absolute location (written within parentheses) of the called subroutine; c. The name of the calling subroutine plus an offset factor and the absolute location (written within parentheses) of the statement within the routine which initiated the call; 9-10 CHAPTER 9 PAUSE Statement, TRACE Option d. The number of arguments involved (written within angle brackets); e. An alphabetic code (written within square brackets) that specifies the type of each argument involved. The alphabetic codes used and the meaning of each are: Code Character U L I F o S D C K Type Specified Undefined type; the use of the argument will determine its type. Logical INTEGER Single precision REAL Octal Statement Number Double precision REAL COMPLEX A literal or constant Exomple The following printout illustrates the execution of the PAUSE statement "PAUSE 'TEST POINT A "', the entry of a T character to initiate the TRACE routine, the resulting trace printout, and the entry of the character G to continue the execution of the program. IESI POINI A IYPE' IO CONIINUE, X IO EXII, I IO IftACE. *I (LOC) «--- CALLEft (LOC)[AR' IYPES} NAME MAIN.+'12(la32) <11> [Ul IRACE. (~11'53) IYPE G IO CONIINUE, X IO EXII, I IO IftACE. «--- *G In addition to its use with the PAUSE statement, the TRACE routine may be called directly, using the form CALL TRACE or as a function, using the form X = TRACE (x) Execution of the foregoing statements starts the TRACE routine which causes the printing of the history of all subprogram calls made during the execution of the program, up to the execution of the CALL statement, or up to the execution of the function, respectively. The history printed by the TRACE routine under these circumstances is exactly the same as described in the preceding paragraph. 9-11 Data Transfer Operations and Modes CHAPTER 10 DEC-system-20 FORTRAN extension to the 1966 ANSI standard set are prin ted in boldface italic type. CHAPTER 10 1/0 STATEMENTS 10.1 DA T A TRANSFER OPERATIONS FORTRAN I/O statements permit data to be transferred between processor storage (memory) and peripheral devices and/or between storage locations. Data in the form of logical records may be transferred using an a) sequential, b) random access, or c) append transfer mode. The areas in core from which data is to be taken during output (write) operations and into which data is stored during input (read) operations are specified by a. a list in the I/O statement which initiated the transfer b. a list defined by a NAMELIST statement, or c. between a specified FORMAT statement and the external medium. The type and arrangement of transferred data may be specified by format specifications located in either a FORMAT statement or an array (formatted I/O) or by the contents of an I/O list (i.e., list-directed I/O). The transfer modes, I/O lists, type conversion and arrangement of data, and the statements required to initiate I/O transfer operations are described in the foil owing paragraphs. 10.2 TRANSFER MODES The characteristics and requirements of the a) sequential, b) random access, and c) append data modes are described in the following paragraphs. 10.2.1 Sequential Mode Records are transferred during a sequential mode of operation in the same order as they appear in the external data file. Each I/O statement executed in a sequential mode transfers the record immediately following the last record transferred from the accessed source file. 10.2.2 Random Access Mode This mode permits records to be accessed and transferred from a file in any desired order. Random access transfers, however, may be made only to (or from) a device that permits random-type data addressing operations (i.e., disk) and to files that have previously been set up for random access transfer operation. Files for random access must contain a specified number of identically sized records that may be accessed, individually, by a record number. 10-1 Append Mode, I/O Statements Form and Components CHAPTER 10 The OPEN statement or a subroutine calf to DEFINE FILE may be used to set up random access files. The OPEN statement is used to establish a random access mode to permit the execution of random access data transfer operations. The OPEN statement should logically precede the first I/O statement for the specified logical unit in the user source program. /0.2.3 Append Mode This mode is a special version of the sequential transfer mode: it may be used only for sequential output (write) operations. The append mode permits the user to write a record immediately after the last logical record of the accessed file. During an append transfer, the records already in the accessed file remain unchanged, the only function performed is the appending of the transferred records to the end of the file. An OPEN statement (Chapter /2) must be used to establish an append mode before append I/O operations can be executed. 10.3 I/O STATEMENTS, BASIC FORMATS AND COMPONENTS The majority of the I/O statements described in this chapter are written in one of the following basic forms, or in some modification of these forms: Basic Statement Forms Keyword (u,f)list Keyword (u#R,f)list Keyword (u, *)list Keyword (u,N) Keyword (u)list Keyword (u#R)list Use Fonnatted I/O Transfer Random Access Formatted I/O Transfer List-Directed I/O Transfer NAMELIST-Controlled I/O Transfer Binary I/O Transfer Random Access Binary I/O Transfer where Keyword the statement name (i.e., READ or WRITE) u logical unit number f FORMAT statement number or the name of an array that contains the desired format specifications list I/O list #R = the delimiter # followed by the number of a record in an established random-access file * = symbol specifying a list-directed I/O transfer. N the name of an I/O list defined by a NAMELIST statement. Details of the foregoing statement components are given in the following paragraphs. 10-2 I/O Statements Key Word, Logical Unit Numbers and FORMAT References CHAPTER 10 10.3.1 I/O Statement Keywords The keywords (i.e., names) of the DECsystem-20 FORTRAN I/O statements described in this chapter arc: a. READ b. REREAD c. WRITE d. ACCEPT e. PRINT f. TYPE g. FIND h. ENCODE i. DECODE j. DECODE 10.3.2 Logical Unit Numbers The physical devices used for most FORTRAN I/O operations are identified by decimal numbers. During compilation, the compiler assigns default logical unit numbers for the REREAD, READ, ACCEPT, PRINT, and TYPE statements. Default unit numbers are negatively signed decimal numbers that are inaccessible to the user. The logical device assignments may be made by the user at run time or the standard assignments contained by the FORTRAN Object Time System (FOROTS) may be used. The standard logical device assignments are listed in Table 10-1. It is recommended that the user specify the device explicitly in the OPEN statement. 10.3.3 FORMAT Statement References A FORMAT statement contains a set of format specifications which define the structure of a record and the form of the data fields which comprise the record. Format specifications may also be stored in an array rather than in a FORMAT statement. (Refer to Chapter 13 for a complete description of the FORMAT statement.) The execution of an I/O statement that includes either a FORMAT statement number or the name of an array which contains format specifications causes the structure and data of the transferred record to assume the form specified in the referenced statement or array. Records transferred under the control of a format specification are referred to as "formatted" records. Conversely, records transferred by I/O statements that do not reference a format specification are referred to as ''unformatted'' records. During unformatted transfers, data is transferred on a one-to-one correspondence between internal (processor) and external (device) locations, with no conversion or formatting operations. Unformatted files are binary files divided into records by DECsystem-20 FORTRAN embedded con tral words; the control words arc invisible to the user. Files of this type cannot be prepared by the user without utilizing FOROTS. Unformatted files arc intended to be used only within the DECsystem-20 FORTRAN environment. 10-3 CHAPTER 10 I/O Lists, Implied DO Constructs 10.3.4 I/O List An I/O list specifies the names of variables, arrays, and array elements to which input data is to be assigned or from which data is to be output. Implied DO constructs (paragraph 10.3.4.1), which specify specific sets of array elements, may also be included in I/O lists. The number of items in a statement's list determines the amount of data to be transferred during each execution of the statement. 10.3.4.1 Implied DO Constructs - When an array name is given in an I/O list all elements of the array are transferred in the order described in Chapter 3 (paragraph 3.5.3). If only a specific set of array elements is involved, they may be specified in the I/O list either individually or in the form of an implied DO construct. Implied DO's are written within parentheses in a format similar to that of DO statements. They may contain one or more variable, array, and/or array element names, delimited by commas and followed by indexing parameters that are defined as for DO statements. The general form of an implied DO is (name(SL),I=M 1,M2,M3) where name SL an array name = the subscript list of an array name or an array element identifier the index control variable that represents a subscript appearing in a preceding subscript list Ml,M2,M3 the indexing parameters that specify, respectively, the initial, terminal, and increment values that control the range of I. If M3 is omitted (with its preceding comma), a value of 1 is assumed. Examples (A(S),S=1,5) Specifies the first five elements of the one-dimension array A (i.e., A(I), A(2), A(3), A(4), A(5». (A(2,S),S=1,10,2) Specifies the elements A(2,1), A(2,3), A(2,5), A(2,7), A(2,9) of array A. As stated previously, implied DO constructs may also contain one or more variable names. Example I, J, B, and C must be integer variables. «A(B,C),B=I,1 O),C=1 ,1 O),I,J Specifies a lOX 10 set of elements of array A, the location identified by I and the location identified by J. Implied DO constructs may also be nested. Nested implied DO's may share one or more sets of indexing parameters. Example «A(J ,K),J= 1,5),D(K),K=1,1 0) Specifies a 5 X 10 set of elements of array A and the first 10 elements of array D. 10-5 CHAPTER 10 Records For Random Access, List-Directed I/O When an array or set of array elements are specified as either a storage or transmitting area for I/O purposes, the array elements involved are accessed in ascending order with the value of the first subscript quantity varying most rapidly and the value of the last given subscript increasing to its maximum value least rapidly_ For example, the elements of an array dimensional as T AB(2,3) are accessed in the order: TAB(I,l) TAB(2,1) TAB(I,2) TAB(2,2) TAB(l,3) TAB(2,3) 1035 The Specification of Records for Random Access Records to be transferred in a random access mode must be identified in an I/O statement by an integer expression or variable preceded by a 'delimiter (e.g., '1OJ). NOTE A number sign (#) may he used in place of the 'delimiter (e.g., hoth #101 and ']0] are accepted by DECsystem-20 FORTRAN). 10.3.6 List-Directed I/O The use of an asterisk in an I/O statement in place of a FORMAT statement number causes the specified transfer operation to be "list-directed." In a Iist-directed transfer, the data to be transferred and the type of each transferred datum are specified by the contents of an I/O list included in the I/O command used. The transfer of data in this mode is performed without regard for column, card, or line boundaries. The Iist-directed mode is specified by the substitution of an asterisk (*) for the FORMA T statement reference (i.e., f) of an I/O statement. The general form of a list-directed I/O statement is keyword (u, *)list Example READ (5, *)IJAB,M,L List-directed transfers may be used to input data from any acceptable input device including an input keyboard terminal. NOTE Device positioning commands, such as BACKSPACE, SKIP RECORD, etc., should not be used in conjunction with list-directed I/O operations. If such a combination is used, the results will be unpredictable. Data for list-directed transfers should consist of alternate constants and delimiters. The constants used should have the following characteristics: a. Input constants must he of a type acceptable to DEC~ystem-20 FOR TRAN. Octal constants, although acceptable, are not permitted in list-directed I/O operations. b. Literal constants must be enclosed within single quotes (e.g., 'ABLE'). 10-6 CHAPTER 10 List-Directed I/O c. Blanks serve as delimiters; therefore, they are not permitted in any but literal constants. d. Decimal points may be omitted from real constants which do not have a fractional parI. FORTRAN assumes tllat the decimal point follows the right-most digit of a real constant. Delimiters in data for list-directed input must comply with the following: a. Delimiters may be either commas or blanks. b. Delimiters may be either preceded by or followed by any number of blanks, carriage return/line feed characters, tabs, or line terminators; any such combination is considered by FORTRAN as being only a single delimiter. c. A null, the complete absence of a datum, is represented by two consecutive commas which have no intervening constant(s). Any number of blanks, tabs, carriage return/line feed characters, or end-of-input conditions may be placed between the commas of a null. Each time a null item is specified in the input data, its corresponding list element is skipped (i.e., unchanged). The following illustrates the effect of a null input: INPUT Items Corresponding I/O List Items ReSUlting Contents of List Items 101, 'A', tab, 'NOl', + ++ + ~ ~ ~ ~ 101. A un- N01 A ,LlT,/AB,NUA:BER changed lAB d. Slashes (/) cause the current input operation to be terminated even if all the items of the directing list are not filled. n,e contents of items of the directing I/O list which either are skipped (by null inputs) or have not received an input datum before the transfer is terminated remain unchanged. Once the I/O list of the control/ing I/O statement is satisfied, the use of the / delimiter is optional. e. Once the 1/0 list has been satisfied (transfers have been made to each item of the list) any items remaining in the input record are skipped. Constants or nulls in data for list-directed input may be assigned a repetition factor to cause an item to be repeated. The repetition of a constant is written as r*K where r is an integer constant that specifies the number of times the constant represented by K is to be repeated. The repetition of a null is written as an integer followed by an asterisk. Examples 10*5 3*'ABLE' 3* represents 5,5,5,5,5,5,5,5,5,5 represents 'ABLE', 'ABLE', 'ABLE' represents null,null,null 10-7 NAMELIST I/O CHAPTER 10 10.3.7 NAMELIST I/O Lists One or more lists may be defined by a NAMELIST statement (Chapter 11). Each I/O list defined in a NAMELIST statement is identified by a unique (within the routine) 1 to 6 character name that may be referenced by one or more READ or WRITE statements. The first character of each I/O list name must be alphabetic. Referencing a NAMELIST-defined I/O list enables any of the foregoing statements to be written without an I/O list and permits the same list to be used by more than one statement. I/O statements which reference a NAMELIST-defined I/O list cannot contain either a FORMAT statement reference or an I/O list. NAMELIST-controlled 1/0 operation cannot be used to transfer octal numbers or literal strings. Records for NAMELIST-controlled input operations must be formatted in the following manner: $NAME D1,D2,D3. . .Dn$ where a. $ symbols delimit the beginning and end of the record. The first $ must be in column 2 of the input record; column 1 must be blank. b. NAME is the name of a NAMELIST-defined input list. The named list identifies the processor storage locations that are to receive the data items read from the accessed record. c. DI through Dn are values of the items of data contained by the record; these items cannot be octal numbers or literal strings. Only NAMELIST-controlled READ statements may be used to input records formatted in the foregoing manner. NAMELIST-controlled WRITE statements will output records in the foregoing format. NOTE Device positioning commands such as BACKSPACE, SKIP RECORD, etc., should not be used in conjunction with NAMELIST-controlled I/O operations. If such a combination is used, the results are unpredictable. 10.4 OPTIONAL READ/WRITE ERROR EXIT AND END-OF-FILE ARGUMENTS Either or both an error exit or an end-of-file argument may, optionally, be added to the parenthesized portion of most forms of the READ and WRITE I/O statements. The error exit argument is written as ERR=c where c is a statement number. The use of this argument causes the current I/O operation to be terminated and program control transferred to the statement identified by the argument if a device error is detected. For example, the detection of an error during the execution of READ(JO,77,ERR=IOI)TABLE,I,M,J terminates the input operation and transfers program control to statement 101. 10-8 Sequential Formatted READ Statements CHAPTER 10 The end-of-file argument is written as END=d where d is a statement number. The use of this argument causes the current I/O operation to be terminated and program control to be transferred to the statement identified by the argument when an end-of-file condition is detected. For example, the detection of an end-of-file condition during the execution of READ(l 0, n,END=50)TABLEJ,M,J transfers program control to statement 50. If the END= argument is not present and an end of file (EOF) condition is detected, the file is closed, program execution is terminated, and the user is returned to command level. 10.5 READ STATEMENTS READ statements transfer data from peripheral devices into specified processor storage locations. The permitted forms of this type of input statement permit READ statements to be used on both sequential and random access transfer modes for formatted, unformatted, list-directed, and NAMELIST-controlled data transfers. 10.5.1 Sequential Fonnatted READ Transfers Descriptions of the READ statements that may be used for the sequential transfer of formatted data follow: a. b. c. Form: READ (u,f}list Use: Input data from logical unit u, formatted according to the specifications given in f, into the processor storage locations identified in input list. Example: READ (I O,555)TABLE( IO,20),ABLE,BAKER,CHARL Form: READ (u,f) Use: Input the data from logical unit u directly into either a Hollerith (H) field descriptor or a literal field descriptor given within the format specifications of the referenced FORMAT statement. If the referenced FORMAT statement does not contain either of the foregoing types of format field descriptors, the input record is skipped. If a required field descriptor is present, its contents are replaced by the inrut data. Example: READ(I5,101) Form: READf Use: Input the data from the READ default device (card reader) directly into either a Hollerith (H) field descriptor or a literal field descriptor given within the format specifications of the referenced FORMAT statement. If the referenced FORMAT statement does not contain either of the foregoing types of format field descriptors, the input record is skipped. If a required field descriptor is present, its contents are replaced by the input data. Example: READ 66 10·9 Sequential Binary and List-Directed READ Statements CHAPTER 10 d. Form: READ f, list Use: Input the data from the READ default device (card reader) into the processor storage locations identified in the input list. The input data is formatted according to the specifications given in f. Example: READ 15, ARRAY (20,30) 10.5.2 Sequential Unformatted Binary READ Transfers Only the following form of the READ statement may be used for the sequential transfer of unformatted input FORTRAN binary data: Form: READ (u)list Use: Input one logical record of data from logical unit u into processor storage as the value of the location identified in list. Only binary files that have been output by a DECsystem-20 FORTRAN unformatted WRITE statement may be read by this type of READ statement. NOTE If the form READ (u) is used, it will cause one unformatted input record to be skipped. Example: READ (10) BINFIL (10,20,30) /0.5.3 Sequential List-Directed READ Transfers The following forms of the READ statements may be used to control a sequential, list-directed input transfer: a. b. Form: READ (u, *)list Use: Input data from logical device u into processor storage or the value of the locations identified in list. Each input datum is converted, if necessary, to the type of its assigned list variable. Example: READ (10, *) IARY (20,20), A,B,M Form: READ *,list Use: Input the data from the READ default device (card reader, CDR) into the processor storage locations identified in the input list. Each input datum is converted, if necessary, to the type of its assigned list variable. Example: READ *, ABEL(10,20),/,J,K IO-IO NAMELIST -Controlled and Random Access READ Statements CHAPTER 10 /0.5.4 Sequential NAMELIST-Controlled READ Transfers Only the following form of the READ statement may be used to initiate a sequential NAMELIST-controlled input transfer: Form: READ (u,n) Use: Input data from logical unit u into processor storage as the value of the location identified by the NAMELIST input list specified by the name n. The input data is converted to the type of assigned variable if type conflicts occur. Only input files that contain records formatted and identified for NAMELIST operations (Paragraph 10.3.7) may be read by READ statements of this form. /0.5.5 Random Access Formatted READ Transfers Only the following form of the READ statement may be used to initiate a random access formatted input transfer: Form: READ (u#R,f)list Use: Input data from record R of logical unit u. Format each input datum according to the format specifications of f and place into processor storage as values of the locations identified in list. Only disk files that have been set up by either an OPEN or DEFINE FILE statement may be accessed by a READ statement of this form. (If record R has not been written, a fatal error results.) /0.5.6 Random Access Unformatted READ Transfers Only the following form of the READ statement may be used to initiate a random-access unformatted input transfer: Form: READ (u#R)list Use: Input dlIta from record R of logical unit u. Place the input data into processor storage as the value of the locations identified in list. Only binary files that have been output by an unformatted random-access WRITE statement may be accessed by a READ statement of this form. (If record R has not been written, a fatal error results.) Example: READ (1#20) BINFIL Read record number 20 into array BINFIL. NOTE If the form READ (u#R) is used, it will cause one logical input record to be skipped. 10.6 SUMMARY OF READ STATEMENTS The various forms of the READ statements are summarized in Table 10-2. 10-11 Summuy Of READ Statements and REREAD Statement CHAPfERIO Table 10-2 Summary of Read Statements Type of Transfer Sequential Formatted Transfer Mode Random Access READ (u,f)list READ (u,f) READ f,list READf READ (u#R,f)list Unformatted READ (u )list READ (u) READ (u#R)list READ (u#R) List-Directed READ (u, *)list READ * list NAMELIST READ (u,N) Note: The ERR=c and END=d arguments may be included in any of the above READ statements. When included, the foregoing arguments must be last, e.g., READ (I0,20,END=101,ERR=500) ARRAY (50,100). 10.7 REREAD STA TEMENT The REREAD statement causes the last record read from the last active input device to again be accessed and processed. The REREAD feature of DECsystem-20 FORTRAN cannot be used until an input (READ) transfer from a file has been accomplished. If REREAD is used prematurely, an error message will be output by DECsystem-20 FORTRAN at execution time. Once a record has been accessed by a formatted READ statement the record transferred may be reread as many times as desired. In a formatted transfer, the same or new format specification may be used by each successive REREAD statement. The REREAD statement may be used for sequential formatted data transfers only. The form of the REREAD statement is: Form: REREAD f,list Use: Reread the last record read during the last initiated READ operation and input the data contained by the record into the processor storage locations specified in the input list. Format the data read according to the format specifications given in statement f. 10-12 Sequential Formatted WRITE Statements CHAPTER 10 Example: DIMENSION ARRAY(IO,IO),FORMA(IO,lO),FORMB(lO,IO),FORMC(IO,lO) 90 READ(l6,l00)ARRAY 100 FORMAT( _______ ) 110 REREAD I 00, FORMA ]]5 REREAD 150,FORMB 120 REREAD 160,FORMC ISO FORMAT( ________ ) 160 FORMAT(________ ) In the above sequence, statement 90 inputs data formatted according to statement 100 into the array ARRA Y. Statement 110 reads the record read by statement 90 and inputs the data formatted as in the initial READ operation into the array FORMA. Statement lIS reads the record read by statements 90 and inputs the data formatted according to statement ISO into the array FORMB. Statement 120 reads the record read by statement 90 and inputs the data formatted according to statement 160 into the array FORMC. 10.8 WRITE STATEMENTS WRITE statements transfer data from specified processor storage locations to peripheral devices. The various forms of the WRITE statement enable it to be used in sequential, append and random access transfer modes for formatted, unformatted, list-directed and NAMELIST-controlled data transfers. 10.8.1 Sequential Fonnatted WRITE Transfers The following forms of the WRITE statement may be used for the sequential transfer of formatted data: a. b. Form: WRITE (u,f) list Use: Output the values of the processor storage locations identified in list, into the me associated with logical unit u. Convert and arrange the output data according to the specifications given in statement or array f Example: WRITE(06,500)OUT(I0,20),A,B Form: WRITE f,list Use: Output the values of the processor storage locations identified in list to the default device (i.e., line printer, LPT). Convert and arrange the output data according to the specifications given in f. Example: WRITE 10, SEND(5,10),A,B,C 10-13 CHAPTER 10 c. Sequential, NAMELIST -Controlled and Random Access WRITE Statements Form: WRITE f Use: Output the contents of any Hollerith (H) or literal (") field descriptor(s) contained by f to the default device (i.e., line printer, LPT). If neither of the foregoing types of field specifications are found in f, no output transfer is performed. Example: WRITE 10 10.8.2 Sequential Unformatted WRITE Transfer The following form of the WRITE statements may be used for the sequential transfer of unformatted data: Form: WRITE (u) list Use: Output the values of the processor storage locations identified in list into the file associated with logical unit u. No conversion or arrangement of output data is performed. Example: WRITE(12)IT AB(20,20),SUMS(! 0,5 ,2) 10.8.3 Sequential List-Directed WRITE Transfers The following form of the WRITE statement may be used to initiate a sequentiallist-directed output transfer. Form: WRITE(u, *)list Use: Output the values of the processor storage locations identified in list into the file associated with logical unit u. The conversion of each datum from internal to external form is performed according to the type of the list variable from which the datum is read. Example: WRITE02, *)C,X, Y,ITABO 0,1 0) 10.8.4 Sequential NAMELIST-Controlled WRITE Transfers Only the following form of the WRITE statement may be used to initiate a sequential NAMELIST output transfer. Form: WRITE(u,N) Use: Output the values of the processor storage locations identified by the contents of the NAMELIST-defined list specified by name N. Example: WRITE( I2,NMLST) 10.8.5 Random Access Formatted WRITE Transfers Only the following form of the WRITE statement may be used to initiate a random access type formatted output transfer: Form: WRITE(u#R,f)list Use: Output the values of the processor storage locations identified by the contents of list to record R of logical device u. Only disk files which have been set up by either an OPEN or a DEFINE FILE statement may be accessed by a WRITE transfer of this form. The data transferred will be formatted according to the specifications given in statement or array f Only those records which have been ~pecifically written are available to be read. 10-14 CHAPTER 10 Random Access WRITE Statements, Summary of WRITE Statements, ACCEPT Statement 10.8.6 Random Access Unformatted WRITE Transfers Only the following form of the WRITE statement may be used to initiate a random access unformatted output transfer: Form: WRITE(u#R)list Use: Output the values of the processor storage locations identified by the contents of list to record R of the logical device unit u. Only disk files which have been set up by either an OPEN or a call to the DEFINE FILE subroutine may be accessed by a WRITE transfer of this form. Only those records which have been specifically written are available to be read. 10.9 SUMMARY OF WRITE STATEMENTS The various forms of the WRITE statements are summarized in Table 10-3. Table )0-3 Summary of WRITE Statements Type of Transfer Sequential Transfer Mode Random Access Formatted WRITE(u,f)Jist WRITE f,list WRITEf WRITE( u#R,f)1ist Unformatted WRITE(u)list WRITE(u#R)list List-Directed WRITE(u, *)Iist NAMELIST-controlled WRITE(u,N) Note: The ERR=c and END=d arguments may be included in any WRITE statement; however, they must be last. 10.10 A CCEPT STATEMENT The ACCEPT statement enables the user to input data via either a terminal keyboard or a Batch control file directly into specified processor storage locations. This statement is used only in the sequential transfer mode for the formatted transfer of inputs from the user's terminal keyboard during program execution. The permitted forms of the ACCEPT statement are described in the following paragraphs. 10.10.1 Formatted ACCEPT Transfers The following forms of the ACCEPT statement are used for the sequential transfer of formatted data. a. Form: ACCEPT f,list Use: Input data character-by-character into the processor storage locations identified by the contents of list. Format the input data according to the format specifications given in f. Example: ACCEPT 101,LINE(73) 10-15 CHAITER 10 b. ACCEIT and PRINT Statements Form: ACCEPT *,list Use: Input data character-by-character into the processor storage locations identified by the contents of list. Convert the input characters, where necessary, to the type of its assigned list variable. Example: ACCEPT *, lAB, ABE, KAB, MAR 10.10.2 ACCEPT Transfers Into FORMAT Statement The following form of the ACCEPT statement may be used to input data from the user's terminal keyboard directly into a specified FORMA T statement If the FORMAT statement has either or both a Hollerith (H) or literal ('s 'j field descriptor. If the referenced statement has neither of the foregoing field descriptors, the input record is skipped. Form: ACCEPTf Use: Replace the contents of the appropriate fields of statement f with the data entered at the user's terminal keyboard. Example: ACCEPT 101 10.11 PRINT STATEMENT The PRINT statement causes data from specified processor storage locations to be output on the standard output device (i.e., line printer, LPT, Table 10-1). This statement may be used only for sequential formatted data transfer operation and may be written in either of the three following forms: a. b. c. Form: PRINT f,list Use: Output the values of the processor storage locations identified by the contents of list to the line printer. The values output are to be formatted and arranged according to the format specifications given in statement f Example: PRINT 55,T ABLE(1 0,20),I,J,K Form: PRINT * ,list Use: Output the values of the processor storage locations identified by the contents of list to the line printer. The conversion of each datum from internal to external form is performed according to the type of the list variable from which the datum is read. Example: PRINT *,C,X,Y,ITAB(lO,IO) Form: PRINT f Use: Output the contents of the FORMAT statement Hollerith (H) or literal field descriptors to the line printer. If neither an H nor a literal field descriptor is present in the referenced FORMAT statement, no operation is performed. Example: PRINT 55 10-16 PUNCH Statement CHAPTER 10 The second form of the PRINT statement is particularly useful when employed with ACCEPT f statements to cause desired data (i.e., comments or headings) to be inserted into reports at program execution time. Example The sequence 55 FORMAT ('\6END\60FlIROUTINE') PRINT 55 results in the prin ting of the phrase END OF ROUTINE on the line printer. 10.12 TYPE STATEMENT The TYPE statement causes data from specified processor storage locations to be output to the user's (control) terminal printing or display device (see Table 10-1 for device assignment for TYPE). This statement may be used only for sequential formatted data transfers and may be written in one of the following forms: a. b. c. Form: TYPE f,list Use: Output the values of the processor storage locations identified by the contents of list to the user's terminal printing or display device. The values output are to be formatted according to the format specifications given in statement f Example: TYPE 101,TABLE(lO,20)1,J,K Form: TYPEf Use: Output the contents of the referenced FORMAT statement Hollerith (H) or literal field descriptors to the user's terminal printing or display device. If the referenced FORMAT statement does not contain either an H or a literal field descriptor, no operation is performed. Example: TYPE 101 Form: TYPE *,/ist Use: Output the values of the processor storage locations identified by the contents of list to the printing or display device of the user's terminal. The conversion of each datum from internal to external form is performed according to the type of the list variable from which the datum is read. Example: TYPE *,lAB(l,5),A,B 10.13 FIND STATEMENT 711e FIND statement does not initiate a data transfer operation; it is used during random access read operations to locate the next record to be read while the current record is being input. The main program does not have access to the "found" record until the next READ statement is executed. 10-17 TYPE and FIND Statements CHAPfERIO The form of the FIND statement is FIND (u#R) Example In the sequence READ (01#90) FIND (01#101) READ (01#101) the FIND statement will locate record #/01 on device 01 after record 90 has been retrieved. Record #101 is not actually processed until the second READ statement in the sequence is executed. 10.14 ENCODE AND DECODE STATEMENTS The ENCODE and DECODE statements are used to perform sequential formatted data transfer between two defined areas of processor storage (i.e., an I/O list and a user-defined buffer); no peripheral I/O device is involved in the operations performed by these statements. The ENCODE statement transfers data from the variables of a specified I/O list into a specified user storage area. ENCODE operations are similar to those performed by a WRITE statement. The DECODE statement transfers data from a specified user storage area into the processor storage locations identified by the variables of an I/O list. DECODE operations are similar to those performed by a READ statement. The ENCODE and DECODE statements are written in the following forms: ENCODE(c,f,s)list DECODE(c,f,s)list where c specifies the number of characters to be in each internal storage area. This argument may be an integer, an integer expression, or either a real or double precision expression that is converted to an integer form. NOTE Characters are stored in the buffer five characters per storage location without regard to the type of variable given as the starting location. f specifies either a FORMAT statement or an array that contains format specifications. s specifies the address of the first storage location that is to be used in the transfer operations. When multiple records are specified by the format being used, the succeeding records follow each other in order of increasing storage addresses. list specifies an I/O list of the standard form (Paragraph 10.3.4). 10-18 CHAPTER 10 ENCODE Statement When multiple records are stored bv ENCODE, each new record is started on a new boundary rather than there being a carriage return, line feed inserted between records. 10.14.1 ENCODE Statement A description of the form and use of the ENCODE statement follows: Form: ENCODE(c,f,s)list Use: The values of the processor storage locations identified by the contents of list are converted to ASCll character strings according to the format specifications contained by f. The converted characters are then written into the destination area starting at location s. If more characters are to be transferred than the specified area can contain, the excess characters are ignored; they are not written into any following records. If fewer characters are to be transferred than specified for the record size, the empty character locations are filled with blanks. Example: ENCODE(500,JOI,START)TABLE /0.14.2 DECODE Statement A description of the form and use of the DECODE statement follows: Form: DECODE(c,f,s)list Use: The character strings stored in the internal reference and are read starting at location s, converted (decoded) according to the format specifications contained by f, and stored as the values of the locations identified in list. If the format specification requires more characters from a record than are specified by c, the extra characters are assumed to be blanks. If fewer characters are required from a record than are specified by c, the extra characters are ignored. Example: DECODE(50,50,START)GET(5,10) 10.14.3 Example of ENCODE/DECODE Operations The following program illustrates the use of both the ENCODE and DECODE statements: Example Assume the contents of the variables to be as follows: A(J) A(2) J B C 10 contains the floating point binary number 300.45 contains the floating point binary number 3.0 is an integer variable is a four-word array of indeterminate contents contains the ASCll string 12345 D02J=I,2 ENCODE(J6,10,B) J, A(J) FORMAT(IX,2HA(,Il,4H),="F8.2) TYPE II,B 10-19 CHAPTER 10 11 2 12 13 DECODE Statement and ENCODE/DECODE Operations FORMAT (4A5) CONTINUE DECODE (4, 12, C) B FORMA T (3FI.0,lX,FI.0) TYPE 13,B FORMAT (4F5.2) END Array B can contain twenty ASCII characters. I1le result of the ENCODE statement after the first iteration of the DO loop is: B(l) B(2) B(3) B(4) A(l) = Typed as 300.4 5 A (1)=300.45 11,e result after the second iteration is: B(l) B(2) B(3) B(4) A (2) Typed as 3.0 A (2)=3. 0 The DECODE statement a. extracts the digits I, 2, and 3 from C b. converts them to floating point binary value c. stores them in B(l), B(2), and B(3) d. skips the next character e. extracts the digit 5 from C f. converts it to a floating point binary value, and, g. stores it in B(4). 10.15 SUMMARY OF I/O STATEMENTS A summary of all permitted forms of the DECsystem·20 FORTRAN I/O statement is given in Table 10-4. 10-20 Table-Summary of I/O Statements CHAPTER 10 Table 10-4 Summary of DECsystem-20 FORTRAN I/O Statements I/O Statements Formatted READ Sequential Random WRITE Sequential or Append! Random 2 READ(u,f)list READ f,list READf READ(u)list READ(u#R,{)list READ(u#R)list WRITE( u,f)list WRITE f,list WRITE f WRlTE(u)list WRITE(u#R,f)list WRITE(u#R)list REREAD Sequential REREAD f,list FIND Random-only FIND(u#R) ACCEPT Sequential only PRINT Sequential only TYPE Sequential only Transfer Format Control Namelist Unformatted List-Directed READ(u,n) READ(u, *)list READ *,1ist WRITE(u,n) WRITE(u, *)Iist FIND(u#R) ACCEPT {,list or ACCEPT{ ACCEPT *,1ist PRINT f,list or PRINT f PRINT *,Iist TYPEf,list or TYPE{ TYPE *,list ENCODE Sequential only ENCODE(c,f,s)list DECODE Sequential only DECODE(c,{,s)list Legend: u f list n logical unit number statement number of FORMAT statement or name of array containing format information [/0 list name of specific NAMELIST [/0 list * #R c symbol used to specify list-directed [/0 operator variable which specifies logical record position number of characters per internal record address of the first storage location to be used ! An OPEN statement must be used to set up an append mode. 2Either the OPEN statement or a call to the DEFINE FILE subroutine must be used to set up a random access mode. 10-21 NAMELIST Statement CHAFfER 11 DECsystem-20 FORTRAN extensions to the 1966 ANSI standard set are printed in boldface italic type. CHAPTER 11 NAME LIST STATEMENTS 11.1 INTRODUCTION The NAMELIST statement is used to define I/O lists similar to those described in Chapter 10 (Paragraph 10.3.4). Defined NAMELIST I/O lists are referenced in special forms of the READ and WRITE statements to provide a method of transferring and converting data without referencing format specifications or specifying an I/O list in the I/O statement. 11.2 NAMELISTSTATEMENT NAMELIST statements are written in the following form: NAMELlST/Nl/Al,A2, . . . ,An/N2/Bl,B2,. . . ,Bn/Nn/. .. where / N/ through / Nn/ represents names of individual lists; the names are always written enclosed by slashes (IN!) Al through An and Bl through Bn are the items of the lists identified, respectively, by names Nl and N2. A list may contain one or more variJIble, array, or array element names. The items of a list are delimited by commas. Each list of a NAMELIST statement is identified (and referenced to) by the name immediately preceding the list. Example NAMELIST/TABLE/A,B,C/SUMS/TOTAL In the foregoing example, the name TABLE identifies the list A,B,C(2,4) and the name SUMS identifies the list comprised of the a"ay TOTAL. Once a list has been defined in a NAMELIST statement, its name may be referenced by one or more I/O statements. 11-1 Structuring NAMELIST Statements, NAMELIST Input Transfers CHAPTER II The rules for structuring a NAMELIST statement are: a. A NAMELIST name may not be longer than six characters; it must start with an alphabetic character; it must be enclosed in slashes; it must precede the list of entries to which it refers; and it must be unique within the program. b. A NAMELIST name may be defined only once and must be defined by a NAMELIST statement. Once defined, a name may appear only in READ or WRITE statements. The NAMELIST name must be defined in advance of the I/O statement in which it is used. c. A variable used in a NAMELIST statement cannot be used as a dummy argument in a SUBROUTINE definition. d. Any dimensioned variable contained in a NAMELIST statement must have been defined in a preceding array declaration statement. 11.2.1 NAMELIST-Controlled Input Transfers During input (read) transfer operations in which a NAMELIST-defined name is referenced, the record accessed is scanned until the symbol $ followed by the referenced name is found. Once the proper symbol-name combination is found, the data items following it are transferred on a one-to-one basis to the processor storage locations identified by the contents of the referenced list. The input data is always converted to the type of the list varible when there is a conflict of types. The input operation continues until another $ symbol is detected. If variables appear in the NAMELIST record that do not appear in the NAMELIST list, an error condition will occur. Data items of records to be input (read) using NAMELIST-defined lists must be separated by commas and may be of the following form: V=KI,K2, ... ,Kn where a. V may be a variable, array, or array element name. b. KI through Kn are constants of type integer, real, double precision, complex (written as (A,B) where A and B are real), or logical (written as T for true or F for false). A series of identical constants may be represented as a single constant preceded by a repetition factor (e.g., 5*5 represents 5,5,5,5,5). In transfers of this type, logical and complex constants must be equated to variables of their own type. Other type constants (real, double precision, and integer) may be equated to any other type of variable (except logical or complex), and will be converted to the variable type. For example, assume A is a 2-dimensional real array, B is a I-dimensional integer array, C is an integer variable, and that the input data is as follows: $FREDA(7,2)=4, B=3,6*2.8, C=3.32$ A READ statement referring to the NAMELIST defined name FRED will result in the following: the integer 4 will be converted to floating point and p/oced in A (7,2). The integer 3 will be placed in B(J) and the integer 2 (converted) will be placed in B(2),B(3), . . . ,B(7). The floating point number 3.32 will be converted to the integer 3 and placed in C. 11-2 NAMELIST Output Transfers CHAPTER 11 11.2.2 NAMELIST-Controlled Output Transfers When a WRITE statement refers to a NAMELIST-defined name, all variables and arrays and their values belonging to the named list are written out, each according to its type. Arrays are written out by columns. Output data is written so that: a. The fields for the data will be large enough to contain all the significant digits. b. The output can be read by an input statement referencing a NAMELIST-defined list. For example, if JOE is a 2 X 3 array, the statement NAMELIST/ NAM 1jJOE,Kl,ALPHA WRITE (u,NAM1) generates the following form of output: Column + $NAMI JOE= -6.75 -17.8, Kl =73.1, .234E-04, 0.0 ALPHA =3. $ 680, -.197E+07, 11-3 OPEN and CLOSE Statements CHAPTER 12 DECsystem·20 FORTRAN extensions to the 1966 ANSI standard set are printed in boldface italic type. CHAPTER 12 FILE CONTROL STATEMENTS 12.1 INTRODUCTION File control statements are used to set up files and establish parameters for I/O operations and to terminate I/O operations. The OPEN and CLOSE statements are described in this chapter. 12.2 OPEN AND CLOSE STATEMENTS Both the OPEN and CLOSE statements use the same format and have the same options and arguments. The OPEN statement enables the user to define, explicitly, all of the important aspects of each desired data transfer operation; they provide an extensive list of required and optional arguments which define in detail: a. the name and location of the data file b. the type of access required c. the data format within the file d. the protection code to be assigned an output data file e. the disposition of the data file f. data file record, block and file sizes g. a data file version identifier In addition, a DIALOG argument is provided which permits the user to establish a dialogue mode of operation when the OPEN statement containing it is executed. In a dialogue mode, interactive user terminal/program communication is established. This enables the user, during program execution, to define, redefine, or defer the values of the 'Optional arguments contained by the current OPEN statement. 12·1 CHAPTER 12 OPEN and CLOSE Statement Options The general form of the OPEN statement is: OPEN(Argl,Arg2, . . . ,Argn} The CLOSE statement is used in the tennination of an I/O operation to dissociate the I/O device being used from the active file and file-related information, and to restore the core occupied by I/O buffers and other transfer-related operations. All required device dependent termination functions are also performed on the execution of a CLOSE statement, including reloading the unit. Note that the CLOSE statement can change the name, and disposition of the file being closed. Once a CLOSE statement has been executed, another OPEN statement is required to regain access to the closed file. The general form of the CLOSE statement is: CLOSE(Argl.,Arg2., . . . ,Argn} 12.2.1 Options for OPEN and CLOSE Statements The options and their arguments, which may be used in both the OPEN and CLOSE statements, are: a. UNIT This option is required; it defines the FORTRAN I/O unit number to be used. FOR TRAN devices are identified by assigned decimal numbers within the range 1-63; however, UNIT may be assigned an integer variable or constant. The general form of this argument is: UNIT = An integer variable or constant DECsystem-20 FORTRAN standard logical unit assignments are described in Chapter /0 (Table /o-I). The range for the possible UNIT numbers is an installation defined parameter. b. DEVICE This option may specify either the physical or the logical name of the I/O device involved. (A logical name always takes precedence over a physical name.) The DEVICE arguments may specify I/O devices located at remote stations; as well as logical devices. The general form of the DEVICE argument is: DEVICE = A literal constant or variable If this option is omitted, the first logical name u (where u is the decimal unit number) is tried; if this is not successful, the standard (defaUlt) device is attempted. c. ACCESS A required option, ACCESS describes the type of input and/or output statements and the file access mode to be used in a specified data transfer operation. A CCESS may be assigned anyone of six possible names, each of which specifies a specific type of I/O operation. The assignable names and the operations specified are: 12-2 CHAPTER 12 MODE Option 1. SEQIN The specified dota file is to be read in sequential access mode. 2. SEQOUT The specified data file is to be written in a sequential access mode. 3. SEQINOUT The specified data file may (READ/WRITE sequence) sequential access mode. specified, a WRITE/READ the file has been removed. 4. RANDOM The specified data file may be either read or written into, one record at a time. In a random access mode of operation, the relative position of each record is independent of the previous READ or WRITE statement; all records accessed must have a fixed logical record length. This argument is required for random access operations. A disk device must be specified when the random argument is used. 5. RANDIN This argument enables the user to establish a special, read-only random access mode with a named file. During a RANDIN mode, the user may read the named file simultaneously with other users who have also established a RANDIN mode and with the owner of the file. The use of RANDIN enables a data base to be shared by more than one user at the same time. 6. APPEND The record specified by a corresponding WRITE statement is to be added to the logical end of a named file. The modified file must be closed then reopened in order to permit it to be read. be first read then written record-by-record in a When SEQINOUT is sequence is illegal unless The general form of the ACCESS argument is: ACCESS = d. MODE 'SEQIN' SEQOUT' 'SEQINOUT' 'RANDOM' 'RANDIN' 'APPEND' variable (set to literal) This option defines the character set of an external file or record. The use of this argument is optional; if it is not given, one of the following is assumed: ASCII for a formatted I/O file transfer Binary for an unformatted I/O file transfer 12·3 DISPOSE Option CHAPTER 12 One of the following character set specifications must be used with the MODE argument: Action Indicated Literal 'ASCII' Specifies an ASCII character set. 'BINAR Y' Specifies data formatted as a FORTRAN binary data file. 'IMAGE' Specifies an image (I) mode data transfer for the associated READ or WRITE statements. IMAGE is an unformatted binary mode. The general form of the MODE argument is: MODE = e. DISPOSE 'ASCII' 'BINARY' 'IMAGE' variable (set to literal) This option specifies an action to be taken regarding a file at close time. When used, DISPOSE must be either an ASCII variflble or one of the following literals: Literal Action Indicated 'SAVE' Leave the file on the device. 'DELETE' If the device involved is disk, remove the file; otherwise, take no action. 'PRINT' If the file is on disk, queue it for printing; otherwise, take no action. 'LIST' If the file is on disk, queue it for printing and delete the file; otherwise take no action. 'RENAME' Change filename. (This is redundant if a new filename is given.) If the DISPOSE argument is not given, the argument DISPOSE = SA VE is assumed. The general form of the DISPOSE argument is: DISPOSE = 124 'SAVE' 'DELETE' 'PRINT' 'LIST' 'RENAME' variflble (set to literal) FILE, PROTECTION, DIRECTORY Options CHAPTER 12 f FILE This option specifies the name of the file involved in the data transfer operation. FILE must be either an ASCII literal, double precision, complex, or single precision variable. Single precision variables are assumed to contain a 1 to 5 character file specification; double precision variables, permit 1O-character file specification. The format is a 1 to 6 character filename optionally followed by a period and a 0 to 3 character file type. Any excess characters in either the name or file type are ignored. If the period and file type are omitted, the file type .DA T is assumed; ifjust the file type is omitted, a ". "is assumed. If a file name is not specified or is zero, a default name is generated which has the form FORxx.DAT where xx is the FORTRAN logical unit number (decimal) or is the logical unit name for the default statements A CCEPT, PRINT, READ, or TYPE. The general form of a FILE argument is: FILE = g. PROTECTION This option specifies a protection code to be assigned the data file being transferred. The protection code determines the level of access to the file that three possible classes of users (i.e., owner, member, or other) will have. PROTECTION may be a 3-digit octal literal or a variable; if the argument is assigned a zero value or is not given, the default protection code established for the DECsystem-20 installation is used. The general form of the PROTECTION argument is: PROTECTION = h. DIRECTORY An ASCII literal or variable (set to literal) 3-digit octal or integer variable This option is used for disk files only. It specifies the location of the user file directory which contains the file specified in the OPEN statement. A directory identifier may consist of the user's project-programmer number for example, 11O,7J. (Refer to Appendix B.) The general form of a DIRECTOR Y argument is: DIRECTORY= i. BUFFER COUNT Literal or variable containing UFD name or directory path specification This option enables the user to specify the number of I/O buffers to be assigned to a particular device. If this argument is not given or is assigned a value of zero, the Monitor default is assumed. The general form of this argument is: BUFFER COUNT = 12·5 An integer constant or variable CHAPTER 12 j. FILE SIZE, VERSION, BLOCK SIZE, RECORD SIZE, ASSOCIATE VARIABLE Options FILE SIZE This option is used for disk operations only; it enables the user to estimate the number of words that an output file is going to contain. The use of FILE SIZE enables the user to ensure at the start of a program that enough space is available for its execution. If the size specified is found to be too small during program executions, the Monitor allocates additional space according to the normal Monitor algorithms. The value assigned to the FILE SIZE arguments may be an integer constant or variable. The general form of this argument is: FILE SIZE = k. VERSION This option is used for disk operations only; it enables the user to assign a 12-digit octal version number to a file when it is output. The quantity assigned to the VERSION argument may be either an octal constant or variable. The general form of the argument is: VERSION = I. BLOCK SIZE RECORD SIZE ASSOCIA TE VARIABLE An integer constant or variable This option enables the user to force all logical records to be a specified length. If a logical record exceeds the specified length, it is truncated; if a logical record is less than the specified size, nulls are added to pad the record to its full size. The RECORD SIZE argument is required whenever a random access mode is specified. The value assigned to this argument may be either an integer constant or variable, and may be expressed as the numbers of words or characters depending on the mode of the file being described. The general form of this argument is: RECORD SIZE = n. An octal constant or integer variable This option can be used for all storage media except disk. It enables the user to specify a physical storage block size for devices other than disk. The value assigned the BLOCK SIZE arguments may be an integer constant or variable. The size specified must be greater than or equal to 3 and less than or equal to 4095. The general form of this argument is: BLOCK SIZE = m. An integer constant or variable An integer constant or variable This option is for disk random access operations only. It provides storage for the number of the record to be accessed next if the program being executed were to continue to access records one after another from the specified random access file. The general form of this argument is: ASSOCIATE VARIABLE = Integer variable 12-6 PARITY, DENSITY, DIALOG Options CHAPTER 12 o. PARITY This option is for magnetic tape operations only; it permits the user to specify the type of parity to be observed (odd or even) during the transfer of data. The general form of this option is: PARITY = p. DENSITY 'ODD' 'EVEN' variable (set to literal) This option is for magnetic tape operations only; it permits the user to specify any of three possible bit-per-inch (bpi) tape density parameters for magnetic tape transfer operations. The general form of this option is: DENSITY = '200' '556' '800' '1600' variable (set to literal) q. DIALOG The use of this option in an OPEN statement enables the user to supersede or defer, at execution time, the values previously assigned to the arguments of the statement. There are two forms of this argument. The first is: DIALOG This form establishes a dialogue with the user's terminal when the OPEN statement is executed. FOROTS outputs the following messages at the user's terminal. ENTER FILE SPECIFICA TIONS FOR LOGICAL UNIT XX (FOROTS then types the existing file specifications defined by the current OPEN statement.) Once the message and defined file specification are output the user may enter any desired changes. Only the arguments that are to be changed need to be entered. The second form of the argument is: DIALOG = Literal or array The value assigned to DIALOG may be a literal or array containing a file specification with the desired information. 12·7 CHAPTER 12 Summary of Options 12.2.2 Summary of OPEN/CLOSE Statement Options The options permitted and required in the OPEN and CLOSE statements and the type of value required by each are summarized in Table 12-1. Table 12-1 OPEN/CLOSE Statement Arguments Values Required Argument UNIT = MODE = DIRECTORY = F1LE SIZE = BUFFER COUNT = ASSOCIA TE VARIABLE = ACCESS = F1LE= DIALOG = BLOCK SIZE = VERSION = DEVICE = PROTECTION = DISPOSE = RECORD SIZE = PARITY = DENSITY = Integer variable or constant Literal constant or variable Literal or variable Integer constant or variable Integer constant or variable Integer variable 'SEQIN', 'SEQOUT', 'SEQINOUT', 'RANDIN', 'RANDOM', 'APPEND', or variable Literal constant or variable Literal or array Integer constant or variable Octal constant or variable Literal constant or variable An octal constant or integer variable Literal constant or variable Integer constant or integer variable Literal constant or variable Literal constant or variable 12-8 CHAPTER 13 FORMAT Statement, General Form DECsystem-20 FORTRAN extensions to the 1966 ANSI standard set are printed in boldface italic type_ CHAPTER 13 FORMAT STATEMENT 13.1 INTRODUCTION FORMAT statements may appear almost anywhere in a FORTRAN source program. The only placement rest ricoperations. The FORMAT statements contain field descriptors which, together with the list items of associated I/O statements, specify the forms of the data and data fields which comprise each record. FORMAT statements may appear almost anywhere in a FORTRAN source program. The only placement restrictions are that they follow PROGRAM, FUNCTION, SUBPROGRAM, or BLOCK DATA statements, and that they precede the END statement. (Refer to Section 2.4.) FORMAT statements must be labeled so that they can be referenced by I/O statements. 13.1.1 FORMAT Statement, General Fonn The general form of a FORMAT statement follows: k FORMAT(SAI ,SA2, ...,SAn/SBI,SB2,... ,SBn/... ) where k SA 1 through SAn and SBl through SBn the required statement label (which can only be referenced by I/O statements). = individual field descriptor sets In the foregoing statement form the individual field descriptors are delimited by commas (,) field descriptor sets and records are delimited by slashes (/). For example, a FORMAT statement of the form: FORMAT(SAI ,SA2/SBI ,SB2/SC 1,SC2) contains format specifications for three records with each record comprised of two field descriptor sets. 13-1 FORMAT Statement, Format Descriptors CHAPTER 13 Adjacent slashes (/ () in a FORMAT statement specify that a record is to be skipped during input or is to consist of an empty record on output. For example, a FORMAT statement of the form: FORMAT(SAI ,SA2/ / /SB 1,SB2) specifies four records are to be processed; however, the second and third records are to be skipped. Repeated field descriptors or groups of field descriptors may be represented using a repeat form. The repetition of a single field descriptor is written by preceding the descriptor with an integer constant which specifies how many times the descriptor is to be repeated. For example, a FORMA Tstatement of the form FORMAT(SA1,SA2,SA3,SA1,SA2,SA3,SA l,SA2,SA3) may be written as FORMA T(3(SA l,SA2,SA3)) The repeat forms of field descriptor may be nested to any depth. For example, a FORMA T statement of the form FORMAT(SA l,sA 2,SA 2, SA 3,SA l,SA2,SA 2, SA 3) may also be written in the form FORMAT(2(SA1,2SA2,SA3)) The manner in which the foregoing statement forms may be used and the effect each has on the data involved are discussed in the following paragraphs. 13.2 FORMAT DESCRIPTORS FORMAT statement descriptors describe the record structure of the data, the format of the fields within the record, and the conversion, scaling, and editing of data within specific fields. The following descriptors can be used with DECsystem-20 FORTRAN: Descriptors Comments rFw.d} rEw.d rDw.d rGw.d Floating pOint numeric field descriptors rIw Integer field descriptor rLw Logical field descriptor rAW} rRw Alphanumeric data field descriptor kHs } 'text' Alphanumeric data in a FORMAT statement field descriptor rx} Tw Field formatting descriptors 13-2 FORTRAN Conversion Codes CHAPTER 13 Descriptors Comments nP Numerical scale factor descriptor / Record delimiter $ Carriage return suppression for terminal rOw Octal field descriptor where r an optional unsigned integer that represents a repeat count. This option enables a field descriptor to be repeated r times. w an optional integer constant which represents the width (total number of characters contained) of the external form of the field being described. All characters including digits, decimal points, signs, and blanks that are to comprise the external form of the field must be included in the value of w . .d an optional unsigned integer that specifies the number of fractional digits which are to appear in the external representation of the field being described. Note that w must be specified if .d is included in the descriptor. k An unsigned integer that specifies the number of characters to be processed during the transfer of alphanumeric data. s represents a string of ASCII (alphanumeric) characters. n a signed integer constant (plus signs are optional). The characters A, D, E, F, G, H, I, L, 0, P, and R indicate the manner of conversion and editing to be performed between the internal (processor) and external representations of the data within a specific field; these characters are referred to as conversion codes. The DECsystem-20 FORTRAN conversion codes and a brief description of the function of each are given in Table 13-1. Table 13-1 DECsystem-20 FORTRAN Conversion Codes Code Function A D E F G H L Transfer alphanumeric data Transfer real data with a D exponent 1 Transfer real data with an E exponent l Transfer real data without an exponent Transfer integer, real, complex, or logical data Transfer literal data Transfer integer data Transfer logical data P R Numerical scaling Factor Transfer alphanumeric data o 1 An Transfer octal data exponent of 0 is assumed if none is given. 13-3 CHAYfER 13 FORMAT Statement, Numeric Field Descriptors The use of commas to delineate format descriptors within a format specification is optional as long as no ambiguity exists. For example, FORMAT (3X,A2) can be written as FORMAT (3XA2) Since interpretation of a format specification is left associative, the specification FORMAT (122,15) can be written as FORMAT (12215) However, a comma is required when the user wishes to specify FORMAT (12,215) Detailed descriptions of the various types of format descriptors, the manner in which they are written and employed and their use in FORMAT statements are given in the following paragraphs. 13.2.1 Numeric Field Descriptors The forms of the field descriptors used to specify the format and conversion of numeric data follow. Description Dw.d Ew.d Ew.d,Ew.d Fw.d Fw.d,Fw.d Iw Ow Gw.d Gw Gw.d,Gw.d Type of Data Used For Double precision real data with a D exponent Real data with an E exponent For the real and imaginary parts of a complex datum Real data without an exponent For the real and imaginary parts of a complex datum In teger da ta Octal data Real or double precision data For integer (or logical) data For the real and imaginary parts of a complex datum NOTE The G conversion code may be used for all but octal numeric data types. Examples Consider the following program segment: INTEGER 11, 12 REAL RI, R2, R3 DOUBLE PRECISION D1, D2 I I = 506 12 = 8 Rl = 506.0 R2 = 18.1 R3 = 506001.0 DI = 18.0 D2 = - 504.0 13·4 Field Descriptors, Action of CHAPTER 13 The actions performed by several types of formatted WRITE statements on the data given in the foregoing program segment are described in Table 13-2. Table 13-2 Action of Field Descriptors On Sample Data Item 1 2 3 4 5 6 7 8 9 10 where: Descriptor Form Dw.d Ew.d Fw.d Iw Iw Ow Gw.d Gw.d Gw.d Gw Sample Descriptor D8.2 E8.2 FS.2 15 12 05 G8.2 G8.2 G8.2 G5 WRITE Statement Using the Sample Descriptor WRITE (-,-) Dl WRITE (-,-) Rl WRITE (-,-) R2 WRITE (-,-) 11 WRITE (-,-) 11 WRITE (-,-) 12 WRITE (-,-) D2 WRITE (-,-) R3 WRITE (-,-) R2 WRITE (-,-) 11 External Form of Sample Field Described External Appearance of Sample Data Z.nnD±nn Z.nnE±nn aa.nnE+nn aaaan an nnnnn Z.nnD±nn Z.nnE±nn aa.nn aaaan 0.18D+02 0.51E+03 18.10 ~~506 ** 00010 -.50D+02 0.51E+06 18.10 ~~S06 a. n represents a numeric character b. Z represents either a - or 0 (Note that if nod > 6, a negative number cannot be output.) c. a represents a digit, leading blank (~) or a minus sign depending on the numeric output. Notes: 1. In Item I, the value Dl has only 2 significant digits and d=2, so no rounding will occur on input. 2. In Item 2, since Rl has 3 significant digits, it is rounded to fit into the specified field. 3. In Item 5, the width (w) part of a format descriptor specifies an exact field which permits no rounding of its contents. If the w specification is too small for the datum to be transferred, asterisks are output to indicate that the transfer was not made. 4. In Item 6, Integer 8 = Octal 10. 5. In Items 8 and 9, the relationship between G and fixed and floating real data is discussed in Paragraph 13.2.3. 6. In items 1,2,3,7, and 8 the D and E exponent prefixes are optional in the external form of the floating point constants. For example, 1.1E+3 may be written as 1.1 +3. The internal and external forms of the data specified by the numeric format conversion code are summarized in Table 13-3. 13-5 CHAPTER 13 Numeric Field Codes, Interaction of Field Descriptors With List Variables Table 13-3 Numeric Field Codes Internal Form Conversion Code External Form Binary floating point double precision D Decimal floating point with D exponent Binary floating point E Decimal floating point with E exponent Binary floating point F Decimal fIxed point Binary integer Decimal integer Binary word o Octal value One of the following: single precision, binary floating point, binary integer, binary logical, or binary complex G Single precision decimal floating point integer, logical (T or F), or complex (two decimal floating point numbers), depending upon the internal form Complex quantities are transferred as two independent real quantities. The format specifIcation for complex quantities consists of either two successive real fIeld descriptors or one repeated real field descriptor. For example, the statement FORMAT(2E15.4,2(F8.3,F8.5)) may transfer up to three complex quantities. The equivalent of the foregoing statement is FORMAT(E 15.4,E 15.4,F8.3,F8.5,F8.3,F8.5) 13.2.2 Interaction of Field Descriptors With I/O List Variables During Transfer The execution of an I/O statement that specifIes a formatted data transfer operation initiates format control. The actions performed by format control depend on information provided by the elements of the I/O statement's list of variables and the field descriptors which comprise the referenced FORMAT statement's format specifIcations. In processing each FORMAT controlled I/O statement which has an I/O list, FORTRAN scans the contents of the list and the format speCifications in step. Each time another variable or array element name is obtained from the list, the next field specification is obtained from the format specifIcation. If the end of the format specifIcation is reached and more items remain in the list, a new line or record is established and the scan process is restarted, either at the first item in the format specification or, if parenthesized sets of format specifIcations exist within the format specification, with the last set within the format specifIcation. When the I/O list is exhausted, control proceeds to the next statement in the program, but not before the FORMAT statement is scanned either to its end or to the next variable transfer format descriptor. (That is, the FORMAT statement is scanned past slashes, literal constants, and spacing descriptors, but not past data field descriptors.) 13-6 G Conversion Code, Scale Factors CHAPTER 13 A record is terminated by one of the following: a. a slash in the FORMAT specification b. the delimiting right parentheses,), of the FORMAT statement c. a lack of items in the 1(0 list d. a lack of Hollerith field descriptors in the FORMAT statement On input, an additional record is read only when a single slash, (, is encountered in the FORMAT statement. A record is skipped when two slashes, ((, are encountered or a slash is followed by the end of the FORMAT statement. If the FORMAT statement finishes a record by a slash or the end of the FORMAT statement, then any data left in the input record is ignored. If the input record is exhausted before the data transfers are completed, the remainder of the transfer is completed as if the record were extended with blanks. On output, an additional record is written only when a slash, (, is encountered in the FORMAT statement. If two consecutive slashes, ((, or a single slash followed by the end of the FORMAT statement, is encountered, then an empty record is written. 13.2.3 G, General Numeric Conversion Code The G conversion code may be used in field descriptors for the format control of real, double precision, integer, . logical, or complex data. With the exception of real and double precision data, the type of conversion performed by a G type field descriptor depends on the type of its corresponding 1(0 list variable. In the case of real and double precision data, the kind of conversion performed is a fun('tion of the external magnitude of the datum being transferred. Table 13-4 illustrates the conversions performed for various ranges of magnitude (external form) of real and double-precision data. 13.2.4 Numeric Fields with Scale Factors Scale factors may be added to D,E,F, and G conversion codes in field descriptors. The scale factor has the form nP where n is a signed integer (+ is optional) and P identifies the operation. When used, a scale factor is added as a prefix to field descriptors. Examples -2PFlO.5 IPE8.2 When added to an F type field deSCriptor (or G type if the external field is a fIxed point decimal) a scale factor specifies a power of 10 so that External Form of Number =(Internal Form)* 10 (scale factor) For example, assuming the data involved to be the real number 26.451, the field descriptor F8.3 produces the external fIeld ~~26.451 13-7 Conversion of Real and Double Precision Data, Scale Factors CHAPTER 13 Table 13-4 Descriptor Conversion of Real and Double Precision Data According to Magnitude Magnitude of Data in its External Fonn (M) Equivalent Method of Conversion Performed < F(w-4).d,4X F(w-4 ).(d-l ),4X 0.1 ';;;'M 1 1 ';;;'M< 10 lOd-2 ..: M lOd-l ":M < lOd-l < lOd F(w-4).1,4X F(w-4).0,4X Ew.d ALL OTHERS Note: In all numeric field conversions the field width (w) specified should be large enough to include the decimal point, sign, and exponent character in addition to the number of digits. If the specified width is too small to accommodate the converted number, the field will be filled with asterisks (*). If the number converted occupies fewer character positions than specified by w, it will be right-justified in the field and leading blanks will be used to fill the field. The addition of the scale factor of -IP -lPF8.3 produces the external field ~~~2.645 When added to D, E, and G (external field not a decimal fixed point) type field descriptors, the scale factor multiplies the number by the specified power of ten and the exponent is changed accordingly. In input operations, F type (and G type, if the external field is decimal fixed point) conversions are the only ones affected by scale factors. When no scale factor is specified, it is understood to be zero. Once a scale factor is specified, however, it holds for all subsequent D, E, F, and G type field descriptors within the same format specification unless another scale factor is specified. A scale factor is reset to zero by specifying a scale factor of zero. Scale factors have no effect on I and 0 type field descriptors. 13-8 Logical Descriptors, Variable Field Widths CHAYfER 13 13.2.5 Logical Field Descriptors Logical data may be transferred under format control in a manner similar to numeric data transfer by use of the field descriptor Lw where L is the control character and w is an integer specifying the field width. The data is transmitted as the value of a corresponding logical variable in the associated input/output list. On input, the first non-blank character in the logical data field must be T or F, the value of the logical variable is stored in the list variable as true or false, respectively. If the entire input data field is blank or empty, a value of false is stored. On output, w minus I blanks followed by T or F will be output if the value of the logical variable is true or false, respec tivel y . 13.2.6 Variable Numeric Field Widths Several of the conversion codes are acceptable in FORMAT statements without field width speCifications (i.e., the w.d portion of the specification is omitted 1 ). On input, the conversion codes D, E, F, G, I, L, and 0 are acceptable without field width specifications. The field begins with the first non-blank character encountered and ends with the first illegal character in the given field. (Blanks and tabs also terminate a field.) Note that for conversion code L (logical data) all consecutive a1phabetics following a T (true) or an F (false) are considered part of the field and are ignored. In succeeding fields the input stream is scanned until a non-blank character is encountered. If the character is a comma (,) the next field is skipped and the following input field begins with the character following the comma. Any character other than a comma is assumed to be the first character in the next input field. Null fields are denoted by successive commas, optionally separated by blanks or tahs. A. null field is equivalent to a fixed-field input of blanks. For example, the source code READ I, X, Y, Z, L, I, J FORMAT (3F, L, I, A3) with data as follows ,1.OE+5"TRUEXXXlt6WIiABC results in X= 0.0 Y= 1.0E+5 Z 0.0 L TRUE I 1 J 'ABC' Note that if a comma is included in the input data after the XXXI and before the blanks, i.e., the data is ,1.0E+5 " TRUEXXXI ,t6WtJABC then J = 't6W' 1 If d is given, then w must also be specified. 13-9 Alphanumeric Field Descriptors, A Descriptor On output, the format codes A, D, E, F, G, I, L, 0, and R are acceptable without field width specifications. The following defaults are assumed: Fonnat Code Assumed Default A single precision A dou ble precision D E F G single precision G dou ble precision I L AIO D25.18 El5.7 Fl5.7 G15.7 G25.18 115 AS LIS o 015 R5 RIO R single precision R double precision 13.2.7 Alphanumeric Field Descriptors The formatted transfer of alphanumeric data may be accomplished in a manner similar to the formatted transfer of numeric data by use of the field descriptors Aw and Rw, where A and R are the control characters and w is the number of characters in the field. The A and R descriptors both transfer alphanumeric data into or from a variable in an input/output list depending on the I/O operation. A list variable may be of any type. For example, READ (6,5) V 5 FORMAT (A4) causes four alphanumeric characters to be read from the card reader and stored in the variable V. The A descriptor deals with variables containing left-justified, blank-fil1ed characters, and the R descriptor deals with variables containing right-justified, zero-filled characters. The fol1owing paragraphs summarize the result of alphanumeric data transfer (both internal and external representations) using the A and R descriptors. These paragraphs assume that w represents the field width and m represents the total number of characters possible in the variable. Double precision variables contain 10 characters (i.e., m=lO); and all other variables contain 5 (i.e., m=5). A Descriptor a. INPUT, where w ~ m - The rightmost m characters of the field are read in and stored left-justified and blank-filled in the associated variable. b. INPUT, where w < m - All w characters are read in and stored left-justified and blank-filled in the associated variable. c. OUTPUT, where w ~ m - m characters are output and right-justified in the field. The remainder of the field is blank-fil1ed. d. OUTPUT, where w < m - The left-most w characters of the associated variable are output. 13-10 R Descriptor, Transferring Alphanumeric Data R Descriptor a. INPUT, where w :> m - The right-most m characters of the field are read in and stored right-justified, zero-filled in the associated variable. b. INPUT, where w < m - All w characters are read in and stored right-justified, zero-filled in the associated variable. c. OUTPUT, where w:> m - m characters are output and right-justified in the field. TIle remainder of the field is blank filled. d. OUTPUT, where w < m - The right-most w characters of the associated variable are output. 13.2.8 Transferring Alphanumeric Data Directly Into or From FORMAT Statements Alphanumeric data may be transmitted directly into or from the FORMAT statement by two different methods: H-conversion, or the use of single quotes (i.e., a literal field descriptor). In H-conversion, the alphanumeric string is specified in the form nH, where H is the control character and n is the total number of characters (including blanks) in the string. For example, the folloWing statement sequence may be used to print the words PROGRAM COMPLETE on the device LPT: 101 PRINT 101 FORMAT (l7H~PROGRAM~COMPLETE) Read and write operations of this type are initiated by I/O statements which reference a format statement and a logical device but do not contain an I/O list (see preceding example). Write transfers from a FORMAT statement cause the contents of the statement field descriptor to be output to a specified logical device. The contents of the field descriptor, however, remain unchanged. Read transfers with a FORMAT statement cause the contents of the field descriptors involved to be replaced by the characters input from the specified logical device. Alphanumeric data is stored in a field descriptor left justified. If the data input into a field has fewer characters than the field, trailing blanks are added to fill the field. If the data input is larger than the field of the descriptor, the excess right most characters are lost. Examples 101 WRITE (I,IOl) FORMAT (l7HV>PROGRAM~COMPLETE) cause the string PROGRAM COMPLETE to be output to the file on device 1. 13-11 CHAPTER 13 Mixed Fields Assuming the string START on device 1, the sequence 101 READ (1,101) FORMAT (17H~PROGRAM~COMPLETE) would change the contents of statement 101 to 101 FORMAT (17HSTART~~~~~~~~~~~~) The foregoing functions may also be accomplished by a literal field descriptor consisting of the desired character string enclosed within apostrophes (i.e., 'string'). For example, the descriptors 101 FORMAT (17H,PROGRAM,COMPLETE) and 101 FORMAT OPROGRAM'COMPLETE') may be used in the same manner. The result of literal conversion is the some as H-conversion; on input, the characters between the apostrophes are replaced by input characters and, on output, the characters between the apostrophes (including blanks) are written as part of the output data. An apostrophe character within a literal field should be represented by two successive apostrophe marks; otherwise, the statement containing the field will not compile. For example, the statement sequence 50 FORMAT ('DON''T') PRlNT50 will compile and will cause the word DON'T to be output on the line printer. The statement 50 FORMA T (,DON'T') however, will cause a compile e"or. 13.2.9 Mixed Numeric and Alphanumeric Fields An alphanumeric field descriptor may be placed among other fields of the format. For example, the statement: FORMAT (l4,7H~FORCE=FIO.5) may be used to output the line: ~~22~FORCE=~~17.68901 The separating comma may be omitted after an alphanumeric format field, as shown in the foregoing statement. When a comma delimiter is omitted from a format specification, format control associates as much information as possible with the leftmost of the two field descriptors. 13-12 Multiple Record Specifications CHAPTER 13 13.2.10 Multiple Record Specifications To handle a group of input/output records where different records have different field descriptors, a slash is used to indicate a new record. For example, the statement FORMAT (308/15,2F8.4) is equivalent to FORMAT (308) for the first record, and FORMAT (I5,2F8.4) for the second record. Separating commas may be omitted when a slash is used. When n slashes appear at the end or beginning of a format, n blank records will be written on output or skipped on input. When n slashes appear in the middle of a format, n-l blank records are written on output or n-l records skipped on input. Both the slash and the closing parenthesis at the end of the format indicate the termination of a record. If the list of an input/output statement dictates that the transmission of data is to continue after the closing parenthesis of the format is reached, the format is repeated starting with that group repeat specification terminated by the last right parenthesis of level one or level zero if no level one group exists. Thus, the statement FORMAT (F7.2,(2(E15.5E15.4),17)) I levelO/ level 1 t ~evel 0 level 1 causes the format 2(E 15.5,E 15.4),17 to be used on the first record. As a further example, consider the statement FORMAT (F7.2/(2(E 15.5,E15.4 ),17)) The first record has the format F7.2 and successive records have the format 2(E 15.5EI5.4 ),17 13-13 Record Formatting Descriptors CHAPTER 13 13.2.11 Record Formatting Field Descriptors Two field descriptors, Tw and nX, may be used to position data within a record. The field descriptor Tw may be used to specify the character position (external form) in which a record begins. In the Tw field descriptor the letter T is the control character and w is an unsigned integer constant which specifies the character position, in a DECsystem-20 FORTRAN record, where the transfer of data is to begin. When the output is printed, w corresponds to the (w-1 )th print position since the first character of the output buffer is a forms control character and is not printed. It is recommended that the first field specification of the output format be IX, except where a forms control character is used. NOTE Two successive T field specifications will result in the second field overwriting the first field. Examples The statement sequence PRINT 2 2 FORMAT(T50,'BLACK'T30,'WHITE') causes the following line to be printed WHITE + (print position 29) BLACK + (print position 49) The statement sequence 1 FORMAT (T35, 'MONTH') READ (2,1) causes the first 34 characters of the input data associated with logical unit 2 to be skipped, and the next five characters to replace the characters M,O,N,T, and H in storage. If an input record containing ABCbbbXYZ is read with the format specification 10 FORMAT(T7,A3,TJ,A3) then the characters XYZ and ABC are read, in that order. The field descriptor nX may be used to introduce blanks into output records or to skip characters of input records. The letter X specifies the operation and n is a positive integer that specifies the number of character positions to be either made blanks (output) or skipped (input). Example The statement FORMAT (5H~STEPI5,lOX2HY=F7.3) may be used to print the line 13-14 CHAPTER 13 Print Control Characters 13.3 CARRIAGE CONTROL CHARACTERS FOR PRINTING ASCII RECORDS The first character of an ASCII record may be used to control the spacing operations of the line printer or terminal printer unit on which the record is being printed. The control character desired is specified by beginning the FORMAT field specification for the ASCII record to the output with IHA ... where a is the desired control character. The control characters permitted in DECsystem·20 FORTRAN and the effect each has on the printing device are described in Table 13·5. Table 13·5 FORTRAN Print Control Characters FORTRAN Character Octal Value Effect LF 012 Skip to next line with form feed after 60 lines 0 zero LF,LF 012 Skip a line 1 one FF 014 Form feed - go to top of next page space Printer Character + plus * Suppress skipping overprint the line DC3 023 Skip to next line with no form feed - minus LF,LF,LF 012 Skip two lines 2 two DLE 020 Space 1/2 of a page 3 three VT 013 Space 1/3 of a page / slash DC4 024 Space 1/6 of a page period DC2 022 Triple space with a form feed after every 20 lines printed DCl 021 Double space with a form feed after every 30 lines printed asterisk , comma Note: Printer control characters DLE, DCl, DC2, DC3, and DC4 affect only the line printer. In order to print these control characters users must specify the switch /FILE:FORTRAN when giving the PRINT command. 13·15 CHAPI'ER 14 Device Control Statements, Introduction DECsystem-20 FORTRAN extensions to the 1966 ANSI standard set are printed in boldface italic type. CHAPTER 14 DEVICE CONTROL STATEMENTS 14.1 INTRODUCTION The following device control statements may be used in FORTRAN source programs: 1. REWIND 2. UNLOAD 3. BACKSPACE! 4. ENDFILE 5. SKIPRECORD! 6. SKIPFILE, and 7. BACKFILE The general form of the foregoing device control statements is keyword u keyword (u) where keyword u is the statement name is the FORTRAN logical device number (Chapter 10, Table 10-1) The operations performed by the device control statement are normally used only for magnetic tape device (MT A). In DECsystem-20 FORTRAN, however, the device control operations are simulated for disk devices. ! The results of these commands are unpredictable when used on list-directed and NAMELIST-controlled data. 14-1 REWlND,UNLOAD,BACKSPACE ENDFILE CHAPTER 14 14.2 REWIND STATEMENT Descriptions of the form and use of the REWIND statement follow: Form: REWIND u Use: Move the file contained by device u to its initial (load) point. If the medium is already at its load point, this statement has no effect. Subsequent READ or WRITE statements that reference device u will transfer data to or from the first record located on the medium mounted on device u. Example: REWIND 16 14.3 UNLOAD STATEMENT Descriptions of the form and use of the UNLOAD statement follow: Form: UNLOADu Use: Move the medium contained on device u past its load point until it has been completely rewound onto the source reel. Example: UNLOAD 16 14.4 BACKSPACE STATEMENT Descriptions of the form and use of the BACKSPACE statement follow: Form: BACKSPACE u Use: Move the medium contained on device u to the start of the record that precedes the current record. If the preceding record prior to execution of this statement was an endfile record, the endfile record becomes the next record after execution. If the current record is the first record of the file, this statement has no effect. NOTE This statement cannot be used for files set up for random access or NAMELIST-controlled I/O operations. Example: BACKSPACE 16 14.5 END FILE STATEMENT Descriptions of the form and use of the END FILE statement follow: Form: END FILEu Use: Write an endfile record in the file located on device u. The endfile record defines the end of the file which contains it. If an endfile record is reached during an I/O operation initiated by a statement that does not contain an END= option, the operation of the current program is terminated. Example: END FILE 16 14-2 SKIP RECORD, SKIP FILE, BACKFILE Statements, Summary CHAPTER 14 14.6 SKIP RECORD STATEMENT Descriptions of the form and use of the SKIP RECORD statement follow: Form: SKIP RECORD u Use: In accessing the file located on device u, skip the record immediately following the current (last accessed) record. The repeat option may be used to cause any desired number of records to be skipped. Example: SKIP RECORD 16 14.7 SKIP FILE STATEMENT Descriptions of the form and use of the SKIP FILE statement follow: Form: SKIPFILEu Use: In accessing the medium located on unit u, skip the file immediately following the current (last accessed) file. If the number of SKIP FILE operations specified exceeds the number of following files available, an error will occur. Example: SKIP FILE 01 14.8 BACKFILE STATEMENT Descriptions of the form and use of the BACKFILE statement follow: Form: BACKFILEu Use: Move the medium mounted on device u to the start of the file which precedes the current (last accessed) file. If the number of BACKFILE operations performed exceeds the number of preceding files, completion of the last operation will move the medium to the start of the first file on the medium. Example: BACKFILE 20 14.9 SUMMARY OF DEVICE CONTROL STATEMENTS The form and use of the DECsystem-20 FOTRAN device control statements are summarized in Table 14-1. Table 14-1 Summary of DECsystem-20 FORTRAN Device Control Statements Statement Form REWINDu UNLOADu END FILEu SKIP RECORD u SKIP FILE u BACKFILEu BACKSPACE u Use Rewind medium to its load point Rewind medium onto its source reel Write an endfile record in to the current me Skip the next record Skip the next file Move medium backwards 1 file Move medium back one record 14-3 Types of Subroutine Statements and Arguments CHAPTER 15 DECsystem-20 FORTRAN extensions to the 1966 ANSI standard set are printed in bold/ace italic type. CHAPTER 15 SUBPROGRAM STATEMENTS 15.1 INTRODUCTION Procedures that are used repeatedly by a program may be written once and then referenced each time the procedure is required. Procedures that may be referenced are either internal (written and contained within the program in which they are referenced) or external (self-contained executable procedures that may be compiled separately). The kinds of FORTRAN procedures that may be referenced are: a. statement functions b. intrinsic functions (DECsystem-20 FORTRAN defined functions) c. external functions, and d. subroutines The first three of the foregoing categories are referred to, collectively, as either functions or function procedures; procedures of the last category are referred to as either subroutines or subroutine procedures. 15.1.1 Dummy and Actual Arguments Since subprograms may be referenced at more than one point throughout a program, many of the values used by the subprogram may be changed each time it is used. Dummy arguments in subprograms represent the actual values to be used which are passed to the subprogram when it is called. Functions and subroutines use dummy arguments to indicate the type of the actual arguments which they represent and whether the actual arguments are variables, array elements, arrays, subroutine names or the names of external functions. Each dummy argument must be used within a function or subroutine as if it were a variable, array, array element, subroutine, or external function identifier. Dummy arguments are given in an argument list associated with the identifier assigned to the subprogram; actual arguments are normally given in an argument list associated with a call made to the desired subprogram. (Examples of argument lists are given in the following paragraphs.) The position, number, and type of each dummy argument in a subprogram list must agree with the positio' number, and type of each actual argument given in the argument list of the subprogram reference. 15-1 Dummy Arguments CHAPTER 15 Dummy arguments may be a. variables b. array names c. subroutine identifiers d. function identifiers, or e. statement label identifiers which are denoted by the symbol *, $, or &. When a subprogram is referenced, its dummy arguments are replaced by the corresponding actual arguments supplied in the reference. All appearances of a dummy argument within a function or subroutine are related to the given actual arguments. Except for subroutine identifiers and literal constants, a valid association between dummy and actual arguments occurs only if both are of the same type; otherwise, the results of the subprogram computations will be unpredictable. Argument association may be carried through more than one level of subprogram reference if a valid association is maintained through each level. The dummy factual argument associations established when a subprogram is referenced are terminated when the desired subprogram operations are completed. The following rules govern the use and form of dummy arguments: a. The number and type of the dummy arguments of a procedure must be the same as the number and type of the actual arguments given each time the procedure is referenced. b. Dummy argument names may not appear in EQUIVALENCE, DAr A, or COMMON statements. c. A variable dummy argument should have a variable, an array element identifier, an expression, or a constant as its corresponding actual argument. d. An array dummy argument should have either an array name or an array element identifier as its corresponding actual argument. If the actual argument is an array, the length of the dummy array should be less than or equal to that of the actual array. Each element of a dummy array is associated directly with the corresponding elements of the actual array. e. A dummy argument representing a subroutine identifier should have a subroutine name as its actual argument. f. A dummy argument representing an external function must have an external function as its actual argument. g. A dummy argument may be defined or redefined in a referenced subprogram only if its corresponding actual argument is a variable. If dummy arguments are array names, then elements of the array may be redefined. Additional information regarding the use of dummy and actual arguments is given in the description of how subprograms are defined and referenced. 15-2 CHAPTER IS Statement and Intrinsic Functions 15.2 STATEMENT FUNCTIONS Statement functions define an internal subprogram in a single statement. The general form of a statement function is: name (argl ,arg2,... ,argn)=E where name is a user-formulated name comprised of from 1 to 6 characters. The name used must conform to the rules for symbolic names given in Paragraph 3.3. The type of a statement function is determined either by the first character of its name or by being declared in an explicit or implicit type statement. (argl . . .argn) represents a list of dummy arguments. E is an arbitrary expression. The expression E of a statement function may be any legitimate arithmetic expression which uses the given dummy arguments and indicates how they are combined to obtain the desired value. The dummy arguments may be used as variables or indirect function references; but they cannot be used as arrays. The dummy argument names bear no relation to their use outside the context of the statement function except for their data type. The expression may reference DECsystem-20 FORTRAN defined functions (Paragraph 15.3) or any other defined statement function, or call an external function. It may not reference any function that directly or indirectly references the given statement function or any subprogram in the chain of references. That is, recursive references are not allowed. Statement functions produce only one value, the result of the expression which it contains. A statement function cannot reference itself. All statement functions within a program unit must be defined before the first executable statement of the program unit. When used, the statement function name must be followed by an actual argument list enclosed within parentheses and may appear in any arithmetic or logical expression. Examples SSQR(K)=(K*(K +1)*2*K+ 1)/6 ACOSH(X)=(EXP(X/ A)+ EXP( - X/A))/ 2.0 15.3 INTRINSIC FUNCTIONS (DECsystem-20 FORTRAN DEFINED FUNCTIONS) Intrinsic functions are subprograms that are defined and supplied by DECsystem-20 FORTRAN. An intrinsic function is referenced by using its assigned name as an operand in an arithmetic or logical expression. The names of the DECsystem-20 FORTRAN intrinsic functions, the type of the arguments which each accepts, and the function it performs are described in Table IS-I. These names always refer to the intrinsic function unless they are preceded by an asterisk (*) or ampersand (&) in an EXTERNAL statement, declared in a conflicting explicit type statement, or are specified as a routine dummy parameter. 15-3 CHAPTER IS Table of Intrinsic Functions Table 15-1 Intrinsic Functions (DECsystem-20 FORTRAN Defined Functions) Function Mnemonic Absolute value: Real Integer Double precision Complex to real ABS* IABS* DABS* CABS Conversion: Integer to real Real to integer FLOAT* IFIX* Double to real Real to double Integer to double Complex to real (obtain real part) Complex to real (obtain imaginary part) Real to complex Truncation: Real to real Real to integer Double to integer Remaindering: Real Integer Double precision Definition Number of Arguments I Real Integer Double Complex Real Integer Double Real I I Integer Real Real Integer SNGL DBLE* DFLOAT REAL* I I I I Double Real Integer Complex Real Double Double Real AlMAG I Complex Real 2 Real Complex I Real Real I I Real Double Integer Integer 2 2 2 Real Integer Double Real Integer Double ;;;'2 ;;;'2 ;;;'2 ;;;'2 ;;;'2 Integer Real Integer Real Double Real Real Integer Integer Double ;;;'2 ;;;'2 ;;;'2 ;;;'2 ;;;'2 Integer Real Integer Real Double Real Real Integer Integer Double CMPLX* AINT INT* IDINT AMOD MOD* DMOD arg arg arg c=(X2+y2)1/2 I I Type of Argument Function 1 Sign of arg * largest in teger ~ largl c= Arg 1 +i * Arg2 Sign of arg * largest in teger ~ largl { Th, "m,ind" when Arg I is divided by Arg 2 } Maximum value: AMAXO AMAXI* MAXO* MAXI DMAXI { M,,(Mg, ,A'g" .. ) } Minimum Value: AMINO AMINI * MINO* MINI DMINI { Min(Mg, ,Mg" .. *In line functions. 154 J Table of Intrinsic Functions External Functions CHAPTER 15 Table 15-1 (Cont) Intrinsic Function (DECsystem-20 FORTRAN Defined Functions) Function Mnemonic Definition Number of Arguments Transfer of Sign: Real Integer Double precision SIGN* ISIGN DSIGN { Sgn(kg,)'lkg, I Positive Difference: Real Integer DIM* lDIM { kg, - Min(kg, ,kg, J J Type of Argument Function 2 2 2 Real Integer Double Real Integer Double 2 2 Real Integer Real Integer *In line functions. 15.4 EXTERNAL FUNCTIONS External functions are function subprograms that consist of a FUNCTION statement followed by a sequence of FORTRAN statements that define one or more desired operations; subprograms of this type may contain one or more RETURN statements and must be terminated by an END statement. Function subprograms are independent programs that may be referenced by other programs. The FUNCTION statement that identifies an external function has the form type FUNCTION name (argI ,arg2,... ,argn) where type is an optional type specification as described in section 6.3. These include INTEGER, REAL, DOUBLE PRECISION, COMPLEX or LOGICAL (plus the optional size modifier, *n, for compatibility with other manufacturers.) name is the name assigned to the function. The name may consist of from I to 6 characters, the first of which must be alphabetic. The optional size modifier (*n) may be included with the name if the type is specified. (Refer to section 6.3.) (argi, . . . ,argn) is a list of dummy arguments. If type is not given in the FUNCTION statement, the type of the function may be assigned, by default, according to the first character of its name, or may be specified by an IMPLICIT statement or by an explicit statement given within the subprogram itself. Note that if a user wants to use the same name for a user-defined function as the name of a FORTRAN defined function Oibrary basic external function), the desired name must be declared in an EXTERNAL statement and prefixed by an asterisk (*) or ampersand (&) in the referencing routine. (Refer to section 6.7 for a description of the EXTERNAL statement.) 15-5 Rules For FUNCTION Statements, Basic External Functions Generic Function Names CHAPTER 15 The following rules govern the structuring of a FUNCTION subprogram: a. The symbolic name assigned a FUNCTION subprogram must also be used as a variable name in the subprogram. During each execution of the subprogram this variable must be defined and, once defined, may be referenced as redefined. The value of the variable at the time of execution on any RETURN statement is the value of the subprogram. NOTE A RETURN statement returns control to the calling statement that initiated the execution of the subprogram. See Paragraph 15.4.1 for a description of this statement. b. The symbolic name of a FUNCTION subprogram must not be used in any nonexecutable statement in the subprogram except in the initial FUNCTION statement or a type statement. c. Dummy argument names may not appear in any EQUIVALENCE, COMMON, or DATA statement used within the subprogram. d. The function subprogram may define or redefine one or more of its arguments so as to effectively return results in addition to the value of the function. e. The function subprogram may contain any FORTRAN statement except BLOCK DATA, SUBROUTINE PROGRAM, another FUNCTION statement or any statement that directly or indirectly references the function being defined or any subprogram in the chain of subprograms leading to this function. f. The function subprogram should contain at least one RETURN statement and must be terminated by an END statement. The RETURN statement signifies a logical conclusion of the computation made by the subprogram and returns the computed function value and control to the calling program. A subprogram may have more than one RETURN statement. The END statement specifies the physical end of the subprogram and implies a return. 15.4.1 Basic External Functions (DECsystem-20 FORTRAN Defined Functions) DECsystem-20 FORTRAN contains a group of predefined external functions which are referred to as a basic functions. Table 15-2 describes each basic function, its name, and its use. These names always refer to the basic external functions unless declared in an EXTERNAL or conflicting explicit type statement. 15.4.2 Generic Function Names The compiler generates a call to the proper DECsystem-20 FORTRAN defined function, depending on the type of the arguments, for the following generic function names: 15-6 Generic Function Names SUBROUTINE Statement CHAPTER IS ABS AMAXI AMINI ATAN ATAN2 COS INT MOD SIGN SIN SQRT EXP ALOG ALOGIO In the following example K=ABS (I) the type of I determines which function is called. If I is an integer, the compiler generates a call to the function lABS. If I is real, the compiler generates a call to the function ABS. If I is double precision, the compiler generates a call to the function DABS. The function name loses its generic properties if it appears in an explicit type statement, if it is specified as a dummy routine parameter, or if it is prefixed by "*,, or "&" in an EXTERNAL statement. When a generic function name, which was specified unprefixed in an EXTERNAL statement, is used as a routine parameter, it is assumed to reference a DECsystem-20 FORTRAN defined rLillell(lll "lllil' saille nanle. or if nOlle exist. a user-defined function. Note that IMPLICIT statements have no cllcct L1pclll the data typc of gencric functioll names unless the name has been removed from its class using an EXTERNAL statement. 15.5 SUBROUTINE SUBPROGRAMS A subroutine is an external computational procedure which is identified by a SUBROUTINE statement and mayor may not return values to thc calling program. The SUBROUTINE statement used to identify a subprogram of this type has the form: SUBROUTINE name(argI ,arg2, ... ,argn) where name (argl, . . . ,argn) is the symbolic name of the subroutine to be defined. is an optional list of dummy arguments. 15-7 Table of Basic External Functions CHAPfERlS Table 15-2 Basic External Functions (DECsystem-20 FORTRAN Defined Functions) Function Exponential: Real Double Complex Logarithm: Real Mnemonic EXP DEXP CEXP Definition ( } eArg Number of Arguments Type of Argument Function 1 1 1 Real Double Complex Real Double Complex ALOG ALOGIO DLOG DLOGIO CLOG loge(Arg) log! o(Arg) log/Arg) log! o(Arg) log/Arg) 1 1 1 1 1 Real Real Double Double Complex Real Real Double Double Complex Square Root: Real Double Complex SQRT* DSQRT CSQRT (Arg)1/2 (Arg)1/2 (Arg)1/2 1 1 I Real Double Complex Real Double Complex Sine: Real (radians) Real (degrees) Double (radians) Complex SIN* SIND DSIN CSIN 1 1 1 1 Real Real Double Complex Real Real Double Complex Cosine: Real (radians) Real (degrees) Double (radians) Complex COS* COSD DCOS CCOS 1 Real Real Double Complex Real Real Double Complex Hyperbolic: Sine Cosine Tangent SINH COSH TANH sinh(Arg) cosh(Arg) tanh(Arg) 1 1 I Real Real Real Real Real Real Arc sine AS IN asin(Arg) 1 Real Real Arc cosine ACOS acos(Arg) 1 Real Real Arc tangent Real Double Two REAL arguments Two DOUBLE arguments ATAN* DATAN ATAN2* DATAN2 atan(Arg) datan(Arg) atan( Arg! / Arg2 ) atan(Arg! / Arg2) 1 1 Real Double Real Double Real Double Real Double Double Complex { SiO(kg} {'OO(~} *Generic Functions. 15-8 I 1 1 2 2 CHAPfER15 CALL Statement Table 15-2 (Cont) Basic External Functions (DECsystem-20 FORTRAN Defined Functions) Function Mnemonic Definition Complex Conjugate CONJC Arg=X+iY,CONJC=X-iY Random Number RAN Result is a random number in the range of 0 to 1.0. Number of Arguments 1 I Dummy Argument Type of Argument Function Complex Complex Integer, Real, Double, or Complex Real The following rules control the structuring of a subroutine subprogram: 15.5.1 a. The symbolic name of the subprogram must not appear in any statement within the defined subprogram except the SUBROUTINE statement itself. b. The given dummy arguments may not appear in an EQUIVALENCE, COMMON, or DATA statement within the subprogram. c. The su broutine subprogram may define or redefine one or more of its arguments so as to effectively return results. d. The subroutine subprogram may contain any FORTRAN statement except BLOCK DATA, FUNCTION, another SUBROUTINE statement, or any statement that either directly or indirectly references the subroutine being defined or any of the subprograms in the chain of subprogram references leading to this subroutine. e. Dummy arguments that represent statement labels may be either an *, $, or &. f. The subprogram should contain at least one RETURN statement and must be terminated by an END statement. The RETURN statements indicate the logical end of a computational routine; the END statement signifies the physical end of the subroutine. g. Subroutine subprograms may have as many entry points as desired (see description of ENTRY statement given in Paragraph 15.4.1). Referencing Subroutines (CALL Statement) Subroutine subprograms must be referenced using a CALL statement of the following form: CALL name(argl ,arg2, ... ,argn) where name is the symbolic name of the desired subroutine subprogram. (argi, . . . ,argn) is an optional list of actual arguments. If the list is included, the given actual arguments must agree in order, number, and type with the corresponding dummy arguments given in the defining SUBROUTINE statement. 15-9 CALL Statement Arguments, FORTRAN Subroutines, RETURN Statement Multiple Returns CHAPTER 15 The use of literal constants is an exception to the rule requiring agreement of type between dummy and actual arguments. An actual argument in a CALL statement may be: a. a constant b. a variable name c. an array element identifier d. an array name e. an expression f. the name of an external subroutine, or g. a statement label. Example The subroutine SUBROUTINE MATRIX(I,J,K,M, *) END may be referenced by CALL MATRIX(IO,20,30,40,$IOI) 15.5.2 DECsystem-20 FORTRAN Supplied Subroutines DECsystem-20 FORTRAN provides the user with an extensive group of predefined subroutines. The descriptions ,and names of these predefined subroutines are given in Table 15-3. 15.6 RETURN STATEMENT AND MULTIPLE RETURNS The RETURN statement causes control to be returned from a subprogram to the caIling program unit. This statement has the form RETURN (standard return) or RETURN e (multiple returns) where e represents an integer constant, variable, or expression. The execution of this statement in the first of the foregoing forms (i.e., standard return) causes control to be returned to the statement of the calling program which foIlows the statement that called the subprogram. 15-10 Multiple Returns CHAPTER 15 The multiple returns form of this statement (i.e., RETURN e) enables the user to select any labeled statement of the calling program as a return point. When the multiple returns form of this statement is executed, the assigned or calculated value of e specifies that the return is to be made to the eth statement label in the argument list of the calling statement. The value of e should be a positive integer which is equal to or less than the number of statement labels given in the argument list of the calling statement. If e is less than 1 or is larger than the number of available statement labels, a standard return operation is performed. NOTE A dummy argument for a statement label must be either a "', $, or & symbol. Any number of RETURN (standard return) statements may be used in any subprogram. The use of the multiple returns form of the RETURN statement, however, is restricted to SUBROUTINE subprograms. The execution of a RETURN statement in a main program will terminate the program. Example Assume the following statement sequence in a main program: CALL EXAMP(l ,$IO,K,$15,M,$20) GO TO 101 10 15 20 Assume the following statement sequence in the called SUBROUTINE subprogram: SUBROUTINE EXAMP (L,*,M,*,N,*) RETURN RETURN RETURN(C/D) END 15-11 CHAPTER 15 Referencing External FUNCTION Subprograms Each occurrence of RETURN returns control to the statement GO TO 101 in the calling program. If, on the execution of the RETURN(C/D) statement, the value of (C/D) is: Less than or equal to: 1 2 3 The following is performed: a standard return to the GO TO 101 statement is made the return is made to statement 10 the return is made to statement 15 the return is made to statement 20 Greater than or equal to: 4 The following is performed: a standard return to the GO TO 101 statement is made. o 15.6.1 Referencing External FUNCTION Subprograms An external function subprogram is referenced by using its assigned name as an operand in an arithmetic or logical expression in the calling program unit. The name must be followed by an actual argument list. The actual arguments in an external function reference may be: a. a variable name b. an array element identifier c. an array name d. an expression e. a statement number f. the name of another external procedure (FUNCTION or SUBROUTINE). NOTE Any subprogram name to be used as an argument to another subprogram must first appear in an EXTERNAL statement (Chapter 6) in the calling program unit. Example The subprogram defined as: INTEGER FUNCTION ICALC(X,Y,Z) RETURN END may be referenced in the following manner: TOT AL = ICALC(IAA,IAB,IAC)+500 15-12 ENTRY Statement, Multiple Entry Points CHAPTER 15 15.7 MULTIPLE SUBPROGRAM ENTRY POINTS (ENTRY STATEMENT) DECsyst('m-20 FORTRAN prol'ides an ENTR Y statement which enables the user to speczf.v additional entry points into an e.\"t('l"I1al subprogram. This statement used in conjunction with a RETURN statement enables the user to employ on~l' olle computational routille of a subprogram which confains several such routines. The form of the ENTR Y statement is: ENTR Y name(argl,arg2,. . . ,argn) where name is the symbolic name to be assigned the desired entry point (argI, . . . ,argn) is an optional list of dummy arguments. This list may contain a. variable names b. array declarators c. the name of an external procedure (SUBROUTINE or FUNCTION), or d. an address constant denoted by either a *, $, or & symbol The rules for the use of an ENTR Y statment follow. a. The ENTRY statement allows entry into a subprogram at a place other than that defined by the subroutine or function statement. Any number of ENTR Y statements may be included in an external subprogram. b. Execution is begun at the first executable statement following the ENTR Y statement. c. Appearance of an ENTR Y statement in a subprogram does not preclude the rule that statement functions in subprograms must precede the first executable statement. d. Entry statements are nonexecutable and do not affect the execution flow of a subprogram. e. An ENTR Y statement may not appear in a main program, nor may a subprogram reference itself through its entry points. f. An ENTR Y statement may not appear in the range of a DO or an extended DO statement construction. g. The dummy arguments in the ENTRY statement need not agree in order, number, or type with the dummy arguments in SUBROUTINE or FUNCTION statements or any other ENTRY statement in the subprogram. However, the arguments for each call or function reference must agree with the dummy arguments in the SUBROUTINE, FUNCTION, or ENTR Y statement that is referenced. h. Entry into a subprogram initializes the dummy arguments of the referenced ENTRY statement, all appearances of these arguments in the entire subprogram are initialized. i. A dummy argument may not be referenced unless it appears in the dummy list of an ENTR Y, SUBROUTINE, or FUNCTION statement by which the subprogram is entered. 15-13 CHAPTER 15 Entry Points j. The source subprogram must be ordered such that references to dummy arguments in executable statements must follow the appearance of the dummy argument in the dummy list of a SUBROUTINE, FUNCTION, or ENTR Y statement. k. Dummy arguments that were defined for a subprogram by some previous reference to the subprogram are undefined for subsequent entry into the subprogram. I. The value of the function must be returned by using the current entry name. 15-14 CHAPTER IS Table of Library Subroutines Table 15-3 DECsystem-20 FORTRAN Library Subroutines Subroutine Name DATE Effect Places today's date as left-justified ASCII characters into a dimensioned 2-word array. CALL DATE (array) where array is the 2-word array. The date is in the form dd-mmm-yy where dd is a 2-digit day (if the first digit is 0, it is converted to a blank), mmm is a 3-digit month (e.g., Mar), and yy is a 2-digit year. The data is stored in ASCII code, left-justified, in the two words. DEFINE FILE A DEFINE FILE caIl can be used to establish and define the structure of each fIle to be used for random access I/O operations. NOTE The OPEN statement may be used to perform the same functions as DEFINE FILE. The format of a DEFINE FILE call may be CALL DEFINE FILE (u,s,v,f,proj,prog) where DEFINE FILE (cont) u = logical the size of the records which comprise the me being defined. The argument s may be an integer constant or variable. s v FORTRAN device numbers. = an associated variable. The associated variable is an integer variable that is set to a value that points to the record that immediately follows the last record transferred. This variable is used by the FIND statement (Chapter 10). At the end of each FIND operation the variable is set to a value that points to the record found. The variable v cannot appear in the I/O list of any I/O statement that accesses the fIle set up by the DEFINE FILE statement. f = fIlename to be given the fIle being defined. 1 proj = user's project number. prog = user's programmer's number. lRefer to Appendix B for detailed information on how to specify a directory for the DECsystem-20. 15-15 Table of Library Subroutines CHAPTER 15 Table 15-3 (Cont) DECsystem-20 FORTRAN Library Subroutines Effect Subroutine Name Example The statement CALL DEFINE FILE (I,IO,ASCYAR,'FORTFL.DAT',O,Q) DUMP establishes a file named FORTFL.DAT on device 01 (i.e., disk) which contains word records. The associated variable is ASCY AR, and the file is in the user's area. Causes particular portions of core to be dumped and is referred to in the following form: where Land U I are the variable names which give the limits of core memory I to be dumped. Either LI or U I may be upper or lower limits. F 1 is a number indicating the format in which the dump is to be performed: a = octal, 1 = real, 2 = integer, and 3 = ASCII. If F is not 0, 1, 2, 3, the dump is in octal. If F n is missing, the last section is dumped in octal. If Un and F n are missing, an octal dump is made from L to the end of the J·ob area. If Ln , U n , and F n are missing, the entire job area is dumped in octal. The dump is terminated by a call to EXIT. ERRSET Allows the user to control the typeout of execution-time arithmetic error messages, ERRSET is called with one argument in integer mode. CALL ERRSET(N) Typeout of each type of error message is suppressed after N occurrences of that error message. If ERRSET is not called, the default value of N is 2. EXIT Returns control to the Monitor and, therefore, terminates the execution of the program. ILL Sets the ILLEG flag. If the flag is set and an illegal character is encountered in floating point/double precision input, the corresponding word is set to zero. 15-16 CHAPTER 15 Table of Library Subroutines Table 15-3 (Cont) DECsystem-20 FORTRAN Library Subroutines Subroutine Name Effect CALL ILL LEGAL Clears the ILLEG flag. If the flag is set and an illegal character is encountered in the floating point/double precision input, the corresponding word is set to zero. CALL LEGAL PDUMP The arguments are the same as those for DUMP. PDUMP is the same as DUMP except that control returns to the calling program after the dump has been executed. RELEAS CALL RELEAS(unit*) Closes out I/O on a device initialized by the FORTRAN Operating System and returns it to the uninitialized state. SAVRAN SETABL SA VRAN is called with one argument in integer mode. SA VRAN sets its argument to the last random number (interpreted as an integer) that has been generated by the function RAN. CALL SET ABL(I,J) Specifies a character set where I is an integer which gives the number of the desired character set. If a character set has been defined by I, the value of J is set to 0; if not, J is set to -1. The standard ASCII character set is defined as 1. SETRAN SETRAN has one argument which must be a non-negative integer < 2 3 I. The starting value of the function RAN is set to one value of this argument, unless the argument is zero. In this case, RAN uses its normal starting value. 15-17 CHAPTER 15 Table of Library Subroutines Table 15-3 (Cont) DECsystem-20 FORTRAN Library Subroutines Subroutine Name TIME Effect Returns the current time in its argument(s) in left-justified ASCII characters. If TIME is called with one argument, CALL TIME(X) the time is in the form hh:mm where hh is the hours (24-hour time) and mm is the minutes. If a second argument is requested, CALL TIME(X,Y) the first argument is returned as before and the second has the form bss.t where ss is the seconds, t is the tenths of a second, and b is a blank. 15-18 CHAPTER 16 BLOCK DATA Statement DECsystem-20 FORTRAN extensions to the 1966 ANSI standard set are printed in boldface italic type. CHAPTER 16 BLOCK DATA SUBPROGRAMS 16.1 INTRODUCTION Block data subprograms are used to initialize data to be stored in any common areas. Only specification and DATA statements are permitted (i.e., DATA, COMMON, DIMENSION, EQillVALENCE, and TYPE) in block subprograms. A subprogram of this type must start with a BLOCK DATA statement. If any entry of a labeled common block is initialized by a BLOCK DATA subprogram, the entire block must be included even though some of the elements of the block do not appear in DATA statements. Initial values may be entered into more than one labeled common block in a single subprogram of this type. An executable program may contain more than one block data subprogram. 16.2 BLOCK DATA STATEMENT The form of the BLOCK DATA statement is BLOCK DATA name where name is a symbolic name given to identify the subprogram. 16-1 APPENDIX A ASCII-1968 CHARACTER CODE SET The character code set defined in the X3.4-1968 Version of the American National Standard for Information Interchange (ASCII) is given in the following matrix. 1st 2 octal digits Last octal digit 0 I OOX Olx 02x 03x 04x 05x NUL BS DLE CAN 06x 07x lOx Ilx 12x 13x 14x 15x 16x 17x SOH HT DCI EM ! ) I 9 A I Q Y a i q y ~ ( 0 8 @ H p x grave h p x 2 3 4 5 6 7 STX LF DC2 SUB ETX VT DC3 ESC ENQ CR NAK GS % * # + ACK SO SYN RS & BEL SI ETB US " EaT FF DC4 FS $ , - 2 3 4 5 6 , < = > D L T E M U F N V \ 1 1\ (t) b j r C K S [ c k s d I t e m u f n v z { I } ~(ESC) B J R Z , I 7 ? G a W -g Characters inside parentheses are ASCII-I 963 Standard. NUL SOH STX ETX EaT ENQ ACK BEL BS HT LF VT FF CR SO SI Null Start of Heading Start of Text End of Text End of Transmission Enquiry Acknowledge Bell Backspace Horizontal Tabulation Line Feed Vertical Tabulation Form Feed Carriage Return Shift Out Shift In DLE DCI DC2 DC3 DC4 NAK SYN ETB CAN EM SUB ESC FS GS RS US DEL A-I Data Link Escape Device Control I Device Control 2 Device Control 3 Device Control 4 Negative Acknowledge Synchronous Idle End of Transmission Block Cancel End of Medium Substitute Escape File Separator Group Separator Record Separator Unit Separator Delete (Rubout) (+-) 0 w DEL Graphic subsets 64 95 APPENDIX B SPECIFYING DIRECTORY AREAS DECsystem-20 FORTRAN has two ways in which the user can access another user's directory. The first way is via a logical name in place of the device name; the second way is via a project-programmer number instead of a directory name. Either method can be used with FORTRAN; however, use of a logical name is recommended. NOTE When the user sees a project-programmer number (i.e., a number similar to [4,204 J) in this manual or in an error message, he can use the TRANSL program to find out its corresponding directory name. Refer to Section B.I.l. For more information about referencing other user's files, refer to the DECsystem-20 USER'S GUIDE. 8.1 USING LOGICAL NAMES To use a logical name in accessing another user's directory, the user: 8.1.1 1. Gives the DEFINE system command to define a logical name (of no more than six characters) as the other user's directory name. 2. Uses the logical name in place of the device name when typing the file specification. Giving The DEFINE Command To give the DEFINE command, the user: 1. Types DEFINE and presses the ESC key; the system prints (LOGICAL NAME). @DEFINE (LOGICAL NAME) 2. Types the logical name (ending it with a colon is optional) and presses the ESC key. The system prints (AS). @DEFINE (LOGICAL NAME) BAK: (AS) 3. Types the directory name (enclosed in angle brackets) and presses the RETURN key. The system prints an@. @DEFINE (LOGICAL NAME) BAK: (AS) To check the logical name, the user can give the INFORMATION (ABOUT) LOGICAL-NAMES system command. @INFORMATION (ABOUT) LOGICAL-NAMES BAK = > @ B-1 B.1.2 Using The Logical Name The user can the" include the logical name in with FORTRAN by typing the logical name in place of a device name. The following example shows how the user would output a log file to the directory named . (Remember he has already defined the logical name BAK: as .) Ca!FORTRA *BAK:TEST B.2 USING PROJECT-PROGRAMMER NUMBERS To use a project-programmer number in accessing another user's directory, the user: 1. Runs the TRANSL program to find the corresponding project-programmer number for the desired directory name. 2. Includes the project-programmer number after the file type. The user does not have to define a logical name when he uses a project-programmer number; however, project-programmer numbers may not remain constant over time. Logical names should be used whenever possible. 8.2.1 Running The TRANSL Program To run the TRANSL program, the user: I. Types TRANSL and presses the RETURN key. The system prints TRANSLATE (DIRECTORY). @TRANSL TRANSLATE (DIRECTORY) 2. Types the directory name and presses the RETURN key. The system prints the corresponding project-programmer number. (a!fRANSL TRANSLATE (DIRECTORY) BAKER IS [4,204] (a) The user can also use the TRANSL program to verify that a project-programmer number is correct. He simply replaces the directory name with the project-programmer number. (aTfRANSL TRANSLATE (DIRECTORY) [4,204] [4,204] IS (w 8.2.2 Using The Project-Programmer Number The user can use the project-programmer number with FORTRAN by typing the project-programmer number after the file type. The following example shows how the user compiles a FORTRAN program from the directory named BAKER, using a project-programmer number. (Remember he has already translated the directory name.) (a)FORTRA *TEST.REL,TEST.LST = TEST. FOR [4,204J B-2 APPENDIX C USING THE COMPILER This appendix explains how to access DECsystem-20 FORTRAN and how to make use of the information it provides. The reader should be familiar with the FORTRAN language and the DECsystem-20 operating system. C.l RUNNING THE COMPILER The command to run FORTRAN is @FORTRA The compiler responds with an asterisk (*) and is then ready to accept a command string. A command is of the general form object filename, listing filename=source filename(s) The following options are given to the user: C.l.l 1. The user may specify more than one input file in the compilation command string. These files will be logically concatenated by the compiler and treated as one source file. 2. Program units need not be terminated at file boundaries and may consist of more than one file. 3. If no object filename is specified, no relocatable binary file is generated. 4. If no listing filename is specified, no listing is generated. 5. If no type is given, the defaults are .LST (listing), .REL (relocatable binary), and .FOR (source) for their respcLtive files. Switches Available with DECsystem-20 FORTRAN Switches to DECsystem-20 FORTRAN are accepted anywhere in the command string. They are totally position and file independent. The switches are shown in Table C-1. C-l Table C-1 FORTRAN Compiler Switches Switch Defaults Meaning CROSSREF Generate a me that can be input to the CREF program. OFF DEBUG See Section C.I.I.I. OFF EXPAND Include the octal-formatted version of the object me in the listing. OFF INCLUDE Compile a D in card column 1 as a space. OFF MACROCODE Add the mnemonics translation of the object code to the listing me. OFF NOERRORS Do not print error messages on the terminal. OFF NOWARNINGS Do not output warning messages. OFF OPTIMIZE Perform global optimization. OFF SYNTAX Perform syntax check only. OFF Each switch must be preceded by a slash (/). Switches need consist of only those letters that are required to make the switch unique. But users are encouraged to use at least three letters to prevent conflict with switches in future implementations. Example @FORTRA *OFILE,LFILE=SFlLE/MAC,S2FILE The /MAC switch will cause the MACRO code equivalent of SFILE and S2FILE to appear in LFILE.LST. c.1.1.1 The /DEBUG Switch - Using the /DEBUG switch tells FORTRAN to compile a series of debugging features into the user program. Several of these features are specifically designed to be used with FORDDT. Refer to Appendix F for more information. By adding the modifiers listed in Table C-2, the user is able to include specific debugging features. C-2 Table C-2 Modifiers to /DEBUG Switch Meaning Modifiers : DIMENSIONS Generates dimension information in .REL me for FORDDT. :TRACE Generates references to FORDDT required for its trace features (automatically activates :LABELS). :LABELS Genertltes a label for each statement of the form "line-number L." (This option may be used without FORDDT.) :INDEX Forces DO LOOP indices to be stored at the beginning of each iteration rather than held in a register for the duration of the loop. : BOUNDS Generates the bounds checking code for all array references. Bounds violations will produce run-time error messages. Note that the technique of specifying dimensions of 1 for subroutine arrays will cause bounds check errors. (This option may be used without FORDDT.) The format of the /DEBUG switch and its modifiers is as follows: /DEBUG:modifier or /DEBUG:(modifier list) Options available with the /DEBUG modifiers are: 1. No debug features - Either do not specify the /DEBUG switch or include /DEBUG:NONE. 2. All debug features - Either /DEBUG or /DEBUG:ALL. 3. Selected features - Either a series of modified switches; i.e., /DEBUG:BOU /DEBUG:LAB or a list of modifiers /DEBUG:(BOU,LAB, ... ) 4. Exclusion of features (if the user wishes all but one or two modifiers and does not wish to list them all, he may use the prefix "NO" before the switch he wishes to exclude). The exclusion of one or more features implicitly includes all the others, i.e., /DEBUG:NOBOU is the same as /DEBUG:(DIM,TRA,LAB,IND). C-3 If more than one statement is included on a single line, only the first statement will receive a label (/DEBUG:LABELS) or FORDDT reference (/DEBUG:TRACE). (The /DEBUG option and the /OPTIMIZE option cannot be used at the same time.) NOTE If a source file contains line sequence numbers that occur more than once in the same subprogram, the /DEBUG option cannot be used. The following formulas may be used to determine the increases in program size that will occur due to the addition of various /DEBUG options. DIMENSIONS: For each array, have 3+3*N words where N is the number of dimensions, and up to 3 constants for each dimension. TRACE: One instruction per executable statement. LABELS: No increase. INDEX: One instruction per inner loop plus one instruction for some of the references to the index of the loop. BOUNDS: For each array, the formula is the same as DIMENSIONS:. For each reference to an array element, use 5+N words where N is the number of dimensions in the array. If BOUNDS: was not specified, apprOximately 1+3*(N- 1) words would be used. C.I.2 LOAD-Class Commands FORTRAN can also be invoked by using one of the LOAD-class commands. These commands cause the system to interpret the command and construct new command strings for the system program actually processing the command. COMPILE LOAD EXECUTE DEBUG Example @EXECUTE(FROM)ROTOR The compiler switches OPT, CREF, and DEBUG may be speCified directly in LOAD-class commands and may be used globally or locally. Example @EXECUTE(FROM)/CREFPI.FOR,P2.FOR/DEBUG:NOBOU The other compiler switches must be passed in parentheses for each specific source file. C4 Refer to the DECsystem-20 User's Guide for further information. C.2 READING A DECsystem-20 FORTRAN LISTING When a user requests a listing from the FORTRAN compiler, it contains the following information: 1. A printout of the source program plus an internal sequence number assigned to each line by the compiler. This internal sequence number is referenced in any error or warning messages generated during the compilation. If the 'input ftle is line sequenced, the number from the ftle is used. If code is added via the INCLUDE statement, all INCLUDEd lines will have an asterisk (*) appended to their line sequence number. 2. A summary of the names and relative program locations (in octal) of scalars and arrays in the source program plus compiler generated variables. 3. All COMMON areas and the relative locations (in octal) of the variables in each COMMON area. 4. A listing of all equivalenced variables or arrays and their relative locations. 5. A listing of the subprograms referenced (both user defined and DECsystem-20 FORTRAN defined library functions). 6. A summary of temporary locations generated by the compiler. 7. A heading on each page of the listing containing the program unit name (MAIN., program, subroutine or function, principal entry), the input ftlename, the list of compiler switches, and the date and time of compilation. 8. If the /MACRO switch was used, a mnemonic printout of the generated code is appended to the listing. This section has four fields: LINE: This column contains the internal sequence number of the line corresponding to the mnemonic code. It appears on the first of the code sequence associated with that internal sequence number. An asterisk indicates a compiler inserted line. LOC: The relative location in the object program of the instruction. LABEL: Any program or compiler generated label. Program labels have the letter "P" appendeci. Labels generated by the compiler are fol1owed by the letter "M". Labels generated by the compiler and associated with the /DEBUG:LABELS switch consist of the internal sequence number followed by an "L". GENERATED CODE: The MACRO mnemonic code. 9. A list of all argument areas generated by the compiler. A zero argument appears first followed by argument blocks for subroutine calls and function references (in order of their appearance in the program). Argument blocks for all I/O operations fol1ow this. C-5 10. Format statement listings. 11. A summary of errors detected or warning messages issued during compilation. C.2.1 Compiler Generated Variables In certain situations the compiler will generate internal variables. Knowing what these variables represent can help in reading the macro expansion. The variables are of the form: .letter digit digit digit digit i.e., .SOOOl where: Letter Function of Variable S Result of the DO LOOP step size expression of computed iteration count for a loop. o Result of a common subexpression or constant computation. Result of a DO LOOP initial value expression or parameters of an adjustably dimensioned array. F Arithmetic statement function formal parameters. R Result of reduced operator strength expression (0.2.1.2). The user may find these variables on the listing under SCALARS and ARRAYS. The following example shows a listing where all these features are pointed out. C-6 Name of Ppogpam /./JA i i••/ 11 r·, 1. t i.JK""-------::::I\!;j l~~LIClr Ouluu Uu)uO Oll3OO Ou4u(J Q ...J ~Uj",l -+A 131/ ) 11\1/r'~~/0 1~ : ~ ~AGI:: 1 1 (A-Z) Al1uu.~OUJ.~(lUU.)u0) =u ~LJ1'lL=U =1 • '2 U 0 =1 * J Uu Out:JUU OU" u 0 UUHLU OOYUO ulUuu Ol1vO 012Uv OIJuU u14UO uU IOU 1=] .lua Ol~Uu \I. l~l~G~k ulM~~~lU~ uO~ViJ 01000 01 I UU 01800 01 ':h) li MACRO code equivalent Name of Soupce File 1 (; u .j 1<.1 1~(1\1 A( ~uu .LI. J.J J=1<.1 Kl=U 1'\1 .Gl. l~UO) 1UO .UR. K2 .~U. 2UU .Uk. .UH. I\I.=l+J l~(I\L .~U. 1\2.~U.300) K2=K2+1 tHl.J)=K2 SLJM1=SUM1+1\1 ~UM2=SuM2+1\2 lOu CUNI1NU~ .... '- ItP~ 1U lU.~UM1.SUM1 ~'UHMA1('H SUMl= .19.10H .19) SUi'12= ~NU SUb~HUGHAM~ CMLL~U The relative address of all variables is given, SCALARS A~U AKRAiS *Kl *SU:" 7. 11blu:) b +1 "*" i~U t.)\f'LiCIT 2 11blOb 1'J ... ,,2 u~i"lNITIUI\i 41042 1101UI - "%" A 'SUMl NOl' H~r'I::REi'4CI::O 4 '/04 J I1b11U j .5U001 11b103 ~compiter .50000 generated vapiablea 116104 ! Internal sequence number on first instruction that goes with that line , L ll~ t: L,JC 30u U 1 2 .3 400 4 ~uO ~ octal displacement of instruction. LAlH.L ,J toC L 000 10 .3 1'\ : 7uO 11 4 [11\: HUu 1.3 1 <.j. 1 :> 1b 9UL 100 L) I'IU V l:. '). l'/1/b.3400Uuli 1 r,lUVr.. .LJ .1 • 0 l /. ) i . 1\ 1 .1 • I b 4 .1 • L 1 .14 O.ot'l dkS'J. ().~M Sr:tZtJ 4 • 1\ 1 Hl!Vl:.l j t'. lJ L AUUl i • 1 4 <+ 1.1. 1.3 I.() ). 1 ~ t'l : r.. 24 I'iu ~ L~ iii U 'y l:. i"! 20 IVI 31 32 33 3,* 3~ U Vl:- AUUI r·lUy 1:.1'1 r'lltV l:. Ju j compiler generated label 01'·\: .. )/ 1 1u u 7.<1 CA lLI:. JkST 1 / d00 hkkZC>1 IHULl '" u V t: IVI CALL 11. 00 H I.Jt 2 t-' 1'l.l[JLST. ,)b v i:.l LJ Sl"iJ j'IU V i:.l ':)7 ~)USHJ 1 h • 11·1 1 "I • r, X 1 '1 • A k C,l.i i·d~ 1'1 I I'IU IH, u:':;\ S \0 : ........- - - - - - - - - - - - - - - - - - - - - - - - - ~l1'gumen t u •• DO b I U 1 H: u •• u 1 () i"1 : U •• -/ I 11 I 3 •• nL rd 04 u •• u () •• U 34U •• 101-' li •• 7 /v U •• U I 1 II. 1 1 fil 1 1 Uli •• Sliil'll II1lU •• Suh) : I .l 'HJUU •• U 'u K •. \ A J S 11\ T to ,'1 t" :', 1 S IJblli 110111. 1161J1 I1b114 (1 lO; IU~: llnl!':> 1 1 0 lit) L u ,', ~) t.l; 1"_ t_ i, 'I ) : ( J tl L J 1',1 = • 1Y • 1 uH ~..; U,vII = .1 Y 1 I b I 1/ 1": A {I, • l (J 'III i'j 1 0':> i> b 07 IHUU 1 h • 1 U [.j 1/.UU1'. 1 h • 1 1 l"i I'll! '" ~~ 1 ~'LJ ::'11 J 53 54 j5 l,)uu program label AUS AuSGi:. LIHSr 51 170u ~ i.l\) 43 41 SO Q A{J~ :.u t,l- 00 "'"'- MA ll~ • OObUO OU/OO OO~OO UO<.JOO 01000 01100 01200 0130U v.4AlJl/) t.XAlv1PLI:.. Ut< A UuUnLt. PHt.Cl~lUh I.; HI t. I~ ~ I U N I:) l 1 U ) ",..'''- ,.. '- "'- lrlt. AH~UMI:..~lb /i\l/ivl CALL TO 1 1 : 0 ':1 2o-JAi,,-/o A SUtH 1 L.{cI~(lbj ").UCT 31v'1: Ij -...l O.(clU(16) O.kEALl () • Cd 1 ( 1 b ) O.ARYNAM O.{cli(lb) O. AkYr~LM t.td3(1td t-IG VI:; j\'lUVi:.r1 r-ilJlJ E..l f 1 7. • Ak'tNAfvl /..777711(2J rilLJ v t:.l i'i U VI:. i'l :1..771 7..UCT fl:Wv'1:; f :~055 ""0'-"215 00/056 0PH057 00 ~~ 0 60 00lfll61 00 ~·~062 00;'06J 01lH064 0liP065 002066 001067 ~"21r2'05 i2l01Z1012!5 0'-"1ZI0QJ5 0"~eJ05 2l000~0 21"21005 ,,0121QJ05 0 P1 0005 o L'!IZI 2105 00~"2I0 0~QJ005 211Z1"0~0 0QJ002'0 ~~lZIrl1"5 00.~027 0000~0 2l000~flJ 01210005 ill I2l 210 21 5 0"~0?0 00;'071 002'072 00?07J flJ0l12174 0'h~0JQJ 121001210QJ ill"I1~05 1210i.~031 1210001l1~ 0QJ0flJ05 00J032 0012l0~121 121 0 21005 "'0!..~03J l2liJ000QJ 0~12I0flJ5 001'076 00(1034 00CoI2IJ5 rzl0 ;;10.J6 00?0J7 00v' QJ4121 12112100~12I 000QJ05 1210210021 ~H'l1Zl005 121000021 0"00QJ5 0QJ0121Q)0 121 021 2'QJ 5 00121213121 12100005 01211ZJ12I~1ZI flJrzl0005 00121121021 001llQJ1ll5 00('1131 00;;102 1210;"10J 0001134 00J105 00~~12I41 00'·'rzl42 0"H~075 1210v~077 00~'10QJ E-7 ~001210121 2lrzJ0~05 12100005 {J01Z1C1J05 0 0 210215 210212105 0021005 0 0 21005 0021005 0000~H' 0 0 8flJI2I5 0021000 00108' 0121~12100 1210iJ285 00001'lflJ C1J00000 liH?J1ZJ001Z1 001210121121 0000Q10 I2lQJ0000 0QJ00k'0 C1J00"~0 0~12I01Z15 0121~"00 21"'21005 002'00flJ "O0005 ?J0121001Z1 0 0 2112105 00~0210 2J0QJ005 01210021121 0012101215 ~030~0 21021005 0~N~00 a0001215 121017,106 00';:107 013~~11121 0r21;~111 121130112 013(11113 11l1ll,111~ I1lPJZl15 000116 0133117 00v3120 r210~1121 0ftH~122 013?123 "0,a24 00~125 00:--126 000127 00013" 00~131 00~132 00~133 000134 "'0~13' "0 ~a 36 "00137 00\1~140 Ql0r.141 00?142 Ql0~143 12113/,144 00~~145 00V'146 00J147 2I2I~' 1513 000151 13l2li~ 152 12112l1..~153 130'~ 15 .. ~13Q!~eJr2I 13"'''''135 21 13 Q!21eJ13 ~01313215 01300013 ,,0"005 0130121013 0"'1321135 0"~W:1013 0 0 130135 "'0013013 00210"5 "'02102113 00210215 "'13012113121 00121211215 "'00121013 0021"1215 rzJ00"12I0 21""0215 eJ"21021" 0""0135 "'''112100 o1ZI"r2! "5 "021210121 00211211215 013210013 ~0"13135 0000"0 00"13215 21"121021" 00"13~5 0812112112113 ~eJ0121135 BIIIII eJ0"""5 0"elle e"811l'" 2181210"'0 0"""21' ""121 121 tlI 0 0"""rzl5 02100(l10 01212102121 0"0C1J05 "130021" 0"210rzl5 0"121130121 21 0"21 rzl 5 00/210 000211 00<1212 "'0;;213 00J214 "'02215 1210t216 002217 00f22tl 000221 000222 000223 01300013 0"012105 001225 ~1300~121 2100000 ~13121"'~121 "'~0Q1"7 00,"155 000156 QlrtJ?157 001160 QlrcH161 elr2I0~12I13 ~00007 130~1162 02100021 ~013Ql07 00~~163 00;':164 2113(165 "00166 "0~167 Ql01~ 110 00;~171 (/l0tJ172 002201 r210i202 00('203 210D21214 lZ113l205 121121\.11206 13~h~207 00k~224 0~"r2105 0"00013 "eJ0r21137 0"2)0013 o"IZJe!eI 7 0130012113 0~0007 013Q10013 :;,r;,13eJ07 01Zl11'~013 000007 013e!I2I013 """"07 0130121210 ~0"007 t':I1300013 ~H'JIZJ007 013012112113 ,,00121137 00~226 0133227 13022321 130~231 13132232 131212233 -Number of words to next LSCW. 2I0i~234 2102235 130~236 "'0;3237 00"'2413 2107241 r/!00242 00'7243 00Z2~4 00~245 1301246 00C247 00/25r/l 00e251 0'H'J"~0 ~~0007 013C1J0013 W'0130137 "'000121121 00130137 01301210121 0""007 eJ13I2!~013 01300013 0012101217 0ltHlJ0013 ~0"r2101 00~176 00~177 0r21~,1200 eJ~8"05 00130021 0"""05 211312101210 0'-"210,,5 00001210 0~"005 013300121 ~fll12l146 211211"12121 0~"032 01210121~0 00;~17~ 00V'115 121""0"5 00~1252 1210:1253 ~0"001 2I13~"254 0130iZ1013 0""121137 211321 Ii' 00 12l"~0r.31 2!0Q!000 ~0~0137 002255 00J256 00J257 E-8 2!0"~137 "rlHH 73 013~H.'l0r21 ~12!13r21137 li"HH'013 0°""'137 0132~"?J2I 0'" 13114 0130000 0"""'07 (7)13130013 ~0r21007 00"2'013 021121121"7 o kHHH!l 121 0"""07 01300!tHI a00"131 012102112113 [3"'0"'137 013k!'0~13 13 0 130131 1111300021 121"012107 0121021"0 0""ClJ137 "00000 13"'''007 013130~" 02'121121"7 0132100" 0rt1130"7 "0et0~13 0""~"7 ""21000 ~IZ!I007 ~130000 0r210~"7 0~~0"'7 0000021 rzl""0rzl7 ""elk""0 12121"0137 010~210 00132107 01121~21 13lZ!rzl12l2l7 0fIJ2I0 1321 13""2101 0131301210 0"01307 ""0W:1013 0"""'''7 01312112121" 0021r1!1rll7 ""013~0 ",,121""217 00k"H!l0 0"""137 01312113~0 021 ""rzl 7 "121 0 21rZl" 0"00"7 0121000" 0""121137 ~1212I"I2121 2l"""rzl7 01300",,, 0°""137 2112121121221 000"'1217 ""00~12I 021""07 o r/l 21 121 2113 13"'02'137 [21001300 ~00~07 ~"0"013 (lI00e!137 0210"00 0 0 132107 "13~000 0000137 01300021 12I~0N'J7 o (lI 021 013 210130137 0r/l "'121 013 0""007 01300013 2121""137 ~130~0121 0021007 0r/l000121 0"0""7 013130021 121 0 "007 01301210121 0°"'-"137 e!'IHl000 00"~~1 0tiH'Hll ~" Co:ttinue LSCW. "'~H260 "'000210 0~0007 ~0~~261 00~"~0 000''-''P 0~"~ 2 62 00001210 00l26~ 0r,,,3264 1210~265 I2lfih:266 00,1267 00;~270 00~271 00i272 00l2?3 "'0~~214 002275 0~h~276 e1rllt:277 0rlle312!0 1211210301 "~0007 000007 0001211210 000007 001210~H' 000007 fll00000 12100007 fZJ012!000 0C1!0007 'HHIJ0"'0 ",002107 000000 ~"0007 000000 011J0007 fll00fZJ00 21 0 0007 fll000210 ,,0012107 021 12Ii21 21121 ~"0007 "'0000121 000"07 00"fZl~0 00~312!2 01210303 0003"4 12100305 00J306 00~307 ~0~310 1210'['311 000312 00.?313 fZJ0l314 fZl0~I2Ic!lr2J ~"0001 00012100 2100000 k'l00fZl00 fZl00000 fZlfZJ0fZJ00 fZJ0012100 0000210 00012100 0000210 fll012!000 "'0fll000 000121210 0~0fl!07 ~00~07 0"30~0 000007 a~0007 0ill000] ~"'J0007 000007 21 rIl 00 IZl 7 000007 00001Zl7 00001Zl7 ok'l 021 121 7 000147 Image mode files contain no LSCW's. This file cannot be backspaced. C C ~OOK AT AN IMAGE MODE PI~E CONTROL WORDS. AND SEE NO ~OGICA~ SEGMENT OP£NCUNI Tc 1,MODE·'IMAGE' ) 1-5 WRIT£(l) (I, J=1,100) J=,,! WRITE(1) (J,K=1,100' END f2J0.H"'0 0f2J~f2J01 00"002 "f2J0003 001004 00002'5 ~0]0f2J6 00.il007 00~010 12100011 0f2J0el12 003013 0f2J~f2J14 fll0v)015 12101f2J16 000017 0021020 0021021 000022 0021023 2l0~fZJ0121 00J024 ~eJ2I0215 0210000 0~0005 "12101210121 0"0f2J05 ~00000 000005 12100'2!00 0 0 0005 121000021 ~021"'05 21012100'" 0~0005 002'000 ",O121005 00",00121 0"'0005 000kHHl i)00005 "000",0 e021ra2l5 2'00000 ~021005 00012100 000005 000Wl2l0 ~00005 0121~0~0 000005 000000 ~0121005 00~fZJ~12I 0021005 ~12I00~a ~00"25 ""~026 00~027 001t030 000031 0021032 000033 00('1034 000035 00J036 00~037 ~"~040 000041 00('1042 00i3f2J43 00~044 00~045 2l~00a5 00~046 ra0210e1121 00a005 "000e10 000~H~15 00~047 E-9 ~2I001210 0000~0 ~"2I0fZJ' ~00005 '2!00fZJ00 ~00005 2'0001210 ~"2I005 000000 12l"0005 000121210 0et0005 ~"0fZJ021 ",O0005 121012100'" 12100005 12100000 2)"'0005 1210012100 ~00005 "00000 0 0 210215 12100000 ~H~0005 12100000 eJ001210S 0000.,0 12l"'0005 eJ000~0 130121005 00012l0k'l 0"00215 000000 0eJ0005 00012100 0~00215 01210000 fil~0005 el 12112!r2J 00 ~0"2105 e IIh' 121 5121 0121012151 1210\-112152 12101053 00~054 1210i1055 00J056 0121012157 00~06121 001061 1210e062 0121(~063 00?064 00 fJ,065 012101210121 k'J"""0k'J 1210"'1210121 "'0000k'J 0121k'J12I0k'J ?Jk'J000k'J 121121000121 012100"121 00""ek'J 12112101211210 ~01211211215 ~12I~~V'l12J ~Q!12I1211215 ~01210Qj5 012H~000 01210~~121 ~ra00eJra ~"12Ij{l12l5 ~""12101215 eJ0"H~05 00:~07J ~12I001210 eJ~0~~12I 0121el0~121 ~01210~5 \30~~1215 1210·:'016 e!12I12!000 12100005 0':H~I~ell2I 21012101215 ~~ra0~121 0 21 121005 eJ0000121 ~0121005 12102100121 012101211215 0012100121 ~"l2IrzJI2I5 ell2l~00121 0 0 12101215 e! 121121 0 121 121 I2lIiHl'rzl05 002'121121121 0 0 12101215 elI2I0000 02!12I1(J~5 012100021 el ti'l12l 005 12l121000" ~000"5 00000121 00/1HH'5 00012100 ~0'H'05 I2lI21 2112121 0 0"'~005 ~12101210121 0"0005 12l1210fZ1121121 021001215 211212102'121 1210~01215 01210~"H' 001210"5 00000121 ~00005 011.1210210 a"'0005 i2l000011.1 01210005 i2l1210"0121 01210005 121 IIIJ " 210 0211210215 0rUlZl00 0011112105 01111"'0 000"1215 210"0011J 12I¥l0005 0121 ""'011J 12100211215 01210121"'121 121 0 121131215 21121"'' '0121 Ql "'121 k'J05 00ra~ra0 1fJ0001215 12!0~~102 000103 12102104 1210 ~~105 12!"W106 00011217 00e110 000111 12102112 00/113 12100114 000115 1210~~116 00~111 1210012121 0rcH3121 12100122 000123 12100124 00i'l12' 000126 00k'!121 0121013121 121121w:l131 00~132 000133 01210134 00~154 1210?155 1210;2156 1210e.157 1Z10,')160 "121000121 0""12101215 1210,/074 0e;~100 1Z10~144 01210145 01/"'146 0rrh'147 001150 ril0,l151 12100152 121I21H53 ~etk'J12I05 ~"0005 "~001115 12!0(J101 00~142 001143 ~H'12I01215 ~121"121121121 ~"00~0 1210~"'77 "0~141 01CHlr2I~12I 00121005 1211210"00 21012101215 00,112166 00('067 1210712170 121121212171 00/12172 00~075 1211210135 01212136 121121('137 12100140 001211211215 k'l"k'J12I1215 1210121"'05 ""'001215 21"'12101215 00121005 kH" 121 0 1215 0001210121 (ZI'H" 00 ° "'00121~121 0121q!00121 rzl12l000121 121121211210121 1211211211210121 ~12101210121 f2JI2I~121"'121 00~~00 ~00~'" 0~"!l00121 0fZl0~07 el12IQl0~0 12100000 00C162 12103163 00:;'164 0003165 002166 1210 ..'167 00el0~121 fl!12I1210~12I 00.~172 002173 00~174 el0~175 00(H76 121121"1211215 21"'01211215 ""12Ik'J12I5 01i'J0"05 k'J"'0"12I5 121 21 12101215 0121121rtJI2I5 0012101211 21 rlI 00121 1 0121121001 00121211217 12101211211211 121 121 00:!J0 012101210121 "~l2Irill2l' "'121 ril " 00 121 rll 121121 121 7 01210000 1210121211217 121121021:11121 ~1Z'~0"7 2'12I0ra~0 12101211211217 00~161 00(~11121 ril0;~171 00~211217 ~000et7 000e107 00012121121 el0~Ql01 00111~12I7 ~011112107 el12l2'0~0 00001217 01211210121121 0021021121 0121012100 12112101210121 121001210121 el001211210 02101211217 00121007 0 0 111"'1217 0QJQle'00 0f21Q12J~k'J ~tIl1ll02!7 00121121"'7 21012112107 121210"'1217 0 21 121007 00~177 0121~~2!0 el000~0 00C20121 1210021211 r2! 121 00 el 0 121 0121QJ 121 7 002100121 2100r2!07 1210~21212 00~12"'3 000~0121 0000~121 012100~0 ~0P.H2I00 2!~12100? 13"ee~12I ~0111007 1210?]204 1210C205 1210021216 000201 0,'H~ 2U.l 00~211 000212 12100213 000214 000215 000216 I2I1Z1~211 "'0~22" 013~221 E-lO 0~H!100121 12112121121~121 0~0121rl!1 021001217 01Zl1lJ007 13 21 121001 0000210 i2l0111007 000000 01Zl0~07 0000~0 001211211217 012100~0 0011J01217 01210021121 2121121211217 2100r21021 elIZl1ll011J1 013 1(JI2I ell2I 0131111210' 0121121130121 ~00007 ~~"'00121 000"'13' 01110021121 ~0012111J7 2102100" 2101211211217 1lJ"~222 0"(3223 rIl""224 IhH~225 ""J226 "e~22" I1Jrn23" l1Jee!231 I1Jrll0232 l1J"l233 (hH'234 11J0~235 21"~236 I1JQH~ 237 00e24" 2100241 11J(IH242 I1JrtJ0243 00'·' 244 "01245 000246 021 ,3247 00~!.250 210:" 251 12!01,252 "02253 00?254 """""" (ZI""Il'", """""" """""" iae"""," ell!l"""" """"' "RlB0"., "0"0"" 0 0 "0(Z17 (,HJ r;, " " 0""""7 "02J021rl' ,,0"0rl'7 "0et000 ""0007 0rl'(llfll2lrl' (2J01!1""., "0121""0 000"0' 12! 0 " " " 0 " IIHHIJrH 00"I2!Ql0 ,,!?IIZ"'01 0""12!",, ,,!?I0"1!I" 21"rl'rl'"" """"B'? ,,2I1!101!17 I1J IHI " " " zI1JB2I((J' "0r1le"" ""2255 ",,2256 "rtJ2257 00·2260 "rtJ?261 "21 i? 262 "rll ~1263 "0t?,264 121"21""" "I.H'0011J QJ0i'266 21rl'(ll0~rl' ~H'0007 00~~26' 21(1"1101210 0",,,0"'0 "00""0 12!00""" "21"2121" "0""0121 "~HHH~ 0 r;, 0 C:H!! eI 0 211210000 01211l10QJI2I QJ0"""T "'''''' "8 """"B., """"'" "It"'" "'''''''''' 12!0~~265 ,,002107 rl'Pl1!l01!1' I2l rl' 21""""0 ""0"0' 21"00"0 "01l1"~0 ,,000217 1Z10,,00" 0""12107 "0"""0 """"1217 21121"""0 12J~0"01 00027" I1Jrllk~271 11J0~272 rl'~H1273 021;'214 "0~'275 ~021001 000216 """0~" fll0~f2I~0 2l0""'1217 el000'31l1 ~12'0~1217 r21000q10 ~f;30~07 ""0012100 Z00007 000"~0 0 0 121007 00000111 0 121 0007 01210000 ~00t2l07 00000121 0012101217 00;J,30" "0Z,301 et0e'0~121 "0(~2'7 (lI01'~31212 00~~31213 00,~31214 Ql0~"305 "0;1306 0r.H1301 012100~7 el """,,~(Z17 0121""07 0 0 ""0' 000"0' 0"121"0' a" """ 7 0 0" 0 01 0~121001 121"001217 2J00001 0121(l1000 0001210' 2I12100~" 0121~1210121 0 0 "I
Source Exif Data:File Type : PDF File Type Extension : pdf MIME Type : application/pdf PDF Version : 1.6 Linearized : Yes XMP Toolkit : Adobe XMP Core 4.2.1-c041 52.342996, 2008/05/07-21:37:19 Modify Date : 2017:08:04 12:50:26-07:00 Create Date : 2007:07:04 11:43:10+10:00 Metadata Date : 2017:08:04 12:50:26-07:00 Creator Tool : Adobe Acrobat 7.08 Format : application/pdf Document ID : uuid:ec522810-2d4e-47a8-be78-bd40367c3ec7 Instance ID : uuid:e67485d1-b68e-7440-a760-375259d49a6a Producer : Adobe Acrobat 9.0 Paper Capture Plug-in Page Layout : SinglePage Page Count : 252 Creator : Adobe Acrobat 7.08EXIF Metadata provided by EXIF.tools