Information technology — Programming languages — Fortran — Part 1: Base language

ISO/IEC 1539-1:2004 specifies the form and establishes the interpretation of programs expressed in the base Fortran language. Its purpose is to promote portability, reliability, maintainability and efficient execution of Fortran programs for use on a variety of computing systems.

Technologies de l'information — Langages de programmation — Fortran — Partie 1: Langage de base

General Information

Status
Withdrawn
Publication Date
17-Nov-2004
Withdrawal Date
17-Nov-2004
Current Stage
9599 - Withdrawal of International Standard
Completion Date
06-Oct-2010
Ref Project

Relations

Buy Standard

Standard
ISO/IEC 1539-1:2004 - Information technology -- Programming languages -- Fortran
English language
567 pages
sale 15% off
Preview
sale 15% off
Preview

Standards Content (Sample)

INTERNATIONAL ISO/IEC
STANDARD 1539-1
Second edition
2004-11-15


Information technology — Programming
languages — Fortran —
Part 1:
Base language
Technologies de l'information — Langages de programmation —
Fortran —
Partie 1: Langage de base




Reference number
ISO/IEC 1539-1:2004(E)
©
ISO/IEC 2004

---------------------- Page: 1 ----------------------
ISO/IEC 1539-1:2004(E)
PDF disclaimer
This PDF file may contain embedded typefaces. In accordance with Adobe's licensing policy, this file may be printed or viewed but
shall not be edited unless the typefaces which are embedded are licensed to and installed on the computer performing the editing. In
downloading this file, parties accept therein the responsibility of not infringing Adobe's licensing policy. The ISO Central Secretariat
accepts no liability in this area.
Adobe is a trademark of Adobe Systems Incorporated.
Details of the software products used to create this PDF file can be found in the General Info relative to the file; the PDF-creation
parameters were optimized for printing. Every care has been taken to ensure that the file is suitable for use by ISO member bodies. In
the unlikely event that a problem relating to it is found, please inform the Central Secretariat at the address given below.


©  ISO/IEC 2004
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 microfilm, without permission in writing from either ISO at the address below or
ISO's member body in the country of the requester.
ISO copyright office
Case postale 56 • CH-1211 Geneva 20
Tel. + 41 22 749 01 11
Fax + 41 22 749 09 47
E-mail copyright@iso.org
Web www.iso.org
Published in Switzerland

ii © ISO/IEC 2004 – All rights reserved

---------------------- Page: 2 ----------------------
ISO/IEC 1539-1:2004(E)
Contents
1 Overview . . 1
1.1 Scope . 1
1.2 Processor. 1
1.3 Inclusions . . 1
1.4 Exclusions . . 1
1.5 Conformance. 2
1.6 Compatibility . 3
1.6.1 Fortran95compatibility . 3
1.6.2 Fortran90compatibility . 3
1.6.3 FORTRAN77compatibility . . 4
1.7 Notation used in this standard . . . . 4
1.7.1 Informativenotes . . 4
1.7.2 Syntaxrules . 4
1.7.3 Constraints . 5
1.7.4 Assumedsyntaxrules. 6
1.7.5 Syntaxconventionsandcharacteristics . . 6
1.7.6 Textconventions . 6
1.8 Deletedandobsolescentfeatures. . 7
1.8.1 Nature of deleted features . 7
1.8.2 Nature of obsolescent features . . . 7
1.9 Normativereferences . 7
2 Fortrantermsandconcepts . 9
2.1 Highlevelsyntax . 9
2.2 Programunitconcepts . 11
2.2.1 Program . 12
2.2.2 Mainprogram . 12
2.2.3 Procedure . 12
2.2.4 Module . 13
2.3 Executionconcepts . 13
2.3.1 Executable/nonexecutable statements . . . . . . 13
2.3.2 Statement order . . . 13
2.3.3 The END statement. 14
2.3.4 Executionsequence . 15
2.4 Data concepts . 15
2.4.1 Type . 15
2.4.2 Data value . . 16
2.4.3 Data entity . . 16
2.4.4 Scalar. 17
2.4.5 Array. 18
2.4.6 Pointer . 18
2.4.7 Storage . 18
2.5 Fundamentalterms . . 18
2.5.1 Name and designator . . . . 19
2.5.2 Keyword . 19
2.5.3 Association. 19
2.5.4 Declaration . 19
© ISO/IEC 2004 – All rights reserved iii

---------------------- Page: 3 ----------------------
ISO/IEC 1539-1:2004(E)
2.5.5 Definition . 19
2.5.6 Reference. 20
2.5.7 Intrinsic . 20
2.5.8 Operator . . . 20
2.5.9 Sequence . . 20
2.5.10 Companionprocessors . . 21
3 Characters,lexicaltokens,andsourceform . . 23
3.1 Processorcharacterset . 23
3.1.1 Letters . 23
3.1.2 Digits. 24
3.1.3 Underscore. . 24
3.1.4 Specialcharacters . 24
3.1.5 Othercharacters. 24
3.2 Low-levelsyntax. 25
3.2.1 Names . 25
3.2.2 Constants . 25
3.2.3 Operators . . 25
3.2.4 Statement labels . . . 26
3.2.5 Delimiters . . 27
3.3 Sourceform . . 27
3.3.1 Freesourceform. . 27
3.3.2 Fixedsourceform . 29
3.4 Includingsourcetext . 30
4 Types . 33
4.1 Theconceptoftype. . 33
4.1.1 Setofvalues . 33
4.1.2 Constants . 33
4.1.3 Operations . . 34
4.2 Typeparameters . . 34
4.3 Relationshipoftypesandvaluestoobjects . 35
4.4 Intrinsictypes . 35
4.4.1 Integertype . 36
4.4.2 Realtype. . 37
4.4.3 Complextype . 39
4.4.4 Charactertype . 40
4.4.5 Logical type . 43
4.5 Derivedtypes . 44
4.5.1 Derived-typedefinition . 45
4.5.2 Derived-typeparameters . . 48
4.5.3 Components . 49
4.5.4 Type-boundprocedures. . 56
4.5.5 Finalsubroutines . . 58
4.5.6 Typeextension . 60
4.5.7 Derived-typevalues . 62
4.5.8 Derived-typespecifier . 62
4.5.9 Constructionofderived-typevalues . 63
4.5.10 Derived-typeoperationsandassignment . 65
4.6 Enumerationsandenumerators . . 66
4.7 Constructionofarrayvalues . 67
5 Data object declarations and specifications . . . 71
5.1 Type declaration statements . 71
iv © ISO/IEC 2004 – All rights reserved

---------------------- Page: 4 ----------------------
ISO/IEC 1539-1:2004(E)
5.1.1 Declarationtypespecifiers . 75
5.1.2 Attributes . 76
5.2 Attribute specification statements . . 85
5.2.1 Accessibility statements . . 86
5.2.2 ALLOCATABLE statement . . . . 86
5.2.3 ASYNCHRONOUSstatement . 86
5.2.4 BIND statement . . . 87
5.2.5 DATA statement . . 87
5.2.6 DIMENSION statement . . 90
5.2.7 INTENTstatement . 90
5.2.8 OPTIONAL statement . . . 90
5.2.9 PARAMETER statement . . 90
5.2.10 POINTER statement . . . . 91
5.2.11 PROTECTEDstatement. . 91
5.2.12 SAVEstatement. 91
5.2.13 TARGET statement . . . . 92
5.2.14 VALUE statement . . 92
5.2.15 VOLATILE statement . . . 92
5.3 IMPLICITstatement . 92
5.4 NAMELISTstatement . 95
5.5 Storageassociationofdataobjects . 95
5.5.1 EQUIVALENCE statement . . . . 95
5.5.2 COMMONstatement . 98
6 Useofdataobjects . . 103
6.1 Scalars . 104
6.1.1 Substrings . . 104
6.1.2 Structurecomponents. 104
6.1.3 Typeparameterinquiry . . 106
6.2 Arrays . 106
6.2.1 Wholearrays . 107
6.2.2 Arrayelementsandarraysections . 107
6.3 Dynamicassociation . 110
6.3.1 ALLOCATE statement . . . 110
6.3.2 NULLIFY statement . . . . 113
6.3.3 DEALLOCATE statement . 114
7 Expressionsandassignment . 117
7.1 Expressions . 117
7.1.1 Formofanexpression. 117
7.1.2 Intrinsicoperations . 121
7.1.3 Definedoperations . 122
7.1.4 Type,typeparameters,andshapeofanexpression . . 123
7.1.5 Conformabilityrulesforelementaloperations . 125
7.1.6 Specificationexpression. 125
7.1.7 Initializationexpression. 126
7.1.8 Evaluationofoperations . 128
7.2 Interpretation of operations . 132
7.2.1 Numericintrinsicoperations . 133
7.2.2 Characterintrinsicoperation. 133
7.2.3 Relationalintrinsicoperations . . 134
7.2.4 Logical intrinsic operations. 135
7.3 Precedence of operators . . . . 136
7.4 Assignment . . 138
© ISO/IEC 2004 – All rights reserved v

---------------------- Page: 5 ----------------------
ISO/IEC 1539-1:2004(E)
7.4.1 Assignment statement . . . 138
7.4.2 Pointerassignment . 142
7.4.3 Maskedarrayassignment–WHERE . 145
7.4.4 FORALL . . . 148
8 Executioncontrol. . 155
8.1 Executableconstructscontainingblocks . 155
8.1.1 Rulesgoverningblocks . . 155
8.1.2 IFconstruct . 156
8.1.3 CASEconstruct . 158
8.1.4 ASSOCIATEconstruct . . 160
8.1.5 SELECTTYPEconstruct . 162
8.1.6 DOconstruct . 164
8.2 Branching . 169
8.2.1 GO TO statement . . 169
8.2.2 Computed GO TO statement . . . 170
8.2.3 Arithmetic IF statement . . 170
8.3 CONTINUE statement . . . . 170
8.4 STOPstatement . . 170
9 Input/output statements . . . 171
9.1 Records. 171
9.1.1 Formatted record . . 171
9.1.2 Unformatted record . 172
9.1.3 Endfilerecord . 172
9.2 Externalfiles. . 172
9.2.1 Fileexistence . 173
9.2.2 Fileaccess . . 173
9.2.3 Fileposition . 175
9.2.4 Filestorageunits . . 177
9.3 Internalfiles . . 177
9.4 Fileconnection . 178
9.4.1 Connectionmodes. 179
9.4.2 Unitexistence . 179
9.4.3 Connectionofafiletoaunit. 179
9.4.4 Preconnection . 180
9.4.5 The OPEN statement . . . . 180
9.4.6 The CLOSE statement . . . 184
9.5 Data transfer statements . . . 186
9.5.1 Controlinformationlist. 186
9.5.2 Data transfer input/output list . . 191
9.5.3 Execution of a data transfer input/output statement . 193
9.5.4 Termination of data transfer statements . . . . 205
9.6 Waitingonpendingdatatransfer . 205
9.6.1 WAITstatement . 205
9.6.2 Waitoperation . 206
9.7 Filepositioningstatements . 207
9.7.1 BACKSPACEstatement . . 207
9.7.2 ENDFILE statement . . . . 208
9.7.3 REWIND statement . . . . 208
9.8 FLUSH statement . . . 208
9.9 Fileinquiry . 209
9.9.1 Inquiryspecifiers . . 210
9.9.2 Restrictionsoninquiryspecifiers. . 216
vi © ISO/IEC 2004 – All rights reserved

---------------------- Page: 6 ----------------------
ISO/IEC 1539-1:2004(E)
9.9.3 Inquirebyoutputlist . 216
9.10 Error,end-of-record,andend-of-fileconditions . . 216
9.10.1 ErrorconditionsandtheERR=specifier . 217
9.10.2 End-of-fileconditionandtheEND=specifier. 217
9.10.3 End-of-recordconditionandtheEOR=specifier. 217
9.10.4 IOSTAT=specifier . 218
9.10.5 IOMSG=specifier. . 218
9.11 Restrictions on input/output statements . . . . . 219
10 Input/output editing . 221
10.1 Explicitformatspecificationmethods . 221
10.1.1 FORMAT statement . . . . 221
10.1.2 Characterformatspecification . 221
10.2 Formofaformatitemlist . . 222
10.2.1 Editdescriptors . . 222
10.2.2 Fields. 224
10.3 Interaction between input/output list and format . . . . 224
10.4 Positioningbyformatcontrol . 225
10.5 Decimalsymbol . 226
10.6 Data edit descriptors . 226
10.6.1 Numericediting . . 226
10.6.2 Logical editing . . . . 232
10.6.3 Characterediting . . 232
10.6.4 Generalizedediting . 233
10.6.5 User-definedderived-typeediting . 235
10.7 Controleditdescriptors. 235
10.7.1 Positionediting . 235
10.7.2 Slashediting . 236
10.7.3 Colonediting . 236
10.7.4 SS,SP,andSediting . 237
10.7.5 Pediting . . 237
10.7.6 BNandBZediting . 237
10.7.7 RU,RD,RZ,RN,RC,andRPediting . . 238
10.7.8 DCandDPediting . 238
10.8 Characterstringeditdescriptors. . 238
10.9 List-directed formatting . . . 238
10.9.1 List-directedinput . 239
10.9.2 List-directedoutput. 241
10.10 Namelist formatting . . 242
10.10.1 Namelistinput. 243
10.10.2 Namelistoutput . . 246
11 Programunits . 249
11.1 Mainprogram . 249
11.2 Modules . 250
11.2.1 The USE statement and use association . . . . . 251
11.3 Blockdataprogramunits. . 253
12 Procedures . 255
12.1 Procedureclassifications . . 255
12.1.1 Procedureclassificationbyreference. 255
12.1.2 Procedureclassificationbymeansofdefinition . 255
12.2 Characteristicsofprocedures. 256
12.2.1 Characteristicsofdummyarguments . . 256
© ISO/IEC 2004 – All rights reserved vii

---------------------- Page: 7 ----------------------
ISO/IEC 1539-1:2004(E)
12.2.2 Characteristicsoffunctionresults . 257
12.3 Procedureinterface . . 257
12.3.1 Implicitandexplicitinterfaces . 257
12.3.2 Specificationoftheprocedureinterface . . 258
12.4 Procedurereference . . 266
12.4.1 Actualarguments,dummyarguments,andargumentassociation. 268
12.4.2 Functionreference. 276
12.4.3 Subroutinereference . 276
12.4.4 Resolvingnamedprocedurereferences. 276
12.4.5 Resolvingtype-boundprocedurereferences . . 278
12.5 Proceduredefinition. . 279
12.5.1 Intrinsicproceduredefinition. 279
12.5.2 Proceduresdefinedbysubprograms . 279
12.5.3 Definition and invocation of procedures by means other than Fortran . . . . . . 285
12.5.4 Statement function . 285
12.6 Pureprocedures . 286
12.7 Elementalprocedures . 287
12.7.1 Elementalproceduredeclarationandinterface . 287
12.7.2 Elementalfunctionactualargumentsandresults. 288
12.7.3 Elementalsubroutineactualarguments . . 289
13 Intrinsicproceduresandmodules . 291
13.1 Classesofintrinsicprocedures . 291
13.2 Argumentstointrinsicprocedures . . 291
13.2.1 Theshapeofarrayarguments . 292
13.2.2 Maskarguments. 292
13.3 Bitmodel . . 292
13.4 Numericmodels . 293
13.5 Standardgenericintrinsicprocedures . 294
13.5.1 Numericfunctions. . 294
13.5.2 Mathematicalfunctions. . 294
13.5.3 Characterfunctions . 295
13.5.4 Kindfunctions. 295
13.5.5 Miscellaneoustypeconversionfunctions. . 295
13.5.6 Numericinquiryfunctions . 295
13.5.7 Arrayinquiryfunctions . 296
13.5.8 Otherinquiryfunctions. 296
13.5.9 Bitmanipulationprocedures . 296
13.5.10 Floating-point manipulation functions . . . . . . 296
13.5.11 Vectorandmatrixmultiplyfunctions . . 297
13.5.12 Arrayreductionfunctions . 297
13.5.13 Arrayconstructionfunctions . 297
13.5.14 Arraylocationfunctions . . 297
13.5.15 Nullfunction. 297
13.5.16 Allocationtransferprocedure . . 297
13.5.17 Randomnumbersubroutines. 297
13.5.18 Systemenvironmentprocedures . . 298
13.6 Specificnamesforstandardintrinsicfunctions . 298
13.7 Specificationsofthestandardintrinsicprocedures . 300
13.8 Standardintrinsicmodules . 359
13.8.1 TheIEEEmodules . 359
13.8.2 The ISO FORTRANENVintrinsicmodule . 359
13.8.3 The ISO C BINDING module . . . 360
viii © ISO/IEC 2004 – All rights reserved

---------------------- Page: 8 ----------------------
ISO/IEC 1539-1:2004(E)
14 ExceptionsandIEEEarithmetic . . 361
14.1 Derivedtypesandconstantsdefinedinthemodules . 362
14.2 Theexceptions . 363
14.3 Theroundingmodes . 365
14.4 Underflowmode . 365
14.5 Halting . 366
14.6 The floating point status . . . 366
14.7 Exceptionalvalues. 366
14.8 IEEEarithmetic. 366
14.9 Tablesoftheprocedures . 367
14.9.1 Inquiryfunctions . . 367
14.9.2 Elementalfunctions . 368
14.9.3 Kindfunction . 368
14.9.4 Elementalsubroutines . . 368
14.9.5 Nonelementalsubroutines . 368
14.10 Specificationsoftheprocedures . 369
14.11 Examples. 384
15 InteroperabilitywithC. 389
15.1 The ISO C BINDING intrinsic module . . . . . . 389
15.1.1 Namedconstantsandderivedtypesinthemodule. 389
15.1.2 Proceduresinthemodule . 390
15.2 InteroperabilitybetweenFortranandCentities . 393
15.2.1 Interoperabilityofintrinsictypes . 394
15.2.2 InteroperabilitywithCpointertypes . 395
15.2.3 InteroperabilityofderivedtypesandCstructtypes . 396
15.2.4 Interoperabilityofscalarvariables . 397
15.2.5 Interoperabilityofarrayvariables . 397
15.2.6 Interoperabilityofproceduresandprocedureinterfaces . 398
15.3 InteroperationwithCglobalvariables. 400
15.3.1 Bindinglabelsforcommonblocksandvariables . 401
15.4 InteroperationwithCfunctions . 401
15.4.1 Bindinglabelsforprocedures . . 401
15.4.2 ExceptionsandIEEEarithmeticprocedures . 402
16 Scope,association,anddefinition . 403
16.1 Scopeofglobalidentifiers. 403
16.2 Scopeoflocalidentifiers . . 404
16.2.1 Localidentifiersthatarethesameascommonblocknames. 405
16.2.2 Functionresults . 405
16.2.3 Restrictionsongenericdeclarations . 405
16.2.4 Components,typeparameters,andbindings . 406
16.2.5 Argumentkeywords . 407
16.3 Statement and construct entities . . . 407
16.4 Association. 408
16.4.1 Nameassociation . 408
16.4.2 Pointerassociation . 412
16.4.3 Storageassociation . 413
16.4.4 Inheritanceassociation . 416
16.4.5 Establishingassociations . . 416
16.5 Definitionandundefinitionofvariables . . 417
16.5.1 Definitionofobjectsandsubobjects. 417
16.5.2 Variablesthatarealwaysdefined . 417
16.5.3 Variablesthatareinitiallydefined. 417
© ISO/IEC 2004 – All rights reserved ix

---------------------- Page: 9 ----------------------
ISO/IEC 1539-1:2004(E)
16.5.4 Variablesthatareinitiallyundefined . 418
16.5.5 Eventsthatcausevariablestobecomedefined . 418
16.5.6 Eventsthatcausevariablestobecomeundefined. 419
16.5.7 Variabledefinitioncontext . 421
AnnexA (informative)Glossaryoftechnicalterms . 423
AnnexB (informative)Decrementalfeatures. 435
B.1 Deletedfeatures . 435
B.2 Obsolescentfeatures. . 436
B.2.1 Alternatereturn. 436
B.2.2 Computed GO TO statement . . . 436
B.2.3 Statement functions. 436
B.2.4 DATA statements among executables . . . . . . 437
B.2.5 Assumedcharacterlengthfunctions. 437
B.2.6 Fixedformsource . 437
B.2.7 CHARACTER* form of CHARACTER declaration . . 437
AnnexC (informative)Extendednotes . 439
C.1 Section 4notes . 439
C.1.1 Intrinsic and derived types (4.4, 4.5) . 439
C.1.2 Selection of the approximation methods (4.4.2) . 440
C.1.3 Type extension and component accessibility (4.5.1.1, 4.5.3) . 440
C.1.4 Abstracttypes. 441
C.1.5 Pointers (4.5.1) . . 442
C.1.6 Structureconstructorsandgenericnames. 443
C.1.7 Generictype-boundprocedures . 445
C.1.8 Final subroutines (4.5.5, 4.5.5.1, 4.5.5.2, 4.5.5.3) . . 446
C.2 Section 5notes . 448
C.2.1 The POINTER attribute (5.1.2.11) . 448
C.2.2 The TARGET attribute (5.1.2.14). 449
C.2.3 The VOLATILE attribute (5.1.2.16). 449
C.3 Section 6notes . 450
C.3.1 Structure components (6.1.2). . 450
C.3.2 Allocation with dynamic type (6.3.1) . 451
C.3.3 Pointerallocationandassociation . 452
C.4 Section 7notes . 453
C.4.1 Characterassignment . 453
C.4.2 Evaluationoffunctionreferences . 453
C.4.3 Pointersinexpressions . 453
C.4.4 Pointersontheleftsideofanassignment. 453
C.4.5 An example of a FORALL construct containing a WHERE construct . . . . . . 454
C.4.6 Examples of FORALL statements . 455
C.5 Section 8notes . 456
C.5.1 Loopcontrol . 456
C.5.2 TheCASEconstruct . 456
C.5.3 ExamplesofDOconstructs. 456
C.5.4 ExamplesofinvalidDOconstructs . 458
C.6 Section 9notes . 459
C.6.1 External files (9.2) . . 459
C.6.2 Nonadvancing input/output (9.2.3.1) . 461
C.6.3 Asynchronousinput/output . 462
C.6.4 OPEN statement (9.4.5) . . 463
C.6.5 Connection properties (9.4.3) . . 464
x © ISO/IEC 2004 – All rights reserved

---------------------- Page: 10 ----------------------
ISO/IEC 1539-1:2004(E)
C.6.6 CLOSE statement (9.4.6). . 465
C.7 Section 10notes.
...

Questions, Comments and Discussion

Ask us and Technical Secretary will try to provide an answer. You can facilitate discussion about the standard in here.