1、I NTE RN AT1 ON AL STANDARD ISO/IEC 1539-1 First edition 1997-12-15 Information technology - Programming languages - Fortran - Part 1: Base language Technologies de linformation - Langages de programmation - Fortran - Partie 1: Langage de base Adopted by INCITS (InterNational Committee for Informati
2、on Technology Standards) as an American National Standard. Date of ANSI Approval: 6/9/98 Published by American National Standards Institute, 25 West 43rd Street, New York, New York 10036 Copyright 2002 by Information Technology Industry Council (ITI). All rights reserved. These materials are subject
3、 to copyright claims of International Standardization Organization (ISO), International Eledrotechnical Commission (IEC), American National Standards Institute (ANSI), and Information Technology Industry Council (ITI). Not for resale. No part of this publication may be reproduced in any form, includ
4、ing an electronic retrieval system, without the prior written permission of ITI. All requests pertaining to this standard should be submitted to ITI, 1250 Eye Street NW, Washington, DC 20005. Printed in the United States of America Reference number ISO/IEC 1539-1:1997(E) ISO/IEC 1539- 1 1997(E) Cont
5、ents . Foreword x111 . xiv Introduction . 1 1 Overview . 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 Scope Processor Inclusions Exclusions . Conformance . 1.5.1 Fortran 90 compatibility . . 1.5.2 FORTRAN 77 compatibility Notation used in this standard 1.6.1 Informative notes . 1.6.2 Syntax rules . 1.6.3 Ass
6、umed syntax rules . Syntax conventions and characteristics . 1.6.4 1.6.5 Text conventions Deleted and obsolescent features 1.7.1 Nature of deleted features . 1.7.2 Nature of obsolescent features Modules . Normativereferences 1 1 1 1 2 3 3 4 4 4 5 5 6 6 6 6 6 7 2 Fortran terms and concepts 9 2.1 High
7、 level syntax 2.2.2 Main program . . 2.2 Program unit concepts . 2.2.1 Program . 2.2.3 Procedure . 2.2.4 Module . 2.3 Executionconcepts 2.3.1 Executable/nonexecutable statements . 2.3.2 Statement order 2.3.3 The END statement . 2.3.4 Execution sequence . 9 11 12 12 12 13 13 13 13 14 14 O ISOIEC 1997
8、 All rights reserved . Unless otherwise specified. no part of this publication may be reproduced or utilized in any form or by any means. electronic or mechanical. including photocopying and micro- film. without permission in writing from the publisher . ISO/IEC Copyright Office Case postale 56 CH-1
9、21 I Genve 20 Switzerland Printed in Switzerland O ISO/IEC ISO/IEC 1539- 1 1997(E) 2.4 Data concepts 2.4.1 Datatype 2.4.3 Data entity 2.4.2 Datavalue . 2.4.4 Scalar . 2.4.5 Array . 2.4.6 Pointer 2.4.7 Storage 2.5 Fundamental terms 2.5.2 Keyword 2.5.3 Declaration 2.5.4 Definition . 2.5.5 Reference 2.
10、5.6 Association 2.5.7 Intrinsic . 2.5.9 Sequence 2.5.1 Name and designator . 2.5.8 Operator . . 3 Characters. lexical tokens. and source form . 3.1 Processor character set . 3.1.1 Letters 3.1.2 Digits . 3.1.3 Underscore 3.1.4 Special characters . 3.1.5 Other characters 3.2 Low-level syntax . 3.2.1 N
11、ames . 3.2.2 Constants . 3.2.3 Operators . 3.2.4 Statement labels 3.2.5 Delimiters . 3.3.1 Free source form 3.3.2 Fixed source form . . . 3.3 Sourceform . 3.4 Including source text 4 Intrinsic and derived data types . 4.1 The concept of data type 4.1.3 Operations 4.2 Relationship of types and values
12、 to objects 4.3 Intrinsic data types 4.3.1 Numeric types . 4.3.2 Nonnumeric types 4.4 Derived types . 4.4.1 -type definition . . 4.4.3 Derived-type values . . 4.1.1 Set of values . 4.1.2 Constants . 4.4.2 4.4.4 4.4.5 Determination of derived types Construction of derived-type values . Derived-type o
13、perations and assignment 15 15 15 15 17 17 17 17 17 18 18 18 18 18 18 19 19 19 21 21 21 21 21 22 22 22 22 23 23 24 24 24 25 27 27 29 29 29 30 30 30 31 31 35 37 38 43 44 44 45 iii ISO/IEC 1539- 1 11 997(E) 0 iSO/IEC 4.5 Construction of array values 45 5 Data object declarations and specifications . 5
14、.1 Type declaration statements 5.1.1 Type specifiers . 5.1.2 Attributes . 5.2 Attribute specification statements 5.2.1 INTENT statement 5.2.2 OPTIONAL statement . 5.2.3 Accessibility statements . 5.2.4 SAVE statement 5.2.5 DIMENSION statement . 5.2.6 ALLOCATABLE statement . 5.2.7 POINTER statement 5
15、.2.8 TARGET statement . 5.2.9 PARAMETER statement . 5.2.10 DATA statement 5.3 IMPLICIT statement 5.4 NAMELIST statement . 5.5 Storage association of data objects . 5.5.1 EQUIVALENCE statement . 5.5.2 COMMON statement . . 6 Useofdataobjects . 6.1 Scalars . 6.1.1 Substrings . 6.1.2 Structure component
16、s . 6.2 Arrays . 6.2.1 Whole arrays . 6.2.2 Array elements and array sections 6.3.1 ALLOCATE statement . 6.3.2 NULLIFY statement . 6.3.3 DEALLOCATE statement 6.3 Dynamic association . 7 Expressions and assignment . 7.1 Expressions 7.1.1 Form of an expression . 7.1.2 Intrinsic operations . 7.1.3 Defi
17、ned operations 7.1.4 Data type, type parameters, and shape of an expression 7.1.5 Conformability rules for elemental operations 7.1.6 Scalar and array expressions 7.1.7 Evaluation of operations . 7.2.1 Numeric intrinsic operations 7.2.3 Relational intrinsic operations 7.2.4 Logical intrinsic operati
18、ons 7.2 Interpretation of intrinsic operations . 7.2.2 Character intrinsic operation . 7.3 Interpretation of defined operations 7.3.1 Unary defined operation . 47 47 50 52 57 58 58 58 59 59 60 60 60 60 61 63 65 66 66 68 73 74 74 75 75 76 76 79 79 82 82 85 85 85 89 90 90 92 93 96 101 101 102 102 104
19、104 104 iv O ISO/IEC ISO/IEC 1539- 1 : 1997(E) 8 9 105 7.4 Precedence of operators 105 7.5 Assignment 107 107 110 111 7.5.3 114 7.5.4 FORALL 7.3.2 Binary defined operation 7.5.1 Assignment statement. 7.5.2 Pointer assignment . Masked array assignment - WHERE . Executioncontrol 121 121 8.1 Executable
20、 constructs containing blocks 121 8.1.1 Rules governing blocks. . 8.1.2 IFconstruct 122 123 8.1.3 CASE construct . 8.1.4 Doconstruct 126 130 8.2 Branching 130 8.2.1 Statement labels 131 8.2.2 GO TO statement. 131 8.2.3 Computed GO TO statement . 131 8.2.4 Arithmetic IF statement . 131 8.3 CONTINUE s
21、tatement . 131 8.4 STOP statement. . Input/output statements 133 9.1 Records 133 133 9.1.1 Formatted record . 133 9.1.2 Unformatted record. 134 9.1.3 Endfile record 134 9.2 Files . 134 9.2.1 External files. 137 9.2.2 Internal files . . 138 9.3 File connection. 138 9.3.1 Unit existence 138 9.3.2 Conn
22、ection of a file to a unit. . 9.3.3 Preconnection 139 139 9.3.4 The OPEN statement. . 143 9.3.5 The CLOSE statement . . 144 9.4 Data transfer statements. 144 9.4.1 Control information list. . 148 9.4.2 Data transfer input/output list . 149 9.4.3 Error, end-of-record, and end-of-file conditions . 9.4
23、.4 Execution of a data transfer input/output statement. . 150 153 9.4.5 Printing of formatted records . 154 9.4.6 Termination of data transfer statements 154 9.5 File positioning statements . 154 9.5.1 BACKSPACE statement. . 155 9.5.2 ENDFILE statement. 155 9.5.3 REWIND statement . 9.6 File inquiry
24、155 156 160 160 160 . 9.6.1 Inquiry specifiers . 9.6.2 Restrictions on inquiry specifiers. 9.6.3 Inquire by output list. . . Restrictions on function references and list items. . 9.7 V ISO/IEC 1539- 1 : 1997(E) O ISO/IEC 160 9.8 Restriction on input/output statements. 10 Input/output editing . 161 1
25、0.1 10.2 10.3 10.4 10.5 10.6 10.7 10.8 10.9 161 161 10.1.1 FORMAT statement. 10.1.2 Character format specification . 161 162 Form of a format item list. . 162 10.2.1 Edit descriptors 164 10.2.2 Fields . 164 . 165 165 Data edit descriptors. . 165 10.5.1 Numeric editing. . 170 10.5.2 Logical editing .
26、 170 10.5.3 Character editing 170 171 172 173 173 173 . 173 174 1 74 1 74 175 177 Namelist formatting . 178 179 10.9.2 Namelist output. 182 Explicit format specification methods Interaction between input/output list and format Positioning by format control . 10.5.4 Generalized editing. Control edit
27、descriptors 10.6.1 Position editing . 10.6.2 Slash editing. 10.6.3 Colon editing S, SP, and SS editing. . 10.6.5 P editing . BN and BZ editing. . Character string edit descriptors. List-directed formatting . 10.8.1 List-directed input. . 10.8.2 List-directed output. 10.9.1 Namelist input . 10.6.4 10
28、.6.6 11 Programunits . 185 185 11.1.1 Main program specifications . 185 186 11.1.3 Main program internal subprograms 186 11.2 External subprograms. . 186 11.3 Modules 186 187 11.3.1 Module reference . 11.3.2 The USE statement and use association . 187 11.4 Block data program units. . 189 11.1 Main p
29、rogram . 11.1.2 Main program executable par . 12 Procedures 191 12.1 Procedure classifications 191 12.1.1 Procedure classification by reference. 191 12.1.2 Procedure classification by means of definition. . 191 12.2 Characteristics of procedures. . 192 12.2.1 Characteristics of dummy arguments 192 1
30、2.2.2 Characteristics of function results . 192 12.3 Procedure interface. 192 12.3.1 Implicit and explicit interfaces. . 192 . . vi O ISO/IEC ISO/IEC 1539- 1 1997(E) 12.3.2 Specification of the procedure interface 12.4 Procedure reference. . 12.4.1 Actual arguments, dummy arguments, and argument ass
31、ociation 12.4.2 Function reference 12.4.3 Subroutine reference Procedure definition. . 12.5.1 Intrinsic procedure definition. 12.5.2 Procedures defined by subprograms. 12.5.3 Definition of procedures by means other than Fortran. . 12.5.4 Statement function. . 12.6 Pureprocedures . Elemental procedur
32、e declaration and interface Elemental function actual arguments and results 12.5 12.7 Elemental procedures Elemental subroutine actual arguments 12.7.1 12.7.2 12.7.3 193 198 199 205 206 206 206 206 211 211 212 213 213 214 214 13 Intrinsic procedures 217 13.1 13.2 13.3 13.4 13.5 13.6 13.7 13.8 13.9 1
33、3.10 13.11 217 217 21 7 218 Numeric, mathematical, character, kind, logical, and bit procedures 218 218 13.5.1 Numeric functions. . 21 8 13.5.2 Mathematical functions. . 218 13.5.3 Character functions . 218 218 13.5.5 Kind functions . 218 219 13.5.7 Transfer function. 21 9 219 219 13.7.1 220 220 13.
34、7.3 220 220 13.8.1 221 13.8.3 221 221 221 222 222 222 Intrinsic functions . Elemental intrinsic procedures Arguments to intrinsic procedures . Argument presence inquiry function . 13.5.4 Character inquiry function . 13.5.6 Logical function Bit manipulation and inquiry procedures. Numeric manipulatio
35、n and inquiry functions . Models for integer and real data 13.7.2 Numeric inquiry functions. Floating point manipulation functions . Array intrinsic functions . The shape of array arguments 13.8.2 Maskarguments 221 Vector and matrix multiplication functions . 13.8.4 Array reduction functions. . 22 1
36、 13.8.5 Array inquiry functions 13.8.6 Array construction functions . 13.8.7 Array reshape function 13.8.8 Array manipulation functions 13.8.9 Array location functions Pointer association status functions Intrinsicsubroutines 222 13.10.1 Date and time subroutines . 222 13.10.2 Pseudorandom numbers.
37、222 13.10.3 Bit copy subroutine 222 223 Generic intrinsic functions 13.11.1 Argument presence inquiry function 223 13.11.2 Numeric functions 223 13.11.3 Mathematical functions. . . 223 . . ISO/IEC 1539- 1 1997(E) O ISO/IEC 13.11.4 Character functions . 13.11.6 Kind functions . 13.11.5 Character inqu
38、iry function . 13.11.7 Logical function 13.11.8 Numeric inquiry functions . 13.11.9 Bit inquiry function . 13.11.10 Bit manipulation functions . 13.11.12 Floating-point manipulation functions . Vector and matrix multiply functions 13.11.14 Array reduction functions 13.11.15 Array inquiry functions .
39、 13.11.16 Array construction functions . 13.11.17 Array reshape function 13.11.18 Array manipulation functions 13.11.19 Array location functions . 13.11.20 Pointer association status functions . 13.12 Intrinsic subroutines . 13.13 Specific names for intrinsic functions . 13.14 Specifications of the
40、intrinsic procedures 13.11.11 Transfer function . 13.11.13 14 Scope. association. and definition . 14.1 Scopeofnames . 14.1.1 Global entities 14.1.2 Local entities . 14.1.3 Statement and construct entities 14.2 Scopeof labels 14.3 14.5 14.6 Association . 14.6.1 Name association . 14.6.2 Pointer asso
41、ciation 14.6.3 Storage association Definition and undefinition of variables 14.7.1 Definition of objects and subobjects . 14.7.2 Variables that are always defined . 14.7.3 Variables that are initially defined . 14.7.4 Variables that are initially undefined 14.7.5 14.7.6 Scope of external input/outpu
42、t units . 14.4 Scope of operators . Scope of the assignment symbol . 14.7 Events that cause variables to become defined Events that cause variables to become undefined A . Glossary of technical terms B . Decremental features . B.l Deleted features . B.l.l Real and double precision DO variables B.1.2
43、 Branching to an END IF statement from outside its IF block . B.1.3 PAUSE statement . 8.1.4 ASSIGN, assigned GO TO, and assigned FORMAT B.1.5 H edit descriptor . 8.2 Obsolescent features . 224 224 224 224 224 225 225 225 225 225 225 226 226 226 226 226 226 226 227 228 275 275 275 275 280 281 281 281
44、 281 281 282 284 285 288 288 288 288 288 288 290 293 303 303 303 304 304 304 306 306 viii O ISO/IEC ISO/IEC 1539- 1 1997(E) B.2.1 Alternate return 306 B.2.3 Statement functions. 307 B.2.2 Computed GO TO statement . 307 B.2.4 DATA statements among executables 307 B.2.5 Assumed character length functi
45、ons. 307 B.2.6 Fixed form source 307 B.2.7 CHARACTER* form of CHARACTER declaration . 307 C. Extended notes 309 c.1 c.2 c.3 c.4 c.5 C.6 c.7 C.8 c.9 c.10 c.11 Section4notes 309 C.l.l Intrinsic and derived data types (4.3,4.4). 309 C.1.2 Selection of the approximation methods (4.3.1.2) 310 C.1.3 Point
46、ers (4.4.1) . 311 Section5notes 312 C.2.1 The POINTER attribute (5.1.2.7) 312 C.2.2 The TARGET attribute (5.1.2.8) . 312 Section6notes 313 C.3.1 Structure components (6.1.2) . 313 C.3.2 Pointer allocation and association . 314 Section7notes 314 C.4.1 Character assignment . 314 C.4.2 Evaluation of fu
47、nction references . 315 C.4.3 Pointers in expressions 315 C.4.4 Pointers on the left side of an assignment 315 C.4.5 An example of a FORALL construct containing a WHERE construct 316 C.4.6 Examples of FORALL statements . 316 Section8notes 317 C.5.1 Loop control . 317 C.5.2 The CASE construct. 317 C.
48、5.3 Additional examples of DO constructs. 317 C.5.4 Examples of invalid DO constructs. . 319 Section9notes 319 C.6.1 Files (9.2). . 319 C.6.2 OPEN statement (9.3.4). . 322 C.6.3 Connection properties (9.3.2) . 323 C.6.4 CLOSE statement (9.3.5) . 324 C.6.5 INQUIRE statement (9.6) 325 SectionlOnotes .
49、 325 C.7.1 Number of records (10.3, 10.4, 10.6.2) 325 C.7.2 List-directed input (10.8.1) . 326 Section 11 notes . 327 C.8.1 Main program and block data program unit (11.1,11.4). 327 C.8.3 Examples of the use of modules 329 Section12notes . 334 C.8.2 Dependent compilation (11.3) . 327 C.9.1 Portability problems with external procedures (12.3.2.2) 334 C.9.2 Procedures defined by means other than Fort 334 C.9.3 Procedure interfaces (12.3) . 335 C.9.4 Argument association and evaluation (12.4.1.1) . 335 C.10.1 Examples of host association (14.6.1.3) . . 337 C.9.5 Pointers and targets as ar