Fortran 2003 Handbook (eBook)
XII, 713 Seiten
Springer London (Verlag)
978-1-84628-746-6 (ISBN)
The Fortran 2003 Handbook is a definitive and comprehensive guide to Fortran 2003 and its use. Fortran 2003, the latest standard version of Fortran, has many excellent features that assist the programmer in writing efficient, portable and maintainable programs. This all-inclusive volume offers a reader-friendly, easy-to-follow and informal description of Fortran 2003, and has been developed to provide not only a readable explanation of features, but also some rationale for the inclusion of features and their use. This highly versatile handbook is intended for anyone who wants a comprehensive survey of Fortran 2003.
Fortran continues to be the premier language used in scientific and engineering computing since its introduction in the 1950s. Fortran 2003 is the latest standard version and has many excellent modern features that assist programmers in writing efficient, portable and maintainable programs that are useful for everything from 'hard science' to text processing.The Fortran 2003 Handbook is the definitive and comprehensive guide to Fortran 2003, the latest standard version of Fortran. This all-inclusive volume offers a reader-friendly, easy-to-follow and informal description of Fortran 2003, and has been developed to provide not only a readable explanation of features, but also some rationale for the inclusion of features and their use. Experienced Fortran 95 programmers will be able to use this volume to assimilate quickly those features in Fortran 2003 that are not in Fortran 95 (Fortran 2003 contains all of the features of Fortran 95).Features and benefits: The complete syntax of Fortran 2003 is supplied. Each of the intrinsic standard procedures is described in detail. There is a complete listing of the new, obsolescent, and deleted features. Numerous examples are given throughout, providing insights into intended uses and interactions of the features. IEEE module procedures are covered thoroughly. Chapters begin with a summary of the main terms and concepts described. Models provide the reader with insight into the language.Key Topics: Fortran Concepts and Terms Language Elements and Source Form Data Types Block Constructs and Execution Control I/O Processing and Editing Interoperability with C Standard Intrinsic ProceduresThis highly versatile and authoritative handbook is intended for anyone who wants a comprehensive survey of Fortran 2003, including those familiar with programming language concepts but unfamiliar with Fortran. It offers a practical description of Fortran 2003 for professionals developing sophisticated application and commercial software in Fortran, as well as developers of Fortran compilers.All authors have been heavily involved in the development of Fortran standards. They have served on national and international Fortran standard development committees, and include a chair, convenors and editors of the Fortran 90, 95, and 2003 standards. In addition, Walt Brainerd is the owner of The Fortran Company, Tucson, AZ, USA.
Contents 5
Preface 11
Target Audience 11
Organization 11
Style of the Programming Examples 12
Jeanne Adams 12
1 Introduction 13
1.1 History 13
1.1.1 Initial Development of Fortran 13
1.1.2 Standardization 13
1.1.2.1 Fortran 66 14
1.1.2.2 Fortran 77 14
1.1.2.3 Fortran 90 14
1.1.2.4 Fortran 95 15
1.1.2.5 Fortran 2003 15
1.2 The Fortran 2003 Language Standard 16
1.2.1 Program Conformance to the Standard 17
1.2.2 Processor Conformance to the Standard 17
1.2.3 Portability 18
1.2.4 A Permissive Standard 18
1.3 Notation Used in this Book 18
1.4 Approximations to Real and Complex Values 20
1.5 References 20
2 Fortran Concepts and Terms 23
2.1 Program Organization 24
2.1.1 Program Units 24
2.1.1.1 Main Program 25
2.1.1.2 Module 26
2.1.1.3 External Subprogram 27
2.1.1.4 Block Data Program Unit 27
2.1.1.5 Compilation 27
2.1.2 Procedures 27
2.1.2.1 Internal Procedures 27
2.1.2.2 Procedure Interfaces 28
2.1.2.3 Generic Procedures 28
2.1.2.4 Procedures Defined by Other Languages 28
2.2 Data Environment 29
2.2.1 Data Type 29
2.2.2 Type Parameters 29
2.2.3 Dimensionality 30
2.2.4 Dynamic Data 31
2.2.5 Packaging and Encapsulation 33
2.3 Program Execution 34
2.3.1 Execution Sequence 34
2.3.2 Definition and Undefinition 35
2.3.3 Scope 36
2.3.4 Association 36
2.4 Terms 36
2.5 High-Level Syntax Forms 42
2.5.1 Fortran Program Units 43
2.5.2 The Specification Part 44
2.5.3 The Execution Part 49
2.6 Ordering Requirements 51
2.7 Example Fortran Program 52
3 Language Elements and Source Form 55
3.1 The Processor Character Set 56
3.1.1 The Fortran Character Set 56
3.1.2 Other Characters 58
3.1.3 The Tab Character 58
3.2 Lexical Tokens 59
3.2.1 Statement Keywords 59
3.2.2 Names 60
3.2.3 Constants 60
3.2.4 Operators 61
3.2.5 Statement Labels 61
3.3 Source Form 62
3.3.1 Free Source Form 63
3.3.1.1 Blanks as Separators 66
3.3.1.2 Sample Program, Free Source Form 67
3.3.2 Fixed Source Form 67
3.3.2.1 Sample Program, Fixed Source Form 69
3.3.3 Rules for Fixed/Free Source Form 69
3.3.3.1 Sample Program, Use with Either Source Form 69
3.4 The INCLUDE Line 70
4 Data Types 73
4.1 Data Type Selection 74
4.1.1 Kinds of Intrinsic Types 75
4.1.2 Derived Types 77
4.1.3 Classes 77
4.2 What Is Meant by “Type” in Fortran? 78
4.2.1 Type Names 78
4.2.2 Type Parameters 78
4.2.3 Type Specifier 79
4.2.4 Type Values 79
4.2.5 Type Operations and Procedures 79
4.2.6 Forms for Constants 80
4.3 Intrinsic Types 80
4.3.1 Integer Type 81
4.3.1.1 Name, Type Parameters, and Type Specifier 81
4.3.1.2 Values 81
4.3.1.3 Operators 82
4.3.1.4 Form for Constant Values 82
4.3.2 Real Type 83
4.3.2.1 Name, Type Parameters, and Type Specifier 83
4.3.2.2 Values 84
4.3.2.3 Operators 85
4.3.2.4 Forms for Constants 85
4.3.3 Complex Type 86
4.3.3.1 Name, Type Parameters, and Type Specifier 86
4.3.3.2 Values 86
4.3.3.3 Operators 86
4.3.3.4 Form for Constants 87
4.3.4 Logical Type 87
4.3.4.1 Name, Type Parameters, and Type Specifier 87
4.3.4.2 Values 88
4.3.4.3 Operators 88
4.3.4.4 Form for Constants 88
4.3.5 Character Type 88
4.3.5.1 Name, Type Parameters, and Type Specifier 88
4.3.5.2 Values 90
4.3.5.3 Collating Sequence 90
4.3.5.4 Operators 91
4.3.5.5 Form for Constants 91
4.4 Derived Types 92
4.4.1 A Simple Example of a Derived-Type Definition 92
4.4.2 Derived-Type Definition Overview 93
4.4.3 Type Parameters 93
4.4.4 Type Specifier 95
4.4.5 Accessibility 96
4.4.6 Data Component Definition 97
4.4.7 Procedure Component Definition 99
4.4.8 The Passed-Object Dummy Argument 101
4.4.9 Default Initialization 103
4.4.10 Sequence Types and Type Equivalence 104
4.4.11 Procedure Type Bindings 107
4.4.11.1 Specific Bindings 107
4.4.11.2 Generic Bindings 109
4.4.11.3 Final Bindings 110
4.4.12 Type Extension and Inheritance 112
4.4.12.1 Type Extension Versus its Alternatives 113
4.4.12.2 Overriding Procedure Bindings 115
4.4.12.3 Abstract Types and Deferred Procedure Bindings 116
4.4.12.4 Example of Inheriting and Overriding Bindings 116
4.4.13 Values 119
4.4.14 Operators 119
4.4.15 Structure Constructor 120
4.5 Array Constructors 123
4.6 Enumerations 125
5 Declarations 127
5.1 Type Declaration Statements 130
5.2 Polymorphism 132
5.3 Implicit Typing 134
5.4 Array Properties 136
5.4.1 Array Specifications 136
5.4.1.1 Explicit-Shape Arrays 136
5.4.1.2 Assumed-Shape Arrays 137
5.4.1.3 Deferred-Shape Arrays 138
5.4.1.4 Assumed-Size Arrays 139
5.4.1.5 Limitations on Whole Arrays 140
5.4.2 The DIMENSION Attribute 141
5.5 The ALLOCATABLE Attribute 142
5.6 Pointer Properties 143
5.6.1 The POINTER Attribute 144
5.6.2 The TARGET Attribute 145
5.7 Value Definition Properties 145
5.7.1 The PARAMETER Attribute 146
5.7.2 Explicit Initialization 147
5.7.3 The DATA Statement 149
5.7.4 The SAVE Attribute 151
5.7.5 The ASYNCHRONOUS Attribute 153
5.7.6 The VOLATILE Attribute 154
5.8 Module Entity Properties 156
5.8.1 PUBLIC and PRIVATE Accessibility 156
5.8.2 The PROTECTED Attribute 158
5.8.3 The BIND Attribute 160
5.9 Dummy Argument Properties 161
5.9.1 The INTENT Attribute 162
5.9.2 The VALUE Attribute 164
5.9.3 The OPTIONAL Attribute 165
5.10 Procedure Properties 166
5.10.1 The EXTERNAL Attribute 166
5.10.2 The INTRINSIC Attribute 168
5.11 The Procedure Declaration Statement 169
5.12 Attribute Compatibility 171
5.13 The NAMELIST Statement 173
5.14 Storage Association 174
5.14.1 The EQUIVALENCE Statement 175
5.14.2 The COMMON Statement 177
6 Using Data 183
6.1 Constants and Variables 185
6.2 Designators 185
6.3 Type Parameter Inquiry 187
6.4 Substrings 188
6.5 Structure Components 190
6.6 Arrays 192
6.6.1 Array Terminology 192
6.6.2 Whole Arrays 193
6.6.3 Array Elements 193
6.6.4 Array Sections 194
6.6.4.1 Subscripts 195
6.6.4.2 Subscript Triplets 195
6.6.4.3 Vector Subscripts 196
6.6.5 Examples of Array Elements and Array Sections 196
6.6.6 Array Element Order 198
6.7 Pointers and Allocatable Variables 199
6.7.1 ALLOCATE Statement 200
6.7.1.1 Allocation of Allocatable Variables 203
6.7.1.2 Allocation of Pointers 205
6.7.2 NULLIFY Statement 206
6.7.3 DEALLOCATE Statement 206
6.7.3.1 Deallocation of Allocatable Variables 208
6.7.3.2 Deallocation of Pointers 209
7 Expressions and Assignment 211
7.1 Formation of Expressions 212
7.1.1 Operators and Operations 213
7.1.1.1 Operators 213
7.1.1.2 Operations 214
7.1.2 Rules for Forming Expressions 215
7.2 Interpretation of Expressions 218
7.2.1 Precedence of Operators 219
7.2.2 Data Type and Type Parameters of an Expression 221
7.2.2.1 Data Type and Type Parameters of a Primary 221
7.2.2.2 Data Type and Type Parameters of an Operation 222
7.2.3 Shape of an Expression 225
7.2.4 Bounds of an Expression 226
7.2.5 Elemental Operations and Functions 226
7.2.6 Value of a Primary 227
7.2.7 Value of an Operation 227
7.2.7.1 Value of Intrinsic Operations 227
7.2.7.2 Value of Defined Operations 230
7.3 Evaluation of Expressions 231
7.3.1 Equivalent Expressions 231
7.3.2 Side Effects and Partial Evaluation 233
7.4 Special Expressions 235
7.4.1 Initialization Expressions 235
7.4.2 Specification Expressions 237
7.4.2.1 Specification Inquiry 240
7.4.2.2 Specification Functions 240
7.4.3 Differences Between Specification and Initialization Expressions 240
7.4.4 Uses of Specification and Initialization Expressions 241
7.5 Assignment 243
7.5.1 The Assignment Statement 244
7.5.2 Intrinsic Assignment 244
7.5.3 Defined Assignment 248
7.5.4 Polymorphic Assignment 249
7.5.5 Pointer Assignment 250
7.5.5.1 Data Pointer Assignment 251
7.5.5.2 Procedure Pointer Assignment 255
7.5.6 Masked Array Assignment-WHERE 256
7.5.6.1 Form of the WHERE Construct 257
7.5.6.2 Execution of a WHERE Construct 258
7.5.6.3 WHERE Statement 260
7.5.7 Indexed Parallel Array Assignment-FORALL 261
7.5.7.1 Form of the FORALL Construct 263
7.5.7.2 Execution of a FORALL Construct 265
7.5.7.3 FORALL Statement 268
8 Block Constructs and Execution Control 269
8.1 Blocks and Construct Names 270
8.2 The ASSOCIATE Construct 271
8.2.1 Form of the ASSOCIATE Construct 271
8.2.2 Execution of the ASSOCIATE Construct 272
8.3 Controlling Execution 273
8.4 The IF Construct and the IF Statement 274
8.4.1 The IF Construct 274
8.4.1.1 Form of the IF Construct 274
8.4.1.2 Execution of the IF Construct 274
8.4.2 The IF Statement 275
8.4.2.1 Form of the IF Statement 276
8.4.2.2 Execution of the IF Statement 276
8.5 The CASE Construct 276
8.5.1 Form of the CASE Construct 276
8.5.2 Execution of the CASE Construct 278
8.6 The SELECT TYPE Construct 279
8.6.1 Form of the SELECT TYPE Construct 279
8.6.2 Execution of the SELECT TYPE Construct 280
8.7 The DO Construct 283
8.7.1 Form of the Block DO Construct 284
8.7.2 Execution of DO Constructs 285
8.7.2.1 Execution of the DO Construct with an Iteration Count 286
8.7.2.2 Execution of the DO Construct with WHILE Control 287
8.7.2.3 Execution of the Simple DO Construct 288
8.7.3 Altering the Execution Sequence within the DO Block 288
8.7.3.1 The EXIT Statement 288
8.7.3.2 The CYCLE Statement 289
8.7.4 Terminating a DO Construct 290
8.7.5 Form of the Nonblock DO 291
8.7.6 Conversion from the Nonblock to the Block Form 292
8.8 Branching 292
8.8.1 Use of Labels in Branching 294
8.8.2 The GO TO Statement 294
8.8.2.1 Form of the GO TO Statement 294
8.8.2.2 Execution of the GO TO Statement 294
8.8.3 The CONTINUE Statement 294
8.8.4 The Arithmetic IF Statement 295
8.8.5 The Computed GO TO Statement 295
8.9 The STOP Statement 296
9 Input and Output Processing 297
9.1 Basic Input/Output Concepts 298
9.1.1 Record Files 299
9.1.2 Stream Files 301
9.1.3 External and Internal Files 302
9.1.3.1 External Files 303
9.1.3.2 Internal Files 303
9.1.3.3 Existence of Files 303
9.1.4 File Position 304
9.1.5 File Access Methods 306
9.1.5.1 Sequential Access 307
9.1.5.2 Direct Access 307
9.1.5.3 Stream Access 308
9.1.6 Units 309
9.1.6.1 Unit Existence 310
9.1.6.2 Establishing a Connection to a Unit 310
9.2 Input/Output Statement Specifier Lists 311
9.2.1 General form of an Input/Output Statement 311
9.2.1.1 Abbreviated Form of Input/Output Statements 313
9.2.1.2 Recursive Input/Output Statements 313
9.2.2 The UNIT Specifier 314
9.2.3 Error and Exception Handling Specifiers 316
9.2.4 Changeable Connection Mode Specifiers 317
9.3 The OPEN Statement 321
9.3.1 Connecting a File to a Unit 321
9.3.2 Form of the OPEN Statement 321
9.3.3 The Connection Specifiers 322
9.4 Data Transfer Statements 328
9.4.1 General Form for Data Transfer Statements 328
9.4.2 The Input/Output Control Specifiers 328
9.4.3 Specifiers for Data Transfer Statements 329
9.4.4 The Input/Output Item List 334
9.4.5 General Data Transfer Restrictions 338
9.4.6 Printing of Formatted Records 338
9.5 Execution Model for Data Transfer Statements 338
9.5.1 Data Transfer 340
9.5.1.1 Unformatted Data Transfer 341
9.5.1.2 Formatted Data Transfer 342
9.5.1.3 Asynchronous Data Transfer 342
9.5.1.4 Defined Input/Output 343
9.5.1.5 Transfer on Internal Files 349
9.5.2 File Position Prior to Data Transfer 350
9.5.3 File Position After Data Transfer 351
9.5.4 Termination of Data Transfer 351
9.6 Error and Other Conditions in Input/Output Statements 352
9.6.1 Error Conditions 352
9.6.2 End-of-File Condition 353
9.6.3 End-of-Record Condition 353
9.7 The WAIT Statement 355
9.7.1 The WAIT Operation 356
9.8 The CLOSE Statement 356
9.8.1 The CLOSE Specifiers 357
9.9 The INQUIRE Statement 358
9.9.1 Inquire by File or Unit 358
9.9.2 Specifiers for Inquiry by Unit or File Name 360
9.9.3 Inquire by Output List 369
9.9.4 Table of Values Assigned by the INQUIRE Statement 369
9.10 File Positioning Statements 369
9.10.1 Specifiers for File Position Statements 372
9.10.2 The BACKSPACE Statement 372
9.10.3 The REWIND Statement 373
9.10.4 The ENDFILE Statement 373
9.11 The FLUSH Statement 374
9.11.1 Form of the FLUSH Statement 374
9.11.2 Specifiers for the FLUSH Statement 374
9.11.3 Execution of the FLUSH Statement 375
9.12 Restrictions on Input/Output Specifiers, List Items, and Statements 375
10 Input and Output Editing 379
10.1 Explicit Formatting 381
10.1.1 The FORMAT Statement 382
10.1.2 Character Expression Format Specifications 382
10.2 Format Specifications 383
10.2.1 Data Edit Descriptor Form 384
10.2.2 Control Edit Descriptor Form 385
10.2.3 Character String Edit Descriptor Form 386
10.3 Formatted Data Transfer 386
10.3.1 Parentheses Usage 387
10.3.2 Correspondence between a Data-Edit Descriptor and a List Item 388
10.4 File Positioning by Format Control 391
10.5 Numeric Editing 391
10.5.1 Integer Editing 392
10.5.2 Real Editing 395
10.5.2.1 F Editing 396
10.5.2.2 E, EN, ES, and D Editing 398
10.5.2.3 Generalized Editing of Real Data 400
10.5.2.4 IEEE Exceptional Values 402
10.5.3 Complex Editing 403
10.6 Logical Editing 404
10.7 Character Editing 405
10.8 Defined Editing 407
10.9 Control Edit Descriptors 407
10.9.1 Position Editing 407
10.9.2 Slash Editing 409
10.9.3 Colon Editing 410
10.9.4 Sign Editing 410
10.9.5 Scale Factors 411
10.9.6 Blanks in Numeric Fields 413
10.9.7 Round Edit Descriptors 414
10.9.8 Decimal Edit Descriptors 414
10.9.9 Character String Edit Descriptors 415
10.10 List-Directed Formatting 416
10.10.1 List-Directed Input 417
10.10.1.1 Value Separators 417
10.10.1.2 Values 417
10.10.1.3 Undelimited Character Strings 419
10.10.1.4 Null Values 420
10.10.1.5 Repeated Values 420
10.10.2 List-Directed Output 421
10.11 Namelist Formatting 423
10.11.1 Namelist Input 424
10.11.1.1 Names in Name=Value Pairs 424
10.11.1.2 Values in Name=Value Pairs 425
10.11.1.3 Separators 427
10.11.1.4 Namelist Comments 427
10.11.1.5 Blanks 428
10.11.1.6 Use of Namelist Input 428
10.11.2 Namelist Output 429
10.11.2.1 Form of Namelist Output 429
10.11.2.2 DELIM Specifier for Character Values 430
11 Program Units 431
11.1 Overview 431
11.1.1 The Specification Part 433
11.1.2 The Execution Part 433
11.1.3 The Subprogram Part 433
11.1.4 Example Program 433
11.2 Fortran Main Program 434
11.3 Modules 435
11.3.1 The Form of a Module 435
11.3.2 The Specification Part 436
11.3.3 Module Subprograms 437
11.3.4 Identifiers in a Module 437
11.3.5 Accessibility 438
11.3.6 The PROTECTED Attribute 438
11.3.7 The USE Statement 438
11.3.7.1 Form of the USE Statement 438
11.3.7.2 Accessing All Public Entities in a Module 439
11.3.7.3 Accessing Only Some of the Public Entities 440
11.3.7.4 Name Conflicts When Using Modules 441
11.3.8 Use Association 441
11.3.9 Typical Applications of Modules 442
11.3.9.1 Global Data 442
11.3.9.2 User-Defined Types 443
11.3.9.3 User-Defined Operators 444
11.3.9.4 Data Abstraction 444
11.3.9.5 Procedure Libraries 445
11.4 External Subprograms 446
11.5 Block Data Program Units 446
12 Using Procedures 449
12.1 Subroutines 450
12.1.1 Subroutine Subprograms 450
12.1.2 Subroutine References 452
12.2 Functions 454
12.2.1 Function Subprograms 454
12.2.2 Result Variable 456
12.2.3 Function References 457
12.2.4 Function Side Effects 458
12.3 RETURN Statement 459
12.4 Procedure Definition 460
12.4.1 External Procedures 460
12.4.2 Module Procedures 460
12.4.3 Internal Procedures 461
12.4.4 Statement Functions 461
12.4.5 Alternate Entries 464
12.5 Procedure Declaration 467
12.5.1 Implicit and Explicit Interfaces 468
12.5.1.1 Interface Properties 468
12.5.1.2 Where an Explicit Interface is Required 469
12.5.2 Interface Bodies 471
12.5.3 Specific Interface Blocks 473
12.5.4 Generic Interface Blocks 473
12.5.4.1 Generic Procedure Names 476
12.5.4.2 Defined Operations 479
12.5.4.3 Defined Assignments 481
12.5.4.4 Defined Input/Output 483
12.5.5 Abstract Interface Blocks 484
12.6 Argument Association 484
12.6.1 Argument Correspondence 486
12.6.2 Optional Arguments 488
12.6.3 Type and Type Parameters 490
12.6.4 Array Arguments 491
12.6.4.1 Sequence Association 491
12.6.4.2 Noncontiguous Arrays 494
12.6.5 Pointer Arguments 495
12.6.6 Target Arguments 496
12.6.7 Allocatable Arguments 498
12.6.8 Procedure Arguments 498
12.6.9 Alternate Returns 499
12.6.10 Argument Aliasing 500
12.7 Special Categories of Procedures 501
12.7.1 Pure Procedures 501
12.7.2 Elemental Procedures 503
12.7.3 Recursive Procedures 504
12.7.4 Procedure Pointers 504
12.8 Resolving Procedure References 505
12.8.1 Resolving Generic Name References 506
12.8.2 Resolving Specific Name References 507
12.9 Procedure Properties 508
13 Intrinsic Procedures and Modules 509
13.1 Properties of Intrinsic Procedures 510
13.2 Representation Models 512
13.2.1 The Bit Model 512
13.2.2 The Integer Number System Model 513
13.2.3 The Real Number System Model 513
13.3 Intrinsic Procedures 514
13.3.1 Inquiry Functions 515
13.3.1.1 Character and Bit Inquiry Functions 515
13.3.1.2 Kind Functions 515
13.3.1.3 Numeric Inquiry Functions 516
13.3.1.4 Array Inquiry Functions 516
13.3.1.5 Inquiry of Dynamic Properties 516
13.3.2 Numeric Manipulation Functions 517
13.3.3 Conversion Functions 517
13.3.3.1 NULL and Transfer Procedures 518
13.3.4 Computation Procedures 518
13.3.4.1 Numeric Computation Procedures 518
13.3.4.2 Character Computation Functions 520
13.3.4.3 Bit Computation Procedures 521
13.3.4.4 Array Functions 521
13.3.5 System Environment Procedures 523
13.3.5.1 Time and Date Subroutines 523
13.3.5.2 Testing Input/Output Status 523
13.3.5.3 Command Line Manipulation Procedures 523
13.4 Specific Names for Generic Intrinsic Procedures 524
13.5 Alphabetical List of All Intrinsic Procedures 526
13.6 Standard Intrinsic Modules 526
13.6.1 The Fortran Environment Module 531
14 IEEE Exceptions and Arithmetic 533
14.1 Terms and Concepts 534
14.2 IEEE Arithmetic and Exceptions-an Introduction 539
14.2.1 Floating-Point Formats 540
14.2.2 Floating-Point Exceptions 541
14.2.3 IEEE Arithmetic 544
14.2.4 Quiet and Signaling NaNs 545
14.2.5 The Programming Approach for the IEEE Standard 545
14.2.6 What If the Processor Is Not Compliant with the IEEE Standard? 545
14.2.7 The Processor’s Floating-Point Status 546
14.2.8 The Modes of the Floating-Point Processor 546
14.3 Descriptions of the Three Intrinsic Modules 546
14.3.1 The Intrinsic Module IEEE_FEATURES 548
14.3.2 The Intrinsic Module IEEE_EXCEPTIONS 550
14.3.2.1 Raising Exceptions from Operations Not To Be Executed 552
14.3.3 The Intrinsic Module IEEE_ARITHMETIC 553
14.3.3.1 Module Function IEEE_COPY_SIGN Versus Intrinsic Function SIGN 558
14.3.3.2 Module Function IEEE_LOGB Versus Intrinsic Function EXPONENT 558
14.3.3.3 Module Function IEEE_NEXT_AFTER Versus Intrinsic Function NEAREST 558
14.3.3.4 Module Function IEEE_REM Versus Intrinsic Functions MODULO or MOD 558
14.3.3.5 Module Function IEEE_RINT Versus Intrinsic Functions AINT or ANINT 559
14.3.3.6 Module Function IEEE_SCALB Versus Intrinsic Function SCALE 559
14.3.3.7 Module Function IEEE_SELECTED_REAL_KIND Versus Intrinsic Function SELECTED_REAL_KIND 559
14.3.3.8 Details of Returned Results for Module Function IEEE_CLASS 561
14.3.3.9 Details of Returned Results for Module Function IEEE_LOGB 561
14.3.3.10 Details of Returned Results for Module Function IEEE_NEXT_AFTER 562
14.3.3.11 Details of Returned Results for Module Function IEEE_SCALB 562
14.3.3.12 Details of Returned Results for Module Function IEEE_SELECTED_REAL_KIND 562
14.4 Initial and Final Status Requirements Entering and Leaving Any Procedure 563
14.5 Interoperability Issues for IEEE Arithmetic and Exceptions 565
14.6 A Summary of the Optional Features 565
14.7 Examples of the Use of IEEE Features, Arithmetic, and Exceptions Modules 568
14.7.1 Discussion of the Simple Example 569
14.7.2 Computing a Dot Product Carefully 570
15 Interoperability with C 573
15.1 Companion Processors 574
15.2 Binding Labels 574
15.3 The ISO_C_BINDING Intrinsic Module 575
15.4 Interoperability of Types 575
15.4.1 Intrinsic Types 576
15.4.2 C Enum Types 576
15.4.3 C Pointer Types 577
15.4.4 Derived Types 578
15.5 Interoperation of Data 579
15.5.1 Scalar Variables 580
15.5.2 Array Variables 580
15.5.3 Character Data 581
15.5.4 Pointers 581
C_LOC (X) Inquiry Function 582
C_FUNLOC (X) Inquiry Function 583
C_F_POINTER (CPTR, FPTR [, SHAPE]) Subroutine 583
C_F_PROCPOINTER (CPTR, FPTR) Subroutine 583
C_ASSOCIATED (C_PTR_1 [, C_PTR_2]) Inquiry Function 583
15.5.5 Global Data 584
15.6 Interoperation of Procedures 585
15.6.1 Interoperable Fortran Procedures and Interfaces 585
15.6.2 Interoperability of Fortran Interfaces and C Prototypes 586
15.6.3 Interoperable C Functions 587
15.6.4 Restrictions on C Functions 587
15.6.5 Connecting Fortran Procedures and C Functions 589
15.7 Examples of Interoperation 589
16 Scope, Association, and Definition 593
16.1 Scope 593
16.1.1 Global Identifiers 594
16.1.2 Local Identifiers 595
16.1.2.1 Classes of Local Identifiers 597
16.1.2.2 Resolution of Generic Identifiers 598
16.1.3 Statement and Construct Identifiers 599
16.2 Association 600
16.2.1 Name Association 600
16.2.1.1 Argument Association 601
16.2.1.2 Use Association 601
16.2.1.3 Host Association 601
16.2.1.4 Linkage Association 604
16.2.1.5 Construct Association 604
16.2.2 Pointer Association 605
16.2.2.1 Pointer Association Status 605
16.2.2.2 Pointer Definition Status 607
16.2.3 Storage Association 607
16.2.3.1 Storage Sequence 607
16.2.3.2 Association of Storage Sequences 608
16.2.3.3 Examples of Storage Association 609
16.2.4 Inheritance Association 610
16.2.5 Establishing Associations 610
16.3 Definition 611
16.3.1 Variable Definition Contexts 611
16.3.2 Events that Cause Variables to Become Defined 612
16.3.3 Events that Cause Variables to Become Undefined 614
A Standard Intrinsic Procedures 617
ABS (A) Elemental Function 618
ACHAR (I {, KIND}) Elemental Function 618
ACOS (X) Elemental Function 619
ADJUSTL (STRING) Elemental Function 619
ADJUSTR (STRING) Elemental Function 619
AIMAG (Z) Elemental Function 619
AINT (A {, KIND}) Elemental Function 620
ALL (MASK {, DIM}) Transformational Function 620
ALLOCATED (ARRAY) or ALLOCATED (SCALAR) Inquiry Function 620
ANINT (A {, KIND}) Elemental Function 621
ANY (MASK {, DIM}) Transformational Function 621
ASIN (X) Elemental Function 621
ASSOCIATED (POINTER{, TARGET}) Inquiry Function 622
ATAN (X) Elemental Function 623
ATAN2 (Y, X) Elemental Function 624
BIT_SIZE (I) Inquiry Function 624
BTEST (I, POS) Elemental Function 624
CEILING (A {, KIND}) Elemental Function 625
CHAR (I {, KIND}) Elemental Function 625
CMPLX (X {, Y, KIND}) Elemental Function 625
COMMAND_ARGUMENT_COUNT () Inquiry Function 626
CONJG (Z) Elemental Function 626
COS (X) Elemental Function 627
COSH (X) Elemental Function 627
COUNT (MASK {, DIM, KIND}) Transformational Function 627
CPU_TIME (TIME) Subroutine 628
CSHIFT (ARRAY, SHIFT {, DIM}) Transformational Function 628
DATE_AND_TIME ({DATE, TIME, ZONE, VALUES}) Subroutine 629
DBLE (A) Elemental Function 630
DIGITS (X) Inquiry Function 631
DIM (X, Y) Elemental Function 631
DOT_PRODUCT (VECTOR_A, VECTOR_B) Transformational Function 631
DPROD (X, Y) Elemental Function 632
EOSHIFT (ARRAY, SHIFT {, BOUNDARY, DIM}) Transformational Function 632
EPSILON (X) Inquiry Function 633
EXP (X) Elemental Function 633
EXPONENT (X) Elemental Function 633
EXTENDS_TYPE_OF (A, MOLD) Inquiry Function 634
FLOOR (A {, KIND}) Elemental Function 634
FRACTION (X) Elemental Function 635
GET_COMMAND ({COMMAND, LENGTH, STATUS}) Subroutine 635
GET_COMMAND_ARGUMENT Subroutine (NUMBER {, VALUE, LENGTH, STATUS}) 636
GET_ENVIRONMENT_VARIABLE Subroutine (NAME {, VALUE, LENGTH, STATUS, TRIM_NAME}) 637
HUGE (X) Inquiry Function 638
IACHAR (C {, KIND}) Elemental Function 638
IAND (I, J) Elemental Function 639
IBCLR (I, POS) Elemental Function 639
IBITS (I, POS, LEN) Elemental Function 639
IBSET (I, POS) Elemental Function 640
ICHAR (C {, KIND}) Elemental Function 640
IEOR (I, J) Elemental Function 640
INDEX (STRING, SUBSTRING {, BACK, KIND}) Elemental Function 641
INT (A {, KIND}) Elemental Function 641
IOR (I, J) Elemental Function 642
ISHFT (I, SHIFT) Elemental Function 642
ISHFTC (I, SHIFT {, SIZE}) Elemental Function 643
IS_IOSTAT_END (I) Elemental Function 643
IS_IOSTAT _EOR (I) Elemental Function 643
KIND (X) Inquiry Function 643
LBOUND (ARRAY {, DIM, KIND}) Inquiry Function 644
LEN (STRING {, KIND}) Inquiry Function 644
LEN_TRIM (STRING {, KIND}) Elemental Function 645
LGE (STRING_A, STRING_B) Elemental Function 645
LGT (STRING_A, STRING_B) Elemental Function 645
LLE (STRING_A, STRING_B) Elemental Function 646
LLT (STRING_A, STRING_B) Elemental Function 646
LOG (X) Elemental Function 646
LOG10 (X) Elemental Function 647
LOGICAL (L {, KIND}) Elemental Function 647
MATMUL (MATRIX_A, MATRIX_B) Transformational Function 647
MAX (A1, A2 {A3, ... }) Elemental Function 648
MAXEXPONENT (X) Inquiry Function 649
MAXLOC (ARRAY, DIM {, MASK, KIND}) or Transformational Function MAXLOC (ARRAY {, MASK, KIND}) 649
MAXVAL (ARRAY, DIM {, MASK}) or Transformational Function MAXVAL (ARRAY {, MASK}) 650
MERGE (TSOURCE, FSOURCE, MASK) Elemental Function 651
MIN (A1, A2 {A3, ... }) Elemental Function 651
MINEXPONENT (X) Inquiry Function 652
MINLOC (ARRAY, DIM {, MASK, KIND}) or Transformational Function MINLOC (ARRAY {, MASK, KIND}) 652
MINVAL (ARRAY, DIM {, MASK}) or Transformational Function MINVAL (ARRAY {, MASK}) 654
MOD (A, P) Elemental Function 654
MODULO (A, P) Elemental Function 655
MOVE_ALLOC (FROM, TO) Pure Intrinsic Subroutine 655
MVBITS (FROM, FROMPOS, LEN, TO, TOPOS) Elemental Subroutine 656
NEAREST (X, S) Elemental Function 656
NEW_LINE (A) Inquiry Function 657
NINT (A {, KIND}) Elemental Function 657
NOT (I) Elemental Function 658
NULL ({MOLD}) Transformational Function 658
PACK (ARRAY, MASK {, VECTOR}) Transformational Function 659
PRECISION (X) Inquiry Function 660
PRESENT (A) Inquiry Function 660
PRODUCT (ARRAY, DIM {, MASK}) or Transformational Function PRODUCT (ARRAY {, MASK}) 661
RADIX (X) Inquiry Function 661
RANDOM_NUMBER (HARVEST) Subroutine 662
RANDOM_SEED ({SIZE, PUT, GET}) Subroutine 662
RANGE (X) Inquiry Function 663
REAL (A {, KIND}) Elemental Function 663
REPEAT (STRING, NCOPIES) Transformational Function 664
RESHAPE (SOURCE, SHAPE {, PAD, ORDER}) Transformational Function 664
RRSPACING (X) Elemental Function 665
SAME_TYPE_AS (A, B) Inquiry Function 665
SCALE (X, I) Elemental Function 666
SCAN (STRING, SET {, BACK, KIND}) Elemental Function 666
SELECTED_CHAR_KIND (NAME) Transformational Function 666
SELECTED_INT_KIND (R) Transformational Function 667
SELECTED_REAL_KIND ({P, R}) Transformational Function 667
SET_EXPONENT (X, I) Elemental Function 668
SHAPE (SOURCE [, KIND]) Inquiry Function 669
SIGN (A, B) Elemental Function 669
SIN (X) Elemental Function 669
SINH (X) Elemental Function 670
SIZE (ARRAY {, DIM, KIND}) Inquiry Function 670
SPACING (X) Elemental Function 671
SPREAD (SOURCE, DIM, NCOPIES) Transformational Function 671
SQRT (X) Elemental Function 671
SUM (ARRAY, DIM {, MASK}) or Transformational Function SUM (ARRAY {, MASK}) 672
SYSTEM_CLOCK ({COUNT, COUNT_RATE, COUNT_MAX}) Subroutine 672
TAN (X) Elemental Function 673
TANH (X) Elemental Function 673
TINY (X) Inquiry Function 674
TRANSFER (SOURCE, MOLD [, SIZE]) Transformational Function 674
TRANSPOSE (MATRIX) Transformational Function 675
TRIM (STRING) Transformational Function 675
UBOUND (ARRAY {, DIM, KIND}) Inquiry Function 675
UNPACK (VECTOR, MASK, FIELD) Transformational Function 676
VERIFY (STRING, SET {, BACK, KIND}) Elemental Function 676
B IEEE Module Procedures 679
IEEE_CLASS (X) Elemental Function 679
IEEE_COPY_SIGN (X, Y) Elemental Function 680
IEEE_GET_FLAG (FLAG, FLAG_VALUE) Elemental Subroutine 680
IEEE_GET_HALTING_MODE (FLAG, HALTING) Elemental Subroutine 681
IEEE_GET_ROUNDING_MODE (ROUND_VALUE) Subroutine 682
IEEE_GET_STATUS (STATUS_VALUE) Subroutine 682
IEEE_GET_UNDERFLOW_MODE (GRADUAL) Subroutine 683
IEEE_IS_FINITE (X) Elemental Function 683
IEEE_IS_NAN (X) Elemental Function 683
IEEE_IS_NEGATIVE (X) Elemental Function 684
IEEE_IS_NORMAL (X) Elemental Function 684
IEEE_LOGB (X) Elemental Function 684
IEEE_NEXT_AFTER (X, Y) Elemental Function 685
IEEE_REM (X, Y) Elemental Function 685
IEEE_RINT (X) Elemental Function 685
IEEE_SCALB (X, I) Elemental Function 686
IEEE_SELECTED_REAL_KIND ({P, R}) Transformational Function 686
IEEE_SET_FLAG (FLAG, FLAG_VALUE) Pure Subroutine 687
IEEE_SET_HALTING_MODE (FLAG, HALTING) Pure Subroutine 687
IEEE_SET_ROUNDING_MODE (ROUND_VALUE) Subroutine 688
IEEE_SET_STATUS (STATUS_VALUE) Subroutine 688
IEEE_SET_UNDERFLOW_MODE (GRADUAL) Subroutine 689
IEEE_SUPPORT_DATATYPE ( ) or Inquiry Function IEEE_SUPPORT_DATATYPE (X) 689
IEEE_SUPPORT_DENORMAL ( ) or Inquiry Function IEEE_SUPPORT_DENORMAL (X) 689
IEEE_SUPPORT_DIVIDE ( ) or IEEE_SUPPORT_DIVIDE (X) Inquiry Function 690
IEEE_SUPPORT_FLAG (FLAG) or Inquiry Function IEEE_SUPPORT_FLAG (FLAG, X) 690
IEEE_SUPPORT_HALTING (FLAG) Inquiry Function 690
IEEE_SUPPORT_INF ( ) or IEEE_SUPPORT_INF (X) Inquiry Function 691
IEEE_SUPPORT_IO ( ) or IEEE_SUPPORT_IO (X) Inquiry Function 691
IEEE_SUPPORT_NAN ( ) or IEEE_SUPPORT_NAN (X) Inquiry Function 691
IEEE_SUPPORT_ROUNDING (ROUND_VALUE) or Inquiry Function IEEE_SUPPORT_ROUNDING (ROUND_VALUE, X) 692
IEEE_SUPPORT_SQRT ( ) or IEEE_SUPPORT_SQRT (X) Inquiry Function 692
IEEE_SUPPORT_STANDARD ( ) or Inquiry Function IEEE_SUPPORT_STANDARD (X) 692
IEEE_SUPPORT_UNDERFLOW_CONTROL ( ) or Inquiry Function IEEE_SUPPORT_UNDERFLOW_CONTROL (X) 693
IEEE_UNORDERED (X, Y) Elemental Function 693
‘IEEE_VALUE (X, CLASS) Elemental Function 694
C Language Evolution 695
C.1 New Features 695
C.2 Obsolescent Features 696
C.3 Deleted Features 697
C.4 Other Compatibility Issues 698
Index of Examples 699
Index 703
Erscheint lt. Verlag | 18.9.2008 |
---|---|
Zusatzinfo | XII, 713 p. |
Verlagsort | London |
Sprache | englisch |
Themenwelt | Mathematik / Informatik ► Informatik ► Programmiersprachen / -werkzeuge |
Mathematik / Informatik ► Informatik ► Software Entwicklung | |
Informatik ► Theorie / Studium ► Künstliche Intelligenz / Robotik | |
Naturwissenschaften ► Chemie | |
Naturwissenschaften ► Physik / Astronomie | |
Technik | |
Schlagworte | array processing • C interoperability • Compiler • Control • C programming language • Development • Evolution • Exception • Floating-point arithmetic • FORTRAN • FORTRAN 2003 • IEEE arithmetic • language • numerical computing • object-oriented programming • Parallel Computation • Processing • programming • Programming language • Programming Languages • Scientific Computing • Software • Standards • structured analysis |
ISBN-10 | 1-84628-746-4 / 1846287464 |
ISBN-13 | 978-1-84628-746-6 / 9781846287466 |
Haben Sie eine Frage zum Produkt? |
Größe: 61,4 MB
DRM: Digitales Wasserzeichen
Dieses eBook enthält ein digitales Wasserzeichen und ist damit für Sie personalisiert. Bei einer missbräuchlichen Weitergabe des eBooks an Dritte ist eine Rückverfolgung an die Quelle möglich.
Dateiformat: PDF (Portable Document Format)
Mit einem festen Seitenlayout eignet sich die PDF besonders für Fachbücher mit Spalten, Tabellen und Abbildungen. Eine PDF kann auf fast allen Geräten angezeigt werden, ist aber für kleine Displays (Smartphone, eReader) nur eingeschränkt geeignet.
Systemvoraussetzungen:
PC/Mac: Mit einem PC oder Mac können Sie dieses eBook lesen. Sie benötigen dafür einen PDF-Viewer - z.B. den Adobe Reader oder Adobe Digital Editions.
eReader: Dieses eBook kann mit (fast) allen eBook-Readern gelesen werden. Mit dem amazon-Kindle ist es aber nicht kompatibel.
Smartphone/Tablet: Egal ob Apple oder Android, dieses eBook können Sie lesen. Sie benötigen dafür einen PDF-Viewer - z.B. die kostenlose Adobe Digital Editions-App.
Buying eBooks from abroad
For tax law reasons we can sell eBooks just within Germany and Switzerland. Regrettably we cannot fulfill eBook-orders from other countries.
aus dem Bereich