Oneapi Fortran Compiler
Oneapi Fortran Compiler
Oneapi Fortran Compiler
Contents
Notices and Disclaimers..................................................................... 47
Intel® Fortran Compiler Classic and Intel® Fortran Compiler
Developer Guide and Reference ..................................................... 48
2
Contents
3
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
hotpatch...................................................................... 168
m ............................................................................... 169
m32, m64, Q32, Q64 .................................................... 171
m80387 ...................................................................... 172
march ......................................................................... 173
masm ......................................................................... 175
mauto-arch, Qauto-arch ................................................ 176
mbranches-within-32B-boundaries, Qbranches-within-32B-
boundaries .............................................................. 177
mconditional-branch, Qconditional-branch........................ 177
minstruction, Qinstruction.............................................. 179
momit-leaf-frame-pointer .............................................. 180
mstringop-inline-threshold, Qstringop-inline-threshold....... 181
mstringop-strategy, Qstringop-strategy ........................... 182
mtune, tune................................................................. 183
Qpatchable-addresses ................................................... 186
x, Qx .......................................................................... 186
xHost, QxHost .............................................................. 190
Interprocedural Optimization (IPO) Options .............................. 193
ffat-lto-objects ............................................................. 193
ip, Qip......................................................................... 194
ip-no-inlining, Qip-no-inlining ......................................... 195
ip-no-pinlining, Qip-no-pinlining ..................................... 196
ipo, Qipo ..................................................................... 196
ipo-c, Qipo-c ................................................................ 198
ipo-jobs, Qipo-jobs ....................................................... 198
ipo-S, Qipo-S ............................................................... 199
ipo-separate, Qipo-separate ........................................... 200
Advanced Optimization Options............................................... 201
ansi-alias, Qansi-alias ................................................... 201
coarray, Qcoarray ......................................................... 202
coarray-config-file, Qcoarray-config-file ........................... 203
coarray-num-images, Qcoarray-num-images .................... 204
complex-limited-range, Qcomplex-limited-range ............... 205
guide, Qguide .............................................................. 206
guide-data-trans, Qguide-data-trans ............................... 208
guide-file, Qguide-file.................................................... 208
guide-file-append, Qguide-file-append ............................. 210
guide-opts, Qguide-opts ................................................ 211
guide-par, Qguide-par ................................................... 213
guide-vec, Qguide-vec................................................... 214
heap-arrays ................................................................. 215
pad, Qpad ................................................................... 216
qmkl, Qmkl.................................................................. 217
qopt-args-in-regs, Qopt-args-in-regs............................... 219
qopt-assume-safe-padding, Qopt-assume-safe-padding ..... 220
qopt-block-factor, Qopt-block-factor ................................ 221
qopt-dynamic-align, Qopt-dynamic-align.......................... 221
qopt-for-throughput, Qopt-for-throughput........................ 222
qopt-jump-tables, Qopt-jump-tables ............................... 223
qopt-malloc-options ...................................................... 224
qopt-matmul, Qopt-matmul ........................................... 225
qopt-mem-layout-trans, Qopt-mem-layout-trans............... 226
qopt-multi-version-aggressive, Qopt-multi-version-
aggressive ............................................................... 227
4
Contents
qopt-multiple-gather-scatter-by-shuffles, Qopt-multiple-
gather-scatter-by-shuffles.......................................... 228
qopt-prefetch, Qopt-prefetch.......................................... 229
qopt-prefetch-distance, Qopt-prefetch-distance ................ 231
qopt-prefetch-issue-excl-hint, Qopt-prefetch-issue-excl-hint232
qopt-ra-region-strategy, Qopt-ra-region-strategy .............. 233
qopt-streaming-stores, Qopt-streaming-stores ................. 234
qopt-subscript-in-range, Qopt-subscript-in-range .............. 235
qopt-zmm-usage, Qopt-zmm-usage ................................ 236
qoverride-limits, Qoverride-limits.................................... 237
reentrancy ................................................................... 238
safe-cray-ptr, Qsafe-cray-ptr .......................................... 239
scalar-rep, Qscalar-rep .................................................. 241
simd, Qsimd ................................................................ 241
unroll, Qunroll .............................................................. 242
unroll-aggressive, Qunroll-aggressive .............................. 243
vec, Qvec .................................................................... 244
vec-guard-write, Qvec-guard-write.................................. 245
vec-threshold, Qvec-threshold ........................................ 246
vecabi, Qvecabi ............................................................ 247
Profile Guided Optimization (PGO) Options ............................... 249
finstrument-functions, Qinstrument-functions ................... 249
fnsplit, Qfnsplit............................................................. 250
p ................................................................................ 251
prof-data-order, Qprof-data-order ................................... 252
prof-dir, Qprof-dir ......................................................... 253
prof-file, Qprof-file ........................................................ 253
prof-func-groups .......................................................... 254
prof-func-order, Qprof-func-order.................................... 255
prof-gen, Qprof-gen ...................................................... 256
prof-gen-sampling ........................................................ 258
prof-hotness-threshold, Qprof-hotness-threshold .............. 259
prof-src-dir, Qprof-src-dir............................................... 260
prof-src-root, Qprof-src-root .......................................... 261
prof-src-root-cwd, Qprof-src-root-cwd ............................. 262
prof-use, Qprof-use....................................................... 263
prof-use-sampling ........................................................ 264
prof-value-profiling, Qprof-value-profiling......................... 265
Qcov-dir ...................................................................... 266
Qcov-file ..................................................................... 267
Qcov-gen..................................................................... 268
Optimization Report Options ................................................... 269
qopt-report, Qopt-report................................................ 269
qopt-report-annotate, Qopt-report-annotate..................... 270
qopt-report-annotate-position, Qopt-report-annotate-
position ................................................................... 272
qopt-report-embed, Qopt-report-embed .......................... 273
qopt-report-file, Qopt-report-file ..................................... 273
qopt-report-filter, Qopt-report-filter ................................. 274
qopt-report-format, Qopt-report-format ........................... 276
qopt-report-help, Qopt-report-help.................................. 277
qopt-report-per-object, Qopt-report-per-object................. 278
qopt-report-phase, Qopt-report-phase ............................. 279
qopt-report-routine, Qopt-report-routine.......................... 283
qopt-report-names, Qopt-report-names ........................... 283
5
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
6
Contents
7
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
EP .............................................................................. 404
fpp ............................................................................. 405
fpp-name .................................................................... 406
gen-dep ...................................................................... 407
gen-depformat ............................................................. 409
gen-depshow ............................................................... 409
I................................................................................. 410
idirafter ....................................................................... 411
isystem ....................................................................... 412
module ....................................................................... 413
preprocess-only............................................................ 413
u (Windows*) .............................................................. 414
U................................................................................ 415
undef .......................................................................... 415
X ................................................................................ 416
Component Control Options.................................................... 417
Qinstall ....................................................................... 417
Qlocation..................................................................... 417
Qoption ....................................................................... 419
Language Options ................................................................. 420
allow........................................................................... 420
altparam ..................................................................... 421
assume ....................................................................... 422
ccdefault ..................................................................... 435
check .......................................................................... 435
extend-source .............................................................. 440
fixed ........................................................................... 441
free ............................................................................ 442
iface ........................................................................... 442
names......................................................................... 446
pad-source, Qpad-source............................................... 447
stand .......................................................................... 448
standard-realloc-lhs ...................................................... 450
standard-semantics ...................................................... 450
syntax-only.................................................................. 451
wrap-margin ................................................................ 452
Data Options ........................................................................ 453
align ........................................................................... 453
auto............................................................................ 456
auto-scalar, Qauto-scalar ............................................... 457
convert ....................................................................... 458
double-size .................................................................. 460
dyncom, Qdyncom ........................................................ 461
falign-functions, Qfnalign ............................................... 462
falign-loops, Qalign-loops .............................................. 463
falign-stack.................................................................. 465
fcommon ..................................................................... 466
fkeep-static-consts, Qkeep-static-consts .......................... 466
fmath-errno ................................................................. 467
fminshared .................................................................. 468
fpconstant ................................................................... 469
fpic ............................................................................. 470
fpie............................................................................. 471
fstack-protector............................................................ 471
fstack-security-check .................................................... 473
8
Contents
9
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
map............................................................................ 535
MD ............................................................................. 536
MDs ............................................................................ 537
MT.............................................................................. 538
nodefaultlibs ................................................................ 538
nofor-main .................................................................. 539
no-intel-lib................................................................... 540
nostartfiles .................................................................. 541
nostdlib ....................................................................... 541
pie.............................................................................. 542
pthread ....................................................................... 543
shared ........................................................................ 544
shared-intel ................................................................. 544
shared-libgcc ............................................................... 545
static .......................................................................... 546
static-intel ................................................................... 547
static-libgcc ................................................................. 548
static-libstdc++............................................................ 548
staticlib ....................................................................... 549
T ................................................................................ 550
threads ....................................................................... 550
v ................................................................................ 552
Wa ............................................................................. 553
winapp ........................................................................ 553
Wl .............................................................................. 554
Wp ............................................................................. 555
Xlinker ........................................................................ 555
Miscellaneous Options ........................................................... 556
bigobj ......................................................................... 556
dryrun......................................................................... 557
dumpmachine .............................................................. 558
extfor.......................................................................... 558
extfpp ......................................................................... 559
global-hoist, Qglobal-hoist ............................................. 560
help ............................................................................ 560
intel-freestanding ......................................................... 562
intel-freestanding-target-os ........................................... 563
libdir ........................................................................... 564
logo ............................................................................ 565
multiple-processes, MP .................................................. 566
save-temps, Qsave-temps ............................................. 567
sox ............................................................................. 568
sysroot........................................................................ 570
Tf ............................................................................... 570
watch.......................................................................... 571
what ........................................................................... 572
Alternate Compiler Options............................................................. 573
Floating-Point Operations ....................................................................... 577
Understanding Floating-Point Operations .......................................... 577
Programming Tradeoffs in Floating-point Applications................. 577
Floating-point Optimizations ................................................... 580
Using the -fp-model (/fp) Option............................................. 581
Subnormal Numbers.............................................................. 582
Floating-Point Environment .................................................... 583
Setting the FTZ and DAZ Flags ............................................... 583
10
Contents
11
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
12
Contents
13
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
14
Contents
15
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
16
Contents
17
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
18
Contents
19
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
ROUND Specifier..................................................................1080
SHARE Specifier...................................................................1081
SHARED Specifier ................................................................1082
SIGN Specifier .....................................................................1082
STATUS Specifier .................................................................1083
TITLE Specifier ....................................................................1084
TYPE Specifier .....................................................................1084
USEROPEN Specifier .............................................................1084
Compilation Control Lines and Statements ...............................................1085
Directive Enhanced Compilation..............................................................1085
Syntax Rules for Compiler Directives...............................................1086
General Compiler Directives...........................................................1086
Rules for Placement of Directives ...........................................1088
Rules for General Directives that Affect DO Loops.....................1089
Rules for Loop Directives that Affect Array Assignment
Statements .....................................................................1090
OpenMP* Fortran Compiler Directives .............................................1090
Clauses Used in Multiple OpenMP* Fortran Directives ................1095
Conditional Compilation Rules................................................1097
Nesting and Binding Rules.....................................................1098
Equivalent Compiler Options ..........................................................1099
Scope and Association...........................................................................1100
Scope .........................................................................................1100
Unambiguous Generic Procedure References ....................................1103
Resolving Procedure References .....................................................1104
References to Generic Names ................................................1104
References to Specific Names ................................................1106
References to Nonestablished Names......................................1106
Association..................................................................................1107
Name Association ................................................................1108
Argument Association...................................................1108
Use and Host Association Overview ................................1111
Linkage Association......................................................1113
Construct Association ...................................................1113
Pointer Association ...............................................................1114
Storage Association..............................................................1115
Storage Units and Storage Sequence..............................1115
Array Association.........................................................1117
Inheritance Association.........................................................1117
Deleted and Obsolescent Language Features ............................................1118
Deleted Language Features in the Fortran Standard ..........................1118
Obsolescent Language Features in the Fortran Standard ....................1121
Additional Language Features.................................................................1122
FORTRAN 66 Interpretation of the EXTERNAL Statement ...................1122
Alternative Syntax for the PARAMETER Statement ............................1123
Alternative Syntax for Binary, Octal, and Hexadecimal Constants ........1124
Alternative Syntax for a Record Specifier .........................................1125
Alternative Syntax for the DELETE Statement ..................................1125
Alternative Form for Namelist External Records ................................1125
Record Structures ........................................................................1126
Structure Declarations ..........................................................1127
Type Declarations within Record Structures .....................1127
Substructure Declarations .............................................1127
References to Record Fields ...................................................1128
Aggregate Assignment..........................................................1130
20
Contents
21
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
22
Contents
ASSUME_ALIGNED ...............................................................1245
ASYNCHRONOUS .................................................................1247
ATAN..................................................................................1248
ATAN2 ................................................................................1248
ATAN2D ..............................................................................1249
ATAND................................................................................1250
ATANH................................................................................1251
ATOMIC ..............................................................................1251
ATOMIC_ADD ......................................................................1257
ATOMIC_AND ......................................................................1258
ATOMIC_CAS.......................................................................1258
ATOMIC_DEFINE ..................................................................1259
ATOMIC_FETCH_ADD ...........................................................1260
ATOMIC_FETCH_AND............................................................1261
ATOMIC_FETCH_OR..............................................................1261
ATOMIC_FETCH_XOR............................................................1262
ATOMIC_OR ........................................................................1263
ATOMIC_REF .......................................................................1263
ATOMIC_XOR ......................................................................1264
ATTRIBUTES........................................................................1265
ATTRIBUTES ALIAS ......................................................1268
ATTRIBUTES ALIGN......................................................1268
ATTRIBUTES ALLOCATABLE ...........................................1269
ATTRIBUTES ALLOW_NULL............................................1270
ATTRIBUTES C and STDCALL ........................................1270
ATTRIBUTES CODE_ALIGN ............................................1272
ATTRIBUTES CONCURRENCY_SAFE ................................1273
ATTRIBUTES CVF .........................................................1274
ATTRIBUTES DECORATE ...............................................1274
ATTRIBUTES DEFAULT ..................................................1275
ATTRIBUTES DLLEXPORT and DLLIMPORT .......................1275
ATTRIBUTES EXTERN ...................................................1276
ATTRIBUTES INLINE, NOINLINE, and FORCEINLINE ..........1276
ATTRIBUTES IGNORE_LOC ............................................1277
ATTRIBUTES MIXED_STR_LEN_ARG and
NOMIXED_STR_LEN_ARG .........................................1277
ATTRIBUTES NO_ARG_CHECK .......................................1277
ATTRIBUTES NOCLONE .................................................1278
ATTRIBUTES OPTIMIZATION_PARAMETER .......................1278
ATTRIBUTES REFERENCE and VALUE ..............................1280
ATTRIBUTES VARYING ..................................................1281
ATTRIBUTES VECTOR ...................................................1281
AUTOAddArg (W*S) .............................................................1286
AUTOAllocateInvokeArgs (W*S) .............................................1287
AUTODeallocateInvokeArgs (W*S) .........................................1287
AUTOGetExceptInfo (W*S) ....................................................1288
AUTOGetProperty (W*S) .......................................................1288
AUTOGetPropertyByID (W*S) ................................................1289
AUTOGetPropertyInvokeArgs (W*S) .......................................1290
AUTOInvoke (W*S) ..............................................................1290
AUTOMATIC ........................................................................1291
AUTOSetProperty (W*S) .......................................................1293
AUTOSetPropertyByID (W*S) ................................................1294
AUTOSetPropertyInvokeArgs (W*S)........................................1294
BACKSPACE ........................................................................1294
23
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
BADDRESS..........................................................................1295
BARRIER.............................................................................1296
BEEPQQ..............................................................................1297
BESJ0, BESJ1, BESJN, BESY0, BESY1, BESYN ..........................1297
BESSEL_J0..........................................................................1298
BESSEL_J1..........................................................................1299
BESSEL_JN .........................................................................1299
BESSEL_Y0 .........................................................................1300
BESSEL_Y1 .........................................................................1300
BESSEL_YN .........................................................................1300
BGE ...................................................................................1301
BGT ...................................................................................1302
BIC, BIS .............................................................................1302
BIND..................................................................................1303
BIT ....................................................................................1304
BIT_SIZE ............................................................................1305
BLE....................................................................................1305
BLOCK................................................................................1306
BLOCK DATA .......................................................................1308
BLOCK_LOOP and NOBLOCK_LOOP ........................................1310
BLT ....................................................................................1312
BSEARCHQQ .......................................................................1312
BTEST ................................................................................1314
BYTE ..................................................................................1315
C to D ........................................................................................1315
C to D ................................................................................1316
C_ASSOCIATED ...................................................................1316
C_F_POINTER......................................................................1316
C_F_PROCPOINTER ..............................................................1317
C_FUNLOC ..........................................................................1319
C_LOC................................................................................1319
C_SIZEOF ...........................................................................1320
CACHESIZE.........................................................................1321
CALL ..................................................................................1321
CANCEL ..............................................................................1323
CANCELLATION POINT ..........................................................1324
CASE..................................................................................1325
CDFLOAT ............................................................................1328
CEILING .............................................................................1328
CFI_address........................................................................1329
CFI_allocate ........................................................................1329
CFI_deallocate.....................................................................1331
CFI_establish ......................................................................1331
CFI_is_contiguous................................................................1333
CFI_section.........................................................................1334
CFI_select_part ...................................................................1336
CFI_setpointer.....................................................................1337
CHANGEDIRQQ....................................................................1338
CHANGEDRIVEQQ ................................................................1339
CHANGE TEAM and END TEAM ...............................................1339
CHAR .................................................................................1343
CHARACTER ........................................................................1344
CHDIR................................................................................1345
CHMOD ..............................................................................1346
CLASS ................................................................................1348
24
Contents
25
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
CTIME ................................................................................1392
CYCLE ................................................................................1393
DATA..................................................................................1394
DATE Intrinsic Procedure.......................................................1397
DATE Portability Routine .......................................................1398
DATE4 ................................................................................1399
DATE_AND_TIME .................................................................1399
DBESJ0, DBESJ1, DBESJN, DBESY0, DBESY1, DBESYN .............1401
DBLE..................................................................................1402
DCLOCK .............................................................................1403
DCMPLX .............................................................................1404
DEALLOCATE .......................................................................1405
DECLARE and NODECLARE ....................................................1406
DECLARE REDUCTION ..........................................................1406
DECLARE SIMD....................................................................1410
DECLARE TARGET ................................................................1411
DECLARE VARIANT...............................................................1412
DECODE .............................................................................1415
DEFAULT.............................................................................1416
DEFINE and UNDEFINE .........................................................1417
DEFINE FILE........................................................................1418
DELDIRQQ ..........................................................................1419
DELETE ..............................................................................1419
DELETEMENUQQ (W*S) ........................................................1420
DELFILESQQ .......................................................................1421
DEPEND Clause ...................................................................1422
DEVICE Clause ....................................................................1423
DFLOAT ..............................................................................1424
DFLOATI, DFLOATJ, DFLOATK ................................................1424
DIGITS ...............................................................................1425
DIM ...................................................................................1425
DIMENSION ........................................................................1426
DISPATCH ...........................................................................1429
DISPLAYCURSOR .................................................................1430
DISTRIBUTE........................................................................1430
DISTRIBUTE PARALLEL DO ....................................................1432
DISTRIBUTE PARALLEL DO SIMD ...........................................1432
DISTRIBUTE POINT ..............................................................1433
DISTRIBUTE SIMD ...............................................................1434
DLGEXIT.............................................................................1435
DLGFLUSH ..........................................................................1435
DLGGET, DLGGETINT, DLGGETLOG, DLGGETCHAR ....................1436
DLGINIT, DLGINITWITHRESOURCEHANDLE .............................1438
DLGISDLGMESSAGE .............................................................1439
DLGMODAL, DLGMODALWITHPARENT .....................................1440
DLGMODELESS ....................................................................1441
DLGSENDCTRLMESSAGE .......................................................1443
DLGSET, DLGSETINT, DLGSETLOG, DLGSETCHAR .....................1444
DLGSETCTRLEVENTHANDLER ................................................1445
DLGSETRETURN...................................................................1447
DLGSETSUB ........................................................................1448
DLGSETTITLE ......................................................................1449
DLGUNINIT .........................................................................1450
DNUM ................................................................................1451
DO Directive .......................................................................1451
26
Contents
DO Statement .....................................................................1456
DO CONCURRENT ................................................................1458
DO SIMD ............................................................................1461
DO WHILE ..........................................................................1462
DOT_PRODUCT ....................................................................1464
DOUBLE COMPLEX ...............................................................1464
DOUBLE PRECISION .............................................................1465
DPROD ...............................................................................1466
DRAND, DRANDM.................................................................1467
DRANSET............................................................................1468
DREAL................................................................................1468
DSHIFTL .............................................................................1469
DSHIFTR ............................................................................1469
DTIME ................................................................................1470
E to F .........................................................................................1471
E to F .................................................................................1471
ELEMENTAL .........................................................................1471
ELLIPSE, ELLIPSE_W (W*S) ..................................................1472
ELSE Directive .....................................................................1473
ELSE Statement...................................................................1474
ELSEIF Directive ..................................................................1474
ELSE IF ..............................................................................1474
ELSE WHERE .......................................................................1474
ENCODE .............................................................................1475
END ...................................................................................1476
END DO..............................................................................1477
ENDIF Directive ...................................................................1477
END IF ...............................................................................1478
ENDFILE .............................................................................1478
END FORALL .......................................................................1479
END INTERFACE...................................................................1479
END TYPE ...........................................................................1479
END WHERE ........................................................................1479
ENTRY ................................................................................1480
EOF ...................................................................................1481
EOSHIFT.............................................................................1482
EPSILON.............................................................................1484
EQUIVALENCE .....................................................................1485
ERF....................................................................................1488
ERFC ..................................................................................1488
ERFC_SCALED .....................................................................1489
ERRSNS..............................................................................1490
ESTABLISHQQ .....................................................................1490
ETIME ................................................................................1495
EVENT POST and EVENT WAIT ...............................................1496
EVENT_QUERY.....................................................................1497
EXECUTE_COMMAND_LINE ...................................................1498
EXIT Statement ...................................................................1499
EXIT Subroutine ..................................................................1501
EXP....................................................................................1501
EXP10 ................................................................................1502
EXPONENT ..........................................................................1503
EXTENDS_TYPE_OF ..............................................................1504
EXTERNAL ..........................................................................1504
FAIL IMAGE.........................................................................1506
27
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
FAILED_IMAGES ..................................................................1507
FDATE ................................................................................1508
FGETC ................................................................................1509
FINAL Clause.......................................................................1509
FINAL Statement .................................................................1510
FIND ..................................................................................1511
FINDLOC ............................................................................1512
FINDFILEQQ........................................................................1514
FIRSTPRIVATE .....................................................................1514
FIXEDFORMLINESIZE ...........................................................1516
FLOAT ................................................................................1516
FLOODFILL, FLOODFILL_W (W*S) ..........................................1516
FLOODFILLRGB, FLOODFILLRGB_W (W*S) ..............................1517
FLOOR................................................................................1519
FLUSH Directive...................................................................1519
FLUSH Statement ................................................................1521
FLUSH Subroutine................................................................1521
FMA and NOFMA ..................................................................1522
FOCUSQQ (W*S) .................................................................1522
FOR__SET_FTN_ALLOC.........................................................1523
FOR_DESCRIPTOR_ASSIGN (W*S) .........................................1525
FOR_GET_FPE .....................................................................1527
FOR_IFCORE_VERSION.........................................................1528
FOR_IFPORT_VERSION .........................................................1529
FOR_LFENCE .......................................................................1530
FOR_MFENCE ......................................................................1530
FOR_RTL_FINISH_ ...............................................................1530
FOR_RTL_INIT_ ...................................................................1531
FOR_SET_FPE .....................................................................1531
FOR_SET_REENTRANCY ........................................................1536
FOR_SFENCE.......................................................................1537
FORALL ..............................................................................1538
FORMAT..............................................................................1540
FORM TEAM ........................................................................1543
FP_CLASS ...........................................................................1546
FPUTC ................................................................................1547
FRACTION...........................................................................1548
FREE ..................................................................................1549
FREEFORM and NOFREEFORM ................................................1549
FSEEK ................................................................................1550
FSTAT.................................................................................1551
FTELL, FTELLI8 ....................................................................1554
FULLPATHQQ .......................................................................1554
FUNCTION ..........................................................................1555
G ...............................................................................................1561
G .......................................................................................1561
GAMMA ..............................................................................1561
GENERIC ............................................................................1561
GERROR .............................................................................1562
GETACTIVEQQ (W*S) ...........................................................1563
GETARCINFO (W*S) .............................................................1563
GETARG..............................................................................1565
GETBKCOLOR (W*S) ............................................................1566
GETBKCOLORRGB (W*S) ......................................................1566
GETC .................................................................................1568
28
Contents
GETCHARQQ .......................................................................1568
GETCOLOR (W*S) ................................................................1569
GETCOLORRGB (W*S) ..........................................................1571
GET_COMMAND ...................................................................1572
GET_COMMAND_ARGUMENT .................................................1573
GETCONTROLFPQQ ..............................................................1573
GETCURRENTPOSITION, GETCURRENTPOSITION_W (W*S) .......1575
GETCWD.............................................................................1576
GETDAT ..............................................................................1577
GETDRIVEDIRQQ .................................................................1578
GETDRIVESIZEQQ................................................................1579
GETDRIVESQQ ....................................................................1580
GETENV..............................................................................1581
GET_ENVIRONMENT_VARIABLE .............................................1581
GETENVQQ .........................................................................1583
GETEXCEPTIONPTRSQQ ........................................................1584
GETEXITQQ (W*S)...............................................................1585
GETFILEINFOQQ ..................................................................1586
GETFILLMASK (W*S) ............................................................1589
GETFONTINFO (W*S) ...........................................................1590
GETGID ..............................................................................1591
GETGTEXTEXTENT (W*S)......................................................1591
GETGTEXTROTATION (W*S) ..................................................1592
GETHWNDQQ (W*S) ............................................................1592
GETIMAGE, GETIMAGE_W .....................................................1593
GETLASTERROR...................................................................1594
GETLASTERRORQQ ..............................................................1594
GETLINESTYLE (W*S)...........................................................1596
GETLINEWIDTHQQ (W*S) .....................................................1597
GETLOG..............................................................................1597
GETPHYSCOORD (W*S) ........................................................1597
GETPID ..............................................................................1599
GETPIXEL, GETPIXEL_W (W*S)..............................................1599
GETPIXELRGB, GETPIXELRGB_W (W*S) ..................................1600
GETPIXELS (W*S)................................................................1601
GETPIXELSRGB (W*S) ..........................................................1602
GETPOS, GETPOSI8..............................................................1603
GETSTATUSFPQQ .................................................................1603
GETSTRQQ..........................................................................1605
GET_TEAM ..........................................................................1605
GETTEXTCOLOR (W*S) .........................................................1606
GETTEXTCOLORRGB (W*S) ...................................................1607
GETTEXTPOSITION (W*S).....................................................1608
GETTEXTWINDOW (W*S)......................................................1609
GETTIM ..............................................................................1609
GETTIMEOFDAY ...................................................................1610
GETUID ..............................................................................1611
GETUNITQQ (W*S) ..............................................................1611
GETVIEWCOORD, GETVIEWCOORD_W (W*S) ..........................1612
GETWINDOWCONFIG (W*S)..................................................1612
GETWINDOWCOORD (W*S) ..................................................1614
GETWRITEMODE (W*S) ........................................................1615
GETWSIZEQQ (W*S) ............................................................1616
GMTIME..............................................................................1617
GOTO - Assigned .................................................................1618
29
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
GOTO - Computed................................................................1619
GOTO - Unconditional ...........................................................1620
GRSTATUS (W*S) ................................................................1621
H to I .........................................................................................1624
H to I .................................................................................1624
HOSTNAM ...........................................................................1624
HUGE .................................................................................1624
HYPOT................................................................................1625
IACHAR ..............................................................................1625
IALL ...................................................................................1626
IAND..................................................................................1627
IANY ..................................................................................1628
IARGC ................................................................................1629
IBCHNG..............................................................................1629
IBCLR.................................................................................1630
IBITS .................................................................................1631
IBSET.................................................................................1632
ICHAR ................................................................................1633
IDATE Intrinsic Procedure .....................................................1634
IDATE Portability Routine ......................................................1635
IDATE4...............................................................................1636
IDENT ................................................................................1636
IDFLOAT .............................................................................1636
IEEE_CLASS........................................................................1637
IEEE_COPY_SIGN ................................................................1637
IEEE_FLAGS ........................................................................1638
IEEE_FMA ...........................................................................1642
IEEE_GET_FLAG ..................................................................1643
IEEE_GET_HALTING_MODE ...................................................1643
IEEE_GET_MODES ...............................................................1644
IEEE_GET_ROUNDING_MODE ................................................1645
IEEE_GET_STATUS ...............................................................1645
IEEE_GET_UNDERFLOW_MODE..............................................1646
IEEE_HANDLER....................................................................1647
IEEE_INT ............................................................................1648
IEEE_IS_FINITE...................................................................1649
IEEE_IS_NAN ......................................................................1649
IEEE_IS_NEGATIVE ..............................................................1650
IEEE_IS_NORMAL ................................................................1650
IEEE_LOGB .........................................................................1651
IEEE_MAX_NUM...................................................................1651
IEEE_MAX_NUM_MAG...........................................................1652
IEEE_MIN_NUM ...................................................................1652
IEEE_MIN_NUM_MAG ...........................................................1653
IEEE_NEXT_AFTER ...............................................................1654
IEEE_NEXT_DOWN...............................................................1654
IEEE_NEXT_UP ....................................................................1655
IEEE_QUIET_EQ ..................................................................1656
IEEE_QUIET_GE ..................................................................1656
IEEE_QUIET_GT ..................................................................1657
IEEE_QUIET_LE ...................................................................1657
IEEE_QUIET_LT ...................................................................1658
IEEE_QUIET_NE ..................................................................1658
IEEE_REAL..........................................................................1659
IEEE_REM ...........................................................................1660
30
Contents
IEEE_RINT ..........................................................................1660
IEEE_SCALB........................................................................1661
IEEE_SELECTED_REAL_KIND.................................................1661
IEEE_SET_FLAG...................................................................1662
IEEE_SET_HALTING_MODE ...................................................1663
IEEE_SET_MODES................................................................1664
IEEE_SET_ROUNDING_MODE ................................................1664
IEEE_SET_STATUS ...............................................................1665
IEEE_SET_UNDERFLOW_MODE ..............................................1665
IEEE_SIGNALING_EQ ...........................................................1666
IEEE_SIGNALING_GE ...........................................................1666
IEEE_SIGNALING_GT ...........................................................1667
IEEE_SIGNALING_LE ............................................................1668
IEEE_SIGNALING_LT ...........................................................1668
IEEE_SIGNALING_NE ...........................................................1669
IEEE_SIGNBIT .....................................................................1669
IEEE_SUPPORT_DATATYPE ....................................................1670
IEEE_SUPPORT_DENORMAL ..................................................1670
IEEE_SUPPORT_DIVIDE ........................................................1671
IEEE_SUPPORT_FLAG ...........................................................1672
IEEE_SUPPORT_HALTING ......................................................1672
IEEE_SUPPORT_INF .............................................................1673
IEEE_SUPPORT_IO ...............................................................1673
IEEE_SUPPORT_NAN ............................................................1674
IEEE_SUPPORT_ROUNDING...................................................1674
IEEE_SUPPORT_SQRT...........................................................1675
IEEE_SUPPORT_STANDARD ...................................................1676
IEEE_SUPPORT_SUBNORMAL.................................................1677
IEEE_SUPPORT_UNDERFLOW_CONTROL .................................1677
IEEE_UNORDERED ...............................................................1678
IEEE_VALUE ........................................................................1678
IEOR ..................................................................................1679
IERRNO ..............................................................................1680
IF - Arithmetic .....................................................................1681
IF - Logical..........................................................................1682
IF Clause ............................................................................1683
IF Construct ........................................................................1684
IF Directive Construct ...........................................................1689
IF DEFINED Directive............................................................1690
IFIX ...................................................................................1690
IFLOATI, IFLOATJ .................................................................1690
ILEN ..................................................................................1691
IMAGE_INDEX .....................................................................1691
IMAGESIZE, IMAGESIZE_W (W*S) .........................................1692
IMAGE_STATUS ...................................................................1693
IMPLICIT ............................................................................1694
IMPORT ..............................................................................1695
IMPURE ..............................................................................1697
IN_REDUCTION ...................................................................1698
INCHARQQ (W*S) ................................................................1699
INCLUDE ............................................................................1700
INDEX ................................................................................1702
INITIALIZEFONTS (W*S) ......................................................1702
INITIALSETTINGS (W*S) ......................................................1703
INLINE, FORCEINLINE, and NOINLINE ....................................1704
31
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
INMAX................................................................................1705
INQFOCUSQQ (W*S) ............................................................1705
INQUIRE.............................................................................1706
INSERTMENUQQ (W*S) ........................................................1708
INT ....................................................................................1711
INTC ..................................................................................1713
INT_PTR_KIND ....................................................................1714
INTEGER ............................................................................1714
INTEGER Directive ...............................................................1715
INTEGERTORGB (W*S) .........................................................1716
INTENT...............................................................................1717
INTERFACE .........................................................................1719
INTERFACE TO.....................................................................1721
INTEROP.............................................................................1722
INTRINSIC ..........................................................................1724
INUM .................................................................................1726
IOR....................................................................................1726
IPARITY ..............................................................................1727
IPXFARGC ...........................................................................1728
IPXFCONST .........................................................................1728
IPXFLENTRIM ......................................................................1729
IPXFWEXITSTATUS (L*X, M*X) ..............................................1729
IPXFWSTOPSIG (L*X, M*X) ...................................................1730
IPXFWTERMSIG (L*X, M*X)...................................................1731
IRAND, IRANDM ..................................................................1731
IRANGET ............................................................................1732
IRANSET.............................................................................1732
IS_CONTIGUOUS .................................................................1732
IS_DEVICE_PTR Clause ........................................................1733
IS_IOSTAT_END ..................................................................1733
IS_IOSTAT_EOR ..................................................................1734
ISATTY ...............................................................................1734
ISHA ..................................................................................1735
ISHC ..................................................................................1735
ISHFT.................................................................................1736
ISHFTC...............................................................................1737
ISHL ..................................................................................1738
ISNAN ................................................................................1739
ITIME .................................................................................1740
IVDEP ................................................................................1740
J to L..........................................................................................1741
J to L .................................................................................1741
JABS ..................................................................................1741
JDATE ................................................................................1742
JDATE4...............................................................................1742
JNUM .................................................................................1743
KILL ...................................................................................1743
KIND..................................................................................1744
KNUM.................................................................................1745
LASTPRIVATE ......................................................................1745
LBOUND .............................................................................1747
LCOBOUND .........................................................................1748
LCWRQQ.............................................................................1749
LEADZ ................................................................................1750
LEN....................................................................................1750
32
Contents
LEN_TRIM...........................................................................1751
LGE....................................................................................1752
LGT....................................................................................1752
LINEAR Clause.....................................................................1753
LINETO, LINETO_W (W*S) ....................................................1757
LINETOAR (W*S) .................................................................1758
LINETOAREX (W*S) .............................................................1759
LLE ....................................................................................1760
LLT ....................................................................................1761
LNBLNK ..............................................................................1762
LOADIMAGE, LOADIMAGE_W (W*S) .......................................1762
LOC ...................................................................................1763
%LOC ................................................................................1764
LOCK and UNLOCK ...............................................................1764
LOG ...................................................................................1766
LOG_GAMMA .......................................................................1767
LOG10................................................................................1767
LOGICAL Function ................................................................1768
LOGICAL Statement .............................................................1768
LONG .................................................................................1769
LOOP .................................................................................1769
LOOP COUNT.......................................................................1772
LSHIFT ...............................................................................1772
LSTAT.................................................................................1773
LTIME.................................................................................1773
M to N ........................................................................................1774
M to N ................................................................................1775
MAKEDIRQQ........................................................................1775
MALLOC..............................................................................1775
MAP clause .........................................................................1776
MAP and END MAP statements ...............................................1778
MASKED .............................................................................1778
MASKED TASKLOOP .............................................................1779
MASKED TASKLOOP SIMD .....................................................1779
MASKL ...............................................................................1780
MASKR ...............................................................................1780
MASTER..............................................................................1781
MASTER TASKLOOP ..............................................................1782
MASTER TASKLOOP SIMD .....................................................1782
MATMUL .............................................................................1783
MAX ...................................................................................1784
MAXEXPONENT ....................................................................1786
MAXLOC .............................................................................1786
MAXVAL..............................................................................1788
MBCharLen .........................................................................1790
MBConvertMBToUnicode........................................................1790
MBConvertUnicodeToMB ........................................................1791
MBCurMax ..........................................................................1792
MBINCHARQQ .....................................................................1793
MBINDEX............................................................................1793
MBJISToJMS, MBJMSToJIS .....................................................1794
MBLead ..............................................................................1795
MBLen ................................................................................1795
MBLen_Trim ........................................................................1796
MBLGE, MBLGT, MBLLE, MBLLT, MBLEQ, MBLNE ........................1796
33
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
MBNext ..............................................................................1798
MBPrev...............................................................................1798
MBSCAN .............................................................................1799
MBStrLead ..........................................................................1799
MBVERIFY...........................................................................1800
MCLOCK .............................................................................1800
MERGE ...............................................................................1801
MERGE_BITS.......................................................................1802
MERGEABLE Clause ..............................................................1802
MESSAGE ...........................................................................1802
MESSAGEBOXQQ (W*S) .......................................................1803
MIN ...................................................................................1804
MINEXPONENT ....................................................................1805
MINLOC ..............................................................................1806
MINVAL ..............................................................................1808
MM_PREFETCH ....................................................................1809
MOD ..................................................................................1811
MODIFYMENUFLAGSQQ (W*S)...............................................1812
MODIFYMENUROUTINEQQ (W*S) ...........................................1813
MODIFYMENUSTRINGQQ (W*S) .............................................1814
MODULE .............................................................................1815
MODULE FUNCTION ............................................................1818
MODULE PROCEDURE ...........................................................1818
MODULE SUBROUTINE .........................................................1819
MODULO.............................................................................1819
MOVE_ALLOC ......................................................................1820
MOVETO, MOVETO_W (W*S) .................................................1822
MVBITS ..............................................................................1823
NAMELIST...........................................................................1824
NARGS ...............................................................................1825
NEAREST ............................................................................1826
NEW_LINE ..........................................................................1827
NINT ..................................................................................1827
NLSEnumCodepages ............................................................1828
NLSEnumLocales .................................................................1829
NLSFormatCurrency .............................................................1829
NLSFormatDate ...................................................................1830
NLSFormatNumber...............................................................1831
NLSFormatTime ...................................................................1832
NLSGetEnvironmentCodepage ...............................................1833
NLSGetLocale ......................................................................1834
NLSGetLocaleInfo ................................................................1834
NLSSetEnvironmentCodepage................................................1842
NLSSetLocale ......................................................................1842
NOFREEFORM......................................................................1844
NOFUSION ..........................................................................1844
NON_RECURSIVE.................................................................1844
NOOPTIMIZE .......................................................................1845
NOPREFETCH ......................................................................1845
NORM2...............................................................................1845
NOSTRICT ..........................................................................1845
NOT ...................................................................................1846
NOUNROLL..........................................................................1847
NOUNROLL_AND_JAM...........................................................1847
NOVECTOR .........................................................................1847
34
Contents
NOWAIT .............................................................................1847
NULL ..................................................................................1847
NULLIFY .............................................................................1848
NUM_IMAGES......................................................................1849
O to P.........................................................................................1850
O to P ................................................................................1850
OBJCOMMENT .....................................................................1850
OPEN .................................................................................1851
OPTIONAL...........................................................................1853
OPTIMIZE and NOOPTIMIZE ..................................................1855
OPTIONS Directive ...............................................................1856
OPTIONS Statement.............................................................1860
OR .....................................................................................1861
ORDERED ...........................................................................1861
OUT_OF_RANGE ..................................................................1864
OUTGTEXT (W*S) ................................................................1865
OUTTEXT (W*S) ..................................................................1866
PACK Directive ....................................................................1866
PACK Function .....................................................................1867
PACKTIMEQQ ......................................................................1868
PARALLEL Directive for OpenMP* API ......................................1869
PARALLEL and NOPARALLEL Loop Directives ............................1871
PARALLEL DO ......................................................................1873
PARALLEL DO SIMD..............................................................1874
PARALLEL LOOP ...................................................................1875
PARALLEL MASKED...............................................................1875
PARALLEL MASKED TASKLOOP ...............................................1876
PARALLEL MASKED TASKLOOP SIMD ......................................1876
PARALLEL MASTER ...............................................................1877
PARALLEL MASTER TASKLOOP ...............................................1878
PARALLEL MASTER TASKLOOP SIMD .......................................1878
PARALLEL SECTIONS ............................................................1879
PARALLEL WORKSHARE ........................................................1880
PARAMETER ........................................................................1880
PARITY ...............................................................................1882
PASSDIRKEYSQQ (W*S) .......................................................1882
PAUSE ................................................................................1885
PEEKCHARQQ ......................................................................1887
PERROR..............................................................................1887
PIE, PIE_W (W*S)................................................................1888
POINTER - Fortran ..............................................................1890
POINTER - Integer ...............................................................1892
POLYBEZIER, POLYBEZIER_W (W*S) ......................................1894
POLYBEZIERTO, POLYBEZIERTO_W (W*S) ...............................1896
POLYGON, POLYGON_W (W*S) ..............................................1897
POLYLINEQQ (W*S) .............................................................1899
POPCNT ..............................................................................1900
POPPAR ..............................................................................1900
PRECISION .........................................................................1901
PREFETCH and NOPREFETCH .................................................1901
PRESENT ............................................................................1902
PRINT ................................................................................1903
PRIORITY............................................................................1904
PRIVATE Clause ...................................................................1905
PRIVATE Statement ..............................................................1906
35
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
PROCEDURE........................................................................1909
PROCESSOR Clause..............................................................1912
PRODUCT ...........................................................................1915
PROGRAM ...........................................................................1916
PROTECTED ........................................................................1917
PSECT ................................................................................1919
PUBLIC...............................................................................1919
PURE..................................................................................1922
PUTC..................................................................................1924
PUTIMAGE, PUTIMAGE_W (W*S)............................................1925
PXF(type)GET......................................................................1927
PXF(type)SET ......................................................................1928
PXFA(type)GET ....................................................................1929
PXFA(type)SET ....................................................................1930
PXFACCESS.........................................................................1931
PXFALARM ..........................................................................1931
PXFCALLSUBHANDLE............................................................1932
PXFCFGETISPEED (L*X, M*X) ................................................1933
PXFCFGETOSPEED (L*X, M*X) ...............................................1933
PXFCFSETISPEED (L*X, M*X) ................................................1934
PXFCFSETOSPEED (L*X, M*X) ...............................................1934
PXFCHDIR...........................................................................1935
PXFCHMOD .........................................................................1935
PXFCHOWN (L*X, M*X) ........................................................1936
PXFCLEARENV .....................................................................1936
PXFCLOSE...........................................................................1936
PXFCLOSEDIR .....................................................................1937
PXFCONST ..........................................................................1937
PXFCREAT ...........................................................................1938
PXFCTERMID .......................................................................1938
PXFDUP, PXFDUP2 ................................................................1939
PXFE(type)GET ....................................................................1939
PXFE(type)SET ....................................................................1940
PXFEXECV...........................................................................1941
PXFEXECVE .........................................................................1942
PXFEXECVP .........................................................................1943
PXFEXIT, PXFFASTEXIT .........................................................1943
PXFFCNTL (L*X, M*X) ..........................................................1944
PXFFDOPEN ........................................................................1946
PXFFFLUSH .........................................................................1947
PXFFGETC ...........................................................................1947
PXFFILENO..........................................................................1948
PXFFORK (L*X, M*X)............................................................1949
PXFFPATHCONF ...................................................................1950
PXFFPUTC ...........................................................................1951
PXFFSEEK ...........................................................................1952
PXFFSTAT ...........................................................................1952
PXFFTELL............................................................................1953
PXFGETARG ........................................................................1953
PXFGETC ............................................................................1954
PXFGETCWD........................................................................1954
PXFGETEGID (L*X, M*X).......................................................1954
PXFGETENV.........................................................................1955
PXFGETEUID (L*X, M*X).......................................................1955
PXFGETGID (L*X, M*X) ........................................................1955
36
Contents
37
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
PXFSYSCONF.......................................................................1992
PXFTCDRAIN (L*X, M*X).......................................................1994
PXFTCFLOW (L*X, M*X)........................................................1994
PXFTCFLUSH (L*X, M*X).......................................................1995
PXFTCGETATTR (L*X, M*X) ...................................................1995
PXFTCGETPGRP (L*X, M*X)...................................................1996
PXFTCSENDBREAK (L*X, M*X)...............................................1996
PXFTCSETATTR (L*X, M*X)....................................................1997
PXFTCSETPGRP (L*X, M*X) ...................................................1997
PXFTIME .............................................................................1998
PXFTIMES ...........................................................................1998
PXFTTYNAME (L*X, M*X) ......................................................2001
PXFUCOMPARE ....................................................................2001
PXFUMASK ..........................................................................2001
PXFUNAME ..........................................................................2002
PXFUNLINK .........................................................................2002
PXFUTIME ...........................................................................2002
PXFWAIT (L*X, M*X) ............................................................2003
PXFWAITPID (L*X, M*X) .......................................................2004
PXFWIFEXITED (L*X, M*X) ...................................................2005
PXFWIFSIGNALED (L*X, M*X) ...............................................2006
PXFWIFSTOPPED (L*X, M*X) .................................................2007
PXFWRITE...........................................................................2007
Q to R ........................................................................................2008
Q to R ................................................................................2008
QCMPLX .............................................................................2008
QEXT .................................................................................2008
QFLOAT ..............................................................................2009
QNUM ................................................................................2010
QRANSET............................................................................2010
QREAL................................................................................2010
QSORT ...............................................................................2011
RADIX ................................................................................2015
RAISEQQ ............................................................................2015
RAN ...................................................................................2016
RAND, RANDOM...................................................................2017
RANDOM ............................................................................2018
RANDOM_INIT.....................................................................2019
RANDOM_NUMBER ...............................................................2020
RANDOM_SEED ...................................................................2022
RANDU ...............................................................................2023
RANF Intrinsic Procedure ......................................................2024
RANF Portability Routine .......................................................2024
RANGE ...............................................................................2025
RANGET..............................................................................2025
RANK .................................................................................2026
RANSET..............................................................................2026
READ .................................................................................2026
REAL Directive.....................................................................2029
REAL Function .....................................................................2030
REAL Statement ..................................................................2031
RECORD .............................................................................2032
RECTANGLE, RECTANGLE_W (W*S) ........................................2033
RECURSIVE and NON_RECURSIVE..........................................2035
REDUCE .............................................................................2036
38
Contents
REDUCTION ........................................................................2037
%REF.................................................................................2040
REGISTERMOUSEEVENT (W*S)..............................................2041
REMAPALLPALETTERGB, REMAPPALETTERGB (W*S) ..................2043
RENAME .............................................................................2044
RENAMEFILEQQ ...................................................................2045
REPEAT ..............................................................................2046
REQUIRES ..........................................................................2046
RESHAPE ............................................................................2048
RESULT ..............................................................................2049
RETURN..............................................................................2050
REWIND .............................................................................2052
REWRITE ............................................................................2053
RGBTOINTEGER (W*S) .........................................................2053
RINDEX ..............................................................................2055
RNUM.................................................................................2055
RRSPACING ........................................................................2056
RSHIFT...............................................................................2056
RTC....................................................................................2056
RUNQQ...............................................................................2057
S ...............................................................................................2058
S .......................................................................................2058
SAME_TYPE_AS ..................................................................2058
SAVE..................................................................................2058
SAVEIMAGE, SAVEIMAGE_W (W*S)........................................2060
SCALE ................................................................................2061
SCAN Directive ....................................................................2061
SCAN Function ....................................................................2064
SCANENV............................................................................2065
SCROLLTEXTWINDOW (W*S) ................................................2065
SCWRQQ ............................................................................2066
SECNDS Intrinsic Procedure ..................................................2067
SECNDS Portability Routine ...................................................2068
SECTIONS ..........................................................................2069
SEED .................................................................................2070
SELECT CASE and END SELECT..............................................2070
SELECT RANK......................................................................2071
SELECT TYPE.......................................................................2073
SELECTED_CHAR_KIND ........................................................2075
SELECTED_INT_KIND ...........................................................2075
SELECTED_REAL_KIND.........................................................2076
SEQUENCE..........................................................................2077
SETACTIVEQQ (W*S) ...........................................................2078
SETBKCOLOR (W*S) ............................................................2078
SETBKCOLORRGB (W*S) ......................................................2079
SETCLIPRGN (W*S) .............................................................2080
SETCOLOR (W*S) ................................................................2082
SETCOLORRGB (W*S) ..........................................................2083
SETCONTROLFPQQ...............................................................2084
SETDAT ..............................................................................2086
SETENVQQ..........................................................................2087
SETERRORMODEQQ .............................................................2088
SETEXITQQ .........................................................................2089
SET_EXPONENT ...................................................................2090
SETFILEACCESSQQ ..............................................................2090
39
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
SETFILETIMEQQ ..................................................................2091
SETFILLMASK (W*S) ............................................................2092
SETFONT (W*S) ..................................................................2094
SETGTEXTROTATION (W*S) ..................................................2097
SETLINESTYLE (W*S) ...........................................................2098
SETLINEWIDTHQQ (W*S) .....................................................2099
SETMESSAGEQQ (W*S) ........................................................2100
SETMOUSECURSOR (W*S) ....................................................2101
SETPIXEL, SETPIXEL_W (W*S) ..............................................2103
SETPIXELRGB, SETPIXELRGB_W (W*S) ..................................2104
SETPIXELS (W*S) ................................................................2105
SETPIXELSRGB (W*S) ..........................................................2106
SETTEXTCOLOR (W*S) .........................................................2107
SETTEXTCOLORRGB (W*S) ...................................................2108
SETTEXTCURSOR (W*S) .......................................................2109
SETTEXTPOSITION (W*S) .....................................................2110
SETTEXTWINDOW (W*S) ......................................................2111
SETTIM...............................................................................2112
SETVIEWORG (W*S) ............................................................2113
SETVIEWPORT.....................................................................2114
SETWINDOW (W*S) .............................................................2114
SETWINDOWCONFIG (W*S) ..................................................2116
SETWINDOWMENUQQ (W*S) ................................................2118
SETWRITEMODE (W*S) ........................................................2119
SETWSIZEQQ (W*S) ............................................................2121
SHAPE................................................................................2122
SHARED .............................................................................2123
SHIFTA ...............................................................................2124
SHIFTL ...............................................................................2124
SHIFTR...............................................................................2125
SHORT ...............................................................................2125
SIGN..................................................................................2126
SIGNAL ..............................................................................2127
SIGNALQQ ..........................................................................2129
SIMD Directive (OpenMP* API) ..............................................2130
SIMD Loop Directive.............................................................2133
SIN ....................................................................................2138
SIND..................................................................................2138
SINGLE ..............................................................................2139
SINH..................................................................................2140
SIZE ..................................................................................2140
SIZEOF...............................................................................2141
SLEEP ................................................................................2142
SLEEPQQ ............................................................................2142
SNGL .................................................................................2143
SORTQQ .............................................................................2143
SPACING ............................................................................2144
SPLITPATHQQ......................................................................2145
SPORT_CANCEL_IO ..............................................................2146
SPORT_CONNECT ................................................................2146
SPORT_CONNECT_EX ...........................................................2148
SPORT_GET_HANDLE ...........................................................2149
SPORT_GET_STATE ..............................................................2150
SPORT_GET_STATE_EX.........................................................2150
SPORT_GET_TIMEOUTS ........................................................2152
40
Contents
SPORT_PEEK_DATA ..............................................................2153
SPORT_PEEK_LINE...............................................................2154
SPORT_PURGE.....................................................................2155
SPORT_READ_DATA .............................................................2155
SPORT_READ_LINE ..............................................................2156
SPORT_RELEASE..................................................................2157
SPORT_SET_STATE ..............................................................2157
SPORT_SET_STATE_EX .........................................................2158
SPORT_SET_TIMEOUTS ........................................................2160
SPORT_SHOW_STATE ...........................................................2161
SPORT_SPECIAL_FUNC .........................................................2162
SPORT_WRITE_DATA............................................................2163
SPORT_WRITE_LINE.............................................................2163
SPREAD..............................................................................2164
SQRT .................................................................................2165
SRAND ...............................................................................2166
SSWRQQ ............................................................................2167
STAT ..................................................................................2167
Statement Function..............................................................2170
STATIC ...............................................................................2172
STOP and ERROR STOP.........................................................2174
STOPPED_IMAGES ...............................................................2175
STORAGE_SIZE ...................................................................2176
STRICT and NOSTRICT .........................................................2177
STRUCTURE and END STRUCTURE .........................................2178
SUBDEVICE.........................................................................2182
SUBMODULE .......................................................................2182
SUBROUTINE ......................................................................2187
SUM...................................................................................2189
SYNC ALL ...........................................................................2190
SYNC IMAGES .....................................................................2191
SYNC MEMORY ....................................................................2193
SYNC TEAM .........................................................................2194
SYSTEM..............................................................................2195
SYSTEM_CLOCK...................................................................2196
SYSTEMQQ .........................................................................2197
T to Z .........................................................................................2198
T to Z.................................................................................2198
TAN ...................................................................................2198
TAND .................................................................................2199
TANH .................................................................................2199
TARGET ..............................................................................2200
TARGET DATA ......................................................................2201
TARGET Statement...............................................................2203
TARGET ENTER DATA............................................................2204
TARGET EXIT DATA ..............................................................2205
TARGET PARALLEL ...............................................................2205
TARGET PARALLEL DO ..........................................................2206
TARGET PARALLEL DO SIMD ..................................................2207
TARGET PARALLEL LOOP .......................................................2208
TARGET SIMD......................................................................2208
TARGET TEAMS....................................................................2209
TARGET TEAMS DISTRIBUTE .................................................2209
TARGET TEAMS DISTRIBUTE PARALLEL DO..............................2210
TARGET TEAMS DISTRIBUTE PARALLEL DO SIMD .....................2211
41
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
42
Contents
WORKSHARE.......................................................................2285
WRAPON (W*S)...................................................................2286
WRITE................................................................................2288
XOR ...................................................................................2290
ZEXT..................................................................................2290
Glossary..............................................................................................2291
Glossary A ..................................................................................2292
Glossary B ..................................................................................2295
Glossary C ..................................................................................2296
Glossary D ..................................................................................2298
Glossary E...................................................................................2301
Glossary F...................................................................................2303
Glossary G ..................................................................................2305
Glossary H ..................................................................................2305
Glossary I ...................................................................................2305
Glossary K ..................................................................................2307
Glossary L ...................................................................................2307
Glossary M ..................................................................................2309
Glossary N ..................................................................................2310
Glossary O ..................................................................................2311
Glossary P...................................................................................2312
Glossary Q ..................................................................................2314
Glossary R ..................................................................................2314
Glossary S ..................................................................................2315
Glossary T...................................................................................2319
Glossary U ..................................................................................2320
Glossary V ..................................................................................2321
Glossary W..................................................................................2321
Glossary Z ..................................................................................2322
Part V: Compilation
Supported Environment Variables ...........................................................2323
Using Other Methods to Set Environment Variables ...................................2357
Understanding Files Associated with Intel® Fortran Applications (Windows*) .2358
Compiling and Linking Multithreaded Programs .........................................2360
Linking Tools and Options ......................................................................2361
Using Configuration Files .......................................................................2363
Using Response Files.............................................................................2364
Creating Fortran Executables .................................................................2365
Linking Debug Information ....................................................................2365
Debugging...........................................................................................2366
Preparing Your Program for Debugging............................................2366
Using Breakpoints in the Debugger .................................................2368
Debugging the Squares Example Program .......................................2371
Viewing Fortran Data Types in the Microsoft Debugger ......................2375
Viewing the Call Stack in the Microsoft Debugger..............................2378
Locating Unaligned Data ...............................................................2378
Debugging a Program that Encounters a Signal or Exception ..............2378
Debugging and Optimizations ........................................................2379
Debugging Mixed-Language Programs.............................................2381
Debugging Multithreaded Programs ................................................2381
Using Remote Debugging ..............................................................2382
Remote Debugging Scenario..................................................2383
43
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
44
Contents
45
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
46
Notices and Disclaimers
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
Intel, the Intel logo, Intel Atom, Intel Core, Intel Xeon, Intel Xeon Phi, Pentium, and VTune are trademarks of
Intel Corporation in the U.S. and/or other countries.
*Other names and brands may be claimed as the property of others.
Portions Copyright © 2001, Hewlett-Packard Development Company, L.P.
Microsoft, Windows, and the Windows logo are trademarks, or registered trademarks of Microsoft Corporation
in the United States and/or other countries.
© Intel Corporation.
This software and the related documents are Intel copyrighted materials, and your use of them is governed
by the express license under which they were provided to you (License). Unless the License provides
otherwise, you may not use, modify, copy, publish, distribute, disclose or transmit this software or the
related documents without Intel's prior written permission.
This software and the related documents are provided as is, with no express or implied warranties, other
than those that are expressly stated in the License.
47
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
This guide provides information about Intel® Fortran Compiler Classic (ifort) and its runtime environment,
and about Intel® Fortran Compiler (ifx), which is a new compiler based on the Intel Fortran Compiler Classic
(ifort) frontend and runtime libraries, using LLVM backend technology.
Refer to the Intel® Fortran Compiler main page for more information about features, specifications, and
downloads.
Use this guide to learn about:
• Compiler Setup: How to invoke the compiler on the command line or from within an IDE.
• Compiler Options: Information about options you can use to affect optimization, code generation, and
more.
• Language Reference: Information on language syntax and semantics, on adherence to various Fortran
standards, and on extensions to those standards.
• OpenMP* Support: Details about compiler support for OpenMP 5.0 Version TR4 features and some
OpenMP Version 5.1 features.
• Fortran Language Extensions: Information on using additional implementation features, including
creating a Component Object Model server, generating listing and map files, and more.
• Mixed Language Programming: Information about Fortran and C interoperable procedures and data
types, as well as various specifics of mixed-language programming.
• Run-Time Error Messages: Information about the errors processed by the Intel® Fortran runtime library
(RTL).
For more information, refer to Introducing the Intel® Fortran Compiler Classic and Intel® Fortran Compiler.
xcode-select --install
48
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• Download Previous Versions of the Developer Guide and Reference :Visit the Download
Documentation: Intel® Compiler (Current and Previous) page to download PDF or FAR HTML versions of
previous compiler documentation.
NOTE
For the best search experience, use a Google Chrome* or Internet Explorer* browser to view your
downloaded copy of the Intel Fortran Compiler Developer Guide and Reference.
If you use Mozilla Firefox*, you may encounter an issue where the Search tab does not work. As a
workaround, you can use the Contents and Index tabs or a third-party search tool to find your
content.
49
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE Support for 32-bit targets is deprecated in ifort and may be removed in a future release. ifx
does not support 32-bit targets.
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
50
Feature Requirements
Feature Requirements
To use these tools and features, you need licensed versions of the tools and you must have an appropriately
supported version of the product edition. For more information, check the product release notes.
The following table shows components (tools) and where to find additional information on them.
Intel® Fortran Compiler Classic and Intel® Fortran More information on tools and features can be
Compiler found on the Intel® Developer Zone and the
Software Development Tools pages.
Intel® Advisor
Intel® Inspector
The following table lists dependent features and their corresponding required products. For certain compiler
options, the compilation may fail if the option is specified but the required product is not installed. In this
case, remove the option from the command line and recompile.
Feature Requirements
Feature Requirement
Coarray programs built to run using distributed Intel® oneAPI HPC Toolkit
memory
Refer to the Release Notes for detailed information about system requirements, late changes to the products,
supported architectures, operating systems, and Integrated Development Environments (IDEs).
51
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE To access support, you must register your product at the Intel® Registration Center: https://
registrationcenter.intel.com/en/products/
Release Notes
For detailed information on system requirements, late changes to the products, supported architectures,
operating systems, and Integrated Development Environments (IDE) see the Release Notes for the product.
Forums
You can find helpful information in the Intel Software user forums. You can also submit questions to the
forums. To see the list of the available forums, go to https://community.intel.com/t5/Software-Development-
Tools/ct-p/software-dev-tools
Related Information
Reference and Tutorial Information
The following commercially published documents provide reference or tutorial information about Fortran:
• Introduction to Programming with Fortran with coverage of Fortran 90, 95, 2003, 2008 and 77, by I.D.
Chivers and J. Sleightholme; published by Springer, ISBN 9780857292322
• The Fortran 2003 Handbook: The Complete Syntax, Features and Procedures, by Adams, J.C., Brainerd,
W.S., Hendrickson, R.A., Maine, R.E., Martin, J.T., Smith, B.T., published by Springer Verlag, ISBN
9781846283789
• Fortran 95/2003 For Scientists and Engineers, by Chapman S.J., published by McGraw- Hill, ISBN
0073191574
• Modern Fortran Explained: Incorporating Fortran 2018, by Metcalf M., Reid J. and Cohen M., 2018,
published by Oxford University Press, ISBN-13: 978-0198811886
Intel does not endorse these books or recommend them over other books on the same subjects.
52
Notational Conventions
Notational Conventions
Information in this documentation applies to all supported operating systems and architectures unless
otherwise specified. This documentation uses the following conventions:
Notational Conventions
THIS TYPE Indicates statements, data types, directives, and
other language keywords. Examples of statement
keywords are WRITE, INTEGER, DO, and OPEN.
File > Open Menu names and menu items joined by a greater
than (>) sign to indicate a sequence of actions. For
example, Click File > Open indicates that in the
File menu, you would click Open to perform this
action.
item [, item ]... Indicates that the item preceding the ellipsis (...)
can be repeated. In some code examples, a
horizontal ellipsis means that not all of the
statements are shown.
53
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
compiler or the compiler These terms are used when information is not
limited to only one specific compiler, or when it is
not necessary to indicate a specific compiler.
Windows* or Windows operating system These terms refer to all supported Microsoft
Windows operating systems.
Linux or Linux operating system These terms refer to all supported Linux operating
systems.
macOS* or macOS* operating system These terms refer to all supported macOS*
operating systems.
54
Introducing the Intel® Fortran Compiler Classic and Intel® Fortran Compiler
55
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
56
Introducing the Intel® Fortran Compiler Classic and Intel® Fortran Compiler
Platform Labels
A platform is a combination of an operating system (OS) and a central processing unit (CPU), which provides
a distinct environment for product use (in this case, a computer language). An example of a platform is
Microsoft Windows on processors using Intel® 64 architecture.
In this documentation, the information applies to all supported platforms unless it is otherwise labeled for a
specific platform (or platforms).
These labels may be used to identify specific platforms:
57
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Part
Compiler Setup II
You can use the Intel® Fortran from the command line, or from the IDEs listed below.
These IDEs are described in further detail in their corresponding sections.
NOTE Type: source /<install-dir>/setvars.sh --help for more setvars usage information.
The compiler environment script file accepts an optional target architecture argument <arg>:
• intel64: Generate code and use libraries for Intel® 64 architecture-based targets.
• ia32: Generate code and use libraries for IA-32 architecture-based targets.
If you want the setvars.sh script to run automatically in all of your terminal sessions, add the source
setvars.sh command to your startup file. For example, inside your .bash_profile entry for Intel® 64
architecture targets:
58
Compiler Setup
If the proper environment variables are not set, errors similar to the following may appear when attempting
to execute a compiled program:
Windows:
Under normal circumstances, you do not need to run the setvars.bat batch file. The terminal shortcuts in the
Windows Start menu, Intel oneAPI command prompt for <target architecture> for Visual Studio
<year>, set these variables automatically.
For additional information, see Using the Command Line on Windows.
NOTE You need to run the setvars batch file if a command line is opened without using one of the
provided Command Prompt menu items in the Start menu, or if you want to use the compiler from a
script of your own.
The setvars batch file inserts DLL directories used by the compiler and libraries at the beginning of the
existing Path. Because these directories appear first, they are searched before any directories that were part
of the original Path provided by Windows (and other applications). This is especially important if the original
Path includes directories with files that have the same names as those added by the compiler and libraries.
The setvars batch file takes multiple optional arguments; the following two arguments are recognized for
compiler and library initialization:
NOTE If <arg1> is not specified, the script uses the intel64 argument by default. If <arg2> is not
specified, the script uses the highest installed version of Microsoft Visual Studio detected during the
installation procedure.
NOTE Support for Microsoft Visual Studio 2017 is deprecated as of the Intel® oneAPI 2022.1 release,
and will be removed in a future release.
See Also
oneAPI Development Environment Setup
59
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE For Windows and macOS* systems, you can use the compiler within the IDE.
For more information on using the Microsoft Visual Studio IDE, see Using Microsoft Visual Studio.
ifort [options]input_file(s)
The ifort command can compile and link projects in one step, or can compile them and then link them as a
separate step.
In most cases, a single ifort command invokes the compiler and linker. You can also use ld (Linux and
macOS*) or link (Windows) to build libraries of object modules. These commands provide syntax
instructions at the command line if you request it with the -help (Linux and macOS*), or the /help or /?
(Windows) options.
The ifort command automatically references the appropriate Intel® Fortran runtime Libraries when it
invokes the linker. To link one or more object files created by the Intel® Fortran Compiler, you should use the
ifort command instead of the link command.
The ifort command invokes a driver program that is the user interface to the compiler and linker. It
accepts a list of command options and file names and directs processing for each file. The driver program
does the following:
• Calls the Intel® Fortran Compiler to process Fortran files.
• Passes the linker options to the linker.
• Passes object files created by the compiler to the linker.
• Passes libraries to the linker.
60
Compiler Setup
NOTE
The compiler recognizes language extensions for offloading in the source program by default and
builds a heterogeneous binary that runs on the target and host when any are present. If your program
includes these language extensions and you do not want to build a heterogeneous binary, specify the
-qno-offload compiler option. For more information, see the -qno-offload compiler option.
Offload is not supported on Windows systems.
NOTE
Windows systems support characters in Unicode* (multibyte) format. The compiler processes the file
names containing Unicode characters.
Syntax Rules
The following rules apply when specifying ifort on the command line:
Argument Description
options An option is specified by one or more letters preceded by a hyphen (-) for Linux and
macOS* or a slash (/) for Windows. (You can use a hyphen (-) instead of a slash
(/) for Windows, but it is not the preferred method.)
Options cannot be combined with a single slash or hyphen, you must specify the
slash or hyphen for each option specified. For example: /1 /c is correct, but /1c is
not.
Options can take arguments in the form of file names, strings, letters, and numbers.
If a string includes spaces, they must be enclosed in quotation marks.
Some options take arguments in the form of file names, strings, letters, or numbers.
Except where otherwise noted, a space between the option and its argument(s) can
be entered or combined. For a complete listing of compiler options, see the Compiler
Options reference.
Some compiler options are case-sensitive. For example, c and C are two different
options.
Option names can be abbreviated, enter as many characters as are needed to
uniquely identify the option.
Compiler options remain in effect for the whole compilation unless overridden by a
compiler directive.
Certain options accept one or more keyword arguments following the option name
on Windows. To specify multiple keywords, you typically specify the option multiple
times. However, some options allow comma-separated keywords. For example:
• Options that use a colon can use an equal sign (=) instead.
61
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Argument Description
NOTE Options on the command line apply to all files. In the following example,
the -c and -nowarn options apply to both files x.f and y.f:
input file(s) Multiple input_files can be specified, using a space as a delimiter. When a file is not
in PATH or working directory, specify the directory path before the file name. The file
name extension specifies the type of file. See Understanding File Extensions.
Xlinker (Linux Unless specified with certain options, the command line compiles and links the files
and macOS*) you specify. To compile without linking, specify the c option.
or /link
All compiler options must precede the -Xlinker (Linux and macOS*) or /link
(Windows)
(Windows) options. Options that appear following -Xlinker or /link are passed
directly to the linker.
ifort x.for
The following command compiles x.for and generates the object file x.o (Linux and macOS*) or x.obj
(Windows). The c option prevents linking (it does not link the object file into an executable file):
62
Compiler Setup
When you use a single ifort command, the order in which files are placed on the command line is
significant. For example, if the free-form source file moddef.f90 defines the modules referenced by the file
projmain.f90, use the following syntax:
// (Windows)
ifort filenames /options 1>one.out 2>two.out
// OR
ifort filenames /options >one.out 2>two.out
To place standard output and standard error into a single file both.out (Windows):
// (Windows)
ifort filenames /options 1>both.out 2>&1
// OR
ifort filenames /options >both.out 2>&1
Other Methods for Using the Command Line to Invoke the Compiler
• Using makefiles from the Command Line: Use makefiles to specify a number of files with various
paths and to save this information for multiple compilations. For more information on using makefiles, see
Using Makefiles to Compile Your Application.
• Using the devenv Command from the Command Line (Windows Only): Use devenv to set various
options for the IDE, and to build, clean, and debug projects from the command line. For more information
on the devenv command, see the devenv description in the Microsoft Visual Studio documentation.
• Using a Batch File from the Command Line: Create and use a .bat file to consistently execute the
compiler with a desired set of options instead of retyping the command each time you need to recompile.
See Also
Understanding File Extensions
Using Microsoft Visual Studio
Using Makefiles to Compile Your Application
watch compiler option
qoffload compiler option
63
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE The command prompts shown are dependent on the versions of Microsoft Visual Studio* you
have installed on your machine.
Multithreaded Programs
If the program is multithreaded, each thread starts on whichever processor is available at the time. On a
computer with one processor, the threads all run in parallel, but not simultaneously; the single processor
switches among them. On a computer with multiple processors, the threads can run simultaneously.
NOTE
In the Visual Studio* IDE, you can provide these filenames using Project > Properties. Choose the
Debugging category and enter the filenames in the Command Arguments text box.
Each filename on the command line (or in an IDE dialog box) must be separated from the names around it
by one or more spaces or tab characters. You can enclose each name in quotation marks ("<filename>"), but
this is not required unless the argument contains spaces or tabs. A null argument consists of an empty set of
quotation marks with no filename enclosed ("").
64
Compiler Setup
The following example runs the program MYPROG.EXE from the command line:
• Call the GETARG library routine to return the specified command-line argument. To execute the program
in the Visual Studio* IDE, provide the command-line arguments to be passed to the program using
Project > Properties. Choose the Debugging category and enter the arguments in the Command
Arguments text box.
• On Windows* OS, call the GetOpenFileName Windows* API routine to request the file name using a
dialog box.
See Also
-fpscomp option
Typical Fortran source files have a file extension of .f90, .for, and .f. When editing your source files,
you need to choose the source form, either free-source form or fixed-source form (or a variant of fixed
form called tab form). You can use a compiler option to specify the source form used by the source files
(see the description for the free or fixed compiler option) or you can use specific file extensions when
creating or renaming your files. For example, the compiler assumes that files with an extension of:
• .f90 or .i90 are free-form source files.
• .f, .for, .ftn, or .i are fixed-form (or tab-form) files.
• Files passed to the linker: .a, .lib, .obj, .o, .exe, .res, .rbj, .def, .dll
file.lib (Windows)
65
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
file.i
file.F90 (Linux and macOS*) Fortran free-form Automatically preprocessed by the Intel®
source Fortran preprocessor fpp; then compiled
by the Intel® Fortran Compiler.
file.asm (Windows)
When you compile from the command line, you can use the compiler configuration file to specify default
directories for input libraries. To specify additional directories for input files, temporary files, libraries, and for
the files used by the assembler and the linker, use compiler options that specify output file and directory
names.
/Fafile .ASM
/dll:file .DLL
/exe:file .EXE
/map:file .MAP
See Also
Invoking the Compiler
66
Compiler Setup
make -f yourmakefile
Where -f is the make command option to specify a particular makefile name.
Argument Description
/f The nmake option to specify a makefile.
The nmake command creates object files (.obj) and executable files () from the information specified in the
your_project.mak makefile.
Build dependencies include a list of all files included with INCLUDE statements and .mod files accessed with
USE statements. The resulting output can be used to create a makefile to with the appropriate dependencies
resolved.
Consider a source file that contains the following:
module b
include 'gendep001b.inc'
end module b
program gendep001
67
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
use b
a_global = b_global
end
When you compile the source using the gen-dep option, the following output is produced:
b.mod : \
gendep001.f90
gendep001.obj : \
gendep001.f90 gendep001b.inc
This output indicates that the generated file, b.mod, depends on the source file, gendep001.f90. Similarly,
the generated file, gendep001.obj, depends on the files, gendpe001.f90 and gendep001b.inc.
See Also
Performing Common Tasks with Microsoft Visual Studio*
Using Microsoft Visual Studio* Solution Explorer
Using Breakpoints in the Debugger
68
Compiler Setup
The Output window displays compilation and linker messages. To display the Output window, select View >
Output. The Output window also links to the build log, if the Generate Build logs option is enabled in
Tools > Options > Intel Compilers and Libraries > Visual Fortran.
NOTE Exact steps may vary depending on the version of Microsoft Visual Studio in use.
The project and its files appear in the Solution Explorer view. For a COM Server project, you will see a
second page with additional user options.
A module file is a precompiled, binary version of a module definition, stored as a .mod file. When you change
the source definition of a module, you can update the .mod file before you rebuild your project. To do this,
compile the corresponding source file separately by selecting the file in the Solution Explorer window and
69
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
selecting Build > Compile. If the module source file is part of your project, you do not need to compile the
file separately. When you build your project, the Intel® Fortran Compiler determines what files need to be
compiled.
To control the placement of module files in directories, use Project > Properties > Fortran > Output
Files > Module Path in the IDE or the compiler option [no]module on the command line. The location you
specify is automatically searched for .mod files.
To control the search for module files in directories, select one of the following:
• In the IDE:
• Project > Properties > Fortran > Preprocessor > Default Include and Use Path
• Project > Properties > Fortran > Preprocessor > Ignore Standard Include Path
• On the Command Line:
• X or I and assume:source_include compiler options.
For a newly created project (or any other project), the IDE scans the file list for sources that define modules
and compiles them before compiling the program units that use them. The IDE automatically scans the
added project files for modules specified in USE statements, as well as any INCLUDE statements. It scans the
source files for all tools used in building the project.
See Also
Understanding Project Types
I
X
assume
See Also
Creating a New Project
Converting Projects
70
Compiler Setup
Project .sln Stores solution information, including the projects and items in the
Solution file solution and their locations on disk.
Project file .vfproj Contains information used to build a single project or sub-project.
.vcxproj
Solution .suo Contains IDE customization for the solution, based on the selected
options file options.
Caution
• Directly modifying these files with a text editor is not supported.
• Before opening Compaq* Visual Fortran 6.0 projects or Intel® Visual Fortran 7.x projects in
Microsoft Visual Studio, review the guidelines listed in Converting Projects.
71
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Each project can specify one or more configurations to build from its source files. A configuration specifies
such information as the type of application to build, the platform it runs on, and the tool settings to use when
building. Having multiple configurations extends the scope of a project, but maintains a consistent source
code base to work with.
Microsoft Visual Studio automatically creates Debug and Release (also known as Retail) configurations
when a new project is started. The default configuration is the Debug configuration. To specify the current
configuration, select Configuration Manager from the Build menu.
Specify build options in the Project > Properties dialog box, for one of the following:
• For all configurations (project-wide).
• For certain configurations (per configuration).
• For certain files (per file).
For example, specify compiler optimizations for all general configurations, but turn them off for certain
configurations or certain files.
Once the files in the project are specified and the configurations for your project build are set, including the
tool settings, build the project with the commands on the Build menu.
NOTE For a multiple-project solution, make sure that the executable project is designated as the
startup project (shown in bold in the Solution Explorer view). To modify the startup project, right-
click on the project and select Set as StartUp Project.
See Also
Converting Projects
Selecting a Configuration
A configuration contains settings that define the final binary output file that you create within a project. It
specifies the type of application to build, the platform on which it is to run, and the tool settings to use when
building.
72
Compiler Setup
Release (Retail) configuration The release configuration does not include the debugging
information, and it uses any optimizations that you have chosen.
Platform Types
The platform type sets options required specifically for the selected platform, such as options that the
compiler uses for the source files, the libraries that the linker uses for the platform, defined constants, and so
on.
73
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
New Configurations
In addition to the default Debug and Release configurations, you can also define new configurations within
your project. These configurations may use the existing source files in your project, the existing project
settings, or other characteristics of existing configurations.
See Also
Setting Compiler Options in the Visual Studio* IDE Property Pages
Understanding Errors During the Build Process
NOTE If you specify devenv or useenv on the command line to start the IDE, the IDE uses the PATH,
INCLUDE, and LIB environment variables as defined for that command line when performing a build. It
uses these values instead of the values defined in Tools > Options.
For more information on the devenv command, see the devenv description in the Microsoft Visual
Studio* documentation.
See Also
Supported Environment Variables
74
Compiler Setup
NOTE For convenience, context-sensitive pop-up menus containing commonly used menu options are
available by right-clicking on an item (for example, a file name or solution) in the IDE.
NOTE Option values that are different from the compiler defaults are displayed in bold.
75
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
76
Compiler Setup
The Intel® Fortran Compiler also supports the following macros (not supported by Visual Studio*).
For additional information on using build macros, see the Microsoft MSDN* online documentation.
Using Manifests
The Intel® Fortran Compiler supports manifests, a Visual Studio* feature. Manifests describe run-time
dependencies of a built application. A manifest file can be embedded in the assembly, which is the default
behavior, or can be a separate standalone file. You can use the Manifest Tool property pages, which are
accessed through Project > Properties, to change project settings that affect the manifest.
NOTE
In earlier releases, manifest files were embedded in the assembly, and were not able to be accessed or
changed.
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
77
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
GAP Scenarios
To illustrate how the various GAP settings work together, consider the following scenarios:
Scenario Result
The GAP analysis setting in the Analysis always occurs for the project, whenever a regular project
property pages is set to Enabled. build occurs. Other analysis settings specified in the property pages
are used. Analysis setting in Tools > Options are ignored.
The Gap analysis setting in the Analysis occurs for this one run. The default values for this analysis
property pages is set to Disabled, are taken from Tools > Options and can be overridden in the
and GAP is run from the Tools dialog box. Options specified in the property pages are also used,
menu. but will be overridden by any specified analysis option.
The GAP analysis setting in the No analysis occurs, unless analysis is explicitly run from the Tools
property pages is set to Disabled, menu.
and GAP options are set in Tools >
Options.
78
Compiler Setup
• Range of lines: Select one or more lines for analysis and right-click.
See Also
Options: Guided Auto Parallelism dialog box
See Also
Code Coverage dialog box
See Also
Profile Guided Optimization dialog box
79
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE If the procedures in your project do not show when browsing in My Solution, you can right-
click the message (No information. Try browsing a different component set.) and select View
Containers as a possible solution.
Disable Database: Choose this option to disable creation of the code browsing database. This may help
increase performance on slow machines. If you disable the database, all features that rely on code browsing
information will not work.
Enable Find all References: Choose this option to enable display of the location(s) in your code where a
symbol is referenced. When this option is enabled, you can use the right-click context menu Find All
References option to display a list of references to the selected symbol. Double-click a reference to find that
reference.
80
Compiler Setup
Enable Go To Definition: Choose this option to enable quick navigation to an object definition. When this
option is enabled, you can use the right-click context menu Go to Definition option to locate where the
selected object was declared, opening the associated source file if required. (If you have also enabled Scan
system includes, any objects declared in system modules such as IFWINTY cause the associated source for
that module to be opened.)
Scan system includes: Choose this option to scan system include files. This option is used with one or
more of the following options: Collect Object Browser Information, Enable Find All References,
Enable Go To Definition.
Intrinsics Section
Enable Intrinsic Parameter Info: Choose this option to enable the display of intrinsic function and
subroutine parameter information. When this option is enabled, you can type a name of an intrinsic
procedure, followed by an open parenthesis, and information about the procedure and its arguments
appears.
Enable Intrinsic Quick Info: Choose this option to enable the display of additional information when the
cursor is moved over an intrinsic function or subroutine name.
Miscellaneous Section
Enumerate Comment Tasks: Choose this option to enable the display of a list of tasks consisting of source
files containing comments. Comments take the form of the ! character, followed by a token such as TO DO.
Valid tokens are listed in Tools > Options > Environment > Task List. When this option is enabled, you
can select Comments from the task list using View > Other Windows Task List. Double-click a comment
in the list to jump to its location.
Highlight Matching Tokens: Choose this option to allow identifier highlighting and block delimiter
matching. When enabled, this option highlights all references to the identifier under the cursor.
Outlining Section
Enable Outlining: Choose this option to allow the collapsing of whole program units. When this option is
enabled, you can click the minus (-) or plus (+) symbols for PROGRAM, SUBROUTINE, FUNCTION, MODULE,
and BLOCK DATA statements.
Outline Statement Blocks: Choose this option to allow collapsing of block constructs such as IF and DO.
You must also choose Enable Outlining.
NOTE To define the build order of projects, right-click on the solution and choose Properties >
Project Dependencies.
81
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example: Assume you have multiple projects (A, B, and C) in a solution with the following defined
dependencies:
• A depends on B
• B depends on C
If you build A, the build process verifies that B is up-to-date. During verification of B, C is also verified that it
is likewise up-to-date. When either, or both, are determined to be out of date, the appropriate build
operations will occur to update them. When C and B produce .lib or .dll output, the output of C is linked
into B and the output of B is linked into A.
The Rebuild <project name> option forces a new compilation of all source files listed for the project.
You either can choose to build a single project, the current project, or multiple project configurations (using
the Batch Build... option) in one operation. You can also choose to build the entire solution.
You can execute your program from the IDE using Debug > Start Without Debugging (Ctrl and F5) or
Debug > Start (F5). You can also execute your program from the command line prompt.
Converting Projects
In general, you can open projects created by older versions of Intel® Visual Fortran and use them directly. If
the projects were created in older versions of Microsoft Visual Studio*, the solution file is converted first and
then any non-Fortran projects it contains. Projects created in newer versions of Intel® Visual Fortran might
not be usable in older versions.
Projects created in Compaq* Visual Fortran 6.0 or later can usually be converted to Intel® Visual Fortran as
follows:
1. Open the Microsoft Visual Studio 6 workspace file (.dsw) in a newer version of Microsoft Visual Studio.
The project is converted to the new format.
2. Right click on the solution and select Extract Compaq Visual Fortran Project Items. This option
is available only if your installation of Microsoft Visual Studio includes Microsoft Visual C++ (MSVC).
82
Compiler Setup
NOTE Support for Microsoft Visual Studio 2017 is deprecated as of the Intel® oneAPI 2022.1 release,
and will be removed in a future release.
• Project conversion support is provided for Compaq Visual Fortran Version 6.x only. Compaq Visual Fortran
projects created with earlier versions may not convert correctly.
• Fortran source files, resource files, and MIDL files lose any custom build step information when converted
from Compaq Visual Fortran to Intel® Fortran. For other file types, custom build steps are propagated
during the project's conversion.
• Conversion of Fortran and C/C++ mixed language projects results in the creation of two separate projects
(a Fortran project and a C/C++ project) in a single solution.
• Intel® Fortran projects that are created with a point release (for instance, 2022.x) are typically backward
compatible to the first release of that number (in this case, 2022.0). Projects are not backward-
compatible between major release numbers.
See Also
Copying Projects
Copying Projects
You need to follow certain procedures to move a project's location if you copy a project to:
• Another disk or directory location on the same system.
• Another system where the Intel® Fortran Compiler is installed.
If you upgrade your operating system version on your current system, you should delete the *.SUO and
*.NCB files in each main project directory before you open solutions with the new operating system.
It is good practice to clean a solution before moving and copying project files. To do this, select Clean in the
Build menu.
83
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE The internal structure of module files can change between Intel® Fortran releases.
If you copied the project files to the same system or a system running the same platform and major
Intel® Fortran version, do the following steps to remove most or all of the files in the configuration
subdirectory:
1.
Open the appropriate solution. In the File menu, either select Open Solution or select Recent
Solutions. If you use Open Solution, select the appropriate .SLN file.
Select Set Active Configuration in the Build menu and select a configuration.
2.
Select Clean in the Build menu.
3.
Repeat the previous two steps for other configurations whose subdirectories have been copied.
4.
4. If possible, after copying a project, verify that you can open the project at its new location using the
same Fortran version that it was created in. This ensures that the project has been moved successfully
and minimizes the chance of conversion problems. If you open the project with a later version of
Fortran, the project will be converted and you will not be able to convert the project back. For this
reason, making an archive copy of the project files before you start is recommended.
5. View the existing configurations. To view the existing configurations associated with the project, open
the solution and view available configurations using the drop-down box at the top of the screen.
6. Check and reset project options.
Because not all settings are transportable across different disks and systems, you should verify your
project settings on the new platform. To verify your project settings:
a. From the Project menu, choose Properties. The Project Property Pages dialog box appears.
b. Configure settings as desired. Pay special attention to the following items:
•General: Review the directories for intermediate and output files. If you moved the project to
a different system, be aware that any absolute directory paths (such as C:\TEMP or \Myproj
\TEMP) will most likely need to be changed. Instead, use relative path directory names
(without a leading back slash), such as Debug
• Custom Build Step: Review for any custom commands that might change between platforms.
• Pre-build, Pre-link, and Post-build Steps in Build Events: Review for any custom
commands that may have changed.
7. Check your source code for directory paths referenced in INCLUDE or similar statements. Microsoft
Visual Studio* provides a multi-file search capability called Find in Files, available from the Edit
menu.
84
Compiler Setup
The following table lists the available Intel® Fortran Compiler project types. The first four projects listed are
main project types, requiring main programs. The last two are library projects, without main programs.
Using Fortran Single window main projects without graphics (resembles character-cell
Console applications). Requires no special programming expertise.
Application
Projects (.EXE)
Using Fortran Single window main projects with graphics. The programming complexity is simple
Standard Graphics to moderate, depending on the graphics and user interaction used.
Application
Projects (.EXE)
Using Fortran Multiple window main projects with graphics. The programming complexity is simple
QuickWin to moderate, depending on the graphics and user interaction used.
Application
Projects (.EXE)
Using Fortran Multiple window main projects with full graphical interface and access to all
Windowing Windows* API routines. Requires advanced programming expertise and knowledge
Application of the Calling Windows API Routines.
Projects (.EXE)
If you need to use the command line to build your project, you can:
• Use the command line compiler options to specify the project type (see Specifying Project Types with ifort
Command Options).
• Create the application from the command line (see Invoking the Intel® Fortran Compiler).
See Also
Understanding Solutions Projects and Configurations
Selecting a Configuration
• To create console application projects, you do not need to specify any options. (If you link separately,
specify the link option /subsystem:console.) A console application is the default project type created.
85
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• To create standard graphics application projects, specify the libs option with keyword qwins (also sets
certain linker options).
• To create QuickWin application projects, specify the libs option with keyword qwin (also sets certain
linker options).
• To create windowing application projects, specify the winapp option (also sets certain linker options).
See Also
Understanding Project Types
Using Fortran Console Application Projects
Using Fortran Standard Graphics Application Projects
Using Fortran QuickWin Application Projects
Using Fortran Windowing Application Projects
Using Fortran Dynamic-Link Library Projects
Using Fortran Static Library Projects
86
Compiler Setup
See Also
Using the Console
Create a Standard Graphics Application with the Microsoft Visual Studio* IDE
1. Select the QuickWin Application project type.
2. Select the Standard Graphics Application template.
When you select the Fortran standard graphics project type, the IDE includes the QuickWin library
automatically, which lets you use the graphics functions. When building from the command line, you must
specify the libs option with keyword qwins. You cannot use the runtime functions meant for multiple-
window projects if you are building a standard graphics project. You cannot make a standard graphics
application a DLL.
See Also
Additional Documentation: Creating Fortran Applications that Use Windows* Features
87
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Applications that use a multiple-document interface (MDI) have a menu bar at the top of the window and a
status bar at the bottom. The QuickWin library provides a default set of menus and menu items that you can
customize with the QuickWin APIs. An application that uses MDI creates many "child" windows within an
outer application window. The user area in an MDI application is a child window that appears in the space
between the menu bar and status bar of the application window. Your application can have more than one
child window open at a time.
Fortran QuickWin applications can use the IFLOGM module to access functions to control dialog boxes. These
functions allow you to display, initialize, and communicate with special dialog boxes in your application. They
are a subset of Windows* API functions, which Windows* applications can call directly.
To create a QuickWin application in Visual Studio*:
1. Select the QuickWin Application project type.
2. Select the QuickWin Application template in the right pane.
When you select the Fortran QuickWin project type, the IDE includes the QuickWin library automatically,
which lets you use the graphics functions.
When building from the command line, you must specify the libs compiler option with keyword qwin to
indicate a QuickWin application.
A QuickWin application covers the entire screen if the resolution selected matches the screen size; otherwise,
the window will contain scroll bars.
You cannot make a Fortran QuickWin application a DLL.
See Also
Additional Documentation: Creating Fortran Applications that Use Windows* Features
See Also
Calling Windows* API Routines
88
Compiler Setup
NOTE
When compiling a static library from the command line, include the c option to suppress linking.
Without this option, the compiler generates an error because the library does not contain a main
program.
When you create a static library, you are asked to specify whether you want to prevent the insertion of link
directives for default libraries. By default, this checkbox is selected, which means insertion of link directives
is prevented. Select this option if you plan to use this static library with other Fortran projects. The option
prevents the static library from specifying a version of the Fortran run-time library. When the static library is
linked with another Fortran project, the Fortran run-time library choice in the other Fortran project is used for
the static library as well.
You may decide against selecting this option if you plan to use this static library with C/C++ projects. If you
do select it, you need to explicitly name the Fortran run-time library to use in the Linker Additional
Dependencies property. You can change your selection after creating the project using the Fortran Disable
Default Library Search Rules property.
A static library is a collection of source and object code defined in the Solution Explorer window. The
source code is compiled when you build the project. The object code is assembled into a .LIB file without
going through a linking process. The name of the project is used as the name of the library file by default.
Static libraries offer important advantages in organizing large programs and in sharing routines between
several programs. These libraries contain only subprograms, not main programs. A static library file has
a .LIB extension and contains object code.
When you associate a static library with a program, any necessary routines are linked from the library into
your executable program when it is built. Static libraries are usually kept in their own directories. If you use a
static library, only those routines actually needed by the program are incorporated into the executable image
(.EXE). This means that your executable image will be smaller than if you included all the routines in the
library in your executable image. The Linker determines which routines to include.
Because applications built with a static library all contain the same version of the routines in the library, you
can use static libraries to help keep applications current. When you revise the routines in a static library, you
can easily update all the applications that use it by relinking the applications.
If you have a library of substantial size, you should maintain it in a dedicated directory. Projects using the
library access it during linking.
When you link a project that uses the library, selected object code from the library is linked into that project's
executable code to satisfy calls to external procedures. Unnecessary object files are not included.
To debug a static library, you must use a main program that calls the library routines. Both the main program
and the static library should have been compiled using the debug option. After compiling and linking is
completed, open the Debug menu and choose Go to reach breakpoints, or use the step controls on the
Debug toolbar.
89
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Additional Documentation: Creating Fortran Applications that Use Windows* OS Features
90
Compiler Setup
Fortran Provides a console window intended to be used for character-cell applications that use
Console text only.
When running a Fortran Console application from the command prompt, the existing
console environment is used. When you run the application from Windows* or Developer
Studio* (by selecting Start Without Debugging in the Debug menu), a new console
environment is created.
Basic console use is described in Code Samples of Console Use.
Fortran Does not provide a console, but output to unit 6 and input to unit 5 are directed to the
QuickWin or application program window, which can handle both text and graphics. Because the
Fortran program window must handle both text and graphics, it is not as efficient as the console
Standard for just text-only use. A Fortran QuickWin or Fortran Standard Graphics program window
Graphics (or child window) provides a console-like window.
See Console Use for Fortran QuickWin and Fortran Standard Graphics Applications.
Fortran Does not provide a console window, but the user can create a console by using Windows*
Windows API routines. See Console Use for Fortran Windows* Applications and Fortran DLL
Applications.
Fortran DLL Does not provide a console window, but the user can create a console by using Win32
routines. See Console Use for Fortran Windows* Applications and Fortran DLL
Applications.
Fortran Static Depends upon the project type of the main application that references the object code in
Library the library (see above project types).
In addition to the Windows* API routines mentioned below, there are other routines related to console use
described in the Microsoft Platform SDK* documentation.
Console Use for Fortran QuickWin and Fortran Standard Graphics Applications
For a Fortran QuickWin or Fortran Standard Graphics application, because the default program window
handles both graphics and text, the use of a QuickWin window may not be very efficient:
• QuickWin windows use lots of memory and therefore have size limitations.
• They can be slow to scroll.
Although you can access the console window using WRITE and READ (or other) statements, applications that
require display of substantial lines of text, consider creating a DLL that creates a separate console window for
efficiency. The DLL application needs to call Windows* API routines to allocate the console, display text,
accept keyed input, and free the console resources.
Basic use of a console is described in Code Samples of Console Use.
Console Use for Fortran Windows Applications and Fortran DLL Applications
With a Fortran Windows* or Fortran DLL application, attempting to write to the console using WRITE and
READ (or other) statements before a console is created results in a run-time error (such as error performing
WRITE).
A console created by a Fortran DLL is distinct from any application console window associated with the main
application. A Fortran DLL application has neither a console nor an application window created for it, so it
must create (allocate) its own console using Windows* API routines. When used with a Fortran QuickWin or
Fortran Standard Graphics application main program, the Fortran DLL can provide its main application with a
very efficient console window for text-only use.
91
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Like a Fortran DLL application, a Fortran Windows application has neither a console nor an application
window created for it, so it must create its own console using Windows* API routines. After allocating a
console in a Fortran DLL, the handle identifier returned by the GetStdHandle Windows* API routine refers
to the actual console the DLL creates.
When the Fortran Windows application does create a console window, it is very efficient for text-only use.
The handle identifier returned by the GetStdHandle Calling Windows* API Routines refers to the actual
console the Fortran Windows application creates.
For information about creating a console, see Allocating and Deallocating a Console below.
92
Compiler Setup
For example:
93
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
sr.top = 0
sr.left = 0
sr.bottom = 40 ! <= console buffer height
-1
sr.right = 60 ! <=
console buffer width -1
lstat = SetConsoleWindowInfo(fhandle, .TRUE., sr)
! Executable code to set console buffer size
nlines = 100
ncols = 80
wpos.x = ncols ! columns >= console window width
wpos.y = nlines ! lines >= console window height
lstat = SetConsoleScreenBufferSize(fhandle, wpos)
! ...
See Also
Understanding Project Types
Calling Windows* API Routines
Using the Console
Code Samples of Console Use
Console Use for Fortran QuickWin and Fortran Standard Graphics Applications
Console Use for Fortran Windows* Applications and Fortran DLL Applications
Allocating and Deallocating a Console
Extending Size of the Console Window and Console Buffer
Writing and Reading Characters at a Cursor Position
94
Compiler Setup
See Also
Intel® Software Documentation Library
NOTE You can specify how you want the optimization reporting to appear with the Optimization
Reports dialog box. Access this dialog box by selecting Tools > Options > Intel Compilers and
Libraries > Optimization Reports.
95
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Options: Optimization Reports dialog box
Do This To Do This
Click a link in the Inlined into column. Jump to the call site of the function where the loop
is inlined.
Expand or collapse a diagnostic in Group by loops View detailed information for the diagnostic.
view.
Click the filter button. Select a scope by which to filter the diagnostics
that appear in the window.
The title bar of the Compiler Optimization
Report window shows the applied filter. Labels on
optimization phase filter buttons show how many
diagnostics of each phase are in the current scope.
Click a Compiler Optimization Report window Turn filtering diagnostics on or off for an
toolbar button corresponding to an optimization optimization phase.
report phase.
Labels on optimization phase filter buttons show
the total number of diagnostics for each phase.
By default all phases turned on.
Enter text in the search box in the Compiler Filter diagnostics using the text pattern.
Optimization Report window toolbar.
Diagnostics are filtered when you stop typing.
Pressing Enter saves this pattern in the search
history.
96
Compiler Setup
Do This To Do This
Do This To Do This
Double-click a diagnostic in the tree, or click on the Jump to the corresponding position in the editor.
source position link under the Properties tab.
Click Just My Code. Only display functions from your code, filter all
records from files that don't belong to the current
solution file tree.
Right-click on a function body in the editor and View detailed information for the specified function.
select Intel Compiler > Show Inline report for
function name.
Right-click on a function body in the editor and Show where the specified function is inlined.
select Intel Compiler > Show where function
name in inlined.
Enter text in the search box in the Compiler Inline Filter diagnostics using the text pattern.
Report window toolbar.
Diagnostics are filtered when you stop typing.
Pressing Enter saves this pattern in the search
history.
To disable filtering, clear the search box.
To use a pattern from the search history, click on
the down arrow next to the search box.
Do This To Do This
97
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Do This To Do This
Double-click an optimization note heading. Expand or collapse the current optimization note.
Click a hyperlink in the optimization note. Show where the specified function is inlined.
Click the help (?) icon. Get detailed help for the selected diagnostic. The
default browser opens and, if you are connected to
the internet, displays the help topic for this
diagnostic.
Hover the mouse over a collapsed optimization View a detailed tooltip about that optimization note.
note.
See Also
Optimization Reports: Enabling in Visual Studio*
qopt-report-phase, Qopt-report-phase
Build Options
Continue on Errors: Check this box to allow compilation to continue regardless of an error in the current
file. The compiler will begin compiling the next file. (To set the maximum number of errors to encounter
before compilation stops, choose Configuration Properties > Fortran > Diagnostics > Error Limit).
Generate Build Logs: Check this box to generate build logs.
Show Environment in Log: Check this box to show environment variable settings in the log file.
98
Compiler Setup
Headers: Specify one or more file extensions for header files, each beginning with a period and separated by
semi-colons.
Sources: Specify one or more file extensions for source files, each beginning with a period and separated by
semi-colons.
Click OK to save your changes.
NOTE The compiler details are shown in the two boxes directly below.
Executables: Specifies the directory location for executable files. You may specify this setting for each
selected compiler.
Includes: Specifies the directory location for included files. You may specify this setting for each selected
compiler.
Libraries: Specifies the directory location for libraries. You may specify this setting for each selected
compiler.
Default options: Sets the default options for a selected compiler You may specify this setting for each
selected compiler.
Reset...: Resets the settings for the compiler.
NOTE The compiler details are shown in the two boxes directly below.
Executables: Specifies the directory location for executable files. You may specify this setting for each
selected compiler.
Includes: Specifies the directory location for included files. You may specify this setting for each selected
compiler.
Libraries: Specifies the directory location for libraries. You may specify this setting for each selected
compiler.
Default options: Sets the default options for a selected compiler You may specify this setting for each
selected compiler.
Reset...: Resets the settings for the compiler.
99
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Selecting the Compiler Version
Specifying Path, Library, and Include Directories
Browsing/Navigation section
Collect Object Browser information: Choose this option to enable the display of procedures in your
project in a hierarchical tree. Once enabled, you can use View > Object Browser to display your
procedures.
Disable Database: Choose this option to disable creation of the code browsing database. This may help
increase performance on slow machines. When you disable the database, all features that rely on code
browsing information do not work.
Enable Database Saving/Loading: Choose this option to save collected data to a file on disk so that all
source browsing features are available immediately when you open the project. When this option is disabled,
the code browsing database is generated via background source parsing, so many features that rely on code
browsing information do not work until this process completes. Saving and loading the database requires
some additional time when saving and loading the project.
Enable Find all References: Choose this option to enable display of the location(s) in your code where a
symbol is referenced. When this option is enabled, you can use the right-click context menu Find All
References option to display a list of references to the selected symbol. Double-click on a reference to find
that reference.
Enable Go To Definition: Choose this option to enable quick navigation to an object definition. When this
option is enabled, you can use the right-click context menu Go to Definition option to locate where the
selected object was declared, opening the associated source file if required. (If you have also enabled Scan
system includes, any objects declared in system modules such as IFWINTY cause the associated source for
that module to be opened.)
Scan system includes: Choose this option to scan system include files. This option is used with one or
more of the following options: Collect Object Browser Information, Enable Find All References,
Enable Go To Definition.
Intrinsics section
Enable Intrinsic Parameter Info: Choose this option to enable the display of intrinsic function and
subroutine parameter information. When this option is enabled, you can type a name of an intrinsic
procedure, followed by an open parenthesis, and information about the procedure and its arguments
appears.
Enable Intrinsic Quick Info: Choose this option to enable the display of additional information when the
mouse pointer is moved over an intrinsic function or subroutine name.
Miscellaneous section
Enumerate Comment Tasks: Choose this option to enable the display of a list of tasks consisting of source
files containing comments. Comments take the form of the ! character, followed by a token such as TO DO.
Valid tokens are those listed in Tools > Options > Environment > Task List. When this option is enabled,
you can select Comments from the task list using View > Other Windows Task List. Double-click on a
comment in the list to jump to its location.
100
Compiler Setup
Highlight Matching Tokens: Choose this option to allow identifier highlighting and block delimiter
matching. When enabled, this option highlights all references to the identifier under the cursor.
Outlining Section
Enable Outlining: Choose this option to allow the collapsing of whole program units. When this option is
enabled, you can click the minus (-) or plus (+) symbols for PROGRAM, SUBROUTINE, FUNCTION, MODULE,
and BLOCK DATA statements.
Outline Statement Blocks: Choose this option to allow collapsing of block constructs such as IF and DO.
You must also choose Enable Outlining.
See Also
Options: Guided Auto Parallelism dialog box
NOTE These settings are used when running analysis using Tools > Intel Compiler > Guided Auto
Parallelism > Run Analysis on project...
101
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Suppress compiler warnings: Check this box to suppress compiler warnings. Selection adds option W0 to
the compiler command line.
Suppress Remark IDs: Specify one or more remark IDs to suppress. Use a comma to separate IDs.
Send remarks to a file: Check this box to send GAP remarks to a specified text file.
Remarks file: Specify the filename to send GAP remarks to.
Show all GAP configuration and informational dialogs: Check this box to display additional dialog boxes
when you run an analysis.
Reset: Click this button to restore the previously selected settings.
See Also
Using Guided Auto Parallelism in Microsoft Visual Studio*
102
Compiler Setup
Phase 2 - Run Instrumented Application(s): This phase runs the instrumented application produced in
the previous phase as well as other applications in the Applications Invocations dialog box. To add a new
application or edit an existing application in the list, click Applications Invocations.
Deselect the checkbox to skip this phase to save time running profile guided optimization. When you skip this
phase, you do not run the applications in the list when running profile guided optimization. For example, you
might want to skip this phase when you change the code to fix a bug and the fix doesn't affect the
architecture of the project.
Phase 3 - Optimize with Profile Data: This phase performs the profile guided optimization.
Deselect the checkbox to skip this phase.
Profile Directory: The directory that contains the profile. Click Edit to edit the profile directory or the
Browse button to browse for the profile directory.
Show this dialog next time: Deselect this checkbox to run profile guided optimization without displaying
this dialog box. The profile guided optimization will use these settings.
Save Settings: Click to save your settings.
Run: Click to start the profile guided optimization.
Cancel: Click to close this dialog box without starting the profile guided optimization.
103
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Merge Environment: Select this checkbox to merge the application environment with the environment
defined by the operating system.
Load from Debugging Settings: Click to load the debug settings for this application.
OK: Click to save the settings and close this dialog box.
Cancel: Click to discard the settings and close this dialog box.
See Also
Profile-Guided Optimization
Using Function Order Lists, Function Grouping, Function Ordering, and Data Ordering
Optimizations
See Also
Using Profile Guided Optimization in Microsoft* Visual Studio*
Profile-Guided Optimizations
104
Compiler Setup
See Also
Options: Guided Auto Parallelism dialog box
See Also
Using Code Coverage in Microsoft Visual Studio*
105
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
General
Show Code Coverage Dialog: Specify whether to display the Code Coverage dialog box when you begin
code coverage.
Profmerge Options
Suppress Startup Banner: Specify whether version information is displayed.
Verbose: Specify whether additional informational and warning messages should be displayed.
See Also
Using Code Coverage in Microsoft Visual Studio*
Profmerge options
Dump Profile Information: Set to True to include profile information in the report.
Exclude Functions: Enter the functions that will be excluded from the profile. The functions must be
separated by a comma (","). A period (".") can be used as a wildcard character in function names.
OK: Click to save your settings and close this dialog box.
Cancel: Click to discard the settings and close this dialog box.
106
Compiler Setup
See Also
Code Coverage dialog box
Using Code Coverage in the Microsoft Visual Studio* IDE
code coverage Tool
General
Always Show Compiler Inline Report: Specify if the Compiler Inline Report appears after building or
rebuilding your solution or project when inline diagnostics are present.
Always Show Compiler Optimization Report: Specify if Compiler Optimization Report appears after
building or rebuilding your solution or project when optimization diagnostics are present. This option has
higher priority than Always Show Compiler Inline Report. If both options are set to True, then this
window has focus by default.
Show Optimization Notes in Text Editor Margin: Specify if optimization notes appear in the editor as
source code annotations.
See Also
Optimization Reports: Enabling in Visual Studio*
107
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Part
II
Compiler Reference I
This section contains compiler reference information. For example, it contains information about compiler
options, compiler limits, and libraries.
Compiler Limits
The amount of data storage, the size of arrays, and the total size of executable programs are limited only by
the amount of process virtual address space available, as determined by system parameters.
The table below shows the limits to the size and complexity of a single Intel® Fortran program unit and to
individual statements contained within it:
Array dimensions 31
(The Fortran 2018 standard supports a maximum array
dimension of 15.)
Continuation lines No fixed limit; at least 255 lines of 132 or fewer characters.
Longer lines may reduce the number of allowed continuations,
subject to the limit on lexical tokens per statement.
108
Compiler Reference
Fortran source line length fixed form: 72 (or 132 if /extend_source is in effect)
characters
free form: 7200 characters
Structure nesting 30
Width field for a numeric edit descriptor 2**15-1 on systems using IA-32 architecture
2**31-1 on systems using Intel® 64 architecture
For limits of other edit descriptor fields, see Forms for Data
Edit Descriptors.
For more information on memory limits for large data objects, see:
• The AUTOMATIC statement
• The /F compiler option
• The heap-array compiler option
• The product Release Notes
See Also
Forms for Data Edit Descriptors
109
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
The objects listed here are provided as an advanced feature for developers who are already familiar
with using Automation objects and the Visual Studio* object model.
Object Description
VFCustomBuildTool Programmatically accesses the properties in the Custom Build Step property page
in a project's Property Pages dialog box.
VFDebugSettings Contains properties that allow the user to programmatically manipulate the settings
in the Debug property page.
VFFile Describes the operations that can take place on a file in the active project.
VFFileConfiguration Contains build information about a file (VFFile object), including such things as what
tool is attached to the file for that configuration.
VFFilter Exposes the functionality on a folder in Solution Explorer for an Intel® Visual Fortran
project.
VFFortranCompiler Provides access to properties relating to the Intel® Visual Fortran Compiler version.
Version
VFManifestTool Programmatically accesses the properties in the Manifest Tool folder of a project's
Property Pages dialog box.
VFMidlTool Programmatically accesses the properties in the MIDL folder of a project's Property
Pages dialog box.
VFPreBuildEventTo Programmatically accesses the properties on the Pre-Build Event property page, in
ol the Build Events folder in a project's Property Pages dialog box.
110
Compiler Reference
VFPreLinkEventToo Programmatically accesses the properties on the PreLink Event property page, in
l the Build Events folder in a project's Property Pages dialog box.
VFPostBuildEventT Programmatically accesses the properties on the Post-Build Event property page,
ool in the Build Events folder in a project's Property Pages dialog box.
The following example, written in Visual Basic*, demonstrates how to use automation objects to modify the
list of available platforms and versions in the Visual Studio* IDE Configuration Manager:
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports System.Diagnostics
Imports Microsoft.VisualStudio.VFProject
Imports System.Collections
Public Module MultiPV
' Create a Console application before executing this module
' Module demonstrates Multi Platform & Multi Version Automation Support
' Variable definition
Dim Prj As Project ' VS project
Dim VFPrj As VFProject ' Intel VF project
Dim o As Object ' Object
Sub run()
' Get the Project
Prj = DTE.Solution.Projects.Item(1)
'
' Get Intel VF project
VFPrj = Prj.Object
'
' Get list of Supported platforms
Dim pList As ArrayList = New ArrayList() ' list of platforms
Dim cList As ArrayList = New ArrayList() ' lost of compilers
Dim i As Integer
pList = getSupportedPlatforms()
For i = 0 To pList.Count - 1
cList = getCompilers(pList.Item(i))
printCompilers(pList.Item(i), cList)
Next
'
' Add configurations - x64
For i = 0 To pList.Count - 1
If pList.Item(i) <> "Win32" Then
addConfiguration(pList.Item(i))
End If
Next
Dim cfgsList As ArrayList = New ArrayList() ' list of configurations
cfgsList = getAllConfigurations()
'
' Set compiler
For i = 0 To pList.Count - 1
Dim pNm As String
Dim cvList As ArrayList = New ArrayList()
pNm = pList.Item(i)
cList = getCompilers(pNm)
cvList = getCompilerVersions(pNm)
111
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Dim j As Integer
For j = 0 To cvList.Count - 1
Dim cv As String = cvList.Item(j)
If SetCmplrForPlatform(pNm, cv) Then
setActiveCfg(pNm)
SolutionRebuild()
Dim sOut As String = GetOutput()
Dim scv As String = CheckCompiler(sOut)
MsgBox(pNm + " " + cv + " " + scv)
End If
Next
Next
End Sub
' get context from Output window
Function GetOutput() As String
Dim win As Window
Dim w As OutputWindow
Dim wp As OutputWindowPane
Dim td As TextDocument
win = DTE.Windows.Item(Constants.vsWindowKindOutput)
w = win.Object
Dim i As Integer
For i = 1 To w.OutputWindowPanes.Count
wp = w.OutputWindowPanes.Item(i)
If wp.Name = "Build" Then
td = wp.TextDocument
td.Selection.SelectAll()
Dim ts As TextSelection = td.Selection
GetOutput = ts.Text
Exit Function
End If
Next
End Function
Function CheckCompiler(ByVal log As String) As String
Dim s As String
Dim beg_ As Integer
Dim end_ As Integer
beg_ = log.IndexOf("Compiling with")
beg_ = log.IndexOf("Intel", beg_)
end_ = log.IndexOf("]", beg_)
s = log.Substring(beg_, end_ - beg_ + 1)
CheckCompiler = s
End Function
Function SetCmplrForPlatform(ByVal plNm As String, ByVal vers As String) As Boolean
Dim pl As VFPlatform
Dim cll As IVFCollection
Dim cvs As IVFCollection
Dim cv As VFFortranCompilerVersion
Dim maj As String
Dim min As String
Dim ind As Integer
Try
ind = vers.IndexOf(".")
maj = vers.Substring(0, ind)
min = vers.Substring(ind + 1)
cll = VFPrj.Platforms
pl = cll.Item(plNm)
If pl Is Nothing Then
112
Compiler Reference
113
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
cv = cvs.Item(j)
Dim vers As String
vers = cv.MajorVersion.ToString() + "." + cv.MinorVersion.ToString()
list.Add(vers)
Next
getCompilerVersions = list
End Function
Sub printCompilers(ByVal plNm As String, ByVal list As ArrayList)
Dim s As String
s = "Platform " + plNm + Chr(13)
Dim i As Integer
For i = 0 To list.Count - 1
s += " " + list.Item(i) + Chr(13)
Next
MsgBox(s)
End Sub
Sub addConfiguration(ByVal cfgNm As String)
Dim cM As ConfigurationManager
cM = Prj.ConfigurationManager
cM.AddPlatform(cfgNm, "Win32", True)
End Sub
Function getAllConfigurations() As ArrayList
Dim list As ArrayList = New ArrayList()
Dim cM As ConfigurationManager
Dim i As Integer
Dim c As Configuration
cM = Prj.ConfigurationManager
For i = 1 To cM.Count
c = cM.Item(i)
list.Add(c.ConfigurationName + "|" + c.PlatformName)
Next
getAllConfigurations = list
End Function
Sub setActiveCfg(ByVal pNm As String)
Dim scs As SolutionConfigurations = DTE.Solution.SolutionBuild.SolutionConfigurations
Dim i As Integer
Dim j As Integer
For i = 1 To scs.Count
Dim sc As SolutionConfiguration
Dim sctxs As SolutionContexts
sc = scs.Item(i)
sctxs = sc.SolutionContexts
For j = 1 To sctxs.Count
Dim sctx As SolutionContext = sctxs.Item(j)
If sctx.ConfigurationName = "Debug" And sctx.PlatformName = pNm Then
sc.Activate()
Exit Sub
End If
Next
Next
End Sub
Sub SolutionRebuild()
DTE.Solution.SolutionBuild.Clean(True)
DTE.Solution.SolutionBuild.Build(True)
End Sub
End Module
114
Compiler Options
Compiler Options
This compiler supports many compiler options you can use in your applications.
The LLVM-based Intel® Fortran Compiler supports many Intel® Fortran Compiler Classic compiler options, but
full implementation is not yet available for ifx.1. Implementation will be improved in future releases.
In this section, we provide the following:
• An alphabetical list of compiler options that includes their short descriptions
• Lists of new options and lists of deprecated and removed options
• General rules for compiler options and the conventions we use when referring to options
• Details about what appears in the compiler option descriptions
• A description of each compiler option. The descriptions appear under the option's functional category.
Within each category, the options are listed in alphabetical order.
New Options
This topic lists the options or option settings that provide new functionality in this release.
If no label appears, the option is available on all supported systems.
If "only" appears in the label, the option is only available on the identified system.
For more details on the options, refer to the individual option descriptions.
For information on conventions used in this table, see Notational Conventions.
New compiler options or option settings are listed in tables below:
• The first table lists new options or option settings that are available on Windows* systems.
• The second table lists new options or option settings that are available on Linux* and macOS* systems. If
an option is only available on one of these operating systems, it is labeled.
115
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
4Nportlib, 4Yportlib Determines whether the compiler links to the library of portability
routines.
ansi-alias, Qansi-alias Tells the compiler to assume certain rules of the Fortran standard
regarding aliasing and array bounds.
arch Tells the compiler which features it may target, including which
instruction sets it may generate.
auto-scalar, Qauto-scalar Causes scalar variables of intrinsic types INTEGER, REAL, COMPLEX, and
LOGICAL that do not have the SAVE attribute to be allocated to the run-
time stack.
B Specifies a directory that can be used to find include files, libraries, and
executables.
bigobj Increases the number of sections that an object file can contain. This
feature is only available for ifort.
bintext Places a text string into the object file (.obj) being generated by the
compiler. This feature is only available for ifort.
116
Compiler Reference
c Prevents linking.
ccdefault Specifies the type of carriage control used when a file is displayed at a
terminal screen.
coarray-config-file, Qcoarray- Specifies the name of a Message Passing Interface (MPI) configuration
config-file file.
coarray-num-images, Specifies the default number of images that can be used to run a coarray
Qcoarray-num-images executable.
cxxlib Determines whether the compiler links using the C++ run-time libraries
provided by gcc.
dbglibs Tells the linker to search for unresolved references in a debug run-time
library.
debug-parameters Tells the compiler to generate debug information for PARAMETERs used in
a program.
diag-dump, Qdiag-dump Tells the compiler to print all enabled diagnostic messages.
diag-error-limit, Qdiag-error- Specifies the maximum number of errors allowed before compilation
limit stops.
diag-id-numbers, Qdiag-id- Determines whether the compiler displays diagnostic messages by using
numbers their ID number values.
diag-once, Qdiag-once Tells the compiler to issue one or more diagnostic messages only once.
117
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
double-size Specifies the default KIND for DOUBLE PRECISION and DOUBLE COMPLEX
declarations, constants, functions, and intrinsics.
dryrun Specifies that driver tool commands should be shown but not executed.
dynamiclib Invokes the libtool command to generate dynamic libraries. This feature
is only available for ifort.
extend-source Specifies the length of the statement field in a fixed-form source file.
F ( macOS* ) Adds a framework directory to the head of an include file search path.
This feature is only available for ifort.
f77rtl Tells the compiler to use the run-time behavior of FORTRAN 77.
falias, Oa Specifies whether or not a procedure call may have hidden aliases of local
variables not supplied as actual arguments.
falign-functions, Qfnalign Tells the compiler to align procedures on an optimal byte boundary.
falign-loops, Qalign-loops Aligns loops to a power-of-two byte boundary. This feature is only
available for ifort.
falign-stack Tells the compiler the stack alignment to use on entry to routines. This
option is deprecated and will be removed in a future release. This feature
is only available for ifort.
fast-transcendentals, Qfast- Enables the compiler to replace calls to transcendental functions with
transcendentals faster but less precise implementations. This feature is only available for
ifort.
118
Compiler Reference
fcode-asm Produces an assembly listing with machine code annotations. This feature
is only available for ifort.
Fd Lets you specify a name for a program database (PDB) file created by the
compiler. This feature is only available for ifort.
fexceptions Enables exception handling table generation. This feature is only available
for ifort.
fimf-absolute-error, Qimf- Defines the maximum allowable absolute error for math library function
absolute-error results. This feature is only available for ifort.
fimf-accuracy-bits, Qimf- Defines the relative error for math library function results, including
accuracy-bits division and square root. This feature is only available for ifort.
fimf-arch-consistency, Qimf- Ensures that the math library functions produce consistent results across
arch-consistency different microarchitectural implementations of the same architecture.
This feature is only available for ifort.
fimf-domain-exclusion, Qimf- Indicates the input arguments domain on which math functions must
domain-exclusion provide correct results. This feature is only available for ifort.
fimf-force-dynamic-target, Instructs the compiler to use run-time dispatch in calls to math functions.
Qimf-force-dynamic-target
fimf-max-error, Qimf-max- Defines the maximum allowable relative error for math library function
error results, including division and square root. This feature is only available
for ifort.
fimf-precision, Qimf-precision Lets you specify a level of accuracy (precision) that the compiler should
use when determining which math library functions to use. This feature is
only available for ifort.
fimf-use-svml, Qimf-use-svml Instructs the compiler to use the Short Vector Math Library (SVML) rather
than the Intel® Math Library (LIBM) to implement math library functions.
finline Tells the compiler to inline functions declared with !DIR$ ATTRIBUTES
FORCEINLINE .
finstrument-functions, Determines whether routine entry and exit points are instrumented.
Qinstrument-functions
119
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
fkeep-static-consts , Qkeep- Tells the compiler to preserve allocation of variables that are not
static-consts referenced in the source. This feature is only available for ifort.
fma, Qfma Determines whether the compiler generates fused multiply-add (FMA)
instructions if such instructions exist on the target processor.
fmath-errno Tells the compiler that errno can be reliably tested after calls to standard
math library functions. This feature is only available for ifort.
fmerge-constants Determines whether the compiler and linker attempt to merge identical
constants (string constants and floating-point constants) across
compilation units. This feature is only available for ifort.
fmpc-privatize Enables or disables privatization of all static data for the MultiProcessor
Computing environment (MPC) unified parallel runtime. This feature is
only available for ifort.
fnsplit, Qfnsplit Enables function splitting. This feature is only available for ifort.
fopenmp-target-buffers, Enables a way to overcome the problem where some OpenMP* offload
Qopenmp-target-buffers SPIR-V* devices produce incorrect code when a target object is larger
than 4GB. This feature is only available for ifx.
fopenmp-targets, Qopenmp- Enables offloading to a specified GPU target if OpenMP* features have
targets been enabled. This feature is only available for ifx.
foptimize-sibling-calls Determines whether the compiler optimizes tail recursive calls. This
feature is only available for ifort.
fpe Allows some control over floating-point exception handling for the main
program at run-time.
fpe-all Allows some control over floating-point exception handling for each
routine in a program at run-time.
120
Compiler Reference
fp-port, Qfp-port Rounds floating-point results after floating-point operations. This feature
is only available for ifort.
fprotect-parens, Qprotect- Determines whether the optimizer honors parentheses when floating-
parens point expressions are evaluated.
fpscomp Controls whether certain aspects of the run-time system and semantic
language features within the compiler are compatible with Intel® Fortran
or Microsoft* Fortran PowerStation.
fp-speculation, Qfp- Tells the compiler the mode in which to speculate on floating-point
speculation operations.
fp-stack-check, Qfp-stack- Tells the compiler to generate extra code after every function call to
check ensure that the floating-point stack is in the expected state. This feature
is only available for ifort.
fsource-asm Produces an assembly listing with source code annotations. This feature is
only available for ifort.
fstack-protector Enables or disables stack overflow security checks for certain (or all)
routines.
fstack-security-check Determines whether the compiler generates code that detects some
buffer overruns.
ftrapuv , Qtrapuv Initializes stack local variables to an unusual value to aid error detection.
This feature is only available for ifort.
fuse-ld Tells the compiler to use a different linker instead of the default linker
(ld). This feature is only available for ifort.
fvisibility Specifies the default visibility for global symbols or the visibility for
symbols in a file. This feature is only available for ifort.
fzero-initialized-in-bss, Qzero- Determines whether the compiler places in the DATA section any
initialized-in-bss variables explicitly initialized with zeros. This feature is only available for
ifort.
gcc-name Lets you specify the name of the GCC compiler that should be used to set
up the link-time environment, including the location of standard libraries.
gdwarf Lets you specify a DWARF Version format when generating debug
information.
gen-dep Tells the compiler to generate build dependencies for the current
compilation.
gen-depformat Specifies the form for the output generated when option gen-dep is
specified.
121
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
gen-interfaces Tells the compiler to generate an interface block for each routine in a
source file.
global-hoist, Qglobal-hoist Enables certain optimizations that can move memory loads to a point
earlier in the program execution than where they appear in the source.
This feature is only available for ifort.
grecord-gcc-switches Causes the command line options that were used to invoke the compiler
to be appended to the DW_AT_producer attribute in DWARF debugging
information.
Gs Lets you control the threshold at which the stack checking routine is
called or not called. This feature is only available for ifort.
guide, Qguide Lets you set a level of guidance for auto-vectorization, auto parallelism,
and data transformation. This feature is only available for ifort.
guide-data-trans, Qguide- Lets you set a level of guidance for data transformation. This feature is
data-trans only available for ifort.
guide-file, Qguide-file Causes the results of guided auto parallelism to be output to a file. This
feature is only available for ifort.
guide-file-append, Qguide- Causes the results of guided auto parallelism to be appended to a file.
file-append This feature is only available for ifort.
guide-opts, Qguide-opts Tells the compiler to analyze certain code and generate recommendations
that may improve optimizations. This feature is only available for ifort.
guide-par, Qguide-par Lets you set a level of guidance for auto parallelism. This feature is only
available for ifort.
guide-vec, Qguide-vec Lets you set a level of guidance for auto-vectorization. This feature is only
available for ifort.
gxx-name Lets you specify the name of the g++ compiler that should be used to set
up the link-time environment, including the location of standard libraries.
heap-arrays Puts automatic arrays and arrays created for temporary computations on
the heap instead of the stack.
homeparams Tells the compiler to store parameters passed in registers to the stack.
This feature is only available for ifort.
hotpatch Tells the compiler to prepare a routine for hotpatching. This feature is
only available for ifort.
122
Compiler Reference
init, Qinit Lets you initialize a class of variables to zero or to various numeric
exceptional values.
inline-factor, Qinline-factor Specifies the percentage multiplier that should be applied to all inlining
options that define upper limits. This feature is only available for ifort.
inline-forceinline, Qinline- Instructs the compiler to force inlining of functions suggested for inlining
forceinline whenever the compiler is capable doing so. This feature is only available
for ifort.
inline-max-per-routine, Specifies the maximum number of times the inliner may inline into a
Qinline-max-per-routine particular routine. This feature is only available for ifort.
inline-max-size, Qinline-max- Specifies the lower limit for the size of what the inliner considers to be a
size large routine. This feature is only available for ifort.
inline-max-total-size, Qinline- Specifies how much larger a routine can normally grow when inline
max-total-size expansion is performed. This feature is only available for ifort.
inline-min-caller-growth, Lets you specify a procedure size n for which procedures of size <= n do
Qinline-min-caller-growth not contribute to the estimated growth of the caller when inlined. This
feature is only available for ifort.
inline-min-size, Qinline-min- Specifies the upper limit for the size of what the inliner considers to be a
size small routine. This feature is only available for ifort.
intconstant Tells the compiler to use FORTRAN 77 semantics to determine the kind
parameter for integer constants.
integer-size Specifies the default KIND for integer and logical variables.
intel-freestanding-target-os Lets you specify the target operating system for compilation.
ip-no-inlining, Qip-no-inlining Disables full and partial inlining enabled by interprocedural optimization
options. This feature is only available for ifort.
ipo-c, Qipo-c Tells the compiler to optimize across multiple files and generate a single
object file.
ipo-S, Qipo-S Tells the compiler to optimize across multiple files and generate a single
assembly file. This feature is only available for ifort.
123
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
ipo-separate, Qipo-separate Tells the compiler to generate one object file for every source file. This
feature is only available for ifort.
isystem Specifies a directory to add to the start of the system include path.
libdir Controls whether linker options for search libraries are included in object
files generated by the compiler.
libs Tells the compiler which type of run-time library to link to.
list-line-len Specifies the line length for the listing generated when option list is
specified.
list-page-len Specifies the page length for the listing generated when option list is
specified.
m32, m64 , Qm32, Qm64 Tells the compiler to generate code for a specific architecture. Option m32
(and /Qm32) is deprecated and will be removed in a future release. 32-
bit options are only available for ifort.
m80387 Specifies whether the compiler can use x87 instructions. This feature is
only available for ifort.
map-opts, Qmap-opts Maps one or more compiler options to their equivalent on a different
operating system.
march Tells the compiler to generate code for processors that support certain
features.
masm Tells the compiler to generate the assembler output file using a selected
dialect.
mbranches-within-32B- Tells the compiler to align branches and fused branches on 32-byte
boundaries, Qbranches- boundaries for better performance.
within-32B-boundaries
mcmodel Tells the compiler to use a specific memory model to generate code and
store data.
mconditional-branch, Lets you identify and fix code that may be vulnerable to speculative
Qconditional-branch execution side-channel attacks, which can leak your secure data as a
result of bad speculation of a conditional branch direction. This feature is
only available for ifort.
124
Compiler Reference
minstruction, Qinstruction Determines whether MOVBE instructions are generated for certain Intel®
processors. This feature is only available for ifort.
module Specifies the directory where module files should be placed when created
and where they should be searched for.
momit-leaf-frame-pointer Determines whether the frame pointer is omitted or kept in leaf functions.
This feature is only available for ifort.
mp1, Qprec Improves floating-point precision and consistency. This feature is only
available for ifort.
mstringop-inline-threshold, Tells the compiler to not inline calls to buffer manipulation functions such
Qstringop-inline-threshold as memcpy and memset when the number of bytes the functions handle
are known at compile time and greater than the specified value. This
feature is only available for ifort.
mstringop-strategy, Lets you override the internal decision heuristic for the particular
Qstringop-strategy algorithm used when implementing buffer manipulation functions such as
memcpy and memset. This feature is only available for ifort.
mtune, tune Performs optimizations for specific processors but does not cause
extended instruction sets to be used (unlike -march).
multiple-processes , MP Creates multiple processes that can be used to compile large numbers of
source files at the same time.
names Specifies how source code identifiers and external names are interpreted.
no-bss-init, Qnobss-init Tells the compiler to place in the DATA section any uninitialized variables
and explicitly zero-initialized variables. This option is deprecated and will
be removed in a future release. This feature is only available for ifort.
nodefaultlibs Prevents the compiler from using standard libraries when linking.
no-intel-lib, Qno-intel-lib Disables linking to specified Intel® libraries, or to all Intel® libraries.
nostartfiles Prevents the compiler from using standard startup files when linking.
nostdlib Prevents the compiler from using standard libraries and startup files when
linking.
125
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Ofast Sets certain aggressive options to improve the speed of your application.
pad, Qpad Enables the changing of the variable and array memory layout.
par-affinity, Qpar-affinity Specifies thread affinity. This feature is only available for ifort.
parallel, Qparallel Tells the auto-parallelizer to generate multithreaded code for loops that
can be safely executed in parallel. This feature is only available for ifort.
par-num-threads, Qpar-num- Specifies the number of threads to use in a parallel region. This feature is
threads only available for ifort.
par-runtime-control, Qpar- Generates code to perform run-time checks for loops that have symbolic
runtime-control loop bounds. This feature is only available for ifort.
par-schedule, Qpar-schedule Lets you specify a scheduling algorithm for loop iterations. This feature is
only available for ifort.
par-threshold, Qpar-threshold Sets a threshold for the auto-parallelization of loops. This feature is only
available for ifort.
pdbfile Lets you specify the name for a program database (PDB) file created by
the linker. This feature is only available for ifort.
prec-div, Qprec-div Improves precision of floating-point divides. This feature is only available
for ifort.
prec-sqrt, Qprec-sqrt Improves precision of square root implementations. This feature is only
available for ifort.
prof-data-order, Qprof-data- Enables or disables data ordering if profiling information is enabled. This
order feature is only available for ifort.
prof-dir, Qprof-dir Specifies a directory for profiling information output files. This feature is
only available for ifort.
prof-file, Qprof-file Specifies an alternate file name for the profiling summary files. This
feature is only available for ifort.
126
Compiler Reference
prof-gen, Qprof-gen Produces an instrumented object file that can be used in profile guided
optimization. This feature is only available for ifort.
prof-gen-sampling Tells the compiler to generate debug discriminators in debug output. This
aids in developing more precise sampled profiling output. This option is
deprecated and will be removed in a future release. This feature is only
available for ifort.
prof-hotness-threshold, Lets you set the hotness threshold for function grouping and function
Qprof-hotness-threshold ordering. This feature is only available for ifort.
prof-src-dir, Qprof-src-dir Determines whether directory information of the source file under
compilation is considered when looking up profile data records. This
feature is only available for ifort.
prof-src-root, Qprof-src-root Lets you use relative directory paths when looking up profile data and
specifies a directory as the base. This feature is only available for ifort.
prof-src-root-cwd, Qprof-src- Lets you use relative directory paths when looking up profile data and
root-cwd specifies the current working directory as the base. This feature is only
available for ifort.
prof-use, Qprof-use Enables the use of profiling information during optimization. This feature
is only available for ifort.
prof-use-sampling Lets you use data files produced by hardware profiling to produce an
optimized executable. This option is deprecated and will be removed in a
future release. This feature is only available for ifort.
prof-value-profiling, Qprof- Controls which values are value profiled. This feature is only available for
value-profiling ifort.
pthread Tells the compiler to use pthreads library for multithreading support.
Qcov-dir Specifies a directory for profiling information output files that can be used
with the codecov or tselect tool. This feature is only available for ifort.
Qcov-file Specifies an alternate file name for the profiling summary files that can
be used with the codecov or tselect tool. This feature is only available for
ifort.
Qcov-gen Produces an instrumented object file that can be used with the codecov
or tselect tool. This feature is only available for ifort.
Qinline-dllimport Determines whether dllimport functions are inlined. This feature is only
available for ifort.
Qinstall Specifies the root directory where the compiler installation was
performed.
qmkl, Qmkl Tells the compiler to link to certain libraries in the Intel® oneAPI Math
Kernel Library ( oneMKL ) . On Windows systems, you must specify this
option at compile time.
qoffload Lets you specify the mode for offloading or tell the compiler to ignore
language constructs for offloading. This is a deprecated option. There is
no replacement option. This feature is only available for ifort.
127
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
qopenmp, Qopenmp Enables recognition of OpenMP* features and tells the parallelizer to
generate multi-threaded code based on OpenMP* directives.
qopenmp-lib, Qopenmp-lib Lets you specify an OpenMP* run-time library to use for linking. This
feature is only available for ifort.
qopenmp-link Controls whether the compiler links to static or dynamic OpenMP* run-
time libraries.
qopt-args-in-regs, Qopt-args- Determines whether calls to routines are optimized by passing arguments
in-regs in registers instead of on the stack. This option is deprecated and will be
removed in a future release. This feature is only available for ifort.
qopt-assume-safe-padding, Determines whether the compiler assumes that variables and dynamically
Qopt-assume-safe-padding allocated memory are padded past the end of the object. This feature is
only available for ifort.
qopt-block-factor, Qopt-block- Lets you specify a loop blocking factor. This feature is only available for
factor ifort.
qopt-dynamic-align, Qopt- Enables or disables dynamic data alignment optimizations. This feature is
dynamic-align only available for ifort.
qopt-for-throughput, Qopt- Determines how the compiler optimizes for throughput depending on
for-throughput whether the program is to run in single-job or multi-job mode. This
feature is only available for ifx.
qopt-jump-tables, Qopt- Enables or disables generation of jump tables for switch statements. This
jump-tables feature is only available for ifort.
qopt-malloc-options Lets you specify an alternate algorithm for malloc(). This feature is only
available for ifort.
qopt-multi-version- Tells the compiler to use aggressive multi-versioning to check for pointer
aggressive, Qopt-multi- aliasing and scalar replacement. This feature is only available for ifort.
version-aggressive
qopt-prefetch, Qopt-prefetch Enables or disables prefetch insertion optimization. This feature is only
available for ifort.
128
Compiler Reference
qopt-ra-region-strategy, Selects the method that the register allocator uses to partition each
Qopt-ra-region-strategy routine into regions. This feature is only available for ifort.
qopt-report, Qopt-report Tells the compiler to generate an optimization report. This feature is only
available for ifort.
qopt-report-annotate, Qopt- Enables the annotated source listing feature and specifies its format. This
report-annotate feature is only available for ifort.
qopt-report-annotate- Enables the annotated source listing feature and specifies the site where
position, Qopt-report- optimization messages appear in the annotated source in inlined cases of
annotate-position loop optimizations. This feature is only available for ifort.
qopt-report-file, Qopt-report- Specifies that the output for the optimization report goes to a file, stderr,
file or stdout. This feature is only available for ifort.
qopt-report-filter, Qopt- Tells the compiler to find the indicated parts of your application, and
report-filter generate optimization reports for those parts of your application. This
feature is only available for ifort.
qopt-report-format, Qopt- Specifies the format for an optimization report. This feature is only
report-format available for ifort.
qopt-report-help, Qopt- Displays the optimizer phases available for report generation and a short
report-help description of what is reported at each level. This feature is only available
for ifort.
qopt-report-names, Qopt- Specifies whether mangled or unmangled names should appear in the
report-names optimization report. This feature is only available for ifort.
qopt-report-per-object, Qopt- Tells the compiler that optimization report information should be
report-per-object generated in a separate file for each object. This feature is only available
for ifort.
qopt-report-phase, Qopt- Specifies one or more optimizer phases for which optimization reports are
report-phase generated. This feature is only available for ifort.
qopt-report-routine, Qopt- Tells the compiler to generate an optimization report for each of the
report-routine routines whose names contain the specified substring. This feature is only
available for ifort.
qopt-streaming-stores, Qopt- Enables generation of streaming stores for optimization. This feature is
streaming-stores only available for ifort.
qopt-subscript-in-range, Determines whether the compiler assumes that there are no "large"
Qopt-subscript-in-range integers being used or being computed inside loops. This feature is only
available for ifort.
qoverride-limits, Qoverride- Lets you override certain internal compiler limits that are intended to
limits prevent excessive memory usage or compile times for very large,
complex compilation units. This feature is only available for ifort.
129
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Qpar-adjust-stack Tells the compiler to generate code to adjust the stack size for a fiber-
based main thread. This feature is only available for ifort.
Qpatchable-addresses Tells the compiler to generate code such that references to statically
assigned addresses can be patched. This feature is only available for ifort.
Qsfalign Specifies stack alignment for functions. This option is deprecated and will
be removed in a future release. This feature is only available for ifort.
qsimd-honor-fp-model, Tells the compiler to obey the selected floating-point model when
Qsimd-honor-fp-model vectorizing SIMD loops. This feature is only available for ifort.
Quse-msasm-symbols Tells the compiler to use a dollar sign ("$") when producing symbol
names. This feature is only available for ifort.
real-size Specifies the default KIND for real and complex declarations, constants,
functions, and intrinsics.
recursive Tells the compiler that all routines should be compiled for possible
recursive execution.
S Causes the compiler to compile to an assembly file only and not link.
safe-cray-ptr, Qsafe-cray-ptr Tells the compiler that Cray* pointers do not alias other variables.
save-temps , Qsave-temps Tells the compiler to save intermediate files created during compilation.
scalar-rep, Qscalar-rep Enables or disables the scalar replacement optimization done by the
compiler as part of loop transformations. This feature is only available for
ifort.
show Controls the contents of the listing generated when option list is specified.
sox Tells the compiler to save the compilation options and version number in
the executable file. It also lets you choose whether to include lists of
certain routines . This feature is only available for ifort.
standard-realloc-lhs Determines whether the compiler uses the current Fortran Standard rules
or the old Fortran 2003 rules when interpreting assignment statements.
130
Compiler Reference
staticlib Invokes the libtool command to generate static libraries. This feature is
only available for ifort.
sysroot Specifies the root directory where headers and libraries are located.
tcollect, Qtcollect Inserts instrumentation probes calling the Intel® Trace Collector API. This
feature is only available for ifort.
tcollect-filter, Qtcollect-filter Lets you enable or disable the instrumentation of specified functions. You
must also specify option [Q]tcollect. This feature is only available for ifort.
traceback Tells the compiler to generate extra information in the object file to
provide source file traceback information when a severe error occurs at
run time.
unroll , Qunroll Tells the compiler the maximum number of times to unroll loops.
unroll-aggressive, Qunroll- Determines whether the compiler uses more aggressive unrolling for
aggressive certain loops. This feature is only available for ifort.
use-asm, Quse-asm Tells the compiler to produce objects through the assembler. This is a
deprecated option. There is no replacement option. This feature is only
available for ifort.
vecabi, Qvecabi Determines which vector function application binary interface (ABI) the
compiler uses to create or call vector functions. This feature is only
available for ifort.
vec-guard-write, Qvec-guard- Tells the compiler to perform a conditional check in a vectorized loop. This
write feature is only available for ifort.
131
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
vms Causes the run-time system to behave like HP* Fortran on OpenVMS*
Alpha systems and VAX* systems (VAX FORTRAN*).
watch Tells the compiler to display certain information to the console output
window.
winapp Tells the compiler to create a graphics or Fortran Windows application and
link against the most commonly used libraries.
Winline Warns when a function that is declared as inline is not inlined. This
feature is only available for ifort.
wrap-margin Provides a way to disable the right margin wrapping that occurs in
Fortran list-directed output.
x, Qx Tells the compiler which processor features it may target, including which
instruction sets and optimizations it may generate.
xHost, QxHost Tells the compiler to generate instructions for the highest instruction set
available on the compilation host processor.
zero, Qzero Initializes to zero variables of intrinsic type INTEGER, REAL, COMPLEX, or
LOGICAL that are not yet initialized. This is a deprecated option. The
replacement option is /Qinit:[no]zero or -init=[no]zero.
Deprecated Options
Occasionally, compiler options are marked as "deprecated." Deprecated options are still supported in the
current release, but they may be unsupported in future releases.
132
Compiler Reference
The following two tables list options that are currently deprecated.
Note that deprecated options are not limited to these lists.
-arch=IA32 None
-axS -axSSE4.1
-cpp -fpp
-device-math-lib None
-falign-stack None
-fopenmp None
-m32 None
-march=pentiumii None
-march=pentiumiii -march=pentium3
-mcpu -mtune
-mia32 None
-mkl -qmkl
-no-bss-init None
-prof-gen-sampling None
-prof-use-sampling None
-qopt-args-in-regs None
-rcd None
-use-asm None
-xS -xSSE4.1
-[no]zero -init=[no]zero
/arch:IA32 None
/arch:SSE None
133
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
/device-math-lib None
/Ge /Gs0
/MDs[d] None
/Oy None
/QaxS /QaxSSE4.1
/QaxT /QaxSSSE3
/QIfist /Qrcd
/Qm32 None
/Qnobss-init None
/Qopt-args-in-regs None
/Qrcd None
/Qsfalign None
/Qsox None
/Quse-asm None
/QxS /QxSSE4.1
/QxT /QxSSSE3
/Qzero[-] /Qinit:[no]zero
/unroll /Qunroll
Removed Options
Some compiler options are no longer supported and have been removed. If you use one of these options, the
compiler issues a warning, ignores the option, and then proceeds with compilation.
The following two tables list options that are no longer supported.
Note that removed options are not limited to these lists.
-1 -f66
-66 -f66
-automatic -auto
-axB -axSSE2
-axH -axSSE4.2
134
Compiler Reference
-axi None
-axM None
-axW -msse2
-cxxlib-gcc[=dir] -cxxlib[=dir]
-cxxlib-icc None
-dps -altparam
-F -preprocess-only or -P
-fp -fno-omit-frame-pointer
-fpstkchk -fp-stack-check
-func-groups -prof-func-groups
-fvisibility=internal -fvisibility=hidden
-guide-profile None
-i-dynamic -shared-intel
-i-static -static-intel
-mp -fp-model
-no-cpprt -no-cxxlib
-nobss-init -no-bss-init
135
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
-Ob -inline-level
-onetrip -f66
-openmp -qopenmp
-openmp-lib -qopenmp-lib
-openmpP -qopenmp
-openmp-profile None
-openmp-report -qopt-report-phase=openmp
-openmpS -qopenmp-stubs
-openmp-simd -qopenmp-simd
-openmp-stubs -qopenmp-stubs
-openmp-threadprivate -qopenmp-threadprivate
-opt-args-in-regs -qopt-args-in-regs
-opt-assume-safe-padding -qopt-assume-safe-padding
-opt-block-factor -qopt-block-factor
-opt-dynamic-align -qopt-dynamic-align
-opt-gather-scatter-unroll None
-opt-jump-tables -qopt-jump-tables
-opt-malloc-options -qopt-malloc-options
-opt-matmul -qopt-matmul
-opt-mem-layout-trans -qopt-mem-layout-trans
-opt-multi-version-aggressive -qopt-multi-version-aggressive
-opt-prefetch -qopt-prefetch
-opt-prefetch-distance -qopt-prefetch-distance
-opt-ra-region-strategy -qopt-ra-region-strategy
-opt-report -qopt-report
-opt-report-embed -qopt-report-embed
-opt-report-file -qopt-report-file
136
Compiler Reference
-opt-report-filter -qopt-report-filter
-opt-report-format -qopt-report-format
-opt-report-help -qopt-report-help
-opt-report-level -qopt-report
-opt-report-per-object -qopt-report-per-object
-opt-report-phase -qopt-report-phase
-opt-report-routine -qopt-report-routine
-opt-streaming-cache-evict None
-opt-streaming-stores -qopt-streaming-stores
-opt-subscript-in-range -qopt-subscript-in-range
-par-report -qopt-report-phase=par
-prefetch -qopt-prefetch
-print-sysroot None
-prof-format-32 None
-prof-genx -prof-gen=srcpos
-profile-functions None
-profile-loops None
-profile-loops-report None
-qcf-protection -fcf-protection
-qoffload-arch None
-qoffload-attribute-target None
-qoffload-option None
-qopenmp-report -qopt-report-phase=openmp
-qopenmp-task None
-qp -p
-rct None
-shared-libcxa -shared-libgcc
-ssp None
-static-libcxa -static-libgcc
137
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
-tcheck None
-tpp1 None
-tpp2 -mtune=itanium2
-tpp5 None
-tpp6 None
-tpp7 -mtune=pentium4
-tprofile None
-tune -x<code>
-vec-report -qopt-report-phase=vec
-xB -xSSE2
-xi None
-xM None
-xO -msse3
-xSSE3_ATOM -xATOM_SSSE3
-xSSSE3_ATOM -xATOM_SSSE3
-xW -msse2
/1 /f66
/4Nb /check:none
/4Yb /check:all
/architecture /arch
138
Compiler Reference
/asmattr:machine /FAc
/asmattr:source /FAs
/asmattr:all /FAcs
/asmfile /Fa
/automatic /auto
/cm /warn:nousage
/debug:parallel None
/debug:partial None
/Fm /map
/G1 None
/G5 None
/G7 None
/Gf /GF
/Op /fltconsistency
/optimize:5 /O3
/QaxB /QaxSSE2
/QaxH /QaxSSE4.2
/Qaxi None
/QaxM None
/QaxN /QaxSSE2
/QaxP /QaxSSE3
/QaxW /arch:SSE2
/Qcpp /fpp
139
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
/Qdps /altparam
/Qextend-source /extend-source
/Qfpp[0 | 1 | 2 | 3] /fpp
/Qfpstkchk /Qfp-stack-check
/Qguide-profile None
/Qinline-debug-info /debug:inline-debug-info
/Qlowercase /names:lowercase
/Qonetrip /f66
/Qopenmp-lib:legacy None
/Qopenmp-link None
/Qopenmp-profile None
/Qopenmp-report /Qopt-report-phase:openmp
/Qopt-report-level /Qopt-report
/Qpar-report /Qopt-report-phase:par
/Qprefetch /Qopt-prefetch
/Qprof-format-32 None
/Qprof-genx /Qprof-gen=srcpos
/Qprofile-functions None
/Qprofile-loops None
/Qprofile-loops-report None
/Qrct None
/Qssp None
/Qtprofile None
/Qtcheck None
/Quppercase /names:uppercase
/Quse-vcdebug None
/Qvc11 None
/Qvc10
/Qvc9 and earlier
140
Compiler Reference
/Qvec-report /Qopt-report-phase:vec
/Qvms /vms
/QxB /QxSSE2
/Qxi None
/QxM None
/QxN /QxSSE2
/QxO /arch:SSE3
/QxP /QxSSE3
/QxSSE3_ATOM /QxATOM_SSSE3
/QxSSSE3_ATOM /QxATOM_SSSE3
/QxW /arch:SSE2
/source /Tf
/tune /Qx<code>
/unix None
/us /assume:underscore
/Zd /debug:minimal
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
141
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
To display functional groupings of compiler options, specify a functional category for option help. For
example, to display a list of options that affect diagnostic messages, enter one of the following commands:
-help diagnostics ! Linux and macOS*systems
/help diagnostics ! Windows systems
For details on other categories you can specify, see help.
All Linux* and macOS* compiler options are case sensitive. Many Windows* options are case sensitive. Some
options have different meanings depending on their case; for example, option "c" prevents linking, but option
"C" checks for certain conditions at run time.
Options specified on the command line apply to all files named on the command line.
Options can take arguments in the form of file names, strings, letters, or numbers. If a string includes
spaces, the string must be enclosed in quotation marks. For example:
• On Linux* and macOS* systems, -unroll [=n] or -Uname (string)
• On Windows* systems, /Famyfile.s (file name) or /V"version 5.0" (string)
Unless you specify certain options, the command line will both compile and link the files you specify.
You can abbreviate some option names, entering as many characters as are needed to uniquely identify the
option.
Certain options accept one or more keyword arguments following the option name. For example, the x option
accepts several keywords.
To specify multiple keywords, you typically specify the option multiple times.
NOTE
On Windows* systems, you can sometimes use a comma to separate keywords. For example, the
following is valid:
142
Compiler Reference
Compiler options remain in effect for the whole compilation unless overridden by a compiler directive.
To disable an option, specify the negative form of the option.
On Windows* systems, you can also disable one or more optimization options by specifying option /Od last
on the command line.
NOTE
On Windows* systems, the /Od option is part of a mutually-exclusive group of options that
includes /Od, /O1, /O2, /O3, and /Ox. The last of any of these options specified on the command line
will override the previous options from this group.
If there are enabling and disabling versions of an option on the command line, the last one on the command
line takes precedence.
For example, if you see a reference to [Q]ipo, the Linux* and macOS* form of the option is -ipo and the
Windows form of the option is /Qipo.
• Several compiler options have similar names except that the Linux* and macOS* forms start with an
initial q and the Windows form starts with an initial Q. Within text, such option names are shown as
[q or Q]option-name.
For example, if you see a reference to [q or Q]opt-report, the Linux* and macOS* form of the option
is -qopt-report and the Windows form of the option is /Qopt-report.
Compiler option names that are more dissimilar are shown in full.
143
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
This section shows any arguments (parameters) that are related to the option. If the option has no
arguments, it will specify "None".
• Default
This section shows the default setting for the option.
• Description
This section shows the full description of the option. It may also include further information on any
applicable arguments.
• IDE Equivalent
This section shows information related to the Intel® Integrated Development Environment (Intel® IDE)
Property Pages on Linux*, macOS*, and Windows* systems. It shows on which Property Page the option
appears, and under what category it's listed. The Windows* IDE is Microsoft* Visual Studio* .NET. If the
option has no IDE equivalent, it will specify "None". Note that in this release, there is no IDE support for
Fortran on Linux*.
• Alternate Options
This section lists any options that are synonyms for the described option. If there are no alternate option
names, it will show "None".
Some alternate option names are deprecated and may be removed in future releases.
Many options have an older spelling where underscores ("_") instead of hyphens ("-") connect the main
option names. The older spelling is a valid alternate option name.
Some option descriptions may also have the following:
• Example (or Examples)
This section shows one or more examples that demonstrate the option.
• See Also
This section shows where you can get further information on the option or it shows related options.
qoffload
Lets you specify the mode for offloading or tell the
compiler to ignore language constructs for offloading.
This is a deprecated option. There is no replacement
option. This feature is only available for ifort.
Syntax
Linux OS:
-qoffload[=keyword]
-qno-offload
macOS:
None
Windows OS:
None
Arguments
keyword Specifies the mode for offloading or it disables offloading. Possible values are:
144
Compiler Reference
none Tells the compiler to ignore language constructs for offloading. Warnings are
issued by the compiler. This is equivalent to the negative form of the option.
optional Specifies that offloading is optional (requested). If the target is not available,
the program is executed on the CPU, not the target.
Default
mandatory The compiler recognizes language constructs for offloading if they are
specified. If option -qoffload is specified with no keyword, the
default is mandatory.
Description
This option lets you specify the mode for offloading or tell the compiler to ignore language constructs for
offloading.
Option -q[no-]offload is the replacement option for -[no-]offload, which is deprecated.
If no -qoffload option appears on the command line, then OFFLOAD directives are processed and:
However, OpenMP* directives for processor control (for example, !$OMP TARGET) are recognized if the
[q or Q]openmp option is specified, regardless of whether or not OFFLOAD directives are recognized or
ignored.
If keyword mandatory or optional appears for -qoffload, then OFFLOAD directives are processed and:
• The MANDATORY or OPTIONAL clauses are obeyed, regardless of the -qoffload keyword specified.
• If no MANDATORY or OPTIONAL clause is present, then the -qoffload keyword is obeyed.
If the STATUS clause is specified for an OFFLOAD directive, it affects run-time behavior.
IDE Equivalent
None
Alternate Options
None
See Also
Supported Environment Variables
Optimization Options
This section contains descriptions for compiler options that pertain to optimization.
145
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
falias, Oa
Specifies whether or not a procedure call may have
hidden aliases of local variables not supplied as actual
arguments.
Syntax
Linux OS:
-falias
-fno-alias
macOS:
-falias
-fno-alias
Windows OS:
/Oa
/Oa-
Arguments
None
Default
Description
This option specifies whether or not the compiler can assume that during a procedure call, local variables in
the caller that are not present in the actual argument list and not visible by host association, are not
referenced or redefined due to hidden aliasing. The Fortran standard generally prohibits such aliasing.
If you specify -falias (Linux* and macOS*) or /Oa- (Windows*), aliasing during a procedure call is
assumed; this can possibly affect performance.
If you specify -fno-alias or /Oa (the default), aliasing during a procedure call is not assumed.
IDE Equivalent
None
Alternate Options
None
See Also
ffnalias compiler option
fast
Maximizes speed across the entire program.
Syntax
Linux OS:
-fast
146
Compiler Reference
macOS:
-fast
Windows OS:
/fast
Arguments
None
Default
Description
This option maximizes speed across the entire program.
It sets the following options:
• On Linux* systems, if you specify option -fast -xSSE3, option -xSSE3 takes effect. However, if you
specify -xSSE3 -fast, option -xHost takes effect.
• On Windows* systems, if you specify option /fast /QxSSE3, option/QxSSE3 takes effect. However, if you
specify /QxSSE3 /fast, option /QxHost takes effect.
NOTE
Option fast sets some aggressive optimizations that may not be appropriate for all
applications. The resulting executable may not run on processor types different from the one
on which you compile. You should make sure that you understand the individual
optimization options that are enabled by option fast.
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
IDE Equivalent
None
Alternate Options
None
147
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
fp-model, fp compiler option
xHost, QxHost
compiler option
x, Qx
compiler option
ffnalias, Ow
Determines whether aliasing is assumed within
functions. This feature is only available for ifort.
Syntax
Linux OS:
-ffnalias
-fno-fnalias
macOS:
-ffnalias
-fno-fnalias
Windows OS:
/Ow
/Ow-
Arguments
None
Default
Description
This option determines whether aliasing is assumed within functions.
If you specify -fno-fnalias or /Ow-, aliasing is not assumed within functions, but it is assumed across
calls.
If you specify -ffnalias or /Ow, aliasing is assumed within functions.
IDE Equivalent
None
Alternate Options
None
See Also
falias compiler option
148
Compiler Reference
foptimize-sibling-calls
Determines whether the compiler optimizes tail
recursive calls. This feature is only available for ifort.
Syntax
Linux OS:
-foptimize-sibling-calls
-fno-optimize-sibling-calls
macOS:
-foptimize-sibling-calls
-fno-optimize-sibling-calls
Windows OS:
None
Arguments
None
Default
Description
This option determines whether the compiler optimizes tail recursive calls. It enables conversion of tail
recursion into loops.
If you do not want to optimize tail recursive calls, specify -fno-optimize-sibling-calls.
Tail recursion is a special form of recursion that doesn't use stack space. In tail recursion, a recursive call is
converted to a GOTO statement that returns to the beginning of the function. In this case, the return value of
the recursive call is only used to be returned. It is not used in another expression. The recursive function is
converted into a loop, which prevents modification of the stack space used.
IDE Equivalent
None
Alternate Options
None
fprotect-parens, Qprotect-parens
Determines whether the optimizer honors parentheses
when floating-point expressions are evaluated.
Syntax
Linux OS:
-fprotect-parens
-fno-protect-parens
149
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
macOS:
-fprotect-parens
-fno-protect-parens
Windows OS:
/Qprotect-parens
/Qprotect-parens-
Arguments
None
Default
Description
This option determines whether the optimizer honors parentheses when determining the order of floating-
point expression evaluation.
When option -fprotect-parens (Linux* and macOS*) or /Qprotect-parens (Windows*) is specified, the
optimizer will maintain the order of evaluation imposed by parentheses in the code.
When option -fno-protect-parens (Linux* and macOS*) or /Qprotect-parens- (Windows*) is specified,
the optimizer may reorder floating-point expressions without regard for parentheses if it produces faster
executing code.
IDE Equivalent
None
Alternate Options
Linux and macOS*: -assume protect_parens
Windows: /assume:protect_parens
Example
Consider the following expression:
A+(B+C)
By default, the parentheses are ignored and the compiler is free to re-order the floating-point operations
based on the optimization level, the setting of option -fp-model (Linux* and macOS*) or /fp (Windows*),
etc. to produce faster code. Code that is sensitive to the order of operations may produce different results
(such as with some floating-point computations).
However, if -fprotect-parens (Linux* and macOS*) or /Qprotect-parens (Windows*) is specified,
parentheses around floating-point expressions (including complex floating-point and decimal floating-point)
are honored and the expression will be interpreted following the normal precedence rules, that is, B+C will
be computed first and then added to A.
This may produce slower code than when parentheses are ignored. If floating-point sensitivity is a specific
concern, you should use option -fp-model precise (Linux* and macOS*) or /fp:precise (Windows*) to
ensure precision because it controls all optimizations that may affect precision.
150
Compiler Reference
See Also
fp-model, fp compiler option
GF
Enables read-only string-pooling optimization.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/GF
Arguments
None
Default
Description
This option enables read only string-pooling optimization.
IDE Equivalent
None
Alternate Options
None
nolib-inline
Disables inline expansion of standard library or
intrinsic functions.
Syntax
Linux OS:
-nolib-inline
macOS:
-nolib-inline
Windows OS:
None
Arguments
None
151
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
OFF The compiler inlines many standard library and intrinsic functions.
Description
This option disables inline expansion of standard library or intrinsic functions. It prevents the unexpected
results that can arise from inline expansion of these functions.
IDE Equivalent
None
Alternate Options
None
O
Specifies the code optimization for applications.
Syntax
Linux OS:
-O[n]
macOS:
-O[n]
Windows OS:
/O[n]
Arguments
Default
O2 Optimizes for code speed. This default may change depending on which other compiler options
are specified. For details, see below.
Description
This option specifies the code optimization for applications.
Option Description
152
Compiler Reference
Option Description
153
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Option Description
This option may set other options, especially options that optimize for
code speed. This is determined by the compiler, depending on which
operating system and architecture you are using. The options that are set
may change from release to release.
On Windows* systems, this option is the same as the Ox option.
Many routines in the shared libraries are more highly optimized for Intel®
microprocessors than for non-Intel microprocessors.
The last O option specified on the command line takes precedence over any others.
IDE Equivalent
Windows
Visual Studio: General > Optimization (/Od, /O1, /O2, /O3, /fast)
Alternate Options
See Also
Od compiler option
154
Compiler Reference
Od
Disables all optimizations.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/Od
Arguments
None
Default
Description
This option disables all optimizations. It can be used for selective optimizations, such as a combination of /Od
and /Ob1 (disables all optimizations, but enables inlining).
IDE Equivalent
Windows
Visual Studio: Optimization > Optimization
Alternate Options
Linux and macOS*: -O0
Windows: /optimize:0
See Also
O compiler option (see O0)
Ofast
Sets certain aggressive options to improve the speed
of your application.
Syntax
Linux OS:
-Ofast
155
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
macOS:
-Ofast
Windows OS:
None
Arguments
None
Default
OFF The aggressive optimizations that improve speed are not enabled.
Description
This option improves the speed of your application.
It sets compiler options -O3, -no-prec-div, and -fp-model fast=2.
IDE Equivalent
None
Alternate Options
None
See Also
O compiler option
prec-div, Qprec-div compiler option
fast compiler option
fp-model, fp compiler option
Os
Enables optimizations that do not increase code size;
it produces smaller code size than O2.
Syntax
Linux OS:
-Os
macOS:
-Os
Windows OS:
/Os
Arguments
None
156
Compiler Reference
Default
OFF Optimizations are made for code speed. However, if O1 is specified, Os is the default.
Description
This option enables optimizations that do not increase code size; it produces smaller code size than O2. It
disables some optimizations that increase code size for a small speed benefit.
This option tells the compiler to favor transformations that reduce code size over transformations that
produce maximum performance.
IDE Equivalent
Visual Studio
Visual Studio: Optimization > Favor Size or Speed
Alternate Options
None
See Also
O compiler option
Ot compiler option
Ot
Enables all speed optimizations.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/Ot
Arguments
None
Default
Description
This option enables all speed optimizations.
IDE Equivalent
Windows
Visual Studio: Optimization > Favor Size or Speed (/Ot, /Os)
157
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Alternate Options
None
See Also
O compiler option
Os compiler option
arch
Tells the compiler which features it may target,
including which instruction sets it may generate.
Syntax
Linux OS:
-arch code
macOS:
-arch code
Windows OS:
/arch:code
Arguments
code Indicates to the compiler a feature set that it may target, including which instruction sets it
may generate. Many of the following descriptions refer to Intel® Streaming SIMD Extensions
(Intel® SSE) and Supplemental Streaming SIMD Extensions (SSSE). Possible values are:
158
Compiler Reference
SKYLAKE
SKYLAKE-AVX512
TIGERLAKE
TREMONT
WHISKEYLAKE
CORE-AVX2 May generate Intel® Advanced Vector Extensions 2 (Intel®
AVX2), Intel® AVX, SSE4.2, SSE4.1, SSE3, SSE2, SSE, and
SSSE3 instructions.
SSE4.1 May generate Intel® SSE4.1, SSE3, SSE2, SSE, and SSSE3
instructions.
SSE2 May generate Intel® SSE2 and SSE instructions. This value
is only available on Linux* and Windows* systems.
Default
Windows and Linux systems: For more information on the default values, see Arguments above.
SSE2
macOS* systems: SSSE3
Description
This option tells the compiler which features it may target, including which instruction sets it may generate.
Code generated with these options should execute on any compatible, non-Intel processor with support for
the corresponding instruction set.
159
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Options /arch and /Qx are mutually exclusive. If both are specified, the compiler uses the last one specified
and generates a warning.
If you specify both the /Qax and /arch options, the compiler will not generate Intel-specific instructions.
For compatibility with Compaq* Visual Fortran, the compiler allows the following keyword values. However,
you should use the suggested replacements.
IDE Equivalent
Visual Studio
Visual Studio: Code Generation > Enable Enhanced Instruction Set
Alternate Options
None
See Also
x, Qx compiler option
xHost, QxHost compiler option
ax, Qax compiler option
arch compiler option
march compiler option
m compiler option
m32, m64 compiler option
ax, Qax
Tells the compiler to generate multiple, feature-
specific auto-dispatch code paths for Intel® processors
if there is a performance benefit. This feature is only
available for ifort.
Syntax
Linux OS:
-axcode
macOS:
-axcode
Windows OS:
/Qaxcode
160
Compiler Reference
Arguments
code Indicates to the compiler a feature set that it may target, including which instruction sets it
may generate. The following descriptions refer to Intel® Streaming SIMD Extensions (Intel®
SSE) and Supplemental Streaming SIMD Extensions (SSSE). Possible values are:
161
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
SSE4.1 May generate Intel® SSE4.1, SSE3, SSE2, SSE, and SSSE3
instructions for Intel® processors.
SSE3 May generate Intel® SSE3, SSE2, and SSE instructions for
Intel® processors. This value is not available on macOS*
systems.
SSE2 May generate Intel® SSE2 and SSE instructions for Intel®
processors. This value is not available on macOS* systems.
You can specify more than one code value. When specifying more than one code value, each value must be
separated with a comma. See the Examples section below.
Default
OFF No auto-dispatch code is generated. Feature-specific code is generated and is controlled by the
setting of the following compiler options:
• Linux*: -m and -x
• Windows*: /arch and /Qx
• macOS*: -x
Description
This option tells the compiler to generate multiple, feature-specific auto-dispatch code paths for Intel®
processors if there is a performance benefit. It also generates a baseline code path. The Intel feature-specific
auto-dispatch path is usually more optimized than the baseline path. Other options, such as O3, control how
much optimization is performed on the baseline path.
The baseline code path is determined by the architecture specified by options -m or -x (Linux* and macOS*)
or options /arch or /Qx (Windows*). While there are defaults for the [Q]x option that depend on the
operating system being used, you can specify an architecture and optimization level for the baseline code
that is higher or lower than the default. The specified architecture becomes the effective minimum
architecture for the baseline code path.
If you specify both the [Q]ax and [Q]x options, the baseline code will only execute on Intel® processors
compatible with the setting specified for the [Q]x.
If you specify both the -ax and -m options (Linux and macOS*) or the /Qax and /arch options (Windows),
the baseline code will execute on non-Intel® processors compatible with the setting specified for the -m
or /arch option.
A Non-Intel® baseline and an Intel® baseline have the same set of optimizations enabled, and the default for
both is SSE4.2 for x86-based architectures.
162
Compiler Reference
If you specify both the -ax and -march options (Linux and macOS*), or the /Qax and /arch options
(Windows), the compiler will not generate Intel-specific instructions. This is because specifying -march
disables -ax and specifying /arch disables /Qax.
The [Q]ax option tells the compiler to find opportunities to generate separate versions of functions that take
advantage of features of the specified instruction features.
If the compiler finds such an opportunity, it first checks whether generating a feature-specific version of a
function is likely to result in a performance gain. If this is the case, the compiler generates both a feature-
specific version of a function and a baseline version of the function. At run time, one of the versions is
chosen to execute, depending on the Intel® processor in use. In this way, the program can benefit from
performance gains on more advanced Intel processors, while still working properly on older processors and
non-Intel processors. A non-Intel processor always executes the baseline code path.
You can use more than one of the feature values by combining them. For example, you can specify
-axSSE4.1,SSSE3 (Linux and macOS*) or /QaxSSE4.1,SSSE3 (Windows). You cannot combine the old
style, deprecated options and the new options. For example, you cannot specify -axSSE4.1,T (Linux and
macOS*) or /QaxSSE4.1,T (Windows).
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
IDE Equivalent
Visual Studio
Visual Studio: Code Generation > Add Processor-Optimized Code Path
Alternate Options
None
Examples
The following shows an example of how to specify this option:
See Also
x, Qx compiler option
xHost, QxHost compiler option
march compiler option
arch compiler option
m compiler option
fasynchronous-unwind-tables
Determines whether unwind information is precise at
an instruction boundary or at a call boundary.
163
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-fasynchronous-unwind-tables
-fno-asynchronous-unwind-tables
macOS:
-fasynchronous-unwind-tables
-fno-asynchronous-unwind-tables
Windows OS:
None
Arguments
None
Default
IA-32 architecture (Linux* only): The unwind table generated is precise at call boundaries only.
-fno-asynchronous-unwind-tables
Description
This option determines whether unwind information is precise at an instruction boundary or at a call
boundary. The compiler generates an unwind table in DWARF2 or DWARF3 format, depending on which
format is supported on your system.
If -fno-asynchronous-unwind-tables is specified, the unwind table is precise at call boundaries only. In
this case, the compiler will avoid creating unwind tables for routines such as the following:
• A C++ routine that does not declare objects with destructors and does not contain calls to routines that
might throw an exception.
• A C/C++ or Fortran routine compiled without -fexceptions, and on Intel® 64 architecture, without
-traceback.
• A C/C++ or Fortran routine compiled with -fexceptions that does not contain calls to routines that
might throw an exception.
IDE Equivalent
None
Alternate Options
None
See Also
fexceptions compiler option
fcf-protection, Qcf-protection
Enables Intel® Control-Flow Enforcement Technology
(Intel® CET) protection, which defends your program
from certain attacks that exploit vulnerabilities. This
option offers preliminary support for Intel® CET.
164
Compiler Reference
Syntax
Linux OS:
-fcf-protection[=keyword]
macOS:
None
Windows OS:
/Qcf-protection[:keyword]
Arguments
keyword Specifies the level of protection the compiler should perform. Possible values are:
Default
Description
This option enables Intel® CET protection, which defends your program from certain attacks that exploit
vulnerabilities.
Intel® CET protections are enforced on processors that support Intel® CET. They are ignored on processors
that do not support Intel® CET, so they are safe to use in programs that might run on a variety of processors.
Specifying shadow_stack helps to protect your program from return-oriented programming (ROP). Return-
oriented programming (ROP) is a technique to exploit computer security defenses such as non-executable
memory and code signing by gaining control of the call stack to modify program control flow and then
execute certain machine instruction sequences.
Specifying branch_tracking helps to protect your program from call/jump-oriented programming (COP/
JOP). Jump-oriented programming (JOP) is a variant of ROP that uses indirect jumps and calls to emulate
return instructions. Call-oriented programming (COP) is a variant of ROP that employs indirect calls.
To get both protections, specify this compiler option with no keyword, or specify -fcf-protection=full
(Linux*) or /Qcf-protection:full (Windows*).
IDE Equivalent
None
Alternate Options
Linux and macOS*: -qcf-protection
Windows: None
165
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
fexceptions
Enables exception handling table generation. This
feature is only available for ifort.
Syntax
Linux OS:
-fexceptions
-fno-exceptions
macOS:
-fexceptions
-fno-exceptions
Windows OS:
None
Arguments
None
Default
Description
This option enables C++ exception handling table generation, preventing Fortran routines in mixed-language
applications from interfering with exception handling between C++ routines. The -fno-exceptions option
disables C++ exception handling table generation, resulting in smaller code. When this option is used, any
use of C++ exception handling constructs (such as try blocks and throw statements) when a Fortran routine
is in the call chain will produce an error.
IDE Equivalent
None
Alternate Options
None
fomit-frame-pointer, Oy
Determines whether EBP is used as a general-purpose
register in optimizations. Option /Oy is deprecated and
will be removed in a future release.This feature is only
available for ifort.
Architecture Restrictions
Option /Oy[-] is only available on IA-32 architecture. IA-32 support is deprecated and will be removed in a
future release.
Syntax
Linux OS:
-fomit-frame-pointer
166
Compiler Reference
-fno-omit-frame-pointer
macOS:
-fomit-frame-pointer
-fno-omit-frame-pointer
Windows OS:
/Oy
/Oy-
Arguments
None
Default
Description
These options determine whether EBP is used as a general-purpose register in optimizations. Option
-fomit-frame-pointer and option /Oy allows this use. Option -fno-omit-frame-pointer and
option /Oy- disallows it.
Some debuggers expect EBP to be used as a stack frame pointer, and cannot produce a stack backtrace
unless this is so. The -fno-omit-frame-pointer and the /Oy- option directs the compiler to generate code
that maintains and uses EBP as a stack frame pointer for all functions so that a debugger can still produce a
stack backtrace without doing the following:
Using the -fno-omit-frame-pointer or /Oy- option reduces the number of available general-purpose
registers by 1, and can result in slightly less efficient code.
IDE Equivalent
Windows
Visual Studio: Optimization > Omit Frame Pointers
Alternate Options
Linux and macOS*: -fp (this is a deprecated option)
Windows: None
See Also
momit-leaf-frame-pointer compiler option
167
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
guard
Enables the control flow protection mechanism.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/guard:keyword
Arguments
keyword Specifies the the control flow protection mechanism. Possible values are:
cf[-] Tells the compiler to analyze control flow of valid targets for indirect calls and to insert
code to verify the targets at runtime.
To explicitly disable this option, specify /guard:cf-.
Default
Description
This option enables the control flow protection mechanism. It tells the compiler to analyze control flow of
valid targets for indirect calls and inserts a call to a checking routine before each indirect call to verify the
target of the given indirect call.
The /guard:cf option must be passed to both the compiler and linker.
Code compiled using /guard:cf can be linked to libraries and object files that are not compiled using the
option.
This option has been added for Microsoft compatibility. It uses the Microsoft implementation.
IDE Equivalent
None
Alternate Options
None
hotpatch
Tells the compiler to prepare a routine for
hotpatching. This feature is only available for ifort.
Syntax
Linux OS:
-hotpatch[=n]
168
Compiler Reference
macOS:
None
Windows OS:
/hotpatch[:n]
Arguments
Default
Description
This option tells the compiler to prepare a routine for hotpatching. The compiler inserts nop padding around
function entry points so that the resulting image is hot patchable.
Specifically, the compiler adds nop bytes after each function entry point and enough nop bytes before the
function entry point to fit a direct jump instruction on the target architecture.
If n is specified, it overrides the default number of bytes that the compiler adds before the function entry
point.
IDE Equivalent
None
Alternate Options
None
m
Tells the compiler which features it may target,
including which instruction set architecture (ISA) it
may generate.
Syntax
Linux OS:
-mcode
macOS:
-mcode
Windows OS:
None
Arguments
code Indicates to the compiler a feature set that it may target, including which instruction sets it
may generate. Many of the following descriptions refer to Intel® Streaming SIMD Extensions
(Intel® SSE) and Supplemental Streaming SIMD Extensions (SSSE). Possible values are:
169
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
sse4.1 May generate Intel® SSE4.1, SSE3, SSE2, SSE, and SSSE3
instructions.
sse2 May generate Intel® SSE2 and SSE instructions. This value
is only available on Linux systems.
This compiler option also supports many of the -m option settings available with gcc. For
more information on gcc settings for -m, see the gcc documentation.
Default
Linux* systems: -msse2 For more information on the default values, see Arguments above.
macOS* systems: -mssse3
Description
This option tells the compiler which features it may target, including which instruction sets it may generate.
Code generated with these options should execute on any compatible, non-Intel processor with support for
the corresponding instruction set.
Linux* systems: For compatibility with gcc, the compiler allows the following options but they have no effect.
You will get a warning error, but the instructions associated with the name will not be generated. You should
use the suggested replacement options.
-mfma -march=core-avx2
170
Compiler Reference
-mvzeroupper -march=corei7-avx
IDE Equivalent
None
Alternate Options
None
See Also
x, Qx compiler option
xHost, QxHost compiler option
ax, Qax compiler option
arch compiler option
march compiler option
m32, m64 compiler option
Syntax
Linux OS:
-m32 (ifort only)
-m64
macOS:
-m64 (ifort only)
Windows OS:
/Qm32 (ifort only)
/Qm64
Arguments
None
Default
Description
These options tell the compiler to generate code for a specific architecture.
171
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Option Description
For ifort, the -m64 option is the same as macOS* option -arch x86_64. This option is not related to the
Intel®Fortran Compiler option arch.
On Linux* systems, these options are provided for compatibility with gcc.
IDE Equivalent
None
Alternate Options
None
m80387
Specifies whether the compiler can use x87
instructions. This feature is only available for ifort.
Syntax
Linux OS:
-m80387
-mno-80387
macOS:
-m80387
-mno-80387
Windows OS:
None
Arguments
None
Default
Description
This option specifies whether the compiler can use x87 instructions.
If you specify option -mno-80387, it prevents the compiler from using x87 instructions. If the compiler is
forced to generate x87 instructions, it issues an error message.
IDE Equivalent
None
172
Compiler Reference
Alternate Options
-m[no-]x87
march
Tells the compiler to generate code for processors that
support certain features.
Syntax
Linux OS:
-march=processor
macOS:
-march=processor
Windows OS:
None
Arguments
processor Tells the compiler the code it can generate. Possible values are:
173
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
Description
This option tells the compiler to generate code for processors that support certain features.
If you specify both the -ax and -march options, the compiler will not generate Intel-specific instructions.
Options -x and -march are mutually exclusive. If both are specified, the compiler uses the last one specified
and generates a warning.
Specifying -march=pentium4 sets -mtune=pentium4.
For compatibility, a number of historical processor values are also supported, but the generated code will not
differ from the default.
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
174
Compiler Reference
IDE Equivalent
None
Alternate Options
macOS*: None
Windows: None
macOS*: None
Windows: None
See Also
xHost, QxHost compiler option
x, Qx compiler option
ax, Qax compiler option
arch compiler option
minstruction, Qinstruction compiler option
m compiler option
masm
Tells the compiler to generate the assembler output
file using a selected dialect.
Syntax
Linux OS:
-masm=dialect
macOS:
None
Windows OS:
None
Arguments
dialect Is the dialect to use for the assembler output file. Possible values are:
175
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
-masm=att The compiler generates the assembler output file using AT&T* syntax.
Description
This option tells the compiler to generate the assembler output file using a selected dialect.
IDE Equivalent
None
Alternate Options
None
mauto-arch, Qauto-arch
Tells the compiler to generate multiple, feature-
specific auto-dispatch code paths for x86 architecture
processors if there is a performance benefit. This
feature is only available for ifort.
Syntax
Linux OS:
-mauto-arch=value
macOS:
-mauto-arch=value
Windows OS:
/Qauto-arch:value
Arguments
Default
Description
This option tells the compiler to generate multiple, feature-specific auto-dispatch code paths for x86
architecture processors if there is a performance benefit. It also generates a baseline code path.
This option cannot be used together with any options that may require Intel-specific optimizations (such as
[Q]x or [Q]ax).
IDE Equivalent
None
Alternate Options
None
See Also
ax, Qax compiler option
176
Compiler Reference
mbranches-within-32B-boundaries, Qbranches-within-32B-boundaries
Tells the compiler to align branches and fused
branches on 32-byte boundaries for better
performance.
Syntax
Linux OS:
-mbranches-within-32B-boundaries
-mno-branches-within-32B-boundaries
macOS:
-mbranches-within-32B-boundaries
-mno-branches-within-32B-boundaries
Windows OS:
/Qbranches-within-32B-boundaries
/Qbranches-within-32B-boundaries-
Arguments
None
Default
Description
This option tells the compiler to align branches and fused branches on 32-byte boundaries for better
performance.
NOTE
When you use this option, it may affect binary utilities usage experience, such as
debugability.
IDE Equivalent
None
Alternate Options
None
mconditional-branch, Qconditional-branch
Lets you identify and fix code that may be vulnerable
to speculative execution side-channel attacks, which
can leak your secure data as a result of bad
speculation of a conditional branch direction. This
feature is only available for ifort.
177
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-mconditional-branch=keyword
macOS:
-mconditional-branch=keyword
Windows OS:
/Qconditional-branch:keyword
Arguments
keyword Tells the compiler the action to take. Possible values are:
keep Tells the compiler to not attempt any vulnerable code detection
or fixing. This is equivalent to not specifying the
-mconditional-branch option.
all-fix Tells the compiler to fix all of the vulnerable code so that it is
either not executed speculatively, or there is no observable
side-channel created from their speculative execution. Since it
is a complete mitigation against Spectre variant 1 attacks, this
setting will have the most run-time performance cost.
In contrast to the pattern-fix setting, the compiler will not
attempt to identify the exact conditional branches that may
have led to the mis-speculated execution.
178
Compiler Reference
Default
Description
This option lets you identify code that may be vulnerable to speculative execution side-channel attacks,
which can leak your secure data as a result of bad speculation of a conditional branch direction. Depending
on the setting you choose, vulnerabilities may be detected and code may be generated to attempt to mitigate
the security risk.
IDE Equivalent
Visual Studio
Visual Studio: Code Generation > Spectre Variant 1 Mitigation
Alternate Options
None
minstruction, Qinstruction
Determines whether MOVBE instructions are
generated for certain Intel® processors. This feature is
only available for ifort.
Syntax
Linux OS:
-minstruction=[no]movbe
macOS:
-minstruction=[no]movbe
Windows OS:
/Qinstruction:[no]movbe
Arguments
None
Default
179
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
This option determines whether MOVBE instructions are generated for Intel Atom® processors. To use this
option, you must also specify [Q]xATOM_SSSE3 or [Q]xATOM_SSE4.2.
• MOVBE instructions are generated that are specific to the Intel Atom® processor.
• Generated executables can only be run on Intel Atom® processors or processors that support
Supplemental Streaming SIMD Extensions 3 (Intel® SSSE3) or Intel® Streaming SIMD Extensions 4.2
(Intel® SSE4.2) and MOVBE.
• The compiler optimizes code for the Intel Atom® processor, but it does not generate MOVBE instructions.
• Generated executables can be run on non-Intel Atom® processors that support Intel® SSE3 or Intel®
SSE4.2.
IDE Equivalent
None
Alternate Options
None
See Also
x, Qx compiler option
momit-leaf-frame-pointer
Determines whether the frame pointer is omitted or
kept in leaf functions. This feature is only available for
ifort.
Syntax
Linux OS:
-momit-leaf-frame-pointer
-mno-omit-leaf-frame-pointer
macOS:
-momit-leaf-frame-pointer
-mno-omit-leaf-frame-pointer
Windows OS:
None
Arguments
None
Default
Varies If you specify option -fomit-frame-pointer (or it is set by default), the default is
-momit-leaf-frame-pointer. If you specify option -fno-omit-frame-pointer, the default is
-mno-omit-leaf-frame-pointer.
180
Compiler Reference
Description
This option determines whether the frame pointer is omitted or kept in leaf functions. It is related to option
-f[no-]omit-frame-pointer and the setting for that option has an effect on this option.
Consider the following option combinations:
IDE Equivalent
None
Alternate Options
None
See Also
fomit-frame-pointer, Oy compiler option
mstringop-inline-threshold, Qstringop-inline-threshold
Tells the compiler to not inline calls to buffer
manipulation functions such as memcpy and memset
when the number of bytes the functions handle are
known at compile time and greater than the specified
value. This feature is only available for ifort.
Syntax
Linux OS:
-mstringop-inline-threshold=val
macOS:
-mstringop-inline-threshold=val
181
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows OS:
/Qstringop-inline-threshold:val
Arguments
val Is a positive 32-bit integer. If the size is greater than val, the compiler
will never inline it.
Default
OFF The compiler uses its own heuristics to determine the default.
Description
This option tells the compiler to not inline calls to buffer manipulation functions such as memcpy and memset
when the number of bytes the functions handle are known at compile time and greater than the specified val.
IDE Equivalent
None
Alternate Options
None
See Also
mstringop-strategy, Qstringop-strategy compiler option
mstringop-strategy, Qstringop-strategy
Lets you override the internal decision heuristic for the
particular algorithm used when implementing buffer
manipulation functions such as memcpy and memset.
This feature is only available for ifort.
Syntax
Linux OS:
-mstringop-strategy=alg
macOS:
-mstringop-strategy=alg
Windows OS:
/Qstringop-strategy:alg
Arguments
const_size_loop Tells the compiler to expand the string operations into an inline
loop when the size is known at compile time and it is not
greater than threshold value. Otherwise, the compiler uses its
own heuristics to decide how to implement the string
operation.
182
Compiler Reference
rep Tells the compiler to use its own heuristics to decide what form
of rep movs | stos to use when inlining string operations.
Default
varies If optimization option Os is specified, the default is rep. Otherwise, the default is
const_size_loop.
Description
This option lets you override the internal decision heuristic for the particular algorithm used when
implementing buffer manipulation functions such as memcpy and memset.
This option may have no effect on compiler-generated string functions, for example, a call to memcpy
generated by the compiler to implement an array copy or structure copy.
IDE Equivalent
None
Alternate Options
None
See Also
mstringop-inline-threshold, Qstringop-inline-threshold compiler option
Os compiler option
mtune, tune
Performs optimizations for specific processors but
does not cause extended instruction sets to be used
(unlike -march).
Syntax
Linux OS:
-mtune=processor
macOS:
-mtune=processor
Windows OS:
/tune:processor
Arguments
processor Is the processor for which the compiler should perform optimizations. Possible values
are:
183
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
184
Compiler Reference
pentiumpro Optimizes for Intel® Pentium® Pro, Intel Pentium II, and
Intel Pentium III processors.
Default
Description
This option performs optimizations for specific processors but does not cause extended instruction sets to be
used (unlike -march).
The resulting executable is backwards compatible and generated code is optimized for specific processors.
For example, code generated with -mtune=core2 or /tune:core2 will run correctly on 4th Generation Intel®
Core™ processors, but it might not run as fast as if it had been generated using -mtune=haswell
or /tune:haswell. Code generated with -mtune=haswell (/tune:haswell) or -mtune=core-avx2
(/tune:core-avx2) will also run correctly on Intel® Core™2 processors, but it might not run as fast as if it
had been generated using -mtune=core2 or /tune:core2. This is in contrast to code generated with
-march=core-avx2 or /arch:core-avx2, which will not run correctly on older processors such as Intel®
Core™2 processors.
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
IDE Equivalent
Windows
Visual Studio: Code Generation >Intel Processor Microarchitecture-Specific Optimization
Alternate Options
macOS*: None
Windows: None
See Also
march compiler option
185
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Qpatchable-addresses
Tells the compiler to generate code such that
references to statically assigned addresses can be
patched. This feature is only available for ifort.
Architecture Restrictions
Only available on Intel® 64 architecture
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/Qpatchable-addresses
Arguments
None
Default
Description
This option tells the compiler to generate code such that references to statically assigned addresses can be
patched with arbitrary 64-bit addresses.
Normally, the Windows* system compiler that runs on Intel® 64 architecture uses 32-bit relative addressing
to reference statically allocated code and data. That assumes the code or data is within 2GB of the access
point, an assumption that is enforced by the Windows object format.
However, in some patching systems, it is useful to have the ability to replace a global address with some
other arbitrary 64-bit address, one that might not be within 2GB of the access point.
This option causes the compiler to avoid 32-bit relative addressing in favor of 64-bit direct addressing so that
the addresses can be patched in place without additional code modifications. This option causes code size to
increase, and since 32-bit relative addressing is usually more efficient than 64-bit direct addressing, you may
see a performance impact.
IDE Equivalent
None
Alternate Options
None
x, Qx
Tells the compiler which processor features it may
target, including which instruction sets and
optimizations it may generate.
186
Compiler Reference
Syntax
Linux OS:
-xcode
macOS:
-xcode
Windows OS:
/Qxcode
Arguments
code Specifies a feature set that the compiler can target, including which instruction sets and
optimizations it may generate. Many of the following descriptions refer to Intel® Streaming
SIMD Extensions (Intel® SSE) and Supplemental Streaming SIMD Extensions (Intel® SSSE).
Possible values are:
187
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
188
Compiler Reference
SSSE3 May generate SSSE3 and Intel® SSE3, SSE2, and SSE
instructions for Intel® processors. Optimizes for Intel
processors that support SSSE3 instructions. For macOS*
systems, this value is only supported on Intel® 64
architecture. This replaces value T, which is deprecated.
SSE3 May generate Intel® SSE3, SSE2, and SSE instructions for
Intel® processors. Optimizes for Intel processors that
support Intel® SSE3 instructions. This value is not available
on macOS* systems.
SSE2 May generate Intel® SSE2 and SSE instructions for Intel®
processors. Optimizes for Intel processors that support
Intel® SSE2 instructions. This value is not available on
macOS* systems.
You can also specify a Host. For more information, see option [Q]xHost.
Default
Windows* systems: None On Windows systems, if neither /Qx nor /arch is specified, the default
Linux* systems: None is /arch:SSE2.
macOS* systems: SSSE3
On Linux systems, if neither -x nor -m is specified, the default is
-msse2.
Description
This option tells the compiler which processor features it may target, including which instruction sets and
optimizations it may generate. It also enables optimizations in addition to Intel feature-specific optimizations.
The specialized code generated by this option may only run on a subset of Intel® processors.
The resulting executables created from these option code values can only be run on Intel® processors that
support the indicated instruction set.
The binaries produced by these code values will run on Intel® processors that support the specified features.
Do not use code values to create binaries that will execute on a processor that is not compatible with the
targeted processor. The resulting program may fail with an illegal instruction exception or display other
unexpected behavior.
Compiling the main program with any of the code values produces binaries that display a fatal run-time error
if they are executed on unsupported processors, including all non-Intel processors.
Compiler options m and arch produce binaries that should run on processors not made by Intel that
implement the same capabilities as the corresponding Intel® processors.
The -x and /Qx options enable additional optimizations not enabled with options -m or /arch (nor with
options -ax and /Qax).
On Windows systems, options /Qx and /arch are mutually exclusive. If both are specified, the compiler uses
the last one specified and generates a warning. Similarly, on Linux and macOS* systems, options -x and -m
are mutually exclusive. If both are specified, the compiler uses the last one specified and generates a
warning.
189
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
All settings except SSE2 do a CPU check. However, if you specify option -O0 (Linux* and
macOS*) or option /Od (Windows*), no CPU check is performed.
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
IDE Equivalent
Visual Studio
Visual Studio: Code Generation > Intel Processor-Specific Optimization
Alternate Options
None
See Also
xHost, QxHost compiler option
ax, Qax compiler option
arch compiler option
march compiler option
minstruction, Qinstruction compiler option
m compiler option
xHost, QxHost
Tells the compiler to generate instructions for the
highest instruction set available on the compilation
host processor.
Syntax
Linux OS:
-xHost
macOS:
-xHost
Windows OS:
/QxHost
Arguments
None
Default
Windows* systems: None On Windows systems, if neither /Qx nor /arch is specified, the default
Linux* systems: None is /arch:SSE2.
macOS* systems: -xSSSE3
190
Compiler Reference
Description
This option tells the compiler to generate instructions for the highest instruction set available on the
compilation host processor.
The instructions generated by this compiler option differ depending on the compilation host processor.
The following table describes the effects of specifying the [Q]xHost option and it tells whether the resulting
executable will run on processors different from the host processor.
Descriptions in the table refer to Intel® Advanced Vector Extensions 2 (Intel® AVX2), Intel® Advanced Vector
Extensions (Intel® AVX), Intel® Streaming SIMD Extensions (Intel® SSE), and Supplemental Streaming SIMD
Extensions (SSSE).
Instruction Set Effects When the -xHost or /QxHost Compiler Option is Specified
of Host
Processor
191
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Instruction Set Effects When the -xHost or /QxHost Compiler Option is Specified
of Host
Processor
For more information on other settings for option [Q]x, see that option description.
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
192
Compiler Reference
IDE Equivalent
Visual Studio
Visual Studio: Code Generation > Intel Processor-Specific Optimization
Alternate Options
None
See Also
x, Qx compiler option
ax, Qax compiler option
m compiler option
arch compiler option
NOTE
For the ifort compiler, support for Interprocedural Optimization (IPO) is disabled for macOS* SDK 11
or higher.
ffat-lto-objects
Determines whether a fat link-time optimization (LTO)
object, containing both intermediate language and
object code, is generated during an interprocedural
optimization compilation (-c –ipo). This feature is only
available for ifort.
Syntax
Linux OS:
-ffat-lto-objects
-fno-fat-lto-objects
macOS:
None
Windows OS:
None
Arguments
None
Default
193
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
This option determines whether a fat link time optimization (LTO) object, containing both intermediate
language and object code, is generated during an interprocedural optimization compilation (-c -ipo).
• If you specify -ffat-lto-objects, the compiler generates a fat link-time optimization (LTO) object that
has both a true object and a discardable intermediate language section. This enables both link-time
optimization (LTO) linking and normal linking.
• If you specify -fno-fat-lto-objects, the compiler generates a fat link-time optimization (LTO) object
that only has a discardable intermediate language section; no true object is generated. This option may
improve compilation time.
Note that these files will be inserted into archives in the form in which they were created.
This option is provided for compatibility with gcc. For more information about this option, see the gcc
documentation.
NOTE
Intel's intermediate language representation is not compatible with gcc's intermediate
language representation.
IDE Equivalent
None
Alternate Options
None
See Also
ipo, Qipo compiler option
ip, Qip
Determines whether additional interprocedural
optimizations for single-file compilation are enabled.
This feature is only available for ifort.
Syntax
Linux OS:
-ip
-no-ip
macOS:
-ip
-no-ip
Windows OS:
/Qip
/Qip-
Arguments
None
194
Compiler Reference
Default
OFF Some limited interprocedural optimizations occur, including inline function expansion for calls to
functions defined within the current source file. These optimizations are a subset of full intra-file
interprocedural optimizations. Note that this setting is not the same as -no-ip (Linux* and
macOS*) or /Qip- (Windows*).
Description
This option determines whether additional interprocedural optimizations for single-file compilation are
enabled.
The [Q]ip option enables additional interprocedural optimizations for single-file compilation.
Options -no-ip (Linux and macOS*) and /Qip- (Windows) may not disable inlining. To ensure that inlining
of user-defined functions is disabled, specify -inline-level=0or -fno-inline (Linux and macOS*), or
specify /Ob0 (Windows).
IDE Equivalent
Windows
Visual Studio: Optimization > Interprocedural Optimization
Alternate Options
None
See Also
finline-functions compiler option
ip-no-inlining, Qip-no-inlining
Disables full and partial inlining enabled by
interprocedural optimization options. This feature is
only available for ifort.
Syntax
Linux OS:
-ip-no-inlining
macOS:
-ip-no-inlining
Windows OS:
/Qip-no-inlining
Arguments
None
Default
Description
This option disables full and partial inlining enabled by the following interprocedural optimization options:
195
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IDE Equivalent
None
Alternate Options
None
ip-no-pinlining, Qip-no-pinlining
Disables partial inlining enabled by interprocedural
optimization options. This feature is only available for
ifort.
Syntax
Linux OS:
-ip-no-pinlining
macOS:
-ip-no-pinlining
Windows OS:
/Qip-no-pinlining
Arguments
None
Default
Description
This option disables partial inlining enabled by the following interprocedural optimization options:
IDE Equivalent
None
Alternate Options
None
ipo, Qipo
Enables interprocedural optimization between files.
196
Compiler Reference
Syntax
Linux OS:
-ipo[n]
-no-ipo
macOS:
-ipo[n]
-no-ipo
Windows OS:
/Qipo[n]
/Qipo-
Arguments
Default
Description
This option enables interprocedural optimization between files. This is also called multifile interprocedural
optimization (multifile IPO) or Whole Program Optimization (WPO).
When you specify this option, the compiler performs inline function expansion for calls to functions defined in
separate files.
You cannot specify the names for the files that are created.
If n is 0, the compiler decides whether to create one or more object files based on an estimate of the size of
the application. It generates one object file for small applications, and two or more object files for large
applications.
If n is greater than 0, the compiler generates n object files, unless n exceeds the number of source files (m),
in which case the compiler generates only m object files.
If you do not specify n, the default is 0.
NOTE
When you specify option [Q]ipo with option [q or Q]opt-report, IPO information is
generated in the compiler optimization report at link time. After linking, you will see a report
named ipo_out.optrpt in the folder where you linked all of the object files.
IDE Equivalent
Windows
Visual Studio: Optimization > Interprocedural Optimization
General > Whole Program Optimization
197
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Alternate Options
None
ipo-c, Qipo-c
Tells the compiler to optimize across multiple files and
generate a single object file.
Syntax
Linux OS:
-ipo-c
macOS:
-ipo-c
Windows OS:
/Qipo-c
Arguments
None
Default
Description
This option tells the compiler to optimize across multiple files and generate a single object file (named
ipo_out.o on Linux* and macOS* systems; ipo_out.obj on Windows* systems).
It performs the same optimizations as the [Q]ipo option, but compilation stops before the final link stage,
leaving an optimized object file that can be used in further link steps.
IDE Equivalent
None
Alternate Options
None
See Also
ipo, Qipo compiler option
ipo-jobs, Qipo-jobs
Specifies the number of commands (jobs) to be
executed simultaneously during the link phase of
Interprocedural Optimization (IPO). This feature is
only available for ifort.
Syntax
Linux OS:
-ipo-jobsn
macOS:
-ipo-jobsn
198
Compiler Reference
Windows OS:
/Qipo-jobs:n
Arguments
Default
Description
This option specifies the number of commands (jobs) to be executed simultaneously during the link phase of
Interprocedural Optimization (IPO). It should only be used if the link-time compilation is generating more
than one object. In this case, each object is generated by a separate compilation, which can be done in
parallel.
This option can be affected by the following compiler options:
• [Q]ipo when applications are large enough that the compiler decides to generate multiple object files.
• [Q]ipon when n is greater than 1.
• [Q]ipo-separate
Caution
Be careful when using this option. On a multi-processor system with lots of memory, it can
speed application build time. However, if n is greater than the number of processors, or if
there is not enough memory to avoid thrashing, this option can increase application build
time.
IDE Equivalent
None
Alternate Options
None
See Also
ipo, Qipo compiler option
ipo-separate, Qipo-separate compiler option
ipo-S, Qipo-S
Tells the compiler to optimize across multiple files and
generate a single assembly file. This feature is only
available for ifort.
Syntax
Linux OS:
-ipo-S
macOS:
-ipo-S
199
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows OS:
/Qipo-S
Arguments
None
Default
Description
This option tells the compiler to optimize across multiple files and generate a single assembly file (named
ipo_out.s on Linux* and macOS* systems; ipo_out.asm on Windows* systems).
It performs the same optimizations as the [Q]ipo option, but compilation stops before the final link stage,
leaving an optimized assembly file that can be used in further link steps.
IDE Equivalent
None
Alternate Options
None
See Also
ipo, Qipo compiler option
ipo-separate, Qipo-separate
Tells the compiler to generate one object file for every
source file. This feature is only available for ifort.
Syntax
Linux OS:
-ipo-separate
macOS:
None
Windows OS:
/Qipo-separate
Arguments
None
Default
OFF The compiler decides whether to create one or more object files.
Description
This option tells the compiler to generate one object file for every source file. It overrides any [Q]ipo option
specification.
200
Compiler Reference
IDE Equivalent
None
Alternate Options
None
See Also
ipo, Qipo compiler option
ansi-alias, Qansi-alias
Tells the compiler to assume certain rules of the
Fortran standard regarding aliasing and array bounds.
Syntax
Linux OS:
-ansi-alias
-no-ansi-alias
macOS:
-ansi-alias
-no-ansi-alias
Windows OS:
/Qansi-alias
/Qansi-alias-
Arguments
None
Default
-ansi-alias Programs adhere to the Fortran standard's rules regarding aliasing and
or /Qansi-alias array bounds.
Description
This option tells the compiler to assume certain rules of the Fortran standard regarding aliasing and array
bounds.
It tells the compiler to assume that the program adheres to the following rules of the Fortran standard:
This option is similar to option assume nodummy_aliases with the additional restriction on array bounds.
If -no-ansi-alias (Linux* and macOS*) or /Qansi-alias- (Windows*) is specified, the compiler assumes
that the program might not follow the Fortran standard's rules regarding dummy argument aliasing and array
bounds; this can possibly affect performance.
201
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IDE Equivalent
None
Alternate Options
None
See Also
assume compiler option, setting [no]dummy_aliases
coarray, Qcoarray
Enables the coarray feature.
Syntax
Linux OS:
-coarray[=keyword]
macOS:
None
Windows OS:
/Qcoarray[:keyword]
Arguments
keyword Specifies the memory system where the coarrays will be implemented. Possible values are:
single Indicates a configuration where the image does not contain self-
replication code. This results in an executable with a single running
image. This configuration can be useful for debugging purposes, even
though there are no inter-image interactions.
Default
OFF Coarrays are not enabled unless you specify this option.
Description
This option enables the coarray feature of the Fortran 2008 Standard. It enables any coarray syntax in your
program. If this option is not specified, coarray syntax is rejected.
It also tells the driver to link against appropriate libraries, and to create the appropriate executables.
Only one keyword can be in effect. If you specify more than one keyword, the last one specified takes
precedence. However, if keyword single is specified anywhere on the command line, it takes precedence.
You can specify option [Q]coarray-num-images to specify the default number of images that can be used
to run a coarray executable. If you do not specify that option, you get the number of execution units on the
current system.
You can specify the [Q]coarray-config-file option to specify the name of a Message Passing Interface
(MPI) configuration file.
Options [Q]coarray-num-images and [Q]coarray-config-file are valid for all keyword values.
202
Compiler Reference
NOTE
Coarrays are only supported on 64-bit architectures.
IDE Equivalent
Windows
Visual Studio: Language > Enable Coarrays
Alternate Options
None
Example
The following command runs a coarray program on shared memory using n images:
See Also
coarray-num-images, Qcoarray-num-images compiler option
coarray-config-file, Qcoarray-config-file compiler option
Coarrays
Using Coarrays
coarray-config-file, Qcoarray-config-file
Specifies the name of a Message Passing Interface
(MPI) configuration file.
Syntax
Linux OS:
-coarray-config-file=filename
203
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
macOS:
None
Windows OS:
/Qcoarray-config-file:filename
Arguments
filename Is the name of the MPI configuration file. You can specify a path.
Default
OFF When coarrays are enabled, the compiler uses default settings for MPI.
Description
This option specifies the name of a Message Passing Interface (MPI) configuration file. This file is used by the
compiler when coarrays are processed; it configures the MPI for multi-node operations.
This option has no affect unless you also specify the [Q]coarray option, which is required to create the
coarray executable.
Note that when a setting is specified in environment variable FOR_COARRAY_CONFIG_FILE, it overrides the
compiler option setting.
IDE Equivalent
Windows
Visual Studio: Language > MPI Configuration File
Alternate Options
None
See Also
coarray, Qcoarray compiler option
coarray-num-images, Qcoarray-num-images
Specifies the default number of images that can be
used to run a coarray executable.
Syntax
Linux OS:
-coarray-num-images=n
macOS:
None
Windows OS:
/Qcoarray-num-images:n
Arguments
n Is the default number of images. The limit is determined from the system
configuration.
204
Compiler Reference
Default
Description
This option specifies the default number of images that can be used to run a coarray executable.
This option has no affect unless you also specify the [Q]coarray option. This option is required to create the
coarray executable.
You can specify option [Q]coarray-num-images to specify the default number of images that can be used
to run a coarray executable. If you do not specify that option, you get the number of execution units on the
current system.
Note that when a setting is specified in environment variable FOR_COARRAY_NUM_IMAGES, it overrides the
compiler option setting.
IDE Equivalent
Windows
Visual Studio: Language > Coarray Images
Alternate Options
None
See Also
coarray, Qcoarray compiler option
complex-limited-range, Qcomplex-limited-range
Determines whether the use of basic algebraic
expansions of some arithmetic operations involving
data of type COMPLEX is enabled. This feature is only
available for ifort.
Syntax
Linux OS:
-complex-limited-range
-no-complex-limited-range
macOS:
-complex-limited-range
-no-complex-limited-range
Windows OS:
/Qcomplex-limited-range
/Qcomplex-limited-range-
Arguments
None
205
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
Description
This option determines whether the use of basic algebraic expansions of some arithmetic operations involving
data of type COMPLEX is enabled.
When the option is enabled, this can cause performance improvements in programs that use a lot of
COMPLEX arithmetic. However, values at the extremes of the exponent range may not compute correctly.
IDE Equivalent
Windows
Visual Studio: Floating point > Limit COMPLEX Range
Alternate Options
None
guide, Qguide
Lets you set a level of guidance for auto-vectorization,
auto parallelism, and data transformation. This feature
is only available for ifort.
Syntax
Linux OS:
-guide[=n]
macOS:
-guide[=n]
Windows OS:
/Qguide[:n]
Arguments
Default
OFF You do not receive guidance about how to improve optimizations for
parallelism, vectorization, and data transformation.
Description
This option lets you set a level of guidance (advice) for auto-vectorization, auto parallelism, and data
transformation. It causes the compiler to generate messages suggesting ways to improve these
optimizations.
When this option is specified, the compiler does not produce any objects or executables.
206
Compiler Reference
You must also specify the [Q]parallel option to receive auto parallelism guidance.
You can set levels of guidance for the individual guide optimizations by specifying one of the following
options:
If you specify the [Q]guide option and also specify one of the options setting a level of guidance for an
individual guide optimization, the value set for the individual guide optimization will override the setting
specified in [Q]guide.
If you do not specify [Q]guide, but specify one of the options setting a level of guidance for an individual
guide optimization, option [Q]guide is enabled with the greatest value passed among any of the three
individual guide optimizations specified.
In debug mode, this option has no effect unless option O2 (or higher) is explicitly specified in the same
command line.
NOTE
The compiler speculatively performs optimizations as part of guide analysis. As a result,
when you use guided auto-parallelism options with options that produce vectorization or
auto-parallelizer reports (such as option [q or Q]opt-report), the compiler generates
"LOOP WAS VECTORIZED" or similar messages as if the compilation was performed with the
recommended changes.
When compilation is performed with the [Q]guide option, you should use extra caution when
interpreting vectorizer diagnostics and auto-parallelizer diagnostics.
NOTE
You can specify [Q]diag-disable to prevent the compiler from issuing one or more
diagnostic messages.
IDE Equivalent
Visual Studio
Visual Studio: Diagnostics > Guided Auto Parallelism > Guided Auto Parallelism Analysis
Alternate Options
None
See Also
guide-data-trans, Qguide-data-trans compiler option
guide-par, Qguide-par compiler option
guide-vec, Qguide-vec compiler option
guide-file, Qguide-file compiler option
guide-file-append, Qguide-file-append compiler option
guide-opts, Qguide-opts compiler option
diag, Qdiag compiler option
qopt-report, Qopt-report compiler option
207
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
guide-data-trans, Qguide-data-trans
Lets you set a level of guidance for data
transformation. This feature is only available for ifort.
Syntax
Linux OS:
-guide-data-trans[=n]
macOS:
-guide-data-trans[=n]
Windows OS:
/Qguide-data-trans[:n]
Arguments
Default
OFF You do not receive guidance about how to improve optimizations for data
transformation.
Description
This option lets you set a level of guidance for data transformation. It causes the compiler to generate
messages suggesting ways to improve that optimization.
IDE Equivalent
None
Alternate Options
None
See Also
guide, Qguide compiler option
guide-par, Qguide-par compiler option
guide-vec, Qguide-vec compiler option
guide-file, Qguide-file compiler option
guide-file, Qguide-file
Causes the results of guided auto parallelism to be
output to a file. This feature is only available for ifort.
Syntax
Linux OS:
-guide-file[=filename]
208
Compiler Reference
macOS:
-guide-file[=filename]
Windows OS:
/Qguide-file[:filename]
Arguments
filename Is the name of the file for output. It can include a path.
Default
OFF Messages that are generated by guided auto parallelism are output to stderr.
Description
This option causes the results of guided auto parallelism to be output to a file.
This option is ignored unless you also specify one or more of the following options:
• [Q]guide
• [Q]guide-vec
• [Q]guide-data-trans
• [Q]guide-par
If you do not specify a path, the file is placed in the current working directory.
If there is already a file named filename, it will be overwritten.
You can include a file extension in filename. For example, if file.txt is specified, the name of the output file is
file.txt. If you do not provide a file extension, the name of the file is filename.guide.
If you do not specify filename, the name of the file is name-of-the-first-source-file.guide. This is also the
name of the file if the name specified for filename conflicts with a source file name provided in the command
line.
NOTE
If you specify the [Q]guide-file option and you also specify option [Q]guide-file-append,
the last option specified on the command line takes precedence.
IDE Equivalent
Windows
Visual Studio: Diagnostics > Guided Auto Parallelism > Emit Guided Auto Parallelism Diagnostics to
File
Diagnostics > Guided Auto Parallelism Diagnostics File
Alternate Options
None
209
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
The following example shows how to cause guided auto parallelism messages to be output to a file named
my_guided_autopar.guide:
See Also
guide, Qguide compiler option
guide-file-append, Qguide-file-append compiler option
guide-file-append, Qguide-file-append
Causes the results of guided auto parallelism to be
appended to a file. This feature is only available for
ifort.
Syntax
Linux OS:
-guide-file-append[=filename]
macOS:
-guide-file-append[=filename]
Windows OS:
/Qguide-file-append[:filename]
Arguments
filename Is the name of the file to be appended to. It can include a path.
Default
OFF Messages that are generated by guided auto parallelism are output to stderr.
Description
This option causes the results of guided auto parallelism to be appended to a file.
This option is ignored unless you also specify one or more of the following options:
• [Q]guide
• [Q]guide-vec
• [Q]guide-data-trans
• [Q]guide-par
If you do not specify a path, the compiler looks for filename in the current working directory.
If filename is not found, then a new file with that name is created in the current working directory.
If you do not specify a file extension, the name of the file is filename.guide.
If the name specified for filename conflicts with a source file name provided in the command line, the name
of the file is name-of-the-first-source-file.guide.
210
Compiler Reference
NOTE
If you specify the [Q]guide-file-append option and you also specify option [Q]guide-file,
the last option specified on the command line takes precedence.
IDE Equivalent
None
Alternate Options
None
Example
The following example shows how to cause guided auto parallelism messages to be appended to a file named
my_messages.txt:
See Also
guide, Qguide compiler option
guide-file, Qguide-file compiler option
guide-opts, Qguide-opts
Tells the compiler to analyze certain code and
generate recommendations that may improve
optimizations. This feature is only available for ifort.
Syntax
Linux OS:
-guide-opts=string
macOS:
-guide-opts=string
Windows OS:
/Qguide-opts:string
Arguments
string Is the text denoting the code to analyze. The string must appear within quotes. It can take
one or more of the following forms:
filename
filename, routine
filename, range [, range]...
filename, routine, range [, range]...
If you specify more than one of the above forms in a string, a semicolon must appear
between each form. If you specify more than one range in a string, a comma must appear
between each range. Optional blanks can follow each parameter in the forms above and
they can also follow each form in a string.
211
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
OFF You do not receive guidance on how to improve optimizations. However, if you specify the
[Q]guide option, the compiler analyzes and generates recommendations for all the code in an
application
Description
This option tells the compiler to analyze certain code and generate recommendations that may improve
optimizations.
This option is ignored unless you also specify one or more of the following options:
• [Q]guide
• [Q]guide-vec
• [Q]guide-data-trans
• [Q]guide-par
When the [Q]guide-opts option is specified, a message is output that includes which parts of the input files
are being analyzed. If a routine is selected to be analyzed, the complete routine name will appear in the
generated message.
When inlining is involved, you should specify callee line numbers. Generated messages also use callee line
numbers.
IDE Equivalent
Visual Studio
Visual Studio: Diagnostics > Guided Auto Parallelism > Guided Auto Parallelism Code Selection
Options
212
Compiler Reference
Alternate Options
None
Example
Consider the following:
Linux*: -guide-opts="m.f, 1-10; m2.f90, 1-40, 50-90, 100-200; m5.f, 300-400; x.f, 'funca(j)',
22-44, 55-77, 88-99; y.f, 'subrb'"
Windows*: /Quide-opts="m.f, 1-10; m2.f90, 1-40, 50-90, 100-200; m5.f, 300-400; x.f, 'funca(j)',
22-44, 55-77, 88-99; y.f, 'subrb'"
The above command causes the following to be analyzed:
See Also
guide, Qguide compiler option
guide-data-trans, Qguide-data-trans compiler option
guide-par, Qguide-par compiler option
guide-vec, Qguide-vec compiler option
guide-file, Qguide-file compiler option
guide-par, Qguide-par
Lets you set a level of guidance for auto parallelism.
This feature is only available for ifort.
Syntax
Linux OS:
-guide-par[=n]
macOS:
-guide-par[=n]
Windows OS:
/Qguide-par[:n]
Arguments
Default
OFF You do not receive guidance about how to improve optimizations for
parallelism.
213
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
This option lets you set a level of guidance for auto parallelism. It causes the compiler to generate messages
suggesting ways to improve that optimization.
You must also specify the [Q]parallel option to receive auto parallelism guidance.
IDE Equivalent
None
Alternate Options
None
See Also
guide, Qguide compiler option
guide-data-trans, Qguide-data-trans compiler option
guide-vec, Qguide-vec compiler option
guide-file, Qguide-file compiler option
guide-vec, Qguide-vec
Lets you set a level of guidance for auto-vectorization.
This feature is only available for ifort.
Syntax
Linux OS:
-guide-vec[=n]
macOS:
-guide-vec[=n]
Windows OS:
/Qguide-vec[:n]
Arguments
Default
OFF You do not receive guidance about how to improve optimizations for
vectorization.
Description
This option lets you set a level of guidance for auto-vectorization. It causes the compiler to generate
messages suggesting ways to improve that optimization.
IDE Equivalent
None
214
Compiler Reference
Alternate Options
None
See Also
guide, Qguide compiler option
guide-data-trans, Qguide-data-trans compiler option
guide-par, Qguide-par compiler option
guide-file, Qguide-file compiler option
heap-arrays
Puts automatic arrays and arrays created for
temporary computations on the heap instead of the
stack.
Syntax
Linux OS:
-heap-arrays [size]
-no-heap-arrays
macOS:
-heap-arrays [size]
-no-heap-arrays
Windows OS:
/heap-arrays[:size]
/heap-arrays-
Arguments
size Is an integer value representing the size of the arrays in kilobytes. Arrays smaller than size are
put on the stack.
Default
-no-heap-arrays The compiler puts automatic arrays and temporary arrays in the stack storage
or /heap-arrays- area.
Description
This option puts automatic arrays and arrays created for temporary computations on the heap instead of the
stack.
When this option is specified, automatic (temporary) arrays that have a compile-time size greater than the
value specified for size are put on the heap, rather than on the stack. If the compiler cannot determine the
size at compile time, it always puts the automatic array on the heap.
If size is specified, the value is only used when the total size of the temporary array or automatic array can
be determined at compile time, using compile-time constants. Any arrays known at compile-time to be larger
than size are allocated on the heap instead of the stack. For example, if 10 is specified for size:
• All automatic and temporary arrays equal to or larger than 10 KB are put on the heap.
• All automatic and temporary arrays smaller than 10 KB are put on the stack.
215
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If size is omitted, and the size of the temporary array or automatic array cannot be determined at compile
time, it is assumed that the total size is greater than size and the array is allocated on the heap.
On Windows, you can use compiler option /F to tell the linker to increase the size of the run-time stack to
allow for large objects on the stack.
On Linux and macOS*, you can use the shell command unlimit to increase the size of the run-time stack
before execution.
IDE Equivalent
Windows
Visual Studio: Optimization > Heap Arrays
Alternate Options
None
Example
In Fortran, an automatic array gets its size from a run-time expression. For example:
RECURSIVE SUBROUTINE F( N )
INTEGER :: N
REAL :: X ( N ) ! an automatic array
REAL :: Y ( 1000 ) ! an explicit-shape local array on the stack
Array X in the example above is affected by the heap-array option; array Y is not.
Temporary arrays are often created before making a routine call, or when an array operation detects overlap.
For example:
integer a(10000)
a(2:) = a(1:ubound(a,dim=1)-1)
In this case, the array assignment uses a temporary intermediate array because there is clearly an overlap
between the right hand side and the left hand side of the assignment.
If you specify the heap-arrays option, the compiler creates the temporary array on the heap.
If you specify the heap-arrays option with size 50, the compiler creates the temporary array on the stack.
This is because the size of the temporary intermediate array can be determined at compile time (40Kb), and
it's size is less than the size value.
In the following example, a contiguous array is created from the array slice declaration and passed on:
call somesub(a(1:10000:2))
If you specify the heap-arrays option, the compiler creates the temporary array on the heap.
If you specify the heap-arrays option with size 25, the compiler creates the temporary array on the stack.
This is because the size of the temporary intermediate array at compile time is only 20Kb.
See Also
F compiler option
pad, Qpad
Enables the changing of the variable and array
memory layout.
216
Compiler Reference
Syntax
Linux OS:
-pad
-nopad
macOS:
-pad
-nopad
Windows OS:
/Qpad
/Qpad-
Arguments
None
Default
-nopad or /Qpad- Variable and array memory layout is performed by default methods.
Description
This option enables the changing of the variable and array memory layout.
This option is effectively not different from the align option when applied to structures and derived types.
However, the scope of pad is greater because it applies also to common blocks, derived types, sequence
types, and structures.
IDE Equivalent
None
Alternate Options
None
See Also
align compiler option
qmkl, Qmkl
Tells the compiler to link to certain libraries in the
Intel® oneAPI Math Kernel Library (oneMKL). On
Windows systems, you must specify this option at
compile time.
Syntax
Linux OS:
-qmkl[=lib]
macOS:
-qmkl[=lib]
Windows OS:
/Qmkl[:lib]
217
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Arguments
lib Indicates which oneMKL library files should be linked. Possible values are:
Default
Description
This option tells the compiler to link to certain libraries in the Intel® oneAPI Math Kernel Library (oneMKL).
On Linux* and macOS* systems, dynamic linking is the default when you specify -qmkl.
-qmkl -static-intel
On Windows* systems, static linking is the default when you specify /Qmkl. To link with oneMKL dynamically,
you must specify:
NOTE
On Windows* systems, this option adds directives to the compiled code, which the linker
then reads without further input from the driver. You do not need to specify a separate link
command.
On Linux* and macOS* systems, the driver must add the library names explicitly to the link command.
You must use option -qmkl to perform the link to pull in the dependent libraries.
IDE Equivalent
Visual Studio
Visual Studio: Libraries > Intel® oneAPI Math Kernel Library
Alternate Options
Linux and macOS* on ifort: -mkl (this is a deprecated option)
See Also
static-intel compiler option
MD compiler option
218
Compiler Reference
qopt-args-in-regs, Qopt-args-in-regs
Determines whether calls to routines are optimized by
passing arguments in registers instead of on the
stack. This option is deprecated and will be removed
in a future release. This feature is only available for
ifort.
Architecture Restrictions
Only available on IA-32 architecture. IA-32 support has been deprecated, and will be removed in a future
release.
Syntax
Linux OS:
-qopt-args-in-regs[=keyword]
macOS:
None
Windows OS:
/Qopt-args-in-regs[:keyword]
Arguments
keyword Specifies whether the optimization should be performed and under what conditions. Possible
values are:
none The optimization is not performed. No arguments are passed in registers. They are
put on the stack.
seen Causes arguments to be passed in registers when they are passed to routines
whose definition can be seen in the same compilation unit.
all Causes arguments to be passed in registers, whether they are passed to routines
whose definition can be seen in the same compilation unit, or not. This value is
only available on Linux* systems.
Default
-qopt-args-in-regs=seen Arguments are passed in registers when they are passed to routines
or /Qopt-args-in-regs:seen whose definition is seen in the same compilation unit.
Description
This option determines whether calls to routines are optimized by passing arguments in registers instead of
on the stack. It also indicates the conditions when the optimization will be performed.
This option can improve performance for Application Binary Interfaces (ABIs) that require arguments to be
passed in memory and compiled without interprocedural optimization (IPO).
Note that on Linux* systems, if all is specified, a small overhead may be paid when calling "unseen"
routines that have not been compiled with the same option. This is because the call will need to go through a
"thunk" to ensure that arguments are placed back on the stack where the callee expects them.
219
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IDE Equivalent
None
Alternate Options
None
qopt-assume-safe-padding, Qopt-assume-safe-padding
Determines whether the compiler assumes that
variables and dynamically allocated memory are
padded past the end of the object. This feature is only
available for ifort.
Architecture Restrictions
Only available on all architectures that support Intel® Advanced Vector Extensions 512 (Intel® AVX-512)
Foundation instructions
Syntax
Linux OS:
-qopt-assume-safe-padding
-qno-opt-assume-safe-padding
macOS:
-qopt-assume-safe-padding
-qno-opt-assume-safe-padding
Windows OS:
/Qopt-assume-safe-padding
/Qopt-assume-safe-padding-
Arguments
None
Default
-qno-opt-assume-safe-padding The compiler will not assume that variables and dynamically allocated
or /Qopt-assume-safe-padding- memory are padded past the end of the object. It will adhere to the
sizes specified in your program.
Description
This option determines whether the compiler assumes that variables and dynamically allocated memory are
padded past the end of the object.
When you specify option [q or Q]opt-assume-safe-padding, the compiler assumes that variables and
dynamically allocated memory are padded. This means that code can access up to 64 bytes beyond what is
specified in your program.
The compiler does not add any padding for static and automatic objects when this option is used, but it
assumes that code can access up to 64 bytes beyond the end of the object, wherever the object appears in
the program. To satisfy this assumption, you must increase the size of static and automatic objects in your
program when you use this option.
This option may improve performance of memory operations.
220
Compiler Reference
IDE Equivalent
None
Alternate Options
None
qopt-block-factor, Qopt-block-factor
Lets you specify a loop blocking factor. This feature is
only available for ifort.
Syntax
Linux OS:
-qopt-block-factor=n
macOS:
-qopt-block-factor=n
Windows OS:
/Qopt-block-factor:n
Arguments
Default
Description
This option lets you specify a loop blocking factor.
IDE Equivalent
None
Alternate Options
None
qopt-dynamic-align, Qopt-dynamic-align
Enables or disables dynamic data alignment
optimizations. This feature is only available for ifort.
Syntax
Linux OS:
-qopt-dynamic-align
-qno-opt-dynamic-align
macOS:
-qopt-dynamic-align
-qno-opt-dynamic-align
221
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows OS:
/Qopt-dynamic-align
/Qopt-dynamic-align-
Arguments
None
Default
Description
This option enables or disables dynamic data alignment optimizations.
If you specify -qno-opt-dynamic-align or /Qopt-dynamic-align-, the compiler generates no code
dynamically dependent on alignment. It will not do any optimizations based on data location and results will
depend on the data values themselves.
When you specify [q or Q]qopt-dynamic-align, the compiler may implement conditional optimizations
based on dynamic alignment of the input data. These dynamic alignment optimizations may result in
different bitwise results for aligned and unaligned data with the same values.
Dynamic alignment optimizations can improve the performance of vectorized code, especially for long trip
count loops. Disabling such optimizations can decrease performance, but it may improve bitwise
reproducibility of results, factoring out data location from possible sources of discrepancy.
IDE Equivalent
None
Alternate Options
None
qopt-for-throughput, Qopt-for-throughput
Determines how the compiler optimizes for throughput
depending on whether the program is to run in single-
job or multi-job mode. This feature is only available
for ifx.
Syntax
Linux OS:
-qopt-for-throughput[=value]
macOS:
None
Windows OS:
/Qopt-for-throughput[:value]
222
Compiler Reference
Arguments
Default
OFF If this option is not specified, the compiler will not optimize for throughput performance.
Description
This option determines whether throughput performance optimization occurs for a program that is run as a
single job or one that is run in a multiple job environment.
The memory optimizations for a single job versus multiple jobs can be tuned in different ways by the
compiler. For example, the cost model for loop tiling and prefetching are different for a single job versus
multiple jobs. When a single job is running, more memory is available and the tunings will be different.
NOTE
When offloading is enabled, this option only applies to host compilation. Offloading can only
be enabled when using ifx.
IDE Equivalent
None
Alternate Options
None
qopt-jump-tables, Qopt-jump-tables
Enables or disables generation of jump tables for
switch statements. This feature is only available for
ifort.
Syntax
Linux OS:
-qopt-jump-tables=keyword
-qno-opt-jump-tables
macOS:
-qopt-jump-tables=keyword
-qno-opt-jump-tables
Windows OS:
/Qopt-jump-tables:keyword
/Qopt-jump-tables-
Arguments
keyword Is the instruction for generating jump tables. Possible values are:
223
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
never Tells the compiler to never generate jump tables. All switch
statements are implemented as chains of if-then-elses.
This is the same as specifying -qno-opt-jump-tables
(Linux* and macOS*) or /Qopt-jump-tables-
(Windows*).
Default
Description
This option enables or disables generation of jump tables for switch statements. When the option is enabled,
it may improve performance for programs with large switch statements.
IDE Equivalent
None
Alternate Options
None
qopt-malloc-options
Lets you specify an alternate algorithm for malloc().
This feature is only available for ifort.
Syntax
Linux OS:
-qopt-malloc-options=n
macOS:
-qopt-malloc-options=n
Windows OS:
None
Arguments
224
Compiler Reference
Default
-qopt-malloc-options=0 The compiler uses the default algorithm when malloc() is called.
No call is made to mallopt().
Description
This option lets you specify an alternate algorithm for malloc().
If you specify a non-zero value for n, it causes alternate configuration parameters to be set for how malloc()
allocates and frees memory. It tells the compiler to insert calls to mallopt() to adjust these parameters to
malloc() for dynamic memory allocation. This may improve speed.
IDE Equivalent
None
Alternate Options
None
See Also
malloc(3) man page
mallopt function (defined in malloc.h)
qopt-matmul, Qopt-matmul
Enables or disables a compiler-generated Matrix
Multiply (matmul) library call.
Syntax
Linux OS:
-qopt-matmul
-qno-opt-matmul
macOS:
None
Windows OS:
/Qopt-matmul
225
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
/Qopt-matmul-
Arguments
None
Default
-qno-opt-matmul The matmul library call optimization does not occur unless this option is
or /Qopt-matmul- enabled or certain other compiler options are specified (see below).
Description
This option enables or disables a compiler-generated Matrix Multiply (MATMUL) library call.
The [q or Q]opt-matmul option tells the compiler to identify matrix multiplication loop nests (if any) and
replace them with a matmul library call for improved performance. The resulting executable may improve
performance on Intel® microprocessors.
NOTE
This option is dependent upon the OpenMP* library. If your product does not support
OpenMP, this option will have no effect.
NOTE
Many routines in the MATMUL library are more highly optimized for Intel® microprocessors
than for non-Intel microprocessors.
IDE Equivalent
Visual Studio
Visual Studio: Optimization > Enable Matrix Multiply Library Call
Alternate Options
None
See Also
O compiler option
qopt-mem-layout-trans, Qopt-mem-layout-trans
Controls the level of memory layout transformations
performed by the compiler.
Syntax
Linux OS:
-qopt-mem-layout-trans[=n]
-qno-opt-mem-layout-trans
macOS:
-qopt-mem-layout-trans[=n]
-qno-opt-mem-layout-trans
226
Compiler Reference
Windows OS:
/Qopt-mem-layout-trans[:n]
/Qopt-mem-layout-trans-
Arguments
Default
Description
This option controls the level of memory layout transformations performed by the compiler. This option can
improve cache reuse and cache locality.
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
IDE Equivalent
None
Alternate Options
None
qopt-multi-version-aggressive, Qopt-multi-version-aggressive
Tells the compiler to use aggressive multi-versioning
to check for pointer aliasing and scalar replacement.
This feature is only available for ifort.
227
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-qopt-multi-version-aggressive
-qno-opt-multi-version-aggressive
macOS:
-qopt-multi-version-aggressive
-qno-opt-multi-version-aggressive
Windows OS:
/Qopt-multi-version-aggressive
/Qopt-multi-version-aggressive-
Arguments
None
Default
Description
This option tells the compiler to use aggressive multi-versioning to check for pointer aliasing and scalar
replacement. This option may improve performance.
The performance can be affected by certain options, such as /arch or /Qx (Windows*) or -m or -x (Linux*
and macOS*).
IDE Equivalent
None
Alternate Options
None
qopt-multiple-gather-scatter-by-shuffles, Qopt-multiple-gather-scatter-by-shuffles
Enables or disables the optimization for multiple
adjacent gather/scatter type vector memory
references.
Syntax
Linux OS:
-qopt-multiple-gather-scatter-by-shuffles
-qno-opt-multiple-gather-scatter-by-shuffles
macOS:
-qopt-multiple-gather-scatter-by-shuffles
-qno-opt-multiple-gather-scatter-by-shuffles
228
Compiler Reference
Windows OS:
/Qopt-multiple-gather-scatter-by-shuffles
/Qopt-multiple-gather-scatter-by-shuffles-
Arguments
None
Default
varies When this option is not specified, the compiler uses default heuristics for
optimization.
Description
This option controls the optimization for multiple adjacent gather/scatter type vector memory references.
This optimization hint is useful for performance tuning. It tries to generate more optimal software sequences
using shuffles.
If you specify this option, the compiler will apply the optimization heuristics. If you specify
-qno-opt-multiple-gather-scatter-by-shuffles
or /Qopt-multiple-gather-scatter-by-shuffles-, the compiler will not apply the optimization.
NOTE
Optimization is affected by optimization compiler options, such as [Q]x, -march (Linux* or
macOS*), and /arch (Windows*).
To override the effect of this option (or the default) per loop basis, you can use directive VECTOR
[NO]MULTIPLE_GATHER_SCATTER_BY_SHUFFLE.
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
IDE Equivalent
None
Alternate Options
None
See Also
VECTOR directive
x, Qx compiler option
march compiler option
arch compiler option
qopt-prefetch, Qopt-prefetch
Enables or disables prefetch insertion optimization.
This feature is only available for ifort.
229
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-qopt-prefetch[=n]
-qno-opt-prefetch
macOS:
-qopt-prefetch[=n]
-qno-opt-prefetch
Windows OS:
/Qopt-prefetch[:n]
/Qopt-prefetch-
Arguments
Default
Description
This option enables or disables prefetch insertion optimization. The goal of prefetching is to reduce cache
misses by providing hints to the processor about when data should be loaded into the cache.
This option enables prefetching when higher optimization levels are specified.
IDE Equivalent
Visual Studio
Visual Studio: Optimization > Prefetch Insertion
Alternate Options
None
See Also
qopt-prefetch-distance, Qopt-prefetch-distance compiler option
230
Compiler Reference
qopt-prefetch-distance, Qopt-prefetch-distance
Specifies the prefetch distance to be used for
compiler-generated prefetches inside loops. This
feature is only available for ifort.
Syntax
Linux OS:
-qopt-prefetch-distance=n1[, n2]
macOS:
None
Windows OS:
/Qopt-prefetch-distance:n1[, n2]
Arguments
Default
OFF The compiler uses default heuristics to determine the prefetch distance.
Description
This option specifies the prefetch distance to be used for compiler-generated prefetches inside loops. The unit
(n1 and optionally n2) is the number of iterations. If the loop is vectorized by the compiler, the unit is the
number of vectorized iterations.
The value of n1 will be used as the distance for prefetches from memory to L2 (for example, the vprefetch1
instruction). If n2 is specified, it will be used as the distance for prefetches from L2 to L1 (for example, the
vprefetch0 instruction).
This option is ignored if option -qopt-prefetch=0 (Linux*) or /Qopt-prefetch:0 (Windows*) is specified.
IDE Equivalent
None
Alternate Options
None
Example
Consider the following Linux* examples:
-qopt-prefetch-distance=64,32
231
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The above causes the compiler to use a distance of 64 iterations for memory to L2 prefetches, and a distance
of 32 iterations for L2 to L1 prefetches.
-qopt-prefetch-distance=24
The above causes the compiler to use a distance of 24 iterations for memory to L2 prefetches. The distance
for L2 to L1 prefetches will be determined by the compiler.
-qopt-prefetch-distance=0,4
The above turns off all memory to L2 prefetches inserted by the compiler inside loops. The compiler will use
a distance of 4 iterations for L2 to L1 prefetches.
-qopt-prefetch-distance=16,0
The above causes the compiler to use a distance of 16 iterations for memory to L2 prefetches. No L2 to L1
loop prefetches are issued by the compiler.
See Also
qopt-prefetch, Qopt-prefetch compiler option
PREFETCH directive
qopt-prefetch-issue-excl-hint, Qopt-prefetch-issue-excl-hint
Supports the prefetchW instruction in Intel®
microarchitecture code name Broadwell and later. This
feature is only available for ifort.
Syntax
Linux OS:
-qopt-prefetch-issue-excl-hint
macOS:
None
Windows OS:
/Qopt-prefetch-issue-excl-hint
Arguments
None
Default
Description
This option supports the PREFETCHW instruction in Intel® microarchitecture code name Broadwell and later.
When you specify this option, you must also specify option [q or Q]opt-prefetch.
The prefetch instruction is merely a hint and does not affect program behavior. If executed, this instruction
moves data closer to the processor and invalidates any other cached copy in anticipation of the line being
written to in the future.
IDE Equivalent
None
232
Compiler Reference
Alternate Options
None
See Also
qopt-prefetch/Qopt-prefetch compiler option
qopt-ra-region-strategy, Qopt-ra-region-strategy
Selects the method that the register allocator uses to
partition each routine into regions. This feature is only
available for ifort.
Syntax
Linux OS:
-qopt-ra-region-strategy[=keyword]
macOS:
-qopt-ra-region-strategy[=keyword]
Windows OS:
/Qopt-ra-region-strategy[:keyword]
Arguments
Default
Description
This option selects the method that the register allocator uses to partition each routine into regions.
When setting default is in effect, the compiler attempts to optimize the tradeoff between compile-time
performance and generated code performance.
This option is only relevant when optimizations are enabled (option O1 or higher).
IDE Equivalent
None
233
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Alternate Options
None
See Also
O compiler option
qopt-streaming-stores, Qopt-streaming-stores
Enables generation of streaming stores for
optimization. This feature is only available for ifort.
Syntax
Linux OS:
-qopt-streaming-stores=keyword
-qno-opt-streaming-stores
macOS:
-qopt-streaming-stores=keyword
-qno-opt-streaming-stores
Windows OS:
/Qopt-streaming-stores:keyword
/Qopt-streaming-stores-
Arguments
keyword Specifies whether streaming stores are generated. Possible values are:
Default
234
Compiler Reference
Description
This option enables generation of streaming stores for optimization. This method stores data with
instructions that use a non-temporal buffer, which minimizes memory hierarchy pollution.
This option may be useful for applications that can benefit from streaming stores.
IDE Equivalent
None
Alternate Options
None
Example
The following example shows one way to insert memory barriers (fences) when specifying
-qopt-streaming-stores=always or /Qopt-streaming-stores:always. It uses the procedure interface
for_sfence from the module IFCORE, which maps to the C/C++ function _mm_sfence:
!$omp parallel do
do j = 1, n1
a(j) = 1.0
b(j) = 2.0
c(j) = 3.0
enddo
!$omp end parallel do
call ftn_sfence()
!$omp parallel do
do i = 1, n2
a(i) = a(i) + b(i) * c(i)
enddo
!$omp end parallel do
end
See Also
ax, Qax compiler option
x, Qx compiler option
qopt-subscript-in-range, Qopt-subscript-in-range
Determines whether the compiler assumes that there
are no "large" integers being used or being computed
inside loops. This feature is only available for ifort.
Syntax
Linux OS:
-qopt-subscript-in-range
-qno-opt-subscript-in-range
235
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
macOS:
-qopt-subscript-in-range
-qno-opt-subscript-in-range
Windows OS:
/Qopt-subscript-in-range
/Qopt-subscript-in-range-
Arguments
None
Default
-qno-opt-subscript-in-range The compiler assumes there are "large" integers being used or being
or /Qopt-subscript-in-range- computed within loops.
Description
This option determines whether the compiler assumes that there are no "large" integers being used or being
computed inside loops.
If you specify [q or Q]opt-subscript-in-range, the compiler assumes that there are no "large" integers
being used or being computed inside loops. A "large" integer is typically > 231.
This feature can enable more loop transformations.
IDE Equivalent
None
Alternate Options
None
Example
The following example shows how these options can be useful. Variable m is declared as type
integer(kind=8) (64-bits) and all other variables inside the subscript are declared as type integer(kind=4)
(32-bits):
A[ i + j + ( n + k) * m ]
qopt-zmm-usage, Qopt-zmm-usage
Defines a level of zmm registers usage.
Syntax
Linux OS:
-qopt-zmm-usage=keyword
macOS:
-qopt-zmm-usage=keyword
Windows OS:
/Qopt-zmm-usage:keyword
236
Compiler Reference
Arguments
keyword Specifies the level of zmm registers usage. Possible values are:
Default
Description
This option may provide better code optimization for Intel® processors that are on the Intel®
microarchitecture formerly code-named Skylake.
This option defines a level of zmm registers usage. The low setting causes the compiler to generate code
with zmm registers very carefully, only when the gain from their usage is proven. The high setting causes
the compiler to use much less restrictive heuristics for zmm code generation.
It is not always easy to predict whether the high or the low setting will yield better performance. Programs
that enjoy high performance gains from the use of xmm or ymm registers may expect performance
improvement by moving to use zmm registers. However, some programs that use zmm registers may not
gain as much or may even lose performance. We recommend that you try both option values to measure the
performance of your programs.
This option is ignored if you do not specify an option that enables Intel® AVX-512, such as [Q]xCORE-AVX512
or option [Q]xCOMMON-AVX512.
This option has no effect on loops that use directive SIMD SIMDLEN(n) or on functions that are generated by
vector specifications specific to CORE-AVX512.
IDE Equivalent
None
Alternate Options
None
See Also
x, Qx compiler option
SIMD Directive (OpenMP* API) clause SIMDLEN
qoverride-limits, Qoverride-limits
Lets you override certain internal compiler limits that
are intended to prevent excessive memory usage or
compile times for very large, complex compilation
units. This feature is only available for ifort.
237
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-qoverride-limits
macOS:
-qoverride-limits
Windows OS:
/Qoverride-limits
Arguments
None
Default
OFF Certain internal compiler limits are not overridden. These limits are determined by default
heuristics.
Description
This option provides a way to override certain internal compiler limits that are intended to prevent excessive
memory usage or compile times for very large, complex compilation units.
If this option is not used and your program exceeds one of these internal compiler limits, some optimizations
will be skipped to reduce the memory footprint and compile time. If you chose to create an optimization
report by specifying [q or Q]opt-report, you may see a related diagnostic remark as part of the report.
Specifying this option may substantially increase compile time and/or memory usage.
NOTE
If you use this option, it is your responsibility to ensure that sufficient memory is available.
If there is not sufficient available memory, the compilation may fail.
This option should only be used where there is a specific need; it is not recommended for
inexperienced users.
IDE Equivalent
None
Alternate Options
None
reentrancy
Tells the compiler to generate reentrant code to
support a multithreaded application.
Syntax
Linux OS:
-reentrancy keyword
-noreentrancy
238
Compiler Reference
macOS:
-reentrancy keyword
-noreentrancy
Windows OS:
/reentrancy:keyword
/noreentrancy
Arguments
none Tells the run-time library (RTL) that the program does not rely on
threaded or asynchronous reentrancy. The RTL will not guard against
such interrupts inside its own critical regions. This is the same as
specifying noreentrancy.
async Tells the run-time library (RTL) that the program may contain
asynchronous (AST) handlers that could call the RTL. This causes the
RTL to guard against AST interrupts inside its own critical regions.
threaded Tells the run-time library (RTL) that the program is multithreaded, such
as programs using the POSIX threads library. This causes the RTL to use
thread locking to guard its own critical regions.
Default
threaded The compiler tells the run-time library (RTL) that the program is multithreaded.
Description
This option tells the compiler to generate reentrant code to support a multithreaded application.
If you do not specify a keyword for reentrancy, it is the same as specifying reentrancy threaded.
To ensure that a threadsafe and/or reentrant run-time library is linked and correctly initialized, option
reentrancy threaded should also be used for the link step and for the compilation of the main routine.
Note that if option threads is specified, it sets option reentrancy threaded, since multithreaded code must
be reentrant.
IDE Equivalent
Windows
Visual Studio: Code Generation > Generate Reentrant Code
Alternate Options
None
See Also
threads compiler option
safe-cray-ptr, Qsafe-cray-ptr
Tells the compiler that Cray* pointers do not alias
other variables.
239
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-safe-cray-ptr
macOS:
-safe-cray-ptr
Windows OS:
/Qsafe-cray-ptr
Arguments
None
Default
OFF The compiler assumes that Cray pointers alias other variables.
Description
This option tells the compiler that Cray pointers do not alias (that is, do not specify sharing memory with)
other variables.
IDE Equivalent
Windows
Visual Studio: Data > Assume CRAY Pointers Do Not Share Memory Locations (/Qsafe-cray-ptr)
Alternate Options
None
Example
Consider the following:
pointer (pb, b)
pb = getstorage()
do i = 1, n
b(i) = a(i) + 1
enddo
By default, the compiler assumes that b and a are aliased. To prevent such an assumption, specify the
-safe-cray-ptr (Linux* and macOS*) or /Qsafe-cray-ptr (Windows*) option, and the compiler will treat
b(i) and a(i) as independent of each other.
However, if the variables are intended to be aliased with Cray pointers, using the option produces incorrect
results. In the following example, you should not use the option:
pointer (pb, b)
pb = loc(a(2))
do i=1, n
b(i) = a(i) +1
enddo
240
Compiler Reference
scalar-rep, Qscalar-rep
Enables or disables the scalar replacement
optimization done by the compiler as part of loop
transformations. This feature is only available for ifort.
Syntax
Linux OS:
-scalar-rep
-no-scalar-rep
macOS:
-scalar-rep
-no-scalar-rep
Windows OS:
/Qscalar-rep
/Qscalar-rep-
Arguments
None
Default
Description
This option enables or disables the scalar replacement optimization done by the compiler as part of loop
transformations. This option takes effect only if you specify an optimization level of O2 or higher.
IDE Equivalent
None
Alternate Options
None
See Also
O compiler option
simd, Qsimd
Enables or disables compiler interpretation of SIMD
directives.This feature is only available for ifort.
Syntax
Linux OS:
-simd
-no-simd
241
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
macOS:
-simd
-no-simd
Windows OS:
/Qsimd
/Qsimd-
Arguments
None
Default
Description
This option enables or disables compiler interpretation of SIMD directives.
To disable interpretation of SIMD directives, specify -no-simd (Linux* and macOS*) or /Qsimd-
(Windows*). Note that the compiler may still vectorize loops based on its own heuristics (leading to
generation of SIMD instructions) even when -no-simd (or /Qsimd-) is specified.
To disable all compiler vectorization, use the "-no-vec -no-simd" (Linux* and macOS*) or
"/Qvec- /Qsimd-" (Windows*) compiler options. The option -no-vec (and /Qvec-) disables all auto-
vectorization, including vectorization of array notation statements. The option -no-simd (and /Qsimd-)
disables vectorization of loops that have SIMD directives.
NOTE
If you specify option -mia32 (Linux*) or option /arch:IA32 (Windows*), SIMD directives are
disabled by default and vector instructions cannot be used. Therefore, you cannot explicitly
enable SIMD directives by specifying option [Q]simd.
IDE Equivalent
None
Alternate Options
None
See Also
vec, Qvec compiler option
SIMD Directive
unroll, Qunroll
Tells the compiler the maximum number of times to
unroll loops.
Syntax
Linux OS:
-unroll[=n]
242
Compiler Reference
macOS:
-unroll[=n]
Windows OS:
/Qunroll[:n]
Arguments
n Is the maximum number of times a loop can be unrolled. To disable loop enrolling, specify 0.
Default
Description
This option tells the compiler the maximum number of times to unroll loops.
If you do not specify n, the optimizer determines how many times loops can be unrolled.
IDE Equivalent
Windows
Visual Studio: Optimization > Loop Unroll Count
Alternate Options
Linux and macOS*: -funroll-loops
unroll-aggressive, Qunroll-aggressive
Determines whether the compiler uses more
aggressive unrolling for certain loops. This feature is
only available for ifort.
Syntax
Linux OS:
-unroll-aggressive
-no-unroll-aggressive
macOS:
-unroll-aggressive
-no-unroll-aggressive
Windows OS:
/Qunroll-aggressive
/Qunroll-aggressive-
Arguments
None
243
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
Description
This option determines whether the compiler uses more aggressive unrolling for certain loops. The positive
form of the option may improve performance.
This option enables aggressive, complete unrolling for loops with small constant trip counts.
IDE Equivalent
None
Alternate Options
None
vec, Qvec
Enables or disables vectorization.
Syntax
Linux OS:
-vec
-no-vec
macOS:
-vec
-no-vec
Windows OS:
/Qvec
/Qvec-
Arguments
None
Default
Description
This option enables or disables vectorization.
To disable vectorization, specify -no-vec (Linux* and macOS*) or /Qvec- (Windows*).
To disable interpretation of SIMD directives, specify -no-simd (Linux* and macOS*) or /Qsimd-
(Windows*).
244
Compiler Reference
To disable all compiler vectorization, use the "-no-vec -no-simd" (Linux* and macOS*) or
"/Qvec- /Qsimd-" (Windows*) compiler options. The option -no-vec (and /Qvec-) disables all auto-
vectorization, including vectorization of array notation statements. The option -no-simd (and /Qsimd-)
disables vectorization of loops that have SIMD directives.
NOTE
Using this option enables vectorization at default optimization levels for both Intel®
microprocessors and non-Intel microprocessors. Vectorization may call library routines that
can result in additional performance gain on Intel microprocessors than on non-Intel
microprocessors. The vectorization can also be affected by certain options, such as /arch
(Windows), -m (Linux and macOS*), or [Q]x.
IDE Equivalent
None
Alternate Options
None
See Also
simd, Qsimd compiler option
ax, Qax compiler option
x, Qx compiler option
vec-guard-write, Qvec-guard-write compiler option
vec-threshold, Qvec-threshold compiler option
vec-guard-write, Qvec-guard-write
Tells the compiler to perform a conditional check in a
vectorized loop. This feature is only available for ifort.
Syntax
Linux OS:
-vec-guard-write
-no-vec-guard-write
macOS:
-vec-guard-write
-no-vec-guard-write
Windows OS:
/Qvec-guard-write
/Qvec-guard-write-
Arguments
None
Default
245
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
or /Qvec-guard-write
Description
This option tells the compiler to perform a conditional check in a vectorized loop. This checking avoids
unnecessary stores and may improve performance.
IDE Equivalent
None
Alternate Options
None
vec-threshold, Qvec-threshold
Sets a threshold for the vectorization of loops.
Syntax
Linux OS:
-vec-threshold[n]
macOS:
-vec-threshold[n]
Windows OS:
/Qvec-threshold[[:]n]
Arguments
Default
Description
This option sets a threshold for the vectorization of loops based on the probability of profitable execution of
the vectorized loop in parallel.
This option is useful for loops whose computation work volume cannot be determined at compile-time. The
threshold is usually relevant when the loop trip count is unknown at compile-time.
246
Compiler Reference
The compiler applies a heuristic that tries to balance the overhead of creating multiple threads versus the
amount of work available to be shared amongst the threads.
IDE Equivalent
Windows
Visual Studio: Optimization > Threshold For Vectorization
Alternate Options
None
vecabi, Qvecabi
Determines which vector function application binary
interface (ABI) the compiler uses to create or call
vector functions. This feature is only available for ifort.
Syntax
Linux OS:
-vecabi=keyword
macOS:
-vecabi=keyword
Windows OS:
/Qvecabi:keyword
Arguments
keyword Specifies which vector function ABI to use. Possible values are:
gcc Tells the compiler to use the gcc vector function ABI.
Use this setting only in cases when you want to link
with modules compiled by gcc. This setting is not
available on Windows* systems.
legacy Tells the compiler to use the legacy vector function ABI.
Use this setting if you need to keep the generated
vector function binary backward compatible with the
vectorized binary generated by older versions of the
Intel® compilers (V13.1 or older).
247
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
Description
This option determines which vector function application binary interface (ABI) the compiler uses to create or
call vector functions.
NOTE
To avoid possible link-time and runtime errors, use identical [Q]vecabi settings when
compiling all files in an application that define or use vector functions, including libraries. If
setting cmdtarget is specified, options [Q]x and/or [Q]ax must have identical values.
Be careful using setting cmdtarget with libraries or program modules/routines with vector function
definitions that cannot be recompiled. In such cases, setting cmdtarget may cause link errors.
On Linux* systems, since the default is compat, you must specify legacy if you need to keep the generated
vector function binary backward compatible with the vectorized binary generated by the previous version of
Intel® compilers.
When cmdtarget is specified, the additional vector function versions are created by copying each vector
specification and changing target processor in the copy. The number of vector functions is determined by the
settings specified in options [Q]x and/or [Q]ax.
interface
integer function foo(a)
!dir$ attributes vector:(processor(core_2_duo_sse4_1)) :: foo
integer a
end function
end interface
and the following options are specified: -axAVX,CORE-AVX2
The following table shows the different results for the above declaration and option specifications when
setting compat or setting cmdtarget is used:
compat cmdtarget
One vector version is created for Intel® SSE4.1 (by Four vector versions are created for the following
vector function specification). targets:
• Intel® SSE2 (default because no -x option is
used)
• Intel® SSE4.1 (by vector function specification)
• Intel® AVX (by the first -ax option value)
• Intel® AVX2 (by the second -ax option value)
For more information about the Intel®-compatible vector functions ABI, see the downloadable PDF titled:
Vector Function Application Binary Interface, at https://software.intel.com/content/www/us/en/develop/
download/vector-simd-function-abi.html
For more information about the GCC vector functions ABI, see the item Libmvec - vector math library
document in the GLIBC wiki at sourceware.org.
248
Compiler Reference
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
IDE Equivalent
None
Alternate Options
None
finstrument-functions, Qinstrument-functions
Determines whether routine entry and exit points are
instrumented.
Syntax
Linux OS:
-finstrument-functions
-fno-instrument-functions
macOS:
-finstrument-functions
-fno-instrument-functions
Windows OS:
/Qinstrument-functions
/Qinstrument-functions-
Arguments
None
Default
Description
This option determines whether routine entry and exit points are instrumented. It may increase execution
time.
The following profiling functions are called with the address of the current routine and the address of where
the routine was called (its "call site"):
249
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IDE Equivalent
None
Alternate Options
None
fnsplit, Qfnsplit
Enables function splitting. This feature is only
available for ifort.
Syntax
Linux OS:
-fnsplit[=n]
-no-fnsplit
macOS:
None
Windows OS:
/Qfnsplit[:n]
/Qfnsplit-
Arguments
Default
250
Compiler Reference
Description
This option enables function splitting. If you specify [Q]fnsplit with no n, you must also specify option
[Q]prof-use, or the option will have no effect and no function splitting will occur.
If you specify n, function splitting is enabled and you do not need to specify option [Q]prof-use.
To disable function splitting when you use option [Q]prof-use, specify /Qfnsplit- (Windows*) or
-no-fnsplit (Linux*).
NOTE
Function splitting is generally not supported when exception handling is turned on for C/C+
+ routines in the stack of called routines. See also -fexceptions (Linux*).
IDE Equivalent
None
Alternate Options
Linux: -freorder-blocks-and-partition (a gcc option)
Windows: None
p
Compiles and links for function profiling with gprof(1).
Syntax
Linux OS:
-p
macOS:
-p
Windows OS:
None
Arguments
None
Default
Description
This option compiles and links for function profiling with gprof(1).
When you specify this option, inlining is disabled. However, you can override this by specifying directive
FORCEINLINE, or a compiler option such as [Q]inline-forceinline.
IDE Equivalent
None
251
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Alternate Options
Linux and macOS*: -pg,-qp (this is a deprecated option)
Windows: None
prof-data-order, Qprof-data-order
Enables or disables data ordering if profiling
information is enabled. This feature is only available
for ifort.
Syntax
Linux OS:
-prof-data-order
-no-prof-data-order
macOS:
None
Windows OS:
/Qprof-data-order
/Qprof-data-order-
Arguments
None
Default
Description
This option enables or disables data ordering if profiling information is enabled. It controls the use of profiling
information to order static program data items.
For this option to be effective, you must do the following:
• For instrumentation compilation, you must specify option [Q]prof-gen setting globdata.
• For feedback compilation, you must specify the [Q]prof-use option. You must not use multi-file
optimization by specifying options such as [Q]ipo or [Q]ipo-c.
IDE Equivalent
None
Alternate Options
None
See Also
prof-gen, Qprof-gen compiler option
prof-use, Qprof-use compiler option
prof-func-order, Qprof-func-order compiler option
252
Compiler Reference
prof-dir, Qprof-dir
Specifies a directory for profiling information output
files. This feature is only available for ifort.
Syntax
Linux OS:
-prof-dir dir
macOS:
-prof-dir dir
Windows OS:
/Qprof-dir:dir
Arguments
dir Is the name of the directory. You can specify a relative pathname or
an absolute pathname.
Default
OFF Profiling output files are placed in the directory where the program is compiled.
Description
This option specifies a directory for profiling information output files (*.dyn and *.dpi). The specified
directory must already exist.
You should specify this option using the same directory name for both instrumentation and feedback
compilations. If you move the .dyn files, you need to specify the new path.
Option /Qprof-dir is equivalent to option /Qcov-dir. If you specify both options, the last option specified
on the command line takes precedence.
IDE Equivalent
Windows
Visual Studio: Output Files > Profile Directory
Alternate Options
None
prof-file, Qprof-file
Specifies an alternate file name for the profiling
summary files. This feature is only available for ifort.
Syntax
Linux OS:
-prof-file filename
macOS:
-prof-file filename
253
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows OS:
/Qprof-file:filename
Arguments
Default
OFF The profiling summary files have the file name pgopti.*
Description
This option specifies an alternate file name for the profiling summary files. The filename is used as the base
name for files created by different profiling passes.
If you add this option to profmerge, the .dpi file will be named filename.dpi instead of pgopti.dpi.
If you specify this option with option [Q]prof-use, the .dpi file will be named filename.dpi instead of
pgopti.dpi.
Option /Qprof-file is equivalent to option /Qcov-file. If you specify both options, the last option
specified on the command line takes precedence.
NOTE
When you use option [Q]prof-file, you can only specify a file name. If you want to specify
a path (relative or absolute) for filename, you must also use option [Q]prof-dir.
IDE Equivalent
None
Alternate Options
None
See Also
prof-gen, Qprof-gen compiler option
prof-use, Qprof-use compiler option
prof-dir, Qprof-dir compiler option
prof-func-groups
Enables or disables function grouping if profiling
information is enabled. This feature is only available
for ifort.
Syntax
Linux OS:
-prof-func-groups
-no-prof-func-groups
macOS:
None
254
Compiler Reference
Windows OS:
None
Arguments
None
Default
Description
This option enables or disables function grouping if profiling information is enabled.
A "function grouping" is a profiling optimization in which entire routines are placed either in the cold code
section or the hot code section.
If profiling information is enabled by option -prof-use, option -prof-func-groups is set and function
grouping is enabled. However, if you explicitly enable -prof-func-order, function ordering is performed
instead of function grouping.
If you want to disable function grouping when profiling information is enabled, specify
-no-prof-func-groups.
To set the hotness threshold for function grouping, use option -prof-hotness-threshold.
IDE Equivalent
None
See Also
prof-use, Qprof-use compiler option
prof-func-order, Qprof-func-order
compiler option
prof-hotness-threshold, Qprof-hotness-threshold
compiler option
prof-func-order, Qprof-func-order
Enables or disables function ordering if profiling
information is enabled. This feature is only available
for ifort.
Syntax
Linux OS:
-prof-func-order
-no-prof-func-order
macOS:
None
Windows OS:
/Qprof-func-order
/Qprof-func-order-
255
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Arguments
None
Default
Description
This option enables or disables function ordering if profiling information is enabled.
For this option to be effective, you must do the following:
• For instrumentation compilation, you must specify option [Q]prof-gen setting srcpos.
• For feedback compilation, you must specify [Q]prof-use. You must not use multi-file optimization by
specifying options such as [Q]ipo or [Q]ipo-c.
If you enable profiling information by specifying option [Q]prof-use, option [Q]prof-func-groups is set
and function grouping is enabled. However, if you explicitly enable the [Q]prof-func-order option, function
ordering is performed instead of function grouping.
On Linux* systems, this option is only available for Linux linker 2.15.94.0.1, or later.
To set the hotness threshold for function grouping and function ordering, use option
[Q]prof-hotness-threshold.
IDE Equivalent
None
Alternate Options
None
Example
The following example shows how to use this option on a Windows system:
See Also
prof-hotness-threshold, Qprof-hotness-threshold compiler option
prof-gen, Qprof-gen compiler option
prof-use, Qprof-use compiler option
prof-data-order, Qprof-data-order compiler option
prof-func-groups compiler option
prof-gen, Qprof-gen
Produces an instrumented object file that can be used
in profile guided optimization. This feature is only
available for ifort.
256
Compiler Reference
Syntax
Linux OS:
-prof-gen[=keyword[, keyword],...]
-no-prof-gen
macOS:
-prof-gen[=keyword[, keyword],...]
-no-prof-gen
Windows OS:
/Qprof-gen[:keyword[,keyword],...]
/Qprof-gen-
Arguments
keyword Specifies details for the instrumented file. Possible values are:
Default
Description
This option produces an instrumented object file that can be used in profile guided optimization. It gets the
execution count of each basic block.
You can specify more than one setting for [Q]prof-gen. For example, you can specify the following:
257
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
When the [Q]prof-gen option is used to produce an instrumented binary file for profile generation, some
optimizations are disabled. Those optimizations are not disabled for any subsequent profile-guided
compilation with option [Q]prof-use that makes use of the generated profiles.
IDE Equivalent
None
Alternate Options
None
See Also
prof-use, Qprof-use compiler option
Profile an Application with Instrumentation
prof-gen-sampling
Tells the compiler to generate debug discriminators in
debug output. This aids in developing more precise
sampled profiling output. This option is deprecated
and will be removed in a future release. This feature is
only available for ifort.
Syntax
Linux OS:
-prof-gen-sampling
macOS:
None
Windows OS:
None
Arguments
None
Default
OFF The compiler does not generate debug discriminators in the debug
output.
Description
This option tells the compiler to generate debug discriminators in debug output. Debug discriminators are
used to distinguish code from different basic blocks that have the same source position information. This aids
in developing more precise sampled hardware profiling output.
To build an executable suitable for generating hardware profiled sampled output, compile with the following
options:
-prof-gen-sampling -g
To use the data files produced by hardware profiling, compile with option -prof-use-sampling.
IDE Equivalent
None
258
Compiler Reference
Alternate Options
None
See Also
prof-use-sampling compiler option
g compiler option
Profile an Application with Instrumentation
prof-hotness-threshold, Qprof-hotness-threshold
Lets you set the hotness threshold for function
grouping and function ordering. This feature is only
available for ifort.
Syntax
Linux OS:
-prof-hotness-threshold=n
macOS:
None
Windows OS:
/Qprof-hotness-threshold:n
Arguments
Default
OFF The compiler's default hotness threshold setting of 10 percent is in effect for function
grouping and function ordering.
Description
This option lets you set the hotness threshold for function grouping and function ordering.
The "hotness threshold" is the percentage of functions in the application that should be placed in the
application's hot region. The hot region is the most frequently executed part of the application. By grouping
these functions together into one hot region, they have a greater probability of remaining resident in the
instruction cache. This can enhance the application's performance.
For this option to take effect, you must specify option [Q]prof-use and one of the following:
IDE Equivalent
None
Alternate Options
None
259
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
prof-use, Qprof-use compiler option
prof-func-groups compiler option
prof-func-order, Qprof-func-order compiler option
prof-src-dir, Qprof-src-dir
Determines whether directory information of the
source file under compilation is considered when
looking up profile data records. This feature is only
available for ifort.
Syntax
Linux OS:
-prof-src-dir
-no-prof-src-dir
macOS:
-prof-src-dir
-no-prof-src-dir
Windows OS:
/Qprof-src-dir
/Qprof-src-dir-
Arguments
None
Default
Description
This option determines whether directory information of the source file under compilation is considered when
looking up profile data records in the .dpi file. To use this option, you must also specify the [Q]prof-use
option.
If the option is enabled, directory information is considered when looking up the profile data records within
the .dpi file. You can specify directory information by using one of the following options:
IDE Equivalent
None
260
Compiler Reference
Alternate Options
None
See Also
prof-use, Qprof-use compiler option
prof-src-root, Qprof-src-root compiler option
prof-src-root-cwd, Qprof-src-root-cwd compiler option
prof-src-root, Qprof-src-root
Lets you use relative directory paths when looking up
profile data and specifies a directory as the base. This
feature is only available for ifort.
Syntax
Linux OS:
-prof-src-root=dir
macOS:
-prof-src-root=dir
Windows OS:
/Qprof-src-root:dir
Arguments
Default
OFF The setting of relevant options determines the path used when looking up profile data records.
Description
This option lets you use relative directory paths when looking up profile data in .dpi files. It lets you specify a
directory as the base. The paths are relative to a base directory specified during the [Q]prof-gen
compilation phase.
This option is available during the following phases of compilation:
To be effective, this option or option [Q]prof-src-root-cwd must be specified during the [Q]prof-gen
phase. In addition, if one of these options is not specified, absolute paths are used in the .dpi file.
IDE Equivalent
None
261
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Alternate Options
None
Example
Consider the initial [Q]prof-gen compilation of the source file c:\user1\feature_foo\myproject\common
\glob.f90 shown below:
See Also
prof-gen, Qprof-gen compiler option
prof-use, Qprof-use compiler option
prof-src-dir, Qprof-src-dir compiler option
prof-src-root-cwd, Qprof-src-root-cwd compiler option
prof-src-root-cwd, Qprof-src-root-cwd
Lets you use relative directory paths when looking up
profile data and specifies the current working directory
as the base. This feature is only available for ifort.
Syntax
Linux OS:
-prof-src-root-cwd
macOS:
-prof-src-root-cwd
Windows OS:
/Qprof-src-root-cwd
Arguments
None
Default
OFF The setting of relevant options determines the path used when looking up profile data records.
262
Compiler Reference
Description
This option lets you use relative directory paths when looking up profile data in .dpi files. It specifies the
current working directory as the base. To use this option, you must also specify option [Q]prof-use.
To be effective, this option or option [Q]prof-src-root must be specified during the [Q]prof-gen phase.
In addition, if one of these options is not specified, absolute paths are used in the .dpi file.
IDE Equivalent
None
Alternate Options
None
See Also
prof-gen, Qprof-gen compiler option
prof-use, Qprof-use compiler option
prof-src-dir, Qprof-src-dir compiler option
prof-src-root, Qprof-src-root compiler option
prof-use, Qprof-use
Enables the use of profiling information during
optimization. This feature is only available for ifort.
Syntax
Linux OS:
-prof-use[=keyword]
-no-prof-use
macOS:
-prof-use[=keyword]
-no-prof-use
Windows OS:
/Qprof-use[:keyword]
/Qprof-use-
Arguments
263
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
Description
This option enables the use of profiling information (including function splitting and function grouping) during
optimization. It enables option /Qfnsplit (Windows*) and -fnsplit (Linux* and macOS*) .
This option instructs the compiler to produce a profile-optimized executable and it merges available profiling
output files into a pgopti.dpi file.
Note that there is no way to turn off function grouping if you enable it using this option.
To set the hotness threshold for function grouping and function ordering, use option
[Q]prof-hotness-threshold.
IDE Equivalent
None
Alternate Options
None
See Also
prof-hotness-threshold, Qprof-hotness-threshold compiler option
prof-gen, Qprof-gen compiler option
Profile an Application with Instrumentation
prof-use-sampling
Lets you use data files produced by hardware profiling
to produce an optimized executable. This option is
deprecated and will be removed in a future release.
This feature is only available for ifort.
264
Compiler Reference
Syntax
Linux OS:
-prof-use-sampling=list
macOS:
None
Windows OS:
None
Arguments
list Is a list of one or more data files. If you specify more than one data
file, they must be separated by colons.
Default
OFF Data files produced by hardware profiling will not be used to produce
an optimized executable.
Description
This option lets you use data files produced by hardware profiling to produce an optimized executable.
These data files are named and produced by using Intel® VTune™.
The executable should have been produced using the following options:
-prof-gen-sampling -g
IDE Equivalent
None
Alternate Options
None
See Also
prof-gen-sampling compiler option
Profile an Application with Instrumentation
prof-value-profiling, Qprof-value-profiling
Controls which values are value profiled. This feature
is only available for ifort.
Syntax
Linux OS:
-prof-value-profiling[=keyword]
macOS:
-prof-value-profiling[=keyword]
Windows OS:
/Qprof-value-profiling[:keyword]
265
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Arguments
keyword Controls which type of value profiling is performed. Possible values are:
You can specify more than one keyword, but they must be separated by commas.
Default
all All value profile types are enabled and value profiling is performed.
Description
This option controls which features are value profiled.
If this option is specified with option [Q]prof-gen, it turns off instrumentation of operations of the specified
type. This also prevents feedback of values for the operations.
If this option is specified with option [Q]prof-use, it turns off feedback of values collected of the specified
type.
If you specify level 2 or higher for option[q or Q]opt-report, the value profiling specialization information
will be reported within the PGO optimization report.
IDE Equivalent
None
Alternate Options
None
See Also
prof-gen, Qprof-gen compiler option
prof-use, Qprof-use compiler option
qopt-report, Qopt-report compiler option
Qcov-dir
Specifies a directory for profiling information output
files that can be used with the codecov or tselect tool.
This feature is only available for ifort.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/Qcov-dir:dir
266
Compiler Reference
Arguments
Default
OFF Profiling output files are placed in the directory where the program is compiled.
Description
This option specifies a directory for profiling information output files (*.dyn and *.dpi) that can be used with
the code-coverage tool (codecov) or the test prioritization tool (tselect). The specified directory must already
exist.
You should specify this option using the same directory name for both instrumentation and feedback
compilations. If you move the .dyn files, you need to specify the new path.
Option /Qcov-dir is equivalent to option /Qprof-dir. If you specify both options, the last option specified
on the command line takes precedence.
IDE Equivalent
None
Alternate Options
None
See Also
Qcov-gen compiler option
Qcov-file compiler option
Qcov-file
Specifies an alternate file name for the profiling
summary files that can be used with the codecov or
tselect tool. This feature is only available for ifort.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/Qcov-file:filename
Arguments
Default
OFF The profiling summary files have the file name pgopti.*.
267
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
This option specifies an alternate file name for the profiling summary files. The file name can be used with
the code-coverage tool (codecov) or the test prioritization tool (tselect).
The filename is used as the base name for the set of files created by different profiling passes.
If you specify this option with option /Qcov-gen, the .spi and .spl files will be named filename.spi and
filename.spl instead of pgopti.spi and pgopti.spl.
Option /Qcov-file is equivalent to option /Qprof-file. If you specify both options, the last option
specified on the command line takes precedence.
IDE Equivalent
None
Alternate Options
None
See Also
Qcov-gen compiler option
Qcov-dir compiler option
Qcov-gen
Produces an instrumented object file that can be used
with the codecov or tselect tool. This feature is only
available for ifort.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/Qcov-gen
/Qcov-gen-
Arguments
None
Default
Description
This option produces an instrumented object file that can be used with the code-coverage tool (codecov) or
the test prioritization tool (tselect). The instrumented code is included in the object file in preparation for
instrumented execution.
This option also creates a static profile information file (.spi) that can be used with the codecov or tselect
tool.
268
Compiler Reference
Option /Qcov-gen should be used to minimize the instrumentation overhead if you are interested in using
the instrumentation only for code coverage. You should use /Qprof-gen:srcpos if you intend to use the
collected data for code coverage and profile feedback.
IDE Equivalent
None
Alternate Options
None
See Also
Qcov-dir compiler option
Qcov-file compiler option
qopt-report, Qopt-report
Tells the compiler to generate an optimization report.
This feature is only available for ifort.
Syntax
Linux OS:
-qopt-report[=n]
macOS:
-qopt-report[=n]
Windows OS:
/Qopt-report[:n]
Arguments
n (Optional) Indicates the level of detail in the report. You can specify
values 0 through 5.
If you specify zero, no report is generated.
For levels n=1 through n=5, each level includes all the information of
the previous level, as well as potentially some additional information.
Level 5 produces the greatest level of detail. If you do not specify n,
the default is level 2, which produces a medium level of detail.
Default
Description
This option tells the compiler to generate a collection of optimization report files, one per object; this is the
same output produced by option [q or Q]opt-report-per-object.
If you prefer another form of output, you can specify option [q or Q]opt-report-file.
If you specify a level (n) higher than 5, a warning will be displayed and you will get a level 5 report.
269
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
For a description of the information that each n level provides, see the Example section in option
[q or Q]opt-report-phase.
IDE Equivalent
Visual Studio
Visual Studio: Diagnostics > Optimization Diagnostic Level
Alternate Options
None
Example
If you only want reports about certain diagnostics, you can use this option with option
[q or Q]opt-report-phase. The phase you specify determines which diagnostics you will receive.
For example, the following examples show how to get reports about certain specific diagnostics.
See Also
qopt-report-file, Qopt-report-file compiler option
qopt-report-per-object, Qopt-report-per-object compiler option
qopt-report-phase, Qopt-report-phase compiler option
qopt-report-annotate, Qopt-report-annotate
Enables the annotated source listing feature and
specifies its format. This feature is only available for
ifort.
Syntax
Linux OS:
-qopt-report-annotate[=keyword]
macOS:
-qopt-report-annotate[=keyword]
270
Compiler Reference
Windows OS:
/Qopt-report-annotate[:keyword]
Arguments
keyword Specifies the format for the annotated source listing. You can specify one of the following:
text Indicates that the listing should be in text format. This is the default if you do not
specify keyword.
Default
Description
This option enables the annotated source listing feature and specifies its format. The feature annotates
source files with compiler optimization reports.
By default, one annotated source file is output per object. The annotated file is written to the same directory
where the object files are generated. If the object file is a temporary file and an executable is generated,
annotated files are placed in the directory where the executable is placed. You cannot generate annotated
files to a directory of your choosing.
However, you can output annotated listings to stdout, stderr, or to a file if you also specify option
[q or Q]opt-report-file.
By default, this option sets option [q or Q]opt-report with default level 2.
The following shows the file extension and listing details for the two possible keywords.
text The annotated source listing has an .annot extension. It includes line numbers and
compiler diagnostics placed after correspondent lines. IPO footnotes are inserted at
the end of annotated file.
html The annotated source listing has an .annot.html extension. It includes line numbers
and compiler diagnostics placed after correspondent lines (as the text format does).
It also provides hyperlinks in compiler messages and quick navigation with the
routine list. IPO footnotes are displayed as tooltips.
IDE Equivalent
None
Alternate Options
None
See Also
qopt-report, Qopt-report compiler option
qopt-report-file, Qopt-report-file compiler option
qopt-report-annotate-position, Qopt-report-annotate-position compiler option
271
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
qopt-report-annotate-position, Qopt-report-annotate-position
Enables the annotated source listing feature and
specifies the site where optimization messages appear
in the annotated source in inlined cases of loop
optimizations. This feature is only available for ifort.
Syntax
Linux OS:
-qopt-report-annotate-position=keyword
macOS:
-qopt-report-annotate-position=keyword
Windows OS:
/Qopt-report-annotate-position:keyword
Arguments
keyword Specifies the site where optimization messages appear in the annotated source. You can specify
one of the following:
caller Indicates that the messages should appear in the caller site.
callee Indicates that the messages should appear in the callee site.
both Indicates that the messages should appear in both the caller and the callee sites.
Default
Description
This option enables the annotated source listing feature and specifies the site where optimization messages
appear in the annotated source in inlined cases of loop optimizations.
This option enables option [q or Q]opt-report-annotate if it is not explicitly specified.
If annotated source listing is enabled and this option is not passed to compiler, loop optimizations are placed
in caller position by default.
IDE Equivalent
None
Alternate Options
None
See Also
qopt-report, Qopt-report compiler option
qopt-report-annotate, Qopt-report-annotate compiler option
272
Compiler Reference
qopt-report-embed, Qopt-report-embed
Determines whether special loop information
annotations will be embedded in the object file and/or
the assembly file when it is generated. This feature is
only available for ifort.
Syntax
Linux OS:
-qopt-report-embed
-qno-opt-report-embed
macOS:
-qopt-report-embed
-qno-opt-report-embed
Windows OS:
/Qopt-report-embed
/Qopt-report-embed-
Arguments
None
Default
OFF When an assembly file is being generated, special loop information annotations will not be
embedded in the assembly file.
However, if option -g (Linux* and macOS*) or /Zi (Windows*) is specified, special loop
information annotations will be embedded in the assembly file unless option
-qno-opt-report-embed (Linux and macOS*) or /Qopt-report-embed- (Windows) is
specified.
Description
This option determines whether special loop information annotations will be embedded in the object file
and/or the assembly file when it is generated. Specify the positive form of the option to include the
annotations in the assembly file.
If an object file (or executable) is being generated, the annotations will be embedded in the object file (or
executable).
If you use this option, you do not have to specify option [q or Q]opt-report.
Alternate Options
None
See Also
qopt-report, Qopt-report compiler option
qopt-report-file, Qopt-report-file
Specifies that the output for the optimization report
goes to a file, stderr, or stdout. This feature is only
available for ifort.
273
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-qopt-report-file=keyword
macOS:
-qopt-report-file=keyword
Windows OS:
/Qopt-report-file:keyword
Arguments
keyword Specifies the output for the report. You can specify one of the following:
filename Specifies the name of the file where the output should go.
Default
Description
This option specifies that the output for the optimization report goes to a file, stderr, or stdout.
If you use this option, you do not have to specify option [q or Q]opt-report.
When optimization reporting is enabled, the default is -qopt-report-phase=all (Linux* and macOS*)
or /Qopt-report-phase:all (Windows*).
IDE Equivalent
Visual Studio
Visual Studio: Diagnostics > Emit Optimization Diagnostics to File
Diagnostics > Optimization Diagnostic File
Alternate Options
None
See Also
qopt-report, Qopt-report compiler option
qopt-report-filter, Qopt-report-filter
Tells the compiler to find the indicated parts of your
application, and generate optimization reports for
those parts of your application. This feature is only
available for ifort.
Syntax
Linux OS:
-qopt-report-filter=string
274
Compiler Reference
macOS:
-qopt-report-filter=string
Windows OS:
/Qopt-report-filter:string
Arguments
string Is the information to search for. The string must appear within quotes. It can take one or
more of the following forms:
filename
filename, routine
filename, range [, range]...
filename, routine, range [, range]...
If you specify more than one of the above forms in a string, a semicolon must appear
between each form. If you specify more than one range in a string, a comma must appear
between each range. Optional blanks can follow each parameter in the forms above and
they can also follow each form in a string.
Default
Description
This option tells the compiler to find the indicated parts of your application, and generate optimization
reports for those parts of your application. Optimization reports will only be generated for the routines that
contain the specified string.
275
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If you use this option, you do not have to specify option [q or Q]opt-report.
When optimization reporting is enabled, the default is -qopt-report-phase=all (Linux* and macOS*)
or /Qopt-report-phase:all (Windows*).
IDE Equivalent
None
Alternate Options
None
See Also
qopt-report, Qopt-report compiler option
qopt-report-format, Qopt-report-format
Specifies the format for an optimization report. This
feature is only available for ifort.
Syntax
Linux OS:
-qopt-report-format=keyword
macOS:
-qopt-report-format=keyword
Windows OS:
/Qopt-report-format:keyword
Arguments
keyword Specifies the format for the report. You can specify one of the following:
vs Indicates that the report should be in Visual Studio* (IDE) format. The Visual Studio
IDE uses the information to visualize the optimization report in the context of your
program source code.
Default
Description
This option specifies the format for an optimization report. If you use this option, you must specify either
text or vs.
If you do not specify this option and another option causes an optimization report to be generated, the
default format is text.
If the [q or Q]opt-report-file option is also specified, it will affect where the output goes:
276
Compiler Reference
When optimization reporting is enabled, the default is -qopt-report-phase=all (Linux* and macOS*)
or /Qopt-report-phase:all (Windows*).
IDE Equivalent
None
Alternate Options
None
See Also
qopt-report, Qopt-report compiler option
qopt-report-file, Qopt-report-file compiler option
qopt-report-help, Qopt-report-help
Displays the optimizer phases available for report
generation and a short description of what is reported
at each level. This feature is only available for ifort.
Syntax
Linux OS:
-qopt-report-help
Windows OS:
/Qopt-report-help
Arguments
None
Default
Description
This option displays the optimizer phases available for report generation using [q or Q]opt-report-phase,
and a short description of what is reported at each level. No compilation is performed.
To indicate where output should go, you can specify one of the following options:
• [q or Q]opt-report-file
• [q or Q]opt-report-per-object
If you use this option, you do not have to specify option [q or Q]opt-report.
IDE Equivalent
None
277
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Alternate Options
None
See Also
qopt-report, Qopt-report compiler option
qopt-report-phase, Qopt-report-phase compiler option
qopt-report-file, Qopt-report-file compiler option
qopt-report-per-object, Qopt-report-per-object compiler option
qopt-report-per-object, Qopt-report-per-object
Tells the compiler that optimization report information
should be generated in a separate file for each object.
This feature is only available for ifort.
Syntax
Linux OS:
-qopt-report-per-object
macOS:
-qopt-report-per-object
Windows OS:
/Qopt-report-per-object
Arguments
None
Default
Description
This option tells the compiler that optimization report information should be generated in a separate file for
each object.
If you specify this option for a single-file compilation, a file with a .optrpt extension is produced for every
object file or assembly file that is generated by the compiler. For a multifile Interprocedural Optimization
(IPO) compilation, one file is produced for each of the N true objects generated in the compilation. If only
one true object file is generated, the optimization report file generated is called ipo_out.optrpt. If multiple
true object files are generated (N>1), the names used are ipo_out1.optprt, ipo_out2.optrpt, …
ipo_outN.optrpt.
The .optrpt files are written to the target directory of the compilation process. If an object or assembly file is
explicitly generated, the corresponding .optrpt file is written to the same directory where the object file is
generated. If the object file is just a temporary file and an executable is generated, the corresponding .optrpt
files are placed in the directory in which the executable is placed.
If you use this option, you do not have to specify option [q or Q]opt-report.
IDE Equivalent
None
278
Compiler Reference
Alternate Options
None
See Also
qopt-report, Qopt-report compiler option
qopt-report-phase, Qopt-report-phase
Specifies one or more optimizer phases for which
optimization reports are generated. This feature is
only available for ifort.
Syntax
Linux OS:
-qopt-report-phase[=list]
macOS:
-qopt-report-phase[=list]
Windows OS:
/Qopt-report-phase[:list]
Arguments
list (Optional) Specifies one or more phases to generate reports for. If you
specify more than one phase, they must be separated with commas.
The values you can specify are:
Default
Description
This option specifies one or more optimizer phases for which optimization reports are generated.
For certain phases, you also need to specify other options:
• If you specify phase cg, you must also specify option O1, O2 (default), or O3.
279
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• If you specify phase ipo, you must also specify option [Q]ipo.
• If you specify phase loop, you must also specify option O2 (default) or O3.
• If you specify phase openmp, you must also specify option [q or Q]openmp.
• If you specify phase par, you must also specify option [Q]parallel.
• If you specify phase pgo, you must also specify option [Q]prof-use.
• If you specify phase tcollect, you must also specify option [Q]tcollect.
• If you specify phase vec, you must also specify option O2 (default) or O3. If you are interested in explicit
vectorization by OpenMP* SIMD, you must also specify option [q or Q]openmp.
If you use this option, you do not have to specify option [q or Q]opt-report.
However, if you want to get more details for each phase, specify option [q or Q]opt-report=n along with
this option and indicate the level of detail you want by specifying an appropriate value for n. (See also the
Example section below.)
When optimization reporting is enabled, the default is -qopt-report-phase=all (Linux* or macOS*)
or /Qopt-report-phase:all (Windows*).
IDE Equivalent
Visual Studio
Visual Studio: Diagnostics > Optimization Diagnostic Phase
Alternate Options
None
Example
The following shows examples of the details you may receive when you specify one of the optimizer phases
and a particular level (n) for option [q or Q]opt-report. Note that details may change in future releases.
280
Compiler Reference
281
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
qopt-report, Qopt-report compiler option
qopt-report-help, Qopt-report-help compiler option
282
Compiler Reference
qopt-report-routine, Qopt-report-routine
Tells the compiler to generate an optimization report
for each of the routines whose names contain the
specified substring. This feature is only available for
ifort.
Syntax
Linux OS:
-qopt-report-routine=substring
macOS:
-qopt-report-routine=substring
Windows OS:
/Qopt-report-routine:substring
Arguments
Default
Description
This option tells the compiler to generate an optimization report for each of the routines whose names
contain the specified substring.
You can also specify a sequence of substrings separated by commas. If you do this, the compiler will
generate an optimization report for each of the routines whose name contains one or more of these
substrings.
If you use this option, you do not have to specify option [q or Q]opt-report.
When optimization reporting is enabled, the default is -qopt-report-phase=all (Linux* and macOS*)
or /Qopt-report-phase:all (Windows*).
IDE Equivalent
Visual Studio
Visual Studio: Diagnostics > Optimization Diagnostic Routine
Alternate Options
None
See Also
qopt-report, Qopt-report compiler option
qopt-report-names, Qopt-report-names
Specifies whether mangled or unmangled names
should appear in the optimization report. This feature
is only available for ifort.
283
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-qopt-report-names=keyword
macOS:
-qopt-report-names=keyword
Windows OS:
/Qopt-report-names:keyword
Arguments
keyword Specifies the form for the names. You can specify one of the following:
Default
Description
This option specifies whether mangled or unmangled names should appear in the optimization report. If you
use this option, you must specify either mangled or unmangled.
When optimization reporting is enabled, the default is -qopt-report-phase=all (Linux* and macOS*)
or /Qopt-report-phase:all (Windows*).
IDE Equivalent
None
Alternate Options
None
See Also
qopt-report, Qopt-report compiler option
tcollect, Qtcollect
Inserts instrumentation probes calling the Intel® Trace
Collector API. This feature is only available for ifort.
284
Compiler Reference
Syntax
Linux OS:
-tcollect[lib]
macOS:
None
Windows OS:
/Qtcollect[:lib]
Arguments
lib Is one of the Intel® Trace Collector libraries; for example, VT, VTcs,
VTmc, or VTfs. If you do not specify lib, the default library is VT.
Default
Description
This option inserts instrumentation probes calling the Intel® Trace Collector API.
This trace analyzing/collecting feature requires installation of another product. For more information, see
Feature Requirements.
This option provides a flexible and convenient way of instrumenting functions of a compiled application. For
every function, the entry and exit points are instrumented at compile time to let the Intel® Trace Collector
record functions beyond the default MPI calls. For non-MPI applications (for example, threaded or serial), you
must ensure that the Intel® Trace Collector is properly initialized (VT_initialize/VT_init).
Caution
Be careful with full instrumentation because this feature can produce very large trace files.
IDE Equivalent
None
Alternate Options
None
See Also
tcollect-filter, Qtcollect-filter compiler option
tcollect-filter, Qtcollect-filter
Lets you enable or disable the instrumentation of
specified functions. You must also specify option
[Q]tcollect. This feature is only available for ifort.
Syntax
Linux OS:
-tcollect-filter filename
285
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
macOS:
None
Windows OS:
/Qtcollect-filter:filename
Arguments
filename Is a configuration file that lists filters, one per line. Each filter consists
of a regular expression string and a switch. Strings with leading or
trailing white spaces must be quoted. Other strings do not have to be
quoted. The switch value can be ON, on, OFF, or off.
Default
OFF Functions are not instrumented. However, if option -tcollect (Linux) or /Qtcollect (Windows)
is specified, the filter setting is ".* ON" and all functions get instrumented.
Description
This option lets you enable or disable the instrumentation of specified functions.
To get instrumentation with a specified filter (or filters), you must specify both option [Q]tcollect and
option [Q]tcollect-filter.
During instrumentation, the regular expressions in the file are matched against the function names. The
switch specifies whether matching functions are to be instrumented or not. Multiple filters are evaluated from
top to bottom with increasing precedence.
The names of the functions to match against are formatted as follows:
• The source file name is followed by a colon-separated function name. Source file names should contain
the full path, if available. For example:
/home/joe/src/file.f:FOO_bar
• Classes and function names are separated by double colons. For example:
/home/joe/src/file.fpp:app::foo::bar
You can use option [q or Q]opt-report to get a full list of file and function names that the compiler
recognizes from the compilation unit. This list can be used as the basis for filtering in the configuration file.
This trace analyzing/collecting feature requires installation of another product. For more information, see
Feature Requirements.
IDE Equivalent
None
Alternate Options
None
Consider the following filters in a configuration file:
286
Compiler Reference
To get a list of the file or routine strings that can be matched by the regular expression filters, generate an
optimization report with tcollect information. For example:
See Also
tcollect, Qtcollect compiler option
qopt-report, Qopt-report compiler option
device-math-lib
Enables or disables certain device libraries. This is a
deprecated option that may be removed in a future
release.
Syntax
Linux OS:
-device-math-lib=library
-no-device-math-lib=library
macOS:
None
Windows OS:
/device-math-lib:library
/no-device-math-lib:library
Arguments
To link more than one library, include a comma between the library names.
For example, if you want to link both the fp32 and fp64 device libraries, specify: fp32,
fp64
Default
fp32, fp64 Both the fp32 and fp64 device libraries are linked.
Description
This option enables or disables certain device libraries.
IDE Equivalent
None
287
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Alternate Options
None
See Also
fopenmp-device-lib compiler option
fmpc-privatize
Enables or disables privatization of all static data for
the MultiProcessor Computing environment (MPC)
unified parallel runtime. This feature is only available
for ifort.
Architecture Restrictions
Only available on Intel® 64 architecture
Syntax
Linux OS:
-fmpc-privatize
-fno-mpc-privatize
macOS:
None
Windows OS:
None
Arguments
None
Default
-fno-mpc-privatize The privatization of all static data for the MPC unified parallel runtime
is disabled.
Description
This option enables or disables privatization of all static data for the MultiProcessor Computing environment
(MPC) unified parallel runtime.
Option -fmpc-privatize causes calls to extended thread-local-storage (TLS) resolution, run-time routines
that are not supported on standard Linux* distributions.
This option requires installation of another product. For more information, see Feature Requirements.
IDE Equivalent
None
Alternate Options
None
fopenmp
Option -fopenmp is a deprecated option that will be
removed in a future release.
288
Compiler Reference
Syntax
Linux OS:
-fopenmp
macOS:
None
Windows OS:
None
Arguments
None
Default
Description
Enables recognition of OpenMP* features and tells the parallelizer to generate multi-threaded code based on
OpenMP* directives.
Option -fopenmp is a deprecated option that will be removed in a future release. For most users, we
recommend that you instead use option qopenmp, Qopenmp.
IDE Equivalent
None
Alternate Options
None
fopenmp-device-lib
Enables or disables certain device libraries for an
OpenMP* target.
Syntax
Linux OS:
-fopenmp-device-lib=library[,library,...]
-fno-openmp-device-lib=library[,library,...]
macOS:
None
Windows OS:
-fopenmp-device-lib=library[,library,...]
-fopenmp-device-lib=library[,library,...]
Arguments
289
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
To link more than one library, include a comma between the library
names. For example, if you want to link both the libm-fp32 device
library and the C library, specify: libm-fp32,libc.
Do not add spaces between library names.
Note that if you specify "all", it supersedes any additional value you
may specify.
Default
Description
This option enables or disables certain device libraries for an OpenMP* target.
If you specify fno-openmp-device-lib=library, linking to the specified library is disabled for the
OpenMP* target.
IDE Equivalent
Windows
Visual Studio: Linker > General > Enable linking of the device libraries for OpenMP offload
Linker > General > Disable linking of the device libraries for OpenMP offload
Alternate Options
None
fopenmp-target-buffers, Qopenmp-target-buffers
Enables a way to overcome the problem where some
OpenMP* offload SPIR-V* devices produce incorrect
code when a target object is larger than 4GB. This
feature is only available for ifx.
Syntax
Linux OS:
-fopenmp-target-buffers=keyword
macOS:
None
Windows OS:
/Qopenmp-target-buffers:keyword
290
Compiler Reference
Arguments
default Tells the compiler to use default heuristics. This may produce incorrect
code on some OpenMP* offload SPIR-V* devices when a target object is
larger than 4GB.
4GB Tells the compiler to generate code to prevent the issue described by
default. OpenMP* offload programs that access target objects of size
larger than 4GB in target code require this option.
This setting applies to the following:
Default
default If you do not specify this option, the compiler may produce incorrect code on some OpenMP*
offload SPIR-V* devices when a target object is larger than 4GB.
Description
This option enables a way to overcome the problem where some OpenMP* offload SPIR-V* devices produce
incorrect code when a target object is larger than 4GB (4294959104 bytes).
However, note that when -fopenmp-target-buffers=4GB (or /Qopenmp-target-buffers:4GB) is
specified on Intel® GPUs, there may be a decrease in performance.
To use this option, you must also specify option -fopenmp-targets (Linux*) or /Qopenmp-targets
(Windows*).
NOTE
This option may have no effect for some OpenMP* offload SPIR-V* devices, and for
OpenMP* offload targets different from SPIR*.
IDE Equivalent
Windows
Visual Studio: Code Generation > Specify buffer size for OpenMP offload kernel access limitations
(ifx only)
Alternate Options
None
See Also
fopenmp-targets, Qopenmp-targets compiler option
291
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
fopenmp-targets, Qopenmp-targets
Enables offloading to a specified GPU target if
OpenMP* features have been enabled. This feature is
only available for ifx.
Syntax
Linux OS:
-fopenmp-targets=keyword
macOS:
None
Windows OS:
/Qopenmp-targets:keyword
Arguments
Default
OFF If this option is not specified, no x86 + SPIR64 fat binary is created.
Description
This option enables offloading to a specified GPU target if OpenMP* features have been enabled.
To use this option, you must enable recognition of OpenMP* features by specifying one of the following
options:
• [q or Q]openmp
• -fiopenmp (Linux*) or /Qiopenmp (Windows*) (ifx only)
These options are equivalent in ifx to -qopenmp on Linux* and /Qopenmp on Windows*
• -fopenmp (ifx; deprecated)
This option is equivalent to -qopenmp on Linux*
IDE Equivalent
Windows
Visual Studio: Code Generation > Enable OpenMP Offloading
292
Compiler Reference
Alternate Options
None
See Also
qopenmp, Qopenmp compiler option
par-affinity, Qpar-affinity
Specifies thread affinity. This feature is only available
for ifort.
Syntax
Linux OS:
-par-affinity=[modifier,...]type[,permute][,offset]
macOS:
None
Windows OS:
/Qpar-affinity:[modifier,...]type[,permute][,offset]
Arguments
type Indicates the thread affinity. This argument is required and must be
one of the following values: compact, disabled, explicit, none,
scatter, logical, physical. The default is none. Values logical
and physical are deprecated. Use compact and scatter,
respectively, with no permute value.
permute Is a positive integer. You cannot use this argument with type setting
explicit, none, or disabled. The default is 0.
offset Is a positive integer. You cannot use this argument with type setting
explicit, none, or disabled. The default is 0.
Default
Description
This option specifies thread affinity, which binds threads to physical processing units. It has the same effect
as environment variable KMP_AFFINITY.
This option overrides the environment variable when both are specified.
This option only has an effect if the following is true:
293
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
This option may behave differently on Intel® microprocessors than on non-Intel
microprocessors.
IDE Equivalent
None
Alternate Options
None
See Also
parallel, Qparallel compiler option
qopt-report, Qopt-report compiler option
par-num-threads, Qpar-num-threads
Specifies the number of threads to use in a parallel
region. This feature is only available for ifort.
Syntax
Linux OS:
-par-num-threads=n
macOS:
-par-num-threads=n
Windows OS:
/Qpar-num-threads:n
Arguments
Default
Description
This option specifies the number of threads to use in a parallel region. It has the same effect as environment
variable OMP_NUM_THREADS.
This option overrides the environment variable when both are specified.
This option only has an effect if the following is true:
IDE Equivalent
None
Alternate Options
None
294
Compiler Reference
See Also
parallel, Qparallel compiler option
qopt-report, Qopt-report compiler option
par-runtime-control, Qpar-runtime-control
Generates code to perform run-time checks for loops
that have symbolic loop bounds. This feature is only
available for ifort.
Syntax
Linux OS:
-par-runtime-control[n]
-no-par-runtime-control
macOS:
-par-runtime-control[n]
-no-par-runtime-control
Windows OS:
/Qpar-runtime-control[n]
/Qpar-runtime-control-
Arguments
Default
Description
This option generates code to perform run-time checks for loops that have symbolic loop bounds.
If the granularity of a loop is greater than the parallelization threshold, the loop will be executed in parallel.
295
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If you do not specify this option, the compiler may not parallelize loops with symbolic loop bounds if the
compile-time granularity estimation of a loop can not ensure it is beneficial to parallelize the loop.
NOTE
This option may behave differently on Intel® microprocessors than on non-Intel
microprocessors.
IDE Equivalent
None
Alternate Options
None
par-schedule, Qpar-schedule
Lets you specify a scheduling algorithm for loop
iterations. This feature is only available for ifort.
Syntax
Linux OS:
-par-schedule-keyword[=n]
macOS:
-par-schedule-keyword[=n]
Windows OS:
/Qpar-schedule-keyword[[:]n]
Arguments
keyword Specifies the scheduling algorithm or tuning method. Possible values are:
n Is the size of the chunk or the number of iterations for each chunk.
This setting can only be specified for static, dynamic, and guided. For
more information, see the descriptions of each keyword below.
296
Compiler Reference
Default
static-balanced Iterations are divided into even-sized chunks and the chunks are assigned
to the threads in the team in a round-robin fashion in the order of the
thread number.
Description
This option lets you specify a scheduling algorithm for loop iterations. It specifies how iterations are to be
divided among the threads of the team.
This option is only useful when specified with option [Q]parallel.
This option affects performance tuning and can provide better performance during auto-parallelization. It
does nothing if it is used with option [q or Q]openmp.
Option Description
297
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Option Description
NOTE
This option may behave differently on Intel® microprocessors than on non-Intel
microprocessors.
IDE Equivalent
None
Alternate Options
None
par-threshold, Qpar-threshold
Sets a threshold for the auto-parallelization of loops.
This feature is only available for ifort.
Syntax
Linux OS:
-par-threshold[n]
macOS:
-par-threshold[n]
298
Compiler Reference
Windows OS:
/Qpar-threshold[[:]n]
Arguments
Default
Description
This option sets a threshold for the auto-parallelization of loops based on the probability of profitable
execution of the loop in parallel. To use this option, you must also specify option [Q]parallel.
This option is useful for loops whose computation work volume cannot be determined at compile-time. The
threshold is usually relevant when the loop trip count is unknown at compile-time.
The compiler applies a heuristic that tries to balance the overhead of creating multiple threads versus the
amount of work available to be shared amongst the threads.
NOTE
This option may behave differently on Intel® microprocessors than on non-Intel
microprocessors.
IDE Equivalent
Windows
Visual Studio: Optimization > Threshold For Auto-Parallelization
Alternate Options
None
parallel, Qparallel
Tells the auto-parallelizer to generate multithreaded
code for loops that can be safely executed in parallel.
This feature is only available for ifort.
299
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-parallel
macOS:
-parallel
Windows OS:
/Qparallel(or /Qpar)
Arguments
None
Default
OFF Multithreaded code is not generated for loops that can be safely executed in parallel.
Description
This option tells the auto-parallelizer to generate multithreaded code for loops that can be safely executed in
parallel.
To use this option, you must also specify option O2 or O3.
NOTE
Using this option enables parallelization for both Intel® microprocessors and non-Intel
microprocessors. The resulting executable may get additional performance gain on Intel
microprocessors than on non-Intel microprocessors. The parallelization can also be affected
by certain options, such as /arch or /Qx (Windows*) or -m or -x (Linux* and macOS*).
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
IDE Equivalent
Visual Studio
Visual Studio: Optimization > Parallelization
Alternate Options
None
See Also
qopt-report, Qopt-report compiler option
par-affinity, Qpar-affinity compiler option
par-num-threads, Qpar-num-threads compiler option
par-runtime-control, Qpar-runtime-control compiler option
300
Compiler Reference
parallel-source-info, Qparallel-source-info
Enables or disables source location emission when
OpenMP* or auto-parallelism code is generated. This
feature is only available for ifort.
Syntax
Linux OS:
-parallel-source-info[=n]
-no-parallel-source-info
macOS:
-parallel-source-info[=n]
-no-parallel-source-info
Windows OS:
/Qparallel-source-info
/Qparallel-source-info-[:n]
Arguments
Default
Description
This option enables or disables source location emission when OpenMP code or auto-parallelism code is
generated. It also lets you set the level of emission.
301
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IDE Equivalent
None
Alternate Options
None
qopenmp, Qopenmp
Enables recognition of OpenMP* features and tells the
parallelizer to generate multi-threaded code based on
OpenMP* directives.
Syntax
Linux OS:
-qopenmp
-qno-openmp
macOS:
-qopenmp
-qno-openmp
Windows OS:
/Qopenmp
/Qopenmp-
Arguments
None
Default
Description
This option enables recognition of OpenMP* features and tells the parallelizer to generate multi-threaded
code based on OpenMP* directives. The code can be executed in parallel on both uniprocessor and
multiprocessor systems.
If you use this option, multithreaded libraries are used, but option fpp is not automatically invoked.
This option works with any optimization level. Specifying no optimization (-O0 on Linux* or /Od on
Windows*) helps to debug OpenMP applications.
To ensure that a threadsafe and/or reentrant run-time library is linked and correctly initialized, option
[q or Q]openmp should also be used for the link step and for the compilation of the main routine.
NOTE
If you want to do offloading, specify option -fiopenmp. This option is only available for ifx.
302
Compiler Reference
NOTE
To enable offloading to a specified GPU target, you must also specify option
fopenmp-targets (Linux*) or /Qopenmp-targets (Windows). This option is only available for
ifx.
NOTE
Options that use OpenMP* API are available for both Intel® microprocessors and non-Intel
microprocessors, but these options may perform additional optimizations on Intel®
microprocessors than they perform on non-Intel microprocessors. The list of major, user-
visible OpenMP constructs and features that may perform differently on Intel®
microprocessors versus non-Intel microprocessors include: locks (internal and user visible),
the SINGLE construct, barriers (explicit and implicit), parallel loop scheduling, reductions,
memory allocation, thread affinity, and binding.
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
IDE Equivalent
Visual Studio
Visual Studio: Language > Process OpenMP Directives
Language > OpenMP Support (for ifx /Qiopenmp)
Alternate Options
Linux and macOS*: -fopenmp (deprecated), -fiopenmp (ifx only)
See Also
fopenmp-targets, Qopenmp-targets compiler option
qopenmp-lib, Qopenmp-lib
Lets you specify an OpenMP* run-time library to use
for linking. This feature is only available for ifort.
Syntax
Linux OS:
-qopenmp-lib=type
macOS:
-qopenmp-lib=type
Windows OS:
/Qopenmp-lib:type
303
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Arguments
type Specifies the type of library to use; it implies compatibility levels. Currently, the only
possible value is:
Default
Description
This option lets you specify an OpenMP* run-time library to use for linking.
The compatibility OpenMP run-time libraries are compatible with object files created using the Microsoft*
OpenMP run-time library (vcomp) or the GNU OpenMP run-time library (libgomp).
To use the compatibility OpenMP run-time library, compile and link your application using the compat setting
for option [q or Q]openmp-lib. To use this option, you must also specify one of the following compiler
options:
NOTE The compatibility OpenMP run-time library is not compatible with object files created
using versions of the Intel compilers earlier than 10.0.
NOTE On Windows* systems, this option is processed by the compiler, which adds directives
to the compiled object file that are processed by the linker. On Linux* and macOS* systems,
this option is processed by the ifort command that initiates linking, adding library names
explicitly to the link command.
IDE Equivalent
None
304
Compiler Reference
Alternate Options
None
See Also
qopenmp, Qopenmp compiler option
qopenmp-stubs, Qopenmp-stubs compiler option
qopenmp-link
Controls whether the compiler links to static or
dynamic OpenMP* run-time libraries.
Syntax
Linux OS:
-qopenmp-link=library
macOS:
-qopenmp-link=library
Windows OS:
None
Arguments
Default
Description
This option controls whether the compiler links to static or dynamic OpenMP* run-time libraries.
To link to the static OpenMP run-time library (RTL) and create a purely static executable, you must specify
-qopenmp-link=static. However, we strongly recommend you use the default setting,
-qopenmp-link=dynamic.
NOTE
Compiler options -static-intel and -shared-intel (Linux* and macOS*) have no effect on
which OpenMP run-time library is linked.
305
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
On Linux* systems, -qopenmp-link=dynamic cannot be used in conjunction with option
-static. If you try to specify both options together, an error will be displayed.
NOTE
On Linux systems, the OpenMP runtime library depends on using libpthread and libc (libgcc
when compiled with gcc). Libpthread and libc (libgcc) must both be static or both be
dynamic. If both libpthread and libc (libgcc) are static, then the static version of the OpenMP
runtime should be used. If both libpthread and libc (libgcc) are dynamic, then either the
static or dynamic version of the OpenMP runtime may be used.
IDE Equivalent
None
Alternate Options
None
qopenmp-offload
Enables or disables OpenMP* offloading compilation
for the TARGET directives. This feature is only
available for ifort.
Syntax
Linux OS:
-qopenmp-offload[=device]
-qno-openmp-offload
macOS:
None
Windows OS:
None
Arguments
device Specifies the default device for TARGET directives. Possible values are:
None
Default
306
Compiler Reference
Description
This option enables or disables OpenMP* offloading compilation for the TARGET directives. When enabling
offloading, it lets you specify what the default target device should be for the TARGET directives.
NOTE
The TARGET directives are only available on Linux* systems.
You can also use this option if you want to enable or disable the offloading feature with no impact on other
OpenMP* features. In this case, no OpenMP runtime library is needed to link and the compiler does not need
to generate OpenMP runtime initialization code.
If you specify this option with the qopenmp option, it can impact other OpenMP* features.
IDE Equivalent
None
Alternate Options
None
Example
Consider the following:
-qno-openmp -qopenmp-offload
The above is equivalent to specifying only qopenmp-offload. In this case, only the offload library is linked,
not the OpenMP* library, and only the !$OMP directives for TARGET are processed but no other !$OMP
directives.
Consider the following:
-qopenmp -qopenmp-offload
In this case, the offload library is linked, the OpenMP library is linked, and OpenMP runtime initialization code
is generated.
See Also
qopenmp, Qopenmp compiler option
TARGET directive
TARGET DATA directive
TARGET UPDATE directive
qopenmp-simd, Qopenmp-simd
Enables or disables OpenMP* SIMD compilation.
Syntax
Linux OS:
-qopenmp-simd
-qno-openmp-simd
macOS:
-qopenmp-simd
-qno-openmp-simd
307
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows OS:
/Qopenmp-simd
/Qopenmp-simd-
Arguments
None
Default
• ifort: O2 or higher
• ifx: O1 or higher
OpenMP* SIMD compilation is always disabled at this
optimization level:
Description
This option enables or disables OpenMP* SIMD compilation.
You can use this option if you want to enable or disable the SIMD support with no impact on other OpenMP
features. In this case, no OpenMP runtime library is needed to link and the compiler does not need to
generate OpenMP runtime initialization code.
If you specify this option with the [q or Q]openmp option, it can impact other OpenMP features.
IDE Equivalent
None
Alternate Options
ifort: None
ifx:
Linux: -fopenmp-simd and -fiopenmp-simd
Windows: /Qiopenmp-simd
Example
Consider the following:
308
Compiler Reference
The above is equivalent to specifying only [q or Q]openmp-simd. In this case, only SIMD support is
provided, the OpenMP* library is not linked, and only the !$OMP directives related to SIMD are processed.
Consider the following:
See Also
qopenmp, Qopenmp compiler option
O compiler option
SIMD Directive (OpenMP* API) directive
qopenmp-stubs, Qopenmp-stubs
Enables compilation of OpenMP* programs in
sequential mode.
Syntax
Linux OS:
-qopenmp-stubs
macOS:
-qopenmp-stubs
Windows OS:
/Qopenmp-stubs
Arguments
None
Default
Description
This option enables compilation of OpenMP* programs in sequential mode. The OpenMP directives are
ignored and a stub OpenMP library is linked.
IDE Equivalent
Windows
Visual Studio: Language > Process OpenMP Directives
Alternate Options
None
See Also
qopenmp, Qopenmp compiler option
309
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
qopenmp-threadprivate, Qopenmp-threadprivate
Lets you specify an OpenMP* threadprivate
implementation.
Syntax
Linux OS:
-qopenmp-threadprivate=type
macOS:
None
Windows OS:
/Qopenmp-threadprivate:type
Arguments
Default
Description
This option lets you specify an OpenMP* threadprivate implementation.
The threadprivate implementation of the legacy OpenMP run-time library may not be compatible with object
files created using OpenMP run-time libraries supported in other compilers.
To use this option, you must also specify one of the following compiler options:
310
Compiler Reference
NOTE
On Windows* systems, if you specify option /Qopenmp-threadprivate:compat, the compiler
does not generate threadsafe code for common blocks in an !$OMP THREADPRIVATE
directive unless at least one element in the common block is explicitly initialized. For more
information, see the article titled: /Qopenmp-threadprivate:compat doesn't work with
uninitialized threadprivate common blocks, which is located in http://intel.ly/1aHhsjc
NOTE
On macOS* systems, legacy is the only type of threadprivate supported. Option
-qopenmp-threadprivate is not recognized by the compiler.
IDE Equivalent
None
Alternate Options
None
See Also
qopenmp, Qopenmp compiler option
qopenmp-stubs, Qopenmp-stubs compiler option
Qpar-adjust-stack
Tells the compiler to generate code to adjust the stack
size for a fiber-based main thread. This feature is only
available for ifort.
Syntax
Linux OS and macOS:
None
Windows OS:
/Qpar-adjust-stack:n
Arguments
n Is the stack size (in bytes) for the fiber-based main thread. It must be
a number equal to or greater than zero.
Default
Description
This option tells the compiler to generate code to adjust the stack size for a fiber-based main thread. This
can reduce the stack size of threads.
For this option to be effective, you must also specify option /Qparallel.
IDE Equivalent
None
311
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Alternate Options
None
See Also
parallel, Qparallel compiler option
Xopenmp-target
Enables options to be passed to the specified tool in
the device compilation tool chain for the target. This
compiler option supports OpenMP* offloading.This
feature is only available for ifx.
Syntax
Linux OS:
-Xopenmp-target-tool=T "options"
macOS:
None
Windows OS:
-Xopenmp-target-tool=T "options"
Arguments
Some targets may have frontend and backend in one component; in that case, options are
merged.
Default
Description
This option enables options to be passed to the specified tool in the device compilation tool chain for the
target. It supports OpenMP* offloading.
312
Compiler Reference
IDE Equivalent
None
Alternate Options
None
Floating-Point Options
This section contains descriptions for compiler options that pertain to floating-point calculations.
fast-transcendentals, Qfast-transcendentals
Enables the compiler to replace calls to transcendental
functions with faster but less precise implementations.
This feature is only available for ifort.
Syntax
Linux OS:
-fast-transcendentals
-no-fast-transcendentals
macOS:
-fast-transcendentals
-no-fast-transcendentals
Windows OS:
/Qfast-transcendentals
/Qfast-transcendentals-
Arguments
None
Default
Description
This option enables the compiler to replace calls to transcendental functions with implementations that may
be faster but less precise.
It allows the compiler to perform certain optimizations on transcendental functions, such as replacing
individual calls to sine in a loop with a single call to a less precise vectorized sine library routine. These
optimizations can cause numerical differences that would not otherwise exist if you are also compiling with a
value-safe option such as -fp-model precise (Linux* and macOS*) or /fp:precise (Windows).
313
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
For example, you may get different results if you specify option O0 versus option O2, or you may get different
results from calling the same function with the same input at different points in your program. If these kinds
of numerical differences are problematic, consider using option -fimf-use-svml (Linux* and macOS*)
or /Qimf-use-svml (Windows) as an alternative. When used with a value-safe option such as
-fp-model precise or /fp:precise, option -fimf-use-svml or /Qimf-use-svml provides many of the
positive performance benefits of [Q]fast-transcendentals without negatively affecting numeric
consistency. For more details, see the description of option -fimf-use-svml and /Qimf-use-svml.
This option does not affect explicit Short Vector Math Library (SVML) intrinsics. It only affects scalar calls to
the standard math library routines.
You cannot use option -fast-transcendentals with option -fp-model strict and you cannot use
option /Qfast-transcendentals with option /fp:strict.
This option determines the setting for the maximum allowable relative error for math library function results
(max-error) if none of the following options are specified:
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
IDE Equivalent
None
Alternate Options
None
See Also
fp-model, fp compiler option
fimf-use-svml, Qimf-use-svml compiler option
fimf-accuracy-bits, Qimf-accuracy-bits compiler option
fimf-max-error, Qimf-max-error compiler option
fimf-precision, Qimf-precision compiler option
fimf-absolute-error, Qimf-absolute-error
Defines the maximum allowable absolute error for
math library function results. This feature is only
available for ifort.
Syntax
Linux OS:
-fimf-absolute-error=value[:funclist]
macOS:
-fimf-absolute-error=value[:funclist]
314
Compiler Reference
Windows OS:
/Qimf-absolute-error:value[:funclist]
Arguments
value Is a positive, floating-point number. Errors in math library function results may exceed
the maximum relative error (max-error) setting if the absolute-error is less than or
equal to value.
The format for the number is [digits] [.digits] [ { e | E }[sign]digits]
funclist Is an optional list of one or more math library functions to which the attribute should
be applied. Do not specify the standard Fortran name of the math function; you must
specify the actual math library name. If you specify more than one function, they must
be separated with commas.
Precision-specific variants like sin and sinf are considered different functions, so you
would need to use -fimf-absolute-error=0.00001:sin,sinf
(or /Qimf-absolute-error:0.00001:sin,sinf) to specify the maximum allowable
absolute error for both the single-precision and double-precision sine functions.
You also can specify the symbol /f to denote single-precision divides, symbol / to
denote double-precision divides, symbol /l to denote extended-precision divides, and
symbol /q to denote quad-precision divides. For example you can specify
-fimf-absolute-error=0.00001:/ or /Qimf-absolute-error: 0.00001:/.
Default
Zero ("0") An absolute-error setting of 0 means that the function is bound by the relative error
setting. This is the default behavior.
Description
This option defines the maximum allowable absolute error for math library function results.
This option can improve run-time performance, but it may decrease the accuracy of results.
This option only affects functions that have zero as a possible return value, such as log, sin, asin, etc.
The relative error requirements for a particular function are determined by options that set the maximum
relative error (max-error) and precision. The return value from a function must have a relative error less
than the max-error value, or an absolute error less than the absolute-error value.
If you need to define the accuracy for a math function of a certain precision, specify the function name of the
precision that you need. For example, if you want double precision, you can specify :sin; if you want single
precision, you can specify :sinf, as in -fimf-absolute-error=0.00001:sin
or /Qimf-absolute-error:0.00001:sin, or -fimf-absolute-error=0.00001:sqrtf
or /Qimf-absolute-error:0.00001:sqrtf.
If you do not specify any function names, then the setting applies to all functions (and to all precisions).
However, as soon as you specify an individual function name, the setting applies only to the function of
corresponding precision. So, for example, sinf applies only to the single-precision sine function, sin applies
only to the double-precision sine function, sinl applies only to the extended-precision sine function, etc.
NOTE
Many routines in libraries LIBM (Math Library) and SVML (Short Vector Math Library) are
more highly optimized for Intel® microprocessors than for non-Intel microprocessors.
315
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
The standard Fortran names for the various math intrinsic functions do not match the math
library names of the math intrinsic functions. You must find the actual math library name
that is generated for the relevant Fortran math intrinsic.
One way to do this is to generate assembly code by using options /Fa or /S on Windows, or option -S
on Linux. The assembly code will show the actual math library name.
For example, if you create a program that contains a call to SIN(x) where x is declared as
REAL(KIND=4) and then use option /S on Windows to produce assembly code for the program, the
assembly code will show a call to sinf.
Therefore, to define the maximum allowable absolute error for the single-precision sine function, you
would specify -fimf-absolute-error=sinf (or /Qimf-absolute-error:sinf).
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
IDE Equivalent
None
Alternate Options
None
See Also
fimf-accuracy-bits, Qimf-accuracy-bits compiler option
fimf-arch-consistency, Qimf-arch-consistency compiler option
fimf-domain-exclusion, Qimf-domain-exclusion compiler option
fimf-max-error, Qimf-max-error compiler option
fimf-precision, Qimf-precision compiler option
fimf-use-svml_Qimf-use-svml compiler option
fimf-accuracy-bits, Qimf-accuracy-bits
Defines the relative error for math library function
results, including division and square root. This
feature is only available for ifort.
Syntax
Linux OS:
-fimf-accuracy-bits=bits[:funclist]
macOS:
-fimf-accuracy-bits=bits[:funclist]
Windows OS:
/Qimf-accuracy-bits:bits[:funclist]
316
Compiler Reference
Arguments
bits Is a positive, floating-point number indicating the number of correct bits the compiler
should use.
The format for the number is [digits] [.digits] [ { e | E }[sign]digits].
funclist Is an optional list of one or more math library functions to which the attribute should
be applied. Do not specify the standard Fortran name of the math function; you must
specify the actual math library name. If you specify more than one function, they must
be separated with commas.
Precision-specific variants like sin and sinf are considered different functions, so you
would need to use -fimf-accuracy-bits=23:sin,sinf
(or /Qimf-accuracy-bits:23:sin,sinf) to specify the relative error for both the
single-precision and double-precision sine functions.
You also can specify the symbol /f to denote single-precision divides, symbol / to
denote double-precision divides, symbol /l to denote extended-precision divides, and
symbol /q to denote quad-precision divides. For example you can specify
-fimf-accuracy-bits=10.0:/f or /Qimf-accuracy-bits:10.0:/f.
Default
-fimf-precision=medium or /Qimf- The compiler uses medium precision when calling math library
precision:medium functions. Note that other options can affect precision; see below
for details.
Description
This option defines the relative error, measured by the number of correct bits, for math library function
results.
The following formula is used to convert bits into ulps: ulps = 2p-1-bits, where p is the number of the target
format mantissa bits (24, 53, and 113 for single, double, and quad precision, respectively).
This option can affect run-time performance and the accuracy of results.
If you need to define the accuracy for a math function of a certain precision, specify the function name of the
precision that you need. For example, if you want double precision, you can specify :sin; if you want single
precision, you can specify :sinf, as in the following:
• -fimf-accuracy-bits=23:sinf,cosf,logf or /Qimf-accuracy-bits:23:sinf,cosf,logf
• -fimf-accuracy-bits=52:sqrt,/,trunc or /Qimf-accuracy-bits:52:sqrt,/,trunc
• -fimf-accuracy-bits=10:powf or /Qimf-accuracy-bits:10:powf
If you do not specify any function names, then the setting applies to all functions (and to all precisions).
However, as soon as you specify an individual function name, the setting applies only to the function of
corresponding precision. So, for example, sinf applies only to the single-precision sine function, sin applies
only to the double-precision sine function, sinl applies only to the extended-precision sine function, etc.
There are three options you can use to express the maximum relative error. They are as follows:
317
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If none of the above options are specified, the default values for the maximum relative error are determined
by the setting of the following options:
• [Q]fast-transcendentals
• [Q]prec-div
• [Q]prec-sqrt
• -fp-model (Linux and macOS*) or /fp (Windows)
NOTE
Many routines in libraries LIBM (Math Library) and SVML (Short Vector Math Library) are
more highly optimized for Intel® microprocessors than for non-Intel microprocessors.
NOTE
The standard Fortran names for the various math intrinsic functions do not match the math
library names of the math intrinsic functions. You must find the actual math library name
that is generated for the relevant Fortran math intrinsic.
One way to do this is to generate assembly code by using options /Fa or /S on Windows, or option -S
on Linux. The assembly code will show the actual math library name.
For example, if you create a program that contains a call to SIN(x) where x is declared as
REAL(KIND=4) and then use option /S on Windows to produce assembly code for the program, the
assembly code will show a call to sinf.
Therefore, to request the relative error for the single-precision sine function, you would specify
-fimf-accuracy-bits=sinf (or /Qimf-accuracy-bits:sinf).
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
IDE Equivalent
None
Alternate Options
None
See Also
fimf-absolute-error, Qimf-absolute-error compiler option
fimf-arch-consistency, Qimf-arch-consistency compiler option
fimf-domain-exclusion, Qimf-domain-exclusion compiler option
fimf-max-error, Qimf-max-error compiler option
fimf-precision, Qimf-precision compiler option
fimf-use-svml_Qimf-use-svml compiler option
318
Compiler Reference
fimf-arch-consistency, Qimf-arch-consistency
Ensures that the math library functions produce
consistent results across different microarchitectural
implementations of the same architecture. This
feature is only available for ifort.
Syntax
Linux OS:
-fimf-arch-consistency=value[:funclist]
macOS:
-fimf-arch-consistency=value[:funclist]
Windows OS:
/Qimf-arch-consistency:value[:funclist]
Arguments
funclist Is an optional list of one or more math library functions to which the
attribute should be applied. Do not specify the standard Fortran name
of the math function; you must specify the actual math library name.
If you specify more than one function, they must be separated with
commas.
Precision-specific variants like sin and sinf are considered different
functions, so you would need to use
-fimf-arch-consistency=true:sin,sinf
(or /Qimf-arch-consistency:true:sin,sinf) to specify consistent
results for both the single-precision and double-precision sine
functions.
You also can specify the symbol /f to denote single-precision divides,
symbol / to denote double-precision divides, symbol /l to denote
extended-precision divides, and symbol /q to denote quad-precision
divides. For example you can specify
-fimf-arch-consistency=true:/
or /Qimf-arch-consistency:true:/.
Default
false Implementations of some math library functions may produce slightly different results on
implementations of the same architecture.
Description
This option ensures that the math library functions produce consistent results across different
microarchitectural implementations of the same architecture (for example, across different microarchitectural
implementations of IA-32 architecture). Consistency is only guaranteed for a single binary. Consistency is not
guaranteed across different architectures. For example, consistency is not guaranteed across IA-32
architecture and Intel® 64 architecture.
319
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If you need to define the accuracy for a math function of a certain precision, specify the function name of the
precision that you need. For example, if you want double precision, you can specify :sin; if you want single
precision, you can specify :sinf, as in -fimf-arch-consistency=true:sin
or /Qimf-arch-consistency:true:sin, or -fimf-arch-consistency=false:sqrtf
or /Qimf-arch-consistency:false:sqrtf.
If you do not specify any function names, then the setting applies to all functions (and to all precisions).
However, as soon as you specify an individual function name, the setting applies only to the function of
corresponding precision. So, for example, sinf applies only to the single-precision sine function, sin applies
only to the double-precision sine function, sinl applies only to the extended-precision sine function, etc.
The -fimf-arch-consistency (Linux* and macOS*) and /Qimf-arch-consistency (Windows*) option
may decrease run-time performance, but the option will provide bit-wise consistent results on all Intel®
processors and compatible, non-Intel processors, regardless of micro-architecture. This option may not
provide bit-wise consistent results between different architectures.
NOTE
Many routines in libraries LIBM (Math Library) and SVML (Short Vector Math Library) are
more highly optimized for Intel® microprocessors than for non-Intel microprocessors.
NOTE
The standard Fortran names for the various math intrinsic functions do not match the math
library names of the math intrinsic functions. You must find the actual math library name
that is generated for the relevant Fortran math intrinsic.
One way to do this is to generate assembly code by using options /Fa or /S on Windows, or option -S
on Linux. The assembly code will show the actual math library name.
For example, if you create a program that contains a call to SIN(x) where x is declared as
REAL(KIND=4) and then use option /S on Windows to produce assembly code for the program, the
assembly code will show a call to sinf.
Therefore, to ensure consistent results for the single-precision sine function, you would specify
-fimf-arch-consistency=sinf (or /Qimf-arch-consistency:sinf).
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
IDE Equivalent
None
Alternate Options
None
See Also
fimf-absolute-error, Qimf-absolute-error compiler option
fimf-accuracy-bits, Qimf-accuracy-bits compiler option
fimf-domain-exclusion, Qimf-domain-exclusion compiler option
fimf-max-error, Qimf-max-error compiler option
320
Compiler Reference
fimf-domain-exclusion, Qimf-domain-exclusion
Indicates the input arguments domain on which math
functions must provide correct results. This feature is
only available for ifort.
Syntax
Linux OS:
-fimf-domain-exclusion=classlist[:funclist]
macOS:
-fimf-domain-exclusion=classlist[:funclist]
Windows OS:
/Qimf-domain-exclusion:classlist[:funclist]
Arguments
• One or more of the following floating-point value classes you can exclude from the
function domain without affecting the correctness of your program. The supported
class names are:
extremes This class is for values which do not lie within the
usual domain of arguments for a given function.
Each classlist element corresponds to a power of two. The exclusion attribute is the
logical or of the associated powers of two (that is, a bitmask).
The following shows the current mapping from classlist mnemonics to numerical
values:
extremes 1
nans 2
infinities 4
denormals 8
zeros 16
none 0
all 31
common 15
321
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
You must specify the integer value that corresponds to the class that you want to
exclude.
Note that on excluded values, unexpected results may occur.
• One of the following short-hand tokens:
none This means that none of the supported classes are
excluded from the domain. To indicate this token,
specify 0, as in -fimf-domain-exclusion=0
(or /Qimf-domain-exclusion:0).
funclist Is an optional list of one or more math library functions to which the attribute should
be applied. Do not specify the standard Fortran name of the math function; you must
specify the actual math library name. If you specify more than one function, they must
be separated with commas.
Precision-specific variants like sin and sinf are considered different functions, so you
would need to use -fimf-domain-exclusion=4:sin,sinf
(or /Qimf-domain-exclusion:4:sin,sinf) to specify infinities for both the single-
precision and double-precision sine functions.
You also can specify the symbol /f to denote single-precision divides, symbol / to
denote double-precision divides, symbol /l to denote extended-precision divides, and
symbol /q to denote quad-precision divides. For example, you can specify:
-fimf-domain-exclusion=4 or /Qimf-domain-exclusion:4
-fimf-domain-exclusion=5:/,powf or /Qimf-domain-exclusion:5:/,powf
-fimf-domain-exclusion=23:log,logf,/,sin,cosf
or /Qimf-domain-exclusion:23:log,logf,/,sin,cosf
If you don't specify argument funclist, the domain restrictions apply to all math library
functions.
Default
Zero ("0") The compiler uses default heuristics when calling math library functions.
Description
This option indicates the input arguments domain on which math functions must provide correct results. It
specifies that your program will function correctly if the functions specified in funclist do not produce
standard conforming results on the number classes.
322
Compiler Reference
This option can affect run-time performance and the accuracy of results. As more classes are excluded, faster
code sequences can be used.
If you need to define the accuracy for a math function of a certain precision, specify the function name of the
precision that you need. For example, if you want double precision, you can specify :sin; if you want single
precision, you can specify :sinf, as in -fimf-domain-exclusion=subnormals:sin
or /Qimf-domain-exclusion:subnormals:sin, or -fimf-domain-exclusion=extremes:sqrtf
or /Qimf-domain-exclusion:extremes:sqrtf.
If you do not specify any function names, then the setting applies to all functions (and to all precisions).
However, as soon as you specify an individual function name, the setting applies only to the function of
corresponding precision. So, for example, sinf applies only to the single-precision sine function, sin applies
only to the double-precision sine function, sinl applies only to the extended-precision sine function, etc.
NOTE
Many routines in libraries LIBM (Math Library) and SVML (Short Vector Math Library) are
more highly optimized for Intel® microprocessors than for non-Intel microprocessors.
NOTE
The standard Fortran names for the various math intrinsic functions do not match the math
library names of the math intrinsic functions. You must find the actual math library name
that is generated for the relevant Fortran math intrinsic.
One way to do this is to generate assembly code by using options /Fa or /S on Windows, or option -S
on Linux. The assembly code will show the actual math library name.
For example, if you create a program that contains a call to SIN(x) where x is declared as
REAL(KIND=4) and then use option /S on Windows to produce assembly code for the program, the
assembly code will show a call to sinf.
Therefore, to indicate the input arguments domain for the single-precision sine function, you would
specify -fimf-domain-exclusion=sinf (or /Qimf-domain-exclusion:sinf).
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
IDE Equivalent
None
Alternate Options
None
Example
Consider the following single-precision sequence for function exp2f:
Operation: y = exp2f(x)
Accuracy: 1.014 ulp
Instructions: 4 (2 without fix-up)
323
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
However, the above 2-instruction sequence will not correctly process NaNs. To process Nans correctly, the
following fix-up must be included following the above instruction sequence:
See Also
fimf-absolute-error, Qimf-absolute-error compiler option
fimf-accuracy-bits, Qimf-accuracy-bits compiler option
fimf-arch-consistency, Qimf-arch-consistency compiler option
fimf-max-error, Qimf-max-error compiler option
fimf-precision, Qimf-precision compiler option
fimf-use-svml_Qimf-use-svml compiler option
fimf-force-dynamic-target, Qimf-force-dynamic-target
Instructs the compiler to use run-time dispatch in calls
to math functions.
Syntax
Linux OS:
-fimf-force-dynamic-target[=funclist]
macOS:
-fimf-force-dynamic-target[=funclist]
Windows OS:
/Qimf-force-dynamic-target[:funclist]
324
Compiler Reference
Arguments
funclist Is an optional list of one or more math library functions to which the
attribute should be applied. Do not specify the standard Fortran name
of the math function; you must specify the actual math library name.
If you specify more than one function, they must be separated with
commas.
Precision-specific variants like sin and sinf are considered different
functions, so you would need to use
-fimf-dynamic-target=sin,sinf
(or /Qimf-dynamic-target:sin,sinf) to specify run-time dispatch
for both the single-precision and double-precision sine functions.
You also can specify the symbol /f to denote single-precision divides,
symbol / to denote double-precision divides, symbol /l to denote
extended-precision divides, and symbol /q to denote quad-precision
divides. For example, you can specify -fimf-dynamic-target=/
or /Qimf-dynamic-target:/.
Default
OFF Run-time dispatch is not forced in math libraries calls. The compiler can choose to call a CPU-
specific version of a math function if one is available.
Description
This option instructs the compiler to use run-time dispatch in calls to math functions. When this option set to
ON, it lets you force run-time dispatch in math libraries calls.
By default, when this option is set to OFF, the compiler often optimizes math library calls using the target
CPU architecture-specific information available at compile time through the [Q]x and arch compiler options.
If you want to target multiple CPU families with a single application or you prefer to choose a target CPU at
run time, you can force run-time dispatch in math libraries by using this option.
NOTE
The standard Fortran names for the various math intrinsic functions do not match the math
library names of the math intrinsic functions. You must find the actual math library name
that is generated for the relevant Fortran math intrinsic.
One way to do this is to generate assembly code by using options /Fa or /S on Windows, or option -S
on Linux. The assembly code will show the actual math library name.
For example, if you create a program that contains a call to SIN(x) where x is declared as
REAL(KIND=4) and then use option /S on Windows to produce assembly code for the program, the
assembly code will show a call to sinf.
Therefore, to use run-time dispatch in calls to the single-precision sine function, you would specify
-fimf-force-dynamic-target=sinf (or /Qimf-force-dynamic-target:sinf).
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
325
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IDE Equivalent
None
Alternate Options
None
See Also
x, Qx compiler option
arch compiler option
mtune, tune compiler option
fimf-max-error, Qimf-max-error
Defines the maximum allowable relative error for
math library function results, including division and
square root. This feature is only available for ifort.
Syntax
Linux OS:
-fimf-max-error=ulps[:funclist]
macOS:
-fimf-max-error=ulps[:funclist]
Windows OS:
/Qimf-max-error:ulps[:funclist]
Arguments
funclist Is an optional list of one or more math library functions to which the
attribute should be applied. Do not specify the standard Fortran name
of the math function; you must specify the actual math library name.
If you specify more than one function, they must be separated with
commas.
Precision-specific variants like sin and sinf are considered different
functions, so you would need to use
-fimf-max-error=4.0:sin,sinf
(or /Qimf-max-error=4.0:sin,sinf) to specify the maximum
allowable relative error for both the single-precision and double-
precision sine functions.
You also can specify the symbol /f to denote single-precision divides,
symbol / to denote double-precision divides, symbol /l to denote
extended-precision divides, and symbol /q to denote quad-precision
divides. For example you can specify -fimf-max-error=4.0:/
or /Qimf-max-error:4.0:/.
326
Compiler Reference
Default
-fimf-precision=medium or /Qimf- The compiler uses medium precision when calling math library
precision:medium functions. Note that other options can affect precision; see below
for details.
Description
This option defines the maximum allowable relative error, measured in ulps, for math library function results.
This option can affect run-time performance and the accuracy of results.
If you need to define the accuracy for a math function of a certain precision, specify the function name of the
precision that you need. For example, if you want double precision, you can specify :sin; if you want single
precision, you can specify :sinf, as in -fimf-max-error=4.0:sin or /Qimf-max-error:4.0:sin, or
-fimf-max-error=4.0:sqrtf or /Qimf-max-error:4.0:sqrtf.
If you do not specify any function names, then the setting applies to all functions (and to all precisions).
However, as soon as you specify an individual function name, the setting applies only to the function of
corresponding precision. So, for example, sinf applies only to the single-precision sine function, sin applies
only to the double-precision sine function, sinl applies only to the extended-precision sine function, etc.
There are three options you can use to express the maximum relative error. They are as follows:
• [Q]fast-transcendentals
• [Q]prec-div
• [Q]prec-sqrt
• -fp-model (Linux and macOS*) or /fp (Windows)
NOTE
Many routines in libraries LIBM (Math Library) and SVML (Short Vector Math Library) are
more highly optimized for Intel® microprocessors than for non-Intel microprocessors.
327
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
The standard Fortran names for the various math intrinsic functions do not match the math
library names of the math intrinsic functions. You must find the actual math library name
that is generated for the relevant Fortran math intrinsic.
One way to do this is to generate assembly code by using options /Fa or /S on Windows, or option -S
on Linux. The assembly code will show the actual math library name.
For example, if you create a program that contains a call to SIN(x) where x is declared as
REAL(KIND=4) and then use option /S on Windows to produce assembly code for the program, the
assembly code will show a call to sinf.
Therefore, to define the maximum allowable relative error for the single-precision sine function, you
would specify -fimf-max-error=sinf (or /Qimf-max-error:sinf).
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
IDE Equivalent
None
Alternate Options
None
See Also
fimf-absolute-error, Qimf-absolute-error compiler option
fimf-accuracy-bits, Qimf-accuracy-bits compiler option
fimf-arch-consistency, Qimf-arch-consistency compiler option
fimf-domain-exclusion, Qimf-domain-exclusion compiler option
fimf-precision, Qimf-precision compiler option
fimf-use-svml_Qimf-use-svml compiler option
fimf-precision, Qimf-precision
Lets you specify a level of accuracy (precision) that
the compiler should use when determining which math
library functions to use. This feature is only available
for ifort.
Syntax
Linux OS:
-fimf-precision[=value[:funclist]]
macOS:
-fimf-precision[=value[:funclist]]
Windows OS:
/Qimf-precision[:value[:funclist]]
328
Compiler Reference
Arguments
funclist Is an optional list of one or more math library functions to which the
attribute should be applied. Do not specify the standard Fortran name
of the math function; you must specify the actual math library name.
If you specify more than one function, they must be separated with
commas.
Precision-specific variants like sin and sinf are considered different
functions, so you would need to use
-fimf-precision=high:sin,sinf
(or /Qimf-precision:high:sin,sinf) to specify high precision for
both the single-precision and double-precision sine functions.
You also can specify the symbol /f to denote single-precision divides,
symbol / to denote double-precision divides, symbol /l to denote
extended-precision divides, and symbol /q to denote quad-precision
divides. For example you can specify -fimf-precision=low:/
or /Qimf-precision:low:/ and -fimf-precision=low:/f
or /Qimf-precision:low:/f.
Default
medium The compiler uses medium precision when calling math library functions. Note that
other options can affect precision; see below for details.
Description
This option lets you specify a level of accuracy (precision) that the compiler should use when determining
which math library functions to use.
This option can be used to improve run-time performance if reduced accuracy is sufficient for the application,
or it can be used to increase the accuracy of math library functions selected by the compiler.
In general, using a lower precision can improve run-time performance and using a higher precision may
reduce run-time performance.
If you need to define the accuracy for a math function of a certain precision, specify the function name of the
precision that you need. For example, if you want double precision, you can specify :sin; if you want single
precision, you can specify :sinf, as in -fimf-precision=low:sin or /Qimf-precision:low:sin, or
-fimf-precision=high:sqrtf or /Qimf-precision:high:sqrtf.
329
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If you do not specify any function names, then the setting applies to all functions (and to all precisions).
However, as soon as you specify an individual function name, the setting applies only to the function of
corresponding precision. So, for example, sinf applies only to the single-precision sine function, sin applies
only to the double-precision sine function, sinl applies only to the extended-precision sine function, etc.
There are three options you can use to express the maximum relative error. They are as follows:
• [Q]fast-transcendentals
• [Q]prec-div
• [Q]prec-sqrt
• -fp-model (Linux and macOS*) or /fp (Windows)
NOTE
Many routines in libraries LIBM (Math Library) and SVML (Short Vector Math Library) are
more highly optimized for Intel® microprocessors than for non-Intel microprocessors.
NOTE
The standard Fortran names for the various math intrinsic functions do not match the math
library names of the math intrinsic functions. You must find the actual math library name
that is generated for the relevant Fortran math intrinsic.
One way to do this is to generate assembly code by using options /Fa or /S on Windows, or option -S
on Linux. The assembly code will show the actual math library name.
For example, if you create a program that contains a call to SIN(x) where x is declared as
REAL(KIND=4) and then use option /S on Windows to produce assembly code for the program, the
assembly code will show a call to sinf.
Therefore, to specify a level of accuracy for the single-precision sine function, you would specify
-fimf-precision=sinf (or /Qimf-precision:sinf).
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
IDE Equivalent
None
Alternate Options
None
330
Compiler Reference
See Also
fimf-absolute-error, Qimf-absolute-error compiler option
fimf-accuracy-bits, Qimf-accuracy-bits compiler option
fimf-arch-consistency, Qimf-arch-consistency compiler option
fimf-domain-exclusion, Qimf-domain-exclusion compiler option
fimf-max-error, Qimf-max-error compiler option
fast-transcendentals, Qfast-transcendentals compiler option
prec-div, Qprec-div compiler option
prec-sqrt, Qprec-sqrt compiler option
fp-model, fp compiler option
fimf-use-svml_Qimf-use-svml compiler option
fimf-use-svml, Qimf-use-svml
Instructs the compiler to use the Short Vector Math
Library (SVML) rather than the Intel® Math Library
(LIBM) to implement math library functions.
Syntax
Linux OS:
-fimf-use-svml=value[:funclist]
macOS:
-fimf-use-svml=value[:funclist]
Windows OS:
/Qimf-use-svml:value[:funclist]
Arguments
funclist Is an optional list of one or more math library functions to which the
attribute should be applied. Do not specify the standard Fortran name
of the math function; you must specify the actual math library name.
If you specify more than one function, they must be separated with
commas.
Precision-specific variants like sin and sinf are considered different
functions, so you would need to use
-fimf-use-svmlt=true:sin,sinf
(or /Qimf-use-svml:true:sin,sinf) to specify that both the
single-precision and double-precision sine functions should use SVML.
Default
false Math library functions are implemented using the Intel® Math Library, though other compiler
options such as -fast-transcendentals or /Qfast-transcendentals may give the compiler
the flexibility to implement math library functions with either LIBM or SVML.
331
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
This option instructs the compiler to implement math library functions using the Short Vector Math Library
(SVML). When you specify -fimf-use-svml=true or /Qimf-use-svml:true, the specific SVML variant
chosen is influenced by other compiler options such as -fimf-precision (Linux* and macOS*)
or /Qimf-precision (Windows*) and -fp-model (Linux and macOS*) or /fp (Windows). This option has
no effect on math library functions that are implemented in LIBM but not in SVML.
In value-safe settings of option -fp-model (Linux and macOS*) or option /fp (Windows) such as precise,
this option causes a slight decrease in the accuracy of math library functions, because even the high
accuracy SVML functions are slightly less accurate than the corresponding functions in LIBM. Additionally, the
SVML functions might not accurately raise floating-point exceptions, do not maintain errno, and are designed
to work correctly only in round-to-nearest-even rounding mode.
The benefit of using -fimf-use-svml=true or /Qimf-use-svml:true with value-safe settings of
-fp-model (Linux and macOS*) or /fp (Windows) is that it can significantly improve performance by
enabling the compiler to efficiently vectorize loops containing calls to math library functions.
If you need to use SVML for a specific math function of a certain precision, specify the function name of the
precision that you need. For example, if you want double precision, you can specify :sin; if you want single
precision, you can specify :sqrtf, as in -fimf-use-svml=true:sin or /Qimf-use-svml:true:sin, or
-fimf-use-svml =false:sqrtf or /Qimf-use-svml:false:sqrtf.
If you do not specify any function names, then the setting applies to all functions (and to all precisions).
However, as soon as you specify an individual function name, the setting applies only to the function of
corresponding precision. So, for example, sinf applies only to the single-precision sine function, sin applies
only to the double-precision sine function, sinl applies only to the extended-precision sine function, etc.
NOTE
If you specify option -mia32 (Linux*) or option /arch:IA32 (Windows*), vector instructions
cannot be used. Therefore, you cannot use Linux* option -mia32 with option
-fimf-use-svml=true, and you cannot use Windows* option /arch:IA32 with
option /Qimf-use-svml:true.
NOTE
Since SVML functions may raise unexpected floating-point exceptions, be cautious about
using features that enable trapping on floating-point exceptions. For example, be cautious
about specifying option -fimf-use-svml=true with option -fp-trap, or
option /Qimf-use-svml:true with option /Qfp-trap. For some inputs to some math library
functions, such option combinations may cause your program to trap unexpectedly.
332
Compiler Reference
NOTE
The standard Fortran names for the various math intrinsic functions do not match the math
library names of the math intrinsic functions. You must find the actual math library name
that is generated for the relevant Fortran math intrinsic.
One way to do this is to generate assembly code by using options /Fa or /S on Windows, or option -S
on Linux. The assembly code will show the actual math library name.
For example, if you create a program that contains a call to SIN(x) where x is declared as
REAL(KIND=4) and then use option /S on Windows to produce assembly code for the program, the
assembly code will show a call to sinf.
Therefore, to request the use of SVML for the single-precision sine function, you would specify
-fimf-use-svml=true: sinf (or /Qimf-use-svml:true: sinf).
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
IDE Equivalent
None
Alternate Options
None
See Also
fp-model, fp compiler option
m compiler option
arch compiler option
fltconsistency
Enables improved floating-point consistency.
Syntax
Linux OS:
-fltconsistency
-nofltconsistency
macOS:
-fltconsistency
-nofltconsistency
Windows OS:
/fltconsistency
/nofltconsistency
Arguments
None
333
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
Description
This option enables improved floating-point consistency and may slightly reduce execution speed. It limits
floating-point optimizations and maintains declared precision. It also disables inlining of math library
functions.
Floating-point operations are not reordered and the result of each floating-point operation is stored in the
target variable rather than being kept in the floating-point processor for use in a subsequent calculation.
For example, the compiler can change floating-point division computations into multiplication by the
reciprocal of the denominator. This change can alter the results of floating-point division computations
slightly.
Floating-point intermediate results are kept in full 80 bits internal precision. Additionally, all spills/reloads of
the X87 floating point registers are done using the internal formats; this prevents accidental loss of precision
due to spill/reload behavior over which you have no control.
Specifying this option has the following effects on program compilation:
This option causes performance degradation relative to using default floating-point optimization flags.
On Windows systems, an alternative is to use the /Qprec option, which should provide better than default
floating-point precision while still delivering good floating-point performance.
The recommended method to control the semantics of floating-point calculations is to use option -fp-model
(Linux* and macOS*) or /fp (Windows*).
IDE Equivalent
None
Alternate Options
334
Compiler Reference
Windows: None
Windows: None
See Also
mp1, Qprec compiler option
fp-model, fp compiler option
fma, Qfma
Determines whether the compiler generates fused
multiply-add (FMA) instructions if such instructions
exist on the target processor.
Syntax
Linux OS:
-fma
-no-fma
macOS:
-fma
-no-fma
Windows OS:
/Qfma
/Qfma-
Arguments
None
Default
-fma If the instructions exist on the target processor, the compiler generates fused multiply-
or /Qfma add (FMA) instructions.
However, if you specify -fp-model strict (Linux* and macOS*) or /fp:strict
(Windows*), but do not explicitly specify -fma or /Qfma, the default is -no-fma
or /Qfma-.
Description
This option determines whether the compiler generates fused multiply-add (FMA) instructions if such
instructions exist on the target processor. When the [Q]fma option is specified, the compiler may generate
FMA instructions for combining multiply and add operations. When the negative form of the [Q]fma option is
specified, the compiler must generate separate multiply and add instructions with intermediate rounding.
This option has no effect unless setting CORE-AVX2 or higher is specified for option [Q]x,-march (Linux and
macOS*), or /arch (Windows).
IDE Equivalent
None
335
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
fp-model, fp compiler option
x, Qx compiler option
ax, Qax compiler option
march compiler option
arch compiler option
fp-model, fp
Controls the semantics of floating-point calculations.
Syntax
Linux OS:
-fp-model=keyword
macOS:
-fp-model=keyword
Windows OS:
/fp:keyword
Arguments
consistent (ifort only) The compiler uses default heuristics to determine results for
different optimization levels or between different processors of
the same architecture.
[no-]except (Linux* and Determines whether strict floating-point exception semantics are
macOS*) or except[-] honored.
(Windows*) (ifort only)
Default
Description
This option controls the semantics of floating-point calculations.
The keywords can be considered in groups:
336
Compiler Reference
• You cannot specify fast and except together in the same compilation. You can specify any other
combination of group A, group B, and group C.
Since fast is the default, you must not specify except without a group A or group B keyword.
• You should specify only one keyword from group A and only one keyword from group B. If you try to
specify more than one keyword from either group A or group B, the last (rightmost) one takes effect.
• If you specify except more than once, the last (rightmost) one takes effect.
• If you specify consistent and any other keyword from another group, the last (rightmost) one may not
fully override the heuristics set by consistent.
NOTE
The fp-model=fast (or /fp:fast) options and the fp-model=fast=2 (or /fp:fast=2) options
behave differently with ifx and ifort.
With ifort, floating-point compares happen as specified by the IEEE floating-point standard, in that
the code sequence generated for them assumes a compare can involve a NaN.
ifx does not generate the check for NaN operands. If you want to use option fp-model=fast
(or /fp:fast) or option fp-model=fast=2 (or /fp:fast=2) with ifx and you want NaN compares to
match ifort’s behavior, specify option assume nan_compares on the command line.
The floating-point (FP) environment is a collection of registers that control the behavior of FP machine
instructions and indicate the current FP status. The floating-point environment may include rounding-mode
controls, exception masks, flush-to-zero controls, exception status flags, and other floating-point related
features.
Option Description
337
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Option Description
338
Compiler Reference
Option Description
-fp-model=except or /fp:except (ifort only) Tells the compiler to follow strict floating-point
exception semantics.
The -fp-model and /fp options determine the setting for the maximum allowable relative error for math
library function results (max-error) if none of the following options are specified (the following options are
only available for ifort):
NOTE
This option cannot be used to change the default (source) precision for the calculation of
intermediate results.
NOTE
In Microsoft* Visual Studio, when you create a Visual Studio* Fortran project,
option /fp:fast is set by default. It sets the floating-point model to use more aggressive
optimizations when implementing floating-point calculations, which increase speed, but may
affect the accuracy or reproducibility of floating-point computations. /fp:fast is the general
default for the IDE project property for Floating Point Model.
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
IDE Equivalent
Visual Studio
Visual Studio: Floating Point > Floating Point Model
Floating Point > Reliable Floating Point Exceptions Model
Alternate Options
None
See Also
O compiler option (specifically O0)
339
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Od compiler option
mp1, Qprec compiler option
fimf-absolute-error, Qimf-absolute-error compiler option
fimf-accuracy-bits, Qimf-accuracy-bits compiler option
fimf-max-error, Qimf-max-error compiler option
fimf-precision, Qimf-precision compiler option
fimf-domain-exclusion, Qimf-domain-exclusion compiler option
fast-transcendentals, Qfast-transcendentals compiler option
Supported Environment Variables
The article titled: Consistency of Floating-Point Results using the Intel® Compiler, which is located in https://
software.intel.com/content/www/us/en/develop/articles/consistency-of-floating-point-results-using-the-intel-
compiler.html
fp-port, Qfp-port
Rounds floating-point results after floating-point
operations. This feature is only available for ifort.
Syntax
Linux OS:
-fp-port
-no-fp-port
macOS:
-fp-port
-no-fp-port
Windows OS:
/Qfp-port
/Qfp-port-
Arguments
None
Default
-no-fp-port The default rounding behavior depends on the compiler's code generation decisions
or /Qfp-port- and the precision parameters of the operating system.
Description
This option rounds floating-point results after floating-point operations.
This option is designed to be used with the -mia32 (Linux*) or /arch:IA32 (Windows*) option on a 32-bit
compiler. Under those conditions, the compiler implements floating-point calculations using the x87
instruction set, which uses an internal precision that may be higher than the precision specified in the
program.
By default, the compiler may keep results of floating-point operations in this higher internal precision.
Rounding to program precision occurs at unspecified points. This provides better performance, but the
floating-point results are less deterministic. The [Q]fp-port option rounds floating-point results to user-
specified precision at assignments and type conversions. This has some impact on speed.
340
Compiler Reference
When compiling for newer architectures, the compiler implements floating-point calculations with different
instructions, such as Intel® SSE and SSE2. These Intel® Streaming SIMD Extensions round directly to single
precision or double precision at every instruction. In these cases, option [Q]fp-port has no effect.
IDE Equivalent
Windows
Visual Studio: Floating-Point > Round Floating-Point Results
Alternate Options
None
See Also
Understanding Floating-point Operations
fp-speculation, Qfp-speculation
Tells the compiler the mode in which to speculate on
floating-point operations.
Syntax
Linux OS:
-fp-speculation=mode
macOS:
-fp-speculation=mode
Windows OS:
/Qfp-speculation:mode
Arguments
Default
341
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
This option tells the compiler the mode in which to speculate on floating-point operations.
Disabling speculation may prevent the vectorization of some loops containing conditionals. For an example,
see the article titled: Diagnostic 15326: loop was not vectorized: implied FP exception model prevents
vectorization, which is located in https://software.intel.com/content/www/us/en/develop/articles/
fdiag15326.html .
IDE Equivalent
Visual Studio
Visual Studio: Floating Point > Floating-Point Speculation
Alternate Options
None
fp-stack-check, Qfp-stack-check
Tells the compiler to generate extra code after every
function call to ensure that the floating-point stack is
in the expected state. This feature is only available for
ifort.
Syntax
Linux OS:
-fp-stack-check
macOS:
-fp-stack-check
Windows OS:
/Qfp-stack-check
Arguments
None
Default
OFF There is no checking to ensure that the floating-point (FP) stack is in the expected state.
Description
This option tells the compiler to generate extra code after every function call to ensure that the floating-point
(FP) stack is in the expected state.
By default, there is no checking. So when the FP stack overflows, a NaN value is put into FP calculations and
the program's results differ. Unfortunately, the overflow point can be far away from the point of the actual
bug. This option places code that causes an access violation exception immediately after an incorrect call
occurs, thus making it easier to locate these issues.
IDE Equivalent
Windows
Visual Studio: Floating-Point > Check Floating-Point Stack
342
Compiler Reference
Alternate Options
None
fpe
Allows some control over floating-point exception
handling for the main program at run-time.
Syntax
Linux OS:
-fpen
macOS:
-fpen
Windows OS:
/fpe:n
Arguments
Underflow results from SSE instructions, as well as x87 instructions, will be set to zero.
By contrast, option [Q]ftz only sets SSE underflow results to zero.
NOTE
If you have more than one module, you must build each module,
including the main module, with value fpe0 (Linux) or fpe:0 (Windows) to
avoid floating-point exceptions that may occur within the modules.
343
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
Description
This option allows some control over floating-point exception handling at run-time. This includes whether
exceptional floating-point values are allowed and how precisely run-time exceptions are reported.
The fpe option affects how the following conditions are handled:
When enabled exceptions occur, execution is aborted and the cause of the abort reported to the user. If
compiler option traceback is specified at compile time, detailed information about the location of the abort
is also reported.
This option does not enable underflow exceptions, input subnormal exceptions, or inexact exceptions.
IDE Equivalent
Visual Studio
Visual Studio: Floating-Point > Floating-Point Exception Handling
Alternate Options
None
See Also
fpe-all compiler option
ftz, Qftz compiler option
fp-model, fp compiler option
fp-speculation, Qfp-speculation compiler option
traceback compiler option
fpe-all
Allows some control over floating-point exception
handling for each routine in a program at run-time.
Syntax
Linux OS:
-fpe-all=n
macOS:
-fpe-all=n
344
Compiler Reference
Windows OS:
/fpe-all:n
Arguments
0 Floating-point invalid, divide-by-zero, and overflow exceptions are enabled. If any such
exceptions occur, execution is aborted. This option sets the [Q]ftz option; therefore
underflow results will be set to zero unless you explicitly specify -no-ftz (Linux and
macOS*) or /Qftz- (Windows).
To get more detailed location information about where the error occurred, use option
traceback.
Default
-fpe-all=3 or /fpe-all:3 or the All floating-point exceptions are disabled. Floating-point underflow is
setting of fpe that the main gradual, unless you explicitly specify a compiler option that enables
program was compiled with flush-to-zero.
Description
This option allows some control over floating-point exception handling for each routine in a program at run-
time. This includes whether exceptional floating-point values are allowed and how precisely run-time
exceptions are reported.
The fpe-all option affects how the following conditions are handled:
The current settings of the floating-point exception and status flags are saved on each routine entry and
restored on each routine exit. This may incur some performance overhead.
When option fpe-all is applied to a main program, it has the same effect as when option fpe is applied to
the main program.
When enabled exceptions occur, execution is aborted and the cause of the abort reported to the user. If
compiler option traceback is specified at compile time, detailed information about the location of the abort
is also reported.
This option does not enable underflow exceptions, input subnormal exceptions, or inexact exceptions.
Option fpe-all sets option assume ieee_fpe_flags.
IDE Equivalent
None
345
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Alternate Options
None
See Also
assume compiler option
fpe compiler option
ftz, Qftz compiler option
traceback compiler option
ftz, Qftz
Flushes subnormal results to zero.
Syntax
Linux OS:
-ftz
-no-ftz
macOS:
-ftz
-no-ftz
Windows OS:
/Qftz
/Qftz-
Arguments
None
Default
Description
This option flushes subnormal results to zero when the application is in the gradual underflow mode. It may
improve performance if the subnormal values are not critical to your application's behavior.
The [Q]ftz option has no effect during compile-time optimization.
The [Q]ftz option sets or resets the FTZ and the DAZ hardware flags. If FTZ is ON, subnormal results from
floating-point calculations will be set to the value zero. If FTZ is OFF, subnormal results remain as is. If DAZ
is ON, subnormal values used as input to floating-point instructions will be treated as zero. If DAZ is OFF,
subnormal instruction inputs remain as is. Systems using Intel® 64 architecture have both FTZ and DAZ. FTZ
and DAZ are not supported on all IA-32 architectures.
When the [Q]ftz option is used in combination with an SSE-enabling option on systems using IA-32
architecture (for example, the [Q]xSSE2 option), the compiler will insert code in the main routine to set FTZ
and DAZ. When [Q]ftz is used without such an option, the compiler will insert code to conditionally set
FTZ/DAZ based on a run-time processor check.
346
Compiler Reference
If you specify option -no-ftz (Linux and macOS*) or option /Qftz- (Windows), it prevents the compiler
from inserting any code that might set FTZ or DAZ.
Option [Q]ftz only has an effect when the main program is being compiled. It sets the FTZ/DAZ mode for
the process. The initial thread and any threads subsequently created by that process will operate in FTZ/DAZ
mode.
If this option produces undesirable results of the numerical behavior of your program, you can turn the
FTZ/DAZ mode off by specifying -no-ftz or /Qftz- in the command line while still benefiting from the O3
optimizations.
NOTE
Option [Q]ftz is a performance option. Setting this option does not guarantee that all
subnormals in a program are flushed to zero. The option only causes subnormals generated
at run time to be flushed to zero.
IDE Equivalent
Windows
Visual Studio: IA-32 architecture: Floating Point > Flush Subnormal Results to Zero
Intel® 64 architecture: None
Alternate Options
None
See Also
x, Qx compiler option
Setting the FTZ and DAZ Flags
Ge
Enables stack-checking for all functions. This is a
deprecated option. The replacement option is /Gs0.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/Ge
Arguments
None
Default
Description
This option enables stack-checking for all functions.
347
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IDE Equivalent
None
Alternate Options
Linux and macOS*: None
Windows: /Gs0
mp1, Qprec
Improves floating-point precision and consistency.
This feature is only available for ifort.
Syntax
Linux OS:
-mp1
macOS:
-mp1
Windows OS:
/Qprec
Arguments
None
Default
OFF The compiler provides good accuracy and run-time performance at the expense of less consistent
floating-point results.
Description
This option improves floating-point consistency. It ensures the out-of-range check of operands of
transcendental functions and improves the accuracy of floating-point compares.
This option prevents the compiler from performing optimizations that change NaN comparison semantics and
causes all values to be truncated to declared precision before they are used in comparisons. It also causes
the compiler to use library routines that give better precision results compared to the X87 transcendental
instructions.
This option disables fewer optimizations and has less impact on performance than option fltconsistency.
This option disables fewer optimizations and has less impact on performance than option
fltconsistency,-fp-model precise (Linux* and macOS*), or option /fp:precise (Windows*).
IDE Equivalent
None
Alternate Options
None
See Also
fltconsistency compiler option
348
Compiler Reference
pc, Qpc
Enables control of floating-point significand precision.
Syntax
Linux OS:
-pcn
macOS:
-pcn
Windows OS:
/Qpcn
Arguments
Default
Description
This option enables control of floating-point significand precision.
Some floating-point algorithms are sensitive to the accuracy of the significand, or fractional part of the
floating-point value. For example, iterative operations like division and finding the square root can run faster
if you lower the precision with the this option.
Note that a change of the default precision control or rounding mode, for example, by using the [Q]pc32
option or by user intervention, may affect the results returned by some of the mathematical functions.
IDE Equivalent
None
Alternate Options
None
prec-div, Qprec-div
Improves precision of floating-point divides. This
feature is only available for ifort.
349
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-prec-div
-no-prec-div
macOS:
-prec-div
-no-prec-div
Windows OS:
/Qprec-div
/Qprec-div-
Arguments
None
Default
OFF Default heuristics are used. The default is not as accurate as full IEEE division, but it is
slightly more accurate than would be obtained when /Qprec-div- or -no-prec-div
is specified.
If you need full IEEE precision for division, you should specify [Q]prec-div.
Description
This option improves precision of floating-point divides. It has a slight impact on speed.
At default optimization levels, the compiler may change floating-point division computations into
multiplication by the reciprocal of the denominator. For example, A/B is computed as A * (1/B) to improve
the speed of the computation.
However, sometimes the value produced by this transformation is not as accurate as full IEEE division. When
it is important to have fully precise IEEE division, use this option to disable the floating-point division-to-
multiplication optimization. The result is more accurate, with some loss of performance.
If you specify -no-prec-div (Linux* and macOS*) or /Qprec-div- (Windows*), it enables optimizations
that give slightly less precise results than full IEEE division.
Option [Q]prec-div is implied by option -fp-model precise (Linux* and macOS*) and
option /fp:precise (Windows*).
IDE Equivalent
None
Alternate Options
None
See Also
fp-model, fp compiler option
prec-sqrt, Qprec-sqrt
Improves precision of square root implementations.
This feature is only available for ifort.
350
Compiler Reference
Syntax
Linux OS:
-prec-sqrt
-no-prec-sqrt
macOS:
-prec-sqrt
-no-prec-sqrt
Windows OS:
/Qprec-sqrt
/Qprec-sqrt-
Arguments
None
Default
-no-prec-sqrt The compiler uses a faster but less precise implementation of square root.
or /Qprec-sqrt- However, the default is -prec-sqrt or /Qprec-sqrt if any of the following options
are specified: /Od, /fltconsistency, or /Qprec on Windows* systems; -O0,
-fltconsistency, or -mp1 on Linux* and macOS* systems.
Description
This option improves precision of square root implementations. It has a slight impact on speed.
This option inhibits any optimizations that can adversely affect the precision of a square root computation.
The result is fully precise square root implementations, with some loss of performance.
IDE Equivalent
None
Alternate Options
None
qsimd-honor-fp-model, Qsimd-honor-fp-model
Tells the compiler to obey the selected floating-point
model when vectorizing SIMD loops. This feature is
only available for ifort.
Syntax
Linux OS:
-qsimd-honor-fp-model
-qno-simd-honor-fp-model
macOS:
-qsimd-honor-fp-model
-qno-simd-honor-fp-model
351
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows OS:
/Qsimd-honor-fp-model
/Qsimd-honor-fp-model-
Arguments
None
Default
Description
The OpenMP* SIMD specification and the setting of compiler option -fp-model (Linux* and macOS*) or /fp
(Windows*) can contradict in requirements. When contradiction occurs, the default behavior of the compiler
is to follow the OpenMP* specification and therefore vectorize the loop.
This option lets you override this default behavior - it causes the compiler to follow the -fp-model (or /fp)
specification. This means that the compiler will serialize the loop.
NOTE
This option does not affect automatic vectorization of loops. By default, the compiler uses
-fp-model (Linux* and macOS*) or /fp (Windows*) settings for this.
IDE Equivalent
None
Alternate Options
None
See Also
qsimd-serialize-fp-reduction, Qsimd-serialize-fp-reduction compiler option
fp-model, fp compiler option
SIMD Loop Directive directive
SIMD Directive (OpenMP* API) directive
qsimd-serialize-fp-reduction, Qsimd-serialize-fp-reduction
Tells the compiler to serialize floating-point reduction
when vectorizing SIMD loops. This feature is only
available for ifort.
Syntax
Linux OS:
-qsimd-serialize-fp-reduction
-qno-simd-serialize-fp-reduction
macOS:
-qsimd-serialize-fp-reduction
-qno-simd-serialize-fp-reduction
352
Compiler Reference
Windows OS:
/Qsimd-serialize-fp-reduction
/Qsimd-serialize-fp-reduction-
Arguments
None
Default
Description
The OpenMP* SIMD reduction specification and the setting of compiler option -fp-model (Linux* and
macOS*) or /fp (Windows*) can contradict in requirements. When contradiction occurs, the default behavior
of the compiler is to follow OpenMP* specification and therefore vectorize the loop, including floating-point
reduction.
This option lets you override this default behavior - it causes the compiler to follow the -fp-model (or /fp)
specification. This means that the compiler will serialize the floating-point reduction while vectorizing the rest
of the loop.
NOTE
When [q or Q]simd-honor-fp-model is specified and OpenMP* SIMD reduction specification
is the only thing causing serialization of the entire loop, addition of option
[q or Q]simd-serialize-fp-reduction will result in vectorization of the entire loop except
for reduction calculation, which will be serialized.
NOTE
This option does not affect automatic vectorization of loops. By default, the compiler uses
-fp-model (Linux* and macOS*) or /fp (Windows*) settings for this.
IDE Equivalent
None
Alternate Options
None
See Also
qsimd-honor-fp-model, Qsimd-honor-fp-model compiler option
fp-model, fp compiler option
SIMD Loop Directive directive
SIMD Directive (OpenMP* API) directive
rcd, Qrcd
Enables fast float-to-integer conversions. This is a
deprecated option. There is no replacement option.
This feature is only available for ifort.
353
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-rcd
macOS:
-rcd
Windows OS:
/Qrcd
Arguments
None
Default
Description
This option enables fast float-to-integer conversions. It can improve the performance of code that requires
floating-point-to-integer conversions.
The system default floating-point rounding mode is round-to-nearest. However, the Fortran language
requires floating-point values to be truncated when a conversion to an integer is involved. To do this, the
compiler must change the rounding mode to truncation before each floating-point-to-integer conversion and
change it back afterwards.
This option disables the change to truncation of the rounding mode for all floating-point calculations,
including floating point-to-integer conversions. This option can improve performance, but floating-point
conversions to integer will not conform to Fortran semantics.
IDE Equivalent
None
Alternate Options
Linux and macOS*: None
Windows: /QIfist (this is a deprecated option)
recursive
Tells the compiler that all routines should be compiled
for possible recursive execution.
Syntax
Linux OS:
-recursive
-norecursive
macOS:
-recursive
-norecursive
354
Compiler Reference
Windows OS:
/recursive
/norecursive
Arguments
None
Default
Description
This option tells the compiler that all routines should be compiled for possible recursive execution. It sets the
automatic option.
NOTE
This option will be deprecated in a future release. We recommend you use its replacement
option: assume [no]recursion.
IDE Equivalent
Windows
Visual Studio: Code Generation > Enable Recursive Routines
Alternate Options
Linux and macOS*: -assume [no]recursion
Windows: /assume:[no]recursion
See Also
auto compiler option
assume compiler option, setting [no]recursion
Inlining Options
This section contains descriptions for compiler options that pertain to inlining.
finline
Tells the compiler to inline functions declared with !
DIR$ ATTRIBUTES FORCEINLINE.
Syntax
Linux OS:
-finline
-fno-inline
macOS:
-finline
-fno-inline
355
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows OS:
None
Arguments
None
Default
-fno-inline The compiler does not inline functions declared with !DIR$ ATTRIBUTES FORCEINLINE.
Description
This option tells the compiler to inline functions declared with !DIR$ ATTRIBUTES FORCEINLINE.
IDE Equivalent
None
Alternate Options
Linux and macOS*: -inline-level
Windows: /Ob
finline-functions
Enables function inlining for single file compilation.
Syntax
Linux OS:
-finline-functions
-fno-inline-functions
macOS:
-finline-functions
-fno-inline-functions
Windows OS:
None
Arguments
None
Default
-finline-functions Interprocedural optimizations occur. However, if you specify -O0, the default
is OFF.
Description
This option enables function inlining for single file compilation.
It enables the compiler to perform inline function expansion for calls to functions defined within the current
source file.
356
Compiler Reference
The compiler applies a heuristic to perform the function expansion. To specify the size of the function to be
expanded, use the -finline-limit option.
IDE Equivalent
None
Alternate Options
Linux and macOS*: -inline-level=2
Windows: /Ob2
See Also
ip, Qip compiler option
finline-limit compiler option
finline-limit
Lets you specify the maximum size of a function to be
inlined.
Syntax
Linux OS:
-finline-limit=n
macOS:
-finline-limit=n
Windows OS:
None
Arguments
Default
Description
This option lets you specify the maximum size of a function to be inlined. The compiler inlines smaller
functions, but this option lets you inline large functions. For example, to indicate a large function, you could
specify 100 or 1000 for n.
Note that parts of functions cannot be inlined, only whole functions.
This option is a modification of the -finline-functions option, whose behavior occurs by default.
IDE Equivalent
None
Alternate Options
None
357
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
finline-functions compiler option
inline
Specifies the level of inline function expansion.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/inline[:keyword]
Arguments
none Disables inlining of user-defined functions. This is the same as specifying manual.
manual Disables inlining of user-defined functions. Fortran statement functions are always
inlined.
size Enables inlining of any function. However, the compiler decides which functions
are inlined.
This option enables interprocedural optimizations and most speed optimizations.
speed Enables inlining of any function. This is the same as specifying all.
all Enables inlining of any function. However, the compiler decides which functions
are inlined.
This option enables interprocedural optimizations and all speed optimizations. This
is the same as specifying inline with no keyword.
Default
Description
This option specifies the level of inline function expansion.
IDE Equivalent
None
Alternate Options
358
Compiler Reference
Windows: /Ob2/Os
See Also
finline-functions compiler option
inline-factor, Qinline-factor
Specifies the percentage multiplier that should be
applied to all inlining options that define upper limits.
This feature is only available for ifort.
Syntax
Linux OS:
-inline-factor=n
-no-inline-factor
macOS:
-inline-factor=n
-no-inline-factor
Windows OS:
/Qinline-factor:n
/Qinline-factor-
Arguments
Default
Description
This option specifies the percentage multiplier that should be applied to all inlining options that define upper
limits:
• [Q]inline-max-size
• [Q]inline-max-total-size
• [Q]inline-max-per-routine
• [Q]inline-max-per-compile
The [Q]inline-factor option takes the default value for each of the above options and multiplies it by n
divided by 100. For example, if 200 is specified, all inlining options that define upper limits are multiplied by
a factor of 2. This option is useful if you do not want to individually increase each option limit.
359
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If you specify -no-inline-factor (Linux* and macOS*) or /Qinline-factor- (Windows*), the following
occurs:
• Every function is considered to be a small or medium function; there are no large functions.
• There is no limit to the size a routine may grow when inline expansion is performed.
• There is no limit to the number of times some routine may be inlined into a particular routine.
• There is no limit to the number of times inlining can be applied to a compilation unit.
To see compiler values for important inlining limits, specify option [q or Q]opt-report.
Caution
When you use this option to increase default limits, the compiler may do so much additional
inlining that it runs out of memory and terminates with an "out of memory" message.
IDE Equivalent
None
Alternate Options
None
See Also
inline-max-size, Qinline-max-size compiler option
inline-max-total-size, Qinline-max-total-size compiler option
inline-max-per-routine, Qinline-max-per-routine compiler option
inline-max-per-compile, Qinline-max-per-compile compiler option
qopt-report, Qopt-report compiler option
inline-forceinline, Qinline-forceinline
Instructs the compiler to force inlining of functions
suggested for inlining whenever the compiler is
capable doing so. This feature is only available for
ifort.
Syntax
Linux OS:
-inline-forceinline
macOS:
-inline-forceinline
Windows OS:
/Qinline-forceinline
Default
OFF The compiler uses default heuristics for inline routine expansion.
Description
This option instructs the compiler to force inlining of functions suggested for inlining whenever the compiler
is capable doing so.
360
Compiler Reference
Without this option, the compiler treats functions declared with an INLINE attribute as merely being
recommended for inlining. When this option is used, it is as if they were declared with the directive !DIR$
ATTRIBUTES FORCEINLINE.
To see compiler values for important inlining limits, specify option [q or Q]opt-report.
Caution
When you use this option to change the meaning of inline to "forceinline", the compiler may
do so much additional inlining that it runs out of memory and terminates with an "out of
memory" message.
IDE Equivalent
None
Alternate Options
None
See Also
qopt-report, Qopt-report compiler option
inline-level, Ob
Specifies the level of inline function expansion.
Syntax
Linux OS:
-inline-level=n
macOS:
-inline-level=n
Windows OS:
/Obn
Arguments
Default
-inline-level=0 or /Ob0 This is the default if option -O0 (Linux* and macOS*) or /Od
(Windows*) is specified.
Description
This option specifies the level of inline function expansion. Inlining procedures can greatly improve the run-
time performance of certain programs.
361
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Option Description
-inline-level=0 or /Ob0 Disables inlining of user-defined functions. Note that statement functions
are always inlined.
-inline-level=1 or /Ob1 Enables inlining when an inline keyword or an inline directive is specified.
IDE Equivalent
Windows
Visual Studio: Optimization > Inline Function Expansion
Alternate Options
None
See Also
inline compiler option
inline-max-per-compile, Qinline-max-per-compile
Specifies the maximum number of times inlining may
be applied to an entire compilation unit. This feature is
only available for ifort.
Syntax
Linux OS:
-inline-max-per-compile=n
-no-inline-max-per-compile
macOS:
-inline-max-per-compile=n
-no-inline-max-per-compile
Windows OS:
/Qinline-max-per-compile=n
/Qinline-max-per-compile-
Arguments
Default
-no-inline-max-per-compile The compiler uses default heuristics for inline routine expansion.
or /Qinline-max-per-compile-
Description
This option the maximum number of times inlining may be applied to an entire compilation unit. It limits the
number of times that inlining can be applied.
362
Compiler Reference
For compilations using Interprocedural Optimizations (IPO), the entire compilation is a compilation unit. For
other compilations, a compilation unit is a file.
If you specify -no-inline-max-per-compile (Linux* and macOS*) or /Qinline-max-per-compile-
(Windows*), there is no limit to the number of times inlining may be applied to a compilation unit.
To see compiler values for important inlining limits, specify option [q or Q]opt-report.
Caution
When you use this option to increase the default limit, the compiler may do so much
additional inlining that it runs out of memory and terminates with an "out of memory"
message.
IDE Equivalent
None
Alternate Options
None
See Also
inline-factor, Qinline-factor compiler option
qopt-report, Qopt-report compiler option
inline-max-per-routine, Qinline-max-per-routine
Specifies the maximum number of times the inliner
may inline into a particular routine. This feature is
only available for ifort.
Syntax
Linux OS:
-inline-max-per-routine=n
-no-inline-max-per-routine
macOS:
-inline-max-per-routine=n
-no-inline-max-per-routine
Windows OS:
/Qinline-max-per-routine=n
/Qinline-max-per-routine-
Arguments
Default
-no-inline-max-per-routine The compiler uses default heuristics for inline routine expansion.
or /Qinline-max-per-routine-
363
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
This option specifies the maximum number of times the inliner may inline into a particular routine. It limits
the number of times that inlining can be applied to any routine.
If you specify -no-inline-max-per-routine (Linux* and macOS*) or /Qinline-max-per-routine-
(Windows*), there is no limit to the number of times some routine may be inlined into a particular routine.
To see compiler values for important inlining limits, specify option [q or Q]opt-report.
Caution
When you use this option to increase the default limit, the compiler may do so much
additional inlining that it runs out of memory and terminates with an "out of memory"
message.
IDE Equivalent
None
Alternate Options
None
See Also
inline-factor, Qinline-factor compiler option
qopt-report, Qopt-report compiler option
inline-max-size, Qinline-max-size
Specifies the lower limit for the size of what the inliner
considers to be a large routine. This feature is only
available for ifort.
Syntax
Linux OS:
-inline-max-size=n
-no-inline-max-size
macOS:
-inline-max-size=n
-no-inline-max-size
Windows OS:
/Qinline-max-size=n
/Qinline-max-size-
Arguments
364
Compiler Reference
Default
-inline-max-size The compiler sets the maximum size (n) dynamically, based on
or /Qinline-max-size the platform.
Description
This option specifies the lower limit for the size of what the inliner considers to be a large routine (a function
or subroutine). The inliner classifies routines as small, medium, or large. This option specifies the boundary
between what the inliner considers to be medium and large-size routines.
The inliner prefers to inline small routines. It has a preference against inlining large routines. So, any large
routine is highly unlikely to be inlined.
If you specify -no-inline-max-size (Linux* and macOS*) or /Qinline-max-size- (Windows*), there are
no large routines. Every routine is either a small or medium routine.
To see compiler values for important inlining limits, specify option [q or Q]opt-report.
Caution
When you use this option to increase the default limit, the compiler may do so much
additional inlining that it runs out of memory and terminates with an "out of memory"
message.
IDE Equivalent
None
Alternate Options
None
See Also
inline-min-size, Qinline-min-size compiler option
inline-factor, Qinline-factor compiler option
qopt-report, Qopt-report compiler option
inline-max-total-size, Qinline-max-total-size
Specifies how much larger a routine can normally
grow when inline expansion is performed. This feature
is only available for ifort.
Syntax
Linux OS:
-inline-max-total-size=n
-no-inline-max-total-size
macOS:
-inline-max-total-size=n
-no-inline-max-total-size
Windows OS:
/Qinline-max-total-size=n
/Qinline-max-total-size-
365
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Arguments
Default
-no-inline-max-total-size The compiler uses default heuristics for inline routine expansion.
or /Qinline-max-total-size-
Description
This option specifies how much larger a routine can normally grow when inline expansion is performed. It
limits the potential size of the routine. For example, if 2000 is specified for n, the size of any routine will
normally not increase by more than 2000.
If you specify -no-inline-max-total-size (Linux* and macOS*) or /Qinline-max-total-size-
(Windows*), there is no limit to the size a routine may grow when inline expansion is performed.
To see compiler values for important inlining limits, specify option [q or Q]opt-report.
Caution
When you use this option to increase the default limit, the compiler may do so much
additional inlining that it runs out of memory and terminates with an "out of memory"
message.
IDE Equivalent
None
Alternate Options
None
See Also
inline-factor, Qinline-factor compiler option
qopt-report, Qopt-report compiler option
inline-min-caller-growth, Qinline-min-caller-growth
Lets you specify a procedure size n for which
procedures of size <= n do not contribute to the
estimated growth of the caller when inlined. This
feature is only available for ifort.
Syntax
Linux OS:
-inline-min-caller-growth=n
macOS:
-inline-min-caller-growth=n
Windows OS:
/Qinline-min-caller-growth=n
366
Compiler Reference
Arguments
Default
Description
This option lets you specify a procedure size n for which procedures of size <= n do not contribute to the
estimated growth of the caller when inlined. It allows you to inline procedures that the compiler would
otherwise consider too large to inline.
NOTE
We recommend that you choose a value of n <= 10; otherwise, compile time and code size
may greatly increase.
IDE Equivalent
None
Alternate Options
None
inline-min-size, Qinline-min-size
Specifies the upper limit for the size of what the
inliner considers to be a small routine. This feature is
only available for ifort.
Syntax
Linux OS:
-inline-min-size=n
-no-inline-min-size
macOS:
-inline-min-size=n
-no-inline-min-size
Windows OS:
/Qinline-min-size=n
/Qinline-min-size-
Arguments
367
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
-no-inline-min-size The compiler uses default heuristics for inline routine expansion.
or /Qinline-min-size-
Description
This option specifies the upper limit for the size of what the inliner considers to be a small routine (a function
or subroutine). The inliner classifies routines as small, medium, or large. This option specifies the boundary
between what the inliner considers to be small and medium-size routines.
The inliner has a preference to inline small routines. So, when a routine is smaller than or equal to the
specified size, it is very likely to be inlined.
If you specify -no-inline-min-size (Linux* and macOS*) or /Qinline-min-size- (Windows*), there is
no limit to the size of small routines. Every routine is a small routine; there are no medium or large routines.
To see compiler values for important inlining limits, specify option [q or Q]opt-report.
Caution
When you use this option to increase the default limit, the compiler may do so much
additional inlining that it runs out of memory and terminates with an "out of memory"
message.
IDE Equivalent
None
Alternate Options
None
See Also
inline-max-size, Qinline-max-size compiler option
qopt-report, Qopt-report compiler option
Qinline-dllimport
Determines whether dllimport functions are inlined.
This feature is only available for ifort.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/Qinline-dllimport
/Qinline-dllimport-
Arguments
None
368
Compiler Reference
Default
Description
This option determines whether dllimport functions are inlined. To disable dllimport functions from being
inlined, specify /Qinline-dllimport-.
IDE Equivalent
None
Alternate Options
None
bintext
Places a text string into the object file (.obj) being
generated by the compiler. This feature is only
available for ifort.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/bintext:string
/nobintext
Arguments
Default
Description
This option places a text string into the object file (.obj) being generated by the compiler. The string also
gets propagated into the executable file.
For example, this option is useful if you want to place a version number or copyright information into the
object and executable.
If the string contains a space or tab, the string must be enclosed by double quotation marks ("). A backslash
(\) must precede any double quotation marks contained within the string.
369
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If the command line contains multiple /bintext options, the last (rightmost) one is used.
IDE Equivalent
Windows
Visual Studio: Code Generation > Object Text String
Alternate Options
Linux and macOS*: None
Windows: /Vstring
c
Prevents linking.
Syntax
Linux OS:
-c
macOS:
-c
Windows OS:
/c
Arguments
None
Default
Description
This option prevents linking. Compilation stops after the object file is generated.
The compiler generates an object file for each Fortran source file.
IDE Equivalent
None
Alternate Options
Linux and macOS*: None
Windows: /compile-only, /nolink
Syntax
Linux OS:
-debug [keyword]
370
Compiler Reference
macOS:
-debug [keyword]
Windows OS:
None
Arguments
For information on the non-default settings for these keywords, see the Description section.
Default
Description
This option enables or disables generation of debugging information.
By default, enabling debugging, will disable optimization. To enable both debugging and optimization use the
-debug option together with one of the optimization level options (-O3, -O2 or -O3).
Keywords semantic-stepping, inline-debug-info, variable-locations, and extended can be used in
combination with each other. If conflicting keywords are used in combination, the last one specified on the
command line has precedence.
371
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Option Description
-debug full or -debug all Generates complete debugging information. It is the same as specifying
-debug with no keyword.
-debug pubnames The compiler generates a DWARF debug_pubnames section. This provides
a means to list the names of global objects and functions in a compilation
unit.
-debug semantic-stepping Generates enhanced debug information useful for breakpoints and
stepping. It tells the debugger to stop only at machine instructions that
achieve the final effect of a source statement.
For example, in the case of an assignment statement, this might be a
store instruction that assigns a value to a program variable; for a function
call, it might be the machine instruction that executes the call. Other
instructions generated for those source statements are not displayed
during stepping.
This option has no impact unless optimizations have also been enabled.
-debug variable-locations Generates enhanced debug information useful in finding scalar local
variables. It uses a feature of the Dwarf object module known as
"location lists".
This feature allows the run-time locations of local scalar variables to be
specified more accurately; that is, whether, at a given position in the
code, a variable value is found in memory or a machine register.
-debug parallel Generates parallel debug code instrumentations needed for the thread
data sharing and reentrant call detection.
On Linux* systems, debuggers read debug information from executable images. As a result, information is
written to object files and then added to the executable by the linker.
On macOS* systems, debuggers read debug information from object files. As a result, the executables don't
contain any debug information. Therefore, if you want to be able to debug on these systems, you must retain
the object files.
372
Compiler Reference
IDE Equivalent
None
Alternate Options
Windows: None
Windows: None
See Also
debug (Windows*) compiler option
qopenmp, Qopenmp compiler option
debug (Windows*)
Enables or disables generation of debugging
information.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/debug[:keyword]
/nodebug
Arguments
For information on the non-default settings for these keywords, see the Description section.
Default
/debug:none This is the default on the command line and for a release configuration in the IDE.
373
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
This option enables or disables generation of debugging information. It is passed to the linker.
By default, enabling debugging, will disable optimization. To enable both debugging and optimization use
the /debug option together with one of the optimization level options (/O3, /O2 or /O3).
If conflicting keywords are used in combination, the last one specified on the command line has precedence.
Option Description
IDE Equivalent
Windows
Visual Studio: General > Debug Information Format (/debug:minimal, /debug:full)
Alternate Options
See Also
dbglibs compiler option
debug (Linux* and macOS*) compiler option
debug-parameters
Tells the compiler to generate debug information for
PARAMETERs used in a program.
Syntax
Linux OS:
-debug-parameters [keyword]
374
Compiler Reference
-nodebug-parameters
macOS:
-debug-parameters [keyword]
-nodebug-parameters
Windows OS:
/debug-parameters[:keyword]
/nodebug-parameters
Arguments
keyword Specifies the PARAMETERs to generate debug information for. Possible values are:
none Generates no debug information for any PARAMETERs used in the program.
This is the same as specifying nodebug-parameters.
used Generates debug information for only PARAMETERs that have actually been
referenced in the program. This is the default if you do not specify a
keyword.
all Generates debug information for all PARAMETERs defined in the program.
Default
nodebug-parameters The compiler generates no debug information for any PARAMETERs used in
the program. This is the same as specifying keyword none.
Description
This option tells the compiler to generate debug information for PARAMETERs used in a program.
Note that if a .mod file contains PARAMETERs, debug information is only generated for the PARAMETERs that
have actually been referenced in the program, even if you specify keyword all.
IDE Equivalent
Windows
Visual Studio: Debugging > Information for PARAMETER Constants
Alternate Options
None
exe
Specifies the name for a built program or dynamic-link
library.
Syntax
Linux OS:
None
macOS:
None
375
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows OS:
/exe:{filename | dir}
Arguments
dir Is the directory where the built program or dynamic-link library should be placed. It can
include filename.
Default
OFF The name of the file is the name of the first source file on the command line with file
extension .exe, so file.f becomes file.exe.
Description
This option specifies the name for a built program (.EXE) or a dynamic-link library (.DLL).
You can use this option to specify an alternate name for an executable file. This is especially useful when
compiling and linking a set of input files. You can use the option to give the resulting file a name other than
that of the first input file (source or object) on the command line.
You can use this option to specify an alternate name for an executable file. This is especially useful when
compiling and linking a set of input files. You can use the option to give the resulting file a name other than
that of the first input file (source or object) on the command line.
IDE Equivalent
None
Alternate Options
Linux and macOS*: -o
Windows: /Fe
Example
The following example creates a dynamic-link library file named file.dll (note that you can use /LD in place
of /dll):
See Also
o compiler option
Fa
Specifies that an assembly listing file should be
generated.
376
Compiler Reference
Syntax
Linux OS:
-Fa[filename|dir]
macOS:
-Fa[filename|dir]
Windows OS:
/Fa[filename|dir]
Arguments
dir Is the directory where the file should be placed. It can include
filename.
Default
Description
This option specifies that an assembly listing file should be generated (optionally named filename).
If filename is not specified, the file name will be the name of the source file with an extension of .asm; the
file is placed in the current directory.
IDE Equivalent
Windows
Visual Studio: Output > ASM Listing Name
Alternate Options
Linux and macOS*: -S
FA
Specifies the contents of an assembly listing file.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/FA[specifier]
Arguments
specifier Denotes the contents of the assembly listing file. Possible values are c, s, or cs.
377
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
OFF No source or machine code annotations appear in the assembly listing file, if one is produced.
Description
These options specify what information, in addition to the assembly code, should be generated in the
assembly listing file.
To use this option, you must also specify option /Fa, which causes an assembly listing to be generated.
Option Description
/FAcs Produces an assembly listing with source and machine code annotations.
The assembly listing file shows the source code as interspersed
comments and shows the hex machine instructions at the beginning of
each line of assembly code. This file cannot be assembled.
IDE Equivalent
Windows
Visual Studio: Output Files > Assembler Output
Alternate Options
Windows: None
Windows: None
fcode-asm
Produces an assembly listing with machine code
annotations. This feature is only available for ifort.
Syntax
Linux OS:
-fcode-asm
378
Compiler Reference
macOS:
-fcode-asm
Windows OS:
None
Arguments
None
Default
OFF No machine code annotations appear in the assembly listing file, if one is produced.
Description
This option produces an assembly listing file with machine code annotations.
The assembly listing file shows the hex machine instructions at the beginning of each line of assembly code.
The file cannot be assembled; the file name is the name of the source file with an extension of .cod.
To use this option, you must also specify option -S, which causes an assembly listing to be generated.
IDE Equivalent
None
Alternate Options
Linux and macOS*: None
Windows: /FAc
See Also
S compiler option
Fd
Lets you specify a name for a program database
(PDB) file created by the compiler. This feature is only
available for ifort.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/Fd[:filename]
Arguments
filename Is the name for the PDB file. It can include a path. If you do not
specify a file extension, the extension .pdb is used.
379
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
OFF No PDB file is created unless you specify option /Zi. If you specify option /Zi and /Fd, the
default filename is vcx0.pdb, where x represents the version of Visual C++, for example
vc100.pdb.
Description
This option lets you specify a name for a program database (PDB) file that is created by the compiler.
A program database (PDB) file holds debugging and project state information that allows incremental linking
of a Debug configuration of your program. A PDB file is created when you build with option /Zi. Option /Fd
has no effect unless you specify option /Zi.
IDE Equivalent
Windows
Visual Studio: Output Files > Program Database File Name
Alternate Options
None
See Also
Zi, Z7 compiler option
pdbfile compiler option
feliminate-unused-debug-types, Qeliminate-unused-debug-types
Controls the debug information emitted for types
declared in a compilation unit. This feature is only
available for ifort.
Syntax
Linux OS:
-feliminate-unused-debug-types
-fno-eliminate-unused-debug-types
macOS:
-feliminate-unused-debug-types
-fno-eliminate-unused-debug-types
Windows OS:
/Qeliminate-unused-debug-types
/Qeliminate-unused-debug-types-
Arguments
None
Default
-feliminate-unused-debug-types The compiler emits debug information only for types that are actually
or used by a variable/parameter/etc..
/Qeliminate-unused-debug-types
380
Compiler Reference
Description
This option controls the debug information emitted for types declared in a compilation unit.
If you specify -fno-eliminate-unused-debug-types (Linux and macOS*)
or /Qeliminate-unused-debug-types-, it will cause the compiler to emit debug information for all types
present in the sources. This option may cause a large increase in the size of the debug information.
IDE Equivalent
None
Alternate Options
None
fmerge-constants
Determines whether the compiler and linker attempt
to merge identical constants (string constants and
floating-point constants) across compilation units. This
feature is only available for ifort.
Syntax
Linux OS:
-fmerge-constants
-fno-merge-constants
macOS:
None
Windows OS:
None
Arguments
None
Default
-fmerge-constants The compiler and linker attempt to merge identical constants across
compilation units if the compiler and linker supports it.
Description
This option determines whether the compiler and linker attempt to merge identical constants (string
constants and floating-point constants) across compilation units.
If you do not want the compiler and linker to attempt to merge identical constants across compilation units.
specify -fno-merge-constants.
IDE Equivalent
None
Alternate Options
None
381
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
fmerge-debug-strings
Causes the compiler to pool strings used in debugging
information.
Syntax
Linux OS:
-fmerge-debug-strings
-fno-merge-debug-strings
macOS:
None
Windows OS:
None
Arguments
None
Default
Description
This option causes the compiler to pool strings used in debugging information. The linker will automatically
retain this pooling.
This option can reduce the size of debug information, but it may produce slightly slower compile and link
times.
This option is only turned on by default if you are using gcc 4.3 or later, where this setting is also the default,
since the generated debug tables require binutils version 2.17 or later to work reliably.
If you do not want the compiler to pool strings used in debugging information, specify option
-fno-merge-debug-strings.
IDE Equivalent
None
Alternate Options
None
fsource-asm
Produces an assembly listing with source code
annotations. This feature is only available for ifort.
Syntax
Linux OS:
-fsource-asm
macOS:
-fsource-asm
382
Compiler Reference
Windows OS:
None
Arguments
None
Default
OFF No source code annotations appear in the assembly listing file, if one is produced.
Description
This option produces an assembly listing file with source code annotations. The assembly listing file shows
the source code as interspersed comments.
To use this option, you must also specify option -S, which causes an assembly listing to be generated.
IDE Equivalent
None
Alternate Options
Linux and macOS*: None
Windows: /FAs
See Also
S compiler option
ftrapuv, Qtrapuv
Initializes stack local variables to an unusual value to
aid error detection. This feature is only available for
ifort.
Syntax
Linux OS:
-ftrapuv
macOS:
-ftrapuv
Windows OS:
/Qtrapuv
Arguments
None
Default
Description
This option initializes stack local variables to an unusual value to aid error detection. Normally, these local
variables should be initialized in the application. It also unmasks the floating-point invalid exception.
383
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The option sets any uninitialized local variables that are allocated on the stack to a value that is typically
interpreted as a very large integer or an invalid address. References to these variables are then likely to
cause run-time errors that can help you detect coding errors.
This option sets option -g (Linux* and macOS*) and /Zi or /Z7 (Windows*), which changes the default
optimization level from O2 to -O0 (Linux and macOS*) or /Od (Windows). You can override this effect by
explicitly specifying an O option setting.
If option O2 and option -ftrapuv (Linux and macOS*) or /Qtrapuv (Windows) are used together, you
should specify option -fp-speculation safe (Linux and macOS*) or /Qfp-speculation:safe (Windows)
to prevent exceptions resulting from speculated floating-point operations from being trapped.
For more details on using options -ftrapuv and /Qtrapuv with compiler option O, see the article in Intel®
Developer Zone titled Don't optimize when using -ftrapuv for uninitialized variable detection, which is located
in https://software.intel.com/content/www/us/en/develop/articles/dont-optimize-when-using-ftrapuv-for-
uninitialized-variable-detection.html.
Another way to detect uninitialized local scalar variables is by specifying keyword uninit for option check.
IDE Equivalent
Windows
Visual Studio: Data > Initialize stack variables to an unusual value
Alternate Options
None
See Also
g compiler option
Zi, Z7 compiler option
O compiler option
check compiler option (see setting uninit)
init, Qinit compiler option (see setting snan)
Locating Run-Time Errors
fverbose-asm
Produces an assembly listing with compiler comments,
including options and version information. This feature
is only available for ifort.
Syntax
Linux OS:
-fverbose-asm
-fno-verbose-asm
macOS:
-fverbose-asm
-fno-verbose-asm
Windows OS:
None
384
Compiler Reference
Arguments
None
Default
-fno-verbose-asm No source code annotations appear in the assembly listing file, if one
is produced.
Description
This option produces an assembly listing file with compiler comments, including options and version
information.
To use this option, you must also specify -S, which sets -fverbose-asm.
If you do not want this default when you specify -S, specify -fno-verbose-asm.
IDE Equivalent
None
Alternate Options
None
See Also
S compiler option
g
Tells the compiler to generate a level of debugging
information in the object file.
Syntax
Linux OS:
-g[n]
macOS:
-g[n]
Windows OS:
See option Zi, Z7.
Arguments
385
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
Description
Option -g tells the compiler to generate symbolic debugging information in the object file, which increases
the size of the object file.
The compiler does not support the generation of debugging information in assemblable files. If you specify
this option, the resulting object file will contain debugging information, but the assemblable file will not.
This option turns off option -O2 and makes option -O0 the default unless option -O2 (or higher) is explicitly
specified in the same command line.
Specifying the -g or -O0 option sets the -fno-omit-frame-pointer option. On Linux*, the -debug inline-
debug-info option will be enabled by default if you compile with optimizations (option -O2 or higher) and
debugging is enabled (option -g).
NOTE
When option -g is specified, debugging information is generated in the DWARF Version 3
format. Older versions of some analysis tools may require applications to be built with the
-gdwarf-2 option to ensure correct operation.
IDE Equivalent
None
Alternate Options
Linux: None
Windows: /Zi, /Z7
See Also
gdwarf compiler option
Zi, Z7 compiler option
debug (Linux* and macOS*) compiler option
gdwarf
Lets you specify a DWARF Version format when
generating debug information.
Syntax
Linux OS:
-gdwarf-n
macOS:
-gdwarf-n
386
Compiler Reference
Windows OS:
None
Arguments
Default
Description
This option lets you specify a DWARF Version format when generating debug information.
Note that older versions of some analysis tools may require applications to be built with the -gdwarf-2 option
to ensure correct operation.
IDE Equivalent
None
Alternate Options
None
See Also
g compiler option
grecord-gcc-switches
Causes the command line options that were used to
invoke the compiler to be appended to the
DW_AT_producer attribute in DWARF debugging
information.
Syntax
Linux OS:
-grecord-gcc-switches
macOS:
None
Windows OS:
None
387
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Arguments
None
Default
OFF The command line options that were used to invoke the compiler are
not appended to the DW_AT_producer attribute in DWARF debugging
information.
Description
This option causes the command line options that were used to invoke the compiler to be appended to the
DW_AT_producer attribute in DWARF debugging information.
The options are concatenated with whitespace separating them from each other and from the compiler
version.
IDE Equivalent
None
Alternate Options
None
gsplit-dwarf
Creates a separate object file containing DWARF
debug information.
Syntax
Linux OS:
-gsplit-dwarf
macOS:
None
Windows OS:
None
Arguments
None
Default
Description
This option creates a separate object file containing DWARF debug information. It causes debug information
to be split between the generated object (.o) file and the new DWARF object (.dwo) file.
The DWARF object file is not used by the linker, so this reduces the amount of debug information the linker
must process and it results in a smaller executable file.
For this option to perform correctly, you must use binutils-2.24 or later. To debug the resulting executable,
you must use gdb-7.6.1 or later.
388
Compiler Reference
NOTE
If you use the split executable with a tool that does not support the split DWARF format, it
will behave as though the DWARF debug information is absent.
IDE Equivalent
None
Alternate Options
None
list
Tells the compiler to create a listing of the source file.
Syntax
Linux OS:
-list[=filename]
-no-list
macOS:
-list[=filename]
-no-list
Windows OS:
/list[:filename]
/list-
Arguments
filename Is the name of the file for output. It can include a path.
Default
Description
This option tells the compiler to create a listing of the source file. The listing contains the following:
The line length of the listing can be specified by using option list-line-len.
The page length of the listing can be specified by using option list-page-len.
If you do not specify filename, the output is written to a file in the same directory as the source. The file
name is the name of the source file with an extension of .lst.
389
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IDE Equivalent
Windows
Visual Studio: Output Files > Source Listing (/list)
Output Files > Source Listing File (/list:[filename])
Alternate Options
None
See Also
show compiler option
list-line-len compiler option
list-page-len compiler option
list-line-len
Specifies the line length for the listing generated when
option list is specified.
Syntax
Linux OS:
-list-line-len=n
macOS:
-list-line-len=n
Windows OS:
/list-line-len:n
Arguments
Default
Description
This option specifies the line length for the listing generated when option list is specified.
If you specify option list-line-len and do not specify option list, the option is ignored.
IDE Equivalent
None
Alternate Options
None
See Also
list compiler option
list-page-len compiler option
390
Compiler Reference
list-page-len
Specifies the page length for the listing generated
when option list is specified.
Syntax
Linux OS:
-list-page-len=n
macOS:
-list-page-len=n
Windows OS:
/list-page-len:n
Arguments
n Is a positive integer indicating the number of lines on a page to show in the listing.
Default
Description
This option specifies the page length for the listing generated when option list is specified.
If you specify option list-page-len and do not specify option list, the option is ignored.
IDE Equivalent
None
Alternate Options
None
See Also
list compiler option
list-line-len compiler option
map-opts, Qmap-opts
Maps one or more compiler options to their equivalent
on a different operating system.
Syntax
Linux OS:
-map-opts
macOS:
None
Windows OS:
/Qmap-opts
391
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Arguments
None
Default
Description
This option maps one or more compiler options to their equivalent on a different operating system. The result
is output to stdout.
On Windows systems, the options you provide are presumed to be Windows options, so the options that are
output to stdout will be Linux equivalents.
On Linux systems, the options you provide are presumed to be Linux options, so the options that are output
to stdout will be Windows equivalents.
The tool can be invoked from the compiler command line or it can be used directly.
No compilation is performed when the option mapping tool is used.
This option is useful if you have both compilers and want to convert scripts or makefiles.
NOTE
Compiler options are mapped to their equivalent on the architecture you are using. For
example, if you are using a processor with Intel® 64 architecture, you will only see
equivalent options that are available on processors with Intel® 64 architecture.
IDE Equivalent
None
Alternate Options
None
Example
The following command line invokes the option mapping tool, which maps the Linux options to Windows-
based options, and then outputs the results to stdout:
See Also
Compiler Option Mapping Tool
o
Specifies the name for an output file.
Syntax
Linux OS:
-o filename
392
Compiler Reference
macOS:
-o filename
Windows OS:
None
Arguments
filename Is the name for the output file. The space before filename is optional.
Default
OFF The compiler uses the default file name for an output file.
Description
This option specifies the name for an output file as follows:
IDE Equivalent
None
Alternate Options
Linux and macOS*: None
Windows: /exe
See Also
object compiler option
exe compiler option
object
Specifies the name for an object file.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/object:filename
393
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Arguments
filename Is the name for the object file. It can be a file name or a directory name. A directory name must
be followed by a backslash (\). If a special character appears within the file name or directory
name, the file name or directory name must appear within quotes. To be safe, you should
consider any non-ASCII numeric character to be a special character.
Default
OFF An object file has the same name as the name of the first source file and a file extension of .obj.
Description
This option specifies the name for an object file.
If you specify this option and you omit /c or /compile-only, the /object option gives the object file its
name.
On Linux and macOS* systems, this option is equivalent to specifying option -ofilename-c.
IDE Equivalent
Windows
Visual Studio: Output Files > Object File Name
Alternate Options
Linux and macOS*: None
Windows: /Fo
Example
The following command shows how to specify a directory:
See Also
o compiler option
pdbfile
Lets you specify the name for a program database
(PDB) file created by the linker. This feature is only
available for ifort.
Syntax
Linux OS:
None
394
Compiler Reference
macOS:
None
Windows OS:
/pdbfile[:filename]
Arguments
filename Is the name for the PDB file. It can include a path. If you do not
specify a file extension, the extension .pdb is used.
Default
OFF No PDB file is created unless you specify option /Zi. If you specify option /Zi the default
filename is executablename.pdb.
Description
This option lets you specify the name for a program database (PDB) file created by the linker. This option
does not affect where the compiler outputs debug information.
To use this option, you must also specify option /debug:full or /Zi.
If filename is not specified, the default file name used is the name of your file with an extension of .pdb.
IDE Equivalent
None
Alternate Options
None
See Also
Zi, Z7 compiler option
debug compiler option
Fd compiler option
print-multi-lib
Prints information about where system libraries should
be found.
Syntax
Linux OS:
-print-multi-lib
macOS:
-print-multi-lib
Windows OS:
None
Arguments
None
395
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
Description
This option prints information about where system libraries should be found, but no compilation occurs. On
Linux* systems, it is provided for compatibility with gcc.
IDE Equivalent
None
Alternate Options
None
Quse-msasm-symbols
Tells the compiler to use a dollar sign ("$") when
producing symbol names. This feature is only available
for ifort.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/Quse-msasm-symbols
Arguments
None
Default
OFF The compiler uses a period (".") when producing symbol names
Description
This option tells the compiler to use a dollar sign ("$") when producing symbol names.
Use this option if you require symbols in your .asm files to contain characters that are accepted by the MS
assembler.
IDE Equivalent
None
Alternate Options
None
S
Causes the compiler to compile to an assembly file
only and not link.
396
Compiler Reference
Syntax
Linux OS:
-S
macOS:
-S
Windows OS:
/S
Arguments
None
Default
Description
This option causes the compiler to compile to an assembly file only and not link.
On Linux* and macOS* systems, the assembly file name has a .s suffix. On Windows* systems, the
assembly file name has an .asm suffix.
IDE Equivalent
None
Alternate Options
Linux and macOS*: None
Windows: /Fa
See Also
Fa compiler option
show
Controls the contents of the listing generated when
option list is specified.
Syntax
Linux OS:
-show keyword[, keyword...]
macOS:
-show keyword[, keyword...]
Windows OS:
/show:keyword[, keyword...]
Arguments
keyword Specifies the contents for the listing. Possible values are:
397
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
[no]options Controls whether a list of compiler options used for the compilation
is included when a listing is generated.
Default
include, map, and When a listing is generated, it contains the contents of INCLUDEd files, a symbol list
options with a line number cross reference, and a list of compiler options used.
Description
This option controls the contents of the listing generated when option list is specified.
If you specify option show and do not specify option list, the option is ignored.
IDE Equivalent
None
Alternate Options
None
See Also
list compiler option
use-asm, Quse-asm
Tells the compiler to produce objects through the
assembler. This is a deprecated option. There is no
replacement option. This feature is only available for
ifort.
Syntax
Linux OS:
-use-asm
-no-use-asm
macOS:
-use-asm
-no-use-asm
Windows OS:
/Quse-asm
/Quse-asm-
Arguments
None
398
Compiler Reference
Default
Description
This option tells the compiler to produce objects through the assembler.
IDE Equivalent
None
Alternate Options
None
Zi, Z7
Tells the compiler to generate full debugging
information in either an object (.obj) file or a project
database (PDB) file.
Syntax
Linux OS:
See option g.
macOS:
See option g.
Windows OS:
/Zi
/Z7
Arguments
None
Default
Description
Option /Z7 tells the compiler to generate symbolic debugging information in the object (.obj) file for use with
the debugger. No .pdb file is produced by the compiler.
The /Zi option tells the compiler to generate symbolic debugging information in a program database (PDB)
file for use with the debugger. Type information is placed in the .pdb file, and not in the .obj file, resulting in
smaller object files in comparison to option /Z7.
• The compiler creates the program database project.pdb. If you compile a file without a project, the
compiler creates a database named vcx0.pdb, where x represents the major version of Visual C++, for
example vc140.pdb.
This file stores all debugging information for the individual object files and resides in the same directory
as the project makefile. If you want to change this name, use option /Fd.
• The linker creates the program database executablename.pdb.
399
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
This file stores all debug information for the .exe file and resides in the debug subdirectory. It contains full
debug information, including function prototypes, not just the type information found in vcx0.pdb.
Both PDB files allow incremental updates. The linker also embeds the path to the .pdb file in the .exe or .dll
file that it creates.
The compiler does not support the generation of debugging information in assemblable files. If you specify
these options, the resulting object file will contain debugging information, but the assemblable file will not.
These options turn off option /O2 and make option /Od the default unless option /O2 (or higher) is explicitly
specified in the same command line.
For more information about the /Z7 and /Zi options, see the Microsoft documentation.
IDE Equivalent
Visual Studio
Visual Studio: General > Generate Debug Information
Alternate Options
Linux: -g
Windows: None
See Also
Fd compiler option
g compiler option
debug (Windows*) compiler option
Zo
Enables or disables generation of enhanced debugging
information for optimized code. This feature is only
available for ifort.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/Zo
/Zo-
Arguments
None
Default
OFF The compiler does not generate enhanced debugging information for optimized code.
400
Compiler Reference
Description
This option enables or disables the generation of additional debugging information for local variables and
inlined routines when code optimizations are enabled. It should be used with option /Zi or /Z7 to allow
improved debugging of optimized code.
Option /Zo enables generation of this enhanced debugging information. Option /Zo- disables this
functionality.
For more information on code optimization, see option /O.
IDE Equivalent
None
Alternate Options
None
See Also
Zi, Z7 compiler option
debug (Windows*) compiler option
O compiler option
Preprocessor Options
This section contains descriptions for compiler options that pertain to preprocessing.
B
Specifies a directory that can be used to find include
files, libraries, and executables.
Syntax
Linux OS:
-Bdir
macOS:
-Bdir
Windows OS:
None
Arguments
Default
OFF The compiler looks for files in the directories specified in your PATH environment variable.
Description
This option specifies a directory that can be used to find include files, libraries, and executables.
The compiler uses dir as a prefix.
401
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
For include files, the dir is converted to -I/dir/include. This command is added to the front of the includes
passed to the preprocessor.
For libraries, the dir is converted to -L/dir. This command is added to the front of the standard -L inclusions
before system libraries are added.
For executables, if dir contains the name of a tool, such as ld or as, the compiler will use it instead of those
found in the default directories.
The compiler looks for include files in dir /include while library files are looked for in dir.
IDE Equivalent
None
Alternate Options
None
D
Defines a symbol name that can be associated with an
optional value.
Syntax
Linux OS:
-Dname[=value]
macOS:
-Dname[=value]
Windows OS:
/Dname[=value]
Arguments
Default
Description
Defines a symbol name that can be associated with an optional value. This definition is used during
preprocessing in both Intel® Fortran conditional compilation directives and the fpp preprocessor. The
Dname=value will be ignored if there are any non-alphabetic, non-numeric characters in name.
If a value is not specified, name is defined as "1".
If you want to specify more than one definition, you must use separate D options.
If you specify noD, all preprocessor definitions apply only to fpp and not to Intel® Fortran conditional
compilation directives. To use this option, you must also specify the fpp option.
402
Compiler Reference
Caution
On Linux* and macOS* systems, if you are not specifying a value, do not use D for name,
because it will conflict with the -DD option.
IDE Equivalent
Windows
Visual Studio: General > Preprocessor Definitions
Preprocessor> Preprocessor Definitions
Preprocessor > Preprocessor Definitions to FPP only
Alternate Options
See Also
Using Predefined Preprocessor Symbols
d-lines, Qd-lines
Compiles debug statements.
Syntax
Linux OS:
-d-lines
-nod-lines
macOS:
-d-lines
-nod-lines
Windows OS:
/d-lines
/nod-lines
/Qd-lines
Arguments
None
Default
Description
This option compiles debug statements. It specifies that lines in fixed-format files that contain a D in column
1 (debug statements) should be treated as source code.
403
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IDE Equivalent
Windows
Visual Studio: Language > Compile Lines With D in Column 1 (/d-lines)
Alternate Options
Linux and macOS*: -DD
Windows: None
E
Causes the preprocessor to send output to stdout.
Syntax
Linux OS:
-E
macOS:
-E
Windows OS:
/E
Arguments
None
Default
Description
This option causes the preprocessor to send output to stdout. Compilation stops when the files have been
preprocessed.
When you specify this option, the compiler's preprocessor expands your source module and writes the result
to stdout. The preprocessed source contains #line directives, which the compiler uses to determine the
source file and line number.
IDE Equivalent
None
Alternate Options
None
EP
Causes the preprocessor to send output to stdout,
omitting #line directives.
Syntax
Linux OS:
-EP
404
Compiler Reference
macOS:
-EP
Windows OS:
/EP
Arguments
None
Default
Description
This option causes the preprocessor to send output to stdout, omitting #line directives.
If you also specify option preprocess-only, option P, or option F, the preprocessor will write the results
(without #line directives) to a file instead of stdout.
IDE Equivalent
None
Alternate Options
None
fpp
Runs the Fortran preprocessor on source files before
compilation.
Syntax
Linux OS:
-fpp
-nofpp
macOS:
-fpp
-nofpp
Windows OS:
/fpp
/fpp[:"fpp_option"]
/nofpp
Arguments
fpp_option Is a Fortran preprocessor (fpp) option; it must start with a slash (/)
and appear in quotes. This argument is only allowed on Windows*
systems.
405
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
Description
This option runs the Fortran preprocessor on source files before they are compiled.
If you want to pass fpp options to the Fortran preprocessor, you can use any of the following methods:
IDE Equivalent
Windows
Visual Studio: Preprocessor > Preprocess Source File
Alternate Options
Linux and macOS*: -cpp (this is a deprecated option)
Windows: None
Example
The following examples show the recommended method of passing fpp options to the Fortran preprocessor:
See Also
Qoption compiler option
Using Fortran Preprocessor Options
Wp compiler option
fpp-name
Lets you specify an alternate preprocessor to use with
Fortran.
Syntax
Linux OS:
-fpp-name=name
macOS:
-fpp-name=name
406
Compiler Reference
Windows OS:
/fpp-name:name
Arguments
name Is the name of the preprocessor executable. It can include a path. See the description below for
more details.
Default
Description
This option lets you specify an alternate preprocessor to use with Fortran.
The compiler invokes the user-specified Fortran preprocessor by spawning a command with the following
signature:
You can use option Qlocation, fpp,… to specify a directory for supporting tools.
IDE Equivalent
None
Alternate Options
None
See Also
fpp Preprocessing
fpp compiler option
Qoption compiler option
Qlocation compiler option
gen-dep
Tells the compiler to generate build dependencies for
the current compilation.
Syntax
Linux OS:
-gen-dep[=filename]
-no-gen-dep
macOS:
-gen-dep[=filename]
-no-gen-dep
407
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows OS:
/gen-dep[:filename]
/gen-dep-
Arguments
filename Is the name of the file for output. It can include a path.
If you specify filename, it is similar to specifying option [Q]MFfilename. If you do not specify
filename, it is similar to specifying option [Q]MD or [Q]MMD.
Default
-no-gen-dep or /gen-dep- The compiler does not generate build dependencies for the compilation.
Description
This option tells the compiler to generate build dependencies for the current compilation. The build
dependencies include a list of all files included with INCLUDE statements or .mod files accessed with USE
statements.
If you do not specify filename, the dependencies are written to stdout.
You can use option gen-depformat to specify the form of the output for the build dependencies generated.
If you specify option gen-dep and you do not specify option gen-depformat, the output format is in a form
acceptable to the make utility.
Note that if option fpp is used to process #include files, those files will also appear in the list of build
dependencies.
If you want to generate build dependencies but you do not want to compile the sources, you must also
specify option syntax-only.
IDE Equivalent
Visual Studio
Visual Studio: Output Files > Build Dependencies (/gen-dep)
Output Files > Emit Build Dependencies to File (/gen-dep:filename)
Output Files > Build Dependencies File (/gen-dep:filename)
Alternate Options
Windows: /QMF
See Also
gen-depformat compiler option
gen-depshow compiler option
syntax-only compiler option
408
Compiler Reference
gen-depformat
Specifies the form for the output generated when
option gen-dep is specified.
Syntax
Linux OS:
-gen-depformat=form
macOS:
-gen-depformat=form
Windows OS:
/gen-depformat:form
Arguments
form Is the output form for the list of build dependencies. Possible values are make or nmake.
Default
make The output form for the list of build dependencies is in a form acceptable to the make utility.
Description
This option specifies the form for the output generated when option gen-dep is specified.
If you specify option gen-depformat and do not specify option gen-dep, the option is ignored.
IDE Equivalent
None
Alternate Options
None
See Also
gen-dep compiler option
gen-depshow
Determines whether certain features are excluded
from dependency analysis. Currently, it only applies to
intrinsic modules.
Syntax
Linux OS:
-gen-depshow=keyword
macOS:
-gen-depshow=keyword
Windows OS:
/gen-depshow:keyword
409
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Arguments
keyword Specifies inclusion or exclusion from dependency analysis. Possible values are:
Default
nointr_mod Tells the compiler to exclude Fortran intrinsic modules in dependency analysis.
Description
This option determines whether certain features are excluded from dependency analysis. Currently, it only
applies to intrinsic modules.
Option Description
gen-depshow intr_mod Tells the compiler to include Fortran intrinsic modules in dependency
analysis.
If you do not specify option gen-dep, the compiler does not generate build dependencies for the compilation.
If you specify option gen-depshow and do not specify option gen-dep, the option is ignored.
IDE Equivalent
None
Alternate Options
Windows: /QMMD
See Also
gen-dep compiler option
I
Specifies an additional directory for the include path.
Syntax
Linux OS:
-Idir
macOS:
-Idir
Windows OS:
/Idir
Arguments
410
Compiler Reference
Default
Description
This option specifies an additional directory for the include path, which is searched for module files
referenced in USE statements and include files referenced in INCLUDE statements. To specify multiple
directories on the command line, repeat the option for each directory you want to add.
For all USE statements and for those INCLUDE statements whose file name does not begin with a device or
directory name, the directories are searched in this order:
IDE Equivalent
Windows
Visual Studio: General > Additional Include Directories (/I)
Preprocessor > Additional Include Directories (/I)
Alternate Options
Linux and macOS*: None
Windows: /include
See Also
X compiler option
assume compiler option
idirafter
Adds a directory to the second include file search
path.
Syntax
Linux OS:
-idirafterdir
macOS:
-idirafterdir
Windows OS:
None
411
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Arguments
Default
Description
This option adds a directory to the second include file search path (after -I).
IDE Equivalent
None
Alternate Options
None
isystem
Specifies a directory to add to the start of the system
include path.
Syntax
Linux OS:
-isystemdir
macOS:
-isystemdir
Windows OS:
None
Arguments
Default
Description
This option specifies a directory to add to the system include path. The compiler searches the specified
directory for include files after it searches all directories specified by the -I compiler option but before it
searches the standard system directories.
On Linux* systems, this option is provided for compatibility with gcc.
IDE Equivalent
None
Alternate Options
None
412
Compiler Reference
module
Specifies the directory where module files should be
placed when created and where they should be
searched for.
Syntax
Linux OS:
-module path
macOS:
-module path
Windows OS:
/module:path
Arguments
Default
Description
This option specifies the directory (path) where module (.mod) files should be placed when created and
where they should be searched for (USE statement).
IDE Equivalent
Windows
Visual Studio: Output > Module Path
Alternate Options
None
preprocess-only
Causes the Fortran preprocessor to send output to a
file.
Syntax
Linux OS:
-preprocess-only
macOS:
-preprocess-only
Windows OS:
/preprocess-only
Arguments
None
413
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
Description
This option causes the Fortran preprocessor to send output to a file.
The source file is preprocessed by the Fortran preprocessor, and the result for each source file is output to a
corresponding .i or .i90 file.
Note that the source file is not compiled.
IDE Equivalent
None
Alternate Options
Linux and macOS*: -P
Windows: /P
u (Windows*)
Undefines all previously defined preprocessor values.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/u
Arguments
None
Default
OFF Defined preprocessor values are in effect until they are undefined.
Description
This option undefines all previously defined preprocessor values.
To undefine specific preprocessor values, use the /U option.
IDE Equivalent
Windows
Visual Studio: Preprocessor > Undefine All Preprocessor Definitions
Alternate Options
None
414
Compiler Reference
See Also
U compiler option
U
Undefines any definition currently in effect for the
specified symbol.
Syntax
Linux OS:
-Uname
macOS:
-Uname
Windows OS:
/Uname
Arguments
Default
Description
This option undefines any definition currently in effect for the specified symbol.
On Windows systems, use the /u option to undefine all previously defined preprocessor values.
IDE Equivalent
Windows
Visual Studio: Preprocessor > Undefine Preprocessor Definitions
Alternate Options
Linux and macOS*: None
Windows: /undefine:name
See Also
u (Windows) compiler option
undef
Disables all predefined symbols.
Syntax
Linux OS:
-undef
macOS:
-undef
415
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows OS:
None
Arguments
None
Default
Description
This option disables all predefined symbols.
IDE Equivalent
None
Alternate Options
None
X
Removes standard directories from the include file
search path.
Syntax
Linux OS:
-X
macOS:
-X
Windows OS:
/X
Arguments
None
Default
Description
This option removes standard directories from the include file search path. It prevents the compiler from
searching the default path specified by the CPATH environment variable.
On Linux* and macOS* systems, specifying -X (or -noinclude) prevents the compiler from searching
in /usr/include for files specified in an INCLUDE statement.
You can use this option with the I option to prevent the compiler from searching the default path for include
files and direct it to use an alternate path.
This option affects fpp preprocessor behavior and the USE statement.
416
Compiler Reference
IDE Equivalent
Windows
Visual Studio: Preprocessor > Ignore Standard Include Path (/X)
Alternate Options
Linux and macOS*: -nostdinc
Windows: /noinclude
See Also
I compiler option
Qinstall
Specifies the root directory where the compiler
installation was performed.
Syntax
Linux OS:
-Qinstalldir
macOS:
-Qinstalldir
Windows OS:
None
Arguments
Default
OFF The default root directory for compiler installation is searched for the compiler.
Description
This option specifies the root directory where the compiler installation was performed. It is useful if you want
to use a different compiler or if you did not use a shell script to set your environment variables.
IDE Equivalent
None
Alternate Options
None
Qlocation
Specifies the directory for supporting tools.
417
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-Qlocation,string,dir
macOS:
-Qlocation,string,dir
Windows OS:
/Qlocation,string,dir
Arguments
Default
Description
This option specifies the directory for supporting tools.
string can be any of the following:
-Qlocation,ld,/usr/bin ! This tells the driver to use /usr/bin/ld for the loader
-Qlocation,ld,/usr/bin/gld ! This tells the driver to use /usr/bin/gld as the loader
The following shows an example on Windows* systems:
418
Compiler Reference
IDE Equivalent
None
Alternate Options
None
Example
The following command provides the path for the fpp tool:
See Also
Qoption compiler option
Qoption
Passes options to a specified tool.
Syntax
Linux OS:
-Qoption,string,options
macOS:
-Qoption,string,options
Windows OS:
/Qoption,string,options
Arguments
options Are one or more comma-separated, valid options for the designated
tool.
Note that certain tools may require that options appear within
quotation marks (" ").
Default
Description
This option passes options to a specified tool.
If an argument contains a space or tab character, you must enclose the entire argument in quotation marks
(" "). You must separate multiple arguments with commas.
string can be any of the following:
• fpp (or cpp) - Indicates the Intel® Fortran preprocessor or a user-specified (alternate) Fortran
preprocessor.
• asm - Indicates the assembler.
• link - Indicates the linker.
• prof - Indicates the profiler.
• On Windows* systems, the following is also available:
419
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IDE Equivalent
None
Alternate Options
None
ifort -Qoption,fpp,"-fpp=macro=no
ifort /Qoption,fpp,"/fpp:macro=no"
See Also
Qlocation compiler option
Language Options
This section contains descriptions for compiler options that pertain to language compatibility, conformity, etc.
allow
Determines whether the compiler allows certain
behaviors.
Syntax
Linux OS:
-allow keyword
420
Compiler Reference
macOS:
-allow keyword
Windows OS:
/allow:keyword
Arguments
Default
Description
This option determines whether the compiler allows certain behaviors.
Option Description
IDE Equivalent
None
Alternate Options
None
Example
Consider the following:
altparam
Allows alternate syntax (without parentheses) for
PARAMETER statements.
Syntax
Linux OS:
-altparam
421
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
-noaltparam
macOS:
-altparam
-noaltparam
Windows OS:
/altparam
/noaltparam
Arguments
None
Default
Description
This option specifies that the alternate syntax for PARAMETER statements is allowed. The alternate syntax is:
IDE Equivalent
Windows
Visual Studio: Language > Enable Alternate PARAMETER Syntax
Alternate Options
assume
Tells the compiler to make certain assumptions.
Syntax
Linux OS:
-assume keyword[, keyword...]
macOS:
-assume keyword[, keyword...]
Windows OS:
/assume:keyword[, keyword...]
422
Compiler Reference
Arguments
423
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
424
Compiler Reference
Default
nobuffered_io Data in the internal buffer is immediately read from or written (flushed)
to disk (OPEN specifier BUFFERED='NO'). Data read from variable length,
unformatted files is read directly from disk to a user's variables.
If you set the FORT_BUFFERED environment variable to true, the default
is assume buffered_io.
nobuffered_stdout Data is not buffered for the standard output device but instead is written
immediately to the device.
nobyterecl Units for OPEN statement RECL values with unformatted files are in four-
byte (longword) units.
425
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
noieee_fpe_flags The flags are not saved on routine entry and they are not restored on
routine exit.
nominus0 The compiler uses Fortran 90/77 standard semantics in the SIGN intrinsic
to treat -0.0 and +0.0 as 0.0, and writes a value of 0.0 with no sign on
formatted output.
nan_compares Code is generated for floating-point compares to check for NaNs and give
the same results as are performed when assume ieee_compares is
specified, except a compare to a signaling NaN behaves as if it was a
quiet NaN.
old_ldout_format For list-directed and namelist-directed output, integers are written with a
fixed width that is dependent on the integer kind, and zero real values
are written using the E format.
426
Compiler Reference
noold_logical_ldio Tells the compiler that NAMELIST and list-directed input cannot accept
logical values (T, F, etc.) for numeric (integer, real, and complex) IO-list
items or numeric values for logical IO-list items. If this option is specified
and a logical value is given for a numeric item or a numeric value is given
for a logical item in NAMELIST and list-directed input, a run-time error
will be produced.
noprotect_allocates Memory allocation requests using the ALLOCATE statement are not
protected with critical sections and may encounter random timing
problems in a multi-threaded environment.
noprotect_parens The optimizer reorders REAL and COMPLEX expressions without regard
for parentheses by reassociating operations if it produces faster executing
code.
realloc_lhs Tells the compiler that when the left-hand side of an assignment is an
allocatable object, it should be reallocated to the shape of the right-hand
side of the assignment before the assignment occurs. This is the current
Fortran Standard definition. This feature may cause extra overhead at run
time. The option standard-realloc-lhs has the same effect as
assume realloc_lhs.
norecursion Tells the compiler that all procedures are not compiled for recursion,
unless declared with the RECURSIVE keyword. Fortran 2018 specifies the
default mode of compilation is recursion; previous standards specified no
recursion. This default will change in a future release.
source_include The compiler searches for USE modules and INCLUDE files in the
directory where the source file is located.
427
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
std_intent_in The compiler assumes that dummy arguments with the INTENT(IN)
attribute in a called procedure are not modified across a call, in
accordance with the Fortran standard.
std_minus0_rounding A negative value that is not zero but rounds to zero on output is
displayed with a leading minus sign. For example, the value -0.00000001
in F5.1 format will be displayed as -0.0 rather than as 0.0.
nostd_mod_proc_name The compiler allows the names of module procedures to conflict with user
external symbol names.
std_value The compiler assumes that the VALUE attribute has the effect as if the
actual argument is assigned to a temporary, and the temporary is then
passed to the called procedure so that subsequent changes to the value
of the dummy argument do not affect the actual argument, in accordance
with the Fortran standard.
Windows: nounderscore On Windows* systems, the compiler does not append an underscore
Linux and macOS*: underscore character to external user-defined names. On Linux* and macOS*
systems, the compiler appends an underscore character to external user-
defined names.
no2underscores The compiler does not append two underscore characters to external
(Linux and macOS*) user-defined names that contain an embedded underscore.
Description
This option specifies assumptions to be made by the compiler.
Option Description
assume bscc Tells the compiler to treat the backslash character (\) as a C-
style control (escape) character syntax in character literals.
The "bscc" keyword means "BackSlashControlCharacters."
assume buffered_io Tells the compiler to accumulate records in a buffer. This sets
the default for opening sequential files to BUFFERED='YES',
which also occurs if the FORT_BUFFERED run-time
environment variable is specified.
When this option is specified, the internal buffer is filled,
possibly by many record input statements (READ) or output
statements (WRITE), before it is read from disk, or written to
disk, by the Fortran run-time system. If a file is opened for
direct access, I/O buffering is ignored.
Using buffered reads and writes usually makes disk I/O more
efficient by handling larger blocks of data on disk less often.
However, if you request buffered writes, records not yet
written to disk may be lost in the event of a system failure.
The OPEN statement BUFFERED specifier applies to a specific
logical unit. In contrast, the assume [no]buffered_io option
and the FORT_BUFFERED environment variable apply to all
Fortran units.
428
Compiler Reference
Option Description
assume buffered_stdout Tells the Fortran run-time system to accumulate data for the
standard output device in a buffer. When the buffer is full or
the user executes a FLUSH on OUTPUT_UNIT in intrinsic
module ISO_FORTRAN_ENV, the data is displayed on the
standard output unit.
Using buffered writes may be a more efficient in time and
space but use assume nobuffered_stdout if you want data
displayed immediately on the standard output device, like for
an input prompt.
assume [no]buffered_stdout does not affect and is not
affected by assume [no]buffered_io.
assume byterecl Specifies that the units for the OPEN statement RECL specifier
(record length) value are in bytes for unformatted data files,
not longwords (four-byte units). For formatted files, the RECL
value is always in bytes.
If a file is open for unformatted data and assume byterecl is
specified, INQUIRE returns RECL in bytes; otherwise, it returns
RECL in longwords. An INQUIRE returns RECL in bytes if the
unit is not open.
assume contiguous_pointer Tells the compiler to assume contiguity for pointers. This may
aid in optimization. However, if you are mistaken about the
contiguity of your data, it could result in run-time failures.
429
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Option Description
assume failed_images Tells the run-time system to check for failed images on the
current team when executing an image control statement that
does not have a STAT= specifier, or when a MOVE_ALLOC or
collective or atomic subroutine without a STAT argument is
executed.
A failed image check is made each time an image control
statement that has a STAT= specifier is executed, and when a
call to MOVE_ALLOC or a collective or atomic subroutine with a
STAT argument is executed.
assume ieee_fpe_flags Tells the compiler to save floating-point exception and status
flags on routine entry and restore them on routine exit.
This option can slow runtime performance because it provides
extra code to save and restore the floating-point exception and
status flags (and the rounding mode) on entry to and exit from
every routine compiled with the option.
This option can be used to get the full Fortran Standard
behavior of intrinsic modules IEEE EXCEPTIONS, IEEE
ARITHMETIC, and IEEE FEATURES, which require that if a flag
is signaling on routine entry, the processor will set it to quiet
on entry and restore it to signaling on return. If a flag signals
while the routine is executing, it will not be set to quiet on
routine exit.
Options fpe and fpe-all can be used to set the initial state
for which floating-point exceptions will signal.
assume minus0 Tells the compiler to use Fortran 95 standard semantics for the
treatment of the IEEE* floating value -0.0 in the SIGN
intrinsic, which distinguishes the difference between -0.0 and
+0.0, and to write a value of -0.0 with a negative sign on
formatted output.
430
Compiler Reference
Option Description
assume old_boz Tells the compiler that the binary, octal, and hexadecimal
constant arguments in intrinsic functions INT, REAL, DBLE, and
CMPLX should be treated as signed integer constants.
assume noold_inquire_recl Tells the compiler to use Fortran 2018 semantics for RECL= on
an INQUIRE statement. If the unit is unconnected, the scalar-
int-variable of the RECL= specifier becomes defined with the
value -1; if the unit is connected for stream access, it becomes
defined with the value -2.
assume noold_ldout_format Tells the compiler to use Fortran 2003 standard semantics for
output of integer and real values in list-directed and namelist-
directed output.
Integers are written using an I0 format with a leading blank
for spacing.
Real and complex values are written using and E or F format
with a leading blank for spacing. The format used depends on
the magnitude of the value. Values that are zero are written
using an F format.
assume old_logical_ldio Logical values are allowed for numeric items and numeric
values are allowed for logical items.
assume noold_maxminloc Tells the compiler that MAXLOC and MINLOC should return 0
when given an empty array as an argument or every element
of the mask is false. Compared to the default setting
(old_maxminloc), this behavior may slow performance
because of the extra code needed to check for an empty array
argument or for an all-false mask.
assume noold_unit_star Tells the compiler that READs or WRITEs to UNIT=* go to the
file to which UNIT=5 or 6 is connected.
431
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Option Description
assume protect_allocates Memory allocation requests using the ALLOCATE statement are
protected with critical sections to avoid random timing
problems in a multi-threaded environment in some
distributions and configurations.
assume protect_parens Tells the optimizer to honor parentheses in REAL and COMPLEX
expression evaluations by not reassociating operations. For
example, (A+B)+C would not be evaluated as A+(B+C).
If assume noprotect_parens is specified, (A+B)+C would be
treated the same as A+B+C and could be evaluated as A+(B
+C) if it produced faster executing code.
Such reassociation could produce different results depending
on the sizes and precision of the arguments.
For example, in (A+B)+C, if B and C had opposite signs and
were very large in magnitude compared to A, A+B could result
in the value as B; adding C would result in 0.0. With
reassociation, B+C would be 0.0; adding A would result in a
non-zero value.
assume norealloc_lhs The compiler uses the old Fortran 2003 rules when interpreting
assignment statements. The left-hand side is assumed to be
allocated with the correct shape to hold the right-hand side. If
it is not, incorrect behavior will occur. The option
nostandard-realloc-lhs has the same effect as
assume norealloc_lhs.
assume recursion Tells the compiler to compile procedures that are declared
without the RECURSIVE or NON_RECURSIVE keyword as
recursive procedures. In Fortran 2018, these procedures are
compiled for recursion by default; in previous standards they
were compiled as non-recursive procedures. The current
default behavior is non-recursive. This will change in a future
release.
assume nosource_include Tells the compiler to search the default directory for module
files specified by a USE statement or source files specified by
an INCLUDE statement. This option affects fpp preprocessor
behavior and the USE statement.
assume nostd_intent_in Tells the compiler to assume that dummy arguments with the
INTENT(IN) attribute in a called procedure may be modified
across a call. This is not in accordance with the Fortran
standard.
432
Compiler Reference
Option Description
assume nostd_minus0_rounding Tells the compiler to use pre-Fortran 2008 standard semantics
for the treatment of IEEE* floating values that are negative,
non-zero, and when rounded for display are zero. The value
should be printed without a leading minus sign.
For example, the floating value -0.00000001 when rounded in
F5.1 format will be displayed as 0.0. Use
assume std_minus0_rounding to use Fortran 2008 standard
semantics to display this value as -0.0 when rounded in F5.1
format.
assume [no]std_minus0_rounding does not affect and is
not affected by assume [no]minus0. The former controls
printing of a minus sign for non-zero numbers while the latter
controls printing of actual signed zero values.
assume std_mod_proc_name Tells the compiler to revise the names of module procedures
so they do not conflict with user external symbol names. For
example, procedure proc in module m would be named
m_MP_proc. The Fortran 2003 Standard requires that module
procedure names not conflict with other external symbols.
By default, procedure proc in module m would be named
m_mp_proc, which could conflict with a user-defined external
name m_mp_proc.
assume nostd_value Tells the compiler to use pre-Fortran 2003 standard semantics
for the VALUE attribute so that the value of the actual
argument is passed to the called procedure, not the address of
the actual argument nor the address of a copy of the actual
argument.
433
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Option Description
assume writeable-strings Tells the compiler to put character constants into non-read-
only memory.
IDE Equivalent
Visual Studio
Visual Studio: Code Generation > Enable Recursive Routines (/assume:[no]recursion)
Alternate Options
Windows: /nbs
Windows: /Qcommon-args
Windows: /Qprotect-parens
Windows: /standard-realloc-lhs
Windows: /recursive
See Also
fp-model, fp compiler option
fpe compiler option
fpe-all compiler option
standard-semantics compiler option
standard-realloc-lhs compiler option
fpscomp compiler option, setting logicals
434
Compiler Reference
ccdefault
Specifies the type of carriage control used when a file
is displayed at a terminal screen.
Syntax
Linux OS:
-ccdefault keyword
macOS:
-ccdefault keyword
Windows OS:
/ccdefault:keyword
Arguments
fortran Tells the compiler to use normal Fortran interpretation of the first character.
For example, the character 0 causes output of a blank line before a record.
list Tells the compiler to output one line feed between records.
Default
ccdefault default The compiler uses the default carriage control setting.
Description
This option specifies the type of carriage control used when a file is displayed at a terminal screen (units 6
and *). It provides the same functionality as using the CARRIAGECONTROL specifier in an OPEN statement.
The default carriage-control setting can be affected by the vms option. If option vms is specified with
ccdefault default, carriage control defaults to normal Fortran interpretation (ccdefault fortran) if the
file is formatted and the unit is connected to a terminal. If option novms (the default) is specified with
ccdefault default, carriage control defaults to list (ccdefault list).
IDE Equivalent
Windows
Visual Studio: Run-time > Default Output Carriage Control
Alternate Options
None
check
Checks for certain conditions at run time.
435
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-check [keyword[, keyword...]]
-nocheck
macOS:
-check [keyword[, keyword...]]
-nocheck
Windows OS:
/check[:keyword[, keyword...]]
/nocheck
Arguments
[no]output_conversion Determines whether checking occurs for the fit of data items
within a designated format descriptor field.
436
Compiler Reference
Default
nocheck No checking is performed for run-time failures. Note that if option vms is specified, the defaults
are check format and check output_conversion.
Description
This option checks for certain conditions at run time.
Option Description
check arg_temp_created Enables run-time checking on whether actual arguments are copied
into temporary storage before routine calls. If a copy is made at run-
time, an informative message is displayed.
check bounds Enables compile-time and run-time checking for array subscript and
character substring expressions. An error is reported if the expression
is outside the dimension of the array or the length of the string.
For array bounds, each individual dimension is checked. For arrays that
are dummy arguments, only the lower bound is checked for a
dimension whose upper bound is specified as * or where the upper and
lower bounds are both 1.
For some intrinsics that specify a DIM= dimension argument, such as
LBOUND, an error is reported if the specified dimension is outside the
declared rank of the array being operated upon.
Once the program is debugged, omit this option to reduce executable
program size and slightly improve run-time performance.
It is recommended that you do bounds checking on unoptimized code.
If you use option check bounds on optimized code, it may produce
misleading messages because registers (not memory locations) are
used for bounds values.
check format Issues the run-time FORVARMIS fatal error when the data type of an
item being formatted for output does not match the format descriptor
being used (for example, a REAL*4 item formatted with an I edit
descriptor).
With check noformat, the data item is formatted using the specified
descriptor unless the length of the item cannot accommodate the
descriptor (for example, it is still an error to pass an INTEGER*2 item
to an E edit descriptor).
437
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Option Description
check output_conversion Issues the run-time OUTCONERR continuable error message when a
data item is too large to fit in a designated format descriptor field
without loss of significant digits. Format truncation occurs, the field is
filled with asterisks (*), and execution continues.
check stack Enables checking on the stack frame. The stack is checked for buffer
overruns and buffer underruns. This option also enforces local variables
initialization and stack pointer verification.
This option disables optimization and overrides any optimization level
set by option O.
check stack Enables checking on the stack frame. The stack is checked for buffer
overruns and buffer underruns. This option also enforces local variables
initialization and stack pointer verification.
This option disables optimization and overrides any optimization level
set by option O.
check teams Enables checking for non-standard coarray team usage. For example,
ifort permits the TEAM argument to NUM_IMAGES to be a type
TEAM_TYPE variable which describes a team that is not the current or
an ancestor of the current team. Similarly, ifort permits the
TEAM_NUMBER specifier in an image selector to specify a value of -1
indicating the initial team. Such behavior is not permitted by the
standard.
When check teams is specified, a message is generated each time a
non-standard coarray extension is detected.
438
Compiler Reference
Option Description
check all Enables all check options. This is the same as specifying check with no
keyword.
This option disables optimization and overrides any optimization level
set by option O.
To get more detailed location information about where an error occurred, use option traceback.
IDE Equivalent
Visual Studio
Visual Studio: Run-time > Runtime Error Checking (/nocheck, /check:all)
Run-time > Check For Actual Arguments Using Temporary Storage (/check:arg_temp_created)
Run-time > Check For Null Pointers and Allocatable Array References (/check:pointers)
Alternate Options
Windows: /nocheck
Windows: /CB
Windows: /CS
Windows: /check, /C
See Also
traceback compiler option
init, Qinit compiler option
warn compiler option
ASSUME directive
ASSUME_ALIGNED directive
439
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
extend-source
Specifies the length of the statement field in a fixed-
form source file.
Syntax
Linux OS:
-extend-source [size]
-noextend-source
macOS:
-extend-source [size]
-noextend-source
Windows OS:
/extend-source[:size]
/noextend-source
Arguments
size Is the length of the statement field in a fixed-form source file. Possible values are: 72, 80, or 132.
Default
72 If you do not specify this option or you specify noextend-source, the statement field ends at
column 72.
132 If you specify extend_source without size, the statement field ends at column 132.
Description
This option specifies the size (column number) of the statement field of a source line in a fixed-form source
file. This option is valid only for fixed-form files; it is ignored for free-form files.
When size is specified, it is the last column parsed as part of the statement field. Any columns after that are
treated as comments.
If you do not specify size, it is the same as specifying extend_source 132.
Option Description
extend-source 132 Specifies that the statement field ends at column 132.
IDE Equivalent
Windows
Visual Studio: Language > Fixed Form Line Length
Alternate Options
440
Compiler Reference
Windows: /4L72
Windows: /4L80
Windows: /4L132
fixed
Specifies source files are in fixed format.
Syntax
Linux OS:
-fixed
-nofixed
macOS:
-fixed
-nofixed
Windows OS:
/fixed
/nofixed
Arguments
None
Default
OFF The source file format is determined from the file extension.
Description
This option specifies source files are in fixed format. If this option is not specified, format is determined as
follows:
• Files with an extension of .f90, .F90, or .i90 are free-format source files.
• Files with an extension of .f, .for, .FOR, .ftn, .FTN, .fpp, .FPP, or .i are fixed-format files.
Note that on Linux* and macOS* systems, file names and file extensions are case sensitive.
IDE Equivalent
Windows
Visual Studio: Language > Source File Format (/free, /fixed)
Alternate Options
Linux and macOS*: -FI
441
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
free
Specifies source files are in free format.
Syntax
Linux OS:
-free
-nofree
macOS:
-free
-nofree
Windows OS:
/free
/nofree
Arguments
None
Default
OFF The source file format is determined from the file extension.
Description
This option specifies source files are in free format. If this option is not specified, format is determined as
follows:
• Files with an extension of .f90, .F90, or .i90 are free-format source files.
• Files with an extension of .f, .for, .FOR, .ftn, or .i are fixed-format files.
IDE Equivalent
Windows
Visual Studio: Language > Source File Format (/free, /fixed)
Alternate Options
Linux and macOS*: -FR
See Also
fixed compiler option
iface
Specifies the default calling convention and argument-
passing convention for an application.
Syntax
Linux OS:
None
442
Compiler Reference
macOS:
None
Windows OS:
/iface:keyword
Arguments
keyword Specifies the calling convention or the argument-passing convention. Possible values are:
Default
Description
This option specifies the default calling convention and argument-passing convention for an application.
The aspects of calling and argument passing controlled by this option are as follows:
• The calling mechanism (C or STDCALL): On IA-32 architecture, these mechanisms differ in how the stack
register is adjusted when a procedure call returns. On Intel® 64 architecture, the only calling mechanism
available is C; requests for the STDCALL mechanism are ignored.
• The argument passing mechanism (by value or by reference)
• Character-length argument passing (at the end of the argument list or after the argument address)
• The case of external names (uppercase or lowercase)
• The name decoration (prefix and suffix)
You can also use the ATTRIBUTES compiler directive to modify these conventions on an individual basis. Note
that the effects of the ATTRIBUTES directive do not always match that of the iface option of the same name.
Option Description
/iface:default Tells the compiler to use the default calling conventions. These
conventions are as follows:
• The calling mechanism: C
• The argument passing mechanism: by reference
• Character-length argument passing: at end of argument list
• The external name case: uppercase
• The name decoration: Underscore prefix on IA-32 architecture,
no prefix on Intel® 64 architecture; no suffix
443
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Option Description
444
Compiler Reference
Caution
On Windows systems, if you specify option /iface:cref, it overrides the default for external
names and causes them to be lowercase. It is as if you specified "!dir$ attributes c,
reference" for the external name.
If you specify option /iface:cref and want external names to be uppercase, you must explicitly
specify option /names:uppercase.
Caution
On systems using IA-32 architecture, there must be agreement between the calling program
and the called procedure as to which calling mechanism (C or STDCALL) is used, or
unpredictable errors may occur. If you change the default mechanism to STDCALL, you must
use the ATTRIBUTES DEFAULT directive to reset the calling conventions for any procedure
that is:
• Specified as a FINAL procedure for a derived type
• Specified as a USEROPEN procedure in an OPEN statement
• Referenced in a variable format expression
• Specified as a comparison routine passed to the QSORT library routine from module IFPORT
• Used as a dialog callback procedure with the IFLOGM module
• Called from other contexts or languages that assume the C calling convention
Note that Visual Studio projects that are imported using the Extract Compaq Visual Fortran project
items wizard have /iface:cvf applied automatically; this establishes STDCALL as the default
convention.
IDE Equivalent
Visual Studio
Visual Studio: External Procedures > Calling Convention
(/iface:{cref|stdref|stdcall|cvf|default})
Alternate Options
Windows: None
Windows: None
See Also
ATTRIBUTES Directive
445
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
names
Specifies how source code identifiers and external
names are interpreted.
Syntax
Linux OS:
-names keyword
macOS:
-names keyword
Windows OS:
/names:keyword
Arguments
keyword Specifies how to interpret the identifiers and external names in source code. Possible values
are:
Default
lowercase This is the default on Linux* and macOS* systems. The compiler ignores case
differences in identifiers and converts external names to lowercase.
uppercase This is the default on Windows* systems. The compiler ignores case differences in
identifiers and converts external names to uppercase.
Description
This option specifies how source code identifiers and external names are interpreted. It can be useful in
mixed-language programming.
This naming convention applies whether names are being defined or referenced.
You can use the ALIAS directive to specify an alternate external name to be used when referring to external
subprograms.
Caution
On Windows systems, if you specify option /iface:cref, it overrides the default for external
names and causes them to be lowercase. It is as if you specified "!dir$ attributes c,
reference" for the external name.
If you specify option /iface:cref and want external names to be uppercase, you must explicitly
specify option /names:uppercase.
446
Compiler Reference
IDE Equivalent
Windows
Visual Studio: External Procedures > Name Case Interpretation
Alternate Options
None
See Also
iface compiler option
ALIAS Directive
pad-source, Qpad-source
Specifies padding for fixed-form source records.
Syntax
Linux OS:
-pad-source
-nopad-source
macOS:
-pad-source
-nopad-source
Windows OS:
/pad-source
/nopad-source
/Qpad-source
/Qpad-source-
Arguments
None
Default
Description
This option specifies padding for fixed-form source records. It tells the compiler that fixed-form source lines
shorter than the statement field width are to be padded with spaces to the end of the statement field. This
affects the interpretation of character and Hollerith literals that are continued across source records.
The default value setting causes a warning message to be displayed if a character or Hollerith literal that
ends before the statement field ends is continued onto the next source record. To suppress this warning
message, specify setting nousage for option warn.
Specifying [Q]pad-source can prevent warning messages associated with setting usage for option warn.
447
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IDE Equivalent
Windows
Visual Studio: Language > Pad Fixed Form Source Lines
Alternate Options
None
See Also
warn compiler option
stand
Tells the compiler to issue compile-time messages for
nonstandard language elements.
Syntax
Linux OS:
-stand [keyword]
-nostand
macOS:
-stand [keyword]
-nostand
Windows OS:
/stand[:keyword]
/nostand
Arguments
keyword Specifies the language to use as the standard. Possible values are:
f90 Issues messages for language elements that are not standard in Fortran 90.
f95 Issues messages for language elements that are not standard in Fortran 95.
f03 Issues messages for language elements that are not standard in Fortran 2003.
f08 Issues messages for language elements that are not standard in Fortran 2008.
f18 Issues messages for language elements that are not standard in Fortran 2018.
Default
Description
This option tells the compiler to issue compile-time messages for nonstandard language elements.
If you do not specify a keyword for stand, it is the same as specifying stand f18.
448
Compiler Reference
Option Description
stand none Tells the compiler to issue no messages for nonstandard language elements. This is
the same as specifying nostand.
stand f90 Tells the compiler to issue messages for language elements that are not standard in
Fortran 90.
stand f95 Tells the compiler to issue messages for language elements that are not standard in
Fortran 95.
stand f03 Tells the compiler to issue messages for language elements that are not standard in
Fortran 2003.
stand f08 Tells the compiler to issue messages for language elements that are not standard in
Fortran 2008.
stand f18 Tells the compiler to issue messages for language elements that are not standard in
Fortran 2018. This option is set if you specify warn stderrors.
NOTE
When you specify this option, things that are not provided for in the Fortran standard at the
specified standard level are diagnosed with warnings - this includes compiler directives
recognized by ifort.
These standard compliance warnings can be ignored as they are informational only and do not affect
compilation.
IDE Equivalent
Visual Studio
Visual Studio: Diagnostics > Warn For Nonstandard Fortran
Alternate Options
Windows: /4Ys
Windows: None
Windows: None
Windows: /stand
Windows: none
449
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
warn stderrors compiler option
standard-realloc-lhs
Determines whether the compiler uses the current
Fortran Standard rules or the old Fortran 2003 rules
when interpreting assignment statements.
Syntax
Linux OS:
-standard-realloc-lhs
-nostandard-realloc-lhs
macOS:
-standard-realloc-lhs
-nostandard-realloc-lhs
Windows OS:
/standard-realloc-lhs
/nostandard-realloc-lhs
Arguments
None
Default
standard-realloc-lhs The compiler uses the current Fortran Standard rules when interpreting
assignment statements.
Description
This option determines whether the compiler uses the current Fortran Standard rules or the old Fortran 2003
rules when interpreting assignment statements.
Option standard-realloc-lhs (the default), tells the compiler that when the left-hand side of an
assignment is an allocatable object, it should be reallocated to the shape of the right-hand side of the
assignment before the assignment occurs. This is the current Fortran Standard definition. This feature may
cause extra overhead at run time. This option has the same effect as option assume realloc_lhs.
If you specify nostandard-realloc-lhs, the compiler uses the old Fortran 2003 rules when interpreting
assignment statements. The left-hand side is assumed to be allocated with the correct shape to hold the
right-hand side. If it is not, incorrect behavior will occur. This option has the same effect as option
assume norealloc_lhs.
IDE Equivalent
None
Alternate Options
None
standard-semantics
Determines whether the current Fortran Standard
behavior of the compiler is fully implemented.
450
Compiler Reference
Syntax
Linux OS:
-standard-semantics
macOS:
-standard-semantics
Windows OS:
/standard-semantics
Arguments
None
Default
OFF The compiler implements most but not all of the current Fortran Standard behavior.
Description
This option determines whether the current Fortran Standard behavior of the compiler is fully implemented.
If you specify option standard-semantics, it enables all of the options that implement the current Fortran
Standard behavior of the compiler, which is Fortran 2018 features.
Option standard-semantics enables option fpscomp logicals and the following settings for option
assume: byterecl, failed_images, fpe_summary, ieee_compares, ieee_fpe_flags (if the fp-model option
setting is strict or precise), minus0, nan_compares, noold_inquire_recl, noold_ldout_format,
noold_ldout_zero, noold_maxminloc, noold_unit_star, noold_xor, protect_parens, realloc_lhs1, recursion,
std_intent_in, std_minus0_rounding1, std_mod_proc_name, and std_value1.
If you specify option standard-semantics and also explicitly specify a different setting for an affected
assume option, the value you specify takes effect. It overrides the settings enabled by option
standard-semantics.
IDE Equivalent
Windows
Visual Studio: Language > Enable F2008 Semantics
Alternate Options
None
See Also
assume compiler option
stand compiler option
syntax-only
Tells the compiler to check only for correct syntax.
Syntax
Linux OS:
-syntax-only
451
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
macOS:
-syntax-only
Windows OS:
/syntax-only
Arguments
None
Default
Description
This option tells the compiler to check only for correct syntax. It lets you do a quick syntax check of your
source file.
Compilation stops after the source file has been parsed. No code is generated, no object file is produced, and
some error checking done by the optimizer is bypassed.
Warnings and messages appear on stderr.
IDE Equivalent
None
Alternate Options
Linux: -y, -fsyntax-only, -syntax (this is a deprecated option)
Windows: /Zs
wrap-margin
Provides a way to disable the right margin wrapping
that occurs in Fortran list-directed output.
Syntax
Linux OS:
-wrap-margin
-no-wrap-margin
macOS:
None
Windows OS:
/wrap-margin
/wrap-margin-
Arguments
None
452
Compiler Reference
Default
wrap-margin The right margin wraps at column 80 if the record length is greater than 80
characters.
Description
This option provides a way to disable the right margin wrapping that occurs in Fortran list-directed output. By
default, when the record being written becomes longer than 80 characters, the record is wrapped to a new
record at what is called the "right margin".
Specify -no-wrap-margin (Linux*) or /wrap-margin- (Windows*) to disable this behavior.
IDE Equivalent
None
Alternate Options
None
Data Options
This section contains descriptions for compiler options that pertain to the treatment of data.
align
Tells the compiler how to align certain data items.
Syntax
Linux OS:
-align [keyword[, keyword...]]
-noalign
macOS:
-align [keyword[, keyword...]]
-noalign
Windows OS:
/align[:keyword[, keyword...]]
/noalign
Arguments
453
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
all Adds padding bytes whenever possible to data items in common blocks
and structures.
Default
records Aligns derived-type components and record structure fields on default natural
boundaries.
Description
This option specifies the alignment to use for certain data items. The compiler adds padding bytes to perform
the alignment.
Option Description
align none Tells the compiler not to add padding bytes anywhere in common blocks or
structures. This is the same as specifying noalign.
align arraynbyte Aligns the start of arrays on an n-byte boundary. n can be 8, 16, 32, 64, 128, or
256. The default value for n is 8. This affects the starting alignment for all
arrays except for arrays in COMMON.
Arrays do not have padding between their elements.
align commons Aligns all common block entities on natural boundaries up to 4 bytes, by adding
padding bytes as needed.
The align nocommons option adds no padding to common blocks. In this case,
unaligned data can occur unless the order of data items specified in the
COMMON statement places the largest numeric data item first, followed by the
next largest numeric data (and so on), followed by any character data.
align dcommons Aligns all common block entities on natural boundaries up to 8 bytes, by adding
padding bytes as needed.
The align nodcommons option adds no padding to common blocks.
align qcommons Aligns all common block entities on natural boundaries up to 16 bytes, by adding
padding bytes as needed.
454
Compiler Reference
Option Description
align zcommons Aligns all common block entities on natural boundaries up to 32 bytes, by adding
padding bytes as needed.
The align nozcommons option adds no padding to common blocks.
align norecords Aligns components of derived types and fields within record structures on
arbitrary byte boundaries with no padding.
The align records option requests that multiple data items in record structures
and derived-type structures without the SEQUENCE statement be naturally
aligned, by adding padding as needed.
align recnbyte Aligns components of derived types and fields within record structures on the
smaller of the size boundary specified (n) or the boundary that will naturally
align them. n can be 1, 2, 4, 8, 16, or 32. The default value for n is 8. When you
specify this option, each structure member after the first is stored on either the
size of the member type or n-byte boundaries, whichever is smaller. For
example, to specify 16 bytes as the packing boundary (or alignment constraint)
for all structures and unions in the file prog1.f, use the following command:
ifort {-align rec16byte | /align:rec16byte} prog1.f
This option does not affect whether common blocks are naturally aligned or
packed.
align sequence Aligns components of a derived type declared with the SEQUENCE statement
(sequenced components) according to the alignment rules that are currently in
use. The default alignment rules are to align unsequenced components on
natural boundaries.
The align nosequence option requests that sequenced components be packed
regardless of any other alignment rules. Note that align none implies
align nosequence.
If you specify an option for standards checking, align sequence is ignored.
align all Tells the compiler to add padding bytes whenever possible to obtain the natural
alignment of data items in common blocks, derived types, and record structures.
Specifies align dcommons, align records, align nosequence. This is the
same as specifying align with no keyword.
IDE Equivalent
Visual Studio
Visual Studio: Data > Structure Member Alignment (/align:recnbyte)
Data > Alignment of COMMON block entities (/align:[no]commons, /align:[no]dcommons, /align:
[no]qcommons, /align:[no]zcommons)
Data > SEQUENCE Types Obey Alignment Rules (/align:[no]sequence)
Data > Default Array Alignment (/align:arraynbyte)
Alternate Options
455
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows: /noalign
Windows: /Zp{1|2|4|8|16}
auto
Causes all local, non-SAVEd variables to be allocated
to the run-time stack.
Syntax
Linux OS:
-auto
-noauto
macOS:
-auto
-noauto
Windows OS:
/auto
/noauto
Arguments
None
Default
-auto-scalar Scalar variables of intrinsic types INTEGER, REAL, COMPLEX, and LOGICAL
or /Qauto-scalar are allocated to the run-time stack. Note that the default changes to auto if
one of the following options are specified:
• recursive
• [q or Q]openmp
Description
This option places local variables (scalars and arrays of all types), except those declared as SAVE, on the
run-time stack. It is as if the variables were declared with the AUTOMATIC attribute.
It does not affect variables that have the SAVE attribute or ALLOCATABLE attribute, or variables that appear
in an EQUIVALENCE statement or in a common block.
456
Compiler Reference
This option may provide a performance gain for your program, but if your program depends on variables
having the same value as the last time the routine was invoked, your program may not function properly.
If you want to cause variables to be placed in static memory, specify option [Q]save. If you want only scalar
variables of certain intrinsic types to be placed on the run-time stack, specify option auto-scalar.
NOTE
On Windows NT* systems, there is a performance penalty for addressing a stack frame that
is too large. This penalty may be incurred with /[Q]auto, because arrays are allocated on
the stack along with scalars. However, with /Qauto-scalar, you would have to have more
than 32K bytes of local scalar variables before you incurred the performance
penalty. /Qauto-scalar enables the compiler to make better choices about which variables
should be kept in registers during program execution.
IDE Equivalent
Visual Studio
Visual Studio: Data > Local Variable Storage
Alternate Options
See Also
auto-scalar, Qauto-scalar compiler option
save, Qsave compiler option
auto-scalar, Qauto-scalar
Causes scalar variables of intrinsic types INTEGER,
REAL, COMPLEX, and LOGICAL that do not have the
SAVE attribute to be allocated to the run-time stack.
Syntax
Linux OS:
-auto-scalar
macOS:
-auto-scalar
Windows OS:
/Qauto-scalar
Arguments
None
457
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
-auto-scalar Scalar variables of intrinsic types INTEGER, REAL, COMPLEX, and LOGICAL
or /Qauto-scalar that do not have the SAVE attribute are allocated to the run-time stack.
Note that the default changes to auto if one of the following options are
specified:
• recursive
• [q or Q]openmp
Description
This option causes allocation of scalar variables of intrinsic types INTEGER, REAL, COMPLEX, and LOGICAL to
the run-time stack. It is as if they were declared with the AUTOMATIC attribute.
It does not affect variables that have the SAVE attribute (which include initialized locals) or that appear in an
EQUIVALENCE statement or in a common block.
This option may provide a performance gain for your program, but if your program depends on variables
having the same value as the last time the routine was invoked, your program may not function properly.
Variables that need to retain their values across subroutine calls should appear in a SAVE statement.
You cannot specify option save or auto with this option.
NOTE
On Windows NT* systems, there is a performance penalty for addressing a stack frame that
is too large. This penalty may be incurred with [Q]auto because arrays are allocated on the
stack along with scalars. However, with /Qauto-scalar, you would have to have more than
32K bytes of local scalar variables before you incurred the performance
penalty. /Qauto-scalar enables the compiler to make better choices about which variables
should be kept in registers during program execution.
IDE Equivalent
Visual Studio
Visual Studio: Data > Local Variable Storage (/Qsave, /Qauto, /Qauto_scalar)
Alternate Options
None
See Also
auto compiler option
save compiler option
convert
Specifies the format of unformatted files containing
numeric data.
Syntax
Linux OS:
-convert keyword
macOS:
-convert keyword
458
Compiler Reference
Windows OS:
/convert:keyword
Arguments
keyword Specifies the format for the unformatted numeric data. Possible values are:
big_endian Specifies that the format will be big endian for integer data and
big endian IEEE floating-point for real and complex data.
cray Specifies that the format will be big endian for integer data and
CRAY* floating-point for real and complex data.
fdx Specifies that the format will be little endian for integer data, and
(Linux*, macOS*) VAX processor floating-point format F_floating, D_floating, and
IEEE binary128 for real and complex data.
fgx Specifies that the format will be little endian for integer data, and
(Linux, macOS*) VAX processor floating-point format F_floating, G_floating, and
IEEE binary128 for real and complex data.
ibm Specifies that the format will be big endian for integer data and
IBM* System\370 floating-point format for real and complex
data.
little_endian Specifies that the format will be little endian for integer data and
little endian IEEE floating-point for real and complex data.
vaxd Specifies that the format will be little endian for integer data, and
VAX* processor floating-point format F_floating, D_floating, and
H_floating for real and complex data.
vaxg Specifies that the format will be little endian for integer data, and
VAX processor floating-point format F_floating, G_floating, and
H_floating for real and complex data.
Default
Description
This option specifies the format of unformatted files containing numeric data.
Option Description
convert big_endian Specifies that the format will be big endian for INTEGER*1, INTEGER*2,
INTEGER*4, or INTEGER*8, and big endian IEEE floating-point for
REAL*4, REAL*8, REAL*16, COMPLEX*8, COMPLEX*16, or COMPLEX*32.
convert cray Specifies that the format will be big endian for INTEGER*1, INTEGER*2,
INTEGER*4, or INTEGER*8, and CRAY* floating-point for REAL*8 or
COMPLEX*16.
459
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Option Description
convert fdx Specifies that the format will be little endian for INTEGER*1, INTEGER*2,
INTEGER*4, or INTEGER*8, and VAX processor floating-point format
F_floating for REAL*4 or COMPLEX*8, D_floating for REAL*8 or
COMPLEX*16, and IEEE binary128 for REAL*16 or COMPLEX*32.
convert fgx Specifies that the format will be little endian for INTEGER*1, INTEGER*2,
INTEGER*4, or INTEGER*8, and VAX processor floating-point format
F_floating for REAL*4 or COMPLEX*8, G_floating for REAL*8 or
COMPLEX*16, and IEEE binary128 for REAL*16 or COMPLEX*32.
convert ibm Specifies that the format will be big endian for INTEGER*1, INTEGER*2,
or INTEGER*4, and IBM* System\370 floating-point format for REAL*4 or
COMPLEX*8 (IBM short 4) and REAL*8 or COMPLEX*16 (IBM long 8).
convert little_endian Specifies that the format will be little endian for INTEGER*1, INTEGER*2,
INTEGER*4, or INTEGER*8 and little endian IEEE floating-point for
REAL*4, REAL*8, REAL*16, COMPLEX*8, COMPLEX*16, or COMPLEX*32.
convert vaxd Specifies that the format will be little endian for INTEGER*1, INTEGER*2,
INTEGER*4, or INTEGER*8, and VAX processor floating-point format
F_floating for REAL*4 or COMPLEX*8, D_floating for REAL*8 or
COMPLEX*16, and H_floating for REAL*16 or COMPLEX*32.
convert vaxg Specifies that the format will be little endian for INTEGER*1, INTEGER*2,
INTEGER*4, or INTEGER*8, and VAX processor floating-point format
F_floating for REAL*4 or COMPLEX*8, G_floating for REAL*8 or
COMPLEX*16, and H_floating for REAL*16 or COMPLEX*32.
Non-native data conversion works on scalars and arrays of intrinsic types: INTEGER*1, INTEGER*2,
INTEGER*4, INTEGER*8, including LOGICAL*1, LOGICAL*2, LOGICAL*4, LOGICAL*8, and REAL*4, REAL*8,
REAL*16, including COMPLEX*8, COMPLEX*16, and COMPLEX*32. Conversion does not work inside defined
type records on their individual fields. For example:
type REC
integer(8) :: K
real(8) :: X
end type REC
type (REC) :: R
IDE Equivalent
Windows
Visual Studio: Compatibility > Unformatted File Conversion
Alternate Options
None
double-size
Specifies the default KIND for DOUBLE PRECISION
and DOUBLE COMPLEX declarations, constants,
functions, and intrinsics.
460
Compiler Reference
Syntax
Linux OS:
-double-size size
macOS:
-double-size size
Windows OS:
/double-size:size
Arguments
size Specifies the default KIND for DOUBLE PRECISION and DOUBLE COMPLEX declarations,
constants, functions, and intrinsics. Possible values are: 64 (KIND=8) or 128 (KIND=16).
Default
64 DOUBLE PRECISION variables are defined as REAL*8 and DOUBLE COMPLEX variables are defined
as COMPLEX*16.
Description
This option defines the default KIND for DOUBLE PRECISION and DOUBLE COMPLEX declarations, constants,
functions, and intrinsics.
Option Description
double-size 128 Defines DOUBLE PRECISION declarations, constants, functions, and intrinsics as
REAL(KIND=16) (REAL*16) and defines DOUBLE COMPLEX declarations, functions,
and intrinsics as COMPLEX(KIND=16) (COMPLEX*32).
The real-size option overrides the double-size option; for example, on Linux* systems, "-double-size 64
-real-size 128" acts like "-double-size 128 -real-size 128".
IDE Equivalent
Windows
Visual Studio: Data > Default Double Precision KIND
Alternate Options
None
dyncom, Qdyncom
Enables dynamic allocation of common blocks at run
time.
Syntax
Linux OS:
-dyncom "common1,common2,..."
461
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
macOS:
-dyncom "common1,common2,..."
Windows OS:
/Qdyncom "common1,common2,..."
Arguments
common1,common2,... Are the names of the common blocks to be dynamically allocated. The list of
names must be within quotes.
Default
Description
This option enables dynamic allocation of the specified common blocks at run time. For example, to enable
dynamic allocation of common blocks a, b, and c at run time, use this syntax:
NOTE
On macOS* systems, to successfully enable dynamic allocation of common blocks, you must
specify the link-time option -undefined dynamic_lookup as well as option -dyncom.
IDE Equivalent
Windows
Visual Studio: Data > Dynamic Common Blocks
Alternate Options
None
See Also
Allocating Common Blocks
FOR__SET_FTN_ALLOC
falign-functions, Qfnalign
Tells the compiler to align procedures on an optimal
byte boundary.
Syntax
Linux OS:
-falign-functions[=n]
462
Compiler Reference
-fno-align-functions
macOS:
-falign-functions[=n]
-fno-align-functions
Windows OS:
/Qfnalign[:n]
/Qfnalign-
Arguments
Default
-fno-align-functions The compiler aligns procedures on 2-byte boundaries. This is the same as
or /Qfnalign- specifying -falign-functions=2 (Linux* and macOS*) or /Qfnalign:2
(Windows*).
Description
This option tells the compiler to align procedures on an optimal byte boundary. If you do not specify n, the
compiler aligns the start of procedures on 16-byte boundaries.
IDE Equivalent
None
Alternate Options
None
falign-loops, Qalign-loops
Aligns loops to a power-of-two byte boundary. This
feature is only available for ifort.
Syntax
Linux OS:
-falign-loops[=n]
-fno-align-loops
macOS:
-falign-loops[=n]
-fno-align-loops
463
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows OS:
/Qalign-loops[:n]
/Qalign-loops-
Arguments
n Is the optional number of bytes for the minimum alignment boundary. It must be a power of 2
between 1 and 4096, such as 1, 2, 4, 8, 16, 32, 64, 128, and so on.
If you specify 1 for n, no alignment is performed; this is the same as specifying the negative form
of the option.
If you do not specify n, the default alignment is 16 bytes.
Default
Description
This option aligns loops to a power-of-two boundary. This alignment may improve performance.
It can be affected by the directives CODE_ALIGN and ATTRIBUTES CODE_ALIGN.
If code is compiled with the -falign-loops=m (Linux* and macOS*) or /Qalign-loops:m (Windows*)
option and a CODE_ALIGN:n directive precedes a loop, the loop is aligned on a MAX (m, n) byte boundary. If
a procedure has the CODE_ALIGN:k attribute and a CODE_ALIGN:n directive precedes a loop, then both the
procedure and the loop are aligned on a MAX (k, n) byte boundary.
IDE Equivalent
None
Alternate Options
None
Example
Consider the following code fragment in file test_align_loops.f90:
DO J = 1, N
…
END DO
Compiling test_align_loops.f90 with the -falign-loops (Linux and macOS*) or /Qalign-loops
(Windows) compiler option aligns the code that begins the DO J loop on a (default) 16-byte boundary. If you
do not specify this compiler option, the alignment of the loop is implementation-dependent and may change
from compilation to compilation.
See Also
falign-functions, Qfnalign compiler option
CODE_ALIGN directive
ATTRIBUTES CODE_ALIGN directive
464
Compiler Reference
falign-stack
Tells the compiler the stack alignment to use on entry
to routines. This option is deprecated and will be
removed in a future release. This feature is only
available for ifort.
Architecture Restrictions
Only available on IA-32 architecture. IA-32 support is deprecated and will be removed in a future release.
Syntax
Linux OS:
-falign-stack=mode
macOS:
None
Windows OS:
None
Arguments
mode Is the method to use for stack alignment. Possible values are:
Default
Description
This option tells the compiler the stack alignment to use on entry to routines.
IDE Equivalent
None
Alternate Options
None
465
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
fcommon
Determines whether the compiler treats common
symbols as global definitions. This feature is only
available for ifort.
Syntax
Linux OS:
-fcommon
-fno-common
macOS:
-fcommon
-fno-common
Windows OS:
None
Arguments
None
Default
-fcommon The compiler does not treat common symbols as global definitions.
Description
This option determines whether the compiler treats common symbols as global definitions and to allocate
memory for each symbol at compile time.
Option -fno-common tells the compiler to treat common symbols as global definitions. When using this
option, you can only have a common variable declared in one module; otherwise, a link time error will occur
for multiple defined symbols.
On macOS*, if a library built with the ar utility contains objects with Fortran module data but no executable
functions, the symbols corresponding to the module data may not be resolved when an object referencing
them is linked against the library. You can work around this by compiling with option -fno-common.
IDE Equivalent
None
Alternate Options
None
fkeep-static-consts, Qkeep-static-consts
Tells the compiler to preserve allocation of variables
that are not referenced in the source. This feature is
only available for ifort.
Syntax
Linux OS:
-fkeep-static-consts
466
Compiler Reference
-fno-keep-static-consts
macOS:
-fkeep-static-consts
-fno-keep-static-consts
Windows OS:
/Qkeep-static-consts
/Qkeep-static-consts-
Arguments
None
Default
Description
This option tells the compiler to preserve allocation of variables that are not referenced in the source.
The negated form can be useful when optimizations are enabled to reduce the memory usage of static data.
IDE Equivalent
None
Alternate Options
None
fmath-errno
Tells the compiler that errno can be reliably tested
after calls to standard math library functions. This
feature is only available for ifort.
Syntax
Linux OS:
-fmath-errno
-fno-math-errno
macOS:
-fmath-errno
-fno-math-errno
Windows OS:
None
Arguments
None
467
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
-fno-math-errno The compiler assumes that the program does not test errno after
calls to standard math library functions.
Description
This option tells the compiler to assume that the program tests errno after calls to math library functions.
This restricts optimization because it causes the compiler to treat most math functions as having side effects.
Option -fno-math-errno tells the compiler to assume that the program does not test errno after calls to
math library functions. This frequently allows the compiler to generate faster code. Floating-point code that
relies on IEEE exceptions instead of errno to detect errors can safely use this option to improve
performance.
IDE Equivalent
None
Alternate Options
None
fminshared
Specifies that a compilation unit is a component of a
main program and should not be linked as part of a
shareable object. This feature is only available for
ifort.
Syntax
Linux OS:
-fminshared
macOS:
-fminshared
Windows OS:
None
Arguments
None
Default
OFF Source files are compiled together to form a single object file.
Description
This option specifies that a compilation unit is a component of a main program and should not be linked as
part of a shareable object.
This option allows the compiler to optimize references to defined symbols without special visibility settings.
To ensure that external and common symbol references are optimized, you need to specify visibility hidden
or protected by using the -fvisibility, -fvisibility-hidden, or -fvisibility-protected option.
468
Compiler Reference
Also, the compiler does not need to generate position-independent code for the main program. It can use
absolute addressing, which may reduce the size of the global offset table (GOT) and may reduce memory
traffic.
IDE Equivalent
None
Alternate Options
None
See Also
fvisibility compiler option
fpconstant
Tells the compiler that single-precision constants
assigned to double-precision variables should be
evaluated in double precision.
Syntax
Linux OS:
-fpconstant
-nofpconstant
macOS:
-fpconstant
-nofpconstant
Windows OS:
/fpconstant
/nofpconstant
Arguments
None
Default
Description
This option tells the compiler that single-precision constants assigned to double-precision variables should be
evaluated in double precision.
This is extended precision. It does not comply with the Fortran 2003 standard, which requires that single-
precision constants assigned to double-precision variables be evaluated in single precision.
It allows compatibility with FORTRAN 77, where such extended precision was allowed. If this option is not
used, certain programs originally created for FORTRAN 77 compilers may show different floating-point results
because they rely on the extended precision for single-precision constants assigned to double-precision
variables.
469
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IDE Equivalent
Windows
Visual Studio: Floating-Point > Extend Precision of Single-Precision Constants
Alternate Options
None
Example
In the following example, if you specify fpconstant, identical values are assigned to D1 and D2. If you omit
fpconstant, the compiler will obey the Fortran 2003 Standard and assign a less precise value to D1:
fpic
Determines whether the compiler generates position-
independent code.
Syntax
Linux OS:
-fpic
-fno-pic
macOS:
-fpic
-fno-pic
Windows OS:
None
Arguments
None
Default
Description
This option determines whether the compiler generates position-independent code.
Option -fpic specifies full symbol preemption. Global symbol definitions as well as global symbol references
get default (that is, preemptable) visibility unless explicitly specified otherwise.
Option -fpic must be used when building shared objects.
IDE Equivalent
None
470
Compiler Reference
Alternate Options
None
fpie
Tells the compiler to generate position-independent
code. The generated code can only be linked into
executables.
Syntax
Linux OS:
-fpie
macOS:
None
Windows OS:
None
Arguments
None
Default
Description
This option tells the compiler to generate position-independent code. It is similar to -fpic, but code
generated by -fpie can only be linked into an executable.
Because the object is linked into an executable, this option causes better optimization of some symbol
references.
To ensure that run-time libraries are set up properly for the executable, you should also specify option -pie
to the compiler driver on the link command line.
Option -fpie can also be specified as -fPIE.
IDE Equivalent
None
Alternate Options
None
See Also
fpic compiler option
pie compiler option
fstack-protector
Enables or disables stack overflow security checks for
certain (or all) routines.
471
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-fstack-protector[-keyword]
-fno-stack-protector[-keyword]
macOS:
-fstack-protector[-keyword]
-fno-stack-protector[-keyword]
Windows OS:
None
Arguments
If no -keyword is specified, option -fstack-protector enables stack overflow security checks for routines
with a string buffer.
Default
-fno-stack-protector, No stack overflow security checks are enabled for the relevant
-fno-stack-protector-strong routines.
-fno-stack-protector-all No stack overflow security checks are enabled for any routines.
Description
This option enables or disables stack overflow security checks for certain (or all) routines. A stack overflow
occurs when a program stores more data in a variable on the execution stack than is allocated to the
variable. Writing past the end of a string buffer or using an index for an array that is larger than the array
bound could cause a stack overflow and security violations.
The -fstack-protector options are provided for compatibility with gcc. They use the gcc/glibc
implementation when possible. If the gcc/glibc implementation is not available, they use the Intel
implementation.
For an Intel-specific version of this feature, see option -fstack-security-check.
IDE Equivalent
None
Alternate Options
None
See Also
fstack-security-check compiler option
GS compiler option
472
Compiler Reference
fstack-security-check
Determines whether the compiler generates code that
detects some buffer overruns.
Syntax
Linux OS:
-fstack-security-check
-fno-stack-security-check
macOS:
-fstack-security-check
-fno-stack-security-check
Windows OS:
None
Arguments
None
Default
Description
This option determines whether the compiler generates code that detects some buffer overruns that
overwrite the return address. This is a common technique for exploiting code that does not enforce buffer
size restrictions.
This option always uses an Intel implementation.
For a gcc-compliant version of this feature, see option fstack-protector.
IDE Equivalent
None
Alternate Options
Linux and macOS*: None
Windows: /GS
See Also
fstack-protector compiler option
GS compiler option
fvisibility
Specifies the default visibility for global symbols or the
visibility for symbols in a file. This feature is only
available for ifort.
473
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-fvisibility=keyword
-fvisibility-keyword=filename
macOS:
-fvisibility=keyword
-fvisibility-keyword=filename
Windows OS:
None
Arguments
filename Is the pathname of a file containing the list of symbols whose visibility
you want to set. The symbols must be separated by whitespace
(spaces, tabs, or newlines).
Default
Description
This option specifies the default visibility for global symbols (syntax -fvisibility=keyword) or the visibility
for symbols in a file (syntax -fvisibility-keyword=filename).
Option Description
474
Compiler Reference
Option Description
If an -fvisibility option is specified more than once on the command line, the last specification takes
precedence over any others.
If a symbol appears in more than one visibility filename, the setting with the least visibility takes precedence.
The following shows the precedence of the visibility settings (from greatest to least visibility):
• extern
• default
• protected
• hidden
• internal
Note that extern visibility only applies to functions. If a variable symbol is specified as extern, it is
assumed to be default.
IDE Equivalent
None
Alternate Options
None
Example
A file named prot.txt contains symbols a, b, c, d, and e. Consider the following:
-fvisibility-protected=prot.txt
This option sets protected visibility for all the symbols in the file. It has the same effect as specifying
fvisibility=protected in the declaration for each of the symbols.
475
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
fzero-initialized-in-bss, Qzero-initialized-in-bss
Determines whether the compiler places in the DATA
section any variables explicitly initialized with zeros.
This feature is only available for ifort.
Syntax
Linux OS:
-fzero-initialized-in-bss
-fno-zero-initialized-in-bss
macOS:
-fzero-initialized-in-bss
-fno-zero-initialized-in-bss
Windows OS:
/Qzero-initialized-in-bss
/Qzero-initialized-in-bss-
Arguments
None
Default
-fno-zero-initialized-in-bss Variables explicitly initialized with zeros are placed in the BSS
or /Qzero-initialized-in-bss- section. This can save space in the resulting code.
Description
This option determines whether the compiler places in the DATA section any variables explicitly initialized
with zeros.
If option -fno-zero-initialized-in-bss (Linux* and macOS*) or /Qzero-initialized-in-bss-
(Windows*) is specified, the compiler places in the DATA section any variables that are initialized to zero.
IDE Equivalent
None
Alternate Options
None
Gs
Lets you control the threshold at which the stack
checking routine is called or not called. This feature is
only available for ifort.
Syntax
Linux OS:
None
macOS:
None
476
Compiler Reference
Windows OS:
/Gs[n]
Arguments
Default
/Gs Stack checking occurs for routines that require more than 4KB (4096 bytes) of stack space. This
is also the default if you do not specify n.
Description
This option lets you control the threshold at which the stack checking routine is called or not called. If a
routine's local stack allocation exceeds the threshold (n), the compiler inserts a __chkstk() call into the
prologue of the routine.
IDE Equivalent
None
Alternate Options
None
GS
Determines whether the compiler generates code that
detects some buffer overruns.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/GS[:keyword]
/GS-
Arguments
keyword Specifies the level of stack protection heuristics used by the compiler. Possible values are:
off Tells the compiler to ignore buffer overruns. This is the same
as specifying /GS-.
477
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
strong Tells the compiler to provide full stack security level checking.
This setting is compatible with more recent Microsoft* Visual
Studio stack protection heuristics. This is the same as
specifying /GS with no keyword.
Default
Description
This option determines whether the compiler generates code that detects some buffer overruns that
overwrite a function's return address, exception handler address, or certain types of parameters.
This option has been added for Microsoft compatibility.
Following Visual Studio 2008, the Microsoft implementation of option /GS became more extensive (for
example, more routines are protected). The performance of some programs may be impacted by the newer
heuristics. In such cases, you may see better performance if you specify /GS:partial.
For more details about option /GS, see the Microsoft documentation.
IDE Equivalent
None
Alternate Options
Linux and macOS*: -fstack-security-check
Windows: None
See Also
fstack-security-check compiler option
fstack-protector compiler option
homeparams
Tells the compiler to store parameters passed in
registers to the stack. This feature is only available for
ifort.
Architecture Restrictions
Only available on Intel® 64 architecture
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/homeparams
Arguments
None
478
Compiler Reference
Default
Description
This option tells the compiler to store parameters passed in registers to the stack.
IDE Equivalent
None
Alternate Options
None
init, Qinit
Lets you initialize a class of variables to zero or to
various numeric exceptional values.
Syntax
Linux OS:
-init=keyword [, keyword ]
macOS:
-init=keyword [, keyword ]
Windows OS:
/Qinit:keyword [, keyword ]
Arguments
keyword Specifies the initial value for a class of variables. Possible values are:
479
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
OFF No initializations are performed by default if you do not specify any of these options.
Description
This option lets you initialize a class of variables to zero or to one or more of the various numeric exceptional
values positive or negative huge, positive or negative Infinity, signaling NaN, or positive or negative tiny.
If you only specify the keyword [minus_]huge, [minus_]infinity, snan, [minus_]tiny, or zero, option
[Q]init affects only scalar variables. To apply an initialization to arrays as well, you must also specify the
keyword arrays.
If you have specified an ALLOCATE statement and you specify one or more [Q]init keywords, the initializers
are applied to the memory that has been allocated by the ALLOCATE statement.
Keywords are applied to the various numeric types in the following order:
• For REAL and COMPLEX variables, keywords [minus_]huge, [minus_]infinity, snan, [minus_]tiny,
and zero initialize to the specified value.
• For INTEGER variables, keywords [minus_]huge and zero initialize to the specified value.
• For LOGICAL variables, keyword zero initializes to .FALSE..
The following classes of variables are initialized by the [Q]init option:
• Variables of intrinsic numeric type, that is, of type COMPLEX, INTEGER, LOGICAL, or REAL, of any KIND
• SAVEd scalar or array variables, not in the main program, that are not initialized in the source code
• Local scalars and arrays
• Module variables that are not initialized in the source code
• Automatic arrays
• Integers can be set to zero, huge, or minus_huge.
• In a COMPLEX variable, each of the real and imaginary parts is separately initialized as a REAL.
• The keywords [minus_]infinity, snan, and [minus_]tiny only affect certain variables of REAL or
COMPLEX type.
• You cannot initialize variables in equivalence groups to any of the numeric exceptional values.
• In an equivalence group, if no member of that equivalence group has an explicit initialization or a default
initialization (in the case of a derived type), a variable in that equivalence group can be initialized to zero
but not to any of the numeric exceptional values.
480
Compiler Reference
• Derived types, arrays of derived types, and their components will not be initialized.
• Dummy arguments including adjustable arrays will not be initialized.
• Variables in COMMON will not be initialized.
The following spellings all cause the same behavior, that is, they initialize certain numeric arrays and scalars
to zero:
1. snan
2. infinity or minus_infinity
3. tiny or minus_tiny
4. huge or minus_huge
5. zero
Because an INTEGER variable can be initialized to huge or minus_huge, or zero, these initializations are
applied in the following order:
1. huge or minus_huge
2. zero
For example, if the you specify [Q]init zero, minus_huge, snan when compiling the following program:
program test
real X
integer K
complex C
end
The variable X will be initialized with a signaling NaN (snan), variable K will be initialized to the integer value
minus_huge, and the real and imaginary parts of variable C will be initialized to a signaling NaN (snan) in
each.
If you specify [Q]init snan, the floating-point exception handling flags will be set to trap signaling NaN and
halt so that when such a value is trapped at run-time, the Fortran library can catch the usage, display an
error message about a possible uninitialized variable, display a traceback, and stop execution. You can use
the debugger to determine where in your code this uninitialized variable is being referenced when execution
stops.
Setting the option [Q]init snan implicitly sets the option fpe 0. A compile time warning will occur if you
specify both option fpe 3 and option [Q]init snan on the command line. In this case, fpe 3 is ignored.
481
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
If you build with optimization, the compiler may speculate floating-point operations,
assuming the default floating-point environment in which floating-point exceptions are
masked. When you add [Q]init snan, this speculation may result in exceptions, unrelated
to uninitialized variables, that now get trapped. To avoid this, reduce the optimization level
to /O1 or /Od (Windows*), or -O1 or -O0 (Linux* and macOS*) when doing uninitialized
variable detection.
If you wish to maintain optimization, you should add option [Q]fp-speculation safe to disable
speculation when there is a possibility that the speculation may result in a floating-point exception.
NOTE
To avoid possible performance issues, you should only use [Q]init for debugging (for
example, [Q]init zero) and checking for uninitialized variables (for example,
[Q]init snan).
Use option [Q]save if you wish all variables to be specifically marked as SAVE.
IDE Equivalent
Visual Studio
Visual Studio: Data > Initialize Variables to Signaling NaN
Data > Initialize Variables to Zero
Data > Initialize Arrays as well as Scalars
Alternate Options
None
Example
The following example shows how to initialize scalars of intrinsic type REAL and COMPLEX to signaling NaN,
and scalars of intrinsic type INTEGER and LOGICAL to zero:
See Also
O compiler option
fp-speculation, Qfp-speculation compiler option
Explicit-Shape Specifications for details on automatic arrays and adjustable arrays
HUGE
TINY
Data Representation Models
482
Compiler Reference
intconstant
Tells the compiler to use FORTRAN 77 semantics to
determine the kind parameter for integer constants.
Syntax
Linux OS:
-intconstant
-nointconstant
macOS:
-intconstant
-nointconstant
Windows OS:
/intconstant
/nointconstant
Arguments
None
Default
Description
This option tells the compiler to use FORTRAN 77 semantics to determine the kind parameter for integer
constants.
With FORTRAN 77 semantics, the kind is determined by the value of the constant. All constants are kept
internally by the compiler in the highest precision possible. For example, if you specify option intconstant,
the compiler stores an integer constant of 14 internally as INTEGER(KIND=8) and converts the constant
upon reference to the corresponding proper size. Fortran specifies that integer constants with no explicit
KIND are kept internally in the default INTEGER kind (KIND=4 by default).
Note that the internal precision for floating-point constants is controlled by option fpconstant.
IDE Equivalent
Windows
Visual Studio: Compatibility > Use F77 Integer Constants
Alternate Options
None
integer-size
Specifies the default KIND for integer and logical
variables.
483
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-integer-size size
macOS:
-integer-size size
Windows OS:
/integer-size:size
Arguments
size Is the size for integer and logical variables. Possible values are: 16, 32, or 64.
Default
integer-size 32 Integer and logical variables are 4 bytes long (INTEGER(KIND=4) and
LOGICAL(KIND=4)).
Description
This option specifies the default size (in bits) for integer and logical variables.
Option Description
integer-size 16 Makes default integer and logical declarations, constants, functions, and intrinsics 2
bytes long. INTEGER and LOGICAL declarations are treated as (KIND=2). Integer
and logical constants of unspecified KIND are evaluated in INTEGER (KIND=2) and
LOGICAL(KIND=2)respectively.
integer-size 32 Makes default integer and logical declarations, constants, functions, and intrinsics 4
bytes long. INTEGER and LOGICAL declarations are treated as (KIND=4). Integer
and logical constants of unspecified KIND are evaluated in INTEGER (KIND=4) and
LOGICAL(KIND=4)respectively.
integer-size 64 Makes default integer and logical declarations, constants, functions, and intrinsics 8
bytes long. INTEGER and LOGICAL declarations are treated as (KIND=8). Integer
and logical constants of unspecified KIND are evaluated in INTEGER (KIND=8) and
LOGICAL(KIND=8)respectively.
IDE Equivalent
Windows
Visual Studio: Data > Default Integer KIND
Alternate Options
Windows: /4I2
Windows: /4I4
484
Compiler Reference
Windows: /4I8
mcmodel
Tells the compiler to use a specific memory model to
generate code and store data.
Architecture Restrictions
Only available on Intel® 64 architecture
Syntax
Linux OS:
-mcmodel=mem_model
macOS:
None
Windows OS:
None
Arguments
Default
-mcmodel=small On systems using Intel® 64 architecture, the compiler restricts code and data to the
first 2GB of address space. Instruction Pointer (IP)-relative addressing can be used to
access code and data.
Description
This option tells the compiler to use a specific memory model to generate code and store data. It can affect
code size and performance. If your program has COMMON blocks and local data with a total size smaller than
2GB, -mcmodel=small is sufficient. COMMONs larger than 2GB require-mcmodel=medium or
-mcmodel=large. Allocation of memory larger than 2GB can be done with any setting of -mcmodel.
IP-relative addressing requires only 32 bits, whereas absolute addressing requires 64-bits. IP-relative
addressing is somewhat faster. So, the small memory model has the least impact on performance.
485
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
When you specify option -mcmodel=medium or -mcmodel=large, it sets option -shared-intel.
This ensures that the correct dynamic versions of the Intel run-time libraries are used.
If you specify option -static-intel while -mcmodel=medium or -mcmodel=large is set, an error will
be displayed.
IDE Equivalent
None
Alternate Options
None
Example
The following example shows how to compile using -mcmodel:
See Also
shared-intel compiler option
fpic compiler option
mdynamic-no-pic
Generates code that is not position-independent but
has position-independent external references. This
feature is only available for ifort.
Syntax
Linux OS:
None
macOS:
-mdynamic-no-pic
Windows OS:
None
Arguments
None
Default
Description
This option generates code that is not position-independent but has position-independent external
references.
The generated code is suitable for building executables, but it is not suitable for building shared libraries.
This option may reduce code size and produce more efficient code. It overrides the -fpic compiler option.
486
Compiler Reference
IDE Equivalent
None
Alternate Options
None
See Also
fpic compiler option
no-bss-init, Qnobss-init
Tells the compiler to place in the DATA section any
uninitialized variables and explicitly zero-initialized
variables. This option is deprecated and will be
removed in a future release. This feature is only
available for ifort.
Syntax
Linux OS:
-no-bss-init
macOS:
-no-bss-init
Windows OS:
/Qnobss-init
Arguments
None
Default
OFF Uninitialized variables and explicitly zero-initialized variables are placed in the BSS section.
Description
This option tells the compiler to place in the DATA section any uninitialized variables and explicitly zero-
initialized variables.
IDE Equivalent
None
Alternate Options
None
Qsfalign
Specifies stack alignment for functions. This option is
deprecated and will be removed in a future release.
This feature is only available for ifort.
Architecture Restrictions
Only available on IA-32 architecture. IA-32 support is deprecated and will be removed in a future release.
487
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/Qsfalign[n]
Arguments
Default
Description
This option specifies stack alignment for functions. It lets you disable the normal optimization that aligns a
stack for 8-byte data.
If you do not specify n, stack alignment occurs for all functions. If you specify /Qsfalign-, no stack
alignment occurs for any function.
IDE Equivalent
None
Alternate Options
None
real-size
Specifies the default KIND for real and complex
declarations, constants, functions, and intrinsics.
488
Compiler Reference
Syntax
Linux OS:
-real-size size
macOS:
-real-size size
Windows OS:
/real-size:size
Arguments
size Is the size for real and complex declarations, constants, functions, and intrinsics. Possible values
are: 32, 64, or 128.
Default
real-size 32 Default real and complex declarations, constants, functions, and intrinsics
are 4 bytes long (REAL(KIND=4) and COMPLEX(KIND=4)).
Description
This option specifies the default size (in bits) for real and complex declarations, constants, functions, and
intrinsics.
Option Description
real-size 32 Makes default real and complex declarations, constants, functions, and intrinsics 4
bytes long. REAL declarations are treated as single precision REAL (REAL(KIND=4))
and COMPLEX declarations are treated as COMPLEX (COMPLEX(KIND=4)). Real and
complex constants of unspecified KIND are evaluated in single precision (KIND=4).
real-size 64 Makes default real and complex declarations, constants, functions, and intrinsics 8
bytes long. REAL declarations are treated as DOUBLE PRECISION (REAL(KIND=8))
and COMPLEX declarations are treated as DOUBLE COMPLEX (COMPLEX(KIND=8)).
Real and complex constants of unspecified KIND are evaluated in double precision
(KIND=8).
real-size 128 Makes default real and complex declarations, constants, functions, and intrinsics 16
bytes long. REAL declarations are treated as extended precision REAL
(REAL(KIND=16)); COMPLEX and DOUBLE COMPLEX declarations are treated as
extended precision COMPLEX (COMPLEX(KIND=16)). Real and complex constants of
unspecified KIND are evaluated in extended precision (KIND=16).
These compiler options can affect the result type of intrinsic procedures, such as CMPLX, FLOAT, REAL, SNGL,
and AIMAG, which normally produce single-precision REAL or COMPLEX results. To prevent this effect, you
must explicitly declare the kind type for arguments of such intrinsic procedures.
For example, if real-size 64 is specified, the CMPLX intrinsic will produce a result of type DOUBLE
COMPLEX (COMPLEX(KIND=8)). To prevent this, you must explicitly declare any real argument to be
REAL(KIND=4), and any complex argument to be COMPLEX(KIND=4).
IDE Equivalent
Windows
Visual Studio: Data > Default Real KIND
489
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Alternate Options
Windows: /4R4
Windows: /4R16
save, Qsave
Causes variables to be placed in static memory.
Syntax
Linux OS:
-save
macOS:
-save
Windows OS:
/Qsave
Arguments
None
Default
-auto-scalar Scalar variables of intrinsic types INTEGER, REAL, COMPLEX, and LOGICAL
or /Qauto-scalar are allocated to the run-time stack. Note that the default changes to auto if
one of the following options are specified:
• recursive
• [q or Q]openmp
Description
This option saves all variables in static allocation except local variables within a recursive routine and
variables declared as AUTOMATIC.
If you want all local, non-SAVEd variables to be allocated to the run-time stack, specify option automatic.
IDE Equivalent
Visual Studio
Visual Studio: Data > Local Variable Storage
Alternate Options
Linux and macOS*: -noauto
490
Compiler Reference
See Also
auto compiler option
auto_scalar compiler option
zero, Qzero
Initializes to zero variables of intrinsic type INTEGER,
REAL, COMPLEX, or LOGICAL that are not yet
initialized. This is a deprecated option. The
replacement option is /Qinit:[no]zero or -
init=[no]zero.
Syntax
Linux OS:
-zero
-nozero
macOS:
-zero
-nozero
Windows OS:
/Qzero
/Qzero-
Arguments
None
Default
Description
This option initializes to zero variables of intrinsic type INTEGER, REAL, COMPLEX, or LOGICAL that are not
yet initialized.
Use option [Q]save on the command line to make all local variables specifically marked as SAVE.
IDE Equivalent
None
Alternate Options
None
See Also
init, Qinit compiler option (see setting zero)
save compiler option
491
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
diag, Qdiag
Controls the display of diagnostic information during
compilation.
Syntax
Linux OS:
-diag-type=diag-list
macOS:
-diag-type=diag-list
Windows OS:
/Qdiag-type:diag-list
Arguments
492
Compiler Reference
Default
Description
This option controls the display of diagnostic information during compilation. Diagnostic messages are output
to stderr unless the [Q]diag-file option is specified.
NOTE
The [Q]diag options do not control diagnostics emitted at run-time. For more information
about run-time errors and diagnostics, see Handling Run-Time Errors.
To control the diagnostic information reported by the vectorizer, use options [q or Q]opt-report and
[q or Q]opt-report-phase, phase vec.
To control the diagnostic information reported by the auto-parallelizer, use options [q or Q]opt-report
and [q or Q]opt-report-phase, phase par.
IDE Equivalent
Visual Studio
Visual Studio: Diagnostics > Disable Specific Diagnostics
493
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Alternate Options
Example
The following example shows how to disable all remarks or comments:
See Also
diag-dump, Qdiag-dump compiler option
diag-id-numbers, Qdiag-id-numbers compiler option
diag-file, Qdiag-file compiler option
qopt-report, Qopt-report compiler option
x, Qx compiler option
494
Compiler Reference
diag-dump, Qdiag-dump
Tells the compiler to print all enabled diagnostic
messages.
Syntax
Linux OS:
-diag-dump
macOS:
-diag-dump
Windows OS:
/Qdiag-dump
Arguments
None
Default
Description
This option tells the compiler to print all enabled diagnostic messages. The diagnostic messages are output to
stdout.
This option prints the enabled diagnostics from all possible diagnostics that the compiler can issue, including
any default diagnostics.
If diag-list is specified for the [Q]diag-enable option, the print out will include the diag-list diagnostics.
IDE Equivalent
None
Alternate Options
None
Example
The following example adds vectorizer diagnostic messages to the printout of default diagnostics:
See Also
diag, Qdiag compiler option
diag-error-limit, Qdiag-error-limit
Specifies the maximum number of errors allowed
before compilation stops.
Syntax
Linux OS:
-diag-error-limit=n
495
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
-no-diag-error-limit
macOS:
-diag-error-limit=n
-no-diag-error-limit
Windows OS:
/Qdiag-error-limit:n
/Qdiag-error-limit-
Arguments
Default
Description
This option specifies the maximum number of errors allowed before compilation stops. It indicates the
maximum number of error-level or fatal-level compiler errors allowed for a file specified on the command
line.
If you specify the negative form of the [Q]diag-error-limit option on the command line, there is no limit
on the number of errors that are allowed.
If the maximum number of errors is reached, a warning message is issued and the next file (if any) on the
command line is compiled.
IDE Equivalent
Visual Studio
Visual Studio: Diagnostics > Error Limit
Alternate Options
Linux and macOS*: -error-limit and -noerror-limit
diag-file, Qdiag-file
Causes the results of diagnostic analysis to be output
to a file.
Syntax
Linux OS:
-diag-file[=filename]
macOS:
None
Windows OS:
/Qdiag-file[:filename]
496
Compiler Reference
Arguments
Default
Description
This option causes the results of diagnostic analysis to be output to a file. The file is placed in the current
working directory.
You can include a file extension in filename. For example, if file.txt is specified, the name of the output file is
file.txt. If you do not provide a file extension, the name of the file is filename.diag.
If filename is not specified, the name of the file is name-of-the-first-source-file.diag. This is also the name of
the file if the name specified for file conflicts with a source file name provided in the command line.
NOTE
If you specify the [Q]diag-file option and you also specify the [Q]diag-file-append
option, the last option specified on the command line takes precedence.
IDE Equivalent
Windows
Visual Studio: Diagnostics > Diagnostics File
Alternate Options
None
Example
The following example shows how to cause diagnostic analysis to be output to a file named
my_diagnostics.diag:
diag-file-append, Qdiag-file-append
Causes the results of diagnostic analysis to be
appended to a file.
Syntax
Linux OS:
-diag-file-append[=filename]
macOS:
None
Windows OS:
/Qdiag-file-append[:filename]
497
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Arguments
filename Is the name of the file to be appended to. It can include a path.
Default
Description
This option causes the results of diagnostic analysis to be appended to a file. If you do not specify a path, the
driver will look for filename in the current working directory.
If filename is not found, then a new file with that name is created in the current working directory. If the
name specified for file conflicts with a source file name provided in the command line, the name of the file is
name-of-the-first-source-file.diag.
NOTE
If you specify the [Q]diag-file-append option and you also specify the [Q]diag-file
option, the last option specified on the command line takes precedence.
IDE Equivalent
None
Alternate Options
None
Example
The following example shows how to cause diagnostic analysis to be appended to a file named
my_diagnostics.txt:
See Also
diag-file, Qdiag-file compiler option
diag-id-numbers, Qdiag-id-numbers
Determines whether the compiler displays diagnostic
messages by using their ID number values.
Syntax
Linux OS:
-diag-id-numbers
-no-diag-id-numbers
macOS:
-diag-id-numbers
-no-diag-id-numbers
Windows OS:
/Qdiag-id-numbers
498
Compiler Reference
/Qdiag-id-numbers-
Arguments
None
Default
-diag-id-numbers The compiler displays diagnostic messages by using their ID number values.
or /Qdiag-id-numbers
Description
This option determines whether the compiler displays diagnostic messages by using their ID number values.
If you specify the negative form of the [Q]diag-id-numbers option, mnemonic names are output for driver
diagnostics only.
IDE Equivalent
None
Alternate Options
None
See Also
diag, Qdiag compiler option
diag-once, Qdiag-once
Tells the compiler to issue one or more diagnostic
messages only once.
Syntax
Linux OS:
-diag-onceid[,id,...]
macOS:
-diag-onceid[,id,...]
Windows OS:
/Qdiag-once:id[,id,...]
Arguments
id Is the ID number of the diagnostic message. If you specify more than one message number, they
must be separated by commas. There can be no intervening white space between each id.
Default
Description
This option tells the compiler to issue one or more diagnostic messages only once.
IDE Equivalent
None
499
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Alternate Options
None
gen-interfaces
Tells the compiler to generate an interface block for
each routine in a source file.
Syntax
Linux OS:
-gen-interfaces [[no]source]
-nogen-interfaces
macOS:
-gen-interfaces [[no]source]
-nogen-interfaces
Windows OS:
/gen-interfaces[:[no]source]
/nogen-interfaces
Arguments
None
Default
nogen-interfaces The compiler does not generate interface blocks for routines in a source file.
Description
This option tells the compiler to generate an interface block for each routine (that is, for each SUBROUTINE
and FUNCTION statement) defined in the source file. The compiler generates two files for each routine,
a .mod file and a .f90 file, and places them in the current directory or in the directory specified by the include
(-I) or -module option. The .f90 file is the text of the interface block; the .mod file is the interface block
compiled into binary form. The .f90 file is for reference only and may not completely represent the generated
interface used by the compiler.
If source is specified, the compiler creates the procedure-name__GENmod.f90 as well as the procedure-
name__GENmod.mod files. If nosource is specified, the compiler creates the procedure-
name__GENmod.mod but not the procedure-name__GENmod.f90 files. If neither is specified, it is the same
as specifying setting source for the gen-interfaces option.
On Windows* systems, for a Debug configuration in a Visual Studio project, the default
is /warn:interfaces.
IDE Equivalent
Visual Studio
Visual Studio: None
Alternate Options
None
500
Compiler Reference
traceback
Tells the compiler to generate extra information in the
object file to provide source file traceback information
when a severe error occurs at run time.
Syntax
Linux OS:
-traceback
-notraceback
macOS:
-traceback
-notraceback
Windows OS:
/traceback
/notraceback
Arguments
None
Default
notraceback No extra information is generated in the object file to produce traceback information.
Description
This option tells the compiler to generate extra information in the object file to provide source file traceback
information when a severe error occurs at run time.
When the severe error occurs, source file, routine name, and line number correlation information is displayed
along with call stack hexadecimal addresses (program counter trace).
Note that when a severe error occurs, advanced users can also locate the cause of the error using a map file
and the hexadecimal addresses of the stack displayed when the error occurs.
This option increases the size of the executable program, but has no impact on run-time execution speeds.
It functions independently of the debug option.
On Windows* systems, traceback sets the /Oy- option, which forces the compiler to use EBP as the stack
frame pointer.
On Windows* systems, the linker places the traceback information in the executable image, in a section
named ".trace". To see which sections are in an image, use the command:
501
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
On Linux* systems, to display the section headers in the image (including the header for the .trace section, if
any), use the command:
objdump -h your_app_name.exe
On macOS* systems, to display the section headers in the image, use the command:
otool -l your_app_name.exe
IDE Equivalent
Windows
Visual Studio: Run-time > Generate Traceback Information
Alternate Options
None
warn
Specifies diagnostic messages to be issued by the
compiler.
Syntax
Linux OS:
-warn [keyword[, keyword...]]
-nowarn
macOS:
-warn [keyword[, keyword...]]
-nowarn
Windows OS:
/warn[:keyword[, keyword...]]
/nowarn
Arguments
502
Compiler Reference
Default
alignments Warnings are issued about data that is not naturally aligned.
noignore_bounds The compiler checks array references with constant subscripts and
warns if the reference is to an element outside the declared bounds of
the array.
nointerfaces The compiler does not check interfaces of SUBROUTINEs called and
FUNCTIONs invoked in your compilation against an external set of
interface blocks.
503
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
noshape Array conformance violations are issued as errors if the check shape
option is specified.
notruncated_source No warnings are issued when source exceeds the maximum column
width in fixed-format files.
nounused No warnings are issued for variables that are declared but never used.
Description
This option specifies the diagnostic messages to be issued by the compiler.
Option Description
warn none Disables all warning messages. This is the same as specifying nowarn.
warn noalignments Disables warnings about data that is not naturally aligned.
warn declarations Enables warnings about any undeclared names. The compiler will use
the default implicit data typing rules for such undeclared names. The
IMPLICIT and IMPLICIT NONE statements override this option.
warn errors Tells the compiler to change all warning-level messages to error-level
messages; this includes warnings about Fortran standards violations.
warn externals Enables warnings about dummy procedures and external procedures
that do not have explicit interfaces and have not been declared with
the EXTERNAL attribute.
warn ignore_bounds The compiler does not check array references with constant subscripts
and no warnings are issued if the reference is to an element outside
the declared bounds of the array.
warn ignore_loc Enables warnings when %LOC is stripped from an actual argument.
warn interfaces Tells the compiler to check the interfaces of all SUBROUTINEs called
and FUNCTIONs invoked in your compilation against a set of interface
blocks stored separately from the source being compiled.
The compiler generates a compile-time message if the interface used
to invoke a routine does not match the interface defined in a .mod file
external to the source (that is, in a .mod generated by option
gen-interfaces as opposed to a .mod file USEd in the source). The
compiler looks for these .mods in the current directory or in the
directory specified by the include (-I) or -module option. If interface
mismatches occur, some will result in a compile-time error, others will
only generate a warning.
504
Compiler Reference
Option Description
warn shape If the check shape option is specified, array conformance violations
are issued as warnings rather than as errors.
warn stderrors Tells the compiler to change all warning-level messages about Fortran
standards violations to error-level messages. This option sets the
stand option.
warn truncated_source Enables warnings when a source line exceeds the maximum column
width in fixed-format source files. The maximum column width for
fixed-format files is 72, 80, or 132, depending on the setting of the
extend-source option. The warn truncated_source option has no
effect on truncation; lines that exceed the maximum column width are
always truncated. This option does not apply to free-format source
files.
warn nouncalled Disables warnings for variables that are declared but never used.
warn unused Enables warnings for variables that are declared but never used.
warn all This is the same as specifying warn. This option does not set options
warn errors or warn stderrors. To enable all the additional
checking to be performed and force the severity of the diagnostic
messages to be severe enough to not generate an object file, specify
warn allwarn errors or warn allwarn stderrors.
On Windows systems: In the Property Pages, Custom means that
diagnostics will be specified on an individual basis.
IDE Equivalent
Windows
Visual Studio: General > Compile Time Diagnostics (/warn:all, /warn:none)
Diagnostics > Language Usage Warnings > Compile Time Diagnostics (/warn:all, /warn:none)
505
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Alternate Options
warn none Linux and macOS*: -nowarn, -w, -W0, -warn nogeneral
Windows: /4Yd
Windows: /W1
warn nogeneral Linux and macOS*: -W0, -w, -nowarn, -warn none
warn stderrors Linux and macOS*: -e90, -e95, -e03, -e08, -e18
Windows: None
WB
Turns a compile-time bounds check into a warning.
Syntax
Linux OS:
-WB
macOS:
-WB
Windows OS:
/WB
Arguments
None
506
Compiler Reference
Default
Description
This option turns a compile-time bounds check into a warning.
IDE Equivalent
None
Alternate Options
None
Winline
Warns when a function that is declared as inline is not
inlined. This feature is only available for ifort.
Syntax
Linux OS:
-Winline
macOS:
-Winline
Windows OS:
None
Arguments
None
Default
OFF No warning is produced when a function that is declared as inline is not inlined.
Description
This option warns when a function that is declared as inline is not inlined.
To see diagnostic messages, including a message about why a particular function was not inlined, you should
generate an optimization report by specifying option -qopt-report=5.
IDE Equivalent
None
Alternate Options
None
See Also
qopt-report, Qopt-report compiler option
Compatibility Options
This section contains descriptions for compiler options that pertain to language compatibility.
507
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
f66
Tells the compiler to apply FORTRAN 66 semantics.
Syntax
Linux OS:
-f66
macOS:
-f66
Windows OS:
/f66
Arguments
None
Default
Description
This option tells the compiler to apply FORTRAN 66 semantics when interpreting language features. This
causes the following to occur:
IDE Equivalent
Windows
Visual Studio: Language > Enable FORTRAN 66 Semantics
Alternate Options
None
f77rtl
Tells the compiler to use the run-time behavior of
FORTRAN 77.
Syntax
Linux OS:
-f77rtl
-nof77rtl
macOS:
-f77rtl
508
Compiler Reference
-nof77rtl
Windows OS:
/f77rtl
/nof77rtl
Arguments
None
Default
Description
This option tells the compiler to use the run-time behavior of FORTRAN 77.
Specifying this option controls the following run-time behavior:
• When the unit is not connected to a file, some INQUIRE specifiers will return different values:
• NUMBER= returns 0
• ACCESS= returns 'UNKNOWN'
• BLANK= returns 'UNKNOWN'
• FORM= returns 'UNKNOWN'
• There is no support for the PAD= qualifier. FORTRAN 77 does not pad formatted input.
• NAMELIST and list-directed input of character strings must be delimited by apostrophes or quotes.
• When processing NAMELIST input:
• Column 1 of each record is skipped.
• The '$' or '&' that appears prior to the group-name must appear in column 2 of the input record.
IDE Equivalent
Windows
Visual Studio: Compatibility > Enable F77 Run-Time Compatibility
Alternate Options
None
fpscomp
Controls whether certain aspects of the run-time
system and semantic language features within the
compiler are compatible with Intel® Fortran or
Microsoft* Fortran PowerStation.
Syntax
Linux OS:
-fpscomp [keyword[, keyword...]]
-nofpscomp
macOS:
-fpscomp [keyword[, keyword...]]
-nofpscomp
509
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows OS:
/fpscomp[:keyword[, keyword...]]
/nofpscomp
Arguments
keyword Specifies the compatibility that the compiler should follow. Possible values are:
Default
Description
This option controls whether certain aspects of the run-time system and semantic language features within
the compiler are compatible with Intel Fortran or Microsoft* Fortran PowerStation.
If you experience problems when porting applications from Fortran PowerStation, specify fpscomp (or
fpscomp all). When porting applications from Intel Fortran, use fpscomp none or fpscomp libs (the
default).
Option Description
fpscomp none Specifies that no options should be used for compatibility with Fortran
PowerStation. This is the same as specifying nofpscomp. Option
fpscomp none enables full Intel® Fortran compatibility. If you omit
fpscomp, the default is fpscomp libs. You cannot use the fpscomp and
vms options in the same command.
fpscomp filesfromcmd Specifies Fortran PowerStation behavior when the OPEN statement FILE=
specifier is blank (FILE=' '). It causes the following actions to be taken at
run time:
510
Compiler Reference
Option Description
• The program reads a file name from the list of arguments (if any) in
the command line that invoked the program. If any of the command-
line arguments contain a null string (''), the program asks the user for
the corresponding file name. Each additional OPEN statement with a
blank FILE= specifier reads the next command-line argument.
• If there are more nameless OPEN statements than command-line
arguments, the program prompts for additional file names.
• In a QuickWin application, a "File Select" dialog box appears to
request file names.
To prevent the run-time system from using the file name specified on the
command line when the OPEN statement FILE specifier is omitted, specify
fpscomp nofilesfromcmd. This allows the application of Intel Fortran
defaults, such as the FORTn environment variable and the FORT. n file
name (where n is the unit number).
The fpscomp filesfromcmd option affects the following Fortran
features:
• The OPEN statement FILE specifier
For example, assume a program OPENTEST contains the following
statements:
OPEN(UNIT = 2, FILE = ' ')
OPEN(UNIT = 3, FILE = ' ')
OPEN(UNIT = 4, FILE = ' ')
fpscomp general Specifies that Fortran PowerStation semantics should be used when a
difference exists between Intel Fortran and Fortran PowerStation. The
fpscomp general option affects the following Fortran features:
• The BACKSPACE statement:
• It allows files opened with ACCESS='APPEND' to be used with the
BACKSPACE statement.
• It allows files opened with ACCESS='DIRECT' to be used with the
BACKSPACE statement.
Note: Allowing files that are not opened with sequential access (such
as ACCESS='DIRECT') to be used with the BACKSPACE statement
violates the Fortran 95 standard and may be removed in the future.
• The READ statement:
511
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Option Description
512
Compiler Reference
Option Description
513
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Option Description
fpscomp ioformat Specifies that Fortran PowerStation semantic conventions and record
formats should be used for list-directed formatted and unformatted I/O.
The fpscomp ioformat option affects the following Fortran features:
BYTE I5 I12
LOGICAL L2 L2
(all)
INTEGER(1) I5 I12
INTEGER(2) I7 I12
CHARACTER Aw Aw
514
Compiler Reference
Option Description
fpscomp nolibs Prevents the portability library from being passed to the linker.
fpscomp ldio_spacing Specifies that at run time a blank should not be inserted after a numeric
value before a character value (undelimited character string). This
representation is used by Intel Fortran releases before Version 8.0 and by
Fortran PowerStation. If you specify fpscomp general, it sets
fpscomp ldio_spacing.
fpscomp logicals Specifies that integers with a non-zero value are treated as true, integers
with a zero value are treated as false. The literal constant .TRUE. has an
integer value of 1, and the literal constant .FALSE. has an integer value of
0. This representation is used by Intel Fortran releases before Version 8.0
and by Fortran PowerStation.
The default is fpscomp nologicals, which specifies that odd integer
values (low bit one) are treated as true and even integer values (low bit
zero) are treated as false.
The literal constant .TRUE. has an integer value of -1, and the literal
constant .FALSE. has an integer value of 0. This representation is used by
Compaq* Visual Fortran. The internal representation of LOGICAL values is
not specified by the Fortran standard. Programs which use integer values
in LOGICAL contexts, or which pass LOGICAL values to procedures
written in other languages, are non-portable and may not execute
correctly. Intel recommends that you avoid coding practices that depend
on the internal representation of LOGICAL values.
The fpscomp logicals option affects the results of all logical
expressions and affects the return value for the following Fortran
features:
• The INQUIRE statement specifiers OPENED, IOFOCUS, EXISTS, and
NAMED
• The EOF intrinsic function
• The BTEST intrinsic function
• The lexical intrinsic functions LLT, LLE, LGT, and LGE
515
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Option Description
fpscomp all Specifies that all options should be used for compatibility with Fortran
PowerStation. This is the same as specifying fpscomp with no keyword.
Option fpscomp all enables full compatibility with Fortran PowerStation.
IDE Equivalent
Windows
Visual Studio: Compatibility > Use Filenames from Command Line (/fpscomp:filesfromcmd)
Alternate Options
None
gcc-name
Lets you specify the name of the GCC compiler that
should be used to set up the link-time environment,
including the location of standard libraries.
Syntax
Linux OS:
-gcc-name=name
macOS:
None
Windows OS:
None
Arguments
name Is the name of the GCC compiler to use. It can include the path where
the GCC compiler is located.
Default
OFF The compiler uses the PATH setting to find the GCC compiler and resolve environment settings.
Description
This option lets you specify the name of the GCC compiler that should be used to set up the link-time
environment, including the location of standard libraries. If you do not specify a path, the compiler will
search the PATH settings for the compiler name you provide.
This option is helpful when you are referencing a non-standard GCC installation, or you have multiple GCC
installations on your system. The compiler will match GCC version values to the GCC compiler you specify.
516
Compiler Reference
IDE Equivalent
None
Alternate Options
None
Example
If the following option is specified, the compiler looks for the GCC compiler named foobar in the PATH
setting:
-gcc-name=foobar
If the following option is specified, the compiler looks for the GCC compiler named foobar in the path
specified:
-gcc-name=/a/b/foobar
See Also
gxx-name compiler option
gxx-name
Lets you specify the name of the g++ compiler that
should be used to set up the link-time environment,
including the location of standard libraries.
Syntax
Linux OS:
-gxx-name=name
macOS:
None
Windows OS:
None
Arguments
name Is the name of the g++ compiler to use. It can include the path where
the g++ compiler is located.
Default
OFF The compiler uses the PATH setting to find the g++ compiler and resolve environment settings.
Description
This option lets you specify the name of the g++ compiler that should be used to set up the link-time
environment, including the location of standard libraries. If you do not specify a path, the compiler will
search the PATH settings for the compiler name you provide.
This option is helpful if you have multiple gcc++ installations on your system. The compiler will match gcc++
version values to the gcc++ compiler you specify.
The C equivalent to option -gxx-name is -gcc-name.
517
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE When compiling a C++ file with , g++ is used to get the environment.
IDE Equivalent
None
Alternate Options
None
Example
If the following option is specified, the compiler looks for the g++ compiler named foobar in the PATH
setting:
-gxx-name=foobar
If the following option is specified, the compiler looks for the g++ compiler named foobar in the path
specified:
-gxx-name=/a/b/foobar
See Also
gcc-name compiler option
Qvc
Specifies which version of Microsoft Visual C++*
(MSVC) or Microsoft Visual Studio* that the compiler
should link to.This feature is only available for ifort.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/Qvc14.2
/Qvc14.1
Arguments
None
Default
varies When the compiler is installed, it detects which version of Microsoft Visual Studio is on your
system. Qvc defaults to the form of the option that is compatible with that version. When multiple
versions of Microsoft Visual Studio are installed, the compiler installation lets you select which
version you want to link to. In this case, Qvc defaults to the version you choose.
Description
This option specifies which version of MSVC or Microsoft Visual Studio that the compiler should link to.
518
Compiler Reference
Option Description
NOTE
Support for Microsoft Visual Studio 2017 is deprecated as of the Intel® oneAPI 2022.1
release, and will be removed in a future release.
IDE Equivalent
None
Alternate Options
None
vms
Causes the run-time system to behave like HP*
Fortran on OpenVMS* Alpha systems and VAX*
systems (VAX FORTRAN*).
Syntax
Linux OS:
-vms
-novms
macOS:
-vms
-novms
Windows OS:
/vms
/novms
Arguments
None
Default
Description
This option causes the run-time system to behave like HP* Fortran on OpenVMS* Alpha systems and VAX*
systems (VAX FORTRAN*).
It affects the following language features:
• Certain defaults
519
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
In the absence of other options, vms sets the defaults as check format and check
output_conversion.
• Alignment
Option vms does not affect the alignment of fields in records or items in common blocks. For compatibility
with HP Fortran on OpenVMS systems, use align norecords to pack fields of records on the next byte
boundary.
• Carriage control default
If option vms and option ccdefault default are specified, carriage control defaults to FORTRAN if the
file is formatted and the unit is connected to a terminal.
• INCLUDE qualifiers
/LIST and /NOLIST are recognized at the end of the file name in an INCLUDE statement at compile time.
If the file name in the INCLUDE statement does not specify the complete path, the path used is the
current directory. Note that if vms is not specified, the path used is the directory where the file that
contains the INCLUDE statement resides.
• Quotation mark character
A quotation mark (") character is recognized as starting an octal constant ("0..7) instead of a character
literal ("...").
• Deleted records in relative files
When a record in a relative file is deleted, the first byte of that record is set to a known character
(currently '@' ). Attempts to read that record later result in ATTACCNON errors. The rest of the record
(the whole record, if vms is not specified) is set to nulls for unformatted files and spaces for formatted
files.
• ENDFILE records
When an ENDFILE is performed on a sequential unit, an actual 1-byte record containing a Ctrl/Z is written
to the file. If vms is not specified, an internal ENDFILE flag is set and the file is truncated. The vms option
does not affect ENDFILE on relative files: these files are truncated.
• Implied logical unit numbers
The vms option enables Intel® Fortran to recognize certain environment variables at run time for ACCEPT,
PRINT, and TYPE statements and for READ and WRITE statements that do not specify a unit number (such
as READ (*,1000)).
• Treatment of blanks in input
The vms option causes the defaults for the keyword BLANK in OPEN statements to become 'NULL' for an
explicit OPEN and 'ZERO' for an implicit OPEN of an external or internal file.
• OPEN statement effects
Carriage control defaults to FORTRAN if the file is formatted, and the unit is connected to a terminal.
Otherwise, carriage control defaults to LIST. The vms option affects the record length for direct access and
relative organization files. The buffer size is increased by 1 to accommodate the deleted record character.
• Reading deleted records and ENDFILE records
The run-time direct access READ routine checks the first byte of the retrieved record. If this byte is '@' or
NULL ("\0"), then an ATTACCNON error is returned. The run-time sequential access READ routine checks
to see if the record it just read is one byte long and contains a Ctrl/Z. If this is true, it returns EOF.
IDE Equivalent
Windows
Visual Studio: Compatibility > Enable VMS Compatibility
Alternate Options
None
520
Compiler Reference
See Also
align compiler option
ccdefault compiler option
check compiler option
4Nportlib, 4Yportlib
Determines whether the compiler links to the library of
portability routines.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/4Nportlib
/4Yportlib
Arguments
None
Default
Description
Option /4Yportlib causes the compiler to link to the library of portability routines. This also includes Intel's
functions for Microsoft* compatibility.
Option /4Nportlib prevents the compiler from linking to the library of portability routines.
IDE Equivalent
Windows
Visual Studio: Libraries > Use Portlib Library
Alternate Options
None
Bdynamic
Enables dynamic linking of libraries at run time.
Syntax
Linux OS:
-Bdynamic
521
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
macOS:
None
Windows OS:
None
Arguments
None
Default
Description
This option enables dynamic linking of libraries at run time. Smaller executables are created than with static
linking.
This option is placed in the linker command line corresponding to its location on the user command line. It
controls the linking behavior of any library that is passed using the command line.
All libraries on the command line following option -Bdynamic are linked dynamically until the end of the
command line or until a -Bstatic option is encountered. The -Bstatic option enables static linking of
libraries.
IDE Equivalent
None
Alternate Options
None
See Also
Bstatic compiler option
Bstatic
Enables static linking of a user's library.
Syntax
Linux OS:
-Bstatic
macOS:
None
Windows OS:
None
Arguments
None
Default
522
Compiler Reference
Description
This option enables static linking of a user's library.
This option is placed in the linker command line corresponding to its location on the user command line. It
controls the linking behavior of any library that is passed using the command line.
All libraries on the command line following option -Bstatic are linked statically until the end of the
command line or until a -Bdynamic option is encountered. The -Bdynamic option enables dynamic linking of
libraries.
IDE Equivalent
None
Alternate Options
None
See Also
Bdynamic compiler option
Bsymbolic
Binds references to all global symbols in a program to
the definitions within a user's shared library.
Syntax
Linux OS:
-Bsymbolic
macOS:
None
Windows OS:
None
Arguments
None
Default
OFF When a program is linked to a shared library, it can override the definition within the shared
library.
Description
This option binds references to all global symbols in a program to the definitions within a user's shared
library.
This option is only meaningful on Executable Linkage Format (ELF) platforms that support shared libraries.
Caution
This option can have unintended side-effects of disabling symbol preemption in the shared
library.
523
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IDE Equivalent
None
Alternate Options
None
See Also
Bsymbolic-functions compiler option
Bsymbolic-functions
Binds references to all global function symbols in a
program to the definitions within a user's shared
library.
Syntax
Linux OS:
-Bsymbolic-functions
macOS:
None
Windows OS:
None
Arguments
None
Default
OFF When a program is linked to a shared library, it can override the definition within the shared
library.
Description
This option binds references to all global function symbols in a program to the definitions within a user's
shared library.
This option is only meaningful on Executable Linkage Format (ELF) platforms that support shared libraries.
Caution
This option can have unintended side-effects of disabling symbol preemption in the shared
library.
IDE Equivalent
None
Alternate Options
None
See Also
Bsymbolic compiler option
524
Compiler Reference
cxxlib
Determines whether the compiler links using the C++
run-time libraries provided by gcc.
Syntax
Linux OS:
-cxxlib
-no-cxxlib
macOS:
-cxxlib
-no-cxxlib
Windows OS:
None
Arguments
None
Default
-no-cxxlib The compiler uses the default run-time libraries and does not link to any
additional C++ run-time libraries.
Description
This option determines whether the compiler links to the standard C++ run-time library (libstdc++). It is
useful for building mixed Fortran/C++ applications.
Option -cxxlib=dir can be used with option -gcc-name=name to specify the location dir/bin/name.
IDE Equivalent
None
Alternate Options
None
See Also
gcc-name compiler option
dbglibs
Tells the linker to search for unresolved references in
a debug run-time library.
Syntax
Linux OS:
None
macOS:
None
525
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows OS:
/dbglibs
/nodbglibs
Arguments
None
Default
/nodbglibs The linker does not search for unresolved references in a debug run-time
library.
Description
This option tells the linker to search for unresolved references in a debug run-time library.
This option is processed by the compiler, which adds directives to the compiled object file that are processed
by the linker.
The following table shows which options to specify for a debug run-time library:
/dbglibs
IDE Equivalent
None
Alternate Options
None
dll
Specifies that a program should be linked as a
dynamic-link (DLL) library.
526
Compiler Reference
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/dll
Arguments
None
Default
Description
This option specifies that a program should be linked as a dynamic-link (DLL) library instead of an executable
(.exe) file. It overrides any previous specification of run-time routines to be used and enables the /libs:dll
option.
If you use this option with the /libs:qwin or /libs:qwins option, the compiler issues a warning.
IDE Equivalent
None
Alternate Options
Linux and macOS*: None
Windows: /LD
dynamic-linker
Specifies a dynamic linker other than the default.
Syntax
Linux OS:
-dynamic-linker file
macOS:
None
Windows OS:
None
Arguments
Default
527
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
This option lets you specify a dynamic linker other than the default.
IDE Equivalent
None
Alternate Options
None
dynamiclib
Invokes the libtool command to generate dynamic
libraries. This feature is only available for ifort.
Syntax
Linux OS:
None
macOS:
-dynamiclib
Windows OS:
None
Arguments
None
Default
Description
This option invokes the libtool command to generate dynamic libraries.
When passed this option, the compiler uses the libtool command to produce a dynamic library instead of
an executable when linking.
To build static libraries, you should specify option -staticlib or libtool -static <objects>.
IDE Equivalent
None
Alternate Options
None
See Also
staticlib compiler option
extlnk
Specifies file extensions to be passed directly to the
linker.
528
Compiler Reference
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/extlnk:ext
Arguments
Default
OFF Only the file extensions recognized by the compiler are passed to the linker.
Description
This option specifies file extensions (ext) to be passed directly to the linker. It is useful if your source file has
a nonstandard extension.
You can specify one or more file extensions. A leading period before each extension is optional; for
example, /extlnk:myobj and /extlnk:.myobj are equivalent.
IDE Equivalent
None
Alternate Options
None
F (Windows*)
Specifies the stack reserve amount for the program.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/Fn
Arguments
529
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
Description
This option specifies the stack reserve amount for the program. The amount (n) is passed to the linker.
Note that the linker property pages have their own option to do this.
IDE Equivalent
None
Alternate Options
None
F (macOS*)
Adds a framework directory to the head of an include
file search path. This feature is only available for ifort.
Syntax
Linux OS:
None
macOS:
-Fdir
Windows OS:
None
Arguments
Default
OFF The compiler does not add a framework directory to the head of an include file search path.
Description
This option adds a framework directory to the head of an include file search path.
IDE Equivalent
None
Alternate Options
None
fuse-ld
Tells the compiler to use a different linker instead of
the default linker (ld). This feature is only available for
ifort.
530
Compiler Reference
Syntax
Linux OS:
-fuse-ld=keyword
macOS:
-fuse-ld=keyword
Windows OS:
None
Arguments
Default
Description
This option tells the compiler to use a different linker instead of default linker (ld).
This option is provided for compatibility with gcc.
IDE Equivalent
None
Alternate Options
None
l
Tells the linker to search for a specified library when
linking.
Syntax
Linux OS:
-lstring
macOS:
-lstring
Windows OS:
None
Arguments
string Specifies the library (libstring) that the linker should search.
531
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
Description
This option tells the linker to search for a specified library when linking.
When resolving references, the linker normally searches for libraries in several standard directories, in
directories specified by the L option, then in the library specified by the l option.
The linker searches and processes libraries and object files in the order they are specified. So, you should
specify this option following the last object file it applies to.
IDE Equivalent
None
Alternate Options
None
See Also
L compiler option
L
Tells the linker to search for libraries in a specified
directory before searching the standard directories.
Syntax
Linux OS:
-Ldir
macOS:
-Ldir
Windows OS:
None
Arguments
Default
Description
This option tells the linker to search for libraries in a specified directory before searching for them in the
standard directories.
IDE Equivalent
None
Alternate Options
None
532
Compiler Reference
See Also
l compiler option
libs
Tells the compiler which type of run-time library to
link to.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/libs[:keyword]
Arguments
keyword Specifies the type of run-time library to link to. Possible values are:
Default
Description
This option tells the compiler which type of run-time library to link to.
This option is processed by the compiler, which adds directives to the compiled object file that are processed
by the linker.
There are several types of libraries you can link to, depending on which compiler options you specify, as
shown in the table below.
If you use the /libs:dll option and an unresolved reference is found in the DLL, it gets resolved when the
program is executed, during program loading, reducing executable program size.
If you use the /libs:qwin or /libs:qwins option with the /dll option, the compiler issues a warning.
You cannot use the /libs:qwin option and options /libs:dll /threads.
The following table shows which options to specify for different run-time libraries:
533
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
and /dbglibs
/dbglibs
NOTE
This option adds directives to the compiled code, which the linker then reads without further
input from the driver.
NOTE
Starting with the 13.0 release of the Intel compilers, the Intel® OpenMP* library is provided
in DLL form only.
IDE Equivalent
Visual Studio
Visual Studio: Libraries > Runtime Library (/libs:{dll|qwin|qwins}, /threads, /dbglibs)
Alternate Options
Windows: /threads
534
Compiler Reference
Windows: /MWs
See Also
threads compiler option
dbglibs compiler option
link
Passes user-specified options directly to the linker at
compile time.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/link
Arguments
None
Default
Description
This option passes user-specified options directly to the linker at compile time.
All options that appear following /link are passed directly to the linker.
IDE Equivalent
None
Alternate Options
None
See Also
Xlinker compiler option
map
Tells the linker to generate a link map file.
Syntax
Linux OS:
None
macOS:
None
535
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows OS:
/map[:filename]
/nomap
Arguments
filename Is the name for the link map file. It can be a file name or a directory name.
Default
Description
This option tells the linker to generate a link map file.
IDE Equivalent
Windows
Visual Studio: Linker > Debugging > Generate Map File (/MAP)
Alternate Options
None
MD
Tells the linker to search for unresolved references in
a multithreaded, dynamic-link run-time library.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/MD
/MDd
Arguments
None
Default
OFF The linker searches for unresolved references in a multi-threaded, static run-time library.
Description
This option tells the linker to search for unresolved references in a multithreaded, dynamic-link (DLL) run-
time library. This is the same as specifying options /libs:dll /threads /dbglibs. You can also
specify /MDd, where d indicates a debug version.
536
Compiler Reference
This option is processed by the compiler, which adds directives to the compiled object file that are processed
by the linker.
IDE Equivalent
Visual Studio
Visual Studio: Libraries > Runtime Library
Alternate Options
None
See Also
libs compiler option
threads compiler option
MDs
Tells the linker to search for unresolved references in
a single-threaded, dynamic-link run-time library. This
is a deprecated option. There is no replacement
option.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/MDs
/MDsd
Arguments
None
Default
OFF The linker searches for unresolved references in a single-threaded, static run-time library.
Description
This option tells the linker to search for unresolved references in a single-threaded, dynamic-link (DLL) run-
time library.
You can also specify /MDsd, where d indicates a debug version.
IDE Equivalent
None
Alternate Options
537
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
libs compiler option
MT
Tells the linker to search for unresolved references in
a multithreaded, static run-time library.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/MT
/MTd
Arguments
None
Default
Description
This option tells the linker to search for unresolved references in a multithreaded, static run-time library. This
is the same as specifying options /libs:static /threads /noreentrancy. You can also specify /MTd,
where d indicates a debug version.
This option is processed by the compiler, which adds directives to the compiled object file that are processed
by the linker.
IDE Equivalent
Visual Studio
Visual Studio: Libraries > Runtime Library
Alternate Options
None
See Also
Qvc compiler option
libs compiler option
threads compiler option
reentrancy compiler option
nodefaultlibs
Prevents the compiler from using standard libraries
when linking.
538
Compiler Reference
Syntax
Linux OS:
-nodefaultlibs
macOS:
-nodefaultlibs
Windows OS:
None
Arguments
None
Default
Description
This option prevents the compiler from using standard libraries when linking.
IDE Equivalent
None
Alternate Options
None
See Also
nostdlib compiler option
nofor-main
Specifies that the main program is not written in
Fortran.
Syntax
Linux OS:
-nofor-main
macOS:
-nofor-main
Windows OS:
None
Arguments
None
Default
539
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
This option specifies that the main program is not written in Fortran. It is a link-time option that prevents the
compiler from linking for_main.o into applications.
For example, if the main program is written in C and calls a Fortran subprogram, specify -nofor-main when
compiling the program with the ifort command.
If you omit this option, the main program must be a Fortran program.
IDE Equivalent
None
Alternate Options
None
no-intel-lib, Qno-intel-lib
Disables linking to specified Intel® libraries, or to all
Intel® libraries.
Syntax
Linux OS:
-no-intel-lib[=library]
macOS:
None
Windows OS:
/Qno-intel-lib[:library]
Arguments
library Indicates which Intel® library should not be linked. Possible values are:
libimf Disables linking to the Intel® Math library. This value is only
available for Linux*.
If you specify more than one library, they must be separated by commas.
If library is omitted, the compiler will not link to any of the Intel® libraries shown above.
Default
OFF If this option is not specified, the compiler uses default heuristics for linking to
libraries.
540
Compiler Reference
Description
This option disables linking to specified Intel® libraries, or to all Intel® libraries.
NOTE
When offloading is enabled, this option only applies to host compilation. Offloading can only
be enabled when using ifx.
IDE Equivalent
None
Alternate Options
None
nostartfiles
Prevents the compiler from using standard startup
files when linking.
Syntax
Linux OS:
-nostartfiles
macOS:
-nostartfiles
Windows OS:
None
Arguments
None
Default
Description
This option prevents the compiler from using standard startup files when linking.
IDE Equivalent
None
Alternate Options
None
See Also
nostdlib compiler option
nostdlib
Prevents the compiler from using standard libraries
and startup files when linking.
541
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-nostdlib
macOS:
-nostdlib
Windows OS:
None
Arguments
None
Default
OFF The compiler uses standard startup files and standard libraries when linking.
Description
This option prevents the compiler from using standard libraries and startup files when linking.
IDE Equivalent
None
Alternate Options
None
See Also
nodefaultlibs compiler option
nostartfiles compiler option
pie
Determines whether the compiler generates position-
independent code that will be linked into an
executable.
Syntax
Linux OS:
-pie
-no-pie
macOS:
-pie
-no-pie
Windows OS:
None
Arguments
None
542
Compiler Reference
Default
varies On Linux* and on macOS* versions less than 10.7, the default is -no-pie. On macOS* 10.7 or
greater, the default is -pie.
Description
This option determines whether the compiler generates position-independent code that will be linked into an
executable. To enable generation of position-independent code that will be linked into an executable, specify
-pie.
To disable generation of position-independent code that will be linked into an executable, specify -no-pie.
IDE Equivalent
None
Alternate Options
None
See Also
fpic compiler option
pthread
Tells the compiler to use pthreads library for
multithreading support.
Syntax
Linux OS:
-pthread
macOS:
-pthread
Windows OS:
None
Arguments
None
Default
OFF The compiler does not use pthreads library for multithreading support.
Description
Tells the compiler to use pthreads library for multithreading support.
IDE Equivalent
None
Alternate Options
Linux and macOS*: -reentrancy threaded
Windows: /reentrancy:threaded
543
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
shared
Tells the compiler to produce a dynamic shared object
instead of an executable.
Syntax
Linux OS:
-shared
macOS:
None
Windows OS:
None
Arguments
None
Default
Description
This option tells the compiler to produce a dynamic shared object (DSO) instead of an executable. This
includes linking in all libraries dynamically and passing -shared to the linker.
You must specify option fpic for the compilation of each object file you want to include in the shared library.
IDE Equivalent
None
Alternate Options
None
See Also
dynamiclib compiler option
fpic compiler option
Xlinker compiler option
shared-intel
Causes Intel-provided libraries to be linked in
dynamically.
Syntax
Linux OS:
-shared-intel
macOS:
-shared-intel
Windows OS:
None
544
Compiler Reference
Arguments
None
Default
OFF Intel® libraries are linked in statically, with the exception of Intel's coarray runtime support library
and Intel's OpenMP* runtime support library, which are linked in dynamically. To link the
OpenMP* runtime support library statically, specify option -qopenmp-link=static.
Description
This option causes Intel-provided libraries to be linked in dynamically. It is the opposite of -static-intel.
This option is processed by the ifort command that initiates linking, adding library names explicitly to the link
command.
If you specify option -mcmodel=medium or -mcmodel=large, it sets option -shared-intel.
IDE Equivalent
None
Alternate Options
None
See Also
static-intel compiler option
qopenmp-link compiler option
shared-libgcc
Links the GNU libgcc library dynamically.
Syntax
Linux OS:
-shared-libgcc
macOS:
None
Windows OS:
None
Arguments
None
Default
Description
This option links the GNU libgcc library dynamically. It is the opposite of option static-libgcc.
This option is processed by the ifort command that initiates linking, adding library names explicitly to the link
command.
545
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
This option is useful when you want to override the default behavior of the static option, which causes all
libraries to be linked statically.
IDE Equivalent
None
Alternate Options
None
See Also
static-libgcc compiler option
static
Prevents linking with shared libraries.
Syntax
Linux OS:
-static
macOS:
None
Windows OS:
/static
Arguments
None
Default
varies The compiler links with shared GNU libraries (Linux* systems) or shared Microsoft* libraries
(Windows* systems) and it links with static Intel libraries, with the exception of the OpenMP*
libraries and coarray library libicaf, which are linked in dynamically.
On Windows* systems, option /static is equivalent to option /MT.
Description
This option prevents linking with shared libraries. It causes the executable to link all libraries statically.
NOTE
This option does not cause static linking of libraries for which no static version is available.
These libraries can only be linked dynamically.
This option does not cause static linking of libraries for which no static version is available, such as the
OpenMP run-time libraries on Windows* or the coarray run-time libraries. These libraries can only be
linked dynamically.
IDE Equivalent
None
Alternate Options
None
546
Compiler Reference
See Also
MT compiler option
Qvc compiler option
static-intel compiler option
static-intel
Causes Intel-provided libraries to be linked in
statically.
Syntax
Linux OS:
-static-intel
macOS:
-static-intel
Windows OS:
None
Arguments
None
Default
ON Intel® libraries are linked in statically, with the exception of Intel's coarray runtime support library
and Intel's OpenMP* runtime support library, which are linked in dynamically. To link the
OpenMP* runtime support library statically, specify option -qopenmp-link=static.
Description
This option causes Intel-provided libraries to be linked in statically with certain exceptions (see the Default
above). It is the opposite of -shared-intel.
This option is processed by the ifort command that initiates linking, adding library names explicitly to the link
command.
If you specify option -static-intel while option -mcmodel=medium or -mcmodel=large is set, an error
will be displayed.
If you specify option -static-intel and any of the Intel-provided libraries have no static version, a
diagnostic will be displayed.
IDE Equivalent
None
Alternate Options
None
See Also
shared-intel compiler option
qopenmp-link compiler option
547
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
static-libgcc
Links the GNU libgcc library statically.
Syntax
Linux OS:
-static-libgcc
macOS:
None
Windows OS:
None
Arguments
None
Default
Description
This option links the GNU libgcc library statically. It is the opposite of option -shared-libgcc.
This option is processed by the ifort command that initiates linking, adding library names explicitly to the link
command.
This option is useful when you want to override the default behavior, which causes the library to be linked
dynamically.
NOTE
If you want to use traceback, you must also link to the static version of the libgcc library.
This library enables printing of backtrace information.
IDE Equivalent
None
Alternate Options
None
See Also
shared-libgcc compiler option
static-libstdc++ compiler option
static-libstdc++
Links the GNU libstdc++ library statically.
Syntax
Linux OS:
-static-libstdc++
548
Compiler Reference
macOS:
None
Windows OS:
None
Arguments
None
Default
Description
This option links the GNU libstdc++ library statically.
This option is processed by the ifort command that initiates linking, adding library names explicitly to the link
command.
This option is useful when you want to override the default behavior, which causes the library to be linked
dynamically.
IDE Equivalent
None
Alternate Options
None
See Also
static-libgcc compiler option
staticlib
Invokes the libtool command to generate static
libraries. This feature is only available for ifort.
Syntax
Linux OS:
None
macOS:
-staticlib
Windows OS:
None
Arguments
None
Default
549
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
This option invokes the libtool command to generate static libraries. This option is processed by the
command that initiates linking, adding library names explicitly to the link command.
When passed this option, the compiler uses the libtool command to produce a static library instead of an
executable when linking.
To build dynamic libraries, you should specify option -dynamiclib or libtool -dynamic <objects>.
IDE Equivalent
None
Alternate Options
None
See Also
dynamiclib compiler option
T
Tells the linker to read link commands from a file.
Syntax
Linux OS:
-Tfilename
macOS:
None
Windows OS:
None
Arguments
Default
OFF The linker does not read link commands from a file.
Description
This option tells the linker to read link commands from a file.
IDE Equivalent
None
Alternate Options
None
threads
Tells the linker to search for unresolved references in
a multithreaded run-time library.
550
Compiler Reference
Syntax
Linux OS:
-threads
-nothreads
macOS:
-threads
-nothreads
Windows OS:
/threads
/nothreads
Arguments
None
Default
threads The linker searches for unresolved references in a library that supports enabling thread-safe
operation.
Description
This option tells the linker to search for unresolved references in a multithreaded run-time library.
This option sets option reentrancy threaded.
Windows systems: The following table shows which options to specify for a multithreaded run-time library.
To ensure that a threadsafe and/or reentrant run-time library is linked and correctly initialized, option
threads should also be used for the link step and for the compilation of the main routine.
551
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
On Windows* systems, this option is processed by the compiler, which adds directives to the
compiled object file that are processed by the linker. On Linux* and macOS* systems, this
option is processed by the ifort command that initiates linking, adding library names
explicitly to the link command.
IDE Equivalent
None
Alternate Options
None
See Also
reentrancy compiler option
v
Specifies that driver tool commands should be
displayed and executed.
Syntax
Linux OS:
-v [filename]
macOS:
-v [filename]
Windows OS:
None
Arguments
Default
Description
This option specifies that driver tool commands should be displayed and executed.
If you use this option without specifying a source file name, the compiler displays only the version of the
compiler.
If you want to display processing information (pass information and source file names), specify keyword all
for the watch option.
IDE Equivalent
None
Alternate Options
Linux and macOS*: -watch cmd
552
Compiler Reference
Windows: /watch:cmd
See Also
dryrun compiler option
watch compiler option
Wa
Passes options to the assembler for processing.
Syntax
Linux OS:
-Wa,option1[,option2,...]
macOS:
-Wa,option1[,option2,...]
Windows OS:
None
Arguments
option Is an assembler option. This option is not processed by the driver and
is directly passed to the assembler.
Default
Description
This option passes one or more options to the assembler for processing. If the assembler is not invoked,
these options are ignored.
IDE Equivalent
None
Alternate Options
None
winapp
Tells the compiler to create a graphics or Fortran
Windows application and link against the most
commonly used libraries.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/winapp
553
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Arguments
None
Default
Description
This option tells the compiler to create a graphics or Fortran Windows application and link against the most
commonly used libraries.
This option is processed by the compiler, which adds directives to the compiled object file that are processed
by the linker.
IDE Equivalent
Visual Studio
Visual Studio: Libraries > Use Common Windows Libraries
Alternate Options
Linux and macOS*: None
Windows: /MG
Wl
Passes options to the linker for processing.
Syntax
Linux OS:
-Wl,option1[,option2,...]
macOS:
-Wl,option1[,option2,...]
Windows OS:
None
Arguments
option Is a linker option. This option is not processed by the driver and is
directly passed to the linker.
Default
Description
This option passes one or more options to the linker for processing. If the linker is not invoked, these options
are ignored.
This option is equivalent to specifying option -Qoption,link,options.
554
Compiler Reference
IDE Equivalent
None
Alternate Options
None
See Also
Qoption compiler option
Wp
Passes options to the preprocessor.
Syntax
Linux OS:
-Wp,option1[,option2,...]
macOS:
-Wp,option1[,option2,...]
Windows OS:
None
Arguments
Default
Description
This option passes one or more options to the preprocessor. If the preprocessor is not invoked, these options
are ignored.
This option is equivalent to specifying option -Qoption,fpp, options.
IDE Equivalent
None
Alternate Options
None
See Also
Qoption compiler option
Xlinker
Passes a linker option directly to the linker.
555
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-Xlinker option
macOS:
-Xlinker option
Windows OS:
None
Arguments
Default
Description
This option passes a linker option directly to the linker. If -Xlinker -shared is specified, only -shared is
passed to the linker and no special work is done to ensure proper linkage for generating a shared object.
-Xlinker just takes whatever arguments are supplied and passes them directly to the linker.
If you want to pass compound options to the linker, for example "-L $HOME/lib", you must use the
following method:
IDE Equivalent
None
Alternate Options
None
See Also
shared compiler option
link compiler option
Miscellaneous Options
This section contains descriptions for compiler options that do not pertain to a specific category.
bigobj
Increases the number of sections that an object file
can contain. This feature is only available for ifort.
Syntax
Linux OS:
None
macOS:
None
556
Compiler Reference
Windows OS:
/bigobj
Arguments
None
Default
Description
This option increases the number of sections that an object file can contain. It increases the address capacity
to 4,294,967,296(2**32).
This option may be helpful for .obj files that can hold more sections, such as machine generated code.
IDE Equivalent
None
Alternate Options
None
dryrun
Specifies that driver tool commands should be shown
but not executed.
Syntax
Linux OS:
-dryrun
macOS:
-dryrun
Windows OS:
None
Arguments
None
Default
Description
This option specifies that driver tool commands should be shown but not executed.
IDE Equivalent
None
Alternate Options
None
557
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
v compiler option
dumpmachine
Displays the target machine and operating system
configuration.
Syntax
Linux OS:
-dumpmachine
macOS:
-dumpmachine
Windows OS:
None
Arguments
None
Default
OFF The compiler does not display target machine or operating system information.
Description
This option displays the target machine and operating system configuration. No compilation is performed.
IDE Equivalent
None
Alternate Options
None
extfor
Specifies file extensions to be processed by the
compiler as Fortran files.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/extfor:ext
Arguments
558
Compiler Reference
Default
OFF Only the file extensions recognized by the compiler are processed as Fortran files.
Description
This option specifies file extensions (ext) to be processed by the compiler as Fortran files. It is useful if your
source file has a nonstandard extension.
You can specify one or more file extensions. A leading period before each extension is optional; for
example, /extfor:myf95 and /extfor:.myf95 are equivalent.
IDE Equivalent
None
Alternate Options
None
See Also
Tf compiler option
extfpp
Specifies file extensions to be recognized as a file to
be preprocessed by the Fortran preprocessor.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/extfpp:ext
Arguments
Default
OFF Only the file extensions recognized by the compiler are preprocessed by fpp.
Description
This option specifies file extensions (ext) to be recognized as a file to be preprocessed by the Fortran
preprocessor (fpp). It is useful if your source file has a nonstandard extension.
You can specify one or more file extensions. A leading period before each extension is optional; for
example, /extfpp:myfpp and /extfpp:.myfpp are equivalent.
IDE Equivalent
None
559
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Alternate Options
None
global-hoist, Qglobal-hoist
Enables certain optimizations that can move memory
loads to a point earlier in the program execution than
where they appear in the source. This feature is only
available for ifort.
Syntax
Linux OS:
-global-hoist
-no-global-hoist
macOS:
-global-hoist
-no-global-hoist
Windows OS:
/Qglobal-hoist
/Qglobal-hoist-
Arguments
None
Default
-global-hoist Certain optimizations are enabled that can move memory loads.
or /Qglobal-hoist
Description
This option enables certain optimizations that can move memory loads to a point earlier in the program
execution than where they appear in the source. In most cases, these optimizations are safe and can
improve performance.
The negative form of the option is useful for some applications, such as those that use shared or dynamically
mapped memory, which can fail if a load is moved too early in the execution stream (for example, before the
memory is mapped).
IDE Equivalent
None
Alternate Options
None
help
Displays all supported compiler options or supported
compiler options within a specified category of
options.
560
Compiler Reference
Syntax
Linux OS:
-help[category]
macOS:
-help[category]
Windows OS:
/help[category]
Arguments
561
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
Description
This option displays all supported compiler options or supported compiler options within a specified category
of options. If you specify category, it will display all available (supported) compiler options in the specified
category.
IDE Equivalent
None
Alternate Options
Linux and macOS*: None
Windows: /?
intel-freestanding
Lets you compile in the absence of a gcc environment.
Syntax
Linux OS:
-intel-freestanding[=ver]
macOS:
None
Windows OS:
None
Arguments
ver Is a three-digit number that is used to determine the gcc version that
the compiler should be compatible with for compilation. It also sets
the corresponding GNUC macros.
The number will be normalized to reflect the gcc compiler version
numbering scheme. For example, if you specify 493, it indicates the
compiler should be compatible with gcc version 4.9.3.
Default
OFF The compiler uses default heuristics when choosing the gcc environment.
562
Compiler Reference
Description
This option lets you compile in the absence of a gcc environment. It disables any external compiler calls
(such as calls to gcc) that the compiler driver normally performs by default.
This option also removes any default search locations for header and library files. So, for successful
compilation and linking, you must provide these search locations.
This option does not affect ld, as, or fpp. They will be used for compilation as needed.
NOTE
This option does not imply option -nostdinc -nostdlib. If you want to assure a clean
environment for compilation (including removal of Intel-specific header locations and libs),
you should specify -nostdinc and/or -nostdlib.
NOTE
This option is supported for any Linux-target compiler, including a Windows-host to Linux-
target compiler.
IDE Equivalent
None
Alternate Options
None
See Also
intel-freestanding-target-os compiler option
nostdlib compiler option
nostdinc compiler option, which is an alternate option for option X
intel-freestanding-target-os
Lets you specify the target operating system for
compilation.
Syntax
Linux OS:
-intel-freestanding-target-os=os
macOS:
None
Windows OS:
None
Arguments
563
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
Description
This option lets you specify the target operating system for compilation. It sets option
-intel-freestanding.
NOTE
This option is supported for any Linux-target compiler, including a Windows-host to Linux-
target compiler.
IDE Equivalent
None
Alternate Options
None
See Also
intel-freestanding compiler option
libdir
Controls whether linker options for search libraries are
included in object files generated by the compiler.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/libdir[:keyword ]
/nolibdir
Arguments
none Prevents any linker search options from being included into the
object file. This is the same as specifying /nolibdir.
564
Compiler Reference
Default
/libdir:all Linker search options for libraries automatically determined by the ifort
command driver (default libraries) and libraries specified by the
OBJCOMMENT directive are included in the object file.
Description
This option controls whether linker options for search libraries (/DEFAULTLIB:library) are included in
object files generated by the compiler.
The linker option /DEFAULTLIB:library adds one library to the list of libraries that the linker searches
when resolving references. A library specified with /DEFAULTLIB:library is searched after libraries
specified on the command line and before default libraries named in .obj files.
IDE Equivalent
Windows
Visual Studio: Libraries > Disable Default Library Search Rules ( /libdir:[no]automatic)
Alternate Options
logo
Displays the compiler version information.
Syntax
Linux OS:
-logo
-nologo
macOS:
-logo
-nologo
Windows OS:
/logo
/nologo
565
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Arguments
None
Default
Linux* and macOS*: nologo The compiler version information is not displayed.
Description
This option displays the startup banner, which contains the following compiler information:
IDE Equivalent
Windows
Visual Studio: General > Suppress Startup Banner (/nologo)
Alternate Options
Linux and macOS*: -V
Windows: None
multiple-processes, MP
Creates multiple processes that can be used to
compile large numbers of source files at the same
time.
Syntax
Linux OS:
-multiple-processes[=n]
macOS:
-multiple-processes[=n]
Windows OS:
/MP[:n]
Arguments
Default
566
Compiler Reference
Description
This option creates multiple processes that can be used to compile large numbers of source files at the same
time. It can improve performance by reducing the time it takes to compile source files on the command line.
This option causes the compiler to create one or more copies of itself, each in a separate process. These
copies simultaneously compile the source files.
If n is not specified for this option, the default value is as follows:
• On Windows* systems, the value is based on the setting of the NUMBER_OF_PROCESSORS environment
variable.
• On Linux* and macOS* systems, the value is 2.
This option applies to compilations, but not to linking or link-time code generation.
IDE Equivalent
Windows
Visual Studio: General > Multi-processor Compilation
Alternate Options
None
save-temps, Qsave-temps
Tells the compiler to save intermediate files created
during compilation.
Syntax
Linux OS:
-save-temps
-no-save-temps
macOS:
-save-temps
-no-save-temps
Windows OS:
/Qsave-temps
/Qsave-temps-
Arguments
None
Default
Linux* and macOS* systems: -no-save-temps On Linux and macOS* systems, the compiler deletes
Windows* systems: .obj files are saved intermediate files after compilation is completed.
On Windows systems, the compiler saves only
intermediate object files after compilation is
completed.
567
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
This option tells the compiler to save intermediate files created during compilation. The names of the files
saved are based on the name of the source file; the files are saved in the current working directory.
If option [Q]save-temps (C++) or is specified, the following occurs:
• The .o file is put into /tmp and deleted after calling ld.
• The preprocessed file is not saved after it has been used by the compiler.
If /Qsave-temps- is specified on Windows systems, the following occurs:
NOTE
This option only saves intermediate files that are normally created during compilation.
IDE Equivalent
None
Alternate Options
None
Example
If you compile program my_foo.F on a Linux or macOS* system and you specify option -save-temps and
option -use-asm, the compilation will produce files my_foo.o, my_foo.s, and my_foo.i.
If you compile program my_foo.fpp on a Windows system and you specify option /Qsave-temps and
option /Quse-asm, the compilation will produce files my_foo.obj, my_foo.asm, and my_foo.i.
sox
Tells the compiler to save the compilation options and
version number in the executable file. It also lets you
choose whether to include lists of certain routines.
This feature is only available for ifort.
Syntax
Linux OS:
-sox[=keyword[,keyword]]
-no-sox
macOS:
None
568
Compiler Reference
Windows OS:
None
Arguments
Default
-no-sox The compiler does not save these informational strings in the object file.
Description
This option tells the compiler to save the compilation options and version number in the executable file. It
also lets you choose whether to include lists of certain routines. The information is embedded as a string in
each object file or assembly output.
If you specify option sox with no keyword, the compiler saves the compiler options and version number used
in the compilation of the objects that make up the executable.
When you specify this option, the size of the executable on disk is increased slightly. Each keyword you
specify increases the size of the executable. When you link the object files into an executable file, the linker
places each of the information strings into the header of the executable. It is then possible to use a tool,
such as a strings utility, to determine what options were used to build the executable file.
IDE Equivalent
None
Alternate Options
None
Example
The following commands are equivalent:
-sox=profile -sox=inline
-sox=profile,inline
You can use the negative form of the option to disable and reset the option. For example:
See Also
prof-use, Qprof-use compiler option
569
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
sysroot
Specifies the root directory where headers and
libraries are located.
Syntax
Linux OS:
--sysroot=dir
macOS:
None
Windows OS:
None
Arguments
dir Specifies the local directory that contains copies of target libraries in
the corresponding subdirectories.
Default
Off The compiler uses default settings to search for headers and libraries.
Description
This option specifies the root directory where headers and libraries are located.
For example, if the headers and libraries are normally located in /usr/include and /usr/lib respectively,
--sysroot=/mydir will cause the compiler to search in /mydir/usr/include and /mydir/usr/lib for the
headers and libraries.
IDE Equivalent
None
Alternate Options
None
Tf
Tells the compiler to compile the file as a Fortran
source file.
Syntax
Linux OS:
-Tf filename
macOS:
-Tf filename
Windows OS:
/Tf filename
570
Compiler Reference
Arguments
Default
OFF Files that do not end in standard Fortran file extensions are not compiled as Fortran files.
Description
This option tells the compiler to compile the file as a Fortran source file.
This option is useful when you have a Fortran file with a nonstandard file extension (that is, not one
of .F, .FOR, or .F90).
This option assumes the file specified uses fixed source form. If the file uses free source form, you must also
specify option free.
IDE Equivalent
None
Alternate Options
None
See Also
extfor compiler option
free compiler option
watch
Tells the compiler to display certain information to the
console output window.
Syntax
Linux OS:
-watch[=keyword[, keyword...]]
-nowatch
macOS:
-watch[=keyword[, keyword...]]
-nowatch
Windows OS:
/watch[:keyword[, keyword...]]
/nowatch
Arguments
571
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
[no]source Determines whether the name of the file being compiled is displayed.
Default
nowatch Pass information and source file names are not displayed to the console output window.
Description
Tells the compiler to display processing information (pass information and source file names) to the console
output window.
none Tells the compiler to not display pass information and source file names
to the console output window. This is the same as specifying nowatch.
cmd Tells the compiler to display and execute driver tool commands.
source Tells the compiler to display the name of the file being compiled.
all Tells the compiler to display pass information and source file names to
the console output window. This is the same as specifying watch with no
keyword. For heterogeneous compilation, the tool commands for the host
and the offload compilations will be displayed.
IDE Equivalent
None
Alternate Options
Windows: None
See Also
v compiler option
what
Tells the compiler to display its detailed version string.
Syntax
Linux OS:
-what
macOS:
-what
Windows OS:
/what
Arguments
None
572
Compiler Reference
Default
Description
This option tells the compiler to display its detailed version string.
IDE Equivalent
None
Alternate Options
None
Code Generation:
-fp -fomit-frame-pointer
-mcpu -mtune
Advanced Optimizations:
-funroll-loops -unroll
-pg -p
-qp -p
-fopenmp -qopenmp
Floating-Point:
-mieee-fp -fltconsistency
-V -logo
Preprocessor:
-cpp -fpp
-DD -d-lines
573
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
-nodefine -noD
-nostdinc -X
-P -preprocess-only
Language:
-72 -extend-source 72
-80 -extend-source 80
-132 -extend-source 132
-C -check all
-FI -fixed
-FR -free
-fsyntax-only -syntax-only
-y -syntax-only
Data:
-autodouble -real-size 64
-automatic -auto
-i2 -integer-size 16
-i4 -integer-size 32
-i8 -integer-size 64
-r4 -real-size 32
-r8 -real-size 64
-r16 -real-size 128
Compiler Diagnostics:
574
Compiler Reference
-e95
-e03
-error-limit -diag-error-limit
-u -warn declarations
Compatibility:
-66 -f66
-onetrip -f66
Linking or Linker:
-i-dynamic -shared-intel
-i-static -static-intel
Optimization:
/Ox /O
/openmp /Qopenmp
Floating Point:
/QIfist /Qrcd
/compile-only /c
/Fe /exe
/Fo /object
/nolink /c
/pdbfile /Fd
/V /bintext
Preprocessor:
/define /D
/include /I
/nodefine /noD
575
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
/noinclude /X
/undefine /U
Language:
/4L72 -extend-source:72
/4L80 -extend-source:80
/4L132 -extend-source:132
/4Naltparam /noaltparam
/4Yaltparam /altparam
/4Nf /fixed
/4Yf /free
/4Ns /stand:none
/4Ys /stand:f90
/C /check:all
/CB /check:bounds
/CU /check:uninit
/FI /fixed
/FR /free
/Gm /iface:cvf
/Gz /iface:stdcall
/nbs /assume:nobcss
/Qcommon-args /assume:dummy_aliases
/RTCu /check:uninit
/Zp /align:recnbyte
/Zs /syntax-only
Data:
/4I2 /integer-size:16
/4I4 /integer-size:32
/4I8 /integer-size:64
/4Na /noauto
/4Ya /auto
/4R4 /real-size:32
/4R8 /real-size:64
/4R16 /real-size:128
576
Floating-Point Operations
/automatic /auto
/Qauto /auto
/Qautodouble /real-size:64
/Zp /align:recnbyte
Compiler Diagnostics:
/4Nd /warn:nodeclarations
/4Yd /warn:declarations
/error-limit /Qdiag-error-limit
/w /warn:none or /warn:nogeneral
Compatibility:
/Qonetrip /f66
Linking or Linker:
/LD /dll
/MG /winapp
/MW /libs
/MWs /libs:qwins
Miscellaneous:
/V /logo
/Zl /libdir:none
Floating-Point Operations
This section contains information about floating-point operations, including IEEE floating-point operations,
and it provides guidelines that can help you improve the performance of floating-point applications.
577
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• Reproducibility and portability: The application produces consistent results across different runs,
different sets of build options, different compilers, different platforms, and different architectures.
• Performance: The application produces fast, efficient code.
Based on the goal of an application, you will need to make tradeoffs among these objectives. For example, if
you are developing a 3D graphics engine, performance may be the most important factor to consider, with
reproducibility and accuracy as secondary concerns.
The compiler provides several options that allow you to tune your applications based on specific objectives.
Broadly speaking, there are the floating-point specific options, such as the -fp-model (Linux* and macOS*)
or /fp (Windows*) option, and the fast-but-low-accuracy options, such as the [Q]imf-max-error option.
The compiler optimizes and generates code differently when you specify these different compiler options.
Select appropriate compiler options by carefully balancing your programming objectives and making tradeoffs
among these objectives. Some of these options may influence the choice of math routines that are invoked.
Many routines in the libirc, libm, and svml library are more highly optimized for Intel microprocessors than
for non-Intel microprocessors.
Example
If you specify the -fp-model extended (Linux and macOS*) or /fp:extended (Windows) option in favor of
accuracy, the compiler generates the following assembly code:
If you specify the -fp-model fast (Linux and macOS*) or /fp:fast (Windows) option in favor of
performance, the compiler generates the following assembly code:
578
Compiler Reference
This code maximizes performance using Intel® Streaming SIMD Extensions (Intel® SSE) instructions and pre-
computing 4.0 + 0.1. It is not as accurate as the first implementation, due to the greater intermediate
rounding error. It does not provide reproducible results like the second implementation, because it must
reorder the addition to pre-compute 4.0 + 0.1. All compilers, on all platforms, at all optimization levels do
not reorder the addition in the same way.
For many other applications, the considerations may be more complicated.
-fimf-max-error=2
To specify twelve bits of accuracy for a sin function, use:
-fimf-accuracy-bits=12:sin
To specify relative error of ten ULPs for a sin function, and four ULPs for other math functions called in the
source file you are compiling, use:
-fimf-max-error=10:sin-fimf-max-error=4
On Windows systems, the compiler defines the default value for the max-error attribute depending on
the /fp option and /Qfast-transcendentals settings. In /fp:fast mode, or if fast but less accurate math
functions are explicitly enabled by /Qfast-transcendentals-, then the compiler sets a max-error=4.0 for
the call. Otherwise, it sets a max-error=0.6.
579
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Using -fp-model(/fp) Options
fimf-max-error, Qimf-max-error compiler option
Floating-point Optimizations
Application performance is an important goal of the Intel® Fortran Compiler, even at default optimization
levels. A number of optimizations involve transformations that might affect the floating-point behavior of the
application, such as evaluation of constant expressions at compile time, hoisting invariant expressions out of
loops, or changes in the order of evaluation of expressions. These optimizations usually help the compiler to
produce the most efficient code possible. However, the optimizations might be contrary to the floating-point
requirements of the application.
Some optimizations are not consistent with strict interpretation of the ANSI or ISO standards for Fortran.
Such optimizations can cause differences in rounding and small variations in floating-point results that may
be more or less accurate than the ANSI-conformant result.
The Intel® Fortran Compiler provides the -fp-model (Linux* and macOS*) or /fp (Windows*) option, which
allows you to control the optimizations performed when you build an application. The option allows you to
specify the compiler rules for:
• Value safety: Whether the compiler may perform transformations that could affect the result. For
example, in the SAFE mode, the compiler won't transform x/x to 1.0 because the value of x at runtime
might be a zero or a NaN . The UNSAFE mode is the default.
• Floating-point expression evaluation: How the compiler should handle the rounding of intermediate
expressions.
• Floating-point contractions: Whether the compiler should generate fused multiply-add (FMA)
instructions on processors that support them. When enabled, the compiler may generate FMA instructions
for combining multiply and add operations; when disabled, the compiler must generate separate multiply
and add instructions with intermediate rounding.
• Floating-point environment access: Whether the compiler must account for the possibility that the
program might access the floating-point environment, either by changing the default floating-point control
settings or by reading the floating-point status flags. This is disabled by default. You can use the
-fp-model:strict (Linux* and macOS*) /fp:strict (Windows*) option to enable it.
• Precise floating-point exceptions: Whether the compiler should account for the possibility that
floating-point operations might produce an exception. This is disabled by default. You can use
-fp-model:strict (Linux* and macOS*) or /fp:strict (Windows*); or -fp-model:except (Linux*
and macOS*) or /fp:except (Windows*) to enable it.
The following table describes the impact of different keywords of the option on compiler rules and
optimizations:
580
Compiler Reference
NOTE
It is illegal to specify the except keyword in an unsafe safety mode.
Based on the objectives of an application, you can choose to use different sets of compiler options and
keywords to enable or disable certain optimizations, so that you can get the desired result.
See Also
Using -fp-model (/fp) Option
Keyword Description
strict Enables precise and except, disables contractions, and enables the
property that allows modification of the floating-point environment.
[no-]except (Linux* and Determines whether strict floating-point exception semantics are used.
macOS*) or
except[-] (Windows*)
The default value of the option is -fp-model fast=1 or /fp:fast=1, which means that the compiler uses
more aggressive optimizations on floating-point calculations.
NOTE
Using the default option keyword -fp-model fast or /fp:fast, you may get significant differences
in your result depending on whether the compiler uses x87 or SSE/AVX instructions to implement
floating-point operations. Results are more consistent when the other option keywords are used.
Several examples are provided to illustrate the usage of the keywords. These examples show:
581
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
The same source code is considered in all the included examples.
• The semantics that are used to interpret floating-point calculations in the source code.
• One or more possible ways the compiler may interpret the source code.
NOTE
There are several ways the compiler may interpret the code; we show just some of these possibilities.
Example
When this option is specified, the compiler applies the following semantics:
• Additions may be performed in any order.
• Intermediate expressions may use single, double, or extended double precision.
• The constant addition may be pre-computed, assuming the default rounding mode.
Using these semantics, some possible ways the compiler may interpret the original code are given below:
Example
See Also
fp-model, fp compiler option
Subnormal Numbers
A normalized number is a number for which both the exponent (including bias) and the most significant bit of
the mantissa are non-zero. For such numbers, all the bits of the mantissa contribute to the precision of the
representation.
The smallest normalized single-precision floating-point number greater than zero is about 1.1754943-38.
Smaller numbers are possible, but those numbers must be represented with a zero exponent and a mantissa
whose leading bit(s) are zero, which leads to a loss of precision. These numbers are called subnormal
numbers or subnormals(older specifications refer to these as denormal numbers).
Subnormal computations use hardware and/or operating system resources to handle denormals; these can
cost hundreds of clock cycles. Subnormal computations take much longer to calculate than normal
computations.
582
Compiler Reference
There are several ways to avoid subnormals and increase the performance of your application:
• Scale the values into the normalized range.
• Use a higher precision data type with a larger range.
• Flush subnormals to zero.
See Also
Reducing Impact of Subnormal Exceptions
Intel® 64 and IA-32 Architectures Software Developer's Manual, Volume 1: Basic Architecture
Institute of Electrical and Electronics Engineers, Inc*. (IEEE) web site for information about the current
floating-point standards and recommendations
Floating-Point Environment
The floating-point environment is a collection of registers that control the behavior of the floating-point
machine instructions and indicate the current floating-point status. The floating-point environment can
include rounding mode controls, exception masks, flush-to-zero (FTZ) controls, exception status flags, and
other floating-point related features.
For example, bit 15 of the MXCSR register enables the flush-to-zero mode, which controls the masked
response to an single-instruction multiple-data (SIMD) floating-point underflow condition.
The floating-point environment affects most floating-point operations; therefore, correct configuration to
meet your specific needs is important. For example, the exception mask bits define which exceptional
conditions will be raised as exceptions by the processor. In general, the default floating-point environment is
set by the operating system. You don't need to configure the floating-point environment unless the default
floating-point environment does not suit your needs.
There are several methods available if you want to modify the default floating-point environment. For
example, you can use inline assembly, compiler built-in functions, library functions, or command line options.
Changing the default floating-point environment affects runtime results only. This does not affect any
calculations that are pre-computed at compile time.
See Also
Intel® 64 and IA-32 Architectures Software Developer's Manual, Volume 1: Basic Architecture
Flag When set to ON, the When set to OFF, the Supported on
compiler... compiler...
FTZ ...sets subnormal results from ...does not change the Intel® 64 and
floating-point calculations to subnormal results. some IA-32
zero. architectures
583
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Flag When set to ON, the When set to OFF, the Supported on
compiler... compiler...
DAZ ...treats subnormal values ...does not change the Intel® 64 and
used as input to floating-point subnormal instruction inputs. some IA-32
instructions as zero. architectures
• FTZ and DAZ are not supported on all IA-32 architectures. The FTZ flag is supported only on IA-32
architectures that support Intel® SSE instructions.
• On systems based on the IA-32 and Intel® 64 architectures, FTZ only applies to Intel® SSE and Intel® AVX
instructions. If the application generates subnormals using x87 instructions, FTZ does not apply.
• DAZ and FTZ flags are not compatible with the IEEE 754 standard, and should only be enabled when
compliance to the IEEE standard is not required.
Options for [Q]ftz are performance options. Setting these options does not guarantee that all subnormals in
a program are flushed to zero. They only cause subnormals generated at run-time to be flushed to zero.
On Intel® 64 and IA-32 systems, the compiler, by default, inserts code into the main routine to set the FTZ
and DAZ flags. When the [Q]ftz option is used on IA-32 systems with the option –msse2 or /arch:sse2,
the compiler inserts code to that conditionally sets the FTZ/DAZ flags based on a run-time processor check.
Using the negative form of [Q]ftz prevents the compiler from inserting any code that sets FTZ or DAZ flags.
When the [Q]ftz option is used in combination with an Intel® SSE-enabling option on systems based on the
IA-32 architecture (for example, -msse2 or /arch:sse2), the compiler inserts code in the main routine to
set FTZ and DAZ. When the option [Q]ftz is used without an Intel® SSE-enabling option, the compiler inserts
code that conditionally sets FTZ or DAZ based on a run-time processor check. The negative form of [Q]ftz
prevents the compiler from inserting any code that might set FTZ or DAZ.
The [Q]ftz option only has an effect when the main program is being compiled. It sets the FTZ/DAZ mode
for the process. The initial thread, and any subsequently created threads, operate in the FTZ/DAZ mode.
On systems based on Intel® 64 and IA-32 architectures, every optimization option O level, except O0, sets
[Q]ftz.
If this option produces undesirable results of the numerical behavior of the program, turn the FTZ/DAZ mode
off by using the negative form of [Q]ftz in the command line while still benefitting from the O3
optimizations.
Manually set the flags by calling the following Intel® Fortran intrinsic:
Example
See Also
ftz, Qftz compiler option
584
Compiler Reference
NOTE
The [Q]fp-stack-check option causes significant code generation after every function/subroutine call to
ensure that the floating-point stack is maintained in the correct state. Therefore, using this option
slows down the program being compiled. Use the option only as a debugging aid to find floating point
stack underflow/overflow problems, which can be otherwise hard to find.
See Also
fp-stack-check, Qfp-stack-check compiler option
See Also
Avoiding Mixed Data Type Arithmetic Expressions
Reducing the Impact of Subnormal Exceptions
Using Efficient Data Types
See Also
Programming Guidelines for Vectorization
585
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
After using flush-to-zero, ensure that your program still gives correct results when treating subnormal
values as zero.
See Also
Setting the FTZ and DAZ Flags
Intel® 64 and IA-32 Architectures Software Developer's Manual, Volume 1: Basic Architecture
586
Compiler Reference
Examples
Inefficient Code Example
INTEGER I, J
I = J / 2.0
INTEGER I, J
I = J / 2
Examples
Example 1: Not auto-vectorizable code
587
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
In an arithmetic expression, you should avoid mixing integer and floating-point data.
Libraries
This section contains information about creating, calling, comparing, and other considerations when using
libraries.
588
Compiler Reference
If your library file and source files are in different directories, use the -Ldir option to indicate where your
library is located:
589
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
You can use the -static-intel option to force the linker to use the static versions of the Intel-supplied
libraries.
You can also create a shared library file with a combination of ifort and ld (Linux*) or libtool (macOS*)
commands:
First, create the .o file, such as octagon.o in the following example:
ld -shared octagon.o \
-lifport -lifcoremt -limf -lm -lcxa \
-lpthread -lirc -lunwind -lc -lirc_s
Note the following:
• When you use ld, you need to list all Intel® Fortran libraries. It is easier and safer to use the ifort
command. On macOS*, you would use libtool.
• The -shared option is required to create a shared library. On macOS*, use the -dynamiclib option, and
also specify the following: -arch_only i386, -noall_load,
-weak_references_mismatches non-weak.
• The name of the object file is octagon.o. You can specify multiple object (.o) files.
• The -lifport option and subsequent options are the standard list of libraries that the ifort command
would have otherwise passed to ld or libtool. When you create a shared library, all symbols must be
resolved.
It is recommended that you review the output of the -dryrun command to find the names of all the libraries
used, to be able to specify them correctly.
If you are using the ifort command to link, you can use the -Qoption command to pass options to the ld
linker. (You cannot use -Qoption on the ld command line.)
For more information on relevant compiler options, see the Compiler Options reference.
See also the ld(1) reference page.
To put a routine in a separate shared library, obtain the source or object file for that routine, recompile if
necessary, and create a separate shared library. You can specify an object file when recompiling with the
ifort command or when creating the shared library with the ld command.
To include a routine in the shared library being created, put the routine (source or object file) with other
source files that make up the shared library and recompile if necessary.
Now create the shared library, and specify the file containing that routine either during recompilation or
when creating the shared library. You can specify an object file when recompiling with the ifort
command or when creating the shared library with the ld or libtool command.
• When creating shared libraries, all symbols must be defined (resolved).
590
Compiler Reference
Because all symbols must be defined to ld when you create a shared library, you must specify the shared
libraries on the ld command line, including all standard Intel® Fortran libraries. The list of standard Intel®
Fortran libraries can be specified by using the -lstring option.
591
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Language Reference section Run-Time Library Routines lists topics that provide an overview of the different
groups of library routines as well as calling syntax for the routines. For example, add the following USE
statement before any data declaration statements, such as IMPLICIT, NONE, or INTEGER:
USE IFPORT
If you want to minimize compile time for source files that use the Intel® Fortran library routines, add the
ONLY keyword to the USE statement. For example:
USE IFPORT, only: getenv
Using the ONLY keyword limits the number of interfaces for that group of library routines.
To view the actual interface definitions, view the .f90 file that corresponds to the .mod file. For example, if a
routine requires a USE IFCORE, locate and use a text editor to view the file ifcore.f90 in the standard
INCLUDE directory.
You should avoid copying the actual interface definitions contained in the ifport.f90 (or ifcore.f90, ...)
into your program because future versions of Intel® Fortran might change these interface definitions.
Similarly, some of the library interface .f90 files contain USE statements for a subgrouping of routines.
However, if you specify a USE statement for such a subgroup, this module name may change in future
version of the Intel® Fortran Compiler. Although this will make compilation times faster, it might not be
compatible with future versions of the compiler.
See Also
Run-Time Library Routines
592
Compiler Reference
• Are described in the Intel® Visual Fortran Compiler Language Reference online documentation, in the A to
Z Reference. The routine description lists the appropriate USE statement needed to include the interface
definitions, such as USE IFPORT.
• Call appropriate Windows* system API routines provided with the operating system.
• Are specific to Windows* systems, with one exception: most of the Intel® Fortran IFPORT Portability
Library routines exist on most Linux* systems.
In contrast, the Windows* API routines provided by the Windows* operating system:
• Are intended to be called from the C language. For example, character arguments are assumed to be null-
terminated C strings.
• Often have multiple words appended together in their names, such as GetSystemTime.
• Are described in the Windows* SDK online documentation. To look up a specific routine, visit the MSDN
Library website. The calling format is listed near the top of the page, followed by a description of the
routine's arguments. The QuickInfo at the bottom of the Windows* API routine documentation page lists
the import library needed.
• Are also specific to Windows*.
Note that the Intel® Visual Fortran Compiler provides interface block definitions that simplify calling
Windows* API routines from the Intel® Visual Fortran Compiler (such as allowing you to specify Fortran data
arguments as being passed by reference). To obtain these interface definitions, add the USE IFWIN
statement to your program.
There are many groups of Windows* routines (see the Platform SDK and other resources). These routines
provide sophisticated window management, memory management, graphics support, threading, security, and
networking.
You can access many Windows* API routines from any Fortran application, including Fortran Console and
Fortran QuickWin applications. Only the Fortran Windows* application Understanding Project Types provides
access to the full set of Win32 routines needed to create GUI applications.
Fortran Console applications are text-only applications. Fortran QuickWin applications allow you to build
Windows*-style applications easily, but access only a small subset of the available Windows* API features.
Fortran QuickWin applications also allow you to use graphics.
See Also
A to Z Reference
IFPORT Portability Library
Understanding Project Types
593
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Fortran DLL Dynamic-link libraries libfcoremd and msvcrt (and their import libraries)
Pure Fortran applications can have mismatched types of libraries. One common scenario is a Fortran
Windows* application that is linking with a Fortran static library. This can cause link-time conflicts as well as
undesired runtime failures. The Fortran library should be rebuilt as a dynamic library to avoid these issues.
Similarly, different C/C++ applications link against different C libraries. If you mix the different types of
applications without modifying the defaults, you can get conflicts. The debug version of a library has a letter
d appended to its base file name:
• Static, multithreaded: libcmt.lib and libcmtd.lib
• Dynamic-link libraries: msvcrt and msvcrtd (.lib import library and .dll)
When using a Debug configuration, Visual C++* selects the debug libraries.
The Intel® Visual Fortran Compiler does not select debug libraries for any configuration, but provides settings
that allow you to request their use. To specify different types of Fortran libraries in the IDE, select Project >
Properties, then select the Libraries category on the Fortran tab:
• To specify static libraries, select the appropriate type of static (non-DLL) library under Run-Time Library
(see /libs:static).
• To specify dynamic-link libraries, select the appropriate type of DLL library under Run-Time Library
(see /libs:dll).
• To specify the debug libraries, select the appropriate type of Debug library under Run-Time Library
(see /[no]dbglibs). If you specify debug libraries (/dbglibs) and also request DLL libraries
(/libs:dll), be aware that this combination selects the debug versions of the Fortran DLLs. These
Fortran DLL files have been linked against the C debug DLLs.
• When you specify QuickWin or Standard Graphics libraries under Run-Time Library, this selection implicitly
requests multithreaded libraries.
NOTE This option does not cause static linking of libraries for which no static version is available, such
as the OpenMP run-time libraries on Windows* or the coarray run-time libraries. These libraries can
only be linked dynamically.
See Also
Building Intel® Fortran C Mixed-Language Programs on Windows* Systems
594
Compiler Reference
The information here is only introductory. The redistributable library installation packages are available at the
following locations:
• Intel® oneAPI versions
• Older Intel® Parallel Studio XE versions
Once you have done this, you must choose how your users will receive these libraries.
Deployment Models
You have two options for deploying the shared libraries from the Intel oneAPI toolkit that your application
depends on:
Private Model Copy the shared libraries from the Intel oneAPI toolkit into your application
environment, and then package and deploy them with your application. Review
the license and third-party files associated with the Intel oneAPI toolkits and/or
components you have installed to determine the files that you can redistribute.
The advantage to this model is that you have control over your library and
version choice, so you only package and deploy the libraries that you have
tested. The disadvantage is that the end users may see multiple libraries
installed on their system, if multiple installed applications all use the private
model. You are also responsible for updating these libraries whenever updates
are required.
Public Model You direct your users to runtime packages provided by Intel. Your users install
these packages on their system when they install your application. The run-time
packages install onto a fixed location, so all applications built with Intel oneAPI
tools can be used.
The advantage is that one copy of each library is shared by all applications, which
results in improved performance. You also can rely on updates to the run-time
packages to resolve issues with libraries independently from when you update
your application. The disadvantage is that the footprint of the run-time package
595
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
is larger than a package from the private model. Another disadvantage is that
your tested versions of the run-time libraries may not be the same as your end
user's versions.
Select the model that best fits your environment, your needs, and the needs of your users.
NOTE Intel ensures that newer compiler-support libraries work with older versions of generated
compiler objects, but newer versioned objects require newer versioned compiler-support libraries. If
an incompatibility is introduced that causes newer compiler-support libraries not to work with older
compilers, you will have sufficient warning and the library will be versioned so that deployed
applications continue to work.
Additional Steps
Under either model, you must manually configure certain environment variables that are normally handled by
the setvars/vars scripts or modulefiles.
For example, with the Intel® MPI Library, you must set the following environment variables during
installation:
See Also
Using Fortran Static Library Projects
596
Compiler Reference
When routines in a shareable library are called, the routines are loaded into memory at run-time as they are
needed. This is most useful when several applications use a common group of routines. By storing these
common routines in a shareable library, you reduce the size of each application that calls the library. In
addition, you can update the routines in the library without having to rebuild any of the applications that call
the library.
Including the Intel® Visual Fortran Interface Definitions for Windows* API Routines
This topic only applies to Windows*.
Intel® Fortran provides interface definitions for both the Intel Fortran library routines and most of the
Windows* API routines in the standard include directory. Documentation on the Windows API can be found at
msdn.microsoft.com.
To include the Windows API interface definitions, do one of the following:
1. Add the statement USE IFWIN to include all Windows API routine definitions.
The USE IFWIN statement makes all parameters and interfaces for most Windows routines available to
your Intel Fortran program. Any program or subprogram that uses the Windows features can include
the statement USE IFWIN, which is needed in each subprogram that makes Windows API calls.
Add the USE statement before any declaration statements (such as IMPLICIT NONE or INTEGER).
2. You can limit the type of parameters and interfaces for Windows applications to make compilation times
faster. To do this, include only the subsets of the Windows API needed in multiple USE statements (see
the file ...\INCLUDE\IFWIN.F90).
To locate the specific libraries for the routines being called, view the QuickInfo at the bottom of the
routine page in the Windows API documentation at msdn.microsoft.com, which lists the import library
name. For example, to call only GetSystemTime, you need the interface definitions provided in
kernel32.mod (binary form). To do this, add the following USE statement:
USE KERNEL32
If you want to further minimize compile time, add the ONLY keyword to the USE statement. For example:
USE KERNEL32, only: GetSystemTime, GetLastError
Calling Windows API Routines Using the Intel® Visual Fortran Interface Definitions
To call the appropriate Windows API routine after including the Intel® Visual Fortran interface definitions,
follow these guidelines:
1. Examine the documentation for the appropriate routine in the Windows API (for example,
GetSystemTime) to obtain the following information:
• The number and order of arguments. You will need to declare and initialize each argument variable
using the correct data type. In the case of the GetSystemTime routine, a structure (derived type) is
passed by reference.
597
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If character arguments are present, add a null character as a terminator to the character variable
before calling the Windows API routine.
• Whether the routine returns a result (function) or not (subroutine). For example, because the
GetSystemTime routine calling format starts with VOID, this routine should be called as a subroutine
with a CALL statement.
2. If you are not sure about the data type of arguments or its function return value, you can examine the
interface definitions in the appropriate .F90 file in ...\INCLUDE\. For example, to view the interface
definition for GetSystemTime:
• In a text editor (such as Notepad), open the file kernel32.f90 from ...\INCLUDE\.
• Search (or Find) the routine name (such as GetSystemTime)
• View the interface definition and compare it to the description in the Windows API documentation to
see how the arguments are represented in Fortran. Take note of how arguments are passed; in
some cases, such as when an arbitrary data type is passed by address, you must pass the address
of a variable using the LOC intrinsic rather than the variable directly.
3. If one of the arguments is a structure, look up the definition in IFWINTY.F90 in ...\INCLUDE\. For
example, to view the data type definition for the T_SYSTEMTIME type used in GetSystemTime:
• In a text editor (such as Notepad), open the file IFWINTY.F90 from ...\INCLUDE\.
• Search (or Find) the data type name (such as T_SYSTEMTIME).
• View the data type definition and note the field names. In some cases, these will differ slightly from
those listed in the Windows API documentation.
• Define a variable name to use the derived-type definition in your program, such as:
Integer(HANDLE) :: hwnd
Use the variable definition to call the Win32 routine. For example, the completed program follows:
598
Compiler Reference
BYTE INTEGER(BYTE)
DWORD INTEGER(DWORD)
ULONG INTEGER(ULONG)
SHORT INTEGER(SHORT)
LPHANDLE INTEGER(LPHANDLE)
PLONG INTEGER(PLONG)
DOUBLE REAL(DOUBLE)
Use the kind constants instead of explicitly specifying the kind as a number, or assuming a default kind.
Note that the Windows BOOL type is not equivalent to Fortran LOGICAL and should not be used with Fortran
LOGICAL operators and literal constants. Use the constants TRUE and FALSE, defined in IFWINTY, rather than
the Fortran literals .TRUE. and .FALSE., and do not test BOOL values using LOGICAL expressions.
Additional notes about equivalent data types for arguments:
• If an argument is described in the Windows API documentation as a pointer, then the corresponding
Fortran interface definition of that argument would have the REFERENCE property (see the ATTRIBUTES).
Older interface definitions use the POINTER - Integer and pass the address of the argument, or the LOC
intrinsic function.
• Pointer arguments on systems using IA-32 architecture are 32-bit (4 bytes) in length. Pointer arguments
on systems using Intel® 64 architecture are 64 bits (8 bytes) in length.
• Be aware that Fortran character variables need to be null-terminated. You can do this by using the C
string extension (see C Strings in Character Constants):
ADVAPI32
COMCTL32
599
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
COMDLG32
GDI32
KERNEL32
LZ32
OLE32
OLEAUT32
PSAPI
SCRNSAVE
SHELL32
USER32
VERSION
WINMM
WINSPOOL
WS2_32
WSOCK32
Additionally, the IFOPNGL module declares OpenGL routines for Windows OS, with Fortran-specific names.
Math Libraries
The Intel® Fortran Compiler includes these math libraries:
libimf.a (Linux* and macOS* ) Intel® Math Libraries, in addition to libm.a, the math library
provided with gcc*
Both of these libraries are linked in by default because certain
math functions supported by the GNU* math library are not
available in the Intel® Math Library. This linking arrangement
allows the GNU* users to have all functions available when
using ifort, with Intel optimized versions available when
supported.
libimf.a is linked in before libm.a. If you link in libm.a
first, it will change the versions of the math functions that are
used.
Many routines in the libimf library are more optimized for
Intel® microprocessors than for non-Intel microprocessors.
600
Data and I/O
NOTE
It is strongly recommended to use the default rounding mode (round-to-nearest-even) when calling
math library transcendental functions and compiling with default optimization or higher. Faster
implementations (in terms of latency and/or throughput) of these functions are validated under the
default round-to-nearest-even mode. Using other rounding modes may make results generated by
these faster implementations less accurate, or set unexpected floating-point status flags. This
behavior may be avoided by -no-fast-transcendentals, which disables calls to the faster
implementations of math functions, or by -fp-model strict, which warns the compiler that it
cannot assume default settings for the floating-point environment.
Many routines in the Intel® Math Library are more optimized for Intel® microprocessors than for non-
Intel microprocessors.
Intel® Math Kernel Library (Intel® MKL) Math library of Fortran routines and functions that perform a
wide variety of operations on vectors and matrices. The library
also includes fast Fourier transform (fft) functions, as well as
vector mathematical and vector statistical functions. For more
information, see Using Intel® Performance Libraries with
Microsoft Visual Studio* and the Intel® Math Kernel Library
documentation.
NOTE The Intel Compiler Math Libraries contain performance-optimized implementations for various
Intel platforms. By default, the best implementation for the underlying hardware is selected at
runtime. The library dispatch of multi-threaded code may lead to apparent data races, which may be
detected by certain software analysis tools. However, as long as the threads are running on cores with
the same CPUID, these data races are harmless and are not a cause for concern.
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
601
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The following table lists the intrinsic data types used by Intel® Fortran, the storage required, and valid
ranges. For information on declaring Fortran intrinsic data types, see Type Declarations. For example, the
declaration INTEGER(4) is the same as INTEGER(KIND=4) and INTEGER*4.
Fortran Data Types and Storage
Data Type Storage Description
REAL See REAL(4), A real floating-point value, either REAL(4), REAL(8), or REAL(16). The
REAL(8), and size is controlled by the real-size compiler option.
REAL(16)
DOUBLE See REAL(8) A double precision floating-point value, either REAL(8) or REAL(16). The
PRECISION and REAL(16) size is controlled by the double-size compiler option.
COMPLEX See A complex floating-point value in a pair of real and imaginary parts that
COMPLEX(4), are either REAL(4), REAL(8), or REAL(16). The size is controlled by the
COMPLEX(8), real-size compiler option.
and
COMPLEX(16
)
DOUBLE See A double complex floating-point value in a pair of real and imaginary
COMPLEX COMPLEX(8) parts that are either REAL(8) or REAL(16). The size is controlled by the
and double-size compiler option.
COMPLEX(16
)
602
Compiler Reference
LOGICAL See A logical value, either LOGICAL(2), LOGICAL(4), or LOGICAL(8). The size
LOGICAL(2), is controlled by the integer-size compiler option.
LOGICAL(4),
and
LOGICAL(8)
603
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
INTEGER(KIND=1) Representation
INTEGER(1) values range from -128 to 127 and are stored in 1 byte, as shown below.
INTEGER(KIND=2) Representation
INTEGER(2) values range from -32,768 to 32,767 and are stored in 2 contiguous bytes, as shown below:
604
Compiler Reference
INTEGER(KIND=4) Representation
INTEGER(4) values range from -2,147,483,648 to 2,147,483,647 and are stored in 4 contiguous bytes, as
shown below.
INTEGER(KIND=8) Representation
INTEGER(8) values range from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 and are stored
in 8 contiguous bytes, as shown below.
605
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
LOGICAL(1), LOGICAL(2), LOGICAL(4), and LOGICAL(8) data representations (when fpscomp nologicals
is set) appear below.
See Also
integer-size compiler option
assume compiler option, setting [no]old_logical_assign
fpscomp compiler option, setting [no]logicals
Character Representation
A character string is a contiguous sequence of bytes in memory, as shown below.
A character string is specified by two attributes: the address A of the first byte of the string, and the length L
of the string in bytes.
On Windows* systems, the length L of a string is in the range 1 through 2,147,483,647 (2**31-1) .
On Linux* systems, the length L of a string is in the range 1 through 2,147,483,647 (2**31-1) for systems
based on IA-32 architecture and in the range 1 through 9,223,372,036,854,775,807 (2**63-1) for systems
based on Intel® 64 architecture.
606
Compiler Reference
Hollerith Representation
Hollerith constants are stored internally, one character per byte, as shown below.
Fortran I/O
In Fortran's I/O system, data is stored and transferred among files. All I/O data sources and destinations are
considered files.
Devices such as the screen, keyboard, and printer are external files, as are data files stored on a device such
as a disk.
Variables in memory can also act as a file on a disk and are typically used to convert ASCII representations
of numbers to binary form. When variables are used in this way, they are called internal files.
For more information, see the individual topics in this section.
607
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Logical Devices
Every file, internal or external, is associated with a logical device. You identify the logical device associated
with a file by using Unit Specifier (UNIT=). The unit specifier for an internal file is the name of the character
variable associated with it. The unit specifier for an external file is one of the following:
• A number you assign with the OPEN statement
• A number assigned by the Intel® Fortran run-time library with the OPEN specifier NEWUNIT=
• A number preconnected as a unit specifier to a device
• An asterisk (*)
The OPEN statement connects a unit number with an external file and allows you to explicitly specify file
attributes and run-time options using OPEN statement specifiers. External unit specifiers that are
preconnected to certain devices do not have to be opened. External units that you connect are disconnected
when program execution terminates or when the unit is closed by a CLOSE statement.
A unit must not be connected to more than one file at a time, and a file must not be connected to more than
one unit at a time. You can OPEN an already opened file but only to change some of the I/O options for the
connection, not to connect an already opened file or unit to a different unit or file.
You must use a unit specifier for all I/O statements except in the following cases:
• ACCEPT, which always reads from standard input unless the FOR_ACCEPT environment variable is defined.
• INQUIRE by file, which specifies the filename rather than the unit with which the file is associated.
• PRINT, which always writes to standard output unless the FOR_PRINT environment variable is defined.
• READ statements that contain only an I/O list and format specifier, which read from standard input
(UNIT=5) unless the FOR_READ environment variable is defined.
• WRITE statements that contain only an I/O list and format specifier, which write to standard output unless
the FOR_WRITE environment variable is defined.
• TYPE, which always writes to standard output unless the FOR_TYPE environment variable is defined.
External Files
A unit specifier associated with an external file must be either an integer expression or an asterisk (*). The
integer expression must be in the range 0 (zero) to a maximum value of 2,147,483,640. (The predefined
parameters FOR_K_PRINT_UNITNO, FOR_K_TYPE_UNITNO, FOR_K_ACCEPT_UNITNO, and
FOR_K_READ_UNITNO may not be in that range. For more information, see the Language Reference.)
The following example connects the external file UNDAMP.DAT to unit 10 and writes to it:
Asterisk (*) None Always represents the keyboard and screen (unless the
appropriate environment variable is defined, such as
FOR_READ).
608
Compiler Reference
The asterisk (*) specifier is the only unit specifier that cannot be reconnected to another file; attempting to
close such a unit causes a compile-time error. Units 0, 5, and 6 can be connected to any file with the OPEN
statement; if you close one of those units, the file is automatically reconnected to its preconnected device
the next time an I/O statement attempts to use that unit.
Intel® Fortran does not support buffering to stdin, and does not buffer to stdout by default unless the
assume buffered_stdout option is specified. All I/O to units * and 6 use line buffering by default.
Therefore, C and Fortran output to stdout should work well as long as the C code is not performing
buffering. If the C code is performing buffering, the C code will have to flush the buffers after each write. For
more information on stdout and stdin, see Assigning Files to Logical Units.
You can change these preconnected files by doing one of the following:
• Using an OPEN statement to open unit 5, 6, or 0. When you explicitly OPEN a file for unit 5, 6, or 0, the
OPEN statement keywords specify the file-related information to be used instead of the preconnected
standard I/O file.
• Setting the appropriate environment variable (FORTn) to redirect I/O to an external file.
To redirect input or output from the standard preconnected files at run time, you can set the appropriate
environment variable or use the appropriate shell redirection character in a pipe (such as > or <).
When you omit the file name in the OPEN statement or use an implicit OPEN, you can define the environment
variable FORTn to specify the file name for a particular unit number n. An exception to this is when the
fpscomp filesfromcmd compiler option is specified.
For example, if you want unit 6 to write to a file instead of standard output, set the environment variable
FORT6 to the path and filename to be used before you run the program. If the appropriate environment
variable is not defined, a default filename is used, in the form fort.n where n is the logical unit number.
The following example writes to the preconnected unit 6 (the screen), then reconnects unit 6 to an external
file and writes to it, and finally reconnects unit 6 to the screen and writes to it:
REAL a, b
! Write to the screen (preconnected unit 6).
WRITE(6, '('' This is unit 6'')')
! Use the OPEN statement to connect unit 6
! to an external file named 'COSINES'.
OPEN (UNIT = 6, FILE = 'COSINES', STATUS = 'NEW')
DO k = 1, 63, 1
a = k/10
b = COS (a)
! Write to the file 'COSINES'.
WRITE (6, 100) a, b
100 FORMAT (F3.1, F5.2)
END DO
! Close it.
CLOSE (6)
! Reconnect unit 6 to the screen, by writing to it.
WRITE(6,' ('' Cosines completed'')')
END
Internal Files
The unit specifier associated with an internal file is a scalar or array character variable:
• If the internal file is a scalar character variable, the file has only one record; its length is equal to that of
the variable.
609
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• If the internal file is an array character variable, the file has a record for each element in the array; each
record's length is equal to one array element.
Follow these rules when using internal files:
• Use only formatted I/O, including I/O formatted with a format specification, namelist, and list-directed
I/O. (List-directed and namelist I/O are treated as sequential formatted I/O.)
• If the character variable is an allocatable array or array part of an allocatable array, the array must be
allocated before use as an internal file. If the character variable is a pointer, it must be associated with a
target.
• Use only READ and WRITE statements. You cannot use file connection (OPEN, CLOSE), file positioning
(REWIND, BACKSPACE), or file inquiry (INQUIRE) statements with internal files.
You can read and write internal files with FORMAT I/O statements, namelist I/O statements, or list-directed
I/O statements exactly as you can external files. Before an I/O statement is executed, internal files are
positioned at the beginning of the variable, before the first record.
With internal files, you can use the formatting capabilities of the I/O system to convert values between
external character representations and Fortran internal memory representations. Reading from an internal
file converts the ASCII representations into numeric, logical, or character representations, and writing to an
internal file converts these representations into their ASCII representations.
This feature makes it possible to read a string of characters without knowing its exact format, examine the
string, and interpret its contents. It also makes it possible, as in dialog boxes, for the user to enter a string
and for your application to interpret it as a number.
If less than an entire record is written to an internal file, the rest of the record is filled with blanks.
In the following example, str and fname specify internal files:
CHARACTER(10) str
INTEGER n1, n2, n3
CHARACTER(14) fname
INTEGER i
str = " 1 2 3"
! List-directed READ sets n1 = 1, n2 = 2, n3 = 3.
READ(str, *) n1, n2, n3
i = 4
! Formatted WRITE sets fname = 'FM004.DAT'.
WRITE (fname, 200) i
200 FORMAT ('FM', I3.3, '.DAT')
See Also
assume compiler option
610
Compiler Reference
PRN Printer
NOTE
If you use the LINE, USER, or ERR name with an extension, for example, LINE.TXT, Fortran will write
to a file rather than to the device.
File connection
OPEN Connects a unit number with an external file and specifies file connection
characteristics.
File inquiry
611
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
DEFINE FILE Specifies file characteristics for a direct access relative file and connects the unit
number to the file, similar to an OPEN statement. Provided for compatibility with
compilers older than FORTRAN-77.
INQUIRE Returns information about a named file, a connection to a unit, or the length of an
output item list.
Record position
BACKSPACE Moves the record position to the beginning of the previous record (sequential access
only).
DELETE Marks the record at the current record position in a relative file as deleted (direct
access only).
ENDFILE Writes an end-of-file marker after the current record (sequential access only).
FIND Changes the record position in a direct access file. Provided for compatibility with
compilers older than FORTRAN-77.
REWIND Sets the record position to the beginning of the file (sequential access only).
Record input
READ Transfers data from an external file record or an internal file to internal storage.
ACCEPT Reads input from stdin. Unlike READ, ACCEPT only provides formatted sequential
input and does not specify a unit number.
Record output
WRITE Transfers data from internal storage to an external file record or to an internal file.
REWRITE Transfers data from internal storage to an external file record at the current record
position (direct access relative files only).
PRINT Transfers data from internal storage to stdout. Unlike WRITE, PRINT only provides
formatted sequential output and does not specify a unit number.
FLUSH Flushes the contents of an external unit's buffer to its associated file.
In addition to the READ, WRITE, REWRITE, TYPE, and PRINT statements, other I/O record-related statements
are limited to a specific file organization. For instance:
• The DELETE statement only applies to relative files. (Detecting deleted records is only available if the vms
option was specified when the program was compiled.)
• The BACKSPACE statement only applies to sequential files open for sequential access.
• The REWIND statement only applies to sequential files open for sequential access and to direct access
files.
• The ENDFILE statement only applies to certain types of sequential files open for sequential access and to
direct access files.
The file-related statements (OPEN, INQUIRE, and CLOSE) apply to any relative or sequential file.
612
Compiler Reference
613
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Internal file
Unformatted None
NOTE
You can use the REWRITE statement only for relative files, using direct access.
PRINT *,100
The READ statement associates the logical unit 7 with the file fort.7 (because the FILE specifier was
omitted) by default:
OPEN (UNIT=7,STATUS='NEW')
READ (7,100)
For example:
Implied OPEN
614
Compiler Reference
An implied OPEN means that the FILE and DEFAULTFILE specifier values are not specified. If you used an
implied OPEN, or if the FILE specifier in an OPEN statement did not specify a file name, you can use an
environment variable to specify a file name or a pathname. The pathname can contain both a directory and
file name.
You can change the file associated with these Intel Fortran environment variables, as you would any other
environment variable, by means of the environment variable assignment command. For example:
NOTE
The association between the logical unit number and the physical file can occur at runtime. Instead of
changing the logical unit numbers specified in the source program, you can change this association at
runtime to match the needs of the program and the available resources. For example, before running
the program, a script file can set the appropriate environment variable or allow the terminal user to
type a directory path, file name, or both.
615
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
File Organization
File organization refers to the way records are physically arranged on a storage device. This topic describes
the two main types of file organization.
Related topics describe the following:
• Record type refers to whether records in a file are all the same length, are of varying length, or use other
conventions to define where one record ends and another begins. For more information on record types,
see Record Types.
• Record access refers to the method used to read records from or write records to a file, regardless of its
organization. The way a file is organized does not necessarily imply the way in which the records within
that file will be accessed. For more information on record access, see File Access and File Structure and
Record Access.
When creating a relative file, use the RECL value to determine the size of the fixed-length cells. Within the
cells, you can store records of varying length, as long as their size does not exceed the cell size.
616
Compiler Reference
Internal Files
When you use sequential access, you can use an internal file to reference character data in a buffer. The
transfer occurs between internal storage spaces (unlike external files), such as between user variables and a
character array.
An internal file consists of any of the following:
• Character variable
• Character-array element
• Character array
• Character substring
• Character array section without a vector subscript
Instead of specifying a unit number for the READ or WRITE statement, use an internal file specifier in the
form of a character scalar memory reference or a character-array name reference.
An internal file is a designated internal storage space (variable buffer) of characters that is treated as a
sequential file of fixed-length records. To perform internal I/O, use formatted and list-directed sequential
READ and WRITE statements. You cannot use file-related statements such as OPEN and INQUIRE on an
internal file (no unit number is used).
If an internal file is made up of a single character variable, array element, or substring, that file comprises a
single record whose length is the same as the length of the character variable, array element, or substring it
contains. If an internal file is made up of a character array, that file comprises a sequence of records, with
each record consisting of a single array element. The sequence of records in an internal file is determined by
the order of subscript progression.
A record in an internal file can be read only if the character variable, array element, or substring comprising
the record has been defined (a value has been assigned to the record).
Prior to each READ and WRITE statement, an internal file is always positioned at the beginning of the first
record.
Scratch Files
Scratch files are created by specifying STATUS= 'SCRATCH' in an OPEN statement. By default, these
temporary files are created by an OPEN statement and are deleted when closed.
617
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
You create a formatted file by opening it with the FORM='FORMATTED' option, or by omitting the FORM
parameter when creating a sequential file. The records of a formatted file are stored as ASCII characters.
Numbers that would otherwise be stored in binary form are converted to ASCII format. Each record ends
with the ASCII carriage return (CR) and/or line feed (LF) characters.
If you need to view a data file's contents, use a formatted file. You can load a formatted file into a text
editor and read its contents directly. The numbers will look like numbers and the strings will look like
character strings (an unformatted or binary file looks like a set of hexadecimal characters).
• Unformatted Files
You create an unformatted file by opening it with the FORM='UNFORMATTED' option, or by omitting the
FORM parameter when creating a direct-access file. An unformatted file is a series of records composed of
physical blocks. Each record contains a sequence of values stored in a representation that is close to what
is used in program memory. Little conversion is required during input/output.
The lack of formatting makes these files quicker to access and more compact than files that store the
same information in a formatted form. However, if the files contain numbers, you will not be able to read
them with a text editor.
• Binary Files
You create a binary file by specifying FORM='BINARY'. Binary files are similar to unformatted files, except
binary files have no internal record format associated with them.
• Sequential-Access Files
Data in sequential files must be accessed in order, one record after the other (unless you change your
position in the file with the REWIND or BACKSPACE statements). Some methods of I/O are possible only
with sequential files, including nonadvancing I/O, list-directed I/O, and namelist I/O. Internal files must
also be sequential files. You must use sequential access for files associated with sequential devices.
A sequential device is a physical storage device that does not allow explicit motion (other than reading or
writing). The keyboard, screen, and printer are all sequential devices.
• Direct-Access Files
Data in direct-access files can be read or written to in any order. Records are numbered sequentially,
starting with record number 1. All records have the length specified by the RECL option in the OPEN
statement. Data in direct-access files is accessed by specifying the record you want within the file. If you
need random access I/O, use direct-access files. A common example of a random-access application is a
database.
• Stream-Access Files
Stream-access I/O is a method of accessing a file without reference to a record structure. With stream
access, a file is seen as a continuous sequence of bytes and is addressed by a positive integer starting
from 1.
To enable stream access, specify ACCESS='STREAM' in the OPEN statement for the file. You can use the
STREAM= specifier in the INQUIRE statement to determine if STREAM is listed in the set of possible
access methods for the file. A value of YES, NO, or UNKNOWN is returned.
A file enabled for stream access is positioned by file storage units (normally bytes) starting at position 1.
To determine the current position, use the POS= specifier in an INQUIRE statement for the unit. You can
indicate a required position in a read or write statement with a POS= specifier.
Stream access can be either formatted or unformatted.
When connected for formatted stream access, an external file has the following characteristics:
• The first file storage unit in the file is at position 1. The relationship between positions of successive file
storage units is processor dependent; not all positive integers need to correspond to valid positions.
• Some file storage units may contain record markers that impose a record structure on the file in
addition to its stream structure. If there is no record marker at the end of the file, the final record is
incomplete. Writing an empty record with no record marker has no effect.
618
Compiler Reference
When connected for unformatted stream access, an external file has the following characteristics:
• The first file storage unit in the file is at position 1. The position of each subsequent file storage unit is
one greater than the position of the preceding file storage unit.
• If it is possible to position the file, the file storage units do not need to be read or written in order of
their position. For example, you may be able to write the file storage unit at position 2, even though
the file storage unit at position 1 has not been written.
• Any file storage unit can be read from the file while it is connected to a unit, if the file storage unit has
been written since the file was created, and a READ statement for this connection is allowed.
• You cannot use BACKSPACE in an unformatted stream.
File Records
Files may be composed of records. Each record is one entry in the file. A record can be a line from a terminal
or a logical record on a magnetic tape or disk file. All records within one file are of the same type.
In Fortran, the number of bytes transferred to a record must be less than or equal to the record length. One
record is transferred for each unformatted READ or WRITE statement. A formatted READ or WRITE statement
can transfer more than one record using the slash (/) edit descriptor.
For binary files, a single READ or WRITE statement reads or writes as many records as needed to
accommodate the number of bytes being transferred. On output, incomplete formatted records are padded
with spaces. Incomplete unformatted and binary records are padded with undefined bytes (zeros).
Record Types
An I/O record is a collection of data items, called fields, which are logically related and are processed as a
unit. The record type refers to the convention for storing fields in records.
The record type of the data within a file is not maintained as an attribute of the file. The results of using a
record type other than the one used to create the file are indeterminate.
A number of record types are available, as shown in the following table. The table also lists the record
overhead. Record overhead refers to bytes associated with each record that are used internally by the file
system and are not available when a record is read or written. Knowing the record overhead helps when
estimating the storage requirements for an application. Although the overhead bytes exist on the storage
media, do not include them when specifying the record length with the RECL specifier in an OPEN statement.
Variable- Sequential file organization only. The variable-length record Eight bytes per record.
length type is generally the most portable record type across multi-
vendor platforms.
Segmented Sequential file organization only and specifically for Four bytes per record.
unformatted sequential access. The segmented record type is One additional padding
unique to Intel Fortran. It should not be used for portability byte (space) is added if
with programs written in languages other than Fortran or for the specified record size
places where Intel Fortran is not used. However, because the is an odd number.
segmented record type is unique to Intel Fortran products,
formatted data in segmented files can be ported across Intel
Fortran platforms.
619
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Fixed-Length Records
When you specify fixed-length records, you are specifying that all records in the file contain the same
number of bytes. When you open a file that is to contain fixed-length records, you must specify the record
size using the RECL keyword. A sequentially organized opened file for direct access must contain fixed-length
records, to allow the record position in the file to be computed correctly.
For relative files, the layout and overhead of fixed-length records depends upon whether the program
accessing the file was compiled using the vms option:
• For relative files where the vms option is omitted (the default), each record has no control information.
• For relative files where the vms option is specified, each record has one byte of control information at the
beginning of the record.
The following figures show the record layout of fixed-length records. The first is for all sequential and relative
files where the vms option is omitted. The second is for relative files where the vms option is specified.
620
Compiler Reference
Variable-Length Records
Variable-length records can contain any number of bytes up to a specified maximum record length, and apply
only to sequential files.
Variable-length records are prefixed and suffixed by 4 bytes of control information containing length fields.
The trailing length field allows a BACKSPACE request to skip back over records efficiently. The 4-byte integer
value stored in each length field indicates the number of data bytes (excluding overhead bytes) in that
particular variable-length record.
The character count field of a variable-length record is available when you read the record by issuing a READ
statement with a Q format descriptor. You can then use the count field information to determine how many
bytes should be in an I/O list.
The following shows the record layout of variable-length records that are less than 2 gigabytes:
For a record length greater than 2,147,483,639 bytes, the record is divided into subrecords. The subrecord
can be of any length from 1 to 2,147,483,639, inclusive.
The sign bit of the leading length field indicates whether the record is continued or not. The sign bit of the
trailing length field indicates the presence of a preceding subrecord. The position of the sign bit is determined
by the endian format of the file.
The following rules describe sign bit values:
• A subrecord that is continued has a leading length field with a sign bit value of 1.
• The last subrecord that makes up a record has a leading length field with a sign bit value of 0.
• A subrecord that has a preceding subrecord has a trailing length field with a sign bit value of 1.
• The first subrecord that makes up a record has a trailing length field with a sign bit value of 0.
• If the value of the sign bit is 1, the length of the record is stored in twos-complement notation.
The following shows the record layout of variable-length records that are greater than 2 gigabytes:
621
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Files written with variable-length records by Intel Fortran programs usually cannot be accessed as text files.
Instead, use the Stream_LF record format for text files with records of varying length.
Segmented Records
A segmented record is a single logical record consisting of one or more variable-length, unformatted records
in a sequentially organized disk file. Unformatted data written to sequentially organized files using sequential
access is stored as segmented records by default.
Segmented records are useful when you want to write exceptionally long records but cannot, or you do not
want to define one long variable-length record. For example, you might not want to define one long variable-
length record because virtual memory limitations can prevent program execution. By using smaller,
segmented records, you reduce the chance of problems caused by virtual memory limitations on systems on
which the program may execute.
For disk files, the segmented record is a single logical record that consists of one or more segments. Each
segment is a physical record. A segmented (logical) record can exceed the absolute maximum record length
(2.14 billion bytes), but each segment (physical record) individually cannot exceed the maximum record
length.
To access an unformatted sequential file that contains segmented records, specify FORM='UNFORMATTED'
and RECORDTYPE='SEGMENTED' when you open the file.
The following shows that the layout of segmented records consists of 4 bytes of control information followed
by the user data:
622
Compiler Reference
The control information consists of a 2-byte integer record length count (includes the 2 bytes used by the
segment identifier), followed by a 2-byte integer segment identifier that identifies this segment as one of the
following:
1 First segment
2 Last segment
3 Only segment
If the specified record length is an odd number, the user data will be padded with a single blank (one byte),
but this extra byte is not added to the 2-byte integer record size count.
Avoid the segmented record type when the application requires that the same file be used for programs
written in languages other than Intel Fortran and for non-Intel platforms.
623
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The Stream, Stream_CR, Stream_LF, Stream_CRLF and segmented record types can be used only with
sequential files.
The default record type (RECORDTYPE) depends on the values for the ACCESS and FORM specifiers for the
OPEN statement. (The RECORDTYPE= specifier is ignored for stream access.)
The record type of the file is not maintained as an attribute of the file. The results of using a record type
other than the one used to create the file are indeterminate.
An I/O record is a collection of fields (data items) that are logically related and are usually processed as a
unit.
Unless you specify nonadvancing I/O (ADVANCE specifier), each Intel Fortran I/O statement transfers at least
one record.
FOR_FMT_TERMINATOR=MODE[:ULIST][;MODE[:ULIST]]
where:
MODE=CR | LF | CRLF
ULIST = U | ULIST,U
U = decimal | decimal - decimal
• MODE specifies the record terminator to be used. The keyword CR means to terminate records with a
carriage return. The keyword LF means to terminate records with a line feed; LF is the default on Linux*
and macOS* systems. The keyword CRLF means to terminate records with a carriage return/line feed
pair; CRLF is the default on Windows systems.
• Each list member "U" is a simple unit number or a number of units as a range. The number of list
members is limited to 64.
• "decimal" is a non-negative decimal number less than 232.
No spaces are allowed inside the FOR_FMT_TERMINATOR value.
On Linux* systems, the following shows the command line for the variable setting in a bash-style shell:
NOTE
The environment variable value should be enclosed in quotes if the semicolon is present.
Example:
624
Compiler Reference
The following specifies that all input/output operations on unit numbers 10, 11, and 12 have records
terminated with a carriage return/line feed pair:
FOR_FMT_TERMINATOR=CRLF:10-12
Record Length
Use the RECL specifier to specify the record length.
The units used for specifying record length depend on the form of the data:
• Formatted files (FORM= 'FORMATTED'): Specify the record length in bytes.
• Unformatted files (FORM= 'UNFORMATTED'): Specify the record length in 4-byte units, unless you specify
the assume byterecl compiler option to request 1-byte units.
For all but variable-length sequential records on 64-bit addressable systems, the maximum record length is
2.147 billion bytes (2,147,483,647 minus the bytes for record overhead). For variable-length sequential
records on 64-bit addressable systems, the theoretical maximum record length is about 17,000 gigabytes.
When considering very large record sizes, also consider limiting factors such as system virtual memory.
NOTE
The RECL specifier is ignored for stream access.
Record Access
Record access refers to how records will be read from or written to a file, regardless of the file's organization.
Record access is specified each time you open a file; it can be different each time. The type of record access
permitted is determined by the combination of file organization and record type.
For example, you can fo the following:
• Add records to a sequential file with ORGANIZATION= 'SEQUENTIAL' and POSITION= 'APPEND' (or use
ACCESS= 'APPEND').
• Add records sequentially by using multiple WRITE statements, close the file, and then open it again with
ORGANIZATION= 'SEQUENTIAL' and ACCESS= 'SEQUENTIAL' (or ACCESS= 'DIRECT' if the sequential file
has fixed-length records).
Sequential Access
Sequential access transfers records sequentially to or from files or I/O devices such as terminals. You can use
sequential I/O with any type of supported file organization and record type.
When you select sequential access mode for files with sequential or relative organization, records are written
to or read from the file starting at the beginning of the file and continuing through it, one record after
another. A particular record can be retrieved only after all of the records preceding it have been read; new
records can be written only at the end of the file.
Direct Access
Direct access transfers records selected by record number to and from either sequential files stored on disk
with a fixed-length record type or relative organization files.
If you select direct access mode, you can determine the order in which records are read or written. Each
READ or WRITE statement must include the relative record number, indicating the record to be read or
written.
625
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
You can directly access a sequential disk file only if it contains fixed-length records. Because direct access
uses cell numbers to find records, you can enter successive READ or WRITE statements requesting records
that either precede or follow previously requested records. For example, the first statement reads record 24;
the second statement reads record 10:
READ (12,REC=24) I
READ (12,REC=10) J
Stream Access
Stream access transfers bytes from records sequentially until a record terminator is found or a specified
number of bytes have been read or written. Formatted stream records are terminated with a new line
character; unformatted stream data contains no record terminators. Bytes can be read from or written to a
file by byte position, where the first byte of the file is position 1. For example:
NOTE
The RECORDTYPE= specifier is ignored for stream access.
Variable Yes No
Segmented Yes No
Stream Yes No
Stream_CR Yes No
Stream_LF Yes No
Stream_CRLF Yes No
NOTE
Direct access and relative files require that the file resides on a disk device.
626
Compiler Reference
Record Transfer
I/O statements transfer all data as records. The amount of data that a record can contain depends on the
following circumstances:
• With formatted I/O (except for fixed-length records), the number of items in the I/O statement and its
associated format specifier jointly determine the amount of data to be transferred.
• With namelist and list-directed output, the items listed in the NAMELIST statement or I/O statement list
(in conjunction with the NAMELIST or list-directed formatting rules) determine the amount of data to be
transferred.
• With unformatted I/O (except for fixed-length records), the I/O statement alone specifies the amount of
data to be transferred.
• When you specify fixed-length records (RECORDTYPE= 'FIXED'), all records are the same size. If the size
of an I/O record being written is less than the record length (RECL), extra bytes are added (padding).
Typically, the data transferred by an I/O statement is read from or written to a single record. However, a
single I/O statement can possibly transfer data from or to more than one record, depending on the form of
I/O used.
627
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
When the resulting file pathname begins with a tilde character (~), C-shell-style pathname substitution is
used (regardless of what shell is being used), such as a top-level directory (below the root). For additional
information on tilde pathname substitution, see csh(1).
628
Compiler Reference
• If the FILE specifier is not present, Intel Fortran examines the corresponding environment variable. If the
corresponding environment variable is set, that value is used. If the corresponding environment variable
is not set, a file name in the form fort.n is used.
Once Intel Fortran determines the resulting file name string, it determines the directory (which optionally
precedes the file name) as follows:
• If the resulting file name string contains an absolute pathname, it is used and the DEFAULTFILE specifier,
environment variable, and current directory values are ignored.
• If the resulting file name string does not contain an absolute pathname, Intel Fortran examines the
DEFAULTFILE specifier and current directory value: If the corresponding environment variable is set and
specifies an absolute pathname, that value is used. Otherwise, the DEFAULTFILE specifier value, if
present, is used. If the DEFAULTFILE specifier is not present, Intel Fortran uses the current directory as an
absolute pathname.
629
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
630
Compiler Reference
The file test.dat in directory /usr/users/smith is opened on logical unit 4. No defaults are applied,
because both the directory and file name were specified. The value of the FILE specifier can be a character
constant, variable, or expression.
In the following interactive example, the user supplies the file name and the DEFAULTFILE specifier supplies
the default values for the full pathname string. The file to be opened is located in /usr/users/smith and is
concatenated with the file name typed by the user into the variable DOC:
CHARACTER(LEN=9) DOC
WRITE (6,*) 'Type file name '
READ (5,*) DOC
OPEN (UNIT=2, FILE=DOC, DEFAULTFILE='/usr/users/smith',STATUS='OLD')
A slash (backslash on Windows systems) is appended to the end of the default file string if it does not have
one.
On Windows, there is a default limit of 260 characters in a pathname string. Longer strings are truncated to
that limit. Windows provides an override of the limit. To use the override, the pathname must be absolute
(from the drive), not relative (from the current directory). To override, start the pathname with "\\?\". If
DEFAULTFILE is set, it can be prefixed with the override. Fortran supports this override for the FILE and
DEFAULTFILE specifiers, up to a limit of 4095 characters.
On Linux, the pathname limit is always 4095 characters.
Inquiry by Unit
An inquiry by unit is usually done for an opened (connected) file. An inquiry by unit causes the Intel® Fortran
RTL to check whether the specified unit is connected or not. One of the following occurs, depending on
whether the unit is connected or not:
If the unit is connected:
• The EXIST and OPENED specifier variables indicate a true value.
• The pathname and file name are returned in the NAME specifier variable (if the file is named).
• Other information requested on the previously connected file is returned.
• Default values are usually returned for the INQUIRE specifiers also associated with the OPEN statement.
• The RECL value unit for connected formatted files is always 1-byte units. For unformatted files, the RECL
unit is 4-byte units, unless you specify the -assume byterecl option to request 1-byte units.
631
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If no match occurs:
• The OPENED specifier variable indicates a false value.
• The unit NUMBER specifier variable is returned as a value of -1.
• The EXIST specifier variable indicates (true or false) whether the named file exists on the device or not.
• If the file does exist, the NAME specifier variable contains the pathname and file name.
• Any other information returned will be default values for the various specifiers, based on any information
specified when calling INQUIRE.
The following INQUIRE statement returns whether the file named log_file is connected in logical variable
I_OPEN, whether the file exists in logical variable I_EXIST, and the unit number in integer variable
I_NUMBER:
INQUIRE (IOLENGTH=I_RECLENGTH) A, B, H
OPEN (FILE='test.dat', FORM='UNFORMATTED', RECL=I_RECLENGTH, UNIT=9)
For an unformatted file, the IOLENGTH value is returned using 4-byte units, unless you specify the
-assume byterecl option to request 1-byte units.
Inquiry by Directory
An inquiry by directory verifies that a directory exists.
If the directory exists:
• The EXIST specifier variable indicates a true value.
• The full directory pathname is returned in the DIRSPEC specifier variable.
If the directory does not exist:
• The EXIST specified variable indicates a false value.
• The value of the DIRSPEC specifier variable is unchanged.
For example, the following INQUIRE statement returns the full directory pathname:
LOGICAL ::L_EXISTS
CHARACTER (255)::C_DIRSPEC
INQUIRE (DIRECTORY=".", DIRSPEC=C_DIRSPEC, EXIST=L_EXISTS)
632
Compiler Reference
The following INQUIRE statement verifies that a directory does not exist:
633
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• Implicit Shared mode, which occurs when no mode is specified. This mode is also called No Locking.
• Explicit Shared mode, when all cooperating processes have access to a file. This mode is set in the OPEN
statement by the SHARED specifier or the SHARE='DENYNONE' specifier.
• Exclusive mode, when only one process has access to a file. This mode is set in the OPEN statement by
the NOSHARED specifier or the SHARE='DENYRW' specifier.
The file locking mechanism looks for explicit setting of the corresponding specifier in the OPEN statement.
Otherwise, the Fortran runtime does not perform any setting or checking for file locking. The process can
access the file regardless of the fact that other processes have already opened or locked the file.
634
Compiler Reference
• BACKSPACE sets the record position to the previous record in a file. Using sequential access, if you wrote
record 5, issued a BACKSPACE to that unit, and then read from that unit, you would read record 5.
• ENDFILE writes an end-of-file marker. This action is used after writing records using sequential access just
before you close the file.
Unless you use nonadvancing I/O, reading and writing records usually advances the current record position
by one record. More than one record might be transferred using a single record I/O statement.
NOTE
If your application requires that you use C to perform the file open and close, as well as all record
operations, call the appropriate C procedure from the Intel® Fortran program without using the Fortran
OPEN statement.
635
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
If a file name was specified in the OPEN statement that included the USEROPEN specifier, any
subsequent CLOSE statement specifying STATUS=DELETE (or DISPOSE=DELETE) only acts on the file
name specified in the OPEN statement. If you specified a different file name in the function named in
USEROPEN, the CLOSE statement will have no effect on that file name.
EXTERNAL UOPEN
INTEGER UOPEN
.
.
.
OPEN (UNIT=10, FILE='/usr/test/data', STATUS='NEW', USEROPEN=UOPEN)
During the execution of the OPEN statement, the external procedure called uopen_ receives control. The
function opens the file, may perform other operations, and subsequently returns control (with the file
descriptor) to the RTL. You can use other system calls or library routines within the USEROPEN function.
In most cases, the USEROPEN function modifies the open flags argument passed by the Intel® Fortran RTL or
uses a new value before the open (or create) system call. After the function opens the file, it must return
control to the RTL.
On Linux and macOS*, the file descriptor is a 4-byte integer on both 32-bit and 64-bit systems. On Windows,
the file descriptor is a 4-byte integer on 32-bit systems and an 8-byte integer on 64-bit systems:
• If the USEROPEN function is written in C, declare it as a C function.
• If the USEROPEN function is written in Fortran, declare it as a FUNCTION, perhaps with an interface block.
The called function must return the file descriptor to the RTL, or -1 if the function detects an error.
The following shows the available arguments and definitions for Linux* and macOS*, and then for Windows*:
Linux* and macOS* Arguments and Definitions:
636
Compiler Reference
4. Indicates the create mode, which is the protection needed when creating a Linux* OS-style file. The
create modes are described in open(2).
5. Indicates the logical unit number.
6. Indicates the pathname length (hidden character length argument of the pathname).
Argument Notes for Linux* and macOS*:
The open system call (see open(2)) requires the passed pathname, the open flags (which define the type of
access needed, whether the file exists, and so on), and the create mode. The logical unit number specified in
the OPEN statement is passed in case the USEROPEN function needs it. The hidden character length of the
pathname is also passed.
Windows* Arguments and Definitions:
637
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
On Linux* systems, system calls and library routines that do not return a file descriptor include mknod (see
mknod(2)) and fopen (see fopen(3)). For example, the fopen routine returns a file pointer instead of a file
descriptor.
The following Intel® Fortran code calls the USEROPEN function named UOPEN:
EXTERNAL UOPEN
INTEGER UOPEN
.
.
.
OPEN (UNIT=1,FILE='ex1.dat',STATUS='NEW',USEROPEN=UOPEN,
ERR=9,IOSTAT=errnum)
If UOPEN is a Fortran function, its name is decorated appropriately for Fortran.
Likewise, if UOPEN is a C function, its name is decorated appropriately for C, as long as the following line is
included in the above code:
Examples
The following shows an example on Linux and macOS* systems and an example on Windows systems.
Example on Linux and macOS* systems:
PROGRAM UserOpenMain
IMPLICIT NONE
EXTERNAL UOPEN
INTEGER(4) UOPEN
CHARACTER(10) :: FileName="UOPEN.DAT"
INTEGER :: IOS
CHARACTER(255):: InqFullName
CHARACTER(100):: InqFileName
INTEGER :: InqLun
CHARACTER(30) :: WriteOutBuffer="Write_One_Record_to_the_File. "
CHARACTER(30) :: ReadInBuffer ="??????????????????????????????"
OPEN(UNIT=10,FILE='UOPEN.DAT',STATUS='REPLACE',USEROPEN=UOPEN, &
IOSTAT=ios, ACTION='READWRITE')
! When the OPEN statement is executed, the uopen_ function receives control.
! The uopen_ function opens the file by calling open(), and subsequently
! returns control with the handle returned by open().
638
Compiler Reference
WRITE(*,120) TRIM(FileName)
END IF
ELSE
WRITE(*,115) TRIM(FileName), IOS
GOTO 9999
END IF
WRITE(10,*) WriteOutBuffer
REWIND(10)
READ(10,*) ReadInBuffer
IF (ReadinBuffer .NE. WriteOutbuffer) THEN
WRITE(*,130) TRIM(FileName)
END IF
CLOSE(10)
WRITE(*,'(X,"FortranMain: Test of USEROPEN Completed")')
9999 CONTINUE
END
!---------------------------------------------------------------
! SUBROUTINE: ParseForFileName
! Takes a full pathname and returns the filename
! with its extension.
!---------------------------------------------------------------
SUBROUTINE ParseForFileName(FullName,FileName)
CHARACTER(255):: FullName
CHARACTER(255):: FileName
INTEGER :: P
P = INDEX(FullName,'/',.TRUE.)
FileName = FullName(P+1:)
END
//
// File: UserOpen_Sub.c
//
// This routine opens a file using data passed from the Intel(c) Fortran OPEN statement.
//
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/file.h>
#include <errno.h>
int uopen_ ( char *file_name, /* access read: name of the file to open (null terminated) */
int *open_flags, /* access read: READ/WRITE, see file.h or open(2) */
int *create_mode, /* access read: set if the file is to be created */
int *unit_num, /* access read: logical unit number to be opened */
int filenam_len ) /* access read: number of characters in file_name */
{
/*
** The returned value is the following:
** value != -1 is a valid file descriptor
639
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
return (return_value);
} /* end of uopen_() */
USE IFWIN
640
Compiler Reference
! Do the CreateFile( ) call and return the status to the Fortran rtl
STS = CreateFile( FILENAME, &
DESIRED_ACCESS, &
SHARE_MODE, &
NULL_SEC_ATTR, &
CREATE_DISP, &
FLAGS_ATTR, &
0 )
UOPEN = STS
RETURN
END
The UOPEN function is declared to use the cdecl calling convention, so it matches the Fortran runtime
library declaration of a USEROPEN routine.
The following function definition and arguments are passed from the Fortran runtime Library to the function
named in USEROPEN:
FILENAME Is the address of a null terminated character string that is the name of
the file.
A_NULL Is always null. The Fortran runtime library always passes a NULL for
the pointer to a SECURITY_ATTRIBUTES structure in its
CreateFile( ) call.
641
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
CREATE_DISP Is the creation disposition specifying the action to take on files that
exist, and the action to take on files that do not exist. The value is
passed by reference.
FLAGS_ATTR Specifies the file attributes and flags for the file. The value is passed
by reference.
B_NULL Is always null. The Fortran runtime library always passes a NULL for
the handle to a template file in its CreateFile( ) call.
The last 2 arguments are the Fortran unit number and length of the file name:
UNIT Is the Fortran unit number on which this OPEN is being done. The
value is passed by reference.
FLEN Is the length of the file name, not counting the terminating null, and
passed by value.
See Also
OPEN: USEROPEN Specifier
PXFFILENO
An example of a program writing three records to a formatted sequential file is given below. The resulting file
is shown in the following figure.
642
Compiler Reference
643
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The records in an unformatted sequential file can vary in length. Unformatted sequential files are organized
in chunks of 130 bytes or less called physical blocks. Each physical block consists of the data you send to the
file (up to 128 bytes) plus two 1-byte "length bytes" inserted by the compiler. The length bytes indicate
where each record begins and ends.
A logical record refers to an unformatted record that contains one or more physical blocks. (See the following
figure.) Logical records can be as big as you want; the compiler will use as many physical blocks as
necessary.
When you create a logical record consisting of more than one physical block, the compiler sets the length
byte to 129 to indicate that the data in the current physical block continues on into the next physical block.
For example, if you write 140 bytes of data, the logical record has the structure shown in the following
figure.
The first and last bytes in an unformatted sequential file are reserved; the first contains a value of 75, and
the last holds a value of 130. Fortran uses these bytes for error checking and end-of-file references.
The following program creates the unformatted sequential file shown in the following figure:
644
Compiler Reference
!
CHARACTER xyz(3)
INTEGER(4) idata(35)
DATA idata /35 * -1/, xyz /'x', 'y', 'z'/
!
! Open the file and write out a 140-byte record:
! 128 bytes (block) + 12 bytes = 140 for IDATA, then 3 bytes for XYZ.
OPEN (3, FILE='UFSEQ',FORM='UNFORMATTED')
WRITE (3) idata
WRITE (3) xyz
CLOSE (3)
END
645
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
646
Compiler Reference
NOTE
To execute a program that uses asynchronous I/O on Linux* or macOS* systems, you must explicitly
include one of the following compiler options when you compile and link your program:
• -threads
• -reentrancy threaded
• -qopenmp
On Windows* systems, no extra options are needed to execute a program that uses asynchronous I/O.
647
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• by an explicit WAIT (initno) statement, which performs a wait operation for the specified pending
asynchronous data transfer operation
• by a CLOSE statement for the file
• by a file-positioning statement such as REWIND or BACKSPACE
• by an INQUIRE statement for the file
Use the WAIT statement to ensure that the objects used in the asynchronous data transfer statements are
not prematurely deallocated. This action is especially important for local stack objects and allocatable objects
that may be deallocated before completion of the pending operation. If you do not specify the wait operation,
the program may terminate with an access violation error. The following example shows use of the WAIT
statement:
module mod
real, allocatable :: X(:)
end module mod
subroutine sbr()
use mod
integer :: Y(500)
!X and Y initialization
allocate (X(500))
call foo1(X, Y)
!asynchronous writing
open(1, asynchronous='yes')
write(1, asynchronous='yes') X, Y
!some computation
call foo2()
!wait operation
wait(1)
!X deallocation
deallocate(X)
!stack allocated object Y will be deallocated when the routine returns
end subroutine sbr
You can use the INQUIRE statement with the keyword of ASYNCHRONOUS (ASYNCHRONOUS=specifier) to
determine whether asynchronous I/O is allowed. If it is allowed, a value of YES is returned.
Additionally, you can use the INQUIRE statement with the keyword of PENDING (PENDING= specifier) to
determine whether previously pending asynchronous data transfers are complete.
If an ID= specifier appears and the specified data transfer operation is complete, the variable specified by
PENDING is assigned the value False and the INQUIRE statement performs a wait operation for the specified
data transfer.
If the ID= specifier is omitted and all previously pending data transfer operations for the specified unit are
complete, the variable specified by PENDING is assigned the value False and the INQUIRE statement
performs wait operations for all previously pending data transfers for the specified unit.
Otherwise, the variable specified by PENDING is assigned the value True and no wait operations are
performed. Previously pending data transfers remain pending.
See Also
Asynchronous Specifier (ASYNCHRONOUS=)
OPEN/ASYNCHRONOUS Specifier
INQUIRE/ASYNCHRONOUS Specifier
ASYNCHRONOUS Statement and Attributes
648
Mixed Language Programming
649
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
module ftn_C_2
interface
integer (C_INT) function C_Library_Function &
(sendbuf, sendcount, recvcounts) &
BIND(C, name='C_Library_Function')
use, intrinsic :: ISO_C_BINDING
implicit none
type (C_PTR), value :: sendbuf
integer (C_INT), value :: sendcount
type (C_PTR), value :: recvcounts
end function C_Library_Function
end interface
end module ftn_C_2
650
Compiler Reference
void simulation(long alpha, double *beta, long *gamma, double delta[], struct pass *arrays);
NOTE
Existing code using legacy extensions will continue to work; however, if you are writing new code, you
should use the standard syntax.
651
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
652
Compiler Reference
ISO_C_BINDING
The intrinsic module provides a set of named constants and procedures that can assist you in programming
with mixed languages.
USE, INTRINSIC::ISO_C_BINDING
There are two groups of named constants included in this intrinsic module -- those that hold kind type
parameter values for intrinsic types and those that provide a Fortran equivalent to some of the C special
characters, including:
The procedures included in ISO_C_BINDING are all generic, not specific. With the exception of C_F_POINTER
and C_F_PROCPOINTER, all of the procedures are pure. They include:
• C_ASSOCIATED
• C_F_POINTER
• C_F_PROCPOINTER
• C_FUNLOC
• C_LOC
• C_SIZEOF
Additionally, ISO_C_BINDING includes the following derived types to interoperate with C pointers:
• C_PTR
• C_FUNPTR
• C_NULL_PTR
653
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• C_NULL_FUNPTR
BIND(C)
Fortran 2003 introduced the language-binding-spec attribute, using the keyword BIND. The syntax is:
BIND(C [, NAME=scalar-default-char-constant-expr])
C is the only language name you can specify. Generally, an entity with the BIND(C) attribute behaves as if it
were the corresponding entity in the companion C processor.
The optional NAME= specifier allows you to use a different external name than the one the standard
prescribes, which is what the companion C processor would do with the Fortran name forced to lowercase. If
the C name was mixed-case, specify the mixed-case name here without any name decoration, such as
leading underscores. The compiler applies whatever decoration the C processor would with the same name.
So NAME= is not a strict replacement for the ALIAS attribute extension, it is more like ALIAS combined with
DECORATE.
BIND(C) is not equivalent to ATTRIBUTES C. Although these both downcase the external name, BIND(C) does
not imply pass-by-value and has other effects that are different from ATTRIBUTES C.
You can specify ATTRIBUTES STDCALL for an interoperable procedure (a procedure whose declaration
includes the BIND(C) language binding attribute). This combination has the following effects for Windows*
applications targeting IA-32 architecture:
• The calling mechanism is changed to STDCALL, which affects how the stack is cleaned up on procedure
exit.
• The external name from the BIND attribute is suffixed with @n, where n is the number of bytes to be
removed from the stack on return.
No other effects from STDCALL, such as pass-by-value, are provided. The Fortran standard VALUE attribute
(not ATTRIBUTES VALUE) may be used if desired. For all other platforms, specifying STDCALL with BIND(C)
has no effect. For more information, see ATTRIBUTES C and STDCALL.
BIND(C) on procedures
BIND(C) is often used on procedures. It can be specified in INTERFACE blocks to specify the interface of an
external interoperable procedure, and on any Fortran procedures that you want to make interoperable. For
SUBROUTINEs and FUNCTIONs, you need to specify BIND(C) after the argument list. For functions, you can
specify BIND(C) before or after the RESULT clause. For example:
SUBROUTINE INTEROP_SUB (ARG) BIND(C,NAME="InteropSub")
654
Compiler Reference
The standard does not provide an easy way to write a Fortran interoperable routine that accepts a string
from C. You must declare the dummy argument as an array of single characters. You can use the
combination of the C_LOC and C_F_POINTER procedures, both defined in intrinsic module ISO_C_BINDING,
to "cast" a character array argument to a Fortran pointer to a character string. An example follows:
subroutine Interop_sub(arg) BIND(C)
USE, INTRINSIC :: ISO_C_BINDING
CHARACTER, DIMENSION(*) :: ARG
CHARACTER(1000), POINTER :: LCL_ARG ! Local pointer to argument
CALL C_F_POINTER(C_LOC(ARG), LCL_ARG)
In the above, ARG comes in as an assumed-size array of single characters, with no length. The C_F_POINTER
subroutine converts a C pointer to a Fortran pointer. C_LOC is used to get a C pointer (of type C_PTR) of the
argument and convert it to the Fortran pointer LCL_ARG. The result is that you can use LCL_ARG as a
character string.
In the example, LCL_ARG has an explicit length. There is no way to make this pointer the correct length of
the incoming string. Use INDEX to find the location of the NUL character, or some other method, to obtain
the length and then use that in subsequent references.
See Also
BIND
Assumed-rank
An assumed-rank object is a dummy variable whose rank is assumed from its actual argument. This
facilitates interoperability with C functions that can accept arguments of arbitrary rank. The intrinsic function,
RANK, can be used to obtain the rank of an assumed-rank variable.
A procedure must have an explicit interface if it has a dummy argument that is assumed-rank.
The SHAPE, SIZE, and UBOUND intrinsic functions are defined for an assumed-rank array that is associated
with an assumed-size array.
An assumed-rank dummy argument may correspond to an actual argument of any rank. If the actual
argument has rank zero, the dummy argument has rank zero; the shape is a zero-sized array and the
LBOUND and UBOUND intrinsic functions, with no DIM argument, return zero-sized arrays. If the actual
argument has rank greater than zero, the rank and extents of the dummy argument are assumed from the
actual argument, including no final extent for an assumed-size array. If the actual argument is an array and
the dummy argument has the ALLOCATABLE or POINTER attribute, the bounds of the dummy argument are
assumed from the actual argument.
Assumed-type
An assumed-type object is a dummy variable declared as TYPE(*). This simplifies interoperability with C
formal parameters of type (void *).
An explicit interface is required for a procedure that has a dummy argument that is assumed-type because
an assumed-type dummy argument is polymorphic.
An assumed-type dummy argument must not correspond to an actual argument that is of derived type with
type parameters, type-bound procedures, or final subroutines.
CFI_cdesc
A C descriptor is a C structure of type CFI_cdesc that is defined in the file ISO_Fortran_binding.h.
655
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Further Requirements
Variables with the ASYNCHRONOUS attribute can be used for asynchronous communications between Fortran
and C procedures.
When a Fortran procedure that has an INTENT (OUT) allocatable dummy argument is invoked by a C
function, and the actual argument in the C function is the address of a C descriptor that describes an
allocated allocatable variable, the variable is deallocated on entry to the Fortran procedure. When a C
function is invoked from a Fortran procedure via an interface with an INTENT (OUT) allocatable dummy
argument, and the actual argument in the reference to the C function is an allocated allocatable variable, the
variable is deallocated on invocation (before execution of the C function begins).
ISO_Fortran_binding.h
The types, macros, and functions declared in ISO_Fortran_binding.h can be used by a C function to
interpret C descriptors and allocate and deallocate objects represented by C descriptors. These provide a
means to specify a C prototype that interoperates with a Fortran interface that has an allocatable, assumed
character length, assumed-rank, assumed-shape, or data pointer dummy argument.
The ISO_Fortran_binding.h is a C header file that contains these definitions:
656
Compiler Reference
• the C descriptor shall not be modified if either the corresponding dummy argument in the Fortran
interface has the INTENT(IN) attribute or the C descriptor is for a nonallocatable nonpointer object,
and
• the base_addr member of the C descriptor shall not be accessed before it is given a value if the
corresponding dummy argument in the Fortran interface has the POINTER and INTENT(OUT)
attributes.
In this context, modification refers to any change to the location or contents of the C descriptor, including
establishing and updating. The intent of these restrictions is that the C descriptors will remain intact at all
times that they are accessible to an active Fortran procedure, so that the Fortran code is not required to
copy them.
• Within a C function, an allocatable object shall be allocated or deallocated only by execution of the
CFI_allocate and CFI_deallocate functions. A Fortran pointer can become associated with a target by
execution of the CFI allocate function.
• Calling CFI_allocate or CFI_deallocate for a C descriptor changes the allocation status of the Fortran
variable it describes and causes the allocation status of any associated allocatable variable to change
accordingly.
• If the address of an object is the value of a formal parameter that corresponds to a nonpointer dummy
argument in a BIND(C) interface, then
• if the dummy argument has the INTENT (IN) attribute, the object must not be defined or become
undefined, and
• if the dummy argument has the INTENT (OUT) attribute, the object must not be referenced before it is
defined.
• When a Fortran object is deallocated, or execution of its host function is completed, or its association
status becomes undefined, all C descriptors and C pointers to any part of it become undefined, and any
further use of them is undefined behavior.
• A C descriptor whose address is a formal parameter that corresponds to a Fortran dummy argument
becomes undefined on return from a call to the function from Fortran. If the dummy argument does not
have either the TARGET or ASYNCHRONOUS attribute, all C pointers to any part of the object described by
the C descriptor become undefined on return from the call, and any further use of them is undefined
behavior.
• When a Fortran object is deallocated, or execution of its host function is completed, or its association
status becomes undefined, all C descriptors and C pointers to any part of it become undefined, and any
further use of them is undefined behavior.
• If the address of a C descriptor is passed as an actual argument to a Fortran procedure, the C lifetime of
the C descriptor shall not end before the return from the procedure call.
• If an object is passed to a Fortran procedure as a nonallocatable, nonpointer dummy argument, its
lifetime shall not end before the return from the procedure call.
• If the lifetime of a C descriptor for an allocatable object that was established by C ends before the
program exits, the object shall be unallocated at that time.
• If a Fortran pointer becomes associated with a C object, the association status of the Fortran pointer
becomes undefined when the lifetime of the C object ends.
See Also
C Structures, Typedefs, and Macros for Interoperability
657
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• CFI_index_t lower_bound: The value of the lower bound for the dimension being described.
• CFI_index_t extent: The value is the number of elements in the dimension being described or -1 for
the last dimension of an assumed-size array.
• CFI_index_t sm: The value is the memory stride for a dimension; this value is the difference in bytes
between the addresses of successive elements in the dimension being described.
CFI_cdesc_t is a typedef name for a C structure, which contains a flexible array member. The first three
members of the structure are base_addr, elem_len, and version in that order. The final member is dim.
All other members must be between version and dim, in any order.
• void * base_addr: If the object Interoperating with arguments using C descriptors is an unallocated
allocatable variable or a pointer that is disassociated, the value is a null pointer. If the object has zero
size, the value is not a null pointer but is processor-11 dependent. Otherwise, the value is the base
address of the object being described. The base address of a scalar is its C address. The base address of
an array is the C address of the first element in Fortran array element order.
• size_t elem_len: If the object is a scalar, the value is the storage size in bytes of the object; otherwise,
the value is the storage size in bytes of an element of the object.
• int version: The value is the value of CFI_VERSION in the source file ISO_Fortran_binding.h that
defined the format and meaning of this C descriptor when the descriptor was established.
• CFI_rank_t rank: The value is the number of dimensions of the Fortran object being described; if the
object is a scalar, the value is zero.
• CFI_type_t type: The value is the specifier for the type of the object. Each interoperable intrinsic C
type has a specifier. Specifiers are also provided to indicate that the type of the object is an interoperable
structure, or is unknown. The macros listed in the table below provide values that correspond to each type
code specifier.
658
Compiler Reference
• The value for CFI_type_other is negative and distinct from all other type specifiers.
• CFI_type_struct specifies a C structure that is interoperable with a Fortran derived type; its value is
positive and distinct from all other type specifiers.
• If a C type is not interoperable with a Fortran type and kind supported by the Fortran processor, its
macro evaluates to a negative value.
• Otherwise, the value for an intrinsic type is positive.
• CFI_attribute_t attribute – The value is the value of an attribute code that indicates whether the
object described is allocatable, a data pointer, or a nonallocatable, nonpointer data object. The values are
nonnegative and distinct.
The macros listed in the table below provide values that correspond to each attribute code.
Macros for Attribute Codes
Macro Attribute code indicated
Data pointer object
CFI_attribute_pointer
Allocatable object
CFI_attribute_allocatable
Nonallocatable, nonpointer object
CFI_attribute_other
•
CFI_attribute_pointer specifies a data object with the Fortran POINTER attribute.
•
CFI_attribute_allocatable specifies an object with the Fortran ALLOCATABLE attribute.
•
CFI_attribute_other specifies a nonallocatable nonpointer object.
• CFI_dim_t dim – The number of elements in the dim array is equal to the rank of the object. Each
element of the array contains the lower bound, extent, and memory stride information for the
corresponding dimension of the Fortran object.
For a C descriptor of an array pointer or allocatable array, the value of the lower_bound member of each
element of the dim member of the descriptor is determined by argument association, allocation, or pointer
association. For a C descriptor of a nonallocatable nonpointer object, the value of the lower_bound member
of each element of the dim member of the descriptor is zero.
In a C descriptor of an assumed-size array, the extent member of the last element of the dim member has
the value -1. The value of elem_len for a Fortran CHARACTER object is equal to the character length times
the number of bytes of a single character of that kind. If the kind is C_CHAR, this value will be equal to the
character length.
659
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
CFI_CDESC_T is a function-like macro that takes one argument: the rank of the C descriptor creates and
evaluates to an unqualified type of suitable size and alignment for defining a variable to use as a C descriptor
of that rank. The argument shall be an integer constant expression with a value that is greater than or equal
to zero and less than or equal to CFI_MAX_RANK. A pointer to a variable declared using CFI_CDESC_T can be
cast to CFI_cdesc_t *. A variable declared using CFI_CDESC_T must not have an initializer.
The CFI_CDESC_T macro provides the memory for a C descriptor. The address of an entity declared using the
macro is not usable as an actual argument corresponding to a formal parameter of type CFI_cdesc_t *
without an explicit cast.
CFI_index_t is a typedef name for a standard signed integer type capable of representing the result of
subtracting two pointers.
The CFI_MAX_RANK macro has a value equal to the largest rank supported, i.e., 31. CFI_rank_t is a typedef
name for a standard integer type capable of representing the largest supported rank.
The CFI_VERSION macro has a processor-dependent value that encodes the version of the
ISO_Fortran_binding.h source file containing this macro. This value is increased if a new version of the
source file is incompatible with the previous version.
CFI_attribute_t is a typedef name for a standard integer type capable of representing the values of the
attribute codes.
CFI_type_t is a typedef name for a standard integer type capable of representing the values for the
supported type specifiers.
The macros in the table below are for use as error codes. The macro CFI_SUCCESS is the integer constant 0.
The value of each macro other than CFI_SUCCESS is nonzero and is different from the values of the other
error code macros.
Macros for Error Codes
Macro name Error condition
CFI_SUCCESS No error detected.
CFI_ERROR_BASE_ADDR_NULL The base address member of a C descriptor is a null
pointer in a context that requires a non-null pointer value.
CFI_ERROR_BASE_ADDR_NOT_NULL The base address member of a C descriptor is not a null
pointer in a context that requires a null pointer value.
CFI_INVALID_ELEM_LEN The value supplied for the element length member of a C
descriptor is not valid.
CFI_INVALID_RANK The value supplied for the rank member of a C descriptor
is not valid.
CFI_INVALID_TYPE The value supplied for the type member of a C descriptor
is not valid.
CFI_INVALID_ATTRIBUTE The value supplied for the attribute member of a C
descriptor is not valid.
CFI_INVALID_EXTENT The value supplied for the extent member of a
CFI_dim_t structure is not valid.
CFI_INVALID_DESCRIPTOR A C descriptor is invalid in some way.
CFI_ERROR_MEM_ALLOCATION Memory allocation failed.
CFI_ERROR_OUT_OF_BOUNDS A reference is out of bounds.
See Also
Interoperating with arguments using C descriptors
660
Compiler Reference
Data Types
Fortran and C support many of the same data types, but there are no direct correlations.
One difference is that Fortran has the concept of kinds. C treats these kinds as distinct types. For example,
the Fortran INTEGER. C has integer types that range from short int to long long int, and has specialty
types such as intptr_t. Fortran may not have a corresponding kind. For each interoperable C integer
type, the ISO_C_BINDING declares a named constant (PARAMETER) that gives the kind number for the
implementation's equivalent INTEGER kind.
Consider the simple C int type. This corresponds to INTEGER(C_INT), where C_INT is defined in the
ISO_C_BINDING. In Intel® Fortran, the value is always four, as a C int corresponds with Fortran
INTEGER(4). Other Fortran implementations may use different kind numbers. Using the named constant
ensures portability.
Now consider the C intptr_t type. This integer is large enough to hold a pointer (address). In Intel®
Fortran, this corresponds to INTEGER(C_INTPTR_T). It is INTEGER(4) when building a 32-bit application, and
INTEGER(8) when building a 64-bit application.
Fortran has no unsigned integer types, so there are no constants for C unsigned types. These types are not
interoperable.
If there is a kind of C type that is not supported by the Fortran implementation, the named constant for that
type is defined as -1 and generates a compile-time error if used.
There are constants defined for REAL, COMPLEX, LOGICAL, and CHARACTER. For REAL, the standard offers
the possibility of a C long double type. This is implemented in different ways by various C compilers on
various platforms supported by Intel® Fortran.
• GCC* on 32-bit Linux*: The long double is an 80-bit floating type, as supported by the X87
instruction set. It is not supported by Intel® Fortran, so the C_LONG_DOUBLE is -1.
• GCC on macOS*: The C_LONG_DOUBLE is defined as 16.
• Windows*: The long double is treated the same as a double, so the C_LONG_DOUBLE is defined as 8.
• 64-bit Linux*: The C_LONG_DOUBLE is defined as 16.
For Intel's DPC++ and C/C++ compilers, long double by default is an 80-bit extended precision
floating-point type. C/C++ files containing long double data types that interoperate with Fortran should
be compiled with the GCC option -mlong-double-128 to force long double variables to 128-bit quad
precision. Intel's Fortran compilers do not support an 80-bit extended precision data type.
NOTE
• Use the constants for kind values and the corresponding types in C to ensure matching.
• In Intel® C/C++ on Linux*, a long double can be forced to be a 128-bit IEEE format floating-point
data type using the -mlong-double-128 command line option. On all platforms, Intel® C/C++
supports __float128 in the source code. On Windows*, Intel® C/C++ supports the _Quad type in
the source code by using the command line option, /Qoption,cpp,--extended_float_types.
LOGICAL and CHARACTER need special treatment for interoperability. The Fortran standard states that
LOGICAL corresponds to the (ISO_C_BINDING) C _Bool type, and defines a single kind value of C_BOOL,
which is 1 in Intel® Fortran. By default, Intel® Fortran, tests LOGICALs for true/false differently than C does.
Where C uses zero for false and not-zero for true, Intel® Fortran defaults to using -1 (all bits set) as true and
zero as false. If you are going to use LOGICAL types to interoperate with C, specify the option
fpscomp[:]logicals to change the interpretation to be C-like. This is included when using the option
standard-semantics, which is recommended for using Fortran 2003 (or later) features. C does not have
character strings. It has arrays of single characters, and this is how strings in Fortran must be represented.
There is a kind value defined as C_CHAR, which corresponds to the C char type. Only character variables
with a length of one are interoperable. See Procedures for more information.
Derived types can also be interoperable. For additional information and restrictions, see Derived Types.
661
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Procedures
Derived Types
Scalar Types
The commonly used types are included in the following table. The following applies:
• Integer types in Fortran are always signed. In C, integer types may be specified as signed or unsigned,
but are signed by default.
• The values of C_LONG, C_SIZE_T, C_LONG_DOUBLE, and C_LONG_DOUBLE_COMPLEX are different on
different platforms.
While there are named constants for all possible C types, every type is not necessarily supported on every
processor. Lack of support is indicated by a negative value for the constant in the module.
For a character type to be interoperable, you must either omit the length type parameter or specify it using a
constant expression whose value is one.
662
Compiler Reference
Characters
The C language does not have character strings. Instead, it has arrays of single characters, so this is how
you must represent a character string in Fortran.
There is a kind value defined, C_CHAR, corresponding to the C char type. However, only character variables
with a length of one (1) are interoperable.
The following shows a Fortran program passing a string to a C routine and the C routine calling a Fortran
routine with a new string.
program demo_character_interop
use, intrinsic :: iso_c_binding
implicit none
interface
subroutine c_append (string) bind(C)
character(len=1), dimension(*), intent(in) :: string
end subroutine c_append
end interface
C Routine Example
C module (c_append.c):
#include <string.h>
extern void fort_print(char * string); /* Fortran routine */
void c_append (char * string) {
663
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
C Routine Example
char mystring[100];
strcpy(mystring, string);
strcat(mystring, " interoperates with C");
/* Call Fortran routine passing new string */
fort_print (mystring);
return;
}
Pointers
For interoperating with C pointers, the module ISO_C_BINDING contains the derived types C_PTR and
C_FUNPTR, which are interoperable with C object and function type pointers, respectively.
These types, as well as certain procedures in the module, provide the mechanism for passing dynamic arrays
between the two languages. Because its elements do not need to be contiguous in memory, a Fortran pointer
target or assumed-shape array cannot be passed to C. However, you can pass an allocated allocatable array
to C, and you can associate an array allocated in C with a Fortran pointer. Additionally, as shown in the
following, you can convert a pointer in C format to one in Fortran format.
program demo_c_f_pointer
use, intrinsic :: iso_c_binding
implicit none
interface
function make_array(n_elements) bind(C)
import ! Make iso_c_binding visible here
type(C_PTR) :: make_array
integer(C_INT), value, intent(IN) :: n_elements
end function make_array
end interface
type(C_PTR) :: cptr_to_array
integer(C_INT), pointer :: array(:) => NULL()
integer, parameter :: n_elements = 3 ! Number of elements
C Module Example
#include <stdlib.h>
int *make_array(int n_elements) {
int *parray;
int i;
parray = (int*) malloc(n_elements * sizeof(int));
for (i = 0; i < n_elements; i++) {
parray[i] = i+1;
664
Compiler Reference
C Module Example
}
return parray;
}
Derived Types
For a derived type to be interoperable with C, you must specify the BIND attribute, as shown in the following:
Additionally, as shown in the examples that follow, each component must have an interoperable type and
interoperable type parameters, must not be a pointer, and must not be allocatable. This allows Fortran and C
types to correspond.
typedef struct {
int m, n;
float r;
} MyCtype
The following restrictions apply to a derived type specified with the BIND attribute:
• It cannot have the SEQUENCE attribute
• It cannot be an extended type
• It cannot have type-bound procedures
Variables
A scalar Fortran variable is interoperable if its type and type parameters are interoperable and it is not a
pointer.
An array Fortran variable is interoperable if its type and type parameters are interoperable and it has an
explicit shape or assumed size. It interoperates with a C array of the same type, type parameters, and
shape, but with subscripts reversed.
For example, a Fortran array declared as integer :: a(18, 3:7, *) is interoperable with a C array
declared as int b[][5][18].
Scalar variables are interoperable only if their type parameters (kind and length) are interoperable (see
above), they are not a coarray, do not have the POINTER or ALLOCATABLE attribute, and if character length
is not assumed nor defined by a non-constant expression.
Arrays are interoperable if the base type meets the scalar variable requirements above, if they are explicit
shape or assumed-size, and are not zero-sized. Furthermore, assumed-size arrays are interoperable only
with C arrays that have no size specified. An allocatable array, coarray, or array pointer is not interoperable.
665
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Global Data
The topics in this section contain information on global data and common blocks.
Interoperability Example
module LINK_TO_C_VARS
use, intrinsic :: ISO_C_BINDING
integer(C_INT), BIND(C) :: c_extern
integer(C_LONG) :: c2
BIND(C, name=’myVariable’) :: c2
common /com/ r,s
real(C_FLOAT) :: r,s,t
BIND(C) :: /com/, /single/
common /single/ t
end module LINK_TO_C_VARS
int c_extern;
long myVariable;
struct {float r, s;} com;
float single;
MODULE Examp
integer, BIND(C)::idata(20)
real::rdata(10)
END MODULE
In Fortran, a variable can access a global parameter by using the standard BIND C attribute.
In the above, two external variables are created (the latter with proper case and decoration): idata and
foo_mp_rdata.
Use the BIND attribute to resolve name discrepancies with C.
Fortran can declare the variable global (COMMON) and other languages can reference it as
external
Use of BIND(C) above means that the name will be appropriately decorated for the target and made
lowercase.
666
Compiler Reference
Note that the global name C references is the name of the Fortran common block (pi), not the name of a
variable within a common block (pi_r). Therefore, you cannot use blank common (unnamed) to make data
accessible between C and Fortran.
See Also
BIND C Statement and Attribute: Specifies that an object is interoperable with C and has
external linkage.
COMMON
To reference C structures from Fortran common blocks and vice versa, you must take into account how
common blocks and structures differ in their methods of storing member variables in memory. Fortran places
common block variables into memory in order as close together as possible, with the following rules:
• A single BYTE, INTEGER(1), LOGICAL(1), or CHARACTER variable in common block list begins immediately
following the previous variable or array in memory.
• All other types of single variables begin at the next even address immediately following the previous
variable or array in memory.
• All arrays of variables begin on the next even address immediately following the previous variable or array
in memory, except for CHARACTER arrays which always follow immediately after the previous variable or
array.
• All common blocks begin on a four-byte aligned address.
Because of these rules, you must consider the alignment of C structure elements with Fortran common block
elements. Specifically, you should ensure interoperability either by making all variables exactly equivalent
types and kinds in both languages (using only 4-byte and 8-byte data types in both languages simplifies this)
or by using the C pack pragmas in the C code around the C structure. This makes C data packing compatible
with Fortran data packing.
As an example, suppose your Fortran code has a common block named Really, as shown:
USE, INTRINSIC::ISO_C_BINDING
REAL (C_float)::x,y,z(6)
REAL (C_double)::ydbl
COMMON, BIND(C) / Really /x, y, z(6), ydbl
You can access this data structure from your C code with the following external data structures.
C Code Example
#pragma pack(2)
extern struct {
float x, y, z[6];
double ydbl;
} Really;
#pragma pack()
To restore the original packing, you must add #pragma pack() at the end of the C structure.
You can also access C structures from Fortran by creating common blocks that correspond to those
structures. This is the reverse case from that shown above. However, the implementation is the same; after
common blocks and structures have been defined and given a common address (name), and, assuming the
alignment in memory has been accounted for, both languages share the same memory locations for the
variables.
667
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Once you have accounted for alignment and padding, you can give C access to an entire common block or
set of common blocks. Alternatively, you can pass individual members of a Fortran common block in an
argument list, just as you can any other data item.
Procedures
For a Fortran procedure to be interoperable with C, it must have an explicit interface and be declared with
the BIND attribute, as shown in the following:
All dummy arguments must be interoperable. Furthermore, you must ensure that either the Fortran routine
uses the VALUE attribute for scalar dummy arguments, or that the C routine receives these scalar arguments
as pointers to the scalar values. Consider the following call to this C function:
As shown here, the interface for the Fortran call to c_func must have x passed with the VALUE attribute. y
should not have the VALUE attribute, since it is received as a pointer:
interface
integer (C_INT) function C_Func(x, y) BIND(C)
use, intrinsic :: ISO_C_BINDING
implicit none
integer (C_INT), value :: x
integer (C_INT) :: y
end function C_Func
end interface
Platform Specifics
The topics in this section contain information on platform specific issues that can come up when using mixed-
language programming.
668
Compiler Reference
NOTE
It is possible to override some default Fortran behavior by using BIND(C) specifier. This is the
preferred method. You can also override default Fortran behavior by using ATTRIBUTES and ALIAS.
669
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Microsoft Visual Studio* projects support a single language; therefore, code for each language must exist in
its own project.
This topic summarizes mixed language compatibility with Intel® Visual Fortran for both managed code and
unmanaged code. Managed code is architecture-independent code that runs under the control of the
Microsoft* .NET Common Language Runtime Environment; unmanaged code is native, architecture-specific
code.
Mixed-language applications can supply programs in a variety of formats:
Format Created by Callable by:
Compiled objects (.OBJ) and Intel® Visual Fortran, Intel® C++, Intel® Visual Fortran, Intel® C++,
static libraries (.LIB) Microsoft Visual C++* Microsoft Visual C++*
(unmanaged) (unmanaged)
NOTE
Objects and libraries must be link-
compatible and not have conflicting
names in their language support
libraries
Dynamic Link Library (.DLL) Intel® Visual Fortran, Intel® C++, Intel® Visual Fortran, Intel® C++,
Microsoft Visual C++* Microsoft Visual C++* (both
(unmanaged), Microsoft Visual managed and unmanaged),
Basic* (unmanaged), many more Microsoft Visual Basic* (managed
and unmanaged), many others
.NET managed code assembly Microsoft Visual C++ .NET, Intel® Visual Fortran (with
Microsoft Visual Basic .NET, interface generated by Fortran
other .NET languages Module Wizard), .NET languages
670
Compiler Reference
Both options cause the routine compiled and routines that it calls to have a @<n> appended to the external
symbol name, where n is the number of bytes of all parameters. Both options assume that any routine called
from a Fortran routine compiled this way will do its own stack cleanup, "callee pops." /iface:cvf also
changes the way that CHARACTER variables are passed. With /iface:cvf, CHARACTER variables are passed
as address/length pairs (that is, /iface:mixed_str_len_arg).
See Also
Handling Fortran Array Pointers and Allocatable Arrays
NOTE
For 32-bit applications, use of the STDCALL calling convention means that the called procedure
controls the stack. The code to restore the stack resides in the called procedure, so the code needs to
appear only once. For 64-bit applications, the stack adjustment and @n name suffix features of
STDCALL are not used.
The C calling convention makes calling with a variable number of arguments possible. In the C calling
convention, the caller cleans up the stack, so it is possible to write a routine with a variable number of
arguments. Therefore, the return point has the same address relative to the frame pointer, regardless of how
many arguments are actually passed. The calling routine controls the stack, knows how many arguments it
passed, how big they are, and where they reside in the stack. It can skip passing an argument and still keep
track.
You can call routines with a variable number of arguments by including the ATTRIBUTES C option in your
interface to a routine.
Naming Conventions
Naming conventions are as follows:
• A leading (prefix) underscore for Windows* operating systems based on IA-32 architecture; no
underscores for Windows* operating systems based on other architectures.
• A trailing (postfix) underscore for all Linux* operating systems
• Leading and trailing underscores for all macOS* operating systems
671
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
To call functions written in Fortran, declare the function as you would in C and use a "C" linkage specification.
For example, to call the Fortran function FACT from C++, declare it as follows:
extern "C" { int fact( int* n ); }
The extern "C" syntax can be used to adjust a call from C++ to other languages, or to change the naming
convention of C++ routines called from other languages. However, extern "C" can only be used from within C
++. If the C++ code does not use extern "C" and cannot be changed, you can call C++ routines only by
determining the name decoration and generating it from the other language. Such an approach should only
be used as a last resort, because the decoration scheme is not guaranteed to remain the same between
versions.
When using extern "C" in a C++ program, keep in mind the following restrictions:
• You cannot declare a member function with extern "C".
• You can specify extern "C" for only one instance of an overloaded function; all other instances of an
overloaded function have C++ linkage.
// for C use:
icx -c cmain.c
// for C++ use:
icpx -c cmain.c
ifort -nofor_main cmain.o fsub.f90
For more information about compiling and linking Intel® Fortran and C++ programs on Windows* operating
systems, and the libraries used, see Specifying Consistent Library Types.
672
Compiler Reference
icl /c cmain.c
ifort cmain.obj forsubs.f90
Intel® Visual Fortran accepts an object file for the main program written in C and compiled by a C compiler.
The compiler compiles the .F90 file and then has the linker create an executable file under the name
CMAIN.EXE using the two object files.
Either compiler (C or Intel® Visual Fortran) can do the linking, regardless of which language the main
program is written in. However, if you use the Intel® Visual Fortran compiler first, you must include
LIBIFCORE.LIB and IFCONSOL.LIB with the C compiler. You may experience some difficulty with the version
of the runtime library used by the C compiler. You may prefer to use the C compiler first or specify your
project settings for both Intel® Visual Fortran and C so there is agreement on the C library to link against.
Ensure that your application links against only one copy of the C library.
If you are using the IDE to build your application, Intel® Visual Fortran uses Fortran and C libraries depending
on the information specified in the Fortran folder in Project > Properties (Project Settings dialog box).
You can also specify linker settings with the Linker folder in the Project Settings dialog box.
In the Fortran folder, within the Libraries property page, the RunTime Library category determines the
libraries selected.
For example, select Debug Multi-threaded DLL in the runtime Library list to specify that DLL (/libs:DLL),
multi-threaded (/threads), and debug (/dbglibs) libraries should be linked against, namely Fortran import
library libifcoremdd.lib and its DLL library libifcoremdd.dll and C/C++ import library msvcrtd.lib
and its DLL library msvcrtd.dll.
A mixed language solution containing a Fortran library project should have Disable Default Library Search
Rules set to No in the IDE. To check this setting, choose Project > Properties and then choose the
Libraries category. If you change the Disable Default Library Search Rules setting to Yes, you will need to
explicitly add the needed runtime libraries to the non-Fortran project. If you are adding libraries explicitly,
make sure you add IFCONSOL.LIB to the libraries of the non-Fortran project. This library is needed to
perform almost any kind of I/O with Intel® Visual Fortran.
When you have a C++ main program and a Fortran library subproject, you need to manually add the library
path to the Intel® Visual Fortran LIB folder. You only need to do this manual add once per user. To add the
path, choose Tools > Options > Projects and Solutions > VC++ Directories. Use the Show
directories for: dropdown item to select Library files. Add the path to the displayed list.
673
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The way Microsoft* Visual C++* chooses libraries is also based upon the Project > Properties item, but
within the C/C++ tab. In the Code Generation category, the runtime library item lists the following C
libraries:
Menu Item Selected CL Option or Project Type Default Library Specified in Object
Enabled File
You must take care to choose the same type of runtime libraries in both your Fortran and C project. For
example, if you select Multithreaded DLL in your Fortran project, you must select Multithreaded DLL in your C
project. Otherwise, when your build your mixed Fortran/C application, you will receive errors from the Linker
regarding undefined and/or duplicate symbols.
If you are using Microsoft* Visual C++* or Intel® C++, the Microsoft Integrated Development Environment
can build mixed Fortran/C applications transparently, with no special directives or steps on your part. You can
edit and browse your C and Fortran programs with appropriate syntax coloring for the language. You need to
place your Fortran source files into a Fortran project and your C/C++ files into a Visual C++* project.
When you debug a mixed Visual C++*/Fortran application, the debugger will adjust to the code type as it
steps through: the C or Fortran expression evaluator will be selected automatically based on the code being
debugged, and the stack window will show Fortran data types for Fortran procedures and C data types for C
procedures.
Implementation Specifics
The topics in this section contain information on implementation specific issues.
674
Compiler Reference
This results in the following symbols being defined in the compiled object file on Linux* operating systems.
(On macOS* operating systems, the symbols would begin with an underscore.)
mymod_mp_a_
mymod_mp_b_
The following symbols are defined in the compiled object file on Windows* operating systems based on IA-32
architecture:
_MYMOD_mp_A
_MYMOD_mp_B
On Windows* operating systems based on Intel® 64 architecture, there is no beginning underscore.
675
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
You can associate a Fortran array pointer with any piece of memory, organized in any way desired (as long as
it is "rectangular" in terms of array bounds). You can also pass Fortran array pointers to the C language, and
have it correctly interpret the descriptor to obtain the information it needs.
The downside to using array descriptors is that it can increase the opportunity for errors. Additionally, the
corresponding code is not portable. Specifically:
• If the descriptor is not defined correctly, the program may access the wrong memory address, possibly
causing a General Protection Fault.
• Array descriptor formats are specific to each Fortran compiler. Code that uses array descriptors is not
portable to other compilers or platforms.
• The array descriptor format may change in the future.
• If the descriptor was built by the compiler, it cannot be modified by the user. Changing fields of existing
descriptors is illegal.
The components of the current Intel® Fortran array descriptor on systems using IA-32 architecture are as
follows:
• Bytes 0 to 3 contain the base address.
• Bytes 4 to 7 contain the size of a single element of the array.
• Bytes 8 to 11 are reserved and should not be explicitly set.
• Bytes 12 to 15 contain a set of flags used to store information about the array. This includes:
• bit 1 (0x01): array is defined -- set if the array has been defined (storage allocated).
• bit 2 (0x02): no deallocation allowed -- set if the array pointed to cannot be deallocated (that is, it is
an explicit array target).
• bit 3 (0x04): array is contiguous -- set if the array pointed to is a contiguous whole array or slice.
• bit 8 (0x80): set if the array pointed to is ALLOCATABLE.
• Other bits are reserved.
• Bytes 16 to 19 contain the number of dimensions (rank) of the array.
• Bytes 20 to 23 are reserved and should not be explicitly set.
• The remaining bytes contain information about each dimension (up to 31). Each dimension is described by
a set of three 4-byte entities:
• The number of elements (extent).
• The distance between the starting address of two successive elements in this dimension, in bytes.
• The lower bound.
An array of rank one requires three additional 4-byte entities for a total of nine 4-byte entities (6 + 3*1) and
ends at byte 35. An array of rank seven is described in a total of twenty-seven 4-byte entities (6 + 3*7) and
ends at byte 107.
integer,target :: a(10,10)
integer,pointer :: p(:,:)
p => a(9:1:-2,1:9:3)
call f(p)
...
The descriptor for actual argument p would contain the following values:
• Bytes 0 to 3 contain the base address (assigned at run-time).
• Bytes 4 to 7 are set to 4 (size of a single element).
• Bytes 8 to 11 are reserved.
• Bytes 12 to 15 contain 3 (array is defined and deallocation is not allowed).
• Bytes 16 to 19 contain 2 (rank).
• Bytes 20 to 23 are reserved.
• Bytes 24 to 35 contain information for the first dimension, as follows:
• 5 (extent).
• -8 (distance between elements).
• 9 (the lower bound).
• For the second dimension, bytes 36 to 47 contain:
676
Compiler Reference
• 3 (extent).
• 120 (distance between elements).
• 1 (the lower bound).
• Byte 47 is the last byte for this example.
NOTE
The format for the descriptor on systems using Intel® 64 architecture is identical to that on systems
using IA-32 architecture, except that all fields are 8-bytes long, instead of 4-bytes.
program FCallsCReturnsCptr
interface
type(C_PTR)function my_croutine1 ( input) bind(c)
import
integer(c_int), value :: input
end function my_croutine1
call my_cprint(my_croutine1(42))
end program
677
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
#include <stdio.h>
The example above shows the C code used to call a Fortran routine. The Fortran routine returns a string that
is then printed by the C program. As shown in the example, it is relatively straightforward to pass a string
back to C from Fortran. Additionally, the string can be easily used by the C program because it is NULL-
terminated.
In the above example, the following restrictions and behaviors apply:
• The function's length and result do not appear in the call statement; they are added by the compiler.
• The called routine must copy the result string into the location specified by result; it must not copy
more than length characters.
• If fewer than length characters are returned, the return location should be padded on the right with
blanks; Fortran does not use zeros to terminate strings.
• The called procedure is type void.
C Code Example
#include <stdio.h>
char *GetFortranWords(void);
int main() {
678
Compiler Reference
GetFortranWords = C_LOC(returnval)
return
end
Legacy Extensions
The topics in this section contain information on legacy extension issues.
679
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Derived Value, size Value, size Value, size Value, size Value, size
Type dependent dependent dependent dependent dependent
[value]
Naming Conventions
Case Upper Case Lower Case Lower Case Lower Case Lower Case
(Windows*)
680
Compiler Reference
Lower Case
(Linux*, macOS*)
Value The argument value is pushed on the stack. All values are padded to the next 4-byte
boundary.
Reference On systems using IA-32 architecture, the 4-byte argument address is pushed on the
stack.
On systems using Intel® 64 architecture, the 8-byte argument address is pushed on the
stack.
No Len For string arguments, the length of the string is not available to the called procedure.
Descriptor On systems using IA-32 architecture, the 4-byte address of the array descriptor.
On systems using Intel® 64 architecture, the 8-byte address of the array descriptor.
@n On systems using IA-32 architecture, the at sign (@) followed by the number of bytes (in
decimal) required for the argument list.
Size On systems using IA-32 architecture, derived-type arguments specified by value are
dependent passed as follows:
681
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Callee The procedure being called is responsible for removing arguments from the stack before
returning to the caller.
Caller The procedure doing the call is responsible for removing arguments from the stack after
the call is over.
You can use the BIND(C, name=<string>) attribute to resolve discrepancies with C. Alternatively, the ALIAS
option can be used with any other Fortran calling-convention option to preserve mixed-case names. +
For Windows* operating systems, the compiler option /iface also establishes some default argument
passing conventions. The /iface compiler option has the following choices:
Option How are Append @n to names on systems using IA-32 Who Vararg
arguments architecture? cleans s
passed? up suppor
stack? t?
NOTE
The following applies to Windows*: When interfacing to the Windows* graphical user interface or
making API calls, you will typically use STDCALL.
682
Error Handling
This example uses DECORATE to automatically reconcile external name declaration for the target platform.
Using the DECORATE option in combination with the ALIAS option specifies that the external name specified
in ALIAS should have the correct prefix and postfix decorations for the calling mechanism in effect.
Compiler Options
The topics in this section contain information on compiler options.
See Also
nofor-main compiler option
Error Handling
This section contains information about understanding and handling compile-time and run-time errors.
Diagnostic Meaning
filename Indicates the name of the source file currently being processed.
linenum Indicates the source line where the compiler detects the condition.
severity Indicates the severity of the diagnostic message: Warning, Error, or Fatal error.
683
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
You can perform compile-time procedure interface checking between routines with no explicit
interfaces present. To do this, generate a module containing the interface for each compiled routine
using the gen-interfaces option and check implicit interfaces using the warn[:]interfaces
compiler option.
684
Compiler Reference
The list items can be one of the keywords warn, remark, or error, a keyword specifying a certain group
(par, vec, driver, cpu-dispatch), or specific diagnostic IDs separated by commas. For more information,
see diag, Qdiag.
Additionally, you can use the following related options:
Comment messages do not terminate translation or linking, they do not interfere with any output files either.
Some examples of the comment messages are:
685
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Error Messages
These messages report syntactic or semantic misuse of Fortran. Errors suppress object code for the file
containing the error and prevent linking, but they do not stop the compiler from scanning for any other
errors. Some typical examples of error messages are:
686
Compiler Reference
• If a compiler option is not available through Project > Properties in the Intel® Fortran Property pages,
you can type the option in the Command Line category. Use the lower part of the window under
Additional Options, just as you would using the command line. For example, you can enter the linker
option /link /DEFAULTLIB to specify an additional library.
NOTE
If you have a question about a compile-time error, submit your question to the Intel® Fortran forum,
which can be found at https://community.intel.com/t5/Software-Products/ct-p/software-products.
See Also
Specifying Path Library and Include Directories
Supported Environment Variables
warn compiler option
diag, Qdiag compiler option
For instance, the following C shell command sets the FOR_DUMP_CORE_FILE environment variable:
setenv FOR_DUMP_CORE_FILE y
The core file is written to the current directory and can be examined using a debugger.
687
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
If you requested a core file to be created on severe errors and you do not get one when expected, the
problem might be that your process limit for the allowable size of a core file is set too low (or to zero).
See the man page for your shell for information on setting process limits. For example, the C shell
command limit (with no arguments) will report your current settings, and limit coredumpsize
unlimited will raise the allowable limit to your current system maximum.
See Also
Supported Environment Variables
Run-Time Default Error Processing
Run-Time Message Display and Format
Values Returned at Program Termination
Methods of Handling Errors
Using the END, EOR, and ERR Branch Specifiers
Using the IOSTAT Specifier and Fortran Exit Codes
Locating Run-Time Errors
List of Run-Time Error Messages
Generating Listing and Map Files
Signal Handling
Overriding the Default Run-Time Library Exception Handler
Traceback and related topics
See Also
Run-Time Message Display and Format
Values Returned at Program Termination
Locating Run-Time Errors
Traceback
Data Representation
See Also
Advanced Exception and Termination Handling Considerations
Setting Compiler Options in the Visual Studio* IDE Property Pages
688
Compiler Reference
Fortran Console applications Run-time error messages are displayed on the standard
error device (unless redirected).
Fortran QuickWin and Fortran Standard Run-time error messages are displayed in a separate
Graphics applications QuickWin message box.
Severit Description
y
severe Must be corrected. The program's execution is terminated when the error is encountered unless
the program's I/O statements use the END, EOR, or ERR branch specifiers to transfer control,
perhaps to a routine that uses the IOSTAT specifier. (See Using the END EOR and ERR Branch
Specifiers and Using the IOSTAT Specifier and Fortran Exit Codes and Methods of Handling
Errors.)
For severe errors, stack trace information is produced by default, unless environment variable
FOR_DISABLE_STACK_TRACE is set. When that environment variable is set, no stack trace
information is produced.
If compiler option traceback is specified on the command line, the stack trace information
contains program counters set to symbolic information. Otherwise, the information only
contains hexadecimal program counter information.
In some cases stack trace information is also produced by the compiled code at run-time to
provide details about the creation of array temporaries.
error Should be corrected. The program might continue execution, but the output from this execution
might be incorrect.
For errors of severity type error, stack trace information is produced by default, unless the
environment variable FOR_DISABLE_STACK_TRACE is set. When that environment variable is
set, no stack trace information is produced.
If the command line option traceback is specified, the stack trace information contains
program counters set to symbolic information. Otherwise, the information only contains
hexadecimal program counter information.
689
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Severit Description
y
In some cases stack trace information is also produced by the compiled code at run-time to
provide details about the creation of array temporaries.
warning Should be investigated. The program continues execution, but output from this execution might
be incorrect.
For a description of each Intel® Fortran run-time error message, see Run-Time Default Error Processing and
related topics.
The following example applies to Linux* and to macOS*:
In some cases, stack trace information is produced by the compiled code at run time to provide details about
the creation of array temporaries.
The following program generates an error at line 12:
program ovf
real*4 x(5),y(5)
integer*4 i
x(1) = -1e32
x(2) = 1e38
x(3) = 1e38
x(4) = 1e38
x(5) = -36.0
do i=1,5
y(i) = 100.0*(x(i))
print *, 'x = ', x(i), ' x*100.0 = ',y(i)
end do
end
The following command line produces stack trace information for the program executable.
x = -1.0000000E+32 x*100.0
= -1.0000000E+34
forrtl: error (72): floating overflow
Image PC Routine Line Source
ovf.exe 08049E4A MAIN__ 14 ovf.f90
ovf.exe 08049F08 Unknown Unknown Unknown
ovf.exe 400B3507 Unknown Unknown Unknown
ovf.exe 08049C51 Unknown Unknown Unknown
Abort
The following suppresses stack trace information because the FOR_DISABLE_STACK_TRACE environment
variable is set.
690
Compiler Reference
Windows* ifcore_msg.dll
ifcore_msg.mc
Windows* irc_msg.dll
irc_msg.mc
Windows* libmUI.dll
libmUI.mc
See Also
Understanding Project Types
Using the IOSTAT Specifier and Fortran Exit Codes
Using the END EOR and ERR Branch Specifiers
Methods of Handling Errors
Run-Time Default Error Processing
See Also
Understanding Run-Time Errors
691
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Using the IOSTAT Specifier and Fortran Exit Codes
Using the END EOR and ERR Branch Specifiers
692
Compiler Reference
USE foriosdef
IMPLICIT NONE
CHARACTER(LEN=40) :: FILNM
INTEGER IERR
PRINT *, 'Type file name:'
READ (*,*) FILNM
OPEN (UNIT=1, FILE=FILNM, STATUS='OLD', IOSTAT=IERR, ERR=100)
PRINT *, 'Opening file: ', FILNM
! process the input file
...
CLOSE (UNIT=1)
STOP
100 IF(IERR . EQ. FOR$IOS_FILNOTFOU) THEN
PRINT *, 'File: ', FILNM, ' does not exist '
ELSE
PRINT *, 'Unrecoverable error, code =', IERR
END IF
END PROGRAM
Another way to obtain information about an error is the ERRSNS subroutine, which allows you to obtain the
last I/O system error code associated with an Intel® Fortran RTL error (see the Intel® Fortran Language
Reference).
693
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
List of Run-Time Error Messages
IS_IOSTAT_END intrinsic function
IS_IOSTAT_EOR intrinsic function
Output 2:
694
Compiler Reference
See Also
Understanding Run-Time Errors
Traceback
NOTE
To see the full list of run-time errors, see file ifcore_msg.msg, which is located in the libraries part of
your kit.
695
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
For each error shown in the below table of example messages, you will see the error number, the severity
code, error message text, and condition symbol name. Some messages also provide more details about the
error.
To define the condition symbol values (PARAMETER statements) in your program, include the following file:
for_iosdef.for
As described in the table, the severity of the message determines which of the following occurs:
• with info and warning, program execution continues
• with error, the results may be incorrect
• with severe, program execution stops (unless a recovery method is specified)
In the last case, to prevent program termination, you must include either an appropriate I/O error-handling
specifier and recompile or, for certain errors, change the default action of a signal before you run the
program again.
In the following table of example messages, the first column lists error numbers returned to IOSTAT variables
when an I/O error is detected.
The first line of the second column provides the message as it is displayed (following forrtl:), including the
severity level, message number, and the message text. The following lines of the second column contain the
status condition symbol (such as FOR$IOS_INCRECTYP) and sometimes an explanation of the message.
In these messages, words in quotes represent variables. For example, "number" indicates a numeric variable,
and "string" indicates a character string variable.
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
5 warning (5): requested disposition modified, file not deleted, unit "number", file
"string"
FOR$IOS_REQDISMOD.
696
Compiler Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
14 info (14): SOURCE length "number" does not equal variable length "number"
FOR$IOS_SOURCELENERR.
697
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
698
Compiler Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
• The file was not a sequential organization file with variable-length records.
• The file was not opened for sequential, append, or direct access.
• An unformatted file did not contain segmented records.
• The Intel® Fortran RTL I/O system detected an error during execution of an ENDFILE
statement.
NOTE
This error can be returned by STAT in an ALLOCATE or a DEALLOCATE statement.
699
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
50 severe (50): inconsistent key change or duplicate key, unit "number", file "string"
FOR$IOS_INCKEYCHG.
700
Compiler Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
NOTE
Note: The ERR transfer is taken after completion of the I/O statement for error number
59. The resulting file status and record position are the same as if no error had occurred.
However, other I/O errors take the ERR transfer as soon as the error is detected, so file
status and record position are undefined.
NOTE
Note: The severity depends on the check[:]keywords option used during the
compilation command. The ERR transfer is taken after completion of the I/O statement
for error numbers 61, 63, 64, and 68. The resulting file status and record position are the
same as if no error had occurred. However, other I/O errors take the ERR transfer as soon
as the error is detected, so file status and record position are undefined.
701
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
NOTE
Note: The severity depends on the check[:]keywords option used during the
compilation command. The ERR transfer is taken after completion of the I/O statement
for error numbers 61, 63, 64, and 68. The resulting file status and record position are the
same as if no error had occurred. However, other I/O errors take the ERR transfer as soon
as the error is detected, so file status and record position are undefined.
NOTE
The ERR transfer is taken after completion of the I/O statement for error numbers 61, 63,
64, and 68. The resulting file status and record position are the same as if no error had
occurred. However, other I/O errors take the ERR transfer as soon as the error is
detected, so file status and record position are undefined.
702
Compiler Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
NOTE
The ERR transfer is taken after completion of the I/O statement for error numbers 61, 63,
64, and 68. The resulting file status and record position are the same as if no error had
occurred. However, other I/O errors take the ERR transfer as soon as the error is
detected, so file status and record position are undefined.
703
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
851 info (85): output conversion overflows field, unit "number", file "string"
FOR$IOS_OUTCONOVE.
901 info (90): INQUIRE of internal unit-number is always an error (NOTE: unit identifies a
file)
FOR$IOS_IOSTAT_INTERNAL. The file name specified for an INQUIRE statement is an internal
unit-number.
911 info (91): INQUIRE of internal unit-number is always an error (NOTE: unit does not
identify a file)
FOR$IOS_IOSTAT_INTERNAL_UNIT. The unit number specified for an INQUIRE statement is an
internal unit-number.
94 severe (94): invalid key match specifier for key direction, unit "number", file "string"
FOR$IOS_INVMATKEY .
704
Compiler Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
• Exceeded the allowable maximum value for the equivalent native format and was set equal
to infinity (plus or minus).
• Was infinity (plus or minus) and was set to infinity (plus or minus).
• Was invalid and was set to not a number (NaN).
Very small numbers are set to zero (0). This error could be caused by the specified nonnative
floating-point format not matching the floating-point format found in the specified file. Check
the following:
• The correct file was specified.
• The record layout matches the format Intel® Fortran is expecting.
• The ranges for the data being used (see Data Representation).
• The correct nonnative floating-point data format was specified (see Supported Native and
Nonnative Numeric Formats).
97 severe (97): write exceeds the record length of the file, unit "number", file "string"
FOR$IOS_WRIEXCEEDRECL.
98 severe (98): cannot allocate memory for the file buffer - out of memory
FOR_S_NOMEMFORIO. This error often occurs during a file I-O operation such as OPEN, READ,
or WRITE. Either increase the amount of memory available to the program, or reduce its
demand.
101 severe (101): Asynchronous data transfer statement is not allowed to this unit, unit
"number", file "string"
FOR$IOS_AIONOTALLOWED.
102 severe (102): ID value is out of range, unit "number", file "string"
FOR$IOS_IDVALOUT.
103 severe (103): incorrect "string" specifier for connected file, unit "number", file
"string"
FOR$IOS_BADSPEC.
104 severe (104): incorrect "XXXXX=" specifier value for connected file
FOR$IOS_BADSPECVAL. The listed specifier value is invalid for the connected file. Possible
specifier values are one of the following:
• ACTION=
• ASSOCIATEVARIABLE=
• ASYNCHRONOUS=
• BUFFERED=
• DISPOSE=
• FORM=
705
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
• IOFOCUS=
• MAXREC=
• MODE=
• ORGANIZATION=
• POSITION=
• RECL=
• RECORDTYPE=
• SHARE=
• STATUS=
• TITLE=
105 severe (105): there is no data-edit-descriptor to match a data-item in the I/O list,
unit "number", file "string"
FOR$IOS_NODATAEDIT.
109 info (109): stream data transfer statement is not allowed to an unopened unit
FOR$IOS_SIONOTOPEN. Stream data transfer statement is not allowed to an unopened unit.
110 severe (110): stream data transfer statement is not allowed to this unit, unit
"number", file "string"
FOR$IOS_SIONOTALLOWED.
111 severe (111): position number is outside of the valid range, unit "number", file
"string"
FOR$IOS_POSNUMOUT.
112 severe (112): RECL= specifier may not be applied to stream access file, unit
"number", file "string"
FOR$IOS_STREAMRECL.
113 severe (113): BACKSPACE statement may not be applied to unformatted stream
access file, unit "number", file "string"
FOR$IOS_STREAMBCKSPC.
114 severe (114): A keyword was specified that is not allowed with unformatted I/O; unit
"number", file "string"
FOR$IOS_KWANDUNFMT.
115 severe (115): keyword value error in a CLOSE statement, unit "number", file "string"
FOR$IOS_KEYVALERRCLOSE.
116 severe (116): keyword value error in an I/O statement, unit "number", file "string"
706
Compiler Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
FOR$IOS_KEYVALERRIO.
117 severe (117): If NEWUNIT appears in OPEN statement either FILE or STATUS (with
value SCRATCH) specifier shall appear
FOR$IOS_FILE_OR_SCRATCH.
118 severe (118): The 'RECL=' value in an OPEN statement exceeds the maximum allowed
for the file's record type.
FOR$IOS_MAX_FXD_RECL. The 'RECL=' value in an OPEN statement is too large for the file’s
record type.
122 severe (122): invalid attempt to assign into a pointer that is not associated
FOR$IOS_UNASSOCPTR. Invalid attempt to assign into a pointer that is not associated.
NOTE
This error can be returned by CMDSTAT in an EXECUTE_COMMAND_LINE statement.
125 severe (125): A derived type variable in this statement requires a DT format specifier
because it has a component that is ALLOCATABLE, POINTER, or PRIVATE, unit
"number", file "string"
FOR$IOS_DT_REQUIRED.
127 severe (127): User Defined I/O procedure returned error <user-iostat, message:
'<user-iomsg>'
707
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
FOR$IOS_UDIO_CHILD_IOSTAT_IOMSG. A child I/O action has set the IOMSG and IOSTAT
shown in this message.
129 info (129): User Defined I/O procedure's IOMSG was truncated to fit IOMSG variable
FOR$IOS_UDIO_IOMSG_TRUNCATED. A child I/O action has set IOMSG and IOSTAT. The result
was too large to be held by the parent's IOMSG variable; non-blank text has been truncated.
1391 severe: (139): Array index out of bounds for index "number"
FOR$IOS_BRK_RANGE2. An array subscript is outside the dimensioned boundaries of that
array. Set the check[:]bounds option and recompile.
708
Compiler Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
FOR$IOS_INVREALLOC. An allocatable array must not already be allocated when you attempt
to allocate it. You must deallocate the array before it can again be allocated.
NOTE
This error can be returned by STAT in an ALLOCATE statement.
1521 severe (152): Unresolved contention for Intel Fortran RTL global resource
FOR$IOS_RESACQFAI. Failed to acquire an Intel® Fortran RTL global resource for a reentrant
routine. For a multithreaded program, the requested global resource is held by a different
thread in your program. For a program using asynchronous handlers, the requested global
resource is held by the calling part of the program (such as main program) and your
asynchronous handler attempted to acquire the same global resource.
NOTE
This error can be returned by STAT in an DEALLOCATE statement.
1551 severe (155): Array index out of bounds for index "number"
FOR$IOS_RANGE2. An array subscript is outside the dimensioned boundaries of that array. Set
the check[:]bounds option and recompile.
709
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
FOR$IOS_DTYPE_MISALIGN. The Intel® Fortran RTL has detected data that is not aligned on a
natural boundary for the data type specified. For example, a REAL(8) data item aligned on
natural boundaries has an address that is a multiple of 8. To ensure naturally aligned data, use
the align option.
This is an operating system error. See your operating system documentation for more
information.
710
Compiler Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
This is an operating system error. See your operating system documentation for more
information.
1731 severe (173): A pointer passed to DEALLOCATE points to an array that cannot be
deallocated
FOR$IOS_INVDEALLOC2. A pointer that was passed to DEALLOCATE pointed to an explicit
array, an array slice, or some other type of memory that could not be deallocated in a
DEALLOCATE statement. Only whole arrays previous allocated with an ALLOCATE statement
may be validly passed to DEALLOCATE.
NOTE
This error can be returned by STAT in a DEALLOCATE statement.
711
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
This message indicates that the program attempted an invalid memory reference. Check the
program for possible errors.
• evere (174): SIGSEGV, possible program stack overflow occurred
s
The following explanatory text also appears:
Program requirements exceed current stacksize resource limit.
1751 severe (175): DATE argument to DATE_AND_TIME is too short (LEN=n), required
LEN=8
FOR$IOS_SHORTDATEARG. The number of characters associated with the DATE argument to
the DATE_AND_TIME intrinsic was shorter than the required length. You must increase the
number of characters passed in for this argument to be at least eight characters in length.
Verify that the TIME and ZONE arguments also meet their minimum lengths.
1761 severe (176): TIME argument to DATE_AND_TIME is too short (LEN=n), required
LEN=10
FOR$IOS_SHORTTIMEARG. The number of characters associated with the TIME argument to the
DATE_AND_TIME intrinsic was shorter than the required length. You must increase the number
of characters passed in for this argument to be at least ten characters in length. Verify that the
DATE and ZONE arguments also meet their minimum lengths.
1771 severe (177): ZONE argument to DATE_AND_TIME is too short (LEN=n), required
LEN=5
FOR$IOS_SHORTZONEARG. The number of characters associated with the ZONE argument to
the DATE_AND_TIME intrinsic was shorter than the required length. You must increase the
number of characters passed in for this argument to be at least five characters in length. Verify
that the DATE and TIME arguments also meet their minimum lengths.
1791 severe (179): Cannot allocate array - overflow on array size calculation
FOR$IOS_ARRSIZEOVF. An attempt to dynamically allocate storage for an array failed because
the required storage size exceeds addressable memory.
NOTE
This error can be returned by STAT in an ALLOCATE statement.
183 warning (183): FASTMEM allocation is requested but the libmemkind library is not
linked in, so using the default allocator.
712
Compiler Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
184 severe (184): FASTMEM allocation is requested but the libmemkind library is not
linked into the executable.
FOR$IOS_NOLIBMEMKINDWARN. An allocation request for FASTMEM failed because the
libmemkind library is not linked into the executable.
NOTE
This error can be returned by STAT in an ALLOCATE statement.
185 warning (185): FASTMEM allocation is requested but HBW memory is not available, so
using the default allocator.
FOR$IOS_NOFASTMEMWARN. An allocation requested FASTMEM but HBW memory is not
available on the node, so memory will be allocated from the default memory allocator for that
platform.
186 severe (186): FASTMEM allocation is requested but HBW memory is not available on
this node.
FOR$IOS_NOLIBMEMKINDWARN. An allocation request for FASTMEM failed because HBW
memory is not available on this node.
NOTE
This error can be returned by STAT in an ALLOCATE statement.
188 severe (188): An assignment was made from an object of one size to an object of a
different size that cannot be deallocated.
FOR$ IOS_INCOMPATIBLE_SIZES. An assignment was made from an object of one size to an
object of a different size that cannot be deallocated.
NOTE
This error can be returned by STAT in an ALLOCATE statement.
189 severe (189): LHS and RHS of an assignment statement have incompatible types.
FOR$ IOS_INCOMPATIBLE_TYPES. The left-hand side (LHS) of an assignment statement is not
type compatible with the right-hand side (RHS) of the assignment statement.
NOTE
This error can be returned by STAT in an ALLOCATE statement.
NOTE
This error can be returned by STAT in an ALLOCATE statement.
713
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
193 severe (193): Run-Time Check Failure. The variable "string" is being used without
being defined
FOR$IOS_RTC_UNINIT_USE .
1941 severe (194): Run-Time Check Failure. The variable "string" is being used in "string"
without being defined.
FOR$IOS_RTC_UNINIT_USE_SRC. The named variable in the named source file is being used
without first being initialized.
201 severe (201): Intel Pentium fdiv flaw detected, please update the processor
FOR$IOS_FLAWEDPENT.
255 info (255): if a UDIO child sets IOMSG, it must set IOSTAT non-zero, unit "number",
file "string"
FOR$IOS_CHILDSTATMSG.
256 severe (256): Unformatted I/O to unit open for formatted transfers
FOR$IOS_UNFIO_FMT. Attempted unformatted I/O to a unit where the OPEN statement (FORM
specifier) indicated the file was formatted. Check that the correct unit (file) was specified. If the
FORM specifier was not present in the OPEN statement and the file contains unformatted data,
specify FORM='UNFORMATTED' in the OPEN statement. Otherwise, if appropriate, use formatted
I/O (such as list-directed or namelist I/O).
257 severe (257): Formatted I/O to unit open for unformatted transfers
FOR$IOS_FMTIO_UNF. Attempted formatted I/O (such as list-directed or namelist I/O) to a unit
where the OPEN statement indicated the file was unformatted (FORM specifier). Check that the
correct unit (file) was specified. If the FORM specifier was not present in the OPEN statement
and the file contains formatted data, specify FORM='FORMATTED' in the OPEN statement.
Otherwise, if appropriate, use unformatted I/O.
258 severe (258): direct-access I/O to unit open for keyed access, unit "number", file
"string"
FOR$IOS_DIRIO_KEY.
259 severe (259): Sequential-access I/O to unit open for direct access
FOR$IOS_SEQIO_DIR. The OPEN statement for this unit number specified direct access and the
I/O statement specifies sequential access. Check the OPEN statement and make sure the I/O
statement uses the correct unit number and type of access.
260 severe (260): keyed-access I/O to unit open for direct access, unit "number", file
"string"
FOR$IOS_KEYIO_DIR.
714
Compiler Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
265 severe (265): operation requires sequential file organization and access
FOR$IOS_OPEREQSEQ. Attempted to use a BACKSPACE statement on a file whose organization
was not sequential or whose access was not sequential. A BACKSPACE statement can only be
used for sequential files opened for sequential access.
269 severe (269): Another process has this file locked for shared/exclusive use, unit
"number", file "string"
FOR$IOS_SHAREDCONFLICT.
270 severe (270): A SHARE= lock request in an OPEN statement is incompatible with a
[NO]SHARED specifier and/or the file's open mode, unit "number", file "string"
FOR$IOS_INVALIDLOCKREQUEST.
271 severe (271): a UDIO child routine may not use POS= or REC=, unit "number", file
"string"
FOR$IOS_CHILDNOPOS.
272 severe (272): a UDIO child routine may not set IOSTAT to a negative value other than
-1 or -2, unit "number", file "string"
FOR$IOS_CHILDNEGSTAT.
273 info (273): if a UDIO child sets IOSTAT, it must set IOMSG, unit "number", file
"string"
FOR$IOS_CHILDMSGSTAT.
279 info (279): Image "number" detected some other images had stopped
FOR$IOS_SOME_WERE_STOPPED.
715
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
285 info (285): Image "number" detected some other images had failed
FOR$IOS_SOME_WERE_FAILED.
286 info (286): Image "number" detected some other images had stopped and some had
failed
FOR$IOS_STOPPED_AND_FAILED.
287 info (287): Image "number" could not get an MPI communicator to use
FOR$IOS_NO_COMM. This problem with MPI will prevent formation of a TEAM.
289 info (289): Image "number" was given an invalid new image ID
FOR$IOS_BAD_NEW_IMAGE_ID. This pertains to the FORM TEAM statement.
290 info (290): Image "number" was given a duplicate new image ID
FOR$IOS_DUPLICATE_NEW_ID. This pertains to the FORM TEAM statement.
291 info (291): Image "number" detected new image IDs are not dense
FOR$IOS_NEW_IDS_NOT_DENSE. This pertains to the FORM TEAM statement.
292 info (292): Image "number" detected new image IDs did not start at 1
FOR$IOS_NEW_IDS_NOT_FROM_1. This pertains to the FORM TEAM statement.
295 info (295): Image "number" detected that current team is not active
FOR$IOS_CURRENT_NOT_ACTIVE. This pertains to the FORM TEAM statement. The user tried
an operation which needs the current team to be active, but it isn't.
716
Compiler Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
FOR$IOS_FLOINEEXC. The total number of floating-point inexact data traps encountered during
program execution was number. This summary message appears at program completion.
301 info (301): Image "number" detected that new team is not active
FOR$IOS_ICAF_NEW_TEAM_ACTIVE.
305 info (305): Image "number" had an internal error, invalid team variable
FOR$IOS_ICAF_BAD_TEAM_VAR.
306 info (306): Image "number" could not define the reduction
FOR$IOS_ICAF_REDUCTION_DEF_FAIL. Pertains to user-defined reduction operations.
307 info (307): Image "number" did not recognize that reduction
FOR$IOS_ICAF_UNKNOWN_REDUCTION. Pertains to user-defined reduction operations.
311 info (311): Image "number" used feature not supported on this architecture
FOR$IOS_ICAF_NOT_SUPPORTED_IA32. Coarray features are not supported on IA-32
architecture for the 2003 Standard or later.
717
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
312 info (312): Image "number" had an internal error configuring dynamic memory
FOR$IOS_ICAF_INTERNAL_DYN_CONFIG. Pertains to indirect pointers (one where the pointer is
the address of memory on another image).
313 info (313): Image "number" internal error attaching dynamic memory
FOR$IOS_ICAF_ERROR_DYN_ATTACH. Pertains to indirect pointers (one where the pointer is
the address of memory on another image).
314 info (314): Image "number" internal error detaching dynamic memory
FOR$IOS_ICAF_ERROR_DYN_DETACH. Pertains to indirect pointers (one where the pointer is
the address of memory on another image).
316 info (316): Image "number" unknown datatype for reduction operator
FOR$IOS_UNKNOWN_FTYPE_REDUCE.
317 info (317): Image "number" non-arithmetic datatype for reduction operator
FOR$IOS_NONARITH_TYPE_REDUCE.
318 info (318): Image "number" (len,root) arguments didn't match image 1's
FOR$IOS_MISMATCHBROADCAST. This pertains to the BROADCAST operation.
319 info (319): Image "number" (len,root, op) arguments didn't match image 1's
FOR$IOS_MISMATCHBROADCAST_OP. This pertains to the BROADCAST operation.
320 error (320): Image "number" ERROR STOP statement is not supported
FOR$IOS_NO_ERROR_STOP.
322 info (322): Environment variable '%s' should be defined to 'YES' or 'NO'
FOR$IOS_ENV_VAR_NEEDS_YES_OR_NO.
323 error (323): Image "number" had internal error in critical region support
FOR$IOS_INTERNAL_ERROR_CRITICAL.
324 error (324): Image "number" could not force unlock of critical region held by failed
image
FOR$IOS_FORCE_UNLOCK_FAIL.
325 error (325): Image "number"; can't do this operation on an inactive team
FOR$IOS_TEAM_NOT_ACTIVE.
327 error (327): Image "number"; mix of default new ids and specified new ids
FOR$IOS_MIXED_DEFAULT_IDS.
328 error (328): Image "number": may not delete or free active team variable
718
Compiler Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
FOR$IOS_TEAM_ACTIVE_NO_FREE.
329 error (329): Image "number": the specified team does not exist
FOR$IOS_NO_SUCH_TEAM.
330 error (330): Image "number": a failed image means a 'hole' in the new image-ids
FOR$IOS_HOLE_IN_IMAGE_IDS.
331 error (331): Image "number": may only change to a team which is the result of FORM
TEAM
FOR$IOS_NOT_FROM_FORM_TEAM.
332 error (332): Image "number": there are no non-failed images for this operation
FOR$IOS_NO_LIVE_IMAGES.
333 error (333): Image "number": team object has wrong version number
FOR$IOS_BAD_TEAM_VERSION.
335 warning (335): Image "number": the DIM argument "number" to THIS_IMAGE is out-
of-range
FOR$IOS_OUT_OF_COBOUNDS.
399 severe (399): Diagnostic message buffer overflow, hex message number was "hex-
number"
FOR$IOS_MSGBUFOVF.
719
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
502 severe (502): Insufficient memory to allocate Fortran RTL message buffer, message
#"number"
FOR$IOS_NO_MEMORY_1.
503 severe (503): Insufficient memory to allocate Fortran RTL message buffer, message
#"number" = hex "hex-number"
FOR$IOS_NO_MEMORY_2.
504 severe (504): FormatMessage failed for system message number "number"
FOR$IOS_MSG_FAILED .
506 info (506): The allocation of dynamic common "string" of size "string" in procedure
"string" failed
FOR$IOS_ALLOC_DYN_COMM.
508 info (508): The current size of dynamic common "string" is "string"
FOR$IOS_CURR_SIZE_COMM.
509 info (509): The declared size in procedure "string" is "string" bytes
FOR$IOS_DECL_SIZE.
510 info (510): Heap Allocation Failure while creating common "string" in procedure
"string"
FOR$IOS_HEAP_ALLOC.
720
Compiler Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
FOR$IOS_STOP_TERMINATED.
523 info (523): File name missing or blank - please enter file name
FOR$IOS_NAME_MISSING.
529 Info (529): Attempt to close a unit which was not open.
FOR$IOS_SYNERRNAM. The unit number specified on a CLOSE statement is not currently open.
530 info (530): FILE= specifier ignored when STATUS has value SCRATCH
FOR$IOS_NAMED_SCRATCH.
531 error (531): SEGMENTED record length includes control bytes, must be greater than
4, unit "number", file "string"
FOR$IOS_SEGINCRLEN.
721
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
551 severe (551): Formatted I/O not consistent with OPEN options
FOR$IOS_F6200. The program tried to perform formatted I/O on a unit opened with
FORM='UNFORMATTED' or FORM='BINARY'.
552 severe (552): List-directed I/O not consistent with OPEN options
FOR$IOS_F6201. The program tried to perform list-directed I/O on a file that was not opened
with FORM='FORMATTED' and ACCESS='SEQUENTIAL'.
553 severe (553): Terminal I/O not consistent with OPEN options
FOR$IOS_F6202. When a special device such as CON, LPT1, or PRN is opened in an OPEN
statement, its access must be sequential and its format must be either formatted or binary. By
default ACCESS='SEQUENTIAL' and FORM='FORMATTED' in OPEN statements.
To generate this error the device's OPEN statement must contain an option not appropriate for
a terminal device, such as ACCESS='DIRECT' or FORM='UNFORMATTED'.
554 severe (554): Direct I/O not consistent with OPEN options
FOR$IOS_F6203. A REC=option was included in a statement that transferred data to a file that
was opened with the ACCESS='SEQUENTIAL' option.
555 severe (555): Unformatted I/O not consistent with OPEN options
FOR$IOS_F6204. If a file is opened with FORM='FORMATTED', unformatted or binary data
transfer is prohibited.
722
Compiler Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
FOR$IOS_F6206. The E, F, D, or G edit descriptor was not specified when a real data item was
read or written using formatted I/O.
561 severe (561): Namelist I/O not consistent with OPEN options
FOR$IOS_F6210. The program tried to perform namelist I/O on a file that was not opened with
FORM='FORMATTED' and ACCESS='SEQUENTIAL'.
723
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
FOR$IOS_F6303. A radix specifier was not between 2 and 36, inclusive. Alternate radix
constants must be of the form n#ddd... where n is a radix from 2 to 36 inclusive and ddd... are
digits with values less than the radix. For example, 3#12 and 34#7AX are valid constants with
valid radix specifiers. 245#7A and 39#12 do not have valid radix specifiers and generate error
569 if input.
724
Compiler Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
725
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
FOR$IOS_F6408. If you have record lengths that exceed the buffer size associated with the
record, (for instance, the record is a file with the buffer set by BLOCKSIZE in the OPEN
statement), either you should not do left tabbing within the record, or you should not use
commas as field delimiters. This is because commas are disabled as input field delimiters if left
tabbing leaves the record positioned in a previous buffer.
For example, consider you have a file LONG.DAT that is one continuous record with data fields
separated by commas. You then set the buffer associated with the file to 512 bytes, read more
than one buffer size of data, tab left to data in the previous buffer, and attempt to read further
data, as follows:
INTEGER value(300)
OPEN (1, FILE = 'LONG.DAT', BLOCKSIZE = 512)s
READ (1, 100) (value(i), i = 1, 300)s
100 FORMAT (290I2,TL50,10I2)
In this case, error 594 occurs.
726
Compiler Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
612 severe (612): File not open for reading or file locked
FOR$IOS_F6500. The program tried to read from a file that was not opened for reading or was
locked.
727
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
Input of 2*1*3 returns this error. The 2*1 means send two values, each 1; the *3 is an error.
620 severe (620): Too many bytes read from unformatted record
FOR$IOS_F6508. The program tried to read more data from an unformatted file than the
current record contained. If the program was reading from an unformatted direct file, it tried to
read more than the fixed record length as specified by the RECL option. If the program was
reading from an unformatted sequential file, it tried to read more data than was written to the
record.
728
Compiler Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
FOR$IOS_F6515. A character item in namelist input was qualified with a subrange that did not
meet the requirement that 1 <= e1 <= e2 <= len (where "len" is the length of the character
item, "e1" is the leftmost position of the substring, and "e2" is the rightmost position of the
substring).
729
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
730
Compiler Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
731
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
663 severe (663): Out of range: substring starting position "pos" is less than 1
FOR$IOS_F6708. A substring starting position must be a positive integer variable or expression
that indicates a position in the string: at least 1 and no greater than the length of the string.
664 severe (664): Out of range: substring ending position "pos" is greater than string
length 'len'
FOR$IOS_F6709. A substring ending position must be a positive integer variable or expression
that indicates a position in the string: at least 1 and no greater than the length of the string.
665 severe (665): Subscript "number" of "string" (value "var") is out of range
('first:last')
FOR$IOS_F6710. The subscript for a substring within a string is not a valid string position: at
least 1 and no greater than the length of the string.
666 severe (666): Subscript "number" of "string" (value "var") is out of range ('first:*')
FOR$IOS_F6711. The subscript for a substring within a string is not a valid string position: at
least 1 and no greater than the length of the string.
667 severe (667): VECTOR argument to PACK has incompatible character length
FOR$IOS_F6712. The character length of elements in the VECTOR argument to PACK is not the
same as the character length of elements in the array to be packed.
669 severe (669): SOURCE and PAD arguments to RESHAPE have different character
lengths
FOR$IOS_F6714. The character length of elements in the SOURCE and PAD arguments to PACK
must be the same.
671 severe (671): SOURCE too small for specified SHAPE in RESHAPE, and no PAD
FOR$IOS_F6716. If there is no PAD array, the SOURCE argument to RESHAPE must have
enough elements to make an array of the shape specified by SHAPE.
673 severe (673): SHAPE and ORDER arguments to RESHAPE have different sizes ('size1'
and 'size2')
FOR$IOS_F6718. ORDER specifies the order of the array dimensions given in SHAPE, and they
must be vectors of the same size.
674 severe (674): Element "n" of ORDER argument to RESHAPE is out of range (range)
732
Compiler Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
FOR$IOS_F6719. The ORDER argument specifies the order of the dimensions of the reshaped
array, and it must be a permuted list of (1, 2, ..., "n") where "n" is the highest dimension in the
reshaped array.
675 severe (675): Value "n" occurs twice in ORDER argument to RESHAPE
FOR$IOS_F6720. The ORDER vector specifies the order of the dimensions of the reshaped
array, and it must be a permuted list of (1, 2, ..., "n") where "n" is the highest dimension in the
reshaped array. No dimension can occur twice.
677 severe (677): Invalid value "dim" for argument DIM for SPREAD of rank 'rank' source
FOR$IOS_F6722. The argument specified for DIM to SPREAD must be greater than or equal to
1, and less than or equal to one larger than the number of dimensions (rank) of SOURCE.
Consider the following statement:
result = SPREAD (SOURCE= array, DIM = dim, NCOPIES = k)
In this case, 1 <= dim <= n+ 1, where nis the number of dimensions in array.
682 severe (682): DIM argument ("dim") to CSHIFT is out of range (1:"n")
FOR$IOS_F6727. The optional argument DIM specifies the dimension along which to perform
the circular shift, and must be greater than or equal to 1 and less than or equal to the number
of dimensions in the array to be shifted. That is, 1 <= DIM <= "n", where "n"is the number of
dimensions in the array to be shifted.
683 severe (683): Shape mismatch (dimension "dim") between ARRAY and SHIFT in
CSHIFT
FOR$IOS_F6728. The SHIFT argument to CSHIFT must be either scalar or an array one
dimension smaller than the shifted array. If an array, the shape of the SHIFT must conform to
the shape of the array being shifted in every dimension except the one being shifted along.
733
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
689 severe (689): VALUES argument to DATE_AND_TIME is too small ("size" elements)
FOR$IOS_F6734. The integer VALUES argument must be a one-dimensional array with a size of
at least eight to hold all returned values.
690 severe (690): Out of range: DIM argument to COUNT has value "dim"
FOR$IOS_F6735. The optional argument DIM specifies the dimension along which to count true
elements of MASK, and must be greater than or equal to 1 and less than or equal to the
number of dimensions in MASK. That is, 1 <= DIM <= "n", where "n" is the number of
dimensions in MASK.
691 severe (691): Out of range: DIM argument to COUNT has value "dim" with MASK of
rank "rank"
FOR$IOS_F6736. The optional argument DIM specifies the dimension along which to count true
elements of MASK, and must be greater than or equal to 1 and less than or equal to the
number of dimensions (rank) in MASK. That is, 1 <= DIM <= "n", where "n"is the number of
dimensions in MASK.
692 severe (692): Out of range: DIM argument to PRODUCT has value "dim"
FOR$IOS_F6737. The optional argument DIM specifies the dimension along which to compute
the product of elements in an array, and must be greater than or equal to 1 and less than or
equal to the number of dimensions in the array. That is, 1 <= DIM <= "n", where "n"is the
number of dimensions in array holding the elements to be multiplied.
693 severe (693): Out of range: DIM argument to PRODUCT has value "dim" with ARRAY
of rank "rank"
FOR$IOS_F6738. The optional argument DIM specifies the dimension along which to compute
the product of elements in an array, and must be greater than or equal to 1 and less than or
equal to the number of dimensions (rank) of the array. That is, 1 <= DIM <= "n", where "n"is
the number of dimensions in array holding the elements to be multiplied.
694 severe (694): Out of range: DIM argument to SUM has value "dim" with ARRAY of
rank "rank"
FOR$IOS_F6739. The optional argument DIM specifies the dimension along which to sum the
elements of an array, and must be greater than or equal to 1 and less than or equal to the
number of dimensions (rank) of the array. That is, 1 <= DIM <= "n", where "n"is the number
of dimensions in array holding the elements to be summed.
734
Compiler Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
FOR$IOS_F6741. Zero of any type (real, complex, or integer) cannot be raised to a negative
power. Raising to a negative power inverts the operand.
697 severe (697): Out of range: DIM argument to SUM has value "dim"
FOR$IOS_F6742. The optional argument DIM specifies the dimension along which to sum the
elements of an array, and must be greater than or equal to 1 and less than or equal to the
number of dimensions in the array. That is, 1 <= DIM <= "n", where "n"is the number of
dimensions in array holding the elements to be summed.
698 severe (698): DIM argument ("dim") to EOSHIFT is out of range (1:"n")
FOR$IOS_F6743. The optional argument DIM specifies the dimension along which to perform
an end-off shift in an array, and must be greater than or equal to 1 and less than or equal to
the number of dimensions in the array. That is, 1 <= DIM <= "n", where "n"is the number of
dimensions in array holding the elements to be shifted.
699 severe (699): Shape mismatch (dimension "dim") between ARRAY and BOUNDARY in
EOSHIFT
FOR$IOS_F6744. The BOUNDARY argument to EOSHIFT must be either scalar or an array one
dimension smaller than the shifted array. If an array, the shape of the BOUNDARY must
conform to the shape of the array being shifted in every dimension except the one being shifted
along.
701 severe (701): Shape mismatch (dimension "dim") between ARRAY and SHIFT in
EOSHIFT
FOR$IOS_F6746. The SHIFT argument to EOSHIFT must be either scalar or an array one
dimension smaller than the shifted array. If an array, the shape of the SHIFT must conform to
the shape of the array being shifted in every dimension except the one being shifted along.
702 severe (702): BOUNDARY argument to EOSHIFT has wrong LEN ("len1 instead of
len2")
FOR$IOS_F6747. The character length of elements in the BOUNDARY argument and in the
array being end-off shifted must be the same.
703 severe (703): BOUNDARY has LEN "len" instead of "len" to EOSHIFT
FOR$IOS_F6748.
735
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
712 severe (712): SIZE argument ("size") to ISHFTC intrinsic out of range
FOR$IOS_F6757. The argument SIZE must be positive and must not exceed the bit size of the
integer being shifted. The bit size of this integer can be determined with the function BIT_SIZE.
713 severe (713): SHIFT argument ("shift") to ISHFTC intrinsic out of range
FOR$IOS_F6758. The argument SHIFT to ISHFTC must be an integer whose absolute value is
less than or equal to the number of bits being shifted: either all bits in the number being
shifted or a subset specified by the optional argument SIZE.
714 severe (714): Out of range: DIM argument to LBOUND has value "dim"
FOR$IOS_F6759. The optional argument DIM specifies the dimension whose lower bound is to
be returned, and must be greater than or equal to 1 and less than or equal to the number of
dimensions in the array. That is, 1 <= DIM <= "n", where "n" is the number of dimensions in
array.
715 severe (715): Out of range: DIM argument ("dim") to LBOUND greater than ARRAY
rank "rank"
FOR$IOS_F6760. The optional argument DIM specifies the dimension whose lower bound is to
be returned, and must be greater than or equal to 1 and less than or equal to the number of
dimensions (rank) in the array. That is, 1 <= DIM <= "n", where "n" is the number of
dimensions in array.
716 severe (716): Out of range: DIM argument to MAXVAL has value "dim"
FOR$IOS_F6761. The optional argument DIM specifies the dimension along which maximum
values are returned, and must be greater than or equal to 1 and less than or equal to the
number of dimensions in the array. That is, 1 <= DIM <= "n", where "n" is the number of
dimensions in array.
717 severe (717): Out of range: DIM argument to MAXVAL has value "dim" with ARRAY of
rank "rank"
FOR$IOS_F6762. The optional argument DIM specifies the dimension along which maximum
values are returned, and must be greater than or equal to 1 and less than or equal to the
number of dimensions (rank) in the array. That is, 1 <= DIM <= "n", where "n" is the number
of dimensions in array.
736
Compiler Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
Dynamic memory allocation is limited by several factors, including swap file size and memory
requirements of other applications that are running. If you encounter an unexpectedly low limit,
you may need to reset your virtual memory size through the Windows Control Panel or redefine
the swap file size. Allocated arrays that are no longer needed should be deallocated.
721 severe (721): Attempt to DEALLOCATE an object which was not allocated
FOR$IOS_F6766. You cannot deallocate an array unless it has been previously allocated. You
cannot deallocate a pointer whose target was not created by allocation. The intrinsic function
ALLOCATED can be used to determine whether an allocatable array is currently allocated.
737
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
Dynamic memory allocation is limited by several factors, including swap file size and memory
requirements of other applications that are running. If you encounter an unexpectedly low limit,
you may need to reset your virtual memory size through the Windows* Control Panel or
redefine the swap file size. Allocated arrays that are no longer needed should be deallocated.
730 severe (730): Out of range: DIM argument to MINVAL has value "dim"
FOR$IOS_F6775. The optional argument DIM specifies the dimension along which minimum
values are returned, and must be greater than or equal to 1 and less than or equal to the
number of dimensions in the array. That is, 1 <= DIM <= "n", where "n"is the number of
dimensions in array.
731 severe (731): Out of range: DIM argument to MINVAL has value "dim" with ARRAY of
rank "rank"
FOR$IOS_F6776. The optional argument DIM specifies the dimension along which minimum
values are returned, and must be greater than or equal to 1 and less than or equal to the
number of dimensions (rank) in the array. That is, 1 <= DIM <= "n", where "n"is the number
of dimensions in array.
738
Compiler Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
FOR$IOS_F6782. The sign of the S argument to NEAREST(X,S) determines the direction of the
search for the nearest number to X, and cannot be zero.
NOTE
RANDOM_SEED can be called with at most one argument at a time.
NOTE
RANDOM_SEED can be called with at most one argument at a time.
743 severe (743): Out of range: DIM argument to UBOUND had value "dim"
FOR$IOS_F6788. The optional argument DIM specifies the dimension whose upper bound is to
be returned, and must be greater than or equal to 1 and less than or equal to the number of
dimensions in the array. That is, 1 <= DIM <= "n", where "n" is the number of dimensions in
array.
744 severe (744): DIM argument ("dim") to UBOUND greater than ARRAY rank "rank"
FOR$IOS_F6789. The optional argument DIM specifies the dimension whose upper bound is to
be returned, and must be greater than or equal to 1 and less than or equal to the number of
dimensions (rank) in the array. That is, 1 <= DIM <= "n", where "n" is the number of
dimensions in array.
739
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
745 severe (745): Out of range: UBOUND of assumed-size array with DIM==rank ("rank")
FOR$IOS_F6790. The optional argument DIM specifies the dimension whose upper bound is to
be returned.
An assumed-size array is a dummy argument in a subroutine or function, and the upper bound
of its last dimension is determined by the size of actual array passed to it. Assumed-size arrays
have no determined shape, and you cannot use UBOUND to determine the extent of the last
dimension. You can use UBOUND to determine the upper bound of one of the fixed dimensions,
in which case you must pass the dimension number along with the array name.
746 severe (746): Out of range: DIM argument ("dim") to UBOUND greater than ARRAY
rank
FOR$IOS_F6791. The optional argument DIM specifies the dimension whose upper bound is to
be returned, and must be greater than or equal to 1 and less than or equal to the number of
dimensions (rank) in the array. That is, 1 <= DIM <= "n", where "n" is the number of
dimensions in array.
747 severe (747): Shape mismatch: Dimension "shape" extents are "ext1" and "ext2"
FOR$IOS_F6792.
750 severe (750): DELIM= specifier not allowed for an UNFORMATTED file
FOR$IOS_F6795. The DELIM specifier is only allowed for files connected for formatted data
transfer. It is used to delimit character constants in list-directed an namelist output.
752 severe (752): PAD= specifier not allowed for an UNFORMATTED file
FOR$IOS_F6797. The PAD specifier is only allowed for formatted input records. It indicates
whether the formatted input record is padded with blanks when an input list and format
specification requires more data than the record contains.
740
Compiler Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
741
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
FOR$IOS_WRITE_TO_SELF.
771 severe (771): A SYNC ALL statement could not perform a synchronization of all
images
FOR$IOS_SYNC_ALL_ERR.
772 severe (772): Image number "number" is not a valid image number; valid numbers
are 1 to "number"
FOR$IOS_IMAGE_OUT_OF_RANGE. A reference has been made to an image number that is not
a valid image number.
774 severe (774): Image-set array expression must not contain repeated values
FOR$IOS_IMG_SET_REPEATED. A SYNC IMAGES <image-list> statement was attempted. The
<image-list> contains duplicate values. This is not permitted by the standard.
775 severe (775): The lock variable in a LOCK statement is already locked by the
executing image
FOR$IOS_LC_VAR_IS_LOCKED. An attempt was made to use a LOCK statement on a lock.
However, that lock has already been locked by this image.
776 severe (776): The lock variable in an UNLOCK statement is not already locked by the
executing image
FOR$IOS_LC_VAR_NOT_LOCKED. An attempt was made to use an UNLOCK statement on a
lock. However, that lock is currently unlocked; it has not been locked by this image.
777 severe (777): The lock variable in a LOCK statement is already locked by another
image
FOR$IOS_LC_VAR_LOCKED_OTHER_IMAGE. An attempt was made to use a LOCK statement on
a lock. However, that lock is already locked by another image.
778 severe (778): One of the images to be synchronized with has terminated
FOR$IOS_LC_STOPPED_IMAGE. The code has tried to synchronize with a set of images using a
SYNC statement. One of the images to be synchronized with has already terminated.
780 severe (780): The lock variable in an UNLOCK statement is locked by another image
FOR$IOS_LC_VAR_UNLOCKED_OTHER_IMAGE. An attempt was made to use a coarray UNLOCK
operation on a lock. However, that lock is locked by another image.
This may be the result of an error in the program that causes the code to think it has a lock
when it does not.
781 error (781): Only image 1 may read from unit '*'
FOR$IOS_ONLY_IMAGE_L_IO. It is a coarray rule that only image 1 may read from the
'console'.
742
Compiler Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
782 severe (782): One of the images to be synchronized with has failed
FOR$IOS_LC_FAILED_IMAGE. A BARRIER operation was performed and one of the images
failed; the barrier completed with the remaining images.
783 severe (783): The lock variable in an UNLOCK statement is locked by a failed image
FOR$IOS_LC_UNLOCK_FAILED_IMAGE. The UNLOCK has failed.
784 error (784): EOR= must not be specified when the specifier ADVANCE='YES' also
appears
FOR$IOS_EOR_ADVANCE.
785 warning (785): File-path is longer than Intel(r) Fortran limit of 4096
FOR$IOS_FTNPATHLIM.
Footnotes:
1 Identifies errors not returned by IOSTAT.
743
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Calling the signal routine (specifying the numbers for these signals) results in overwriting the signal-
handling facility set up by the Intel® Fortran RTL. The only way to restore the default action is to save the
returned value from the first call to signal.
When using a debugger, it may be necessary to enter a command to allow the Intel® Fortran RTL to receive
and handle the appropriate signals.
#include <signal.h>
void clear_signal_() { signal (SIGABRT, SIG_DFL); }
int myabort_() {
abort();
return 0;
}
A call to the clear_signal() local routine must be added to main. Make sure that the call appears before
any call to the local myabort() routine:
program aborts
integer i
call clear_signal()
i = 3
if (i < 5) then
call myabort()
end if
end
744
Compiler Reference
• No default exception handler is included with Fortran Windows or Fortran DLL applications or with C
Console applications that contain Fortran procedures.
When you use the default exception handler, all events are enabled. You cannot connect or disconnect
individual events from the default Fortran exception handler. However, you can disable the Fortran exception
handler, and enable your own. To disable the exception handler, set the FOR_IGNORE_EXCEPTIONS
environment variable to TRUE.
Most exceptions captured by the Intel® Visual Fortran default handler are dealt with as severe errors. When
an exception occurs, the Fortran run-time system will display an error message and traceback output as
described in Understanding Run-Time Errors. A run-time error with a severe error (as described in Run-Time
Message Display and Format) causes the Intel® Visual Fortran run-time system to terminate the application.
Most I/O programming errors are also severe and will terminate an application.
I/O programming errors are not exceptions and cannot be caught by an exception handler. An unhandled I/O
programming error is reported through a different mechanism in the Intel® Visual Fortran run-time system.
Regardless of the application (project) type, unhandled I/O programming error will generate an error
message and traceback output.
See Also
Run-Time Message Display and Format
Understanding Run-Time Errors
project type
See Also
Establishing Console Event Handlers
745
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• The C run-time exit() routine is called with the status code to return to the operating system. The C
run-time exit() routine will call the Windows API routine ExitProcess to terminate the process. (See
crt0dat.c in the C run-time sources.)
Any unhandled exceptions that occur in a Fortran DLL or Fortran Windows application will have application
dependent behavior. Since there is no Fortran default handler present, the behavior depends on what you
provide for a handler. If you do not explicitly provide a handler, the default mechanisms provided in your
main program will determine the behavior. In a Fortran Windows* application, the C run-time system will
terminate the application.
mainCRTStartup() {
C initialization code here
__try {
more initialization code here
mainret = main() /* calls Fortran run-time main() */
exit(mainret)
} __except ( _XcptFilter() )
{ _exit ( GetExceptionCode() ) }
}
In the Fortran run-time system, main() initializes the Fortran run-time system (if not already initialized),
wraps a try-except construct around MAIN__ (the entry point to the Fortran code) with a filter expression
that invokes the Fortran run-time system default handler on exceptions, and calls MAIN__. It also wraps a
try-finally construct around all of this so run-time system clean up gets done (with for_rtl_finish_) when the
program exits. In simplified form, it looks like this:
main() {
__try {
__try {
for_rtl_init()
MAIN__
} __except ( expression-invoking-fortran-default-handler )
{ }
} __finally { for_rtl_finish() }
}
In the Fortran code, symbol MAIN__ is the entry point called by the run-time system's main() routine.
MAIN__ has the code to do any further run-time initialization or checks. For example, if the user compiled
with the non-default fpe[:]0 option, there would be a call to FOR_SET_FPE to tell the run-time system how
to setup/react to floating-point exceptions.
746
Compiler Reference
The entry point for a QuickWin application is specified as the C library WinMainCRTStartup() routine (see
module crt0.c in the C run-time sources). This gets the C run-time initialized, wraps the Intel® Visual
Fortran defined WinMain() in a try-except construct using the C run-time exception filter (_XcptFilter())
and calls the Intel® Visual Fortran defined WinMain() routine. In simplified form, it looks like this:
WinMainCRTStartup() {
C initialization code here
__try {
more initialization code here
mainret = WinMain() /* calls qwin library WinMain() */
exit(mainret)
} __except ( _XcptFilter() )
{ _exit ( GetExceptionCode() ) }
}
In the QuickWin library, WinMain() performs some initialization specific to QuickWin, creates a new thread
which begins execution at QWINForkMain, and then sits in a message loop directing the action. The message
loop is wrapped in a try-except-finally construct which invokes the Fortran run-time system default handler if
an exception occurs, and calls for_rtl_finish_ at exit. QWINForkMain() running in the other thread calls the
Fortran run-time system main(), which in turn calls MAIN__. In simplified form, it looks like this:
WinMain() {
Initialization code here
BeginThreadEx (..., QWINForkMain, ... )
__try {
__try {
the message loop...
for_rtl_finish()
return (msg.wParam)
} __except ( expression-invoking-default-fortran-handler )
{ }
} __finally {
for_rtl_finish()
return (msg.wParam)
}
}
QWINForkMain resembles the following:
QWINForkMain() {
main() /* calls the CVF rtl main() which calls MAIN__ */
cleanup and exit...
}
The routines main() and MAIN__ are the same as previously described for a Fortran Console application.
747
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
There are no automatic provisions for any exception handler in a DLL. There is no environment initialization
except what you provide. Of course, if your main application is also written in Fortran, you will get the default
Fortran handlers provided by that application type.
WinMainCRTStartup() {
C initialization code
__try {
more initialization code
mainret = WinMain() /* calls the user's WinMain() */
exit(mainret)
} __except ( _XcptFilter() )
{ _exit ( GetExceptionCode() ) }
}
The Fortran code contains:
See Also
for_rtl_finish_
FOR_SET_FPE
748
Compiler Reference
See Also
Using SIGNALQQ
SIGNALQQ
Handlers for the Application (Project) Types
Establishing Console Event Handlers
Using Windows* Structured Exception Handling (SEH) Overview
List of Run-Time Error Messages
749
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• If you do not specify an action to take on an error, the Fortran run-time system has no choice but to deal
with the error as an unhandled severe error and terminate the program. For a specific example of using
IOSTAT and ERR to deal gracefully with an OPEN statement that gets a file-not-found error, see Using the
IOSTAT Specifier and Fortran Exit Codes. You can do the same sort of thing in your code, but just return
the status back to your Visual Basic* or other non-Fortran main program and let it decide what to do.
• Try to write your DLL code so unexpected program exceptions cannot occur, but devise a strategy for
dealing with unexpected exceptions if they do happen. The most effective alternative for dealing with an
exception is to use Windows Structured Exception Handling support to gain control when an exception
happens. Wrap all your DLL routine calls in C try/except constructs and have the except() filter
expression call a routine you define which determines how to respond.
See Also
ISNAN
FP_CLASS
ALLOCATE
DEALLOCATE
750
Compiler Reference
You must call SIGNALQQ again to reset the action to your routine if you want to continue from the control
event. Your handler is called with the signal code (either SIGINT or SIGBREAK) as the argument. After your
routine returns to the C run-time event handler, the C handler will return the value TRUE to the operating
system indicating the event has been handled.
See Also
SIGNALQQ
Default Console Event Handling
Using SIGNALQQ
For lightweight exception handling requirements, a handler established with SIGNALQQ may meet your
needs. This section describes how signal handling with SIGNALQQ works in detail and also how the Fortran
run-time routine GETEXCEPTIONPTRSQQ works.
Reference is made to C run-time sources provided with Microsoft* Visual C++*. The discussion is worth
reviewing even if you do not have Visual C++* available.
751
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The C filter function, _XcptFilter, compares the exception code from the operating system with its
mapping of operating system exceptions to C signal codes. If it finds a match in the table, it uses the
exception action entry in the table corresponding to the signal code. This is the same table where your
SIGNALQQ handler is recorded as the action for the requested signal code. If you have established a handler,
it will be called from _XcptFilter. Before your handler is called, _XcptFilter resets the specified action
for the signal to SIG_DFL in the exception action table. If you try to continue from the exception and you
want your handler invoked on the next occurrence of the signal, you must call SIGNALQQ again to
reestablish your handler as the action for that signal. When your handler routine is finished executing and
returns to _XcptFilter, the value EXCEPTION_CONTINUE_EXECUTION is returned to the operating system
by _XcptFilter. The operating system will then resume execution at the point of the exception. If you do
not want to continue execution, your handler should take appropriate action to shut down the application.
Not every operating system exception code maps to a C signal code. You can see the mapping in source
WINXFLTR.C if you have it. Here is the list if you do not have WINXFLTR.C:
STATUS_ACCESS_VIOLATION SIGSEGV
STATUS_ILLEGAL_INSTRUCTION SIGILL
STATUS_PRIVILEGED_INSTRUCTION SIGILL
STATUS_FLOAT_DENORMAL_OPERAND SIGFPE
STATUS_FLOAT_DIVIDE_BY_ZERO SIGFPE
STATUS_FLOAT_INEXACT_RESULT SIGFPE
STATUS_FLOAT_INVALID_OPERATION SIGFPE
STATUS_FLOAT_OVERFLOW SIGFPE
STATUS_FLOAT_STACK_CHECK SIGFPE
STATUS_FLOAT_UNDERFLOW SIGFPE
The value returned by GETEXCEPTIONPTRSQQ can be used in your handler routine to generate a traceback
with TRACEBACKQQ. GETEXCEPTIONPTRSQQ just returns _pxcptinfoptrs. This pointer is only valid while
you are executing within the evaluation of the C run-time filter function _XcptFilter because the exception
information is on the program stack, so do not use GETEXCEPTIONPTRSQQ in any other context.
See Also
GETEXCEPTIONPTRSQQ (W*32)
Handlers for the Application (Project) Types
SIGNALQQ
752
Language Reference
Part
I
Language Reference V
This document contains the complete description of the Intel® Fortran programming language, which includes
Fortran 2018, Fortran 2008, Fortran 2003, Fortran 95, and Fortran 90. It contains information on language
syntax and semantics, on adherence to various Fortran standards, and on extensions to those standards.
For information about the Fortran standards, visit the Fortran standards technical committee website at
http://j3-fortran.org/.
This manual is intended for experienced applications programmers who have a basic understanding of
Fortran concepts and the Standard Fortran language.
Some familiarity with your operating system is helpful. This manual is not a Fortran or programming tutorial.
This document contains the following sections:
New Language Features Describes the major new features for this release.
Program Elements and Source Forms Describes program elements, the Fortran standard
character set, and source forms.
Data Types, Constants, and Variables Describes intrinsic and derived data types,
constants, variables (scalars and arrays), and
substrings.
753
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
File Operation I/O Statements Summarizes auxiliary I/O statements you can use
to perform file operations.
Scope and Association Describes scope, which refers to the area in which a
name is recognized, and association, which is the
language concept that allows different names to
refer to the same entity in a particular region of a
program.
Deleted and Obsolescent Language Features Describes deleted features in Fortran 2003 and
obsolescent language features in Fortran 2003.
Library Modules and Run-Time Library Routines Summarizes the library modules and run-time
library routines.
Other books in this documentation set provide details about the features of the compilers, how to improve
the run-time performance of Fortran programs, floating-point support, and compiler options.
For information on conventions used in this document, see Conventions.
For a summary of Fortran 2018 features in this release, see Fortran 2018 Features.
For a summary of Fortran 2008 features in this release, see Fortran 2008 Features.
For a summary of Fortran 2003 features in this release, see Fortran 2003 Features.
754
New Features for ifx
755
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
756
Program Elements and Source Forms
Program Units
A Fortran program consists of one or more program units. A program unit is usually a sequence of
statements that define the data environment and the steps necessary to perform calculations; it is
terminated by an END statement.
A program unit can be either a main program, an external subprogram, a module, a submodule, or a block
data program unit. An executable program contains one main program, and, optionally, any number of the
other kinds of program units. Program units can be separately compiled.
An external subprogram is a function or subroutine that is not contained within a main program, a module,
a submodule, or another subprogram. It defines a procedure to be performed and can be invoked from other
program units of the Fortran program. Modules, submodules, and block data program units are not
executable, so they are not considered to be procedures. (Modules and submodules can contain module
procedures, though, which are executable.)
Modules contain definitions that can be made accessible to other program units: data and type definitions,
definitions of procedures (called module subprograms), and procedure interfaces. Module subprograms can
be either functions or subroutines. They can be invoked by other module subprograms in the module, or by
other program units that access the module.
A submodule extends a module or another submodule. It can contain the definitions of procedures declared
in a module or submodule.
A block data program unit specifies initial values for data objects in named common blocks. In Standard
Fortran, this type of program unit can be replaced by a module program unit.
Main programs, external subprograms, and module subprograms can contain internal subprograms. The
entity that contains the internal subprogram is its host. Internal subprograms can be invoked only by their
host or by other internal subprograms in the same host. Internal subprograms must not contain internal
subprograms.
The following sections discuss Statements, Names, and Keywords.
See Also
Program Units and Procedures
Statements
Program statements are grouped into two general classes: executable and nonexecutable. An executable
statement specifies an action to be performed. A nonexecutable statement describes program attributes,
such as the arrangement and characteristics of data, as well as editing and data-conversion information.
757
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
PUBLIC and PRIVATE statements are only allowed in the scoping units of modules. In Standard Fortran,
NAMELIST statements can appear only among specification statements. However, Intel® Fortran allows them
to also appear among executable statements.
The following table shows other statements restricted from different types of scoping units.
758
Language Reference
See Also
Scope for details on scoping units
Keywords
A keyword can either be a part of the syntax of a statement (statement keyword), or it can be the name of a
dummy argument (argument keyword). Examples of statement keywords are WRITE, INTEGER, DO, and
OPEN. Examples of argument keywords are arguments to the intrinsic functions.
In the intrinsic function UNPACK (vector, mask, field), for example, vector, mask, and field are argument
keywords. They are dummy argument names, and any variable may be substituted in their place. Dummy
argument names and real argument names are discussed in topic Program Units and Procedures.
Keywords are not reserved. The compiler recognizes keywords by their context. For example, a program can
have an array named IF, read, or Goto, even though this is not good programming practice. The only
exception is the keyword PARAMETER. If you plan to use variable names beginning with PARAMETER in an
assignment statement, you need to use compiler option altparam.
Using keyword names for variables makes programs harder to read and understand. For readability, and to
reduce the possibility of hard-to-find bugs, avoid using names that look like parts of Fortran statements.
Rules that describe the context in which a keyword is recognized are discussed in topic Program Units and
Procedures.
759
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Argument keywords are a feature of Standard Fortran that let you specify dummy argument names when
calling intrinsic procedures, or anywhere an interface (either implicit or explicit) is defined. Using argument
keywords can make a program more readable and easy to follow. This is described more fully in topic
Program Units and Procedures. The syntax statements in the A-Z Reference show the dummy keywords you
can use for each Fortran procedure.
See Also
altparam compiler option
Program Units and Procedures
Names
Names identify entities within a Fortran program unit (such as variables, function results, common blocks,
named constants, procedures, program units, namelist groups, and dummy arguments). In FORTRAN 77,
names were called "symbolic names".
A name can contain letters, digits, underscores ( _ ), and the dollar sign ($) special character. The first
character must be a letter or a dollar sign.
In Fortran 2018 and Fortran 2008, a name can contain up to 63 characters.
The length of a module name (in MODULE and USE statements) may be restricted by your file system.
NOTE
Be careful when defining names that contain dollar signs. A dollar sign can be a symbol for command
or symbol substitution in various shell and utility commands.
In an executable program, the names of the following entities are global and must be unique in the entire
program:
• Program units
• External procedures
• Common blocks
• Modules
Examples
The following examples demonstrate valid and invalid names:
Valid Names
NUMBER
FIND_IT
Invalid Names
5Q Begins with a numeral.
760
Language Reference
Character Sets
Intel® Fortran supports the following characters:
• The Fortran character set, which consists of the following:
• All uppercase and lowercase letters (A through Z and a through z)
• The numerals 0 through 9
• The underscore ( _ )
• The following special characters:
/ Slash ~ Tilde
: Colon @ Commercial at
• Other printable characters
Printable characters include the tab character (09 hex), ASCII characters with codes in the range 20(hex)
through 7E(hex), and characters in certain special character sets.
Printable characters that are not in the Standard Fortran character set can only appear in comments,
character constants, Hollerith constants, character string edit descriptors, and input/output records.
Uppercase and lowercase letters are treated as equivalent when used to specify program behavior (except in
character constants and Hollerith constants).
See Also
Data Types, Constants, and Variables for further details on character sets and default character
types
ASCII and Key Code Charts for Windows*
ASCII Character Set for Linux* and macOS*
761
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Source Forms
Within a program, source code can be in free, fixed, or tab form. Fixed or tab forms must not be mixed with
free form in the same source program, but different source forms can be used in different source programs.
All source forms allow lowercase characters to be used as an alternative to uppercase characters.
Several characters are indicators in source code (unless they appear within a comment or a Hollerith or
character constant). The following are rules for indicators in all source forms:
• Comment indicator
A comment indicator can precede the first statement of a program unit and appear anywhere within a
program unit. If the comment indicator appears within a source line, the comment extends to the end of
the line.
An all blank line is also a comment line.
Comments have no effect on the interpretation of the program unit.
For more information, see comment indicators in free source form, or fixed and tab source forms.
• Statement separator
More than one statement (or partial statement) can appear on a single source line if a statement
separator is placed between the statements. The statement separator is a semicolon character (;).
Consecutive semicolons (with or without intervening blanks) are considered to be one semicolon.
If a semicolon is the first character on a line, the last character on a line, or the last character before a
comment, it is ignored.
• Continuation indicator
A statement can be continued for more than one line by placing a continuation indicator on the line. Intel
Fortran allows at least 511 continuation lines for a fixed or tab source program. Although Standard Fortran
permits up to 256 continuation lines in free-form programs, Intel® Fortran allows up to 511 continuation
lines.
Comments can occur within a continued statement, but comment lines cannot be continued.
For more information, see continuation indicators in free source form, or fixed and tab source forms.
The following table summarizes characters used as indicators in source forms.
!, C, or * Fixed In column 1
Tab In column 1
762
Language Reference
Tab In column 1
1 If the character appears in a Hollerith or character constant, it is not an indicator and is ignored.
2For fixed or tab source form, at least 511 continuation lines are allowed. For free source form, at least
255 continuation lines are allowed.
3 Fixed and tab forms only.
Source form and line length can be changed at any time by using the FREEFORM, NOFREEFORM, or
FIXEDFORMLINESIZE directives. The change remains in effect until the end of the file, or until changed
again.
You can also select free source form by using compiler option free.
Source code can be written so that it is useable for all source forms.
Statement Labels
A statement label (or statement number) identifies a statement so that other statements can refer to it,
either to get information or to transfer control. A label can precede any statement that is not part of another
statement.
A statement label must be one to five decimal digits long; blanks and leading zeros are ignored. An all-zero
statement label is invalid, and a blank statement cannot be labeled.
Labeled FORMAT and labeled executable statements are the only statements that can be referred to by other
statement. FORMAT statements are referred to only in the format specifier of an I/O statement or in an
ASSIGN statement. Two statements within a scoping unit cannot have the same label.
See Also
free compiler option
763
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• Some adjacent keywords must have one or more blank characters between them. Others do not require
any; for example, BLOCK DATA can also be spelled BLOCKDATA. The following list shows which keywords
have optional or required blanks:
IN OUT
SELECT CASE
SELECT TYPE
764
Language Reference
specified more than once. You cannot specify both IMPURE and PURE. You cannot specify both
NON_RECURSIVE and RECURSIVE.
For information on statement separators (;) in all forms, see Source Forms.
Comment Indicator
In free source form, the exclamation point character (!) indicates a comment if it is within a source line, or a
comment line if it is the first character in a source line.
Continuation Indicator
In free source form, the ampersand character (&) indicates a continuation line (unless it appears in a
Hollerith or character constant, or within a comment). The continuation line is the first noncomment line
following the ampersand. Although Standard Fortran permits up to 256 continuation lines in free-form
programs, Intel® Fortran allows up to 511 continuation lines.
The following shows a continued statement:
See Also
Source Forms for details on the general rules for all source forms
765
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Except in a character context, blanks are not significant and can be used freely throughout the program for
maximum legibility.
Some Fortran compilers use blanks to pad short source lines out to 72 characters. By default, Intel® Fortran
does not. If portability is a concern, you can use the concatenation operator to prevent source lines from
being padded by other Fortran compilers (see the example in "Continuation Indicator" below) or you can
force short source lines to be padded by using compiler option pad-source.
Comment Indicator
In fixed and tab source forms, the exclamation point character (!) indicates a comment if it is within a source
line. It must not appear in column 6 of a fixed form line; that column is reserved for a continuation indicator.
The letter C (or c), an asterisk (*), or an exclamation point (!) indicates a comment line when it appears in
column 1 of a source line.
Continuation Indicator
In fixed and tab source forms, a continuation line is indicated by one of the following:
• For fixed form: Any character (except a zero or blank) in column 6 of a source line
• For tab form: Any digit (except zero) after the first tab
The compiler considers the characters following the continuation indicator to be part of the previous line.
Although Standard Fortran permits up to 19 continuation lines in a fixed-form program, Intel® Fortran allows
up to 511 continuation lines.
If a zero or blank is used as a continuation indicator, the compiler considers the line to be an initial line of a
Fortran statement.
The statement label field of a continuation line must be blank (except in the case of a debugging statement).
When long character or Hollerith constants are continued across lines, portability problems can occur. Use the
concatenation operator to avoid such problems. For example:
CHARACTER*(*) LONG_CONST
PARAMETER (LONG_CONST = 'This is a very long '//
+ 'character constant which is safely continued '//
+ 'across lines')
CHARACTER*100 LONG_VAL
DATA LONG_VAL /LONG_CONST/
Hollerith constants must be converted to character constants before using the concatenation method of line
continuation.
The Fortran Standard requires that, within a program unit, the END statement cannot be continued, and no
other statement in the program unit can have an initial line that appears to be the program unit END
statement. In these instances, Intel Fortran produces warnings when standards checking is requested.
766
Language Reference
By default, the compiler treats debugging statements as comments. However, you can specify compiler
option d-lines to force the compiler to treat debugging statements as source text to be compiled.
See Also
Fixed-format lines
Tab-format lines
Source Forms for details on the general rules for all source forms
d-lines compiler option
extend-source compiler option
pad-source compiler option
Fixed-Format Lines
In fixed source form, a source line has columns divided into fields for statement labels, continuation
indicators, statement text, and sequence numbers. Each column represents a single character.
The column positions for each field follow:
Field Column
Continuation indicator 6
By default, a sequence number or other identifying information can appear in columns 73 through 80 of any
fixed-format line in an Intel® Fortran program. The compiler ignores the characters in this field.
If you extend the statement field to position 132, the sequence number field does not exist.
NOTE
If you use the sequence number field, do not use tabs anywhere in the source line, or the compiler
may interpret the sequence numbers as part of the statement field in your program.
See Also
Source Forms
Fixed and Tab Source Forms
extend-source compiler option
Tab-Format Lines
In tab source form, you can specify a statement label field, a continuation indicator field, and a statement
field, but not a sequence number field.
The following figure shows equivalent source lines coded with tab and fixed source form.
767
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The statement label field precedes the first tab character. The continuation indicator field and statement field
follow the first tab character.
The continuation indicator is any nonzero digit. The statement field can contain any Fortran statement. A
Fortran statement cannot start with a digit.
If a statement is continued, a continuation indicator must be the first character (following the first tab) on
the continuation line.
Many text editors and terminals advance the terminal print carriage to a predefined print position when you
press the <Tab> key. However, the Intel® Fortran compiler does not interpret the tab character in this way. It
treats the tab character in a statement field the same way it treats a blank character. In the source listing
that the compiler produces, the tab causes the character that follows to be printed at the next tab stop
(usually located at columns 9, 17, 25, 33, and so on).
NOTE
If you use the sequence number field, do not use tabs anywhere in the source line, or the compiler
may interpret the sequence numbers as part of the statement field in your program.
See Also
Source Forms for details on the general rules for all source forms
Fixed and Tab Source Forms for details on the general rules for fixed and tab source forms
768
Data Types, Constants, and Variables
Continuation indicator Use only &. Place in column position 73 of the initial
line and each continuation line, and in column 6 of
each continuation line (no tab character can
precede the ampersand in column 6).
769
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
A constant that has a name is a named constant. A named constant can be of any type, including derived
type, and it can be array-valued. A named constant has the PARAMETER attribute and is specified in a
type declaration statement or PARAMETER statement.
• A set of operations to manipulate and interpret these values
The data type of a variable determines the operations that can be used to manipulate it. Besides intrinsic
operators and operations, you can also define operators and operations.
See Also
Type Declarations
Defined Operations
PARAMETER attribute and statement
Expressions for details on valid operations for data types
770
Language Reference
For more portable programs, you should not use the forms INTEGER([KIND=]n) or REAL([KIND=]n). You
should instead define a PARAMETER constant using the SELECTED_INT_KIND or SELECTED_REAL_KIND
function, whichever is appropriate. For example, the following statements define a PARAMETER constant for
an INTEGER kind that has 9 digits:
INTEGER, PARAMETER :: MY_INT_KIND = SELECTED_INT_KIND(9)
...
INTEGER(MY_INT_KIND) :: J
...
Note that the syntax :: is used in type declaration statements.
The following sections describe the intrinsic data types and forms for literal constants for each type.
See Also
KIND intrinsic function
Declaration Statements for Noncharacter Types for details on declaration statements for intrinsic
data types
Declaration Statements for Character Types for details on declaration statements for intrinsic data
types
Expressions for details on operations for intrinsic data types
Data Type Storage Requirements table for details on storage requirements for intrinsic data types
If a kind parameter is specified, the integer has the kind specified. If a kind parameter is not specified,
integer constants are interpreted as follows:
• If the integer constant is within the default integer kind range, the kind is default integer.
• If the integer constant is outside the default integer kind range, the kind of the integer constant is the
smallest integer kind that holds the constant.
Default integer is affected by compiler option integer-size, the INTEGER compiler directive, and the OPTIONS
statement.
The intrinsic inquiry function KIND returns the kind type parameter, if you do not know it. You can use the
intrinsic function SELECTED_INT_KIND to find the kind values that provide a given range of integer values.
The decimal exponent range is returned by the intrinsic function RANGE.
Examples
The following examples show ways an integer variable can be declared.
An entity-oriented example is:
771
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
INTEGER I, X
READ (*,*) I
IF (I) THEN
X = 1
END IF
See Also
Integer Constants
integer-size compiler option
Integer Constants
An integer constant is a whole number with no decimal point. It can have a leading sign and is interpreted as
a decimal number.
Integer constants take the following form:
[s]n[n...][ _k]
Note that compiler option integer-size can affect the KIND type parameter of INTEGER data and integer
constants.
772
Language Reference
Examples
Valid Integer (base 10) Constants
0
-127
+32123
47_2
The following seven integers are all assigned a value equal to 3,994,575 decimal:
I = 2#1111001111001111001111
m = 7#45644664
J = +8#17171717
K = #3CF3CF
n = +17#2DE110
L = 3994575
index = 36#2DM8F
The following seven integers are all assigned a value equal to -3,994,575 decimal:
I = -2#1111001111001111001111
m = -7#45644664
J = -8#17171717
K = -#3CF3CF
n = -17#2DE110
L = -3994575
index = -36#2DM8F
You can use integer constants to assign values to data. The following table shows assignments to different
data and lists the integer and hexadecimal values in the data:
LOGICAL(1)X
INTEGER(1)X
X = -128 -128 Z'80'
X = 127 127 Z'7F'
X = 255 -1 Z'FF'
LOGICAL(2)X
INTEGER(2)X
X = 255 255 Z'FF'
X = -32768 -32768 Z'8000'
X = 32767 32767 Z'7FFF'
X = 65535 -1 Z'FFFF'
773
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Numeric Expressions
integer-size compiler option
If a kind parameter is specified, the real constant has the kind specified. If a kind parameter is not specified,
the kind is default real.
Default real is affected by compiler options specifying real size and by the REAL directive.
The default KIND for DOUBLE PRECISION is affected by compiler option double-size. If this compiler option is
not specified, default DOUBLE PRECISION is REAL(8).
No kind parameter is permitted for data declared with type DOUBLE PRECISION.
The intrinsic inquiry function KIND returns the kind type parameter. The intrinsic inquiry function RANGE
returns the decimal exponent range, and the intrinsic function PRECISION returns the decimal precision. You
can use the intrinsic function SELECTED_REAL_KIND to find the kind values that provide a given precision
and exponent range.
Examples
The following examples show how real variables can be declared.
An entity-oriented example is:
See Also
General Rules for Real Constants
REAL(4) Constants
REAL(8) or DOUBLE PRECISION Constants
REAL(16) Constants
real-size
774
Language Reference
[s]n[n...]E[s]nn...[_k]
[s]n[n...]D[s]nn...
[s]n[n...]Q[s]nn...
Description
Leading zeros (zeros to the left of the first nonzero digit) are ignored in counting significant digits. For
example, in the constant 0.00001234567, all of the nonzero digits, and none of the zeros, are significant.
(See the following sections for the number of significant digits each kind type parameter typically has).
The exponent represents a power of 10 by which the preceding real or integer constant is to be multiplied
(for example, 1.0E6 represents the value 1.0 * 10**6).
A real constant with no exponent part and no kind type parameter is (by default) a single-precision
(REAL(4)) constant. You can change the default behavior by specifying compiler option fpconstant.
If the real constant has no exponent part, a decimal point must appear in the string (anywhere before the
optional kind parameter). If there is an exponent part, a decimal point is optional in the string preceding the
exponent part; the exponent part must not contain a decimal point.
The exponent letter E denotes a single-precision real (REAL(4)) constant, unless the optional kind parameter
specifies otherwise. For example, -9.E2_8 is a double-precision constant (which can also be written as
-9.D2).
The exponent letter D denotes a double-precision real (REAL(8)) constant.
The exponent letter Q denotes a quad-precision real (REAL(16)) constant.
A minus sign must appear before a negative real constant; a plus sign is optional before a positive constant.
Similarly, a minus sign must appear between the exponent letter (E, D, or Q ) and a negative exponent,
whereas a plus sign is optional between the exponent letter and a positive exponent.
If the real constant includes an exponent letter, the exponent field cannot be omitted, but it can be zero.
To specify a real constant using both an exponent letter and a kind parameter, the exponent letter must be E,
and the kind parameter must follow the exponent part.
See Also
fpconstant compiler option
REAL(4) Constants
A single-precision REAL constant occupies four bytes of memory. The number of digits is unlimited, but
typically only the leftmost seven digits are significant.
IEEE* IEEE binary32 format is used.
Note that compiler option real-size can affect REAL data.
Examples
Valid REAL(4) Constants
3.14159
3.14159_4
775
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
621712._4
-.00127
+5.0E3
2E-3_4
See Also
General Rules for Real Constants
real-size compiler option
Compiler Reference > Data and I/O section: Data Representation
Examples
Valid REAL(8) or DOUBLE PRECISION Constants
123456789D+5
123456789E+5_8
+2.7843D00
-.522D-12
2E200_8
2.3_8
3.4E7_8
776
Language Reference
See Also
General Rules for Real Constants
double-size compiler option
Compiler Reference > Data and I/O section: Data Representation
REAL(16) Constants
A REAL(16) constant has more than four times the accuracy of a REAL(4) number, and a greater range.
A REAL(16) constant occupies 16 bytes of memory. The number of digits that precede the exponent is
unlimited, but typically only the leftmost 33 digits are significant.
IEEE* binary128 format is used.
Examples
Valid REAL(16) Constants
123456789Q4000
-1.23Q-400
+2.72Q0
1.88_16
See Also
General Rules for Real Constants
Compiler Reference > Data and I/O section: Data Representation
777
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If a kind parameter is specified, the complex constant has the kind specified. If no kind parameter is
specified, the kind of both parts is default real, and the constant is of type default complex.
Default real is affected by compiler option real-size and by the REAL directive.
The default KIND for DOUBLE COMPLEX is affected by compiler option double-size. If the compiler option is
not specified, default DOUBLE COMPLEX is COMPLEX(8).
No kind parameter is permitted for data declared with type DOUBLE COMPLEX.
A complex number of any kind is made up of a real part and an imaginary part. The REAL and AIMAG
intrinsic functions return the real and imaginary parts of a complex number respectively. The CMPLX intrinsic
constructs a complex number from two real numbers. The %re and %im complex part designators access the
real and imaginary parts of a complex number respectively.
Examples
The following examples show how complex variables can be declared.
An entity-oriented example is:
COMPLEX(4) cz, cq
DIMENSION(8) cz, cq
The following shows an example of the parts of a complex number:
See Also
General Rules for Complex Constants
AIMAG intrinsic
CMPLX intrinsic
COMPLEX(4) Constants
COMPLEX(8) or DOUBLE COMPLEX Constants
REAL intrinsic
c Is as follows:
778
Language Reference
COMPLEX(4) Constants
A COMPLEX(4) constant is a pair of integer or single-precision real constants that represent a complex
number.
A COMPLEX(4) constant occupies eight bytes of memory and is interpreted as a complex number.
If the real and imaginary part of a complex literal constant are both real, the kind parameter value is that of
the part with the greater decimal precision.
The rules for REAL(4) constants apply to REAL(4) constants used in COMPLEX constants. (See General Rules
for Complex Constants and REAL(4) Constants for the rules on forming REAL(4) constants.)
The REAL(4) constants in a COMPLEX constant have IEEE* binary32 format.
Note that compiler option real-size can affect REAL data.
Examples
Valid COMPLEX(4) Constants
(1.7039,-1.70391)
(44.36_4,-12.2E16_4)
(+12739E3,0.)
(1,2)
See Also
General Rules for Complex Constants
real-size compiler option
779
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The default KIND for DOUBLE COMPLEX is affected by compiler option double-size.
Examples
Valid COMPLEX(8) or DOUBLE COMPLEX Constants
(1.7039,-1.7039D0)
(547.3E0_8,-1.44_8)
(1.7039E0,-1.7039D0)
(+12739D3,0.D0)
See Also
General Rules for Complex Constants
double-size
COMPLEX(16) Constants
A COMPLEX(16) constant is a pair of constants that represents a complex number. One of the pair must be a
REAL(16) constant, the other can be an integer, single-precision real, double-precision real, or REAL(16)
constant.
A COMPLEX(16) constant occupies 32 bytes of memory and is interpreted as a complex number.
The rules for REAL(16) constants apply to REAL(16) constants used in COMPLEX constants. (See General
Rules for Complex Constants and REAL(16) Constants for the rules on forming REAL(16) constants.)
The REAL(16) constants in a COMPLEX constant have IEEE* binary128 format.
Note that compiler option real-size can affect REAL data.
Examples
Valid COMPLEX(16) Constants
(1.7039,-1.7039Q2)
(547.3E0_16,-1.44)
(+12739D3,0.Q0)
See Also
General Rules for Complex Constants
780
Language Reference
If a kind parameter is specified, the logical constant has the kind specified. If no kind parameter is specified,
the kind of the constant is default logical.
Examples
The following examples show how logical variables can be declared.
An entity-oriented example is:
See Also
Logical Constants
Logical Constants
A logical constant represents only the logical values true or false, and takes one of the following forms:
.TRUE.[_k]
.FALSE.[_k]
The numeric value of .TRUE. and .FALSE. can be -1 and 0 or 1 and 0 depending on compiler option fpscomp
[no]logicals. Logical data can take on integer data values. Logical data type ranges correspond to their
comparable integer data type ranges. For example, the LOGICAL(2) range is the same as the INTEGER(2)
range.
781
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
len Is a string length (not a kind). For more information, see Declaration
Statements for Character Types.
If no kind type parameter is specified, the kind of the constant is default character.
On Windows systems, several Multi-Byte Character Set (MBCS) functions are available to manipulate special
non-English characters.
See Also
Character Constants
C Strings
Character Substrings
Character Data Type
Character Constants
A character constant is a character string enclosed in delimiters (apostrophes or quotation marks). It takes
one of the following forms:
[k_]'[ch...]' [C]
[k_]"[ch...]" [C]
ch Is an ASCII character.
Description
The value of a character constant is the string of characters between the delimiters. The value does not
include the delimiters, but does include all blanks or tabs within the delimiters.
If a character constant is delimited by apostrophes, use two consecutive apostrophes ('' ) to place an
apostrophe character in the character constant.
Similarly, if a character constant is delimited by quotation marks, use two consecutive quotation marks ("")
to place a quotation mark character in the character constant.
The length of the character constant is the number of characters between the delimiters, but two consecutive
delimiters are counted as one character.
The length of a character constant must be in the range of 0 to 7188. Each character occupies one byte of
memory.
If a character constant appears in a numeric context (such as an expression on the right side of an arithmetic
assignment statement), it is considered a Hollerith constant.
A zero-length character constant is represented by two consecutive apostrophes or quotation marks.
Examples
Valid Character Constants
"WHAT KIND TYPE? "
782
Language Reference
''
See Also
Declaration Statements for Character Types
\a or \A A bell
\b or \B A backspace
\f or \F A formfeed
\n or \N A new line
\r or \R A carriage return
\t or \T A horizontal tab
\v or \V A vertical tab
\0 A null character
\\ A backslash
If a string contains an escape sequence that isn't in this table, the backslash is ignored.
A C string must also be a valid Fortran string. If the string is delimited by apostrophes, apostrophes in the
string itself must be represented by two consecutive apostrophes ('' ).
For example, the escape sequence \'string causes a compiler error because Fortran interprets the
apostrophe as the end of the string. The correct form is \''string.
If the string is delimited by quotation marks, quotation marks in the string itself must be represented by two
consecutive quotation marks ("").
783
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The sequences \ooo and \xhh allow any ASCII character to be given as a one- to three-digit octal or a one-
to two-digit hexadecimal character code. Each octal digit must be in the range 0 to 7, and each hexadecimal
digit must be in the range 0 to F. For example, the C strings '\010'C and '\x08'C both represent a
backspace character followed by a null character.
The C string '\\abcd'C is equivalent to the string '\abcd' with a null character appended. The string ''C
represents the ASCII null character.
Character Substrings
A character substring is a contiguous segment of a character string. It takes one of the following forms:
v ([e1]:[e2])
a (s [, s] . . . ) ([e1]:[e2])
s Is a subscript expression.
Both e1 and e2 must be within the range 1,2, ..., len, where len is the length of the parent character string.
If e1 exceeds e2, the substring has length zero.
Description
Character positions within the parent character string are numbered from left to right, beginning at 1.
If the value of the numeric expression e1 or e2 is not of type integer, it is converted to integer before use
(any fractional parts are truncated).
If e1 is omitted, the default is 1. If e2 is omitted, the default is len. For example, NAMES(1,3)(:7) specifies
the substring starting with the first character position and ending with the seventh character position of the
character array element NAMES(1,3).
Examples
Consider the following example:
CHARACTER*8 C, LABEL
LABEL = 'XVERSUSY'
C = LABEL(2:7)
LABEL(2:7) specifies the substring starting with the second character position and ending with the seventh
character position of the character variable assigned to LABEL, so C has the value 'VERSUS'.
TYPE ORGANIZATION
INTEGER ID
CHARACTER*35 NAME
END TYPE ORGANIZATION
TYPE(ORGANIZATION) DIRECTOR
CHARACTER*25 BRANCH, STATE(50)
784
Language Reference
See Also
Arrays
Array Elements
Structure Components
See Also
Derived-Type Assignment Statements
Defining Generic Operators for details on OPERATOR interfaces
Defining Generic Assignment for details on ASSIGNMENT interfaces
TYPE Statement (Derived Types)
Parameterized Derived-Type Declarations
Records for details on record structures
Default Initialization
Default initialization occurs if initialization appears in a derived-type component definition.
The specified initialization of the component will apply even if the definition is PRIVATE.
Default initialization applies to dummy arguments with INTENT(OUT). It does not imply the derived-type
component has the SAVE attribute.
Explicit initialization in a type declaration statement overrides default initialization.
785
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
To specify default initialization of an array component, use a constant expression that includes one of the
following:
• An array constructor
• A single scalar that becomes the value of each array element
Pointers can have an association status of associated, disassociated, or undefined. If no default initialization
status is specified, the status of the pointer is undefined. To specify disassociated status for a pointer
component, use =>NULL( ). To default initialize a pointer component as associated with the target T, use =>
T.
Examples
You do not have to specify initialization for each component of a derived type. For example:
TYPE REPORT
CHARACTER (LEN=20) REPORT_NAME
INTEGER DAY
CHARACTER (LEN=3) MONTH
INTEGER :: YEAR = 1995 ! Only component with default
END TYPE REPORT ! initialization
Consider the following:
TYPE MGR_REPORT
TYPE (REPORT) :: STATUS = NOV_REPORT
INTEGER NUM
END TYPE MGR_REPORT
TYPE (MGR_REPORT) STARTUP
In this case, the STATUS component of STARTUP gets its initial value from NOV_REPORT, overriding the
initialization for the YEAR component.
See Also
Initialization expressions
786
Language Reference
If you specify NOPASS, procedures will not have have passed-object dummy
arguments. NOPASS is required if the interface is implicit.
The PASS attribute can be used to confirm the default (as the first argument),
The NOPASS attribute prevents passing the object as an argument.
Each proc-attr can only appear once in a given component definition.
Examples
The following example defines a type that represents a list of procedures with the same interface, which can
be called at some future time:
TYPE PROCEDURE_LIST
PROCEDURE (PROC_INTERFACE), POINTER :: PROC
TYPE (PROCEDURE_LIST), POINTER :: NEXT => NULL()
END TYPE PROCEDURE_LIST
ABSTRACT INTERFACE
SUBROUTINE PROC_INTERFACE
...
END SUBROUTINE PROC_INTERFACE
END INTERFACE
A procedure pointer can be pointer-assigned to a procedure pointer variable, invoked directly, or passed as
an actual argument. For example:
Type-Bound Procedures
In a derived-type definition, you can optionally specify a type-bound-procedure-part, which consists of a
CONTAINS statement, optionally followed by a PRIVATE statement, and one or more procedure binding
statements. Specific, GENERIC, and FINAL procedure bindings are defined below.
A type-bound-procedure-part in a derived-type definition declares one or more type-bound procedures. It
takes the following form:
CONTAINS
[PRIVATE]
proc-binding-stmt
[ proc-binding-stmt]...
787
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
specific-binding
A specific type-bound procedure binds a procedure to a type or it specifies a deferred binding to an abstract
type. It takes the following form:
PROCEDURE (interface-name), binding-attr-list :: binding-name [, binding-name]...
PROCEDURE [ [ , binding-attr-list ] :: ] binding-name [ => procedure-name ] [, [binding-name [ =>
procedure-name]]…]
interface-name (Optional) Is the interface for the procedure. It must be the name of an abstract
interface or a procedure that has an explicit interface. interface-name can only
be specified if the binding has the DEFERRED attribute.
binding-attr-list (Optional) Is one or more of the following. The same attribute can only appear
once for the same binding:
• PASS [ (arg-name)]
Defines the "passed-object dummy argument" of the procedure. If arg-name
is specified, the interface of the binding must have a dummy argument named
arg-name.
• NOPASS
Indicates that the procedure has no passed-object dummy argument. Use this
keyword if the procedure pointer component has an implicit interface or has
no arguments. PASS and NOPASS can not both be specified for the same
binding.
• access-spec
Is the PUBLIC or PRIVATE attribute.
• NON_OVERRIDABLE
Determines whether a binding can be overridden in an extended type. You
must not specify NON_OVERRIDABLE for a binding with the DEFERRED
attribute.
• DEFERRED
Indicates that the procedure is deferred. Deferred bindings must only be
specified for derived-type definitions with the ABSTRACT attribute. A
procedure with the DEFERRED binding attribute must specify an interface-
name. An overriding binding can have the DEFERRED attribute only if the
binding it overrides is deferred. The NON_OVERRIDABLE and DEFERRED
binding attributes must not both be specified for the same procedure.
binding-name Is the name of the type-bound procedure. It is referred to in the same way as a
component of a type.
procedure-name (Optional) Is the name of the actual procedure which implements binding-name.
It is the name of an accessible module procedure or an external procedure that
has an explicit interface. It defines the interface for the procedure, and the
procedure to be executed when the procedure is referenced.
If neither =>procedure-name nor interface-name appears, the procedure-name
is the same as the binding-name. If =>procedure-name appears, you must
specify the double-colon separator and you must not specify an interface-name.
In general, the invoking variable, the passed-object dummy argument, is passed as an additional argument.
By default, this is the first dummy argument of the actual procedure. So, the first argument in the argument
list becomes the second argument, etc.
A passed-object dummy argument can be changed by declaring the type-bound procedure with the
PASS(arg-name) attribute. In this case, the variable is passed as the named argument. The PASS attribute
can also be used to confirm the default as the first argument. The NOPASS attribute prevents passing the
object as an argument.
788
Language Reference
See Also
TYPE
Passed-Object Dummy Arguments
PROCEDURE statement
Type Extension
Type extension lets you create new derived types by extending pre-existing derived types.
Any derived type can be extended using the EXTENDS keyword, except for types with the SEQUENCE or
BIND(C) attributes. SEQUENCE types and BIND(C) types (as well as intrinsic types) are non-extensible.
The extended type either inherits or overrides each type-bound procedure of the parent type. An overriding
procedure must be compatible with the parent procedure; in particular, each dummy argument must have
the same type except for the passed-object dummy argument which must have the new type. A type-bound
procedure that is declared to be NON_OVERRIDABLE cannot be overridden during type extension.
The extended type inherits all the components and parameters of the parent type and they are known by the
same name. The extended type can also specify additional components.
For example, consider the following derived-type definition:
TYPE PERSON_INFO
INTEGER :: AGE
CHARACTER (LEN = 60) :: NAME
END TYPE PERSON_INFO
Derived type PERSON_INFO (the parent type) can be extended to create a new type as follows:
TYPE, EXTENDS (PERSON_INFO) :: EMPLOYEE_DATA
INTEGER :: ID
REAL :: SALARY
END TYPE EMPLOYEE_DATA
Extended type EMPLOYEE_DATA inherits all the components in type PERSON_INFO, as well as additional
components ID and SALARY.
789
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
TYPE
Passed-Object Dummy Arguments
kind-selector (Optional) Is one of the kind type parameter numbers allowed for integer data
types. For more information, see Integer Data Types.
If you do not specify kind-selector, default integer kind is assumed.
type-param-name Is the name of the type parameter. Each type-param-name must match one of
the type-param-name parameters listed in the derived TYPE statement.
If init-spec is specified, the type parameter has a default value that is specified by the expression init-spec. If
necessary, the value of init-spec is converted to an integer value of the same kind as the type parameter in
accordance with the rules of intrinsic assignment.
Explicit values for the type parameters are normally specified when an object of the parameter type is
declared.
Within the type definition, kind type parameters may be used in constant expressions and specification
expressions. Length type parameters may be used in specification expressions but not in constant
expressions. The type parameters need not be used anywhere in the derived type.
Kind type parameters also participate in generic resolution Unambiguous Generic Procedure References. A
single generic can include two specific procedures that have interfaces distinguished only by the value of a
kind type parameter of a dummy argument.
An explicit interface is required if a parameterized derived type is used as a dummy argument. In a SELECT
TYPE construct, the kind type parameter values of a type guard statement must be the same as those of the
dynamic type of the selector. A BIND(C) type and a SEQUENCE type must not have type parameters.
Advantages to Using This Feature
Adding type parameters to a derived type allows you to declare objects of similar types that differ depending
on the kind and length parameters used in the object declaration. For example, the type definition matrix
below has two type parameters, a kind parameter k and a length parameter b.
TYPE matrix ( k, b )
INTEGER, KIND :: k = 4
INTEGER (8), LEN :: b
REAL (k) :: element (b,b)
END TYPE matrix
The user can declare a matrix named square of 10 by 10 elements of REAL(8) with the following declaration:
790
Language Reference
The user can declare another matrix named big_square of 100 by 100 elements of REAL(4) with the
following declaration:
TYPE (matrix (10)) :: square ! k defaults to 4
See Also
Parameterized TYPE Statements
SELECT TYPE
SEQUENCE
A type-param-spec-list must appear only if the type is parameterized. There must be at most one type-
param-spec corresponding to each parameter of the type. If a type parameter does not have a default value,
there must be a type-param-spec corresponding to that type parameter.
The following topics in this section include cumulative examples demonstrating various kinds of
parameterized TYPE statements.
Examples
Consider the following:
See Also
Parameterized Derived-Type Declarations
791
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
derived-type-spec Is a derived type-spec. See Type Declarations for details on derived type
specifications.
Example
Matrix (kind (0.0),1,3) :: my_matrix
my_matrix = matrix (kind (0.0),1,3) ([1.0,2.0,3.0])
See Also
Parameterized Derived-Type Declarations
Parameterized TYPE Statements
Structure Constructors
Examples
Consider the following:
Type :: t1 (k1,k2)
Integer, kind :: k1,k2
Real(k1) :: a(k2)
End type
The type parameter order for type t2 is k1, then k2, then k3.
See Also
Parameterized Derived-Type Declarations
Parameterized TYPE Statements
792
Language Reference
See Also
Parameterized Derived-Type Declarations
Parameterized TYPE Statements
ALLOCATE
ALLOCATABLE
POINTER - Fortran
! d1 here is assumed and its value '10' is obtained from the actual argument
Type(matrix(k= KIND(0d0), d1=*, d2=:), pointer :: x(:)
ALLOCATE(matrix(KIND(0.0), *, 10) :: x(10))
...
End Subroutine
All length type parameters of the dummy argument must be assumed for a final subroutine. All length type
parameters of the first dummy argument to a user-defined I/O subroutine must be assumed. All of the length
type parameters of a passed-object dummy argument must be assumed. In a SELECT TYPE construct, each
length type parameter in a type-guard-stmt must be assumed.
793
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Array Constructors
If type-spec in an array constructor specifies a parameterized derived type, all ac-value expressions in the
array constructor must be of that derived type and must have the same kind type parameter values as
specified by type-spec. Also, type-spec specifies the declared type and type parameters of the array
constructor.
Each ac-value expression in the array constructor must be compatible with intrinsic assignment to a variable
of this type and type parameter. Each value is converted to the type parameters of the array constructor in
accordance with the rules of intrinsic assignment.
If type-spec is omitted, each ac-value expression in the array constructor must have the same length type
parameters; in which case, the declared type and type parameters of the array constructor are those of the
ac-value expressions.
REAL(selected_real_kind(10,20)) :: z(100)
..
PRINT *,z%kind ! A single value is printed
This is same as calling KIND(z). However, the type parameter inquiry can be used even when the intrinsic
function is not available.
See Also
Parameterized Derived-Type Declarations
Parameterized TYPE Statements
SELECT TYPE
Structure Components
A reference to a component of a derived-type structure takes the following form:
parent [(s-list)] [image-selector] [%component [(s-list)] [image-selector]] ... %component [(s-list)] [image-
selector]
794
Language Reference
parent Is the name of a scalar or array of derived type. The percent sign (%)
is called a component selector.
s-list Is a list of one or more subscripts. If the list contains subscript triplets
or vector subscripts, the reference is to an array section.
Each subscript must be a scalar integer (or other numeric) expression
with a value that is within the bounds of its dimension.
The number of subscripts in any s-list must equal the rank of the
immediately preceding parent or component.
Description
Each parent or component (except the rightmost) must be of derived type.
The parent or one of the components can have nonzero rank (be an array). Any component to the right of a
parent or component of nonzero rank must not have the POINTER attribute.
The rank of the structure component is the rank of the part (parent or component) with nonzero rank (if
any); otherwise, the rank is zero. The type and type parameters (if any) of a structure component are those
of the rightmost part name.
The structure component must not be referenced or defined before the declaration of the parent object.
If the parent object has the INTENT, TARGET, or PARAMETER attribute, the structure component also has the
attribute.
If the rightmost component is of type C_PTR or C_FUNPTR from the intrinsic module ISO_C_BINDING, or of
type TEAM_TYPE from the intrinsic module ISO_FORTRAN_ENV, each parent or component must not have an
image-selector.
Examples
The following example shows a derived-type definition with two components:
TYPE EMPLOYEE
INTEGER ID
CHARACTER(LEN=40) NAME
END TYPE EMPLOYEE
The following shows how to declare CONTRACT to be of type EMPLOYEE:
TYPE(EMPLOYEE) :: CONTRACT
Note that both examples started with the keyword TYPE. The first (initial) statement of a derived-type
definition is called a derived-type statement, while the statement that declares a derived-type object is called
a TYPE statement.
The following example shows how to reference component ID of parent structure CONTRACT:
CONTRACT%ID
The following example shows a derived type with a component that is a previously defined type:
TYPE DOT
REAL X, Y
END TYPE DOT
....
795
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
TYPE SCREEN
TYPE(DOT) C, D
END TYPE SCREEN
The following declares a variable of type SCREEN:
TYPE(SCREEN) M
Variable M has components M%C and M%D (both of type DOT); M%C has components M%C%X and M%C
%Y of type REAL.
The following example shows a derived type with a component that is an array:
TYPE CAR_INFO
INTEGER YEAR
CHARACTER(LEN=15), DIMENSION(10) :: MAKER
CHARACTER(LEN=10) MODEL, BODY_TYPE*8
REAL PRICE
END TYPE
...
TYPE(CAR_INFO) MY_CAR
Note that MODEL has a character length of 10, but BODY_TYPE has a character length of 8. You can assign a
value to a component of a structure; for example:
MY_CAR%YEAR = 1985
The following shows an array structure component:
MY_CAR%MAKER
In the preceding example, if a subscript list (or substring) was appended to MAKER, the reference would not
be to an array structure component, but to an array element or section.
Consider the following:
MY_CAR%MAKER(2) (4:10)
In this case, the component is substring 4 to 10 of the second element of array MAKER.
Consider the following:
TYPE CHARGE
INTEGER PARTS(40)
REAL LABOR
REAL MILEAGE
END TYPE CHARGE
TYPE(CHARGE) MONTH
TYPE(CHARGE) YEAR(12)
Some valid array references for this type follow:
796
Language Reference
The following example shows a derived type with a pointer component that is of the type being defined:
TYPE NUMBER
INTEGER NUM
END TYPE
A type such as this can be used to construct linked lists of objects of type NUMBER. Note that the pointers
are given the default initialization status of disassociated.
The following example shows a private type:
TYPE REAL_ARRAY
REAL,ALLOCATABLE :: RA(:)
END TYPE
TYPE CO_ARRAY
TYPE(REAL_ARRAY) :: CA[*]
END TYPE
TYPE STRUCT
TYPE(CO_ARRAY) :: COMP
END TYPE
ALLOCATE(ARRAY(5,10)%COMP%CA%RA(10))
ARRAY(5,10)%COMP%CA[5]%RA(:) = 0
See Also
Array Elements for details on references to array elements
Array Sections for details on references to array sections
Modules and Module Procedures for examples of derived types in modules
Structure Constructors
A structure constructor lets you specify scalar values of a derived type. It takes the following form:
d-name (comp-spec)
797
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
data-target Is a data pointer component. It must have the same rank as its
corresponding component.
Description
A structure constructor must not appear before its derived type is defined.
If keyword= appears, any expr is assigned to the component named by the keyword. If keyword= is omitted,
each comp-data-source is assigned to the corresponding component in component order. The keyword= can
be omitted from a comp-spec only if the keyword= has been omitted from each preceding comp-spec in the
constructor, if any.
If a component of the derived type is an array, the shape in the expression list must conform to the shape of
the component array.
If a component of the derived type is a pointer, the value in the expression list must evaluate to an object
that would be a valid target in a pointer assignment statement. (A constant is not a valid target in a pointer
assignment statement.)
If all the values in a structure constructor are constant expressions, the constructor is a derived-type
constant expression.
The type name and all components of the type for which a comp-spec appears must be accessible in the
scoping unit containing the structure constructor.
For a pointer component, the corresponding comp-data-source must be an allowable data-target or proc-
target for such a pointer in a pointer assignment statement. If the comp-data-source is a pointer, the
association of the component is that of the pointer; otherwise, the component is pointer-associated with the
comp-data-source.
If a component with default initialization has no corresponding comp-data-source, then the default
initialization is applied to that component.
If a component of a derived type is allocatable, the corresponding constructor expression must either be a
reference to the intrinsic function NULL with no arguments or an allocatable entity of the same rank, or it
must evaluate to an entity of the same rank.
If the expression is a reference to the intrinsic function NULL, the corresponding component of the
constructor has a status of unallocated.
If the expression is an allocatable entity, the corresponding component of the constructor has the same
allocation status as that allocatable entity. If the entity is allocated, the constructor component has the same
dynamic type, bounds, and value. If a length parameter of the component is deferred, its value is the same
as the corresponding parameter of the expression.
798
Language Reference
If the component is allocatable and the expression is not an allocatable entity, the component has an
allocation status of allocated, and the same bounds as the expression. If the component has a deferred
length parameter, its value is the same as the corresponding length parameter of the expression. If the
component is polymorphic, it has the same dynamic type and value. Otherwise, the value is converted, if
necessary, to the declared type of the component.
Examples
Consider the following derived-type definition:
TYPE EMPLOYEE
INTEGER ID
CHARACTER(LEN=40) NAME
END TYPE EMPLOYEE
This can be used to produce the following structure constructor:
TYPE ITEM
REAL COST
CHARACTER(LEN=30) SUPPLIER
CHARACTER(LEN=20) ITEM_NAME
END TYPE ITEM
TYPE PRODUCE
REAL MARKUP
TYPE(ITEM) FRUIT
END TYPE PRODUCE
In this case, you must use an embedded structure constructor to specify the values of that component; for
example:
See Also
Pointer Assignments
Procedure Pointers
799
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The length of a sequence of bits is the number of bits in the sequence. The position of the leftmost nonzero
bit is interpreted to be at least m - 1, where m is the maximum value that could result from invoking the
intrinsic function STORAGE SIZE with an argument that is a real or an integer scalar of any kind supported
by the processor.
In Intel® Fortran, binary, octal, hexadecimal, and Hollerith constants can appear wherever numeric constants
are allowed.
See Also
Determining the Data Type of Nondecimal Constants
Bit Sequence Comparisons
Binary Constants
A binary constant is an alternative way to represent a numeric constant. A binary constant takes one of the
following forms:
B'd[d...]'
B"d[d...]"
Examples
Valid Binary Constants
B'0101110'
B"1"
See Also
Alternative Syntax for Binary, Octal, and Hexadecimal Constants
Octal Constants
An octal constant is an alternative way to represent numeric constants. An octal constant takes one of the
following forms:
O'd[d...]'
O"d[d...]"
You can specify up to 128 bits (43 octal digits) in octal constants.
Examples
Valid Octal Constants
O'07737'
800
Language Reference
O"1"
See Also
Alternative Syntax for Binary, Octal, and Hexadecimal Constants
Hexadecimal Constants
A hexadecimal constant is an alternative way to represent numeric constants. A hexadecimal constant takes
one of the following forms:
Z'd[d...]'
Z"d[d...]"
You can specify up to 128 bits (32 hexadecimal digits) in hexadecimal constants.
Examples
Valid Hexadecimal Constants
Z'AF9730'
Z"FFABC"
Z'84'
See Also
Alternative Syntax for Binary, Octal, and Hexadecimal Constants
Hollerith Constants
A Hollerith constant is a string of printable ASCII characters preceded by the letter H. Before the H, there
must be an unsigned, nonzero default integer constant stating the number of characters in the string
(including blanks and tabs).
Hollerith constants are strings of 1 to 2000 characters. They are stored as byte strings, one character per
byte.
Examples
Valid Hollerith Constants
16HTODAY'S DATE IS:
801
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1HB
4H ABC
INTEGER(2) ICOUNT
INTEGER(4) JCOUNT
INTEGER(4) N
REAL(8) DOUBLE
RAFFIA = REAL(4) 4
B'1001100111111010011'
DOUBLE = REAL(8) 8
B'1111111111100110011010'
When a specific data type (generally integer) is required, that type is assumed for the constant. For example:
802
Language Reference
When a binary, octal, or hexadecimal constant is used in any other context, the default integer data type is
assumed. In the following examples, default integer is INTEGER(4):
When nondecimal constants are not the same length as the length implied by a data type, the following
occurs:
• Binary, octal, and hexadecimal constants
These constants can specify up to 16 bytes of data. When the length of the constant is less than the
length implied by the data type, the leftmost digits have a value of zero.
When the length of the constant is greater than the length implied by the data type, the constant is
truncated on the left. An error results if any nonzero digits are truncated.
The Data Type Storage Requirements table lists the number of bytes that each data type requires.
• Hollerith constants
When the length of the constant is less than the length implied by the data type, blanks are appended to
the constant on the right.
When the length of the constant is greater than the length implied by the data type, the constant is
truncated on the right. If any characters other than blank characters are truncated, a warning occurs.
Each Hollerith character occupies one byte of memory.
803
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If = appears in an enumerator, a double-colon separator must appear before the enumerator or list of
enumerators.
The compiler ensures that the integer kind declared for the enumerator is compatible with the integer type
used by the corresponding C enumeration. The processor uses the same representation for the types
declared by all C enumeration specifiers that specify the same values in the same order.
An enumerator is treated as if it were explicitly declared with the PARAMETER attribute.
The order in which the enumerators appear in an enumerator definition is significant.
If you do not explicitly assign each enumerator a value by specifying an expr, the compiler assigns a value
according to the following rules:
• If the enumerator is the first enumerator in the enumerator definition, the enumerator has the value 0.
• If the enumerator is not the first enumerator in the enumerator definition, its value is the result of adding
one to the value of the immediately preceding enumerator in the enumerator definition.
You can define the enumerators in multiple ENUMERATOR statements or in one ENUMERATOR statement. The
order in which the enumerators are declared in an enumeration definition is significant, but the number of
ENUMERATOR statements is not.
Examples
The following example shows an enumeration definition:
ENUM, BIND(C)
ENUMERATOR ORANGE
ENUMERATOR :: RED = 5, BLUE = 7
ENUMERATOR GREEN
END ENUM
The kind type parameter for this enumeration is processor dependent, but the processor must select a kind
sufficient to represent the values of the enumerators.
The order of the enumerators is significant if the values are not assigned explicitly. In the above example,
the value of ORANGE becomes defined as a named constant with the value zero and the value of GREEN
becomes defined as a named constant with the value 8. Note that if RED was the enumerator preceding
GREEN, the value of GREEN would be 6 rather than 8.
The following declaration may be considered to be equivalent to the above enumeration definition:
INTEGER(KIND(BLUE)) :: X
804
Language Reference
Variables
A variable is a data object whose value can be changed (defined or redefined) at any point in a program. A
variable can be any of the following:
• A scalar
A scalar is a single object that has a single value; it can be of any intrinsic or derived (user-defined) type.
• An array
An array is a collection of scalar elements of any intrinsic or derived type. All elements must have the
same type and kind parameters.
• A subobject designator
A subobject is part of an object. The following are subobjects:
An array element
An array section
A structure component
A character substring
For example, B(3) is a subobject (array element) designator for array B. A subobject cannot be a variable
if its parent object is a constant.
• A reference to a function that returns a data pointer
A reference to a function that returns a data pointer is treated as a variable and is permitted in any
variable-definition context .
The name of a variable is associated with a single storage location.
A designator is a name followed by zero or more component selectors, complex part selectors, array section
selectors, array element selectors, image selectors, and substring selectors.
Variables are classified by data type, as constants are. The data type of a variable indicates the type of data
it contains, including its precision, and implies its storage requirements. When data of any type is assigned to
a variable, it is converted to the data type of the variable (if necessary).
A variable is defined when you give it a value. A variable can be defined before program execution by a DATA
statement or a type declaration statement. During program execution, variables can be defined or redefined
in assignment statements and input statements, or undefined (for example, if an I/O error occurs). When a
variable is undefined, its value is unpredictable.
When a variable becomes undefined, all variables associated by storage association also become undefined.
An object with subobjects, such as an array, can only be defined when all of its subobjects are defined.
Conversely, when at least one of its subobjects are undefined, the object itself, such as an array or derived
type, is undefined.
This section also discusses the Data Types of Scalar Variables and Arrays.
See Also
Type Declarations
DATA statement
Data Type of a Numeric Expressions
Storage Association for details on storage association of variables
805
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
An explicit declaration of data type takes precedence over any implicit type. Implicit type specified in an
IMPLICIT statement takes precedence over predefined typing rules.
See Also
Specification of Data Type
Implicit Typing Rules
NOTE
If no kind parameter is specified for a data type, the default kind is used. The default kind can be
affected by compiler options that affect the size of variables.
You can explicitly specify the data type of a scalar variable only once.
If no explicit data type specification appears, any variable with a name that begins with the letter in the
range specified in the IMPLICIT statement becomes the data type of the variable.
Character type declaration statements specify that given variables represent character values with the length
specified. For example, the following statements associate the variable names INLINE, NAME, and NUMBER
with storage locations containing character data of lengths 72, 12, and 9, respectively:
CHARACTER(72) INLINE
CHARACTER NAME*12, NUMBER*9
In single subprograms, assumed-length character arguments can be used to process character strings with
different lengths. The assumed-length character argument has its length specified with an asterisk, for
example:
CHARACTER(*) CHARDUMMY
The argument CHARDUMMY assumes the length of the actual argument.
See Also
Type Declarations
ALPHA JCOUNT
BETA ITEM_1
TOTAL_NUM NTOTAL
806
Language Reference
You can override the default data type implied in a name by specifying data type in either an IMPLICIT
statement or a type declaration statement.
See Also
Type Declarations
IMPLICIT statement
Arrays
An array is a set of scalar elements that have the same type and kind parameters. Any object that is
declared with an array specification is an array. Arrays can be declared by using a type declaration
statement, or by using a DIMENSION, COMMON, ALLOCATABLE, POINTER, or TARGET statement.
An array can be referenced by element (using subscripts), by section (using a section subscript list), or as a
whole. A subscript list (appended to the array name) indicates which array element or array section is being
referenced.
A section subscript list consists of subscripts, subscript triplets, or vector subscripts. At least one subscript in
the list must be a subscript triplet or vector subscript.
When an array name without any subscripts appears in an intrinsic operation (for example, addition), the
operation applies to the whole array (all elements in the array).
An array has the following properties:
• Data type
An array can have any intrinsic or derived type. The data type of an array (like any other variable) is
specified in a type declaration statement or implied by the first letter of its name. All elements of the
array have the same type and kind parameters. If a value assigned to an individual array element is not
the same as the type of the array, it is converted to the array's type.
• Rank
The rank of an array is the number of dimensions in the array. An array can have up to 31 dimensions. A
rank-one array represents a column of data (a vector), a rank-two array represents a table of data
arranged in columns and rows (a matrix), a rank-three array represents a table of data on multiple pages
(or planes), and so forth.
• Bounds
Arrays have a lower and upper bound in each dimension. These bounds determine the range of values
that can be used as subscripts for the dimension. The value of either bound can be positive, negative, or
zero.
The bounds of a dimension are defined in an array specification.
• Size
The size of an array is the total number of elements in the array (the product of the array's extents).
The extent is the total number of elements in a particular dimension. The extent is determined as follows:
upper bound - lower bound + 1. If the value of any of an array's extents is zero, the array has a size of
zero.
• Shape
The shape of an array is determined by its rank and extents, and can be represented as a rank-one array
(vector) where each element is the extent of the corresponding dimension.
Two arrays with the same shape are said to be conformable. A scalar is conformable to an array of any
shape.
The name and rank of an array must be specified when the array is declared. The extent of each dimension
can be constant, but does not need to be. The extents can vary during program execution if the array is a
dummy argument array, an automatic array, an array pointer, or an allocatable array.
A whole array is referenced by the array name. Individual elements in a named array are referenced by a
scalar subscript or list of scalar subscripts (if there is more than one dimension). A section of a named array
is referenced by a section subscript.
807
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Examples
The following are examples of valid array declarations:
INTEGER L(2:11,3)
The properties of array L are as follows:
Second dimension: 1 to 3
The following example shows other valid ways to declare this array:
DIMENSION L(2:11,3)
INTEGER, DIMENSION(2:11,3) :: L
COMMON L(2:11,3)
The following example shows references to array elements, array sections, and a whole array:
808
Language Reference
See Also
DIMENSION attribute
Intrinsic data types
Derived data types
Declaration Statements for Arrays for details on array specifications
Categories of Intrinsic Functions for details on intrinsic functions that perform array operations
Whole Arrays
A whole array is a named array; it is either a named constant or a variable. It is referenced by using the
array name (without any subscripts).
If a whole array appears in a nonexecutable statement, the statement applies to the entire array. For
example:
INTEGER, DIMENSION(2:11,3) :: L ! Specifies the type and
! dimensions of array L
If a whole array appears in an executable statement, the statement applies to all of the elements in the
array. For example:
L = 10 ! The value 10 is assigned to all the
! elements in array L
WRITE *, L ! Prints all the elements in array L
Array Elements
An array element is one of the scalar data items that make up an array. A subscript list (appended to the
array or array component) determines which element is being referred to. A reference to an array element
takes the following form:
array(subscript-list)
Description
Each array element inherits the type, kind type parameter, and certain attributes (INTENT, PARAMETER, and
TARGET) of the parent array. An array element cannot inherit the POINTER attribute.
If an array element is of type character, it can be followed by a substring range in parentheses; for example:
REAL A(3, 3)
REAL B(3, 3), C(89), R
B(2, 2) = 4.5 ! Assigns the value 4.5 to element B(2, 2)
R = 7.0
C(INT®*2 + 1) = 2.0 ! Element 15 of C = 2.0
A(1,2) = B(INT(C(15)), INT(SQRT®)) ! Element A(1,2) = element B(2,2) = 4.5
809
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
For information on forms for array specifications, see Declaration Statements for Arrays.
Array Storage
For example, in two-dimensional array BAN, element BAN(1,2) has a subscript order value of 4; in three-
dimensional array BOS, element BOS(1,1,1) has a subscript order value of 1.
810
Language Reference
In an array section, the subscript order of the elements is their order within the section itself. For example, if
an array is declared as B(20), the section B(4:19:4) consists of elements B(4), B(8), B(12), and B(16). The
subscript order value of B(4) in the array section is 1; the subscript order value of B(12) in the section is 3.
See Also
Array association
Character Constants for details on substrings
Structure Components for details on arrays as structure components
Storage Association for details on storage sequence association
Array Sections
An array section is a portion of an array that is an array itself. It is an array subobject. A section subscript
list (appended to the array or array component) determines which portion is being referred to. A reference to
an array section takes the following form:
array(sect-subscript-list)
Description
If no section subscript list is specified, the rank and shape of the array section is the same as the parent
array.
Otherwise, the rank of the array section is the number of vector subscripts and subscript triplets that appear
in the list. Its shape is a rank-one array where each element is the number of integer values in the sequence
indicated by the corresponding subscript triplet or vector subscript.
If any of these sequences is empty, the array section has a size of zero. The subscript order of the elements
of an array section is that of the array object that the array section represents.
Each array section inherits the type, kind type parameter, and certain attributes (INTENT, PARAMETER, and
TARGET) of the parent array. An array section cannot inherit the POINTER attribute.
If an array (or array component) is of type character, it can be followed by a substring range in parentheses.
Consider the following declaration:
CHARACTER(LEN=15) C(10,10)
In this case, an array section referenced as C(:,:) (1:3) is an array of shape (10,10), whose elements are
substrings of length 3 of the corresponding elements of C.
The following shows valid references to array sections. Note that the syntax (/.../) denotes an array
constructor.
REAL, DIMENSION(20) :: B
...
PRINT *, B(2:20:5) ! The section consists of elements
! B(2), B(7), B(12), and B(17)
811
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
K = (/3, 1, 4/)
B(K) = 0.0 ! Section B(K) is a rank-one array with shape (3) and
! size 3. (0.0 is assigned to B(1), B(3), and B(4).)
See Also
INTENT attribute
PARAMETER attribute
TARGET attribute
Array constructors
Character Substrings
Structure components for details on array sections as structure components
Subscript Triplets
A subscript triplet is a set of three values representing the lower bound of the array section, the upper
bound of the array section, and the increment (stride) between them. It takes the following form:
[first-bound] : [last-bound] [:stride]
first-bound Is a scalar integer (or other numeric) expression representing the first
value in the subscript sequence. If omitted, the declared lower bound
of the dimension is used.
last-bound Is a scalar integer (or other numeric) expression representing the last
value in the subscript sequence. If omitted, the declared upper bound
of the dimension is used.
When indicating sections of an assumed-size array, this subscript must
be specified.
812
Language Reference
A subscript in a subscript triplet need not be within the declared bounds for that dimension if all values used
to select the array elements are within the declared bounds. For example, if an array has been declared as
A(15), the array section specified as A(4:16:10) is valid. The section is a rank-one array with shape (2) and
size 2. It consists of elements A(4) and A(14).
If the subscript triplet does not specify bounds or stride, but only a colon (:), the entire declared range for
the dimension is used.
If you leave out all subscripts, the section defaults to the entire extent in that dimension. For example:
REAL A(10)
A(1:5:2) = 3.0 ! Sets elements A(1), A(3), A(5) to 3.0
A(:5:2) = 3.0 ! Same as the previous statement
! because the lower bound defaults to 1
A(2::3) = 3.0 ! Sets elements A(2), A(5), A(8) to 3.0
! The upper bound defaults to 10
A(7:9) = 3.0 ! Sets elements A(7), A(8), A(9) to 3.0
! The stride defaults to 1
A(:) = 3.0 ! Same as A = 3.0; sets all elements of
! A to 3.0
See Also
Array Sections
Vector Subscripts
A vector subscript is a one-dimensional (rank one) array of integer values (within the declared bounds for
the dimension) that selects a section of a whole (parent) array. The elements in the section do not have to be
in order and the section can contain duplicate values.
For example, A is a rank-two array of shape (4,6). B and C are rank-one arrays of shape (2) and (3),
respectively, with the following values:
B = (/1,4/) ! Syntax (/.../) denotes an array constructor
C = (/2,1,1/) ! This constructor produces a many-one array section
Array section A(3,B) consists of elements A(3,1) and A(3,4). Array section A(C,1) consists of elements
A(2,1), A(1,1), and A(1,1). Array section A(B,C) consists of the following elements:
A(1,2) A(1,1) A(1,1)
A(4,2) A(4,1) A(4,1)
An array section with a vector subscript that has two or more elements with the same value is called a
many-one array section. For example:
REAL A(3, 3), B(4)
INTEGER K(4)
! Vector K has repeated values
K = (/3, 1, 1, 2/)
! Sets all elements of A to 5.0
A = 5.0
B = A(3, K)
The array section A(3,K) consists of the elements:
A(3, 3) A(3, 1) A(3, 1) A(3, 2)
A many-one section must not appear on the left of the equal sign in an assignment statement, or as an input
item in a READ statement.
813
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Array sections
Array constructors
Array Constructors
An array constructor can be used to create and assign values to rank-one arrays and array constants. An
array constructor takes one of the following forms:
(/ac-spec/)
[ac-spec]
kind-selector Is ( [KIND=] n ).
do-variable Is the name of a scalar integer variable. Its scope is that of the
implied-DO loop.
expr Is a scalar integer expression. The expr1 and expr2 specify a range of
values for the loop; expr3 specifies the stride. The expr3 must be a
nonzero value; if it is omitted, it is assumed to be 1.
Description
If type-spec is omitted, each ac-value-list expression must have the same type and kind type parameters,
and the same length parameters. In this case, the array constructed has the same type as the ac-value-list
expressions.
814
Language Reference
If type-spec appears, it specifies the type and type parameters of the array constructor. Each ac-value-list
expression must be compatible with intrinsic assignment to a variable of this type and type parameters. Each
value is converted to the type parameters of the array constructor in accordance with the rules of intrinsic
assignment.
If type-spec specifies an intrinsic type, each ac-value-list expression must be of an intrinsic type that
conforms with a variable of type type-spec.
If type-spec specifies a derived type, all ac-value-list expressions must be of that derived type and must
have the same kind type parameter values as specified by type-spec.
A do-variable of an implied-DO that is in another implied-do must not appear as the do-variable of a
containing implied-DO.
If the sequence of values specified by the array constructor is empty (an empty array expression or the
implied-DO loop produces no values), the rank-one array has a size of zero.
An ac-value is interpreted as follows:
815
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
3
++a --++ab --++abc--++d --
If an implied-DO loop is contained within another implied-DO loop (nested), they cannot have the same DO
variable (do-variable).
To define arrays of more than one dimension, use the RESHAPE intrinsic function.
The following are alternative forms for array constructors:
• Square brackets (instead of parentheses and slashes) to enclose array constructors; for example, the
following two array constructors are equivalent:
INTEGER C(4)
C = (/4,8,7,6/)
C = [4,8,7,6]
• A colon-separated triplet (instead of an implied-DO loop) to specify a range of values and a stride; for
example, the following two array constructors are equivalent:
INTEGER D(3)
D = (/1:5:2/) ! Triplet form - also [1:5:2]
D = (/(I, I=1, 5, 2)/) ! implied-DO loop form
The stride is optional; it defaults to 1. For example, the following two array constructors are equivalent:
INTEGER E(5)
E = (/1:5/) ! Triplet form with default stride – also [1:5]
E = (/(I, I=1, 5)/) ! implied-DO loop form
Examples
The following example shows an array constructor using an implied-DO loop:
INTEGER ARRAY_C(10)
ARRAY_C = (/(I, I=30, 48, 2)/)
The values of ARRAY_C are the even numbers 30 through 48.
Implied-DO expressions and values can be mixed in the value list of an array constructor. For example:
INTEGER A(10)
A = (/1, 0, (I, I = -1, -6, -1), -7, -8 /)
! Mixed values and implied-DO in value list.
This example sets the elements of A to the values, in order, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8.
The following example shows an array constructor of derived type that uses a structure constructor:
TYPE EMPLOYEE
INTEGER ID
CHARACTER(LEN=30) NAME
END TYPE EMPLOYEE
TYPE(EMPLOYEE) CC_4T(4)
CC_4T = (/EMPLOYEE(2732,"JONES"), EMPLOYEE(0217,"LEE"), &
EMPLOYEE(1889,"RYAN"), EMPLOYEE(4339,"EMERSON")/)
The following example shows how the RESHAPE intrinsic function can be used to create a multidimensional
array:
816
Language Reference
TYPE EMPLOYEE
INTEGER AGE
CHARACTER (LEN = 60) NAME
END TYPE EMPLOYEE
The following equivalent lines use the above type to construct a derived-type array value:
See Also
Execution Control
Subscript triplets
Derived types
Structure constructors
Array Elements for details on array element order
Array Assignment Statements for details on another way to assign values to arrays
Declaration Statements for Arrays for details on array specifications
Coarrays
Coarrays and synchronization constructs are defined by the Fortran 2008 Standard and extended by Fortran
2018. These constructs support parallel programming using a Single Program Multiple Data (SPMD) model.
These features are not available on macOS* systems.
NOTE
Coarrays are only supported on 64-bit architectures.
You must specify compiler option [Q]coarray to enable coarrays in your program.
A Fortran program containing coarrays is interpreted as if it were replicated a fixed number of times and all
copies were executed asynchronously.
Each replication is called an "image", and each image has its own set of data objects. The number of images
is set at run-time, but it can also be set by a compiler option or an environment variable.
817
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The array syntax of Fortran is extended with additional trailing subscripts in square brackets to provide a
clear representation of references to data that is spread across images. References without square brackets
are to local data, so source code that can run independently is uncluttered. Any appearance of square
brackets indicates communication between images.
A team is an ordered set of images. Each image is identified by a unique image index, numbered from 1 to
the number of images on the team. The set of all images at program start up is called the initial team. A
team of images can be divided into subteams by executing a FORM TEAM statement. The team executing the
FORM TEAM statement is the parent team of th teams created by the FORM TEAM statement. Each child
team of a parent team is identified by a team number, which is a positive integer value specified on the
FORM TEAM statement. The initial team has no parent team.
While the program is executing, each image executes on a current team. At program start-up, the current
team is the initial team, which consists of all images. An image's current team changes when a CHANGE
TEAM statement is executed, causing the images of the current team to begin executing as images on
subteams of the current team; the subteam an image is on becomes its current team. When an END TEAM
statement is executed by an image, the image's current team becomes the team that was current just before
the corresponding CHANGE TEAM statement was executed. Image indices are relative to the current team,
unless a different team is specified.
Usually, each image resides on one processor. However, several images may share a processor and one
image can execute on a cluster.
To reference any array variable that is coindexed, a subscript list must be present. If no subscript list is
present, then the coindexed object must be a scalar.
Examples
Consider the following statement:
a(:) = b(:)[q]
In this case, the coarray b on image q is copied into coarray a on the executing image.
Consider the coindexed reference x[k]. If x is a rank 1 array, this reference to x on image k is incorrect
syntax: a subscript list must be present. The correct form is x(:)[k] to access the entire array x on image
k. If x is a scalar, then the syntax x[k] is correct.
See Also
Image Control Statements
Established Coarrays
Using Coarrays
Image Selectors
An image selector determines the image index for a coindexed object. It takes the following form:
lbracket cosubscript-list [ , selector-spec-list ] rbracket
cosubscript Is a scalar integer expression. Its value must be within the cobounds
for its codimension. The number of cosubscripts must be equal to the
corank of the object. If the lower bound is not specified, it is assumed
to be 1.
selector-spec Is TEAM=team-var
818
Language Reference
or TEAM_NUMBER=scalar-integer-expression
or STAT=stat-var
Considering the cobounds and bounds, respectively, the cosubscript list in an image selector determines the
image index in the same way that a subscript list in an array element determines the subscript order value.
The selector-specs may appear in any order in the selector-spec-list. TEAM= and TEAM_NUMBER must not
both be specified. A given selector-spec may appear at most once.
If TEAM= is specified, team-var must be the current or an ancestor team. If TEAM_NUMBER= appears and
the initial team is not the current team, scalar-integer-expression must have a value of -1 indicating the
initial team, or a positive integer value that identifies a sibling team of the current team. If the initial team is
the current team and TEAM_NUMBER appears, scalar-integer-expression must have the value -1. If TEAM or
TEAM_NUMBER is specified, the team of the image selector is the specified team; the image index specified
by the cosubscript list applies to the specified team. Otherwise, the team of the image selector is the current
team.
If the image selector specifies TEAM_NUMBER=, and the value of scalar-integer-expression is a positive
integer that is not that of the current team, the coarray object must be established on an ancestor team or
be an associating entity on the enclosing CHANGE TEAM construct. Otherwise, the coarray object must be
established in the specified team, or in an ancestor of that team.
An image selector must specify an image index value that is not greater than the number of images on the
specified team.
When a statement containing an image selector with STAT= specified is executed, stat-var becomes defined
with value STAT_FAILED_IMAGE defined in the intrinsic module ISO_FORTRAN_ENV if the object referenced
by the image selector is on a failed image. Otherwise, stat-var becomes defined with the value zero.
A stat-var in an image selector cannot depend on the evaluation of any other entity in the same statement.
An expression cannot depend on the value of any stat-var that is specified in the same statement. The value
of stat-var cannot depend on execution of any part of the statement, other than if the object is on a failed
image.
Examples
Assume that there are 16 images and the coarray C is declared as follows:
REAL :: C(15)[5,*]
C(:)[1,4] is valid because it selects image 16, but C(:)[2,4] is invalid because it selects image 17.
C(1)[2, 1, STAT=istatus] will cause istatus to become defined with the value STAT_FAILED_IMAGE if image 6
has failed; otherwise, istatus becomes defined with the value zero.
Consider the following program:
PROGRAM main
USE, INTRINSIC :: ISO_FORTRAN_ENV
TYPE (TEAM_TYPE) :: initial, odd_even
REAL :: ca[4:*], x, y, z
INTEGER :: me
initial = GET_TEAM (CURRENT_TEAM)
me = THIS_IMAGE ()
FORM TEAM (2-MOD(me, 2), odd_even, NEW_INDEX=(me+1)/2)
. . .
CHANGE TEAM (odd_even, ae[2,*]=>ca)
819
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
x = ca[2,3, TEAM=initial]
y = ae[2,4, TEAM_NUMBER=2]
x = ae[2,2]
. . .
END TEAM
. . .
END PROGRAM
Assuming there are 16 images, ca is then a 4x4 coarray. The FORM TEAM statement divides the images into
two teams. Team 1 contains images [1, 3, …, 15] and team 2 contains images [2, 4, …, 16] with image
indices on the new teams [1, 2, …, 8] respectively.
The CHANGE TEAM statement has an associating entity ae which is a 2x4 coarray on each team executing
the CHANGE TEAM construct. Within the CHANGE TEAM construct for team 1, ae[1, 1] is ca[1, 1], ae[2, 1] is
ca[3, 1], ae[1, 2] is ca[1, 2], ae[2,2] is ca[3,2], ae[1,3] is ca[1,3], ae[2, 3] is ca[3,3], ae[1,4] is ca[1,4] and
ae[2,4] is ca[3,4], and for team 2, ae[1, 1] is ca[2, 1], ae[2, 1] is ca[4, 1], ae[1, 2] is ca[2, 2], ae[2,2] is
ca[4,2], ae[1,3] is ca[2,3], ae[2, 3] is ca[4,3], ae[1,4] is ca[2,4] and ae[2,4] is ca[4,4].
The first statement in the CHANGE TEAM construct assigns x the value of ca[2,3] on the initial team, which is
on image 10 on the initial team. The second statement in the CHANGE TEAM construct assigns y the value of
ae[2, 2] on team number 2 that is on image 8 of team 2; it is the same as ca[4,4], that is on image 16 of
the initial team. The third statement in the CHANGE TEAM construct assigns z the value of ae[2,2]. ae[2,2] is
on image 4 of both team 1 and team 2; on team 1 it is the same as ca[3,2] on image 7 of the initial team,
and on team 2 it is the same as ca[4,2], which is on image 8 of the initial team.
See Also
Coarrays
ISO_FORTRAN_ENV Module
FORM TEAM
CHANGE TEAM
Established Coarrays
An established coarray is a coarray that is accessible using an image selector. The following can be said about
coarrays:
• Nonallocatable coarrays that have the SAVE attribute are established in the initial team.
• Allocated allocatable coarrays are established in the team that allocates them. Unallocated allocatable
coarrays are not established.
• An associating entity that appears in a coarray association in a CHANGE TEAM statement is a coarray that
is established in the team that becomes the current team after the CHANGE TEAM statement has been
executed.
• Nonallocatable coarrays that are host associated with a dummy arguments.
Deferred-Coshape Coarrays
A deferred-coshape(allocatable) coarray has cobounds that are determined by allocation or argument
association.
An allocatable coarray has the ALLOCATABLE attribute and a deferred-coshape specification.
A deferred-coshape specification is indicated by a colon (:).
The corank of an allocatable coarray is equal to the number of colons in its deferred-coshape specification.
The cobounds of an unallocated allocatable coarray are undefined. No part of such a coarray can be
referenced or defined; however, the coarray may appear as an argument to an intrinsic inquiry function.
The cobounds of an allocated allocatable coarray are those specified when the coarray is allocated.
The cobounds of an allocatable coarray are unaffected by any subsequent redefinition or undefinition of the
variables on which the cobounds' expressions depend.
820
Language Reference
See Also
Coarrays
Explicit-Coshape Coarrays
An explicit-coshape coarray is a named coarray that has its corank and cobounds declared by an explicit-
coshape specification.
An explicit-coshape specification takes the following form:
[[lower-cobound:] upper-cobound, ] ... [lower-cobound:] *
Examples
The following are examples of variables with coarray specifications (coarray-specs):
A [*]
AA [2:*]
B [2, 3, *]
C [3:5, -2:7, *]
See Also
Coarrays
821
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
To find the set of cosubscript indices for a coarray z that corresponds to the executing image on an ancestor
team described by the team variable team_var, specify THIS_IMAGE(z, team_var).
To find the cosubscript sub for a coarray z that corresponds to the executing image on an ancestor team
described by the team variable team_var, specify THIS_IMAGE (coarray, z, team_var).
To find the image index un the current team that corresponds to a set of cosubscript indices sub for a coarray
z, specify intrinsic function IMAGE_INDEX(z, sub).
To find the image index on the ancestor team described by team_var that corresponds to a set of cosubscript
indices sub for a coarray z, specify intrinsic function IMAGE_INDEX(z, sub, team_var).
To find the image index on the sibling team numbered 4 that corresponds to a set of cosubscript indices sub
for a coarray z, specify intrinsic function IMAGE_INDEX(z, sub, 4).
To find the number of images, specify intrinsic function NUM_IMAGES.
See Also
THIS_IMAGE
IMAGE_INDEX
NUM_IMAGES
See Also
NUM_IMAGES
Variable-Definition Context
A variable can appear in different contexts that imply definition or undefinition of the variable. A reference to
a function that returns a data pointer is permitted in such variable-definition contexts.
822
Language Reference
When a function returns a data pointer, that pointer is always associated with a variable that has the TARGET
attribute, either by pointer assignment or by allocation. If a reference to a function that returns a data
pointer appears in a variable-definition context, the definable target (with which the function result is
associated) is the variable that becomes defined or undefined.
This section describes the different variable-definition contexts in which a function reference returning a data
pointer can be used. It also describes the contexts in which data pointer function references are not allowed.
Assignment Statement
Function references returning a data pointer can be used on the left-hand side of an assignment statement.
References to type bound and generic procedures are also permitted on the left-hand side of an intrinsic
assignment. If the variable on the left-hand side is polymorphic, it must be an allocatable. Therefore, a
function returning a polymorphic pointer cannot be used on the left-hand side.
In the following example, function STORAGE returns a data pointer to either the module variable OUTSIDE or
to an element of VAR into which a value is stored:
MODULE TMOD
PUBLIC
INTEGER, PARAMETER :: N = 10
INTEGER, TARGET :: VAR(N)
INTEGER, TARGET :: OUTSIDE
CONTAINS
FUNCTION STORAGE(KEY) RESULT(LOC)
INTEGER, INTENT(IN) :: KEY
INTEGER, POINTER :: LOC
PROGRAM MAIN
USE TMOD
OUTSIDE = -1
STORAGE(1) = 11
STORAGE(0) = 0
PRINT *, VAR(1), OUTSIDE ! prints 11, 0
END
The following example shows generic resolution on the left-hand side of an assignment statement:
MODULE MYMODULE
TYPE :: VEC
INTEGER :: X(3)
CONTAINS
GENERIC :: GET => GETELEMENT, GETARRAY
PROCEDURE :: GETELEMENT
PROCEDURE :: GETARRAY
END TYPE VEC
CONTAINS
FUNCTION GETELEMENT( THIS, EL ) RESULT( P )
IMPLICIT NONE
CLASS(VEC), TARGET :: THIS
INTEGER, INTENT(IN) :: EL
INTEGER, POINTER :: P
823
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
P => THIS%X(EL)
END FUNCTION GETELEMENT
PROGRAM TEST
USE MYMODULE
IMPLICIT NONE
TYPE(VEC) :: MYVEC
INTEGER :: Y(3)
MYVEC%X = [1,2,3]
Y = [6,7,8]
! expected output 1 2 1 2 3
WRITE(6,*) MYVEC%GET(1), MYVEC%GET(2), MYVEC%GET()
Argument Association
A function reference returning a data pointer can be used as an actual argument in a reference to a
procedure with an explicit interface. If the corresponding dummy argument has the INTENT (OUT) or INTENT
(INOUT) attribute, then the pointer function is used in a variable definition context.
The following example uses the function STORAGE, which was defined in the above section "Assignment
Statement":
824
Language Reference
INTEGER, INTENT(OUT) :: X
X = X*5
END SUBROUTINE CHANGE_VAL
The following example shows that the target of the function pointer can get modified inside the subroutine
without using the dummy argument corresponding to the function reference:
MODULE M200C2
INTEGER, TARGET :: X = 42
CONTAINS
FUNCTION FX()
INTEGER, POINTER :: FX
FX => X
END FUNCTION
END MODULE
PROGRAM Q1
USE M200C2
CALL TEST(X, FX())
! note that corresponding dummy is not INTENT (OUT) or INTENT(INOUT).
! FX() is not used in a variable definition context but it still
! denotes a variable.
CONTAINS
SUBROUTINE TEST(A, B)
INTEGER, TARGET :: B
A = A*10
PRINT *, A, B ! prints 420 420
END SUBROUTINE
END PROGRAM
PROGRAM MAIN
INTEGER, TARGET :: DATA = 123
CONTAINS
FUNCTION FX1()
INTEGER, POINTER :: FX1
FX1 => DATA
END FUNCTION FX1
FUNCTION FX2()
CLASS(*),POINTER :: FX2
825
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
PROGRAM MAIN
INTEGER, TARGET :: DATA = 123
CONTAINS
FUNCTION FX1 ()
INTEGER, POINTER :: FX1
FX1 => DATA
END FUNCTION FX1
FUNCTION FX2()
CLASS(*),POINTER :: FX2
FX2 => DATA
END FUNCTION FX2
Input/Output Statements
A pointer function reference can be used as an input item in a READ statement.
A function reference returning a character pointer can be used as an internal file variable in a WRITE
statement.
A scalar integer pointer function reference can be an IOSTAT= or a SIZE= specifier in an input/output
statement. A scalar character pointer function reference can be an IOMSG= specifier in an input/output
statement.
A function returning a scalar pointer, whose datatype matches the specifier, can be specified in an INQUIRE
statement except for the three specifiers FILE=, ID=, and UNIT=.
A function returning a scalar integer pointer can be a NEWUNIT= specifier in an OPEN statement.
Consider the following example:
...
CHARACTER(50), TARGET :: V(33)
INTEGER, TARGET :: I
..
FUNCTION RET_CHAR(INDEX) RESULT (DCV)
CHARACTER(50), POINTER :: DCV
INTEGER :: INDEX
DCV => V(INDEX)
826
Language Reference
END FUNCTION
FUNCTION RET_INT() RESULT (P)
INTEGER, POINTER :: P
P => I
END FUNCTION
...
! an input item in a read stmt
READ (6, *) RET_INT()
READ 10, RET_INT()
STAT=, ERRMSG=, and ACQUIRED_LOCK= Specifiers and STAT and ERRMSG Arguments to
Intrinsic Procedures
A scalar integer pointer function reference can be used as a STAT= variable. A scalar character pointer
function reference can be used as an ERRMSG= variable.
STAT= and ERRMSG= are allowed in CHANGE TEAM, END TEAM, CRITICAL, EVENT POST, EVENT WAIT, FORM
TEAM, SYNC ALL, SYNC IMAGES, SYNC MEMORY, SYNC TEAM, LOCK, UNLOCK, ALLOCATE, and DEALLOCATE
statements.
A STAT= specifier is allowed in an image selector. Collective and atomic procedures have an optional STAT
argument, and the MOVE_ALLOC intrinsic has optional STAT and ERRMSG arguments.
A scalar logical pointer function reference can be an ACQUIRED_LOCK= specifier in a LOCK statement.
The following example uses RET_CHAR and RET_INT, which were defined in the above section "Input/Output
Statements":
TYPE(EVENT_TYPE) :: ET[*]
TYPE(LOCK_TYPE) :: LT[*]
INTEGER, POINTER :: AR(:)
ALLOCATE(AR(2), STAT=RET_INT())
DEALLOCATE(AR, STAT=RET_INT())
827
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Disallowed Contexts
The Fortran Standard defines both a "variable" and a "variable name". For function F, F is a variable name;
F(7) is a function. If F returns a data pointer, F(7) is a variable and can be used in a variable-definition
context.
For the following variable-definition contexts, the Fortran Standard specifies that a "variable name" must be
used and not a "variable":
• The pointer object in a NULLIFY statement
• A data pointer object or procedure pointer object in a pointer assignment statement
• The DO variable in a DO statement or an implied DO construct
• A variable name in a NAMELIST statement if the NAMELIST group name appears in a NML= specifier in a
READ statement
• The object in an ALLOCATE or DEALLOCATE statement
• An event variable in an EVENT POST or EVENT WAIT statement
• The lock variable in a LOCK or UNLOCK statement
A function reference can return a pointer to any data object, even one that cannot be stored into, for
example, a USE associated PROTECTed object or a constant. This will not be caught at compile time. It is
possible that the target of the pointer function is a local variable from a different subprogram or a private
USE associated variable, in which case the pointer returned has an undefined association status.
MODULE TMOD
PUBLIC
TYPE PDT(K, L)
INTEGER, KIND :: K
INTEGER, LEN :: L
INTEGER :: FIELD(L)
END TYPE PDT
828
Expressions and Assignment Statements
END MODULE
PROGRAM MAIN
USE TMOD
IMPLICIT NONE
TYPE(PDT(4,2)), TARGET :: PDTOBJ1, OBJ
TYPE(PDT(2,2)), POINTER :: ACTARG
CHARACTER(10), TARGET :: C1
BAR() = PDT(4,2)((/5,3/))
PRINT *, PDTOBJ1%FIELD ! prints 5 3
AUTO_RES(ACTARG) = PDT(4,2)((/6,4/))
PRINT *, PDTOBJ1%FIELD ! prints 6 4
AUTO_CHAR(10) = "TEST"
PRINT *, C1 ! prints TEST
CONTAINS
FUNCTION BAR() RESULT(LOC)
TYPE(PDT(4,2)), POINTER :: LOC
LOC => PDTOBJ1
END FUNCTION
FUNCTION AUTO_CHAR(DUM1) RESULT(LOC)
INTEGER, INTENT(IN) :: DUM1
CHARACTER(DUM1), POINTER :: LOC
LOC => C1
END FUNCTION
Expressions
An expression represents either a data reference or a computation, and is formed from operators, operands,
and parentheses. The result of an expression is either a scalar value or an array of scalar values.
If the value of an expression is of intrinsic type, it has a kind type parameter. (If the value is of intrinsic type
CHARACTER, it also has a length parameter.) If the value of an expression is of derived type, it has no kind
type parameter.
An operand is a scalar or array. An operator can be either intrinsic or defined. An intrinsic operator is known
to the compiler and is always available to any program unit. A defined operator is described explicitly by a
user in a function subprogram and is available to each program unit that uses the subprogram.
829
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Arrays
Derived data types
Defining Generic Operators for details on function subprograms that define operators
POINTER statement for details on pointers
Numeric Expressions
Numeric expressions express numeric computations, and are formed with numeric operands and numeric
operators. The evaluation of a numeric operation yields a single numeric value.
The term numeric includes logical data, because logical data is treated as integer data when used in a
numeric context. The default for .TRUE. is -1; .FALSE. is 0. Note that the default can change if compiler
option fpscomp logicals is used.
Numeric operators specify computations to be performed on the values of numeric operands. The result is a
scalar numeric value or an array whose elements are scalar numeric values. The following are numeric
operators:
Operator Function
** Exponentiation
* Multiplication
/ Division
830
Language Reference
Operator Function
Unary operators operate on a single operand. Binary operators operate on a pair of operands. The plus and
minus operators can be unary or binary. When they are unary operators, the plus or minus operators precede
a single operand and denote a positive (identity) or negative (negation) value, respectively. The
exponentiation, multiplication, and division operators are binary operators.
Valid numeric operations must have results that are defined by the arithmetic used by the processor. For
example, raising a negative-valued base to a real power is invalid.
Numeric expressions are evaluated in an order determined by a precedence associated with each operator, as
follows (see also Summary of Operator Precedence):
Operator Precedence
** Highest
* and / .
Unary + and - .
Operators with equal precedence are evaluated in left-to-right order. However, exponentiation is evaluated
from right to left. For example, A**B**C is evaluated as A**(B**C). B**C is evaluated first, then A is raised
to the resulting power.
Normally, two operators cannot appear together. However, Intel® Fortran allows two consecutive operators if
the second operator is a plus or minus.
Examples
In the following example, the exponentiation operator is evaluated first because it takes precedence over the
multiplication operator:
A**B*C is evaluated as (A**B)*C
Ordinarily, the exponentiation operator would be evaluated first in the following example. However, because
Intel Fortran allows the combination of the exponentiation and minus operators, the exponentiation operator
is not evaluated until the minus operator is evaluated:
A**-B*C is evaluated as A**(-(B*C))
Note that the multiplication operator is evaluated first, since it takes precedence over the minus operator.
When consecutive operators are used with constants, the unary plus or minus before the constant is treated
the same as any other operator. This can produce unexpected results. In the following example, the
multiplication operator is evaluated first, since it takes precedence over the minus operator:
X/-15.0*Y is evaluated as X/-(15.0*Y)
See Also
fpscomp compiler option
831
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
In the following examples, the numbers below the operators indicate a possible order of evaluation.
Alternative evaluation orders are possible in the first three examples because they contain operators of equal
precedence that are not enclosed in parentheses. In these cases, the compiler is free to evaluate operators of
equal precedence in any order, as long as the result is the same as the result gained by the algebraic left-to-
right order of evaluation.
4 + 3 * 2 - 6/2 = 7
^ ^ ^ ^
2 1 4 3
(4 + 3) * 2 - 6/2 = 11
^ ^ ^ ^
1 2 4 3
(4 + 3 * 2 - 6)/2 = 2
^ ^ ^ ^
2 1 3 4
((4 + 3) * 2 - 6)/2 = 4
^ ^ ^ ^
1 2 3 4
Expressions within parentheses are evaluated according to the normal order of precedence. In expressions
containing nested parentheses, the innermost parentheses are evaluated first.
Nonessential parentheses do not affect expression evaluation, as shown in the following example:
4 + (3 * 2) - (6/2)
However, using parentheses to specify the evaluation order is often important in high-accuracy numerical
computations. In such computations, evaluation orders that are algebraically equivalent may not be
computationally equivalent when processed by a computer (because of the way intermediate results are
rounded off).
Parentheses can be used in argument lists to force a given argument to be treated as an expression, rather
than as the address of a memory item.
LOGICAL(2) .
LOGICAL(4) .
LOGICAL(8) .
INTEGER(1) .
INTEGER(2) .
INTEGER(4) .
INTEGER(8) .
REAL(4) .
REAL(8)1 .
REAL(16) .
832
Language Reference
COMPLEX(4) .
COMPLEX(8)2 .
COMPLEX(16) Highest
1 DOUBLE PRECISION
2 DOUBLE COMPLEX
The data type of the value produced by an operation on two numeric operands of different data types is the
data type of the highest-ranking operand in the operation. For example, the value resulting from an
operation on an integer and a real operand is of real type. However, an operation involving a COMPLEX(4) or
COMPLEX(8) data type and a DOUBLE PRECISION data type produces a COMPLEX(8) result.
The data type of an expression is the data type of the result of the last operation in that expression, and is
determined according to the following conventions:
• Integer operations: Integer operations are performed only on integer operands. (Logical entities used in a
numeric context are treated as integers.) In integer arithmetic, any fraction resulting from division is
truncated, not rounded. For example, the result of 9/10 is 0, not 1.
• Real operations: Real operations are performed only on real operands or combinations of real, integer, and
logical operands. Any integer operands present are converted to real data type by giving each a fractional
part equal to zero. The expression is then evaluated using real arithmetic. However, in the statement Y =
(I /J)*X, an integer division operation is performed on I and J, and a real multiplication is performed on
that result and X.
If one operand is a higher-precision real (REAL(8) or REAL(16)) type, the other operand is converted to
that higher-precision real type before the expression is evaluated.
When a single-precision real operand is converted to a double-precision real operand, low-order binary
digits are set to zero. This conversion does not increase accuracy; conversion of a decimal number does
not produce a succession of decimal zeros. For example, a REAL variable having the value 0.3333333 is
converted to approximately 0.3333333134651184D0. It is not converted to either
0.3333333000000000D0 or 0.3333333333333333D0.
• Complex operations: In operations that contain any complex operands, integer operands are converted to
real type, as previously described. The resulting single-precision or double-precision operand is
designated as the real part of a complex number and the imaginary part is assigned a value of zero. The
expression is then evaluated using complex arithmetic and the resulting value is of complex type.
Operations involving a COMPLEX(4) or COMPLEX(8) operand and a DOUBLE PRECISION operand are
performed as COMPLEX(8) operations; the DOUBLE PRECISION operand is not rounded.
These rules also generally apply to numeric operations in which one of the operands is a constant. However,
if a real or complex constant is used in a higher-precision expression, additional precision will be retained for
the constant. The effect is as if a DOUBLE PRECISION (REAL(8)) or REAL(16) representation of the constant
were given. For example, the expression 1.0D0 + 0.3333333 is treated as if it is 1.0D0 +
dble(0.3333333).
Character Expressions
A character expression consists of a character operator (//) that concatenates two operands of type
character. The evaluation of a character expression produces a single value of that type.
The result of a character expression is a character string whose value is the value of the left character
operand concatenated to the value of the right operand. The length of a character expression is the sum of
the lengths of the values of the operands. For example, the value of the character expression 'AB'//'CDE'
is 'ABCDE', which has a length of five.
833
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Parentheses do not affect the evaluation of a character expression; for example, the following character
expressions are equivalent:
('ABC'//'DE')//'F'
'ABC'//('DE'//'F')
'ABC'//'DE'//'F'
Each of these expressions has the value ' ABCDEF'.
If a character operand in a character expression contains blanks, the blanks are included in the value of the
character expression. For example, 'ABC '//'D E'//'F ' has a value of 'ABC D EF '.
Relational Expressions
A relational expression consists of two or more expressions whose values are compared to determine
whether the relationship stated by the relational operator is satisfied. The following are relational operators:
Operator Relationship
.EQ. or == Equal to
The result of the relational expression is .TRUE. if the relation specified by the operator is satisfied; the result
is .FALSE. if the relation specified by the operator is not satisfied.
Relational operators are of equal precedence. Numeric operators and the character operator // have a higher
precedence than relational operators.
In a numeric relational expression, the operands are numeric expressions. Consider the following example:
APPLE+PEACH > PEAR+ORANGE
This expression states that the sum of APPLE and PEACH is greater than the sum of PEAR and ORANGE. If
this relationship is valid, the value of the expression is .TRUE.; if not, the value is .FALSE.
Operands of type complex can only be compared using the equal operator (== or .EQ.) or the not equal
operator (/= or .NE.). Complex entities are equal if their corresponding real and imaginary parts are both
equal.
In a character relational expression, the operands are character expressions. In character relational
expressions, less than (< or .LT.) means the character value precedes in the ASCII collating sequence, and
greater than (> or .GT.) means the character value follows in the ASCII collating sequence. For example:
'AB'//'ZZZ' .LT. 'CCCCC'
This expression states that 'ABZZZ' is less than 'CCCCC'. In this case, the relation specified by the operator
is satisfied, so the result is .TRUE..
Character operands are compared one character at a time, in order, starting with the first character of each
operand. If the two character operands are not the same length, the shorter one is padded on the right with
blanks until the lengths are equal; for example:
'ABC' .EQ. 'ABC '
'AB' .LT. 'C'
834
Language Reference
The first relational expression has the value .TRUE. even though the lengths of the expressions are not equal,
and the second has the value .TRUE. even though 'AB' is longer than 'C'.
A relational expression can compare two numeric expressions of different data types. In this case, the value
of the expression with the lower-ranking data type is converted to the higher-ranking data type before the
comparison is made.
See Also
Data Type of Numeric Expressions
Logical Expressions
A logical expression consists of one or more logical operators and logical, numeric, or relational operands.
The following are logical operators:
Periods cannot appear consecutively except when the second operator is .NOT. For example, the following
logical expression is valid:
A+B/(A-1) .AND. .NOT. D+B/(D-1)
835
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Summary of Operator Precedence
Defined Operations
When operators are defined for functions, the functions can then be referenced as defined operations.
The operators are defined by using a generic interface block specifying OPERATOR, followed by the defined
operator (in parentheses).
A defined operation is not an intrinsic operation. However, you can use a defined operation to extend the
meaning of an intrinsic operator.
For defined unary operations, the function must contain one argument. For defined binary operations, the
function must contain two arguments.
Interpretation of the operation is provided by the function that defines the operation.
A Standard Fortran defined operator can contain up to 31 letters, and is enclosed in periods (.), or it may be
an intrinsic operator.
An intrinsic operator can be followed by a defined unary operator.
The result of a defined operation can have any type. The type of the result (and its value) must be specified
by the defining function.
Examples
The following examples show expressions containing defined operators:
.COMPLEMENT. A
X .PLUS. Y .PLUS. Z
M * .MINUS. N
See Also
Defining Generic Operators
836
Language Reference
Numeric ** .
Numeric * or / .
Numeric Unary + or - .
Numeric Binary + or - .
Character // .
Logical .NOT. .
Logical .AND. .
Logical .OR. .
Constant Expressions
A constant expression is an expression that you can use as a kind type parameter, a named constant, or to
specify an initial value for an entity. It is evaluated when a program is compiled.
In a constant expression, each operation is intrinsic and each primary is one of the following:
• A constant or subobject of a constant
• A specification inquiry where each designator or function argument is one of the following:
• A constant expression
• A variable whose properties inquired about are not assumed, deferred, or defined by an expression
that is not a constant expression
• A reference to the transformational function IEEE_SELECTED_REAL_KIND from the intrinsic module
IEEE_ARITHMETIC, where each argument is a constant expression
• A kind type parameter of the derived type being defined
837
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• A DO variable within an array constructor where each scalar integer expression of the corresponding DO
loop is an constant expression
• Another constant expression enclosed in parentheses, where each subscript, section subscript, substring
starting and ending point, and type parameter value is a constant expression
If a constant expression invokes an inquiry function for a type parameter or an array bound of an object, the
type parameter or array bound must be specified in a prior specification statement (or to the left of the
inquiry function in the same statement). The previous specification cannot be in the same entity declaration.
If a reference to a generic entity is included in a constant expression that is in the specification part of a
module or submodule, that generic entity shall have no specific procedures defined subsequent to the
constant expression in the module or submodule.
Examples
Valid constant Expressions
-1 + 3
7_2
SELECTED_INT_KIND (2)
See Also
Array constructors
Specification Expressions
Structure constructors
Intrinsic procedures
Specification Expressions
A specification expression is a restricted scalar integer expression that you can use in specifications such as
length type parameters and array bounds. Unless a specification expression is in an interface body, the
specification part of a subprogram or BLOCK construct, a derived type definition, or the declaration type spec
of a FUNCTION statement, it must be a constant expression.
In a restricted expression, each operation is intrinsic or defined by a specification function and each primary
is one of the following:
• A constant or subobject of a constant
• An object designator with a base object that is one of the following:
• A dummy argument that does not have the OPTIONAL or INTENT (OUT) attribute
• In a common block
• Made accessible by use or host association
• A local variable of the procedure containing the BLOCK construct in which the restricted expression
appears
• A local variable of an outer BLOCK construct containing the BLOCK construct in which the restricted
expression appears
• An array constructor where each element and each scalar integer expression of each DO loop is a
restricted expression
838
Language Reference
NOTE
The requirement that specification functions be pure ensures that they cannot have side effects that
could affect other objects being declared in the same specification.
The restriction that specification functions cannot be internal ensures that they cannot use host
association to inquire about other objects being declared in the same specification. The restriction
against recursion prevents the creation of a new instance of a procedure during construction of that
procedure.
A variable in a specification expression must have its type and type parameters (if any) specified in one of
the following ways:
• By a previous declaration in the same scoping unit
• By the implicit typing rules currently in effect for the scoping unit
• By host or use association
If a variable in a specification expression is typed by the implicit typing rules, its appearance in any
subsequent type declaration statement must confirm the implied type and type parameters.
If a specification expression includes a specification inquiry that depends on a type parameter or an array
bound or cobound of an entity specified in the same specification statement, the type parameter or array
bound or cobound must be specified in a previous specification statement (or to the left of the inquiry
839
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
function in the same statement). The previous specification cannot be in the same entity declaration unless
the specification inquiry appears in an initialization. If a specification expression includes a reference to the
value of an element of an array specified in the same specification statement, the array must be completely
specified in previous declarations.
In the specification part of a module or submodule, if a specification expression includes a reference to a
generic entity, that generic entity must have no specific procedures defined in the module or submodule
subsequent to the specification expression.
In a specification expression, the number of arguments for a function reference is limited to 255.
Examples
The following shows valid specification expressions:
See Also
Array constructors
Structure constructors
Constant Expressions
Intrinsic procedures
Implicit typing rules
Use and host association
PURE procedures
Assignments
An assignment causes variables to be defined or redefined.
Assignment is specified by the following:
• An intrinsic assignment statement
This lets you assign a value to a nonpointer variable.
• A defined assignment statement
This lets you specify an assignment operation.
• pointer assignment
This lets you associate a pointer with a target.
• masked array assignment
This kind of assignment is denoted by a WHERE construct or statement. It lets you perform an array
operation on selected elements in an array.
• element array assignment
This kind of assignment is denoted by a FORALL construct or statement. It is a generalization of masked
array assignment. It allows more general array shapes to be assigned, especially if it is used in construct
form.
Note that the ASSIGN statement assigns a label to an integer variable. It is discussed elsewhere.
840
Language Reference
expression Is of intrinsic type or the same derived type as variable. Its shape
must conform with variable. If necessary, it is converted to the same
type and kind as variable.
Description
Before a value is assigned to the variable, the expression part of the assignment statement and any
expressions within the variable are evaluated. No definition of expressions in the variable can affect or be
affected by the evaluation of the expression part of the assignment statement.
NOTE
When the run-time system assigns a value to a scalar integer or character variable and the variable is
shorter than the value being assigned, the assigned value may be truncated and significant bits (or
characters) lost. This truncation can occur without warning, and can cause the run-time system to
pass incorrect information back to the program.
See Also
Arrays
Pointers
Derived data types
Defining Generic Assignment for details on subroutine subprograms that define assignment
Examples of Intrinsic Assignment to Polymorphic Variables
841
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If the expression (E) is of type logical, it is first converted to type integer as follows:
• If E evaluates to .TRUE. the result is -1 or 1 depending on the setting of the compiler option
fpscomp logicals
• Otherwise the result is 0
The result of this conversion is then interpreted according to the above table.
Examples
Valid Numeric Assignment Statements
BETA = -1./(2.*X)+A*A /(4.*(X*X))
PI = 3.14159
SUM = SUM + 1.
842
Language Reference
See Also
INT
REAL
DBLE
QEXT
CMPLX
AIMAG
Examples
The following examples demonstrate valid logical assignment statements:
PAGEND = .FALSE.
PRNTOK = LINE .LE. 132 .AND. .NOT. PAGEND
ABIG = A.GT.B .AND. A.GT.C .AND. A.GT.D
LOGICAL_VAR = 123 ! Assigns .TRUE. to LOGICAL_VAR
Examples
Valid Character Assignment Statements. (All variables are of type character.)
FILE = 'PROG2'
REVOL(1) = 'MAR'//'CIA'
LOCA(3:8) = 'PLANT5'
TEXT(I,J+1)(2:N-1) = NAME//X
843
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Examples
The following example shows derived-type assignment:
TYPE DATE
LOGICAL(1) DAY, MONTH
INTEGER(2) YEAR
END TYPE DATE
TYPE(APPOINTMENT) MEETING
DO I = 1,7
CALL GET_DATE(TODAY)
THIS_WEEK(I) = TODAY
END DO
MEETING%APP_DATE = TODAY
See Also
Derived types
Pointer assignments
Examples
844
Language Reference
X = Y
The corresponding elements of Y are assigned to those of X element by element; the first element of Y is
assigned to the first element of X, and so forth. The processor can perform the element-by-element
assignment in any order.
The following example shows a scalar assigned to an array:
B(C+1:N, C) = 0
This sets the elements B (C+1,C), B (C+2,C),...B (N,C) to zero.
The following example causes the values of the elements of array A to be reversed:
REAL A(20)
...
A(1:20) = A(20:1:-1)
See Also
Arrays
Array constructors
WHERE for details on masked array assignment
FORALL for details on element array assignment
Type type2
End type
845
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If variable is the same type and size as expr then just do the assignment.
Class(type1), allocatable :: var
Class(type1), allocatable :: expr
Allocate(expr, source=type1())
Allocate(var, source=type1())
var = expr ! No deallocation of var, simple assignment
Example of same type and different size:
If variable is the same type as expr but their sizes are not the same then deallocate var, reallocate it, and
then do the assignment.
Class(type1), allocatable :: var(:)
Class(type1), allocatable :: expr(:)
Allocate(var(5), source=type1())
Allocate(expr(6), source=type1())
var = expr ! var deallocated and then
! allocated to the size of expr - then
! the usual assignment is performed
Example of different types or shape and same size:
If variable and expr are of different types or shapes but of the same size, then do the assignment and update
the type/bounds of var to be same as that of expr, only if type1 and type3 are type compatible.
846
Language Reference
Otherwise, allocate var with same dynamic type, shape, and size as expr.
See Also
Subroutines
Derived data types
Defining Generic Assignment for details on subroutine subprograms that define assignment
Numeric Expressions for details on intrinsic operations
Character Expressions for details on intrinsic operations
Pointer Assignments
In ordinary assignment involving pointers, the pointer is an alias for its target. In pointer assignment, the
pointer is associated with a target. If the target is undefined or disassociated, the pointer acquires the same
status as the target. Pointer assignment has the following form:
pointer-object [ (s-spec) ] => target
847
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
target Is a variable or expression. Its type and kind parameters, and rank
must be the same as pointer-object unless bounds remapping is
specified. It cannot be an array section with a vector subscript.
Description
If the target is a variable, it must have the POINTER or TARGET attribute, or be a subobject whose parent
object has the TARGET attribute.
If the target is an expression, the result must be a pointer.
If the target is not a pointer (it has the TARGET attribute), the pointer object is associated with the target.
If the target is a pointer (it has the POINTER attribute), its status determines the status of the pointer object,
as follows:
• If the pointer is associated, the pointer object is associated with the same object as the target
• If the pointer is disassociated, the pointer object becomes disassociated
• If the pointer is undefined, the pointer object becomes undefined
A pointer must not be referenced or defined unless it is associated with a target that can be referenced or
defined.
When pointer assignment occurs, any previous association between the pointer object and a target is
terminated.
Pointers can also be assigned for a pointer structure component by execution of a derived-type intrinsic
assignment statement or a defined assignment statement.
Pointers can also become associated by using the ALLOCATE statement to allocate the pointer.
Pointers can become disassociated by deallocation, nullification of the pointer (using the DEALLOCATE or
NULLIFY statements), or by reference to the NULL intrinsic function.
Pointer assignment for arrays allows lower bounds to be specified. The specified lower bounds can be any
scalar integer expressions.
Remapping of the elements of a rank-one array is permitted. The mapping is in array-element order and the
target array must be large enough. The specified bounds may be any scalar integer expressions.
Examples
The following are examples of pointer assignments:
INTEGER, POINTER :: P, N
INTEGER, TARGET :: M
INTEGER S
M = 14
N => M ! N is associated with M
P => N ! P is associated with M through N
S = P + 5
The value assigned to S is 19 (14 + 5).
848
Specification Statements
You can use the intrinsic function ASSOCIATED to find out if a pointer is associated with a target or if two
pointers are associated with the same target. For example:
See Also
Arrays
ALLOCATE statement
DEALLOCATE statement
NULLIFY statement
NULL intrinsic function
POINTER attribute
TARGET attribute
Defined assignments
Intrinsic Assignments for details on derived-type intrinsic assignments
Specification Statements
A specification statement is a nonexecutable statement that declares the attributes of data objects. In
Standard Fortran, many of the attributes that can be defined in specification statements can also be
optionally specified in type declaration statements.
The following are specification statements:
• Type Declarations
Explicitly specify the properties (for example: data type, rank, and extent) for data objects or functions.
• ALLOCATABLE attribute and statement
849
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Specifies that an array is an allocatable array with a deferred shape. The shape of an allocatable array is
determined when an ALLOCATE statement is executed, dynamically allocating space for the array.
• ASYNCHRONOUS attribute and statement
Specifies that a variable can be used for asynchronous input and output.
• AUTOMATIC and STATIC attributes and statements
Control the storage allocation of variables in subprograms.
• BIND attribute and statement
Specifies that an object is interoperable with C and has external linkage.
• CODIMENSION attribute and statement
Specifies that an entity is a coarray.
• COMMON statement
Defines one or more contiguous areas, or blocks, of physical storage (called common blocks) that can be
accessed by any of the scoping units in an executable program. COMMON statements also define the
order in which variables and arrays are stored in each common block, which can prevent misaligned data
items.
• CONTIGUOUS attribute and statement
Specifies that the target of a pointer or an assumed-sized array is contiguous.
• DATA statement
Assigns initial values to variables before program execution.
• DIMENSION attribute and statement
Specifies that an object is an array, and defines the shape of the array.
• EQUIVALENCE statement
Specifies that a storage area is shared by two or more objects in a program unit. This causes total or
partial storage association of the objects that share the storage area.
• EXTERNAL attribute and statement
Allows an external or dummy procedure to be used as an actual argument.
• IMPLICIT statement
Overrides the default implicit typing rules for names.
• INTENT attribute and statement
Specifies the intended use of one or more dummy arguments.
• INTRINSIC attribute and statement
Allows the specific name of an intrinsic procedure to be used as an actual argument. Certain specific
function names cannot be used. For more information, see Intrinsic Functions Not Allowed as Actual
Arguments.
• NAMELIST statement
Associates a name with a list of variables. This group name can be referenced in some input/output
operations.
• OPTIONAL attribute and statement
Allows dummy arguments to be omitted in a procedure reference.
• PARAMETER attribute and statement
Defines a named constant.
• POINTER attribute and statement
Specifies that an object or a procedure is a pointer (a dynamic variable).
• PRIVATE and PUBLIC and attributes and statements
Specifies the accessibility of entities in a module. (These attributes are also called accessibility attributes.)
• PROTECTED attribute and statement
Specifies limitations on the use of module entities.
• SAVE attribute and statement
Causes the values and definition of objects to be retained after execution of a RETURN or END statement
in a subprogram.
850
Language Reference
See Also
BLOCK DATA statement
PROGRAM statement
Derived data types
DATA
Initialization expressions
Intrinsic Data Types
Implicit Typing Rules
Specification of Data Type
Type Declarations
A type declaration is a nonexecutable statement specifying the data type of one or more variables. The
declaration can be specified in an INTEGER, REAL, DOUBLE PRECISION, COMPLEX, DOUBLE COMPLEX,
CHARACTER, LOGICAL, or TYPE statement. A type declaration statement may also specify attributes for the
variables.
BYTE1
LOGICAL2
INTEGER3
REAL4
851
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
COMPLEX5
In noncharacter type declarations, you can optionally specify the name of the data object or function as v*n,
where n is the length (in bytes) of v. The length specified overrides the length implied by the data type.
The value for n must be a valid length for the type of v. The type specifiers BYTE, DOUBLE PRECISION, and
DOUBLE COMPLEX have one valid length, so the n specifier is invalid for them.
For an array specification, the n must be placed immediately following the array name; for example, in an
INTEGER declaration, IVEC*2(10) is an INTEGER(2) array of 10 elements.
Note that certain compiler options can affect the defaults for numeric and logical data types.
Examples
In a noncharacter type declaration, a subsequent kind parameter overrides any initial kind parameter. For
example, consider the following statements:
See Also
Type Declarations for details on the general form and rules for type declarations
len Is a length type parameter. It can have one of the following values:
852
Language Reference
Description
An automatic object can appear in a character declaration. The object cannot be a dummy argument, and its
length must be declared with a specification expression that is not a constant expression.
The length specified for a character-valued statement function or statement function dummy argument of
type character must be an integer constant expression.
When an asterisk length specification *(*) is used for a function name or dummy argument, it assumes the
length of the corresponding function reference or actual argument. Similarly, when an asterisk length
specification is used for a named constant, the name assumes the length of the actual constant it represents.
For example, STRING assumes a 9-byte length in the following statements:
CHARACTER*(*) STRING
PARAMETER (STRING = 'VALUE IS:')
A function name must not be declared with a * length unless it is of type CHARACTER and is the name of the
result of an external function or the name of a dummy function.
A function name declared with a * length must not be an array, a pointer, recursive, elemental, or pure.
If the CHARACTER type declaration statement specifies a colon (:) length, the length type parameter is a
deferred type parameter. An entity or component with a deferred type parameter must specify the
ALLOCATABLE or POINTER attribute. A deferred type parameter is a length type parameter whose value can
change during execution of the program.
The obsolete form is an obsolescent feature in the Fortran standard.
Examples
In the following example, the character string last_name is given a length of 20:
853
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
In the following example, stri is given a length of 12, while the other two variables retain a length of 8.
CHARACTER*32 string1
CHARACTER string2*32
The following examples show ways to specify strings of unknown length:
CHARACTER string3*(*)
CHARACTER*(*) string4
The following example declares an array NAMES containing 100 32-character elements, an array SOCSEC
containing 100 9-character elements, and a variable NAMETY that is 10 characters long and has an initial
value of 'ABCDEFGHIJ'.
SUBROUTINE AUTO_NAME(NAME1)
CHARACTER(LEN = *) NAME1
CHARACTER(LEN = LEN(NAME1)) NAME2
The following example shows the handling of a deferred-length CHARACTER variables:
See Also
Obsolescent Language Features in the Fortran Standard
Data Types of Scalar Variables
Assumed-Length Character Arguments for details on asterisk length specifications
Type Declarations for details on the general form and rules for type declaration statements
854
Language Reference
Examples
The following are examples of derived-type declarations:
TYPE(EMPLOYEE) CONTRACT
...
TYPE(SETS), DIMENSION(:,:), ALLOCATABLE :: SUBSET_1
The following example shows a public type with private components:
TYPE LIST_ITEMS
PRIVATE
...
TYPE(LIST_ITEMS), POINTER :: NEXT, PREVIOUS
END TYPE LIST_ITEMS
See Also
TYPE
Use and host association
PUBLIC
PRIVATE
Structure constructors
Type Declarations for details on the general form and rules for type declarations
The array specification can be appended to the name of the array when the array is declared.
Examples
The following examples show array declarations:
SUBROUTINE SUB(N, C, D, Z)
REAL, DIMENSION(N, 15) :: IARRY ! An explicit-shape array
REAL C(:), D(0:) ! An assumed-shape array
REAL, POINTER :: B(:,:) ! A deferred-shape array pointer
REAL, ALLOCATABLE, DIMENSION(:) :: K ! A deferred-shape allocatable array
REAL :: Z(N,*) ! An assumed-size array
INTEGER, PARAMETER :: R(*) = [1,2,3] ! An implied-shape constant array
See Also
Type Declarations for details on the general form and rules for type declaration statements
Explicit-Shape Specifications
An explicit-shape array is declared with explicit values for the bounds in each dimension of the array. An
explicit-shape specification takes the following form:
855
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Automatic Arrays
An automatic array is an explicit-shape array that is a local variable. Automatic arrays are only allowed in
function and subroutine subprograms, and are declared in the specification part of the subprogram. At least
one bound of an automatic array must be a nonconstant specification expression. The bounds are determined
when the subprogram is called.
The following example shows automatic arrays:
856
Language Reference
...
INTEGER AUTO_ARRAY3(20, B*A/2)
END SUBROUTINE
Consider the following:
Adjustable Arrays
An adjustable array is an explicit-shape array that is a dummy argument to a subprogram. At least one
bound of an adjustable array must be a nonconstant specification expression. The bounds are determined
when the subprogram is called.
The array specification can contain integer variables that are either dummy arguments or variables in a
common block.
When the subprogram is entered, each dummy argument specified in the bounds must be associated with an
actual argument. If the specification includes a variable in a common block, the variable must have a defined
value. The array specification is evaluated using the values of the actual arguments, as well as any constants
or common block variables that appear in the specification.
The size of the adjustable array must be less than or equal to the size of the array that is its corresponding
actual argument.
To avoid possible errors in subscript evaluation, make sure that the bounds expressions used to declare
multidimensional adjustable arrays match the bounds as declared by the caller.
In the following example, the function calculates the sum of the elements of a rank-two array. Notice how the
dummy arguments M and N control the iteration:
FUNCTION THE_SUM(A, M, N)
DIMENSION A(M, N)
SUMX = 0.0
DO J = 1, N
DO I = 1, M
SUMX = SUMX + A(I, J)
END DO
END DO
THE_SUM = SUMX
END FUNCTION
The following are examples of calls on THE_SUM:
DIMENSION ARRAY(9,5)
L = 9
M = 5
CALL SUB(ARRAY,L,M)
857
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
END
SUBROUTINE SUB(X,I,J)
DIMENSION X(-I/2:I/2,J)
X(I/2,J) = 999
J = 1
I = 2
END
The assignments to I and J do not affect the declaration of adjustable array X as X(-4:4,5) on entry to
subroutine SUB.
See Also
Specification expressions
Assumed-Shape Specifications
An assumed-shape array is a dummy argument array that assumes the shape of its associated actual
argument array. An assumed-shape specification takes the following form:
([dl]:[, [dl]:] ...)
Examples
The following is an example of an assumed-shape specification:
INTERFACE
SUBROUTINE SUB(M)
INTEGER M(:, 1:, 5:)
END SUBROUTINE
END INTERFACE
INTEGER L(20, 5:25, 10)
CALL SUB(L)
SUBROUTINE SUB(M)
INTEGER M(:, 1:, 5:)
END SUBROUTINE
Array M has the same extents as array L, but array M has bounds (1:20, 1:21, 5:14).
Note that an explicit interface is required when calling a routine that expects an assumed-shape or pointer
array.
Consider the following:
SUBROUTINE ASSUMED(A)
REAL A(:, :, :)
858
Language Reference
Array A has rank 3, indicated by the three colons (:) separated by commas (,). However, the extent of each
dimension is unspecified. When the subroutine is called, A takes its shape from the array passed to it. For
example, consider the following:
REAL X (4, 7, 9)
...
CALL ASSUMED(X)
This declaration gives A the dimensions (4, 7, 9). The actual array and the assumed-shape array must have
the same rank.
Consider the following:
SUBROUTINE ASSUMED(A)
REAL A(3:, 0:, -2:)
...
If the subroutine is called with the same actual array X(4, 7, 9), as in the previous example, the lower and
upper bounds of A would be:
Assumed-Size Specifications
An assumed-size array is a dummy argument array that assumes the size (only) of its associated actual
argument array, or the associate name of a RANK (*) block in a SELECT RANK construct. The rank and
extents can differ for the actual and dummy arrays. An assumed-size specification takes the following form:
([expli-shape-spec,] [expli-shape-spec,] ... [dl:] *)
859
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Examples
The following is an example of an assumed-size specification:
SUBROUTINE SUB(A, N)
REAL A, N
DIMENSION A(1:N, *)
...
The following example shows that you can specify lower bounds for any of the dimensions of an assumed-
size array, including the last:
SUBROUTINE ASSUME(A)
REAL A(-4:-2, 4:6, 3:*)
See Also
Array Elements
Assumed-Rank Specifications
An assumed-rank array is a dummy argument whose rank is inherited from the actual argument associated
with it, or it is the associate name of a RANK DEFAULT block of a SELECT RANK construct. It can have zero
rank.
You declare an assumed-rank object (a dummy variable) by using DIMENSION(..) or (..)array bounds in its
declaration.
Its rank is assumed from its effective argument, which means it is passed by descriptor.
An assumed-rank entity must not have the CODIMENSION or VALUE attribute. It can have the CONTIGUOUS
attribute.
An assumed-rank variable name must not appear in a designator or expression except as one of the
following:
• An actual argument corresponding to a dummy argument that is assumed-rank
• The argument of the C_LOC function in the ISO_C_BINDING intrinsic module
• The first argument in a reference to an intrinsic inquiry function
• The selector of a SELECT RANK construct
If an assumed-size or nonallocatable, nonpointer, assumed-rank array is an actual argument corresponding
to a dummy argument that is an INTENT(OUT) assumed-rank array, it must not be polymorphic, finalizable,
of a type with an allocatable ultimate component, or of a type for which default initialization is specified.
You can find the rank of an assumed-rank object by using the RANK intrinsic.
If a procedure has an assumed-rank argument, the procedure must have an explicit interface.
When an assumed-rank object is passed from Fortran to a BIND(C) routine, it is passed by C descriptor. A
Fortran procedure that has the BIND(C) language-binding-spec attribute will also receive an assumed-rank
object by C descriptor.
Examples
The following shows an assumed-rank object:
INTERFACE
SUBROUTINE csub (baz) BIND(C)
REAL, DIMENSION(..) :: baz
END SUBROUTINE
860
Language Reference
END INTERFACE
See Also
Argument Association
RANK
Deferred-Shape Specifications
A deferred-shape array is an array pointer or an allocatable array.
The array specification contains a colon (:) for each dimension of the array. No bounds are specified. The
bounds (and shape) of allocatable arrays and array pointers are determined when space is allocated for the
array during program execution.
An array pointer is an array declared with the POINTER attribute. Its bounds and shape are determined when
it is associated with a target by pointer assignment, or when the pointer is allocated by execution of an
ALLOCATE statement.
In pointer assignment, the lower bound of each dimension of the array pointer is the result of the LBOUND
intrinsic function applied to the corresponding dimension of the target. The upper bound of each dimension is
the result of the UBOUND intrinsic function applied to the corresponding dimension of the target.
An actual argument that is a pointer can be associated with a nonpointer dummy argument. Normally, a
pointer dummy argument can be associated only with a pointer actual argument. However, a pointer dummy
argument with INTENT(IN) can be argument associated with a non-pointer actual argument with the TARGET
attribute. During the execution of the procedure, it is pointer associated with the actual argument.
A function result can be declared to have the pointer attribute.
An allocatable array is declared with the ALLOCATABLE attribute. Its bounds and shape are determined when
the array is allocated by execution of an ALLOCATE statement.
Examples
The following are examples of deferred-shape specifications:
DIMENSION P(:, :, :)
POINTER P
TARGET B(:,:)
ALLOCATABLE B
If the deferred-shape array is an array of pointers, its size, shape, and bounds are set in an ALLOCATE
statement or in the pointer assignment statement when the pointer is associated with an allocated target. A
pointer and its target must have the same rank.
For example:
861
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
A pointer dummy argument with INTENT(IN) can be argument associated with a non-pointer actual
argument with the TARGET attribute. It is pointer associated with the actual argument, so the following
example prints “17".
program test
integer, target :: j = 17
call f (j)
contains
subroutine f (i)
integer, intent (in), pointer :: i
print *,i
end subroutine f
end program test
See Also
POINTER attribute
ALLOCATABLE attribute
ALLOCATE statement
Pointer assignment
LBOUND intrinsic function
UBOUND intrinsic function
Implied-Shape Specifications
Short Description
An implied-shape array is a named constant that takes its shape from the constant expression in its
declaration. An implied-shape specification takes the following form:
([dl:] du [, [dl:] du] ...)
Examples
The following examples show implied-shape specifications:
862
Language Reference
TRIPLE(1,1,1) 1
TRIPLE(2,1,1) 2
TRIPLE(1,2,1) 3
TRIPLE(2,2,1) 4 TABLE(1,1) 1
TRIPLE(1,1,2) 5 TABLE(2,1) 2
TRIPLE(2,1,2) 6 TABLE(1,2) 3
TRIPLE(1,2,2) 7 TABLE(2,2) 4
TRIPLE(2,2,2) 8
Each of the following statements also aligns the two arrays as shown in the above table:
EQUIVALENCE(TABLE, TRIPLE(2,2,1))
EQUIVALENCE(TRIPLE(1,1,2), TABLE(2,1))
863
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
You can also make arrays equivalent with nonunity lower bounds. For example, an array defined as A(2:3,4)
is a sequence of eight values. A reference to A(2,2) refers to the third element in the sequence. To make
array A(2:3,4) share storage with array B(2:4,4), you can use the following statement:
EQUIVALENCE(A(3,4), B(2,4))
The entire array A shares part of the storage allocated to array B. The following table shows how these
statements align the arrays. The arrays can also be aligned by the following statements:
EQUIVALENCE(A, B(4,1))
EQUIVALENCE(B(3,2), A(2,2))
Equivalence of Arrays with Nonunity Lower Bounds
Array B Array A
B(2,1) 1
B(3,1) 2
B(4,1) 3 A(2,1) 1
B(2,2) 4 A(3,1) 2
B(3,2) 5 A(2,2) 3
B(4,2) 6 A(3,2) 4
B(2,3) 7 A(2,3) 5
B(3,3) 8 A(3,3) 6
B(4,3) 9 A(2,4) 7
B(2,4) 10 A(3,4) 8
B(3,4) 11
B(4,4) 12
Only in the EQUIVALENCE statement can you identify an array element with a single subscript (the linear
element number), even though the array was defined as multidimensional. For example, the following
statements align the two arrays as shown in the above table:
DIMENSION B(2:4,1:4), A(2:3,1:4)
EQUIVALENCE(B(6), A(4))
864
Language Reference
These statements cause character variables NAME and ID to share space (see the following figure). The
arrays can also be aligned by the following statement:
EQUIVALENCE(NAME(9:9), ID(1:1))
Equivalence of Substrings
If the character substring references are array elements, the EQUIVALENCE statement sets associations
between the other corresponding characters in the complete arrays.
865
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Character elements of arrays can overlap at any character position. For example, the following statements
cause character arrays FIELDS and STAR to share storage (see the following figure).
CHARACTER FIELDS(100)*4, STAR(5)*5
EQUIVALENCE(FIELDS(1)(2:4), STAR(2)(3:5))
Equivalence of Character Arrays
866
Language Reference
The EQUIVALENCE statement cannot assign the same storage location to two or more substrings that start at
different character positions in the same character variable or character array. The EQUIVALENCE statement
also cannot assign memory locations in a way that is inconsistent with the normal linear storage of character
variables and arrays.
Examples
The following two figures demonstrate valid and invalid extensions of the common block, respectively.
The second example is invalid because the extended portion, B(1), precedes the first element of the common
block.
The following example shows a valid EQUIVALENCE statement and an invalid EQUIVALENCE statement in the
context of a common block.
COMMON A, B, C
DIMENSION D(3)
EQUIVALENCE(B, D(1)) ! Valid, because common block is extended
! from the end.
COMMON A, B, C
867
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
DIMENSION D(3)
EQUIVALENCE(B, D(3)) ! Invalid, because D(1) would extend common
! block to precede A's location.
Dynamic Allocation
Data objects can be static or dynamic. If a data object is static, a fixed amount of memory storage is created
for it at compile time and is not freed until the program exits. If a data object is dynamic, memory storage
for the object can be created (allocated), altered, or freed (deallocated) as a program executes.
Pointers, classes, deferred length character, allocatable scalars and arrays, and automatic arrays are dynamic
data objects.
No storage space is created for a pointer until it is allocated with an ALLOCATE statement or until it is
assigned to an allocated target. The storage space allocated is uninitialized.
An ALLOCATE statement can also be used to create storage for an allocatable array. A DEALLOCATE
statement can be used to free the storage space reserved in a previous ALLOCATE statement. It also causes
any pointers to become disassociated.
A pointer can be dynamically disassociated from a target by using a NULLIFY statement.
Automatic arrays differ from allocatable arrays in that they are automatically allocated and deallocated
whenever you enter or leave a procedure, respectively.
Dynamic allocation occurs at runtime and is handled by the Fortran runtime library. Several restrictions on
allocation and deallocation must be observed when these operations on a specific object are performed in
program units that are separately compiled. When allocation and deallocation of an object are split between
procedures in static code and dynamic shared libraries (.so files on Linux*) or dynamic-link libraries (DLLs on
Windows*), the following applies:
• If the dynamic library is compiled with the [q or Q]openmp compiler option, then the main program
must be compiled and linked with [q or Q]openmp to include the OpenMP memory handling routines in
the program.
• If the dynamic library allocates data in High bandwidth (HBW) memory on Linux*, then the program must
be linked with the libmemkind library to include the HBW memory handling routines in the program.
NOTE
Dynamic memory allocation is limited by several factors, including swap file size and memory
requirements of other applications that are running. Dynamic allocations that are too large or
otherwise attempt to use the protected memory of other applications result in General Protection Fault
errors. If you encounter an unexpectedly low limit, you might need to reset your virtual memory size
through the Control Panel or redefine the swap file size.
Some programming techniques can help minimize memory requirements, such as using one large
array instead of two or more individual arrays. Allocated arrays that are no longer needed should be
deallocated.
See Also
qopenmp, Qopenmp compiler option
Pointer Assignments
Automatic arrays
NULL intrinsic function, which can also be used to disassociate a pointer
TARGET
868
Language Reference
Effects of Allocation
When you allocate allocatable variables, allocatable arrays, and pointer targets, it can have various effects on
your program.
For more information, see the topics in this section.
869
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Allocation Status
During program execution, the allocation status of an allocatable array is one of the following:
• Not currently allocated
The array was never allocated or the last operation on it was a deallocation. Such an array must not be
referenced or defined.
• Currently allocated
The array was allocated by an ALLOCATE statement. Such an array can be referenced, defined, or
deallocated.
If an allocatable array has the SAVE attribute, it has an initial status of "not currently allocated". If the array
is then allocated, its status changes to "currently allocated". It keeps that status until the array is
deallocated.
If an allocatable array does not have the SAVE attribute, it has the status of "not currently allocated" at the
beginning of each invocation of the procedure. If the array's status changes to "currently allocated", it is
deallocated if the procedure is terminated by execution of a RETURN or END statement.
INTEGER(4) :: N
READ (5,*) N ! Reads an integer value
CALL MAT(N)
END
! Subroutine MAT uses the typed integer value to display the square
! root values of numbers from 1 to N (the number read)
SUBROUTINE MAT(N)
REAL(4), ALLOCATABLE :: SQR(:) ! Declares SQR as a one-dimensional
! allocatable array
ALLOCATE (SQR(N)) ! Allocates array SQR
DO J=1,N
SQR(J) = SQRT(FLOATJ(J)) ! FLOATJ converts integer to REAL
ENDDO
870
Language Reference
If the previous target was created by allocation, it becomes inaccessible unless it can still be referred to by
other pointers that are currently associated with it.
The intrinsic function ASSOCIATED can be used to determine whether a pointer is currently associated with a
target. The association status of the pointer must be defined. For example:
See Also
POINTER statement and attribute
Pointer assignments
ASSOCIATED intrinsic function
Effects of Deallocation
When you deallocate allocatable variables, allocatable arrays, and pointer targets, it can have various effects
on your program.
For more information, see the topics in this section.
871
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
There is also an implicit synchronization of all images in association with the deallocation of a coarray or
coarray subcomponent caused by the execution of a RETURN or END statement.
The intrinsic function ALLOCATED can be used to determine whether a variable is allocated or unallocated.
Consider the following example:
SUBROUTINE PROCESS
REAL, ALLOCATABLE :: TEMP(:)
REAL, ALLOCATABLE, SAVE :: X(:)
...
END SUBROUTINE PROCESS
Upon return from subroutine PROCESS, the allocation status of X is preserved because X has the SAVE
attribute. TEMP does not have the SAVE attribute, so it will be deallocated if it was allocated. On the next
invocation of PROCESS, TEMP will have an allocation status of unallocated.
See Also
Host association
TARGET statement and attribute
RETURN statement
END statement
SAVE statement
872
Execution Control
A pointer must not be deallocated if it is associated with an allocatable array, or it is associated with a portion
of an object (such as an array element or an array section).
If a pointer is deallocated, the association status of any other pointer associated with the target (or portion of
the target) becomes undefined.
Execution of a RETURN or END statement in a subprogram causes the pointer association status of any
pointer declared or accessed in the procedure to become undefined, unless any of the following applies to the
pointer:
• It has the SAVE attribute.
• It is in the scoping unit of a module that is accessed by another scoping unit which is currently executing.
• It is accessible by host association.
• It is in blank common.
• It is in a named common block that appears in another scoping unit that is currently executing.
• It is the return value of a function declared with the POINTER attribute.
If the association status of a pointer becomes undefined, it cannot subsequently be referenced or defined.
Examples
The following example shows deallocation of a pointer:
INTEGER ERR
REAL, POINTER :: PTR_A(:)
...
ALLOCATE (PTR_A(10), STAT=ERR)
...
DEALLOCATE(PTR_A)
See Also
POINTER statement and attribute
COMMON statement
NULL intrinsic function
Host association
TARGET statement and attribute
RETURN statement
END statement
SAVE statement
Execution Control
Execution of a program consists of the asynchronous execution of the program in a fixed number of one or
more of its images. Each image has its own execution environment, including floating-point status, a set of
data objects, input/output units, and procedure pointers.
A program normally executes statements in the order in which they are written. Executable control
constructs and statements, and procedure invocations, modify this normal execution by transferring control
to another statement in the program, or by selecting blocks (groups) of constructs and statements for
execution or repetition.
Procedures may be invoked by the CALL statement (subroutine), during expression evaluation (function), or
as part of data definition and handling (user-defined operators and FINAL procedures). There are many ways
to define a procedure: for example, external, internal, contained, type-bound, defined operator or
assignment, and module. All procedures have one entry point; procedures usually return to their caller.
873
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The control constructs ASSOCIATE, CASE, DO, IF, SELECT RANK, and SELECT TYPE contain blocks and can be
named. The name must be a unique identifier in the scoping unit, and must appear on the initial line and
terminal line of the construct. On the initial line, the name is separated from the statement keyword by a
colon (:).
A block can contain any executable Fortran statement except an END statement. You can transfer control out
of a block, but you cannot transfer control into another block.
DO loops cannot partially overlap blocks. The DO statement and its terminal statement must appear together
in a statement block.
The following are execution control statements or constructs:
• ASSOCIATE construct
Creates a temporary association between a named entity and a variable or the value of an expression.
The association lasts for the duration of the block.
• BLOCK construct
Executes a block of statements or constructs that can contain declarations.
• CALL statement
Transfers control to a subroutine subprogram.
• CASE construct
Conditionally executes one block of constructs or statements depending on the value of a scalar
expression in a SELECT CASE statement.
• CONTINUE statement
Primarily used to terminate a labeled DO construct when the construct would otherwise end improperly
with either a GO TO, arithmetic IF, or other prohibited control statement.
• CRITICAL construct
Limits execution of a block to one image at a time.
• DO construct
Controls the repeated execution of a block of statements or constructs. The following statements are used
in DO constructs:
• DO CONCURRENT statement
Specifies that there are no data dependencies between the iterations of a DO loop.
• DO WHILE statement
Executes the range of a DO construct while a specified condition remains true.
• CYCLE statement
Interrupts the current execution cycle of the innermost (or named) DO construct.
• EXIT statement
Terminates execution of a DO construct
• END statement
Marks the end of a program unit.
• IF construct and IF statement
The IF construct conditionally executes one block of statements or constructs. The IF statement
conditionally executes one statement. The decision to transfer control or to execute the statement or
block is based on the evaluation of a logical expression within the IF statement or construct.
• PAUSE statement
Temporarily suspends program execution until the user or system resumes execution.
These statements are deleted features in the Fortran Standard. Intel® Fortran fully supports features
deleted in the Fortran Standard.
• RETURN statement
Transfers control from a subprogram to the calling program unit.
• SELECT RANK construct
Selects for execution at most one of its constituent blocks based on the rank of an assumed-rank variable.
874
Language Reference
Program Termination
Program termination may involve flushing I/O buffers, closing open I/O files, writing of a STOP code or an
ERROR STOP code, or reporting an error status on one or more images. There are two types of image
termination, normal termination and error termination.
Normal termination occurs when an image executes a STOP statement or an END [PROGRAM] statement. If
there are multiple images running, execution of STOP or END [PROGRAM] statement effects only the image
that executes the statement; it has no effect on other images. When an image initiates normal termination,
its image status becomes STOPPED, and it waits until all other active images initiate normal termination at
which time all images terminate execution. While an image has the status STOPPED, its coarrays are still
accessible for reference or definition by other active images.
Error termination of one image causes termination of all other images. Error termination is not initiated if an
error condition occurs during the execution of an I/O statement which specifies either an IOSTAT= or ERR=
specifier, during the execution of an image control statement that specifies a STAT= specifier, or during a
reference to an intrinsic function with a present STAT argument. Otherwise, if an error condition occurs, error
termination is initiated.
A program terminates execution when all images that have not failed terminate execution.
Statement Restriction
DO terminal statement The branch must be taken from within its nonblock
DO construct1.
END BLOCK The branch must be taken from within its BLOCK
construct.
875
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Statement Restriction
END SELECT The branch must be taken from within its SELECT
CASE, SELECT RANK, or SELECT TYPE construct.
1Ifthe terminal statement is shared by more than one nonblock DO construct, the branch can only be
taken from within the innermost DO construct.
2You can branch to an END IF statement from outside the IF construct; this is a deleted feature in the
Fortran Standard. Intel® Fortran fully supports features deleted in the Fortran Standard.
See Also
ASSOCIATE
BLOCK
DO Statement
FORALL
IF constructs
SELECT CASE
SELECT RANK
SELECT TYPE
WHERE
Effects of DO Constructs
This section discusses ways you can use DO loops and their effects on your program.
For more information, see the topics in this section.
876
Language Reference
Description
A DO variable or expression of type real is a deleted feature in the Fortran Standard. Intel® Fortran fully
supports features deleted in the Fortran Standard.
The following steps are performed in iteration loop control:
1. The expressions expr1, expr2, and expr3 are evaluated to respectively determine the initial, terminal,
and increment parameters.
The increment parameter (expr3) is optional and must not be zero. If an increment parameter is not
specified, it is assumed to be of type default integer with a value of 1.
2. The DO variable (do-var) becomes defined with the value of the initial parameter (expr1).
3. The iteration count is determined as follows:
Examples
The following example specifies 25 iterations:
DO 100 K=1,50,2
K=49 during the final iteration, K=51 after the loop.
The following example specifies 27 iterations:
DO 350 J=50,-2,-2
J=-2 during the final iteration, J=-4 after the loop.
877
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
DO NUMBER=5,40,4
NUMBER=37 during the final iteration, NUMBER=41 after the loop. The terminating statement of this DO loop
must be END DO.
See Also
f66
Deleted and Obsolescent Language Features for details on obsolescent features in Standard
Fortran, as well as features deleted in Standard Fortran
Nested DO Constructs
A DO construct can contain one or more complete DO constructs (loops). The range of an inner nested DO
construct must lie completely within the range of the next outer DO construct. Nested nonblock DO
constructs can share a labeled terminal statement.
The following figure shows correctly and incorrectly nested DO constructs:
In a nested DO construct, you can transfer control from an inner construct to an outer construct. However,
you cannot transfer control from an outer construct to an inner construct.
If two or more nested DO constructs share the same terminal statement, you can transfer control to that
statement only from within the range of the innermost construct. Any other transfer to that statement
constitutes a transfer from an outer construct to an inner construct, because the shared statement is part of
the range of the innermost construct.
When the nested DO constructs contain no statements between the DO statements in the nest of DO
constructs, the nest is called “perfectly nested”. When perfectly nested DO constructs are modified by a
COLLAPSE clause in any of these OpenMP* directives:
• !$OMP DISTRIBUTE
• !$OMP DO
• !$OMP SIMD
There are restrictions on which general compiler directives (see General Compiler Directives) and OpenMP
Fortran compiler directives (see OpenMP Fortran Compiler Directives) can appear before the DO statements
in the nested DO construct:
• Any OpenMP or general directives that are allowed to affect DO loops are allowed prior to the first DO loop
of the "perfectly nested" DO construct.
• It is an error if any of these directives are between any of the perfectly nested DO loop statements for the
loops affected by the COLLAPSE clause.
Examples
In the following example, COLLAPSE (1) on affects the DO I loop. Therefore general directives before the DO
J loop, which is at level 2, are allowed:
do i = …
!dir$ loop count … ! this is allowed since collapse only applies
! to the i-loop, not the j-loop
do j = …
enddo ! end for j-loop
enddo ! end for i-loop
878
Language Reference
In the following example, COLLAPSE (2) affects the DO I loop and the DO J loop but not the DO k loop.
See Also
!$OMP DISTRIBUTE
!$OMP DO
!$OMP SIMD
Rules for General Directives that Affect DO loops
Extended Range
A DO construct has an extended range if both of the following are true:
• The DO construct contains a control statement that transfers control out of the construct.
• Another control statement returns control back into the construct after execution of one or more
statements.
The range of the construct is extended to include all executable statements between the destination
statement of the first transfer and the statement that returns control to the construct.
The following rules apply to a DO construct with extended range:
• A transfer into the range of a DO statement is permitted only if the transfer is made from the extended
range of that DO statement.
• The extended range of a DO statement must not change the control variable of the DO statement.
879
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The following figure shows valid and invalid extended range control transfers:
880
Language Reference
NOTE
Collective actions may hang if images have stopped or failed and the other images have not all
detected the stop or fail; for more information, see FAILED_IMAGES.
See Also
Execution Segments for Images
FAILED_IMAGES
881
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
STAT_FAILED_IMAGE in the intrinsic module ISO_FORTRAN_ENV. If any other error condition occurs during
execution of one of these statements, the variable becomes defined with a processor-dependent positive
integer value that is different from the value of STAT_STOPPED_IMAGE or STAT_FAILED_IMAGE.
If the STAT= specifier appears in a SYNC ALL, SYNC IMAGES, or SYNC TEAM statement and the error
STAT_STOPPED_IMAGES occurs, the effect of executing the statement is the same as that of executing the
SYNC_MEMORY statement.
If the STAT= specifier appears in a LOCK statement and the lock variable is located on an image that has
failed, the specified variable becomes defined with the value STAT_FAILED_IMAGE. If the lock variable is
locked by the executing image, the specified variable becomes defined with the value of STAT_LOCKED.
Otherwise, if the lock variable is unlocked because the image that locked it has failed, the specified STAT=
variable becomes defined with the value STAT_UNLOCKED_FAILED_IMAGE defined in the intrinsic module
ISO_FORTRAN_ENV.
If the STAT= specifier appears in an UNLOCK statement and the lock variable is located on an image that has
failed, the specifier becomes defined with the value STAT_FAILED_IMAGE. Otherwise, if the lock variable has
the value unlocked, the variable specified by the STAT= specifier becomes defined with the value of
STAT_UNLOCKED. If the STAT= specifier appears in an UNLOCK statement and the lock variable is locked by
a different image, the specified variable becomes defined with the value STAT_LOCKED_OTHER_IMAGE. The
named constants STAT_LOCKED, STAT_UNLOCKED, and STAT_LOCKED_OTHER_IMAGE are defined in the
intrinsic module ISO_FORTRAN_ENV.
If any other error condition occurs during execution of a LOCK or UNLOCK statement, the specified variable
becomes defined with a positive integer value that is different from STAT_LOCKED, STAT_UNLOCKED,
STAT_UNLOCKED_FAILED_IMAGE, and STAT_LOCKED_OTHER_IMAGE.
If an image completes execution of a CRITICAL statement that has a STAT= specifier and the previous image
that entered the CRITICAL construct failed during execution of the construct, the specifier becomes defined
with the value STAT_FAILED_IMAGE and the execution of the construct executes normally. If any other error
occurs during execution of the construct, the specifier becomes defined with a positive integer value other
different from STAT_FAILED_IMAGE.
If an error condition occurs during execution of an image control statement that does not contain the STAT=
specifier, error termination is initiated.
If an ERRMSG= specifier appears in an image control statement, and an error condition occurs during
execution of that statement, the processor will assign an explanatory message to the specified variable. If no
such condition occurs, the processor will not change the value or definition status of the variable.
The set of error conditions that can occur during execution of an image control statement is processor
dependent.
See Also
ISO_FORTRAN_ENV Module
882
Program Units and Procedures
• If a procedure invocation on image P is in execution in segments Pi, Pi+1, ..., Pk and defines a noncoarray
dummy argument, the effective argument must not be referenced, defined, or become undefined on
another image Q in a segment Qj unless Qj precedes Pi or succeeds Pk (because a copy of the actual
argument may be passed to the procedure)
Incorrect sequencing of image control statements can suspend execution indefinitely. For example, one
image might be executing a SYNC ALL statement while another is executing an ALLOCATE statement for a
coarray.
See Also
Image Control Statements
883
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
A function is invoked in an expression using the name of the function or a defined operator. It returns a a
single value (function result) that is used to evaluate the expression.
A subroutine is invoked in a CALL statement or by a defined assignment statement. It does not directly
return a value, but values can be passed back to the calling program unit through arguments (or variables)
known to the calling program.
Recursion (direct or indirect) is permitted for functions and subroutines.
A procedure interface refers to the properties of a procedure that interact with or are of concern to the calling
program. A procedure interface can be explicitly defined in interface blocks. All program units, except block
data program units, can contain interface blocks.
See Also
Program structure
Intrinsic procedures
Scope
RECURSIVE keyword
Main Program
A main program is a program unit whose first statement is not a SUBROUTINE, FUNCTION, MODULE,
SUBMODULE, or BLOCK DATA statement. Program execution always begins with the first executable
statement in the main program, so there must be exactly one main program unit in every executable
program. For more information, see PROGRAM.
Procedure Characteristics
The characteristics of a procedure are as follows:
• Whether it is classified as a function or subroutine
• The characteristics of its result value if it is a function
• The characteristics of its dummy arguments
• Whether it is pure
• Whether it is impure
• Whether it is elemental
• Whether it has the BIND attribute
884
Language Reference
• Its intent
• Its corank
• Its codimensions
• Whether it is optional
• Whether it is allocatable
• Whether it has the ASYNCHRONOUS, CONTIGUOUS, VALUE, or VOLATILE attribute
• Whether it is a pointer or a target
• Whether it is polymorphic
• Whether or not it is assumed rank or assumed type
If a type parameter of an object or a bound of an array is not a constant expression, a characteristic is the
exact dependence on the entities in the expression. Another characteristic is whether a shape, size, or type
parameter is assumed or deferred.
The characteristics of a dummy procedure are as follows:
• Whether it is optional
• The explicitness of its interface
• Its characteristics as a procedure if the interface is explicit
• Whether it is a pointer
885
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
PRIVATE attribute
PUBLIC attribute
Use association
interface
real module function FOO (arg)
type(tt), intent(in) :: arg
end function FOO
end interface
end module M
submodule (M) A
contains
real module function FOO (arg) result(res)
type(tt), intent(in) :: arg
res = arg%r
end function FOO
end submodule A
A separate module procedure is accessible by use association only if its interface body is declared in a
module and it is public (for example, FOO in the above example). If a separate module interface is declared
in a submodule, the module procedure is only accessible in that submodule or its descendent submodules.
A separate module procedure interface body (either in a module or submodule) has access to entities in its
host through host association.
NOTE
For an interface body that is not a separate interface body, IMPORT statements are required to make
entities accessible by host association. However, IMPORT statements are not permitted in a separate
interface body.
The initial statement of a separate module procedure body can take one of the two following forms:
• MODULE appears as a prefix for a FUNCTION or SUBROUTINE statement
886
Language Reference
NOTE
Two modules cannot have USE statements that reference each other because circular reference is not
allowed. However, you can solve that problem by putting at least one side of the USEs in submodules.
This is because submodules cannot be referenced by use association and the USE statements in
submodules are effectively hidden.
887
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Examples
See the examples in SUBMODULE.
See Also
MODULE
SUBMODULE
Intrinsic Modules
Intrinsic modules, like other module program units, contain specifications and definitions that can be made
accessible to other program units. The intrinsic modules are part of the Fortran library.
An intrinsic module is specified in a USE statement, as follows:
USE, INTRINSIC :: mod-name [, rename-list] ...
USE, INTRINSIC :: mod-name, ONLY : [, only-list]
Procedures and types defined in an intrinsic module are not themselves intrinsic.
An intrinsic module can have the same name as other global entities, such as program units, common blocks,
or external procedures. A scoping unit must not access both an intrinsic module and a non-intrinsic module
with the same name.
When INTRINSIC is used, mod-name must be the name of an intrinsic module. If NON_INTRINSIC is used,
mod-name must be the name of an nonintrinsic module. If neither is specified, mod-name must be the name
of an intrinsic or nonintrinsic module. If both are provided, the nonintrinsic module is used.
The following intrinsic modules are included in the Fortran library: ISO_C_BINDING, ISO_FORTRAN_ENV, and
IEEE Intrinsic Modules.
ISO_C_BINDING Module
The ISO_C_BINDING intrinsic module provides access to data entities that are useful in mixed-language
programming. It takes the following form:
USE, INTRINSIC :: ISO_C_BINDING
This intrinsic module provides access to the following data entities:
• Named Constants
• Derived Types
Derived type C_PTR is interoperable with any C object pointer type. Derived type C_FUNPTR is
interoperable with any C function pointer type.
• Intrinsic Module Procedures
See Also
Standard Tools for Interoperability
Intrinsic-Type Constants
The following table shows interoperable Fortran types and C Types.
888
Language Reference
C_SIZE_T size_t
C_INT8_T int8_t
C_INT16_T int16_t
C_INT32_T int32_t
C_INT64_T int64_t
C_INT_LEAST8_T int_least8_t
C_INT_LEAST16_T int_least16_t
C_INT_LEAST32_T int_least32_t
C_INT_LEAST64_T int_least64_t
C_INT_FAST8_T int_fast8_t
C_INT_FAST16_T int_fast16_t
C_INT_FAST32_T int_fast32_t
C_INT_FAST64_T int_fast64_t
C_INTMAX_T intmax_t
C_INTPTR_T intptr_t
C_PTRDIFF_T ptrdiff_t
C_DOUBLE double
889
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
2Forcharacter type, the length type parameter must be omitted or it must be specified by a constant
expression whose value is one.
For example, an integer type with the kind type parameter C_LONG is interoperable with the C integer type
"long" or any C type derived from "long".
The value of C_INT will be a valid value for an integer kind type parameter on the processor. The values for
the other integer named constants (C_INT*) will be a valid value for an integer kind type parameter on the
processor, if any, or one of the following:
• -1 if the C processor defines the corresponding C type and there is no interoperating Fortran processor
kind
• -2 if the C processor does not define the corresponding C type
The values of C_FLOAT, C_DOUBLE, and C_LONG_DOUBLE will be a valid value for a real kind type parameter
on the processor, if any, or one of the following:
• -1 if the C processor's type does not have a precision equal to the precision of any of the Fortran
processor's real kinds
• -2 if the C processor's type does not have a range equal to the range of any of the Fortran processor's
real kinds
• -3 if the C processor's type has neither the precision or range equal to the precision or range of any of the
Fortran processor's real kinds
• -4 if there is no interoperating Fortran processor or kind for other reasons
The values of C_FLOAT_COMPLEX, C_DOUBLE_COMPLEX, and C_LONG_DOUBLE_COMPLEX will be the same
as those of C_FLOAT, C_DOUBLE, and C_LONG_DOUBLE, respectively.
The value of C_BOOL will be a valid value for a logical kind parameter on the processor, if any, or -1.
The value of C_CHAR is the character kind.
Character Constants
The following table shows interoperable named constants and C characters:
Derived-Type Constants
The constant C_NULL_PTR is of type C_PTR; it has the value of a C null data pointer. The constant
C_NULL_FUNPTR is of type C_FUNPTR; it has the value of a C null function pointer.
890
Language Reference
ISO_FORTRAN_ENV Module
The ISO_FORTRAN_ENV intrinsic module provides information about the Fortran run-time environment. It
takes the following form:
USE, INTRINSIC :: ISO_FORTRAN_ENV
This intrinsic module provides access to the following data entities:
• Named Constants
• Derived Types
• Intrinsic Module Procedures
891
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
892
Language Reference
893
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
894
Language Reference
895
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The following three IEEE intrinsic modules are described in this section:
• IEEE_ARITHMETIC
• IEEE_EXCEPTIONS
• IEEE_FEATURES
IEEE_CLASS IEEE_REM
IEEE_COPY_SIGN IEEE_RINT
IEEE_FMA IEEE_SCALB
IEEE_IS_FINITE IEEE_SET_ROUNDING_MODE 3
IEEE_NEGATIVE IEEE_SIGNALING_EQ
IEEE_INT IEEE_SIGNALING_GE
IEEE_IS_NORMAL IEEE_SIGNALING_GT
IEEE_LOGB IEEE_SIGNALING_LE
IEEE_MAX_NUM IEEE_SIGNALING_LT
896
Language Reference
IEEE_MAX_NUM_MAG IEEE_SIGNALING_NE
IEEE_MIN_NUM IEEE_SIGNBIT
IEEE_MIN_NUM_MAG IEEE_SUPPORT_DENORMAL
IEEE_NEXT_AFTER IEEE_SUPPORT_DIVIDE
IEEE_NEXT_DOWN 1 IEEE_SUPPORT_INF
IEEE_NEXT_UP 1 IEEE_SUPPORT_IO
IEEE_QUIET_EQ IEEE_SUPPORT_NAN
IEEE_QUIET_GE IEEE_SUPPORT_ROUNDING
IEEE_QUIET_GT IEEE_SUPPORT_SQRT
IEEE_QUIET_LE IEEE_SUPPORT_SUBNORMAL
IEEE_QUIET_LT IEEE_SUPPORT_UNORDERED
IEEE_QUIET_NE IEEE_SUPPORT_VALUE
IEEE_REAL 2 IEEE_VALUE
1 IEEE_SUPPORT_INF() must be true if IEEE_NEXT_DOWN is called with the argument -HUGE (X) or if
IEEE_NEXT_UP is called with the argument HUGE (X).
2 IEEE_SUPPORT_DATATYPE (IEEE_REAL (A, KIND)) must also be true.
3 IEEE_SUPPORT_ROUNDING(ROUND_VALUE, X) must also be true.
For example, the IEEE_IS_NORMAL(X) function can only be invoked if IEEE_SUPPORT_DATATYPE(X) has the
value true. Consider the following:
USE, INTRINSIC :: IEEE_ARITHMETIC
...
IF IEEE_SUPPORT_DATATYPE(X) THEN
IF IEEE_IS_NORMAL(X) THEN
PRINT *, ' X is a "normal" '
ELSE
PRINT *, ' X is not "normal" '
ENDIF
ELSE
PRINT *, ' X is not a supported IEEE type '
ENDIF
...
Certain other IEEE intrinsic module procedures have similar restrictions:
• IEEE_IS_NAN(X) can only be invoked if IEEE_SUPPORT_NAN(X) has the value true.
• IEEE_SET_HALTING_MODE(FLAG, HALTING) can only be invoked if IEEE_SUPPORT_HALTING(FLAG) has
the value true.
• IEEE_GET_UNDERFLOW_MODE(GRADUAL) can only be invoked if
IEEE_SUPPORT_UNDERFLOW_CONTROL(X) is true for some X.
For intrinsic module function IEEE_CLASS(X), some of the possible return values also have restrictions. These
restrictions are also true for argument CLASS in intrinsic module function IEEE_VALUE(X, CLASS):
• IEEE_POSITIVE_INF and IEEE_NEGATIVE_INF can only be returned if IEEE_SUPPORT_INF(X) has the
value true.
897
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IEEE_SIGNALING_NAN IEEE_NEGATIVE_NORMAL
IEEE_QUIET_NAN IEEE_POSITIVE_DENORMAL
IEEE_POSITIVE_INF IEEE_NEGATIVE_DENORMAL
IEEE_NEGATIVE_INF IEEE_POSITIVE_ZERO
IEEE_POSITIVE_NORMAL IEEE_NEGATIVE_ZERO
IEEE_OTHER_VALUE
• IEEE_ROUND_TYPE: Identifies a rounding mode. Its values are the following named constants:
IEEE_AWAY 1 IEEE_OTHER 4
IEEE_DOWN 2 IEEE_TO_ZERO 5
IEEE_NEAREST 3 IEEE_UP 6
898
Language Reference
The derived types in the intrinsic modules have components that are private. The IEEE_EXCEPTIONS intrinsic
module supports the setting, clearing, saving, restoring, or testing of exception flags. It defines the following
derived types:
• IEEE_FLAG_TYPE: Identifies an exception flag for errors that occur during an IEEE arithmetic operation or
assignment. Its values are the following named constants:
IEEE_INVALID IEEE_DIVIDE_BY_ZERO
IEEE_OVERFLOW IEEE_INEXACT
IEEE_UNDERFLOW
Each of the above exceptions has a flag whose value is either quiet or signaling. The initial value is quiet
and it signals when the associated exception occurs. To determine the value of a flag, use intrinsic module
subroutine IEEE_GET_FLAG. To change the status for a flag, use intrinsic module subroutine
IEEE_SET_FLAG or IEEE_SET_STATUS.
If a flag is signaling on entry to a procedure, the processor sets it to quiet on entry and restores it to
signaling on return.
If a flag is quiet on entry to a procedure with access to modules IEEE_ARITHMETIC or IEEE_EXCEPTIONS,
and is signaling on return, the processor will not restore it to quiet.
The IEEE_FLAG_TYPE module also defines the following named array constants:
• IEEE_USUAL=(/IEEE_OVERFLOW,IEEE_DIVIDE_BY_ZERO, IEEE_INVALID/)
• IEEE_ALL=(/IEEE_USUAL,IEEE_UNDERFLOW,IEEE_INEXACT/)
• IEEE_MODES_TYPE: The floating-point modes are the values of the rounding modes, underflow mode,
and halting mode. They can be saved in a variable of type IEEE_MODES_TYPE by calling the subroutine
IEEE_GET_MODES and restored by calling the subroutine IEEE_SET_MODES.
• IEEE_STATUS_TYPE: The floating-point status can be saved in a variable of type IEEE_STATUS_TYPE by
calling the subroutine IEEE_GET_STATUS and restored by calling the subroutine IEEE_SET_STATUS.
The IEEE_ARITHMETIC module includes support for IEEE_EXCEPTIONS module, and public entities in
IEEE_EXCEPTIONS module are also public in the IEEE_ARITHMETIC module.
To see a summary of all the IEEE_EXCEPTIONS intrinsic procedures, see IEEE Intrinsic Modules Quick
Reference Tables
IEEE_DATATYPE IEEE_INF
IEEE_DIVIDE IEEE_NAN
IEEE_ROUNDING IEEE_INEXACT_FLAG
IEEE_SQRT IEEE_INVALID_FLAG
IEEE_SUBNORMAL IEEE_UNDERFLOW_FLAG
IEEE_HALTING
899
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
900
Language Reference
901
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Key to Classes
E-Elemental function
I-Inquiry
SI-Impure Subroutine
T-Transformational
902
Language Reference
Key to Classes
ES-Elemental subroutine
SI-Impure Subroutine
SP-Pure Subroutine
T-Transformational
Examples
An example of a block data program unit follows:
903
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
A function reference is used in an expression to invoke a function; it consists of the function name and its
actual arguments. The function reference returns a value to the calling expression that is used to evaluate
the expression.
See Also
ENTRY statement
CALL statement
See Also
RECURSIVE procedures
PURE procedures
User-defined ELEMENTAL procedures
Module procedures
Internal procedures
External procedures
Optional arguments
INTENT attribute
standard-semantics compiler option
assume recursion compiler option
Recursive Procedures
A recursive procedure is a function or subroutine that references itself, either directly or indirectly. For more
information, see RECURSIVE.
904
Language Reference
Pure Procedures
A pure procedure is a procedure that has no side effects. For more information, see PURE.
Impure Procedures
An impure procedure is a user-defined procedure that has side effects. For more information, see IMPURE
Elemental Procedures
An elemental procedure is a user-defined procedure defined on scalar arguments that may be called with
array arguments. An elemental procedure is pure unless you specify that it is impure. For more information,
see PURE, ELEMENTAL, and IMPURE.
Functions Overview
A function subprogram is invoked in an expression and returns a single value (a function result) that is used
to evaluate the expression. For more information, see FUNCTION.
Function References
Functions are invoked by a function reference in an expression or by a defined operation.
A function reference takes the following form:
fun ([a-arg [, a-arg] ...])
Description
When a function is referenced, each actual argument is associated with the corresponding dummy argument
by its position in the argument list or by the name of its keyword. The arguments must agree in type and
kind parameters.
Execution of the function produces a result that is assigned to the function name or to the result name,
depending on whether the RESULT keyword was specified.
The program unit uses the result value to complete the evaluation of the expression containing the function
reference.
If positional arguments and argument keywords are specified, the argument keywords must appear last in
the actual argument list.
If a dummy argument is optional, the actual argument can be omitted.
If a dummy argument is specified with the INTENT attribute, its use may be limited. A dummy argument
whose intent is not specified is subject to the limitations of its associated actual argument.
905
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
An actual argument associated with a dummy procedure must be the specific name of a procedure, or be
another dummy procedure. Certain specific intrinsic function names must not be used as actual arguments
(see table Specific Functions Not Allowed as Actual Arguments in Intrinsic Procedures).
Examples
Consider the following example:
X = 2.0
NEW_COS = COS(X) ! A function reference
Intrinsic function COS calculates the cosine of 2.0. The value -0.4161468 is returned (in place of COS(X))
and assigned to NEW_COS.
See Also
INTENT attribute
Defining Generic Operators
Dummy Procedure Arguments
Intrinsic Procedures
Optional arguments
RESULT keyword
FUNCTION statement
Argument Association for details on procedure arguments
Subroutines Overview
A subroutine subprogram is invoked in a CALL statement or by a defined assignment statement, and does
not return a particular value. For more information, see SUBROUTINE.
906
Language Reference
All entry names within a function subprogram are associated with the name of the function subprogram.
Therefore, defining any entry name or the name of the function subprogram defines all the associated names
with the same data type. All associated names with different data types become undefined.
If RECURSIVE is specified in the FUNCTION statement, all entry points in the FUNCTION are recursive. The
interface of the function defined by the ENTRY statement is explicit within the function subprogram.
Examples
The following example shows a function subprogram that computes the hyperbolic functions SINH, COSH,
and TANH:
TANH = TSINH(X)/TCOSH(X)
RETURN
ENTRY SINH(X)
SINH = TSINH(X)/2.0
RETURN
ENTRY COSH(X)
COSH = TCOSH(X)/2.0
RETURN
END
See Also
RESULT keyword
Examples
The following example shows a main program calling a subroutine containing an ENTRY statement:
PROGRAM TEST
...
CALL SUBA(A, B, C) ! A, B, and C are actual arguments
... ! passed to entry point SUBA
END
SUBROUTINE SUB(X, Y, Z)
...
ENTRY SUBA(Q, R, S) ! Q, R, and S are dummy arguments
... ! Execution starts with this statement
END SUBROUTINE
The following example shows an ENTRY statement specifying alternate returns:
907
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
RETURN 1
RETURN 2
END
Note that the CALL statement for entry point SUBC includes actual alternate return arguments. The RETURN
1 statement transfers control to statement label 100 and the RETURN 2 statement transfers control to
statement label 200 in the calling program.
External Procedures
External procedures are user-written functions or subroutines. They are located outside of the main program
and can't be part of any other program unit.
External procedures can be invoked by the main program or any procedure of an executable program.
External procedures can include internal subprograms (defining internal procedures). Internal subprograms
are placed after a CONTAINS statement.
An external procedure can reference itself (directly or indirectly).
The interface of an external procedure is implicit unless an interface block is supplied for the procedure.
See Also
Functions, Subroutines, and Statement Functions
Procedure Interfaces
Internal Procedures
Internal procedures are functions or subroutines that follow a CONTAINS statement in a program unit. The
program unit in which the internal procedure appears is called its host.
Internal procedures can appear in the main program, in an external subprogram, or in a module subprogram.
An internal procedure takes the following form:
CONTAINS
internal-subprogram
[internal-subprogram] ...
Description
Internal procedures are the same as external procedures, except for the following:
• Only the host program unit can use an internal procedure.
• An internal procedure has access to host entities by host association; that is, names declared in the host
program unit are useable within the internal procedure.
• An internal procedure must not contain an ENTRY statement.
An internal procedure can reference itself (directly or indirectly); it can be referenced in the execution part of
its host and in the execution part of any internal procedure contained in the same host (including itself).
The interface of an internal procedure is always explicit.
908
Language Reference
Examples
The following example shows an internal procedure:
PROGRAM COLOR_GUIDE
...
CONTAINS
FUNCTION HUE(BLUE) ! An internal procedure
...
END FUNCTION HUE
END PROGRAM
The following example program contains an internal subroutine find, which performs calculations that the
main program then prints. The variables a, b, and c declared in the host program are also known to the
internal subroutine.
program INTERNAL
! shows use of internal subroutine and CONTAINS statement
real a,b,c
call find
print *, c
contains
subroutine find
read *, a,b
c = sqrt(a**2 + b**2)
end subroutine find
end
See Also
Functions, Subroutines, and Statement Functions
Host association
Procedure Interfaces
CONTAINS statement
909
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
An actual argument associated with a dummy argument that is allocatable or a pointer must have the same
type parameters as the dummy argument.
A dummy argument referenced as a subprogram must be associated with an actual argument that has been
declared EXTERNAL or INTRINSIC in the calling routine.
If a scalar dummy argument is of type character, its length must not be greater than the length of its
associated actual argument.
If the character dummy argument's length is specified as *(*) (assumed length), it uses the length of the
associated actual argument.
Once an actual argument has been associated with a dummy argument, no action can be taken that affects
the value or availability of the actual argument, except indirectly through the dummy argument. For
example, if the following statement is specified:
CALL SUB_A (B(2:6), B(4:10))
B(4:6) must not be defined, redefined, or become undefined through either dummy argument, since it is
associated with both arguments. However, B(2:3) is definable through the first argument, and B(7:10) is
definable through the second argument.
Similarly, if any part of the actual argument is defined through a dummy argument, the actual argument can
only be referenced through that dummy argument during execution of the procedure. For example, if the
following statements are specified:
MODULE MOD_A
REAL :: A, B, C, D
END MODULE MOD_A
PROGRAM TEST
USE MOD_A
CALL SUB_1 (B)
...
END PROGRAM TEST
910
Language Reference
See Also
CALL for details on argument keywords in subroutine references
Function References for details on argument keywords in function references
Optional Arguments
Dummy arguments can be made optional if they are declared with the OPTIONAL attribute. In this case, an
actual argument does not have to be supplied for it in a procedure reference.
If argument keywords are not used, argument association is positional. The first dummy argument becomes
associated with the first actual argument, and so on. If argument keywords are used, arguments are
associated by the keyword name, so actual arguments can be in a different order than dummy arguments. A
keyword is required for an argument only if a preceding optional argument is omitted or if the argument
sequence is changed.
Positional arguments (if any) must appear first in an actual argument list, followed by keyword arguments (if
any). If an optional argument is the last positional argument, it can simply be omitted if desired.
However, if the optional argument is to be omitted but it is not the last positional argument, keyword
arguments must be used for any subsequent arguments in the list.
Optional arguments must have explicit procedure interfaces so that appropriate argument associations can
be made.
The PRESENT intrinsic function can be used to determine if an actual argument is associated with an optional
dummy argument in a particular reference.
A dummy argument or an entity that is host associated with a dummy argument is not present if any of the
following are true for the dummy argument:
• It does not correspond to an actual argument.
• It corresponds to an actual argument that is not present.
• It does not have the ALLOCATABLE or POINTER attribute, and corresponds to one of the following:
• An actual argument that has the ALLOCATABLE attribute and is not allocated
• An actual argument that has the POINTER attribute and is disassociated
The following example shows optional arguments:
PROGRAM RESULT
TEST_RESULT = LGFUNC(A, B=D)
...
CONTAINS
FUNCTION LGFUNC(G, H, B)
OPTIONAL H, B
...
END FUNCTION
END
911
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
In the function reference, A is a positional argument associated with required dummy argument G. The
second actual argument D is associated with optional dummy argument B by its keyword name (B). No
actual argument is associated with optional argument H.
The following shows another example:
! Arguments can be passed out of order, but must be
! associated with the correct dummy argument.
CALL EXT1 (Z=C, X=A, Y=B)
. . .
END
SUBROUTINE EXT1(X,Y,Z)
REAL X, Y
REAL, OPTIONAL :: Z
. . .
END SUBROUTINE
In this case, argument A is associated with dummy argument X by explicit assignment. Once EXT1 executes
and returns, A is no longer associated with X, B is no longer associated with Y, and C is no longer associated
with Z.
If you pass an omitted dummy argument as the actual argument to a procedure, the corresponding dummy
argument is considered to be omitted as well. This rule applies to both intrinsic and non-intrinsic procedures.
For example:
CALL SUB1()
CONTAINS
SUBROUTINE SUB1(B)
LOGICAL, OPTIONAL :: B
PRINT *, INDEX('Fortran','r',BACK=B) ! Prints 3
CALL SUB2(B) ! Same as CALL SUB2()
END SUBROUTINE SUB1
SUBROUTINE SUB2(C)
LOGICAL, OPTIONAL :: C
PRINT *, PRESENT(C) ! Prints F
END SUBROUTINE SUB2
END
See Also
OPTIONAL attribute
PRESENT intrinsic function
Argument association for details on general rules for procedure argument association
CALL for details on argument keywords in subroutine references
Function References for details on argument keywords in function references
Array Arguments
Arrays are sequences of elements. Each element of an actual array is associated with the element of the
dummy array that has the same position in array element order.
If the dummy argument is an explicit-shape or assumed-size array, the size of the dummy argument array
must not exceed the size of the actual argument array.
The type and kind parameters of an explicit-shape or assumed-size dummy argument must match the type
and kind parameters of the actual argument, but their ranks need not match.
If the dummy argument is an assumed-shape array, the size of the dummy argument array is equal to the
size of the actual argument array. The associated actual argument must not be an assumed-size array or a
scalar (including a designator for an array element or an array element substring).
912
Language Reference
If the actual argument is an array section with a vector subscript, the associated dummy argument must not
be defined and it must not have the INTENT (OUT), INTENT (INOUT), VOLATILE, or ASYNCHRONOUS
attribute.
If an actual argument is an array section or an assumed-shape array, and the corresponding dummy
argument has either the VOLATILE or ASYNCHRONOUS attribute, that dummy argument must be an
assumed-shape array.
If an actual argument is a pointer array, and the corresponding dummy argument has either the VOLATILE or
ASYNCHRONOUS attribute, that dummy argument must be an assumed-shape array or a pointer array.
The declaration of an array used as a dummy argument can specify the lower bound of the array.
If a dummy argument is allocatable, the actual argument must be allocatable and the type parameters and
ranks must agree. An example of an allocatable function with allocatable arrays appears in FUNCTION.
Dummy argument arrays declared as assumed-shape, deferred-shape, or pointer arrays require an explicit
interface visible to the caller.
See Also
Arrays
Array association
Procedure Interfaces
Argument association for details on general rules for procedure argument association
Array Elements for details on array element order
Explicit-Shape Specifications for details on explicit-shape arrays
Assumed-Shape Specifications for details on assumed-shape arrays
Assumed-Size Specifications for details on assumed-size arrays
Pointer Arguments
An argument is a pointer if it is declared with the POINTER attribute.
When a procedure is invoked, the dummy argument pointer receives the pointer association status of the
actual argument. If the actual argument is currently associated, the dummy argument becomes associated
with the same target.
The pointer association status of the dummy argument can change during the execution of the procedure,
and any such changes are reflected in the actual argument.
If both the dummy and actual arguments are pointers, an explicit interface is required.
A dummy argument that is a pointer can be associated only with an actual argument that is a pointer.
However, an actual argument that is a pointer can be associated with a nonpointer dummy argument. In this
case, the actual argument is associated with a target and the dummy argument, through argument
association, also becomes associated with that target.
If the dummy argument does not have the TARGET or POINTER attribute, any pointers associated with the
actual argument do not become associated with the corresponding dummy argument when the procedure is
invoked.
If the dummy argument has the TARGET attribute, and is either a scalar or assumed-shape array, and the
corresponding actual argument has the TARGET attribute but is not an array section with a vector subscript,
the following occurs:
• Any pointer associated with the actual argument becomes associated with the corresponding dummy
argument when the procedure is invoked.
• Any pointers associated with the dummy argument remain associated with the actual argument when
execution of the procedure completes.
If the dummy argument has the TARGET attribute, and is an explicit-shape or assumed-size array, and the
corresponding actual argument has the TARGET attribute but is not an array section with a vector subscript,
association of actual and corresponding dummy arguments when the procedure is invoked or when execution
is completed is processor dependent.
913
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If the dummy argument has the TARGET attribute and the corresponding actual argument does not have that
attribute or is an array section with a vector subscript, any pointer associated with the dummy argument
becomes undefined when execution of the procedure completes.
See Also
POINTER statement and attribute
Pointer assignments
TARGET statement and attribute
Argument association for details on general rules for procedure argument association
See Also
TYPE
Passed-Object Dummy Arguments
914
Language Reference
See Also
LEN intrinsic function
Argument association for details on general rules for procedure argument association
See Also
Argument association for details on general rules for procedure argument association
915
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
You can also use the RETURN statement to specify alternate returns.
The following example shows alternate return actual and dummy arguments:
CALL MINN(X, Y, *300, *250, Z)
...
SUBROUTINE MINN(A, B, *, *, C)
See Also
Argument association for details on general rules for procedure argument association
SUBROUTINE statement
CALL statement
RETURN statement
Deleted and Obsolescent Language Features for details on obsolescent features in Standard
Fortran
See Also
Argument association for details on general rules for procedure argument association
916
Language Reference
Examples
When a procedure is invoked on a particular image, each dummy coarray is associated with its ultimate
argument on the image. During the execution of the procedure, this image can access the coarray
corresponding to the ultimate argument on any other image. For example, consider the following:
INTERFACE
SUBROUTINE MY_SUB(Y)
REAL :: Y[*]
END SUBROUTINE MY_SUB
END INTERFACE
...
REAL :: B(700)[:]
...
CALL MY_SUB(B(10))
When subroutine MY_SUB is invoked, the executing image has access through the syntax Y[P] to B(10) on
image P.
Each invocation of a procedure with a nonallocatable coarray dummy argument establishes a dummy coarray
for the image with its own bounds and cobounds. During the execution of the procedure, this image may use
its own bounds and cobounds to access the coarray corresponding to the ultimate argument on any other
image. For example, consider the following:
INTERFACE
SUBROUTINE MY_SUB(Y,I)
INTEGER :: I
REAL :: Y(I,I)[I,*]
END SUBROUTINE MY_SUB
END INTERFACE
...
REAL :: B(1000)[:]
...
CALL MY_SUB(B,10)
When subroutine MY_SUB is invoked, the executing image has access through the syntax Y(1,2)[3,4] to
B(11) on the image with image index 33.
See Also
Image Control Statements
See Also
Unambiguous Generic Procedure References
Intrinsic procedures
Resolving Procedure References
917
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Defining Generic Names for Procedures for details on user-defined generic procedures
NOTE
If you call an intrinsic procedure by using the wrong number of arguments or an incorrect argument
type, the compiler assumes you are referring to an external procedure. For example, intrinsic
procedure SIN requires one argument; if you specify two arguments, such as SIN(10,4), the compiler
assumes SIN is external and not intrinsic.
The data type of an intrinsic procedure does not change if you use an IMPLICIT statement to change the
implied data type rules.
Intrinsic and user-defined procedures cannot have the same name if they appear in the same program unit.
Examples
The following example shows the local and global properties of an intrinsic function name. It uses the name
SIN in different procedures as follows:
• The name of a statement function
• The generic name of an intrinsic function
• The specific name of an intrinsic function
• The name of a user-defined function
Using and Redefining an Intrinsic Function Name
918
Language Reference
SUBROUTINE COMPUT(Y)
DOUBLE PRECISION Y
! Makes the generic name SIN reference the double-precision sine DSIN
V(1) = SIN(Y)
SUBROUTINE SUB(A,S)
919
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The statement function named SIN is defined in terms of the generic function name COS. Because the
argument of COS is double precision, the double-precision cosine function is evaluated. The statement
function SIN is itself single precision.
The name SIN is declared intrinsic so that the single-precision intrinsic sine function can be passed as an
actual argument at 5.
The generic function name SIN is used to refer to the double-precision sine function.
The user-defined SIN function is defined as a simple Taylor series using a user-defined function FACTOR
to compute the factorial function.
See Also
EXTERNAL attribute
INTRINSIC attribute
Intrinsic procedures
Names for details on the scope of names
920
Language Reference
Examples
Consider the following:
See Also
Arrays
Intrinsic procedures for details on elemental procedures
Procedure Interfaces
Every procedure has an interface, which consists of the name and characteristics of a procedure, the name
and characteristics of each dummy argument, and the generic identifier (if any) by which the procedure can
be referenced. The characteristics of a procedure are fixed, but the remainder of the interface can change in
different scoping units.
If these properties are all known within the scope of the calling program, the procedure interface is explicit;
otherwise it is implicit (deduced from its reference and declaration). The following table shows which
procedures have implicit or explicit interfaces:
The interface of a recursive subroutine or function is explicit within the subprogram that defines it.
An explicit interface can come from any of the following:
• An interface block
• The procedure's definition in a module
• An internal procedure
A procedure must not access through use association its own interface.
An abstract interface lets you give a name to a set of characteristics and argument keyword names that
create an explicit interface to a procedure. It does not declare any actual procedure to have those
characteristics.
921
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Depending on the characteristics of the procedure and its dummy arguments, an explicit interface may be
required to be visible to its caller. For more information see Procedures that Require Explicit Interfaces.
You can use a procedure declaration statement to declare procedure pointers, dummy procedures, and
external procedures. It specifies the EXTERNAL attribute for all procedure entities in the procedure
declaration list.
You can use the IMPORT statement to make host entities accessible in the interface body of an interface
block.
You can specify the ALLOCATABLE, OPTIONAL, or POINTER attributes for a dummy argument in a procedure
interface that has the BIND attribute.
Examples
An example of an interface block follows:
INTERFACE
SUBROUTINE Ext1 (x, y, z)
REAL, DIMENSION (100,100) :: x, y, z
END SUBROUTINE Ext1
See Also
INTERFACE
ABSTRACT INTERFACE
PROCEDURE
IMPORT
922
Language Reference
See Also
Optional arguments
Array arguments
Pointer arguments
CALL for details on argument keywords in subroutine references
Function references for details on argument keywords in function references
Pure procedures
Elemental procedures
Procedure Interfaces
Defining Generic Names for Procedures for details on user-defined generic procedures
Defining Generic Operators for details on defined operators
Defining Generic Assignment for details on defined assignment
Parameterized Derived-Type Declarations
generic-name Is the generic name. It can be the same as any of the procedure
names in the interface block, or the same as any accessible generic
name (including a generic intrinsic name).
A generic name can be the same as a derived-type name. In this
case, all of the procedures in the interface block must be functions.
923
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
SUBROUTINE REAL_LINE_EQ(X1,Y1,X2,Y2,M,B)
REAL,INTENT(IN) :: X1,Y1,X2,Y2
REAL,INTENT(OUT) :: M,B
END SUBROUTINE REAL_LINE_EQ
SUBROUTINE INT_LINE_EQ(X1,Y1,X2,Y2,M,B)
INTEGER,INTENT(IN) :: X1,Y1,X2,Y2
INTEGER,INTENT(OUT) :: M,B
END SUBROUTINE INT_LINE_EQ
END INTERFACE
In this example, LINE_EQUATION is the generic name which can be used for either REAL_LINE_EQ or
INT_LINE_EQ. Fortran selects the appropriate subroutine according to the nature of the arguments passed to
LINE_EQUATION. Even when a generic name exists, you can always invoke a procedure by its specific name.
In the previous example, you can call REAL_LINE_EQ by its specific name (REAL_LINE_EQ), or its generic
name LINE_EQUATION.
See Also
INTERFACE statement for details on interface blocks
GENERIC statement for an alternate to interface blocks for declaring generic procedures
924
Language Reference
The functions within the interface block must have one or two nonoptional arguments with the INTENT(IN)
and/or the VALUE attribute, and the function result must not be of type character with assumed length. A
defined operation is treated as a reference to the function.
The following shows the form (and an example) of a defined unary and defined binary operation:
For intrinsic operator symbols, the generic properties include the intrinsic operations they represent. Both
forms of each relational operator have the same interpretation, so extending one form (such as >=) defines
both forms (>= and .GE.).
The following is an example of a procedure interface block defining a new operator:
INTERFACE OPERATOR(.BAR.)
FUNCTION BAR(A_1)
INTEGER, INTENT(IN) :: A_1
INTEGER :: BAR
END FUNCTION BAR
END INTERFACE
The following example shows a way to reference function BAR by using the new operator:
INTEGER B
I = 4 + (.BAR. B)
The following is an example of a procedure interface block with a defined operator extending an existing
operator:
INTERFACE OPERATOR(+)
FUNCTION LGFUNC (A, B)
LOGICAL, INTENT(IN) :: A(:), B(SIZE(A))
LOGICAL :: LGFUNC(SIZE(A))
END FUNCTION LGFUNC
END INTERFACE
The following example shows two equivalent ways to reference function LGFUNC:
LOGICAL, DIMENSION(1:10) :: C, D, E
N = 10
E = LGFUNC(C(1:N), D(1:N))
E = C(1:N) + D(1:N)
See Also
INTENT attribute
INTERFACE for details on interface blocks
Expressions for details on intrinsic operators
Defined Operations for details on defined operators and operations
925
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Defined Assignments
INTENT attribute
INTERFACE statement for details on interface blocks
926
Language Reference
927
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Procedure Pointers
A procedure pointer has the POINTER attribute and points to a procedure instead of a data object. It can be
associated with an external procedure, a module procedure, an intrinsic procedure, or a dummy procedure
that is not a procedure pointer. It can have an implicit or explicit interface, but the interface cannot be
generic or elemental.
A procedure pointer can be one of the following:
• A named pointer (described below)
• A derived-type component (See Procedure Pointers as Derived-Type Components.)
POINTER :: MyP
INTERFACE
SUBROUTINE MyP(c,d)
REAL, INTENT(INOUT) :: c
REAL, INTENT(IN) :: d
END SUBROUTINE MyP
END INTERFACE
REAL, EXTERNAL, POINTER :: MyR
The above specifies that MyP is a pointer to a subroutine with an explicit interface. It also specifies that MyR
is a pointer to a scalar REAL function with an implicit interface.
Note that in a type declaration statement, you must specify the EXTERNAL attribute as well as the POINTER
attribute when declaring the procedure pointer.
See Also
INTERFACE
ABSTRACT INTERFACE
PROCEDURE
Intrinsic Procedures
Intrinsic procedures are functions and subroutines that are included in the Fortran library. The following are
classes of intrinsic procedures:
• Elemental procedures
These procedures have scalar dummy arguments that can be called with scalar or array actual arguments.
There are many elemental intrinsic functions and one elemental intrinsic subroutine (MVBITS). All
elemental intrinsic procedures are pure.
928
Language Reference
If the arguments are all scalar, the result is scalar. If an actual argument is array-valued, the intrinsic
procedure is applied to each element of the actual argument, resulting in an array that has the same
shape as the actual argument.
If there is more than one array-valued argument, they must all have the same shape.
Many algorithms involving arrays can now be written conveniently as a series of computations with whole
arrays. For example, consider the following:
a = b + c
... ! a, b, c, and s are all arrays of similar shape
s = sum(a)
The above statements can replace entire DO loops.
Consider the following:
real, dimension (5,5) :: x,y
. . . ! Assign values to x
y = sin(x) ! Pass the entire array as an argument
In this example, since the SIN(X) function is an elemental procedure, it operates element-by-element on
the array x when you pass it the name of the whole array.
• Inquiry functions
These functions have results that depend on the properties of their principal argument, not the value of
the argument (the argument value can be undefined).
• Transformational functions
These functions have one or more array-valued dummy or actual arguments, an array result, or both. The
intrinsic function is not applied elementally to an array-valued actual argument; instead it changes
(transforms) the argument array into another array.
• Nonelemental procedures
These procedures must be called with only scalar arguments; they return scalar results. All subroutines
(except MVBITS) are nonelemental.
• Atomic subroutines
These subroutines perform an action on a variable (its atom argument) atomically. When an atomic
subroutine is executed, it is as if the subroutine were executed instantaneously without overlapping other
atomic actions that might occur asynchronously. For information on the semantics of atomic subroutines,
see Overview of Atomic Subroutines.
• Collective subroutines
These subroutines perform a cooperative calculation on a team of images and require no synchronization.
For information on the semantics of collective subroutines, see Overview of Collective Subroutines.
The intrinsic subroutine MVBITS, and the subroutine MOVE_ALLOC with a noncoarray argument FROM, are
pure. All other intrinsic subroutines are impure.
Intrinsic procedures are invoked the same way as other procedures, and follow the same rules of argument
association.
The intrinsic procedures have generic (or common) names, and many of the intrinsic functions have specific
names. (Some intrinsic functions are both generic and specific.)
In general, generic functions accept arguments of more than one data type; the data type of the result is the
same as that of the arguments in the function reference. For elemental functions with more than one
argument, all arguments must be of the same type (except for the function MERGE).
When an intrinsic function is passed as an actual argument to a procedure, its specific name must be used,
and when called, its arguments must be scalar. Some specific intrinsic functions are not allowed as actual
arguments in all circumstances. The following table lists specific functions that cannot be passed as actual
arguments or as targets in procedure pointer assignment statements.
Starting with Fortran 2018, specific names of intrinsic functions that also have generic names are
obsolescent.
929
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Note that none of the intrinsic subroutines can be passed as actual arguments or as targets in procedure
pointer assignment statements.
The A to Z Reference contains the descriptions of all intrinsics listed in alphabetical order. Each reference
entry indicates whether the procedure is inquiry, elemental, transformational, or nonelemental, and whether
it is a function or a subroutine.
See Also
Argument association
MERGE
Optional arguments
Data representation models
References to Generic Intrinsic Functions
930
Language Reference
Some argument keywords are optional (denoted by square brackets). The following describes some of the
most commonly used optional arguments:
Examples
The syntax for the DATE_AND_TIME intrinsic subroutine shows four optional positional arguments: DATE,
TIME, ZONE, and VALUES. The following shows some valid ways to specify these arguments:
! Keyword example
CALL DATE_AND_TIME (ZONE=Z)
! Positional example
CALL DATE_AND_TIME (DATE, TIME, ZONE)
See Also
CALL for details on argument keywords in subroutine references
Function references for details on argument keywords in function references
Argument Association
931
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If stat is present and an error condition occurs, any INTENT(INOUT) or INTENT(OUT) argument becomes
undefined. If the atom argument is on a failed image, stat, if present, becomes defined with the value
STAT_FAILED_IMAGE from the intrinsic module ISO_FORTRAN_ENV and an error condition occurs. If any
other error condition occurs, stat becomes defined with a processor-dependent positive integer value other
than that of STAT_FAILED_IMAGE.
If an error condition occurs and stat is not present, error termination is initiated.
For a list of all atomic intrinsic subroutines, including links to the subroutine's full description, see Atomic
Intrinsic Subroutines.
932
Language Reference
A bit field is a contiguous group of bits within a binary pattern. Bit fields are specified by a starting bit
position and a length. A bit field must be entirely contained in its source operand.
For example, the integer 47 is represented by the following:
You can refer to the bit field contained in bits 3 through 6 by specifying a starting position of 3 and a length
of 4.
Negative integers are represented in two's complement notation. For example, the integer -47 is represented
by the following:
INTEGER(1) 1
INTEGER(2) 2
933
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
INTEGER(4) 4
INTEGER(8) 8
The bit manipulation functions each have a generic form that operates on all of these integer types and a
specific form for each type.
When you specify the intrinsic functions that refer to bit positions or that shift binary patterns within a
storage unit, be careful that you do not create a value that is outside the range of integers representable by
the data type. If you shift by an amount greater than or equal to the size of the object you're shifting, the
result is 0.
Consider the following:
INTEGER(2) I,J
I = 1
J = 17
I = ISHFT(I,J)
The variables I and J have INTEGER(2) type. Therefore, the generic function ISHFT maps to the specific
function IISHFT, which returns an INTEGER(2) result. INTEGER(2) results must be in the range -32768 to
32767, but the value 1, shifted left 17 positions, yields the binary pattern 1 followed by 17 zeros, which
represents the integer 131072. In this case, the result in I is 0.
The previous example would be valid if I was INTEGER(4), because ISHFT would then map to the specific
function JISHFT, which returns an INTEGER(4) value.
If ISHFT is called with a constant first argument, the result will either be the default integer size or the
smallest integer size that can contain the first argument, whichever is larger.
934
Language Reference
935
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
936
Language Reference
937
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1 All of the numeric manipulation, and many of the numeric inquiry functions are defined by the model
The following table summarizes the generic intrinsic functions and indicates whether they are elemental,
inquiry, or transformational functions. Optional arguments are shown within square brackets.
Some intrinsic functions are specific with no generic association. These functions are listed below.
Summary of Generic Intrinsic Functions
Generic Function Class Value Returned
938
Language Reference
939
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
940
Language Reference
941
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
942
Language Reference
943
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
944
Language Reference
MAXLOC (ARRAY, DIM [, MASK, T The rank-one array that has the
KIND, BACK]) or MAXLOC location of the maximum element
(ARRAY [, MASK, KIND, BACK]) in the argument array
MINLOC (ARRAY, DIM [, MASK, T The rank-one array that has the
KIND, BACK]) or MINLOC (ARRAY location of the minimum element
[, MASK, KIND, BACK]) in the argument array
945
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
946
Language Reference
947
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
948
Language Reference
Key to Classes
E-Elemental
I-Inquiry
T-Transformational
The following table lists specific functions that have no generic function associated with them and indicates
whether they are elemental, nonelemental, or inquiry functions. Optional arguments are shown within square
brackets.
Specific Functions with No Generic Association
Generic Function Class Value Returned
949
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Key to Classes
E-Elemental
I-Inquiry
N-Nonelemental
Intrinsic Subroutines
The following table lists the intrinsic subroutines. Optional arguments are shown within square brackets. All
these subroutines are nonelemental except for MVBITS. All of these subroutines, with the exception of
MVBITS, and MOVE_ALLOC with a noncoarray FROM argument, are impure. None of the intrinsic subroutines
can be passed as actual arguments.
Intrinsic Subroutines
Subroutine Value Returned or Result
950
Language Reference
ATOMIC_CAS (atom, old, compare, new [,stat]) Performs atomic compare and swap.
ATOMIC_FETCH_ADD (atom, value, old [, stat]) Performs atomic fetch and addition.
ATOMIC_FETCH_AND (atom, value, old [, stat]) Performs atomic fetch and bitwise AND.
ATOMIC_FETCH_OR (atom, value, old [, stat]) Performs atomic fetch and bitwise OR.
ATOMIC_FETCH_XOR (atom, value, old [, stat]) Performs atomic fetch and bitwise exclusive OR.
CO_MAX (a, result_image [, stat, errmsg]) Computes maximum value across images.
CO_MIN (a, result_image [, stat, errmsg]) Computes minimum value across images.
CO_REDUCE (a, operation [, result_image, stat, Performs a generalized reduction across images.
errmsg])
CO_SUM (a, result_image [, stat, errmsg]) Performs a sum reduction across images.
DATE_AND_TIME ([date] [,time] [,zone] [,values]) Returns the date and time information from the
real-time clock.
ERRSNS ([io_err] [,sys_err] [,stat] [,unit] [,cond]) Returns information about the most recently
detected error condition.
GETARG (n, buffer [,status]) Returns the specified command line argument
(where the command itself is argument number
zero).
GET_COMMAND ([command, length, status, Returns the entire command that was used to
errmsg]) invoke the program.
951
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
MM_PREFETCH (address [,hint] [,fault] Returns data from the specified address on one
[,exclusive]) memory cache line.
MVBITS (from, frompos, len, to, topos)1 Causes a sequence of bits (bit field) to be copied
from one location to another.
SYSTEM_CLOCK ([count] [,count_rate] Returns data from the processors real-time clock.
[,count_max])
952
Language Reference
The PRINT statement is the same as a formatted, sequential WRITE statement, except that the PRINT
statement must never transfer data to user-specified I/O units.
TYPE is a synonym for PRINT. All forms and rules for the PRINT statement also apply to the TYPE
statement.
• REWRITE
It rewrites the current record and it can be formatted or unformatted.
File connection, file inquiry, and file positioning I/O statements are discussed in File Operation I O
Statements.
See Also
Unit Specifier (UNIT=)
io-keyword Is one of the following: ACCEPT, PRINT (or TYPE), READ, REWRITE, or
WRITE.
953
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
io-list Is an I/O list, which can contain variables (except for assumed-size
arrays) or implied-DO lists. Output statements can contain constants
or expressions.
If a format specifier ([FMT=]format) or namelist specifier ([NML=]group) is present, the data transfer
statement is called a formatted I/O statement; otherwise, it is an unformatted I/O statement.
If a record specifier (REC=) is present, the data transfer statement is a direct-access I/O statement;
otherwise, it is a sequential-access I/O statement.
If an error, end-of-record, or end-of-file condition occurs during data transfer, file positioning and execution
are affected, and certain control-list specifiers (if present) become defined. (For more information, see
Branch Specifiers.)
Following sections describe the I/O control list and I/O lists.
954
Language Reference
When a mix of keyword and nonkeyword forms is used for control-list specifiers in an I/O statement, the
nonkeyword values must appear first. Once a keyword form of a specifier is used, all specifiers to the right
must also be keyword forms.
io-unit For external files, it identifies a logical unit and is one of the following:
• A scalar integer expression that refers to a specific file, I/O device,
or pipe. If necessary, the value is converted to integer data type
before use. The integer is in the range 0 through 2,147,483,643,
equal to the value of one of the constants INPUT_UNIT,
OUTPUT_UNIT or ERROR_UNIT from intrinsic module
ISO_FORTRAN_ENV, or a value returned by a NEWUNIT= specifier
from an OPEN statement.
Units 5, 6, and 0 are associated with preconnected units.
• An asterisk (*). This is the default (or implicit) external unit, which
is preconnected for formatted sequential access. You can also
preconnect files by using an environment variable.
For internal files, it identifies a scalar or array character variable that
is an internal file. An internal file is designated internal storage space
(a variable buffer) that is used with formatted (including list-directed)
sequential READ and WRITE statements.
The io-unit must be specified in a control list. If the keyword UNIT is omitted, the io-unit must be first in the
control list.
A unit number is assigned either explicitly through an OPEN statement or implicitly by the system. If a READ
statement implicitly opens a file, the file's status is STATUS='OLD'. If a WRITE statement implicitly opens a
file, the file's status is STATUS='UNKNOWN'.
If the internal file is a scalar character variable, the file has only one record; its length is equal to that of the
variable.
If the internal file is an array character variable, the file has a record for each element in the array; each
record's length is equal to one array element.
An internal file can be read only if the variable has been defined and a value assigned to each record in the
file. If the variable representing the internal file is a pointer, it must be associated; if the variable is an
allocatable array, it must be currently allocated.
Before data transfer, an internal file is always positioned at the beginning of the first character of the first
record.
See Also
OPEN statement
955
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• A scalar default integer variable that has been assigned the label of
a FORMAT statement (through an ASSIGN statement)
The FORMAT statement must be in the same scoping unit as the
data transfer statement.
• A character expression (which can be an array or character
constant) containing the run-time format
A default character expression must evaluate to a valid format
specification. If the expression is an array, it is treated as if all the
elements of the array were specified in array element order and
were concatenated.
• The name of a numeric array (or array element) containing the
format
If the keyword FMT is omitted, the format specifier must be the second specifier in the control list; the io-unit
specifier must be first.
If a format specifier appears in a control list, a namelist group specifier must not appear.
See Also
FORMAT statement
Interaction between FORMAT statements and I/O lists
Rules for List-Directed Sequential READ Statements for details on list-directed input
Rules for List-Directed Sequential WRITE Statements for details on list-directed output
If the keyword NML is omitted, the namelist specifier must be the second specifier in the control list; the io-
unit specifier must be first.
If a namelist specifier appears in a control list, a format specifier must not appear.
See Also
Rules for Namelist Sequential READ Statements for details on namelist input
Rules for Namelist Sequential WRITE Statements for details on namelist output
READ
WRITE
956
Language Reference
See Also
Alternative Syntax for a Record Specifier
Execution continues with the statement following the data transfer statement, or the statement identified by
a branch specifier (if any).
An end-of-file condition occurs only during execution of a sequential READ statement; an end-of-record
condition occurs only during execution of a nonadvancing READ statement.
See Also
List of Run-Time Error Messages
CLOSE
READ
WRITE
label Is the label of the branch target statement that receives control when
the specified condition occurs.
The branch target statement must be in the same scoping unit as the
data transfer statement.
957
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If IOSTAT was specified, the IOSTAT variable becomes defined as a positive integer value. If SIZE was
specified (in a nonadvancing READ statement), the SIZE variable becomes defined as an integer value. If
a label was specified, execution continues with the labeled statement.
• END
The end-of-file specifier can appear only in a sequential access READ statement.
An end-of-file condition occurs when no more records exist in a file during a sequential read, or when an
end-of-file record produced by the ENDFILE statement is encountered. End-of-file conditions do not occur
in direct-access READ statements.
If an end-of-file condition occurs, the file is positioned after the end-of-file record, and execution of the
statement terminates.
If IOSTAT was specified, the IOSTAT variable becomes defined as a negative integer value. If a label was
specified, execution continues with the labeled statement.
• EOR
The end-of-record specifier can appear only in a formatted, sequential access READ statement that has
the specifier ADVANCE='NO'(nonadvancing input).
An end-of-record condition occurs when a nonadvancing READ statement tries to transfer data from a
position after the end of a record.
If an end-of-record condition occurs, the file is positioned after the current record, and execution of the
statement terminates.
If IOSTAT was specified, the IOSTAT variable becomes defined as a negative integer value. If PAD='YES'
was specified for file connection, the record is padded with blanks (as necessary) to satisfy the input item
list and the corresponding data edit descriptor. If SIZE was specified, the SIZE variable becomes defined
as an integer value. If a label was specified, execution continues with the labeled statement.
If one of the conditions occurs, no branch specifier appears in the control list, but an IOSTAT specifier
appears, execution continues with the statement following the I/O statement. If neither a branch specifier
nor an IOSTAT specifier appears, the program terminates.
See Also
I/O Status Specifier
Branch Statements
Compiler Reference section: Error Handling for details on error processing
The ADVANCE specifier can appear only in a formatted, sequential data transfer statement that specifies an
external unit. It must not be specified for list-directed or namelist data transfer, for a data transfer statement
within a DO CONCURRENT block, nor for a data transfer statement within a DO CONCURRENT block.
Advancing I/O always positions a file at the end of a record, unless an error condition occurs. Nonadvancing
I/O can position a file at a character position within the current record.
See Also
Compiler Reference: Data and I/O: Fortran I/O: Advancing and Nonadvancing Record I/O
958
Language Reference
Asynchronous I/O is permitted only for external files opened with an OPEN statement that specifies
ASYNCHRONOUS='YES'.
When an asynchronous I/O statement is executed, the pending I/O storage sequence for the data transfer
operation is defined to be:
• The set of storage units specified by the I/O item list or by the NML= specifier
• The storage units specified by the SIZE= specifier
If PAD='YES' was specified for file connection, blanks inserted as padding are not counted.
For input statements, the SIZE= specifier can appear only in a formatted, sequential READ statement that
has the specifier ADVANCE='NO' (nonadvancing input). It must not be specified for list-directed or namelist
data transfer.
For asynchronous nonadvancing input, the storage units specified in the SIZE= specifier become defined with
the count of the characters transferred when the corresponding wait operation is executed.
ID Specifier (ID=)
The ID specifier identifies a pending data transfer operation for a specified unit. It takes the following form:
ID=id-var
If an ID specifier is used in a data transfer statement, a wait operation is performed for the operation. If it is
omitted, wait operations are performed for all pending data transfers for the specified unit.
If an error occurs during the execution of a data transfer statement containing an ID specifier, the variable
specified becomes undefined.
In an INQUIRE statement, the ID= specifier identifies a pending asynchronous data transfer. It is is used with
the PENDING specifier to determine whether a specific asynchronous pending data transfer is completed.
959
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Each file storage unit has a unique file position, represented by a positive integer. The first file storage unit is
a file is at file position 1. The position of each subsequent file storage unit is one greater than that of its
preceding file storage unit.
For a formatted file, the file storage unit is an eight-bit byte. For an unformatted file, the file storage unit is
an eight-bit byte (if option assume byterecl is specified) or a 32-bit word (if option assume nobyterecl, the
default, is specified).
If an error (ERR=), end-of-file (END=), or end-of-record (EOR=) condition occurs during execution of an I/O
statement, msg-var is assigned an explanatory message.
If no error occurs, the value of the variable remains unchanged.
I/O Lists
In a data transfer statement, the I/O list specifies the entities whose values will be transferred. An input list
is made up of implied-do lists and simple lists of variables (except for assumed-size arrays). An output list is
made up of implied-do lists, expressions, and simple lists of variables (except for assumed-size arrays).
In input statements, the I/O list cannot contain constants and expressions because these do not specify
named memory locations that can be referenced later in the program.
However, constants and expressions can appear in the I/O lists for output statements because the compiler
can use temporary memory locations to hold these values during the execution of the I/O statement.
If an input item is a pointer, it must be currently associated with a definable target; data is transferred from
the file to the associated target. If an output item is a pointer, it must be currently associated with a target;
data is transferred from the target to the file.
If an input or output item is an array, it is treated as if the elements (if any) were specified in array element
order. For example, if ARRAY_A is an array of shape (2,1), the following input statements are equivalent:
READ *, ARRAY_A
READ *, ARRAY_A(1,1), ARRAY_A(2,1)
However, no element of that array can affect the value of any expression in the input list, nor can any
element appear more than once in an input list. For example, the following input statements are invalid:
INTEGER B(50)
...
READ *, B(B)
READ *, B(B(1):B(10))
If an input or output item is an allocatable array, it must be currently allocated.
If an input or output item is a derived type, the following rules apply:
• Any derived-type component must be in the scoping unit containing the I/O statement.
• The derived type must not have a pointer component.
• In a formatted I/O statement, a derived type is treated as if all of the components of the structure were
specified in the same order as in the derived-type definition.
• In an unformatted I/O statement, a derived type is treated as a single object.
960
Language Reference
See Also
Simple List Items in I/O Lists
Implied-DO Lists in I/O Lists
The data transfer statement assigns values to (or transfers values from) the list items in the order in which
the items appear, from left to right.
When multiple array names are used in the I/O list of an unformatted input or output statement, only one
record is read or written, regardless of how many array name references appear in the list.
Examples
The following example shows a simple I/O list:
DIMENSION ARRAY(3,3)
If the name ARRAY appears with no subscripts in a READ statement, that statement assigns values from the
input record(s) to ARRAY(1,1), ARRAY(2,1), ARRAY(3,1), ARRAY(1,2), and so on through ARRAY(3,3).
An input record contains the following values:
1,3,721.73
The following example shows how variables in the I/O list can be used in array subscripts later in the list:
DIMENSION ARRAY(3,3)
...
READ (1,30) J, K, ARRAY(J,K)
When the READ statement is executed, the first input value is assigned to J and the second to K, establishing
the subscript values for ARRAY(J,K). The value 721.73 is then assigned to ARRAY(1,3). Note that the
variables must appear before their use as array subscripts.
Consider the following derived-type definition and structure declaration:
TYPE EMPLOYEE
INTEGER ID
CHARACTER(LEN=40) NAME
961
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
READ *, CONTRACT
! Namelist I/O:
INTEGER int1
LOGICAL log1
REAL r1
CHARACTER (20) char20
962
Language Reference
See Also
I/O Lists for details on the general rules for I/O lists
do-var Is the name of a scalar integer or real variable. The variable must not
be one of the input items in list.
expr Are scalar numeric expressions of type integer or real. They do not all
have to be the same type, or the same type as the DO variable.
The implied-DO loop is initiated, executed, and terminated in the same way as a DO construct.
The list is the range of the implied-DO loop. Items in that list can refer to do-var, but they must not change
the value of do-var.
Two nested implied-DO lists must not have the same (or an associated) DO variable.
Use an implied-DO list to do the following:
• Specify iteration of part of an I/O list
• Transfer part of an array
• Transfer array items in a sequence different from the order of subscript progression
If the I/O statement containing an implied-DO list terminates abnormally (with an END, EOR, or ERR branch
or with an IOSTAT value other than zero), the DO variable becomes undefined.
Examples
The following two output statements are equivalent:
963
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The inner DO loop is executed 10 times for each iteration of the outer loop; the second subscript (L)
advances from 1 through 10 for each increment of the first subscript (K). This is the reverse of the normal
array element order. Note that K is incremented by 2, so only the odd-numbered rows of the array are
output.
In the following example, the entire list of the implied-DO list (P(1), Q(1,1), Q(1,2)...,Q(1,10)) are read
before I is incremented to 2:
INTEGER mydata(25)
READ (10, 9000) (mydata(I), I=6,10,1)
9000 FORMAT (5I3)
In this example, the iolist specifies to put the input data into elements 6 through 10 of the array called
mydata. The third value in the implied-DO loop, the increment, is optional. If you leave it out, the increment
value defaults to 1.
See Also
Execution Control
I/O Lists for details on the general rules for I/O lists
Formatted:
READ (eunit, format [, advance] [, asynchronous] [, blank] [, decimal] [, id] [, pad] [, pos] [, round] [, size]
[, iostat] [, err] [, end] [, eor] [, iomsg]) [io-list]
READ form [, io-list]
Formatted - List-Directed:
READ (eunit, * [, asynchronous] [, blank] [, decimal] [, id] [, pad] [, pos] [, round] [, iostat] [, err] [, end]
[, iomsg]) [io-list]
READ * [, io-list]
964
Language Reference
Formatted - Namelist:
READ (eunit, nml-group [, asynchronous] [, blank] [, decimal] [, id] [, pad ] [, pos] [, round] [, iostat] [, err]
[, end] [, iomsg])
READ nml
Unformatted:
READ (eunit [, asynchronous] [, id] [, pos] [, iostat] [, err] [, end] [, iomsg]) [io-list]
See Also
READ
I/O control-list specifiers
I/O lists
Examples
The following example shows formatted, sequential READ statements:
See Also
READ statement
Forms for Sequential READ Statements
965
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
List-Directed Records
A list-directed external record consists of a sequence of values and value separators. A value can be any of
the following:
• A constant
Each constant must be a literal constant of type integer, real, complex, logical, or character; or a
nondelimited character string. Binary, octal, hexadecimal, Hollerith, and named constants are not
permitted.
In general, the form of the constant must be acceptable for the type of the list item. The data type of the
constant determines the data type of the value and the translation from external to internal form. The
following rules also apply:
• A numeric list item can correspond only to a numeric constant, and a character list item can
correspond only to a character constant. If the data types of a numeric list element and its
corresponding numeric constant do not match, conversion is performed according to the rules for
arithmetic assignment (see the table in Numeric Assignment Statements). Conversion is not performed
between numeric and logical types unless compiler option assume old_logical_ldio is in effect. The
decimal point in a numeric constant can either be a period if DECIMAL='POINT' or a comma if
DECIMAL='COMMA'.
• A complex constant has the form of a pair of real or integer constants separated by a comma if
DECIMAL='POINT' or a semicolon if DECIMAL='COMMA' and enclosed in parentheses. Blanks can
appear between the opening parenthesis and the first constant, before and after the separating comma
or semicolon, and between the second constant and the closing parenthesis.
• A logical constant represents true values (.TRUE. or any value beginning with T, .T, t, or .t) or false
values (.FALSE. or any value beginning with F, .F, f, or .f).
A character string does not need delimiting apostrophes or quotation marks if the corresponding I/O list
item is of type default character, and the following is true:
• The character string does not contain a blank, comma (,), or slash ( / ).
• The character string is not continued across a record boundary.
• The first nonblank character in the string is not an apostrophe or a quotation mark.
• The leading character is not a string of digits followed by an asterisk.
A nondelimited character string is terminated by the first blank, comma, slash, or end-of-record
encountered. Apostrophes and quotation marks within nondelimited character strings are transferred as
is.
• A null value
A null value is specified by two consecutive value separators (such as,,) or a nonblank initial value
separator. (A value separator before the end of the record does not signify a null value.)
A null value indicates that the corresponding list element remains unchanged. A null value can represent
an entire complex constant, but cannot be used for either part of a complex constant.
• A repetition of a null value (r*) or a constant (r*constant), where r is an unsigned, nonzero, integer literal
constant with no kind parameter, and no embedded blanks.
A value separator is any number of blanks, a slash, or a comma if DECIMAL='POINT' or a semicolon if
DECIMAL='COMMA', preceded or followed by any number of blanks. When any of these appear in a character
constant, they are considered part of the character constant, not value separators.
The end of a record is equivalent to a blank character, except when it occurs in a character constant. In this
case, the end of the record is ignored, and the character constant is continued with the next record (the last
character in the previous record is immediately followed by the first character of the next record).
Blanks at the beginning of a record are ignored unless they are part of a character constant continued from
the previous record. In this case, the blanks at the beginning of the record are considered part of the
constant.
966
Language Reference
Examples
Suppose the following statements are specified:
CHARACTER*14 C
DOUBLE PRECISION T
COMPLEX D,E
LOGICAL L,M
READ (1,*) I,R,D,E,L,M,J,K,S,T,C,A,B
Then suppose the following external record is read:
I 4
R 6.3
D (3.4,4.2)
E (3.0,2.0)
L .TRUE.
M .FALSE.
J Unchanged
K 14
S 14.6
T 14.6D0
C ABC,DEF/GHI' JK
A Unchanged
B Unchanged
With DECIMAL='COMMA', the following external record produces the same values as in the table above:
REAL a
INTEGER i
COMPLEX c
LOGICAL up, down
DATA a /2358.2E-8/, i /91585/, c /(705.60,819.60)/
DATA up /.TRUE./, down /.FALSE./
OPEN (UNIT = 9, FILE = 'listout', STATUS = 'NEW')
WRITE (9, *) a, i
WRITE (9, *) c, up, down
REWIND (9)
READ (9, *) a, i
READ (9, *) c, up, down
967
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
WRITE (*, *) a, i
WRITE (*, *) c, up, down
END
The preceding program produces the following output:
2.3582001E-05 91585
(705.6000,819.6000) T F
See Also
READ
Forms for Sequential READ Statements
Intrinsic Data Types for details on the literal constant forms of intrinsic data types
Rules for List-Directed Sequential WRITE Statements for details on list-directed output
Namelist Records
A namelist external record takes the following form:
&group-nameobject = value [{, | ;} object = value] .../
group-name Is the name of the group containing the objects to be given values.
The name must have been previously defined in a NAMELIST
statement in the scoping unit. The name cannot contain embedded
blanks and must be contained within a single record.
968
Language Reference
969
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Blanks can precede or follow the beginning ampersand (&), follow the group name, precede or follow the
equal sign, or precede the terminating slash.
Comments (beginning with ! only) can appear anywhere in namelist input. The comment extends to the end
of the source line.
If an entity appears more than once within the input record for a namelist data transfer, the last value is the
one that is used.
If there is more than one object = value pair, they must be separated by value separators.
A value separator is any number of blanks, a slash, or a comma if DECIMAL='POINT' or a semicolon if
DECIMAL='COMMA', preceded or followed by any number of blanks. When any of these appear in a character
constant, they are considered part of the character constant, not value separators.
The end of a record is equivalent to a blank character, except when it occurs in a character constant. In this
case, the end of the record is ignored, and the character constant is continued with the next record (the last
character in the previous record is immediately followed by the first character of the next record).
Blanks at the beginning of a record are ignored unless they are part of a character constant continued from
the previous record. In this case, the blanks at the beginning of the record are considered part of the
constant.
When the name in the input record is an array variable or a variable of derived type, the effect is as if the
variable represented were expanded into a sequence of scalar list items of intrinsic data types. Each input
value following the equal sign must comply with format specifications for the intrinsic type of the list item in
the corresponding position in the expanded sequence.
The number of values following the equal sign must be equal to or less than the number of list items in the
expanded sequence. In the latter case (less than), the effect is as if null values have been added to match
any remaining list items in the expanded sequence.
The string length in the NAMELIST statement is not checked against the size of the CHARACTER variable to
which it will be assigned. This means that an array of n elements written in a NAMELIST statement with
DELIM=NONE may not be read back as n values. For example, consider a three-element array ARR of three-
character elements with values "ABC","DEF","GHI". In DELIM=NONE form, it prints to the data file as follows:
ARR = ABCDEFGHI
If your program reads that data file, the value will be interpreted as one non-delimited string with the value
"ABCDEFGHI" because termination is caused by the trailing blank, tab, or new line.
In some cases, values can be read as more than one string; for example, if the values themselves have final
or internal blanks, tabs, or new lines. Consider that ARR contains strings "WX ","Y\tR", "S\nQ", where "\t" is
a tab character and "\n" is a newline character. In this case, the data file contains:
ARR = WX Y\tRS\nQ
The NAMELIST processing will interpret this as four non-delimited strings: "WX", "Y", "RS" and "Q".
NOTE
In NAMELIST declarations, you may get unexpected results if all of the following are true:
1. DELIM=NONE is in effect on input.
2. A character variable is followed by another variable.
3. The other variable is either an array variable that is subscripted or a string variable that is a
substring.
4. That subscript or substring expression contains blanks.
970
Language Reference
In Intel® Fortran, a list of values may follow the equal sign when the object is a single array element. In this
case, values are assigned to the specified array element and subsequent elements, in element sequence
order. For example, suppose the following input is read:
&ELEM
ARRAY_A(3)=34.54, 45.34, 87.63, 3*20.00
/
New values are assigned only to array ARRAY_A elements 3 through 8. The other element values are
unchanged.
&NLIST
A
B
C
/
If a blank followed by =? is entered, the following values are displayed:
&NLIST
A = 1.500000,
B = 2,
C = ABCDE
/
Examples
Suppose the following statements are specified:
971
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The NAMELIST statement associates the group name CONTROL with a list of five objects. The corresponding
READ statement reads the following input data from unit 1:
&CONTROL
TITLE='TESTT002AA',
INTERVAL=1,
RESET=.TRUE.,
START=10.2,
STOP =14.5
/
The following values are assigned to objects in group CONTROL:
TITLE TESTT002AA
RESET T
START 10.2
STOP 14.5
INTERVAL 1
It is not necessary to assign values to all of the objects declared in the corresponding NAMELIST group. If a
namelist object does not appear in the input statement, its value (if any) is unchanged.
Similarly, when character substrings and array elements are specified, only the values of the specified
variable substrings and array elements are changed. For example, suppose the following input is read:
&CONTROL TITLE(9:10)='BB' /
The new value for TITLE is TESTT002BB; only the last two characters in the variable change.
The following example shows an array as an object:
DIMENSION ARRAY_A(20)
NAMELIST /ELEM/ ARRAY_A
READ (UNIT=1,NML=ELEM)
Suppose the following input is read:
&ELEM
ARRAY_A=1.1, 1.2,, 1.4
/
The following values are assigned to the ARRAY_A elements:
ARRAY_A(1) 1.1
ARRAY_A(2) 1.2
ARRAY_A(3) Unchanged
ARRAY_A(4) 1.4
ARRAY_A(5)...ARRAY(20) Unchanged
972
Language Reference
Nondelimited character strings that are written out by using a NAMELIST write may not be read in as
expected by a corresponding NAMELIST read. Consider the following:
NAMELIST/TEST/ CHARR
CHARACTER*3 CHARR(4)
DATA CHARR/'AAA', 'BBB', 'CCC', 'DDD'/
OPEN (UNIT=1, FILE='NMLTEST.DAT')
WRITE (1, NML=TEST)
END
The output file NMLTEST.DAT will contain:
NAMELIST/TEST/ CHARR
CHARACTER*3 CHARR(4)
DATA CHARR/4*' '/
OPEN (UNIT=1, FILE='NMLTEST.DAT')
READ (1, NML=TEST)
PRINT *, 'CHARR read in >', CHARR(1),'< >',CHARR(2),'< >',
1 CHARR(3), '< >', CHARR(4), '<'
END
The result is the following:
See Also
NAMELIST
Alternative Form for Namelist External Records
Rules for Formatted Sequential READ Statements
Rules for Namelist Sequential WRITE Statements
973
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
You have previously been able to buffer the output (WRITEs) of variable length, unformatted, sequential files,
by specifying certain values for an OPEN statement, environment variable, or compiler option. You can now
do the same buffering for input (READs) of records. To enable buffering for the input of records, you can
specify any of the following:
• BUFFERED=YES in the file's OPEN statement
• Value YES (Y or y), or TRUE (T or t), or a number > 0 for the environment variable FORT_BUFFERED
• Setting buffered_io for the assume option
When any of the above are specified, the Fortran Runtime Library buffers all input records from variable
length, unformatted, sequential files, regardless of the size of the records in the file. In addition, if the
environment variable FORT_ BUFFERING_THRESHOLD has a positive value n, the following occurs:
• I/O list items with a size <= n are buffered and are moved one at a time from the runtime buffer to the
I/O list item
• I/O list items with a size > n are not buffered and are moved one at a time from the file to the I/O list
item
record length >= block size record length < block size
If an input record's length is less than or equal to the specified block size, then by default, the runtime
system always optimizes for time rather than for space and the input is buffered.
974
Language Reference
If an input record’s length is greater than the specified block size, then the following occurs:
• By default, the runtime system always optimizes for space rather than time and the input is not buffered.
• If you request buffering of input, then the runtime system optimizes for time and the input is buffered.
• If you request no buffering of input, then the runtime system optimizes for space rather than time and the
input is not buffered.
• If you request dynamic buffering of input, the runtime system optimizes based on the size of the I/O list
item and some items are buffered and some are not.
Optimizing for time:
Traditionally, optimizing for time comes at the expense of using more memory.
When the runtime system optimizes for time, it buffers input. It reads as much data as possible during one
disk access into the runtime's internal buffer, extending it if necessary to hold the file's largest record. Fields
within the record are then moved to the user space in response to READs from the file. Typically, minimizing
file accesses is faster.
However, there are circumstances when optimizing for space can actually be faster than optimizing for time.
For example, consider you are reading records whose length exceeds the block size and the data is being
read into a contiguous array. Reading this huge array directly into a user's space is going to be faster than
reading it first into the runtime system's internal buffer, then moving the data to the user's space. In this
case, it is better to optimize for space; that is, you should not buffer the input record.
On the other hand, if the READ is being done into non-contiguous elements of an array, the traditional
method of optimizing for time becomes a huge win. Data being read into non-contiguous array elements
must be moved, or read, into the user's space one element at a time. In this case, you always want to
optimize for time; that is, you should buffer the input data.
If you are reading large, variable length, unformatted records, you should try both buffered and unbuffered
I/O to determine which delivers the better performance.
Optimizing for space:
Traditionally, optimizing for space comes at the expense of time.
When the runtime system optimizes for space, it wants to avoid creating a huge internal buffer in order to
hold a "very large" record. The size of a "very large" record is clearly subjective, but the rule of thumb here
is whether or not a record's size is greater than the specified block size.
If this is the case, the runtime system will read one field at a time from the record, directly into the I/O list
items. The optimal record for this optimization is one whose record length exceeds the default block size of
128 KB (or a user-specified block size) and contains "very large" fields.
Note that because fields are read one at a time from the file to the user space, very large records that
contain very small fields may see a serious performance issue. In these cases, it may be better to buffer the
input. If you are reading large, variable length, unformatted records, you should try both buffered and
unbuffered I/O to determine which delivers the better performance.
Optimizing unformatted sequential input based on field size - dynamic buffering:
Dynamic buffering is a hybrid solution that chooses the time/space trade-off on a per field basis. The decision
is based on a "field size threshold" supplied by the user, deciding, for every field in every record in the file,
regardless of the record length, whether or not to buffer a field from the file to the I/O list item. The runtime
system can do this because it knows the size of a field that is being requested before actually attempting to
read the field.
When a READ statement is first executed, a read from the file is issued to fill the buffer, regardless of its size.
This is necessary so that the runtime system can extract the record size from the first length control field.
(Each unformatted sequential record has 4-byte leading and trailing record lengths to facilitate reading both
975
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
forwards and backwards in the file.) From that point on, dynamic buffering decides whether or not to buffer a
field or to read it directly from the file to the I/O list item. If the buffer holds the beginning portion of a large
field, it will be moved to the start of the I/O list item and the remainder will be read directly from the file.
The following table shows the various buffering options for unformatted, sequential input:
Dynamic buffering You get this kind of buffering by When dynamic buffering is in
specifying: effect:
• FORT_BUFFERING_THRESHOL • The runtime system does not
D=n re-allocate its buffer to
accommodate large records.
- and one of -
• All fields with a size <= n are
• OPEN (BUFFERED=YES)
buffered and are moved one
- or - at a time from the buffer to
• FORT_BUFFERED=YES the I/O list item.
- or - • Fields with a size > n are not
• assume buffered_io buffered and are moved one
at a time from the file to the
I/O list item.
Examples
The following example shows an unformatted, sequential READ statement:
976
Language Reference
See Also
READ statement
Forms for Sequential READ Statements
Record Types
Formatted:
READ (eunit, format, rec [, asynchronous] [, blank] [, decimal ] [, id] [, pad ] [, pos] [, round] [, size ] [,
iostat] [, err] [, iomsg]) [io-list]
Unformatted:
READ (eunit, rec [, asynchronous] [, id] [, pos] [, iostat] [, err] [, iomsg]) [io-list]
See Also
READ
I/O control-list specifiers
I/O lists
Examples
The following example shows a formatted, direct-access READ statement:
977
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
For data transfer, the file must be positioned so that the record read is an unformatted record or an end-of-
file record.
The unformatted, direct-access READ statement reads a single record. Each value in the record must be of
the same type as the corresponding entity in the input list, unless the value is real or complex.
If the value is real or complex, one complex value can correspond to two real list entities, or two real values
can correspond to one complex list entity. The corresponding values and entities must have the same kind
parameter.
If the number of I/O list items is less than the number of fields in an input record, the statement ignores the
excess fields. If the number of I/O list items is greater than the number of fields in an input record, an error
occurs.
If the file is connected for formatted, list-directed, or namelist I/O, unformatted data transfer is prohibited.
Examples
The following example shows unformatted, direct-access READ statements:
Examples
The following example shows stream READ statements:
978
Language Reference
Values can be transferred to objects of intrinsic or derived types. For derived types, values of intrinsic types
are transferred to the components of intrinsic types that ultimately make up these structured objects.
Before data transfer occurs, the file is positioned at the beginning of the first record. This record becomes the
current record.
If the number of I/O list items is less than the number of fields in an input record, the statement ignores the
excess fields.
If the number of I/O list items is greater than the number of fields in an input record, the input record is
padded with blanks. However, if PAD='NO' was specified for file connection, the input list and file specification
must not require more characters from the record than it contains.
In list-directed and namelist formatting, character strings have no delimiters.
Examples
The following program segment reads a record and examines the first character to determine whether the
remaining data should be interpreted as decimal, octal, or hexadecimal. It then uses internal READ
statements to make appropriate conversions from character string representations to binary.
INTEGER IVAL
CHARACTER TYPE, RECORD*80
CHARACTER*(*) AFMT, IFMT, OFMT, ZFMT
PARAMETER (AFMT='(Q,A)', IFMT= '(I10)', OFMT= '(O11)', & ZFMT= '(Z8)')
ACCEPT AFMT, ILEN, RECORD
TYPE = RECORD(1:1)
IF (TYPE .EQ. 'D') THEN
READ (RECORD(2:MIN(ILEN, 11)), IFMT) IVAL
ELSE IF (TYPE .EQ. 'O') THEN
READ (RECORD(2:MIN(ILEN, 12)), OFMT) IVAL
ELSE IF (TYPE .EQ. 'X') THEN
READ (RECORD(2:MIN(ILEN, 9)),ZFMT) IVAL
ELSE
PRINT *, 'ERROR'
END IF
END
See Also
I/O control-list specifiers
I/O lists
Rules for List-Directed Sequential READ Statements for details on list-directed input
Rules for Namelist Sequential READ Statement for details on namelist input
Formatted:
WRITE (eunit, format [, advance] [, asynchronous] [, decimal ] [, id] [, pos] [, round] [, sign ] [, iostat] [,
err] [, iomsg]) [io-list]
979
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Formatted - List-Directed:
WRITE (eunit, * [, asynchronous] [, decimal ] [, delim ] [, id] [, pos] [, round ] [, sign ] [, iostat] [, err] [,
iomsg]) [io-list]
Formatted - Namelist:
WRITE (eunit, nml-group [, asynchronous] [, decimal ] [, delim ] [, id] [, pos] [, round ] [, sign ] [, iostat] [,
err] [, iomsg])
Unformatted:
WRITE (eunit [, asynchronous] [, id] [, pos] [, iostat] [, err] [, iomsg]) [io-list]
See Also
WRITE
I/O control-list specifiers
I/O lists
Examples
The following example shows formatted, sequential WRITE statements:
See Also
WRITE statement
Forms for Sequential WRITE Statements
980
Language Reference
BYTE I5
LOGICAL(1) L2
LOGICAL(2) L2
LOGICAL(4) L2
LOGICAL(8) L2
INTEGER(1) I5
INTEGER(2) I7
INTEGER(4) I12
INTEGER(8) I22
REAL(4) 1PG15.7E2 2
REAL(8) 1PG24.15E3 2
REAL(16) 1PG43.33E4 2
COMPLEX(4) '(',1PG14.7E2,',',1PG14.7E2,')' 2
COMPLEX(8) '(',1PG23.15E3,',',1PG23.15E3,')' 2
COMPLEX(16) '(',1PG42.33E4,',',1PG42.33E4,')' 2
CHARACTER Aw1
1 Where w is the length of the character expression.
2 If option assume noold_ldout_format is in effect, the compiler uses Fortran 2018 standard semantics
for output of integer and real values in list-directed and namelist-directed output. This means that for real
and complex values, the output is in E or F format depending on the magnitude of the value. For more
information, see the description of option assume.
By default, character constants are not delimited by apostrophes or quotation marks, and each internal
apostrophe or quotation mark is represented externally by one apostrophe or quotation mark.
This behavior can be changed by the DELIM specifier (in an OPEN statement) as follows:
• If the file is opened with the DELIM='QUOTE' specifier, character constants are delimited by quotation
marks and each internal quotation mark is represented externally by two consecutive quotation marks.
• If the file is opened with the DELIM='APOSTROPHE' specifier, character constants are delimited by
apostrophes and each internal apostrophe is represented externally by two consecutive apostrophes.
Each output statement writes one or more complete records.
If DECIMAL='POINT', the decimal point in a numeric value is displayed as a period, values are separated by
commas, and the separator between the real and imaginary parts of a complex value is a comma. If
DECIMAL='COMMA', the decimal point is displayed as a comma, values are separated by semicolons, and the
separator between the real and imaginary parts of a complex value is a semicolon.
A literal character constant or complex constant can be longer than an entire record. For complex constants,
the end of the record can occur between the comma or semicolon and the imaginary part, if the imaginary
part and closing right parenthesis cannot fit in the current record. For literal constants that are longer than
an entire record, the constant is continued onto as many records as necessary.
Each output record begins with a blank character for carriage control.
Slashes, octal values, null values, and repeated forms of values are not output.
981
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If the file is connected for unformatted I/O, list-directed data transfer is prohibited.
Examples
Suppose the following statements are specified:
DIMENSION A(4)
DATA A/4*3.4/
WRITE (1,*) 'ARRAY VALUES FOLLOW'
WRITE (1,*) A,4
The following records are then written to external unit 1:
INTEGER i, j
REAL a, b
LOGICAL on, off
CHARACTER(20) c
DATA i /123456/, j /500/, a /28.22/, b /.0015555/
DATA on /.TRUE./, off/.FALSE./
DATA c /'Here''s a string'/
WRITE (*, *) i, j
WRITE (*, *) a, b, on, off
WRITE (*, *) c
END
The preceding example produces the following output:
123456 500
28.22000 1.555500E-03 T F
Here's a string
See Also
Rules for Formatted Sequential WRITE Statements
Rules for List-Directed Sequential READ Statements for details on list-directed input
982
Language Reference
If DECIMAL='POINT', the decimal point in a numeric value is displayed as a period, values are separated by
commas, and the separator between the real and imaginary parts of a complex value is a comma. If
DECIMAL='COMMA', the decimal point is displayed as a comma, values are separated by semicolons, and the
separator between the real and imaginary parts of a complex value is a semicolon.
A literal character constant or complex constant can be longer than an entire record. For complex constants,
the end of the record can occur between the comma or semicolon and the imaginary part, if the imaginary
part and closing right parenthesis cannot fit in the current record. For literal constants that are longer than
an entire record, the constant is continued onto as many records as necessary.
Each output record begins with a blank character for carriage control, except for literal character constants
that are continued from the previous record.
Slashes, octal values, null values, and repeated forms of values are not output.
If the file is connected for unformatted I/O, namelist data transfer is prohibited.
Examples
Consider the following statements:
&PARAM
NAME(2)(10:)='HEISENBERG',
PITCH=5.0, YAW=0.0, ROLL=5.0,
DIAGNOSTICS=.TRUE.
ITERATIONS=10
/
The following is then written to the file connected to unit 2:
&PARAM
NAME = ' ', ' HEISENBERG',
PITCH = 5.000000,
ROLL = 5.000000,
TYPEVAR = 1, 2.0, 'ABCDE'
YAW = 0.0000000E+00,
POSITION = 3*0.0000000E+00,
DIAGNOSTICS = T,
ITERATIONS = 10
/
Note that character values are not enclosed in apostrophes unless the output file is opened with
DELIM='APOSTROPHE'. The value of POSITION is not defined in the namelist input, so the current value of
POSITION is written.
983
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The following example declares a number of variables, which are placed in a namelist, initialized, and then
written to the screen with namelist I/O:
INTEGER(1) int1
INTEGER int2, int3, array(3)
LOGICAL(1) log1
LOGICAL log2, log3
REAL real1
REAL(8) real2
COMPLEX z1, z2
CHARACTER(1) char1
CHARACTER(10) char2
int1 = 11
int2 = 12
int3 = 14
log1 = .TRUE.
log2 = .TRUE.
log3 = .TRUE.
real1 = 24.0
real2 = 28.0d0
z1 = (38.0,0.0)
z2 = (316.0d0,0.0d0)
char1 = 'A'
char2 = '0123456789'
array(1) = 41
array(2) = 42
array(3) = 43
WRITE (*, example)
The preceding example produces the following output:
&EXAMPLE
INT1 = 11,
INT2 = 12,
INT3 = 14,
LOG1 = T,
LOG2 = T,
LOG3 = T,
REAL1 = 24.00000,
REAL2 = 28.0000000000000,
Z1 = (38.00000,0.0000000E+00),
Z2 = (316.0000,0.0000000E+00),
CHAR1 = A,
CHAR2 = 0123456789,
ARRAY = 41, 42, 43
/
See Also
NAMELIST
Rules for Formatted Sequential WRITE Statements
Rules for Namelist Sequential READ Statements
984
Language Reference
Examples
The following example shows an unformatted, sequential WRITE statement:
Formatted:
WRITE (eunit, format, rec [, asynchronous] [, decimal ] [, delim ] [, id] [, pos] [, round ] [, sign ] [, iostat] [,
err] [, iomsg]) [io-list]
Unformatted:
WRITE (eunit, rec [, asynchronous] [, id] [, pos] [, iostat] [, err] [, iomsg]) [io-list]
See Also
WRITE
I/O control-list specifiers
I/O lists
Examples
The following example shows a formatted, direct-access WRITE statement:
985
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Examples
The following example shows unformatted, direct-access WRITE statements:
See Also
NEW_LINE
986
Language Reference
Examples
The following example shows an internal WRITE statement:
INTEGER J, K, STAT_VALUE
CHARACTER*50 CHAR_50
...
WRITE (FMT=*, UNIT=CHAR_50, IOSTAT=STAT_VALUE) J, K
See Also
I/O control-list specifiers
I/O lists
Rules for List-Directed Sequential WRITE Statements for details on list-directed output
Rules for Namelist Sequential WRITE Statements for details on namelist output
987
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
A DT edit descriptor must correspond to a list item of a derived type. Also, there should be an accessible
interface to a corresponding defined FORMATTED I/O procedure for that derived type.
In a format statement, if the last closing parenthesis of the format string is reached and there are no
effective items left, then format processing terminates. But, if there are more items to be processed, then
format control reverts to the beginning of the format item which was terminated by the next-to-last right
parenthesis.
If there is no such preceding right parenthesis, it reverts to the first left parenthesis of the format
specification. During this format reversion, the right parenthesis that is part of a DT edit descriptor is not
considered as the next-to-last parenthesis. For example, consider the following:
write (10, '(F10.3, I5, 'DT "sample" (1, 2) )' ) 10.1, 3, obj1, 4.7, 1, obj2
In the above case, format control reverts to the left parenthesis before F10.3 and not to DT.
Examples
The following are valid ways to specify the DT edit descriptor:
DT
DT "z8, i4, e10.2"
DT (1, -1, +1000)
DT 'my type' (0)
988
Language Reference
See Also
Type-Bound Procedures
Resolving Defined I/O Procedure References
TYPE LIST
INTEGER :: X
END TYPE
CONTAINS
See Also
TYPE Statement (Derived Types)
Defining Generic Names for Procedures
989
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
var Is a scalar of the derived type. For output, it holds the value to be
written. For input, it will be altered in accordance with the values
read.
unit Is the scalar integer value of the I/O unit on which input or output is
taking place. It is a negative number for an internal file or for an
external unit that is a NEWUNIT value. It is a processor-dependent
number (which may be negative) for the '*' unit.
The following interfaces specify the characteristics of the user-defined I/O procedures:
SUBROUTINE my_read_formatted (var,unit,iotype,vlist,iostat,iomsg)
dtv-type-spec,INTENT(INOUT) :: var
INTEGER,INTENT(IN) :: unit
CHARACTER(*),INTENT(IN) :: iotype
INTEGER,INTENT(IN) :: vlist(:)
INTEGER,INTENT(OUT) :: iostat
CHARACTER(*),INTENT(INOUT) :: iomsg
END
990
Language Reference
INTEGER,INTENT(OUT) :: iostat
CHARACTER(*),INTENT(INOUT) :: iomsg
END
See Also
ISO_FORTRAN_ENV Module
See Also
ISO_FORTRAN_ENV Module
User-Defined Derived-Type I/O
See Also
Characteristics of Defined I/O Procedures
991
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
MODULE LIST_MODULE
IMPLICIT NONE
TYPE NODE
! This type declaration represents a singly-linked list that also
! contains a user-defined i/o procedure. The name of the procedure
! is arbitrary, but the order of arguments must conform to the
! standard definition.
INTEGER :: VALUE = -1
TYPE(NODE), POINTER :: NEXT_NODE => NULL()
CONTAINS
PROCEDURE :: PWF
GENERIC :: WRITE(FORMATTED) => PWF ! <=== GENERIC BINDING.
END TYPE NODE
CONTAINS
RECURSIVE SUBROUTINE PWF( DTV, UNIT, IOTYPE, V_LIST, IOSTAT, IOMSG )
! These arguments are defined in the standard.
CLASS(NODE), INTENT(IN) :: DTV
INTEGER, INTENT(IN) :: UNIT
CHARACTER(LEN=*), INTENT(IN) :: IOTYPE
INTEGER, DIMENSION(:), INTENT(IN) :: V_LIST
INTEGER :: IOSTAT
CHARACTER(LEN=*), INTENT(INOUT) :: IOMSG
! The following is a child i/o statement that is called when user-defined i/o
! statement is invoked.
WRITE( UNIT=UNIT, FMT='(I9)', IOSTAT=IOSTAT ) DTV%VALUE
PRINT *, ASSOCIATED(DTV%NEXT_NODE)
IF(IOSTAT /= 0)RETURN
PROGRAM LISTE
USE LIST_MODULE
IMPLICIT NONE
INTEGER :: UNIT, IOSTAT, I
TYPE(NODE), POINTER :: CUR, TO_PRINT
992
Language Reference
DO I = 1,10
ALLOCATE(CUR%NEXT_NODE)
CUR % VALUE = I
CUR => CUR%NEXT_NODE
END DO
CUR % NEXT_NODE => NULL()
! END CREATION OF LINKED LIST
DO I = 1,15
IF(ASSOCIATED(TO_PRINT)) THEN
PRINT *, I, TO_PRINT%VALUE
TO_PRINT => TO_PRINT % NEXT_NODE
END IF
END DO
Example 1
The following example shows formatted defined I/O using the DT edit descriptor and both generic type-bound
and explicit interface procedures:
MODULE TYPES
TYPE T
INTEGER :: K(10)
CONTAINS
! an explicit interface
INTERFACE WRITE(FORMATTED)
MODULE PROCEDURE UDIO_WRITE_ARRAY
END INTERFACE
CONTAINS
SUBROUTINE UDIO_READ_ARRAY (DTV, UNIT, IOTYPE, V_LIST, IOSTAT, IOMSG)
CLASS(T), INTENT(INOUT) :: DTV
INTEGER, INTENT(IN) :: UNIT
CHARACTER(*), INTENT(IN) :: IOTYPE
INTEGER, INTENT(IN) :: V_LIST (:)
INTEGER, INTENT(OUT) :: IOSTAT
CHARACTER(*), INTENT(INOUT) :: IOMSG
! This is the child I/O that gets performed when the procedure
! is called from a parent I/O – it uses list-directed input to read
! the array K
993
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
! This is the child I/O that gets performed when the procedure
! is called from a parent I/O – it uses list-directed output to write
! the array K
PROGRAM TEST1
USE TYPES
TYPE (T) :: V
INTEGER :: COUNTCHAR
1, 3, 5, 7, 9, 2, 4, 6, 8, 10
In this case, the program TEST1 in procedure UDIO_WRITE_ARRAY prints:
1 3 5 7 9 2
4 6 8 10
Example 2
The following example shows list-directed formatted output and user-defined I/O:
MODULE M
TYPE T
REAL, POINTER :: R (:)
CONTAINS
PROCEDURE :: UDIO_WRITE_LD
GENERIC :: WRITE(FORMATTED) => UDIO_WRITE_LD
END TYPE T
CONTAINS
SUBROUTINE UDIO_WRITE_LD (DTV, UNIT, IOTYPE, V_LIST, IOSTAT, IOMSG)
994
Language Reference
PROGRAM TEST2
USE M
TYPE (T) :: X
REAL, TARGET :: V (3)
Example 3
The following example shows user-defined derived-type NAMELIST input/output:
! PROGRAM: udio_nml_read_write.f90
!
! This program tests NAMELIST READ and WRITE. In the WRITE subroutine, there
! are FORMATTED WRITES as well as NAMELIST WRITES.
!
MODULE UDIO
TYPE MYDT
INTEGER F1
INTEGER F2
CONTAINS
PROCEDURE :: MYSUBROUTINE
GENERIC :: READ (FORMATTED) => MYSUBROUTINE
END TYPE MYDT
INTEGER I, J
NAMELIST /SUBRT_NML/ I, J
995
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
I=DTV%F1
J=DTV%F2
! X and Y are aliases for DTV%F1 and DTV%F2 since field references
! cannot be referenced in a NAMELIST statement
INTEGER X, Y
NAMELIST /SUBRT_NML/ X, Y
X = DTV%F1
Y = DTV%F2
PROGRAM UDIO_PROGRAM
USE UDIO
TYPE (MYDT) :: MYDTV
INTEGER :: A, B
NAMELIST /MAIN_NML/ A, MYDTV, B
&MAIN_NML
A=100
MYDTV=20 30
&SUBRT_NML
X=20
Y=30
/
/B=200
/
996
Language Reference
&MAIN_NML
A = 100,
MYDTV=NAMELIST 20 30
&SUBRT_NML
I = 20,
J = 30
/
/B = 200
/
Example 4
The following example shows user-defined derived-type UNFORMATTED input/output:
! PROGRAM: udio_unformatted_1.f90
!
! This test first writes unformatted data to a file via user-defined derived type output
! and then reads the data from the file via user-defined derived type input.
!
MODULE UNFORMATTED
TYPE UNFORMATTED_TYPE
INTEGER :: I
CHARACTER*25 :: CHAR
CONTAINS
PROCEDURE :: MY_UNFMT_WRITE
GENERIC :: WRITE (UNFORMATTED) => MY_UNFMT_WRITE
END TYPE UNFORMATTED_TYPE
CONTAINS
SUBROUTINE MY_UNFMT_WRITE (DTV, UNIT, IOSTAT, IOMSG)
CLASS (UNFORMATTED_TYPE), INTENT(IN) :: DTV
INTEGER, INTENT(IN) :: UNIT
INTEGER, INTENT(OUT) :: IOSTAT
CHARACTER(LEN=*), INTENT(INOUT) :: IOMSG
PROGRAM UNFORMATTED_WRITE_PROGRAM
USE UNFORMATTED
997
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
T T
T T
I/O Formatting
A format appearing in an input or output (I/O) statement specifies the form of data being transferred and the
data conversion (editing) required to achieve that form. The format specified can be explicit or implicit.
Explicit format is indicated in a format specification that appears in a FORMAT statement or a character
expression (the expression must evaluate to a valid format specification).
The format specification contains edit descriptors, which can be data edit descriptors, control edit descriptors,
or string edit descriptors.
Implicit format is determined by the processor and is specified using list-directed or namelist formatting.
List-directed formatting is specified with an asterisk (*); namelist formatting is specified with a namelist
group name.
List-directed formatting can be specified for advancing sequential files and internal files. Namelist formatting
can be specified only for advancing sequential files.
See Also
Rules for List-Directed Sequential READ Statements for details on list-directed input
Rules for List-Directed Sequential WRITE Statements for details on list-directed output
Rules for Namelist Sequential READ Statements for details on namelist input
Rules for Namelist Sequential WRITE Statements for details on namelist output
Format Specifications
A format specification can appear in a FORMAT statement or a character expression. In a FORMAT statement,
it is preceded by the keyword FORMAT. A format specification takes one of the following forms:
( [format-items])
( [format-items, ] unlimited-format-item)
998
Language Reference
data-edit-desc Is one of the data edit descriptors: I, B, O, Z, F, E, EN, ES, EX, D, DT, G, L, or A.
A repeat specification can precede any data edit descriptor.
control-edit-desc Is one of the control edit descriptors: T, TL, TR, X, S, SP, SS, BN, BZ, P, :, /, $, \,
and Q.
A repeat specification can precede the slash (/) edit descriptor.
char-string-edit-desc Is one of the string edit descriptors: H, 'c', and "c", where c is a character
constant.
If more than one edit descriptor is specified, they must be separated by commas or slashes (/).
A comma can be omitted in the following cases:
• Between a P edit descriptor and an immediately following F, E, EN, ES, EX, D, or G edit descriptor
• Before a slash (/) edit descriptor when the optional repeat specification is not present
• After a slash (/) edit descriptor
• Before or after a colon (:) edit descriptor
Description
A FORMAT statement must be labeled.
Named constants are not permitted in format specifications.
If the associated I/O statement contains an I/O list, the format specification must contain at least one data
edit descriptor or the control edit descriptor Q.
Blank characters can precede the initial left parenthesis, and additional blanks can appear anywhere within
the format specification. These blanks have no meaning unless they are within a character string edit
descriptor.
When a formatted input statement is executed, the setting of the BLANK specifier (for the relevant logical
unit) determines the interpretation of blanks within the specification. If the BN or BZ edit descriptors are
specified for a formatted input statement, they supersede the default interpretation of blanks. (For more
information on BLANK defaults, see BLANK Specifier in OPEN statements.)
For formatted input, you can use the comma as an external field separator. The comma terminates the input
of fields (for noncharacter data types) that are shorter than the number of characters expected. It can also
designate null (zero-length) fields.
The following table summarizes the edit descriptors that can be used in format specifications.
Summary of Edit Descriptors
Code Form Effect
999
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1000
Language Reference
1001
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
To avoid using consecutive apostrophes or quotation marks, you can put the character constant in an I/O list
instead of a format specification, as follows:
SUBROUTINE PRINT(TABLE)
REAL TABLE(10,5)
CHARACTER*5 FORCHR(0:5), RPAR*1, FBIG, FMED, FSML
DATA FORCHR(0),RPAR /'(',')'/
DATA FBIG,FMED,FSML /'F8.2,','F9.4,','F9.6,'/
DO I=1,10
DO J=1,5
IF (TABLE(I,J) .GE. 100.) THEN
FORCHR(J) = FBIG
ELSE IF (TABLE(I,J) .GT. 0.1) THEN
FORCHR(J) = FMED
ELSE
FORCHR(J) = FSML
END IF
END DO
FORCHR(5)(5:5) = RPAR
WRITE (6,FORCHR) (TABLE(I,J), J=1,5)
END DO
END
The DATA statement assigns a left parenthesis to character array element FORCHR(0), and (for later use) a
right parenthesis and three F edit descriptors to character variables.
Next, the proper F edit descriptors are selected for inclusion in the format specification. The selection is
based on the magnitude of the individual elements of array TABLE.
A right parenthesis is added to the format specification just before the WRITE statement uses it.
NOTE
Format specifications stored in arrays are recompiled at run time each time they are used. If a
Hollerith or character run-time format is used in a READ statement to read data into the format itself,
that data is not copied back into the original array, and the array is unavailable for subsequent use as
a run-time format specification.
Examples
The following example shows a format specification:
1002
Language Reference
In the following example, the format list is put into an 80-character variable called MYLIST:
CHARACTER(80) MYLIST
MYLIST = '(I5, 3F5.2, A16)'
WRITE (*, MYLIST) iolist
Consider the following two-dimensional array:
1 2 3
4 5 6
In this case, the elements are stored in memory in the order: 1, 4, 2, 5, 3, 6 as follows:
CHARACTER(6) array(3)
DATA array / '(I5', ',3F5.2', ',A16)' /
WRITE (*, array) iolist
In the following example, the WRITE statement uses the character array element array(2) as the format
specifier for data transfer:
CHARACTER(80) array(5)
array(2) = '(I5, 3F5.2, A16)'
WRITE (*, array(2)) iolist
See Also
Data edit descriptors
Control edit descriptors
Character string edit descriptors
Variable Format Expressions
Nested and group repeats
Printing of formatted records
w Is the total number of digits in the field (the field width). If omitted,
the system applies default values (see Default Widths for Data Edit
Descriptors). The range of w is 1 through 2147483647 (2**31-1) on
1003
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
Standard Fortran allows the field width to be omitted only for the A descriptor. However, Intel® Fortran allows
the field width to be omitted for any data edit descriptor.
The r, w, m, d, and e must all be positive, unsigned, integer literal constants, or the digit 0 where allowed, or
variable format expressions -- no kind parameter can be specified. They must not be named constants.
Actual useful ranges for r, w, m, d, and e may be constrained by record sizes (RECL) and the file system.
The data edit descriptors have the following specific forms:
Logical: Lw
Character: A[w]
The d must be specified with F, E, EN, ES, EX, D, and G field descriptors even if d is zero. The decimal point
is also required. You must specify both w and d.
A repeat specification can simplify formatting. For example, the following two statements are equivalent:
20 FORMAT (E12.4,E12.4,E12.4,I5,I5,I5,I5)
20 FORMAT (3E12.4,4I5)
Examples
! This WRITE outputs three integers, each in a five-space field
! and four reals in pairs of F7.2 and F5.2 values.
INTEGER(2) int1, int2, int3
1004
Language Reference
See Also
General rules for numeric editing
Nested and group repeats
A minus sign must precede a negative value in an external field; a plus sign is optional before a positive
value.
In input records, constants can include any valid kind parameter. Named constants are not permitted.
If the data field in a record contains fewer than w characters, an input statement will read characters from
the next data field in the record. You can prevent this by padding the short field with blanks or zeros, or by
using commas to separate the input data. The comma terminates the data field, and can also be used to
designate null (zero-length) fields. For more information, see Terminating Short Fields of Input Data.
1005
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If the value is smaller than the field width specified, leading blanks are inserted (the value is right-justified).
If the value is too large for the field width specified, the entire output field is filled with asterisks (*).
When the value of the field width is zero, the compiler selects the smallest possible positive actual field width
that does not result in the field being filled with asterisks.
See Also
Forms for data edit descriptors
Format Specifications
Integer Editing
Integer editing is controlled by the I (decimal), B (binary), O (octal), and Z (hexadecimal) data edit
descriptors.
I Editing
The I edit descriptor transfers decimal integer values. It takes the following form:
Iw[.m]
The value of m (the minimum number of digits in the constant) must not exceed the value of w (the field
width), unless w is zero. The m has no effect on input, only output.
The specified I/O list item must be of type integer; logical and real items are also allowed if the compiler
option check format is not specified.
The G edit descriptor can be used to edit integer data; it follows the same rules as Iw.
1006
Language Reference
The following shows output using the I edit descriptor (the symbol ^ represents a nonprinting blank
character):
See Also
Forms for data edit descriptors
General rules for numeric editing
B Editing
The B data edit descriptor transfers binary (base 2) values. It takes the following form:
Bw[.m]
The value of m (the minimum number of digits in the constant) must not exceed the value of w (the field
width), unless w is zero. The m has no effect on input, only output.
The specified I/O list item can be of type integer, real, or logical.
1007
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The following shows output using the B edit descriptor (the symbol ^ represents a nonprinting blank
character):
See Also
Forms for data edit descriptors
General rules for numeric editing
O Editing
The O data edit descriptor transfers octal (base 8) values. It takes the following form:
Ow[.m]
The value of m (the minimum number of digits in the constant) must not exceed the value of w (the field
width), unless w is zero. The m has no effect on input, only output.
The specified I/O list item can be of type integer, real, or logical.
1008
Language Reference
O4.2 7 ^^07
O4.4 7 0007
O0 83 123
See Also
Forms for data edit descriptors
General rules for numeric editing
Z Editing
The Z data edit descriptor transfers hexadecimal (base 16) values. It takes the following form:
Zw[.m]
The value of m (the minimum number of digits in the constant) must not exceed the value of w (the field
width), unless w is zero. The m has no effect on input, only output.
The specified I/O list item can be of type integer, real, or logical.
1009
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Forms for data edit descriptors
General rules for numeric editing
NOTE
Do not use the real data edit descriptors when attempting to parse textual input. These descriptors
accept some forms that are purely textual as valid numeric input values. For example, input values T
and F are treated as values -1.0 and 0.0, respectively, for .TRUE. and .FALSE.
See Also
Forms for data edit descriptors
General rules for numeric editing
Scale Factor Editing (P)
Default Widths for Data Edit Descriptors for details on system default values for data edit
descriptors
F Editing
The F data edit descriptor transfers real values. It takes the following form:
Fw.d
The value of d (the number of places after the decimal point) must not exceed the value of w (the field
width) unless w is zero. When w is zero, the processor selects the field width. On input, w must not be zero.
The specified I/O list item must be of type real, or it must be the real or imaginary part of a complex type.
1010
Language Reference
If the field contains an exponent, that exponent is used to establish the magnitude of the value before it is
assigned to the list element.
An input field that is an IEEE exception specification consists of optional blanks, followed by either of the
following:
• An optional sign, followed by the string 'INF' or the string 'INFINITY'; this is an IEEE infinity
This form can not be used if the processor does not support IEEE infinities for the input variable.
• An optional sign, followed by the string 'NAN', optionally followed by zero or more alphanumeric
characters enclosed in parentheses, optionally followed by blanks; this is an IEEE Nan
This form can not be used if the processor does not support IEEE Nans for the input variable.
The NaN value is a quiet NaN if the only nonblank characters in the field are 'NAN' or 'NAN()'.
An input field that is a hexadecimal-significand number contains an optional sign, followed by the digit 0,
followed immediately by the letter X, followed by the hexadecimal significand followed by a hexadecimal
exponent. A hexadecimal significand is a string of one or more hexadecimal characters, optionally
containing a decimal symbol. The position of the hexadecimal point is indicated by the decimal symbol. The
hexadecimal point implicitly follows the last hexadecimal character if decimal symbol appears in the string. A
hexadecimal exponent is the letter P followed by a signed decimal digit string. Embedded blanks are not
allowed; trailing blanks are ignored. The value is equal to the significand multiplied by two raised to the
power of the exponent. If the optional sign is a minus, the value is negated.
The following shows input using the F edit descriptor:
1011
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The following shows output using the F edit descriptor (the symbol ^ represents a nonprinting blank
character):
See Also
Forms for data edit descriptors
General rules for numeric editing
assume compiler option
E and D Editing
The E and D data edit descriptors transfer real values in exponential form. They take the following form:
Ew.d[Ee]
Dw.d
where w is the total field width, d is the number of places after the decimal point, and e is the number of
digits in the exponent.
For the E edit descriptor, if w is zero, the processor selects the field width. If e is zero, the exponent part
contains the minimum number of digits needed to represent the value of the exponent.
For the D edit descriptor, if the value of w is zero, the processor selects the field width.
The specified I/O list item must be of type real, or it must be the real or imaginary part of a complex type.
1012
Language Reference
If an exponent exceeds its specified or implied width, or the number of characters produced exceeds the field
width, the entire field of width w is filled with asterisks.
The exponent field width (e) is optional for the E edit descriptor; if omitted, the default value is 2. If e is
specified, w should be greater than or equal to d+e+5, or zero.
NOTE
If w is greater than zero, it can be as small as d + 5 or d + e + 3, if the optional fields for the sign and
the zero are omitted.
For an internal value that is an IEEE infinity or an IEEE NaN, the form of the output field is the same as for
Fw.d.
A negative value that is not zero but rounds to zero on output is displayed with a leading minus sign. For
example, the value -0.01 in "-5P,E20.5" format will be displayed as -0.00 rather than as 0.00. The setting of
compiler option assume [no]std_minus0_rounding can affect this behavior.
The following shows output using the E and D edit descriptors (the symbol ^ represents a nonprinting blank
character):
See Also
Forms for data edit descriptors
General rules for numeric editing
Scale Factor Editing (P)
assume compiler option
1013
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
EN Editing
The EN data edit descriptor transfers values by using engineering notation. It takes the following form:
ENw.d[Ee]
where w is the total field width, d is the number of places after the decimal point, and e is the number of
digits in the exponent.
If w is zero, the processor chooses the field width. If e is present and zero, the exponent part contains the
minimal number of digits needed to represent the exponent .
The specified I/O list item must be of type real, or it must be the real or imaginary part of a complex type.
If an exponent exceeds its specified or implied width, or the number of characters produced exceeds the field
width, the entire field of width w is filled with asterisks.
The exponent field width (e) is optional; if omitted, the default value is 2. If e is specified, w should be
greater than or equal to d + e + 5, or zero.
For an internal value that is an IEEE infinity or an IEEE NaN, the form of the output field is the same as for
Fw.d.
1014
Language Reference
The following shows output using the EN edit descriptor (the symbol ^ represents a nonprinting blank
character):
See Also
Forms for data edit descriptors
General rules for numeric editing
ES Editing
The ES data edit descriptor transfers values by using scientific notation. It takes the following form:
ESw.d[Ee]
where w is the total field width, d is the number of places after the decimal point, and e is the number of
digits in the exponent.
If w is zero, the processor selects the field width. If e is present and zero, the exponent part contains the
minimal number of digits needed to represent the exponent.
The specified I/O list item must be of type real, or it must be the real or imaginary part of a complex type.
1015
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If an exponent exceeds its specified or implied width, or the number of characters produced exceeds the field
width, the entire field of width w is filled with asterisks.
The exponent field width (e) is optional; if omitted, the default value is 2. If e is specified, the w should be
greater than or equal to d + e + 5.
For an internal value that is an IEEE infinity or an IEEE NaN, the form of the output field is the same as for
Fw.d.
The following shows output using the ES edit descriptor (the symbol ^ represents a nonprinting blank
character):
See Also
Forms for data edit descriptors
General rules for numeric editing
EX Editing
The EX data edit descriptor transfers real values represented as hexadecimal-significand numbers. It takes
the following form:
EXw.d[Ee]
w is the external field width, unless it is zero. d is the width of the fractional part of the number, unless it is
0.
If w or d are zero, the processor picks the external field width or the width of the fractional part, respectively.
d cannot be zero if the radix of the internal value is not a power of two. The hexadecimal point appears after
the first hexadecimal digit and it represented by the decimal symbol.
e, if present and nonzero, is the number of digits in the exponent. If Ee is not present, or e is zero, the
exponent contains the minimum number of digits needed to represent the exponent. e is ignored on input.
The specified I/O list item must be of type real, or it must be the real or imaginary part of a complex type.
1016
Language Reference
For EXw.dEe with e greater than zero, the form is P[+|-]z1z2…ze. For EXw.d and EXw.dE0, the form of the
exponent is P[+|-]z1z2…zn where n is the minimum number of digits required to represent the exponent. The
exponent sign is always produced and is plus if the exponent is zero. The choice of the binary exponent is
processor dependent.
The following shows possible output using the EX edit descriptor if SS is in effect:
See Also
F Editing
General rules for numeric editing
G Editing
The G data edit descriptor for generalized editing can be used for input or output with any intrinsic type. It
takes the following forms:
Gw
Gw.d
Gw.dEe
where w is the total field width, d is the number of places after the decimal point, and e is the number of
digits in the exponent.
If w is 0, the field width is selected by the processor. If w is zero, you can only specify forms G0 or G0.d.
If w is nonzero, d must be specified.
If e is present and zero, the exponent part contains the minimal number of digits needed to represent the
exponent. For integer, character, and logical data types d and e are ignored.
When used to specify I/O for integer data, the Gw, Gw.d and Gw.dEe edit descriptors follow the rules for Iw
editing.
When used to specifiy I/O for logical data, the Gw.d and Gw.dEe edit descriptors with nonzero w follow the
rules for Lw editing. On output, if w is 0, the Gw and Gw.d edit descriptors follow the rules for L1 editing.
When used to specify I/O for character data, the Gw.d and Gw.d.Ee edit descriptors with nonzero w follows
the same rules as Aw editing. For output, when w is zero, the Gw and Gw.d edit descriptors follow the rules
for A editing when no w is specified.
1017
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
. .
. .
. .
The 'b' is a blank following the numeric data representation. For Gw.d, n('b') is 4 blanks. For Gw.dEe, n('b' )
is e+2 blanks.
The r is defined for each I/O rounding mode as follows:
Rounding Mode r
COMPATIBLE 0.5
UP 1
DOWN 0
Note that the scale factor has no effect on output unless the magnitude of the datum to be edited is outside
the range that permits effective use of F editing.
If w is greater than zero, it should be greater than or equal to d+7 to allow for the following:
• A sign (optional if the value is positive and descriptor SP is not in effect)
• One digit to the left of the decimal point
• The decimal point
• The d digits to the right of the decimal point
• The 4-digit or e+2-digit exponent
If e is specified and positive, w should be greater than or equal to d + e + 5 if w is positive.
If an exponent exceeds its specified or implied width, or the number of characters produced exceeds the field
width, the entire field of width w is filled with asterisks. However, the field width is not filled with asterisks if
the field width is exceeded when optional characters are omitted.
For an internal value that is an IEEE infinity or an IEEE NaN, the form of the output field is the same as for
Fw.d.
1018
Language Reference
The following shows output using the G edit descriptor and compares it to output using equivalent F editing
(the symbol ^ represents a nonprinting blank character):
See Also
Forms for data edit descriptors
General rules for numeric editing
I data edit descriptor
L data edit descriptor
A data edit descriptor
Scale Factor Editing (P)
Complex Editing
A complex value is an ordered pair of real values. Complex editing is specified by a pair of real edit
descriptors, using any combination of the forms: Fw.d, Ew.d[Ee], Dw.d, ENw.d[Ee], ESw.d[Ee], or Gw.d[Ee].
See Also
Forms for data edit descriptors
General rules for numeric editing
General Rules for Complex Constants for details on complex constants
1019
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Forms for data edit descriptors
BYTE 1
1020
Language Reference
LOGICAL(1) or LOGICAL*1 1
LOGICAL(2) or LOGICAL*2 2
LOGICAL(4) or LOGICAL*4 4
LOGICAL(8) or LOGICAL*8 8
INTEGER(1) or INTEGER*1 1
INTEGER(2) or INTEGER*2 2
INTEGER(4) or INTEGER*4 4
INTEGER(8) or INTEGER*8 8
REAL(4) or REAL*4 4
DOUBLE PRECISION 8
REAL(8) or REAL*8 8
REAL(16) or REAL*16 16
COMPLEX(4) or COMPLEX*81 8
DOUBLE COMPLEX1 16
COMPLEX(8) or COMPLEX*161 16
COMPLEX(16) or COMPLEX*321 32
1Complex values are treated as pairs of real numbers, so complex editing requires a pair of edit
descriptors. (See Complex Editing.)
If w is equal to or greater than the length (len) of the input item, the rightmost characters are assigned to
that item. The leftmost excess characters are ignored.
If w is less than len, or less than the number of characters that can be stored, w characters are assigned to
the list item, left-justified, and followed by trailing blanks.
The following shows input using the A edit descriptor (the symbol ^ represents a nonprinting blank
character):
1021
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If w is greater than the size of the list item, the data is transferred to the output field, right-justified, with
leading blanks. If w is less than or equal to the size of the list item, the leftmost w characters are
transferred.
The following shows output using the A edit descriptor (the symbol ^ represents a nonprinting blank
character):
See Also
Forms for data edit descriptors
I, B, O, Z, G BYTE 7
INTEGER(1), LOGICAL(1) 7
INTEGER(2), LOGICAL(2) 7
INTEGER(4), LOGICAL(4) 12
INTEGER(8), LOGICAL(8) 23
O, Z REAL(4) 12
REAL(8) 23
REAL(16) 44
L, G LOGICAL(1), LOGICAL(2), 2
LOGICAL(4), LOGICAL(8)
REAL(8), COMPLEX(8) 25 d: 16 e: 2
REAL(16), COMPLEX(16) 42 d: 33 e: 3
EN REAL(4), COMPLEX(4) 15 d: 6 e: 2
1022
Language Reference
REAL(8), COMPLEX(8) 25 d: 16 e: 2
REAL(16), COMPLEX(16) 42 d: 32 e: 3
A1, G LOGICAL(1) 1
LOGICAL(2), INTEGER(2) 2
LOGICAL(4), INTEGER(4) 4
LOGICAL(8), INTEGER(8) 8
REAL(4), COMPLEX(4) 4
REAL(8), COMPLEX(8) 8
REAL(16), COMPLEX(16) 16
CHARACTER*len len
1 The default is the actual length of the corresponding I/O list item.
1, -2, 1.0, 35
1023
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
I = 1
J = -2
A = 1.0
B = 0.35
A comma can only terminate fields less than w characters long. If a comma follows a field of w or more
characters, the comma is considered part of the next field.
A null (zero-length) field is designated by two successive commas, or by a comma after a field of w
characters. Depending on the field descriptor specified, the resulting value assigned is 0, 0.0, 0.0D0, 0.0Q0,
or .FALSE..
See Also
General Rules for Numeric Editing
c Is one of the following format codes: T, TL, TR, X, S, SP, SS, BN, BZ,
P, RU, RD, RZ, RN, RC, RP, DC, DP, :, /, \, $, and Q.
Description
In general, control edit descriptors are nonrepeatable. The only exception is the slash (/) edit descriptor,
which can be preceded by a repeat specification or a * indicating an unlimited repeat count.
The control edit descriptors have the following specific forms:
Scale factor: kP
1024
Language Reference
Miscellaneous: :, /, \, $, and Q
The P edit descriptor is an exception to the general control edit descriptor syntax. It is preceded by a scale
factor, rather than a character position specifier.
Control edit descriptors can be grouped in parentheses and preceded by a group repeat specification.
See Also
Group repeat specifications
Format Specifications
Positional Editing
The T, TL, TR, and X edit descriptors specify the position where the next character is transferred to or from a
record.
On output, these descriptors do not themselves cause characters to be transferred and do not affect the
length of the record. If characters are transferred to positions at or after the position specified by one of
these descriptors, positions skipped and not previously filled are filled with blanks. The result is as if the
entire record was initially filled with blanks.
The TR and X edit descriptors produce the same results.
See Also
Forms for Control Edit Descriptors
T Editing
The T edit descriptor specifies a character position in an I/O record. It takes the following form:
Tn
The n is a positive integer literal constant (with no kind parameter) indicating the character position of the
record, relative to the left tab limit.
On input, the T descriptor positions the external record at the character position specified by n. On output,
the T descriptor indicates that data transfer begins at the nth character position of the external record.
Examples
In the following examples, the symbol ^ represents a nonprinting blank character.
Suppose a file has a record containing the value ABC^^^XYZ, and the following statements are executed:
PRINT 25
25 FORMAT (T51,'COLUMN 2',T21,'COLUMN 1')
The following line is printed at the positions indicated:
Position 20 Position 50
| |
COLUMN 1 COLUMN 2
Note that the first character of the record printed was reserved as a control character.
See Also
Printing of Formatted Records
1025
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
TL Editing
The TL edit descriptor specifies a character position to the left of the current position in an I/O record. It
takes the following form:
TLn
The n is a positive integer literal constant (with no kind parameter) indicating the nth character position to
the left of the current character.
If n is greater than or equal to the current position, the next character accessed is the first character of the
record.
TR Editing
The TR edit descriptor specifies a character position to the right of the current position in an I/O record. It
takes the following form:
TRn
The n is a positive integer literal constant (with no kind parameter) indicating the nth character position to
the right of the current character.
X Editing
The X edit descriptor specifies a character position to the right of the current position in an I/O record. It
takes the following form:
nX
The n is a positive integer literal constant (with no kind parameter) indicating the nth character position to
the right of the current character.
On output, the X edit descriptor does not output any characters when it appears at the end of a format
specification; for example:
WRITE (6,99) K
99 FORMAT ('^K=',I6,5X)
Note that the symbol ^ represents a nonprinting blank character. This example writes a record of only 9
characters. To cause n trailing blanks to be output at the end of a record, specify a format of n('^').
Sign Editing
The SP, SS and S edit descriptors control the output of the optional plus (+) sign within numeric output
fields. These descriptors have no effect during execution of input statements.
These specifiers correspond to the SIGN= specifier values PLUS, SUPPRESS, and PROCESSOR_DEFINED,
respectively.
Within a format specification, a sign editing descriptor affects all subsequent I, F, E, EN, ES, EX, D, and G
descriptors until another sign editing descriptor occurs.
Examples
Consider the following:
INTEGER i
REAL r
1026
Language Reference
See Also
Forms for Control Edit Descriptors
SP Editing
The SP edit descriptor causes the processor to produce a plus sign in any subsequent position where it would
be otherwise optional. It takes the following form:
SP
SS Editing
The SS edit descriptor causes the processor to suppress a plus sign in any subsequent position where it
would be otherwise optional. It takes the following form:
SS
S Editing
The S edit descriptor restores the plus sign as optional for all subsequent positive numeric fields. It takes the
following form:
S
The S edit descriptor restores to the processor the discretion of producing plus characters on an optional
basis.
Blank Editing
The BN and BZ descriptors control the interpretation of embedded and trailing blanks within numeric input
fields. These descriptors have no effect during execution of output statements.
Within a format specification, a blank editing descriptor affects all subsequent I, B, O, Z, F, E, EN, ES, D, and
G descriptors until another blank editing descriptor occurs.
The blank editing descriptors override the effect of the BLANK specifier during execution of a particular input
data transfer statement. (For more information, see the BLANK specifier in OPEN statements.)
See Also
Forms for Control Edit Descriptors
BN Editing
The BN edit descriptor causes the processor to ignore all embedded and trailing blanks in numeric input
fields. It takes the following form:
BN
The input field is treated as if all blanks have been removed and the remainder of the field is right-justified.
An all-blank field is treated as zero.
Examples
If an input field formatted as a six-digit integer (I6) contains '2 3 4', it is interpreted as ' 234'.
Consider the following code:
1027
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If you enter any one of the following three records and terminate by pressing Enter, the READ statement
interprets that record as the value 123:
123
123
123 456
Because the repeatable edit descriptor associated with the I/O list item n is I6, only the first six characters of
each record are read (three blanks followed by 123 for the first record, and 123 followed by three blanks for
the last two records). Because blanks are ignored, all three records are interpreted as 123.
The following example shows the effect of BN editing with an input record that has fewer characters than the
number of characters specified by the edit descriptors and iolist. Suppose you enter 123 and press Enter in
response to the following READ statement:
BZ Editing
The BZ edit descriptor causes the processor to interpret all embedded and trailing blanks in numeric input
fields as zeros. It takes the following form:
BZ
Examples
The input field ' 23 4 ' is interpreted as ' 23040'. If ' 23 4' is entered, the formatter adds one blank to pad the
input to the six-digit integer format (I6), but this extra space is ignored, and the input is interpreted as '
2304 '. The blanks following the E or D in real-number input are ignored, regardless of the form of blank
interpretation in effect.
Suppose you enter 123 and press Enter in response to the following READ statement:
Round Editing
The RU, RD, RZ, RN, RC, and RP edit descriptors temporarily change the I/O rounding mode for a connection.
These forms of rounding correspond to the ROUND= specifier values UP, DOWN, ZERO, NEAREST,
COMPATIBLE, and PROCESSOR DEFINED, respectively. Rounding conforms to the ISO/IEC/IEEE 60559:2011
standard.
The I/O rounding mode affects the conversion of real and complex values in formatted I/O. It affects only D,
E, EN, ES, EX, F, and G editing.
Each descriptor continues to be in effect until a different round editing descriptor is encountered or until the
end of the current I/O statement.
See Also
Forms for Control Edit Descriptors
RU Editing
The RU edit descriptor causes rounding to the smallest value that is greater than or equal to the original
value. It takes the following form:
1028
Language Reference
RU
RD Editing
The RD edit descriptor causes rounding to the largest representable value that is less than or equal to the
original value. It takes the following form:
RD
RZ Editing
The RZ edit descriptor causes rounding to the value closest to the original value, but not greater in
magnitude. It takes the following form:
RZ
RN Editing
The RN edit descriptor selects NEAREST rounding as specified by the ISO/IEC/IEEE 60559:2011 standard. It
takes the following form:
RN
RC Editing
The RC edit descriptor causes rounding to the closer of the two nearest representable values. If the value is
halfway between the two values, the one chosen is the one farther from zero. It takes the following form:
RC
RP Editing
The RP edit descriptor causes rounding to be determined by the default settings in the processor, which may
correspond to one of the other modes. It takes the following form:
RP
Decimal Editing
The DC and DP edit descriptors temporarily change the decimal edit mode for a connection.
These specifiers correspond to the DECIMAL= specifier values COMMA and POINT, respectively.
The decimal editing mode controls the representation of the decimal symbol during conversion of real and
complex values in formatted I/O. It affects only D, E, EN, ES, F, and G editing.
Each descriptor continues to be in effect until a different decimal editing descriptor is encountered or until the
end of the current I/O statement.
See Also
Forms for Control Edit Descriptors
DC Editing
The DC edit descriptor changes the decimal editing mode for a connection to a decimal comma. It takes the
following form:
DC
Note that during list-directed I/O, a semicolon is used as a value separator in place of a comma.
DP Editing
The DP edit descriptor causes rounding to be determined by the default settings in the processor, which may
correspond to one of the other modes. It takes the following form:
DP
1029
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1030
Language Reference
A positive scale factor decreases the exponent; a negative scale factor increases the exponent.
For a positive scale factor, k must be less than d + 2 or an output conversion error occurs.
• For G editing, the scale factor has no effect if the magnitude of the data to be output is within the
effective range of the descriptor (the G descriptor supplies its own scaling).
If the magnitude of the data field is outside G descriptor range, E editing is used, and the scale factor has
the same effect as E output editing.
• For EN, ES, and EX editing, the scale factor has no effect.
The following shows output using the P edit descriptor (the symbol ^ represents a nonprinting blank
character):
Examples
The following shows a FORMAT statement containing a scale factor:
DIMENSION A(6)
DO 10 I=1,6
10 A(I) = 25.
WRITE (6, 100) A
100 FORMAT(' ', F8.2, 2PF8.2, F8.2)
The preceding statements produce the following results:
a = 12.34
1031
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Forms for Control Edit Descriptors
Slash Editing ( / )
The slash edit descriptor terminates data transfer for the current record and starts data transfer for a new
record. It takes the following form:
[r]/
The r is a repeat specification. It must be a positive default integer literal constant; no kind parameter can be
specified.
The range of r is 1 through 2147483647 (2**31-1) on Intel® 64 architecture; 1 through 32767 (2**15-1) on
IA-32 architecture. If r is omitted, it is assumed to be 1.
Multiple slashes cause the system to skip input records or to output blank records, as follows:
• When n consecutive slashes appear between two edit descriptors, n - 1 records are skipped on input, or n
- 1 blank records are output. The first slash terminates the current record. The second slash terminates
the first skipped or blank record, and so on.
• When n consecutive slashes appear at the beginning or end of a format specification, n records are
skipped or n blank records are output, because the opening and closing parentheses of the format
specification are themselves a record initiator and terminator, respectively. For example, suppose the
following statements are specified:
WRITE (6,99)
99 FORMAT ('1',T51,'HEADING LINE'//T51,'SUBHEADING LINE'//)
The following lines are written:
Column 50, top of page | HEADING LINE
(blank line) SUBHEADING LINE
(blank line)
(blank line)
Note that the first character of the record printed was reserved as a control character (see Printing of
Formatted Records).
Examples
! The following statements write spreadsheet column and row labels:
WRITE (*, 100)
100 FORMAT (' A B C D E' &
& /,' 1',/,' 2',/,' 3',/,' 4',/,' 5')
The above example generates the following output:
A B C D E
1
2
3
4
5
See Also
Forms for Control Edit Descriptors
1032
Language Reference
Examples
Suppose the following statements are specified:
PRINT 1,3
PRINT 2,13
1 FORMAT (' I=',I2,' J=',I2)
2 FORMAT (' K=',I2,:,' L=',I2)
The above code causes the following lines to be written (the symbol ^ represents a nonprinting blank
character):
I=^3^J=
K=13
The following shows another example:
See Also
Forms for Control Edit Descriptors
1033
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Forms for Control Edit Descriptors
Examples
Consider the following:
CHARACTER ICHAR(80)
READ (4, 1000) XRAY, K, NCHAR, (ICHAR(I), I= 1, NCHAR)
1000 FORMAT (E15.7, I4, Q, 80A1)
The preceding input statement reads the variables XRAY and K. The number of characters remaining in the
record is NCHAR, specified by the Q edit descriptor. The array ICHAR is then filled by reading exactly the
number of characters left in the record. (Note that this instruction will fail if NCHAR is greater than 80, the
length of the array ICHAR.) By placing Q in the format specification, you can determine the actual length of
an input record.
Note that the length returned by Q is the number of characters left in the record, not the number of reals or
integers or other data types. The length returned by Q can be used immediately after it is read and can be
used later in the same format statement or in a variable format expression. (See Variable Format
Expressions.)
Assume the file Q.DAT contains:
1234.567Hello, Q Edit
1034
Language Reference
The following program reads in the number REAL1, determines the characters left in the record, and reads
those into STR:
CHARACTER STR(80)
INTEGER LENGTH
REAL REAL1
OPEN (UNIT = 10, FILE = 'Q.DAT')
100 FORMAT (F8.3, Q, 80A1)
READ (10, 100) REAL1, LENGTH, (STR(I), I=1, LENGTH)
WRITE(*,'(F8.3,2X,I2,2X,<LENGTH>A1)') REAL1, LENGTH, (STR(I), &
& I= 1, LENGTH)
END
The output on the screen is:
abcdefg
abcd
Consider it is then READ with the following statements:
7
4
See Also
Forms for Control Edit Descriptors
See Also
Nested and Group Repeat Specifications
1035
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
To include an apostrophe in a character constant that is enclosed by apostrophes, place two consecutive
apostrophes ('') in the format specification; for example:
50 FORMAT ('TODAY''S^DATE^IS:^',I2,'/',I2,'/',I2)
Note that the symbol ^ represents a nonprinting blank character.
Similarly, to include a quotation mark in a character constant that is enclosed by quotation marks, place two
consecutive quotation marks ("") in the format specification.
On input, the character constant edit descriptor transfers length of string characters to the edit descriptor.
Examples
Consider the following '(3I5)' format in the WRITE statement:
See Also
Character constants
Format Specifications
H Editing
The H edit descriptor transfers data between the external record and the H edit descriptor itself. The H edit
descriptor is a deleted feature in the Fortran Standard. Intel® Fortran fully supports features deleted in the
Fortran Standard.
An H edit descriptor has the form of a Hollerith constant, as follows:
nHstring
1036
Language Reference
On input, the H edit descriptor transfers n characters from the external field to the edit descriptor. The first
character appears immediately after the letter H. Any characters in the edit descriptor before input are
replaced by the input characters. If the edit descriptor appears in a FORMAT statement, the replaced
characters are preserved for future uses of that FORMAT statement; otherwise, the replacement is discarded.
On output, the H edit descriptor causes n characters following the letter H to be output to an external record.
Examples
! These WRITE statements both print "Don't misspell 'Hollerith'"
! (The leading blanks are carriage-control characters).
! Hollerith formatting does not require you to embed additional
! single quotation marks as shown in the second example.
!
WRITE (*, 960)
960 FORMAT (27H Don't misspell 'Hollerith')
WRITE (*, 961)
961 FORMAT (' Don''t misspell ''Hollerith''')
See Also
Deleted and Obsolescent Language Features
Format Specifications
See Also
String edit descriptors
Control edit descriptors
Forms for Data Edit Descriptors for details on repeat specifications for data edit descriptors
Interaction Between Format Specifications and I/O Lists for details on group repeat specifications
and format reversion
1037
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Examples
Consider the following statement:
FORMAT (I<J+1>)
When the format is scanned, the preceding statement performs an I (integer) data transfer with a field width
of J+1. The expression is reevaluated each time it is encountered in the normal format scan.
Consider the following statements:
DIMENSION A(5)
DATA A/1.,2.,3.,4.,5./
DO 10 I=1,10
WRITE (6,100) I
100 FORMAT (I<MAX(I,5)>)
10 CONTINUE
DO 20 I=1,5
WRITE (6,101) (A(I), J=1,I)
101 FORMAT (<I>F10.<I-1>)
20 CONTINUE
END
On execution, these statements produce the following output:
1
2
3
4
5
6
7
8
9
10
1.
2.0 2.0
3.00 3.00 3.00
4.000 4.000 4.000 4.000
5.0000 5.0000 5.0000 5.0000 5.0000
1038
Language Reference
WRITE(6,20) INT1
20 FORMAT(I<MAX(20,5)>)
See Also
Interaction Between Format Specifications and I/O Lists for details on the synchronization of I/O
lists with formats
ASCII NUL1 Overprinting with no advance Outputs the record (at the
current position in the current
line), but no carriage return.
1039
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Any other character is interpreted as a blank and is deleted from the print line. If you do not specify a control
character for printing, the first character of the record is not printed.
Examples
The data in file FOR002.DAT is to be processed 2 records at a time. Each record starts with a number to be
put into an element of a vector B, followed by 5 numbers to be put in a row in matrix A.
FOR002.DAT contains the following data:
1040
Language Reference
The following example shows how several different format specifications interact with I/O lists to process
data in file FOR002.DAT:
END
This statement reads B(1); then A(1,1) through A(1,5); then B(2) and A(2,1) through A(2,5).
The first record read (starting with 001) starts the processing of the I/O list.
There are two records, each in the format I3, X, 5(I4, X). The slash (/) forces the reading of the second
record after A(1,5) is processed. It also forces the reading of the third record after A(2,5) is processed; no
data is taken from that record.
B is 1 2 ; A is 101 102 103 104 105 201 202 203 204 205
This statement reads the record starting with 004. The slash (/) forces the reading of the next record
after A(1,5) is processed. The colon (:) stops the reading after A(2,5) is processed, but before the slash (/)
forces another read.
B is 4 5 ; A is 401 402 403 404 405 501 502 503 504 505
1041
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
This statement reads the record starting with 006. After A(1,5) is processed, format reversion causes the
next record to be read and starts format processing at the left parenthesis before the I3.
B is 6 7 ; A is 601 602 603 604 605 701 702 703 704 705
This statement reads the record starting with 008. After A(1,5) is processed, format reversion causes the
next record to be read and starts format processing at the left parenthesis before the I4.
B is 8 90 ; A is 801 802 803 804 805 9010 9020 9030 9040 100
The record 009 0901 0902 0903 0904 0905 is processed with I4 as "009 " for B(2), which is 90. X skips the
next "0". Then "901 " is processed for A(2,1), which is 9010, "902 " for A(2,2), "903 " for A(2,3), and "904 "
for A(2,4). The repeat specification of 5 is now exhausted and the format ends. Format reversion causes
another record to be read and starts format processing at the left parenthesis before the I4, so "010 " is read
for A(2,5), which is 100.
See Also
Data edit descriptors
Control edit descriptors
Q edit descriptor
Character string edit descriptors
Scale Factor Editing (P)
1042
Language Reference
• WAIT
Performs a wait operation for a specified pending asynchronous data transfer operation.
The following table summarizes I/O statement specifiers:
I/O Specifiers
1043
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
I/O Specifiers
DISPOSE=dis (or 'KEEP', 'SAVE', 'DELETE', Specifies the status of a OPEN, CLOSE
DISP=dis) 'PRINT', 'PRINT/ file after the unit is
DELETE', 'SUBMIT', or closed.
'SUBMIT/DELETE'
(default is 'DELETE' for
scratch files; 'KEEP' for
all other files)
ERR=errlabel Integer between 1 and Specifies the label of an All except PRINT
99999 executable statement
where execution is
transferred after an I/O
error.
1044
Language Reference
I/O Specifiers
1045
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
I/O Specifiers
POS=pos Positive integer Specifies the file storage INQUIRE, READ, WRITE
unit position in a stream
file.
REC=rec Positive integer variable Specifies the first (or READ, WRITE
or expression only) record of a file to
be read from, or written
to.
1046
Language Reference
I/O Specifiers
See Also
Data transfer I/O statements
I/O Control List for details on control specifiers
1047
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
UNIT control specifier
ERR control specifier
ID control specifier
IOMSG control specifier
IOSTAT control specifier
RECL specifier in OPEN statements
FILE specifier in OPEN statements
DEFAULTFILE specifier in OPEN statements
1048
Language Reference
1049
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
BLOCKSIZE = bks
1050
Language Reference
1051
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1052
Language Reference
1053
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
iof Is a scalar default logical variable that is assigned one of the following
values:
If unit '*' is specified, the default is .FALSE.; otherwise, the default is .TRUE..
A value of .TRUE. causes a call to FOCUSQQ immediately before any READ, WRITE, or PRINT statement to
that window.
If you use this specifier with a non-Windows application, an error occurs.
nme Is a scalar default character variable that is assigned the name of the
file to which the unit is connected. If the file does not have a name,
nme is undefined.
The value assigned to nme is not necessarily the same as the value
given in the FILE specifier. However, the value that is assigned is
always valid for use with the FILE specifier in an OPEN statement,
unless the value has been truncated in a way that makes it
unacceptable. (Values are truncated if the declaration of nme is too
small to contain the entire value.)
NOTE
The FILE and NAME specifiers are synonyms when used with the OPEN statement, but not when used
with the INQUIRE statement.
See Also
The appropriate manual in your operating system documentation set for details on the maximum size of file
pathnames
1054
Language Reference
nmd Is a scalar default logical variable that is assigned one of the following
values:
1055
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
pnd Is a scalar default logical variable that is assigned the value .TRUE.
or .FALSE..
1056
Language Reference
See Also
ID Specifier
If the file is positioned at its terminal position, p is assigned a value one greater than the number of the
highest-numbered file storage unit in the file.
If the file is not connected for stream access or if the position of the file is indeterminate because of previous
error conditions, p is assigned the value one.
If there are pending asynchronous data operations for the specified file, the value assigned to the POS=
specifier is computed as if all pending data transfers have already completed.
1057
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The assigned value is expressed in 4-byte units if the file is currently (or was previously) connected for
unformatted data transfer and the assume byterecl compiler option is not in effect; otherwise, the value is
expressed in bytes.
1058
Language Reference
1059
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The rounding modes conform to the corresponding rounding modes specified in the ISO/IEC/IEEE
60559:2011 standard.
1060
Language Reference
For a file that is connected for stream access, the file size is the number of the highest-numbered file storage
unit in the file.
For a file that is connected for sequential or direct access, the file size may be different from the number of
storage units implied by the data in the records; the exact relationship is processor-dependent.
If there are pending asynchronous data transfer operations for the specified file, the value assigned to the
SIZE= specifier is computed as if the pending data transfers have already completed.
1061
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1062
Language Reference
'ZERO'
1063
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
name)
QuickWin application
.FALSE.
1064
Language Reference
'DENYWR' 5
'DENYRD' 6
'DENYNONE'
'NEW'
'SCRATCH'
'REPLACE'
'UNKNOWN'
Key to Values
See Also
INQUIRE Statement for details on using the INQUIRE statement to get file attributes of existing
files
1065
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
fpscomp compiler option
1066
Language Reference
Direct access READs, direct access WRITEs, and the FIND, DELETE, and REWRITE statements can affect the
value of asv.
This specifier is valid only for direct access; it is ignored for other access modes.
The default is 'NULL' (for explicitly OPENed files, preconnected files, and internal files). If you specify
compiler option f66 (or OPTIONS/NOF77), the default is 'ZERO'.
If the BN or BZ edit descriptors are specified for a formatted input statement, they supersede the default
interpretation of blanks.
This specifier is not allowed on unformatted input or output.
See Also
Blank Editing for details on the BN and BZ edit descriptors
f66
1067
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If you specify a nonzero number for bks, it is rounded up to a multiple of 512 byte blocks. The maximum
valid value of BLOCKSIZE is 2147467264.
If you do not specify BLOCKSIZE or you specify zero for bks, the default value of 128 KB (131,072 bytes) is
assumed. However, if you compile with the assume buffered_stdout option, the default blocksize for
stdout is 8 KB.
The default BLOCKSIZE value can be changed by using the FORT_BLOCKSIZE environment variable or by
specifying the BLOCKSIZE parameter on the unit's OPEN. The BLOCKSIZE value can be changed for stdout
by re-opening the unit corresponding to stdout with an explicit BLOCKSIZE parameter; for example:
OPEN(6,ACCESS='SEQUENTIAL',FORM='FORMATTED',BUFFERED='YES',BLOCKSIZE=1048576
The BLOCKSIZE specifier determines the size of each buffer. For example, if BUFFERCOUNT=3 and
BLOCKSIZE=2048, the total number of bytes allocated for buffers is 3*2048, or 6144 bytes.
If you do not specify BUFFERCOUNT or you specify zero for bc, the default is 1.
See Also
BLOCKSIZE specifier
1068
Language Reference
The default is 'NO' for buffering output. The default is also 'NO' when reading variable length, unformatted
records whose length exceeds that of the block size specified for the file.
If BUFFERED='YES' is specified, the request may or may not be honored, depending on the device and other
file or connection characteristics.
For direct access, you should specify BUFFERED='YES', although using direct-access I/O to a network file
system may be much slower.
If both BLOCKSIZE and BUFFERCOUNT for OPEN have been specified with positive values, their product
determines the size in bytes of the buffer for that I/O unit. Otherwise, the default size of the internal buffer is
8 KB (8192 bytes).
NOTE
On Windows systems, the default size of the internal buffer is 1024 bytes if compiler option fpscomp
general is used.
The internal buffer will grow to hold the largest single record but will never shrink.
See Also
Rules for Unformatted Sequential READ Statements
The default for binary (W*S) and unformatted files is 'NONE'. The default for formatted files is 'LIST'.
However, if you specify compiler option vms or fpscomp general, and the unit is connected to a terminal, the
default is 'FORTRAN'.
On output, if a file was opened with CARRIAGECONTROL='FORTRAN' in effect or the file was processed by
the fortpr format utility, the first character of a record transmitted to a line printer or terminal is typically a
character that is not printed, but is used to control vertical spacing.
1069
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Printing of Formatted Records for details on valid control characters for printing
vms compiler option
fpscomp compiler option
1070
Language Reference
REAL(4) or COMPLEX(4),
G_floating for size REAL(8) or
COMPLEX(8), and H_floating for
REAL(16) or COMPLEX(16).
You can use CONVERT to specify multiple formats in a single program, usually one format for each specified
unit number.
When reading a nonnative format, the nonnative format on disk is converted to native format in memory. If a
converted nonnative value is outside the range of the native data type, a run-time message appears.
There are other ways to specify numeric format for unformatted files: you can specify an environment
variable, compiler option convert, or OPTIONS/CONVERT. The following shows the order of precedence:
OPEN (CONVERT=) .
OPTIONS/CONVERT .
Compiler option convert and OPTIONS/CONVERT affect all unit numbers used by the program, while
environment variables and OPEN (CONVERT=) affect specific unit numbers.
The following example shows how to code the OPEN statement to read unformatted CRAY* numeric data
from unit 15, which might be processed and possibly written in native little endian format to unit 20:
OPEN (CONVERT='CRAY', FILE='graph3.dat', FORM='UNFORMATTED',
1 UNIT=15)
...
OPEN (FILE='graph3_native.dat', FORM='UNFORMATTED', UNIT=20)
See Also
Data Types, Constants, and Variables for details on supported ranges for data types
convert compiler option
1071
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
DEFAULTFILE supplies a value to the Fortran I/O system that is prefixed to the name that appears in FILE.
If def does not end in a slash (/), a slash is added.
If DEFAULTFILE is omitted, the Fortran I/O system uses the current working directory.
1072
Language Reference
The DELIM specifier is only allowed for files connected for formatted data transfer; it is ignored during input.
This specifier is not allowed on unformatted input or output.
The default is 'DELETE' for scratch files. For all other files, the default is 'KEEP'.
On Windows*, PRINT and the PRINT part of PRINT/DELETE do not use the system PRINT command. One of
the following occurs:
• If you set the environment variable FOR_DEFAULT_PRINT_DEVICE to a print device, the Fortran run-time
will copy the file to that device.
• Otherwise, the Fortran run-time will copy the file to a new file named "PRN-FILE". In this case, you will
need to do the actual printing
1073
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1074
Language Reference
Unit 2 is associated with the file FIRST.FIL. Because a blank argument was specified on the command
line for the second filename, the OPEN statement for unit 4 produces the following prompt:
Filename missing or blank - Please enter name UNIT 4?
Unit 5 is associated with the file THIRD.TXT. Because no fourth file was specified on the command line,
the OPEN statement for unit 10 produces the following prompt:
Filename missing or blank - Please enter name UNIT 10?
See Also
fpscomp compiler option
The default is 'FORMATTED' for sequential access files, and 'UNFORMATTED' for direct access files.
The data is stored and retrieved in a file according to the file's access (set by the ACCESS specifier) and the
form of the data the file contains.
A formatted file is a sequence of formatted records. Formatted records are a series of ASCII characters
terminated by an end-of-record mark (a carriage return and line feed sequence). The records in a formatted
direct-access file must all be the same length. The records in a formatted sequential file can have varying
lengths. All internal files must be formatted.
An unformatted file is a sequence of unformatted records. An unformatted record is a sequence of values.
Unformatted direct files contain only this data, and each record is padded to a fixed length with undefined
bytes. Unformatted sequential files contain the data plus information that indicates the boundaries of each
record.
Binary sequential files are sequences of bytes with no internal structure. There are no records. The file
contains only the information specified as I/O list items in WRITE statements referring to the file.
Binary direct files have very little structure. A record length is assigned by the RECL specifier in an OPEN
statement. This establishes record boundaries, which are used only for repositioning and padding before and
after read and write operations and during BACKSPACE operations. Record boundaries do not restrict the
number of bytes that can be transferred during a read or write operation. If an I/O operation attempts to
read or write more values than are contained in a record, the read or write operation is continued on the next
record.
Fortran standard stream access provides similar functionality to FORM='BINARY'. This is specified using
ACCESS='STREAM'.
See Also
Record Access
1075
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If unit '*' is specified, the default is .FALSE.; otherwise, the default is .TRUE..
A value of .TRUE. causes a call to FOCUSQQ immediately before any READ, WRITE, or PRINT statement to
that window. OUTTEXT, OUTGTEXT, or any other graphics routine call does not cause the focus to shift.
If the OPEN is successful, u-var can be used in subsequent I/O statements to access the connected file.
If an error occurs during execution of the OPEN statement containing the NEWUNIT= speciifier, the processor
does not change the value of the variable.
1076
Language Reference
NOSHARED
1077
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If the file is connected for formatted data transfer, the value must be expressed in bytes (characters).
Otherwise, the value is expressed in 4-byte units (longwords). If the file is connected for unformatted data
transfer, the value can be expressed in bytes if compiler option assume byterecl is specified.
Except for segmented records, the rl is the length for record data only, it does not include space for control
information. If rl is too large, you can exhaust your program's virtual memory resources trying to create
room for the record.
The length specified is interpreted depending on the type of records in the connected file, as follows:
• For segmented records, RECL indicates the maximum length for any segment (including the four bytes of
control information).
1078
Language Reference
• For fixed-length records, RECL indicates the size of each record; it must be specified. If the records are
unformatted, the size must be expressed as an even multiple of four.
You can use the RECL specifier in an INQUIRE statement to get the record length before opening the file.
• For variable-length records, RECL indicates the maximum length for any record.
If you read a fixed-length file with a record length different from the one used to create the file,
indeterminate results can occur.
The maximum length for rl depends on the record type and the setting of the CARRIAGECONTROL specifier,
as shown in the following table:
Maximum Record Lengths (RECL)
Record Type CARRIAGECONTROL Formatted (size in bytes)
The default value depends on the setting of the RECORDTYPE specifier, as shown in the following table:
Default Record Lengths (RECL)
RECORDTYPE RECL value
All other settings 132 bytes for formatted records; 510 longwords for
unformatted records.1
1Tochange the default record length values, you can use environment variable FORT_FMT_RECL or
FORT_UFMT_RECL.
For formatted records with other than RECORDTYPE='FIXED', the default RECL is 132.
There is a property of list-directed sequential WRITE statements called the right margin. If you do not
specify RECL as an OPEN statement specifier or in environmental variable FORT_FMT_RECL, the right margin
value defaults to 80. When RECL is specified, the right margin is set to the value of RECL. If the length of a
list-directed sequential WRITE exceeds the value of the right margin value, the remaining characters will
wrap to the next line. Therefore, writing 100 characters will produce two lines of output, and writing 180
characters will produce three lines of output. You can turn off the right margin using the wrap-margin
compiler option or the FORT_FMT_NO_WRAP_MARGIN environment variable.
See Also
assume:byterecl compiler option
vms compiler option
Record Transfer
1079
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
A segmented record is a logical record consisting of segments that are physical records. Since the length of a
segmented record can be greater than 65,535 bytes, only use segmented records for unformatted sequential
access to disk or raw magnetic tape files.
Files containing segmented records can be accessed only by unformatted sequential data transfer
statements.
If an output statement does not specify a full record for a file containing fixed-length records, the following
occurs:
• In formatted files, the record is filled with blanks
• In unformatted files, the record is filled with zeros
1080
Language Reference
ROUND = rmode
The default I/O rounding mode is 'PROCESSOR_DEFINED'. For ifort, this corresponds to 'NEAREST'.
The rounding modes conform to the corresponding rounding modes specified in the ISO/IEC/IEEE
60559:2011 standard.
You can only use this specifier for a formatted I/O connection.
The rounding mode can be temporarily changed within a READ or WRITE statement by the corresponding RU,
RD, RZ, RN, RC, and RP edit descriptors.
This specifier is not allowed on unformatted input or output.
1081
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
On Windows systems, the default is 'DENYWR'. However, if you specify compiler option fpscomp general or
the SHARED specifier, the default is 'DENYNONE'.
On Linux and macOS* systems, no restrictions are applied to file opening if you do not use a locking
mechanism.
'COMPAT' is accepted for compatibility with previous versions. It is equivalent to 'DENYNONE'.
Use the ACCESS specifier in an INQUIRE statement to determine the access permission for a file.
Be careful not to permit other users to perform operations that might cause problems. For example, if you
open a file intending only to read from it, and want no other user to write to it while you have it open, you
could open it with ACTION='READ' and SHARE='DENYRW'. Other users would not be able to open it with
ACTION='WRITE' and change the file.
Suppose you want several users to read a file, and you want to make sure no user updates the file while
anyone is reading it. First, determine what type of access to the file you want to allow the original user.
Because you want the initial user to read the file only, that user should open the file with ACTION='READ'.
Next, determine what type of access the initial user should allow other users; in this case, other users should
be able only to read the file. The first user should open the file with SHARE='DENYWR'. Other users can also
open the same file with ACTION='READ' and SHARE='DENYWR'.
See Also
fpscomp compiler option
See Also
fpscomp compiler option
1082
Language Reference
SIGN = sn
1083
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Scratch files go into a temporary directory and are visible while they are open. Scratch files are deleted when
the unit is closed or when the program terminates normally, whichever occurs first.
To specify the path for scratch files, you can use one of the following environment variables:
• On Windows*: FORT_TMPDIR, TMP, or TEMP, searched in that order
• On Linux* and macOS*: FORT_TMPDIR or TMPDIR, searched in that order
If no environment variable is defined, the default is the current directory.
The default is 'UNKNOWN'. This is also the default if you implicitly open a file by using WRITE. However, if
you implicitly open a file using READ, the default is 'OLD'. If you specify compiler option f66 (or OPTIONS/
NOF77), the default is 'NEW'.
NOTE
The STATUS specifier can also appear in CLOSE statements to indicate the file's status after it is
closed. However, in CLOSE statements the STATUS values are the same as those listed for the
DISPOSE specifier.
See Also
f66 compiler option
1084
Compilation Control Lines and Statements
The return value is the file descriptor. On Linux and macOS*, the file
descriptor is a 4-byte integer on both 32-bit and 64-bit systems. On
Windows, the file descriptor is a 4-byte integer on 32-bit systems and
an 8-byte integer on 64-bit systems.
If the function is written in Fortran, do not execute a Fortran OPEN statement to open the file named in
USEROPEN.
The Intel® Fortran Run-time Library (RTL) I/O support routines call the function named in USEROPEN in place
of the system calls normally used when the file is first opened for I/O.
On Windows* systems, the Fortran RTL normally calls CreateFile( ) to open a file. When USEROPEN is
specified, the called function opens the file (or pipe, etc.) by using CreateFile( ) and returns the handle of
the file (return value from CreateFile( )) when it returns control to the calling Fortran program.
On Linux* and macOS* systems, the Fortran RTL normally calls the open function to open a file. When
USEROPEN is specified, the called function opens the file by calling open and returns the file descriptor of the
file when it returns control to the calling Fortran program.
When opening the file, the called function usually specifies options different from those provided by a normal
Fortran OPEN statement.
NOTE
You may get unexpected results if you specify OPEN with a filename and a USEROPEN specifier that
opens a different filename, and then use a CLOSE statement with STATUS=DELETE (or
DISPOSE=DELETE). In this case, the run-time library assumes you want to delete the file named in
the OPEN statement, not the one you specified in the USEROPEN function.
For more information about how to use the USEROPEN specifier, see User-Supplied OPEN Procedures/
USEROPEN Specifier.
1085
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The following prefix forms can be used in place of !DIR$: cDIR$, cDEC$, or !MS$, where c is one of the
following: C (or c), !, or *.
The following prefix forms can be used in place of !$OMP: c$OMP, where c is one of the following: C (or c), !,
or *.
The following are source form rules for directive prefixes:
• In fixed and tab source forms, prefixes begin with !, C (or c), or *.
The prefix must appear in columns 1 through 5; column 6 must be a blank or a tab (except for prefix !MS
$). From column 7 on, blanks are insignificant, so the directive can be positioned anywhere on the line
after column 6.
• In free source form, prefixes begin with !.
The prefix can appear in any column, but it cannot be preceded by any nonblank, nontab characters on
the same line.
• In all source forms, directives spelled with two keywords can be separated by an optional space; for
example, "LOOP COUNT" and "LOOPCOUNT" are both valid spellings for the same directive. However,
when a directive name is preceded by the prefix "NO", this is not considered to be two keywords. For
example, "NO DECLARE" is not a valid spelling; the only valid spelling for this directive is "NODECLARE".
A compiler directive ends in column 72 (or column 132, if compiler option extend-source is specified).
General compiler directives and OpenMP Fortran directives can be continued in the same way as Fortran
statements can be continued:
• In fixed form, the first line of the directive {initial line} has the directive prefix is in columns 1 through 5
and has a blank, a tab, or a zero in column 6; each continued line of the directive has the directive prefix
in columns 1 through 5 and has a character other than a blank, a tab, or a zero in column 6.
• In free form, the initial line of the directive ends with an ampersand followed by an optional comment
beginning with an exclamation point. Each continued line of the directive has the directive prefix
optionally preceded by blanks or tabs, followed by an ampersand optionally preceded by blanks or tabs.
A comment beginning with an ! can follow a compiler directive on the same line.
Additional Fortran statements (or directives) cannot appear on the same line as the compiler directive.
Compiler directives cannot appear within a continued Fortran statement.
Blank common used in a compiler directive is specified by two slashes (/ /).
If the source line starts with a valid directive prefix but the directive is not recognized, the compiler displays
an informational message and ignores the line.
1086
Language Reference
• ALIAS
Specifies an alternate external name to be used when referring to external subprograms.
• ASSUME
Provides heuristic information to the compiler optimizer.
• ASSUME_ALIGNED
Specifies that an entity in memory is aligned.
• ATTRIBUTES
Specifies properties for data objects and procedures.
• BLOCK_LOOP and NOBLOCK_LOOP
Enables or disables loop blocking for the immediately following nested DO loops.
• DECLARE and NODECLARE
Generates or disables warnings for variables that have been used but not declared.
• DEFINE and UNDEFINE
Defines (or undefines) a symbolic variable whose existence (or value) can be tested during conditional
compilation.
• DISTRIBUTE POINT
Suggests a location at which a DO loop may be split.
• FIXEDFORMLINESIZE
Sets the line length for fixed-form source code.
• FMA and NOFMA
Enables (or disables) the compiler to allow generation of fused multiply-add (FMA) instructions, also
known as floating-point contractions.
• FREEFORM and NOFREEFORM
Specifies free-format or fixed-format source code.
• IDENT
Specifies an identifier for an object module.
• IF and IF DEFINED
Specifies a conditional compilation construct.
• INLINE, FORCEINLINE, NOINLINE
Tell the compiler to perform the specified inlining on routines within statements or DO loops.
• INTEGER
Specifies the default integer kind.
• IVDEP
Assists the compiler's dependence analysis of iterative DO loops.
• LOOP COUNT
Specifies the typical trip count for a DO loop; this assists the optimizer.
• MESSAGE
Specifies a character string to be sent to the standard output device during the first compiler pass.
• NOFUSION
Prevents a loop from fusing with adjacent loops.
• OBJCOMMENT
Specifies a library search path in an object file.
• OPTIMIZE and NOOPTIMIZE
Enables or disables optimizations for the program unit.
• OPTIONS
Affects data alignment and warnings about data alignment.
• PACK
Specifies the memory alignment of derived-type items.
• PARALLEL and NOPARALLEL
1087
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
See Also
Syntax Rules for Compiler Directives
Rules for General Directives that Affect DO Loops
subroutine sub()
integer kk
1088
Language Reference
print *, kind(kk), kind(-42) ! this prints 4, 4 because the INTEGER:2 directive has no effect
here
end
The following directives have this behavior:
• ALIAS
• ATTRIBUTES
• DECLARE and NODECLARE
• DEFINE and UNDEFINE
• FIXEDFORMLINESIZE
• FREEFORM and NOFREEFORM
• IDENT
• INTEGER
• OPTIMIZE and NOOPTIMIZE
• PACK
• PREFETCH
• PSECT
• REAL
• STRICT and NOSTRICT
Other rules may apply to these directives. For more information, see the description of each directive.
LOOP COUNT
NOFUSION
NOUNROLL_AND_JAM
1089
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Rules for Loop Directives that Affect Array Assignment Statements
FORCEINLINE SIMD
IVDEP UNROLL_AND_JAM
NOFUSION
NOUNROLL_AND_JAM
Usually only one of the general directives can precede the array assignment statement (one-dimensional-
array = expression) to affect it. The BLOCK_LOOP and NOBLOCK_LOOP directives may precede array
assignment statements with any rank variable on the left-hand-side of the assignment.
Other rules may apply to the general directives. For more information, see the description of each directive.
Examples
Consider the following:
!DIR$ IVDEP
DO I = 1, 10
A (I) = B (I) + 3
END DO
See Also
Rules for General Directives that Affect DO Loops
1090
Language Reference
OpenMP directives are specially formatted Fortran comment lines embedded in the source file which provide
the compiler with hints and suggestions for parallelization, optimization, vectorization, and offloading code to
accelerator hardware. The compiler uses the information specified in the directives with compiler heuristic
algorithms to generate more efficient code. At times, these heuristics may choose to ignore or override the
information provided by a directive. If the directive is ignored by the compiler, no diagnostic message is
issued.
Options that use OpenMP* are available for both Intel® microprocessors and non-Intel microprocessors, but
these options may perform additional optimizations on Intel® microprocessors than they perform on non-Intel
microprocessors. The list of major, user-visible OpenMP constructs and features that may perform differently
on Intel® microprocessors vs. non-Intel microprocessors includes: locks (internal and user visible), the
SINGLE construct, barriers (explicit and implicit), parallel loop scheduling, reductions, memory allocation,
thread affinity, and binding.
This section discusses clauses used in multiple OpenMP* Fortran directives, conditional compilation rules,
nesting and binding rules, and the following directives:
• ALLOCATE directive
Specifies memory allocators to use for object allocation and deallocation. This feature is only available for
ifx.
• ATOMIC construct
Specifies that a specific memory location is to be updated atomically.
• BARRIER directive
Synchronizes all the threads in a team.
• CANCEL directive
Requests cancellation of the innermost enclosing region of the type specified, and causes the
encountering implicit or explicit task to proceed to the end of the canceled construct.
• CANCELLATION POINT directive
Defines a point at which implicit or explicit tasks check to see if cancellation has been requested for the
innermost enclosing region of the type specified.
• CRITICAL construct
Restricts access for a block of code to only one thread at a time.
• DECLARE REDUCTION directive
Declares a user-defined reduction for one or more types.
• DECLARE SIMD directive
Generates a SIMD procedure.
• DECLARE TARGET directive
Causes the creation of a device-specific version of a named routine that can be called from a target
region. This feature is only available for ifx.
• DECLARE VARIANT directive
Identifies a variant of a base procedure and specifies the context in which this variant is used. This
feature is only available for ifx.
• DISPATCH directive
Determines if a variant of a base procedure is to be called for a given subroutine or function call. This
feature is only available for ifx.
• DISTRIBUTE construct
Specifies that loop iterations will be executed by thread teams in the context of their implicit tasks.
• DISTRIBUTE PARALLEL DO construct
Specifies a loop that can be executed in parallel by multiple threads that are members of multiple teams.
• DISTRIBUTE PARALLEL DO SIMD construct
Specifies a loop that will be executed in parallel by multiple threads that are members of multiple teams.
It will be executed concurrently using SIMD instructions.
• DISTRIBUTE SIMD construct
1091
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Specifies a loop that will be distributed across the primary threads of the teams region. It will be executed
concurrently using SIMD instructions.
• DO construct
Specifies that the iterations of the immediately following DO loop must be executed in parallel.
• DO SIMD construct
Specifies a loop that can be executed concurrently using SIMD instructions.
• FLUSH directive
Specifies synchronization points where the threads in a team must have a consistent view of memory.
• INTEROP directive
Identifies a foreign runtime context and identifies runtime characteristics of that context, enabling
interoperability with it. This feature is only available for ifx.
• LOOP construct
Specifies that the iterations of the associated loops can execute concurrently. This feature is only available
for ifx.
• MASKED construct
Specifies a block of code to be executed by the primary thread of the team. This feature is only available
for ifx.
• MASKED TASKLOOP construct
Provides an abbreviated way to specify a TASKLOOP construct inside a MASKED construct. This feature is
only available for ifx.
• MASKED TASKLOOP SIMD construct
Provides an abbreviated way to specify a TASKLOOP SIMD construct inside a MASKED construct. This
feature is only available for ifx.
• MASTER construct
Deprecated; see MASKED. Specifies a block of code to be executed by the master thread of the team.
• MASTER TASKLOOP construct
Deprecated; provides an abbreviated way to specify a TASKLOOP construct inside a MASTER construct.
This feature is only available for ifx.
• MASTER TASKLOOP SIMD construct
Deprecated; provides an abbreviated way to specify a TASKLOOP SIMDconstruct inside a MASTER
construct. This feature is only available for ifx.
• ORDERED directive and construct
Specifies a block of code that the threads in a team must execute in the natural order of the loop
iterations.
• PARALLEL construct
Defines a parallel region.
• PARALLEL DO construct
Defines a parallel region that contains a single DO directive.
• PARALLEL DO SIMD construct
Specifies a loop that can be executed concurrently using SIMD instructions. It provides a shortcut for
specifying a PARALLEL construct containing one SIMD loop construct and no other statement.
• PARALLEL LOOP construct
Specifies a shortcut for indicating that a loop or loop nest can execute concurrently across multiple
threads. This feature is only available for ifx.
• PARALLEL MASKED construct
Provides an abbreviated way to specify a MASKED construct inside a PARALLEL construct.This feature is
only available for ifx.
• PARALLEL MASKED TASKLOOP construct
Provides an abbreviated way to specify a MASKED TASKLOOP construct inside a PARALLEL construct.This
feature is only available for ifx.
• PARALLEL MASKED TASKLOOP SIMD construct
1092
Language Reference
Provides an abbreviated way to specify a MASKED TASKLOOP SIMD construct inside a PARALLEL
construct.This feature is only available for ifx.
• PARALLEL MASTER construct
Deprecated; provides an abbreviated way to specify a MASTER construct inside a PARALLEL construct.
This feature is only available for ifx.
• PARALLEL MASTER TASKLOOP construct
Deprecated; provides an abbreviated way to specify a MASTER TASKLOOP construct inside a PARALLEL
construct. This feature is only available for ifx.
• PARALLEL MASTER TASKLOOP SIMD construct
Deprecated; provides an abbreviated way to specify a MASTER TASKLOOP SIMD construct inside a
PARALLEL construct. This feature is only available for ifx.
• PARALLEL SECTIONS construct
Defines a parallel region that contains a single SECTIONS directive.
• PARALLEL WORKSHARE construct
Defines a parallel region that contains a single WORKSHARE directive.
• REQUIRES directive
Lists the features that an implementation must support so that the program compiles and runs correctly.
This feature is only available for ifx.
• SCAN directive
Specifies a scan computation that updates each list item in each iteration of the loop the directive appears
in.
• SECTIONS construct
Specifies that the enclosed SECTION directives define blocks of code to be divided among threads in a
team.
• SIMD construct
Requires and controls SIMD vectorization of loops.
• SINGLE construct
Specifies a block of code to be executed by only one thread in a team at a time.
• TARGET construct
Creates a device data environment and executes the construct on the same device.
• TARGET DATA construct
Creates a device data environment for the extent of the region.
• TARGET ENTER DATA
Specifies that variables are mapped to a device data environment.
• TARGET EXIT DATA
Specifies that variables are unmapped from a device data environment.
• TARGET PARALLEL construct
Creates a device data environment in a parallel region and executes the construct on that device.
• TARGET PARALLEL DO construct
Provides an abbreviated way to specify a TARGET directive containing a PARALLEL DO directive and no
other statements.
• TARGET PARALLEL DO SIMD construct
Specifies a TARGET construct that contains a PARALLEL DO SIMD construct and no other statement.
• TARGET PARALLEL LOOP construct
Specifies a shortcut for specifying a parallel loop inside a TARGET construct that contains no other
statements than the parallel loop. This feature is only available for ifx.
• TARGET SIMD construct
Specifies a TARGET construct that contains a SIMD construct and no other statement.
• TARGET TEAMS construct
1093
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Creates a device data environment and executes the construct on the same device. It also creates a
league of thread teams with the primary thread in each team executing the structured block.
• TARGET TEAMS DISTRIBUTE construct
Creates a device data environment and executes the construct on the same device. It also specifies that
loop iterations will be shared among the primary threads of all thread teams in a league created by a
TEAMS construct.
• TARGET TEAMS DISTRIBUTE PARALLEL DO construct
Creates a device data environment and then executes the construct on that device. It also specifies a loop
that can be executed in parallel by multiple threads that are members of multiple teams created by a
TEAMS construct.
• TARGET TEAMS DISTRIBUTE PARALLEL DO SIMD construct
Creates a device data environment and then executes the construct on that device. It also specifies a loop
that can be executed in parallel by multiple threads that are members of multiple teams created by a
TEAMS construct. The loop will be distributed across the teams, which will be executed concurrently using
SIMD instructions.
• TARGET TEAMS DISTRIBUTE SIMD construct
Creates a device data environment and executes the construct on the same device. It also specifies that
loop iterations will be shared among the master threads of all thread teams in a league created by a
teams construct. It will be executed concurrently using SIMD instructions.
• TARGET TEAMS LOOP construct
Specifies a shortcut for specifying a TEAMS LOOP construct inside a TEAMS construct that contains no
other statements. This feature is only available for ifx.
• TARGET UPDATE directive
Makes the list items in the device data environment consistent with their corresponding original list items.
• TARGET VARIANT DISPATCH directive
Conditionally calls a procedure offload variant if the device is free; otherwise, executes the procedure on
the host. This feature is only available for ifx.
• TASK construct
Defines a task region.
• TASKGROUP construct
Specifies a wait for the completion of all child tasks of the current task and all of their descendant tasks.
• TASKLOOP construct
Specifies that the iterations of one or more associated DO loops should be executed in parallel using
OpenMP* tasks. The iterations are distributed across tasks that are created by the construct and
scheduled to be executed.
• TASKLOOP SIMD construct
Specifies a loop that can be executed concurrently using SIMD instructions and that those iterations will
also be executed in parallel using OpenMP* tasks.
• TASKWAIT directive
Specifies a wait on the completion of child tasks generated since the beginning of the current task.
• TASKYIELD directive
Specifies that the current task can be suspended at this point in favor of execution of a different task.
• TEAMS construct
Creates a group of thread teams to be used in a parallel region.
• TEAMS DISTRIBUTE construct
Creates a league of thread teams to execute a structured block in the primary thread of each team. It also
specifies that loop iterations will be shared among the primary threads of all thread teams in a league
created by a TEAMS construct.
• TEAMS DISTRIBUTE PARALLEL DO construct
Creates a league of thread teams to execute a structured block in the primary thread of each team. It also
specifies a loop that can be executed in parallel by multiple threads that are members of multiple teams.
• TEAMS DISTRIBUTE PARALLEL DO SIMD construct
1094
Language Reference
Creates a league of thread teams to execute a structured block in the primary thread of each team. It also
specifies a loop that can be executed in parallel by multiple threads that are members of multiple teams.
The loop will be distributed across the primary threads of the teams region, which will be executed
concurrently using SIMD instructions.
• TEAMS DISTRIBUTE SIMD construct
Creates a league of thread teams to execute the structured block in the primary thread of each team. It
also specifies a loop that will be distributed across the primary threads of the teams region. The loop will
be executed concurrently using SIMD instructions.
• TEAMS LOOP construct
Specifies a shortcut for specifying a LOOP construct inside a TEAMS construct. This feature is only
available for ifx.
• THREADPRIVATE directive
Makes named common blocks private to each thread, but global within the thread.
• WORKSHARE construct
Divides the work of executing a block of statements or constructs into separate units.
The OpenMP parallel directives can be grouped into the categories. For more information about the
categories for these directives, see OpenMP* Directives Summary.
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
See Also
Syntax Rules for Compiler Directives
qopenmp, Qopenmp compiler option
Clauses Used in Multiple OpenMP* Fortran Directives
The OpenMP web site http://www.openmp.org/
1095
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Name Description
The data copying clauses let you copy data values from private or threadprivate variables in one implicit task
or thread to the corresponding variables in other implicit tasks or threads in the team.
Data Copying Clauses
Name Description
The data motion clause MAP is used in OpenMP* Fortran TARGET directives. This data motion clause does not
modify the values of any of the internal control variables (ICVs).
List items that appear in this data motion clause may have corresponding new list items created in the device
data environment that is associated with the construct. If a new list item is created, a new list item of the
same type, kind, and rank is allocated. The initial value of the new list item is undefined.
The original list items and new list items may share storage. This means that data races can occur. Data
races are caused by unintended sharing of data; for example, when WRITEs to either item by one task or
device are followed by a READ of the other item by another task or device without intervening
synchronization.
Data Allocation and Data Mapping Clauses
Name Description
The following are other clauses that can be used in more than one OpenMP* Fortran directive.
1096
Language Reference
Miscellaneous Clauses
Name Description
1097
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
c23456789
!$ IAM = OMP_GET_THREAD_NUM( ) +
!$ * INDEX
#IFDEF _OPENMP
IAM = OMP_GET_THREAD_NUM( ) +
* INDEX
#ENDIF
Binding Rules
The following rules apply to dynamic binding:
• The DO, SECTIONS, SINGLE, MASKED, MASTER, and BARRIER directives bind to the dynamically
enclosing PARALLEL directive, if one exists.
• The ORDERED directive binds to the dynamically enclosing DO directive.
• The ATOMIC directive enforces exclusive access with respect to ATOMIC directives in all threads, not just
the current team.
• The CRITICAL directive enforces exclusive access with respect to CRITICAL directives in all threads, not
just the current team.
• A directive can never bind to any directive outside the closest enclosing PARALLEL directive.
Nesting Rules
The following rules apply to dynamic nesting:
• A PARALLEL directive dynamically inside another PARALLEL directive logically establishes a new team,
which is composed of only the current thread unless nested parallelism is enabled.
• DO, SECTIONS, and SINGLE directives that bind to the same PARALLEL directive are not allowed to be
nested one inside the other.
• DO, SECTIONS, and SINGLE directives are not permitted in the dynamic extent of CRITICAL, MASKED,
and MASTER directives.
• BARRIER directives are not permitted in the dynamic extent of DO, SECTIONS, SINGLE, MASKED,
MASTER, and CRITICAL directives.
• MASKED and MASTER directives are not permitted in the dynamic extent of DO, SECTIONS, and SINGLE
directives.
• ORDERED sections are not allowed in the dynamic extent of CRITICAL sections.
• Any directive set that is legal when executed dynamically inside a PARALLEL region is also legal when
executed outside a parallel region. When executed dynamically outside a user-specified parallel region,
the directive is executed with respect to a team composed of only the primary thread.
1098
Language Reference
Examples
The following example shows nested PARALLEL regions:
1099
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Scope
Program entities have the following kinds of scope (as shown in the table below):
1100
Language Reference
• Global
Entities that are accessible throughout an executable program. The name of a global entity must be
unique. It cannot be used to identify any other global entity in the same executable program.
• Scoping unit (Local scope)
Entities that are declared within a scoping unit. These entities are local to that scoping unit. The names of
local entities are divided into classes (see the table below).
A scoping unit is one of the following:
• A derived-type definition
• A procedure interface body (excluding any derived-type definitions and interface bodies contained
within it)
• A program unit or subprogram (excluding any derived-type definitions, interface bodies, and
subprograms contained within it)
A scoping unit that immediately surrounds another scoping unit is called the host scoping unit. Named
entities within the host scoping unit are accessible to the nested scoping unit by host association, unless
access is blocked by an IMPORT ONLY or IMPORT NONE statement. For information about host association,
see Use and Host Association.
Once an entity is declared in a scoping unit, its name can be used throughout that scoping unit. An entity
declared in another scoping unit is a different entity even if it has the same name and properties.
Within a scoping unit, a local entity name that is not generic or an OpenMP* reduction identifier must be
unique within its class. However, the name of a local entity in one class can be used to identify a local
entity of another class.
Within a scoping unit, a generic name can be the same as any one of the procedure names in the
interface block. A generic name can be the same as the name of a derived type.
An OpenMP* reduction identifier can be the same as any local entity name.
A component name has the same scope as the derived type of which it is a component. It can appear only
within a component designator of a structure of that type.
For information on interactions between local and global names, see the table below.
• Statement
Entities that are accessible only within a statement or part of a statement; such entities cannot be
referenced in subsequent statements.
The name of a statement entity can also be the name of a common block, or a local or construct variable
accessible in the same scoping unit or construct; in this case, the name is interpreted within the
statement as that of the statement entity.
• Construct
Construct entities are accessible during the execution of the construct in which they are declared. Entities
declared in the specification part of a BLOCK construct, associate names in ASSOCIATE, SELECT RANK,
and SELECT TYPE constructs, and index variables in FORALL statements or constructs, or DO
CONCURRENT constructs are construct entities. An index name of an inner FORALL statement or
construct, or of a DO CONCURRENT construct cannot be the same as that of an index variable of an outer
(containing) FORALL or DO CONCURRENT construct.
An associate name of a SELECT TYPE construct has a different scope for each block of the construct; the
declared type, dynamic type, type parameters, rank or bounds may differ from block to block. An
associate name for a SELECT RANK construct has a different scope for each block of the construct since
the rank of the associate name is different in each block. An associate name for an ASSOCIATE construct
has the scope of the ASSOCIATE construct.
Scope of Program Entities
Entity Scope
1101
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Entity Scope
1102
Language Reference
Entity Scope
4 The scope of the assignment symbol (=) is global, but it can identify additional operations (see Defining
Generic Assignment).
Scoping units can contain other scoping units. For example, the following shows six scoping units:
MODULE MOD_1 ! Scoping unit 1
... ! Scoping unit 1
CONTAINS ! Scoping unit 1
FUNCTION FIRST ! Scoping unit 2
TYPE NAME ! Scoping unit 3
... ! Scoping unit 3
END TYPE NAME ! Scoping unit 3
... ! Scoping unit 2
CONTAINS ! Scoping unit 2
SUBROUTINE SUB_B ! Scoping unit 4
TYPE PROCESS ! Scoping unit 5
... ! Scoping unit 5
END TYPE PROCESS ! Scoping unit 5
INTERFACE ! Scoping unit 5
SUBROUTINE SUB_A ! Scoping unit 6
... ! Scoping unit 6
BLOCK ! Scoping unit 7
... ! Scoping unit 7
END BLOCK ! Scoping unit 7
END SUBROUTINE SUB_A ! Scoping unit 6
END INTERFACE ! Scoping unit 5
END SUBROUTINE SUB_B ! Scoping unit 4
END FUNCTION FIRST ! Scoping unit 2
END MODULE ! Scoping unit 1
See Also
Derived data types
Defining Generic Names for Procedures
Intrinsic procedures
Program Units and Procedures
Use and host association
Construct association
BLOCK construct
Defining Generic Operators
Defining Generic Assignment
PRIVATE Attributes and Statements
PUBLIC Attributes and Statements
IMPORT statement
1103
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• One is a function with nonzero rank and the other is not known to be a function.
• Within a scoping unit, two procedures that have the same generic name must both be subroutines or both
be functions. One of the procedures must have a nonoptional dummy argument that is one of the
following:
• Not present by position or argument keyword in the other argument list
• Is present, but is distinguishable from the dummy argument in the other argument list
• Within a scoping unit, two procedures that have the same generic operator must both have the same
number of arguments or both define assignment.
One of the procedures must have a dummy argument that corresponds, by position in the argument list,
to a dummy argument of the other procedure. The dummy arguments must be distinguishable from each
other in each argument list.
When an interface block extends an intrinsic procedure, operator, or assignment, the rules apply as if the
intrinsic consists of a collection of specific procedures, one for each allowed set of arguments.
When a generic procedure is accessed from a module, the rules apply to all the specific versions, even if
some of them are inaccessible by their specific names.
See Also
Defining Generic Names for Procedures for details on generic procedure names
1104
Language Reference
Examples
The following example shows how a module can define three separate procedures and give them a generic
name DUP through an interface block. Although the main program calls all three by the generic name, there
is no ambiguity since the arguments are of different data types, and DUP is a function rather than a
subroutine. The module UN_MOD must give each procedure a different name.
MODULE UN_MOD
!
CONTAINS
subroutine dup1(x,y)
real x,y
print *, ' Real arguments', x, y
end subroutine dup1
subroutine dup2(m,n)
integer m,n
print *, ' Integer arguments', m, n
end subroutine dup2
END MODULE
program unclear
!
! shows how to use generic procedure references
USE UN_MOD
INTERFACE DUP
MODULE PROCEDURE dup1, dup2, dup3
END INTERFACE
real a,b
integer c,d
character (len=2) state
a = 1.5
b = 2.32
c = 5
d = 47
state = 'WA'
call dup(a,b)
call dup(c,d)
print *, dup(state) !actual output is 'S' only
END
1105
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Note that the function DUP3 only prints one character, since module UN_MOD specifies no length parameter
for the function result.
If the dummy arguments x and y for DUP were declared as integers instead of reals, then any calls to DUP
would be ambiguous. If this is the case, a compile-time error results.
The subroutine definitions, DUP1, DUP2, and DUP3, must have different names. The generic name is
specified in the first line of the interface block, and in the example is DUP.
1106
Language Reference
See Also
Function references
USE statement
CALL Statement for details on subroutine references
Defining Generic Names for Procedures for details on generic procedure names
Association
Association allows different program units to access the same value through different names. Entities are
associated when each is associated with the same storage location.
Association can occur in the following ways:
• Name association
• Pointer association
• Storage association
• Inheritance association
The following example shows name, pointer, and storage association between an external program unit and
an external procedure.
REAL A, B(4)
REAL, POINTER :: M(:)
REAL, TARGET :: N(12)
COMMON /COM/...
EQUIVALENCE (A, B(1)) ! Storage association between A and B(1)
M => N ! Pointer association
CALL P (actual-arg,...)
...
REAL Y
CALL Q (actual-arg,...)
CONTAINS
SUBROUTINE Q (dummy-arg,...) ! Name and storage association
between
! these arguments and the calling
! routine's arguments in host procedure
! P (subprogram Q has host association
! with procedure P)
Y = 2.0*(Y-1.0) ! Name association with Y in host procedure P
...
1107
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Name Association
Name association allows an entity to be accessed from different scoping units by the same name or by
different names.
Name association can occur in the following ways:
• By argument association
• By use association
• By host association
• By linkage association
• By construct association
Argument Association
Arguments are the values passed to and from functions and subroutines through calling program argument
lists.
Execution of a procedure reference establishes argument association between an actual argument and its
corresponding dummy argument. The name of a dummy argument can be different from the name of its
associated actual argument (if any).
When the procedure completes execution, the argument association is terminated. A dummy argument of
that procedure can be associated with an entirely different actual argument in a subsequent invocation of the
procedure.
1108
Language Reference
If a dummy argument is not allocatable and is not a pointer, it must be type compatible with the associated
actual argument. If a dummy argument is allocatable or a pointer, the associated actual argument must be
polymorphic only if the dummy argument is polymorphic, and the declared type of the actual argument must
be the same as the declared type of the dummy argument.
If the dummy argument is a pointer, the actual argument must be a pointer and the nondeferred type
parameters and ranks must agree. If a dummy argument is allocatable, the actual argument must be
allocatable and the nondeferred type parameters and ranks must agree. The actual argument can have an
allocation status of unallocated.
At the invocation of the procedure, the pointer association status of an actual argument associated with a
pointer dummy argument becomes undefined if the dummy argument has INTENT(OUT).
The dynamic type of a polymorphic, allocatable, or pointer dummy argument can change as a result of
execution of an allocate statement or pointer assignment in the subprogram. Because of this behavior, the
corresponding actual argument needs to be polymorphic and have a declared type that is the same as the
declared type of the dummy argument, or an extension of that type.
The values of assumed type parameters of a dummy argument are assumed from the corresponding type
parameters of the associated actual argument.
Except in references to intrinsic inquiry functions, if the dummy argument is not a pointer and the
corresponding actual argument is a pointer, the actual argument must be associated with a target and the
dummy argument becomes the argument associated with that target.
Except in references to intrinsic inquiry functions, if the dummy argument is not allocatable and the actual
argument is allocatable, the actual argument must be allocated.
If the dummy argument has the VALUE attribute, it becomes associated with a definable anonymous data
object whose initial value is that of the actual argument. Subsequent changes to the value or definition
status of the dummy argument do not affect the actual argument.
If the dummy argument does not have the TARGET or POINTER attribute, any pointers associated with the
actual argument do not become associated with the corresponding dummy argument on invocation of the
procedure.
If the dummy argument has the TARGET attribute, does not have the VALUE attribute, is either a scalar or an
assumed-shape array, and the corresponding actual argument has the TARGET attribute but is not an array
section with a vector subscript, then the following is true:
• Any pointers associated with the actual argument become associated with the corresponding dummy
argument on invocation of the procedure.
• When execution of the procedure completes, any pointers that do not become undefined and are
associated with the dummy argument remain associated with the actual argument.
Any pointers associated with the dummy argument become undefined when execution of the procedure
completes in these cases:
• If the dummy argument has the TARGET attribute and the corresponding actual argument does not have
the TARGET attribute, or is an array section with a vector subscript.
• If the dummy argument has the TARGET attribute and the VALUE attribute.
If a nonpointer dummy argument has INTENT (OUT) or INTENT (INOUT), the actual argument must be
definable. If a dummy argument has INTENT (OUT), the corresponding actual argument becomes undefined
at the time the association is established, except for components of an object of derived type for which
default initialization has been specified. If the dummy argument is not polymorphic and the type of the actual
argument is an extension of the type of the dummy argument, only the part of the actual argument that is of
the same type as the dummy argument becomes undefined.
1109
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Argument Association in Procedures
Procedure Characteristics
1110
Language Reference
Examples
The following example shows host and use association:
MODULE SHARE_DATA
REAL Y, Z
END MODULE
PROGRAM DEMO
USE SHARE_DATA ! All entities in SHARE_DATA are available
REAL B, Q ! through use association.
...
CALL CONS (Y)
CONTAINS
SUBROUTINE CONS (Y) ! Y is a local entity (dummy argument).
REAL C, Y
...
Y = B + C + Q + Z ! B and Q are available through host association.
... ! C is a local entity, explicitly declared.
END SUBROUTINE CONS ! is available through use association.
END PROGRAM DEMO
See Also
Use Association
Host Association
Scope for details on entities with local scope
Use Association
Use association allows the entities in a module to be accessible to other scoping units. This association
remains in effect throughout the execution of the program. The mechanism for use association is the USE
statement. The USE statement provides access to all public entities in the module, unless ONLY is specified.
In this case, only the entities named in the ONLY list can be accessed.
If an entity that is accessed by use association has the same nongeneric name as a host entity, the host
entity is inaccessible. A name that appears in the scoping unit as an external name in an EXTERNAL
statement is a global name, and any entity of the host that has this as its nongeneric name is inaccessible.
For more information on rules that apply to use association, see the USE statement.
See Also
USE statement
Host Association
Scope for details on entities with local scope
Host Association
Host association allows the entities in a host scoping unit to be accessible to an internal subprogram, a
module subprogram, or submodule program. This association remains in effect throughout the execution of
the program.
1111
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
Implicit declarations can cause problems for host association. It is recommended that you use
IMPLICIT NONE in both the host and the contained procedure, and that you explicitly declare all
entities.
When all entities are explicitly declared, local declarations override host declarations, and host
declarations that are not overridden are available in the contained procedure.
1112
Language Reference
Examples
The following example shows how a host and an internal procedure can use host-associated entities:
program INTERNAL
! shows use of internal subroutine and CONTAINS statement
real a,b,c
call find
print *, c
contains
subroutine find
read *, a,b
c = sqrt(a**2 + b**2)
end subroutine find
end
In this case, the variables a, b, and c are available to the internal subroutine find through host association.
They do not have to be passed as arguments to the internal procedure. In fact, if they are, they become local
variables to the subroutine and hide the variables declared in the host program.
Conversely, the host program knows the value of c, when it returns from the internal subroutine that has
defined c.
See Also
Use Association
Scope for details on entities with local scope
Linkage Association
Linkage association occurs between the following:
• A module variable that has the BIND attribute and the C variable with which it interoperates
• A Fortran common block and the C variable with which it interoperates
This association remains in effect throughout the execution of the program.
See Also
USE statement
Host Association
Scope for details on entities with local scope
Construct Association
Construct association establishes an association between each selector and the corresponding associate
name of an ASSOCIATE, CHANGE TEAM, SELECT RANK, or SELECT TYPE construct.
If the selector is allocatable, it must be allocated. The associate name is associated with the data object and
does not have the ALLOCATABLE attribute.
If the selector has the POINTER attribute, it must be associated. The associate name is associated with the
target of the pointer and does not have the POINTER attribute; it has the TARGET attribute if the selector is a
variable that has the POINTER or TARGET attribute.
If the selector has the ASYNCHRONOUS or VOLATILE attribute, the entity associated with the corresponding
associate name also has that attribute. If the selector is polymorphic, the associated entity has the same
dynamic type and type parameters as the selector. If the selector has the OPTIONAL attribute, it must be
present. If the selector is contiguous, the associated entity is also contiguous.
If the selector is a variable other than an array section having a vector subscript, the association is with the
data object specified by the selector; otherwise, the association is with the value of the selector expression,
which is evaluated before the execution of the block.
1113
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Each associate name remains associated with the corresponding selector throughout the execution of the
executed block. Within the block, each selector is known by, and can be accessed by, the corresponding
associate name. When the construct is terminated, the association is terminated.
See Also
USE statement
Host Association
Additional Attributes Of Associate Names
Scope for details on entities with local scope
See Also
ASSOCIATE
CHANGE TEAM and END TEAM
SELECT RANK
SELECT TYPE
Pointer Association
A pointer can be associated with a target. At different times during the execution of a program, a pointer can
be undefined, associated with different targets, or be disassociated. The initial association status of a pointer
is undefined. A pointer can become associated by the following:
• Pointer assignment (pointer => target)
The target must be associated, or specified with the TARGET attribute. If the target is allocatable, it must
be currently allocated.
• Allocation (successful execution of an ALLOCATE statement)
The ALLOCATE statement must reference the pointer.
A pointer becomes disassociated if any of the following occur:
• The pointer is nullified by a NULLIFY statement.
• The pointer is deallocated by a DEALLOCATE statement.
• The pointer is assigned a disassociated pointer or the NULL intrinsic function.
• The pointer is an ultimate component of an object of a type for which default initialization is specified for
the component and one of the following is true:
• A procedure is invoked with this object as an actual argument corresponding to a nonpointer,
nonallocatable, dummy argument with INTENT (OUT).
1114
Language Reference
• A procedure is invoked with this object as an unsaved, nonpointer, nonallocatable local object that is
not accessed by use or host association.
• This object is allocated.
When a pointer is associated with a target, the definition status of the pointer is defined or undefined,
depending on the definition status of the target. A target is undefined in the following cases:
• If it was never allocated
• If it is not deallocated through the pointer
• If a RETURN or END statement causes it to become undefined
If a pointer is associated with a definable target, the definition status of the pointer can be defined or
undefined, according to the rules for a variable.
The association status of a pointer becomes undefined when a DO CONCURRENT construct is terminated and
the pointer's association status was changed in more than one iteration of the construct.
If the association status of a pointer is disassociated or undefined, the pointer must not be referenced or
deallocated.
Whatever its association status, a pointer can always be nullified, allocated, or associated with a target.
When a pointer is nullified, it is disassociated. When a pointer is allocated, it becomes associated, but is
undefined. When a pointer is associated with a target, its association and definition status are determined by
its target.
See Also
Pointer assignments
NULL intrinsic function
Dynamic Allocation for details on the ALLOCATE, DEALLOCATE, and NULLIFY statements
Storage Association
Storage association describes the relationships that exist among data objects. It is the association of two or
more data objects that occurs when two or more storage sequences share, or are aligned with, one or more
storage units. Storage sequences are used to describe relationships among variables, common blocks, and
result variables.
See Also
Storage Units and Storage Sequence
Array Association
1115
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
BYTE 1
LOGICAL 2, 4, or 8 1
LOGICAL(1) 1
LOGICAL(2) 2
LOGICAL(4) 4
LOGICAL(8) 8
INTEGER 2, 4, or 8 1
INTEGER(1) 1
INTEGER(2) 2
INTEGER(4) 4
INTEGER(8) 8
REAL 4, 8, or 162
REAL(4) 4
DOUBLE PRECISION 8
REAL(8) 8
REAL(16) 16
COMPLEX(4) 8
DOUBLE COMPLEX 16
COMPLEX(8) 16
COMPLEX(16) 32
CHARACTER 1
CHARACTER*len len 3
CHARACTER*(*) assumed-length 4
1 Depending on default integer, LOGICAL and INTEGER can have 2, 4, or 8 bytes. The default allocation is
four bytes.
2Depending on default real, REAL can have 4, 8, or 16 bytes and COMPLEX can have 8, 16, or 32 bytes.
The default allocations are four bytes for REAL and eight bytes for COMPLEX.
3 The value of len is the number of characters specified. The largest valid value is 2**31-1 on IA-32
architecture; 2**63-1 on Intel® 64 architecture. Negative values are treated as zero.
4 The assumed-length format *(*) applies to dummy arguments, PARAMETER statements, or character
functions, and indicates that the length of the actual argument or function is used. (See Assumed-Length
Character Arguments.)
A nonpointer scalar of sequence derived type occupies a sequence of storage sequences corresponding to the
components of the structure, in the order they occur in the derived-type definition. Note that a sequence
derived type has a SEQUENCE statement.
1116
Language Reference
A pointer occupies a single unspecified storage unit that is different from that of any nonpointer object and is
different for each combination of type, type parameters, and rank.
The definition status and value of a data object affects the definition status and value of any storage-
associated entity.
When two objects occupy the same storage sequence, they are totally storage-associated. When two objects
occupy parts of the same storage sequence, they are partially associated. An EQUIVALENCE statement, a
COMMON statement, or an ENTRY statement can cause total or partial storage association of storage
sequences.
See Also
Assumed-Length Character Arguments
COMMON
ENTRY
EQUIVALENCE
Array Association
A nonpointer array occupies a sequence of contiguous storage sequences, one for each array element, in
array element order.
Two or more arrays are associated when each one is associated with the same storage location. They are
partially associated when part of the storage associated with one array is the same as part or all of the
storage associated with another array.
If arrays with different data types are associated, or partially associated, with the same storage location, and
the value of one array is defined (for example, by assignment), the value of the other array becomes
undefined. This happens because an element of an array is considered defined only if the storage associated
with it contains data of the same type as the array name.
An array element, array section, or whole array is defined by a DATA statement before program execution.
Note that the array properties must be declared in a previous specification statement. During program
execution, array elements and sections are defined by an assignment or input statement, and entire arrays
are defined by input statements.
See Also
Arrays
DATA statement
Array Elements for details on array element order
Inheritance Association
Inheritance association occurs between components of a parent component and components inherited by
type extension into an extended type.
This association is not affected by the accessibility of the inherited components.
See Also
Storage Association
Pointer Association
1117
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
Intel® Fortran fully supports features identified as deleted from or obsolescent in the Fortran Standard.
See Also
stand compiler option
1118
Language Reference
1119
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The END IF statement can no longer be a target of a GO TO statement that is outside the IF block that
ends with that END IF statement. Use a CONTINUE statement after the END IF as the target of the GO TO
statement. For example, replace:
IF ...
GO TO 100
ELSE IF ...
100 END IF
with:
IF ...
GO TO 100
ELSE IF ...
END IF
100 CONTINUE
• H edit descriptor
Replace the H edit descriptor of the form nHcharacters with "characters". Remember to double any quotes
or apostrophes in the string characters.
• PAUSE statement
The PAUSE statement displays a character string on the standard output device and then suspends
program execution until any character is typed on the standard input device. You can replace the PAUSE
statement with a WRITE statement followed by a READ statement. For example, replace:
PAUSE " don’t forget to buy milk"
with:
WRITE (6, *) " don’t forget to buy milk"
READ (5, *) ! no io-list is necessary, the input is ignored
• Real and double precision DO control variables and DO loop control expressions
REAL variables of any KIND can no longer be used as DO loop control variables and expressions. You can
replace such DO loops with the appropriate DO WHILE loop that explicitly initializes, increments, and tests
the REAL variable. For example, replace:
DO X = 0.1, 0.5, 0.01
...
END DO
with:
X = 0.1
DO WHILE (X .LE. 0.5)
...
X = X + 0.01
END DO
• Vertical format control
Formatted output to certain printing output units used to result in the first character of each record being
interpreted as controlling vertical spacing on the unit. There is no standard way to detect whether output
to such a unit should result in such vertical format control and no way to specify that it should be applied.
The effect can be achieved by post-processing a formatted file after it is created to interpret the first
character as some form of control character. This is left to the user.
Intel Fortran flags these features if you specify compiler option stand.
See Also
Obsolescent Language Features in the Fortran Standard
stand compiler option
1120
Language Reference
1121
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
The FORTRAN 66 EXTERNAL statement declares that each name in its list is an external procedure name.
Such a name can then be used as an actual argument to a subprogram, which then can use the
corresponding dummy argument in a function reference or CALL statement.
1122
Language Reference
However, when used as an argument, a complete function reference represents a value, not a subprogram
name; for example, SQRT(B) in CALL SUBR(A, SQRT(B), C). Therefore, it does not need to be defined in an
EXTERNAL statement. Note that the incomplete reference SQRT would need to be defined in an EXTERNAL
statement.
Examples
The following example, when compiled with compiler option f66, shows the FORTRAN 66 EXTERNAL
statement:
Y = SIN(X)
Y = COS(X)
Y = TAN(X)
Y = SINDEG(X)
The functions SIN and COS are examples of trigonometric functions supplied in the Fortran intrinsic
procedure library. The function TAN is also supplied in the library, but the asterisk (*) in the EXTERNAL
statement specifies that the user-supplied function be used, instead of the intrinsic function. The function
SINDEG is also a user-supplied function. Because no library function has the same name, no asterisk is
required.
See Also
f66 compiler option
1123
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
Each name c becomes a constant and is defined as the value of expression expr. Once a name is defined as a
constant, it can appear in any position in which a constant is allowed. The effect is the same as if the
constant were written there instead of the name.
The name of a constant cannot appear as part of another constant, except as the real or imaginary part of a
complex constant. For example:
PARAMETER I=3
PARAMETER M=I.25 ! Not allowed
PARAMETER N=(1.703, I) ! Allowed
The name used in the PARAMETER statement identifies only the name's corresponding constant in that
program unit. Such a name can be defined only once in PARAMETER statements within the same program
unit.
The name of a constant assumes the data type of its corresponding constant expression. The data type of a
parameter constant cannot be specified in a type declaration statement. Nor does the initial letter of the
constant's name implicitly affect its data type.
Examples
The following are valid examples of this form of the PARAMETER statement:
See Also
PARAMETER for details on compile-time constant expressions
You can use a quotation mark (") in place of an apostrophe in all the above syntax forms.
For information on the # syntax for integers not in base 10, see Integer Constants.
See Also
Binary constants
Octal constants
Hexadecimal constants
1124
Language Reference
The value must be greater than or equal to 1, and less than or equal to the maximum number of records
allowed in the file. If necessary, a record number is converted to integer data type before being used.
If this nonkeyword form is used in an I/O control list, it must immediately follow the nonkeyword form of the
io-unit specifier.
io-unit Is the number of the logical unit containing the record to be deleted.
See Also
DELETE statement
group-name Is the name of the group containing the objects to be given values.
The name must have been previously defined in a NAMELIST
statement in the scoping unit.
If more than one object=value or more than one value is specified, they must be separated by value
separators.
A value separator is any number of blanks, or a comma or slash, preceded or followed by any number of
blanks.
See Also
NAMELIST statement
1125
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Rules for Namelist Sequential READ Statements for details on namelist input
Rules for Namelist Sequential WRITE Statements for details on namelist output
Record Structures
The record structure was defined in earlier versions of Intel® Fortran as a language extension. It is still
supported, although its functionality has been replaced by Standard Fortran derived data types. Record
structures in existing code can be easily converted to Standard Fortran derived type structures for portability,
but can also be left in their old form. In most cases, an Intel Fortran record and a Standard Fortran derived
type can be used interchangeably.
Intel Fortran record structures are similar to Standard Fortran derived types.
A record structure is an aggregate entity containing one or more elements. (Record elements are also called
fields or components.) You can use records when you need to declare and operate on multi-field data
structures in your programs.
Creating a record is a two-step process:
1. You must define the form of the record with a multistatement structure declaration.
2. You must use a RECORD statement to declare the record as an entity with a name. (More than one
RECORD statement can refer to a given structure.)
Examples
Intel Fortran record structures, using only intrinsic types, easily convert to Standard Fortran derived types.
The conversion can be as simple as replacing the keyword STRUCTURE with TYPE and removing slash ( / )
marks. The following shows an example conversion:
The record structures can be used as subordinate record variables within another record, such as the
employee_data record. The equivalent Standard Fortran derived type would use the derived-type objects as
components in a similar manner, as shown below:
1126
Language Reference
See Also
RECORD Statement
Structure Declarations
A structure declaration defines the field names, types of data within fields, and order and alignment of fields
within a record. Fields and structures can be initialized, but records cannot be initialized. For more
information, see STRUCTURE.
See Also
Type Declarations
Substructure Declarations
Union Declarations
Substructure Declarations
A field within a structure can itself be a structured item composed of other fields, other structures, or both.
You can declare a substructure in two ways:
• By nesting structure declarations within other structure or union declarations (with the limitation that you
cannot refer to a structure inside itself at any level of nesting).
One or more field names must be defined in the STRUCTURE statement for the substructure, because all
fields in a structure must be named. In this case, the substructure is being used as a field within a
structure or union.
Field names within the same declaration nesting level must be unique, but an inner structure declaration
can include field names used in an outer structure declaration without conflict.
1127
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• By using a RECORD statement that specifies another previously defined record structure, thereby
including it in the structure being declared.
See the example in STRUCTURE for a sample structure declaration containing both a nested structure
declaration (TIME) and an included structure (DATE).
scalar-field-name Is the name of a data item (having a data type) defined within a
structure declaration.
Description
Records and record fields cannot be used in DATA statements, but individual fields can be initialized in the
STRUCTURE definition.
An automatic array cannot be a record field.
A scalar field reference consists of the name of a record (as specified in a RECORD statement) and zero or
more levels of aggregate field names followed by the name of a scalar field. A scalar field reference refers to
a single data item (having a data type) and can be treated like a normal reference to a Fortran variable or
array element.
You can use scalar field references in statement functions and in executable statements. However, they
cannot be used in COMMON, SAVE, NAMELIST, or EQUIVALENCE statements, or as the control variable in an
indexed DO-loop.
Type conversion rules for scalar field references are the same as those for variables and array elements.
An aggregate field reference consists of the name of a record (as specified in a RECORD statement) and zero
or more levels of aggregate field names.
You can only assign an aggregate field to another aggregate field (record = record) if the records have the
same structure. Intel® Fortran supports no other operations (such as arithmetic or comparison) on aggregate
fields.
Intel Fortran requires qualification on all levels. While some languages allow omission of aggregate field
names when there is no ambiguity as to which field is intended, Intel Fortran requires all aggregate field
names to be included in references.
1128
Language Reference
You can use aggregate field references in unformatted I/O statements; one I/O record is written no matter
how many aggregate and array name references appear in the I/O list. You cannot use aggregate field
references in formatted, namelist, and list-directed I/O statements.
You can use aggregate field references as actual arguments and record dummy arguments. The declaration
of the dummy record in the subprogram must match the form of the aggregate field reference passed by the
calling program unit; each structure must have the same number and types of fields in the same order. The
order of map fields within a union declaration is irrelevant.
Records are passed by reference. Aggregate field references are treated like normal variables. You can use
adjustable arrays in RECORD statements that are used as dummy arguments.
Examples
The following examples show record and field references. Consider the following structure declarations:
Structure DATE:
STRUCTURE /DATE/
INTEGER*1 DAY, MONTH
INTEGER*2 YEAR
STRUCTURE
Structure APPOINTMENT:
STRUCTURE /APPOINTMENT/
RECORD /DATE/ APP_DATE
STRUCTURE /TIME/ APP_TIME(2)
INTEGER*1 HOUR, MINUTE
END STRUCTURE
CHARACTER*20 APP_MEMO(4)
LOGICAL*1 APP_FLAG
END STRUCTURE
The following RECORD statement creates a variable named NEXT_APP and a 10-element array named
APP_LIST. Both the variable and each element of the array take the form of the structure APPOINTMENT.
NEXT_APP
• The field APP_DATE, a 4-byte array field in the record array APP_LIST(3):
APP_LIST(3).APP_DATE
NEXT_APP.APP_FLAG
• The first character of APP_MEMO(1), a CHARACTER*20 field of the record NEXT_APP:
NEXT_APP.APP_MEMO(1)(1:1)
1129
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
Because periods are used in record references to separate fields, you should avoid using relational
operators (.EQ., .XOR.), logical constants (.TRUE., .FALSE.), and logical expressions
(.AND., .NOT., .OR.) as field names in structure declarations. Dots can also be used instead of % to
separate fields of a derived type.
use mod
type(T2_t) :: t2
integer :: i
t2%eq%i = 0
t2%i = -10
i = -10
print *, t2.eq.i, (t2).eq.i
end
In this case, the reference "t2.eq.i" prints 0. The reference "(t2).eq.i" will invoke eq_func and will print -10.
See Also
RECORD statement
STRUCTURE
for details on structure declarations
UNION
for details on UNION and MAP statements
Aggregate Assignment
For aggregate assignment statements, the variable and expression must have the same structure as the
aggregate they reference.
The aggregate assignment statement assigns the value of each field of the aggregate on the right of an equal
sign to the corresponding field of the aggregate on the left. Both aggregates must be declared with the same
structure.
1130
Additional Character Sets
Examples
The following example shows valid aggregate assignments:
STRUCTURE /DATE/
INTEGER*1 DAY, MONTH
INTEGER*2 YEAR
END STRUCTURE
DO I = 1,7
CALL GET_DATE (TODAY)
THIS_WEEK(I) = TODAY
THIS_WEEK(I).DAY = TODAY.DAY + 1
END DO
MEETING.APP_DATE = TODAY
See Also
Character Sets for details on the Standard Fortran character set
1131
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1132
Language Reference
1133
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1134
Language Reference
1135
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1136
Data Representation Models
SI Shift In SP Space
The remaining half of each column identifies the character by the binary value of the byte; the value is stated
in three radixes—octal, decimal, and hexadecimal. For example, the uppercase letter A has, under ASCII
conventions, a storage value of hexadecimal 41 (a bit configuration of 01000001), equivalent to 101 in octal
notation and 65 in decimal notation.
1137
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
For more information on the range of values for each data type (and kind), see Data and I/O in the Compiler
Reference.
1138
Language Reference
The following example shows the general integer model for i = -20 using a base (r) of 2:
emin emax
1139
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The following example shows the general real model for x = 20.0 using a base (b) of 2:
See Also
BIT_SIZE
1140
Library Modules and Run-Time Library Routines
IFWINTY Defines Fortran parameter constants and derived data types for
use with Windows APIs
NOTE
The same routine name may appear in different modules. These routines may have different
semantics, so be careful you are using the module that contains the routine that will produce the
results you want.
1141
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• Routines that help you write programs for graphics, QuickWin, and other applications (in modules
IFQWIN, IFLOGM, and IFCORE):
• QuickWin routines (W*S)
• Graphics routines (W*S)
• Dialog routines (W*S)
• Miscellaneous run-time routines
• Routines systems that help you write programs using Component Object Model (COM) and Automation
servers (in modules IFCOM and IFAUTO):
• COM routines (W*S)
• AUTO routines (W*S)
• Portability routines that help you port your programs to or from other systems, or help you perform basic
I/O to serial ports on Windows* systems (in module IFPORT).
• National Language Support routines that help you write foreign language programs for international
markets (in module IFNLS). These routines are only available on Windows* systems.
• POSIX routines that help you write Fortran programs that comply with the POSIX* Standard (in module
IFPOSIX).
• ESTABLISHQQ lets you specify a routine to handle Run-Time Library (RTL) errors (in module
IFESTABLISH).
• FOR__SET_FTN_ALLOC lets you specify a user-defined routine to dynamically allocate commons. The
caller of FOR__SET_FTN_ALLOC must include module IFCOMMONALLOC.
When you include the statement USE module-name in your program, these library routines are automatically
linked to your program if called.
You can restrict what is accessed from a USE module by adding ONLY clauses to the USE statement.
NOTE
The same routine name may appear in different modules. These routines may have different
semantics, so be careful you are using the module that contains the routine that will produce the
results you want.
See Also
USE
1142
Language Reference
All the formatting routines return the number of bytes in the formatted string (not the number of
characters, which can vary if multibyte characters are included). If the output string is longer than the
formatted string, the output string is blank padded. If the output string is shorter than the formatted
string, an error occurs, NLS$ErrorInsufficientBuffer is returned, and nothing is written to the output
string.
• Multibyte Character Set (MBCS) routines for using multi-byte characters
Examples of multibyte character sets are Japanese, Korean, and Chinese.
• The MBCS inquiry routines provide information on the maximum length of multibyte characters, the
length, number and position of multibyte characters in strings, and whether a multibyte character is a
leading or trailing byte. These routines are summarized in the following table. The NLS library provides
a parameter, MBLenMax, defined in the NLS module to be the longest length (in bytes) of any
character, in any codepage. This parameter can be useful in comparisons and tests. To determine the
maximum character length of the current codepage, use the MBCurMax function.
• There are four MBCS conversion routines. Two convert Japan Industry Standard (JIS) characters to
Microsoft Kanji characters or vice versa. Two convert between a codepage multibyte character string
and a Unicode string.
• There are several MBCS Fortran equivalent routines. They are the exact equivalents of Fortran intrinsic
routines except that the MBCS equivalents allow character strings to contain multibyte characters.
Examples
The following example uses Locale Setting and Inquiry routines:
USE IFNLS
INTEGER(4) strlen, status
CHARACTER(40) str
strlen = NLSGetLocaleInfo(NLS$LI_SDAYNAME1, str)
print *, str ! prints Monday
strlen = NLSGetLocaleInfo(NLS$LI_SDAYNAME2, str)
print *, str ! prints Tuesday
strlen = NLSGetLocaleInfo(NLS$LI_SDAYNAME3, str)
print *, str ! prints Wednesday
! Change locale to Spanish, Mexico
status = NLSSetLocale("Spanish", "Mexico")
strlen = NLSGetLocaleInfo(NLS$LI_SDAYNAME1, str)
print *, str ! prints lunes
strlen = NLSGetLocaleInfo(NLS$LI_SDAYNAME2, str)
print *, str ! prints martes
strlen = NLSGetLocaleInfo(NLS$LI_SDAYNAME3, str)
print *, str ! prints miércoles
END
The following example uses NLS Formatting routines:
USE IFNLS
INTEGER(4) strlen, status
CHARACTER(40) str
strlen = NLSFormatTime(str)
print *, str ! prints 11:42:24 AM
strlen = NLSFormatDate(str, flags= NLS$LongDate)
print *, str ! prints Friday, July 14, 2000
status = NLSSetLocale ("Spanish", "Mexico")
strlen = NLSFormatTime(str)
print *, str ! prints 11:42:24
print *, str ! prints viernes 14 de julio de 2000
1143
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The following example uses Multibyte Character Set (MBCS) inquiry routines:
USE IFNLS
CHARACTER(4) str
INTEGER status
status = NLSSetLocale ("Japan")
str = " ·, " ¿"
PRINT '(1X,''String by char = '',\)'
DO i = 1, len(str)
PRINT '(A2,\)',str(i:i)
END DO
PRINT '(/,1X,''MBLead = '',\)'
DO i = 1, len(str)
PRINT '(L2,\)',mblead(str(i:i))
END DO
PRINT '(/,1X,''String as whole = '',A,\)',str
PRINT '(/,1X,''MBStrLead = '',\)'
DO i = 1, len(str)
PRINT '(L1,\)',MBStrLead(str,i)
END DO
END
This code produces the following output for str = · , " ¿
The following example uses Multibyte Character Set (MBCS) Fortran equivalent routines:
USE IFNLS
INTEGER(4) i, len(7), infotype(7)
CHARACTER(10) str(7)
LOGICAL(4) log4
data infotype / NLS$LI_SDAYNAME1, NLS$LI_SDAYNAME2, &
& NLS$LI_SDAYNAME3, NLS$LI_SDAYNAME4, &
& NLS$LI_SDAYNAME5, NLS$LI_SDAYNAME6, &
& NLS$LI_SDAYNAME7 /
WRITE(*,*) 'NLSGetLocaleInfo'
WRITE(*,*) '----------------'
WRITE(*,*) ' '
WRITE(*,*) 'Getting the names of the days of the week...'
DO i = 1, 7
len(i) = NLSGetLocaleInfo(infotype(i), str(i))
WRITE(*, 11) 'len/str/hex = ', len(i), str(i), str(i)
END DO
11 FORMAT (1X, A, I2, 2X, A10, 2X, '[', Z20, ']')
WRITE(*,*) ' '
WRITE(*,*) 'Lexically comparing the names of the days...'
DO i = 1, 6
log4 = MBLGE(str(i), str(i+1), NLS$IgnoreCase)
WRITE(*, 12) 'Is day ', i, ' GT day ', i+1, '? Answer = ', log4
END DO
12 FORMAT (1X, A, I1, A, I1, A, L1)
1144
Language Reference
See Also
National Language Support Library Routines
Standard Fortran Routines That Handle MBCS Characters
USE
1145
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Because Fortran uses character lengths instead of NULLs to indicate the length of a string, some functions
work solely from the length of the string, and not with the contents of the string. This function works as
usual on strings containing MBCS characters, and include:
REPEAT (string, ncopies)
1146
Language Reference
• When used with direct files, after an FSEEK, GETC, or PUTC operation, the record number is the number
of the next whole record. Any subsequent normal Fortran I/O to that unit occurs at the next whole record.
For example, if you seek to absolute location 1 of a file whose record length is 10, the NEXTREC returned
by an INQUIRE would be 2. If you seek to absolute location 10, NEXTREC would still return 2.
• On units with CARRIAGECONTROL='FORTRAN' (the default), PUTC and FPUTC characters are treated as
carriage control characters if they appear in column 1.
• On sequentially formatted units, the C string "\n"c, which represents the carriage return/line feed escape
sequence, is written as CHAR(13) (carriage return) and CHAR(10) (line feed), instead of just line feed, or
CHAR(10). On input, the sequence 13 followed by 10 is returned as just 10. (The length of character
string "\n"c is 1 character, whose ASCII value, indicated by ICHAR('\n'c), is 10.)
• Reading and writing is in a raw form for direct files. Separators between records can be read and
overwritten. Therefore, be careful if you continue using the file as a direct file.
I/O errors arising from the use of these routines result in an Intel® Fortran run-time error.
Some portability file I/O routines have equivalents in Standard Fortran. For example, you could use the
ACCESS function to check a file specified by name for accessibility according to mode. It tests a file for read,
write, or execute permission, as well as checking to see if the file exists. It works on the file attributes as
they exist on disk, not as a program's OPEN statement specifies them.
Instead of ACCESS, you can use the INQUIRE statement with the ACTION specifier to check for similar
information. (The ACCESS function always returns 0 for read permission on FAT files, meaning that all files
have read permission.)
IERRNO is updated only when an error occurs. For example, if a call to the GETC function results in an error,
but two subsequent calls to PUTC succeed, a call to IERRNO returns the error for the GETC call. Examine
IERRNO immediately after returning from one of the portability library routines. Other Standard Fortran
routines might also change the value to an undefined value.
If your application uses multithreading, remember that IERRNO is set on a per-thread basis.
1147
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Additional Routines
You can also use portability routines for program call and control, keyboards and speakers, file management,
arrays, floating-point inquiry and control, IEEE* functionality, and other miscellaneous uses.
NOTE
On Windows* systems, all portability routines that take path names also accept long file names or
UNC (Universal Naming Convention) file names. A forward slash in a path name is treated as a
backslash. All path names can contain drive specifications as well as MBCS (multiple-byte character
set) characters.
See Also
Portability Routines
Overview of Serial Port I/O Routines
USE IFPORT
The USE IFPORTstatement includes the routine definitions in the compilation. You may also need to add a
USE IFWINTY statement to your program because some Windows* constants may be required that are
typically defined in the IFWINTY module.
Many arguments are optional. If a constant is used where an argument is both input and output, a probe for
writeability is done before the output. Thus, in many cases, a constant may be used without creating a
temporary variable. It should be noted, however, that doing so may not be compatible with all Fortran
implementations.
1148
Language Reference
See Also
Portability Routines for a list of the SPORT routines
1149
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
LOGICAL*4 REAL*4
LOGICAL*8 REAL*8
See Also
Intrinsic Data Types
1150
Language Reference
1151
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1152
Language Reference
1153
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
E to I
EOF HMOD IIDNNT IMVBITS
J to P
JFIX JISIGN KIBSET KMOD
1154
Language Reference
Q to Z
QABS QCOSH QNINT SIZEOF
1155
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
A to Z Reference
This section contains the following:
• Language Summary Tables
This section organizes the Fortran functions, subroutines, and statements by the operations they perform.
You can use the tables to locate a particular routine for a particular task.
• The descriptions of all Fortran statements, intrinsics, directives, and module library routines, which are
listed in alphabetical order.
In the description of routines, pointers and handles are INTEGER(4) on IA-32 architecture and
INTEGER(8) on Intel® 64 architecture.
The Fortran compiler understands statements and intrinsic functions in your program without any additional
information, such as that provided in modules.
However, modules must be included in programs that contain the following routines:
• Quickwin routines and graphics routines (W*S)
These routines require a USE IFQWIN statement to include the library and graphics modules.
• Portability routines
It is recommended that you specify USE IFPORT when accessing routines in the portability library.
• Serial port I/O routines
These routines require a USE IFPORT statement to access the portability library. These routines are only
available on Windows* systems.
• NLS routines (W*S)
These routines require a USE IFNLS statement to access the NLS library.
• POSIX* routines
These routines require a USE IFPOSIX statement to access the POSIX library.
• Dialog routines (W*S)
1156
Language Reference
These routines require a USE IFLOGM statement to access the dialog library.
• Component Object Module (COM) routines (W*S)
These routines require a USE IFCOM statement to access the COM library.
• Automation server routines (W*S)
These routines require a USE IFAUTO statement to access the AUTO library.
• Miscellaneous Run-Time Routines
Most of these routines require a USE IFCORE statement to obtain the proper interfaces.
Whenever required, these USE module statements are prominent in the A to Z Reference.
In addition to the appropriate USE statement, for some routines you must specify the types of libraries to be
used when linking.
Name Description
1157
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Name Description
1158
Language Reference
Name Description
1159
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Compiler Directives
The following tables list available compiler directives.
Each OpenMP* Fortran directive name is preceded by the prefix c$OMP, where c is one of the following: !, C
(or c), or *; for example, !$OMP ATOMIC.
Compiler directives are specially formatted comments in the source file that provide information to the
compiler. Some directives, such as line length or conditional compilation directives, provide the compiler
information that is used in interpreting the source file. Other directives, such as optimization directives,
provide hints or suggestions to the compiler, which, in some cases, may be ignored or overridden by the
compiler, based on the heuristics of the optimizer and/or code generator. If the directive is ignored by the
compiler, no diagnostic message is issued.
You do not need to specify a compiler option to enable general directives.
Some directives may perform differently on Intel® microprocessors than on non-Intel microprocessors.
General Directives
Name Description
1160
Language Reference
Name Description
LOOP COUNT Specifies the typical trip loop count for a DO loop;
which assists the optimizer.
1161
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Name Description
Name Description
1162
Language Reference
Name Description
1163
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Name Description
1164
Language Reference
Name Description
1165
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Name Description
TARGET TEAMS DISTRIBUTE PARALLEL DO Creates a device data environment and then
executes the construct on that device. It also
specifies a loop that can be executed in parallel by
multiple threads that are members of multiple
teams created by a TEAMS construct.
TARGET TEAMS DISTRIBUTE PARALLEL DO SIMD Creates a device data environment and then
executes the construct on that device. It also
specifies a loop that can be executed in parallel by
multiple threads that are members of multiple
teams created by a TEAMS construct. The loop will
be distributed across the teams, which will be
executed concurrently using SIMD instructions.
TARGET TEAMS DISTRIBUTE SIMD Creates a device data environment and executes
the construct on the same device. It also specifies
that loop iterations will be shared among the
1166
Language Reference
Name Description
TARGET UPDATE Makes the list items in the device data environment
consistent with their corresponding original list
items.
1167
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Name Description
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
See Also
qopenmp, Qopenmp compiler option
1168
Language Reference
Name Description
1169
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Name Description
Name Description
1170
Language Reference
Name Description
RADIX Returns the base for data of the same type as the
argument.
1171
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The portability routines RANF, RANDOM, and SEED also supply this functionality.
Atomic Operation
Name Procedure Type Description
1172
Language Reference
Collective Operation
Name Procedure Type Description
The portability routines GETDAT, GETTIM, SETDAT, and SETTIM also supply this functionality.
1173
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Name Description
1174
Language Reference
Name Description
1175
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Name Description
Name Description
1176
Language Reference
Name Description
NOTE
Many routines in the LIBM library (Math Library) are more highly optimized for Intel® microprocessors
than for non-Intel microprocessors.
Name Description
1177
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Name Description
1178
Language Reference
Name Description
1179
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Name Description
Name Description
1180
Language Reference
Name Description
RADIX Returns the base for data of the same type as the
argument.
Name Description
1181
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Name Description
1182
Language Reference
Bit Representation
Name Procedure Type Description
1183
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1184
Language Reference
1185
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1186
Language Reference
1187
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1188
Language Reference
1189
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Process Control
Name Procedure Type Description
1190
Language Reference
1191
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1192
Language Reference
1193
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Error Handling
Name Procedure Type Description
Program Control
Name Procedure Type Description
1194
Language Reference
Speaker
Name Procedure Type Description
File Management
Name Procedure Type Description
1195
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Arrays
Name Procedure Type Description
IEEE Functionality
Name Procedure Type Description
1196
Language Reference
1197
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Miscellaneous
Name Procedure Type Description
1198
Language Reference
MBLGE, MBLGT, MBLLE, Function Same as LGE, LGT, LLE, and LLT,
MBLLT,MBLEQ, MBLNE and the logical operators .EQ.
and .NE., except that multibyte
characters can be included in
their arguments.
1199
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Name Description
1200
Language Reference
Name Description
1201
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Name Description
1202
Language Reference
Name Description
1203
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Name Description
PXFUMASK Sets a new file creation mask and gets the previous
one.
1204
Language Reference
Name Description
1205
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Additional Documentation: Creating Fortran Applications that Use Windows* OS Features
1206
Language Reference
1207
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1208
Language Reference
A to B
This section describes language features that start with A or B.
1209
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
A to B
ABORT
Portability Subroutine: Flushes and closes I/O
buffers, and terminates program execution.
Module
USE IFPORT
Syntax
CALL ABORT[string]
This subroutine causes the program to terminate and an exit code value of 134 is returned to the program
that launched it.
Example
USE IFPORT
!The following prints "abort: Fortran Abort Called"
CALL ABORT
!The following prints "abort: Out of here!"
Call ABORT ("Out of here!")
See Also
EXIT
STOP
ABOUTBOXQQ (W*S)
QuickWin Function: Specifies the information
displayed in the message box that appears when the
user selects the About command from a QuickWin
application's Help menu.
Module
USE IFQWIN
Syntax
result=ABOUTBOXQQ(cstring)
Results
The value of the result is INTEGER(4). It is zero if successful; otherwise, nonzero.
If your program does not call ABOUTBOXQQ, the QuickWin run-time library supplies a default string.
1210
Language Reference
Example
USE IFQWIN
INTEGER(4) dummy
! Set the About box message
dummy = ABOUTBOXQQ ('Matrix Multiplier\r Version 1.0'C)
ABS
Elemental Intrinsic Function (Generic): Computes
an absolute value.
Syntax
result=ABS(a)
Results
The result has the same type and kind type parameter as a except if a is complex value, the result type is
real. If a is an integer or real value, the value of the result is | a |; if a is a complex value (X, Y), the result is
the real value SQRT (X**2 + Y**2).
Example
ABS (-7.4) has the value 7.4.
ABS ((6.0, 8.0)) has the value 10.0.
1211
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The following ABS.F90 program calculates two square roots, retaining the sign:
ABSTRACT INTERFACE
Statement: Defines an abstract interface.
Syntax
ABSTRACT INTERFACE
[interface-body]...
END INTERFACE
Description
An abstract interface block defines an interface whose name can be used in a PROCEDURE declaration
statement to declare subprograms with identical arguments and characteristics.
An abstract interface block cannot contain a PROCEDURE statement or a MODULE PROCEDURE statement.
Interface blocks can appear in the specification part of the program unit that invokes the external or dummy
procedure.
An interface block must not appear in a block data program unit.
An interface block comprises its own scoping unit, and does not inherit anything from its host through host
association.
The function or subroutine named in the interface-body cannot have the same name as a keyword that
specifies an intrinsic type.
To make an interface block available to multiple program units (through a USE statement), place the
interface block in a module.
Example
Previously, within an interface block, you needed to individually declare subroutines and functions that had
the same argument keywords and characteristics. For example:
INTERFACE
SUBROUTINE SUB_ONE (X)
REAL, INTENT(IN) :: X
END SUBROUTINE SUB_ONE
1212
Language Reference
ABSTRACT INTERFACE
SUBROUTINE TEMPLATE (X)
REAL, INTENT(IN) :: X
END SUBROUTINE TEMPLATE
END INTERFACE
You can then use the subprogram in the abstract interface as a template in a PROCEDURE statement to
declare procedures. For example:
See Also
INTERFACE
PROCEDURE
FUNCTION
SUBROUTINE
Procedure Interfaces
Use and Host Association
ACCEPT
Statement: Transfers input data.
Syntax
Formatted:
ACCEPT form[,io-list]
Formatted - List-Directed:
ACCEPT *[,io-list]
Formatted - Namelist:
ACCEPT nml
The ACCEPT statement is the same as a formatted, sequential READ statement, except that an ACCEPT
statement must never be connected to user-specified I/O units. You can override this restriction by using
environment variable FOR_ACCEPT.
1213
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
In the following example, character data is read from the implicit unit and binary values are assigned to each
of the five elements of array CHARAR:
CHARACTER*10 CHARAR(5)
ACCEPT 200, CHARAR
200 FORMAT (5A10)
ACCESS Function
Portability Function: Determines if a file exists and
how it can be accessed.
Module
USE IFPORT
Syntax
result = ACCESS(name,mode)
Character Meaning
Results
The value of the result is INTEGER(4). It is zero if all inquiries specified by mode are true. If either argument
is invalid, or if the file cannot be accessed in all of the modes specified, one of the following error codes is
returned:
• EACCES: Access denied; the file's permission setting does not allow the specified access
• EINVAL: The mode argument is invalid
• ENOENT: File or path not found
For a list of error codes, see IERRNO.
The name argument can contain either forward or backward slashes for path separators.
1214
Language Reference
On Windows* systems, all files are readable. A test for read permission always returns 0.
Example
use ifport
! checks for read and write permission on the file "DATAFILE.TXT"
J = ACCESS ("DATAFILE.TXT", "rw")
PRINT *, J
! checks whether "DATAFILE.TXT" is executable. It is not, since
! it does not end in .COM, .EXE, .BAT, or .CMD
J = ACCESS ("DATAFILE.TXT","x")
PRINT *, J
See Also
INQUIRE
GETFILEINFOQQ
ACHAR
Elemental Intrinsic Function (Generic): Returns
the character in a specified position of the ASCII
character set, even if the processor's default character
set is different. It is the inverse of the IACHAR
function. In Intel® Fortran, ACHAR is equivalent to the
CHAR function.
Syntax
result = ACHAR (i [, kind])
Results
The result type is character with length 1. If kind is present, the kind parameter of the result is that
specified by kind; otherwise, the kind parameter of the result is that of default character. If the processor
cannot represent the result value in the kind of the result, the result is undefined.
If i has a value within the range 0 to 127, the result is the character in position i of the ASCII character set;
otherwise, it is processor defined. ACHAR (IACHAR(C)) has the value C for any character C capable of
representation in the default character set. For a complete list of ASCII character codes, see Character and
Key Code Charts.
Example
ACHAR (71) has the value 'G'.
See Also
CHAR
IACHAR
ICHAR
1215
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
ACOS
Elemental Intrinsic Function (Generic): Produces
the arccosine of x.
Syntax
result = ACOS (x)
Results
The result type and kind are the same as x and is expressed in radians.
If the result is real, the value is expressed in radians and lies in the range 0 <= ACOS(X) <= pi.
If the result is complex, the real part is expressed in radians and lies in the range 0 <= REAL(ACOS (x)) <=
pi.
Example
ACOS (0.68032123) has the value .8225955.
ACOSD
Elemental Intrinsic Function (Generic): Produces
the arccosine of x.
Syntax
result = ACOSD (x)
Results
The result type and kind are the same as x and are expressed in degrees. The value lies in the range −90 to
90 degrees.
1216
Language Reference
Example
ACOSD (0.886579) has the value 27.55354.
ACOSH
Elemental Intrinsic Function (Generic): Produces
the hyperbolic arccosine of x.
Syntax
result = ACOSH (x)
Results
The result type and kind are the same as x.
If the result is complex, the real part is non-negative, and the imaginary part is expressed in radians and lies
in the range -pi <= AIMAG (ACOSH (x)) <= pi.
Example
ACOSH (1.0) has the value 0.0.
ACOSH (180.0) has the value 5.8861.
ADJUSTL
Elemental Intrinsic Function (Generic): Adjusts a
character string to the left, removing leading blanks
and inserting trailing blanks.
Syntax
result = ADJUSTL (string)
Results
The result type is character with the same length and kind parameter as string. The value of the result is the
same as string, except that any leading blanks have been removed and inserted as trailing blanks.
Example
CHARACTER(16) STRING
STRING= ADJUSTL(' Fortran 90 ') ! returns 'Fortran 90 '
1217
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
ADJUSTR
ADJUSTR
Elemental Intrinsic Function (Generic): Adjusts a
character string to the right, removing trailing blanks
and inserting leading blanks.
Syntax
result = ADJUSTR (string)
Results
The result type is character with the same length and kind parameter as string.
The value of the result is the same as string, except that any trailing blanks have been removed and inserted
as leading blanks.
Example
CHARACTER(16) STRING
STRING= ADJUSTR(' Fortran 90 ') ! returns ' Fortran 90'
See Also
ADJUSTL
AIMAG
Elemental Intrinsic Function (Generic): Returns
the imaginary part of a complex number. This function
can also be specified as IMAG.
Syntax
result = AIMAG (z)
Results
The result type is real with the same kind parameter as z. If z has the value (x, y), the result has the value y.
1218
Language Reference
Example
AIMAG ((4.0, 5.0)) has the value 5.0.
If C is complex, C%IM is the same as AIMAG (C).
The program AIMAG.F90 applies the quadratic formula to a polynomial and allows for complex results:
REAL a, b, c
COMPLEX ans1, ans2, d
WRITE ( *, 100)
100 FORMAT (' Enter A, b, and c of the ', &
'polynomial ax**2 + bx + c: '\)
READ (*, *) a, b, c
d = CSQRT (CMPLX (b**2 - 4.0*a*c)) ! d is either:
! 0.0 + i root, or
! root + i 0.0
ans1 = (-b + d) / (2.0 * a)
ans2 = (-b + d) / (2.0 * a)
WRITE (*, 200)
200 FORMAT (/ ' The roots are:' /)
WRITE (*, 300) REAL(ans1), AIMAG(ans1), &
REAL(ans2), AIMAG(ans2)
300 FORMAT (' X = ', F10.5, ' + i', F10.5)
END
See Also
CONJG
DBLE
AINT
Elemental Intrinsic Function (Generic): Truncates
a value to a whole number.
Syntax
result = AINT (a [,kind])
Results
The result type is real. If kind is present, the kind parameter of the result is that specified by kind;
otherwise, the kind parameter is that of a.
The result is defined as the largest integer whose magnitude does not exceed the magnitude of a and whose
sign is the same as that of a. If | a | is less than 1, AINT( a) has the value zero.
1219
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
AINT (3.678) has the value 3.0.
AINT (-1.375) has the value -1.0.
REAL r1, r2
REAL(8) r3(2)
r1 = AINT(2.6) ! returns the value 2.0
r2 = AINT(-2.6) ! returns the value -2.0
r3 = AINT((/1.3, 1.9/), KIND = 8) ! returns the values
! (1.0D0, 1.0D0)
See Also
ANINT
ALARM
Portability Function: Causes a subroutine to begin
execution after a specified amount of time has
elapsed.
Module
USE IFPORT
Syntax
result = ALARM (time,proc)
time (Input) Integer. Specifies the time delay, in seconds, between the call
to ALARM and the time when proc is to begin execution. If time is 0,
the alarm is turned off and no routine is called.
Results
The return value is INTEGER(4). It is zero if no alarm is pending. If an alarm is pending (has already been
set by a previous call to ALARM), it returns the number of seconds remaining until the previously set alarm is
to go off, rounded up to the nearest second.
After ALARM is called and the timer starts, the calling program continues for time seconds. The calling
program then suspends and calls proc, which runs in another thread. When proc finishes, the alarm thread
terminates, the original thread resumes, and the calling program resets the alarm. Once the alarm goes off,
it is disabled until set again.
If proc performs I/O or otherwise uses the Fortran library, you need to compile it with one of the multithread
libraries.
The thread that proc runs in has a higher priority than any other thread in the process. All other threads are
essentially suspended until proc terminates, or is blocked on some other event, such as I/O.
No alarms can occur after the main process ends. If the main program finishes or any thread executes an
EXIT call, than any pending alarm is deactivated before it has a chance to run.
Example
USE IFPORT
INTEGER(4) numsec, istat
EXTERNAL subprog
1220
Language Reference
numsec = 4
write *, "subprog will begin in ", numsec, " seconds"
ISTAT = ALARM (numsec, subprog)
See Also
RUNQQ
ALIAS Directive
General Compiler Directive: Declares alternate
external names for external subprograms.
Syntax
!DIR$ ALIAS internal-name,external-name
internal-name The name of the entity as used in the current program unit. It can be
a procedure name, a COMMON block name, a module variable that is
initialized, or a PARAMETER in a module. It may not be the name of an
internal procedure.
If a name is specified, the name (in uppercase) is used as the external name for the specified internal-name.
If a character constant is specified, it is used as is; the string is not changed to uppercase, nor are blanks
removed.
The ALIAS directive affects only the external name used for references to the specified internal-name.
Names that are not acceptable to the linker will cause link-time errors.
See Also
ATTRIBUTES ALIAS
ATTRIBUTES DECORATE
ATTRIBUTES DEFAULT
General Compiler Directives
Syntax Rules for Compiler Directives
ALIGNED Clause
Parallel Directive Clause: Specifies that all variables
in a list are aligned.
Syntax
ALIGNED (list [:n])
list Is the name of one or more variables. Each name must be separated
by a comma. Any variable that appears in list cannot appear in more
than one ALIGNED clause.
1221
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The ALIGNED clause declares that the location of each list item is aligned to the number of bytes expressed
in the optional alignment parameter n of the ALIGNED clause. If a list item has the ALLOCATABLE attribute,
its allocation status must be allocated. If it has the POINTER attribute, its association status must be
associated. If the type of a list item is type(C_PTR) or a Cray pointer, the item must be defined.
NOTE
Be careful when using the ALIGNED clause. Instructing the compiler to implement all array references
with aligned data movement instructions will cause a runtime exception if some of the access patterns
are actually unaligned.
ALL
Transformational Intrinsic Function (Generic):
Determines if all values are true in an entire array or
in a specified dimension of an array.
Syntax
result = ALL (mask)
result = ALL (mask, dim)
Results
The result is an array or a scalar of type logical.
The result is a scalar if dim is not specified or mask has rank one. A scalar result is true only if all elements
of mask are true, or mask has size zero. The result has the value false if any element of mask is false.
An array result has the same type and kind parameters as mask, and a rank that is one less than mask. Its
shape is (d1, d2, ..., ddim-1, ddim+1, ..., dn), where (d1, d2,..., dn) is the shape of mask.
Each element in an array result is true only if all elements in the one dimensional array defined by mask(s1,
s2, ..., sdim-1, :, sdim+1, ..., sn) are true.
Example
LOGICAL mask( 2, 3), AR1(3), AR2(2)
mask = RESHAPE((/.TRUE., .TRUE., .FALSE., .TRUE., .FALSE., &
.FALSE./),(/2,3/))
! mask is true false false
! true true false
AR1 = ALL(mask,DIM = 1) ! evaluates the elements column by
! column yielding [true false false]
AR2 = ALL(mask,DIM = 2) ! evaluates the elements row by row
! yielding [false false].
ALL ((/.TRUE., .FALSE., .TRUE./)) has the value false because some elements of MASK are not true.
ALL ((/.TRUE., .TRUE., .TRUE./)) has the value true because all elements of MASK are true.
A is the array
[ 1 5 7 ]
[ 3 6 8 ]
1222
Language Reference
[ 0 5 7 ]
[ 2 6 9 ].
ALL (A .EQ. B, DIM=1) tests to see if all elements in each column of A are equal to the elements in the
corresponding column of B. The result has the value (false, true, false) because only the second column has
elements that are all equal.
ALL (A .EQ. B, DIM=2) tests to see if all elements in each row of A are equal to the elements in the
corresponding row of B. The result has the value (false, false) because each row has some elements that are
not equal.
See Also
ANY
COUNT
ALLOCATABLE
Statement and Attribute: Specifies that an object is
allocatable. The shape of an allocatable array is
determined when an ALLOCATE statement is
executed, dynamically allocating space for the array. A
character object may have a deferred length that is
determined when the object is allocated with an
ALLOCATE statement. A allocatable scalar object of
any type may be allocated with an ALLOCATE
statement.
Syntax
The ALLOCATABLE attribute can be specified in a type declaration statement or an ALLOCATABLE statement,
and takes one of the following forms:
Type Declaration Statement:
type, [att-ls,] ALLOCATABLE [, att-ls] :: a[(d-spec)] [[coarray-spec]][, a[(d-spec)]
[[coarray-spec]]...
Statement:
ALLOCATABLE [::] a[(d-spec)] [[coarray-spec]][, a[(d-spec)] [[coarray-spec]]...
Description
A character object declaration uses LEN=: to indicate it is deferred length.
If the array is given the DIMENSION attribute elsewhere in the program, it must be declared as a deferred-
shape array.
1223
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
When the allocatable object is no longer needed, it can be deallocated by execution of a DEALLOCATE
statement.
An allocatable object cannot be specified in a COMMON, EQUIVALENCE, DATA, or NAMELIST statement.
Allocatable objects are not saved by default. If you want to retain the values of an allocatable object across
procedure calls, you must specify the SAVE attribute for the object.
Example
! Method for declaring and allocating objects.
REAL A, B(:)
ALLOCATABLE :: A(:,:), B
See Also
Type Declarations
Compatible attributes
ALLOCATE
DEALLOCATE
Arrays
Allocation of Allocatable Arrays
SAVE
ALLOCATE Clause
Directive Clause: Specifies the memory allocator to
be used for one or more private variables or common
blocks of a construct. This feature is only available for
ifx.
Syntax
ALLOCATE ([allocator :] list)
-or-
ALLOCATE (allocator-modifier [, allocator-modifier] : list)
1224
Language Reference
Each list item must appear in a data sharing clause that creates a private copy of the list item in the directive
containing the ALLOCATE clause. The storage for the private copies of an object specified in the list are
allocated using the specified memory allocator.
An ALLOCATE clause in a TARGET directive or a directive within a TARGET region must specify an allocator
expression unless a REQUIRES directive with the DYNAMIC_ALLOCATORS clause appears in the same
compilation unit.
The result of allocating private variables with a memory allocator whose access trait is set to THREAD by a
TASK, TASKLOOP, or TARGET directive is undefined.
See Also
ALLOCATE Directive
OpenMP* Memory Spaces and Allocators
ALLOCATE Directive
OpenMP* Fortran Compiler Directive: Specifies
memory allocators to use for object allocation and
deallocation. This feature is only available for ifx.
Syntax
!$OMP ALLOCATE (list) [clause [[,] clause]...]
1225
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
-or-
!$OMP ALLOCATE [(list)] [clause [[,] clause]...]
[!$OMP ALLOCATE (list) [clause [[,] clause]...]
[...]]
ALLOCATE statement
• ALLOCATOR (allocator)
allocator is an integer expression with a kind type of
omp_allocator_handle_kind.
If the ALLOCATOR clause is not specified, the list items in that
directive will be allocated using the allocator specified by the def-
allocator-var internal control variable (ICV).
At most one ALLOCATOR clause is permitted in the ALLOCATE
directive.
• ALIGN (alignment)
alignment is a positive integer scalar expression with a value that
is a positive power of two.
Each list item is allocated with a byte alignment of at least the
maximum of the following:
1.The required alignment specified by Fortran
2.The alignment trait of the specified allocator
3.The alignment value specified by the ALIGN clause
If the ALIGN clause is not specified, each list item is allocated with
a byte alignment of at least the maximum of the following:
1.The required alignment specified by Fortran
2.The alignment trait of the specified allocator
At most one ALIGN clause is permitted in the ALLOCATE directive.
The first form of the directive is not associated with an ALLOCATE statement. It is a declarative directive and
must appear in the specification part where the list items are declared, and after all declarations of the list
items. The storage for each list item will be allocated by the specified memory allocator and deallocated by
the same memory allocator when the list item goes out of scope.
The list items in a declarative ALLOCATE directive must not have the POINTER or ALLOCATABLE attribute. If a
list item has the SAVE attribute (implicitly or explicitly), is a common block name, or is declared in the scope
of a module or submodule, then the specified allocator must be one of the pre-defined memory allocators.
The list items in a declarative ALLOCATE directive cannot be an array element, a structure component, or a
variable in a common block. The declaration of all list items must be in the same scope as the declarative
ALLOCATE directive and must precede the ALLOCATE directive.
A list item may appear once in a declarative ALLOCATE directive and it may appear in only one declarative
ALLOCATE directive.
The second form of the ALLOCATE directive is associated with an ALLOCATE statement and can appear in the
executable statement part of a subprogram after the first executable statement or OpenMP* construct. It
associates an allocator with each allocate item in the associated ALLOCATE statement. If an ALLOCATE
1226
Language Reference
directive with no list items appears, all the allocate list objects in the ALLOCATE statement that are not listed
in an ALLOCATE directive associated with the same ALLOCATE statement, are allocated by the allocator
specified in the ALLOCATE directive with no list items specified. Multiple ALLOCATE directives with list items
can be specified for an ALLOCATE statement.
A list item may not appear in more than one ALLOCATE directive associated with a given ALLOCATE
statement, or appear more than once in the same directive. Each list item must have the ALLOCATABLE or
POINTER attribute. A list item may be a POINTER or ALLOCATABLE component of a derived type. A list item
may not be an associate name.
If an object appears as a list item of an ALLOCATE directive, it must also appear in the allocation list of the
associated ALLOCATE statement. When an object is deallocated, it is deallocated using the same allocator
used to allocate it. If an object is deallocated and reallocated during intrinsic assignment, the same allocator
is used for the deallocation and reallocation, otherwise, the allocator specified for a list item is used to
allocate the list item only in the ALLOCATE statement associated with the ALLOCATE directive.
If multiple ALLOCATE directives are associated with an ALLOCATE statement, only one ALLOCATE directive
can appear with no list items.
An ALLOCATOR must be specified in ALLOCATE directives that appear in a TARGET region, unless a
REQUIRES directive with the DYNAMIC_ALLOCATORS clause is specified in the same compilation unit.
When a list item goes out of scope, if it has not been deallocated, it is automatically deallocated with the
same allocator that allocated it.
See Also
ALLOCATE Clause
OpenMP* Memory Spaces and Allocators
ALLOCATE Statement
Statement: Dynamically creates storage for
allocatable variables and pointer targets.
Syntax
ALLOCATE ([type::] object[(s-spec[, s-spec]...)] [, object[(s-spec[, s-spec]...)] ]...
[[coarray-spec]]...[, alloc-opt[, alloc-opt]...])
type Is a data type specifier. If specified, the kind type parameters of each
object must be the same as the corresponding type parameter
values and each object must be type compatible with the specified
type. The type must not have an ultimate subcomponent that is a
coarray.
You cannot specify type if you specify SOURCE= or MOLD=.
1227
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
You can specify an s-spec list for each array object in an ALLOCATE
statement.
You can specify STAT=, ERRMSG=, and one of MOLD= or SOURCE= in the same ALLOCATE statement. The
keywords can appear in any order.
Description
The storage space allocated is uninitialized unless SOURCE= is specified or the type of the object is default
initialized.
A bound in s-spec must not be an expression containing an array inquiry function whose argument is any
allocatable object in the same ALLOCATE statement; for example, the following is not permitted:
INTEGER ERR
INTEGER, ALLOCATABLE :: A(:), B(:)
...
ALLOCATE(A(10:25), B(SIZE(A)), STAT=ERR) ! A is invalid as an argument to function SIZE
1228
Language Reference
If object is an array, s-spec must appear and the number of s-specs must equal the rank of object, or
source-expr must appear and have the same rank as object and the shape of object is that of source-expr. If
both s-spec and SOURCE=source-expr appear, source-expr must be scalar. If object is scalar, no s-spec
should appear. If SOURCE=source-expr appears, object is initialized with the value of source-expr.
A type parameter value in type can be an asterisk if and only if each object is a dummy argument for which
the corresponding type parameter is assumed.
If a STAT= variable, ERRMSG= variable, or source-expr is specified, it must not be allocated in the ALLOCATE
statement in which it appears; nor can they depend on the value, bounds, length type parameters, allocation
status, or association status of any object in the same ALLOCATE statement.
If the allocation is successful, the STAT= variable becomes defined with the value zero, and the definition
status of the ERRMSG= variable remains unchanged. If the allocation is not successful, an error condition
occurs, and the STAT= variable is set to a positive integer value (representing the run-time error); the
ERRMSG= variable contains a descriptive message about the error condition.
If no STAT= variable is specified and an error condition occurs, the program initiates error termination.
If the allocation is successful and source-expr is specified, the dynamic type and value of the allocated object
becomes that of the source expression. If the value of a non-deferred length type parameter of object is
different from the value of the corresponding type parameter of source-expr, an error condition occurs.
If any object has a deferred type parameter, is unlimited polymorphic, or is of ABSTRACT type, either type
or source-expr must appear.
If object is a coarray, source-expr must not have a dynamic type of C_PTR, C_FUNPTR, EVENT_TYPE, or
LOCK_TYPE, or have a subcomponent whose dynamic type is EVENT_TYPE or LOCK_TYPE. The object cannot
be a coindexed object.
When an ALLOCATE statement is executed for an object that is a coarray, there is an implicit synchronization
of all images. On each image, execution of the segment following the statement is delayed until all other
images have executed the same statement the same number of times.
If an ALLOCATE or DEALLOCATE statement with a coarray allocatable object is executed when one or more
images of the current team has initiated normal termination, the STAT= variable becomes defined with the
processor-dependent positive integer value of the constant STAT_STOPPED_IMAGE from the intrinsic module
ISO_FORTRAN_ENV. Otherwise, if an allocatable object is a coarray and one or more images of the current
team has failed, the STAT= variable becomes defined with the processor-dependent positive integer value of
the constant STAT_FAILED_IMAGE from the intrinsic module ISO_FORTRAN_ENV.
If any other error condition occurs during execution of the ALLOCATE or DEALLOCATE statement, the STAT=
variable becomes defined with a processor-dependent positive integer value different from
STAT_STOPPED_IMAGE or STAT_FAILED_IMAGE.
If an ALLOCATE or DEALLOCATE statement with a coarray allocatable object is executed when one or more
images of the current team has failed, each allocatable object is successfully allocated or deallocated on the
active images of the current team. If any other error occurs, the allocation status of each allocatable object is
processor dependent:
• Successfully allocated allocatable objects have the allocation status of allocated, or associated if the
allocate object is has the POINTER attribute.
• Successfully deallocated allocatable objects have the allocation status of deallocated, or disassociated if
the allocatable object has the POINTER attribute.
• An allocatable object that was not successfully allocated or deallocated has its previous allocation status,
or its previous association status if it has the POINTER attribute.
If MOLD= appears and source-expr is a variable, its value does not have to be defined.
To release the storage for an object, use DEALLOCATE.
To determine whether an allocatable object is currently allocated, use the ALLOCATED intrinsic function.
1229
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
To determine whether a pointer is currently associated with a target, use the ASSOCIATED intrinsic function.
Example
!Method for creating and allocating deferred shape arrays.
INTEGER,ALLOCATABLE::matrix(:,:)
REAL, ALLOCATABLE:: vector(:)
. . .
ALLOCATE (matrix(3,5),vector(-2:N+2))
. . .
The following shows another example of the ALLOCATE statement:
INTEGER J, N, ALLOC_ERR
REAL, ALLOCATABLE :: A(:), B(:,:)
...
ALLOCATE(A(0:80), B(-3:J+1, N), STAT = ALLOC_ERR)
The above example allocates the scalar objects s and t to be 15 by 25 matrices with the value of r.
Consider the following:
See Also
ALLOCATABLE
ALLOCATED
DEALLOCATE
ASSOCIATED
POINTER
Dynamic Allocation
Pointer Assignments
ISO_FORTRAN_ENV Module
ALLOCATED
Inquiry Intrinsic Function (Generic): Indicates
whether an allocatable array or allocatable scalar is
currently allocated.
Syntax
result = ALLOCATED ([ARRAY=]array)
result = ALLOCATED ([SCALAR=]scalar)
Results
The result is a scalar of type default logical.
The result has the value true if argument array or scalar is currently allocated; it has the value false if the
argument is not currently allocated.
1230
Language Reference
NOTE
When the argument keyword ARRAY is used, array must be an allocatable array. When the
argument keyword SCALAR is used, scalar must be an allocatable scalar.
Example
REAL, ALLOCATABLE :: A(:)
...
IF (.NOT. ALLOCATED(A)) ALLOCATE (A (5))
Consider the following:
See Also
ALLOCATABLE
ALLOCATE
DEALLOCATE
Arrays
Dynamic Allocation
ANINT
Elemental Intrinsic Function (Generic): Calculates
the nearest whole number.
Syntax
result = ANINT (a[,kind] )
Results
The result type is real. If kind is present, the kind parameter is that specified by kind; otherwise, the kind
parameter is that of a. If a is greater than zero, ANINT ( a) has the value AINT (a + 0.5); if a is less than or
equal to zero, ANINT (a) has the value AINT (a - 0.5).
Example
ANINT (3.456) has the value 3.0.
ANINT (-2.798) has the value -3.0.
1231
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
REAL r1, r2
r1 = ANINT(2.6) ! returns the value 3.0
r2 = ANINT(-2.6) ! returns the value -3.0
See Also
NINT
ANY
Transformational Intrinsic Function (Generic):
Determines if any value is true in an entire array or in
a specified dimension of an array.
Syntax
result = ANY (mask)
result = ANY (mask, dim)
dim (Input) Must be a scalar integer expression with a value in the range 1
to n, where n is the rank of mask.
Results
The result is an array or a scalar of type logical.
The result is a scalar if dim is not specified or mask has rank one. A scalar result is true if any elements of
mask are true. The result has the value false if no element of mask is true, or mask has size zero.
An array result has the same type and kind parameters as mask, and a rank that is one less than mask. Its
shape is (d1, d2, ..., ddim-1, ddim+1, ..., dn), where (d1, d2, ..., dn) is the shape of mask.
Each element in an array result is true if any elements in the one dimensional array defined by mask(s1,
s2, ..., sdim-1, :, sdim+1, ..., sn) are true.
Example
LOGICAL mask( 2, 3), AR1(3), AR2(2)
logical, parameter :: T = .true.
logical, parameter :: F = .false.
DATA mask /T, T, F, T, F, F/
! mask is true false false
! true true false
AR1 = ANY(mask,DIM = 1) ! evaluates the elements column by
1232
Language Reference
[ 1 5 7 ]
[ 3 6 8 ]
and B is the array
[ 0 5 7 ]
[ 2 6 9 ].
ANY (A .EQ. B, DIM=1) tests to see if any elements in each column of A are equal to the elements in the
corresponding column of B. The result has the value (false, true, true) because the second and third columns
have at least one element that is equal.
ANY (A .EQ. B, DIM=2) tests to see if any elements in each row of A are equal to the elements in the
corresponding row of B. The result has the value (true, true) because each row has at least one element that
is equal.
See Also
ALL
COUNT
APPENDMENUQQ (W*S)
QuickWin Function: Appends a menu item to the
end of a menu and registers its callback subroutine.
Module
USE IFQWIN
Syntax
result = APPENDMENUQQ (menuID, flags, text,routine)
flags (Input) INTEGER(4). Constant indicating the menu state. Flags can be
combined with an inclusive OR (see the Results section below). The
following constants are available:
• $MENUGRAYED - Disables and grays out the menu item.
• $MENUDISABLED - Disables but does not gray out the menu item.
• $MENUENABLED - Enables the menu item.
• $MENUSEPARATOR - Draws a separator bar.
• $MENUCHECKED - Puts a check by the menu item.
• $MENUUNCHECKED - Removes the check by the menu item.
1233
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
routine (Input) EXTERNAL. Callback subroutine that is called if the menu item
is selected. All routines take a single LOGICAL parameter that
indicates whether the menu item is checked or not. You can assign the
following predefined routines to menus:
• WINPRINT - Prints the program.
• WINSAVE - Saves the program.
• WINEXIT - Terminates the program.
• WINSELECTTEXT - Selects text from the current window.
• WINSELECTGRAPHICS - Selects graphics from the current window.
• WINSELECTALL - Selects the entire contents of the current window.
• WININPUT - Brings to the top the child window requesting input
and makes it the current window.
• WINCOPY - Copies the selected text and/or graphics from the
current window to the Clipboard.
• WINPASTE - Allows the user to paste Clipboard contents (text only)
to the current text window of the active window during a READ.
• WINCLEARPASTE - Clears the paste buffer.
• WINSIZETOFIT - Sizes output to fit window.
• WINFULLSCREEN - Displays output in full screen.
• WINSTATE - Toggles between pause and resume states of text
output.
• WINCASCADE - Cascades active windows.
• WINTILE - Tiles active windows.
• WINARRANGE - Arranges icons.
• WINSTATUS - Enables a status bar.
• WININDEX - Displays the index for QuickWin help.
• WINUSING - Displays information on how to use Help.
• WINABOUT - Displays information about the current QuickWin
application.
• NUL - No callback routine.
Results
The result type is logical. It is .TRUE. if successful; otherwise, .FALSE..
You do not need to specify a menu item number, because APPENDMENUQQ always adds the new item to the
bottom of the menu list. If there is no item yet for a menu, your appended item is treated as the top-level
menu item (shown on the menu bar), and text becomes the menu title. APPENDMENUQQ ignores the
callback routine for a top-level menu item if there are any other menu items in the menu. In this case, you
can set routine to NUL.
If you want to insert a menu item into a menu rather than append to the bottom of the menu list, use
INSERTMENUQQ.
The constants available for flags can be combined with an inclusive OR where reasonable, for example
$MENUCHECKED .OR. $MENUENABLED. Some combinations do not make sense, such as $MENUENABLED
and $MENUDISABLED, and lead to undefined behavior.
You can create quick-access keys in the text strings you pass to APPENDMENUQQ as text by placing an
ampersand (&) before the letter you want underlined. For example, to add a Print menu item with the r
underlined, text should be "P&rint". Quick-access keys allow users of your program to activate that menu
item with the key combination ALT+QUICK-ACCESS-KEY (ALT+R in the example) as an alternative to
selecting the item with the mouse.
1234
Language Reference
Example
USE IFQWIN
LOGICAL(4) result
CHARACTER(25) str
...
! Append two items to the bottom of the first (FILE) menu
str = '&Add to File Menu'C ! 'A' is a quick-access key
result = APPENDMENUQQ(1, $MENUENABLED, str, WINSTATUS)
str = 'Menu Item &2b'C ! '2' is a quick-access key
result = APPENDMENUQQ(1, $MENUENABLED, str, WINCASCADE)
! Append an item to the bottom of the second (EDIT) menu
str = 'Add to Second &Menu'C ! 'M' is a quick-access key
result = APPENDMENUQQ(2, $MENUENABLED, str, WINTILE)
See Also
INSERTMENUQQ
DELETEMENUQQ
MODIFYMENUFLAGSQQ
MODIFYMENUROUTINEQQ
MODIFYMENUSTRINGQQ
Module
USE IFQWIN
Syntax
result = ARC (x1,y1,x2,y2,x3,y3,x4,y4)
result = ARC_W (wx1,wy1,wx2,wy2,wx3,wy3,wx4,wy4)
1235
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type is INTEGER(2). It is nonzero if successful; otherwise, 0. If the arc is clipped or partially out of
bounds, the arc is considered successfully drawn and the return is 1. If the arc is drawn completely out of
bounds, the return is 0.
The center of the arc is the center of the bounding rectangle defined by the points (x1, y1) and (x2, y2) for
ARC and (wx1, wy1) and (wx2, wy2) for ARC_W.
The arc starts where it intersects an imaginary line extending from the center of the arc through (x3, y3) for
ARC and (wx3, wy3) for ARC_W. It is drawn counterclockwise about the center of the arc, ending where it
intersects an imaginary line extending from the center of the arc through (x4, y4) for ARC and (wx4, wy4)
for ARC_W.
ARC uses the view-coordinate system. ARC_W uses the window-coordinate system. In each case, the arc is
drawn using the current color.
NOTE
The ARC routine described here is a QuickWin graphics routine. If you are trying to use the
Microsoft* Platform SDK version of the Arc routine by including the IFWIN module, you need
to specify the routine name as MSFWIN$Arc.
Example
This program draws the arc shown below.
USE IFQWIN
INTEGER(2) status, x1, y1, x2, y2, x3, y3, x4, y4
x1 = 80; y1 = 50
x2 = 240; y2 = 150
x3 = 120; y3 = 75
x4 = 90; y4 = 180
status = ARC( x1, y1, x2, y2, x3, y3, x4, y4 )
END
ASIN
Elemental Intrinsic Function (Generic): Produces
the arcsine of an argument.
Syntax
result = ASIN (x)
1236
Language Reference
Results
The result type and kind are the same as x.
If the result is real, it is expressed in radians and lies in the range - pi/2 <= ASIN (x) <= pi/2.
If the result is complex, the real part is expressed in radians and lies in the range pi/2 <= REAL (ASIN (x))
<= pi/2.
Example
ASIN (0.79345021) has the value 0.9164571.
ASIND
Elemental Intrinsic Function (Generic): Produces
the arcsine of x.
Syntax
result = ASIND (x)
Results
The result type and kind are the same as x and are expressed in degrees. The value lies in the range −90 to
90 degrees.
Example
ASIND (0.2467590) has the value 14.28581.
ASINH
Elemental Intrinsic Function (Generic): Produces
the hyperbolic arcsine of x.
Syntax
result = ASINH (x)
1237
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type and kind are the same as x.
If the result is complex, the imaginary part is expressed in radians and lies in the range - pi/ 2 <= AIMAG
(ASINH (x)) <= pi / 2.
Example
ASINH (1.0) has the value -0.88137.
ASINH (180.0) has the value 5.88611.
Syntax
ASSIGN label TO var
When an ASSIGN statement is executed, the statement label is assigned to the integer variable. The variable
is then undefined as an integer variable and can only be used as a label (unless it is later redefined with an
integer value).
The ASSIGN statement must be executed before the statements in which the assigned variable is used.
Indirect branching through integer variables makes program flow difficult to read, especially if the integer
variable is also used in arithmetic operations. Using these statements permits inconsistent usage of the
integer variable, and can be an obscure source of error. The ASSIGN statement was used to simulate internal
procedures, which now can be coded directly.
Example
The value of a label is not the same as its number; instead, the label is identified by a number assigned by
the compiler. In the following example, 400 is the label number (not the value) of IVBL:
IVBL = 400
1238
Language Reference
INTEGER ERROR
...
ASSIGN 10 TO NSTART
ASSIGN 99999 TO KSTOP
ASSIGN 250 TO ERROR
Note that NSTART and KSTOP are integer variables implicitly, but ERROR must be previously declared as an
integer variable.
The following statement associates the variable NUMBER with the statement label 100:
NUMBER = NUMBER + 1
To return NUMBER to the status of an integer variable, you can use the following statement:
NUMBER = 10
This statement dissociates NUMBER from statement 100 and assigns it an integer value of 10. Once NUMBER
is returned to its integer variable status, it can no longer be used in an assigned GO TO statement.
See Also
Assignment: intrinsic
Obsolescent Language Features in the Fortran Standard
Syntax
The initial line for such an interface block takes the following form:
INTERFACE ASSIGNMENT (=)
Description
The subroutines within the interface block must have two nonoptional arguments, the first with intent OUT or
INOUT, and the second with intent IN and/or attribute VALUE.
A defined assignment is treated as a reference to a subroutine. The left side of the assignment corresponds
to the first dummy argument of the subroutine; the right side of the assignment, enclosed in parentheses,
corresponds to the second argument. A defined assignment procedure with an ALLOCATABLE or POINTER
dummy argument cannot be directly invoked through defined assignment; the right-hand side of the
assignment operator becomes an expression, and an expression cannot have the ALLOCATABLE, POINTER, or
TARGET attribute.
The ASSIGNMENT keyword extends or redefines an assignment operation if both sides of the equal sign are
of the same derived type.
Defined elemental assignment is indicated by specifying ELEMENTAL in the SUBROUTINE statement.
Any procedure reference involving generic assignment must be resolvable to one specific procedure; it must
be unambiguous. For more information, see Unambiguous Generic Procedure References.
1239
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
The following is an example of a procedure interface block defining assignment:
PROGRAM assign
use mod1
TYPE(CIRCLE) circle1
TYPE(INTERVAL) interval1
INTERFACE ASSIGNMENT(=)
module procedure circle_to_interval
END INTERFACE
!Begin executable part of program
circle1%radius = 2.5
circle1%center_point = (/3.0,5.0/)
1240
Language Reference
interval1 = circle1
. . .
END PROGRAM
See Also
INTERFACE
Assignment Statements
Syntax
variable=expression
expression Is of intrinsic type or the same derived type as variable. Its shape
must conform with variable. If necessary, it is converted to the
same type and kind as variable.
Description
Before a value is assigned to the variable, the expression part of the assignment statement and any
expressions within the variable are evaluated. No definition of expressions in the variable can affect or be
affected by the evaluation of the expression part of the assignment statement.
NOTE
When the run-time system assigns a value to a scalar integer or character variable and the
variable is shorter than the value being assigned, the assigned value may be truncated and
significant bits (or characters) lost. This truncation can occur without warning, and can
cause the run-time system to pass incorrect information back to the program.
If the variable is a pointer, it must be associated with a definable target. The shape of the target and
expression must conform and their type and kind parameters must match.
If the !DIR$ NOSTRICT compiler directive (the default) is in effect, then you can assign a character
expression to a noncharacter variable, and a noncharacter variable or array element (but not an expression)
to a character variable.
Example
REAL a, b, c
LOGICAL abigger
CHARACTER(16) assertion
c = .01
a = SQRT (c)
1241
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
b = c**2
assertion = 'a > b'
abigger = (a .GT. b)
WRITE (*, 100) a, b
100 FORMAT (' a =', F7.4, ' b =', F7.4)
IF (abigger) THEN
WRITE (*, *) assertion, ' is true.'
ELSE
WRITE (*, *) assertion, ' is false.'
END IF
END
! The program above has the following output:
! a = .1000 b = .0001 a > b is true.
! The following code shows legal and illegal
! assignment statements:
!
INTEGER i, j
REAL rone(4), rtwo(4), x, y
COMPLEX z
CHARACTER name6(6), name8(8)
i = 4
x = 2.0
z = (3.0, 4.0)
rone(1) = 4.0
rone(2) = 3.0
rone(3) = 2.0
rone(4) = 1.0
name8 = 'Hello,'
See Also
Assignment: defined
NOSTRICT directive
ASSOCIATE
Statement: Marks the beginning of an ASSOCIATE
construct. The ASSOCIATE construct creates a
temporary association between a named entity and a
variable or the value of an expression. The association
lasts for the duration of the block.
Syntax
[name:] ASSOCIATE (assoc-entity[, assoc-entity]...)
block
END ASSOCIATE [name]
1242
Language Reference
Description
If a construct name is specified at the beginning of an ASSOCIATE statement, the same name must appear in
the corresponding END ASSOCIATE statement. The same construct name must not be used for different
named constructs in the same scoping unit. If no name is specified at the beginning of an ASSOCIATE
statement, you cannot specify one following the END ASSOCIATE statement.
During execution of the block within the construct, each associate-name identifies an entity, which is
associated with the corresponding selector. The associating entity assumes the declared type and type
parameters of the selector.
You can only branch to an END ASSOCIATE statement from within its ASSOCIATE construct.
This construct is useful when you want to simplify multiple accesses to a variable that has a lengthy
description; for example, if the variable contains multiple subscripts and component names.
Example
The following shows an expression as a selector:
See Also
Construct Association
Additional Attributes Of Associate Names
ASSOCIATED
Inquiry Intrinsic Function (Generic): Returns the
association status of its pointer argument or indicates
whether the pointer is associated with the target.
Syntax
result = ASSOCIATED (pointer [, target])
1243
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
pointer (Input) Must be a pointer. It can be of any data type. The pointer
association status must be defined.
Results
The result is a scalar of type default logical. The setting of compiler options specifying integer size can affect
this function.
If only pointer appears, the result is true if it is currently associated with a target; otherwise, the result is
false.
If target also appears and is a target, the result is true if pointer is currently associated with target;
otherwise, the result is false.
If target is a pointer, the result is true if both pointer and target are currently associated with the same
target; otherwise, the result is false. (If either pointer or target is disassociated, the result is false.)
Example
REAL C (:), D(:), E(5)
POINTER C, D
TARGET E
LOGICAL STATUS
C => E ! pointer assignment
D => E ! pointer assignment
STATUS = ASSOCIATED(C) ! returns TRUE; C is associated
STATUS = ASSOCIATED(C, E) ! returns TRUE; C is associated with E
STATUS = ASSOCIATED (C, D) ! returns TRUE; C and D are associated
! with the same target
Consider the following:
1244
Language Reference
POINTER
TARGET
Pointer Assignments
ASSUME
General Compiler Directive: Provides heuristic
information to the compiler optimizer.
Syntax
!DIR$ ASSUME (scalar-Boolean-expression)
The scalar-Boolean-expression is presumed to be true and may be used by the optimizer to generate better
code.
If the check assume option is specified and scalar-Boolean-expression does not evaluate to .TRUE. at run
time, an error message is displayed and execution is aborted.
Example
In the example below, the compiler is told that A is aligned on a 32-byte boundary using the
ASSUME_ALIGNED directive. The ASSUME directive says that the length of the first dimension of A is a
multiple of 8. Therefore the optimizer knows that A(I,J+1) and A(I,J-1) are 0 mod 64 bytes away from A(I,J)
and are therefore also aligned on 32-byte boundaries. This information helps the optimizer in generating
efficiently vectorized code for these loops.
See Also
General Compiler Directives
ASSUME_ALIGNED
General Compiler Directive: Specifies that an entity
in memory is aligned.
Syntax
!DIR$ ASSUME_ALIGNED address1:n1 [, address2:n2]...
1245
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
address An array variable. It can be of any data type, kind, or rank > 0. It can
be an array component of a variable of derived type or a record field
reference, host or use associated, or have the ALLOCATABLE or
POINTER attribute.
It cannot be any of the following:
• An entity in COMMON (or an entity EQUIVALENCEd to something in
COMMON)
• A component of a variable of derived type or a record field
reference
• An entity accessed by use or host association
If it is a module variable, that address is silently ignored.
The ASSUME_ALIGNED directive must appear after the specification statements section or inside the
executable statements section.
If you specify more than one address:n item, they must be separated by a comma.
If address is a Cray POINTER or it has the POINTER attribute, it is the POINTER and not the pointee or the
TARGET that is assumed aligned.
If the check assume option is specified and address is not aligned on an n-byte boundary at run time, an
error message is displayed and execution is aborted.
For more information, see the example in the description of the ASSUME directive.
Example
The following example shows the correct placement and usage of the ASSUME_ALIGNED directive:
SUBROUTINE F(A, N)
TYPE NODE
REAL(KIND=8), POINTER :: A(:,:)
END TYPE NODE
ALLOCATE(NODES)
ALLOCATE(NODES%A(1000,1000))
TYPE S
!DIR$ ASSUME_ALIGNED T : 16 ! this is an error
REAL(8), ALLOCATABLE :: T(:)
END TYPE S
See Also
General Compiler Directives
1246
Language Reference
ASYNCHRONOUS
Statement and Attribute: Specifies that a variable
can be used for asynchronous input and output.
Syntax
The ASYNCHRONOUS attribute can be specified in a type declaration statement or an ASYNCHRONOUS
statement, and takes one of the following forms:
Type Declaration Statement:
type, [att-ls,] ASYNCHRONOUS [, att-ls] :: var [, var] ...
Statement:
ASYNCHRONOUS [::] var [, var] ...
Description
Asynchronous I/O, or non-blocking I/O, allows a program to continue processing data while the I/O operation
is performed in the background.
A variable can have the ASYNCHRONOUS attribute in a particular scoping unit without necessarily having it in
other scoping units. If an object has the ASYNCHRONOUS attribute, then all of its subobjects also have the
ASYNCHRONOUS attribute.
The ASYNCHRONOUS attribute can also be implied by use of a variable in an asynchronous READ or WRITE
statement.
You can specify variables that are used for asynchronous communication, such as with Message Passing
Interface Standard (MPI). Asynchronous communication has the following restrictions:
• For input, a pending communication affector must not be referenced, become defined, become undefined,
become associated with a dummy argument that has the VALUE attribute, or have its pointer association
status changed.
• For output, a pending communication affector must not be redefined, become undefined, or have its
pointer association status changed.
Examples
The following example shows how the ASYNCHRONOUS attribute can be applied in an OPEN and READ
statement.
program test
integer, asynchronous, dimension(100) :: array
open (unit=1,file='asynch.dat',asynchronous='YES',&
form='unformatted')
write (1) (i,i=1,100)
rewind (1)
read (1,asynchronous='YES') array
1247
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
wait(1)
write (*,*) array(1:10)
end
See Also
Type Declarations
Compatible attributes
ATAN
Elemental Intrinsic Function (Generic): Produces
the arctangent of an argument.
Syntax
result = ATAN (x)
result = ATAN (y,x)
x (Input) If y appears, x must be of type real with the same kind type
parameter as y.
If y has the value zero, x must not have the value zero.
If y does not appear, x must be of type real or complex.
Results
The result type and kind are the same as x.
If y appears, the result is the same as the result of ATAN2 (y, x).
If y does not appear, the real part of the result is expressed in radians and lies in the range -pi/2 <= ATAN
(x) <= pi/2.
Example
ATAN (1.5874993) has the value 1.008666.
ATAN (2.679676, 1.0) has the value 1.213623.
ATAN2
Elemental Intrinsic Function (Generic): Produces
an arctangent (inverse tangent). The result is the
principal value of the argument of the nonzero
complex number (x, y).
Syntax
result = ATAN2 (y,x)
1248
Language Reference
x (Input) Must have the same type and kind parameters as y. If y has
the value zero, x cannot have the value zero.
Results
The result type and kind are the same as x and are expressed in radians. The value lies in the range -pi <=
ATAN2 (y, x) <= pi.
If x is not zero, the result is approximately equal to the value of arctan (y/ x).
If y > zero, the result is positive.
If y < zero, the result is negative.
If y is zero and x > zero, the result is y (so for x>0, ATAN2 ((+0.0), x) is +0.0 and ATAN2 ((-0.0), x) is
-0.0).
If y is a positive real zero and x < zero, the result is pi.
If y is a negative real zero and x < zero, the result is -pi.
If x is a positive real zero, the result is pi/2.
If y is a negative real zero, the result is -pi/2.
Example
ATAN2 (2.679676, 1.0) has the value 1.213623.
If Y is an array that has the value
[ 1 1 ]
[ -1 -1 ]
and X is an array that has the value
[ -1 1 ]
[ -1 1 ],
then ATAN2 (Y, X) is
ATAN2D
Elemental Intrinsic Function (Generic): Produces
an arctangent. The result is the principal value of the
argument of the nonzero complex number (x, y).
1249
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
result = ATAN2D (y,x)
x (Input) Must have the same type and kind parameters as y. If y has
the value zero, x cannot have the value zero.
Results
The result type and kind are the same as x and are expressed in degrees. The value lies in the range -180
degrees to 180 degrees. If x zero, the result is approximately equal to the value of arctan (y/ x).
If y > zero, the result is positive.
If y < zero, the result is negative.
If y = zero, the result is zero (if x > zero) or 180 degrees (if x < zero).
If x = zero, the absolute value of the result is 90 degrees.
Example
ATAN2D (2.679676, 1.0) has the value 69.53546.
ATAND
Elemental Intrinsic Function (Generic): Produces
the arctangent of x.
Syntax
result = ATAND (x)
Results
The result type and kind are the same as x and are expressed in degrees.
Example
ATAND (0.0874679) has the value 4.998819.
1250
Language Reference
ATANH
Elemental Intrinsic Function (Generic): Produces
the hyperbolic arctangent of x.
Syntax
result = ATANH (x)
Results
The result type and kind are the same as x.
If the result is real, it lies in the range -1.0 < ATANH (x) < 1.0.
If the result is complex, the imaginary part is expressed in radians and lies in the range –pi/2 <= AIMAG
(ATANH (x)) <= pi/2.
Example
ATANH (-0.77) has the value -1.02033.
ATANH (0.5) has the value 0.549306.
ATOMIC
OpenMP* Fortran Compiler Directive: Ensures that
a specific memory location is updated atomically. This
prevents the possibility of multiple threads
simultaneously reading and writing the specific
memory location.
Syntax
!$OMP ATOMIC [clause[[[,] clause]...]]
block
[!$OMP END ATOMIC]
1251
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• ACQ_REL
Specifies both an ACQUIRE and a RELEASE flush.
• ACQUIRE
Forces consistency between views of memory of two
synchronizing threads by discarding any value of a shared
variable in its temporary view, which the thread has not written
since last performing a RELEASE flush.
It also will reload any value of a shared variable propagated by
a RELEASE flush that synchronizes with it.
• RELAXED
Permits a thread's local or temporary view of memory, which
may be held in registers, cache, or other local memory, to be
temporarily inconsistent with the memory, which may have
been updated by another thread.
Note that a strong flush operation forces consistency between
memory and a threads temporary view and memory, and it
restricts reordering of memory operations that may otherwise
be performed. RELAXED memory ordering has no implicit
flushes.
• RELEASE
Forces consistency between views of memory of two
synchronizing threads by guaranteeing that any prior READ or
WRITE of a shared variable will appear complete before any
READ or WRITE of the same shared variable that follows an
ACQUIRE flush that is synchronized with a RELEASE flush.
The RELEASE flush propagates the values of all shared variables
in its temporary view of memory prior to the thread performing
a subsequent atomic operation that establishes a
synchronization.
• SEQ_CST
Specifies that the construct is a sequentially consistent atomic
construct. Unlike non-sequentially consistent atomic constructs,
sequentially consistent atomic constructs preserve the
interleaving (sequentially consistent) behavior of correct, data-
race-free programs.
However, sequentially consistent atomic constructs are not
designed to replace the FLUSH directive as a mechanism to
enforce ordering for non-sequentially consistent atomic
constructs. Attempts to do so require extreme caution.
For example, a sequentially consistent ATOMIC WRITE construct
may appear to be reordered with a subsequent non-sequentially
consistent ATOMIC WRITE construct because such reordering
would not be observable by a correct program if the second
WRITE was outside an ATOMIC construct.
If a memory-order-clause is present, or implicitly provided by a
REQUIRES directive, it specifies the effective memory ordering;
otherwise, the effective memory ordering is RELAXED.
• Or one of the following:
1252
Language Reference
• CAPTURE
Causes an atomic update to x to occur using the specified
operator or intrinsic. The original or final value of the location x
is captured and written to the storage location v.
Only the READ and WRITE of the location specified by x are
performed mutually atomically. The evaluation of expr or expr-
list and the write to v need not be atomic with respect to the
READ and WRITE of x.
• COMPARE
Specifies that the atomic update is a conditional atomic update.
If the equality operator is used, the operation is an atomic
compare and swap.
The values of x and e are compared and if equal, the value of d
is written to x. The original or final value of x is written to v,
which may be the same as e.
Only the READ and WRITE of x is performed atomically; neither
the comparison nor the writes to v need be atomic with respect
to the READ or WRITE of x.
• HINT (hint-expression)
Provides additional information about the expected properties of
the atomic operation, which can be used for optimization
purposes.
This clause does not affect the semantics of the ATOMIC
construct.
hint-expression is an integer constant expression with kind
omp_sync_hint, which has a value that is a valid
synchronization hint.
• FAIL (SEQ_CAT | ACQUIRE |RELAXED)
Specifies that its parameter overrides the effective memory
ordering used when the comparison for a conditional update
fails.
• WEAK
Indicates that the comparison performed by an atomic compare
and swap may falsely fail, evaluating to not equal even when
the values are equal.
• statement
• or if CAPTURE is also specified, it can be the following:
• statement
• capture-statement
The order is not important. capture-statement can appear before
statement.
1253
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
compare-statement Is as follows:
if (x == e) then
x = d
end
or:
if (x == e) x = d
or if CAPTURE also appears and block contains no capture-statement it
can also be the following:
if (x == e) then
x = d
else
v = x
end if
x = x operator expr
x = expr operator x
x = intrinsic (x, expr-list)
x = intrinsic (expr-list, x)
The following rules apply:
1254
Language Reference
intrinsic Is one of the following intrinsic procedures: MAX, MIN, IAND, IOR, or
IEOR.
If x is of size 8, 16, 32, or 64 bits and x is aligned to a multiple of its size, the binding thread set is all
threads on the device. Otherwise, the binding thread set is all threads in the contention group. Atomic
regions enforce exclusive access with respect to other atomic regions that access the same storage location x
among all the threads in the binding thread set without regard to the teams to which the threads belong.
If !$OMP ATOMIC is specified with no atomic-clause, it is the same as specifying !$OMP ATOMIC UPDATE.
If !$OMP ATOMIC CAPTURE is specified, you must include an !$OMP END ATOMIC directive following the
block. Otherwise, the !$OMP END ATOMIC directive is optional.
Note that the following restriction applies to the ATOMIC directive:
• All atomic accesses to the storage locations designated by x throughout the program must have the same
type and type parameters.
The following table describes what happens when you specify one of the values in the atomic-clause in an
ATOMIC construct.
Clause Result
If all of the following conditions are true, the strong flush on entry to the atomic operation is also a RELEASE
flush:
• The atomic-clause is WRITE or UPDATE.
• The atomic operation is not a conditional update for which the comparison fails.
• The effective memory ordering is RELEASE, ACQ_REL, or SEQ_CST.
If both of the following conditions are true, the strong flush on exit from the atomic operation is also an
ACQUIRE flush:
• The atomic-clause is READ or UPDATE.
• The effective memory ordering is ACQUIRE, ACQ_REL, or SEQ_CST.
Therefore, as the above shows, the effective memory ordering is not RELAXED. RELEASE and ACQUIRE
flushes can be implied and permit synchronization between threads without an explicit FLUSH directive.
Any combination of two or more of these atomic constructs enforces mutually exclusive access to the
locations designated by x.
1255
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
A race condition exists when two unsynchronized threads access the same shared variable with at least one
thread modifying the variable; this can cause unpredictable results. To avoid race conditions, all accesses of
the locations designated by x that could potentially occur in parallel must be protected with an ATOMIC
construct.
Atomic regions do not guarantee exclusive access with respect to any accesses outside of atomic regions to
the same storage location x even if those accesses occur during a CRITICAL or ORDERED region, while an
OpenMP* lock is owned by the executing task, or during the execution of a REDUCTION clause.
However, other OpenMP* synchronization can ensure the desired exclusive access. For example, a BARRIER
directive following a series of atomic updates to x guarantees that subsequent accesses do not form a race
condition with the atomic accesses.
Example
The following example shows a way to avoid race conditions by using ATOMIC to protect all simultaneous
updates of the location by multiple threads.
Since the ATOMIC directive below applies only to the statement immediately following it, elements of Y are
not updated atomically.
PROGRAM ATOMIC_DEMO
REAL X(1000), Y(10000)
INTEGER INDEX(10000)
INTEGER I
DO I=1,10000
INDEX(I) = MOD(I, 1000) + 1
Y(I) = 0.0
ENDDO
DO I = 1,1000
X(I) = 0.0
ENDDO
CALL SUB(X, Y, INDEX, 10000)
END PROGRAM ATOMIC_DEMO
1256
Language Reference
The following non-conforming example demonstrates the restriction on the ATOMIC construct:
SUBROUTINE ATOMIC_INCORRECT()
INTEGER:: I
REAL:: R
EQUIVALENCE(I,R)
!$OMP PARALLEL
!$OMP ATOMIC UPDATE
I = I + 1
!$OMP ATOMIC UPDATE
R = R + 1.0
! The above is incorrect because I and R reference the same location
! but have different types
!$OMP END PARALLEL
END SUBROUTINE ATOMIC_INCORRECT
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
CRITICAL construct
ORDERED construct
BARRIER directive
FLUSH directive
REDUCTION Clause
Parallel Processing Model for information about Binding Sets
ATOMIC_ADD
Atomic Intrinsic Subroutine (Generic): Performs
atomic addition.
Syntax
CALL ATOMIC_ADD (atom, value [, stat])
value (Input) Must be a scalar integer. The value of value and value + atom
must be representable as integers with kind ATOMIC_INT_KIND.
Example
Consider the following:
1257
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If N on image 12 is 4 when this operation is initiated, the value of N on image 12 is defined with the value 11
when the operation is complete and no error occurs during the subroutine reference.
See Also
Overview of Atomic Subroutines
ISO_FORTRAN_ENV Module
ATOMIC_AND
Atomic Intrinsic Subroutine (Generic): Performs
atomic bitwise AND.
Syntax
CALL ATOMIC_AND (atom, value [, stat])
Example
Consider the following:
See Also
Overview of Atomic Subroutines
ISO_FORTRAN_ENV Module
ATOMIC_CAS
Atomic Intrinsic Subroutine (Generic): Performs
atomic compare and swap.
Syntax
CALL ATOMIC_CAS (atom, old, compare, new [, stat])
1258
Language Reference
compare (Input) Must be scalar and the same type and kind as atom.
new (Input) Must be scalar and the same type and kind as atom.
Example
Consider the following:
See Also
Overview of Atomic Subroutines
ISO_FORTRAN_ENV Module
ATOMIC_DEFINE
Atomic Intrinsic Subroutine (Generic): Defines a
variable atomically.
Syntax
CALL ATOMIC_DEFINE (atom, value [, stat])
1259
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
Consider the following:
See Also
Overview of Atomic Subroutines
ISO_FORTRAN_ENV Module
ATOMIC_FETCH_ADD
Atomic Intrinsic Subroutine (Generic): Performs
atomic fetch and addition.
Syntax
CALL ATOMIC_FETCH_ADD (atom, value, old [, stat])
value (Input) Must be a scalar integer. The value of value and value + atom
must be representable as integers with kind ATOMIC_INT_KIND.
Example
Consider the following:
See Also
Overview of Atomic Subroutines
1260
Language Reference
ISO_FORTRAN_ENV Module
ATOMIC_FETCH_AND
Atomic Intrinsic Subroutine (Generic): Performs
atomic fetch and bitwise AND.
Syntax
CALL ATOMIC_FETCH_AND (atom, value, old [, stat])
Example
Consider the following:
See Also
Overview of Atomic Subroutines
ISO_FORTRAN_ENV Module
ATOMIC_FETCH_OR
Atomic Intrinsic Subroutine (Generic): Performs
atomic fetch and bitwise OR.
Syntax
CALL ATOMIC_FETCH_OR (atom, value, old [, stat])
1261
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
Consider the following:
ATOMIC_FETCH_OR (N[4], 9, M)
If the value of N on image 4 is 4 when the atomic operation is initiated, N on image 4 is defined with the
value 13, and M is defined with the value 4 when the operation completes and no error occurs during the
subroutine reference.
See Also
Overview of Atomic Subroutines
ISO_FORTRAN_ENV Module
ATOMIC_FETCH_XOR
Atomic Intrinsic Subroutine (Generic): Performs
atomic fetch and bitwise exclusive OR.
Syntax
CALL ATOMIC_FETCH_XOR (atom, value, old [, stat])
1262
Language Reference
Example
Consider the following:
See Also
Overview of Atomic Subroutines
ISO_FORTRAN_ENV Module
ATOMIC_OR
Atomic Intrinsic Subroutine (Generic): Performs
atomic bitwise OR.
Syntax
CALL ATOMIC_OR (atom, value [, stat])
Example
Consider the following:
See Also
Overview of Atomic Subroutines
ISO_FORTRAN_ENV Module
ATOMIC_REF
Atomic Intrinsic Subroutine (Generic): Lets you
reference a variable atomically.
Syntax
CALL ATOMIC_REF (value, atom [, stat])
1263
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
value (Output) Must be a scalar and of the same type as atom. If its kind is
the same as that of atom or its type is logical, it becomes defined with
the value of atom. Otherwise, it is defined with the value of
INT(ATOM, KIND (VALUE)).
Example
Consider the following:
ATOMIC_XOR
Atomic Intrinsic Subroutine (Generic): Performs
atomic bitwise exclusive OR.
Syntax
CALL ATOMIC_XOR (atom, value [, stat])
Example
Consider the following:
1264
Language Reference
If the value of N on image 4 is 14 when the atomic operation is initiated, the value on N on image 4 is the
value 4 when the operation is complete and no error condition occurred during the subroutine reference.
See Also
Overview of Atomic Subroutines
ISO_FORTRAN_ENV Module
ATTRIBUTES
General Compiler Directive: Declares properties for
specified variables.
Syntax
!DIR$ ATTRIBUTES att[,att]...:: object[,object]...
C IGNORE_LOC VARYING
CONCURRENCY_SAF MIXED_STR_LEN_AR
E G
CVF NO_ARG_CHECK
DECORATE NOCLONE
DEFAULT NOINLINE
The following table shows which ATTRIBUTES options can be used with various objects:
ALIGN Yes No No
ALLOCATABLE Yes2 No No
ALLOW_NULL Yes No No
C No Yes Yes
CODE_ALIGN No No Yes5, 6
1265
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
CONCURRENCY_SAFE No No Yes
DECORATE No No Yes
EXTERN Yes No No
FASTMEM Yes No No
FORCEINLINE No No Yes
IGNORE_LOC Yes4 No No
INLINE No No Yes
MIXED_STR_LEN_ARG No No Yes
NOCLONE No No Yes
NOINLINE No No Yes
OPTIMIZATION_PARAME No No Yes5, 6
TER
VALUE Yes No No
VARYING No No Yes
VECTOR No No Yes5
1A common block name is specified as [/]common-block-name[/]
2This option can only be applied to arrays.
3Module-level variables and arrays only.
4This option can only be applied to INTERFACE blocks.
5This option cannot be applied to EXTERNAL statements.
6This option can be applied to named main programs.
These options can be used in function and subroutine definitions, in type declarations, and with the
INTERFACE and ENTRY statements.
1266
Language Reference
Options applied to entities available through use or host association are in effect during the association. For
example, consider the following:
MODULE MOD1
INTERFACE
SUBROUTINE NEW_SUB
!DIR$ ATTRIBUTES C, ALIAS:'othername' :: NEW_SUB
END SUBROUTINE
END INTERFACE
CONTAINS
SUBROUTINE SUB2
CALL NEW_SUB
END SUBROUTINE
END MODULE
In this case, the call to NEW_SUB within SUB2 uses the C and ALIAS options specified in the interface block.
Options C, STDCALL, REFERENCE, VALUE, and VARYING affect the calling conventions of routines:
• You can specify C, STDCALL, REFERENCE, and VARYING for an entire routine.
• You can specify VALUE and REFERENCE for individual arguments.
Examples
INTERFACE
SUBROUTINE For_Sub (I)
!DIR$ ATTRIBUTES C, ALIAS:'_For_Sub' :: For_Sub
INTEGER I
END SUBROUTINE For_Sub
END INTERFACE
You can assign more than one option to multiple variables with the same compiler directive. All assigned
options apply to all specified variables. For example:
SUBROUTINE ARRAYTEST(arr)
!DIR$ ATTRIBUTES DLLEXPORT :: ARRAYTEST
REAL(4) arr(3, 7)
INTEGER i, j
DO i = 1, 3
DO j = 1, 7
arr (i, j) = 11.0 * i + j
END DO
END DO
END SUBROUTINE
See Also
General Compiler Directives
Syntax Rules for Compiler Directives
Programming with Mixed Languages Overview
1267
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
ATTRIBUTES ALIAS
The ATTRIBUTES directive option ALIAS specifies an
alternate external name to be used when referring to
external subprograms.
Syntax
!DIR$ ATTRIBUTES ALIAS: external-name:: subprogram
The ALIAS option overrides the C (and STDCALL) option. If both C and ALIAS are specified for a subprogram,
the subprogram is given the C calling convention, but not the C naming convention. It instead receives the
name given for ALIAS, with no modifications.
ALIAS cannot be used with internal procedures, and it cannot be applied to dummy arguments.
The following example gives the subroutine happy the name "_OtherName@4" outside this scoping unit:
INTERFACE
SUBROUTINE happy(i)
!DIR$ ATTRIBUTES STDCALL, DECORATE, ALIAS:'OtherName' :: happy
INTEGER i
END SUBROUTINE
END INTERFACE
!DIR$ ATTRIBUTES ALIAS has the same effect as the !DIR$ ALIAS directive.
See Also
ATTRIBUTES
Syntax Rules for Compiler Directives
ATTRIBUTES DECORATE
ATTRIBUTES ALIGN
The ATTRIBUTES directive option ALIGN specifies the
byte alignment for variables and for allocatable or
pointer components of derived types.
Syntax
!DIR$ ATTRIBUTES ALIGN: n:: object
1268
Language Reference
Objects that can be aligned by this directive include static local variables, automatic variables, module
variables, dynamically allocated arrays, allocatable array components of derived types, and the start of
common blocks. This directive cannot be used to align variables within common blocks
If you specify directive !DIR$ ATTRIBUTES ALIGN on an object with the ALLOCATABLE or POINTER attribute,
an ALLOCATE statement will attempt to use that alignment when the memory is allocated.
For allocatable or pointer components of derived types, the directive must appear within the derived-type
TYPE…END TYPE block.
If the TYPE is an extended type, the directive cannot reference a component in the parent type.
Example
Consider the following:
TYPE EXAMPLE
!DIR$ ATTRIBUTES ALIGN : 64 :: R_alloc
REAL, ALLOCATABLE :: R_alloc ( : )
REAL :: R_scalar
INTEGER :: I_nonalloc(25)
END TYPE EXAMPLE
See Also
ATTRIBUTES
ASSUME_ALIGNED directive
align compiler option (see setting arraynbyte)
Syntax Rules for Compiler Directives
ATTRIBUTES ALLOCATABLE
The ATTRIBUTES directive option ALLOCATABLE is
provided for compatibility with older programs. It lets
you delay allocation of storage for a particular
declared entity until some point at run time when you
explicitly call a routine that dynamically allocates
storage for the entity.
Syntax
!DIR$ ATTRIBUTES ALLOCATABLE :: entity
entity Is the name of the entity that should have allocation delayed.
The recommended method for dynamically allocating storage is to use the ALLOCATABLE statement or
attribute.
1269
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
ATTRIBUTES
Syntax Rules for Compiler Directives
ATTRIBUTES ALLOW_NULL
The ATTRIBUTES directive option ALLOW_NULL
enables a corresponding dummy argument to pass a
NULL pointer (defined by a zero or the NULL intrinsic)
by value for the argument.
Syntax
!DIR$ ATTRIBUTES ALLOW_NULL :: arg
ALLOW_NULL is only valid if ATTRIBUTES REFERENCE is also specified; otherwise, it has no effect.
See Also
ATTRIBUTES
Syntax Rules for Compiler Directives
Syntax
!DIR$ ATTRIBUTES C :: object[, object] ...
!DIR$ ATTRIBUTES STDCALL :: object[, object] ...
On Windows* systems on IA-32 architecture, C and STDCALL have slightly different meanings; on all other
platforms, STDCALL is treated as C.
When applied to a subprogram, these options define the subprogram as having a specific set of calling
conventions. The effects depend on whether or not the subprogram is interoperable (has the BIND attribute).
For interoperable subprograms with the BIND attribute, ATTRIBUTES STDCALL has the following effects for
subprograms in applications targeting Windows systems on IA-32 architecture:
• The STDCALL calling convention is used where the called subprogram cleans up the stack at exit.
• The external name has @n appended, where n is the number of bytes of arguments pushed on the stack.
No other effects of ATTRIBUTES STDCALL are applied for interoperable subprograms. If pass-by-value is
desired for a dummy argument to an interoperable subprogram, the Fortran standard VALUE attribute should
be specified for that argument.
For platforms other than Windows systems on IA-32 architecture, ATTRIBUTES STDCALL has no effect on
interoperable subprograms. You should not specify ATTRIBUTES C for interoperable subprograms.
The following table and subsequent text summarizes the differences between the calling conventions for
subprograms that are not interoperable:
Convention C 1 STDCALL 1 Default 2
1270
Language Reference
Case of external L*X, M*X: Lowercase L*X, M*X: Lowercase L*X, M*X: Lowercase
subprogram names
W*S: Lowercase W*S: Lowercase W*S: Uppercase
M*X only:
W*S only:
If C or STDCALL is specified for a subprogram, arguments (except for arrays and characters) are passed by
value. Subprograms using standard Fortran conventions pass arguments by reference.
On IA-32 architecture, an underscore ( _ ) is placed at the beginning of the external name of a subprogram.
If STDCALL is specified, an at sign (@) followed by the number of argument bytes being passed is placed at
the end of the name. For example, a subprogram named SUB1 that has three INTEGER(4) arguments and is
defined with STDCALL is assigned the external name _sub1@12.
Character arguments are passed as follows:
• By default, hidden lengths are put at the end of the argument list.
On Windows* systems using IA-32 architecture, you can get Compaq* Visual Fortran default behavior by
specifying compiler option iface.
• If C or STDCALL (only) is specified:
On all systems, the first character of the string is passed (and padded with zeros out to INTEGER(4)
length).
• If C or STDCALL is specified, and REFERENCE is specified for the argument:
On all systems, the string is passed with no length.
• If C or STDCALL is specified, and REFERENCE is specified for the routine (but REFERENCE is not specified
for the argument, if any):
On all systems, the string is passed with the length.
1271
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
ATTRIBUTES
REFERENCE
BIND
Syntax Rules for Compiler Directives
iface compiler option
Compiler Reference section: Mixed Language Programming
ATTRIBUTES CODE_ALIGN
The ATTRIBUTES directive option CODE_ALIGN
specifies the byte alignment for a procedure.
Syntax
!DIR$ ATTRIBUTES CODE_ALIGN: n:: procedure-name
This directive can be affected by compiler option -falign-loops (Linux* and macOS*) or /Qalign-loops
(Windows*), the CODE_ALIGN directive, and the CODE_ALIGN attribute.
If code is compiled with the -falign-loops=m (Linux and macOS*) or /Qalign-loops:m (Windows) option
and a procedure has the CODE_ALIGN:k attribute, the procedure is aligned on a MAX (m, k) byte boundary.
If a procedure has the CODE_ALIGN:k attribute and a CODE_ALIGN:n directive precedes a loop, then both
the procedure and the loop are aligned on a MAX (k, n) byte boundary.
Example
Consider the following code fragment in file test_align.f90:
FUNCTION F ()
!DIR$ ATTRIBUTES CODE_ALIGN:32 :: F
…
!DIR$ CODE_ALIGN:16
DO J = 1, N
…
END DO
…
END FUNCTION F
Compiling test_align.f90 with option -falign-loops=64 (Linux and macOS*) or /Qalign-loops:64
(Windows) aligns the function F and the DO J loop on 64-byte boundaries.
See Also
ATTRIBUTES
CODE_ALIGN directive
falign-loops, Qalign-loops compiler option
Syntax Rules for Compiler Directives
1272
Language Reference
ATTRIBUTES CONCURRENCY_SAFE
The ATTRIBUTES directive option
CONCURRENCY_SAFE specifies that there are no
unacceptable side effects and no illegal (or improperly
synchronized) memory access interferences among
multiple invocations of a routine or between an
invocation of the specified routine and other
statements in the program if they were executed
concurrently.
Syntax
!DIR$ ATTRIBUTES CONCURRENCY_SAFE [: clause] :: routine-name-list
When a CONCURRENCY_SAFE routine is called from parallelized code, you can ignore assumed cross-block or
cross-iteration dependencies and side effects of calling the specified routine from parallelized code.
The profitable clause indicates that the loops or blocks that contain calls to the routine can be safely
executed in parallel if the loop or blocks are legal to be parallelized; that is, if it is profitable to parallelize
them.
The cost clause indicates the execution cycles of the routine where the compiler can perform parallelization
profitability analysis while compiling its enclosing loops or blocks.
The attribute can appear in the declaration of the routine; for example:
function f(x)
!DIR$ attributes concurrency_safe :: f
The attribute can also appear in the code of the caller; for example:
main m
integer f
external f
!dir$ attributes concurrency_safe :: f ! or it could be in an interface block describing f
...
Print *, f(x)
NOTE
For every routine named in routine-name-list, you should ensure that any possible side effects are
acceptable or expected, and the memory access interferences are properly synchronized.
See Also
ATTRIBUTES
Syntax Rules for Compiler Directives
1273
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
ATTRIBUTES CVF
The ATTRIBUTES direction option CVF tells the
compiler to use calling conventions compatible with
Compaq Visual Fortran* and Microsoft Fortran
PowerStation.
Syntax
!DIR$ ATTRIBUTES CVF :: object[, object] ...
See Also
ATTRIBUTES
ATTRIBUTES DECORATE
The ATTRIBUTES directive option DECORATE specifies
that the external name used in !DIR$ ALIAS or !DIR$
ATTRIBUTES ALIAS should have the prefix and postfix
decorations performed on it that are associated with
the platform and calling mechanism that is in effect.
These are the same decorations performed on the
procedure name when ALIAS is not specified, except
that, on Linux* and macOS* systems, DECORATE
does not add a trailing underscore signifying a Fortran
procedure.
Syntax
!DIR$ ATTRIBUTES DECORATE :: exname
See Also
ATTRIBUTES
Syntax Rules for Compiler Directives
ATTRIBUTES ALIAS
The summary of prefix and postfix decorations in the description of the ATTRIBUTES options C and
STDCALL
1274
Language Reference
ATTRIBUTES DEFAULT
The ATTRIBUTES directive option DEFAULT overrides
certain compiler options that can affect external
routine and COMMON block declarations.
Syntax
c!DIR$ ATTRIBUTES DEFAULT :: entity
It specifies that the compiler should ignore compiler options that change the default conventions for external
symbol naming and argument passing for routines and COMMON blocks (such as names, assume underscore,
assume 2underscores on Linux systems, and iface on Windows* systems).
This option can be combined with other ATTRIBUTES options, such as STDCALL, C, REFERENCE, ALIAS, etc.
to specify properties different from the compiler defaults.
This option is useful when declaring INTERFACE blocks for external routines, since it prevents compiler
options from changing calling or naming conventions.
See Also
ATTRIBUTES
Syntax Rules for Compiler Directives
iface compiler option
names compiler option
assume compiler option
Syntax
!DIR$ ATTRIBUTES DLLEXPORT :: object[, object] ...
!DIR$ ATTRIBUTES DLLIMPORT :: object[, object] ...
DLLEXPORT and DLLIMPORT define the interface for the following dynamic-link libraries:
• DLL on Windows*
• DYLIB on macOS*
DLLEXPORT specifies that procedures or data are being exported to other applications or dynamic libraries.
This causes the compiler to produce efficient code; for example, eliminating the need on Windows systems
for a module definition (.def) file to export symbols.
DLLEXPORT should be specified in the routine to which it applies. If the routine's implementation is in a
submodule, specify DLLEXPORT in the parent module's INTERFACE block for the routine. If MODULE
PROCEDURE is used in the submodule, the DLLEXPORT attribute will be inherited; otherwise you must also
specify DLLEXPORT in the submodule routine.
1275
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Symbols defined in a DLL are imported by programs that use them. On Windows*, the program must link
with the DLL import library (.lib).
The DLLIMPORT option is used inside the program unit that imports the symbol. DLLIMPORT is specified in a
declaration, not a definition, since you cannot define a symbol you are importing.
See Also
ATTRIBUTES
Syntax Rules for Compiler Directives
ATTRIBUTES EXTERN
The ATTRIBUTES directive option EXTERN specifies
that a variable is allocated in another source file.
EXTERN can be used in global variable declarations,
but it must not be applied to dummy arguments.
Syntax
!DIR$ ATTRIBUTES EXTERN :: var
This option must be used when accessing variables declared in other languages.
See Also
ATTRIBUTES
Syntax Rules for Compiler Directives
Syntax
The INLINE option specifies that a function or subroutine can be inlined. The inlining can be ignored by the
compiler if inline heuristics determine it may have a negative impact on performance or will cause too much
of an increase in code size.
!DIR$ ATTRIBUTES INLINE :: procedure
The FORCEINLINE option specifies that a function or subroutine must be inlined unless it will cause errors.
!DIR$ ATTRIBUTES FORCEINLINE :: procedure
See Also
ATTRIBUTES
Syntax Rules for Compiler Directives
1276
Language Reference
ATTRIBUTES IGNORE_LOC
The ATTRIBUTES directive option IGNORE_LOC
enables %LOC to be stripped from an argument.
Syntax
!DIR$ ATTRIBUTES IGNORE_LOC :: arg
IGNORE_LOC is only valid if ATTRIBUTES REFERENCE is also specified; otherwise, it has no effect.
See Also
ATTRIBUTES
Syntax Rules for Compiler Directives
Syntax
!DIR$ ATTRIBUTES MIXED_STR_LEN_ARG :: procs
!DIR$ ATTRIBUTES NOMIXED_STR_LEN_ARG :: procs
See Also
ATTRIBUTES directive
Syntax Rules for Compiler Directives
iface compiler option
ATTRIBUTES NO_ARG_CHECK
The ATTRIBUTES directive option NO_ARG_CHECK
specifies that type and shape matching rules related
to explicit interfaces are to be ignored. This permits
the construction of an INTERFACE block for an
external procedure or a module procedure that
accepts an argument of any type or shape; for
example, a memory copying routine.
Syntax
!DIR$ ATTRIBUTES NO_ARG_CHECK :: object
1277
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NO_ARG_CHECK can appear only in an INTERFACE block for a non-generic procedure or in a module
procedure. It can be applied to an individual dummy argument name or to the routine name, in which case
the option is applied to all dummy arguments in that interface.
NO_ARG_CHECK cannot be used for procedures with the PURE or ELEMENTAL prefix.
See Also
ATTRIBUTES
Syntax Rules for Compiler Directives
ATTRIBUTES NOCLONE
The ATTRIBUTES directive option NOCLONE can be
used to prevent a procedure from being considered for
cloning, which is a mechanism performed by
interprocedural constant propagation that produces
specialized copies of the procedure.
Syntax
!DIR$ ATTRIBUTES NOCLONE :: procedure
Note that if you specify ATTRIBUTES NOINLINE, it does not prevent this cloning.
See Also
ATTRIBUTES
Syntax Rules for Compiler Directives
ATTRIBUTES INLINE
ATTRIBUTES OPTIMIZATION_PARAMETER
The ATTRIBUTES directive option
OPTIMIZATION_PARAMETER passes certain
information about a procedure or main program to the
optimizer.
Syntax
!DIR$ ATTRIBUTES OPTIMIZATION_PARAMETER: string::{ procedure-name | named-main-program}
• TARGET_ARCH= cpu
Tells the compiler to generate code specialized for a particular
processor. For the list of cpus you can specify, see option [Q]x.
• G2S = {ON | OFF}
Disables or enables the use of gather/scatter instructions in the
specified program unit.
ON tells the optimizer to disable the generation of gather/scatter
and to transform gather/scatter into unit-strided loads/stores plus
a set of shuffles wherever possible.
1278
Language Reference
Description
The characters in string can appear in any combination of uppercase and lowercase. The following rules also
apply to string:
• If string does not contain an equal sign (=), then the entire value of string is converted to lowercase
before being passed to the optimizer.
• If string contains an equal sign, then all characters to the left of the equal sign are converted to lowercase
before all of string is passed to the optimizer.
Characters to the right of the equal sign are not converted to lowercase since their value may be case
sensitive to the optimizer, for example “target_arch=AVX”.
You can specify multiple ATTRIBUTES OPTIMIZATION_PARAMETER directives for one procedure or one main
program.
For the named procedure or main program, the values specified for ATTRIBUTES OPTIMIZATION_PARAMETER
override any settings specified for the following compiler options:
1279
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
Consider the two attributes optimization_parameter directives in the following code:
function f (x)
!dir$ attributes optimization_parameter: “inline_max_per_routine=10” :: f
!dir$ attributes optimization_parameter: “inline_max_total_size=2000” :: f
real :: f, x
…
The two directives have the same effect as if the function F had been complied with
"/Qinline-max-per-routine:10 /Qinline-max-total-size:2000" on Windows* or with
"-inline-max-per-routine=10 -inline-max-total-size=2000" on Linux* or macOS*, that is, inlining
will not increase the size of F by more than 2000 and the inliner will not inline routines into F more than 10
times.
See Also
ATTRIBUTES
Syntax Rules for Compiler Directives
x, Qx compiler option
inline-max-per-routine, Qinline-max-per-routine compiler option
inline-max-total-size, Qinline-max-total-size compiler option
Syntax
!DIR$ ATTRIBUTES REFERENCE :: arg
!DIR$ ATTRIBUTES VALUE :: arg
REFERENCE specifies a dummy argument's memory location is to be passed instead of the argument's value.
VALUE specifies a dummy argument's value is to be passed instead of the argument's memory location.
When VALUE is specified for a dummy argument, the actual argument passed to it can be of a different type.
If necessary, type conversion is performed before the subprogram is called.
When a complex (KIND=4 or KIND=8) argument is passed by value, two floating-point arguments (one
containing the real part, the other containing the imaginary part) are passed by immediate value.
Character values, substrings, assumed-size arrays, and adjustable arrays cannot be passed by value.
If REFERENCE (only) is specified for a character argument, the string is passed with no length.
If REFERENCE is specified for a character argument, and C (or STDCALL) has been specified for the routine,
the string is passed with no length. This is true even if REFERENCE is also specified for the routine.
If REFERENCE and C (or STDCALL) are specified for a routine, but REFERENCE has not been specified for the
argument, the string is passed with the length.
VALUE is the default if the C or STDCALL option is specified in the subprogram definition.
In the following example integer x is passed by value:
1280
Language Reference
See Also
C and STDCALL
ATTRIBUTES
Syntax Rules for Compiler Directives
Mixed Language Programming: Adjusting Calling Conventions in Mixed-Language Programming Overview
ATTRIBUTES VARYING
The ATTRIBUTES directive option VARYING allows a
Fortran routine to call a C/C++ routine with a variable
number of arguments.
Syntax
!DIR$ ATTRIBUTES VARYING :: var[, var] ...
This attribute can be used in an interface block to create an explicit interface for a C/C++ routine or it can be
used on a variable declared EXTERN that represents a C/C++ routine. When the routine is called from the
Fortran code, a variable number of arguments can be specified.
This attribute cannot be used with a Fortran routine declaration.
If ATTRIBUTES VARYING is specified, the C calling convention must also be used, either implicitly or explicitly.
All actual arguments in the routine call are passed to the called routine, regardless of the number of dummy
arguments specified in the interface. If the called routine tries to access a dummy argument that has no
matching actual argument, it causes a user error and the program may fail unpredictably.
See Also
ATTRIBUTES
Syntax Rules for Compiler Directives
ATTRIBUTES VECTOR
The ATTRIBUTES directive option VECTOR tells the
compiler to vectorize the specified function or
subroutine.
Syntax
!DIR$ ATTRIBUTES [att,] VECTOR [:clause] [, att]... :: routine-name
!DIR$ ATTRIBUTES [att,] VECTOR :(clause [, clause]...) [, att] :: routine-name
1281
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Tells the compiler that the values of the specified arguments can be
broadcasted to all iterations as a performance optimization.
Multiple UNIFORM clauses are merged as a union.
• VECTORLENGTH (n[, n]…)
Tells the compiler that each routine invocation at the call site
should execute the computation equivalent to n times the scalar
function execution.
The VECTORLENGTH and VECTORLENGTHFOR clauses are mutually
exclusive. You cannot use the VECTORLENGTH clause with the
VECTORLENGTHFOR clause, and vice versa.
Multiple VECTORLENGTH clauses cause a syntax error.
• VECTORLENGTHFOR (data-type)
INTEGER(1) INTEGER
(KIND=1)
INTEGER(2) INTEGER
(KIND=2)
INTEGER(4) INTEGER
(KIND=4)
INTEGER(8) INTEGER
(KIND=8)
1282
Language Reference
COMPLEX(4) COMPLEX
(KIND=4)
COMPLEX(8) COMPLEX
(KIND=8)
If you specify more than one clause, they must be separated by commas and enclosed in parentheses.
When you specify the ATTRIBUTES VECTOR directive, the compiler provides data parallel semantics by
combining with the vectorized operations or loops at the call site. When multiple instances of the vector
declaration are invoked in a parallel context, the execution order among them is not sequenced. If you
specify one or more clauses, they affect the data parallel semantics provided by the compiler.
If you specify the ATTRIBUTES VECTOR directive with no VECTORLENGTH clause, a default VECTORLENGTH is
computed based on efficiency heuristics of the vectorizer and the following:
• The return type of the function, if the function has a return type.
• The data type of the first non-scalar argument (that is, the first argument that is specified in the scalar
clause), if any.
• Default integer type, if neither of the above is supplied.
1283
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If you do not explicitly specify a VECTORLENGTH clause, the compiler will choose a VECTORLENGTH using its
own cost model.
If you specify the ATTRIBUTES VECTOR directive with no clause, the compiler will generate vector code based
on compiler efficiency heuristics and whatever processor compiler options are specified.
The VECTOR attribute implies the C attribute, so that when you specify the VECTOR attribute on a routine,
the C attribute is automatically also set on the same routine. This changes how the routine name is
decorated and how arguments are passed.
NOTE
You should ensure that any possible side effects for the specified routine-name are acceptable or
expected, and the memory access interferences are properly synchronized.
The Fortran Standard keyword ELEMENTAL specifies that a procedure written with scalar arguments can be
extended to conforming array arguments by processing the array elements one at a time in any order. The
ATTRIBUTES VECTOR directive tells the optimizer to produce versions of the procedure routine-name that
execute with contiguous slices of the array arguments as defined by the VECTORLENGTH clause in an
"elemental" fashion. routine-name does not need to be defined as ELEMENTAL to be given the VECTOR
attribute.
The VECTOR attribute causes the compiler to generate a short vector form of the procedure, which can
perform the procedure's operation on multiple elements of its array arguments in a single invocation. The
short vector version may be able to perform multiple operations as fast as the regular implementation
performs a single operation by using the vector instruction set in the CPU.
In addition, when invoked from an OMP construct, the compiler may assign different copies of the elemental
procedures to different threads, executing them concurrently. The end result is that your data parallel
operation executes on the CPU using both the parallelism available in the multiple cores and the parallelism
available in the vector instruction set. If the short vector procedure is called inside a parallel loop or an auto-
parallelized loop that is vectorized, you can achieve both vector-level and thread-level parallelism.
The INTENT(OUT) or INTENT(INOUT) attribute is not allowed for arguments of a procedure with the VECTOR
attribute since the VECTOR attribute forces the procedure to receive its arguments by value.
The Intel C/C++ compiler built in function __intel_simd_lane() may be helpful in removing certain
performance penalties caused by non-unit stride vector access. Consider the following:
interface
! returns a number between 0 and vectorlength – 1 that reflects the current “lane id” within the
SIMD vector
! __intel_simd_lane() will return zero if the loop is not vectorized
function for_simd_lane () bind (C, name = “__intel_simd_lane”)
integer (kind=4) :: for_simd_lane
!DEC$ attributes known_intrinsic, default :: for_simd_lane
end function for_simd_lane
end interface
For more details, see the Intel C++ documentation.
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
1284
Language Reference
Example
The ATTRIBUTES VECTOR directive must be accessible in the caller, either via an INTERFACE block or by USE
association.
The following shows an example of an external function with an INTERFACE block:
function f(x)
!dir$ attributes vector :: f
real :: f, x
...
! attribute vector explicit in calling procedure using an INTERFACE
interface
function f(x)
!dir$ attributes vector :: f
real :: f, x
end
end interface
...
do i=1,n
z(i) = f( x(i) )
end do
The ATTRIBUTES VECTOR directive can be brought into the caller by USE association if the vector function is
a module procedure; for example:
module use_vect
contains
function f(x)
!dir$ attributes vector :: f
real :: f, x
...
end function
end module use_vect
! USE and call of f(x) from another procedure with a module USE statement
do i=1,n
z(i) = f( x(i) )
end do
You can specify more than one SCALAR or LINEAR clause in an ATTRIBUTES VECTOR directive. For example,
all of the following are valid:
1285
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The three directives above are equivalent to specifying a single, continued, directive in fixed-form source, as
follows:
See Also
ATTRIBUTES
Syntax Rules for Compiler Directives
AUTOAddArg (W*S)
AUTO Subroutine: Passes an argument name and
value and adds the argument to the argument list
data structure.
Module
USE IFAUTO
USE IFWINTY
Syntax
CALL AUTOAddArg (invoke_args,name,value[,intent_arg][,type])
intent_arg Indicates the intended use of the argument by the called method.
Must be one of the following constants defined in the IFAUTO module:
• AUTO_ARG_IN: The argument's value is read by the called method,
but not written. This is the default value if intent_arg is not
specified.
• AUTO_ARG_OUT: The argument's value is written by the called
method, but not read.
• AUTO_ARG_INOUT: The argument's value is read and written by
the called method.
When the value of intent_arg is AUTO_ARG_OUT or
AUTO_ARG_INOUT, the variable used in the value argument should
be declared using the VOLATILE attribute. This is because the value of
the variable will be changed by the subsequent call to AUTOInvoke.
The compiler's global optimizations need to know that the value can
change unexpectedly.
type The variant type of the argument. Must be one of the following
constants defined in the IFWINTY module:
1286
Language Reference
VT_I1 INTEGER(1)
VT_I2 INTEGER(2)
VT_I4 INTEGER(4)
VT_R4 REAL(4)
VT_R8 REAL(8)
VT_CY REAL(8)
VT_DATE REAL(8)
VT_BSTR CHARACTER*(*)
VT_DISPATCH INTEGER(4)
VT_ERROR INTEGER(4)
VT_BOOL LOGICAL(2)
VT_VARIANT TYPE(VARIANT)
VT_UNKNOWN INTEGER(4)
Example
See the example in COMInitialize.
AUTOAllocateInvokeArgs (W*S)
AUTO Function: Allocates an argument list data
structure that holds the arguments to be passed to
AUTOInvoke.
Module
USE IFAUTO
Syntax
result = AUTOAllocateInvokeArgs( )
Results
The value returned is an argument list data structure of type INTEGER(INT_PTR_KIND()).
Example
See the example in COMInitialize.
AUTODeallocateInvokeArgs (W*S)
AUTO Subroutine: Deallocates an argument list data
structure.
Module
USE IFAUTO
1287
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
CALL AUTODeallocateInvokeArgs (invoke_args)
Example
See the example in COMInitialize.
AUTOGetExceptInfo (W*S)
AUTO Subroutine: Retrieves the exception
information when a method has returned an exception
status.
Module
USE IFAUTO
Syntax
CALL AUTOGetExceptInfo (invoke_args,code,source,description,h_file,h_context,scode)
code An output argument that returns the error code. Must be of type
INTEGER(2).
h_file An output argument that returns the fully qualified path of a Help file
with more information about the error. Must be of type
CHARACTER*(*).
h_context An output argument that returns the Help context of the topic within
the Help file. Must be of type INTEGER(4).
scode An output argument that returns an SCODE describing the error. Must
be of type INTEGER(4).
AUTOGetProperty (W*S)
AUTO Function: Passes the name or identifier of the
property and gets the value of the automation object's
property.
Module
USE IFAUTO
USE IFWINTY
Syntax
result = AUTOGetProperty (idispatch,id,value[,type])
1288
Language Reference
type The variant type of the requested argument. Must be one of the
following constants defined in the IFWINTY module:
VT_I2 INTEGER(2)
VT_I4 INTEGER(4)
VT_R4 REAL(4)
VT_R8 REAL(8)
VT_CY REAL(8)
VT_DATE REAL(8)
VT_BSTR CHARACTER*(*)
VT_DISPATCH INTEGER(4)
VT_ERROR INTEGER(4)
VT_BOOL LOGICAL(2)
VT_UNKNOWN INTEGER(4)
Results
Returns an HRESULT describing the status of the operation. Must be of type INTEGER(4).
AUTOGetPropertyByID (W*S)
AUTO Function: Passes the member ID of the
property and gets the value of the automation object's
property into the argument list's first argument.
Module
USE IFAUTO
Syntax
result = AUTOGetPropertyByID (idispatch,memid,invoke_args)
1289
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
Returns an HRESULT describing the status of the operation. Must be of type INTEGER(4).
AUTOGetPropertyInvokeArgs (W*S)
AUTO Function: Passes an argument list data
structure and gets the value of the automation
object's property specified in the argument list's first
argument.
Module
USE IFAUTO
Syntax
result = AUTOGetPropertyInvokeArgs (idispatch,invoke_args)
Results
Returns an HRESULT describing the status of the operation. Must be of type INTEGER(INT_PTR_KIND()).
AUTOInvoke (W*S)
AUTO Function: Passes the name or identifier of an
object's method and an argument list data structure
and invokes the method with the passed arguments.
Module
USE IFAUTO
Syntax
result = AUTOInvoke (idispatch,id,invoke_args)
Results
Returns an HRESULT describing the status of the operation. Must be of type INTEGER(4).
Example
See the example in COMInitialize.
1290
Language Reference
AUTOMATIC
Statement and Attribute: Controls the storage
allocation of variables in subprograms (as does
STATIC). Variables declared as AUTOMATIC and
allocated in memory reside in the stack storage area,
rather than at a static memory location.
Syntax
The AUTOMATIC attribute can be specified in a type declaration statement or an AUTOMATIC statement, and
takes one of the following forms:
Type Declaration Statement:
type, [att-ls,] AUTOMATIC [, att-ls] :: v[, v] ...
Statement:
AUTOMATIC [::] v[, v] ...
NOTE
Variables that are data-initialized, and variables in COMMON and SAVE statements are always static.
This is regardless of whether a compiler option specifies recursion.
A variable cannot be specified as AUTOMATIC more than once in the same scoping unit.
If the variable is a pointer, AUTOMATIC applies only to the pointer itself, not to any associated target.
Some variables cannot be specified as AUTOMATIC. The following table shows these restrictions:
1291
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Variable AUTOMATIC
Dummy argument No
Automatic object No
Use-associated item No
Function result No
Example
The following example shows a type declaration statement specifying the AUTOMATIC attribute:
REAL, AUTOMATIC :: A, B, C
The following example uses an AUTOMATIC statement:
...
CONTAINS
INTEGER FUNCTION REDO_FUNC
INTEGER I, J(10), K
REAL C, D, E(30)
AUTOMATIC I, J, K(20)
STATIC C, D, E
...
END FUNCTION
...
C In this example, all variables within the program unit
C are saved, except for "var1" and "var3". These are
C explicitly declared in an AUTOMATIC statement, and thus have
C memory locations on the stack:
SUBROUTINE DoIt (arg1, arg2)
INTEGER(4) arg1, arg2
INTEGER(4) var1, var2, var3, var4
SAVE
AUTOMATIC var1, var3
C var2 and var4 are saved
See Also
heap-arrays compiler option
recursive compiler option
STATIC
SAVE
Type Declarations
Compatible attributes
RECURSIVE
OPTIONS
POINTER
1292
Language Reference
AUTOSetProperty (W*S)
AUTO Function: Passes the name or identifier of the
property and a value, and sets the value of the
automation object's property.
Module
USE IFAUTO
USE IFWINTY
Syntax
result = AUTOSetProperty (idispatch,id,value[,type])
type The variant type of the argument. Must be one of the following
constants defined in the IFWINTY module:
VT_I2 INTEGER(2)
VT_I4 INTEGER(4)
VT_R4 REAL(4)
VT_R8 REAL(8)
VT_CY REAL(8)
VT_DATE REAL(8)
VT_BSTR CHARACTER*(*)
VT_DISPATCH INTEGER(4)
VT_ERROR INTEGER(4)
VT_BOOL LOGICAL(2)
VT_UNKNOWN INTEGER(4)
Results
Returns an HRESULT describing the status of the operation. Must be of type INTEGER(4).
1293
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
AUTOSetPropertyByID (W*S)
AUTO Function: Passes the member ID of the
property and sets the value of the automation object's
property into the argument list's first argument.
Module
USE IFAUTO
Syntax
result = AUTOSetPropertyByID (idispatch,memid,invoke_args)
Results
Returns an HRESULT describing the status of the operation. Must be of type INTEGER(4).
AUTOSetPropertyInvokeArgs (W*S)
AUTO Function: Passes an argument list data
structure and sets the value of the automation
object's property specified in the argument list's first
argument.
Module
USE IFAUTO
Syntax
result = AUTOSetPropertyInvokeArgs (idispatch,invoke_args)
Results
Returns an HRESULT describing the status of the operation. Must be of type INTEGER(4).
BACKSPACE
Statement: Positions a sequential file at the
beginning of the preceding record, making it available
for subsequent I/O processing. It takes one of the
following forms:
Syntax
BACKSPACE ([UNIT=]io-unit[, ERR=label] [, IOMSG=msg-var] [, IOSTAT=i-var])
1294
Language Reference
BACKSPACE io-unit
label Is the label of the branch target statement that receives control if an
error occurs.
Description
The I/O unit number must specify an open file on disk or magnetic tape.
Backspacing from the current record n is performed by rewinding to the start of the file and then performing
n - 1 successive READs to reach the previous record.
A BACKSPACE statement must not be specified for a file that is open for direct or append access, because n
is not available to the Fortran I/O system.
BACKSPACE cannot be used to skip over records that have been written using list-directed or namelist
formatting.
If a file is already positioned at the beginning of a file, a BACKSPACE statement has no effect.
If the file is positioned between the last record and the end-of-file record, BACKSPACE positions the file at
the start of the last record.
Example
BACKSPACE 5
BACKSPACE (5)
BACKSPACE lunit
BACKSPACE (UNIT = lunit, ERR = 30, IOSTAT = ios)
The following statement repositions the file connected to I/O unit 4 back to the preceding record:
BACKSPACE 4
Consider the following statement:
See Also
REWIND
ENDFILE
Data Transfer I/O Statements
Branch Specifiers
BADDRESS
Inquiry Intrinsic Function (Generic): Returns the
address of an argument. This function cannot be
passed as an actual argument. This function can also
be specified as IADDR.
1295
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
result = BADDRESS (x)
Results
The result type is INTEGER(4) on IA-32 architecture; INTEGER(8) on Intel® 64 architecture. The value of the
result represents the address of the data object or, in the case of pointers, the address of its associated
target. If the argument is not valid, the result is undefined.
Example
PROGRAM batest
INTEGER X(5), I
DO I=1, 5
PRINT *, BADDRESS(X(I))
END DO
END
BARRIER
OpenMP* Fortran Compiler Directive:
Synchronizes all the threads in a team. It causes each
thread to wait until all of the other threads in the
team have reached the barrier.
Syntax
!$OMP BARRIER
The binding thread set for a BARRIER construct is the current team. A barrier region binds to the innermost
enclosing parallel region.
Each barrier region must be encountered by all threads in a team or by none at all, unless cancellation has
been requested for the innermost enclosing parallel region.
The barrier region must also be encountered in the same order by all threads in a team.
Example
INTEGER K
K = 17
1296
Language Reference
!$OMP BARRIER
IF (OMP_GET_THREAD_NUM() == 0) THEN
PRINT *,"2: THREAD# ", OMP_GET_THREAD_NUM (), "K = ", K
ELSE
PRINT *,"3: THREAD# ", OMP_GET_THREAD_NUM (), "K = ", K
ENDIF
!$OMP END PARALLEL
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
Nesting and Binding Rules
Parallel Processing Model for information about Binding Sets
BEEPQQ
Portability Subroutine: Sounds the speaker at the
specified frequency for the specified duration in
milliseconds.
Module
USE IFPORT
Syntax
CALL BEEPQQ (frequency,duration)
Example
USE IFPORT
INTEGER(4) frequency, duration
frequency = 4000
duration = 1000
CALL BEEPQQ(frequency, duration)
See Also
SLEEPQQ
Module
USE IFPORT
1297
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
result = BESJ0 (value)
result = BESJ1 (value)
result = BESJN (n, value)
result = BESY0 (posvalue)
result = BESY1 (posvalue)
result = BESYN (n, value)
Results
BESJ0, BESJ1, and BESJN return Bessel functions of the first kind, orders 0, 1, and n, respectively, with the
independent variable posvalue.
BESY0, BESY1, and BESYN return Bessel functions of the second kind, orders 0, 1, and n, respectively, with
the independent variable posvalue.
Negative arguments cause BESY0, BESY1, and BESYN to return QNAN.
Bessel functions are explained more fully in most mathematics reference books, such as the Handbook of
Mathematical Functions (Abramowitz and Stegun. Washington: U.S. Government Printing Office, 1964).
These functions are commonly used in the mathematics of electromagnetic wave theory.
See the descriptions of the BESSEL_* functions, if you need to use quad-precision (REAL(16)).
See Also
DBESJ0, DBESJ1, DBESJN
BESSEL_J0
Elemental Intrinsic Function (Generic): Computes
a Bessel function of the first kind, order 0.
Syntax
result = BESSEL_J0 (x)
Results
The result type and kind are the same as x.
The result has a value equal to a processor-dependent approximation to the Bessel function of the first kind
and order zero of x.
Example
BESSEL_J0 (1.0) has the approximate value 0.765.
1298
Language Reference
BESSEL_J1
Elemental Intrinsic Function (Generic): Computes
a Bessel function of the first kind, order 1.
Syntax
result = BESSEL_J1 (x)
Results
The result type and kind are the same as x.
The result has a value equal to a processor-dependent approximation to the Bessel function of the first kind
and order 1 of x.
Example
BESSEL_J1 (1.0) has the approximate value 0.440.
BESSEL_JN
Elemental and Transformational Intrinsic
Functions (Generic): Compute Bessel functions of
the first kind.
Syntax
Elemental function: result = BESSEL_JN (n, x)
Transformational function: result = BESSEL_JN (n1, n2, x)
Results
The result type and kind are the same as x.
The result of BESSEL_JN (n, x) is scalar. The result value of BESSEL_JN (n , x) is a processor-dependent
approximation to the Bessel function of the first kind and order n of x.
The result of BESSEL_JN (n1, n2, x) is a rank-one array with extent MAX (n2 - n1 + 1, 0). Element i of the
result value of BESSEL_JN (n1, n2, x) is a processor-dependent approximation to the Bessel function of the
first kind and order n1 + i - 1 of x.
Example
BESSEL_JN (2, 1.0) has the approximate value 0.115.
Consider the following program Bessel.90:
1299
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
BESSEL_Y0
Elemental Intrinsic Function (Generic): Computes
a Bessel function of the second kind, order 0.
Syntax
result = BESSEL_Y0 (x)
Results
The result type and kind are the same as x.
The result has a value equal to a processor-dependent approximation to the Bessel function of the second
kind and order zero of x.
Example
BESSEL_Y0 (1.0) has the approximate value 0.088.
BESSEL_Y1
Elemental Intrinsic Function (Generic): Computes
a Bessel function of the second kind, order 1.
Syntax
result = BESSEL_Y1 (x)
Results
The result type and kind are the same as x.
The result has a value equal to a processor-dependent approximation to the Bessel function of the second
kind and order 1 of x.
Example
BESSEL_Y1 (1.0) has the approximate value -0.781.
BESSEL_YN
Elemental and Transformational Intrinsic
Functions (Generic): Compute Bessel functions of
the second kind.
1300
Language Reference
Syntax
Elemental function: result = BESSEL_YN (n, x)
Transformational function: result = BESSEL_YN (n1, n2, x)
Results
The result type and kind are the same as x.
The result of BESSEL_YN (n, x) is scalar. The result value of BESSEL_YN (n , x) is a processor-dependent
approximation to the Bessel function of the second kind and order n of x.
The result of BESSEL_YN (n1, n2, x) is a rank-one array with extent MAX (n2 - n1 + 1, 0). Element i of the
result value of BESSEL_YN (n1, n2, x) is a processor-dependent approximation to the Bessel function of the
second kind and order n1 + i - 1 of x.
Example
BESSEL_YN (2, 1.0) has the approximate value -1.651.
BGE
Elemental Intrinsic Function (Generic): Performs
a bitwise greater than or equal to on its arguments.
Syntax
result = BGE (i,j)
If the kinds of i and j do not match, the value with the smaller kind is extended with zeros on the left and
the larger kind is used for the operation and the result.
Results
The result is true if the sequence of bits represented by i is greater than or equal to the sequence of bits
represented by j, according to the method of bit sequence comparison in Bit Sequence Comparisons;
otherwise, the result is false.
The interpretation of a binary, octal, or hexadecimal literal constant as a sequence of bits is described in
Binary, Octal, Hexadecimal, and Hollerith Constants.
The model for the interpretation of an integer value as a sequence of bits is shown in Model for Bit Data.
Example
If BIT_SIZE (J) has the value 8, BGE (Z'FF', J) has the value true for any value of J. BGE (0, -1) has the
value false.
See Also
BIT_SIZE
1301
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
BGT
Elemental Intrinsic Function (Generic): Performs
a bitwise greater than on its arguments.
Syntax
result = BGT (i,j)
If the kinds of i and j do not match, the value with the smaller kind is extended with zeros on the left and
the larger kind is used for the operation and the result.
Results
The result is true if the sequence of bits represented by i is greater than the sequence of bits represented by
j, according to the method of bit sequence comparison in Bit Sequence Comparisons; otherwise, the result is
false.
The interpretation of a binary, octal, or hexadecimal literal constant as a sequence of bits is described in
Binary, Octal, Hexadecimal, and Hollerith Constants.
The model for the interpretation of an integer value as a sequence of bits is shown in Model for Bit Data.
Example
BGT (Z'FF', Z'FC') has the value true. BGT (0, -2) has the value false.
BIC, BIS
Portability Subroutines: Perform a bit-level set and
clear for integers.
Module
USE IFPORT
Syntax
CALL BIC (bitnum, target)
CALL BIS (bitnum, target)
bitnum (Input) INTEGER(4). Bit number to set. Must be in the range 0 (least
significant bit) to 31 (most significant bit) if target is INTEGER(4). If
target is INTEGER(8), bitnum must be in range 0 to 63.
1302
Language Reference
Example
Consider the following:
USE IFPORT
integer(4) bitnum, target_i4
integer(8) target_i8
target_i4 = Z'AAAA'
bitnum = 1
call BIC(bitnum, target_i4)
target_i8 = Z'FFFFFFFF00000000'
bitnum = 40
call BIC(bitnum, target_i8)
bitnum = 0
call BIS(bitnum, target_i4)
bitnum = 1
call BIS(bitnum, target_i8)
print '(" integer*4 result ",Z)', target_i4
print '(" integer*8 result ",Z)', target_i8
end
See Also
BIT
BIND
Statement and Attribute: Specifies that an object is
interoperable with C and has external linkage.
Syntax
The BIND attribute can be specified in a type declaration statement or a BIND statement, and takes one of
the following forms:
Type Declaration Statement:
type, [att-ls, ] BIND (C [, NAME=ext-name]) [, att-ls] :: object
Statement:
BIND (C [, NAME=ext-name]) [::] object
object Is the name of a variable or common block. It can also be the name of
an internal procedure if NAME= is not specified.
Description
If a common block is specified in a BIND statement, it must be specified with the same binding label in each
scoping unit in which it is declared.
For variables and common blocks, BIND also implies the SAVE attribute, which may be explicitly confirmed
with SAVE.
A variable given the BIND attribute (or declared in a BIND statement) must appear in the specification part
of a module. You cannot specify BIND for a subroutine local variable or a variable in a main program.
The BIND attribute is similar to directive !DIR$ ATTRIBUTES C as follows:
1303
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• The compiler applies the same naming rules, that is, names are lowercase (unless NAME= specifies
otherwise).
• The compiler applies the appropriate platform decoration, such as a leading underscore.
However, procedure argument passing differs. When BIND is specified, procedure arguments are passed by
reference unless the VALUE attribute is also specified.
The BIND attribute can optionally be used in a PROCEDURE, SUBROUTINE, or FUNCTION declaration. It must
be used in an ENUM declaration.
Example
The following example shows the BIND attribute used in a type declaration statement, a statement, and a
SUBROUTINE statement.
BIND(C,NAME='SharedCommon') :: /SHAREDCOMMON/
! you need empty parens after the subroutine name if BIND is present
SUBROUTINE FOOBAR() BIND(C, NAME='FooBar')
...
END SUBROUTINE
See Also
Modules and Module Procedures
Type Declarations
Compatible attributes
Pointer Assignments
FUNCTION
SUBROUTINE
PROCEDURE
BIND(C)
in mixed language programming
BIT
Portability Function: Performs a bit-level test for
integers.
Module
USE IFPORT
Syntax
result = BIT (bitnum, source)
1304
Language Reference
bitnum (Input) INTEGER(4). Bit number to test. Must be in the range 0 (least
significant bit) to 31 (most significant bit).
Results
The result type is logical. It is .TRUE. if bit bitnum of source is 1; otherwise, .FALSE..
See Also
BIC, BIS
BIT_SIZE
Inquiry Intrinsic Function (Generic): Returns the
number of bits in an integer type.
Syntax
result = BIT_SIZE (i)
Results
The result is a scalar integer with the same kind parameter as i. The result value is the number of bits (s)
defined by the bit model for integers with the kind parameter of the argument. For information on the bit
model, see Model for Bit Data.
Example
BIT_SIZE (1_2) has the value 16 because the KIND=2 integer type contains 16 bits.
See Also
BTEST
IBCLR
IBITS
IBSET
BLE
Elemental Intrinsic Function (Generic): Performs
a bitwise less than or equal to on its arguments.
Syntax
result = BLE (i,j)
If the kinds of i and j do not match, the value with the smaller kind is extended with zeros on the left and
the larger kind is used for the operation and the result.
1305
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result is true if the sequence of bits represented by i is less than or equal to the sequence of bits
represented by j, according to the method of bit sequence comparison in Bit Sequence Comparisons;
otherwise, the result is false.
The interpretation of a binary, octal, or hexadecimal literal constant as a sequence of bits is described in
Binary, Octal, Hexadecimal, and Hollerith Constants.
The model for the interpretation of an integer value as a sequence of bits is shown in Model for Bit Data.
Example
BLE (0, J) has the value true for any value of J. BLE (-2, 0) has the value false.
BLOCK
Statement: Marks the beginning of a BLOCK
construct. The BLOCK construct executes a block of
statements or constructs that can contain
declarations.
Syntax
[name:] BLOCK
[specification-part]
block
END BLOCK [name]
1306
Language Reference
Description
A BLOCK construct is itself a scoping unit. Entities declared in a BLOCK construct are local to the BLOCK
construct and are accessible only in that construct and in any contained constructs. A local entity in a block
construct hides any entity with the same name in its host scope. No transfer of control into a block from
outside the block is allowed, except for the return from a procedure call. Transfers within a block or out of
the block are allowed.
If a construct name is specified at the beginning of a BLOCK statement, the same name must appear in the
corresponding END BLOCK statement. The same construct name must not be used for different named
constructs in the same scoping unit. If no name is specified at the beginning of a BLOCK statement, you
cannot specify one following the END BLOCK statement.
You can only branch to an END BLOCK statement from within its BLOCK construct.
The SAVE attribute specifies that a local variable of a BLOCK construct retains its association status,
allocation status, definition status, and value after termination of the construct unless it is a pointer and its
target becomes undefined. If the BLOCK construct contains a SAVE statement, the SAVE statement cannot
specify the name of a common block. A SAVE statement outside a BLOCK construct does not affect variables
local to the BLOCK construct, because a SAVE statement affects variables in its scoping unit which excludes
nested scoping units in it.
The statements specified within the specification-part are evaluated in a processor-dependent order, followed
by execution of block. When execution exits block, all non-SAVEd automatic and allocatable local variables
are deallocated.
Example
The following shows a BLOCK construct:
block
integer :: i
real :: a(n)
do i = 1,n
a(i) = i
end do
…
end block
When control exits the bottom of the BLOCK, local variables i and a revert to their meaning outside the
block.
The following example shows two nested BLOCK constructs where the inner BLOCK construct has the
construct name INNER and the outer one does not have a name:
BLOCK
...
INNER: BLOCK
...
END BLOCK INNER
...
END BLOCK
In the following example, the appearance and the reference of the FORMAT statement are legal:
PROGRAM MAIN
WRITE(6, FMT=10)
...
BLOCK
10 FORMAT(“Hello”)
1307
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
END BLOCK
...
END
Implicit typing is not affected by BLOCK constructs. In the following example, even if NSQP only appears in
the two BLOCK constructs, the scope of NSQP is the whole subroutine S:
SUBROUTINE S(N)
...
IF (N>0) THEN
BLOCK
NSQP = CEILING(SQRT(DBLE(N)))
END BLOCK
END IF
...
IF (N>0) THEN
BLOCK
PRINT *,NSQP
END BLOCK
END IF
END SUBROUTINE S
BLOCK DATA
Statement: Identifies a block-data program unit,
which provides initial values for variables in named
common blocks. BLOCK DATA is an obsolescent
language feature in Standard Fortran.
Syntax
BLOCK DATA [name]
[specification-part]
END [BLOCK DATA [name]]
definition
IMPLICIT SAVE
1For more information, see RECORD statement and record structure
declarations.
2Can only contain attributes: DIMENSION, INTRINSIC, PARAMETER,
POINTER, SAVE, STATIC, or TARGET.
1308
Language Reference
Description
A block data program unit need not be named, but there can only be one unnamed block data program unit
in an executable program.
If a name follows the END statement, it must be the same as the name specified in the BLOCK DATA
statement.
An interface block must not appear in a block data program unit and a block data program unit must not
contain any executable statements.
If a DATA statement initializes any variable in a named common block, the block data program unit must
have a complete set of specification statements establishing the common block. However, all of the variables
in the block do not have to be initialized.
A block data program unit can establish and define initial values for more than one common block, but a
given common block can appear in only one block data program unit in an executable program.
The name of a block data program unit can appear in the EXTERNAL statement of a different program unit to
force a search of object libraries for the block data program unit at link time.
Example
The following shows a block data program unit:
C Main Program
CHARACTER(LEN=10) family
INTEGER a, b, c, d, e
REAL X(10), Y(4)
COMMON/Lakes/a,b,c,d,e,family/Blk2/x,y
...
C The following block-data subprogram initializes
C the named common block /Lakes/:
C
BLOCK DATA InitLakes
COMMON /Lakes/ erie, huron, michigan, ontario,
+ superior, fname
DATA erie, huron, michigan, ontario, superior /1, 2, 3, 4, 5/
CHARACTER(LEN=10) fname/'GreatLakes'/
INTEGER erie, huron, michigan, ontario, superior
END
See Also
COMMON
DATA
EXTERNAL
Program Units and Procedures
1309
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
!DIR$ BLOCK_LOOP [clause[[,] clause]...]
!DIR$ NOBLOCK_LOOP
• FACTOR(expr)
The clauses can be specified in any order. If you do not specify any
clause, the compiler chooses the best blocking factor to apply to all
levels of the immediately following nested loop.
The BLOCK_LOOP directive lets you exert greater control over optimizations on a specific DO loop inside a
nested DO loop.
1310
Language Reference
Using a technique called loop blocking, the BLOCK_LOOP directive separates large iteration counted DO loops
into smaller iteration groups. Execution of these smaller groups can increase the efficiency of cache space
use and augment performance.
If there is no LEVEL and FACTOR clause, the blocking factor will be determined based on the processor's type
and memory access patterns and it will apply to all the levels in the nested loops following this directive.
You can use the NOBLOCK_LOOP directive to tune the performance by disabling loop blocking for nested
loops.
NOTE
The loop-carried dependence is ignored during the processing of BLOCK_LOOP directives.
Example
!dir$ block_loop factor (256) ! the blocking factor applies to all levels of loop nest
!dir$ noblock_loop ! None of the levels in the nested loop following this
! directive will have a blocking factor applied
Consider the following:
do jj=1,n/256+1
do ii = 1,n/256+1
do j = (jj-1)*256+1, min(jj*256, n)
f = 0
do i = (ii-1)*256+1, min(ii*256,n)
f = f + a(i) * b(i)
enddo
c(j) = c(j) + f
1311
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
enddo
enddo
enddo
See Also
General Compiler Directives
Syntax Rules for Compiler Directives
Rules for General Directives that Affect DO Loops
Rules for Loop Directives that Affect Array Assignment Statements
Nested DO Constructs
BLT
Elemental Intrinsic Function (Generic): Performs
a bitwise less than on its arguments.
Syntax
result = BLT (i,j)
If the kinds of i and j do not match, the value with the smaller kind is extended with zeros on the left and
the larger kind is used for the operation and the result.
Results
The result is true if the sequence of bits represented by i is less than the sequence of bits represented by j,
according to the method of bit sequence comparison in Bit Sequence Comparisons; otherwise, the result is
false.
The interpretation of a binary, octal, or hexadecimal literal constant as a sequence of bits is described in
Binary, Octal, Hexadecimal, and Hollerith Constants.
The model for the interpretation of an integer value as a sequence of bits is shown in Model for Bit Data.
Example
BLT (0, 2) has the value true. BLT (Z'FF', Z'FC') has the value false.
BSEARCHQQ
Portability Function: Performs a binary search of a
sorted one-dimensional array for a specified element.
The array elements cannot be derived types or
structures.
Module
USE IFPORT
Syntax
result = BSEARCHQQ (adrkey,adrarray,length,size)
1312
Language Reference
size (Input) INTEGER(4). Positive constant less than 32,767 that specifies
the kind of array to be sorted. The following constants, defined in
IFPORT.F90, specify type and kind for numeric arrays:
SRT$INTEGER1 INTEGER(1)
If the value provided in size is not a symbolic constant and is less than 32,767, the array is assumed to be a
character array with size characters per element.
Results
The result type is INTEGER(4). It is an array index of the matched entry, or 0 if the entry is not found.
The array must be sorted in ascending order before being searched.
Caution
The location of the array and the element to be found must both be passed by address using
the LOC function. This defeats Fortran type checking, so you must make certain that the
length and size arguments are correct, and that size is the same for the element to be found
and the array searched.
If you pass invalid arguments, BSEARCHQQ attempts to search random parts of memory. If the
memory it attempts to search is not allocated to the current process, the program is halted, and you
receive a General Protection Violation message.
Example
USE IFPORT
INTEGER(4) array(10), length
INTEGER(4) result, target
length = SIZE(array)
...
result = BSEARCHQQ(LOC(target),LOC(array),length,SRT$INTEGER4)
1313
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
SORTQQ
LOC
BTEST
Elemental Intrinsic Function (Generic): Tests a bit
of an integer argument.
Syntax
result = BTEST (i,pos)
pos (Input) Must be of type integer. It must not be negative and it must
be less than BIT_SIZE(i).
Results
The result type is default logical.
The result is true if bit pos of i has the value 1. The result is false if pos has the value zero. For more
information, see Bit Functions.
For information on the model for the interpretation of an integer value as a sequence of bits, see Model for
Bit Data.
The setting of compiler options specifying integer size can affect this function.
Example
BTEST (9, 3) has the value true.
If A has the value
[ 1 2 ]
[ 3 4 ],
the value of BTEST (A, 2) is
[ false false ]
[ false true ]
1314
Language Reference
[ true false ]
[ false false ].
The following shows more examples:
INTEGER(1) i(2)
LOGICAL result(2)
i(1) = 2#10101010
i(2) = 2#01010101
result = BTEST(i, (/3,2/)) ! returns (.TRUE.,.TRUE.)
write(*,*) result
See Also
IBCLR
IBSET
IBCHNG
IOR
IEOR
IAND
BYTE
Statement: Specifies the BYTE data type, which is
equivalent to INTEGER(1).
Example
See Also
INTEGER
Integer Data Types
C to D
This section describes language features that start with C or D.
1315
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
C to D
C_ASSOCIATED
Intrinsic Module Inquiry function (Generic):
Indicates the association status of one argument, or
whether two arguments are associated with the same
entity.
Module
USE, INTRINSIC :: ISO_C_BINDING
Syntax
result = C_ASSOCIATED(c_ptr_1[, c_ptr_2])
Results
The result is a scalar of type default logical. The result value is one of the following:
• If only c_ptr_1 is specified, the result is false if c_ptr_1 is a C null pointer; otherwise, the result is true.
• If c_ptr_2 is specified, the result is false if c_ptr_1 is a C null pointer. The result is true if c_ptr_1 is equal
to c_ptr_2; otherwise, the result is false.
See Also
Intrinsic Modules
ISO_C_BINDING Module
C_F_POINTER
Intrinsic Module Subroutine: Associates a data
pointer with the target of a C pointer and specifies its
shape.
Module
USE, INTRINSIC :: ISO_C_BINDING
Syntax
CALL C_F_POINTER(cptr, fptr [,shape])
cptr (Input) Is a scalar of derived type C_PTR. Its value is the C address of
an interoperable data entity, or the result of a reference to function
C_LOC with a noninteroperable argument. If the value of cptr is the C
address of a Fortran variable, it must have the TARGET attribute.
shape (Optional, input) Must be of type integer and rank one. Its size equals
the rank of fptr.
1316
Language Reference
If the value of cptr is the C address of an interoperable data entity, fptr must be a data pointer with type and
type parameters interoperable with the type of the entity. In this case, fptr becomes pointer-associated with
the target of cptr.
If fptr is an array, it has the shape specified by shape and each lower bound is 1.
If the value of cptr is the result of a reference to C_LOC with a noninteroperable argument x, the following
rules apply:
• C_LOC argument x (or its target) must not have been deallocated or have become undefined due to the
execution of a RETURN or END statement since the reference to C_LOC.
• fptr is a scalar pointer with the same type and type parameters as x. fptr becomes pointer-associated with
x, or it becomes pointer-associated with its target if x is a pointer.
Since the resulting data pointer fptr could point to a target that was not allocated with an ALLOCATE
statement, fptr cannot be freed with a DEALLOCATE statement.
See Also
Intrinsic Modules
ISO_C_BINDING Module
C_LOC
C_F_PROCPOINTER
Intrinsic Module Subroutine: Associates a Fortran
procedure pointer with the target of a C function
pointer.
Module
USE, INTRINSIC :: ISO_C_BINDING
Syntax
CALL C_F_PROCPOINTER(cptr, fptr)
Examples
Example 1
The following Fortran subroutine can be called from a C program that passes a pointer to a C function to be
called:
1317
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
INTEGER(C_INT) :: j
main.c:
#include <stdio.h>
int main () {
void (*fun_b)(int*) = NULL;
int *i;
int j = 10;
fun_b = foo;
i = &j;
printf (“Test in C\n”);
fun_b (i);
printf (“Test in Fortran\n”);
bar_ (&fun_b);
}
bar.f90
SUBROUTINE bar (c_fptr)
USE ISO_C_BINDING
TYPE(c_funptr) :: c_fptr
PROCEDURE(),POINTER :: proc_ptr
INTEGER(c_int) :: i = 20
Test in C
The value is 10
Test in Fortran
The value is 20
See Also
Intrinsic Modules
ISO_C_BINDING Module
Procedure Pointers
1318
Language Reference
PROCEDURE
C_FUNLOC
Intrinsic Module Inquiry function (Generic):
Returns the C address of a function pointer.
Module
USE, INTRINSIC :: ISO_C_BINDING
Syntax
result = C_FUNLOC(x)
Results
The result is a scalar of derived type C_FUNPTR. The result value represents the C address of the argument.
See Also
Intrinsic Modules
ISO_C_BINDING Module
C_LOC
Intrinsic Module Inquiry function (Generic):
Returns the C address of an argument.
Module
USE, INTRINSIC :: ISO_C_BINDING
Syntax
result = C_LOC(x)
1319
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result is a scalar of derived type C_PTR. The result value represents the C address of the argument.
The result is a value that can be used as an actual CPTR argument in a call to procedure C_F_POINTER where
fptr has attributes that allow the pointer assignment fptr=>x. Such a call to C_F_POINTER has the effect of
the pointer assignment fptr=>x.
If x is a scalar, the result is determined as if C_PTR were a derived type containing a scalar pointer
component PX of the type and type parameters of x and the pointer assignment CPTR%PX=>x were
executed.
If x is an array, the result is determined as if C_PTR were a derived type containing a scalar pointer
component PX of the type and type parameters of x and the pointer assignment CPTR%PX to the first
element of x were executed.
See Also
Intrinsic Modules
ISO_C_BINDING Module
C_F_POINTER
C_SIZEOF
Intrinsic Module Inquiry function (Generic):
Returns the number of bytes of storage used by the
argument. It cannot be passed as an actual argument.
Module
USE, INTRINSIC :: ISO_C_BINDING
Syntax
result = C_SIZEOF(x)
Results
The result is a scalar of type INTEGER(4) on IA-32 architecture; INTEGER(8) on Intel® 64 architecture. If x is
scalar, the result value is the size of x in bytes. If x is an array, the result value is the size of a single element
of x multiplied by the number of elements in x.
Example
Consider the following:
INTEGER(4) :: S
INTEGER(4) :: T(3)
C_SIZEOF(S) ! has the value 4
C_SIZEOF(T) ! has the value 12
See Also
Intrinsic Modules
ISO_C_BINDING Module
1320
Language Reference
SIZEOF
CACHESIZE
Inquiry Intrinsic Function (Generic): Returns the
size of a level of the memory cache.
Syntax
result = CACHESIZE (n)
Results
The result type and kind are the same as n. The result value is the number of kilobytes in the level n
memory cache.
n = 1 specifies the first level cache; n = 2 specifies the second level cache; etc. If cache level n does not
exist, the result value is 0.
Example
CACHESIZE(1) returns 16 for a processor with a 16KB first level memory cache.
CALL
Statement: Transfers control to a subroutine
subprogram.
Syntax
CALL sub[( [a-arg[,a-arg]...] )]
Description
When the CALL statement is executed, any expressions in the actual argument list are evaluated, then
control is passed to the first executable statement or construct in the subroutine. When the subroutine
finishes executing, control returns to the next executable statement following the CALL statement, or to a
statement identified by an alternate return label (if any).
1321
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If an argument list appears, each actual argument is associated with the corresponding dummy argument by
its position in the argument list or by the name of its keyword. The arguments must agree in type and kind
parameters.
If positional arguments and argument keywords are specified, the argument keywords must appear last in
the actual argument list.
If a dummy argument is optional, the actual argument can be omitted.
An actual argument associated with a dummy procedure must be the specific name of a procedure, or be
another dummy procedure. Certain specific intrinsic function names must not be used as actual arguments
(see table Specific Functions Not Allowed as Actual Arguments in Intrinsic Procedures).
The procedure invoked by the CALL statement must be a subroutine subprogram and not a function. Calling a
function as if it were a subroutine can cause unpredictable results.
Example
The following example shows valid CALL statements:
CALL CURVE(BASE,3.14159+X,Y,LIMIT,R(LT+2))
CALL PNTOUT(A,N,'ABCD')
CALL EXIT
CALL MULT(A,B,*10,*20,C) ! The asterisks and ampersands denote
CALL SUBA(X,&30,&50,Y) ! alternate returns
The following example shows a subroutine with argument keywords:
PROGRAM KEYWORD_EXAMPLE
INTERFACE
SUBROUTINE TEST_C(I, L, J, KYWD2, D, F, KYWD1)
INTEGER I, L(20), J, KYWD1
REAL, OPTIONAL :: D, F
COMPLEX KYWD2
...
END SUBROUTINE TEST_C
END INTERFACE
INTEGER I, J, K
INTEGER L(20)
COMPLEX Z1
CALL TEST_C(I, L, J, KYWD1 = K, KYWD2 = Z1)
...
The first three actual arguments are associated with their corresponding dummy arguments by position. The
argument keywords are associated by keyword name, so they can appear in any order.
Note that the interface to subroutine TEST has two optional arguments that have been omitted in the CALL
statement.
The following shows another example of a subroutine call with argument keywords:
1322
Language Reference
CALL SUB1(B=X,C=S*T,FUNC=NINT,A=4.0)
!Here is the same call using an implicit reference
CALL SUB1(4.0,X,S*T,NINT)
CONTAINS
SUBROUTINE sub1(a,b,c,func)
INTEGER func
REAL a,b,c
PRINT *, a,b,c, func(b)
END SUBROUTINE
END
See Also
SUBROUTINE
CONTAINS
RECURSIVE
USE
Program Units and Procedures
CANCEL
OpenMP* Fortran Compiler Directive: Requests
cancellation of the innermost enclosing region of the
construct specified, and causes the encountering
implicit or explicit task to proceed to the end of the
canceled construct.
Syntax
!$OMP CANCEL construct-clause [[,] if-clause]
• DO
• PARALLEL
• SECTIONS
• TASKGROUP
The binding thread set of a CANCEL construct is the current team. The cancel region binds to the innermost
enclosing construct of the type corresponding to the construct-clause specified in the directive specifying the
innermost DO, PARALLEL, SECTIONS, or TASKGROUP construct.
This is a stand-alone directive, so there are some restrictions on its placement within a program:
• It can only be placed at a point where a Fortran executable statement is allowed.
• It cannot be used as the action statement in an IF statement, or as the executable statement following a
label, if the label is referenced in the program.
If construct-clause is TASKGROUP, the CANCEL construct must be closely nested inside a TASK construct.
Otherwise, the CANCEL construct must be closely nested inside an OpenMP construct that matches the type
specified in construct-clause.
The CANCEL construct requests cancellation of the innermost enclosing region of the type specified. The
request is checked at a cancellation point. When a cancellation is observed, execution jumps to the end of
the canceled region.
Cancellation points are implied at certain locations, as follows:
• Implicit barriers
1323
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• BARRIER regions
• CANCEL regions
• CANCELLATION POINT regions
When cancellation of tasks occurs with a CANCEL TASKGROUP construct, the encountering task jumps to the
end of its task region and is considered complete. Any task that belongs to the innermost enclosing
taskgroup and has already begun execution, must run to completion or run until a cancellation point is
reached. Any task that belongs to the innermost enclosing taskgroup and has not begun execution may be
discarded and considered completed.
When cancellation occurs for a PARALLEL region, each thread of the binding thread set resumes execution at
the end of the canceled region and any tasks that have been created by a TASK construct and their
descendants are canceled according to the above taskgroup cancellation semantics.
When cancellation occurs for a DO or SECTIONS region, each thread of the binding thread set resumes
execution at the end of the canceled region but no task cancellation occurs.
A DO construct that is being canceled must not have a NOWAIT or an ORDERED clause. A SECTIONS
construct that is being canceled must not have a NOWAIT clause.
The behavior for concurrent cancellation of a region and a region nested within it is unspecified.
NOTE
You must release locks and similar data structures that can cause a deadlock when a CANCEL
construct is encountered; blocked threads cannot be canceled.
If the canceled construct contains a REDUCTION or LASTPRIVATE clause, the final value of the REDUCTION or
LASTPRIVATE variable is undefined.
All private objects or subobjects with the ALLOCATABLE attribute that are allocated inside the canceled
construct are deallocated.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
CANCELLATION POINT
Parallel Processing Model for information about Binding Sets
CANCELLATION POINT
OpenMP* Fortran Compiler Directive: Defines a
point at which implicit or explicit tasks check to see if
cancellation has been requested for the innermost
enclosing region of the type specified. This construct
does not implement a synchronization between
threads or tasks.
Syntax
!$OMP CANCELLATION POINT construct-clause
• DO
• PARALLEL
• SECTIONS
• TASKGROUP
This is a stand-alone directive, so there are some restrictions on its placement within a program:
1324
Language Reference
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
CANCEL
CASE
Statement: Marks the beginning of a CASE construct.
A CASE construct conditionally executes one block of
constructs or statements depending on the value of a
scalar expression in a SELECT CASE statement.
Syntax
[name:] SELECT CASE (expr)
[CASE (case-value [, case-value] ...) [name]
block]...
[CASE DEFAULT [name]
block]
END SELECT [name]
low:high
low:
:high
Case values must not overlap.
1325
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
If a construct name is specified in a SELECT CASE statement, the same name must appear in the
corresponding END SELECT statement. The same construct name can optionally appear in any CASE
statement in the construct. The same construct name must not be used for different named constructs in the
same scoping unit.
The case expression ( expr) is evaluated first. The resulting case index is compared to the case values to find
a matching value (there can only be one). When a match occurs, the block following the matching case value
is executed and the construct terminates.
The following rules determine whether a match occurs:
• When the case value is a single value (no colon appears), a match occurs as follows:
You cannot use branching statements to transfer control to a CASE statement. However, branching to a
SELECT CASE statement is allowed. Branching to the END SELECT statement is allowed only from within the
CASE construct.
1326
Language Reference
Example
The following are examples of CASE constructs:
CHARACTER*1 cmdchar
GET_ANSWER: SELECT CASE (cmdchar)
CASE ('0')
WRITE (*, *) "Must retrieve one to nine files"
CASE ('1':'9')
CALL RetrieveNumFiles (cmdchar)
CASE ('A', 'a')
CALL AddEntry
CASE ('D', 'd')
CALL DeleteEntry
CASE ('H', 'h')
CALL Help
1327
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
CASE DEFAULT
WRITE (*, *) "Command not recognized; please use H for help"
END SELECT GET_ANSWER
See Also
Execution Control
CDFLOAT
Portability Function: Converts a COMPLEX(4)
argument to double-precision real type.
Module
USE IFPORT
Syntax
result = CDFLOAT (input)
Results
The result type is REAL(8).
CEILING
Elemental Intrinsic Function (Generic): Returns
the smallest integer greater than or equal to its
argument.
Syntax
result = CEILING (a[,kind])
Results
The result type is integer. If kind is present, the kind parameter of the result is that specified by kind;
otherwise, the kind parameter of the result is that of default integer. If the processor cannot represent the
result value in the kind of the result, the result is undefined.
The value of the result is equal to the smallest integer greater than or equal to a.
The setting of compiler options specifying integer size can affect this function.
Example
CEILING (4.8) has the value 5.
CEILING (-2.55) has the value -2.0.
The following shows another example:
INTEGER I, IARRAY(2)
I = CEILING(8.01) ! returns 9
I = CEILING(-8.01) ! returns -8
IARRAY = CEILING((/8.01,-5.6/)) ! returns (9, -5)
1328
Language Reference
See Also
FLOOR
CFI_address
C function prototype: Returns the C address of an
object described by a C descriptor.
Syntax
Result Value
If the object is an array of rank n, the result is the C address of the element of the object that the first n
elements of the subscripts argument would specify if used as subscripts. If the object is scalar, the result is
its C address.
Example
If dv is the address of a C descriptor for the Fortran array A declared as follows:
CFI_index_t subscripts[2];
float *address;
subscripts[0] = 4;
subscripts[1] = 9;
address = (float *) CFI_address(dv, subscripts );
See Also
C Structures Typedefs and Macros for interoperability
Interoperating with arguments using C descriptors
CFI_allocate
C function prototype: Allocates memory for an
object described by a C descriptor.
1329
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
lower_bounds The address of an array with at least dv->rank elements. The first dv-
>rank elements of lower_bounds provide the lower Fortran bounds for
each corresponding dimension of the object.
upper_bounds The address of an array with at least dv->rank elements. The first dv-
>rank elements of upper_bounds provide the upper Fortran bounds
for each corresponding dimension of the object.
Description
Successful execution of CFI_allocate allocates memory for the object described by the C descriptor with the
address dv using the same mechanism as the Fortran ALLOCATE statement, and assigns the address of that
memory to dv->base_addr.
The first dv->rank elements of the lower_bounds and upper_bounds arguments provide the lower and upper
Fortran bounds, respectively, for each corresponding dimension of the object. The supplied lower and upper
bounds override any current dimension information in the C descriptor. If the rank is zero, the lower_bounds
and upper_bounds arguments are ignored.
If the type specified in the C descriptor is a character type, the supplied element length overrides the current
element-length information in the descriptor.
If an error is detected, the C descriptor is not modified.
Result Value
The result is an error indicator.
Example
If dv is the address of a C descriptor for the Fortran array A declared as follows:
1330
Language Reference
See Also
ALLOCATE
C Structures Typedefs and Macros for interoperability
Interoperating with arguments using C descriptors
CFI_deallocate
C function prototype: Deallocates memory for an
object described by a C descriptor.
Syntax
int CFI_deallocate (CFI_cdesc_t *dv);
Formal Parameters:
Description
Successful execution of CFI_deallocate deallocates memory for the object using the same mechanism as the
Fortran DEALLOCATE statement, and the base_addr member of the C descriptor becomes a null pointer.
Result Value
The result is an error indicator.
Example
If dv is the address of a C descriptor for the Fortran array A declared as follows:
int ind;
ind = CFI_deallocate(dv);
See Also
ALLOCATE
DEALLOCATE
C Structures Typedefs and Macros for interoperability
Interoperating with arguments using C descriptors
CFI_establish
C function prototype: Establishes a C descriptor.
Syntax
1331
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
attribute One of the attribute codes in Table "Macros for attribute codes" in C
Typedefs and Macros for interoperability. If it is
CFI_attribute_allocatable, base_addr must be a null pointer.
type One of the type codes in Table "Macros for type codes" in C Typedefs
and Macros for interoperability.
Description
Successful execution of CFI_establish updates the object with the address dv to be an established C
descriptor for a nonallocatable nonpointer data object of known shape, an unallocated allocatable object, or a
data pointer.
If base_addr is not a null pointer, it is the address for a nonallocatable entity that is a scalar or a contiguous
array. If the attribute argument has the value CFI_attribute_pointer, the lower bounds of the object
described by dv are set to zero. If base_addr is a null pointer, the established C descriptor is for an
unallocated allocatable, a disassociated pointer, or is a C descriptor that has the attribute
CFI_attribute_other but does not describe a data object. If base_addr is the C address of a Fortran data
object, the type and elem_len arguments must be consistent with the type and type parameters of the
Fortran data object.
The remaining properties of the object are given by the other arguments.
CFI_establish is used to initialize a C descriptor declared in C with CFI_CDESC_T before passing it to any
other functions as an actual argument, in order to set the rank, attribute, type and element length.
1332
Language Reference
A C descriptor with attribute CFI_attribute_other and a base_addr that is a null pointer can be used as
the argument result in calls to CFI_section or CFI_select_part, which will produce a C descriptor for a
nonallocatable nonpointer data object.
If an error is detected, the object with the address dv is not modified.
Result Value
The result is an error indicator.
Example
The following code fragment establishes a C descriptor for an unallocated rank-one allocatable array that can
be passed to Fortran for allocation there:
CFI_rank_t rank;
CFI_CDESC_T(1) field;
int ind;
rank = 1;
ind = CFI_establish((CFI_cdesc_t *)&field, NULL,
CFI_attribute_allocatable,
CFI_type_double, 0, rank, NULL);
If the following Fortran type definition is specified:
TYPE, BIND(C) :: T
REAL(C_DOUBLE) :: X
COMPLEX(C_DOUBLE_COMPLEX) :: Y
END TYPE
and a Fortran subprogram that has an assumed-shape dummy argument of type T, the following code
fragment creates a descriptor a_fortran for an array of size 100 that can be used as the actual argument in
an invocation of the subprogram from C:
extent[0] = 100;
ind = CFI_establish((CFI_cdesc_t *)&a_fortran, a_c,
CFI_attribute_other,
CFI_type_struct, sizeof(t), 1, extent);
See Also
C Structures Typedefs and Macros for interoperability
Interoperating with arguments using C descriptors
CFI_is_contiguous
C function prototype: Tests contiguity of an array.
Syntax
int CFI_is_contiguous(const CFI_cdesc_t *dv);
Formal Parameters:
1333
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Result Value
The value of the result is 1 if the array described by dv is contiguous; otherwise, 0.
Since assumed-size and allocatable arrays are always contiguous, the result of CFI_is_contiguous on a C
descriptor for such an array is 1.
See Also
C Structures Typedefs and Macros for interoperability
Interoperating with arguments using C descriptors
CFI_section
C function prototype: Updates a C descriptor for an
array section for which each element is an element of
a given array.
Syntax
int CFI_section(CFI_cdesc_t *result, const CFI_cdesc_t *source,
const CFI_index_t lower_bounds[],
const CFI_index_t upper_bounds[],
const CFI_index_t strides[]);
Formal Parameters:
result The address of a C descriptor with rank equal to the rank of source
minus the number of zero strides. The attribute member must have
the value CFI_attribute_other or CFI_attribute_pointer. If the
value of result is the same as either a C formal parameter that
corresponds to a Fortran actual argument or a C actual argument that
corresponds to a Fortran dummy argument, the attribute member
must have the value CFI_attribute_pointer.
1334
Language Reference
If an error is detected, the C descriptor with the address result is not modified.
Result Value
The result is an error indicator.
Example
If source is already the address of a C descriptor for the rank-one Fortran array A, the lower bounds of A are
equal to 1, and the lower bounds in the C descriptor are equal to 0, the following code fragment establishes a
new C descriptor section and updates it to describe the array section A(3::5):
1335
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
CFI_type_float, 0, 1, NULL);
ind = CFI_section((CFI_cdesc_t *)§ion, source,
lower, upper, strides);
See Also
C Structures Typedefs and Macros for interoperability
Interoperating with arguments using C descriptors
CFI_select_part
C function prototype: Updates a C descriptor for an
array section for which each element is a part of the
corresponding element of an array.
Syntax
result The address of a C descriptor; result->rank must have the same value
as source->rank and result->attribute must have the value
CFI_attribute_other or CFI_attribute_pointer. If the address
specified by result is the value of a C formal parameter that
corresponds to a Fortran actual argument or of a C actual argument
that corresponds to a Fortran dummy argument, result->attribute
must have the value CFI_attribute_pointer. The value of result-
>type specifies the type of the array section.
elem_len A value equal to the storage size in bytes of an element of the array
section if result->type specifies a Fortran character type; otherwise,
elem_len is ignored.
Description
Successful execution of CFI_select_part updates the base_addr, dim, and elem_len members of the C
descriptor with the address result for an array section for which each element is a part of the corresponding
element of the array described by the C descriptor with the address source. The part must be a component of
a structure, a substring, or the real or imaginary part of a complex value.
If an error is detected, the C descriptor with the address result is not modified.
Result Value
The result is an error indicator.
1336
Language Reference
Example
If source is already the address of a C descriptor for the Fortran array A declared as follows:
TYPE, BIND(C) :: T
REAL(C_DOUBLE) :: X
COMPLEX(C_DOUBLE_COMPLEX) :: Y
END TYPE
TYPE(T) A(100)
then the following code fragment establishes a C descriptor for the array A%Y:
typedef struct {
double x; double _Complex y;
} t;
CFI_CDESC_T(1) component;
CFI_cdesc_t * comp_cdesc = (CFI_cdesc_t *)&component;
CFI_index_t extent[] = { 100 };
(void)CFI_establish(comp_cdesc, NULL, CFI_attribute_other,
CFI_type_double_Complex,
sizeof(double _Complex), 1, extent);
(void)CFI_select_part(comp_cdesc, source, offsetof(t,y), 0);
See Also
C Structures Typedefs and Macros for interoperability
Interoperating with arguments using C descriptors
CFI_setpointer
C function prototype: Updates a C descriptor for a
Fortran pointer to be associated with the whole of a
given object or to be disassociated.
Syntax
Description
Successful execution of CFI_setpointer updates the base_addr and dim members of the C descriptor with
the address result as follows:
• If source is a null pointer or the address of a C descriptor for a disassociated pointer, the updated C
descriptor describes a disassociated pointer.
1337
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• Otherwise, the C descriptor with the address result becomes a C descriptor for the object described by the
C descriptor with the address source, except that if source->rank is nonzero and lower_bounds is not a
null pointer, the lower bounds are replaced by the values of the first source->rank elements of the
lower_bounds array.
Result Value
The result is an error indicator.
Example
If ptr is already the address of a C descriptor for an array pointer of rank 1, the following code updates it to
be a C descriptor for a pointer to the same array with lower bound 0:
CFI_index_t lower_bounds[1];
int ind;
lower_bounds[0] = 0;
ind = CFI_setpointer(ptr, ptr, lower_bounds);
See Also
C Structures Typedefs and Macros for interoperability
Interoperating with arguments using C descriptors
CHANGEDIRQQ
Portability Function: Makes the specified directory
the current, default directory.
Module
USE IFPORT
Syntax
result = CHANGEDIRQQ (dir)
Results
The result type is LOGICAL(4). It is .TRUE. if successful; otherwise, .FALSE..
If you do not specify a drive in the dir string, the named directory on the current drive becomes the current
directory. If you specify a drive in dir, the named directory on the specified drive becomes the current
directory.
Example
USE IFPORT
LOGICAL(4) status
status = CHANGEDIRQQ('d:\fps90\bin'))
! We are now CCed to 'd:\fps90\bin'
status = CHANGEDIRQQ('bessel')
! We are now CCed to 'd:\fps90\bin\bessel'
See Also
GETDRIVEDIRQQ
MAKEDIRQQ
DELDIRQQ
CHANGEDRIVEQQ
1338
Language Reference
CHANGEDRIVEQQ
Portability Function: Makes the specified drive the
current, default drive.
Module
USE IFPORT
Syntax
result = CHANGEDRIVEQQ (drive)
Results
The result type is LOGICAL(4). On Windows* systems, the result is .TRUE. if successful; otherwise, .FALSE.
On Linux* and macOS* systems, the result is always .FALSE..
Because drives are identified by a single alphabetic character, CHANGEDRIVEQQ examines only the first
character of drive. The drive letter can be uppercase or lowercase.
CHANGEDRIVEQQ changes only the current drive. The current directory on the specified drive becomes the
new current directory. If no current directory has been established on that drive, the root directory of the
specified drive becomes the new current directory.
Example
USE IFPORT
LOGICAL(4) status
status = CHANGEDRIVEQQ('d')
See Also
GETDRIVESQQ
GETDRIVESIZEQQ
GETDRIVEDIRQQ
CHANGEDIRQQ
Syntax
The CHANGE TEAM construct takes the following form:
[name:] CHANGE TEAM (team-variable [, coarray-association-list][, sync-stat-list])
block
END TEAM [([sync-stat-list])] [name]
1339
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
stat-var Is a scalar integer variable in which the status of the FORM TEAM
operation is stored.
The sync-stat-list items can appear in any order, but each sync-stat specifier may appear at most once. A
selector may appear only once in selector-list. stat-var and err-var cannot be coindexed variables. team-
variable must have been previously defined by the execution of a FORM TEAM statement.
Description
A CHANGE TEAM statement begins the CHANGE TEAM construct. The current team of each image that
executes a CHANGE team statement becomes the team specified by the team variable. This remains the
current team of the image until another CHANGE TEAM construct is executed by the image, or until the
corresponding END TEAM statement is executed. The current team of each image executing an END TEAM
statement becomes the team that was current prior to execution of the corresponding CHANGE TEAM
statement.
Branching into or out of a CHANGE TEAM construct is not permitted. A branch to an END TEAM statement is
permitted only from within the corresponding CHANGE TEAM construct. An EXIT statement in a CHANGE
TEAM construct is effectively the same as a branch to the END TEAM statement of the construct. Within a
CHANGE TEAM construct, a CYCLE or EXIT statement is not allowed if it belongs to an outer construct. A
RETURN statement may not appear in a CHANGE TEAM construct.
If a construct name appears on the CHANGE TEAM statement of the construct, the same name must also
appear on the END TEAM construct. If a construct name appears on an END TEAM statement, the same
construct name must appear on the corresponding CHANGE TEAM statement. The construct name must not
be the same as any other construct name in the scoping unit.
The purpose of the coarray-association is to redefine the codimensions of a coarray during execution of the
CHANGE TEAM construct. The associating entity is a coarray with the corank and cobounds specified in the
codimension-decl. This means the coshape and cobounds of an associating entity can be different from that
of the selector. When the CHANGE TEAM statement is executed, the selectors must all be established
coarrays.
The coarray name in a coarray-association must not be the same as the name as the name of another
coarray or of a selector in the CHANGE TEAM statement. The coarray names specified in the codimension-
decl are associate names associated with their corresponding selectors. The type and type parameters of the
associating entity is that of its selector. The associating entity is polymorphic if the selector is polymorphic, in
which case the associating entity assumes the dynamic type and type parameters of the selector.
On each active image that executes the CHANGE TEAM statement, the team variables must have been
defined by corresponding execution of the same FORM TEAM statement. The current team executing prior to
the CHANGE TEAM statement must be the same team that executed the FORM TEAM statement that defined
the team variables. On each image, the team variable specified in the CHANGE TEAM statement cannot
become undefined or redefined during execution of the construct.
An allocatable coarray that has an allocation status of allocated when the CHANGE TEAM construct is entered
cannot be deallocated during execution of the construct. Allocatable coarrays that are allocated during the
CHANGE TEAM construct and remain allocated at the end of the construct are deallocated upon exit from the
construct. This is true even if the allocatable coarray has the SAVE attribute.
1340
Language Reference
Each image executing the CHANGE TEAM statement is implicitly synchronized with all the other active images
that will be on the same team after execution of the CHANGE TEAM construct. Execution of the statements
forming the block of the CHANGE TEAM construct are delayed until all images on the new team have entered
the construct. The construct completes execution when the END TEAM statement is executed. The images of
the team executing the construct are implicitly synchronized when the END TEAM statement is executed.
If STAT= is specified on a CHANGE TEAM or END TEAM statement, stat-var becomes defined with the value 0
if no error condition occurs. If the team executing the statement contains a stopped image, stat-var becomes
defined with the value STAT_STOPPED_IMAGE from the intrinsic module ISO_FORTRAN_ENV. If the team
contains a failed image and no other error condition occurs, stat-var becomes defined with the value
STAT_FAILED_IMAGE defined in the module ISO_FORTRAN_ENV. Otherwise, stat-var becomes defined with a
positive integer value other than STAT_FAILED_IMAGE or STAT_STOPPED_IMAGE. If STAT= is not specified,
and the team contains a stopped or failed image, or if any other error occurs, error termination is initiated.
If ERRMSG= is specified in a CHANGE TEAM or an END TEAM statement and an error condition occurs, err-
var becomes defined with a character string containing an informative message about the error. The string is
truncated or padded according to the rules of intrinsic assignment. If no error occurs, err-var is unchanged.
Examples
Example 1:
USE ISO_FORTRAN_ENV
TYPE (TEAM_TYPE) :: odd_even
FORM TEAM (2-MOD(THIS_IMAGE(), 2), odd_even)
CHANGE TEAM (odd_even)
! Segment 1
. . .
END TEAM
! Segment 2
. . .
END PROGRAM
If a team with 8 images executes the above code, two teams are formed. Team number 1 contains the odd
numbered images [1, 3, 5, 7] of the parent team with new image indices [1, 2, 3, 4], and team number 2
contains the even numbered images [2, 4, 6, 8] of the parent team with new image indices [1, 2, 3, 4].
Segment 1 can be executed by team number 1 once images 1, 3, 5, and 7 of the initial team have arrived at
the CHANGE TEAM construct. Team number 1 can execute segment 2 once the same images have executed
the END TEAM statement. Similarly, segment 1 can be executed by team 2 only after image 2, 4, 6, and 8
have all arrived at the CHANGE TEAM statement, and they can execute segment 2 after they have all reached
the END TEAM statement.
Example 2:
USE ISO_FORTRAN_ENV
INTEGER, PARAMETER :: n = 4
TYPE (TEAM_TYPE) :: column
REAL,CODIMENSION[n, *]:: co_array
INTEGER,DIMENSION(2) :: my_cosubscripts
my_cosubscripts (:) = THIS_IMAGE(co_array)
FORM TEAM (my_cosubscripts(2), column, NEW_INDEX = my_cosubscripts(1))
CHANGE TEAM (column, ca[*] => co_array)
….
END TEAM
If there are 16 images on the initial team, the scalar coarray co_array will be distributed across a 4 x 4 grid
of processors. Execution of the FORM TEAM statement divides the initial team into four teams of four images.
Each team contains the images of one column of the grid of processors. The team number of each team is
the column number in the processor grid, and the image indices on each new team are the row indices of the
processor grid. Inside the CHANGE TEAM construct, the image pattern is a 1 x 4 pattern.
1341
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
On team 1, ca[1] is co_array[1, 1], ca[2] is co_array[2,1], …, and ca[4] is coarray[4, 1]. On team 2, ca[1] is
co_array[1, 2], ca[2] is co_array [2,2], …, and ca[4] is co_array[2, 4]. On team 3, ca[1] is co_array[1, 3],
ca[2] is co_array[2 ,3], …, and ca[4] is co_array[4, 3]. And on team 4, ca[1] is co_array[1, 4], ca[2] is
co_array[2, 4], …, and ca[4] is co_array[4, 4].
co_array's cosubscripts:
Team 1 2 3 4
Number
1,1 1,2 1,3 1,4
2,1 2,2 2,3 2,4
3,1 3,2 3,3 3,4
4,1 4,2 4,3 4,4
Example 3:
USE ISO_FORTRAN_ENV
TYPE (TEAM_TYPE) :: one_or_two
IF (THIS_IMAGE() .LE. NUM_IMAGES() / 2) THEN
new_team = 1
ELSE
new_team = 2
END IF
FORM TEAM (new_team, one_or_two)
SYNC ALL
CHANGE TEAM (one_or_two)
! Segment 1
. . .
END TEAM
SYNC ALL
! Segment 2
. . .
END PROGRAM
In the above case, the FORM TEAM statement creates two teams, team 1 and team 2. The SYNC ALL
statement before the CHANGE TEAM statement prevents either team from entering the CHANGE TEAM
construct until all images of the other team are ready to enter it also. Similarly, the SYNC ALL after the END
TEAM statement prevents either team from executing segment 2 until all images of the other team have
exited the CHANGE TEAM construct.
Example 4:
This example divides a 4x4 grid of images into 4 2x2 grids of images. The image indices of the 4x4 grid are:
1 5 9 13
2 6 10 14
3 7 11 15
4 8 12 16
The 2x2 grids are laid out and identified symbolically and with team numbers as:
top_lef top_rig
t (1,1) ht (1,2)
1342
Language Reference
bot_lef bot_rig
t (2,1) ht (2,2)
The image numbers on each of the teams in the 2x2 grids become:
1 3 1 3
2 4 2 4
1 3 1 3
2 4 2 4
PROGRAM MAIN
USE ISO_FORTRAN_ENV
INTEGER,PARAMETER :: top_left = 11, bot_left = 21, top_right = 12, bot_right = 22
INTEGER,DIMENSION(16) :: quads = [top_left, top_left, bot_left, bot_left, &
top_left, top_left, bot_left, bot_left, &
top_right, top_right, bot_right, bot_right, &
top_right, top_right, bot_right, bot_right]
INTEGER,DIMENSION(16) :: images = [1, 2, 1, 2, 3, 4, 3, 4, 1, 2, 1, 2, 3, 4, 3, 4]
TYPE (TEAM_TYPE) :: quadrants, original_team
REAL :: co_array1[4,*], co_array2 [4, *]
INTEGER :: me
See Also
Image Control Statements
Coarrays
Using Coarrays
Construct Association
FORM TEAM
CHAR
Elemental Intrinsic Function (Generic): Returns
the character in the specified position of the
processor's character set. It is the inverse of the
function ICHAR.
Syntax
result = CHAR (i[,kind])
1343
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result is of type character with length 1. If kind is present, the kind parameter of the result is that
specified by kind; otherwise, the kind parameter of the result is that of default character. If the processor
cannot represent the result value in the kind of the result, the result is undefined.
The result is the character in position i of the processor's character set. ICHAR(CHAR ( i, kind( c))) has the
value I for 0 to n - 1 and CHAR(ICHAR( c), kind( c)) has the value c for any character c capable of
representation in the processor.
INTEGER(1) CHARACTER
INTEGER(2) CHARACTER
INTEGER(8) CHARACTER
1This specific function cannot be passed as an actual argument.
Example
CHAR (76) has the value 'L'.
See Also
ACHAR
IACHAR
ICHAR
Character and Key Code Charts
CHARACTER
Statement: Specifies the CHARACTER data type.
Syntax
CHARACTER ([LEN=]len [, [KIND=]n])
CHARACTER (KIND=n [, [LEN=]len])
CHARACTER* len
n Is kind 1.
len Is a string length (not a kind). For more information, see Declaration
Statements for Character Types.
If no kind type parameter is specified, the kind of the constant is
default character.
Example
C
C Length of wt and vs is 10, city is 80, and ch is 1
C
1344
Language Reference
See Also
Character Data Type
Character Constants
Character Substrings
C Strings
Declaration Statements for Character Types
CHDIR
Portability Function: Changes the default directory.
Module
USE IFPORT
Syntax
result = CHDIR(dir_name)
Results
The result type is INTEGER(4). It returns zero if the directory was changed successfully; otherwise, an error
code. Possible error codes are:
• ENOENT: The named directory does not exist.
• ENOTDIR: The dir_name parameter is not a directory.
Example
use ifport
integer(4) istatus, enoent, enotdir
character(255) newdir
character(300) prompt, errmsg
1345
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
write(*,*) TRIM(errmsg)
goto 10
See Also
CHANGEDIRQQ
CHMOD
Portability Function: Changes the access mode of a
file.
Module
USE IFPORT
Syntax
result = CHMOD (name,mode)
1346
Language Reference
[ugoa]*[+-=] [rwxXst]*
On Windows* systems, "[ugoa]*" is ignored. On Linux* and macOS* systems, a combination of the letters
"ugoa" control which users' access to the file will be changed:
u The user who owns the file
a All users
"[rwxXst]*" indicates the permission to add, subtract, or set. On Windows systems, only "w" is significant
and affects write permission; all other letters are ignored. On Linux and macOS* systems, all letters are
significant.
Results
The result type is INTEGER(4). It is zero if the mode was changed successfully; otherwise, an error code.
Possible error codes are:
• ENOENT: The specified file was not found.
• EINVAL: The mode argument is invalid.
• EPERM: Permission denied; the file's mode cannot be changed.
Example
USE IFPORT
integer(4) I,Istatus
I = ACCESS ("DATAFILE.TXT", "w")
if (i) then
1347
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
SETFILEACCESSQQ
CLASS
Statement: Declares a polymorphic object. It takes
one of the following forms:
Syntax
CLASS (name) att-list :: v-list
CLASS (*) att-list :: v-list
att-list Is one or more attribute specifiers. These are the same attribute
specifiers allowed for a derived-type TYPE statement.
v-list Is the name of one or more data objects or functions. The name can
optionally be followed by any of the following:
• An array specification, if the object is an array.
In a function declaration, an array must be a deferred-shape array
if it has the POINTER attribute; otherwise, it must be an explicit-
shape array.
• A character length, if the object is of type character.
• A coarray specification, if the object is a coarray.
• A constant expression preceded by an = or, for pointer objects, =>
NULL( ).
Description
A polymorphic object can have differing types during program execution.
The type of the object at a particular point during execution of a program is its dynamic type.
The declared type of a data entity is the type that it is declared to have, either explicitly or implicitly.
If CLASS (*) is specified, it denotes an unlimited polymorphic object. An unlimited polymorphic entity is not
declared to have a type. It is not considered to have the same declared type as any other entity, including
another unlimited polymorphic entity.
An entity declared with the CLASS keyword must be a dummy argument or have the ALLOCATABLE or
POINTER attribute.
A polymorphic entity that is not an unlimited polymorphic entity is type compatible with entities of the same
declared type or any of its extensions. Even though an unlimited polymorphic entity is not considered to have
a declared type, it is type compatible with all entities. An entity is said to be type compatible with a type if it
is type compatible with entities of that type.
A polymorphic allocatable object can be allocated to be of any type with which it is type compatible.
During program execution, a polymorphic pointer or dummy argument can be associated with objects with
which it is type compatible.
1348
Language Reference
See Also
Type declarations
TYPE Statement (Derived Types)
CLEARSCREEN (W*S)
Graphics Subroutine: Erases the target area and fills
it with the current background color.
Module
USE IFQWIN
Syntax
CALL CLEARSCREEN (area)
area (Input) INTEGER(4). Identifies the target area. Must be one of the
following symbolic constants (defined in IFQWIN.F90):
All pixels in the target area are set to the color specified with SETBKCOLORRGB. The default color is black.
Example
USE IFQWIN
CALL CLEARSCREEN($GCLEARSCREEN)
See Also
GETBKCOLORRGB
SETBKCOLORRGB
SETTEXTWINDOW
SETVIEWPORT
CLEARSTATUSFPQQ
Portability Subroutine: Clears the exception flags in
the floating-point processor status word.
Module
USE IFPORT
Syntax
CALL CLEARSTATUSFPQQ()
Description
The floating-point status word indicates which floating-point exception conditions have occurred. Intel®
Fortran initially clears (sets to 0) all floating-point status flags, but as exceptions occur, the status flags
accumulate until the program clears the flags again. CLEARSTATUSFPQQ will clear the flags.
CLEARSTATUSFPQQ is appropriate for use in applications that poll the floating-point status register as the
method for detecting a floating-point exception has occurred.
1349
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
For a full description of the floating-point status word, exceptions, and error handling, see Floating-Point
Operations: Floating-Point Environment.
Example
USE IFPORT
REAL*4 A,B,C
INTEGER*2 STS
A = 2.0E0
B = 0.0E0
END
This program is available in the online samples.
See Also
GETSTATUSFPQQ
SETCONTROLFPQQ
GETCONTROLFPQQ
SIGNALQQ
CLICKMENUQQ (W*S)
QuickWin Function: Simulates the effect of clicking
or selecting a menu command. The QuickWin
application responds as though the user had clicked or
selected the command.
1350
Language Reference
Module
USE IFQWIN
Syntax
result = CLICKMENUQQ (item)
Results
The result type is INTEGER(4). The result is zero if successful; otherwise, nonzero.
See Also
REGISTERMOUSEEVENT
UNREGISTERMOUSEEVENT
WAITONMOUSEEVENT
CLOCK
Portability Function: Converts a system time into an
8-character ASCII string.
Module
USE IFPORT
Syntax
result = CLOCK( )
Results
The result type is character with a length of 8. The result is the current time in the form hh:mm:ss, using a
24-hour clock.
Example
USE IFPORT
character(8) whatimeisit
whatimeisit = CLOCK ()
print *, 'The current time is ',whatimeisit
See Also
DATE_AND_TIME
CLOCKX
Portability Subroutine: Returns the processor clock
in units of microseconds.
1351
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Module
USE IFPORT
Syntax
CALL CLOCKX (clock)
On Windows systems, this subroutine has millisecond precision, and the last three digits of the returned
value are not significant.
CLOSE
Statement: Disconnects a file from a unit.
Syntax
CLOSE ( [UNIT=] io-unit[, {STATUS | DISPOSE | DISP} = p] [, ERR= label] [, IOMSG=msg-var]
[, IOSTAT=i-var])
label Is the label of the branch target statement that receives control if an
error occurs.
1352
Language Reference
Description
The CLOSE statement specifiers can appear in any order. An I/O unit must be specified, but the UNIT=
keyword is optional if the unit specifier is the first item in the I/O control list.
The status specified in the CLOSE statement supersedes the status specified in the OPEN statement, except
that a file opened as a scratch file cannot be saved, printed, or submitted, and a file opened for read-only
access cannot be deleted.
If a CLOSE statement is specified for a unit that is not open, it has no effect.
You do not need to explicitly close open files. Normal program termination closes each file according to its
default status. The CLOSE statement does not have to appear in the same program unit that opened the file.
Closing unit 0 automatically reconnects unit 0 to the keyboard and screen. Closing units 5 and 6
automatically reconnects those units to the keyboard or screen, respectively.Closing the asterisk (*) unit
causes a compile-time error. In Windows QuickWin applications, use CLOSE with unit 0, 5, or 6 to close the
default window. If all of these units have been detached from the console (through an explicit OPEN), you
must close one of these units beforehand to reestablish its connection with the console. You can then close
the reconnect unit to close the default window.
If a parameter of the CLOSE statement is an expression that calls a function, that function must not cause an
I/O operation or the EOF intrinsic function to be executed, because the results are unpredictable.
NOTE
You may get unexpected results if you specify OPEN with a filename and a USEROPEN
specifier that opens a different filename, and then use a CLOSE statement with
STATUS=DELETE (or DISPOSE=DELETE). In this case, the run-time library assumes you
want to delete the file named in the OPEN statement, not the one you specified in the
USEROPEN function. For more information about how to use the USEROPEN specifier, see
User-Supplied OPEN Procedures: USEROPEN Specifier.
Example
! Close and discard file:
CLOSE (7, STATUS = 'DELETE')
Consider the following statement:
See Also
Data Transfer I/O Statements
Branch Specifiers
CMPLX
Elemental Intrinsic Function (Specific): Converts
the argument to complex type. This function cannot
be passed as an actual argument.
Syntax
This intrinsic function can take one of the following forms:
result = CMPLX (x [,kind])
1353
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
or
result = CMPLX (x [,y ,kind])
Results
The result type is complex. If kind is present, the kind parameter is that specified by kind; otherwise, the
kind parameter is that of default real type.
If x is type complex, y must not be specified, and the result value is CMPLX (REAL (x), AIMAG (x)), with
default kind if kind is not present, otherwise with the kind type as specified by kind.
If x is present and not of complex type, and y is not present, x is converted into the real part of the result
value and zero is assigned to the imaginary part.
If x and y are present, the complex value is produced by converting the x into the real part of the value, and
converting the y into the imaginary part.
CMPLX (x, y, kind) has the complex value whose real part is REAL (x, kind) and whose imaginary part is
REAL (y, kind).
The setting of compiler options specifying real size can affect this function.
If the argument is a binary, octal, or hexadecimal literal constant, the result is affected by the
assume old-boz option. The default option setting, noold-boz, treats the argument as a bit string that
represents a value of the data type of the intrinsic, that is, the bits are not converted. If setting old-boz is
specified, the argument is treated as a signed integer and the bits are converted.
NOTE
The result values of CMPLX are defined by references to the intrinsic function REAL with the
same arguments. Therefore, the padding and truncation of binary, octal, and hexadecimal
literal constant arguments to CMPLX is the same as for the intrinsic function REAL.
Example
CMPLX (-3) has the value (-3.0, 0.0).
CMPLX (4.1, 2.3) has the value (4.1, 2.3).
The following shows another example:
COMPLEX z1, z2
COMPLEX(8) z3
z1 = CMPLX(3) ! returns the value 3.0 + i 0.0
z2 = CMPLX(3,4) ! returns the value 3.0 + i 4.0
z3 = CMPLX(3,4,8) ! returns a COMPLEX(8) value 3.0D0 + i 4.0D0
See Also
Binary, Octal, Hexadecimal, and Hollerith Constants
1354
Language Reference
CO_BROADCAST
Collective Intrinsic Subroutine (Generic):
Broadcasts a value to other images.
Syntax
CALL CO_BROADCAST (a, source_image [, stat, errmsg])
a (Input; output) Must have the same shape, dynamic type, and type
parameter values in corresponding references across all participating
images. It cannot be a coindexed object. If an error occurs, it
becomes undefined. Otherwise, a becomes defined as if by intrinsic
assignment with the value a on image source_image on all images of
the current team.
source_image (Input) Must be a scalar integer. The value of source_image must the
value of an image index of an image on the current team. Its value
must be the same in corresponding references on all images
participating in the collective operation.
Example
Consider the following:
See Also
Overview of Collective Subroutines
CO_MAX
Collective Intrinsic Subroutine (Generic):
Calculates the maximum value across images.
1355
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
CALL CO_MAX (a [, result_image, stat, errmsg])
a (Input; output) Must be of type real, integer, or charater, and have the
same shape, type, and type parameter values in corresponding
references across all images of the current team. It cannot be a
coindexed object. If it is scalar, the computed value is the maximum
value of a in all corresponding references. If it is an array, each
element of the computed value is equal to the maximum value of the
corresponding element of a in all corresponding references.
If no error occurs, the computed value is assigned to a on all images
of the current team if result_image is not present, or on the executing
image if the executing image is the image identified by result_image.
Otherwise, a becomes undefined.
Example
Consider the following:
See Also
Overview of Collective Subroutines
CO_MIN
Collective Intrinsic Subroutine (Generic):
Calculates the minimum value across images.
Syntax
CALL CO_MIN (a [, result_image, stat, errmsg])
a (Input; output) Must be of type real, integer, or charater, and have the
same shape, type, and type parameter values in corresponding
references across all images of the current team. It cannot be a
1356
Language Reference
Example
Consider the following:
See Also
Overview of Collective Subroutines
CO_REDUCE
Collective Intrinsic Subroutine (Generic):
Performs generalized reduction across images.
Syntax
CALL CO_REDUCE (a, operation [, result_image, stat, errmsg])
1357
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
operation Is a pure function with exactly two arguments whose result and each
argument are a scalar, nonallocatable, nonpointer, nonpolymorphic
data object with the same type and kind type parameters as a.
Neither argument can be optional. If one argument has the attribute
TARGET, VOLATILE, or ASYNCHRONOUS, the other argument must
have that attribute. operation must implement a mathematical
associative operation and be the same in each corresponding
reference. If operation is not commutative, the computed value may
depend on the order of evaluation.
The computed value of a reduction operation over a set of values is
the result of an iterative process. Each iteration evaluates operation
(x, y) for x and y in that set, the removal of x and y from that set, and
the addition of the result of operation (x, y) to that set. The process
ends when the set has a single value, which is the computed value.
Example
The following subroutine demonstrates how CO_REDUCE can be used to create a collective version of the
intrinsic function ANY.
See Also
Overview of Collective Subroutines
1358
Language Reference
CO_SUM
Collective Intrinsic Subroutine (Generic):
Performs a sum reduction across images.
Syntax
CALL CO_SUM (a [, result_image, stat, errmsg])
Example
Consider the following:
See Also
Overview of Collective Subroutines
CODE_ALIGN
General Compiler Directive: Specifies the byte
alignment for a loop.
1359
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
!DIR$ CODE_ALIGN [:n]
Example
Consider the following code fragment in file test_code_align.f90:
!DIR$ CODE_ALIGN
DO J = 1, N
…
END DO
Compiling test_code_align.f90 aligns the code that begins the DO J loop on a (default) 16-byte boundary.
If you do not specify the CODE_ALIGN directive, the alignment of the loop is implementation-dependent and
may change from compilation to compilation.
See Also
General Compiler Directives
Syntax Rules for Compiler Directives
falign-loops, Qalign-loops compiler option
ATTRIBUTES CODE_ALIGN directive
CODIMENSION
Statement and Attribute: Specifies that an entity is
a coarray, and specifies its corank and cobounds, if
any.
Syntax
The CODIMENSION attribute can be specified in a type declaration statement or a CODIMENSION statement,
and takes one of the following forms:
Type Declaration Statement:
type, [att-ls,] CODIMENSION [coarray-spec] :: var-list [(array-spec)]...
type, [att-ls,] var-list [(array-spec)] [coarray-spec]...
Statement:
CODIMENSION [::] var-list [coarray-spec]...
1360
Language Reference
Description
In Intel® Fortran, the sum of the rank and corank of an entity must not exceed 31. The Fortran 2018
Standard allows a combined rank of up to 15.
A coarray must be a component or a variable that is not a function result.
A coarray must not be of type C_PTR or C_FUNPTR from the intrinsic module ISO_C_BINDING or of type
TEAM_TYPE from the intrinsic module ISO_FORTRAN_ENV.
An entity whose type has a coarray ultimate component must be a nonpointer nonallocatable scalar, must not
be a coarray, and must not be a function result.
A coarray or an object with a coarray ultimate component must be an associate name, a dummy argument,
or have the ALLOCATABLE or SAVE attribute.
A coarray must not be a dummy argument of a procedure that has a BIND attribute.
A coarray can be a derived type with pointer or allocatable components. The target of such a pointer
component is always on the same image as the pointer.
Examples
Explicit-shape coarrays that are not dummy arguments must have the SAVE attribute. Because of this,
automatic coarrays are not allowed. For example, coarray TASK in the following code is not valid:
SUBROUTINE SUBA(I,C,D)
INTEGER :: I
REAL :: C(I)[*], D(I)
REAL :: TASK(I)[*] ! Not permitted
The following lines show valid examples of CODIMENSION attribute specifications:
COLLAPSE Clause
Parallel Directive Clause: Specifies how many loops
are associated with a loop construct.
Syntax
COLLAPSE (n)
1361
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The iteration count for each associated loop is computed before entry
to the outermost loop. If execution of any associated loop changes
any of the values used to compute any of the iteration counts, then
the behavior is unspecified. The integer kind used to compute the
iteration count for the collapsed loop is implementation defined.
If COLLAPSE is not specified, the only loop that is associated with the loop construct is the one that
immediately follows the construct.
At most one COLLAPSE clause can appear in a directive that allows the clause.
See Nested DO Constructs for restrictions on perfectly nested loops using COLLAPSE.
If more than one loop is associated with a TASKLOOP construct, then the iterations of all associated loops are
collapsed into one larger iteration space that is then divided according to the specifications in the GRAINSIZE
and NUM_TASKS clauses. The sequential execution of the iterations in all associated loops determines the
order of the iterations in the collapsed iteration space.
COMAddObjectReference (W*S)
COM Function: Adds a reference to an object's
interface.
Module
USE IFCOM
Syntax
result = COMAddObjectReference (iunknown)
Results
The result type is INTEGER(4). It is the object's current reference count.
See Also
IUnknown::AddRef in the Microsoft* Platform SDK
COMCLSIDFromProgID (W*S)
COM Subroutine: Passes a programmatic identifier
and returns the corresponding class identifier.
Module
USE IFCOM
USE IFWINTY
Syntax
CALL COMCLSIDFromProgID (prog_id,clsid,status)
1362
Language Reference
See Also
CLSIDFromProgID in the Microsoft* Platform SDK
COMCLSIDFromString (W*S)
COM Subroutine: Passes a class identifier string and
returns the corresponding class identifier.
Module
USE IFCOM
USE IFWINTY
Syntax
CALL COMCLSIDFromString (string,clsid,status)
See Also
CLSIDFromString in the Microsoft* Platform SDK
COMCreateObject (W*S)
COM Subroutine: A generic routine that executes
either COMCreateObjectByProgID or
COMCreateObjectByGUID.
Module
USE IFCOM
USE IFWINTY
Description
Your application obtains its first pointer to an object’s interface by calling COMCreateObject. It creates a
new instance of an object class and returns a pointer to it.
See Also
COMCreateObjectByGUID
COMCreateObjectByProgID
COMCreateObjectByGUID (W*S)
COM Subroutine: Passes a class identifier, creates
an instance of an object, and returns a pointer to the
object's interface.
1363
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Module
USE IFCOM
USE IFWINTY
Syntax
CALL COMCreateObjectByGUID (clsid,clsctx,iid,interface,status)
clsctx Lets you restrict the types of servers used for the object. Must be of
type INTEGER(4). Must be one of the CLSCTX_* constants defined in
the IFWINTY module.
interface An output argument that returns the object's interface pointer. Must
be of type INTEGER(INT_PTR_KIND()).
See Also
CoCreateInstance in the Microsoft* Platform SDK
COMCreateObjectByProgID (W*S)
COM Subroutine: Passes a programmatic identifier,
creates an instance of an object, and returns a pointer
to the object's IDispatch interface.
Module
USE IFCOM
Syntax
CALL COMCreateObjectByProgID (prog_id,idispatch,status)
See Also
COMCLSIDFromProgID
CoCreateInstance in the OLE section of the Microsoft* Platform SDK
1364
Language Reference
COMGetActiveObjectByGUID (W*S)
COM Subroutine: Passes a class identifier and
returns a pointer to the interface of a currently active
object.
Module
USE IFCOM
USE IFWINTY
Syntax
CALL COMGetActiveObjectByGUID (clsid,iid,interface,status)
clsid The class identifier of the class of object to be found. Must be of type
GUID, which is defined in the IFWINTY module.
interface An output argument that returns the object's interface pointer. Must
be of type INTEGER(INT_PTR_KIND()).
See Also
GetActiveObject in the Microsoft* Platform SDK
COMGetActiveObjectByProgID (W*S)
COM Subroutine: Passes a programmatic identifier
and returns a pointer to the IDispatch interface of a
currently active object.
Module
USE IFCOM
Syntax
CALL COMGetActiveObjectByProgID (prog_id,idispatch,status)
Example
See the example in COMInitialize.
See Also
CLSIDFromProgID and GetActiveObject in the Microsoft* Platform SDK
1365
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
COMGetFileObject (W*S)
COM Subroutine: Passes a file name and returns a
pointer to the IDispatch interface of an automation
object that can manipulate the file.
Module
USE IFCOM
Syntax
CALL COMGetFileObject (filename,idispatch,status)
status The status of the operation. It can be any status returned by the
CreateBindCtx or MkParseDisplayName routines, or the
IMoniker::BindToObject method. Must be of type INTEGER(4).
See Also
CreateBindCtx, MkParseDisplayName, and IMonker::BindToObject in the Microsoft* Platform SDK
COMInitialize (W*S)
COM Subroutine: Initializes the COM library.
Module
USE IFCOM
Syntax
CALL COMInitialize (status)
You must use this routine to initialize the COM library before calling any other COM or AUTO routine.
Example
Consider the following:
program COMInitExample
use ifwin
use ifcom
use ifauto
implicit none
! Variables
integer(4) word_app
integer(4) status
integer(INT_PTR_KIND()) invoke_args
call COMInitialize(status)
1366
Language Reference
call COMUninitialize()
end program
See Also
OleInitialize in the Microsoft* Platform SDK
COMIsEqualGUID (W*S)
COM Function: Determines whether two globally
unique identifiers (GUIDs) are the same.
Module
USE IFCOM
USE IFWINTY
Syntax
result = COMIsEqualGUID (guid1,guid2)
guid1 The first GUID. Must be of type GUID, which is defined in the IFWINTY
module. It can be any type of GUID, including a class identifier
(CLSID), or an interface identifier (IID).
guid2 The second GUID, which will be compared to guid1. It must be the
same type of GUID as guid1. For example, if guid1 is a CLSID,
guid2 must also be a CLSID.
Results
The result type is LOGICAL(4). The result is .TRUE. if the two GUIDs are the same; otherwise, .FALSE.
See Also
IsEqualGUID in the Microsoft* Platform SDK
COMMAND_ARGUMENT_COUNT
Inquiry Intrinsic Function (Generic): Returns the
number of command arguments.
Syntax
result = COMMAND_ARGUMENT_COUNT ()
1367
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result is a scalar of type default integer. The result value is equal to the number of command arguments
available. If there are no command arguments available, the result is 0. The command name does not count
as one of the command arguments.
Example
Consider the following:
program echo_command_line
integer i, cnt, len, status
character c*30, b*100
cnt = command_argument_count ()
write (*,*) 'number of command arguments = ', cnt
do i = 1, cnt
call get_command_argument (i, c, len, status)
if (status .ne. 0) then
write (*,*) 'get_command_argument failed: status = ', status, ' arg = ', i
stop
end if
write (*,*) 'command arg ', i, ' = ', c (1:len)
end do
1368
Language Reference
GET_COMMAND
GET_COMMAND_ARGUMENT
COMMITQQ
Run-Time Function: Forces the operating system to
execute any pending write operations for the file
associated with a specified unit to the file's physical
device.
Module
USE IFCORE
Syntax
result = COMMITQQ (unit)
Results
The result type is LOGICAL(4). If an open unit number is supplied, .TRUE. is returned and uncommitted
records (if any) are written. If an unopened unit number is supplied, .FALSE. is returned.
Data written to files on physical devices is often initally written into operating-system buffers and then
written to the device when the operating system is ready. Data in the buffer is automatically flushed to disk
when the file is closed. However, if the program or the computer crashes before the data is transferred from
buffers, the data can be lost. COMMITQQ tells the operating system to write any cached data intended for a
file on a physical device to that device immediately. This is called flushing the file.
COMMITQQ is most useful when you want to be certain that no loss of data occurs at a critical point in your
program; for example, after a long calculation has concluded and you have written the results to a file, or
after the user has entered a group of data items, or if you are on a network with more than one program
sharing the same file. Flushing a file to disk provides the benefits of closing and reopening the file without
the delay.
Example
USE IFCORE
INTEGER unit / 10 /
INTEGER len
CHARACTER(80) stuff
OPEN(unit, FILE='COMMITQQ.TST', ACCESS='Sequential')
DO WHILE (.TRUE.)
WRITE (*, '(A, \)') 'Enter some data (Hit RETURN to &
exit): '
len = GETSTRQQ (stuff)
IF (len .EQ. 0) EXIT
WRITE (unit, *) stuff
IF (.NOT. COMMITQQ(unit)) WRITE (*,*) 'Failed'
END DO
CLOSE (unit)
END
See Also
PRINT
WRITE
1369
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
COMMON
Statement: Defines one or more contiguous areas, or
blocks, of physical storage (called common blocks)
that can be accessed by any of the scoping units in an
executable program. COMMON statements also define
the order in which variables and arrays are stored in
each common block, which can prevent misaligned
data items. COMMON is an obsolescent language
feature in Standard Fortran.
Syntax
COMMON [ /[cname]/] var-list[[,] /[cname]/ var-list]...
cname (Optional) Is the name of the common block. The name can be
omitted for blank common (//).
Description
Common blocks can be named or unnamed (a blank common).
A common block is a global entity, and must not have the same name as any other global entity in the
program, such as a subroutine or function.
Any common block name (or blank common) can appear more than once in one or more COMMON
statements in a program unit. The list following each successive appearance of the same common block
name is treated as a continuation of the list for the block associated with that name. Consider the following
COMMON statements:
• A dummy argument
• A result variable
• An allocatable variable
• A derived-type object with an ultimate component that is allocatable
• A procedure pointer
• An automatic object
• A variable with the BIND attribute
1370
Language Reference
Any other intrinsic type Must have the same type and kind parameters
So, variables can be associated if they are of different numeric type. For example, the following is valid:
INTEGER A(20)
REAL Y(20)
COMMON /QUANTA/ A, Y
When common blocks from different program units have the same name, they share the same storage area
when the units are combined into an executable program.
Entities are assigned storage in common blocks on a one-for-one basis. So, the data type of entities assigned
by a COMMON statement in one program unit should agree with the data type of entities placed in a common
block by another program unit. For example:
...
When these program units are combined into an executable program, incorrect results can occur if the 2-byte
integer variable MONEY is made to correspond to the lower-addressed two bytes of the real variable CENTS.
Named common blocks must be declared to have the same size in each program unit. Blank common can
have different lengths in different program units.
NOTE
If a common block is initialized by a DATA statement, the module containing the initialization
must declare the common block to be its maximum defined length.
This limitation does not apply if you compile all source modules together.
1371
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
PROGRAM MyProg
COMMON i, j, x, k(10)
COMMON /mycom/ a(3)
...
END
SUBROUTINE MySub
COMMON pe, mn, z, idum(10)
COMMON /mycom/ a(3)
...
END
In the following example, the COMMON statement in the main program puts HEAT and X in blank common,
and KILO and Q in a named common block, BLK1:
...
CALL FIGURE
... RETURN
END
The COMMON statement in the subroutine makes ALFA and BET share the same storage location as HEAT and
X in blank common. It makes LIMA and R share the same storage location as KILO and Q in BLK1.
The following example shows how a COMMON statement can be used to declare arrays:
SUBROUTINE unit1
REAL(8) x(5)
INTEGER J
CHARACTER str*12
TYPE(member) club(50)
COMMON / blocka / x, j, str, club
...
SUBROUTINE unit2
REAL(8) z(5)
INTEGER m
CHARACTER chr*12
TYPE(member) myclub(50)
COMMON / blocka / z, m, chr, myclub
...
See also the example for BLOCK DATA.
See Also
BLOCK DATA
DATA
1372
Language Reference
MODULE
EQUIVALENCE
Specification expressions
Storage association
Interaction between COMMON and EQUIVALENCE Statements
Obsolescent Language Features in the Fortran Standard
COMPILER_OPTIONS
Module Intrinsic Inquiry Function: Returns a
string containing the compiler options that were used
for compilation.
Module
USE ISO_FORTRAN_ENV
Syntax
result = COMPILER_OPTIONS( )
Results
The result is a scalar of type default character of processor-defined length.
The return value is a list of the compiler options that were used for compilation.
Example
Consider the following file named t.f90:
use ISO_FORTRAN_ENV
res = compiler_options ()
print *, "len of res is: ", len (res)
print *, "('<<', A, '>>')") res
deallocate (res)
end
The following is the output:
On Windows:
-out:t.exe
-subsystem:console
t.obj
Win> t.exe
len of compiler_options is: 48
<</exe:t /warn:alignments /assume:writeable-strings>>
1373
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
On Linux:
COMPILER_VERSION
Module Intrinsic Inquiry Function: Returns a
string containing the name and version number of the
compiler used for compilation.
Module
USE ISO_FORTRAN_ENV
Syntax
result = COMPILER_VERSION( )
Results
The result is a scalar of type default character of processor-defined length.
The return value contains the name and version number of the compiler used for compilation.
Example
Consider the following file named t.f90:
use ISO_FORTRAN_ENV
res = compiler_version ()
print *, "len of res is: ", len (res)
print *, "('<<', A, '>>')", res
deallocate (res)
close (1)
end
The following is the output:
On Windows, with generic labels like user so the length displayed is not accurate:
-out:t.exe
-subsystem:console
t.obj
1374
Language Reference
Win> t.exe
len of res is: 184
Win>
On Linux, with generic labels like user so the length displayed is not accurate:
Lin$
See Also
COMPILER_OPTIONS
ISO_FORTRAN_ENV Module
COMPLEX Statement
Statement: Specifies the COMPLEX data type.
Syntax
COMPLEX
COMPLEX([KIND=] n)
COMPLEX*s
DOUBLE COMPLEX
n Is kind 4, 8, or 16.
If a kind parameter is specified, the complex constant has the kind specified. If no kind parameter is
specified, the kind of both parts is default real, and the constant is of type default complex.
DOUBLE COMPLEX is COMPLEX(8). No kind parameter is permitted for data declared with type DOUBLE
COMPLEX.
Example
COMPLEX ch
COMPLEX (KIND=4),PRIVATE :: zz, yy !equivalent to COMPLEX*8 zz, yy
COMPLEX(8) ax, by !equivalent to COMPLEX*16 ax, by
COMPLEX (kind(4)) y(10)
complex (kind=8) x, z(10)
See Also
DOUBLE COMPLEX
Complex Data Type
1375
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
COMPLEX(4) Constants
COMPLEX(8) or DOUBLE COMPLEX Constants
Data Types, Constants, and Variables
Module
USE IFPORT
Syntax
result = COMPLINT (intval)
result = COMPREAL (realval)
result = COMPLLOG (logval)
Results
The result is INTEGER(4) for COMPLINT, REAL(4) for COMPLREAL and LOGICAL(4) for COMPLLOG with a
value that is the bitwise complement of the argument.
COMQueryInterface (W*S)
COM Subroutine: Passes an interface identifier and
returns a pointer to an object's interface.
Module
USE IFCOM
USE IFWINTY
Syntax
CALL COMQueryInterface (iunknown,iid,interface,status)
interface An output argument that returns the object's interface pointer. Must
be of type INTEGER(INT_PTR_KIND()).
status The status of the operation. It can be any status returned by the
IUnknown method QueryInterface. Must be of type INTEGER(4).
See Also
IUnknown::QueryInterface in the Microsoft* Platform SDK
1376
Language Reference
COMReleaseObject (W*S)
COM Function: Indicates that the program is done
with a reference to an object's interface.
Module
USE IFCOM
Syntax
result = COMReleaseObject (iunknown)
Results
The result type is INTEGER(4). It is the object's current reference count.
Example
See the example in COMInitialize.
COMStringFromGUID (W*S)
COM Subroutine: Passes a globally unique identifier
(GUID) and returns a string of printable characters.
Module
USE IFCOM
USE IFWINTY
Syntax
CALL COMStringFromGUID (guid,string,status)
status The status of the operation. If the string is too small to contain the
string representation of the GUID, the value is zero. Otherwise, the
value is the number of characters in the string representation of the
GUID. Must be of type INTEGER(4).
The string representation of a GUID has a format like that of the following:
[c200e360-38c5-11ce-ae62-08002b2b79ef]
where the successive fields break the GUID into the form DWORD-WORD-WORD-WORD-WORD.DWORD
covering the 128-bit GUID. The string includes enclosing braces, which are an OLE convention.
See Also
StringFromGUID2 in the Microsoft* Platform SDK
1377
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
COMUninitialize (W*S)
COM Subroutine: Uninitializes the COM library.
Module
USE IFCOM
Syntax
CALL COMUninitialize( )
When using COM routines, this must be the last routine called.
Example
See the example in COMInitialize.
CONJG
Elemental Intrinsic Function (Generic): Calculates
the conjugate of a complex number.
Syntax
result = CONJG (z)
Results
The result type and kind are the same as z. If z has the value (x, y), the result has the value (x, -y).
Example
CONJG ((2.0, 3.0)) has the value (2.0, -3.0).
CONJG ((1.0, -4.2)) has the value (1.0, 4.2).
The following shows another example:
COMPLEX z1
COMPLEX(8) z2
z1 = CONJG((3.0, 5.6)) ! returns (3.0, -5.6)
z2 = DCONJG((3.0D0, 5.6D0)) ! returns (3.0D0, -5.6D0)
See Also
AIMAG
1378
Language Reference
CONTAINS
Statement: Separates the body of a main program,
module, submodule, or external subprogram from any
internal or module procedures it may contain, or it
introduces the type-bound procedure part of a
derived-type definition. It is not executable.
Syntax
CONTAINS
Any number of internal procedures can follow a CONTAINS statement, but a CONTAINS statement cannot
appear in the internal procedures themselves.
An empty CONTAINS section is allowed.
Example
PROGRAM OUTER
REAL, DIMENSION(10) :: A
. . .
CALL INNER (A)
CONTAINS
SUBROUTINE INNER (B)
REAL, DIMENSION(10) :: B
. . .
END SUBROUTINE INNER
END PROGRAM OUTER
See Also
Internal Procedures
Modules and Module Procedures
Main Program
CONTIGUOUS
Statement and Attribute: Specifies that the target
of a pointer or an assumed-sized array is contiguous.
Syntax
The CONTIGUOUS attribute can be specified in a type declaration statement or an CONTIGUOUS statement,
and takes one of the following forms:
Type Declaration Statement:
type, [att-ls,] CONTIGUOUS [, att-ls] :: object [, object] ...
Statement:
CONTIGUOUS [::] object [, object] ...
1379
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
This attribute explicitly indicates that an assumed-shape array is contiguous or that a pointer will only be
associated with a contiguous object.
An entity can be contiguous even if CONTIGUOUS is not specified. An object is contiguous if it is one of the
following:
An object is not contiguous if it is an array subobject, and all of the following are true:
The CONTIGUOUS attribute can make it easier to enable optimizations that rely on the memory layout of an
object occupying a contiguous block of memory.
Examples
The following examples show valid CONTIGUOUS statements:
See Also
Type Declarations
Compatible attributes
CONTINUE
Statement: Primarily used to terminate a labeled DO
construct when the construct would otherwise end
improperly with either a GO TO, arithmetic IF, or other
prohibited control statement.
Syntax
CONTINUE
The statement by itself does nothing and has no effect on program results or execution sequence.
1380
Language Reference
Example
The following example shows a CONTINUE statement:
DO 150 I = 1,40
40 Y = Y + 1
Z = COS(Y)
PRINT *, Z
IF (Y .LT. 30) GO TO 150
GO TO 40
150 CONTINUE
The following shows another example:
DIMENSION narray(10)
DO 100 n = 1, 10
narray(n) = 120
100 CONTINUE
See Also
END DO
DO
Execution Control
COPYIN Clause
Parallel Directive Clause: Specifies that the data in
the primary thread of the team is to be copied to the
thread private copies of the common block at the
beginning of the parallel region.
Syntax
COPYIN (list)
list Is the name of one or more variables or common blocks that are
accessible to the scoping unit. Subobjects cannot be specified. Each
name must be separated by a comma, and a named common block
must appear between slashes (/ /).
COPYPRIVATE Clause
Parallel Directive Clause: Uses a private variable to
broadcast a value, or a pointer to a shared object,
from one member of a team to the other members.
The COPYPRIVATE clause can only appear in the END
SINGLE directive.
Syntax
COPYPRIVATE (list)
1381
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
list Is the name of one or more variables or common blocks that are
accessible to the scoping unit. Subobjects cannot be specified. Each
name must be separated by a comma, and a named common block
must appear between slashes (/ /).
Variables in the list must not appear in a PRIVATE or FIRSTPRIVATE clause for the SINGLE directive
construct. A dummy argument that is a pointer with the INTENT (IN) attribute must not appear in a
COPYPRIVATE clause.
If the directive is encountered in the dynamic extent of a parallel region, variables in the list must be private
in the enclosing context.
If a common block is specified, it must be declared as THREADPRIVATE; the effect is the same as if the
variable names in its common block object list were specified.
The effect of the COPYPRIVATE clause on the variables in its list occurs after the execution of the code
enclosed within the SINGLE construct, and before any threads in the team have left the barrier at the end of
the construct.
COS
Elemental Intrinsic Function (Generic): Produces
the cosine of an argument.
Syntax
result = COS (x)
Results
The result type and kind are the same as x.
If x is of type real, the result is a value in radians.
If x is of type complex, the real part of the result is a value in radians.
Example
COS (2.0) has the value -0.4161468.
COS (0.567745) has the value 0.8431157.
1382
Language Reference
COSD
Elemental Intrinsic Function (Generic): Produces
the cosine of x.
Syntax
result = COSD (x)
Results
The result type and kind are the same as x.
Example
COSD (2.0) has the value 0.9993908.
COSD (30.4) has the value 0.8625137.
COSH
Elemental Intrinsic Function (Generic): Produces
a hyperbolic cosine.
Syntax
result = COSH (x)
Results
The result type and kind are the same as x.
If x is of type complex, the imaginary part of the result is in radians.
Example
COSH (2.0) has the value 3.762196.
COSH (0.65893) has the value 1.225064.
1383
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
COSHAPE
Inquiry Intrinsic Function (Generic): Returns the
sizes of codimensions of a coarray.
Syntax
result = COSHAPE (coarray [, kind])
Results
The result is an integer array of rank one whose size is equal to the corank of coarray. If kind is present, the
kind parameter of the result is that specified by kind; otherwise, the kind parameter of the result is that of
default integer.
The result has a value whose ith element is equal to the size of the ith codimension of coarray as provided by
UCOBOUND(coarray, i) − LCOBOUND(coarray, i) + 1.
The setting of compiler options specifying integer size can affect this function.
Example
Consider the following coarray declaration:
• RANK (X) == 2
• corank of X == 3
• SHAPE (X) == [10,20]
• COSHAPE (X) == [10,10,2]
• LCOBOUND (X) == [1, -1, 0]
• UCOBOUND (X) == [10, 8, 1]
See Also
Coarrays
Using Coarrays
CODIMENSION
LCOBOUND
UCOBOUND
COTAN
Elemental Intrinsic Function (Generic): Produces
the cotangent of x.
Syntax
result = COTAN (x)
1384
Language Reference
Results
The result type and kind are the same as x.
Example
COTAN (2.0) has the value -4.576575E-01.
COTAN (0.6) has the value 1.461696.
COTAND
Elemental Intrinsic Function (Generic): Produces
the cotangent of x.
Syntax
result = COTAND (x)
Results
The result type and kind are the same as x.
Example
COTAND (2.0) has the value 0.2863625E+02.
COTAND (0.6) has the value 0.9548947E+02.
COUNT
Transformational Intrinsic Function (Generic):
Counts the number of true elements in an entire array
or in a specified dimension of an array.
Syntax
result = COUNT (mask[,dim][, kind])
1385
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result is an array or a scalar of type integer. If kind is present, the kind parameter of the result is that
specified by kind; otherwise, the kind parameter of the result is that of default integer. If the processor
cannot represent the result value in the kind of the result, the result is undefined.
The result is a scalar if dim is omitted or mask has rank one. A scalar result has a value equal to the number
of true elements of mask. If mask has size zero, the result is zero.
An array result has a rank that is one less than mask, and shape (d1, d2, ..., ddim-1, ddim+1, ..., dn), where
(d1, d2,..., dn) is the shape of mask.
Each element in an array result equals the number of elements that are true in the one dimensional array
defined by mask(s1, s2, ..., sdim-1, :, sdim+1, ..., sn).
Example
COUNT ((/.TRUE., .FALSE., .TRUE./)) has the value 2 because two elements are true.
COUNT ((/.TRUE., .TRUE., .TRUE./)) has the value 3 because three elements are true.
A is the array
[ 1 5 7 ]
[ 3 6 8 ]
and B is the array
[ 0 5 7 ]
[ 2 6 9 ].
COUNT (A .NE. B, DIM=1) tests to see how many elements in each column of A are not equal to the
elements in the corresponding column of B. The result has the value (2, 0, 1) because:
• The first column of A and B have 2 elements that are not equal.
• The second column of A and B have 0 elements that are not equal.
• The third column of A and B have 1 element that is not equal.
COUNT (A .NE. B, DIM=2) tests to see how many elements in each row of A are not equal to the elements in
the corresponding row of B. The result has the value (1, 2) because:
• The first row of A and B have 1 element that is not equal.
• The second row of A and B have 2 elements that are not equal.
The following shows another example:
See Also
ALL
ANY
1386
Language Reference
CPU_TIME
Intrinsic Subroutine (Generic): Returns a
processor-dependent approximation of the processor
time in seconds. Intrinsic subroutines cannot be
passed as actual arguments.
Syntax
CALL CPU_TIME (time)
The time returned is summed over all active threads. The result is the sum (in units of seconds) of the
current process's user time and the user and system time of all its child processes, if any.
If a meaningful time cannot be returned, a processor-dependent negative value is returned.
NOTE
If you want to estimate performance or scaling of multithreaded applications, you should use intrinsic
subroutine SYSTEM_CLOCK or portability function DCLOCK. Both of these routines return the elapsed
time from a single clock.
Example
Consider the following:
See Also
DCLOCK
SYSTEM_CLOCK
CRITICAL Directive
OpenMP* Fortran Compiler Directive: Restricts
access to a block of code to only one thread at a time.
Syntax
!$OMP CRITICAL [(name)]
block
!$OMP END CRITICAL [(name)]
1387
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The binding thread set for a CRITICAL construct is all threads in the contention group. Region execution is
restricted to a single thread at a time among all threads in the contention group, without regard to the teams
to which the threads belong.
A thread waits at the beginning of a critical section until no other thread in the team is executing a critical
section having the same name. All unnamed CRITICAL directives map to the same name.
If a name is specified in the CRITICAL directive, the same name must appear in the corresponding END
CRITICAL directive. If no name appears in the CRITICAL directive, no name can appear in the corresponding
END CRITICAL directive.
Critical section names are global entities of the program. If the name specified conflicts with any other entity,
the behavior of the program is undefined.
Example
The following example shows a queuing model in which a task is dequeued and worked on. To guard against
multiple threads dequeuing the same task, the dequeuing operation is placed in a critical section.
Because there are two independent queues in this example, each queue is protected by CRITICAL directives
having different names, XAXIS and YAXIS, respectively:
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
Parallel Processing Model for information about Binding Sets
CRITICAL Statement
Statement: Marks the beginning of a CRITICAL
construct. A CRITICAL construct limits execution of a
block to one image at a time.
Syntax
[name:] CRITICAL [([STAT=stat-var] [, ERRMSG=err-var])]
block
END CRITICAL [name]
1388
Language Reference
Description
If a construct name is specified in a CRITICAL statement, the same name must appear in the corresponding
END CRITICAL statement. If no name is specified at the beginning of a CRITICAL statement, you cannot
specify one following the END CRITICAL statement. The same construct name must not be used for different
named constructs in the same scoping unit.
The block of a CRITICAL construct must not contain a RETURN statement or an image control statement.
A branch within a CRITICAL construct must not have a branch target that is outside the construct. A branch
to the END CRITICAL statement is permitted from within the construct.
STAT= and ERRMSG= specifiers can appear in any order. Each may appear at most once.
Execution of the CRITICAL construct is completed when execution of its block is completed. A procedure that
is invoked, directly or indirectly, from a CRITICAL construct must not execute an image control statement.
If no error condition occurs during the execution of the construct, stat-var becomes defined with the value
zero. If the image that previously entered the construct failed while executing the construct, stat-var
becomes defined with the value STAT_FAILED_IMAGE defined in the intrinsic module ISO_FORTRAN_ENV. If
any other error occurs and STAT= is specified, stat-var becomes defined with a positive integer value other
than that of STAT_FAILED_IMAGE. Otherwise, if an error occurs, error termination is initiated.
If ERRMSG= is specified and an error condition occurs during execution of the construct, err-var becomes
defined with a descriptive message describing the nature of the error.
The processor ensures that once an image has commenced executing block, no other image can start
executing block until this image has completed executing block. The image must not execute an image
control statement during the execution of block. The sequence of executed statements is therefore a
segment. If image S is the next to execute the construct after image N, the segment on image N precedes
the segment on image S.
If more than one image executes the block of a CRITICAL construct, its execution by one image always
precedes or succeeds its execution by another image. Normally no other statement ordering is needed.
Example
Consider the following example:
CONA: CRITICAL
MY_COUNTER[1] = MY_COUNTER[1] + 1
END CRITICAL CONA
The definition of MY_COUNTER [1] by a particular image will always precede the reference to the same
variable by the next image to execute the block.
The following example shows a way to share a large number of tasks among images:
1389
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
END IF
END DO
SYNC ALL
See Also
Image Control Statements
Coarrays
Using Coarrays
ISO_FORTRAN_ENV Module
CSHIFT
Transformational Intrinsic Function (Generic):
Performs a circular shift on a rank-one array, or
performs circular shifts on all the complete rank-one
sections (vectors) along a given dimension of an array
of rank two or greater.
Syntax
Elements shifted off one end are inserted at the other end. Different sections can be shifted by different
amounts and in different directions.
result = CSHIFT (array,shift [,dim])
array (Input) Array whose elements are to be shifted. It can be of any data
type.
dim (Input; optional) Optional dimension along which to perform the shift.
Must be a scalar integer with a value in the range 1 to n, where n is
the rank of array. If dim is omitted, it is assumed to be 1.
Results
The result is an array with the same type and kind parameters, and shape as array.
If array has rank one, element i of the result is array(1 + MODULO (i + shift- 1, SIZE ( array))). (The same
shift is applied to each element.)
If array has rank greater than one, each section (s1,s2, ..., sdim-1, :, sdim+1, ..., sn) of the result is shifted as
follows:
• By the value of shift, if shift is scalar
• According to the corresponding value in shift(s1, s2,..., sdim-1, sdim+1,..., sn), if shift is an array
The value of shift determines the amount and direction of the circular shift. A positive shift value causes a
shift to the left (in rows) or up (in columns). A negative shift value causes a shift to the right (in rows) or
down (in columns). A zero shift value causes no shift.
Example
V is the array (1, 2, 3, 4, 5, 6).
CSHIFT (V, SHIFT=2) shifts the elements in V circularly to the left by 2 positions, producing the value (3, 4,
5, 6, 1, 2). 1 and 2 are shifted off the beginning and inserted at the end.
1390
Language Reference
CSHIFT (V, SHIFT= -2) shifts the elements in V circularly to the right by 2 positions, producing the value (5,
6, 1, 2, 3, 4). 5 and 6 are shifted off the end and inserted at the beginning.
M is the array
[ 1 2 3 ]
[ 4 5 6 ]
[ 7 8 9 ].
CSHIFT (M, SHIFT = 1, DIM = 2) produces the result
[ 2 3 1 ]
[ 5 6 4 ]
[ 8 9 7 ].
Each element in rows 1, 2, and 3 is shifted to the left by 1 position. The elements shifted off the beginning
are inserted at the end.
CSHIFT (M, SHIFT = -1, DIM = 1) produces the result
[ 7 8 9 ]
[ 1 2 3 ]
[ 4 5 6 ].
Each element in columns 1, 2, and 3 is shifted down by 1 position. The elements shifted off the end are
inserted at the beginning.
CSHIFT (M, SHIFT = (/1, -1, 0/), DIM = 2) produces the result
[ 2 3 1 ]
[ 6 4 5 ]
[ 7 8 9 ].
Each element in row 1 is shifted to the left by 1 position; each element in row 2 is shifted to the right by 1
position; no element in row 3 is shifted at all.
The following shows another example:
See Also
EOSHIFT
ISHFT
ISHFTC
1391
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
CSMG
Portability Function: Performs an effective BIT-
WISE store under mask.
Module
USE IFPORT
Syntax
result = CSMG (x,y,z)
x, y, z (Input) INTEGER(4).
Results
The result type is INTEGER(4). The result is equal to the following expression:
(x & z) | (y & ~z )
where "&" is a bitwise AND operation, | - bitwise OR, ~ - bitwise NOT.
The function returns the value based on the following rule: when a bit in z is 1, the output bit is taken from
x. When a bit in z is zero, the corresponding output bit is taken from y.
CTIME
Portability Function: Converts a system time into a
24-character ASCII string.
Module
USE IFPORT
Syntax
result = CTIME (stime)
Results
The result is a value in the form Mon Jan 31 04:37:23 1994. Hours are expressed using a 24-hour clock.
The value of stime can be determined by calling the TIME function. CTIME(TIME( )) returns the current time
and date.
Example
USE IFPORT
character (24) systime
systime = CTIME (TIME( ))
print *, 'Current date and time is ',systime
See Also
DATE_AND_TIME
1392
Language Reference
CYCLE
Statement: Interrupts the current execution cycle of
the innermost (or named) DO construct.
Syntax
CYCLE [name]
Description
When a CYCLE statement is executed, the following occurs:
1. The current execution cycle of the named (or innermost) DO construct is terminated.
If a DO construct name is specified, the CYCLE statement must be within the range of that construct.
2. The iteration count (if any) is decremented by 1.
3. The DO variable (if any) is incremented by the value of the increment parameter (if any).
4. A new iteration cycle of the DO construct begins.
Any executable statements following the CYCLE statement (including a labeled terminal statement) are not
executed.
A CYCLE statement can be labeled, but it cannot be used to terminate a DO construct.
Execution of a CYCLE statement that belongs to a DO CONCURRENT construct completes execution of that
iteration of the construct.
Example
The following example shows a CYCLE statement:
DO I =1, 10
A(I) = C + D(I)
IF (D(I) < 0) CYCLE ! If true, the next statement is omitted
A(I) = 0 ! from the loop and the loop is tested again.
END DO
The following shows another example:
sample_loop: do i = 1, 5
print *,i
if( i .gt. 3 ) cycle sample_loop
print *,i
end do sample_loop
print *,'done!'
!output:
! 1
! 1
! 2
! 2
! 3
! 3
! 4
! 5
! done!
See Also
DO
DO WHILE
1393
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Execution Control
DATA
Statement: Assigns initial values to variables before
program execution.
Syntax
DATA var-list /clist/ [[,] var-list /clist/]...
kind-selector Is ( [KIND=] n ).
Description
A variable can be initialized only once in an executable program. A variable that appears in a DATA statement
and is typed implicitly can appear in a subsequent type declaration which may change the implicit typing.
The number of constants in c-list must equal the number of variables in var-list. The constants are assigned
to the variables in the order in which they appear (from left to right).
The following objects cannot be initialized in a DATA statement:
• A dummy argument
1394
Language Reference
• A function
• A function result
• An automatic object
• An allocatable array
• A variable that is accessible by use or host association
• A variable in a named common block (unless the DATA statement is in a block data program unit)
• A variable in blank common
Except for variables in named COMMON blocks, a named variable has the SAVE attribute if any part of it is
initialized in a DATA statement. You can confirm this property by specifying the variable in a SAVE statement
or a type declaration statement containing the SAVE attribute.
When an unsubscripted array name appears in a DATA statement, values are assigned to every element of
that array in the order of subscript progression. If the associated constant list does not contain enough
values to fill the array, a warning is issued and the remaining array elements become undefined.
Array element values can be initialized in three ways: by name, by element, or by an implied-DO list
(interpreted in the same way as a DO construct).
The following conversion rules and restrictions apply to variable and constant list items:
• If the constant and the variable are both of numeric type, the following conversion occurs:
• The constant value is converted to the data type of the variable being initialized, if necessary.
• When a binary, octal, or hexadecimal constant is assigned to a variable or array element, the number
of digits that can be assigned depends on the data type of the data item. If the constant contains
fewer digits than the capacity of the variable or array element, the constant is extended on the left
with zeros. If the constant contains more digits than can be stored, the constant is truncated on the
left. An error results if any nonzero digits are truncated.
• If the constant and the variable are both of character type, the following conversion occurs:
• If the length of the constant is less than the length of the variable, the rightmost character positions of
the variable are initialized with blank characters.
• If the length of the constant is greater than the length of the variable, the character constant is
truncated on the right.
• If the constant is of numeric type and the variable is of character type, the following restrictions apply:
• The character variable must have a length of one character.
• The constant must be an integer, binary, octal, or hexadecimal constant, and must have a value in the
range 0 through 255.
When the constant and variable conform to these restrictions, the variable is initialized with the character
that has the ASCII code specified by the constant. (This lets you initialize a character object to any 8-bit
ASCII code.)
• If the constant is a Hollerith or character constant, and the variable is a numeric variable or numeric array
element, the number of characters that can be assigned depends on the data type of the data item.
If the Hollerith or character constant contains fewer characters than the capacity of the variable or array
element, the constant is extended on the right with blank characters. If the constant contains more
characters than can be stored, the constant is truncated on the right.
Example
The following example shows the three ways that DATA statements can initialize array element values:
DIMENSION A(10,10)
DATA A/100*1.0/ ! initialization by name
DATA A(1,1), A(10,1), A(3,3) /2*2.5, 2.0/ ! initialization by element
DATA ((A(I,J), I=1,5,2), J=1,5) /15*1.0/ ! initialization by implied-DO list
1395
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
TYPE EMPLOYEE
INTEGER ID
CHARACTER(LEN=40) NAME
END TYPE EMPLOYEE
TYPE(EMPLOYEE) MAN_NAME, CON_NAME
DATA MAN_NAME / EMPLOYEE(417, 'Henry Adams') /
DATA CON_NAME%ID, CON_NAME%NAME /891, "David James"/
In the following example, the first DATA statement assigns zero to all 10 elements of array A, and four
asterisks followed by two blanks to the character variable STARS:
1396
Language Reference
The first DATA statement in the previous example could also be written as:
INTEGER, POINTER :: P
DATA P/NULL( )/
END
The implied-DO limits can be any constant expressions in a DATA statement. For example:
See Also
CHARACTER
INTEGER
REAL
COMPLEX
COMMON
Data Types, Constants, and Variables
I/O Lists
Derived Data Types
Allocating Common Blocks
Syntax
CALL DATE (buf)
The date is returned as a 9-byte ASCII character string taking the form dd-mmm-yy, where:
If buf is of numeric type and smaller than 9 bytes, data corruption can occur.
If buf is of character type, its associated length is passed to the subroutine. If buf is smaller than 9 bytes,
the subroutine truncates the date to fit in the specified length. If an array of type character is passed, the
subroutine stores the date in the first array element, using the element length, not the length of the entire
array.
1397
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Caution
The two-digit year return value may cause problems with the year 2000. Use DATE_AND_TIME
instead.
Example
CHARACTER*1 DAY(9)
…
CALL DATE (DAY)
The length of the first array element in CHARACTER array DAY is passed to the DATE subroutine. The
subroutine then truncates the date to fit into the 1-character element, producing an incorrect result.
See Also
DATE_AND_TIME
Module
USE IFPORT
Syntax
Function Syntax:
result = DATE( )
Subroutine Syntax:
CALL DATE (dstring)
DATE in its function form returns a CHARACTER string of length 8 in the form mm/dd/yy, where mm, dd, and
yy are two-digit representations of the month, day, and year, respectively.
DATE in its subroutine form returns dstring in the form dd-mmm-yy, where dd is a two-digit representation
of the current day of the month, mmm is a three-character abbreviation for the current month (for example,
Jan) and yy are the last two digits of the current year.
Caution
The two-digit year return value may cause problems with the year 2000. Use DATE_AND_TIME
instead.
Example
USE IFPORT
!If today's date is March 02, 2000, the following
!code prints "02-Mar-00"
1398
Language Reference
CHARACTER(9) TODAY
CALL DATE(TODAY)
PRINT *, TODAY
!The next line prints "03/02/00"
PRINT *, DATE( )
See Also
DATE_AND_TIME
DATE4
Portability Subroutine: Returns the current system
date.
Module
USE IFPORT
Syntax
CALL DATE4 (datestr)
This subroutine returns datestr in the form dd-mmm-yyyy, where dd is a two-digit representation of the
current day of the month, mmm is a three-character abbreviation for the current month (for example, Jan)
and yyyy are the four digits of the current year.
DATE_AND_TIME
Intrinsic Subroutine (Generic): Returns character
and binary data on the real-time clock and date.
Intrinsic subroutines cannot be passed as actual
arguments.
Syntax
CALL DATE_AND_TIME ([date,time,zone,values])
date (Output; optional) Must be scalar and of type default character; its
length must be at least 8 to contain the complete value. Its leftmost 8
characters are set to a value of the form CCYYMMDD, where:
CC Is the century
time (Output; optional) Must be scalar and of type default character; its
length must be at least 10 to contain the complete value. Its leftmost
10 characters are set to a value of the form hhmmss.sss, where:
1399
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
zone (Output; optional) Must be scalar and of type default character; its
length must be at least 5 to contain the complete value. Its leftmost 5
characters are set to a value of the form +hhmm or -hhmm, where hh
and mm are the time difference with respect to Coordinated Universal
Time (UTC) in hours and parts of an hour expressed in minutes,
respectively.
UTC is also known as Greenwich Mean Time.
Example
Consider the following example executed on 2000 March 28 at 11:04:14.5:
CHARACTER(10) t
CHARACTER(5) z
CALL DATE_AND_TIME(TIME = t, ZONE = z)
1400
Language Reference
See Also
GETDAT
GETTIM
FDATE
ITIME
RTC
CLOCK
Module
USE IFPORT
Syntax
result = DBESJ0 (value)
result = DBESJ1 (value)
result = DBESJN (n, value)
result = DBESY0 (posvalue)
result = DBESY1 (posvalue)
result = DBESYN (n, posvalue)
Results
DBESJ0, DBESJ1, and DBESJN return Bessel functions of the first kind, orders 0, 1, and n, respectively, with
the independent variable value.
DBESY0, DBESY1, and DBESYN return Bessel functions of the second kind, orders 0, 1, and n, respectively,
with the independent variable posvalue.
Negative arguments cause DBESY0, DBESY1, and DBESYN to return a huge negative value.
1401
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Bessel functions are explained more fully in most mathematics reference books, such as the Handbook of
Mathematical Functions(Abramowitz and Stegun. Washington: U.S. Government Printing Office, 1964). These
functions are commonly used in the mathematics of electromagnetic wave theory.
See the descriptions of the BESSEL_* functions, if you need to use quad-precision (REAL(16)).
Example
USE IFPORT
real(8) besnum, besout
10 read *, besnum
besout = dbesj0(besnum)
print *, 'result is ',besout
goto 10
end
See Also
BESJ0, BESJ1, BESJN, BESY0, BESY1, BESYN
DBLE
Elemental Intrinsic Function (Generic): Converts
a number to double-precision real type.
Syntax
result = DBLE (a)
Results
The result type is double precision real (by default, REAL(8) or REAL*8). Functions that cause conversion of
one data type to another type have the same effect as the implied conversion in assignment statements.
If a is of type double precision, the result is the value of the a with no conversion (DBLE( a) = a).
If a is of type integer or real, the result has as much precision of the significant part of a as a double
precision value can contain.
If a is of type complex, the result has as much precision of the significant part of the real part of a as a
double precision value can contain.
INTEGER(1) REAL(8)
INTEGER(2) REAL(8)
INTEGER(4) REAL(8)
INTEGER(8) REAL(8)
REAL(8) REAL(8)
COMPLEX(4) REAL(8)
1402
Language Reference
COMPLEX(8) REAL(8)
COMPLEX(16) REAL(8)
1These specific functions cannot be passed as actual arguments.
2 The setting of compiler options specifying double size can affect DBLE.
If the argument is a binary, octal, or hexadecimal literal constant, the result is affected by the
assume old-boz option. The default option setting, noold-boz, treats the argument as a bit string that
represents a value of the data type of the intrinsic, that is, the bits are not converted. If setting old-boz is
specified, the argument is treated as a signed integer and the bits are converted.
NOTE
The result values of DBLE are defined by references to the intrinsic function REAL with the
same arguments. Therefore, the padding and truncation of binary, octal, and hexadecimal
literal constant arguments to DBLE is the same as for the intrinsic function REAL.
Example
DBLE (4) has the value 4.0.
DBLE ((3.4, 2.0)) has the value 3.4.
See Also
Binary, Octal, Hexadecimal, and Hollerith Constants
Model for Bit Data
FLOAT
SNGL
REAL
CMPLX
DCLOCK
Portability Function: Returns the elapsed time in
seconds since the start of the current process.
Module
USE IFPORT
Syntax
result = DCLOCK( )
Results
The result type is REAL(8). This routine provides accurate timing to the nearest millisecond (Windows*) or to
the nearest microsecond (Linux* and macOS*), taking into account the frequency of the processor where the
current process is running.
Note that the first call to DCLOCK performs calibration.
1403
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
USE IFPORT
DOUBLE PRECISION START_TIME, STOP_TIME
START_TIME = DCLOCK()
CALL FOO()
STOP_TIME = DCLOCK()
PRINT *, 'foo took:', STOP_TIME - START_TIME, 'seconds.'
See Also
DATE_AND_TIME
CPU_TIME
DCMPLX
Elemental Intrinsic Function (Specific): Converts
the argument to double complex type. This function
cannot be passed as an actual argument.
Syntax
result = DCMPLX (x[,y])
Results
The result type is double complex (COMPLEX(8) or COMPLEX*16).
If only one noncomplex argument appears, it is converted into the real part of the result value and zero is
assigned to the imaginary part. If y is not specified and x is complex, the result value is CMPLX(REAL( x),
AIMAG( x)).
If two noncomplex arguments appear, the complex value is produced by converting the first argument into
the real part of the value, and converting the second argument into the imaginary part.
DCMPLX( x, y) has the complex value whose real part is REAL( x, KIND=8) and whose imaginary part is
REAL( y, KIND=8).
Example
DCMPLX (-3) has the value (-3.0, 0.0).
DCMPLX (4.1, 2.3) has the value (4.1, 2.3).
See Also
CMPLX
FLOAT
INT
IFIX
REAL
SNGL
1404
Language Reference
DEALLOCATE
Statement: Frees the storage allocated for allocatable
variables and nonprocedure pointer targets (and
causes the pointers to become disassociated).
Syntax
DEALLOCATE (object[,object]...[, dealloc-opt])
Description
If a STAT= variable or ERRMSG= variable is specified, it must not be deallocated in the DEALLOCATE
statement in which it appears. If the deallocation is successful, the STAT= variable is set to zero and the
ERRMSG= variable is unchanged. If the deallocation is not successful, an error condition occurs, the STAT=
variable is set to a positive integer value (representing the run-time error), and the ERRMSG= variable is
defined with a descriptive message about the error condition. If no STAT= variable is specified and an error
condition occurs, error termination is initiated.
If an ALLOCATE or DEALLOCATE statement with a coarray allocatable object is executed when one or more
images has initiated termination of execution, the STAT= variable becomes defined with the processor-
dependent positive integer value of the constant STAT_STOPPED_IMAGE from the intrinsic module
ISO_FORTRAN_ENV. Otherwise, if an allocatable object is a coarray and one or more images of the current
team has failed, the STAT= variable becomes defined with the processor-dependent positive integer value of
the constant STAT_FAILED_IMAGE from the intrinsic module ISO_FORTRAN_ENV.
If any other error condition occurs during execution of the ALLOCATE or DEALLOCATE statement, the STAT=
variable becomes defined with a processor-dependent positive integer value different from
STAT_STOPPED_IMAGE or STAT_FAILED_IMAGE.
If an ALLOCATE or DEALLOCATE statement with a coarray allocatable object is executed when one or more
images of the current team has failed, each allocatable object is successfully allocated or deallocated on the
active images of the current team. If any other error occurs, the allocation status of each allocatable object is
processor dependent:
• Successfully allocated allocatable objects have the allocation status of allocated, or associated if the
allocate object is has the POINTER attribute.
• Successfully deallocated allocatable objects have the allocation status of deallocated, or disassociated if
the allocatable object has the POINTER attribute.
• An allocatable object that was not successfully allocated or deallocated has its previous allocation status,
or its previous association status if it has the POINTER attribute.
It is recommended that all explicitly allocated storage be explicitly deallocated when it is no longer needed.
To disassociate a pointer that was not associated with the ALLOCATE statement, use the NULLIFY statement.
For a list of run-time errors, see Error Handling in the Compiler Reference.
1405
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
The following example shows deallocation of an allocatable array:
INTEGER ALLOC_ERR
REAL, ALLOCATABLE :: A(:), B(:,:)
...
ALLOCATE (A(10), B(-2:8,1:5))
...
DEALLOCATE(A, B, STAT = ALLOC_ERR)
The following shows another example:
See Also
ALLOCATE
NULLIFY
Arrays
Dynamic Allocation
ISO_FORTRAN_ENV Module
Syntax
!DIR$ DECLARE
!DIR$ NODECLARE
The DECLARE directive is primarily a debugging tool that locates variables that have not been properly
initialized, or that have been defined but never used.
See Also
IMPLICIT
General Compiler Directives
Syntax Rules for Compiler Directives
Equivalent Compiler Options
DECLARE REDUCTION
OpenMP* Fortran Compiler Directive: Declares
user-defined reductions which are identified by a
reduction-identifier that can be used in a reduction
clause of other directives.
Syntax
!$OMP DECLARE REDUCTION (reduction-identifier : type-list : combiner) [initializer-
clause]
1406
Language Reference
• omp_out
This identifier refers to the storage that holds the resulting
combined value following execution of the combiner.
• omp_in
The above identifiers refer to variables that are the type of the
reduction variables specified in type-list for the reduction-identifier.
They denote values to be combined by executing the combiner.
No other identifiers are permitted in the combiner. Any number of
literal or named constants can appear in the combiner.
If combiner is a subroutine name followed by an argument list, it is
evaluated by calling the subroutine with the specified argument list. If
combiner is an assignment statement, combiner is evaluated by
executing the assignment statement.
The number of times the combiner is executed, and the order of these
executions, is unspecified.
• omp_priv = expression
This identifier refers to the storage to be initialized.
• subroutine-name (argument-list)
1407
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The DECLARE REDUCTION directive is a specification directive. It can appear in a specification part of a
subroutine, function, main program, module, or block construct.
User-defined (custom) reductions can be defined using the DECLARE REDUCTION directive. The reduction is
identified by the reduction-identifier and the associated type from type-list. The reduction-identifier can be
used in a REDUCTION clause in another OpenMP* directive anywhere it is accessible by use or host
association.
A DECLARE REDUCTION directive cannot redefine a predefined reduction-identifier (see the table of implicitly
defined reduction identifiers in the REDUCTION clause section).
If a type in type-list has deferred or assumed-length type parameters, the reduction-identifier can be used in
a REDUCTION clause with a variable of the same type and kind type parameter as type, regardless of the
length parameter with which the variable is declared. The length parameter of a character type must be a
constant, colon, or asterisk. An accessible reduction-identifier defined with a deferred or assumed-length
character type cannot appear in another DECLARE REDUCTION directive with a type-list item of type
character with the same kind type parameter.
The accessibility of a reduction-identifier is determined by the same rules as for other Fortran entities; it can
be declared PUBLIC or PRIVATE, be made accessible or blocked by a USE or IMPORT statement, and it can be
renamed. If the reduction-identifier is the same as a generic name that is also the name of a derived type,
the accessibility of the reduction-identifier is the same as that of the generic name.
If a subroutine or function used in initializer-expression or combiner is not an intrinsic procedure, it must
have an accessible interface. Defined operators and defined assignments used in initializer or combiner
must have accessible interfaces. All subroutines, functions, defined operators and defined assignments used
in initializer or combiner must have accessible interfaces in the subprogram in which the corresponding
REDUCTION clause appears. Procedures referenced in combiner and initializer cannot be alternate return
subprograms.
The initial value of a user-defined reduction is not known before it is specified. The initializer-clause can be
used to specify an initial value for the reduction variable. The initializer-clause will be executed to establish
initial values for the private copies of reduction list items indicated in a REDUCTION clause that specifies the
reduction-identifier.
If initializer is not specified, private reduction variables are initialized as follows:
• If the reduction variable is type COMPLEX, REAL, or INTEGER, the default initializer is the value zero.
• If the reduction variable specified in list of the REDUCTION clause is LOGICAL, the default initializer is the
value .FALSE..
• If the reduction variable is of a default initialized derived type, the default initializer value is used.
• Otherwise, the initial value is unspecified.
If initializer is used in a target region, then a DECLARE TARGET construct (Linux* only) must be
specified for any procedures that are executed during the execution of combiner or initializer.
1408
Language Reference
Example
Consider that a DECLARE REDUCTION directive is used to declare a sum reduction for an integer component
of a type my_type that is identified by the reduction-identifier '+'. It is then used in a REDUCTION clause of a
parallel region to produce the sum of the thread numbers (numbered 1 thru 4) of the region:
module types
type my_type
integer :: component
end type
interface operator(+)
module procedure :: my_add
end interface
!$omp declare reduction (+ : my_type : omp_out = omp_out + omp_in) initializer (omp_priv =
my_type (0))
contains
function my_add (a1, a2)
type(my_type),intent(in) :: a1, a2
type(my_type) :: my_add
my_add%component = a1%component + a2%component
return
end function my_add
end module types
program main
use types
use omp_lib
type(my_type) :: my_var
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
DECLARE TARGET
REDUCTION clause
1409
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
DECLARE SIMD
OpenMP* Fortran Compiler Directive: Creates a
version of a function that can process multiple
arguments using Single Instruction Multiple Data
(SIMD) instructions from a single invocation from a
SIMD loop.
Syntax
!$OMP DECLARE SIMD(routine-name) [clause[[,] clause]... ]
The DECLARE SIMD construct enables the creation of SIMD versions of the specified subroutine or function.
You can use multiple DECLARE SIMD constructs in a single procedure to produce more than one SIMD
version of a procedure. These versions can be used to process multiple arguments from a single invocation
from a SIMD loop concurrently.
1410
Language Reference
When routine-name is executed, it cannot have any side-effects that would change its execution for
concurrent iterations of a SIMD chunk. When the routine is called from a SIMD loop, it cannot cause the
execution of any OpenMP* Fortran construct.
If a DECLARE SIMD directive is specified for a routine name with explicit interface and for the definition of
the routine, they must match. Otherwise, the result is unspecified.
You cannot use procedure pointers to access routines created by the DECLARE SIMD directive.
You can only specify a particular variable in at most one instance of a UNIFORM or LINEAR clause.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
DECLARE TARGET
OpenMP* Fortran Compiler Directive: Specifies
that named variables, common blocks, functions, and
subroutines are mapped to a device. This feature is
only available for ifx.
Syntax
!$OMP DECLARE TARGET [(extended-list)]
• A THREADPRIVATE variable
• A variable that is part of another variable (for example, an element
in an array or a field of a structure)
• A variable that is an element of a common block
• A variable that appears in an EQUIVALENCE statement
If the extended-list item is a common block:
1411
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If a DECLARE TARGET directive is specified in an interface block for a procedure, it must match a DECLARE
TARGET directive in the definition of the procedure.
If a procedure is declared in a procedure declaration statement, any DECLARE TARGET directive containing
the procedure name must appear in the same specification part.
The following additional rules apply to variables and common blocks:
• The DECLARE TARGET directive must appear in the declaration section of a scoping unit in which the
common block or variable is declared.
• If a variable or common block is declared with the BIND attribute, the corresponding C entities must also
be specified in a DECLARE TARGET directive in the C program.
Variables with static storage and procedures used in an OMP TARGET region are implicitly treated as OMP
DECLARE TARGET:
MODULE VARS
INTEGER X
END MODULE
!$OMP TARGET
X = FOO() ! X and FOO are implicitly DECLARE TARGET
!$OMP END TARGET
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
DECLARE VARIANT
OpenMP* Fortran Compiler Directive: Identifies a
variant of a base procedure and specifies the context
in which this variant is used. This feature is only
available for ifx.
Syntax
!$OMP DECLARE VARIANT ([base-proc-name:]variant-proc-name) clause[[[,] clause]... ]
variant-proc-name Is the name of the variant procedure that is to be called instead of the
base procedure if the base procedure is called from an OpenMP*
context that matches the context specified by the MATCH clause.
1412
Language Reference
The DECLARE VARIANT directive is a declarative directive and must appear in the specification part of a
subroutine or function, or in an interface in an interface block. It identifies the name of a variant procedure
that is to be called instead of the base procedure when the call appears in a context that matches the
context-selector-specification in the MATCH clause.
If base-proc-name is not specified, the name of the procedure containing the directive is the base-proc-
name. base-proc-name must not be a dummy procedure name, a statement function name, a generic name,
a procedure pointer, or an alternate entry name.
1413
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If a DECLARE VARIANT directive appears in an interface body for a procedure, it must match a DECLARE
VARIANT directive in the definition of that procedure. If a DECLARE VARIANT directive appears for a
procedure with an explicit interface, and the definition of that procedure also contains a DECLARE VARIANT
directive for that procedure, the two directives must match.
Multiple DECLARE VARIANT directives can associate different variant-proc-names with the same base-proc-
name. If more than one DECLARE VARIANT associates the same variant-proc-name with the same base-
proc-name, then the context-selector-specification must be the same for all such directives.
A variant procedure must have the same interface characteristics as the base procedure, except that a
variant procedure must have one additional final argument declared in its dummy argument list, which must
be of type C_PTR from the intrinsic module ISO_C_BINDING. When a call to the base procedure is replaced
by a call to the variant, the compiler adds the additional argument into the actual argument list.
When the ADJUST_ARGS clause is specified, an argument with the is-device-ptr property in its
interoperability requirement set will be passed as is. Otherwise, the argument will be converted in the same
way that a USE_DEVICE_PTR clause on a TARGET DATA construct converts a pointer list item into a device
pointer.
When the APPEND_ARGS clause appears, the following occurs:
• For each interop-type specified, an additional argument of type omp_interop_kind from the
interoperability requirement set of the encountering task is added to the argument list.
The ordering of the appended arguments is the same as the order of the interop-types that are specified
in list of interop-types in parentheses following the INTEROP keyword in the APPEND_ARGS clause.
• Each argument is constructed as if an INTEROP construct specifying an interop-type INIT clause was
present.
• If the interoperability requirement set contains properties that could be used as INTEROP construct
clauses, it is as if the INTEROP construct also contained those clauses, and the properties will be removed
from the interoperability requirement set.
• Each appended argument is destroyed after the selected variant completes executions as if the INTEROP
construct contained a DESTROY clause.
Calling a procedure variant directly by variant-proc-name within an OpenMP* context that is different than
the context specified in the MATCH clause is non-conforming.
Example
The DECLARE VARIANT directive in the module procedure vecadd_base identifies the procedure
vecadd_gpu_offload as a variant that is to replace references to vecadd_base when called from a TARGET
DISPATCH VARIANT construct and a GEN device is available for offloading. Notice that vecadd_base does not
have any dummy arguments, while vecadd_gpu_offload has a single C_PTR dummy argument.
MODULE vecadd
INTEGER,PARAMETER :: n = 1024
CONTAINS
FUNCTION vecadd_gpu_offload (ptr) RESULT (res)
USE,INTRINSIC :: ISO_C_BINDING, ONLY : c_ptr
!$DEC ATTRIBUTES NOINLINE :: vecadd_gpu_offload
TYPE (c_ptr) :: ptr
REAL :: res
REAL,DIMENSION(n) :: a, b
INTEGER :: k
1414
Language Reference
END DO
!$omp END TARGET PARALLEL DO
PRINT *, "GPU version of vecadd called"
END FUNCTION vecadd_gpu_offload
PROGRAM main
USE vecadd
REAL :: result = 0.0
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
INTEROP
TARGET DATA
TARGET VARIANT DISPATCH
DECODE
Statement: Translates data from character to internal
form. It is comparable to using internal files in
formatted sequential READ statements.
Syntax
DECODE (c,f,b[, IOSTAT=i-var] [, ERR=label]) [io-list]
1415
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
io-list Is an I/O list. An I/O list is either an implied-DO list or a simple list of
variables (except for assumed-size arrays). The list receives the data
after translation to internal form.
The interaction between the format specifier and the I/O list is the
same as for a formatted I/O statement.
The number of characters that the DECODE statement can translate depends on the data type of b. For
example, an INTEGER(2) array can contain two characters per element, so that the maximum number of
characters is twice the number of elements in that array.
The maximum number of characters a character variable or character array element can contain is the length
of the character variable or character array element.
The maximum number of characters a character array can contain is the length of each element multiplied by
the number of elements.
Example
In the following example, the DECODE statement translates the 12 characters in A to integer form (as
specified by the FORMAT statement):
DIMENSION K(3)
CHARACTER*12 A,B
DATA A/'123456789012'/
DECODE(12,100,A) K
100 FORMAT(3I4)
The 12 characters are stored in array K:
K(1) = 1234
K(2) = 5678
K(3) = 9012
See Also
READ
WRITE
ENCODE
DEFAULT Clause
Parallel Directive Clause: Lets you specify a scope
for all variables in the lexical extent of a parallel
region.
1416
Language Reference
Syntax
DEFAULT (PRIVATE | FIRSTPRIVATE | SHARED | NONE )
The specifications have the following effects:
• PRIVATE - Makes all named objects in the lexical extent of the parallel region, including common block
variables but excluding THREADPRIVATE variables, private to a thread as if you explicitly listed each
variable in a PRIVATE clause.
• FIRSTPRIVATE - Makes all variables in the construct that have implicitly determined data-sharing
attributes firstprivate as if you explicitly listed each variable in a FIRSTPRIVATE clause.
• SHARED - Makes all named objects in the lexical extent of the parallel region shared among the threads in
a team, as if you explicitly listed each variable in a SHARED clause. If you do not specify a DEFAULT
clause, this is the default.
• NONE - Specifies that there is no implicit default as to whether variables are PRIVATE or SHARED. In this
case, you must specify the PRIVATE, SHARED, FIRSTPRIVATE, LASTPRIVATE, or REDUCTION property of
each variable you use in the lexical extent of the parallel region.
You can specify only one DEFAULT clause in a PARALLEL directive. You can exclude variables from a defined
default by using the PRIVATE, SHARED, FIRSTPRIVATE, LASTPRIVATE, or REDUCTION clauses.
Variables in THREADPRIVATE common blocks are not affected by this clause.
Syntax
!DIR$ DEFINE name[ = val]
!DIR$ UNDEFINE name
DEFINE creates and UNDEFINE removes symbols for use with the IF (or IF DEFINED) compiler directive.
Symbols defined with DEFINE directive are local to the directive. They cannot be declared in the Fortran
program.
Because Fortran programs cannot access the named variables, the names can duplicate Fortran keywords,
intrinsic functions, or user-defined names without conflict.
To test whether a symbol has been defined, use the IF DEFINED ( name) directive. You can assign an integer
value to a defined symbol. To test the assigned value of name, use the IF directive. IF test expressions can
contain most logical and arithmetic operators.
Attempting to undefine a symbol that has not been defined produces a compiler warning.
The DEFINE and UNDEFINE directives can appear anywhere in a program, enabling and disabling symbol
definitions.
Example
!DIR$ DEFINE testflag
!DIR$ IF DEFINED (testflag)
write (*,*) 'Compiling first line'
!DIR$ ELSE
1417
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
IF Directive Construct
General Compiler Directives
Syntax Rules for Compiler Directives
D compiler option
Equivalent Compiler Options
DEFINE FILE
Statement: Establishes the size and structure of files
with relative organization and associates them with a
logical unit number.
Syntax
DEFINE FILE u(m,n,U,asv) [,u(m,n,U,asv)] ...
asv Is a scalar integer variable, called the associated variable of the file.
At the end of each direct access I/O operation, the record number of
the next higher numbered record in the file is assigned to asv; asv
must not be a dummy argument.
The DEFINE FILE statement is comparable to the OPEN statement. In situations where you can use the OPEN
statement, OPEN is the preferable mechanism for creating and opening files.
The DEFINE FILE statement specifies that a file containing m fixed-length records, each composed of n16-bit
words, exists (or will exist) on the specified logical unit. The records in the file are numbered sequentially
from 1 through m.
A DEFINE FILE statement does not itself open a file. However, the statement must be executed before the
first direct access I/O statement referring to the specified file. The file is opened when the I/O statement is
executed.
If this I/O statement is a WRITE statement, a direct access sequential file is opened, or created if necessary.
If the I/O statement is a READ or FIND statement, an existing file is opened, unless the specified file does
not exist. If a file does not exist, an error occurs.
The DEFINE FILE statement establishes the variable asv as the associated variable of a file. At the end of
each direct access I/O operation, the Fortran I/O system places in asv the record number of the record
immediately following the one just read or written.
1418
Language Reference
The associated variable always points to the next sequential record in the file (unless the associated variable
is redefined by an assignment, input, or FIND statement). So, direct access I/O statements can perform
sequential processing on the file by using the associated variable of the file as the record number specifier.
Example
DEFINE FILE 3(1000,48,U,NREC)
In this example, the DEFINE FILE statement specifies that the logical unit 3 is to be connected to a file of
1000 fixed-length records; each record is forty-eight 16-bit words long. The records are numbered
sequentially from 1 through 1000 and are unformatted.
After each direct access I/O operation on this file, the integer variable NREC will contain the record number
of the record immediately following the record just processed.
See Also
OPEN
DELDIRQQ
Portability Function: Deletes a specified directory.
Module
USE IFPORT
Syntax
result = DELDIRQQ (dir)
Results
The result type is LOGICAL(4). The result is .TRUE. if successful; otherwise, .FALSE..
The directory to be deleted must be empty. It cannot be the current directory, the root directory, or a
directory currently in use by another process.
Example
See the example for GETDRIVEDIRQQ.
See Also
GETDRIVEDIRQQ
GETDRIVEDIRQQ
MAKEDIRQQ
CHANGEDIRQQ
CHANGEDRIVEQQ
UNLINK
DELETE
Statement: Deletes a record from a relative file.
Syntax
DELETE ([UNIT=] io-unit[, REC=r][, ERR=label] [, IOSTAT=i-var])
1419
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
label Is the label of the branch target statement that receives control if an
error occurs.
In a relative file, the DELETE statement deletes the direct access record specified by r. If REC= r is omitted,
the current record is deleted. When the direct access record is deleted, any associated variable is set to the
next record number.
The DELETE statement logically removes the appropriate record from the specified file by locating the record
and marking it as a deleted record. It then frees the position formerly occupied by the deleted record so that
a new record can be written at that position.
NOTE
You must use compiler option vms for READs to detect that a record has been deleted.
Example
The following statement deletes the fifth record in the file connected to I/O unit 10:
See Also
Data Transfer I/O Statements
Branch Specifiers
vms compiler option
DELETEMENUQQ (W*S)
QuickWin Function: Deletes a menu item from a
QuickWin menu.
Module
USE IFQWIN
Syntax
result = DELETEMENUQQ (menuID, itemID)
menuID (Input) INTEGER(4). Identifies the menu that contains the menu item
to be deleted, starting with 1 as the leftmost menu.
1420
Language Reference
Results
The result type is LOGICAL(4). The result is .TRUE. if successful; otherwise, .FALSE..
Example
USE IFQWIN
LOGICAL(4) result
CHARACTER(25) str
str = 'Add to EDIT Menu'C ! Append to 2nd menu
result = APPENDMENUQQ(2, $MENUENABLED, str, WINSTATUS)
! Delete third item (EXIT) from menu 1 (FILE)
result = DELETEMENUQQ(1, 3)
! Delete entire fifth menu (WINDOW)
result = DELETEMENUQQ(5,0)
END
See Also
APPENDMENUQQ
INSERTMENUQQ
MODIFYMENUFLAGSQQ
MODIFYMENUROUTINEQQ
MODIFYMENUSTRINGQQ
DELFILESQQ
Portability Function: Deletes all files matching the
name specification, which can contain wildcards (*
and ?).
Module
USE IFPORT
Syntax
result = DELFILESQQ (files)
Results
The result type is INTEGER(2). The result is the number of files deleted.
You can use wildcards to delete more than one file at a time. DELFILESQQ does not delete directories or
system, hidden, or read-only files. Use this function with caution because it can delete many files at once. If
a file is in use by another process (for example, if it is open in another process), it cannot be deleted.
Example
USE IFPORT
USE IFCORE
INTEGER(4) len, count
CHARACTER(80) file
CHARACTER(1) ch
WRITE(*,*) "Enter names of files to delete: "
len = GETSTRQQ(file)
IF (file(1:len) .EQ. '*.*') THEN
WRITE(*,*) "Are you sure (Y/N)?"
1421
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
ch = GETCHARQQ()
IF ((ch .NE. 'Y') .AND. (ch .NE. 'y')) STOP
END IF
count = DELFILESQQ(file)
WRITE(*,*) "Deleted ", count, " files."
END
See Also
FINDFILEQQ
DEPEND Clause
Parallel Directive Clause: Enforces additional
constraints on the scheduling of a task by enabling
dependences between sibling tasks in the task region.
Syntax
It takes one of the following forms:
In Synchronization Directive !$OMP ORDERED
DEPEND (SOURCE) -or-
DEPEND (SINK:vec)
In all other directives:
DEPEND (dependence-type : list)
dependence-type Can be any one of the following clauses: IN, OUT, or INOUT,
MUTEXINOUTSET, or INOUTSET.
If one or more of the list items specified in an IN dependence-type is
the same as a list item appearing in a DEPEND clause with an OUT,
INOUT, MUTEXINOUTSET or INOUTSET dependence-type on a
construct that previously generated a sibling task, the generated task
is a dependent task of the sibling task.
If one or more of the list items specified in an OUT or INOUT
dependence-type is the same as a list item appearing in a DEPEND
clause with an IN, OUT, INOUT, MUTEXINOUTSET, or INOUTSET
dependence-type on a construct that previously generated a sibling
task, the generated task is a dependent task of the sibling task.
If one or more of the list items specified in an MUTEXINOUTSET
dependence-type is the same as a list item appearing in a DEPEND
clause with an IN, OUT, INOUT, or INOUTSET dependence-type on a
construct that previously generated a sibling task, the generated task
is a dependent task of the sibling task.
If a list item specified in a MUTEXINOUTSET dependence-type is the
same as a list item appearing in a DEPEND clause with a
MUTEXINOUTSET dependence-type on a different task generating
construct and both constructs generate sibling tasks, the sibling tasks
are mutually exclusive.
1422
Language Reference
list Is one or more variables or non-zero length array sections. Any list
items used in a DEPEND clause of the same task or sibling tasks must
indicate identical storage or disjoint storage. The list items that appear
in the DEPEND clause may include array sections. Zero-sized arrays
and common block names are not permitted as list items.
The behavior is undefined in these cases:
• If a list item has the POINTER attribute and its association status is
disassociated or undefined
• If a list item has the ALLOCATABLE attribute and its allocation
status is unallocated
Note that this enforced task dependence establishes a synchronization
of accesses to each list item performed by a dependent task, with
respect to accesses to the same list item performed by any previous
tasks. You must properly synchronize access with respect to other
concurrent accesses to each list item.
If a DEPEND clause appears in a TARGET or TARGET UPDATE directive, it is treated as if it had appeared on
the implicit task construct that encloses the TARGET construct.
DEVICE Clause
Parallel Directive Clause: Specifies the target
device for a processor control directive like TARGET.
Syntax
DEVICE (scalar-integer-expression)
1423
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
At most one DEVICE clause can appear in a directive that allows the clause.
If DEVICE is not specified, the default device is determined by the internal control variable (ICV) named
device-num-var.
DFLOAT
Elemental Intrinsic Function (Generic): Converts
an integer to double-precision real type.
Syntax
result = DFLOAT (a)
Results
The result type is double-precision real (by default, REAL(8) or REAL*8). Functions that cause conversion of
one data type to another type have the same effect as the implied conversion in assignment statements.
INTEGER(1) REAL(8)
Example
DFLOAT (-4) has the value -4.0.
See Also
REAL
Module
USE IFPORT
Syntax
result = DFLOATI (i)
result = DFLOATJ (j)
result = DFLOATK (k)
1424
Language Reference
Results
The result type is double-precision real (REAL(8) or REAL*8).
See Also
DFLOAT
DIGITS
Inquiry Intrinsic Function (Generic): Returns the
number of significant digits for numbers of the same
type and kind parameters as the argument.
Syntax
result = DIGITS (x)
Results
The result is a scalar of type default integer.
The result has the value q if x is of type integer; it has the value p if x is of type real. Integer parameter q is
defined in Model for Integer Data; real parameter p is defined in Model for Real Data.
Example
If x is of type REAL(4), DIGITS(x) has the value 24.
See Also
EXPONENT
RADIX
FRACTION
Data Representation Models
DIM
Elemental Intrinsic Function (Generic): Returns
the difference between two numbers (if the difference
is positive).
Syntax
result = DIM (x, y)
Results
The result type and kind are the same as x. The value of the result is x- y if x is greater than y; otherwise,
the value of the result is zero.
1425
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The setting of compiler options specifying integer size can affect this function.
Example
DIM (6, 2) has the value 4.
DIM (-4.0, 3.0) has the value 0.0.
The following shows another example:
INTEGER i
REAL r
REAL(8) d
i = IDIM(10, 5) ! returns 5
r = DIM (-5.1, 3.7) ! returns 0.0
d = DDIM (10.0D0, -5.0D0) ! returns 15.0D0
See Also
Argument Keywords in Intrinsic Procedures
DIMENSION
Statement and Attribute: Specifies that an object is
an array, and defines the shape of the array.
Syntax
The DIMENSION attribute can be specified in a type declaration statement or a DIMENSION statement, and
takes one of the following forms:
Type Declaration Statement:
type,[att-ls,] DIMENSION (a-spec) [, att-ls] :: a[(a-spec)][ , a[(a-spec)] ] ...
Statement:
DIMENSION [::]a(a-spec) [, a(a-spec) ] ...
1426
Language Reference
Description
The DIMENSION attribute allocates a number of storage elements to each array named, one storage element
to each array element in each dimension. The size of each storage element is determined by the data type of
the array.
The total number of storage elements assigned to an array is equal to the number produced by multiplying
together the number of elements in each dimension in the array specification. For example, the following
statement defines ARRAY as having 16 real elements of 4 bytes each and defines MATRIX as having 125
integer elements of 4 bytes each:
Example
The following examples show type declaration statements specifying the DIMENSION attribute:
DIMENSION BOTTOM(12,24,10)
DIMENSION X(5,5,5), Y(4,85), Z(100)
DIMENSION MARK(4,4,4,4)
SUBROUTINE APROC(A1,A2,N1,N2,N3)
DIMENSION A1(N1:N2), A2(N3:*)
CHARACTER(LEN = 20) D
DIMENSION A(15), B(15, 40), C(-5:8, 7), D(15)
You can declare arrays by using type statements and ALLOCATABLE attributes and statements, for example:
INTEGER A(2,0:2)
COMPLEX F
ALLOCATABLE F(:,:)
REAL(8), ALLOCATABLE, DIMENSION( :, :, : ) :: E
You can declare an implicit-shape constant array by using a type statement and a PARAMETER attribute, for
example:
1427
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
You can also declare arrays by using type and ALLOCATABLE statements, for example:
INTEGER A(2,0:2)
COMPLEX F
ALLOCATABLE F(:,:)
REAL(8), ALLOCATABLE, DIMENSION( :, :, : ) :: E
You can specify both the upper and lower dimension bounds. If, for example, one array contains data from
experiments numbered 28 through 112, you could dimension the array as follows:
DIMENSION experiment(28:112)
Then, to refer to the data from experiment 72, you would reference experiment(72).
Array elements are stored in column-major order: the leftmost subscript is incremented first when the array
is mapped into contiguous memory addresses. For example, consider the following statements:
INTEGER(2) a
DIMENSION a(2, 0:2)
DATA a /1, 2, 3, 4, 5, 6/
If a is placed at location decimal 1000 in memory, the preceding DATA statement produces the following
mapping.
a(1,0) 1000 1
a(2,0) 1002 2
a(1,1) 1004 3
a(2,1) 1006 4
a(1,2) 1008 5
a(2,2) 100A 6
...
SUBROUTINE Subr (matrix, rows, vector)
REAL MATRIX, VECTOR
INTEGER ROWS
DIMENSION MATRIX (ROWS,*), VECTOR (10),
+ LOCAL (2,4,8)
MATRIX (1,1) = VECTOR (5)
...
See Also
ALLOCATE
Declaration Statements for Arrays
Arrays
1428
Language Reference
DISPATCH
OpenMP* Fortran Compiler Directive: Determines
whether a variant of a procedure is called for a given
function or subroutine call. This feature is only
available for ifx.
Syntax
!$OMP DISPATCH [clause[[,] clause]... ]
statement
1429
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The DISPATCH directive creates an explicit task around the associated code as if a TASK construct was
present. Properties added to the interoperability requirement set can be removed by other directives. The
task will be an included task if the interoperability requirement set does not contain a NOWAIT property.
If the interoperability requirements set contains DEPEND properties, it is as if the TASK construct contained
the corresponding DEPEND clauses.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
DECLARE VARIANT
DISPLAYCURSOR (W*S)
Graphics Function: Controls cursor visibility.
Module
USE IFQWIN
Syntax
result = DISPLAYCURSOR (toggle)
toggle (Input) INTEGER(2). Constant that defines the cursor state. Has two
possible values:
• $GCURSOROFF - Makes the cursor invisible regardless of its current
shape and mode.
• $GCURSORON - Makes the cursor always visible in graphics mode.
Results
The result type is INTEGER(2). The result is the previous value of toggle.
Cursor settings hold only for the currently active child window. You need to call DISPLAYCURSOR for each
window in which you want the cursor to be visible.
A call to SETWINDOWCONFIG turns off the cursor.
See Also
SETTEXTCURSOR
SETWINDOWCONFIG
DISTRIBUTE
OpenMP* Fortran Compiler Directive: Specifies
that loop iterations will be distributed among the
primary threads of all thread teams in a league
created by a teams construct.
Syntax
!$OMP DISTRIBUTE [clause[[,] clause]... ]
do-loop
1430
Language Reference
The binding thread set for a DISTRIBUTE construct is the set of primary threads created by a TEAMS
construct. A DISTRIBUTE region binds to the innermost enclosing team's parallel region. Only the threads
that execute the binding team's parallel region participate in the execution of the loop iterations. A
DISTRIBUTE construct must be closely nested in a team's region.
If used, the END DISTRIBUTE directive must appear immediately after the end of the loop. If you do not
specify an END DISTRIBUTE directive, an END DISTRIBUTE directive is assumed at the end of the do-loop.
The DISTRIBUTE construct is associated with loop iterations that follow the directive. The iterations are
distributed across the primary threads of all teams that execute the team's parallel region to which the
DISTRIBUTE region binds.
A list item may appear in a FIRSTPRIVATE or LASTPRIVATE clause but not both.
1431
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
DO Directive
TEAMS
Parallel Processing Model for information about Binding Sets
DISTRIBUTE PARALLEL DO
OpenMP* Fortran Compiler Directive: Specifies a
loop that can be executed in parallel by multiple
threads that are members of multiple teams.
Syntax
!$OMP DISTRIBUTE PARALLEL DO [clause[[,] clause]... ]
do-loop
[!$OMP END DISTRIBUTE PARALLEL DO]
If the END DISTRIBUTE PARALLEL DO directive is not specified, an END DISTRIBUTE PARALLEL DO directive
is assumed at the end of do-loop.
This directive specifies a composite construct.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
Syntax
!$OMP DISTRIBUTE PARALLEL DO SIMD [clause[[,] clause]... ]
do-loop
[!$OMP END DISTRIBUTE PARALLEL DO SIMD]
1432
Language Reference
If the END DISTRIBUTE PARALLEL DO SIMD directive is not specified, an END DISTRIBUTE PARALLEL DO
SIMD directive is assumed at the end of do-loop.
This directive specifies a composite construct.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
DISTRIBUTE POINT
General Compiler Directive: Specifies loop
distribution. It suggests a location at which a DO loop
can be split.
Syntax
!DIR$ DISTRIBUTE POINT
Loop distribution causes large loops to be distributed (split) into smaller ones. The resulting loops contain a
subset of the instructions from the initial loop. Loop distribution can enable software pipelining to be applied
to more loops. It can also reduce register pressure and improve both instruction and data cache use.
If the directive is placed before a loop, the compiler will determine where to distribute; data dependencies
are observed.
If the directive is placed inside a loop, the distribution is performed after the directive and any loop-carried
dependencies are ignored. Currently only one distribute directive is supported if the directive is placed inside
the loop.
Example
1433
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
b(i) = a(i) +1
....
!DIR$ DISTRIBUTE POINT
call sub(a, n)! Distribution will start here,
! ignoring all loop-carried
! depedencies
c(i) = a(i) + b(i)
....
d(i) = c(i) + 1
enddo
See Also
General Compiler Directives
DISTRIBUTE SIMD
OpenMP* Fortran Compiler Directive: Specifies a
loop that will be distributed across the primary
threads of the teams region. It will be executed
concurrently using SIMD instructions.
Syntax
!$OMP DISTRIBUTE SIMD [clause[[,] clause]... ]
do-loop
[!$OMP END DISTRIBUTE SIMD]
If the END DISTRIBUTE SIMD directive is not specified, an END DISTRIBUTE SIMD directive is assumed at
the end of do-loop.
This directive specifies a composite construct.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
1434
Language Reference
DLGEXIT (W*S)
Dialog Subroutine: Closes an open dialog box.
Module
USE IFLOGM
Syntax
CALL DLGEXIT (dlg)
dlg (Input) Derived type dialog. Contains dialog box parameters. The
components of the type dialog are defined with the PRIVATE
attribute, and cannot be changed or individually accessed by the user.
If you want to exit a dialog box on a condition other than the user selecting the OK or Cancel button, you
need to include a call to DLGEXIT from within your callback routine. DLGEXIT saves the data associated with
the dialog box controls and then closes the dialog box. The dialog box is exited after DLGEXIT has returned
control back to the dialog manager, not immediately after the call to DLGEXIT.
Example
SUBROUTINE EXITSUB (dlg, exit_button_id, callbacktype)
USE IFLOGM
TYPE (DIALOG) dlg
INTEGER exit_button_id, callbacktype
...
CALL DLGEXIT (dlg)
See Also
DLGSETRETURN
DLGINIT
DLGMODAL
DLGMODELESS
DLGFLUSH (W*S)
Dialog Subroutine: Updates the display of a dialog
box.
Module
USE IFLOGM
Syntax
CALL DLGFLUSH (dlg[,flushall])
dlg (Input) Derived type dialog. Contains dialog box parameters. The
components of the type dialog are defined with the PRIVATE
attribute, and cannot be changed or individually accessed by the user.
flushall (Input; optional) Logical. If .FALSE. (the default), then only the
controls that the dialog routines have marked as changed are
updated. If .TRUE., all controls are updated with the state of the
controls as known by the dialog routines. Normally, you would not set
flushall to .TRUE..
1435
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
When your application calls DLGSET to change a property of a control in a dialog box, the change is not
immediately reflected in the displayed dialog box. Changes are applied when the dialog box is first displayed,
and then after every dialog callback to the user's code.
This design expects that, after a call to DLGMODAL or DLGMODELESS, every call to DLGSET will be made
from within a callback routine, and that the callback routine finishes quickly. This is true most of the time.
However, there may be cases where you want to change a control outside of a dialog callback, or from within
a loop in a dialog callback.
In these cases, DLGFLUSH is required, but is not always sufficient, to update the dialog display. DLGFLUSH
sends pending Windows* system messages to the dialog box and the controls that it contains. However,
many display changes do not appear until after the program reads and processes these messages. A loop
that processes the pending messages may be required; for example:
use IFWINTY
use USER32
use IFLOGM
logical lNotQuit, lret
integer iret
TYPE (T_MSG) mesg
lNotQuit = .TRUE.
do while (lNotQuit .AND. (PeekMessage(mesg, 0, 0, 0, PM_NOREMOVE) <> 0))
lNotQuit = GetMessage(mesg, NULL, 0, 0)
if (lNotQuit) then
if (DLGISDLGMESSAGE(mesg) .EQV. .FALSE) then
lret = TranslateMessage(mesg)
iret = DispatchMessage(mesg)
end if
end if
end do
See Also
DLGINIT
DLGMODAL
DLGMODELESS
DLGSET
DLGSETSUB
Module
USE IFLOGM
Syntax
result = DLGGET (dlg,controlid,value[,index])
result = DLGGETINT (dlg,controlid,value[,index])
result = DLGGETLOG (dlg,controlid,value[,index])
result = DLGGETCHAR (dlg,controlid,value[,index])
1436
Language Reference
dlg (Input) Derived type dialog. Contains dialog box parameters. The
components of the type dialog are defined with the PRIVATE
attribute, and cannot be changed or individually accessed by the user.
controlid (Input) Integer. Specifies the identifier of a control within the dialog
box. Can be either the symbolic name for the control or the identifier
number, both listed in the Include file (with extension .FD).
index (Input; optional) Integer. Specifies the control variable whose value is
retrieved. Necessary if the control has more than one variable of the
same data type and you do not want to get the value of the default for
that type.
Results
The result type is LOGICAL(4). The result is .TRUE. if successful; otherwise, the result is .FALSE..
Use the DLGGET functions to retrieve the values of variables associated with your dialog box controls. Each
control has at least one of the integer, logical, or character variable associated with it, but not necessarily all.
For information about the location of a document that contains lists of index variables for each control type,
see Additional Documentation: Creating Fortran Applications that Use Windows* Features.
You can use DLGGET to retrieve the value of any variable. You can also use DLGGETINT to retrieve an integer
value, or DLGGETLOG and DLGGETCHAR to retrieve logical and character values, respectively. If you use
DLGGET, you do not have to worry about matching the function to the variable type. If you use the wrong
function type for a variable or try to retrieve a variable type that is not available, the DLGGET functions
return .FALSE..
If two or more controls have the same controlid, you cannot use these controls in a DLGGET operation. In
this case the function returns .FALSE..
The dialog box does not need to be open to access its control variables.
Example
USE IFLOGM
INCLUDE "THISDLG.FD"
TYPE (DIALOG) dlg
INTEGER val
LOGICAL retlog, is_checked
CHARACTER(256) text
...
retlog = DLGGET (dlg, IDC_CHECKBOX1, is_checked, dlg_status)
retlog = DLGGET (dlg, IDC_SCROLLBAR2, val, dlg_range)
retlog = DLGGET (dlg, IDC_STATIC_TEXT1, text, dlg_title)
...
See Also
DLGSET
DLGSETSUB
DLGINIT
DLGMODAL
DLGMODELESS
1437
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Module
USE IFLOGM
Syntax
result = DLGINIT (id,dlg)
result = DLGINITWITHRESOURCEHANDLE (id,hinst,dlg)
Results
The result type is LOGICAL(4). The result is .TRUE. if successful; otherwise, the result is .FALSE..
DLGINIT must be called to initialize a dialog box before it can be used with DLGMODAL, DLGMODELESS, or
any other dialog function.
DLGINIT will only search for the dialog box resource in the main application. For example, it will not find a
dialog box resource that has been built into a dynamic link library.
DLGINITWITHRESOURCEHANDLE can be used when the dialog resource is not in the main application. If the
dialog resource is in a dynamic link library (DLL), hinst must be the value passed as the first argument to the
DLLMAIN procedure.
Dialogs can be used from any application, including console, QuickWin, and Windows* applications.
Example
USE IFLOGM
INCLUDE 'DLG1.FD'
LOGICAL retlog
TYPE (DIALOG) thisdlg
...
retlog = DLGINIT (IDD_DLG3, thisdlg)
IF (.not. retlog) THEN
WRITE (*,*) 'ERROR: dialog not found'
ELSE
...
See Also
DLGEXIT
DLGMODAL
DLGMODELESS
DLGUNINIT
1438
Language Reference
Module
USE IFLOGM
Syntax
result = DLGISDLGMESSAGE (mesg)
result = DLGISDLGMESSAGEWITHDLG (mesg, dlg)
dlg (Input) Derived type dialog. Contains dialog box parameters. The
components of the type dialog are defined with the PRIVATE
attribute, and cannot be changed or individually accessed by the user.
Results
The result type is LOGICAL(4). The result is .TRUE. if the message is processed by the dialog box. Otherwise,
the result is .FALSE. and the message should be further processed.
DLGISDLGMESSAGE must be called in the message loop of Windows applications that display a modeless
dialog box using DLGMODELESS. DLGISDGMESSAGE determines whether the message is intended for one of
the currently displayed modeless dialog boxes. If it is, it passes the message to the dialog box to be
processed.
DLGISDLGMESSAGEWITHDLG specifies a particular dialog box to check. Use DLGISDLGMESSAGEWITHDLG
when the message loop is in a main application and the currently active modeless dialog box was created by
a DLL.
Example
use IFLOGM
include 'resource.fd'
type (DIALOG) dlg
type (T_MSG) mesg
integer*4 ret
logical*4 lret
...
! Create the main dialog box and set up the controls and callbacks
lret = DlgInit(IDD_THERM_DIALOG, dlg)
lret = DlgSetSub(dlg, IDD_THERM_DIALOG, ThermSub)
...
lret = DlgModeless(dlg, nCmdShow)
...
! Read and process messsages
do while( GetMessage (mesg, NULL, 0, 0) /= 0 )
! Note that DlgIsDlgMessage must be called in order to give
! the dialog box first chance at the message.
if ( DlgIsDlgMessage(mesg) .EQV. .FALSE. ) then
lret = TranslateMessage( mesg )
ret = DispatchMessage( mesg )
end if
end do
1439
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
DLGMODELESS
Module
USE IFLOGM
Syntax
result = DLGMODAL (dlg)
result = DLGMODAL (dlg, hwndParent)
dlg (Input) Derived type dialog. Contains dialog box parameters. The
components of the type dialog are defined with the PRIVATE
attribute, and cannot be changed or individually accessed by the user.
hwndParent (Input) Integer. Specifies the parent window for the dialog box. If
omitted, the value is determined in this order:
1. If DLGMODAL is called from the callback of a modal or modeless
dialog box, then that dialog box is the parent window.
2. If it is a QuickWin or Standard Graphics application, then the
frame window is the parent window.
3. The Windows* desktop window is the parent window.
Results
The result type is INTEGER(4). By default, if successful, it returns the identifier of the control that caused the
dialog to exit; otherwise, it returns -1. The return value can be changed with the DLGSETRETURN subroutine.
During execution, DLGMODAL displays a dialog box and then waits for user control selections. When a control
selection is made, the callback routine, if any, of the selected control (set with DLGSETSUB) is called.
The dialog remains active until an exit control is executed: either the default exit associated with the OK and
Cancel buttons, or DLGEXIT within your own control callbacks. DLGMODAL does not return a value until the
dialog box is exited.
The default return value for DLGMODAL is the identifier of the control that caused it to exit (for example,
IDOK for the OK button and IDCANCEL for the Cancel button). You can specify your own return value with
DLGSETRETURN from within one of your dialog control callback routines. You should not specify -1 as your
return value, because this is the error value DLGMODAL returns if it cannot open the dialog.
Use DLGMODALWITHPARENT when you want the parent window to be other than the default value (see
argument hwndParent above). In particular, in an SDI or MDI Windows application, you may want the parent
window to be the main application window. The parent window is disabled for user input while the modal
dialog box is displayed.
1440
Language Reference
Example
USE IFLOGM
INCLUDE "MYDLG.FD"
INTEGER return
TYPE (DIALOG) mydialog
...
return = DLGMODAL (mydialog)
...
See Also
DLGSETRETURN
DLGSETSUB
DLGINIT
DLGEXIT
DLGMODELESS (W*S)
Dialog Function: Displays a modeless dialog box.
Module
USE IFLOGM
Syntax
result = DLGMODELESS (dlg[,nCmdShow,hwndParent])
dlg (Input) Derived type dialog. Contains dialog box parameters. The
components of the type dialog are defined with the PRIVATE
attribute, and cannot be changed or individually accessed by the user.
The variable passed to this function must remain in memory for the
duration of the dialog box, that is from the DLGINIT call through the
DLGUNINIT call.
The variable can be declared as global data in a module, as a variable
with the STATIC attribute, or in a calling procedure that is active for
the duration of the dialog box. It must not be an AUTOMATIC variable
in the procedure that calls DLGMODELESS.
nCmdShow (Input) Integer. Specifies how the dialog box is to be shown. It must
be one of the following values:
Value Description
1441
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Value Description
hwndParent (Input) Integer. Specifies the parent window for the dialog box. The
default value is determined in this order:
1. If DLGMODELESS is called from a callback of a modeless dialog
box, then that dialog box is the parent window.
2. The Windows desktop window is the parent window.
Results
The result type is LOGICAL(4). The value is .TRUE. if the function successfully displays the dialog box.
Otherwise the result is .FALSE..
During execution, DLGMODELESS displays a modeless dialog box and returns control to the calling
application. The dialog box remains active until DLGEXIT is called, either explicitly or as the result of the
invocation of a default button callback.
DLGMODELESS is typically used in a Windows application. The application must contain a message loop that
processes Windows messages. The message loop must call DLGISDLGMESSAGE for each message. See the
example below in the Example section. Multiple modeless dialog boxes can be displayed at the same time. A
modal dialog box can be displayed from a modeless dialog box by calling DLGMODAL from a modeless dialog
callback. However, DLGMODELESS cannot be called from a modal dialog box callback.
DLGMODELESS also can be used in a Console, DLL, or LIB project. However, the requirements remain that
the application must contain a message loop and must call DLGISDLGMESSAGE for each message. For an
example of calling DLGMODELESS in a DLL project, see the Dllprgrs sample in the ...\SAMPLES
\DIALOGfolder.
1442
Language Reference
Use the DLG_INIT callback with DLGSETSUB to perform processing immediately after the dialog box is
created and before it is displayed, and to perform processing immediately before the dialog box is destroyed.
Example
use IFLOGM
include 'resource.fd'
type (DIALOG) dlg
type (T_MSG) mesg
integer*4 ret
logical*4 lret
...
! Create the main dialog box and set up the controls and callbacks
lret = DlgInit(IDD_THERM_DIALOG, dlg)
lret = DlgSetSub(dlg, IDD_THERM_DIALOG, ThermSub)
...
lret = DlgModeless(dlg, nCmdShow)
...
! Read and process messsages
do while( GetMessage (mesg, NULL, 0, 0) )
! Note that DlgIsDlgMessage must be called in order to give
! the dialog box first chance at the message.
if ( DlgIsDlgMessage(mesg) .EQV. .FALSE. ) then
lret = TranslateMessage( mesg )
ret = DispatchMessage( mesg )
end if
end do
! Cleanup dialog box memory and exit the application
call DlgUninit(dlg)
WinMain = mesg%wParam
return
See Also
DLGSETSUB
DLGINIT
DLGEXIT
DLGISDLGMESSAGE
DLGSENDCTRLMESSAGE (W*S)
Dialog Function: Sends a Windows message to a
dialog box control.
Module
USE IFLOGM
Syntax
result = DLGSENDCTRLMESSAGE (dlg,controlid,msg,wparam,lparam)
dlg (Input) Derived type dialog. Contains dialog box parameters. The
components of the type dialog are defined with the PRIVATE
attribute, and cannot be changed or individually accessed by the user.
1443
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
controlid (Input) Integer. Specifies the identifier of the control within the dialog
box. Can be either the symbolic name for the control or the identifier
number, both listed in the Include file (with extension .FD).
Results
The result type is INTEGER(4). The value specifies the result of the message processing and depends upon
the message sent.
The dialog box must be currently active by a call to DLGMODAL or DLGMODELESS. This function does not
return until the message has been processed by the control.
Example
use IFLOGM
include 'resource.fd'
type (dialog) dlg
integer callbacktype
integer cref
integer iret
See Also
DLGINIT
DLGSETSUB
DLGMODAL
DLGMODELESS
Module
USE IFLOGM
Syntax
result = DLGSET (dlg,controlid,value[,index])
result = DLGSETINT (dlg,controlid,value[,index])
result = DLGSETLOG (dlg,controlid,value[,index])
result = DLGSETCHAR (dlg,controlid,value[,index])
1444
Language Reference
dlg (Input) Derived type dialog. Contains dialog box parameters. The
components of the type dialog are defined with the PRIVATE
attribute, and cannot be changed or individually accessed by the user.
controlid (Input) Integer. Specifies the identifier of a control within the dialog
box. Can be either the symbolic name for the control or the identifier
number, both listed in the Include file (with extension .FD).
index (Input; optional) Integer. Specifies the control variable whose value is
set. Necessary if the control has more than one variable of the same
data type and you do not want to set the value of the default for that
type.
Results
The result type is LOGICAL(4). The result is .TRUE. if successful; otherwise, the result is .FALSE..
Use the DLGSET functions to set the values of variables associated with your dialog box controls. Each
control has at least one of the integer, logical, or character variables associated with it, but not necessarily
all. For information about the location of a document that contains lists of index variables for each control
type, see Additional Documentation: Creating Fortran Applications that Use Windows* OS Features.
You can use DLGSET to set any control variable. You can also use DLGSETINT to set an integer variable, or
DLGSETLOG and DLGSETCHAR to set logical and character values, respectively. If you use DLGSET, you do
not have to worry about matching the function to the variable type. If you use the wrong function type for a
variable or try to set a variable type that is not available, the DLGSET functions return .FALSE..
Calling DLGSET does not cause a callback routine to be called for the changing value of a control. In
particular, when inside a callback, performing a DLGSET on a control does not cause the associated callback
for that control to be called. Callbacks are invoked automatically only by user action on the controls in the
dialog box. If the callback routine needs to be called, you can call it manually after the DLGSET is executed.
If two or more controls have the same controlid, you cannot use these controls in a DLGSET operation. In
this case the function returns .FALSE..
Example
USE IFLOGM
INCLUDE "DLGRADAR.FD"
TYPE (DIALOG) dlg
LOGICAL retlog
...
retlog = DLGSET (dlg, IDC_SCROLLBAR1, 400, dlg_range)
retlog = DLGSET (dlg, IDC_CHECKBOX1, .FALSE., dlg_status)
retlog = DLGSET (dlg, IDC_RADIOBUTTON1, "Hot Button", dlg_title)
...
See Also
DLGSETSUB
DLGGET
DLGSETCTRLEVENTHANDLER (W*S)
Module
Dialog Function: Assigns user-written event handlers to ActiveX controls in a dialog box.
1445
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
USE IFLOGM
Syntax
result = DLGSETCTRLEVENTHANDLER (dlg,controlid,handler,dispid[,iid])
dlg (Input) Derived type dialog. Contains dialog box parameters. The
components of the type dialog are defined with the PRIVATE
attribute, and cannot be changed or individually accessed by the user.
controlid (Input) Integer. Specifies the identifier of a control within the dialog
box. Can be the symbolic name for the control or the identifier
number, both listed in the include (with extension .FD) file.
handler (Input) Name of the routine to be called when the event occurs. It
must be declared EXTERNAL.
dispid (Input) Integer. Specifies the member id of the method in the event
interface that identifies the event.
iid (Input; optional) Derived type GUID, which is defined in the IFWINTY
module. Specifies the interface identifier of the source (event)
interface. If omitted, the default source interface of the ActiveX
control is used.
Results
The result type is INTEGER(4). The result is an HRESULT describing the status of the operation.
When the ActiveX control event occurs, the handler associated with the event is called. You call
DLGSETCTRLEVENTHANDLER to specify the handler to be called.
The events supported by an ActiveX control and the interfaces of the handlers are determined by the ActiveX
control.
You can find this information in one of the following ways:
• By reading the documentation of the ActiveX control.
• By using a tool that lets you examine the type information of the ActiveX control;, such as the OLE-COM
Object Viewer.
• By using the Fortran Module Wizard to generate a module that contains Fortran interfaces to the ActiveX
control, and examining the generated module.
The handler that you define in your application must have the interface that the ActiveX control expects,
including calling convention and parameter passing mechanisms. Otherwise, your application will likely crash
in unexpected ways because of the application's stack getting corrupted.
Note that an object is always the first parameter in an event handler. This object value is a pointer to the
control's source (event) interface, not the IDispatch pointer of the control. You can use DLGGET with the
DLG_IDISPATCH index to retrieve the control's IDispatch pointer.
Example
USE IFLOGM
ret = DlgSetCtrlEventHandler( &
dlg, &
IDC_ACTIVEMOVIECONTROL1, & ! Identifies the control
ReadyStateChange, & ! Name of the event handling routine
-609, & ! Member id of the ActiveMovie's
& ! control ReadyStateChange event.
IID_DActiveMovieEvents2 ) ! Identifer of the source (event)
! interface.
1446
Language Reference
See Also
DLGINIT
DLGGET
DLGMODAL
DLGMODELESS
DLGSETSUB
DLGSETRETURN (W*S)
Dialog Subroutine: Sets the return value for the
DLGMODAL function from within a callback subroutine.
Module
USE IFLOGM
Syntax
CALL DLGSETRETURN (dlg,retval)
dlg (Input) Derived type dialog. Contains dialog box parameters. The
components of the type dialog are defined with the PRIVATE
attribute, and cannot be changed or individually accessed by the user.
retval (Input) Integer. Specifies the return value for DLGMODAL upon
exiting.
DLGSETRETURN overrides the default return value with retval. You can set your own value as a means of
determining the condition under which the dialog box was closed. The default return value for an error
condition is -1, so you should not use -1 as your return value.
DLGSETRETURN should be called from within a callback routine, and is generally used with DLGEXIT, which
causes the dialog box to be exited from a control callback rather than the user selecting the OK or Cancel
button.
Example
SUBROUTINE SETRETSUB (dlg, button_id, callbacktype)
USE IFLOGM
INCLUDE "MYDLG.FD"
TYPE (DIALOG) dlg
LOGICAL is_checked, retlog
INTEGER return, button_id, callbacktype
...
retlog = DLGGET(dlg, IDC_CHECKBOX4, is_checked, dlg_state)
IF (is_checked) THEN
return = 999
ELSE
return = -999
END IF
CALL DLGSETRETURN (dlg, return)
CALL DLGEXIT (dlg)
END SUBROUTINE SETRETSUB
See Also
DLGEXIT
DLGMODAL
1447
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
DLGSETSUB (W*S)
Dialog Function: Assigns your own callback
subroutines to dialog controls and to the dialog box.
Module
USE IFLOGM
Syntax
result = DLGSETSUB (dlg,controlid,value[,index])
dlg (Input) Derived type dialog. Contains dialog box parameters. The
components of the type dialog are defined with the PRIVATE
attribute, and cannot be changed or individually accessed by the user.
controlid (Input) Integer. Specifies the identifier of a control within the dialog
box. Can be the symbolic name for the control or the identifier
number, both listed in the include (with extension .FD) file, or it can
be the identifier of the dialog box.
value (Input) EXTERNAL. Name of the routine to be called when the callback
event occurs.
Results
The result type is LOGICAL(4). The result is .TRUE. if successful; otherwise, .FALSE..
When a callback event occurs (for example, when you select a check box), the callback routine associated
with that callback event is called. You use DLGSETSUB to specify the subroutine to be called. All callback
routines should have the following interface:
SUBROUTINE callbackname( dlg, control_id, callbacktype)
dlg Refers to the dialog box and allows the callback to change values of
the dialog controls.
The control_id and callbacktype parameters let you write a single subroutine that can be used with multiple
callbacks from more than one control. Typically, you do this for controls comprising a logical group. You can
also associate more than one callback routine with the same control, but you must use then use index
parameter to indicate which callback routine to use.
The control_id can also be the identifier of the dialog box. The dialog box supports two callbacktypes,
DLG_INIT and DLG_SIZECHANGE. The DLG_INIT callback is executed immediately after the dialog box is
created with callbacktype DLG_INIT, and immediately before the dialog box is destroyed with callbacktype
DLG_DESTROY. DLG_SIZECHANGE is called when the size of a dialog is changed.
1448
Language Reference
Callback routines for a control are called after the value of the control has been updated based on the user's
action.
If two or more controls have the same controlid, you cannot use these controls in a DLGSETSUB operation.
In this case, the function returns .FALSE..
Example
USE IFLOGM
INCLUDE "MYDLG.FD"
TYPE (dialog) mydialog
LOGICAL retlog
INTEGER return
EXTERNAL RADIOSUB
retlog = DLGINIT(IDD_mydlg, mydialog)
retlog = DLGSETSUB (mydialog, IDC_RADIO_BUTTON1, RADIOSUB)
retlog = DLGSETSUB (mydialog, IDC_RADIO_BUTTON2, RADIOSUB)
return = DLGMODAL(mydialog)
END
SUBROUTINE RADIOSUB( dlg, id, callbacktype )
!DIR$ ATTRIBUTES DEFAULT :: radiosub
USE IFLOGM
TYPE (dialog) dlg
INTEGER id, callbacktype
INCLUDE 'MYDLG.FD'
CHARACTER(256) text
LOGICAL retlog
SELECT CASE (id)
CASE (IDC_RADIO_BUTTON1)
! Radio button 1 selected by user so
! change text accordingly
text = 'Statistics Package A'
retlog = DLGSET( dlg, IDC_STATICTEXT1, text )
CASE (IDC_RADIO_BUTTON2)
! Radio button 2 selected by user so
! change text accordingly
text = 'Statistics Package B'
retlog = DLGSET( dlg, IDC_STATICTEXT1, text )
END SELECT
END SUBROUTINE RADIOSUB
See Also
DLGSET
DLGGET
DLGSETTITLE (W*S)
Dialog Subroutine: Sets the title of a dialog box.
Module
USE IFLOGM
Syntax
CALL DLGSETTITLE (dlg,title)
1449
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
dlg (Input) Derived type dialog. Contains dialog box parameters. The
components of the type dialog are defined with the PRIVATE
attribute, and cannot be changed or individually accessed by the user.
title (Input) Character*(*). Specifies text to be the title of the dialog box.
Use this routine when you want to specify the title for a dialog box.
Example
USE IFLOGM
INCLUDE "MYDLG.FD"
TYPE (DIALOG) mydialog
LOGICAL retlog
...
retlog = DLGINIT(IDD_mydlg, mydialog)
...
CALL DLGSETTITLE(mydialog, "New Title")
...
See Also
DLGINIT
DLGMODAL
DLGMODELESS
DLGUNINIT (W*S)
Dialog Subroutine: Deallocates memory associated
with an initialized dialog.
Module
USE IFLOGM
Syntax
CALL DLGUNINIT (dlg)
dlg (Input) Derived type dialog. Contains dialog box parameters. The
components of the type dialog are defined with the PRIVATE
attribute, and cannot be changed or individually accessed by the user.
You should call DLGUNINIT when a dialog that was successfully initialized by DLGINIT is no longer needed.
DLGUNINIT should only be called on a dialog initialized with DLGINIT. If it is called on an uninitialized dialog
or one that has already been deallocated with DLGUNINIT, the result is undefined.
Example
USE IFLOGM
INCLUDE "MYDLG.FD"
TYPE (DIALOG) mydialog
LOGICAL retlog
...
retlog = DLGINIT(IDD_mydlg, mydialog)
...
CALL DLGUNINIT (mydialog)
END
1450
Language Reference
See Also
DLGINIT
DLGMODAL
DLGMODELESS
DLGEXIT
DNUM
Elemental Intrinsic Function (Specific): Converts
a character string to a REAL(8) value. This function
cannot be passed as an actual argument.
Syntax
result = DNUM (i)
Results
The result type is REAL(8). The result value is the double-precision real value represented by the character
string i.
Example
DNUM ("3.14159") has the value 3.14159 of type REAL(8).
The following sets x to 311.0:
CHARACTER(3) i
DOUBLE PRECISION x
i = "311"
x = DNUM(i)
DO Directive
OpenMP* Fortran Compiler Directive: Specifies
that the iterations of the immediately following DO
loop must be executed in parallel.
Syntax
!$OMP DO [clause[[,] clause] ... ]
do_loop
[!$OMP END DO [NOWAIT]]
1451
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Kinds Effect
1452
Language Reference
Kinds Effect
Modifier Effect
1453
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Modifier Effect
where simd_width is an
implementation-defined value.
The first chunk will have at least
new_chunk_size iterations
unless it is also the last chunk.
The last chunk may have fewer
iterations than new_chunk_size.
If SIMD is specified and the loop
is not associated with an OMP
SIMD construct, the modifier is
ignored.
1NONMONOTONIC can only be specified with SCHEDULE(DYNAMIC)
or SCHEDULE(GUIDED).
The binding thread set for a DO construct is the current team. A DO loop region binds to the innermost
enclosing parallel region.
If used, the END DO directive must appear immediately after the end of the loop. If you do not specify an
END DO directive, an END DO directive is assumed at the end of the DO loop.
If you specify NOWAIT in the END DO directive, threads do not synchronize at the end of the parallel loop.
Threads that finish early proceed straight to the instruction following the loop without waiting for the other
members of the team to finish the DO directive.
Parallel DO loop control variables are block-level entities within the DO loop. If the loop control variable also
appears in the LASTPRIVATE list of the parallel DO, it is copied out to a variable of the same name in the
enclosing PARALLEL region. The variable in the enclosing PARALLEL region must be SHARED if it is specified
in the LASTPRIVATE list of a DO directive.
Only a single SCHEDULE, COLLAPSE, or ORDERED clause can appear in a DO directive.
ORDERED (n) specifies how many loops are associated with the DO directive and it specifies that those
associated loops form a doacross loop nest. n does not affect how the logical iteration space is divided.
1454
Language Reference
If you specify COLLAPSE (M) ORDERED (N) for loops nested K deep, the following rules apply:
• If either M > K or N > K, the behavior is unspecified.
• N must be greater than M
A LINEAR clause or an ORDERED (n) clause can be specified on a DO directive but not both.
DO directives must be encountered by all threads in a team or by none at all. It must also be encountered in
the same order by all threads in a team.
Example
In the following example, the loop iteration variable is private by default, and it is not necessary to explicitly
declare it. The END DO directive is optional:
!$OMP PARALLEL
!$OMP DO
DO I=1,N
B(I) = (A(I) + A(I-1)) / 2.0
END DO
!$OMP END DO
!$OMP END PARALLEL
If there are multiple independent loops within a parallel region, you can use the NOWAIT option to avoid the
implied BARRIER at the end of the DO directive, as follows:
!$OMP PARALLEL
!$OMP DO
DO I=2,N
B(I) = (A(I) + A(I-1)) / 2.0
END DO
!$OMP END DO NOWAIT
!$OMP DO
DO I=1,M
Y(I) = SQRT(Z(I))
END DO
!$OMP END DO NOWAIT
!$OMP END PARALLEL
Correct execution sometimes depends on the value that the last iteration of a loop assigns to a variable.
Such programs must list all such variables as arguments to a LASTPRIVATE clause so that the values of the
variables are the same as when the loop is executed sequentially, as follows:
!$OMP PARALLEL
!$OMP DO LASTPRIVATE(I)
DO I=1,N
A(I) = B(I) + C(I)
END DO
!$OMP END PARALLEL
CALL REVERSE(I)
In this case, the value of I at the end of the parallel region equals N+1, as in the sequential case.
Ordered sections are useful for sequentially ordering the output from work that is done in parallel. Assuming
that a reentrant I/O library exists, the following program prints out the indexes in sequential order:
1455
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
!$OMP ORDERED
WRITE(*,*) K
!$OMP END ORDERED
In the next example, the loops over J1 and J2 are collapsed and their iteration space is executed by all
threads of the current team:
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
Rules for General Directives that Affect DO Loops
Parallel Processing Model for information about Binding Sets
DO Statement
Statement: Marks the beginning of a DO construct.
The DO construct controls the repeated execution of a
block of statements or constructs. This repeated
execution is called a loop.
Syntax
A DO construct takes one of the following forms:
Block Form:
[name:] DO [label[, ] ] [loop-control]
block
[label] term-stmt
Non-block Form:
DO label [,] [loop-control]
block
[label] ex-term-stmt
1456
Language Reference
term-stmt Is the terminal statement for the block form of the construct.
ex-term-stmt Is the terminal statement for the non-block form of the construct.
Description
The terminal statement (term-stmt) for a block DO construct is an END DO or CONTINUE statement. If the
block DO statement contains a label, the terminal statement must be identified with the same label. If no
label appears, the terminal statement must be an END DO statement.
If a construct name is specified in a block DO statement, the same name must appear in the terminal END
DO statement. If no construct name is specified in the block DO statement, no name can appear in the
terminal END DO statement.
The terminal statement (ex-term-stmt) for a non-block DO construct is an executable statement (or
construct) that is identified by the label specified in the non-block DO statement. A non-block DO construct
can share a terminal statement with another non-block DO construct. A block DO construct cannot share a
terminal statement.
The following cannot be terminal statements for non-block DO constructs:
• CONTINUE (allowed if it is a shared terminal statement)
• CYCLE
• END (for a program or subprogram)
• EXIT
• GO TO (unconditional or assigned)
• Arithmetic IF
• RETURN
• STOP
The non-block DO construct is a deleted feature in the Fortran Standard. Intel® Fortran fully supports
features deleted in the Fortran Standard.
The labeled form of a DO loop is an obsolescent feature in the Fortran Standard.
Example
The following example shows a simple block DO construct (contains no iteration count or DO WHILE
statement):
DO
READ *, N
IF (N == 0) STOP
CALL SUBN
END DO
The DO block executes repeatedly until the value of zero is read. Then the DO construct terminates.
The following example shows a named block DO construct:
LOOP_1: DO I = 1, N
A(I) = C * B(I)
END DO LOOP_1
The following example shows a nonblock DO construct with a shared terminal statement:
DO 20 I = 1, N
DO 20 J = 1 + I, N
20 RESULT(I,J) = 1.0 / REAL(I + J)
1457
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
DO j = 1, 10
WRITE (*, '(I5)') j
END DO
WRITE (*, '(I5)') j
See Also
CONTINUE
CYCLE
EXIT
DO WHILE
DO CONCURRENT
Execution Control
DO CONCURRENT
Statement: Specifies that there are no data
dependencies between the iterations of a DO loop.
Syntax
The DO CONCURRENT statement takes the following form:
[name:] DO [label [,]] CONCURRENT concurrent-header [locality-spec]
block
[END DO [name]]
1458
Language Reference
1459
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If END DO is specified, it terminates the construct. If END DO is not specified, when all of the iterations have
completed execution, the loop terminates, and the DO construct becomes inactive. You can branch to the
END DO statement only from within the construct.
When the DO CONCURRENT construct terminates, a variable that is defined or becomes undefined during
more than one iteration of the construct becomes undefined.
Execution of a CYCLE statement that belongs to a DO CONCURRENT construct completes execution of that
iteration of the construct.
A branch within a DO CONCURRENT construct must not have a branch target that is outside the construct.
If type appears, the index-name has the specified type and type parameters. Otherwise, it has the type and
type parameters that it would have if it were the name of a variable in the innermost executable construct or
scoping unit.
If type does not appear, the index-name must not be the same as a local identifier, an accessible global
identifier, or an identifier of an outer construct entity, except for a common block name or a scalar variable
name.
The index-name of a contained FORALL or DO CONCURRENT construct must not be the same as an index-
name of any of its containing FORALL or DO CONCURRENT constructs.
The following cannot appear in a DO CONCURRENT construct:
• A RETURN statement
• An image control statement
• A branch to a target outside the construct block
• A statement that may result in the deallocation of a polymorphic variable
• An input/output statement with an ADVANCE= specifier
• A reference to a nonpure procedure
• A reference to module IEEE_EXCEPTIONS procedure IEEE_GET_FLAG, IEEE_SET_HALTING_MODE, or
IEEE_GET_HALTING_MODE
An EXIT statement must not appear within a DO CONCURRENT construct if it belongs to that construct or an
outer construct.
A construct or statement entity with the SAVE attribute and with unspecified locality in a DO CONCURRENT
construct has SHARED locality. If it does not have the SAVE attribute, it is a different entity in each iteration
of the construct.
A variable with LOCAL or LOCAL_INIT locality is a construct entity with the same type, type parameters, and
rank as variable with the same name in the innermost construct or scope containing the DO CONCURRENT
construct. The variable outside the construct is inaccessible by that name inside the DO CONCURRENT
construct. The construct entity does not have the BIND, SAVE, VALUE, PROTECTED, or INTENT attribute,
even if the variable with the same name outside the construct has the attribute. The construct entity does
have the VOLATILE, CONTIGUOUS, POINTER, TARGET or ASYCHRONOUS attribute if the variable outside the
construct with the same name has the attribute. If it is a non-pointer, it has the same bounds as the variable
outside the construct.
At the beginning of each iteration, a variable with LOCAL locality that is a pointer has pointer association
status of undefined; otherwise, it is undefined except for any subobjects that are default initialized. A
variable with LOCAL_INIT locality has the definition status and pointer association status of the variable
outside the construct. The variable outside the construct cannot be an undefined nonallocatable nonpointer
variable, or an undefined pointer.
A pointer that becomes associated with a LOCAL or LOCAL_INIT TARGET variable becomes undefined at the
end of the iteration. If a LOCAL or LOCAL_INIT variable appears in an input/output statement, the input/
output operation must complete before the iteration completes.
1460
Language Reference
References in a DO CONCURRENT construct to a SHARED variable are references to the variable in the
innermost construct or scope containing the DO CONCURRENT construct. If the variable is defined or
becomes undefined in one iteration, it cannot be referenced, defined, or become undefined in another
iteration. If it becomes pointer assigned, allocated, deallocated, or nullified in an iteration, its dynamic type,
allocation or allocations status, shape, bounds, or a deferred-type parameter cannot be inquired about in
another iteration. A SHARED noncontiguous array cannot be an actual argument associated with a contiguous
INTENT(INOUT) dummy argument.
The following are rules for variables with unspecified locality in DO CONCURRENT constructs:
• A variable that is referenced in an iteration must be previously defined during that iteration, or it must not
be defined or become undefined during any other iteration.
A variable that is defined or becomes undefined by more than one iteration becomes undefined when the
loop terminates.
• An allocatable object that is allocated in more than one iteration must be subsequently deallocated during
the same iteration in which it was allocated.
An object that is allocated or deallocated in only one iteration must not be referenced, allocated,
deallocated, defined, or become undefined in a different iteration.
• A pointer that is referenced in an iteration must have been pointer associated previously during that
iteration, or it must not have its pointer association changed during any iteration.
A pointer that has its pointer association changed in more than one iteration has an association status of
undefined when the construct terminates.
• An input/output statement must not write data to a file record or position in one iteration and read from
the same record or position in a different iteration.
• Records written by output statements in the range of the loop to a sequential-access file appear in the file
in an indeterminate order.
The restrictions on referencing variables defined in an iteration of a DO CONCURRENT construct also apply to
any procedure invoked within the loop.
These restrictions ensure no interdependencies occur that might affect code optimizations.
Note that if compiler option -qopenmp (Linux* and macOS*) or /Qopenmp (Windows*) is specified, the
compiler will attempt to parallelize the construct.
The labeled form of a DO CONCURRENT loop is an obsolescent feature in the Fortran Standard.
Example
The following shows a DO CONCURRENT construct with a mask-expr and locality specified for variables:
INTEGER,DIMENSION(N) :: J, K
INTEGER :: I, M
M = 10
I = 15
DO CONCURRENT (I = 1:N, J(I)> 0)LOCAL (M) SHARED (J, K)
M = MOD (K(I), J(I))
K(I) = K(I) – M
END DO
PRINT *, I, M ! Prints 15 10
DO SIMD
OpenMP* Fortran Compiler Directive: Specifies
that the iterations of the loop will be distributed across
threads in the team. Iterations executed by each
thread can also be executed concurrently using SIMD
instructions.
1461
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
!$OMP DO SIMD [clause[[,] clause] ... ]
do-loop
[!$OMP END DO SIMD[NOWAIT]]
If the END DO SIMD directive is not specified, an END DO SIMD directive is assumed at the end of do-loop.
You can specify the NOWAIT clause to avoid the implied barrier at the end of a loop construct.
The DO SIMD construct converts the associated DO loop to a SIMD loop in a way that is consistent with any
clauses that apply to the SIMD construct. The resulting SIMD chunks and any remaining iterations will be
distributed across the implicit tasks of the parallel region in a way that is consistent with any clauses that
apply to the DO construct.
This directive specifies a composite construct.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
DO WHILE
Statement: Executes the range of a DO construct
while a specified condition remains true.
Syntax
[name:] DO [label[, ]] WHILE (expr)
block
[END DO [name]]
1462
Language Reference
Description
If a construct name is specified in a DO WHILE statement, the same name must appear in a terminal END
DO statement. If no construct name is specified in the DO WHILE statement, no name can appear in the
terminal END DO statement, if one is specified.
Before each execution of the DO range, the logical expression is evaluated. If it is true, the statements in the
body of the loop are executed. If it is false, the DO construct terminates and control transfers to the
statement following the loop.
If END DO is specified, it terminates the construct. If END DO is not specified, when all of the iterations have
completed execution, the loop terminates, and the DO construct becomes inactive.
If no label appears in a DO WHILE statement, the DO WHILE loop must be terminated with an END DO
statement. See the description of the DO statement for the semantics of labeled and block forms of DO
loops.
You can transfer control out of a DO WHILE loop but not into a loop from elsewhere in the program.
Terminating a DO WHILE loop with an executable statement other than a DO WHILE or a CONTINUE
statement is a deleted feature in the Fortran Standard. Intel® Fortran fully supports features deleted in the
Fortran Standard.
The labeled form of a DO WHILE loop is an obsolescent feature in the Fortran Standard.
Example
The following example shows a DO WHILE statement:
CHARACTER*132 LINE
...
I = 1
DO WHILE (LINE(I:I) .EQ. ' ')
I = I + 1
END DO
The following examples show required and optional END DO statements:
RequiredOptional
DO WHILE (I .GT. J) DO 10 WHILE (I .GT. J)
ARRAY(I,J) = 1.0 ARRAY(I,J) = 1.0
I = I - 1 I = I - 1
END DO 10 END DO
The following shows another example:
CHARACTER(1) input
input = ' '
DO WHILE ((input .NE. 'n') .AND. (input .NE. 'y'))
WRITE (*, '(A)') 'Enter y or n: '
READ (*, '(A)') input
END DO
See Also
CONTINUE
CYCLE
EXIT
DO statement
Execution Control
1463
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
DOT_PRODUCT
Transformational Intrinsic Function (Generic):
Performs dot-product multiplication of numeric or
logical vectors (rank-one arrays).
Syntax
result = DOT_PRODUCT (vector_a,vector_b)
Results
The result is a scalar whose type depends on the types of vector_a and vector_b.
If vector_a is of type integer or real, the result value is SUM ( vector_a* vector_b).
If vector_a is of type complex, the result value is SUM (CONJG ( vector_a)* vector_b).
If vector_a is of type logical, the result has the value ANY ( vector_a.AND. vector_b).
If either rank-one array has size zero, the result is zero if the array is of numeric type, and false if the array
is of logical type.
Example
DOT_PRODUCT ((/1, 2, 3/), (/3, 4, 5/)) has the value 26, calculated as follows:
((1 x 3) + (2 x 4) + (3 x 5)) = 26
DOT_PRODUCT ((/ (1.0, 2.0), (2.0, 3.0) /), (/ (1.0, 1.0), (1.0, 4.0) /)) has the value (17.0, 4.0).
DOT_PRODUCT ((/ .TRUE., .FALSE. /), (/ .FALSE., .TRUE. /)) has the value false.
The following shows another example:
See Also
PRODUCT
MATMUL
TRANSPOSE
DOUBLE COMPLEX
Statement: Specifies the DOUBLE COMPLEX data
type.
Syntax
DOUBLE COMPLEX
A COMPLEX(8) or DOUBLE COMPLEX constant is a pair of constants that represents a complex number. One
of the pair must be a double-precision real constant, the other can be an integer, single-precision real, or
double-precision real constant.
1464
Language Reference
A COMPLEX(8) or DOUBLE COMPLEX constant occupies 16 bytes of memory and is interpreted as a complex
number.
The rules for DOUBLE PRECISION (REAL(8)) constants also apply to the double precision portion of
COMPLEX(KIND=8) or DOUBLE COMPLEX constants. (For more information, see REAL and DOUBLE
PRECISION.)
The DOUBLE PRECISION constants in a COMPLEX(8) or DOUBLE COMPLEX constant have IEEE* binary64
format.
Example
DOUBLE COMPLEX vector, arrays(7,29)
DOUBLE COMPLEX pi, pi2 /3.141592654,6.283185308/
Valid COMPLEX(8) or DOUBLE COMPLEX constants
(547.3E0_8,-1.44_8)
(1.7039E0,-1.7039D0)
(+12739D3,0.D0)
See Also
General Rules for Complex Constants
COMPLEX Statement
Complex Data Types
DOUBLE PRECISION
REAL
DOUBLE PRECISION
Statement: Specifies the DOUBLE PRECISION data
type.
Syntax
DOUBLE PRECISION
A REAL(8) or DOUBLE PRECISION constant has more than twice the accuracy of a REAL(4) number, and
greater range.
A REAL(8) or DOUBLE PRECISION constant occupies eight bytes of memory. The number of digits that
precede the exponent is unlimited, but typically only the leftmost 15 digits are significant.
IEEE* binary64 format is used.
For more information, see General Rules for Real Constants.
Example
DOUBLE PRECISION varnam
DOUBLE PRECISION,PRIVATE :: zz
1465
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
123456789E+5_8
+2.7843D00
-.522D-12
2E200_8
2.3_8
3.4E7_8
See Also
REAL Statement
REAL(8) or DOUBLE PRECISION Constants
Data Types, Constants, and Variables
Real Data Types
DPROD
Elemental Intrinsic Function (Specific): Produces
a higher precision product. This is a specific function
that has no generic function associated with it.
Syntax
result = DPROD (x, y)
Results
If x and y are of type REAL(4), the result type is double-precision real (REAL(8) or REAL*8). If x and y are of
type REAL(8), the result type is REAL(16). The result value is equal to x* y.
The setting of compiler options specifying real size can affect this function.
Example
DPROD (2.0, -4.0) has the value -8.00D0.
DPROD (5.0D0, 3.0D0) has the value 15.00Q0.
1466
Language Reference
REAL(4) e
REAL(8) d
e = 123456.7
d = 123456.7D0
! DPROD (e,e) returns 15241557546.4944
DRAND, DRANDM
Portability Functions: Return double-precision
random numbers in the range 0.0 to 1.0, not including
the end points.
Module
USE IFPORT
Syntax
result = DRAND (iflag)
result = DRANDM (iflag)
iflag (Input) INTEGER(4). Controls the way the random number is selected.
Results
The result type is REAL(8). DRAND and DRANDM return random numbers in the range 0.0 to 1.0, not
including the end points.
There is no difference between DRAND and DRANDM. Both functions are included to insure portability of
existing code that references one or both of them.
The intrinsic subroutines RANDOM_INIT, RANDOM_NUMBER, and RANDOM_SEED provide the same
functionality and they are the recommended functions to use when writing programs to generate random
numbers.
Example
USE IFPORT
REAL(8) num
INTEGER(4) f
f=1
CALL print_rand
f=0
CALL print_rand
f=22
CALL print_rand
1467
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
CONTAINS
SUBROUTINE print_rand
num = drand(f)
print *, 'f= ',f,':',num
END SUBROUTINE
END
See Also
RANDOM_INIT
RANDOM_NUMBER
RANDOM_SEED
DRANSET
Portability Subroutine: Sets the seed for the
random number generator.
Module
USE IFPORT
Syntax
CALL DRANSET (seed)
See Also
RANGET
DREAL
Elemental Intrinsic Function (Specific): Converts
the real part of a double complex argument to double-
precision type. This is a specific function that has no
generic function associated with it. It cannot be
passed as an actual argument.
Syntax
result = DREAL (a)
Results
The result type is double precision real (REAL(8) or REAL*8).
Example
DREAL ((2.0d0, 3.0d0)) has the value 2.0d0.
See Also
REAL
1468
Language Reference
DSHIFTL
Elemental Intrinsic Function (Specific): Selects
the left 64 bits after shifting a 128-bit integer value to
the left. This function cannot be passed as an actual
argument.
Syntax
result = DSHIFTL (i,j,shift)
shift (Input) Integer. Must be nonnegative and less than or equal to 64.
This is the shift count.
Results
The result type is integer. The result value is the 64-bit value starting at bit 128 - shift of the 128-bit
concatenation of the values of i and j.
If either i or j is a binary, octal, or hexadecimal literal constant, it is first converted as if by the intrinsic
function INT to type integer with the kind type parameter of the other. The rightmost shift bits of the result
value are the same as the leftmost bits of i, and the remaining bits of the result value are the same as the
rightmost bits of j. This is equal to IOR (SHIFTL (I, SHIFT), SHIFTR (J, BIT SIZE (J) - SHIFT)).
Example
Consider the following:
See Also
Binary, Octal, Hexadecimal, and Hollerith Constants
Model for Bit Data
DSHIFTR
Elemental Intrinsic Function (Specific): Selects
the left 64 bits after shifting a 128-bit integer value to
the right. This function cannot be passed as an actual
argument.
Syntax
result = DSHIFTR (i,j,shift)
1469
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
shift (Input) Integer. Must be nonnegative and less than or equal to 64.
This is the shift count.
Results
The result type is integer. The result value is the 64-bit value starting at bit 64 + shift of the 128-bit
concatenation of the values of i and j.
If either i or j is a binary, octal, or hexadecimal literal constant, it is first converted as if by the intrinsic
function INT to type integer with the kind type parameter of the other. The leftmost shift bits of the result
value are the same as the rightmost bits of i, and the remaining bits of the result value are the same as the
leftmost bits of j. This is equal to IOR (SHIFTL (I, BIT SIZE (I) - SHIFT), SHIFTR (J, SHIFT)).
Example
Consider the following:
See Also
Binary, Octal, Hexadecimal, and Hollerith Constants
Model for Bit Data
DTIME
Portability Function: Returns the elapsed CPU time
since the start of program execution when first called,
and the elapsed execution time since the last call to
DTIME thereafter.
Module
USE IFPORT
Syntax
result = DTIME (tarray)
Results
The result type is REAL(4). The result is the total CPU time, which is the sum of tarray(1) and tarray(2). If an
error occurs, -1 is returned.
Example
USE IFPORT
REAL(4) I, TA(2)
I = DTIME(TA)
1470
Language Reference
See Also
DATE_AND_TIME
CPU_TIME
E to F
This section describes language features that start with E or F.
E to F
ELEMENTAL
Keyword: Asserts that a user-defined procedure is
defined on scalar arguments that may be called with
array arguments. An elemental procedure may be a
pure procedure or an impure procedure. An elemental
procedure is an elemental intrinsic procedure, an
intrinsic module procedure that is specified to be
elemental, a user-defined procedure that is specified
to be elemental, or a type-bound procedure that is
bound to an elemental procedure. A procedure pointer
or a dummy procedure can not be specified to be
elemental.
Description
To specify an elemental procedure, use this keyword in a FUNCTION or SUBROUTINE statement.
An explicit interface must be visible to the caller of an ELEMENTAL procedure.
An elemental procedure can be passed an array, which is acted upon one element at a time.
For functions, the result must be scalar; it cannot have the POINTER or ALLOCATABLE attribute.
Dummy arguments in ELEMENTAL procedures may appear in specification expressions in the procedure.
Dummy arguments have the following restrictions:
• They must be scalar.
• They cannot have the POINTER or ALLOCATABLE attribute.
• They cannot be an alternate return specifier (*).
• They cannot be dummy procedures.
If the actual arguments are all scalar, the result is scalar. If the actual arguments are array valued, the
values of the elements (if any) of the result are the same as if the function or subroutine had been applied
separately, in any order, to corresponding elements of each array actual argument.
Elemental procedures are pure procedures and all rules that apply to pure procedures also apply to elemental
procedures, unless you specify that the elemental procedure is IMPURE. In that case, the rules for pure
procedures do not apply.
Example
Consider the following:
1471
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
In this case, the elemental reference to the MIN intrinsic function is an array expression whose elements
have the following values:
See Also
FUNCTION
SUBROUTINE
Determining When Procedures Require Explicit Interfaces
Optional Arguments
Module
USE IFQWIN
Syntax
result = ELLIPSE (control,x1,y1,x2,y2)
result = ELLIPSE_W (control,wx1,wy1,wx2,wy2)
control (Input) INTEGER(2). Fill flag. Can be one of the following symbolic
constants:
• $GFILLINTERIOR - Fills the figure using the current color and fill
mask.
• $GBORDER - Does not fill the figure.
Results
The result type is INTEGER(2). The result is nonzero if successful; otherwise, 0. If the ellipse is clipped or
partially out of bounds, the ellipse is considered successfully drawn, and the return is 1. If the ellipse is
drawn completely out of bounds, the return is 0.
The border is drawn in the current color and line style.
1472
Language Reference
When you use ELLIPSE, the center of the ellipse is the center of the bounding rectangle defined by the
viewport-coordinate points ( x1, y1) and ( x2, y2). When you use ELLIPSE_W, the center of the ellipse is the
center of the bounding rectangle defined by the window-coordinate points ( wx1, wy1) and ( wx2, wy2). If
the bounding-rectangle arguments define a point or a vertical or horizontal line, no figure is drawn.
The control option given by $GFILLINTERIOR is equivalent to a subsequent call to the FLOODFILLRGB
function using the center of the ellipse as the start point and the current color (set by SETCOLORRGB) as the
boundary color.
NOTE
The ELLIPSE routine described here is a QuickWin routine. If you are trying to use the
Microsoft* Platform SDK version of the Ellipse routine by including the IFWIN module, you
need to specify the routine name as MSFWIN$Ellipse.
Example
The following program draws the shape shown below.
See Also
ARC
FLOODFILLRGB
GRSTATUS
LINETO
PIE
POLYGON
RECTANGLE
SETCOLORRGB
SETFILLMASK
ELSE Directive
Statement: Marks an optional branch in an IF
Directive Construct.
See Also
See IF Directive Construct.
1473
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
ELSE Statement
Statement: Marks an optional branch in an IF
Construct.
See Also
See IF Construct.
ELSEIF Directive
Statement: Marks an optional branch in an IF
Directive Construct.
See Also
See IF Directive Construct.
ELSE IF
Statement: Marks an optional branch in an IF
Construct.
See Also
See IF Construct.
ELSE WHERE
Statement: Marks the beginning of an ELSE WHERE
block within a WHERE construct.
Syntax
[name:]WHERE (mask-expr1)
[where-body-stmt]...
[ELSE WHERE(mask-expr2) [name]
[where-body-stmt]...]
[ELSE WHERE[name]
[where-body-stmt]...]
END WHERE [name]
1474
Language Reference
Description
Every assignment statement following the ELSE WHERE is executed as if it were a WHERE statement with
".NOT. mask-expr1". If ELSE WHERE specifies "mask-expr2", it is executed as "(.NOT. mask-expr1) .AND.
mask-expr2" during the processing of the ELSE WHERE statement.
Example
WHERE (pressure <= 1.0)
pressure = pressure + inc_pressure
temp = temp - 5.0
ELSEWHERE
raining = .TRUE.
END WHERE
The variables temp, pressure, and raining are all arrays.
See Also
WHERE
ENCODE
Statement: Translates data from internal (binary)
form to character form. It is comparable to using
internal files in formatted sequential WRITE
statements.
Syntax
ENCODE (c,f,b[, IOSTAT=i-var] [, ERR=label]) [io-list]
io-list Is an I/O list. An I/O list is either an implied-DO list or a simple list of
variables (except for assumed-size arrays). The list contains the data
to be translated to character form.
The interaction between the format specifier and the I/O list is the
same as for a formatted I/O statement.
The number of characters that the ENCODE statement can translate depends on the data type of b. For
example, an INTEGER(2) array can contain two characters per element, so that the maximum number of
characters is twice the number of elements in that array.
The maximum number of characters a character variable or character array element can contain is the length
of the character variable or character array element.
1475
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The maximum number of characters a character array can contain is the length of each element multiplied by
the number of elements.
Example
Consider the following:
DIMENSION K(3)
CHARACTER*12 A,B
DATA A/'123456789012'/
DECODE(12,100,A) K
100 FORMAT(3I4)
ENCODE(12,100,B) K(3), K(2), K(1)
The DECODE statement stores the 12 characters into array K:
K(1) = 1234
K(2) = 5678
K(3) = 9012
The ENCODE statement translates the values K(3), K(2), and K(1) to character form and stores the
characters in the character variable B.:
B = '901256781234'
See Also
READ
WRITE
DECODE
END
Statement: Marks the end of a program unit. It takes
one of the following forms:
Syntax
END [PROGRAM [program-name]]
END [FUNCTION [function-name]]
END [SUBROUTINE [subroutine-name]]
END [MODULE [module-name]]
END [SUBMODULE [module-name]]
END [BLOCK DATA [block-data-name]]
In main programs, function subprograms, and subroutine subprograms, END statements are executable and
can be branch target statements. If control reaches the END statement in these program units, the following
occurs:
• In a main program, execution of the END statement initiates normal termination of the image that
executes it.
• In a function or subroutine subprogram, a RETURN statement is implicitly executed.
The END statement cannot be continued in a program unit, and no other statement in the program unit can
have an initial line that appears to be the program unit END statement.
The END statements in a module or block data program unit are nonexecutable.
1476
Language Reference
Example
C An END statement must be the last statement in a program
C unit:
PROGRAM MyProg
WRITE (*, '("Hello, world!")')
END
C
C An example of a named subroutine
C
SUBROUTINE EXT1 (X,Y,Z)
Real, Dimension (100,100) :: X, Y, Z
END SUBROUTINE EXT1
See Also
Program Units and Procedures
Branch Statements
Program Termination
END DO
Statement: Marks the end of a DO or DO WHILE
loop.
Syntax
END DO
Description
There must be a matching END DO statement for every DO or DO WHILE statement that does not contain a
label reference.
An END DO statement can terminate only one DO or DO WHILE statement. If you name the DO or DO WHILE
statement, the END DO statement can specify the same name.
Example
The following examples both produce the same output:
DO ivar = 1, 10
PRINT ivar
END DO
ivar = 0
do2: DO WHILE (ivar .LT. 10)
ivar = ivar + 1
PRINT ivar
END DO do2
See Also
DO
DO WHILE
CONTINUE
ENDIF Directive
Statement: Marks the end of an IF Directive
Construct.
1477
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
See IF Directive Construct.
END IF
Statement: Marks the end of an IF Construct.
See Also
See IF Construct.
ENDFILE
Statement: For sequential files, writes an end-of-file
record to the file and positions the file after this record
(the terminal point). For direct access files, truncates
the file after the current record.
Syntax
It can have either of the following forms:
ENDFILE ([UNIT=] io-unit[, ERR=label] [, IOMSG=msg-var] [, IOSTAT=i-var])
ENDFILE io-unit
label Is the label of the branch target statement that receives control if an
error occurs.
Description
If the unit specified in the ENDFILE statement is not open, the default file is opened for unformatted output.
An end-of-file record can be written only to files with sequential organization that are accessed as formatted-
sequential or unformatted-segmented sequential files. An ENDFILE performed on a direct access file always
truncates the file.
End-of-file records should not be written in files that are read by programs written in a language other than
Fortran.
NOTE
If you use compiler option vms and an ENDFILE is performed on a sequential unit, an actual
one byte record containing a CTRL+Zis written to the file. If this option is not specified, an
internal ENDFILE flag is set and the file is truncated. The option does not affect ENDFILE on
relative files; such files are truncated.
If a parameter of the ENDFILE statement is an expression that calls a function, that function must not cause
an I/O statement or the EOF intrinsic functionto be executed, because unpredictable results can occur.
1478
Language Reference
Example
The following statement writes an end-of-file record to I/O unit 2:
ENDFILE 2
Suppose the following statement is specified:
WRITE (6, *) x
ENDFILE 6
REWIND 6
READ (6, *) y
See Also
BACKSPACE
REWIND
Data Transfer I/O Statements
Branch Specifiers
END FORALL
Statement: Marks the end of a FORALL construct.
The FORALL construct is an obsolescent language
feature in Fortran 2018.
See Also
See FORALL.
END INTERFACE
Statement: Marks the end of an INTERFACE block.
See Also
See INTERFACE.
END TYPE
Statement: Specifies the end of a derived type TYPE
statement.
See Also
See TYPE Statement (Derived Types).
END WHERE
Statement: Marks the end of a WHERE construct.
Example
WHERE (pressure <= 1.0)
pressure = pressure + inc_pressure
temp = temp - 5.0
1479
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
ELSEWHERE
raining = .TRUE.
END WHERE
Note that the variables temp, pressure, and raining are all arrays.
See Also
See WHERE.
ENTRY
Statement: Provides one or more entry points within
a subprogram. It is not executable and must precede
any CONTAINS statement (if any) within the
subprogram.
Syntax
ENTRY name[ ( [d-arg[,d-arg]...] ) [RESULT (r-name)] ]
name Is the name of an entry point. If RESULT is specified, this entry name
must not appear in any specification statement in the scoping unit of
the function subprogram.
r-name (Optional) Is the name of a function result. This name must not be the
same as the name of the entry point, or the name of any other
function or function result. This parameter can only be specified for
function subprograms.
Description
ENTRY statements can only appear in external procedures or module procedures.
An ENTRY statement must not appear in an executable construct.
When the ENTRY statement appears in a subroutine subprogram, it is referenced by a CALL statement. When
the ENTRY statement appears in a function subprogram, it is referenced by a function reference.
An entry name within a function subprogram can appear in a type declaration statement.
Within the subprogram containing the ENTRY statement, the entry name must not appear as a dummy
argument in the FUNCTION or SUBROUTINE statement, and it must not appear in an EXTERNAL or
INTRINSIC statement. For example, neither of the following are valid:
1480
Language Reference
Dummy arguments can be used in ENTRY statements even if they differ in order, number, type and kind
parameters, and name from the dummy arguments used in the FUNCTION, SUBROUTINE, and other ENTRY
statements in the same subprogram. However, each reference to a function, subroutine, or entry must use
an actual argument list that agrees in order, number, and type with the dummy argument list in the
corresponding FUNCTION, SUBROUTINE, or ENTRY statement.
Dummy arguments can be referred to only in executable statements that follow the first SUBROUTINE,
FUNCTION, or ENTRY statement in which the dummy argument is specified. If a dummy argument is not
currently associated with an actual argument, the dummy argument is undefined and cannot be referenced.
Arguments do not retain their association from one reference of a subprogram to another.
Example
C This fragment writes a message indicating
C whether num is positive or negative
IF (num .GE. 0) THEN
CALL Sign
ELSE
CALL Negative
END IF
...
END
SUBROUTINE Sign
WRITE (*, *) 'It''s positive.'
RETURN
ENTRY Negative
WRITE (*, *) 'It''s negative.'
RETURN
END SUBROUTINE
See Also
Program Units and Procedures
ENTRY Statements in Function Subprograms
ENTRY Statements in Subroutine Subprograms
EOF
Inquiry Intrinsic Function (Generic): Checks
whether a file is at or beyond the end-of-file record.
Syntax
result = EOF (unit)
Results
The result type is default logical. The value of the result is .TRUE. if the file connected to unit is at or beyond
the end-of-file record; otherwise, .FALSE..
Example
! Creates a file of random numbers, reads them back
REAL x, total
INTEGER count
OPEN (1, FILE = 'TEST.DAT')
DO I = 1, 20
1481
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
CALL RANDOM_NUMBER(x)
WRITE (1, '(F6.3)') x * 100.0
END DO
CLOSE(1)
OPEN (1, FILE = 'TEST.DAT')
count = 0
total = 0.0
DO WHILE (.NOT. EOF(1))
count = count + 1
READ (1, *) value
total = total + value
END DO
100 IF ( count .GT. 0) THEN
WRITE (*,*) 'Average is: ', total / count
ELSE
WRITE (*,*) 'Input file is empty '
END IF
STOP
END
See Also
ENDFILE
READ Statement for details on an END specifier in a READ statement
BACKSPACE
REWIND
EOSHIFT
Transformational Intrinsic Function (Generic):
Performs an end-off shift on a rank-one array, or
performs end-off shifts on all the complete rank-one
sections along a given dimension of an array of rank
two or greater. Elements are shifted off at one end of
a section and copies of a boundary value are filled in
at the other end. Different sections can have different
boundary values and can be shifted by different
amounts and in different directions.
Syntax
result = EOSHIFT (array,shift [,boundary][,dim])
shift (Input) Must be a scalar integer or an array with a rank that is one
less than array, and shape (d1, d2, ..., ddim-1, ddim+1, ..., dn), where
(d1, d2, ..., dn) is the shape of array.
boundary (Input; optional) Must have the same type and kind parameters as
array. It must be a scalar or an array with a rank that is one less than
array, and shape (d1, d2, ..., ddim-1, ddim+1, ..., dn). The boundary
specifies a value to replace spaces left by the shifting procedure.
If boundary is not specified, it is assumed to have the following
default values (depending on the data type of array):
1482
Language Reference
Integer 0
Real 0.0
Logical false
dim (Input; optional) Must be a scalar integer with a value in the range 1
to n, where n is the rank of array. If dim is omitted, it is assumed to
be 1.
Results
The result is an array with the same type and kind parameters, and shape as array.
If array has rank one, the same shift is applied to each element. If an element is shifted off one end of the
array, the boundary value is placed at the other end the array.
If array has rank greater than one, each section (s1, s2, ..., sdim-1, :, sdim+1, ..., sn) of the result is shifted as
follows:
• By the value of shift, if shift is scalar
• According to the corresponding value in shift(s1, s2, ..., sdim-1, sdim+1, ..., sn), if shift is an array
If an element is shifted off one end of a section, the boundary value is placed at the other end of the section.
The value of shift determines the amount and direction of the end- off shift. A positive shift value causes a
shift to the left (in rows) or up (in columns). A negative shift value causes a shift to the right (in rows) or
down (in columns).
Example
V is the integer array (1, 2, 3, 4, 5, 6).
EOSHIFT (V, SHIFT=2) shifts the elements in V to the left by 2 positions, producing the value (3, 4, 5, 6, 0,
0). 1 and 2 are shifted off the beginning and two elements with the default BOUNDARY value are placed at
the end.
EOSHIFT (V, SHIFT= -3, BOUNDARY= 99) shifts the elements in V to the right by 3 positions, producing the
value (99, 99, 99, 1, 2, 3). 4, 5, and 6 are shifted off the end and three elements with BOUNDARY value 99
are placed at the beginning.
M is the CHARACTER(LEN=1) array
[ 1 2 3 ]
[ 4 5 6 ]
[ 7 8 9 ].
EOSHIFT (M, SHIFT = 1, BOUNDARY = '*', DIM = 2) produces the result
[ 2 3 * ]
[ 5 6 * ]
[ 8 9 * ].
Each element in rows 1, 2, and 3 is shifted to the left by 1 position. This causes the first element in each row
to be shifted off the beginning, and the BOUNDARY value to be placed at the end.
1483
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
[ ^ ^ ^ ]
[ 1 2 3 ]
[ 4 5 6 ].
Each element in columns 1, 2, and 3 is shifted down by 1 position. This causes the last element in each
column to be shifted off the end and the BOUNDARY value (the default character boundary value <space>,
represented by "^") to be placed at the beginning.
EOSHIFT (M, SHIFT = (/1, -1, 0/), BOUNDARY = (/ '*', '?', '/' /), DIM = 2) produces the result
[ 2 3 * ]
[ ? 4 5 ]
[ 7 8 9 ].
Each element in row 1 is shifted to the left by 1 position, causing the first element to be shifted off the
beginning and the BOUNDARY value * to be placed at the end. Each element in row 2 is shifted to the right
by 1 position, causing the last element to be shifted off the end and the BOUNDARY value ? to be placed at
the beginning. No element in row 3 is shifted at all, so the specified BOUNDARY value is not used.
The following shows another example:
INTEGER shift(3)
CHARACTER(1) array(3, 3), AR1(3, 3)
array = RESHAPE ((/'A', 'D', 'G', 'B', 'E', 'H', &
'C', 'F', 'I'/), (/3,3/))
! array is A B C
! D E F
! G H I
shift = (/-1, 1, 0/)
AR1 = EOSHIFT (array, shift, BOUNDARY = (/'*','?','#'/), DIM= 2)
! returns * A B
! E F ?
! G H I
See Also
CSHIFT
ISHFT
ISHFTC
TRANSPOSE
EPSILON
Inquiry Intrinsic Function (Generic): Returns a
positive model number that is almost negligible
compared to unity in the model representing real
numbers.
Syntax
result = EPSILON (x)
Results
The result is a scalar of the same type and kind parameters as x. The result has the value b 1-p. Parameters b
and p are defined in Model for Real Data.
1484
Language Reference
EPSILON makes it easy to select a delta for algorithms (such as root locators) that search until the
calculation is within delta of an estimate. If delta is too small (smaller than the decimal resolution of the data
type), the algorithm might never halt. By scaling the value returned by EPSILON to the estimate, you obtain
a delta that ensures search termination.
Example
If x is of type REAL(4), EPSILON (X) has the value 2 -23.
See Also
PRECISION
TINY
Data Representation Models
EQUIVALENCE
Statement: Specifies that a storage area is shared by
two or more objects in a program unit. This causes
total or partial storage association of the objects that
share the storage area. EQUIVALENCE is an
obsolescent language feature in Standard Fortran.
Syntax
EQUIVALENCE (equiv-list) [,(equiv-list)]...
Description
The following objects cannot be specified in EQUIVALENCE statements:
• A dummy argument
• An allocatable variable
• An automatic object
• A pointer
• An object of nonsequence derived type
• A derived-type object that has an allocatable or pointer component at any level
• A component of a derived-type object
• A function, entry, or result name
• A named constant
• A structure component
• A subobject of any of the above objects
• A coarray
• An object with either the DLLIMPORT or DLLEXPORT attribute
• A variable with the BIND attribute
• A variable in a common block that has the BIND attribute
The EQUIVALENCE statement causes all of the entities in one parenthesized list to be allocated storage
beginning at the same storage location.
If an equivalence object has the PROTECTED attribute, all of the objects in the equivalence set must have the
PROTECTED attribute.
1485
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Any other intrinsic type Must have the same type and kind parameters
So, objects can be associated if they are of different numeric type. For example, the following is valid:
INTEGER A(20)
REAL Y(20)
EQUIVALENCE(A, Y)
Objects of default character do not need to have the same length. The following example associates
character variable D with the last 4 (of the 6) characters of character array F:
CHARACTER(LEN=4) D
CHARACTER(LEN=3) F(2)
EQUIVALENCE(D, F(1)(3:))
Entities having different data types can be associated because multiple components of one data type can
share storage with a single component of a higher-ranked data type. For example, if you make an integer
variable equivalent to a complex variable, the integer variable shares storage with the real part of the
complex variable.
The same storage unit cannot occur more than once in a storage sequence, and consecutive storage units
cannot be specified in a way that would make them nonconsecutive.
Intel® Fortran lets you associate character and noncharacter entities, for example:
CHARACTER*1 char1(10)
REAL reala, realb
EQUIVALENCE (reala, char1(1))
EQUIVALENCE (realb, char1(2))
EQUIVALENCE statements require only the first subscript of a multidimensional array (unless the STRICT
compiler directive is in effect). For example, the array declaration var(3,3), var(4) could appear in an
EQUIVALENCE statement. The reference is to the fourth element of the array (var(1,2)), not to the beginning
of the fourth row or column.
If you use the STRICT directive, the following rules apply to the kinds of variables and arrays that you can
associate:
• If an EQUIVALENCE object is default integer, default real, double-precision real, default complex, default
logical, or a sequenced derived type of all numeric or logical components, all objects in the EQUIVALENCE
statement must be one of these types, though it is not necessary that they be the same type.
• If an EQUIVALENCE object is default character or a sequenced derived type of all character components,
all objects in the EQUIVALENCE statement must be one of these types. The lengths do not need to be the
same.
• If an EQUIVALENCE object is a sequenced derived type that is not purely numeric or purely character, all
objects in the EQUIVALENCE statement must be the same derived type.
• If an EQUIVALENCE object is an intrinsic type other than the default (for example, INTEGER(1)), all
objects in the EQUIVALENCE statement must be the same type and kind.
1486
Language Reference
Example
The following EQUIVALENCE statement is invalid because it specifies the same storage unit for X(1) and
X(2):
REAL, DIMENSION(2) :: X
REAL :: Y
EQUIVALENCE(X(1), Y), (X(2), Y)
The following EQUIVALENCE statement is invalid because A(1) and A(2) will not be consecutive:
REAL A(2)
DOUBLE PRECISION D(2)
EQUIVALENCE(A(1), D(1)), (A(2), D(2))
In the following example, the EQUIVALENCE statement causes the four elements of the integer array IARR to
share the same storage as that of the double-precision variable DVAR:
CHARACTER (LEN = 4) :: a, b
CHARACTER (LEN = 3) :: c(2)
EQUIVALENCE (a, c(1)), (b, c(2))
This causes the following alignment:
1 2 3 4 5 6 7
a(1:1) a(2:2) a(3:3) a(4:4)
b(1:1) b(2:2) b(3:3) b(4:4)
c(1)(1:1) c(1)(2:2) c(1)(3:3) c(2)(1:1) c(2)(2:2) c(2)(3:3)
Note that the fourth element of a, the first element of b, and the first element of c(2) share the same storage
unit.
See Also
Initialization Expressions
Derived Data Types
Storage Association
STRICT Directive
Obsolescent Language Features in the Fortran Standard
1487
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
ERF
Elemental Intrinsic Function (Generic): Returns
the error function of an argument.
Syntax
result = ERF (x)
Results
The result type and kind are the same as x. The result is in the range -1 to 1.
ERF returns the error function of x defined as follows:
Example
ERF (1.0) has the value 0.842700794.
See Also
ERFC
ERFC
Elemental Intrinsic Function (Generic): Returns
the complementary error function of an argument.
Syntax
result = ERFC (x)
Results
The result type and kind are the same as x. The result is in the range 0 to 2.
ERFC returns 1 - ERF(x) and is defined as follows:
ERFC is provided because of the extreme loss of relative accuracy if ERF(x) is called for large x and the result
is subtracted from 1.
1488
Language Reference
Example
ERFC (1.0) has the value 0.1572992057.
See Also
ERF
ERFC_SCALED
Elemental Intrinsic Function (Generic): Returns
the scaled complementary error function of an
argument.
Syntax
result = ERFC_SCALED (x)
Results
The result type and kind are the same as x.
The result has a value equal to a processor-dependent approximation to the exponentially-scaled
complementary error function of
NOTE
Example
ERFC_SCALED (20.0) has the approximate value 0.02817434874.
See Also
ERFC
1489
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
ERRSNS
Intrinsic Subroutine (Generic): Returns
information about the most recently detected I/O
system error condition. Intrinsic subroutines cannot be
passed as actual arguments.
Syntax
CALL ERRSNS ([io_err] [,sys_err] [,stat] [,unit] [,cond])
If you specify INTEGER(2) arguments, only the low-order 16 bits of information are returned or adjacent
data can be overwritten. Because of this, it is best to use INTEGER(4) arguments.
The saved error information is set to zero after each call to ERRSNS.
Example
Any of the arguments can be omitted. For example, the following is valid:
ESTABLISHQQ
Portability Function: Lets you specify a function to
handle errors detected by the Run-Time Library (RTL).
It lets you take appropriate steps in addition to the
RTL's error-handling behavior, or it lets you replace
that behavior.
Module
USE IFESTABLISH
1490
Language Reference
Syntax
result = ESTABLISHQQ (handler_routine,context,prev_handler,prev_context)
Results
The result type for ESTABLISHQQ is LOGICAL(4). It indicates whether the handler was successfully
established. .TRUE. means it was established successfully; .FALSE. means it was not.
The handler function is called when an error occurs. The result for the handler is set by your code in the
handler. .TRUE. means that the error has been handled and the application should not issue an error
message. .FALSE. means that the application should issue an error message and continue as if there had
never been a handler.
After you use ESTABLISHQQ to specify an error handler function and an error occurs, the handler function is
called with the following input arguments. They are set up by the RTL when it calls the handler function:
Handler Function Syntax:
result = Handler_Function (error_code, continuable, message_string, context)
Handler_Function is a function you supply that has a compatible interface. It must use the Intel® Fortran
compiler defaults for calling mechanism and argument passing. When the Intel Fortran Run-Time Library
detects an error, it first calls your handler function with the following arguments:
error_code
(Input) INTEGER(4). This is the number of the error
that occurred and it is the value that will be set in
an IOSTAT= or STAT= specifier variable.
A list of run-time error codes can be found at List of
Run-Time Error Messages.
continuable
(Input) LOGICAL(4). If execution can be continued
after handling this error, this argument is passed
the value .TRUE., otherwise, it is passed the
value .FALSE..
Do not compare this value using arithmetic equality
operators; use logical data type tests or .EQV..
If an error is not continuable, the program exits
after processing the error.
message_string
(Input) CHARACTER(*). This is the text of the error
message as it would otherwise be displayed to the
user.
1491
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
context
(Input) INTEGER(INT_PTR_KIND()). This is the
value passed for the context argument to
ESTABLISHQQ.
Your handler function can use this for any purpose.
The function result of the handler function is type LOGICAL(4). The handler function should return .TRUE. if it
successfully handled the error; otherwise, .FALSE..
If the handler function returns .TRUE. and the error is continuable, execution of the program continues. If the
handler function returns .FALSE., normal error processing is performed, such as message output to the user
and possible program termination.
The handler function can be written in any language, but it must follow the Intel Fortran conventions. Note
that for argument message_string, an address-sized length is passed by value after argument context.
If you want to handle errors using a C/C++ handler, use the ISO_C_BINDINGS module features to call the
C/C++ routine.
Example
logical :: ret
integer(INT_PTR_KIND()) :: old_context, my_context = 0
real, volatile :: x,y,z
integer, volatile :: i, eleven, a(10)
my_context = 1
eleven = 11
if (associated(old_handler_1)) then
print *, "** Unexpected old handler on first ESTABLISH **"
ret = old_handler_1(100, .true., "call number one", 1 )
print *, "back from call of old handler with", ret
else
print *,"== Got expected NULL old handler"
end if
1492
Language Reference
if (associated(old_handler_2)) then
print *, "== Expect first handler as old handler"
ret = old_handler_2(100, .true., "call number one", 1 )
else
print *,"** Unexpectedly didn't get first handler as old handler **"
end if
if (associated(old_handler_3)) then
print *, "== Expect second handler as old handler"
ret = old_handler_3(100, .true., "call number one", 1 )
!print *, "back from call of old handler with", ret
else
print *,"** Unexpectedly didn't get second handler as old handler **"
end if
! Arguments
!
1493
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
if (context == 1) then
print *, " Handler 1, continue"
else
print *, " ** Error -- wrong context value"
end if
return
! Arguments
!
integer, intent(in) :: error_code ! RTL error code from IOSTAT table
logical, intent(in) :: continuable ! True if condition is continuable
character(*), intent(in) :: message_string ! Formatted message string a la ERRMSG/IOMSG
integer(INT_PTR_KIND()), intent(in) :: context ! Address-sized integer passed in to call
! ESTABLISHQQ, for whatever purpose
! the programmer desires
if (context == 1) then
print *," Handler 2, continue"
my_handler_2 = .TRUE. ! Continue
return
end function my_handler_2
1494
Language Reference
! Arguments
!
logical :: my_handler_3
integer, intent(in) :: error_code ! RTL error code from IOSTAT table
logical, intent(in) :: continuable ! True if condition is continuable
character(*), intent(in) :: message_string ! Formatted message string a la ERRMSG/IOMSG
integer(INT_PTR_KIND()), intent(in) :: context ! Address-sized integer passed in to call
! ESTABLISHQQ, for whatever purpose
! the programmer desires
if (context == 1) then
print *," Handler 3, continue"
else if (context == 2) then
print *, " Handler 3, error is ", error_code, message_string
end if
See Also
Understanding Run-Time Errors
List of Run-Time Error Messages
ETIME
Portability Function: On single processor systems,
returns the elapsed CPU time, in seconds, of the
process that calls it. On multi-core or multi-processor
systems, returns the elapsed wall-clock time, in
seconds.
Module
USE IFPORT
Syntax
result = ETIME (array)
array (Output) REAL(4). Must be a rank one array with two elements:
• array(1) − Elapsed user time, which is time spent executing user
code. This value includes time running protected Windows
subsystem code. On single processors, ETIME returns the elapsed
CPU time, in seconds, of the process that calls it. On multiple
processors, ETIME returns the elapsed wall-clock time, in seconds.
• array(2) − Elapsed system time, which is time spent executing
privileged code (code in the Windows Executive) on single
processors; on multiple processors, this value is zero.
1495
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type is REAL(4). The result is the total CPU time, which is the sum of array(1) and array(2).
Example
USE IFPORT
REAL(4) I, TA(2)
I = ETIME(TA)
write(*,*) 'Program has used', I, 'seconds of CPU time.'
write(*,*) ' This includes', TA(1), 'seconds of user time and', &
& TA(2), 'seconds of system time.'
See Also
DATE_AND_TIME
Syntax
EVENT POST (event-var [, sync-stat-list])
EVENT WAIT (event-var [, wait-spec-list])
sync-stat-list Is STAT=stat-var
or ERRMSG=err-var
wait-spec-list Is until-spec
or sync-stat-list
Each specifier is optional and may appear at most once in a sync-stat-list or in a wait-spec-list.
Description
An EVENT POST statement atomically increments the value of event-var by one. Its value is processor
dependent if an error condition occurs during the execution of an EVENT POST statement. The completion of
an EVENT POST statement does not in any way depend on execution of a corresponding EVEN WAIT
statement.
The following actions occur during the execution of an EVENT WAIT statement:
1496
Language Reference
• If UNTIL_COUNT is not specified, the threshold value is one; otherwise, it is the maximum value of one
and the specified scalar-integer-expression.
• The image executing the EVENT WAIT statement waits until the value of event-var is equal to or greater
than the threshold value; otherwise, an error condition occurs.
• If no error condition has occurred, event-var is atomically decremented by the threshold value.
The value of event-var is processor dependent if an error condition occurs during the execution of an EVENT
WAIT statement.
An EVEN POST statement execution is initially unsatisfied. The successful execution of an EVENT WAIT
statement with a threshold value of n satisfies the first n unsatisfied EVENT POST statement executions for
the specified event-var. The EVENT WAIT statement delays execution of the segment following the EVENT
WAIT statement to execute after the segments which precede the first n EVENT POST statement executions
for the specified event-var.
Example
The following example shows the use of EVENT POST and EVENT WAIT statements to synchronize each
image with its left and right neighbor. Image 1 and image NUM_IMAGES() treat each other as left and right
neighbors, conceptually laying the images out in a circle.
See Also
ISO_FORTRAN_ENV
Image Control Statements
Coarrays
Using Coarrays
EVENT_QUERY
Intrinsic Subroutine (Generic): Queries the event
count of an event variable.
Syntax
CALL EVENT_QUERY (event, count [, stat])
1497
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
event (Input) Must be an event variable of type EVENT_TYPE, and must not
be coindexed. The event variable is accessed atomically with respect
to the execution of EVENT POST statements in unordered segments, in
exact analogy to atomic subroutines.
Example
Consider the following example:
See Also
EVENT POST and EVENT WAIT
EXECUTE_COMMAND_LINE
Intrinsic Subroutine: Executes a command line.
Syntax
CALL EXECUTE_COMMAND_LINE (command [,wait,exitstat,cmdstat,cmdmsg])
1498
Language Reference
Description
When command is executed synchronously, EXECUTE_COMMAND_LINE returns after the command line has
completed execution. Otherwise, EXECUTE_COMMAND_LINE returns without waiting.
If a condition occurs that would assign a nonzero value to cmdstat but cmdstat is not present, execution is
terminated.
NOTE
If the application has a standard console window, command output will appear in that
window. On Windows* systems, if the application does not have a console window, including
QuickWin applications, command output will not be shown.
Example
INTEGER :: CSTAT, ESTAT
CHARACTER(100) :: CMSG
CALL EXECUTE_COMMAND_LINE (“dir > dir.txt”, EXITSTAT=ESTAT, &
CMDSTAT=CSTAT, CMDMSG=CMSG)
IF (CSTAT > 0) THEN
PRINT *, “Command execution failed with error “, TRIM(CMSG)
ELSE IF (CSTAT < 0) THEN
PRINT *, “Command execution not supported”
ELSE
PRINT *, “Command completed with status “, ESTAT
END IF
END
In the above example, EXECUTE_COMMAND_LINE is called to execute a "dir" command with output
redirected to a file. Since the WAIT argument was omitted, the call waits for the command to complete and
the command's exit status is returned in ESTAT. If the command cannot be executed, the error message
returned in CMSG is displayed, but note that this is not based on the success or failure of the command itself.
EXIT Statement
Statement: Terminates execution of a DO loop or a
named construct.
Syntax
EXIT [name]
Description
The EXIT statement causes execution of a DO loop or a named construct to be terminated.
If name is specified, the EXIT statement must be within the range of that named construct. Otherwise, the
EXIT statement must be within a DO loop and it exits the innermost DO within which it appears.
If a DO loop is terminated, any inner DO loops are also terminated and the DO control variables retain their
last value. If a non-DO construct is terminated, any DO loops inside that construct are also terminated.
1499
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
An EXIT statement must not appear within a DO CONCURRENT construct if it belongs to that construct or an
outer construct.
An EXIT statement must not appear in a CHANGE TEAM or CRITICAL construct if it belongs to an outer
construct.
An EXIT statement can appear in any of the following constructs:
• ASSOCIATE
• BLOCK
• CHANGE TEAM
• CRITICAL
• DO
• IF
• SELECT CASE
• SELECT RANK
• SELECT TYPE
Example
The following examples demonstrate EXIT statements.
Example 1:
LOOP_A : DO I = 1, 15
N = N + 1
IF (N > I) EXIT LOOP_A
END DO LOOP_A
Example 2:
DO I=1,N
MyBlock: BLOCK
REAL :: T
T = A(I) + B(I)
IF (T == 0.0) EXIT MyBlock
C(I) = T + SQRT(T)
END BLOCK
END DO
Example 4:
DO CONCURRENT (I = 1:N)
MyBlock: BLOCK
REAL :: T
T = A(I) + B(I)
IF (T == 0.0) EXIT MyBlock
C(I) = T + SQRT(T)
END BLOCK
END DO
1500
Language Reference
The following example shows illegal EXIT statements in DO CONCURRENT and CRITICAL:
LOOP_2 : DO I = 1, 15
CRITICAL
N = N + 1
IF (N > I) EXIT LOOP_2 ! can’t EXIT outer construct from inside
END CRITICAL ! CHANGE TEAM, DO CONCURRENT, or CRITICAL
END DO LOOP_2
See Also
DO
DO WHILE
EXIT Subroutine
Intrinsic Subroutine (Generic): Terminates
program execution, closes all files, and returns control
to the operating system. Intrinsic subroutines cannot
be passed as actual arguments.
Syntax
CALL EXIT [( [status] )]
status (Output; optional) Is an integer argument you can use to specify the
image exit-status value.
The exit-status value may not be accessible after program termination in some application environments.
Example
INTEGER(4) exvalue
! all is well, exit with 1
exvalue = 1
CALL EXIT(exvalue)
! all is not well, exit with diagnostic -4
exvalue = -4
CALL EXIT(exvalue)
! give no diagnostic, just exit
CALL EXIT ( )
See Also
END
ABORT
EXP
Elemental Intrinsic Function (Generic): Computes
an exponential value.
Syntax
result = EXP (x)
1501
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type and kind are the same as x. The value of the result is e x. If x is of type complex, its
imaginary part is regarded as a value in radians.
Example
EXP (2.0) has the value 7.389056.
EXP (1.3) has the value 3.669297.
The following shows another example:
See Also
EXP10
LOG
EXP10
Elemental Intrinsic Function (Generic): Computes
a base 10 exponential value.
Syntax
result = EXP10 (x)
1502
Language Reference
Results
The result type and kind are the same as x. The value is 10 raised to the power of x. If x is of type complex,
its imaginary part is regarded as a value in radians.
Example
EXP10 (2.0) has the value 100.00.
EXP10 (1.3) has the value 19.95262.
See Also
LOG10
EXP
EXPONENT
Elemental Intrinsic Function (Generic): Returns
the exponent part of the argument when represented
as a model number.
Syntax
result = EXPONENT (x)
Results
The result type is default integer. If x is not equal to zero, the result value is the exponent part of x. The
exponent must be within default integer range; otherwise, the result is undefined.
If x is zero, the exponent of x is zero. For more information on the exponent part ( e) in the real model, see
Model for Real Data.
Example
EXPONENT (2.0) has the value 2.
If 4.1 is a REAL(4) value, EXPONENT (4.1) has the value 3.
The following shows another example:
REAL(4) r1, r2
REAL(8) r3, r4
r1 = 1.0
r2 = 123456.7
1503
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
r3 = 1.0D0
r4 = 123456789123456.7
write(*,*) EXPONENT(r1) ! prints 1
write(*,*) EXPONENT(r2) ! prints 17
write(*,*) EXPONENT(r3) ! prints 1
write(*,*) EXPONENT(r4) ! prints 47
END
See Also
DIGITS
RADIX
FRACTION
MAXEXPONENT
MINEXPONENT
Data Representation Models
EXTENDS_TYPE_OF
Inquiry Intrinsic Function (Generic): Inquires
whether the dynamic type of an object is an extension
type of the dynamic type of another object.
Syntax
result = EXTENDS_TYPE_OF (a , mold)
Results
The result type is default logical scalar.
The following determines the result value:
• If mold is unlimited polymorphic and is a disassociated pointer or an unallocated allocatable, the result
is .TRUE..
• If a is unlimited polymorphic and is a disassociated pointer or an unallocated allocatable, the result
is .FALSE..
• If the dynamic type of a or mold is extensible, the result is true only if the dynamic type of a is an
extension type of the dynamic type of mold.
EXTERNAL
Statement and Attribute: Allows an external
procedure, a dummy procedure, a procedure pointer,
or a block data subprogram to be used as an actual
argument. (To specify intrinsic procedures as actual
arguments, use the INTRINSIC attribute.)
Syntax
The EXTERNAL attribute can be specified in a type declaration statement or an EXTERNAL statement, and
takes one of the following forms:
1504
Language Reference
Description
In a type declaration statement, only functions can be declared EXTERNAL. However, you can use the
EXTERNAL statement to declare subroutines and block data program units, as well as functions, to be
external.
The name declared EXTERNAL is assumed to be the name of an external procedure, even if the name is the
same as that of an intrinsic procedure. For example, if SIN is declared with the EXTERNAL attribute, all
subsequent references to SIN are to a user-supplied function named SIN, not to the intrinsic function of the
same name.
You can include the name of a block data program unit in the EXTERNAL statement to force a search of the
object module libraries for the block data program unit at link time. However, the name of the block data
program unit must not be used in a type declaration statement.
If you want to describe a routine with greater detail, use the INTERFACE statement. This statement
automatically declares a routine as EXTERNAL, and provides information on result types and argument types.
A procedure that has both the EXTERNAL and POINTER attributes is a procedure pointer.
Example
The following example shows type declaration statements specifying the EXTERNAL attribute:
PROGRAM TEST
...
INTEGER, EXTERNAL :: BETA
LOGICAL, EXTERNAL :: COS
...
CALL SUB(BETA) ! External function BETA is an actual argument
You can use a name specified in an EXTERNAL statement as an actual argument to a subprogram, and the
subprogram can then use the corresponding dummy argument in a function reference or a CALL statement;
for example:
EXTERNAL FACET
CALL BAR(FACET)
SUBROUTINE BAR(F)
EXTERNAL F
CALL F(2)
Used as an argument, a complete function reference represents a value, not a subprogram; for example,
FUNC(B) represents a value in the following statement:
1505
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
INTRINSIC
Program Units and Procedures
Type Declarations
INTRINSIC
Compatible attributes
FORTRAN 66 Interpretation of the External Statement
FAIL IMAGE
Statement: Causes the image that executes it to stop
participating in program execution, without initiating
termination.
Syntax
FAIL IMAGE
This statement allows you to simulate image failure and to test and debug image failure recovery in a
program, without requiring an actual image failure.
After execution of a FAIL IMAGE statement, no additional statements are executed by the image.
A FAIL IMAGE statement is not an image control statement.
The detection of a failed image may happen at different times in the execution of other images; for more
information, see FAILED_IMAGES.
NOTE
If you use a FAIL IMAGE statement to make an image fail, you should use a STAT= specifier or a STAT
argument in all coarray operations that might encounter that failed image if the statement or
operation permits, or you should specify either the assume failed_images or standard-semantics
compiler option. If you do not use a STAT= specifier, a STAT argument, or specify one of the compiler
options, those operations will not check for failed images. They may then try to coordinate with the
failed image, waiting for a response from it. The response would never happen and so the application
would hang.
Examples
The following example demonstrates using the STAT= specifier to prevent an application hang (see Note
above):
1506
Language Reference
END IF
SYNC ALL (STAT=MY_STAT) ! Would hang without STAT=
END SUBROUTINE FAIL_AND_SYNC
If an image calls the following procedure at regular time intervals, it has a one in ten thousand chance of
failure in each time step:
SUBROUTINE RANDOM_FAILURE ()
REAL RANDOM
CALL RANDOM_NUMBER (RANDOM)
IF (RANDOM > 0.9999) FAIL IMAGE
RETURN
END SUBROUTINE RANDOM_FAILURE
See Also
FAILED_IMAGES
IMAGE_STATUS
standard-semantics compiler option
assume [no]failed_images compiler option
FAILED_IMAGES
Transformational Intrinsic Function (Generic):
Returns an array of index images that have failed.
Syntax
result = FAILED_IMAGES ([team, kind])
kind (Input; optional) Must be a scalar integer expression with a value that
is a valid INTEGER kind type parameter.
Results
The result is a rank-one integer array with the same type kind parameters as kind if present; otherwise,
default integer. The size of the array is equal to the number of images in the specified team that are known
to have failed.
The result array elements are the image index values of images on the current team that are known to have
failed. The indices are arranged in increasing numeric order.
If the image executing the FAILED_IMAGES reference previously executed a collective subroutine whose
STAT argument returned the value STAT_FAILED_IMAGES defined in the intrinsic module ISO_FORTRAN_ENV,
or if the image executed an image control statement whose STAT= specifier returned the value
STAT_FAILED_IMAGE, at least one image in the team executing the collective or image control statement is
known to have failed.
Failed images may lead to unavoidable hangs
Coarray programs are parallel programs, so between synchronization points the relative ordering of events in
different images is unknown and undefined. The failure of an image or the execution of the FAIL IMAGE
statement is such an event. It happens at a definite time in the image that fails, but the other images will
discover the failure at different points in their execution. Also, because a failed image does not participate in
synchronization points, it is possible for the discovery to happen before a synchronization point in one image
and after it in another.
1507
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
This means that when other images synchronize (such as with a SYNC ALL), it is possible that some will
know that that image has failed and some will not. In this case, the images that don't know will attempt to
synchronize with the failed image and the application will hang, making no progress.
There is no certain way to prevent a hang when an image fails. However, if you structure your program so
that synchronizations points are infrequent, the chance of a failure happening just before a synchronization
point is lower. If images frequently do coarray loads and stores, or check image status, they are more likely
to discover a failed image sooner. The FAILED_IMAGES intrinsic will check for failed images, but other images
might not get the same result from that call.
Example
If image 5 and 12 of the current team are known to have failed, the result of FAILED_IMAGES ( ) is an array
of default integer type with size 2 defined with the value [5, 12]. If no images in the current team are known
to have failed, the result of FAILED_IMAGES ( ) is a zero-sized array.
See Also
IMAGE_STATUS
STOPPED_IMAGES
ISO_FORTRAN_ENV Module
FDATE
Portability Function and Subroutine: Returns the
current date and time as an ASCII string.
Module
USE IFPORT
Syntax
Function Syntax
result = FDATE()
Subroutine Syntax:
CALL FDATE ( [string] )
Results
The result of the function FDATE and the value of string returned by the subroutine FDATE( string) are
identical. Newline and NULL are not included in the string.
When you use FDATE as a function, declare it as:
CHARACTER*24 FDATE
Example
USE IFPORT
CHARACTER*24 today
!
CALL FDATE(today)
1508
Language Reference
See Also
DATE_AND_TIME
FGETC
Portability Function: Reads the next available
character from a file specified by a Fortran unit
number.
Module
USE IFPORT
Syntax
result = FGETC (lunit,char)
Results
The result type is INTEGER(4). The result is zero if the read is successful, or -1 if an end-of-file is detected. A
positive value is either a system error code or a Fortran I/O error code, such as:
EINVAL: The specified unit is invalid (either not already open, or an invalid unit number).
If you use WRITE, READ, or any other Fortran I/O statements with lunit, be sure to read Portability Routines.
Example
USE IFPORT
CHARACTER inchar
INTEGER istatus
istatus = FGETC(5,inchar)
PRINT *, inchar
END
See Also
GETCHARQQ
READ
FINAL Clause
Parallel Directive Clause: Specifies that the
generated task will be a final task.
Syntax
FINAL (scalar-logical-expression)
1509
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
All task constructs encountered during execution of a final task will generate included tasks.
Note that if a variable is used in a FINAL clause expression of a directive construct, it causes an implicit
reference to the variable in all enclosing constructs.
Only a single FINAL clause can appear in the directive.
FINAL Statement
Statement: Denotes a finalization procedure that
defines one or more final subroutines that are bound
to a derived type.
Syntax
The FINAL statement takes the following form:
FINAL [::] sub1 [, sub2 ]...
sub1, sub2, ... Is a final subroutine, which is a module procedure with exactly one
dummy argument of the derived type. The dummy argument cannot
be INTENT(OUT), it cannot have the VALUE attribute, it cannot be
optional, and it cannot be a pointer, allocatable, or a coarray. All array
shape and length type parameters are assumed.
Description
A final subroutine must not have a dummy argument with the same kind type parameters and rank as the
dummy argument of another final subroutine of the type.
You cannot specify a subroutine that was previously specified as a final subroutine for the derived type.
If a final subroutine has an assumed-rank dummy argument, no other final subroutine of that type can have
a dummy argument with the same kind type parameters.
This statement is used in derived-type type-bound procedures.
A derived type is finalizable only if it has a final subroutine or a nonpointer, nonallocatable component of
finalizable type. A nonpointer data entity is finalizable only if it is of finalizable type.
When an entity is finalized, the following actions occur in this order:
1. If the dynamic type of the entity has a final subroutine whose dummy argument has the same kind
type parameters and rank as the entity being finalized, it is called with the entity as an actual
argument.
Otherwise, if there is an elemental final subroutine whose dummy argument has the same kind type
parameters as the entity being finalized, or a final subroutine whose dummy argument is assumed-rank
with the same kind type parameters as the entity being finalized, it is called with the entity as an actual
argument. Otherwise, no subroutine is called.
2. Finalizable components in the type are finalized. If the entity is an array, each finalizable component of
each element is finalized. The order of finalization is processor dependent.
3. If the entity is of an extended type with a finalizable parent type, the parent component is finalized.
Effects of Finalization
If the variable of an intrinsic assignment is not an unallocated allocatable array when the statement is
executed, the variable is finalized after the expression on the right-hand side (RHS) is evaluated and before
the variable is defined. If the variable is an allocated allocatable variable or has an allocated allocatable
subobject that would be deallocated by intrinsic assignment, finalization occurs before deallocation.
1510
Language Reference
When a pointer is deallocated, its target is finalized. When an allocatable entity is deallocated, it is finalized
unless it is the variable on the left-hand side (LHS) of the intrinsic assignment or a subobject of the variable.
A nonpointer, nonallocatable object that is not a dummy argument or function result is finalized immediately
before it would become undefined due to execution of a RETURN or END statement.
If the entity is of extended type and the parent type is finalizable, the parent component is finalized.
A nonpointer, nonallocatable local variable of a BLOCK construct is finalized immediately before it would
become undefined due to termination of the BLOCK construct.
The following rules also apply:
• If an executable construct references a nonpointer function, the result is finalized after execution of the
innermost executable construct containing the reference.
• If a specification expression in a scoping unit references a function, the result is finalized before execution
of the executable constructs in the scoping unit.
• A nonpointer, nonallocatable, INTENT(OUT) dummy argument of a procedure is finalized when the
procedure is invoked before the dummy argument becomes undefined. Finalization of INTENT(OUT)
dummy arguments occurs in the invoked procedure; for elemental procedures, an INTENT(OUT) argument
will be finalized only if a scalar or elemental final subroutine is available, regardless of the rank of the
argument.
• If image execution is terminated, either by an error or by execution of a ERROR STOP, STOP, or END
PROGRAM statement, any entities that exist immediately before termination are not finalized.
Example
The following example declares two module subroutines to be final:
TYPE MY_TYPE
... ! Component declarations
CONTAINS
FINAL :: CLEAN1, CLEAN2
END TYPE MY_TYPE
See Also
Type-Bound Procedures
FIND
Statement: Positions a direct access file at a
particular record and sets the associated variable of
the file to that record number. It is comparable to a
direct access READ statement with no I/O list, and it
can open an existing file. No data transfer takes place.
Syntax
FIND ([UNIT=] io-unit, REC= r[, ERR= label] [, IOSTAT= i-var])
FIND (io-unit 'r [, ERR=label] [, IOSTAT=i-var])
1511
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
In the following example, the FIND statement positions logical unit 1 at the first record in the file. The file's
associated variable is set to one:
FIND(1, REC=1)
In the following example, the FIND statement positions the file at the record identified by the content of
INDX. The file's associated variable is set to the value of INDX:
FIND(4, REC=INDX)
See Also
Forms for Direct-Access READ Statements
I/O Control List
FINDLOC
Transformational Intrinsic Function (Generic):
Finds the location of a specified value in an array.
Syntax
result = FINDLOC (array, value, dim [, mask, kind, back])
result = FINDLOC (array, value[, mask, kind, back])
dim (Input) Must be a scalar integer with a value in the range 1 <= dim
<= n, where n is the rank of array.
mask (Input; optional) Must be of type logical and conformable with array.
Results
The result is integer. If kind is present, the kind type parameter is that specified by the value of kind.
Otherwise, the kind type parameter is that of default integer type. If dim does not appear, the result is an
array of rank one and of size equal to the rank of array; otherwise, the result is of rank n - 1 and shape (d1,
d2,...ddim-1, ddim+1,...dn), where (d1, d2,...dn) is the shape of array.
The result of FINDLOC (array, value) is a rank-one array whose element values are the values of the
subscripts of an element of array whose value matches value. If there is such a value, the ith subscript
returned is in the range 1 to ei, where ei is the extent of the ith dimension of array. If no elements match
value or if array has size zero, all elements of the result are zero.
1512
Language Reference
The result of FINDLOC (array, value, MASK = mask) is a rank-one array whose element values are the
values of the subscripts of an element of array, corresponding to a true element of mask, whose value
matches value. If there is such a value, the ith subscript returned is in the range 1 to ei, where ei is the
extent of the ith dimension of array. If no elements match value, or array has size zero, or every element
of mask has the value .FALSE., all elements of the result are zero.
If ARRAY has rank one, the result of FINDLOC (array, value, DIM = dim [, MASK = mask]) is a scalar
whose value is equal to that of the first element of FINDLOC (array, value [, MASK = mask]). Otherwise,
the value of element (s1, s2,...sdim-1, sdim+1,...sn) of the result is equal to FINDLOC ( array (s1,
s2,...svaluedim-1, :, sdim+1,...sn), value, DIM = 1 [, MASK = mask (s1, s2,...sdim-1, :, sdim+1,...sn)]).
If both array and value are of type logical, the comparison is performed with the .EQV. operator; otherwise,
the comparison is performed with the == operator. If the value of the comparison is true, that element of
array matches value.
If only one element matches value, that element’s subscripts are returned. If more than one element
matches value and back is absent or present with the value .FALSE., the element whose subscripts are
returned is the first element, taken in array element order. If back is present with the value .TRUE., the
element whose subscripts are returned is the last element, taken in array element order.
The setting of compiler options specifying integer size can affect this function.
Example
The value of FINDLOC ([2, 6, 4, 6], VALUE = 6) is [2].
The value of FINDLOC ([2, 6, 4, 6], VALUE = 6, BACK = .TRUE.) is [4].
If A has the value
[ 0 −5 7 7 ]
[ 3 4 −1 2 ]
[ 1 5 6 7 ]
and M has the value
[ T T F T ]
[ T T F T ]
[ T T F T ]
then FINDLOC (A, 7, MASK = M) is [1, 4] and FINDLOC (A, 7, MASK = M, BACK = .TRUE.) is [3, 4].
This is independent of the declared lower bounds for A.
The value of FINDLOC ([2, 6, 4], VALUE = 6, DIM = 1) is 2.
If B has the value
[ 1 2 -9 ]
[ 2 3 6 ]
then FINDLOC (B, VALUE = 2, DIM = 1) is [2, 1, 0] and FINDLOC (B, VALUE = 2, DIM = 2) is [2, 1].
This is independent of the declared lower bounds for B.
See Also
MAXLOC
MINLOC
1513
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
FINDFILEQQ
Portability Function: Searches for a specified file in
the directories listed in the path contained in the
environment variable.
Module
USE IFPORT
Syntax
result = FINDFILEQQ (filename,varname,pathbuf)
pathbuf (Output) Character*(*). Buffer to receive the full path of the file
found.
Results
The result type is INTEGER(4). The result is the length of the string containing the full path of the found file
returned in pathbuf, or 0 if no file is found.
Example
USE IFPORT
CHARACTER(256) pathname
INTEGER(4) pathlen
pathlen = FINDFILEQQ("libfmt.lib", "LIB", pathname)
WRITE (*,*) pathname
END
See Also
FULLPATHQQ
GETFILEINFOQQ
SPLITPATHQQ
FIRSTPRIVATE
Parallel Directive Clause: Provides a superset of the
functionality provided by the PRIVATE clause. It
declares one or more variables to be private to each
thread in a team, and initializes each of them with the
value of the corresponding original variable.
Syntax
FIRSTPRIVATE (list)
list Is the name of one or more variables or common blocks that are
accessible to the scoping unit. Subobjects cannot be specified. Each
name must be separated by a comma, and a named common block
must appear between slashes (/ /).
1514
Language Reference
Variables that appear in a FIRSTPRIVATE list are subject to PRIVATE clause semantics. In addition, private
(local) copies of each variable in the different threads are initialized to the value the variable had upon
entering the parallel region.
To avoid race conditions, which are caused by unintended sharing of data, concurrent updates of the original
variable must be synchronized with the read of the original variable that occurs as a result of the
FIRSTPRIVATE clause.
If the original variable has the POINTER attribute, the new variable receives the same association status of
the original variable as if by pointer assignment.
If the original variable does not have the POINTER attribute, initialization of the new variable occurs as if by
intrinsic assignment, unless the original variable has the allocation status of "not currently allocated". In this
case, the new variable also has the status of " not currently un allocated".
The following are restrictions for the FIRSTPRIVATE clause:
• A variable that is part of another variable (as an array or structure element) must not appear in a
FIRSTPRIVATE clause.
• A variable that is private within a parallel region must not appear in a FIRSTPRIVATE clause in a
worksharing construct if any of the worksharing regions arising from the worksharing construct ever bind
to any of the parallel regions arising from the parallel construct.
• A variable that appears in a REDUCTION clause of a PARALLEL construct must not appear in a
FIRSTPRIVATE clause in a worksharing or task construct if any of the worksharing or task regions arising
from the worksharing or task construct ever bind to any of the parallel regions arising from the parallel
construct.
• A variable that appears in a REDUCTION clause in a WORKSHARE construct must not appear in a
FIRSTPRIVATE clause in a task construct encountered during execution of any of the worksharing regions
arising from the worksharing construct.
• Assumed-size arrays must not appear in a PRIVATE clause.
• Variables that appear in NAMELIST statements, in variable format expressions, and in expressions for
statement function definitions, must not appear in a PRIVATE clause.
• If a list item appears in both the FIRSTPRIVATE and LASTPRIVATE clauses, the update required for
LASTPRIVATE occurs after all of the initializations for FIRSTPRIVATE.
NOTE
If a variable appears in both FIRSTPRIVATE and LASTPRIVATE clauses, the update required for
LASTPRIVATE occurs after all initializations for FIRSTPRIVATE..
Example
Consider the following:
A = 3
B = 4
!$OMP PARALLEL PRIVATE(A) FIRSTPRIVATE(B)
In this case, variable A has an undefined value at the beginning of the parallel region. However, variable B
has the value 4, which was specified in the serial region preceding the parallel region.
See Also
PRIVATE clause
LASTPRIVATE clause
1515
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
FIXEDFORMLINESIZE
General Compiler Directive: Sets the line length for
fixed-form Fortran source code.
Syntax
!DIR$ FIXEDFORMLINESIZE:{72 | 80 | 132}
You can set FIXEDFORMLINESIZE to 72 (the default), 80, or 132 characters. The FIXEDFORMLINESIZE
setting remains in effect until the end of the file, or until it is reset.
The FIXEDFORMLINESIZE directive sets the source-code line length in include files, but not in USE modules,
which are compiled separately. If an include file resets the line length, the change does not affect the host
file.
This directive has no effect on free-form source code.
Example
!DIR$ NOFREEFORM
!DIR$ FIXEDFORMLINESIZE:132
WRITE (*,*) 'Sentence that goes beyond the 72nd column without continuation.'
See Also
FREEFORM and NOFREEFORM
Source Forms
General Compiler Directives
Syntax Rules for Compiler Directives
Equivalent Compiler Options
FLOAT
Elemental Intrinsic Function (Generic): Converts
an integer to REAL(4).
See Also
REAL
Module
USE IFQWIN
Syntax
result = FLOODFILL (x,y,bcolor)
result = FLOODFILL_W (wx,wy,bcolor)
1516
Language Reference
Results
The result type is INTEGER(2). The result is a nonzero value if successful; otherwise, 0 (occurs if the fill could
not be completed, or if the starting point lies on a pixel with the boundary color bcolor, or if the starting point
lies outside the clipping region).
FLOODFILL begins filling at the viewport-coordinate point ( x, y). FLOODFILL_W begins filling at the window-
coordinate point ( wx, wy). The fill color used by FLOODFILL and FLOODFILL_W is set by SETCOLOR. You can
obtain the current fill color index by calling GETCOLOR. These functions allow access only to the colors in the
palette (256 or less). To access all available colors on a VGA (262,144 colors) or a true color system, use the
RGB functions FLOODFILLRGB and FLOODFILLRGB_W.
If the starting point lies inside a figure, the interior is filled; if it lies outside a figure, the background is filled.
In both cases, the fill color is the current graphics color index set by SETCOLOR. The starting point must be
inside or outside the figure, not on the figure boundary itself. Filling occurs in all directions, stopping at pixels
of the boundary color bcolor.
NOTE
The FLOODFILL routine described here is a QuickWin routine. If you are trying to use the
Microsoft* Platform SDK version of the FloodFill routine by including the IFWIN module, you
need to specify the routine name as MSFWIN$FloodFill.
Example
USE IFQWIN
INTEGER(2) status, bcolor, red, blue
INTEGER(2) x1, y1, x2, y2, xinterior, yinterior
x1 = 80; y1 = 50
x2 = 240; y2 = 150
red = 4
blue = 1
status = SETCOLOR(red)
status = RECTANGLE( $GBORDER, x1, y1, x2, y2 )
bcolor = GETCOLOR()
status = SETCOLOR (blue)
xinterior = 160; yinterior = 100
status = FLOODFILL (xinterior, yinterior, bcolor)
END
See Also
FLOODFILLRGB, FLOODFILLRGB_W
ELLIPSE
GETCOLOR
GETFILLMASK
GRSTATUS
PIE
SETCLIPRGN
SETCOLOR
SETFILLMASK
1517
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Module
USE IFQWIN
Syntax
result = FLOODFILLRGB (x,y,color)
result = FLOODFILLRGB_W (wx,wy,color)
Results
The result type is INTEGER(4). The result is a nonzero value if successful; otherwise, 0 (occurs if the fill could
not be completed, or if the starting point lies on a pixel with the boundary color color, or if the starting point
lies outside the clipping region).
FLOODFILLRGB begins filling at the viewport-coordinate point ( x, y). FLOODFILLRGB_W begins filling at the
window-coordinate point ( wx, wy). The fill color used by FLOODFILLRGB and FLOODFILLRGB_W is set by
SETCOLORRGB. You can obtain the current fill color by calling GETCOLORRGB.
If the starting point lies inside a figure, the interior is filled; if it lies outside a figure, the background is filled.
In both cases, the fill color is the current color set by SETCOLORRGB. The starting point must be inside or
outside the figure, not on the figure boundary itself. Filling occurs in all directions, stopping at pixels of the
boundary color color.
Example
! Build as a QuickWin or Standard Graphics App.
USE IFQWIN
INTEGER(2) status
INTEGER(4) result, bcolor
INTEGER(2) x1, y1, x2, y2, xinterior, yinterior
x1 = 80; y1 = 50
x2 = 240; y2 = 150
result = SETCOLORRGB(Z'008080') ! red
status = RECTANGLE( $GBORDER, x1, y1, x2, y2 )
bcolor = GETCOLORRGB( )
result = SETCOLORRGB (Z'FF0000') ! blue
xinterior = 160; yinterior = 100
result = FLOODFILLRGB (xinterior, yinterior, bcolor)
END
See Also
ELLIPSE
FLOODFILL
GETCOLORRGB
GETFILLMASK
GRSTATUS
PIE
SETCLIPRGN
SETCOLORRGB
SETFILLMASK
1518
Language Reference
FLOOR
Elemental Intrinsic Function (Generic): Returns
the greatest integer less than or equal to its
argument.
Syntax
result = FLOOR (a[,kind])
Results
The result type is integer. If kind is present, the kind parameter of the result is that specified by kind;
otherwise, the kind parameter of the result is that of default integer. If the processor cannot represent the
result value in the kind of the result, the result is undefined.
The value of the result is equal to the greatest integer less than or equal to a.
The setting of compiler options specifying integer size can affect this function.
Example
FLOOR (4.8) has the value 4.
FLOOR (-5.6) has the value -6.
The following shows another example:
I = FLOOR(3.1) ! returns 3
I = FLOOR(-3.1) ! returns -4
See Also
CEILING
FLUSH Directive
OpenMP* Fortran Compiler Directive: Identifies
synchronization points at which the threads in a team
must provide a consistent view of memory.
Syntax
!$OMP FLUSH [(list)]
The binding thread set for a FLUSH construct is the encountering thread.
The FLUSH directive must appear at the precise point in the code at which the synchronization is required. To
avoid flushing all variables, specify a list.
Thread-visible variables are written back to memory at the point at which this directive appears.
Modifications to thread-visible variables are visible to all threads after this point. Subsequent reads of thread-
visible variables fetch the latest copy of the data.
Thread-visible variables include the following data items:
• Globally visible variables (common blocks and modules)
1519
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• Local variables that do not have the SAVE attribute but have had their address taken and saved or have
had their address passed to another subprogram
• Local variables that do not have the SAVE attribute that are declared shared in a parallel region within the
subprogram
• Dummy arguments
• All pointer dereferences
The FLUSH directive is implied for the following directives (unless the NOWAIT keyword is used):
• ATOMIC and END ATOMIC
• BARRIER
• CRITICAL and END CRITICAL
• END DO
• END PARALLEL
• END SECTIONS
• END SINGLE
• END WORKSHARE
• ORDERED and END ORDERED
• PARALLEL and END PARALLEL
• PARALLEL DO and END PARALLEL DO
• PARALLEL SECTIONS and END PARALLEL SECTIONS
• TARGET
• TARGET DATA
• TARGET ENTER DATA on entry
• TARGET EXIT DATA on exit
• TARGET UPDATE on entry if TO is present and on exit if FROM is present
These directives are only available on Linux* systems: TARGET, TARGET DATA, TARGET ENTER DATA, TARGET
EXIT DATA, TARGET UPDATE.
Example
The following example uses the FLUSH directive for point-to-point synchronization between pairs of threads:
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
Parallel Processing Model for information about Binding Sets
1520
Language Reference
FLUSH Statement
Statement: Causes data written to a file to become
available to other processes or causes data written to
a file outside of Fortran to be accessible to a READ
statement. It takes one of the following forms:
Syntax
FLUSH([UNIT=]io-unit [, ERR=label] [, IOMSG=msg-var] [IOSTAT=i-var])
FLUSH io-unit
label (Input) Is the label of the branch target statement that receives
control if an error occurs.
The FLUSH statement specifiers can appear in any order. An I/O unit must be specified, but the UNIT=
keyword is optional if the unit specifier is the first item in the I/O control list.
This statement has no effect on file position.
FLUSH Subroutine
Portability Subroutine: Flushes the contents of an
external unit buffer into its associated file.
Module
USE IFPORT
Syntax
CALL FLUSH (lunit)
NOTE
The flush is performed in a non-blocking mode. In this mode, the command may return before the
physical write is completed. If you want to use a blocking mode of FLUSH use COMMITQQ.
See Also
COMMITQQ
1521
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
!DIR$ FMA
!DIR$ NOFMA
These directives affect the current program unit but they also apply to subsequent program units in the
source file, unless and until a program unit containing another FMA or NOFMA directive is encountered.
Once a NOFMA directive has been specified, it is in effect from that point forward. The setting impacts later
routines in the source file. For example, consider that the following are in the same source file:
!dir$ nofma
fms_mul2 = a*b - c*d ! no fma generation here
end function fms_mul2
See Also
General Compiler Directives
Syntax Rules for Compiler Directives
fma, Qfma compiler option
fp-model strict, fp:strict compiler option
FOCUSQQ (W*S)
QuickWin Function: Sets focus to the window with
the specified unit number.
Module
USE IFQWIN
Syntax
result = FOCUSQQ (iunit)
iunit (Input) INTEGER(4). Unit number of the window to which the focus is
set. Unit numbers 0, 5, and 6 refer to the default startup window.
1522
Language Reference
Results
The result type is INTEGER(4). The result is zero if successful; otherwise, nonzero.
Units 0, 5, and 6 refer to the default window only if the program does not specifically open them. If these
units have been opened and connected to windows, they are automatically reconnected to the console once
they are closed.
Unlike SETACTIVEQQ, FOCUSQQ brings the specified unit to the foreground. Note that the window with the
focus is not necessarily the active window (the one that receives graphical output). A window can be made
active without getting the focus by calling SETACTIVEQQ.
A window has focus when it is given the focus by FOCUSQQ, when it is selected by a mouse click, or when an
I/O operation other than a graphics operation is performed on it, unless the window was opened with
IOFOCUS=.FALSE.. The IOFOCUS specifier determines whether a window receives focus when on I/O
statement is executed on that unit. For example:
See Also
SETACTIVEQQ
INQFOCUSQQ
FOR__SET_FTN_ALLOC
Run-Time Function: Lets you specify your own
routine to dynamically allocate common blocks. This
function is especially useful when you are sharing
libraries.
Syntax
result = FOR__SET_FTN_ALLOC(alloc_routine)
Results
The result has the same type as the type of the argument. The return value is a pointer to the previous
allocation routine you specified for allocation of COMMONs, or to a null pointer if you did not specify a
previous allocation routine.
The caller of FOR__SET_FTN_ALLOC must include a USE IFCOMMONALLOC statement. The allocation routine
should include ISO_C_BINDING so it can correctly declare the arguments.
This function takes precedence over _FTN_ALLOC.
Example
The following shows an example of a user-defined routine that can be used with FOR__SET_FTN_ALLOC.
1523
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Note that you must compile the program using option [Q]dyncom to name the commons you want to be
dynamically allocated.
! Users would put their allocation code here. This example text
! does not contain code to allocate memory.
logical for_old
! Do the swap
!
print *, "my_Fortran_alloc_routine"
if (for_old) then
saved_alloc_routine = set_ftn_alloc( C_FUNLOC(my_Fortran_alloc_routine) )
else
saved_alloc_routine = set_ftn_alloc( saved_alloc_routine )
end if
! Dynamic commons in routines first called in this region will use the
! default allocation method.
1524
Language Reference
swap_alloc_routines( .true. )
swap_alloc_routines( .false. )
! Dynamic commons in routines first called in this region will use the
! default allocation method.
See Also
Allocating Common Blocks
dyncom, Qdyncom compiler option
ISO_C_BINDING
FOR_DESCRIPTOR_ASSIGN (W*S)
Run-Time Subroutine: Creates an array descriptor
in memory.
Module
USE IFCORE
Syntax
CALL FOR_DESCRIPTOR_ASSIGN (dp,base,size,reserved,rank,dims_info)
Note that a Fortran pointer describes both the location and type of the
data item.
size (Input) INTEGER(4). The size of the data type; for example, 4 for
INTEGER(4).
1525
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
TYPE FOR_DIMS_INFO
INTEGER(4) LOWERBOUND !Lower bound for the dimension
INTEGER(4) UPPERBOUND !Upper bound for the dimension
INTEGER(4) STRIDE !Stride for the dimension
END TYPE FOR_DIMS_INFO
The FOR_DESCRIPTOR_ASSIGN routine is similar to a Fortran pointer assignment, but gives you more control
over the assignment, allowing, for example, assignment to any location in memory.
You can also use this routine to create an array that can be used from both Fortran or C.
Example
use IFCORE
common/c_array/ array
real(8) array(5,5)
external init_array
external c_print_array
real(8),pointer :: p_array(:,:)
type(FOR_DIMS_INFO) dims_info(2)
call init_array()
do i=1,5
do j=1,5
print *,i,j, array(i,j)
end do
end do
dims_info(1)%LOWERBOUND = 11
dims_info(1)%UPPERBOUND = 15
dims_info(1)%STRIDE = 1
dims_info(2)%LOWERBOUND = -5
dims_info(2)%UPPERBOUND = -1
dims_info(2)%STRIDE = 1
1526
Language Reference
p_array = p_array + 1
call c_print_array()
end
The following shows the C program containing init_array and c_print_array:
#include <stdio.h>
#if !defined(_WIN32) && !defined(_WIN64)
#define C_ARRAY c_array_
#define INIT_ARRAY init_array_
#define C_PRINT_ARRAY c_print_array_
#endif
double C_ARRAY[5][5];
void INIT_ARRAY(void);
void C_PRINT_ARRAY(void);
void INIT_ARRAY(void)
{
int i,j;
for(i=0;i<5;i++)
for(j=0;j<5;j++)
C_ARRAY[i][j] = j + 10*i;
}
void C_PRINT_ARRAY(void)
{
int i,j;
for(i=0;i<5;i++){
for(j=0;j<5;j++)
printf("%f ", C_ARRAY[i][j]);
printf("\n");
}
}
See Also
POINTER - Fortran
FOR_GET_FPE
Run-Time Function: Returns the current settings of
floating-point exception flags. This routine can be
called from a C or Fortran program.
Module
USE IFCORE
Syntax
result = FOR_GET_FPE( )
1527
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type is INTEGER(4). The return value represents the settings of the current floating-point
exception flags. The meanings of the bits are defined in the IFPORT module file.
To set floating-point exception flags after program initialization, use FOR_SET_FPE.
Example
USE IFCORE
INTEGER*4 FPE_FLAGS
FPE_FLAGS = FOR_GET_FPE ( )
See Also
FOR_SET_FPE
FOR_IFCORE_VERSION
Portability Function: Returns the version of the
Fortran run-time library (ifcore).
Module
USE IFPORT
Syntax
result = FOR_IFCORE_VERSION (string)
string (Output) Character*(*). The version information for the Fortran run-
time library (ifcore).
Results
The result type is INTEGER(4). The result is non-zero if successful; otherwise, zero.
If string is not long enough to contain the version information, the result is truncated on the right. If string is
longer than the version information, the result is blank-padded on the right. The result may contain multiple
blank or ASCII tab characters.
Example
Consider the following:
program what_ifcore
use ifport
integer :: res
character*56 :: str
1528
Language Reference
See Also
FOR_IFCORE_VERSION
FOR_IFPORT_VERSION
Portability Function: Returns the version of the
Fortran portability library (ifport).
Module
USE IFPORT
Syntax
result = FOR_IFPORT_VERSION (string)
Results
The result type is INTEGER(4). The result is non-zero if successful; otherwise, zero.
If string is not long enough to contain the version information, the result is truncated on the right. If string is
longer than the version information, the result is blank-padded on the right. The result may contain multiple
blank or ASCII tab characters.
Example
Consider the following:
program what_ifport
use ifport
integer :: res
character*56 :: str
1529
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
FOR_IFPORT_VERSION
FOR_LFENCE
Run-Time Subroutine: Inserts a memory load fence
instruction that ensures completion of preceding load
instructions.
Module
USE IFCORE
Syntax
CALL FOR_LFENCE ()
Using this subroutine guarantees that in program order, every load instruction that precedes the load fence
instruction is globally visible before any load instruction that follows the load fence.
FOR_MFENCE
Run-Time Subroutine: Inserts a memory fence
instruction that ensures completion of all preceding
load and store instructions.
Module
USE IFCORE
Syntax
CALL FOR_MFENCE ()
Using this subroutine guarantees that in program order, every load and store instruction that precedes the
memory fence instruction is globally visible before any load or store instruction that follows the memory
fence can proceed.
for_rtl_finish_
Run-Time Function: Cleans up the Fortran run-time
environment; for example, flushing buffers and closing
files. It also issues messages about floating-point
exceptions, if any occur.
Syntax
This routine should be called from a C main program; it is invoked by default from a Fortran main program.
result = for_rtl_finish_ ( )
Results
The result is an I/O status value. For information on these status values, see Error Handling: Using the
IOSTAT Value and Fortran Exit Codes.
1530
Language Reference
Example
Consider the following C code:
int io_status;
int for_rtl_finish_ ( );
io_status = for_rtl_finish_ ( );
See Also
for_rtl_init_
for_rtl_init_
Run-Time Subroutine: Initializes the Fortran run-
time environment and causes Fortran procedures and
subroutines to behave the same as when called from a
Fortran main program. On Linux* and macOS*, it also
establishes handlers and floating-point exception
handling.
Syntax
This routine should be called from a C main program; it is invoked by default from a Fortran main program.
CALL for_rtl_init_ (argcount,actarg)
Example
Consider the following C code:
int argc;
char **argv;
void for_rtl_init_ (int *, char **);
for_rtl_init_ (&argc, argv);
See Also
for_rtl_finish_
FOR_SET_FPE
Run-Time Function: Sets the floating-point
exception flags. This routine can be called from a C or
Fortran program.
Module
USE IFCORE
Syntax
result = FOR_SET_FPE (a)
1531
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type is INTEGER(4). The return value represents the previous settings of the floating-point
exception flags. The meanings of the bits are defined in the IFCORE module file.
To get the current settings of the floating-point exception flags, use FOR_GET_FPE.
Example
USE IFCORE
INTEGER*4 OLD_FPE_FLAGS, NEW_FPE_FLAGS
OLD_FPE_FLAGS = FOR_SET_FPE (NEW_FPE_FLAGS)
The following example program is compiled without any fpe options. However, it uses calls to for_set_fpe
to enable the same flags as when compiling with option fpe:0. The new flags can be verified by compiling
the program with option -fpe:0.
program samplefpe
use ifcore
implicit none
end
subroutine PRINT_FPE_FLAGS(fpe_flags)
use ifcore
implicit none
integer(4) :: fpe_flags
character(3) :: toggle
1532
Language Reference
1533
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
>ifort set_fpe_sample01.f90
>set_fpe_sample01.exe
The original FPE FLAGS were:
FPE FLAGS = 0X00000000 B'00000000000000000000000000000000
FPE_TRAP_UND :OFF
FPE_TRAP_OVF :OFF
FPE_TRAP_DIV0 :OFF
FPE_TRAP_INV :OFF
FPE_ABRUPT_UND :OFF
FPE_ABRUPT_OVF :OFF
FPE_ABRUPT_DIV0 :OFF
FPE_ABRUPT_INV :OFF
FPE_ABRUPT_DMZ :OFF (ftz related)
if (ieee_support_subnormal()) then
print *, "Subnormals already supported"
else
orig_flags = for_get_fpe()
1534
Language Reference
if (ieee_support_subnormal()) then
print *, "Subnormals are now supported"
else
print *, "Error: Subnormals still not supported after FOR_SET_FPE call"
end if
end if
x = 0.0
y = tiny(x)
if (ieee_support_subnormal()) then
print *, "Subnormals already supported; turn off"
orig_flags = for_get_fpe()
if (ieee_support_subnormal()) then
print *, "Error: Subnormals still supported after FOR_SET_FPE call"
else
print *, "Subnormals are now NOT supported, should flush to zero"
end if
1535
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
else
print *, "Subnormals already not supported"
end if
1 FORMAT(1X,Z)
2 FORMAT("Flush to zero",1X,E40.25)
x = 0.0
y = tiny(x)
! Expect zeros
!
do i = 1, 20
y = y / 2.0
print 1,y
enddo
FOR_SET_REENTRANCY
Run-Time Function: Controls the type of reentrancy
protection that the Fortran Run-Time Library (RTL)
exhibits. This routine can be called from a C or Fortran
program.
Module
USE IFCORE
1536
Language Reference
Syntax
result = FOR_SET_REENTRANCY (mode)
mode Must be of type INTEGER(4) and contain one of the following options:
Results
The result type is INTEGER(4). The return value represents the previous setting of the Fortran Run-Time
Library reentrancy mode, unless the argument is FOR_K_REENTRANCY_INFO, in which case the return value
represents the current setting.
You must be using an RTL that supports the level of reentrancy you desire. For example,
FOR_SET_REENTRANCY ignores a request for thread protection (FOR_K_REENTRANCY_THREADED) if you do
not build your program with the thread-safe RTL.
Example
PROGRAM SETREENT
USE IFCORE
INTEGER*4 MODE
CHARACTER*10 REENT_TXT(3) /'NONE ','ASYNCH ','THREADED'/
PRINT*,'Setting Reentrancy mode to ',REENT_TXT(MODE+1)
MODE = FOR_SET_REENTRANCY(FOR_K_REENTRANCY_NONE)
PRINT*,'Previous Reentrancy mode was ',REENT_TXT(MODE+1)
MODE = FOR_SET_REENTRANCY(FOR_K_REENTRANCY_INFO)
PRINT*,'Current Reentrancy mode is ',REENT_TXT(MODE+1)
END
FOR_SFENCE
Run-Time Subroutine: Inserts a memory store fence
instruction that ensures completion of preceding store
instructions.
Module
USE IFCORE
1537
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
CALL FOR_SFENCE ()
Using this subroutine guarantees that in program order, every store instruction that precedes the store fence
instruction is globally visible before any store instruction that follows the store fence.
FORALL
Statement and Construct: The FORALL statement
and construct is an element-by-element generalization
of the masked array assignment in the WHERE
statement and construct. It allows more general array
shapes to be assigned, especially in construct form.
The FORALL construct is an obsolescent language
feature in Fortran 2018.
Syntax
Statement:
FORALL (triplet-spec[, triplet-spec] ...[, mask-expr]) assign-stmt
Construct:
[name:] FORALL (triplet-spec[, triplet-spec] ...[, mask-expr])
forall-body-stmt
[forall-body-stmt]...
END FORALL [name]
1538
Language Reference
Description
If a construct name is specified in the FORALL statement, the same name must appear in the corresponding
END FORALL statement.
A FORALL statement is executed by first evaluating all bounds and stride expressions in the triplet
specifications, giving a set of values for each subscript name. The FORALL assignment statement is executed
for all combinations of subscript name values for which the mask expression is true.
The FORALL assignment statement is executed as if all expressions (on both sides of the assignment) are
completely evaluated before any part of the left side is changed. Valid values are assigned to corresponding
elements of the array being assigned to. No element of an array can be assigned a value more than once.
A FORALL construct is executed as if it were multiple FORALL statements, with the same triplet specifications
and mask expressions. Each statement in the FORALL body is executed completely before execution begins
on the next FORALL body statement.
Any procedure referenced in the mask expression or FORALL assignment statement must be pure.
Pure functions can be used in the mask expression or called directly in a FORALL statement. Pure subroutines
cannot be called directly in a FORALL statement, but can be called from other pure procedures.
Starting with Fortran 2018, the FORALL statement and construct are obsolescent features.
Example
The following example, which is not expressible using array syntax, sets diagonal elements of an array to 1:
REAL, DIMENSION(N, N) :: A
FORALL (I=1:N) A(I, I) = 1
Consider the following:
TYPE MONARCH
INTEGER, POINTER :: P
END TYPE MONARCH
TYPE(MONARCH), DIMENSION(8) :: PATTERN
INTEGER, DIMENSION(8), TARGET :: OBJECT
FORALL(J=1:8) PATTERN(J)%P => OBJECT(1+IEOR(J-1,2))
This FORALL statement causes elements 1 through 8 of array PATTERN to point to elements 3, 4, 1, 2, 7, 8,
5, and 6, respectively, of OBJECT. IEOR can be referenced here because it is pure.
1539
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
WHERE
FORMAT
Statement: Specifies the form of data being
transferred and the data conversion (editing) required
to achieve that form.
Syntax
FORMAT (format-list)
Description
A FORMAT statement must be labeled.
Named constants are not permitted in format specifications.
If the associated I/O statement contains an I/O list, the format specification must contain at least one data
edit descriptor or the control edit descriptor Q.
Blank characters can precede the initial left parenthesis, and additional blanks can appear anywhere within
the format specification. These blanks have no meaning unless they are within a character string edit
descriptor.
1540
Language Reference
When a formatted input statement is executed, the setting of the BLANK specifier (for the relevant logical
unit) determines the interpretation of blanks within the specification. If the BN or BZ edit descriptors are
specified for a formatted input statement, they supersede the default interpretation of blanks. (For more
information on BLANK defaults, see the OPEN statement.
For formatted input, you can use the comma as an external field separator. The comma terminates the input
of fields (for noncharacter data types) that are shorter than the number of characters expected. It can also
designate null (zero-length) fields.
The first character of a record transmitted to a line printer or terminal is typically used for carriage control; it
is not printed. The first character of such a record should be a blank, 0, 1, $,+, or ASCII NUL. Any other
character is treated as a blank.
A format specification cannot specify more output characters than the external record can contain. For
example, a line printer record cannot contain more than 133 characters, including the carriage control
character.
Whenever an edit descriptor requires an integer constant, you can specify an expression enclosed in angle
brackets (< and >). For more information, see Variable Format Expressions.
The integer expression can be any valid Fortran expression, including function calls and references to dummy
arguments, with the following restrictions:
• Expressions cannot be used with the H edit descriptor.
• Expressions cannot contain graphical relational operators (such as > and <).
The value of the expression is reevaluated each time an input/output item is processed during the execution
of the READ, WRITE, or PRINT statement.
The following tables summarize the different kinds of edit descriptors:
1541
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1542
Language Reference
Example
INTEGER width, value
width = 2
read (*,1) width, value
! if the input is 3123, prints 123, not 12
1 format ( i1, i<width>)
print *, value
END
See Also
I/O Formatting
Format Specifications
Variable Format Expressions
Data Edit Descriptors
FORM TEAM
Statement: Defines team variables; creates one or
more teams of images from the images on the current
team.
Syntax
The FORM TEAM statement takes the following form:
FORM TEAM(team-number, team-variable [, form-team-spec-list])
team-number Is a scalar-integer-expression.
1543
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
stat-var Is a scalar integer variable in which the status of the FORM TEAM
operation is stored.
The form-team-spec items can appear in any order. Each specifier in a FORM TEAM statement can appear at
most once. stat-var and err-var cannot be coindexed variables.
Description
A FORM TEAM statement creates a new team for each unique team-number specified by the active images of
the current team. The teams are identified by their team numbers, which are positive integers. An image
becomes a member of the team-number specified on the FORM TEAM statement the image executes. The
team-variable becomes defined with values that describe the team.
An image index must be positive and less than or equal to n, the number of images on the team. If
NEW_INDEX= is specified, the value of the scalar-integer-expression is the image index the image executing
the FORM TEAM statement will have on its new team. Its value must be different from any value specified for
every other image that is assigned to the same new team. If NEW_IMAGE= is not specified, the image is
given a processor-dependent unique image index in the range 1, 2, … n on the new team.
All active images of the current team must execute the same FORM TEAM statement. An implicit SYNC ALL
occurs at the FORM TEAM statement. Execution of the segment following the FORM TEAM statement is
delayed until other images of the current team have executed the same FORM TEAM statement the same
number of times. FORM TEAM is an image control statement; all segments executed before the FORM TEAM
statement precede all segments that execute after the FORM TEAM statement.
If STAT= appears and no error occurs, stat-var becomes defined with the value 0. If an image on the current
team has executed a STOP statement, stat-var is assigned the value STAT_STOPPED_IMAGE from the
intrinsic module ISO_FORTRAN_ENV. If there is a failed image on the current team and no other error occurs,
stat-var is assigned the value STAT_FAILED_IMAGE from ISO_FORTRAN_ENV. Otherwise, stat-var is assigned
a positive integer value different from STAT_FAILED_IMAGE and STAT_STOPPED_IMAGE.
team-variable becomes undefined if an error condition occurs.
Examples
Example 1:
USE ISO_FORTRAN
TYPE (TEAM_TYPE) :: one_or_two
IF (THIS_IMAGE() .LE. NUM_IMAGES() / 2) THEN
new_team = 1
ELSE
new_team = 2
END IF
FORM TEAM (new_team, one_or_two)
If the initial team has seven images, and the initial team executes the above FORM TEAM statement, two
teams are formed. The new image indices are assigned by the runtime system in a processor-dependent
manner.
Team number 1 has three images, images [1, 2, 3] of the initial team with new image indices [1, 2, 3]. Team
number 2 has four images, images [4, 5, 6, 7] from the initial team, with new image indices [1, 2, 3, 4]. The
team variable one_or_two on initial team images [1, 2, 3] collectively describe team number 1, while the
team variable one_or_two on the initial team images [4, 5, 6, 7] collectively describe team number 2.
1544
Language Reference
Example 2:
USE ISO_FORTRAN_ENV
TYPE (TEAM_TYPE) :: odd_even
FORM TEAM (2-MOD(THIS_IMAGE(), 2), odd_even)
If a team with 10 images executes the above code, two teams are formed. Team number 1 contains the odd
numbered images [1, 3, 5, 7, 9] of the parent team, and team number 2 contains the even numbered
images [2, 4, 6, 8, 10] of the parent. New image indices on each team are assigned by the processor. The
team variable odd_even across the odd numbered images on the parent team collectively describe team
number 1, and the team variable odd_even across the even numbered images on the parent team
collectively describe team number 2.
Example 3:
USE ISO_FORTRAN_ENV
INTEGER, PARAMETER :: n = 4
TYPE (TEAM_TYPE) :: column
REAL,CODIMENSION[n, *] :: co_array
INTEGER,DIMENSION(2) :: my_cosubscripts
my_cosubscripts (:) = THIS_IMAGE(co_array)
FORM TEAM (my_cosubscripts(2), column, NEW_INDEX = my_cosubscripts(1))
If there are 16 images on the initial team, the scalar coarray co_array will be distributed across a 4x4 grid
of processors. The image indices of the 4x4 grid are:
1 5 9 13
2 6 10 14
3 7 11 15
4 8 12 16
THIS_IMAGE (co_array) will return a two element array of integer cosubscripts of co_array on the image
that executes the reference to THIS_IMAGE. The cosubscripts of each image are:
Execution of the FORM TEAM statement divides the initial team into four teams of four images. Each team
contains the images of one column of the grid of processors. The team number of each team is the column
number in the processor grid, and the image indices on each new team are the row indices of the processor
grid. The new image numbers on each team are shown below:
Team 1 2 3 4
Number
1 1 1 1
2 2 2 2
3 3 3 3
4 4 4 4
Example 4:
This example divides a 4x4 grid of images into 4 2x2 grids of images. Team numbers are assigned in the
FORM TEAM statement that reflect the position of each team in the grid of subteams. The example also
shows the use of NEW_INDEX to assign image indices to the images of the new teams.
The image indices of the 4x4 grid are:
1 5 9 13
1545
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
2 6 10 14
3 7 11 15
4 8 12 16
The 2x2 grids are laid out and identified symbolically and with team numbers as:
top_lef top_rig
t (1,1) ht (1,2)
bot_lef bot_rig
t (2,1) ht (2,2)
The image numbers on each of the teams in the 2x2 grids become:
1 3 1 3
2 4 2 4
1 3 1 3
2 4 2 4
PROGRAM MAIN
USE ISO_FORTRAN_ENV
INTEGER,PARAMETER :: top_left=11, bot_left=21, top_right=12, bot_right=22
INTEGER,DIMENSION(16) :: quads = [top_left, top_left, bot_left, bot_left, &
top_left, top_left, bot_left_ bot_left, &
top_right, top_right, bot_right, bot_right, &
top_right, top_right, bot_right, bot_right]
INTEGER,DIMENSION(16) :: images = [1,2,1,2,3,4,3,4,1,2,1,2,3,4,3,4]
TYPE(TEAM_TYPE) :: quadrants
INTEGER :: me
me = THIS_IMAGE()
FORM TEAM (quads(me), quadrants, NEW_INDEX=images(me))
. . .
END PROGRAM
Example 5:
USE ISO_FORTRAN_ENV
TYPE (TEAM_TYPE) :: original
FORM TEAM (1, original, NEW_INDEX = THIS_IMAGE())
This example forms a single subteam described by the team variable original. The subteam has the same
number of images as the initial team, and each image has the same image number on the initial team as on
the subteam. However, original describes a team that is different but functionally the same as the initial
team. It has a parent team, while the initial team does not.
See Also
Image Control Statements
Coarrays
Using Coarrays
FP_CLASS
Elemental Intrinsic Function (Generic): Returns
the class of an IEEE* real (binary32, binary64, and
binary128) argument. This function cannot be passed
as an actual argument.
Syntax
result = FP_CLASS (x)
1546
Language Reference
Results
The result type is INTEGER(4). The return value is one of the following:
Example
FP_CLASS (4.0_8) has the value 4 (FOR_K_FP_POS_NORM).
FPUTC
Portability Function: Writes a character to the file
specified by a Fortran external unit, bypassing normal
Fortran input/output.
Module
USE IFPORT
Syntax
result = FPUTC (lunit,char)
Results
The result type is INTEGER(4). The result is zero if the write was successful; otherwise, an error code, such
as:
EINVAL - The specified unit is invalid (either not already open, or an invalid unit number)
If you use WRITE, READ, or any other Fortran I/O statements with lunit, be sure to read Input and Output
Routines in Overview of Portability Routines.
1547
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
use IFPORT
integer*4 lunit, i4
character*26 string
character*1 char1
lunit = 1
open (lunit,file = 'fputc.dat')
do i = 1,26
char1 = char(123-i)
i4 = fputc(1,char1) !make valid writes
if (i4.ne.0) iflag = 1
enddo
rewind (1)
read (1,'(a)') string
print *, string
See Also
I/O Formatting
FRACTION
Elemental Intrinsic Function (Generic): Returns
the fractional part of the model representation of the
argument value.
Syntax
result = FRACTION (x)
Results
The result type and kind are the same as x.
The result has the value x* b e. Parameters b and e are defined in Model for Real Data.
If x has the value zero, the result has the value zero.
Example
If 3.0 is a REAL(4) value, FRACTION (3.0) has the value 0.75.
The following shows another example:
REAL result
result = FRACTION(3.0) ! returns 0.75
result = FRACTION(1024.0) ! returns 0.5
See Also
DIGITS
RADIX
EXPONENT
Data Representation Models
1548
Language Reference
FREE
Intrinsic Subroutine (Specific): Frees a block of
memory that is currently allocated. Intrinsic
subroutines cannot be passed as actual arguments.
Syntax
CALL FREE (addr)
If the freed address was not previously allocated by MALLOC, or if an address is freed more than once,
results are unpredictable.
Example
INTEGER(4) SIZE
REAL(4) STORAGE(*)
POINTER (ADDR, STORAGE) ! ADDR will point to STORAGE
SIZE = 1024 ! Size in bytes
ADDR = MALLOC(SIZE) ! Allocate the memory
CALL FREE(ADDR) ! Free it
Syntax
!DIR$ FREEFORM
!DIR$ NOFREEFORM
When the FREEFORM or NOFREEFORM directives are used, they remain in effect for the remainder of the
source or include file in which the directive appears, or until the opposite directive is used. When in effect,
they apply to include files, but do not affect USE modules, which are compiled separately.
source or include file in which the directive appears
Example
Consider the following:
1549
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
ENDDO
ENDDO
!DIR$ NOFREEFORM ! and now back to fixed form
END SUBROUTINE F
See Also
Source Forms
General Compiler Directives
Syntax Rules for Compiler Directives
free compiler option
Equivalent Compiler Options
FSEEK
Portability Function: Repositions a file specified by a
Fortran external unit.
Module
USE IFPORT
Syntax
result = FSEEK (lunit,offset,from)
Results
The result type is INTEGER(4). The result is zero if the repositioning was successful; otherwise, an error
code, such as:
EINVAL: The specified unit is invalid because either the unit is not already open, an invalid unit number was
specified, or the from parameter is invalid.
The file specified in lunit must be open.
1550
Language Reference
Example
USE IFPORT
integer(4) istat, offset, ipos
character ichar
OPEN (unit=1,file='datfile.dat')
offset = 5
ipos = 0
istat=fseek(1,offset,ipos)
if (.NOT. stat) then
istat=fgetc(1,ichar)
print *, 'data is ',ichar
end if
FSTAT
Portability Function: Returns detailed information
about a file specified by a external unit number.
Module
USE IFPORT
Syntax
result = FSTAT (lunit,statb)
1551
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type is INTEGER(4). The result is zero if successful; otherwise, returns an error code equal to
EINVAL (lunit is not a valid unit number, or is not open).
The access mode (the third element of statb) is a bitmap consisting of an IOR of the following constants:
1552
Language Reference
STAT returns the same information as FSTAT, but accesses files by name instead of external unit number.
Example
USE IFPORT
integer(4) statarray(12), istat
OPEN (unit=1,file='datfile.dat')
ISTAT = FSTAT (1, statarray)
if (.NOT. istat) then
print *, statarray
end if
1553
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
INQUIRE
STAT
FTELL, FTELLI8
Portability Functions: Return the current position of
a file.
Module
USE IFPORT
Syntax
result = FTELL (lunit)
result = FTELLI8 (lunit)
Results
The result type is INTEGER(4) for FTELL; INTEGER(8) for FTELLI8. The result is the offset, in bytes, from the
beginning of the file. A negative value indicates an error, which is the negation of the IERRNO error code. The
following is an example of an error code:
EINVAL: lunit is not a valid unit number, or is not open.
FULLPATHQQ
Portability Function: Returns the full path for a
specified file or directory.
Module
USE IFPORT
Syntax
result = FULLPATHQQ (name,pathbuf)
name (Input) Character*(*). Item for which you want the full path. Can be
the name of a file in the current directory, a relative directory or file
name, or a network uniform naming convention (UNC) path.
Results
The result type is INTEGER(4). The result is the length of the full path in bytes, or 0 if the function fails. This
function does not verify that the resulting path and file name are valid nor that they exist.
The length of the full path depends upon how deeply the directories are nested on the drive you are using. If
the full path is longer than the character buffer provided to return it ( pathbuf), FULLPATHQQ returns only
that portion of the path that fits into the buffer.
1554
Language Reference
Check the length of the path before using the string returned in pathbuf. If the longest full path you are likely
to encounter does not fit into the buffer you are using, allocate a larger character buffer. You can allocate the
largest possible path buffer with the following statements:
USE IFPORT
CHARACTER($MAXPATH) pathbuf
$MAXPATH is a symbolic constant defined in IFPORT.F90 as 260.
Example
USE IFPORT
USE IFCORE
CHARACTER($MAXPATH) buf
CHARACTER(3) drive
CHARACTER(256) dir
CHARACTER(256) name
CHARACTER(256) ext
CHARACTER(256) file
INTEGER(4) len
DO WHILE (.TRUE.)
WRITE (*,*)
WRITE (*,'(A, \)') ' Enter filename (Hit &
RETURN to exit): '
len = GETSTRQQ(file)
IF (len .EQ. 0) EXIT
len = FULLPATHQQ(file, buf)
IF (len .GT. 0) THEN
WRITE (*,*) buf(:len)
ELSE
WRITE (*,*) 'Can''t get full path'
EXIT
END IF
!
! Split path
WRITE (*,*)
len = SPLITPATHQQ(buf, drive, dir, name, ext)
IF (len .NE. 0) THEN
WRITE (*, 900) ' Drive: ', drive
WRITE (*, 900) ' Directory: ', dir(1:len)
WRITE (*, 900) ' Name: ', name
WRITE (*, 900) ' Extension: ', ext
ELSE
WRITE (*, *) 'Can''t split path'
END IF
END DO
900 FORMAT (A, A)
END
See Also
SPLITPATHQQ
FUNCTION
Statement: The initial statement of a function
subprogram. A function subprogram is invoked in an
expression and returns a single value (a function
result) that is used to evaluate the expression.
1555
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
[prefix [prefix]] FUNCTION name [([d-arg-list])] [suffix]
[specification-part]
[execution-part]
[CONTAINS
[internal-subprogram-part]]
END [FUNCTION [name]]
name Is the name of the function. If RESULT is specified, the function name
must not appear in any specification statement in the scoping unit of
the function subprogram.
The function name can be followed by the length of the data type. The
length is specified by an asterisk (*) followed by any unsigned,
nonzero integer that is a valid length for the function's type. For
example, REAL FUNCTION LGFUNC*8 (Y, Z) specifies the function
result as REAL(8) (or REAL*8).
This optional length specification is not permitted if the length has
already been specified following the keyword CHARACTER.
1556
Language Reference
FUNCTION F
Description
The type and kind parameters (if any) of the function's result can be defined in the FUNCTION statement or
in a type declaration statement within the function subprogram, but not both. If no type is specified, the type
is determined by implicit typing rules in effect for the function subprogram.
Execution begins with the first executable construct or statement following the FUNCTION statement. Control
returns to the calling program unit once the END statement (or a RETURN statement) is executed.
If you specify CHARACTER(LEN=*) as the type of the function, the function assumes the length declared for
it in the program unit that invokes it. This type of the resulting character function can have different lengths
when it is invoked by different program units. An assumed-length character function cannot be directly
recursive.
If the character length is specified as an integer constant, the value must agree with the length of the
function specified in the program unit that invokes the function. If no length is specified, a length of 1 is
assumed.
If the function is array-valued or a pointer, the declarations within the function must state these attributes for
the function result name. The specification of the function result attributes, dummy argument attributes, and
the information in the procedure heading collectively define the interface of the function.
The value of the result variable is returned by the function when it completes execution. Certain rules apply
depending on whether the result is a pointer, as follows:
• If the result is a pointer, its allocation status must be determined before the function completes execution.
The function must associate a target with the pointer, or cause the pointer to be explicitly disassociated
from a target.
1557
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If the pointer result points to a TARGET with the INTENT(IN) attribute, the function can give the result a
value but the caller is not allowed to change the value pointed to.
• The shape of the value returned by the function is determined by the shape of the result variable when
the function completes execution.
• If the result is not a pointer, its value must be defined before the function completes execution. If the
result is an array, all the elements must be defined. If the result is a derived-type structure, all the
components must be defined.
A function subprogram cannot contain a BLOCK DATA statement, a PROGRAM statement, a MODULE
statement, or a SUBMODULE statement. A function can contain SUBROUTINE and FUNCTION statements to
define internal procedures. ENTRY statements can be included to provide multiple entry points to the
subprogram.
Example
The following example uses the Newton-Raphson iteration method (F(X) = cosh(X) + cos(X) - A = 0)
to get the root of the function:
FUNCTION ROOT(A)
X = 1.0
DO
EX = EXP(X)
EMINX = 1./EX
ROOT = X - ((EX+EMINX)*.5+COS(X)-A)/((EX-EMINX)*.5-SIN(X))
IF (ABS((X-ROOT)/ROOT) .LT. 1E-6) RETURN
X = ROOT
END DO
END
In the preceding example, the following formula is calculated repeatedly until the difference between Xi and
Xi+1 is less than 1.0E-6:
1558
Language Reference
Another program unit within the executable program can specify a different length. For example, the
following REDO function has a length of 2:
INTEGER Divby2
10 PRINT *, 'Enter a number'
READ *, i
Print *, Divby2(i)
GOTO 10
END
C
C This is the function definition
C
INTEGER FUNCTION Divby2 (num)
Divby2=num / 2
END FUNCTION
The following example shows an allocatable function with allocatable arguments:
MODULE AP
CONTAINS
FUNCTION ADD_VEC(P1,P2)
! Function to add two allocatable arrays of possibly differing lengths.
! The arrays may be thought of as polynomials (coefficients)
REAL, ALLOCATABLE :: ADD_VEC(:), P1(:), P2(:)
PROGRAM TEST
USE AP
REAL, ALLOCATABLE :: P(:), Q(:), R(:), S(:)
ALLOCATE(P(3))
ALLOCATE(Q(2))
ALLOCATE(R(3))
ALLOCATE(S(3))
1559
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
P = (/1,1,1/) ! P = X**2 + X + 1
R = (/2,2,2/) ! R = 2X**2 + 2X + 2
S = (/3,3,3/) ! S = 3X**2 + 3X + 3
PRINT *,' Result should be: 6.000000 6.000000 6.000000'
PRINT *,' Coefficients are: ', ADD_VEC(ADD_VEC(P,R), S)
END
Consider the following example:
module mymodule
type :: vec
integer :: x(3)
contains
procedure :: at
end type vec
contains
function at( this, i ) result( p )
implicit none
class(vec), intent(in), target :: this
integer, intent(in) :: i
integer, pointer :: p
p => this%x(i)
end function at
end module mymodule
program test
use mymodule
implicit none
type(vec) :: myvec
myvec%x = [1,2,3]
1560
Language Reference
G
This section describes language features that start with G.
GAMMA
Elemental Intrinsic Function (Generic): Returns
the gamma value of its argument.
Syntax
result = GAMMA (x)
Results
The result type and kind are the same as x.
The result has a value equal to a processor-dependent approximation to the gamma function of x,
Example
GAMMA (1.0) has the approximate value 1.000.
GENERIC
Statement: Declares a generic interface that is bound
to a derived type-bound procedure, or specifies a
generic identifier for one or more specific procedures.
Syntax
The GENERIC statement takes the following form:
GENERIC [, access-spec]:: generic-spec => binding-name1 [, binding-name2]...
1561
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Examples
Consider the following:
TYPE MY_TYPE2
...
CONTAINS
PROCEDURE :: MYPROC => MYPROC1
PROCEDURE,PASS(C) :: UPROC => UPROC1
GENERIC :: OPERATOR(+) => MYPROC, UPROC
END TYPE MY_TYPE2
...
TYPE,EXTENDS(MY_TYPE2) :: MY_TYPE3
...
CONTAINS
PROCEDURE :: MYPROC => MYPROC2
PROCEDURE,PASS(C) :: UPROC => UPROC2
END TYPE MY_TYPE3
The type MY_TYPE3 inherits the generic operator '+'. Invoking the generic (+) invokes the specific type-
bound procedure. For entities of type MY_TYPE3, that invokes the overriding actual procedure (MYPROC2 or
UPROC2).
See Also
Type-Bound Procedures
Defining Generic Names for Procedures
GERROR
Run-Time Subroutine: Returns a message for the
last error detected by a Fortran run-time routine.
Module
USE IFCORE
1562
Language Reference
Syntax
CALL GERROR (string)
The last detected error does not necessarily correspond to the most recent function call. The compiler resets
string only when another error occurs.
Example
USE IFCORE
character*40 errtext
character char1
integer*4 iflag, i4
. . .!Open unit 1 here
i4=fgetc(1,char1)
if (i4) then
iflag = 1
Call GERROR (errtext)
print *, errtext
end if
See Also
PERROR
IERRNO
GETACTIVEQQ (W*S)
QuickWin Function: Returns the unit number of the
currently active child window.
Module
USE IFQWIN
Syntax
result = GETACTIVEQQ( )
Results
The result type is INTEGER(4). The result is the unit number of the currently active window. If no child
window is active, it returns the parameter QWIN$NOACTIVEWINDOW (defined in IFQWIN.F90).
See Also
SETACTIVEQQ
GETHWNDQQ
GETARCINFO (W*S)
Graphics Function: Determines the endpoints (in
viewport coordinates) of the most recently drawn arc
or pie.
Module
USE IFQWIN
1563
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
result = GETARCINFO (lpstart, lpend, lppaint)
lpend (Output) Derived type xycoord. Viewport coordinates of the end point
of the arc.
Results
The result type is INTEGER(2). The result is nonzero if successful. The result is zero if neither the ARC nor
the PIE function has been successfully called since the last time CLEARSCREEN or SETWINDOWCONFIG was
successfully called, or since a new viewport was selected.
GETARCINFO updates the lpstart and lpendxycoord derived types to contain the endpoints (in viewport
coordinates) of the arc drawn by the most recent call to the ARC or PIE functions. The xycoord derived type,
defined in IFQWIN.F90, is:
TYPE xycoord
INTEGER(2) xcoord
INTEGER(2) ycoord
END TYPE xycoord
The returned value in lppaint specifies a point from which a pie can be filled. You can use this to fill a pie in a
color different from the border color. After a call to GETARCINFO, change colors using SETCOLORRGB. Use
the new color, along with the coordinates in lppaint, as arguments for the FLOODFILLRGB function.
Example
USE IFQWIN
INTEGER(2) status, x1, y1, x2, y2, x3, y3, x4, y4
TYPE (xycoord) xystart, xyend, xyfillpt
x1 = 80; y1 = 50
x2 = 240; y2 = 150
x3 = 120; y3 = 80
x4 = 90; y4 = 180
status = ARC(x1, y1, x2, y2, x3, y3, x4, y4)
status = GETARCINFO(xystart, xyend, xyfillpt)
END
See Also
ARC
FLOODFILLRGB
GETCOLORRGB
GRSTATUS
PIE
SETCOLORRGB
1564
Language Reference
GETARG
Intrinsic Subroutine: Returns the specified
command-line argument (where the command itself is
argument number zero). Intrinsic subroutines cannot
be passed as actual arguments.
Syntax
CALL GETARG (n,buffer[,status])
buffer (Output) Must be a scalar of type default character. Its value is the
returned command-line argument.
GETARG returns the nth command-line argument. If n is zero, the name of the executing program file is
returned.
GETARG returns command-line arguments as they were entered. There is no case conversion.
If the command-line argument is shorter than buffer, GETARG pads buffer on the right with blanks. If the
argument is longer than buffer, GETARG truncates the argument on the right. If there is an error, GETARG
fills buffer with blanks.
Example
Assume a command-line invocation of PROG1 -g -c -a, and that buffer is at least five characters long. The
following calls to GETARG return the corresponding arguments in buffer and status:
See Also
NARGS
IARGC
COMMAND_ARGUMENT_COUNT
GET_COMMAND
1565
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
GET_COMMAND_ARGUMENT
GETBKCOLOR (W*S)
Graphics Function: Returns the current background
color index for both text and graphics output.
Module
USE IFQWIN
Syntax
result = GETBKCOLOR( )
Results
The result type is INTEGER(4). The result is the current background color index.
GETBKCOLOR returns the current background color index for both text and graphics, as set with
SETBKCOLOR. The color index of text over the background color is set with SETTEXTCOLOR and returned
with GETTEXTCOLOR. The color index of graphics over the background color is set with SETCOLOR and
returned with GETCOLOR. These non-RGB color functions use color indexes, not true color values, and limit
the user to colors in the palette, at most 256. For access to all system colors, use SETBKCOLORRGB,
SETCOLORRGB, and SETTEXTCOLORRGB.
Generally, INTEGER(4) color arguments refer to color values and INTEGER(2) color arguments refer to color
indexes. The two exceptions are GETBKCOLOR and SETBKCOLOR. The default background index is 0, which
is associated with black unless the user remaps the palette with REMAPPALETTERGB.
NOTE
The GETBKCOLOR routine described here is a QuickWin routine. If you are trying to use the
Microsoft* Platform SDK version of the GetBkColor routine by including the IFWIN module,
you need to specify the routine name as MSFWIN$GetBkColor.
Example
USE IFQWIN
INTEGER(4) bcindex
bcindex = GETBKCOLOR()
See Also
GETBKCOLORRGB
SETBKCOLOR
GETCOLOR
GETTEXTCOLOR
REMAPALLPALETTERGB, REMAPPALETTERGB
GETBKCOLORRGB (W*S)
Graphics Function: Returns the current background
Red-Green-Blue (RGB) color value for both text and
graphics.
Module
USE IFQWIN
1566
Language Reference
Syntax
result = GETBKCOLORRGB( )
Results
The result type is INTEGER(4). The result is the RGB value of the current background color for both text and
graphics.
In each RGB color value, each of the three colors, red, green, and blue, is represented by an eight-bit value
(2 hex digits). In the value you retrieve with GETBKCOLORRGB, red is the rightmost byte, followed by green
and blue. The RGB value's internal structure is as follows:
Larger numbers correspond to stronger color intensity with binary 1111111 (hex FF) the maximum for each
of the three components. For example, Z'0000FF' yields full-intensity red, Z'00FF00' full-intensity green,
Z'FF0000' full-intensity blue, and Z'FFFFFF' full-intensity for all three, resulting in bright white.
GETBKCOLORRGB returns the RGB color value of the current background for both text and graphics, set with
SETBKCOLORRGB. The RGB color value of text over the background color (used by text functions such as
OUTTEXT, WRITE, and PRINT) is set with SETTEXTCOLORRGB and returned with GETTEXTCOLORRGB. The
RGB color value of graphics over the background color (used by graphics functions such as ARC, OUTGTEXT,
and FLOODFILLRGB) is set with SETCOLORRGB and returned with GETCOLORRGB.
SETBKCOLORRGB (and the other RGB color selection functions SETCOLORRGB and SETTEXTCOLORRGB) sets
the color to a value chosen from the entire available range. The non-RGB color functions (SETBKCOLOR,
SETCOLOR, and SETTEXTCOLOR) use color indexes rather than true color values. If you use color indexes,
you are restricted to the colors available in the palette, at most 256. Some display adapters (SVGA and true
color) are capable of creating 262,144 (256K) colors or more. To access any available color, you need to
specify an explicit RGB value with an RGB color function, rather than a palette index with a non-RGB color
function.
Example
! Build as a QuickWin or Standard Graphics App.
USE IFQWIN
INTEGER(4) back, fore, oldcolor
INTEGER(2) status, x1, y1, x2, y2
x1 = 80; y1 = 50
x2 = 240; y2 = 150
oldcolor = SETCOLORRGB(Z'FF') ! red
! reverse the screen
back = GETBKCOLORRGB()
fore = GETCOLORRGB()
oldcolor = SETBKCOLORRGB(fore)
oldcolor = SETCOLORRGB(back)
CALL CLEARSCREEN ($GCLEARSCREEN)
status = ELLIPSE($GBORDER, x1, y1, x2, y2)
END
See Also
GETCOLORRGB
GETTEXTCOLORRGB
SETBKCOLORRGB
GETBKCOLOR
1567
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
GETC
Portability Function: Reads the next available
character from external unit 5, which is normally
connected to the console.
Module
USE IFPORT
Syntax
result = GETC (char)
Results
The result type is INTEGER(4). The result is zero if successful, or -1 if an end-of-file was detected.
Example
use IFPORT
character ans,errtxt*40
print *, 'Enter a character: '
ISTAT = GETC (ans)
if (istat) then
call gerror(errtxt)
end if
See Also
GETCHARQQ
GETSTRQQ
GETCHARQQ
Run-Time Function: Returns the next keystroke.
Module
USE IFCORE
Syntax
result = GETCHARQQ( )
Results
The result type is character with length 1. The result is the character representing the key that was pressed.
The value can be any ASCII character.
If the key pressed is represented by a single ASCII character, GETCHARQQ returns the character. If the key
pressed is a function or direction key, a hex Z'00' or Z'E0' is returned. If you need to know which function or
direction was pressed, call GETCHARQQ a second time to get the extended code for the key.
1568
Language Reference
If there is no keystroke waiting in the keyboard buffer, GETCHARQQ waits until there is one, and then returns
it. Compare this to the function PEEKCHARQQ, which returns .TRUE. if there is a character waiting in the
keyboard buffer, and .FALSE. if not. You can use PEEKCHARQQ to determine if GETCHARQQ should be called.
This can prevent a program from hanging while GETCHARQQ waits for a keystroke that isn't there. Note that
PEEKCHARQQ is only supported in console applications.
If your application is a QuickWin or Standard Graphics application, you may want to put a call to
PASSDIRKEYSQQ in your program. This will enable the program to get characters that would otherwise be
trapped. These extra characters are described in PASSDIRKEYSQQ.
Note that the GETCHARQQ routine used in a console application is a different routine than the one used in a
QuickWin or Standard Graphics application. The GETCHARQQ used with a console application does not trap
characters that are used in QuickWin for a special purpose, such as scrolling. Console applications do not
need, and cannot use PASSDIRKEYSQQ.
Example
! Program to demonstrate GETCHARQQ
USE IFCORE
CHARACTER(1) key / 'A' /
PARAMETER (ESC = 27)
PARAMETER (NOREP = 0)
WRITE (*,*) ' Type a key: (or q to quit)'
! Read keys until ESC or q is pressed
DO WHILE (ICHAR (key) .NE. ESC)
key = GETCHARQQ()
! Some extended keys have no ASCII representation
IF(ICHAR(key) .EQ. NOREP) THEN
key = GETCHARQQ()
WRITE (*, 900) 'Not ASCII. Char = NA'
WRITE (*,*)
! Otherwise, there is only one key
ELSE
WRITE (*,900) 'ASCII. Char = '
WRITE (*,901) key
END IF
IF (key .EQ. 'q' ) THEN
EXIT
END IF
END DO
900 FORMAT (1X, A, \)
901 FORMAT (A)
END
See Also
PEEKCHARQQ
GETSTRQQ
INCHARQQ
MBINCHARQQ
GETC
FGETC
PASSDIRKEYSQQ
GETCOLOR (W*S)
Graphics Function: Returns the current graphics
color index.
1569
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Module
USE IFQWIN
Syntax
result = GETCOLOR( )
Results
The result type is INTEGER(2). The result is the current color index, if successful; otherwise, -1.
GETCOLOR returns the current color index used for graphics over the background color as set with
SETCOLOR. The background color index is set with SETBKCOLOR and returned with GETBKCOLOR. The color
index of text over the background color is set with SETTEXTCOLOR and returned with GETTEXTCOLOR. These
non-RGB color functions use color indexes, not true color values, and limit the user to colors in the palette, at
most 256. For access to all system colors, use SETCOLORRGB, SETBKCOLORRGB, and SETTEXTCOLORRGB.
Example
! Program to demonstrate GETCOLOR
PROGRAM COLORS
USE IFQWIN
INTEGER(2) loop, loop1, status, color
LOGICAL(4) winstat
REAL rnd1, rnd2, xnum, ynum
type (windowconfig) wc
status = SETCOLOR(INT2(0))
! Color random pixels with 15 different colors
DO loop1 = 1, 15
color = INT2(MOD(GETCOLOR() +1, 16))
status = SETCOLOR (color) ! Set to next color
DO loop = 1, 75
! Set color of random spot, normalized to be on screen
CALL RANDOM(rnd1)
CALL RANDOM(rnd2)
winstat = GETWINDOWCONFIG(wc)
xnum = wc%numxpixels
ynum = wc%numypixels
status = &
SETPIXEL(INT2(rnd1*xnum+1),INT2(rnd2*ynum))
status = &
SETPIXEL(INT2(rnd1*xnum),INT2(rnd2*ynum+1))
status = &
SETPIXEL(INT2(rnd1*xnum-1),INT2( rnd2*ynum))
status = &
SETPIXEL(INT2(rnd1*xnum),INT2( rnd2*ynum-1))
END DO
END DO
END
See Also
GETCOLORRGB
GETBKCOLOR
GETTEXTCOLOR
SETCOLOR
1570
Language Reference
GETCOLORRGB (W*S)
Graphics Function: Returns the current graphics
color Red-Green-Blue (RGB) value (used by graphics
functions such as ARC, ELLIPSE, and FLOODFILLRGB).
Module
USE IFQWIN
Syntax
result = GETCOLORRGB( )
Results
The result type is INTEGER(4). The result is the RGB value of the current graphics color.
In each RGB color value, each of the three colors, red, green, and blue, is represented by an eight-bit value
(2 hex digits). In the value you retrieve with GETCOLORRGB, red is the rightmost byte, followed by green
and blue. The RGB value's internal structure is as follows:
Larger numbers correspond to stronger color intensity with binary 1111111 (hex FF) the maximum for each
of the three components. For example, Z'0000FF' yields full-intensity red, Z'00FF00' full-intensity green,
Z'FF0000' full-intensity blue, and Z'FFFFFF' full-intensity for all three, resulting in bright white.
GETCOLORRGB returns the RGB color value of graphics over the background color (used by graphics
functions such as ARC, ELLIPSE, and FLOODFILLRGB), set with SETCOLORRGB. GETBKCOLORRGB returns
the RGB color value of the current background for both text and graphics, set with SETBKCOLORRGB.
GETTEXTCOLORRGB returns the RGB color value of text over the background color (used by text functions
such as OUTTEXT, WRITE, and PRINT), set with SETTEXTCOLORRGB.
SETCOLORRGB (and the other RGB color selection functions SETBKCOLORRGB and SETTEXTCOLORRGB) sets
the color to a value chosen from the entire available range. The non-RGB color functions (SETCOLOR,
SETBKCOLOR, and SETTEXTCOLOR) use color indexes rather than true color values. If you use color indexes,
you are restricted to the colors available in the palette, at most 256. Some display adapters (SVGA and true
color) are capable of creating 262,144 (256K) colors or more. To access any available color, you need to
specify an explicit RGB value with an RGB color function, rather than a palette index with a non-RGB color
function.
Example
! Build as a QuickWin or Standard Graphics App.
USE IFQWIN
INTEGER(2) numfonts
INTEGER(4) fore, oldcolor
numfonts = INITIALIZEFONTS ( )
oldcolor = SETCOLORRGB(Z'FF') ! set graphics
! color to red
fore = GETCOLORRGB()
oldcolor = SETBKCOLORRGB(fore) ! set background
! to graphics color
CALL CLEARSCREEN($GCLEARSCREEN)
oldcolor = SETCOLORRGB (Z'FF0000') ! set graphics
1571
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
! color to blue
CALL OUTGTEXT("hello, world")
END
See Also
GETBKCOLORRGB
GETTEXTCOLORRGB
SETCOLORRGB
GETCOLOR
GET_COMMAND
Intrinsic Subroutine: Returns the entire command
that was used to invoke the program.
Syntax
CALL GET_COMMAND ([command, length, status, errmsg])
Example
See the example in COMMAND_ARGUMENT_COUNT.
See Also
GETARG
NARGS
IARGC
COMMAND_ARGUMENT_COUNT
GET_COMMAND_ARGUMENT
1572
Language Reference
GET_COMMAND_ARGUMENT
Intrinsic Subroutine: Returns a command line
argument of the command that invoked the program.
Intrinsic subroutines cannot be passed as actual
arguments.
Syntax
CALL GET_COMMAND_ARGUMENT (number [, value, length, status, errmsg])
Example
See the example in COMMAND_ARGUMENT_COUNT.
See Also
GETARG
NARGS
IARGC
COMMAND_ARGUMENT_COUNT
GET_COMMAND
GETCONTROLFPQQ
Portability Subroutine: Returns the floating-point
processor control word.
1573
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Module
USE IFPORT
Syntax
CALL GETCONTROLFPQQ (controlword)
1574
Language Reference
An exception is disabled if its control bit is set to 1. An exception is enabled if its control bit is cleared to 0.
Exceptions can be disabled by setting the control bits to 1 with SETCONTROLFPQQ.
If an exception is disabled, it does not cause an interrupt when it occurs. Instead, floating-point processes
generate an appropriate special value (NaN or signed infinity), but the program continues.
You can find out which exceptions (if any) occurred by calling GETSTATUSFPQQ. If errors on floating-point
exceptions are enabled (by clearing the control bits to 0 with SETCONTROLFPQQ), the operating system
generates an interrupt when the exception occurs. By default, these interrupts cause run-time errors, but
you can capture the interrupts with SIGNALQQ and branch to your own error-handling routines.
You can use GETCONTROLFPQQ to retrieve the current control word and SETCONTROLFPQQ to change the
control word. Most users do not need to change the default settings.
Example
USE IFPORT
INTEGER(2) control
CALL GETCONTROLFPQQ (control)
! if not rounding down
IF (IAND(control, FPCW$DOWN) .NE. FPCW$DOWN) THEN
control = IAND(control, NOT(FPCW$MCW_RC)) ! clear all
! rounding
control = IOR(control, FPCW$DOWN) ! set to
! round down
CALL SETCONTROLFPQQ(control)
END IF
END
See Also
SETCONTROLFPQQ
GETSTATUSFPQQ
SIGNALQQ
CLEARSTATUSFPQQ
Module
USE IFQWIN
Syntax
CALL GETCURRENTPOSITION (s)
CALL GETCURRENTPOSITION_W (s)
1575
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
TYPE xycoord
INTEGER(2) xcoord ! x-coordinate
INTEGER(2) ycoord ! y-coordinate
END TYPE xycoord
LINETO, MOVETO, and OUTGTEXT all change the current graphics position. It is in the center of the screen
when a window is created.
Graphics output starts at the current graphics position returned by GETCURRENTPOSITION or
GETCURRENTPOSITION_W. This position is not related to normal text output (from OUTTEXT or WRITE, for
example), which begins at the current text position (see SETTEXTPOSITION). It does, however, affect
graphics text output from OUTGTEXT.
Example
! Program to demonstrate GETCURRENTPOSITION
USE IFQWIN
TYPE (xycoord) position
INTEGER(2) result
result = LINETO(INT2(300), INT2(200))
CALL GETCURRENTPOSITION( position )
IF (position%xcoord .GT. 50) THEN
CALL MOVETO(INT2(50), position%ycoord, position)
WRITE(*,*) "Text unaffected by graphics position"
END IF
result = LINETO(INT2(300), INT2(200))
END
See Also
LINETO
MOVETO
OUTGTEXT
SETTEXTPOSITION
GETTEXTPOSITION
GETCWD
Portability Function: Returns the path of the current
working directory.
Module
USE IFPORT
Syntax
result = GETCWD (dirname)
dirname (Output) Character *(*). Name of the current working directory path,
including drive letter.
Results
The result type is INTEGER(4). The result is zero if successful; otherwise, an error code.
1576
Language Reference
Example
USE IFPORT
character*30 dirname
! variable dirname must be long enough to hold entire string
integer(4) istat
ISTAT = GETCWD (dirname)
IF (ISTAT == 0) write *, 'Current directory is ',dirname
See Also
GETDRIVEDIRQQ
GETDAT
Portability Subroutine: Returns the date.
Module
USE IFPORT
Syntax
CALL GETDAT (iyr, imon, iday)
All arguments must be of the same integer kind, that is, all must be INTEGER(2) or all must be INTEGER(4).
If INTEGER(2) arguments are passed, you must specify USE IFPORT.
Example
! Program to demonstrate GETDAT and GETTIM
USE IFPORT
INTEGER(4) tmpday, tmpmonth, tmpyear
INTEGER(4) tmphour, tmpminute, tmpsecond, tmphund
CHARACTER(1) mer
CALL GETDAT(tmpyear, tmpmonth, tmpday)
CALL GETTIM(tmphour, tmpminute, tmpsecond, tmphund)
IF (tmphour .GT. 12) THEN
mer = 'p'
tmphour = tmphour - 12
ELSE
mer = 'a'
END IF
WRITE (*, 900) tmpmonth, tmpday, tmpyear
900 FORMAT(I2, '/', I2.2, '/', I4.4)
WRITE (*, 901) tmphour, tmpminute, tmpsecond, tmphund, mer
901 FORMAT(I2, ':', I2.2, ':', I2.2, ':', I2.2, ' ',&
A, 'm')
END
See Also
GETTIM
1577
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
SETDAT
SETTIM
FDATE
JDATE
GETDRIVEDIRQQ
Portability Function: Returns the path of the current
working directory on a specified drive.
Module
USE IFPORT
Syntax
result = GETDRIVEDIRQQ (drivedir)
Results
The result type is INTEGER(4). The result is the length (in bytes) of the full path of the directory on the
specified drive. Zero is returned if the path is longer than the size of the character buffer drivedir.
You specify the drive from which to return the current working directory by putting the drive letter into
drivedir before calling GETDRIVEDIRQQ. To make sure you get information about the current drive, put the
symbolic constant FILE$CURDRIVE (defined in IFPORT.F90) into drivedir.
Because drives are identified by a single alphabetic character, GETDRIVEDIRQQ examines only the first letter
of drivedir. For instance, if drivedir contains the path c:\fps90\bin, GETDRIVEDIRQQ ( drivedir) returns the
current working directory on drive C and disregards the rest of the path. The drive letter can be uppercase or
lowercase.
The length of the path returned depends on how deeply the directories are nested on the drive specified in
drivedir. If the full path is longer than the length of drivedir, GETDRIVEDIRQQ returns only the portion of the
path that fits into drivedir. If you are likely to encounter a long path, allocate a buffer of size $MAXPATH
($MAXPATH = 260).
On Linux* and macOS* systems, the function gets a path only when symbolic constant FILE$CURDRIVE has
been applied to drivedir.
Example
! Program to demonstrate GETDRIVEDIRQQ
USE IFPORT
CHARACTER($MAXPATH) dir
INTEGER(4) length
! Get current directory
dir = FILE$CURDRIVE
1578
Language Reference
length = GETDRIVEDIRQQ(dir)
IF (length .GT. 0) THEN
WRITE (*,*) 'Current directory is: '
WRITE (*,*) dir
ELSE
WRITE (*,*) 'Failed to get current directory'
END IF
END
See Also
CHANGEDRIVEQQ
CHANGEDIRQQ
GETDRIVESIZEQQ
GETDRIVESQQ
GETLASTERRORQQ
SPLITPATHQQ
GETDRIVESIZEQQ
Portability Function: Returns the total size of the
specified drive and space available on it.
Module
USE IFPORT
Syntax
result = GETDRIVESIZEQQ (drive,total,avail)
drive (Input) Character*(*). String containing the letter of the drive to get
information about.
Results
The result type is LOGICAL(4). The result is .TRUE. if successful; otherwise, .FALSE..
The data types and dimension (if any) specified for the total and avail arguments must be the same.
Specifying an array of two INTEGER(4) elements, or an INTEGER(8) argument, allows drive sizes larger than
2147483647 to be returned.
If an array of two INTEGER(4) elements is specified, the least-significant 32 bits are returned in the first
element, the most-significant 32 bits in the second element. If an INTEGER(4) scalar is specified, the least-
significant 32 bits are returned.
Because drives are identified by a single alphabetic character, GETDRIVESIZEQQ examines only the first
letter of drive. The drive letter can be uppercase or lowercase. You can use the constant FILE$CURDRIVE
(defined in IFPORT.F90) to get the size of the current drive.
1579
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
! Program to demonstrate GETDRIVESQQ and GETDRIVESIZEQQ
USE IFPORT
CHARACTER(26) drives
CHARACTER(1) adrive
LOGICAL(4) status
INTEGER(4) total, avail
INTEGER(2) i
! Get the list of drives
drives = GETDRIVESQQ()
WRITE (*,'(A, A)') ' Drives available: ', drives
!
!Cycle through them for free space and write to console
DO i = 1, 26
adrive = drives(i:i)
status = .FALSE.
WRITE (*,'(A, A, A, \)') ' Drive ', CHAR(i + 64), ':'
IF (adrive .NE. ' ') THEN
status = GETDRIVESIZEQQ(adrive, total, avail)
END IF
IF (status) THEN
WRITE (*,*) avail, ' of ', total, ' bytes free.'
ELSE
WRITE (*,*) 'Not available'
END IF
END DO
END
See Also
GETLASTERRORQQ
GETDRIVESQQ
GETDRIVEDIRQQ
CHANGEDRIVEQQ
CHANGEDIRQQ
GETDRIVESQQ
Portability Function: Reports which drives are
available to the system.
Module
USE IFPORT
Syntax
result = GETDRIVESQQ( )
Results
The result type is character with length 26. It is the positional character string containing the letters of the
drives available in the system.
The returned string contains letters for drives that are available, and blanks for drives that are not available.
For example, on a system with A, C, and D drives, the string 'A CD' is returned.
On Linux* and macOS* systems, the function returns a string filled with spaces.
1580
Language Reference
Example
See the example for GETDRIVESIZEQQ.
See Also
GETDRIVEDIRQQ
GETDRIVESIZEQQ
CHANGEDRIVEQQ
GETENV
Portability Subroutine: Returns the value of an
environment variable.
Module
USE IFPORT
Syntax
CALL GETENV (ename,evalue)
evalue (Output) Character*(*). Value found for ename. Blank if ename is not
found.
Example
use IFPORT
character*40 libname
CALL GETENV ("LIB",libname)
TYPE *, "The LIB variable points to ",libname
See Also
GETENVQQ
GET_ENVIRONMENT_VARIABLE
Intrinsic Subroutine: Gets the value of an
environment variable.
Syntax
CALL GET_ENVIRONMENT_VARIABLE (name [, value, length, status, trim_name, errmsg])
1581
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
The following program asks for the name of an environment variable. If the environment variable exists in
the program's environment, it prints out its value:
program print_env_var
character name*20, val*40
integer len, status
write (*,*) 'enter the name of the environment variable'
read (*,*) name
call get_environment_variable (name, val, len, status, .true.)
if (status .ge. 2) then
write (*,*) 'get_environment_variable failed: status = ', status
stop
end if
if (status .eq. 1) then
write (*,*) 'env var does not exist'
stop
end if
if (status .eq. -1) then
write (*,*) 'env var length = ', len, ' truncated to 40'
len = 40
end if
if (len .eq. 0) then
write (*,*) 'env var exists but has no value'
stop
end if
write (*,*) 'env var value = ', val (1:len)
end
When the above program is invoked, the following line is displayed:
1582
Language Reference
• On a Windows* system:
GETENVQQ
Portability Function: Returns the value of an
environment variable.
Module
USE IFPORT
Syntax
result = GETENVQQ (varname,value)
Results
The result type is INTEGER(4). The result is the length of the string returned in value. Zero is returned if the
given variable is not defined.
GETENVQQ searches the list of environment variables for an entry corresponding to varname. Environment
variables define the environment in which a process executes. For example, the LIB environment variable
defines the default search path for libraries to be linked with a program.
Note that some environment variables may exist only on a per-process basis and may not be present at the
command-line level.
GETENVQQ uses the C runtime routine getenv and SETENVQQ uses the C runtime routine _putenv. From the
C documentation:
getenv and _putenv use the copy of the environment pointed to by the global variable _environ to access the
environment. getenv operates only on the data structures accessible to the run-time library and not on the
environment segment created for the process by the operating system.
In a program that uses the main function, _environ is initialized at program startup to settings taken from
the operating system's environment.
Changes made outside the program by the console SET command, for example, SET MY_VAR=ABCDE, will be
reflected by GETENVQQ.
GETENVQQ and SETENVQQ will not work properly with the Windows* APIs GetEnvironmentVariable and
SetEnvironmentVariable.
1583
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
See Also
SETENVQQ
GETLASTERRORQQ
GETEXCEPTIONPTRSQQ (W*S)
Run-Time Function: Returns a pointer to C run-time
exception information pointers appropriate for use in
signal handlers established with SIGNALQQ or direct
calls to the C rtl signal( ) routine.
Module
USE IFCORE
Syntax
result = GETEXCEPTIONPTRSQQ( )
Results
The result type is INTEGER(4) on IA-32 architecture; INTEGER(8) on Intel® 64 architecture. The return value
is the address of a data structure whose members are pointers to exception information captured by the C
runtime at the time of an exception. This result value can then be used as the eptr argument to routine
TRACEBACKQQ to generate a stack trace from a user-defined handler or to inspect the exception context
record directly.
1584
Language Reference
Calling GETEXCEPTIONPTRSQQ is only valid within a user-defined handler that was established with
SIGNALQQ or a direct call to the C rtl signal( ) function.
For a full description of exceptions and error handling, see Compiler Reference: Error Handling.
Example
PROGRAM SIGTEST
USE IFCORE
...
R3 = 0.0E0
STS = SIGNALQQ(MY_HANDLER)
! Cause a divide by zero exception
R1 = 3.0E0/R3
...
END
INTEGER(4) FUNCTION MY_HANDLER(SIGNUM,EXCNUM)
USE IFCORE
...
EPTRS = GETEXCEPTIONPTRSQQ()
...
CALL TRACEBACKQQ("Application SIGFPE error!",USER_EXIT_CODE=-1,EPTR=EPTRS)
...
MY_HANDLER = 1
END
See Also
TRACEBACKQQ
GETSTATUSFPQQ
CLEARSTATUSFPQQ
SETCONTROLFPQQ
GETCONTROLFPQQ
SIGNALQQ
GETEXITQQ (W*S)
QuickWin Function: Returns the setting for a
QuickWin application's exit behavior.
Module
USE IFQWIN
Syntax
result = GETEXITQQ( )
Results
The result type is INTEGER(4). The result is exit mode with one of the following constants (defined in
IFQWIN.F90):
• QWIN$EXITPROMPT - Displays a message box that reads "Program exited with exit status n. Exit
Window?", where n is the exit status from the program.
If you choose Yes, the application closes the window and terminates. If you choose No, the dialog box
disappears and you can manipulate the window as usual. You must then close the window manually.
• QWIN$EXITNOPERSIST - Terminates the application without displaying a message box.
• QWIN$EXITPERSIST - Leaves the application open without displaying a message box.
The default for both QuickWin and Console Graphics applications is QWIN$EXITPROMPT.
1585
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
! Program to demonstrate GETEXITQQ
USE IFQWIN
INTEGER i
i = GETEXITQQ()
SELECT CASE (i)
CASE (QWIN$EXITPROMPT)
WRITE(*, *) "Prompt on exit."
CASE (QWIN$EXITNOPERSIST)
WRITE(*,*) "Exit and close."
CASE (QWIN$EXITPERSIST)
WRITE(*,*) "Exit and leave open."
END SELECT
END
See Also
SETEXITQQ
GETFILEINFOQQ
Portability Function: Returns information about the
specified file. File names can contain wildcards (*
and ?).
Module
USE IFPORT
Syntax
result = GETFILEINFOQQ (files,buffer,handle)
files (Input) Character*(*). Name or pattern of files you are searching for.
Can include a full path and wildcards (* and ?).
TYPE FILE$INFO
INTEGER(4) CREATION ! CREATION TIME (-1 on FAT)
INTEGER(4) LASTWRITE ! LAST WRITE TO FILE
INTEGER(4) LASTACCESS ! LAST ACCESS (-1 on FAT)
INTEGER(4) LENGTH ! LENGTH OF FILE
INTEGER(4) PERMIT ! FILE ACCESS MODE
CHARACTER(255) NAME ! FILE NAME
END TYPE FILE$INFO
The derived type FILE$INFOI8 is defined in IFPORT.F90 as follows:
TYPE FILE$INFOI8
INTEGER(4) CREATION ! CREATION TIME (-1 on FAT)
INTEGER(4) LASTWRITE ! LAST WRITE TO FILE
INTEGER(4) LASTACCESS ! LAST ACCESS (-1 on FAT)
INTEGER(8) LENGTH ! LENGTH OF FILE
INTEGER(4) PERMIT ! FILE ACCESS MODE
CHARACTER(255) NAME ! FILE NAME
END TYPE FILE$INFOI8
1586
Language Reference
Results
The result type is INTEGER(4). The result is the nonblank length of the file name if a match was found, or 0 if
no matching files were found.
To get information about one or more files, set the handle to FILE$FIRST and call GETFILEINFOQQ. This will
return information about the first file which matches the name and return a handle. If the program wants
more files, it should call GETFILEINFOQQ with the handle. GETFILEINFOQQ must be called with the handle
until GETFILEINFOQQ sets handle to FILE$LAST, or system resources may be lost.
The derived-type element variables FILE$INFO%CREATION, FILE$INFO%LASTWRITE, and FILE$INFO
%LASTACCESS contain packed date and time information that indicates when the file was created, last
written to, and last accessed, respectively.
To break the time and date into component parts, call UNPACKTIMEQQ. FILE$INFO%LENGTH contains the
length of the file in bytes. FILE$INFO%PERMIT contains a set of bit flags describing access information about
the file as follows:
You can use the constant FILE$NORMAL to check that all bit flags are set to 0. If the derived-type element
variable FILE$INFO%PERMIT is equal to FILE$NORMAL, the file has no special attributes. The variable FILE
$INFO%NAME contains the short name of the file, not the full path of the file.
If an error occurs, call GETLASTERRORQQ to retrieve the error message, such as:
• ERR$NOENT: The file or path specified was not found.
1587
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• ERR$NOMEM: Not enough memory is available to execute the command, the available memory has been
corrupted, or an invalid block exists, indicating that the process making the call was not allocated
properly.
Example
USE IFPORT
USE IFCORE
CALL SHOWPERMISSION( )
END
length = GETSTRQQ(files)
handle = FILE$FIRST
DO WHILE (.TRUE.)
length = GETFILEINFOQQ(files, info, handle)
IF ((handle .EQ. FILE$LAST) .OR. &
(handle .EQ. FILE$ERROR)) THEN
SELECT CASE (GETLASTERRORQQ( ))
CASE (ERR$NOMEM)
WRITE (*,*) 'Out of memory'
CASE (ERR$NOENT)
EXIT
CASE DEFAULT
WRITE (*,*) 'Invalid file or path name'
END SELECT
END IF
1588
Language Reference
GETFILLMASK (W*S)
Graphics Subroutine: Returns the current pattern
used to fill shapes.
Module
USE IFQWIN
Syntax
CALL GETFILLMASK (mask)
There are 8 bytes in mask, and each of the 8 bits in each byte represents a pixel, creating an 8x8 pattern.
The first element (byte) of mask becomes the top 8 bits of the pattern, and the eighth element (byte) of
mask becomes the bottom 8 bits.
During a fill operation, pixels with a bit value of 1 are set to the current graphics color, while pixels with a bit
value of 0 are unchanged. The current graphics color is set with SETCOLORRGB or SETCOLOR. The 8-byte
mask is replicated over the entire fill area. If no fill mask is set (with SETFILLMASK), or if the mask is all
ones, solid current color is used in fill operations.
The fill mask controls the fill pattern for graphics routines (FLOODFILLRGB, PIE, ELLIPSE, POLYGON, and
RECTANGLE).
Example
! Build as QuickWin or Standard Graphics
USE IFQWIN
INTEGER(1) style(8). array(8)
INTEGER(2) i
style = 0
style(1) = Z'F'
style(3) = Z'F'
style(5) = Z'F'
style(7) = Z'F'
CALL SETFILLMASK (style)
...
CALL GETFILLMASK (array)
WRITE (*, *) 'Fill mask in bits: '
DO i = 1, 8
WRITE (*, '(B8)') array(i)
END DO
END
See Also
ELLIPSE
FLOODFILLRGB
PIE
POLYGON
RECTANGLE
SETFILLMASK
1589
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
GETFONTINFO (W*S)
Graphics Function: Returns the current font
characteristics.
Module
USE IFQWIN
Syntax
result = GETFONTINFO (font)
TYPE FONTINFO
INTEGER(4) type ! 1 = truetype, 0 = bit map
INTEGER(4) ascent ! Pixel distance from top to
! baseline
INTEGER(4) pixwidth ! Character width in pixels,
! 0=proportional
INTEGER(4) pixheight ! Character height in pixels
INTEGER(4) avgwidth ! Average character width in
! pixels
CHARACTER(81) filename ! File name including path
CHARACTER(32) facename ! Font name
LOGICAL(1) italic ! .TRUE. if current font
! formatted italic
LOGICAL(1) emphasized ! .TRUE. if current font
! formatted bold
LOGICAL(1) underline ! .TRUE. if current font
! formatted underlined
END TYPE FONTINFO
Results
The result type is INTEGER(2). The result is zero if successful; otherwise, -1.
You must initialize fonts with INITIALIZEFONTS before calling any font-related function, including
GETFONTINFO.
Example
! Build as QuickWin or Standard Graphics
USE IFQWIN
TYPE (FONTINFO) info
INTEGER(2) numfonts, return, line_spacing
numfonts = INITIALIZEFONTS ( )
return = GETFONTINFO(info)
line_spacing = info%pixheight + 2
END
See Also
GETGTEXTEXTENT
GETGTEXTROTATION
GRSTATUS
OUTGTEXT
INITIALIZEFONTS
1590
Language Reference
SETFONT
GETGID
Portability Function: Returns the group ID of the
user of a process.
Module
USE IFPORT
Syntax
result = GETGID( )
Results
The result type is INTEGER(4). The result corresponds to the primary group of the user under whose identity
the program is running. The result is returned as follows:
• On Windows* systems, this function returns the last subauthority of the security identifier for the process.
This is unique on a local machine and unique within a domain for domain accounts.
Note that on Windows systems, domain accounts and local accounts can overlap.
• On Linux* and macOS* systems, this function returns the group identity for the current process.
Example
USE IFPORT
ISTAT = GETGID( )
GETGTEXTEXTENT (W*S)
Graphics Function: Returns the width in pixels that
would be required to print a given string of text
(including any trailing blanks) with OUTGTEXT using
the current font.
Module
USE IFQWIN
Syntax
result = GETGTEXTEXTENT (text)
Results
The result type is INTEGER(2). The result is the width of text in pixels if successful; otherwise, -1 (for
example, if fonts have not been initialized with INITIALIZEFONTS).
This function is useful for determining the size of text that uses proportionally spaced fonts. You must
initialize fonts with INITIALIZEFONTS before calling any font-related function, including GETGTEXTEXTENT.
Example
! Build as QuickWin or Standard Graphics
USE IFQWIN
INTEGER(2) status, pwidth
CHARACTER(80) text
status= INITIALIZEFONTS( )
1591
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
status= SETFONT('t''Arial''h22w10')
pwidth= GETGTEXTEXTENT('How many pixels wide is this?')
WRITE(*,*) pwidth
END
See Also
GETFONTINFO
OUTGTEXT
SETFONT
INITIALIZEFONTS
GETGTEXTROTATION
GETGTEXTROTATION (W*S)
Graphics Function: Returns the current orientation
of the font text output by OUTGTEXT.
Module
USE IFQWIN
Syntax
result = GETGTEXTROTATION( )
Results
The result type is INTEGER(4). It is the current orientation of the font text output in tenths of degrees.
Horizontal is 0°, and angles increase counterclockwise so that 900 tenths of degrees (90°) is straight up,
1800 tenths of degrees (180°) is upside-down and left, 2700 tenths of degrees (270°) is straight down, and
so forth.
The orientation for text output with OUTGTEXT is set with SETGTEXTROTATION.
Example
! Build as QuickWin or Standard Graphics
USE IFQWIN
INTEGER ang
REAL rang
ang = GETGTEXTROTATION( )
rang = FLOAT(ang)/10.0
WRITE(*,*) "Text tilt in degrees is: ", rang
END
See Also
OUTGTEXT
SETFONT
SETGTEXTROTATION
GETHWNDQQ (W*S)
QuickWin Function: Converts a window unit number
into a Windows* handle.
Module
USE IFQWIN
1592
Language Reference
Syntax
result = GETHWNDQQ (unit)
unit (Input) INTEGER(4). The window unit number. If unit is set to QWIN
$FRAMEWINDOW (defined in IFQWIN.F90), the handle of the frame
window is returned.
Results
The result type is INTEGER(4) on IA-32 architecture; INTEGER(8) on Intel® 64 architecture. The result is a
true Windows handle to the window. If unit is not open, it returns -1 .
See Also
GETACTIVEQQ
GETUNITQQ
SETACTIVEQQ
Module
USE IFQWIN
Syntax
CALL GETIMAGE (x1,y1,x2,y2,image)
CALL GETIMAGE_W (wx1,wy1,wx2,wy2,image)
GETIMAGE defines the bounding rectangle in viewport-coordinate points ( x1, y1) and ( x2, y2).
GETIMAGE_W defines the bounding rectangle in window-coordinate points ( wx1, wy1) and ( wx2, wy2).
The buffer used to store the image must be large enough to hold it. You can determine the image size by
calling IMAGESIZE at run time, or by using the formula described under IMAGESIZE. After you have
determined the image size, you can dimension the buffer accordingly.
Example
! Build as QuickWin or Standard Graphics
USE IFQWIN
INTEGER(1), ALLOCATABLE:: buffer (:)
INTEGER(2) status, x, y, error
1593
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
INTEGER(4) imsize
x = 50
y = 30
status = ELLIPSE ($GFILLINTERIOR, INT2(x-15), &
INT2(y-15), INT2( x+15), INT2(y+15))
imsize = IMAGESIZE (INT2(x-16), INT2(y-16), &
INT2( x+16), INT2(y+16))
ALLOCATE(buffer (imsize), STAT = error)
IF (error .NE. 0) THEN
STOP 'ERROR: Insufficient memory'
END IF
CALL GETIMAGE (INT2(x-16), INT2(y-16), &
INT2( x+16), INT2(y+16), buffer)
END
See Also
IMAGESIZE
PUTIMAGE
GETLASTERROR
Portability Function: Returns the last error set.
Module
USE IFPORT
Syntax
result = GETLASTERROR( )
Results
The result type is INTEGER(4). The result is the integer corresponding to the last run-time error value that
was set.
For example, if you use an ERR= specifier in an I/O statement, your program will not abort if an error occurs.
GETLASTERROR provides a way to determine what the error condition was, with a better degree of certainty
than just examining errno. Your application can then take appropriate action based upon the error number.
GETLASTERRORQQ
Portability Function: Returns the last error set by a
run-time procedure.
Module
USE IFPORT
Syntax
result = GETLASTERRORQQ( )
Results
The result type is INTEGER(4). The result is the most recent error code generated by a run-time procedure.
Library functions that return a logical or integer value sometimes also provide an error code that identifies
the cause of errors. GETLASTERRORQQ retrieves the most recent error message. The error constants are
defined in IFPORT.F90. The following table shows some library routines and the errors each routine
produces:
1594
Language Reference
BEEPQQ no error
BSEARCHQQ ERR$INVAL
COMMITQQ ERR$BADF
GETCHARQQ no error
GETDRIVESQQ no error
GETLASTERRORQQ no error
GETSTRQQ no error
PACKTIMEQQ no error
PEEKCHARQQ no error
SETERRORMODEQQ no error
SLEEPQQ no error
SORTQQ ERR$INVAL
1595
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
UNPACKTIMEQQ no error
GETLINESTYLE (W*S)
Graphics Function: Returns the current graphics line
style.
Module
USE IFQWIN
Syntax
result = GETLINESTYLE( )
Results
The result type is INTEGER(2). The result is the current line style.
GETLINESTYLE retrieves the mask (line style) used for line drawing. The mask is a 16-bit number, where
each bit represents a pixel in the line being drawn.
If a bit is 1, the corresponding pixel is colored according to the current graphics color and logical write mode;
if a bit is 0, the corresponding pixel is left unchanged. The mask is repeated for the entire length of the line.
The default mask is Z'FFFF' (a solid line). A dashed line can be represented by Z'FF00' (long dashes) or
Z'F0F0' (short dashes).
The line style is set with SETLINESTYLE. The current graphics color is set with SETCOLORRGB or SETCOLOR.
SETWRITEMODE affects how the line is displayed.
The line style retrieved by GETLINESTYLE affects the drawing of straight lines as in LINETO, POLYGON and
RECTANGLE, but not the drawing of curved lines as in ARC, ELLIPSE or PIE.
Example
! Build as Graphics
USE IFQWIN
INTEGER(2) lstyle
lstyle = GETLINESTYLE()
WRITE (*, 100) lstyle, lstyle
100 FORMAT (1X, 'Line mask in Hex ', Z4, ' and binary ', B16)
END
See Also
LINETO
POLYGON
RECTANGLE
SETCOLORRGB
SETFILLMASK
SETLINESTYLE
SETWRITEMODE
1596
Language Reference
GETLINEWIDTHQQ (W*S)
Graphics Function: Gets the current line width or the
line width set by the last call to SETLINEWIDTHQQ.
Module
USE IFQWIN
Syntax
result = GETLINEWIDTHQQ( )
Results
The result is of type INTEGER(4). It contains the current width of the line in pixels.
If there is no call to SETLINEWIDTHQQ in the program (or on that particular graphics window), it returns 1.
(The default width of a line drawn by any graphics routine is 1 pixel.)
See Also
SETLINEWIDTHQQ (W*S)
GETLOG
Portability Subroutine: Returns the user's login
name.
Module
USE IFPORT
Syntax
CALL GETLOG (name)
The login name must be less than or equal to 64 characters. If the login name is longer than 64 characters, it
is truncated. The actual parameter corresponding to name should be long enough to hold the login name. If
the supplied actual parameter is too short to hold the login name, the login name is truncated.
If the login name is shorter than the actual parameter corresponding to name, the login name is padded with
blanks at the end, until it reaches the length of the actual parameter.
If the login name cannot be determined, all blanks are returned.
Example
use IFPORT
character*20 username
CALL GETLOG (username)
print *, "You logged in as ",username
GETPHYSCOORD (W*S)
Graphics Subroutine: Translates viewport
coordinates to physical coordinates.
1597
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Module
USE IFQWIN
Syntax
CALL GETPHYSCOORD (x,y,s)
TYPE xycoord
INTEGER(2) xcoord ! x-coordinate
INTEGER(2) ycoord ! y-coordinate
END TYPE xycoord
Physical coordinates refer to the physical screen. Viewport coordinates refer to an area of the screen defined
as the viewport with SETVIEWPORT. Both take integer coordinate values. Window coordinates refer to a
window sized with SETWINDOW or SETWSIZEQQ. Window coordinates are floating-point values and allow
easy scaling of data to the window area.
Example
! Program to demonstrate GETPHYSCOORD, GETVIEWCOORD,
! and GETWINDOWCOORD. Build as QuickWin or Standard
! Graphics
USE IFQWIN
TYPE (xycoord) viewxy, physxy
TYPE (wxycoord) windxy
CALL SETVIEWPORT(INT2(80), INT2(50), &
INT2(240), INT2(150))
See Also
GETVIEWCOORD
GETWINDOWCOORD
SETCLIPRGN
1598
Language Reference
SETVIEWPORT
GETPID
Portability Function: Returns the process ID of the
current process.
Module
USE IFPORT
Syntax
result = GETPID( )
Results
The result type is INTEGER(4). The result is the process ID number of the current process.
Example
USE IFPORT
INTEGER(4) istat
istat = GETPID()
Module
USE IFQWIN
Syntax
result = GETPIXEL (x, y)
result = GETPIXEL_W (wx, wy)
Results
The result type is INTEGER(2). The result is the pixel color index if successful; otherwise, -1 (if the pixel lies
outside the clipping region, for example).
Color routines without the RGB suffix, such as GETPIXEL, use color indexes, not true color values, and limit
you to colors in the palette, at most 256. To access all system colors, use SETPIXELRGB to specify an explicit
Red-Green-Blue value and retrieve the value with GETPIXELRGB.
NOTE
The GETPIXEL routine described here is a QuickWin routine. If you are trying to use the
Microsoft* Platform SDK version of the GetPixel routine by including the IFWIN module, you
need to specify the routine name as MSFWIN$GetPixel.
See Also
GETPIXELRGB
1599
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
GRSTATUS
REMAPALLPALETTERGB, REMAPPALETTERGB
SETCOLOR
GETPIXELS
SETPIXEL
Module
USE IFQWIN
Syntax
result = GETPIXELRGB (x,y)
result = GETPIXELRGB_W (wx,wy)
Results
The result type is INTEGER(4). The result is the pixel's current RGB color value.
In each RGB color value, each of the three colors, red, green, and blue, is represented by an eight-bit value
(2 hex digits). In the value you retrieve with GETPIXELRGB, red is the rightmost byte, followed by green and
blue. The RGB value's internal structure is as follows:
Larger numbers correspond to stronger color intensity with binary 1111111 (hex Z'FF') the maximum for
each of the three components. For example, Z'0000FF' yields full-intensity red, Z'00FF00' full-intensity green,
Z'FF0000' full-intensity blue, and Z'FFFFFF' full-intensity for all three, resulting in bright white.
GETPIXELRGB returns the true color value of the pixel, set with SETPIXELRGB, SETCOLORRGB,
SETBKCOLORRGB, or SETTEXTCOLORRGB, depending on the pixel's position and the current configuration of
the screen.
SETPIXELRGB (and the other RGB color selection functions SETCOLORRGB, SETBKCOLORRGB, and
SETTEXTCOLORRGB) sets colors to a color value chosen from the entire available range. The non-RGB color
functions (SETPIXELS, SETCOLOR, SETBKCOLOR, and SETTEXTCOLOR) use color indexes rather than true
color values. If you use color indexes, you are restricted to the colors available in the palette, at most 256.
Some display adapters (SVGA and true color) are capable of creating 262,144 (256K) colors or more. To
access any available color, you need to specify an explicit Red-Green-Blue (RGB) value with an RGB color
function, rather than a palette index with a non-RGB color function.
Example
! Build as QuickWin or Standard Graphics
USE IFQWIN
INTEGER(4) pixcolor, rseed
INTEGER(2) status
REAL rnd1, rnd2
1600
Language Reference
LOGICAL(4) winstat
TYPE (windowconfig) wc
CALL GETTIM (status, status, status, INT2(rseed))
CALL SEED (rseed)
CALL RANDOM (rnd1)
CALL RANDOM (rnd2)
! Get the color index of a random pixel, normalized to
! be in the window. Then set current color to that
! pixel color.
winstat = GETWINDOWCONFIG(wc)
xnum = wc%numxpixels
ynum = wc%numypixels
pixcolor = GETPIXELRGB( INT2( rnd1*xnum ), INT2( rnd2*ynum ))
status = SETCOLORRGB (pixcolor)
END
See Also
SETPIXELRGB
GETPIXELSRGB
SETPIXELSRGB
GETPIXEL, GETPIXEL_W
GETPIXELS (W*S)
Graphics Subroutine: Returns the color indexes of
multiple pixels.
Module
USE IFQWIN
Syntax
CALL GETPIXELS (n,x,y,color)
color (Output) INTEGER(2). Array to be filled with the color indexes of the
pixels at x and y.
GETPIXELS fills in the array color with color indexes of the pixels specified by the two input arrays x and y.
These arrays are parallel: the first element in each of the three arrays refers to a single pixel, the second
element refers to the next pixel, and so on.
If the pixel is outside the clipping region, the value placed in the color array is undefined. Calls to
GETPIXELS with n less than 1 are ignored. GETPIXELS is a much faster way to acquire multiple pixel color
indexes than individual calls to GETPIXEL.
The range of possible pixel color index values is determined by the current video mode and palette, at most
256 colors. To access all system colors you need to specify an explicit Red-Green-Blue (RGB) value with an
RGB color function such as SETPIXELSRGB and retrieve the value with GETPIXELSRGB, rather than a palette
index with a non-RGB color function.
See Also
GETPIXELSRGB
1601
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
SETPIXELSRGB
GETPIXEL
SETPIXELS
GETPIXELSRGB (W*S)
Graphics Subroutine: Returns the Red-Green-Blue
(RGB) color values of multiple pixels.
Module
USE IFQWIN
Syntax
CALL GETPIXELSRGB (n,x,y,color)
color (Output) INTEGER(4). Array to be filled with RGB color values of the
pixels at x and y.
GETPIXELS fills in the array color with the RGB color values of the pixels specified by the two input arrays x
and y. These arrays are parallel: the first element in each of the three arrays refers to a single pixel, the
second element refers to the next pixel, and so on.
In each RGB color value, each of the three colors, red, green, and blue, is represented by an eight-bit value
(2 hex digits). In the values you retrieve with GETPIXELSRGB, red is the rightmost byte, followed by green
and blue. The RGB value's internal structure is as follows:
Larger numbers correspond to stronger color intensity with binary 11111111 (hex Z'FF') the maximum for
each of the three components. For example, Z'0000FF' yields full-intensity red, Z'00FF00' full-intensity green,
Z'FF0000' full-intensity blue, and Z'FFFFFF' full-intensity for all three, resulting in bright white.
GETPIXELSRGB is a much faster way to acquire multiple pixel RGB colors than individual calls to
GETPIXELRGB. GETPIXELSRGB returns an array of true color values of multiple pixels, set with
SETPIXELSRGB, SETCOLORRGB, SETBKCOLORRGB, or SETTEXTCOLORRGB, depending on the pixels'
positions and the current configuration of the screen.
SETPIXELSRGB (and the other RGB color selection functions SETCOLORRGB, SETBKCOLORRGB, and
SETTEXTCOLORRGB) sets colors to a color value chosen from the entire available range. The non-RGB color
functions (SETPIXELS, SETCOLOR, SETBKCOLOR, and SETTEXTCOLOR) use color indexes rather than true
color values. If you use color indexes, you are restricted to the colors available in the palette, at most 256.
Some display adapters (SVGA and true color) are capable of creating 262,144 (256K) colors or more. To
access any available color, you need to specify an explicit RGB value with an RGB color function, rather than
a palette index with a non-RGB color function.
Example
! Build as QuickWin or Standard Graphics
USE IFQWIN
INTEGER(4) color(50), result
1602
Language Reference
See Also
SETPIXELSRGB
GETPIXELRGB, GETPIXELRGB_W
GETPIXELS
SETPIXELS
GETPOS, GETPOSI8
Portability Functions: Return the current position of
a file.
Module
USE IFPORT
Syntax
result = GETPOS (lunit)
result = GETPOSI8 (lunit)
lunit (Input) INTEGER(4). External unit number of a file. The value must be
in the range 0 to 100 and the file must be connected.
Results
The result type is INTEGER(4) for GETPOS; INTEGER(8) for GETPOSI8. The result is the offset, in bytes, from
the beginning of the file. If an error occurs, the result value is -1 and the following error code is returned in
errno:
EINVAL: lunit is not a valid unit number, or is not open.
These functions are equivalent to FTELL, FTELLI8.
GETSTATUSFPQQ (W*S)
Portability Subroutine: Returns the floating-point
processor status word.
Module
USE IFPORT
1603
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
CALL GETSTATUSFPQQ (status)
The floating-point status word shows whether various floating-point exception conditions have occurred. The
compiler initially clears (sets to 0) all status flags, but after an exception occurs it does not reset the flags
before performing additional floating-point operations. A status flag with a value of one thus shows there has
been at least one occurrence of the corresponding exception. The following table lists the status flags and
their values:
You can use a logical comparison on the status word returned by GETSTATUSFPQQ to determine which of the
six floating-point exceptions listed in the table has occurred.
An exception is disabled if its control bit is set to 1. An exception is enabled if its control bit is cleared to 0.
By default, all exception traps are disabled. Exceptions can be enabled and disabled by clearing and setting
the flags with SETCONTROLFPQQ. You can use GETCONTROLFPQQ to determine which exceptions are
currently enabled and disabled.
If an exception is disabled, it does not cause an interrupt when it occurs. Instead, floating-point processes
generate an appropriate special value (NaN or signed infinity), but the program continues. You can find out
which exceptions (if any) occurred by calling GETSTATUSFPQQ.
If errors on floating-point exceptions are enabled (by clearing the flags to 0 with SETCONTROLFPQQ), the
operating system generates an interrupt when the exception occurs. By default, these interrupts cause run-
time errors, but you can capture the interrupts with SIGNALQQ and branch to your own error-handling
routines.
Example
! Program to demonstrate GETSTATUSFPQQ
USE IFPORT
INTEGER(2) status
CALL GETSTATUSFPQQ(status)
! check for divide by zero
IF (IAND(status, FPSW$ZERODIVIDE) .NE. 0) THEN
WRITE (*,*) 'Divide by zero occurred. Look &
for NaN or signed infinity in resultant data.'
END IF
END
1604
Language Reference
See Also
SETCONTROLFPQQ
GETCONTROLFPQQ
SIGNALQQ
CLEARSTATUSFPQQ
GETSTRQQ
Run-Time Function: Reads a character string from
the keyboard using buffered input.
Module
USE IFCORE
Syntax
result = GETSTRQQ (buffer)
Results
The result type is INTEGER(4). The result is the number of characters placed in buffer.
The function does not complete until you press Return or Enter.
Example
! Program to demonstrate GETSTRQQ
USE IFCORE
USE IFPORT
INTEGER(4) length, result
CHARACTER(80) prog, args
WRITE (*, '(A, \)') ' Enter program to run: '
length = GETSTRQQ (prog)
WRITE (*, '(A, \)') ' Enter arguments: '
length = GETSTRQQ (args)
result = RUNQQ (prog, args)
IF (result .EQ. -1) THEN
WRITE (*,*) 'Couldn''t run program'
ELSE
WRITE (*, '(A, Z4, A)') 'Return code : ', result, 'h'
END IF
END
See Also
READ
GETCHARQQ
PEEKCHARQQ
GET_TEAM
Transformational Intrinsic Function (Generic):
Returns a copy of a team variable.
Syntax
result = GET_TEAM ([ level ])
1605
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
level (Optional, Input) Must be a scalar integer whose value is equal to one
of the named constants INITIAL_TEAM, CURRENT_TEAM, or
PARENT_TEAM defined in the ISO_FORTRAN_ENV intrinsic module.
Results
The result is type TEAM_TYPE from the ISO_FORTRAN_ENV intrinsic module. If level is not present, or if
CURRENT_TEAM is specified, the result is a team variable describing the current team. If level has the value
PARENT_TEAM, the result is a team variable describing the parent team of the current team. If level has the
value INITIAL_TEAM, the result is a team variable describing the initial team.
Example
Consider the following program fragment:
PROGRAM main
USE, INTRINSIC :: ISO_FORTRAN_ENV
TYPE (TEAM_TYPE) :: original
original = GET_TEAM (INITIAL_TEAM)
After execution of the GET_TEAM function, original is defined with a team value describing the initial team.
GETTEXTCOLOR (W*S)
Graphics Function: Returns the current text color
index.
Module
USE IFQWIN
Syntax
result = GETTEXTCOLOR( )
Results
The result type is INTEGER(2). It is the current text color index.
GETTEXTCOLOR returns the text color index set by SETTEXTCOLOR. SETTEXTCOLOR affects text output with
OUTTEXT, WRITE, and PRINT. The background color index is set with SETBKCOLOR and returned with
GETBKCOLOR. The color index of graphics over the background color is set with SETCOLOR and returned with
GETCOLOR. These non-RGB color functions use color indexes, not true color values, and limit the user to
colors in the palette, at most 256. To access all system colors, use SETTEXTCOLORRGB, SETBKCOLORRGB,
and SETCOLORRGB.
The default text color index is 15, which is associated with white unless the user remaps the palette.
NOTE
The GETTEXTCOLOR routine described here is a QuickWin routine. If you are trying to use
the Microsoft* Platform SDK version of the GetTextColor routine by including the IFWIN
module, you need to specify the routine name as MSFWIN$GetTextColor.
See Also
OUTTEXT
REMAPPALETTERGB
SETCOLOR
SETTEXTCOLOR
1606
Language Reference
GETTEXTCOLORRGB (W*S)
Graphics Function: Returns the Red-Green-Blue
(RGB) value of the current text color (used with
OUTTEXT, WRITE and PRINT).
Module
USE IFQWIN
Syntax
result = GETTEXTCOLORRGB( )
Results
The result type is INTEGER(4). It is the RGB value of the current text color.
In each RGB color calue, each of the three colors, red, green, and blue, is represented by an eight-bit value
(2 hex digits). In the value you retrieve with GETTEXTCOLORRGB, red is the rightmost byte, followed by
green and blue. The RGB value's internal structure is as follows:
Larger numbers correspond to stronger color intensity with binary (hex Z'FF') the maximum for each of the
three components. For example, Z'0000FF' yields full-intensity red, Z'00FF00' full-intensity green, Z'FF0000'
full-intensity blue, and Z'FFFFFF' full-intensity for all three, resulting in bright white.
GETTEXTCOLORRGB returns the RGB color value of text over the background color (used by text functions
such as OUTTEXT, WRITE, and PRINT), set with SETTEXTCOLORRGB. The RGB color value used for graphics is
set and returned with SETCOLORRGB and GETCOLORRGB. SETCOLORRGB controls the color used by the
graphics function OUTGTEXT, while SETTEXTCOLORRGB controls the color used by all other text output
functions. The RGB background color value for both text and graphics is set and returned with
SETBKCOLORRGB and GETBKCOLORRGB.
SETTEXTCOLORRGB (and the other RGB color selection functions SETBKCOLORRGB, and SETCOLORRGB) sets
the color to a color value chosen from the entire available range. The non-RGB color functions
(SETTEXTCOLOR, SETBKCOLOR, and SETCOLOR) use color indexes rather than true color values. If you use
color indexes, you are restricted to the colors available in the palette, at most 256. Some display adapters
(SVGA and true color) are capable of creating 262,144 (256K) colors or more. To access any available color,
you need to specify an explicit RGB value with an RGB color function, rather than a palette index with a non-
RGB color function.
Example
! Build as QuickWin or Standard Graphics
USE IFQWIN
INTEGER(4) oldtextc, oldbackc, temp
TYPE (rccoord) curpos
! Save color settings
oldtextc = GETTEXTCOLORRGB()
oldbackc = GETBKCOLORRGB()
CALL CLEARSCREEN( $GCLEARSCREEN )
! Reset colors
temp = SETTEXTCOLORRGB(Z'00FFFF') ! full red + full green
! = full yellow text
temp = SETBKCOLORRGB(Z'FF0000') ! blue background
1607
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
SETTEXTCOLORRGB
GETBKCOLORRGB
GETCOLORRGB
GETTEXTCOLOR
GETTEXTPOSITION (W*S)
Graphics Subroutine: Returns the current text
position.
Module
USE IFQWIN
Syntax
CALL GETTEXTPOSITION (s)
s (Output) Derived type rccord. Current text position. The derived type
rccoord is defined in IFQWIN.F90 as follows:
TYPE rccoord
INTEGER(2) row ! Row coordinate
INTEGER(2) col ! Column coordinate
END TYPE rccoord
The text position given by coordinates (1, 1) is defined as the upper-left corner of the text window. Text
output from the OUTTEXT function (and WRITE and PRINT statements) begins at the current text position.
Font text is not affected by the current text position. Graphics output, including OUTGTEXT output, begins at
the current graphics output position, which is a separate position returned by GETCURRENTPOSITION.
Example
! Build as QuickWin or Standard Graphics
USE IFQWIN
TYPE (rccoord) textpos
CALL GETTEXTPOSITION (textpos)
END
See Also
SETTEXTPOSITION
GETCURRENTPOSITION
OUTTEXT
WRITE
SETTEXTWINDOW
1608
Language Reference
GETTEXTWINDOW (W*S)
Graphics Subroutine: Finds the boundaries of the
current text window.
Module
USE IFQWIN
Syntax
CALL GETTEXTWINDOW (r1,c1,r2,c2)
Output from OUTTEXT and WRITE is limited to the text window. By default, this is the entire window, unless
the text window is redefined by SETTEXTWINDOW.
The window defined by SETTEXTWINDOW has no effect on output from OUTGTEXT.
Example
! Build as QuickWin or Standard Graphics
USE IFQWIN
INTEGER(2) top, left, bottom, right
DO i = 1, 10
WRITE(*,*) "Hello, world"
END DO
! Save text window position
CALL GETTEXTWINDOW (top, left, bottom, right)
! Scroll text window down seven lines
CALL SCROLLTEXTWINDOW (INT2(-7))
! Restore text window
CALL SETTEXTWINDOW (top, left, bottom, right)
WRITE(*,*) "At beginning again"
END
See Also
GETTEXTPOSITION
OUTTEXT
WRITE
SCROLLTEXTWINDOW
SETTEXTPOSITION
SETTEXTWINDOW
WRAPON
GETTIM
Portability Subroutine: Returns the time.
Module
USE IFPORT
1609
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
CALL GETTIM (ihr, imin, isec, i100th)
All arguments must be of the same integer kind, that is, all must be INTEGER(2) or all must be INTEGER(4).
If INTEGER(2) arguments are passed, you must specify USE IFPORT.
Example
See the example in GETDAT.
See Also
GETDAT
SETDAT
SETTIM
CLOCK
CTIME
DTIME
ETIME
GMTIME
ITIME
LTIME
RTC
TIMEF
GETTIMEOFDAY
Portability Subroutine: Returns seconds and
microseconds since 00:00 Jan 1, 1970.
Module
USE IFPORT
1610
Language Reference
Syntax
CALL GETTIMEOFDAY (ret, err)
Element Value
ret(1) Seconds
ret(2) Microseconds
If an error occurs, err contains a value equal to -1 and array ret contains zeros.
On Windows* systems, this subroutine has millisecond precision, and the last three digits of the returned
value are not significant.
GETUID
Portability Function: Returns the user ID of the
calling process.
Module
USE IFPORT
Syntax
result = GETUID( )
Results
The result type is INTEGER(4). The result corresponds to the user identity under which the program is
running. The result is returned as follows:
• On Windows* systems, this function returns the last subauthority of the security identifier for the process.
This is unique on a local machine and unique within a domain for domain accounts.
Note that on Windows systems, domain accounts and local accounts can overlap.
• On Linux* and macOS* systems, this function returns the user identity for the current process.
Example
USE IFPORT
integer(4) istat
istat = GETUID( )
GETUNITQQ (W*S)
QuickWin Function: Returns the unit number
corresponding to the specified Windows* handle.
Module
USE IFQWIN
Syntax
result = GETUNITQQ (whandle)
1611
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type is INTEGER(4). The result is the unit number corresponding to the specified Windows handle.
If whandle does not exist, it returns -1 .
This routine is the inverse of GETHWNDQQ.
See Also
GETHWNDQQ
Module
USE IFQWIN
Syntax
CALL GETVIEWCOORD (x, y, s)
CALL GETVIEWCOORD_W (wx, wy, s)
TYPE xycoord
INTEGER(2) xcoord ! x-coordinate
INTEGER(2) ycoord ! y-coordinate
END TYPE xycoord
Viewport coordinates refer to an area of the screen defined as the viewport with SETVIEWPORT. Physical
coordinates refer to the whole screen. Both take integer coordinate values. Window coordinates refer to a
window sized with SETWINDOW or SETWSIZEQQ. Window coordinates are floating-point values and allow
easy scaling of data to the window area.
Example
See the example program in GETPHYSCOORD.
See Also
GETPHYSCOORD
GETWINDOWCOORD
GETWINDOWCONFIG (W*S)
QuickWin Function: Returns the properties of the
current window.
1612
Language Reference
Module
USE IFQWIN
Syntax
result = GETWINDOWCONFIG (wc)
TYPE windowconfig
INTEGER(2) numxpixels ! Number of pixels on x-
axis
INTEGER(2) numypixels ! Number of pixels on y-
axis
INTEGER(2) numtextcols ! Number of text columns
available
INTEGER(2) numtextrows ! Number of text rows
available
INTEGER(2) numcolors ! Number of color indexes
INTEGER(4) fontsize ! Size of default font. Set to
! QWIN$EXTENDFONT when
specifying
! extended attributes, in
which
! case extendfontsize sets
the
! font size
CHARACTER(80) title ! The window title
INTEGER(2) bitsperpixel ! The number of bits per
pixel
INTEGER(2) numvideopages ! Unused
INTEGER(2) mode ! Controls scrolling mode
INTEGER(2) adapter ! Unused
INTEGER(2) monitor ! Unused
INTEGER(2) memory ! Unused
INTEGER(2) environment ! Unused
!
! The next three parameters provide extended font attributes.
!
CHARACTER(32) extendfontname ! The name of the desired
font
INTEGER(4) extendfontsize ! Takes the same values
as fontsize,
! when fontsize is set
to
! QWIN$EXTENDFONT
INTEGER(4) extendfontattributes ! Font attributes such as
bold
! and italic
END TYPE windowconfig
Results
The result type is LOGICAL(4). The result is .TRUE. if successful; otherwise, .FALSE. (for example, if there is
no active child window).
GETWINDOWCONFIG returns information about the active child window. If you have not set the window
properties with SETWINDOWCONFIG, GETWINDOWCONFIG returns default window values.
1613
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
A typical set of values would be 1024 x pixels, 768 y pixels, 128 text columns, 48 text rows, and a font size
of 8x16 pixels. The resolution of the display and the assumed font size of 8x16 pixels generates the number
of text rows and text columns. The resolution (in this case, 1024 x pixels by 768 y pixels) is the size of the
virtual window. To get the size of the physical window visible on the screen, use GETWSIZEQQ. In this case,
GETWSIZEQQ returned the following values: (0,0) for the x and y position of the physical window, 25 for the
height or number of rows, and 71 for the width or number of columns.
The number of colors returned depends on the video drive. The window title defaults to "Graphic1" for the
default window. All of these values can be changed with SETWINDOWCONFIG.
Note that the bitsperpixel field in the windowconfig derived type is an output field only, while the other
fields return output values to GETWINDOWCONFIG and accept input values from SETWINDOWCONFIG.
Example
!Build as QuickWin or Standard Graphics App.
USE IFQWIN
LOGICAL(4) status
TYPE (windowconfig) wc
status = GETWINDOWCONFIG(wc)
IF(wc%numtextrows .LT. 10) THEN
wc%numtextrows = 10
status = SETWINDOWCONFIG(wc)
IF(.NOT. status ) THEN ! if setwindowconfig error
status = SETWINDOWCONFIG(wc) ! reset
! setwindowconfig with corrected values
status = GETWINDOWCONFIG(wc)
IF(wc%numtextrows .NE. 10) THEN
WRITE(*,*) 'Error: Cannot increase text rows to 10'
END IF
END IF
END IF
END
See Also
GETWSIZEQQ
SETWINDOWCONFIG
SETACTIVEQQ
GETWINDOWCOORD (W*S)
Graphics Subroutine: Converts viewport coordinates
to window coordinates.
Module
USE IFQWIN
Syntax
CALL GETWINDOWCOORD (x,y,s)
1614
Language Reference
TYPE wxycoord
REAL(8) wx ! x-coordinate
REAL(8) wy ! y-coordinate
END TYPE wxycoord
Physical coordinates refer to the physical screen. Viewport coordinates refer to an area of the screen defined
as the viewport with SETVIEWPORT. Both take integer coordinate values. Window coordinates refer to a
window sized with SETWINDOW or SETWSIZEQQ. Window coordinates are floating-point values and allow
easy scaling of data to the window area.
Example
See the example program in GETPHYSCOORD.
See Also
GETCURRENTPOSITION
GETPHYSCOORD
GETVIEWCOORD
MOVETO
SETVIEWPORT
SETWINDOW
GETWRITEMODE (W*S)
Graphics Function: Returns the current logical write
mode, which is used when drawing lines with the
LINETO, POLYGON, and RECTANGLE functions.
Module
USE IFQWIN
Syntax
result = GETWRITEMODE( )
Results
The result type is INTEGER(2). The result is the current write mode. Possible return values are:
• $GPSET - Causes lines to be drawn in the current graphics color. (default)
• $GAND - Causes lines to be drawn in the color that is the logical AND of the current graphics color and the
current background color.
• $GOR - Causes lines to be drawn in the color that is the logical OR of the current graphics color and the
current background color.
• $GPRESET - Causes lines to be drawn in the color that is the logical NOT of the current graphics color.
• $GXOR - Causes lines to be drawn in the color that is the logical exclusive OR (XOR) of the current
graphics color and the current background color.
The default value is $GPSET. These constants are defined in IFQWIN.F90.
1615
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
! Build as QuickWin or Standard Graphics App.
USE IFQWIN
INTEGER(2) mode
mode = GETWRITEMODE()
END
See Also
SETWRITEMODE
SETLINESTYLE
LINETO
POLYGON
PUTIMAGE
RECTANGLE
SETCOLORRGB
SETFILLMASK
GRSTATUS
GETWSIZEQQ (W*S)
QuickWin Function: Returns the size and position of
a window.
Module
USE IFQWIN
Syntax
result = GETWSIZEQQ (unit, ireq, winfo)
unit (Input) INTEGER(4). Specifies the window unit. Unit numbers 0, 5 and
6 refer to the default startup window only if you have not explicitly
opened them with the OPEN statement. To access information about
the frame window (as opposed to a child window), set unit to the
symbolic constant QWIN$FRAMEWINDOW, defined in IFQWIN.F90.
TYPE QWINFO
INTEGER(2) TYPE ! request type (controls
! SETWSIZEQQ)
INTEGER(2) X ! x coordinate for upper left
INTEGER(2) Y ! y coordinate for upper left
1616
Language Reference
Results
The result type is INTEGER(4). The result is zero if successful; otherwise, nonzero.
The position and dimensions of child windows are expressed in units of character height and width. The
position and dimensions of the frame window are expressed in screen pixels.
The height and width returned for a frame window reflects the size in pixels of the client area excluding any
borders, menus, and status bar at the bottom of the frame window. You should adjust the values used in
SETWSIZEQQ to take this into account.
The client area is the area actually available to place child windows.
See Also
GETWINDOWCONFIG
SETWSIZEQQ
GMTIME
Portability Subroutine: Returns the Greenwich
mean time in an array of time elements.
Module
USE IFPORT
Syntax
CALL GMTIME (stime,tarray)
Element Value
1617
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Element Value
Caution
This subroutine may cause problems with the year 2000. Use DATE_AND_TIME instead.
Example
use IFPORT
integer(4) stime, timearray(9)
! initialize stime to number of seconds since
! 00:00:00 GMT January 1, 1970
stime = time()
CALL GMTIME (stime, timearray)
print *, timearray
end
See Also
DATE_AND_TIME
GOTO - Assigned
Statement: Transfers control to the statement whose
label was most recently assigned to a variable. This
feature has been deleted in the Fortran Standard.
Intel® Fortran fully supports features deleted in the
Fortran Standard.
Syntax
GOTO var[[ ,] ( label-list)]
The variable must have a statement label value assigned to it by an ASSIGN statement (not an arithmetic
assignment statement) before the GO TO statement is executed.
If a list of labels appears, the statement label assigned to the variable is not checked against the labels in the
list.
Both the assigned GO TO statement and its associated ASSIGN statement must be in the same scoping unit.
Example
The following example is equivalent to GO TO 200:
1618
Language Reference
ASSIGN 10 TO I
J = I
GO TO J
In this case, variable J is not the variable assigned to, so it cannot be used in the assigned GO TO statement.
The following shows another example:
ASSIGN 10 TO N
GOTO N
10 CONTINUE
The following example uses an assigned GOTO statement with a label-list but it is not checked against the
value of VIEW:
See Also
Obsolescent Language Features in the Fortran Standard
GOTO - Computed GOTO
GOTO - Unconditional GOTO
Execution Control
GOTO - Computed
Statement: Transfers control to one of a set of
labeled branch target statements based on the value
of an expression. It is an obsolescent feature in
Fortran 95.
Syntax
GOTO (label-list) [ ,] expr
When the computed GO TO statement is executed, the expression is evaluated first. The value of the
expression represents the ordinal position of a label in the associated list of labels. Control is transferred to
the statement identified by the label. For example, if the list contains (30,20,30,40) and the value of the
expression is 2, control is transferred to the statement identified with label 20.
If the value of the expression is less than 1 or greater than the number of labels in the list, control is
transferred to the next executable statement or construct following the computed GO TO statement.
1619
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
The following example shows valid computed GO TO statements:
GO TO (12,24,36), INDEX
GO TO (320,330,340,350,360), SITU(J,K) + 1
The following shows another example:
next = 1
C
C The following statement transfers control to statement 10:
C
GOTO (10, 20) next
...
10 CONTINUE
...
20 CONTINUE
See Also
Obsolescent Language Features in the Fortran Standard
GOTO - Unconditional GOTO
Execution Control
GOTO - Unconditional
Statement: Transfers control to the same branch
target statement every time it executes.
Syntax
GO TO label
label Is the label of a valid branch target statement in the same scoping
unit as the GO TO statement.
The unconditional GO TO statement transfers control to the branch target statement identified by the
specified label.
Example
The following are examples of GO TO statements:
GO TO 7734
GO TO 99999
The following shows another example:
integer(2) in
10 print *, 'enter a number from one to ten: '
read *, in
select case (in)
case (1:10)
exit
case default
print *, 'wrong entry, try again'
goto 10
end select
See Also
GOTO - Computed GOTO
1620
Language Reference
Execution Control
GRSTATUS (W*S)
Graphics Function: Returns the status of the most
recently used graphics routine.
Module
USE IFQWIN
Syntax
result = GRSTATUS( )
Results
The result type is INTEGER(2). The result is the status of the most recently used graphics function.
Use GRSTATUS immediately following a call to a graphics routine to determine if errors or warnings were
generated. Return values less than 0 are errors, and values greater than 0 are warnings.
The following symbolic constants are defined in the IFQWIN.F90 module file for use with GRSTATUS:
Constant Meaning
$GROK Success
1621
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
After a graphics call, compare the return value of GRSTATUS to $GROK. to determine if an error has
occurred. For example:
GETCOLOR GETTEXTPOSITION
The following table lists some other routines with the error or warning messages they produce for
GRSTATUS:
CLEARSCREEN $GRINVALIDPARAMETER
GETARCINFO $GRERROR
GETFILLMASK $GRERROR,
$GRINVALIDPARAMETER
GETFONTINFO $GRERROR
GETGTEXTEXTENT $GRERROR
GETPIXEL $GRBITMAPTOOLARGE
GETPIXELRGB $GRBITMAPTOOLARGE
LOADIMAGE $GRFILEOPENERROR,
$GRNOBITMAPFILE,
$GRALEREADERROR,
$GRIMPROPERBITMAPFORMAT,
$GRBITMAPTOOLARGE,
$GRIMAGEREADERROR
1622
Language Reference
REMAPPALETTERGB $GRERROR,
$GRINVALIDPARAMETER
REMAPALLPALETTERGB $GRERROR,
$GRINVALIDPARAMETER
SAVEIMAGE $GRFILEOPENERROR
SCROLLTEXTWINDOW $GRNOOUTPUT
SETCLIPRGN $GRPARAMETERALTERED
SETCOLOR $GRPARAMETERALTERED
SETTEXTCOLOR $GRPARAMETERALTERED
SETTEXTCOLORRGB $GRPARAMETERALTERED
SETTEXTPOSITION $GRPARAMETERALTERED
SETTEXTWINDOW $GRPARAMETERALTERED
SETVIEWPORT $GRPARAMETERALTERED
SETWRITEMODE $GRINVALIDPARAMETER
See Also
ARC
ELLIPSE
FLOODFILLRGB
1623
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
LINETO
PIE
POLYGON
REMAPALLPALETTERGB
SETBKCOLORRGB
SETCOLORRGB
SETPIXELRGB
SETTEXTCOLORRGB
SETWINDOW
SETWRITEMODE
H to I
This section describes language features that start with H or I.
H to I
HOSTNAM
Portability Function: Returns the current host
computer name. This function can also be specified as
HOSTNM.
Module
USE IFPORT
Syntax
result = HOSTNAM (name)
Results
The result type is INTEGER(4). The result is zero if successful. If name is not long enough to contain all of
the host name, the function truncates the host name and returns -1.
Example
use IFPORT
character(MAX_HOSTNAM_LENGTH + 1) hostname
integer(4) istat
ISTAT = HOSTNAM (hostname)
HUGE
Inquiry Intrinsic Function (Generic): Returns the
largest number in the model representing the same
type and kind parameters as the argument.
Syntax
result = HUGE (x)
1624
Language Reference
Results
The result is a scalar of the same type and kind parameters as x. If x is of type integer, the result has the
value r q - 1. If x is of type real, the result has the value (1 - b -p)b emax.
Integer parameters r and q are defined in Model for Integer Data; real parameters b, p, and e maxare defined
in Model for Real Data.
Example
If X is of type REAL(4), HUGE (X) has the value (1 - 2 -24) x2 128.
See Also
TINY
Data Representation Models
HYPOT
Elemental Intrinsic Function (Generic): Returns
the value of the Euclidean distance of the arguments.
Syntax
result = HYPOT (x,y)
y (Input) Must be of type real. It must be the same type and kind as x.
Results
The result type and kind are the same as x.
The result has a value equal to a processor-dependent approximation to the Euclidean distance, ,
without undue overflow or underflow.
Example
HYPOT (3.0, 4.0) has the approximate value 5.0.
IACHAR
Elemental Intrinsic Function (Generic): Returns
the position of a character in the ASCII character set,
even if the processor's default character set is
different. In Intel® Fortran, IACHAR is equivalent to
the ICHAR function.
Syntax
result = IACHAR (c [, kind])
1625
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type is integer. If kind is present, the kind parameter of the result is that specified by kind;
otherwise, the kind parameter of the result is that of default integer. If c is in the ASCII collating sequence,
the result is the position of c in that sequence and satisfies the inequality (0 .le. IACHAR(c) .le. 127).
The results must be consistent with the LGE, LGT, LLE, and LLT lexical comparison functions. For example, if
LLE(C, D) is true, IACHAR(C) .LE. IACHAR(D) is also true.
Example
IACHAR ( 'Y' ) has the value 89.
IACHAR ( '%' ) has the value 37.
See Also
ASCII and Key Code Charts
ACHAR
CHAR
ICHAR
LGE
LGT
LLE
LLT
IALL
Transformational Intrinsic Function (Generic):
Reduces an array with a bitwise AND operation.
Syntax
result = IALL (array, dim [, mask])
result = IALL (array [, mask])
dim (Input) Must be a scalar integer with a value in the range 1 <= dim
<= n, where n is the rank of array.
mask (Input; optional) Must be of type logical and conformable with array.
Results
The result has the same type and kind parameters as array. It is scalar if dim does not appear or if array has
rank one; otherwise, the result is an array of rank n - 1 and shape [d1, d2, ..., ddim-1, ddim+1 , ..., dn] where
[d1, d2,..., dn] is the shape of array.
If array has size zero the result value is equal to NOT (INT (0, KIND (array))). Otherwise, the result of IALL
(array) has a value equal to the bitwise AND of all the elements of array.
The result of IALL (array, MASK=mask) has a value equal to IALL (PACK (array, mask)).
The result of IALL (array, DIM=dim [ , MASK=mask]) has a value equal to that of IALL (array [ ,
MASK=mask]) if array has rank one. Otherwise, the value of element (s1, s2, ..., sdim-1, sdim+1 , ..., sn) of the
result is equal to IALL (array (s1, s2, ..., sdim-1 , :, sdim+1 , ..., sn) [, MASK = mask (s1, s2, ..., sdim-1 , :, sdim
+1 , ..., sn)]).
1626
Language Reference
Example
IALL ([14, 13, 11]) has the value 8. IALL ([14, 13, 11], MASK=[.true., .false., .true]) has the value 10.
See Also
IANY
IPARITY
IAND
Elemental Intrinsic Function (Generic): Performs
a logical AND on corresponding bits. This function can
also be specified as AND.
Syntax
result = IAND (i,j)
Results
If both i and j are of type integer or logical, the result type and kind are the same as i. If either i or j is a
binary, octal, or hexadecimal literal constant, it is first converted as if by the intrinsic function INT to type
integer with the kind type parameter of the other.
The result value is derived by combining i and j bit-by-bit according to the following truth table:
i j IAND (i, j)
1 1 1
1 0 0
0 1 0
0 0 0
The model for the interpretation of an integer value as a sequence of bits is shown in Model for Bit Data.
Example
IAND (2, 3) has the value 2.
1627
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
INTEGER(1) i, m
INTEGER result
INTEGER(2) result2
i = 1
m = 3
result = IAND(i,m) ! returns an integer of default type
! (INTEGER(4) unless reset by user) whose
! value = 1
result2 = IAND(i,m) ! returns an INTEGER(2) with value = 1
See Also
Binary, Octal, Hexadecimal, and Hollerith Constants
IEOR
IOR
NOT
IALL
IANY
IPARITY
IANY
Transformational Intrinsic Function (Generic):
Reduces an array with a bitwise OR operation.
Syntax
result = IANY (array, dim [, mask])
result = IANY (array [, mask])
dim (Input) Must be a scalar integer with a value in the range 1 <= dim
<= n, where n is the rank of array.
mask (Input; optional) Must be of type logical and conformable with array.
Results
The result has the same type and kind parameters as array. It is scalar if dim does not appear; otherwise,
the result is an array of rank n - 1 and shape [d1, d2, ..., ddim-1, ddim+1 , ..., dn] where [d1, d2,..., dn] is the
shape of array.
The result of IANY (array) is the bitwise OR of all the elements of array. If array has size zero, the result
value is equal to zero.
The result of IANY (array, MASK=mask) has a value equal to IANY (PACK (array, mask)).
The result of IANY (array, DIM=dim [ , MASK=mask]) has a value equal to that of IANY (array [ ,
MASK=mask]) if array has rank one. Otherwise, the value of element (s1, s2, ..., sdim-1, sdim+1 , ..., sn) of the
result is equal to IANY (array (s1, s2, ..., sdim-1 , :, sdim+1 , ..., sn) [, MASK = mask (s1, s2, ..., sdim-1 , :, sdim
+1 , ..., sn)]).
Example
IANY ([14, 13, 8]) has the value 15. IANY ([14, 13, 8], MASK=[.true., .false., .true]) has the value 14.
1628
Language Reference
See Also
IALL
IPARITY
IARGC
Inquiry Intrinsic Function (Specific): Returns the
index of the last command-line argument. It cannot
be passed as an actual argument. This function can
also be specified as IARG or NUMARG.
Syntax
result = IARGC( )
Results
The result type is INTEGER(4). The result is the index of the last command-line argument, which is also the
number of arguments on the command line. The command is not included in the count. For example, IARGC
returns 3 for the command-line invocation of PROG1 -g -c -a.
Example
integer(4) no_of_arguments
no_of_arguments = IARGC ()
print *, 'total command line arguments are ', no_of_arguments
For a command-line invocation of PROG1 -g -c -a, the program above prints:
IBCHNG
Elemental Intrinsic Function (Generic): Reverses
the value of a specified bit in an integer.
Syntax
result = IBCHNG (i,pos)
pos (Input) Must be of type integer. This argument is the position of the
bit to be changed.
The rightmost (least significant) bit of i is in position 0.
Results
The result type and kind are the same as i. The result is equal to i with the bit in position pos reversed.
1629
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
INTEGER J, K
J = IBCHNG(10, 2) ! returns 14 = 1110
K = IBCHNG(10, 1) ! returns 8 = 1000
See Also
BTEST
IAND
IBCLR
IBSET
IEOR
IOR
ISHA
ISHC
ISHL
ISHFT
NOT
IBCLR
Elemental Intrinsic Function (Generic): Clears one
bit to zero.
Syntax
result = IBCLR (i,pos)
pos (Input) Must be of type integer. It must not be negative and it must
be less than BIT_SIZE(i).
Results
The result type and kind are the same as i. The result has the value of the sequence of bits of i, except that
bit pos of i is set to zero.
For more information, see Bit Functions.
The model for the interpretation of an integer value as a sequence of bits is shown in Model for Bit Data.
1630
Language Reference
Example
IBCLR (18, 1) has the value 16.
If V has the value (1, 2, 3, 4), the value of IBCLR (POS = V, I = 15) is (13, 11, 7, 15).
The following shows another example:
INTEGER J, K
J = IBCLR(7, 1) ! returns 5 = 0101
K = IBCLR(5, 1) ! returns 5 = 0101
See Also
BTEST
IAND
IBCHNG
IBSET
IEOR
IOR
ISHA
ISHC
ISHL
ISHFT
NOT
IBITS
Elemental Intrinsic Function (Generic): Extracts a
sequence of bits (a bit field).
Syntax
result = IBITS (i,pos,len)
pos (Input) Must be of type integer. It must not be negative and pos+ len
must be less than or equal to BIT_SIZE(i).
Results
The result type and kind are the same as i. The result has the value of the sequence of len bits in i,
beginning at pos, right-adjusted and with all other bits zero.
For more information, see Bit Functions.
The model for the interpretation of an integer value as a sequence of bits is shown in Model for Bit Data.
1631
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
IBITS (12, 1, 4) has the value 6.
IBITS (10, 1, 7) has the value 5.
See Also
BTEST
BIT_SIZE
IBCLR
IBSET
ISHFT
ISHFTC
MVBITS
IBSET
Elemental Intrinsic Function (Generic): Sets one
bit to 1.
Syntax
result = IBSET (i,pos)
pos (Input) Must be of type integer. It must not be negative and it must
be less than BIT_SIZE( i).
Results
The result type and kind are the same as i. The result has the value of the sequence of bits of i, except that
bit pos of i is set to 1.
For more information, see Bit Functions.
The model for the interpretation of an integer value as a sequence of bits is shown in Model for Bit Data.
1632
Language Reference
Example
IBSET (8, 1) has the value 10.
If V has the value (1, 2, 3, 4), the value of IBSET (POS = V, I = 2) is (2, 6, 10, 18).
The following shows another example:
INTEGER I
I = IBSET(8, 2) ! returns 12 = 1100
See Also
BTEST
IAND
IBCHNG
IBCLR
IEOR
IOR
ISHA
ISHC
ISHL
ISHFT
NOT
ICHAR
Elemental Intrinsic Function (Generic): Returns
the position of a character in the processor's character
set.
Syntax
result = ICHAR (c [, kind])
Results
The result type is integer. If kind is present, the kind parameter of the result is that specified by kind;
otherwise, the kind parameter of the result is that of default integer.
The result value is the position of c in the processor's character set. c is in the range zero to n - 1, where n is
the number of characters in the character set.
For any characters C and D (capable of representation in the processor), C .LE. D is true only if
ICHAR(C) .LE. ICHAR(D) is true, and C .EQ. D is true only if ICHAR(C) .EQ. ICHAR(D) is true.
CHARACTER INTEGER(2)
CHARACTER INTEGER(8)
1This specific function cannot be passed as an actual argument.
1633
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
ICHAR ( 'W' ) has the value 87.
ICHAR ( '#' ) has the value 35.
See Also
IACHAR
CHAR
ASCII and Key Code Charts
Syntax
CALL IDATE (i, j, k)
j (Output) Must be of type integer with the same kind type parameter
as i. It is the current day.
k (Output) Must be of type integer with the same kind type parameter
as i. It is the current year.
The current month is returned in i; the current day in j. The last two digits of the current year are returned
in k.
Caution
The two-digit year return value may cause problems with the year 2000. Use DATE_AND_TIME
instead.
Example
If the current date is September 16, 1999, the values of the integer variables upon return are: I = 9, J = 16,
and K = 99.
See Also
DATE intrinsic procedure
DATE_AND_TIME
GETDAT
1634
Language Reference
Module
USE IFPORT
Syntax
CALL IDATE (i, j, k)
-or-
CALL IDATE (iarray)
Caution
The two-digit year return value may cause problems with the year 2000. Use DATE_AND_TIME
instead.
Example
Consider the following:
use IFPORT
integer(4) imonth, iday, iyear, datarray(3)
! If the date is July 11, 1999:
CALL IDATE(IMONTH, IDAY, IYEAR)
! sets IMONTH to 7, IDAY to 11 and IYEAR to 99.
CALL IDATE (DATARRAY)
! datarray is (/11,7,99/)
See Also
DATE portability routine
DATE_AND_TIME
GETDAT
1635
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IDATE4
Portability Subroutine: Returns the month, day,
and year of the current system.
Module
USE IFPORT
Syntax
CALL IDATE4 (i,j,k)
-or-
CALL IDATE4 (iarray)
IDENT
General Compiler Directive: Specifies a string that
identifies an object module. The compiler places the
string in the identification field of an object module
when it generates the module for each source
program unit.
Syntax
!DIR$ IDENT string
Only the first IDENT directive is effective; the compiler ignores any additional IDENT directives in a program
unit or module.
See Also
General Compiler Directives
IDFLOAT
Portability Function: Converts an INTEGER(4)
argument to double-precision real type.
Module
USE IFPORT
1636
Language Reference
Syntax
result = IDFLOAT (i)
Results
The result type is double-precision real (REAL(8) or REAL*8).
See Also
DFLOAT
IEEE_CLASS
Elemental Module Intrinsic Function (Generic):
Returns the IEEE class.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_CLASS (x)
Results
The result is of type TYPE(IEEE_CLASS_TYPE). The result value is one of the following:
IEEE_SIGNALING_NAN IEEE_NEGATIVE_NORMAL
IEEE_QUIET_NAN IEEE_POSITIVE_DENORMAL
IEEE_POSITIVE_INF IEEE_NEGATIVE_DENORMAL
IEEE_NEGATIVE_INF IEEE_POSITIVE_ZERO
IEEE_POSITIVE_NORMAL IEEE_NEGATIVE_ZERO
Example
IEEE_CLASS(1.0) has the value IEEE_POSITIVE_NORMAL.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_COPY_SIGN
Elemental Module Intrinsic Function (Generic):
Returns an argument with a copied sign. This is
equivalent to the IEEE copysign function.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
1637
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
result = IEEE_COPY_SIGN (x,y)
Results
The result type and kind are the same as x. The result has the value x with the sign of y. This is true even for
IEEE special values, such as NaN or infinity.
The flags information is returned as a set of 1-bit flags.
Example
The value of IEEE_COPY_SIGN (X,3.0) is ABS (X), even when X is NaN.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_FLAGS
Portability Function: Gets, sets or clears IEEE flags
for rounding direction and precision as well as queries
or controls exception status. This function provides
easy access to the modes and status required to use
the features of ISO/IEC/IEEE 60559:2011 arithmetic
in a Fortran program.
Module
USE IFPORT
Syntax
result = IEEE_FLAGS (action,mode,in,out)
action (Input) Character*(*). One of the following literal values: 'GET', 'SET',
'CLEAR', or 'CLEARALL'.
Value Description
1638
Language Reference
Value Description
'negative'
'positive'
The values for in and out depend on the action and mode they are
used with. The interaction of the parameters can be summarized as
follows:
1639
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
CLEAR 'direction' Null (' ') Null (' ') Clears the
mode. Sets
rounding to
'nearest'.
Returns 0 if
successful.
1640
Language Reference
CLEARALL Null (' ') Null (' ') Null (' ') Clears all
flags. Sets
rounding to
'nearest',
sets
precision to
'double'
(W*S) or
'extended'
(L*X,
M*X), and
sets all
exception
flags to 0.
Returns 0 if
successful.
Results
IEEE_FLAGS is an elemental, integer-valued function that sets IEEE flags for GET, SET, CLEAR, or CLEARALL
procedures. It lets you control rounding direction and rounding precision, query exception status, and control
exception enabling or disabling by using the SET or CLEAR procedures, respectively.
The flags information is returned as a set of 1-bit flags.
Example
The following example gets the highest priority exception that has a flag raised. It passes the input argument
in as a null string:
USE IFPORT
INTEGER*4 iflag
CHARACTER*9 out
iflag = ieee_flags('get', 'exception', '', out)
PRINT *, out, ' flag raised'
1641
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The following example sets the rounding direction to round toward zero, unless the hardware does not
support directed rounding modes:
USE IFPORT
INTEGER*4 iflag
CHARACTER*10 mode, out, in
iflag = ieee_flags('set', 'direction', 'tozero', out)
The following example sets the rounding direction to the default ('nearest'):
USE IFPORT
INTEGER*4 iflag
CHARACTER*10 out, in
iflag = ieee_flags('clear','direction', '', '' )
The following example clears all exceptions:
USE IFPORT
INTEGER*4 iflag
CHARACTER*10 out
iflag = ieee_flags('clear','exception', 'all', '' )
The following example restores default direction and precision settings, and sets all exception flags to 0:
USE IFPORT
INTEGER*4 iflag
CHARACTER*10 mode, out, in
iflag = ieee_flags('clearall', '', '', '')
The following example detects an underflow exception:
USE IFPORT
CHARACTER*20 out, in
excep_detect = ieee_flags('get', 'exception', 'underflow', out)
if (out .eq.'underflow') stop 'underflow'
IEEE_FMA
Elemental Module Intrinsic Function (Generic):
Returns the result of a fused multiply-add operation.
This is equivalent to the IEEE fusedMultiplyAdd
operation.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_FMA (a,b,c)
b (Input) Must be of type REAL with the same kind type parameter as a.
c (Input) Must be of type REAL with the same kind type parameter as a.
Results
The result type is REAL with the same kind type parameter as a. When the result is in range, the value of the
result is the mathematical value of (a * b) + c rounded according to the rounding mode of the representation
method of a. Only the final step in the calculation may cause IEEE_INEXACT, IEEE_OVERFLOW, or
IEEE_UNDERFLOW to signal; intermediate calculations do not.
1642
Language Reference
Example
The result value of IEEE_FMA (TINY(0.0), TINY(0.0) 1.0) is equal to 1.0 when the rounding mode is set to
NEAREST. The exception IEEE_INEXACT is signaled.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_GET_FLAG
Elemental Module Intrinsic Subroutine
(Generic): Returns whether an exception flag is
signaling.
Module
USE, INTRINSIC :: IEEE_EXCEPTIONS
Syntax
CALL IEEE_GET_FLAG (flag, flag_value)
Example
Consider the following:
See Also
IEEE_EXCEPTIONS Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_GET_HALTING_MODE
Elemental Module Intrinsic Subroutine
(Generic): Stores the halting mode for an exception.
Module
USE, INTRINSIC :: IEEE_EXCEPTIONS
Syntax
CALL IEEE_GET_HALTING_MODE (flag, halting)
1643
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
Consider the following:
See Also
IEEE_EXCEPTIONS Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_GET_MODES
Intrinsic Module Subroutine (Generic): Stores the
current IEEE floating-point modes. This is an impure
subroutine.
Module
USE, INTRINSIC :: IEEE_EXCEPTIONS
Syntax
CALL IEEE_GET_MODES (modes)
Example
Consider the following:
See Also
IEEE_EXCEPTIONS Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
1644
Language Reference
IEEE_GET_ROUNDING_MODE
Intrinsic Module Subroutine (Generic): Stores the
current IEEE rounding mode. This is an impure
subroutine.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
CALL IEEE_GET_ROUNDING_MODE (round_value [, radix])
radix (Input; optional) Must be an integer scalar with a value of two or ten.
The rounding mode queried is the binary rounding mode, unless radix
is present with the value ten, in which case it is the decimal rounding
mode queried.
Example
Consider the following:
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_GET_STATUS
Intrinsic Module Subroutine (Generic): Stores the
current state of the floating-point environment. This is
an impure subroutine.
Module
USE, INTRINSIC :: IEEE_EXCEPTIONS
Syntax
CALL IEEE_GET_STATUS (status_value)
1645
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
Consider the following:
See Also
IEEE_EXCEPTIONS Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_GET_UNDERFLOW_MODE
Intrinsic Module Subroutine (Generic): Stores the
current underflow mode. This is an impure subroutine.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
CALL IEEE_GET_UNDERFLOW_MODE (gradual)
Example
Consider the following:
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
1646
Language Reference
IEEE_HANDLER
Portability Function: Establishes a handler for IEEE
exceptions.
Module
USE IFPORT
Syntax
result = IEEE_HANDLER (action, exception, handler)
action (Input) Character*(*). One of the following literal IEEE actions: 'GET',
'SET', or 'CLEAR'. For more details on these actions, see IEEE_FLAGS.
Results
The result type is INTEGER(4) on IA-32 architecture; INTEGER(8) on Intel® 64 architecture. The result is 0 if
successful; otherwise, 1.
IEEE_HANDLER calls a signal-handling routine to establish a handler for IEEE exceptions. It also enables an
FPU trap corresponding to the required exception.
The state of the FPU is not defined in the handler routine. When the FPU trap occurs, the program invokes
the handler routine. After the handler routine is executed, the program terminates.
The handler routine gets the exception code in the SIGINFO argument. SIGNO is the number of the system
signal. The meaning of the SIGINFO constants appear in the following table (defined in the IFPORT module):
FPE$ZERODIVIDE Divide-by-zero
'GET' actions return the location of the current handler routine for exception cast to an INTEGER.
Example
The following example creates a handler routine and sets it to trap divide-by-zero:
PROGRAM TEST_IEEE
REAL :: X, Y, Z
CALL FPE_SETUP
X = 0.
Y = 1.
Z = Y / X
END PROGRAM
SUBROUTINE FPE_SETUP
1647
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
USE IFPORT
IMPLICIT NONE
INTERFACE
SUBROUTINE FPE_HANDLER(SIGNO, SIGINFO)
INTEGER(4), INTENT(IN) :: SIGNO, SIGINFO
END SUBROUTINE
END INTERFACE
INTEGER IR
IR = IEEE_HANDLER('set','division',FPE_HANDLER)
END SUBROUTINE FPE_SETUP
SUBROUTINE FPE_HANDLER(SIG, CODE)
USE IFPORT
IMPLICIT NONE
INTEGER SIG, CODE
IF(CODE.EQ.FPE$ZERODIVIDE) PRINT *,'Occurred divide by zero.'
CALL ABORT
END SUBROUTINE FPE_HANDLER
See Also
IEEE_FLAGS
IEEE_INT
Elemental Module Intrinsic Function (Generic):
Enables conversion to INTEGER type.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_INT (a, round [, kind])
Results
The result type is INTEGER. If kind is present, the kind type parameter is that specified by kind; otherwise,
the kind type parameter is default integer.
The result is the value of a converted to integer according to the rounding mode specified by round if the
values can be represented in the representation method of the result type kind; otherwise, the result is
processor dependent and IEEE_INVALID is signaled.
The result must be consistent with the ISO/IEC/IEEE 60559:2011 operation convertToInteger{round} or
convertToIntegerExact{round}. The processor consistently chooses which operation is performed.
Example
The result value of IEEE_INT (63.5, IEEE_DOWN) is 63. If converToIntegerExact{round} is used,
IEEE_INEXACT will signal.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
1648
Language Reference
IEEE_IS_FINITE
Elemental Module Intrinsic Function (Generic):
Returns whether an IEEE value is finite.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_IS_FINITE (x)
Results
The result type is default logical. The result has the value true if the value of x is finite; otherwise, false.
An IEEE value is finite if IEEE_CLASS(x) has one of the following values:
IEEE_POSITIVE_NORMAL IEEE_NEGATIVE_DENORMAL
IEEE_NEGATIVE_NORMAL IEEE_POSITIVE_ZERO
IEEE_POSITIVE_DENORMAL IEEE_NEGATIVE_ZERO
Example
IEEE_IS_FINITE (-2.0) has the value true.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_IS_NAN
Elemental Module Intrinsic Function (Generic):
Returns whether an IEEE value is Not-a-Number
(NaN).
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_IS_NAN (x)
Results
The result type is default logical. The result has the value true if the value of x is NaN; otherwise, false.
Example
IEEE_IS_NAN (SQRT(-2.0)) has the value true if IEEE_SUPPORT_SQRT (2.0) has the value true.
See Also
IEEE_ARITHMETIC Intrinsic Module
1649
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IEEE_IS_NEGATIVE
Elemental Module Intrinsic Function (Generic):
Returns whether an IEEE value is negative.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_IS_NEGATIVE (x)
Results
The result type is default logical. The result has the value true if the value of x is negative; otherwise, false.
An IEEE value is negative if IEEE_CLASS(x) has one of the following values::
IEEE_NEGATIVE_NORMAL IEEE_NEGATIVE_ZERO
IEEE_NEGATIVE_DENORMAL IEEE_NEGATIVE_INF
Example
IEEE_IS_NEGATIVE (2.0) has the value false.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_IS_NORMAL
Elemental Module Intrinsic Function (Generic):
Returns whether an IEEE value is normal.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_IS_NORMAL (x)
Results
The result type is default logical. The result has the value true if the value of x is normal; otherwise, false.
An IEEE value is normal if IEEE_CLASS(x) has one of the following values:
IEEE_POSITIVE_NORMAL IEEE_POSITIVE_ZERO
IEEE_NEGATIVE_NORMAL IEEE_NEGATIVE_ZERO
Example
IEEE_IS_NORMAL (SQRT(-2.0)) has the value false if IEEE_SUPPORT_SQRT (-2.0) has the value true.
1650
Language Reference
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_LOGB
Elemental Module Intrinsic Function (Generic):
Returns a floating-point value equal to the unbiased
exponent of the argument. This is equivalent to the
IEEE logb function.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_LOGB (x)
Results
The result type and kind are the same as x. The result has the value of the unbiased exponent of x if the
value of x is not zero, infinity, or NaN. The value of the result is equal to EXPONENT(x) - 1.
If x is equal to 0, the result is -infinity if IEEE_SUPPORT_INF(x) is true; otherwise, -HUGE(x). In either case,
the IEEE_DIVIDE_BY_ZERO exception is signaled.
Example
IEEE_LOGB (3.4) has the value 1.0; IEEE_LOGB (4.0) has the value 2.0.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_MAX_NUM
Inquiry Module Intrinsic Function (Generic):
Returns the maximum of two values. This is
equivalent to the IEEE maxNum operation.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_MAX_NUM (x,y)
y (Input) Must be of type REAL with the same kind type parameter as x.
Results
The result type is REAL with the same kind type parameter as x. The result is x if y < x. The result is y if x <
y.
1651
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If one of the arguments is a quiet NaN, the result is the value of the argument which is not a quiet NaN. If
either or both of the arguments is a signaling NaN, the result is a NaN and IEEE_INVALID signals. Otherwise,
the result value is that of either x or y (processor dependent). No exceptions are signaled unless x or y is a
signaling NaN.
This is the maxNum operation as specified in the ISO/IEC/IEEE 60559:2011 standard.
Example
The result value of IEEE_MAX_NUM (3.7, IEEE_VALUE (0.0, IEEE_SIGNALING_NAN)) is a NaN. The exception
IEEE_INVALID is signaled.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_MAX_NUM_MAG
Inquiry Module Intrinsic Function (Generic):
Returns the maximum magnitude of two values. This
is equivalent to the IEEE maxNumMag operation.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_MAX_NUM_MAG (x,y)
y (Input) Must be of type REAL with the same kind type parameter as x.
Results
The result type is REAL with the same kind type parameter as x. The result is x if ABS(y) < ABS(x). The
result is the value of y if ABS(x) < ABS(y).
If one of the arguments is a quiet NaN, the result is the value of the argument which is not a quiet Nan. If
either or both of the arguments is a signaling NaN, the result is a NaN and IEEE_INVALID signals. Otherwise,
the result value is that of either x or y (processor dependent). No exceptions are signaled unless x or y is a
signaling NaN.
This is the maxNumMag operation as specified in the ISO/IEC/IEEE 60559:2011 standard.
Example
The result value of IEEE_MAX_NUM_MAG (3.7, -7.5) is -7.5.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_MIN_NUM
Inquiry Module Intrinsic Function (Generic):
Returns the minimum of two values. This is equivalent
to the IEEE minNum operation.
1652
Language Reference
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_MIN_NUM (x,y)
y (Input) Must be of type REAL with the same kind type parameter as x.
Results
The result type is REAL with the same kind type parameter as x. The result is x if x < y. The result is y if y <
x.
If one of the arguments is a quiet NaN, the result is the value of the argument which is not a quiet NaN. If
either or both of the arguments is a signaling NaN, the result is a NaN and IEEE_INVALID signals. Otherwise,
the result value is that of either x or y (processor dependent). No exceptions are signaled unless x or y is a
signaling NaN.
This is the minNum operation as specified in the ISO/IEC/IEEE 60559:2011 standard.
Example
The result value of IEEE_MIN_NUM (3.7, IEEE_VALUE (0.0, IEEE_QUIET _NAN)) is 3.7. No exceptions are
signaled.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_MIN_NUM_MAG
Inquiry Module Intrinsic Function (Generic):
Returns the minimum magnitude of two values. This is
equivalent to the IEEE minNumMag operation.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_MIN_NUM_MAG (x,y)
y (Input) Must be of type REAL with the same kind type parameter as x.
Results
The result type is REAL with the same kind type parameter as x. The result is y if ABS(y) < ABS(x). The
result is the value of x if ABS(x) < ABS(y).
If one of the arguments is a quiet NaN, the result is the value of the argument which is not a quiet NaN. If
either or both of the arguments is a signaling NaN, the result is a NaN and IEEE_INVALID signals. Otherwise,
the result value is that of either x or y (processor dependent). No exceptions are signaled unless x or y is a
signaling NaN.
This is the minNumMag operation as specified in the ISO/IEC/IEEE 60559:2011 standard.
1653
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
The result value of IEEE_MIN_NUM_MAG (3.7, -7.5) is 3.7.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_NEXT_AFTER
Elemental Module Intrinsic Function (Generic):
Returns the next representable value after X toward Y.
This is equivalent to the IEEE nextafter function.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_NEXT_AFTER (x,y)
Results
The result type and kind are the same as x. If x is equal to y, the result is x; no exception is signaled. If x is
not equal to y, the result has the value of the next representable neighbor of x toward y. The neighbors of
zero (of either sign) are both nonzero.
The following exceptions are signaled under certain cases:
Exception Signaled
Example
The value of IEEE_NEXT_AFTER (2.0,3.0) is 2.0 + EPSILON (X).
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_NEXT_DOWN
Elemental Module Intrinsic Function (Generic):
Returns the next lower adjacent machine number.
This is equivalent to the IEEE nextDown operation.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
1654
Language Reference
Syntax
result = IEEE_NEXT_DOWN (x)
Results
The result type and kind are the same as x. The value of the result is the greatest value that compares less
than x - except when x has the value NaN, the result is NaN, and when x has the value - ∞ , the result is -
∞ . If x is a signaling NaN, IEEE_INVALID signals; otherwise, no exception is signaled.
This is the nextDown operation as specified in the ISO/IEC/IEEE 60559:2011 standard.
Example
The value of IEEE_NEXT_DOWN(+0.0) is the negative subnormal number with the least magnitude if the
value if IEEE_SUPPORT_SUBNORMAL (0.0) is .TRUE..
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_NEXT_UP
Elemental Module Intrinsic Function (Generic):
Returns the next higher adjacent machine number.
This is equivalent to the IEEE nextUp operation.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_NEXT_UP (x)
Results
The result type and kind are the same as x. The value of the result is the least value that compares greater
than x - except when x has the value NaN, the result is NaN, and when x has the value + ∞, the result is +
∞. If x is a signaling NaN, IEEE_INVALID signals; otherwise, no exception is signaled.
This is the nextUp operation as specified in the ISO/IEC/IEEE 60559:2011 standard.
Example
The value of IEEE_NEXT_UP (HUGE (x)) is + ∞ if the value of IEEE_SUPPORT_INF (x) is .true..
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
1655
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IEEE_QUIET_EQ
Elemental Module Intrinsic Function (Generic):
Performs a non-signaling comparison for equality. This
is equivalent to the IEEE compareQuietEqual
operation.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_QUIET_EQ (a,b)
b (Input) Must be of type REAL with the same kind type parameter as a.
Results
The result type is default LOGICAL. It has the value true if a compares equal to b. If a or b is a NaN, the
result is false. IEEE_INVALID signals if either a or b is a signaling NaN, otherwise no exception is signaled.
This is the compareQuietEqual operation as specified in the ISO/IEC/IEEE 60559:2011 standard.
Example
The result value of IEEE_QUIET_EQ (3.7, IEEE_VALUE (0.0, IEEE_QUIET_NAN)) is false and no exception is
signaled.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_QUIET_GE
Elemental Module Intrinsic Function (Generic):
Performs a non-signaling comparison for greater than
or equal. This is equivalent to the IEEE
compareQuietGreaterEqual operation.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_QUIET_GE (a,b)
b (Input) Must be of type REAL with the same kind type parameter as a.
Results
The result type is default LOGICAL. It has the value true if a compares greater than or equal to b. If a or b is
a NaN, the result is false. IEEE_INVALID signals if either a or b is a signaling NaN, otherwise no exception is
signaled.
This is the compareQuietGreaterEqual operation as specified in the ISO/IEC/IEEE 60559:2011 standard.
1656
Language Reference
Example
The result value of IEEE_QUIET_GE (3.7, IEEE_VALUE (0.0, IEEE_QUIET_NAN)) is false and no exception is
signaled.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_QUIET_GT
Elemental Module Intrinsic Function (Generic):
Performs a non-signaling comparison for greater than.
This is equivalent to the IEEE compareQuietGreater
operation.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_QUIET_GT (a,b)
b (Input) Must be of type REAL with the same kind type parameter as a.
Results
The result type is default LOGICAL. It has the value true if a compares greater than b. If a or b is a NaN, the
result is false. IEEE_INVALID signals if either a or b is a signaling NaN, otherwise no exception is signaled.
This is the compareQuietGreater operation as specified in the ISO/IEC/IEEE 60559:2011 standard.
Example
The result value of IEEE_QUIET_GT (3.7, IEEE_VALUE (0.0, IEEE_QUIET_NAN)) is false and no exception is
signaled.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_QUIET_LE
Elemental Module Intrinsic Function (Generic):
Performs a non-signaling comparison for less than or
equal. This is equivalent to the IEEE
compareQuietLessEqual operation.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_QUIET_LE (a,b)
1657
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
b (Input) Must be of type REAL with the same kind type parameter as a.
Results
The result type is default LOGICAL. It has the value true if a compares less than or equal to b. If a or b is a
NaN, the result is false. IEEE_INVALID signals if either a or b is a signaling NaN, otherwise no exception is
signaled.
This is the compareQuietLessEqual operation as specified in the ISO/IEC/IEEE 60559:2011 standard.
Example
The result value of IEEE_QUIET_LE (3.7, IEEE_VALUE (0.0, IEEE_QUIET_NAN)) is false and no exception is
signaled.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_QUIET_LT
Elemental Module Intrinsic Function (Generic):
Performs a non-signaling comparison for less than.
This is equivalent to the IEEE compareQuietLess
operation.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_QUIET_LT (a,b)
b (Input) Must be of type REAL with the same kind type parameter as a.
Results
The result type is default LOGICAL. It has the value true if a compares less than b. If a or b is a NaN, the
result is false. IEEE_INVALID signals if either a or b is a signaling NaN, otherwise no exception is signaled.
This is the compareQuietLess operation as specified in the ISO/IEC/IEEE 60559:2011 standard.
Example
The result value of IEEE_QUIET_LT (3.7, IEEE_VALUE (0.0, IEEE_QUIET_NAN)) is false and no exception is
signaled.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_QUIET_NE
Elemental Module Intrinsic Function (Generic):
Performs a non-signaling comparison for inequality.
This is equivalent to the IEEE compareQuietNotEqual
operation.
1658
Language Reference
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_QUIET_NE (a,b)
b (Input) Must be of type REAL with the same kind type parameter as a.
Results
The result type is default LOGICAL. It has the value true if a compares not equal to b. If a or b is a NaN, the
result is true. IEEE_INVALID signals if either a or b is a signaling NaN, otherwise no exception is signaled.
This is the compareQuietNotEqual operation specified as specified in the ISO/IEC/IEEE 60559:2011 standard.
Example
The result value of IEEE_QUIET_NE (3.7, IEEE_VALUE (0.0, IEEE_QUIET_NAN)) is true and no exception is
signaled.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_REAL
Elemental Module Intrinsic Function (Generic):
Enables conversion to REAL type.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_REAL (a [, kind])
Results
The result type is REAL. If kind is present, the kind type parameter is that specified by kind; otherwise, the
kind type parameter is default real.
The result has the same value as a if that value is representable in the representation method of the result
type kind; otherwise, it is rounded according to the current rounding mode.
The result must be consistent with the ISO/IEC/IEEE 60559:2011 operation convertFromInt if a is an integer,
and with operation convertFormat if a is real.
Example
The result value of IEEE_REAL (987) is 987.0.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
1659
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IEEE_REM
Elemental Module Intrinsic Function (Generic):
Returns the result of an exact remainder operation.
This is equivalent to the IEEE remainder function.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_REM (x,y)
y (Input) Must be of type REAL with a radix that is the same as that of
x.
Results
The result type is real with the kind type parameter of whichever argument has greater precision.
Regardless of the rounding mode, the result value is x - y*N, where N is the integer nearest to the value x /
y. If |N – x / y | = 1/2, N is even. If the result value is zero, the sign is the same as x.
Example
The value of IEEE_REM (5.0,4.0) is 1.0; the value of IEEE_REM (2.0,1.0) is 0.0; the value of IEEE_REM
(3.0,2.0) is -1.0.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_RINT
Elemental Module Intrinsic Function (Generic):
Returns an integer value rounded according to the
current rounding mode.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_RINT (x [, round])
Results
The result type and kind are the same as x.
The value of the result is x rounded to an integer according to the current rounding mode if round is not
present. If round is present, the value of the result is x rounded to an integer according to the mode
specified by round; this is the operation roundToInteger (rounding) as specified by ISO/IEC/IEEE
60559:2011.
1660
Language Reference
Example
If the current rounding mode is IEEE_UP, the value of IEEE_RINT (2.2) is 3.0.
If the current rounding mode is IEEE_NEAREST, the value of IEEE_RINT (2.2) is 2.0.
The value of IEEE_RINT (7.4, IEEE_DOWN) is 7.0.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_SCALB
Elemental Module Intrinsic Function (Generic):
Returns the exponent of a radix-independent floating-
point number. This is equivalent to the IEEE scalb
function.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_SCALB (x,i)
Results
The result type and kind are the same as x. The result is x multiplied by 2**i, if the value can be represented
as a normal number.
If x (2**i) is too small and there is a loss of accuracy, the exception IEEE_UNDERFLOW is signaled. The
result value is the nearest number that can be represented with the same sign as x.
If x is finite and x (2**i) is too large, an IEEE_OVERFLOW exception occurs. If IEEE_SUPPORT_INF (x) is
true, the result value is infinity with the same sign as x; otherwise, the result value is SIGN (HUGE(x), x).
If x is infinite, the result is the same as x; no exception is signaled.
Example
The value of IEEE_SCALB (2.0,3) is 16.0.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_SELECTED_REAL_KIND
Transformational Module Intrinsic Function
(Generic): Returns the value of the kind parameter of
an IEEE REAL data type.
1661
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_SELECTED_REAL_KIND ([p][,r][,radix])
Results
If p or r is absent, the result is as if the argument was present with the value zero. If radix is absent, there
is no requirement on the radix of the selected kind.
The result is a scalar of type default integer. The result has a value equal to a value of the kind parameter of
an IEEE real data type with decimal precision, as returned by the function PRECISION, of at least p digits, a
decimal exponent range, as returned by the function RANGE, of at least r, and a radix, as returned by the
function RADIX, of radix.
If no such kind type parameter is available on the processor, the result is as follows:
If more than one kind type parameter value meets the criteria, the value returned is the one with the
smallest decimal precision.
Example
IEEE_SELECTED_REAL_KIND (6, 70, 2) = 8.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
SELECTED_REAL_KIND
Model for Real Data
for information on the real model.
IEEE_SET_FLAG
Elemental Module Intrinsic Function (Generic):
Assigns a value to an exception flag. This is a pure
subroutine.
Module
USE, INTRINSIC :: IEEE_EXCEPTIONS
Syntax
CALL IEEE_SET_FLAG (flag,flag_value)
1662
Language Reference
flag_value (Output) Must be of type logical. If it has the value true, the exception
in flag is set to signal; otherwise, the exception is set to be quiet.
Example
Consider the following:
See Also
IEEE_EXCEPTIONS Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_SET_HALTING_MODE
Elemental Module Intrinsic Function (Generic):
Controls halting or continuation after an exception.
This is a pure subroutine.
Module
USE, INTRINSIC :: IEEE_EXCEPTIONS
Syntax
CALL IEEE_SET_HALTING_MODE (flag, halting)
halting (Input) Must be scalar and of type logical. If the value is true, the
exception specified in flag will cause halting; otherwise, execution will
continue after this exception.
Example
Consider the following:
See Also
IEEE_EXCEPTIONS Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
1663
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IEEE_SET_MODES
Intrinsic Module Subroutine (Generic): Restores
the current IEEE floating-point modes. This is an
impure subroutine.
Module
USE, INTRINSIC :: IEEE_EXCEPTIONS
Syntax
CALL IEEE_SET_MODES (modes)
Example
Consider the following:
See Also
IEEE_EXCEPTIONS Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_SET_ROUNDING_MODE
Intrinsic Module Subroutine (Generic): Sets the
IEEE rounding mode. This is an impure subroutine.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
CALL IEEE_SET_ROUNDING_MODE (round_value [, radix])
radix (Input; optional) Must be an integer scalar with a value of ten or two.
The rounding mode set is the binary rounding mode unless radix is
present with the value of ten, in which case it is the decimal rounding
mode set.
1664
Language Reference
Example
Consider the following:
IEEE_SET_STATUS
Intrinsic Module Subroutine (Generic): Restores
the state of the floating-point environment. This is an
impure subroutine.
Module
USE, INTRINSIC :: IEEE_EXCEPTIONS
Syntax
CALL IEEE_SET_STATUS (status_value)
Example
Consider the following:
IEEE_SET_UNDERFLOW_MODE
Intrinsic Module Subroutine (Generic): Sets the
current underflow mode. This is an impure subroutine.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
CALL IEEE_SET_UNDERFLOW_MODE (gradual)
gradual (Input) Must be scalar and of type logical. If it is true, the current
underflow mode is set to gradual underflow (subnormals may be
produced on underflow). If it is false, the current underflow mode is
set to abrupt (underflowed results are set to zero).
1665
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
Consider the following:
IEEE_SIGNALING_EQ
Elemental Module Intrinsic Function (Generic):
Performs a signaling comparison for equality. This is
equivalent to the IEEE compareSignalingEqual
operation.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_SIGNALING_EQ (a,b)
b (Input) Must be of type REAL with the same kind type parameter as a.
Results
The result type is default LOGICAL. It has the value true if a compares equal to b. If a or b is a NaN, the
result is false and IEEE_INVALID signals, otherwise no exception is signaled.
This is the compareSignalingEqual operation as specified in the ISO/IEC/IEEE 60559:2011 standard.
Example
The result value of IEEE_SIGNALING_EQ (3.7, IEEE_VALUE (0.0, IEEE_QUIET_NAN)) is false and
IEEE_INVALID is signaled.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_SIGNALING_GE
Elemental Module Intrinsic Function (Generic):
Performs a signaling comparison for greater than or
equal. This is equivalent to the IEEE
compareSignalingGreaterEqual operation.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_SIGNALING_GE (a,b)
1666
Language Reference
b (Input) Must be of type REAL with the same kind type parameter as a.
Results
The result type is default LOGICAL. It has the value true if a compares greater than or equal to b. If a or b is
a NaN, the result is false and IEEE_INVALID signals, otherwise no exception is signaled.
This is the compareSignalingGreaterEqual operation as specified in the ISO/IEC/IEEE 60559:2011 standard.
Example
The result value of IEEE_SIGNALING_GE (3.7, IEEE_VALUE (0.0, IEEE_QUIET_NAN)) is false and
IEEE_INVALID is signaled.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_SIGNALING_GT
Elemental Module Intrinsic Function (Generic):
Performs a signaling comparison for greater than. This
is equivalent to the IEEE compareSignalingGreater
operation.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_SIGNALING_GT (a,b)
b (Input) Must be of type REAL with the same kind type parameter as a.
Results
The result type is default LOGICAL. It has the value true if a compares greater than b. If a or b is a NaN, the
result is false and IEEE_INVALID signals, otherwise no exception is signaled.
This is the compareSignalingGreater operation as specified in the ISO/IEC/IEEE 60559:2011 standard.
Example
The result value of IEEE_SIGNALING_GT (3.7, IEEE_VALUE (0.0, IEEE_QUIET_NAN)) is false and
IEEE_INVALID is signaled.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
1667
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IEEE_SIGNALING_LE
Elemental Module Intrinsic Function (Generic):
Performs a signaling comparison for less than or
equal. This is equivalent to the IEEE
compareSignalingLessEqual operation.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_SIGNALING_LE (a,b)
b (Input) Must be of type REAL with the same kind type parameter as a.
Results
The result type is default LOGICAL. It has the value true if a compares less than or equal to b. If a or b is a
NaN, the result is false and IEEE_INVALID signals, otherwise no exception is signaled.
This is the compareSignalingLessEqual operation as specified in the ISO/IEC/IEEE 60559:2011 standard.
Example
The result value of IEEE_SIGNALING_LE (3.7, IEEE_VALUE (0.0, IEEE_QUIET_NAN)) is false and
IEEE_INVALID is signaled.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_SIGNALING_LT
Elemental Module Intrinsic Function (Generic):
Performs a signaling comparison for less than. This is
equivalent to the IEEE compareSignalingLess
operation.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_SIGNALING_LT (a,b)
b (Input) Must be of type REAL with the same kind type parameter as a.
Results
The result type is default LOGICAL. It has the value true if a compares less than b. If a or b is a NaN, the
result is false and IEEE_INVALID signals, otherwise no exception is signaled.
This is the compareSignalingLess operation as specified in the ISO/IEC/IEEE 60559:2011 standard.
1668
Language Reference
Example
The result value of IEEE_SIGNALING_LT (3.7, IEEE_VALUE (0.0, IEEE_QUIET_NAN)) is false and
IEEE_INVALID is signaled.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_SIGNALING_NE
Elemental Module Intrinsic Function (Generic):
Performs a signaling comparison for inequality. This is
equivalent to the IEEE compareSignalingNotEqual
operation.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_SIGNALING_NE (a,b)
b (Input) Must be of type REAL with the same kind type parameter as a.
Results
The result type is default LOGICAL. It has the value true if a compares not equal to b. If a or b is a NaN, the
result is true and IEEE_INVALID signals, otherwise no exception is signaled.
This is the compareSignalingNotEqual operation as specified in the ISO/IEC/IEEE 60559:2011 standard.
Example
The result value of IEEE_SIGNALING_NE (3.7, IEEE_VALUE (0.0, IEEE_QUIET_NAN)) is true and
IEEE_INVALID is signaled.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_SIGNBIT
Elemental Module Intrinsic Function (Generic):
Tests to determine if the argument's sign bit is set.
This is equivalent to the IEEE SignMinus operation.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_SIGNBIT (x)
1669
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result is a scalar of type default logical. The result has the value .true. if the sign bit of x is set
(nonzero); otherwise, it has the value .false.. No exception is signaled even if x has the value of a signaling
NaN.
This is the SignMinus operation as specified in the ISO/IEC/IEEE 60559:2011 standard.
Example
The result of IEEE_SIGNBIT (-3.14) is .true..
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_SUPPORT_DATATYPE
Inquiry Module Intrinsic Function (Generic):
Returns whether the processor supports IEEE
arithmetic.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_SUPPORT_DATATYPE ([x])
Results
The result is a scalar of type default logical. If x is omitted, the result has the value true if the processor
supports IEEE arithmetic for all real values; otherwise, false.
If x is specified, the result has the value true if the processor supports IEEE arithmetic for real variables of
the same kind type parameter as x; otherwise, false.
If real values are implemented according to the IEEE standard except that underflowed values flush to zero
(abrupt) instead of being subnormal.
Example
IEEE_SUPPORT_DATATYPE (3.0) has the value true.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_SUPPORT_DENORMAL
Inquiry Module Intrinsic Function (Generic):
Returns whether the processor supports IEEE
subnormal numbers.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
1670
Language Reference
Syntax
result = IEEE_SUPPORT_DENORMAL ([x])
Results
The result is a scalar of type default logical. If x is omitted, the result has the value true if the processor
supports arithmetic operations and assignments with subnormal numbers for all real values; otherwise, false.
If x is specified, the result has the value true if the processor supports arithmetic operations and assignments
with subnormal numbers for real variables of the same kind type parameter as x; otherwise, false.
IEEE_SUPPORT_DENORMAL() and IEEE_SUPPORT_DENORMAL(0.0_16) return .TRUE. even though Intel®
Fortran’s implementation does not signal when an underflow results in a REAL(16) denormal value. Intel®
Fortran’s implementation does signal when an underflow results in a REAL(16) zero.
Example
IEEE_SUPPORT_DENORMAL () has the value true if IEEE subnormal numbers are supported for all real types.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_SUPPORT_DIVIDE
Inquiry Module Intrinsic Function (Generic):
Returns whether the processor supports IEEE divide.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_SUPPORT_DIVIDE ([x])
Results
The result is a scalar of type default logical. If x is omitted, the result has the value true if the processor
supports divide with the accuracy specified by the IEEE standard for all real values; otherwise, false.
If x is specified, the result has the value true if the processor supports divide with the accuracy specified by
the IEEE standard for real variables of the same kind type parameter as x; otherwise, false.
Example
IEEE_SUPPORT_DIVIDE ( ) has the value true if IEEE divide is supported for all real types.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
1671
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IEEE_SUPPORT_FLAG
Transformational Module Intrinsic Function
(Generic): Returns whether the processor supports
IEEE exceptions.
Module
USE, INTRINSIC :: IEEE_EXCEPTIONS
Syntax
result = IEEE_SUPPORT_FLAG (flag [, x])
Results
The result is a scalar of type default logical. If x is omitted, the result has the value true if the processor
supports detection of the exception specified by flag for all real values; otherwise, false.
If x is specified, the result has the value true if the processor supports detection of the exception specified by
flag for real variables of the same kind type parameter as x; otherwise, false.
Example
IEEE_SUPPORT_FLAG (IEEE_UNDERFLOW) has the value true if the IEEE_UNDERFLOW exception is
supported for all real types.
See Also
IEEE_EXCEPTIONS Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_SUPPORT_HALTING
Transformational Module Intrinsic Function
(Generic): Returns whether the processor supports
IEEE halting.
Module
USE, INTRINSIC :: IEEE_EXCEPTIONS
Syntax
result = IEEE_SUPPORT_HALTING(flag)
1672
Language Reference
Results
The result is a scalar of type default logical. The result has the value true if the processor supports the ability
to control halting after the exception specified by flag; otherwise, false.
Example
IEEE_SUPPORT_HALTING (IEEE_UNDERFLOW) has the value true if halting is supported after an
IEEE_UNDERFLOW exception
See Also
IEEE_EXCEPTIONS Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_SUPPORT_INF
Inquiry Module Intrinsic Function (Generic):
Returns whether the processor supports IEEE
infinities.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_SUPPORT_INF ([x])
Results
The result is a scalar of type default logical. If x is omitted, the result has the value true if the processor
supports IEEE infinities (positive and negative) for all real values; otherwise, false.
If x is specified, the result has the value true if the processor supports IEEE infinities for real variables of the
same kind type parameter as x; otherwise, false.
Example
IEEE_SUPPORT_INF( ) has the value true if IEEE infinities are supported for all real types.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_SUPPORT_IO
Inquiry Module Intrinsic Function (Generic):
Returns whether the processor supports IEEE base
conversion rounding during formatted I/O.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_SUPPORT_IO ([x])
1673
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result is a scalar of type default logical. If x is omitted, the result has the value true if the processor
supports base conversion rounding during formatted input and output for all real values; otherwise, false.
If x is specified, the result has the value true if the processor supports base conversion rounding during
formatted input and output for real variables of the same kind type parameter as x; otherwise, false.
The base conversion rounding applies to modes IEEE_UP, IEEE_DOWN, IEEE_TO_ZERO, and IEEE_NEAREST.
Example
IEEE_SUPPORT_IO ( ) has the value true if base conversion rounding is supported for all real types during
formatted I/O.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_SUPPORT_NAN
Inquiry Module Intrinsic Function (Generic):
Returns whether the processor supports IEEE Not-a-
Number feature.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_SUPPORT_NAN ([x])
Results
The result is a scalar of type default logical. If x is omitted, the result has the value true if the processor
supports NaNs for all real values; otherwise, false.
If x is specified, the result has the value true if the processor supports NaNs for real variables of the same
kind type parameter as x; otherwise, false.
Example
IEEE_SUPPORT_NAN () has the value true if IEEE NaNs are supported for all real types.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_SUPPORT_ROUNDING
Transformational Module Intrinsic Function
(Generic): Returns whether the processor supports
IEEE rounding mode.
1674
Language Reference
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_SUPPORT_ROUNDING (round_value [, x])
Results
The result is a scalar of type default logical. If x is omitted, the result has the value true if the processor
supports the rounding mode specified by round_value for all real values; otherwise, false.
If x is specified, the result has the value true if the processor supports the rounding mode specified by
round_value for real variables of the same kind type parameter as x; otherwise, false.
Example
IEEE_SUPPORT_ROUNDING (IEEE_DOWN) has the value true if rounding mode IEEE_DOWN is supported for
all real types.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_SUPPORT_SQRT
Inquiry Module Intrinsic Function (Generic):
Returns whether the processor supports IEEE SQRT
(square root).
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_SUPPORT_SQRT ([x])
Results
The result is a scalar of type default logical. If x is omitted, the result has the value true if the processor
implements SQRT in accord with the IEEE standard for all real values; otherwise, false.
If x is specified, the result has the value true if the processor implements SQRT in accord with the IEEE
standard for real variables of the same kind type parameter as x; otherwise, false.
Example
IEEE_SUPPORT_SQRT ( ) has the value true if IEEE SQRT is supported for all real types.
1675
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_SUPPORT_STANDARD
Inquiry Module Intrinsic Function (Generic):
Returns whether the processor supports IEEE features
defined in the standard.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_SUPPORT_STANDARD ([x])
Results
The result is a scalar of type default logical. The result has the value true if the results of all the following
functions are true (x can be omitted):
IEEE_SUPPORT_DATATYPE([x])
IEEE_SUPPORT_DENORMAL([x])
IEEE_SUPPORT_DIVIDE([x])
IEEE_SUPPORT_FLAG(flag [, x])1
IEEE_SUPPORT_HALTING(flag)1
IEEE_SUPPORT_INF([x])
IEEE_SUPPORT_NAN([x])
IEEE_SUPPORT_ROUNDING(round_value [, x])2
IEEE_SUPPORT_SQRT([x])
1 "flag" must be a valid value
2 "round_value" must be a valid value
Example
IEEE_SUPPORT_STANDARD () has the value false if both IEEE and non-IEEE real kinds are supported.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
1676
Language Reference
IEEE_SUPPORT_SUBNORMAL
Inquiry Module Intrinsic Function (Generic):
Returns whether the processor supports IEEE
subnormal numbers.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_SUPPORT_SUBNORMAL ([x])
Results
The result is a scalar of type default logical. If x is omitted, the result has the value true if the processor
supports arithmetic operations and assignments with subnormal numbers for all real values; otherwise, false.
If x is specified, the result has the value true if the processor supports arithmetic operations and assignments
with subnormal numbers for real variables of the same kind type parameter as x; otherwise, false.
IEEE_SUPPORT_SUBNORMAL () and IEEE_SUPPORT_SUBNORMAL (0.0_16) return .TRUE. even though Intel®
Fortran’s implementation does not signal when an underflow results in a REAL (16) subnormal value. Intel®
Fortran’s implementation does signal when an underflow results in a REAL (16) zero.
Example
IEEE_SUPPORT_SUBNORMAL () has the value true if IEEE subnormal numbers are supported for all real
types.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_SUPPORT_UNDERFLOW_CONTROL
Inquiry Module Intrinsic Function (Generic):
Returns whether the processor supports the ability to
control the underflow mode.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_SUPPORT_UNDERFLOW_CONTROL ([x])
Results
The result is a scalar of type default logical. If x is omitted, the result has the value true if the processor
supports controlling the underflow mode for all real values; otherwise, false.
If x is specified, the result has the value true if the processor supports controlling the underflow mode for
real variables of the same kind type parameter as x; otherwise, false.
1677
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
IEEE_SUPPORT_UNDERFLOW _CONTROL () has the value true if controlling the underflow mode is supported
for all real types.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_UNORDERED
Elemental Module Intrinsic Function (Generic):
Returns whether one or more of the arguments is Not-
a-Number (NaN). This is equivalent to the IEEE
unordered function.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_UNORDERED (x,y)
Results
The result type is default logical. The result has the value true if x or y is a NaN, or both are NaNs;
otherwise, false.
Example
IEEE_UNORDERED (0.0, SQRT(-2.0)) has the value true if IEEE_SUPPORT_SQRT (2.0) has the value true.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_VALUE
Elemental Module Intrinsic Function (Generic):
Creates an IEEE value.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_VALUE (x, class)
IEEE_SIGNALING_NAN IEEE_NEGATIVE_NORMAL
1678
Language Reference
IEEE_QUIET_NAN IEEE_POSITIVE_DENORMAL
IEEE_POSITIVE_INF IEEE_NEGATIVE_DENORMAL
IEEE_NEGATIVE_INF IEEE_POSITIVE_ZERO
IEEE_POSITIVE_NORMAL IEEE_NEGATIVE_ZERO
Results
The result type and kind are the same as x. The result value is an IEEE value as specified by "class".
When IEEE_VALUE returns a signaling NaN, it is processor dependent whether or not invalid is signaled and
processor dependent whether or not the signaling NaN is converted to a quiet NaN.
Example
IEEE_VALUE (1.0,IEEE_POSITIVE_INF) has the value +infinity.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEOR
Elemental Intrinsic Function (Generic): Performs
an exclusive OR on corresponding bits. This function
can also be specified as XOR or IXOR.
Syntax
result = IEOR (i,j)
Results
The result is the same as i if i is of type integer or logical; otherwise, the result is the same as j. If either i or
j is a binary, octal, or hexadecimal literal constant, it is first converted as if by the intrinsic function INT to
type integer with the kind type parameter of the other.
The result value is derived by combining i and j bit-by-bit according to the following truth table:
i j IEOR (i, j)
1 1 0
1 0 1
0 1 1
0 0 0
The model for the interpretation of an integer value as a sequence of bits is shown in Model for Bit Data.
1679
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
IEOR (12, 7) has the value 11; binary 1100 exclusive OR with binary 0111 is binary 1011.
The following shows another example:
INTEGER I
I = IEOR(240, 90) ! returns 170
! IEOR (B'11110000', B'1011010') == B'10101010'
The following shows an example using alternate option XOR:
INTEGER i, j, k
i = 3 ! B'011'
j = 5 ! B'101'
k = XOR(i, j) ! returns 6 = B'110'
See Also
Binary, Octal, Hexadecimal, and Hollerith Constants
IAND
IOR
NOT
IALL
IANY
IPARITY
IERRNO
Portability Function: Returns the number of the last
detected error from any routines in the IFPORT
module that return error codes.
Module
USE IFPORT
Syntax
result = IERRNO( )
1680
Language Reference
Results
The result type is INTEGER(4). The result value is the last error code from any portability routines that return
error codes. These error codes are analogous to errno on a Linux* or macOS* system. The module
IFPORT.F90 provides parameter definitions for the following errno names (typically found in errno.h on
Linux systems):
The value returned by IERRNO is updated only when an error occurs. For example, if an error occurs on a
GETLOG call and then two CHMOD calls succeed, a subsequent call to IERRNO returns the error for the
GETLOG call.
Examine IERRNO immediately after returning from a portability routine. IERRNO is set on a per thread basis.
Example
USE IFPORT
CHARACTER*20 username
INTEGER(4) ierrval
ierrval=0 !initialize return value
CALL GETLOG(username)
IF (IERRNO( ) == ierrval) then
print *, 'User name is ',username
exit
ELSE
ierrval = ierrno()
print *, 'Error is ',ierrval
END IF
IF - Arithmetic
Statement: Conditionally transfers control to one of
three statements, based on the value of an arithmetic
expression. The arithmetic IF statement is a deleted
feature in the Fortran Standard. Intel® Fortran fully
supports features deleted in the Fortran Standard.
1681
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
IF (expr) label1,label2,label3
label1, label2, label3 Are the labels of valid branch target statements that are in the same
scoping unit as the arithmetic IF statement.
Description
All three labels are required, but they do not need to refer to three different statements. The same label can
appear more than once in the same arithmetic IF statement.
During execution, the expression is evaluated first. Depending on the value of the expression, control is then
transferred as follows:
Example
The following example transfers control to statement 50 if the real variable THETA is less than or equal to the
real variable CHI. Control passes to statement 100 only if THETA is greater than CHI.
IF (THETA-CHI) 50,50,100
The following example transfers control to statement 40 if the value of the integer variable NUMBERis even. It
transfers control to statement 20 if the value is odd.
See Also
SELECT CASE...END SELECT
Execution Control
Deleted Language Features in the Fortran Standard
IF - Logical
Statement: Conditionally executes one statement
based on the value of a logical expression. (This
statement was called a logical IF statement in
FORTRAN 77.)
Syntax
IF (expr) stmt
1682
Language Reference
When an IF statement is executed, the logical expression is evaluated first. If the value is true, the
statement is executed. If the value is false, the statement is not executed and control transfers to the next
statement in the program.
Example
The following examples show valid IF statements:
USE IFPORT
INTEGER(4) istat, errget
character(inchar)
real x
istat = getc(inchar)
IF (istat) errget = -1
...
! IF (x .GT. 2.3) call new_subr(x)
...
See Also
IF Construct
Execution Control
IF Clause
Parallel Directive Clause: Specifies a conditional
expression. If the expression evaluates to .FALSE., the
construct is not executed.
Syntax
IF ([directive-name-modifier:] scalar-logical-expression)
directive-name-modifier Names the associated construct that the IF clause applies to.
Currently, you can specify one of the following associated constructs
(directives): PARALLEL, SIMD, TARGET DATA, TARGET, TARGET
UPDATE, TARGET ENTER DATA, TARGET EXIT DATA, TASK, or
TASKLOOP.
These directives are only available on Linux* systems: TARGET DATA,
TARGET, TARGET UPDATE, TARGET ENTER DATA, TARGET EXIT DATA.
1683
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
At most one IF clause can appear in a non-combined directive. In combined directives, IF clauses with
different directive-name-modifiers can occur, at most one for each constituent directive making up the
combined directive where IF is allowed.
Description
The effect of the IF clause depends on the construct to which it is applied:
• For combined or composite constructs, the IF clause only applies to the semantics of the construct named
in the directive-name-modifier if one is specified.
• If no directive-name-modifier is specified for a combined or composite construct then the IF clause applies
to all constructs to which an IF clause can apply.
The following are additional rules that apply to specific OpenMP Fortran directives:
• For the CANCEL OpenMP* Fortran directive, if scalar-logical-expression evaluates to false, the construct
does not request cancellation. Note that directive-name-modifier cannot specify CANCEL.
• For the PARALLEL OpenMP Fortran directive:
• The enclosed code section is executed in parallel only if scalar-logical-expression evaluates to .TRUE..
Otherwise, the parallel region is serialized. If this clause is not used, the region is executed as if an
IF(.TRUE.) clause were specified.
• This clause is evaluated in the context outside of this construct.
• For the SIMD OpenMP Fortran directive, if scalar-logical-expression evaluates to .FALSE., the number of
iterations to be executed concurrently is one.
• For the TARGET OpenMP Fortran directive, if scalar-logical-expression evaluates to .FALSE., the target
region is not executed by the device. It is executed by the encountering task.
• For the TARGET DATA OpenMP Fortran directive, if scalar-logical-expression evaluates to .FALSE., the new
device data environment is not created.
• For the TARGET UPDATE OpenMP Fortran directive, if scalar-logical-expression evaluates to .FALSE., the
TARGET UPDATE directive is ignored.
• For the TASK OpenMP Fortran directive:
• If scalar-logical-expression evaluates to .FALSE., the encountering thread must suspend the current
task region and begin execution of the generated task immediately. The suspended task region will not
be resumed until the generated task is completed.
• This clause is evaluated in the context outside of this construct.
IF Construct
Statement: Conditionally executes one block of
constructs or statements depending on the evaluation
of a logical expression. (This construct was called a
block IF statement in FORTRAN 77.)
Syntax
[name:] IF (expr) THEN
block
[ELSE IF (expr) THEN [name]
block]
[ELSE [name]
block]
END IF [name]
1684
Language Reference
Description
If a construct name is specified at the beginning of an IF THEN statement, the same name must appear in
the corresponding END IF statement. If a construct name is specified on an ELSE IF or ELSE statement, the
same name must appear in the corresponding IF THEN and END IF statements.
The same construct name must not be used for different named constructs in the same scoping unit.
Depending on the evaluation of the logical expression, one block or no block is executed. The logical
expressions are evaluated in the order in which they appear, until a true value is found or an ELSE or END IF
statement is encountered.
Once a true value is found or an ELSE statement is encountered, the block immediately following it is
executed and the construct execution terminates.
If none of the logical expressions evaluate to true and no ELSE statement appears in the construct, no block
in the construct is executed and the construct execution terminates.
NOTE
No additional statement can be placed after the IF THEN statement in a block IF construct.
For example, the following statement is invalid in the block IF construct:
IF (e) THEN I = J
This statement is translated as the following logical IF statement:
IF (e) THENI = J
You cannot use branching statements to transfer control to an ELSE IF statement or ELSE statement.
However, you can branch to an END IF statement from within the IF construct.
The following figure shows the flow of control in IF constructs:
1685
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
You can include an IF construct in the statement block of another IF construct, if the nested IF construct is
completely contained within a statement block. It cannot overlap statement blocks.
1686
Language Reference
Example
The following example shows the simplest form of an IF construct:
Form Example
IF (expr) THEN IF (ABS(ADJU) .GE. 1.0E-6) THEN
block TOTERR = TOTERR + ABS(ADJU)
QUEST = ADJU/FNDVAL
END IF END IF
This construct conditionally executes the block of statements between the IF THEN and the END IF
statements.
The following shows another example:
Form Example
IF (expr) THEN IF (NAME .LT. 'N') THEN
block1 IFRONT = IFRONT + 1
FRLET(IFRONT) = NAME(1:2)
ELSE ELSE
block2 IBACK = IBACK + 1
END IF END IF
Block1 consists of all the statements between the IF THEN and ELSE statements. Block2 consists of all the
statements between the ELSE and the END IF statements.
If the value of the character variable NAME is less than 'N ', block1 is executed. If the value of NAME is
greater than or equal to 'N ', block2 is executed.
Form Example
IF (expr) THEN IF (A .GT. B) THEN
block1 D = B
F = A - B
ELSE IF (expr) THEN ELSE IF (A .GT. B/2.) THEN
block2 D = B/2.
F = A - B/2.
END IF END IF
If A is greater than B, block1 is executed. If A is not greater than B, but A is greater than B/2, block2 is
executed. If A is not greater than B and A is not greater than B/2, neither block1 nor block2 is executed.
Control transfers directly to the next executable statement after the END IF statement.
1687
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Form Example
IF (expr) THEN IF (A .GT. B) THEN
block1 D = B
F = A - B
ELSE IF (expr) THEN ELSE IF (A .GT. C) THEN
block2 D = C
F = A - C
ELSE IF (expr) THEN ELSE IF (A .GT. Z) THEN
block3 D = Z
F = A - Z
ELSE ELSE
block4 D = 0.0
F = A
END IF END IF
If A is greater than B, block1 is executed. If A is not greater than B but is greater than C, block2 is executed.
If A is not greater than B or C but is greater than Z, block3 is executed. If A is not greater than B, C, or Z,
block4 is executed.
The following example shows a nested IF construct:
Form Example
IF (expr) THEN IF (A .LT. 100) THEN
block1 INRAN = INRAN + 1
IF (expr2) THEN IF (ABS(A-AVG) .LE. 5.) THEN
block1a INAVG = INAVG + 1
ELSE ELSE
block1b OUTAVG = OUTAVG + 1
END IF END IF
ELSE ELSE
block2 OUTRAN = OUTRAN + 1
END IF END IF
If A is less than 100, the code immediately following the IF is executed. This code contains a nested IF
construct. If the absolute value of A minus AVG is less than or equal to 5, block1a is executed. If the
absolute value of A minus AVG is greater than 5, block1b is executed.
If A is greater than or equal to 100, block2 is executed, and the nested IF construct (in block1) is not
executed.
The following shows another example:
1688
Language Reference
See Also
Execution Control
IF - Logical
IF - Arithmetic
IF Directive Construct
General Compiler Directive: A conditional
compilation construct that begins with an IF or IF
DEFINED directive. IF tests whether a logical
expression is .TRUE. or .FALSE.. IF DEFINED tests
whether a symbol has been defined.
Syntax
!DIR$ IF (expr) -or- !DIR$ IF DEFINED (name)
block
[!DIR$ ELSEIF (expr)
block] ...
[!DIR$ ELSE
block]
!DIR$ ENDIF
block Are executable statements that are compiled (or not) depending on
the value of logical expressions in the IF directive construct.
The IF and IF DEFINED directive constructs end with an ENDIF directive and can contain one or more ELSEIF
directives and at most one ELSE directive. If the logical condition within a directive evaluates to .TRUE. at
compilation, and all preceding conditions in the IF construct evaluate to .FALSE., then the statements
contained in the directive block are compiled.
A name can be defined with a DEFINE directive, and can optionally be assigned an integer value. If the
symbol has been defined, with or without being assigned a value, IF DEFINED (name) evaluates to .TRUE.;
otherwise, it evaluates to .FALSE..
If the logical condition in the IF or IF DEFINED directive is .TRUE., statements within the IF or IF DEFINED
block are compiled. If the condition is .FALSE., control transfers to the next ELSEIF or ELSE directive, if any.
1689
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If the logical expression in an ELSEIF directive is .TRUE., statements within the ELSEIF block are compiled. If
the expression is .FALSE., control transfers to the next ELSEIF or ELSE directive, if any.
If control reaches an ELSE directive because all previous logical conditions in the IF construct evaluated
to .FALSE., the statements in an ELSE block are compiled unconditionally.
You can use any Fortran logical or relational operator or symbol in the logical expression of the directive,
including: .LT., <, .GT., >, .EQ., ==, .LE., <=, .GE., >=, .NE., /=, .EQV., .NEQV., .NOT., .AND., .OR.,
and .XOR.. The logical expression can be as complex as you like, but the whole directive must fit on one line.
Example
! When the following code is compiled and run,
! the output is:
! Or this compiled if all preceding conditions .FALSE.
!
!DIR$ DEFINE flag=3
!DIR$ IF (flag .LT. 2)
WRITE (*,*) "This is compiled if flag less than 2."
!DIR$ ELSEIF (flag >= 8)
WRITE (*,*) "Or this compiled if flag greater than &
or equal to 8."
!DIR$ ELSE
WRITE (*,*) "Or this compiled if all preceding &
conditions .FALSE."
!DIR$ ENDIF
END
See Also
DEFINE and UNDEFINE
IF Construct
General Compiler Directives
Syntax Rules for Compiler Directives
IF DEFINED Directive
Statement: Marks the start of an IF Directive
Construct.
See Also
See IF Directive Construct.
IFIX
Elemental Intrinsic Function (Generic): Converts
a single-precision real argument to an integer by
truncating.
See Also
See INT.
IFLOATI, IFLOATJ
Portability Functions: Convert an integer to single-
precision real type.
Module
USE IFPORT
1690
Language Reference
Syntax
result = IFLOATI (i)
result = IFLOATJ (j)
Results
The result type is single-precision real (REAL(4) or REAL*4).
See Also
DFLOAT
ILEN
Inquiry Intrinsic Function (Generic): Returns the
length (in bits) of the two's complement
representation of an integer.
Syntax
result = ILEN (i)
Results
The result type and kind are the same as i. The result value is (LOG2( i+ 1 )) if i is not negative; otherwise,
the result value is (LOG2( - i)).
Example
ILEN (4) has the value 3.
ILEN (-4) has the value 2.
IMAGE_INDEX
Transformational Intrinsic Function (Generic):
Converts cosubscripts to an image index.
Syntax
result = IMAGE_INDEX (coarray, sub)
result = IMAGE_INDEX (coarray, sub, team)
result = IMAGE_INDEX (coarray, sub, team_number)
sub (Input) Must be a rank-one integer array of size equal to the corank of
coarray.
1691
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
team_number (Input) Must be an integer scalar. It must identify the initial team (-1)
or a team formed by the same execution of the FORM TEAM statement
that created the current team (a sibling team of the current team).
Results
The result is default integer scalar. The result is the index of the corresponding image if the value of sub is a
valid sequence of cosubscripts for coarray on the team specified by team or team_number, or for the current
team if neither team nor team_number is specified. Otherwise, the result is zero.
Examples
If coarray D is declared as D [0:*] and coarray C is declared as C(5,10) [10, 0:9, 0:*], IMAGE_INDEX (D,
[0]) has the value 1 and IMAGE_INDEX (C, [3, 1, 2]) has the value 213 (on any image).
Consider the following program:
PROGRAM main
USE, INTRINSIC :: ISO_FORTRAN_ENV
TYPE (TEAM_TYPE) :: initial, odd_even
REAL :: ca1[4:*], ca2[2, *]
INTEGER :: i, j, k, l
initial = GET_TEAM (CURRENT_TEAM)
FORM TEAM (2-MOD(THIS_IMAGE(), 2), odd_even)
PRINT *, THIS_IMAGE()
PRINT *, THIS_IMAGE (coarray1)
PRINT *, THIS_IMAGE (coarray2, 2)
CHANGE TEAM (odd_even)
. . .
i = IMAGE_INDEX(ca1, [6], 2)
j = IMAGE_INDEX(ca1, [6], 1)
k = IMAGE_INDEX(ca2, [2, 4], initial)
l = IMAGE_INDEX(ca1, [12], -1)
. . .
END TEAM
. . .
END PROGRAM
If there are 10 images on the initial team, ca1[4] will be on image 1, ca1[5] on image 2, and ca1[13] will be
on image 10. Similarly, ca2[1, 1] will be on image 1, ca[2, 1] on image 2, ending with ca2[2, 5] will be on
image 10. The FORM TEAM statement divides the images into two teams, with team 1 having images [1, 3,
5, 7, 9] with image numbers [1, 2, 3, 4, 5] respectively, and team 2 having images [2, 4, 6, 8, 10] with
image numbers [1, 2, 3, 4, 5] respectively.
After the 4 calls to IMAGE_INDEX, the value of i will be zero (ca1[6] is not on an image in team 2), j will
have the value 2, k will have the value 8, and l will have the value 9. Note that the team number -1 always
refers to the initial team. Note also that if the FORM TEAM does not specify NEW_INDEX, the image numbers
on the new teams formed by the FORM TEAM are assigned in a processor-dependent manner.
See Also
FORM TEAM
1692
Language Reference
Module
USE IFQWIN
Syntax
result = IMAGESIZE (x1,y1,x2,y2)
result = IMAGESIZE_W (wx1,wy1,wx2,wy2)
wx1, wy1 (Input) REAL(8). Window coordinates for upper-left corner of image.
wx2, wy2 (Input) REAL(8). Window coordinates for lower-right corner of image.
Results
The result type is INTEGER(4). The result is the storage size of an image in bytes.
IMAGESIZE defines the bounding rectangle in viewport-coordinate points ( x1, y1) and ( x2, y2).
IMAGESIZE_W defines the bounding rectangle in window-coordinate points ( wx1, wy1) and ( wx2, wy2).
IMAGESIZE_W defines the bounding rectangle in terms of window-coordinate points ( wx1, wy1) and ( wx2,
wy2).
Example
See the example in GETIMAGE.
See Also
GETIMAGE
GRSTATUS
PUTIMAGE
IMAGE_STATUS
Elemental Intrinsic Function (Generic): Returns
the execution status value of the specified image.
Syntax
result = IMAGE_STATUS (image [, team])
image (Input) Must be a positive integer with a value equal to or less than
the number of executing images on the specified team.
Results
The result type is default integer. If image on the specified team has initiated normal termination, the result
is the value STAT_STOPPED_IMAGE defined in the intrinsic module ISO_FORTRAN_ENV. If image on the
specified team has failed, the result is the value STAT_FAILED_IMAGE defined in the intrinsic module
ISO_FORTRAN_ENV. Otherwise, the result value is zero.
1693
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
If image 5 on the specified team has initiated normal termination, and image 12 on the specified team is
known to have failed, then IMAGE_STATUS (5) returns the value STAT_STOPPED_IMAGE and IMAGE_STATUS
(12) returns the value STAT_FAILED_IMAGE. If image 3 on the specified team has neither initiated normal
termination nor failed, IMAGE_STATUS (3) returns the value zero.
See Also
FAILED_IMAGES
STOPPED_IMAGES
ISO_FORTRAN_ENV Module
IMPLICIT
Statement: Overrides the default implicit typing rules
for names. (The default data type is default INTEGER
kind for names beginning with the letters I through N,
and default REAL kind for names beginning with any
other letter.) An IMPLICIT NONE statement overrides
all implicit typing in a scoping unit, or it indicates that
all dummy procedures and externals must explicitly be
given the external attribute.
Syntax
The IMPLICIT statement takes one of the following forms:
IMPLICIT type(a[,a]...)[,type(a[,a]...)]...
IMPLICIT NONE [(spec-list])
The dollar sign can be used at the end of a range of letters, since IMPLICIT interprets the dollar sign to
alphabetically follow the letter Z. For example, a range of X-$ would apply to identifiers beginning with the
letters X, Y, Z, or $.
In Intel® Fortran, the parentheses around the list of letters are optional.
Description
The IMPLICIT statement assigns the specified data type (and kind parameter) to all names that have no
explicit data type and begin with the specified letter or range of letters. It has no effect on the default types
of intrinsic procedures.
When the data type is CHARACTER*len, len is the length for character type. The len is an unsigned integer
constant or an integer specification expression enclosed in parentheses. The range for len is 1 to 2**31-1 on
IA-32 architecture; 1 to 2**63-1 on Intel® 64 architecture.
Names beginning with a dollar sign ($) are implicitly INTEGER.
The IMPLICIT NONE statement disables all implicit typing defaults. When IMPLICIT NONE is used, all names
in a program unit must be explicitly declared. An IMPLICIT NONE statement must precede any PARAMETER
statements, and there must be no other IMPLICIT statements in the scoping unit. An IMPLICIT NONE (TYPE)
1694
Language Reference
statement is the same as an IMPLICIT NONE statement. If an IMPLICIT NONE (EXTERNAL) statement
appears in a scoping unit, all dummy procedures and external procedures in that scope or a contained scope
of BLOCK must have an accessible explicit interface or be declared EXTERNAL.
NOTE
To receive diagnostic messages when variables are used but not declared, you can specify
compiler option warn declarations instead of using IMPLICIT NONE or IMPLICIT NONE
(TYPE). To receive diagnostic messages when external and dummy procedures have not
explicitly been given the EXTERNAL attribute, you can specify compiler option
warn externals instead of using IMPLICIT NONE (EXTERNAL).
The following IMPLICIT statement represents the default typing as specified by the Fortran Standard for
names when they are not explicitly typed:
Example
The following are examples of the IMPLICIT statement:
SUBROUTINE FF (J)
IMPLICIT INTEGER (a-b), CHARACTER*(J+1) (n), TYPE(fried) (c-d)
TYPE fried
INTEGER e, f
REAL g, h
END TYPE
age = 10 ! integer
name = 'Paul' ! character
c%e = 1 ! type fried, integer component
See Also
Data Types, Constants, and Variables
warn declarations compiler option
warn externals compiler option
IMPORT
Statement: Controls accessibility of host entities in a
submodule, module procedure, a contained procedure,
a block construct, or in the interface body of an
interface block.
Syntax
The IMPORT statement takes the following form:
IMPORT [[::] import-name-list]
IMPORT,ONLY: import-name-list
IMPORT,NONE
1695
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IMPORT,ALL
import-name-list (Input) Is the name of one or more entities accessible in the host
scoping unit.
An IMPORT statement can appear in a submodule, module procedure, a contained procedure, the
specification part of a BLOCK construct, or in an interface body. It can not appear in the specification part of
a main program, external procedure, module, or block data except in an interface body.
An IMPORT statement must appear after any USE statements, and before any other specification statements.
Each of the named entities must be an accessible entity in the host scoping unit. Within an interface body
each named entity must be explicitly declared before the interface body, or accessible by use or host
association in the host containing the IMPORT statement.
If IMPORT, ONLY appears within a scoping unit, all other IMPORT statements in that scoping unit must be
IMPORT, ONLY statements. An entity is host associated in a scoping unit which contains an IMPORT, ONLY
statement if it appears in an import-name-list in that scoping unit.
If IMPORT, NONE is specified, no entities in the host are accessible by host association in that scoping unit.
This is the default behavior for interface bodies for a dummy or external procedure. IMPORT, NONE must not
appear in the specification part of a submodule.
If an IMPORT, ALL or an IMPORT, NONE statement appears in a scoping unit, it must be the only IMPORT
statement in that scoping unit.
If import-name-list is not specified, and if ALL, ONLY, or NONE are not specified, all of the accessible named
entities in the host scoping unit are imported unless they are made inaccessible by an entity of the same
name in the local scope. This is the default behavior for a nested scoping unit, other than an interface body,
for a dummy or external procedure.
If IMPORT, ALL is specified, all entities in the host are accessible by host association. If an entity is made
accessible by an IMPORT, ALL statement or by its name appearing in an import-name-list, it cannot be made
inaccessible by declaring another entity with the same name in the local scope.
If an IMPORT statement with an import-name-list appears, only the named entities are available by host
association.
Examples
The following examples show how the IMPORT statement can be applied.
module mymod
type mytype
integer comp
end type mytype
interface
subroutine sub (arg)
import
type(mytype) :: arg
end subroutine sub
end interface
end module mymod
module host
integer :: i, j, k
contains
subroutine sub1 ()
import :: i, j
k = i + j ! only i and j are host associated, k is local to sub1
end subroutine
subroutine sub2 ()
import, none
1696
Language Reference
IMPURE
Keyword: Asserts that a user-defined procedure has
side effects.
Description
This kind of procedure is specified by using the prefix IMPURE in a FUNCTION or SUBROUTINE statement. By
default all user-defined procedures are impure, that is, they are allowed to have side effects, except for
elemental procedures.
An IMPURE elemental procedure has the restrictions that apply to elemental procedures, but it does not have
any of the restrictions of PURE elemental procedures.
An impure elemental procedure can have side effects and it can contain the following:
• Any external I/O statement (including a READ or WRITE statement whose I/O unit is an external file unit
number or *)
• A PAUSE statement
• A STOP statement or an ERROR STOP statement
• An image control statement
An impure elemental procedure cannot be referenced in a context that requires a procedure to be pure; for
example:
• It cannot be called directly in a FORALL statement or be used in the mask expression of a FORALL
statement.
• It cannot be called from a pure procedure. Pure procedures can only call other pure procedures, including
one referenced by means of a defined operator, defined assignment, or finalization.
• It cannot be passed as an actual argument to a pure procedure.
Example
module my_rand_mod
integer, save :: my_rand_seed (8)
contains
impure elemental subroutine my_rand (r)
real, intent(out) :: r
1697
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
FUNCTION
SUBROUTINE
IN_REDUCTION
Specifies that a task participates in a reduction. The
IN_REDUCTION clause is a reduction participating
clause.
Syntax
IN_REDUCTION (reduction-identifier : list)
Arguments reduction-identifier and list are defined in the REDUCTION clause description. All the common
restrictions for the REDUCTION clause apply to the IN_REDUCTION clause.
A list item that appears in an IN_REDUCTION clause must appear in a TASK_REDUCTION clause or a
REDUCTION clause with the TASK reduction modifier. The construct associated with the innermost region that
meets this condition must specify the same reduction-identifier as the IN_REDUCTION clause.
If the IN_REDUCTION clause appears in a TARGET construct, the target task becomes the task participating
in the reduction. A private copy of each list item is created in the data environment of the target task. The
copy is implicitly mapped into the data environment of the target device if the target device is not the parent
device.
If the IN_REDUCTION clause is associated with a TASK construct, the generated task is the participating
task, and a private copy of each list item may be created.
At the end of the region, the value of private copies of list items are combined with the value of a private
copy created by a reduction scoping clause, and finally with the original list item.
The list items specified in an IN_REDUCTION clause must match the list items that appear in a
TASK_REDUCTION clause or in a REDUCTION clause with the TASK reduction modifier. The construct
specifying the TASK_REDUCTION or REDUCTION clause corresponds to a region in which the participating
task’s region is closely nested. The innermost enclosing construct that meets this condition must also specify
the same reduction-identifier specified in the IN_REDUCTION clause.
In the following example, the IN_REDUCTION clause at (3) must name the same operator (+) and variable
(a) as in the TASK_REDUCTION clause in (2). The IN_REDUCTION clause at (4) must name the same
operator (*) and variable (a) as in the TASK_REDUCTION clause in (1).
1698
Language Reference
See Also
REDUCTION
DECLARE REDUCTION
TASK_REDUCTION
TARGET
TASK
TASKLOOP
INCHARQQ (W*S)
QuickWin Function: Reads a single character input
from the keyboard and returns the ASCII value of that
character without any buffering.
Module
USE IFQWIN
Syntax
result = INCHARQQ( )
Results
The result type is INTEGER(2). The result is the ASCII key code.
The keystroke is read from the child window that currently has the focus. You must call INCHARQQ before
the keystroke is made (INCHARQQ does not read the keyboard buffer). This function does not echo its input.
For function keys, INCHARQQ returns 0xE0 as the upper 8 bits, and the ASCII code as the lower 8 bits.
For direction keys, INCHARQQ returns 0xF0 as the upper 8 bits, and the ASCII code as the lower 8 bits. To
allow direction keys to be read, you must use the PASSDIRKEYSQQ function. The escape characters (the
upper 8 bits) are different from those of GETCHARQQ. Note that console applications do not need, and
cannot use PASSDIRKEYSQQ.
Example
use IFQWIN
integer*4 res
integer*2 exchar
character*1 ch, ch1
123 continue
exchar = incharqq()
! check for escapes
! 0xE0 0x?? is a function key
! 0xF0 0x?? is a direction key
1699
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
INCLUDE
Statement: Directs the compiler to stop reading
statements from the current file and read statements
in an included file or text module.
Syntax
The INCLUDE line takes the following form:
INCLUDE 'filename[/[NO]LIST]'
Description
An INCLUDE line can appear anywhere within a scoping unit. The line can span more than one source line,
but no other statement can appear on the same line. The source line cannot be labeled.
An included file or text module cannot begin with a continuation line, and each Fortran statement must be
completely contained within a single file.
1700
Language Reference
An included file or text module can contain any source text, but it cannot begin or end with an incomplete
Fortran statement.
The included statements, when combined with the other statements in the compilation, must satisfy the
statement-ordering restrictions shown in Statements.
Included files or text modules can contain additional INCLUDE lines, but they must not be recursive.
INCLUDE lines can be nested until system resources are exhausted.
When the included file or text module completes execution, compilation resumes with the statement
following the INCLUDE line.
You can use modules instead of include files to achieve encapsulation of related data types and procedures.
For example, one module can contain derived type definitions as well as special operators and procedures
that apply to those types. For information on how to use modules, see Program Units and Procedures.
Example
In the following example, a file named COMMON.FOR (in the current working directory) is included and read
as input.
PROGRAM
INCLUDE 'COMMON.FOR' INTEGER, PARAMETER :: M=100
REAL, DIMENSION(M) :: Z REAL, DIMENSION(M) :: X, Y
CALL CUBE COMMON X, Y
DO I = 1, M
Z(I) = X(I) + SQRT(Y(I))
...
END DO
END
SUBROUTINE CUBE
INCLUDE 'COMMON.FOR'
DO I=1,M
X(I) = Y(I)**3
END DO
RETURN
END
The file COMMON.FOR defines a named constant M, and defines arrays X and Y as part of blank common.
The following example program declares its common data in an include file. The contents of the file
INCLUDE.INC are inserted in the source code in place of every INCLUDE 'INCLUDE.INC' line. This guarantees
that all references to common storage variables are consistent.
INTEGER i
REAL x
INCLUDE 'INCLUDE.INC'
DO i = 1, 5
READ (*, '(F10.5)') x
CALL Push (x)
END DO
See Also
MODULE
1701
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
USE
INDEX
Elemental Intrinsic Function (Generic): Returns
the starting position of a substring within a string.
Syntax
result = INDEX (string, substring [,back] [, kind])
Results
The result is of type integer. If kind is present, the kind parameter of the result is that specified by kind;
otherwise, the kind parameter of the result is that of default integer. If the processor cannot represent the
result value in the kind of the result, the result is undefined.
If back does not appear (or appears with the value false), the value returned is the minimum value of I such
that string(I : I + LEN (substring) - 1) = substring(or zero if there is no such value). If LEN (string) < LEN
(substring), zero is returned. If LEN (substring) = zero, 1 is returned.
If back appears with the value true, the value returned is the maximum value of I such that string(I : I +
LEN (substring) - 1) = substring (or zero if there is no such value). If LEN(string) < LEN (substring), zero is
returned. If LEN (substring) = zero, LEN (string) + 1 is returned.
CHARACTER INTEGER(1)
CHARACTER INTEGER(2)
CHARACTER INTEGER(8)
1The setting of compiler options specifying integer size can affect this function.
Example
INDEX ('FORTRAN', 'O', BACK = .TRUE.) has the value 2.
INDEX ('XXXX', " ", BACK = .TRUE.) has the value 5.
The following shows another example:
See Also
SCAN
INITIALIZEFONTS (W*S)
Graphics Function: Initializes Windows* fonts.
1702
Language Reference
Module
USE IFQWIN
Syntax
result = INITIALIZEFONTS( )
Results
The result type is INTEGER(2). The result is the number of fonts initialized.
All fonts on Windows systems become available after a call to INITIALIZEFONTS. Fonts must be initialized
with INITIALIZEFONTS before any other font-related library function (such as GETFONTINFO,
GETGTEXTEXTENT, SETFONT, OUTGTEXT) can be used.
The font functions affect the output of OUTGTEXT only. They do not affect other Fortran I/O functions (such
as WRITE) or graphics output functions (such as OUTTEXT).
For each window you open, you must call INITIALIZEFONTS before calling SETFONT. INITIALIZEFONTS needs
to be executed after each new child window is opened in order for a subsequent SETFONT call to be
successful.
Example
! build as a QuickWin or Standard Graphics App.
USE IFQWIN
INTEGER(2) numfonts
numfonts = INITIALIZEFONTS()
WRITE (*,*) numfonts
END
See Also
SETFONT
OUTGTEXT
INITIALSETTINGS (W*S)
QuickWin Function: Initializes QuickWin.
Module
USE IFQWIN
Syntax
result = INITIALSETTINGS( )
Results
The result type is LOGICAL(4). The result is .TRUE. if successful; otherwise, .FALSE..
You can change the initial appearance of an application's default frame window and menus by defining an
INITIALSETTINGS function. Do not use INITIALSETTINGS to open or change the properties of child windows.
If no user-defined INITIALSETTINGS function is supplied, QuickWin calls a predefined INITIALSETTINGS
routine to control the default frame window and menu appearance. You do not need to call INITIALSETTINGS
if you define it, since it will be called automatically during initialization.
See Also
APPENDMENUQQ
INSERTMENUQQ
1703
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
DELETEMENUQQ
SETWSIZEQQ
Syntax
!DIR$ INLINE [RECURSIVE]
!DIR$ FORCEINLINE [RECURSIVE]
!DIR$ NOINLINE
The INLINE directive specifies that the routines can be inlined.
The FORCEINLINE directive specifies that a routine should be inlined whenever the compiler can do so. This
condition can also be specified by using compiler option [Q]inline-forceinline.
Caution
When you use directive FORCEINLINE, the compiler may do so much additional inlining that it runs out
of memory and terminates with an "out of memory" message.
Example
Consider the following:
!DIR$ INLINE
A = F(B) + G(C) ! inline the call to function F and inline the call to function G
!DIR$ INLINE
DO I = 1, N
CALL F1 ( G1(A), G2(A)) ! inline the call to F1 and the function executions of G1 and G2
!DIR$ NOINLINE
DO J = 1, M
M(J) = F (M(J)) ! do not inline this call to F {M is a data array}
END DO
M(I) = F2 (X) ! F2 gets inlined from the directive before DO I
See Also
General Compiler Directives
1704
Language Reference
INMAX
Portability Function: Returns the maximum positive
value for an integer.
Module
USE IFPORT
Syntax
result = INMAX (i)
i (Input) INTEGER(4).
Results
The result type is INTEGER(4). The result is the maximum 4-byte signed integer value for the argument.
INQFOCUSQQ (W*S)
QuickWin Function: Determines which window has
the focus.
Module
USE IFQWIN
Syntax
result = INQFOCUSQQ (unit)
unit (Output) INTEGER(4). Unit number of the window that has the I/O
focus.
Results
The result type is INTEGER(4). The result is zero if successful; otherwise, nonzero. The function fails if the
window with the focus is associated with a closed unit.
Unit numbers 0, 5, and 6 refer to the default window only if the program has not specifically opened them. If
these units have been opened and connected to windows, they are automatically reconnected to the console
once they are closed.
The window with focus is always in the foreground. Note that the window with the focus is not necessarily the
active window (the one that receives graphical output). A window can be made active without getting the
focus by calling SETACTIVEQQ.
A window has focus when it is given the focus by FOCUSQQ, when it is selected by a mouse click, or when an
I/O operation other than a graphics operation is performed on it, unless the window was opened with
IOFOCUS=.FALSE.. The IOFOCUS specifier determines whether a window receives focus when an I/O
statement is executed on that unit. For example:
1705
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
By default IOFOCUS=.TRUE., except for child windows opened with as unit *. If IOFOCUS=.TRUE., the child
window receives focus prior to each READ, WRITE, PRINT, or OUTTEXT. Calls to graphics functions (such as
OUTGTEXT and ARC) do not cause the focus to shift.
See Also
FOCUSQQ
INQUIRE
Statement: Returns information on the status of
specified properties of a file, logical unit, or directory.
It takes one of the following forms:
Syntax
Inquiring by File:
INQUIRE (FILE=name[, ERR=label] [, ID=id-var] [, IOMSG=msg-var] [, SIZE=sz] [, IOSTAT=i-
var] [, DEFAULTFILE=def] slist)
Inquiring by Unit:
INQUIRE ([UNIT=]io-unit [, ERR=label] [, ID=id-var] [, IOMSG=msg-var] [, SIZE=sz] [,
IOSTAT=i-var] slist)
Inquiring by Directory:
INQUIRE (DIRECTORY=dir, EXIST=ex [, DIRSPEC=dirspec] [, ERR=label] [, ID=id-var] [,
IOMSG=msg-var] [, SIZE=sz] [, IOSTAT=i-var])
Inquiring by Output List:
INQUIRE (IOLENGTH=len) out-item-list
name Is a scalar default character expression specifying the name of the file
for inquiry. For more information, see FILE Specifier and STATUS
Specifier.
label Is the label of the branch target statement that receives control if an
error occurs. For more information, see Branch Specifiers.
sz Is a scalar integer variable that is assigned the size of the file in file
storage units. For more information, see Size Specifier.
slist Is one or more of the following inquiry specifiers (each specifier can
appear only once):
1706
Language Reference
dirspec Is a scalar default character variable that is assigned the value of the
full directory specification of dir if ex is assigned the value .TRUE..
This specifier can only be used when inquiring by directory.
out-item-list (Output) Is a list of one or more output items (see I/O Lists).
Description
The control specifiers ([UNIT=] io-unit, ERR= label, and IOSTAT= i-var) and inquiry specifiers can appear
anywhere within the parentheses following INQUIRE. However, if the UNIT keyword is omitted, the io-unit
must appear first in the list.
1707
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
An INQUIRE statement can be executed before, during, or after a file is connected to a unit. The specifier
values returned are those that are current when the INQUIRE statement executes.
To get file characteristics, specify the INQUIRE statement after opening the file.
Example
The following are examples of INQUIRE statements:
CHARACTER*12 fname
LOGICAL exists
See Also
OPEN statement
UNIT control specifier
ERR control specifier
ID control specifier
IOMSG control specifier
IOSTAT control specifier
RECL specifier in OPEN statements
FILE specifier in OPEN statements
DEFAULTFILE specifier in OPEN statements
assume:minus0 compiler option
INSERTMENUQQ (W*S)
QuickWin Function: Inserts a menu item into a
QuickWin menu and registers its callback routine.
1708
Language Reference
Module
USE IFQWIN
Syntax
result = INSERTMENUQQ (menuID,itemID,flag,text,routine)
menuID (Input) INTEGER(4). Identifies the menu in which the item is inserted,
starting with 1 as the leftmost menu.
itemID (Input) INTEGER(4). Identifies the position in the menu where the
item is inserted, starting with 0 as the top menu item.
flag (Input) INTEGER(4). Constant indicating the menu state. Flags can be
combined with an inclusive OR (see Results section below). The
following constants are available:
• $MENUGRAYED - Disables and grays out the menu item.
• $MENUDISABLED - Disables but does not gray out the menu item.
• $MENUENABLED - Enables the menu item.
• $MENUSEPARATOR - Draws a separator bar.
• $MENUCHECKED - Puts a check by the menu item.
• $MENUUNCHECKED - Removes the check by the menu item.
routine (Input) EXERNAL. Callback subroutine that is called if the menu item
is selected. You can assign the following predefined routines to
menus:
• WINPRINT - Prints the program.
• WINSAVE - Saves the program.
• WINEXIT - Terminates the program.
• WINSELECTTEXT - Selects text from the current window.
• WINSELECTGRAPHICS - Selects graphics from the current window.
• WINSELECTALL - Selects the entire contents of the current window.
• WININPUT - Brings to the top the child window requesting input
and makes it the current window.
• WINCOPY - Copies the selected text and/or graphics from current
window to the Clipboard.
• WINPASTE - Allows the user to paste Clipboard contents (text only)
to the current text window of the active window during a READ.
• WINCLEARPASTE - Clears the paste buffer.
• WINSIZETOFIT - Sizes output to fit window.
• WINFULLSCREEN - Displays output in full screen.
• WINSTATE - Toggles between pause and resume states of text
output.
• WINCASCADE - Cascades active windows.
• WINTILE - Tiles active windows.
• WINARRANGE - Arranges icons.
• WINSTATUS - Enables a status bar.
• WININDEX - Displays the index for QuickWin help.
• WINUSING - Displays information on how to use Help.
• WINABOUT - Displays information about the current QuickWin
application.
• NUL - No callback routine.
1709
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type is LOGICAL(4). The result is .TRUE. if successful; otherwise, .FALSE.
Menus and menu items must be defined in order from left to right and top to bottom. For example,
INSERTMENUQQ fails if you try to insert menu item 7 when 5 and 6 are not defined yet. For a top-level menu
item, the callback routine is ignored if there are subitems under it.
The constants available for flags can be combined with an inclusive OR where reasonable, for example
$MENUCHECKED .OR. $MENUENABLED. Some combinations do not make sense, such as $MENUENABLED
and $MENUDISABLED, and lead to undefined behavior.
You can create quick-access keys in the text strings you pass to INSERTMENUQQ as text by placing an
ampersand (&) before the letter you want underlined. For example, to add a Print menu item with the r
underlined, text should be "P&rint". Quick-access keys allow users of your program to activate that menu
item with the key combination ALT+QUICK-ACCESS-KEY(ALT+Rin the example) as an alternative to selecting
the item with the mouse.
Example
USE IFQWIN
LOGICAL(4) :: status
CHARACTER (80) :: text_input
END
See Also
APPENDMENUQQ
DELETEMENUQQ
MODIFYMENUFLAGSQQ
MODIFYMENUROUTINEQQ
MODIFYMENUSTRINGQQ
1710
Language Reference
INT
Elemental Intrinsic Function (Generic): Converts
a value to integer type.
Syntax
result = INT (a[,kind])
Results
The result type is integer. If kind is present, the kind parameter of the result is that specified by kind;
otherwise, the kind parameter of the result is shown in the following table. If the processor cannot represent
the result value in the kind of the result, the result is undefined.
Functions that cause conversion of one data type to another type have the same effect as the implied
conversion in assignment statements.
The result value depends on the type and absolute value of a as follows:
1711
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1712
Language Reference
COMPLEX(4), COMPLEX(8),
COMPLEX(16)
If the argument is a binary, octal, or hexadecimal constant, the result is affected by the assume old-boz
option. The default option setting, noold-boz, treats the argument as a bit string that represents a value of
the data type of the intrinsic, that is, the bits are not converted. If setting old-boz is specified, the
argument is treated as a signed integer and the bits are converted.
Example
INT (-4.2) has the value -4.
INT (7.8) has the value 7.
See Also
Binary, Octal, Hexadecimal, and Hollerith Constants
NINT
AINT
ANINT
REAL
DBLE
SNGL
INTC
Portability Function: Converts an INTEGER(4)
argument to INTEGER(2) type.
1713
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Module
USE IFPORT
Syntax
result = INTC (i)
Results
The result type is INTEGER(2). The result is the value of i with type INTEGER(2). Overflow is ignored.
INT_PTR_KIND
Inquiry Intrinsic Function (Specific): Returns the
INTEGER KIND that will hold an address. This is a
specific function that has no generic function
associated with it. It cannot be passed as an actual
argument.
Syntax
result = INT_PTR_KIND( )
Results
The result type is default integer. The result is a scalar with the value equal to the value of the kind
parameter of the integer data type that can represent an address on the targeted platform.
The result value is 4 on IA-32 target architecture; 8 on Intel® 64 architecture.
Example
REAL A(100)
POINTER (P, A)
INTEGER (KIND=INT_PTR_KIND()) SAVE_P
P = MALLOC (400)
SAVE_P = P
INTEGER Statement
Statement: Specifies the INTEGER data type.
Syntax
INTEGER
INTEGER([KIND=] n)
INTEGER*n
n Is kind 1, 2, 4, or 8.
If a kind parameter is specified, the integer has the kind specified. If a kind parameter is not specified,
integer constants are interpreted as follows:
• If the integer constant is within the default integer kind range, the kind is default integer.
• If the integer constant is outside the default integer kind range, the kind of the integer constant is the
smallest integer kind which holds the constant.
1714
Language Reference
The default kind can also be changed by using the INTEGER directive or compiler options specifying integer
size.
Example
! Entity-oriented declarations:
INTEGER, DIMENSION(:), POINTER :: days, hours
INTEGER (2) :: k=4
INTEGER (2), PARAMETER :: limit=12
! Attribute-oriented declarations:
INTEGER days, hours
INTEGER (2):: k=4, limit
DIMENSION days(:), hours(:)
POINTER days, hours
PARAMETER (limit=12)
See Also
INTEGER Directive
Integer Data Types
Integer Constants
INTEGER Directive
General Compiler Directive: Specifies the default
integer kind.
Syntax
!DIR$ INTEGER:{ 2 | 4 | 8 }
The INTEGER directive specifies a size of 2 (KIND=2), 4 (KIND=4), or 8 (KIND=8) bytes for default integer
numbers.
When the INTEGER directive is in effect, all default integer variables are of the kind specified. Only numbers
specified or implied as INTEGER without KIND are affected.
The INTEGER directive can only appear at the top of a program unit. A program unit is a main program, an
external subroutine or function, a module or a block data program unit. INTEGER cannot appear at the
beginning of internal subprograms. It does not affect modules invoked with the USE statement in the
program unit that contains it.
The default logical kind is the same as the default integer kind. So, when you change the default integer kind
you also change the default logical kind.
Example
INTEGER i ! a 4-byte integer
WRITE(*,*) KIND(i)
CALL INTEGER2( )
WRITE(*,*) KIND(i) ! still a 4-byte integer
! not affected by setting in subroutine
END
SUBROUTINE INTEGER2( )
!DIR$ INTEGER:2
INTEGER j ! a 2-byte integer
WRITE(*,*) KIND(j)
END SUBROUTINE
1715
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
INTEGER
REAL Directive
General Compiler Directives
Syntax Rules for Compiler Directives
Integer Data Types
Integer Constants
INTEGERTORGB (W*S)
QuickWin Subroutine: Converts an RGB color value
into its red, green, and blue components.
Module
USE IFQWIN
Syntax
CALL INTEGERTORGB (rgb,red,green,blue)
rgb (Input) INTEGER(4). RGB color value whose red, green, and blue
components are to be returned.
red (Output) INTEGER(4). Intensity of the red component of the RGB color
value.
INTEGERTORGB separates the four-byte RGB color value into the three components as follows:
Example
! build as a QuickWin App.
USE IFQWIN
INTEGER(4) r, g, b
CALL INTEGERTORGB(2456, r, g, b)
write(*,*) r, g, b
END
See Also
RGBTOINTEGER
GETCOLORRGB
GETBKCOLORRGB
GETPIXELRRGB
GETPIXELSRGB
GETTEXTCOLORRGB
1716
Language Reference
INTENT
Statement and Attribute: Specifies the intended use
of one or more dummy arguments.
Syntax
The INTENT attribute can be specified in a type declaration statement or an INTENT statement, and takes
one of the following forms:
Type Declaration Statement:
type,[att-ls,] INTENT (intent-spec) [, att-ls] :: d-arg[, d-arg]...
Statement:
INTENT (intent-spec) [::] d-arg[, d-arg] ...
Description
The INTENT statement can only appear in the specification part of a subprogram or interface body.
If no INTENT attribute is specified for a dummy argument, its use is subject to the limitations of the
associated actual argument.
If a function specifies a defined operator, the dummy arguments must have intent IN.
If a subroutine specifies defined assignment, the first argument must have intent OUT or INOUT, and the
second argument must have intent IN or the VALUE attribute, or both IN and the VALUE attribute.
1717
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
An entity with the INTENT (OUT) attribute must not be an allocatable coarray or have a subobject that is an
allocatable coarray. It must not be of, or have a subcomponent of, type EVENT_TYPE or type LOCK_TYPE
from the ISO_FORTRAN_ENV module.
A non-pointer dummy argument with intent IN (or a subobject of such a dummy argument) must not appear
as any of the following:
• A DO variable
• The variable of an assignment statement
• The pointer-object of a pointer assignment statement
• An object or STAT variable in an ALLOCATE or DEALLOCATE statement
• An input item in a READ statement
• A variable name in a NAMELIST statement if the namelist group name appears in a NML specifier in a
READ statement
• An internal file unit in a WRITE statement
• A definable variable in an INQUIRE statement
• An IOSTAT or SIZE specifier in an I/O statement
• An actual argument in a reference to a procedure with an explicit interface if the associated dummy
argument has intent OUT or INOUT
INTENT on a pointer dummy argument refers to the pointer association status of the pointer and has no
effect on the value of the target of the pointer.
A pointer dummy argument with intent IN (or a subobject of such a pointer argument) must not appear as
any of the following:
• A pointer-object in a NULLIFY statement
• A pointer-object in a pointer assignment statement
• An object in an ALLOCATE or DEALLOCATE statement
• An actual argument in a reference to a procedure if the associated dummy argument is a pointer with the
INTENT(OUT) or INTENT(INOUT) attribute.
A pointer dummy argument with INTENT(IN) can be argument associated with a non-pointer actual
argument with the TARGET attribute. During the execution of the procedure, it is pointer associated with the
actual argument.
If an actual argument is an array section with a vector subscript, it cannot be associated with a dummy array
that is defined or redefined (has intent OUT or INOUT).
On entry to a routine, given an INTENT(OUT) dummy argument:
Example
The following example shows type declaration statements specifying the INTENT attribute:
SUBROUTINE TEST(I, J)
INTEGER, INTENT(IN) :: I
INTEGER, INTENT(OUT), DIMENSION(I) :: J
The following are examples of the INTENT statement:
SUBROUTINE TEST(A, B, X)
INTENT(INOUT) :: A, B
...
SUBROUTINE CHANGE(FROM, TO)
USE EMPLOYEE_MODULE
1718
Language Reference
TYPE(EMPLOYEE) FROM, TO
INTENT(IN) FROM
INTENT(OUT) TO
...
The following shows another example:
See Also
Argument Association
Type Declarations
ISO_FORTRAN_ENV
Compatible attributes
INTERFACE
Statement: Defines an explicit interface for an
external or dummy procedure. It can also be used to
define a generic name for procedures, a new operator
for functions, and a new form of assignment for
subroutines.
Syntax
INTERFACE [generic-spec]
[interface-body]...
[[MODULE]PROCEDURE [::]name-list]...
END INTERFACE [generic-spec]
1719
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
name-list Is the name of one or more nonintrinsic procedures that are accessible
in the host. The MODULE keyword is only allowed if the interface block
specifies a generic-spec and has a host that is a module, or
accesses a module by use association.
The characteristics of module procedures or internal procedures are
not given in interface blocks, but are assumed from the module
subprogram definitions or the USE associated interfaces.
Description
Interface blocks can appear in the specification part of the program unit that invokes the external or dummy
procedure.
A generic-spec can only appear in the END INTERFACE statement if one appears in the INTERFACE
statement; they must be identical.
The characteristics specified for the external or dummy procedure must be consistent with those specified in
the procedure's definition.
An interface block must not appear in a block data program unit.
An interface block comprises its own scoping unit, and does not inherit anything from its host through host
association.
Internal, module, and intrinsic procedures are all considered to have explicit interfaces. External procedures
have implicit interfaces by default; when you specify an interface block for them, their interface becomes
explicit. A procedure must not have more than one explicit interface in a given scoping unit. This means that
you cannot include internal, module, or intrinsic procedures in an interface block, unless you want to define a
generic name for them.
The function or subroutine named in the interface-body cannot have the same name as a keyword that
specifies an intrinsic type.
A interface block containing generic-spec specifies a generic interface for the following procedures:
• The procedures within the interface block
Any generic name, defined operator, or equals symbol that appears is a generic identifier for all the
procedures in the interface block. For the rules on how any two procedures with the same generic
identifier must differ, see Unambiguous Generic Procedure References.
• The module procedures listed in the MODULE PROCEDURE statement
1720
Language Reference
Example
The following example shows a simple procedure interface block with no generic specification:
See Also
ABSTRACT INTERFACE
CALL
PROCEDURE
FUNCTION
MODULE
SUBMODULE
MODULE PROCEDURE
SUBROUTINE
PURE
Procedure Interfaces
Procedures that Require Explicit Interfaces
Use and Host Association
INTERFACE TO
Statement: Identifies a subprogram and its actual
arguments before it is referenced or called.
1721
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
INTERFACE TO subprogram-stmt
[formal-declarations]
END
The INTERFACE TO block defines an explicit interface, but it contains specifications for only the procedure
declared in the INTERFACE TO statement. The explicit interface is defined only in the program unit that
contains the INTERFACE TO statement.
The recommended method for defining explicit interfaces is to use an INTERFACE block.
Example
Consider that a C function that has the following prototype:
See Also
INTERFACE
INTEROP
OpenMP* Fortran Compiler Directive: Identifies a
foreign runtime context and identifies runtime
characteristics of that context, enabling
interoperability with it. This feature is only available
for ifx.
Syntax
!$OMP INTEROP clause[[[,] clause]... ]
1722
Language Reference
• TARGET
Provides the following properties:
• device - the foreign device handle
• device_context - the foreign device context handle
• platform - the handle to the foreign platform of the device
• TARGETSYNC
Enables synchronization between foreign tasks executing in the
foreign execution context and OpenMP* tasks.
1723
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
OpenMP* may interoperate with one or more foreign runtime environments using the INTEROP directive, the
INTEROP clause on a DECLARE VARIANT directive, or the interoperability functions in the OpenMP* runtime
API.
A task has an interoperability requirement set, which is a logical set of properties. Properties can be added to
or removed from the set by different directives. The properties can be queried by other constructs that have
interoperability semantics. The following properties can be added by a construct:
• DEPEND - requires the construct enforce the synchronization relationship specified by the DEPEND clause
• IS_DEVICE_PTR (list-item) - indicates that the list-item is a device pointer within the construct
• NOWAIT - indicates that the construct is asynchronous
The DISPATCH directive can add properties to the interoperability requirement set.
The DECLARE VARIANT directive can remove properties from the interoperability requirement set.
If the interop-var is initialized with TARGETSYNC, an empty mergeable task is generated. DEPEND clauses
apply to the generated task. If NOWAIT is omitted, the generated task is also an included task. The INTEROP
construct guarantees ordered execution of the generated task with respect to foreign tasks executing in
foreign contexts through the foreign synchronization object accessible through the TARGETSYNC property of
the interop-var.
If a foreign task is created prior to encountering an INTEROP construct, the foreign task must complete
execution before the generated task executes. If the creation of a foreign task occurs after an INTEROP
construct is encountered, the foreign task cannot begin execution until the generated task finishes execution.
The INTEROP construct imposes no ordering between the thread that encounters it and foreign tasks or
OpenMP* tasks.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
DECLARE VARIANT directive
DISPATCH directive
INTRINSIC
Statement and Attribute: Allows the specific name
of an intrinsic procedure to be used as an actual
argument.
Syntax
The INTRINSIC attribute can be specified in a type declaration statement or an INTRINSIC statement, and
takes one of the following forms:
Type Declaration Statement:
type,[att-ls,] INTRINSIC [, att-ls] :: in-pro[, in-pro]...
1724
Language Reference
Statement:
INTRINSIC [::] in-pro[, in-pro] ...
Description
In a type declaration statement, only functions can be declared INTRINSIC. However, you can use the
INTRINSIC statement to declare subroutines, as well as functions, to be intrinsic.
The name declared INTRINSIC is assumed to be the name of an intrinsic procedure. If a generic intrinsic
function name is given the INTRINSIC attribute, the name retains its generic properties.
Some specific intrinsic function names cannot be used as actual arguments. For more information, see table
Specific Functions Not Allowed as Actual Arguments in Intrinsic Procedures.
Example
The following example shows a type declaration statement specifying the INTRINSIC attribute:
PROGRAM EXAMPLE
...
REAL(8), INTRINSIC :: DACOS
...
CALL TEST(X, DACOS) ! Intrinsic function DACOS is an actual argument
The following example shows an INTRINSIC statement:
... RETURN
END
CALL TRIG(ANGLE,SIN,SINE)
CTN = COS(X)/SIN(X)
... END
CALL TRIG(ANGLE,CTN,COTANGENT)
Note that when TRIG is called with a second argument of SIN or COS, the function reference F(X) references
the Standard Fortran library functions SIN and COS; but when TRIG is called with a second argument of CTN,
F(X) references the user function CTN.
1725
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
References to Generic Procedures
Type Declarations
Compatible attributes
INUM
Elemental Intrinsic Function (Specific): Converts
a character string to an INTEGER(2) value. This
function cannot be passed as an actual argument.
Syntax
result = INUM (i)
Results
The result type is INTEGER(2). The result value is the INTEGER(2) value represented by the character string
i.
If the argument contains characters that are illegal in an integer value, an error is signaled and execution
stops.
Example
INUM ("451") has the value 451 of type INTEGER(2).
IOR
Elemental Intrinsic Function (Generic): Performs
an inclusive OR on corresponding bits. This function
can also be specified as OR.
Syntax
result = IOR (i,j)
1726
Language Reference
Results
The result is the same as i if i is of type integer; otherwise, the result is the same as j. If either i or j is a
binary, octal, or hexadecimal literal constant, it is first converted as if by the intrinsic function INT to type
integer with the kind type parameter of the other.
The result value is derived by combining i and j bit-by-bit according to the following truth table:
i j IOR (i, j)
1 1 1
1 0 1
0 1 1
0 0 0
The model for the interpretation of an integer value as a sequence of bits is shown in Model for Bit Data.
Example
IOR (1, 4) has the value 5.
IOR (1, 2) has the value 3.
The following shows another example:
INTEGER result
result = IOR(240, 90) ! returns 250
See Also
Binary, Octal, Hexadecimal, and Hollerith Constants
IAND
IEOR
NOT
IALL
IANY
IPARITY
IPARITY
Transformational Intrinsic Function (Generic):
Returns the result of a bitwise exclusive OR operation.
Syntax
result = IPARITY (array, dim [, mask])
result = IPARITY (array [, mask])
1727
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
dim (Input) Must be a scalar integer with a value in the range 1 <= dim
<= n, where n is the rank of array.
mask (Input; optional) Must be of type logical and conformable with array.
Results
The result has the same type and kind parameters as array. It is scalar if dim does not appear; otherwise,
the result has rank n - 1 and shape [d1, d2, ..., ddim-1, ddim+1 , ..., dn] where [d1, d2,..., dn] is the shape of
array.
The result of IPARITY (array) has a value equal to the bitwise exclusive OR of all the elements of array. If
array has size zero, the result value is equal to zero.
The result of IPARITY (array, MASK=mask) has a value equal to IPARITY (PACK (array, mask)).
The result of IPARITY (array, DIM=dim [ , MASK=mask]) has a value equal to that of IPARITY (array [ ,
MASK=mask]) if array has rank one. Otherwise, the value of element (s1, s2, ..., sdim-1, sdim+1 , ..., sn) of the
result is equal to IPARITY (array (s1, s2, ..., sdim-1 , :, sdim+1 , ..., sn) [, MASK = mask (s1, s2, ..., sdim-1 , :,
sdim+1 , ..., sn)]).
Example
IPARITY ([14, 13, 8]) has the value 11. IPARITY ([14, 13, 8], MASK=[.true., .false., .true]) has the value 6.
See Also
IANY
IALL
IPXFARGC
POSIX Function: Returns the index of the last
command-line argument.
Module
USE IFPOSIX
Syntax
result = IPXFARGC( )
Results
The result type is INTEGER(4). The result value is the number of command-line arguments, excluding the
command name, in the command used to invoke the executing program. A return value of zero indicates
there are no command-line arguments other than the command name itself.
See Also
PXFGETARG
IPXFCONST
POSIX Function: Returns the value associated with a
constant defined in the C POSIX standard.
Module
USE IFPOSIX
1728
Language Reference
Syntax
result = IPXFCONST (constname)
Results
The result type is INTEGER(4). If constname corresponds to a defined constant in the C POSIX standard, the
result value is the integer that is associated with the constant. Otherwise, the result value is -1.
See Also
PXFGETARG
PXFCONST
IPXFLENTRIM
POSIX Function: Returns the index of the last non-
blank character in an input string.
Module
USE IFPOSIX
Syntax
result = IPXFLENTRIM (string)
Results
The result type is INTEGER(4). The result value is the index of the last non-blank character in the input
argument string, or zero if all characters in string are blank characters.
Module
USE IFPOSIX
Syntax
result = IPXFWEXITSTATUS (istat)
Results
The result type is INTEGER(4). The result is the low-order eight bits of the output argument of PXFWAIT or
PXFWAITPID.
The IPXFWEXITSTATUS function should only be used if PXFWIFEXITED returns TRUE.
1729
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
program t1
use ifposix
integer(4) ipid, istat, ierror, ipid_ret, istat_ret
print *," the child process will be born"
call PXFFORK(IPID, IERROR)
call PXFGETPID(IPID_RET,IERROR)
if(IPID.EQ.0) then
print *," I am a child process"
print *," My child's pid is", IPID_RET
call PXFGETPPID(IPID_RET,IERROR)
print *," The pid of my parent is",IPID_RET
print *," Now I have exited with code 0xABCD"
call PXFEXIT(Z'ABCD')
else
print *," I am a parent process"
print *," My parent pid is ", IPID_RET
print *," I am creating the process with pid", IPID
print *," Now I am waiting for the end of the child process"
call PXFWAIT(ISTAT, IPID_RET, IERROR)
print *," The child with pid ", IPID_RET," has exited"
if( PXFWIFEXITED(ISTAT) ) then
print *, " The child exited normally"
istat_ret = IPXFWEXITSTATUS(ISTAT)
print 10," The low byte of the child exit code is", istat_ret
end if
end if
10 FORMAT (A,Z)
end program
See Also
PXFWAIT
PXFWAITPID
PXFWIFEXITED
Module
USE IFPOSIX
Syntax
result = IPXFWSTOPSIG (istat)
Results
The result type is INTEGER(4). The result is the number of the signal that caused the child process to stop.
The IPXFWSTOPSIG function should only be used if PXFWIFSTOPPED returns TRUE.
See Also
PXFWAIT
1730
Language Reference
PXFWAITPID
PXFWIFSTOPPED
Module
USE IFPOSIX
Syntax
result = IPXFWTERMSIG (istat)
Results
The result type is INTEGER(4). The result is the number of the signal that caused the child process to
terminate.
The IPXFWTERMSIG function should only be used if PXFWIFSIGNALED returns TRUE.
See Also
PXFWAIT
PXFWAITPID
PXFWIFSIGNALED
IRAND, IRANDM
Portability Functions: Return random numbers in
the range 0 through (2**31)-1, or 0 through
(2**15)-1 if called without an argument.
Module
USE IFPORT
Syntax
result = IRAND ([iflag])
result = IRANDM ([iflag])
iflag (Input) INTEGER(4). Optional for IRAND. Controls the way the
returned random number is chosen. If iflag is omitted, it is assumed
to be 0, and the return range is 0 through (2**15)-1 (inclusive).
Results
The result type is INTEGER(4). If iflag is 1, the generator is restarted and the first random value is returned.
If iflag is 0, the next random number in the sequence is returned. If iflag is neither zero nor 1, it is used as a
new seed for the random number generator, and the functions return the first new random value.
IRAND and IRANDM are equivalent and return the same random numbers. Both functions are included to
ensure portability of existing code that references one or both of them.
You can use SRAND to restart the pseudorandom number generator used by these functions.
1731
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
USE IFPORT
INTEGER(4) istat, flag_value, r_nums(20)
flag_value=1
r_nums(1) = IRAND (flag_value)
flag_value=0
do istat=2,20
r_nums(istat) = irand(flag_value)
end do
See Also
RANDOM_INIT
RANDOM_NUMBER
RANDOM_SEED
SRAND
IRANGET
Portability Subroutine: Returns the current seed.
Module
USE IFPORT
Syntax
CALL IRANGET (seed)
See Also
IRANSET
IRANSET
Portability Subroutine: Sets the seed for the
random number generator.
Module
USE IFPORT
Syntax
CALL IRANSET (seed)
See Also
IRANGET
IS_CONTIGUOUS
Inquiry Intrinsic Function (Generic): Tests the
contiguity of an array.
1732
Language Reference
Syntax
result = IS_CONTIGUOUS (array)
Results
The result is default logical scalar. The result has the value .TRUE. if array is contiguous; otherwise, .FALSE..
Example
After the pointer assignment MY_P => TARGET (2:20:4), IS_CONTIGUOUS (MY_P) has the value .FALSE..
See Also
CONTIGUOUS
IS_DEVICE_PTR Clause
Parallel Directive Clause: Indicates that a list item
is a device pointer currently in the device data
environment and that it should be used directly
Syntax
IS_DEVICE_PTR (list)
list Is a list of one or more variables that are of type C_PTR from the
intrinsic module ISO_C_BINDING, or that do not have the POINTER,
ALLOCATABLE, or VALUE attribute1. Each list item is a device pointer
currently in the device data environment and that it should be used
directly.
1 List items not of type C_PTR have been deprecated in the OpenMP* specification.
If a list item in a MAP clause is an array section, and the array section is derived from a variable with a
POINTER or ALLOCATABLE attribute, then the behavior is unspecified if the corresponding list item's variable
is modified in the region.
A list item may be a device address returned as the result of a call to the OpenMP* run-time library memory
management function omp_target_alloc function.
IS_IOSTAT_END
Elemental Intrinsic Function (Generic): Tests for
an end-of-file condition.
Syntax
result=IS_IOSTAT_END(i)
Results
The result type is default logical. The value of the result is true only if i is a value that could be assigned to
the scalar integer variable in an IOSTAT= specifier to indicate an end-of-file condition.
1733
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
INTEGER IO_STATUS
…
READ (20, IOSTAT=IO_STATUS) A, B, C
IF (IS_IOSTAT_END (IO_STATUS)) THEN
… ! process end of file
ENDIF
… ! process data read
IS_IOSTAT_EOR
Elemental Intrinsic Function (Generic): Tests for
an end-of-record condition.
Syntax
result=IS_IOSTAT_EOR(i)
Results
The result type is default logical. The value of the result is true only if i is a value that could be assigned to
the scalar integer variable in an IOSTAT= specifier to indicate an end-of-record condition.
Example
INTEGER IO_STATUS
…
READ (30, ADVANCE='YES', IOSTAT=IO_STATUS) A, B, C
IF (IS_IOSTAT_EOR (IO_STATUS)) THEN
… ! process end of record
ENDIF
… ! process data read
ISATTY
Portability Function: Checks whether a logical unit
number is a terminal.
Module
USE IFPORT
Syntax
result = ISATTY (lunit)
Results
The result type is LOGICAL(4). The result is .TRUE. if the specified logical unit is connected to a terminal
device; otherwise, .FALSE..
If lunit is out of range or is not connected, zero is returned.
1734
Language Reference
ISHA
Elemental Intrinsic Function (Generic):
Arithmetically shifts an integer left or right by a
specified number of bits.
Syntax
result = ISHA (i,shift)
shift (Input) Must be of type integer. This argument is the direction and
distance of shift.
Positive shifts are left (toward the most significant bit); negative shifts
are right (toward the least significant bit).
Results
The result type and kind are the same as i. The result is equal to i shifted arithmetically by shift bits.
If shift is positive, the shift is to the left; if shift is negative, the shift is to the right. If shift is zero, no shift is
performed.
Bits shifted out from the left or from the right, as appropriate, are lost. If the shift is to the left, zeros are
shifted in on the right. If the shift is to the right, copies of the sign bit (0 for non-negative i; 1 for negative i)
are shifted in on the left.
The kind of integer is important in arithmetic shifting because sign varies among integer representations (see
the following example). If you want to shift a one-byte or two-byte argument, you must declare it as
INTEGER(1) or INTEGER(2).
Example
INTEGER(1) i, res1
INTEGER(2) j, res2
i = -128 ! equal to 10000000
j = -32768 ! equal to 10000000 00000000
res1 = ISHA (i, -4) ! returns 11111000 = -8
res2 = ISHA (j, -4) ! returns 11111000 10100000 = -2048
See Also
ISHC
ISHL
ISHFT
ISHFTC
ISHC
Elemental Intrinsic Function (Generic): Rotates
an integer left or right by specified number of bits.
Bits shifted out one end are shifted in the other end.
No bits are lost.
Syntax
result = ISHC (i,shift)
1735
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
shift (Input) Must be of type integer. This argument is the direction and
distance of rotation.
Positive rotations are left (toward the most significant bit); negative
rotations are right (toward the least significant bit).
Results
The result type and kind are the same as i. The result is equal to i circularly rotated by shift bits.
If shift is positive, i is rotated left shift bits. If shift is negative, i is rotated right shift bits. Bits shifted out one
end are shifted in the other. No bits are lost.
The kind of integer is important in circular shifting. With an INTEGER(4) argument, all 32 bits are shifted. If
you want to rotate a one-byte or two-byte argument, you must declare it as INTEGER(1) or INTEGER(2).
Example
INTEGER(1) i, res1
INTEGER(2) j, res2
i = 10 ! equal to 00001010
j = 10 ! equal to 00000000 00001010
res1 = ISHC (i, -3) ! returns 01000001 = 65
res2 = ISHC (j, -3) ! returns 01000000 00000001 =
! 16385
See Also
ISHA
ISHL
ISHFT
ISHFTC
ISHFT
Elemental Intrinsic Function (Generic): Performs
a logical shift.
Syntax
result = ISHFT (i,shift)
shift (Input) Must be of type integer. The absolute value for shift must be
less than or equal to BIT_SIZE( i).
Results
The result type and kind are the same as i. The result has the value obtained by shifting the bits of i by shift
positions. If shift is positive, the shift is to the left; if shift is negative, the shift is to the right. If shift is zero,
no shift is performed.
Bits shifted out from the left or from the right, as appropriate, are lost. Zeros are shifted in from the opposite
end.
ISHFT with a positive shift can also be specified as LSHIFT (or LSHFT). ISHFT with a negative shift can also
be specified as RSHIFT (or RSHFT) with | shift |.
1736
Language Reference
Example
ISHFT (2, 1) has the value 4.
ISHFT (2, -1) has the value 1.
The following shows another example:
INTEGER(1) i, res1
INTEGER(2) j, k(3), res2
i = 10 ! equal to 00001010
j = 10 ! equal to 00000000 00001010
res1 = ISHFT (i, 5) ! returns 01000000 = 64
res2 = ISHFT (j, 5) ! returns 00000001 01000000 =
! 320
k = ISHFT((/3, 5, 1/), (/1, -1, 0/)) ! returns array
! /6, 2, 1/
See Also
BIT_SIZE
ISHFTC
ISHA
ISHC
ISHFTC
Elemental Intrinsic Function (Generic): Performs
a circular shift of the rightmost bits.
Syntax
result = ISHFTC (i,shift[,size])
shift (Input) Must be of type integer. The absolute value of shift must be
less than or equal to size.
1737
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type and kind are the same as i. The result value is obtained by circular shifting the size rightmost
bits of i by shift positions. If shift is positive, the shift is to the left; if shift is negative, the shift is to the
right. If shift is zero, no shift is performed.
No bits are lost. Bits in i beyond the value specified by size are unaffected.
For more information on bit functions, see Bit Functions.
The model for the interpretation of an integer value as a sequence of bits is shown in Model for Bit Data.
Example
ISHFTC (4, 2, 4) has the value 1.
ISHFTC (3, 1, 3) has the value 6.
The following shows another example:
INTEGER(1) i, res1
INTEGER(2) j, res2
i = 10 ! equal to 00001010
j = 10 ! equal to 00000000 00001010
res1 = ISHFTC (i, 2, 3) ! rotates the 3 rightmost
! bits by 2 (left) and
! returns 00001001 = 9
res1 = ISHFTC (i, -2, 3) ! rotates the 3 rightmost
! bits by -2 (right) and
! returns 00001100 = 12
res2 = ISHFTC (j, 2, 3) ! rotates the 3 rightmost
! bits by 2 and returns
! 00000000 00001001 = 9
See Also
BIT_SIZE
ISHFT
MVBITS
ISHL
Elemental Intrinsic Function (Generic): Logically
shifts an integer left or right by the specified bits.
Zeros are shifted in from the opposite end.
Syntax
result = ISHL (i,shift)
1738
Language Reference
shift (Input) Must be of type integer. This argument is the direction and
distance of shift.
If positive, i is shifted left (toward the most significant bit). If
negative, i is shifted right (toward the least significant bit).
Results
The result type and kind are the same as i. The result is equal to i logically shifted by shift bits. Zeros are
shifted in from the opposite end.
Unlike circular or arithmetic shifts, which can shift ones into the number being shifted, logical shifts shift in
zeros only, regardless of the direction or size of the shift. The integer kind, however, still determines the end
that bits are shifted out of, which can make a difference in the result (see the following example).
Example
INTEGER(1) i, res1
INTEGER(2) j, res2
i = 10 ! equal to 00001010
j = 10 ! equal to 00000000 00001010
res1 = ISHL (i, 5) ! returns 01000000 = 64
res2 = ISHL (j, 5) ! returns 00000001 01000000 = 320
See Also
ISHA
ISHC
ISHFT
ISHFTC
ISNAN
Elemental Intrinsic Function (Generic): Tests
whether IEEE* real (binary32, binary64, and
binary128) numbers are Not-a-Number (NaN) values.
Syntax
result = ISNAN (x)
Results
The result type is default logical. The result is .TRUE. if x is an IEEE NaN; otherwise, the result is .FALSE..
Example
LOGICAL A
DOUBLE PRECISION B
...
A = ISNAN(B)
A is assigned the value .TRUE. if B is an IEEE NaN; otherwise, the value assigned is .FALSE..
1739
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
ITIME
Portability Subroutine: Returns the time in numeric
form.
Module
USE IFPORT
Syntax
CALL ITIME (array)
array (Output) INTEGER(4). A rank one array with three elements used to
store numeric time data:
• array(1) - the hour
• array(2) - the minute
• array(3) - the second
Example
USE IFPORT
INTEGER(4) time_array(3)
CALL ITIME (time_array)
write(*,10) time_array
10 format (1X,I2,':',I2,':',I2)
END
See Also
DATE_AND_TIME
IVDEP
General Compiler Directive: Assists the compiler's
dependence analysis of iterative DO loops.
Syntax
!DIR$ IVDEP [: option]
The IVDEP directive is an assertion to the compiler's optimizer about the order of memory references inside a
DO loop.
IVDEP:LOOP implies no loop-carried dependencies. IVDEP:BACK implies no backward dependencies.
When no option is specified, the following occurs:
• The compiler begins dependence analysis by assuming all dependences occur in the same forward
direction as their appearance in the normal scalar execution order. This contrasts with normal compiler
behavior, which is for the dependence analysis to make no initial assumptions about the direction of a
dependence.
!DIR$ IVDEP with no option can also be spelled !DIR$ INIT_DEP_FWD (INITialize DEPendences ForWarD).
The IVDEP directive is applied to a DO loop in which the user knows that dependences are in lexical order.
For example, if two memory references in the loop touch the same memory location and one of them
modifies the memory location, then the first reference to touch the location has to be the one that appears
earlier lexically in the program source code. This assumes that the right-hand side of an assignment
statement is "earlier" than the left-hand side.
1740
Language Reference
The IVDEP directive informs the compiler that the program would behave correctly if the statements were
executed in certain orders other than the sequential execution order, such as executing the first statement or
block to completion for all iterations, then the next statement or block for all iterations, and so forth. The
optimizer can use this information, along with whatever else it can prove about the dependences, to choose
other execution orders.
Example
In the following example, the IVDEP directive provides more information about the dependences within the
loop, which may enable loop transformations to occur:
!DIR$ IVDEP
DO I=1, N
A(INDARR(I)) = A(INDARR(I)) + B(I)
END DO
In this case, the scalar execution order follows:
1. Retrieve INDARR(I).
2. Use the result from step 1 to retrieve A(INDARR(I)).
3. Retrieve B(I).
4. Add the results from steps 2 and 3.
5. Store the results from step 4 into the location indicated by A(INDARR(I)) from step 1.
IVDEP directs the compiler to initially assume that when steps 1 and 5 access a common memory location,
step 1 always accesses the location first because step 1 occurs earlier in the execution sequence. This
approach lets the compiler reorder instructions, as long as it chooses an instruction schedule that maintains
the relative order of the array references.
See Also
General Compiler Directives
Syntax Rules for Compiler Directives
Rules for General Directives that Affect DO Loops
Rules for Loop Directives that Affect Array Assignment Statements
J to L
This section describes language features that start with J, K, or L.
J to L
JABS
Portability Function: Returns an absolute value.
Module
USE IFPORT
Syntax
result = JABS (i)
Results
The result type is INTEGER(4). The value of the result is | i |.
1741
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
JDATE
Portability Function: Returns an 8-character string
with the Julian date in the form "yyddd". Three spaces
terminate this string.
Module
USE IFPORT
Syntax
result = JDATE( )
Results
The result type is character with length 8. The result is the Julian date, in the form YYDDD, followed by three
spaces.
The Julian date is a five-digit number whose first two digits are the last two digits of the year, and whose
final three digits represent the day of the year (1 for January 1, 366 for December 31 of a leap year, and so
on). For example, the Julian date for February 1, 1999 is 99032.
Caution
The two-digit year return value may cause problems with the year 2000. Use
DATE_AND_TIME instead.
Example
! Sets julian to today's julian date
USE IFPORT
CHARACTER*8 julian
julian = JDATE( )
See Also
DATE_AND_TIME
JDATE4
Portability Function: Returns a 10-character string
with the Julian date in the form "yyyyddd". Three
spaces terminate this string.
Module
USE IFPORT
Syntax
result = JDATE4( )
Results
The result type is character with length 10. The result is the Julian date, in the form YYYYDDD, followed by
three spaces.
The Julian date is a seven-digit number whose first four digits are the year, and whose final three represent
the day of the year (1 for January 1, 366 for December 31 of a leap year, and so on). For example, the Julian
date for February 1, 1999 is 1999032.
1742
Language Reference
See Also
DATE_AND_TIME
JNUM
Elemental Intrinsic Function (Specific): Converts
a character string to an INTEGER(4) value. This
function cannot be passed as an actual argument.
Syntax
result = JNUM (i)
Results
The result type is INTEGER(4). The result value is the integer value represented by the character string i.
If the argument contains characters that are illegal in an integer value, an error is signaled and execution
stops.
Example
JNUM ("46616") has the value 46616 of type INTEGER(4).
KILL
Portability Function: Sends a signal to the process
given by ID.
Module
USE IFPORT
Syntax
result = KILL (pid,signum)
signum (Input) INTEGER(4). A signal value. For the definition of signal values,
see the SIGNALfunction.
Results
The result type is INTEGER(4). The result is zero if the call was successful; otherwise, an error code. Possible
error codes are:
• EINVAL: The signum is not a valid signal number, or PID is not the same as getpid( ) and signum does not
equal SIGKILL.
• ESRCH: The given PID could not be found.
• EPERM: The current process does not have permission to send a signal to the process given by PID.
On Windows* systems, arbitrary signals can be sent only to the calling process (where pid= getpid( )). Other
processes can send only the SIGKILL signal ( signum= 9), and only if the calling process has permission.
1743
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
USE IFPORT
integer(4) id_number, sig_val, istat
id_number=getpid( )
ISTAT = KILL (id_number, sig_val)
See Also
SIGNAL
RAISEQQ
SIGNALQQ
KIND
Inquiry Intrinsic Function (Generic): Returns the
kind parameter of the argument.
Syntax
result = KIND (x)
Results
The result is a scalar of type default integer. The result has a value equal to the kind type parameter value of
x.
Example
KIND (0.0) has the kind value of default real type.
KIND (12) has the kind value of default integer type.
The following shows another example:
See Also
SELECTED_INT_KIND
SELECTED_REAL_KIND
CMPLX
INT
REAL
LOGICAL
CHAR
Intrinsic Data Types
Argument Keywords in Intrinsic Procedures
1744
Language Reference
KNUM
Elemental Intrinsic Function (Specific): Converts
a character string to an INTEGER(8) value.
Syntax
result = KNUM (i)
Results
The result type is INTEGER(8). The result value is the integer value represented by the character string i.
If the argument contains characters that are illegal in an integer value, an error is signaled and execution
stops.
Example
KNUM ("46616") has the value 46616 of type INTEGER(8).
LASTPRIVATE
Parallel Directive Clause: Provides a superset of the
functionality provided by the PRIVATE clause. It
declares one or more variables to be private to an
implicit task, and causes the corresponding original
variable to be updated after the end of the region.
Syntax
LASTPRIVATE ([CONDITIONAL:] list)
CONDITIONAL Is an optional modifier specifying that the last value assigned to a list
item can be from the sequentially last iteration of the associated loops
or the lexically last section construct.
list Is the name of one or more variables or common blocks that are
accessible to the scoping unit. Subobjects cannot be specified. Each
name must be separated by a comma, and a named common block
must appear between slashes (/ /).
If CONDITIONAL is present, list items must be scalar of intrinsic type
(INTEGER, REAL, COMPLEX, LOGICAL, and CHARACTER) and they
must have neither the POINTER nor the ALLOCATABLE attribute.
Variables that appear in a LASTPRIVATE list are subject to PRIVATE clause semantics. In addition, once the
parallel region is exited, each variable has the value provided by the sequentially last section or loop
iteration.
Multiple LASTPRIVATE clauses are allowed on all of the directives that accept them. A list item may not
appear in more than one LASTPRIVATE clause. LASTPRIVATE (CONDITIONAL:A,B) is equivalent to
LASTPRIVATE(CONDITIONAL:A) LASTPRIVATE(CONDITIONAL:B).
LASTPRIVATE (CONDITIONAL:list) can appear in the following directives:
• OMP DISTRIBUTE
• OMP DO
• OMP SECTIONS
• OMP SIMD
1745
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• OMP TASKLOOP
• Any and all of the combination directives of the above directives
The OMP PARALLEL directive does not allow the LASTPRIVATE clause.
If the original variable has the POINTER attribute, its update occurs as if by pointer assignment.
If the original variable does not have the POINTER attribute, its update occurs as if by intrinsic assignment.
When a LASTPRIVATE clause without the CONDITIONAL modifier appears in a worksharing or a SIMD
directive, the value of each new list item from the sequentially last iteration of the associated loops, or the
lexically last section, is assigned to the original list item.
When the CONDITIONAL modifier is specified, the final value written by the sequentially last iteration or
lexically last section that writes to a list item, if any, is assigned to the original list item.
When the CONDITIONAL modifier is not specified, list items that are not assigned a value by the sequentially
last iteration of the loops, or by the lexically last section, have unspecified values after the construct.
Therefore, variables specified in the list of a LASTPRIVATE clause that contains a CONDITIONAL modifier
should be variables that are conditionally assigned to in the loop/region/sections. The variables in the list of a
LASTPRIVATE clause that does not contain a CONDITIONAL modifier should be variables that are
unconditionally assigned to in the loop or sections.
Subobjects that are not assigned a value by the last iteration of the DO or the lexically last SECTION of the
SECTIONS directive are undefined after the construct.
The original variable becomes defined at the end of the construct if there is an implicit barrier at that point.
To avoid race conditions, concurrent reads or updates of the original variable must be synchronized with the
update of the original variable that occurs as a result of the LASTPRIVATE clause.
If the LASTPRIVATE clause is used in a construct for which NOWAIT is specified, accesses to the original
variable may create a data race. To avoid this, synchronization must be inserted to ensure that the
sequentially last iteration or lexically last section construct has stored and flushed that variable.
The following are restrictions for the LASTPRIVATE clause:
• A variable that is part of another variable (as an array or structure element) must not appear in a
PRIVATE clause.
• A variable that is private within a parallel region, or that appears in the REDUCTION clause of a PARALLEL
construct, must not appear in a LASTPRIVATE clause on a worksharing construct if any of the
corresponding worksharing regions ever binds to any of the corresponding parallel regions.
• A variable that appears in a LASTPRIVATE clause must be definable.
• An original variable with the ALLOCATABLE attribute must be in the allocated state at entry to the
construct containing the LASTPRIVATE clause. The variable in the sequentially last iteration or lexically last
section must be in the allocated state upon exit from that iteration or section with the same bounds as the
corresponding original variable.
• Assumed-size arrays must not appear in a PRIVATE clause.
• Variables that appear in NAMELIST statements, in variable format expressions, and in expressions for
statement function definitions, must not appear in a PRIVATE clause.
• If a list item appears in both the FIRSTPRIVATE and LASTPRIVATE clauses, the update required for
LASTPRIVATE occurs after all of the initializations for FIRSTPRIVATE.
NOTE
If a variable appears in both FIRSTPRIVATE and LASTPRIVATE clauses, the update required for
LASTPRIVATE occurs after all initializations for FIRSTPRIVATE.
1746
Language Reference
NOTE
If a variable appears in a LASTPRIVATE clause on a combined construct for which the first construct is
TARGET, it is treated as if it had appeared in a MAP clause with a map-type of FROM.
Example
Consider the following:
P = 0
!$OMP DO PRIVATE(I), FIRSTPRIVATE(P), LASTPRIVATE(CONDITIONAL:P)
DO I = 1, 1000
IF (A(I) .EQ. B) THEN
P = I
EXIT
END IF
ENDDO
!$OMP END DO
After the loop, P will be the index of the first element of A to match B; if no match is found, P will be zero.
See Also
PRIVATE Clause
FIRSTPRIVATE clause
LBOUND
Inquiry Intrinsic Function (Generic): Returns the
lower bounds for all dimensions of an array, or the
lower bound for a specified dimension.
Syntax
result = LBOUND (array [, dim] [, kind])
1747
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
dim (Input; optional) Must be a scalar integer with a value in the range 1
to n, where n is the rank array.
Results
The result type is integer. If kind is present, the kind parameter of the result is that specified by kind;
otherwise, the kind parameter of the result is that of default integer. If the processor cannot represent the
result value in the kind of the result, the result is undefined.
If dim is present, the result is a scalar. Otherwise, the result is a rank-one array with one element for each
dimension of array. Each element in the result corresponds to a dimension of array.
If array is an array section or an array expression that is not a whole array or array structure component,
each element of the result has the value 1.
If array is a whole array or array structure component, LBOUND ( array, dim) has a value equal to the lower
bound for subscript dim of array(if dim is nonzero or array is an assumed-size array of rank dim). Otherwise,
the corresponding element of the result has the value 1.
If LBOUND is invoked for an assumed-rank object that is associated with a scalar and dim is absent, the
result is a zero-sized array. LBOUND cannot be invoked for an assumed-rank object that is associated with a
scalar if dim is present because the rank of a scalar is zero and dim must be >= 1.
The setting of compiler options specifying integer size can affect this function.
Example
Consider the following:
See Also
UBOUND
LCOBOUND
Inquiry Intrinsic Function (Generic): Returns the
lower cobounds of a coarray.
Syntax
result = LCOBOUND (coarray [,dim [, kind])
1748
Language Reference
dim (Input; optional) Must be an integer scalar with a value in the range 1
<= dim <= n, where n is the corank of coarray. The corresponding
actual argument must not be an optional dummy argument.
Results
The result type is integer. If kind is present, the kind parameter is that specified by kind; otherwise, the kind
parameter is that of default integer type. The result is scalar if dim is present; otherwise, the result is an
array of rank one and size n, wheren is the corank of coarray.
The result depends on whether dim is specified:
• If dim is specified, LCOBOUND (COARRAY, DIM) has a value equal to the lower cobound for cosubscript
dim of coarray.
• If dim is not specified, LCOBOUND (COARRAY) has a value whose ith element is equal to LCOBOUND
(COARRAY, i), for i = 1, 2,. . . , n, where n is the corank of coarray.
Example
If B is allocated by the statement ALLOCATE (B [2:3, 8:*]), then LCOBOUND (B) is [2, 8] and LCOBOUND (B,
DIM=2) is 8.
LCWRQQ
Portability Subroutine: Sets the value of the
floating-point processor control word.
Module
USE IFPORT
Syntax
CALL LCWRQQ (controlword)
LCWRQQ performs the same function as the run-time subroutine SETCONTROLFPQQ and is provided for
compatibility.
Example
USE IFPORT
INTEGER(2) control
CALL SCWRQQ(control) ! get control word
! Set control word to make processor round up
control = control .AND. (.NOT. FPCW$MCW_RC) ! Clear
! control word with inverse
! of rounding control mask
control = control .OR. FPCW$UP ! Set control word
! to round up
CALL LCWRQQ(control)
WRITE (*, 9000) 'Control word: ', control
9000 FORMAT (1X, A, Z4)
END
1749
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
SETCONTROLFPQQ
LEADZ
Elemental Intrinsic Function (Specific): Returns
the number of leading zero bits in an integer.
Syntax
result = LEADZ (i)
Results
The result type is default integer. The result value is the number of leading zeros in the binary representation
of the integer i.
The model for the interpretation of an integer value as a sequence of bits is shown in Model for Bit Data.
Example
Consider the following:
INTEGER*8 J, TWO
PARAMETER (TWO=2)
DO J= -1, 40
TYPE *, LEADZ(TWO**J) ! Prints 64 down to 23 (leading zeros)
ENDDO
END
LEN
Inquiry Intrinsic Function (Generic): Returns the
length of a character expression.
Syntax
result = LEN (string [, kind])
string (Input) Must be of type character; it can be scalar or array valued. (It
can be an array of strings.)
Results
The result is a scalar of type integer. If kind is present, the kind parameter of the result is that specified by
kind; otherwise, the kind parameter of the result is that of default integer. If the processor cannot represent
the result value in the kind of the result, the result is undefined.
The result has a value equal to the number of characters in string(if it is scalar) or in an element of string(if
it is array valued).
CHARACTER INTEGER(8)
1750
Language Reference
1The setting of compiler options specifying integer size can affect this function.
Example
Consider the following example:
CHARACTER(11) STR(100)
INTEGER I
I = LEN (STR) ! returns 11
I = LEN('A phrase with 5 trailing blanks.^^^^^')
! returns 37
See Also
LEN_TRIM
Declaration Statements for Character Types
Character Data Type
LEN_TRIM
Elemental Intrinsic Function (Generic): Returns
the length of the character argument without counting
trailing blank characters.
Syntax
result = LEN_TRIM (string [, kind])
Results
The result is a scalar of type integer. If kind is present, the kind parameter of the result is that specified by
kind; otherwise, the kind parameter of the result is that of default integer. If the processor cannot represent
the result value in the kind of the result, the result is undefined.
The result has a value equal to the number of characters remaining after any trailing blanks in string are
removed. If the argument contains only blank characters, the result is zero.
The setting of compiler options specifying integer size can affect this function.
Example
LEN_TRIM (' C D ') has the value 4.
LEN_TRIM (' ') has the value 0.
The following shows another example:
INTEGER LEN1
LEN1 = LEN_TRIM (' GOOD DAY ') ! returns 9
LEN1 = LEN_TRIM (' ') ! returns 0
1751
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
LEN
LNBLNK
LGE
Elemental Intrinsic Function (Generic):
Determines if a string is lexically greater than or equal
to another string, based on the ASCII collating
sequence, even if the processor's default collating
sequence is different. In Intel® Fortran, LGE is
equivalent to the (.GE.) operator.
Syntax
result = LGE (string_a,string_b)
Results
The result type is default logical. If the strings are of unequal length, the comparison is made as if the
shorter string were extended on the right with blanks, to the length of the longer string.
The result is true if the strings are equal, both strings are of zero length, or if string_a follows string_b in the
ASCII collating sequence; otherwise, the result is false.
Example
LGE ( 'ONE', 'SIX' ) has the value false.
LGE ( 'TWO', 'THREE' ) has the value true.
The following shows another example:
LOGICAL L
L = LGE('ABC','ABD') ! returns .FALSE.
L = LGE ('AB', 'AAAAAAAB') ! returns .TRUE.
See Also
LGT
LLE
LLT
ASCII and Key Code Charts
LGT
Elemental Intrinsic Function (Generic):
Determines whether a string is lexically greater than
another string, based on the ASCII collating sequence,
1752
Language Reference
Syntax
result = LGT (string_a,string_b)
Results
The result type is default logical. If the strings are of unequal length, the comparison is made as if the
shorter string were extended on the right with blanks, to the length of the longer string.
The result is true if string_a follows string_b in the ASCII collating sequence; otherwise, the result is false. If
both strings are of zero length, the result is also false.
Example
LGT ( 'TWO', 'THREE' ) has the value true.
LGT ( 'ONE', 'FOUR' ) has the value true.
The following shows another example:
LOGICAL L
L = LGT('ABC', 'ABC') ! returns .FALSE.
L = LGT('ABC', 'AABC') ! returns .TRUE.
See Also
LGE
LLE
LLT
ASCII and Key Code Charts
LINEAR Clause
Parallel Directive Clause: Specifies that all variables
in a list are private to a SIMD lane and that they have
a linear relationship within the iteration space of a
loop.
Syntax
It takes one of the following forms:
In Construct Directive !$OMP SIMD:
LINEAR (var-list[: linear-step])
In Declarative Directive !$OMP DECLARE SIMD:
LINEAR (linear-list[: linear-step])
1753
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1754
Language Reference
If more than one linear-step is specified for a var, a compile-time error occurs. Multiple LINEAR clauses can
be used to specify different values for linear-step. The linear-step expression must be invariant (must not be
changed) during the execution of the associated construct. Multiple LINEAR clauses are merged as a union.
The value corresponding to the sequentially last iteration of the associated loops is assigned to the original
list item.
A list item in a LINEAR clause cannot appear in any other data scope attribute clause, in another LINEAR
clause, or more than once in list. For a list of data scope attribute clauses, see the first table in Clauses Used
in Multiple OpenMP* Fortran Directives.
In the sequentially last iteration, any list item with the ALLOCATABLE attribute must have an allocation status
of allocated upon exit from that iteration.
If a list item is a dummy argument without the Fortran Standard VALUE attribute and the REF modifier is not
specified, then a read of the list item must be executed before any writes to the list item.
If a LINEAR clause appears in a directive that also contains a REDUCTION clause with the INSCAN modifier,
only a loop iteration variable of a loop associated with the construct can appear as a list item in the LINEAR
clause.
The following cannot appear in a LINEAR clause:
• Variables that have the POINTER attribute
• Cray* pointers
The LINEAR (REF) clause is very important because Fortran passes dummy arguments by reference. By
default, the compiler places consecutive addresses in a vector register, which leads to an inefficient gather of
the addresses.
In the following example, LINEAR (REF (X)) tells the compiler that the 4 addresses for the dummy argument
X are consecutive, so the code only needs to dereference X once and then copy consecutive values to a
vector register.
subroutine test_linear(x, y)
!$omp declare simd (test_linear) linear(ref(x, y)) ! arguments by reference
real(8),intent(in) :: x
real(8),intent(out) :: y
y = 1. + sin(x)**3
end subroutine test_linear
… ! procedure that calls test_linear
interface ! test_linear needs an explicit interface
…
do j = 1,n
call test_linear(a(j), b(j)) ! loop vectorized via qopenmp-simd
enddo
…
Example
Consider the following:
! universal but slowest definition; it matches the use of func in loops 1, 2, and 3:
!$OMP DECLARE SIMD
!
! matches the use of func in loop 1:
1755
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
!loop 1
!$OMP SIMD
DO i=1,100
c(i) = func(a + i, b(i), mul) ! the value of the 1st parameter is changed linearly,
! the 2nd parameter reference is changed linearly,
! the 3rd parameter is not changed
END DO
!loop 2
!$OMP SIMD
DO i=1,100
c(i) = func(b(ndx(i)), b(i), i + 1 ! the value of the 1st parameter is unpredictable,
! the 2nd reference is changed linearly,
! the 3rd parameter is changed linearly
END DO
!loop 3
!$OMP SIMD
DO i=1,100
k = i * 2 ! during vectorization, private variables are
c(i) = func(b(ndx(i)), k, b(i)) ! transformed into arrays: k -> k_vec(simdlen)
! the value of the 1st parameter is unpredictable,
! for the 2nd parameter both value and reference
! to its location can be considered linear,
! the value for the 3rd parameter is unpredictable
!
! the !$OMP DECLARE SIMD LINEAR(VAL(in2:2))) will
END DO ! be chosen from the two matching variants)
See Also
VALUE statement and attribute
SIMD Directive (OpenMP* API)
DECLARE SIMD
1756
Language Reference
Module
USE IFQWIN
Syntax
result = LINETO (x,y)
result = LINETO_W (wx, wy)
Results
The result type is INTEGER(2). The result is a nonzero value if successful; otherwise, 0.
The line is drawn using the current graphics color, logical write mode, and line style. The graphics color is set
with SETCOLORRGB, the write mode with SETWRITEMODE, and the line style with SETLINESTYLE.
If no error occurs, LINETO sets the current graphics position to the viewport point (x, y), and LINETO_W sets
the current graphics position to the window point (wx, wy).
If you use FLOODFILLRGB to fill in a closed figure drawn with LINETO, the figure must be drawn with a solid
line style. Line style is solid by default and can be changed with SETLINESTYLE.
NOTE
The LINETO routine described here is a QuickWin routine. If you are trying to use the
Microsoft* Platform SDK version of the LineTo routine by including the IFWIN module, you
need to specify the routine name as MSFWIN$LineTo.
Example
This program draws the figure shown below.
1757
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
GETCURRENTPOSITION
GETLINESTYLE
GRSTATUS
MOVETO
POLYGON
POLYLINEQQ
SETLINESTYLE
SETWRITEMODE
LINETOAR (W*S)
Graphics Function: Draws a line between each x,y
point in the from-array to each corresponding x,y
point in the to-array.
Module
USE IFQWIN
Syntax
result = LINETOAR (loc(fx), loc(fy), loc(tx) loc(ty), cnt)
Results
The result type is INTEGER(2). The result is a nonzero value if successful; otherwise, zero.
The lines are drawn using the current graphics color, logical write mode, and line style. The graphics color is
set with SETCOLORRGB, the write mode with SETWRITEMODE, and the line style with SETLINESTYLE.
Example
! Build for QuickWin or Standard Graphics
USE IFQWIN
integer(2) fx(3),fy(3),tx(3),ty(3),result
integer(4) cnt, i
! load the points
do i = 1,3
!from here
fx(i) =20*i
fy(i) =10
!to there
tx(i) =20*i
ty(i) =60
end do
! draw the lines all at once
1758
Language Reference
See Also
LINETO
LINETOAREX
LOC
SETCOLORRGB
SETLINESTYLE
SETWRITEMODE
LINETOAREX (W*S)
Graphics Function: Draws a line between each x,y
point in the from-array to each corresponding x,y
point in the to-array. Each line is drawn with the
specified graphics color and line style.
Module
USE IFQWIN
Syntax
result = LINETOAREX (loc(fx), loc(fy), loc(tx) loc(ty), loc(C), loc(S), cnt)
cnt (Input) INTEGER(4). Length of each coordinate array; also the length
of the color array and style array. All of the arrays should be the same
size.
Results
The result type is INTEGER(2). The result is a nonzero value if successful; otherwise, zero.
The lines are drawn using the specified graphics colors and line styles, and with the current write mode. The
current write mode is set with SETWRITEMODE.
If the color has the Z'80000000' bit set, the color is an RGB color; otherwise, the color is a palette color.
The styles are as follows from wingdi.h:
SOLID 0
DASH 1 /* ------- */
DOT 2 /* ....... */
DASHDOT 3 /* _._._._ */
DASHDOTDOT 4 /* _.._.._ */
NULL 5
1759
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
! Build for QuickWin or Standard Graphics
USE IFQWIN
integer(2) fx(3),fy(3),tx(3),ty(3),result
integer(4) C(3),S(3),cnt,i,color
color = #000000FF
See Also
LINETO
LINETOAR
LOC
POLYLINEQQ
SETWRITEMODE
LLE
Elemental Intrinsic Function (Generic):
Determines whether a string is lexically less than or
equal to another string, based on the ASCII collating
sequence, even if the processor's default collating
sequence is different. In Intel® Fortran, LLE is
equivalent to the (.LE.) operator.
Syntax
result = LLE (string_a,string_b)
Results
The result type is default logical. If the strings are of unequal length, the comparison is made as if the
shorter string were extended on the right with blanks, to the length of the longer string.
The result is true if the strings are equal, both strings are of zero length, or if string_a precedes string_b in
the ASCII collating sequence; otherwise, the result is false.
1760
Language Reference
Example
LLE ( 'TWO', 'THREE' ) has the value false.
LLE ( 'ONE', 'FOUR' ) has the value false.
The following shows another example:
LOGICAL L
L = LLE('ABC', 'ABC') ! returns .TRUE.
L = LLE('ABC', 'AABCD') ! returns .FALSE.
See Also
LGE
LGT
LLT
ASCII and Key Code Charts
LLT
Elemental Intrinsic Function (Generic):
Determines whether a string is lexically less than
another string, based on the ASCII collating sequence,
even if the processor's default collating sequence is
different. In Intel® Fortran, LLT is equivalent to the <
(.LT.) operator.
Syntax
result = LLT (string_a,string_b)
Results
The result type is default logical. If the strings are of unequal length, the comparison is made as if the
shorter string were extended on the right with blanks, to the length of the longer string.
The result is true if string_a precedes string_b in the ASCII collating sequence; otherwise, the result is false.
If both strings are of zero length, the result is also false.
Example
LLT ( 'ONE', 'SIX' ) has the value true.
1761
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
LOGICAL L
L = LLT ('ABC', 'ABC') ! returns .FALSE.
L = LLT ('AAXYZ', 'ABCDE') ! returns .TRUE.
See Also
LGE
LGT
LLE
ASCII and Key Code Charts
LNBLNK
Portability Function: Locates the position of the last
nonblank character in a string.
Module
USE IFPORT
Syntax
result = LNBLNK (string)
Results
The result type is INTEGER(4). The result is the index of the last nonblank character in string.
LNBLNK is very similar to the intrinsic function LEN_TRIM, except that string cannot be an array.
Example
USE IFPORT
integer(4) p
p = LNBLNK(' GOOD DAY ') ! returns 9
p = LNBLNK(' ') ! returns 0
See Also
LEN_TRIM
Module
USE IFQWIN
Syntax
result = LOADIMAGE (filename,xcoord,ycoord)
result = LOADIMAGE_W (filename,wxcoord,wycoord)
1762
Language Reference
wxcoord, wycoord (Input) REAL(8). Window coordinates for upper-left corner of image
display.
Results
The result type is INTEGER(4). The result is zero if successful; otherwise, a negative value.
The image is displayed with the colors in the bitmap file. If the color palette in the bitmap file is different
from the current system palette, the current palette is discarded and the bitmap's palette is loaded.
LOADIMAGE specifies the screen placement of the image in viewport coordinates. LOADIMAGE_W specifies
the screen placement of the image in window coordinates.
See Also
SAVEIMAGE, SAVEIMAGE_W
LOC
Inquiry Intrinsic Function (Generic): Returns the
internal address of a storage item. This function
cannot be passed as an actual argument.
Syntax
result = LOC (x)
Results
The result type is INTEGER(4) on IA-32 architecture; INTEGER(8) on Intel® 64 architecture. The value of the
result represents the address of the data object or, in the case of pointers, the address of its associated
target. If the argument is not valid, the result is undefined.
This function performs the same function as the %LOC built-in function.
Example
The Fortran standard provides the C_LOC intrinsic module function as an alternative to the non-standard
LOC. For more information, see the descriptions of C_LOC, C_FUNLOC, C_F_POINTER and
C_F_PROCPOINTER.
1763
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
%LOC
Built-in Function: Computes the internal address of
a storage item.
Syntax
result = %LOC (a)
Description
The result type is INTEGER(4) on IA-32 architecture; INTEGER(8) on Intel® 64 architecture. The value of the
result represents the address of the data object or, in the case of pointers, the address of its associated
target. If the argument is not valid, the result is undefined.
This function performs the same function as the LOC intrinsic function.
Syntax
LOCK (lock-var [, ACQUIRED_LOCK=log-var] [, STAT=stat-var] [, ERRMSG=err-var])
UNLOCK (lock-var [, STAT=stat-var] [, ERRMSG=err-var])
ACQUIRED_LOCK=, STAT=, and ERRMSG= can appear in any order, but only once in a LOCK statement.
STAT= and ERRMSG= can appear in either order, but only once in an UNLOCK statement.
Description
A lock variable is unlocked if its value is equal to that of the structure constructor LOCK_TYPE ( ). If it has
any other value, it is locked.
A lock variable is locked by an image if it was locked by execution of a LOCK statement on that image and
has not been subsequently unlocked by execution of an UNLOCK statement on the same image.
When a LOCK statement is specified without an ACQUIRED_LOCK= specifier, it causes the lock variable to
become locked by that image. If the lock variable is already locked by another image, that LOCK statement
causes the lock variable to become defined after the other image causes the lock variable to become
unlocked.
1764
Language Reference
If the lock variable is unlocked, successful execution of a LOCK statement with an ACQUIRED LOCK=
specifier causes the lock variable to become locked by that image and the log-var to become defined with the
value TRUE. If the lock variable is already locked by a different image, successful execution of a LOCK
statement with an ACQUIRED LOCK= specifier leaves the lock variable unchanged and causes the log-var to
become defined with the value FALSE.
During the execution of the program, the value of a lock variable changes through a sequence of locked and
unlocked states when LOCK and UNLOCK statements are executed. If a lock variable becomes unlocked by
execution of an UNLOCK statement on image M and next becomes locked by execution of a LOCK statement
on image T, the segments preceding the UNLOCK statement on image M precede the segments following the
LOCK statement on image T. Execution of a LOCK statement that does not cause the lock variable to become
locked does not affect segment ordering.
An error condition occurs in the following cases:
• If the lock variable in a LOCK statement is already locked by the executing image
• If the lock variable in an UNLOCK statement is not already locked by the executing image
If an error condition occurs during execution of a LOCK or UNLOCK statement, the value of the lock variable
is not changed and the value of the ACQUIRED_LOCK variable, if any, is not changed.
Example
The following example shows the use of LOCK and UNLOCK statements to manage a work queue:
TYPE(Task) :: current_task
INTEGER :: my_image
my_image = THIS_IMAGE()
DO
! Process the next task in the work queue
LOCK (work_queue_lock) ! Start of new segment A
! Segment A is ordered with respect to segment B
! executed by image my_image-1 below because of lock exclusion
IF (work_queue_size>0) THEN
! Get the next job from the queue
current_task = work_queue(work_queue_size)
work_queue_size = work_queue_size-1
END IF
UNLOCK (work_queue_lock) ! Segment ends
...
! Process the task
1765
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Image Control Statements
Coarrays
Using Coarrays
LOG
Elemental Intrinsic Function (Generic): Returns
the natural logarithm of the argument.
Syntax
result = LOG (x)
Results
The result type and kind are the same as x. The result value is approximately equal to logex.
If the arguments are complex, the result is the principal value with imaginary part omega in the range -pi <=
omega <= pi.
If the real part of x < 0 and the imaginary part of x is a positive real zero, the imaginary part of the result is
pi.
If the real part of x < 0 and the imaginary part of x is a negative real zero, the imaginary part of the result is
-pi.
Example
LOG (8.0) has the value 2.079442.
LOG (25.0) has the value 3.218876.
The following shows another example:
REAL r
r = LOG(10.0) ! returns 2.302585
1766
Language Reference
See Also
EXP
LOG10
LOG_GAMMA
Elemental Intrinsic Function (Generic): Returns
the logarithm of the absolute value of the gamma
function of the argument.
Syntax
result = LOG_GAMMA (x)
Results
The result type and kind are the same as x.
The result has a value equal to a processor-dependent approximation to the natural logarithm of the absolute
value of the gamma function of x.
Example
LOG_GAMMA (3.0) has the approximate value 0.693.
LOG10
Elemental Intrinsic Function (Generic): Returns
the common logarithm of the argument.
Syntax
result = LOG10 (x)
Results
The result type and kind are the same as x. The result value is approximately equal to log10x.
1767
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
LOG10 (8.0) has the value 0.9030900.
LOG10 (15.0) has the value 1.176091.
The following shows another example:
REAL r
r = LOG10(10.0) ! returns 1.0
See Also
LOG
LOGICAL Function
Elemental Intrinsic Function (Generic): Converts
the logical value of the argument to a logical value
with different kind parameters.
Syntax
result = LOGICAL (l[,kind])
Results
The result is of type logical. If kind is present, the kind parameter is that specified by kind; otherwise, the
kind parameter is that of default logical. The result value is that of l.
The setting of compiler options specifying integer size can affect this function.
Example
LOGICAL (L .OR. .NOT. L) has the value true and is of type default logical regardless of the kind parameter of
logical variable L.
LOGICAL (.FALSE., 2) has the value false, with the parameter of kind 2.
See Also
CMPLX
INT
REAL
Logical Data Types
LOGICAL Statement
Statement: Specifies the LOGICAL data type.
Syntax
LOGICAL
LOGICAL([KIND=] n)
LOGICAL*n
n Is kind 1, 2, 4, or 8.
1768
Language Reference
If a kind parameter is specified, the logical constant has the kind specified. If no kind parameter is specified,
the kind of the constant is default logical.
Example
LOGICAL, ALLOCATABLE :: flag1, flag2
LOGICAL (2), SAVE :: doit, dont=.FALSE.
LOGICAL switch
See Also
Logical Data Types
Logical Constants
Data Types, Constants, and Variables
LONG
Portability Function: Converts an INTEGER(2)
argument to INTEGER(4) type.
Module
USE IFPORT
Syntax
result = LONG (int2)
Results
The result type is INTEGER(4). The result is the value of int2 with type INTEGER(4). The upper 16 bits of the
result are zeros and the lower 16 are equal to int2.
See Also
INT
KIND
LOOP
OpenMP* Fortran Compiler Directive: Specifies
that the iterations of the associated loops can execute
concurrently. This feature is only available for ifx.
Syntax
!$OMP LOOP [clause[[,] clause]... ]
do-loop
[!$OMP END LOOP]
1769
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• BIND (binding)
Determines the binding region of the construct. binding is teams,
parallel, or thread.
If teams is specified, and an innermost enclosing teams region
exists, the binding region is that innermost teams region. If
parallel is specified, the binding region is the innermost
enclosing parallel region. It may be an implicit parallel region. If
thread is specified, the binding region is not defined.
If the BIND clause does not appear and the construct is enclosed in
a teams or parallel region, the binding region is the innermost
enclosing team or parallel region. If no teams or parallel region
encloses the loop construct, the binding region is undefined.
If the binding region is a parallel region, the binding thread set
is the set of threads executing the parallel region. If the binding
region is a teams region, the biding thread set is the set of primary
threads executing the region. If the binding region is not defined,
the binding thread is the encountering thread.
• COLLAPSE (n)
For n, a value greater than 1 tells the compiler the number of
associated loops to collapse into a larger iterations space, which
executes without ordering.The associated loop nest must not
contain any OpenMP* directives between associated loops in the
nest.
If no COLLAPSE clause appears, or if it appears with a value of 1
for n, only the outermost loop is associated with the LOOP
construct.
At most one COLLAPSE clause is permitted on a LOOP directive.
• LASTPRIVATE ([CONDITIONAL:] list)
Only a loop iteration variable of a loop associated with the LOOP
construct may appear as a list item in a LASTPRIVATE clause.
• ORDER (CONCURRENT)
Indicates that the iterations of the loop may execute in any order
or simultaneously. This is also the behavior when the clause is not
specified.
• PRIVATE (list)
• REDUCTION ([DEFAULT,]reduction-identifier : list)
do-loop Is a DO loop that may contain other nested DO loops. The DO loops
must all be in canonical loop form.
The LOOP construct tells the compiler that all iterations of the associated loops can execute concurrently or in
any order.
If used, the END LOOP directive must appear immediately after the end of the loop. If you do not specify an
END LOOP directive, an END LOOP directive is assumed at the end of the outermost associated do-loop.
A LOOP construct can not contain calls to procedures containing other OpenMP* constructs or calls to the
OpenMP* runtime library functions.
The only OpenMP* constructs permitted inside a LOOP construct are another LOOP, PARALLEL, or SIMD
construct or a combined construct whose leftmost construct is a PARALLEL construct.
1770
Language Reference
A LOOP construct that appears in a procedure and is not nested inside another OpenMP* construct must
contain a BIND clause.
If more than one loop is associated with the construct, any intervening code between two associated loops
executes at least once per iteration of the loop containing the intervening code, and at most once per
execution of the innermost loop associated with the construct. If an associated loop has a trip count of zero
and that loop does not contain the intervening code, the behavior is undefined.
The set of threads that may execute iterations of the LOOP construct is the binding thread set. Each iteration
is executed by one of these threads.
If a loop region is bound to a teams region, the threads in the binding set can continue execution at the end
of the loop region without waiting for all iterations of the region to complete execution. All iterations of the
loop region must complete execution before the end of the teams region. If the binding region is not a teams
region, all iterations of the associated loops must complete execution before the loop region is exited.
If a loop region is bound to a teams or parallel region, it must be encountered by all or none of the
binding threads.
A LOOP construct with a BIND clause that specifies a value of teams must be strictly nested inside a teams
region. The behavior of a LOOP construct with a BIND clause specifying a value of parallel is undefined if
the loop construct is nested inside a SIMD construct.
Referencing a THREADPRIVATE variable in a LOOP construct results in undefined behavior.
If a reduction-modifier is present in a reduction clause, the only permitted value is DEFAULT.
Example
In the following example, the loop iteration variable is private by default, and it is not necessary to explicitly
declare it. The END LOOP directive is optional. Iterations of the do loop can execute in any order, or
concurrently.
!$OMP PARALLEL
!$OMP LOOP
DO I=1,N
B(I) = (A(I) + A(I-1)) / 2.0
END DO
!$OMP END LOOP
!$OMP END PARALLEL
In the next example, the loops over J1 and J2 are collapsed and their iteration space is executed by all
threads of the current team. The subroutine BAR referenced in the innermost loop cannot contain OpenMP*
constructs or calls to procedures that do, and it cannot contain calls to the OpenMP* runtime library. The
END LOOP directive is optional:
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
Rules for General Directives that Affect DO Loops
Parallel Processing Model for information about Binding Sets
1771
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
LOOP COUNT
General Compiler Directive: Specifies the iterations
(typical trip count) for a DO loop.
Syntax
!DIR$ LOOP COUNT (n1[, n2]...)
!DIR$ LOOP COUNT= n1[, n2]...
!DIR$ LOOP COUNT qualifier(n)[, qualifier(n)]...
!DIR$ LOOP COUNT qualifier=n[, qualifier=n]...
The value of the loop count affects heuristics used in software pipelining, vectorization, and loop-
transformations.
Example
Consider the following:
See Also
General Compiler Directives
LSHIFT
Elemental Intrinsic Function (Generic): Shifts the
bits in an integer left by a specified number of
positions. This is the same as specifying ISHFT with a
positive shift.
See Also
See ISHFT.
1772
Language Reference
LSTAT
Portability Function: Returns detailed information
about a file.
Module
USE IFPORT
Syntax
result = LSTAT (name,statb)
Results
The result type is INTEGER(4). The result is zero if successful; otherwise, an error code (see IERRNO).
LSTAT returns detailed information about the file named in name.
On Linux* and macOS* systems, if the file denoted by name is a link, LSTAT provides information on the link,
while STAT provides information on the file at the destination of the link.
On Windows* systems, LSTAT returns exactly the same information as STAT (because there are no symbolic
links on these systems). STAT is the preferred function.
INQUIRE also provides information about file properties.
Example
USE IFPORT
INTEGER(4) info_array(12), istatus
character*20 file_name
print *, "Enter name of file to examime: "
read *, file_name
ISTATUS = LSTAT (file_name, info_array)
if (.NOT. ISTATUS) then
print *, info_array
else
print *, 'Error ',istatus
end if
See Also
INQUIRE
GETFILEINFOQQ
STAT
FSTAT
LTIME
Portability Subroutine: Returns the components of
the local time zone time in a nine-element array.
Module
USE IFPORT
1773
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
CALL LTIME (time,array)
Element Value
Caution
This subroutine is not year-2000 compliant, use DATE_AND_TIME instead.
On Linux* and macOS*, time can be a negative number returning the time before 00:00:00 Greenwich mean
time, January 1, 1970. On Windows*, time can not be negative, in which case all 9 elements of array are set
to -1. On all operating systems, if there is a system error in getting the local time, all 9 elements of array are
set to -1.
Example
USE IFPORT
INTEGER(4) input_time, time_array(9)
! find number of seconds since 1/1/70
input_time=TIME()
! convert number of seconds to time array
CALL LTIME (input_time, time_array)
PRINT *, time_array
See Also
DATE_AND_TIME
M to N
This section describes language features that start with M or N.
1774
Language Reference
M to N
MAKEDIRQQ
Portability Function: Creates a new directory with a
specified name.
Module
USE IFPORT
Syntax
result = MAKEDIRQQ (dirname)
Results
The result type is LOGICAL(4). The result is .TRUE. if successful; otherwise, .FALSE..
MAKEDIRQQ can create only one directory at a time. You cannot create a new directory and a subdirectory
below it in a single command. MAKEDIRQQ does not translate path delimiters. You can use either slash (/) or
backslash (\) as valid delimiters.
If an error occurs, call GETLASTERRORQQ to retrieve the error message. Possible errors include:
• ERR$ACCES - Permission denied. The file's (or directory's) permission setting does not allow the specified
access.
• ERR$EXIST - The directory already exists.
• ERR$NOENT - The file or path specified was not found.
Example
USE IFPORT
LOGICAL(4) result
result = MAKEDIRQQ('mynewdir')
IF (result) THEN
WRITE (*,*) 'New subdirectory successfully created'
ELSE
WRITE (*,*) 'Failed to create subdirectory'
END IF
END
See Also
DELDIRQQ
CHANGEDIRQQ
GETLASTERRORQQ
MALLOC
Elemental Intrinsic Function (Generic): Allocates
a block of memory. This is a generic function that has
no specific function associated with it. It must not be
passed as an actual argument.
Syntax
result = MALLOC (size)
1775
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
size (Input) Must be of type integer. This value is the size (in bytes) of
memory to be allocated.
Results
The result type is INTEGER(4) on IA-32 architecture; INTEGER(8) on Intel® 64 architecture. The result is the
starting address of the allocated memory. The memory allocated can be freed by using the FREE intrinsic
function.
Example
INTEGER(4) SIZE
REAL(4) STORAGE(*)
POINTER (ADDR, STORAGE) ! ADDR will point to STORAGE
SIZE = 1024 ! Size in bytes
ADDR = MALLOC(SIZE) ! Allocate the memory
CALL FREE(ADDR) ! Free it
MAP Clause
Clause for TARGET Directives: Maps a variable
from the data environment of the current task to the
data environment of the device associated with the
construct. This clause only applies to the TARGET
directives.
Syntax
MAP ([[map-type-modifier[,]] map-type :] list)
1776
Language Reference
On entry to an outermost target region where this clause is used, for each original list item, a new
corresponding list item is created on the device. On exit from the outermost target region, if the
corresponding list item is present on the device, it is then deleted from the device.
At least one MAP clause must appear in a directive that allows the clause.
THREADPRIVATE variables cannot appear in a MAP clause.
For the TARGET ENTER DATA directive, map-type must be either TO or ALLOC.
For the TARGET EXIT DATA directive, map-type must be FROM, RELEASE, or DELETE.
For the TARGET and TARGET DATA directives, map-type must be TO, FROM, TOFROM, or ALLOC.
For the TARGET UPDATE directive, map-type must be TO or FROM.
If original and corresponding list items share storage, data races can result when intervening synchronization
between tasks does not occur. If variables that share storage are mapped, it causes unspecified behavior.
Any variables within a TARGET MAP region that are not specified in a MAP clause are treated as shared
variables within the region.
A list item must not contain any components that have the ALLOCATABLE attribute.
If the allocation status of a list item with the ALLOCATABLE attribute is unallocated upon entry to a target
region, the list item must be unallocated upon exit from the region.
If the allocation status of a list item with the ALLOCATABLE attribute is allocated upon entry to a target
region, the allocation status of the corresponding list item must not be changed and must not be reshaped in
the region.
If an array section of an allocatable array is mapped and the size of the section is smaller than that of the
whole array, the target region must not have any reference to the whole array.
1777
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
TARGET directive clause DEFAULTMAP
Example
UNION
MAP
CHARACTER*20 string
END MAP
MAP
INTEGER*2 number(10)
END MAP
END UNION
UNION
MAP
RECORD /Cartesian/ xcoord, ycoord
END MAP
MAP
RECORD /Polar/ length, angle
END MAP
END UNION
See Also
See STRUCTURE.
MASKED
OpenMP* Fortran Compiler Directive: Specifies a
block of code to be executed by the primary thread of
the team. This feature is only available for ifx.
Syntax
!$OMP MASKED
block
!$OMP END MASKED
The binding thread set for a MASKED construct is the current team. A master region binds to the innermost
enclosing parallel region.
When the MASKED directive is specified, the other threads in the team skip the enclosed block (section) of
code and continue execution. There is no implied barrier, either on entry to or exit from the masked section.
Example
The following example forces the primary thread to execute the routines OUTPUT and INPUT:
1778
Language Reference
CALL OUTPUT(X)
CALL INPUT(Y)
!$OMP END MASKED
CALL WORK(Y)
!$OMP END PARALLEL
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
Parallel Processing Model for information about Binding Sets
MASKED TASKLOOP
OpenMP* Fortran Compiler Directive: Creates a
MASKED construct containing a TASKLOOP construct,
with no Fortran statements in the MASKED construct
that are not also in the TASKLOOP construct. This
feature is only available for ifx.
Syntax
!$OMP MASKED TASKLOOP [clause[[,] clause]... ]
loop-nest
[!$OMP END MASKED TASKLOOP]
This combined directive provides a shortcut for specifying a MASKED construct with a TASKLOOP construct
nested inside of it. The semantics are identical to a TASKLOOP construct specified immediately after a
MASKED construct.
All restrictions for MASKED and TASKLOOP constructs apply to this combined construct.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
MASKED directive
TASKLOOP directive
To learn more about canonical form loops, see the OpenMP* specification https://www.openmp.org/
specifications/
Syntax
!$OMP MASKED TASKLOOP SIMD [clause[[,] clause]... ]
loop-nest
1779
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
This combined directive provides a shortcut for specifying a MASKED construct with a TASKLOOP SIMD
construct nested inside of it. The semantics are identical to a TASKLOOP SIMD construct specified
immediately after a MASKED construct.
All restrictions for MASKED and TASKLOOP SIMD constructs apply to this combined construct.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
MASKED directive
TASKLOOP SIMD directive
To learn more about canonical form loops, see the OpenMP* specification https://www.openmp.org/
specifications/
MASKL
Elemental Intrinsic Function (Generic): Returns a
left-justified mask.
Syntax
result = MASKL (i[,kind])
Results
The result type is integer. If kind is present, the kind parameter of the result is that specified by kind;
otherwise, the kind parameter of the result is that of default integer. If the processor cannot represent the
result value in the kind of the result, the result is undefined.
The result value has its leftmost I bits set to 1 and the remaining bits set to 0.
The model for the interpretation of an integer value as a sequence of bits is in Model for Bit Data.
Example
MASKL (3) has the value SHIFTL (7, BIT_SIZE (0) - 3).
See Also
MASKR
MASKR
Elemental Intrinsic Function (Generic): Returns a
right-justified mask.
1780
Language Reference
Syntax
result = MASKR (i[,kind])
Results
The result type is integer. If kind is present, the kind parameter of the result is that specified by kind;
otherwise, the kind parameter of the result is that of default integer. If the processor cannot represent the
result value in the kind of the result, the result is undefined.
The result value has its rightmost I bits set to 1 and the remaining bits set to 0.
The model for the interpretation of an integer value as a sequence of bits is in Model for Bit Data.
Example
MASKR (3) has the value 7.
See Also
MASKL
MASTER
OpenMP* Fortran Compiler Directive:
(Deprecated; see MASKED) Specifies a block of code
to be executed by the master thread of the team.
Syntax
!$OMP MASTER
block
!$OMP END MASTER
The binding thread set for a MASTER construct is the current team. A master region binds to the innermost
enclosing parallel region.
When the MASTER directive is specified, the other threads in the team skip the enclosed block (section) of
code and continue execution. There is no implied barrier, either on entry to or exit from the master section.
The MASTER directive is deprecated; you should use the MASKED directive.
Example
The following example forces the master thread to execute the routines OUTPUT and INPUT:
1781
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
Parallel Processing Model for information about Binding Sets
MASTER TASKLOOP
OpenMP* Fortran Compiler Directive:
(Deprecated; replaced by MASKED TASKLOOP)
Creates a MASTER construct containing a TASKLOOP
construct, with no Fortran statements in the MASTER
construct that are not also in the TASKLOOP construct.
This feature is only available for ifx.
Syntax
!$OMP MASTER TASKLOOP [clause[[,] clause]... ]
loop-nest
[!$OMP END MASTER TASKLOOP]
This combined directive provides a shortcut for specifying a MASTER construct with a TASKLOOP construct
nested inside of it. The semantics are identical to a TASKLOOP construct specified immediately after a
MASTER construct.
All restrictions for MASTER and TASKLOOP constructs apply to this combined construct.
The MASTER TASKLOOP directive is deprecated; you should use the MASKED TASKLOOP directive.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
MASTER directive
TASKLOOP directive
To learn more about canonical form loops, see the OpenMP* specification https://www.openmp.org/
specifications/
Syntax
!$OMP MASTER TASKLOOP SIMD [clause[[,] clause]... ]
1782
Language Reference
loop-nest
[!$OMP END MASTER TASKLOOP SIMD]
This combined directive provides a shortcut for specifying a MASTER construct with a TASKLOOP SIMD
construct nested inside of it. The semantics are identical to a TASKLOOP SIMD construct specified
immediately after a MASTER construct; the only Fortran statements in the construct are inside the block.
All restrictions for MASTER and TASKLOOP SIMD constructs apply to this combined construct.
The MASTER TASKLOOP SIMD directive is deprecated; you should use the MASKED TASKLOOP SIMD
directive.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
MASTER directive
TASKLOOP SIMD directive
To learn more about canonical form loops, see the OpenMP* specification https://www.openmp.org/
specifications/
MATMUL
Transformational Intrinsic Function (Generic):
Performs matrix multiplication of numeric or logical
matrices.
Syntax
result = MATMUL (matrix_a,matrix_b)
Results
The result is an array whose type depends on the data type of the arguments, according to the rules
described in Data Type of Numeric Expressions. The rank and shape of the result depends on the rank and
shapes of the arguments, as follows:
• If matrix_a has shape (n, m) and matrix_b has shape (m, k), the result is a rank-two array with shape (n,
k).
• If matrix_a has shape (m) and matrix_b has shape (m, k), the result is a rank-one array with shape (k).
• If matrix_a has shape (n, m) and matrix_b has shape (m), the result is a rank-one array with shape (n).
If the arguments are of numeric type, element (i, j) of the result has the value SUM((row i of matrix_a) *
(column j of matrix_b)). If the arguments are of logical type, element (i, j) of the result has the value
ANY((row i of matrix_a) .AND. (column j of matrix_b)).
1783
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
A is matrix
[ 2 3 4 ]
[ 3 4 5 ],
B is matrix
[ 2 3 ]
[ 3 4 ]
[ 4 5 ],
X is vector (1, 2), and Y is vector (1, 2, 3).
The result of MATMUL (A, B) is the matrix-matrix product AB with the value
[ 29 38 ]
[ 38 50 ].
The result of MATMUL (X, A) is the vector-matrix product XA with the value (8, 11, 14).
The result of MATMUL (A, Y) is the matrix-vector product AY with the value (20, 26).
The following shows another example:
e = MATMUL(a, b) ! returns 22 49
! 28 64
See Also
TRANSPOSE
PRODUCT
MAX
Elemental Intrinsic Function (Generic): Returns
the maximum value of the arguments.
Syntax
result = MAX (a1,a2[,a3]...)
a1, a2, a3 (Input) All must have the same type (integer, real, or character) and
kind parameters.
1784
Language Reference
Results
For arguments of character type, the result type is character, and the length of the result is the length of the
longest argument. For MAX0, AMAX1, DMAX1, QMAX1, IMAX0, JMAX0, and KMAX0, the result type is the
same as the arguments. For MAX1, IMAX1, JMAX1, and KMAX1, the result type is integer. For AMAX0,
AIMAX0, AJMAX0, and AKMAX0, the result type is real. The value of the result is that of the largest
argument. For character arguments, the comparison is done using the ASCII collating sequence. If the
selected argument is shorter than the longest argument, the result is extended to the length of the longest
argument by inserting blank characters on the right.
INTEGER(1) INTEGER(1)
older versions of Fortran, these functions can also be specified as generic functions.
5Or JMAX1. MAX1 is the same as INT(MAX).
6The setting of compiler options specifying integer size can affect MAX1.
7The setting of compiler options specifying real size can affect AMAX1.
Example
MAX (2.0, -8.0, 6.0) has the value 6.0.
MAX (14, 32, -50) has the value 32.
The following shows another example:
INTEGER m1, m2
REAL r1, r2
m1 = MAX(5, 6, 7) ! returns 7
1785
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
MAXLOC
MAXVAL
MIN
MAXEXPONENT
Inquiry Intrinsic Function (Generic): Returns the
maximum exponent in the model representing the
same type and kind parameters as the argument.
Syntax
result = MAXEXPONENT (x)
Results
The result is a scalar of type default integer. The result has the value emax, as defined in Model for Real Data.
Example
REAL(4) x
INTEGER i
i = MAXEXPONENT(x) ! returns 128.
See Also
MINEXPONENT
MAXLOC
Transformational Intrinsic Function (Generic):
Returns the location of the maximum value of all
elements in an array, a set of elements in an array, or
elements in a specified dimension of an array.
Syntax
result = MAXLOC (array, dim [, mask, kind, back])
result = MAXLOC (array [, mask, kind, back])
1786
Language Reference
Results
The result is an array of type integer. If kind is present, the kind parameter of the result is that specified by
kind; otherwise, the kind parameter of the result is that of default integer. If the processor cannot represent
the result value in the kind of the result, the result is undefined.
The following rules apply if dim is not specified:
• The array result has rank one and a size equal to the rank of array.
• If MAXLOC(array) is specified, the elements in the array result form the subscript of the location of the
element with the maximum value in array.
The ith subscript returned lies in the range 1 to ei, where ei is the extent of the ith dimension of array.
• If MAXLOC( array, MASK= mask) is specified, the elements in the array result form the subscript of the
location of the element with the maximum value corresponding to the condition specified by mask.
The following rules apply if dim is specified:
• The array result has a rank that is one less than array, and shape (d1, d2,...ddim-1, ddim+1,...dn), where
(d1, d2,...dn) is the shape of array.
• If array has rank one, MAXLOC( array, dim [, mask]) is a scalar and has a value equal to the first element
of MAXLOC( array [, MASK = mask]). Otherwise, the value of element (s1, s2,...sdim-1, sdim+1,...sn) of
MAXLOC( array, dim [, mask]) is equal to MAXLOC( array(s1, s2,...sdim-1, :, sdim+1,...sn) [, MASK =
mask(s1, s2,...sdim-1, :, sdim+1,...sn)]).
If only one element has the maximum value, that element’s subscripts are returned. Otherwise, if more than
one element has the maximum value and back is absent or present with the value .FALSE., the element
whose subscripts are returned is the first such element, taken in array element order. If back is present with
the value .TRUE., the element whose subscripts are returned is the last such element, taken in array element
order.
If array has size zero, or every element of mask has the value .FALSE., the value of the result is controlled by
compiler option assume [no]old_maxminloc, which can set the value of the result to either 1 or 0.
If array is of type character, the comparison is done using the ASCII collating sequence.
The setting of compiler options specifying integer size can affect this function.
Example
The value of MAXLOC((/3, 7, 4, 7/)) is (2), which is the subscript of the location of the first occurrence of the
maximum value in the rank-one array.
A is the array
[ 4 0 4 2 ]
[ 3 1 -2 6 ]
[ -1 -4 5 5 ].
MAXLOC (A, MASK=A .LT. 5) has the value (1, 1) because these are the subscripts of the location of the first
maximum value (4) that is less than 5.
MAXLOC (A, DIM=1) has the value (1, 2, 3, 2). 1 is the subscript of the location of the first maximum value
(4) in column 1; 2 is the subscript of the location of the first maximum value (1) in column 2; and so forth.
MAXLOC (A, DIM=2) has the value (1, 4, 3). 1 is the subscript of the location of the first maximum value in
row 1; 4 is the subscript of the location of the first maximum value in row 2; and so forth.
MAXLOC (A, DIM=2, BACK=.TRUE.) has the value (3, 4, 4). 3 is the subscript of the location of the last
maximum value in row 1; 4 is the subscript of the location of the last maximum value in row 2; and so forth.
1787
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
MAXVAL
MINLOC
MINVAL
FINDLOC
MAXVAL
Transformational Intrinsic Function (Generic):
Returns the maximum value of all elements in an
array, a set of elements in an array, or elements in a
specified dimension of an array.
Syntax
result = MAXVAL (array [, mask])
result = MAXVAL (array, dim [, mask])
1788
Language Reference
dim (Input) Must be a scalar integer expression with a value in the range 1
to n, where n is the rank of array.
Results
The result is an array or a scalar of the same data type as array.
The result is a scalar if dim is not specified or array has rank one.
The following rules apply if dim is not specified:
• If MAXVAL( array) is specified, the result has a value equal to the maximum value of all the elements in
array.
• If MAXVAL( array, MASK= mask) is specified, the result has a value equal to the maximum value of the
elements in array corresponding to the condition specified by mask.
The following rules apply if dim is specified:
• An array result has a rank that is one less than array, and shape (d1, d2,...,ddim-1, ddim+1, ..., dn), where
(d1, d2, ..., dn) is the shape of array.
• If array has rank one, MAXVAL( array, dim[, mask]) has a value equal to that of MAXVAL( array[,MASK =
mask]). Otherwise, the value of element (s1, s2, ..., sdim-1, sdim+1, ..., sn) of MAXVAL( array, dim, [,
mask]) is equal to MAXVAL( array(s1, s2, ..., sdim-1, :, sdim+1, ..., sn) [,MASK = mask(s1, s2, ..., sdim-1, :,
sdim+1, ..., sn)]).
If array has size zero or if there are no true elements in mask, the result (if dim is omitted), or each element
in the result array (if dim is specified), has the value of the negative number of the largest magnitude
supported by the processor for numbers of the type and kind parameters of array.
If array is of type character, the comparison is done using the ASCII collating sequence.
Example
The value of MAXVAL ((/2, 3, 4/)) is 4 because that is the maximum value in the rank-one array.
MAXVAL (B, MASK=B .LT. 0.0) finds the maximum value of the negative elements of B.
C is the array
[ 2 3 4 ]
[ 5 6 7 ].
MAXVAL (C, DIM=1) has the value (5, 6, 7). 5 is the maximum value in column 1; 6 is the maximum value in
column 2; and so forth.
MAXVAL (C, DIM=2) has the value (4, 7). 4 is the maximum value in row 1 and 7 is the maximum value in
row 2.
The following shows another example:
1789
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
! (a row) of array
max = MAXVAL(array, MASK = array .LT. 4) ! returns 3
AR1 = MAXVAL(array, DIM = 1) ! returns [ 4 5 6 ]
AR2 = MAXVAL(array, DIM = 2) ! returns [ 5 6 ]
END
See Also
MAXLOC
MINVAL
MINLOC
MBCharLen (W*S)
NLS Function: Returns the length, in bytes, of the
first character in a multibyte-character string.
Module
USE IFNLS
Syntax
result = MBCharLen (string)
Results
The result type is INTEGER(4). The result is the number of bytes in the first character contained in string.
The function returns 0 if string has no characters (is length 0).
MBCharLen does not test for multibyte character validity.
See Also
MBCurMax
MBLead
MBLen
MBLen_Trim
MBConvertMBToUnicode (W*S)
NLS Function: Converts a multibyte-character string
from the current codepage to a Unicode string.
Module
USE IFNLS
Syntax
result = MBConvertMBToUnicode (mbstr,unicodestr[,flags])
1790
Language Reference
Results
The result type is INTEGER(4). If no error occurs, the result is the number of bytes written to
unicodestr(bytes are counted, not characters), or the number of bytes required to hold the output string if
unicodestr has zero size. If the unicodestr array is bigger than needed to hold the translation, the extra
elements are set to space characters. If unicodestr has zero size, the function returns the number of bytes
required to hold the translation and nothing is written to unicodestr.
If an error occurs, one of the following negative values is returned:
• NLS$ErrorInsufficentBuffer - The unicodestr argument is too small, but not zero size so that the needed
number of bytes would be returned.
• NLS$ErrorInvalidFlags - The flags argument has an illegal value.
• NLS$ErrorInvalidCharacter - A character with no Unicode translation was encountered in mbstr. This error
can occur only if the NLS$InvalidCharsError flag was used in flags.
NOTE
By default, or if flags is set to NLS$Precomposed, the function MBConvertMBToUnicode
attempts to translate the multibyte codepage string to a precomposed Unicode string. If a
precomposed form does not exist, the function attempts to translate the codepage string to
a composite form.
See Also
MBConvertUnicodeToMB
MBConvertUnicodeToMB (W*S)
NLS Function: Converts a Unicode string to a
multibyte-character string from the current codepage.
Module
USE IFNLS
Syntax
result = MBConvertUnicodeToMB (unicodestr,mbstr[,flags])
1791
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type is INTEGER(4). If no error occurs, returns the number of bytes written to mbstr (bytes are
counted, not characters), or the number of bytes required to hold the output string if mbstr has zero length.
If mbstr is longer than the translation, it is blank-padded. If mbstr is zero length, the function returns the
number of bytes required to hold the translation and nothing is written to mbstr.
If an error occurs, one of the following negative values is returned:
• NLS$ErrorInsufficientBuffer - The mbstr argument is too small, but not zero length so that the needed
number of bytes is returned.
• NLS$ErrorInvalidFlags - The flags argument has an illegal value.
See Also
MBConvertMBToUnicode
MBCurMax (W*S)
NLS Function: Returns the longest possible multibyte
character length, in bytes, for the current codepage.
Module
USE IFNLS
Syntax
result = MBCurMax( )
Results
The result type is INTEGER(4). The result is the longest possible multibyte character, in bytes, for the current
codepage.
The MBLenMax parameter, defined in the module IFNLS.F90, is the longest length, in bytes, of any character
in any codepage installed on the system.
1792
Language Reference
See Also
MBCharLen
MBINCHARQQ (W*S)
NLS Function: Performs the same function as
INCHARQQ except that it can read a single multibyte
character at once, and it returns the number of bytes
read as well as the character.
Module
USE IFNLS
Syntax
result = MBINCHARQQ (string)
Results
The result type is INTEGER(4). The result is the number of characters read.
See Also
INCHARQQ
MBCurMax
MBCharLen
MBLead
MBINDEX (W*S)
NLS Function: Performs the same function as INDEX
except that the strings manipulated can contain
multibyte characters.
Module
USE IFNLS
Syntax
result = MBINDEX (string,substring[,back])
1793
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type is INTEGER(4). If back is omitted or is .FALSE., it returns the leftmost position in string that
contains the start of substring. If back is .TRUE., it returns the rightmost position in string that contains the
start of substring. If string does not contain substring, it returns 0. If substring occurs more than once, it
returns the starting position of the first occurrence ("first" is determined by the presence and value of back).
The position returned is a byte index, not a character index because of the confounding case of multibyte
characters. As an example, if a substring which is a single multi-byte character matches the second multibyte
character in a string consisting of two two-byte multi-byte characters the position is 3, not 2.
See Also
INDEX
MBSCAN
MBVERIFY
Module
USE IFNLS
Syntax
result = MBJISToJMS (char)
result = MBJMSToJIS (char)
Results
The result type is character with length 2. MBJISToJMS returns a Microsoft Kanji (Shift JIS or JMS) character.
MBJMSToJIS returns a Japan Industry Standard (JIS) character.
Only computers with Japanese installed as one of the available languages can use the MBJISToJMS and
MBJMSToJIS conversion functions.
See Also
NLSEnumLocales
NLSEnumCodepages
NLSGetLocale
NLSSetLocale
1794
Language Reference
MBLead (W*S)
NLS Function: Determines whether a given character
is the lead (first) byte of a multibyte character
sequence.
Module
USE IFNLS
Syntax
result = MBLead (char)
Results
The result type is LOGICAL(4). The result is .TRUE. if char is the first character of a multibyte character
sequence; otherwise, .FALSE..
MBLead only works stepping forward through a whole multibyte character string. For example:
See Also
MBStrLead
MBCharLen
MBLen (W*S)
NLS Function: Returns the number of characters in a
multibyte-character string, including trailing blanks.
Module
USE IFNLS
Syntax
result = MBLen (string)
Results
The result type is INTEGER(4). The result is the number of characters in string.
1795
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
MBLen recognizes multibyte-character sequences according to the multibyte codepage currently in use. It
does not test for multibyte-character validity.
See Also
MBLen_Trim
MBStrLead
MBLen_Trim (W*S)
NLS Function: Returns the number of characters in a
multibyte-character string, not including trailing
blanks.
Module
USE IFNLS
Syntax
result = MBLen_Trim (string)
Results
The result type is INTEGER(4). The result is the number of characters in string minus any trailing blanks
(blanks are bytes containing character 32 (hex 20) in the ASCII collating sequence).
MBLen_Trim recognizes multibyte-character sequences according to the multibyte codepage currently in use.
It does not test for multibyte-character validity.
See Also
MBLen
MBStrLead
Module
USE IFNLS
Syntax
result = MBLGE (string_a,string_b, [ flags])
result = MBLGT (string_a,string_b, [ flags])
result = MBLLE (string_a,string_b, [ flags])
result = MBLLT (string_a,string_b, [ flags])
result = MBLEQ (string_a,string_b, [ flags])
result = MBLNE (string_a,string_b, [ flags])
1796
Language Reference
Results
The result type is LOGICAL(4). Comparisons are made using the current locale, not the current codepage.
The codepage used is the default for the language/country combination of the current locale.
The results of these functions are as follows:
• MBLGE returns .TRUE. if the strings are equal or string_a comes last in the collating sequence;
otherwise, .FALSE..
• MBLGT returns .TRUE. if string_a comes last in the collating sequence; otherwise, .FALSE..
• MBLLE returns .TRUE. if the strings are equal or string_a comes first in the collating sequence;
otherwise, .FALSE..
• MBLLT returns .TRUE. if string_a comes first in the collating sequence; otherwise, .FALSE..
• MBLEQ returns .TRUE. if the strings are equal in the collating sequence; otherwise, .FALSE..
• MBLNE returns .TRUE. if the strings are not equal in the collating sequence; otherwise, .FALSE..
If the two strings are of different lengths, they are compared up to the length of the shortest one. If they are
equal to that point, then the return value indicates that the longer string is greater.
If flags is invalid, the functions return .FALSE..
If the strings supplied contain Arabic Kashidas, the Kashidas are ignored during the comparison. Therefore, if
the two strings are identical except for Kashidas within the strings, the functions return a value indicating
they are "equal" in the collation sense, though not necessarily identical.
NOTE
When not using the NLS$MB_StringSort flag, the hyphen and apostrophe are special
symbols and are treated differently than others. This is to ensure that words like coop and
co-op stay together within a list. All symbols, except the hyphen and apostrophe, sort
before any other alphanumeric character. If you specify the NLS$MB_StringSort flag, hyphen
and apostrophe sort at the beginning also.
See Also
LGE
LGT
1797
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
LLE
LLT
MBNext (W*S)
NLS Function: Returns the position of the first lead
byte or single-byte character immediately following
the given position in a multibyte-character string.
Module
USE IFNLS
Syntax
result = MBNext (string,position)
string (Input) Character*(*). String to be searched for the first lead byte or
single-byte character after the current position. Can contain multibyte
characters.
Results
The result type is INTEGER(4). The result is the position of the first lead byte or single-byte character in
string immediately following the position given in position, or 0 if no following first byte is found in string.
See Also
MBPrev
MBPrev (W*S)
NLS Function: Returns the position of the first lead
byte or single-byte character immediately preceding
the given string position in a multibyte-character
string.
Module
USE IFNLS
Syntax
result = MBPrev (string,position)
string (Input) Character*(*). String to be searched for the first lead byte or
single-byte character before the current position. Can contain
multibyte characters.
Results
The result type is INTEGER(4). The result is the position of the first lead byte or single-byte character in
string immediately preceding the position given in position, or 0 if no preceding first byte is found in string.
1798
Language Reference
See Also
MBNext
MBSCAN (W*S)
NLS Function: Performs the same function as SCAN
except that the strings manipulated can contain
multibyte characters.
Module
USE IFNLS
Syntax
result = MBSCAN (string,set[,back])
Results
The result type is INTEGER(4). If back is .FALSE. or is omitted, it returns the position of the leftmost
character in string that is in set. If back is .TRUE., it returns the rightmost character in string that is in set. If
no characters in string are in set, it returns 0.
See Also
SCAN
MBINDEX
MBVERIFY
MBStrLead (W*S)
NLS Function: Performs a context-sensitive test to
determine whether a given character byte in a string
is a multibyte-character lead byte.
Module
USE IFNLS
Syntax
result = MBStrLead (string,position)
1799
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type is LOGICAL(4). The result is .TRUE. if the character byte in position of string is a lead byte;
otherwise, .FALSE..
MBStrLead is passed a whole string and can identify any byte within the string as a lead or trail byte because
it performs a context-sensitive test, scanning all the way back to the beginning of a string if necessary to
establish context.
MBLead is passed only one character at a time and must start on a lead byte and step through a string one
character at a time to establish context for the character. So, MBStrLead can be much slower than MBLead
(up to n times slower, where n is the length of the string).
See Also
MBLead
MBVERIFY (W*S)
NLS Function: Performs the same function as VERIFY
except that the strings manipulated can contain
multibyte characters.
Module
USE IFNLS
Syntax
result = MBVERIFY (string,set[,back])
Results
The result type is INTEGER(4). If back is .FALSE. or is omitted, it returns the position of the leftmost
character in string that is not in set. If back is .TRUE., it returns the rightmost character in string that is not
in set. If all the characters in string are in set, it returns 0.
See Also
VERIFY
MBINDEX
MBSCAN
MCLOCK
Inquiry Intrinsic Function (Specific): Returns time
accounting for a program.
Syntax
result = MCLOCK( )
1800
Language Reference
Results
The result type is INTEGER(4). The result is the sum (in units of milliseconds) of the current process's user
time and the user and system time of all its child processes.
MERGE
Elemental Intrinsic Function (Generic): Selects
between two values or between corresponding
elements in two arrays, according to the condition
specified by a logical mask.
Syntax
result = MERGE (tsource,fsource,mask)
fsource (Input) Must be of the same type and type parameters as tsource.
Results
The result type and kind are the same as tsource. The value of mask determines whether the result value is
taken from tsource (if mask is true) or fsource (if mask is false).
Example
For MERGE (1.0, 0.0, R < 0), R = -3 has the value 1.0, and R = 7 has the value 0.0.
TSOURCE is the array
[ 1 3 5 ]
[ 2 4 6 ],
FSOURCE is the array
[ 8 9 0 ]
[ 1 2 3 ],
and MASK is the array
[ F T T]
[ T T F].
MERGE (TSOURCE, FSOURCE, MASK) produces the result:
[ 8 3 5 ]
[ 2 4 3 ].
The following shows another example:
1801
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
MERGE_BITS
Elemental Intrinsic Function (Generic): Merges
bits by using a mask.
Syntax
result = MERGE_BITS (i,j,mask)
If both i and j are of type integer they must have the same kind type parameter. They cannot both be binary,
octal, or hexadecimal literal constants.
If mask is of type integer, it must have the same kind type parameter as each other argument of type
integer.
Results
The result type and kind are the same as i if i is of type integer; otherwise, the result type and kind are the
same as j.
If any argument is a binary, octal, or hexadecimal literal constant, it is first converted as if by the intrinsic
function INT to the type and kind parameter of the result. The result has the value of IOR (IAND (i, mask),
IAND (j, NOT (mask))).
Example
MERGE_BITS (13, 18, 22) has the value 4.
MERGEABLE Clause
Parallel Directive Clause: Specifies that the
implementation may generate a merged task.
Syntax
MERGEABLE
When the generated task is an undeferred task or an included task, it specifies that the implementation may
instead generate a merged task.
When the MERGEABLE clause is present on a TASKLOOP construct, each generated task is a mergeable task.
MESSAGE
General Compiler Directive: Specifies a character
string to be sent to the standard output device during
the first compiler pass; this aids debugging.
1802
Language Reference
Syntax
!DIR$ MESSAGE:string
Example
!DIR$ MESSAGE:'Compiling Sound Speed Equations'
See Also
General Compiler Directives
Syntax Rules for Compiler Directives
MESSAGEBOXQQ (W*S)
QuickWin Function: Displays a message box in a
QuickWin window.
Module
USE IFQWIN
Syntax
result = MESSAGEBOXQQ (msg,caption,mtype)
1803
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type is INTEGER(4). The result is zero if memory is not sufficient for displaying the message box.
Otherwise, the result is one of the following values, indicating the user's response to the message box:
• MB$IDABORT - The Abort button was pressed.
• MB$IDCANCEL - The Cancel button was pressed.
• MB$IDIGNORE - The Ignore button was pressed.
• MB$IDNO - The No button was pressed.
• MB$IDOK - The OK button was pressed.
• MB$IDRETRY - The Retry button was pressed.
• MB$IDYES - The Yes button was pressed.
Example
! Build as QuickWin app
USE IFQWIN
message = MESSAGEBOXQQ('Do you want to continue?'C, &
'Matrix'C, &
MB$ICONQUESTION.OR.MB$YESNO.OR.MB$DEFBUTTON1)
END
See Also
ABOUTBOXQQ
SETMESSAGEQQ
MIN
Elemental Intrinsic Function (Generic): Returns
the minimum value of the arguments.
Syntax
result = MIN (a1,a2[,a3...])
a1, a2, a3 (Input) All must have the same type (integer, real, or character) and
kind parameters.
Results
For arguments of character type, the result type is character, and the length of the result is the length of the
longest argument. For MIN0, AMIN1, DMIN1, QMIN1, IMIN0, JMIN0, and KMIN0, the result type is the same
as the arguments. For MIN1, IMIN1, JMIN1, and KMIN1, the result type is integer. For AMIN0, AIMIN0,
AJMIN0, and AKMIN0, the result type is real. The value of the result is that of the smallest argument. For
character arguments, the comparison is done using the ASCII collating sequence. If the selected argument is
shorter than the longest argument, the result is extended to the length of the longest argument by inserting
blank characters on the right.
INTEGER(1) INTEGER(1)
1804
Language Reference
Example
MIN (2.0, -8.0, 6.0) has the value -8.0.
MIN (14, 32, -50) has the value -50.
The following shows another example:
INTEGER m1, m2
REAL r1, r2
m1 = MIN (5, 6, 7) ! returns 5
m2 = MIN1 (-5.7, 1.23, -3.8) ! returns -5
r1 = AMIN0 (-5, -6, -7) ! returns -7.0
r2 = AMIN1(-5.7, 1.23, -3.8) ! returns -5.7
See Also
MINLOC
MINVAL
MAX
MINEXPONENT
Inquiry Intrinsic Function (Generic): Returns the
minimum exponent in the model representing the
same type and kind parameters as the argument.
Syntax
result = MINEXPONENT (x)
1805
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result is a scalar of type default integer. The result has the value emin, as defined in Model for Real Data.
Example
If X is of type REAL(4), MINEXPONENT (X) has the value -125.
The following shows another example:
See Also
MAXEXPONENT
MINLOC
Transformational Intrinsic Function (Generic):
Returns the location of the minimum value of all
elements in an array, a set of elements in an array, or
elements in a specified dimension of an array.
Syntax
result = MINLOC (array, dim [, mask, kind, back])
result = MINLOC (array [, mask, kind, back])
Results
The result is an array of type integer. If kind is present, the kind parameter of the result is that specified by
kind; otherwise, the kind parameter of the result is that of default integer. If the processor cannot represent
the result value in the kind of the result, the result is undefined.
The following rules apply if dim is not specified:
• The array result has rank one and a size equal to the rank of array.
• If MINLOC(array) is specified, the elements in the array result form the subscript of the location of the
element with the minimum value in array.
The ith subscript returned lies in the range 1 to ei, where ei is the extent of the ith dimension of array.
• If MINLOC(array, MASK= mask) is specified, the elements in the array result form the subscript of the
location of the element with the minimum value corresponding to the condition specified by mask.
The following rules apply if dim is specified:
1806
Language Reference
• The array result has a rank that is one less than array, and shape (d1, d2,...ddim-1, ddim+1,...dn), where
(d1, d2,...dn) is the shape of array.
• If array has rank one, MINLOC( array, dim [, mask]) is a scalar and has a value equal to the first element
of MINLOC( array [,MASK = mask]). Otherwise, the value of element (s1, s2,...sdim-1, sdim+1,...sn) of
MINLOC( array, dim [, mask]) is equal to MINLOC( array(s1, s2,...sdim-1, :, sdim+1,...sn) [, MASK =
mask(s1, s2,...sdim-1, :, sdim+1,...sn)]).
If only one element has the minimum value, that element’s subscripts are returned. Otherwise, if more than
one element has the minimum value and back is absent or present with the value .FALSE., the element
whose subscripts are returned is the first such element, taken in array element order. If back is present with
the value .TRUE., the element whose subscripts are returned is the last such element, taken in array element
order.
If array has size zero, or every element of mask has the value .FALSE., the value of the result is controlled by
compiler option assume [no]old_maxminloc, which can set the value of the result to either 1 or 0.
If array is of type character, the comparison is done using the ASCII collating sequence.
The setting of compiler options specifying integer size can affect this function.
Example
The value of MINLOC ((/3, 1, 4, 1/)) is (2), which is the subscript of the location of the first occurrence of the
minimum value in the rank-one array.
A is the array
[ 4 0 0 2 ]
[ 3 -6 -2 6 ]
[ -1 -4 5 -4 ].
MINLOC (A, MASK=A .GT. -5) has the value (3, 2) because these are the subscripts of the location of the first
minimum value (-4) that is greater than -5.
MINLOC (A, DIM=1) has the value (3, 2, 2, 3). 3 is the subscript of the location of the first minimum value
(-1) in column 1; 3 is the subscript of the location of the first minimum value (-6) in column 2; and so forth.
MINLOC (A, DIM=2) has the value (2, 2, 2). 2 is the subscript of the location of the first minimum value (0)
in row 1; 2 is the subscript of the location of the first minimum value (-6) in row 2; and so forth.
MINLOC (A, DIM=2, BACK=.TRUE.) has the value (3, 2, 4). 3 is the subscript of the location of the last
minimum value (0) in row 1; 2 is the subscript of the location of the last minimum value (-6) in row 2; and
so forth.
The following shows another example:
INTEGER i, minl(1)
INTEGER array(2, 3)
INTEGER, ALLOCATABLE :: AR1(:)
! put values in array
array = RESHAPE((/-7, 1, -2, -9, 5, 0/),(/2, 3/))
! array is -7 -2 5
! 1 -9 0
i = SIZE(SHAPE(array)) ! Get the number of dimensions
! in array
ALLOCATE (AR1 (i)) ! Allocate AR1 to number
! of dimensions in array
AR1 = MINLOC (array, MASK = array .GT. -5) ! Get the
! location (subscripts) of
! smallest element greater
! than -5 in array
1807
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
!
! MASK = array .GT. -5 creates a mask array the same
! size and shape as array whose elements are .TRUE. if
! the corresponding element in array is greater than
! -5, and .FALSE. if it is not. This mask causes MINLOC
! to return the index of the element in array with the
! smallest value greater than -5.
!
!array is -7 -2 5 and MASK= array .GT. -5 is F T T
! 1 -9 0 T F T
! and AR1 = MINLOC(array, MASK = array .GT. -5) returns
! (1, 2), the location of the element with value -2
See Also
MAXLOC
MINVAL
MAXVAL
FINDLOC
MINVAL
Transformational Intrinsic Function (Generic):
Returns the minimum value of all elements in an
array, a set of elements in an array, or elements in a
specified dimension of an array.
Syntax
result = MINVAL (array [, mask])
result = MINVAL (array, dim [, mask])
Results
The result is an array or a scalar of the same data type as array.
The result is a scalar if dim is omitted or array has rank one.
The following rules apply if dim is not specified:
• If MINVAL( array) is specified, the result has a value equal to the minimum value of all the elements in
array.
• If MINVAL( array, MASK= mask) is specified, the result has a value equal to the minimum value of the
elements in array corresponding to the condition specified by mask.
The following rules apply if dim is specified:
• An array result has a rank that is one less than array, and shape (d1, d2, ..., ddim-1, ddim+1, ..., dn), where
(d1, d2, ..., dn) is the shape of array.
1808
Language Reference
• If array has rank one, MINVAL( array, dim[, mask]) has a value equal to that of MINVAL( array[,MASK =
mask]). Otherwise, the value of element (s1, s2, ..., sdim-1, sdim+1, ..., sn) of MINVAL( array, dim, [,
mask]) is equal to MINVAL( array(s1, s2, ..., sdim-1, :, sdim+1, ..., sn) [,MASK = mask(s1, s2, ..., sdim-1, :,
sdim+1, ..., sn)]).
If array has size zero or if there are no true elements in mask, the result (if dim is omitted), or each element
in the result array (if dim is specified), has the value of the positive number of the largest magnitude
supported by the processor for numbers of the type and kind parameters of array.
If array is of type character, the comparison is done using the ASCII collating sequence.
Example
The value of MINVAL ((/2, 3, 4/)) is 2 because that is the minimum value in the rank-one array.
The value of MINVAL (B, MASK=B .GT. 0.0) finds the minimum value of the positive elements of B.
C is the array
[ 2 3 4 ]
[ 5 6 7 ].
MINVAL (C, DIM=1) has the value (2, 3, 4). 2 is the minimum value in column 1; 3 is the minimum value in
column 2; and so forth.
MINVAL (C, DIM=2) has the value (2, 5). 2 is the minimum value in row 1 and 5 is the minimum value in row
2.
The following shows another example:
See Also
MAXVAL
MINLOC
MAXLOC
MM_PREFETCH
Intrinsic Subroutine (Generic): Prefetches data
from the specified address on one memory cache line.
Intrinsic subroutines cannot be passed as actual
arguments.
Syntax
CALL MM_PREFETCH (address[,hint] [,fault] [,exclusive])
1809
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
address (Input) Is the name of a scalar or array; it can be of any type or rank.
It specifies the address of the data on the cache line to prefetch.
1810
Language Reference
Example
subroutine spread_lf (a, b)
PARAMETER (n = 1025)
stop
end
MOD
Elemental Intrinsic Function (Generic): Returns
the remainder when the first argument is divided by
the second argument.
Syntax
result = MOD (a, p)
Results
The result type and kind are the same as a. If p is not equal to zero, the value of the result is a - INT( a/ p) *
p. If p is equal to zero, the result is undefined.
1811
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1 Or HMOD.
2 Or JMOD.
3 The setting of compiler options specifying real size can affect AMOD and DMOD.
4 The setting of compiler options specifying double size can affect DMOD.
Example
MOD (7, 3) has the value 1.
MOD (9, -6) has the value 3.
MOD (-9, 6) has the value -3.
The following shows more examples:
INTEGER I
REAL R
R = MOD(9.0, 2.0) ! returns 1.0
I = MOD(18, 5) ! returns 3
I = MOD(-18, 5) ! returns -3
I = MOD( 8, 5) ! returns 3
I = MOD(-8, 5) ! returns -3
I = MOD( 8,-5) ! returns 3
I = MOD(-8,-5) ! returns -3
See Also
MODULO
MODIFYMENUFLAGSQQ (W*S)
QuickWin Function: Modifies a menu item's state.
Module
USE IFQWIN
Syntax
result = MODIFYMENUFLAGSQQ (menuID,itemID,flag)
menuID (Input) INTEGER(4). Identifies the menu containing the item whose
state is to be modified, starting with 1 as the leftmost menu.
flags (Input) INTEGER(4). Constant indicating the menu state. Flags can be
combined with an inclusive OR (see the Results section below). The
following constants are available:
• $MENUGRAYED - Disables and grays out the menu item.
• $MENUDISABLED - Disables but does not gray out the menu item.
• $MENUENABLED - Enables the menu item.
• $MENUSEPARATOR - Draws a separator bar.
• $MENUCHECKED - Puts a check by the menu item.
• $MENUUNCHECKED - Removes the check by the menu item.
1812
Language Reference
Results
The result type is LOGICAL(4). The result is .TRUE. if successful; otherwise, .FALSE..
The constants available for flags can be combined with an inclusive OR where reasonable, for example
$MENUCHECKED .OR. $MENUENABLED. Some combinations do not make sense, such as $MENUENABLED
and $MENUDISABLED, and lead to undefined behavior.
Example
USE IFQWIN
LOGICAL(4) result
CHARACTER(20) str
! Append item to the bottom of the first (FILE) menu
str = '&Add to File Menu'C
result = APPENDMENUQQ(1, $MENUENABLED, str, WINSTATUS)
! Gray out and disable the first two menu items in the
! first (FILE) menu
result = MODIFYMENUFLAGSQQ (1, 1, $MENUGRAYED)
result = MODIFYMENUFLAGSQQ (1, 2, $MENUGRAYED)
END
See Also
APPENDMENUQQ
DELETEMENUQQ
INSERTMENUQQ
MODIFYMENUROUTINEQQ
MODIFYMENUSTRINGQQ
MODIFYMENUROUTINEQQ (W*S)
QuickWin Function: Changes a menu item's callback
routine.
Module
USE IFQWIN
Syntax
result = MODIFYMENUROUTINEQQ (menuIdD,itemID,routine)
menuID (Input) INTEGER(4). Identifies the menu that contains the item whose
callback routine is be changed, starting with 1 as the leftmost menu.
itemID (Input) INTEGER(4). Identifies the menu item whose callback routine
is to be changed, starting with 0 as the top item.
1813
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type is LOGICAL(4). The result is .TRUE. if successful; otherwise, .FALSE..
See Also
APPENDMENUQQ
DELETEMENUQQ
INSERTMENUQQ
MODIFYMENUFLAGSQQ
MODIFYMENUSTRINGQQ
MODIFYMENUSTRINGQQ (W*S)
QuickWin Function: Changes a menu item's text
string.
Module
USE IFQWIN
Syntax
result = MODIFYMENUSTRINGQQ (menuID,itemID,text)
menuID (Input) INTEGER(4). Identifies the menu containing the item whose
text string is to be changed, starting with 1 as the leftmost item.
itemID (Input) INTEGER(4). Identifies the menu item whose text string is to
be changed, starting with 0 as the top menu item.
1814
Language Reference
Results
The result type is LOGICAL(4). The result is .TRUE. if successful; otherwise, .FALSE..
You can add access keys in your text strings by placing an ampersand (&) before the letter you want
underlined. For example, to add a Print menu item with the r underlined, use "P&rint"C as text.
Example
USE IFQWIN
LOGICAL(4) result
CHARACTER(25) str
! Append item to the bottom of the first (FILE) menu
str = '&Add to File Menu'C
result = APPENDMENUQQ(1, $MENUENABLED, str, WINSTATUS)
! Change the name of the first item in the first menu
str ='&Browse'C
result = MODIFYMENUSTRINGQQ (1, 1, str)
END
See Also
APPENDMENUQQ
DELETEMENUQQ
INSERTMENUQQ
SETMESSAGEQQ
MODIFYMENUFLAGSQQ
MODIFYMENUROUTINEQQ
MODULE
Statement: Marks the beginning of a module
program unit, which contains specifications and
definitions that can be used by one or more program
units.
Syntax
MODULE name
[specification-part]
[CONTAINS
[module-subprogram
[module-subprogram]...] ]
END[ MODULE [name]]
1815
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
If a name follows the END statement, it must be the same as the name specified in the MODULE statement.
The module name is considered global and must be unique. It cannot be the same as any local name in the
main program or the name of any other program unit, external procedure, or common block in the
executable program.
A module is host to any module procedures it contains, and entities in the module are accessible to the
module procedures through host association.
A module must not reference itself (either directly or indirectly).
You can use the PRIVATE attribute to restrict access to procedures or variables within a module.
Although ENTRY statements, FORMAT statements, and statement functions are not allowed in the
specification part of a module, they are allowed in the specification part of a module subprogram.
The following rules also apply to modules:
• The specification part of a module must not contain IMPORT, ENTRY, FORMAT, executable, or statement
function statements.
• A variable, common block, or procedure pointer declared in a submodule implicitly has the SAVE attribute,
which may be confirmed by explicit specification.
• If a specification or constant expression in the specification-part of a module includes a reference to a
generic entity, there must be no specific procedures of the generic entity defined in the submodule
subsequent to the specification or constant expression.
Example
The following example shows a simple module that can be used to provide global data:
MODULE MOD_A
INTEGER :: B, C
REAL E(25,5)
END MODULE MOD_A
...
SUBROUTINE SUB_Z
USE MOD_A ! Makes scalar variables B and C, and array
... ! E available to this subroutine
END SUBROUTINE SUB_Z
The following example shows a module procedure:
MODULE RESULTS
...
CONTAINS
FUNCTION MOD_RESULTS(X,Y) ! A module procedure
1816
Language Reference
...
END FUNCTION MOD_RESULTS
END MODULE RESULTS
The following example shows a module containing a derived type:
MODULE EMPLOYEE_DATA
TYPE EMPLOYEE
INTEGER ID
CHARACTER(LEN=40) NAME
END TYPE EMPLOYEE
END MODULE
The following example shows a module containing an interface block:
MODULE ARRAY_CALCULATOR
INTERFACE
FUNCTION CALC_AVERAGE(D)
REAL :: CALC_AVERAGE
REAL, INTENT(IN) :: D(:)
END FUNCTION
END INTERFACE
END MODULE ARRAY_CALCULATOR
The following example shows a derived-type definition that is public with components that are private:
MODULE MATTER
TYPE ELEMENTS
PRIVATE
INTEGER C, D
END TYPE
...
END MODULE MATTER
In this case, components C and D are private to type ELEMENTS, but type ELEMENTS is not private to
MODULE MATTER. Any program unit that uses the module MATTER can declare variables of type ELEMENTS,
and pass as arguments values of type ELEMENTS.
This design allows you to change components of a type without affecting other program units that use the
module.
If a derived type is needed in more than one program unit, the definition should be placed in a module and
accessed by a USE statement whenever it is needed, as follows:
MODULE STUDENTS
TYPE STUDENT_RECORD
...
END TYPE
CONTAINS
SUBROUTINE COURSE_GRADE(...)
TYPE(STUDENT_RECORD) NAME
...
END SUBROUTINE
END MODULE STUDENTS
...
PROGRAM SENIOR_CLASS
USE STUDENTS
TYPE(STUDENT_RECORD) ID
...
END PROGRAM
1817
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Program SENIOR_CLASS has access to type STUDENT_RECORD, because it uses module STUDENTS. Module
procedure COURSE_GRADE also has access to type STUDENT_RECORD, because the derived-type definition
appears in its host.
See Also
SUBMODULE
PUBLIC
PRIVATE
USE
Procedure Interfaces
Program Units and Procedures
PROTECTED Attribute and Statement
MODULE FUNCTION
Statement: Indicates a separate module procedure.
Example
submodule (M) A
contains
real module function foo (arg) result(res)
type(tt), intent(in) :: arg
res = arg%r
end function foo
end submodule A
See Also
Separate Module Procedures
MODULE PROCEDURE
Statement: Identifies module procedures in an
interface block that specifies a generic name.
Example
!A program that changes non-default integers and reals
! into default integers and reals
PROGRAM CHANGE_KIND
USE Module1
integer(2) in
integer indef
indef = DEFAULT(in)
END PROGRAM
1818
Language Reference
INTEGER(2) z
sub2 = INT(z)
END FUNCTION
END MODULE
See Also
INTERFACE
MODULE
Modules and Module Procedures
PROCEDURE
MODULE SUBROUTINE
Statement: Indicates a separate module procedure.
Example
submodule (M) A
contains
real module subroutine FOO (arg)
type(tt), intent(in) :: arg
arg%r =1
end subroutine FOO
end submodule A
See Also
Separate Module Procedures
MODULO
Elemental Intrinsic Function (Generic): Returns
the modulo of the arguments.
Syntax
result = MODULO (a,p)
p (Input) Must have the same type and kind parameters as a. It must
not have a value of zero.
Results
The result type is the same a. The result value depends on the type of a, as follows:
• If a is of type integer and p is not equal to zero, the value of the result is a - FLOOR(REAL( a) / REAL( p))
* p, that is, the result has a value such that a = q * p + result where q is an integer. The following also
applies:
• If p > 0, then 0 <= result < p
• If p < 0, then p < result <= 0
• If a is of type real and p is not equal to zero, the value of the result is a - FLOOR( a/ p) * p.
If p is equal to zero (regardless of the type of a), the result is undefined.
Example
MODULO (7, 3) has the value 1.
1819
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
INTEGER I
REAL R
I= MODULO(8, 5) ! returns 3 Note: q=1
I= MODULO(-8, 5) ! returns 2 Note: q=-2
I= MODULO(8, -5) ! returns -2 Note: q=-2
I= MODULO(-8,-5) ! returns -3 Note: q=1
R= MODULO(7.285, 2.35) ! returns 0.2350001 Note: q=3
R= MODULO(7.285, -2.35) ! returns -2.115 Note: q=-4
See Also
MOD
MOVE_ALLOC
Intrinsic Subroutine (Generic): Moves an allocation
from one allocatable object to another. Intrinsic
subroutines cannot be passed as actual arguments.
Syntax
CALL MOVE_ALLOC (from,to [, stat, errmsg])
from (Input; output) Can be of any type, type parameters, corank, and
rank; it must be allocatable.
to (Output) Must be type compatible with from and have the same rank
and corank; it must be allocatable. It must be polymorphic if from is
polymorphic. Each nondeferred type parameter of the declared type of
to must have the same value as the corresponding type parameter of
the declared type of from. For more information about type
compatibility, see the description in CLASS.
When the execution of MOVE_ALLOC is successful, or if STAT is assigned the value STAT_FAILED_IMAGE, the
following occurs:
• If to is currently allocated, it is deallocated.
• If from is allocated, to becomes allocated with the same type, type parameters, array bounds, and values
as from.
• from is deallocated.
If to has the TARGET attribute, any pointer associated with from at the time of the call to MOVE_ALLOC
becomes correspondingly associated with to. If to does not have the TARGET attribute, the pointer
association status of any pointer associated with from on entry becomes undefined.
During execution of MOVE_ALLOC, the internal descriptor contents are copied from from to to, so that the
storage pointed to by to is the storage that from used to point to.
Typically, MOVE_ALLOC is used to provide an efficient way to reallocate a variable to a larger size without
copying the data twice.
1820
Language Reference
A reference to MOVE_ALLOC that has a coarray from argument has an implicit synchronization of all active
images of the current team. No image proceeds until all active images of the current team have completed
execution of the reference. If the current team contains any images that have stopped or failed, an error
condition occurs.
If the procedure reference is successful, stat becomes defined with the value zero.
If an error condition occurs and stat is not specified, error termination is initiated. If stat is present and the
current team contains an image that has stopped, stat becomes defined with the value
STAT_STOPPED_IMAGE from the intrinsic module ISO_FORTRAN_ENV. Otherwise, if stat is present, the
current team contains a failed image, and no other error condition occurs, stat becomes defined with the
value STAT_FAILED_IMAGE from the intrinsic module ISO_FORTRAN_ENV. Otherwise, stat becomes defined
with a positive integer value different from STAT_STOPPED_IMAGE and STAT_FAILED_IMAGE.
The definition status of errmsg, if present, remains unchanged if the execution of the reference is successful.
If errmsg is present and an error condition occurs, errmsg becomes defined with an explanatory message
describing the error.
Example
The following shows an example of how to increase the allocated size of X and keep the old values with only
one copy of the old values. Using only assignment, a temporary variable named Y will be allocated and X
assigned to Y. Then X will be deallocated and reallocated to be twice the size; then Y will be assigned to the
first half of X. Finally, the temporary Y is deallocated.
allocated of X is T
allocated of Y is T
old X is 1.000000 2.000000
old Y is -1.000000 -1.000000 -1.000000 -1.000000
new Y is 1.000000 2.000000 -1.000000 -1.000000
allocated of X is T
allocated of Y is F
new X is 1.000000 2.000000 -1.000000 -1.000000
See Also
ISO_FORTRAN_ENV Module
1821
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Module
USE IFQWIN
Syntax
CALL MOVETO (x,y,s)
CALL MOVETO_W (wx,wy,ws)
TYPE xycoord
INTEGER(2) xcoord ! x coordinate
INTEGER(2) ycoord ! y coordinate
END TYPE xycoord
TYPE wxycoord
DOUBLE PRECISION WX,WY
STRUCTURE/WXYCOORD/
DOUBLE PRECISION WX
DOUBLE PRECISION WY
END STRUCTURE
END TYPE wxycoord
MOVETO sets the current graphics position to the viewport coordinate ( x, y). MOVETO_W sets the current
graphics position to the window coordinate ( wx, wy).
MOVETO and MOVETO_W assign the coordinates of the previous position to s.
Example
! Build as QuickWin or Standard Graphics ap.
USE IFQWIN
INTEGER(2) status, x, y
INTEGER(4) result
TYPE (xycoord) xy
RESULT = SETCOLORRGB(Z'FF0000') ! blue
x = 60
! Draw a series of lines DO y = 50, 92, 3
CALL MOVETO(x, y, xy)
status = LINETO(INT2(x + 20), y)
END DO
END
1822
Language Reference
See Also
GETCURRENTPOSITION
LINETO
OUTGTEXT
MVBITS
Elemental Intrinsic Subroutine (Generic): Copies
a sequence of bits (a bit field) from one location to
another. Intrinsic subroutines cannot be passed as
actual arguments.
Syntax
CALL MVBITS (from,frompos,len,to,topos)
from (Input) Integer. Can be of any integer type. It represents the location
from which a bit field is transferred.
to (Input; output) Can be of any integer type, but must have the same
kind parameter as from. It represents the location to which a bit field
is transferred. to is set by copying the sequence of bits of length len,
starting at position frompos of from to position topos of to. No other
bits of to are altered.
Example
If TO has the initial value of 6, its value after a call to MVBITS(7, 2, 2, TO, 0) is 5.
1823
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
BIT_SIZE
IBCLR
IBSET
ISHFT
ISHFTC
NAMELIST
Statement: Associates a name with a list of
variables. This group name can be referenced in some
input/output operations.
Syntax
NAMELIST /group/ var-list[[,] /group/ var-list]...
Description
The namelist group name is used by namelist I/O statements instead of an I/O list. The unique group name
identifies a list whose entities can be modified or transferred.
A variable can appear in more than one namelist group.
Each variable in var-list must be accessed by use or host association, or it must have its type, type
parameters, and shape explicitly or implicitly specified in the same scoping unit. If the variable is implicitly
typed, it can appear in a subsequent type declaration only if that declaration confirms the implicit typing.
You cannot specify an assumed-size array in a namelist group.
Only the variables specified in the namelist can be read or written in namelist I/O. It is not necessary for the
input records in a namelist input statement to define every variable in the associated namelist.
The order of variables in the namelist controls the order in which the values appear on namelist output. Input
of namelist values can be in any order.
If the group name has the PUBLIC attribute, no item in the variable list can have the PRIVATE attribute.
The group name can be specified in more than one NAMELIST statement in a scoping unit. The variable list
following each successive appearance of the group name is treated as a continuation of the list for that group
name.
Example
In the following example, D and E are added to the variables A, B, and C for group name LIST:
NAMELIST /LIST/ A, B, C
NAMELIST /LIST/ D, E
1824
Language Reference
CHARACTER*30 NAME(25)
NAMELIST /INPUT/ NAME, GRADE, DATE /OUTPUT/ TOTAL, NAME
Group name INPUT contains variables NAME, GRADE, and DATE. Group name OUTPUT contains variables
TOTAL and NAME.
The following shows another example:
NAMELIST /example/ i1, l1, r4, r8, z8, z16, c1, c10, iarray
! The corresponding input statements could be:
&example
i1 = 11
l1 = .TRUE.
r4 = 24.0
r8 = 28.0d0
z8 = (38.0, 0.0)
z16 = (316.0d0, 0.0d0)
c1 = 'A'
c10 = 'abcdefghij'
iarray(8) = 41, 42, 43
/
A sample program, NAMELIST.F90, is included in the <install-dir>/samples subdirectory.
See Also
READ
WRITE
Namelist Specifier
Namelist Input
Namelist Output
NARGS
Inquiry Intrinsic Function (Specific): Returns the
total number of command-line arguments, including
the command. This function cannot be passed as an
actual argument.
Syntax
result = NARGS( )
Results
The result type is INTEGER(4). The result is the number of command-line arguments, including the
command. For example, NARGS returns 4 for the command-line invocation of PROG1 -g -c -a.
Example
INTEGER(2) result
result = RUNQQ('myprog', '-c -r')
END
1825
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
COMPLEX c1 / (0.0,0.0) /
REAL(8) d1 / 0.0 /
num = 5
count = NARGS()
DO i = 1, count-1
CALL GETARG(i, buf, status)
IF (status .lt. 0) THEN
WRITE (*,*) 'GETARG error - exiting'
EXIT
END IF
IF (buf(2:status) .EQ.'r') THEN
r1 = REAL(num)
WRITE (*,*) 'r1 = ',r1
ELSE IF (buf(2:status) .EQ.'c') THEN
c1 = CMPLX(num)
WRITE (*,*) 'c1 = ', c1
ELSE IF (buf(2:status) .EQ.'d') THEN
d1 = DBLE(num)
WRITE (*,*) 'd1 = ', d1
ELSE
WRITE(*,*) 'Invalid command switch: ', buf (1:status)
END IF
END DO
END
See Also
GETARG
IARGC
COMMAND_ARGUMENT_COUNT
GET_COMMAND
GET_COMMAND_ARGUMENT
NEAREST
Elemental Intrinsic Function (Generic): Returns
the nearest different number (representable on the
processor) in a given direction.
Syntax
result = NEAREST (x, s)
Results
The result type and kind are the same as x. The result has a value equal to the machine representable
number that is different from and nearest to x, in the direction of the infinity with the same sign as s.
Example
If 3.0 and 2.0 are REAL(4) values, NEAREST (3.0, 2.0) has the value 3 + 2 -22, which equals approximately
3.0000002. (For more information on the model for REAL(4), see Model for Real Data.
1826
Language Reference
REAL(4) r1
REAL(8) r2, result
r1 = 3.0
result = NEAREST (r1, -2.0)
WRITE(*,*) result ! writes 2.999999761581421
See Also
EPSILON
NEW_LINE
Inquiry Intrinsic Function (Generic): Returns a
new line character.
Syntax
result = NEW_LINE(a)
Results
The result is a character scalar of length one with the same kind type parameter as a.
The result value is the ASCII newline character ACHAR(10).
NINT
Elemental Intrinsic Function (Generic): Returns
the nearest integer to the argument.
Syntax
result = NINT (a[,kind])
Results
The result type is integer. If kind is present, the kind parameter of the result is that specified by kind;
otherwise, the kind parameter of the result is shown in the following table. If the processor cannot represent
the result value in the kind of the result, the result is undefined.
If a is greater than zero, NINT(a) has the value INT(a+ 0.5); if a is less than or equal to zero, NINT(a) has
the value INT(a- 0.5).
1827
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
NINT (3.879) has the value 4.
NINT (-2.789) has the value -3.
The following shows another example:
INTEGER(4) i1, i2
i1 = NINT(2.783) ! returns 3
i2 = IDNINT(-2.783D0) ! returns -3
See Also
ANINT
INT
NLSEnumCodepages (W*S)
NLS Function: Returns an array containing the
codepages supported by the system, with each array
element describing one valid codepage.
Module
USE IFNLS
Syntax
ptr=> NLSEnumCodepages( )
Results
The result is a pointer to an array of codepages, with each element describing one supported codepage.
1828
Language Reference
NOTE
After use, the pointer returned by NLSEnumCodepages should be deallocated with the
DEALLOCATE statement.
See Also
NLSEnumLocales
DEALLOCATE
NLSEnumLocales (W*S)
NLS Function: Returns an array containing the
language and country combinations supported by the
system, in which each array element describes one
valid combination.
Module
USE IFNLS
Syntax
ptr=> NLSEnumLocales( )
Results
The result is a pointer to an array of locales, in which each array element describes one supported language
and country combination. Each element has the following structure:
TYPE NLS$EnumLocale
CHARACTER*(NLS$MaxLanguageLen) Language
CHARACTER*(NLS$MaxCountryLen) Country
INTEGER(4) DefaultWindowsCodepage
INTEGER(4) DefaultConsoleCodepage
END TYPE
If the application is a Windows or QuickWin application, NLS$DefaultWindowsCodepage is the codepage used
by default for the given language and country combination. If the application is a console application, NLS
$DefaultConsoleCodepage is the codepage used by default for the given language and country combination.
NOTE
After use, the pointer returned by NLSEnumLocales should be deallocated with the
DEALLOCATE statement.
See Also
NLSEnumCodepages
DEALLOCATE
NLSFormatCurrency (W*S)
NLS Function: Returns a correctly formatted
currency string for the current locale.
Module
USE IFNLS
1829
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
result = NLSFormatCurrency (outstr,instr[,flags])
Results
The result type is INTEGER(4). The result is the number of characters written to outstr(bytes are counted,
not multibyte characters). If an error occurs, the result is one of the following negative values:
• NLS$ErrorInsufficentBuffer - outstr buffer is too small
• NLS$ErrorInvalidFlags - flags has an illegal value
• NLS$ErrorInvalidInput - instr has an illegal value
Example
USE IFNLS
CHARACTER(40) str
INTEGER(4) i
i = NLSFormatCurrency(str, "1.23")
print *, str ! prints $1.23
i = NLSFormatCurrency(str, "1000000.99")
print *, str ! prints $1,000,000.99
i = NLSSetLocale("Spanish", "Spain")
i = NLSFormatCurrency(str, "1.23")
print *, str ! prints 1 Pts
i = NLSFormatCurrency(str, "1000000.99")
print *, str ! prints 1.000.001 Pts
See Also
NLSFormatNumber
NLSFormatDate
NLSFormatTime
NLSFormatDate (W*S)
NLS Function: Returns a correctly formatted string
containing the date for the current locale.
Module
USE IFNLS
1830
Language Reference
Syntax
result = NLSFormatDate (outstr [, intime] [, flags])
Results
The result type is INTEGER(4). The result is the number of characters written to outstr (bytes are counted,
not multibyte characters). If an error occurs, the result is one of the following negative values:
• NLS$ErrorInsufficentBuffer - outstr buffer is too small
• NLS$ErrorInvalidFlags - flags has an illegal value
• NLS$ErrorInvalidInput - intime has an illegal value
Example
USE IFNLS
INTEGER(4) i
CHARACTER(40) str
i = NLSFORMATDATE(str, FLAGS=NLS$NORMAL) ! 8/1/10
i = NLSFORMATDATE(str, FLAGS=NLS$USEALTCALENDAR) ! 8/1/10
i = NLSFORMATDATE(str, FLAGS=NLS$LONGDATE) ! Sunday, August 1, 2010
i = NLSFORMATDATE(str, FLAGS=NLS$SHORTDATE) ! 8/1/10
END
See Also
NLSFormatTime
NLSFormatCurrency
NLSFormatNumber
NLSFormatNumber (W*S)
NLS Function: Returns a correctly formatted number
string for the current locale.
Module
USE IFNLS
Syntax
result = NLSFormatNumber (outstr, instr [, flags])
1831
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type is INTEGER(4). The result is the number of characters written to outstr (bytes are counted,
not multibyte characters). If an error occurs, the result is one of the following negative values:
• NLS$ErrorInsufficentBuffer - outstr buffer is too small
• NLS$ErrorInvalidFlags - flags has an illegal value
• NLS$ErrorInvalidInput - instr has an illegal value
Example
USE IFNLS
CHARACTER(40) str
INTEGER(4) i
i = NLSFormatNumber(str, "1.23")
print *, str ! prints 1.23
i = NLSFormatNumber(str, "1000000.99")
print *, str ! prints 1,000,000.99
i = NLSSetLocale("Spanish", "Spain")
i = NLSFormatNumber(str, "1.23")
print *, str ! prints 1,23
i = NLSFormatNumber(str, "1000000.99")
print *, str ! prints 1.000.000,99
END
See Also
NLSFormatTime
NLSFormatCurrency
NLSFormatDate
NLSFormatTime (W*S)
NLS Function: Returns a correctly formatted string
containing the time for the current locale.
Module
USE IFNLS
Syntax
result = NLSFormatTime (outstr [, intime] [, flags])
1832
Language Reference
Results
The result type is INTEGER(4). The result is the number of characters written to outstr (bytes are counted,
not multibyte characters). If an error occurs, the result is one of the following negative values:
• NLS$ErrorInsufficentBuffer - outstr buffer is too small
• NLS$ErrorInvalidFlags - flags has an illegal value
• NLS$ErrorInvalidInput - intime has an illegal value
Example
USE IFNLS
INTEGER(4) i
CHARACTER(20) str
i = NLSFORMATTIME(str, FLAGS=NLS$NORMAL) ! 11:38:28 PM
i = NLSFORMATTIME(str, FLAGS=NLS$NOMINUTESORSECONDS) ! 11 PM
i = NLSFORMATTIME(str, FLAGS=NLS$NOTIMEMARKER) ! 11:38:28 PM
i = NLSFORMATTIME(str, FLAGS=IOR(NLS$FORCE24HOURFORMAT, &
& NLS$NOSECONDS)) ! 23:38 PM
END
See Also
NLSFormatCurrency
NLSFormatDate
NLSFormatNumber
NLSGetEnvironmentCodepage (W*S)
NLS Function: Returns the codepage number for the
system (Window) codepage or the console codepage.
Module
USE IFNLS
Syntax
result = NLSGetEnvironmentCodepage (flags)
1833
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type is INTEGER(4). The result is zero if successful; otherwise, it returns one of the following error
codes:
• NLS$ErrorInvalidFlags - flags has an illegal value.
• NLS$ErrorNoConsole - There is no console associated with the given application. So, operations with the
console codepage are not possible.
See Also
NLSSetEnvironmentCodepage
NLSGetLocale (W*S)
NLS Subroutine: Returns the current language,
country, or codepage.
Module
USE IFNLS
Syntax
CALL NLSGetLocale ([language] [,country] [,codepage])
NLSGetLocale returns a valid codepage in codepage. It does not return one of the NLS$... symbolic
constants that can be used with NLSSetLocale.
Example
USE IFNLS
CHARACTER(50) cntry, lang
INTEGER(4) code
CALL NLSGetLocale (lang, cntry, code) ! get all three
CALL NLSGetLocale (CODEPAGE = code) ! get the codepage
CALL NLSGetLocale (COUNTRY = cntry, CODEPAGE =code) ! get country
! and codepage
See Also
NLSSetLocale
NLSGetLocaleInfo (W*S)
NLS Function: Returns information about the current
locale.
1834
Language Reference
Module
USE IFNLS
Syntax
result = NLSGetLocaleInfo (type,outstr)
outstr (Output) Character*(*). Parameter setting for the current locale. All
parameter settings placed in outstr are character strings, even
numbers. If a parameter setting is numeric, the ASCII representation
of the number is used. If the requested parameter is a date or time
string, an explanation of how to interpret the format in outstr is
provided in NLS Date and Time Format.
Results
The result type is INTEGER(4). The result is the number of characters written to outstr if successful, or if
outstr has 0 length, the number of characters required to hold the requested information. Otherwise, the
result is one of the following error codes (defined in IFNLS.F90):
The NLS$LI parameters are used for the argument type and select the locale information returned by
NLSGetLocaleInfo in outstr. You can perform an inclusive OR with NLS$NoUserOverride and any NLS$LI
parameter. This causes NLSGetLocaleInfo to bypass any user overrides and always return the system default
value.
The following table lists and describes the NLS$LI parameters in alphabetical order.
NLS$LI_ICENTURY Specifies whether to use full 4-digit century for the short date
only:
0 - Two-digit year
1 - Full century
1835
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Parameter Description
NLS$LI_IDAYLZERO Specifies whether to use leading zeros in day fields for the
short date only:
0 - Use no leading zeros
1 - Use leading zeros
NLS$LI_IDEFAULTCOUNTRY Country code for the principal country in this locale. This is
provided so that partially specified locales can be completed
with default values.
1836
Language Reference
Parameter Description
NLS$LI_IMEASURE This value is 0 if the metric system (S.I.) is used and 1 for the
U.S. system of measurements.
NLS$LI_IMONLZERO Specifies whether to use leading zeros in month fields for the
short date only:
0 - Use no leading zeros
1 - Use leading zeros
1837
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Parameter Description
1838
Language Reference
Parameter Description
NLS$LI_SABBREVDAYNAME1 - Native abbreviated name for each day of the week. 1 = Mon, 2
NLS$LI_SABBREVDAYNAME7 = Tue, etc.
NLS$LI_SCURRENCY The string used as the local monetary symbol. Cannot be set
to digits 0-9.
NLS$LI_SENGCOUNTRY The full English name of the country. This will always be
restricted to characters that map into the ASCII 127 character
subset.
NLS$LI_SENGLANGUAGE The full English name of the language from the ISO Standard
639. This will always be restricted to characters that map into
the ASCII 127 character subset.
NLS$LI_SGROUPING Sizes for each group of digits to the left of the decimal. An
explicit size is needed for each group; sizes are separated by
semicolons. If the last value is 0 the preceding value is
repeated. To group thousands, specify "3;0".
NLS$LI_SLONGDATE Long Date formatting string for this locale. The string returned
may contain a string within single quotes (' '). Any characters
within single quotes should be left as is. The d, M and y should
have the day, month, and year substituted, respectively.
1839
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Parameter Description
NLS$LI_SMONGROUPING Sizes for each group of monetary digits to the left of the
decimal. If the last value is 0, the preceding value is repeated.
To group thousands, specify "3;0".
NLS$LI_SNATIVEDIGITS The ten characters that are the native equivalent to the ASCII
0-9.
NLS$LI_SNEGATIVESIGN String value for the negative sign. Cannot be set to digits 0-9.
NLS$LI_SPOSITIVESIGN String value for the positive sign. Cannot be set to digits 0-9.
NLS$LI_SSHORTDATE Short Date formatting string for this locale. The d, M and y
should have the day, month, and year substituted,
respectively. See NLS Date and Time Format for explanations
of the valid strings.
NLS$LI_STIMEFORMAT Time formatting string. See NLS Date and Time Format for
explanations of the valid strings.
When NLSGetLocaleInfo ( type, outstr) returns information about the date and time formats of the current
locale, the value returned in outstr can be interpreted according to the following tables. Any text returned
within a date and time string that is enclosed within single quotes should be left in the string in its exact
form; that is, do not change the text or the location within the string.
Day
The day can be displayed in one of four formats using the letter "d". The following table shows the four
variations:
d Day of the month as digits without leading zeros for single-digit days
dd Day of the month as digits with leading zeros for single-digit days
Month
1840
Language Reference
The month can be displayed in one of four formats using the letter "M". The uppercase "M" distinguishes
months from minutes. The following table shows the four variations:
Year
The year can be displayed in one of three formats using the letter "y". The following table shows the three
variations:
Period/Era
The period/era string is displayed in a single format using the letters "gg".
gg Period/Era string
Time
The time can be displayed in one of many formats using the letter "h" or "H" to denote hours, the letter "m"
to denote minutes, the letter "s" to denote seconds and the letter "t" to denote the time marker. The
following table shows the numerous variations of the time format. Lowercase "h" denotes the 12 hour clock
and uppercase "H" denotes the 24 hour clock. The lowercase "m" distinguishes minutes from months.
h Hours without leading zeros for single-digit hours (12 hour clock)
hh Hours with leading zeros for single-digit hours (12 hour clock)
H Hours without leading zeros for single-digit hours (24 hour clock)
HH Hours with leading zeros for single-digit hours (24 hour clock)
Example
USE IFNLS
INTEGER(4) strlen
CHARACTER(40) str
strlen = NLSGetLocaleInfo(NLS$LI_SDAYNAME1, str)
1841
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
NLSGetLocale
NLSFormatDate
NLSFormatTime
NLSSetLocale
NLSSetEnvironmentCodepage (W*S)
NLS Function: Sets the codepage for the current
console. The specified codepage affects the current
console program and any other programs launched
from the same console. It does not affect other open
consoles or any consoles opened later.
Module
USE IFNLS
Syntax
result = NLSSetEnvironmentCodepage (codepage,flags)
Results
The result type is INTEGER(4). The result is zero if successful. Otherwise, returns one of the following error
codes defined in IFNLS.F90:
See Also
NLSGetEnvironmentCodepage
NLSSetLocale (W*S)
NLS Function: Sets the current language, country, or
codepage.
Module
USE IFNLS
Syntax
result = NLSSetLocale (language[,country] [,codepage])
1842
Language Reference
Results
The result type is INTEGER(4). The result is zero if successful. Otherwise, one of the following error codes
(defined in IFNLS.F90) may be returned:
NOTE
NLSSetLocale works on installed locales only. Many locales are supported, but they must be
installed through the system Control Panel/International menu.
When doing mixed-language programming with Fortran and C, calling NLSSetLocale with a codepage other
than the default environment Windows codepage causes the codepage in the C run-time library to change by
calling C's setmbcp( ) routine with the new codepage. Conversely, changing the C run-time library codepage
does not change the codepage in the Fortran NLS library.
Calling NLSSetLocale has no effect on the locale used by C programs. The locale set with C's setlocale( )
routine is independent of NLSSetLocale.
Calling NLSSetLocale with the default environment console codepage, NLS$ConsoleEnvironmentCodepage,
causes an implicit call to the Windows API SetFileApisToOEM( ). Calling NLSSetLocale with any other
codepage causes a call to SetFileApisToANSI( ).
1843
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
NLSGetLocale
NOFREEFORM
Statement: Specifies that source code is in fixed-
form format.
For more information, see FREEFORM and NOFREEFORM.
NOFUSION
General Compiler Directive: Prevents a loop from
fusing with adjacent loops.
Syntax
!DIR$ NOFUSION
The NOFUSION directive lets you fine tune your program on a loop-by-loop basis.
This directive should be placed immediately before the DO statement of the loop that should not be fused.
Example
Consider the following example that demonstrates use of the NOFUSION directive:
See Also
General Compiler Directives
NON_RECURSIVE
Keyword: Specifies that a subroutine or function does
not call itself directly or indirectly.
For more information, see RECURSIVE and NON_RECURSIVE.
1844
Language Reference
NOOPTIMIZE
Statement: Disables optimizations.
For more information, see OPTIMIZE and NOOPTIMIZE.
NOPREFETCH
Statement: Disables data prefetching.
For more information, see PREFETCH and NOPREFETCH.
NORM2
Transformational Intrinsic Function (Generic):
Returns the L2 norm of an array.
Syntax
result = NORM2 (x)
result = NORM2 (x, dim)
dim (Input) Must be a scalar integer with a value in the range 1 <= dim
<= n, where n is the rank of x.
Results
The result is of the same type and kind parameters as x.
The result is a scalar if dim is not specified; otherwise, the result has rank n - 1 and shape [d1, d2, ..., ddim-1,
ddim+1, ..., dn], where n is the rank of x and [d1, d2, ..., dn] is the shape of x.
The result of NORM2 (x) has a value equal to a processor-dependent approximation to the generalized L2
norm of x, which is the square root of the sum of the squares of the elements of x.
The result of NORM2 (x, DIM=dim) has a value equal to that of NORM2 (x) if x has rank one.
Otherwise, the value of element (s1, s2, .., sdim-1, sdim+1, ... sn) of the result is equal to NORM2 (x (s1, s2, ..,
sdim-1, :, sdim+1, ... sn)).
It is recommended that the processor compute the result without undue overflow or underflow.
Example
The value of NORM2 ([3.0, 4.0]) is 5.0 (approximately).
If X has the value:
[ 1.0 2.0 ]
[ 3.0 4.0 ]
then the value of NORM2 (X, DIM=1) is approximately [3.162, 4.472] and the value of NORM2 (X, DIM=2) is
approximately [2.236,5.0].
NOSTRICT
Statement: Enables language features not found in
the language standard specified on the command line.
For more information, see STRICT and NOSTRICT.
1845
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOT
Elemental Intrinsic Function (Generic): Returns
the logical complement of the argument.
Syntax
result = NOT (i)
Results
The result type and kind are the same as i. The result value is obtained by complementing i bit-by-bit
according to the following truth table:
INOT (I)
1 0
0 1
The model for the interpretation of an integer value as a sequence of bits is shown in Model for Bit Data.
Example
If I has a value equal to 10101010 (base 2), NOT (I) has the value 01010101 (base 2).
The following shows another example:
See Also
BTEST
IAND
IBCHNG
IBCLR
IBSET
IEOR
IOR
ISHA
ISHC
ISHL
ISHFT
1846
Language Reference
ISHFTC
NOUNROLL
Statement: Disables the unrolling of a DO loop.
For more information, see UNROLL and NOUNROLL.
NOUNROLL_AND_JAM
Statement: Hints to the compiler to disable loop
unrolling and jamming.
For more information, see UNROLL_AND_JAM and NOUNROLL_AND_JAM.
NOVECTOR
Statement: Disables vectorization of a DO loop.
For more information, see VECTOR and NOVECTOR.
NOWAIT Clause
Parallel Directive Clause: Specifies that threads
may resume execution before the execution of the
region completes.
Syntax
NOWAIT
When you specify this clause, it removes the synchronization barrier implied at the end of the region.
Note that NOWAIT can also be specified as a keyword in several directives.
At most one NOWAIT clause or keyword can appear in a directive that allows the clause or keyword.
NULL
Transformational Intrinsic Function (Generic):
Initializes a pointer as disassociated when it is
declared.
Syntax
result = NULL ([ mold])
Results
The result type and kind are the same as mold, if present; otherwise, it is determined as follows:
On the right side of pointer assignment The pointer on the left side
1847
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Caution
If you use module IFWIN or IFWINTY, you will have a name conflict if you use the NULL
intrinsic. To avoid this problem, rename the integer parameter constant NULL to something
else; for example:
USE IFWIN, NULL0 => NULL
This example lets you use both NULL0 and NULL( ) in the same program unit with no conflict.
Example
Consider the following:
NULLIFY
Statement: Disassociates a pointer from a target.
Syntax
NULLIFY (pointer-object[,pointer-object]...)
Description
The initial association status of a pointer is undefined. You can use NULLIFY to initialize an undefined pointer,
giving it disassociated status. Then the pointer can be tested using the intrinsic function ASSOCIATED.
Example
The following is an example of the NULLIFY statement:
1848
Language Reference
NULLIFY (arrow2)
IF (.NOT.ASSOCIATED(arrow2)) WRITE (*,'(/a/)') ' ARROW2 is not pointed.'
WRITE (*,'( 1x,a,7f8.0)') 'pointer',arrow1
WRITE (*,'(/1x,a,7f8.0)') 'target ',bullseye
END
See Also
ALLOCATE
ASSOCIATED
DEALLOCATE
POINTER
TARGET
NULL
Pointer Assignments
Dynamic Allocation
NUM_IMAGES
Transformational Intrinsic Function (Generic):
Returns the number of images on the current or
specified team.
Syntax
result = NUM_IMAGES()
result = NUM_IMAGES (team)result = NUM_IMAGES (team_number)
1849
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
team_number (Input) Must be an integer scalar. It must identify the initial team (-1),
or a vaild team number of a team created by the same execution of
the FORM TEAM statement that created the current team executing
the function reference (a sibling of the current team).
Results
The result type is default integer. The result is the number of images on the current or specified team.
If neither team nor team_number are specified, the team is the current team. team and team_number may
not both be specified.
You can specify a compiler option or environment variable to modify the number of images. If both are
specified, the environment variable setting overrides the compiler option setting.
A compiler option must be specified to enable coarrays. If it is not specified and you use this intrinsic
function, an error occurs.
Example
In the following example, image 1 is used to read data. The other images then copy the data:
REAL :: R[*]
IF (THIS_IMAGE()==1) THEN
READ (7,*) R
DO I = 2, NUM_IMAGES()
R[I] = R
END DO
END IF
SYNC ALL
See Also
FORM TEAM
O to P
This section describes language features that start with O or P.
O to P
OBJCOMMENT
General Compiler Directive: Specifies a library
search path in an object file.
Syntax
!DIR$ OBJCOMMENT LIB: library
The linker searches for the library named in OBJCOMMENT as if you named it on the command line, that is,
before default library searches. You can place multiple library search directives in the same source file. Each
search directive appears in the object file in the order it is encountered in the source file.
If the OBJCOMMENT directive appears in the scope of a module, any program unit that uses the module also
contains the directive, just as if the OBJCOMMENT directive appeared in the source file using the module.
1850
Language Reference
If you want to have the OBJCOMMENT directive in a module, but do not want it in the program units that use
the module, place the directive outside the module that is used.
Example
! MOD1.F90
MODULE a
!DIR$ OBJCOMMENT LIB: "opengl32.lib"
END MODULE a
! MOD2.F90
!DIR$ OBJCOMMENT LIB: "graftools.lib"
MODULE b
!
END MODULE b
! USER.F90
PROGRAM go
USE a ! library search contained in MODULE a
! included here
USE b ! library search not included
END
See Also
General Compiler Directives
Syntax Rules for Compiler Directives
Equivalent Compiler Options
OPEN
Statement: Connects an external file to a unit,
creates a new file and connects it to a unit, creates a
preconnected file, or changes certain properties of a
connection.
Syntax
OPEN ([UNIT=] io-unit[, FILE= name] [, ERR= label] [, IOMSG=msg-var] [, IOSTAT=i-
var],slist)
label Is the label of the branch target statement that receives control if an
error occurs. For more information, see Branch Specifiers.
slist Is one or more of the following OPEN specifiers in the form specifier=
value or specifier (each specifier can appear only once):
1851
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
The control specifiers ([UNIT=] io-unit, ERR= label, and IOSTAT= i-var) and OPEN specifiers can appear
anywhere within the parentheses following OPEN. However, if the UNIT specifier is omitted, the io-unit must
appear first in the list.
If you specify BLANK=, DECIMAL=, PAD=, ROUND=, or SIGN=, you must also specify FMT= or NML=.
If you specify ID=, you must also specify ASYNCHRONOUS='YES'.
Specifier values that are scalar numeric expressions can be any integer or real expression. The value of the
expression is converted to integer data type before it is used in the OPEN statement.
If the NEWUNIT= specifier does not appear, an io-unit must be specified. If the keyword UNIT= is omitted,
the io-unit must be first in the control list.
If the NEWUNIT= specifier appears, an io-unit must not be specified.
If the NEWUNIT= specifier appears, either the FILE= specifier or the STATUS=SCRATCH specifier must also
appear.
Only one unit at a time can be connected to a file, but multiple OPENs can be performed on the same unit. If
an OPEN statement is executed for a unit that already exists, the following occurs:
• If FILE is not specified, or FILE specifies the same file name that appeared in a previous OPEN statement,
the current file remains connected.
If the file names are the same, the values for the BLANK, CARRIAGECONTROL, CONVERT, DELIM,
DISPOSE, ERR, IOSTAT, and PAD specifiers can be changed. Other OPEN specifier values cannot be
changed, and the file position is unaffected.
• If FILE specifies a different file name, the previous file is closed and the new file is connected to the unit.
The ERR and IOSTAT specifiers from any previously executed OPEN statement have no effect on any
currently executing OPEN statement. If an error occurs, no file is opened or created.
1852
Language Reference
Secondary operating system messages do not display when IOSTAT is specified. To display these messages,
remove IOSTAT or use a platform-specific method.
Example
You can specify character values at run time by substituting a character expression for a specifier value in the
OPEN statement. The character value can contain trailing blanks but not leading or embedded blanks; for
example:
OPTIONAL
Statement and Attribute: Permits dummy
arguments to be omitted in a procedure reference.
Syntax
The OPTIONAL attribute can be specified in a type declaration statement or an OPTIONAL statement, and
takes one of the following forms:
Type Declaration Statement:
type,[att-ls,] OPTIONAL [, att-ls] :: d-arg[, d-arg]...
Statement:
OPTIONAL [::] d-arg[, d-arg] ...
1853
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
The OPTIONAL attribute can only appear in the scoping unit of a subprogram or an interface body, and can
only be specified for dummy arguments. It cannot be specified for arguments that are passed by value.
A dummy argument is "present" if it associated with an actual argument that is itself present. A dummy
argument that is not optional must be present. You can use the PRESENT intrinsic function to determine
whether an optional dummy argument is associated with an actual argument.
To call a procedure that has an optional argument, you must use an explicit interface.
If argument keywords are not used, argument association is positional. The first dummy argument becomes
associated with the first actual argument, and so on. If argument keywords are used, arguments are
associated by the keyword name, so actual arguments can be in a different order than dummy arguments. A
keyword is required for an argument only if a preceding optional argument is omitted or if the argument
sequence is changed.
Example
The following example shows a type declaration statement specifying the OPTIONAL attribute:
SUBROUTINE TEST(A)
REAL, OPTIONAL, DIMENSION(-10:2) :: A
END SUBROUTINE
The following is an example of the OPTIONAL statement:
SUBROUTINE TEST(A, B, L, X)
OPTIONAL :: B
INTEGER A, B, L, X
IF (PRESENT(B)) THEN ! Printing of B is conditional
PRINT *, A, B, L, X ! on its presence
ELSE
PRINT *, A, L, X
ENDIF
END SUBROUTINE
INTERFACE
SUBROUTINE TEST(ONE, TWO, THREE, FOUR)
INTEGER ONE, TWO, THREE, FOUR
OPTIONAL :: TWO
END SUBROUTINE
END INTERFACE
INTEGER I, J, K, L
I = 1
J = 2
K = 3
L = 4
1854
Language Reference
Note that in the second call to subroutine TEST, the second positional (optional) argument is omitted. In this
case, all following arguments must be keyword arguments.
The following shows another example:
SUBROUTINE EX (a, b, c)
REAL, OPTIONAL :: b,c
This subroutine can be called with any of the following statements:
See Also
PRESENT
Argument Keywords in Intrinsic Procedures
Optional Arguments
Argument Association
Type Declarations
Compatible attributes
Syntax
!DIR$ OPTIMIZE[: n]
!DIR$ NOOPTIMIZE
The OPTIMIZE and NOOPTIMIZE directives can only appear once at the top of a procedure program unit. A
procedure program unit is a main program, an external subroutine or function, or a module. OPTIMIZE and
NOOPTIMIZE cannot appear between program units or in a block data program unit. They do not affect any
modules invoked with the USE statement in the program unit that contains them. They do affect CONTAINed
procedures that do not include an explicit OPTIMIZE or NOOPTIMIZE directive.
1855
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOOPTIMIZE is the same as OPTIMIZE:0. They are both equivalent to −O0 (Linux* and macOS*) and /Od
(Windows*).
The procedure is compiled with an optimization level equal to the smaller of n and the optimization level
specified by the O compiler option on the command line. For example, if the procedure contains the directive
NOOPTIMIZE and the program is compiled with compiler option O3, this procedure is compiled at O0 while the
rest of the program is compiled at O3.
See Also
General Compiler Directives
Syntax Rules for Compiler Directives
O compiler option
OPTIONS Directive
General Compiler Directive: Affects data alignment
and warnings about data alignment. Also controls
whether a target attribute is assigned to a section of
program declarations.
Syntax
!DIR$ OPTIONS option[option]
...
!DIR$ END OPTIONS
1856
Language Reference
• RECORDS: For
records
• STRUCTURES:
A synonym
for RECORDS
PAC Packs
KED fields in
records
or data
items in
common
blocks on
arbitrary
byte
boundarie
s.
NAT Naturally
URA aligns
L fields in
records
and data
items in
common
blocks on
up to 64-
bit
boundarie
s
(inconsist
ent with
the
Standard
Fortran).
This
keyword
causes
the
compiler
to
naturally
align all
data in a
common
block,
including
INTEGER(
KIND=8),
1857
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
REAL(KIN
D=8),
and all
COMPLEX
data.
STA Naturally
NDA aligns
RD data
items in
common
blocks on
up to 32-
bit
boundarie
s
(consiste
nt with
the
Standard
Fortran).
This
keyword
only
applies to
common
blocks;
so, you
can
specify /
ALIGN=C
OMMONS
=STANDA
RD, but
you
cannot
specify /
ALIGN=S
TANDARD
.
1858
Language Reference
The OPTIONS (and accompanying END OPTIONS) directives must come after OPTIONS, SUBROUTINE,
FUNCTION, and BLOCK DATA statements (if any) in the program unit, and before the executable part of the
program unit.
The OPTIONS directive supersedes the compiler option align.
For performance reasons, Intel® Fortran aligns local data items on natural boundaries. However,
EQUIVALENCE, COMMON, RECORD, and STRUCTURE data declaration statements can force misaligned data.
If /WARN=NOALIGNMENT is specified, warnings will not be issued if misaligned data is encountered.
NOTE
Misaligned data significantly increases the time it takes to execute a program. As the number of
misaligned fields encountered increases, so does the time needed to complete program execution.
Specifying /ALIGN (or compiler option align) minimizes misaligned data.
Example
Consider the following:
See Also
General Compiler Directives
1859
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
OPTIONS Statement
Statement: Overrides or confirms the compiler
options in effect for a program unit.
Syntax
OPTIONS option[option...]
/ASSUME = [NO]UNDERSCORE
/CHECK = ALL
[NO]BOUNDS
NONE
/NOCHECK
/CONVERT = BIG_ENDIAN
CRAY
FDX
FGX
IBM
LITTLE_ENDIAN
NATIVE
VAXD
VAXG
/[NO]EXTEND_SOURCE
/[NO]F77
/[NO]I4
/[NO]RECURSIVE
The OPTIONS statement must be the first statement in a program unit, preceding the PROGRAM,
SUBROUTINE, FUNCTION, MODULE, and BLOCK DATA statements.
OPTIONS statement options override compiler options, but only until the end of the program unit for which
they are defined. If you want to override compiler options in another program unit, you must specify the
OPTIONS statement before that program unit.
1860
Language Reference
Example
The following are valid OPTIONS statements:
OPTIONS /CHECK=ALL/F77
OPTIONS /I4
See Also
OPEN Statement CONVERT Method
OPTIONS Statement Method
For details on compiler options, see your Compiler Options reference
OR
Elemental Intrinsic Function (Generic): Performs
a bitwise inclusive OR on its arguments.
See IOR.
Example
INTEGER i
i = OR(3, 10) ! returns 11
ORDERED
OpenMP* Fortran Compiler Directive: Specifies a
block of code that the threads in a team must execute
in the natural order of the loop iterations, or, as a
stand-alone directive, it specifies cross-iteration
dependences in a doacross loop nest.
Syntax
It takes one of the following forms:
Form 1:
!$OMP ORDERED [clause [[,] clause ]]
block
!$OMP END ORDERED
Form 2:
!$OMP ORDERED clause [[[,] clause ]...]
1861
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• DEPEND (SOURCE)
• DEPEND (SINK : vec)
At most one DEPEND (SOURCE) clause can appear on an ORDERED
construct.
Either DEPEND (SINK : vec) clauses or DEPEND (SOURCE) clauses
can appear in an ORDERED construct, but not both.
The binding thread set for an ORDERED construct is the current team. An ordered region binds to the
innermost enclosing loop region or the innermost enclosing SIMD region if the SIMD clause is present.
A doacross loop nest is a loop nest that has cross-iteration dependences. An iteration is dependent on one or
more lexicographically earlier iterations. The ORDERED clause parameter on a loop directive identifies the
loops associated with the doacross loop nest.
An ORDERED directive with no clause or with the THREADS clause specified can appear only in the dynamic
extent of a DO or PARALLEL DO directive. The DO directive to which the ordered section binds must have the
ORDERED clause specified.
An iteration of a loop using a DO directive must not execute the same ORDERED directive more than once,
and it must not execute more than one ORDERED directive.
One thread is allowed in an ordered section at a time. Threads are allowed to enter in the order of the loop
iterations. No thread can enter an ordered section until it can be guaranteed that all previous iterations have
completed or will never execute an ordered section. This sequentializes and orders code within ordered
sections while allowing code outside the section to run in parallel.
Ordered sections that bind to different DO directives are independent of each other.
If the SIMD clause is specified, the ordered regions encountered by any thread will use only a single SIMD
lane to execute the ordered regions in the order of the loop iterations.
1862
Language Reference
You can only specify the SIMD clause (!$OMP ORDERED SIMD) within an !$OMP SIMD loop or an !$OMP
DECLARE SIMD procedure.
When a thread executing any subsequent iteration encounters an ORDERED construct with one or more
DEPEND (SINK : vec) clauses, it waits until its dependences on all valid iterations specified by the DEPEND
clauses are satisfied before it completes execution of the ORDERED region. A specific dependence is satisfied
when a thread executing the corresponding iteration encounters an ORDERED construct with a DEPEND
(SOURCE) clause.
For MONOTONIC (list : linear-step), the following rules apply:
• The value of the new list item on each iteration of the associated SIMD loop corresponds to the value of
the original list item before entering the associated loop, plus the number of the iterations for which the
conditional update happens prior to the current iteration, times linear-step.
• The value corresponding to the sequentially last iteration of the associated loop is assigned to the original
list item.
• A list item must not be used in statements that lexically precede the ORDERED SIMD to which it is bound,
that is, in the region from the OMP SIMD to the OMP ORDERED SIMD. A list item must not be modified
outside the ORDERED SIMD to which it is bound, that is, in the region from the OMP END ORDERED to the
OMP END SIMD.
Example
Ordered sections are useful for sequentially ordering the output from work that is done in parallel. Assuming
that a reentrant I/O library exists, the following program prints out the indexes in sequential order:
!$OMP SIMD
DO I=0,N
AMOUNT = COMPUTE_AMOUNT(I)
CLUSTER = COMPUTE_CLUSTER(I) ! Multiple I’s may belong to the
! same cluster within SIMD chunk
!$OMP ORDERED SIMD
TOTALS(CLUSTER) = TOTALS(CLUSTER) + AMOUNT ! Requires ordering to
! process multiple updates
! to the same cluster
!$OMP END ORDERED
END DO
!$OMP END SIMD
The MONOTONIC keyword on the OMP ORDERED SIMD directive specifies that the body of a loop must be
executed in the natural order of the loop iterations. In the following example, the block of code in the OMP
ORDERED SIMD is executed in the ascending, monotonic order of the loop index I:
COUNT = 0
!$OMP SIMD
DO I = 1, N
IF (COND(I)) THEN
!$OMP ORDERED SIMD MONOTONIC (COUNT:1)
1863
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
!$OMP SIMD
DO I = 1, N
INX = INDEX(I)
!$OMP ORDERED SIMD OVERLAP (INX)
A(INX) = A(INX) + B(I)
!$OMP END ORDERED
END DO
!$OMP END SIMD
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
Parallel Processing Model for information about Binding Sets
OUT_OF_RANGE
Elemental Intrinsic Function (Generic): Indicates
if a value can be safely converted to a specified type.
Syntax
result = OUT_OF_RANGE (value, mold [, round])
mold (Input) Must be a scalar of type real or integer. It need not be defined
if it is a variable.
round (Input; optional) Must be a scalar logical. round can only be present if
value is type real and mold is type integer.
Results
The result type is default logical.
If round is not present or has the value .false., and mold is an integer type, the result is .true. if value is a
NaN or an IEEE infinity, or if the integer with the largest magnitude between zero and value (inclusively) is
not representable by an object with the type and kind of mold.
If round has the value .true. and mold is an integer type, the result is .true. if value is a NaN or an IEEE
infinity, or if the integer value nearest value, or the integer of greater magnitude if the two integers are
equally near value, is not representable by an object with the type and kind of mold.
Otherwise, the result is .true. if value is a NaN or IEEE infinity that is not supported by an object of type and
kind of mold, or X is a finite number and the result of rounding value to the extended model for the kind of
mold has a magnitude larger than that of the largest finite number with the same size as value that can be
represented by objects with the type and kind of mold.
1864
Language Reference
Example
If J8 is a variable with type INTEGER (KIND=1), OUT_OF_RANGE (-128.5, J8) will have the result .false. and
OUT_OF_RANGE (-128.5, J8, .TRUE.) will have the value .true..
OUTGTEXT (W*S)
Graphics Subroutine: In graphics mode, sends a
string of text to the screen, including any trailing
blanks.
Module
USE IFQWIN
Syntax
CALL OUTGTEXT (text)
Text output begins at the current graphics position, using the current font set with SETFONT and the current
color set with SETCOLORRGB or SETCOLOR. No formatting is provided. After it outputs the text, OUTGTEXT
updates the current graphics position.
Before you call OUTGTEXT, you must call the INITIALIZEFONTS function.
Because OUTGTEXT is a graphics function, the color of text is affected by the SETCOLORRGB function, not by
SETTEXTCOLORRGB.
Example
! build as a QuickWin App.
USE IFQWIN
INTEGER(2) result
INTEGER(4) i
TYPE (xycoord) xys
result = INITIALIZEFONTS()
result = SETFONT('t''Arial''h18w10pvib')
do i=1,6
CALL MOVETO(INT2(0),INT2(30*(i-1)),xys)
grstat=SETCOLOR(INT2(i))
CALL OUTGTEXT('This should be ')
SELECT CASE (i)
CASE (1)
CALL OUTGTEXT('Blue')
CASE (2)
CALL OUTGTEXT('Green')
CASE (3)
CALL OUTGTEXT('Cyan')
CASE (4)
CALL OUTGTEXT('Red')
CASE (5)
CALL OUTGTEXT('Magenta')
CASE (6)
CALL OUTGTEXT('Orange')
END SELECT
end do
END
1865
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
GETFONTINFO
GETGTEXTEXTENT
INITIALIZEFONTS
MOVETO
SETCOLORRGB
SETFONT
SETGTEXTROTATION
OUTTEXT (W*S)
Graphics Subroutine: In text or graphics mode,
sends a string of text to the screen, including any
trailing blanks.
Module
USE IFQWIN
Syntax
CALL OUTTEXT (text)
Text output begins at the current text position in the color set with SETTEXTCOLORRGB or SETTEXTCOLOR.
No formatting is provided. After it outputs the text, OUTTEXT updates the current text position.
To output text using special fonts, you must use the OUTGTEXT subroutine.
Example
USE IFQWIN
INTEGER(2) oldcolor
TYPE (rccoord) rc
CALL CLEARSCREEN($GCLEARSCREEN)
CALL SETTEXTPOSITION (INT2(1), INT2(5), rc)
oldcolor = SETTEXTCOLOR(INT2(4))
CALL OUTTEXT ('Hello, everyone')
END
See Also
OUTGTEXT
SETTEXTPOSITION
SETTEXTCOLORRGB
WRITE
WRAPON
PACK Directive
General Compiler Directive: Specifies the memory
alignment of derived-type items (and record structure
items).
Syntax
!DIR$ PACK[: {1 | 2 | 4 | 8} ]
1866
Language Reference
Items of derived types, unions, and structures are aligned in memory on the smaller of two sizes: the size of
the type of the item, or the current alignment setting. The current alignment setting can be 1, 2, 4, or 8
bytes. The default initial setting is 8 bytes (unless compiler option vms or align rec n bytes is specified). By
reducing the alignment setting, you can pack variables closer together in memory.
The PACK directive lets you control the packing of derived-type or record structure items inside your program
by overriding the current memory alignment setting.
For example, if PACK:1 is specified, all variables begin at the next available byte, whether odd or even.
Although this slightly increases access time, no memory space is wasted. If PACK:4 is specified, INTEGER(1),
LOGICAL(1), and all character variables begin at the next available byte, whether odd or even. INTEGER(2)
and LOGICAL(2) begin on the next even byte; all other variables begin on 4-byte boundaries.
If the PACK directive is specified without a number, packing reverts to the compiler option setting (if any), or
the default setting of 8.
The directive can appear anywhere in a program before the derived-type definition or record structure
definition. It cannot appear inside a derived-type or record structure definition.
Example
! Use 4-byte packing for this derived type
! Note PACK is used outside of the derived type definition
!DIR$ PACK:4
TYPE pair
INTEGER a, b
END TYPE
! revert to default or compiler option
!DIR$ PACK
See Also
TYPE
STRUCTURE...END STRUCTURE
UNION...END UNION
General Compiler Directives
Syntax Rules for Compiler Directives
align:recnbytes compiler option
vms compiler option
Equivalent Compiler Options
PACK Function
Transformational Intrinsic Function (Generic):
Takes elements from an array and packs them into a
rank-one array under the control of a mask.
Syntax
result = PACK (array,mask[,vector])
1867
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
vector (Input; optional) Must be a rank-one array with the same type and
type parameters as array. Its size must be at least t, where t is the
number of true elements in mask. If mask is a scalar with value true,
vector must have at least as many elements as there are in array.
Elements in vector are used to fill out the result array if there are not
enough elements selected by mask.
Results
The result is a rank-one array with the same type and kind parameters as array. If vector is present, the size
of the result is that of vector. Otherwise, the size of the result is the number of true elements in mask, or the
number of elements in array (if mask is a scalar with value true).
Elements in array are processed in array element order to form the result array. Element i of the result is the
element of array that corresponds to the ith true element of mask. If vector is present and has more
elements than there are true values in mask, any result elements that are empty (because they were not
true according to mask) are set to the corresponding values in vector.
Example
N is the array
[ 0 8 0 ]
[ 0 0 0 ]
[ 7 0 0 ].
PACK (N, MASK=N .NE. 0, VECTOR=(/1, 3, 5, 9, 11, 13/)) produces the result (7, 8, 5, 9, 11, 13).
PACK (N, MASK=N .NE. 0) produces the result (7, 8).
The following shows another example:
See Also
UNPACK
PACKTIMEQQ
Portability Subroutine: Packs time and date values.
Module
USE IFPORT
Syntax
CALL PACKTIMEQQ (timedate,iyr,imon,iday,ihr,imin,isec)
1868
Language Reference
The input values are interpreted as being in the time zone set on the local computer and following the
daylight savings rules for that time zone.
The packed time is the number of seconds since 00:00:00 Greenwich mean time, January 1, 1970. Because
packed time values can be numerically compared, you can use PACKTIMEQQ to work with relative date and
time values. Use UNPACKTIMEQQ to unpack time information. SETFILETIMEQQ uses packed time.
Example
USE IFPORT
INTEGER(2) year, month, day, hour, minute, second, &
hund
INTEGER(4) timedate
CALL GETDAT (year, month, day)
CALL GETTIM (hour, minute, second, hund)
CALL PACKTIMEQQ (timedate, year, month, day, hour, &
minute, second)
END
See Also
UNPACKTIMEQQ
SETFILETIMEQQ
GETFILEINFOQQ
TIME portability routine
Syntax
!$OMP PARALLEL [clause[[,] clause] ... ]
block
!$OMP END PARALLEL
1869
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The PARALLEL and END PARALLEL directive pair must appear in the same routine in the executable section of
the code.
The END PARALLEL directive denotes the end of the parallel region. There is an implied barrier at this point.
Only the primary thread of the team continues execution at the end of a parallel region.
The number of threads in the team can be controlled by the NUM_THREADS clause, the environment variable
OMP_NUM_THREADS, or by calling the run-time library routine OMP_SET_NUM_THREADS from a serial
portion of the program.
NUM_THREADS supersedes the OMP_SET_NUM_THREADS routine, which supersedes the
OMP_NUM_THREADS environment variable. Subsequent parallel regions, however, are not affected unless
they have their own NUM_THREADS clauses.
Once specified, the number of threads in the team remains constant for the duration of that parallel region.
If the dynamic threads mechanism is enabled by an environment variable or a library routine, then the
number of threads requested by the NUM_THREADS clause is the maximum number to use in the parallel
region.
The code contained within the dynamic extent of the parallel region is executed on each thread, and the code
path can be different for different threads.
If a thread executing a parallel region encounters another parallel region, it creates a new team and becomes
the primary thread of that new team. By default, nested parallel regions are always serialized and executed
by a team of one thread.
1870
Language Reference
Example
You can use the PARALLEL directive in coarse-grain parallel programs. In the following example, each thread
in the parallel region decides what part of the global array X upon which to work based on the thread
number:
CALL OMP_SET_NUM_THREADS(3)
!$OMP PARALLEL
...
!$OMP END PARALLEL
CALL OMP_SET_NUM_THREADS(4)
!$OMP PARALLEL DO
...
!$OMP END PARALLEL DO
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
OpenMP* Run-time Library Routines for Fortran
PARALLEL DO
SHARED Clause
Parallel Processing Model for information about Binding Sets
Syntax
!DIR$ PARALLEL [clause[[,] clause] ... ]
!DIR$ NOPARALLEL
• ALWAYS [ASSERT]
• FIRSTPRIVATE (list)
Provides a superset of the functionality provided by the PRIVATE
clause. Variables that appear in a FIRSTPRIVATE list are subject to
PRIVATE clause semantics. In addition, private (local) copies of
each variable in the different iterations are initialized to the value
the variable had upon entering the parallel loop.
• LASTPRIVATE (list)
1871
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
list Is one or more items in the form: var [:expr]…. Each list item must be
separated by a comma.
• If var is an array, then only its first expr elements are privatized.
If expr is omitted, the entire array is privatized.
• If var is a pointer, then the first expr elements are privatized
(element size is provided by the pointer's target type). If expr is
omitted, only the pointer variable itself is privatized.
• Program behavior is undefined if expr evaluates to a non-positive
value, or if it exceeds the array size.
PARALLEL helps the compiler to resolve dependencies, facilitating auto-parallelization of the immediately
following DO loop. It instructs the compiler to ignore dependencies that it assumes may exist and which
would prevent correct parallelization in the loop. However, if dependencies are proven, they are not ignored.
In addition, PARALLEL ALWAYS overrides the compiler heuristics that estimate the likelihood that
parallelization of a loop will increase performance. It allows a loop to be parallelized even if the compiler
thinks parallelization may not improve performance. If the ASSERT keyword is added, the compiler will
generate an error-level assertion message saying that the compiler analysis and cost model indicate that the
loop cannot be parallelized.
NOPARALLEL prevents auto-parallelization of the immediately following DO loop.
These directives take effect only if you specify the compiler option that enables auto-parallelization.
1872
Language Reference
Caution
The directive PARALLEL ALWAYS should be used with care. Overriding the heuristics of the compiler
should only be done if you are absolutely sure the parallelization will improve performance.
Example
program main
parameter (n=100)
integer x(n), a(n), k
!DIR$ NOPARALLEL
do i=1,n
x(i) = i
enddo
!DIR$ PARALLEL LASTPRIVATE (k)
do i=1,n
a( x(i) ) = i
k = x(i)
enddo
print *, k ! print 100, the value of x(n)
end
See Also
General Compiler Directives
PARALLEL DO
OpenMP* Fortran Compiler Directive: Provides an
abbreviated way to specify a parallel region containing
a single DO directive.
Syntax
!$OMP PARALLEL DO [clause[[,] clause] ... ]
do-loop
[!$OMP END PARALLEL DO]
If the END PARALLEL DO directive is not specified, the PARALLEL DO is assumed to end with the DO loop that
immediately follows the PARALLEL DO directive. If used, the END PARALLEL DO directive must appear
immediately after the end of the DO loop.
The semantics are identical to explicitly specifying a PARALLEL directive immediately followed by a DO
directive.
1873
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
In the following example, the loop iteration variable is private by default and it is not necessary to explicitly
declare it. The END PARALLEL DO directive is optional:
!$OMP PARALLEL DO
DO I=1,N
B(I) = (A(I) + A(I-1)) / 2.0
END DO
!$OMP END PARALLEL DO
The following example shows how to use the REDUCTION clause in a PARALLEL DO directive:
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
PARALLEL DO SIMD
OpenMP* Fortran Compiler Directive: Specifies a
PARALLEL construct that contains one DO SIMD
construct and no other statement.
Syntax
!$OMP PARALLEL DO SIMD [clause[[,] clause] ... ]
do-loop
[!$OMP END PARALLEL DO SIMD]
clause Can be any of the clauses accepted by the PARALLEL, DO, or SIMD
directives.
If the END PARALLEL DO SIMD directive is not specified, an END PARALLEL DO SIMD directive is assumed at
the end of do-loop.
You cannot specify NOWAIT in a PARALLEL DO SIMD directive.
1874
Language Reference
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
PARALLEL LOOP
OpenMP* Fortran Compiler Directive: Specifies a
shortcut for indicating that a loop or loop nest can
execute concurrently across multiple threads. This
feature is only available for ifx.
Syntax
!$OMP PARALLEL LOOP [clause[[,] clause]... ]
do-loop
[!$OMP END PARALLEL LOOP]
do-loop Is a DO loop that may contain other nested DO loops. The DO loops
must all be in canonical form. The DO loop iteration variable must be
of type integer.
This combined directive is semantically equivalent to a LOOP construct that immediately follows a PARALLEL
directive. All restrictions for PARALLEL and LOOP constructs apply to this combined construct.
If used, the END PARALLEL LOOP directive must appear immediately after the end of the loop. If you do not
specify an END PARALLEL LOOP directive, an END PARALLEL LOOP directive is assumed at the end of the do-
loop.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
PARALLEL construct
LOOP construct
PARALLEL MASKED
OpenMP* Fortran Compiler Directive: Creates a
PARALLEL construct containing a MASKED construct,
with no Fortran statements in the PARALLEL construct
which are not also in the MASKED construct. This
feature is only available for ifx.
Syntax
!$OMP PARALLEL MASKED [clause[[,] clause]... ]
block
!$OMP END PARALLEL MASKED
1875
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
This combined directive provides a shortcut for specifying a PARALLEL construct with a MASKED construct
nested inside of it. The semantics are identical to a MASKED construct specified immediately after a
PARALLEL construct; the only Fortran statements in the construct are inside the block.
All restrictions for PARALLEL and MASKED constructs apply to this combined construct.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
PARALLEL directive
MASKED directive
Syntax
!$OMP PARALLEL MASKED TASKLOOP [clause[[,] clause]... ]
loop-nest
[!$OMP END PARALLEL MASKED TASKLOOP]
This combined directive provides a shortcut for specifying a PARALLEL construct with a MASKED TASKLOOP
construct nested inside of it. The semantics are identical to a MASKED TASKLOOP construct specified
immediately after a PARALLEL construct.
All restrictions for PARALLEL and MASKED TASKLOOP constructs apply to this combined construct.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
PARALLEL directive
MASKED TASKLOOP directive
To learn more about canonical form loops, see the OpenMP* specification https://www.openmp.org/
specifications/
Syntax
!$OMP PARALLEL MASKED TASKLOOP SIMD [clause[[,] clause]... ]
1876
Language Reference
loop-nest
[!$OMP END PARALLEL MASKED TASKLOOP SIMD]
This combined directive provides a shortcut for specifying a PARALLEL construct with a MASKED TASKLOOP
SIMD construct nested inside of it. The semantics are identical to a MASKED TASKLOOP SIMD construct
specified immediately after a PARALLEL construct.
All restrictions for PARALLEL and MASKED TASKLOOP SIMD constructs apply to this combined construct.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
PARALLEL directive
MASKED TASKLOOP SIMD directive
To learn more about canonical form loops, see the OpenMP* specification https://www.openmp.org/
specifications/
PARALLEL MASTER
OpenMP* Fortran Compiler Directive:
(Deprecated; see PARALLEL MASKED) Creates a
PARALLEL construct containing a MASTER construct,
with no Fortran statements in the PARALLEL construct
that are not also in the MASTER construct. This
feature is only available for ifx.
Syntax
!$OMP PARALLEL MASTER [clause[[,] clause]... ]
block
!$OMP END PARALLEL MASTER
This combined directive provides a shortcut for specifying a PARALLEL construct with a MASTER construct
nested inside of it. The semantics are identical to a MASTER construct specified immediately after a
PARALLEL construct; the only Fortran statements in the construct are inside block.
All restrictions for PARALLEL and MASTER constructs apply to this combined construct.
The PARALLEL MASTER directive is deprecated; you should use the PARALLEL MASKED directive.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
PARALLEL directive
MASTER directive
1877
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
!$OMP PARALLEL MASTER TASKLOOP [clause[[,] clause]... ]
loop-nest
[!$OMP END PARALLEL MASTER TASKLOOP]
This combined directive provides a shortcut for specifying a PARALLEL construct with a MASTER TASKLOOP
construct nested inside of it. The semantics are identical to a MASTER TASKLOOP construct specified
immediately after a PARALLEL construct.
All restrictions for PARALLEL and MASTER TASKLOOP constructs apply to this combined construct.
The PARALLEL MASTER TASKLOOP directive is deprecated; you should use the PARALLEL MASKED TASKLOOP
directive.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
PARALLEL directive
MASTER TASKLOOP directive
To learn more about canonical form loops, see the OpenMP* specification https://www.openmp.org/
specifications/
Syntax
!$OMP PARALLEL MASTER TASKLOOP SIMD [clause[[,] clause]... ]
loop-nest
[!$OMP END PARALLEL MASTER TASKLOOP SIMD]
1878
Language Reference
This combined directive provides a shortcut for specifying a PARALLEL construct with a MASTER TASKLOOP
SIMD construct nested inside of it. The semantics are identical to a MASTER TASKLOOP SIMD construct
specified immediately after a PARALLEL construct.
All restrictions for PARALLEL and MASTER TASKLOOP SIMD constructs apply to this combined construct.
The PARALLEL MASTER TASKLOOP SIMD directive is deprecated; you should use the PARALLEL MASKED
TASKLOOP SIMD directive.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
PARALLEL directive
MASTER TASKLOOP SIMD directive
To learn more about canonical form loops, see the OpenMP* specification https://www.openmp.org/
specifications/
PARALLEL SECTIONS
OpenMP* Fortran Compiler Directive: Provides an
abbreviated way to specify a parallel region containing
a single SECTIONS directive. The semantics are
identical to explicitly specifying a PARALLEL directive
immediately followed by a SECTIONS directive.
Syntax
!$OMP PARALLEL SECTIONS [clause[[,] clause] ...]
[!$OMP SECTION]
block
[!$OMP SECTION
block]...
!$OMP END PARALLEL SECTIONS
Example
In the following example, subroutines XAXIS, YAXIS, and ZAXIS can be executed concurrently:
1879
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
PARALLEL WORKSHARE
OpenMP* Fortran Compiler Directive: Provides an
abbreviated way to specify a parallel region containing
a single WORKSHARE directive.
Syntax
!$OMP PARALLEL WORKSHARE [clause[[,] clause] ... ]
block
!$OMP END PARALLEL WORKSHARE
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
PARAMETER
Statement and Attribute: Defines a named
constant.
Syntax
The PARAMETER attribute can be specified in a type declaration statement or a PARAMETER statement, and
takes one of the following forms:
Type Declaration Statement:
type, [att-ls,] PARAMETER [, att-ls] :: c =expr[, c = expr] ...
Statement:
PARAMETER [( ]c= expr[, c= expr] ... [) ]
Description
The type, type parameters, and shape of the named constant are determined in one of the following ways:
• By an explicit type declaration statement in the same scoping unit.
• By the implicit typing rules in effect for the scoping unit. If the named constant is implicitly typed, it can
appear in a subsequent type declaration only if that declaration confirms the implicit typing.
For example, consider the following statement:
PARAMETER (MU=1.23)
1880
Language Reference
According to implicit typing, MU is of integer type, so MU=1. For MU to equal 1.23, it should previously be
declared REAL in a type declaration or be declared in an IMPLICIT statement.
A named array constant defined by a PARAMETER statement must have its rank specified in a previous
specification statement.
A named constant must not appear in a format specification or as the character count for Hollerith constants.
For compilation purposes, writing the name is the same as writing the value.
If the named constant is used as the length specifier in a CHARACTER declaration, it must be enclosed in
parentheses.
The name of a constant cannot appear as part of another constant, although it can appear as either the real
or imaginary part of a complex constant.
You can only use the named constant within the scoping unit containing the defining PARAMETER statement.
Any named constant that appears in the constant expression must have been defined previously in the same
type declaration statement (or in a previous type declaration statement or PARAMETER statement), or made
accessible by use or host association.
An entity with the PARAMETER attribute must not be a variable, a coarray, or a procedure.
Omission of the parentheses in a PARAMETER statement is an extension controlled by compiler option
altparam. In this form, the type of the name is taken from the form of the constant rather than from implicit
or explicit typing of the name.
Example
The following example shows a type declaration statement specifying the PARAMETER attribute:
1881
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
!
! PARAMETER in attribute syntax
REAL, PARAMETER :: mass=47.3, pi=3.14159, loads=10.0, mass=32.2
See Also
DATA
Type Declarations
Compatible attributes
Constant Expressions
IMPLICIT
Alternative syntax for the PARAMETER statement
altparam compiler option
PARITY
Transformational Intrinsic Function (Generic):
Reduces an array by using an exclusive OR (.NEQV.)
operation.
Syntax
result = PARITY (mask)
result = PARITY (mask, dim)
dim (Input) Must be a scalar integer with a value in the range 1 <= dim
<= n, where n is the rank of mask.
Results
The result has the same type and kind parameters as mask. It is scalar if dim is not specified; otherwise, the
result has rank n - 1 and shape [d1, d2, ..., ddim-1, ddim+1 , ..., dn] where [d1, d2,..., dn] is the shape of mask.
The result of PARITY(mask) has the value .TRUE. if an odd number of the elements of mask are true;
otherwise, .FALSE..
If mask has rank one, PARITY(mask, dim) is equal to PARITY(mask). Otherwise, the value of element (s1,
s2, ..., sdim-1, sdim+1 , ..., sn) of PARITY(mask, dim) is equal to PARITY (mask (s1, s2, ..., sdim-1 , :, sdim+1 , ...,
sn)).
Example
If A is the array
[ T F T ]
[ T T F ]
and T has the value .TRUE. and F has the value .FALSE., then
PARITY (A, DIM=1) has the value [F, T, T] and PARITY (A, DIM=2) has the value [F, F].
PASSDIRKEYSQQ (W*S)
QuickWin Function: Determines the behavior of
direction and page keys in a QuickWin application.
Module
USE IFQWIN
1882
Language Reference
Syntax
result = PASSDIRKEYSQQ (val)
Results
The return value indicates the previous setting of the PassDirKeys flag.
The return data type is the same as the data type of val; that is, either INTEGER(4) or LOGICAL(4).
When the PassDirKeys flag is turned on, the mouse must be used for scrolling since the direction and page
keys are treated as normal input characters.
The PASSDIRKEYSQQ function is meant to be used primarily with the GETCHARQQ and INCHARQQ functions.
Do not use normal input statements (such as READ) with the PassDirKeys flag turned on, unless your
program is prepared to interpret direction and page keys.
Example
use IFQWIN
logical*4 res
character*1 ch, ch1
123 continue
ch = getcharqq( )
! check for escapes
! 0x00 0x?? is a function key
! 0xE0 0x?? is a direction key
if (ichar(ch) .eq. 0) then
ch1 = getcharqq()
print *,"function key follows escape = ",ichar(ch), " ",ichar(ch1)," ",ch1
goto 123
else if (ichar(ch) .eq. 224) then
1883
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
ch1 = getcharqq()
print *,"direction key follows escape = ",ichar(ch)," ",ichar(ch1)," ",ch1
goto 123
else
print *,ichar(ch)," ",ch
endif
end
The following example uses an integer constant as an argument to PASSDIRKEYSQQ:
c=======================================================================
c
c dirkeys4.for
c
c=======================================================================
c
c Compile/Load Input Line for Standard Graphics Full Screen Window
c
c ifort /libs:qwins dirkeys4.for
c
c Compile/Load Input Line for QuickWin Graphics
c
c ifort /libs:qwin dirkeys4.for
c
c Program to illustrate how to get almost every character
c from the keyboard in QuickWin or Standard Graphics mode.
c Comment out the deletemenu line for Standard Graphics mode.
c
c If you are doing a standard graphics application,
c control C will come in as a Z'03' without furtherc effort.
c
c In a QuickWin application, The File menu Exit item must
c be deleted, and PassDirKeysQQ called with PASS_DIR_CNTRLC
c to get control C.
c
c=======================================================================
use IFQWIN
integer(4) status
character*1 key1,key2,ch1
write(*,*) 'Initializing'
1884
Language Reference
10 key1 = getcharqq()
See Also
GETCHARQQ
INCHARQQ
PAUSE
Statement: Temporarily suspends program execution
and lets you execute operating system commands
during the suspension. The PAUSE statement is a
deleted feature in the Fortran Standard. Intel® Fortran
fully supports features deleted in the Fortran
Standard.
Syntax
PAUSE [pause-code]
1885
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If you specify pause-code, the PAUSE statement displays the specified message and then displays the default
prompt.
If you do not specify pause-code, the system displays the following default message:
FORTRAN PAUSE
The following prompt is then displayed:
• On Windows* systems:
PAUSE prompt>
For alternate methods of pausing while reading from and writing to a device, see READ and WRITE.
Effect on Windows* Systems
The program waits for input on stdin. If you enter a blank line, execution resumes at the next executable
statement.
Anything else is treated as a DOS command and is executed by a system( ) call. The program loops, letting
you execute multiple DOS commands, until a blank line is entered. Execution then resumes at the next
executable statement.
Effect on Linux* and macOS* Systems
The effect of PAUSE differs depending on whether the program is a foreground or background process, as
follows:
• If a program is a foreground process, the program is suspended until you enter the CONTINUE command.
Execution then resumes at the next executable statement.
Any other command terminates execution.
• If a program is a background process, the behavior depends on stdin, as follows:
• If stdinis redirected from a file, the system displays the following (after the pause code and prompt):
Example
The following examples show valid PAUSE statements:
PAUSE 701
PAUSE 'ERRONEOUS RESULT DETECTED'
The following shows another example:
CHARACTER*24 filename
PAUSE 'Enter DIR to see available files or press RETURN' &
&' if you already know filename.'
1886
Language Reference
READ(*,'(A\)') filename
OPEN(1, FILE=filename)
. . .
See Also
STOP
SYSTEM
Deleted and Obsolescent Language Features
PEEKCHARQQ
Run-Time Function: Checks the keystroke buffer for
a recent console keystroke and returns .TRUE. if there
is a character in the buffer or .FALSE. if there is not.
Module
USE IFCORE
Syntax
result = PEEKCHARQQ( )
Results
The result type is LOGICAL(4). The result is .TRUE. if there is a character waiting in the keyboard buffer;
otherwise, .FALSE..
To find out the value of the key in the buffer, call GETCHARQQ. If there is no character waiting in the buffer
when you call GETCHARQQ, GETCHARQQ waits until there is a character in the buffer. If you call
PEEKCHARQQ first, you prevent GETCHARQQ from halting your process while it waits for a keystroke. If there
is a keystroke, GETCHARQQ returns it and resets PEEKCHARQQ to .FALSE..
Example
USE IFCORE
LOGICAL(4) pressed / .FALSE. /
DO WHILE (.NOT. pressed)
WRITE(*,*) ' Press any key'
pressed = PEEKCHARQQ ( )
END DO
END
See Also
GETCHARQQ
GETSTRQQ
FGETC
GETC
PERROR
Run-Time Subroutine: Sends a message to the
standard error stream, preceded by a specified string,
for the last detected error.
Module
USE IFCORE
1887
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
CALL PERROR (string)
Example
USE IFCORE
character*24 errtext
errtext = 'In my opinion, '
. . .
! any error message generated by errtext is
! preceded by 'In my opinion, '
Call PERROR (errtext)
See Also
GERROR
IERRNO
Module
USE IFQWIN
Syntax
result = PIE (i,x1,y1,x2,y2,x3,y3,x4,y4)
result = PIE_W (i, wx1, wy1, wx2, wy2, wx3, y3,wx4, wy4)
• $GFILLINTERIOR - Fills the figure using the current color and fill
mask.
• $GBORDER - Does not fill the figure.
1888
Language Reference
Results
The result type is INTEGER(2). The result is nonzero if successful; otherwise, 0. If the pie is clipped or
partially out of bounds, the pie is considered successfully drawn and the return is 1. If the pie is drawn
completely out of bounds, the return is 0.
The border of the pie wedge is drawn in the current color set by SETCOLORRGB.
The PIE function uses the viewport-coordinate system. The center of the arc is the center of the bounding
rectangle, which is specified by the viewport-coordinate points (x1, y1) and ( x2, y2). The arc starts where it
intersects an imaginary line extending from the center of the arc through ( x3, y3). It is drawn
counterclockwise about the center of the arc, ending where it intersects an imaginary line extending from the
center of the arc through (x4, y4).
The PIE_W function uses the window-coordinate system. The center of the arc is the center of the bounding
rectangle specified by the window-coordinate points (wx1, wy1) and ( wx2, wy2). The arc starts where it
intersects an imaginary line extending from the center of the arc through ( wx3, wy3). It is drawn
counterclockwise about the center of the arc, ending where it intersects an imaginary line extending from the
center of the arc through ( wx4, wy4).
The fill flag option $GFILLINTERIOR is equivalent to a subsequent call to FLOODFILLRGB using the center of
the pie as the starting point and the current graphics color (set by SETCOLORRGB) as the fill color. If you
want a fill color different from the boundary color, you cannot use the $GFILLINTERIOR option. Instead, after
you have drawn the pie wedge, change the current color with SETCOLORRGB and then call FLOODFILLRGB.
You must supply FLOODFILLRGB with an interior point in the figure you want to fill. You can get this point for
the last drawn pie or arc by calling GETARCINFO.
If you fill the pie with FLOODFILLRGB, the pie must be bordered by a solid line style. Line style is solid by
default and can be changed with SETLINESTYLE.
NOTE
The PIE routine described here is a QuickWin routine. If you are trying to use the Microsoft*
Platform SDK version of the Pie routine by including the IFWIN module, you need to specify
the routine name as MSFWIN$Pie.
Example
! build as Graphics App.
USE IFQWIN
INTEGER(2) status, dummy
INTEGER(2) x1, y1, x2, y2, x3, y3, x4, y4
x1 = 80; y1 = 50
x2 = 180; y2 = 150
x3 = 110; y3 = 80
x4 = 90; y4 = 180
status = SETCOLOR(INT2(4))
dummy = PIE( $GFILLINTERIOR, x1, y1, x2, y2, &
x3, y3, x4, y4)
END
This figure shows the coordinates used to define PIE and PIE_W:
1889
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
SETCOLORRGB
SETFILLMASK
SETLINESTYLE
FLOODFILLRGB
GETARCINFO
ARC
ELLIPSE
GRSTATUS
LINETO
POLYGON
RECTANGLE
POINTER - Fortran
Statement and Attribute: Specifies that an object or
a procedure is a pointer (a dynamic variable). A
pointer does not contain data, but points to a scalar or
array variable where data is stored. A pointer has no
initial storage set aside for it; memory storage is
created for the pointer as a program runs.
Syntax
The POINTER attribute can be specified in a type declaration statement or a POINTER statement, and takes
one of the following forms:
Type Declaration Statement:
type,[att-ls,] POINTER [, att-ls] :: ptr[(d-spec)][ , ptr[(d-spec)]]...
Statement:
POINTER [::]ptr[(d-spec)][ , ptr[(d-spec)]] ...
ptr Is the name of the pointer. The pointer cannot be declared with the
INTENT or PARAMETER attributes.
Description
No storage space is created for a data pointer until it is allocated with an ALLOCATE statement or until it is
assigned to a allocated target.
1890
Language Reference
Each pointer has an association status, which tells whether the pointer is currently associated with a target
object. When a pointer is initially declared, its status is undefined. You can use the ASSOCIATED intrinsic
function to find the association status of a pointer if the pointer's association status is defined.
Entities with the POINTER attribute can be associated with different data objects or procedures during
execution of a program.
A data pointer must not be referenced or defined unless it is pointer associated with a target object that can
be referenced or defined. A procedure pointer must not be referenced unless it is pointer associated with a
target procedure.
If the data pointer is an array, and it is given the DIMENSION attribute elsewhere in the program, it must be
declared as a deferred-shape array.
A pointer cannot be specified in an EQUIVALENCE or NAMELIST statement. A pointer in a DATA statement
can only be associated with NULL().
A procedure that has both the EXTERNAL and POINTER attributes is a procedure pointer.
An entity with the POINTER attribute must not have the ALLOCATABLE, INTRINSIC, or TARGET attribute, and
it must not be a coarray.
Fortran pointers are not the same as integer pointers. For more information, see the POINTER - Integer
statement.
Example
The following example shows type declaration statements specifying the POINTER attribute:
TYPE(SYSTEM) :: TODAYS
POINTER :: TODAYS, A(:,:)
The following shows another example:
1891
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
WRITE (*,'(/1x,a)') 'ARROW is repointed & resized, all the 5s are lost'
WRITE (*,'(1x,8f8.0)') arrow
NULLIFY (arrow)
IF (.NOT.ASSOCIATED(arrow)) WRITE (*,'(/a/)') ' ARROW is not pointed'
See Also
ALLOCATE
ASSOCIATED
DEALLOCATE
NULLIFY
TARGET
Deferred-Shape Arrays
Pointer Assignments
Pointer Association
Pointer Arguments
NULL
Integer POINTER statement
Type Declarations
Compatible attributes
POINTER - Integer
Statement: Establishes pairs of objects and pointers,
in which each pointer contains the address of its
paired object. This statement is different from the
Fortran POINTER statement.
Syntax
POINTER (pointer,pointee) [,(pointer,pointee)] . . .
1892
Language Reference
• Integers can be converted to pointers, so you can point to absolute memory locations.
• A pointer variable cannot be declared to have any other data type.
• A pointer cannot be a function return value.
• You can give values to pointers by doing the following:
• Retrieve addresses by using the LOC intrinsic function (or the %LOC built-in function)
• Allocate storage for an object by using the MALLOC intrinsic function (or by using malloc(3f) on Linux*
and macOS* systems)
For example:
INTENT POINTER
• A pointee cannot be:
• A dummy argument
• A function return value
• A record field or an array element
• Zero-sized
• An automatic object
• The name of a generic interface block
• If a pointee is of derived type, it must be of sequence type.
Example
POINTER (p, k)
INTEGER j(2)
See Also
POINTER - Fortran
LOC
1893
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
MALLOC
FREE
Module
USE IFQWIN
Syntax
result = POLYBEZIER (lppoints,cpoints)
result = POLYBEZIER_W (lppoints,cpoints)
lppoints (Input) Derived type xycoord. Array of derived types defining the
endpoints and the control points for each Bezier curve. The derived
type xycoord is defined in IFQWIN.F90 as follows:
TYPE xycoord
INTEGER(2) xcoord
INTEGER(2) ycoord
END TYPE xycoord
Results
The result type is INTEGER(2). The result is nonzero if anything is drawn; otherwise, 0.
A Bezier curve is based on fitting a cubic curve to four points. The first point is the starting point, the next
two points are control points, and last point is the ending point. The starting point must be given for the first
curve; subsequent curves use the ending point of the previous curve as their starting point. So, cpoints
should contain 4 for one curve, 7 for 2 curves, 10 for 3 curves, and so forth.
POLYBEZIER does not use or change the current graphics position.
Example
Program Bezier
use IFQWIN
! Shows how to use POLYBEZIER, POLYBEZIER_W,
! POLYBEZIERTO, and POLYBEZIERTO_W,
TYPE(xycoord) lppoints(31)
TYPE(wxycoord) wlppoints(31)
TYPE(xycoord) xy
TYPE(wxycoord) wxy
integer(4) i
integer(2) istat, orgx, orgy
real(8) worgx, worgy
i = setcolorrgb(Z'00FFFFFF') ! graphic to black
i = settextcolorrgb(Z'00FFFFFF') ! text to black
i = setbkcolorrgb(Z'00000000') ! background to white
call clearscreen($GCLEARSCREEN)
orgx = 20
orgy = 20
lppoints(1)%xcoord = 1+orgx
lppoints(1)%ycoord = 1+orgy
1894
Language Reference
lppoints(2)%xcoord = 30+orgx
lppoints(2)%ycoord = 120+orgy
lppoints(3)%xcoord = 150+orgx
lppoints(3)%ycoord = 60+orgy
lppoints(4)%xcoord = 180+orgx
lppoints(4)%ycoord = 180+orgy
istat = PolyBezier(lppoints, 4)
! Show tangent lines
! A bezier curve is tangent to the line
! from the begin point to the first control
! point. It is also tangent to the line from
! the second control point to the end point.
do i = 1,4,2
call moveto(lppoints(i)%xcoord,lppoints(i)%ycoord,xy)
istat = lineto(lppoints(i+1)%xcoord,lppoints(i+1)%ycoord)
end do
read(*,*)
worgx = 50.0
worgy = 50.0
wlppoints(1)%wx = 1.0+worgx
wlppoints(1)%wy = 1.0+worgy
wlppoints(2)%wx = 30.0+worgx
wlppoints(2)%wy = 120.0+worgy
wlppoints(3)%wx = 150.0+worgx
wlppoints(3)%wy = 60.0+worgy
wlppoints(4)%wx = 180.0+worgx
wlppoints(4)%wy = 180.0+worgy
i = setcolorrgb(Z'000000FF') ! graphic to red
istat = PolyBezier_W(wlppoints, 4)
! Show tangent lines
! A bezier curve is tangent to the line
! from the begin point to the first control
! point. It is also tangent to the line from
! the second control point to the end point.
do i = 1,4,2
call moveto_w(wlppoints(i)%wx,wlppoints(i)%wy,wxy)
istat = lineto_w(wlppoints(i+1)%wx,wlppoints(i+1)%wy)
end do
read(*,*)
orgx = 80
orgy = 80
! POLYBEZIERTO uses the current graphics position
! as its initial starting point so we start the
! array with the first first control point.
! lppoints(1)%xcoord = 1+orgx ! need to move to this
! lppoints(1)%ycoord = 1+orgy
lppoints(1)%xcoord = 30+orgx
lppoints(1)%ycoord = 120+orgy
lppoints(2)%xcoord = 150+orgx
lppoints(2)%ycoord = 60+orgy
lppoints(3)%xcoord = 180+orgx
lppoints(3)%ycoord = 180+orgy
i = setcolorrgb(Z'0000FF00') ! graphic to green
call moveto(1+orgx,1+orgy,xy)
istat = PolyBezierTo(lppoints, 3)
! Show tangent lines
! A bezier curve is tangent to the line
! from the begin point to the first control
1895
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
POLYBEZIERTO, POLYBEZIERTO_W
Module
USE IFQWIN
Syntax
result = POLYBEZIERTO (lppoints,cpoints)
result = POLYBEZIERTO_W (lppoints,cpoints)
lppoints (Input) Derived type xycoord. Array of derived types defining the
endpoints and the control points for each Bezier curve. The derived
type xycoord is defined in IFQWIN.F90 as follows:
TYPE xycoord
INTEGER(2) xcoord
INTEGER(2) ycoord
END TYPE xycoord
1896
Language Reference
Results
The result type is INTEGER(2). The result is nonzero if anything is drawn; otherwise, 0.
A Bezier curve is based on fitting a cubic curve to four points. The first point is the starting point, the next
two points are control points, and last point is the ending point. The starting point is the current graphics
position as set by MOVETO for the first curve; subsequent curves use the ending point of the previous curve
as their starting point. So, cpoints should contain 3 for one curve, 6 for 2 curves, 9 for 3 curves, and so
forth.
POLYBEZIERTO moves the current graphics position to the ending point of the last curve drawn.
Example
See the example in POLYBEZIER, POLYBEZIER_W (W*S).
See Also
POLYBEZIER, POLYBEZIER_W
MOVETO, MOVETO_W
Module
USE IFQWIN
Syntax
result = POLYGON (control,lppoints,cpoints)
result = POLYGON_W (control,lppoints,cpoints)
control (Input) INTEGER(2). Fill flag. One of the following symbolic constants
defined in IFQWIN.F90:
lppoints (Input) Derived type xycoord. Array of derived types defining the
polygon vertices in viewport coordinates. The derived type xycoord is
defined in IFQWIN.F90 as follows:
TYPE xycoord
INTEGER(2) xcoord
INTEGER(2) ycoord
END TYPE xycoord
Results
The result type is INTEGER(2). The result is nonzero if anything is drawn; otherwise, 0.
1897
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The border of the polygon is drawn in the current graphics color, logical write mode, and line style, set with
SETCOLORRGB, SETWRITEMODE, and SETLINESTYLE, respectively. The POLYGON routine uses the viewport-
coordinate system (expressed in xycoord derived types), and the POLYGON_W routine uses real-valued
window coordinates (expressed in xycoord types).
The argument lppoints is an array whose elements are xycoord derived types. Each element specifies one of
the polygon's vertices. The argument cpoints is the number of elements (the number of vertices) in the
lppoints array.
Note that POLYGON draws between the vertices in their order in the array. Therefore, when drawing outlines,
skeletal figures, or any other figure that is not filled, you need to be careful about the order of the vertices. If
you don't want lines between some vertices, you may need to repeat vertices to make the drawing backtrack
and go to another vertex to avoid drawing across your figure. Also, POLYGON draws a line from the last
specified vertex back to the first vertex.
If you fill the polygon using FLOODFILLRGB, the polygon must be bordered by a solid line style. Line style is
solid by default and can be changed with SETLINESTYLE.
NOTE
The POLYGON routine described here is a QuickWin routine. If you are trying to use the
Microsoft* Platform SDK version of the Polygon routine by including the IFWIN module, you
need to specify the routine name as MSFWIN$Polygon.
Example
! Build as a Graphics App.
poly(1)%xcoord = 50
poly(1)%ycoord = 80
poly(2)%xcoord = 85
poly(2)%ycoord = 35
poly(3)%xcoord = 185
poly(3)%ycoord = 35
poly(4)%xcoord = 150
poly(4)%ycoord = 80
poly(5)%xcoord = 50
poly(5)%ycoord = 80
poly(6)%xcoord = 50
poly(6)%ycoord = 180
poly(7)%xcoord = 150
poly(7)%ycoord = 180
poly(8)%xcoord = 185
poly(8)%ycoord = 135
poly(9)%xcoord = 185
poly(9)%ycoord = 35
poly(10)%xcoord = 150
poly(10)%ycoord = 80
poly(11)%xcoord = 150
poly(11)%ycoord = 180
1898
Language Reference
poly(12)%xcoord = 150
poly(12)%ycoord = 80
status = SETCOLORRGB(Z'0000FF')
status = POLYGON($GBORDER, poly, INT2(12))
END
See Also
SETCOLORRGB
SETFILLMASK
SETLINESTYLE
FLOODFILLRGB
GRSTATUS
LINETO
RECTANGLE
SETWRITEMODE
POLYLINEQQ (W*S)
Graphics Function: Draws a line between each
successive x, y point in a given array.
Module
USE IFQWIN
Syntax
result = POLYLINEQQ (points,cnt)
type DF_POINT
sequence
integer(4) x
integer(4) y
end type DF_POINT
Results
The result type is INTEGER(4). The result is a nonzero value if successful; otherwise, zero.
POLYLINEQQ uses the viewport-coordinate system.
The lines are drawn using the current graphics color, logical write mode, and line style. The graphics color is
set with SETCOLORRGB, the write mode with SETWRITEMODE, and the line style with SETLINESTYLE.
The current graphics position is not used or changed as it is in the LINETO function.
Example
! Build for QuickWin or Standard Graphics
USE IFQWIN
TYPE(DF_POINT) points(12)
integer(4) result
integer(4) cnt, i
1899
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
LINETO
LINETOAREX
SETCOLORRGB
SETLINESTYLE
SETWRITEMODE
POPCNT
Elemental Intrinsic Function (Generic): Returns
the number of 1 bits in the integer argument.
Syntax
result = POPCNT (i)
Results
The result type and kind are the same as i. The result value is the number of 1 bits in the binary
representation of the integer i.
The model for the interpretation of an integer value as a sequence of bits is shown in Model for Bit Data.
Example
If the value of I is B'0...00011010110', the value of POPCNT(I) is 5.
POPPAR
Elemental Intrinsic Function (Generic): Returns
the parity of the integer argument.
Syntax
result = POPPAR (i)
Results
The result type and kind are the same as i. The result value is 1 if there are an odd number of 1 bits in the
binary representation of the integer I. The result value is zero if there are an even number.
POPPAR( i) is the same as 1 .AND. POPCNT( i).
The model for the interpretation of an integer value as a sequence of bits is shown in Model for Bit Data.
1900
Language Reference
Example
If the value of I is B'0...00011010110', the value of POPPAR(I) is 1.
PRECISION
Inquiry Intrinsic Function (Generic): Returns the
decimal precision in the model representing real
numbers with the same kind parameter as the
argument.
Syntax
result = PRECISION (x)
Results
The result is a scalar of type default integer. The result has the value INT((DIGITS( x) - 1) *
LOG10(RADIX( x))). If RADIX( x) is an integral power of 10, 1 is added to the result.
Example
If X is a REAL(4) value, PRECISION(X) has the value 6. The value 6 is derived from INT ((24-1) * LOG10
(2.)) = INT (6.92...). For more information on the model for REAL(4), see Model for Real Data.
Syntax
!DIR$ PREFETCH [var1[: hint1[: distance1]] [,var2[: hint2[: distance2]]]...]
!DIR$ PREFETCH *: hint[: distance]
!DIR$ NOPREFETCH [var1[,var2]...]
1901
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
To use these directives, compiler option [q or Q]opt-prefetch must be set. Note that this option is turned
on by default if the compiler general optimization level is O2 or higher.
This directive affects the DO loop it precedes.
If you specify PREFETCH *, the hint and optional distance are used to prefetch all array accesses in the DO
loop.
If you specify NOPREFETCH with no arguments, the following occurs:
• All arrays accessed in the DO loop will NOT be prefetched.
• It negates all other PREFETCH directives for the following DO loop.
If a loop includes expression A(j), placing !DIR$ PREFETCH A:0:d in front of the loop instructs the compiler to
insert a vprefetch0 instruction for A within the loop that is d iterations ahead.
The PREFETCH directive takes precedence over the [q or Q]opt-prefetch-distance options.
Example
! Issue no prefetches for A1
! Issue vector prefetch from L2 and higher caches for B with a distance
! of 16 vectorized iterations ahead
! Issue vector prefetch from L1 and higher caches for B with a distance
! of 4 vectorized iterations ahead
!DIR$ NOPREFETCH A1
!DIR$ PREFETCH B:1:16
!DIR$ PREFETCH B:0:4
DO J = 1,N
A1(J) = B(J-1) + B(J+1)
END DO
In the following example, array A will be prefetched with hint 0 and distance 5, arrays B and C will be
prefetched with hint 1 and distance 10, and array D will not be prefetched:
See Also
General Compiler Directives
PRESENT
Inquiry Intrinsic Function (Generic): Returns
whether or not an optional dummy argument is
present, that is, whether it has an associated actual
argument.
1902
Language Reference
Syntax
result = PRESENT (a)
Results
The result is a scalar of type default logical. The result is .TRUE. if a is present; otherwise, the result
is .FALSE..
Example
Consider the following:
MODULE MYMOD
CONTAINS
SUBROUTINE CHECK (X, Y)
REAL X, Z
REAL, OPTIONAL :: Y
...
IF (PRESENT (Y)) THEN
Z = Y
ELSE
Z = X * 2
END IF
END SUBROUTINE CHECK
END MODULE MYMOD
...
USE MYMOD
CALL CHECK (15.0, 12.0) ! Causes Z to be set to 12.0
CALL CHECK (15.0) ! Causes Z to be set to 30.0
The following shows another example:
See Also
OPTIONAL
Optional Arguments
PRINT
Statement: Displays output on the screen. TYPE is a
synonym for PRINT. All forms and rules for the PRINT
statement also apply to the TYPE statement.
1903
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
The PRINT statement is the same as a formatted, sequential WRITE statement, except that the PRINT
statement must never transfer data to user-specified I/O units. You can override this restriction by using
environment variable FOR_PRINT.
A PRINT statement takes one of the following forms:
Formatted:
PRINT form[, io-list]
Formatted - List-Directed:
PRINT *[, io-list]
Formatted - Namelist:
PRINT nml
Example
In the following example, one record (containing four fields of data) is printed to the implicit output device:
See Also
PUTC
READ
WRITE
FORMAT
Data Transfer I/O Statements
File Operation I/O Statements
PRINT as a value in CLOSE
PRIORITY
Parallel Directive Clause: Specifies that the
generated tasks have the indicated priority for
execution.
Syntax
PRIORITY (priority-value)
1904
Language Reference
priority-value Provides a hint for the priority of task execution order. priority-value
must evaluate to a non-negative scalar integer value.
Among all tasks ready to be executed, higher priority tasks (those with a higher numerical value of priority-
value) are recommended to execute before lower priority tasks. A program that relies on task execution
order being determined by this priority-value may have unspecified behavior.
At most one PRIORITY clause can appear in the directive.
If this clause is not specified, tasks generated by the construct have a task priority of zero (the default).
PRIVATE Clause
Parallel Directive Clause: Declares one or more
variables to be private to each thread in a team.
Syntax
PRIVATE (list)
list Is the name of one or more variables or common blocks that are
accessible to the scoping unit. Subobjects cannot be specified. Each
name must be separated by a comma, and a named common block
must appear between slashes (/ /).
This clause allows each thread to have its own copy of the variable and makes it a local variable to the
thread.
The following occurs when variables are declared in a PRIVATE clause:
• A new object of the same type is declared once for each thread in the team (or for each implicit task in a
region) and it is used by each thread (or task) inside the scope of the directive construct instead of the
original variable. The new object is no longer storage associated with the original object.
• All references to the original object in the lexical extent of the directive construct are replaced with
references to the private object.
• Variables defined as PRIVATE are undefined for each thread upon entering the construct and the
corresponding shared variable is undefined when the parallel construct is exited. Within a parallel,
worksharing, or task region, the initial status of a private pointer is undefined.
The value and allocation status of the original variable will change only in the following cases:
• If it is accessed and modified by means of a pointer
• If it is accessed in the region but outside of the construct
• As a side effect of directives or clauses
• If accessed and modified via construct association.
If a variable has the ALLOCATABLE attribute, the following rules apply:
• If the variable is not currently allocated, the new list item will have an initial state of "unallocated".
• If the variable is allocated, the new list item will have an initial state of allocated with the same array
bounds.
A variable that appears in a PRIVATE clause may be storage-associated with other variables when the
PRIVATE clause is encountered by constructs such as EQUIVALENCE or COMMON. If A is a variable appearing
in a PRIVATE clause and B is a variable that is storage-associated with A, then the following applies:
• The contents, allocation, and association status of B are undefined on entry to the parallel or task region.
• Any definition of A, or any definition of its allocation or association status, causes the contents, allocation,
and association status of B to become undefined.
• Any definition of B, or any definition of its allocation or association status, causes the contents, allocation,
and association status of A to become undefined.
1905
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• A list item that appears in a private clause can be a selector in an ASSOCIATE construct. If the
ASSOCIATE construct association is established before entry to a parallel region, the association between
the associate name and the original PRIVATE list item will be retained in the parallel region.
The following are restrictions for the PRIVATE clause:
• A variable that is part of another variable (as an array or structure element) must not appear in a
PRIVATE clause.
• A variable that appears in a PRIVATE clause must either be definable or it must be an allocatable array.
This restriction does not apply to the FIRSTPRIVATE clause.
• Assumed-size arrays must not appear in a PRIVATE clause.
• A dummy argument that is a pointer with the INTENT (IN) attribute must not appear in a PRIVATE clause.
This restriction does not apply to the FIRSTPRIVATE clause.
• Variables that appear in NAMELIST statements, in variable format expressions, and in expressions for
statement function definitions, must not appear in a PRIVATE clause.
Variables in a list can appear in other clauses as follows:
• Variables that appear in a PRIVATE, FIRSTPRIVATE, or REDUCTION clause in a parallel construct can also
appear in a PRIVATE clause in an enclosed parallel, task, or worksharing construct.
• Variables that appear in a PRIVATE or FIRSTPRIVATE clause in a task construct can also appear in a
PRIVATE clause in an enclosed parallel or task construct.
• Variables that appear in a PRIVATE, FIRSTPRIVATE, LASTPRIVATE, or REDUCTION clause in a worksharing
construct can also appear in a PRIVATE clause in an enclosed parallel or task construct.
NOTE
Variables that are used as counters for explicit or implicit DO loops or FORALL commands, or common
blocks that are specified to be THREADPRIVATE become automatically private to each thread, even
though they are not explicitly included inside a PRIVATE clause at the beginning of the scope of the
parallel region.
Example
Consider the following:
PRIVATE Statement
Statement and Attribute: Specifies that entities in a
module can be accessed only within the module itself.
Syntax
The PRIVATE attribute can be specified in a type declaration statement or a PRIVATE statement, and takes
one of the following forms:
Type Declaration Statement:
type,[att-ls,] PRIVATE [, att-ls] :: entity[, entity]...
Statement:
PRIVATE [[::] entity[, entity] ...]
1906
Language Reference
Description
The PRIVATE attribute can only appear in the scoping unit of a module.
Only one PRIVATE statement without an entity list is permitted in the scoping unit of a module; it sets the
default accessibility of all entities in the module and any entities accessed from a module by USE association
whose names do not appear in a PUBLIC statement.
A module name can appear at most once in all the PUBLIC or PRIVATE statements in a scoping unit. If a
module name is specified in a PRIVATE statement, the module name must have appeared in a USE statement
within the same scoping unit.
A PRIVATE attribute can be specified on the TYPE statement of a derived-type definition in a module. This
specifies the derived-type definition is not accessible outside the module or the module's descendants.
A PRIVATE statement without an entity-list can appear in the component-definition part of a derived-type
definition, specifying the default accessibility of all components as PRIVATE. A PRIVATE statement with no
entity-list can appear in the type-bound-procedure-part of a derived-type definition specifying the default
accessibility of all type-bound procedures of that type as PRIVATE. In such cases, the default accessibility of
components and type-bound procedures can be overridden by explicitly declaring a component or type-
bound procedure PUBLIC.
A PRIVATE attribute can be specified in the statement declaring a component or a type-bound procedure of a
derived type. This specifies that the component or type-bound procedure is not accessible outside the
module or its descendants.
If no PRIVATE statements are specified in a module, the default is PUBLIC accessibility. Entities with PUBLIC
accessibility can be accessed from outside the module by means of a USE statement.
If a derived type is declared PRIVATE in a module, its components are also PRIVATE. The derived type and its
components are accessible to any subprograms within the defining module and the module's descendants
through host association, but they are not accessible from outside the module.
If the derived type is declared PUBLIC in a module, but its components are declared PRIVATE, any scoping
unit accessing the module though use association (or host association) can access the derived-type
definition, but not its components.
If a module procedure has a dummy argument or a function result of a type that has PRIVATE accessibility,
the module procedure must have PRIVATE accessibility. If the module has a generic identifier, it must also be
declared PRIVATE.
1907
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If a procedure has a generic identifier, the accessibility of the procedure's specific name is independent of the
accessibility of its generic identifier. One can be declared PRIVATE and the other PUBLIC.
The accessibility of the components of a type is independent of the accessibility of the type name. The
following combinations are possible:
The accessibility of a type does not affect, and is not affected by, the accessibility of its components and
type-bound procedures. If a type definition is private, then the type name, and thus the structure constructor
for the type, are accessible only within the module containing the definition.
Example
The following examples show type declaration statements specifying the PUBLIC and PRIVATE attributes:
REAL, PRIVATE :: A, B, C
INTEGER, PUBLIC :: LOCAL_SUMS
The following is an example of the PUBLIC and PRIVATE statements:
MODULE SOME_DATA
REAL ALL_B
PUBLIC ALL_B
TYPE RESTRICTED_DATA
REAL LOCAL_C(50)
END TYPE RESTRICTED_DATA
PRIVATE RESTRICTED_DATA
END MODULE
The following derived-type declaration statement indicates that the type is restricted to the module:
MODULE MATTER
TYPE ELEMENTS
PRIVATE
INTEGER C, D
END TYPE
...
END MODULE MATTER
In this case, components C and D are private to type ELEMENTS, but type ELEMENTS is not private to
MODULE MATTER. Any program unit that uses the module MATTER, can declare variables of type ELEMENTS,
and pass as arguments values of type ELEMENTS.
The following shows another example:
1908
Language Reference
REAL,INTENT(OUT) z
CALL SQUARE(x,y)
z = SQRT(x + y)
RETURN
END SUBROUTINE
SUBROUTINE SQUARE(x1,y1)
REAL x1,y1
x1 = x1**2
y1 = y1**2
RETURN
END SUBROUTINE
END MODULE
See Also
MODULE
PUBLIC
TYPE
Defining Generic Names for Procedures
USE
Use and Host Association
Type Declarations
Compatible attributes
PROCEDURE
Statement: Declares procedure pointers, dummy
procedures, and external procedures.
Syntax
PROCEDURE ([proc-interface]) [[, proc-attr-spec]... :: ] proc-decl-list
1909
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• OPTIONAL
• POINTER
• PROTECTED
• SAVE
Each proc-attr-spec gives the corresponding attribute to all
procedures declared in that statement.
If a procedure entity has the INTENT attribute or SAVE attribute, it
must also have the POINTER attribute.
Description
A PROCEDURE statement declares nonintrinsic procedures (procedure pointers, dummy procedures, internal
procedures, and external procedures). If the procedure is not a procedure pointer, a module procedure, or an
internal procedure, it specifies the EXTERNAL attribute for the procedure.
You cannot use the PROCEDURE statement to identify a BLOCK DATA subprogram.
If => null-init appears, it specifies that the initial association status of the corresponding procedure entity is
disassociated. It also implies the SAVE attribute.
You can also declare procedures by using an EXTERNAL statement or a procedure component definition
statement.
If the BIND attribute is specified for a procedure, each dummy argument must be:
If the BIND attribute is specified for a function, the function result must be an interoperable scalar variable.
A Fortran procedure is interoperable if it has the BIND attribute; that is, if its interface is specified with a
language-binding-spec.
The ALLOCATABLE or POINTER attribute must not be specified for a default-initialized dummy argument of a
procedure that has a BIND attribute.
A dummy argument of a procedure that has a BIND attribute must not have both the OPTIONAL and VALUE
attributes.
A variable that is a dummy argument of a procedure that has a BIND attribute must be of interoperable type
or assumed type.
When a procedure whose interface has the BIND attribute is called, any actual argument corresponding to a
dummy argument with the ALLOCATABLE or POINTER attribute is passed by C descriptor. Similarly, if a
Fortran procedure with a BIND attribute has such dummy arguments, they are received by C descriptor.
1910
Language Reference
Example
Consider the following:
PROCEDURE (INTEGER) X
INTEGER, EXTERNAL :: X
Consider the following:
ABSTRACT INTERFACE
FUNCTION SIM_FUNC (X)
REAL, INTENT (IN) :: X
REAL :: SIM_FUNC
END FUNCTION SIM_FUNC
END INTERFACE
INTERFACE
SUBROUTINE SUB2 (X)
REAL, INTENT (IN) :: X
END SUBROUTINE SUB2
END INTERFACE
The following shows external and dummy procedures with explicit interfaces:
TYPE MEMO_TYPE
PROCEDURE (SIM_FUNC), POINTER :: COMPONENT
END TYPE MEMO_TYPE
The following shows a variable of the above type:
See Also
Procedure Interfaces
Type-Bound Procedures
ABSTRACT INTERFACE
INTERFACE
EXTERNAL attribute
1911
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
PROCESSOR Clause
Parallel Directive Clause: Tells the compiler to
create a vector version of the routine for the specified
processor. When running on a processor that does not
match "cpuid", a scalar version will be invoked
multiple times based on vector length.
Syntax
PROCESSOR (cpuid)
se4
_2
ato Intel Atom® processors with Intel® Streaming
m_s SIMD Extensions 4.2 (Intel SSE4.2) with
®
o_s
se4
_1
cor Intel® Core™2 Duo processors with Intel®
e_2 Supplemental Streaming SIMD Extensions 3
_du (SSSE3)
o_s
sse
3
cor 2nd generation Intel® Core™ processor family
e_2 with support for Intel Advanced Vector
®
gen
_av
x
1912
Language Reference
7_s instructions
se4
_2
gen Other Intel processors for IA-32 or Intel® 64
eri architecture or compatible processors not
c provided by Intel Corporation
1913
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1914
Language Reference
vx5
12
The vector version of the routine that is created by the compiler is not affected by processor options specified
on the command line.
Multiple PROCESSOR clauses cause a syntax error.
See Also
DECLARE SIMD
ATTRIBUTES VECTOR
PRODUCT
Transformational Intrinsic Function (Generic):
Returns the product of all the elements in an entire
array or in a specified dimension of an array.
Syntax
result = PRODUCT (array [, mask])
result = PRODUCT (array, dim [, mask])
mask (Input; optional) Must be of type logical and conformable with array.
Results
The result is an array or a scalar of the same data type as array.
The result is a scalar if dim is not specified or array has rank one.
The following rules apply if dim is not specified:
• If PRODUCT(array) is specified, the result is the product of all elements of array. If array has size zero,
the result is 1.
• If PRODUCT(array, MASK= mask) is specified, the result is the product of all elements of array
corresponding to true elements of mask. If array has size zero, or every element of mask has the
value .FALSE., the result is 1.
The following rules apply if dim is specified:
• If array has rank one, the value is the same as PRODUCT(array[,MASK= mask]).
• An array result has a rank that is one less than array, and shape (d1, d2, ..., ddim-1, ddim+1, ..., dn), where
(d1, d2, ..., dn) is the shape of array.
• The value of element (s1, s2, ..., sdim-1, sdim+1, ..., sn) of PRODUCT(array, dim[, mask]) is equal to
PRODUCT(array(s1, s2, ..., sdim-1, :, sdim+1, ..., sn) [,MASK= mask(s1, s2, ..., sdim-1, :, sdim+1, ..., sn)]).
Example
PRODUCT ((/2, 3, 4/)) returns the value 24 (the product of 2 * 3 * 4). PRODUCT ((/2, 3, 4/), DIM=1)
returns the same result.
PRODUCT (C, MASK=C .LT. 0.0) returns the product of the negative elements of C.
1915
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
A is the array
[ 1 4 7 ]
[ 2 3 5 ].
PRODUCT (A, DIM=1) returns the value (2, 12, 35), which is the product of all elements in each column. 2 is
the product of 1 * 2 in column 1. 12 is the product of 4 * 3 in column 2, and so forth.
PRODUCT (A, DIM=2) returns the value (28, 30), which is the product of all elements in each row. 28 is the
product of 1 * 4 * 7 in row 1. 30 is the product of 2 * 3 * 5 in row 2.
If array has shape (2, 2, 2), mask is omitted, and dim is 1, the result is an array result with shape (2, 2)
whose elements have the following values.
See Also
SUM
PROGRAM
Statement: Identifies the program unit as a main
program and gives it a name.
Syntax
[PROGRAM name]
[specification-part]
[execution-part]
[CONTAINS
internal-subprogram-part]
END[PROGRAM [name]]
1916
Language Reference
Description
The PROGRAM statement is optional. Within a program unit, a PROGRAM statement can be preceded only by
comment lines or an OPTIONS statement.
The END statement is the only required part of a program. If a name follows the END statement, it must be
the same as the name specified in the PROGRAM statement.
The program name is considered global and must be unique. It cannot be the same as any local name in the
main program or the name of any other program unit, external procedure, or common block in the
executable program.
A main program must not reference itself (either directly or indirectly).
Example
The following is an example of a main program:
PROGRAM TEST
INTEGER C, D, E(20,20) ! Specification part
CALL SUB_1 ! Executable part
...
CONTAINS
SUBROUTINE SUB_1 ! Internal subprogram
...
END SUBROUTINE SUB_1
END PROGRAM TEST
The following shows another example:
PROGRAM MyProg
PRINT *, 'hello world'
END
PROTECTED
Statement and Attribute: Specifies limitations on
the use of module entities.
Syntax
The PROTECTED attribute can be specified in a type declaration statement or a PROTECTED statement, and
takes one of the following forms:
Type Declaration Statement:
type, [att-ls, ] PROTECTED [, att-ls] :: entity[, entity] ...
Statement:
PROTECTED [::]entity[, entity] ...
1917
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The PROTECTED attribute can only appear in the specification part of a module.
The PROTECTED attribute can only be specified for a procedure pointer or named variable that is not in a
common block.
A non-pointer object that has the PROTECTED attribute and is accessed by use association can not appear in
a variable definition or as the target in a pointer assignment statement.
A pointer object that has the PROTECTED attribute and is accessed by use association must not appear as
any of the following:
• A pointer-object in a NULLIFY statement
• A pointer-object in a pointer assignment statement
• An object in an ALLOCATE or DEALLOCATE statement
• An actual argument in a reference to a procedure if the associated dummy argument is a pointer with the
INTENT(OUT) or INTENT(INOUT) attribute.
The following restrictions apply outside of the module in which the entity has been given the PROTECTED
attribute:
• A non-pointer entity may not be defined or redefined.
• A pointer entity may not have its association status changed through the pointer.
• A data entity with the TARGET and the PROTECTED attribute that is USE associated may not appear in a
pointer initialization expression or a constructor if it corresponds to a pointer component.
Example
The following example shows a type declaration statement specifying the PROTECTED attribute:
INTEGER, PROTECTED :: D, E
Consider the following example:
MODULE counter_mod
INTEGER, PROTECTED :: current = 0
CONTAINS
PROGRAM test_counter
USE counter_mod
PRINT *, next( ) ! Prints 1
current = 42 ! Error: variable is protected
END PROGRAM test_counter
See Also
Modules and Module Procedures
Type Declarations
Compatible attributes
Pointer Assignments
1918
Language Reference
PSECT
General Compiler Directive: Modifies characteristics
of a common block.
Syntax
!DIR$ PSECT /common-name/ a[,a] ...
common-name Is the name of the common block. The slashes ( / ) are required.
BYTE 0
WORD 1
LONG 2
QUAD 3
OCTA 4
If one program unit changes one or more characteristics of a common block, all other units that reference
that common block must also change those characteristics in the same way.
The defaults are ALIGN=OCTA and WRT.
See Also
General Compiler Directives
PUBLIC
Statement and Attribute: Specifies that entities in a
module can be accessed from outside the module by
specifying a USE statement.
1919
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
The PUBLIC attribute can be specified in a type declaration statement or a PUBLIC statement, and takes one
of the following forms:
Type Declaration Statement:
type,[att-ls,] PUBLIC [, att-ls] :: entity [, entity]...
Statement:
PUBLIC [[::] entity [, entity] ...]
Description
The PUBLIC attribute can only appear in the scoping unit of a module.
Only one PUBLIC statement without an entity list is permitted in the scoping unit of a module; it sets the
default accessibility of all entities in the module and any entities accessed from a module by use association.
If no PRIVATE statements are specified in a module, the default is PUBLIC accessibility for all entities in the
module and entities accessible from other modules by use association.
A module name can appear at most once in all the PUBLIC or PRIVATE statements in a scoping unit. If a
module name is specified in a PUBLIC statement, the module name must have appeared in a USE statement
within the same scoping unit.
A PUBLIC attribute can be specified on the TYPE statement of a derived-type definition in a module. This
specifies that the derived-type definition is accessible by USE association where the module is used.
A PUBLIC attribute can be specified in the statement declaring a component or a type-bound procedure of a
derived type. This specifies that the component or type-bound procedure is accessible by USE association
where the module is used, even if the default accessibility of the components and type-bound procedures of
the derived type has been set to PRIVATE in the definition of the derived type.
If a derived type is declared PUBLIC in a module, but its components are declared PRIVATE, any scoping unit
accessing the module though use association (or host association) can access the derived-type definition, but
not its components.
If a module procedure has a dummy argument or a function result of a type that has PRIVATE accessibility,
the module procedure must have PRIVATE accessibility. If the module procedure has a generic identifier, it
must also be declared PRIVATE.
1920
Language Reference
If a procedure has a generic identifier, the accessibility of the procedure's specific name is independent of the
accessibility of its generic identifier. One can be declared PRIVATE and the other PUBLIC.
The accessibility of the components of a type is independent of the accessibility of the type name. The
following combinations are possible:
The accessibility of a type does not affect, and is not affected by, the accessibility of its components and
type-bound procedures. If a type definition is private, then the type name, and thus the structure constructor
for the type, are accessible only within the module containing the derived-type definition or in the module's
descendants.
Example
The following examples show type declaration statements specifying the PUBLIC and PRIVATE attributes:
REAL, PRIVATE :: A, B, C
INTEGER, PUBLIC :: LOCAL_SUMS
The following is an example of the PUBLIC and PRIVATE statements:
MODULE SOME_DATA
REAL ALL_B
PUBLIC ALL_B
TYPE RESTRICTED_DATA
REAL LOCAL_C(50)
END TYPE RESTRICTED_DATA
PRIVATE RESTRICTED_DATA
END MODULE
The following example shows a PUBLIC type with PRIVATE components:
MODULE MATTER
TYPE ELEMENTS
PRIVATE
INTEGER C, D
END TYPE
...
END MODULE MATTER
In this case, components C and D are private to type ELEMENTS, but type ELEMENTS is not private to
MODULE MATTER. Any program unit that uses the module MATTER, can declare variables of type ELEMENTS,
and pass as arguments values of type ELEMENTS.
The following shows another example:
1921
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
END SUBROUTINE
SUBROUTINE SQUARE(x1,y1)
REAL x1,y1
x1 = x1**2
y1 = y1**2
RETURN
END SUBROUTINE
END MODULE
See Also
PRIVATE
MODULE
TYPE
Defining Generic Names for Procedures
USE
Use and Host Association
Type Declarations
Compatible attributes
PURE
Keyword: Asserts that a user-defined procedure has
no side effects.
Description
This kind of procedure is specified by using the prefix PURE or the prefix ELEMENTAL without the prefix
IMPURE in a FUNCTION or SUBROUTINE statement.
A pure procedure has no side effects. It has no effect on the state of the program, except for the following:
• For functions: It returns a value.
• For subroutines: It modifies INTENT(OUT) and INTENT(INOUT) parameters.
The following intrinsic and library procedures are implicitly pure:
• All intrinsic functions
• The elemental intrinsic subroutine MVBITS
• The intrinsic subroutine MOVE_ALLOC
• Intrinsic module procedures that are specified to be pure
A dummy argument or a procedure pointer may be specified to be pure. A type-bound procedure that is
bound to a pure procedure is also pure.
A statement function is pure only if all functions that it references are pure and its definition does not
reference any data object with the VOLATILE attribute.
Except for procedure arguments and pointer arguments, the following intent must be specified in the
specification part of the procedure for all dummy arguments:
• For functions: INTENT(IN) or the VALUE attribute
• For subroutines: any INTENT (IN, OUT, or INOUT) or the VALUE attribute
A local variable declared in a pure procedure (including variables declared in any internal procedure) must
not:
• Specify the SAVE attribute
• Specify the VOLATILE attribute
• Be initialized in a type declaration statement or a DATA statement
The following variables have restricted use in pure procedures (and any internal procedures):
1922
Language Reference
• Global variables
• Dummy arguments with INTENT(IN)
• Dummy arguments with no declared intent that do not have the VALUE attribute
• Objects that are storage associated with any part of a global variable
They must not be used in any context that does either of the following:
• Causes their value to change. For example, they must not be used as:
• The left side of an assignment statement or pointer assignment statement
• An actual argument associated with a dummy argument with INTENT(OUT), INTENT(INOUT), or the
POINTER attribute
• An index variable in a DO or FORALL statement, or an implied-DO clause
• The variable in an ASSIGN statement
• An input item in a READ statement
• An internal file unit in a WRITE statement
• An object in an ALLOCATE, DEALLOCATE, or NULLIFY statement
• An IOSTAT or SIZE specifier in an I/O statement, the STAT specifier in a ALLOCATE, DEALLOCATE, or
image control statement, or as the STAT argument to the intrinsic MOVE_ALLOC or a collective or
atomic intrinsic subroutine.
• Creates a pointer to that variable. For example, they must not be used as:
• The target in a pointer assignment statement
• The right side of an assignment to a derived-type variable (including a pointer to a derived type) if the
derived type has a pointer component at any level
• The actual argument to the C_LOC function defined in the intrinsic module ISO_C_BINDING
A pure procedure must not contain the following:
• Any external I/O statement (including a READ or WRITE statement whose I/O unit is an external file unit
number or *)
• A PAUSE statement
• A STOP statement
• An image control statement
• An OpenMP* directive
A pure procedure can be used in contexts where other procedures are restricted; for example:
• It can be called directly in a FORALL statement or be used in the mask expression of a FORALL statement.
• It can be called from a pure procedure. Pure procedures can only call other pure procedures, including
one referenced by means of a defined operator, defined assignment, or finalization.
• It can be passed as an actual argument to a pure procedure.
If a procedure is used in any of these contexts, its interface must be explicit and it must be declared pure in
that interface.
Example
Consider the following:
1923
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
! INTEGER ITOL
USE SHARED_DEFS
K = 0
XTMP = -X
DO WHILE (ABS(XTMP) < 2.0 .AND. K < ITOL)
XTMP = XTMP**2 - X
K = K + 1
END DO
MANDELBROT = K
END FUNCTION
The following shows the preceding function used in an interface block:
INTERFACE
PURE INTEGER FUNCTION MANDELBROT(X)
COMPLEX, INTENT(IN) :: X
END FUNCTION MANDELBROT
END INTERFACE
The following shows a FORALL construct calling the MANDELBROT function to update all the elements of an
array:
See Also
FUNCTION
SUBROUTINE
FORALL
ELEMENTAL prefix
PUTC
Portability Function: Writes a character to Fortran
external unit number 6.
Module
USE IFPORT
Syntax
result = PUTC (char)
Results
The result type is INTEGER(4). The result is zero if successful; otherwise, an error code.
Example
use IFPORT
integer(4) i4
character*1 char1
do i = 1,26
char1 = char(123-i)
1924
Language Reference
i4 = putc(char1)
if (i4.ne.0) iflag = 1
enddo
See Also
GETC
WRITE
PRINT
FPUTC
Module
USE IFQWIN
Syntax
CALL PUTIMAGE (x,y,image,action)
CALL PUTIMAGE_W (wx,wy,image,action)
action (Input) INTEGER(2). Interaction of the stored image with the existing
screen image. One of the following symbolic constants defined in
IFQWIN.F90:
• $GAND - Forms a new screen display as the logical AND of the
stored image and the existing screen display. Points that have the
same color in both the existing screen image and the stored image
remain the same color, while points that have different colors are
joined by a logical AND.
• $GOR - Superimposes the stored image onto the existing screen
display. The resulting image is the logical OR of the image.
• $GPRESET - Transfers the data point-by-point onto the screen.
Each point has the inverse of the color attribute it had when it was
taken from the screen by GETIMAGE, producing a negative image.
• $GPSET - Transfers the data point-by-point onto the screen. Each
point has the exact color attribute it had when it was taken from
the screen by GETIMAGE.
• $GXOR - Causes points in the existing screen image to be inverted
wherever a point exists in the stored image. This behavior is like
that of a cursor. If you perform an exclusive OR of an image with
the background twice, the background is restored unchanged. This
1925
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
PUTIMAGE places the upper-left corner of the image at the viewport coordinates (x, y). PUTIMAGE_W places
the upper-left corner of the image at the window coordinates (wx, wy).
Example
! Build as a Graphics App.
USE IFQWIN
INTEGER(1), ALLOCATABLE :: buffer(:)
INTEGER(2) status, x
INTEGER(4) imsize
status = SETCOLOR(INT2(4))
! draw a circle
status = ELLIPSE($GFILLINTERIOR,INT2(40),INT2(55), &
INT2(70),INT2(85))
imsize = IMAGESIZE (INT2(39),INT2(54),INT2(71), &
INT2(86))
ALLOCATE (buffer(imsize))
CALL GETIMAGE(INT2(39),INT2(54),INT2(71),INT2(86), &
buffer)
See Also
GETIMAGE
GRSTATUS
IMAGESIZE
1926
Language Reference
PXF(type)GET
POSIX Subroutine: Gets the value stored in a
component (or field) of a structure.
Module
USE IFPOSIX
Syntax
CALL PXF(type)GET (jhandle,compname,value,ierror)
CALL PXF(type)GET (jhandle,compname,value,ilen,ierror) ! syntax when (type) is STR
compname (Input) Character. The name of the component (or field) of the
structure to retrieve data from.
value (Output) A variable, whose data type depends on the value of (type).
See the table above for the data types for each value; for example, if
the value for (type) is INT, the data type is INTEGER(4). Stores the
value of the component (or field).
ilen (Output) INTEGER(4). This argument can only be used when (type)
is STR (PXFSTRGET). Stores the length of the returned string.
The PXF(type)GET subroutines retrieve the value from component (or field) compname of the structure
associated with handle jhandle into variable value.
Example
See the example in PXFTIMES (which shows PXFINTGET and PXFINT8GET)
See Also
PXF(type)SET
1927
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
PXF(type)SET
POSIX Subroutine: Sets the value of a component
(or field) of a structure.
Module
USE IFPOSIX
Syntax
CALL PXF(type)SET (jhandle,compname,value,ierror)
CALL PXF(type)SET (jhandle,compname,value,ilen,ierror) ! syntax when (type) is STR
compname (Input) Character. The name of the component (or field) of the
structure to write data to.
value (Input) A variable, whose data type depends on the value of (type).
See the table above for the data types for each value; for example, if
the value for (type) is INT, the data type is INTEGER(4). The value
for the component (or field).
ilen (Input) INTEGER(4). This argument can only be used when (type) is
STR (PXFSTRSET). The length of the string in value.
Example
See the example in PXFSTRUCTCREATE (which shows PXFSTRSET)
See Also
PXF(type)GET
1928
Language Reference
PXFA(type)GET
POSIX Subroutine: Gets the array values stored in a
component (or field) of a structure.
Module
USE IFPOSIX
Syntax
CALL PXFA(type)GET (jhandle,compname,value,ialen,ierror)
CALL PXFA(type)GET (jhandle,compname,value,ialen,ilen,ierror) ! syntax when (type) is
STR
compname (Input) Character. The name of the component (or field) of the
structure to retrieve data from.
value (Output) An array, whose data type depends on the value of (type).
See the table above for the data types for each value; for example, if
the value for (type) is INT, the data type of the array is INTEGER(4).
Stores the value of the component (or field).
ilen (Output) INTEGER(4). This argument can only be used when (type)
is STR (PXFASTRGET). An array that stores the lengths of elements of
array value.
The PXFA(type)GET subroutines are similar to the PXF(type)GET subroutines, but they should be used when
the component (or field) of the structure is an array.
When the PXFA(type)GET subroutines are used, the entire array is accessed (read from the component or
field) as a unit.
1929
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
PXFA(type)SET
PXF(type)GET
PXFA(type)SET
POSIX Subroutine: Sets the value of an array
component (or field) of a structure.
Module
USE IFPOSIX
Syntax
CALL PXFA(type)SET (jhandle, compname,value,ialen,ierror)
CALL PXFA(type)SET (jhandle,compname,value,ialen,ilen,ierror) ! syntax when (type) is
STR
compname (Input) Character. The name of the component (or field) of the
structure to write data to.
value (Input) An array, whose data type depends on the value of (type).
See the table above for the data types for each value; for example, if
the value for (type) is INT, the data type of the array is INTEGER(4).
The value for the component (or field).
ilen (Input) INTEGER(4). This argument can only be used when (type) is
STR (PXFASTRSET). An array that specifies the lengths of elements of
array value.
The PXFA(type)GET subroutines are similar to the PXF(type)GET subroutines, but they should be used when
the component (or field) of the structure is an array.
1930
Language Reference
When the PXFA(type)GET subroutines are used, the entire array is accessed (read from the component or
field) as a unit.
See Also
PXFA(type)GET
PXF(type)SET
PXFACCESS
POSIX Subroutine: Determines the accessibility of a
file.
Module
USE IFPOSIX
Syntax
CALL PXFACCESS (path,ilen,iamode,ierror)
If access is permitted, the result value is zero; otherwise, an error code. Possible error codes are:
• -1: A bad parameter was passed.
• ENOENT: The named directory does not exist.
• EACCES: Access requested was denied.
On Windows* systems, if the name given is a directory name, the function only checks for existence. All
directories have read/write access on Windows* systems.
PXFALARM
POSIX Subroutine: Schedules an alarm.
Module
USE IFPOSIX
Syntax
CALL PXFALARM (iseconds,isecleft,ierror)
1931
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
iseconds (Input) INTEGER(4). The number of seconds before the alarm signal
should be delivered.
The PXFALARM subroutine arranges for a SIGALRM signal to be delivered to the process in seconds
iseconds.
On Linux* and macOS* systems, SIGALRM is a reserved defined constant that is equal to 14. You can use
any other routine to install the signal handler. You can get SIGALRM and other signal values by using
PXFCONST or IPXFCONST.
On Windows* systems, the SIGALRM feature is not supported, but the POSIX library has an implementation
you can use. You can provide a signal handler for SIGALRM by using PXFSIGACTION.
See Also
PXFCONST
IPXFCONST
PXFSIGACTION
PXFCALLSUBHANDLE
POSIX Subroutine: Calls the associated subroutine.
Module
USE IFPOSIX
Syntax
CALL PXFCALLSUBHANDLE (jhandle2,ival,ierror)
The PXFCALLSUBHANDLE subroutine, when given a subroutine handle, calls the associated subroutine.
PXFGETSUBHANDLE should be used to obtain a subroutine handle.
NOTE
The subroutine cannot be a function, an intrinsic, or an entry point, and must be defined with exactly
one integer argument.
See Also
PXFGETSUBHANDLE
1932
Language Reference
Module
USE IFPOSIX
Syntax
CALL PXFCFGETISPEED (jtermios,iospeed,ierror)
iospeed (Output) INTEGER(4). The returned value of the input baud rate from
the structure associated with handle jtermios.
NOTE
To get a handle for an instance of the termios structure, use PXFSTRUCTCREATE with the string
'termios' for the structure name.
See Also
PXFSTRUCTCREATE
PXFCFSETISPEED
Module
USE IFPOSIX
Syntax
CALL PXFCFGETOSPEED (jtermios,iospeed,ierror)
iospeed (Output) INTEGER(4). The returned value of the output baud rate
from the structure associated with handle jtermios.
NOTE
To get a handle for an instance of the termios structure, use PXFSTRUCTCREATE with the string
'termios' for the structure name.
1933
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
PXFSTRUCTCREATE
PXFCFSETOSPEED
Module
USE IFPOSIX
Syntax
CALL PXFCFSETISPEED (jtermios,ispeed,ierror)
ispeed (Input) INTEGER(4). The value of the input baud rate for the structure
associated with handle jtermios.
NOTE
To get a handle for an instance of the termios structure, use PXFSTRUCTCREATE with the string
'termios' for the structure name.
See Also
PXFSTRUCTCREATE
PXFCFGETISPEED
Module
USE IFPOSIX
Syntax
CALL PXFCFSETOSPEED (jtermios,ispeed,ierror)
ispeed (Input) INTEGER(4). The value of the output baud rate for the
structure associated with handle jtermios.
1934
Language Reference
NOTE
To get a handle for an instance of the termios structure, use PXFSTRUCTCREATE with the string
'termios' for the structure name.
See Also
PXFSTRUCTCREATE
PXFCFGETOSPEED
PXFCHDIR
POSIX Subroutine: Changes the current working
directory.
Module
USE IFPOSIX
Syntax
CALL PXFCHDIR (path,ilen,ierror)
See Also
PXFMKDIR
PXFCHMOD
POSIX Subroutine: Changes the ownership mode of
the file.
Module
USE IFPOSIX
Syntax
CALL PXFCHMOD (path,ilen,imode,ierror)
1935
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
On Linux* and macOS* systems, you must have sufficient ownership permissions, such as being the
owner of the file or having read/write access of the file.
Module
USE IFPOSIX
Syntax
CALL PXFCHOWN (path,ilen,iowner,igroup,ierror)
PXFCLEARENV
POSIX Subroutine: Clears the process environment.
Module
USE IFPOSIX
Syntax
CALL PXFCLEARENV (ierror)
PXFCLOSE
POSIX Subroutine: Closes the file associated with
the descriptor.
Module
USE IFPOSIX
Syntax
CALL PXFCLOSE (fd,ierror)
1936
Language Reference
See Also
PXFOPEN
PXFCLOSEDIR
POSIX Subroutine: Closes the directory stream.
Module
USE IFPOSIX
Syntax
CALL PXFCLOSEDIR (idirid,ierror)
See Also
PXFOPENDIR
PXFCONST
POSIX Subroutine: Returns the value associated
with a constant.
Module
USE IFPOSIX
Syntax
CALL PXFCONST (constname,ival,ierror)
1937
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
For more information on these constants, see your Microsoft* Visual C++ documentation (Windows*
systems) or the errno.h file (Linux* and macOS* systems).
See Also
PXFISCONST
PXFCREAT
POSIX Subroutine: Creates a new file or rewrites an
existing file.
Module
USE IFPOSIX
Syntax
CALL PXFCREAT (path,ilen,imode,ifildes,ierror)
Module
USE IFPOSIX
Syntax
CALL PXFCTERMID (s,ilen,ierror)
ilen (Output) INTEGER(4). The length of the returned value in the s string.
This subroutine returns a string that refers to the current controlling terminal for the current process.
1938
Language Reference
PXFDUP, PXFDUP2
POSIX Subroutine: Duplicates an existing file
descriptor.
Module
USE IFPOSIX
Syntax
CALL PXFDUP (ifildes,ifid,ierror)
CALL PXFDUP2 (ifildes,ifildes2,ierror)
ifildes2 (Input) INTEGER(4). The number for the new file descriptor.
The PXFDUP subroutine creates a second file descriptor for an opened file.
The PXFDUP2 subroutine copies the file descriptor associated with ifildes. Integer number ifildes2
becomes associated with this new file descriptor, but the value of ifildes2 is not changed.
PXFE(type)GET
POSIX Subroutine: Gets the value stored in an array
element component (or field) of a structure.
Module
USE IFPOSIX
Syntax
CALL PXFE(type)GET (jhandle, compname,index,value,ierror)
CALL PXFE(type)GET (jhandle,compname,index,value,ilen,ierror) ! syntax when (type) is
STR
1939
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
compname (Input) Character. The name of the component (or field) of the
structure to retrieve data from.
index (Input) INTEGER(4). The index of the array element to get data for.
value (Output) A variable, whose data type depends on the value of (type).
See the table above for the data types for each value; for example, if
the value for (type) is INT, the data type is INTEGER(4). Stores the
value of the component (or field).
ilen (Output) INTEGER(4). This argument can only be used when (type)
is STR (PXFESTRGET). Stores the length of the returned string.
The PXFE(type)GET subroutines are similar to the PXF(type)GET subroutines, but they should be used when
the component (or field) of the structure is an array.
When the PXFE(type)GET subroutines are used, the array element with index index is accessed (read from
the component or field).
See Also
PXFE(type)SET
PXF(type)GET
PXFE(type)SET
POSIX Subroutine: Sets the value of an array
element component (or field) of a structure.
Module
USE IFPOSIX
Syntax
CALL PXFE(type)SET (jhandle, compname,index,value,ierror)
CALL PXFE(type)SET (jhandle,compname,index,value,ilen,ierror) ! syntax when (type) is
STR
1940
Language Reference
compname (Input) Character. The name of the component (or field) of the
structure to write data to.
index (Input) INTEGER(4). The index of the array element to write data to.
value (Input) A variable, whose data type depends on the value of (type).
See the table above for the data types for each value; for example, if
the value for (type) is INT, the data type is INTEGER(4). The value
for the component (or field).
ilen (Input) INTEGER(4). This argument can only be used when (type) is
STR (PXFESTRSET). The length of the string value.
The PXFE(type)SET subroutines are similar to the PXF(type)SET subroutines, but they should be used when
the component (or field) of the structure is an array.
When the PXFE(type)SET subroutines are used, the array element with index index is accessed (written to
the component or field).
See Also
PXFE(type)GET
PXF(type)SET
PXFEXECV
POSIX Subroutine: Executes a new process by
passing command-line arguments.
Module
USE IFPOSIX
Syntax
CALL PXFEXECV (path,lenpath,argv,lenargv,iargc,ierror)
lenargv (Input) INTEGER(4). An array that contains the lengths for each
corresponding character string in argv.
1941
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The PXFEXECV subroutine executes a new executable process (file) by passing command-line arguments
specified in the argv array. If execution is successful, no return is made to the calling process.
See Also
PXFEXECVE
PXFEXECVP
PXFEXECVE
POSIX Subroutine: Executes a new process by
passing command-line arguments.
Module
USE IFPOSIX
Syntax
CALL PXFEXECVE (path,lenpath,argv,lenargv,iargc,env,lenenv,ienvc,ierror)
lenargv (Input) INTEGER(4). An array that contains the lengths for each
corresponding character string in argv.
lenenv (Input) INTEGER(4). An array that contains the lengths for each
corresponding character string in env.
The PXFEXECVE subroutine executes a new executable process (file) by passing command-line arguments
specified in the argv array and environment settings specified in the env array.
See Also
PXFEXECV
PXFEXECVP
1942
Language Reference
PXFEXECVP
POSIX Subroutine: Executes a new process by
passing command-line arguments.
Module
USE IFPOSIX
Syntax
CALL PXFEXECVP (file,lenfile,argv,lenargv,iargc,ierror)
lenargv (Input) INTEGER(4). An array that contains the lengths for each
corresponding character string in argv.
The PXFEXECVP subroutine executes a new executable process(file) by passing command-line arguments
specified in theargv array. It uses the PATH environment variable to find the file to execute.
See Also
PXFEXECV
PXFEXECVE
PXFEXIT, PXFFASTEXIT
POSIX Subroutine: Exits from a process.
Module
USE IFPOSIX
Syntax
CALL PXFEXIT (istatus)
CALL PXFFASTEXIT (istatus)
The PXFEXIT subroutine terminates the calling process. It calls, in last-in-first-out (LIFO) order, the functions
registered by C runtime functions atexit and onexit, and flushes all file buffers before terminating the
process. The istatus value is typically set to zero to indicate a normal exit and some other value to indicate
an error.
The PXFFASTEXIT subroutine terminates the calling process without processing atexit or onexit, and
without flushing stream buffers.
1943
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
program t1
use ifposix
integer(4) ipid, istat, ierror, ipid_ret, istat_ret
print *," the child process will be born"
call PXFFORK(IPID, IERROR)
call PXFGETPID(IPID_RET,IERROR)
if(IPID.EQ.0) then
print *," I am a child process"
print *," My child's pid is", IPID_RET
call PXFGETPPID(IPID_RET,IERROR)
print *," The pid of my parent is",IPID_RET
print *," Now I have exited with code 0xABCD"
call PXFEXIT(Z'ABCD')
else
print *," I am a parent process"
print *," My parent pid is ", IPID_RET
print *," I am creating the process with pid", IPID
print *," Now I am waiting for the end of the child process"
call PXFWAIT(ISTAT, IPID_RET, IERROR)
print *," The child with pid ", IPID_RET," has exited"
if( PXFWIFEXITED(ISTAT) ) then
print *, " The child exited normally"
istat_ret = IPXFWEXITSTATUS(ISTAT)
print 10," The low byte of the child exit code is", istat_ret
end if
end if
10 FORMAT (A,Z)
end program
Module
USE IFPOSIX
Syntax
CALL PXFFCNTL (ifildes,icmd,iargin,iargout,ierror)
1944
Language Reference
Constant Action
F_SETFL Sets the file status flags from iargin for file
descriptor ifildes. Only O_APPEND or O_NONBLOCK
flags can be modified. In this case, iargout is
ignored.
1945
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Constant Action
NOTE
To get a handle for an instance of the flock structure, use PXFSTRUCTCREATE with the string 'flock'
for the structure name.
See Also
PXFSTRUCTCREATE
IPXFCONST
PXFCONST
PXFFDOPEN
POSIX Subroutine: Opens an external unit.
Module
USE IFPOSIX
Syntax
CALL PXFFDOPEN (ifildes,iunit,access,ierror)
access (Input) Character. A character string that specifies the attributes for
the Fortran unit. The string must consist of one or more of the
following keyword/value pairs. Keyword/value pairs should be
separated by a comma, and blanks are ignored.
1946
Language Reference
The PXFFDOPEN subroutine connects an external unit identified by iunit to a file descriptor ifildes. If unit is
already connected to a file, the file should be closed before using PXFFDOPEN.
NOTE
On Windows* systems, the default value of the POSIX/IO flag is 0, which causes PXFFDOPEN to return
an error.
To prevent this, call subroutine PXFPOSIXIO and set the value of the POSIX/IO flag to 1.
See Also
PXFPOSIXIO
PXFFFLUSH
POSIX Subroutine: Flushes a file directly to disk.
Module
USE IFPOSIX
Syntax
CALL PXFFFLUSH (lunit,ierror)
The PXFFFLUSH subroutine writes any buffered output to the file connected to unit lunit.
PXFFGETC
POSIX Subroutine: Reads a character from a file.
Module
USE IFPOSIX
1947
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
CALL PXFFGETC (lunit,char,ierror)
The PXFFGETC subroutine reads a character from a file connected to unit lunit.
See Also
PXFFPUTC
PXFFILENO
POSIX Subroutine: Returns the file descriptor
associated with a specified unit.
Module
USE IFPOSIX
Syntax
CALL PXFFILENO (lunit,fd,ierror)
If successful, ierror is set to zero; otherwise, an error code. Possible error codes are:
The PXFFILENO subroutine returns in fd the file descriptor associated with lunit.
NOTE
On Windows* systems, the default value of the POSIX/IO flag is 0, which prevents OPEN from
connecting a unit to a file descriptor and causes PXFFILENO to return an error.
To prevent this, call subroutine PXFPOSIXIO and set the value of the POSIX/IO flag to 1. This setting
allows a connection to a file descriptor.
NOTE
The file-descriptor used by POSIX is not the same as the corresponding file handle used by Windows,
so it does not have the same value.
See Also
PXFPOSIXIO
1948
Language Reference
Module
USE IFPOSIX
Syntax
CALL PXFFORK (ipid,ierror)
ipid (Output) INTEGER(4). The returned PID of the new child process.
The PXFFORK subroutine creates a child process that differs from the parent process only in its PID. If
successful, the PID of the child process is returned in the parent's thread of execution, and a zero is returned
in the child's thread of execution. Otherwise, a -1 is returned in the parent's context and no child process is
created.
Example
program t1
use ifposix
integer(4) ipid, istat, ierror, ipid_ret, istat_ret
print *," the child process will be born"
call PXFFORK(IPID, IERROR)
call PXFGETPID(IPID_RET,IERROR)
if(IPID.EQ.0) then
print *," I am a child process"
print *," My child's pid is", IPID_RET
call PXFGETPPID(IPID_RET,IERROR)
print *," The pid of my parent is",IPID_RET
print *," Now I have exited with code 0xABCD"
call PXFEXIT(Z'ABCD')
else
print *," I am a parent process"
print *," My parent pid is ", IPID_RET
print *," I am creating the process with pid", IPID
print *," Now I am waiting for the end of the child process"
call PXFWAIT(ISTAT, IPID_RET, IERROR)
print *," The child with pid ", IPID_RET," has exited"
if( PXFWIFEXITED(ISTAT) ) then
print *, " The child exited normally"
istat_ret = IPXFWEXITSTATUS(ISTAT)
print 10," The low byte of the child exit code is", istat_ret
end if
end if
10 FORMAT (A,Z)
end program
See Also
IPXWEXITSTATUS
1949
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
PXFFPATHCONF
POSIX Subroutine: Gets the value for a
configuration option of an opened file.
Module
USE IFPOSIX
Syntax
CALL PXFFPATHCONF (ifildes,name,ival,ierror)
Constant Action
1950
Language Reference
Constant Action
On Linux* and macOS* systems, the corresponding macros are defined in <unistd.h>. The values for name
can be obtained by using PXFCONST or IPXFCONST when passing the string names of predefined macros in
<unistd.h>. The following table shows the corresponding macro names for the above constants:
_PC_LINK_MAX _POSIX_LINK_MAX
_PC_MAX_CANON _POSIX_MAX_CANON
_PC_MAX_INPUT _POSIX_MAX_INPUT
_PC_NAME_MAX _POSIX_NAME_MAX
_PC_PATH_MAX _POSIX_PATH_MAX
_PC_PIPE_BUF _POSIX_PIPE_BUF
_PC_CHOWN_RESTRICTED _POSIX_CHOWN_RESTRICTED
_PC_NO_TRUNC _POSIX_NO_TRUNC
_PC_VDISABLE _POSIX_VDISABLE
See Also
IPXFCONST
PXFCONST
PXFPATHCONF
PXFFPUTC
POSIX Subroutine: Writes a character to a file.
Module
USE IFPOSIX
Syntax
CALL PXFFPUTC (lunit,char,ierror)
If successful, ierror is set to zero; otherwise, an error code. A possible error code is EEND if the end of the
file has been reached.
The PXFFPUTC subroutine writes a character to the file connected to unit lunit.
1951
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
PXFFGETC
PXFFSEEK
POSIX Subroutine: Modifies a file position.
Module
USE IFPOSIX
Syntax
CALL PXFFSEEK (lunit,ioffset,iwhence,ierror)
ioffset (Input) INTEGER(4). The number of bytes away from iwhence to place
the pointer.
iwhence (Input) INTEGER(4). The position within the file. The value must be
one of the following constants (defined in stdio.h):
If successful, ierror is set to zero; otherwise, an error code. Possible error codes are:
• EINVAL: No file is connected to lunit, iwhence is not a proper value, or the resulting offset is invalid.
• ESPIPE: lunit is a pipe or FIFO.
• EEND: The end of the file has been reached.
The PXFFSEEK subroutine modifies the position of the file connected to unit lunit.
PXFFSTAT
POSIX Subroutine: Gets a file's status information.
Module
USE IFPOSIX
Syntax
CALL PXFFSTAT (ifildes,jstat,ierror)
The PXFFSTAT subroutine puts the status information for the file associated with ifildes into the structure
associated with handle jstat.
1952
Language Reference
NOTE
To get a handle for an instance of the stat structure, use PXFSTRUCTCREATE with the string 'stat' for
the structure name.
See Also
PXFSTRUCTCREATE
PXFFTELL
POSIX Subroutine: Returns the relative position in
bytes from the beginning of the file.
Module
USE IFPOSIX
Syntax
CALL PXFFTELL (lunit,ioffset,ierror)
ioffset (Output) INTEGER(4). The returned relative position in bytes from the
beginning of the file.
PXFGETARG
POSIX Subroutine: Gets the specified command-line
argument.
Module
USE IFPOSIX
Syntax
CALL PXFGETARG (argnum,str,istr,ierror)
The PXFGETARG subroutine places the command-line argument with number argnum into character string
str. If argnum is equal to zero, the value of the argument returned is the command name of the executable
file.
See Also
IPXFARGC
1953
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
PXFGETC
POSIX Subroutine: Reads a character from standard
input unit 5.
Module
USE IFPOSIX
Syntax
CALL PXFGETC (nextcar,ierror)
See Also
PXFPUTC
PXFGETCWD
POSIX Subroutine: Returns the path of the current
working directory.
Module
USE IFPOSIX
Syntax
CALL PXFGETCWD (buf,ilen,ierror)
If successful, ierror is set to zero; otherwise, an error code. A possible error code is EINVAL if the size of
buf is insufficient.
Module
USE IFPOSIX
Syntax
CALL PXFGETEGID (iegid,ierror)
1954
Language Reference
Description
If successful, ierror is set to zero; otherwise, an error code.
The effective ID corresponds to the set ID bit on the file being executed.
PXFGETENV
POSIX Subroutine: Gets the setting of an
environment variable.
Module
USE IFPOSIX
Syntax
CALL PXFGETENV (name,lenname,value,lenval,ierror)
See Also
PXFSETENV
Module
USE IFPOSIX
Syntax
CALL PXFGETEUID (ieuid,ierror)
The effective ID corresponds to the set ID bit on the file being executed.
1955
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Module
USE IFPOSIX
Syntax
CALL PXFGETGID (igid,ierror)
Example
See the example in PXFGETGROUPS
See Also
PXFSETGID
Module
USE IFPOSIX
Syntax
CALL PXFGETGRGID (jgid,jgroup,ierror)
The PXFGETGRGID subroutine stores the group information from /etc/group for the entry that matches the
group GID jgid in the structure associated with handle jgroup.
NOTE
To get a handle for an instance of the groupstructure, use PXFSTRUCTCREATE with the string 'group'
for the structure name.
Example
See the example in PXFGETGROUPS
See Also
PXFSTRUCTCREATE
1956
Language Reference
Module
USE IFPOSIX
Syntax
CALL PXFGETGRNAM (name,ilen,jgroup,ierror)
The PXFGETGRNAM subroutine stores the group information from /etc/group for the entry that matches the
group name name in the structure associated with handle jgroup.
NOTE
To get a handle for an instance of the group structure, use PXFSTRUCTCREATE with the string 'group'
for the structure name.
See Also
PXFSTRUCTCREATE
Module
USE IFPOSIX
Syntax
CALL PXFGETGROUPS (igidsetsize,igrouplist,ngroups,ierror)
igrouplist (Output) INTEGER(4). The array that has the returned supplementary
group IDs.
1957
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The PXFGETGROUPS subroutine returns, up to size igidsetsize, the supplementary group IDs in array
igrouplist. It is unspecified whether the effective group ID of the calling process is included in the
returned list. If the size is zero, the list is not modified, but the total number of supplementary group IDs for
the process is returned.
Example
program test5
use ifposix
implicit none
integer(4) number_of_groups, ierror, isize,i, igid
integer(4),allocatable,dimension(:):: igrouplist
integer(JHANDLE_SIZE) jgroup
do i=1, number_of_groups
call PXFGETGRGID( igrouplist(i), jgroup, ierror)
if(ierror.NE.0) then
DEALLOCATE(igrouplist)
call PXFSTRUCTFREE(jgroup, ierror)
print *,'Error: PXFGETGRGID failed for i=',i," gid=", igrouplist(i)
STOP 'Abnormal termination'
end if
call PRINT_GROUP_INFO(jgroup)
end do
call PXFGETGID(igid,ierror)
if(ierror.NE.0) then
DEALLOCATE(igrouplist)
call PXFSTRUCTFREE(jgroup, ierror)
print *,'Error: PXFGETGID failed'
STOP 'Abnormal termination'
end if
call PXFGETGRGID( igid, jgroup, ierror)
if(ierror.NE.0) then
DEALLOCATE(igrouplist)
1958
Language Reference
call PRINT_GROUP_INFO(jgroup)
DEALLOCATE(igrouplist)
call PXFSTRUCTFREE(jgroup, ierror)
print *," Program will normal terminated"
call PXFEXIT(0)
end
PXFGETLOGIN
POSIX Subroutine: Gets the name of the user.
Module
USE IFPOSIX
Syntax
CALL PXFGETLOGIN (s,ilen,ierror)
Module
USE IFPOSIX
Syntax
CALL PXFGETPGRP (ipgrp,ierror)
Each process group is a member of a session and each process is a member of the session in which its
process group is a member.
PXFGETPID
POSIX Subroutine: Gets the process ID of the calling
process.
Module
USE IFPOSIX
1959
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
CALL PXFGETPID (ipid,ierror)
Example
program t1
use ifposix
integer(4) ipid, istat, ierror, ipid_ret, istat_ret
print *," the child process will be born"
call PXFFORK(IPID, IERROR)
call PXFGETPID(IPID_RET,IERROR)
if(IPID.EQ.0) then
print *," I am a child process"
print *," My child's pid is", IPID_RET
call PXFGETPPID(IPID_RET,IERROR)
print *," The pid of my parent is",IPID_RET
print *," Now I have exited with code 0xABCD"
call PXFEXIT(Z'ABCD')
else
print *," I am a parent process"
print *," My parent pid is ", IPID_RET
print *," I am creating the process with pid", IPID
print *," Now I am waiting for the end of the child process"
call PXFWAIT(ISTAT, IPID_RET, IERROR)
print *," The child with pid ", IPID_RET," has exited"
if( PXFWIFEXITED(ISTAT) ) then
print *, " The child exited normally"
istat_ret = IPXFWEXITSTATUS(ISTAT)
print 10," The low byte of the child exit code is", istat_ret
end if
end if
10 FORMAT (A,Z)
end program
PXFGETPPID
POSIX Subroutine: Gets the process ID of the
parent of the calling process.
Module
USE IFPOSIX
Syntax
CALL PXFGETPPID (ippid,ierror)
1960
Language Reference
Example
program t1
use ifposix
integer(4) ipid, istat, ierror, ipid_ret, istat_ret
print *," the child process will be born"
call PXFFORK(IPID, IERROR)
call PXFGETPID(IPID_RET,IERROR)
if(IPID.EQ.0) then
print *," I am a child process"
print *," My child's pid is", IPID_RET
call PXFGETPPID(IPID_RET,IERROR)
print *," The pid of my parent is",IPID_RET
print *," Now I have exited with code 0xABCD"
call PXFEXIT(Z'ABCD')
else
print *," I am a parent process"
print *," My parent pid is ", IPID_RET
print *," I am creating the process with pid", IPID
print *," Now I am waiting for the end of the child process"
call PXFWAIT(ISTAT, IPID_RET, IERROR)
print *," The child with pid ", IPID_RET," has exited"
if( PXFWIFEXITED(ISTAT) ) then
print *, " The child exited normally"
istat_ret = IPXFWEXITSTATUS(ISTAT)
print 10," The low byte of the child exit code is", istat_ret
end if
end if
10 FORMAT (A,Z)
end program
Module
USE IFPOSIX
Syntax
CALL PXFGETPWNAM (name,ilen,jpasswd,ierror)
name (Input) Character. The login name of the user to retrieve information
about. For example, a login name might be "jsmith", while the actual
name is "John Smith".
The PXFGETPWNAM subroutine stores the user information from /etc/passwd for the entry that matches the
user name name in the structure associated with handle jpasswd.
1961
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
To get a handle for an instance of the compnam structure, use PXFSTRUCTCREATE with the string
'compnam' for the structure name.
See Also
PXFSTRUCTCREATE
Module
USE IFPOSIX
Syntax
CALL PXFGETPWUID (iuid,jpasswd,ierror)
The PXFGETPWUID subroutine stores the user information from /etc/passwd for the entry that matches the
user ID iuid in the structure associated with handle jpasswd.
NOTE
To get a handle for an instance of the compnam structure, use PXFSTRUCTCREATE with the string
'compnam' for the structure name.
See Also
PXFSTRUCTCREATE
PXFGETSUBHANDLE
POSIX Subroutine: Returns a handle for a
subroutine.
Module
USE IFPOSIX
Syntax
CALL PXFGETSUBHANDLE (sub,jhandle1,ierror)
1962
Language Reference
NOTE
The argument sub cannot be a function, an intrinsic, or an entry point, and must be defined with
exactly one integer argument.
Module
USE IFPOSIX
Syntax
CALL PXFGETUID (iuid,ierror)
See Also
PXFSETUID
Module
USE IFPOSIX
Syntax
CALL PXFISATTY (ifildes,isatty,ierror)
If file descriptor ifildes is open and connected to a terminal, isatty returns .TRUE.; otherwise, .FALSE..
See Also
PXFOPEN
PXFISBLK
POSIX Function: Tests for a block special file.
Module
USE IFPOSIX
1963
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
result = PXFISBLK (m)
Results
The result type is logical. If the file is a block special file, the result value is .TRUE.; otherwise, .FALSE..
See Also
PXFISCHR
PXFISCHR
POSIX Function: Tests for a character file.
Module
USE IFPOSIX
Syntax
result = PXFISCHR (m)
Results
The result type is logical. If the file is a character file, the result value is .TRUE.; otherwise, .FALSE..
See Also
PXFISBLK
PXFISCONST
POSIX Function: Tests whether a string is a valid
constant name.
Module
USE IFPOSIX
Syntax
result = PXFISCONST (s)
Results
The result type is logical. The PXFISCONST function confirms whether the argument is a valid constant name
that can be passed to functions PXFCONST and IPXFCONST. It returns .TRUE. only if IPXFCONST will return a
valid value for name s.
See Also
IPXFCONST
PXFCONST
1964
Language Reference
PXFISDIR
POSIX Function: Tests whether a file is a directory.
Module
USE IFPOSIX
Syntax
result = PXFISDIR (m)
Results
The result type is logical. If the file is a directory, the result value is .TRUE.; otherwise, .FALSE..
PXFISFIFO
POSIX Function: Tests whether a file is a special
FIFO file.
Module
USE IFPOSIX
Syntax
result = PXFISFIFO (m)
Results
The result type is logical.
The PXFISFIFO function tests whether the file is a special FIFO file created by PXFMKFIFO. If the file is a
special FIFO file, the result value is .TRUE.; otherwise, .FALSE..
See Also
PXFMKFIFO
PXFISREG
PXFISREG
POSIX Function: Tests whether a file is a regular file.
Module
USE IFPOSIX
Syntax
result = PXFISREG (m)
1965
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type is logical. If the file is a regular file, the result value is .TRUE.; otherwise, .FALSE..
See Also
PXFMKFIFO
PXFISFIFO
PXFKILL
POSIX Subroutine: Sends a signal to a specified
process.
Module
USE IFPOSIX
Syntax
CALL PXFKILL (ipid,isig,ierror)
The PXFKILL subroutine sends a signal with value isig to a specified process. On Windows* systems, only
the ipid for the current process can be used.
Module
USE IFPOSIX
Syntax
CALL PXFLINK (existing,lenexist,new,lennew,ierror)
existing (Input) Character. The path to the file or directory that you want to
link to.
1966
Language Reference
The PXFLINK subroutine creates a new link (also known as a hard link) to an existing file or directory.
This new name can be used exactly as the old one for any operation. Both names refer to the same entity (so
they have the same permissions and ownership) and it is impossible to tell which name was the "original".
PXFLOCALTIME
POSIX Subroutine: Converts a given elapsed time in
seconds to local time.
Module
USE IFPOSIX
Syntax
CALL PXFLOCALTIME (isecnds,iatime,ierror)
Element Value
The PXFLOCALTIME subroutine converts the time (in seconds since epoch) in the isecnds argument to the
local date and time as described by the array iatime above.
1967
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
PXFLSEEK
POSIX Subroutine: Positions a file a specified
distance in bytes.
Module
USE IFPOSIX
Syntax
CALL PXFLSEEK (ifildes,ioffset,iwhence,iposition,ierror)
iwhence (Input) INTEGER(4). The starting position. The value must be one of
the following:
• SEEK_SET = 0
Sets the offset to ioffset bytes.
• SEEK_CUR = 1
Sets the offset to its current location plus ioffset bytes.
• SEEK_END = 2
Sets the offset to the size of the file plus ioffset bytes.
The PXFLSEEK subroutine repositions the offset of file descriptor ifildes to the argument ioffset
according to the value of argument iwhence.
PXFLSEEK allows the file offset to be set beyond the end of the existing end-of-file. If data is later written at
this point, subsequent reads of the data in the gap return bytes of zeros (until data is actually written into
the gap).
PXFMKDIR
POSIX Subroutine: Creates a new directory.
Module
USE IFPOSIX
Syntax
CALL PXFMKDIR (path,ilen,imode,ierror)
imode (L*X only) (Input) INTEGER(4). The mode mask. Octal file-access mode.
1968
Language Reference
See Also
PXFRMDIR
PXFCHDIR
Module
USE IFPOSIX
Syntax
CALL PXFMKFIFO (path,ilen,imode,ierror)
The PXFMKFIFO subroutine creates a FIFO special file with name path. A FIFO special file is similar to a pipe,
except that it is created in a different way. Once a FIFO special file is created, any process can open it for
reading or writing in the same way as an ordinary file.
However, the FIFO file has to be open at both ends simultaneously before you can proceed to do any input or
output operations on it. Opening a FIFO for reading normally blocks it until some other process opens the
same FIFO for writing, and vice versa.
See Also
PXFISFIFO
PXFOPEN
POSIX Subroutine: Opens or creates a file.
Module
USE IFPOSIX
Syntax
CALL PXFOPEN (path,ilen,iopenflag,imode,ifildes,ierror)
iopenflag (Input) INTEGER(4). The flags for the file. (For possible constant
names that can be passed to PXFCONST or IPXFCONST, see below.)
1969
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
imode (Input) INTEGER(4). The permissions for a new file. This argument
should always be specified when iopenflag=O_CREAT; otherwise, it
is ignored. (For possible permissions, see below.)
ifildes (Output) INTEGER(4). The returned file descriptor for the opened or
created file.
O_NONBLOCK (or O_NDELAY)1 When possible, opens the file in non-blocking mode.
Neither the open nor any subsequent operations on
the file descriptor that is returned will cause the
calling process to wait. This mode need not have
any effect on files other than FIFOs.
1970
Language Reference
Value Action
1L*X only
2W*S
2W*S
3For more information, see "Text and Binary Modes" in the Visual C++* programmer's guide.
Argument imode specifies the permissions to use if a new file is created. The permissions only apply to future
accesses of the newly created file. The value for imode can be any of the following constant values (which
can be obtained by using PXFCONST or IPXFCONST):
Value Description
S_IRWXU 00700 user (file owner) has read, write and execute
permission.
1971
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
The following call opens a file for writing only and if the file does not exist, it is created:
See Also
PXFCLOSE
IPXFCONST
PXFCONST
PXFOPENDIR
POSIX Subroutine: Opens a directory and associates
a stream with it.
Module
USE IFPOSIX
Syntax
CALL PXFOPENDIR (dirname,lendirname,opendirid,ierror)
This subroutine opens a directory pointed to by the dirname argument and returns the ID of the directory
into opendirid. After the call, this ID can be used by functions PXFREADDIR, PXFREWINDDIR,
PXFCLOSEDIR.
See Also
PXFCLOSEDIR
PXFREADDIR
PXFREADDIR
PXFPATHCONF
POSIX Subroutine: Gets the value for a
configuration option of an opened file.
Module
USE IFPOSIX
Syntax
CALL PXFPATHCONF (path,ilen,name,ival,ierror)
1972
Language Reference
Constant Action
_PC_PIPE_BUF Returns the size of the pipe buffer; the path must
refer to a FIFO.
On Linux* and macOS* systems, the corresponding macros are defined in <unistd.h>. The values for name
can be obtained by using PXFCONST or IPXFCONST when passing the string names of predefined macros in
<unistd.h>. The following table shows the corresponding macro names for the above constants:
_PC_LINK_MAX _POSIX_LINK_MAX
_PC_MAX_CANON _POSIX_MAX_CANON
_PC_MAX_INPUT _POSIX_MAX_INPUT
1973
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
_PC_NAME_MAX _POSIX_NAME_MAX
_PC_PATH_MAX _POSIX_PATH_MAX
_PC_PIPE_BUF _POSIX_PIPE_BUF
_PC_CHOWN_RESTRICTED _POSIX_CHOWN_RESTRICTED
_PC_NO_TRUNC _POSIX_NO_TRUN C
_PC_VDISABLE _POSIX_VDISABLE
See Also
IPXFCONST
PXFCONST
PXFFPATHCONF
PXFPAUSE
POSIX Subroutine: Suspends process execution.
Module
USE IFPOSIX
Syntax
CALL PXFPAUSE (ierror)
The PXFPAUSE subroutine causes the invoking process (or thread) to sleep until a signal is received that
either terminates it or causes it to call a signal-catching function.
Module
USE IFPOSIX
Syntax
CALL PXFPIPE (ireadfd,iwritefd,ierror)
The PXFPIPE subroutine returns a pair of file descriptors, pointing to a pipe inode, and places them into
ireadfd for reading and into iwritefd for writing.
1974
Language Reference
PXFPOSIXIO
POSIX Subroutine: Sets the current value of the
POSIX I/O flag.
Module
USE IFPOSIX
Syntax
CALL PXFPOSIXIO (new,old,ierror)
new (Input) INTEGER(4). The new value for the POSIX I/O flag.
old (Output) INTEGER(4). The previous value of the POSIX I/O flag.
This subroutine sets the current value of the Fortran POSIX I/O flag and returns the previous value of the
flag. The initial state of the POSIX I/O flag is unspecified.
If a file is opened with a Fortran OPEN statement when the value of the POSIX I/O flag is 1, the unit is
accessed as if the records are newline delimited, even if the file does not contain records that are delimited
by a new line character.
If a file is opened with a Fortran OPEN statement when the value of the POSIX I/O flag is zero, a connection
to a file descriptor is not assumed and the records in the file are not required to be accessed as if they are
newline delimited.
PXFPUTC
POSIX Subroutine: Outputs a character to logical
unit 6 (stdout).
Module
USE IFPOSIX
Syntax
CALL PXFPUTC (ch,ierror)
If successful, ierror is set to zero; otherwise, an error code. A possible error code is EEND if the end of the
file has been reached.
See Also
PXFGETC
PXFREAD
POSIX Subroutine: Reads from a file.
Module
USE IFPOSIX
1975
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
CALL PXFREAD (ifildes,buf,nbyte,nread,ierror)
ifildes (Input) INTEGER(4). The file descriptor of the file to be read from.
buf (Output) Character. The buffer that stores the data read from the file.
The PXFREAD subroutine reads nbyte bytes from the file specified by ifildes into memory in buf. The
subroutine returns the total number of bytes read into nread. If no error occurs, the value of nread will
equal the value of nbyte.
See Also
PXFWRITE
PXFREADDIR
POSIX Subroutine: Reads the current directory
entry.
Module
USE IFPOSIX
Syntax
CALL PXFREADDIR (idirid,jdirent,ierror)
The PXFREADDIR subroutine reads the entry of the directory associated with idirid into the structure
associated with handle jdirent.
NOTE
To get a handle for an instance of the dirent structure, use PXFSTRUCTCREATE with the string 'dirent'
for the structure name.
See Also
PXFOPENDIR
PXFREWINDDIR
1976
Language Reference
PXFRENAME
POSIX Subroutine: Changes the name of a file.
Module
USE IFPOSIX
Syntax
CALL PXFRENAME (old,lenold,new,lennew,ierror)
PXFREWINDDIR
POSIX Subroutine: Resets the position of the stream
to the beginning of the directory.
Module
USE IFPOSIX
Syntax
CALL PXFREWINDDIR (idirid,ierror)
PXFRMDIR
POSIX Subroutine: Removes a directory.
Module
USE IFPOSIX
Syntax
CALL PXFRMDIR (path,ilen,ierror)
1977
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
PXFMKDIR
PXFCHDIR
PXFSETENV
POSIX Subroutine: Adds a new environment
variable or sets the value of an environment variable.
Module
USE IFPOSIX
Syntax
CALL PXFSETENV (name,lenname,new,lennew,ioverwrite,ierror)
If name exists, PXFSETENV sets its value to new ifioverwrite is a nonzero number. If ioverwrite is zero,
the value of name is not changed.
If lennew is equal to zero, PXFSETENV sets the value of the environment variable to a string equal to new
after removing any leading or trailing blanks.
Example
program test2
use ifposix
character*10 name, new
integer lenname, lennew, ioverwrite, ierror
name = "FOR_NEW"
lenname = 7
new = "ON"
lennew = 2
ioverwrite = 1
1978
Language Reference
See Also
PXFGETENV
Module
USE IFPOSIX
Syntax
CALL PXFSETGID (igid,ierror)
If the caller is the superuser, the real and saved group ID's are also
set. This feature allows a program other than root to drop all of its
group privileges, do some un-privileged work, and then re-engage the
original effective group ID in a secure manner.
Caution
If the user is root then special care must be taken. PXFSETGID checks the effective gid of the caller. If
it is the superuser, all process-related group ID's are set to gid. After this has occurred, it is impossible
for the program to regain root privileges.
See Also
PXFGETGID
Module
USE IFPOSIX
Syntax
CALL PXFSETPGID (ipid,ipgid,ierror)
The PXFSETPGID subroutine sets the process group ID of the process specified by ipid to ipgid.
If ipid is zero, the process ID of the current process is used. If ipgid is zero, the process ID of the process
specified by ipid is used.
1979
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
PXFSETPGID can be used to move a process from one process group to another, but both process groups
must be part of the same session. In this case, ipgid specifies an existing process group to be joined and
the session ID of that group must match the session ID of the joining process.
Module
USE IFPOSIX
Syntax
CALL PXFSETSID (isid,ierror)
The PXFSETSID subroutine creates a new session if the calling process is not a process group leader.
The calling process is the leader of the new session and the process group leader for the new process group.
The calling process has no controlling terminal.
The process group ID and session ID of the calling process are set to the PID of the calling process. The
calling process will be the only process in this new process group and in this new session.
Module
USE IFPOSIX
Syntax
CALL PXFSETUID (iuid,ierror)
If the effective user ID of the caller is root, the real and saved user ID's are also set. This feature allows a
program other than root to drop all of its user privileges, do some un-privileged work, and then re-engage
the original effective user ID in a secure manner.
Caution
If the user is root then special care must be taken. PXFSETUID checks the effective uid of the caller. If
it is the superuser, all process-related user ID's are set to uid. After this has occurred, it is impossible
for the program to regain root privileges.
See Also
PXFGETUID
1980
Language Reference
Module
USE IFPOSIX
Syntax
CALL PXFSIGACTION (isig,jsigact,josigact,ierror)
The signal specified in isig can be any valid signal except SIGKILL and SIGSTOP.
If jsigact is nonzero, the new action for signal isig is installed from the structure associated with handle
jsigact. If josigact is nonzero, the previous action of the specified signal is saved in the structure
associated with handle josigact where it can be examined.
NOTE
To get a handle for an instance of the sigaction structure, use PXFSTRUCTCREATE with the string
'sigaction' for the structure name.
See Also
PXFSTRUCTCREATE
Module
USE IFPOSIX
Syntax
CALL PXFSIGADDSET (jsigset,isigno,ierror)
1981
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The PXFSIGADDSET subroutine adds signal number isigno to the set of signals associated with handle
jsigset. This set of signals is used by PXFSIGACTION as field sa_mask in structure sigaction. It defines
the set of signals that will be blocked during execution of the signal handler function (the field sa_handler in
structure sigaction).
NOTE
To get a handle for an instance of the sigset structure, use PXFSTRUCTCREATE with the string 'sigset'
for the structure name.
See Also
PXFSTRUCTCREATE
PXFSIGDELSET
PXFSIGACTION
Module
USE IFPOSIX
Syntax
CALL PXFSIGDELSET (jsigset,isigno,ierror)
isigno (Input) INTEGER(4). The signal number to delete from the set.
The PXFSIGDELSET subroutine removes signal number isigno from the set of signals associated with handle
jsigset. This set of signals is used by PXFSIGACTION as field sa_mask in structure sigaction. It defines
the set of signals that will be blocked during execution of the signal handler function (the field sa_handler in
structure sigaction).
NOTE
To get a handle for an instance of the sigset structure, use PXFSTRUCTCREATE with the string 'sigset'
for the structure name.
See Also
PXFSTRUCTCREATE
PXFSIGADDSET
PXFSIGACTION
1982
Language Reference
Module
USE IFPOSIX
Syntax
CALL PXFSIGEMPTYSET (jsigset,ierror)
The PXFSIGEMPTYSET subroutine initializes the signal set associated with handle jsigset to empty; all
signals are excluded from the set. This set of signals is used by PXFSIGACTION as field sa_mask in structure
sigaction. It defines the set of signals that will be blocked during execution of the signal handler function
(the field sa_handler in structure sigaction).
NOTE
To get a handle for an instance of the sigset structure, use PXFSTRUCTCREATE with the string 'sigset'
for the structure name.
See Also
PXFSTRUCTCREATE
PXFSIGFILLSET
PXFSIGACTION
Module
USE IFPOSIX
Syntax
CALL PXFSIGFILLSET (jsigset,ierror)
The PXFSIGFILLSET subroutine initializes the signal set associated with handle jsigset to full; all signals are
included into the set. This set of signals is used by PXFSIGACTION as field sa_mask in structure sigaction.
It defines the set of signals that will be blocked during execution of the signal handler function (the field
sa_handler in structure sigaction).
1983
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
To get a handle for an instance of the sigset structure, use PXFSTRUCTCREATE with the string 'sigset'
for the structure name.
See Also
PXFSTRUCTCREATE
PXFSIGEMPTYSET
PXFSIGACTION
Module
USE IFPOSIX
Syntax
CALL PXFSIGISMEMBER (jsignset,isigno,ismember,ierror)
jsignset (Input) INTEGER(4). A handle of structure sigset. This is the set the
signal will be tested in.
The PXFSIGISMEMBER subroutine tests whether isigno is a member of the set associated with handle
jsignset. If the signal is a member of the set, ismember is set to .TRUE.; otherwise, .FALSE.. This set of
signals is used by PXFSIGACTION as field sa_mask in structure sigaction. It defines the set of signals that
will be blocked during execution of the signal handler function (the field sa_handler in structure sigaction).
NOTE
To get a handle for an instance of the sigset structure, use PXFSTRUCTCREATE with the string 'sigset'
for the structure name.
See Also
PXFSTRUCTCREATE
PXFSIGACTION
1984
Language Reference
Module
USE IFPOSIX
Syntax
CALL PXFSIGPENDING (jsigset,ierror)
The PXFSIGPENDING subroutine is used to examine pending signals (ones that have been raised while
blocked). The signal mask of the pending signals is stored in the signal set associated with handle jsigset.
Module
USE IFPOSIX
Syntax
CALL PXFSIGPROCMASK (ihow,jsigset,josigset,ierror)
The argument ihow indicates the way in which the set is to be changed, and consists of one of the following
constant names:
Constant 1 Action
1985
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If josigset is non-zero, the previous value of the signal mask is stored in the structure associated with
handle josigset.
See Also
IPXFCONST
PXFCONST
Module
USE IFPOSIX
Syntax
CALL PXFSIGSUSPEND (jsigset,ierror)
PXFSIGSUSPEND temporarily replaces the signal mask for the process with that given by the structure
associated with the jsigset handle; it then suspends the process until a signal is received.
PXFSLEEP
POSIX Subroutine: Forces the process to sleep.
Module
USE IFPOSIX
Syntax
CALL PXFSLEEP (iseconds,isecleft,ierror)
The PXFSLEEP subroutine forces the current process to sleep until seconds iseconds have elapsed or a
signal arrives that cannot be ignored.
PXFSTAT
POSIX Subroutine: Gets a file's status information.
Module
USE IFPOSIX
1986
Language Reference
Syntax
CALL PXFSTAT (path,ilen,jstat,ierror)
The PXFSTAT subroutine puts the status information for the file specified by path into the structure
associated with handle jstat.
NOTE
To get a handle for an instance of the stat structure, use PXFSTRUCTCREATE with the string 'stat' for
the structure name.
See Also
PXFSTRUCTCREATE
PXFSTRUCTCOPY
POSIX Subroutine: Copies the contents of one
structure to another.
Module
USE IFPOSIX
Syntax
CALL PXFSTRUCTCOPY (structname,jhandle1,jhandle2,ierror)
jhandle2 (Input) INTEGER(4). A handle to the structure that will receive the
copy.
Example
See the example in PXFSTRUCTCREATE
PXFSTRUCTCREATE
POSIX Subroutine: Creates an instance of the
specified structure.
Module
USE IFPOSIX
1987
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
CALL PXFSTRUCTCREATE (structname,jhandle,ierror)
If your application passes information to the system, you should call one of the PXF(type)SET subroutines. If
your application needs to get information from the structure, you should call one of the PXF(type)GET
subroutines.
The following table shows:
• The structures that are available in the Fortran POSIX library
• The fields within each structure
• The subroutines you must use to access the structure fields
1988
Language Reference
1989
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
As for any character string, you must use single or double quotes when specifying a field name in a
PXF(type)GET or PXF(type)SET subroutine. For example, field name sysname (in structure utsname) must be
specified as 'sysname'.
Example
program test4
use ifposix
implicit none
integer(jhandle_size) jhandle1,jhandle2
integer(4) ierror,ilen1
print *,"Fill the structure associated with jhandle1 with arbitrary data"
call PXFSTRSET(jhandle1,"sysname","00000000000000",14,ierror)
if(ierror.NE.0) call Error('Error: can't set component sysname for jhandle1')
call PXFSTRSET(jhandle1,"Nodename","11111111111111",14,ierror)
if(ierror.NE.0) call Error('Error: can't set component nodename for jhandle1')
call PXFSTRSET(jhandle1,"RELEASE","22222222222222",14,ierror)
if(ierror.NE.0) call Error('Error: can't set component release for jhandle1')
call PXFSTRSET(jhandle1,"verSION","33333333333333",14,ierror)
if(ierror.NE.0) call Error('Error: can't set component version for jhandle1')
call PXFSTRSET(jhandle1,"machine","44444444444444",14,ierror)
if(ierror.NE.0) call Error('Error: can't set component machine for jhandle1')
print *,"Fill the structure associated with jhandle2 with arbitary data"
call PXFSTRSET(jhandle2,"sysname","aaaaaaaaa",7,ierror)
if(ierror.NE.0) call Error('Error: can't set component sysname for jhandle2')
call PXFSTRSET(jhandle2,"verSION","ddddd",1,ierror)
if(ierror.NE.0) call Error('Error: can't set component version for jhandle2')
call PXFSTRSET(jhandle2,"machine","eeeeeee",6,ierror)
if(ierror.NE.0) call Error('Error: can't set component machine for jhandle2')
1990
Language Reference
print *,"Get operating system info into structure associated with jhandle1"
call PXFUNAME(jhandle1,ierror)
if(ierror.NE.0) call Error('Error: call to PXFUNAME has failed')
See Also
PXFSTRUCTFREE
the example in PXFTIMES
PXFSTRUCTFREE
POSIX Subroutine: Deletes the instance of a
structure.
Module
USE IFPOSIX
Syntax
CALL PXFSTRUCTFREE (jhandle,ierror)
The PXFSTRUCTFREE subroutine deletes the instance of the structure associated with handle jhandle.
Example
See the example in PXFSTRUCTCREATE, the example in PXFTIMES
1991
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
PXFSYSCONF
POSIX Subroutine: Gets values for system limits or
options.
Module
USE IFPOSIX
Syntax
CALL PXFSYSCONF (name,ival,ierror)
name (Input) INTEGER(4). The system option you want information about.
Constant Description
1992
Language Reference
Constant Description
The corresponding macros are defined in <bits/confname.h> on Linux* systems; <unistd.h> on macOS*
systems. The values for argument name can be obtained by using PXFCONST or IPXFCONST when passing
the string names of predefined macros in the appropriate .h file.
1993
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
IPXFCONST
PXFCONST
Module
USE IFPOSIX
Syntax
CALL PXFTCDRAIN (ifildes,ierror)
ifildes (Input) INTEGER(4). The file descriptor associated with the terminal.
Module
USE IFPOSIX
Syntax
CALL PXFTCFLOW (ifildes,iaction,ierror)
ifildes (Input) INTEGER(4). The file descriptor associated with the terminal.
Constant 1 Action
1994
Language Reference
Constant 1 Action
See Also
IPXFCONST
PXFCONST
Module
USE IFPOSIX
Syntax
CALL PXFTCFLUSH (ifildes,iaction,ierror)
ifildes (Input) INTEGER(4). The file descriptor associated with the terminal.
Constant 1 Action
TCIFLUSH Discards all data that has been received but not
read.
TCOFLUSH Discards all data that has been written but not
transmitted.
TCIOFLUSH Discards both data received but not read and data
written but not transmitted. (Performs TCIFLUSH
and TCOFLUSH actions.)
1These names can be used in PXFCONST or IPXFCONST.
See Also
IPXFCONST
PXFCONST
Module
USE IFPOSIX
Syntax
CALL PXFTCGETATTR (ifildes,jtermios,ierror)
1995
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
ifildes (Input) INTEGER(4). The file descriptor associated with the terminal.
NOTE
To get a handle for an instance of the termiosstructure, use PXFSTRUCTCREATE with the string
'termios' for the structure name.
See Also
PXFSTRUCTCREATE
PXFTCSETATTR
Module
USE IFPOSIX
Syntax
CALL PXFTCGETPGRP (ifildes,ipgid,ierror)
ifildes (Input) INTEGER(4). The file descriptor associated with the terminal.
See Also
PXFTCSETPGRP
Module
USE IFPOSIX
Syntax
CALL PXFTCSENDBREAK (ifildes,iduration,ierror)
ifildes (Input) INTEGER(4). The file descriptor associated with the terminal.
iduration (Input) INTEGER(4). Indicates how long the break should be.
1996
Language Reference
The PXFTCSENDBREAK subroutine sends a break (a '\0' with a framing error) to the terminal associated with
ifildes.
Module
USE IFPOSIX
Syntax
CALL PXFTCSETATTR (ifildes,ioptacts,jtermios,ierror)
ifildes (Input) INTEGER(4). The file descriptor associated with the terminal.
ioptacts (Input) INTEGER(4). Specifies when the terminal changes take effect.
Constant 1 Action
NOTE
To get a handle for an instance of the termiosstructure, use PXFSTRUCTCREATE with the string
'termios' for the structure name.
See Also
PXFSTRUCTCREATE
PXFTCGETATTR
1997
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Module
USE IFPOSIX
Syntax
CALL PXFTCSETPGRP (ifildes,ipgid,ierror)
ifildes (Input) INTEGER(4). The file descriptor associated with the terminal.
See Also
PXFTCGETPGRP
PXFTIME
POSIX Subroutine: Returns the current system time.
Module
USE IFPOSIX
Syntax
CALL PXFTIME (itime,ierror)
The PXFTIME subroutine returns the number of seconds since Epoch (00:00:00 UTC, January 1, 1970).
Example
See the example in PXFTIMES.
PXFTIMES
POSIX Subroutine: Returns process times.
Module
USE IFPOSIX
Syntax
CALL PXFTIMES (jtms,itime,ierror)
1998
Language Reference
The PXFTIMES subroutine fills the fields of structure tms associated with handle jtms with components of
time that was spent by the current process. The structure fields are:
• tms_utime - User CPU time
• tms_stime - System CPU time
• tms_cutime - User time of child process
• tms_cstime - System time of child process
All members are measured in system clocks. The values can be converted to seconds by dividing by value
ival returned from the following call:
NOTE
To get a handle for an instance of the tms structure, use PXFSTRUCTCREATE with the string 'tms' for
the structure name.
Example
program test_uname
use ifposix
implicit none
integer(jhandle_size) jtms1, jtms2
integer(4) ierror,i
integer(4),parameter :: n=10000000
integer(SIZEOF_CLOCK_T) itime,time1,time2, user_time1,user_time2
integer(SIZEOF_CLOCK_T) system_time1,system_time2
integer(4) clocks_per_sec, iname
real(8) s, PI
real(8) seconds_user, seconds_system
1999
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
s = 0._8
PI = atan(1._8)*4
do i=0, n
s = s + cos(i*PI/n)*sin(i*PI/n)
end do
print *," s=",s
iname = IPXFCONST("_SC_CLK_TCK")
call PXFSYSCONF(iname,clocks_per_sec, ierror)
if(ierror.NE.0) then
call PXFSTRUCTFREE(jtms1,ierror)
call PXFSTRUCTFREE(jtms2,ierror)
STOP 'Error: the call of PXFSYSCONF fails'
end if
See Also
PXFSTRUCTCREATE
2000
Language Reference
Module
USE IFPOSIX
Syntax
CALL PXFTTYNAME (ifildes,s,ilen,ierror)
ifildes (Input) INTEGER(4). The file descriptor associated with the terminal.
PXFUCOMPARE
POSIX Subroutine: Compares two unsigned
integers.
Module
USE IFPOSIX
Syntax
CALL PXFUCOMPARE (i1,i2,icmpr,idiff)
-1 If i1 < i2
0 If i1 = i2
1 If i1 > i2
The PXFUCOMPARE subroutine compares two unsigned integers and returns the absolute value of their
difference into idiff.
PXFUMASK
POSIX Subroutine: Sets a new file creation mask
and gets the previous one.
Module
USE IFPOSIX
2001
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
CALL PXFUMASK (icmask,iprevcmask,ierror)
PXFUNAME
POSIX Subroutine: Gets the operation system
name.
Module
USE IFPOSIX
Syntax
CALL PXFUNAME (jutsname,ierror)
The PXFUNAME subroutine provides information about the operation system. The information is stored in the
structure associated with handle jutsname.
Example
See the example in PXFSTRUCTCREATE
PXFUNLINK
POSIX Subroutine: Removes a directory entry.
Module
USE IFPOSIX
Syntax
CALL PXFUNLINK (path,ilen,ierror)
PXFUTIME
POSIX Subroutine: Sets file access and modification
times.
2002
Language Reference
Module
USE IFPOSIX
Syntax
CALL PXFUTIME (path,ilen,jutimbuf,ierror)
The PXFUTIME subroutine sets access and modification times for the file pointed to by path. The time values
are retrieved from structure utimbuf.
Module
USE IFPOSIX
Syntax
CALL PXFWAIT (istat,iretpid,ierror)
The PXFWAIT subroutine suspends execution of the current process until a child has exited, or until a signal
is delivered whose action terminates the current process or calls a signal handling routine. If the child has
already exited by the time of the call (a "zombie" process), a return is immediately made. Any system
resources used by the child are freed.
The subroutine returns in iretpid the value of the process ID of the child that exited, or zero if no child was
available. The returned value in istat can be used in subroutines IPXFWEXITSTATUS, IPXFWSTOPSIG,
IPXFWTERMSIG, PXFWIFEXITED, PXFWIFSIGNALLED, and PXFWIFSTOPPED.
Example
program t1
use ifposix
integer(4) ipid, istat, ierror, ipid_ret, istat_ret
print *," the child process will be born"
call PXFFORK(IPID, IERROR)
call PXFGETPID(IPID_RET,IERROR)
if(IPID.EQ.0) then
print *," I am a child process"
print *," My child's pid is", IPID_RET
call PXFGETPPID(IPID_RET,IERROR)
print *," The pid of my parent is",IPID_RET
2003
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
PXFWAITPID
IPXFWEXITSTATUS
IPXFWSTOPSIG
IPXFWTERMSIG
PXFWIFEXITED
PXFWIFSIGNALLED
PXFWIFSTOPPED
Module
USE IFPOSIX
Syntax
CALL PXFWAITPID (ipid,istat,ioptions,iretpid,ierror)
ipid (Input) INTEGER(4). The PID to wait for. One of the following values:
Value Action
2004
Language Reference
Value Action
Value Action
The PXFWAITPID subroutine suspends execution of the current process until the child specified by ipid has
exited, or until a signal is delivered whose action terminates the current process or calls a signal handling
routine. If the child specified by ipid has already exited by the time of the call (a "zombie" process), a return
is immediately made. Any system resources used by the child are freed.
The returned value in istat can be used in subroutines IPXFWEXITSTATUS, IPXFWSTOPSIG, IPXFWTERMSIG,
PXFWIFEXITED, PXFWIFSIGNALLED, and PXFWIFSTOPPED.
See Also
PXFWAIT
IPXFWEXITSTATUS
IPXFWSTOPSIG
IPXFWTERMSIG
PXFWIFEXITED
PXFWIFSIGNALLED
PXFWIFSTOPPED
Module
USE IFPOSIX
Syntax
result = PXFWIFEXITED (istat)
2005
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
istat (Output) INTEGER(4). The status of the child process (obtained from
PXFWAIT or PXFWAITPID).
Results
The result type is logical. The result value is .TRUE. if the child process has exited normally;
otherwise, .FALSE..
Example
program t1
use ifposix
integer(4) ipid, istat, ierror, ipid_ret, istat_ret
print *," the child process will be born"
call PXFFORK(IPID, IERROR)
call PXFGETPID(IPID_RET,IERROR)
if(IPID.EQ.0) then
print *," I am a child process"
print *," My child's pid is", IPID_RET
call PXFGETPPID(IPID_RET,IERROR)
print *," The pid of my parent is",IPID_RET
print *," Now I have exited with code 0xABCD"
call PXFEXIT(Z'ABCD')
else
print *," I am a parent process"
print *," My parent pid is ", IPID_RET
print *," I am creating the process with pid", IPID
print *," Now I am waiting for the end of the child process"
call PXFWAIT(ISTAT, IPID_RET, IERROR)
print *," The child with pid ", IPID_RET," has exited"
if( PXFWIFEXITED(ISTAT) ) then
print *, " The child exited normally"
istat_ret = IPXFWEXITSTATUS(ISTAT)
print 10," The low byte of the child exit code is", istat_ret
end if
end if
10 FORMAT (A,Z)
end program
See Also
PXFWIFSIGNALED
PXFWIFSTOPPED
Module
USE IFPOSIX
Syntax
result = PXFWIFSIGNALED (istat)
istat (Output) INTEGER(4). The status of the child process (obtained from
PXFWAIT or PXFWAITPID).
2006
Language Reference
Results
The result type is logical. The result value is .TRUE. if the child process has exited because of a signal that
was not caught; otherwise, .FALSE..
See Also
PXFWIFEXITED
PXFWIFSTOPPED
Module
USE IFPOSIX
Syntax
result = PXFWIFSTOPPED (istat)
istat (Output) INTEGER(4). The status of the child process (obtained from
PXFWAIT or PXFWAITPID).
Results
The result type is logical. The result value is .TRUE. if the child process has stopped; otherwise, .FALSE..
See Also
PXFWIFEXITED
PXFWIFSIGNALED
PXFWRITE
POSIX Subroutine: Writes to a file.
Module
USE IFPOSIX
Syntax
CALL PXFWRITE (ifildes,buf,nbyte,nwritten,ierror)
ifildes (Input) INTEGER(4). The file descriptor for the file to be written to.
buf (Input) Character. The buffer that contains the data to write into the
file.
The PXFWRITE subroutine writes nbyte bytes from the storage buf into a file specified by file descriptor
ifildes. The subroutine returns the total number of bytes read into nwritten. If no error occurs, the value
of nwritten will equal the value of nbyte.
2007
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
PXFREAD
Q to R
This section describes language features that start with Q or R.
Q to R
QCMPLX
Elemental Intrinsic Function (Specific): Converts
an argument to COMPLEX(16) type. This function
cannot be passed as an actual argument.
Syntax
result = QCMPLX (x[,y])
Results
The result type is COMPLEX(16) (or COMPLEX*32).
If only one noncomplex argument appears, it is converted into the real part of the result value and zero is
assigned to the imaginary part. If y is not specified and x is complex, the result value is CMPLX(REAL( x),
AIMAG( x)).
If two noncomplex arguments appear, the complex value is produced by converting the first argument into
the real part of the value, and converting the second argument into the imaginary part.
QCMPLX( x, y) has the complex value whose real part is REAL( x, kind=16) and whose imaginary part is
REAL( y, kind=16).
Example
QCMPLX (-3) has the value (-3.0Q0, 0.0Q0).
QCMPLX (4.1, 2.3) has the value (4.1Q0, 2.3Q0).
See Also
CMPLX
DCMPLX
FLOAT
INT
IFIX
REAL
SNGL
QEXT
Elemental Intrinsic Function (Generic): Converts
a number to quad precision (REAL(16)) type.
2008
Language Reference
Syntax
result = QEXT (a)
Results
The result type is REAL(16) (REAL*16). Functions that cause conversion of one data type to another type
have the same effect as the implied conversion in assignment statements.
If a is of type REAL(16), the result is the value of the a with no conversion (QEXT(a) = a).
If a is of type integer or real, the result has as much precision of the significant part of a as a REAL(16) value
can contain.
If a is of type complex, the result has as much precision of the significant part of the real part of a as a
REAL(16) value can contain.
INTEGER(1) REAL(16)
INTEGER(2) REAL(16)
INTEGER(4) REAL(16)
INTEGER(8) REAL(16)
REAL(16) REAL(16)
COMPLEX(4) REAL(16)
COMPLEX(8) REAL(16)
COMPLEX(16) REAL(16)
1These specific functions cannot be passed as actual arguments.
Example
QEXT (4) has the value 4.0 (rounded; there are 32 places to the right of the decimal point).
QEXT ((3.4, 2.0)) has the value 3.4 (rounded; there are 32 places to the right of the decimal point).
QFLOAT
Elemental Intrinsic Function (Generic): Converts
an integer to quad precision (REAL(16)) type.
Syntax
result = QFLOAT (a)
Results
The result type is REAL(16) (REAL*16).
2009
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Functions that cause conversion of one data type to another type have the same affect as the implied
conversion in assignment statements.
Example
QFLOAT (-4) has the value -4.0 (rounded; there are 32 places to the right of the decimal point).
QNUM
Elemental Intrinsic Function (Specific): Converts
a character string to a REAL(16) value. This function
cannot be passed as an actual argument.
Syntax
result = QNUM (i)
Results
The result type is REAL(16). The result value is the real value represented by the character string i.
Example
QNUM ("-174.23") has the value -174.23 of type REAL(16).
QRANSET
Portability Subroutine: Sets the seed for a
sequence of pseudo-random numbers.
Module
USE IFPORT
Syntax
CALL QRANSET (rseed)
QREAL
Elemental Intrinsic Function (Specific): Converts
the real part of a COMPLEX(16) argument to REAL(16)
type. This is a specific function that has no generic
function associated with it. It cannot be passed as an
actual argument.
Syntax
result = QREAL (a)
Results
The result type is quad-precision real (REAL(16) or REAL*16).
2010
Language Reference
Example
QREAL ((2.0q0, 3.0q0)) has the value 2.0q0.
See Also
REAL
DREAL
QSORT
Portability Subroutine: Performs a quick sort on an
array of rank one.
Module
USE IFPORT
Syntax
CALL QSORT (array,len,isize,compar)
2011
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
If you use QSORT with different data types, your program must have a USE IFPORT statement so that
all the calls work correctly. In addition, if you wish to use QSORT with a derived type or a type that is
not in the predefined interfaces, you must include an overload for the generic subroutine QSORT.
Examples of how to do this are in the portability module's source file, IFPORT.F90.
Example
2012
Language Reference
end interface
type(element_type) :: c(7)
size_of_array = size(c) ! 7
size_of_element = sizeof(c(1)) ! 16
2013
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
! Passing "element_type" objects, it's called first with the pair (1, <invalid>),
! and the second item has a address well before the beginning of "C".
!
implicit none
! Function result:
!
integer(2) :: OrderCharCI
! Locals:
!
character(10) :: c1L !} Local copies of c1 and c2.
character(10) :: c2L !}
write(*,*)'OrderCharCI, parameter C1 is "', c1%key, '" ', c1%data, ', len is ', len(c1%key)
write(*,*)' len_trim is ', len_trim(c1%key)
write(*,*) ' '
! SEGV on access to C2
!
write(*,*)'OrderCharCI, parameter C2 is "', c2%key, '" ', c2%data, ', len is ', len(c2%key)
write(*,*)' len_trim is ', len_trim(c2%key)
write(*,*) ' '
c1L = c1%key
c2L = c2%key
do i = 1, len_trim(C1L)
if ('a' <= C1L(i:i) .and. c1L(i:i) <= 'z') c1L(i:i) = char(ichar(c1L(i:i)) - ichar('a')
+ ichar('A'))
end do
do i = 1, len_trim(C2L)
if ('a' <= c2L(i:i) .and. c2L(i:i) <= 'z') c2L(i:i) = char(ichar(c2L(i:i)) - ichar('a')
+ ichar('A'))
end do
if (c1L == c2L) Then
OrderCharCI = 0
write(*,*) ' - equal'
else if (c1L < c2L) Then
OrderCharCI = -1
write(*,*) ' - c1 is less'
else
OrderCharCI = 1
write(*,*) ' - c1 is more'
end if
end function OrderCharCI
2014
Language Reference
PROGRAM SORTQ
use, intrinsic :: iso_c_binding, only: c_size_t
use IFPORT
integer(2), external :: cmp_function
integer(2) insort(26), i
integer (C_SIZE_T) array_len, array_size
array_len = 26
array_size = 2
do i=90,65,-1
insort(i-64)=91 - i
end do
print *, "Before: "
print *,insort
CALL qsort(insort,array_len,array_size,cmp_function)
print *, 'After: '
print *, insort
END
!
integer(2) function cmp_function(a1, a2)
integer(2) a1, a2
cmp_function=a1-a2
end function
RADIX
Inquiry Intrinsic Function (Generic): Returns the
base of the model representing numbers of the same
type and kind as the argument.
Syntax
result = RADIX (x)
Results
The result is a scalar of type default integer. For an integer argument, the result has the value r (as defined
in Model for Integer Data). For a real argument, the result has the value b (as defined in Model for Real
Data).
Example
If X is a REAL(4) value, RADIX (X) has the value 2.
See Also
DIGITS
EXPONENT
FRACTION
Data Representation Models
RAISEQQ
Portability Function: Sends a signal to the executing
program.
2015
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Module
USE IFPORT
Syntax
result = RAISEQQ (sig)
If you do not install a signal handler (with SIGNALQQ, for example), when a signal occurs the system by
default terminates the program with exit code 3.
Results
The result type is INTEGER(4). The result is zero if successful; otherwise, nonzero.
If a signal-handling routine for sig has been installed by a prior call to SIGNALQQ, RAISEQQ causes that
routine to be executed. If no handler routine has been installed, the system terminates the program (the
default action).
See Also
SIGNALQQ
SIGNAL
KILL
RAN
Nonelemental Intrinsic Function (Specific):
Returns the next number from a sequence of
pseudorandom numbers of uniform distribution over
the range 0 to 1. This is a specific function that has no
generic function associated with it. It cannot be
passed as an actual argument.
Syntax
result = RAN (i)
Results
The result type is REAL(4). The result is a floating-point number that is uniformly distributed in the range
between 0.0 inclusive and 1.0 exclusive. The result is set equal to the value associated with the argument i.
2016
Language Reference
Example
In RAN (I), if variable I has the value 3, RAN has the value 4.8220158E-05.
See Also
RANDOM
RANDOM_NUMBER
RAND, RANDOM
Portability Functions: Return real random numbers
in the range 0.0 to 1.0, not including the end points.
Module
USE IFPORT
Syntax
result = RAND ([ iflag])
result = RANDOM (iflag)
iflag (Input) INTEGER(4). Optional for RAND. Controls the way the random
number is selected.
Results
The result type is REAL(4). RAND and RANDOM return random numbers in the range 0.0 to 1.0, not including
the end points.
NOTE
RANDOM is available as a function or subroutine.
2017
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
The following example shows how to use both the RANDOM function and the RANDOM subroutine:
use ifport
real(4) ranval
call seed(1995) ! initialize
call random(ranval) ! get next random number
print *,ranval
print *,ranval
end
See Also
RANDOM_INIT
RANDOM_NUMBER
RANDOM_SEED
SRAND
RANDOM Subroutine
Portability Subroutine: Returns a pseudorandom
number greater than or equal to zero and less than
one from the uniform distribution.
Module
USE IFPORT
Syntax
CALL RANDOM (ranval)
A given seed always produces the same sequence of values from RANDOM.
If SEED is not called before the first call to RANDOM, RANDOM begins with a seed value of one. If a program
must have a different pseudorandom sequence each time it runs, pass the constant RND$TIMESEED (defined
in IFCORE.F90) to SEED before the first call to RANDOM.
The portability routines DRAND, DRANDM, IRAND, IRANDM, RAN, RAND, and the RANDOM portability
function and subroutine use the same algorithms and thus return the same answers. They are all compatible
and can be used interchangeably. The algorithm used is a "Prime Modulus M Multiplicative Linear
Congruential Generator," a modified version of the random number generator by Park and Miller in "Random
Number Generators: Good Ones Are Hard to Find," CACM, October 1988, Vol. 31, No. 10.
Example
USE IFPORT
REAL(4) ran
CALL SEED(1995)
CALL RANDOM(ran)
2018
Language Reference
The following example shows how to use both the RANDOM subroutine and the RANDOM function:
use ifport
real(4) ranval
! from libifcore.lib
call seed(1995) ! initialize
! also from for_m_irand.c in libfor
call random(ranval) ! get next random number
print *,ranval
! from libifport.lib
ranval = random(1) ! initialize
! same
ranval = random(0) ! get next random number
print *,ranval
end
See Also
RANDOM_NUMBER
SEED
DRAND and DRANDM
IRAND and IRANDM
RAN
RAND
RANDOM_INIT
Intrinsic Subroutine: Initializes the pseudorandom
number generator used by RANDOM_NUMBER.
Syntax
CALL RANDOM_INIT (repeatable, image_distinct)
If repeatable has the value .true. and image_distinct has the value .true., the effect of a call to
RANDOM_INIT is equivalent to calling RANDOM_SEED with a different processor-dependent value of PUT on
each image that executes the call. If the invoking image index on the initial team is the same, the value of
PUT is the same each time the program is executed.
If repeatable has the value .true. and image_distinct has the value .false., the effect of a call to
RANDOM_INIT is equivalent to calling RANDOM_SEED with the same processor-dependent value of PUT on
each image that executes the call. If the invoking image index on the initial team is the same, the value of
PUT is the same each time the program is executed.
If repeatable has the value .false. and image_distinct has the value .true., the effect of a call to
RANDOM_INIT is equivalent to calling RANDOM_SEED with a different processor-dependent value of PUT on
each image that executes the call. If the invoking image index on the initial team is the same, the value of
PUT is different each time the program is executed.
If repeatable has the value .false. and image_distinct has the value .false., the effect of a call to
RANDOM_INIT is equivalent to calling RANDOM_SEED with the same processor-dependent value of PUT on
each image that executes the call. If the invoking image index on the initial team is the same, the value of
PUT is the different each time the program is executed.
2019
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
Consider the following:
PROGRAM main
REAL,DIMENSION(1000) :: y
CALL RANDOM_INIT (REPEATABLE=.TRUE., IMAGE_DISTINCT=.TRUE.)
CALL RANDOM_NUMBER (y)
. . .
END
After executing the above code, the array y contains a different sequence of pseudorandom numbers on each
image that executes the code. If the program is executed multiple times, for an image that has the same
image index in the initial team, the value of y is the same each time the program is run.
Consider another example:
PROGRAM main
REAL,DIMENSION(1000) :: y
CALL RANDOM_INIT (REPEATABLE=.FALSE., IMAGE_DISTINCT=.FALSE.)
CALL RANDOM_NUMBER (y)
. . .
END
After executing the above code, the array y contains the same sequence of pseudorandom numbers on each
image that executes the code. If the program is executed multiple times, the value of y is different each time
the program is run.
See Also
RANDOM_NUMBER
RANDOM_SEED
RANDOM
SEED
DRAND and DRANDM
IRAND and IRANDM
RAN
RAND and RANDOM
RANDOM_NUMBER
Intrinsic Subroutine: Returns one pseudorandom
number or an array of such numbers.
Syntax
CALL RANDOM_NUMBER (harvest)