Contents

About this document
Who should read this document
How to use this document
How this document is organized
Conventions and terminology used in this document
Typographical conventions
Qualifying elements (icons and bracket separators)
How to read syntax diagrams
Examples
Related information
IBM XL Fortran documentation
Additional documentation
Related documentation
Standards documents
Technical support
How to send your comments
XL Fortran for Linux
Language standards
Fortran 2003 Standard
Fortran 95
Fortran 90
IBM Extensions
Other standards and standards documents
Fundamentals of the XL Fortran language
Characters
Names
Statements
Statement keywords
Statement labels
Lines and source formats
Fixed source form
Free source form
IBM free source form
Conditional compilation
Order of statements and execution sequence
Data types and data objects
Data types
Type parameters and specifiers
Data objects
Constants
Automatic objects
Intrinsic types
Integer
Real
Vector
Pixel
Unsigned
Complex
Logical
Character
BYTE
Derived types
Default initialization
Input/Output
Determining declared type for derived types
Structure components
Structure constructor
Record structures
Union and map
Typeless literal constants
Hexadecimal constants
Octal constants
Binary constants
Hollerith constants
Using typeless constants
How type is determined
Definition status of variables
Events causing definition
Events causing undefinition
Allocation status
Storage classes for variables
Fundamental storage classes
Secondary storage classes
Storage class assignment
Array concepts
Arrays
Bounds of a dimension
Extent of a dimension
Rank, shape, and size of an array
Array declarators
Explicit-shape arrays
Examples of explicit-shape arrays
Automatic arrays
Adjustable arrays
Pointee arrays
Assumed-shape arrays
Examples of assumed-shape arrays
Deferred-shape arrays
Allocatable arrays
Array pointers
Assumed-size arrays
Examples of assumed-size arrays
Array elements
Notes
Array element order
Array sections
Subscript triplets
Vector subscripts
Array sections and substring ranges
Array sections and structure components
Rank and shape of array sections
Array constructors
Implied-DO list for an array constructor
Expressions involving arrays
Expressions and assignment
Introduction to expressions and assignment
Primary
Constant expressions
Examples of constant expressions
Initialization expressions
Examples of initialization expressions
Specification expressions
Examples of specification expressions
Operators and expressions
Arithmetic
Character
General
Logical
Primary
Relational
Extended intrinsic and defined operations
How expressions are evaluated
Precedence of operators
Using BYTE data objects
Intrinsic assignment
Arithmetic conversion
WHERE construct
Interpreting masked array assignments
FORALL construct
Interpreting the FORALL construct
Pointer assignment
Examples of pointer assignment
Procedure pointer assignment
Integer pointer assignment
Example of integer pointer assignment
Execution Control
statement blocks
ASSOCIATE Construct
DO construct
The terminal statement
DO WHILE construct
Example
IF construct
Example
SELECT CASE construct
Examples
Branching
Program units and procedures
Scope
The scope of a name
Association
Host association
Use association
Construct Association
Pointer association
Integer pointer association
Program units, procedures, and subprograms
Internal procedures
Interface concepts
Interface blocks
Example of an interface Block
Generic interface blocks
Unambiguous generic procedure references
Extending intrinsic procedures with generic interface blocks
Defined operators
Defined assignment
Main program
Modules
Example of a module
Block data program unit
Example of a block data program unit
Function and subroutine subprograms
Procedure references
Intrinsic procedures
Conflicts between intrinsic procedure names and other names
Arguments
Actual argument specification
Argument association
%VAL and %REF
Intent of dummy arguments
Optional dummy arguments
Restrictions on optional dummy arguments not present
Length of character arguments
Variables as dummy arguments
Allocatable objects as dummy arguments
Pointers as dummy arguments
Procedures as dummy arguments
Asterisks as dummy arguments
Resolution of procedure references
Rules for resolving procedure references to names
Resolving procedure references to generic names
Recursion
Pure procedures
Examples
Elemental Procedures
Examples
XL Fortran Input/Output
Records
Formatted records
Unformatted records
Endfile records
Files
Definition of an external file
File access methods
Units
Connection of a unit
Data transfer statements
Asynchronous Input/Output
Advancing and nonadvancing Input/Output
File position before and after data transfer
Conditions and IOSTAT values
End-of-record conditions
End-of-file conditions
Error conditions
Input/Output formatting
Format-directed formatting
Complex editing
Data edit descriptors
Control edit descriptors
Character string edit descriptors
Interaction of Input/Output lists and format specifications
Comma-separated Input/Output
Data edit descriptors
A (Character) Editing
B (Binary) Editing
E, D, and Q (Extended Precision) Editing
EN Editing
ES Editing
F (Real without Exponent) Editing
G (General) Editing
H Editing
I (Integer) Editing
L (Logical) Editing
O (Octal) Editing
Q (Character Count) Editing
Z (Hexadecimal) Editing
Control edit descriptors
/ (Slash) Editing
: (Colon) Editing
$ (Dollar) Editing
BN (Blank Null) and BZ (Blank Zero) Editing
P (Scale Factor) Editing
S, SP, and SS (Sign Control) Editing
T, TL, TR, and X (Positional) Editing
List-directed formatting
Value separators
List-directed input
List-directed output
Namelist formatting
Namelist input
Namelist output
Statements and attributes
Attributes
ALLOCATABLE
ALLOCATE
ASSIGN
ASSOCIATE
AUTOMATIC
BACKSPACE
BIND
BLOCK DATA
BYTE
CALL
CASE
CHARACTER
CLOSE
COMMON
Common association
COMPLEX
CONTAINS
CONTINUE
CYCLE
DATA
DEALLOCATE
Derived Type
DIMENSION
DO
DO WHILE
DOUBLE COMPLEX
DOUBLE PRECISION
ELSE
ELSE IF
ELSEWHERE
END
END (Construct)
END INTERFACE
END TYPE
ENDFILE
ENTRY
Recursion
ENUM/END ENUM
EQUIVALENCE
EXIT
EXTERNAL
FLUSH
FORALL
Interpreting the FORALL statement
Loop parallelization
FORALL (construct)
FORMAT
Character format specification
FUNCTION
Recursion
Elemental procedures
GO TO (assigned)
GO TO (computed)
GO TO (unconditional)
IF (arithmetic)
IF (block)
IF (logical)
IMPLICIT
IMPORT
INQUIRE
INTEGER
INTENT
INTERFACE
INTRINSIC
LOGICAL
MODULE
MODULE PROCEDURE
NAMELIST
NULLIFY
OPEN
OPTIONAL
PARAMETER
PAUSE
POINTER (Fortran 90)
POINTER (integer)
PRINT
Implied-DO List
PRIVATE
PROCEDURE
PROGRAM
PROTECTED
PUBLIC
READ
Implied-DO List
REAL
RECORD
RETURN
REWIND
SAVE
SELECT CASE
SEQUENCE
Statement Function
STATIC
STOP
SUBROUTINE
TARGET
TYPE
Type Declaration
USE
VALUE
VECTOR
VIRTUAL
VOLATILE
WAIT
WHERE
WRITE
Implied-DO List
Directives
Comment and noncomment form directives
Comment form directives
Noncomment form directives
Directives and optimization
Assertive directives
Directives for Loop Optimization
Detailed directive descriptions
ASSERT
BLOCK_LOOP
CNCALL
COLLAPSE
EJECT
INCLUDE
INDEPENDENT
#LINE
LOOPID
NEW
NOSIMD
NOVECTOR
PERMUTATION
@PROCESS
SNAPSHOT
SOURCEFORM
STREAM_UNROLL
SUBSCRIPTORDER
UNROLL
UNROLL_AND_FUSE
Hardware-specific directives
CACHE_ZERO
EIEIO
ISYNC
LIGHT_SYNC
PREFETCH
PROTECTED STREAM
Intrinsic procedures
Classes of intrinsic procedures
Inquiry intrinsic functions
Elemental intrinsic procedures
System inquiry intrinsic functions
Transformational intrinsic functions
Intrinsic subroutines
Data representation models
Integer bit model
Integer data model
Real data model
Detailed descriptions of intrinsic procedures
ABORT()
ABS(A)
ACHAR(I)
ACOS(X)
ACOSD(X)
ADJUSTL(STRING)
ADJUSTR(STRING)
AIMAG(Z), IMAG(Z)
AINT(A, KIND)
ALIGNX(K,M)
ALL(MASK, DIM)
ALLOCATED(X)
ANINT(A, KIND)
ANY(MASK, DIM)
ASIN(X)
ASIND(X)
ASSOCIATED(POINTER, TARGET)
ATAN(X)
ATAND(X)
ATAN2(Y, X)
ATAN2D(Y, X)
BIT_SIZE(I)
BTEST(I, POS)
CEILING(A, KIND)
CHAR(I, KIND)
CMPLX(X, Y, KIND)
COMMAND_ARGUMENT_COUNT()
CONJG(Z)
COS(X)
COSD(X)
COSH(X)
COUNT(MASK, DIM)
CPU_TIME(TIME)
CSHIFT(ARRAY, SHIFT, DIM)
CVMGx(TSOURCE, FSOURCE, MASK)
DATE_AND_TIME(DATE, TIME, ZONE, VALUES)
DBLE(A)
DCMPLX(X, Y)
DIGITS(X)
DIM(X, Y)
DOT_PRODUCT(VECTOR_A, VECTOR_B)
DPROD(X, Y)
EOSHIFT(ARRAY, SHIFT, BOUNDARY, DIM)
EPSILON(X)
ERF(X)
ERFC(X)
EXP(X)
EXPONENT(X)
FLOOR(A, KIND)
FRACTION(X)
GAMMA(X)
GETENV(NAME, VALUE)
GET_COMMAND(COMMAND, LENGTH, STATUS)
GET_COMMAND_ARGUMENT(NUMBER, VALUE, LENGTH, STATUS)
GET_ENVIRONMENT_VARIABLE(NAME, VALUE, LENGTH, STATUS, TRIM_NAME)
HFIX(A)
HUGE(X)
IACHAR(C)
IAND(I, J)
IBCLR(I, POS)
IBITS(I, POS, LEN)
IBSET(I, POS)
ICHAR(C)
IEOR(I, J)
ILEN(I)
IMAG(Z)
INDEX(STRING, SUBSTRING, BACK)
INT(A, KIND)
INT2(A)
IOR(I, J)
ISHFT(I, SHIFT)
ISHFTC(I, SHIFT, SIZE)
KIND(X)
LBOUND(ARRAY, DIM)
LEADZ(I)
LEN(STRING)
LEN_TRIM(STRING)
LGAMMA(X)
LGE(STRING_A, STRING_B)
LGT(STRING_A, STRING_B)
LLE(STRING_A, STRING_B)
LLT(STRING_A, STRING_B)
LOC(X)
LOG(X)
LOG10(X)
LOGICAL(L, KIND)
LSHIFT(I, SHIFT)
MATMUL(MATRIX_A, MATRIX_B, MINDIM)
MAX(A1, A2, A3, ...)
MAXEXPONENT(X)
MAXLOC(ARRAY, DIM, MASK) or MAXLOC(ARRAY, MASK)
MAXVAL(ARRAY, DIM, MASK) or MAXVAL(ARRAY, MASK)
MERGE(TSOURCE, FSOURCE, MASK)
MIN(A1, A2, A3, ...)
MINEXPONENT(X)
MINLOC(ARRAY, DIM, MASK) or MINLOC(ARRAY, MASK)
MINVAL(ARRAY, DIM, MASK) or MINVAL(ARRAY, MASK)
MOD(A, P)
MODULO(A, P)
MVBITS(FROM, FROMPOS, LEN, TO, TOPOS)
NEAREST(X,S)
NEW_LINE(A)
NINT(A, KIND)
NOT(I)
NULL(MOLD)
NUM_PARTHDS()
NUMBER_OF_PROCESSORS(DIM)
NUM_USRTHDS()
PACK(ARRAY, MASK, VECTOR)
POPCNT(I)
POPPAR(I)
PRECISION(X)
PRESENT(A)
PROCESSORS_SHAPE()
PRODUCT(ARRAY, DIM, MASK) or PRODUCT(ARRAY, MASK)
QCMPLX(X, Y)
QEXT(A)
RADIX(X)
RAND()
RANDOM_NUMBER(HARVEST)
RANDOM_SEED(SIZE, PUT, GET, GENERATOR)
RANGE(X)
REAL(A, KIND)
REPEAT(STRING, NCOPIES)
RESHAPE(SOURCE, SHAPE, PAD, ORDER)
RRSPACING(X)
RSHIFT(I, SHIFT)
SCALE(X,I)
SCAN(STRING, SET, BACK)
SELECTED_INT_KIND(R)
SELECTED_REAL_KIND(P, R)
SET_EXPONENT(X,I)
SHAPE(SOURCE)
SIGN(A, B)
SIGNAL(I, PROC)
SIN(X)
SIND(X)
SINH(X)
SIZE(ARRAY, DIM)
SIZEOF(A)
SPACING(X)
SPREAD(SOURCE, DIM, NCOPIES)
SQRT(X)
SRAND(SEED)
SUM(ARRAY, DIM, MASK) or SUM(ARRAY, MASK)
SYSTEM(CMD, RESULT)
SYSTEM_CLOCK(COUNT, COUNT_RATE, COUNT_MAX)
TAN(X)
TAND(X)
TANH(X)
TINY(X)
TRANSFER(SOURCE, MOLD, SIZE)
TRANSPOSE(MATRIX)
TRIM(STRING)
UBOUND(ARRAY, DIM)
UNPACK(VECTOR, MASK, FIELD)
VERIFY(STRING, SET, BACK)
Hardware-specific intrinsic procedures
FCFI(I)
FCTID(X)
FCTIDZ(X)
FCTIW(X)
FCTIWZ(X)
FMADD(A, X, Y)
FMSUB(A, X, Y)
FNABS(X)
FNMADD(A, X, Y)
FNMSUB(A, X, Y)
FRE(X)
FRES(X)
FRIM(A)
FRIN(A)
FRIP(A)
FRIZ(A)
FRSQRTE(X)
FRSQRTES(X)
FSEL(X,Y,Z)
MTFSF(MASK, R)
MTFSFI(BF, I)
MULHY(RA, RB)
POPCNTB(I)
ROTATELI(RS, IS, SHIFT, MASK)
ROTATELM(RS, SHIFT, MASK)
SETFSB0(BT)
SETFSB1(BT)
SFTI(M, Y)
SWDIV(X,Y)
SWDIV_NOCHK(X,Y)
TRAP(A, B, TO)
VMX intrinsic procedures
VEC_ABS(ARG1)
VEC_ABSS(ARG1)
VEC_ADD(ARG1, ARG2)
VEC_ADDC(ARG1, ARG2)
VEC_ADDS(ARG1, ARG2)
VEC_ALL_EQ(ARG1, ARG2)
VEC_ALL_GE(ARG1, ARG2)
VEC_ALL_GT(ARG1, ARG2)
VEC_ALL_IN(ARG1, ARG2)
VEC_ALL_LE(ARG1, ARG2)
VEC_ALL_LT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G1)
VEC_UNPACKL(ARG1)
VEC_XOR(ARG1, ARG2)
Language interoperability features
Interoperability of types
Intrinsic types
Derived types
Interoperability of Variables
Interoperability of common blocks
Interoperability of procedures
The ISO_C_BINDING module
Constants for use as kind type parameters
Character constants
Other constants
Types
Procedures
Binding labels
The ISO_FORTRAN_ENV intrinsic module
CHARACTER_STORAGE_SIZE
ERROR_UNIT
FILE_STORAGE_SIZE
INPUT_UNIT
IOSTAT_END
IOSTAT_EOR
NUMERIC_STORAGE_SIZE
OUTPUT_UNIT
Floating-point control and inquiry procedures
fpgets fpsets
Efficient floating-point control and inquiry procedures
xlf_fp_util Floating-Point Procedures
IEEE Modules and support
Compiling and exception handling
General rules for implementing IEEE modules
IEEE Derived data types and constants
IEEE Operators
IEEE PROCEDURES
Rules for floating-point status
Examples
Service and utility procedures
General service and utility procedures
List of service and utility procedures
alarm_(time, func)
bic_(X1, X2)
bis_(X1, X2)
bit_(X1, X2)
clock_()
ctime_(STR, TIME)
date()
dtime_(dtime_struct)
etime_(etime_struct)
exit_(exit_status)
fdate_(str)
fiosetup_(unit, command, argument)
flush_(lunit)
ftell_(lunit)
ftell64_(lunit)
getarg(i1,c1)
getcwd_(name)
getfd(lunit)
getgid_()
getlog_(name)
getpid_()
getuid_()
global_timef()
gmtime_(stime, tarray)
hostnm_(name)
iargc()
idate_(idate_struct)
ierrno_()
irand()
irtc()
itime_(itime_struct)
jdate()
lenchr_(str)
lnblnk_(str)
ltime_(stime, tarray)
mclock()
qsort_(array, len, isize, compar)
qsort_down(array, len, isize)
qsort_up(array, len, isize)
rtc()
setrteopts(c1)
sleep_(sec)
time_()
timef()
timef_delta(t)
umask_(cmask)
usleep_(msec)
xl__trbk()
Appendix A. Compatibility across standards
Fortran 90 compatibility
Obsolescent features
Deleted features
Appendix B. ASCII and EBCDIC character sets
Glossary
Index