Digital PDFs
Documents
Guest
Register
Log In
AA-DO34A-TE
August 1978
226 pages
Original
9.4MB
view
download
OCR Version
8.8MB
view
download
Document:
VAX-11 Fortran IV-Plus Language Reference Manual
Order Number:
AA-DO34A-TE
Revision:
0
Pages:
226
Original Filename:
OCR Text
August 1978 This document describes the FORTRAN language elements supported by VAX-11 FORTRAN IV-PLUS. Itis intended to be used as a reference manual in preparing FORTRAN source programs. It is not a tutorial document, nor does it present information on the FORTRAN user’s interface to the VAX/VMS operating system, . VAX-11 FORTRAN IV-PLUS Language Reference Manual Order No. AA-DO34A-TE SUPERSESSION/UPDATE INFORMATION: This is a new document for this release. OPERATING SYSTEM AND VERSION: VAX/VMS V01 SOFTWARE VERSION: VAX-11 FORTRAN IV-PLUS 01 To order additional copies of this document, contact the Software Distribution Center, Digital Equipment Corporation, Maynard, Massachusetts 01754 digital equipment corporation - maynard, massachusetts First Printing, August 1978 The information in this document is subject to change without notice and should not be construed as a commitment by Digital Equipment Corporation. Digital Equipment Corporation assumes no responsibility for any errors that may appear in this document. The software described in this document is furnished under a license and may only be used or copied in accordance with the terms of such license. ’ No responsibility is assumed for the use or reliability of software on equipment that is not supplied by DIGITAL or its affiliated companies. Copyright C) 1978 by Digital Equipment Corporation The postage-prepaid READER'S COMMENTS form on the last page of this document requests the user's critical evaluation to assist us in preparing future documentation. The following are trademarks of Digital Equipment Corporation: DIGITAL DECsystem-10 DEC DECtape MASSBUS OMNIBUS PDP DIBOL 0s/8 DECUS EDUSYSTEM PHA UNIBUS COMPUTER LABS FLIP CHIP FOCAL RSTS RSX COMTEX DDT DECCOMM ASSIST-11 INDAC LAB-8 DECSYSTEM-20 RTS-8 TYPESET~-8 TYPESET-11 TMS-11 ITPS-10 VAX VMS SBI DECnet IAS CONTENTS Page PREFACE CHAPTER ix 1 INTRODUCTION 1.1 1.2 1.2.1 1.2.2 1.2.3 LANGUAGE OVERVIEW ELEMENTS OF FORTRAN PROGRAMS Statements Comments FORTRAN Character Set 1-1 1-3 1-3 1-3 1-4 1.3 1.3.1 1.3.2 FORMATTING A FORTRAN LINE Character-per-Column Formatting Tab-Character Formatting 1-5 1-5 1-6 Statement Label Field Comment Indicator Debugging Statement Indicator Continuation Field Statement Field Sequence Number Field 1-7 1-7 1-7 1-7 1-8 1-8 1.3.3 1.3.3.1 1.3.3.2 1.3.4 1.3.5 1.3.6 CHAPTER TO VAX-1ll FORTRAN IV-PLUS 1.4 PROGRAM UNIT 1.5 INCLUDE STATEMENT 1-9 2 FORTRAN STATEMENT COMPONENTS 2-1 2.1 2.2 SYMBOLIC NAMES DATA TYPES 2-2 2-3 2.3 CONSTANTS 2-4 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.4 2.4.1 2.4.2 Integer Constants Real Constants Double Precision Constants Complex Constants Octal and Hexadecimal Constants Logical Constants Character Constants Hollerith Constants VARIABLES Data Type Specification Data Type by Implication 2-5 2-6 2-7 2-7 2-8 2-10 2-10 2-11 2-12 2-12 2-13 2.5 ARRAYS 2-13 2.5.1 Array 2.5.2 Subscripts 2.5.3 Array 2.5.4 Data 2.5.5 2.5.6 2.6 2.7 2.7.1 STRUCTURE 1-1 Declarators 2-14 2-15 Storage Type 1-8 of 2-15 an Array 2-16 Array References Without Subscripts Adjustable Arrays CHARACTER SUBSTRINGS EXPRESSIONS Arithmetic Expressions 2-16 2-17 2-17 2-18 2-18 2.7.1.1 Use of Parentheses 2-20 2.7.1.2 2.7.2 2.7.3 2.7.4 Data Type of an Arithmetic Expression Character Expressions Relational Expressions Logical Expressions 2-21 2-22 2-23 2-24 iii CONTENTS (Cont.) Page CHAPTER CHAPTER 3 ASSIGNMENT 3.1 ARITHMETIC ASSIGNMENT 3.2 LOGICAL ASSIGNMENT 3.3 CHARACTER ASSIGNMENT 3.4 ASSIGN 4 CONTROL STATEMENTS 4-1 4.1 4.1.1 4,1.2 GO 4-2 4-2 4-2 4.1.3 4.2 TO STATEMENTS Unconditional GO TO Statement Computed GO TO Statement Assigned GO TO Statement STATEMENTS Block 4.2.3.3 Nested IF Statement Statement Block 4-5 4-8 IF 4-8 Constructs STATEMENT 4.3.3 Control 4,.3.4 Extended 4-13 Loops Transfers 4-10 4-12 DO Iteration Control DO 4-3 4-4 4-5 IF Examples Nested 3-3 3-4 4-4 4,.2.3.2 4,3.2 3-1 3-5 Block IF Statements Statement Blocks 4-14 in DO Loops 4-15 Range 4-15 STATEMENT 4-17 4.4 CONTINUE 4.5 CALL 4.6 RETURN 4.7 PAUSE 4.8 STOP 4.9 END STATEMENT 5 SPECIFICATION 5.1 5.2 TYPE 5.2.1 5.2.2 CHAPTER STATEMENT 4.2.3 4.2.3.1 DO STATEMENT STATEMENT Arithmetic Logical IF 4,.3.1 3-1 STATEMENT 4,2.1 4.2.2 4.3 CHAPTER IF STATEMENTS STATEMENT 4-18 STATEMENT 4-19 STATEMENT 4-21 STATEMENT 4-22 4-23 STATEMENTS 5-1 IMPLICIT STATEMENT DECLARATION STATEMENTS Numeric Type Declaration Statements Character Type Declaration Statements 5-2 5-3 5-3 5-4 5.3 5.4 DIMENSION STATEMENT COMMON STATEMENT 5-5 5-6 5.5 5.5.1 5.5.2 EQUIVALENCE STATEMENT Making Arrays Equivalent Making Substrings Equivalent 5-8 5-8 5-10 5.5.3 5.6 5.7 5.8 5.9 EQUIVALENCE and COMMON EXTERNAL STATEMENT DATA STATEMENT PARAMETER STATEMENT PROGRAM STATEMENT 5-13 5-14 5-16 5-18 5~-19 5.10 BLOCK 6 SUBPROGRAMS 6.1 6.1.1 , SUBPROGRAM ARGUMENTS Actual Argument and Association 6.1.1.1 6.1.1.2 Interaction DATA STATEMENT 5-20 6-1 6~1 Dummy Argument Adjustable Arrays Passed Length Character Arguments iv 6-1 6-2 6~3 CONTENTS (Cont.) FUNCTIONS Function References Generic Function References Processor-Defined and Generic W N 0 L) 00 00 0o [00] N N = N = N N = NN N NSNS NN NN e ©® & o L] e & e & s @ L] L] NOOAONOUTOTUTd R WWWNNDN ¢ o L] [] L) L) L[] . L] N = . . e e ALTUIUT D W N H [ '_.l D I/0 STATEMENT COMPONENTS Logical Unit Numbers Direct Access Record Numbers Format Specifiers Input/Output Records Input/Output Lists Simple Lists 1 1~ w . ~J INPUT/OUTPUT STATEMENTS o CHAPTER Character Library Functions NN N Usage CHAPTER Implied DO Lists Transferring Control on End-of-File or Error Conditions FORMATTED SEQUENTIAL INPUT/OUTPUT Formatted Sequential Input Statements Formatted Sequential Output Statements LIST-DIRECTED SEQUENTIAL INPUT/OUTPUT List-Directed Input Statements List~Directed Output Statements UNFORMATTED SEQUENTIAL INPUT/OUTPUT Unformatted Sequential Input Unformatted Sequential Output Statement Statement FORMATTED DIRECT ACCESS INPUT/OUTPUT Formatted Direct Access Input Statement Formatted Direct Access Output Statement UNFORMATTED DIRECT ACCESS INPUT/OUTPUT Unformatted Direct Access Unformatted Direct Access ENCODE AND DECODE FORMAT STATEMENTS FIELD DESCRIPTORS STATEMENTS I O Field Descriptor Field Descriptor Z Field Descriptor > N O o o 6~17 Function B_WWwwdhDNDNDN LIBRARY Processor-Defined Input Statement Output Statement HHEONNSO FORTRAN 6-15 O Statement ENTRY in Function Subprograms ENTRY in Subroutine Subprograms N Functions Character Functions Function Reference Subroutine Subprograms AN Functions 1 N I T U i s o HEHEOONNOUTOO Statement Subprograms 1 M SUBPROGRAMS A OY O Functions DN =0 w N Arguments o)W )] 1= N Return Numeric ENTRY = as $LOC Built-In Function Function N Hollerith Constants Built-In Functions Argument List Built-In Arithmetic * L] Alternate USER-WRITTEN . WWWWRNRNNNNNNNNNN . . [} [3 ° whH R B W NN NN NN AN AN O O . * L[] . L] and Arguments J Character Actual NNNNNNNN w . o)l [ i.—l Page CONTENTS (Cont.) 9 AUXILIARY INPUT/OUTPUT STATEMENTS 9-1 9.1 OPEN * Keyword BLOCKSIZE BUFFERCOUNT Keyword Keyword L] Keyword CARRIAGECONTROL Keyword DISPOSE Keyword ERR Keyword INITIALSIZE Keyword MAXREC Keyword NAME Keyword 9.1.13 9.1.14 9.1.15 9.1.16 9.1.17 9.1.18 9.1.19 9.1.20 9.1.21 9.2 NOSPANBLOCKS Keyword ORGANIZATION Keyword READONLY Keyword RECORDSIZE Keyword RECORDTYPE Keyword SHARED Keyword TYPE Keyword UNIT Keyword USEROPEN Keyword CLOSE STATEMENT L] FORM Keyword ] [] [] [ . . L] . [ . L] EXTENDSIZE Keyword * L[] 9.1 9.1 9.1 9.1 9.1 9.1.10 9.1.11 9.1.12 9.3 9.4 9.5 9.6 9.7 REWIND STATEMENT BACKSPACE STATEMENT FIND STATEMENT ENDFILE STATEMENT DEFINE FILE STATEMENT vi 8-22 8-23 8-23 8-24 8-24 - FHWOWVWVOOOLIIIJN 0N L[] . ASSOCIATEVARIABLE * 9.1 9.1 9.1 STATEMENT ACCESS NNFRHHREHRERFRHEBOO0ONO0S WN 9.1 . 8.1.4 8.1.5 8.1.6 8.1.7 8.1.8 8.1.9 8.1.10 8.1.10.1 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.1.19 8.1.20 8.2 8.3 8.4 8.5 8.6 CHAPTER 8-5 8-6 8-7 8-8 8-9 8-10 8-11 8-11 8-12 8-12 8-13 8-13 8-14 8-14 8-14 8-16 8-17 8-18 8-18 8-19 8-20 8-21 8.7 8.7.1 8.7.2 8.7.3 F Field Descriptor E Field Descriptor D Field Descriptor G Field Descriptor L Field Descriptor A Field Descriptor H Field Descriptor Character Constants X Field Descriptor T Field Descriptor Q Field Descriptor Dollar Sign Descriptor Colon Descriptor Complex Data Editing Scale Factor Repeat Counts and Group Repeat Counts Variable Format Expressions Default Field Descriptors CARRIAGE CONTROL FORMAT SPECIFICATION SEPARATORS EXTERNAL FIELD SEPARATORS RUN--TIME FORMAT FORMAT CONTROL INTERACTION WITH INPUT/OUTPUT LISTS SUMMARY OF RULES FOR FORMAT STATEMENTS General Rules Input Rules Output Rules PPOVVVOOVVOOVYOY Page -10 -10 -10 9-10 9-11 9-12 9-12 9-12 9-12 9-13 9-14 9-15 9-16 9-17 9-18 CONTENTS (Cont.) Page APPENDIX A ~ A.l A.2 A.3 APPENDIX B CHARACTER SETS A-1 FORTRAN CHARACTER SET CHARACTER SET RADIX~-50 CONSTANTS AND A-2 FORTRAN B.1 B.2 B.3 A-1 ASCII LANGUAGE CHARACTER SET A-2 SUMMARY EXPRESSION OPERATORS B-1 | STATEMENTS B-1 B-2 LIBRARY FUNCTIONS Bfl7 INDEX Index-1 FIGURES FIGURE 1-1 1-2 1-3 2-1 4-1 4-2 4-3 FORTRAN Coding Form Formatting Example Required Order of Statements Array Storage 1-5 Line Examples of Block Nested DO Loops and ILines 1-6 1-8 2-16 IF Constructs 4-7 5-1 5-2 Control Transfers and Extended Range Equivalence of Array Storage Equivalence of Arrays with Nonunity Lower 5-3 5-4 6-1 6-2 8-1 Equivalence of Substrings Equivalence of Character Arrays Multiple Functions in a Function Subprogram Multiple Function Name Usage Variable Format Expression Example Bounds 4-14 4-16 5-9 5-10 5-11 5-12 6-15 6-20 8-17 TABLES 2-1 2-2 2-3 3-1 6-1 Entities Identified by Symbolic Names Requirements Allowed Combinations for Exponentiation ( Conversion Rules for Assignment Statements Data Type Storage Argument List Built-In Functions Defaults 6-2 6-3 Default Carriage Summary Subprograms Summary OPEN ASCII Field Descriptor Values Control Characters of FORMAT Codes Statement Keyword Character Generic 2-4 2-19 3-2 6-6 6-7 6-18 7-14 8 8 8 8-25 Values 9 Set and Processor-Defined vii 2-3 and List-Directed Output Formats of Data Magnitude on G Format Conversions Effect wns?cnaam 7-1 Types of User-Written Generic Function Name 8-1 s W N TABLE A Functions B PREFACE MANUAL OBJECTIVES This manual describes the elements of VAX-11 manual is designed for reference, rather than The user interface to VAX-11 companion manual to this FORTRAN IV-PLUS document, Guide. FORTRAN as the a 1is VAX-11 IV-PLUS. The tutorial document. described FORTRAN IV-PLUS in the User's INTENDED AUDIENCE This manual is intended readers should have order derive maximum to a for use basic as a reference understanding benefit from the the VAX/VMS operating system is information concerning VAX/VMS refer under "ASSOCIATED STRUCTURE This OF manual ® THIS to document. the manual. helpful, the DOCUMENTS." Therefore, FORTRAN Some language knowledge in of but not necessary. For documents listed below DOCUMENT contains nine chapters and Chapter 1 consists of general introduces basic facts and of two appendixes. information needed concerning FORTRAN, prior to writing FORTRAN programs. e Chapter as e Chapter define e e e 2 3 ® describes Chapter 4 control from Chapter 5 used deals define as data the in of FORTRAN statements, statements, statements, the 6 which are program to used to used discusses 7 covers Chapter 8 describes formatted subprograms; VAX-11 the I/O FORTRAN topic the both user-written IV-PLUS. of FORMAT statements. ix FORTRAN to transfer another. describes with such etc. program. control point Chapter with assignment in with one components variables, specification statements, which are characteristics of symbols used in the program, type, array dimensions, etc. to Chapter the constants, values supplied e describes symbols, and used such those input/output. statements used in conjunction Chapter 9 contains information on CLOSE, such as OPEN, auxiliary and DEFINE FILE. I/0 statements, Appendix A summarizes the character sets supported FORTRAN by VAX-11 IV-PLUS. Appendix B summarizes the language elements of VAX-11 FORTRAN IV-PLUS. ASSOCIATED DOCUMENTS FORTRAN IV-PLUS including complete 1list of all VAX-1ll documents, For a descriptions of each, see the VAX-1ll Information Directory. brief The following documents are of to interest VAX-11 programmers: VAX/VMS Primer VAX-11 FORTRAN IV-PLUS User's Guide VAX/VMS Command Language User's Guide CONVENTIONS USED IN THIS DOCUMENT The following syntactic conventions are used in this manual: Uppercase words and letters used in examples indicate that you should type the word or letter as shown Lowercase words and letters used in format examples indicate that you are to substitute a word or value of your choice Brackets indicate optional elements ([]) Braces ({}) are used to enclose lists from which one element is item(s) can be denote special to be chosen Ellipses indicate that (...) repeated one or more times In addition, the nonprinting following characters: Tab character notations the are preceding used to TAB Space character A or (in terminal dialog examples) CHAPTER INTRODUCTION 1.1 LANGUAGE 1 TO VAX-11 FORTRAN IV-PLUS OVERVIEW VAX-11 FORTRAN IV—PLUSl is based on American National FORTRAN X3.9-1966, and includes the following type provides Standard enhancements (ANS) to ANS FORTRAN: e The CHARACTER data character functions, and a means of manipulating data. Character constants, variables, and expressions using the concatenation substring references are arrays, operator provided. e Block IF statements provide a way to conditionally execute a block of statements. The block IF statements are IF THEN, ELSE IF THEN, ELSE, and END IF. @ Any If arithmetic expression can be used as an the expression 1is not of type integer integer ® type. Mixed-mode including e The array subscript. it is converted to expressions complex. following data can types contain have been elements of any data type, added: LOGICAL*1 LOGICAL*2 INTEGER*2 CHARACTER e The IMPLICIT symbolic statement redefines the implied data type of names. e The following input/output (4}0) statements have been added: ACCEPT TYPE Device-oriented I/0O PRINT 1 the READ WRITE FIND (u'r) READ WRITE (u'r,fmt) (u'r,fmt) (u'r) (u'r) Unformatted Formatted direct-access direct-access VvAX-11 FORTRAN IV-PLUS is referred to simply as FORTRAN rest of this manual. I1/0 I/0 throughout INTRODUCTION TO VAX-11 OPEN FORTRAN IV-PLUS CLOSE DEFINE FILE File control and attribute specification ENCODE DECODE Formatted data conversion in memory The specifications END=s and/or ERR=s can be included in any READ or WRITE statement to transfer control to the specified statement when an end-of-file or error condition occurs. List-directed I/0 can be used to perform formatted I/O without a format specification. I/0O 1lists of PARAMETER statements can be used to assign symbolic names to Constants and expressions are permitted in the WRITE, TYPE, constant and PRINT statements. values. Generic-function selection by argument data type for many FORTRAN-supplied 1s functions. provided A DO statement control variable can be a real or double precision variable. Any arithmetic expression can be used as the initial value, increment, or limit parameter 1in the DO as the control parameter in the computed GO TO or statement, statement. The DO statement increment parameter you optionally can have a negative value. For readability, statements. For Do I=1,10 5, can example: Lower bounds for array dimensions array declarators. can use be commas in DO specified 1in all ENTRY statements can be used in SUBROUTINE and subprograms to define multiple , entry points 1in program FUNCTION a single unit. A PROGRAM statement can be used in a main program. The INCLUDE statement incorporates FORTRAN source text from file separate You can FORTRAN into a a FORTRAN program. include an explanatory comment on the same line as any statement. Begin comments with exclamation points (1. You can include debugging statements in a program by placing the letter D in column 1. These statements are compiled only when you specify the associated compiler command qualifier; otherwise, they are treated as comments. The statement label list in an assigned optional. GO TO statement 8, is INTRODUCTION e Octal and hexadecimal numeric constants. e Symbolic letters, TO VAX-1ll constants FORTRAN can be IV-PLUS used names can be up to 15 characters digits, dollar signs ($), and in place of any long and consist of underline characters (). VAX-11 FORTRAN IV-PLUS is also a compatible superset of PDP-11 FORTRAN IV-PLUS. This means you can compile existing PDP-11 FORTRAN source programs, as well as new programs that incorporate features available in VAX-11l FORTRAN IV-PLUS. 1.2 ELEMENTS OF FORTRAN PROGRAMS FORTRAN programs consist of FORTRAN statements and optional comments. The statements are organized into program units. A program unit is a sequence of statements that define a computing procedure and is terminated by an END statement. A program unit can be either a main program or a subprogram. An executable program consists of one main program and, optionally, one or more subprograms. 1.2.1 Statements Statements are grouped 1into two general classes: executable and nonexecutable. Executable statements describe the action of the program. Nonexecutable statements describe data arrangement and characteristics, and provide editing and data-conversion 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 further information on continuation characters, see Section 1.3.4.) You can identify a statement with a statement 1label so that other statements can refer to it, either for the information it contains or to transfer control to it. A statement label takes the form of an integer number 1in the first five columns of a statement's initial line. 1.2.2 Comments Comments do not affect program processing in any way. They are merely a documentation aid to the programmer. You can use them freely to describe the actions of the program, to identify program sections and processes, and to provide greater ease in reading the source program listing. The letter C in the first column of a source line identifies that line as a comment. In addition, if you place an ex¢lamation point (!) in column 1 or in the statement portion of a source 1line, the rest of that line is treated as a comment. INTRODUCTION TO VAX-11 1.2.3 The FORTRAN Character FORTRAN character 1. FORTRAN IV-PLUS Set set consists of: All uppercase and lowercase letters (A through Z, a through z) 2. The numerals 0 through 9 3. The special characters listed below Character Name A or (me) Space or tab = Equal + Plus sign - Minus sign * Asterisk / Slash ( Left parenthesis ) Right parenthesis ’ Comma . Period ! Apostrophe " Quotation mark $ Dollar sign sign Underline Exclamation point : Colon < Left > Right angle bracket % Percent & Amper sand angle bracket sign Other printable ASCII characters can appear in a only as part of a character or Hollerith constant a list of printable characters). in a FORTRAN statement (see Appendix A for Any printable character can appear comment. Except in character and Hollerith constants, distinction between uppercase and the compiler lowercase letters. makes no INTRODUCTION 1.3 FORMATTING A FORTRAN Each FORTRAN line has Statement label e Continuation ®© Statement field ® Sequence number fields, as indicator form, use at can a field. entering tab-character terminal 1.3.1 As or using a lines shown in Figure text 1-1, labels, sequence 1.3.3 from terminal when using you are a text editor. entering lines Formatting FORTRAN Each through a only editor. line continuation numbers. Sections a a FORTRAN line: 1) on a using the tab character. You can when punching cards, using a formatting Character-per-Column statement follows: field to format basis or 2) by character-per-column formatting You IV-PLUS field There are two ways character-per-column use coding FORTRAN LINE four e TO VAX-11 column 1.3.6 1is divided indicators, represents describe the a CODER CODING FORM PROBLEM fields for text, and single use of FORTRAN 1into statement each character. field. DATE PAGE C Convmer STATEMENT N UM C & FORTRAN STATEMENT [ IDENTIFICATION R 1234 . 506§7891001213141516171819202122232425262728293031323334 3536373839404 424344454647 484950 515253 54555657 5859 6061626364 6556676869707 72|7376 757677 7879 80 s THI1S, PROGRAM CALCULATES PRIME NUMBERS FROM 11 TO 50 (210 TR RS NN P IR J.=1 4, I R X P . L .. @ @ @ .., ettt A N T ....... + e +———+ - —t ettt e A R TN =N NN A= 1/A + L=1/4 . + D ——— B=A-L st BF (B S LF (J. LT SGRT, ((FLOAT, (l))) 10 CONTINUE — 1,05 FORMAT PRlME") . MND TYPE 5, 105 e e B e L L o B yes e s e — — B n o S S t S . GQ TO. ‘4........................... 1 o — . s bttt e LA AAAAAAAAAAAAAAAAAAAAAAAAAA T o e 5 (I4 'IS e L 10, T 4 e S S LANRLANAGHE + S B VST S U S U S SIS o SR BN Sl A 1 Sa e S A S e . ——s e | 1+ et PN SN SN o T 4 e o o I T U T o P Y T WU W S 1 Attt + A U La " NS 4 D W W T At e oottt e B W g bbbt Attt S N 4ttt U A+ AT W +7T I ¢ 1 4 ' T bbbt -ttt gy T e W i 4 DN 1234 35016[789101012131415161718192021222324252627282970 31323334 133637307940 41 4243444540 47484950 315233 343356 57 39390061 626164 836687680970 1N 71 717473 7877 787980 PG-3 DIGITAL EQUIPMENT Figure CORPORATION 1-1 : MAYNARD, FORTRAN MASSACHUSETTS Coding Form INTRODUCTION TO VAX-11] FORTRAN IV-PLUS the To enter an item in a field, enter it in the column(s) in form, <coding as listed below: Field Column (s) Statement label 1 through 5 Continuation indicator 6 Statement 7 through 72 Sequence number 73 through 80 Tab-Character Formatting 1.3.2 statement the ‘You can use tab-character formatting to specify field, the continuation indicator field, and the statement field. label You cannot specify a sequence number field with tab-character formatting. Figure 1-2 illustrates FORTRAN lines with tab-character formatting and the equivalent lines with character-per-column formatting. Character-per-Column Format Format Using TAB Character 112 3 4 51617 8 10|11 C @a® FIRST VALUE C FIIIRISIT 10@B | = J + 5xK + 110 | Figure 1-2 before the first tab character. 5 characters. After you type the first tab 51+ + K + I {+1]2 = Line Formatting Example. The statement label field consists of the than VAL JUIE J = I {V[AlL @B IVAL = 1+2 12 13 14 15|16 17 18 19 20 L]|+IM 1 1 L+M more 9 characters that you type either the The statement label field cannot have character, you can continuation indicator field or the statement field. type the To enter the continuation indicator field, type any digit after the field, indicator continuation the enter you If first tab. statement field consists of all the characters after the digit to the end of the line. To enter the statement field without a continuation indicatorK field, Note that no the first tab. type the statement immediately after FORTRAN statement starts with a digit. 1-6 INTRODUCTION TO VAX-11l FORTRAN IV-PLUS 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 space character to improve the legibility of a FORTRAN statement. The compiler ignores all spaces 1in a statement field except those within a character or Hollerith constant. For example, GO in TO a and GOTO statement are equivalent. field the the compiler produces, printed 1.3.3 at the next Statement same The as a compiler space. 1In treats the the tab causes the character tab Label stop (located at columns the tab source 9, character listing that that follows to be 17, 25, 33, etc.). Field A statement label or statement number consists of one to five decimal digits in the statement 1label field of a statement's initial line. Spaces and leading zeros are ignored. An all-zero statement label is illegal. Any statement two statements that another statement within a program unit refers to must have a label. can have the same label. You can use two special indicators -- the comment debugging statement indicator -in the first field. These indicators are described below. The statement 1.3.3.1 indicate the label field of a continuation Comment Indicator - You can that the line is a comment. source program listing, then line indicator column of must be No and the the label blank. use the letter C in column 1 The compiler prints that line ignores the to in line. 1.3.3.2 Debugging Statement Indicator - You can use the letter D in column 1 to designate debugging statements. The initial line of the debugging statement can contain a statement label in the remaining columns of the 1label onto more than one line, column The be 1 as compiler compiled compiler statements not well 1.3.4 a are D continuation the debugging statement a comment, depending on qualifier. compiled LINES, Continuation indicator. [4 treats or as command specify as field. 1If a debugging statement is continued every continuation line must contain a D in If you either as source text to the setting of the D_LINES specify as a part of the debugging statements D LINES, source program; are treated as debugging if you do comments. Field A continuation indicator is any character, except zero or space, in column 6 of a FORTRAN line or any digit, except zero, after the first tab. A statement can be divided into distinct lines at any point. The compiler considers the characters after the continuation character as the characters following the last character of the previous 1line, as if zero, no break occurred then FORTRAN the compiler statement. at that point. considers the If a continuation 1line an 1initial indicator 1line of is a INTRODUCTION TO VAX-11l FORTRAN IV-PLUS Comment lines can occur between a Comment lines cannot be continued. statement's initial line and its continuation line(s), or between successive continuation lines. 1.3.5 Statement Field placed The text of a FORTRAN statement is 2 A aWa OIRD Q-Nno la A in - the A N d statement E A field. -‘ character and Hollerith constants), you can space the text in any ln way desired for maximum legibility. NOTE If a 1line position 72, 1 72 is ignored printed. 70 1.3.6 extends character beyond the text following position and no warning message 1 1s Sequence Number Field A sequence number or other identifying information can appear in columns 73 through 80 of any line in a FORTRAN program. The compiler ignores the characters in this field. 1.4 PROGRAM UNIT STRUCTURE Figure 1-3 shows the order of statements in a FORTRAN program unit. In this figure, vertical lines separate statement types that can be interspersed. For example, DATA statements can be interspersed with executable statements. Horizontal lines indicate statement types that For example, type declaration statements cannot be interspersed. cannot be interspersed with executable statements. PROGRAM, FUNCTION, SUBROUTINE, or BLOCK DATA Statements IMPLICIT Statements . PARAMETER Statements Other Comment Li a'r':ss INCLUDE Statements Specification Statements FORMAT and ENTRY Statements DATA Statements Statement Function Definitions Executable Statements END Line Figure 1-3 Required Order of Statements and Lines 1-8 INTRODUCTION TO VAX-11 FORTRAN IV-PLUS 1.5 INCLUDE STATEMENT The INCLUDE statement specifies that the contents of a designated file are to be incorporated in the FORTRAN compilation directly following the INCLUDE statement. The INCLUDE statement is described in this has chapter rather than with the other FORTRAN statements because it read no effect on program execution, except to direct the compiler to FORTRAN statements from a file. The INCLUDE statement has the form: INCLUDE 'file specification[/[NO]JLIST]' file specification Is a character constant that specifies the file to be included in This file specification must be acceptable to the compilation. (See the VAX-11 FORTRAN IV-PLUS User's the operating system. Guide for the form of a file specification.) The /LIST qualifier indicates that the statements in the specified file are to be listed in the compilation source listing. An asterisk (*) precedes each statement listed. The /NOLIST gqualifier indicates that the included statements are not to be listed in the compilation source listing. The default is /LIST; that is, the compiler assumes /LIST if you do not specify a qualifier. When the compiler encounters an INCLUDE statement, it stops reading statements from the current file and reads the statements in the included file. When it reaches the end of the included file, the compiler resumes compilation with the next statement after the INCLUDE statement. An INCLUDE statement can be contained in an included file. An included file cannot begin with a continuation line. Each statement must be completely contained within a single file. FORTRAN The INCLUDE statement can appear anywhere that a comment line can appear, as shown in Figure 1-3. Any FORTRAN statement can appear in an included file. However, the included statements, when combined with the other statements in the compilation, must satisfy the statement ordering restrictions described in Section 1.4. In the following example, the file COMMON.FOR defines the size of blank COMMON block and the size of the arrays X, Y, and Z. Main Program File File COMMON.FOR INCLUDE 'COMMON.FOR' DIMENSION Z (M) PARAMETER M = 100 ,Y (M) COMMON X (M) CALL CUBE 1I=1,M 5, Z(I) it 5 DO X(I)+SQRT(Y(I)) SUBROUTINE INCLUDE DO 10, 10 X(I) I=1,M = Y(I)**3 RETURN END CUBE 'COMMON.FOR' the CHAPTER 2 FORTRAN STATEMENT COMPONENTS The basic components of FORTRAN statements are: Constants —- fixed, self-describing values. Variables -- symbolic names that represent stored values. contiguously and Arrays -- groups of values that are storedtively . Individual collec or can be referred to individually values are called array elements. ts, or Expressions -- single constants, variables, array elemen or, combinations of these components function references; that specify plus certain other elements, called operators,these components of values the on med perfor be to ations comput to obtain a single result. optionally followed Function references —-- names of functions, nce performs the refere on functi A nts. argume by 1lists of The ition. defin ion funct computation indicated by the resulting value is used in place of the function reference. ic name have symbolic names. A symbol variables, arrays, and functionsidenti fy entities in the program. is a string of characters that Constants, variables, arrays, expressions, and functions can have the following data types: Logical Integer Real Double precision Complex Character components of FORTRAN, with The following sections detail the basic which are described in Chapter the exception of function references, 6. FORTRAN 2.1 SYMBOLIC Symbolic unit. A symbolic (S$) and are used entities name is underline symbolic name maximum of Examples must 15 of a to are identify listed string (_) be a of valid and By symbolic names with 5Q (begins B.4 (contains other SFREQ for wuse conflicts, that Symbolic cannot you the same consisting following must the be unique within symbolic unit. be Function ® Subroutine e Common ® Main e Block ® Function ® Subroutine That is, if as the the _ name a to any dollar sign character can in contain a a unique numeral) or a a dollar the sign components. symbolic program within character §) §) identify Furthermore, in more program units, ® unit. two an or ($)- are To avoid names in vyour That 1s, you entities in more executable the symbolic names entire program: program of the cannot use functions subprograms subprograms blocks programs data your subprograms entries entries program symbolic program, unit. entity with Sections 2.4.1 contains name even if "yes" under and 2.4.2 name. Within a subprogram, arguments. A dummy element, the name software define sign. of two or entities must BTU not dollar Processor-defined Each program are: a containing a same program names ® in FORTRAN first special with DIGITAL-supplied should contain names use in a than (begins symbolic vy program and The symbolic K9 convention, block digits, NUMBER reserved name The a Invalid FIND_IT R within 2-1. characters. letter. X P Table letters, special invalid entities in characters. Valid -« COMPONENTS NAMES names These STATEMENT constant, of a any the function other name "Typed" discuss named BTU, subprogram, appears in a you entry, different in Table 2-1 has how to specify the or common program a data type. data type of a you can also use symbolic names as argument can represent a variable, array, expression, or subprogram. dummy array FORTRAN STATEMENT COMPONENTS 2-1 Table Entities Identified by Symbolic Names Typed Entity Variables yes Arrays yes Arithmetic statement functions Processor-defined functions yes yes Function subprograms Subroutine subprograms Common blocks Main programs Block data subprograms yes no no no no yes no Function entries Subroutine entries Parameter 2.2 yes constants DATA TYPES The types. several of Each basic component represents data of one data type of a component can be inherent in its construction, implied in available The data types by convention, or explicitly declared. FORTRAN, and their definitions, are: -- a whole number e Integer @ Real -- a decimal number; e Double precision -- similar to real, but with more than e that values Complex -- a pair of real represents value first the number ; fraction, that is, a whole number, a or a combination of the two the degree of accuracy in its representation number, the second represents the twice complex a represent the real part of that imaginary part true or false e Logical -- the logical value, @ Character -- a sequence of characters An important attribute of each data decimal type 1is the amount of memory required to represent a value of that type. Variations on the basic the represented value or the types affect either the accuracy of allowed range of values. of amount ANS FORTRAN specifies that a "numeric storage unit" is the Double storage needed to represent a real, integer, or logical value. In units. storage precision and complex values occupy two numeric bytes 4 to corresponds unit storage numeric a IV-PLUS, FORTRAN VAX-11 of memory. ANS FORTRAN specifies that a "character storage unit" is the amount of 1In VAX-11l FORTRAN represent one character value. to needed storage IV-PLUS, a character storage unit corresponds to 1 byte of memory. VAX-11 FORTRAN IV-PLUS provides additional data types for optimum Table 2-2 lists the selection of performance and memory requirements. and data types available, the names associated with each data type, The form *n appended to a amount of storage required (in bytes). the specifier. length type data a called is name type data FORTRAN Data Type STATEMENT COMPONENTS Table 2-2 Storage Requirements Data Type Storage Requirements (in BYTE 12 LOGICAL 2 LOGICAL*1 18 bytes) 5 or 4 LOGICAL*2 2 LOGICAL*4 4 INTEGER 2 or 4P INTEGER*2 INTEGER*4 2 4 REAL \ 4 REAL¥*4 4 REAL*8 DOUBLE 8 8 PRECISION COMPLEX 8 COMPLEX*8 8 CHARACTER*1len len® CHARACTER* (*) @ fThe l-byte storage area can contain or false, a single character, or the logical integers in values the true range -128 to +127. b gither 2 or 4 bytes are allocated depending on command qualifier specified. The default the compiler allocation is 4 bytes. € The value.of len is the number of characters specified. The value of 1len can be in the range 1 to 32767. Passed length format -- *(*) -- applies only to dummy arguments or character functions, and actual arqument or function indicates that the length is used (see Chapter 6). The following sections contain additional types and their representations. 2.3 of these the data CONSTANTS A constant represents a fixed logical value, or a character Octal, assume 2.3.5 descriptions of hexadecimal, and the data type of and 2.3.8). value and string. can be a numeric Hollerith constants have no data the context in which they appear value, a type. They (see Sections FORTRAN STATEMENT COMPONENTS 2.3.1 Integer Constants An integer constant is a whole number with no decimal point. have a leading sign and is interpreted as a decimal number. An constant has the integer It can form: snn An optional sign. nn A string of numeric Leading zeros, if any, characters. are ignored. A plus A minus sign must appear before a negative integer constant. 1is optional before a positive constant (an unsigned constant is sign assumed to be positive). constant integer an sign, algebraic 1leading Except for a contain any character other than the numerals 0 through 9. The absolute value of an 2147483647. Examples of valid and integer invalid constant integer cannot be cannot greater than constants are: Invalid Valid 0 -127 +32123 99999999999 3.14 32,767 (too large) (decimal point and comma not allowed) it If the value of the constant is within the range -32768 to +32767, represents a 2-byte signed quantity and is treated as INTEGER*2 data type. If the value is outside that range, it represents a 4-byte signed quantity and Integer data type. constants can also be specified in octal form. The octal is treated as INTEGER*4 form of an integer constant is: llnn nn A string of digits Examples of valid and in the range invalid octal 0 to 7. integer constants are: Valid Invalid "107 "108 (contains a digit outside the allowed "177777 "1377. "17777" (contains a decimal point) (contains a trailing quotation mark) range) FORTRAN 2.3.2 Real A constant real STATEMENT COMPONENTS Constants can be any one e A basic real constant ® A basic real constant e An integer constant A basic real constant following forms: is a of the following: followed followed string of by by a a decimal decimal exponent exponent decimal digits, in (decimal digits). any of the S.nn snn.nn snn. s An optional sign A numeric nn string of characters The decimal point can appear anywhere in the string. The number of digits 1is not 1limited, but typically only the leftmost 7 digits are significant. Leading zeros (zeros to the left of the first nonzero digit) are ignored in counting the leftmost 7 digits. Thus, in the constant zeroes, A 0.00001234567, are decimal all the nonzero digits, and none of the significant. exponent has the form: Esnn An optional An integer sign. nn constant. The exponent represents a integer constant 1is to the value 1.0 * 10 ** power be of 10 by which the preceding real or multiplied (for example, 1.0E6 represents 6),. A real constant occupies 4 bytes as a real number with a degree digits. of of VAX-1l storage and is interpreted precision of, typically, 7 decimal A minus sign must appear between the letter E and A plus sign is optional for a positive exponent. Except used), for a numerals 0 algebraic signs, a decimal point, real constant cannot contain any through negative and the character exponent. 1letter E other than (if the 9. If the letter E appears 1in exponent field must follow. it can be zero. The magnitude approximately a a real constant, The exponent field of a non-zero real 0.29E-38 or greater an integer constant cannot be omitted, but constant cannot than approximately be smaller 1.7E38. than FORTRAN STATEMENT COMPONENTS Examples of valid and invalid real constants are: vValid Invalid 3.14159 621712. -.00127 +5.0E3 2E-3 1,234,567 325E-45 (commas not allowed) (too small) (too large) (decimal point missing) (special character -47.E47 100 $25.00 not allowed) Double Precision Constants 2.3.3 A double precision constant is a basic real or constant constant followed by a decimal exponent of the form: an integer Dsnn An optional sign. nn An integer constant. The number of digits that precede the exponent is not typically only the leftmost 16 digits are significant. 1limited, but A double precision constant occupies 8 bytes of VAX-11l storage and is interpreted as a real number with a degree of precision that is typically 16 significant digits. A minus sign must appear before a negative double precision constant. Similarly, a A plus sign 1is optional before a positive constant. exponent; minus sign must appear between the letter D and a negative a plus sign is optional for a positive exponent. The exponent field following the letter D cannot be can be omitted, but it zero. The magnitude of a non-zero double precision constant cannot be less than approximately 0.29D-38 or greater than approximately 1.7D38. Examples of valid and invalid double precision constants are: Valid 1234567890D+5 +2.7182815.846182D00 -72.5D-15 1DO Invalid 1234567890D45 (too large) +2.7182812846182 (no Dsnn present; 1234567890.0D-89 (too small) this is a valid single precision constant) 2.3.4 Complex Constants A complex constant is a pair of real constants separated by a comma The first real constant represents the in parentheses. and enclosed real part of that number and the second real constant represents the imaginary part. FORTRAN A complex constant has the STATEMENT COMPONENTS form: (rc,rc) rc A real constant. The parentheses See Section A complex and 2.3.2 comma for constant interpreted as Examples valid of a are the part rules occupies complex and of for 8 the constant forming bytes real of and are required. constants. VAX-1ll storage and is number. invalid complex constants Valid Invalid (1.70391,-1.70391) (1,2) (1.23,) (+12739E3,0.) are: (integers are not allowed) (second real constant is missing) (1.0,1.000) (double constants 2.3.5 Octal Octal and numeric and Hexadecimal hexadecimal They not allowed) Constants constants constants. precision are are can be alternative used wherever ways to numeric represent constants are allowed. An octal and constant followed by is the a string of octal digits alphabetic character range 7. O. enclosed An octal by apostrophes constant has the form: 1 clczc3...cn t 0] A A digit in hexadecimal enclosed by hexadecimal the constant 0 to is a string of hexadecimal digits and letters and followed by the alphabetic character X. A has the form: apostrophes constant 'e.c.c....c 123 n 'X o] A digit to f. Leading in zeros the are constants must be constants must be Examples of valid range ignored in in and the the 0 to in 9 or octal range range invalid '0'0 '0'X octal Valid Invalid '07737'0 '1'0 '7782'0 7772'0 '0737" a and to to letter in the hexadecimal range to constants. '37777777777'0, 'FFFFFFFF'X. constants A and F or a Octal hexadecimal are: (invalid character) (no initial apostrophe) (no O after second apostrophe) FORTRAN STATEMENT COMPONENTS Examples of valid and invalid hexadecimal constants are: Invalid Valid (invalid character) '999.'X 'AF9730'X (no apostrophe before 'FI9X 'FFABC'X the X) They Octal and hexadecimal constants are typeless numeric constants. assume data types based on the way they are used, and thus are not converted ) before use. including When the constant is used with a binary operator, the assignment operator, the data type of the constant is the data type of the other operand. For example: Data Type Length of of Constant Constant Statement INTEGER*2 ICOUNT REAL*8 DOUBLE ) When a specific data type 1is required, that type is assumed for the constant. generally For example: 4 INTEGER*4 Y(IX)=Y('15'0)+3. When the constant is used as an actual argument, no data type is assumed. For example: Data Type When the constant is used in is assumed. I = J = 1,2,3 any For example: Statement IF('AF77'X) of '"7777'0 - 'A39'X .NOT.'73777'0 4 none CALL APAC('34BC2'X) data type Length of Constant Constant Statement ) integer, Length of Data Type of Constant Constant Statement ° 4 2 8 4 REAL*4 INTEGER*2 REAL*8 INTEGER*4 RAPHA = '99AF2'X JCOUNT = ICOUNT + '777'0 DOUBLE = 'FFF99A'X IF(N.EQ.'123'0) GO TO 10 other INTEGER%*4 context, Data Type Length INTEGER* 4 4 of of Constant Constant INTEGER*4 INTEGER*4 4 4 An octal or hexadecimal constant actually specifies 4 bytes of data. When the data type implies that the length of the constant is more When the data than 4 bytes, the leftmost digits have a value of 0. 4 bytes, the than less is constant the of length the that implies type lists Table 2-2 (in Section 2.2) constant is truncated on the left. the number of bytes that each data type requires. FORTRAN 2.3.6 Logical STATEMENT COMPONENTS Constants A logical constant only the following specifies a two logical logical value, true or constants are possible: false. Thus, .TRUE. .FALSE, The delimiting 2.3.7 periods Character are constant 1is apostrophes. A constant Both has ! A printable character. delimiting apostrophes value the delimiting of a apostrophes, a string the t The required part of each constant. Constants A character enclosed by character a character does printable ASCII must be constant The include present. is the value all string does not spaces of characters include or apostrophes. represent must be a in Examples the character apostrophes, single the of apostrophe. range valid constant is except that and 1 to The the two length of within invalid character constants the is represented other character number of consecutive a between delimiting characters apostrophes character 255. Valid constant are: Invalid 'WHAT?' 'HEADINGS 'TODAY''S DATE 'HE "HELLO"' SAID, IS: (no trailing apostrophe) ' '! (character "NOW OR NEVER" (quotation marks constant must contain at least 1 character) , cannot place If a the the tabs Within a character constant, the apostrophe character by two consecutive apostrophes (with no space or between them). The length of between the characters form: apostrophes. but of character be of used in apostrophes) constant appears in a numeric context (for example, as expression on the right side of an arithmetic assignment statement), it is considered a Hollerith constant. See Section 2.3.8. FORTRAN 2.3.8 STATEMENT COMPONENTS Hollerith Constants A Hollerith constant is a string of printable characters preceded by a character count and the letter H. A Hollerith constanfi has the form: nHc. n ¢c.Cc....C n 1273 An unsigned, nonzero integer constant stating the characters in the string (including spaces and tabs). number of C A printable character. The maximum number of characters is 255. Hollerith constants are stored as byte strings, 1 character per byte. Hollerith constants have no data type. They assume a numeric data Hollerith in which they are used. context the to according type constants cannot assume a character data type; they cannot be used where a character value Examples of valid and is expected. invalid Hollerith constants are: Valid Invalid 16HTODAY'S DATE 1IS: 3HABCD (wrong number of characters) 1HB When Hollerith constants are used in numeric expressions, data types according to the following rules. ° they assume including operator, When the constant is used with a binary the assignment operator, the data type of the constant is the data type of the other operand. For example: Length of Data Type of Constant Constant Statement INTEGER*2 ICOUNT REAL*8 DOUBLE RALPHA = 4HABCD JCOUNT = ICOUNT + 2HXY DOUBLE = 8HABCDEFGH IF(N.EQ.1HZ) GO TO 10 ) When a specific data type 1is required, that type is assumed for the constant. Y (IX)=Y(1HA)+3. When the constant is assumed. For generally For example: integer, INTEGER*4 is used as an actual 4 argument, no data type example: Data Statement CALL APAC 4 2 8 4 Length of Data Type of Constant Constant Statement ) REAL*4 INTEGER*2 REAL*8 INTEGER*4 (9HABCDEFGHI) Type Length of of Constant Constant none 9 FORTRAN ® When data When the data type, STATEMENT the constant is used in any other type is assumed. For example: INTEGER*4 Data Type of Constant IF (2HAB) INTEGER*4 4 I= 1HC-1HA INTEGER*4 4 J= .NOT. INTEGER*4 4 of spaces the are 1,2,3 1HB constant appended is to less the the constant is greater than constant is truncated on the Table 2-2 each data type. Section Each 2.2) lists character the than the constant length of type, the 2.4 context, Statement length (in COMPONENTS Length of Constant length on the length right. the implied right. implied by by the When the the data number of characters required 1 byte of storage. for occupies VARIABLES A variable is a symbolic name associated with a storage value of the variable is the value currently stored in that value can be changed by assigning a new value to (See Section 2.1 for the form of a symbolic name.) Variables are data type of classified a variable by data type, indicates the precision, and itc¢ storage assigned to a variable, type of the variable. You by type declaration typing rules. location. The that location; the variable. as constants are. The of data it represents, its requirements. When data of any type |is it is converted, if necessary, to the data can establish the data type of a variable statements, just type IMPLICIT statements, or predefined Two or more variables are associated with each other when each is associated with the same storage location. They are partially associated, when part (but not all) of the storage associated with one variable is the same as part or all of the storage associated with another variable. Association and partial association occur when you use the COMMON statements, EQUIVALENCE statements, or actual arguments and dummy arguments in subprogram references. A variable is contains data considered defined if the storage associated with it of the same type as the name. A variable can be defined before program execution by a DATA assignment or input statement. 1f variables associated) of different data types with the same storage variable is defined (for example, other variable becomes undefined. 2.4.1 Data Type Type declaration variables are to COMPLEX DOUBLE statement by or during execution by an are associated (or partially location, and the value of one assignment), the value of the Specification statements (see Section 5.2) represent specified data types. VARI1 PRECISION VAR2 specify that For example: given FORTRAN STATEMENT COMPONENTS These statements indicate that the variable VARl is to be associated with an 8-byte storage location that is to contain complex data, and that the variable VARZ2 is to be associated with an 8-byte double precision storage cation. The IMPLICIT statement (see Section 5.1) has a broader scope. states that, 1in the absence of an explicit type declaration, variable with a name that begins with a 'specified letter, or letter within a specified range, 1is to represent specified It any any data only once. over the An type a type. You can explicitly specify the data explicit data type specification implied by an IMPLICIT statement. Character type specify that the length type of takes a variable precedence declaration statements (see Sections 5.1 given variables are to represent character specified. CHARACTER*72 For example: INLINE CHARACTER NAME*12, NUMBER*9 These statements indicate that the variables are to be associated with storage locations of lengths 72, 12, and 9, respectively. Passed length character arguments are used process character strings of different to character and 5.2.2) values with argument has a length INLINE, NAME, and NUMBER containing character data within a lengths. specification of single The (*). subprogram passed length For example: CHARACTER* (*) CHARDUMMY The passed argument 2.4.2 length (see Data Type by In the absence statements, all N are assumed to with any Real 2.5 character Chapter other argument assumes the length of the actual 6). Implication of either IMPLICIT statements or explicit type variables with names beginning with I, J, K, L, M, or be integer variables. Variables with names beginning letter are assumed to Variables be real Integer variables. For example: Variables ALPHA JCOUNT BETA ITEM TOTAL NTOTAL ARRAYS An array single 1is a group of contiguous storage locations associated with a symbolic name, the array name. The 1individual storage locations, called array elements, are referred to by a subscript appended An of to array can figures column of the array name. Section have from one to seven 1is a one-dimensional figures is a 2.5.2 discusses dimensions. array. A two-dimensional array. subscripts. For example, table of more To refer to a a column than one specific FORTRAN STATEMENT COMPONENTS value in this array, you must specify both its row number and its a 1is pages several covers A table of figures that column number. locate a value in this array, you must To array. three-dimensional specify the row number, column number, and a page number. The following FORTRAN statements establish arrays: e Type declaration statements e The DIMENSION statement ® The COMMON statement (see Section 5.2) (see Section 5.3) (see Section 5.4) These statements contain array declarators (see Section define the name of the array, the number of dimensions and the number of elements in each dimension. 2.5.1) that in the array, An element of an array is considered defined if the storage associated of the same data type as the array name (see data contains it with defined be can An array element or an entire array Section 2.5.4). An array element can be before program execution by a DATA statement. statement; defined during program execution by an assignment or input be defined during program execution by an can array entire an and input statement. 2.5.1 ' Array Declarators An array declarator specifies the symbolic name that identifies an array within a program wunit and indicates the properties of that array. An array declarator a a d (d[,d]l has the ...) The symbolic name of (Section 2.1 gives the A dimension declarator; upper form: bound as the array, that 1is, the form of a symbolic name.) 4 can specify both a lower array name. bound and an follows: [d1l:]du dl du The lower bound of the dimension. The upper bound of the dimension. The number of dimension declarators indicates the number of dimensions in the array. The number of dimensions can range from one to seven. The value of the lower bound dimension declarator can be negative, zero, or positive. The value of the upper bound dimension declarator must be greater than or equal to the corresponding 1lower bound dimension declarator. The number of elements in the dimension 1is du-dl+1l. If a lower bound is not specified, it is assumed to be 1, and the value of the upper bound specifies the number of elements in that dimension. For example, a dimension declarator of 50 indicates that the dimension contains 50 elements. FORTRAN STATEMENT COMPONENTS Each dimension bound is an integer arithmetic expression in which: e Each operand 1is an integer constant, an integer argument, or an integer variable in a COMMON block e Each operator is a +, -, *, /, or dummy ** operator Note that array references and function references are not allowed in dimension bounds expressions. Dimension bounds that are not constant expressions can be used in a subprogram to define adjustable arrays. You can use adjustable arrays within a single subprogram to process arrays with different dimension bounds by specifying the bounds as well as the array name as subprogram arguments. See Section 6.1.1.1 for more information on adjustable arrays. Dimension bounds that are not constant expressions are not permitted in a main program. The number of elements number of elements in an array is equal in each An array name can appear unit. 2.5.2 to the product of the in only one array declarator within a program Subscripts A subscript qualifies expressions, called that determine which subscript is appended A dimension. subscript has the an array name. A subscript 1is a 1list of subscript expressions, enclosed in parentheses, element in the array 1is referred to. The to the array name it qualifies. form: (s[,s]...) A subscript expression. A subscripted array reference must contain one subscript expression for each dimension defined for that array (one for each dimension declarator). Each subscript can be any valid arithmetic expression. If the value of a subscript is not of type integer, it is converted to an integer value by truncation of any fractional part before use. 2.5.3 Array Storage As discussed earlier in this section, you can think of the dimensions of an array as rows, columns, and levels or planes. However, FORTRAN always stores an array in memory as a linear sequence of values. A one-dimensional array is stored with its first storage location and its last element in the last the sequence. A multidimensional array is stored subscripts vary most rapidly. This is called the progression." For example, Figure 2-1 shows array and three dimensions. element in the first storage location of so that the leftmost "order of subscript storage in one, two, FORTRAN STATEMENT COMPONENTS 1-Dimensional Array BRC (6) F[BRC(H l 2|BRC(2)[ BIBRC(3)I 4IB'RC(4)| sl BRC (5) | GlBRC(G)J Memory Positions BAN (1,1) 4 BAN (1,2)] 7 { BAN (1,3) |10 | BAN (1,4) BAN (2,1) 5 |BAN (2,2)| - —l W N =Y 2-Dimensional Array BAN (3,4) BAN (2,4) BAN (3,1){ 6 |BAN (3,2}| 9| BAN (3,3)| 12| BAN (3,4) 8| BAN (2,3} |1 Memory Positions 3-Dimensional Array BOS (3,3,3) 19 | BOS (1,1,3) | 22 BOS (1,2,3) | 26 | BOS (1,3,3) 20 | BOS (2,1,3) | 23|B0OS (2,2,3) | 26 | BOS (2,3,3) 10 | BOS (1,1,2) { 13|B0S (1,2,2) | 16 | BOS (1,3,2) BOS (3,3,3) 11 | BOS(2,1,2) | 14|B0S (2,2,2) | 17 | BOS (2,3,2) 1]180S(1,1,1)| 4 |BOS (1,2,1)| 7 | BOS {1,3,1) 18 | BOS (3,3,2) ,BOS (2,1,1) | 5 | BOS (2,2,1) | 8 | BOS (2,3,1) BOS (3,1,1) BOS (3,2,1) BOS (3,3,1) Memory Positions Figure 2.5.4 Data Type of 2-1 Array Storage an Array The data type of an array is specified the same way as the data type of a wvariable. That 1is, the data type of an array is specified implicitly by the initial letter of the name, or explicitly by a type declaration statement. All the values in an array have the same data type. Any value assigned to an array element 1is converted to the data type of the array. If an array is named in a DOUBLE PRECISION statement, for example, the compiler allocates an 8-byte storage location element of the array. When a value of any type 1s assigned element of that array, it is converted to double precision. 2.5.5 Array for to each any statement, you can specify an array indicate that the entire array is to be name used References Without In the following types without a subscript, (or defined): e Type e COMMON e DATA of to declaration statement statement Subscripts statements FORTRAN e EQUIVALENCE e FUNCTION e SUBROUTINE @ ENTRY e Input/output STATEMENT COMPONENTS statement statement statement statement statements You can also use unsubscripted array names as actual arguments 1in references to external procedures. The use of unsubscripted array names in all other types of statements is not permitted. 2.5.6 Adjustable Arrays Adjustable arrays dimensions. the allow To wuse subprograms an adjustable array bounds, as well as its 6 for more information. CHARACTER manipulate arrays of variable array in a subprogram, you specify name, Chapter 2.6 to character subprogram arguments. See SUBSTRINGS A character substring is a contiguous or character array element. A as substring reference has segment one of of the a character following variable forms: v(lel]:[e2]) a(s[,sl...) (lel]:[e2]) A character variable A character array A subscript expression. v name. a S name. . el A numeric position of expression that the substring. specifies the leftmost character rightmost character e2 A numeric expression that position of the substring. Character positions within numbered from to left a right, specifies character beginning variable at specifies the substring and ending with the beginning with the seventh <character variable LABEL. CHARACTER*8 XVERSUSY, then If the the substring the 1. has array element example, second character position of the variable LABEL(2:7) or For LABEL a value has of a are LABEL(2:7) position character value VERSUS. of FORTRAN If the value of the numeric integer, it 1is converted fractional part before use. The value of 1 STATEMENT COMPONENTS expression el or e2 1is not of type to an integer value by truncation of any the numeric expressions, LE. el .LE. e2 .LE. el and e2, must be such that: 1len where len is the length of the character variable or array element. If el If e2 is omitted, FORTRAN assumes FORTRAN assumes that el equals 1. that e2 equals len. is omitted, For example, NAMES(1,3) (:7) specifies the substring starting with the first character position and ending with the seventh character position of 2.7 the character array element NAMES(1,3). EXPRESSIONS An expression represents a single value. It can be a single basic component, such as a constant or variable, or a combination of basic components with one or more operators. Operators specify computations to be performed, using the values of the basic components, to obtain a single value. Expressions are classified as arithmetic, character, relational, or logical. Arithmetic expressions produce numeric values; character expressions produce character values; and relational and 1logical expressions produce logical values. 2.7.1 Arithmetic Expressions Arithmetic arithmetic single expressions operators. numeric are formed with arithmetic elements and The evaluation of such an expression yields a value. An arithmetic element can be any of the following: ) A numeric constant ° A numeric variable ) A numeric ) An arithmetic expression enclosed ® An arithmetic function array element in parentheses reference The term "numeric," as used above, can also be interpreted to include logical data, 'since logical data is treated as integer data when used in an arithmetic context. FORTRAN Arithmetic values of result. STATEMENT COMPONENTS operators specify a computation to be performed arithmetic elements. They produce a numeric The operators and their meanings Operator These two the as a are: Function ** Exponentiation * Multiplication / Division + Addition - Subtraction operators are elements. called The binary plus (+) operators, and minus Any arithmetic operator can be except as noted in Table 2-3. used with or array element must have arithmetic expression. Table 2-3 shows the allowed and exponent data types for Allowed a and unary and because unary each an arithmetic any valid defined 2-3 for minus is symbols are used also value with unary element arithmetic before combinations and result data the exponentiation operator. Table Combinations plus (-) operators when written immediately preceding denote a positive or negative value. A variable used in an using value to element, it types can of be base Exponentiation Exponent Base Integer Real Double Integer Integer No No No Real Real Real Double No Double Double Double | Double No Complex Complex No No Note: only A by negative an integer zero value zero-value cannot element element; be Complex No can and be an exponentiated element with a exponentiated by another element. In any valid exponentiation, the result has the same data type as the base element, except in the case of a real base and a double precision exponent. The result in this case is double precision. FORTRAN STATEMENT COMPONENTS in an order Arithmetic expressions are evaluated The precedence associated with each operator. by a determined precedence of the is: operators Operator Precedence *x First * and / Second + and - Third (such as + and -) When two or more operators of egual precedence long as the order of as order, any in evaluated be can they appear, evaluation is algebraically equivalent to a left-to-right order of Exponentiation, however, is evaluated from right to left. evaluation. is evaluated B**C For example, A**B**C is evaluated as A** (B**C); then A is raised to the resulting power. first, Use of Parentheses - You 2.7.1.1 particular evaluation. of order can use When parentheses part of an to force a expression is and the that part 1is evaluated first, enclosed in parentheses, resulting value is wused in the evaluation of the remainder of the the the numbers below In the following examples, expression. operators indicate the order of the evaluations. 6 3 N> + 4 / 2 7 (4+3) 4 ((4+3) * 1 2 2 T As shown in the third and fourth examples above, expressions within expression, do parentheses are evaluated according to the normal order of precedence, unless you override the order by using parentheses within parentheses. Nonessential parentheses, as affect expression evaluation. 4 + (3*2) - in the following not (6/2) 1is often The use of parentheses to specify the evaluation order In such computations. numerical y high-accurac in important computations, evaluation orders that are algebraically equivalent might not be computationally eguivalent when processed by a computer. FORTRAN 2.7.1.2 an by Data Type arithmetic the of an Arithmetic expression expression is STATEMENT also is of of that associated with is as follows: Data each data Expression the data types are combined in expression and the data type of COMPONENTS same data an the type. data If every type. If the The rank element value elements expression, the resulting value Type of different evaluation depend on assigned to in produced of a that rank each data type Rank Logical 1 Integer*2 2 Integer*4 3 Real 4 Double - type, precision (Low) 5 Complex 6 (High) The data type of the value produced by an operation on two arithmetic elements of different data types 1is the data type of the highest-ranked element in the operation. For example, the data type of the wvalue resulting from an operation on an integer and a real element is real. The data last type of operation determined ) as an in expres:tion that is the exrression. data The type data of the type of Integer operations -- Integer fraction that can rounded. For example: 1/3 ® Real + value 1/3 of + the is operations are or elements. Any data type by expression however, division is that only from division is 0, not 1. -- operations are performed only on integer and logical expression Real combinations integer giving then in operation multiplication result performed in an arithmetic arithmetic, any is truncated, not 1/3 this operations elements ) of expression follows: on integer elements. (Logical entities used context are treated as integers.) In integer The result an is real, elements present a fractional each evaluated the is of using real statement performed performed on are part Y on that converted equal to to 0. arithmetic. = (I/J)*X, I and result and J an and real real The Note, integer a real X. Double precision operations -- Any real or integer element in a double precision operation is converted to double precision data type by making the existing element the most portion of a double precision datum. The least portion is 0. The expression is then evaluated precision arithmetic. significant significant in double FORTRAN STATEMENT COMPONENTS does Converting a real element to a double precision element For example, the real number not increase its accuracy. ° 0.3333333 is converted to 0.3333333000000000D0 not to 0.3333333333333333D0 Complex ) operations -- In an operation that contains any complex element, integer elements are converted to real data Double precision elements are type, as previously described. converted to real data type by rounding the least significant The real element thus obtained is designated as the portion. The the imaginary part is 0. real part of a complex number; expression is then evaluated using complex arithmetic and the resulting value is of complex data type. Character Expressions 2.7.2 elements and character Character expressions consist of character The evaluation of a character expression yields a single operators. value of character data type. A character element can be any one of the following: constant o A character ° A character variable ° A character array element ° A character substring ° A character expression enclosed in parentheses ) A character function reference The only character operator is the concatenation operator (//). A character expression is a sequence of one or more character elements separated by the concatenation operator. A character expression has the character element form: [//character element]... The value of a character expression is a character string formed by left-to-right concatenations of the values of the elements successive of the character expression. The length of a character expression is For example, the the sum of the lengths of the character elements. value of the character expression 'AB'//'CDE' is 'ABCDE', which has a length of 5. expression. character Parentheses do not affect the value of a example, the following character expressions are equivalent. ('ABC'//'DE') //'F! "ABC'///('DE'//"F') For FORTRAN Each of these character STATEMENT expressions has COMPONENTS the value 'ABCDEF'. If a character element in a character expression contains spaces, spaces are included in the value of the character expression. example, 'ABCA'//'DAE'//'FA' has a value of 'ABCADAEFA'. The are order in which evaluated 1is the For the character elements of a character expression determined by the compiler even if parentheses are present. 2.7.3 A Relational relational Expressions expression consists of two arithmetic expressions or two character expressions, separated by a relational operator. The value of the expression is either true or false, depending on whether or not the stated relationship A relational expressions exists. operator tests for a relationship between or between two character expressions. two arithmetic These operators are: Operator The Relationship .LT. Less than .LE. Less than .EQ. Equal to .NE. Not .GT. Greater than .GE. Greater than or equal required part of each delimiting periods Complex expressions operators. Complex imaginary parts are In an arithmetic first evaluated both to determine For example:; expression related are equal equal to to only by if their to operator. the .EQ. and .NE. corresponding real and equal. relational expression, the arithmetic expressions are to obtain their values. These values are then compared This a can be entities exists. APPLE+PEACH are equal or .GT. whether the relationship stated by the operator PEAR+ORANGE states the relationship, "The sum of the real variables APPLE and PEACH 1is greater than the sum of the real variables PEAR and ORANGE." If tiat relationship exists, the value of the expression is true; if not, the value of the expression is false. FORTRAN STATEMENT COMPONENTS expressions are In a character relational expression, the character These values are then first evaluated to obtain their values. compared to determine whether the relationship stated by the operator In character relational expressions "less than" means exists. "precedes in the ASCII collating seqguence," and "greater "follows in the ASCII collating sequence." For example: 'AB'//'22Z"' .LT. than" means 'CCCCC! That 'CCCCC'. is less than 'ABZZZ' This expression states that 1If relationship does exist, so the value of the expression is true. 1is expression the of value the exist, not the relationship stated does false. If the two character expressions in a relational expression are not the shorter one is padded on the right with spaces the same length, until the lengths are equal. 'ABC' .EQ. .LT. 'AB' For example: 'ABCAAA' 'C! The first relational expression has a value of true even though the lengths of the expressions are not equal, and the second has a value of true even though 'AB' is longer than 'C'. All relational operators have the same precedence. a higher precedence have operators character Arithmetic and than relational operators. to You can use parentheses, as in any other arithmetic expression, a in expressions arithmetic the of evaluation of alter the order However, arithmetic and character operators relational expression. are evaluated before relational operators so you need not enclose the entire arithmetic or character expression in parentheses. Two numeric expressions of different data types can be compared by a relational expression. 1In this case, the value of the expression with the lower-ranked data type is converted to the higher-ranked data type . before the comparison is made. Logical Expressions 2.7.4 A logical expression can be a single logical element, or a combination A logical expression of logical elements and 1logical operators. yields a single logical value, true or false. A logical element can be any of the following: ® An integer or logical constant ° An integer or logical variable ® An integer or logical array element ® A relational expression ) A logical expression enclosed in parentheses ) An integer or logical function reference FORTRAN The logical operators Operator STATEMENT COMPONENTS are: Example .AND. A .AND. .OR. A .OR. Meaning B B Logical if, and conjunction: only if, both Logical disjunction expression both, . XOR. A .XOR. B is .EQV. (inclusive OR): 1if A either B Logical but the have the B is The When .NOT. delimiting A expression the same equivalence: periods of Logical negation: if, only and logical the B, expression false, or is false if, the the A operators is are or if is vice both value. expression if, and only if, both A and B logical value, whether true or .NOT. or true true. elements A true Logical exclusive OR: true if A 1is true and versa; .EQV. is the expression is A and B are true. is true have the false. same expression 1is true false. required. a logical operator operates on logical elements, the resulting type 1is logical. When a logical operator operates on integer elements, the logical operation is carried out bit-by-bit on the data corresponding integer operator bits of the internal (binary) representation of the elements. The resulting data type is integer. When a logical combines first converted to as for two integer integer and an integer elements. 1logical values, the logical value, The value then the operation is carried resulting data type is integer. is out A logical expression is evaluated according to an order of precedence assigned to its operators. Some logical expressions can be evaluated before all their subexpressions are evaluated. For example, if A is .FALSE., the -FALSE.. The without expression value of the A .AND. expression (F(X,Y) can be .GT. 2.0) determined evaluating by .AND. B is testing A F(X,Y). Thus, the function subprogram F may not be called, and side-effects resulting from the call, for example changing variables in COMMON, cannot occur. The following list summarizes all the operators that can appear logical expression, in the order in which they are evaluated: Operator Precedence * % First *,/ Second ty=4// Third (Highest) Relational Operators Fourth .NOT. Fifth .AND. Sixth .OR. Seventh .XOR. , .EQV. Eighth in a FORTRAN STATEMENT COMPONENTS Operators of equal rank are evaluated left from For right. to example: A*B+C*ABC .EQ. X*Y+DM/ZZ .AND. .NOT. K*B .GT. TT The sequence in which this logical expression is evaluated is: (((A*B)+(C*ABC)).EQ.((X*Y)+(DM/ZZ))).AND.(.NOT.((K*B).GT.TT)) As in arithmetic expressions, you can use normal sequence of evaluation. parentheses . to Two logical operators cannot appear consecutively, unless operator is .NOT.. alter the the second CHAPTER ASSIGNMENT Assignment or statements character assigning the character substring. The define substring. resulting value STATEMENTS value of a do this by evaluating to the assignment statements are: ) Arithmetic assignment statement ) Logical © Character ] ASSIGN assignment arithmetic the on arithmetic v = A numeric and element, or array statement STATEMENT assignment on element element, expression statement The array array an statement assignment ARITHMETIC ASSIGNMENT expression variable, variable, four 3.1 The the They 3 statement assigns right of the equal sign left of the equal sign. the assignment statement has the to the the value of the mathematics. It numeric variable or form: e v variable or array element. e An expression. The equal means "is sign does not mean "is equal replaced by." For example: KOUNT = KOUNT + the undefined, references symbolic values in The expression the wvariable example, a the real or "replace the sum name must on have expression must as in 1 This statement means, variable KOUNT with constant 1." Although to," yield a the current value of the of that current value and the the left been previously on the value array element expression that of right that the of the conforms to which produces a equal assigned it equal to is value the to sign to all integer integer can be symbolic sign. requirements of assigned. For be greater than 32767 is ASSIGNMENT STATEMENTS 1if invalid variable. the entity on the left of the equal sign is an INTEGER*2 the If the variable or array element on the left of the equal sign has assigns t statemen the right, the on on expressi the as type data same If the data types are different, the value of the the value directly. is converted to the data type of the entity on the left of expression Table 3-1 summarizes the equal sign before it is assigned. conversion rules for assignment statements. Table - the 3-1 Conversion Rules for Assignment Statements Expression Variable or (E) Array Element Integer, Logical, or Octal Constant Real Double Precision Complex Truncate E to integer and assignto 'V Truncate E to integer and assign toV Truncate real part ofE to integer and assign to V; TM) Integer or Logical Assign Eto V imaginary part of E is not used Real Append fraction (.0) to E and AssignEtoV assign to'V Double Precision Append fraction (.0) to E and as- sign to MS* porV; LS* tion of portion of Vis 0 Assign MS* por- Assign real part LS* portion of inary part of E AssignEtoV Assign real part of E to MS* por- tion of E to V; E is rounded Assign E to MS* portion of V; of E to V;imag- is not used tion of V; LS* portion ofV is zero, imaginary LS* portion of Vis0 part of E is not used Complex Append fraction (.0) to E and assign to real part of V; imaginary part of Vis 0.0 Assign E to real part of V; imaginary part of Vis 0.0 Assign MS* portion of E to real part of V; LS* portion of E is rounded; imaginary part of V is 0.0 * MS = most significant (high order); LS = least significant (low order) Assign EtoV ASSIGNMENT Examples of valid and invalid STATEMENTS assignment statements are: valid BETA = PI 3.14159 = SUM = =1./(2.*X)+A*A/(4.%* (X*X)) SUM+1. Invalid 3.14 = A-B (entity on variable -J = I*%*4 (entity the or on left array the must be a element) left must not be signed) ALPHA = ((X+6)*B*B/(X-Y) (left and right parentheses do not- balance) ICOUNT = 'A'//'B' (expression on character data the 3.2 LOGICAL ASSIGNMENT left is right not must type, of if not the character be of entity data on type) STATEMENT The logical assignment statement assigns the value of the logical expression on the right of the equal sign to the variable or array element on the left of the equal sign. See Table 3-1 for conversion rules. The logical assignment statement vV = A logical variable A logical expression. has the form: e The variable logical data or array or array element type. 1Its value element. on the can be left of the undefined. Values, either numeric or logical, must have to all symbolic references that appear expression must yield a logical value. of PAGEND logical assignment = .FALSE. PRNTOK ] Examples LINE .LE. ABIG A .GT. B = 132 .AND. statements .AND. A .GT. .NOT. C equal are: A must be of been previously assigned 1in the expression. The PAGEND .AND. sign .GT. D ASSIGNMENT STATEMENTS 3.3 CHARACTER ASSIGNMENT STATEMENT The character assignment statement assigns the value of the character the right of the equal sign to the character variable, expression on array element, or substring on the left of the equal sign. The character assignment statement has the form: vV = e A character variable, A character array element, or substring. expression. 1length the If the length of the character expression is greater than the character variable, array element, or substring, the character of expression is truncated on the right. of 1length If the length of the character expression is less than the element, or substring, the character array variable, character the is filled on the right with spaces. expression be can sign egqual the of 1left Although the symbolic name on the values must have been previously assigned to all symbolic undefined, in the expression. references assign You cannot The expression must be of character data type. numeric value to a character variable, array element, or substring. a affect not Note that assigning a value to a character substring does the character variable or array element that in positions character If a character position outside of are not included in the substring. has a value previously assigned, it remains unchanged, substring the and if the character position is undefined, it remains undefined. Examples of valid and invalid character assignment statements follow. variables and arrays in the examples are of character all that Note data type. valid FILE = 'PROG2' REVOL (1) 'MAR'//'CIA' = LOCA(3:8) = 'PLANTS' TEXT(I,J+1) (2:N-1) = NAME//X Invalid 'ABC' = CHARS CHARS = 25 (element on left must be a character variable, array element, or substring reference) (expression on right must be of character data type) ASSIGNMENT STATEMENTS ASSIGN 3.4 ASSIGN STATEMENT integer The ASSIGN statement assigns a statement label value to ana transfer specify to used be then can variable The variable. destination in a subsequent assigned GO TO statement (see Section 4.1.3) L4 The ASSIGN statement has the form: ASSIGN s TO v The label of an executable statement in the same program unit the ASSIGN as statement. An integer variable. The ASSIGN statement assigns the statement number to the variable. It is similar to an arithmetic assignment statement, with one exception: the variable becomes defined for use as a statement label reference and becomes undefined as an integer variable. The ASSIGN statement must be executed before the assigned GO TO (s) in which the assigned variable is to be used. The ASSIGN statement t statemen and the assigned GO TO statement(s) must occur in the same program unit. For example: ASSIGN TO NUMBER 100 This statement associates the variable NUMBER with the statement labelg Arithmetic operations on the variable, as in the followin 100. statement then become invalid, since a statement label cannot be altered. NUMBER = NUMBER+1 The next statement dissociates NUMBER from statement 100, assigns it an integer value 10, and returns it to its status as an integer variable. NUMBER = 10 The variable NUMBER can no an assigned GO TO (ERROR must have been defined as an longer be used in statement. Examples of ASSIGN ASSIGN 10 statements are: TO NSTART ASSIGN 99999 TO KSTOP ASSIGN 250 TO ERROR integer variable) CHAPTER 4 CONTROL STATEMENTS Statements are normally executed in the order in which they are However, you may interrupt normal program flow to transfer written. control to another section of the program or to a subprogram. of control from a given point in the program may occur every Transfer time that point is reached in the program flow; a decision made at that point. or it may be based on You use the FORTRAN control statements to transfer control to a point within the same program unit or to another program unit. These statements also govern iterative processing, suspension of program execution, and program termination. The control @ statements are: GO TO statements —-- transfer control within a program unit control, or e END and ELSE, THEN, IF ELSE THEN, IF statements of blocks execute ly conditional -statements IF e DO statement -- specifies iterative processing e CONTINUE statement -- transfers control to the next executable e CALL statement —-- invokes a subroutine subprogram e RETURN statement —-- returns control from a subprogram e PAUSE statement -- temporarily suspends program execution e STOP statement —-- terminates program execution e END statement -- marks the end of a program unit e IF statements —-- conditionally conditionally execute a statement transfer statement The following sections describe these statements, giving and to the calling program unit examples of use. their forms CONTROL STATEMENTS control within GO TO 4.1 GO GO TO TO STATEMENTS statements transferred or The to one set types of the of statements, GO TO same based statement ® Computed GO TO statement ® Assigned GO TO statement GO TO a statement Unconditional program every on the unit. time GO value Control TO of is an is executed, expression. are: statement Unconditional GO TO Statement unconditional statement The a to ® 4.1.1 The of three transfer either every unconditional GO TO GO time TO statement it is GO TO statement an executable label of the GO statement. TO The unconditional GO identified by the Examples control to the has the same form: s The executable transfers executed. GO TO in the same TO statement transfers control specified 1label. The 1label statement of statement in the same statements program unit as program unit as to the statement must identify an the GO TO statement. are: GO TO 7734 GO 4.1.2 TO 99999 Computed The computed GO the value an of GO TO A list GO TO Statement TO statement transfers control to expression within the statement. (slist)[,] a statement based on e slist by of commas. one or The more list labels of of labels executable is called An arithmetic expression in the range 1 to number of statement labels in the transfer The computed necessary, GO TO converts statement the evaluates resulting value the to statements the transfer separated list. n (where list). expression integer data is transferred to the statement label in position e in list. For example, if the list contains (30,20,30,40), of e is 2, control is transferred to statement 20. n e type. the and is the and, if Control transfer the value CONTROL STATEMENTS 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 of computed GO TO statements are: GO TO (12,24,36),INDEX GO TO (320,330,340,350,360), SITU(J,K)+1 4.1.3 Assigned GO TO Statement The assigned GO TO statement transfers control to a statement label The relationship between the 1is represented by a variable. that be -established by an variable and a specific statement label must the transfer destination can be changed, Thus, ASSIGN statement. depending on the most recently executed ASSIGN statement. The assigned GO TO statement has the form: GO TO v[[,](slist)] An slist integer variable. statements' separated A list of one or more labels of executable slist does not affect statement execution and can be by commas; omitted. The assigned GO TO statement transfers control to the statement label was most recently assigned to the variable v. whose The variable v must be integer data type and must have been assigned a statement value label by an ASSIGN statement (not an arithmetic assignment statement) before the GO TO statement is executed. (s) The assigned GO TO statement and its associated ASSIGN statement must exist in the same program unit. Statements to which control is transferred must be executable statements in the same program unit. Examples of assigned GO TO statements are: ASSIGN 200 GO TO IGO TO 450 TO IGO Equivalent to GO TO 200. ASSIGN IBEG GO TO IBEG, (300,450,1000,25) Equivalent to GO TO 450. CONTROL STATEMENTS IF 4.2 1IF STATEMENTS IF statements a statement conditionally or block of transfer control, statements. or The three ELSE IF conditionally types of IF execute statements are: For e Arithmetic IF e Logical statement ® Block each IF type, statement IF statements the or decision block of expression within the 4,2.1 IF The Arithmetic arithmetic statements, The statement arithmetic IF IF (e) An arithmetic sl, THEN, to transfer statements IF ELSE, END IF) control or to based the evaluation on execute statement. statement on the value statement s2, is THEN, the of an Statement IF based (IF transfers of has an the control arithmetic to one of three expression. form: s3 e expression. sl,s2,s3 Labels of executable statements in the same program All three labels (sl,s2,s3) are required; however, refer to three different statements. You can use one refer The to the statement arithmetic parentheses. labels in If the the Equal to Greater IF This to of statement IF as 100 to they or two need not labels to statement. the one expression of the (e) in three statement real variable follows: 0 IF IF evaluates Control statements passes Label sl Label s2 Label s3 to: follow. 50,50,100 transfers than the control 0 arithmetic less list, after 0 (THETA-CHI) is first transfers is: than statement THETA statement then value than Examples IF It transfer Less immediately unit. or only control equal if to THETA (NUMBER/Z*Z—NUMBER) to the is statement real greater 50 variable than if the CHI. Control passes CHI. 20,40,20 This statement transfers control integer variable NUMBER is even; if the value is odd. to statement 40 if the value of the it transfers control to statement 20 CONTROL STATEMENTS Logical 4.2.2 A IF Statement 1IF logical The statement. statement decision conditionally execute to executes a single FORTRAN the statement is based on the value of a logical expression within the logical IF statement. The logical IF statement has the form: st (e) IF A logical expression. st any be The statement can A complete FORTRAN statement. , statement IF block a , statement DO a except statement e executabl an END statement, or another logical IF statement. expression (e). (st) is statement the true, is n expressio the of If the value executed. If the value of the expression is false, control transfers The logical IF statement first evaluates the logical to (st) is not executed. Examples of logical (J IF (REF(J,K) IF (ENDRUN) IF statements are: .OR. 4 .GT. IF J .LT. .NE. HOLD) 1) GO TO 250 REF(J,K) = REF (J,K) *(-1.5D0) CALL EXIT Block IF Statements 4.2.3 statements Block IF statements. The The statement the next executable statement after the logical IF. four block IF IF THEN ELSE IF ELSE END IF THEN conditionally statements are: execute blocks (or groups) of CONTROL These statements construct IF has the are used form: in STATEMENTS block 1IF constructs. The block 1IF (e) THEN block ELSE IF (e) THEN block ELSE block END IF A logical A sequence expression. block sequence Figure 4-1 constructs. is of zero called describes the or a more complete statement flow of FORTRAN statements. This block. control for four examples of block IF STATEMENTS CONTROL Flow of Control., Construct False IF (e) THEN block True END IF Ex\ecute block Y Test False e IF (e) THEN block True ELSE v blocks END IF Execute Execute block 4 block, Y IF (eq) THEN block4 ELSE IF (e5) THEN blocksy END IF ' Execute Execute block 4 blockoy Y IF (eq) THEN False _ block4 ELSE iF (ep) THEN block, ELSE IF (e3) THEN b|OCk3 ELSE blockg Execute Execute Execute Execute block4 block, blocks blockg END IF L \ Figure 4-1 ‘ Examples of 4-7 Block IF Constructs CONTROL Each block statement IF statement block. The STATEMENTS except the END IF statement statement block consists of following the block IF statement up to block statement in the IF construct. 1IF block conditionally executed based the preceding block statements. The IF statement THEN IF ELSE IF statement THEN statement block to be the begins following it is executed if IF THEN statement is true. The on a the is an of block IF of the optional if not values value executed (but the has all associated statements including) The the statement logical statement of The is in block expression that the next block expressions construct. logical value an the in the specifies logical a expression in the ELSE IF THEN statement is true and no preceding statement block in the block IF construct was executed. A block IF construct can contain any number of ELSE IF THEN statements. The ELSE statement specifies preceding statement block No block IF statement statement. The END IF statement After The ELSE the passes last construct terminates statement the next may be ELSE IF THEN END IF statement transferred Section and to 4.2.3.1 block. 4.2.3.3 ELSE statement block IF except construct. the END IF The END IF block END 1IF block a block IF is executed. time the from within describes - A THEN cannot restrictions Blocks IF statement nested IF statement You statement have statement labels. but control block IF construct. the on in label, statements examples block statement. control the each label executed, following statement a is statement one have describes statement block Note that you statement only 4.2.3.2 FORTRAN a statements can its Statement executable ELSE describes Section 4.2.3.1 in executed The Section the executable Consequently, The be the required. to statement. follow statement is optional. statement is can a statement block to be executed if no in the block IF construct was executed. of 1in block a IF can only statement constructs. constructs. block <can can transfer contain control out any of a but control cannot cannot transfer be transferred back into the block. control from one statement block %o overlap blocks. another. DO loops cannot contains a statement, each loop DO and statement statement, vice versa. must be wholly 4.2.3.2 Block IF Examples of IF THEN one statement the executes Form IF it and must If you contained END - IF The also use DO within simplest statements; loops one (e) THEN IF with this IF THEN TOTERR=TOTERR+ABS (ADJU) END IF block loop's terminal statement blocks, block. construct construct block. QUEST=ADJU/FNDVAL IF statement DO statement block (ABS(ADJU).GE.1.0E-6) a the Example block END When contain consists conditionally CONTROL STATEMENTS The statement block consists of all the statements between the IF THEN the END and IF statements. (e), The IF THEN statement first evaluates the 1logical expression If the value of e is true, the statement block ABS (ADJU) .GE.1.0E-6. is executed. If the value of e is false, control transfers to the next not executable executed. statement the after the block is statement; IF END an The following example contains a block IF construct with THEN ELSE IF statement. Example Form IF (el) (A. IF THEN GT. B) THEN =B D blockl F=A-2B ELSE IF (e2) block2 ELSE IF (A .GT. B/2.) D = B/2. THEN F=A - B/2. IF END IF END THEN Blockl consists of all the statements between the IF THEN and the ELSE block2 consists of all the statements between the IF THEN statements; ELSE IF THEN and the END IF blockl is than B but A If A is greater than B, If A is not greater statements. executed. is greater than block2 B/2, Iis executed. neither B/2, than greater not If A is not greater than B and A is next the to directly transfers control executed; is block2 nor blockl executable statement after the END IF statement. The following example contains a construct IF block ELSE an with statement. Example Form IF (e) THEN blockl (NAME .LT. 'N') THEN IFRONT = IFRONT + 1 T) =NAME (1:2) FRLET (IFRON ELSE ELSE block2 IF END IF END IBACK=IBACK + 1 IF Blockl consists of all the statements between the IF THEN and ELSE block2 consists of all the statements between the ELSE statements; and the END IF statements. If the value of the character variable NAME is less than is 'N', blockl executed. If the value of NAME is greater than or egual to 'N', block2 is executed. The following example contains a block IF construct with several IF THEN statements and an ELSE statement. ELSE CONTROL Form IF STATEMENTS Example (el) THEN IF (A blockl D .GT. B) =2B THEN F=A-B ELSE IF (e2) THEN ELSE block?2 IF (A .GT. C) THEN Z) THEN D =2¢C F=A-2¢C ELSE IF (e3) THEN ELSE block3 IF D (A F=A ELSE IF D = 0.0 F = A END There the -1 ELSE block4 END .GT. =12 are four statements IF statement blocks in this example. Each consists between the block IF statements listed below. Block Delimiting blockl IF block2 First THEN IF Block and ELSE IF first IF IF and THEN second block3 Second block4 ELSE ELSE and IF END greater If A is not greater than B but If A is not greater than B or greater than B, than B, THEN and ELSE IF is blockl is executed. is greater C but is not 4.2.3.3 Nested included nested 1in a block Block IF following it example block must of must not contains Form IF or %, Constructs construct statement ‘-block; The IF statement C, block4 - A be C, is than block block executed. 2%, block3 construct can be construct. But the contained within blocks. IF construct. Example (e) THEN IF (A .LT. IF blockl (e) THEN blocka IF ELSE 100) END ELSE block?2 IF THEN + 1 (ABS (A-AVG) .LE. INAVG = INAVG + 1 5.) ELSE blockb OUTAVG IF END = OUTAVG + IF ELSE OUTRAN = OUTRAN + END IF is IF completely statement nested is IF INRAN=INRAN END block2 executed. block another overlap a than greater executed. is ELSE THEN If A If A all Statements ELSE THEN of 1 1 THEN a CONTROL STATEMENTS If A is less than 100, blockl is executed. Blockl contains a nested block IF construct. If the absolute value of A minus AVG is less than or equal to 5, blocka is executed. If the absolute value of A minus AVG is greater than 5, blockb is executed. If A is greater than or equal to 100, block2 is executed; IF construct is not executed because it is not in block2. the nested CONTROL STATEMENTS DO 4.3 DO STATEMENT The DO statement statements 1in its specifies 1iterative processing. That range are executed repeatedly a specified 1is, the number of times. The DO statement DO s|,] has the form: v=el,e2[,e3] s The label physically of an executable statement. follow in the same program unit. The statement must \' An integer, el,e2,e3 Arithmetic real, or double precision variable. expressions. The variable v is the control variable; and el, e2, and e3 are the initial, terminal, and increment parameters, respectively. If you omit the increment parameter, a default increment value of 1 is used. The terminal statement of a DO appears in the DO statement. of the following statements: e GO TO e Arithmetic ® Any block ®¢ END statement e RETURN e DO IF IF statement statement, ENDIF statement range DO statement, of up The DO statement first determine the DO values initial, to except statement the use, is identified by the label that terminal statement must not be one The statement The The loop statement to for data includes including evaluates the terminal, the and the initial, and type the the statements terminal expressions terminal, increment of all the parameters control el, and that e2, increment are variable, follow statement. and e3 converted, if to parameters. before necessary. The value of the initial parameter is assigned to the control variable. The executable statements in the range of the DO loop are then executed If the (e2) repeatedly. increment must Conversely, The be if increment parameter greater e3 is (e3) than negative, parameter (e3) is positive, or equal el must cannot be to be the less zero. the terminal initial than or parameter parameter equal to (el). e2. CONTROL STATEMENTS The number of executions of the DO range, called the iteration count, by: is given e2 - el el where whose the [X] (the value of the expression) represents the largest integer magnitude does not exceed the magnitude of X and whose sign is as same the sign of X. If the iteration count is zero or negative, the loop is executed once. 4.3.1 DO Iteration Control iteration After each of the DO range, the following steps are executed: 1. The value of the increment parameter is 2. The 3. If the iteration transfers to the to the control iteration count statement 4. If the for algebraically added variable. is decremented. <count first another iteration count 1is greater than zero, control executable statement after the DO iteration of the is zero, range. execution of the DO statement terminates. double or Note that if the data type of the control variable is real the number of iterations of the DO range might not be what precision, is expected, because of rounding errors. a using by statement terminate execution of a DO You can also range that. transfers control outside the loop. the statement within its remains defined with statement The control variable of the DO current value. if other DO When execution of a DO loop terminates, 1loops share its most next the to outward transfers control statement, terminal enclosing DO loop in the DO nesting structure (Section 4.3.2). If no other DO loop shares the terminal statement, or if this DO statement 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 use the control variable for can you However, statement. DO the reference as a variable within the range. increment and terminating, initial, You can modify the within the loop without affecting the iteration count. parameters long as The range of a DO statement can contain other DO statements, Section 4.3.2 1loops meet certain requirements. DO nested these as describes these requirements. from loop a You can transfer control out of a DO loop, but not into Exceptions to this rule are described in the program. 1in elsewhere Sections 4.3.3 and 4.3.4. ) CONTROL Examples of DO This DO 100 iteration control STATEMENTS follow. K=1,50,2 statement specifies 25 iterations; K=49 during the final 27 iterations; J=-2 during ) the final IVAR=5 during the final iteration. DO 350 J=50,-2,-2 This statement iteration. DO 25 IVAR=1,5 This statement iteration. This specifies specifies DO NUMBER=5,40,4 is an invalid DO 40 M=2.10 5 iterations; statement; the statement label is missing. This is an invalid DO statement; it contains a decimal point instead of a comma. This example illustrates a common typing error. It is the valid arithmetic assignment statement: DO40M 4.3.2 = Nested 2.10 DO Loops A DO loop can contain one or more complete DO loops. The range of an inner nested DO loop must lie completely within the range of the next outer loop. Nested loops can share a terminal statement. Figure 4-2 illustrates nested loops. Correctly Nested DO B Incorrectly Nested Loops DO DO 45 K=1,10 B Dé 35 L=2,50,2 B | B DO 45 L 45 CONTINUE DO 15 B | 35 CONTINUE "15 CONTINUE DO - 4-2 Nested K=1,10 Dé 25 L=1,20 M=1,20 Figure Loops 30 M=1,15 25 CONTINUE | 30 CONTINUE DO Loops CONTROL 4.3.3 Control Within a to outer an loop If is two nested not or more the innermost transfer 4.3.4 A DO that or into loop. part the transfer has an an of and transfer transfer share control from an from outer the same terminal statement only from other transfer loop range to of to an that inner innermost it contains inner to loop an inner statement, within the statement loop, the an loop that extended Thus, the the statement govern transfer into the statement. The extended if the loop control range the the of the that transfer DO control of between rules if range out another statements A a outer the can loops to control loop. only 2. DO Any statements, following l. you Loops you range of constitutes because the shared loop. Range transfers executable The nested control Extended more DO However, from is locp loop, in permitted. transfer statement DC loop. can a Transfers STATEMENTS and statement the loop use of range range of a variable of the of made DO a control to of the statement DO from DO statement DO statement. extended extended must include the one back all first loop. statement the of control extended to statement execution statement control a a after returns is destination returns is if, not is range: permitted range of that change the CONTROL STATEMENTS Figure 4-3 transfers. illustrates valid and invalid Control Transfers Control Transfers GO TO 20 DO 35 K=1,10 B DO 15 L=2,20 20 DO 35 L=2,20 CONTINUE 20 A=B+C 30 D=E/F DO 35 M=1,15 35 CONTINUE 30 GO TO 50 GO TO 40 X=A*D DO 45 M=1,15 . . 40 X=A*D . 45 CONTINUE 50 CONTINUE L \_35 CONTINUE Range A=B+C 15 B Extended DO 50 K=1,10 i GO TO 20 Loop range Invalid valid DO extended 50 D=E/F . . GO TO 30 Figure 4-3 L . . GO TO 30 Control Transfers and Extended Range control CONTROL STATEMENTS CONTINUE 4.4 CONTINUE The CONTINUE statement. loop when arithmetic The STATEMENT statement It that IF, CONTINUE CONTINUE transfers control 1is wused primarily loop would otherwise or other statement prohibited has the as the end control form: to the terminal illegally statement. next executable statement with a of GO a DO TO, CONTROL STATEMENTS CALL 4.5 STATEMENT CALL The CALL statement executes a SUBROUTINE subprogram or other external It can also specify an argument list for the subroutine. procedure. (See Chapter 6 for greater detail on the definition and use of subroutines.) form: The CALL statement has the CALL s[([all,[al]l...)] s procedure; The name of a subroutine subprogram or other external a dummy argument associated with a subroutine subprogram or or external procedure. other a An actual argument. (Section 6.1 describes actual arguments.) If you specify an argument list, the CALL statement associates the It values in the 1list with the dummy arguments in the subroutine. first executable statement of the then transfers control to the subroutine. and order, The arguments in the CALL statement must agree in number, They can be the dummy arguments in the subroutine. type with data constants, references, substring variables, arrays, array elements, specifiers, or return alternate Hollerith constants, expressions, An unsubscripted array name in the argument list subprogram names. refers to the entire array. Examples of CALL are: (BASE,3.14159+X,Y,LIMIT,R(LT+2)) CALL CURVE CALL PNTOUT CALL statements (A,N,'ABCD') EXIT CALL MULT (A,B,*10,*20,C) The example last illustrates the use of statement label The asterisk lists. argument statement CALL in identifiers identifiers. label statement are *20 that *10 and indicates prefixed by asterisks (or ampersands (&)) are identifiers Label See Section 4.6. called alternate return specifiers. CONTROL STATEMENTS RETURN 4.6 RETURN The the program RETURN STATEMENT statement is that called RETURN used to transfer the subprogram. control from a subprogram It has the form: to [1i] The optional argument is used to indicate an alternate return from the subprogram. It can be specified only in subroutine subprograms. When specified, the value of i indicates that the ith alternate return in the actual argument 1list 1is to be taken. (See the second example below.) The value of i can be any integer constant or expression, for example, 2 or I+J. When a RETURN statement is to the calling program, reference (see Chapter 6). subroutine, statement or to the return You use in can the RETURN control following is the CALL in a function, control is returned at the statement that contains the function When a RETURN statement is executed in a returned CALL statement the executed 1label argument either statement that that was to specified SUBROUTINE CONVRT DATA (N), (N .GE. 10) = subroutine, the ith alternate units. You cannot (N,ALPH,DATA,PRNT,K) PRNT(N) THEN DATA (K+2) N executable the examples: DIMENSION IF as first list. use RETURN statements only in subprogram RETURN i form in function subprograms. statement the initiated = N-(N/10)*N N/10 DATA (K+1l) = N PRNT (K+2) = ALPH(DATA (K+2)+1) PRNT (K+1) = ALPH(DATA (K+1)+1) ELSE PRNT (K+2) END = ALPH(N+1) IF RETURN END In this example, first executable SUBROUTINE 50 60 IF(Z) 60, RETURN 70 RETURN 1 80 RETURN 2 control is returned statement following CHECK 70, to the calling the CALL CONVRT program at statement. the (X,Y,*,*,C) 80 END This example subroutine. return is executable the first than 0, shows how alternate returns If the value computed for Z can be is less included than 0, a taken, and the <calling program continues at statement following CALL CHECK. If Z equals alternate return (RETURN 1) is taken; and if Z the second alternate return (RETURN 2) is taken. in a normal the first however, is greater 0, Control is CONTROL STATEMENTS returned to the statement specified as the first or second alternate return argument in the CALL statement argument list. For example, CALL CHECK(A,B,&10,&20,C) Thus, RETURN 1 transfers control to statement label 10, and RETURN 2 transfers control to statement label 20. Note that if a subroutine includes an alternate return that specifies a value either 1less than or greater than the number of alternate return arguments, control is returned to the next executable statement after That is, the alternate returns are ignored. ensure that the value of i is within the range arguments. the CALL statement. Therefore, you should of alternate return CONTROL STATEMENTS PAUSE 4.7 PAUSE STATEMENT The PAUSE statement displays a message on The PAUSE statement PAUSE disp A temporarily the terminal has the suspends to permit program execution and you to take some action. form: [disp] character constant or a decimal digit string of 1 to 5 digits. The disp argument is optional. The effect of a PAUSE statement depends on how your program is being executed. If it is running as a batch job or detached process, the contents of disp are written to the system output file but the program is not suspended. If the program is running in interactive mode, the contents of disp are displayed at your terminal, followed by the prompt sequence, indicating that the program is suspended, and you should enter a command. For example, if the following statement is executed in interactive mode: PAUSE You will 'ERRONEOUS see the ERRONEOUS RESULT following RESULT DETECTED' display at the terminal: DETECTED $ If you do not specify a value for disp, you will receive the following message: FORTRAN You can PAUSE respond by typing one CONTINUE - execution resumes STOP - eXxecution is DEBUG - execution program. of the following at the next commands: executable statement terminated resumes under control of the DEBUG CONTROL STATEMENTS STOP 4.8 STOP STATEMENT The STOP statement terminates program execution. The STOP statement has the [disp] STOP disp form: A character constant or a decimal digit string of 1 to 5 digits. statement 1If you specify it, the STOP The disp argument is optional. displays the contents of disp at your terminal, terminates program execution, and returns control to the operating system. Examples of STOP statements STOP 98 STOP 'END OF RUN' are: CONTROL STATEMENTS END 4.9 END STATEMENT The END statement marks the end of a program unit. last source line of every program unit. It must be the The END statement has the form: END In a main program, execution if terminates. implicitly executed. control In a reaches the subprogram, END a statement, RETURN program statement 1is CHAPTER 5 SPECIFICATION STATEMENTS you 1let that statements Specification statements are nonexecutable other define and arrays, and variables initialize and allocate characteristics of the symbolic names used in the program. The specification statements are: statement —-- overrides the implied type data of e IMPLICIT e Type declaration statement -- explicitly defines the data type e DIMENSION statement -- defines the number of dimensions in array and the number of elements in each dimension an e COMMON statement -- defines one or more areas of symbolic of names specified symbolic names contiguous storage e EQUIVALENCE statement -- associates two or more entities e EXTERNAL statement -- defines the specified symbolic names e DATA statement -- assigns initial values to variables, and array elements before program execution e the same external storage with location procedure names PARAMETER statement -- assigns a symbolic name to a as arrays, constant value e PROGRAM statement -- assigns a symbolic name to a main program e BLOCK DATA statement -- establishes and defines common blocks and assigns initial values to entities contained in those unit common blocks The following sections detail these statements, and examples of use. giving their forms, SPECIFICATION IMPLICIT 5.1 STATEMENTS | IMPLICIT e STATEMENT By default, all names beginning with the 1letters I through N are assumed to be integer data, and all names beginning with any other letter are assumed to be real. The IMPLICIT statement overrides implied data typing of symbolic names. The IMPLICIT statement IMPLICIT typ One of has the form: typ(al,al...){[,typ(al,al...)]... the data type specifiers. (See Chapter 2, Table 2-2.) An alphabetic specification in either of the general forms: cl-c2, where ¢ 1is an alphabetic <character. The latter specifies a range of letters, from ¢l through <¢2, which occur in alphabetical ¢ or form must order. When you specify typ as CHARACTER*len, len specifies the 1length for character data type. Len 1is an unsigned integer constant or an integer constant expression enclosed in parentheses, and must be in the range 1 through 32767. The IMPLICIT statement assigns the specified data type to all symbolic names that begin with any specified 1letter, or any letter in a specified range, and which have no explicit data type declaration. For example: IMPLICIT INTEGER IMPLICIT REAL (I,J,K,L,M,N) (A-H, 0O-1%) These statements specifications. represent You IMPLICIT cannot Examples of label IMPLICIT the default in the statements. statements are: PRECISION (D) IMPLICIT DOUBLE IMPLICIT IMPLICIT COMPLEX (S,Y), LOGICAL*1 CHARACTER*32 (T-V) IMPLICIT CHARACTER*2 (W) (L,A-C) absence of any data type SPECIFICATION STATEMENTS Type Declaration 5.2 TYPE DECLARATION STATEMENTS Type declaration statements explicitly define the data type of There are two forms of type declaration specified symbolic names. type character and declarations, type numeric statements: declarations. The following rules apply to type declaration statements: 5.2.1 declaration statements must precede executable all e Type @ You can declare the data type of a symbolic name only once. @ You cannot label type declaration statements. statements Numeric Type Declaration Statements Numeric type declaration statements have the form: typ vi,vil... typ Any data type specifier except CHARACTER. The symbolic name of a variable, function subprogram, or array, statement function or an array declarator. You can use a numeric data type declaration statement to define arrays by including array declarators (see Section 2.5.1) in the 1list. A symbolic name can be followed by a data type length specifier of the form *s, where s is one of the acceptable lengths for the data type being declared. Such a specification overrides the length attribute that the statement implies, and assigns a new length to the specified If you specify both a data type length specifier and item. declarator, the data type length specifier goes first. Examples of numeric type declaration statements are: INTEGER COUNT, REAL MATRIX(4,4), SUM MAN,IABS LOGICAL SWITCH INTEGER*2 I, J, K, M12*4, Q, IVEC*4(10) REAL*8 WX1, WXZ, WX3*4, WX5, WX6*8 an array SPECIFICATION 5.2.2 Character Character type Type declaration CHARACTER([*1len] The Declaration symbolic an array An unsigned STATEMENTS Statements statements have the form: v([*len][,v[*1len]]... name of a variable, array, function subprogram, or declarator. len integer constant, 1in parentheses, or an of len specifies the enclosed The value an integer constant expression asterisk enclosed in parentheses. 1length of the character data elements. If you specify CHARACTER*len, len is for that 1list. If an item in the default length that 1list does not specification have a length specification, the item's length is len. But if an item does have length specification, it overrides the default length specified CHARACTER*1len. A length specifies have this specification a passed length If you do not specification asterisk Only specification specify a must be specification of length. of 0 a dummy (see invalid. You example, argument Chapter length, a length in the range 1 1is (for of to or a in CHARACTER* (*)) function name can 6). 1 is assumed. The 32767. Note that a can wuse a character length length type declaration statement to define arrays by including array declarators (see Section 2.5.1) in the 1list. If you specify both an array declarator and a length, the array declarator goes first. Examples of character CHARACTER*32 type declaration NAMES(100), statements SOCSEC(100)*9, follow. NAMETY This statement specifies an array NAMES comprising 100 32-character elements, an array SOCSEC comprising 100 9-character elements, and a variable NAMETY, 32 characters long. PARAMETER LENGTH=4 CHARACTER* (4+LENGTH) This (The statement specifies PARAMETER statement SUBROUTINE LAST, two 8-~character variables, LAST is described in Section 5.8.) statement elements and a defined by the and FIRST. S1 (BUBBLE) . CHARACTER LETTER(26), This FIRST specifies an BUBBLE * (*) array LETTER comprising dummy argument BUBBLE, calling program). CHARACTER*16 which has a 26 passed one-character length (it is BIGCHR* (30000%*2) ,QUEST* (5*INT (A)) This statement is invalid; the value large and the 1length specifier for expression. specified for QUEST is not an BIGCHR integer is too constant SPECIFICATION STATEMENTS DIMENSION 5.3 DIMENSION STATEMENT The DIMENSION statement defines the number of dimensions in and the number of elements in each dimension. an array The DIMENSION statement has the form: DIMENSION a(d)[,a(d)]... a(d) An array declarator a d (see Section 2.5.1). The symbolic name of an array. A dimension declarator. number of storage elements to each The DIMENSION statement allocates a storag e element is assigned to each One array named in the statement. of each storage element length The ion. dimens each in t array elemen The total number of array. the of is determined by the data type product of all the to equal is array an to ed assign storage elements array. For dimension example: declarators in the array declarator for that DIMENSION ARRAY (4,4), MATRIX(5,5,5) s of 4 Dbytes This statement defines ARRAY as having 16 real element ts of 4 bytes elemen r intege 125 having as MATRIX s define and each, each. and effect as the DIMENSION The VIRTUAL statement has the same form ibilit y with other versions of statement. FORTRAN. It is provided for compat For further information on arrays and on storing array elements, Section 2.5. You can also use array declarators statements. 1in type declaration and see COMMON However, in each program unit, you can use an array name in only one array declarator. You cannot label DIMENSION statements. Examples of DIMENSION statements are: DIMENSION BUD(12,24,10) DIMENSION X(5,5,5),Y(4,85),2(100) DIMENSION MARK (4,4,4,4) SPECIFICATION STATEMENTS COMMON 5.4 A COMMON COMMON STATEMENT statement storage. A defines symbolic one name omit or more contiguous identifies each areas block; (blocks) however, you of a symbolic name for one block in a program unit. This block blank common block. COMMON statements also define the order variables and arrays in each common block. the The COMMON statement COMMON has [/[cbl/] the can is of form: nlist[[,]/[cb]l/ nlist]... cb A symbolic If the A list name, first cb called a is blank, variable names, common you block can name. omit the cb can first pair be of blank. slashes. nlist of separated A common in name it cannot the array names, commas. block However, entry by can and array or be the same as a variable have the same name as a executable program. function, declarators array When you declare common blocks of the same name in different units, these blocks all share the same storage area when the units are combined into You can have only you can have several one The entities of character data and character data. Entities Thus, are in an blank named nlist assigned executable common should must be either all type. A common block program COMMON another executable program, storage in common of numeric cannot blocks on data contain a type both one-for-one or but all numeric basis. unit. For example, if one program unit contains the CENTS program INTEGER*2 COMMON unit contains the statement: MONEY MONEY When these program units are incorrect results may occur, is made to correspond to the CENTS. an entities assigned by a COMMON statement in one program unit agree in data type with entities placed in a common block by statement: and in or program program common blocks. the another program. block hame. subroutine, combined into an executable program, because the 2-byte integer variable MONEY high-order 2 bytes of the real variable SPECIFICATION An example of Main COMMON the COMMON statement STATEMENTS follows. Program Subprogram HEAT,X/BLK1/KILO,Q SUBROUTINE . COMMON CALL FIGURE FIGURE /BLK1/LIMA,R/ /ALFA,BET . . RETURN . END The COMMON statement in common block, and puts the main KILO and program puts Q in a named HEAT and X in common block, the blank BLK1l. The COMMON statement in the subroutine makes ALFA and BET correspond to HEAT and X in the blank common block, and makes LIMA and R correspond to KILO and Q You can use array arrays. in BLKI1. declarators in the COMMON statement to define SPECIFICATION STATEMENTS EQUIVALENCE 5.5 STATEMENT EQUIVALENCE The EQUIVALENCE statement partially or totally associates two or entities in the same program unit with the same storage location. The EQUIVALENCE statement has the form: EQUIVALENCE nlist more (nlist) [,(nlist)]... A list of variables, array elements, arrays, and character You must specify at separated by commas. references, substring least two of these entities in each list. entities the of all allocates statement The EQUIVALENCE parenthesized list beginning at the same storage location. one in subscript a in expression In an EQUIVALENCE statement, each substring reference must be an integer constant expression. or a of or type numeric data of either The entities in nlist must be You cannot make numeric entities and character type. data character entities equivalent. You can equivalence variables of different numeric data types. If you multiple components of one data type can share storage with a do, you if example, For single component of a higher-ranked data type. make an integer variable equivalent to a complex variable, the integer variable shares storage with the real part of the complex variable. Examples of EQUIVALENCE statements follow. DOUBLE PRECISION DVAR IARR(4) INTEGER*2 EQUIVALENCE (DVAR,IARR(1)) integer the elements of four This EQUIVALENCE statement makes the IARR occupy the same storage as the double-precision variable array DVAR. CHARACTER KEY*16, STAR*10 EQUIVALENCE (KEY,STAR) This EQUIVALENCE statement makes the first character of the character variables KEY and STAR share the same storage location. The character variable STAR is equivalent to the substring KEY (1:10). 5.5.1 Making Arrays Equivalent an element of When you make an element of one array eguivalent to sets equivalences also statement EQUIVALENCE the array, another the 1f Thus, between the corresponding elements of the two arrays. first elements of two equal-sized arrays are made eguivalent, both arrays share the same storage space. If the third element of a seven-element array is made equivalent to the first element of another array, the last five elements of the first five elements of the second array. array overlap the first SPECIFICATION STATEMENTS same assign to You must not attempt to use the EQUIVALENCE statement You For in also must not attempt to assign memory locations inconsistent way a that with the normal linear storage of array elements. element of another example, you cannot make the first element of one array equivalent first the array, equivalence between the second element of and the then first is to attempt to set an array and the array. the other sixth element of For the storage location to two or more elements of the same array. example: DIMENSION TABLE (2,2), TRIPLE (2,2,2) EQUIVALENCE (TABLE(2,2), TRIPLE(1,2,2)) As a result of these statements, the entire array TABLE shares part of Figure 5-1 shows how space allocated to array TRIPLE. storage the these statements align the arrays. Array TABLE Array TRIPLE Array Element Element Number TRIPLE(1,1,1) TRIPLE(2,1,1) TRIPLE(1,2,1) 1 2 3 TRIPLE(2,2,2) 8 TRIPLE(2,2,1) TRIPLE(1,1,2) TRIPLE(2,1,2) TRIPLE(1,2,2) Figure 5-1 4 5 6 7 Array Element Element Number TABLE (1,1) TABLE (2,1) TABLE (1,2) TABLE (2,2) 1 2 3 4 Equivalence of Array Storage The following statements also align the two arrays as shown in Figure 5-1: EQUIVALENCE EQUIVALENCE (TABLE,TRIPLE(2,2,1)) (TRIPLE(1,1,2), TABLE(2,1)) Similarly, you can make arrays equivalent with nonunity lower bounds. an array defined as A(2:3,4) is a sequence of eight For example, A reference to A(2,2) refers to the third element 1in the values. To make array A(2:3,4) share storage with array B(2:4,4), sequence. you can use the EQUIVALENCE statement: (A(3,4), B(2,4)) The entire array A shares part of the storage space allocated to array Figure 5-2 shows how these statements align the arrays. B. SPECIFICATION STATEMENTS Array Array Array Element Element Number B(2,1) B(3,1) 1 2 B(4,1) B(2,2) B(3,2) B(4,2) B(2,3) B(3,3) B(4,3) B(2,4) 3 4 5 6 7 8 9 10 B(3,4) B(4,4) 11 12 Figure 5-2 The B following A Array Element Element Number A(2,1) A(3,1) A(2,2) A(3,2) A(2,3) A(3,3) A(2,4) A(3,4) 1 2 3 4 5 6 7 8 Equivalence of Arrays with Nonunity Lower Bounds statements also align EQUIVALENCE (A,B(4,1)) EQUIVALENCE (B(3,2), the arrays as shown in Figure 5-2: A(2,2)) In the EQUIVALENCE statement only, you can identify an array element with a single subscript (that is, the linear element number), even though the array was defined as a multidimensional array. For example, the following statements align the two arrays as shown in Figure 5-1: DIMENSION TABLE (2,2), EQUIVALENCE (TABLE(4), 5.5.2 Making Substrings TRIPLE (2,2,2) TRIPLE(7)) Equivalent When you make one character substring equivalent to another character substring, the EQUIVALENCE statement also sets equivalences between the other corresponding characters in the character entities. For example: CHARACTER NAME*16 ID*9 EQUIVALENCE (NAME(10:13), ID(2:5)) SPECIFICATION STATEMENTS As a result of these statements, the character variables NAME share space as illustrated in Figure 5-3. and 1ID NAME Character w ID Character WIN|— Position QNP o -— — -— (43} LN —_ ey D - -d Figure 5-3 N — QioivN|loOi|dIWIN|— Position Equivalence of Substrings The following statement also aligns the arrays as shown in Figure 5-3: EQUIVALENCE (NAME(9:9),ID(1:1)) If the character substring references are equivalences sets statement EQUIVALENCE corresponding characters in the complete arrays. Character elements of arrays can overlap at For any the array elements, other the between character position. example: CHARACTER FIELDS®100)*4, STAR(5)*5 EQUIVALENCE (FIELDS(1l) (2:4), STAR(2) (3:5)) As a result of these statements, the character arrays FIELDS and share storage space as shown in Figure 5-4. STAR SPECIFICATION STATEMENTS STAR Character Position Subscript 1 1 2 3 FIELDS Subscript 4 Character Position 1 2 3 4 5 5 1 1 2 2 3 3 4 4 5 1 1 2 2 3 3 4 4 1 5 2 1 3 2 4 3 1 4 2 5 3 1 4 2 1 3 2 4 3 5 2 3 4 5 4 6 1 2 3 4 7 1 2 A/ N\ 100 1 ¢ 2 3 4 Figure 5-4 Equivalence of Character Arrays You cannot use the EQUIVALENCE statement to assign the same storage location to two or more substrings that start at different character positions in the same character variable or character array. You also cannot use the EQUIVALENCE statement to assign memory locations in a way that is inconsistent with the normal linear storage of character variables and arrays. SPECIFICATION STATEMENTS 5.5.3 EQUIVALENCE and COMMON Interaction When you make components equivalent to entities block, the boundaries. previously stored in a common original it s beyond extended can block common the of element 1 ast But it can only extend beyond the You cannot extend the common block. common established block in such-a way as to place the extended portion before the elemént of the existing common block. first following examples show The valid and invalid extensions of the common block: Vvalid A(l) | A(2) | A(3) | A(4) DIMENSION A(4) ,B(6) COMMON A EQUIVALENCE B(1l) (A(2),B(1l)) N B(2) B(3) B(4) '\ NS Existing Common B(5) B(6) T Extended Portion Invalid A(l) | A(2) | A(3) | A(4) DIMENSION A (4) ,B(6) COMMON A EQUIVALENCE (A(2),B(3)) B(1) | B(2) | B(3) | B(4) | B(5) | B(6) \\/_J\ Extended Portion ~" Existing Common J\\/'_J Extended Portion If you assign two components to common blocks, you cannot make them Note also that character data can be equivalent to each other. equivalenced only with character data. _J SPECIFICATION STATEMENTS EXTERNAL 5.6 The EXTERNAL EXTERNAL arguments An The statement to external subprogram STATEMENT other procedure or EXTERNAL a can FORTRAN statement EXTERNAL [*]v EXTERNAL external statement procedure argument to argument name a be a a library has the use external procedure names user-supplied function or as actual subroutine function. form: of a subprogram or subprogram name. declares name. that Such subprogram; in you [,[*]v]... The symbolic name associated with a The lets subprograms. the function a each name subprogram reference or the name name in can then can use CALL of a dummy the appear the argument 1list is an as an actual associated dummy statement. If an asterisk user-supplied Use the the (*) precedes a name in the list, the name identifies a function or subprogram, not a FORTRAN library function. asterisk only when a user-supplied function or subprogram has same name additional Note, however, (such as, name. An as a information FORTRAN on library FORTRAN function. library (See 6.3 for that a complete function reference used as an argument SUBR(A,SQRT(B),C)) represents a value, not a subprogram function name need not be defined in an EXTERNAL statement. CALL The example of Main EXTERNAL the EXTERNAL statement follows. Program SIN,COS,*TAN,SINDEG . Subprograms SUBROUTINE Y . = TRIG (X,F,Y) F(X) RETURN CALL TRIG (ANGLE,SIN,SINE) CALL TRIG (ANGLE,COS,COSINE) CALL TRIG (ANGLE,TAN,TANGNT) END FUNCTION . TAN = TAN SIN(X) (X) / COS(X) RETURN . CALL Section functions.) END TRIG (ANGLED,SINDEG,SINE) . FUNCTION SINDEG . SINDEG SIN . RETURN END = (X) (X*3.14159/180) ( SPECIFICATION STATEMENTS The CALL statements pass the name of a function to the subroutine The function reference F(X) subsequently invokes the function TRIG. in the second statement of TRIG. Depending on which CALL statement invoked TRIG, the second statement 1is equivalent +to one of the following: Y Y Y Y = SIN(X) = COS(X) = TAN(X) = SINDEG (X) The functions SIN and COS are examples of trigonometric functions supplied in the FORTRAN library. The function TAN is also supplied in the library. But the asterisk in the EXTERNAL statement specifies that the user-supplied function be wused, instead of the library function. The function SINDEG is also a user-supplied function. Because no library function has the same name, no asterisk is required. SPECIFICATION STATEMENTS DATA 5.7 The DATA DATA STATEMENT statement elements before The statement DATA DATA assigns 1initial values to variables and array program execution. has the form: nlist/clist/[[,]lnlist/clist/]... nlist A list of names one or or more variable character names, substring array names, Subscript expressions and expressions must be integer constant expressions. names, array separated in element by substring commas. references clist A list of constants; clist constants have one of the following forms: value n * value Used when you specify clist as n * value. 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 integer constant or the symbolic name of an integer constant. The DATA entities order as The statement 1in they number entities of in assigns the constant values in each <c¢list to the the preceding nlist. Values are assigned one by one in appear, from left to right. constants must the preceding correspond exactly to When an unsubscripted array name appears in a DATA are assigned to every element of that array. The list must therefore contain enough values to f£ill elements are filled in If both the constant have numeric data rules: ® The type ®¢ constant of When an variable the the order value in types, value the the is variable octal or or array of subscript When a Hollerith numeric variable characters that clist and the conversion is converted, being or of if array right with spaces. than can be stored, entity based in on necessary, the the nlist following to the data hexadecimal constant is assigned to a element that is longer than 4 bytes, the or or can statement, values associated constant the array. Array initialized. character numeric be assigned element, variable or is truncated a of depends of the If the constant the constant is 5-16 1If the constant constant 1is assigned to array element, the number the component (see Table 2-2). If the constant contains fewer characters than variable number progression. leftmost digits are initialized to zero. array element is less than 4 bytes, the on the left. e the nlist. on the data type Hollerith or character the capacity of the constant is contains truncated extended on the more characters on the right. SPECIFICATION STATEMENTS If the constant value in the clist and the entity in the nlist are both character data type, the conversion is based on the following rules: ‘ If the constant contains fewer bytes than the length of the entity, the rightmost character positions of the entity are e initialized with spaces. If the constant contains more bytes than e the length the of entity, the character constant is truncated on the right. If the constant value is numeric data type and the entity in the nlist is character data restrictions: these type, the constant and the entity must conform to : @ The character entity must have a length of 1 character. e The constant must be an integer, octal, or hexadecimal constant and must have a value in the range 0 through 255. When the constant and the entity conform to these restrictions, the entity 1is initialized with the character that has the ASCII code specified by the constant. This permits a character entity to Dbe initialized to any 8-bit ASCII code. An example of the DATA statement follows. INTEGER A (10) CHARACTER BELL,TAB,LF,FF, STARS*6 DATA A,STARS / 10%0, '****! DATA BELL,TAB,LF,FF /7,9,10,12/ The DATA statements assign 0 to all ten elements of array A, and 4 asterisks followed by 2 spaces to the character variable STARS. ASCII control character codes are assigned to the character variables TAB, LF, FF. BELL, SPECIFICATION STATEMENTS PARAMETER 5.8 PARAMETER STATEMENT The PARAMETER statement assigns a The PARAMETER statement has the form: [,p=c] ... PARAMETER p=c A symbolic name. A constant, the constant name (p) or becomes a constant A compile-time which: Each or ® constant operand expression is a constant, a compile-time Each a to constant, operand is a constant. or a constant is an the symbolic arithmetic name of Each operator is valid only integer, is a +,-,*,/, if the real a symbolic name is defined position in which a constant is the constant were written there The symbolic constant. or exponent Once a or double ** is operator. of type precision The in constant, expression. of value valid expression type. ® compile~time constant and is defined as the expression (c); c can be any constant. e of name expression. Each symbolic name of the constant FORTRAN symbolic symbolic ** data operator integer. as a constant, it can appear in any allowed. The effect is the same as if instead of the symbolic name. name of a But it can constant appear as cannot a real a name PARAMETER appear as part or imaginary part of of a another complex constant. You can the symbolic a name use can symbolic name's be defined same program unit. The symbolic name corresponding constant's data type only of constant name of a does in a corresponding not parameter a once constant in constant affect in that PARAMETER assumes expression. its constant statement in data a statements the The only to program data initial identify unit. Such within the type 1letter of rof type. type You cannot specify declaration statement. Examples PARAMETER PI=3.1415927, PARAMETER PIOV2=PI/2, DPIOV2=DPI/2 PARAMETER FLAG=.TRUE., LONGNAME='A DPI=3.141592653589793238D0 STRING OF 25 CHARACTERS' its the the SPECIFICATION STATEMENTS PROGRAM 5.9 PROGRAM STATEMENT The PROGRAM statement assigns a symbolic name to a main program unit. The PROGRAM statement has the form: PROGRAM nam A nam symbolic name. The PROGRAM statement is optional. If you use it, it must be the first statement in the main program. The symbolic name must not be the name of any entity within the main program. It also must not be the same as the name of any subprogram, entry, or common block in the same executable program. SPECIFICATION STATEMENTS BLOCK DATA 5.10 BLOCK DATA STATEMENT The BLOCK DATA statement, followed by a series of specification statements, assigns initial values to entities in named common blocks and, at the same time, establishes and defines these blocks. The BLOCK DATA BLOCK statement DATA [nam] symbolic name. has the form: nam A You can use EQUIVALENCE, type and declaration, DATA statements IMPLICIT, following a The specification statements that follow the establish and define common blocks, assign these blocks, and assign initial values to the A BLOCK DATA statement must A BLOCK DATA statement and BLOCK —If you DATA use program a BLOCK unit DATA have 1its comprise a special kind BLOCK DATA program unit is A not a associated not contain statement to DATA statement arrays to arrays. label. specification any COMMON, statement. BLOCK DATA variables and variables and statement of program unit. an END statement. must DIMENSION, BLOCK The last executable initialize statements statement any in a statements. entity in a stateients to establish the entire block, even though some of the labeled common entities 1in block, the the same BLOCK than one common An example BLOCK of LOGICAL DOUBLE must do not block DATA program provide appear unit to in a complete a DATA define set of specification statement. initial values You can for block. a BLOCK DATA INTEGER you DATA program unit follows. BLKDAT S,X T,W PRECISION DIMENSION U R(3) 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 use more CHAPTER 6 SUBPROGRAMS from another Subprograms are program units that can be invoked tion on behalf computa y-used commonl some program, usually to perform of the other program. Subprograms are either user-written, or supplied as part of the VAX-1ll1 User-written subprograms include: FORTRAN IV-PLUS system. @ Arithmetic statement functions e Functions e Subroutines Subprograms supplied with the FORTRAN system include: ® Processor-defined functions ® Generic functions e Character functions known Generally the program that invokes the subprogram passes values, actual the wuses which am, subprogr the to s, argument actual as arguments to compute the results. 6.1 SUBPROGRAM ARGUMENTS arguments. Subprogram arguments are either dummy arguments or actualram. Actual subprog the define you when ed specifi are ts Dummy argumen are and ram, subprog the arguments are specified when you invoke associated with the corresponding arguments when control is dummy transferred to the subprogram. This means that each dummy argument takes on the value of the corresponding actual argument; and any to the dummy argument is also assigned value assigned 6.1.1 Actual Argument and Dummy Argument Association corresponding actual argument. to the ts. There must be agreement between actual arguments and dummy argumen the with type data and number order, in agree Actual arguments must can ts argumen Actual ted. associa are they which with ts argumen dummy expressions, arrays, array elements, variables, constants, be character substrings, alternate return specifiers, or subprogram ions, The dummy arguments specified in subprogram definitripted names. unsubsc as appear s, argument actual onding corresp nting represe variable names. SUBPROGRAMS Although dummy arguments are not actual variables, arrays, or subprograms, each dummy argument may be declared as though it were a variable, A dummy array, or argument actual declared argument type. If array that Section subprogram. that as is a dummy argument is the actual 6.1.1.1) to subprogram. an an is array array an array, argument. process can or You be associated only array element the same larger than the arrays (see of it must be can adjustable different use sized no arrays in with a an data single The length of a dummy argument of type character must not be greater than the 1length of its associated actual argument. Note that if the character dummy argument's length is specifi ed as *(*), the length used 1is exactly the length of the associated actual argument. (This is known as a passed length character argumen t. See Section 6.1.1.2.) Section 6.1.1.3 constants as describes actual the Section 6.1.1.4 6.1.1.1 Adjustable Arrays subprograms. the describes The reference 2.5.1) dummy use of character arguments. alternate return - Adjustable dimensions of an arrays the actual arguments, variables specified in the array declarator. The size of size of the to in in the following example two-dimensional array. Note the control the iteration. FUNCTION SUM(A,M,N) DIMENSION SUM 10 argument actual = common the use of the calls on SUM: A(M,N) DO 10 J =1 'N 10 I =1 M SUM = computes SUM + A(I,J) RETURN END The arguments are following DIMENSION statements A1(10,35), SUM1 SUM2 = = SUM(A1,10,35) SUM(A2,3,56) SUM3 = SUM(A1,10,10) are sample A2(3,56) in determined in Section that are used in the array argument and each blocks, 0.0 DO Hollerith declarator must have a evaluated using the values the adjustable array must be less than array that is its corresponding actual function N dummy to the subprogram. The array declarator (see an adjustable array can contain integer variables arguments or variables in a common block. of a are array for variable in a common block used in an array defined value. The dimension declarator is The and arguments. adjustable When the subprogram is entered, each dummy declarator must be associated with an of constants and or equal argument. sum of dummy constants to the the elements arguments M and SUBPROGRAMS The upper and lower dimension bound values are determined once each time a subprogram is entered. These values do not change during the execution of that subprogram even if the values of variables contained in the array declaration are changed. For example: DIMENSION CALL ARRAY (11,5) SUB (ARRAY,L,M) END SUBROUTINE SUB(X,I,J) DIMENSION X(-I/2:1/2,3J) J =1 I =2 END In this entry that An example, to the adjustable subroutine SUB. declaration. adjustable currently array is array X The undefined associated with an is declared assignments if a actual to I as and dummy argument argument array, X(-4:4,5) J do not array or if 1is any on affect of not the variables in the adjustable array declarator are not currently associated with an actual argument or are not in a common block. Note that argument association is not retained between one reference to a subprogram and the SUBROUTINE DIMENSION A(I) next reference to that subprogram. For example: S(A,I,J) A(I) =4 RETURN ENTRY ! A(I) S1 (I,A,K,L) = A(I) + 1 B is RETURN END In this example, a real array with statement sets B(2)=3: DIMENSION The following CALL The next S(B,2,3) 6.1.1.2 Passed must the For a passed B (5) by 1: a of the length as the Character dummy Arguments argument. A actual argument. character string, length - passed specification use (see A passed length an length character character argument asterisk Section enclosed in 6.2.2.2). transfers to a subprogram, each passed length argument must be associated with a character actual length of the dummy argument is the length of the actual dummy The control Length be length parentheses When increments S1(5,B,3,2) argument has elements: B (10) statement CALL 10 character argument. argument. SUBPROGRAMS The length length. A character array dummy argument can have passed elements in the of length the is nt argume dummy of each element in the the array declarator the actual argument. The passed length and character array. A length passed together determine the size of the passed length character array can also be an adjustable array. gram uses a passed length The following example of a function subprothe position of the character character argument. The function finds length of the passed the uses 1t value; code with the highest ASCII ion. (Note that the iterat the length character argument to control the length of the ine determ to used is LEN on functi processor—-defined LEN function.) the of argument. See Section 6.3.4 for a description INTEGER FUNCTION ICMAX (CVAR) (*) CVAR CHARACTER* ICMAX = 1 DO 10 I = 1, LEN(CVAR) 10 IF (CVAR(I:I) .GT. CVAR (ICMAX:ICMAX)) ICMAX=I RETURN END each time control The length of the dummy argument is determinedactual argument can be the of length transfers to the function. The substring, or t, elemen array le, variab ter charac a of the length specifies a ces referen n functio Each of the following expression. different length for the dummy argument. CHARACTER VAR*10, CARRAY (3,5)*20 I1 = ICMAX(VAR) I2 = ICMAX(CARRAY (2,2)) I3 = ICMAX(VAR(3:8)) . I4 = ICMAX(CARRAY(1,3) (5:15)) I5 = ICMAX (VAR(3:4)//CARRAY(3,5) Arguments -Actual 6.1.1.3 Character and Hollerith Constants as Actual agree in data must ts argumen dummy g pondin corres their and nts argume example, (for nt consta ith Holler a is type. If the actual argument VAX-11 In type. data numeric of be must t argumen dummy the , 4HABCD) (for nt consta er charact a is nt argume FORTRAN IV-PLUS, if an actual either have can t argumen dummy g pondin corres the , 'ABCD') example, numeric or character data type. If the dummy argument has a numeric converted to a data type, the character constant '"ABCD' is, in effect, linker. Hollerith constant by the FORTRAN compiler and the subroutine name 1is An exception to this occurs when the functionle orto determ ine at compile possib itself a dummy argument. It is not t or Hollerith constant time or link time whether a character constan In this case, a character constant actual argument can is required. only correspond to a character dummy argument. For example: SUBROUTINE S (CHARSUB,HOLLSUB,A,B) EXTERNAL CHARSUB,HOLLSUB B 'STRING') RSU CALL CHA(A, G) B 6HSTRIN LSU (B, CALL HOL SUBPROGRAMS In this example, themselves dummy the subroutine arguments of the names CHARSUB subroutine S. and HOLLSUB Therefore, the argument 'STRING' in the «call to CHARSUB must correspond character dummy argument, while the actual argument 6HSTRING call to HOLLSUB must correspond to a Hollerith dummy argument. 6.1.1.4 Alternate argument in a Return Arguments dummy argument - list, To specify place an alternate asterisks in the are actual to a in the return list. For example: SUBROUTINE MINN(A,B,*,*,C) The actual return the argument arguments in list the passed in the corresponding CALL must positions. include These alternate arguments have form: *label or &label You can use either an asterisk alternate return argument in an specify for label must be issued the CALL. 6.1.2 Built-In Functions the or an ampersand to actual argument list. label of a statement Built-in functions perform utility operations communicating with subprograms written in FORTRAN. There two kinds of built-in e Argument list built-in functions ® 23LOC 6.1.2.1 written may are Argument in need uses. built-in to pass You can the use -- in the argument change the form of You must not procedure or The three argument functions function use a program that the that are languages useful in other than functions: Built-In other actual three Functions - To call subprograms FORTRAN (such as system services), you arguments in a different form than FORTRAN than built-in list of a CALL the argument. these built-in user-supplied functions statement functions subprogram to -- or $%VAL, invoke written $REF, function in a You cannot use them in any and $DESCR reference FORTRAN to library FORTRAN. argument 1list built-in functions specify should be passed to the subprogram. You only in the actual argument list of a CALL reference. an you function List languages in indicate The value other the way the can use these statement or context. SUBPROGRAMS The argument list built-in functions are: Effect Function $VAL (a) Pass the argument as a 32-bit value. $REF (a) Pass the argument by reference. $DESCR(a) Pass the argument by descriptor. In these functions, a is an actual argument. See the VAX-11 FORTRAN IV-PLUS User's Guide for more information on argument-passing mechanisms. Table 6-1 lists the FORTRAN argument-passing defaults and the uses of %VAL, %REF, and %DESCR. Table 6-1 Argument List Built-In Functions and Defaults Actual Argument Data Type Functions Allowed Default VAL $REF $DESCR Expressions LOGICAL REF Yes Yes Yes INTEGER REF Yes Yes Yes REAL*4 REF Yes Yes Yes REAL*8 REF No Yes Yes COMPLEX REF No Yes Yes CHARACTER DESCR No Yes Yes Hollerith REF No No No Numeric REF No Yes Yes CHARACTER DESCR No Yes Yes Numeric REF No Yes Yes CHARACTER DESCR No Yes Yes Array Name Procedure Name allowed SUBPROGRAMS 6.1.2.2 $LOC Built-In Function - The 3%LOC built-in function the internal address of a storage element. It has the form: computes $LOC (v) A variable name, substring name, or array element name, array external procedure name. name, character The %LOC built-in function produces an INTEGER*4 value that represents the 1location of 1its argument. It can be used as an element in an arithmetic expression. See the VAX-11l FORTRAN IV-PLUS User's Guide for the %LOC built-in function. 6.2 more information on USER-WRITTEN SUBPROGRAMS A user-written subprogram is a FORTRAN statement or group of FORTRAN statements that perform a computing procedure. A computing procedure can be either a series of arithmetic operations or a series of FORTRAN statements. You can use subprograms to perform a computing procedure in several places in your program, and thus avoid having to duplicate the series of operations or statements in each place. There are three types of subprograms. Table 6-2 lists each type of subprogram, the statements needed to define it, and the method of transferring control to the subprogram. . Types Subprogram Arithmetic function of Table 6-2 User-Written Subprograms Defining statement Function Control Transfer Method Statements Arithmetic statement | Function function definition reference FUNCTION reference Function ENTRY RETURN Subroutine SUBROUTINE CALL statement ENTRY RETURN A function reference function name and returns a value that is used in an expression and consists of the the function arguments. A function reference is used in evaluating the expression in which it appears. Function and subroutine subprograms can change the values arguments; the calling program can use the changed values. A subprogram can refer to other subprograms; directly or indirectly, refer to itself. but it of cannot, their either SUBPROGRAMS 6.2.1 Arithmetic Statement Functions An arithmetic statement function is a computing procedure defined by a Its definition statement is similar in form to an statement. single statement arithmetic the to refer you If assignment statement. The resulting value is made the computation is performed. function, statement arithmetic the available to the expression that contains reference. function The arithmetic statement function definition statement has the form: ([pl,p)...]1)=e £ The name of the arithmetic statement A dummy An function. argument. expression. The expression (e) is an arithmetic or logical expression that defines the computation to be performed. An arithmetic statement function reference has the form: £ (Ipl,pl...1) function. The name of the p An actual argument. an in appears reference function statement an arithmetic When expression, the values of the actual arguments are associated with the The dummy arguments in the arithmetic statement function definition. The resulting value the definition is then evaluated. in expression the containing expression is used to complete the evaluation of the function reference. The data type of an arithmetic statement function is determined either implicitly by the initial letter of the function name, or explicitly in a type declaration statement. The data type can be any of the numeric data types, but cannot be character data type. Dummy arguments in a statement function indicate only the number, order, and data type of the actual arguments. You can use the names of the dummy arguments to represent other entities elsewhere in the program unit. Note that, except for data type, declarative information associated with an entity is not associated with the dummy That is, declaring an arguments in the arithmetic statement function. a affect not does entity to be an array or to be in a common block dummy argument with the You cannot use the name same name. of the arithmetic statement represent any other entity within the same program unit. function to can definition function statement arithmetic The expression in an a reference to another arithmetic If references. function contain statement function appears in the expression, you must have previously defined that function in the same program unit. SUBPROGRAMS Any reference to an arithmetic statement function must appear same program unit as the definition of that function. An arithmetic statement function of, an expression. You cannot an assignment statement. Actual arguments must agree in corresponding dummy arguments. Examples of arithmetic VOLUME (RADIUS) SINH(X) The a = following dummy is of function definitions type with their follow. 4.189*RADIUS**3 an invalid definition. = You cannot use a constant as (A+B+C)/3. arithmetic statement function references follow. the definition: AVG(A,B,C) These and data argument. Examples is order, (EXP(X)-EXP(-X))*0.5 AVG(A,B,C,3.) This = the reference must appear as, or be part use the reference as the left side of number, statement in are the = (A+B+C)/3. references: GRADE = AVG(TEST1,TESTZ2,XLAB) IF (AVG(P,D,Q).LT.AVG(X,Y,Z)) FINAL = AVG(TEST3,TEST4,LAB2) GO TO 300 The last of these three references is invalid, because the data of the third argument does not agree with the dummy argument. 6.2.2 type Function Subprograms A function subprogram is a program A function subprogram returns unit consisting of a FUNCTION statement followed by a series of statements that define a computing procedure. You use a function reference to transfer control to a function subprogram, and a RETURN statement to return control to the calling program unit. a single value to the unit by assigning that value to the function's name. name determines the data type of the value returned. <calling The program function's SUBPROGRAMS 6.2.2.1 Numeric Functions - The FUNCTION statement has the [typ] typ form: FUNCTION nam[*m] [([p[,p]...]1)] One of the numeric data type specifiers. nam The name of m Unsigned, data P A function. nonzero integer constant specifying the length of the statement has type. dummy argument. Character Functions - The CHARACTER 6.2.2.2 the the FUNCTION form: CHARACTER[*n] FUNCTION nam [([p[,p]...1)] Unsigned, nonzero integer constant, or (*) indicating a passed If you specify CHARACTER*(*), the function length function name. assumes the length declared for it in the program unit that invokes it. A passed length character function can have different lengths when it is invoked by different program units. If n 1is an integer constant, the value of n must agree with the length of the function specified in the program unit that invokes If you do not specify n, a length of 1 is assumed. the function. nam The name of the A dummy 6.2.2.3 control function. argument. Function Reference - A function reference to a function subprogram has the form: nam ([pl[,pl...]) The symbolic name of that transfers nam p An actual the function. argument. the the values of When control transfers to a function subprogram, in the function reference are associated (if any) arguments actual The statement. FUNCTION the in with the dummy arguments (if any) A value must be then executed. subprogram are in the statements is Finally, a RETURN statement assigned to the name of the function. executed in that function and returns control to the calling program to available The value assigned to the function's name is now unit. and is used to reference, function the expression containing the complete the evaluation of that expression. SUBPROGRAMS The data type of a function name can be specified explicitly in the FUNCTION statement or in a type declaration statement, or implicitly. The function name defined in the function subprogram must have the same data type as the function name in the calling program unit. The FUNCTION statement must be the first statement of a function subprogram. It must not have a statement 1label. A function subprogram cannot contain a SUBROUTINE statement, a BLOCK DATA statement, or another FUNCTION statement. ENTRY statements can be included, to provide multiple entry points to the subprogram. (See Section 6.2.4.) Examples of function FUNCTION 2 subprograms follow. ROOT (A) X =1.0 EX = EXP (X) EMINX = ROOT = IF 1./EX ((EX+EMINX)*.5+COS(X)-A)/((EX - (ABS(X-ROOT) .LT.1E-6) EMINX)*.5-SIN(X)) RETURN X = ROOT GO TO 2 END The function in this example uses the to obtain the root of the function: F(X) = cosh(X) The value of A this root is: + cos(X) is passed as - an A Newton-Raphson iteration method =0 argument. The iteration formula for cosh (Xi)+cos(Xi)-A Xi+l = Xi sinh (Xi)-sin(Xi) This is calculated repeatedly until is 1less than 1.0E-6. The function EXP, SIN, COS, and ABS (see Section the difference between Xi and Xi+l uses the FORTRAN library functions 6.3). The following example returns the value of function. length repeated is its a passed argument, CHARACTER* (*) FUNCTION CHARACTER*1 CARG DO 10 10 I=1, REPEAT REPEAT character function. to fill the length of It the (CARG) LEN(REPEAT) (I:I) = CARG RETURN END Within any character example, given program function must the REPEAT unit have function has CHARACTER*1000 REPEAT, MANYAS = REPEAT('A') MANYZS = REPEAT('Z2') all the a MANYAS, references to same length. length MANYZS of 1000. a In passed 1length the following SUBPROGRAMS However, another program unit within the executing program can specify a different length. 1In the following example, the REPEAT function has a length of 2. CHARACTER HOLD*6, REPEAT*2 HOLD = REPEAT('A') // REPEAT('B') 6.2.3 // REPEAT('C') Subroutine Subprograms A subroutine subprogram is a program unit consisting of a SUBROUTINE statement followed by a series of statements that define a computing procedure. You use a CALL statement to transfer control to a subroutine subprogram, and a RETURN statement to return control to the calling program unit. The SUBROUTINE statement has SUBROUTINE nam the form: [([pl[,p]l..-]1)] nam The p name A dummy of the subroutine. argument. alternate You can . specify a dummy return argument by placing an asterisk argument as an in the argument list. Section 4.5 describes the CALL statement. When control transfers 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. The SUBROUTINE statement must be the first subroutine. It must not have a statement label. statement of a A subroutine BLOCK DATA subprogram cannot contain a FUNCTION statement, a statement, or another SUBROUTINE statement. ENTRY subroutine. (See statements are allowed, to specify multiple entry points Section in the 6.2.4.) Examples: 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 1is 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. SUBPROGRAMS Main Program COMMON NFACES,EDGE,VOLUME ACCEPT *, NFACES,EDGE CALL TYPE PLYVOL 'VOLUME=',6 VOLUME *, STOP END Subroutine SUBROUTINE PLYVOL COMMON NFACES ,EDGE,VOLUME CUBED = EDGE**3 corTo 1 GOTO (6,6,6,1,6,2,6,3,6,6,6,4,6,6,6,6,6,6,6,5),NFACES 6 * 0.11785 VOLUME = CUBED * 0.47140 VOLUME = CUBED RETURN 2 VOLUME CUBED = RETURN 3 RETURN 4 VOLUME = CUBED * RETURN 5 VOLUME = CUBED * 7.66312 2.18170 RETURN 6 TYPE 100, NFACES (' NO REGULAR POLYHEDRON HAS 100 FORMAT ',I3,'FACES.'/) VOLUME=0.0 RETURN END example following The illustrates the wuse of alternate return specifiers to determine where control is transferred on completion of The SUBROUTINE statement argument list contains two the subroutine. actual the to corresponding return arguments, alternate dummy The RETURN arguments *10 and *20 in the CALL statement argument list. Thus, taken depends on the value of Z, as computed in the subroutine. O, to equal if taken; 1is return normal the 0, than less is 2 if if more than 0, 1is to statement label 10 in the main program; return return is to statement label 20 in the main program. Main Program CALL CHECK TYPE GO TO 10 20 30 . . *, Subroutine SUBROUTINE CHECK (A,B,*10,%*20,C) 'VALUE LESS THAN ZERO' . 30 TYPE *, 'VALUE EQUALS ZERO' GO TO 30 TYPE *, 'VALUE MORE THAN ZERO' CONTINUE . 50 60 70 80 IF(z) 60,70,80 RETURN RETURN 1 RETURN 2 END (X,Y,*,*,Q) SUBPROGRAMS ENTRY 6.2.4 ENTRY The ENTRY subprogram. Statement statement It is provides multiple executable and can after the FUNCTION entry not points appear within a within a function or subroutine program or SUBROUTINE statement. Execution of a subprogram referred to by an entry name begins with the first executable statement after the ENTRY statement. The ENTRY statement ENTRY nam has the form: [([p[,p]...]1)] nam The p Use entry name. A dummy argument. the CALL statement to refer subprograms. function Use function subprograms. An name entry declaration You can an actual You a function an entry argument; use the name you entry in cannot names appearance of entry in the to names refer subprogram statement. specify cannot precede within to references an EXTERNAL use it as a executable entry name can can use number, dummy type, arguments in ENTRY names appear in an a use that ENTRY statements and within type it as argument. statements in subroutine entry statement dummy You can include alternate return arguments in placing asterisks in the dummy argument list. specify alternate return arguments can be used subprograms. You within to physically statement. ENTRY ENTRY only that statements by statements that in subroutine differ and in order, name from the dummy arguments you use in the FUNCTION, SUBROUTINE, and other ENTRY statements in the same subprogram. However, each reference to a function, subroutine, or entry and must type use dummy follow or ENTRY dummy not argument the first argument currently retention of to the next. You cannot loop. actual the SUBROUTINE, A an with is list that list in agrees the in order, corresponding number, FUNCTION, statement. specified. associated an argument can be referred to only in executable statements that SUBROUTINE, FUNCTION, or ENTRY statement im which the argument use argument dummy A dummy with association ENTRY statement an argument actual is undefined argument. from one reference within block a IF of if it There a 1is is no subprogram construct or a DO SUBPROGRAMS entry names within a 6.2.4.1 ENTRY in Function Subprograms - All function subprogram are associated with the name of the function subprogram. Therefore, defining any entry name or the name of the function subprogram defines all the associated names of the same data all associated names that are of different data types become type; The function and entry names need not be of the same data undefiped. data type, but they all must be either numeric data type or character type. At the execution of a RETURN statement or the implied return at subprogram must be defined. to refer to the end of the subprogram, the name used the function If the function is of character data type, the entry name must also be of character data type and must have the same length specification as Note that the length specified must also agree with the the function. If length specified in the program unit referring to the entry name. an asterisk enclosed in parentheses is used to specify the length of the entry name has a passed length (see Section the entry name, 6.1.1.2). Figure 6-1 illustrates hyperbolic functions sinh, a subprogram function cosh, and tanh. that computes REAL FUNCTION TANH (X) C C C STATEMENT FUNCTION TO COMPUTE TWICE SINH TSINH(Y) = EXP(Y) - EXP (-Y) C C C STATEMENT FUNCTION TO COMPUTE TWICE TCOSH(Y) = EXP(Y) COSH + EXP(-Y) C C C COMPUTE TANH TANH = TSINH(X) / TCOSH (X) . RETURN C C COMPUTE SINH C ENTRY SINH (X) SINH = TSINH(X) / 2.0 RETURN C C COMPUTE COSH C ENTRY COSH = COSH (X) TCOSH(X) / 2.0 RETURN END Figure 6-1 Multiple Functions in a Function Subprogram the SUBPROGRAMS 6.2.4.2 ENTRY name in point name a in Subroutine Subprograms - To refer to an entry subroutine, issue a CALL statement that includes the defined in the ENTRY statement. For example: point entry Main Program CALL SUBA(A,B,C) Subroutine SUBROUTINE ENTRY SUB (X,Y,Z) SUBA(Q,R,S) In this example, the CALL is subroutine (SUB). Execution ENTRY CALL SUBA (Q,R,S), statement. statements. using Note For that to an begins the SUB ENTRY (J,K,*,*,X) SUBC RETURN 1 2 arguments returns (SUBA) within the statement following (A,B,C) can example: SUBROUTINE RETURN actual alternate entry point with the first be passed in specified in the ENTRY (K,*,*) END If you issue a CALL to entry alternate return arguments. CALL In this RETURN program. SUBC, example: you control statement must include actual SUBC(M,N,*100,*200,P) case, 2 point For RETURN transfers 1 transfers control to to statement label label 200, in 100, the and calling SUBPROGRAMS 6.3 FORTRAN LIBRARY FUNCTIONS tions are provided to perform commonly used FORTRAN library funcions . mathematical computat Function The FORTRAN library functions are listed in Appendix B. the same way ary functions are written inwritt references to FORTRAN libr en. For are function references to user-defined functions example: R = 3.14159 * ABS(X-1) of X-1 is calculated ence, the absolute value As a result of this refer is assigned to the t resul the 59; 3.141 and multiplied by the constant variable R. ion and of ther type of each librarydescfunct Appendix B gives the data the characte s ribe also 4 6.3. Section actual arguments. functions. Processor-Defined Function References 6.3.1 called processor—-defined function names are defin The FORTRAN library ed functions include ssorthat the proce function , names. Note ions Functions defined nal Exter Basic the and both the Intrinsic Funct in ANS FORTRAN. d function names table of processor-definename. Normally, a name in the libr However, the that with ion funct ary AN refers to the FORTRuser following the of any r -defined function unde name can refer to a conditions: declaration statement specifying a e The name appears in a typeshown in the table. different data type than in an e The name is prefixed with an asterisk and appears EXTERNAL statement. ion reference with arguments of a e The name is used in a funct shown in the table._ different data type than and are prefixed by in an EXTERNAL statement local Except when they are used to the program ed function names are for other an asterisk, processor-definThus, purposes used be can they unit that refers to them. . of a type data the In addition, units in other program tion ICIT IMPL an use you if e chang not does processor-defined func statement to change the implied data type rules. t with an EXTERNAL statemention fined function name inname Use of a processor-de or func a to s refer specifies that the nal subprogram. an asterisk prefix will provide as an exter subroutine that you 6.3.2 Generic Function References ng some of the provide a way of calli Generic function references n of the actual ctio sele the that such s tion FORTRAN mathematical is func ent in the argum the of type based on the data used library routinerenc able, the vari real a is X 1if ple, exam For e. function refe tion. sine ed valu real ) refers to the the function referencfunc function reference leSIN(X (D) SIN e able, But if D is a doub precisionn vari e writ not need You . tion sine func refers to the double precisio . DSIN(D) 6-17 SUBPROGRAMS Generic function selection occurs independeritly for each function reference. Thus, you could use both the function references in the example above, SIN(X) and SIN(D), in the same program unit. Table 6-3 only with You if cannot lists the generic argument data the use the them in you use ® In a ® As the ° As a type names function types in Table 6-3 unit in a program declaration name dummy of an names. These names shown in the table. generic of the function following be used selection ways: statement arithmetic argument for any can name, statement common block name function name, variable or array Using a generic name in an EXTERNAL stateme nt does not affect generic function selection for function references. When you use a generic function name in an actual argument list as the name of a function to be passed, no generic function selection occurs, as there is no argument list according above in Generic them. on which to to base the rules Section 6.3.1. function Thus, names they can are be nongeneric local used selection. a for for to Table Generic Generic the other Function program unit in Name Type Integer Double Complex INT, ANINT NINT DBLE EXP, LOG, MIN, SIN, SIGN, COS, DIM LOG10, TAN, ATAN, ATAN2, ACOS, SINH, COSH, TANH ASIN, Type Result Integer Real Double Real Real Integer Double Integer Integer Double Real Integer SQRT Data Double Integer MAX, of Real Real MOD, refers programs. Double Real SNGL that other treated described Summary Real AINT, 1is 6-3 Argument ABS name functions purposes Data Name The FORTRAN Real Double Double Integer Real Real Double Double Real Real Double Double Complex Complex Real Double Real Double of to SUBPROGRAMS 6.3.3 Processor-Defined and Figure 6-2 shows the use In this figure, four distinct ways: name As the As a generic As a processor-defined As a user-defined Using the name in properties of the In Figure 6-2, the follow the figure. of an arithmetic function these name. Function Usage of processor-defined and generic a single executable program uses the names. in Generic statement function name SIN function name function name function four ways parenthetical emphasizes notes are the keyed local to the and notes global that QOO0 SUBPROGRAMS COMPARE WAYS PROGRAM SINES PARAMETER PI COMPUTING = SINE. 3.141592653589793238D0 REAL*8 X COMMON V (3) DEFINE SIN(X) SIN AS A STATEMENT FUNCTION = COS(PI/2-X) DO 10 X = REFERENCE 10 100 OF R -PI, PI, CALL COMPUT (X) THE 1) 2*PI/100 STATEMENT WRITE (6,100) X,V, FORMAT (5F10.7) (Note FUNCTION SIN (Note 2) SIN(X) END SUBROUTINE COMPUT (Y) REAL*8 Y MAKE PROCESSOR-DEFINED EXTERNAL COMMON SIN EXTERNAL (Note REFERENCE V(l) = SIN(Y) PROCESSOR-DEFINED TO DOUBLE FUNCTION PRECISION SINE AS SINE (Note END SUBROUTINE SUB(A,S) DECLARE SIN AS NAME OF USER FUNCTION. EXTERNAL *SIN DECLARE SIN AS REAL*8 A, SIN TYPE REAL*8 (Note = (Note 6) 7) COMMON V (3) EVALUATE PROCESSOR-DEFINED FUNCTION V{(2) = S(A) EVALUATE USER DEFINED SIN FUNCTION. SIN (Note (Note 9) SIN(A) OO0 END DEFINE THE REAL*8 FUNCTION INTEGER SIN 1 = USER SIN FUNCTION. (Note 10) SIN(X) FACTOR X - X**3/FACTOR(3) X**7/FACTOR(7) + X**5/FACTOR(5) END INTEGER FUNCTION FACTOR =1 DO 10 10 FACTOR I=N, = 1, FACTOR(N) -1 FACTOR * I END Figure 6-2 Multiple 4) ACTUAL ARGUMENT. SUB(Y,SIN) V(3) 3) V (3) GENERIC CALL FUNCTION SIN Function Name Usage 8) (Note 5) SUBPROGRAMS NOTES 1 An arithmetic statement function named SIN is defined in terms of the generic function name COS. Since the argument of COS is double precision, the double precision cosine function will be evaluated. 2 The 3 The name precision, an arithmetic actual statement function SIN is called. SIN is declared external so that the single processor—-defined sine function can be passed as argument at 5. 4 The generic function name precision sine function. 5 The single precision, processor—-defined as an actual argument. sine ) The name SIN is function 7 The type of SIN 8 The single precision 9 The user-defined SIN 10 6.3.4 declared is SIN a used to user-defined declared sine is refer to the function double is used name. double precision. function passed function is at 5 is evaluated. evaluated. The user—-defined SIN function is defined as a simple Taylor series using a user-defined function FACTOR to compute the factorial function. Character Library Functions Character library functions are functions that take arguments or return character values. There are four functions provided with FORTRAN: e character character LEN The LEN The LEN function function returns has the the length of form: a character expression. LEN (c) o] A character expression. many bytes there are in ® The value returned the expression. indicates how INDEX - The INDEX function searches for a substring (c2). in a specified character string (cl), and, if it finds the substring, it returns the substring's starting position. If c2 occurs more than once in cl, the starting position of the first occurrence is returned. If c2 does not occur in cl, the value zero is returned. The INDEX function has the form: INDEX (cl, c2) SUBPROGRAMS cl A character searched expression for the specifying substring the specified by string c2. c2 A character the ¢ location specifying is to be the substring for which determined. ICHAR The ICHAR function equivalent the form: ASCII ICHAR The character than returned. e converts code and a character returns expression the ASCII value. to an ASCII ICHAR has (c) longer to be 1 byte, The converted only the value of remainder are ignored. converts an ASCII code. the If first c byte is CHAR The CHAR function character the An Examples value, and returns the integer character (1) integer illustrating Function expression. the LEN and Example: SUBROUTINE REVERSE (S) CHARACTER T, S*(¥*) J = LEN(S) IF (J .GT. 1) THEN DO I=1, J/2 10 T S(I:1I) S(I:I) = S(Jd:J) =T J 10 = = J-1 CONTINUE ENDIF RETURN END S(J:J) INDEX functions value value. form: CHAR LEN expression starting follow. CHAR has SUBPROGRAMS INDEX Function Example: GS S) (SUB, SUBROUTINE FINDSUBSTRIN (*) CHARACTER* CHARACTER*132 SUB,S MARKS I =1 K=1 MARKS 10 = ' ! J = INDEX(S(I:), IF (J 0) .NE. SUB) THEN I =1+ (J-1) MARKS (I:I) = '#' K=1 I IF = I+l (I .LE. LEN(S)) GO TO 10 ENDIF 100 WRITE(7,100) S, MARKS(:K) FORMAT( 2(/1X, A) ) END CHAPTER 7 INPUT/OUTPUT STATEMENTS FORTRAN programs WRITE, TYPE, and statements are use READ and ACCEPT PRINT statements used with format statements for output. specifiers translation and editing of the data to and and external character (readable) form. for Some that input; these the (binary) form from internal Each READ or WRITE statement refers to the logflcal and forms of control unit to or which data is to be transferred. A logical unit can be connected device or file by the OPEN statement (see Section 9.1). from to a The ACCEPT, TYPE, and PRINT statements do not refer to logical units; rather, they transfer data between the program and an implicit logical unit. The ACCEPT and TYPE statements are normally connected to the default input or output device and the PRINT statement is normally connected to Input/ouytput categoriies: @ the default output device. (I/0) statements are grouped into the following Formatted Sequential I/0O -- transmits character data using format specifiers to control translation of data from internal (binary) form to character (readable) form on output, and vice versa oninput. @ List-Directed Sequential I/0 -- transmits character data. The data type of the I/O list elements controls the translation of data to internal form on input and to character form on output. e Unformatted Sequential @ Formatted Direct Access I/0 -- transmits character data to and from direct access files using format specifiers to control translation of data from internal form to character form on output, and vice versa on input. e Unformatted Direct Access I/0 -- transmits binary data without translation to and from direct access files. e Internal transfer without translation. I/0 -- transmits data I/0 -- ENCODE and DECODE data between variables in statements and arrays internal form translate and in the FORTRAN program. These categories of through 7.7. Section 7.1 I/0 statements below describes are the general described components of 1in I/0 Sections 7.2 statements. INPUT/OUTPUT STATEMENTS 7.1 I/0 STATEMENT COMPONENTS The following record if an sections numbers, error 7.1.1 or describe format end-of-file Logical logical specifiers, condition unit I/O numbers, lists, and occurs. direct transfer access of control Unit Numbers I/0 statements use logical unit numbers to refer to files and I/0 devices. A logical unit number is an integer expression with a value in the range 0 through 99. It is converted, if necessary, to integer data type before use. You can use an OPEN device to a 1logical User's Guide logical Some (see wunit. describes other Chapter Chapter ways to 3 of 9) to the connect a I/O connect VAX-11 file unit. or a file FORTRAN I/O or I/O IV-PLUS device to a ! statements do Instead, these number. ‘The implicit logical 7.1.2 statement not statements VAX-11 contain use FORTRAN unit Direct Access a IV-PLUS numbers Record an explicit 1logical system-specific, User's in greater Guide unit implicit number. logical describes the unit use of detail. Numbers When using direct access I/0, you must indicate which record is to be read or written. To do so, you specify a direct access record number, which is a numeric expression. If necessary, the record number is converted direct to access less than For the a more VAX-11 or integer record equal to general FORTRAN 7.1.3 Format Format of the specifiers following: data number the type used. than number of records defined discussion of record numbers, IV-~PLUS User's Guide. or The equal for refer value to the to of 1, a and file. Chapter 3 of Specifiers are used a FORMAT in formatted label ° A character variable A character array name A character array element A character substring A numeric of array as 8 FORMAT describes In sequential I/O format specifier a statements and can be any can be name reference which format contains a value that statements. statements, to denote list-directed I/O statement name interpreted describes is greater A Chapter it be e ® before must 1/0. you can use an 1list-directed asterisk instead of a formatting. Section 7.3 INPUT/OUTPUT STATEMENTS Input/Output Records 7.1.4 The amount of I/0 statements transfer all data in terms of records. data that one record can contain, and the way records are separated, depend on how the data is transferred. In unformatted I/0, the I/0 statement specifies the amount of data to the 1I/0 statement and 1its In formatted 1I/0, transferred. be associated format specifier jointly determine the amount of data to be transferred. of a new Executing an input or output statement initiates transfer the record, a of part only requires statement input an If record. ©Normally, the data transferred by remainder of the record is ignored. formatted However, record. constitutes one statement I/0 an sequential I/0 statements can transfer more than one record. | ! Input/Output Lists 7'1F5 ! The I/0 list in an input or output statement contains the names of and character substrings whose array elements, arrays, variables, The I/0 list in an output statement can values are to be transferred. also contain constants and expressions. An I/0 list has the form: s[,s]... A simple list or an implied DO list. from, The I/0 statement assigns input values to, or transfers values in the order in which they appear, from left to the 1list elements right. 7.1.5.1 Simple Lists - A simple I/O list element can be a single substring reference, character array element, array, variable, constant, or expression. A simple I/O 1list consists of either a simple I/O 1list element or a group of two or more simple I/0 list elements separated by commas and enclosed in parentheses. a READ or When you use an unsubscripted array name in an I/O 1list, ACCEPT statement reads enough data to fill every element of the array; array. a WRITE, TYPE, or PRINT statement writes all the values in the Data transfer begins proceeds in the order of subscript with the subscript varying most rapidly. two-dimensional initial element progression, of with the array and the leftmost For example, the following defines a array: DIMENSION ARRAY (3,3) statement, If the name ARRAY, with no subscripts, appears in a READ to input record(s) the from values assigns statement that through on, so and ARRAY(l,2), ARRAY(3,1), ARRAY (1,1), ARRAY(2,1), ARRAY (3,3). INPUT/OUTPUT STATEMENTS In in a READ array or ACCEPT statement, variables in the I/0 list can be subscripts or substring references later in the list. used For example: 1250 The input READ (1,1250) J,K,ARRAY (J,K) FORMAT (Il,X,Il,X,F6.2) record contains the following values: 1,3,721.73 When the READ statement is executed, to J and the second to K, thereby values for ARRAY (1,3). must appear An output However, on the ARRAY (J,K). Then the value 721.73 1is assigned to Variables that are to be used as subscripts in this way before (to the left of) their use in the array subscript. statement I/O0O 1list this expression must same the first input value is assigned establishing the actual subscript logical unit. expression cannot refer the same logical unit. An input statement I/O subscript expression substring reference. For to a <can <contain any valid expression. not attempt any further I/0 operations example, function an output subprogram list cannot contain an 1in an array reference statement that I/0 performs 1list I/0 expression, except as or as an expression in on a a 7.1.5.2 1Implied DO Lists - Implied DO lists are used to: specify iteration within an I/0 list; transfer part of an array; or transfer array elements in a sequence different than the order of subscript progression. This type of list element functions as though it were a part of an I/0 statement in a DO loop; it uses the control variable of the implied DO statement to specify the value(s) to be transferred during each iteration of the loop. An implied DO list has the form: (list,i=el,e2[,e3]) list An I/0 An integer, list. el,e2,e3 Arithmetic real, or double precision variable. expressions. The variable i, and the parameters el, e2, and e3 have the same forms and the same functions that they have in the DO statement (see Section 4.3). The list can refer to the variable i (which 1is the control variable) as 1long as it does not change the value of i. The list specifies the range of the implied DO list. For example: WRITE (3,200) WRITE (6,15) READ (1,75) (A,B,C, I=1,3) L,M,(I,(J,P(I),0Q(I,d),d=1,L),I=1,M) (((ARRAY(M,N,I), I=2,8), N=2,8), M=2,8) INPUT/OUTPUT STATEMENTS innermost the The first control variable definition is equivalent to DO loop of a set of nested loops, and therefore varies most rapidly. example: For 150 This WRITE FORMAT statement (6,150) (F10.2) L=1,10), ((FORM(K,L), K=1,10,2) to: 1is similar 150 50 K=1,10,2 50 L=1,10 WRITE (6,150) FORM(K,L) FORMAT (Fl10.2) 50 CONTINUE DO DO Because the inner DO loop is executed ten times for each iteration of the second subscript, L, advances from 1 through 10 1loop, outer the This is the reverse of the for each increment of the first subscript. In addition, K is incremented by 2, subscript progression. of order so only the odd-numbered rows of the array are output. The entire list of the implied control variable is incremented. READ (5,999) (p(I), DO (Q(I1,J), 1list is For example: J=1,10), transmitted before I=1,5) This statement assigns input values to the elements of arrays P and in the the Q order: P(l), Q(1,1), Qo(1,2), P(2), Q(2,1), Q(2,2), ... ... P(5), Q(5,1), Q(5,2), ... , Q(5,10) When processing multidimensional arrays, you can use a combination of fixed subscripts and subscripts that vary according to an implied DO list. For READ example: (3,5555) (BOX(1,J), J=1,10) through BOX(1l,10), to BOX(1l,1) This statement assigns input values then terminates without affecting any other element of the array. The value of the control variable can also be output example: WRITE (6,1111) (I, I=1,20) This statement simply prints the integers 1 through 20. directly. For INPUT/OUTPUT STATEMENTS 7.1.6 Any Transferring READ or another error WRITE Control statement statement if condition. respectively, on the The for End-of-File can specify I/0 statement that specifications end-of-file and or Error control is to transfer to encounters an end-of-file or have error Conditions the following forms, conditions: END=s ' ERR=s — The label transfer. of an executable statement to which control A sequential READ or WRITE statement can contain either above the specifications, unit number, in record any order. number, The and/or or both specification(s) format is must specification. to the follow An end-of-file condition occurs when no more records exist in a sequential file, or when an end-file record produced by the ENDFILE statement is encountered. If a READ statement encounters an end-of-file condition during an I/0 operation, it transfers control to the statement named in the END=s specification. If no END=s specification is present, an error condition occurs. If a READ I/0 or WRITE operation, appears in present, the the statement an executable encounters transfers an control specification. If error terminates program label in the statement END=s or within error to ERR=s I/O The statement it ERR=s the the condition during statement whose no ERR=s execution. an label specification is specification must refer program unit as the I/0 same to statement. An END= specification in a WRITE statement or a direct statement is ignored. If you attempt to read or write a a record number dgreater than the maximum specified for unit, The that also an error condition occurs. access record the READ using 1logical VAX-11 FORTRAN IV-PLUS User's Guide describes system subroutines you can use to control error processing. These subroutines can obtain information from the I/0O system on the type of error that occurred. Examples of READ I/0 statements (8,END=550) follow. (MATRIX(K),K=1,100) This statement transfers control condition occurs on logical unit WRITE This to 8. statement 550 when an 390 when end-of-file (6,50,ERR=390) statement transfers control to statement occurs., and (1,FORM,ERR=150,END=200) statement to error : READ This an transfers statement 200 when control the ARRAY to statement end-of-file 7-6 150 when condition an error occurs. occurs INPUT/OUTPUT STATEMENTS FORMATTED SEQUENTIAL INPUT/OUTPUT 7.2 Formatted sequential I/O statements are used with format specifiers to output data from internal (binary) form to external translate character (readable) form; and to translate input data from external to form. internal READ ACCEPT Formatted Sequential Input Statements 7.2.1 the A formatted sequential READ statement transfers data from specified logical unit. If a formatted sequential READ statement does not have a logical unit number, it uses an implicit logical unit. The formatted sequential ACCEPT statement is similar to a formatted sequential READ statement except that it always uses an implicit logical unit number. Formatted sequential input statements have the forms: READ (u,f[,END=S][,ERR=s])[list] READ £f£[,list] ACCEPT u f s list f[,list] A logical unit number. A format specifier. The label of an executable statement. An I/0 list. A statement of the following form system-defined logical unit: READ 200, to data be read from a ALPHA,BETA,GAMMA transferred Characters causes by formatted sequential statements are translated to the internal form specified by the format specifier. 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 formatted sequential input statement. However, the format specifier can specify that more than one record is to be read during execution of a single : input statement. formatted input statement character constant, input data is read and If the FORMAT statement associated with a contains a Hollerith or stored directly into the format specification. INPUT/OUTPUT STATEMENTS If no I/0 record list and 100 is format READ (5,100) FORMAT 5. If REVIEW The FORMAT 100 the to occurs example: only betveen the 15 characters from the next record statements follow. on logical SECTIONS becomes: (lS5HREVIEWASECTIONS) formatted READ 300 These read statement of transfer For 15 characters are: FORMAT Examples data specifier. (l5HADATAAGOESAHERE) These statements unit present, the sequential (1,300) FORMAT input ARRAY (20F8.2) statements read ARRAY. a record from logical unit 1, and assign fields READ (5,50) CHARV FORMAT (AZ25) 50 These statements read a record from logical character field to character variable CHARV. READ 100 100, (I5, These statements read assign fields BETA. F8.2, assign a logical wunit, variables ALPHA and and CHARAR(5) ACCEPT 200, FORMAT (5A10) These statements assign fields to and F5.1) a record from an implicit integer variable ICOUNT and real CHARACTER*10 200 5, ICOUNT,ALPHA,BETA FORMAT to wunit CHARAR read a record the character from an implicit array CHARAR. logical wunit, and WRITE TYPE PRINT 7.2.2 The Formatted formatted specified Sequential sequential logical unit. Output Statements WRITE statement The formatted sequential TYPE and PRINT formatted sequential WRITE statement, to an implicit logical unit. transfers data to the statements are similar to the except that output is directed INPUT/OUTPUT STATEMENTS The formatted sequential output statements have the form: WRITE TYPE PRINT u (u,f[,ERR=s]) [list] f[,list] f[,list] A logical unit number. f A format specifier. s The label of an executable statement. list An I/O0 list. d to The I/0 list specifies a sequence of values that are converte r. If no characters and positioned as specified by the format specifie I/0 list is present, data transfer occurs only between the format specifier and the record. nt The data transferred by a formatted sequential output thestateme format However, record. d formatte one normally constitutes specifier can specify that additional records are to be written during execution of a single output statement. during the Numeric data output under format control is isrounded ently input subsequ data such (If format. l externa to ion convers To avoid result. may on precisi of loss for additional calculations, loss of precision, use unformatted output.) nt must not exceed The records transmitted by a formatted WRITE statemeFor example, a line accept. can the 1length that the specified device characters. printer typically cannot print a record longer than 132 Examples of formatted sequential output statements follow. 650 WRITE FORMAT (6, 650) ('AHELLOATHERE') These statements write the contents of the FORMAT statement to logical unit 6. CHARACTER*16 NAME,JOB PRINT 400, NAME, JOB 400 FORMAT ('NAME=',A,'JOB=',A) These statements write one record consisting of four fields. 95 WRITE (1,95) AYE,BEE,CEE FORMAT (3F8.5) These statements write one record, logical unit 1. consisting of three fields, to INPUT/OUTPUT STATEMENTS 950 WRITE (1,950) FORMAT (F8.5) These statements each, to In of write three unit 1. the last example, format the FORMAT statement output. new logical AYE,BEE,CEE Each record is time this initiated. separate control before occurs, Thus, the records, consisting of one field reaches the rightmost all elements of the current three record is separate records parenthesis I/0 1list are terminated and a are written. INPUT/OUTPUT STATEMENTS 7.3 LIST-DIRECTED SEQUENTIAL INPUT/OUTPUT List-directed sequential I/O statements provide a way to obtain simple formatted sequential input or output without using FORMAT statements. On input, values are read from the logical unit, converted to internal form, and assigned to the elements of the.I/0O list. On output, values in the I/0 list are converted to character form and written in a fixed format according to the data type of the value. The I/0 list is required. Records written by list-directed list-directed input statements logical values. Both formatted to the same sequential output statements if they contain can be input only numeric by and and list-directed sequential I/O statements can refer 1logical unit. All operations permitted for formatted I/0 are permitted for 1list-directed I1/0. However, backspacing over list-directed records 1leaves the file position undefined. When files are read that contain both formatted and list-directed records, the user program should ensure that each record is read with the same kind of formatting that was used to write it. READ ACCEPT 7.3.1 List-Directed Input Statements A list-directed READ statement transfers data from the specified logical wunit, translates data from external to internal form, and assigns the input values to the .elements of the I/0 list in the order in which they appear, statement does not have logical unit number. The list-directed ACCEPT statement except that it The list-directed input from a to unit right. statements (u,*[,END=s][,ERR=s]) READ *,list have the list *,list u A logical unit number. * Indicates list-directed The of formatting. s label list An I/0 list. an If number, statement is similar to always uses an implicit READ ACCEPT left logical executable statement. a it list-directed uses an READ implicit a list-directed READ logical unit number. forms: INPUT/OUTPUT STATEMENTS The external separators. contains record A value can be: sequence a values of value and constant e A e A null e A repetition of constants in the form r*c e A repetition of null values in the form r* value The following paragraphs describe these values. Each input constant has the form of the corresponding FORTRAN A complex constant has the form of a pair of real or constant. in parentheses. integer constants separated by a comma and enclosed Spaces can occur between the opening parenthesis and the first constant, before and after the separating comma, and between the second A logical constant is the closing parenthesis. and constant A character constant 1is delimited by either T (true) or F (false). any apostrophe in the character constant is represented apostrophes; and hexadecimal octal, Hollerith, by two consecutive apostrophes. constants are not permitted. no A null value is specified by two consecutive commas with A null Spaces can occur between the commas. intervening constant. value specifies that the corresponding list element remains unchanged. A null value cannot be used for either part of a complex constant, but can represent an entire complex constant. 1is a nonzero, r The form r*c indicates r occurrences of ¢ where Spaces are not integer constant and ¢ is a constant. unsigned permitted except within the constant c as specified above. is an input statement tabs -- terminates processing on the all remaining I/0 list elements are unchanged record; and they are The form r* indicates r occurrences of a null unsigned integer constant. A value separator can be: value where tabs @ One or more spaces or e A comma, with or without surrounding spaces or tabs e A slash, When any of the with above or appear r considered part of the constant, without in a surrounding character spaces constant, not value separators. or The end of a record is equivalent to a space character except when it In this case, the end of the record occurs in a character constant. 1is continued with the next constant is ignored and the character in the previous record is the last character That is, record. followed immediately by the first character of the next record. Spaces at'the beginning of a record are ignored unless they are part 1In this of a character constant continued from the previous record. case, the spaces at the beginning of the record are considered part of the constant. Input constants can be any of the following data types: complex, and character. logical, double precision, real, type of the constant determines the data type of the value translation from external to internal 7-12 form. integer, The data and the INPUT/OUTPUT STATEMENTS A numeric a list character element list can element correspond can only correspond to only a numeric to a constant, character and constant. If the data types of a numeric 1list element and its corresponding numeric constant do not match, conversion is performed according to the rules for arithmetic assignment (see Table 3-1). Each input statement will read one satisfy the I/O list. If a slash or more separator exhausted a before all the values the record is ignored. An example of list-directed The program unit consists CHARACTER*14 DOUBLE The D,E LOGICAL L,M I,R,D,E,L,M,J,K,S,T,C,A,B record read contains: (3.4,4.2), following I/0 B, used, the remainder of follows. T (1,*) 6.3 are of: values (3, are 2 ) , T,F,,3*14.6 assigned to the ,'ABC,DEF/GHI''JK'/ I/O list elements: List OWH Value 4 ORI Element A, statements READ 4 The input record to is C PRECISION COMPLEX in records as required occurs or the I/0 list .TRUE. and 6.3 (3.4,4.2) (3.0,2.0) .FALSE. 14 14.6 14.6D0 ABC,DEF/GHI'JK J will be unchanged. WRITE TYPE PRINT 7.3.2 List-Directed Output The list-directed WRITE list to according Statements statement transfers the elements the specified wunit, translating to the data type of the value. and editing The list-directed TYPE and PRINT statements are list-directed WRITE statement, except that output implicit logical unit. in the 1I/0 each value similar to the is directed to an INPUT/OUTPUT STATEMENTS The list—-directed output WRITE (u,*[,ERR=s]) TYPE *,list PRINT *,list statements have the forms: list u A logical unit number. * Indicates list-directed formatting. s The label of an executable statement. character constants, the list An Except I/0 for list. output values have the same forms as the input constant values described above in Section 7.3.1. Character constants are transferred without delimiting apostrophes; each internal apostrophe 1is represented by only one apostrophe. Consequently, records containing list-directed character output can be printed but cannot be used for list-directed input. Table 7-1 lists the default output formats Table 7-1 List-Directed Output Data Type for each data type. Formats Output Format LOGICAL*1 I5 LOGICAL*2 LOGICAL*4 L2 L2 INTEGER*2 17 INTEGER*4 REAL* 4’ REAL*8 I12 1PG15.7 1PG25.16 COMPLEX*8 CHARACTER 1X,'(',1pG14.7, ',', 1PG1l4.7,")" 1X,An (n is the length of the character expression) The list-directed output statements do not produce octal values, null values, slash separators, or repeated forms of values. Each output record begins with a space for carriage control. Each output statement writes one or more complete records. Each output value is contained within a single record, except for character constants that are longer than a record. An example of list-directed output statements PRINT *,'THEAARRAYAZAIS',Z TYPE *, 'THEAANSWERAIS', (I,XX(I),I=1,10) follows. INPUT/OUTPUT STATEMENTS If a program unit consists of: DIMENSION A(5) DATA A/5%*3.4/ WRITE WRITE This (1,*) (1,*) program 'ARRAYAVALUESAFOLLOW' A,5 unit writes the following records: ARRAYAVALUESAFOLLOW AAA3.400000AAAAAAA3.400000AAAAAAA3.400000AAAAAAA3.400000 AAA3.400000AAAAAAAAAAS INPUT/OUTPUT STATEMENTS 7.4 UNFORMATTED SEQUENTIAL INPUT/OUTPUT Unformatted sequential I/0 transfers data in internal (binary) format.-. That 1is, no conversion or editing takes place. Unformatted I/O is generally used when data output by a program will be subsequently input by the same (or a similar) program. Unformatted I/0 saves execution time by eliminating the data translation process, preserves greater precision in the external data, and usually conserves file storage space. READ 7.4.1 The Unformatted Sequential Input Statement unformatted sequential READ statement inputs one unformatted record from the specified logical unit, and assigns the untranslated fields of the record to the I/0 list elements in the order in which they appear, from left to right. The data type of each element determines the amount of data that element receives. The unformatted READ sequential READ statement has the form: (ul,END=s][,ERR=s])[list] u A logical unit number. s The label of an executable statement. ) list An I/0 list. An unformatted sequential READ statement reads exactly one record. 1If the I/0 list does not use all the values in the record (that is, there are more values in the record than elements in the 1list), the remainder of the record is discarded. If the number of list elements is greater than the number of values in the record, an error occurs. If an unformatted sequential READ statement contains no I/O skips over one full record, positioning the file to read the record on the next execution of a READ statement. The unformatted records created Examples READ of sequential READ statement can only be used by unformatted sequential WRITE statements. unformatted (1) FIELDl, sequential This statements from logical unit 8 unit (8) statement to read follow. FIELD2 This statement reads one record to variables FIELD1 and FIELD2. READ input 1list, it following advances logical one record. 1 and assigns values INPUT/OUTPUT STATEMENTS WRITE 7.4.2 Unformatted Sequential Output Statement untranslated The unformatted sequential WRITE statement transfers the values of the elements in the I/O list to the specified logical unit. That is, one unformatted record is output. The unformatted WRITE sequential WRITE statement has the form: (u[,ERR=s]) [list] u A logical unit The of number. S label an executable statement. list An I/0 list. If an unformatted WRITE record is output to the statement contains specified unit. Examples of sequential WRITE This LIST unformatted (1) I/0 statements list, one null of array follow. (LIST(K) ,K=1,5) statement outputs the to logical unit 1. WRITE output no contents of elements 1 through (4) This statement writes a null record on logical unit 4. 5 INPUT/OUTPUT STATEMENTS 7.5 FORMATTED DIRECT ACCESS INPUT/OUTPUT Formatted direct access I/0 transfers character data to and from a file on a direct access device. The OPEN statement (see Section 9.1) establishes the attributes of the direct access file. Each READ or WRITE statement contains a direct access record number. READ 7.5.1 Formatted Direct Access Input Statement The formatted direct access READ record from the direct access specified unit. The <characters internal form according are assigned The formatted direct READ to to the format the elements of access statement transfers the specified file currently connected to the in the record are translated to READ the specifier. The resulting values I/0 list. statement has the form: (u'r,f[,ERR=s])[list] u A logical unit number. r The direct access record number. £ A format specifier. s The list An label of an executable statement. I/0 list. If the I/0 list and format specify more characters than contains, or specify additional records, an error occurs. a record INPUT/OUTPUT STATEMENTS WRITE 7.5.2 Formatted Direct Access Output Statement The formatted direct access WRITE statement transfers record to the direct access file currently connected to list specifies a sequence of values that are translated and positioned as specified by the format specifier. The formatted direct WRITE access WRITE statement has the the specified the unit. The to characters form: (u'r,f[,ERR=s])[list] u A logical unit number. r The direct access record number. f A format specifier. S The label of an executable statement. list An I/0 list. If the values specified by the list the unused portion of the record is If the the I/0 record, list or and format and format do not filled with space specify more specify additional characters records, an error fill the record, characters. than can occurs. fit into INPUT/OUTPUT STATEMENTS 7.6 UNFORMATTED DIRECT ACCESS INPUT/OUTPUT Unformatted direct access I/0 transfers data in internal (binary) form The OPEN or DEFINE FILE statement from a direct access file. and to (see Sections 9.1 and 9.7) establishes the direct Each record number. access attributes of the file. READ or WRITE statement contains a direct access READ 7.6.1 Unformatted Direct Access Input Statement The unformatted direct access READ statement transfers the specified the to file currently connected from the direct access record to record specified unit, and assigns the untranslated fields of the the I/0 list elements. The unformatted direct access READ statement has the form: (u'r[,ERR=s]) READ u A logical r label The list unit number. The direct access s An [list] record number. of an executable statement. I/0 list. is, (that record If the I/0 list does not use all the fields in the there are more fields in the record than elements in the list), the 1If the number of list elements remainder of the record is discarded. is greater than the number of record fields, an error occurs. Examples of unformatted direct access input statements follow. READ (1'10) LIST(1l),LIST(8) This statement reads record 10 of a file on 1logical wunit 1, and a file on logical wunit 4, and assigns two integer values to specified elements of array LIST. READ (4'58) (RHO(N) ,N=1,5) This statement reads record 58 of assigns five real values to array RHO. INPUT/OUTPUT STATEMENTS WRITE 7.6.2 Unformatted Direct Access Output Statement The unformatted direct access WRITE statement transfers the untranslated values of the elements in the I/0 list to the specified record of the direct access file currently connected to the specified unit. The unformatted direct access WRITE statement has the form: WRITE (u'r[,ERR=s]) [list] u A logical unit number. r The direct access record number. s An executable An I/0 statement 1label. list list. If the values specified by the list do not fill portion of the record is filled with zeros. If the list specifies more data than can the fit into record, the the record, an unused error occurs. Examples of unformatted direct access output WRITE (2'35) (3'J) follow. (NUM(K) ,K=1,10) This statement outputs ten integer connected to logical unit 2. WRITE statements values to record 35 of the file ARRAY This statement outputs the entire contents of ARRAY to the record indicated by the value of J in the file connected to logical unit 3. INPUT/OUTPUT STATEMENTS ENCODE DECODE ENCODE AND DECODE STATEMENTS 7.7 The ENCODE and DECODE statements transfer data according to format specifiers, translating the data from internal to character form, and vice versa. ‘Unlike conventional formatted 1I/0 statements, however, these data transfers take place entirely between variables or arrays in the FORTRAN program. The ENCODE and DECODE statements have the forms: ENCODE (c,f,b[ ,ERR=s]) [list] DECODE (c,f,b[,ERR=s8]) [1list] c An integer expression. 1In the ENCODE statement, ¢ is the number of characters (bytes) to be translated to character form. 1In the DECODE statement, ¢ is the number of characters to be translated to f internal A format specifier. error b form. If more than one record is specified, an occurs. The name of an array, array element, variable, or character substring reference. In the ENCODE statement, b receives the characters after translation to external form. In the DECODE statement, b contains the characters to be translated to internal form. s The list label of an executable statement. An I/0O list. 1In the ENCODE statement, the I/O list contains the data to be translated to character form. In the DECODE statement, the 1list receives the data after translation to internal The ENCODE form. statement translates the list elements to character form according to the format specifier, and stores the characters in b, similar to a WRITE statement. If fewer than ¢ characters are transmitted, the remaining character positions are filled with spaces. The DECODE statement translates the character data in b to internal (binary) form according to the format specifier, and stores the elements If b in the list, is an array, similar to a READ statement. its elements are processed in the order of subscript progression. The number of characters that the ENCODE or DECODE statement can process depends on the data type of b in that statement. For example, an INTEGER*2 array can contain 2 <characters per element, so the maximum number of characters is twice the number of elements in that array. A character variable or character array characters equal in number to 1its 1length. element can contain A character array can INPUT/OUTPUT STATEMENTS contain characters equal the number of elements. in number to the length of each element times The interaction between the format specifier and same as for a formatted I/0 statement. An example of the ENCODE and DECODE statements the I/0 list 1is the follows. DIMENSION K (3) CHARACTER*12 A, B DATA A /'123456789012'/ DECODE (12,100,A) K FORMAT (3I4) ENCODE (12,100,B) K(3), K(2), 100 K(1) The DECODE statement translates the 12 characters in A to integer form (specified by statement 100), and stores them in array K, as follows: K(1) K(2) K(3) = = = The ENCODE character as 1234 5678 9012 statement translates form follows: B = the values (K(3), K(2), and K(1l) to and stores the characters in the character variable B '901256781234" CHAPTER 8 FORMAT STATEMENTS FORMAT statements are nonexecutable statements used with formatted I/O statements and with ENCODE and DECODE statements. A FORMAT statement describes the format in which data is to be transferred, and what data conversion and editing are required to achieve that format. FORMAT statements have FORMAT q f (qlf s form: f.s_ ... fnqn) slash (/) record 11 Zero or more the 22 : terminators. A field descriptor or a group of field descriptors enclosed in parentheses. S A field separator. The entire list of field descriptors and field separators, including the parentheses, is called the format specification. The list must be enclosed in parentheses. A field descriptor in a format specification has the form: [r]lcw][.d] r The repeat count for assumed c to be A format code 1. the field descriptor. If you omit r, (I1,0,%2,F,E,D,G,L,A,H,X,T,P,Q,S$, Or it |is :). w The external d The field width. The number of characters to the right of the decimal point. terms r, w, and d must all be unsigned integer constants; r and w must be less than or equal to 32767, and 4 must be less than or equal to 255. The r term is optional; however, you cannot use it in some field descriptors (see Section 8.1.18). The d term is required in some field descriptors and is invalid in others. You are not allowed to use PARAMETER constants for the terms r, w, or d. FORMAT The field descriptors are: ® Integer -- Iw, e Logical -- Lw ® Real, e Character e double Editing, nX, TTMn, STATEMENTS Ow, Zw precision, and complex and nP, character Q, $, : . Section 8.1 describes each The first character in an control information: see and (n Hollerith is a number field descriptor output record Section 8.2 The field separators are comma terminator. Sections 8.3 and field You can and 8.4 separators. create a format instead formats. Fw.d, Ew.d, Dw.d, Gw.d nH, ‘'...', -- Aw positions) the -- format of a during FORMAT constants of or character contains information. carriage in detail. generally for more slash. A slash is describe in detail program statement. -- characters execution Section by 8.5 alsoc a record the functions of using a describes run-time run-time During data transfers, the format specification is scanned from left to right. Data conversion is performed by correlating the elements in the I/0 list with the corresponding field descriptors. In H field descriptors and character constants, data transfer takes place entirely between the field descriptor and the external record. Section 8.6 describes 1in detail the interaction between the format specifier and the I/0 list. Section 8.1 8.7 summarizes the rules for writing FORMAT statements. FIELD DESCRIPTORS A field descriptor describes the several data items; each data an external field. size item and format of a data item in the external medium is or of called The following sections describe each of the field descrlptors in detail. The field descriptors ignore leading spaces in the external field, but treat embedded and trailing spaces as zeros. 8.1.1 The I I Field field Descriptor descriptor transfers decimal integer values. It has the Iw The corresponding I/0 logical data type. list element must be of either integer or FORMAT STATEMENTS w characters In an input statement, the I field descriptor transfers external field and assigns them, as a decimal value, to the the from The external data corresponding I/0 list element as an integer value. must have the form an of integer decimal point or exponent fields. constant; 1t cannot contain a the range of the exceeds field the external the value of If If the first nonblank an error occurs. element, list corresponding treated character of the external field is a minus sign, the field is 1If the first nonblank character is a plus sign, as a negative value. or if no sign appears in the field, the field is treated as a positive Blanks treated as a value of zero. 1is field all-blank An value. following the first non-blank character are treated as zeros. Input Example: Internal Representation External Field Format 2788 -26 312 2788 -26 AAAAAA312 2AA8 14 I3 I9 14 2008 In an output statement, the I field descriptor transfers the value of the corresponding I/0 1list element, right justified, to an external field, the fill not value does the If field w characters long. if the value exceeds the field width, inserted; spaces are leading 1list the If the value of the entire field is filled with asterisks. leftmost, its as sign minus a have will field the negative, is element to therefore be 1large enough The term w must nonblank character. Plus signs, however, are a minus sign, when necessary. for provide suppressed. Output Example: Format Internal Value 284 -284 AA174 ** *kk Not permitted: 284 -284 174 3244 -473 29.812 I3 14 I5 12 I3 17 8.1.2 External Representation error O Field Descriptor The O field descriptor transfers octal values. It has the form: Ow The corresponding I/0 list logical data type. element must be of either integer or In an input statement, the O field descriptor transfers w characters assigns them as an octal value to the and field external the from The external field can contain only corresponding I/0 list element. it cannot contain a sign, a decimal point, the numerals 0 through 7; of value a as An all-blank field is treated or an exponent field. following the first non-blank character are treated as Blanks zero. the range of If the value of the external field exceeds the zeros. corresponding list element, an error occurs. FORMAT Input STATEMENTS Example: Format External Field 05 32767 04 06 03 16234 13AAAA 97A Internal Representation Octal 32767 Not 1623 130000 permitted: In an output statement, the O field descriptor value of the «corresponding I/0 list element, external field w characters long. No signs are error transfers the octal right justified, to an output; a negative value is transmitted in its octal (2's complement) form. If the value does not fill the field, leading spaces are inserted; if the value exceeds the field width, the entire field is filled with asterisks. Output Example: Format 8.1.3 The (Decimal) 06 06 32767 -32767 02 14261 04 27 05 13.52 2 7 Internal Value External Representation ATT7777 100001 * % AA33 Not permitted: error Field Descriptor field descriptor transfers hexadecimal values. It has the form: Zw The corresponding logical data I/0 list element must be of either integer or type. In an input statement, the Z field descriptor transfers w characters from the external field and assigns them as a hexadecimal value to the corresponding I/O list element. The external field can contain only the numerals 0 through 9 and the letters A through F; it cannot contain a sign, a decimal point, or an exponent field. An all-blank field 1is treated as a value of zero. Blanks following the first non-blank external character field error occurs. Input Example: Format In an are exceeds treated the range External A94 A23DEF z7 9AFAAAA Z5 95.AF2 statement, zeros. the the If the corresponding value list of the element, an Internal Hexadecimal Representation Field z3 Z5 output as of A94 A23DE 9AF0000 Not Z field permitted: descriptor error transfers the hexadecimal value of the corresponding I/0 1list element, right justified, to an external field w characters 1long. No signs are output; a negative wvalue 1is transmitted in its hexadecimal (2's complement) form. If the value does not fill the field, 1leading spaces are inserted; if the value exceeds the field width, the entire field is filled with asterisks. FORMAT STATEMENTS Output Example: Format Internal (Decimal) Value 7FFF A8001 10 32767 -32767 16 z4 z5 Z2 Not permitted: error 25.2 z3 External Representation F Field Descriptor §.1.4 The F field descriptor transfers real or double precision values. has the It form: Fw.d real or double The corresponding I/0 list element must be of either or it must be either the real or the imaginary precision data type; part of a complex data type. In an input statement, the F field descriptor transfers w characters from the external field, and assigns them, as a real or double precision value, to the corresponding I/O list element. If the first nonblank character of the external field is a minus sign, the field is treated as a negative value. If the first nonblank character is a plus sign, or if no sign appears in the field, the field is treated as a positive value. An all-blank field is treated as a value of =zero. In all F field descriptors, w must be greater than or equal to d+l. If the field contains neither a decimal point nor an exponent, it is treated as a real number of w digits, in which the rightmost 4 digits If the field contains an are to the right of the decimal point. explicit decimal point, the location of that decimal point overrides the location specified by the field descriptor. If the field contains an exponent (as described in Section 2.3.2 for real constants or Section 2.3.3 for double precision constants), that exponent is used to establish the magnitude of the value before it is assigned to the list element. Input Example: Format External Field Internal Representation F8.5 F8.5 F8.5 F5.2 123456789 -1234.567 24.77E+2 1234567.89 123.45678 -1234.56 2477.0 123.45 In an output statement, the F field descriptor transfers the value of the corresponding I/0 list element, rounded to d decimal positions and If the value right justified, to an external field w characters long. if the value does not fill the field, leading spaces are inserted; exceeds the field width, the entire field is filled with asterisks. (when The term w must be large enough to include a minus sign left the to digit one least at , suppressed) are signs plus necessary; of the decimal point, the decimal point, and d digits to the right of the decimal. Therefore, w must be greater than or equal to d+3. FORMAT Output STATEMENTS Example: Format Internal F8.5 F9.3 F2.1 F10.4 E External A2.35472 A8789.736 * & -23.24352 325.013 AA-23.2435 kkkkk -.2 Field The E field exponential Representation 2.3547188 8789.7361 51.44 F5.2 F5.2 8.1.5 Value -0.20 Descriptor descriptor transfers real form. It has the form: or double precision values in Ew.d The corresponding I/0 list precision data type; or part of a complex data element must be of either it must be either the real type. real or double or the imaginary In an input statement, the E field descriptor transfers w characters from the external field and assigns them as a real or double precision value to the corresponding I/0O list element. This is exactly the same way that the F field descriptor interprets and assigns data. Input Example: Format External Field E9.3 El2.4 E15.3 734.432E3 AA1022.43E-6 52.3759663AAAAA E12.5 210.5271D+10 Note that, in the last example, exponent field indicator as an single precision. In an Internal output statement, the E Representation 734432.0 1022.43E-6 52,.3759663 210.5271E10 the E field E indicator field descriptor if the I/0 descriptor treats the list element transfers the value D is of the corresponding I/0 list element, rounded to d decimal digits, and right justified, to an external field w characters long. If the value does not fill (the field, leading spaces are inserted; if the value exceeds the field width, the entire field is filled with asterisks. When you standard use the form. E field This descriptor, form data consists of output a is minus transferred sign if in a value is point, d the negative (plus signs are suppressed), a zero, a decimal digits to the right of the decimal points, and a 4-character The exponent has one of the following two forms: exponent. E+nn E-nn nn A 2-digit integer constant. The d digits to the right of the decimal value, scaled to a decimal fraction. 8-6 point represent the entire FORMAT STATEMENTS (when sign a minus include to 1large enough The term w must be suppressed), a zero, a decimal point, d signs are plus necessary; equal or Therefore, w must be greater than digits, and an exponent. to d+7. Output Example: Internal Value Format A0 .48E+06 A0.47587E+06 AAAO.690E-03 475867.222 475867.222 0.00069 E9.2 E12.5 E12.3 -0.556E+00 ok ok *kk -0.5555 56.12 E10.3 E5.3 8.1.6 External Representation D Field Descriptor The D field descriptor transfers real or double exponential form. It has the form: precision values in Dw.d double or real The corresponding I/O list element must be of either or it must be either the real or the imaginary type; precision data part of a complex data type. w characters In an input statement, the D field descriptor transfers from the external field, and assigns them as a double precision value the This is the same way that to the corresponding I/O list element. F field descriptor interprets and assigns data. Input Example: Format External Field Internal Representation D10.2 D10.2 D15.3 12345AAAAA AA123 .45AA 367.4981763D+04 12345000.0D0 123.45D0 3.674981763D+06 In an output statement, the D field descriptor has the same effect the used as E field descriptor, except that the D exponent field indicator is in place of the E indicator. Output Example: Format D14.3 D23.12 D9.6 Internal Value 0.0363 5413.87625793 1.2 External Representation AAAAA0.363D-01 AAAAAQ.541387625793D+04 kkkkkkkkk FORMAT 8.1.7 The G Field Descriptor G form the STATEMENTS field descriptor transfers that, in combines effect, form: real the F or double and E precision values field descriptors. in It a has Gw.d The corresponding I/0 list element must be of either precision data type; or it must be either the real part of a complex data type. real or double or the imaginary In an input statement, the G field descriptor transfers w characters from the external field, and assigns them as a real or double precision value to the corresponding I/0 list element. This 1is the same way the F field descriptor interprets and assigns data. In an the output statement, corresponding right which value, I/0 the list G field element, justified, descriptor transfers the value rounded of d positions and The form the magnitude of the to an external field the value is written is a as described in Table 8-1. Effect of Data Table Magnitude Data decimal w characters long. function of 8-1 on G Magnitude are Format Effective Conversion 0.1 0.1 <m<«< 1.0 F(w-4).d, 1.0 <m < 10.0 F(w=4).(d-1), 10d-2 < m < 104-1 F(w=4).1, 'AAAA! 10d-1 < m < 10d F(w=4).0, 'AAAA! m > 10d to follow the numeric in Conversions m< Ew.d 'AAAA' 'AAAA! Ew.d The 'AAAA' field descriptor, which is, field descriptor for values within spaces to data in effect, inserted by the G its range, specifies that four representation. - necessary; of the plus decimal signs point, decimal point, and field descriptor) a greater than or equal are the suppressed), decimal point, at least one d digits to (for values outside the 4-character exponent. to 4 plus 7. digit the to the right of left the range of the G Therefore, w must be effective FORMAT STATEMENTS Output Example: Internal Value Format ~ External Representation A0.123457E-01 0.01234567 Gl13.6 -0.123457AAAA AA1.23457AAAA AA12.3457AAAA AA123.457AAAA A-1234.57AAAA AA12345.7AAAA AA123457.AAAA -0.12345678 1.23456789 12.34567890 123.45678901 -1234.56789012 12345.67890123 123456.78901234 Gl3.6 Gl3.6 Gl3.6 Gl3.6 G13.6 G1l3.6 Gl3.6 -0.123457E+07 -1234567.89012345 Gl3.6 Compare the above example with the following example, which shows same values output using an equivalent F field descriptor. External Representation Internal Value Format AAAAAD.012346 0.01234567 F13.6 AAAA-0.123457 AAAAAL. 234568 AAAAL2.345679 ~0.12345678 1.23456789 12.34567890 F13.6 F13.6 F13.6 AAA123.456789 A-1234.567890 A12345.678901 123456.789012 gk ke dkod ek ok ok ok 123.45678901 -1234.56789012 12345.67890123 123456.78901234 ~1234567.89012345 F13.6 F13.6 F13.6 F13.6 F13.6 the L Field Descriptor 8.1.8 The L field descriptor transfers logical data. It has the form: Lw The corresponding I/O list logical data element must be of either integer or type. In an input statement, the L field descriptor transfers w characters 1If the first nonblank character of the field from the external field. 1is assigned to the corresponding is the letter T, the value .TRUE. character of the field is the nonblank first the If I/0 list element. is .FALSE. letter F, or if the entire field 1is blank, the value assigned. Any other value in the external field produces an error. In an output statement, the L field descriptor transfers either the letter T (if the value of the corresponding I/0 list element is to an external .TRUE.), or the letter F (if the value 1is .FALSE.) The letter T or F is in the rightmost field w characters 1long. position of the field, preceded by w-1 spaces. Output Example: Format Internal Value L5 .TRUE. Ll .FALSE. External Representation AAAAT F FORMAT 8.1.9 The has STATEMENTS A Field Descriptor A field descriptor the form: transfers character or Hollerith values. It Aw The corresponding of character data any other data type, The value of In an from list I/O w must list element can be of any data type. If it character data is transmitted. If it is Hollerith data is transmitted. type, be less than input statement, the A the external record element. depends on or size elements, the size substring elements, the size of the I/O 32767. on the transfers w characters to the corresponding I/0 of characters list element. is the length of the reference, or character array depends to field descriptor and assigns them The maximum number the equal data I/0 List is of that For character can be character variable, stored I/0 list character element. For numeric type, as follows: I/0 list Maximum Number Element of Characters BYTE LOGICAL*1 N LOGICAL*2 LOGICAL*4 0 0O CO > o> DN INTEGER*2 INTEGER*4 REAL REAL*8 DOUBLE PRECISION COMPLEX If w is greater stored in the characters are characters are than the maximum number of characters that can be corresponding I/0 1list element, only the rightmost assigned to that element. The leftmost excess ignored. If w is less than the number of characters can be stored, w characters are assigned to the 1list element, justified, and trailing spaces are added to fill the element. that left Input Example: Format In an of Field Internal Representation (CHARACTER*1) A6 PAGEA# A6 # PAGEA# A6 EA# PAGEA# (CHARACTER*3) A6 PAGEA# PAGEA# (CHARACTER*6) A6 PAGEA#AA PAGEA# (CHARACTER*8) # (LOGICAL*1) A® PAGEA# Ab A# PAGEA# (INTEGER*2) A6 GEA# (REAL) PAGEA# PAGEA#AA (DOUBLE output the appears than statement, corresponding characters less External long. in the transferred. the If w field, 1list the A I/0 is field 1list greater right element, descriptor element than justified, only 8-10 the to the with PRECISION) transfers an 1list the external element, leading leftmost w spaces. contents field the w data If w is characters are " FORMAT STATEMENTS Output Example: External Representation Internal Value Format AOHMS OHMS A5 VOLTS AMPER VOLTSAAAA AMPERESA A5 A5 is supplied. If you omit w in an A field descriptor, a default value If the I/0 list element is of character data type, the default value If the I/0 list element is of is the length of the I/O0 list element. is the maximum number of the default value numeric data type, characters that can be stored in a variable of that data type. 8.1.10 H Field Descriptor The H field descriptor transfers data between the external record and It has the form of a Hollerith itself. the H field descriptor constant: 4 e anlczc3 cn The number of characters to be transferred. An ASCII character. In an input statement, the H field descriptor transfers n characters from the external field to the field descriptor. The first character appears immediately after the letter H. Any characters in the descriptor before input are replaced by the input characters. field In an output statement, the H field descriptor transfers n characters following the letter H from the field descriptor to the external field. An example of H field descriptor usage follows. TYPE 100 FORMAT ACCEPT 200 The 100 FORMAT (41HAENTERAPROGRAMATITLE , AUPATOA20ACHARACTERS) 200 (20HAATITLEAGOESAHEREAAA) transfers statement TYPE in descriptor statement 100 the to from characters wuser's the statement accepts the response from the keyboard, the terminal. placing H field the input The ACCEPT The new characters’ in the H field descriptor in statement 200. data less than 20 enters user the If HERE. GOES TITLE words replace the characters, remainder the spaces to the right. 8.1.10.1 instead Character of an H the H field descriptor is filled with Constants - You field function identically. of descriptor. can use a character constant Both types of format specifier In a character constant, the apostrophe is written as two apostrophes. For example: 50 FORMAT ('TODAY''SADATEAIS:A',I1I2,'/',12,'/',12) A pair of apostrophes used this way is considered a single character. 8-11 FORMAT STATEMENTS 8.1.11 The X X Field Descriptor field descriptor is a positional specifier. It has the form: nX The term n specifies how many character positions are over. The value of n must be greater than or equal to to 1. In an input statement, the X field descriptor specifies n characters in the input record are to be skipped. In an the output statement, external record. the For X field descriptor be passed that the n spaces transfers next to example: WRITE (6,90) NPAGE FORMAT (13H1PAGEANUMBERA,I2,16X,23HGRAPHICAANALYSIS,ACONT.) 90 The WRITE PAGE statement NUMBER prints a record similar nn to: GRAPHIC ANALYSIS, CONT. The term nn is the current value of the variable NPAGE. The numeral 1 in the first H field descriptor is not printed, but is used to advance the printer paper to the top of a new page. Section 8.2 describes printer carriage control. 8.1.12 The T T Field field Descriptor descriptor is a tabulation specifier. It has the form: Tn The term n indicates the character position of the external record. The value of n must be greater than or equal to 1, but not greater than the number of characters allowed in the external record. In an input statement, the T field descriptor positions the record to its nth character position. For example, a READ inputs a record containing: external statement ABCAAAXYZ This record 10 On the an the control of the FORMAT statement: (T7,A3,T1,A3) the READ statement would input the characters XYz first, characters ABC. output terminal, transfer under FORMAT execution, then In is statement the is T to field to begin at devices other descriptor than specifies the nth character the 1line that position printer subsequent of the or data external record. On output to a printer, data transfer begins at position (n-1). The first position of a printed record is reserved for a carriage control character, which is never printed (see Section 8.2). For example: 25 PRINT 25 FORMAT (T51, 'COLUMNA2" 'COLUMNAl"') ',T21, FORMAT STATEMENTS These statements would print the following line: Position 50 Position 20 COLUMN 1 8.1.13 COLUMN 2 Q Field Descriptor The Q field descriptor obtains the number of characters in the input record remaining to be transferred during a READ operation. It has the form: Q The corresponding I/O 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 (E15.7,14,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 By ICHR. array the and exactly that many characters are read into the Q descriptor first in the format specification, you can placing determine the actual length of the input record. no In an output statement, the Q field descriptor has that the corresponding I/0 list element is skipped. 8.1.14 Dollar effect except Sign Descriptor The dollar sign character ($) in a format specification modifies the carriage control specified by the first character of the record. 1In an output statement, the $ descriptor suppresses the carriage return if the first character of the record is a space or a plus sign. 1In an input statement, the $ descriptor is ignored. The $ descriptor is intended primarily for interactive I/0; it leaves the terminal print position at the end of the text (rather than returning it to the left a typed response will follow the output on the same that so margin) line. Thus, the 100 200 statements: TYPE 100 FORMAT ('AENTERARADIUSAVALUEA',S) ACCEPT 200 FORMAT (F6.2) produce a message on the terminal in the form: ENTERARADIUSAVALUE Your response (for example, 12.) ENTER RADIUS VALUE 12. can then go on the same line, as: FORMAT STATEMENTS 8.1.15 Colon Descriptor The colon character (:) in a format specification terminates format control if no more items are in the I/O list. The : descriptor has no effect if I/0 list items remain. For example: PRINT PRINT 1 FORMAT ('AI="',I2, 'AJ=',I2) FORMAT ('AK=",I2,:,"'AL=",12) 2 These 1,3 2,4 statements print the following two lines: I=A3Ad= K=A4 Section 8.6 describes 8.1.16 Complex Data Editing - A complex value or output of descriptors, is a format control an ordered pair complex value in detail. of real values. Therefore, is governed by two real using any combination of the forms Fw.d, Ew.d, input field Dw.d, or Gw.d. In an to a input statement, complex I/0 the 1list respectively. Input successive as fields its are real read and and assigned imaginary parts, Example: Format External F8.5,F8.5 E9.1,F9.3 In two element an Field Internal 1234567812345.67 734.432E8123456789 output statement, the two Representation 123.45678, 734.432E8, parts of a 12345.67 12345.678 complex value are transferred under the control of repeated or successive field descriptors. The two parts are transferred consecutively, without punctuation or spacing, unless the format specifier states otherwise. Output Example: Format Internal 2F8.5 E9.2,'A,A" ,E5.3 8.1.17 Scale Value 2.3547188, 47587.222, External 3.456732 56.123 Representation A2,35472 3.45673 AO.48E+06A, A***** Factor The of scale factor the decimal two parts of The scale factor lets you point in complex has alter, during input or output, the 1location real and double precision values, and in the values. the form: npP A signed or +127. It right, that unsigned integer constant in the range specifies the number of positions, the decimal point is 8-14 to move. -127 to the through left or FORMAT STATEMENTS A scale factor can appear anywhere in a format specification, but must precede the field descriptors that are to be associated with it. For example: nPGw.d nPDw.d nPEw.d nPFw.d On input, the scale factor in any of the above field descriptors multiplies the data by 10**-n and assigns it to the corresponding I/0 list element. For example, a 2P scale factor multiplies an input value by .01, moving the decimal point two places to the left. A -2P scale factor multiplies an input value by 100, moving the decimal two point places to the right. However, if the external field contains an explicit exponent, the scale factor has no effect. Input Exauple: Form;t External Field Internal Representation 3PE10.5 3PE10.5 -3PE10.5 AAA37.614 AA37.614E2 AAAA37.614 .037614 3761.4 37614.0 On output, the effect of the scale factor depends on the type of field descriptor associated with it. For the F field descriptor, the value of the I/0 list element is multiplied by 10**n before transfer to the Thus, a positive scale factor moves the decimal external record. point to the right; a negative scale factor moves the decimal point to the left. For the E or D field descriptor, the basic real constant part of the I/0 list element is multiplied by 10**n, and n is subtracted from the exponent. Thus, a positive scale factor moves the decimal point to the right and decreases the exponent; a negative scale factor moves the decimal point to the left and increases the exponent. Output Example: Format Internal Value External Representation 1PE12.3 1PE12.2 -1PE12.2 -270.139 -270.139 -270.139 AA-2.701E+02 AAA-2.70E+02 AAA-0.03E+04 The effect of the scale factor for the G field descriptor is suspended if the magnitude of the data to be output is within the effective range of the descriptor, because the G field descriptor supplies 1its own scaling function. The G field descriptor functions as an E field descriptor if the magnitude of the data value is outside its range. In this case, the scale factor has the same effect as for the E field - descriptor. On input, and on output under F field descriptor control, a scale factor actually alters the magnitude of the data. On output, a scale factor under E, D, or G field descriptor control merely alters the form in which the data is transferred. 1In addition, on input, a positive scale factor moves the decimal point to the 1left and a negative scale factor moves the decimal point to the right; and, on output, the effect is the reverse. 8-15 FORMAT If you do not specify a scale default scale factor of 0 factor, however, it applies precision field descriptors another scale factor appears. STATEMENTS factor with a field descriptor, a 1is assumed. Once you specify a scale to all subsequent real and double in For the same example: FORMAT statement, unless DIMENSION A(6) DO 10 10 A(I) I = =1,6 25. TYPE 100,A FORMAT(' ',F8.2,2PF8.2,F8.2) 100 produces: 25.00 2500.00 2500.00 2500.00 2500.00 If a second scale factor appears in the control from the first scale factor. Format reversion A scale factor specification. has of 8.1.18 Repeat Counts You apply most can no 0 the following and field descriptors can apply a group of enclosing them with 1is called a statements are these field field an unsigned group repeat H P, or descriptors descriptors in to and equivalent: 50 FORMAT (I8,f8,F8.3,E15.7,F8.3,E15.7,F8.3,E15.7) If you do assumed. not a repeatedly FORMAT specification. to parentheses 50 or X field enclosed X) For example, integer constant. count. For example, The integer the following (218,3(F8.3,E15.7)) 1 be T, equivalent: (3E12.4,415) by takes Section 8.6). an explicit OP is called a repeat count. are FORMAT constant An H, 20 preceding two constant statements (except (E12.4,E12.4,E12.4,15,15,1I5,1I5) you (see by it fields by preceding that field descriptor constant specifying the number of FORMAT fields statement, Group Repeat Counts 20 Similarly, data This two FORMAT effect on the scale factor can only be reinstated number of successive data with an unsigned integer repetitions. 2500.00 2 descriptor, in Thus, which parentheses it specify a could group be could and 3 not repeated repeat otherwise treated count, a as desired a default be repeated, a group number count of of can repeat times. 1 is Section 8.6 discusses how to use parentheses when the number of values to be formatted is greater than the number of format specifications. FORMAT STATEMENTS 8.1.19 Variable Format Expressions You can use an expression in a FORMAT statement wherever you can use an integer (except as the specification of the number of characters in the H field) by enclosing it in angle brackets. For example: (I<J+1>) FORMAT field transfer with a data This statement performs an I (integer) than the value of J at the time the format is width one greater encountered is The expression is re-evaluated each time it scanned. in the normal format scan. If the expression is not of integer data You can use any type it is converted to integer data type before use. valid FORTRAN expression, including function calls and references to dummy arguments. Figure 8-1 shows an example of a variable format expression. The value of a variable format expression must obey on magnitude applying to its use in the format, the restrictions or an error occurs. DIMENSION A(5) 100 DO 10 I =1,10 WRITE (6,100) I FORMAT (I<MAX(I,5)>) 10 CONTINUE DO 201 =1,5 WRITE (6,101) (A(I),J=1,I) (<KI>F10.<I-1>) 101 FORMAT 20 CONTINUE END On execution, these statements produce the following output: 1 2 3 4 5 6 7 8 9 10 1. 2.0 3.00 4.000 5.0000 2.0 3.00 4.000 5.0000 Figure 8-1 3.00 4.000 5.0000 4.000 5.0000 Variable Format Expression 5.0000 Example FORMAT STATEMENTS 8.1.20 Default Field Descriptors If you write the field descriptors 1, O, %2, L, F, E, D, G, or A without specifying a field width value, default values for w and d are supplied based on the data type of the I/0 list element. Table 8-2 lists the default values Default 2 INTEGER*2 INTEGER*4 LOGICAL F, E, G, 2 D REAL, F, E, G, D 15 DOUBLE 7 25 16 COMPLEX PRECISION LOGICAL*1 A 1 LOGICAL*2,INTEGER*2 LOGICAL*4,INTEGER*4 4 REAL, - 2 COMPLEX DOUBLE 4 PRECISION 8 CHARACTER*n for the A corresponding field I/0 descriptor, list the n default element. is the actual length CARRIAGE CONTROL The first printed. The 7 12 A A 8.2 d 2 A that w O, A the Values 0, A of d. List Element L Note w and Table 8-2 Field Descriptor Field Descriptor I, I, for character FORTRAN control of every record transferred to a printer is not it is interpreted as a carriage control character. system recognizes certain characters as carriage Instead, I/0 characters. Table effects. 8-3 1lists these characters and Table 8-3 Carriage Control Characters Character Zffect A (space) Advances one line 0 (zero) Advances two lines 1 (one) Advances to top of next + (plus) $ (dollar page Does not advance (allows overprinting) sign) Advances one and line before printing suppresses return at record 8-18 the carriage end of the their FORMAT Any character other than space, and 1is deleted those from listed in Table 8-3 the print 1line. accidentally omit the carriage of the record is not printed. 8.3 control character, is treated Note that the descriptors commas. field You and character statement 50 A slash slash (/) terminates new record. is equivalent WRITE (6,40) FORMAT (306) WRITE (6,50) use specification the are generally separated record input For terminator or output result in K,L,M N,O,P slashes output. slash n The to bypass first terminates slashes n current to: input records the slash first terminates skipped at skipped the or beginning blank or records. end This of or to output between two or (n-1) field blank the current record; or blank record, and a format on. However, the (I6,2F8.4) multiple are second separate example: blank records. If n consecutive slashes appear descriptors, (n-1) records are skipped on input, records of by to K,L,M,N,O,P (306/16,2F8.4) FORMAT can format use (6,40) FORMAT 40 a also initiates a WRITE 40 This in can descriptors. record, the first as a if you FORMAT SPECIFICATION SEPARATORS Field You STATEMENTS so specification is because the opening and closing parentheses of the format specification are themselves a record initiator and terminator, respectively. For example: 99 The above WRITE (6,99) FORMAT ('1',T51, 'HEADINGALINE'//T51,'SUBHEADINGALINE'//) statements Column 50, top produce of page HEADING (blank line) (blank (blank line) line) the LINE SUBHEADING LINE following output: FORMAT STATEMENTS 8.4 EXTERNAL FIELD SEPARATORS A field descriptor such as Fw.d specifies that an input statement is to read w characters from the external record. If the data field in the external record contains less than w characters, the input statement would read characters from the next data field in the external record, unless the short field is padded with leading zeros When the field descriptor is numeric, you can avoid or spaces. The padding the input field by using a comma to terminate the field. n. specificatio width field descriptor's field the overrides comma This is called short field termination, and 1is particularly useful when you are entering data from a terminal keyboard. You can use it For example: with the I, O, 2, F, E, D, G, and L field descriptors. (5,100) I,J,A,B FORMAT (2I6,2F10.2) READ 100 The above statements read the following record: 1,-2,1.0,35 On execution, the following assignments occur: I =1 J = -2 A =1.0 B = 0.35 Note that the physical end of the record also serves as a field and that the d part of a w.d specification is not terminator; affected by an external field separator. You can use a comma to terminate only fields less than w characters If a comma follows a field of w characters or more, the comma long. is considered 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 0.0, field descriptor specified, the resulting value assigned is 0, 0.D0, or .FALSE.. You cannot use a comma to terminate a field that is controlled by an A, H, or character constant 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. FORMAT 8.5 You RUN-TIME can STATEMENTS FORMAT store format specifications in character variables, character arrays, character array elements, character substrings, or numeric arrays. Such a format specification is called a run-time format, and can be constructed or altered during program execution. A run-time format in an array has the same form as a FORMAT statement, without the word FORMAT and the statement label. The opening and closing parentheses are required. Variable format expressions are not permitted. In the following parenthesis parenthesis to and for |use. 1later example, the three inclusion in the the DATA statement character variable field descriptors to The proper field descriptors format specification. assigns a left FORCHR, and assigns a right four character variables are then selected The selection is based on for the magnitude of the individual elements of the array TABLE. A right parenthesis is then added to the format specification just before the WRITE statement uses it. Thus, the format specification changes with each iteration of the DO loop. REAL TABLE (10,5) CHARACTER*5 FORCHR(0:5), RPAR*1, DATA FORCHR(0) ,RPAR/'(',')'/ DATA DO FBIG,FMED,FSML FBIG,FMED,FSML/'F8.2,','F9.4,','F9.6,"'/ 20 I=1,10 DO 18 J=1,5 IF (TABLE(I,J) .GE. 100.) THEN FORCHR (J) =FBIG ELSE IF (TABLE(I,J) .GT. 0.l1) THEN FORCHR (J) =FMED ELSE FORCHR (J) =FSML END 18 IF CONTINUE FORCHR (5) (5:5)=RPAR WRITE 20 (6,FORCHR) (TABLE(I,J), J=1,5) CONTINUE END NOTE Format specifications stored in arrays are recompiled at run time each time they are character READ statement format back used. If a Hollerith run-time format is used to itself, into the read that data data original will not be available using that array as a specification. is array. into not in or a the copied Thus, it subsequently for run-time format FORMAT STATEMENTS 8.6 FORMAT CONTROL INTERACTION WITH INPUT/OUTPUT LISTS I/O statement. formatted Format control begins with execution of a information provided takes depends on The action format control the and exists) jointly by the next element of the I/O list (if one Both the I/O list next field descriptor of the format specification. and the format specification are interpreted except when repeat counts are specified. irom 1left to right, 1least If the I/0 statement contains an I/O list, you must specify at F, E, D, G, L, A, or Q field descriptor in the format %2, O, I, one An error occurs if these conditions are not met. specification. the from record On execution, a formatted input statement reads one Thereafter, additional specified unit and initiates format control. Format records can be read as indicated by the format specification. control requires that a new record be input when a slash occurs in the the 1last closing parenthesis of format specification, or when the and I/0 list elements remain to be reached is format specification Any remaining characters in the current record are discarded filled. when the new record is read. to the On execution, a formatted output statement transmits a record Records can also be specified unit as format control terminates. if a slash appears in the format written during format control if the last closing parenthesis is reached and more specification or I/0 list elements remain to be transferred. The I, O, 2, F, E, D, G, L, A, and Q field descriptors each correspond No list element corresponds to an H, one element in the I/O list. to character In H and X, P, T, or character constant field descriptor. field descriptors, data transfer occurs directly between the constant external record and the format specification. When format control encounters an I, O, %2, F, E, b, G, L, A, Q or field descriptor, it determines whether a corresponding element exists transfers data format control If one does, I/0 list. in the as appropriate, to or from external format) between the (translated, then proceeds to the next £field record and the 1list element, If no corresponding descriptor (unless the current one is to repeat). list element remains, format control terminates. . is format specification When the last closing parenthesis of the format control determines whether more I/O list elements are reached, 1if However, terminates. format control If not, to be processed. format the all of part or remain, elements list additional specification is reused in a process called format reversion. is In format reversion, the current record is terminated, a new one repeat group the to reverts control format and initiated, specification whose opening parenthesis matches the next-to-last If the format does closing parenthesis of the format specification. to returns not contain a group repeat specification, format control Format the initial opening parenthesis of the format specification. control continues from that point. FORMAT STATEMENTS 8.7 SUMMARY OF RULES FOR FORMAT STATEMENTS The following sections summarize the rules for constructing and using the format specifications and their components, and for constructing external fields and records. Table 8-4 summarizes the FORMAT codes. 8.7.1 General Rules 1‘ A 2. In a field descriptor n must be unsigned FORMAT statement must (They cannot be statements.) such as be can omit labeled. rIw or integer assigned names You always nX, the terms constants greater to constants in the repeat count and r, w, and than zero. PARAMETER field width specification. In a field descriptor such as unsigned 1integer constant. Fw.d, the term d must be an You must specify 4 in F, E, D, and G field descriptors even if it is zero; 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. In a field descriptor characters must printing ASCII In a scale such follow character factor of the as the in H this nHclc2 ... cn, format code. You field descriptor. form nP, n must be a exactly can n use any signed or unsigned integer constant in 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 real or double precision 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. No repeat count is permitted in H, X, T or character constant field descriptors unless these descriptors are enclosed in parentheses and treated as a group repeat specification. If the format associated I/O statement contains an I/0 specification must contain at least descriptor. or A a However, character format an the same as a including the cannot be H, X, P, T, constant. specification reference, this descriptor 1list, the one field in a variable, array element, or an format specification opening and a character array must substring be constructed in a FORMAT closing parentheses. statement, 8-23 FORMAT STATEMENTS Input Rules 8.7.2 l. A minus sign must precede a negative value in an external input field; a plus sign 1is optional before a positive value. On input, an external field under I field descriptor control must be an integer constant. It cannot contain a decimal point or an exponent. An external field under O field descriptor control must contain only the numerals 0 through 7. An external field input under Z field descriptor control must contain only the numerals 0 through 9 and the letters A through F. An external field under O or Z field descriptor control must not contain a sign, a decimal point, or an exponent. You cannot use octal and hexadecimal constants in the form '777'0 or 'AF9'X in external records. On input, an external field under F, E, D, or G field descriptor control must be an integer constant or a real or double precision constant. It can contain a decimal point and/or an E or D exponent field. If an external field contains a decimal point, the actual size of the fractional part of the field, as indicated by that decimal point, overrides the d specification of the corresponding real or double precision field descriptor. If an external field contains an exponent, the (if any) of the corresponding field descriptor for the conversion of that field. The field width specification must accommodate both the numeric character field and any other characters that sign, decimal point, scale factor is inoperative be 1large enough to string of the external are and/or exponent). allowed (algebraic A comma is the only character you can use as an external field separator. It terminates input of fields (for noncharacter data types) that are shorter than the number of characters expected. It also designates null (zero-length) fields. 8.7.3 Output Rules 1. A format specification cannot specify more output characters printer record cannot contain more than including the carriage control character. characters than the external record can contain. For example, a line 133 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 d4+7 characters. 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 deleted from the record. 8-24 FORMAT Summary STATEMENTS Table 8-4 of FORMAT Codes Code Form Effect I Iw Transfers decimal 0 Oow Transfers octal Z Zw Transfers hexadecimal F Fw.d Transfers E Ew.d Transfers real or (E exponent field double precision indicator) values D Dw.d Transfers double values real real (D exponent G Gw.d Transfers integer integer values or integer values double precision values or field real values precision indicator) or double precision on input, acts 1like F code; acts like E code or F code. L Lw Transfers logical data: characters; Transfers on output, character input, transfers transfers T or F A Aw H nHc...cC or -’ Transfers data between an external record and the H field descriptor, or character 'c...c! constant X nX Specifies that T Tn Tabulation specifier Q Q Obtains the number of characters remaining to be transferred in an input record. $ $ suppresses interactive : : Terminates n or on values: on output, Hollerith values characters skipped (on input) or that n be transmitted (on output) is carriage I/0. format control exhausted. are spaces return if the to are be to during I/0 1list CHAPTER 9 AUXILIARY INPUT/OUTPUT STATEMENTS The auxiliary input/output functions. These statements OPEN -- associates statements are: FORTRAN logical perform wunits file with management files. OPEN establishes a connection between a logical unit and device, and declares the attributes required for write operations. a file or read and CLOSE -- terminates a file or device. unit REWIND, BACKSPACE, the and connection between FIND -- perform a logical file and positioning functions. ENDFILE -- writes a special form of record end-of-file condition (and END= transfer) statement reads the record. DEFINE FILE -and associates that causes an when an input describes an unformatted, direct access the file with a logical unit number. file AUXILIARY INPUT/OUTPUT STATEMENTS OPEN 9.1 OPEN STATEMENT An OPEN statement either connects an existing file or creates a new file and connects it to a logical OPEN can specify file attributes subsequent processing. The OPEN statement has the that control to a logical unit, unit. 1In addition, file creation and/or form: OPEN (par | ,par]...) par A keyword key key = specification in one of the following forms: value key A keyword, as described the keyword, below. value Depends Keywords ® ® ® ® ® are on divided Keywords that into as described several identify categories the unit UNIT - logical NAME TYPE DISPOSE - file file file Keywords that describe below. unit and the file FORTRAN access - logical file READONLY - write BLOCKSIZE CARRIAGECONTROL - to processing — describe method the records in the to to be be performed: used file: physical block size printer control type - type - logical record length RECORDTYPE - logical record format that describe of file INITIALSIZE - initial EXTENDSIZE - file that used protection FORM Keywords be structure RECORDSIZE Keywords created: function: file: number ORGANIZATION that on name specification for the file existence status at OPEN existence status after CLOSE ACCESS Keywords based provide FORTRAN storage file formatting allocation when a file increment capability size for direct I/0: ASSOCIATEVARIABLE MAXREC - is allocation allocation additional record the next record number value maximum direct access record number access AUXILIARY INPUT/OUTPUT STATEMENTS e Optional keywords that provide improved performance or special capabilities. processing: BUFFERCOUNT NOSPANBLOCKS SHARED USEROPEN ERR These options are generally transparent to I/O number of I/0 buffers to use are records physical not blocks other programs can the to be simultaneously file user program option to provide lists across access additional OPEN capability statement to which control transfers if an error occurs during execution of the OPEN statement Table 9-1 split the values accepted for each keyword. AUXILIARY INPUT/OUTPUT STATEMENTS Table OPEN Keyword ACCESS Statement Values¥* 'SEQUENTIAL' 9-1 Keyword Values Function Access method Default 'SEQUENTIAL" 'DIRECT' 'APPEND' ASSOCIATEVARIABLE \'4 Next direct access BLOCKSIZE e record Physical block System default I/0 System default size BUFFERCOUNT e Number of buffers CARRIAGECONTROL 'FORTRAN' Print control 'LIST' 'NONE' 'FORTRAN' (formatted) 'NONE' (unformatted) DISPOSE 'SAVE' DISP '"PRINT' 'DELETE' ERR or 'KEEP' ] | File disposi- 'SAVE' tion at close Error transfer label EXTENDSIZE e File allocation increment FORM 'FORMATTED' Format type sys- Depends on access method INITIALSIZE e File MAXREC e Direct access record limit c or tem default 'UNFORMATTED' NAME |Volume File allocation name specification NOSPANBLOCKS ORGANIZATION - 'SEQUENTIAL’ Records do not span blocks File structure 'SEQUENTIAL' 'RELATIVE' *NOTES: <S0T O ¢ is a character expression, numeric array variable name, or numeric array element name is a numeric expression is an external function is a statement label is an integer variable name (continued name, on numeric next page) AUXILIARY INPUT/OUTPUT STATEMENTS Table 9-1 (Cont.) OPEN Statement Keyword Values Default Function Values* Keyword READONLY - Write protec- RECORDSIZE e Record length As specified at Record Direct access - tion 'FIXED' RECORDTYPE "VARIABLE' "SEGMENTED' file creation 'FIXED'. Format~ted seq. access structure - 'VARIABLE'. formatted access Un- seq. - 'SEGMENTED' File sharing - SHARED allowed ‘OLD' TYPE 'NEW' '*SCRATCH' ' "UNKNOWN 'NEW' File status at open UNIT e Logical unit USEROPEN P User program number option *NOTES: is a character expression, numeric array S0 O variable name, or numeric array element name is is is is name, numeric a numeric expression an external function a statement label an integer variable name In most cases, Keyword specifications can appear in any order. and, if not present, default values are provided. are optional; they The following examples illustrate four uses of the OPEN statement: OPEN (UNIT=1, ERR=100) This statement creates a new sequential formatted file on unit 1 the default file name FOROO01.DAT. OPEN with (UNIT=3, TYPE='SCRATCH', ACCESS='DIRECT', INITIALSIZE=50, RECORDSIZE=64) file access This statement creates a 50-block direct The file is deleted at program termination. storage. for temporary AUXILIARY OPEN INPUT/OUTPUT STATEMENTS (UNIT=I, NAME='MTAQ:MYDATA.DAT', BLOCKSIZE=8192, TYPE='NEW', ERR=14, RECORDSIZE=1024, RECORDTYPE='FIXED') This statement creates a file on magnetic for efficient processing. OPEN tape with a large block size (UNIT=I, NAME='MTAO:MYDATA.DAT', READONLY, TYPE='OLD', RECORDSIZE=1024, RECORDTYPE='FIXED', BLOCKSIZE=8192) This statement opens input. the CHARACTER*40 OPEN file created in the previous example for FILENAME (UNIT=1,NAME=FILENAME,TYPE='OLD') This statement opens an existing character variable FILENAME. file, using the name specified by the Sections 9.1.1 through 9.1.21 describe the keywords in detail. As used in these sections, a numeric expression can be any integer, real, or double precision expression. The value of the expression is converted to integer data type before it is wused in the OPEN statement. 9.1.1 This ACCESS keyword ACCESS Keyword has = the form: acc acc The character constant , 'DIRECT', 'SEQUENTIAL', or 'APPEND'. ACCESS specifies whether the file is direct or sequential access. If you specify 'DIRECT', the file is accessed directly. If you specify 'SEQUENTIAL', the file is accessed sequential access and positioning The default 9.1.2 This is 'SEQUENTIAL'. ASSOCIATEVARIABLE keyword has the sequentially. after the last 'APPEND' implies record of the file. Keyword form: ASSOCIATEVARIABLE = asv asv An integer variable. ASSOCIATEVARIABLE each next direct sequential sequential specifies access record access the integer 1I/0 operation, file. in the file. variable contains This the (asv) that, record number specifier is ignored after of for the a AUXILIARY INPUT/OUTPUT STATEMENTS BLOCKSIZE Keyword 9.1.3 This keyword has the format: BLOCKSIZE = bks bks A numeric expression. the I/0 transfer size (in bytes). for BLOCKSIZE specifies the physicalsyste the See device the for lt defau m the is lt defau file. The de for more information. VAX-11] FORTRAN IV-PLUS User's‘Gui BUFFERCOUNT Keyword 9.1.4 This keyword has the form: BUFFERCOUNT = bc bc A numeric expression. with the of buffers to be associated buffe BUFFERCOUNT specifies the number r is each of size The 1I/0. red buffe multi for logical wunit y specif not do you If d. keywor determined by the BLOCKSIZE d. assume is t defaul system the zero, y specif you if BUFFERCOUNT, or CARRIAGECONTROL Keyword 9.1.5 This keyword has the form: CARRIAGECONTROL = ccC cc The character constant 'FORTRAN', 'L,IST', or 'NONE'. of carriage control processing to CARRIAGECONTROL determines the kind The is default for formatted filesRAN' file. be used when printing da files 'FORT '. '"NONE is lt defau the , matte 'FORTRAN'; for unfor pretation of the first character; specifies normal FORTRAN interbetwe en records; and 'NONE' specifies ng spaci e 'LIST' specifies singl no implied carriage control. 9.1.6 DISPOSE Keyword This keyword has two forms: DISPOSE = dis DISP = dis dis The character constant 'SAVE', '"KEEP', 'PRINT', or 'DELETE’. AUXILIARY DISPOSE determines when the retained unit the 'PRINT', and is the disposition closed. after specify spooler is not INPUT/OUTPUT unit the If of the z This keyword to the deleted. If you specify 'DELETE', printed or the deleted. unit file is If you printer file A is scratch has of ERR transfers an error occurs, 9.1.8 an form: executable control occurs. specified, error the s Label This connected specify 'SAVE' or 'KEEP', the is closed; this is the default value. file is submitted to the system line ERR Keyword ERR= is file you deleted. A read-only file cannot be file cannot be saved or printed. 9.1.7 STATEMENTS to ERR statement. the executable applies only and not to no subsequent is opened file or to statement the OPEN specified statement I/0 operations on created. the by in s when which unit. If it an EXTENDSIZE Keyword keyword has EXTENDSIZE the = form: es es A numeric EXTENDSIZE file when specifies additional EXTENDSIZE, is or used. 9.1.9 This expression. if the number file you of storage specify blocks is zero, by which allocated. the system to If extend you do default for a disk not specify the device and written For direct FORM Keyword keyword FORM = has the form: ft ft The FORM using character specifies access whether formatted sequential access files, constant or the 'FORMATTED' file being unformatted files, or 'UNFORMATTED' . opened READ or is 'FORMATTED' is the 'UNFORMATTED' is the default. to WRITE be read statements. default. For AUXILIARY INPUT/OUTPUT STATEMENTS 9.1.10 This INITIALSIZE Keyword keyword has INITIALSIZE the = form: insz insz A numeric expression. INITIALSIZE specifies the number of blocks in of space for a new file on a disk. If you do or if you specify zero, no initial allocation 9.1.11 This the 1initial allocation not specify INITIALSIZE, is made. MAXREC Keyword keyword MAXREC has = the form: mr mr A numeric expression. MAXREC specifies the maximum number of records permitted in a direct access file. The default is no maximum number of records. This specifier is ignored for a sequential access file. 9.1.12 This NAME Keyword keyword NAME = has the form: fln fln A character name, or expression, numeric array numeric element array name, numeric variable name. NAME specifies the name of the file to be connected to the unit. The name can be any file specification accepted by the operating system. The VAX-1ll FORTRAN IV-PLUS User's Guide describes default file name conventipns. If the file name is stored in a numeric variable, numeric array, or numeric array element, the name must consist of ASCII characters terminated by an ASCII null character (zero byte). However, if it |is stored in a character variable, array, or array element, it must not contain a zero byte. AUXILIARY INPUT/OUTPUT STATEMENTS 9.1.13 This NOSPANBLOCKS Keyword keyword has the form: NOSPANBLOCKS NOSPANBLOCKS boundaries. error not to «cross disk block size of a physical block, an occurs. 9.1.14 This specifies that records are If any record exceeds the ORGANIZATION Keyword keyword has the ORGANIZATION = form: org org The character constant 'SEQUENTIAL' or 'RELATIVE'. ORGANIZATION specifies the internal organization of the file. When you create a file, the default is 'SEQUENTIAL'. When you access an existing file, the default is the organization of that file. If you specify ORGANIZATION for an existing file, org must have the same value as that of the existing file. The internal organization of a file does not limit the access allowed a file. Specifically, both sequential and direct access are allowed on files with either sequential or relative organization. However, you must specify fixed length records for direct access, sequential organization files. See the VAX-11 FORTRAN IV-PLUS User's Guide internal file organization. 9.1.15 This READONLY keyword for more information on be read, but prohibits If file contains Keyword has the form: READONLY READONLY specifies that writing to that file. 9.1.16 This RECORDSIZE keyword has RECORDSIZE existing file can Keyword the = an form: rl rl A numeric RECORDSIZE expression. specifies the logical record length. the fixed 1length records, RECORDSIZE specifies the size of each record. If the file contains variable length records, RECORDSIZE specifies the maximum length for any record. If the records are formatted, the length is the number of characters; if the records are unformatted, the 1length is the number of numeric storage units (4 bytes). If the 9-10 AUXILIARY INPUT/OUTPUT STATEMENTS file exists record, an and rl error does not occurs. agree If you with omit the this actual 1length of the specifier for old files, the actual record length specified when the assumed. You must specify RECORDSIZE when you length records or with relative organization. 9.1.17 This RECORDTYPE keyword has RECORDTYPE typ The form: typ character RECORDTYPE was created is files with fixed Keyword the = file create constant specifies whether variable 1length records, file, the defaults are: File Relative Direct 'FIXED', the or 'VARIABLE', file segmented Type 'SEGMENTED'. fixed records. Default organization access has or Record 1length records, When you create a Type 'FIXED® files 'FIXED' Formatted sequential access files 'VARIABLE' Unformatted sequential access files 'SEGMENTED' Segmented records consists of one or more variable 1length records. Using segmented records allows a FORTRAN 1logical record to span several physical records. Only sequential access, unformatted files with sequential organization can use segmented records. You cannot specify 'SEGMENTED' for any other file type. If you do not specify RECORDTYPE when accessing an existing record type of the file is used. An exception to this is access, have unformatted a default of files with sequential organization: file, the sequential these files 'SEGMENTED'. If you specify RECORDTYPE, existing file. typ must In fixed length record files, if an a full record, the record is filled or zeros (for an unformatted file). match the record type of the output statement does not specify with spaces (for a formatted file) 9-11 AUXILIARY 9.1.18 This IRPUT/OUTPUT STATEMENTS SHARED Keyword keyword has the form: SHARED SHARED specifies that the file is to be opened for more than one program executing simultaneously. See the VAX~11l FORTRAN on this keyword. 9.1.19 This User's Guide for additional access by information TYPE Keyword keyword TYPE typ 1IV-PLUS shared The = has the form: typ character constant 'OLD', 'NEW', 'SCRATCH', or 'UNKNOWN'. TYPE specifies the status of file to be opened. If you specify 'OLD', the file must already exist. If you specify 'NEW', a new file is created. If you specify 'SCRATCH', a new file is created and it is deleted when the file 1is closed. If you specify 'UNKNOWN', the processor will first try 'OLD'; if the file 1is not found, the processor will use 'NEW', thereby creating a new file. The default is 'NEW'. 9.1.20 This UNIT Keyword keyword UNIT = has the form: u A numeric expression. UNIT specifies the logical unit to which a file is to be connected. The unit specification must appear in the list. Another file cannot be connected to the logical unit when the OPEN statement is executed. 9.1.21 The USEROPEN Keyword keyword has USEROPEN p An = external the form: p function name. The USEROPEN keyword specifies a controls the opening of the user-written external function that file. Knowledgeable users can employ additional features of the operating system which are not directly available from FORTRAN, while retaining the convenience of writing programs in FORTRAN. See the VAX-11l Common Run-Time Procedure Library Reference Manual for more information on USEROPEN. AUXILIARY INPUT/OUTPUT STATEMENTS CLOSE 9.2 CLOSE STATEMENT The CLOSE statement disconnects a file from a unit. DISPOSE CLOSE (UNIT=u|{, = p| It has the form: [,ERR=s]) DISP u A logical p unit number. [ [] » . A character constant that determines the disposition of the Its values are 'SAVE', 'KEEP', 'DELETE', and 'PRINT'. . file. s The label of an executable statement. If you specify either 'SAVE' or 'KEEP', the file is retained after unit 1is closed. If you specify 'PRINT', the file is submitted to line printer spooler and is not deleted. If you specify 'DELETE', file is deleted. For scratch files, the default is 'DELETE'; for the the the all other files, the default is 'SAVE'. The disposition specified in a CLOSE statement supersedes the disposition specified in the OPEN statement, except that a file opened as a scratch file cannot be saved or printed, nor can a file opened for read-only access be printed or deleted. For example: CLOSE (UNIT=1,DISPOSE='PRINT') This statement closes the file on unit 1 printing. and submits ,ERR=99) CLOSE (UNIT=J,DISPOSE="DELETE' This statement closes the file on unit J and deletes it. the file for AUXILIARY INPUT/OUTPUT STATEMENTS REWIND 9.3 The the REWIND STATEMENT REWIND statement beginning of the REWIND currently open the form: sequential file at u A logical The unit number For example: REWIND repositions a file. It has unit number. must refer to an open file on disk or magnetic tape. 3 This statement repositions currently open file. You must not issue direct access. a REWIND 1logical statement 9-14 wunit for a 3 to file the that beginning is open of for AUXILIARY INPUT/OUTPUT STATEMENTS BACKSPACE 9.4 BACKSPACE STATEMENT The BACKSPACE statement repositions a currently open sequential file at the beginning of the preceding record. When the next I/O statement for the unit executes, that record is available for processing. The BACKSPACE statement has the form: BACKSPACE u A logical unit number. The unit number must refer to an open file on disk or For tape. magnetic example: BACKSPACE 4 This statement repositions the open file on beginning of the preceding record. 1logical wunit You must not issue a BACKSPACE statement for a file that is 'DIRECT' or 'APPEND' access. 4 to the open for ‘ AUXILIARY INPUT/OUTPUT STATEMENTS FIND 9.5 FIND STATEMENT The FIND statement positions a direct access file on a specified unit to a particular record and sets the associated variable of the file to that The record FIND number. statement FIND has direct access unit number must The record For the transfer number defined place. form: record refer to cannot be for the number. an open direct less than 1 or access greater file. than file. the number of example: FIND (1'1l) This statement positions logical unit file; the file's associated variable FIND This 1 to the is set to first 1. record of the (4'INDX) statement positions content of takes unit number. The records data (u'r) A logical The No of INDX; the the file file's to the associated INDX. 9-16 record variable identified is set to by the the value AUXILIARY INPUT/OUTPUT STATEMENTS ENDFILE 9.6 ENDFILE STATEMENT The ENDFILE statement writes an end-file record to the specified unit. It has the form: ENDFILE u A logical unit number. An end-file record can be written only to sequentially accessed, sequentially organized files containing variable length records. For example: ENDFILE 2 This statement outputs an end-file record to logical 9-17 unit 2. AUXILIARY INPUT/OUTPUT STATEMENTS DEFINE FILE 9.7 DEFINE The DEFINE FILE associated preferred FILE STATEMENT way size and The DEFINE statement with to a do this.) structure of FILE DEFINE describes 1logical wunit The FILE u DEFINE the direct statement has direct (m,n,U,asv) FILE access the access number. (See files that Section statement 9.1 are for establishes file. a the form: [,u(m,n,U,asv)] ... u A logical unit A numeric expression that specifies the number expression that specifies the length, number. m file. of records in the n A numeric (2 bytes), of each record. in 16-bit words U Specifies only that the file is unformatted acceptable entry in this position. (binary); this 1is the asv An integer variable, At the end of of the next DEFINE FILE n 1l6-bit records in DEFINE DEFINE higher specifies called direct the numbered that a associated access I/0 record file in variable operation, the containing m file the is fixed of the file. record number assigned length to must that FILE be executed refers also to the before specified establishes the the first direct access file. integer wvariable v. records words each exists, or is to exist, on logical unit u. the file are numbered sequentially from 1 through m. FILE statement each asv as of The I/0 the associated variable of the file. At the end of each direct access I/0 operation, the FORTRAN I/O system places in asv the record number of the record immediately following the one just read or written. Since the associated variable always points to the next sequential record in the file (unless it 1is redefined by an assignment, input, or FIND statement), processing as the For direct of record access the file, number I/O statements using the can associated perform variable specifier. sequential of the file example: DEFINE This file FILE statement of 1000 3 (1000,48,U,NREC) specifies that fixed 1length long. are the by logical unit 3 records; each is to be connected to a record is 48 16-bit words The records are numbered sequentially from 1 through unformatted. After each direct access I/0 operation on integer variable NREC will contain the record number of immediately following the record just processed. 1000, and this file, the record APPENDIX A CHARACTER SETS FORTRAN CHARACTER SET A.1l The FORTRAN character set consists of: 1. The letters A through Z and a through z 2. The numerals 0 3. The following special characters: through 9 Name Character Name Character A Space or tab ! Apostrophe = Equal sign " Quotation mark + Plus sign $ Dollar sign - Minus sign _ Underline * Asterisk ! Exclamation point / Slash : Colon ( Left parenthesis < Left angle bracket ) Right parenthesis > Right angle bracket ’ Comma % Percent sign . Period & Ampersand Other printing characters can appear in a FORTRAN statement only as part of a Hollerith or character constant. Any printing character can Printing characters are characters whose ASCII appear in a comment. codes are in the range 20 through 7D. See Table A-1. CHARACTER SETS A.2 ASCII CHARACTER SET Table A-1 is a table representing the ASCII characte r 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, use the hexadecimal corresponds to hexadecimal digit position. equal sign the row in the "units" that corresponds to For example, the value of the is 3D. position, At the top left of the hexadecimal digit that and the use the column in the "16's" character representing the Table A-1 ASCII Character Set Columns 0 2 3 4 5 6 7 0 NUL DLE 1 2 SP SOH STX 0 DCl1 DC2 @ P DC3 DC4 q r S ENQ ACK BEL NAK SYN ETB % & ' 8 5 6 7 BS E F G CAN Q R S T U A4 W a b c 5 6 7 A B C D P ETX EOT 1 2 3 4 \ 3 4 ! " # § ( 9 8 H EM X LF ) SUB 9 t u A w X A HT d e f g h * I : Y VT y/ ESC i j y B J + ; C K FF [ FS k , { D < CR L GS \ 1 l = M E ] SO m RS } . > N F - sI n Us / ~ ? 0 _ 0 DEL NUL Null SOH DLE Start Data of Heading Link STX Start DC1l of Device Text Control 1 ETX End DC2 of Text Device Control 2 EOT DC3 End of Device Transmission Control 3 DC4 Device z Escape Control 4 Negative Acknowledge ENQ Enquiry ACK Acknowledge BEL SYN Bell Synchronous BS Backspace ETB End HT Horizontal CAN Cancel EM End NAK of VT Tabulation Feed Vertical Tab FF Form Feed CR SO FS Carriage Return Shift Out File GS Group LF A.3 1 Line SI Shift Sp Space RADIX-50 In CONSTANTS AND SUB ESC Idle Transmission Block of Medium Substitute Escape Separator RS Us Separator Record Separator Unit Separato DEL Delete CHARACTER SET Radix-50 is a special character data re presentation in which up to 3 characters can be encoded and packed into 16 bits. The Radix-50 character set is a subset of the ASCII character set. It is for compatibility with PDP-11 FORTRAN. provided CHARACTER SETS The Radix-50 characters and their corresponding code values are: Radix-50 Value AESCII Octal (Octal) Equivalent Character 0 1 - 32 33 34 35 36 - 47 40 101 - 132 44 56 Space A -2 $ . (Unassigned) 0 -9 60 - 71 Radix-50 values are stored, up to 3 characters per word, them into single numeric values according to the formula: ((i * 50 + j) * 50 + by packing k) where i, j, and k represent the code values of 3 Radix-50 characters. Thus, the maximum Radix-50 value is: 47*50*50 + 47*50 + 47 = 174777 A Radix-50 constant has the form: chlcz...cn n An unsigned, nonzero integer constant that states the number of characters to follow. < A character from the Radix-50 character The maximum number of characters is 12. set. The character mnmust count in the character string (the space include any spaces that appear You can use Radix-50 character). Radix-50 character is a valid constants only in DATA statements. Examples of valid and invalid Radix-50 constants are: valid Invalid 4RABCD 4RDKO: (colon is not a Radix~-50 character) 6RATOAAA when a Radix-50 constant is assigned to a numeric variable or array the number of bytes that can be assigned depends on the data element, constant If the Radix-50 2-2). type of the component (see Table contains fewer bytes than the length of the component, ASCII null If the constant characters (zero bytes) are appended on the right. contains more bytes than the length of the component, the rightmost characters are not used. APPENDIX B FORTRAN LANGUAGE SUMMARY B.1 EXPRESSION OPERATORS The following lists the expression operators order of descending precedence: each data type in Operates upon: Operation Data Type Operator Arithmetic *% Exponentiation *,/ Multiplication, +,- Addition, subtraction, unary plus and minus Character // Concatenation Character expressions Relational .GT. Greater than Arithmetic, logical, .GE. Greater than or expressions (all Arithmetic or logical expressions division equal to or character relational operators have equal priority) .LT. Less than .LE. Less than or equal to LEQ. Equal .NE. Not equal to to FORTRAN LANGUAGE Data Type Operator Logical SUMMARY Operation .NOT. .NOT.A is only if A +AND. A.AND.B .OR. only are both A.OR.B true if and is false is and Operates true true Logical or integer expressions if if A and true is upon: B if either A or B or both are true .EQV. A.EQV.B is true only if A and are both true and .XOR. B.2 B are A.XOR.B both is if B or and A true if .XOR. and if A is true and false or B is true and is and false only B is A .EQV. have equal priority false STATEMENTS The following FORTRAN statement. reference. manual summarizes IV-PLUS that The the language, statements are "Manual Section" The describes each column in available the listed statement Form ACCEPT statements including alphabetically indicates detail. for See See READ, READ, A variable of section of the Section 7.2.1 7.3.1 Assignment name, an array element character substring name a An expression Assigns each ease Formatted Sequential List-Directed or VAX-11 of Manual 3.1, v=e e the the form Effect Arithmetic/Logical/Character v in general name, the value of the arithmetic, logical, or character expression to the variable. 3.2, 3.3 FORTRAN LANGUAGE SUMMARY Arithmetic Statement Function 6.2.1 f(lpl,pl...]1)=e £ A symbolic name P A symbolic name e An expression Creates a user~defined function having the variables p as dummy arguments. When referred to the expression is evaluated using the actual arguments in the function call. ASSIGN s TO v 3.4 s Label v An of an integer executable statement variable name Associates the statement label s with the integer variable v for later use in an assigned GO TO statement. BACKSPACE u u 9.4 An integer expression Backspaces the currently open logical unit u one record. BLOCK DATA nam file on [nam] 5.10 A symbolic name Specifies the subprogram BLOCK DATA subprogram. that follows as a 4.5 CaLL f[([a]l[,[al}l...)] 6.2 £ A subprogram name or entry point a An expression, an array name, a procedure name, or an alternate return specifier. An alternate return specifier is *s or &s, where s is the label of an executable statement. Calls the subroutine subprogram with the name specified by f, passing the actual arguments arguments a in to replace the the dummy subroutine definition. FORTRAN LANGUAGE P One of the UNIT e = following DISPOSE DISPOSE DISPOSE = = = 'SAVE' 'KEEP' 'DELETE' DISPOSE = ‘'PRINT' ERR = e An s Label [/[cb]/] integer of expression an nlist cb A common nlist A list array forms: s executable Closes the specified be abbreviated DISP. COMMON SUMMARY statement file. DISPOSE can [[,]1/[cb]l/nlist]... block of name one or names, separated by or more variable names, array declarators commas Reserves more space one or under the name the variables 5.4 blocks of specified associated with storage to contain that block name. CONTINUE 4.4 Causes no processing. DATA nlist/clist/[[,] nlist A list array nlist/clist/]... of one or names, more array 5.7 variable elemeit names, names, or character substring names separated by commas. Subscript expressions and substring expressions must be constant. clist A by list of commas, where j one or each is a more constants separated optionally preceded nonzero, unsigned by integer constant. Initially stores elements of clist in the corresponding elements of nlist. j*, FORTRAN LANGUAGE DECODE SUMMARY (c,f,b[,ERR=s]) [list] c An integer £ A format b A variable name, element name, or s A label list An 7.7 expression specifier array name, array character substring of an executable name statement I/0 list. Reads ¢ characters from buffer b and assigns values to the elements in the list converted according to format specification f. DEFINE FILE u(m,n,U,v)[,u(m,n,U,v)]... u An integer expression m An integer expression n An integer expression v An integer variable 9.7 name Defines the record structure of a direct access file where u is the logical unit number, m is the number of fixed length records in the file, n is the length in words of a single record, U is a fixed argument, and v is the associated variable. DIMENSION a(d) a(d)[,a(d)]... An 5.3 array declarator Specifies arrays. storage space requirements for FORTRAN LANGUAGE SUMMARY DO s [,] v = el,e2[,e3] 4.3 s The label of an v A variable name executable statement ei,e2,e3 Numeric expressions Executes the DO loop by performing the ‘following l. Set v 2. Execute all statements statement number s 3. Evaluate v = v+e3 4. Repeat steps iterations: steps: =el MAX (1, 2 through through 3 for the INT((e2 - el)/e3) following + 1) ELSE 4.2.3 Defines a block of statements to be executed if logical expressions in previous IF THEN and ELSE IF THEN statements have values of false. See ELSE IF (e) e IF THEN. THEN ‘ 4.2.3 A logical expression Defines a block of statements to be executed if logical expressions in previous IF THEN and ELSE IF THEN statements have values of false, and the logical expression e has a value of ENCODF true. See IF THEN. (c,f,b[,ERR=s]i[list] 7.7 c An integer expression £ A format specifier b A variable name, element name, or s A label list An I/0 list array name, array substring name of an executable statement Writes c characters into buffer b which contains the values of the elements of the list, converted according to format specification f. FORTRAN LANGUAGE SUMMARY END 4.9 Delimits a program ENDFILE unit. u u 9.6 An integer variable Writes an end-file unit u. END or constant record on logical IF 4.2.3 Terminates block IF construct. THEN. See IF END=s,ERR=s 7.1.6 9.1.7 s A label of Transfers an executable control on statement end-of-file or error condition. This is an optional element in each type of I/0 statement and allows the program to transfer to statement number s when an end-of-file (END=) or error ENTRY nam (ERR=) condition occurs. [([pl[,p]l...1)] nam A subprogram P A symbolic 6.2.4 name name Defines an alternative entry point within a subroutine or function subprogram. EQUIVALENCE (nlis [, (nlist)]... t) nlist A list array of 5.5 two or more variable names, names, array element names, or character substring names separated by commas. Subscript expressions and substring expressions must be constants. Assigns each of the names in nlist the same storage location. FORTRAN LANGUAGE SUMMARY EXTERNAL ([*]v[,[*]v]... A v 5.6 subprogram name Defines the names specified as user-defined subprograms. FIND (u'r) 9.5 u An integer expression r An integer expression Positions the file on logical unit u to record r and sets the associated variable to record number r. FORMAT (field specification,...) 8.1 - 8.7 Describes the format in which one or more records are to be transmitted; a statement label must be present. [typ] FUNCTION nam[*n] [([p[,pl...]1)] 6.2.2 typ A data type specifier nam A symbolic name *n A data type length specifier p A symbol name Begins a function subprogram, the program name names (p). can be included. and indicating any dummy argument An optional type specification GO TO s s 4.1.1 A label of an executable statement Transfers control to statement number s. FORTRAN GO TO (slist)|[,] slist LANGUAGE SUMMARY. e 4.1.2 A list of one or more statement labels separated by commas An integer Transfers expression control to the statement by the value of e (if e=1, specified control transfers label; if to the e=2, control second statement first statement transfers to the If e is less than 1 number of statement transfer GO TO v label, etc.). or greater than the labels present, no takes place. [[,](slist)] 4.1.3 v An slist A list of one or more statement labels separated by commas integer variable name Transfers controi to the statément*most recently associated with v by an ASSIGN statement. IF (e) sl,s2,s3 e An S A 4.2.1 expression label of Transfers depending an executable statement control to statement si value of e (if e is less than zero, control transfers to sl; 1f e equals zero, control transfers to s2; if e is greater than zero, control transfers to s3). IF (e) the st An st on Any expression executable logical statement IF Executes the statement expression has a value except if the of true. a DO logical or FORTRAN LANGUAGE SUMMARY 4.2.3 IF (el) THEN block ELSE IF (e2) THEN block ELSE block END IF el,e2 Logical expressions block A series of zero or more FORTRAN statements. Defines blocks of statements and If the conditionally executes them. logical expression in the IF THEN statement has a value of true, the first block is executed and control transfers to the first executable statement after the END IF statement. If the logical expression has a value of false, the process is repeated for the next ELSE IF THEN If all logical statement. expressions have values of false, the ELSE block is executed. If there is no ELSE block, control transfers to the next executable statement following END IF. 5.1 IMPLICIT typ (al,al...)[,typ(al,al...)]... typ A data type specifier a Either a single letter, or two letters in alphabetical order separated by a hyphen (i.e., X-Y) The element a represents a single (or a range of) letter(s) whose presence as the initial letter of a variable specifies the variable to be of that data type. INCLUDE 'file specification’ 'file specification’ A character constant Includes the source statements in the compilation from the file specified. 1.5 FORTRAN LANGUAGE SUMMARY OPEN (par[,par]...) A keyword forms: par specification in one of the following key key = value key A keyword, as described below. value Depends on below. the as keyword, Keyword Values ACCESS 'SEQUENTIAL' 'DIRECT' 'APPEND' ASSOCIATEVARIABLE BLOCKSIZE v e BUFFERCOUNT e CARRIAGECONTROL { described 'FORTRAN' 'LIST' 'NONE' 'SAVE' or 'PRINT' 'DELETE" DISPOSE} DISP ERR s EXTENDSIZE e FORM 'KEEP' 'FORMATTED' 'UNFORMATTED' INITIALSIZE e MAXREC e NAME c NOSPANBLOCKS ORGANIZATION 'SEQUENTIAL"' 'RELATIVE' R&\DONLY RECORDSIZE e RECORDTYPE 'FIXED' 'VARIABLE' ' SEGMENTED' SHARED TYPE 'OLD’ 'NEW' 'SCRATCH' ' UNKNOWN' UNIT e USEROPEN p A character expression, numeric array name, numeric variable name, numeric array element name, or Hollerith constant A numeric expression A program unit A statement An integer Opens a name label variable file on the name specified according to the parameters the keywords. logical specified unit by FORTRAN LANGUAGE SUMMARY PARAMETER p=c [,p=c]... A symbolic 5.8 name A constant or compile-time constant expression Defines a symbolic name for PAUSE a constant. [disp] disp 4.7 A decimal digit string containing 1 to 5 digits or a character constant Suspends program execution and prints display, if one is specified. PRINT See WRITE, See WRITE, the Formatted Sequential List-Directed 7.2.2 7.3.2 PROGRAM nam nam 5.9 A symbolic name. Specifies a name for READ (u,f[,END=s][,ERR=s]) [list] READ f[,list] the main program. 7.2.1 ACCEPT f[,list] . u An integer expression f A format s A label list An specifier of an executable statement I/0 list Reads one or more logical records from unit u and assigns values to the elements in the list. The records are converted according to the format specifier (f). FORTRAN LANGUAGE READ SUMMARY (u'r,f[,ERR=s])[list] 7.5.1 u An integer expression r An integer expression £ A format s A label list An specifier of an executable statement I/0 list Reads record r from unit u and assigns values to the elements in the list. The record is converted according to f. READ (u[ ,END=s] [ ,ERR=s] ) [1list] u s list An integer A label of An I/0 list 7.4.1 expression an executable statement Reads one unformatted record from unit u, and assigns values to the elements in the list. READ(u'r [ ,ERR=s]) [list] 7.6.1 u An integer expression r An integer expression s A list An label of an executable statement I/0 list Reads record r from unit u, and assigns values to the elements in the list. "FORTRAN LANGUAGE READ (u,*[,END=s][,ERR=s])list READ *,list SUMMARY 7.3.1 ACCEPT *,list u An integer * Denotes list-directed formatting S A label list An I/0 list of expression an executable statement Reads one or more logical records from unit u and assigns values to the elements in the list. The records are converted according to data type of the list element. RETURN the 4.6 [i] Returns control to the calling program from the current subprogram. The optional argument is an integer value that indicates which is to be taken. REWI ND alternate return 9.3 u u An integer expression Repositions logical unit u to the beginning of the currently opened file. [displ STOP disp A decimal digit string containing digits or a character constant 1 to 5 Terminates program execution and prints the display, if one is specified. SUBROUTINE nam{ ([p[,p]l...])] nam A symbolic name p A symbolic name 6.2.3 Begins a subroutine the program names TYPE name and subprogram, indicating any dummy argument (p). See WRITE, See WRITE, Formatted Sequential List-Directed 7.2.2 7.3.2 FORTRAN LANGUAGE Type SUMMARY Declaration 5.2 typ vi,v]... typ One of the following data type specifiers: BYTE LOGICAL LOGICAL*1 LOGICAL*2 LOGICAL*4 INTEGER INTEGER*2 INTEGER*4 REAL REAL*4 REAL*8 DOUBLE PRECISION COMPLEX COMPLEX*8 CHARACTER*1len CHARACTER®* (*) A variable name, array name, function or function entry name, an array declarator. The name or can optionally be followed by a data type length specifier (*n). For character entities, the length specifier can be *len or *(¥*),. The symbolic names (v) specified data type. VIRTUAL assigned the a{(d)[,a(d)]... 5.3 Equivalent to WRITE (u,f[,ERR=s])[1list] PRINT f[,list] TYPE f£f[,list] An list are integer A format A label An the DIMENSION statement. 7.2.2 expression specifier of an executable statement I/0 list Writes one or u, containing in the list. according to more logical records to unit the values of the elements The f. records are converted FORTRAN LANGUAGE SUMMARY WRITE (u'r,f[,ERR=s]) [list] u An integer expression r An integer expression f A format specifier s A label of an executable statement list An I/0 list 7.5.2 Writes the values of the elements of the list to record r on unit u. The record is converted according to £. WRITE (ul[,ERR=s])[list] u An integer expression s A label of an executable statement label list An I/0 list 7.4.2 Writes one unformatted record to unit u containing the values of the elements in the list. WRITE (u'r[,ERR=s]) [list] u An integer expression r An integer expression S A label of an executable statement label list An I/0 list Writes record r to unit u containing the values of the elements in the list. 7.6.2 FORTRAN LANGUAGE SUMMARY WRITE (u,*[ ,ERR=s])1list PRINT TYPE 7.3.2 *,list *,list u An integer expression * Denotes list-directed s A label of list An I/0 list an executable Writes one or more u containing the list. according aelement. B.3 formatting the statement logical values of records the to unit elements in The records are converted to the data type of the list LIBRARY FUNCTIONS Table B-1 lists the VAX-11 FORTRAN IV-PLUS generic functions and processor-defined functions (listed in the column headed "PDF Name"). Superscripts in the table refer to notes, which follow the table. FORTRAN LANGUAGE SUMMARY Table B-1 Functions Square Root’ Generic and Processor-Defined Functions Number of | Generic | PDF Type of Type of Arguments | Name | Name Argument Result 1 SQRT | SQRT DSQRT CSQRT al” Natural Logarithm? 1 LOG log. a Common Logarithm? ALOG DLOG CLOG 1 Real Double Complex Real Real Double Complex Real Double Double Complex Complex LOG10 | ALOG10 | Real Real DLOG10 | Double Double EXP DEXP Real Double logyea Exponential e? 1 Sine® 1 EXP CEXP SIN » Sina Cosine® DSIN CSIN 1 CcOS coS DCOS CCOS Cos a Tangent? SIN 1 TAN TAN 1 ASIN ASIN 1 ACOS | ACOS 1 ATAN | ATAN DTAN Real Double Complex Real Double Complex Real Double Complex Real Double Complex Real Double Complex Complex Real Real Double Double Tana Arc Sine*S DASIN Real Double Real Double Arc Sin a Arc Cosine*® DACOS Real Double Real Double Arc Cos a Arc Tangent’ Arc Tana DATAN Real Real Double Double FORTRAN LANGUAGE SUMMARY Table B-1 (Cont.) Functions Generic and Processor-Defined Functions Number of | Generic | PDF Type of Arguments; Name | Name Argument 2 ATAN2 | ATAN2 Real 1 SINH SINH 1 COSH COSH 1 TANH | TANH 1 ABS Arc TangentTM$ DATAN2 | Double Type of Result Real Double Arc Tan a,/a; Hyperbolic Sine DSINH Real Real Double Double Real Real Sinh a Hyperbolic Cosine DCOSH Double Double Cosh a Hyperbolic Tangent Real Real DTANH Double Double ABS Real Real CABS Complex Tanh a Absolute value’ lal IABS N Truncation® 1 INT Double HHABS JIABS Integer*2 Integer*4 Integer*2 Integer*4 1HABS Integer*2 Integer*2 JIABS HNT JINT Real Integer*4 Integer*2 Real Integer*4 Integer*2 Double Double integer*4 IDINT | HIDINT JIDINT AINT 1 Integer*4 Real IIDINT [a] Nearest Integer® Double DABS NINT [a+.5*sign(a)] IDNINT| Double Integer*2 JIDINT Double Integer*4 AINT DINT Real Double Real Double ININT Real Integer*2 IIDNNT Double Integer*2 Real Integer*4 JIDNNT Double Integer*4 IIDNNT JIDNNT Double Double integer*2 Integer*4 JNINT ANINT | ANINT DNINT Real Double Real Double FORTRAN Table B-1 (Cont.) Functions Fix® LANGUAGE SUMMARY Generic and Processor-Defined Functions Number of | Generic | PDF Type of Type of Arguments | Name |Name Argument Result 1 IFIX HFIX Real Integer*2 JIFIX Real Integer*4 {FLOATI Integer*2 Real FLOATJ Integer*4 Real DFLOAT{DFLOTI Integer*2 Double DFLOTJ Integer*4 Double (real-to-integer conversion) Float’ 1 FLOAT (integer-to-real conversion) Double Precision Float® 1 (integer-to-double conversion) Conversion to® Single 1 SNGL Precision Conversion to? 1 DBLE Double Precision — Real Real SNGL Double Real FLOATI Integer*2 Real FLOATJ | Integer*4 Real |DBLE - Real Double Double Double DFLOTI Integer*2 Double DFLOTJ | Integer*4 Double Real Part of Complex 1 - REAL Complex Real Imaginary Part of Complex 1 — AIMAG Complex Real Complex From Two Reals 2 - CMPLX Real Complex Complex Conjugate 1 - CONJG Complex Complex 2 - DPROD Real Double (if a=(X,Y) CONJG (a)=(X,-Y) Double product of Reals a; *a, FORTRAN LANGUAGE SUMMARY Table B-1 (Cont.) Generic and Processor-Defined Functions Functions Maximum Number of | Generic | PDF Arguments | Name MAX n |Name AMAX1 Real Type of Result Real DMAX1 Double Double JMAXO0 integer*4 Integer*4 IMAXO max{a, ,a;,...a,) Type of Argument Integer*2 Integer*2 (returns the maximum value from among the argument MAX0 |IMAXO JMAXO Integer*2 Integer*4 Integer*2 Integer*4 two arguments) MAX1 |IMAX1 Real Integer*2 list; there must be at least JMAX1 Real AMAXO |AIMAXO | Integer*2 AJMAXO0 | Integer*4 Minimum n MIN AMINT1 (returns the minimum value among the argument list; MINO arguments) MIN1 there must be at least two Double JMINO Integer*4 Integer*4 IMINO JMINO Integer*2 Integer*4 Integer*2 Integer*4 IMIN1 Real Integer*2 Integer*2 Real JMIN1 AJMINO 2 DIM DIM (returns the first argument minus the minimum of the integer*2 Real Integer*4 Real Integer*2 Integer*4 Real Real DDIM Double Double JIDIM Integer*4 Integer*4 Integer*2 integer*4 Integer*2 integer*4 {IDIM a, —(min(a, ,a,)) Real Double AMINO | AIMINO Positive Difference Real Real DMIN1 IMINO minf{a, ,az, - - .an) Real Integer*4 IDIM HDIM JIDIM MOD AMOD Integer*2 Integer*2 two arguments) Remainder 2 DMOD iIMOD JMOD a, —a, *[a, /a, ] (returns the remainder Real Double Integer*2 Integer*4 Real ‘Double Integer*2 Integer*4 when the first argument is divided by the second) Transfer of Sign la,|*Sign a, 2 SIGN SIGN Real Real DSIGN Double Double JISIGN Integer*4 Integer*4 ISIGN | HSIGN Integer*2 Integer*2 IISIGN JISIGN Integer*2 Integer*4 Integer*2 Integer*4 FORTRAN Table B-1 (Cont.) . Functions LANGUAGE SUMMARY Generic and Processor-Defined Functions Number of | Generic| Arguments| Bitwise AND 2 PDF Type of Type of Argument Result IIAND Integer*2 Integer*2 JIAND Integer*4 Integer*4 Name | Name IAND (performs a legical AND on corresponding bits) Bitwise OR ( 2 IOR (performs an inclusive OR on IHHOR Integer*2 Integer*2 JIOR integer*4 Integer*4 HHEOR Integer*2 Integer*2 JIEOR Integer*4 Integer*4 corresponding bits) Bitwise Exclusive OR 2 IEOR (performs an exclusive OR on corresponding bits) Bitwise Complement 1 NOT (complements each bit) :Bitwise Shift 2 INOT Integer*2 Integer*2 JNOT Integer*4 Integer*4 ISHFT | ISHFT Integer*2 Integer*2 JISHFT Integer*4 Integer*4 (a; logically shifted left a, bits) Random number!® 1 - RAN Integer*4 Real 1 - LEN Character Integer*4 2 - INDEX Character Integer*4 1 - CHAR Logical* 1 Character (returns the next number from a sequence of pseudorandom numbers of uniform distribution over the range Oto 1) Length!! (returns length of the character expression) Index*! (returns the position of the substring c, in the character expression ¢, ) Character'? (returns a character that has the ASCII value specified by the argument) Integer*2 Integer*4 [3 FORTRAN LANGUAGE Table B-1 (Cont.) Functions ASCII Value® SUMMARY Generic and Processor-Defined Functions Number of | Generic | PDF Arguments| Name | Name 1 - ICHAR Type of Argument Type of Result Character Integer*4 (returns the ASCII value of the argument; the argument must be a character expres- sion that has a length of 1) Notes for Table B-1 ! The argument of SQRT and DSQRT must be greater than or equal to zero. The result of CSQRT is the principal value with the real part greater than or equal to zero. When the real part is zero, the result is the principal value with the imaginary part greater than or equal to zero. 2 The argument of ALOG, DLOG, ALOG10, and DLOG10 must be greater than zero. The argument of CLOG must not be (0., 0.). 3 The argument of SIN, DSIN, COS, DCOS, DCOS, TAN, and DTAN must be in radians. The argument is treated modulo 2*pi. 4 The absolute value of the argument of ASIN, DASIN, ACOS, and DACOS must be less than or equal to 1. 5 The result of ASIN, DASIN, ACOS, DACOS, ATAN, DATAN, ATAN2, and DATAN2 is in radians. ¢ The result of ATAN2 and DATAN2 is zero or positive when a, is less than or equal to zero. The result is undefined if both arguments are zero. 7 The absolute value of a complex number, (X,Y), is the real value: (X2 +Y2 )1 2 8 [x] is defined as the largest integer whose magnitude does not exceed the magnitude of x and whose sign is the same as that of x. For example [5.7] equals 5. and [-5.7] equals -5. % Functions that cause conversion of one data type to another type provide the same effect as the The function SNGL with a real argument and the funcimplied conversion in assignment statements. tion DBLE with a double precision argument return the value of the argument without conversion. 10 The argument for this function must be an integer variable or integer array element. The argument 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 O regenerates the sequence. Alternate starting values generate different random number sequences. 11 See Cnapter 6 for additional information on character functions. B-23 INDEX A Array reference without subscripts, 2-16 A field descriptor, 8-10 ACCEPT statement, 7-1, 7-3, 7-4, 7-7, 7-11, B-2, B-12, B-14 ACCESS keyword, 9-2, 9-6 Actual argument, 4-18, 6-1 character constants as, 6-4 Hollerith constants as, 6-4 Actual, dummy arguments, agreement between, 6-1 Adjustable arrays, 2-17, Agreement between actual, 6-2 dummy arguments, 6-1 Alternate return, 4-19, 6-14 Alternate 6-5 return arguments, Argument, actual, 4-18, 6-1 dummy, 4-18, 6-1 Argument list, 4-18 Argument list built-in functions, 6-5 2-15 Arrays, adjustable, 2-17, 6-2 data type of, 2-16 format specifications in, 8-20 ASCII character set, A-2 ASSIGN statement, 3-5 Assigned GO TO statement, 4-3 Assigning symbolic names to a constant, 5-1, 5-18 Assigning symbolic names to main program, 5-1, 5-19 Assigning values to an array, 5-1 Assigning values to an array element, 5-1, 5-16 Assigning values to a variable, 5-1, 5-16 Assignment statement, Arguments, character constants actual, 6-4 Array storage, as passed length character, 6-3, 6-10, 6-11 subprogram, 6-1 Arguments, actual, Hollerith constants as, 6-4 Arguments with ENTRY state- 3-1, B-2 character, 3-4 conversion of, 3-2 logical, 3-3 ASSOCIATEVARIABLE keyword, 9-2, 9-6 Asterisk, 5-4, 5-14, 6-14, 6-17, 7-2, 7-11 Auxiliary I/O statements, 9-1 ment, dummy, 6-14 Arithmetic assignment statement, 3-1, B-3 Arithmetic expression, 2-18 data type of, 2-21 Arithmetic IF statement, 4-4, 4-12 Arithmetic operators, 2-18 Arithmetic statement function, 6-1, 6-7, 6-8, B-3 Array, 2-1, 2-13 assigning values to an, 5-1, 5-16 Array declarators, 2-14 Array dimensions, 5-5 Array element, assigning values to an, 5-1, 5-16 Array equivalence, 5-8 BACKSPACE statement, 9-15, 9-1, B-3 Binary operators, 2-19 Block, common, 2-2, 5-6 named, 5-6 unnamed, 5-6 Block data, 2-2 BLOCK DATA statement, 5-20, Block IF, nested, 6-12, 4-10 5-1, B-3 Block IF statement, 4-5, 4-8, 4-12 Blocks, statement, 4-8 BLOCKSIZE keyword, 9-2, 9-7 BUFFERCOUNT keyword, 9-3, 9Built-in functions, 6-5 Index-1 = (Cont). C Constant CALL statement, 4-1, 5-14, 6-7, B-3 Carriage control, 8-18, 4-18, 8-2, 8-13, integer, logical, 9-7 CARRIAGECONTROL keyword, 9-2, octal, 9-7 passed length, Constant 6-3, 6-10 6-11 Character assignment statement, , 3-4 Character constant, 2-10 Character constant field descriptor, 7-7, 8-11 Character constant in Hollerith field descriptor, 8-2 Character constants as actual arguments, Character data, transferring, ASCII, 1-4, A-1, A-2 Character substrings, 2-17 Character type declaration 9-1, Colon descriptor, Comments, 1-3 indicator, 1-7 Common block, defining, named, as statement, 5-1, 9-2 2-4 assigning symbolic names to a, 5-1, character, 5-18 4-1 3-2 file, 9-2 D field descriptor, Data editing, complex, 8-14 DATA statement, 5-16, Data transfer, 2-16, decimal, Data 7-1 8-2 8-5 to type, 2-1, type type rank, 2-21 DECODE array, statement, 8-1, B-5 2-16 2-21 Debugging statement, Decimal values, transferring, 8-2 Declarators, 2-13 2-12 arithmetic Data type of arrays, Index-2 8-8 2-3 implication, expression, 2-10 to 8-8 declaration, Data type of Data 8-5 format specification, 7-7, -8-11 Data type by Data 5l, 8-10 double precision, hexadecimal, 8-4 Hollerith, 8-10 logical, 8-9 octal, 8-3 real, 8-7 B~-4 character, to 2-1, 4-17, D 5-20 5-6, 5-13, B-4 Complex constant, 2-7 Complex data editing, 8-14 Complex field descriptor, 8-2 Computed GO TO statement, 4-2 Connecting files to logical Constant, statements, Creating a 5-6 units, statement, Conversion of assignment 9-13, 2-16, 6-4 4-1, 5-6 5-6, 5-6 statement, arguments, CONTINUE unnamed, COMMON actual 1-7 8-14 2-2, 5-1, arguments, Continuation field, 5-4 CLOSE statement, B-4 actual statement, A-2 statements, as character, 6-4 Constants, Hollerith, Control library functions, set, Constants B-4 Character expression, 2-22 Character field descriptor, 8-2 Character functions, 6-10 6-10 Character 6-21 Character ~ field descriptor, character, 7-7, 8-11 Constant, Hollerith, 2-11, 2-17 Constant in Hollerith field descriptor, character, 8-2 6-4 8-10 CHARACTER FUNCTION 2-7 2-5 2-10 2-8 2-6 real, CHAR function, 6-22 Character arguments, (Cont.), complex, 2-7 double precision, hexadecimal, 2-8 1-7 2-14 7-1, 7-22, INDEX END IF statement, Default field descriptors, DEFINE FILE statement, 9-1, 9-18, B-5 Defining common blocks, 5-1, 5-6, colon, 5-20 End-of-file, 7-6 transfer on, 7-6, B-7 END=, 7-6, 7-7, 7-11, 9-1, B-7 ENTRY in subroutines, 6-16 ENTRY statement, 2-17, 6-7, 6-6 6-12, 8-14 B-5 : Dimensions, array, 5-5 Direct access file, unformatted, 92-1, 9-18 Direct access 1/0, 7-1, 7-2, 9~-2, 9-9 formatted, 7-1, 7-18 unformatted, 7-1, 7-20 Direct access record numbers, 7-2, 9-2, 9-6 Display, 4-21, 4-22 DISPOSE keyword, 9-2, 9-7 DO iteration control, 4-13 DO list, implied, 7-3, 7-4 DO loop extended range, 4-15 6-15 Equivalence, array, 5-8 substring, B-7 nested, 4-14 DO statement, 4-1, 4-12, B-6 Dollar sign descriptor, 8-13 Double precision constant, 2-7 8-7, 8-8 Dummy argument, 4-18, 6-1 Dummy arguments with ENTRY statement, 6-14 5-10 2-17, EQUIVALENCE statement, 5-1, 5-8, B-7 ERR keyword, 9-3, ERR=, 7-6, 9-8 7-9, 7-7, 7-11, B-7 Error, I1I/0, transfer on, 7-6, B-7 Evaluation, order of, 2-20, 2-25 Exponential form, 8-6, 8-7 Exponentiation, 2-19 Expression, 2-1, 2-18 arithmetic, 2-18 character, 2-22 data type of arithmetic, DO loops, Double precision field descriptor, 8-2 Double precision values, transferring, 8-5, 8-6, 6-14, dummy arguments with, 6-14 ENTRY statement in functions dollar sign, 8-13 Dimension bound, 2-14 Dimension declarator, 2-14 DIMENSION statement, 5-1, 5-5, 4-5, 4-1, B-7 8-18 $DESCR function, Descriptor, (Cont.) 2-21 logical, 2-24 relational, 2-23 variable format, 8-17 Expression operators, B-1 Extended range, DO loop, 4-15 EXTENDSIZE keyword, 9-2, 9-8 External field separators, 8~-20 External procedure, 4-18, 5-1, 5-14 EXTERNAL statement, 5-1, 5-14, 6-14, 6-17, B-8 F' E field descriptor, Editing, complex data, 8-6 F field descriptor, Editing field descriptor; 8-2, 8-12 continuation, 1-7 Field descriptor, 8-2 A, 8-10 character, 8-2 character constant, ELSE statement, 4-1, 4-5, B-6 ELSE IF THEN statement, 4-1, 4-5, B~-6 ENCODE statement, 8-1, 7-1, 8-5 Field, 8-14 8-11 7-22, 7-7, character constant in Hollerith, 8-2 B-6 END statement, 4-1, 4-12, 4-23, B-7 ENDFILE statement, 7-6, 9-1, 9-17, B-7 complex, 8-2 D, 8-7 default, 8-18 Index-3 INDEX Field descriptor (Cont.), double precision, 8-2 E, F, 8-2, 8-8 H, 8-11 Hollerith, L, o, 8-3 Q, 8-13 T, X, 8-2 8-12 8-12 Z, 8-4 8-2 real, generic, 6-22 INDEX, 6-21 LEN, 6-21 external, File, $LOC, 6-7 numeric, 8-20 9-2 connecting to logical units, 9-2 FIND statement, 9-1, 9-2, 9-16, B-8 9-8 $REF, $VAL, run-time, 8-2, codes, 6-10 6-7 6-9, statement, 6-10, 6-12, G field descriptor, 8-8 Generic functions, 6-17, 6-19, B-17 TO statement, computed, 4-1, 4-2, 4-2 unconditional, 8-17 8-19 statement, B-8 G 8-2 in 7-2, 7-2, 8-1, B-8 repeat count in, 8-16 rules for, 8-23 Formatted direct access 7-7, 7-7, 1/0, , Formatted 1/0, 7-1, 7-2, 8-1 Formatted sequential I/0, 7-1, 7-7 Formatting FORTRAN lines, 1-5 7-1, 6-6 6-6 6-7, 8-21 arrays, 8-20 Format specifiers, 7-9 2-2, 4-12, B-9 assigned, 4-3 Format specifications FORMAT 6-10 2-17, GO Format specification, 8-1 transferring data to, 7-7, 8-11 Format specification separators, B-17 Function reference, 8~25 Format of data item, Format expressions, variable, 6-1, FUNCTION Format, Format 6-19, processor-defined, 6-17, 6-19, B-17 unformatted direct access, 9-1, 9-18 File access, simultaneous, 9- 3, 9-12 File allocation, 9 -2, 9-8, 9-9 File positioning, 9-1, 9-14, 9-15, 9-16 Files, 6-17, ICHAR, Field separators, FORM keyword, 6-1, CHAR, 6-22 character, 6-10 character library, 6-21 $DESCR, 6-6 ENTRY statement in, 6-15 FORTRAN library, 6-1, 6-11, 6-17, B-17 8-2 creating a, 4-19, arithmetic statement, 6-7, 6-8, B-3 8-11 8-9 logical, 2-1, functions, 6-17, B-17 6-7, 6-9 argument list built-in, 6-5 8-2 integer, 6-11, Function, 8-12 8-2, library 6-1, 8-5 G, I, FORTRAN 8-6 editing, (Cont.) 4-2 H H field descriptor, 8-11 Hexadecimal constant, 2-8 Hexadecimal values, transferring, 8-4 Hollerith constant, 2-11, as actual 7-7 arguments, 6-4 Hollerith data, transferring, 8-10 Hollerith field descriptor, 8-2, 8-11 character constant in, 8-2 7-18 I field descriptor, 8-2 ICHAR function, 6-22 IF, nested block, Index-4 4-10 INDEX IF statement, 4-1, arithmetic, 4-4, logical, 4-5 IF THEN statement, 4-4, B-9 4-12 B-10 IMPLICIT statement, 6-17, 4-1, 4-5, 5-2, 5-1, Implied DO list, 7-3, 7-4 INCLUDE statement, 1-9, B-10 INDEX function, 6-21 INITIALSIZE keyword, 9-2, 9-9 Input/output lists, 7-3, 7-7, 7-9, 7-11, 7-16, 8-22 Input/output statements, 2-17, 7-1 Integer constant, 2-5 Integer field descriptor, 8-2 Internal 1/0, 7-1, 7-22 I1/0, direct access, unformatted, 7-1, 7-20 formatted, 7-1, 7-2, 8-1 formatted direct access, 7-1, 7-18 formatted sequential, internal, 7-1, 7-1, 7-22 list-directed sequential, 7-1, 7-11 unformatted, 7-1, 7-3 unformatted sequential, 7-1, 7-16 I/0 error, transfer on, 7-6, I/0 statements, auxiliary, 9-1 Keywords, OPEN statement (Cont.), SHARED, 9-3, 9-12 TYPE, 9-2, 9-12 UNIT, 9-2, 9-12 USEROPEN, 9-3, 9-12 s B-10 7-7 (Cont.) L L field descriptor, 8-9 Label field, statement, 1-7. LEN function, 6-21 Library functions, character, 6-21 FORTRAN, 6-1, 6-11, 6-17, B-17 List, argument, 4-18 List-directed sequential I/O, 7-1, Lists, 7-11 input/output, 7-3, 7-7, 7-9, 7-11, 7-16, 8-22 $LOC function, 6-7 Logical assignment statement, 3-3 Logical constant, 2-10 Logical data, transferring, Logical Logical Logical Logical 8-9 expression, 2-24: field descriptor, 8-2 IF statement, 4-5 operators, 2-25 Logical unit, 7-1 connecting files to, 9-2 Logical unit numbers, 7-2 B-7 K Keywords, OPEN statement, 9-2, 9-4 ‘ ACCESS, 9-2, 9-6 ASSOCIATEVARIABLE, 9-2, BLOCKSIZE, 9-2, 9-7 BUFFERCOUNT, 9-3, 9-7 Main program, 9-6 CARRIAGECONTROL, 9-2, 9-7 DISPOSE, 9-2, 9-7 ERR, 9-3, 9-8 EXTENDSIZE, 9-2, 9-8 FORM, 9-2, 9-8 INITIALSIZE, 9-2, 9-9 MAXREC, 9-2, 9-9 NAME, 9-2, 9-9 NOSPANBLOCKS, 9-3, 9-10 ORGANIZATION, 9-2, 9-10 READONLY, 9-2, 9-10 RECORDSIZE,-.9-2, 9-10 RECORDTYPE, 9-2, 9-11 assigning symbolic names to, 5-1, 5-19 MAXREC keyword, 9-2, 9-9 Name, symbolic, 2-1, 2-2 NAME keyword, 9-2, 9-9 Named common block, 5-6 Nested block IF, 4-10 Nested DO loops, 4-14 NOSPANBLOCKS keyword, 9-3 9-10 Numeric functions, 6-10 Numeric type declaration statements, Index-5 5-3 INDEX (o) (Cont.) constant, Octal values, 2-8 Real values, transferring, 8-8 Record numbers, transferring, 8-3 Records, O field descriptor, Octal OPEN statement, 8-3 direct access, 7-2, 9-1, B-11 keywords, 9-2, arithmetic, 2-18 binary, 2-19 expression, B-1l logical, 2-25 relational, 2-23 unary, 2-19 9-2, 9-10 RECORDTYPE keyword, 9-2, 9-11 alternate, 2-20, 4-19, statement, 4-1, 6-5 RETURN 6-7, 6~-9, 4-12, 6-10, B-14 5-1, statement, 9-1, 9-14, B-14 Rules for FORMAT statements, 8-23 Run-time format, 8-2, 8-21 5-18, B-12 Parenthages, 2~20 length 6-3, 6-10, 6-11 length specification, 5-4 statement, B-12 Positional 4-1, 4-21, specifier, statement, 7-8, B-17 S character arguments, 7-13, 8-12 7-1, B-12, 7-3, B-15, Procedure, external, 4-18, 5-1, 5-14 Processor-defined function, 2-2, 6-17, 6-19, B-17 statement, 5-1, 5-19, B-12 ’ Q Q field descriptor, 8-13 Scale factor, 8-14 Sequence number, 1-8 Sequential I/0, formatted, 7-1, list-directed, Radix~-50, Simultaneous file access, 9-2, 9-12 Specification, format, 8-1 passed length, 5-4 Specification separators, format, 8-19 Specification statements, 5-1 Specifications, format, in arrays, 8-20 Specifier, format, 7-2, 7-7, 7-9 7-1, 7-3, 7-4, 7-6, 7-7, 7-11, 7-16, 7-18, 7-20, B-12 READONLY keyword, constant, 7-11 8-12 8-12 Statement, A-2 statement, 7-7 7-1, unformatted, 7-1, 7-16 SHARED keyword, 9-3, 9-12 positional, tabulation, Real Real 6-14 alternate, REWIND PARAMETER statement, READ 8-16 arguments, 4-19, P PROGRAM 9-6 RECORDSIZE keyword, Return 9-10 PRINT 9-2, 7-3 statements, 2-25 PAUSE 7-2, 8-7, Return, Order of evaluation, Passed 8-6, $REF function, 6-6 Relational expression, 2-23 Relational operators, 2-23 Repeat count in FORMAT 9-4 Operators, Passed 8-5, 9-2, 7-1, 7-3, 7-11, B-2, B-12, arithmetic ASSIGN, IF, 7-4, 4-4, 4-12 3-5 assignment, 3-1, B-2 auxiliary 1I/0, 9-1 8-2 BACKSPACE, Index-6 7-7, B-14 9-10 2-6 field descriptor, ACCEPT, 9-1, 9-15, B-3 INDEX Statement (Cont.), BLOCK DATA, 5-1, B-3 (Cont.) Statement 5-20, 6-12 ' (Cont.), SUBROUTINE, block IF, 4-5, 4-8, 4-12 CALL, 4-1, 4-18, 5-14, 6-7 ’ 3-4 CHARACTER FUNCTION, VIRTUAL, CLOSE, WRITE, COMMON, 5-13, B-4 computed GO CONTINUE, DATA, TO, 2-16, DECODE, 5-1, 4-1, debugging, 6-10 B-4 9-13, 2-16, 5-6, 4-2 B-4 5-16, 7-22, 8-1, 9-1, 9-18, Statement label Statements, DO, B-5 ELSE 4-12, B-6 4-1, 4-5, B-6 IF ENCODE, ENDFILE 4-1, 4-5, B-6 7-1, 7-22, 8-1, B-6 9-1, 9-17, B-7 4-1, 4-5, B-7 2-17, 6-7, 6-12, EQUIVALENCE, 5-1, 5-14, 5-8 4 6-14, 6-17, FIND, B-8 9-1, 9-16, FORMAT, 7-2, FUNCTION, 6-10, GO TO, 2-17, 6-12, 4-1, B-8 7-7, 8-1, 6-7, 4-4, B-9 IF THEN, 4-1, 4-5, B-10 INCLUDE, 5~1, 1-9, B-9 B-10 5-2, 6-17, B-10 logical assignment, logical IF, 4-5 OPEN, 6-9, 4-12, 4-2, 4-1, IMPLICIT, B-8 B-8 IF, 3-3 5-3 9-1, B-1l1 5-1, 5-18, PAUSE, 4-1, 4-21, PRINT, 7-1, 7-3, B-12 B-12 7-8, B-12, B-15, B-17 PROGRAM, 5-1, 5-19, array, 2-15 Subprogram arguments, Subprograms, 6-1 7-13, 6-1 user-written, 6-~7 Subroutine, 2-2, 4-18, 6-1, 6-7, 6-12 SUBROUTINE statement, 6-7, 6-12, Subroutines, 4-19, 2-17, B-14 ENTRY IN, 6-16 Subscript, 2-15 array reference without, 2-16 Substring equivalence, Substrings, character, 2-17 Symbolic name, 7-2, PARAMETER, 8-16 Storage, 5-1, B-7 EXTERNAL, in, rules for FORMAT, 8-23 specification, 5-1 STOP statement, 4-1, 4-22, B-14 6-15 2-17, 4-1 repeat count 4-23, B-7 7-6, 6-14, B-7 in functions, 1-7 input/output, 2-17, 7-1 numeric type declaration, statement, IF, ENTRY, 4-12, field, FORMAT, THEN, 4-1, END, 4-8 conversion of assignment, 3-2 4-1, ELSE, END 5-5, 7-8, 7-21, character type declaration, 5-4 control, 5-1, 7-6, 7-19, B-4 B-5 DIMENSION, 7-17, Statement keywords, B-5 DEFINE FILE, 6-12, B-15 7-3, Statement blocks, 4-17, 5-1, 5-5, 7-1, 7-13, B-15 1-7 7-1, 6-7, TYPE, 7-1, 7-3, 7-8, 7-13, B-14 type declaration, 5-1, 5-3, B-15 B-3 character assignment, 9-1, 2-17, B-14 2-1, Symbolic 5-10 2-2 names to constants, assigning, 5-1, 5-18 Symbolic names to main program, assigning, B-12 5-1, 5-19 READ, 7-1, 7-3, 7-4, 7-6, 7-7, 7-11, 7-16, 7-18, 7-20, T B-12 RETURN, 4-1, 4-12, 4-19, 6-7, 6-9, 6-10, B-14 REWIND, 9-1, 9-14, B-14 sTOP, 4-1, 4-22, B-14 T field descriptor, 8-12 Tabulation specifier, 8-12 Transfer on end-of-file, 7-6, Index-7 B-7 INDEX Transfer on I/0 error, 7-6, B-7 Transferring character data, 8-10 Transferring data to format specification, 7-7, 8-11 Transferring decimal values, 8-2 Transferring double precision values, 8-5, 8-6, 8-7, 8-8 Transferring hexadecimal values, 8-4 Transferring Hollerith data, 8-10 Transferring logical data, 8-9 Transferring octal wvalues, 8-3 Transferring real values, 8-5, 8-6, 8-7, 8-8 Type declaration, 2-16 Type declaration statement, character, 5-4 numeric, 5-3 TYPE keyword, 9-2, 9-12 TYPE statement, 7-1, 7-3, 7-13, B-14 (Cont.) Unformatted 1/0, 7-1, 7-3 Unformatted sequential I/0, 7-1, 7-16 Unit, logical, 7-1 UNIT keyword, 9-12 6-7 '} $VAL function, 6-6 Variable, 2-1, 2-12 assigning values to 5-16 Variable a, 5-1, format expressions, 8~-17 VIRTUAL statement, 5-5, B-15 w 7-8 [4 WRITE statement, 7-1, 7-3, 7-6, 7-8, 7-13, 7-17, 7-19, 7-21, B-15 U Unary operators, 2-19 Unconditional GO TO statement, 4-2 Unformatted direct access file, 9-1, 9-18 Unformatted direct access I/0, 7-1, 7-20 9-2, Unit numbers, logical, 7-2 Unnamed common block, 5-6 USEROPEN keyword, 9-3, 9-12 User-written subprograms, X X field descriptor, 8-12 Z Z Index-8 field descriptor, 8-4 IS GRS SWEN SGIS MR SINR swus VAX-11 FORTRAN IV-PLUS Language Reference Manual AA~-DQ034A-TE This form is for document comments only. DIGITAL will use comments submitted on this form at the company's discretion. Problems with software should be reported on a Software Performance Report (SPR) form. If you require a written reply and are eligible to receive one under SPR service, submit your comments on an SPR NOTE: AR SANS WED D WIS MW WENe MR Gmm READER'S COMMENTS Did you find errors in this manual? If so, specify by page. Did you find this manual understandable, Please make suggestions for improvement. usable, and well-organized? Is there sufficient documentation on associated system programs required for use of the software described in this manual? If not, what material is missing and where should it be placed? Please indicate the type of user/reader that you most nearly represent. [] Assembly language programmer O 0000 g this line Please cut along S SR GAMDS EESD G Gm D WAL AR WU AR GG SAS WeI form. Higher-level language programmer Occasional programmer (experienced) User with little programming experience Student programmer Non-programmer interested in computer concepts and capabilities Name Date Organization Street City State Zip Code or Country No Postage Necessary if Mailed in the United States BUSINESS REPLY MAIL FIRST CLASS PERMIT NO.33 MAYNARD MASS. POSTAGE WILL BE PAID BY ADDRESSEE RT/C SOFTWARE PUBLICATIONS TW/A14 DIGITAL EQUIPMENT CORPORATION 1925 ANDOVER STREET TEWKSBURY, MASSACHUSETTS Do Not Tear - Fold Here 01876
Home
Privacy and Data
Site structure and layout ©2025 Majenko Technologies