ebook img

NCAR-TN/IA-70 FORTRAN Reference Manual PDF

380 Pages·2003·11.03 MB·English
by  
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview NCAR-TN/IA-70 FORTRAN Reference Manual

(NCAR-TN/IA-79 cOctober 1975) -NCAR TECHNICAL NOTE Revision 3April 1978J) gu FORTRAN Reference Manual / J.C. Adams /RCO, LO ,O B.A . Domenico)- % | P.A.Rotar * | F : 4 :- ATMOSPHERIC TECHNOLOGY DIVISION NATIONAL CENTER FOR ATMOSPHERIC RESEARCH J/ v BOULDER, COLORADO 1B iii FOREWORD This manual describes the FORTRAN language as interpreted by the NCAR compiler. Portions of this manual have been edited from Control Data copyrighted publications with the permission of the Control Data Corporation. New sections have been added and all of the examples have been checked using computer runs. Sample programs have been run on the NCAR system. NCAR FORTRAN uses the American National Standards Institute standard FORTRAN X3.9-1966 as a guide in order to have the current standard a subset of the NCAR FORTRAN as far as possible. However, there are a number of cases where its usage is nonstandard. Some of these have been noted. Chapter 10 contains a statement list for FORTRAN X3.9-1966, the new standard (FORTRAN 77) currently in the final release process, NCAR Control Data 7600 FORTRAN, and CRAY FORTRAN. Astrik Deirmendjian was the programmer responsible for testing the examples. David Kitts and Sandra Fuller, who are responsible for compilers at NCAR, were very helpful in interpretation of technical material. John Snyder was the final reader for this issue. Linda Besen and Sara Ladd did the layout work and prepared the final copy. Linda generated the index based on the execution of a KWIC index program using topical subtitles. Veronica Martinez assisted the editors. This document is the third revision of Technical Note TN/IA-70 and supersedes the FORTRAN Reference Manual dated October 1975. February 1978 V Contents TABLE OF CONTENTS CHAPTER 1 FORTRAN CODING FORMS . .............. 1.1 Introduction . . .... ... ....... 1.1 Coding Line ....... ..... .... 2 Statement . . . . . . . . . . . . . . . . . . .. . . 1.2 Staterent Label .. ........ 1.3 Identification Field ............... 1.3 Comment Information .......... ....... 1.3 Special Comment Option .............. 1,4 Punched Cards ................. 1.4 Blank Cards ........... .. 1.4 CHAPTER 2 FORTRAN CONCEPTS ....... 2.1 FORTRAN Character Set . ....... .2.1 Identifiers ... ............... . 2.2 Alphanumeric Identifier .......... .. . 2.2 Constants . . . . . . . . . . . . . . . . . . . . . . . 2.4 Integer Constants .................. 2.4 Octal Constants ................... 2.6 Real Constants . . .............. . 2.7 Double-Precision Constants ............. 2.8 Complex Constants .................. 2.10 Hollerith Constants . ................ 2.11 Logical Constants .............. . 2.12 Variables ... . 2.13 Types of Variables . ............ 2.14 Integer Variables ......... . ..... 2.14 Real Variables . ................. 2.15 Double-Precision Variables .... ... 2.15 Complex Variables .............. 2.15 Naming Octal Constants .............. 2.15 Alphanumeric Names (Hollerith) .......... 2.16 Logical Variables ................. 2.16 Classes of Variables ................ 2.16 Simple Variable . . ................ 2.16 Subscripted Variable ............... 2.17 Arrays ... ... . . . . . . . . . 2.19 Array Structure ................. 2.20 vi Contents CHAPTER 3 EXPRESSIONS: ARITMETIC, LOGICAL, MASKING, MIXED MODE . 3.1 Introduction ...................... 3.1 Expressions . . . . . . . . . . . . . . . . . . . . . . 3.2 Arithmetic Expressions ................ 3.2 Standard Evaluation .. ............ 3.3 Evaluation with Optimization . ......... 3.6 Logical Expressions . ....... ......... 3.11 Relational Operators . ........... 3.11 Logical Connectives ............... 3.13 Masking Expressions ............... 3.14 Mixed-Mode Expressions . ............ 3.17 CHAPTER 4 REPLACEMENT STATEMENTS ................. 4.1 Introduction .. ................4 .1 Mixed-Mode Replacement Statements ........... 4.1 Multiple Replacement Statements ........... 4.4 CHAPTER 5 TYPE DECLARATIONS AND STORAGE ALLOCATION ..... 5.1 Introduction ........ ............. 5.1 Statement Ordering .................. 5.1 Type Declaration ................. 5.2 Implicit Typing ................... 5.4 IMPLICIT Statement .......... 5.4 Symbolic Name of a Constant .............. 5.7 PARAMETER Statement ..... ... ......... 5.7 Dimension Declaration ... ....... 5.10 Variable Dimensions ...... . 5.13 Common Declaration . ............ 5.14 Local Variables ........... 5.14 Common Variables ..... ...... . 5.15 Equivalence Declaration . ............. 5.24 Storage Allocation ................. 5.28 Data Declaration ........... 5.35 DATA Statement .... 5.35 CHAPTER 6 CONTROL STATEMENTS .. . ............... 6.1 Introduction ...................... 6.1 GO TO Statements .. ......... 6.2 Unconditional GO TO Statement ... 6.2 Assigned GO TO Statement ............... 6.2 ASSIGN Statement ......... .6.3 Computed GO TO Statement ............... 6.3 IF Statements .... .... .... .. 6.5 Three-Branch Arithmetic IF Statement ........ 6.5 Two-Branch Relational IF Statement ..... 6.7 One-Branch Relational IF Statement ......... 6.8 DO Statement ............ .......... 6.9 DO Loop Execution .................. 6.13 vii Contents DO Nests ...................... 6.15 Subscripting within DO Loops ............. 6.18 Extended Range . .................. 6.18 Optimization ..................... 6.21 *FORTRAN,1 . ... .. .. .. .. ... . . . ... 6.21 *FORTRAN,2 ..................... 6.22 *FORTRAN,3 .. .... .. .. .. ... ... .. . 6.23 *FORTRAN,4 ..................... 6.23 *FORTRAN,13 .................... 6.24 *FORTRAN,18 .................... 6.24 *FORTRAN,25 .................... 6.24 *FORTRAN, 60 ..... ............... 6.24 CONTINUE Statement ...... .. . . ... ...... 6.26 PAUSE Statement ........... 6.26 END Statement ... .................. 6.26 Normal Termination Statements . ............ 6.27 IF/THEN/ELSE ................... ... 6.28 General Structure . ................. 6.28 Nesting Levels ............. .. 6.29 Transfer of Control ................ 6.29 IF THEN Statement ................ 6.30 Form ....................... 6.30 Block ................ 6.30 Execution . ................ . 6.30 ELSE IF Statement ................. 6.31 Form ......................... 6.31 Block ................. 6.31 Execution ... . ........ 6.31 ELSE Statement . ........ ........... 6.32 Form .... . . . . . . . . . . . . . 6.32 Block ....... .. ............. 6.32 Execution ...... .... . .. 6.32 END IF Statement .............. 6.33 Form . . . . . . . . . . . . . . . . . . . . . . . . 6.33 Execution ................... 6.33 DO-Loop (FORTRAN 77) ............ ...... 6.37 DO-Loop Structure ................. 6.37 DO Statement ............... .6.37 DO-Loop Range ................... 6.37 Terminal Statement ..... .. . ....... 6.38 DO-Loop Execution ........... ...... 6.39 DO Statement Execution . ...... . 6.40 Loop Control Processing ........... 6.41 Execution of the Range ............... 6.41 Incrementation Processing ............. 6.41 Active and Inactive DO-Loops ............ 6.42 * * · Vlll Contents CHAPTER 7 PROGRAM, FUNCTION, AND SUBROUTINE ........... 7.1 Introduction ...................... 7.1 Main Program ....... ........... . . .. 7.2 Subprograms . ........................ 7.3 Formal Parameters ........ . .... 7.3 Actual Parameters .................. 7.4 Subroutine Subprogram ........ ........ 7.7 CALL Statement .... ........... .... 7.8 Function ......... ....... 7.11 Function Definition .......... ... 7.11 Function Reference ................. 7.13 Arithmetic Statement Function .. .. ..... 7.15 Library Functions ................ .7.18 In-Line Algorithms ................... 7.18 Mathematical Library Routines ............. 7.18 Auxiliary Library Routines ... .......... 7.25 Block Data . . . . . . . . . . . . . . . . . . . . . . . 7.26 RETURN and END Statements ....... .. . . 7.27 ENTRY Statement .................... 7.28 EXTERNAL Statement ...... ........ .... 7.31 Variable Dimensions in Subprograms .... .... 7.33 Arrangement of FORTRAN Decks .............. 7.35 CHAPTER 8 INPUT/OUTPUT FORMATS ................. 8.1 Introduction . ................. . 8.1 Input/Output List .................. 8.2 Standard Subscripts ........... 8.2 Nonstandard Subscripts ........... 8.3 Array Transmission .................. 8.3 FORMAT Declaration .................. 8.7 FORMAT Specifications ................ 8.8 Conversion Specifications ............... 8.9 Ew.d Input ................... ... 9 Ew.d Output ..................... 8.12 Fw.d Input ............. ..... . .. 8.14 Fw.d Output ............ . 8.14 Gw.d Input ................... .. 8.16 Gw.d Output ................... 8.16 Dw.d Input ...................... 8.18 Dw.d Output .................. . 8.18 Iw Input ....................... 8.19 Iw Output . .. ..... .8.20 Ow Input ................... 8.21 Ow O utput . . . . . . . . . . . . . . . . . . . . . . 8.22 Aw Input . ..................... 8.23 Aw Output . . . . . . . . . . . . . . . . . . . . . . 8.23 Rw Input ....................... 8.24 Rw Output . . . . . . . . . . . . . . . . . . . . . . 8.24 Lw Input ....................... 8.25 Lw Output ..................... 8.25 ix Contents Scale Factor ...... ...... ....... .. 8.26 Fw. d Scaling ... .................... 8.27 Input ... ........... 8.27 Output . . . . . . . . . . . . . * * .8.27 Ew.d or Fw.d Scaling ................ 8.28 O t utpu.t. . . . . . . . . . . . . . . . . . . . . . 8.28 Editing Specifications ................. 8.29 wX Specification ................. .. 8.29 wH Input ..................... 8.30 :wH Otutput . . . .. .. .... . . . .8.31 a New Record .... ........... ....... 8.32 Repeated FORMAT Specifications . ... ...... 8.34 Unlimited Groups .................. 8.35 Variable Format ........ ............ 8.36 CHAPTER 9 INPUT/OUTPUT STATEMENTS ................ 9.1 Data Transfer .................... 9.1 Units . . . . . . . . . . . . . . . . . . . . . . . 9.2 Source Data ................... 9.2 The I/O List .................. 9.3 Rules ...................9...3... Input/Output Terminology ............... 9.4 Synchronous and Asynchronous .. . .......... 9.4 Core-to-Core Transfer ......... 9.4 Access to Data .................... 9.5 Keywords and Keylists ............... 9.5 Formatted and Unformatted ............ 9.6 Reading and Writing ............ . .. 9.7 Generalized Form of Synchronous Read/Write ...... 9.8 Format . .. . . .. ... ..... . . .... 9.8 Inpiut Parameters ............. .... 9.9 Output Parameters ................. 9.11 Syntax Error Diagnostics ............. 9.11 Specific Forms of Synchronous I/O ...... 9.12 Specific Output Statements Under Format Control . .9.12 Unformatted Input Statements ......... .. 9.15 Unformatted Output Statements ........... 9.17 Structure of Logical Records ........... 9.18 Generalized Form of Asynchronous READ/WRITE ..... 9.19 Format . . . .................... 9.19 Input Parameters .................. 9.20 Output Parameters .......... ... .. 9.21 Syntax Error Diagnostics .............. 9.22 Alternate Form for Asynchronous Statements . ..... 9.23 Parameters . .......... 9.24 Record Structure for BUFFER OUT in Binary or Character Code .......... . ...... 9 .25 Status Statement ............. 9.25 Internal Files . . . ............. 9.27 ENCODE/DECODE Statements ... ............ 9.27 x Contents CHAPTER 9 Dataset Support Statements ............... 9.38 (continued) The OPEN Statement .................. 9.38 Form . . . . . . . . . . . . . . . . . . . .9.38 Ident Parameters .................. 9.39 Error Condition Statement Label .......... 9.40 Keylist Parameters ...... ........... 9.40 Return Parameter. . ... ......... . 9.42 Syntax Error Diagnostics .............. 9.43 The CLOSE Statement . ................ 9.44 Form .............. .... .. 9.44 Input Parameters ............... .9.44 Error Condition Statement Label ......... 9.45 Return Parameter ..... ........... . 9.45 Syntax Error Diagnostics . . . . ......... 9.45 The INQUIRE Statement ................ 9.46 FornL. ..... ............ . 9.46 Ident Parameters .................. 9.46 Error Condition Statement Label ......... 9.47 Keylist Parameters ................. 9.48 Syntax Error Diagnostics .............. 9.54 The SETPASS Statement . .............. 9.55 Form . . . . . . . . . . . . . . . . . . . . . . . 9.55 Parameters . ... ........ ....... . 9.55 Syntax Error Diagnostics .............. 9.57 File Positioning with Sequential Access ........ 9.58 Positioning Statements ................ 9.60 Example Using Sequential Access ........... 9.65 Comments . . . . . . .. . . . . . . . . . . . . . . 9.66 Example Using Direct Access .............. 9.67 Comments .... ..... ...... 9.67 Example Using Direct and Sequential Access on the Same Unit .................. 9.68 Comments .. O.................... 9.68 Example of User Catalog Program ............ 9.69 Comments ....................... 9.69 Summary Table of FORTRAN Syntax ............ 9.73 CHAPTER 10 FORTRAN STATEMENT LIST ......... ...... 10.1 Introduction ...................... 10.1 Program and Subprogram Statements .......... 10.2 Subprogram Reference and Transfer ......... 10.2 Arithmetic Statement Function ............ 10.2 Type Declaration ................... 10.2 Storage Allocation ................. 10.4 Replacement .......... ........... 10.4 Branching and IF Logic .............. . 10.4 Looping and Control Statements ............ 10.6 FORMAT ........................ 10.6 Data Input ......... ............. 10.6

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.