Digital PDFs
Documents
Guest
Register
Log In
AA-R953A-TK
March 1983
161 pages
Original
7.4MB
view
download
OCR Version
7.2MB
view
download
Document:
F4LangRef Mar83
Order Number:
AA-R953A-TK
Revision:
0
Pages:
161
Original Filename:
AA-R953A-TK_F4LangRef_Mar83.pdf
OCR Text
PDP-11 FORTRAN IV Language Reference Manual Order No. AA-R953A-TK March 1983 This document describes the fundamentals of the FORTRAN IV language elements, as implemented for the PDP-11 systems. SUPERSESSION/UPDATE INFORMATION: This manual contains information concerning FORTRAN IV as of March 1983 SOFTWARE VERSION TO OPERATING SYSTEM AND VERSION: FORTRAN |V V2.6 e RSTS/E V8.0 * RT-11 V5B e RSX-11M V4.1 ¢ RSX-11M-PLUS V2.1 VAX/VMS V3.0 digital equipment corporation - maynard, massachusetts First Printing, June Revised: December 1974 1974 December 1975 June 1977 September 1979 March 1983 The and information should in not this be document is construed subject as a to change commitment by Corporation. Digital Equipment Corporation assumes for any errors that may appear in this document. The software and may license. described be wused or in this copied document only in is no furnished accordance without Digital responsibility under with notice Equipment the a license terms of such No responsibility is assumed for the use or reliability of software on equipment that is not supplied by Digital Equipment Corporation or its affiliated companies. Copyright by 1974, Printed The postpaid READER'S requests the user's documentation. The following are 1975, 1977, 1979, 1983 Digital Equipment Corporation All Rights Reserved. COMMENTS critical trademarks in form U.S.A. on the evaluation of Digital to last page assist Equipment of in this document preparing Corporation: DEC DIBOL DEC/CMS EduSystem UNIBUS DECnet IAS VAX DECsystem-10 MASSBUS VMS DECSYSTEM-20 PDP vT DECUS PDT Logo DECwriter RSTS RSX mflannan : ZK2266 HOW TO ORDER ADDITIONAL DOCUMENTATION in Continental USA and Puerto Rico call 800-258-1710 In New Hampshire, Alaska, and Hawaii call 603-884-6660 In Canada call 613-234-7726 (Ottawa-Hull) 800-267-6146 (all other Canadian) DIRECT MAIL ORDERS (USA & PUERTO RICO)* * DIRECT MAIL ORDERS (CANADA) Digitat Equipment of Canada Ltd. 940 Belfast Road Ottawa, Ontario K1G 4C2 Attn: A&SG Business Manager DIRECT MAIL ORDERS (INTERNATIONAL) Digital Equipment Corporation Digital Equipment Corporation P.O. Box CS52008 A&SG Business Manager Nashua, New Hampshire 03061 c/o Digital's local subsidiary or approved distributor *Any prepaid order from Puerto Rico must be placed with the local Digital subsidiary (809-754-7575) Internal orders should be placed through the Software Distribution Center (SDC), Digital Equipment Corporation, Northboro, Massachusetts 01532 future CONTENTS Page ix PREFACE . e s e e e e o o o e o & +« « & +« o « « & . . « .« & « « « « & . . ¢ ¢« ¢ o o & o & ¢ o o o o o o o o & &« o o o o o o o o o o . « . « « .« o o . . o o . .« ¢« &« « + & Logical Constants . Hollerith Constants « . ¢« . ¢« . « « o . & & = N Constants Type . Literals Rules . ¢ ¢ for ¢ ¢ o o o Specification . . . . by Implication . . . . o o o o o o o o . .« « +« + + & ¢« ¢ o o o o o .« .+« ¢ o o o o o .« « « « . o o o o o ¢ o 4 Data o & Array Array References Without Adjustable Arrays . « ¢« Declarators ¢« « Storage Type of EXPRESSIONS = ¢« . an e | I I o o o o 2-13 . . . . . . . . . . 2-14 2-15 Logical of ¢ an o 2-12 2-12 2-13 o type ¢ Subscripts o « o & 2-12 o Data 4 Array Arithmetic Expressions Use of Parentheses . Relational . S Constants o Type Subscripts N o Type Array AU B WN o Data ¢ O . Hollerlth Data ARRAYS e I Constants & T . I . Data O COMPONENTS Precision VARIABLES .« o e +« ¢« . Alphanumeric el e I e « ¢« Field Constants Complex N Indlcator ¢« . Constants Double . | Real . « STRUCTURE NAMES . | STATEMENT . L FORTRAN . . DN NN UNIT . 1 PROGRAM . I Number . . | Sequence .. . . O COWVWOOOIJAOAATUH BN = Field Integer . . . I Field Statement CONSTANTS Field Statement Continuation TYPES Formatting Formatting Indicator Debugging e LINE O Set FORTRAN Label Comment e s | Statement ¢ e [I ¢ e . e o ¢ N o . NN BB W WN N o = A ¢ O ¢ + Character Tab-Character N OV D WWWN - .« + ¢ ¢ Character-per-Column DATA AU D W) .« « + PROGRAMS [ w FORTRAN . FORTRAN = (WP OF 1V — OVERVIEW FORTRAN NN N N LANGUAGE SYMBOLIC . PDP-11 ELEMENTS FORMATTING WK = e o6 ® o e 8 6 ® e e ® 8 6 8 & & 6 ° e s 6 e o o o NN NN NNDNNNNDNNNBNNNNONNDNNNDNNNND MDD DNNODN CHAPTER TO Statements Comments . N R e o o B e S py W S ey DWWWWwWwwwwhDoND NP INTRODUCTION |o 1 SOOI OTd B B RWWWWWwWwwwN - CHAPTER Arithmetic Expressions Expressions iii . . . . « . « Expression 2-16 . 2-17 2-18 .+ . & CONTENTS - o & o o o o & . . o o o @ ¢ ¢ ¢ GO TO ¢ ¢ ¢ ¢ o o o o o o & o 4 o o o o o o o o o o o . « « & « o o o & . « « o o o TO Statement . « « o & o o o o o o STATEMENTS .« 4 ¢ ¢ o o Arithmetic IF Statement o . o . o . o o ¢« ¢ o o o o o o s o o o o o o & Logical & . . « ¢ &« ¢ o o o o o o o« . o o o o o s o s o o o o o o = Control . . ¢ ¢ ¢ & o o & o« o o o ' o o o o o s o o o o o o o DO LOOPS + ¢ o ¢ ¢ =+ ¢ &« o « o o o o« o o o o o o o o o LOOPS + o Control Transfers in Extended Range . . ¢ STATEMENT CALL STATEMENT . RETURN STATEMENT o o o o o o ¢ o o o o o o o ¢ o o o o o o o ¢ o o o o o o o o s o o o o o o o o ¢ & ¢ o ¢« o o o o o o o o o o o s STA,TEMENT . Ll Ld * L4 L) L] L) . * L) e L L] L L] L] L L] L o o L] L] L] Ll L] L SPECIFICATION IMPLICIT STATEMENT . ¢ & o 4 TYPE DECLARATION STATEMENTS 4 . o o o o o o o ¢ ¢« ¢ ¢ o o o L ¢ ¢ o ¢ o o o o o & & o o o o o o o o o o . . +« ¢« ¢ ¢ o o Use of Virtual Arrays . . . ¢ 4 « o o o o o o o o o Equivalent . . ¢ ¢ ¢« ¢« « o o o o« o . ¢« & ¢ ¢ ¢ ¢ « o o & . Blocks STATEMENT in Subprograms . . . ¢ o ¢ ¢ o ¢ o ¢ o o o o & o ¢ o ¢ o o o o o o o o o o o . . &+ o o o o o s o o o o o o STATEMENT . ¢ ¢ ¢ ¢ ¢ o o o o o o o & ARGUMENTS . & ¢« ¢ o o o o . ¢ STATEMENT | e the o . &« @ ! WWNHHFOLOIJAADd WNH o . References Common STATEMENT DATA Ll & STATEMENT Extending o on Array Arrays EXTERNAL L] e TR N Making BLOCK . STATEMENT EQUIVALENCE L) STATEMENTS Restrictions PROGRAM L4 STATEMENT Virtual DATA e STATEMENT VIRTUAL N - o DIMENSION COMMON e [ STATEMENT [ ¢« ¢ o o o o ¢ wn END . . 4 o o PAUSE STOP o . » CONTINUE & NN ¢ o DO & Statement Iteration Nested o o DO o o IF STATEMENT o | LY > ST~ S = e | U| Hi= O OWW O] GO o LGN Assigned ¢ S S A T L N LSO S Y Y. |I [I TR I B IOULH WWND DN - Statement o TO S IGNGRS GO Statement o = N o ¢« o o N w s . L] o L] W - e o & STATEMENTS Computed DO WCOJOAUMd WWWWWNNON R o P A & & S & & A ® S 9 S o T s Y L Y o . B O S « + ooy o e o o o o o o e o i o ¢« . « « o o o o o o o o o o o USER-WRITTEN SUBPROGRAMS Statement Functions . . . ¢ ¢« &« ¢« ¢ &« 4 ¢ o ¢ ¢ o o o o o o o o o o o o & . . . « ¢ ¢« ¢ o o o o o o o Subprograms . . . ¢ ¢ ¢ ¢ o o o o o . . ¢ ¢ ¢ ¢ ¢ e o o o o AT YA YO { I OO dWwwNnr L] . ® L) L4 [} L . * . L] L] L [} L . L . L [ L4 L] . . 7 7 N SUBPROGRAM w N - NN L] N WN e @ L] * ® SUBPROGRAMS "Rules = [] . W N Governing Adjustable Function Subprogram Arrays « Subprograms Subroutine FORTRAN ~l N NN CHAPTER ¢ . STATEMENTS Unconditional IF ¢ . . STATEMENT « * W W * [1~Y GO TO . STATEMENT ASSIGNMENT STATEMENT Y W ASSIGN CONTROL AT A CHAPTER ASSIGNMENT LOGICAL b CHAPTER STATEMENTS ARITHMETIC o CHAPTER ASSIGNMENT N 3 w CHAPTER W ww | ww Page LIBRARY FUNCTIONS INPUT/OUTPUT STATEMENTS I/O OVERVIEW Records . . . L] [ * [} ¢ ® . * . L4 [] Ll [ s o o o o o« & Arguments . . . . . & Files o ¢ o o ¢ o o o o o o o o o o o o o o o« 1- ACCeSS MOAES v o ¢ o« o o o ¢ o o o o o o o« o o o 1 iv CONTENTS Page o+ o o o o o o o o o o 1-2 Direct Access . © e s I/0 STATEMENT COMPONENTS e o o Logical Unit Numbers . « « « Format Specifiers =« « o« o+ o Direct Access Record Numbers AcCCeESS & & + e o « o . s o « o « e o ¢ o « o o o o « o o o o o« o s o o o e e o o o o o o o o o o o« o o o o o » o+ 1-3 1-3 1-3 1-3 1-3 o o o o e . o o o » o . o o o o e o 1-3 1-4 1-5 [1-6 1-7 7-7 . e « « o« o . . o . o« o o o @ . . o . 7-9 1-10 7-12 FIELD DESCRIPTORS '« & &« o o o s o o o o s o o I Field DesSCriptor « « o o o o o o o s o o o O Field Descriptor « « « o o o o o o s o s o F Field Descriptor « « « o o ¢ s o o o o« o o E Field DescCriptor « « « o o o o o s o o o s« D Field DesScCriptor « « o o o o o o o o o o o G Field DescCriptor +« o + o o« o o o o s o s o L Field Descriptor +« « o + o o s s o s o o s A Field Descriptor « o « o o « o o o ¢« o o + H Field Descriptor « « o« o o o o o o o o o « X Field DesSCriptor « o o o o o o o o o o o o T Field Descriptor « « « o« o« o o o o o o o o Q Field Descriptor « « « o ¢ o o o o o o o « Dollar Sign Descriptor + « « « o« o o o o o o« Colon DeSCripPtor « « « « o o s o o o o« o o « Complex Data Editing « « « &+« o o« o ¢ o & « « Scale Factor . . . . . e o o o o s+ o« Repeat Counts and Group Repeat Counts .+ « . Default Field Descriptors . « « ¢« o« o o o o+ CARRIAGE CONTROL CHARACTERS . « ¢ « ¢« o« o « o+ FORMAT SPECIFICATION SEPARATORS . ¢« ¢« o o o o EXTERNAL FIELD SEPARATORS .+ ¢ ¢+ ¢ o o o o « « RUN-TIME FORMATS . . . « .+ & . . FORMAT CONTROL INTERACTION WITH INPUT/OUTPUT LISTS ¢« « o s o o o o o o o o o o o o o o o o« SUMMARY OF RULES FOR FORMAT STATEMENTS . . . . General RULlES o &+ o + o o o o o o o o o o o Input RULIES o o o« ¢ o o o o o o o o o o oo Output RULES &« « o o ¢ s o o o o o o o o o o o o o« o o+ o s+ o« « o o « o« o« » o+ o . o« . & o . » o« » o« o+ o« « o« End-of-File Condition and Error Condition Parameters . . . ¢t e o e o o o s o e o e 7.2.5 Input/Output LlStS e e o s s s e o e e e o 7.2.5.1 Simple LiStS « ¢« ¢ o o o o o o o o o o o 7e2.5.2 Implied DO LiStS o « o o o o o o o o o o 7.3 SEQUENTIAL INPUT/OUTPUT . e s e e s e e e 7.3.1 Formatted Sequential Input Statements . . 7.3.2 Formatted Sequential Output Statements . . 7.3.3 List-Directed Input Statements . . . . . 7.3.4 List-Directed Output Statements . « « « « 7435 Unformatted Sequential Input Statement « 7.3.6 Unformatted Sequential Output Statements « 7.4 DIRECT ACCESS INPUT/OUTPUT . « ¢ o o o o o s 7.4.1 Unformatted Direct Access Input Statement 7.4.2 Unformatted Direct Access Output Statement 7.5 ENCODE AND DECODE STATEMENTS .+ o o « o o o o 7-15 7-15 7-16 7=17 - [) L] [] * * L ® [) o L] L] . L] . . o . . L] . e . & L] Keyword 8-23 8-23 . BUFFERCOUNT . Keyword Keyword 8-21 8-22 8=22 * 4 « o BLOCKSIZE « e ASSOCIATEVARIABLE 3 o+ o« 8-10 8-11 8-12 8-12 8-13 8-13 8-14 8-14 8-15 8-17 8-17 8-18 8-18 8-109 8-20 L] . 2 o & o 8=2 8=2 8-4 8-5 8-6 8=7 8-8 8-9 * « . o ¢« . o . . [} . . . Keyword ACCESS * STATEMENT 1 5 71-14 STATEMENTS 3 OPEN INPUT/OUTPUT . AUXILIARY [ CHAPTER o 8.7 8.7.1 8.7.2 8.7.3 e 8.1 8.1.1 8.1.2 8.1.3 8.1.4 8.1.5 8.1.6 8.1.7 8.1.8 8.1.9 8.1.10 8.1.11 8.1.12 8.1.13 8.1.14 8.1.15 8.1.16 8.1.17 8.1.18 8.2 8.3 - 8.4 8.5 8.6 1-14 STATEMENTS e FORMAT * 8 L] CHAPTER * 7.2.4 Sequential L) 7.1.3.2 7.2 7.2.1 7¢2.2 7.2.3 o 7.1.3.1 APPENDIX APPENDIX o +¢ o o o o o o o o o . . « o ¢ o o o o NOSPANBLOCKS o o o o o o o o o ¢ & o & « o o o o o o o & @ Keyword « +« & « o o o o & @ . . o &+ &+ & & o« o o o @ Keyword « « & o « o o o o o @ o Keyword . .« « « & ¢ o o o o o o ¢« o & & o o o o o o o o TYPE Keyword « UNIT Keyword . « ¢ ¢ ¢ & o o o o o o o o . . . ¢ ¢ ¢ ¢ ¢ & ¢ ¢ o o ¢ &« o o o o « o o o o & & . . ¢ & & & o o o o @ & . ¢ ¢ 4 ¢ ¢ ¢ o ¢ o o o ¢« o o« o o o o o o o . . & & ¢ ¢« o o o« o . . . . . « « « . . . . SET . . . CLOSE STATEMENT REWIND STATEMENT BACKSPACE FIND STATEMENT + &+ ENDFILE STATEMENT DEFINE STATEMENT FILE CHARACTER A A.l FORTRAN A,2 ASCII A.3 RADIX-50 B FORTRAN STATEMENT I « .« Keyword RECORDSIZE SHARED « T . o Keyword Keyword READONLY o ® O O HWNEHO CO o b b e b b . = e L] NAME « WN) b [] b MAXREC . Keyword B o Keyword INITIALSIZE D ] FORM I 2 b b = & (I o o o e o o o R OCWOOUWYWOOOODIIIJdO DN o o & NN H o o o — o o« « o » o« ¢ + e o ¢ « o o ¢ « *® & & « W WOWWw W OWw i WO OWWOWWIWOWWOUWYOOY WY ¢« o . Keyword e b O ¢« Q0 . ERR Keyword . . ¢ EXTENDSIZE Keyword b DISPOSE N AU WCOWYW O OWOYVWLOYWWOWWOVYWWOWWOUWYYOWYY o CONTENTS SETS CHARACTER CHARACTER SET SET CONSTANTS LANGUAGE . AND CHAR ACTER SUMMARY B.l EXPRESSION OPERATORS + &+ ¢ ¢ ¢ o o o o o o B.2 STATEMENTS . L4 * L) * B.3 . Ll Ll * . L] . Ll LIBRARY . . 4 4 o o o o o o o o . . &+ &+ o & o o o & . . « + ¢« & « . . . L L] * FUNCTIONS INDEX 1-1 FORTRAN 1-2 Line 1-3 2-1 Array 4-1 Nested 4-2 5-1 Control Transfers and Extended Equivalence of Array Storage . Form Required Order Storage DO . Example and ¢ Lines « ¢ o o o o ¢ o o o o o & ¢ ©¢ ¢ o o o o o o o o Range . . . . o« o+ & . . . . . . . . of .« LoOPS Statements « « | Coding Formatting o B FIGURE O 00 ~JWw-~J U FIGURES Statements Effect of Data Magnitude on G Default Field Widths . . . « Carriage Control Characters ¢« . Summary « OPEN of FORMAT Statement CodesS Keyword vi . « Values . . . . .« . .« . Formats ¢« ¢ ¢ « . « o« o« . « o« . & & « o« o« o o @ . . « « .« o * L N Wb NDUNWN Assignment 00000 O for W Rules * Conversion Types of User-Written Subprograms List-Directed Output Formats . . . L) Names ~J Symbolic o] LU D B | N w NN [ Ol Ll| = | by * Identified Data Type Storage Requirements . . « Result Data Type for Exponentiation 0o Entities o W W - = TABLE WOWWOW-JNWNN N | TABLES CONTENTS ASCII Character Set o o Expression Operators . . FORTRAN Library Functions vii PREFACE MANUAL OBJECTIVES This manual designed as describes the elements a reference, rather than of PDP-11 FORTRAN tutorial, document. IV and 1is This document serves as the FORTRAN language reference manual for several operating systems that run on the PDP-1l1 family of computers. Therefore, no information specific to an operating system is presented here. For that information, refer to the user's guide for each system, INTENDED AUDIENCE Because this is understanding of STRUCTURE OF This manual ® a reference document, readers who FORTRAN will derive maximum benefit. THIS a basic DOCUMENT contains nine chapters and Chapter 1 consists of general and have introduces basic two appendixes. information facts needed concerning for FORTRAN writing FORTRAN programs. ® Chapter 2 describes the components of FORTRAN as symbolic names, constants, and variables. ® Chapter used in 3 describes assignment the program. ® Chapter control 4 deals with control statements, which from one point in the program to another. ® Chapter 5 describes specification characteristics of symbols used type and array dimensions. ® Chapter 6 discusses subprograms, supplied with PDP-11 FORTRAN 1IV. e Chapter 7 covers ® Chapter 8 describes with formatted FORTRAN I/0 the statements, statements, which define such values transfer statements, which define the in the program, such as data both user-written and those input/output. FORMAT statements. ix statements used in conjunction ® ® e Chapter such as 9 contains information on auxiliary CLOSE, and DEFINE FILE. I/0 statements, OPEN, Appendix A FORTRAN 1V. Appendix B summarizes the character summarizes the language sets supported elements of by PDP-11 PDP-11 FORTRAN 1v. ASSOCIATE The DOCUMENTS following documents are of interest to PDP-11 FORTRAN IV programmers: e RT-11/RSTS/E FORTRAN IV User's Guide e RSX, FORTRAN IV User's Guide CONVENTIONS The VAX/VMS USED IN THIS DOCUMENT following conventions ® Uppercase should words type the are used and Lowercase words and are to substitute a ® Brackets @ Braces ([]) ({}) letters words ® and used indicate that you used in examples indicate value of your choice. that you to be can be optional lists this manual: letters letters word or enclose enclose in from in examples as shown. elements. which one element 1is chosen. e In Ellipses repeated addition, (...) indicate that or more times. the following characters: Tab character Space the preceding item(s) one character (TAB) A characters denote special nonprinting CHAPTER INTRODUCTION l.1 LANGUAGE TO 1 PDP-11 FORTRAN 1V OVERVIEW The PDP-11 FORTRAN IV language is based on American National Standard (ANS) FORTRAN X3.9-1966 but includes the following enhancements to ANS FORTRAN: @ You can If the use any arithmetic expression is not integer type. ® Mixed-mode e The expressions following data expression an integer can type contain has been as an type, array subscript. it is converted to elements of any data type. added: LOGICAL*1 ® The IMPLICIT statement symbolic names. e The following redefines input/output the (I/0) implied statements have data type been of added: ACCEPT TYPE PRINT READ WRITE FIND Device-oriented ' I/0 (u'r) (u'r (u'r) Unformatted direct-access I/0 OPEN CLOSE DEFINE File control and specification FILE ENCODE DECODE Formatted in data The specifications END=s and/or ERR=s or WRITE statements in order to statement specified by s when an condition occurs. e Alphanumeric apostrophes) e List-directed I/0 can be a format specification. ® Constants and 1literals (strings can be used in place expressions REWRITE, TYPE, and conversion memory ® WRITE, attribute used are to of of can be included in READ transfer control to the end-of-file or error characters bounded Hollerith constants. perform permitted PRINT formatted in statements. the I/0 by I/O without 1lists of INTRODUCTION e The DO statement TO PDP-11 increment FORTRAN parameter 1V can have a negative value. ® For readability, label ®¢ A ® in a PROGRAM You can ® You e statement include FORTRAN point you can statement. DO an can optionally be used explanatory statement. These include D debugging statements column These letter when you specify a compiler they are treated as comments. in ® in statement can the label use 1. list in The TO arrays provide address space. OF programs sequence of terminated program or program and a following the program. on the begin same with line an as any exclamation is simply command an assigned consist of FORTRAN organized into statements that by statement. an END one or more data referred PROGRAMS subprogram. to program are by as placing compiled only otherwise, GO TO the control as FORTRAN statements a statement A and units. outside is parameter program unit program of throughout normal the rest optional comments. A unit computing executable optional areas program defines An a qualifier; expression large FORTRAN are in statements statement. program statements l1.2.1 arithmetic GO Virtual ELEMENTS FORTRAN any computed PDP-11 FORTRAN IV of this manual. 1.2 comma (!). can You a main comment optional. ® a comments the The in use program procedure can be either consists of is and a a is main one main subprograms. Statements Statements are grouped nonexecutable, program, into two Executable Nonexecutable characteristics, and general statements statements provide classes: specify describe editing and executable the data actions and of arrangement data-conversion a and information. Statements are divided into physical sections called lines. A line is a string of up to 80 characters. If a statement is too long to fit on one line, you can continue it on one or more additional lines, called continuation lines. A continuation 1line 1is identified by a continuation character in the sixth column of that line. (For information on continuation characters, see Section 1.3.4.) You can identify a statement transfer control to statement label an of a statement's is it with or integer initial line. a label obtain number so the placed that other information in the further statements it first contains. five can A columns INTRODUCTION l.2.2 TO PDP-11 FORTRAN 1V Comments Comments program processing a do not affect documentation aid to programmer. describe the processes, actions and to of the the provide program, to greater ease in any way. They are merely You can use them freely to identify in program reading the sections source and program listing. The letter C in the first column of a source line identifies that 1line as a comment. In addition, if you place an exclamation point (!) in the statement portion of a source line, the rest of that line is treated as a comment. Any printable 1.2.3 The character can FORTRAN Character FORTRAN 1. All character in a comment. Set set uppercase appear and consists of: lowercase letters (A through Z, a through z) 2. The numerals 3. The special 0 through characters 9 listed below: Character Name A OY (AB Space or = Equal sign + Plus - Minus * Asterisk / Slash ( ' Left tab sign sign parenthesis ) Right ’ Comma . Period ! Apostrophe parenthesis Quotation mark S Dollar sign ! Exclamation : Colon point Other printable ASCII characters can appear in a FORTRAN statement only as a part of a Hollerith constant or alphanumeric literal (see Appendix A for a list of printable characters). Except in Hollerith constants and alphanumeric literals, the makes no distinction between uppercase and lowercase letters. compiler INTRODUCTION TO 1.3 FORMATTING Each FORTRAN A FORTRAN line has Statement label ® Continuation e Statement field e Sequence number FORTRAN 1IV LINE the e PDP-11 following four fields: field indicator field field You can format a FORTRAN line in two ways: 1) by typing one character per column (character-per-column) or 2) by using the tab character (tab-character) to get from field to field. You can use character-per-column formatting when punching cards, writing on a coding form, or typing on a terminal keyboard. However, you can use character-per-column tab-character formatting, in addition to formatting, only when you are typing at a terminal keyboard. 1.3.1 As Character-per-Column Formatting shown in Figure statement 1-1, labels, sequence numbers. each field. Each column field a FORTRAN line continuation Sections represents a 1.3.3 single 1is divided indicators, through 1.3.6 The character. 1into fields for text, and statement describe the use columns making up each follow. FO RTRAN CODER CODING FORM | mOMEM DATE PAGE € Connnent i SY\A"A.A('P:Jl IDENTIFICATION FORTRAN STATEMENT ! < 12345670 91011 12131413161718192021222)M232027282930313233341530317 30394041 424344454647404950513233545536375059606162016405860676868 701 7217374 757627 707964 C, THIS, PROGRAM CALCULATES PRIME NUMBERS FROM 'L 1O 350, ., + DO 10, A=Vl +——+- .\, AN A 5,00 2, L bbbttt J=I + + S 2 b4 S e e et S e S S o b o s S o B e e + At et S B iS S S e e ee eS e e o o + + =4 ~++—+ - =L/A e T T SIS ARY S + ——t - =1/J B=A-L — I F (B) 3, 4 1F (J,. LJ SQRT, ((FLOAT TY PE ‘705 ! :AQNTAI NQEL‘ L ‘40 +—+ + 1,05 + i T e (l))) e S I S GQ 1O 4 N s N —— ei e I Rl ot S i e o e e T oo e eS e b o e ee e o e e Ti e e ei o oe S S S +—+ FORMAT e ‘0 5 B e U4,'IS e e e I O i o o o o —~+ + +-—+ b+ + 4 PRIME ") s . DN, -— —— Set S -+ -+ b+ b+ + R A + +—t- e e e S T +————4—+ O o i T S U R S eT e A A e S e T S S S e SO G i T e e I e A ST I s S S e IR R DIGITAL IR o St e W G G e >t T R T T o ee S e S HE It S XL e B Ml s S I N R v e B B S S e e s o e oe e e -+ e S e e e S U U I T G S W S 2o ob S Y O o S o o o L IS W U G e U e U e S ST m YT E { e i ol ol 4 - 0-#+¢—+—#—04—04—+—##0f&#+»0—44&440—##—F4++0—++¢—1‘5%#“1 ~+ U e st a8 e S e S S S e e U e V234 8] l S 101 121314131617101920212223262526 2720930 M IV PG-3 SRRS T R e B e S T T L b SRS T S o oo et S PR U e S e e o b S ST e S Ae e S ST SR S ot a2 S g B S8 SR dnaderdrabdrabrbhmhash e S0 +——4 o o S e o mm am o o o oy obasboadnrudonb I NIV W40 414740444340 47484950 3132333453503730596061010)04 0300 7 MH 70 N 7] nnnunnnu EQUIPMENT CORPORATION - MAYNARD, MASSACHUSETYTS ZK-613-82 Figure 1-1: FORTRAN Coding Form INTRODUCTION TO PDP-11 FORTRAN Field Statement Column(s) label Continuation 1 indicator Statement Sequence IV through 5 6 | 7 through 72 number 73 through 80 To get from one field to another, type each space individually. example, in Figure 1-1, enter the first line, type C, press the bar five times, and begin typing the comment. 1.3.2 Tab-Character For space Formatting You can press the tab character to move to the continuation indicator field or the statement field. You cannot move to the sequence number field, however, by pressing the tab. Figure 1-2 compares keystrokes in lines using tab-character formatting and in those wusing character-per-column formatting. Format Using TAB Character Character-per-Coiumn Format 112 3 4 sle6|7 8 910111213i41s1617181920 C Ga® FIRST VALUE C FII|R|S|T VI]A|L 10@B| = J + 5+K + 1]0 I + @B 1 LM = 1 @B IVAL = 1+2 J |U{E 5|+ |K + L+|M I {V[{A]L = Fl+]2 ZK-614-82 Figure 1-2: Line Formatting Example The statement label field consists of the characters that you before the first tab character. The statement label field cannot more than five characters. After you type the first tab character, you can continuation indicator field or the statement field. To enter the statement the end To enter type of FORTRAN then the line. the the continuation field statement statement statement indicator consists of all field, the type characters type any after type have either digit. the the The digit to ' field without immediately starts with a continuation after a'digit. the first indicator tab. Note field, that no INTRODUCTION TO PDP-11 FORTRAN IV Many text editors and terminals advance the terminal print carriage to a predefined print position when you type the TAB key. However, this action is not related to the FORTRAN compiler's interpretation of the tab character described above. You can use the tab character to improve the legibility of a FORTRAN statement. For compilation, spaces are ignored, except those within a Hollerith constant or alphanumeric literal. For 1legibility, spaces are printed 1in the source 1listing. Tabs also are ignored for compilation purposes in a statement field. 1In the source listing, the tab causes the character that follows to be printed at the next tab stop (located at columns 9, 17, 25, 33, and so forth) 1.3.3 Statement Label Field A statement label or statement number consists of one to five decimal digits ir the statement label field of a statement's initial line. Spaces and leading 0s are ignored. An all-zero statement 1label is invalid. Any statement referenced by another statement must hava a label. two statements within a program unit can have the same label. No You can use two special indicators in the first column of the label field: the comment indicator and the debugging statement indicator. These indicators are described in Sections 1.3.3.1 and 1.3.3.2 below. The statement label field of a continuation line must be blank. 1.3.3.1 Comment Indicator - The letter C in column the line 1is a comment. The compiler prints that program listing and then ignores the 1 indicates that line in the source line. 1.3.3.2 Debugging Statement Indicator - The 1letter D in column 1 designates a debugging statement. The first line of the debugging statement can have a statement label in the remaining columns of the label field. 1f a debugging statement is continued, every continuation line must have a D in column 1 and a continuation indicator The in compiler column command 6. specifies whether debugging statements are to be compiled. If you specify debug-statement compilation, debugging statements are compiled as a part of the source program; if you do not specify debug-statement compilation, debugging statements are treated as comments. For a description of compilation commands, refer to the appropriate user's guide. 1.3.4 Continuation Field A continuation indicator is any character, except 0 or space, 1in column 6 of a FORTRAN line or any digit, except 0, after the first tab. A statement can be divided into continuation lines at any point. The compiler considers the characters after the continuation character to follow the last character of the previous 1line, as 1if no Dbreak occurred at that point. If a continuation indicator is 0, then the compiler considers the 1line to be the first 1line of a FORTRAN statement. INTRODUCTION TO PDP-11 FORTRAN IV occur can they but continued, Comment lines cannot be 1line(s) continuation its 1line and initial statement's a between or between lines. successive continuation Statement Field 1.3.5 field. statement the in placed The text of a FORTRAN statement is Because the compiler ignores the tab character and spaces (except in text Hollerith constants or alphanumeric literals), you can space the The use of tabs for 1legibility. for maximum any way desired in spacing is discussed in Section 1.3.2 NOTE If a 1line extends beyond character position 72, the text following position is 72 is ignored and no warning message printed. 1.3.6 Sequence Number Field in information can appear identifying other A sequence number or The compiler 73 through 80 of any line in a FORTRAN program. columns cannot Remember that you ignores characters in this field. the sequence number field by tab-character formatting, 1.4 move to PROGRAM UNIT STRUCTURE program Figure 1-3 shows the allowed order of statements in a FORTRAN figure, vertical lines separate statement types that this In unit. statements, FORMAT For example, comment lines, can be interspersed. DATA statements, and executable statements are allowed alternatives in types statement indicate Horizontal lines the body of the program. For example, IMPLICIT statements cannot cannot be interspersed. that be interspersed with executable statements, a PROGRAM statement, or an END statement because each has a definite order in the program. PROGRAM,FUNCTION,SUBROUTINE, or BLOCK DATA Statements IMPLICIT Statements PARAMETER Other Statements Specification Comment FORMAT Lines and StENTRYt atements Statements DATA Statements Statement Function Definitions Executable Statements END Line ZK-1043-82 Figure 1-3: Required Order of Statements and Lines 1-7 CHAPTER FORTRAN The basic e components Constants changed ® ® -- by Variables fixed -- Arrays -- groups be of names that by a values The a a symbolic computation using the the trigonometric 1is wused in name name. is to be performed followed unit that arguments, if any: sine of of the argument. the function function obtain a used single result. and functions have symbolic names. A symbolic characters that identify entities in the program. of variables, data e Logical ® ‘Integer ® Real e Double e Complex following the exception 6. Sections respectively, arrays, expressions, types: and functions can in symbol such as arrays, string a program place to and with Individual optionally a be The contiguously symbolic variables, array elements, combinations of these components with operators. An operator is a that a certain kind of operation, specifying following stored by constants, multiplication, Constants, are or conjunction a that cannot stored values. statements. -- names of functions, arguments. A function is -- They represent individually specified references is numbers. program collectively by just called array elements. of Expressions Variables, as changed for example, computing The resulting value reference. e are: references 1lists performs such or are Function by statements values, referenced subscript values can COMPONENTS statements. symbolic values be STATEMENT FORTRAN program stored can ® of 2 have name the precision sections of 2.1 detail function and provide 2.2 the basic references, on information components which are symbolic names common all to of FORTRAN, described and basic in data with Chapter types, components. FORTRAN STATEMENT COMPONENTS 2.1 SYMBOLIC NAMES Symbolic names identify entities within a FORTRAN program unit. These The "Typed" column indicates entities are 1listed in Table 2-1. whether the entity has a data type, such as so Entities Identified by Symbolic Names Table 2-1: Typed Entity yes Variables Arrays Statement yes functions Processor-defined functions Function subprograms Subroutine subprograms Common blocks Main programs Block data subprograms arguments Dummy yes yes yes no no no no yes A symbolic name is a string of letters and digits totaling of six characters. and integer, real, Data types are discussed in Section 2.2. forth., The first character must be a letter. a maximum Examples of valid and invalid symbolic names are: valid Invalid/Explanation NUMBER K9 5Q B.4 (begins with a numeral) (contains a special character) you That is, Symbolic names must be unique within a program unit. cannot use the same symbolic name to identify two or more entities in the same program unit. some In executable programs consisting of two or more program units, The entities must have unique names throughout all the program units. entities 2.2 are: e Processor-defined functions e Function e Subroutine subprograms e Common e Main e Block subprograms blocks programs data subprograms DATA TYPES Each basic component one of ® several Integer data (constants, variables, and so types: -- a whole number. forth) represents FORTRAN ® Real -- a decimal fraction, ® Double maximum ® or The -- can -- true a basic type Whenever a or is, a whole the two. number with numbers in can its be specified construction can explicitly declared. data 1is (see specifies that to IV, a type is twice as a many complex part, the second one of three Section in (as or converted performed in constants); without to a according an value to a "numeric real, values occupy numeric storage storage integer, two unit" or of is four another rules for the amount of logical numeric unit is it IMPLICIT the 3.1). a store complex real decimal false. (with one than a part. convention of more the naming be number, representing represents component statements and of real value imaginary conversion FORTRAN that real of inherent it needed precision PDP-11 by value FORTRAN memory be or the assignment ANS of can statement); a COMPONENTS digits. first Logical implied type, pair the it be a the represents data -- significant number; ways: number, combination precision Complex ® a STATEMENT value. Double storage units. bytes memory. of In PDP-11 FORTRAN IV provides additional data types for better control of performance and memory requirements. Table 2-2 lists the data types available and the amount of memory required (in bytes). The form *n appended to a data type name is called a data type length specifier. Table 2-2: Data Data Type Type Storage Requirements Storage Requirements (Bytes) BYTE 12 LOGICAL 4 LOGICAL*1 12 LOGICAL*4 4 INTEGER 2 INTEGER*2 43 REAL 4 REAL*4 4 REAL*8 8 DOUBLE PRECISION 8 COMPLEX 8 COMPLEX*8 2. BYTE two bytes. The l-byte or false, to 3. 8 Either two or four bytes compiler command qualifier is Only storage a +127. LOGICAL*1l two area single Four bytes are computation. and 4 2 INTEGER*4 l. 1 or are are allocated specified. bytes can are contain character, allocated used but synonymous. 2-3 or only the on default for computation. logical integers two depending The in bytes the allocation values true the range -128 are used for FORTRAN STATEMENT COMPONENTS 2.3 CONSTANTS A constant represents a fixed value and can be value, or a character string. a logical a number, They Hollerith constants or alphanumeric literals have no data type. Section (see appear they which in context the of type data the assume 2.3.6.2). Integer Constants 2.3.1 It can An integer constant is a whole number with no decimal point. An number. decimal a as ed interpret 1is and sign have a leading integer constant has the following form: snn An optional nn A string Leading 0s, of sign. numeric characters. if any, are ignored. A plus A minus sign must appear before a negative integer constant. is constant unsigned (an constant positive a sign is optional before assumed to be positive). Except for the sign, an integer constant cannot other than the numerals 0 through 9. constant integer The absolute value of an contain cannot be a character greater than 32767. Examples of valid and invalid integer constants are: Invalid/Explanation valid 0 -127 +32123 (too 99999999999 large) (decimal point and 3.14 comma not allowed) 32,767 Integer constants can also be specified in octal form. of an The octal form is: integer constant "nn nn A string of digits in the range 0 to 7. An octal integer constant cannot be negative or greater than "177777. Examples of valid and invalid octal integer constants are: valid Invalid/Explanation "107 "108 (contains a digit outside the "177777 "1377. (decimal point not allowed) "177777" allowed range) (trailing quotation mark not allowed) FORTRAN 2.3.2 A Real real three STATEMENT COMPONENTS Constants constant is a number with forms: ® A basic real constant ® A basic real constant ® An integer A basic real formats: constant constant is a a decimal followed followed string of by by a point. a It decimal decimal decimal can take one of exponent exponent digits in one of three S.nn snn.nn snn. s An optional sign. nn A string of decimal digits. The decimal point can appear anywhere in the string. The number of digits is not limited, but only the leftmost 7 digits are significant . Leading 0s (0s to the left of the first nonzero digit) are ignored in counting the leftmost 7 digits. Thus, in the constant 0.00001234567, all of the nonzero digits are significant, and none of the 0s are significant. A decimal exponent has the form: Esnn An optional An integer sign. nn The exponent integer the A real A minus A plus 1.0 a sign sign Except for a numerals the * constant with used), If represents constant value number constant. ** g),. occupies must is E four of bytes by which (for and seven the signs, is the letter E and positive exponent. a decimal point, contain 1.0E6 interpreted decimal a cannot preceding example, between a and a appears 1in a follow. The exponent real of a nonzero real 0.29E-38 or greater cannot be as nedative the character constant, real or represents a real digits. 9. 0. The magnitude approximately 10 typically for constant through must power be multiplied of appear optional algebraic letter exponent to precision real 0 10 a is an constant cannot than approximately 1letter E (if other than the integer omitted, exponent. but constant it be smaller 1.7E38. can be than FORTRAN STATEMENT COMPONENTS Examples of valid and invalid real constants are: valid Invalid/Explanation 3.14159 621712, -.00127 +5.0E3 1,234,567 325E-45 -47.E47 100 $25.00 2E-3 (commas not allowed) (too small) (too large) (decimal point missing) (special character not allowed) Double Precision Constants 2.3.3 integer A double precision constant is a basic real constant or an constant followed by a decimal exponent of the following form: Dsnn An optional An integer sign. nn constant. A double precision constant occupies eight bytes and is interpreted as The a real number with a precision of typically 16 decimal digits. only but limited, not is exponent the number of digits that precede the leftmost 16 digits are significant. A minus sign must appear before a negativée double precision constant; Similarly, a is optional before a positive constant. sign a plus negative exponent a for D minus sign must appear after the letter while a plus sign is optional for a positive exponent. The exponent following the letter D cannot be omitted, but it can be 0. The magnitude of a nonzero double precision constant cannot be smaller than approximately 0.29D-38 or greater than approximately 1.7D38. Examples of valid and invalid double precision constants are: valid Invalid/Explanation 1234567890D+5 +2.71828182846182D00 -72.5D-15 1234567890D45 1234567890.0D-89 +2.7182812846182 1DO0 2.3.4 (too large) (too small) (no Dsnn present; this is a valid real constant) Complex Constants comma by a A complex constant is a pair of real constants separated The first real constant represents the in parentheses. and enclosed constant real second the and number complex the of part real represents the imaginary part. FORTRAN A complex constant has the STATEMENT following COMPONENTS form: (rc,rc) rc A The real parentheses required. A constant. See complex complex and comma Section constant are 2.3.2 part for occupies of eight of complex rules for bytes number. Examples the the constant forming and 1is real and are constants. interpreted as a ' valid and invalid valid complex constants are: Invalid/Explanation (1.70391,-1.70391) (1,2) (+12739E3,0.) (integers (1.23,) (second are real not allowed) constant is missing) (1.0,1.0D0 (double are 2.3.5 A Logical logical two constants allowed) Constants constant logical precision not specifies constants are true or false. Thus, only the possible: following . TRUE. .FALSE. The delimiting 2.3.6 A are a required part of each constant. Hollerith Constants Hollerith character A periods constant count Hollerith and is a string of letter H. the constant has the printable following characters preceded by a form: nHclc2c3...cn An unsigned, characters A The printable maximum Examples of nonzero in the integer constant stating the string (including spaces and tabs). character. number of valid and characters invalid valid 16HTODAY'S 1HB number is 255. Hollerith constants are: Invalid/Explanation DATE 1IS: 3HABCD (wrong number of characters) of FORTRAN STATEMENT COMPONENTS 2.3.6.1 a Alphanumeric Literals - An alphanumeric literal is string printable ASCII characters enclosed by apostrophes that represents of The form is: an alternate form of a Hollerith constant. '‘clc2c3...cn! character. A printable Both delimiting apostrophes must be present. alphanumeric an Within by represented between character 1literal, consecutive two character apostrophe the apostrophes is (with no space or other them). characters of number the The length of the alphanumeric literal is including spaces and tabs, except that two between the apostrophes, is A tab consecutive apostrophes represent a single apostrophe. stored as a single character but is displayed as spaces up to the next The length must be tab stop. Examples of valid and invalid in the range from 1 to 255. literals are: valid Invalid/Explanation 'WHAT?' 'HEADINGS (must contain trailing 'TODAY''S DATE 1IS: v (must contain at least "NOW OR NEVER" (quotation HE SAID, 2.3.6.2 constants according e "HELLO"' Data Type are to the used Rules 1in for apostrophe) one character) Hollerith Constants - When Hollerith numeric expressions, following rules: marks in wused be cannot place of apostrophes) they assume a data type including When the constant is used with a binary operator, assignment operator, the data type of the constant is the the data type of the other operand. Statement For example: Data Type of Constant Length of Constant REAL*4 INTEGER*2 REAL*8 4 2 8 INTEGER*2 ICOUNT DOUBLE REAL*8 RALPHA = 4HABCD JCOUNT = ICOUNT + 'XY' DOUBLE = 8HABCDEFGH e When a specific data type is required, for the constant. For example: Data type that 1is type Length of Statement of Constant Constant X=Y (1HA) INTEGER*2 2 assumed FORTRAN STATEMENT COMPONENTS ® When is the constant assumed. For is used as ® APAC When the type is of constant is in any example: When IF (2HAB) 1HC-1HA J= ,NOT, length of the constant 2-2 lists Table the character 2.4 VARIABLES variable is Section 2,1 variable is change Type INTEGER*2 data Length of Constant Constant 2 2 2 assigned type of Two or to the and a variables the and partial EQUIVALENCE subprogram memory a in new type, requirements can for a are storage to the establish statements, data the data considered of or If variables associated) the execution input of if as the is defined (for variable becomes data same variable you variable. it The type by undefined; data represents, of a its type the is data variable statements, are and dummy or by variable or during associated assignment), is, Association statements, arguments associated A location, that refers. COMMON storage nam €. statem ent types use arguments the the storage example, you each other when they refer partially associated when part refers is the same as part or actual by a DATA statement. different with type the however, with when defined same (see of are one variable which the Other and references., They occur value constants. are type of type. location The location; value data When data of any converted, if necessary, to associated location. each name). that as the is with symbolic stored data it You required storage. a indicates association program assignment value, by right. associated assigning to which location to A variable is contains data other of of currently variable, location variable name by the characters byte form storage variable. same of before its on type declaration statements or IMPLICIT names that begin with certa in letters. more the the variable of one classified to wusing is truncated symbolic value the choosing a is less than the length impl ied by the to the constant on the right . When the greater than the length impli ed by the data number value a Precision, the the type of context, INTEGER*?2 occupies that are of is for Variables all Constant INTEGER*2 INTEGER*2 'B' constant Each by 1,2,3 type length of the constant type, spaces are appended type, can of data 9 Data of the data A Length Type other Statement I= no none used For argument, Constant (9HABCDEFGHTI) assumed. actual Data Statement CALL an example: and you can with be (or it definedqd execution the in by an partially value of one value of cannot predict the the its FORTRAN STATEMENT COMPONENTS Data Type Specification 2.4.1 that given ion 5.2) specify le: statements (see dSect Type declaration repr examp For . esent specifie data types variables are to COMPLEX VARl DOUBLE PRECISION VAR2 Dbe associated variable VARl is tocompl indicate that the which These statements stora ex data, and ain cont will ge location with an 8-byte e double 8-byt an with ed ciat asso be is to that the variable VAR2 ion. precision storage locat a more general scope: n, ita (see Section 5.1) has The IMPLICIT statement the icit type declaratio in expl an of nce signifies that, in g withabse or any letter with r, lette fied speci a nnin variable name begi type. a specified range, is to represent a specified data only once. the data type of a variable You can explicitly declare prece statement. CIT IMPLI an over dence takes n explicit declaratio 2.4.2 An Data Type by Implication or explicit type r IMPLICIT statements begi In the absence of eithe nning with I, J, names with s variable declaration statements,ed all bles with integer variables. edVaria K, L, M, or N are assum anyto be be real to assum are r lette other names beginning withle: For examp variables. Integer Variables Real Variables ALPHA 2.5 : JCOUNT BETA ITEM TOTAL NTOTAL ARRAYS associated with a guous storage locations indiv An array is a group of conti idual storage The name. the array single symbolic name, eleme a subscript by to red refer are nts, locations, called arrayname. Section 2.5.2 discusses subscripts . appended to the array n . For example, a colum one to seven dimensions An array can have from imens must you , value a to refer To . array ional of figures is a one-d A table of more than one column of figures is r. specify the row numbearray must specify both . To refer to a value you a two-dimensional covers several that es figur of r. A table row number and column numbe a value in this to refer To . array al nsion pages 1is a three-dime page number, and r, numbe n array, you must specify row number, colum The following FORTRAN statements establish arrays: e Type declaration statements (see Section 5.2) e The DIMENSION statement (see Section 5.3) The COMMON statement (see Section 5.4) e The VIRTUAL statement (see Section 5.5) e FORTRAN These define array, and the element with of may contain array declarators (see Section the" name of the array, the number of dimensions number an An program execution defined 2.5.1 Array array array by DATA can a declarator a specifies program declarator (df,d] The defined has the unit symbolic number the For 2.1 of the The The in is a name of the the form The of dimension. number of elements. An IUNIT value number array unit. subprogram a subprogram main 2.5.2 array during or element input program Section before can be statement, execution by an name that the identifies properties of an that array, a is an that 1is, symbolic integer upper bound can array constant of indicates dimensions the name.,) the the integer array. number range or from of one name, dimensions to seven. (10,10,10) dimension 10 of In elements elements can to by the in in array specifying arguments. to the See declarators program. that one are adjustable subprogram is equal not to process Section are not use arrays with as well 6.1.2 for constant of the 1000 be are a the in a arrays dimension array more not program used adjustable different as IUNIT contains within can can elements of product above declarator You of dimension the constant declarators number each IUNIT array arrays. the above, dimension. only that specifies example each appear define an in declarators array. declarator elements. single declarators Dimension a name Dimension within of three-dimensional of associated form: of declarators number that consists storage in DIMENSION IUNIT An indicates following gives dimension array. example, the assignment symbolic ang A dimension declarator that variable that specifies the in if the ...) (Section The defined an in Declarators within array be by 2.5.1) demension, statement. execution array. An each the same type as the arra y name (see or an entire array can be defined a array statement. in is considered program entire elements data of element array during an input An contains of array it 2.5.4). and COMPONENTS statements that An STATEMENT name as information. permitted in a Subscripts A subscript qualifies expressions, called an array subscript name., A subscript is expressions, that are 2-11 a 1list of enclosed in FORTRAN STATEMENT COMPONENTS array is ent in theit qual e which elem that determin parentheses and ifies. name y arra the referenced. The subscript is appended to A subscript has the following form: (sl,s)...) A subscript expression. ic , oOr arithmet tant, variable ession can be a asubscons A subscript expr is it ger, inte type of t is not al part. the value of cation crip expression., If tion frac any of converted to integer by trun cript expressionn contain one subsfor y reference must A subscripted arra each dimensio (one for each dimension defined for that array declarator). 2.5.3 Array Storage ns k of the dimensioRAN ion, you can thines. ier in this sect As discussed earl FORT ver, Howe ls or plan , columns, and leve of an array as LoOws es. A ar sequence of inwvalu line a as ry memo in y arra an es stor always first the ent with its first elem y 1is stored ent one-dimensional arra of tion loca age stor last the in elem and its last onal storage location ost lefm the that so array is stored multidimensi the sequence. Amost t "order of subscrip is called they stor This dly. rapi vary subscripts two, one, in age ple, Figure 2-1 shows arra progression." For exam . and three dimensions Data Type of an Array 2.5.4 the data the same way as er y is specified in by The data type of an ,arra of the lett ial the init ly that is, implicit type of a variable t. emen stat name or explicitly by a type declaration e data type. Any ofvalu array have theconvsame All the values anin an the type data d to the array element a is DOUBLEertePREC assigned to for ISION statement, each in d name is y arra an array. If for tion loca te storage example, the compiler allocates e anof 8-by any type is assigned to any a valu element of the array.y, When ision. element of that arra it is converted to double prec Array References Without Subscripts 2.5.5 ify an array name statements, you can spec In the following types of array is to be used re enti the to indicate that without a subscript (or defined): e Type declaration statements e COMMON statement e DATA statement e EQUIVALENCE statement FORTRAN ® FUNCTION ® SUBROUTINE ® Input/output STATEMENT COMPONENTS statement statement statements You can also use unsu bscripted array names as actual references to external procedures, Unsubscripted array permitted in any othe r type of statement. arguments names are in not One-Dimensional Array BRC (6) [ 1 [BRO(M)[ 2 [BRC(2)] 3 |BRC(3)| 4 |BRC4)| 5 |BRC(5 )| 6 [BRc(e)] Memory Positions Two-Dimensional Array BAN (3,4) 1 [ BAN(1,1)] 4 | BAN(1,2)| 7 BAN(1,3) { 10 | BAN(1,4) 2 | BAN(2,1)| 5 | BAN(2,2)| 8 BAN(2,3) | 11 | BAN(2,4) 3 | BAN(3,1)| 6 | BAN(3,2){ 9 BAN(3,3) | 12 | BAN(3,4) L Memory Positions Three-Dimensional Array BOS (3,3,3) 191 BOS(1,1,3) | 22 | BOS(1,2,3) | 25 20 | BOS(2,1,3) | 23 | BOS(2,2,3) | 101 BOS(1,1,2) — 11]BOS(2,1,2) 1 [BOS(1.1.1)| 2 [BOS(2,1,1) | 5 3 | BOS(3,1,1) 4 B0OS(1,3,3) 26 B0OS(2,3,3) |13 | BOS(1,2,2) [ 16 | BOS(1,3,2) § | 27 | BOS(3,3.3) |14 [ BOS(2,2,2) | 17| BOS(2,3.2) 1 BOS(1,2,1) | 7 | BOS(1,3,1) | | 18| BOS(3,3.2) [ BOS(2,2,1) | 8 | BOS(2,3,1) 6 | BOS(3,2,1) | 9 | BOS(3,3,1) Memory Positions ZK-616-82 Figure 2.5.6 Adjustable array Chapter 2.6 An Array Storage Adjustable Arrays dimensions. the 2-1: 6 arrays To allow use bounds for an subprograms adjustable and the array more information. name to manipulate array as in a arrays subprogram, of variable you specify subprogram arguments. It a See EXPRESSIONS expression component, represents such as a a single constant or value. variable, can or be a single combination of basic basic FORTRAN STATEMENT COMPONENTS computations s. Operators specc ify one or more operator components with d, onent(s) to comp basi the using the value(s) of to be performe obtain a single value. cal. ic, relational, al orand logi sified as arithmetvalu Expressions are clasons cal logi tion rela es; produce numeric Arithmetic expressi es. valu expressions produce logical Arithmetic Expressions 2.6.1 and arithmetic elements ons are formed with Arithmetic expressis. a ds yiel on essi expr an The evaluation of such arithmetic operator . value single numeric g: An arithmetic element can be any of the followin e A numeric constant e A numeric variable e A numeric array element e An arithmetic expression enclosed in parentheses e An arithmetic function reference include be interpreted to when used above, can also The term "numeric," e aslogi used data ger inte cal data is treated as logical data, sinc in an arithmetic context. g the be performed usinresu ify a computation a tonume Arithmetic operatorsic spec lt. a as e valu ric produce values of arithmet elements to are: The operators and their meanings Operator Function *% Exponentiation * Multiplication / Division + Addition and unary plus - Subtraction and unary minus with s because each is used called binary operator These operators are y unar also are ls The plus (+) and minus (-) symbo two elements. immediately preceding an arithmetic element to operators when writtennega tive value. denote a positive or hmetic operator with any valid arithmetic element, You can use any aritTabl e 2-3. except as noted in nt must have a defined value before it can be A variable or array eleme expression. used in an arithmetic FORTRAN Table 2-3 shows exponent, and the the Table allowed data of Result the Data Type Real Real Real Double No Double Double Double Double No Complex Complex No No No A by negative an value valid element integer cannot be except in Arithmetic expressions result The the in precedence are the are result case of case is by has in performed first. an in element another the same base and double ranked and / Second + and - Third or more they algebraically example, type double as the precision precision, order determined and precedence operators are of evaluated equivalent to a equal by precedence the by the operations of is: left-to-right power. 2.6.1.1 Use of Parentheses - You particular order of evaluation. in parentheses, value 1is used that in (such compiler order in 3+4-1, the addition is performed Exponentiation, however, is evalua ted right to A**B**C, B**C is evaluated first and then A is resulting a First * enclosed data a precedence The with 0-value Precedence * % two and exponentiated an real are Operator appear, a evaluated be and exponentiated this operators can element; exponentiation, The operators. base Complex No exponent. When Double No element. higher Real No element, of Exponentiation Integer Note: any for types exponentiation. Integer only In data of Exponent Integer base of result Base 0 COMPONENTS combinations type 2-3: STATEMENT and of evaluation. order -) that is For before the subtraction. left. For raised example, to use parentheses When part of an part + any can the as in is evaluated evaluation of the the in resulting to force expression first and remainder of a is the the FORTRAN STATEMENT COMPONENTS examples, following the In expression. operators indicate the order of evaluation: the numbers below the 4 +3%2-6/2=7T Y S 31 (443) * 1 2 2 2 -6 / 2 =11 Ao (4 S 4 A 3 4 +3*2-6) S 2 1 3 ((4+43) * 2 - 6) 1 2 3 Lo /2=2 A 4 / 2 = 4 A 4 expressions within As shown in the third and fourth examples, order of precedence, normal the to ing accord ed evaluat parentheses are parentheses. within eses unless you override the order by using parenth nt Using parentheses to specify the evaluation order is often importa are that orders ion evaluat since tions computa high-accuracy in algebraically equivalent might not be computationally equivalent due to rounding and normalization. order 1is important, Using parentheses to specify the evaluation doubt exists as to the any furthermore, in difficult expressions. If parentheses Extra eses. parenth use ion, express resulting value of an do not affect the result, but lack of sufficient parentheses does. - If every element in 2.6.1.2 Data type of an Arithmetic Expression type, the value produced data same the of is an arithmetic expression s of different by the expression is also of that data type. 1f element type of the result data types are combined in an expression, the data of each operation is determined by a rank associated with each data type, on the following basis: Rank Data Type Logical 1 Integer 2 Real 3 Double precision 4 Complex 5 (Low) (High) on two arithmetic The data type of the value produced by an operation data type of the types is the data different of elements the value , example For on. operati the in highest-ranked element element is real. resulting £from an operation on an integer and a real The data type of an expression is the data type of the result of the last operation in that expression. FORTRAN Operations are classified by Integer operations integer elements. context are STATEMENT COMPONENTS data as -- treated Integer operations are entities wused as that can rounded. For example: The + value Real 1/3 of + integers.) result is 0, not 1. operations are performed real, integer, expression -- Real combinations elements. Any integer by giving is an is then or elements each a present using part real only on and converted are fractional evaluated however, precision double by operations precision making precision it the element. expression is then -- operation most The real element not its accuracy. Any is equal to to real or integer to real 0. arithmetic. converted real The Note, integer a real element double in precision significant portion of a double significant portion is 0. The double precision arithmetic. least evaluated Converting a increase not 1logical that in the statement Y = (I/J)*X, an operation is performed on I and J and multiplication is performed on that result and X. Double on any truncated, division a only arithmetic arithmetic, division or type expression integer in from elements data In performed 1/3 this operations follows: (Logical fraction 1/3 type in to a double precision element example, the real number: For does 0.3333333 is converted to: 0.3333333000000000D0 not to: 0.3333333333333333D90 Complex operations -containing a complex to real data elements are type, as In imaginary 2.6.2 A relational separated true if the by converted stated to real on an elements described. data type expression are Double by converted precision rounding the least and the resulting value is complex. Expressions expression a integer portion. The real element thus obtained is as the real part of a complex number; the part is 0. The expression is then evaluated using arithmetic Relational operation previously significant designated complex an element, consists relational of operator. relationship exists two The and arithmetic value false of if the it expressions expression does not. is FORTRAN STATEMENT COMPONENTS A relational operator tests for a relationship between two expressions. These operators arithmetic are: Relationship Operator .LT. Less than .LE. Less than or equal .EQ. Equal .NE. Not .GT. Greater than .GE. Greater than or equal The delimiting periods are a to to equal to required part to of each operator. L.NE,. and L[EQ. the by only related be can Complex expressions Complex entities are equal if their corresponding real and operators. are imaginary parts both equal. In an arithmetic relational expression, the arithmetic expressions are are then These values values. their to obtain evaluated first operator the by stated relationship the whether determine to compared exists. For example: APPLE+PEACH PEAR+ORANGE .GT. real the sum of "The relationship, the states expression This real the of sum the than greater 1is PEACH and APPLE variables of variables PEAR and ORANGE." If that relationship exists, the value false. is expression the of value the not, 1if true; is expression the All operators relational have the same precedence. you can Arithmetic operators have a higher precedence than relational operators. As in any other arithmetic expression, the alter relational order of expression. evaluation However, of use parentheses to operators are the arithmetic expressions in a since arithmetic evaluated before relational operators, you need not enclose the entire arithmetic expression in parentheses. You can compare two numeric expressions of different in a relational the expression with the the value of this case, In expression. type data the higher-ranked lower-ranked data type is converted to before the comparison 2.6.3 Logical is made. Expressions Logical expressions are formed with logical elements and 1logical A logical expression yields a single logical value, either operators. true or false. A logical element can be any of the following: e An integer or logical constant e An integer or logical variable e An integer or logical array element FORTRAN The ®¢ A relational ® A logical ® An logical or logical operators Operator COMPONENTS expression expression integer STATEMENT enclosed in function parentheses reference are: Example .AND. A Meaning _AND. B Logical true conjunction: if, and only The if, true, .OR. A ,OR. B Logical disjunction expression both, .XOR, A ,XOR. B is exclusive if A A .EQV. B Logical true The A .NOT. delimiting logical assigned which all periods expression to A of is its the evaluated: either The true and and only logical The if, are OR): A or The B, expression B is false, negation: true and only logical operators are evaluated according to A A and whether The if, expression both value, Logical if, is B or is or the expression is false have the same value. equivalence: if, the same false. .NOT. if OR: is and (inclusive true vice versa; but if both elements .EQV. A true. Logical true is expression both B is have true or expression is is false. required. an order of precedence operators. The following list gives the order in operators that can appear in a logical expression are Operator Precedence * % First */ Second +, - (Highest) Third Relational Operators Fourth .NOT. Fifth .AND. Sixth .OR. Seventh . XOR., .EQV, Operators of Eighth equal rank example: A*B+C*ABC The sequence in .EQ. which are X*Y+DM/ZZ evaluated .AND. evaluation from .NOT. occurs left K*B .GT., to right. TT is: (((A*B)+(C*ABC)).EQ.((X*Y)+(DM/ZZ))).AND.( .NOT.((K*B).GT.TT)) For FORTRAN STATEMENT COMPONENTS As in arithmetic expressions, you can use normal sequence of evaluation. parentheses to alter the Two consecutive logical operators are not allowed unless the second is .NOT. . essions Some logical expressions are evaluated before all their subexpr A .AND. on expressi the .FALSE., is A if For example, are evaluated. ion (F(X,Y) .GT. 2.0) .AND. B is .FALSE.. The value of the express the Thus, F(X,Y). ng evaluati without A can be determined by testing function subprogram F may not be called, and side-effects resulting from the call, such as changing variables in COMMON, cannot occur. g When a logical operator operates on logical elements, the onresultin integer operates operator logical a When logical. 1is type data the elements, the logical operation 1is <carried out bit-by-bit onof the corresponding bits of the internal (binary) representation logical integer elements. The resulting data type is integer. When a value is logical the values, logical and integer combines operator carried is n operatio the then and first converted to an integer value, out as for two integer elements. The resulting data type is integer. Example: INTEGER I = "65 J K = = I, J, K I.0R."100 I.AND."23 In this example, I has the value "165 and K has the value "21. CHAPTER ASSIGNMENT Assignment statements element. The three 3.1 An kinds assign a 3 STATEMENTS single value of assignment statements ® Arithmetic assignment statement ® Logical ® ASSIGN assignment arithmetic or ASSIGNMENT A numeric or array are: STATEMENT statement element. assigns The arithmetic assignment statement has = variable statement assignment array v a statement ARITHMETIC variable to an arithmetic value to a the following form: e \ variable or array element. e An The arithmetic equal rather, it KOUNT This sign does means = expression. KOUNT statement not "is mean replaced + means, KOUNT integer with constant 1." "teplace the the of sum Although the symbolic name on undefined, values must have The the If is the expression real of in entity v and e e on have converted to the yield that the directly summarizes expression must expression the the data a the been on of same v, If data the value produces left to equal For to," as in mathematics; example: 1 variable references "is by." the data the type conversion a current the value of the of KOUNT 1left of the equal sign previously assigned to all right of the value equal Proper the is are of before it for equal size. than an is For 32767 is the assigned. assignment the can be symbolic example, a invalid if variable. assigns different, integer and sign. INTEGER*2 statement types rules the greater sign types, of data v value current the value Table statements. value of e 3-1 ASSIGNMENT STATEMENTS Table Conversion Rules for Assignment Statements 3-1: Expression (E) Variable or Array Assign Integer to E V or Logical Append fraction (.0) to E and Real Double to Append fraction to E and sign to Msl por- tion of V; LSl portion of V is 0 Truncate real part of E to integer and assign to Vj; imaginary part of E is not used Truncate E to integer and assign to V Assign E to V Assign Msl por- Assign real part Lsl portion of inary part of is not used tion E as- Complex Truncate E to integer and assign to V V assign (.0) Precision Double Precision Real Integer or Logical (V) Element Assign E to MsI E to of V; rounded tion of V; LS part of E is portion of V is zero, imaginary 0 is E of E to Msl pir- sl portion of vV imag- E to V; Assign real part Assign E to V v: of portion is of not used Append Complex fraction (.) to E and assign to real part of V; imaginary part of vV is 0.0 Assign Assign Msl por- to E tion of real part of V; imaginary part of nary part MS = most significant (high order); E to V portion of E is rounded; imagiis 1. Assign real part of V; LSl 0.0 is Vv E to LS = least of V 0.0 significant (low order) Examples of valid and invalid assignment statements are: valid (4.* BETA = -1./(2.*X)+A*A/(X*X)) PI SUM 3,14159 = = SUM+l. Invalid/Explanation 3.14 = A-B (entity on the left must be a variable -J = 1I**4 (entity on the left must be a variable is an invalid or or array element) array element) ALPHA = ((X+6)*B*B/(X-Y) (entity on expression not the right because the parentheses are balanced) ASSIGNMENT 3.2 LOGICAL ASSIGNMENT The logical false) to a variable The assignment logical Note statement or array A logical variable A logical expression. all a logical value (true or has the following form: e that v must be of Otherwise, the assigns element. statement = Values, to STATEMENT Vv value, but assignment STATEMENTS will either numeric Examples of array logical element. data conversions values variables or not or logical have type will any logical or logical, must array elements in assignment and be e must made yield according a to logical Table 3-1, meaning. have been previously assigned e. statements are: valid LOGICAL PAGEND PAGEND, = = ABIG ,FALSE. PRNTOK ABIG PRNTOK, A LINE .LE. .,GT. B 132 .AND. ,AND. .NOT. A C .GT. PAGEND .AND. A .GT. D Invalid/Explanation X=,TRUE. (entity on the left must be logical) ASSIGN 3.3 The ASSIGN ASSIGN variable. destination STATEMENT statement The in a assigns a statement variable can then subsequent assigned label be GO an integer wused to specify a TO statement (see value to transfer Section 4.1.3). The ASSIGN ASSIGN statement s TO has the label the ASSIGN statement. An integer variable. ASSIGN is similar of an statement to form: v The The following an executable assigns the arithmetic statement in statement assignment the label same to program the statement, unit variable. except that as It the ASSIGNMENT STATEMENTS variable becomes defined for use as a statement 1label reference and becomes undefined as an integer variable; that is, the value cannot be used for purposes of output or arithmetic. The statement program label must unit. It may not refer to an executable statement refer to a FORMAT in the same statement. The ASSIGN statement must be executed before the assigned GO TO statement(s) in which the assigned variable is to be used. The ASSIGN statement and the assigned GO TO statement(s) must occur in the same program For unit. example: ASSIGN This 100 statement 100. then NUMBER = undefined NUMBER associates Arithmetic statement, is TO the variable operations become on invalid. NUMBER with the variable, as the For statement in the label following example: NUMBER+1 and does not result in a value of 101 being stored in NUMBER. Assigning the assignment statement: variable a value with the following arithmetic NUMBER=10 dissociates the longer be used value variable from statement 100. in an assigned GO TO statement, The variable can no but has the arithmetic 10. Examples: valid ASSIGN 10 TO ASSIGN 99999 NSTART TO KSTOP Invalid/Explanation ASSIGN 250 TO ERROR (variable must be integer) CHAPTER CONTROL Statements are written. However, control to You use can another the same also govern program The normally section control program iterative termination. control ® GO e IF TO DO ¢ of ® statement -- conditionally executes -- The following examples sections the they to are transfer a point within Control program statements execution, and -- iterative transfers -- --- returns the in from suspends program end they a of a control of or a specified the next executable subprogram a subprogram program to the execution execution program statements, are unit times to control these which of to terminates describe ways program processing control temporarily marks a transfers control statement of flow statement transfers statement to within -- -- and control statement unit END of number program ® which subprogram. unit. specified statement a control a statement STOP a specifies RETURN ® to statements calling PAUSE transfer or in program are: statement ® to transfers CONTINUE CALL program to statement ® the -- of order normal statement statement group the another program processing, suspension statements conditionally ®¢ or in interrupt statements unit STATEMENTS executed you may 4 unit giving their forms used. GO TO 4.1 GO GO TO TO STATEMENTS statements types of GO TO transfer statements control ® Unconditional e Computed GO TO statement ® Assigned GO TO statement GO within are: TO statement a program unit. The three CONTROL STATEMENTS Unconditional GO TO Statement 4.1.1 The unconditional GO TO statement statement every time it is executed. transfers to control same the The unconditional GO TO statement has the form: GO TO s A statement label. 1in The statement identified by s must be an executable statement same program unit as the GO TO statement. the Examples: GO TO GO TO 99999 Computed GO TO Statement 4.1.2 The 7734 computed GO statement TO transfers control specified by the value of an arithmetic expression. GO TO slist (slist)([,] to a statement e one or more labels of An arithmetic expression whose value is in the range 1 to n, A list, called the transfer 1list, of executable statements separated by commas. where n is the number of statement labels in the transfer list. The computed GO TO statement evaluates e and, if the result to integer data type. Control necessary, converts 1is transferred to the statement label in position e in the transfer list. If the value of e is less than 1 or greater than the number of labels in the transfer list, control is transferred to the first executable statement after the computed GO TO. Examples: GO TO (12,24,36),INDEX GO TO (320,330,340,350,360), SITU(J,K)+1 In the first example, if INDEX has a value of 2, execution will be transferred to statement 24, In the second example, if SITU(J,K) has a value of 2, execution will be transferred to statement 340. 4.1.3 Assigned GO TO Statement The assigned GO TO statement transfers control to a statement label placed in a variable by an ASSIGN statement. Thus, the transfer destination can be changed, depending on the most recently executed ASSIGN statement. CONTROL The assigned GO GO TO An integer TO v([[,] statement STATEMENTS has the following labels of executable form: (slist)] variable. slist A list by of one or more commas. statements The assigned GO TO statement transfers control to the label was most recently assigned to the variable v. on the The GO ASSIGN TO to statements value of Examples of assigned ASSIGN GO TO See associated control 200 TO GO TO 1is ASSIGN statement(s), transferred unit. slist. If statements whose Section 3.3 slist must is be used, and the executable the assigned are: IGO IGO (This example ASSIGN GO the which in the same program must be a member of v statement statement, statement, statements separated TO 450 TO IBEG, (This is equivalent to GO TO 200.) GO TO 450.) IBEG (300,450,1000,25) example is equivalent to IF 4.2 An 1IF IF STATEMENTS statement specified For IF e Logical IF statement each type, the decision is based The or two executes a types IF of statement Arithmetic arithmetic IF based to transfer evaluation arithmetic IF IF (e) An arithmetic sl, the value statement s2, of control an or to expression execute contained has transfers of an the control arithmetic following to one of expression. form: s3 expression. sl,s2,s3 Labels of a the in the Statement statement on if are: statement on the IF only statements statement. statements, The control met. Arithmetic 4.2.1 The is e statement IF transfers condition executable statements in the same program unit. three CONTROL (sl,s2,s3) All three labels refer to three different are STATEMENTS The arithmetic IF statement first If evaluates Then, parentheses. e is: Less than Equal to Greater however, required; Control 0 O than need not 0 the (e) 1in passes Label sl Label s2 Label s3 expression to: examples Some IF (THETA-CHI) 50,50,100 This statement transfers control to statement 50 if the real THETA 1is less than or equal to the real variable CHI. to statement 100 only if THETA is greater than CHI. IF (NUMBER/2*2-NUMBER) the 4.2.2 value is Logical to statement 40 if the value of the it transfers control to statement 20 odd. IF Statement The logical IF statement conditionally executes a single statement based on the evaluation of a logical expression. The logical IF IF (e) variable Control passes 20,40,20 This statement transfers control integer variable NUMBER is even; if they statements. statement has the following FORTRAN form: st e A logical expression. st A complete executable another FORTRAN statement logical IF statement. except a DO The statement can be any statement, an END statement, or statement. The logical IF statement first evaluates the logical expression (e). I1If the wvalue of the expression 1is true, the statement (st) is executed., If the value of the expression is false, control transfers to the next executable statement after the 1logical IF and the statement (st) is not executed. Note that e must yield a 1logical value. Examples of logical IF (J .GT. IF (REF(J,K) LOGICAL IF 4 IF statements .,OR. .NE. J HOLD) ENDRUN (ENDRUN) CALL .,LT. EXIT are: 1) GO REF(J,K) TO = 250 REF(J,K)*(-1.5DO0) CONTROL STATEMENTS DO 4.3 The DO DO STATEMENT statement statements. statement, and "DO loop." The DO specifies The the statement DO s[,] iterative sequence DO has of statement the processing statements is together following of a the range range 1is called with its sequence of of the DO called a form: v=el,e2[,e3] S The label physically of an executable statement. follow in the same program unit. An variable. The statement must \' integer el,e2,e3 Integer The variable initial, omit the s expressions, v identifies statement The the must called ® An arithmetic ®¢ An END e A RETURN ® A DO statement range of the DO to and GO TO up e2, and e3 first for loop then the executed Conversely, be if increment the the initial, of the DO loop. The terminal e3 is (e3) negative, parameter (e3) is equal exact e2 must cannot be to be 0. follow the DO and e3 to the less e2, increment parameter positive, or el, and statements The that statement. expressions initial repeatedly. than statements terminal, executable parameter greater the terminal 4.3.1, increment must all the evaluates the The If is including value Section of the If you used. statement statement The in statement are statement wvariable. The el, statement values respectively. IF control (e2) variable; statement statement determine are control be: A DO the terminal not ¢ statement, The is terminal, and increment parameters, respectively. increment parameter, a default increment value of 1 is is in assigned the mechanism the range to of the the DO is explained terminal parameter initial than parameters, or parameter equal to (el). el. CONTROL STATEMENTS The number of executions of the DO range, called the iteration is count, given by: - e2 el e3 the greatest is, that 1in X, where [X] means the greatest integer integer less than the absolute value of X and with the same sign. 1f the iteration count is 0 or negative, the DO loop is executed once. DO Iteration Control 4.3.1 After each execution of the DO range, the following actions are taken: algebraically added 1. The value of the increment parameter is 2. The iteration count is decremented by 1. 3, transfers control 1If the iteration count is greater than 0, to the first executable statement after the DO statement for to the control another variable. iteration of the range. If the iteration count is 0, execution of 4. the DO statement terminates. You can also terminate execution of a DO statement by wusing a statement within the range that transfers control outside the loop. The control variable of the DO statement remains defined with its current value. When execution of a DO loop terminates, if other DO 1loops share its transfers outward to the next outer DO control statement, terminal If no other DO loop in the DO nesting structure (see Section 4.3.2). loop shares the terminal statement, or if this DO loop is outermost, control transfers to the first executable statement after the terminal statement, You cannot alter the value of the control variable within the range of However, you can reference the control variable for the DO 1loop. other purposes in statements within the range. long as The range of a DO statement can contain other DO statements, as these nested DO loops meet certain requirements. See Section 4.3.2. You cannot transfer control into the range of a DO 1loop. Exceptions during the to this rule are described in Sections 4.3.3 and 4.3.4. Examples of DO statements follow. valid DO This 100 K=1,50,2 statement iteration. specifies 25 iterations; K=49 final CONTROL This statement iteration. DO 25 specifies 27 STATEMENTS iterations; J=-2 during the final IVAR=5 during the final IVAR=1l,5 This statement iteration. specifies 5 iterations; Invalid/Explanation DO NUMBER=5,40,4 DO 40 (the M=2.,10 (a statement decimal label point is has missing) been typed for a of an comma) Note is that in the DO40M = 2.10 an last invalid unintentionally 4,3.2 Nested DO DO loop can inner-nested DO A outer loop. the arithmetic include one or loop must nested assignment loops r more lie can share a Loops DO 45 K=1,10 F . 35 CONTINUE DO 45 15 M=1,20 a outer loop an is nested not Transfers DO loop; the The range range of statement. the next Figure 4-1 DO Nested Loops DO 15 K=1,10 CONTINUE DO 30 M=1,15 CONTINUE Figure to loops. DO 25 L=1,20 | Within statement. Incorrectly DO 35 L=2,50,2 Control DO within terminal Nested DO B |_ L. 45 complete completely loops. Correctly 4.,3.3 statement Loops Nested illustrates valid example, loop, in you however, permitted. 4-1: DO CONTINUE 30 CONTINUE DO Loops Loops can a Nested 25 transfer transfer control from an from outer an loop inner to an loop inner CONTROL STATEMENTS If two or more nested DO loops share the same terminal statement, you can transfer control to that statement only from within the range of the innermost loop. Since the shared terminal statement 1is part of the innermost 1loop, any transfer to the terminal statement from an outer loop is an Extended 4.3.4 invalid transfer. Range A DO loop has an extended range if it contains a control statement that transfers control out of the loop and if, after execution of one or more statements, another control statement returns control back into the loop. Thus, the range of the loop is extended to include all executable statements between the destination statement of the first transfer The and the following 1. statement rules A transfer from 2. its govern into in the returns use of a control DO to the statement loop. extended the range of a DO statement extended Statements that range: is permitted only range. the extended range must not change the control range control variable. Figure 4-2 illustrates valid and 1invalid extended transfers. valiad Control Transfers » DO 35 K=1,10 DO 15 L=2,20 GO 15 DO TO Invalid Control Transfers GO B 20 Loop 20 B 30 |_ L 35 50 Extended CONTINUE A=B+C DO 35 L=2,20 . A=B+C DO 35 M=1,15 GO TO 50 30 D=E/F 35 CONTINUE X=A*D GO TO 40 DO 45 M=1,15 CONTINUE 40 X=A*D . D=E/F . 45 CONTINUE . CONTINUE Range | . GO Figure 20 DO 50 K=1,10 20 . TO 4-2: 50 . TO 30 Control GO Transfers and TO Extended 30 Range CONTROL STATEMENTS CONTINUE 4,4 CONTINUE The STATEMENT CONTINUE statement statement. loop It transfers is used control primarily when that loop would otherwise statement such as GO or The CONTINUE a statement TO has as the end arithmetic the to the next terminal with a executable statement of prohibited a DO control IF. following form: CONTINUE CALL 4.5 The CALL CALL STATEMENT statement procedure. It (See 6 Chapter executes can for also the a SUBROUTINE specify greater CALL on the list or other for the definition has the following external subroutine. and : statement CALL subprogram argument detail subroutine) . The an use of a form: s[([a)l[,[al])...)] S The name or a of a SUBROUTINE dummy other argument external subprogram associated or with other a procedure. external SUBROUTINE procedure; subprogram or a An If you actual specify values then argument. an (Section argument in the 1list transfers control list, the with the dummy to the subroutine. The arguments data type in the with variables, arrays, constants, CALL the array describes CALL statement arguments first in executable of CALL CALL CURVE ICALL PNTOUT CALL EXIT the arguments.) associates subroutine. statement of the It the statement must agree in number, order, and arguments in the subroutine. They can be elements, constants, expressions, Hollerith array name literals, in the argument ox list subprogram refers array. Examples actual dummy alphanumeric unsubscripted 6.1 statements are: (BASE,3.14159+X,Y,LIMIT,R(LT+2)) (A,N,'ABCD') names. to the An entire CONTROL STATEMENTS RETURN 4.6 RETURN STATEMENT It has the following form: the calling program. subprogram a The RETURN statement is used to return control from to RETURN When a RETURN statement is executed in a function subprogram, control is returned to the statement that contains the function reference (see Chapter 6). When a RETURN statement is executed 1in a subroutine subprogram, control is returned to the first executable statement following statement. the CALL example: RETURN statement 10 SUBROUTINE SIZCHK IF (N) 10,20,30 =-1 20 K=0 30 K=+1 (N,K) RETURN RETURN RETURN END PAUSE 4,7 PAUSE and The PAUSE statement temporarily suspends program execution displays a message on the terminal to permit you to take some action. The PAUSE statement has the following form: PAUSE disp [disp] An alphanumeric literal, a decimal digit string of digits, or an octal The disp argument is one to five constant. optional. The effect of a PAUSE statement If it is running as a depends on how your program is being executed. batch job, the contents of disp are written to the system output file but the program is not suspended. 1f the program is running in interactive mode, the contents of disp followed by the prompt sequence are displayed at your terminal, you should then enter a suspended; is program the that indicating command, after which execution control executable statement following the PAUSE. specific to the operating system, Some examples of PAUSE statements PAUSE 999 PAUSE '"MOUNT NEXT TAPE' resumes Because with the first the command 1is it is not given here. are: CONTROL STATEMENTS STOP 4.8 STOP STATEMENT The STOP the operating The STOP statement terminates statement STOP program system. has the following execution and returns control to form: [disp] disp An alphanumeric digits, The or an literal, octal disp when argument, if execution stops. Example of STOP STOP 98 STOP 'END present, statements OF a decimal constant. digit specifies a string message of one to be to five displayed are: RUN' STOP END 4.9 END The END last The STATEMENT statement source END line marks the end of a program every program unit. of statement has the following unit, It must Dbe the form: END The END statement continued, In a main reaching must not occur program, if the END statement, RETURN statement subprogram, a no STOP on a statement program is continuation prevents execution implicitly 1line execution terminates. executed. or be from In a CHAPTER 5 SPECIFICATION STATEMENTS Specification allocate statements and characteristics The of specfication e ® ¢ e are initialize the symbolic statements IMPLICIT statement symbolic names Type declaration type of statement the -- number statement arrays, used in specifies -- symbolic array statements and the VIRTUAL be -- ® the one implied DATA and ® statement array PROGRAM -- procedure -- elements statement number more contiguous BLOCK DATA which initial in common blocks The following and examples sections of their for one two the or or more more specifed initial values program execution assigns -- values describe data a symbolic establishes may be these in an areas of arrays to entities symbolic names before statement in the of storage assigns -- type dimensions or space declares of dimension associates unit ¢ declares each program -- data in location statement external reserves normal statement storage EXTERNAL be ® same vyou other program. explicitly elements reserves -- outside EQUIVALENCE the ¢ statement located let define names declares of the storage e that and are: -- DIMENSION COMMON names statement specified and nonexecutable variables a to BLOCK assigned to statements, usage. names variables, name to a DATA main giving to arrays, program program entities with unit contained their forms IMPLICIT 5.1 By IMPLICIT STATEMENT default, all interpreted as names beginning integer data, with and the all 1letters names I beginning through with any N are other SPECIFICATION STATEMENTS The IMPLICIT statement permits you to letter are interpreted as real. change these default data typing rules. The IMPLICIT statement has the following form: IMPLICIT typ(al,al...)[,typ(al,al...)])... typ (See Table 2-2.) One of the data type specifiers. ¢ or cl-c2, An alphabetic specification in one of two forms: The latter form specifies a where c¢ is an alphabetic character. in which must occur through c¢2, from ¢l range of letters, order. alphabetical The IMPLICIT statement assigns the specified data type to all symbolic or any letter in a names that begin with any specified 1letter, specified range, and which have no explicit data type declaration. For example: IMPLICIT IMPLICIT INTEGER (I,J,K,L,M,N) REAL (A-H, 0-2Z) These statements specify the default in the absence explicit any of statement. IMPLICIT statements must precede all other and all executable You cannot IMPLICIT label Any data type can be following examples specification statements, statements. statements. in specified show: IMPLICIT DOUBLE IMPLICIT COMPLEX PRECISION (S,Y), (D) LOGICAL*l statement, IMPLICIT an as the type to (L,A-C) TYPE DECLARATION 5.2 TYPE DECLARATION STATEMENTS The type specified statement declaration symbolic explicitly gives a data names. The type declaration statement has the following form: typ typ vi,v]... One of the data o type specifiers The symbolic name of function subprogram, a (see Table 2-2). variable, array, or an array declarator. statement function, The following rules apply to a type declaration statement: e A type declaration statement must precede all executable statements. @ You can declare the data type of a symbolic name only once. 5-2 SPECIFICATION ® You ® cannot You can by appending array A label symbolic use a name can be being is length attribute to *s, specified specifier and an first. Examples INTEGER type declaration declaration an array statement. statement declarator to (see declare Section an array 2.5.1) to followed by a data type length specifier of one of the acceptable lengths for the data Table 2-2). Such a specification overrides that the REAL type name., where s declared (see form a STATEMENTS the statement implies, and item. assigns a new an the type the length If you specify both a data type length declarator, the data type length specifier goes type declaration statements are: array of COUNT, MATRIX (4,4), SUM MAN, IABS LOGICAL SWITCH INTEGER*2 REAL* Q, WX1l, M12*4, WX3*4, IVEC*4 (10) WX5, WX6*8 DIMENSION 5.3 DIMENSION The DIMENSION and the The DIMENSION STATEMENT statement number of specifies elements statement DIMENSION in has the each the number of dimensions dimension. following in an array form: a(d)[,a(d)]... a(d) An array declarator (see Section 2,5.1). a The symbolic name of an array. d A The dimension DIMENSION element in determines number of product of This declarator. statement each allocates dimension the its dimension statement defines and can array defines You also ARRAY MATRIX use array statements. name cannot element The in only label one as having 16 as having 125 declarators However, array DIMENSION For data to type each of Moreover, array is array the array the total equal to example: the MATRIX(5,5,5) each. You storage array. declarators. ARRAY(4,4), VIRTUAL one each length of a storage element. storage elements assigned to an DIMENSION each, of in in type each declarator. statements. real elements integer declaration, program of elements unit, 4 of Dbytes 2 bytes COMMON, you can use and an SPECIFICATION STATEMENTS Examples of DIMENSION statements are: BUD(12,24,10) DIMENSION DIMENSION X(5,5,5),Y(4,85),2(100) DIMENSION MARK(4,4,4,4) For further information on arrays and on storing array Section elements, see 2.5. COMMON 5.4 COMMON STATEMENT A COMMON statement reserves one or more contiguous blocks of name symbolic A identifies each block; the order of statments common block. specify storage. you can omit a COMMON program unit. variables and arrays in each symbolic name for the blank common block in a also however, The COMMON statement has the following form: COMMON [/[cbl/] cb nlist nlist[[,]/[cb]/ nlist]... A symbolic name, called a common block name. cb can be Dblank. If the first cb is blank, you can omit the first pair of slashes. A list of variable names, separated by commas. A common block name can be the same However, it and array variable or names, array as a declarators array name. cannot be the same as a function name or subroutine name in the executable program (see Section 2.1). When you declare common blocks of the same name in different program units, these names are all associated with the same storage area when For the program units are combined into an executable program. example: PROGRAM MAIN COMMON /BLOCK1/ICOUN, IHOL/BLOCK2/ICHK CALL GSUB END SUBROUTINE GSUB COMMON /BLOCK2 /JCHK (10) /BLOCKL /JCOUN, JHOL END In the example, BLOCKl in MAIN and BLOCK1 in GSUB are associated the same storage area, as are the BLOCK2s, with You can have only one blank common block in an executable program, but you can have any number of named common blocks. SPECIFICATION Entities are In above the storage space Entities agree in if the INTEGER*2 to COMMON with same must results unit space may to not assign in on for beginning Examples occur an on of a when the to a way byte the or boundary. (even program 2-byte 2 the list. program unit same should correspondence program unit. For The byte) statements are combined into of variable the variables subsequent however, units integer bytes (BYTE) that blocks; word these data compiler all of MONEY real or arrays other block is variable any supplies common no to a type is filler are allocated /BLK1/LIMA,R/ /ALFA,BET boundary. follow. Program Subprogram HEAT,X/BLK1/KILO,Q SUBROUTINE FIGURE FIGURE . RETURN END statement block, and statement and KILO the statement. COMMON COMMON HEAT in basis. with statement . COMMON one-for-one one-to-one another . The a first one in the . CALL on associated occur in by high-order LOGICAL*1 odd COMMON Main common are placed contains because the such common COMMON statement contains program block allocated each block unit CENTS. You they entities common blocks JCOUN MONEY correspond common common and MONEY executable made a because program program COMMON incorrect by in ICOUN CENTS another an BLOCKl type one COMMON and in data them example, storage example, assigned in with assigned STATEMENTS X in and Valid Q in the in in puts the the main KILO and program Q subroutine blank common in a makes block, puts named ALFA and BLKl. HEAT and common and makes X in block, BET LIMA the blank BLK1l. correspond and R The to correspond Usage LOGICAL*1 CHARS (9) COMMON/STRING/ILEN,CHARS Invalid Usage LOGICAL*1 CHARS (9) COMMON/STRING/CHARS, ILEN In odd the second example, byte address. the integer variable ILEN is allocated on an SPECIFICATION STATEMENTS VIRTUAL 5.5 VIRTUAL STATEMENT allocated in physical A virtual array is an array whose storage is addres sable main memory. ly main memory outside of the program's direct ly addressable direct frees m progra a in arrays The use of virtual memory for executable code and other data storage. specifies the The VIRTUAL statement specifies a virtual array. s It dimension. each in element of number the and ons, number of dimensi The VIRTUAL statement has the following form: VIRTUAL a(d) a(d) a [,a(d)]... An array declarator (see Section 2.5.1). The symbolic name of an array. 4 A dimension declarator. directly addressable space available to user total or 65,536 programs executing on a PDP-11 family computer sis of64K, 1 to 8 from element 32,767 of m maximu bytes. An array can have a element per byte 1 of array L*1 LOGICA m maximu A . element per bytes maximum COMPLEX array The maximum would require 32,767 bytes of storage space. A storage space, a of 8 bytes per element would require 262,136 bytes of ressab le memory. ly-add direct on limit requirement far beyond the 64K without memory main l externa in placed are arrays Virtual memory le ressab ly-add direct of 64K significantly diminishing the to available programs. NOTE Virtual arrays are not supported on all See the systems. operating PDP-11 appropriate PDP-11 FORTRAN IV user's guide for more information. Examples: VIRTUAL A(1000), LARG(180,180), MULT (4,4,4,4,4,4,4) named A having 1000 The above example defines a one-dimensional arrayhaving 32400 elements, LARG named array elements, a two-dimensional 16384 elements. and a seven-dimensional array named MULT having same way as the The data type of a virtual array is specified in the implicitly either is, that array, or e data type of any other variabl a type in itly explic or name the of letter first the to ing accord declaration statement. For further information Section 2.5. concerning arrays and their storage, see SPECIFICATION 5.5.1 Restrictions The names used in some 1. A of virtual 4. array of and name Virtual virtual must not name of used A virtual in a virtual an array EQUIVALENCE array initial array be or value virtual by a or 5. The be I/0 name of a specified The name actual value 7. virtual as of of a to The name wused (Section the of array the an to or array a a not COMMON array must virtual array the as a format (third or statement must if not the element must not argument inside (Section 7.6). be used subprogram argument format array or specifier virtual array element assigned run-time a virtual DECODE not 5.6) . argument dummy specify of be statement element contain name appear subprogram corresponding to a (Section to The or buffer ENCODE virtual argument be in must array element cannot be statement (Section 5.8). DATA statement. parentheses) 6. used virtual arrays cannot be used specifications (Section 8.6). virtual array element must not an elements statement Virtual in Arrays 5.4). be an Use arrays contexts: The 3. the virtual (Section 2. on STATEMENTS (Section as an assigns a 6.1). virtual NAME 9.1.13). array element cannot keyword in an OPEN statement Examples: Valid Usage VIRTUAL A(1000),B(2000) READ(1,*) DO 10 A 10,1I=1,1000 B(I)=-A(I)*2 WRITE(2,*) CALL SUB Invalid Usage VIRTUAL A(10) DATA (A(I),I=1,1000) (A,B) A(l)/2.5/ COMMON /X/ A EQUIVALENCE WRITE(1,A) (A(l),Y) X,Y ENCODE(4,100,A(3)) 5.5.2 A Virtual Array dummy argument associated with an X,Y References declared actual (Used in DATA (Used in COMMON (Used in EQUIVALENCE (Used as format specifier) (Used as ENCODE output in as statement) statement) An actual variable argument associated (see that a argument is a virtual that reference only with Section 2.4). 1In a buffer) Subprograms is array also array. become statement) to a the virtual dummy argument effect, an actual can only name of array declared argument a become virtual element as a that can simple is a SPECIFICATION STATEMENTS a Furthermore, an expression. virtual array element is treated as value must have been assigned to the element before it is used as an The subprogram must not alter the value of the actual argument. corresponding dummy argument. EXAMPLES: Valid Usage A(1000),B(1000) VIRTUAL B(3)=0.5 CALL SCALE(A,1000,B(3)) END SUBROUTINE (X,N,W) SCALE X (N) VIRTUAL S=0 DO 10 I=1,N 10, S=S+X(I)*W TYPE *,S END Invalid Usage VIRTUAL A(1000) REAL B(4000) CALL ABC(A,B,A,(3)) END SUBROUTINE ABC(X,Y,Z) (Actual argument is virtual) (Actual argument is nonvirtual) (Actual argument is virtual array REAL X (1000) VIRTUAL Y (4000) Z=2.3 element) END EQUIVALENCE 5.6 EQUIVALENCE STATEMENT The EQUIVALENCE statement partially or totally associates two or entities in the same program unit with the same storage location. more The EQUIVALENCE statement has the following form: EQUIVALENCE nlist (nlist) [,(nlist)]... A list of variables, array elements, and arrays separated commas. You must specify at least two entities in each list. by 1list The EQUIVALENCE statement allocates all of the entities in each In an EQUIVALENCE statement, each expression in a subscript reference beginning at the same storage location. must be an integer constant. ' Dummy arguments, virtual arrays, and virtual array elements may not be used in an EQUIVALLENCE statement. SPECIFICATION You a must way byte An not equivalence that subsequent data used EQUIVALENCE LOGICAL*1l of STATEMENTS arrays any boundary. array name in element of You equivalence can the that each store multiple variables begins with Examples of Valid the of one a data PRECISION of the complex statements (DVAR,IARR(1l)) EQUIVALENCE statement IARR occupy Invalid Usage the makes same above (ILEN, example, Making you Arrays make an make an integer variable shares variable. the four as elements the double of the integer precision variable integer variable ILEN is allocated the elements of arrays share same element of of another the first You must the a not to to normal the use the or linear array and of the the statement of of locations storage element for made equivalent, example, the in a to same way assign array. that is the same You also of array elements. For array equivalent to to equivalence attempt first array and set the an sixth example, the examples DIMENSION of TABLE EQUIVALENCE a these result storage of the use of (2,2), the TRIPLE (TABLE(2,2), these EQUIVALENCE both element overlap storage must element statement you first array. the odd third inconsistent one then the made equivalent to the first elements of the first array second array. elements memory are I1f, is five EQUIVALENCE more arrays space. array the assign element equal-sized storage last elements of two first two 7-element five make As an the array, the Some on of one array equivalent to an element of EQUIVALENCE statement also sets equivalences corresponding elements of the two arrays. Thus, if the first second you integer element between another if Equivalent array, attempt data types, such Furthermore, you can single component of BYTS(2)) the another location first are: storage address. When a the odd BYTES (10) EQUIVALENCE 5.6.1 with such an DVAR EQUIVALENCE the type to in on IARR(4) LOGICAL*1 In numeric address. example, variable, the DVAR. byte refers For complex part same elements allocated Usage INTEGER*2 array is statement different the type. EQUIVALENCE DOUBLE This real of at components higher-ranked data variable equivalent to storage other type array. entity a an with other not with cannot element between of the of the other follow. (2,2,2) TRIPLE(1,2,2)) statements, the space allocated to statements align the arrays. entire array array TRIPLE. TABLE shares Figure 5-1 part shows of how SPECIFICATION STATEMENTS Array TABLE Element Number TRIPLE(1,1,1) TRIPLE(2,1,1) TRIPLE(l,2,1) TRIPLE(2,2,1) TRIPLE(1,1,2) TRIPLE(2,1,2) TRIPLE(1,2,2) TRIPLE(2,2,2) Element Number Array Element Ol Array Element WU WN - Array TRIPLE TABLE(1,1) TABLE(2,1) TABLE (1,2) TABLE (2,2) Equivalence of Array Storage Figure 5-1: The following statements also align the two arrays as shown in Figure 5-~1: EQUIVALENCE EQUIVALENCE (TABLE,TRIPLE(2,2,1)) (TRIPLE(l,1,2), TABLE(2,1)) In the EQUIVALENCE statement only, you can identify an array element (that is, the linear element number), even with a single subscript For though the array was defined as a multidimensional array. example, Figure the EQUIVALENCE 5.6.2 aligns the two arrays as shown in statement following 5-1: (TABLE(4), TRIPLE(7)) Extending Common Blocks When you make entities equivalent to other entities stored in a common block, the common block can be extended beyond its original boundaries But to include the entities specified in the EQUIVALENCE statement. you can extend the common block only beyond the last element of the previously established common block. extend cannot You the common B(5) B(6) block in such a way as to place the extended portion before the first The following examples show element of the existing common block. valid and invalid extensions of the common block: valid COMMON A(2) A(l) DIMENSION A(4),B(6) A EQUIVALENCE (A(2),B(1l)) B(l) A(3) A(4) B(2) B(3) B(4) vy ~— S g ~ Extended Portion Existing Common Invalid DIMENSION A(4),B(6) COMMON A B(1l) EQUIVALENCE (A(2),B(3)) A(l) A(2) A(3) A(4) B(2) B(3) B(4) B(5) \V_/\ Ex tended Portion If you assign two entites to equivalent to each other. common — - —~ Existing Common blocks, you cannot B(6) 7 ~ Extended Portion make them SPECIFICATION STATEMENTS EXTERNAL 5.7 EXTERNAL The EXTERNAL arguments An external The statement to subprogram STATEMENT other procedure (Section EXTERNAL v symbolic EXTERNAL external to name a Note, however, (for example, not a An a a use in a a subprogram declares or function as actual subroutine (Section 6.3). form: the a in name. The CALL the each a name subprogram reference complete SQRT(B) or name of a name. that Such function or name can 1in then can use CALL dummy the appear the argument list is as actual an associated reference used as an SUBR(A,SQR (B) ,C)) T represents name dummy statement. function function an need not be argument a value, defined in an : the EXTERNAL Main Program EXTERNAL names function library following subprogram name. that of procedure user-supplied statement. example external FORTRAN the subprogram; subprogram EXTERNAL of a statement argument be or has name with procedure argument you {,v}... associated The can 6.2) statement EXTERNAL The lets subprograms. statement is: Subprograms SIN,COS,SINDEG SUBROUTINE EXTERNAL . Y . = TRIG (X,F,Y) F F(X) RETURN CALL TRIG (ANGLE,SIN,SINE) CALL TRIG (ANGLE,COS,COSINE) CALL TRIG (ANGLE,SINDEG,SINE) END . . . FUNCTION SINDEG SINDEG SIN = (X) (X*3.14159/180) RETURN END In the the example, FORTRAN statements function second TRIG, pass the reference statement the SIN library, second of and COS and name of F (X) TRIG. statement Y SIN (X) Y COS (X) Y SINDEG (X) are SINDEG a trigonometric is a functions supplied 1in user-supplied function. The CALL function to subsequently Depending is on equivalent the subroutine invokes which to the CALL one of TRIG. function statement the The in the invoked following: SPECIFICATION STATEMENTS DATA 5.8 DATA STATEMENT The DATA statement assigns initial values to array elements before program execution, variables, arrays, and Or array The DATA statement has the following form: DATA nlist/clist/[[,)nlist/clist/]... nlist A list of one or more variable names, names, array names, separated by commas, to which the values in clist basis. one-for-one be assigned sequentially on a element are to Subscript expressions must be integer constants. clist A list of constants, separated by commas, to be assigned Clist constants have one of the following forms: nlist. to val n * val Used when you specify clist as n * val. Specifies the number of times the same value is to be assigned to successive entities in the associated nlist. The value of n is a nonzero, unsigned constant. integer The DATA statement assigns the constant values in each <clist to the entites in the preceding nlist. Values are assigned one for one in the order in which they appear, from left to right. The number of constants must correspond entities in the preceding nlist. exactly to the number of When an unsubscripted array name appears in nlist, values are assigned to every element. The associated constant list must therefore contain enough values to fill the array. Array elements are filled 1in the order of subscript progression. Dummy arguments, virtual arrays, and virtual array elements may not be initialized in DATA statements. When a Hollerith constant or alphanumeric literal is assigned to a variable or array element, the number of characters that can be (see Table 2-2). assigned depends on the data type of the component capacity of the the than s character fewer contains If the constant variable or array element, the constant is extended on the right with 1f the constant contains more characters than can be stored, spaces. the constant is truncated on the right. Examples of INTEGER the DATA statement are: A(10) BYTE BELL,TAB,LF,FF,ACHR,ZCHR DATA A, BELL,TAB,LF,FF,ACHR,ZCHR/10*0,7,9,10,12'A"',1HZ/ SPECIFICATION In the array example, the A, the ASCII BELL, TAB, and byte variables Some other REAL examples statements control LF, assign 0 to character all codes 10 are FF. elements assigned to of the are: X (5) COMPLEX DATA DATA STATEMENTS 72 X/2*—3.,4.,2*0.37/,Z/(l.0,-3.0)/ PROGRAM 5.9 PROGRAM STATEMENT The PROGRAM statement assigns a The PROGRAM statement has following PROGRAM the symbolic name to a main it, it program unit., form: nam nam A The symbolic PROGRAM first the statement statement name of any the same same executable The name, as PROGRAM is optional. in the main entity within the name of program statement any (see must If you program. use The the symbolic main program. subprogram, entry, Section not have It or must be name must also must common statement be not be in the block 2.1), a the not label. BLOCK DATA 5.10 The BLOCK BLOCK only DATA DATA purpose blocks. statement is to BLOCK the a special type blocks and common BLOCK DATA statements. DATA BLOCK begins declare Therefore, nonexecutable The STATEMENT statement DATA [nam] A symbolic name. can use has the program following of to program define wunit unit data can in contain whose common only form: nam You EQUIVALENCE, The last only and statement statement., type DATA in declaration, statements a BLOCK DATA program ‘ A BLOCK DATA program A BLOCK DATA statement unit must must not not IMPLICIT, following contain have a any a DIMENSION, BLOCK unit DATA must executable statement label. COMMON, statement. be an END statements. SPECIFICATION STATEMENTS If you use a BLOCK DATA program unit to initialize any entity in a you must provide a complete set of data type block, common specification statements for all the entities 1in the block, even though some of the entities are not assigned an initial value in a DATA statement. You can use the same BLOCK DATA program unit to define initial values for more than one common block. An example of a BLOCK DATA program unit is: BLOCK DATA BLKDAT INTEGER LOGICAL S,X T,W DOUBLE PRECISION DIMENSION R(3) U COMMON /AREAl/R,S,T,U,/AREA2/W,X,Y DATA R/1.0,2*2.0/,T/.FALSE./,U/0.214537D-7/,W/.TRUE./,Y/3.5/ END In the example, enough information implicitly declare the data type blocks AREA1l and AREA2. Not all the statement. 1is provided to explicitly or of every variable in the common variables appear in the DATA ' CHAPTER 6 SUBPROGRAMS A subprogram procedure. is one A subprogram the subprogram some cases, different program Subprograms of the are FORTRAN User-written same of two kinds: subprograms of the called actual arguments to dummy in be In discussion A subprogram referencing a argument the arguments basis argument and any also cases, the library references to the or supplied in in as a part back functions: to to Section The subprogram the actual referencing 6.1 which subprogram receive the system-supplied the subprogram, results. describes describes the specifies arguments. program. actual user-written passes uses and dummy subprograms; and subprograms. is 1is ends. reference For example, of if when on assigned returns, 1is the (I,J(3),4) of and is the a list to the dummy of of subprogram. corresponding argument corresponding actual actual argument actual in of actual value of K is 4. the argument. and dummy association next. arguments, a the association the M has of the retention to dummy transferred value to to no subprogram an associated list associated with J(3), is the assigned There a control takes value subprogram one is located, an entity which passes a value to or from a arguments are specified in the statement the subprogram. Dummy arguments are specified in the of the subprogram and are associated with actual arguments dummy subprogram When is other in ARGUMENTS one-to-one argument; statement and, Actual definition Each computing references references arguments, 6.2 describes SUBPROGRAM a that kinds: FORTRAN that passed below, Section subprogram. on turn to function compute called 6.1 define statement user-written three arguments, may 6.3 of program actual entities, Section wunit either reference Values the are Processor-defined cases, that a functions kind values, when referencing system. Subroutines arguments; statements unit. ® many of invoked The Functions ® is program e one group the Statement is a executed. ® There In is in or from arguments and (K,L,M) associated with I, L is SUBPROGRAMS Rules Governing Subprogram Arguments 6.1.1 constants, Actual arguments can be elements, or subprogram names. array Actual as appear the subprogram definition variables, arrays, expressions, Dummy arguments as specified in variable unsubscripted names. must agree in order, number, and data type with the arguments dummy arguments with which they are associated. are Dummy arguments symbolic names associated become which with variables, arrays, or subprograms defined or declared in other program A units. associated dummy an with argument actual is wundefined if Although dummy arguments are not variables, each dummy argument array, or subprogram. it not is currently argument. arrays, Or subprograms, may be declared as though it were a variable, the Each dummy argument name is declared with the associated actual argument. attributes of Of If the actual argument is a constant, expression, subprogram name, may argument dummy g correspondin the reference, array element virtual not be modified. A dummy argument declared as an array can be associated only with an 1is an array or array element of the same data actual argument that dummy argument array If the actual argument is an array element, the dummy argument array type. If the actual argument is an array, the must not be larger than the actual argument array. will be associated with elements of the actual argument array starting In this case, the dummy argument array must from the actual argument. not be larger than the number of elements remaining in the actual argument array. Valid Usage PROGRAM MAIN DIMENSION CALL X(A, A(10), B(5.5) B(1l,2)) END X(Y,Z) DIMENSION Y (10), Z(5,2) SUBROUTINE END Invalid Usage PROGRAM MAIN DIMENSION CALL A(10), B(5,5) X(A,B(1,21) END SUBROUTINE X (C,D) DIMENSION C(12) DIMENSION D(5,5) END (dummy array must not be larger than actual array) (dummy array must not be larger than number of elements remaining in actual array) SUBPROGRAMS 6.1.2 Adjustable Arrays An adjustable array is a dummy argument array with dimensions that can be changed or dimensions of the associated actual argument program. as An well The as adjustable constants, following ® The rules array in the govern adjustable declarator dimension the use array The adjustable argument ® ® array is an must size of the the adjustable size of the actual be a become in the match the referencing integer variables, arrays: dummy argument associated with array must be less array. in the adjustable array adjustable dimensions must be Variables the in contains subprogram declarators. Variables ® array a to adjustable array arguments of the subprogram, arguments must have a defined than declarator of the the or the actual equal that integer declarator and of an array. The the For that in "adjusted" adjustable must subprogram. e of declared to represent data must type. be dummy corresponding actual value. example, PROGRAM MAIN DIMENSION SUM1 = Al1(10,35), A2(3,56) SUM(Al1,10,35) SUM2 = SUM(A2,3,56) SUM3 = SUM(A1l,10,10) END FUNCTION SUM DIMENSION 10 (A,M,N) A (M,N) SUM = DO 10 J = 1,N DO 10 I = 1,M SUM = 0.0 SUM + A (I,J) RETURN END In the example, array. of Al The or control Al 6.2 A more the the DO You can places of in that statement information user-written a actual Note USER-WRITTEN be are A2. statements can A2 subprogram A, For and function on series perform of is either subprograms your program, or as well declarators, A is sum of M and arguments iteration a use operations and the as see to the adjustable specified N are specify Section sections used the size to of 2.5.1. SUBPROGRAMS subprogram that dummy array arrays computes a FORTRAN statement or computing procedure. arithmetic A operations or and statements to perform thus in avoid each a computing having place. to group of computing FORTRAN procedure duplicate FORTRAN procedure statements. in several the series SUBPROGRAMS Table 6-1 1lists There are three types of user-written subprograms. it, and the define to needed ts statemen the am, each type of subprogr method of transferring control to the subprogram. Table 6-1: Types of User-Written Subprograms Subprogram Method definition Function reference function Statement function Function subprogram FUNCTION Function reference Subroutine subprogram SUBROUTINE Statement . Control Transfer Defining Statements RETURN CALL statement RETURN A function reference consists of the function name and the function arguments and is used in an expression. The function returns a value that is used in place of the reference in the expression in which it appears. Function and subroutine subprograms can change of their cannot, either values the arguments and the calling program can use the changed values. A subprogram can refer to other subprograms, directly or indirectly, refer to itself. but it Statement Functions 6.2.1 A statement function is a single-statement computation specified by a When you reference the statement function name, with symbolic name. its arguments, in an expression, the computation defined by the statement Ffunction name is performed and the resulting value replaces Statement the statement function name in evaluating the expression. unit. program single a within d reference and defined are functions The statement function definition statement has the following form: £ f p ([pl,pl...]1)=e The name of the statement function. A dummy argument. e An expression. The expression (e) is an arithmetic or logical expression that defines the computation to be performed. SUBPROGRAMS A statement £ function reference has the following form: (lal[,al...]) The name An actual of the function. argument. When a statement function reference appears 1in an expression, the values of the actual arguments are associated with the dummy arguments in the statement function definition. The expression in the definition is then evaluated. The resulting value is used to complete the evaluation of the expression containing the function reference. The following e rules govern the Statement function unit., use names of statement must be functions: . unique within the same program e A statement unit as its ¢ A statement function definition statement reference to another statement function, which earlier in the same program unit. e Statement function definitions must be executable statements (see Figure 1-3). e The data type of the resulting value assigned to the determined either implicitly by the first letter of or explicitly by a type declaration statement. e Statement order, function reference definition. function number, dummy and must appear arguments data type of in the same can must placed program include a be defined before all name 1is the name, serve only to indicate arguments for the statement function. e Statement function usual rules for 2.1). Statement within each arrays of declared e dummy argument uniqueness of function statement the and same used dummy names do not symbolic names arguments function names within as the be definition. the same must dummy program follow the (see Section unique Variables arguments can or be unit. The data type of statement function dummy arguments 1is determined either implicitly by the first letter of the name, or explicitly by a type declaration statement. Examples of statement function definitions are: valid VOLUME (RADIUS) = AVG (A+B+C)/3 SINH (A,B,C) (X) = = 4.189*RADIUS**3 (EXP(X) - EXP (-X))*0.5 Invalid/Explanation AXG only (A,B,C,3.) = (A+B+C)/3 (A constant argument). cannot be a dummy SUBPROGRAMS Examples of statement refer the second to function statement references function follow. definition The examples below above. valid GRADE IF = AVG (AVG (TEST1,TEST2,XLAB) (P,D,Q).LT.AVG(X,Y,Z))GO TO 300 Invalid/Explanation FINAL (An in = actual data 6.2.2 AVG (TEST3,TEST4,LAB2) argument type; in Function A function When you and this its case, corresponding LAB2 is dummy integer argument but C above must is agree real.) Subprograms subprogram reference is a the program unit referenced by function name, with its a symbolic arguments, name. in an expression, the program unit defined by the function name is executed; and the resulting value of the function replaces the function name in evaluating the expression. A function subprogram consists of a FUNCTION statement computing procedure. The FUNCTION [typ] typ followed statement FUNCTION One of the The name has the by a series following of statements that define a form: nam[*m] [([p[,pP]...])] data type specifiers (see Table 2-2). nam of the function. m p A A data A dummy function has the type length specifier (see Table 2-2). argument. reference following that transfers control to a function subprogram form: nam ([a[,al...]) The symbolic nam When An actual the name name of the function. argument. of the function subprogram is used in an expression, control 1is transferred to the subprogram; and the values of the actual arguments (if any) in the function reference are associated with the dummy arguments (if any) in the FUNCTION statement. The statements in the subprogram are then executed. A value must be assigned to the name of the function as though it were a variable. Finally, a RETURN statement control to the <calling implied RETURN. The value to complete the evaluation is executed in the function and returns program unit. An END statement acts as an assigned to the function's name is now used of the expression containing the name. SUBPROGRAMS The following ® The ® The e A rules govern use FUNCTION statement function subprogram. FUNCTION function SUBROUTINE, ¢ A function cannot e The data type e The example or type function a X can itself of or a subprograms: be first the have not a statement statement contain these FUNCTION statement. reference another either directly function name or can in the in function must the have the referencing subprogram subprogram but it indirectly. be specified FUNCTION same a statements: statement statement. name of label. another explicitly and FUNCTION 2 must DATA, function not subprogram declaration of must BLOCK subprogram subprogram of must statement reference implicitly An the data type either or in in a the program. is: ROOT (A) =1.0 EX = EXP(X) EMINX ROOT IF X = = 1./EX ((EX+EMINX)*.5+COS(X)-A)/((EX (ABS (X-ROOT).LT.lE-6) = - EMINX)*.5-SIN (X)) RETURN ROOT GO TO 2 in this END The to function obtain the example root of cosh(X) + F(X) = The value of this root is: Xi+l = A is X1 - uses the Newton-Raphson following function: the cos(X) passed as - an A iteration method =0 argument. The iteration formula for cosh (Xi)+cos (Xi)-A sinh (Xi)-sin(X1i) The is caluclation less than is The function uses (see Section 6.3). 6.2.3 A Subroutine subroutine name., When program to the returned a a the FORTRAN defined the SUBROUTINE the difference between Xi and library functions EXP, SIN, COS, Xi+l and ABS Subprograms is reference statement computing until : subprogram you unit to repeated 1.0E-6. by a the statement procedure. unit subroutine subroutine function subroutine program the and referenced name name function name. A followed by in is series by CALL a symbolic statement, the executed. In contrast subprogram, no value subroutine a a of subprogram statements consists that is of define SUBPROGRAMS The SUBROUTINE statement has SUBROUTINE nam the following form: [([pl,p]...1)] nam The A name dummy of the subroutine. argument. You must use a CALL statement to transfer control to a subroutine subprogram, and a RETURN statement to return control to the calling program unit. Section 4.5 describes the CALL statement. When control is transferred to the subroutine, the values of the actual arguments (if any) in the CALL statement are associated with the corresponding dummy arguments (if any) in the SUBROUTINE statement. The statements in the subprogram are then executed. Finally, a RETURN statement is executed in the subroutine and it returns control implied The to the calling program. An END statement acts as an of a RETURN. following ® rules govern The SUBROUTINE the use of subroutine statement must be the statement must not have subprograms: first statement subroutine. @ The SUBROUTINE e A subroutine DATA, e or subprogram must another SUBROUTINE not a contain statement a label. FUNCTION, BLOCK statement. A subroutine subprogram can reference another it cannot reference itself either directly or subprogram, indirectly. but Example: The subroutine in the following example computes the volume of a regular polyhedron, given the number of faces and the length of one edge. It uses the computed GO TO statement to determine whether the polyhedron is a tetrahedron, cube, octahedron, dodecahedron, or icosahedron. The GO TO statement also transfers control to the proper procedure for calculating the volume. If the number of faces is not 4, 6, 8, 12, or 20, the subroutine displays an error message on the user's terminal. Main Program COMMON NFACES, EDGE, VOLUME ACCEPT *, NFACES,EDGE CALL PLYVOL TYPE *, STOP END 'VOLUME=',6VOLUME SUBPROGRAMS Subroutine SUBROUTINE COMMON CUBED PLYVOL NFACES, EDGE,VOLUME Goro = EDGE**3 (6,6,6,1,6,2,6,3,6,6,6,4,6,6,6,6,6,6,6,5) ,NFACES GOTO 6 1 VOLUME = CUBED * 0,11785 = CUBED = CUBED * 0.47140 = CUBED * 7.66312 = CUBED * 2.18170 RETURN 2 VOLUME RETURN 3 VOLUME RETURN 4 VOLUME RETURN 5 VOLUME RETURN 6 TYPE 100 100, FORMAT NFACES (' NO REGULAR POLYHEDRON HAS ',I3, ' FACES.'/) VOLUME=0.0 RETURN END 6.3 FORTRAN LIBRARY FORTRAN library in the same way For FUNCTIONS functions are system-supplied subprograms as user-written function subprograms. referenced example: R = 3.14159 * ABS is a absolute FORTRAN value library of X-1 3.14159; the The FORTRAN gives the ABS (X-1) result is function. As a result of this reference, the 1is calculated and multiplied by the constant assigned library functions are data type of each to the variable “"R. listed in Appendix B, which also 1library function and of the actual arguments. The FORTRAN 1library functions. Note that Intrinsic Functions functions the and also are processor-defined the Basic External called functions Functions processor-defined include both the described in ANS FORTRAN. Normally, a name in the table of processor-defined functions refers to the FORTRAN library function with that name. However, the name can refer to a user-defined function wunder any of the following conditions: e The name appears in different data type a type declaration from that shown in statement specifying the table. @ The name is used in different data type a function reference with arguments from that shown in the table. of a a Processor-defined function names apply only to the program unit in which they are referenced. Thus, they can be used for other purposes in other program units. In addition, the data type of a processor-defined function does not change because of an IMPLICIT statement, CHAPTER INPUT/OUTPUT FORTRAN programs use READ REWRITE, TYPE, and PRINT statements are translation wused and and with editing ACCEPT statements format of data (readable character) form. Each or statement refers WRITE STATEMENTS statements external READ 7 for for output. specifiers between to the input, Some that internal logical ACCEPT, rather, unit. TYPE, they The user's ACCEPT terminal system line (binary) ® PRINT data and TYPE and the (I/0) Direct to Internal and I/0 data program. See statements between are unit refer and to an normally is that from 1I/0 - to or records, access ENCODE and between variables units; logical to connected form DECODE format specifiers statements form in See arrays the to and from terminal. by Section statements and the to categories: selected files. a See record 7.4. translate within the and FORTRAN 7.6. 1I/0 (binary) three from to logical sequentially I/0 device such as a transfers Section into and implicit connected normally the connected records an direct contain character) grouped transfers Formatted internal (readable not program statement are and from - transfer statements. - Access number, ® do the statements PRINT statements Sequential I/0 files, or to Section 7.3. ® statements between these form printer. Input/output I/0 and transfer WRITE, of control which data is to be transferred. A logical unit can be device or file by the OPEN statement (see Section 9.1). The and forms the are are within called used the to formatted translate program and 1/0 data external records. I/0 statements that do not contain format specifiers are called unformatted 1I/0 statements. Unformatted I/0 statements transfer data without translation. Unformatted I/0 1is generally used when data output by similar) the data external I/0 and on how unformatted record the associated format transferred. data I/0, transferred. be saves all data in contain, file terms and input execution preserves conserves can is subsequently I/O process, usually transfer one will Unformatted translation data, that depend In program statements data be a program. greater storage of the by by same (or a eliminating precision in the amount of space. records. way the time The records are separated, transferred. the I/O In formatted specifier statement jointly specifies 1/0, the determine the 1I/0 the amount of statement amount of data to and its data to be INPUT/OUTPUT STATEMENTS Executing an input or output statement initiates transfer of a new record. Normally, the data transferred by an I/0 statement constitutes one record. However, formatted I/0 statements can transfer more than one record. Section 7.1 describes general FORTRAN input/output concepts. Section 7.2 describes the components of FORTRAN I/O statements. Sections 7.3 through 7.6 describe each category of I/0 statement. I/0 OVERVIEW 7.1 The following sections describe in general terms the characteristics of FORTRAN I/0 processing: records, files and access modes. See the appropriate PDP-11 FORTRAN IV wuser's guide for more detail about FORTRAN 7.1.1 I/0 processing. Records A record is a collection of data items, called fields, that are logically related and are processed as a unit. Each FORTRAN I/O statement transfers one record. Formatted I/0 statements may transfer additional records. If an input statement does not use all of the data fields in a record, the remaining fields are ignored. If an input statement requires more data fields than the record contains, an error occurs. If an output statement record can contain, an 7.1.2 attempts to write more error condition occurs. data fields than PFiles A file is a collection of logically related records, arranged 1in sequential order, and treated as a unit. The arrangement of a file determined when the file is created. Files can be stored on disk or on magnetic devices such as terminals, card readers, and as the sequential tape. Other line printers a is peripheral are treated files. In the sequential file organization, records appear in physical sequence. Each record, except the first, has another record preceding it, and each record, except the last, has another record following it. The physical order in which records appear is always identical to the order in which the records were originally written to the file. 7.1.3 Access Modes Access mode is the method your program uses to retrieve and store records in a file. The access mode is specified as part of each 1/0 statement. PDP-11 FORTRAN IV supports two kinds of access modes: sequential and direct. 7.1.3.1 Sequential Access - Sequential access means that records processed 1n sequence. For a sequential organization file, sequence is the physical sequence of 7-2 the records. are the INPUT/OUTPUT 7.1.3.2 Direct specifies number in records 7.2 the each must 1/0 Access order I/0 be - of Direct processing statement. STATEMENT access by For fixed-length, STATEMENTS means including sequential a that the direct access organization program record files, the COMPONENTS The following sections logical unit numbers, key expressions, control 7.2.1 A if or A or I/0 error Logical logical file an or Unit unit number logical with unit a end-of-file is A an value number in is Explicitly through ® TImplicitly by guide numbers in Format Format specifiers of the are The statement ® The name 8 of 7.3.3 7.2.3 A direct position The to value the 7.2.4 If an WRITE, 1/0 7.3.4 Direct in to an 99, a file device or Statement The the (see of in specific constant one Section appropriate use a integer through to of two 9.1). PDP-11 FORTRAN implicit 1logical 1V unit Record record number in error REWRITE, greater number End-of-File or you a run-time format Section 8.7 statements. can of a use an than or or and end-of-file ENCODE can be any (see Section describes asterisk formatting. is an integer value direct access file, records Condition and instead See the of a Sections Numbers record be 1/0 statements statement. denote list-directed list~directed 1/0. access must FORMAT I/0 statements, and statements, on a containing of the formatted of array formats Access maximum I/0 be 1 detail. label FORMAT between specifier and OPEN System. used an describes sequential format to refers must Specifiers ®¢ interaction occurs. that number range describes greater 8.6). In the following: Chapter the an value unit connected ® user's integer logical ways : 7.2.2 condition Numbers 1/0 device. variable describe the components of I/0 statements: format specifiers, dire ct access record numbers, lists, and parameters specifying the transfer of equal in to the Error Condition statement 7-3 and less file, condition DECODE 1, that is can specifies than the or equal any READ, Parameters encountered, specify that control is INPUT/OUTPUT STATEMENTS rs have the ement. The specifie to a specified stat to be transferred resp conditions: r erro and ile of-f endfor ectively, following forms, END=s ERR=s to be The label of an executable statement to which control is transferred. de either ENCODE or DECODE statementin cananyinclu A READ, WRITE, REWRITE, above . The order specifications, the or both of must and/or r, numbe d recor r, numbe unit follow the specification(s) format. to ification must refer the in the END=s or ERR=s spec The statement label emen of that as unit ram prog same the in t with an executable stat 1/0 statement. records exist in a occurs when no more produ An end-of-file conditionwhen ced by the ENDFILE d recor ile end-f an sequential file, oOr a READ statement 1f is encountered. statement (see Section 9.8)e condi 1/0 operation, it an g durin tion f-fil encounters an end-o specification. END=s named in the transfers control to the statementnt, an error condition occurs. If no END=s specification is prese 1f a READ, WRITE, REWRITE, ENCODE or DECODE statement encounters an sfers control to the an I/0 operation, it tran error condition during ion., If no ERR=5S ficat speci ERR=S the statement whose label appears in is present, the 1/0 error terminates program execution. s or REWRITE statement or directa acces An END= specification in a WRITE d recor write or read to pt attem you If READ statement 1is ignored.er than the maximum specified for the using a record number great logical unit, an error condition occurs. describes system FORTRAN IV user's guide proce The appropriate PDP-11 can ssing. These to control error subroutines that you used use I1/0 system the from n matio infor n to obtai subroutines can also be occur red. that on the type of error Examples of I/O statements follow. READ (8,END=550) (MATRIX(K),K=1,100) control to statement 550 if an end-of-file This statement transfers al unit 8. condition occurs on logic WRITE (6,50,ERR=390) to statement 390 if an This statement transfers controlment. in execution of the WRITE state error occurs READ (l,FORM,ERR=150,END=200) ARRAY OcCCuUurs ol to statement 150 if an error This statement transfers contr if the 200 ment state to and ment state READ in the execution of the end-of-file condition occurs. 7.2.5 Input/Output Lists ment contains t, ENCODE, or DECODE state The I/0 list in an input, outpu which or to from nts eleme array and s, the names of variables, array 7-4 INPUT/OUTPUT which can An data also I/O will be contain list has transferred. constants the and STATEMENTS The I/0 list expressions following to in an be output. output statement form: s[,s]... A The simple list or an implied DO 1list. I/0 statement assigns values to, or elements in the order in which they list transfers values appear, from left 7.2.5.1 Simple Lists - A simple I/0 list variable, array, array element, constant, list consists of more simple I/0 parentheses. For WRITE When you ACCEPT a use an TYPE, in J, K(3), reads PRINT order varying most two-dimensional array: the name ARRAY, statement ARRAY (2,1), In a array READ or list in fill writes rapidly. commas an I/0 every all initial subscript by 1list, element the values element progression, For and enclosed in a or N name to the with no assigns example, subscripts, values ARRAY (3,1), ACCEPT statement, subscripts READ The can be a single expression. A simple I/0 element or a group of two or of in READ the array; the of the with the the following in a array. array and leftmost defines a ARRAY(3,3) that in array data statement of element or separated (L+4)/2, with subscript if 4, enough begins the I/0 example: or DIMENSION simple elements unsubscripted transfer proceeds a 1list (5,10) statement WRITE, Data either from, the to right. ARRAY later (1,1250) from in appears the (1,2), input and variables the list. so in For READ record(s) on the to through I1/0 list statement, ARRAY (1,1), ARRAY can (3,3). be used example: J,K,ARRAY (J,K) 1250 FORMAT (I1,X,I1,X,F6.2) input record contains the following values: 1,3,721.73 When to the J READ and values statement the for the An output 1/0 a An a before this example, function input executed, K, (to thereby Then that the the are left an output subprogram statement subscript I/0 expression I/0 expression 1list must an must I/0 input value be 721.73 used as use list the any any is actual is expression in array contain reference. an to way expression. I/0 must this subscripts valid further assigned subscript assigned subscripts as contain value the operations. not 1/0. not array first attempt performs list in the establishing their may not statement that to of) list. statement However, For Variables appear in is to ARRAY(J,K). ARRAY (1,3). must second expression, refer except to as INPUT/OUTPUT STATEMENTS element 7.2.5.2 Implied DO Lists - An implied DO list is an I/0 list a within t statemen I/O an of part a were it that functions as though Implied DO lists can be used to: DO loop. An e Specify iteration of part of an 1/0 list e Transfer e Transfer array elements in a sequence different from the order part of an array of subscript progression implied DO list has the form: (list,i=el,e2[,e3]) list list. An 1/0 An integer variable. el,e2,e3 Integer expressions. same forms and the same functions that they have in the DO statement (see Section 4.3). The list immediately preceding the DO loop parameter is the range of the implied DO loop. Elements in that list can reference i, The variable i and the parameters el, e2, and e3 have the but they must not alter the value of i. WRITE (A,B,C, (3,200) Some examples are: I=1,3) The statement in this example behaves as though you had written: WRITE Another is: example WRITE A,B,C,A,B,C,A,B,C, (3,200) (I,(J,P(I),Q(I,J),J=1,L),I=1,M) (6) The I/0 list in this example consists of an implied DO list containing The implied DO lists another implied DO 1list nested within it, the Js for varying fields, *M (1+3*L) of together will write a total each value of I. In a series of nested implied DO lists, the parentheses indicate the Execution of the innermost lists is nesting (see Section 4.3.2). repeated most often. 150 WRITE FORMAT For example: (6,150) (F10.2) ((FORM(K,L), L=1,10), K=1,10,2) Because the inner DO loop is executed 10 times for each iteration of the outer loop, the second subscript L advances from 1 through 10 for each increment of the first subscript. This is the reverse of the order of subscript progression. In addition, K is incremented by 2, so only the odd-numbered rows of the array are output. The entire control list READ In this This then The P(l), 1list DO For (Q(I,J), Q(1,1), (3,5555) Q(1l,2) that of the control WRITE (6,1111) This statement 7.3 SEQUENTIAL (I, simply variable can you vary can is read use a according external to prints the integers statements I/0 statements specifier, control 1In wusing statements translation formatted Both that contain that each 1 translation list-directed simple can both of through an of implied B0OX(1,10) the DO and array. directly. For 20, to the formatted is read sequential and I/0 translation. data I/0 logical unit. list-directed the correct statements or using format and records. of the I1/0 internal and external statements are a without wusing and list method FORMAT list-directed When you records, records 1I/0 read files you must ensure of binary format. transfer from internal formatted types between output to between transfer the data or records data sequential same with sequentially of sequential input formatted refer record Unformatted a the effect, statements. is combination to output transfer format elements without I/0 sequential of obtaining be records the Instead form, also «control form. List-directed I INPUT/OUTPUT sequential specifiers before I=1,20) Sequential I/O statements transfer either files or I/0 devices. Formatted the I=1,5) statément assigns input values to BOX(1,1) through terminates without affecting any other element of value before J=1,10) example: of transmitted eeesQ(1,10) arrays, subscripts (BOX(1,J), 1is example: J=1,10), multidimensional subscripts and For example: READ implied incremented. 2. processing fixed list, STATEMENTS (p(1), example, to an is (5,999) incremented When of variable INPUT/OUTPUT data READ ACCEPT 7.3.1 Formatted Sequential Input Statements The formatted sequential READ statement transfers data from specified logical unit. If a formatted sequential READ statement not have a logical unit number, it uses an implicit logical unit. the does INPUT/OUTPUT STATEMENTS The formatted sequential ACCEPT statement is similar to a formatted sequential READ statement except that an implicit logical unit number is always used. Formatted sequential input statements have the following forms: READ s]) [1list] (u,f[,END=s][,ERR= READ f{,list] f[,list] ACCEPT u A logical A format number. unit £ specifier. s label The an of executable statement. list An I/0 list. A statement of the following form system-defined 200, READ logical data causes be to read from a ALPHA,BETA,GAMMA transferred Characters unit: formatted by statements sequential are form specified by the format specifier. internal translated to the The resulting values are assigned to the elements of the I/0 list. If the number of list elements is less than the number of input record fields, the excess portion of the record is ignored. Usually a single formatted record is transferred by the execution of a However, the format specifier input statement. formatted sequential can specify that more than one record is to be read during execution of a single statement. input If the FORMAT statement associated with a formatted statement input contains a Hollerith constant, input data is read and stored directly See Section into the storage location of the format specification. 8.]—.9. only occurs transfer data If no I/0 list is present, record and the storage location of the format specifier. READ (5,100) FORMAT 100 (15H DATA GOES HERE) These statements read 15 characters from the next unit 5. If REVIEW The FORMAT 100 15 the characters the between For example: are: record on SECTIONS statement becomes: (1l5HREVIEW FORMAT SECTIONS) Other examples of formatted sequential input statements follow: READ 300 (1,300) FORMAT ARRAY (20F8.2) logical INPUT/OUTPUT These to statements read a record ARRAY. READ 100 100, from logical unit 1 and assign fields ICOUNT,ALPHA,BETA FORMAT (I5, F8.2, These statements read assign a fields to STATEMENTS F5.,1) record integer from variable BETA. an implicit ICOUNT and 1logical real wunit, variables ALPHA and and WRITE TYPE PRINT 7.3.2 Formatted Sequential The formatted sequential specified logical unit. The formatted formatted to an The sequential sequential implicit logical formatted WRITE TYPE Output Statements WRITE statement TYPE WRITE and PRINT statement, unit. sequential output transfers statements except statements are that have the data similar output is following to the to the directed forms: (u,f[,ERR=s])[list] f[,list] PRINT f[,list] u A logical A format unit number. £ specifier. s The label of an executable statement. list An I/O0 list, The I/0 list specifies a sequence of values that are converted to characters and positioned as specified by the format specifier. 1If no I/0 list is present, data transfer occurs only between the storage location of the format specifier and the record. The data transferred by normally constitutes one specify a single Numeric that additional output data conversion records under external calculations, 1loss unformatted of are format format. precision, use formatted formatted statement. output to a precision output. If sequential record. to be written control such may data output However, is is result. statement the during format can execution of during the rounded input for To avoid additional loss of INPUT/OUTPUT STATEMENTS not exceed The records transmitted by a formatted WRITE statement must , a line example For accept. can device ed the length that the specifi characters. printer typically cannot print a record longer than 132 Examples of formatted sequential output statements follow. WRITE FORMAT 650 (6, (' 650) HELLO THERE') the These statements write alphanumeric FORMAT statement to logical unit 6. literal in the fields, to contained WRITE (1,95) AYE,BEE,CEE FORMAT (3F8.5) 95 These statements write one record, unit logical WRITE (1,950) FORMAT (F8.5) 950 consisting of three 1. AYE,BEE,CEE These statements write three separate records, consisting of one field each, to logical unit 1. In the last example, the rightmost parenthesis of the FORMAT statement is reached before all elements of the I/O list are output. Each time 1is this occurs, the current record is terminated and a new record more a For written. are records separate Thus, three initiated. complete explanation, see Section 8.7. READ ACCEPT List-Directed Input Statements 7.3.3 d The list-directed READ statement transfers records from the specifie and form, internal to external from data the logical unit, translates assigns the resulting values to the elements of the 1/0 1list in the order in which those elements appear, from left to right. The 1/0 list is required. 1I1f a list-directed READ statement does not 1include a logical wunit number, an implicit logical unit number is used. The list-directed ACCEPT statement is similar to a 1list-directed READ statement except that an implicit logical unit number is always used. The list-directed input statements have the following forms: READ (u,*[,END=s][,ERR=s]) READ *,list ACCEPT A list *,list logical unit number. Indicates list-directed formatting. INPUT/OUTPUT The label of an executable STATEMENTS Sstatement. list An The I/0 list, external record separators. The A constant ® A null ® A repetition of constants ® A repetition of null input A constants before and has constant after F or do not permitted. constant for A If arithmetic null value value represent 1is The form r*c permitted except A value ®¢ One ® A comma, ®¢ A slash The slash value and record; Each input exhausted or I/0 before is The end a Spaces at of (see FORTRAN the value a by of (see real Section or integer parentheses. the between the constant octal element Spaces first constant, second constant is either constants and its T two between to the list element part of a commas the t not corresponding according consecutive occur or are rules 3-1). either complex pair and performed can for constant a in and list is r* with commas. remains complex A no null unchanged. constant, but constant. of is ¢ a c as of a where r constant. specified null is a nonzero, Spaces are not is an above. value where r be: spaces with or will all 1If the ignored. is beginning tabs surrounding terminates remaining list. or without separator record and corresponding used of logical Table Spaces the can statement record of A r occurrences <constant and ¢ within the constant more all the and values. form comma, r occurrences constant. separator the values r*c form enclosed indicates integer satisfy types specified be a indicates integer r* of parenthesis conversion entire unsigned The form unsigned the form the Hollerith data that an of has opening assignment cannot can form separating constant. in these comma-and (false). the values parenthesis. the specifies null a match, value intervening A £ the the the closing or by in describe constant between and (true) paragraphs separated the sequence value complex occur a be: A 2.3). can contain can ® following Each must value I/0 list read one slash values in equivalent of a processing elements or a more separator a to record spaces record a are space are on or tabs the input records as required or the I/0 list used, the remainder occurs are character. ignored. statement unchanged. to is of INPUT/OUTPUT STATEMENTS follows. An example includes: The program unit PRECISION T DOUBLE COMPLEX LOGICAL READ D,E L,M (1,*) I,R,D,E,L,M,J,K,S,T,A,B The external record contains: (3, 2 ) (3.4E0,4.2¢0), 4 6.3 , t,F,,3*14.6 / The following values are assigned to the I/O list elements: 1/0 List Value Element HnRIOEHO=H 4 A, B, 6.3 (3.4,4.2) (3.0,2.0) . TRUE. .FALSE. 14 14.6 14.6DO and J will be unchanged. WRITE TYPE PRINT 7.3.4 List-Directed Output Statements The list-directed WRITE statement transfers the elements in the 1/0 list to the specified logical unit, translating and editing each value according to the data type of the value. The list-directed TYPE and PRINT statements are similar to the list-directed WRITE statement, except that output is directed to an implicit logical unit. List-directed output statements have the following forms: WRITE TYPE PRINT (u,*[,ERR=s]) *,list *,list list INPUT/OUTPUT STATEMENTS u A logical unit number. * Indicates list-directed The of formatting. S label an executable statement. list An I/0 list. The values in the I/0 list are converted to character form and written a fixed format according to the data type of the value. Table 7-1 lists the output formats for each data type. The I/0 1list is required. in Table Data 7-1: List-Directed Type Output Output LOGICAL*1 Format L2 INTEGER*?2 I7 INTEGER*4 I12 REAL*4 1PG1l5.7 REAL*8 1PG25.16 COMPLEX*8 IX,'(',1PGl4.7, Hollerith 1X,An (n is ',"', the Hollerith List-directed output values, slash literals separators, in the Hollerith Each statements 1I/0 record statement or 1list Note may not produce forms are not be input output using begins with a space writes one or more of output 1list-directed 8.7). for Some examples PRINT TYPE a octal values, values. without delimiting that a single record. unit consists (see record, of: A(5) A/5*3.4/ WRITE (1,*) 'ARRAYAVALUESAFOLLOW' WRITE (1,*) A,5 the following records will be contain formatting. control. records a null Alphanumeric records carriage complete the follow: DIMENSION then of constant) *, 'THEAARRAYAZAIS',Z *,'THEAANSWERAIS', (I,XX(I),I=1,10) program DATA 1pGl4.7,")" length list-directed Each output value is contained within Hollerith constants that are longer than for If do repeated itself that constants output output ’ I5 LOGICAL*4 apostrophes. Formats output: ARRAYAVALUESAFOLLOW AAA3 . 400000AAAAAAAZ . 400000AAAAAAA3 . 400000AAAAAAAS . 400000 ANAASZ s 40000 0AAAAAAAAAND Each Section except INPUT/OUTPUT STATEMENTS READ Unformatted Sequential Input Statement 7.3.5 The unformatted sequential READ statement transfers one unformatted record from the specified logical unit, and assigns the untranslated fields of the record to the 1/0 list elements in the order in which The data type of each element from left to right. they appear, the amount of data input to the element. determines The unformatted sequential READ statement has the following form: [list] (u[,END=s][,ERR=s]) READ u logical A number. unit S of label The an executable statement. list an I/0 list. An unformatted sequential READ statement reads exactly one record, If the I/0 list does not use all the values in the record (that is, the there are more values in the record than elements in the list), list of number the If discarded. 1is record the of remainder values elements is greater than the number of error 1in ,the record, an occurs. I/0 list, The unformatted sequential READ statement must only be used to read no If an unformatted sequential READ statement contains one full record is skipped. records created by unformatted sequential WRITE statements. Examples of unformatted sequential READ (1) FIELDl, input statements follow. FIELD2 This statement reads one record from values to variables FIELD1l and READ FIELD2. logical wunit 1 and assigns (8) This statement advances logical unit 8 by one record. WRITE 7.3.6 Unformatted Sequential Output Statements the transfers statement WRITE sequential unformatted The untranslated values of the elements in the I/0 list to the specified logical unit as one unformatted record. The unformatted sequential WRITE statement has the following form: WRITE (ul,ERR=s])[list] INPUT/OUTPUT STATEMENTS u A logical unit number. ] The label of an executable statement. list An If an list. unformatted record Some I/0 is output examples WRITE This statement LIST to contains unit. no I/0 1list, one null outputs the unit 1. writes a contents of elements 1 through of array on logical unit 5 (4) statement 7.4 DIRECT ACCESS access I/0 to record statement contains 4. INPUT/OUTPUT and establishes null statements numbers, 9.1) statement specified (LIST(K),K=1,5) logical This Direct the follow. (1) WRITE WRITE to from a record the transfer direct records, access files. number. attributes of The the specified Each OPEN direct direct statement access by record access I/0 (Section file. Unformatted direct access I/0 statements transfer records of binary data without translation. The DEFINE FILE statement (Section 9.9) may be used to specify the attributes of the direct access file. READ 7.4.1 The Unformatted unformatted record from assigns the Direct Access direct access file currently the untranslated Input READ fields Statement statement connected of the to transfers the record the specified to the specified unit, and I/0 list following form: elements. The unformatted READ direct access (u'r[,ERR=s]) [list] READ statement u A logical unit number. r The record The label number. S of list An I/0 list. an executable statement. has the INPUT/OUTPUT STATEMENTS is, If the I/0 list does not use all the fields in the record (that there are more fields in the record than elements in the list), the 1list of number the If 1is discarded. record remainder of the the than greater is elements number of record fields, an error occurs. Examples of unformatted direct access (1'10) READ input statements LIST(1l),LIST(8) This statement reads record 10 of a file 2 assigns follow. on logical wunit integer values to specified elements of array LIST. READ (4'IREC) (RHO(N) ,N=1,5) This statement reads the record specified by the value of file on logical and 1, unit 4, and assigns 5 real values IREC of a to array RHO. WRITE Unformatted Direct Access Output Statement 7.4.2 the transfers statement WRITE access direct unformatted The untranslated values of the elements in the I/0 list to the specified record of the file currently connected to the specified unit. WRITE The unformatted direct access statement the has following Form: (u'r[,ERR=s]) WRITE [list] u A logical unit number. r The record number. S An executable An I/0 statement label. list list. the record, the into the record, an new to If the values specified by the I/0 list do not fill unused portion of the record is filled with zeroes. If the error I/0 list specifies more data than can fit occurs. You can use a WRITE statement either update an existing record. to write a record or Example: WRITE (2'35) (NUM(K),K=1,10) This statement outputs 10 connected to logical unit integer values to record 35 2. of the file INPUT/OUTPUT STATEMENTS ENCODE DECODE 7.5 ENCODE AND DECODE STATEMENTS The ENCODE and DECODE statements transfer data according to format specifiers, translating the data from internal to character form, and vice versa. however, these or in arrays The ENCODE Unlike data the and conventional transfers FORTRAN DECODE take formatted place 1I/0 statements, entirely between following forms: variables program. statements have the the ENCODE ENCODE (c,f,b[,ERR=s]) [list] DECODE (¢, f,b[,ERR=s]) [list] An integer number form. to 1In be A format The to DECODE a (bytes) to statement, to formatted specifier. ¢ internal statement, be is translated the number form. It ¢ to of 1is the character characters corresponds to the specified, an record. TIf more than one record is occurs. name a the of In characters translated length error expression. of of an formatted characters array, array record. In after translation statement, it internal form, contains The an executable (see Section label of element the to the or ENCODE variable. b statement, external form. characters to b corresponds receives In be the the DECODE translated to statement. list An I/O0 I/0 In list 1list the contains DECODE translation "and to a WRITE elements to stores the transmitted, 7.2.6). data statement, to Similar list the internal to the characters in remaining the ENCODE translated 1list statement, to receives character the the form. data after form. statement, the character form the 1In be b. ENCODE statement translates the according to the format specifier, If fewer character than ¢ positions characters are filled are with spaces. Similar to a character format If b is an and array, stores its array number of or a The virtual characters the that in are processed buffer array element the data ENCODE depends example, element, since an INTEGER*2 array the maximum number of elements in array. data record process that on this elements prograssion. virtual The statement, the DECODE statement b to internal (binary) form in specifier, subscript a READ data type of the b elements must (see or b translates to according in the not be Section DECODE in can contain characters is in that the 1list. order the the the name of of 5.5). statement can statement. For 2 characters per twice the number of INPUT/OUTPUT STATEMENTS The interaction between the format specifier and the I/0 1list Section 8.7) for an ENCODE or DECODE statement is the same as for An a formatted example of I/0 statement. the DOUBLE ENCODE PRECISION INTEGER*2 DATA DECODE INBUF, statements follows. OUTBUF A,B,C,D INBUF/'12345678'/ DECODE 100 and (see that ENCODE FORMAT (8,100,INBUF) A,B,C,D (8,100,0UTBUF) D,C,B,A (412) - The DECODE statement translates the 8 characters in INBUF to integer form (specified by statement 100), and stores them in the integer variables A,B,C,D, A =12 B = 34 C = 56 D = 78 as follows: The ENCODE statement translates the values D,C,B,A to character and stores the characters in the variable OUTBUF, as follows: OUTBUF = '78563412' form CHAPTER FORMAT 8 STATEMENTS FORMAT statements are nonexecutable statements used with formatted I/0 statements, and with ENCODE and DECODE statements, to specify the editing and formatting of the data. If input is being performed or a DECODE statement is being executed, the format statement describes the format in which the input data is interpreted. If output 1is being performed or an ENCODE statement 1is being executed, the format statement describes the format in which the output data will be represented. Throughout this chapter a distinction is made between "external" and "internal" form. External form refers to the ASCII characters in a data field of a formatted record. Internal form refers to the binary representation of a data value. FORMAT q statements have the following FORMAT (glflslf2s2 ... £fnqgn) Zero more slash (/) record descriptor or or form: terminators. f A field a group of field descriptors enclosed in parentheses. s A field separator. The entire list of field terminators, including specification. The list descriptors, field separators, the parentheses, 1is called must be enclosed in parentheses. The field separators are comma and slash. terminator. Section 8.5 describes in field record format also a functions record of the separators. field descriptor has the following form: [rlclwl.d]] field descriptor code descriptor 1is to it is assumed to be be 1, (I1,0,F,E,D,G,L,A,H,X,T,P,Q,S, oOF repeated (X3 A the field you omit ¥, . The number of times (repeat count). If — A A slash is detail the and the FORMAT STATEMENTS W The external The number field width. d r, of w, characters The terms and 4 must be less and The r term is optional; descriptors. The invalid in others. The field must d descriptors -- Iw, e Logical -- Lw e Real, ® Character -- e Editing, and $, is @ 8.1 first control (n be equal is right of unsigned to however, 255; you required the decimal integer and r constants. and cannot use in field some point. w must it in be r, w, nonzero. some field descriptors and is Ow precision, and complex -- Fw.d, Ew.d, nH, '...', nX, or character Dw.d, Gw.d Aw Hollerith a number describes character the are: Integer double all or term e Section The d than to -- characters each field an output record See Section 8.3 in information. constant of descriptor in more nP, Q, detail. generally for TTMn, positions) contains carriage information. During data transfers, the format specification is scanned from 1left to right. The elements 1in the I/0 list are correlated one-for-one with the corresponding field descriptors. However, the editing and Hollerith constant field descriptors do not require an I/0 list element. Section 8.7 describes in detail the interaction between format You specifiers use an data. I, You double O, and or use precision, Section 8.8 You create can format the L field F, a and complex format of a E, the list. descriptor an summarizes instead I/0 D, or to process field integer descriptor to and 1logical process real, data. rules during FORMAT G for writing program FORMAT execution by Section 8.6 statement. statements. using a describes run-time run-time formats. 8.1 A FIELD field DESCRIPTORS descriptor several data an external descriptors the I in I field It has the Iw The detail. field, Field The each field. external 8.1.1 describes items; but the size and data item in following The field treat format the of a external data item medium is or of called sections describe each of the field descriptors ignore leading spaces in embedded and trailing spaces as zeroes. Descriptor descriptor following specifies form: transfer of decimal integer values. FORMAT The corresponding I/0 logical data type. Rules in @ Effect The I the value, The a the e If the minus e If data of the first sign, the of specifies that w field, interpreted assigned to must first be an or data integer exponent value either integer or is the of character the I/O the element. it maximum element, the as is list constant; exceeds treated field, characters are read as a decimal integer cannot field. list character field nonblank in corresponding corresponding nonblank the the point external appears be Input: decimal magnitude must descriptor external If element external and contain e Data field from ® for list STATEMENTS a a an external negative occurs. field 1is a value. plus sign, 1is treated field allowed error or if as no a sign positive value. @ Input An all-blank field is treated as a value of 0. Example: Format Rules Internal Value 2788 2788 I3 -26 -26 I9 ANANNAN3 L2 I4 2 Effect The I for Data field external If the 2008 Output: I/0 field value 312 8 descriptor corresponding ¢ Field 14 in @ External w specifies 1list characters does not output element, fill long, the of the right as a value of Jjustified, the to an decimal integer. field, 1leading spaces are inserted. e If the filled e If the have ® Output value exceeds with asterisks. value a of minus the the list sign as term w must therefore sign, when necessary. Plus signs are be field width, element its is entire negative, leftmost, large the enough nonblank to the field field character. provide for a suppressed. Example: Format Internal Value External Representation 13 284 284 14 -284 -284 I5 174 12 3244 I3 17 174 *x -473 29,812 * k% Not permitted: error is will The minus FORMAT 8.1.2 O Field The O has the field STATEMENTS Descriptor descriptor following specifies transfer of octal integer values. It of either integer or form: Ow The corresponding I/0 logical data type. Rules in @ Effect The O for list Data field element must be Input: descriptor specifies that w characters are read value, and through 7; from the external field, interpreted as an octal assigned to the corresponding I/0 list element, ®¢ The external it cannot field. @ ¢ An all-blank field If the of the Input field can contain value is the corresponding contain a only sign, a treated as external list numerals 0 decimal point, or a of data element, the value exceeds an error an exponent 0. the allowed size of occurs. Example: Format Rules 05 77777 31274 1623 06 15AAAAN 53248 03 974 Effect The O the ® e Internal Decimal Value Field 04 in ¢ External for Data field Not descriptor external field No are octal (2's If value the permitted: error Output: corresponding signs 32767 w specifies 1I/0 1list characters output; a complement) does not output of element, long, negative as an value the octal value right justified, octal integer. is transmitted to of an in its spaces are form. fill the field, leading inserted. e If the filled Output value exceeds with asterisks. the field width, the entire field Example: Format Internal (Decimal) 06 32767 06 -32767 02 04 14261 05 Value External (octal) Representation ATTT777 100001 * * 27 13.52 AA33 Not permitted: error 1is FORMAT 8.1.3 F Field STATEMENTS Descriptor The F field descriptor specifies the precision values. It has the following transfer form: of real or double Fw.d The corresponding I/0 list precision data type; or part of Rules a in complex Effect @ The F data for field from the precision element it must type. Data must be of either be either the real real or double or the imaginary Input: descriptor external value, and specifies that w characters are field, interpreted as a real assigned to the corresponding read or double I/0 1list element. Any decimal point, signs, or exponent field present in the external field are included in the w count and d is part e If the of the w. w ' characters point 1is include used. If decimal point, the rightmost d digits of a decimal the decimal w. w point, the characters point 1is do placed position not of include before a the e If the w characters include an exponent field (see Section 2.3.2 for real constants and Section 2.3.3 for double precision constants), the exponent is used to evaluate the number's magnitude before the decimal point position is determined. @ If the first nonblank minus sign, the field e If the first appears in character of the external field is treated as a negative value. nonblank character is a the field, the field plus sign, or if 1is treated as a 1is a no sign positive value. e An e w must Input all-blank be field greater is treated than or as equal a value to d+1l. of 0. Examples: Format Rules External Field Internal F8.5 F8.5 -1234.567 ~-1234,56 F8.5 24,77E+2 2477.0 F5.2 1234567.89 in Effect 123456789 Value for Data 123.45678 123.45 Output: ¢ The F field descriptor transfers the value of the corresponding I/0 list element, rounded to d decimal positions and right justified, to an external field w characters 1long. ¢ If the value inserted. @ If the filled does not fill value exceeds the with asterisks. the field field, width, leading the entire spaces field are is FORMAT @ Plus signs ¢ w must width are suppressed. be greater should be after the point, digits to the negative Output STATEMENTS than or equal to d+l; however, the field large enough to contain the number of digits plus 1left 1 for the of the point, point, plus plus 1 the for number of a possible sign. Examples:: Format Internal Value F8.5 External 2.3547188 F9.3 8789.7361 F2.1 51.44 Representation N2.35472 N8789.736 * % F10.4 -23.24352 AN-23.2435 F5.2 325.013 *hk kK F5.2 -.2 -0.20 8.1.4 E Field Descriptor The E field descriptor specifies transfer of real values in exponential form. It has the following or double form: precision Ew.d The corresponding I/0 list data type; or complex data type. precision part of Rules a in Effect On input, the descriptor. Input E for element must it be must be of either either the real real or the or double imaginary Input: field descriptor does not differ from the F field Examples: Format External 734.432E3 AN1022,43E-6 0.102243E-2 E15.3 E12.5 52.3759663 AAAAA 210.5271D+10 0.523759E+2 0.2105271E+13 precision. Rules in Effect for If are If right the 0.734432E+6 that as the an E E field indicator descriptor if the I/0 treats the list element D is Output: The E field corresponding and e Value E12.4 single e Internal E9.3 In the last example, note exponent field indicator e Field descriptor I/0 justified, value does transfers the element, rounded to 1list to not an fill external the w field w value of the d decimal digits characters characters, leading 1long. spaces inserted. the filled value exceeds with asterisks. the w characters, the entire field 1is FORMAT ® Output is in a standard STATEMENTS form: that is, value is negative, an optional 0, a the right of the decimal point, and one of the following two a minus sign if the decimal point, 4 digits a 4-character exponent to in forms: E+nn E-nn nn A ® Plus ® w 2-digit signs must be width integer are suppressed. greater must constant. not than be or stated after the point, plus the point, plus one the Output Internal for a for the d+7; that 1is, the field the number of digits than point, plus 1 negative for possible the 0 before plus 4 for sign, Value External Representation E9.2 475867.222 N0 .48E+06 E12.5 475867.222 A0,47587E+06 0.00069 E10.3 E5.3 D less be Examples: E12.3 The to to exponent. Format 8.1.5 1 equal D Field field AAND L 690E-03 -0.5555 56.12 -0.556E+00 kkkkk Descriptor descriptor specifies transfer form a values in exponential following form: with D of real or double instead of an precision E. It real or has the Dw.d The corresponding precision part of a Rules in Effect On input, the descriptors. Input I/0 data type; complex data D for list element or it type. must must be be of either either the real or the differ from the F double imaginary Input: field descriptor does not or E field Examples: Format External Field Internal Value D10.2 12345AA00A 0.1234500000D+8 D10.2 AA123.45AN 0.1234500000D+3 D15.3 367.4981763D-04 0.3674981763D-1 Rules in Effect for Input: There is only one difference output: If of the letter you E. use the D between descriptor, the the D and letter E D descriptors is output on instead FORMAT Output STATEMENTS Examples: Format Internal Value D14.3 D23.12 5413.87625793 0.0363 D9.6 8.1.6 External AAANAND «363D-01 AANAAND .541387625793D+04 1.2 G Field Value khkkkhkkxkhkkkk Descriptor The G field descriptor specifies transfer of real or double precision values, combining Eor F-type formats according to the size of the number being output. It has the following form: Gw.d The corresponding I/0 list precision data type; or part of Rules in a complex Effect On input, the descriptors. Rules in ¢ e G Effect data for element it must must be of either be either the real real oxr double or the imaginary type. Input: field for descriptor does not differ from the F, E, or D Output: The G field descriptor transfers the value of the corresponding I/0 list element, rounded to d decimal positions and right justified, to an external field w characters long. The form in magnitude Table which the the value, of 8-1: Data Effect Magnitude m value of as is written described is in Data Magnitude Effective a function Table on G of the 8-1. Formats Conversion < 0.1 Ew.d 0.1 <m¢<«<K 1,0 1.0 <m < 10.0 F(w-4).(d-1), 10d-2 < m < 104d-1 F(w=4).1, 'aAnnn! 10d-1 < m < 10d F(w=4).0, 'aAnnA!' m > 10d F(w=4).d, NOTE: The 'aAaaA' in the second column of four spaces are to follow the numeric data 'AAAA! 'anaa’ Ew.d Table 8-1 specifies representation. that FORMAT @ Plus e w must be greater than or equal width must not be stated to be after the point, plus 1 for the before the point, plus 1 for a for a possible exponent. Output signs are suppressed. to d+7; that 1is, the field less than the number of digits point, plus 1 for a possible 0 possible negative sign, plus 4 Examples: Format Internal G1l3.6 G1l3.6 G1l3.6 G13.6 Value External Representation 0.01234567 -0.12345678 1.23456789 12,.34567890 A0.123457E-01 -0.123457A00N AAY . 23457A0AN AAL2,3457 ALAAA Gl3.6 123.45678901 AN123,457 000N Gl3.6 -1234.56789012 AN=1234,.57A00N Gl3.6 12345.67890123 ANL12345.7AMAN Gl3.6 123456.78901234 AAL23457 .AAAAN Gl3.6 -1234567.89012345 -0.123457E+07 Compare the same values above examples output with an Format with the following equivalent F field Internal Value examples, which descriptor. External 0.01234567 F13.6 -0.12345678 ADAN-0.123457 F13.6 1.23456789 AANANL . 234568 12,34567890 ANANL2 345679 F13.6 123.45678901 AAN123.456789 F13.6 F13.6 F13.6 -1234.,56789012 12345,.67890123 123456.,78901234 A=-1234,567890 A12345.678901 123456.789012 F13.6 -1234567.89012345 L field following the ANAAND 012346 F13.6 L Field show Representation F13.6 8.1.7 The STATEMENTS . khkkkkkhhkhhxk Descriptor descriptor specifies transfer of logical data. It has the either integer or characters are form: Lw The corresponding logical Rules in data I/0 list element must Effect for of Input: ¢ The L field descriptor specifies from the external field. e If or the t, list be type. that w first nonblank character of the field the value .TRUE. 1is assigned to the read is the letter T corresponding I/0 element., e If the first nonblank character of the field or f, or if the entire field is blank, the assigned. e Any other value in the external field is the letter value .FALSE. produces an error. F 1is FORMAT Rules in ¢ Effect The (1f ® L for field descriptor specifies output the value of the corresponding .TRUE.), or field letter preceded Output Output: external The STATEMENTS the T by letter w or F w-1 F (if characters is in the of either the letter T I/0 1list element is value 1is .FALSE.) to an long. the rightmost position of the field, spaces. Examples: Format 8.1.8 The A the Value External Representation L5 . TRUE. ANANAAT L1l .FALSE, F A has Internal Field field Descriptor descriptor following specifies the transfer of Hollerith values. It type, data. since you characters from the corresponding I/0 list form: Aw The can corresponding use variables The value Rules in ¢ of w must Effect The I/0 list element of any data type be for A than or equal to 255. Input: field external less can be of any data to store Hollerith descriptor record and transfers assigns them to w the element. ® The maximum number the size the of I/0 of I/0 characters list List Maximum Element of 1 LOGICAL*1 1 LOGICAL*4 4 INTEGER*?2 2 INTEGER*4 4 REAL 4 REAL*S8 If w e If W w is is characters less characters and stored depends on Number 8 the stored excess be 8 greater than 1in the rightmost characters be can follows: 8 PRECISION COMPLEX e as Characters BYTE DOUBLE that element, trailing than are maximum number of characters 1I/0 list element, assigned to that element. <corresponding are are ignored. the number assigned spaces are of characters than to the list element, added to fill the can left element. be that can the Leftmost only stored, justified, FORMAT Input STATEMENTS Examples: Format External Field A6 A6 A6 A6 PAGEA# PAGEA# PAGEA# PAGEA# Rules in @ Effect for Internal Value # A# GEA# PAGEA#AA (LOGICAL*1) (INTEGER*2) (REAL) (DOUBLE PRECISION) Output: The A field descriptor specifies output of corresponding I/0 1list element to an characters e the contents of the external field w long. If w is greater than the size of the list element, the data appears in the field, right justified, with leading spaces. e If w is less than the size leftmost w characters are of the 1list transferred. element, only the Examples: Output Format Internal Value External Representation A5 A5 A5 OHMS VOLTSAAA AMPERES A AQHMS VOLTS AMPER H Field Descriptor 8.1.9 The H field descriptor specifies transfer of data between the external record and the storage location of the H field descriptor itself. It has the form of nHclc2c3 The a Hollerith ¢n ... number constant: of characters to be transferred. ci An ASCII in Rules e Effect for Input: The H field descriptor specifies acceptance of n characters from the external field and their assignment to the same storage location as the characters of the H descriptor, which are overlaid by the input data, character for character. in Rules character. @ Effect the H field descriptor TYPE 200 Output: The H field descriptor specifies output of the following the letter H to the external field. An example of 100 for FORMAT n characters usage follows. 100 (41HAENTERAPROGRAMATITLE,AUPATOA20ACHARACTERS) ACCEPT 200 FORMAT (20HATITLEAGOESAHEREAAA) FORMAT The TYPE statement descriptor statement data in in spaces an to words the the 50 A TITLE GOES remainder pair For FORMAT of to The H characters the the terminal. the keyboard, statement 200. HERE. 1If of the H field from user's placing The new the user enters field descriptor descriptor may also H field The ACCEPT the input characters 1less than 20 is filled with be specified as literal. alphanumeric apostrophes. the 100 response from descriptor in right. alphanumeric In an transfers statement accepts the the H field replace the characters, STATEMENTS 1literal, the apostrophe is written as two example: ('TODAY''SADATEAIS:A',I2,'/',12,'/',12) apostrophes wused 1in this way 1is considered a single character. 8.1.10 The the X Field Descriptor X field descriptor following form: specifies skipping character positions. It has nX The The term n value specifies how many character of n must be greater than equal to 255. Rules in Effect ¢ Rules The X the input in ¢ for field Effect The X field external WRITE 90 The WRITE where nn numeral NUMBER is 1 are specifies to be The T T descriptor For field the next n character in specifies output of n spaces to the example: NPAGE ‘ (13H1PAGEANUMBERA,I2,16X,23HGRAPHICAANALYSIS,ACONT.) prints a record similar nn to: GRAPHIC the current value of 1in the first H field Field that skipped. ANALYSIS, CONT. the variable NPAGE. Note that descriptor is not printed but is to advance the printer paper to the top describes printer carriage control.) 8.1.11 be skipped. less than or Output: record. statement PAGE descriptor (6,90) FORMAT to and Input: record for positions are or equal to 1 of a new the used page. (Section 8.3 the character Descriptor descriptor be treated relative following form: specifies to the the start position of the of external next record. It has to the Tn The term character to 1 but record. n indicates to not be the treated. greater than position in The value the number the of n of external must be record greater characters of than allowed the next or equal 1in the FORMAT Rules in e Effect In an data For for STATEMENTS Input: input statement, the T field descriptor specifies that 1is to be input starting with the nth character position. example: 10 FORMAT (T7,A3,T1,A3) READ (5,10) J,K In the example, a 3-character string starting at character position 7 in the external record is read first, followed by a 3-character string starting at character position 1; however, any order can be specified. Rules in e ' Effect for Output: In an output statement, the T field descriptor specifies that the data 1is to be output starting at the nth character position of the external record. For example: PRINT 25 FORMAT 25 (T50,'COLUMNA2',T20,'COLUMNAL"') These statements will print position 50. The remainder 8.1.12 "COLUMN 1" at position 20 and COLUMN 2" of the line contains blank characters. at Q Field Descriptor The Q field descriptor specifies assignment to the corresponding variable in the 1I/0 1list of the number of characters in the input record remaining to be transferred during a READ operation. It has the following form: Q The corresponding I/0 list element must be of integer or logical data type. For example: 1000 READ (4,1000) XRAY,KK,NCHRS, (ICHR(I),I=1,NCHRS) FORMAT (El15.7,I4,Q,80Al) These input statements read two fields into the variables XRAY and KK. The number of characters remaining in the record is stored in NCHRS and exactly that many characters are read into the array ICHR. By placing the Q descriptor first in the format specification, you can determine the actual length of the input record. In an output statement, the Q field descriptor has that the corresponding I/0 list element is skipped. 8.1.13 Dollar no effect except Sign Descriptor The dollar sign character ($) used as a field descriptor suppresses, on output, a carriage return at the end of the line when the first character of the line is a space or a plus sign (see Section 8.3 on carriage control characters). In an input statement, the $§ descriptor FORMAT is ignored. 1/0; The § descriptor it (rather leaves the than returning will follow Thus, the the 200 produce is intended terminal it to the output on the primarily for interactive print position at the end of left margin) so that a typed same the text response line. statements TYPE 100 STATEMENTS 100 FORMAT ('AENTERARADIUSAVALUEA',S) ACCEPT 200,X FORMAT (F6.2) a message on the terminal in the following form: ENTERARADIUSAVALUE Your response (in this case, 12.) can then go follows: on the same 1line, as ENTERARADIUSAVALUEALZ2, Note that same result. used as a carriage following two (11HASIGNAHERE:,S) 200 FORMAT (l1ll1HS$SSIGNAHERE:) Colon colon list accomplishes the equivalent: more (:) used as a items are in the remain. For PRINT 100,3 PRINT 200,4 field descriptor I/0 list. The terminates : has no format effect if example: FORMAT ('AlI=',I2, 'AJ=',I2) FORMAT ('AK=',I2,:,'AL=',12) 200 These no items 100 character are Descriptor character if control formats FORMAT control I/0 $ The 200 8.1.14 The the statements print the following two lines: in detail. I=A3AJ= K=n4 Section 8.7 8.1.15 Complex A complex or describes value output Data is of descriptors, format Editing an a ordered complex using control any pair value combination of 1is of real values. governed the forms Gw.d. Rules in ® Effect In an for input assigned imaginary to Therefore, by Fw.d, two real Ew.d, input field Dw.d, or Input: statement, a parts, the complex two I/0 respectively. successive 1list fields element as are 1its read real and and FORMAT Input STATEMENTS Examples: Format External Field Internal Value F8.5,F8.5 1234567812345.67 123.45678, 12345.67 E9.1,F9.3 734,432E8123456789 734.432E8, 123456.789 Rules in Effect e In an for Output: output statement, transferred descriptors. e under The two parts punctuation or the the two control parts of of a repeated complex or value successive are field are transferred consecutively, without spacing, unless the format specifier states otherwise. Output Examples: Format Internal Value 2F8.5 E9.2,'A,A",E5.3 3.456732 56.123 Representation A2,35472 3.45673 AQ.48E+06AL ,A***x*k Scale Factor 8.1.16 A scale factor the location complex The 2.3547188, 47587.,222, External is of a value used in a format the decimal point in specifier which determines real, double precision, or values. scale factor has the form: nP A signed +127. or It that the in Effect Rules unsigned specifies decimal for point both e If you do applies. not e The factor scale integer the is Input use a is constant number to and scale set to of in the positions range -127 to left the through or right move. Output: factor, 0P a default at the scale start factor of every of OP 1/0 statement. e A scale factor applies to all subsequent descriptors, until a new scale factor is @ The scale factor can appear as a F, E, D, or specified. field G field descriptor. For example: 10 In the not to FORMAT (X, example, the E6.3 14, E6.3, the 3P or the 3P, 2A3, 212, 2F5.3, applies to the 2F5.3 and X, I, or A descriptors. E8.5) the E8.5 but FORMAT A scale field 10 In factor FORMAT For this (X, factor Rules in external no effect. If the external toan 2F5.3 E3.2, 2PE4.2, of example, .01, moving has and no F, E, to E8.5. effect two F4.2, records scale factor D, or G on the scale 3PE4.2) are read, reinstated an field does contain 2P the not of corresponding scale factor decimal multiplies two by exponent, multiplication to only an record, explicit 0P Input: contains the point be reversion second format. field it a can for specifies assignment Input OP the Effect the decimal to 8.7) suppose of If For both Section F3.2, in has factor prefix to the start of the format. 1In the scale factor 3P now applies to F3.2. specification Additional a E8.5) applies (see example, scale as example: example: FORMAT occurring the active A 3P reversion factor. For (3P2F5.3, example, Format In appear descriptor. the 10 can STATEMENTS an places two input to the scale an exponent, the data I/0 list multiplies point the an places value the by by scale 10**-n and element. input to factor the 100, value left. A moving by -2P the right. Examples: Format External Field Internal 3PE10.5 AAN3T . 614N 3PE10.5 AN3T7 ,614E2 -3PE10.5 3761.4 AAAN3T 614 37614.0 Additional Rules Scale Effect factors I/0 list For the is in apply variables F field multiplied Thus, a right; for .037614 Output: only do to not data output. descriptor, the value of 10**n before transfer positive scale factor moves negative E or scale The values factor the to the I/0 the list For the the is subtracted value factor moves exponent; the left a and D field (see the decimal point moves the decimal descriptor, the basic real Section 2,3.2) from the exponent. the decimal point is to multiplied Thus, the negative scale factor increases the exponent. right moves the a element external left. of of change. by a Value record. to point the to constant by 10**n, positive and part and n scale decreases decimal the point the to FORMAT STATEMENTS ®¢ A scale factor magnitude range has of of no the the effect data to descriptor, the scale data value factor has 1is a be output field descriptor is within the G the field 1if the effective descriptor function. Moreover, the G field field descriptor if the magnitude outside the G because supplies 1its own scaling descriptor functions as an E of on same its range. effect as 1In for this case, the E field the X) to descriptor. Output Examples: Format Internal Value External 1PE12.3 -270.139 AAN=-2,.701E+02 1PE12.2 -270.139 AAA=-2,70E+02 -1PE12.2 -270.139 AAN=-0.03E+04 8.1.17 Repeat You apply can number of Counts most and field successive Group Repeat descriptors data fields Counts (except by an unsigned nonzero integer constant repetitions. This constant 1is called a following two statements are H, T, preceding with the Representation P, that the number of count. For example, repeat equivalent: FORMAT (El12.4,El12.4,E12.4,15,15,15,15) 20 FORMAT (3E12.4,415) Similarly, you can apply a group of field descriptors data fields by enclosing these field descriptors in them with an unsigned nonzero constant 1is called a group repeat two statements are equivalent: H For repeatedly parentheses constant. example, 50 FORMAT (218,3(F8.3,E15.7)) 50 FORMAT (18,I8,€8.3,E15.7,€8.3,E15.3,€8.3,E15.Z) or X field be enclosed specification. If integer count. 1 An you do not descriptor, 2 which in parentheses Thus, it could be specify a group a descriptor specifying 20 preceding or field integer following 3 could not otherwise and treated as repeated a desired repeat The the to and count, a default be repeated, a group number of count can repeat times. of 1 is assumed. 8.1.18 Default Field Descriptors If you write the field descriptors I, O, L, F, E, D, G, or A specifying a w or w.d, default values are supplied based on type of the I/0 list element. Note that for F, E, D, and G, not specify only w or d; you must specify w.d or nothing. Table 8-2 lists the default values for w and 4. without the data you may FORMAT Table Field 8-2: STATEMENTS Default Descriptor List Element Data the 8.2 w d Type I, O INTEGER*2 7 I, L O INTEGER*4 LOGICAL 2 F, E, G, D REAL, 15 7 F, E, G, D DOUBLE 25 16 A Notice Field Widths 12 COMPLEX PRECISION LOGICAL*1 or BYTE 1 A INTEGER*?2 A LOGICAL*4, INTEGER*4 4 A REAL, 4 A DOUBLE that for the corresponding CARRIAGE A field 1/0 CONTROL list COMPLEX PRECISION descriptor the 8 default is the 1length of element. CHARACTERS The first character of every record transferred to a printer 1is not printed. Instead, it is interpreted as a carriage control character. The FORTRAN I/0 system recognizes certain characters as carriage control characters. Table 8-3 1lists these characters and their effects. Table 8-3: Carriage Control Character Characters Effect A (space) Advances one line 0 (zero) Advances two lines 1 (one) Advances to + (plus) Does advance $ (dollar sign) not Advances suppresses top of next (allows one line carriage page overprinting) before return at printing the end of and the record Any character other than those space and 1is deleted from accidentally omit the carriage of 8.3 the record FORMAT is not printed. SPECIFICATION Field descriptors commas. You can listed in Table 8-3 1is treated as a the print line. Note that 1if you control character, the first character in a also SEPARATORS format specification are use the slash (/) record generally separated by terminator to separate FORMAT field descriptors. record and WRITE 40 This statement 50 You (6,40) (306) WRITE (6,50) multiple However, result n parentheses initiator The at the are the or (blank line) (blank (blank line) line) top w the external statement external This with is record, called the are 1, 0, READ 100 The above the or end (n-1l) of a because format field records record; record, the are For blank current blank output two and the so on. specification opening and closing a record themselves example: following output: LINE LINE such as Fw.d specifies that from the external record. contains read unless 1less characters you than from padded the an w statement Iis If data in the characters, the short input next field data with field the field leading input in the zeroes the field descriptor is numeric, you can avoid having field by using a comma to terminate the field. The the field descriptor's field width specification. short field termination, entering data F, G, E, D, (5,100) FORMAT the SEPARATORS record would you or records or to page characters or spaces. When to pad the input comma overrides when skipped respectively. produce of FIELD descriptor read input or between ('1l',T51,'HEADINGALINE'//T51,"'SUBHEADINGALINE'//) 50, field current (6,99) Column to on specification SUBHEADING A records appear terminates beginning blank terminator, input slashes skipped first format statements EXTERNAL bypass slash the HEADING 8.4 to consecutive first of FORMAT above n skipped WRITE 99 the to: slashes n and of N,O,P terminates slashes 1in output K,L,M records The slash or example: K,L,M,N,O0,P If (n-1l) output. input For (16,2F8.4) records. second terminates record. equivalent FORMAT descriptors, are is WRITE use new (306/16,2F8.4) FORMAT can blank slash a (6,40) FORMAT 40 A initiates STATEMENTS from and L a and terminal field is descriptors. I1,J,A,B (216,2F10.2) statements read the following particularly keyboard. record: For You can useful use example: it FORMAT On execution, I =1 J = the following STATEMENTS assignments occur: =2 A= 1.0 B 0.35 = The physical end of the record Note that the 4 part of a w.d external field separator. explicit decimal point in the also serves as a field terminator. specification is not affected by an Therefore, you should always include an external field for F, E, D and G field descriptions. You can use a long. If a is considered comma to terminate only fields less than w characters comma follows a field of w characters or more, the comma part of the next field. Two successive commas, or a comma after a field of exactly w characters, constitutes a null (zero-length) field. Depending on the field descriptor specified, the resulting value assigned is 0, 0.0, or 0.DO, or .FALSE.. You cannot use a comma to terminate a field that is controlled by an A, H, or alphanumeric 1literal field descriptor. However, if the record reaches its physical end before w characters are read, short field termination occurs; and the characters that were input are assigned successfully. Trailing spaces are appended to fill the corresponding I/0 list element or the field descriptor. 8.5 RUN-TIME FORMATS A run-time format 1is a format stored as Hollerith or alphanumeric data in an array. In the I/0 statement referencing the format, you write the name of the array instead of a format statement label (see Section 7.2.2). Virtual arrays must not be used for this purpose. A run-time without closing format in the word parentheses an array has the FORMAT and the are required. same form statement as a label. FORMAT statement, The opening and Run-time formats are especially useful when you do not know exactly which field descriptors will be required until execution time. To solve this problem, you can write a program to create a format, the choice of field descriptors being made to depend on the attributes of the data. For example: REAL TABLE (10,5) REAL FMT(1l1l),FBIG,FMED, FSML DATA FMT(1)/'('/,EMT(1ll)/')'/ DATA FBIG,FMED,FSML/'F8.2','F9.4','F9.6"'/ DATA FMT (3),FMT(5) ,FMT(7) ,FMT(9) /4*',"'/ DO 20 I=1,10 DO 18 J=1,5 FMT (2*J) =FMED IF IF (TABLE(I,J).GE.100) (TABLE(I,J).LE.0.l1) 18 CONTINUE WRITE (6,FMT) 20 CONTINUE END FMT(2*J)=FBIG FMT(2*J)=FSMAL (TABLE(I,J),J=1,5)" FORMAT In the example, magnitudes known until the real the data array is FMT. A stored in odd-numbered elements stored real the descriptors depend on to the be left of Each time an the format FMT CONTROL control During format begins by field the format when repeat If I/0 statement I, O, else an error On F, records a counts of are G, L, an A, I/O be and read input initiates as indicated 1is record read. On execution, a specified wunit is F, E, D, element in the G, L, I/O0 alphanumeric A, and literal field descriptors, external record and In format control, element. is 1If the the reached, to last executed, storage the H At field the end LISTS list 1I/0 statement. on information (if one exists) specification. from left The to you must specify descriptor in reads record one when is an found, closing format one control. the I/0 right, at the Thereafter, format and in I/0 the Q field No list field data storage encountered, translated Dbetween is not found, format When to output a format. least format, or from the additional specification. a list elements current Format slash occurs in parenthesis of record if a slash appears closing parenthesis is transferred, list. literal descriptor made remain are 1, descriptors element location O, ¥, the I/0 data is E, list parenthesis determines the D, is of and the whether the H L, and, list I/0 to an H, to X, alphanumeric between the specification. A, for format more and format G, to the also be correspond directly checked transferred the external record control terminates. control of each 1In occurs be in the format reached and mote corresponds descriptor. transfer to the the discarded formatted output statement transmits a record as format control terminates. Records can written during format «control specification or if the last I/0 list elements remain to be or I/0 is of depends be input when 1last closing reached new T, list, field by when P, the is the label. formatted format statement characters O, Q a new record or when the specification 1, the correlated format remaining The are or Any one of the FMT is field specified. filled. the use right of assigned INPUT/OUTPUT element contains D, control requires that format specification, format next through a of be in other descriptors format and a in choice statement taken (1), Finally, run-time of FMT field The holding lost. action descriptor formatted wunit can WITH execution the The occurs. execution, specified E, location specification except the with TABLE. stored elements format in the array data will be control, next one that of TABLE. a in are FSML. recompiled) INTERACTION jointly the a (or Format and of referencing 1is not stored statement, the list in statement descriptor of the I/0 the data array stored even-~-numbered the compiled into is selection I/0 read real commas FMED, 1is Data and A instead location. FORMAT and FBIG, to of the the elements of TABLE will not format specification is stored parenthesis FMT. assigned magnitude references provided in FMT(l11l), variables statement 8.6 stored of the data stored in just before output. The parenthesis in is STATEMENTS or Q field a corresponding 1if appropriate, element. If specification list elements one is are be processed. 1If not, format control terminates. However, if additional list elements remain, part or all of the format specification is reused in a process called format reversion. FORMAT Format reversion starting of a from point. is new STATEMENTS the termination of one. Format reversion are: the control current reverts to record and the group the repeat specification whose 1left parenthesis is complemented by the next-to-last right parenthesis of the format specification. If the format does not contain a group repeat specification, format control returns to the beginning of the format specification and continues that Examples of format READ 100 (I,l100) FORMAT A, (F8.3, B, C, D, E, F F8.3) In this example, three records containing first record assigns values to A and B; the third to E and DIMENSION (6,10)X,(I,B(I),(A(I,J),J=1,5),I=1,5) FORMAT SUMMARY The and F. (E10.3/(I5,E10.3, In this example, specification that 8.7 are read. to C and D; A(5,5),B(5) WRITE 10 two fields the second OF 5(F8.5))) format reversion begins with I5. RULES FOR FORMAT returns to the group repeat STATEMENTS The following sections summarize the rules for constructing and wusing the format specifications and their components, and for constructing external fields and records. Table 8-4 summarizes the FORMAT codes. 8.7.1 General l. 2. A Rules FORMAT In a n must omit statement field be the must descriptor unsigned repeat always such integer count and as be rIw labeled. or constants field nX, the greater width terms than ¥, 0. w, and You can specification. 3. In a field descriptor such as Fw.d, the term d must Dbe an unsigned integer constant. If w is specified, then you must specify 4 in F, E, D, and G field descriptors even if it |is 0; and the field width specification (w) must be greater than or equal to d. The decimal point is also required. You must either specify both w and d, or omit them both. 4. In a field descriptor such as nHclc2 characters must follow the H format printing ASCII character in this field 5. In a scale factor of the form nP, n ... cn, exactly n code. You can use any descriptor. must be a signed or unsigned integer <constant 1in the range -127 through 127 inclusive. The scale factor affects the F, E, D, and G field descriptors only. Once you specify a scale factor, it applies to all subsequent F, E, D, and G field descriptors in that format specification until another scale factor appears. You must explicitly specify OP to reinstate a scale factor of zero. Format reversion does not affect the scale factor. FORMAT STATEMENTS No repeat count is permitted for H, X, T, literal field descriptors unless these enclosed 1in parentheses and treated as specification. If the associated format descriptor A format same as Input l. statement other than contains the and I/0 1list, contain at X, T, alphanumeric H,;, opening the an must P, or an specification in an array must a format specification in including FORMAT 8.7.2 I/0 specification or alphanumeric descriptors are a group repeat and statement c¢losing label 1least be a one are literal. constructed the statement, FORMAT parentheses. only the field The word permitted. Rules A minus sign must input field; a precede a negative value plus sign 1is optional 1in an before a external positive value. On input, must be an external an 1integer field under I <constant. field It descriptor cannot contain point or an exponent. An external field wunder descriptor control must contain only the numerals 0 and must not contain a sign, a decimal point, or an On input, an descriptor double and/or If an size that external control field must under be an precision constant. It can an E or D exponent field. external field contains a real or double E, D, contain the d precision a the The conversion field of width that G a field real decimal point, the or point actual field, as indicated by specification of the field descriptor. If an external field contains an exponent, the (if any) of the corresponding field descriptor on or decimal O field through 7 exponent. or constant decimal of the fractional part of decimal point, overrides the corresponding F, integer control a scale has no factor effect field. specification must be large enough to accommodate both the numeric character string of the external field and any other characters that are allowed (algebraic sign, decimal A comma field are is Output l. A and/or only character the separator. shorter designates 8.7.3 point, than null It the exponent). you terminates number of (zero-length) can input use of characters as numeric an external fields expected. It that also fields. Rules format specification cannot specify than the external record can printer record cannot contain including the carriage control more output characters contain. For example, a line more than 133 characters, character. FORMAT 2. STATEMENTS The field width specification (w) must be large enough to accommodate all characters that the data transfer can generate, including an algebraic sign, decimal point, and exponent. For example, the field width specification in an E field descriptor should be 1large enough to contain d+7 characters. 3. The first character of a record output to a line printer or terminal is wused for carriage control; it is not printed. The first character of such a record should be a space, 0, 1, $, or +, Any other character is treated as a space and is deleted from the Table Code record. 8-4: Summary of Form FORMAT Codes Effect I Iw Specifies transfer of decimal 0 Oow Specifies transfer of octal F Fw.d Specifies transfer of values basic E D Ew.d Dw.d Gw.d L Lw or transfer exponential form. transfer real in Specifies values a 1in D of instead real of double precision or double precision or double precision precision of an of real Specifies transfer of logical or input, acts like E code or T, t, F, exponential form E. transfer on acts values. double Specifies values: output, T Aw real integer values. form. values transfers A real Specifies with G in integer or f£; or double precision 1like F F code. code; data: on on on input, output, transfers F. Specifies transfer of alphanumeric or Hollerith transfer of alphanumeric or Hollerith values. H nHc...cC Specifies values format X nX between an external storage location. Specifies that n characters (on input) or that transmitted (on output). T Tn Specifies of Q Q S the next Specifies be S the the transferred Suppresses position, character number in an carriage of are n to spaces in to record the be be are external and the skipped to Dbe recotd, processed. characters input record. return during remaining to interactive 1/0. : : Terminates exhausted. format control if the I/0 1list is CHAPTER AUXILIARY INPUT/OUTPUT The auxiliary input/output functions., These statements ® OPEN -- file or and e e -- file terminates or REWIND, STATEMENTS statements perform file a connection the between the a logical FIND -- writes condition the e (and read between logical unit and a -- perform file-positioning DEFINE Section these special record transfer) that when causes an an input end-of-file statement record. FILE -- unformatted, See a END= 7.2 for associates direct a a access definition a for connection and and required device. BACKSPACE, ENDFILE unit attributes functions. e management are: device, and specifies write operations. CLOSE a establishes 9 FORTRAN logical wunit reads with an components of file. of the I/O statement statements. OPEN 9.1 OPEN STATEMENT An OPEN or creates OPEN statement can a new either file specify subsequent connects and file an connects existing it attributes to a that file logical control to a unit. file logical 1In creation processing. The OPEN statement has the following form: OPEN (par[,par]...) par A keyword specification in one of the following key key = value key A keyword, as described the keyword, below. value Depends on as described 9~-1 below. forms: unit, addition, and AUXILIARY INPUT/OUTPUT STATEMENTS Keywords are divided into several categories based on function: Keywords that identify the unit and file. UNIT - logical unit number to be used TYPE DISPOSE - file existence status at OPEN - file existence status after CLOSE - file name specification for the file NAME Keywords that describe the file processing to be performed. - FORTRAN access method to be used ACCESS - write protection READONLY Keywords that describe the records in the file. BLOCKSIZE CARRIAGECONTROL - size of I/0 transfer buffer - type of printer control RECORDSIZE - FORM - type of FORTRAN record formatting length record logical Keywords that describe file storage allocation when a file is created. - initial file storage allocation - file storage allocation increment size INITIALSIZE EXTENDSIZE access Keywords that provide additional capability for direct 1/0. access direct ASSOCIATEVARIABLE - variable holding the next MAXREC - maximum direct access record number record number Optional keywords that provide improved performance or special capabilities. ERR - statement to which control is transferred occurs during execution of error an if BUFFERCOUNT - the NOSPANBLOCKS OPEN number - records of physical statement 1/0 buffers are not to to use be split blocks - other programs can simultaneously SHARED the across access file NOTE Not all PDP-11 operating systems support all keywords and options. Consult the user's IV FORTRAN PDP-11 appropriate guide for information in system-specific restrictions. Table 9-1 lists in alphabetical order the keywords and their associated values, including default values. possible AUXILIARY Table Keyword ACCESS 9-1: INPUT/OUTPUT OPEN Statement values? 'SEQUENTIAL" STATEMENTS Keyword Values Function Access Default method 'SEQUENTIAL" 'DIRECT' 'APPEND' ASSOCIATEVARIABLE v Next record number direct BLOCKSIZE e Size No in access of 1/0 associate variable System default System default buffer BUFFERCOUNT e Number of I/0 buffers CARRIAGECONTROL 'FORTRAN' Print control ‘LIST' "NONE' 'FORTRAN' (formatted) 'NONE' (unformatted) DISPOSE 'SAVE' DISP '"PRINT' tion 'DELETE' at ERR or 'KEEP' ] File disposi- close Error transfer label EXTENDSIZE e File 'FORMATTED' storage Format type e error Volume or system default Depends 'UNFORMATTED' INITIALSIZE No transfer allocation increment FORM 'SAVE' on ACCESS File storage No allocation No maximum allocation MAXREC e Maximum number direct NAME o File record in access name Depends specification NOSPANBLOCKS - Records span READONLY - Write tion do not blocks unit on and Records system can span blocks protec- No write protection (continued on next page) AUXILIARY Table 9-1 Keyword INPUT/OUTPUT (Cont): STATEMENTS OPEN Statement Keyword Values valuesl Function RECORDSIZE e Record SHARED - File sharing File sharing File status 'NEW' Logical No default TYPE length Default allowed '‘OLD! at 'NEW Depends on TYPE, not open allowed 'SCRATCH' 'UNKNOWN' UNIT e is an alphanumeric literal, c 1. number array element name. expression. e is an integer S is a statement label,. v is an integer variable unit or array name, variable name, name. Keyword specifications can appear in any order. Determining whether they are optional and which ones are required depends upon the type of file you are establishing or have established, and upon what you plan to do Some with it, examples OPEN follow. (UNIT=1, ERR=100) This example creates a new sequential formatted file on the default OPEN file wunit 1 with name,. (UNIT=3, TYPE='SCRATCH', INITIALSIZE=50, ACCESS='DIRECT', RECORDSIZE=64) This example creates a 50-block sequential file to be used with direct access. OPEN The file is deleted at program termination. (UNIT=I, NAME='MTO:MYDATA.DAT', BLOCKSIZE=8192, TYPE="NEW', ERR=14, RECORDSIZE=1024, RECORDTYPE='FIXED') This example creates a file on magnetic tape with a large for efficient OPEN block size processing. (UNIT=I, NAME='MTO:MYDATA.DAT', READONLY, TYPE='OLD', RECORDSIZE=1024, RECORDTYPE='FIXED', BLOCKSIZE=8192) This example opens the file created in the previous example for Sections 9.1.1 through 9.1.18 describe the keywords in detail. input. AUXILIARY 9.1.1 ACCESS INPUT/OUTPUT STATEMENTS Keyword The ACCESS keyword specifies the method writing records. In FORTRAN IV there sequential and direct. This keyword has ACCESS= acc the following of 1locating, are reading, or access methods: two form: acc One of the alphanumeric ACCESS= 'APPEND' the record last If no In sequential the beginning ACCESS is implies in the specified, access, of the 1literals, 'SEQUENTIAL', sequential access the you must file. In direct access, you specify I/0 statement, and the system ASSOCIATEVARIABLE ASSOCIATEVARIABLE each direct default is read write or 'SEQUENTIAL'. next sequential sequential This 1I/0 record records that record number n selects the nth the has the in the integer (Section record. variable operation, contains the This file. following ASSOCIATEVARIABLE sequence records the from in the file 7.2.3) in the (asv) that, record number specifier 1is access. keyword in Keyword specifies access or 'APPEND'. positioning after file. Direct access to sequential file requires be fixed-length (see Section 9.1.15.) 9.1.2 and = after of ignored the for form: asv asv An 9.1.3 integer variable. BLOCKSIZE Keyword BLOCKSIZE I/0 the the This specifies statements the appear size to (in bytes) transfer of records entities specified in the I/0 list. 1In records to an intermediate I/0 buffer. keyword has BLOCKSIZE the = following the I/0 directly fact, transfer between the system buffer. a file and transfers form: Dbks bks An integer For sequential to transfer magnetic tape expression. files, for files. device. See the BLOCKSIZE disk files The determines or default the 1is the number physical the system of default appropriate information. PDP-11 FORTRAN IV wuser's disk blocking guide blocks factor for for the for more AUXILIARY INPUT/OUTPUT STATEMENTS BUFFERCOUNT Keyword 9,1.4 BUFFERCOUNT specifies the number of buffers to be associated with the The BLOCKSIZE keyword determines logical wunit for multibuffered 1/0. If you do not specify BUFFERCOUNT, or if you the size of each buffer. This keyword has the following specify 0, the system default is used. form: BUFFERCOUNT bc An integer = bc expression. CARRIAGECONTROL Keyword 9.1.5 used to Dbe CARRIAGECONTROL determines the kind of carriage control The default for formatted files is 'FORTRAN', a file. when printing 'FORTRAN' 'NONE'. the default for unformatted files, the default is (see character first the of interpretation FORTRAN normal specifies rather 'LIST' specifies no FORTRAN interpretation, but Section 8.2); specifies no implied 'NONE' and records; spacing between single carriage control. This keyword has the CARRIAGECONTROL cc following = form: cc One of the alphanumeric literals 'FORTRAN', 'LIST', or 'NONE'. DISPOSE Keyword 9.,1.6 DISPOSE determines the disposition of the file connected to the wunit 1If you specify 'SAVE' or 'KEEP', the file is when the unit is closed. 1If you this is the default value. retained after the unit is closed; submitted to the system line printer 1is file the 'PRINT', specfiy If you On some systems, the file is deleted after printing. spooler. A read-only file (see Section 'DELETE', the file is deleted. specfiy 9.1.14) cannot be printed or deleted, and a scratch file (see Section 9.1.17) cannot be saved or printed. This keyword has the following forms: DISPOSE = dis DISP = dis dis One of the alphanumeric literals 'SAVE', 'KEEP', 'PRINT', or '"DELETE'. 9.1.7 ERR Keyword ERR transfers control to the executable statement specified by s if an ERR The statement. OPEN the of execution during occurs error subsequent to not specification applies only to the OPEN statement, If an error does occur, no file is opened I/0 operations on the unit. or created. AUXILIARY This keyword ERR= The 9.1.8 the following an executable label of EXTENDSIZE when STATEMENTS form: s EXTENDSIZE file has INPUT/OUTPUT Keyword specifies the additional file EXTENDSIZE, or statement. if you number of storage specify 0, blocks is by the system used. This keyword has the following EXTENDSIZE = An expression. which allocated. to extend If you do default for the not a disk specify device is form: es es integer 9.1.9 FORM FORM specifies Keyword whether using formatted or '"FORMATTED' is the default. the You same This the file being opened is unformatted I/O statements. default. For direct access, must not mix formatted and to be and written access, is the unformatted unit. keyword FORM = has the following read For sequential 'UNFORMATTED' I/0 statements on form: ft ft The 9.1.10 alphanumeric INITIALSIZE INITIALSIZE of space or if This for you a new has INITIALSIZE the file 0, the = 'FORMATTED' or 'UNFORMATTED'. Keyword specifies specify keyword literal no number on a of blocks in the 1If you do not allocation is made. disk. initial following initial specify allocation INITIALSIZE, form: insz insz An 9.1.11 MAXREC integer MAXREC expression. Keyword specifies the access file. The specifier is ignored maximum number of records permitted in a direct default is no maximum number of records. This for other types of files. AUXILIARY the This keyword has MAXREC INPUT/OUTPUT STATEMENTS following form: mr = mr An 9.1.12 integer expression. NAME Keyword The NAME specifies the name of the file to be connected to the unit. name can be any file specification accepted by the operating system. file The appropriate PDP-11 FORTRAN IV user's guide describes default name conventions., 1f the file name is stored in a variable, array, or array element, the <characters terminated by an ASCII null ASCII of consist name must character byte). (0 This keyword has NAME fln = the following form: fln An array name, variable name, array element name, Or alphanumeric literal. 9.,1.13 NOSPANBLOCKS Keyword It only. on disk NOSPANBLOCKS is used for sequential files stored If any specifies that records are not to cross disk block boundaries. record exceeds the size of a disk block, This keyword has the following an error occurs. form: NOSPANBLOCKS 9.1.14 READONLY Keyword READONLY prohibits writing by the program to a file. This keyword has the following form: READONLY 9,1.15 RECORDSIZE Keyword RECORDSIZE specifies the logical record length. the specifies RECORDSIZE If the file contains fixed-length records, If the file contains variable-length records, record. each of size RECORDSIZE specifies the maximum length for any record. You must specify RECORDSIZE when you create a file records, with fixed-length AUXILIARY This keyword has the INPUT/OUTPUT following RECORDSIZE = An expression. STATEMENTS form: rl rl integer The value on the value the records of are rl depends formatted, the length the records are unformatted, storage units (four 9.1.16 SHARED Keyword SHARED specifies more than one Sequential that the file is executing may only be program may have write only one This keyword has FORM (see Section is the number 1length is the of 9.1.9). characters; number of If if numeric bytes). program files the of the to shared following be opened for shared access by disk, and simultaneously. if they are stored on guide for access. form: SHARED See the appropriate information 9.1.17 on TYPE specifies the file IV status already 1If you specify 'SCRATCH', when the file closed. will first try 'NEW', thereby typ FORTRAN must created. This PDP-11 keyword. user's keyword the = typ One of the is 'OLD'; if creating a has TYPE the of file exist. the new following alphanumeric to be opened. 1If you specify 'OLD', you specify 'NEW', a new file is If a If new you file is created UNIT The be UNIT 'UNKNOWN', file is not found, file. The default the system is 'NEW'. to keyword An = it is system will use form: literals 'OLD', 'NEW', specifies the logical unit to which a file is unit specification must appear in the list. UNIT the 'SCRATCH', or Keyword connected This and specify unknown. 9.1.18 additional Keyword TYPE deleted this has the the logical following u integer unit expression. when form: the OPEN to be Another statement is connected. file cannot executed. AUXILIARY INPUT/OUTPUT STATEMENTS CLOSE 9.2 CLOSE STATEMENT The CLOSE statement disconnects a file from a unit. The CLOSE statement has the following form: DISPOSE CLOSE (UNIT=u], =p |[,ERR=8]) DISP u A p logical unit number. » L] ] » ] of disposition An alphanumeric literal that determines the 1Its values are 'SAVE', 'KEEP', 'DELETE', and 'PRINT'. file. S The label of an executable the statement. If you specify either 'SAVE' or 'KEEP', the file is retained after the If you specify 'PRINT', the file is submitted to the 1is closed. unit after deleted is file the On some systems, line printer spooler. For scratch If you specify 'DELETE', the file is deleted. printing. is for all other files, the default files, the default is 'DELETE'; The disposition specified in a CLOSE statement supersedes the 'SAVE'. disposition specified in the OPEN statement, except that a file opened file cannot be saved or printed, nor can a file opened scratch a as for read-only access be printed or deleted. For example: CLOSE (UNIT=1,DISPOSE="'PRINT"') This statement closes the file on unit 1 and submits the file for at the printing. E' ,ERR=99) CLOSE (UNIT=J,DISPOSE='DELET This statement closes the file on unit J and deletes it. REWIND 9.3 REWIND STATEMENT The REWIND statement beginning of the file. repositions an open The REWIND statement has the following form: REWIND u A logical unit number. sequential file AUXILIARY The unit magnetic number must tape. For REWIND This You must direct refer to example: an open STATEMENTS sequential file on disk or 3 statement currently INPUT/OUTPUT repositions open not logical wunit file. issue a REWIND statement access. for 3 to a file the beginning that is of open a for BACKSPACE 9.4 BACKSPACE STATEMENT The BACKSPACE statement repositions an open sequential file at beginning of the preceding record. When the next I/0 statement the unit is executed, that record is available for processing. The BACKSPACE The statement BACKSPACE u A unit logical unit magnetic has must refer tape. For example: must or not form: to an open sequential file on disk or to the open for 4 This statement repositions beginning of the preceding You following for number. number BACKSPACE direct the the issue append a the open record. BACKSPACE file statement access. on 1logical for a file wunit that is 4 FIND 9.5 FIND The to STATEMENT FIND a This statement positions a direct access file on a particular record. No data transfer takes place. statement FIND A the following form: (u'r) logical The has direct unit number. access record number. specified unit AUXILIARY INPUT/OUTPUT STATEMENTS The record number cannot be less than 1 or greater than the number of to the the file. for records defined The associated variable of the file, record direct access number. if specified, 1is set ENDFILE 9.6 ENDFILE STATEMENT The ENDFILE statement writes an end-file record to the specified unit. This statement has the following ENDFILE form: u unit A logical number. You can write an end-file record only to sequentially accessed sequential organization files containing variable-length or segmented records. For example: ENDFILE 2 This statement outputs an end-file record to logical unit 2, DEFINE FILE 9.7 DEFINE FILE STATEMENT The DEFINE FILE statement describes direct-access files sequential The OPEN statement ‘that are associated with a logical unit number. The DEFINE FILE this. to do way (Section 9.1) is the preferred statement establishes the size and structure of the direct access file. The DEFINE FILE statement has the following form: DEFINE FILE u u An integer logical m records An integer length, U constant number. or [,u(m,n,U,asv)] integer ... variable that specifies the An integer constant or integer variable that specifies the number of n unit (m,n,U,asv) in the file. constant or in 16-bit words, integer variable Specifies that the file is unformatted only acceptable entry in that (2 bytes), of each record. this position. (binary); specifies the 1is the this AUXILIARY INPUT/OUTPUT STATEMENTS asv An At of integer variable, called the asociated variable of the file. end of each direct access I/0 operation, the record number the next higher-numbered record in the file 1is assigned to the asv. DEFINE FILE specifies that a file containing m fixed-length records of n 1l6-bit words each exists, or is to exist, on logical unit u. The records in the file are numbered sequentially from 1 through m. DEFINE FILE statement must that be refers executed to the before specified the first direct-access DEFINE FILE also establishes the integer variable asv as associated variable of the file. At the end of each direct access operation, the FORTRAN I/0 system places in asv the record number the the the record immediately associated variable file (unless it For example: 1/0 file, the I/0O of one just read or written. Since to the next sequential record in by an assignment, input, or FIND statement), direct access 1I/0 statements can perform sequential processing of the file by using the associated variable of the file as the record number specifier. DEFINE This FILE statement file of 1000 words long. 1000, and this file, the record (1000,48,U,NREC) specifies that logical unit 3 is to be connected fixed-length records; each record is forty-eight The are 3 following the always points 1is redefined records are unformatted. the integer immediately numbered After each variable NREC following the sequentially from direct I1/0 access 1 to a 16-bit through operation will contain the record record just processed. number on of APPENDIX CHARACTER A.1l The FORTRAN CHARACTER FORTRAN character The letters 2. The numerals 3. The following Character A Or A consists through 0 Z through special of: and Space or = Equal sign + Plus - Minus * a through z 9 characters: Name (TAB SETS SET set 1. A Character tab Name ' Comma . Period ! Apostrophe " Quotation Asterisk $ Dollar / Slash ! Exclamation ( Left : Colon ) Right sign sign parenthesis mark sign point parenthesis Other printing characters can appear in a FORTRAN statement only as part of a Hollerith constant. Any printing character can appear in a comment. See Table A-1l. A.2 ASCII CHARACTER SET Table A-1 is a table representing the ASCII character set. of the table are hexadecimal digits (0 to 7), and to the table are hexadecimal digits (0 to F). To determine the value of an ASCII character, locate the ASCII character use the row number as the unit's position digit, number as the 16's position digit. For example, of the equal sign (=) is 3D. and the in At the top left of the hexadecimal the table, use the column hexadecimal value CHARACTER Table A-1: ASCII SETS Character Set Columns 0 NUL SOH STX ETX EOT ENQ A.3 1 2 3 4 5 6 7 0 NOL DLE SP 0 Q P * P 1 SOH DCl ! 1 A Q a q 2 STX DC2 " 2 B R b r 3 ETX DC3 # 3 c ) o S 4 EOT DC4 S 4 D T d t 5 ENQ NAK % 5 E U e u o 7 ACK BEL SYN ETB & 6 7 F G v W £ g v W 8 9 A BS HT LF CAN EM SUB 8 9 : H I J X Y Z h i j B C VT FF ESC FS ( ) * + , ; < K L [ \ k 1 X y z { J D CR GS - = M ] m E SO RS . > N - n ~ F sT us [/ ? 0 _ 0 DEL Null Start of Heading Start of Text End of Text End of Transmission Enquiry DLE DCl1 DC2 DC3 DC4 NAK ACK Acknowledge SYN BEL Bell ETB Data Link Escape Device Control 1 Device Control 2 Device Control 3 Device Control 4 Negative Acknowledge Synchronous Idle End of Transmission Block BS Backspace CAN Cancel HT LF VT FF Horizontal Tabulation Line Feed Vertical Tab Form Feed EM SUB ESC FS End of Medium Substitute Escape File Separator CR SO SI SP Carriage Return Shift Out Shift In Space GS RS us DEI, Group Separator Record Separator Unit Separator Delete RADIX-50 Radix-50 is characters character CONSTANTS AND CHARACTER set is a subset characters Character 2 . (Unassigned) 0 -9 of and the their ASCII Octal Equivalent Space S SET a special character data representation in which up to 3 can be encoded and packed into 16 bits. The Radix-50 The Radix-50 A - ASCII character corresponding 0 - 132 44 1 56 60 - 71 code Radix~50 Value (Octal) 40 101 set. 36 - 32 33 34 35 - 47 values are: CHARACTER SETS Radix-50 values are stored, up to 3 characters per word, them into single numeric values according to the formula: ((i * 50 where i, j, Thus, the + §) and k maximum 47*50*50 A Radix-50 + * 50 + the code Radix-50 value is: constant + 47 has packing k) represent 47*50 by = the values of 3 Radix-50 characters. 174777 following form: nRclc2...cn n An unsigned, characters nonzero to integer constant that states the number of follow. c A character from The maximum number include any character is only of a that valid in and character is 12. appear Radix-50 DATA valid Radix-50 of characters spaces constants Examples the 1in set. The the character character character). You count must (the space string can use Radix-50 statements. invalid valid Invalid 4RABCD 4RDKO: Radix-50 (the constants colon is not are: a Radix~-50 character) 6 RATOAAA When a Radix-50 element, type of the the contains characters contains characters constant number of component fewer (0 more are (see bytes bytes) bytes not is assigned bytes than are Table the appended than used. that the to can a numeric variable be assigned depends 2-2). 1length on length the of If of the the Radix-50 component, right. the or on If component, the array data constant ASCII null the constant the rightmost APPENDIX FORTRAN B.1l EXPRESSION LANGUAGE Table Type Arithmetic SUMMARY OPERATORS Table B-1 lists the expression descending precedence. Data B B-1l: Operator * ok operators in Expression each data type in order of Operators Operation Operates Exponentiation Upon: Arithmetic expressions *,/ Multiplication, division +,- Addition, unary Relational .GT. subtraction, plus Greater and minus than Arithmetic expressions .GE. LLT. .LE, Logical Greater than equal to Less than Less than equal to .EQ. Equal to .NE, Not .NOT. .AND. and are .OR, both is is only both A.OR.B either true A A.AND.B operators priority) equal to is if relational have or equal .NOT.A only or or logical (all if true if A true and false Logical or integer expressions if and B is true if A or B or are true (continued on next page) FORTRAN LANGUAGE SUMMARY Table B-1 (Cont.): Expression Operators Operates Upon: Data Type Operator Operation Logical (cont.) .EQV. A.EQV.B is true if and only if A and B are both true or A and .XOR. B.2 are B A.XOR.B only B is true both is true .EQV. and .XOR. have equal priority false if and if A is true and false or B is and A is false STATEMENTS e the PDP-11 The following list summarizes the statements availablin including the general form of each statement. FORTRAN IV language, The The statements are listed alphabetically for ease of reference. "Manual Section" column indicates the section of the manual that describes each statement in detail. Effect Form ACCEPT See READ, Formatted Sequential See READ, List-Directed Manual Section 7.3.1 7.3.3 3.1, 3.2 Arithmetic/Logical Assignment v=e v A variable name, e An expression. or an array element name. Assigns the value of the arithmetic or logical expression to the variable. 6.2.1 Statement Function f(lpl,pl...]1)=e f A symbolic name. p A e An expression, symbolic name. Creates a user-defined function having the When variable p as a dummy argument. referred to, the expression is evaluated using the actual arguments in the function call. FORTRAN Form LANGUAGE SUMMARY Manual Section Effect ASSIGN s TO v 3.3 S A v An label of an integer executable variable statement. name. Associates the statement label s integer variable v for later use assigned GO TO statement. BACKSPACE u u 9.4 An integer expression. Backspaces logical BLOCK DATA nam one unit record the currently open file on u. [nam] A symbolic Specifies BLOCK CALL with the in an name. the DATA subprogram that follows as a subprogram. f[(fa]l,[al]l...)] 4.5 6.2 £ a A subprogram An name expression, or an entry array point. name, or a procedure name. Calls the subroutine name specified by £, CLOSE arguments a arguments in to subprogram with the passing the actual replace the the subroutine dummy definition. (pl,pl...) P 9.2 One of UNIT = the e An s A = forms: e DISPOSE DISPOSE DISPOSE DISPOSE ERR following = = = = 'SAVE' 'KEEP' 'DELETE' 'PRINT' s integer label of expression. an executable Closes the specified be abbreviated DISP. statement. file. DISPOSE can FORTRAN LANGUAGE SUMMARY Manual Section Effect Form COMMON [/[cbl/] nlist [[,]/[cb]/nlist]... block cb A common nlist A list array of one names, separated by Reserves one 5.4 name. or more or variable array names, declarators commas. or more blocks of storage space under the name specified to contain the variables associated with that block name. CONTINUE Causes DATA no nlist/clist/[[,] nlist A list processing. nlist/clist/]... of one array names, separated by expressions clist or more variable or array commas. must be names, element names Subscript constant. A list of one or more constants separated by commas, each optionally preceded by j*, where j is a nonzero, unsigned integer constant. Initially stores elements of clist in the corresponding elements of nlist. DECODE (c,f,b[,ERR=s]) [list] An list integer A format A variable expression. specifier. name, element name. A label of An I/0 list. Reads c¢ assigns list, an FILE name, executable characters values to converted specification DEFINE array Or statement. from buffer the elements according array to b in and the format f. u(m,n,U,v)[,u(m,n,U0,v)]... u An integer variable or integer constant. m An integer variable or integer constant. FORTRAN Form LANGUAGE SUMMARY Manual Section Effect n An integer variable or integer \% An integexr variable name. constant. Defines the record structure of a direct access file where u is the logical unit number, m is the number of fixedlength records in the file, n is the length in words of a single record, U is a fixed argument, variable. DIMENSION and v is the associated a(d)[,a(d)]... a(d) An array 5.3 declarator. Specifies storage space requirements for arrays. DO s [,] v = el,e2[,e3] label 4.3 S A of \' A variable el,e2,e3 Numeric an executable statement. name. expressions. Executes the v = DO loop by performing l. Set 2. Execute all statements statement number s 3. Evaluate 4. Repeat the following steps: el v = steps through v+e3 2 through 3 for the following iterations: MAX ENCODE (1, INT((e2 - el)/e3) + 1) (c,f,b[,ERR=s]) [list] c An £ A format A variable b integer 7.6 expression. specifier. name, element name., s A label of list An I/0 list. an array name, executable Writes ¢ characters contains the values the list, converted specification f. Or array statement. into buffer b, which of the elements of according to format FORTRAN LANGUAGE SUMMARY Manual Form Section Effect 4.9 END Delimits ENDEFILE a program unit. u u An integer Writes unit an expression. end-£file record on logical u. END=s ,ERR=s s A label of an executable statement. Transfers control on end-of-file or error condition. This is an optional element in each the type program of to I/0 statement transfer to and allows statement number s when an end-of-file (END=) error (ERR=) condition occurs. EQUIVALENCE (nlist)[,(nlist)]... nlist A list of two or more variable names, array names, Or array element names, separated by commas. Subscript expressions must be constants. Assigns each of the names in the same storage location. EXTERNAL nlist v[,v]... \Y A subprogram Defines FIND or the name, names specified as subprograms. (u'r) u An integer expression. r An integer expression. FORMAT (field Positions unit u to the the specified by file on record logical r. specification,...) 8.1 Describes the format in which one or more records are to be transmitted; statement label must be present. a - 8.8 FORTRAN LANGUAGE SUMMARY Manual [typ] FUNCTION nam[*n] [([p[,pP)...])] typ A data nam A *n A data p A type symbolic TO a length function program name (p). can included. be specifier. name. names An subprogram, and any optional indicating dummy type argument specification s A label of Transfers GO name. symbolic the 6.2'2 specifier. type Begins GO Section Effect Form TO (slist)[,] slist A executable control to statement. statement number s. e list labels An an of one or separated integer Transfers more by statement commas. expression. control to the statement specified by the value of e (if e=1, control transfers to the first statement label; 1if e=2, control transfers to the If e second is number less of transfer GO TO v statement than statement takes \Y An slist A integer e label, etc.). greater labels than present, the no place. list of variable one or separated by control recently associated sl,s2,s3 An expression. name. more Transfers statement, (e) or [[,] (slist)] labels IF 1 to statement commas. the with statement v by an most ASSIGN FORTRAN LANGUAGE SUMMARY Manual Effect Form A label of Transfers control on the less 0, control than to statement. statement value of e (if transfers sl e is to e equals 0, control transfers if e is greater than 0, control transfers (e) executable depending sl; 1if to s2; IF an Section to s3). st st An expression. Any executable logical statement Executes the statement expression has a value IMPLICIT typ except a DO or IF. if of the logical true. (al,al...)[,typ(al,al...)]... typ A data a Either type specifier. a single alphabetical in The element a letter, or two letters order separated by represents range of) letter (s) initial letter of a the variable to be a single (or a whose presence as the variable specifies of that data type. OPEN (par[,par] ees) par A keyword specification in one of the forms: key key key value A value keyword, Depends on as described the keyword, below. as described below. Keyword ACCESS Values 'SEQUENTIAL" 'DIRECT! 'APPEND' ASSOCIATEVARIABLE \Y BLOCKSIZE e BUFFERCOUNT e CARRIAGECONTROL 'FORTRAN' 'LIST! 'NONE' DISPOSE 'SAVE' DISP 'PRINT' or 'DELETE' 'KEEP' following FORTRAN LANGUAGE SUMMARY Manual Section Effect Form Keyword Values ERR S EXTENDSIZE e FORM '"FORMATTED' 'UNFORMATTED' INITIALSIZE e MAXREC e NAME o] NOSPANBLOCKS - READONLY - RECORDSIZE e SHARED - TYPE 'OLD! 'NEW' 'SCRATCH" "UNKNOWN'' UNIT An e array element name, name, A numeric A label An variable or name, alphanumeric array literal. expression. of an integer executable variable statement. name. Opens a file on the specified logical according to the parameters specified the keywords. PAUSE unit by [disp] disp PRINT PROGRAM 4'7 A decimal digit string containing digits, an octal constant, or an alphanumeric literal. Suspends program display, if one execution is prints to five the specified. See WRITE, Formatted See WRITE, List-Directed. Sequential. 7.3.2 7.3.4 nam nam 5.10 A symbolic Specifies name. a name for READ (u,f[,END=s][,ERR=s]) [list] READ f[,list] ACCEPT and one the f[,list] u An f A integer format expression. specifier. main program. 7.3.1 FORTRAN LANGUAGE SUMMARY Manual Form Effect s A label of an list An I/0 list. Section executable statement. Reads one or more logical records from unit u and assigns values to the elements in the list., The values are converted according to format specification f. READ (u[,END=s] [ ,ERR=s]) [list] u An integer s A label of list An I/0 list. 7.3.5 expression. an executable statement. Reads one unformatted record from unit u, and assigns values to the elements in the list. logical READ(u'r[,ERR=s8])[list] 7.4.3 u An integer expression. r An integer expression. S A label of list An I/0 list. an executable statement. Reads record r from logical unit u and values to the elements in the list,. READ (u,*[,END=s][,ERR=s])list READ *,list ACCEPT 7.3.3 *,list integer u An * Denotes list-directed S A label of list An I/0 list. Reads one expression. an or formatting. executable more assigns records statement. from logical unit u and assigns values the elements in the list. The values are converted according to data type of the list element. to the FORTRAN Form LANGUAGE SUMMARY Effect "~ RETURN 4.6 Returns from REWIND control the current to the calling program subprogram. u 9.3 u An integer expression. Repositions logical unit u beginning of the currently STOP Manual Section to the opened file. [disp] disp A decimal digit string containing digits, an octal constant, or an alphanumeric literal. one to five Terminates program execution and prints the display, if one is specified. SUBROUTINE nam[([p[,p)l...])] nam A symbolic name. p A symbolic name. Begins the Type typ subroutine program names TYPE a 6.2.3 name and subprogram, any dummy indicating argument (p). See WRITE, Formatted See WRITE, List-Directed. Sequential. Declaration 5.2 vi,v]... typ One 7.3.2 7.3.4 of the following BYTE LOGICAL LOGICAL*1 LOGICAL*4 INTEGER INTEGER*2 INTEGER*4 REAL REAL*4 REAL*8 DOUBLE PRECISION COMPLEX COMPLEX*8 data types: FORTRAN LANGUAGE SUMMARY Manual Section Effect Form v A variable name, array name, function or function entry name, or an array declarator. The name can optionally be followed by a data type length specifier (*n). The symbolic specified names data (v) are assigned the type. VIRTUAL a(d)[,a(d)]}... a(d) An 5.5 array declarator. Specifies storage space for arrays outside normal program address space. WRITE (u,f[,ERR=s])[list] PRINT f[,list] TYPE f[,list] integer 7.3.2 u An expression. f A format S A label of list An I/0 list. specifier. an executable statement. Writes one or more records to logical unit u, containing the values of the elements in the list. according WRITE to The values format are converted specification f. (ul[,ERR=s])[list] integer 7.3.6 u An s A label of list An I/0 list, Writes unit u in WRITE an executable statement label. one unformatted record to logical containing the values of the elements list. the (u'r(,ERR=s]) expression. [list] 7.4.4 u An integer expression. X An integer expression. S A label of list An I/0 list. an Writes record the values of executable statement r to logical the elements B-12 unit u in the label. containing list. FORTRAN Form LANGUAGE SUMMARY Manual Section Effect WRITE(u,*[,ERR=s])1list PRINT TYPE 7.3.4 *,list *,list u An integer expression. * Denotes list-directed S A label of list An I/0 list. an formatting. executable statement. Writes one or more logical records to logical unit u containing the values of the elements in the list. The values are converted according to the data type of the list element. B.3 Table table LIBRARY FUNCTIONS B-2 lists the FORTRAN IV library functions. refer to notes which follow the table. Table B-2: FORTRAN Form Real absolute value Integer absolute value DABS (X) Double CABS (Z) FLOAT(I) IFIX (X) SNGL (X) DBLE (X) REAL (Z) AIMAG(Z) CMPLX (X, Y) precision Complex to Real, IDINT (X) value Complex to Real conversion, obtain real part Complex to Real conversion, obtain imaginary part Real to Complex conversion CMPLX (X, Y)=X+i*Y functions * return largest the the sign integer Argument Result Type Type Real Integer Real Integer Double Double Integer Real Complex Integer to Real conversion?2 the argument AINT (X) INT (X) absolute absolute valuel Real to Integer conversion? Double to Real conversion2 Real to Double conversion?2 Truncation in Library Functions Definition ABS (X) IABS (1) Superscripts Real Real Double Real Integer Real Double Complex Real Complex Real Real Complex Real Real Double Real Integer Integer of = largl Real to Real truncation3 Real to Integer truncation3 Double to Integer truncation3 Remainder functions return the remainder when the first argument is divided by the second. (continued on next page) FORTRAN Table B-2 LANGUAGE (Cont.): Form SUMMARY FORTRAN Real DMOD (X, Y) Double precision remainder remainder Integer remainder Maximum value largest value list; AMAXO(I,J,¢40) AMAX1(X,Y,...) MAX0(I,J,...) MAX1(X,Y,...) DMAX1(X,Y,...) Argument Result Type Type Definition AMOD (X, Y) MOD(I,J) Library Functions 2 or Real Real Double Double Integer Real Integer Real Double Real Real Integer Integer Double Integer Real Real Integer Real Integer Integer Integer functions return the from among the argument more arguments. Real maximum from Integer list Real maximum from Real list Integer maximum from Integer list Integer maximum from Real list Double maximum from Double list Minimum value functions return the smallest value from among the argument list; 2 or more arguments. AMINO(I,J,...) Real AMIN1(X,Y,...) MINO(I,Jd,...) Real minimum of Real list Integer minimum of Integer MIN1(X,Y,¢..) DMINL(X,Y,...) of Integer list list Integer minimum of Real list Double minimum of Double list The SIGN(X,Y) ISIGN(I,J) DSIGN(X,Y) minimum transfer of (sign of the value of first sign second functions Real Double Integer Double Real Integer Double Real Integer Double Real Integer Real Integerx return argument) argument). Real transfer of Integexr transfer Double precision sign of sign transfer of sign Positive difference functions return the first argument minus the minimum of the two DIM(X,Y) IDIM(I,J) arguments. Real positive difference Integer positive difference Exponential of e raised functions return the value to the argument power, EXP(X) DEXP (X) CEXP(2) eXx eX e? Real Double Complex Real Double ALOG (X) ALOG10 (X) DLOG (X) DLOG10 (X) CLOG(Z) loge(X) logq g (X) loge (X) logyg (X) loge (2) Real Real Double Double Complex Real Real Double Double Complex SQRT (X) DSQRT (X) Square Square Real Double Real Double CSQRT (Z)> root root of of Real argument Double precision Square root of Complex argument argument Complex (continued on Complex Complex next page) Table B-2 FORTRAN LANGUAGE SUMMARY (Cont.): FORTRAN Library Functions : Form SIN(X) Real DSIN(X) Double CSIN(2Z)6 sine precision sine Complex sine COS (X) Real DCOS (X) Double precision Complex cosine TANH (X) Hyperbolic ATAN (X) Real DATAN (X) Double ATAN2 (X,Y) Real arc cosine Type tangent tangent precision arc tangent arc tangent of (X/Y) . Double precision arc tangent of CONJG(2Z) Complex conjugate, CONJG(Z)=X-1i*Y RAN (I,J)9 Returns a pseudo-random number of uniform 0 absolute to 1. value of if Real Double complex Complex Real Real Double Double Real Real over the number, range Complex Real Real Double Double Real (X/Y) Z=X+i*Y distribution a Real Double Complex DATAN2 (X,Y) 7,8 The Result Type Complex cosine Cccos(z)® 1. Argument Definition Real Double Double Complex Complex Integer Real the value: of (X,Y), is real (X2+Y2)1/2 2. Functions provide statements. DBLE with a without 3. [x] is the For example 4. The 5. The than than of the one data implied type to another conversion in type assignment real argument and the return the value of the function argument [5.7] equals of 5. ALOG, argument of and DLOG, CLOG integer whose magnitude sign is the same as whose [-5.7] equals ALOGl0, must not and be does that of not x. -5. DLOGl0 must be greater (0.,0.). The argument of SQRT and DSQRT must be greater than or equal to 0. result of CSQRT is the principal value with the real part greater or equal The The DATAN2 8. as defined as the largest magnitude of x and The 0. When value with the argument of SIN, radians. 7. conversion effect The function SNGL with a double precision argument argument 0. principal 6. cause same conversion. exceed than that the to The argument result is in of real DSIN, is ASIN, the part imaginary part COS, treated DASIN, 1is DCOS, modulo ACOS, 0, greater TAN, the than and result or equal DTAN 1is to must the 0. be in 2*pi. DACOS, ATAN, DATAN, positive when ATANZ2, and radians. The result or equal of to ATAN2 0. The and DATAN2 result is is 0 or undefined if both a(2) arguments is are less 0. 9. The argument for this function must be an 1integer variable or integer array element. The atrgument should initially be set to 0. The RAN function stores a value in the argument that it later uses to calculate the next random number. Resetting the argument to 0 regenerates different the random sequence. number Alternate sequences. starting values generate INDEX A field descriptor, 8-10 to 8-11, 8-18 Absolute value constant, ACCEPT of and B-2, keyword, Access modes, B-9 9-2, 7~2 Array arguments, format 9-3, to 7-3 9-9 2-10, 6-1 to in, dummy, 6-3 Array size, Array storage, record length, 9-4, 2-13, 8-20 7-5 to 8-21 2-12 character set, A-1 characters, 8-22 9-8 null octal Allocating 2-13, 6-3 8-3, 8-5, 8-9 storage elements, 9-8 equivalents of characters, A-2 statement, 4-2, All-zero statement Alphanumeric American National FORTRAN label, literals, 1-6 7-17, 'APPEND' initial l-byte value, 9-3, 9-5 2-9 storage, list, 4-9 2-9, actual, the dummy, 6-1 CALL 2-9, 6-3, function 6-1 to dummy references to values to list values to variables, and array 2-14, expression, elements, Assignment operator, used 3-4 Associated variables, as, 6-3 9-3, 3-1 2-16, 4-3 2-14, Arithmetic/loyical to to 2-9, 9-13 keyword, 9-2, 9-5 dummy arguments, Asterisk 2-15, 6~-4 statement, 5-12 2-8 statements, 3-1 2-15 2-14, 7-5 arrays, Assignment statement, operators, elements, arithmetic/logical, Associating assignment 5-13 3-1 ASSOCIATEVARIABLE 6-1 5-9 name, to Arithmetic elements, program B-2 4-9 6-5 5-11 subprogram, to 5-5 locations, 6-2 6-1 and 6-1 to actual 6-2 (*), Auxiliary 1-3, 8-3, 8-4 specifications, 9-1 1/0 statement, 9-1 BACKSPACE statement, Attribute 4-4 B-1 assignment, B-2 9-1, 9-11 B-3 2-1, 2-2, adjustable, type of dimensions 4-9, Base 2-11 elements, 2-15 2-13, 6-3 Basic component, an, 2-12 Basic real in, ansubscripted, 5-14, 5-3 2-12 7-5 to to to common elements Assignment, statement, 4-9, in symbolic 6-3 and to 4-2 5-14 storage values, 2-3 Arguments associating 3-4, statement, values COMMON, Access actual, TO LOGICAL*]1l 2-8, 8-12 spaces, Argument GO blocks, character, to Assigning 1-1 2-19 Apostrophe 3-3 Radix-50 4-3 Standard X3.9-1966, A-2 4-3 Assigned 2-8 to character, ASSIGN 5-3 data 2-12, formats ASCII field, Allocation, 2-3 Array, 7-6 specifications, references, run-time All-blank IF to equivalent, 5-9 to 5-10 multidimensional, 2-10, 7-7 9-5 Addition, 2-14 Adjustable arrays, in 5-12 8-23 6-3 Area, statements, transmitting, 7-8 Array Actual Append 2-11, 5-13 7-2 shared, .AND., 5-3 2-10, making Access, Actual DATA to 7-3 sequential, 2-11, 2-1, 2-14 Input ACCESS direct, elements, 2-4 statement, also declarator, Array integer B-10, B-13 formatted sequential, list-directed, 7-10 See Array 5-4 2-13, 2-13 constant, to 2-14 2-5 Binary data, Binary operator, 2-8, Blank. See character Index-1 7-1 Space 2-14 INDEX Commas, 7-11 as a field Blank common block, 5-4 boundaries, crossing disk, Block, common, 2-2, 5-4 to See also Common blocks data subprograms, 2-2 size, physical, 9-5 BLOCK DATA statement, 5-13 5-5 indicator, 1-6 1-6 line, 1-7 1-6, assigning to of storage, 5-4 dimensions, byte, 5-9 9-2, 9_3 i Boundary, word, 5-5 BUFFERCOUNT keyword, 5-4 Bypassing input records, Byte boundary, odd, 5-9 Byte, C zero, CALL statement, 4_9 r of, control 8-24, 8-19 l1-6 1-3, 6-8, B-3 discussion Carriage 9-6 9-8 (letter), 5-11 4-9 character, Character set ASCII, A-1, FORTRAN, RADIX~-50, editing, Complex type, Plus 8-13 (+), tab, external 8-13 1-3 integer, 2-4 integer, 2-4 of, stored 8-10 form, FORTRAN, descriptor, values, 7-11 2-1 and DATA 2-6 2-9 Constants, statement, storage in 2-2 Continuation field, 1-6 indicator, lines, 1-6 CONTINUE 5-12 carriage, DO 80, 1-5, 8-18, iteration, format, one through 72, 1-5 seventy-three through 5-4 1-6 statement, 1-4 2-10 8-22 locations, Control 8-14 Column number, to 2-10, 1-5 B-3 (:) 2-5 Contiguous Classes of symbolic names, CLOSE statement, 9-1, 9-10 Colon 2-5 octal integer, 2-4 repetition of, 7-11 unsigned integer, 2-4, character-per-column Coding 4-2 7-11 positive truncated, 1-5 maximum number variables, 2-4, 2-6 negative real, 8-18 formatting, statement, negative double precision, l1-6 special, TO statement execution, logical, 2-7, 7-11 magnitude of a real, position space, GO 8-2, 8-11 input, 7-15 integer, 2-4 transferred, 72, 1-7 position of, in the record, 8-12 to printable, 1-4, A-1l 8-15 4-4 A-3 be FORTRAN Conditional A-1 2-8 to to 2-16 statement, 8-18 of, 8~14 2-3, absolute value of an integer, 2-4 complex 2-6 to 2-7, 7-11 double precision, 2-6 Hollerith, 1-1, 1-3, 2-7, 7-11, ASCII, 8-22 carriage control, 8-18, 8-24 colon (:), 8-14 dollar sign ($), 8-13 to 8-14, number data Components, Characters apostrophe, 2-7, 2-17 to 8-15 2-17 A-2, to complex operations, Complex value, 8-14 COMPLEX*8, 2-3 A-2 1-3, 2-6 Complex data Constant, count, Character B-4 5-5, 7-11 Computed 9"2' keyword, to constant, Complex 5-14 2-1 9-6 CARRIAGECONTROL 9-3, 9-6 5-10 and, extending, 5-10 initial values in, 2-13 allocation, elements 5-5 blank, 5-4 EQUIVALENCE Bound Boundary LOGICAL*1l 5-5 to 5-4 2-2, Common blocks, to Blocks separator, 8-23 Comments, 1-3, 9-8 8-24 4-6 8-21 in DO Control loops, 4-6 statements, Control transfer to 1-5 Index-2 4-4, 6-4, 4-1 methods, 6-6, 6-8 4-1 INDEX Control variable, 4-5, 7-7 Conversion, double precision, 2-17 rules for DECODE Default assignment statements, group 2-7 8-17, 8-23 DEFINE 4-6 repeat, 8-1 Crossing disk (letter), 1-6, D exponent field 2-6 indicator, Defined descriptor, 8-8, ¢ 8-7, 8-2, 8-7 8-12 editing between external editing format internal form, complex, for input of, 7-1 7-1 statement, 5-12 Data to type, 7-2, to 7-7 7-17, 2-9, to 2-3, array, 8-9 5-3 default 5-1 to integer, 2-2, to READ length specifier, list the to 5-2 logical, 2-3, rank 2-17 of, real, 2-3, 2-9, specifications, 5-3 storage factor and, 1-2, 8-15 5-1, 5-2 to 5-3 Declarator adjustable array, array, 2-11, dimension, implied, 7-6 4-6, to 5-3, 4-7 9-3 9-6 4-8, 7-10 DO range, DO statement, executions sign 4-5 of the, 4-6 to 4-6, 7-6, ($), 8-13 to 8-14, negative Dummy type, 2-17 constant, to 6-3, association 2-9, integer, Dummy array 4-9, 5-8, 6-5 with arguments, 2-10, 2-6 2-17 arguments, 6-1 2-15, 2-6 operations, 8-23 2-3, 8-8 constant, 2-10 statements, 7-16 list, conversion, type, Declaration 7-16 loop, to 8-17 explicit to 8-18 Double precision, to Declaration, 7-15 DO Dollar 1-6 8-16, 7-16 DO 2-16, 2-3 to B-5 5-3 : requirements, 7-15 file default, control, 4-6 iteration 6-11, 7-11 5-2 5-4, statement, unformatted, 2-16 Debugging statement, Decimal point, 8-15, scale to 2-6 2-10, to 'DIRECT' ACCESS value, 9-3 Disconnecting a file, 9-10 DISPOSE (DISP) keyword, 9-2, DO 2-16 2-5, 5-3 9-13 unformatted, 5-2 2-3, elements, 8-22, statement, WRITE 2-4 of 8-21, 6-3 statement, Disposition, double precision, 2-3, by implication, 2-10 8-14 2-11 2-13, unformatted, 2-12 rules, 8-14 statement, complex, 2-3, 2-16 declaration statement, 2-19 9-12 2-16 an (colon), 9-6 I1/0 2-10, 2-16 to 2-17, 6-2, 7-14 of an arithmetic expression, of B-5 Direct access, 7-3 files, 7-1, 9_7, 5-1, 2-8 2-9 9—]., to B-5 5-13 2-2 variable, DIMENSION 8-2 2-11, B-4 variable, 8-14 to 8-15 and output, to 7-12 9-13, declarator, 8-1 7-10, to Dimension adjustable, 6-3 in an array, 5-1 and integer, 2-10 logical, 2-14 magnitude, and G formats, rounding numeric, 7-9 transfer, 8-17 8-23 Data transmission statement, to $ (dollar), 8-13 to field, 8-2 to 8-18, to 8-16 alphanumeric, data 'DELETE' DISPOSE value, 9_3, Delimiting periods, 2-7, Descriptor 8-23 field for 2-3 FILE 9-12 block boundaries, 9-8 D to 8-18 repeat, iteration, 7-17 data names, 5-1 field descriptors, Default character, DATA allocations Default 3-2 7-4, 8-4 types, Count D statement, 7-18, actual 6-1 to 6-2 6-3 size, 6-3 6- 3 5- 6 E 2-11 field 8-7, ‘Index-3 descriptor, 8-15, 8-16 8-2, 8-6 to INDEX Editing, complex data, 8-14 Extended using Editor, a text, 1-6 Elements arithmetic, 2-14, 2-15 array, 2-10, 2-11, 2-1, See also assigning base, of a Array values FORTRAN Embedded 2-14 list, 1-2, program, 7-17 7-4, F 1-2, 4-11, all-blank, B-6 external, 2-18 sign, Even byte boundary, of 5-16 statement, 8-9 8-4 Q, 8-13 T, 8-12 X, 8-12 2-14, 2-15, 4-10 default logical, 4-4, 2-14, 6-4 mixed-mode, relational, statement subscript, FIND 2-16, for values, statement, character 8-18, Fixed-length FORTRAN 2-19, 2-17 to 2-12, to 2-18 6-5 5-4, 8-17 8-22 8-18 8-23, 8-24 9-1, 9-11 of record, a to 8-24 records, 9-13 Form to 8-16 8-13 B-7 2-14 functions, 2-11 to 8-15, 8-17 a, 7-2 to 7-3 attributes of, 9-1 seqguential organization, 7-2 Filling array elements, 5-12 output, 2-18 1-1 2-14, 8-19 File, 7-2 access to First to 8-23 8-1, 8-10 specification 6-4 complex, 2-18 defined, 2-1, 2-13 in I/0 1list, 7-5 to general trules Field width Explicit type declaration, 2-10 Exponent, 2-5, 2-6, 8-5 in an external field, 8-23 Exponent field indicator, 8-6 Exponentiation, 2-14, 2-15 in L, 0, 4-11 Expressions, arithmetic, 8-20, to 8-11, 8-18 8-7 to 8-8, 8-16 8-6 to 8-7, 8-15, 5-4, 8-21 to external 8-2, 8-5 to 8-6, 8-2, 8-8 to 8-9, 8-11 to 8-12 8-2 to 8-3 Execution of a condition statement, 4-4 of the DO range, 4-6 of a formatted I/0 statement, termination 8-23 (zero-length), F, G, H, I, 1-2, statements, 8-9 8-23 of, 2-19 5-5 Executable to part 8-10 8-2, 8-2, 9-6 5-5 Exclamation point, 1-3 Executable program, 1-2, 8-5, A, D, E, 7-4, of operators, order, 2-16 8-17, statement label, 1-6 termination, short, 8-19 Field descriptors, 8-2 to 8-18, 8-21, 8-22, 8-23 B-6 to to to 8-20, 8-23 sequence number, 1-7 statement, 1-7 9-6 to 9-7 specification, 7-3 to 8-5 1-6 8-22 separators, 3-1 EQUIVALENCE statement, 2—9 7 5-1, 5-8 to 5-10, B-7 .EQV., 2-19 ERR keyword, 9-2, 9—3' Evaluation Evaluation 8-3, fractional null condition, 8-2, 2-7 continuation, statement, 9-7, 8-23 Field B-6 Error block, 5-10 9-2, 9_3’ field 8-22 .FALSE., B-7 ERR= keyword, descriptor, 8-6, 8-15, 8-17 Factor, scale, 8-15 to 7-3 to 7-4 record, 7-4, 9-12 transfer of control on, 7-4 END= specification, 1-1, 7-4, statement, 9-7 common 8-2 statement, ENDFILE 4-8 separators, 8-19 to 8-20, 8-23 EXTERNAL statement, 5-1, 5-11, B-7 1-3 2-20 spaces, file, loop, field constructing, 8-22 to procedure names, 5-11 7-5 End-of-file condition, .EQ., Equal the DO 9-7 External 7-18 END a 2-15 logical, ENCODE Extending Extending EXTENDSIZE elements to range, to B-2 B-1 operators, Expression to 8-15 7-5 *n, 2-3 r*, 7-11 coding, 1-4 r*c, 7-11 readable character, 7-1 FORM keyword, 9-2, 9-3, 9-7 Index-4 9-12, INDEX Format G, effect of magnitude Hollerith constants, 1-1, 1-3, 2-4, 2-7 to 2-9, 7-11, 8-2, 8-11 data type rules for, 2-8 to data on, 8-8 reversion, 8-16, rules summarized, for, 8-21 to 8-22 8-22 to 2-9 Hollerith data, 5-2, 8-10, 8-20 8-24 run-time, 8-20 to 8-21 8-23 to 8-24 8-1, 8-18 Format control, Format separators, I to IF 8-19 See descriptor, 8-2 Input/Output statement, specifiers, FORMAT statement, 8-1, 8-22 to summary 'FORMATTED' 7-1, 7-8, 8-24, B-6 of FORM 7-3 7-3, codes, value, 7-10, See also Implicit 8-24 number, 9-3, IMPLICIT I/O0. Input; Output 'FORTRAN' CARRIAGECONTROL value, Increment 9-3, 9-6 character FORTRAN language summary, FORTRAN library functions, B-13 to also set, 1-3, A-1 B-1 6-9 B-14 Processor-defined line formatting, program Inner 1-4 elements, X3.9-1966, National allocation, part of to 7-1 1-2, statement, 6-5, 2-3 to FORTRAN 8-23 7-1 , 2-9, sequential, to B-14. G field G formats, 6-5, functions B-2 8-2, magnitude on, 2-18 GO statement, See repeat .GT., 2-18 H (letter), H field count, 8-8 to 4-3, 8-17, 7-14 statement; ACCEPT Input; 7-3 to to 2-15 2-4, value negative, 2-4 unsigned, 8-22 of an, 2-4 2-10 for, logical 8-3 operator, 2-19 to 2-20 B-7 8-23 Output 2-3, absolute variables, Integer 2-10, operations, INTEGER*2, 2-3 INTEGER*4, 2-3 Internal 8-11 sequential, components, 2-2, rules to 7-12 7-16 READ also data, data 2-7 descriptor, also constant, 8-9 4-1 to access, 7-19. Integer, and .GE., Group of 7-10 direct 7-7. 8-17 effect to statement 6-9 See also descriptor, 7-7 7-9 7-5, 8-23 format control interaction with, 8-21 to 8-22 sequential, 7-7 2-2, 6-6, 8-23 devices, 7-3 lists, 7-4 to 6-6 6-7 library, to Input/output B-8 statement, TO 8-22 statement 6-4, Processor-defined 8-9, 7-11 rules, to 5-11 subprogram, 4-8 statement 7-15 Functions B-13 to FORMAT See 8-12 Index-5 7-1 9-7 loop unformatted 6-9 9-3, 8-19 list-directed, 4-11, 9-7 9-2, external, to field, 2-1, arguments, 6-8, 4-5 field, formatted 6-6 statement, Function 6-6 4-7 DO statements, 6-4 to record, constant, 9-1 processor-defined, FUNCTION 2-10, 7-6 keyword, loop, Input, 1-1 the reference, as 2-9, 4-5 allocation, unformatted Function 7-1 B-8 lists, space also American standard, positioning, used 5-2, parameter, See 8-23 Function file unit, 7-8 1-6 parameter, Initial Initial 1-3 Fractional to DO Initiator, 1-7 Four-byte 7-3, INITIALSIZE functions FORTRAN B-8 Indicator, FORTRAN FORTRAN to type statement, Formatted See Data logical 5-1 Implied FORTRAN B-7 8-3 numbers, 2-3, 2-6 Implication, data type by, 2-10. 9-7 See 4-4, to Imaginary Format Format, field I1/0. 6-3 2-17 representation, 2-20, INDEX Iteration DO iteration control, 4-6 Newton-Raphson method, 6-7 LOGICAL*1l, array, 2-3 5-5, elements, COMMON, 'KEEP' DISPOSE value, Keywords in the 9-1 to 9-9 OPEN 9-3, LOGICAL*2, 9-6 LOGICAL*4, statement, Loop. See . field Label, descriptor, statement, 7-3 field, list, 1-5, 1-6, Language loop 1-2, 4-10 terminating, 3-4 FORTRAN, Leading spaces, Length specifier, 8-2, B-1 MAXREC and keyword, A-3 value, 9-2, 9-3, 9-7 to 9-8 Memory type, requirements types, 5-3 lower- 2-2 4-11 Radix-50 Maximum 8-5 data 1-3 letter, 6-8, 2-18 2-3, 2-3 Main program, RETURN and, summary, Letters, 2-3 2-18 .LT., 8-10 1-6 1-2 reference, .LE., 8-9, to 5-5 DO Lowercase 5-6 assigning for data 2-3 Minus, unary, 2-14 Mixed-mode expressions, 1-1 Multibuffered 1/0, 9-6 Multidimensional arrays, processing, 7-7 Multiplication, 2-14 uppercase, 1-3 Library functions, FORTRAN, 6-9, B-13 to B-14, See also Processor-defined functions Line, 1-2 comment, 1-6, continuation formatting a List *n, 1-7 1-7, 1-9 FORTRAN, 4-9 elements, assigning 1/0, 7-4 simple DO, 7-6 to 7-5, 1/0, to 1-7 values to, See Input; 7-5 'NEW' constant, Logical data type, Logical Logical of, Logical operators, B-1 to 2-7, 9-4, 2-6 9-9 iteration method, «NOT., to ].-'2, keyword, 2-9 character, ASCII, 9-8 7-15 record, 7-11 values, repetition zero-length field, 2-18 to Number complex, 2-6 to 2-20, of, 9-15 8-20, 8-23 2-7 of dimensions in implicit logical 4-4 2-19 statements, Null value, statement, value, 9-8 7-11 arrays, 2-10 unit, 7-3, 7-8 B-2 Logical record length, 9-8 Logical unit, 7-1 number, 7-3 Logical values, 2-14, 2-18, 3-3 value, NOSPANBLOCKS 4-4 IF 5-11 5-1 8-9 Logical TYPE Nonexecutable literals 2-3, 2-16, 3-3 elements, 2-20 expressions, 2-14, 2-19, 5-4 6-7 Output 3-3 Logical block '"NONE' CARRIAGECONTROL 9-3, 9-6 Locations. See Storage Logical assignment statement, transfer Names Newton-Raphson 1/0. Alphanumeric 9-8 2-11 List-directed output formats (table), 7-13 Literals, alphanumeric. See 9-2, 9-3, block, 5-4 .NE,, 2-18 Negative constants, 2-4, Nested DO loops, 4-7 8-21 9-6 List-directed common external procedure, symbolic, 2-1, 2-2, statement label, 1-5, 1-6 'LIST' CARRIAGECONTROL value, 9-3, keyword, Named common argument, 7-5 implied 1-4 2-3 NAME logical of 2-20, unit, 7-3 blocks, 9-7 statement, 1-6 Numeric data, Numeric Index-6 value, rounding, 2-14 7-9 INDEX O field descriptor, 8-4 Octal integer constant, Octal values, transfer 'OLD' TYPE value, 9-4, One-byte storage area, One (1) character, PRINT 2-4 of, 9-9 8-4 See 2-10 OPEN 9-1 9-4, to to B-8 keywords, 9-1 Procedure, Operators arithmetic, 9-9 B-1 carriage evaluation of, 2-19 exponentiation, 2-14 expression, B-1 to B-2 logical, 2-19 of, relational, role of, unary, 2-19 Order of B-1 7-17 termination Ordering 2-18, elements progression, rules, statement, 4-7 to 1-7 4-8, loop sequential, 7-10 list-directed, unformatted 7-9 Output to WRITE access, TYPE 5-16, 3-4, 5-4, 5-5, 6-6, block data, 6-7, 6-8, 6-9 5-13 to 5-14 of subscript, DO also Parentheses, 2-20, PAUSE Q REWRITE 8-23 to field 2-15 7-11, 8-24 READ to 2-16, 2-18, 8-17 4-10, delimiting, B-9 2-7, 2-18, See block also Plus (+) Plus, unary, Point, character, See also Precision, also 9-5. 8-18 2-14 8-15, 8-16, 8-23 constant, 2-4. integer Precedence, See size, Block decimal, Positive descriptor, A-2 data Constant 2-15, loss Data 9-3, A-3 2-17 B-9, B-10 sequential, 7-7 sequential, See also Input Read-only file, 9-6 keyword, Real data Real constant, type, REAL*4, 2-3 Record, 7-2 end a, of to in, first 9-2, 2-3, 2-5 7-14. 9 2-5 to 2- 6 7-11 external, 2-19 character 8-12, 8-13 character of position an output, 8-18, 8-24 initiator, 8-19 length Double value, 8-13 unformatted of, 7-9. type storage requirements; precision 'PRINT' DISPOSE 2-18, to type, statement, READONLY 2-19 Physical order list-directed, 7-10 to 7-11 unformatted direct access, 7-15 to 7-16 4-5. 8-1, 1-7 5-12 Radix-50, Rank, Constants statement, Periods, 4-11 formatted statements, See of, of, physical size of, 9-6 B-9 to statement rules, 1-3 5-5 5-1, Progression, statement; statement; 1-2, 5-4, 1-2 structure, 7-14 FORTRAN, 1-2, 1-2, Parameter of a unit, 7-13 sequential, format 2-2, statement, 2-12, statement; 7-11 function, PROGRAM to 7-16 7-15 See also 2-10, Program end 7-12 direct unformatted arrays, main, 1-2, 2-2 terminating, 4-11 7-7 formatted PRINT of FORTRAN, 5-12 DO keyword Program executable, also control; 6~-9 B-1 2-14 loop, Output, of, Processor-defined to subscript 2-12, See 2-20, 5-11 9-6. Carriage 4-5 multidimensional 2-14 .OR., control, also iterative, 2-15 2-17 arguments, CARRIAGECONTROL B-2 precedence Outer to 5-11 subprogram See A-1 1-3 names Processing 2-14, 2-8 assignment, as 1-4, computing, external, to ' Output characters, Procedure 9-4 to also Printing B-9 examples, B-12, sequential, 7-9 to 7-10 list-directed, 7-12 to 7-13. 2-3 array, B-9, formatted 8-18 One~dimensional statement, statement, B-13 spaces Index-7 at 9-8 end 9-8 to of, 9-9 8-20 beginning of, 7-11 7-8 INDEX (Cont.) Record, terminator, 8-1, transmitting. See Input; SHARED Output zero-filled, RECORDSIZE, 9-4, 9-8 to 9-9 Reference array, 2-12, 2-13, 7-5 arguments, as used function, function, 6-9 statement Reference, Relational 2-17 label, Relational 3-4 function, 2-1, 6-4 expressions, 2-14, to 2-17 to count, 8-1 specifications, 8-17, 8-23 Representation, 2-18, 2-20, 8-21 8-16, format, to 8-22 REWIND statement, 9-1, attribute, to 9-10 Scratch file, 9-6 TYPE value, '"SCRATCH' Separators external field, summary, 8-19 8-1 format 8-18 specification, to 8-19 to 7-8, 7-14 FORMAT separators, format, 8-1, 8-18 length, type 2“3' format, 7-1, 7-3 assignment, 3-1 Statement 9-9 8-20, ACCEPT, 7-8, B-10, B-13 arithmetic to 3-2 See 8-1, ASSIGN, 3-3, assigned GO BACKSPACE, TO, 9-1, 4-2 to 4-3 9-11, B-3 BLOCK 5-14, DATA, 5-1, 5-13 to 4-9, 5—11’ 6-7' 6_8, B-3 CALL, B-3 CLOSE, Input; statement, to 5-1 data Specifiers, Output READ B-6 5-3 9-5 Sequential 9-7, statement Specifier, Sequence number field, 1-7 Sequential access, 7-2 Sequential file, 7-2 'SEQUENTIAL' ACCESS value, 1I/0. also to statements in BLOCK DATA program units, 5-13 7-11 Sequential 9-6 1-1, statements, 9-3, 9-6 8-17, 8-22 9-4, 8-23, 8-19 1-7 8-23 field, slash, B-7 See for subptogram arguments, 6-2 Run-time formats, 8-20 to 8-21 'SAVE' DISPOSE value, Scale factor, 8-15 to 7-4, 1-1, 7-4, format, 8-1. END=, assignment 8-24 ordering, 8-22 to statement width, field ERR=, statements, 3-2 for format statements, 1-3 8-24 7-9 Rules for 8-5 2-10 determining Rounding numeric data, Rule, 1/0 list, 8-23 record, a 9-1 type, data 9-11, B-11 See also Output conversion 8-2, 9-7 5-9 trailing, 8-2 Special characters, Specification B-11 Reversion, of beginning 7-11 leading, Resuming program execution, 4-10 RETURN statement, 4-10, 6-6, 6-8, 4-11 allocation, initial, character, 8-18 at 7-1 8-19 8-18, Space sharing storage, Spaces, 7-11 appended, 2-9 group, internal, 9-9 7-11 line, Source B-1 Repeat Repeat 9-4, terminator, record separator, 2-18 operators, 9-2, block, 9-5 Slash (/), 7-11, 8-1, 8-19, 8-21 consecutive, 8-19 5-11 processor-defined keyword, Sharing storage space, 5-9 Short field termination, 8-19 Signed quantity, 2-4 Simple 1I/0 list, 7-5 Size, dummy array, 6-3 Size, specifying the physical 7-16 9-2, 7-9 Sequential WRITE statement, to 7-10, 7-16 Shared access, 9-19 8-19 7-7 9-1, 9-10, COMMON, 2-9, 2-10, 5-5, 5-11, B-4 to computed Index-8 GO TO, B-3 4-2 5-1, 5-4 to INDEX Statement, (Cont.) Statement field, 4-9, Statement function, CONTINUE, control, baTa, 4-1 2-9, 5-13, 2-11, 7-4, 7-18, 5-1, 5-12 to 7-17 to 9-1, 9-12 to 9-13, 5-3 to 5-4, B-5 ENCODE, END, 4-6, 7-4, 7-18, list, B-5 7-17 ENDFILE, 9-1, EQUIVALENCE, FORMAT, B-6 5-8 5-10, ment, to 7-8, formatted. See 6-4, 9-12, 8-1, B-6 8-22 to to functions, 2-2, to IF, 4-4, B-7 to 2-9, logical IF, 9-1 4-10, PRINT, 7-9 7-13, READ, B-8 to B-8 to to 5-2, B-9 to 7-10 B-9 to to 7-11, B-10. 9-1, 9-10, sSTOoP, 4-11, terminal, TYPE, type 6-7 to to to 9-11, 6-8, 7-10, 5-3, 7-12 2-10, B-1l1 to B-11 B-11 to 7-13 See Input; 5-6 to 5-8, 7-10, 7-12 7-9 to also to TO, 7-15, WRITE 5-1, 2-1, Statement 4-4 6-1 to governing, 6-2 procedure name block data, dummy arguments, 6-1 and, as, 6-6 in, to 6-7 6-6 to 6-3 to Output 6-9 statement, 6-4 to B-12 subroutine, to 7-13, 6-7 See to also 2-2, FORTRAN, conditional, array 5-7 5-8 SUBROUTINE B-11 Index-9 6-6 4-9, 6-9. virtual to 6-4 User-supplied subprograms; 7-7 6-3, 6-7 to 2-2, B-13. 5-11 4-11 function, statement; execution, 6-3 2-2 supplied to 1-7 6-1 rules user-written, 4-2 B-12, components, 7-3 arguments, FUNCTION output Statement unit, 2-15, using END B-12 unformatted. See 2-7 function, VIRTUAL, 5-1 2-3 9-9 1-2, B-13 GO 7-14 defined, 2-3 5-9 arguments unconditional WRITE, sharing, 2-10 type, 6-6 declaration, 5-2 data program 6-8 to 5-2 5-3 contiquous, Subprogram, 4-9 7-9 B-11 2-12 String, B-11 SUBROUTINE, 5-1, 2-3 Structure, B-11 REWIND, array, actual 6-6, B-13 2-10, elements, l-byte, units, statement; 4-10, to 1-5 area, unit, Input RETURN, tab, space, B-9 7-8, 8-22 5-3 locations, B-13 7-16, rules, blocks, 5-4 location, 5-8 7-12 5-16, READ B-2 requirements, B-12, to to also 5-1 3-3 7-10, 5-1, 7-7 See 9-4, of, declaration, allocating 2-10, B-9 B-9, 7-15 Stop, 2-10 Storage 4-4 to PAUSE, PROGRAM, 6-6 of 1-2 summary B-7 arrays, 5-1 type 6-5, assign- 1-2 specification, Output 4-3, for nonexecutable, 6-8, 5-3, B-8 logical assignment, OPEN, rules summary Input; to subprogram, 8-24 to 4-1 DATA 3-2 6-6 B-7 GO 1-7 5-14 executable, B-6 iMpLICIT, to establishing FUNCTION, TO, BLOCK conversion to 5-11, 9-11 7-3, 8-24, a 5-13 format, 9-1, rules, 1-2 assignment, 3-1 B-6 9-12, 5-1, 1-6 Statements, B-6 FIND, 3-4 ordering B-6 EXTERNAL, 4-3, 1-2 Statement to 2-9, 1-6, 1-6 number, in 4-11, 1-5, Statement B-=5 1-2, 6-6, 1-6 reference, 5-1, to 6-5, 7-3 all-zero, B-5 4-5 label, 6-8, field, FILE, to DIMENSION, DO, Statement B-4 DEFINE 1-7 B-2 B-4 DECODE, B-4 B-4 System- subprograms referencing, statement, 6-7 to 6-8, INDEX operators, 2-14 Unconditional GO TO statement, Subroutine subprogram, 4-9, Unary 6-9 to 6-7 Subscript expressions, 2-11 to 4-2 Subscript progression, 5-12, 7-5 Subscript order, 2-14 Subtraction, 9-7 Unit logical, FORTRAN language, B-1 generic function names, 6-14 of rules for format statements, 8-24 to of statements, B-2 to B-13 Suspending program execution, 4-10 2-11 2-2 classes, 2-9 to 2-2, 2-1, Symbolic name, types of, defining data 5-2 to overriding length attributes 5-3 of statement, DO a separator, value a as Terminal 7-11 4-9 Terminating program execution, 4-11 Termination of processing, 7-11 Termination, short field, 8-19 Terminator, record, 8-1, 8-19 8-18 (/), slash 1-6 editor, Text to 8-19 spaces, 8-2 Transfer of control, 6-5, 6-6, 6-8 Transmitting records. See 7-6 by implication, data, value Data assigning 2-20, 4-5 TYPE statement, B-11 to B-13 formatted sequential, 7-10 7-9 list-directed 7-12 to 7-13 also the, 2-1, 2-9 2-2, 2-11 assigning 2-10 type B-18 of variables, declaration, explicit, 2-10 specification, data, 2-10 Type declaration statement, 2-10, 5-1, 5-2 to 5-3, B-11 to B-12 TYPE keyword, 9-2, 9-4, 9-9 See 3-1 to variables and in dimension declarators, Type to 7-1l1 array elements, 5-12 default field descriptors, 8-17 to 8-18 control, Truncated constant, 2-9 Two-dimensional array, 2-10 See Values Variable True, 2-7 .TRUE., 2-7 data. Value separators, 3-3 Output Input; 6-3 2-9 A-3 initial, 5-14 logical, 2-14, 2-18, Transmitting array elements by lists, of the variable, Radix-50, A-2 to in common blocks, also GO TO statements implied DO in form r*c, 7-11 integer, 2-20 null, 7-11 numeric, 2-14 assigning 7-4. See 2-12 6-4 assigning, Three-dimensional arrays, 2-10 Trailing 2-13, to 8-5 4-5 loop, 8-22 Unsubscripted array, 2-12 4-9, 5-14, 7-5 Unsubscripted array name, complex, 8-14 to 8-15 constant, 7-11 evaluating magnitude of, T field descriptor, 8-12 to 8-13 TAB character, 1-5 to 1-6 Tab 7-2 Value library See also FORTRAN functions Output main program, 5-4, 5-5, 5-13 UNIT keyword, 9-2, 9-4, 9-13 'UNKNOWN' TYPE value, 9-4, 9-9 Unsigned integer constant, 2-4, to System-supplied subprograms, 6-9 9-3, Input; 2-13, 4-9, 5-14, 7-5 Uppercase letters, 1-3 User-written subprograms, 5-3 of, See 1/0. Unformatted 2-12 Summary 8-22 FORM value, 'UNFORMATTED' 7-5 5-4, 2-12, 2-10, to array to 5-8 elements and, 5-12 associated, 2-9, 9-13 integer, 2-10 in I/0 lists, 7-4 to 7-5 maximum number of characters stored in, real, 2-10 Virtual to values 2-9, 6-3 array, 8-10 5-6 references, restrictions on use of, 5-7 VIRTUAL statement, 5-1, 5-6 to 5-8, output Index-10 B-12 to INDEX Width default Word value, boundary, 5-5 WRITE statement, formatted unformatted 7-12 Output 8-18 X field descriptor, 8-12 B-13 7-9 to sequential, 7-15 also B-12, sequential, 7-10 list-directed, See field, to 7-13 7-14 Zero byte, Zero character, Zero scale to 9-8 8-18 factor, reinstating, 8-22 Zero-filled records, Zero-length field 8-23 Index-11 7-16 (null), 8-20, PDP-11 FORTRAN IV Language Reference Manual AA-R953A-TK READER’S COMMENTS NOTE: This form is for document comments only. DIGITAL will use comments submitted on this form at the company’s discretion. If you require a written reply and are eligible to receive one under Software Performance Report (SPR) service, submit your comments on an SPR form. Did you find this' manual understandable, usable, and well organized? Please make suggestions for improvement. Did you find errors in this manual? If so, specify the error and the page number. Please indicate the type of user/reader that you most nearly represent. [] Assembly language programmer [ Higher-level language programmer (] Occasional programmer (experienced) (] User with little programming experience (] Student programmer (71 Other (please specify) Name Date Organization Street City _ State Zip Code or Country — — — DoNotTear-FoldHereandTape — — — — — — — — — — — — — — — — — — —— No Postage i i ' Necessary i i if Mailed in the United States BUSINESS REPLY MAIL FIRST CLASS PERMIT NO.33 MAYNARD MASS. POSTAGE WILL BE PAID BY ADDRESSEE BSSG PUBLICATIONS ZK1-3/J35 DIGITAL EQUIPMENT CORPORATION 110 SPIT BROOK ROAD NASHUA, NEW HAMPSHIRE 03061 DoNotTear-FoldHere — — — — — — - - — - — - - - - — - - _— = —] Cut Along Dotted Line — — —
Home
Privacy and Data
Site structure and layout ©2025 Majenko Technologies