· 2019. 3. 19. · p ar tial_dcbt .......... . 552 prefetch_by_load ........ . 553...

1106
IBM XL Fortran for AIX, V15.1.3 Language Reference Version 15.1.3 SC27-4245-02 IBM

Upload: others

Post on 09-Feb-2021

8 views

Category:

Documents


0 download

TRANSCRIPT

  • IBM XL Fortran for AIX, V15.1.3

    Language ReferenceVersion 15.1.3

    SC27-4245-02

    IBM

  • IBM XL Fortran for AIX, V15.1.3

    Language ReferenceVersion 15.1.3

    SC27-4245-02

    IBM

  • NoteBefore using this information and the product it supports, read the information in “Notices” on page 1045.

    First edition

    This edition applies to IBM XL Fortran for AIX, V15.1.3 (Program 5765-J09; 5725-C74) and to all subsequent releasesand modifications until otherwise indicated in new editions. Make sure you are using the correct edition for thelevel of the product.

    © Copyright IBM Corporation 1996, 2015.US Government Users Restricted Rights – Use, duplication or disclosure restricted by GSA ADP Schedule Contractwith IBM Corp.

  • Contents

    About this document . . . . . . . . xiiiWho should read this document . . . . . . . xiiiHow to use this document . . . . . . . . . xiiiHow this document is organized . . . . . . . xiiiConventions . . . . . . . . . . . . . . xivRelated information . . . . . . . . . . . xviii

    IBM XL Fortran information . . . . . . . xviiiStandards and specifications . . . . . . . xixOther IBM information . . . . . . . . . xx

    Technical support . . . . . . . . . . . . xxHow to send your comments . . . . . . . . xx

    Chapter 1. XL Fortran for AIX . . . . . 1Fortran language standards . . . . . . . . . 1

    Technical specification 29113 . . . . . . . . 1Fortran 2008 . . . . . . . . . . . . . 1Fortran 2003 . . . . . . . . . . . . . 4Fortran 95 . . . . . . . . . . . . . . 4Fortran 90 . . . . . . . . . . . . . . 5FORTRAN 77 . . . . . . . . . . . . . 5IBM extensions . . . . . . . . . . . . 5

    OpenMP API Version 4.0 . . . . . . . . . . 5Standards documents . . . . . . . . . . . 6

    Chapter 2. XL Fortran languagefundamentals . . . . . . . . . . . . 7Characters . . . . . . . . . . . . . . . 7Names . . . . . . . . . . . . . . . . 8Designators . . . . . . . . . . . . . . . 8Operators . . . . . . . . . . . . . . . 9Statements . . . . . . . . . . . . . . . 9

    Statement keywords . . . . . . . . . . . 9Statement labels . . . . . . . . . . . . 9

    Delimiters . . . . . . . . . . . . . . . 9Lines and source formats . . . . . . . . . . 10

    Fixed source form . . . . . . . . . . . 11Free source form . . . . . . . . . . . 13IBM free source form (IBM extension) . . . . 14Conditional compilation (IBM extension) . . . 15

    Order of statements and execution sequence . . . 16Data types. . . . . . . . . . . . . . . 17

    Type declaration: type parameters and specifiers 17Determining Type . . . . . . . . . . . 19

    Data objects . . . . . . . . . . . . . . 19Constants . . . . . . . . . . . . . . 19Automatic objects . . . . . . . . . . . 20Polymorphic entities (Fortran 2003) . . . . . 20Definition status of variables . . . . . . . 21Allocation status. . . . . . . . . . . . 28Storage classes for variables (IBM extension) . . 28

    Typeless literal constants . . . . . . . . . . 30Hexadecimal constants . . . . . . . . . 31Octal constants . . . . . . . . . . . . 31Binary constants . . . . . . . . . . . . 32Hollerith constants . . . . . . . . . . . 32

    Using typeless constants . . . . . . . . . 33

    Chapter 3. Intrinsic data types . . . . 37Integer . . . . . . . . . . . . . . . . 37Real . . . . . . . . . . . . . . . . . 38Complex . . . . . . . . . . . . . . . 41Logical . . . . . . . . . . . . . . . . 43Character . . . . . . . . . . . . . . . 44

    Examples of character constants . . . . . . 45Character substrings . . . . . . . . . . 46

    Byte (IBM extension) . . . . . . . . . . . 47Vector (IBM extension). . . . . . . . . . . 47Pixel (IBM extension) . . . . . . . . . . . 48Unsigned (IBM extension) . . . . . . . . . 48

    Chapter 4. Derived types . . . . . . . 49Syntax of a derived type . . . . . . . . . . 49Derived type parameters (Fortran 2003) . . . . . 50Derived type components . . . . . . . . . 51

    Allocatable and pointer components . . . . . 52Procedure pointer components . . . . . . . 53Array components . . . . . . . . . . . 54Default initialization for components . . . . . 54Component order . . . . . . . . . . . 56Referencing components . . . . . . . . . 56

    Component and procedure accessibility . . . . . 58Sequence derived types . . . . . . . . . . 58Extensible derived types (Fortran 2003) . . . . . 58Abstract types and deferred bindings (Fortran 2003) 60Derived type values . . . . . . . . . . . 60Type-bound procedures (Fortran 2003) . . . . . 60

    Syntax of a type-bound procedure . . . . . . 61Specific binding . . . . . . . . . . . . 61Generic binding . . . . . . . . . . . . 63Final binding . . . . . . . . . . . . . 65Procedure overriding . . . . . . . . . . 67

    Finalization (Fortran 2003) . . . . . . . . . 68The finalization process . . . . . . . . . 68When finalization occurs . . . . . . . . . 69

    Determining declared type for derived types . . . 70Structure constructor . . . . . . . . . . . 71

    Chapter 5. Array concepts . . . . . . 75Array basics . . . . . . . . . . . . . . 75

    Bounds of a dimension . . . . . . . . . 75Extent of a dimension . . . . . . . . . . 76Rank, shape, and size of an array . . . . . . 76

    Array declarators . . . . . . . . . . . . 76Explicit-shape arrays . . . . . . . . . . . 77

    Automatic arrays . . . . . . . . . . . 78Adjustable arrays . . . . . . . . . . . 79Pointee arrays (IBM extension) . . . . . . . 79

    Assumed-shape arrays. . . . . . . . . . . 80Deferred-shape arrays . . . . . . . . . . . 81

    Allocatable arrays . . . . . . . . . . . 82

    © Copyright IBM Corp. 1996, 2015 iii

  • Array pointers . . . . . . . . . . . . 83Implied-shape arrays (Fortran 2008) . . . . . . 83Assumed-size arrays . . . . . . . . . . . 84Assumed-rank objects (TS 29113) . . . . . . . 86Array elements . . . . . . . . . . . . . 87Array sections . . . . . . . . . . . . . 88

    Subscript triplets . . . . . . . . . . . 90Vector subscripts . . . . . . . . . . . 92Substring ranges. . . . . . . . . . . . 92Array sections and structure components . . . 92Rank and shape of array sections . . . . . . 94

    Array constructors . . . . . . . . . . . . 94Implied-DO list for an array constructor . . . . 97

    Contiguity (Fortran 2008) . . . . . . . . . . 98Expressions involving arrays . . . . . . . . 100

    Chapter 6. Expressions andassignment . . . . . . . . . . . . 101Introduction to expressions and assignment . . . 101

    Primary . . . . . . . . . . . . . . 101Constant expressions . . . . . . . . . . . 102Specification expressions . . . . . . . . . 103Operators and expressions . . . . . . . . . 105

    Arithmetic . . . . . . . . . . . . . 105Character. . . . . . . . . . . . . . 108General . . . . . . . . . . . . . . 108Logical . . . . . . . . . . . . . . 109Primary . . . . . . . . . . . . . . 111Relational . . . . . . . . . . . . . 112

    Extended intrinsic and defined operations . . . . 113How expressions are evaluated . . . . . . . 114

    Precedence of operators . . . . . . . . . 114Using BYTE data objects (IBM extension) . . . 116

    Intrinsic assignment . . . . . . . . . . . 117Arithmetic conversion . . . . . . . . . 119

    WHERE construct . . . . . . . . . . . . 121Interpreting masked array assignments . . . . 123

    FORALL construct. . . . . . . . . . . . 127Interpreting the FORALL construct . . . . . 128

    Data pointer assignment. . . . . . . . . . 130Procedure pointer assignment (Fortran 2003) . . . 133Integer pointer assignment (IBM extension) . . . 134

    Chapter 7. Execution control . . . . . 135Statement blocks . . . . . . . . . . . . 135ASSOCIATE Construct (Fortran 2003) . . . . . 135BLOCK construct (Fortran 2008) . . . . . . . 136DO construct . . . . . . . . . . . . . 138

    The terminal statement . . . . . . . . . 139DO CONCURRENT construct (Fortran 2008) 142DO WHILE construct. . . . . . . . . . 142

    IF construct . . . . . . . . . . . . . . 143CASE construct. . . . . . . . . . . . . 145SELECT TYPE construct (Fortran 2003) . . . . . 147Associate names . . . . . . . . . . . . 149Branching . . . . . . . . . . . . . . 149CONTINUE statement . . . . . . . . . . 150STOP statement . . . . . . . . . . . . 150ERROR STOP statement (Fortran 2008) . . . . . 150

    Chapter 8. Program units andprocedures . . . . . . . . . . . . 151Scope . . . . . . . . . . . . . . . . 151

    Scoping unit. . . . . . . . . . . . . 151Entities with scope . . . . . . . . . . 151

    Association . . . . . . . . . . . . . . 156Host association . . . . . . . . . . . 156Use association . . . . . . . . . . . . 158Construct Association . . . . . . . . . 158Pointer association . . . . . . . . . . 159Integer pointer association (IBM extension) . . 160

    Program units, procedures, and subprograms. . . 161Internal procedures . . . . . . . . . . 161Interface concepts . . . . . . . . . . . 162

    Interface blocks. . . . . . . . . . . . . 164Generic interface blocks . . . . . . . . . . 167

    Unambiguous generic procedure references . . 167Extending intrinsic procedures with genericinterface blocks . . . . . . . . . . . . 169Defined operators . . . . . . . . . . . 170Defined assignment . . . . . . . . . . 171User-defined derived-type Input/Outputprocedures (Fortran 2003) . . . . . . . . 172

    Abstract interface (Fortran 2003) . . . . . . . 174Main program . . . . . . . . . . . . . 176Modules . . . . . . . . . . . . . . . 177Submodules (Fortran 2008) . . . . . . . . . 180Module subprograms. . . . . . . . . . . 183

    Function and subroutine subprograms . . . . 183Separate module subprograms (Fortran 2008) 188

    Block data program unit. . . . . . . . . . 190Intrinsic procedures . . . . . . . . . . . 191

    Conflicts between intrinsic procedure namesand other names . . . . . . . . . . . 191

    Arguments . . . . . . . . . . . . . . 192Actual argument specification . . . . . . . 192

    Argument association . . . . . . . . . . 194%VAL and %REF (IBM extension) . . . . . 196Intent of dummy arguments . . . . . . . 197Optional dummy arguments . . . . . . . 197The passed-object dummy argument . . . . 198Restrictions on optional dummy arguments notpresent . . . . . . . . . . . . . . 198Length of character arguments . . . . . . 199Variables as dummy arguments . . . . . . 199Allocatable objects as dummy arguments(Fortran 2003) . . . . . . . . . . . . 202Pointers as dummy arguments . . . . . . 203Procedures as dummy arguments . . . . . 204Asterisks as dummy arguments . . . . . . 205

    Resolution of procedure references . . . . . . 205Rules for resolving procedure references tonames . . . . . . . . . . . . . . . 206

    Recursion . . . . . . . . . . . . . . 207Pure procedures . . . . . . . . . . . . 208Elemental procedures. . . . . . . . . . . 210

    Chapter 9. XL Fortran Input/Output 213Records . . . . . . . . . . . . . . . 213

    Formatted records . . . . . . . . . . . 213

    iv XL Fortran: Language Reference

  • Unformatted records . . . . . . . . . . 214Endfile records . . . . . . . . . . . . 214

    Files . . . . . . . . . . . . . . . . 214Definition of an external file . . . . . . . 214File access methods . . . . . . . . . . 215

    Units . . . . . . . . . . . . . . . . 216Connection of a unit . . . . . . . . . . 217

    Data transfer statements . . . . . . . . . . 218Asynchronous Input/Output . . . . . . . 219Advancing and nonadvancing Input/Output 220User-defined derived-type Input/Outputprocedure interfaces (Fortran 2003) . . . . . 221User-defined derived-type Input/Output(Fortran 2003) . . . . . . . . . . . . 221File position before and after data transfer. . . 223

    Conditions and IOSTAT values . . . . . . . 225End-of-record conditions . . . . . . . . 225End-of-file conditions. . . . . . . . . . 225Error conditions . . . . . . . . . . . 226

    Chapter 10. Input/Output formatting 237Format-directed formatting . . . . . . . . . 237

    Complex editing . . . . . . . . . . . 237Data edit descriptors . . . . . . . . . . 237Control edit descriptors . . . . . . . . . 242Character string edit descriptors . . . . . . 243Effective list items (Fortran 2003) . . . . . . 244Interaction of Input/Output lists and formatspecifications . . . . . . . . . . . . 244Comma-separated Input/Output (IBMextension) . . . . . . . . . . . . . 246

    Data edit descriptors . . . . . . . . . . . 247A (Character) Editing. . . . . . . . . . 247B (Binary) Editing . . . . . . . . . . . 247E, D, and Q (Extended Precision) Editing . . . 249DT Editing (Fortran 2003) . . . . . . . . 250EN Editing . . . . . . . . . . . . . 251ES Editing . . . . . . . . . . . . . 252F (Real without Exponent) Editing . . . . . 253G (General) Editing . . . . . . . . . . 254H Editing . . . . . . . . . . . . . 256I (Integer) Editing . . . . . . . . . . . 257L (Logical) Editing. . . . . . . . . . . 258O (Octal) Editing . . . . . . . . . . . 259Q (Character Count) Editing (IBM extension) 260Z (Hexadecimal) Editing . . . . . . . . 261

    Control edit descriptors . . . . . . . . . . 263/ (Slash) Editing . . . . . . . . . . . 263: (Colon) Editing . . . . . . . . . . . 263$ (Dollar) Editing (IBM extension) . . . . . 264BN (Blank Null) and BZ (Blank Zero) Editing 264DC and DP (Decimal) Editing (Fortran 2003) 265P (Scale Factor) Editing . . . . . . . . . 265RC, RD, RN, RP, RU, and RZ (Round) Editing(Fortran 2003) . . . . . . . . . . . . 266S, SP, and SS (Sign Control) Editing . . . . . 267T, TL, TR, and X (Positional) Editing . . . . 267

    List-directed formatting . . . . . . . . . . 269Value separators . . . . . . . . . . . 269List-directed input. . . . . . . . . . . 269List-directed output . . . . . . . . . . 270

    Namelist formatting . . . . . . . . . . . 272Namelist input . . . . . . . . . . . . 273Namelist output . . . . . . . . . . . 277

    Chapter 11. Statements and attributes 281Attributes . . . . . . . . . . . . . . 284ABSTRACT (Fortran 2003) . . . . . . . . . 285ALLOCATABLE (Fortran 2003) . . . . . . . 285ALLOCATE . . . . . . . . . . . . . . 287ASSIGN . . . . . . . . . . . . . . . 290ASSOCIATE (Fortran 2003) . . . . . . . . . 292ASYNCHRONOUS . . . . . . . . . . . 293AUTOMATIC (IBM extension). . . . . . . . 295BACKSPACE . . . . . . . . . . . . . 296BIND (Fortran 2003) . . . . . . . . . . . 298BLOCK (Fortran 2008) . . . . . . . . . . 299BLOCK DATA . . . . . . . . . . . . . 299BYTE (IBM extension) . . . . . . . . . . 300CALL . . . . . . . . . . . . . . . . 303CASE . . . . . . . . . . . . . . . . 305CHARACTER . . . . . . . . . . . . . 307CLASS (Fortran 2003) . . . . . . . . . . 312CLOSE . . . . . . . . . . . . . . . 313COMMON . . . . . . . . . . . . . . 315

    Common association . . . . . . . . . . 317COMPLEX . . . . . . . . . . . . . . 319CONTAINS . . . . . . . . . . . . . . 322CONTIGUOUS (Fortran 2008) . . . . . . . . 323CONTINUE . . . . . . . . . . . . . . 326CYCLE . . . . . . . . . . . . . . . 326DATA . . . . . . . . . . . . . . . . 327DEALLOCATE . . . . . . . . . . . . . 331Derived Type . . . . . . . . . . . . . 333DIMENSION . . . . . . . . . . . . . 335DO . . . . . . . . . . . . . . . . . 336DO CONCURRENT (Fortran 2008) . . . . . . 338DO WHILE . . . . . . . . . . . . . . 340DOUBLE COMPLEX (IBM extension) . . . . . 342DOUBLE PRECISION . . . . . . . . . . 344ELSE . . . . . . . . . . . . . . . . 347ELSE IF . . . . . . . . . . . . . . . 348ELSEWHERE . . . . . . . . . . . . . 349END . . . . . . . . . . . . . . . . 350END (Construct) . . . . . . . . . . . . 351END INTERFACE . . . . . . . . . . . . 354END TYPE . . . . . . . . . . . . . . 356ENDFILE. . . . . . . . . . . . . . . 356ENTRY . . . . . . . . . . . . . . . 358ENUM/END ENUM (Fortran 2003) . . . . . . 361EQUIVALENCE . . . . . . . . . . . . 363ERROR STOP (Fortran 2008) . . . . . . . . 365EXIT . . . . . . . . . . . . . . . . 367EXTERNAL . . . . . . . . . . . . . . 369FLUSH (Fortran 2003) . . . . . . . . . . 370FORALL . . . . . . . . . . . . . . . 372

    Interpreting the FORALL statement . . . . . 374Loop parallelization . . . . . . . . . . 375

    FORALL (Construct) . . . . . . . . . . . 376FORMAT . . . . . . . . . . . . . . . 378

    Character format specification . . . . . . . 379FUNCTION . . . . . . . . . . . . . . 380

    Contents v

  • Recursion . . . . . . . . . . . . . 384Elemental procedures. . . . . . . . . . 384

    GO TO (assigned) . . . . . . . . . . . . 384GO TO (computed) . . . . . . . . . . . 385GO TO (unconditional) . . . . . . . . . . 386IF (arithmetic) . . . . . . . . . . . . . 387IF (block) . . . . . . . . . . . . . . . 388IF (logical) . . . . . . . . . . . . . . 389IMPLICIT . . . . . . . . . . . . . . 389IMPORT (Fortran 2003) . . . . . . . . . . 392INQUIRE. . . . . . . . . . . . . . . 393INTEGER . . . . . . . . . . . . . . 401INTENT . . . . . . . . . . . . . . . 404INTERFACE. . . . . . . . . . . . . . 406INTRINSIC . . . . . . . . . . . . . . 409LOGICAL . . . . . . . . . . . . . . 410MODULE . . . . . . . . . . . . . . 413MODULE PROCEDURE (Fortran 2008). . . . . 414NAMELIST . . . . . . . . . . . . . . 415NULLIFY. . . . . . . . . . . . . . . 416OPEN . . . . . . . . . . . . . . . . 417OPTIONAL . . . . . . . . . . . . . . 424PARAMETER . . . . . . . . . . . . . 426PAUSE . . . . . . . . . . . . . . . 427POINTER (Fortran 90) . . . . . . . . . . 427POINTER (integer) (IBM extension) . . . . . . 429PRINT. . . . . . . . . . . . . . . . 431

    Implied-DO List . . . . . . . . . . . 432PRIVATE . . . . . . . . . . . . . . . 433PROCEDURE . . . . . . . . . . . . . 435PROCEDURE declaration (Fortran 2003) . . . . 436PROGRAM . . . . . . . . . . . . . . 438PROTECTED (Fortran 2003) . . . . . . . . 439PUBLIC . . . . . . . . . . . . . . . 441READ . . . . . . . . . . . . . . . . 442

    Implied-DO List . . . . . . . . . . . 449REAL . . . . . . . . . . . . . . . . 450RECORD (IBM extension) . . . . . . . . . 454RETURN . . . . . . . . . . . . . . . 455REWIND . . . . . . . . . . . . . . . 456SAVE . . . . . . . . . . . . . . . . 458SELECT CASE . . . . . . . . . . . . . 460SELECT TYPE (Fortran 2003) . . . . . . . . 461SEQUENCE . . . . . . . . . . . . . . 461Statement Function . . . . . . . . . . . 462STATIC (IBM extension) . . . . . . . . . . 464STOP . . . . . . . . . . . . . . . . 465SUBMODULE (Fortran 2008) . . . . . . . . 467SUBROUTINE . . . . . . . . . . . . . 469TARGET . . . . . . . . . . . . . . . 472TYPE . . . . . . . . . . . . . . . . 473Type Declaration . . . . . . . . . . . . 477Type Guard (Fortran 2003) . . . . . . . . . 484USE . . . . . . . . . . . . . . . . 485VALUE (Fortran 2003) . . . . . . . . . . 488VECTOR (IBM extension) . . . . . . . . . 490VIRTUAL (IBM extension) . . . . . . . . . 490VOLATILE . . . . . . . . . . . . . . 490WAIT (Fortran 2003) . . . . . . . . . . . 493WHERE . . . . . . . . . . . . . . . 495WRITE . . . . . . . . . . . . . . . 496

    Implied-DO List . . . . . . . . . . . 503

    Chapter 12. Directives (IBM extension) 505Comment and noncomment form directives . . . 505

    Comment form directives . . . . . . . . 505Noncomment form directives . . . . . . . 507

    Directives and optimization . . . . . . . . 508Assertive directives . . . . . . . . . . 508Directives for Loop Optimization . . . . . . 508

    Detailed directive descriptions. . . . . . . . 508ALIGN . . . . . . . . . . . . . . 508ASSERT . . . . . . . . . . . . . . 509BLOCK_LOOP . . . . . . . . . . . . 512CNCALL . . . . . . . . . . . . . . 513COLLAPSE . . . . . . . . . . . . . 514EJECT . . . . . . . . . . . . . . . 516EXECUTION_FREQUENCY (IBM extension) 516EXPECTED_VALUE . . . . . . . . . . 517FUNCTRACE_XLF_CATCH . . . . . . . 518FUNCTRACE_XLF_ENTER . . . . . . . 519FUNCTRACE_XLF_EXIT . . . . . . . . 519IGNORE_TKR (IBM extension) . . . . . . 520INCLUDE . . . . . . . . . . . . . 521INDEPENDENT . . . . . . . . . . . 523#LINE . . . . . . . . . . . . . . . 526LOOPID . . . . . . . . . . . . . . 528MEM_DELAY . . . . . . . . . . . . 529NEW . . . . . . . . . . . . . . . 529NOFUNCTRACE . . . . . . . . . . . 530NOSIMD . . . . . . . . . . . . . . 532NOVECTOR. . . . . . . . . . . . . 532PERMUTATION . . . . . . . . . . . 533@PROCESS . . . . . . . . . . . . . 534SNAPSHOT . . . . . . . . . . . . . 535SOURCEFORM. . . . . . . . . . . . 536STREAM_UNROLL . . . . . . . . . . 537SUBSCRIPTORDER . . . . . . . . . . 539UNROLL . . . . . . . . . . . . . . 541UNROLL_AND_FUSE . . . . . . . . . 542

    Chapter 13. Hardware-specificdirectives . . . . . . . . . . . . . 545Cache control . . . . . . . . . . . . . 545

    CACHE_ZERO . . . . . . . . . . . . 545DCBF . . . . . . . . . . . . . . . 545DCBFL . . . . . . . . . . . . . . 546DCBFLP . . . . . . . . . . . . . . 546DCBST . . . . . . . . . . . . . . 546EIEIO . . . . . . . . . . . . . . . 547ISYNC. . . . . . . . . . . . . . . 547LIGHT_SYNC . . . . . . . . . . . . 547

    PREFETCH . . . . . . . . . . . . . . 548DCBTSTT . . . . . . . . . . . . . 548DCBTT . . . . . . . . . . . . . . 549DEFAULT_PREFETCH_DEPTH . . . . . . 549DEPTH_ATTAINMENT_URGENCY . . . . . 550HARDWARE_TRANSIENT_ENABLE . . . . 551HARDWARE_UNIT_COUNT_ENABLE . . . 551LOAD_STREAM_DISABLE. . . . . . . . 551LOAD_TRANSIENT_ENABLE . . . . . . 552

    vi XL Fortran: Language Reference

  • PARTIAL_DCBT . . . . . . . . . . . 552PREFETCH_BY_LOAD . . . . . . . . . 553PREFETCH_BY_STREAM . . . . . . . . 553PREFETCH_FOR_LOAD . . . . . . . . 554PREFETCH_FOR_STORE . . . . . . . . 554PREFETCH_GET_DSCR_REGISTER . . . . . 554PREFETCH_SET_DSCR_REGISTER(VALUE) . . 555PROTECTED_STORE_STREAM_SET . . . . 555PROTECTED_STREAM_COUNT . . . . . . 556PROTECTED_STREAM_COUNT_DEPTH . . . 556PROTECTED_STREAM_GO . . . . . . . 557PROTECTED_STREAM_SET . . . . . . . 558PROTECTED_STREAM_STRIDE . . . . . . 558PROTECTED_STREAM_STOP. . . . . . . 559PROTECTED_STREAM_STOP_ALL . . . . . 559PROTECTED_UNLIMITED_STORE_STREAM_SET . . . . . . . . . . . . . . . 560PROTECTED_UNLIMITED_STREAM_SET . . 560PROTECTED_UNLIMITED_STREAM_SET_GO 561SET_PREFETCH_UNIT_COUNT . . . . . . 562SOFTWARE_TRANSIENT_ENABLE. . . . . 562SOFTWARE_UNIT_COUNT_ENABLE . . . . 562STORE_TRANSIENT_ENABLE . . . . . . 563STRIDE_N_STREAM_ENABLE . . . . . . 563TRANSIENT_PROTECTED_STREAM_COUNT_DEPTH . . . . . . . . . . . . . . 564TRANSIENT_UNLIMITED_PROTECTED_STREAM_DEPTH . . . . . . . . . . 564UNLIMITED_PROTECTED_STREAM_DEPTH 564Examples . . . . . . . . . . . . . . 565

    Chapter 14. Intrinsic procedures . . . 567Classes of intrinsic procedures. . . . . . . . 567

    Inquiry intrinsic functions . . . . . . . . 567Elemental intrinsic procedures. . . . . . . 567System inquiry intrinsic functions (IBMextension) . . . . . . . . . . . . . 569Transformational intrinsic functions . . . . . 569Intrinsic subroutines . . . . . . . . . . 569

    Data representation models. . . . . . . . . 570Integer bit model . . . . . . . . . . . 570Integer data model . . . . . . . . . . 570Real data model . . . . . . . . . . . 571

    Detailed descriptions of intrinsic procedures . . . 572ABORT() (IBM extension) . . . . . . . . 572ABS(A) . . . . . . . . . . . . . . 573ACHAR(I, KIND) . . . . . . . . . . . 573ACOS(X) . . . . . . . . . . . . . . 574ACOSD(X) (IBM extension). . . . . . . . 575ACOSH(X) (Fortran 2008) . . . . . . . . 576ADJUSTL(STRING) . . . . . . . . . . 576ADJUSTR(STRING) . . . . . . . . . . 577AIMAG(Z), IMAG(Z). . . . . . . . . . 577AINT(A, KIND) . . . . . . . . . . . 578ALIGNX(K,M) (IBM extension) . . . . . . 579ALL(MASK, DIM) . . . . . . . . . . . 579ALLOCATED(X) . . . . . . . . . . . 580ANINT(A, KIND) . . . . . . . . . . . 581ANY(MASK, DIM) . . . . . . . . . . 582ASIN(X) . . . . . . . . . . . . . . 582ASIND(X) (IBM extension) . . . . . . . . 583

    ASINH(X) (Fortran 2008) . . . . . . . . 584ASSOCIATED(POINTER, TARGET) . . . . . 585ATAN(X) . . . . . . . . . . . . . . 586ATAN(Y, X) (Fortran 2008) . . . . . . . . 587ATAN2(Y, X) . . . . . . . . . . . . 587ATAN2D(Y, X) (IBM extension) . . . . . . 588ATAND(X) (IBM extension). . . . . . . . 589ATANH(X) (Fortran 2008) . . . . . . . . 590BTEST(I, POS) . . . . . . . . . . . . 590BIT_SIZE(I) . . . . . . . . . . . . . 591CEILING(A, KIND) . . . . . . . . . . 592CHAR(I, KIND) . . . . . . . . . . . 592CMPLX(X, Y, KIND) . . . . . . . . . . 593COMMAND_ARGUMENT_COUNT() (Fortran2003) . . . . . . . . . . . . . . . 594CONJG(Z) . . . . . . . . . . . . . 595COS(X) . . . . . . . . . . . . . . 595COSD(X) (IBM extension) . . . . . . . . 596COSH(X) . . . . . . . . . . . . . . 597COUNT(MASK, DIM, KIND) . . . . . . . 598CPU_TIME(TIME) (Fortran 95) . . . . . . 599CSHIFT(ARRAY, SHIFT, DIM) . . . . . . . 600CVMGx(TSOURCE, FSOURCE, MASK) (IBMextension) . . . . . . . . . . . . . 601DATE_AND_TIME(DATE, TIME, ZONE,VALUES) . . . . . . . . . . . . . . 602DBLE(A) . . . . . . . . . . . . . . 604DCMPLX(X, Y) (IBM extension) . . . . . . 605DIGITS(X) . . . . . . . . . . . . . 605DIM(X, Y) . . . . . . . . . . . . . 606DOT_PRODUCT(VECTOR_A, VECTOR_B) . . 607DPROD(X, Y) . . . . . . . . . . . . 607DSHIFTL(I, J, SHIFT) (Fortran 2008) . . . . . 608DSHIFTR(I, J, SHIFT) (Fortran 2008) . . . . . 609EOSHIFT(ARRAY, SHIFT, BOUNDARY, DIM) 610EPSILON(X) . . . . . . . . . . . . . 611ERF(X) (Fortran 2008) . . . . . . . . . 612ERFC(X) (Fortran 2008) . . . . . . . . . 613ERFC_SCALED(X) (Fortran 2008). . . . . . 613EXECUTE_COMMAND_LINE(COMMAND,WAIT, EXITSTAT, CMDSTAT, CMDMSG)(Fortran 2008) . . . . . . . . . . . . 614EXP(X) . . . . . . . . . . . . . . 616EXPONENT(X) . . . . . . . . . . . . 617EXTENDS_TYPE_OF(A, MOLD) (Fortran 2003) 617FINDLOC(ARRAY, VALUE, DIM, MASK, KIND,BACK) or FINDLOC(ARRAY, VALUE, MASK,KIND, BACK) (Fortran 2008) . . . . . . . 618FLOOR(A, KIND) . . . . . . . . . . . 620FRACTION(X) . . . . . . . . . . . . 621GAMMA(X) (Fortran 2008) . . . . . . . . 621GET_COMMAND(COMMAND, LENGTH,STATUS) (Fortran 2003) . . . . . . . . . 622GET_COMMAND_ARGUMENT(NUMBER,VALUE, LENGTH, STATUS) (Fortran 2003) . . 623GET_ENVIRONMENT_VARIABLE(NAME,VALUE, LENGTH, STATUS, TRIM_NAME)(Fortran 2003) . . . . . . . . . . . . 624GETENV(NAME, VALUE) (IBM extension) . . 625HFIX(A) (IBM extension) . . . . . . . . 626HYPOT(X, Y) (Fortran 2008) . . . . . . . 626

    Contents vii

  • HUGE(X). . . . . . . . . . . . . . 627IACHAR(C, KIND) . . . . . . . . . . 627IAND(I, J) . . . . . . . . . . . . . 628IBCLR(I, POS) . . . . . . . . . . . . 629IBITS(I, POS, LEN) . . . . . . . . . . 630IBSET(I, POS) . . . . . . . . . . . . 630ICHAR(C, KIND) . . . . . . . . . . . 631IEOR(I, J) . . . . . . . . . . . . . . 632ILEN(I) (IBM extension) . . . . . . . . 633IMAG(Z) (IBM extension) . . . . . . . . 633INDEX(STRING, SUBSTRING, BACK, KIND) 633INT(A, KIND) . . . . . . . . . . . . 634INT2(A) (IBM extension) . . . . . . . . 635IOR(I, J) . . . . . . . . . . . . . . 636IS_CONTIGUOUS(ARRAY) (Fortran 2008). . . 637IS_IOSTAT_END(I) (Fortran 2003) . . . . . 638IS_IOSTAT_EOR(I) (Fortran 2003). . . . . . 638ISHFT(I, SHIFT) . . . . . . . . . . . 639ISHFTC(I, SHIFT, SIZE) . . . . . . . . . 639KIND(X) . . . . . . . . . . . . . . 640LBOUND(ARRAY, DIM, KIND) . . . . . . 641LEADZ(I) (Fortran 2008). . . . . . . . . 642LEN(STRING, KIND). . . . . . . . . . 642LEN_TRIM(STRING, KIND) . . . . . . . 643LGAMMA(X) (IBM extension) . . . . . . . 644LGE(STRING_A, STRING_B) . . . . . . . 644LGT(STRING_A, STRING_B) . . . . . . . 645LLE(STRING_A, STRING_B) . . . . . . . 646LLT(STRING_A, STRING_B) . . . . . . . 647LOC(X) (IBM extension) . . . . . . . . . 647LOG(X) . . . . . . . . . . . . . . 648LOG_GAMMA(X) (Fortran 2008) . . . . . . 649LOG10(X) . . . . . . . . . . . . . 650LOGICAL(L, KIND) . . . . . . . . . . 651LSHIFT(I, SHIFT) (IBM extension) . . . . . 651MASKL(I, KIND) (Fortran 2008) . . . . . . 652MASKR(I, KIND) (Fortran 2008) . . . . . . 653MATMUL(MATRIX_A, MATRIX_B, MINDIM) 653MAX(A1, A2, A3, ...) . . . . . . . . . . 655MAXEXPONENT(X) . . . . . . . . . . 656MAXLOC(ARRAY, DIM, MASK, KIND, BACK)or MAXLOC(ARRAY, MASK, KIND, BACK) . . 657MAXVAL(ARRAY, DIM, MASK) orMAXVAL(ARRAY, MASK) . . . . . . . . 659MERGE(TSOURCE, FSOURCE, MASK). . . . 660MERGE_BITS(I, J, MASK) (Fortran 2008) . . . 661MIN(A1, A2, A3, ...) . . . . . . . . . . 662MINEXPONENT(X) . . . . . . . . . . 663MINLOC(ARRAY, DIM, MASK, KIND, BACK)or MINLOC(ARRAY, MASK, KIND, BACK) . . 663MINVAL(ARRAY, DIM, MASK) orMINVAL(ARRAY, MASK) . . . . . . . . 665MOD(A, P) . . . . . . . . . . . . . 667MODULO(A, P) . . . . . . . . . . . 668MOVE_ALLOC(FROM, TO) (Fortran 2003) . . 668MVBITS(FROM, FROMPOS, LEN, TO, TOPOS) 669NEAREST(X,S) . . . . . . . . . . . . 670NEW_LINE(A) (Fortran 2003) . . . . . . . 670NINT(A, KIND) . . . . . . . . . . . 671NOT(I) . . . . . . . . . . . . . . 672NULL(MOLD) . . . . . . . . . . . . 672

    NUM_PARTHDS() (IBM extension) . . . . . 673NUM_USRTHDS() (IBM extension) . . . . . 674NUMBER_OF_PROCESSORS(DIM) (IBMextension) . . . . . . . . . . . . . 675PACK(ARRAY, MASK, VECTOR) . . . . . . 675POPCNT(I) (Fortran 2008) . . . . . . . . 676POPPAR(I) (Fortran 2008) . . . . . . . . 677PRECISION(X) . . . . . . . . . . . . 678PRESENT(A) . . . . . . . . . . . . 679PROCESSORS_SHAPE() (IBM extension) . . . 679PRODUCT(ARRAY, DIM, MASK) orPRODUCT(ARRAY, MASK) . . . . . . . 680QCMPLX(X, Y) (IBM extension) . . . . . . 681QEXT(A) (IBM extension) . . . . . . . . 682RADIX(X) . . . . . . . . . . . . . 683RAND() (IBM extension) . . . . . . . . 683RANDOM_NUMBER(HARVEST) . . . . . 684RANDOM_SEED(SIZE, PUT, GET,GENERATOR) . . . . . . . . . . . . 685RANGE(X) . . . . . . . . . . . . . 686RANK(A) (TS 29113) . . . . . . . . . . 687REAL(A, KIND) . . . . . . . . . . . 687REPEAT(STRING, NCOPIES) . . . . . . . 688RESHAPE(SOURCE, SHAPE, PAD, ORDER) 689RRSPACING(X) . . . . . . . . . . . 690RSHIFT(I, SHIFT) (IBM extension) . . . . . 691SAME_TYPE_AS(A,B) (Fortran 2003) . . . . 691SCALE(X,I) . . . . . . . . . . . . . 692SCAN(STRING, SET, BACK, KIND) . . . . . 693SELECTED_CHAR_KIND(NAME) (Fortran2003) . . . . . . . . . . . . . . . 693SELECTED_INT_KIND(R) . . . . . . . . 694SELECTED_REAL_KIND(P, R, RADIX) . . . . 695SET_EXPONENT(X,I). . . . . . . . . . 696SHAPE(SOURCE, KIND) . . . . . . . . 697SHIFTA(I, SHIFT) (Fortran 2008) . . . . . . 698SHIFTL(I, SHIFT) (Fortran 2008) . . . . . . 699SHIFTR(I, SHIFT) (Fortran 2008) . . . . . . 699SIGN(A, B) . . . . . . . . . . . . . 700SIGNAL(I, PROC) (IBM extension) . . . . . 701SIN(X). . . . . . . . . . . . . . . 702SIND(X) (IBM extension) . . . . . . . . 702SINH(X) . . . . . . . . . . . . . . 703SIZE(ARRAY, DIM, KIND) . . . . . . . . 704SIZEOF(A) (IBM extension). . . . . . . . 705SPACING(X) . . . . . . . . . . . . 706SPREAD(SOURCE, DIM, NCOPIES). . . . . 707SQRT(X) . . . . . . . . . . . . . . 708SRAND(SEED) (IBM extension) . . . . . . 709STORAGE_SIZE (A, KIND) (Fortran 2008). . . 710SUM(ARRAY, DIM, MASK) or SUM(ARRAY,MASK) . . . . . . . . . . . . . . 710SYSTEM(CMD, RESULT) (IBM extension) . . . 712SYSTEM_CLOCK(COUNT, COUNT_RATE,COUNT_MAX) . . . . . . . . . . . . 713TAN(X) . . . . . . . . . . . . . . 714TAND(X) (IBM extension) . . . . . . . . 715TANH(X). . . . . . . . . . . . . . 715TINY(X) . . . . . . . . . . . . . . 716TRAILZ(I) (Fortran 2008) . . . . . . . . 717TRANSFER(SOURCE, MOLD, SIZE). . . . . 717

    viii XL Fortran: Language Reference

  • TRANSPOSE(MATRIX) . . . . . . . . . 718TRIM(STRING) . . . . . . . . . . . . 719UBOUND(ARRAY, DIM, KIND) . . . . . . 720UNPACK(VECTOR, MASK, FIELD) . . . . . 721VERIFY(STRING, SET, BACK, KIND) . . . . 722

    Chapter 15. Hardware-specificintrinsic procedures (IBM extension) . 725Cryptography procedures . . . . . . . . . 725

    Advanced Encryption Standard procedures . . 725Secure Hash Algorithm procedures . . . . . 727Miscellaneous procedures . . . . . . . . 729

    BPERMD(MASK, SOURCE) . . . . . . . . 732CMPB(X,Y) . . . . . . . . . . . . . . 732DIVDE(X,Y) . . . . . . . . . . . . . . 733DIVWE(X,Y). . . . . . . . . . . . . . 734FCFI(I) . . . . . . . . . . . . . . . 734FCFID(I) . . . . . . . . . . . . . . . 735FCFUD(I). . . . . . . . . . . . . . . 735FCTID(X). . . . . . . . . . . . . . . 736FCTIDZ(X) . . . . . . . . . . . . . . 737FCTIW(X) . . . . . . . . . . . . . . 737FCTIWZ(X) . . . . . . . . . . . . . . 737FCTUDZ(X) . . . . . . . . . . . . . . 738FCTUWZ(X). . . . . . . . . . . . . . 738FMADD(A, X, Y) . . . . . . . . . . . . 739FMSUB(A, X, Y) . . . . . . . . . . . . 740FNABS(X) . . . . . . . . . . . . . . 740FNMADD(A, X, Y) . . . . . . . . . . . 741FNMSUB(A, X, Y) . . . . . . . . . . . . 741FRE(X) . . . . . . . . . . . . . . . 742FRES(X) . . . . . . . . . . . . . . . 742FRIC(A) . . . . . . . . . . . . . . . 743FRIM(A) . . . . . . . . . . . . . . . 743FRIN(A) . . . . . . . . . . . . . . . 744FRIP(A) . . . . . . . . . . . . . . . 744FRIZ(A) . . . . . . . . . . . . . . . 745FRSQRTE(X). . . . . . . . . . . . . . 745FRSQRTES(X) . . . . . . . . . . . . . 746FSEL(X,Y,Z) . . . . . . . . . . . . . . 746LOAD2R(X) . . . . . . . . . . . . . . 747LOAD4R(X) . . . . . . . . . . . . . . 747LOAD8R(X) . . . . . . . . . . . . . . 748MTFSF(MASK, R) . . . . . . . . . . . . 749MTFSFI(BF, I) . . . . . . . . . . . . . 749MULHY(RA, RB) . . . . . . . . . . . . 750POPCNTB(I) . . . . . . . . . . . . . 750REVERSE_BYTE_ORDER(X) . . . . . . . . 751ROTATELI(RS, IS, SHIFT, MASK) . . . . . . 752ROTATELM(RS, SHIFT, MASK) . . . . . . . 752SETFSB0(BT) . . . . . . . . . . . . . 753SETFSB1(BT) . . . . . . . . . . . . . 753SFTI(M, Y) . . . . . . . . . . . . . . 754SWDIV(X,Y) . . . . . . . . . . . . . . 754SWDIV_NOCHK(X,Y) . . . . . . . . . . 755TRAP(A, B, TO) . . . . . . . . . . . . 756

    Chapter 16. TheTRANSACTIONAL_MEMORY intrinsicmodule (IBM extension) . . . . . . . 757Transaction begin and end functions. . . . . . 758

    TM_SIMPLE_BEGIN() . . . . . . . . . 758TM_BEGIN(TM_BUFF) . . . . . . . . . 758TM_END() . . . . . . . . . . . . . 759

    Transaction abort functions . . . . . . . . . 759TM_ABORT() . . . . . . . . . . . . 759TM_NAMED_ABORT(CODE) . . . . . . . 760

    Transaction inquiry functions . . . . . . . . 760TM_IS_USER_ABORT(TM_BUFF) . . . . . 760TM_IS_NAMED_USER_ABORT(TM_BUFF,CODE) . . . . . . . . . . . . . . 760TM_IS_ILLEGAL(TM_BUFF) . . . . . . . 761TM_IS_FOOTPRINT_EXCEEDED(TM_BUFF) 761TM_NESTING_DEPTH(TM_BUFF) . . . . . 762TM_IS_NESTED_TOO_DEEP(TM_BUFF) . . . 762TM_IS_CONFLICT(TM_BUFF) . . . . . . 763TM_IS_FAILURE_PERSISTENT(TM_BUFF) . . 763TM_FAILURE_ADDRESS() . . . . . . . . 764TM_FAILURE_CODE(TM_BUFF) . . . . . . 764

    Chapter 17. Vector intrinsicprocedures (IBM extension) . . . . . 767VEC_ABS(ARG1) . . . . . . . . . . . . 767VEC_ABSS(ARG1). . . . . . . . . . . . 767VEC_ADD(ARG1, ARG2) . . . . . . . . . 768VEC_ADD_U128 (ARG1, ARG2) . . . . . . . 768VEC_ADDC_U128 (ARG1, ARG2) . . . . . . 769VEC_ADDE_U128 (ARG1, ARG2, ARG3) . . . . 770VEC_ADDEC_U128 (ARG1, ARG2, ARG3) . . . 770VEC_ADDC(ARG1, ARG2) . . . . . . . . . 771VEC_ADDS(ARG1, ARG2) . . . . . . . . . 771VEC_ALL_EQ(ARG1, ARG2) . . . . . . . . 772VEC_ALL_GE(ARG1, ARG2) . . . . . . . . 772VEC_ALL_GT(ARG1, ARG2) . . . . . . . . 773VEC_ALL_IN(ARG1, ARG2) . . . . . . . . 773VEC_ALL_LE(ARG1, ARG2) . . . . . . . . 774VEC_ALL_LT(ARG1, ARG2) . . . . . . . . 774VEC_ALL_NAN(ARG1) . . . . . . . . . . 775VEC_ALL_NE(ARG1, ARG2) . . . . . . . . 775VEC_ALL_NGE(ARG1, ARG2) . . . . . . . 776VEC_ALL_NGT(ARG1, ARG2) . . . . . . . 776VEC_ALL_NLE(ARG1, ARG2). . . . . . . . 777VEC_ALL_NLT(ARG1, ARG2). . . . . . . . 777VEC_ALL_NUMERIC(ARG1) . . . . . . . . 778VEC_AND(ARG1, ARG2) . . . . . . . . . 778VEC_ANDC(ARG1, ARG2) . . . . . . . . . 779VEC_ANY_EQ(ARG1, ARG2) . . . . . . . . 779VEC_ANY_GE(ARG1, ARG2) . . . . . . . . 780VEC_ANY_GT(ARG1, ARG2) . . . . . . . . 780VEC_ANY_LE(ARG1, ARG2) . . . . . . . . 781VEC_ANY_LT(ARG1, ARG2) . . . . . . . . 781VEC_ANY_NAN(ARG1) . . . . . . . . . 782VEC_ANY_NE(ARG1, ARG2) . . . . . . . . 782VEC_ANY_NGE(ARG1, ARG2) . . . . . . . 782VEC_ANY_NGT(ARG1, ARG2) . . . . . . . 783VEC_ANY_NLE(ARG1, ARG2) . . . . . . . 783VEC_ANY_NLT(ARG1, ARG2) . . . . . . . 784

    Contents ix

  • VEC_ANY_NUMERIC(ARG1) . . . . . . . . 784VEC_ANY_OUT(ARG1, ARG2) . . . . . . . 785VEC_AVG(ARG1, ARG2) . . . . . . . . . 785VEC_BPERM (ARG1, ARG2) . . . . . . . . 786VEC_CEIL(ARG1) . . . . . . . . . . . . 787VEC_CIPHER_BE(ARG1,ARG2) . . . . . . . 787VEC_CIPHERLAST_BE(ARG1,ARG2) . . . . . 788VEC_CMPB(ARG1, ARG2) . . . . . . . . . 788VEC_CMPEQ(ARG1, ARG2) . . . . . . . . 789VEC_CMPGE(ARG1, ARG2) . . . . . . . . 790VEC_CMPGT(ARG1, ARG2) . . . . . . . . 790VEC_CMPLE(ARG1, ARG2) . . . . . . . . 791VEC_CMPLT(ARG1, ARG2) . . . . . . . . 792VEC_CNTLZ(ARG1) . . . . . . . . . . . 793VEC_CONVERT(V, MOLD). . . . . . . . . 793VEC_CPSGN(ARG1, ARG2) . . . . . . . . 794VEC_CTD(ARG1, ARG2) . . . . . . . . . 794VEC_CTF(ARG1, ARG2). . . . . . . . . . 795VEC_CTS(ARG1, ARG2). . . . . . . . . . 795VEC_CTSL(ARG1, ARG2) . . . . . . . . . 796VEC_CTU(ARG1, ARG2) . . . . . . . . . 796VEC_CTUL(ARG1, ARG2) . . . . . . . . . 797VEC_CVF(ARG1) . . . . . . . . . . . . 797VEC_DIV(ARG1, ARG2). . . . . . . . . . 798VEC_DSS(ARG1) . . . . . . . . . . . . 798VEC_DSSALL . . . . . . . . . . . . . 799VEC_DST(ARG1, ARG2, ARG3) . . . . . . . 799VEC_DSTST(ARG1, ARG2, ARG3) . . . . . . 799VEC_DSTSTT(ARG1, ARG2, ARG3) . . . . . . 800VEC_DSTT(ARG1, ARG2, ARG3) . . . . . . . 800VEC_EQV(ARG1, ARG2) . . . . . . . . . 801VEC_EXPTE(ARG1) . . . . . . . . . . . 802VEC_EXTRACT(ARG1, ARG2) . . . . . . . 802VEC_FLOOR(ARG1) . . . . . . . . . . . 803VEC_GBB(ARG1) . . . . . . . . . . . . 803VEC_INSERT(ARG1, ARG2, ARG3) . . . . . . 804VEC_LD(ARG1, ARG2) . . . . . . . . . . 804VEC_LDE(ARG1, ARG2) . . . . . . . . . 805VEC_LDL(ARG1, ARG2) . . . . . . . . . 805VEC_LOGE(ARG1) . . . . . . . . . . . 806VEC_LVSL(ARG1, ARG2) . . . . . . . . . 806VEC_LVSR(ARG1, ARG2) . . . . . . . . . 807VEC_MADD(ARG1, ARG2, ARG3) . . . . . . 807VEC_MADDS(ARG1, ARG2, ARG3) . . . . . . 808VEC_MAX(ARG1, ARG2) . . . . . . . . . 809VEC_MERGEE(ARG1,ARG2) . . . . . . . . 809VEC_MERGEH(ARG1, ARG2) . . . . . . . . 810VEC_MERGEL(ARG1, ARG2) . . . . . . . . 811VEC_MERGEO(ARG1,ARG2) . . . . . . . . 811VEC_MFVSCR . . . . . . . . . . . . . 812VEC_MIN(ARG1, ARG2) . . . . . . . . . 812VEC_MLADD(ARG1, ARG2, ARG3) . . . . . . 813VEC_MRADDS(ARG1, ARG2, ARG3) . . . . . 814VEC_MSUB(ARG1, ARG2, ARG3) . . . . . . 814VEC_MSUM(ARG1, ARG2, ARG3) . . . . . . 815VEC_MSUMS(ARG1, ARG2, ARG3) . . . . . . 816VEC_MTVSCR(ARG1) . . . . . . . . . . 816VEC_MUL(ARG1, ARG2) . . . . . . . . . 817VEC_MULE(ARG1, ARG2) . . . . . . . . . 817VEC_MULO(ARG1, ARG2) . . . . . . . . . 818VEC_NABS(ARG1) . . . . . . . . . . . 818

    VEC_NAND(ARG1, ARG2). . . . . . . . . 819VEC_NCIPHER_BE(ARG1,ARG2) . . . . . . 820VEC_NCIPHERLAST_BE(ARG1,ARG2). . . . . 820VEC_NEG(ARG1) . . . . . . . . . . . . 821VEC_NMADD(ARG1, ARG2, ARG3) . . . . . 821VEC_NMSUB(ARG1, ARG2, ARG3) . . . . . . 822VEC_NOR(ARG1, ARG2) . . . . . . . . . 822VEC_OR(ARG1, ARG2) . . . . . . . . . . 823VEC_ORC(ARG1, ARG2) . . . . . . . . . 823VEC_PACK(ARG1, ARG2) . . . . . . . . . 824VEC_PACKPX(ARG1, ARG2) . . . . . . . . 824VEC_PACKS(ARG1, ARG2) . . . . . . . . 825VEC_PACKSU(ARG1, ARG2) . . . . . . . . 826VEC_PERM(ARG1, ARG2, ARG3) . . . . . . 826VEC_PERMI(ARG1, ARG2, ARG3) . . . . . . 827VEC_PMSUM_BE(ARG1,ARG2) . . . . . . . 828VEC_POPCNT(ARG1) . . . . . . . . . . 828VEC_PROMOTE(ARG1, ARG2) . . . . . . . 829VEC_RE(ARG1) . . . . . . . . . . . . 829VEC_REVB(ARG1) . . . . . . . . . . . 830VEC_REVE(ARG1) . . . . . . . . . . . 831VEC_RL(ARG1, ARG2) . . . . . . . . . . 831VEC_ROUND(ARG1) . . . . . . . . . . 832VEC_ROUNDC(ARG1) . . . . . . . . . . 833VEC_ROUNDM(ARG1) . . . . . . . . . . 833VEC_ROUNDP(ARG1) . . . . . . . . . . 833VEC_ROUNDZ(ARG1) . . . . . . . . . . 833VEC_RSQRTE(ARG1). . . . . . . . . . . 833VEC_SBOX_BE(ARG1) . . . . . . . . . . 834VEC_SEL(ARG1, ARG2, ARG3) . . . . . . . 834VEC_SHASIGMA_BE(ARG1,ARG2,ARG3). . . . 835VEC_SL(ARG1, ARG2) . . . . . . . . . . 836VEC_SLD(ARG1, ARG2, ARG3) . . . . . . . 836VEC_SLDW(ARG1, ARG2, ARG3) . . . . . . 837VEC_SLL(ARG1, ARG2) . . . . . . . . . . 838VEC_SLO(ARG1, ARG2) . . . . . . . . . 838VEC_SPLAT(ARG1, ARG2) . . . . . . . . . 839VEC_SPLATS(ARG1) . . . . . . . . . . . 839VEC_SPLAT_S8(ARG1) . . . . . . . . . . 840VEC_SPLAT_S16(ARG1). . . . . . . . . . 840VEC_SPLAT_S32(ARG1). . . . . . . . . . 840VEC_SPLAT_U8(ARG1) . . . . . . . . . . 841VEC_SPLAT_U16(ARG1) . . . . . . . . . 841VEC_SPLAT_U32(ARG1) . . . . . . . . . 842VEC_SQRT(ARG1) . . . . . . . . . . . 842VEC_SR(ARG1, ARG2) . . . . . . . . . . 843VEC_SRA(ARG1, ARG2) . . . . . . . . . 843VEC_SRL(ARG1, ARG2) . . . . . . . . . . 844VEC_SRO(ARG1, ARG2) . . . . . . . . . 844VEC_ST(ARG1, ARG2, ARG3) . . . . . . . . 845VEC_STE(ARG1, ARG2, ARG3) . . . . . . . 846VEC_STL(ARG1,ARG2,ARG3) . . . . . . . . 847VEC_SUB(ARG1, ARG2). . . . . . . . . . 847VEC_SUB_U128 (ARG1, ARG2) . . . . . . . 848VEC_SUBC_U128 (ARG1, ARG2) . . . . . . . 849VEC_SUBE_U128 (ARG1, ARG2, ARG3) . . . . 849VEC_SUBEC_U128 (ARG1, ARG2, ARG3) . . . . 850VEC_SUBC(ARG1, ARG2) . . . . . . . . . 851VEC_SUBS(ARG1, ARG2) . . . . . . . . . 851VEC_SUM2S(ARG1, ARG2) . . . . . . . . 852VEC_SUM4S(ARG1, ARG2) . . . . . . . . 852

    x XL Fortran: Language Reference

  • VEC_SUMS(ARG1, ARG2) . . . . . . . . . 853VEC_TRUNC(ARG1) . . . . . . . . . . . 853VEC_UNPACKH(ARG1). . . . . . . . . . 854VEC_UNPACKL(ARG1) . . . . . . . . . . 855VEC_XL(ARG1, ARG2) . . . . . . . . . . 855VEC_XL_BE(ARG1, ARG2) . . . . . . . . . 856VEC_XLD2(ARG1, ARG2) . . . . . . . . . 857VEC_XLDS(ARG1, ARG2) . . . . . . . . . 858VEC_XLW4(ARG1, ARG2) . . . . . . . . . 859VEC_XOR(ARG1, ARG2) . . . . . . . . . 860VEC_XST(ARG1, ARG2, ARG3) . . . . . . . 860VEC_XST_BE(ARG1, ARG2, ARG3) . . . . . . 861VEC_XSTD2(ARG1, ARG2, ARG3) . . . . . . 862VEC_XSTW4(ARG1, ARG2, ARG3) . . . . . . 862

    Chapter 18. Language interoperabilityfeatures . . . . . . . . . . . . . . 865Interoperability of types . . . . . . . . . . 865

    Intrinsic types . . . . . . . . . . . . 865Derived types . . . . . . . . . . . . 865

    Interoperability of variables . . . . . . . . 866Interoperable variables in asynchronouscommunication (TS 29113) . . . . . . . . 866

    Interoperability of common blocks . . . . . . 868Interoperability of procedures . . . . . . . . 868

    Interoperability of optional arguments (TS29113) . . . . . . . . . . . . . . . 869Interoperability of allocatable and pointerarguments (TS 29113) . . . . . . . . . . 869Interoperability of assumed-length arguments(TS 29113) . . . . . . . . . . . . . 874Interoperability of assumed-type arguments (TS29113) . . . . . . . . . . . . . . . 875Interoperability of assumed-rank arguments (TS29113) . . . . . . . . . . . . . . . 877

    The ISO_C_BINDING module . . . . . . . . 880Constants for use as kind type parameters . . 880Character constants . . . . . . . . . . 881Other constants. . . . . . . . . . . . 882Types . . . . . . . . . . . . . . . 882Procedures . . . . . . . . . . . . . 882

    The ISO_Fortran_binding.h header file (TS 29113) 885Type definitions and structures . . . . . . 886Macros . . . . . . . . . . . . . . 887Functions. . . . . . . . . . . . . . 888

    Binding labels . . . . . . . . . . . . . 899

    Chapter 19. The ISO_FORTRAN_ENVintrinsic module . . . . . . . . . . 901ISO_FORTRAN_ENV constants . . . . . . . 901

    CHARACTER_KINDS (Fortran 2008) . . . . 901CHARACTER_STORAGE_SIZE . . . . . . 901ERROR_UNIT . . . . . . . . . . . . 901FILE_STORAGE_SIZE . . . . . . . . . 902INT8 (Fortran 2008) . . . . . . . . . . 902INT16 (Fortran 2008) . . . . . . . . . . 902INT32 (Fortran 2008) . . . . . . . . . . 902INT64 (Fortran 2008) . . . . . . . . . . 903INTEGER_KINDS (Fortran 2008) . . . . . . 903INPUT_UNIT . . . . . . . . . . . . 903

    IOSTAT_END . . . . . . . . . . . . 903IOSTAT_EOR . . . . . . . . . . . . 904IOSTAT_INQUIRE_INTERNAL_UNIT (Fortran2008) . . . . . . . . . . . . . . . 904LOGICAL_KINDS (Fortran 2008) . . . . . . 905NUMERIC_STORAGE_SIZE . . . . . . . 905OUTPUT_UNIT . . . . . . . . . . . 905REAL32 (Fortran 2008) . . . . . . . . . 905REAL64 (Fortran 2008) . . . . . . . . . 906REAL128 (Fortran 2008) . . . . . . . . . 906REAL_KINDS (Fortran 2008) . . . . . . . 906

    ISO_FORTRAN_ENV functions . . . . . . . 906COMPILER_OPTIONS (Fortran 2008) . . . . 907COMPILER_VERSION (Fortran 2008) . . . . 907

    Chapter 20. Floating-point control andinquiry procedures . . . . . . . . . 909fpgets fpsets . . . . . . . . . . . . . . 909Efficient floating-point control and inquiryprocedures . . . . . . . . . . . . . . 910

    xlf_fp_util floating-point procedures . . . . . 912IEEE Modules and support (Fortran 2003) . . . . 916

    Compiling and exception handling . . . . . 917General rules for implementing IEEE modules 917IEEE derived data types and constants . . . . 917IEEE Operators . . . . . . . . . . . . 919IEEE procedures . . . . . . . . . . . 920Rules for floating-point status . . . . . . . 943Examples . . . . . . . . . . . . . . 944

    Chapter 21. Service and utilityprocedures (IBM extension) . . . . . 949General service and utility procedures . . . . . 949List of service and utility procedures . . . . . 950

    alarm_(time, func) . . . . . . . . . . . 950bic_(X1, X2) . . . . . . . . . . . . . 951bis_(X1, X2) . . . . . . . . . . . . . 951bit_(X1, X2) . . . . . . . . . . . . . 952clock_() . . . . . . . . . . . . . . 952ctime_(STR, TIME) . . . . . . . . . . 953date() . . . . . . . . . . . . . . . 953dtime_(dtime_struct) . . . . . . . . . . 953etime_(etime_struct) . . . . . . . . . . 954exit_(exit_status) . . . . . . . . . . . 954fdate_(str) . . . . . . . . . . . . . 955fiosetup_(unit, command, argument) . . . . 955flush_(lunit) . . . . . . . . . . . . . 956ftell_(lunit) . . . . . . . . . . . . . 956ftell64_(lunit) . . . . . . . . . . . . 957getarg(i1,c1) . . . . . . . . . . . . . 957getcwd_(name) . . . . . . . . . . . . 958getfd(lunit) . . . . . . . . . . . . . 958getgid_() . . . . . . . . . . . . . . 959getlog_(name) . . . . . . . . . . . . 959getpid_() . . . . . . . . . . . . . . 959getuid_() . . . . . . . . . . . . . . 960global_timef() . . . . . . . . . . . . 960gmtime_(stime, tarray) . . . . . . . . . 960hostnm_(name) . . . . . . . . . . . . 961iargc() . . . . . . . . . . . . . . . 961

    Contents xi

  • idate_(idate_struct) . . . . . . . . . . 962ierrno_() . . . . . . . . . . . . . . 962irand(). . . . . . . . . . . . . . . 962irtc() . . . . . . . . . . . . . . . 963itime_(itime_struct) . . . . . . . . . . 963jdate() . . . . . . . . . . . . . . . 963lenchr_(str) . . . . . . . . . . . . . 964lnblnk_(str) . . . . . . . . . . . . . 964ltime_(stime, tarray) . . . . . . . . . . 965mclock() . . . . . . . . . . . . . . 965qsort_(array, len, isize, compar) . . . . . . 965qsort_down(array, len, isize) . . . . . . . 966qsort_up(array, len, isize) . . . . . . . . 967rtc() . . . . . . . . . . . . . . . 967setrteopts(c1) . . . . . . . . . . . . 968sleep_(sec) . . . . . . . . . . . . . 968time_() . . . . . . . . . . . . . . 968timef() . . . . . . . . . . . . . . . 969timef_delta(t) . . . . . . . . . . . . 969umask_(cmask) . . . . . . . . . . . . 969usleep_(msec) . . . . . . . . . . . . 970xl__trbk() . . . . . . . . . . . . . . 970

    The XLF_POSIX_BINDINGS module . . . . . 970Types . . . . . . . . . . . . . . . 971Named constants . . . . . . . . . . . 971

    Abstract interfaces. . . . . . . . . . . 976Procedures . . . . . . . . . . . . . 977

    Chapter 22. Extensions for sourcecompatibility (IBM extension) . . . . 1025Record structures. . . . . . . . . . . . 1025

    Declaring record structures . . . . . . . 1026Storage mapping . . . . . . . . . . . 1028

    Union and map (IBM extension). . . . . . . 1029

    Appendix. . . . . . . . . . . . . 1033Compatibility across standards . . . . . . . 1033

    Fortran 90 compatibility . . . . . . . . 1034Obsolescent features. . . . . . . . . . 1034Deleted features . . . . . . . . . . . 1036

    ASCII and EBCDIC character sets . . . . . . 1036

    Notices . . . . . . . . . . . . . 1045Trademarks . . . . . . . . . . . . . 1047

    Glossary . . . . . . . . . . . . . 1049

    Index . . . . . . . . . . . . . . 1069

    xii XL Fortran: Language Reference

  • About this document

    This document, which is part of the XL Fortran documentation suite, describes thesyntax, semantics, and IBM implementation of the Fortran programming languageon the AIX® operating system. Although XL Fortran implementations conform toTS 29113 (partial support), Fortran 2008 (partial support), Fortran 2003 (fullsupport), and other specifications maintained by the ISO standards for the Fortranprogramming language, they also incorporate many extensions to the corelanguage. These extensions have been implemented to enhance usability in specificoperating environments, assure compatibility with other compilers, and supportnew hardware capabilities.

    Who should read this documentThis document is a reference for users who already have experience programmingin Fortran. Users new to Fortran can still use this document to find informationabout the language and features unique to XL Fortran; however, it does not aim toteach programming concepts nor to promote specific programming practices.

    How to use this documentWhile this document covers both standard and implementation-specific features ofXL Fortran, it does not include the following topics, which are covered in otherdocuments:v Installation, system requirements, last-minute updates: see the XL Fortran

    Installation Guide and product README file.v Overview of XL Fortran features: see Getting Started with XL Fortran.v Compiler setup, compiling and running programs, compiler options, diagnostics:

    see the XL Fortran Compiler Reference.v Optimizing, porting, OpenMP and SMP programming: see the XL Fortran

    Optimization and Programming Guide.v Operating system commands related to the use of the compiler: AIX Commands

    Reference, Volumes 1 - 6 and the AIX information center.v Operating system commands related to the use of the compiler: consult your

    man page help and documentation of the specific distribution.

    How this document is organizedThe following lists group information into sections that provide details onparticular language topics and implementations:v XL Fortran language elements:

    – XL Fortran for AIX– XL Fortran language fundamentals– Intrinsic data types– Derived types– Arrays concepts– Expressions and assignment– Execution control– Program units and procedures

    © Copyright IBM Corp. 1996, 2015 xiii

  • – XL Fortran Input/Output– Input/Output formatting– Statements and attributes– Directives (IBM extension)– Intrinsic procedures– The TRANSACTIONAL_MEMORY intrinsic module (IBM extension)– Vector intrinsic procedures (IBM extension)– Language interoperability features (Fortran 2003)– The ISO_FORTRAN_ENV intrinsic module– Extensions for source compatibility (IBM extension)

    v Procedures that provide hardware-related functionality, and additional featuresfor those who are already familiar with the Fortran language:– Floating-point control and inquiry procedures– Hardware–specific directives– Hardware–specific intrinsic procedures (IBM extension)– Service and utility procedures (IBM extension)

    v The appendices provide information about compatibility across standards forusers of earlier versions of Fortran and the ASCII and EBCDIC character setsmapping table.

    ConventionsTypographical conventions

    The following table shows the typographical conventions used in the IBM® XLFortran for AIX, V15.1.3 information.

    Table 1. Typographical conventions

    Typeface Indicates Example

    lowercasebold

    Invocation commands, executablenames, and compiler options.

    The compiler provides basicinvocation commands, xlf, along withseveral other compiler invocationcommands to support various Fortranlanguage levels and compilationenvironments.

    The default file name for theexecutable program is a.out.

    italics Parameters or variables whoseactual names or values are to besupplied by the user. Italics arealso used to introduce new terms.

    Make sure that you update the sizeparameter if you return more thanthe size requested.

    underlining The default setting of a parameterof a compiler option or directive.

    nomaf | maf

    monospace Examples of program code,reference to program code, filenames, path names, commandstrings, or user-defined names.

    To compile and optimizemyprogram.f, enter: xlf myprogram.f-O3.

    xiv XL Fortran: Language Reference

  • Table 1. Typographical conventions (continued)

    Typeface Indicates Example

    UPPERCASEbold

    Fortran programming keywords,statements, directives, and intrinsicprocedures. Uppercase letters mayalso be used to indicate theminimum number of charactersrequired to invoke a compileroption/suboption.

    The ASSERT directive applies only tothe DO loop immediately followingthe directive, and not to any nestedDO loops.

    Qualifying elements (icons and bracket separators)

    In descriptions of language elements, this information uses icons and markedbracket separators to delineate the Fortran language standard text as follows:

    Table 2. Qualifying elements

    IconBracketseparator text Meaning

    F2008

    F2008

    Fortran 2008begins /Fortran 2008ends

    The text describes an IBM XL Fortran implementation ofthe Fortran 2008 standard.

    Fortran 2003begins /Fortran 2003ends

    The text describes an IBM XL Fortran implementation ofthe Fortran 2003 standard, and it applies to all laterstandards.

    IBM extensionbegins / IBMextension ends

    The text describes a feature that is an IBM XL Fortranextension to the standard language specifications.

    TS 29113

    TS 29113

    TS 29113begins / TS29113 ends

    The text describes an IBM XL Fortran implementation ofTechnical Specification 29113, referred to as TS 29113.

    Note: If the information is marked with a Fortran language standard icon orbracket separators, it applies to this specific Fortran language standard and all laterones. If it is not marked, it applies to all Fortran language standards.

    Syntax diagrams

    Throughout this information, diagrams illustrate XL Fortran syntax. This sectionhelps you to interpret and use those diagrams.v Read the syntax diagrams from left to right, from top to bottom, following the

    path of the line.The ►►─── symbol indicates the beginning of a command, directive, or statement.The ───► symbol indicates that the command, directive, or statement syntax iscontinued on the next line.The ►─── symbol indicates that a command, directive, or statement is continuedfrom the previous line.The ───►◄ symbol indicates the end of a command, directive, or statement.

    About this document xv

  • Fragments, which are diagrams of syntactical units other than completecommands, directives, or statements, start with the │─── symbol and end withthe ───│ symbol.IBM XL Fortran extensions are marked by a number in the syntax diagram withan explanatory note immediately following the diagram.Program units, procedures, constructs, interface blocks and derived-typedefinitions consist of several individual statements. For such items, a boxencloses the syntax representation, and individual syntax diagrams show therequired order for the equivalent Fortran statements.

    v Required items are shown on the horizontal line (the main path):

    ►► keyword required_argument ►◄

    v Optional items are shown below the main path:

    ►► keywordoptional_argument

    ►◄

    Note: Optional items (not in syntax diagrams) are enclosed by square brackets ([and ]). For example, [UNIT=]u

    v If you can choose from two or more items, they are shown vertically, in a stack.If you must choose one of the items, one item of the stack is shown on the mainpath.

    ►► keyword required_argument1required_argument2

    ►◄

    If choosing one of the items is optional, the entire stack is shown below themain path.

    ►► keywordoptional_argument1optional_argument2

    ►◄

    v An arrow returning to the left above the main line (a repeat arrow) indicatesthat you can make more than one choice from the stacked items or repeat anitem. The separator character, if it is other than a blank, is also indicated:

    ►► ▼

    ,

    keyword repeatable_argument ►◄

    v The item that is the default is shown above the main path.

    ►► keyworddefault_argumentalternate_argument ►◄

    v Keywords are shown in nonitalic letters and should be entered exactly as shown.v Variables are shown in italicized lowercase letters. They represent user-supplied

    names or values. If a variable or user-specified name ends in _list, you canprovide a list of these terms separated by commas.

    xvi XL Fortran: Language Reference

  • v If punctuation marks, parentheses, arithmetic operators, or other such symbolsare shown, you must enter them as part of the syntax.

    Sample syntax diagram

    The following is an example of a syntax diagram with an interpretation:

    How to read syntax statements

    Syntax statements are read from left to right:v Individual required arguments are shown with no special notation.v When you must make a choice between a set of alternatives, they are enclosed

    by { and } symbols.v Optional arguments are enclosed by [ and ] symbols.v When you can select from a group of choices, they are separated by | characters.v Arguments that you can repeat are followed by ellipses (...).

    Example of a syntax statementEXAMPLE char_constant {a|b}[c|d]e[,e]... name_list{name_list}...

    The following list explains the syntax statement:v Enter the keyword EXAMPLE.v Enter a value for char_constant.v Enter a value for a or b, but not for both.v Optionally, enter a value for c or d.v Enter at least one value for e. If you enter more than one value, you must put a

    comma between each.

    ►►(1)

    EXAMPLE char_constant ab c

    d

    ,

    e name_list ►◄

    Notes:

    1 IBM extension

    Interpret the diagram as follows:

    v Enter the keyword EXAMPLE.v EXAMPLE is an IBM extension.v Enter a value for char_constant.v Enter a value for a or b, but not for both.v Optionally, enter a value for c or d.v Enter at least one value for e. If you enter more than one value, you must put a

    comma between each.

    v Enter the value of at least one name for name_list. If you enter more than one value,you must put a comma between each. (The _list syntax is equivalent to the previoussyntax for e.)

    About this document xvii

  • v Optionally, enter the value of at least one name for name_list. If you enter morethan one value, you must put a comma between each name.

    Note: The same example is used in both the syntax-statement and syntax-diagramrepresentations.

    Examples in this information

    The examples in this information, except where otherwise noted, are coded in asimple style that does not try to conserve storage, check for errors, achieve fastperformance, or demonstrate all possible methods to achieve a specific result.

    The examples for installation information are labelled as either Example or Basicexample. Basic examples are intended to document a procedure as it would beperformed during a basic, or default, installation; these need little or nomodification.

    Notes on the terminology used

    Some of the terminology in this information is shortened as follows:v The term free source form format often appears as free source form.v The term fixed source form format often appears as fixed source form.v The term XL Fortran often appears as XLF.

    Related informationThe following sections provide related information for XL Fortran:

    IBM XL Fortran informationXL Fortran provides product information in the following formats:v Quick Start Guide

    The Quick Start Guide (quickstart.pdf) is intended to get you started with IBMXL Fortran for AIX, V15.1.3. It is located by default in the XL Fortran directoryand in the \quickstart directory of the installation DVD.

    v README filesREADME files contain late-breaking information, including changes andcorrections to the product information. README files are located by default inthe XL Fortran directory and in the root directory of the installation DVD.

    v Installable man pagesMan pages are provided for the compiler invocations and all command-lineutilities provided with the product. Instructions for installing and accessing theman pages are provided in the IBM XL Fortran for AIX, V15.1.3 Installation Guide.

    v Online product documentationThe fully searchable HTML-based documentation is viewable in IBM KnowledgeCenter at http://www.ibm.com/support/knowledgecenter/SSGH4D_15.1.3/com.ibm.compilers.aix.doc/welcome.html.

    v PDF documentsPDF documents are available on the web at http://www.ibm.com/support/docview.wss?uid=swg27036673.The following files comprise the full set of XL Fortran product information:

    xviii XL Fortran: Language Reference

    http://www.ibm.com/support/knowledgecenter/SSGH4D_15.1.3/com.ibm.compilers.aix.doc/welcome.htmlhttp://www.ibm.com/support/knowledgecenter/SSGH4D_15.1.3/com.ibm.compilers.aix.doc/welcome.htmlhttp://www.ibm.com/support/docview.wss?uid=swg27036673http://www.ibm.com/support/docview.wss?uid=swg27036673

  • Table 3. XL Fortran PDF files

    Document titlePDF filename Description

    IBM XL Fortran for AIX,V15.1.3 Installation Guide,SC27-4243-02

    install.pdf Contains information for installing XL Fortranand configuring your environment for basiccompilation and program execution.

    Getting Started with IBMXL Fortran for AIX,V15.1.3, SC27-4242-02

    getstart.pdf Contains an introduction to the XL Fortranproduct, with information about setting up andconfiguring your environment, compiling andlinking programs, and troubleshootingcompilation errors.

    IBM XL Fortran for AIX,V15.1.3 Compiler Reference,SC27-4244-02

    compiler.pdf Contains information about the variouscompiler options and environment variables.

    IBM XL Fortran for AIX,V15.1.3 Language Reference,SC27-4245-02

    langref.pdf Contains information about the Fortranprogramming language as supported by IBM,including language extensions for portabilityand conformance to nonproprietary standards,compiler directives and intrinsic procedures.

    IBM XL Fortran for AIX,V15.1.3 Optimization andProgramming Guide,SC27-4246-02

    proguide.pdf Contains information on advancedprogramming topics, such as applicationporting, interlanguage calls, floating-pointoperations, input/output, applicationoptimization and parallelization, and the XLFortran high-performance libraries.

    To read a PDF file, use Adobe Reader. If you do not have Adobe Reader, youcan download it (subject to license terms) from the Adobe website athttp://www.adobe.com.

    More information related to XL Fortran, including IBM Redbooks® publications,white papers, and other articles, is available on the web at http://www.ibm.com/support/docview.wss?uid=swg27036673.

    For more information about Fortran, see the Fortran café at https://www.ibm.com/developerworks/mydeveloperworks/groups/service/html/communityview?communityUuid=b10932b4-0edd-4e61-89f2-6e478ccba9aa.

    Standards and specificationsXL Fortran is designed to support the following standards and specifications. Youcan refer to these standards and specifications for precise definitions of some of thefeatures found in this information.v American National Standard Programming Language FORTRAN, ANSI X3.9-1978.v American National Standard Programming Language Fortran 90, ANSI X3.198-1992.v ANSI/IEEE Standard for Binary Floating-Point Arithmetic, ANSI/IEEE Std 754-1985.v Federal (USA) Information Processing Standards Publication Fortran, FIPS PUB 69-1.v Information technology - Programming languages - Fortran, ISO/IEC 1539-1:1991.

    (This information uses its informal name, Fortran 90.)v Information technology - Programming languages - Fortran - Part 1: Base language,

    ISO/IEC 1539-1:1997. (This information uses its informal name, Fortran 95.)v Information technology - Programming languages - Fortran - Part 1: Base language,

    ISO/IEC 1539-1:2004. (This information uses its informal name, Fortran 2003.)

    About this document xix

    http://www.adobe.comhttp://www.ibm.com/support/docview.wss?uid=swg27036673http://www.ibm.com/support/docview.wss?uid=swg27036673https://www.ibm.com/developerworks/mydeveloperworks/groups/service/html/communityview?communityUuid=b10932b4-0edd-4e61-89f2-6e478ccba9aahttps://www.ibm.com/developerworks/mydeveloperworks/groups/service/html/communityview?communityUuid=b10932b4-0edd-4e61-89f2-6e478ccba9aahttps://www.ibm.com/developerworks/mydeveloperworks/groups/service/html/communityview?communityUuid=b10932b4-0edd-4e61-89f2-6e478ccba9aa

  • v Information technology - Programming languages - Fortran - Part 1: Base language,ISO/IEC 1539-1:2010. (This information uses its informal name, Fortran 2008. Wecurrently provide partial support to this standard.)

    v Information technology - Further interoperability of Fortran with C, ISO/IEC TS29113:2012. (This information uses its informal name, Technical specification29113, referred to as TS 29113. We currently provide partial support to thisspecification.)

    v Military Standard Fortran DOD Supplement to ANSI X3.9-1978, MIL-STD-1753(United States of America, Department of Defense standard). Note that XLFortran supports only those extensions documented in this standard that havealso been subsequently incorporated into the Fortran 90 standard.

    v OpenMP Application Program Interface Version 3.1 (full support), and OpenMPApplication Program Interface Version 4.0 (partial support), available athttp://www.openmp.org

    Other IBM informationv Parallel Environment for AIX: Operation and Usev The IBM Systems Information Center, at http://publib.boulder.ibm.com/

    infocenter/systems/index.jsp?topic=/com.ibm.aix.doc/doc/base/aixparent.htm,is a resource for AIX information.You can find the following books for your specific AIX system:– AIX Commands Reference, Volumes 1 - 6– Technical Reference: Base Operating System and Extensions, Volumes 1 & 2– AIX National Language Support Guide and Reference– AIX General Programming Concepts: Writing and Debugging Programs– AIX Assembler Language Reference

    Technical supportAdditional technical support is available from the XL Fortran Support page athttp://www.ibm.com/support/entry/portal/product/rational/xl_fortran_for_aix.This page provides a portal with search capabilities to a large selection ofTechnotes and other support information.

    If you cannot find what you need, you can send an email [email protected].

    For the latest information about XL Fortran, visit the product information site athttp://www.ibm.com/software/products/en/xlfortran-aix.

    How to send your commentsYour feedback is important in helping us to provide accurate and high-qualityinformation. If you have any comments about this information or any other XLFortran information, send your comments to [email protected].

    Be sure to include the name of the manual, the part number of the manual, theversion of XL Fortran, and, if applicable, the specific location of the text you arecommenting on (for example, a page number or table number).

    xx XL Fortran: Language Reference

    http://www.openmp.orghttp://publib.boulder.ibm.com/infocenter/systems/index.jsp?topic=/com.ibm.aix.doc/doc/base/aixparent.htmhttp://publib.boulder.ibm.com/infocenter/systems/index.jsp?topic=/com.ibm.aix.doc/doc/base/aixparent.htmhttp://www.ibm.com/support/entry/portal/product/rational/xl_fortran_for_aixhttp://www.ibm.com/software/products/en/xlfortran-aix

  • Chapter 1. XL Fortran for AIX

    The XL Fortran Language Reference is part of a documentation suite that offersinformation on installing and using the XL Fortran compiler on AIX. Thisdocument defines the syntax, semantics, and restrictions you must follow to writevalid XL Fortran programs.

    Fortran (FORmula TRANslation) is a high-level programming language primarilyuseful for engineering, mathematical, and scientific applications involving numericcomputations.

    XL Fortran implements partial Technical specification 29113, partial Fortran 2008,full Fortran 2003, and other language specifications maintained by the ISOstandards for the Fortran programming language. XL Fortran also incorporatesmany extensions to the core language. These extensions have been implementedwith the aims of enhancing usability in specific operating environments, assuringcompatibility with other compilers, and supporting new hardware capabilities. Aprogram that compiles correctly on one standard-conforming compiler shouldcompile and execute correctly under all other conforming compilers, insofar ashardware differences permit.

    The compiler detects most nonconformances to the XL Fortran language rules. Thecompiler cannot detect all combinations of syntax and semantic nonconformancesbecause the diagnosis might hinder performance. XL Fortran programs that containthese undiagnosed nonconformances are not valid, even though they might run asexpected.

    Fortran language standards

    Technical specification 29113An important supplement to Fortran 2008 is the ISO Technical Specification onFurther Interoperability of Fortran with C, referred to as Technical specification29113 or TS 29113. XL Fortran compiler supports the following subset of features inTS 29113:v “Interoperability of assumed-length arguments (TS 29113)” on page 874v “Interoperability of assumed-rank arguments (TS 29113)” on page 877v “Interoperability of assumed-type arguments (TS 29113)” on page 875v “Interoperability of allocatable and pointer arguments (TS 29113)” on page 869v “Interoperability of optional arguments (TS 29113)” on page 869v “Interoperable variables in asynchronous communication (TS 29113)” on page

    866v “The ISO_Fortran_binding.h header file (TS 29113)” on page 885

    Fortran 2008Segments of this document contain information based on the Fortran 2008standard. The standard is open to continual interpretation, modification andrevision. IBM reserves the right to modify the behavior of any features of thisproduct to conform with future interpretations of this standard.

    © Copyright IBM Corp. 1996, 2015 1

  • The Fortran Standards Committee responds to questions of interpretation aboutaspects of Fortran. Some questions can relate to language features alreadyimplemented in the XL Fortran compiler. Responses provided by the committeerelating to these language features can result in changes to future releases of theXL Fortran compiler. These changes may result in incompatibilities with previousreleases of the product.

    Some of the Fortran 2008 features are as follows:

    Module enhancements

    v Submodules provide additional structuring facilities for modules.v To declare a module procedure interface body or define a separate module

    procedure, specify the MODULE prefix specifier for the “FUNCTION” on page380 or “SUBROUTINE” on page 469 statement.

    Performance enhancements

    v The DO CONCURRENT construct provides a means for programs to specifythat individual loop iterations have no interdependencies.

    v The CONTIGUOUS attribute provides a means for programs to specifyrestrictions on the storage layout of pointer targets and assumed-shape dummyarguments.

    Data declaration

    v A named constant array's shape can be implied by its value. For details, seeImplied-shape arrays.

    v A “FORALL” on page 372 index variable can have its type and kind explicitlydeclared within the construct.

    v In addition to derived types, the TYPE type specifier is extended to declareentities of intrinsic types.

    v Multiple type-bound procedures can be declared in a single type-boundprocedure statement.

    Data usage and computation

    v You can allocate more than one allocate_object by using an ALLOCATE statementthat contains the SOURCE= or MOLD= specifier.

    v The MOLD= specifier has been added to the “ALLOCATE” on page 287statement. In addition, you can omit the bounds in the ALLOCATE statement ifyou provide source_expr in the SOURCE= or MOLD= specifier.

    v The real and imaginary parts of a complex entity can be accessed independentlyby using complex part designators.

    v Variables now can be polymorphic in an intrinsic assignment.

    Input and output

    v NEWUNIT= in an OPEN statement automatically selects a unit number thatdoes not interfere with other unit numbers that are selected by the program.

    Execution control

    v The BLOCK construct can contain declarations of objects with construct scope.v The EXIT statement can transfer control from within more named executable

    constructs.

    2 XL Fortran: Language Reference

  • v The STOP statement can now take an integer or character constant expression asstop code. The ERROR STOP statement initiates error termination of a programwhile the STOP statement initiates normal termination of a program.

    Intrinsic procedures

    v The intrinsic functions ACOS, ASIN, ATAN, COSH, SINH, TAN, and TANH canhave arguments of type complex.

    v The new intrinsic functions ACOSH, ASINH, and ATANH calculate the inversehyperbolic cosine, sine, and tangent respectively.

    v The new intrinsic functions DSHIFTL and DSHIFTR calculate combined left andright shifts.

    v The new intrinsic functions ERF, ERFC, and ERFC_SCALED calculate the errorfunction and its complement.

    v The EXECUTE_COMMAND_LINE subroutine can be used to pass a commandto the operating system for execution.

    v The new intrinsic function FINDLOC searches an array for a value.v The new intrinsic functions GAMMA and LOG_GAMMA calculate the gamma

    function and its log.v The new intrinsic function HYPOT calculates the Euclidean distance.v The new intrinsic function IS_CONTIGUOUS(ARRAY) tests contiguity of an

    array.v The new intrinsic functions LEADZ and TRAILZ return the number of leading

    and trailing zero bits in an integer.v The new intrinsic functions MASKL and MASKR return simple left and right

    justified masks.v A BACK= argument is added to the intrinsic functions MAXLOC and MINLOC.v The new intrinsic functions POPCNT and POPPAR return the number of 1 bits

    of an integer and its parity.v The new intrinsic functions SHIFTA, SHIFTL, and SHIFTR perform shift

    operations.v A RADIX= argument has been added to the intrinsic procedure SELECTED

    REAL KIND.

    Intrinsic modules

    v The functions COMPILER_VERSION and COMPILER_OPTIONS in theISO_FORTRAN_ENV intrinsic module return information about the programtranslation phase.

    v The ISO_FORTRAN_ENV intrinsic module provides the following constants thatare related to the Fortran environment: CHARACTER_KINDS, INT8, INT16,INT32, INT64, INTEGER_KINDS, IOSTAT_INQUIRE_INTERNAL_UNIT,LOGICAL_KINDS, REAL32, REAL64, REAL128, and REAL_KINDS.

    v A RADIX= argument has been added to the IEEE_SELECTED_REAL_KINDintrinsic procedure.

    Programs and procedures

    v A dummy argument that has the POINTER and INTENT(IN) attributes can beargument that is associated with a nonpointer actual argument that has theTARGET attribute. For details, see Pointer dummy argument enhancements.

    v Internal procedures and pointers to internal procedures can be used as actualarguments. Besides, internal procedures can be used as procedure pointertargets.

    Chapter 1. XL Fortran for AIX 3

  • v If a dummy argument of an elemental procedure does not have the VALUEattribute, the dummy argument must have the INTENT attribute specified.

    v In a reference to an elemental procedure, if any actual argument is an array,every actual argument that corresponds to an INTENT(OUT) orINTENT(INOUT) dummy argument must be an array.

    v A separate module subprograms defines a separate module procedure that isdeclared by a corresponding module procedure interface body.

    v Elemental procedures are no longer required to be pure in Fortran 2008. You canexplicitly declare procedures with the IMPURE prefix specifier.

    v The generic resolution rules are extended to distinguish between allocatable andpointer dummy arguments and between procedure and data dummy arguments.For details, see “Unambiguous generic procedure references” on page 167.

    v A double colon separator (::) can be used in PROCEDURE and MODULEPROCEDURE statements inside interface blocks.

    v The FUNCTION and SUBROUTINE keywords can be omitted from the ENDstatement for a module or internal subprogram.

    v You can specify the BIND attribute without the NAME= specifier for an internalprocedure.

    v You can specify the VALUE attribute on an array dummy argument that haseither assumed shape or explicit shape.

    Fortran 2003Fortran 2003 offers many new features and feature enhancements to Fortran 95.Some of the major new features in Fortran 2003 are:v Derived type enhancementsv Object-oriented programming support: type extension, type-bound procedures,

    type finalization, abstract and generic interfaces, polymorphism and PASSattribute

    v Scoping and data manipulation enhancements: allocatable components,VOLATILE attribute, MAX, MIN, MAXLOC, MINLOC, MAXVAL and MINVALintrinsics for character type

    v Input/Output enhancements: User defined derived type I/O, asynchronoustransfer including the WAIT statement

    v Subroutine enhancements: VALUE attribute, Procedure pointers, deferredCHARACTER length

    v Support for IEEE Floating Point Standard (IEEE 1989) exceptionsv Interoperability with the C programming language

    Related informationv “Allocatable and pointer components” on page 52

    Fortran 95The Fortran 95 language standard is upward-compatible with the FORTRAN 77and Fortran 90 language standards, excluding deleted features. Some of theimprovements provided by the Fortran 95 standard are:v Default initializationv ELEMENTAL proceduresv The FORALL construct statementv POINTER initializationv PURE functions

    4 XL Fortran: Language Reference

  • v Specification expressions

    Fortran 90Fortran 90 offers many new features and feature enhancements to FORTRAN 77.The following topics outline some of the key features that Fortran 90 brings to theFORTRAN 77 language:v Array enhancementsv Control construct enhancementsv Derived typesv Dynamic behaviorv Free source formv Modulesv Parameterized data typesv Procedure enhancementsv Pointers

    FORTRAN 77FORTRAN 77 introduced new features and enhancements to FORTRAN 66, formore information see:v The full American National Standard FORTRAN 77 language (referred to as

    FORTRAN 77), defined in the document American National StandardProgramming Language FORTRAN, ANSI X3.9-1978.

    IBM extensionsAn IBM extension generally modifies a rule or restriction from a given standardsimplementation. In this document, IBM extensions to the Fortran 2008, Fortran2003, Fortran 95, and Fortran 90 standards are marked as indicated in theConventions section under Conventions, Standards, and Documentation.

    OpenMP API Version 4.0The OpenMP API provides additional features which you can use to supplementthe existing Technical specification 29113, Fortran 2008, Fortran 2003, and otherlanguage specifications.

    The OpenMP Architecture Review Board (ARB) responds to questions ofinterpretation about aspects of the API. Some of these questions can relate tointerface features implemented in this version of the XL Fortran compiler.Responses provided by this board relating to the interface can result in changes infuture releases of the XL Fortran compiler. These changes may result inincompatibilities with previous releases of the product.

    You can find information pertaining to the implementation of OpenMP API Version4.0 in the following sections:v OpenMP environment variables in the XL Fortran Optimization and Programming

    Guide

    v SMP Directives in the XL Fortran Optimization and Programming Guide

    Chapter 1. XL Fortran for AIX 5

  • Standards documentsXL Fortran is designed according to the standards listed in the Standardsdocuments section. You can refer to these standards for precise definitions of someof the features found in this document.

    6 XL Fortran: Language Reference

  • Chapter 2. XL Fortran language fundamentals

    This section describes the fundamental aspects of an XL Fortran application. Referto the following headings for more information:

    CharactersThe XL Fortran character set consists of letters, digits, and special characters:

    Table 4. The XL Fortran character set

    Letters Digits Special Characters

    A N a nB O b oC P c pD Q d qE R e rF S f sG T g tH U h uI V i vJ W j wK X k xL Y l yM Z m z

    0123456789

    BlankTab

    = Equal sign+ Plus sign- Minus sign* Asterisk/ Slash( Left parenthesis) Right parenthesis[ Right square bracket] Left square bracket, Comma. Decimal point / period$ Currency symbol’ Apostrophe: Colon! Exclamation point" Double quotation mark% Percent sign& Ampersand; Semicolon? Question mark< Less than> Greater than_ Underscore

    The characters have an order known as a collating sequence, which is thearrangement of characters that determines their sequence order for such processesas sorting, merging, and comparing. XL Fortran uses American National StandardCode for Information Interchange (ASCII) to determine the ordinal sequence ofcharacters. See “ASCII and EBCDIC character sets” on page 1036 for a completelisting of the ASCII character set.

    White space refers to blanks and tabs. The significance of white space depends onthe source format. See “Lines and source formats” on page 10 for details.

    A lexical token is a sequence of characters with an indivisible interpretation thatforms a building block of a program. A lexical token can be a keyword, name,literal constant (not of type complex), operator, label, delimiter, comma, equal sign,colon, semicolon, percent sign, ::, or =>.

    © Copyright IBM Corp. 1996, 2015 7

  • NamesA name is a sequence of any or all of the following elements:v Letters (A-Z, a-z)v Digits (0-9)v Underscores (_)v Dollar signs ($)

    The first character of a name must not be a digit.

    In Fortran 2003, the maximum length of a name is 63 characters. In Fortran 90 andFortran 95, the maximum length of a name is 31 characters.

    IBM extension

    In XL Fortran, the maximum length of a name is 250 characters. Although you canbegin a name with an underscore, the AIX operating system as well as the XLFortran compiler and libraries use reserved names that begin with underscores.

    The compiler translates all letters in a source program into lowercase unless theyare in a character context. Character context refers to characters within characterliteral constants, character-string edit descriptors, and Hollerith constants.

    Note: When you specify the -qmixed compiler option, the compiler does nottranslate names to lowercase. For example, XL Fortran treatsia Ia iA IA

    the same by default, but treats lower and uppercase letters as distinct if youspecify -qmixed.

    End of IBM extension

    A name can identify entities such as:v A variablev A named constantv A procedurev A derived typev A constructv A CRITICAL constructv A program unitv A common blockv A namelist group

    DesignatorsA designator is a name that identifies a data object followed by zero or moreselectors such as array element selectors, array section selectors, substring selectors,

    F2008 complex part selectors F2008 , and component selectors. A subobjectdesignator identifies the following items:v An array elementv An array sectionv A character substring

    8 XL Fortran: Language Reference

  • v F2008 A complex part F2008v A structure component

    OperatorsIn Fortran an expression is comprised of operands and operators. For a detaileddescription of Fortran operators, see “Operators and expressions” on page 105

    Table 5. XL Fortran operators

    Arithmetic Logical

    Character Primary

    General Relational

    StatementsA Fortran statement is a sequence of lexical tokens. Statements are used to formprogram units.

    The maximum length of a statement in XL Fortran is 34 000 characters.

    See Statements and Attributes for more information on statements supported byXL Fortran.

    Statement keywordsA statement keyword is part of the syntax of a statement. A sequence of charactersis not reserved in all contexts. A statement keyword is interpreted as an entityname if the keyword is used in such a context.

    Statement labelsA statement label is a sequence of one to five digits, one of which must benonzero, that you can use to identify statements in a Fortran scoping unit. In fixedsource form, a statement label can appear anywhere in columns 1 through 5 of theinitial line of the statement. In free source form, such column restrictions do notapply.

    XL Fortran ignores all characters that appear in columns 1 through 5 on

    fixed source form continuation lines.

    Giving the same label to more than one statement in a scoping unit causesambiguity, and the compiler generates an error. White space and leading zeros arenot significant in distinguishing between statement labels. You can label anystatement, but a statement label reference can only refer to an executable statementor a FORMAT statement. The statement making the reference and the statementreferenced must be in the same scoping unit for the reference to resolve.

    DelimitersDelimiters are pairs used to enclose syntactic lists. XL Fortran supports thefollowing delimiters:v Parentheses: (...)v Slashes: /.../

    Chapter 2. XL Fortran language fundamentals 9

  • v Array constructors: (/.../)v Array constructors: [...]

    Lines and source formatsA line is a horizontal arrangement of characters. A column is a verticalarrangement of characters, where each character, or each byte of a multibytecharacter, in a given column shares the same horizontal line position.

    Because XL Fortran measures lines in bytes, these definitions apply only

    to lines containing single-byte characters. Each byte of a multibyte characteroccupies one column.

    The kinds of lines are:

    Initial line Is the first line of a statement.

    Continuationline

    Continues a statement beyond its initial line.

    Comment line Does not affect the executable program and can be used fordocumentation. The comment text continues to the end of a line.Although comment lines can follow one another, a comment line cannotbe continued. A line of all white space or a zero-length line is acomment line without any text. Comment text can contain anycharacters allowed in a character context.

    If an initial line or continuation line is not continued, or if it iscontinued but not in a character context, an inline comment can beplaced on the same line, to the right of any statement label, statementtext, and continuation character that may be present. An exclamationmark (!) begins an inline comment.

    Conditionalcompilation line

    Indicates that the line should only be compiled if recognition ofconditional compilation lines is enabled. A conditional compilationsentinel should appear on a conditional compilation line. For moreinformation, see Conditional compilation.

    Debug Line Indicates that the line is for debugging code (for fixed source formonly). In XL Fortran the letter D or X must be specified in column 1. Formore information, see Debug lines.

    Directive line Provides instructions or information to the compiler in XL Fortran. Formore information, see Comment form directives.

    IBM extension

    In XL Fortran source lines can be in fixed source form or free source form format.Use the SOURCEFORM directive to mix source formats within the same programunit. When you use the f77 , fort77, or xlf_r7 invocation command, fixed sourceform is the default. When you use xlf or xlf_r to compile the .f, .F, .f77, or .F77files, fixed source form is also the default. When you use the f90, xlf90, xlf90_r,xlf90_r7, f95, xlf95, xlf95_r, xlf95_r7, f2003, xlf2003, xlf2003_r, f2008, xlf2008, orxlf2008_r invocation command, Fortran 90 free source form is the default.

    See Compiling XL Fortran Programs in the XL Fortran Compiler Reference for detailson invocation commands.

    End of IBM extension

    10 XL Fortran: Language Reference

  • Fixed source formA fixed source form line is a sequence of 1 to 132 characters. The default

    line size is 72 characters. This is also the Fortran standard line size. You can changethe default using the -qfixed=right_margin compiler option. In XL Fortran there isno limit to the number of continuation lines for a statement, but the statementcannot be longer than 34 000 characters. Fortran 2003 limits the number ofcontinuation lines to 255, while Fortran 95 limits the number of continuation linesto 19.

    I