]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/fortran/intrinsic.texi
Update Copyright years for files modified in 2011 and/or 2012.
[thirdparty/gcc.git] / gcc / fortran / intrinsic.texi
CommitLineData
56327b76 1@ignore
71e45bc2 2Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
56327b76 3Free Software Foundation, Inc.
61156d26 4This is part of the GNU Fortran manual.
56327b76 5For copying conditions, see the file gfortran.texi.
6
7Permission is granted to copy, distribute and/or modify this document
2d0c81dc 8under the terms of the GNU Free Documentation License, Version 1.3 or
56327b76 9any later version published by the Free Software Foundation; with the
a4cb9727 10Invariant Sections being ``Funding Free Software'', the Front-Cover
11Texts being (a) (see below), and with the Back-Cover Texts being (b)
12(see below). A copy of the license is included in the gfdl(7) man page.
56327b76 13
14
15Some basic guidelines for editing this document:
16
17 (1) The intrinsic procedures are to be listed in alphabetical order.
2e3f30e8 18 (2) The generic name is to be used.
56327b76 19 (3) The specific names are included in the function index and in a
20 table at the end of the node (See ABS entry).
21 (4) Try to maintain the same style for each entry.
22
23
24@end ignore
25
ed8f9044 26@tex
27\gdef\acos{\mathop{\rm acos}\nolimits}
28\gdef\asin{\mathop{\rm asin}\nolimits}
29\gdef\atan{\mathop{\rm atan}\nolimits}
30\gdef\acosh{\mathop{\rm acosh}\nolimits}
31\gdef\asinh{\mathop{\rm asinh}\nolimits}
32\gdef\atanh{\mathop{\rm atanh}\nolimits}
33@end tex
34
35
56327b76 36@node Intrinsic Procedures
37@chapter Intrinsic Procedures
5e246457 38@cindex intrinsic procedures
56327b76 39
56327b76 40@menu
07ebdb45 41* Introduction: Introduction to Intrinsics
bb3d0c30 42* @code{ABORT}: ABORT, Abort the program
43* @code{ABS}: ABS, Absolute value
a5f53fac 44* @code{ACCESS}: ACCESS, Checks file access modes
bb3d0c30 45* @code{ACHAR}: ACHAR, Character in @acronym{ASCII} collating sequence
a3c4ed23 46* @code{ACOS}: ACOS, Arccosine function
a08bb357 47* @code{ACOSH}: ACOSH, Inverse hyperbolic cosine function
bb3d0c30 48* @code{ADJUSTL}: ADJUSTL, Left adjust a string
49* @code{ADJUSTR}: ADJUSTR, Right adjust a string
50* @code{AIMAG}: AIMAG, Imaginary part of complex number
51* @code{AINT}: AINT, Truncate to a whole number
247981ce 52* @code{ALARM}: ALARM, Set an alarm clock
bb3d0c30 53* @code{ALL}: ALL, Determine if all values are true
54* @code{ALLOCATED}: ALLOCATED, Status of allocatable entity
ed8f9044 55* @code{AND}: AND, Bitwise logical AND
bb3d0c30 56* @code{ANINT}: ANINT, Nearest whole number
57* @code{ANY}: ANY, Determine if any values are true
58* @code{ASIN}: ASIN, Arcsine function
a08bb357 59* @code{ASINH}: ASINH, Inverse hyperbolic sine function
bb3d0c30 60* @code{ASSOCIATED}: ASSOCIATED, Status of a pointer or pointer/target pair
61* @code{ATAN}: ATAN, Arctangent function
62* @code{ATAN2}: ATAN2, Arctangent function
a08bb357 63* @code{ATANH}: ATANH, Inverse hyperbolic tangent function
6ccde1eb 64* @code{ATOMIC_DEFINE}: ATOMIC_DEFINE, Setting a variable atomically
65* @code{ATOMIC_REF}: ATOMIC_REF, Obtaining the value of a variable atomically
899edbae 66* @code{BACKTRACE}: BACKTRACE, Show a backtrace
ff4425cf 67* @code{BESSEL_J0}: BESSEL_J0, Bessel function of the first kind of order 0
68* @code{BESSEL_J1}: BESSEL_J1, Bessel function of the first kind of order 1
69* @code{BESSEL_JN}: BESSEL_JN, Bessel function of the first kind
70* @code{BESSEL_Y0}: BESSEL_Y0, Bessel function of the second kind of order 0
71* @code{BESSEL_Y1}: BESSEL_Y1, Bessel function of the second kind of order 1
72* @code{BESSEL_YN}: BESSEL_YN, Bessel function of the second kind
f004c7aa 73* @code{BGE}: BGE, Bitwise greater than or equal to
74* @code{BGT}: BGT, Bitwise greater than
bb3d0c30 75* @code{BIT_SIZE}: BIT_SIZE, Bit size inquiry function
f004c7aa 76* @code{BLE}: BLE, Bitwise less than or equal to
77* @code{BLT}: BLT, Bitwise less than
bb3d0c30 78* @code{BTEST}: BTEST, Bit test function
10e232cd 79* @code{C_ASSOCIATED}: C_ASSOCIATED, Status of a C pointer
80* @code{C_F_POINTER}: C_F_POINTER, Convert C into Fortran pointer
81* @code{C_F_PROCPOINTER}: C_F_PROCPOINTER, Convert C into Fortran procedure pointer
82* @code{C_FUNLOC}: C_FUNLOC, Obtain the C address of a procedure
83* @code{C_LOC}: C_LOC, Obtain the C address of an object
189ffda5 84* @code{C_SIZEOF}: C_SIZEOF, Size in bytes of an expression
bb3d0c30 85* @code{CEILING}: CEILING, Integer ceiling function
572d7b7f 86* @code{CHAR}: CHAR, Integer-to-character conversion function
a3c4ed23 87* @code{CHDIR}: CHDIR, Change working directory
88* @code{CHMOD}: CHMOD, Change access permissions of files
bb3d0c30 89* @code{CMPLX}: CMPLX, Complex conversion function
666bf11e 90* @code{COMMAND_ARGUMENT_COUNT}: COMMAND_ARGUMENT_COUNT, Get number of command line arguments
57f524d7 91* @code{COMPLEX}: COMPLEX, Complex conversion function
e3d1ab2b 92* @code{COMPILER_VERSION}: COMPILER_VERSION, Compiler version string
93* @code{COMPILER_OPTIONS}: COMPILER_OPTIONS, Options passed to the compiler
4e7aa3fa 94* @code{CONJG}: CONJG, Complex conjugate function
bb3d0c30 95* @code{COS}: COS, Cosine function
96* @code{COSH}: COSH, Hyperbolic cosine function
ed8f9044 97* @code{COUNT}: COUNT, Count occurrences of TRUE in an array
4e7aa3fa 98* @code{CPU_TIME}: CPU_TIME, CPU time subroutine
a1149005 99* @code{CSHIFT}: CSHIFT, Circular shift elements of an array
b902b078 100* @code{CTIME}: CTIME, Subroutine (or function) to convert a time into a string
4e7aa3fa 101* @code{DATE_AND_TIME}: DATE_AND_TIME, Date and time subroutine
20d81f06 102* @code{DBLE}: DBLE, Double precision conversion function
103* @code{DCMPLX}: DCMPLX, Double complex conversion function
20d81f06 104* @code{DIGITS}: DIGITS, Significant digits function
a1149005 105* @code{DIM}: DIM, Positive difference
20d81f06 106* @code{DOT_PRODUCT}: DOT_PRODUCT, Dot product function
107* @code{DPROD}: DPROD, Double product function
108* @code{DREAL}: DREAL, Double real part function
f004c7aa 109* @code{DSHIFTL}: DSHIFTL, Combined left shift
110* @code{DSHIFTR}: DSHIFTR, Combined right shift
20d81f06 111* @code{DTIME}: DTIME, Execution time subroutine (or function)
a1149005 112* @code{EOSHIFT}: EOSHIFT, End-off shift elements of an array
c656b4ab 113* @code{EPSILON}: EPSILON, Epsilon function
bb3d0c30 114* @code{ERF}: ERF, Error function
115* @code{ERFC}: ERFC, Complementary error function
ff4425cf 116* @code{ERFC_SCALED}: ERFC_SCALED, Exponentially-scaled complementary error function
c656b4ab 117* @code{ETIME}: ETIME, Execution time subroutine (or function)
fe2de951 118* @code{EXECUTE_COMMAND_LINE}: EXECUTE_COMMAND_LINE, Execute a shell command
c656b4ab 119* @code{EXIT}: EXIT, Exit the program with status.
2c5b695e 120* @code{EXP}: EXP, Exponential function
121* @code{EXPONENT}: EXPONENT, Exponent function
24c079ad 122* @code{EXTENDS_TYPE_OF}: EXTENDS_TYPE_OF, Query dynamic type for extension
b902b078 123* @code{FDATE}: FDATE, Subroutine (or function) to get the current time as a string
ed8f9044 124* @code{FGET}: FGET, Read a single character in stream mode from stdin
a3c4ed23 125* @code{FGETC}: FGETC, Read a single character in stream mode
2c5b695e 126* @code{FLOOR}: FLOOR, Integer floor function
572d7b7f 127* @code{FLUSH}: FLUSH, Flush I/O unit(s)
2c5b695e 128* @code{FNUM}: FNUM, File number function
ed8f9044 129* @code{FPUT}: FPUT, Write a single character in stream mode to stdout
a3c4ed23 130* @code{FPUTC}: FPUTC, Write a single character in stream mode
572d7b7f 131* @code{FRACTION}: FRACTION, Fractional part of the model representation
b3d3a366 132* @code{FREE}: FREE, Memory de-allocation subroutine
a3c4ed23 133* @code{FSEEK}: FSEEK, Low level file positioning subroutine
134* @code{FSTAT}: FSTAT, Get file status
135* @code{FTELL}: FTELL, Current stream position
95b66823 136* @code{GAMMA}: GAMMA, Gamma function
475c7d78 137* @code{GERROR}: GERROR, Get last system error message
a3c4ed23 138* @code{GETARG}: GETARG, Get command line arguments
666bf11e 139* @code{GET_COMMAND}: GET_COMMAND, Get the entire command line
140* @code{GET_COMMAND_ARGUMENT}: GET_COMMAND_ARGUMENT, Get command line arguments
a3c4ed23 141* @code{GETCWD}: GETCWD, Get current working directory
142* @code{GETENV}: GETENV, Get an environmental variable
143* @code{GET_ENVIRONMENT_VARIABLE}: GET_ENVIRONMENT_VARIABLE, Get an environmental variable
572d7b7f 144* @code{GETGID}: GETGID, Group ID function
a3c4ed23 145* @code{GETLOG}: GETLOG, Get login name
572d7b7f 146* @code{GETPID}: GETPID, Process ID function
147* @code{GETUID}: GETUID, User ID function
a3c4ed23 148* @code{GMTIME}: GMTIME, Convert time to GMT info
149* @code{HOSTNM}: HOSTNM, Get system host name
572d7b7f 150* @code{HUGE}: HUGE, Largest number of a kind
5f7aa0fe 151* @code{HYPOT}: HYPOT, Euclidean distance function
572d7b7f 152* @code{IACHAR}: IACHAR, Code in @acronym{ASCII} collating sequence
9028d57d 153* @code{IALL}: IALL, Bitwise AND of array elements
a3c4ed23 154* @code{IAND}: IAND, Bitwise logical and
9028d57d 155* @code{IANY}: IANY, Bitwise OR of array elements
666bf11e 156* @code{IARGC}: IARGC, Get the number of command line arguments
a3c4ed23 157* @code{IBCLR}: IBCLR, Clear bit
158* @code{IBITS}: IBITS, Bit extraction
159* @code{IBSET}: IBSET, Set bit
572d7b7f 160* @code{ICHAR}: ICHAR, Character-to-integer conversion function
a8a6baf6 161* @code{IDATE}: IDATE, Current local time (day/month/year)
a3c4ed23 162* @code{IEOR}: IEOR, Bitwise logical exclusive or
163* @code{IERRNO}: IERRNO, Function to get the last system error number
5f7aa0fe 164* @code{IMAGE_INDEX}: IMAGE_INDEX, Cosubscript to image index conversion
70dabb1d 165* @code{INDEX}: INDEX intrinsic, Position of a substring within a string
a3c4ed23 166* @code{INT}: INT, Convert to integer type
fe97b755 167* @code{INT2}: INT2, Convert to 16-bit integer type
168* @code{INT8}: INT8, Convert to 64-bit integer type
a3c4ed23 169* @code{IOR}: IOR, Bitwise logical or
9028d57d 170* @code{IPARITY}: IPARITY, Bitwise XOR of array elements
572d7b7f 171* @code{IRAND}: IRAND, Integer pseudo-random number
52ed1096 172* @code{IS_IOSTAT_END}: IS_IOSTAT_END, Test for end-of-file value
173* @code{IS_IOSTAT_EOR}: IS_IOSTAT_EOR, Test for end-of-record value
475c7d78 174* @code{ISATTY}: ISATTY, Whether a unit is a terminal device
a3c4ed23 175* @code{ISHFT}: ISHFT, Shift bits
176* @code{ISHFTC}: ISHFTC, Shift bits circularly
4e549567 177* @code{ISNAN}: ISNAN, Tests for a NaN
a8a6baf6 178* @code{ITIME}: ITIME, Current local time (hour/minutes/seconds)
a3c4ed23 179* @code{KILL}: KILL, Send a signal to a process
572d7b7f 180* @code{KIND}: KIND, Kind of an entity
a3c4ed23 181* @code{LBOUND}: LBOUND, Lower dimension bounds of an array
a250d560 182* @code{LCOBOUND}: LCOBOUND, Lower codimension bounds of an array
0b820f43 183* @code{LEADZ}: LEADZ, Number of leading zero bits of an integer
a3c4ed23 184* @code{LEN}: LEN, Length of a character entity
185* @code{LEN_TRIM}: LEN_TRIM, Length of a character entity without trailing blank characters
186* @code{LGE}: LGE, Lexical greater than or equal
187* @code{LGT}: LGT, Lexical greater than
188* @code{LINK}: LINK, Create a hard link
189* @code{LLE}: LLE, Lexical less than or equal
190* @code{LLT}: LLT, Lexical less than
191* @code{LNBLNK}: LNBLNK, Index of the last non-blank character in a string
b549d2a5 192* @code{LOC}: LOC, Returns the address of a variable
bb3d0c30 193* @code{LOG}: LOG, Logarithm function
194* @code{LOG10}: LOG10, Base 10 logarithm function
2cd8ef8b 195* @code{LOG_GAMMA}: LOG_GAMMA, Logarithm of the Gamma function
a3c4ed23 196* @code{LOGICAL}: LOGICAL, Convert to logical type
fe97b755 197* @code{LONG}: LONG, Convert to integer type
a3c4ed23 198* @code{LSHIFT}: LSHIFT, Left shift bits
666bf11e 199* @code{LSTAT}: LSTAT, Get file status
a3c4ed23 200* @code{LTIME}: LTIME, Convert time to local time info
b3d3a366 201* @code{MALLOC}: MALLOC, Dynamic memory allocation function
f004c7aa 202* @code{MASKL}: MASKL, Left justified mask
203* @code{MASKR}: MASKR, Right justified mask
a3c4ed23 204* @code{MATMUL}: MATMUL, matrix multiplication
205* @code{MAX}: MAX, Maximum value of an argument list
572d7b7f 206* @code{MAXEXPONENT}: MAXEXPONENT, Maximum exponent of a real kind
a3c4ed23 207* @code{MAXLOC}: MAXLOC, Location of the maximum value within an array
208* @code{MAXVAL}: MAXVAL, Maximum value of an array
fe97b755 209* @code{MCLOCK}: MCLOCK, Time function
210* @code{MCLOCK8}: MCLOCK8, Time function (64-bit)
a3c4ed23 211* @code{MERGE}: MERGE, Merge arrays
f004c7aa 212* @code{MERGE_BITS}: MERGE_BITS, Merge of bits under mask
a3c4ed23 213* @code{MIN}: MIN, Minimum value of an argument list
572d7b7f 214* @code{MINEXPONENT}: MINEXPONENT, Minimum exponent of a real kind
a3c4ed23 215* @code{MINLOC}: MINLOC, Location of the minimum value within an array
216* @code{MINVAL}: MINVAL, Minimum value of an array
572d7b7f 217* @code{MOD}: MOD, Remainder function
218* @code{MODULO}: MODULO, Modulo function
2294b616 219* @code{MOVE_ALLOC}: MOVE_ALLOC, Move allocation from one object to another
a3c4ed23 220* @code{MVBITS}: MVBITS, Move bits from one integer to another
572d7b7f 221* @code{NEAREST}: NEAREST, Nearest representable number
f4b3b5f4 222* @code{NEW_LINE}: NEW_LINE, New line character
572d7b7f 223* @code{NINT}: NINT, Nearest whole number
b4ba8232 224* @code{NORM2}: NORM2, Euclidean vector norm
a3c4ed23 225* @code{NOT}: NOT, Logical negation
ed8f9044 226* @code{NULL}: NULL, Function that returns an disassociated pointer
c6cd3066 227* @code{NUM_IMAGES}: NUM_IMAGES, Number of images
ed8f9044 228* @code{OR}: OR, Bitwise logical OR
a3c4ed23 229* @code{PACK}: PACK, Pack an array into an array of rank one
b4ba8232 230* @code{PARITY}: PARITY, Reduction with exclusive OR
a3c4ed23 231* @code{PERROR}: PERROR, Print system error message
41cbc93c 232* @code{POPCNT}: POPCNT, Number of bits set
233* @code{POPPAR}: POPPAR, Parity of the number of bits set
572d7b7f 234* @code{PRECISION}: PRECISION, Decimal precision of a real kind
8873d8a6 235* @code{PRESENT}: PRESENT, Determine whether an optional dummy argument is specified
a3c4ed23 236* @code{PRODUCT}: PRODUCT, Product of array elements
572d7b7f 237* @code{RADIX}: RADIX, Base of a data model
a3c4ed23 238* @code{RANDOM_NUMBER}: RANDOM_NUMBER, Pseudo-random number
239* @code{RANDOM_SEED}: RANDOM_SEED, Initialize a pseudo-random number sequence
572d7b7f 240* @code{RAND}: RAND, Real pseudo-random number
67bc85bf 241* @code{RANGE}: RANGE, Decimal exponent range
b3a2ccd7 242* @code{RANK} : RANK, Rank of a data object
a3c4ed23 243* @code{RAN}: RAN, Real pseudo-random number
a7d25c4a 244* @code{REAL}: REAL, Convert to real type
a3c4ed23 245* @code{RENAME}: RENAME, Rename a file
246* @code{REPEAT}: REPEAT, Repeated string concatenation
247* @code{RESHAPE}: RESHAPE, Function to reshape an array
572d7b7f 248* @code{RRSPACING}: RRSPACING, Reciprocal of the relative spacing
a3c4ed23 249* @code{RSHIFT}: RSHIFT, Right shift bits
24c079ad 250* @code{SAME_TYPE_AS}: SAME_TYPE_AS, Query dynamic types for equality
572d7b7f 251* @code{SCALE}: SCALE, Scale a real value
a3c4ed23 252* @code{SCAN}: SCAN, Scan a string for the presence of a set of characters
10387833 253* @code{SECNDS}: SECNDS, Time function
fe97b755 254* @code{SECOND}: SECOND, CPU time function
59e2a584 255* @code{SELECTED_CHAR_KIND}: SELECTED_CHAR_KIND, Choose character kind
572d7b7f 256* @code{SELECTED_INT_KIND}: SELECTED_INT_KIND, Choose integer kind
257* @code{SELECTED_REAL_KIND}: SELECTED_REAL_KIND, Choose real kind
258* @code{SET_EXPONENT}: SET_EXPONENT, Set the exponent of the model
a3c4ed23 259* @code{SHAPE}: SHAPE, Determine the shape of an array
f004c7aa 260* @code{SHIFTA}: SHIFTA, Right shift with fill
261* @code{SHIFTL}: SHIFTL, Left shift
262* @code{SHIFTR}: SHIFTR, Right shift
572d7b7f 263* @code{SIGN}: SIGN, Sign copying function
247981ce 264* @code{SIGNAL}: SIGNAL, Signal handling subroutine (or function)
bb3d0c30 265* @code{SIN}: SIN, Sine function
266* @code{SINH}: SINH, Hyperbolic sine function
a3c4ed23 267* @code{SIZE}: SIZE, Function to determine the size of an array
1318f16c 268* @code{SIZEOF}: SIZEOF, Determine the size in bytes of an expression
5309bf0b 269* @code{SLEEP}: SLEEP, Sleep for the specified number of seconds
a3c4ed23 270* @code{SPACING}: SPACING, Smallest distance between two numbers of a given type
271* @code{SPREAD}: SPREAD, Add a dimension to an array
247981ce 272* @code{SQRT}: SQRT, Square-root function
572d7b7f 273* @code{SRAND}: SRAND, Reinitialize the random number generator
a3c4ed23 274* @code{STAT}: STAT, Get file status
24c079ad 275* @code{STORAGE_SIZE}: STORAGE_SIZE, Storage size in bits
a3c4ed23 276* @code{SUM}: SUM, Sum of array elements
277* @code{SYMLNK}: SYMLNK, Create a symbolic link
278* @code{SYSTEM}: SYSTEM, Execute a shell command
279* @code{SYSTEM_CLOCK}: SYSTEM_CLOCK, Time function
bb3d0c30 280* @code{TAN}: TAN, Tangent function
281* @code{TANH}: TANH, Hyperbolic tangent function
a250d560 282* @code{THIS_IMAGE}: THIS_IMAGE, Cosubscript index of this image
a3c4ed23 283* @code{TIME}: TIME, Time function
0eb92d52 284* @code{TIME8}: TIME8, Time function (64-bit)
572d7b7f 285* @code{TINY}: TINY, Smallest positive number of a real kind
0b820f43 286* @code{TRAILZ}: TRAILZ, Number of trailing zero bits of an integer
a3c4ed23 287* @code{TRANSFER}: TRANSFER, Transfer bit patterns
288* @code{TRANSPOSE}: TRANSPOSE, Transpose an array of rank two
8873d8a6 289* @code{TRIM}: TRIM, Remove trailing blank characters of a string
475c7d78 290* @code{TTYNAM}: TTYNAM, Get the name of a terminal device.
a3c4ed23 291* @code{UBOUND}: UBOUND, Upper dimension bounds of an array
a250d560 292* @code{UCOBOUND}: UCOBOUND, Upper codimension bounds of an array
a3c4ed23 293* @code{UMASK}: UMASK, Set the file creation mask
294* @code{UNLINK}: UNLINK, Remove a file from the file system
a3c4ed23 295* @code{UNPACK}: UNPACK, Unpack an array of rank one into an array
296* @code{VERIFY}: VERIFY, Scan a string for the absence of a set of characters
ed8f9044 297* @code{XOR}: XOR, Bitwise logical exclusive or
56327b76 298@end menu
299
07ebdb45 300@node Introduction to Intrinsics
56327b76 301@section Introduction to intrinsic procedures
302
ae03e2bc 303The intrinsic procedures provided by GNU Fortran include all of the
304intrinsic procedures required by the Fortran 95 standard, a set of
ff4425cf 305intrinsic procedures for backwards compatibility with G77, and a
306selection of intrinsic procedures from the Fortran 2003 and Fortran 2008
307standards. Any conflict between a description here and a description in
308either the Fortran 95 standard, the Fortran 2003 standard or the Fortran
3092008 standard is unintentional, and the standard(s) should be considered
310authoritative.
56327b76 311
312The enumeration of the @code{KIND} type parameter is processor defined in
61156d26 313the Fortran 95 standard. GNU Fortran defines the default integer type and
56327b76 314default real type by @code{INTEGER(KIND=4)} and @code{REAL(KIND=4)},
315respectively. The standard mandates that both data types shall have
316another kind, which have more precision. On typical target architectures
20d81f06 317supported by @command{gfortran}, this kind type parameter is @code{KIND=8}.
56327b76 318Hence, @code{REAL(KIND=8)} and @code{DOUBLE PRECISION} are equivalent.
319In the description of generic intrinsic procedures, the kind type parameter
320will be specified by @code{KIND=*}, and in the description of specific
321names for an intrinsic procedure the kind type parameter will be explicitly
322given (e.g., @code{REAL(KIND=4)} or @code{REAL(KIND=8)}). Finally, for
323brevity the optional @code{KIND=} syntax will be omitted.
324
96a252c6 325Many of the intrinsic procedures take one or more optional arguments.
56327b76 326This document follows the convention used in the Fortran 95 standard,
327and denotes such arguments by square brackets.
328
61156d26 329GNU Fortran offers the @option{-std=f95} and @option{-std=gnu} options,
56327b76 330which can be used to restrict the set of intrinsic procedures to a
331given standard. By default, @command{gfortran} sets the @option{-std=gnu}
20d81f06 332option, and so all intrinsic procedures described here are accepted. There
56327b76 333is one caveat. For a select group of intrinsic procedures, @command{g77}
334implemented both a function and a subroutine. Both classes
335have been implemented in @command{gfortran} for backwards compatibility
336with @command{g77}. It is noted here that these functions and subroutines
337cannot be intermixed in a given subprogram. In the descriptions that follow,
2e3f30e8 338the applicable standard for each intrinsic procedure is noted.
339
56327b76 340
341
dc820f84 342@node ABORT
a1149005 343@section @code{ABORT} --- Abort the program
344@fnindex ABORT
345@cindex program termination, with core dump
346@cindex terminate program, with core dump
347@cindex core, dump
56327b76 348
349@table @asis
350@item @emph{Description}:
351@code{ABORT} causes immediate termination of the program. On operating
b2130263 352systems that support a core dump, @code{ABORT} will produce a core dump.
899edbae 353It will also print a backtrace, unless @code{-fno-backtrace} is given.
56327b76 354
a3c4ed23 355@item @emph{Standard}:
356GNU extension
56327b76 357
bb3d0c30 358@item @emph{Class}:
138b8aca 359Subroutine
56327b76 360
361@item @emph{Syntax}:
362@code{CALL ABORT}
363
364@item @emph{Return value}:
365Does not return.
366
367@item @emph{Example}:
368@smallexample
369program test_abort
370 integer :: i = 1, j = 2
371 if (i /= j) call abort
372end program test_abort
373@end smallexample
a3c4ed23 374
375@item @emph{See also}:
899edbae 376@ref{EXIT}, @ref{KILL}, @ref{BACKTRACE}
a3c4ed23 377
56327b76 378@end table
379
380
fe97b755 381
dc820f84 382@node ABS
a1149005 383@section @code{ABS} --- Absolute value
384@fnindex ABS
385@fnindex CABS
386@fnindex DABS
387@fnindex IABS
388@fnindex ZABS
389@fnindex CDABS
56327b76 390@cindex absolute value
391
392@table @asis
393@item @emph{Description}:
e06f8026 394@code{ABS(A)} computes the absolute value of @code{A}.
56327b76 395
a3c4ed23 396@item @emph{Standard}:
f40b44c0 397Fortran 77 and later, has overloads that are GNU extensions
56327b76 398
bb3d0c30 399@item @emph{Class}:
a3c4ed23 400Elemental function
56327b76 401
402@item @emph{Syntax}:
e06f8026 403@code{RESULT = ABS(A)}
56327b76 404
405@item @emph{Arguments}:
aee612a9 406@multitable @columnfractions .15 .70
e06f8026 407@item @var{A} @tab The type of the argument shall be an @code{INTEGER},
408@code{REAL}, or @code{COMPLEX}.
56327b76 409@end multitable
410
411@item @emph{Return value}:
412The return value is of the same type and
e06f8026 413kind as the argument except the return value is @code{REAL} for a
414@code{COMPLEX} argument.
56327b76 415
416@item @emph{Example}:
417@smallexample
1ef88f15 418program test_abs
56327b76 419 integer :: i = -1
420 real :: x = -1.e0
421 complex :: z = (-1.e0,0.e0)
422 i = abs(i)
423 x = abs(x)
424 x = abs(z)
1ef88f15 425end program test_abs
56327b76 426@end smallexample
427
428@item @emph{Specific names}:
aee612a9 429@multitable @columnfractions .20 .20 .20 .25
a3c4ed23 430@item Name @tab Argument @tab Return type @tab Standard
7d74ce87 431@item @code{ABS(A)} @tab @code{REAL(4) A} @tab @code{REAL(4)} @tab Fortran 77 and later
432@item @code{CABS(A)} @tab @code{COMPLEX(4) A} @tab @code{REAL(4)} @tab Fortran 77 and later
433@item @code{DABS(A)} @tab @code{REAL(8) A} @tab @code{REAL(8)} @tab Fortran 77 and later
434@item @code{IABS(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab Fortran 77 and later
435@item @code{ZABS(A)} @tab @code{COMPLEX(8) A} @tab @code{COMPLEX(8)} @tab GNU extension
436@item @code{CDABS(A)} @tab @code{COMPLEX(8) A} @tab @code{COMPLEX(8)} @tab GNU extension
56327b76 437@end multitable
438@end table
439
440
fe97b755 441
a3c4ed23 442@node ACCESS
a5f53fac 443@section @code{ACCESS} --- Checks file access modes
a1149005 444@fnindex ACCESS
445@cindex file system, access mode
a3c4ed23 446
a3c4ed23 447@table @asis
448@item @emph{Description}:
a5f53fac 449@code{ACCESS(NAME, MODE)} checks whether the file @var{NAME}
450exists, is readable, writable or executable. Except for the
451executable check, @code{ACCESS} can be replaced by
452Fortran 95's @code{INQUIRE}.
a3c4ed23 453
454@item @emph{Standard}:
455GNU extension
456
457@item @emph{Class}:
a5f53fac 458Inquiry function
459
a3c4ed23 460@item @emph{Syntax}:
4eb41f08 461@code{RESULT = ACCESS(NAME, MODE)}
a5f53fac 462
a3c4ed23 463@item @emph{Arguments}:
aee612a9 464@multitable @columnfractions .15 .70
b44437b9 465@item @var{NAME} @tab Scalar @code{CHARACTER} of default kind with the
466file name. Tailing blank are ignored unless the character @code{achar(0)}
467is present, then all characters up to and excluding @code{achar(0)} are
a5f53fac 468used as file name.
b44437b9 469@item @var{MODE} @tab Scalar @code{CHARACTER} of default kind with the
470file access mode, may be any concatenation of @code{"r"} (readable),
471@code{"w"} (writable) and @code{"x"} (executable), or @code{" "} to check
472for existence.
a5f53fac 473@end multitable
474
a3c4ed23 475@item @emph{Return value}:
a5f53fac 476Returns a scalar @code{INTEGER}, which is @code{0} if the file is
2b9c8475 477accessible in the given mode; otherwise or if an invalid argument
a5f53fac 478has been given for @code{MODE} the value @code{1} is returned.
479
a3c4ed23 480@item @emph{Example}:
a5f53fac 481@smallexample
482program access_test
483 implicit none
484 character(len=*), parameter :: file = 'test.dat'
485 character(len=*), parameter :: file2 = 'test.dat '//achar(0)
486 if(access(file,' ') == 0) print *, trim(file),' is exists'
487 if(access(file,'r') == 0) print *, trim(file),' is readable'
488 if(access(file,'w') == 0) print *, trim(file),' is writable'
489 if(access(file,'x') == 0) print *, trim(file),' is executable'
490 if(access(file2,'rwx') == 0) &
491 print *, trim(file2),' is readable, writable and executable'
492end program access_test
493@end smallexample
a3c4ed23 494@item @emph{Specific names}:
495@item @emph{See also}:
a3c4ed23 496
497@end table
498
56327b76 499
fe97b755 500
dc820f84 501@node ACHAR
56327b76 502@section @code{ACHAR} --- Character in @acronym{ASCII} collating sequence
a1149005 503@fnindex ACHAR
56327b76 504@cindex @acronym{ASCII} collating sequence
a1149005 505@cindex collating sequence, @acronym{ASCII}
56327b76 506
507@table @asis
508@item @emph{Description}:
509@code{ACHAR(I)} returns the character located at position @code{I}
510in the @acronym{ASCII} collating sequence.
511
a3c4ed23 512@item @emph{Standard}:
f40b44c0 513Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later
56327b76 514
bb3d0c30 515@item @emph{Class}:
a3c4ed23 516Elemental function
56327b76 517
518@item @emph{Syntax}:
f40b44c0 519@code{RESULT = ACHAR(I [, KIND])}
56327b76 520
521@item @emph{Arguments}:
aee612a9 522@multitable @columnfractions .15 .70
e06f8026 523@item @var{I} @tab The type shall be @code{INTEGER}.
f40b44c0 524@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
c24c5fac 525expression indicating the kind parameter of the result.
56327b76 526@end multitable
527
528@item @emph{Return value}:
e06f8026 529The return value is of type @code{CHARACTER} with a length of one.
530If the @var{KIND} argument is present, the return value is of the
531specified kind and of the default kind otherwise.
56327b76 532
533@item @emph{Example}:
534@smallexample
535program test_achar
536 character c
537 c = achar(32)
1ef88f15 538end program test_achar
56327b76 539@end smallexample
c5cb0f03 540
e95fe2fe 541@item @emph{Note}:
542See @ref{ICHAR} for a discussion of converting between numerical values
543and formatted string representations.
544
c5cb0f03 545@item @emph{See also}:
546@ref{CHAR}, @ref{IACHAR}, @ref{ICHAR}
547
56327b76 548@end table
549
550
551
dc820f84 552@node ACOS
a3c4ed23 553@section @code{ACOS} --- Arccosine function
a1149005 554@fnindex ACOS
555@fnindex DACOS
556@cindex trigonometric function, cosine, inverse
557@cindex cosine, inverse
56327b76 558
559@table @asis
560@item @emph{Description}:
ed8f9044 561@code{ACOS(X)} computes the arccosine of @var{X} (inverse of @code{COS(X)}).
56327b76 562
a3c4ed23 563@item @emph{Standard}:
6f4274f9 564Fortran 77 and later, for a complex argument Fortran 2008 or later
56327b76 565
bb3d0c30 566@item @emph{Class}:
a3c4ed23 567Elemental function
56327b76 568
569@item @emph{Syntax}:
4eb41f08 570@code{RESULT = ACOS(X)}
56327b76 571
572@item @emph{Arguments}:
aee612a9 573@multitable @columnfractions .15 .70
6f4274f9 574@item @var{X} @tab The type shall either be @code{REAL} with a magnitude that is
575less than or equal to one - or the type shall be @code{COMPLEX}.
56327b76 576@end multitable
577
578@item @emph{Return value}:
6f4274f9 579The return value is of the same type and kind as @var{X}.
580The real part of the result is in radians and lies in the range
581@math{0 \leq \Re \acos(x) \leq \pi}.
56327b76 582
583@item @emph{Example}:
584@smallexample
585program test_acos
586 real(8) :: x = 0.866_8
a3c4ed23 587 x = acos(x)
56327b76 588end program test_acos
589@end smallexample
590
591@item @emph{Specific names}:
aee612a9 592@multitable @columnfractions .20 .20 .20 .25
7d74ce87 593@item Name @tab Argument @tab Return type @tab Standard
594@item @code{ACOS(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later
595@item @code{DACOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
56327b76 596@end multitable
a3c4ed23 597
598@item @emph{See also}:
599Inverse function: @ref{COS}
600
601@end table
602
603
fe97b755 604
a3c4ed23 605@node ACOSH
a08bb357 606@section @code{ACOSH} --- Inverse hyperbolic cosine function
a1149005 607@fnindex ACOSH
608@fnindex DACOSH
609@cindex area hyperbolic cosine
a08bb357 610@cindex inverse hyperbolic cosine
a1149005 611@cindex hyperbolic function, cosine, inverse
612@cindex cosine, hyperbolic, inverse
a3c4ed23 613
a3c4ed23 614@table @asis
615@item @emph{Description}:
a08bb357 616@code{ACOSH(X)} computes the inverse hyperbolic cosine of @var{X}.
ed8f9044 617
a3c4ed23 618@item @emph{Standard}:
ff4425cf 619Fortran 2008 and later
ed8f9044 620
a3c4ed23 621@item @emph{Class}:
ed8f9044 622Elemental function
623
a3c4ed23 624@item @emph{Syntax}:
4eb41f08 625@code{RESULT = ACOSH(X)}
ed8f9044 626
a3c4ed23 627@item @emph{Arguments}:
aee612a9 628@multitable @columnfractions .15 .70
ff4425cf 629@item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
ed8f9044 630@end multitable
631
a3c4ed23 632@item @emph{Return value}:
6f4274f9 633The return value has the same type and kind as @var{X}. If @var{X} is
634complex, the imaginary part of the result is in radians and lies between
635@math{ 0 \leq \Im \acosh(x) \leq \pi}.
ed8f9044 636
a3c4ed23 637@item @emph{Example}:
ed8f9044 638@smallexample
639PROGRAM test_acosh
640 REAL(8), DIMENSION(3) :: x = (/ 1.0, 2.0, 3.0 /)
641 WRITE (*,*) ACOSH(x)
642END PROGRAM
643@end smallexample
644
fe97b755 645@item @emph{Specific names}:
646@multitable @columnfractions .20 .20 .20 .25
647@item Name @tab Argument @tab Return type @tab Standard
648@item @code{DACOSH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
649@end multitable
650
a3c4ed23 651@item @emph{See also}:
652Inverse function: @ref{COSH}
56327b76 653@end table
654
dc820f84 655
656
657@node ADJUSTL
56327b76 658@section @code{ADJUSTL} --- Left adjust a string
a1149005 659@fnindex ADJUSTL
660@cindex string, adjust left
661@cindex adjust string
56327b76 662
663@table @asis
664@item @emph{Description}:
e06f8026 665@code{ADJUSTL(STRING)} will left adjust a string by removing leading spaces.
56327b76 666Spaces are inserted at the end of the string as needed.
667
a3c4ed23 668@item @emph{Standard}:
57b9ac90 669Fortran 90 and later
56327b76 670
bb3d0c30 671@item @emph{Class}:
a3c4ed23 672Elemental function
56327b76 673
674@item @emph{Syntax}:
e06f8026 675@code{RESULT = ADJUSTL(STRING)}
56327b76 676
677@item @emph{Arguments}:
aee612a9 678@multitable @columnfractions .15 .70
e06f8026 679@item @var{STRING} @tab The type shall be @code{CHARACTER}.
56327b76 680@end multitable
681
682@item @emph{Return value}:
b44437b9 683The return value is of type @code{CHARACTER} and of the same kind as
684@var{STRING} where leading spaces are removed and the same number of
685spaces are inserted on the end of @var{STRING}.
56327b76 686
687@item @emph{Example}:
688@smallexample
689program test_adjustl
690 character(len=20) :: str = ' gfortran'
691 str = adjustl(str)
692 print *, str
693end program test_adjustl
694@end smallexample
8873d8a6 695
696@item @emph{See also}:
697@ref{ADJUSTR}, @ref{TRIM}
56327b76 698@end table
699
700
bb3d0c30 701
dc820f84 702@node ADJUSTR
56327b76 703@section @code{ADJUSTR} --- Right adjust a string
a1149005 704@fnindex ADJUSTR
705@cindex string, adjust right
706@cindex adjust string
56327b76 707
708@table @asis
709@item @emph{Description}:
e06f8026 710@code{ADJUSTR(STRING)} will right adjust a string by removing trailing spaces.
56327b76 711Spaces are inserted at the start of the string as needed.
712
a3c4ed23 713@item @emph{Standard}:
f40b44c0 714Fortran 95 and later
56327b76 715
bb3d0c30 716@item @emph{Class}:
a3c4ed23 717Elemental function
56327b76 718
719@item @emph{Syntax}:
e06f8026 720@code{RESULT = ADJUSTR(STRING)}
56327b76 721
722@item @emph{Arguments}:
aee612a9 723@multitable @columnfractions .15 .70
56327b76 724@item @var{STR} @tab The type shall be @code{CHARACTER}.
725@end multitable
726
727@item @emph{Return value}:
b44437b9 728The return value is of type @code{CHARACTER} and of the same kind as
729@var{STRING} where trailing spaces are removed and the same number of
730spaces are inserted at the start of @var{STRING}.
56327b76 731
732@item @emph{Example}:
733@smallexample
734program test_adjustr
735 character(len=20) :: str = 'gfortran'
736 str = adjustr(str)
737 print *, str
738end program test_adjustr
739@end smallexample
8873d8a6 740
741@item @emph{See also}:
742@ref{ADJUSTL}, @ref{TRIM}
56327b76 743@end table
744
745
bb3d0c30 746
fb53528a 747@node AIMAG
748@section @code{AIMAG} --- Imaginary part of complex number
a1149005 749@fnindex AIMAG
750@fnindex DIMAG
751@fnindex IMAG
752@fnindex IMAGPART
753@cindex complex numbers, imaginary part
fb53528a 754
755@table @asis
756@item @emph{Description}:
757@code{AIMAG(Z)} yields the imaginary part of complex argument @code{Z}.
a7d25c4a 758The @code{IMAG(Z)} and @code{IMAGPART(Z)} intrinsic functions are provided
759for compatibility with @command{g77}, and their use in new code is
760strongly discouraged.
fb53528a 761
a3c4ed23 762@item @emph{Standard}:
f40b44c0 763Fortran 77 and later, has overloads that are GNU extensions
fb53528a 764
bb3d0c30 765@item @emph{Class}:
a3c4ed23 766Elemental function
fb53528a 767
768@item @emph{Syntax}:
4eb41f08 769@code{RESULT = AIMAG(Z)}
fb53528a 770
771@item @emph{Arguments}:
aee612a9 772@multitable @columnfractions .15 .70
e06f8026 773@item @var{Z} @tab The type of the argument shall be @code{COMPLEX}.
fb53528a 774@end multitable
775
776@item @emph{Return value}:
e06f8026 777The return value is of type @code{REAL} with the
fb53528a 778kind type parameter of the argument.
779
780@item @emph{Example}:
781@smallexample
782program test_aimag
783 complex(4) z4
784 complex(8) z8
785 z4 = cmplx(1.e0_4, 0.e0_4)
786 z8 = cmplx(0.e0_8, 1.e0_8)
787 print *, aimag(z4), dimag(z8)
788end program test_aimag
789@end smallexample
790
791@item @emph{Specific names}:
aee612a9 792@multitable @columnfractions .20 .20 .20 .25
7d74ce87 793@item Name @tab Argument @tab Return type @tab Standard
794@item @code{AIMAG(Z)} @tab @code{COMPLEX Z} @tab @code{REAL} @tab GNU extension
795@item @code{DIMAG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{REAL(8)} @tab GNU extension
796@item @code{IMAG(Z)} @tab @code{COMPLEX Z} @tab @code{REAL} @tab GNU extension
797@item @code{IMAGPART(Z)} @tab @code{COMPLEX Z} @tab @code{REAL} @tab GNU extension
fb53528a 798@end multitable
799@end table
800
801
bb3d0c30 802
fb53528a 803@node AINT
a3c4ed23 804@section @code{AINT} --- Truncate to a whole number
a1149005 805@fnindex AINT
806@fnindex DINT
807@cindex floor
808@cindex rounding, floor
fb53528a 809
810@table @asis
811@item @emph{Description}:
e06f8026 812@code{AINT(A [, KIND])} truncates its argument to a whole number.
fb53528a 813
a3c4ed23 814@item @emph{Standard}:
f40b44c0 815Fortran 77 and later
fb53528a 816
bb3d0c30 817@item @emph{Class}:
a3c4ed23 818Elemental function
fb53528a 819
820@item @emph{Syntax}:
e06f8026 821@code{RESULT = AINT(A [, KIND])}
fb53528a 822
823@item @emph{Arguments}:
aee612a9 824@multitable @columnfractions .15 .70
e06f8026 825@item @var{A} @tab The type of the argument shall be @code{REAL}.
826@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
c24c5fac 827expression indicating the kind parameter of the result.
fb53528a 828@end multitable
829
830@item @emph{Return value}:
e06f8026 831The return value is of type @code{REAL} with the kind type parameter of the
4e7aa3fa 832argument if the optional @var{KIND} is absent; otherwise, the kind
fb53528a 833type parameter will be given by @var{KIND}. If the magnitude of
e06f8026 834@var{X} is less than one, @code{AINT(X)} returns zero. If the
835magnitude is equal to or greater than one then it returns the largest
fb53528a 836whole number that does not exceed its magnitude. The sign is the same
837as the sign of @var{X}.
838
839@item @emph{Example}:
840@smallexample
841program test_aint
842 real(4) x4
843 real(8) x8
844 x4 = 1.234E0_4
845 x8 = 4.321_8
846 print *, aint(x4), dint(x8)
847 x8 = aint(x4,8)
848end program test_aint
849@end smallexample
850
851@item @emph{Specific names}:
aee612a9 852@multitable @columnfractions .20 .20 .20 .25
a3c4ed23 853@item Name @tab Argument @tab Return type @tab Standard
7d74ce87 854@item @code{AINT(A)} @tab @code{REAL(4) A} @tab @code{REAL(4)} @tab Fortran 77 and later
855@item @code{DINT(A)} @tab @code{REAL(8) A} @tab @code{REAL(8)} @tab Fortran 77 and later
fb53528a 856@end multitable
857@end table
858
859
bb3d0c30 860
247981ce 861@node ALARM
862@section @code{ALARM} --- Execute a routine after a given delay
a1149005 863@fnindex ALARM
864@cindex delayed execution
247981ce 865
866@table @asis
867@item @emph{Description}:
a3c4ed23 868@code{ALARM(SECONDS, HANDLER [, STATUS])} causes external subroutine @var{HANDLER}
f1a63476 869to be executed after a delay of @var{SECONDS} by using @code{alarm(2)} to
247981ce 870set up a signal and @code{signal(2)} to catch it. If @var{STATUS} is
871supplied, it will be returned with the number of seconds remaining until
872any previously scheduled alarm was due to be delivered, or zero if there
873was no previously scheduled alarm.
874
a3c4ed23 875@item @emph{Standard}:
876GNU extension
247981ce 877
878@item @emph{Class}:
a3c4ed23 879Subroutine
247981ce 880
881@item @emph{Syntax}:
96a252c6 882@code{CALL ALARM(SECONDS, HANDLER [, STATUS])}
247981ce 883
884@item @emph{Arguments}:
aee612a9 885@multitable @columnfractions .15 .70
247981ce 886@item @var{SECONDS} @tab The type of the argument shall be a scalar
887@code{INTEGER}. It is @code{INTENT(IN)}.
888@item @var{HANDLER} @tab Signal handler (@code{INTEGER FUNCTION} or
f1a63476 889@code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar. The scalar
890values may be either @code{SIG_IGN=1} to ignore the alarm generated
891or @code{SIG_DFL=0} to set the default action. It is @code{INTENT(IN)}.
247981ce 892@item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
f1a63476 893variable of the default @code{INTEGER} kind. It is @code{INTENT(OUT)}.
247981ce 894@end multitable
895
896@item @emph{Example}:
897@smallexample
898program test_alarm
899 external handler_print
900 integer i
901 call alarm (3, handler_print, i)
902 print *, i
903 call sleep(10)
904end program test_alarm
905@end smallexample
906This will cause the external routine @var{handler_print} to be called
907after 3 seconds.
908@end table
909
910
911
fb53528a 912@node ALL
913@section @code{ALL} --- All values in @var{MASK} along @var{DIM} are true
a1149005 914@fnindex ALL
915@cindex array, apply condition
916@cindex array, condition testing
fb53528a 917
918@table @asis
919@item @emph{Description}:
920@code{ALL(MASK [, DIM])} determines if all the values are true in @var{MASK}
921in the array along dimension @var{DIM}.
922
a3c4ed23 923@item @emph{Standard}:
f40b44c0 924Fortran 95 and later
fb53528a 925
bb3d0c30 926@item @emph{Class}:
138b8aca 927Transformational function
fb53528a 928
929@item @emph{Syntax}:
4eb41f08 930@code{RESULT = ALL(MASK [, DIM])}
fb53528a 931
932@item @emph{Arguments}:
aee612a9 933@multitable @columnfractions .15 .70
e06f8026 934@item @var{MASK} @tab The type of the argument shall be @code{LOGICAL} and
fb53528a 935it shall not be scalar.
936@item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer
937with a value that lies between one and the rank of @var{MASK}.
938@end multitable
939
940@item @emph{Return value}:
e06f8026 941@code{ALL(MASK)} returns a scalar value of type @code{LOGICAL} where
fb53528a 942the kind type parameter is the same as the kind type parameter of
943@var{MASK}. If @var{DIM} is present, then @code{ALL(MASK, DIM)} returns
944an array with the rank of @var{MASK} minus 1. The shape is determined from
945the shape of @var{MASK} where the @var{DIM} dimension is elided.
946
947@table @asis
948@item (A)
949@code{ALL(MASK)} is true if all elements of @var{MASK} are true.
950It also is true if @var{MASK} has zero size; otherwise, it is false.
951@item (B)
952If the rank of @var{MASK} is one, then @code{ALL(MASK,DIM)} is equivalent
953to @code{ALL(MASK)}. If the rank is greater than one, then @code{ALL(MASK,DIM)}
954is determined by applying @code{ALL} to the array sections.
955@end table
956
957@item @emph{Example}:
958@smallexample
959program test_all
960 logical l
961 l = all((/.true., .true., .true./))
962 print *, l
963 call section
964 contains
965 subroutine section
966 integer a(2,3), b(2,3)
967 a = 1
968 b = 1
969 b(2,2) = 2
970 print *, all(a .eq. b, 1)
971 print *, all(a .eq. b, 2)
972 end subroutine section
973end program test_all
974@end smallexample
975@end table
56327b76 976
1ef88f15 977
db8ac666 978
1ef88f15 979@node ALLOCATED
980@section @code{ALLOCATED} --- Status of an allocatable entity
a1149005 981@fnindex ALLOCATED
982@cindex allocation, status
1ef88f15 983
984@table @asis
985@item @emph{Description}:
7d74ce87 986@code{ALLOCATED(ARRAY)} and @code{ALLOCATED(SCALAR)} check the allocation
987status of @var{ARRAY} and @var{SCALAR}, respectively.
1ef88f15 988
a3c4ed23 989@item @emph{Standard}:
7d74ce87 990Fortran 95 and later. Note, the @code{SCALAR=} keyword and allocatable
991scalar entities are available in Fortran 2003 and later.
1ef88f15 992
bb3d0c30 993@item @emph{Class}:
a3c4ed23 994Inquiry function
1ef88f15 995
996@item @emph{Syntax}:
75016020 997@multitable @columnfractions .80
998@item @code{RESULT = ALLOCATED(ARRAY)}
999@item @code{RESULT = ALLOCATED(SCALAR)}
1000@end multitable
1ef88f15 1001
1002@item @emph{Arguments}:
aee612a9 1003@multitable @columnfractions .15 .70
e06f8026 1004@item @var{ARRAY} @tab The argument shall be an @code{ALLOCATABLE} array.
7d74ce87 1005@item @var{SCALAR} @tab The argument shall be an @code{ALLOCATABLE} scalar.
1ef88f15 1006@end multitable
1007
1008@item @emph{Return value}:
1009The return value is a scalar @code{LOGICAL} with the default logical
7d74ce87 1010kind type parameter. If the argument is allocated, then the result is
1011@code{.TRUE.}; otherwise, it returns @code{.FALSE.}
1ef88f15 1012
1013@item @emph{Example}:
1014@smallexample
1015program test_allocated
1016 integer :: i = 4
1017 real(4), allocatable :: x(:)
57b9ac90 1018 if (.not. allocated(x)) allocate(x(i))
1ef88f15 1019end program test_allocated
1020@end smallexample
1021@end table
1022
1023
fe97b755 1024
a3c4ed23 1025@node AND
ed8f9044 1026@section @code{AND} --- Bitwise logical AND
a1149005 1027@fnindex AND
1028@cindex bitwise logical and
1029@cindex logical and, bitwise
a3c4ed23 1030
1031@table @asis
1032@item @emph{Description}:
ed8f9044 1033Bitwise logical @code{AND}.
1034
1035This intrinsic routine is provided for backwards compatibility with
1036GNU Fortran 77. For integer arguments, programmers should consider
1037the use of the @ref{IAND} intrinsic defined by the Fortran standard.
1038
a3c4ed23 1039@item @emph{Standard}:
ed8f9044 1040GNU extension
1041
a3c4ed23 1042@item @emph{Class}:
138b8aca 1043Function
ed8f9044 1044
a3c4ed23 1045@item @emph{Syntax}:
bf4e8122 1046@code{RESULT = AND(I, J)}
ed8f9044 1047
a3c4ed23 1048@item @emph{Arguments}:
aee612a9 1049@multitable @columnfractions .15 .70
e06f8026 1050@item @var{I} @tab The type shall be either a scalar @code{INTEGER}
a48103f3 1051type or a scalar @code{LOGICAL} type.
1052@item @var{J} @tab The type shall be the same as the type of @var{I}.
ed8f9044 1053@end multitable
1054
a3c4ed23 1055@item @emph{Return value}:
e06f8026 1056The return type is either a scalar @code{INTEGER} or a scalar
a48103f3 1057@code{LOGICAL}. If the kind type parameters differ, then the
1058smaller kind type is implicitly converted to larger kind, and the
1059return has the larger kind.
ed8f9044 1060
a3c4ed23 1061@item @emph{Example}:
ed8f9044 1062@smallexample
1063PROGRAM test_and
b9f2f128 1064 LOGICAL :: T = .TRUE., F = .FALSE.
ed8f9044 1065 INTEGER :: a, b
1066 DATA a / Z'F' /, b / Z'3' /
1067
1068 WRITE (*,*) AND(T, T), AND(T, F), AND(F, T), AND(F, F)
1069 WRITE (*,*) AND(a, b)
1070END PROGRAM
1071@end smallexample
1072
a3c4ed23 1073@item @emph{See also}:
f40b44c0 1074Fortran 95 elemental function: @ref{IAND}
a3c4ed23 1075@end table
1076
1077
bb3d0c30 1078
1ef88f15 1079@node ANINT
572d7b7f 1080@section @code{ANINT} --- Nearest whole number
a1149005 1081@fnindex ANINT
1082@fnindex DNINT
1083@cindex ceiling
1084@cindex rounding, ceiling
1ef88f15 1085
1086@table @asis
1087@item @emph{Description}:
e06f8026 1088@code{ANINT(A [, KIND])} rounds its argument to the nearest whole number.
1ef88f15 1089
a3c4ed23 1090@item @emph{Standard}:
f40b44c0 1091Fortran 77 and later
1ef88f15 1092
bb3d0c30 1093@item @emph{Class}:
a3c4ed23 1094Elemental function
1ef88f15 1095
1096@item @emph{Syntax}:
e06f8026 1097@code{RESULT = ANINT(A [, KIND])}
1ef88f15 1098
1099@item @emph{Arguments}:
aee612a9 1100@multitable @columnfractions .15 .70
e06f8026 1101@item @var{A} @tab The type of the argument shall be @code{REAL}.
1102@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
c24c5fac 1103expression indicating the kind parameter of the result.
1ef88f15 1104@end multitable
1105
1106@item @emph{Return value}:
1107The return value is of type real with the kind type parameter of the
4e7aa3fa 1108argument if the optional @var{KIND} is absent; otherwise, the kind
e06f8026 1109type parameter will be given by @var{KIND}. If @var{A} is greater than
1110zero, @code{ANINT(A)} returns @code{AINT(X+0.5)}. If @var{A} is
1111less than or equal to zero then it returns @code{AINT(X-0.5)}.
1ef88f15 1112
1113@item @emph{Example}:
1114@smallexample
1115program test_anint
1116 real(4) x4
1117 real(8) x8
1118 x4 = 1.234E0_4
1119 x8 = 4.321_8
1120 print *, anint(x4), dnint(x8)
1121 x8 = anint(x4,8)
1122end program test_anint
1123@end smallexample
1124
1125@item @emph{Specific names}:
aee612a9 1126@multitable @columnfractions .20 .20 .20 .25
a3c4ed23 1127@item Name @tab Argument @tab Return type @tab Standard
7d74ce87 1128@item @code{AINT(A)} @tab @code{REAL(4) A} @tab @code{REAL(4)} @tab Fortran 77 and later
e06f8026 1129@item @code{DNINT(A)} @tab @code{REAL(8) A} @tab @code{REAL(8)} @tab Fortran 77 and later
1ef88f15 1130@end multitable
1131@end table
1132
1133
bb3d0c30 1134
1ef88f15 1135@node ANY
1136@section @code{ANY} --- Any value in @var{MASK} along @var{DIM} is true
a1149005 1137@fnindex ANY
1138@cindex array, apply condition
1139@cindex array, condition testing
1ef88f15 1140
1141@table @asis
1142@item @emph{Description}:
c656b4ab 1143@code{ANY(MASK [, DIM])} determines if any of the values in the logical array
1144@var{MASK} along dimension @var{DIM} are @code{.TRUE.}.
1ef88f15 1145
a3c4ed23 1146@item @emph{Standard}:
f40b44c0 1147Fortran 95 and later
1ef88f15 1148
bb3d0c30 1149@item @emph{Class}:
138b8aca 1150Transformational function
1ef88f15 1151
1152@item @emph{Syntax}:
4eb41f08 1153@code{RESULT = ANY(MASK [, DIM])}
1ef88f15 1154
1155@item @emph{Arguments}:
aee612a9 1156@multitable @columnfractions .15 .70
e06f8026 1157@item @var{MASK} @tab The type of the argument shall be @code{LOGICAL} and
1ef88f15 1158it shall not be scalar.
1159@item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer
1160with a value that lies between one and the rank of @var{MASK}.
1161@end multitable
1162
1163@item @emph{Return value}:
e06f8026 1164@code{ANY(MASK)} returns a scalar value of type @code{LOGICAL} where
1ef88f15 1165the kind type parameter is the same as the kind type parameter of
1166@var{MASK}. If @var{DIM} is present, then @code{ANY(MASK, DIM)} returns
1167an array with the rank of @var{MASK} minus 1. The shape is determined from
1168the shape of @var{MASK} where the @var{DIM} dimension is elided.
1169
1170@table @asis
1171@item (A)
1172@code{ANY(MASK)} is true if any element of @var{MASK} is true;
1173otherwise, it is false. It also is false if @var{MASK} has zero size.
1174@item (B)
1175If the rank of @var{MASK} is one, then @code{ANY(MASK,DIM)} is equivalent
1176to @code{ANY(MASK)}. If the rank is greater than one, then @code{ANY(MASK,DIM)}
1177is determined by applying @code{ANY} to the array sections.
1178@end table
1179
1180@item @emph{Example}:
1181@smallexample
1182program test_any
1183 logical l
1184 l = any((/.true., .true., .true./))
1185 print *, l
1186 call section
1187 contains
1188 subroutine section
1189 integer a(2,3), b(2,3)
1190 a = 1
1191 b = 1
1192 b(2,2) = 2
1193 print *, any(a .eq. b, 1)
1194 print *, any(a .eq. b, 2)
1195 end subroutine section
1196end program test_any
1197@end smallexample
1198@end table
1199
1200
bb3d0c30 1201
1ef88f15 1202@node ASIN
1203@section @code{ASIN} --- Arcsine function
a1149005 1204@fnindex ASIN
1205@fnindex DASIN
1206@cindex trigonometric function, sine, inverse
1207@cindex sine, inverse
1ef88f15 1208
1209@table @asis
1210@item @emph{Description}:
ed8f9044 1211@code{ASIN(X)} computes the arcsine of its @var{X} (inverse of @code{SIN(X)}).
1ef88f15 1212
a3c4ed23 1213@item @emph{Standard}:
6f4274f9 1214Fortran 77 and later, for a complex argument Fortran 2008 or later
1ef88f15 1215
bb3d0c30 1216@item @emph{Class}:
a3c4ed23 1217Elemental function
1ef88f15 1218
1219@item @emph{Syntax}:
4eb41f08 1220@code{RESULT = ASIN(X)}
1ef88f15 1221
1222@item @emph{Arguments}:
aee612a9 1223@multitable @columnfractions .15 .70
6f4274f9 1224@item @var{X} @tab The type shall be either @code{REAL} and a magnitude that is
1225less than or equal to one - or be @code{COMPLEX}.
1ef88f15 1226@end multitable
1227
1228@item @emph{Return value}:
6f4274f9 1229The return value is of the same type and kind as @var{X}.
1230The real part of the result is in radians and lies in the range
1231@math{-\pi/2 \leq \Re \asin(x) \leq \pi/2}.
1ef88f15 1232
1233@item @emph{Example}:
1234@smallexample
1235program test_asin
1236 real(8) :: x = 0.866_8
1237 x = asin(x)
1238end program test_asin
1239@end smallexample
1240
1241@item @emph{Specific names}:
aee612a9 1242@multitable @columnfractions .20 .20 .20 .25
a3c4ed23 1243@item Name @tab Argument @tab Return type @tab Standard
7d74ce87 1244@item @code{ASIN(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later
f40b44c0 1245@item @code{DASIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
1ef88f15 1246@end multitable
a3c4ed23 1247
1248@item @emph{See also}:
1249Inverse function: @ref{SIN}
1250
1251@end table
1252
1253
fe97b755 1254
a3c4ed23 1255@node ASINH
a08bb357 1256@section @code{ASINH} --- Inverse hyperbolic sine function
a1149005 1257@fnindex ASINH
1258@fnindex DASINH
1259@cindex area hyperbolic sine
a08bb357 1260@cindex inverse hyperbolic sine
a1149005 1261@cindex hyperbolic function, sine, inverse
1262@cindex sine, hyperbolic, inverse
a3c4ed23 1263
a3c4ed23 1264@table @asis
1265@item @emph{Description}:
a08bb357 1266@code{ASINH(X)} computes the inverse hyperbolic sine of @var{X}.
ed8f9044 1267
a3c4ed23 1268@item @emph{Standard}:
ff4425cf 1269Fortran 2008 and later
ed8f9044 1270
a3c4ed23 1271@item @emph{Class}:
ed8f9044 1272Elemental function
1273
a3c4ed23 1274@item @emph{Syntax}:
4eb41f08 1275@code{RESULT = ASINH(X)}
ed8f9044 1276
a3c4ed23 1277@item @emph{Arguments}:
aee612a9 1278@multitable @columnfractions .15 .70
ff4425cf 1279@item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
ed8f9044 1280@end multitable
1281
a3c4ed23 1282@item @emph{Return value}:
6f4274f9 1283The return value is of the same type and kind as @var{X}. If @var{X} is
1284complex, the imaginary part of the result is in radians and lies between
1285@math{-\pi/2 \leq \Im \asinh(x) \leq \pi/2}.
ed8f9044 1286
a3c4ed23 1287@item @emph{Example}:
ed8f9044 1288@smallexample
1289PROGRAM test_asinh
1290 REAL(8), DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1291 WRITE (*,*) ASINH(x)
1292END PROGRAM
1293@end smallexample
1294
fe97b755 1295@item @emph{Specific names}:
1296@multitable @columnfractions .20 .20 .20 .25
1297@item Name @tab Argument @tab Return type @tab Standard
1298@item @code{DASINH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension.
1299@end multitable
1300
a3c4ed23 1301@item @emph{See also}:
ed8f9044 1302Inverse function: @ref{SINH}
1ef88f15 1303@end table
1304
1305
bb3d0c30 1306
db8ac666 1307@node ASSOCIATED
1308@section @code{ASSOCIATED} --- Status of a pointer or pointer/target pair
a1149005 1309@fnindex ASSOCIATED
1310@cindex pointer, status
1311@cindex association status
db8ac666 1312
1313@table @asis
1314@item @emph{Description}:
e06f8026 1315@code{ASSOCIATED(POINTER [, TARGET])} determines the status of the pointer
1316@var{POINTER} or if @var{POINTER} is associated with the target @var{TARGET}.
db8ac666 1317
a3c4ed23 1318@item @emph{Standard}:
f40b44c0 1319Fortran 95 and later
db8ac666 1320
bb3d0c30 1321@item @emph{Class}:
a3c4ed23 1322Inquiry function
db8ac666 1323
1324@item @emph{Syntax}:
e06f8026 1325@code{RESULT = ASSOCIATED(POINTER [, TARGET])}
db8ac666 1326
1327@item @emph{Arguments}:
aee612a9 1328@multitable @columnfractions .15 .70
e06f8026 1329@item @var{POINTER} @tab @var{POINTER} shall have the @code{POINTER} attribute
1330and it can be of any type.
1331@item @var{TARGET} @tab (Optional) @var{TARGET} shall be a pointer or
1332a target. It must have the same type, kind type parameter, and
1333array rank as @var{POINTER}.
db8ac666 1334@end multitable
e06f8026 1335The association status of neither @var{POINTER} nor @var{TARGET} shall be
1336undefined.
db8ac666 1337
1338@item @emph{Return value}:
e06f8026 1339@code{ASSOCIATED(POINTER)} returns a scalar value of type @code{LOGICAL(4)}.
db8ac666 1340There are several cases:
1341@table @asis
e06f8026 1342@item (A) When the optional @var{TARGET} is not present then
1343@code{ASSOCIATED(POINTER)} is true if @var{POINTER} is associated with a target; otherwise, it returns false.
1344@item (B) If @var{TARGET} is present and a scalar target, the result is true if
1345@var{TARGET} is not a zero-sized storage sequence and the target associated with @var{POINTER} occupies the same storage units. If @var{POINTER} is
1346disassociated, the result is false.
1347@item (C) If @var{TARGET} is present and an array target, the result is true if
1348@var{TARGET} and @var{POINTER} have the same shape, are not zero-sized arrays,
1349are arrays whose elements are not zero-sized storage sequences, and
1350@var{TARGET} and @var{POINTER} occupy the same storage units in array element
1351order.
1352As in case(B), the result is false, if @var{POINTER} is disassociated.
1353@item (D) If @var{TARGET} is present and an scalar pointer, the result is true
1354if @var{TARGET} is associated with @var{POINTER}, the target associated with
1355@var{TARGET} are not zero-sized storage sequences and occupy the same storage
1356units.
1357The result is false, if either @var{TARGET} or @var{POINTER} is disassociated.
1358@item (E) If @var{TARGET} is present and an array pointer, the result is true if
1359target associated with @var{POINTER} and the target associated with @var{TARGET}
1360have the same shape, are not zero-sized arrays, are arrays whose elements are
1361not zero-sized storage sequences, and @var{TARGET} and @var{POINTER} occupy
1362the same storage units in array element order.
1363The result is false, if either @var{TARGET} or @var{POINTER} is disassociated.
db8ac666 1364@end table
1365
1366@item @emph{Example}:
1367@smallexample
1368program test_associated
1369 implicit none
1370 real, target :: tgt(2) = (/1., 2./)
1371 real, pointer :: ptr(:)
1372 ptr => tgt
1373 if (associated(ptr) .eqv. .false.) call abort
1374 if (associated(ptr,tgt) .eqv. .false.) call abort
1375end program test_associated
1376@end smallexample
a3c4ed23 1377
1378@item @emph{See also}:
1379@ref{NULL}
db8ac666 1380@end table
1381
1382
bb3d0c30 1383
c0075f3c 1384@node ATAN
1385@section @code{ATAN} --- Arctangent function
a1149005 1386@fnindex ATAN
1387@fnindex DATAN
1388@cindex trigonometric function, tangent, inverse
1389@cindex tangent, inverse
c0075f3c 1390
1391@table @asis
1392@item @emph{Description}:
1393@code{ATAN(X)} computes the arctangent of @var{X}.
1394
a3c4ed23 1395@item @emph{Standard}:
1b25477b 1396Fortran 77 and later, for a complex argument and for two arguments
1397Fortran 2008 or later
c0075f3c 1398
bb3d0c30 1399@item @emph{Class}:
a3c4ed23 1400Elemental function
c0075f3c 1401
1402@item @emph{Syntax}:
75016020 1403@multitable @columnfractions .80
1404@item @code{RESULT = ATAN(X)}
1405@item @code{RESULT = ATAN(Y, X)}
1406@end multitable
c0075f3c 1407
1408@item @emph{Arguments}:
aee612a9 1409@multitable @columnfractions .15 .70
1b25477b 1410@item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX};
1411if @var{Y} is present, @var{X} shall be REAL.
1412@item @var{Y} shall be of the same type and kind as @var{X}.
c0075f3c 1413@end multitable
1414
1415@item @emph{Return value}:
6f4274f9 1416The return value is of the same type and kind as @var{X}.
1b25477b 1417If @var{Y} is present, the result is identical to @code{ATAN2(Y,X)}.
1418Otherwise, it the arcus tangent of @var{X}, where the real part of
1419the result is in radians and lies in the range
6f4274f9 1420@math{-\pi/2 \leq \Re \atan(x) \leq \pi/2}.
c0075f3c 1421
1422@item @emph{Example}:
1423@smallexample
1424program test_atan
1425 real(8) :: x = 2.866_8
1426 x = atan(x)
1427end program test_atan
1428@end smallexample
1429
1430@item @emph{Specific names}:
aee612a9 1431@multitable @columnfractions .20 .20 .20 .25
a3c4ed23 1432@item Name @tab Argument @tab Return type @tab Standard
7d74ce87 1433@item @code{ATAN(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later
f40b44c0 1434@item @code{DATAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
c0075f3c 1435@end multitable
a3c4ed23 1436
1437@item @emph{See also}:
1438Inverse function: @ref{TAN}
1439
c0075f3c 1440@end table
1441
1442
bb3d0c30 1443
db8ac666 1444@node ATAN2
1445@section @code{ATAN2} --- Arctangent function
a1149005 1446@fnindex ATAN2
1447@fnindex DATAN2
1448@cindex trigonometric function, tangent, inverse
1449@cindex tangent, inverse
db8ac666 1450
1451@table @asis
1452@item @emph{Description}:
1b25477b 1453@code{ATAN2(Y, X)} computes the principal value of the argument
1454function of the complex number @math{X + i Y}. This function can
5f7aa0fe 1455be used to transform from Cartesian into polar coordinates and
1b25477b 1456allows to determine the angle in the correct quadrant.
db8ac666 1457
a3c4ed23 1458@item @emph{Standard}:
f40b44c0 1459Fortran 77 and later
db8ac666 1460
bb3d0c30 1461@item @emph{Class}:
a3c4ed23 1462Elemental function
db8ac666 1463
1464@item @emph{Syntax}:
e06f8026 1465@code{RESULT = ATAN2(Y, X)}
db8ac666 1466
1467@item @emph{Arguments}:
aee612a9 1468@multitable @columnfractions .15 .70
e06f8026 1469@item @var{Y} @tab The type shall be @code{REAL}.
bc57849d 1470@item @var{X} @tab The type and kind type parameter shall be the same as @var{Y}.
db8ac666 1471If @var{Y} is zero, then @var{X} must be nonzero.
1472@end multitable
1473
1474@item @emph{Return value}:
6152df27 1475The return value has the same type and kind type parameter as @var{Y}. It
1476is the principal value of the complex number @math{X + i Y}. If @var{X}
1477is nonzero, then it lies in the range @math{-\pi \le \atan (x) \leq \pi}.
db8ac666 1478The sign is positive if @var{Y} is positive. If @var{Y} is zero, then
6152df27 1479the return value is zero if @var{X} is strictly positive, @math{\pi} if
1480@var{X} is negative and @var{Y} is positive zero (or the processor does
1481not handle signed zeros), and @math{-\pi} if @var{X} is negative and
1482@var{Y} is negative zero. Finally, if @var{X} is zero, then the
1483magnitude of the result is @math{\pi/2}.
db8ac666 1484
1485@item @emph{Example}:
1486@smallexample
1487program test_atan2
1488 real(4) :: x = 1.e0_4, y = 0.5e0_4
1489 x = atan2(y,x)
1490end program test_atan2
1491@end smallexample
1492
1493@item @emph{Specific names}:
aee612a9 1494@multitable @columnfractions .20 .20 .20 .25
7d74ce87 1495@item Name @tab Argument @tab Return type @tab Standard
1496@item @code{ATAN2(X, Y)} @tab @code{REAL(4) X, Y} @tab @code{REAL(4)} @tab Fortran 77 and later
1497@item @code{DATAN2(X, Y)} @tab @code{REAL(8) X, Y} @tab @code{REAL(8)} @tab Fortran 77 and later
db8ac666 1498@end multitable
1499@end table
1500
c0075f3c 1501
bb3d0c30 1502
a3c4ed23 1503@node ATANH
a08bb357 1504@section @code{ATANH} --- Inverse hyperbolic tangent function
1505@fnindex ATANH
1506@fnindex DATANH
a1149005 1507@cindex area hyperbolic tangent
a08bb357 1508@cindex inverse hyperbolic tangent
a1149005 1509@cindex hyperbolic function, tangent, inverse
1510@cindex tangent, hyperbolic, inverse
a3c4ed23 1511
a3c4ed23 1512@table @asis
1513@item @emph{Description}:
a08bb357 1514@code{ATANH(X)} computes the inverse hyperbolic tangent of @var{X}.
ed8f9044 1515
a3c4ed23 1516@item @emph{Standard}:
ff4425cf 1517Fortran 2008 and later
ed8f9044 1518
a3c4ed23 1519@item @emph{Class}:
ed8f9044 1520Elemental function
1521
a3c4ed23 1522@item @emph{Syntax}:
4eb41f08 1523@code{RESULT = ATANH(X)}
ed8f9044 1524
a3c4ed23 1525@item @emph{Arguments}:
aee612a9 1526@multitable @columnfractions .15 .70
ff4425cf 1527@item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
ed8f9044 1528@end multitable
1529
a3c4ed23 1530@item @emph{Return value}:
6f4274f9 1531The return value has same type and kind as @var{X}. If @var{X} is
1532complex, the imaginary part of the result is in radians and lies between
1533@math{-\pi/2 \leq \Im \atanh(x) \leq \pi/2}.
ed8f9044 1534
a3c4ed23 1535@item @emph{Example}:
ed8f9044 1536@smallexample
1537PROGRAM test_atanh
1538 REAL, DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1539 WRITE (*,*) ATANH(x)
1540END PROGRAM
1541@end smallexample
1542
fe97b755 1543@item @emph{Specific names}:
1544@multitable @columnfractions .20 .20 .20 .25
1545@item Name @tab Argument @tab Return type @tab Standard
1546@item @code{DATANH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1547@end multitable
1548
a3c4ed23 1549@item @emph{See also}:
ed8f9044 1550Inverse function: @ref{TANH}
a3c4ed23 1551@end table
1552
1553
1554
6ccde1eb 1555@node ATOMIC_DEFINE
1556@section @code{ATOMIC_DEFINE} --- Setting a variable atomically
1557@fnindex ATOMIC_DEFINE
1558@cindex Atomic subroutine, define
1559
1560@table @asis
1561@item @emph{Description}:
1562@code{ATOMIC_DEFINE(ATOM, VALUE)} defines the variable @var{ATOM} with the value
1563@var{VALUE} atomically.
1564
1565@item @emph{Standard}:
1566Fortran 2008 and later
1567
1568@item @emph{Class}:
1569Atomic subroutine
1570
1571@item @emph{Syntax}:
1572@code{CALL ATOMIC_DEFINE(ATOM, VALUE)}
1573
1574@item @emph{Arguments}:
1575@multitable @columnfractions .15 .70
1576@item @var{ATOM} @tab Scalar coarray or coindexed variable of either integer
1577 type with @code{ATOMIC_INT_KIND} kind or logical type
1578 with @code{ATOMIC_LOGICAL_KIND} kind.
1579@item @var{VALURE} @tab Scalar and of the same type as @var{ATOM}. If the kind
1580 is different, the value is converted to the kind of
1581 @var{ATOM}.
1582@end multitable
1583
1584@item @emph{Example}:
1585@smallexample
1586program atomic
1587 use iso_fortran_env
1588 integer(atomic_int_kind) :: atom[*]
1589 call atomic_define (atom[1], this_image())
1590end program atomic
1591@end smallexample
1592
1593@item @emph{See also}:
1594@ref{ATOMIC_REF}, @ref{ISO_FORTRAN_ENV}
1595@end table
1596
1597
1598
1599@node ATOMIC_REF
1600@section @code{ATOMIC_REF} --- Obtaining the value of a variable atomically
1601@fnindex ATOMIC_REF
1602@cindex Atomic subroutine, reference
1603
1604@table @asis
1605@item @emph{Description}:
1606@code{ATOMIC_DEFINE(ATOM, VALUE)} atomically assigns the value of the
1607variable @var{ATOM} to @var{VALUE}.
1608
1609@item @emph{Standard}:
1610Fortran 2008 and later
1611
1612@item @emph{Class}:
1613Atomic subroutine
1614
1615@item @emph{Syntax}:
1616@code{CALL ATOMIC_REF(VALUE, ATOM)}
1617
1618@item @emph{Arguments}:
1619@multitable @columnfractions .15 .70
1620@item @var{VALURE} @tab Scalar and of the same type as @var{ATOM}. If the kind
1621 is different, the value is converted to the kind of
1622 @var{ATOM}.
1623@item @var{ATOM} @tab Scalar coarray or coindexed variable of either integer
1624 type with @code{ATOMIC_INT_KIND} kind or logical type
1625 with @code{ATOMIC_LOGICAL_KIND} kind.
1626@end multitable
1627
1628@item @emph{Example}:
1629@smallexample
1630program atomic
1631 use iso_fortran_env
1632 logical(atomic_logical_kind) :: atom[*]
1633 logical :: val
1634 call atomic_ref (atom, .false.)
1635 ! ...
1636 call atomic_ref (atom, val)
1637 if (val) then
1638 print *, "Obtained"
1639 end if
1640end program atomic
1641@end smallexample
1642
1643@item @emph{See also}:
1644@ref{ATOMIC_DEFINE}, @ref{ISO_FORTRAN_ENV}
1645@end table
1646
1647
1648
899edbae 1649@node BACKTRACE
1650@section @code{BACKTRACE} --- Show a backtrace
1651@fnindex BACKTRACE
1652@cindex backtrace
1653
1654@table @asis
1655@item @emph{Description}:
1656@code{BACKTRACE} shows a backtrace at an arbitrary place in user code. Program
1657execution continues normally afterwards. The backtrace information is printed
1658to the unit corresponding to @code{ERROR_UNIT} in @code{ISO_FORTRAN_ENV}.
1659
1660@item @emph{Standard}:
1661GNU Extension
1662
1663@item @emph{Class}:
1664Subroutine
1665
1666@item @emph{Syntax}:
1667@code{CALL BACKTRACE}
1668
1669@item @emph{Arguments}:
1670None
1671
1672@item @emph{See also}:
1673@ref{ABORT}
1674@end table
1675
1676
1677
ff4425cf 1678@node BESSEL_J0
1679@section @code{BESSEL_J0} --- Bessel function of the first kind of order 0
1680@fnindex BESSEL_J0
a1149005 1681@fnindex BESJ0
1682@fnindex DBESJ0
1683@cindex Bessel function, first kind
c0075f3c 1684
1685@table @asis
1686@item @emph{Description}:
ff4425cf 1687@code{BESSEL_J0(X)} computes the Bessel function of the first kind of
1688order 0 of @var{X}. This function is available under the name
1689@code{BESJ0} as a GNU extension.
c0075f3c 1690
a3c4ed23 1691@item @emph{Standard}:
ff4425cf 1692Fortran 2008 and later
c0075f3c 1693
bb3d0c30 1694@item @emph{Class}:
a3c4ed23 1695Elemental function
c0075f3c 1696
1697@item @emph{Syntax}:
ff4425cf 1698@code{RESULT = BESSEL_J0(X)}
c0075f3c 1699
1700@item @emph{Arguments}:
aee612a9 1701@multitable @columnfractions .15 .70
e06f8026 1702@item @var{X} @tab The type shall be @code{REAL}, and it shall be scalar.
c0075f3c 1703@end multitable
1704
1705@item @emph{Return value}:
e06f8026 1706The return value is of type @code{REAL} and lies in the
1707range @math{ - 0.4027... \leq Bessel (0,x) \leq 1}. It has the same
1708kind as @var{X}.
c0075f3c 1709
1710@item @emph{Example}:
1711@smallexample
1712program test_besj0
1713 real(8) :: x = 0.0_8
ff4425cf 1714 x = bessel_j0(x)
c0075f3c 1715end program test_besj0
1716@end smallexample
1717
1718@item @emph{Specific names}:
aee612a9 1719@multitable @columnfractions .20 .20 .20 .25
a3c4ed23 1720@item Name @tab Argument @tab Return type @tab Standard
1721@item @code{DBESJ0(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
c0075f3c 1722@end multitable
1723@end table
1724
1725
1726
ff4425cf 1727@node BESSEL_J1
2c8e4834 1728@section @code{BESSEL_J1} --- Bessel function of the first kind of order 1
ff4425cf 1729@fnindex BESSEL_J1
a1149005 1730@fnindex BESJ1
1731@fnindex DBESJ1
1732@cindex Bessel function, first kind
c0075f3c 1733
1734@table @asis
1735@item @emph{Description}:
ff4425cf 1736@code{BESSEL_J1(X)} computes the Bessel function of the first kind of
1737order 1 of @var{X}. This function is available under the name
1738@code{BESJ1} as a GNU extension.
c0075f3c 1739
a3c4ed23 1740@item @emph{Standard}:
ff4425cf 1741Fortran 2008
c0075f3c 1742
bb3d0c30 1743@item @emph{Class}:
a3c4ed23 1744Elemental function
c0075f3c 1745
1746@item @emph{Syntax}:
ff4425cf 1747@code{RESULT = BESSEL_J1(X)}
c0075f3c 1748
1749@item @emph{Arguments}:
aee612a9 1750@multitable @columnfractions .15 .70
e06f8026 1751@item @var{X} @tab The type shall be @code{REAL}, and it shall be scalar.
c0075f3c 1752@end multitable
1753
1754@item @emph{Return value}:
e06f8026 1755The return value is of type @code{REAL} and it lies in the
1756range @math{ - 0.5818... \leq Bessel (0,x) \leq 0.5818 }. It has the same
1757kind as @var{X}.
c0075f3c 1758
1759@item @emph{Example}:
1760@smallexample
1761program test_besj1
1762 real(8) :: x = 1.0_8
ff4425cf 1763 x = bessel_j1(x)
c0075f3c 1764end program test_besj1
1765@end smallexample
1766
1767@item @emph{Specific names}:
aee612a9 1768@multitable @columnfractions .20 .20 .20 .25
7d74ce87 1769@item Name @tab Argument @tab Return type @tab Standard
1770@item @code{DBESJ1(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
c0075f3c 1771@end multitable
1772@end table
1773
1774
1775
ff4425cf 1776@node BESSEL_JN
1777@section @code{BESSEL_JN} --- Bessel function of the first kind
1778@fnindex BESSEL_JN
a1149005 1779@fnindex BESJN
1780@fnindex DBESJN
1781@cindex Bessel function, first kind
c0075f3c 1782
1783@table @asis
1784@item @emph{Description}:
ff4425cf 1785@code{BESSEL_JN(N, X)} computes the Bessel function of the first kind of
1786order @var{N} of @var{X}. This function is available under the name
8db68199 1787@code{BESJN} as a GNU extension. If @var{N} and @var{X} are arrays,
1788their ranks and shapes shall conform.
c0075f3c 1789
8db68199 1790@code{BESSEL_JN(N1, N2, X)} returns an array with the Bessel functions
1791of the first kind of the orders @var{N1} to @var{N2}.
dceb1607 1792
a3c4ed23 1793@item @emph{Standard}:
8db68199 1794Fortran 2008 and later, negative @var{N} is allowed as GNU extension
c0075f3c 1795
bb3d0c30 1796@item @emph{Class}:
5f7aa0fe 1797Elemental function, except for the transformational function
8db68199 1798@code{BESSEL_JN(N1, N2, X)}
c0075f3c 1799
1800@item @emph{Syntax}:
75016020 1801@multitable @columnfractions .80
1802@item @code{RESULT = BESSEL_JN(N, X)}
1803@item @code{RESULT = BESSEL_JN(N1, N2, X)}
1804@end multitable
c0075f3c 1805
1806@item @emph{Arguments}:
aee612a9 1807@multitable @columnfractions .15 .70
e06f8026 1808@item @var{N} @tab Shall be a scalar or an array of type @code{INTEGER}.
8db68199 1809@item @var{N1} @tab Shall be a non-negative scalar of type @code{INTEGER}.
1810@item @var{N2} @tab Shall be a non-negative scalar of type @code{INTEGER}.
1811@item @var{X} @tab Shall be a scalar or an array of type @code{REAL};
1812for @code{BESSEL_JN(N1, N2, X)} it shall be scalar.
c0075f3c 1813@end multitable
1814
1815@item @emph{Return value}:
e06f8026 1816The return value is a scalar of type @code{REAL}. It has the same
1817kind as @var{X}.
c0075f3c 1818
8db68199 1819@item @emph{Note}:
d8a9d052 1820The transformational function uses a recurrence algorithm which might,
8db68199 1821for some values of @var{X}, lead to different results than calls to
1822the elemental function.
1823
c0075f3c 1824@item @emph{Example}:
1825@smallexample
1826program test_besjn
1827 real(8) :: x = 1.0_8
ff4425cf 1828 x = bessel_jn(5,x)
c0075f3c 1829end program test_besjn
1830@end smallexample
1831
1832@item @emph{Specific names}:
aee612a9 1833@multitable @columnfractions .20 .20 .20 .25
2cd8ef8b 1834@item Name @tab Argument @tab Return type @tab Standard
1835@item @code{DBESJN(N, X)} @tab @code{INTEGER N} @tab @code{REAL(8)} @tab GNU extension
1836@item @tab @code{REAL(8) X} @tab @tab
c0075f3c 1837@end multitable
1838@end table
1839
1840
1841
ff4425cf 1842@node BESSEL_Y0
1843@section @code{BESSEL_Y0} --- Bessel function of the second kind of order 0
1844@fnindex BESSEL_Y0
a1149005 1845@fnindex BESY0
1846@fnindex DBESY0
1847@cindex Bessel function, second kind
c0075f3c 1848
1849@table @asis
1850@item @emph{Description}:
ff4425cf 1851@code{BESSEL_Y0(X)} computes the Bessel function of the second kind of
1852order 0 of @var{X}. This function is available under the name
1853@code{BESY0} as a GNU extension.
c0075f3c 1854
a3c4ed23 1855@item @emph{Standard}:
ff4425cf 1856Fortran 2008 and later
c0075f3c 1857
bb3d0c30 1858@item @emph{Class}:
a3c4ed23 1859Elemental function
c0075f3c 1860
1861@item @emph{Syntax}:
ff4425cf 1862@code{RESULT = BESSEL_Y0(X)}
c0075f3c 1863
1864@item @emph{Arguments}:
aee612a9 1865@multitable @columnfractions .15 .70
e06f8026 1866@item @var{X} @tab The type shall be @code{REAL}, and it shall be scalar.
c0075f3c 1867@end multitable
1868
1869@item @emph{Return value}:
e06f8026 1870The return value is a scalar of type @code{REAL}. It has the same
1871kind as @var{X}.
c0075f3c 1872
1873@item @emph{Example}:
1874@smallexample
1875program test_besy0
1876 real(8) :: x = 0.0_8
ff4425cf 1877 x = bessel_y0(x)
c0075f3c 1878end program test_besy0
1879@end smallexample
1880
1881@item @emph{Specific names}:
aee612a9 1882@multitable @columnfractions .20 .20 .20 .25
a3c4ed23 1883@item Name @tab Argument @tab Return type @tab Standard
1884@item @code{DBESY0(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
c0075f3c 1885@end multitable
1886@end table
1887
1888
1889
ff4425cf 1890@node BESSEL_Y1
1891@section @code{BESSEL_Y1} --- Bessel function of the second kind of order 1
1892@fnindex BESSEL_Y1
a1149005 1893@fnindex BESY1
1894@fnindex DBESY1
1895@cindex Bessel function, second kind
c0075f3c 1896
1897@table @asis
1898@item @emph{Description}:
ff4425cf 1899@code{BESSEL_Y1(X)} computes the Bessel function of the second kind of
1900order 1 of @var{X}. This function is available under the name
1901@code{BESY1} as a GNU extension.
c0075f3c 1902
a3c4ed23 1903@item @emph{Standard}:
ff4425cf 1904Fortran 2008 and later
c0075f3c 1905
bb3d0c30 1906@item @emph{Class}:
a3c4ed23 1907Elemental function
c0075f3c 1908
1909@item @emph{Syntax}:
ff4425cf 1910@code{RESULT = BESSEL_Y1(X)}
c0075f3c 1911
1912@item @emph{Arguments}:
aee612a9 1913@multitable @columnfractions .15 .70
e06f8026 1914@item @var{X} @tab The type shall be @code{REAL}, and it shall be scalar.
c0075f3c 1915@end multitable
1916
1917@item @emph{Return value}:
e06f8026 1918The return value is a scalar of type @code{REAL}. It has the same
1919kind as @var{X}.
c0075f3c 1920
1921@item @emph{Example}:
1922@smallexample
1923program test_besy1
1924 real(8) :: x = 1.0_8
ff4425cf 1925 x = bessel_y1(x)
c0075f3c 1926end program test_besy1
1927@end smallexample
1928
1929@item @emph{Specific names}:
aee612a9 1930@multitable @columnfractions .20 .20 .20 .25
a3c4ed23 1931@item Name @tab Argument @tab Return type @tab Standard
1932@item @code{DBESY1(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
c0075f3c 1933@end multitable
1934@end table
1935
1936
1937
ff4425cf 1938@node BESSEL_YN
1939@section @code{BESSEL_YN} --- Bessel function of the second kind
1940@fnindex BESSEL_YN
a1149005 1941@fnindex BESYN
1942@fnindex DBESYN
1943@cindex Bessel function, second kind
c0075f3c 1944
1945@table @asis
1946@item @emph{Description}:
ff4425cf 1947@code{BESSEL_YN(N, X)} computes the Bessel function of the second kind of
1948order @var{N} of @var{X}. This function is available under the name
8db68199 1949@code{BESYN} as a GNU extension. If @var{N} and @var{X} are arrays,
1950their ranks and shapes shall conform.
c0075f3c 1951
8db68199 1952@code{BESSEL_YN(N1, N2, X)} returns an array with the Bessel functions
1953of the first kind of the orders @var{N1} to @var{N2}.
dceb1607 1954
a3c4ed23 1955@item @emph{Standard}:
8db68199 1956Fortran 2008 and later, negative @var{N} is allowed as GNU extension
c0075f3c 1957
bb3d0c30 1958@item @emph{Class}:
5f7aa0fe 1959Elemental function, except for the transformational function
8db68199 1960@code{BESSEL_YN(N1, N2, X)}
c0075f3c 1961
1962@item @emph{Syntax}:
75016020 1963@multitable @columnfractions .80
1964@item @code{RESULT = BESSEL_YN(N, X)}
1965@item @code{RESULT = BESSEL_YN(N1, N2, X)}
1966@end multitable
c0075f3c 1967
1968@item @emph{Arguments}:
aee612a9 1969@multitable @columnfractions .15 .70
8db68199 1970@item @var{N} @tab Shall be a scalar or an array of type @code{INTEGER} .
1971@item @var{N1} @tab Shall be a non-negative scalar of type @code{INTEGER}.
1972@item @var{N2} @tab Shall be a non-negative scalar of type @code{INTEGER}.
1973@item @var{X} @tab Shall be a scalar or an array of type @code{REAL};
1974for @code{BESSEL_YN(N1, N2, X)} it shall be scalar.
c0075f3c 1975@end multitable
1976
1977@item @emph{Return value}:
e06f8026 1978The return value is a scalar of type @code{REAL}. It has the same
1979kind as @var{X}.
c0075f3c 1980
8db68199 1981@item @emph{Note}:
d8a9d052 1982The transformational function uses a recurrence algorithm which might,
8db68199 1983for some values of @var{X}, lead to different results than calls to
1984the elemental function.
1985
c0075f3c 1986@item @emph{Example}:
1987@smallexample
1988program test_besyn
1989 real(8) :: x = 1.0_8
ff4425cf 1990 x = bessel_yn(5,x)
c0075f3c 1991end program test_besyn
1992@end smallexample
1993
1994@item @emph{Specific names}:
aee612a9 1995@multitable @columnfractions .20 .20 .20 .25
a3c4ed23 1996@item Name @tab Argument @tab Return type @tab Standard
e06f8026 1997@item @code{DBESYN(N,X)} @tab @code{INTEGER N} @tab @code{REAL(8)} @tab GNU extension
7d74ce87 1998@item @tab @code{REAL(8) X} @tab @tab
c0075f3c 1999@end multitable
2000@end table
2001
2002
bb3d0c30 2003
f004c7aa 2004@node BGE
2005@section @code{BGE} --- Bitwise greater than or equal to
2006@fnindex BGE
2007@cindex bitwise comparison
2008
2009@table @asis
2010@item @emph{Description}:
2011Determines whether an integral is a bitwise greater than or equal to
2012another.
2013
2014@item @emph{Standard}:
2015Fortran 2008 and later
2016
2017@item @emph{Class}:
2018Elemental function
2019
2020@item @emph{Syntax}:
2021@code{RESULT = BGE(I, J)}
2022
2023@item @emph{Arguments}:
2024@multitable @columnfractions .15 .70
2025@item @var{I} @tab Shall be of @code{INTEGER} type.
2026@item @var{J} @tab Shall be of @code{INTEGER} type, and of the same kind
2027as @var{I}.
2028@end multitable
2029
2030@item @emph{Return value}:
2031The return value is of type @code{LOGICAL} and of the default kind.
2032
2033@item @emph{See also}:
2034@ref{BGT}, @ref{BLE}, @ref{BLT}
2035@end table
2036
2037
2038
2039@node BGT
2040@section @code{BGT} --- Bitwise greater than
2041@fnindex BGT
2042@cindex bitwise comparison
2043
2044@table @asis
2045@item @emph{Description}:
2046Determines whether an integral is a bitwise greater than another.
2047
2048@item @emph{Standard}:
2049Fortran 2008 and later
2050
2051@item @emph{Class}:
2052Elemental function
2053
2054@item @emph{Syntax}:
2055@code{RESULT = BGT(I, J)}
2056
2057@item @emph{Arguments}:
2058@multitable @columnfractions .15 .70
2059@item @var{I} @tab Shall be of @code{INTEGER} type.
2060@item @var{J} @tab Shall be of @code{INTEGER} type, and of the same kind
2061as @var{I}.
2062@end multitable
2063
2064@item @emph{Return value}:
2065The return value is of type @code{LOGICAL} and of the default kind.
2066
2067@item @emph{See also}:
2068@ref{BGE}, @ref{BLE}, @ref{BLT}
2069@end table
2070
2071
2072
bb3d0c30 2073@node BIT_SIZE
2074@section @code{BIT_SIZE} --- Bit size inquiry function
a1149005 2075@fnindex BIT_SIZE
2076@cindex bits, number of
5e246457 2077@cindex size of a variable, in bits
bb3d0c30 2078
2079@table @asis
2080@item @emph{Description}:
c656b4ab 2081@code{BIT_SIZE(I)} returns the number of bits (integer precision plus sign bit)
57b9ac90 2082represented by the type of @var{I}. The result of @code{BIT_SIZE(I)} is
2083independent of the actual value of @var{I}.
bb3d0c30 2084
a3c4ed23 2085@item @emph{Standard}:
f40b44c0 2086Fortran 95 and later
bb3d0c30 2087
2088@item @emph{Class}:
a3c4ed23 2089Inquiry function
bb3d0c30 2090
2091@item @emph{Syntax}:
4eb41f08 2092@code{RESULT = BIT_SIZE(I)}
bb3d0c30 2093
2094@item @emph{Arguments}:
aee612a9 2095@multitable @columnfractions .15 .70
e06f8026 2096@item @var{I} @tab The type shall be @code{INTEGER}.
bb3d0c30 2097@end multitable
2098
2099@item @emph{Return value}:
e06f8026 2100The return value is of type @code{INTEGER}
bb3d0c30 2101
2102@item @emph{Example}:
2103@smallexample
2104program test_bit_size
2105 integer :: i = 123
2106 integer :: size
2107 size = bit_size(i)
2108 print *, size
2109end program test_bit_size
2110@end smallexample
2111@end table
2112
2113
2114
f004c7aa 2115@node BLE
2116@section @code{BLE} --- Bitwise less than or equal to
2117@fnindex BLE
2118@cindex bitwise comparison
2119
2120@table @asis
2121@item @emph{Description}:
2122Determines whether an integral is a bitwise less than or equal to
2123another.
2124
2125@item @emph{Standard}:
2126Fortran 2008 and later
2127
2128@item @emph{Class}:
2129Elemental function
2130
2131@item @emph{Syntax}:
2132@code{RESULT = BLE(I, J)}
2133
2134@item @emph{Arguments}:
2135@multitable @columnfractions .15 .70
2136@item @var{I} @tab Shall be of @code{INTEGER} type.
2137@item @var{J} @tab Shall be of @code{INTEGER} type, and of the same kind
2138as @var{I}.
2139@end multitable
2140
2141@item @emph{Return value}:
2142The return value is of type @code{LOGICAL} and of the default kind.
2143
2144@item @emph{See also}:
2145@ref{BGT}, @ref{BGE}, @ref{BLT}
2146@end table
2147
2148
2149
2150@node BLT
2151@section @code{BLT} --- Bitwise less than
2152@fnindex BLT
2153@cindex bitwise comparison
2154
2155@table @asis
2156@item @emph{Description}:
2157Determines whether an integral is a bitwise less than another.
2158
2159@item @emph{Standard}:
2160Fortran 2008 and later
2161
2162@item @emph{Class}:
2163Elemental function
2164
2165@item @emph{Syntax}:
2166@code{RESULT = BLT(I, J)}
2167
2168@item @emph{Arguments}:
2169@multitable @columnfractions .15 .70
2170@item @var{I} @tab Shall be of @code{INTEGER} type.
2171@item @var{J} @tab Shall be of @code{INTEGER} type, and of the same kind
2172as @var{I}.
2173@end multitable
2174
2175@item @emph{Return value}:
2176The return value is of type @code{LOGICAL} and of the default kind.
2177
2178@item @emph{See also}:
2179@ref{BGE}, @ref{BGT}, @ref{BLE}
2180@end table
2181
2182
2183
bb3d0c30 2184@node BTEST
2185@section @code{BTEST} --- Bit test function
a1149005 2186@fnindex BTEST
2187@cindex bits, testing
bb3d0c30 2188
2189@table @asis
2190@item @emph{Description}:
c656b4ab 2191@code{BTEST(I,POS)} returns logical @code{.TRUE.} if the bit at @var{POS}
57b9ac90 2192in @var{I} is set. The counting of the bits starts at 0.
bb3d0c30 2193
a3c4ed23 2194@item @emph{Standard}:
f40b44c0 2195Fortran 95 and later
bb3d0c30 2196
2197@item @emph{Class}:
a3c4ed23 2198Elemental function
bb3d0c30 2199
2200@item @emph{Syntax}:
4eb41f08 2201@code{RESULT = BTEST(I, POS)}
bb3d0c30 2202
2203@item @emph{Arguments}:
aee612a9 2204@multitable @columnfractions .15 .70
e06f8026 2205@item @var{I} @tab The type shall be @code{INTEGER}.
2206@item @var{POS} @tab The type shall be @code{INTEGER}.
bb3d0c30 2207@end multitable
2208
2209@item @emph{Return value}:
2210The return value is of type @code{LOGICAL}
2211
2212@item @emph{Example}:
2213@smallexample
2214program test_btest
2215 integer :: i = 32768 + 1024 + 64
2216 integer :: pos
2217 logical :: bool
2218 do pos=0,16
2219 bool = btest(i, pos)
2220 print *, pos, bool
2221 end do
2222end program test_btest
2223@end smallexample
2224@end table
2225
2226
10e232cd 2227@node C_ASSOCIATED
2228@section @code{C_ASSOCIATED} --- Status of a C pointer
2229@fnindex C_ASSOCIATED
a0527218 2230@cindex association status, C pointer
2231@cindex pointer, C association status
10e232cd 2232
2233@table @asis
2234@item @emph{Description}:
e06f8026 2235@code{C_ASSOCIATED(c_prt_1[, c_ptr_2])} determines the status of the C pointer
2236@var{c_ptr_1} or if @var{c_ptr_1} is associated with the target @var{c_ptr_2}.
10e232cd 2237
2238@item @emph{Standard}:
ff4425cf 2239Fortran 2003 and later
10e232cd 2240
2241@item @emph{Class}:
2242Inquiry function
2243
2244@item @emph{Syntax}:
e06f8026 2245@code{RESULT = C_ASSOCIATED(c_prt_1[, c_ptr_2])}
10e232cd 2246
2247@item @emph{Arguments}:
2248@multitable @columnfractions .15 .70
e06f8026 2249@item @var{c_ptr_1} @tab Scalar of the type @code{C_PTR} or @code{C_FUNPTR}.
2250@item @var{c_ptr_2} @tab (Optional) Scalar of the same type as @var{c_ptr_1}.
10e232cd 2251@end multitable
2252
2253@item @emph{Return value}:
2254The return value is of type @code{LOGICAL}; it is @code{.false.} if either
e06f8026 2255@var{c_ptr_1} is a C NULL pointer or if @var{c_ptr1} and @var{c_ptr_2}
10e232cd 2256point to different addresses.
2257
2258@item @emph{Example}:
2259@smallexample
2260subroutine association_test(a,b)
2261 use iso_c_binding, only: c_associated, c_loc, c_ptr
2262 implicit none
2263 real, pointer :: a
2264 type(c_ptr) :: b
2265 if(c_associated(b, c_loc(a))) &
2266 stop 'b and a do not point to same target'
2267end subroutine association_test
2268@end smallexample
2269
2270@item @emph{See also}:
2271@ref{C_LOC}, @ref{C_FUNLOC}
2272@end table
2273
2274
2275@node C_FUNLOC
2276@section @code{C_FUNLOC} --- Obtain the C address of a procedure
2277@fnindex C_FUNLOC
2278@cindex pointer, C address of procedures
2279
2280@table @asis
2281@item @emph{Description}:
2282@code{C_FUNLOC(x)} determines the C address of the argument.
2283
2284@item @emph{Standard}:
ff4425cf 2285Fortran 2003 and later
10e232cd 2286
2287@item @emph{Class}:
2288Inquiry function
2289
2290@item @emph{Syntax}:
2291@code{RESULT = C_FUNLOC(x)}
2292
2293@item @emph{Arguments}:
2294@multitable @columnfractions .15 .70
2295@item @var{x} @tab Interoperable function or pointer to such function.
2296@end multitable
2297
2298@item @emph{Return value}:
2299The return value is of type @code{C_FUNPTR} and contains the C address
2300of the argument.
2301
2302@item @emph{Example}:
2303@smallexample
2304module x
2305 use iso_c_binding
2306 implicit none
2307contains
2308 subroutine sub(a) bind(c)
2309 real(c_float) :: a
2310 a = sqrt(a)+5.0
2311 end subroutine sub
2312end module x
2313program main
2314 use iso_c_binding
2315 use x
2316 implicit none
2317 interface
2318 subroutine my_routine(p) bind(c,name='myC_func')
2319 import :: c_funptr
2320 type(c_funptr), intent(in) :: p
2321 end subroutine
2322 end interface
2323 call my_routine(c_funloc(sub))
2324end program main
2325@end smallexample
2326
2327@item @emph{See also}:
2328@ref{C_ASSOCIATED}, @ref{C_LOC}, @ref{C_F_POINTER}, @ref{C_F_PROCPOINTER}
2329@end table
2330
2331
2332@node C_F_PROCPOINTER
2333@section @code{C_F_PROCPOINTER} --- Convert C into Fortran procedure pointer
2334@fnindex C_F_PROCPOINTER
2335@cindex pointer, C address of pointers
2336
2337@table @asis
2338@item @emph{Description}:
e06f8026 2339@code{C_F_PROCPOINTER(CPTR, FPTR)} Assign the target of the C function pointer
2340@var{CPTR} to the Fortran procedure pointer @var{FPTR}.
10e232cd 2341
10e232cd 2342@item @emph{Standard}:
ff4425cf 2343Fortran 2003 and later
10e232cd 2344
2345@item @emph{Class}:
2346Subroutine
2347
2348@item @emph{Syntax}:
2349@code{CALL C_F_PROCPOINTER(cptr, fptr)}
2350
2351@item @emph{Arguments}:
2352@multitable @columnfractions .15 .70
e06f8026 2353@item @var{CPTR} @tab scalar of the type @code{C_FUNPTR}. It is
c24c5fac 2354@code{INTENT(IN)}.
e06f8026 2355@item @var{FPTR} @tab procedure pointer interoperable with @var{cptr}. It is
c24c5fac 2356@code{INTENT(OUT)}.
10e232cd 2357@end multitable
2358
2359@item @emph{Example}:
2360@smallexample
2361program main
2362 use iso_c_binding
2363 implicit none
2364 abstract interface
2365 function func(a)
2366 import :: c_float
2367 real(c_float), intent(in) :: a
2368 real(c_float) :: func
2369 end function
2370 end interface
2371 interface
2372 function getIterFunc() bind(c,name="getIterFunc")
2373 import :: c_funptr
2374 type(c_funptr) :: getIterFunc
2375 end function
2376 end interface
2377 type(c_funptr) :: cfunptr
2378 procedure(func), pointer :: myFunc
2379 cfunptr = getIterFunc()
2380 call c_f_procpointer(cfunptr, myFunc)
2381end program main
2382@end smallexample
2383
2384@item @emph{See also}:
2385@ref{C_LOC}, @ref{C_F_POINTER}
2386@end table
2387
2388
2389@node C_F_POINTER
2390@section @code{C_F_POINTER} --- Convert C into Fortran pointer
2391@fnindex C_F_POINTER
2392@cindex pointer, convert C to Fortran
2393
2394@table @asis
2395@item @emph{Description}:
abd3b740 2396@code{C_F_POINTER(CPTR, FPTR[, SHAPE])} assigns the target of the C pointer
2397@var{CPTR} to the Fortran pointer @var{FPTR} and specifies its shape.
10e232cd 2398
2399@item @emph{Standard}:
ff4425cf 2400Fortran 2003 and later
10e232cd 2401
2402@item @emph{Class}:
2403Subroutine
2404
2405@item @emph{Syntax}:
e06f8026 2406@code{CALL C_F_POINTER(CPTR, FPTR[, SHAPE])}
10e232cd 2407
2408@item @emph{Arguments}:
2409@multitable @columnfractions .15 .70
e06f8026 2410@item @var{CPTR} @tab scalar of the type @code{C_PTR}. It is
c24c5fac 2411@code{INTENT(IN)}.
e06f8026 2412@item @var{FPTR} @tab pointer interoperable with @var{cptr}. It is
c24c5fac 2413@code{INTENT(OUT)}.
e06f8026 2414@item @var{SHAPE} @tab (Optional) Rank-one array of type @code{INTEGER}
c24c5fac 2415with @code{INTENT(IN)}. It shall be present
2416if and only if @var{fptr} is an array. The size
2417must be equal to the rank of @var{fptr}.
10e232cd 2418@end multitable
2419
2420@item @emph{Example}:
2421@smallexample
2422program main
2423 use iso_c_binding
2424 implicit none
2425 interface
2426 subroutine my_routine(p) bind(c,name='myC_func')
2427 import :: c_ptr
2428 type(c_ptr), intent(out) :: p
2429 end subroutine
2430 end interface
2431 type(c_ptr) :: cptr
2432 real,pointer :: a(:)
2433 call my_routine(cptr)
2434 call c_f_pointer(cptr, a, [12])
2435end program main
2436@end smallexample
2437
2438@item @emph{See also}:
2439@ref{C_LOC}, @ref{C_F_PROCPOINTER}
2440@end table
2441
2442
2443@node C_LOC
2444@section @code{C_LOC} --- Obtain the C address of an object
2445@fnindex C_LOC
2446@cindex procedure pointer, convert C to Fortran
2447
2448@table @asis
2449@item @emph{Description}:
e06f8026 2450@code{C_LOC(X)} determines the C address of the argument.
10e232cd 2451
2452@item @emph{Standard}:
ff4425cf 2453Fortran 2003 and later
10e232cd 2454
2455@item @emph{Class}:
2456Inquiry function
2457
2458@item @emph{Syntax}:
e06f8026 2459@code{RESULT = C_LOC(X)}
10e232cd 2460
2461@item @emph{Arguments}:
f10a970e 2462@multitable @columnfractions .10 .75
2463@item @var{X} @tab Shall have either the POINTER or TARGET attribute. It shall not be a coindexed object. It shall either be a variable with interoperable type and kind type parameters, or be a scalar, nonpolymorphic variable with no length type parameters.
2464
10e232cd 2465@end multitable
2466
2467@item @emph{Return value}:
2468The return value is of type @code{C_PTR} and contains the C address
2469of the argument.
2470
2471@item @emph{Example}:
2472@smallexample
2473subroutine association_test(a,b)
2474 use iso_c_binding, only: c_associated, c_loc, c_ptr
2475 implicit none
2476 real, pointer :: a
2477 type(c_ptr) :: b
2478 if(c_associated(b, c_loc(a))) &
2479 stop 'b and a do not point to same target'
2480end subroutine association_test
2481@end smallexample
2482
2483@item @emph{See also}:
2484@ref{C_ASSOCIATED}, @ref{C_FUNLOC}, @ref{C_F_POINTER}, @ref{C_F_PROCPOINTER}
2485@end table
2486
bb3d0c30 2487
189ffda5 2488@node C_SIZEOF
2489@section @code{C_SIZEOF} --- Size in bytes of an expression
2490@fnindex C_SIZEOF
2491@cindex expression size
2492@cindex size of an expression
2493
2494@table @asis
2495@item @emph{Description}:
2496@code{C_SIZEOF(X)} calculates the number of bytes of storage the
2497expression @code{X} occupies.
2498
2499@item @emph{Standard}:
2500Fortran 2008
2501
2502@item @emph{Class}:
e3d1ab2b 2503Inquiry function of the module @code{ISO_C_BINDING}
189ffda5 2504
2505@item @emph{Syntax}:
2506@code{N = C_SIZEOF(X)}
2507
2508@item @emph{Arguments}:
2509@multitable @columnfractions .15 .70
24c079ad 2510@item @var{X} @tab The argument shall be an interoperable data entity.
189ffda5 2511@end multitable
2512
2513@item @emph{Return value}:
2514The return value is of type integer and of the system-dependent kind
e3d1ab2b 2515@code{C_SIZE_T} (from the @code{ISO_C_BINDING} module). Its value is the
189ffda5 2516number of bytes occupied by the argument. If the argument has the
2517@code{POINTER} attribute, the number of bytes of the storage area pointed
2518to is returned. If the argument is of a derived type with @code{POINTER}
6152df27 2519or @code{ALLOCATABLE} components, the return value does not account for
189ffda5 2520the sizes of the data pointed to by these components.
2521
2522@item @emph{Example}:
2523@smallexample
2524 use iso_c_binding
2525 integer(c_int) :: i
2526 real(c_float) :: r, s(5)
2527 print *, (c_sizeof(s)/c_sizeof(r) == 5)
2528 end
2529@end smallexample
2530The example will print @code{.TRUE.} unless you are using a platform
2531where default @code{REAL} variables are unusually padded.
2532
2533@item @emph{See also}:
24c079ad 2534@ref{SIZEOF}, @ref{STORAGE_SIZE}
189ffda5 2535@end table
2536
2537
bb3d0c30 2538@node CEILING
2539@section @code{CEILING} --- Integer ceiling function
a1149005 2540@fnindex CEILING
5e246457 2541@cindex ceiling
a1149005 2542@cindex rounding, ceiling
bb3d0c30 2543
2544@table @asis
2545@item @emph{Description}:
e06f8026 2546@code{CEILING(A)} returns the least integer greater than or equal to @var{A}.
bb3d0c30 2547
a3c4ed23 2548@item @emph{Standard}:
f40b44c0 2549Fortran 95 and later
bb3d0c30 2550
2551@item @emph{Class}:
a3c4ed23 2552Elemental function
bb3d0c30 2553
2554@item @emph{Syntax}:
e06f8026 2555@code{RESULT = CEILING(A [, KIND])}
bb3d0c30 2556
2557@item @emph{Arguments}:
aee612a9 2558@multitable @columnfractions .15 .70
e06f8026 2559@item @var{A} @tab The type shall be @code{REAL}.
2560@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
c24c5fac 2561expression indicating the kind parameter of the result.
bb3d0c30 2562@end multitable
2563
2564@item @emph{Return value}:
e06f8026 2565The return value is of type @code{INTEGER(KIND)} if @var{KIND} is present
2566and a default-kind @code{INTEGER} otherwise.
bb3d0c30 2567
2568@item @emph{Example}:
2569@smallexample
2570program test_ceiling
2571 real :: x = 63.29
2572 real :: y = -63.59
2573 print *, ceiling(x) ! returns 64
2574 print *, ceiling(y) ! returns -63
2575end program test_ceiling
2576@end smallexample
a3c4ed23 2577
2578@item @emph{See also}:
2579@ref{FLOOR}, @ref{NINT}
2580
bb3d0c30 2581@end table
2582
2583
2584
2585@node CHAR
2586@section @code{CHAR} --- Character conversion function
a1149005 2587@fnindex CHAR
2588@cindex conversion, to character
bb3d0c30 2589
2590@table @asis
2591@item @emph{Description}:
0eb92d52 2592@code{CHAR(I [, KIND])} returns the character represented by the integer @var{I}.
bb3d0c30 2593
a3c4ed23 2594@item @emph{Standard}:
f40b44c0 2595Fortran 77 and later
bb3d0c30 2596
2597@item @emph{Class}:
a3c4ed23 2598Elemental function
bb3d0c30 2599
2600@item @emph{Syntax}:
4eb41f08 2601@code{RESULT = CHAR(I [, KIND])}
bb3d0c30 2602
2603@item @emph{Arguments}:
aee612a9 2604@multitable @columnfractions .15 .70
e06f8026 2605@item @var{I} @tab The type shall be @code{INTEGER}.
2606@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
c24c5fac 2607expression indicating the kind parameter of the result.
bb3d0c30 2608@end multitable
2609
2610@item @emph{Return value}:
2611The return value is of type @code{CHARACTER(1)}
2612
2613@item @emph{Example}:
2614@smallexample
2615program test_char
2616 integer :: i = 74
2617 character(1) :: c
2618 c = char(i)
2619 print *, i, c ! returns 'J'
2620end program test_char
2621@end smallexample
a3c4ed23 2622
7d74ce87 2623@item @emph{Specific names}:
2624@multitable @columnfractions .20 .20 .20 .25
2625@item Name @tab Argument @tab Return type @tab Standard
2626@item @code{CHAR(I)} @tab @code{INTEGER I} @tab @code{CHARACTER(LEN=1)} @tab F77 and later
2627@end multitable
2628
e95fe2fe 2629@item @emph{Note}:
2630See @ref{ICHAR} for a discussion of converting between numerical values
2631and formatted string representations.
2632
a3c4ed23 2633@item @emph{See also}:
c5cb0f03 2634@ref{ACHAR}, @ref{IACHAR}, @ref{ICHAR}
a3c4ed23 2635
2636@end table
2637
2638
fe97b755 2639
a3c4ed23 2640@node CHDIR
2641@section @code{CHDIR} --- Change working directory
a1149005 2642@fnindex CHDIR
2643@cindex system, working directory
a3c4ed23 2644
a3c4ed23 2645@table @asis
2646@item @emph{Description}:
7eb0a16c 2647Change current working directory to a specified path.
2648
2649This intrinsic is provided in both subroutine and function forms; however,
2650only one form can be used in any given program unit.
ed8f9044 2651
a3c4ed23 2652@item @emph{Standard}:
ed8f9044 2653GNU extension
2654
a3c4ed23 2655@item @emph{Class}:
138b8aca 2656Subroutine, function
ed8f9044 2657
a3c4ed23 2658@item @emph{Syntax}:
7eb0a16c 2659@multitable @columnfractions .80
2660@item @code{CALL CHDIR(NAME [, STATUS])}
2661@item @code{STATUS = CHDIR(NAME)}
2662@end multitable
ed8f9044 2663
a3c4ed23 2664@item @emph{Arguments}:
aee612a9 2665@multitable @columnfractions .15 .70
b44437b9 2666@item @var{NAME} @tab The type shall be @code{CHARACTER} of default
c24c5fac 2667kind and shall specify a valid path within the file system.
7eb0a16c 2668@item @var{STATUS} @tab (Optional) @code{INTEGER} status flag of the default
c24c5fac 2669kind. Returns 0 on success, and a system specific and nonzero error code
2670otherwise.
ed8f9044 2671@end multitable
2672
a3c4ed23 2673@item @emph{Example}:
ed8f9044 2674@smallexample
2675PROGRAM test_chdir
2676 CHARACTER(len=255) :: path
2677 CALL getcwd(path)
2678 WRITE(*,*) TRIM(path)
2679 CALL chdir("/tmp")
2680 CALL getcwd(path)
2681 WRITE(*,*) TRIM(path)
2682END PROGRAM
2683@end smallexample
2684
a3c4ed23 2685@item @emph{See also}:
ed8f9044 2686@ref{GETCWD}
bb3d0c30 2687@end table
2688
2689
ed8f9044 2690
a3c4ed23 2691@node CHMOD
2692@section @code{CHMOD} --- Change access permissions of files
a1149005 2693@fnindex CHMOD
2694@cindex file system, change access mode
a3c4ed23 2695
a3c4ed23 2696@table @asis
2697@item @emph{Description}:
cc4e1ef4 2698@code{CHMOD} changes the permissions of a file.
0873bfe5 2699
2700This intrinsic is provided in both subroutine and function forms; however,
2701only one form can be used in any given program unit.
a3c4ed23 2702
2703@item @emph{Standard}:
2704GNU extension
2705
2706@item @emph{Class}:
138b8aca 2707Subroutine, function
a3c4ed23 2708
2709@item @emph{Syntax}:
0873bfe5 2710@multitable @columnfractions .80
2711@item @code{CALL CHMOD(NAME, MODE[, STATUS])}
2712@item @code{STATUS = CHMOD(NAME, MODE)}
2713@end multitable
a5f53fac 2714
a3c4ed23 2715@item @emph{Arguments}:
aee612a9 2716@multitable @columnfractions .15 .70
a5f53fac 2717
b44437b9 2718@item @var{NAME} @tab Scalar @code{CHARACTER} of default kind with the
2719file name. Trailing blanks are ignored unless the character
2720@code{achar(0)} is present, then all characters up to and excluding
2721@code{achar(0)} are used as the file name.
2722
2723@item @var{MODE} @tab Scalar @code{CHARACTER} of default kind giving the
cc4e1ef4 2724file permission. @var{MODE} uses the same syntax as the @code{chmod} utility
2725as defined by the POSIX standard. The argument shall either be a string of
2726a nonnegative octal number or a symbolic mode.
a5f53fac 2727
2728@item @var{STATUS} @tab (optional) scalar @code{INTEGER}, which is
a0527218 2729@code{0} on success and nonzero otherwise.
a5f53fac 2730@end multitable
2731
0873bfe5 2732@item @emph{Return value}:
a0527218 2733In either syntax, @var{STATUS} is set to @code{0} on success and nonzero
0873bfe5 2734otherwise.
2735
a3c4ed23 2736@item @emph{Example}:
0873bfe5 2737@code{CHMOD} as subroutine
a5f53fac 2738@smallexample
2739program chmod_test
2740 implicit none
2741 integer :: status
2742 call chmod('test.dat','u+x',status)
2743 print *, 'Status: ', status
2744end program chmod_test
2745@end smallexample
138b8aca 2746@code{CHMOD} as function:
0873bfe5 2747@smallexample
2748program chmod_test
2749 implicit none
2750 integer :: status
2751 status = chmod('test.dat','u+x')
2752 print *, 'Status: ', status
2753end program chmod_test
2754@end smallexample
a3c4ed23 2755
2756@end table
2757
bb3d0c30 2758
fe97b755 2759
bb3d0c30 2760@node CMPLX
2761@section @code{CMPLX} --- Complex conversion function
a1149005 2762@fnindex CMPLX
5e246457 2763@cindex complex numbers, conversion to
a1149005 2764@cindex conversion, to complex
bb3d0c30 2765
2766@table @asis
2767@item @emph{Description}:
0eb92d52 2768@code{CMPLX(X [, Y [, KIND]])} returns a complex number where @var{X} is converted to
4e7aa3fa 2769the real component. If @var{Y} is present it is converted to the imaginary
2770component. If @var{Y} is not present then the imaginary component is set to
bb3d0c30 27710.0. If @var{X} is complex then @var{Y} must not be present.
2772
a3c4ed23 2773@item @emph{Standard}:
f40b44c0 2774Fortran 77 and later
bb3d0c30 2775
2776@item @emph{Class}:
a3c4ed23 2777Elemental function
bb3d0c30 2778
2779@item @emph{Syntax}:
4eb41f08 2780@code{RESULT = CMPLX(X [, Y [, KIND]])}
bb3d0c30 2781
2782@item @emph{Arguments}:
aee612a9 2783@multitable @columnfractions .15 .70
e06f8026 2784@item @var{X} @tab The type may be @code{INTEGER}, @code{REAL},
c24c5fac 2785or @code{COMPLEX}.
0eb92d52 2786@item @var{Y} @tab (Optional; only allowed if @var{X} is not
c24c5fac 2787@code{COMPLEX}.) May be @code{INTEGER} or @code{REAL}.
e06f8026 2788@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
c24c5fac 2789expression indicating the kind parameter of the result.
bb3d0c30 2790@end multitable
2791
2792@item @emph{Return value}:
57f524d7 2793The return value is of @code{COMPLEX} type, with a kind equal to
2794@var{KIND} if it is specified. If @var{KIND} is not specified, the
2795result is of the default @code{COMPLEX} kind, regardless of the kinds of
2796@var{X} and @var{Y}.
bb3d0c30 2797
2798@item @emph{Example}:
2799@smallexample
2800program test_cmplx
2801 integer :: i = 42
2802 real :: x = 3.14
2803 complex :: z
2804 z = cmplx(i, x)
2805 print *, z, cmplx(x)
2806end program test_cmplx
2807@end smallexample
57f524d7 2808
2809@item @emph{See also}:
2810@ref{COMPLEX}
bb3d0c30 2811@end table
2812
2813
2814
4e7aa3fa 2815@node COMMAND_ARGUMENT_COUNT
666bf11e 2816@section @code{COMMAND_ARGUMENT_COUNT} --- Get number of command line arguments
a1149005 2817@fnindex COMMAND_ARGUMENT_COUNT
2818@cindex command-line arguments
2819@cindex command-line arguments, number of
2820@cindex arguments, to program
4e7aa3fa 2821
2822@table @asis
2823@item @emph{Description}:
e8c1bbb4 2824@code{COMMAND_ARGUMENT_COUNT} returns the number of arguments passed on the
4e7aa3fa 2825command line when the containing program was invoked.
2826
a3c4ed23 2827@item @emph{Standard}:
ff4425cf 2828Fortran 2003 and later
4e7aa3fa 2829
2830@item @emph{Class}:
a3c4ed23 2831Inquiry function
4e7aa3fa 2832
2833@item @emph{Syntax}:
4eb41f08 2834@code{RESULT = COMMAND_ARGUMENT_COUNT()}
4e7aa3fa 2835
2836@item @emph{Arguments}:
aee612a9 2837@multitable @columnfractions .15 .70
4e7aa3fa 2838@item None
2839@end multitable
2840
2841@item @emph{Return value}:
2cd8ef8b 2842The return value is an @code{INTEGER} of default kind.
4e7aa3fa 2843
2844@item @emph{Example}:
2845@smallexample
2846program test_command_argument_count
2847 integer :: count
2848 count = command_argument_count()
2849 print *, count
2850end program test_command_argument_count
2851@end smallexample
4e7aa3fa 2852
666bf11e 2853@item @emph{See also}:
2854@ref{GET_COMMAND}, @ref{GET_COMMAND_ARGUMENT}
2855@end table
4e7aa3fa 2856
fe97b755 2857
2858
e3d1ab2b 2859@node COMPILER_OPTIONS
2860@section @code{COMPILER_OPTIONS} --- Options passed to the compiler
2861@fnindex COMPILER_OPTIONS
2862@cindex flags inquiry function
2863@cindex options inquiry function
2864@cindex compiler flags inquiry function
2865
2866@table @asis
2867@item @emph{Description}:
e8c1bbb4 2868@code{COMPILER_OPTIONS} returns a string with the options used for
e3d1ab2b 2869compiling.
2870
2871@item @emph{Standard}:
2872Fortran 2008
2873
2874@item @emph{Class}:
2875Inquiry function of the module @code{ISO_FORTRAN_ENV}
2876
2877@item @emph{Syntax}:
2878@code{STR = COMPILER_OPTIONS()}
2879
2880@item @emph{Arguments}:
2881None.
2882
2883@item @emph{Return value}:
2884The return value is a default-kind string with system-dependent length.
2885It contains the compiler flags used to compile the file, which called
2886the @code{COMPILER_OPTIONS} intrinsic.
2887
2888@item @emph{Example}:
2889@smallexample
2890 use iso_fortran_env
2891 print '(4a)', 'This file was compiled by ', &
851d9296 2892 compiler_version(), ' using the options ', &
e3d1ab2b 2893 compiler_options()
2894 end
2895@end smallexample
2896
2897@item @emph{See also}:
2898@ref{COMPILER_VERSION}, @ref{ISO_FORTRAN_ENV}
2899@end table
2900
2901
2902
2903@node COMPILER_VERSION
2904@section @code{COMPILER_VERSION} --- Compiler version string
2905@fnindex COMPILER_VERSION
2906@cindex compiler, name and version
2907@cindex version of the compiler
2908
2909@table @asis
2910@item @emph{Description}:
e8c1bbb4 2911@code{COMPILER_VERSION} returns a string with the name and the
e3d1ab2b 2912version of the compiler.
2913
2914@item @emph{Standard}:
2915Fortran 2008
2916
2917@item @emph{Class}:
2918Inquiry function of the module @code{ISO_FORTRAN_ENV}
2919
2920@item @emph{Syntax}:
2921@code{STR = COMPILER_VERSION()}
2922
2923@item @emph{Arguments}:
2924None.
2925
2926@item @emph{Return value}:
2927The return value is a default-kind string with system-dependent length.
2928It contains the name of the compiler and its version number.
2929
2930@item @emph{Example}:
2931@smallexample
2932 use iso_fortran_env
2933 print '(4a)', 'This file was compiled by ', &
851d9296 2934 compiler_version(), ' using the options ', &
e3d1ab2b 2935 compiler_options()
2936 end
2937@end smallexample
2938
2939@item @emph{See also}:
2940@ref{COMPILER_OPTIONS}, @ref{ISO_FORTRAN_ENV}
2941@end table
2942
2943
2944
57f524d7 2945@node COMPLEX
2946@section @code{COMPLEX} --- Complex conversion function
2947@fnindex COMPLEX
2948@cindex complex numbers, conversion to
2949@cindex conversion, to complex
2950
2951@table @asis
2952@item @emph{Description}:
2953@code{COMPLEX(X, Y)} returns a complex number where @var{X} is converted
2954to the real component and @var{Y} is converted to the imaginary
2955component.
2956
2957@item @emph{Standard}:
2958GNU extension
2959
2960@item @emph{Class}:
2961Elemental function
2962
2963@item @emph{Syntax}:
2964@code{RESULT = COMPLEX(X, Y)}
2965
2966@item @emph{Arguments}:
2967@multitable @columnfractions .15 .70
e06f8026 2968@item @var{X} @tab The type may be @code{INTEGER} or @code{REAL}.
2969@item @var{Y} @tab The type may be @code{INTEGER} or @code{REAL}.
57f524d7 2970@end multitable
2971
2972@item @emph{Return value}:
2973If @var{X} and @var{Y} are both of @code{INTEGER} type, then the return
2974value is of default @code{COMPLEX} type.
2975
2976If @var{X} and @var{Y} are of @code{REAL} type, or one is of @code{REAL}
2977type and one is of @code{INTEGER} type, then the return value is of
2978@code{COMPLEX} type with a kind equal to that of the @code{REAL}
2979argument with the highest precision.
2980
2981@item @emph{Example}:
2982@smallexample
2983program test_complex
2984 integer :: i = 42
2985 real :: x = 3.14
2986 print *, complex(i, x)
2987end program test_complex
2988@end smallexample
2989
2990@item @emph{See also}:
2991@ref{CMPLX}
2992@end table
2993
2994
2995
4e7aa3fa 2996@node CONJG
2997@section @code{CONJG} --- Complex conjugate function
a1149005 2998@fnindex CONJG
2999@fnindex DCONJG
4e7aa3fa 3000@cindex complex conjugate
a1149005 3001
4e7aa3fa 3002@table @asis
3003@item @emph{Description}:
3004@code{CONJG(Z)} returns the conjugate of @var{Z}. If @var{Z} is @code{(x, y)}
3005then the result is @code{(x, -y)}
3006
a3c4ed23 3007@item @emph{Standard}:
f40b44c0 3008Fortran 77 and later, has overloads that are GNU extensions
4e7aa3fa 3009
3010@item @emph{Class}:
a3c4ed23 3011Elemental function
4e7aa3fa 3012
3013@item @emph{Syntax}:
3014@code{Z = CONJG(Z)}
3015
3016@item @emph{Arguments}:
aee612a9 3017@multitable @columnfractions .15 .70
e06f8026 3018@item @var{Z} @tab The type shall be @code{COMPLEX}.
4e7aa3fa 3019@end multitable
3020
3021@item @emph{Return value}:
e06f8026 3022The return value is of type @code{COMPLEX}.
4e7aa3fa 3023
3024@item @emph{Example}:
3025@smallexample
3026program test_conjg
3027 complex :: z = (2.0, 3.0)
3028 complex(8) :: dz = (2.71_8, -3.14_8)
3029 z= conjg(z)
3030 print *, z
3031 dz = dconjg(dz)
3032 print *, dz
3033end program test_conjg
3034@end smallexample
3035
3036@item @emph{Specific names}:
aee612a9 3037@multitable @columnfractions .20 .20 .20 .25
7d74ce87 3038@item Name @tab Argument @tab Return type @tab Standard
3039@item @code{CONJG(Z)} @tab @code{COMPLEX Z} @tab @code{COMPLEX} @tab GNU extension
3040@item @code{DCONJG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
4e7aa3fa 3041@end multitable
3042@end table
3043
3044
3045
338c728c 3046@node COS
3047@section @code{COS} --- Cosine function
a1149005 3048@fnindex COS
3049@fnindex DCOS
3050@fnindex CCOS
3051@fnindex ZCOS
3052@fnindex CDCOS
3053@cindex trigonometric function, cosine
3054@cindex cosine
338c728c 3055
3056@table @asis
3057@item @emph{Description}:
3058@code{COS(X)} computes the cosine of @var{X}.
3059
a3c4ed23 3060@item @emph{Standard}:
f40b44c0 3061Fortran 77 and later, has overloads that are GNU extensions
338c728c 3062
bb3d0c30 3063@item @emph{Class}:
a3c4ed23 3064Elemental function
338c728c 3065
3066@item @emph{Syntax}:
4eb41f08 3067@code{RESULT = COS(X)}
338c728c 3068
3069@item @emph{Arguments}:
aee612a9 3070@multitable @columnfractions .15 .70
e06f8026 3071@item @var{X} @tab The type shall be @code{REAL} or
3072@code{COMPLEX}.
338c728c 3073@end multitable
3074
3075@item @emph{Return value}:
6f4274f9 3076The return value is of the same type and kind as @var{X}. The real part
3077of the result is in radians. If @var{X} is of the type @code{REAL},
3078the return value lies in the range @math{ -1 \leq \cos (x) \leq 1}.
338c728c 3079
3080@item @emph{Example}:
3081@smallexample
3082program test_cos
3083 real :: x = 0.0
3084 x = cos(x)
3085end program test_cos
3086@end smallexample
3087
3088@item @emph{Specific names}:
aee612a9 3089@multitable @columnfractions .20 .20 .20 .25
a3c4ed23 3090@item Name @tab Argument @tab Return type @tab Standard
11b070e5 3091@item @code{COS(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later
f40b44c0 3092@item @code{DCOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
3093@item @code{CCOS(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab Fortran 77 and later
a3c4ed23 3094@item @code{ZCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
3095@item @code{CDCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
338c728c 3096@end multitable
a3c4ed23 3097
3098@item @emph{See also}:
3099Inverse function: @ref{ACOS}
3100
338c728c 3101@end table
3102
c0075f3c 3103
bb3d0c30 3104
c0075f3c 3105@node COSH
3106@section @code{COSH} --- Hyperbolic cosine function
a1149005 3107@fnindex COSH
3108@fnindex DCOSH
c0075f3c 3109@cindex hyperbolic cosine
a1149005 3110@cindex hyperbolic function, cosine
3111@cindex cosine, hyperbolic
c0075f3c 3112
3113@table @asis
3114@item @emph{Description}:
3115@code{COSH(X)} computes the hyperbolic cosine of @var{X}.
3116
a3c4ed23 3117@item @emph{Standard}:
4ca842c8 3118Fortran 77 and later, for a complex argument Fortran 2008 or later
c0075f3c 3119
bb3d0c30 3120@item @emph{Class}:
a3c4ed23 3121Elemental function
c0075f3c 3122
3123@item @emph{Syntax}:
3124@code{X = COSH(X)}
3125
3126@item @emph{Arguments}:
aee612a9 3127@multitable @columnfractions .15 .70
4ca842c8 3128@item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
c0075f3c 3129@end multitable
3130
3131@item @emph{Return value}:
4ca842c8 3132The return value has same type and kind as @var{X}. If @var{X} is
3133complex, the imaginary part of the result is in radians. If @var{X}
3134is @code{REAL}, the return value has a lower bound of one,
3135@math{\cosh (x) \geq 1}.
c0075f3c 3136
3137@item @emph{Example}:
3138@smallexample
3139program test_cosh
3140 real(8) :: x = 1.0_8
3141 x = cosh(x)
3142end program test_cosh
3143@end smallexample
3144
3145@item @emph{Specific names}:
aee612a9 3146@multitable @columnfractions .20 .20 .20 .25
a3c4ed23 3147@item Name @tab Argument @tab Return type @tab Standard
7d74ce87 3148@item @code{COSH(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later
f40b44c0 3149@item @code{DCOSH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
c0075f3c 3150@end multitable
a3c4ed23 3151
3152@item @emph{See also}:
3153Inverse function: @ref{ACOSH}
3154
c0075f3c 3155@end table
3156
3157
bb3d0c30 3158
4e7aa3fa 3159@node COUNT
3160@section @code{COUNT} --- Count function
a1149005 3161@fnindex COUNT
3162@cindex array, conditionally count elements
3163@cindex array, element counting
3164@cindex array, number of elements
4e7aa3fa 3165
3166@table @asis
3167@item @emph{Description}:
7fe55cc9 3168
b646cda9 3169Counts the number of @code{.TRUE.} elements in a logical @var{MASK},
3170or, if the @var{DIM} argument is supplied, counts the number of
3171elements along each row of the array in the @var{DIM} direction.
3172If the array has zero size, or all of the elements of @var{MASK} are
3173@code{.FALSE.}, then the result is @code{0}.
4e7aa3fa 3174
a3c4ed23 3175@item @emph{Standard}:
f40b44c0 3176Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
4e7aa3fa 3177
3178@item @emph{Class}:
138b8aca 3179Transformational function
4e7aa3fa 3180
3181@item @emph{Syntax}:
b646cda9 3182@code{RESULT = COUNT(MASK [, DIM, KIND])}
4e7aa3fa 3183
3184@item @emph{Arguments}:
aee612a9 3185@multitable @columnfractions .15 .70
4e7aa3fa 3186@item @var{MASK} @tab The type shall be @code{LOGICAL}.
7fe55cc9 3187@item @var{DIM} @tab (Optional) The type shall be @code{INTEGER}.
3188@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
c24c5fac 3189expression indicating the kind parameter of the result.
4e7aa3fa 3190@end multitable
3191
3192@item @emph{Return value}:
7fe55cc9 3193The return value is of type @code{INTEGER} and of kind @var{KIND}. If
3194@var{KIND} is absent, the return value is of default integer kind.
b646cda9 3195If @var{DIM} is present, the result is an array with a rank one less
3196than the rank of @var{ARRAY}, and a size corresponding to the shape
3197of @var{ARRAY} with the @var{DIM} dimension removed.
4e7aa3fa 3198
3199@item @emph{Example}:
3200@smallexample
3201program test_count
3202 integer, dimension(2,3) :: a, b
3203 logical, dimension(2,3) :: mask
3204 a = reshape( (/ 1, 2, 3, 4, 5, 6 /), (/ 2, 3 /))
3205 b = reshape( (/ 0, 7, 3, 4, 5, 8 /), (/ 2, 3 /))
3206 print '(3i3)', a(1,:)
3207 print '(3i3)', a(2,:)
3208 print *
3209 print '(3i3)', b(1,:)
3210 print '(3i3)', b(2,:)
3211 print *
3212 mask = a.ne.b
3213 print '(3l3)', mask(1,:)
3214 print '(3l3)', mask(2,:)
3215 print *
3216 print '(3i3)', count(mask)
3217 print *
3218 print '(3i3)', count(mask, 1)
3219 print *
3220 print '(3i3)', count(mask, 2)
3221end program test_count
3222@end smallexample
3223@end table
3224
3225
3226
3227@node CPU_TIME
3228@section @code{CPU_TIME} --- CPU elapsed time in seconds
a1149005 3229@fnindex CPU_TIME
5e246457 3230@cindex time, elapsed
4e7aa3fa 3231
3232@table @asis
3233@item @emph{Description}:
e06f8026 3234Returns a @code{REAL} value representing the elapsed CPU time in
fe97b755 3235seconds. This is useful for testing segments of code to determine
3236execution time.
4e7aa3fa 3237
dd6c1457 3238If a time source is available, time will be reported with microsecond
3239resolution. If no time source is available, @var{TIME} is set to
3240@code{-1.0}.
3241
3242Note that @var{TIME} may contain a, system dependent, arbitrary offset
3243and may not start with @code{0.0}. For @code{CPU_TIME}, the absolute
3244value is meaningless, only differences between subsequent calls to
3245this subroutine, as shown in the example below, should be used.
3246
3247
a3c4ed23 3248@item @emph{Standard}:
f40b44c0 3249Fortran 95 and later
4e7aa3fa 3250
3251@item @emph{Class}:
a3c4ed23 3252Subroutine
4e7aa3fa 3253
3254@item @emph{Syntax}:
bf4e8122 3255@code{CALL CPU_TIME(TIME)}
4e7aa3fa 3256
3257@item @emph{Arguments}:
aee612a9 3258@multitable @columnfractions .15 .70
e06f8026 3259@item @var{TIME} @tab The type shall be @code{REAL} with @code{INTENT(OUT)}.
4e7aa3fa 3260@end multitable
3261
3262@item @emph{Return value}:
3263None
3264
3265@item @emph{Example}:
3266@smallexample
3267program test_cpu_time
3268 real :: start, finish
3269 call cpu_time(start)
3270 ! put code to test here
3271 call cpu_time(finish)
3272 print '("Time = ",f6.3," seconds.")',finish-start
3273end program test_cpu_time
3274@end smallexample
c3faa3c9 3275
3276@item @emph{See also}:
3277@ref{SYSTEM_CLOCK}, @ref{DATE_AND_TIME}
4e7aa3fa 3278@end table
3279
3280
3281
3282@node CSHIFT
a1149005 3283@section @code{CSHIFT} --- Circular shift elements of an array
3284@fnindex CSHIFT
3285@cindex array, shift circularly
3286@cindex array, permutation
3287@cindex array, rotate
4e7aa3fa 3288
3289@table @asis
3290@item @emph{Description}:
4eb41f08 3291@code{CSHIFT(ARRAY, SHIFT [, DIM])} performs a circular shift on elements of
4e7aa3fa 3292@var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is omitted it is
57b9ac90 3293taken to be @code{1}. @var{DIM} is a scalar of type @code{INTEGER} in the
83c6ea1d 3294range of @math{1 \leq DIM \leq n)} where @math{n} is the rank of @var{ARRAY}.
4e7aa3fa 3295If the rank of @var{ARRAY} is one, then all elements of @var{ARRAY} are shifted
3296by @var{SHIFT} places. If rank is greater than one, then all complete rank one
3297sections of @var{ARRAY} along the given dimension are shifted. Elements
3298shifted out one end of each rank one section are shifted back in the other end.
3299
a3c4ed23 3300@item @emph{Standard}:
f40b44c0 3301Fortran 95 and later
4e7aa3fa 3302
3303@item @emph{Class}:
dceb1607 3304Transformational function
4e7aa3fa 3305
3306@item @emph{Syntax}:
dceb1607 3307@code{RESULT = CSHIFT(ARRAY, SHIFT [, DIM])}
4e7aa3fa 3308
3309@item @emph{Arguments}:
aee612a9 3310@multitable @columnfractions .15 .70
dceb1607 3311@item @var{ARRAY} @tab Shall be an array of any type.
4e7aa3fa 3312@item @var{SHIFT} @tab The type shall be @code{INTEGER}.
3313@item @var{DIM} @tab The type shall be @code{INTEGER}.
3314@end multitable
3315
3316@item @emph{Return value}:
3317Returns an array of same type and rank as the @var{ARRAY} argument.
3318
3319@item @emph{Example}:
3320@smallexample
3321program test_cshift
3322 integer, dimension(3,3) :: a
3323 a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
3324 print '(3i3)', a(1,:)
3325 print '(3i3)', a(2,:)
3326 print '(3i3)', a(3,:)
3327 a = cshift(a, SHIFT=(/1, 2, -1/), DIM=2)
3328 print *
3329 print '(3i3)', a(1,:)
3330 print '(3i3)', a(2,:)
3331 print '(3i3)', a(3,:)
3332end program test_cshift
3333@end smallexample
3334@end table
3335
3336
fe97b755 3337
b902b078 3338@node CTIME
3339@section @code{CTIME} --- Convert a time into a string
a1149005 3340@fnindex CTIME
3341@cindex time, conversion to string
3342@cindex conversion, to string
b902b078 3343
3344@table @asis
3345@item @emph{Description}:
7eb0a16c 3346@code{CTIME} converts a system time value, such as returned by
4be95726 3347@code{TIME8}, to a string. Unless the application has called
3348@code{setlocale}, the output will be in the default locale, of length
334924 and of the form @samp{Sat Aug 19 18:13:14 1995}. In other locales,
3350a longer string may result.
b902b078 3351
7eb0a16c 3352This intrinsic is provided in both subroutine and function forms; however,
3353only one form can be used in any given program unit.
b902b078 3354
a3c4ed23 3355@item @emph{Standard}:
3356GNU extension
b902b078 3357
3358@item @emph{Class}:
138b8aca 3359Subroutine, function
b902b078 3360
3361@item @emph{Syntax}:
3362@multitable @columnfractions .80
7eb0a16c 3363@item @code{CALL CTIME(TIME, RESULT)}.
4be95726 3364@item @code{RESULT = CTIME(TIME)}.
b902b078 3365@end multitable
3366
3367@item @emph{Arguments}:
aee612a9 3368@multitable @columnfractions .15 .70
4be95726 3369@item @var{TIME} @tab The type shall be of type @code{INTEGER}.
b44437b9 3370@item @var{RESULT} @tab The type shall be of type @code{CHARACTER} and
4be95726 3371of default kind. It is an @code{INTENT(OUT)} argument. If the length
3372of this variable is too short for the time and date string to fit
3373completely, it will be blank on procedure return.
b902b078 3374@end multitable
3375
3376@item @emph{Return value}:
4be95726 3377The converted date and time as a string.
b902b078 3378
3379@item @emph{Example}:
3380@smallexample
3381program test_ctime
3382 integer(8) :: i
3383 character(len=30) :: date
3384 i = time8()
3385
3386 ! Do something, main part of the program
3387
3388 call ctime(i,date)
3389 print *, 'Program was started on ', date
3390end program test_ctime
3391@end smallexample
0eb92d52 3392
3393@item @emph{See Also}:
4be95726 3394@ref{DATE_AND_TIME}, @ref{GMTIME}, @ref{LTIME}, @ref{TIME}, @ref{TIME8}
b902b078 3395@end table
4e7aa3fa 3396
0eb92d52 3397
3398
4e7aa3fa 3399@node DATE_AND_TIME
3400@section @code{DATE_AND_TIME} --- Date and time subroutine
a1149005 3401@fnindex DATE_AND_TIME
5e246457 3402@cindex date, current
3403@cindex current date
3404@cindex time, current
3405@cindex current time
4e7aa3fa 3406
3407@table @asis
3408@item @emph{Description}:
3409@code{DATE_AND_TIME(DATE, TIME, ZONE, VALUES)} gets the corresponding date and
3410time information from the real-time system clock. @var{DATE} is
3411@code{INTENT(OUT)} and has form ccyymmdd. @var{TIME} is @code{INTENT(OUT)} and
3412has form hhmmss.sss. @var{ZONE} is @code{INTENT(OUT)} and has form (+-)hhmm,
3413representing the difference with respect to Coordinated Universal Time (UTC).
3414Unavailable time and date parameters return blanks.
3415
3416@var{VALUES} is @code{INTENT(OUT)} and provides the following:
3417
aee612a9 3418@multitable @columnfractions .15 .30 .40
20d81f06 3419@item @tab @code{VALUE(1)}: @tab The year
4e7aa3fa 3420@item @tab @code{VALUE(2)}: @tab The month
3421@item @tab @code{VALUE(3)}: @tab The day of the month
ed8f9044 3422@item @tab @code{VALUE(4)}: @tab Time difference with UTC in minutes
4e7aa3fa 3423@item @tab @code{VALUE(5)}: @tab The hour of the day
3424@item @tab @code{VALUE(6)}: @tab The minutes of the hour
3425@item @tab @code{VALUE(7)}: @tab The seconds of the minute
3426@item @tab @code{VALUE(8)}: @tab The milliseconds of the second
c24c5fac 3427@end multitable
4e7aa3fa 3428
a3c4ed23 3429@item @emph{Standard}:
f40b44c0 3430Fortran 95 and later
4e7aa3fa 3431
3432@item @emph{Class}:
a3c4ed23 3433Subroutine
4e7aa3fa 3434
3435@item @emph{Syntax}:
3436@code{CALL DATE_AND_TIME([DATE, TIME, ZONE, VALUES])}
3437
4e7aa3fa 3438@item @emph{Arguments}:
aee612a9 3439@multitable @columnfractions .15 .70
b44437b9 3440@item @var{DATE} @tab (Optional) The type shall be @code{CHARACTER(LEN=8)}
c24c5fac 3441or larger, and of default kind.
b44437b9 3442@item @var{TIME} @tab (Optional) The type shall be @code{CHARACTER(LEN=10)}
c24c5fac 3443or larger, and of default kind.
b44437b9 3444@item @var{ZONE} @tab (Optional) The type shall be @code{CHARACTER(LEN=5)}
c24c5fac 3445or larger, and of default kind.
20d81f06 3446@item @var{VALUES}@tab (Optional) The type shall be @code{INTEGER(8)}.
4e7aa3fa 3447@end multitable
3448
3449@item @emph{Return value}:
3450None
3451
3452@item @emph{Example}:
3453@smallexample
3454program test_time_and_date
3455 character(8) :: date
3456 character(10) :: time
3457 character(5) :: zone
3458 integer,dimension(8) :: values
3459 ! using keyword arguments
3460 call date_and_time(date,time,zone,values)
3461 call date_and_time(DATE=date,ZONE=zone)
3462 call date_and_time(TIME=time)
3463 call date_and_time(VALUES=values)
3464 print '(a,2x,a,2x,a)', date, time, zone
3465 print '(8i5))', values
3466end program test_time_and_date
3467@end smallexample
c3faa3c9 3468
3469@item @emph{See also}:
3470@ref{CPU_TIME}, @ref{SYSTEM_CLOCK}
4e7aa3fa 3471@end table
3472
3473
3474
3475@node DBLE
3476@section @code{DBLE} --- Double conversion function
a1149005 3477@fnindex DBLE
3478@cindex conversion, to real
4e7aa3fa 3479
3480@table @asis
3481@item @emph{Description}:
e06f8026 3482@code{DBLE(A)} Converts @var{A} to double precision real type.
4e7aa3fa 3483
a3c4ed23 3484@item @emph{Standard}:
f40b44c0 3485Fortran 77 and later
4e7aa3fa 3486
3487@item @emph{Class}:
a3c4ed23 3488Elemental function
4e7aa3fa 3489
3490@item @emph{Syntax}:
e06f8026 3491@code{RESULT = DBLE(A)}
4e7aa3fa 3492
3493@item @emph{Arguments}:
aee612a9 3494@multitable @columnfractions .15 .70
e06f8026 3495@item @var{A} @tab The type shall be @code{INTEGER}, @code{REAL},
c24c5fac 3496or @code{COMPLEX}.
4e7aa3fa 3497@end multitable
3498
3499@item @emph{Return value}:
3500The return value is of type double precision real.
3501
3502@item @emph{Example}:
3503@smallexample
3504program test_dble
3505 real :: x = 2.18
3506 integer :: i = 5
3507 complex :: z = (2.3,1.14)
a3c4ed23 3508 print *, dble(x), dble(i), dble(z)
4e7aa3fa 3509end program test_dble
3510@end smallexample
a3c4ed23 3511
3512@item @emph{See also}:
b53b53b4 3513@ref{REAL}
4e7aa3fa 3514@end table
3515
3516
3517
20d81f06 3518@node DCMPLX
3519@section @code{DCMPLX} --- Double complex conversion function
a1149005 3520@fnindex DCMPLX
5e246457 3521@cindex complex numbers, conversion to
a1149005 3522@cindex conversion, to complex
20d81f06 3523
3524@table @asis
3525@item @emph{Description}:
3526@code{DCMPLX(X [,Y])} returns a double complex number where @var{X} is
3527converted to the real component. If @var{Y} is present it is converted to the
3528imaginary component. If @var{Y} is not present then the imaginary component is
3529set to 0.0. If @var{X} is complex then @var{Y} must not be present.
3530
a3c4ed23 3531@item @emph{Standard}:
3532GNU extension
20d81f06 3533
3534@item @emph{Class}:
a3c4ed23 3535Elemental function
20d81f06 3536
3537@item @emph{Syntax}:
4eb41f08 3538@code{RESULT = DCMPLX(X [, Y])}
20d81f06 3539
3540@item @emph{Arguments}:
aee612a9 3541@multitable @columnfractions .15 .70
e06f8026 3542@item @var{X} @tab The type may be @code{INTEGER}, @code{REAL},
c24c5fac 3543or @code{COMPLEX}.
e06f8026 3544@item @var{Y} @tab (Optional if @var{X} is not @code{COMPLEX}.) May be
c24c5fac 3545@code{INTEGER} or @code{REAL}.
20d81f06 3546@end multitable
3547
3548@item @emph{Return value}:
3549The return value is of type @code{COMPLEX(8)}
3550
3551@item @emph{Example}:
3552@smallexample
3553program test_dcmplx
3554 integer :: i = 42
3555 real :: x = 3.14
3556 complex :: z
3557 z = cmplx(i, x)
3558 print *, dcmplx(i)
3559 print *, dcmplx(x)
3560 print *, dcmplx(z)
3561 print *, dcmplx(x,i)
3562end program test_dcmplx
3563@end smallexample
3564@end table
3565
3566
20d81f06 3567@node DIGITS
57b9ac90 3568@section @code{DIGITS} --- Significant binary digits function
a1149005 3569@fnindex DIGITS
3570@cindex model representation, significant digits
20d81f06 3571
3572@table @asis
3573@item @emph{Description}:
57b9ac90 3574@code{DIGITS(X)} returns the number of significant binary digits of the internal
3575model representation of @var{X}. For example, on a system using a 32-bit
20d81f06 3576floating point representation, a default real number would likely return 24.
3577
a3c4ed23 3578@item @emph{Standard}:
f40b44c0 3579Fortran 95 and later
20d81f06 3580
3581@item @emph{Class}:
a3c4ed23 3582Inquiry function
20d81f06 3583
3584@item @emph{Syntax}:
4eb41f08 3585@code{RESULT = DIGITS(X)}
20d81f06 3586
3587@item @emph{Arguments}:
aee612a9 3588@multitable @columnfractions .15 .70
e06f8026 3589@item @var{X} @tab The type may be @code{INTEGER} or @code{REAL}.
20d81f06 3590@end multitable
3591
3592@item @emph{Return value}:
3593The return value is of type @code{INTEGER}.
3594
3595@item @emph{Example}:
3596@smallexample
3597program test_digits
3598 integer :: i = 12345
3599 real :: x = 3.143
3600 real(8) :: y = 2.33
20d81f06 3601 print *, digits(i)
3602 print *, digits(x)
3603 print *, digits(y)
3604end program test_digits
3605@end smallexample
3606@end table
3607
3608
3609
3610@node DIM
a1149005 3611@section @code{DIM} --- Positive difference
3612@fnindex DIM
3613@fnindex IDIM
3614@fnindex DDIM
3615@cindex positive difference
20d81f06 3616
3617@table @asis
3618@item @emph{Description}:
3619@code{DIM(X,Y)} returns the difference @code{X-Y} if the result is positive;
3620otherwise returns zero.
3621
a3c4ed23 3622@item @emph{Standard}:
f40b44c0 3623Fortran 77 and later
20d81f06 3624
3625@item @emph{Class}:
a3c4ed23 3626Elemental function
20d81f06 3627
3628@item @emph{Syntax}:
4eb41f08 3629@code{RESULT = DIM(X, Y)}
20d81f06 3630
3631@item @emph{Arguments}:
aee612a9 3632@multitable @columnfractions .15 .70
e06f8026 3633@item @var{X} @tab The type shall be @code{INTEGER} or @code{REAL}
20d81f06 3634@item @var{Y} @tab The type shall be the same type and kind as @var{X}.
3635@end multitable
3636
3637@item @emph{Return value}:
e06f8026 3638The return value is of type @code{INTEGER} or @code{REAL}.
20d81f06 3639
3640@item @emph{Example}:
3641@smallexample
3642program test_dim
3643 integer :: i
3644 real(8) :: x
3645 i = dim(4, 15)
3646 x = dim(4.345_8, 2.111_8)
3647 print *, i
3648 print *, x
3649end program test_dim
3650@end smallexample
3651
3652@item @emph{Specific names}:
aee612a9 3653@multitable @columnfractions .20 .20 .20 .25
7d74ce87 3654@item Name @tab Argument @tab Return type @tab Standard
3655@item @code{DIM(X,Y)} @tab @code{REAL(4) X, Y} @tab @code{REAL(4)} @tab Fortran 77 and later
3656@item @code{IDIM(X,Y)} @tab @code{INTEGER(4) X, Y} @tab @code{INTEGER(4)} @tab Fortran 77 and later
3657@item @code{DDIM(X,Y)} @tab @code{REAL(8) X, Y} @tab @code{REAL(8)} @tab Fortran 77 and later
20d81f06 3658@end multitable
3659@end table
3660
3661
3662
3663@node DOT_PRODUCT
3664@section @code{DOT_PRODUCT} --- Dot product function
a1149005 3665@fnindex DOT_PRODUCT
5e246457 3666@cindex dot product
a1149005 3667@cindex vector product
3668@cindex product, vector
20d81f06 3669
3670@table @asis
3671@item @emph{Description}:
e06f8026 3672@code{DOT_PRODUCT(VECTOR_A, VECTOR_B)} computes the dot product multiplication
3673of two vectors @var{VECTOR_A} and @var{VECTOR_B}. The two vectors may be
3674either numeric or logical and must be arrays of rank one and of equal size. If
3675the vectors are @code{INTEGER} or @code{REAL}, the result is
3676@code{SUM(VECTOR_A*VECTOR_B)}. If the vectors are @code{COMPLEX}, the result
3677is @code{SUM(CONJG(VECTOR_A)*VECTOR_B)}. If the vectors are @code{LOGICAL},
3678the result is @code{ANY(VECTOR_A .AND. VECTOR_B)}.
20d81f06 3679
a3c4ed23 3680@item @emph{Standard}:
f40b44c0 3681Fortran 95 and later
20d81f06 3682
3683@item @emph{Class}:
138b8aca 3684Transformational function
20d81f06 3685
3686@item @emph{Syntax}:
e06f8026 3687@code{RESULT = DOT_PRODUCT(VECTOR_A, VECTOR_B)}
20d81f06 3688
3689@item @emph{Arguments}:
aee612a9 3690@multitable @columnfractions .15 .70
e06f8026 3691@item @var{VECTOR_A} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
3692@item @var{VECTOR_B} @tab The type shall be numeric if @var{VECTOR_A} is of numeric type or @code{LOGICAL} if @var{VECTOR_A} is of type @code{LOGICAL}. @var{VECTOR_B} shall be a rank-one array.
20d81f06 3693@end multitable
3694
3695@item @emph{Return value}:
57b9ac90 3696If the arguments are numeric, the return value is a scalar of numeric type,
e06f8026 3697@code{INTEGER}, @code{REAL}, or @code{COMPLEX}. If the arguments are
20d81f06 3698@code{LOGICAL}, the return value is @code{.TRUE.} or @code{.FALSE.}.
3699
3700@item @emph{Example}:
3701@smallexample
3702program test_dot_prod
3703 integer, dimension(3) :: a, b
3704 a = (/ 1, 2, 3 /)
3705 b = (/ 4, 5, 6 /)
3706 print '(3i3)', a
3707 print *
3708 print '(3i3)', b
3709 print *
3710 print *, dot_product(a,b)
3711end program test_dot_prod
3712@end smallexample
3713@end table
3714
3715
3716
3717@node DPROD
3718@section @code{DPROD} --- Double product function
a1149005 3719@fnindex DPROD
3720@cindex product, double-precision
20d81f06 3721
3722@table @asis
3723@item @emph{Description}:
3724@code{DPROD(X,Y)} returns the product @code{X*Y}.
3725
a3c4ed23 3726@item @emph{Standard}:
f40b44c0 3727Fortran 77 and later
20d81f06 3728
3729@item @emph{Class}:
a3c4ed23 3730Elemental function
20d81f06 3731
3732@item @emph{Syntax}:
4eb41f08 3733@code{RESULT = DPROD(X, Y)}
20d81f06 3734
3735@item @emph{Arguments}:
aee612a9 3736@multitable @columnfractions .15 .70
20d81f06 3737@item @var{X} @tab The type shall be @code{REAL}.
3738@item @var{Y} @tab The type shall be @code{REAL}.
3739@end multitable
3740
3741@item @emph{Return value}:
3742The return value is of type @code{REAL(8)}.
3743
3744@item @emph{Example}:
3745@smallexample
3746program test_dprod
20d81f06 3747 real :: x = 5.2
3748 real :: y = 2.3
3749 real(8) :: d
3750 d = dprod(x,y)
3751 print *, d
3752end program test_dprod
3753@end smallexample
20d81f06 3754
7d74ce87 3755@item @emph{Specific names}:
3756@multitable @columnfractions .20 .20 .20 .25
3757@item Name @tab Argument @tab Return type @tab Standard
3758@item @code{DPROD(X,Y)} @tab @code{REAL(4) X, Y} @tab @code{REAL(4)} @tab Fortran 77 and later
3759@end multitable
3760
3761@end table
20d81f06 3762
3763
3764@node DREAL
3765@section @code{DREAL} --- Double real part function
a1149005 3766@fnindex DREAL
3767@cindex complex numbers, real part
20d81f06 3768
3769@table @asis
3770@item @emph{Description}:
3771@code{DREAL(Z)} returns the real part of complex variable @var{Z}.
3772
a3c4ed23 3773@item @emph{Standard}:
3774GNU extension
20d81f06 3775
3776@item @emph{Class}:
a3c4ed23 3777Elemental function
20d81f06 3778
3779@item @emph{Syntax}:
e06f8026 3780@code{RESULT = DREAL(A)}
20d81f06 3781
3782@item @emph{Arguments}:
aee612a9 3783@multitable @columnfractions .15 .70
e06f8026 3784@item @var{A} @tab The type shall be @code{COMPLEX(8)}.
20d81f06 3785@end multitable
3786
3787@item @emph{Return value}:
3788The return value is of type @code{REAL(8)}.
3789
3790@item @emph{Example}:
3791@smallexample
3792program test_dreal
3793 complex(8) :: z = (1.3_8,7.2_8)
3794 print *, dreal(z)
3795end program test_dreal
3796@end smallexample
a3c4ed23 3797
3798@item @emph{See also}:
3799@ref{AIMAG}
3800
20d81f06 3801@end table
3802
3803
3804
f004c7aa 3805@node DSHIFTL
3806@section @code{DSHIFTL} --- Combined left shift
3807@fnindex DSHIFTL
3808@cindex left shift, combined
3809@cindex shift, left
3810
3811@table @asis
3812@item @emph{Description}:
3813@code{DSHIFTL(I, J, SHIFT)} combines bits of @var{I} and @var{J}. The
3814rightmost @var{SHIFT} bits of the result are the leftmost @var{SHIFT}
3815bits of @var{J}, and the remaining bits are the rightmost bits of
3816@var{I}.
3817
3818@item @emph{Standard}:
3819Fortran 2008 and later
3820
3821@item @emph{Class}:
3822Elemental function
3823
3824@item @emph{Syntax}:
3825@code{RESULT = DSHIFTL(I, J, SHIFT)}
3826
3827@item @emph{Arguments}:
3828@multitable @columnfractions .15 .70
10089e90 3829@item @var{I} @tab Shall be of type @code{INTEGER} or a BOZ constant.
3830@item @var{J} @tab Shall be of type @code{INTEGER} or a BOZ constant.
3831If both @var{I} and @var{J} have integer type, then they shall have
3832the same kind type parameter. @var{I} and @var{J} shall not both be
3833BOZ constants.
3834@item @var{SHIFT} @tab Shall be of type @code{INTEGER}. It shall
3835be nonnegative. If @var{I} is not a BOZ constant, then @var{SHIFT}
3836shall be less than or equal to @code{BIT_SIZE(I)}; otherwise,
3837@var{SHIFT} shall be less than or equal to @code{BIT_SIZE(J)}.
f004c7aa 3838@end multitable
3839
3840@item @emph{Return value}:
10089e90 3841If either @var{I} or @var{J} is a BOZ constant, it is first converted
3842as if by the intrinsic function @code{INT} to an integer type with the
3843kind type parameter of the other.
f004c7aa 3844
3845@item @emph{See also}:
3846@ref{DSHIFTR}
f004c7aa 3847@end table
3848
3849
f004c7aa 3850@node DSHIFTR
3851@section @code{DSHIFTR} --- Combined right shift
3852@fnindex DSHIFTR
3853@cindex right shift, combined
3854@cindex shift, right
3855
3856@table @asis
3857@item @emph{Description}:
3858@code{DSHIFTR(I, J, SHIFT)} combines bits of @var{I} and @var{J}. The
3859leftmost @var{SHIFT} bits of the result are the rightmost @var{SHIFT}
3860bits of @var{I}, and the remaining bits are the leftmost bits of
3861@var{J}.
3862
3863@item @emph{Standard}:
3864Fortran 2008 and later
3865
3866@item @emph{Class}:
3867Elemental function
3868
3869@item @emph{Syntax}:
3870@code{RESULT = DSHIFTR(I, J, SHIFT)}
3871
3872@item @emph{Arguments}:
3873@multitable @columnfractions .15 .70
10089e90 3874@item @var{I} @tab Shall be of type @code{INTEGER} or a BOZ constant.
3875@item @var{J} @tab Shall be of type @code{INTEGER} or a BOZ constant.
3876If both @var{I} and @var{J} have integer type, then they shall have
3877the same kind type parameter. @var{I} and @var{J} shall not both be
3878BOZ constants.
3879@item @var{SHIFT} @tab Shall be of type @code{INTEGER}. It shall
3880be nonnegative. If @var{I} is not a BOZ constant, then @var{SHIFT}
3881shall be less than or equal to @code{BIT_SIZE(I)}; otherwise,
3882@var{SHIFT} shall be less than or equal to @code{BIT_SIZE(J)}.
f004c7aa 3883@end multitable
3884
3885@item @emph{Return value}:
10089e90 3886If either @var{I} or @var{J} is a BOZ constant, it is first converted
3887as if by the intrinsic function @code{INT} to an integer type with the
3888kind type parameter of the other.
f004c7aa 3889
3890@item @emph{See also}:
3891@ref{DSHIFTL}
f004c7aa 3892@end table
3893
3894
20d81f06 3895@node DTIME
3896@section @code{DTIME} --- Execution time subroutine (or function)
a1149005 3897@fnindex DTIME
5e246457 3898@cindex time, elapsed
3899@cindex elapsed time
20d81f06 3900
3901@table @asis
3902@item @emph{Description}:
2cd8ef8b 3903@code{DTIME(VALUES, TIME)} initially returns the number of seconds of runtime
3904since the start of the process's execution in @var{TIME}. @var{VALUES}
3905returns the user and system components of this time in @code{VALUES(1)} and
3906@code{VALUES(2)} respectively. @var{TIME} is equal to @code{VALUES(1) +
3907VALUES(2)}.
20d81f06 3908
c656b4ab 3909Subsequent invocations of @code{DTIME} return values accumulated since the
3910previous invocation.
20d81f06 3911
3912On some systems, the underlying timings are represented using types with
ed8f9044 3913sufficiently small limits that overflows (wrap around) are possible, such as
20d81f06 391432-bit types. Therefore, the values returned by this intrinsic might be, or
3915become, negative, or numerically less than previous values, during a single
3916run of the compiled program.
3917
dd6c1457 3918Please note, that this implementation is thread safe if used within OpenMP
2dd2bcbd 3919directives, i.e., its state will be consistent while called from multiple
dd6c1457 3920threads. However, if @code{DTIME} is called from multiple threads, the result
3921is still the time since the last invocation. This may not give the intended
3922results. If possible, use @code{CPU_TIME} instead.
3923
138b8aca 3924This intrinsic is provided in both subroutine and function forms; however,
3925only one form can be used in any given program unit.
20d81f06 3926
2cd8ef8b 3927@var{VALUES} and @var{TIME} are @code{INTENT(OUT)} and provide the following:
20d81f06 3928
aee612a9 3929@multitable @columnfractions .15 .30 .40
2cd8ef8b 3930@item @tab @code{VALUES(1)}: @tab User time in seconds.
3931@item @tab @code{VALUES(2)}: @tab System time in seconds.
3932@item @tab @code{TIME}: @tab Run time since start in seconds.
20d81f06 3933@end multitable
3934
a3c4ed23 3935@item @emph{Standard}:
3936GNU extension
20d81f06 3937
3938@item @emph{Class}:
138b8aca 3939Subroutine, function
20d81f06 3940
3941@item @emph{Syntax}:
c656b4ab 3942@multitable @columnfractions .80
2cd8ef8b 3943@item @code{CALL DTIME(VALUES, TIME)}.
3944@item @code{TIME = DTIME(VALUES)}, (not recommended).
c656b4ab 3945@end multitable
20d81f06 3946
3947@item @emph{Arguments}:
aee612a9 3948@multitable @columnfractions .15 .70
83c6ea1d 3949@item @var{VALUES}@tab The type shall be @code{REAL(4), DIMENSION(2)}.
3950@item @var{TIME}@tab The type shall be @code{REAL(4)}.
20d81f06 3951@end multitable
3952
3953@item @emph{Return value}:
dd6c1457 3954Elapsed time in seconds since the last invocation or since the start of program
3955execution if not called before.
20d81f06 3956
3957@item @emph{Example}:
3958@smallexample
3959program test_dtime
3960 integer(8) :: i, j
3961 real, dimension(2) :: tarray
3962 real :: result
3963 call dtime(tarray, result)
3964 print *, result
3965 print *, tarray(1)
3966 print *, tarray(2)
3967 do i=1,100000000 ! Just a delay
3968 j = i * i - i
3969 end do
3970 call dtime(tarray, result)
3971 print *, result
3972 print *, tarray(1)
3973 print *, tarray(2)
3974end program test_dtime
3975@end smallexample
dd6c1457 3976
3977@item @emph{See also}:
3978@ref{CPU_TIME}
3979
20d81f06 3980@end table
3981
3982
3983
c656b4ab 3984@node EOSHIFT
a1149005 3985@section @code{EOSHIFT} --- End-off shift elements of an array
3986@fnindex EOSHIFT
3987@cindex array, shift
c656b4ab 3988
3989@table @asis
3990@item @emph{Description}:
e06f8026 3991@code{EOSHIFT(ARRAY, SHIFT[, BOUNDARY, DIM])} performs an end-off shift on
c656b4ab 3992elements of @var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is
57b9ac90 3993omitted it is taken to be @code{1}. @var{DIM} is a scalar of type
83c6ea1d 3994@code{INTEGER} in the range of @math{1 \leq DIM \leq n)} where @math{n} is the
c656b4ab 3995rank of @var{ARRAY}. If the rank of @var{ARRAY} is one, then all elements of
3996@var{ARRAY} are shifted by @var{SHIFT} places. If rank is greater than one,
3997then all complete rank one sections of @var{ARRAY} along the given dimension are
3998shifted. Elements shifted out one end of each rank one section are dropped. If
97c5a027 3999@var{BOUNDARY} is present then the corresponding value of from @var{BOUNDARY}
c656b4ab 4000is copied back in the other end. If @var{BOUNDARY} is not present then the
4001following are copied in depending on the type of @var{ARRAY}.
4002
4003@multitable @columnfractions .15 .80
4004@item @emph{Array Type} @tab @emph{Boundary Value}
4005@item Numeric @tab 0 of the type and kind of @var{ARRAY}.
4006@item Logical @tab @code{.FALSE.}.
4007@item Character(@var{len}) @tab @var{len} blanks.
4008@end multitable
4009
a3c4ed23 4010@item @emph{Standard}:
f40b44c0 4011Fortran 95 and later
c656b4ab 4012
4013@item @emph{Class}:
dceb1607 4014Transformational function
c656b4ab 4015
4016@item @emph{Syntax}:
dceb1607 4017@code{RESULT = EOSHIFT(ARRAY, SHIFT [, BOUNDARY, DIM])}
c656b4ab 4018
4019@item @emph{Arguments}:
aee612a9 4020@multitable @columnfractions .15 .70
57b9ac90 4021@item @var{ARRAY} @tab May be any type, not scalar.
c656b4ab 4022@item @var{SHIFT} @tab The type shall be @code{INTEGER}.
4023@item @var{BOUNDARY} @tab Same type as @var{ARRAY}.
4024@item @var{DIM} @tab The type shall be @code{INTEGER}.
4025@end multitable
4026
4027@item @emph{Return value}:
4028Returns an array of same type and rank as the @var{ARRAY} argument.
4029
4030@item @emph{Example}:
4031@smallexample
4032program test_eoshift
4033 integer, dimension(3,3) :: a
4034 a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
4035 print '(3i3)', a(1,:)
4036 print '(3i3)', a(2,:)
4037 print '(3i3)', a(3,:)
4038 a = EOSHIFT(a, SHIFT=(/1, 2, 1/), BOUNDARY=-5, DIM=2)
4039 print *
4040 print '(3i3)', a(1,:)
4041 print '(3i3)', a(2,:)
4042 print '(3i3)', a(3,:)
4043end program test_eoshift
4044@end smallexample
4045@end table
4046
4047
4048
4049@node EPSILON
4050@section @code{EPSILON} --- Epsilon function
a1149005 4051@fnindex EPSILON
4052@cindex model representation, epsilon
c656b4ab 4053
4054@table @asis
4055@item @emph{Description}:
57b9ac90 4056@code{EPSILON(X)} returns the smallest number @var{E} of the same kind
4057as @var{X} such that @math{1 + E > 1}.
c656b4ab 4058
a3c4ed23 4059@item @emph{Standard}:
f40b44c0 4060Fortran 95 and later
c656b4ab 4061
4062@item @emph{Class}:
a3c4ed23 4063Inquiry function
c656b4ab 4064
4065@item @emph{Syntax}:
4eb41f08 4066@code{RESULT = EPSILON(X)}
c656b4ab 4067
4068@item @emph{Arguments}:
aee612a9 4069@multitable @columnfractions .15 .70
e06f8026 4070@item @var{X} @tab The type shall be @code{REAL}.
c656b4ab 4071@end multitable
4072
4073@item @emph{Return value}:
4074The return value is of same type as the argument.
4075
4076@item @emph{Example}:
4077@smallexample
4078program test_epsilon
4079 real :: x = 3.143
4080 real(8) :: y = 2.33
4081 print *, EPSILON(x)
4082 print *, EPSILON(y)
4083end program test_epsilon
4084@end smallexample
4085@end table
4086
4087
4088
c0075f3c 4089@node ERF
4090@section @code{ERF} --- Error function
a1149005 4091@fnindex ERF
db8ac666 4092@cindex error function
c0075f3c 4093
4094@table @asis
4095@item @emph{Description}:
4096@code{ERF(X)} computes the error function of @var{X}.
4097
a3c4ed23 4098@item @emph{Standard}:
ff4425cf 4099Fortran 2008 and later
c0075f3c 4100
bb3d0c30 4101@item @emph{Class}:
a3c4ed23 4102Elemental function
c0075f3c 4103
4104@item @emph{Syntax}:
4eb41f08 4105@code{RESULT = ERF(X)}
c0075f3c 4106
4107@item @emph{Arguments}:
aee612a9 4108@multitable @columnfractions .15 .70
ff4425cf 4109@item @var{X} @tab The type shall be @code{REAL}.
c0075f3c 4110@end multitable
4111
4112@item @emph{Return value}:
ff4425cf 4113The return value is of type @code{REAL}, of the same kind as
4114@var{X} and lies in the range @math{-1 \leq erf (x) \leq 1 }.
c0075f3c 4115
4116@item @emph{Example}:
4117@smallexample
4118program test_erf
4119 real(8) :: x = 0.17_8
4120 x = erf(x)
4121end program test_erf
4122@end smallexample
4123
4124@item @emph{Specific names}:
aee612a9 4125@multitable @columnfractions .20 .20 .20 .25
a3c4ed23 4126@item Name @tab Argument @tab Return type @tab Standard
4127@item @code{DERF(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
c0075f3c 4128@end multitable
4129@end table
4130
4131
4132
4133@node ERFC
4134@section @code{ERFC} --- Error function
a1149005 4135@fnindex ERFC
4136@cindex error function, complementary
c0075f3c 4137
4138@table @asis
4139@item @emph{Description}:
4140@code{ERFC(X)} computes the complementary error function of @var{X}.
4141
a3c4ed23 4142@item @emph{Standard}:
ff4425cf 4143Fortran 2008 and later
c0075f3c 4144
bb3d0c30 4145@item @emph{Class}:
a3c4ed23 4146Elemental function
c0075f3c 4147
4148@item @emph{Syntax}:
4eb41f08 4149@code{RESULT = ERFC(X)}
c0075f3c 4150
4151@item @emph{Arguments}:
aee612a9 4152@multitable @columnfractions .15 .70
ff4425cf 4153@item @var{X} @tab The type shall be @code{REAL}.
c0075f3c 4154@end multitable
4155
4156@item @emph{Return value}:
ff4425cf 4157The return value is of type @code{REAL} and of the same kind as @var{X}.
4158It lies in the range @math{ 0 \leq erfc (x) \leq 2 }.
c0075f3c 4159
4160@item @emph{Example}:
4161@smallexample
4162program test_erfc
4163 real(8) :: x = 0.17_8
4164 x = erfc(x)
4165end program test_erfc
4166@end smallexample
4167
4168@item @emph{Specific names}:
aee612a9 4169@multitable @columnfractions .20 .20 .20 .25
a3c4ed23 4170@item Name @tab Argument @tab Return type @tab Standard
4171@item @code{DERFC(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
338c728c 4172@end multitable
4173@end table
4174
4175
4176
ff4425cf 4177@node ERFC_SCALED
4178@section @code{ERFC_SCALED} --- Error function
4179@fnindex ERFC_SCALED
4180@cindex error function, complementary, exponentially-scaled
4181
4182@table @asis
4183@item @emph{Description}:
4184@code{ERFC_SCALED(X)} computes the exponentially-scaled complementary
4185error function of @var{X}.
4186
4187@item @emph{Standard}:
4188Fortran 2008 and later
4189
4190@item @emph{Class}:
4191Elemental function
4192
4193@item @emph{Syntax}:
4194@code{RESULT = ERFC_SCALED(X)}
4195
4196@item @emph{Arguments}:
4197@multitable @columnfractions .15 .70
4198@item @var{X} @tab The type shall be @code{REAL}.
4199@end multitable
4200
4201@item @emph{Return value}:
4202The return value is of type @code{REAL} and of the same kind as @var{X}.
4203
4204@item @emph{Example}:
4205@smallexample
4206program test_erfc_scaled
4207 real(8) :: x = 0.17_8
4208 x = erfc_scaled(x)
4209end program test_erfc_scaled
4210@end smallexample
4211@end table
4212
4213
4214
c656b4ab 4215@node ETIME
4216@section @code{ETIME} --- Execution time subroutine (or function)
a1149005 4217@fnindex ETIME
5e246457 4218@cindex time, elapsed
c656b4ab 4219
4220@table @asis
4221@item @emph{Description}:
2cd8ef8b 4222@code{ETIME(VALUES, TIME)} returns the number of seconds of runtime
4223since the start of the process's execution in @var{TIME}. @var{VALUES}
4224returns the user and system components of this time in @code{VALUES(1)} and
4225@code{VALUES(2)} respectively. @var{TIME} is equal to @code{VALUES(1) + VALUES(2)}.
c656b4ab 4226
4227On some systems, the underlying timings are represented using types with
ed8f9044 4228sufficiently small limits that overflows (wrap around) are possible, such as
c656b4ab 422932-bit types. Therefore, the values returned by this intrinsic might be, or
4230become, negative, or numerically less than previous values, during a single
4231run of the compiled program.
4232
138b8aca 4233This intrinsic is provided in both subroutine and function forms; however,
4234only one form can be used in any given program unit.
c656b4ab 4235
2cd8ef8b 4236@var{VALUES} and @var{TIME} are @code{INTENT(OUT)} and provide the following:
c656b4ab 4237
4238@multitable @columnfractions .15 .30 .60
2cd8ef8b 4239@item @tab @code{VALUES(1)}: @tab User time in seconds.
4240@item @tab @code{VALUES(2)}: @tab System time in seconds.
4241@item @tab @code{TIME}: @tab Run time since start in seconds.
c656b4ab 4242@end multitable
4243
a3c4ed23 4244@item @emph{Standard}:
4245GNU extension
c656b4ab 4246
4247@item @emph{Class}:
138b8aca 4248Subroutine, function
c656b4ab 4249
4250@item @emph{Syntax}:
aee612a9 4251@multitable @columnfractions .80
2cd8ef8b 4252@item @code{CALL ETIME(VALUES, TIME)}.
4253@item @code{TIME = ETIME(VALUES)}, (not recommended).
c656b4ab 4254@end multitable
4255
4256@item @emph{Arguments}:
aee612a9 4257@multitable @columnfractions .15 .70
83c6ea1d 4258@item @var{VALUES}@tab The type shall be @code{REAL(4), DIMENSION(2)}.
4259@item @var{TIME}@tab The type shall be @code{REAL(4)}.
c656b4ab 4260@end multitable
4261
4262@item @emph{Return value}:
4263Elapsed time in seconds since the start of program execution.
4264
4265@item @emph{Example}:
4266@smallexample
4267program test_etime
4268 integer(8) :: i, j
4269 real, dimension(2) :: tarray
4270 real :: result
4271 call ETIME(tarray, result)
4272 print *, result
4273 print *, tarray(1)
4274 print *, tarray(2)
4275 do i=1,100000000 ! Just a delay
4276 j = i * i - i
4277 end do
4278 call ETIME(tarray, result)
4279 print *, result
4280 print *, tarray(1)
4281 print *, tarray(2)
4282end program test_etime
4283@end smallexample
a3c4ed23 4284
4285@item @emph{See also}:
4286@ref{CPU_TIME}
4287
c656b4ab 4288@end table
4289
4290
4291
fe2de951 4292@node EXECUTE_COMMAND_LINE
4293@section @code{EXECUTE_COMMAND_LINE} --- Execute a shell command
4294@fnindex EXECUTE_COMMAND_LINE
4295@cindex system, system call
4296@cindex command line
4297
4298@table @asis
4299@item @emph{Description}:
4300@code{EXECUTE_COMMAND_LINE} runs a shell command, synchronously or
4301asynchronously.
4302
4303The @code{COMMAND} argument is passed to the shell and executed, using
88647254 4304the C library's @code{system} call. (The shell is @code{sh} on Unix
4305systems, and @code{cmd.exe} on Windows.) If @code{WAIT} is present
4306and has the value false, the execution of the command is asynchronous
4307if the system supports it; otherwise, the command is executed
4308synchronously.
fe2de951 4309
4310The three last arguments allow the user to get status information. After
4311synchronous execution, @code{EXITSTAT} contains the integer exit code of
4312the command, as returned by @code{system}. @code{CMDSTAT} is set to zero
4313if the command line was executed (whatever its exit status was).
4314@code{CMDMSG} is assigned an error message if an error has occurred.
4315
e8c1bbb4 4316Note that the @code{system} function need not be thread-safe. It is
4317the responsibility of the user to ensure that @code{system} is not
4318called concurrently.
fe2de951 4319
4320@item @emph{Standard}:
4321Fortran 2008 and later
4322
4323@item @emph{Class}:
4324Subroutine
4325
4326@item @emph{Syntax}:
4327@code{CALL EXECUTE_COMMAND_LINE(COMMAND [, WAIT, EXITSTAT, CMDSTAT, CMDMSG ])}
4328
4329@item @emph{Arguments}:
4330@multitable @columnfractions .15 .70
4331@item @var{COMMAND} @tab Shall be a default @code{CHARACTER} scalar.
4332@item @var{WAIT} @tab (Optional) Shall be a default @code{LOGICAL} scalar.
4333@item @var{EXITSTAT} @tab (Optional) Shall be an @code{INTEGER} of the
4334default kind.
4335@item @var{CMDSTAT} @tab (Optional) Shall be an @code{INTEGER} of the
4336default kind.
4337@item @var{CMDMSG} @tab (Optional) Shall be an @code{CHARACTER} scalar of the
4338default kind.
4339@end multitable
4340
4341@item @emph{Example}:
4342@smallexample
4343program test_exec
4344 integer :: i
4345
4346 call execute_command_line ("external_prog.exe", exitstat=i)
4347 print *, "Exit status of external_prog.exe was ", i
4348
4349 call execute_command_line ("reindex_files.exe", wait=.false.)
4350 print *, "Now reindexing files in the background"
4351
4352end program test_exec
4353@end smallexample
4354
4355
4356@item @emph{Note}:
4357
88647254 4358Because this intrinsic is implemented in terms of the @code{system}
5f7aa0fe 4359function call, its behavior with respect to signaling is processor
fe2de951 4360dependent. In particular, on POSIX-compliant systems, the SIGINT and
4361SIGQUIT signals will be ignored, and the SIGCHLD will be blocked. As
4362such, if the parent process is terminated, the child process might not be
4363terminated alongside.
4364
4365
4366@item @emph{See also}:
4367@ref{SYSTEM}
4368@end table
4369
4370
4371
c656b4ab 4372@node EXIT
4373@section @code{EXIT} --- Exit the program with status.
a1149005 4374@fnindex EXIT
4375@cindex program termination
4376@cindex terminate program
c656b4ab 4377
4378@table @asis
4379@item @emph{Description}:
4380@code{EXIT} causes immediate termination of the program with status. If status
97c5a027 4381is omitted it returns the canonical @emph{success} for the system. All Fortran
c656b4ab 4382I/O units are closed.
4383
a3c4ed23 4384@item @emph{Standard}:
4385GNU extension
c656b4ab 4386
4387@item @emph{Class}:
a3c4ed23 4388Subroutine
c656b4ab 4389
4390@item @emph{Syntax}:
4391@code{CALL EXIT([STATUS])}
4392
4393@item @emph{Arguments}:
aee612a9 4394@multitable @columnfractions .15 .70
7eb0a16c 4395@item @var{STATUS} @tab Shall be an @code{INTEGER} of the default kind.
c656b4ab 4396@end multitable
4397
4398@item @emph{Return value}:
4399@code{STATUS} is passed to the parent process on exit.
4400
4401@item @emph{Example}:
4402@smallexample
4403program test_exit
4404 integer :: STATUS = 0
4405 print *, 'This program is going to exit.'
4406 call EXIT(STATUS)
4407end program test_exit
4408@end smallexample
a3c4ed23 4409
4410@item @emph{See also}:
4411@ref{ABORT}, @ref{KILL}
c656b4ab 4412@end table
4413
4414
4415
338c728c 4416@node EXP
4417@section @code{EXP} --- Exponential function
a1149005 4418@fnindex EXP
4419@fnindex DEXP
4420@fnindex CEXP
4421@fnindex ZEXP
4422@fnindex CDEXP
4423@cindex exponential function
e7f272a2 4424@cindex logarithm function, inverse
338c728c 4425
4426@table @asis
4427@item @emph{Description}:
4428@code{EXP(X)} computes the base @math{e} exponential of @var{X}.
4429
a3c4ed23 4430@item @emph{Standard}:
f40b44c0 4431Fortran 77 and later, has overloads that are GNU extensions
338c728c 4432
bb3d0c30 4433@item @emph{Class}:
a3c4ed23 4434Elemental function
338c728c 4435
4436@item @emph{Syntax}:
4eb41f08 4437@code{RESULT = EXP(X)}
338c728c 4438
4439@item @emph{Arguments}:
aee612a9 4440@multitable @columnfractions .15 .70
e06f8026 4441@item @var{X} @tab The type shall be @code{REAL} or
4442@code{COMPLEX}.
338c728c 4443@end multitable
4444
4445@item @emph{Return value}:
bb3d0c30 4446The return value has same type and kind as @var{X}.
338c728c 4447
4448@item @emph{Example}:
4449@smallexample
4450program test_exp
4451 real :: x = 1.0
4452 x = exp(x)
4453end program test_exp
4454@end smallexample
4455
4456@item @emph{Specific names}:
aee612a9 4457@multitable @columnfractions .20 .20 .20 .25
a3c4ed23 4458@item Name @tab Argument @tab Return type @tab Standard
7d74ce87 4459@item @code{EXP(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later
f40b44c0 4460@item @code{DEXP(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
4461@item @code{CEXP(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab Fortran 77 and later
a3c4ed23 4462@item @code{ZEXP(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
4463@item @code{CDEXP(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
338c728c 4464@end multitable
4465@end table
4466
4467
bb3d0c30 4468
2c5b695e 4469@node EXPONENT
4470@section @code{EXPONENT} --- Exponent function
a1149005 4471@fnindex EXPONENT
4472@cindex real number, exponent
4473@cindex floating point, exponent
2c5b695e 4474
4475@table @asis
4476@item @emph{Description}:
4477@code{EXPONENT(X)} returns the value of the exponent part of @var{X}. If @var{X}
4478is zero the value returned is zero.
4479
a3c4ed23 4480@item @emph{Standard}:
f40b44c0 4481Fortran 95 and later
2c5b695e 4482
4483@item @emph{Class}:
a3c4ed23 4484Elemental function
2c5b695e 4485
4486@item @emph{Syntax}:
4eb41f08 4487@code{RESULT = EXPONENT(X)}
2c5b695e 4488
4489@item @emph{Arguments}:
aee612a9 4490@multitable @columnfractions .15 .70
e06f8026 4491@item @var{X} @tab The type shall be @code{REAL}.
2c5b695e 4492@end multitable
4493
4494@item @emph{Return value}:
4495The return value is of type default @code{INTEGER}.
4496
4497@item @emph{Example}:
4498@smallexample
4499program test_exponent
4500 real :: x = 1.0
4501 integer :: i
4502 i = exponent(x)
4503 print *, i
4504 print *, exponent(0.0)
4505end program test_exponent
4506@end smallexample
4507@end table
4508
4509
fe97b755 4510
24c079ad 4511@node EXTENDS_TYPE_OF
4512@section @code{EXTENDS_TYPE_OF} --- Query dynamic type for extension
4513@fnindex EXTENDS_TYPE_OF
4514
4515@table @asis
4516@item @emph{Description}:
4517Query dynamic type for extension.
4518
4519@item @emph{Standard}:
4520Fortran 2003 and later
4521
4522@item @emph{Class}:
4523Inquiry function
4524
4525@item @emph{Syntax}:
4526@code{RESULT = EXTENDS_TYPE_OF(A, MOLD)}
4527
4528@item @emph{Arguments}:
4529@multitable @columnfractions .15 .70
4530@item @var{A} @tab Shall be an object of extensible declared type or
4531unlimited polymorphic.
4532@item @var{MOLD} @tab Shall be an object of extensible declared type or
4533unlimited polymorphic.
4534@end multitable
4535
4536@item @emph{Return value}:
4537The return value is a scalar of type default logical. It is true if and only if
4538the dynamic type of A is an extension type of the dynamic type of MOLD.
4539
4540
4541@item @emph{See also}:
4542@ref{SAME_TYPE_AS}
4543@end table
4544
4545
4546
b902b078 4547@node FDATE
4548@section @code{FDATE} --- Get the current time as a string
a1149005 4549@fnindex FDATE
5e246457 4550@cindex time, current
4551@cindex current time
4552@cindex date, current
4553@cindex current date
b902b078 4554
4555@table @asis
4556@item @emph{Description}:
4557@code{FDATE(DATE)} returns the current date (using the same format as
4558@code{CTIME}) in @var{DATE}. It is equivalent to @code{CALL CTIME(DATE,
5e246457 4559TIME())}.
b902b078 4560
138b8aca 4561This intrinsic is provided in both subroutine and function forms; however,
4562only one form can be used in any given program unit.
b902b078 4563
a3c4ed23 4564@item @emph{Standard}:
4565GNU extension
b902b078 4566
4567@item @emph{Class}:
138b8aca 4568Subroutine, function
b902b078 4569
4570@item @emph{Syntax}:
4571@multitable @columnfractions .80
4572@item @code{CALL FDATE(DATE)}.
4be95726 4573@item @code{DATE = FDATE()}.
b902b078 4574@end multitable
4575
4576@item @emph{Arguments}:
aee612a9 4577@multitable @columnfractions .15 .70
b44437b9 4578@item @var{DATE}@tab The type shall be of type @code{CHARACTER} of the
4be95726 4579default kind. It is an @code{INTENT(OUT)} argument. If the length of
4580this variable is too short for the date and time string to fit
4581completely, it will be blank on procedure return.
b902b078 4582@end multitable
4583
4584@item @emph{Return value}:
4be95726 4585The current date and time as a string.
b902b078 4586
4587@item @emph{Example}:
4588@smallexample
4589program test_fdate
4590 integer(8) :: i, j
4591 character(len=30) :: date
4592 call fdate(date)
4593 print *, 'Program started on ', date
4594 do i = 1, 100000000 ! Just a delay
4595 j = i * i - i
4596 end do
4597 call fdate(date)
4598 print *, 'Program ended on ', date
4599end program test_fdate
4600@end smallexample
b902b078 4601
4be95726 4602@item @emph{See also}:
4603@ref{DATE_AND_TIME}, @ref{CTIME}
4604@end table
fe97b755 4605
4606
ed8f9044 4607@node FGET
4608@section @code{FGET} --- Read a single character in stream mode from stdin
a1149005 4609@fnindex FGET
4610@cindex read character, stream mode
4611@cindex stream mode, read character
4612@cindex file operation, read character
a3c4ed23 4613
4614@table @asis
4615@item @emph{Description}:
ed8f9044 4616Read a single character in stream mode from stdin by bypassing normal
4617formatted output. Stream I/O should not be mixed with normal record-oriented
4618(formatted or unformatted) I/O on the same unit; the results are unpredictable.
4619
138b8aca 4620This intrinsic is provided in both subroutine and function forms; however,
4621only one form can be used in any given program unit.
4622
4623Note that the @code{FGET} intrinsic is provided for backwards compatibility with
61156d26 4624@command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
ed8f9044 4625Programmers should consider the use of new stream IO feature in new code
4626for future portability. See also @ref{Fortran 2003 status}.
4627
a3c4ed23 4628@item @emph{Standard}:
4629GNU extension
4630
4631@item @emph{Class}:
138b8aca 4632Subroutine, function
ed8f9044 4633
a3c4ed23 4634@item @emph{Syntax}:
6c07e6d8 4635@multitable @columnfractions .80
4636@item @code{CALL FGET(C [, STATUS])}
4637@item @code{STATUS = FGET(C)}
4638@end multitable
ed8f9044 4639
a3c4ed23 4640@item @emph{Arguments}:
aee612a9 4641@multitable @columnfractions .15 .70
b44437b9 4642@item @var{C} @tab The type shall be @code{CHARACTER} and of default
c24c5fac 4643kind.
0eb92d52 4644@item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
c24c5fac 4645Returns 0 on success, -1 on end-of-file, and a system specific positive
4646error code otherwise.
ed8f9044 4647@end multitable
4648
a3c4ed23 4649@item @emph{Example}:
ed8f9044 4650@smallexample
4651PROGRAM test_fget
4652 INTEGER, PARAMETER :: strlen = 100
4653 INTEGER :: status, i = 1
4654 CHARACTER(len=strlen) :: str = ""
4655
4656 WRITE (*,*) 'Enter text:'
4657 DO
4658 CALL fget(str(i:i), status)
4659 if (status /= 0 .OR. i > strlen) exit
4660 i = i + 1
4661 END DO
4662 WRITE (*,*) TRIM(str)
4663END PROGRAM
4664@end smallexample
4665
a3c4ed23 4666@item @emph{See also}:
ed8f9044 4667@ref{FGETC}, @ref{FPUT}, @ref{FPUTC}
a3c4ed23 4668@end table
4669
4670
fe97b755 4671
ed8f9044 4672@node FGETC
4673@section @code{FGETC} --- Read a single character in stream mode
a1149005 4674@fnindex FGETC
4675@cindex read character, stream mode
4676@cindex stream mode, read character
4677@cindex file operation, read character
a3c4ed23 4678
4679@table @asis
4680@item @emph{Description}:
ed8f9044 4681Read a single character in stream mode by bypassing normal formatted output.
4682Stream I/O should not be mixed with normal record-oriented (formatted or
4683unformatted) I/O on the same unit; the results are unpredictable.
4684
138b8aca 4685This intrinsic is provided in both subroutine and function forms; however,
4686only one form can be used in any given program unit.
4687
4688Note that the @code{FGET} intrinsic is provided for backwards compatibility
4689with @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
ed8f9044 4690Programmers should consider the use of new stream IO feature in new code
4691for future portability. See also @ref{Fortran 2003 status}.
4692
a3c4ed23 4693@item @emph{Standard}:
4694GNU extension
4695
4696@item @emph{Class}:
138b8aca 4697Subroutine, function
ed8f9044 4698
a3c4ed23 4699@item @emph{Syntax}:
6c07e6d8 4700@multitable @columnfractions .80
4701@item @code{CALL FGETC(UNIT, C [, STATUS])}
4702@item @code{STATUS = FGETC(UNIT, C)}
4703@end multitable
ed8f9044 4704
a3c4ed23 4705@item @emph{Arguments}:
aee612a9 4706@multitable @columnfractions .15 .70
ed8f9044 4707@item @var{UNIT} @tab The type shall be @code{INTEGER}.
b44437b9 4708@item @var{C} @tab The type shall be @code{CHARACTER} and of default
c24c5fac 4709kind.
b44437b9 4710@item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
c24c5fac 4711Returns 0 on success, -1 on end-of-file and a system specific positive
4712error code otherwise.
ed8f9044 4713@end multitable
4714
a3c4ed23 4715@item @emph{Example}:
ed8f9044 4716@smallexample
4717PROGRAM test_fgetc
4718 INTEGER :: fd = 42, status
4719 CHARACTER :: c
4720
4721 OPEN(UNIT=fd, FILE="/etc/passwd", ACTION="READ", STATUS = "OLD")
4722 DO
4723 CALL fgetc(fd, c, status)
4724 IF (status /= 0) EXIT
4725 call fput(c)
4726 END DO
4727 CLOSE(UNIT=fd)
4728END PROGRAM
4729@end smallexample
4730
a3c4ed23 4731@item @emph{See also}:
ed8f9044 4732@ref{FGET}, @ref{FPUT}, @ref{FPUTC}
06a4a0dd 4733@end table
4734
b902b078 4735
ed8f9044 4736
2c5b695e 4737@node FLOOR
4738@section @code{FLOOR} --- Integer floor function
a1149005 4739@fnindex FLOOR
2c5b695e 4740@cindex floor
a1149005 4741@cindex rounding, floor
2c5b695e 4742
4743@table @asis
4744@item @emph{Description}:
e06f8026 4745@code{FLOOR(A)} returns the greatest integer less than or equal to @var{X}.
2c5b695e 4746
a3c4ed23 4747@item @emph{Standard}:
f40b44c0 4748Fortran 95 and later
2c5b695e 4749
4750@item @emph{Class}:
a3c4ed23 4751Elemental function
2c5b695e 4752
4753@item @emph{Syntax}:
e06f8026 4754@code{RESULT = FLOOR(A [, KIND])}
2c5b695e 4755
4756@item @emph{Arguments}:
aee612a9 4757@multitable @columnfractions .15 .70
e06f8026 4758@item @var{A} @tab The type shall be @code{REAL}.
4759@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
c24c5fac 4760expression indicating the kind parameter of the result.
2c5b695e 4761@end multitable
4762
4763@item @emph{Return value}:
e06f8026 4764The return value is of type @code{INTEGER(KIND)} if @var{KIND} is present
4765and of default-kind @code{INTEGER} otherwise.
2c5b695e 4766
4767@item @emph{Example}:
4768@smallexample
4769program test_floor
4770 real :: x = 63.29
4771 real :: y = -63.59
4772 print *, floor(x) ! returns 63
4773 print *, floor(y) ! returns -64
4774end program test_floor
4775@end smallexample
a3c4ed23 4776
4777@item @emph{See also}:
4778@ref{CEILING}, @ref{NINT}
4779
2c5b695e 4780@end table
4781
4782
4783
572d7b7f 4784@node FLUSH
4785@section @code{FLUSH} --- Flush I/O unit(s)
a1149005 4786@fnindex FLUSH
4787@cindex file operation, flush
572d7b7f 4788
4789@table @asis
4790@item @emph{Description}:
4791Flushes Fortran unit(s) currently open for output. Without the optional
4792argument, all units are flushed, otherwise just the unit specified.
4793
a3c4ed23 4794@item @emph{Standard}:
4795GNU extension
572d7b7f 4796
4797@item @emph{Class}:
138b8aca 4798Subroutine
572d7b7f 4799
4800@item @emph{Syntax}:
4801@code{CALL FLUSH(UNIT)}
4802
4803@item @emph{Arguments}:
aee612a9 4804@multitable @columnfractions .15 .70
572d7b7f 4805@item @var{UNIT} @tab (Optional) The type shall be @code{INTEGER}.
4806@end multitable
4807
4808@item @emph{Note}:
4809Beginning with the Fortran 2003 standard, there is a @code{FLUSH}
1f556a03 4810statement that should be preferred over the @code{FLUSH} intrinsic.
572d7b7f 4811
21e0620a 4812The @code{FLUSH} intrinsic and the Fortran 2003 @code{FLUSH} statement
4813have identical effect: they flush the runtime library's I/O buffer so
4814that the data becomes visible to other processes. This does not guarantee
4815that the data is committed to disk.
4816
4817On POSIX systems, you can request that all data is transferred to the
4818storage device by calling the @code{fsync} function, with the POSIX file
4819descriptor of the I/O unit as argument (retrieved with GNU intrinsic
4820@code{FNUM}). The following example shows how:
4821
4822@smallexample
4823 ! Declare the interface for POSIX fsync function
4824 interface
4825 function fsync (fd) bind(c,name="fsync")
4826 use iso_c_binding, only: c_int
4827 integer(c_int), value :: fd
4828 integer(c_int) :: fsync
4829 end function fsync
4830 end interface
4831
4832 ! Variable declaration
4833 integer :: ret
4834
4835 ! Opening unit 10
4836 open (10,file="foo")
4837
4838 ! ...
4839 ! Perform I/O on unit 10
4840 ! ...
4841
4842 ! Flush and sync
4843 flush(10)
4844 ret = fsync(fnum(10))
4845
4846 ! Handle possible error
4847 if (ret /= 0) stop "Error calling FSYNC"
4848@end smallexample
4849
572d7b7f 4850@end table
4851
4852
4853
2c5b695e 4854@node FNUM
4855@section @code{FNUM} --- File number function
a1149005 4856@fnindex FNUM
4857@cindex file operation, file number
2c5b695e 4858
4859@table @asis
4860@item @emph{Description}:
ed8f9044 4861@code{FNUM(UNIT)} returns the POSIX file descriptor number corresponding to the
2c5b695e 4862open Fortran I/O unit @code{UNIT}.
4863
a3c4ed23 4864@item @emph{Standard}:
4865GNU extension
2c5b695e 4866
4867@item @emph{Class}:
138b8aca 4868Function
2c5b695e 4869
4870@item @emph{Syntax}:
4eb41f08 4871@code{RESULT = FNUM(UNIT)}
2c5b695e 4872
4873@item @emph{Arguments}:
aee612a9 4874@multitable @columnfractions .15 .70
2c5b695e 4875@item @var{UNIT} @tab The type shall be @code{INTEGER}.
4876@end multitable
4877
4878@item @emph{Return value}:
4879The return value is of type @code{INTEGER}
4880
4881@item @emph{Example}:
4882@smallexample
4883program test_fnum
4884 integer :: i
4885 open (unit=10, status = "scratch")
4886 i = fnum(10)
4887 print *, i
4888 close (10)
4889end program test_fnum
4890@end smallexample
4891@end table
4892
572d7b7f 4893
4894
a3c4ed23 4895@node FPUT
ed8f9044 4896@section @code{FPUT} --- Write a single character in stream mode to stdout
a1149005 4897@fnindex FPUT
4898@cindex write character, stream mode
4899@cindex stream mode, write character
4900@cindex file operation, write character
2c5b695e 4901
b549d2a5 4902@table @asis
4903@item @emph{Description}:
ed8f9044 4904Write a single character in stream mode to stdout by bypassing normal
4905formatted output. Stream I/O should not be mixed with normal record-oriented
4906(formatted or unformatted) I/O on the same unit; the results are unpredictable.
4907
138b8aca 4908This intrinsic is provided in both subroutine and function forms; however,
4909only one form can be used in any given program unit.
4910
4911Note that the @code{FGET} intrinsic is provided for backwards compatibility with
61156d26 4912@command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
ed8f9044 4913Programmers should consider the use of new stream IO feature in new code
4914for future portability. See also @ref{Fortran 2003 status}.
4915
a3c4ed23 4916@item @emph{Standard}:
4917GNU extension
572d7b7f 4918
4919@item @emph{Class}:
138b8aca 4920Subroutine, function
ed8f9044 4921
572d7b7f 4922@item @emph{Syntax}:
6c07e6d8 4923@multitable @columnfractions .80
4924@item @code{CALL FPUT(C [, STATUS])}
4925@item @code{STATUS = FPUT(C)}
4926@end multitable
ed8f9044 4927
572d7b7f 4928@item @emph{Arguments}:
aee612a9 4929@multitable @columnfractions .15 .70
b44437b9 4930@item @var{C} @tab The type shall be @code{CHARACTER} and of default
c24c5fac 4931kind.
b44437b9 4932@item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
c24c5fac 4933Returns 0 on success, -1 on end-of-file and a system specific positive
4934error code otherwise.
ed8f9044 4935@end multitable
4936
572d7b7f 4937@item @emph{Example}:
ed8f9044 4938@smallexample
4939PROGRAM test_fput
b9f2f128 4940 CHARACTER(len=10) :: str = "gfortran"
ed8f9044 4941 INTEGER :: i
4942 DO i = 1, len_trim(str)
4943 CALL fput(str(i:i))
4944 END DO
4945END PROGRAM
4946@end smallexample
4947
a3c4ed23 4948@item @emph{See also}:
ed8f9044 4949@ref{FPUTC}, @ref{FGET}, @ref{FGETC}
a3c4ed23 4950@end table
4951
4952
4953
4954@node FPUTC
4955@section @code{FPUTC} --- Write a single character in stream mode
a1149005 4956@fnindex FPUTC
4957@cindex write character, stream mode
4958@cindex stream mode, write character
4959@cindex file operation, write character
a3c4ed23 4960
4961@table @asis
4962@item @emph{Description}:
ed8f9044 4963Write a single character in stream mode by bypassing normal formatted
4964output. Stream I/O should not be mixed with normal record-oriented
4965(formatted or unformatted) I/O on the same unit; the results are unpredictable.
4966
138b8aca 4967This intrinsic is provided in both subroutine and function forms; however,
4968only one form can be used in any given program unit.
4969
4970Note that the @code{FGET} intrinsic is provided for backwards compatibility with
61156d26 4971@command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
ed8f9044 4972Programmers should consider the use of new stream IO feature in new code
4973for future portability. See also @ref{Fortran 2003 status}.
4974
a3c4ed23 4975@item @emph{Standard}:
4976GNU extension
4977
4978@item @emph{Class}:
138b8aca 4979Subroutine, function
ed8f9044 4980
a3c4ed23 4981@item @emph{Syntax}:
6c07e6d8 4982@multitable @columnfractions .80
4983@item @code{CALL FPUTC(UNIT, C [, STATUS])}
4984@item @code{STATUS = FPUTC(UNIT, C)}
4985@end multitable
ed8f9044 4986
a3c4ed23 4987@item @emph{Arguments}:
aee612a9 4988@multitable @columnfractions .15 .70
ed8f9044 4989@item @var{UNIT} @tab The type shall be @code{INTEGER}.
b44437b9 4990@item @var{C} @tab The type shall be @code{CHARACTER} and of default
c24c5fac 4991kind.
b44437b9 4992@item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
c24c5fac 4993Returns 0 on success, -1 on end-of-file and a system specific positive
4994error code otherwise.
ed8f9044 4995@end multitable
4996
a3c4ed23 4997@item @emph{Example}:
ed8f9044 4998@smallexample
4999PROGRAM test_fputc
b9f2f128 5000 CHARACTER(len=10) :: str = "gfortran"
ed8f9044 5001 INTEGER :: fd = 42, i
5002
5003 OPEN(UNIT = fd, FILE = "out", ACTION = "WRITE", STATUS="NEW")
5004 DO i = 1, len_trim(str)
5005 CALL fputc(fd, str(i:i))
5006 END DO
5007 CLOSE(fd)
5008END PROGRAM
5009@end smallexample
5010
a3c4ed23 5011@item @emph{See also}:
ed8f9044 5012@ref{FPUT}, @ref{FGET}, @ref{FGETC}
a3c4ed23 5013@end table
5014
5015
5016
5017@node FRACTION
5018@section @code{FRACTION} --- Fractional part of the model representation
a1149005 5019@fnindex FRACTION
5020@cindex real number, fraction
5021@cindex floating point, fraction
a3c4ed23 5022
5023@table @asis
5024@item @emph{Description}:
5025@code{FRACTION(X)} returns the fractional part of the model
5026representation of @code{X}.
5027
5028@item @emph{Standard}:
f40b44c0 5029Fortran 95 and later
a3c4ed23 5030
5031@item @emph{Class}:
5032Elemental function
5033
5034@item @emph{Syntax}:
5035@code{Y = FRACTION(X)}
5036
5037@item @emph{Arguments}:
aee612a9 5038@multitable @columnfractions .15 .70
a3c4ed23 5039@item @var{X} @tab The type of the argument shall be a @code{REAL}.
5040@end multitable
5041
5042@item @emph{Return value}:
5043The return value is of the same type and kind as the argument.
5044The fractional part of the model representation of @code{X} is returned;
5045it is @code{X * RADIX(X)**(-EXPONENT(X))}.
5046
5047@item @emph{Example}:
5048@smallexample
5049program test_fraction
5050 real :: x
5051 x = 178.1387e-4
572d7b7f 5052 print *, fraction(x), x * radix(x)**(-exponent(x))
5053end program test_fraction
5054@end smallexample
5055
5056@end table
5057
5058
5059
5060@node FREE
5061@section @code{FREE} --- Frees memory
a1149005 5062@fnindex FREE
5063@cindex pointer, cray
572d7b7f 5064
5065@table @asis
5066@item @emph{Description}:
e8c1bbb4 5067Frees memory previously allocated by @code{MALLOC}. The @code{FREE}
572d7b7f 5068intrinsic is an extension intended to be used with Cray pointers, and is
61156d26 5069provided in GNU Fortran to allow user to compile legacy code. For
572d7b7f 5070new code using Fortran 95 pointers, the memory de-allocation intrinsic is
5071@code{DEALLOCATE}.
b549d2a5 5072
a3c4ed23 5073@item @emph{Standard}:
5074GNU extension
b549d2a5 5075
5076@item @emph{Class}:
a3c4ed23 5077Subroutine
b549d2a5 5078
5079@item @emph{Syntax}:
bf4e8122 5080@code{CALL FREE(PTR)}
b549d2a5 5081
5082@item @emph{Arguments}:
aee612a9 5083@multitable @columnfractions .15 .70
572d7b7f 5084@item @var{PTR} @tab The type shall be @code{INTEGER}. It represents the
5085location of the memory that should be de-allocated.
b549d2a5 5086@end multitable
5087
5088@item @emph{Return value}:
572d7b7f 5089None
5090
5091@item @emph{Example}:
5092See @code{MALLOC} for an example.
a3c4ed23 5093
5094@item @emph{See also}:
5095@ref{MALLOC}
5096@end table
5097
5098
5099
e0c54690 5100@node FSEEK
5101@section @code{FSEEK} --- Low level file positioning subroutine
a1149005 5102@fnindex FSEEK
5103@cindex file operation, seek
5104@cindex file operation, position
e0c54690 5105
e0c54690 5106@table @asis
5107@item @emph{Description}:
7d866870 5108Moves @var{UNIT} to the specified @var{OFFSET}. If @var{WHENCE}
5109is set to 0, the @var{OFFSET} is taken as an absolute value @code{SEEK_SET},
5110if set to 1, @var{OFFSET} is taken to be relative to the current position
5111@code{SEEK_CUR}, and if set to 2 relative to the end of the file @code{SEEK_END}.
a0527218 5112On error, @var{STATUS} is set to a nonzero value. If @var{STATUS} the seek
7d866870 5113fails silently.
5114
5115This intrinsic routine is not fully backwards compatible with @command{g77}.
5116In @command{g77}, the @code{FSEEK} takes a statement label instead of a
5117@var{STATUS} variable. If FSEEK is used in old code, change
5118@smallexample
5119 CALL FSEEK(UNIT, OFFSET, WHENCE, *label)
5120@end smallexample
5121to
5122@smallexample
5123 INTEGER :: status
5124 CALL FSEEK(UNIT, OFFSET, WHENCE, status)
5125 IF (status /= 0) GOTO label
5126@end smallexample
5127
5128Please note that GNU Fortran provides the Fortran 2003 Stream facility.
5129Programmers should consider the use of new stream IO feature in new code
5130for future portability. See also @ref{Fortran 2003 status}.
e0c54690 5131
5132@item @emph{Standard}:
5133GNU extension
5134
5135@item @emph{Class}:
5136Subroutine
5137
5138@item @emph{Syntax}:
7d866870 5139@code{CALL FSEEK(UNIT, OFFSET, WHENCE[, STATUS])}
5140
e0c54690 5141@item @emph{Arguments}:
7d866870 5142@multitable @columnfractions .15 .70
5143@item @var{UNIT} @tab Shall be a scalar of type @code{INTEGER}.
5144@item @var{OFFSET} @tab Shall be a scalar of type @code{INTEGER}.
5145@item @var{WHENCE} @tab Shall be a scalar of type @code{INTEGER}.
5146Its value shall be either 0, 1 or 2.
5147@item @var{STATUS} @tab (Optional) shall be a scalar of type
5148@code{INTEGER(4)}.
5149@end multitable
5150
e0c54690 5151@item @emph{Example}:
7d866870 5152@smallexample
5153PROGRAM test_fseek
5154 INTEGER, PARAMETER :: SEEK_SET = 0, SEEK_CUR = 1, SEEK_END = 2
5155 INTEGER :: fd, offset, ierr
5156
5157 ierr = 0
5158 offset = 5
5159 fd = 10
5160
5161 OPEN(UNIT=fd, FILE="fseek.test")
5162 CALL FSEEK(fd, offset, SEEK_SET, ierr) ! move to OFFSET
5163 print *, FTELL(fd), ierr
5164
5165 CALL FSEEK(fd, 0, SEEK_END, ierr) ! move to end
5166 print *, FTELL(fd), ierr
e0c54690 5167
7d866870 5168 CALL FSEEK(fd, 0, SEEK_SET, ierr) ! move to beginning
5169 print *, FTELL(fd), ierr
5170
5171 CLOSE(UNIT=fd)
5172END PROGRAM
5173@end smallexample
5174
5175@item @emph{See also}:
5176@ref{FTELL}
e0c54690 5177@end table
5178
5179
a3c4ed23 5180
5181@node FSTAT
5182@section @code{FSTAT} --- Get file status
a1149005 5183@fnindex FSTAT
5184@cindex file system, file status
a3c4ed23 5185
5186@table @asis
5187@item @emph{Description}:
666bf11e 5188@code{FSTAT} is identical to @ref{STAT}, except that information about an
5189already opened file is obtained.
5190
2cd8ef8b 5191The elements in @code{VALUES} are the same as described by @ref{STAT}.
a3c4ed23 5192
138b8aca 5193This intrinsic is provided in both subroutine and function forms; however,
5194only one form can be used in any given program unit.
5195
a3c4ed23 5196@item @emph{Standard}:
666bf11e 5197GNU extension
5198
a3c4ed23 5199@item @emph{Class}:
138b8aca 5200Subroutine, function
666bf11e 5201
a3c4ed23 5202@item @emph{Syntax}:
6c07e6d8 5203@multitable @columnfractions .80
5204@item @code{CALL FSTAT(UNIT, VALUES [, STATUS])}
5205@item @code{STATUS = FSTAT(UNIT, VALUES)}
5206@end multitable
666bf11e 5207
a3c4ed23 5208@item @emph{Arguments}:
aee612a9 5209@multitable @columnfractions .15 .70
666bf11e 5210@item @var{UNIT} @tab An open I/O unit number of type @code{INTEGER}.
2cd8ef8b 5211@item @var{VALUES} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
666bf11e 5212@item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0
c24c5fac 5213on success and a system specific error code otherwise.
666bf11e 5214@end multitable
5215
a3c4ed23 5216@item @emph{Example}:
666bf11e 5217See @ref{STAT} for an example.
5218
a3c4ed23 5219@item @emph{See also}:
666bf11e 5220To stat a link: @ref{LSTAT}, to stat a file: @ref{STAT}
a3c4ed23 5221@end table
5222
5223
5224
a3c4ed23 5225@node FTELL
5226@section @code{FTELL} --- Current stream position
a1149005 5227@fnindex FTELL
5228@cindex file operation, position
a3c4ed23 5229
5230@table @asis
5231@item @emph{Description}:
944aa497 5232Retrieves the current position within an open file.
5233
5234This intrinsic is provided in both subroutine and function forms; however,
5235only one form can be used in any given program unit.
5236
a3c4ed23 5237@item @emph{Standard}:
5238GNU extension
5239
5240@item @emph{Class}:
944aa497 5241Subroutine, function
5242
a3c4ed23 5243@item @emph{Syntax}:
944aa497 5244@multitable @columnfractions .80
5245@item @code{CALL FTELL(UNIT, OFFSET)}
5246@item @code{OFFSET = FTELL(UNIT)}
5247@end multitable
5248
a3c4ed23 5249@item @emph{Arguments}:
aee612a9 5250@multitable @columnfractions .15 .70
944aa497 5251@item @var{OFFSET} @tab Shall of type @code{INTEGER}.
5252@item @var{UNIT} @tab Shall of type @code{INTEGER}.
5253@end multitable
5254
a3c4ed23 5255@item @emph{Return value}:
944aa497 5256In either syntax, @var{OFFSET} is set to the current offset of unit
5257number @var{UNIT}, or to @math{-1} if the unit is not currently open.
5258
a3c4ed23 5259@item @emph{Example}:
944aa497 5260@smallexample
5261PROGRAM test_ftell
5262 INTEGER :: i
5263 OPEN(10, FILE="temp.dat")
5264 CALL ftell(10,i)
5265 WRITE(*,*) i
5266END PROGRAM
5267@end smallexample
666bf11e 5268
a3c4ed23 5269@item @emph{See also}:
666bf11e 5270@ref{FSEEK}
a3c4ed23 5271@end table
5272
5273
5274
95b66823 5275@node GAMMA
5276@section @code{GAMMA} --- Gamma function
5277@fnindex GAMMA
5278@fnindex DGAMMA
5279@cindex Gamma function
5280@cindex Factorial function
5281
5282@table @asis
5283@item @emph{Description}:
5284@code{GAMMA(X)} computes Gamma (@math{\Gamma}) of @var{X}. For positive,
5285integer values of @var{X} the Gamma function simplifies to the factorial
5286function @math{\Gamma(x)=(x-1)!}.
5287
5288@tex
5289$$
5290\Gamma(x) = \int_0^\infty t^{x-1}{\rm e}^{-t}\,{\rm d}t
5291$$
5292@end tex
5293
5294@item @emph{Standard}:
ff4425cf 5295Fortran 2008 and later
95b66823 5296
5297@item @emph{Class}:
5298Elemental function
5299
5300@item @emph{Syntax}:
5301@code{X = GAMMA(X)}
5302
5303@item @emph{Arguments}:
5304@multitable @columnfractions .15 .70
5305@item @var{X} @tab Shall be of type @code{REAL} and neither zero
5306nor a negative integer.
5307@end multitable
5308
5309@item @emph{Return value}:
5310The return value is of type @code{REAL} of the same kind as @var{X}.
5311
5312@item @emph{Example}:
5313@smallexample
5314program test_gamma
5315 real :: x = 1.0
5316 x = gamma(x) ! returns 1.0
5317end program test_gamma
5318@end smallexample
5319
5320@item @emph{Specific names}:
5321@multitable @columnfractions .20 .20 .20 .25
5322@item Name @tab Argument @tab Return type @tab Standard
5323@item @code{GAMMA(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU Extension
5324@item @code{DGAMMA(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU Extension
5325@end multitable
5326
5327@item @emph{See also}:
ff4425cf 5328Logarithm of the Gamma function: @ref{LOG_GAMMA}
95b66823 5329
5330@end table
5331
5332
5333
475c7d78 5334@node GERROR
5335@section @code{GERROR} --- Get last system error message
a1149005 5336@fnindex GERROR
5337@cindex system, error handling
475c7d78 5338
5339@table @asis
5340@item @emph{Description}:
5341Returns the system error message corresponding to the last system error.
5342This resembles the functionality of @code{strerror(3)} in C.
5343
5344@item @emph{Standard}:
5345GNU extension
5346
5347@item @emph{Class}:
5348Subroutine
5349
5350@item @emph{Syntax}:
5351@code{CALL GERROR(RESULT)}
5352
5353@item @emph{Arguments}:
5354@multitable @columnfractions .15 .70
b44437b9 5355@item @var{RESULT} @tab Shall of type @code{CHARACTER} and of default
475c7d78 5356@end multitable
5357
5358@item @emph{Example}:
5359@smallexample
5360PROGRAM test_gerror
5361 CHARACTER(len=100) :: msg
5362 CALL gerror(msg)
5363 WRITE(*,*) msg
5364END PROGRAM
5365@end smallexample
5366
5367@item @emph{See also}:
5368@ref{IERRNO}, @ref{PERROR}
5369@end table
5370
5371
5372
a3c4ed23 5373@node GETARG
5374@section @code{GETARG} --- Get command line arguments
a1149005 5375@fnindex GETARG
5376@cindex command-line arguments
5377@cindex arguments, to program
a3c4ed23 5378
5379@table @asis
5380@item @emph{Description}:
e06f8026 5381Retrieve the @var{POS}-th argument that was passed on the
666bf11e 5382command line when the containing program was invoked.
5383
5384This intrinsic routine is provided for backwards compatibility with
5385GNU Fortran 77. In new code, programmers should consider the use of
5386the @ref{GET_COMMAND_ARGUMENT} intrinsic defined by the Fortran 2003
5387standard.
5388
a3c4ed23 5389@item @emph{Standard}:
5390GNU extension
5391
5392@item @emph{Class}:
666bf11e 5393Subroutine
5394
a3c4ed23 5395@item @emph{Syntax}:
5ef4af82 5396@code{CALL GETARG(POS, VALUE)}
666bf11e 5397
a3c4ed23 5398@item @emph{Arguments}:
aee612a9 5399@multitable @columnfractions .15 .70
5ef4af82 5400@item @var{POS} @tab Shall be of type @code{INTEGER} and not wider than
5401the default integer kind; @math{@var{POS} \geq 0}
b44437b9 5402@item @var{VALUE} @tab Shall be of type @code{CHARACTER} and of default
5403kind.
e06f8026 5404@item @var{VALUE} @tab Shall be of type @code{CHARACTER}.
666bf11e 5405@end multitable
5406
a3c4ed23 5407@item @emph{Return value}:
5ef4af82 5408After @code{GETARG} returns, the @var{VALUE} argument holds the
5409@var{POS}th command line argument. If @var{VALUE} can not hold the
5410argument, it is truncated to fit the length of @var{VALUE}. If there are
5411less than @var{POS} arguments specified at the command line, @var{VALUE}
5412will be filled with blanks. If @math{@var{POS} = 0}, @var{VALUE} is set
5413to the name of the program (on systems that support this feature).
666bf11e 5414
a3c4ed23 5415@item @emph{Example}:
666bf11e 5416@smallexample
5417PROGRAM test_getarg
5418 INTEGER :: i
5419 CHARACTER(len=32) :: arg
5420
5421 DO i = 1, iargc()
5422 CALL getarg(i, arg)
5423 WRITE (*,*) arg
5424 END DO
5425END PROGRAM
5426@end smallexample
a3c4ed23 5427
5428@item @emph{See also}:
425f0433 5429GNU Fortran 77 compatibility function: @ref{IARGC}
666bf11e 5430
ff4425cf 5431Fortran 2003 functions and subroutines: @ref{GET_COMMAND},
5432@ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
a3c4ed23 5433@end table
5434
5435
5436
5437@node GET_COMMAND
666bf11e 5438@section @code{GET_COMMAND} --- Get the entire command line
a1149005 5439@fnindex GET_COMMAND
5440@cindex command-line arguments
5441@cindex arguments, to program
a3c4ed23 5442
5443@table @asis
5444@item @emph{Description}:
666bf11e 5445Retrieve the entire command line that was used to invoke the program.
5446
a3c4ed23 5447@item @emph{Standard}:
ff4425cf 5448Fortran 2003 and later
a3c4ed23 5449
5450@item @emph{Class}:
666bf11e 5451Subroutine
5452
a3c4ed23 5453@item @emph{Syntax}:
2cd8ef8b 5454@code{CALL GET_COMMAND([COMMAND, LENGTH, STATUS])}
666bf11e 5455
a3c4ed23 5456@item @emph{Arguments}:
aee612a9 5457@multitable @columnfractions .15 .70
2cd8ef8b 5458@item @var{COMMAND} @tab (Optional) shall be of type @code{CHARACTER} and
5459of default kind.
5460@item @var{LENGTH} @tab (Optional) Shall be of type @code{INTEGER} and of
5461default kind.
5462@item @var{STATUS} @tab (Optional) Shall be of type @code{INTEGER} and of
5463default kind.
666bf11e 5464@end multitable
5465
a3c4ed23 5466@item @emph{Return value}:
2cd8ef8b 5467If @var{COMMAND} is present, stores the entire command line that was used
5468to invoke the program in @var{COMMAND}. If @var{LENGTH} is present, it is
5469assigned the length of the command line. If @var{STATUS} is present, it
5470is assigned 0 upon success of the command, -1 if @var{COMMAND} is too
5471short to store the command line, or a positive value in case of an error.
666bf11e 5472
a3c4ed23 5473@item @emph{Example}:
666bf11e 5474@smallexample
5475PROGRAM test_get_command
5476 CHARACTER(len=255) :: cmd
5477 CALL get_command(cmd)
5478 WRITE (*,*) TRIM(cmd)
5479END PROGRAM
5480@end smallexample
5481
a3c4ed23 5482@item @emph{See also}:
666bf11e 5483@ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
a3c4ed23 5484@end table
5485
5486
5487
5488@node GET_COMMAND_ARGUMENT
666bf11e 5489@section @code{GET_COMMAND_ARGUMENT} --- Get command line arguments
a1149005 5490@fnindex GET_COMMAND_ARGUMENT
5491@cindex command-line arguments
5492@cindex arguments, to program
a3c4ed23 5493
5494@table @asis
5495@item @emph{Description}:
cf37b737 5496Retrieve the @var{NUMBER}-th argument that was passed on the
666bf11e 5497command line when the containing program was invoked.
5498
a3c4ed23 5499@item @emph{Standard}:
ff4425cf 5500Fortran 2003 and later
a3c4ed23 5501
5502@item @emph{Class}:
666bf11e 5503Subroutine
5504
a3c4ed23 5505@item @emph{Syntax}:
cf37b737 5506@code{CALL GET_COMMAND_ARGUMENT(NUMBER [, VALUE, LENGTH, STATUS])}
666bf11e 5507
a3c4ed23 5508@item @emph{Arguments}:
aee612a9 5509@multitable @columnfractions .15 .70
2cd8ef8b 5510@item @var{NUMBER} @tab Shall be a scalar of type @code{INTEGER} and of
5511default kind, @math{@var{NUMBER} \geq 0}
a9601c93 5512@item @var{VALUE} @tab (Optional) Shall be a scalar of type @code{CHARACTER}
c24c5fac 5513and of default kind.
a9601c93 5514@item @var{LENGTH} @tab (Optional) Shall be a scalar of type @code{INTEGER}
2cd8ef8b 5515and of default kind.
a9601c93 5516@item @var{STATUS} @tab (Optional) Shall be a scalar of type @code{INTEGER}
2cd8ef8b 5517and of default kind.
666bf11e 5518@end multitable
5519
a3c4ed23 5520@item @emph{Return value}:
cf37b737 5521After @code{GET_COMMAND_ARGUMENT} returns, the @var{VALUE} argument holds the
5522@var{NUMBER}-th command line argument. If @var{VALUE} can not hold the argument, it is
5523truncated to fit the length of @var{VALUE}. If there are less than @var{NUMBER}
5524arguments specified at the command line, @var{VALUE} will be filled with blanks.
57b9ac90 5525If @math{@var{NUMBER} = 0}, @var{VALUE} is set to the name of the program (on
5526systems that support this feature). The @var{LENGTH} argument contains the
5527length of the @var{NUMBER}-th command line argument. If the argument retrieval
5528fails, @var{STATUS} is a positive number; if @var{VALUE} contains a truncated
5529command line argument, @var{STATUS} is -1; and otherwise the @var{STATUS} is
5530zero.
666bf11e 5531
a3c4ed23 5532@item @emph{Example}:
666bf11e 5533@smallexample
5534PROGRAM test_get_command_argument
5535 INTEGER :: i
5536 CHARACTER(len=32) :: arg
5537
5538 i = 0
5539 DO
5540 CALL get_command_argument(i, arg)
5541 IF (LEN_TRIM(arg) == 0) EXIT
5542
5543 WRITE (*,*) TRIM(arg)
5544 i = i+1
5545 END DO
5546END PROGRAM
5547@end smallexample
5548
a3c4ed23 5549@item @emph{See also}:
666bf11e 5550@ref{GET_COMMAND}, @ref{COMMAND_ARGUMENT_COUNT}
a3c4ed23 5551@end table
5552
5553
5554
5555@node GETCWD
5556@section @code{GETCWD} --- Get current working directory
a1149005 5557@fnindex GETCWD
5558@cindex system, working directory
a3c4ed23 5559
5560@table @asis
5561@item @emph{Description}:
ed8f9044 5562Get current working directory.
5563
138b8aca 5564This intrinsic is provided in both subroutine and function forms; however,
5565only one form can be used in any given program unit.
5566
a3c4ed23 5567@item @emph{Standard}:
5568GNU extension
5569
5570@item @emph{Class}:
138b8aca 5571Subroutine, function
ed8f9044 5572
a3c4ed23 5573@item @emph{Syntax}:
6c07e6d8 5574@multitable @columnfractions .80
5575@item @code{CALL GETCWD(C [, STATUS])}
5576@item @code{STATUS = GETCWD(C)}
5577@end multitable
ed8f9044 5578
a3c4ed23 5579@item @emph{Arguments}:
aee612a9 5580@multitable @columnfractions .15 .70
b44437b9 5581@item @var{C} @tab The type shall be @code{CHARACTER} and of default kind.
ed8f9044 5582@item @var{STATUS} @tab (Optional) status flag. Returns 0 on success,
c24c5fac 5583a system specific and nonzero error code otherwise.
ed8f9044 5584@end multitable
5585
a3c4ed23 5586@item @emph{Example}:
ed8f9044 5587@smallexample
5588PROGRAM test_getcwd
5589 CHARACTER(len=255) :: cwd
5590 CALL getcwd(cwd)
5591 WRITE(*,*) TRIM(cwd)
5592END PROGRAM
5593@end smallexample
5594
a3c4ed23 5595@item @emph{See also}:
ed8f9044 5596@ref{CHDIR}
a3c4ed23 5597@end table
5598
5599
5600
5601@node GETENV
5602@section @code{GETENV} --- Get an environmental variable
a1149005 5603@fnindex GETENV
666bf11e 5604@cindex environment variable
a3c4ed23 5605
5606@table @asis
5607@item @emph{Description}:
cf37b737 5608Get the @var{VALUE} of the environmental variable @var{NAME}.
666bf11e 5609
026484b4 5610This intrinsic routine is provided for backwards compatibility with
5611GNU Fortran 77. In new code, programmers should consider the use of
666bf11e 5612the @ref{GET_ENVIRONMENT_VARIABLE} intrinsic defined by the Fortran
56132003 standard.
5614
026484b4 5615Note that @code{GETENV} need not be thread-safe. It is the
5616responsibility of the user to ensure that the environment is not being
5617updated concurrently with a call to the @code{GETENV} intrinsic.
5618
a3c4ed23 5619@item @emph{Standard}:
5620GNU extension
5621
5622@item @emph{Class}:
666bf11e 5623Subroutine
5624
a3c4ed23 5625@item @emph{Syntax}:
cf37b737 5626@code{CALL GETENV(NAME, VALUE)}
666bf11e 5627
a3c4ed23 5628@item @emph{Arguments}:
aee612a9 5629@multitable @columnfractions .15 .70
b44437b9 5630@item @var{NAME} @tab Shall be of type @code{CHARACTER} and of default kind.
5631@item @var{VALUE} @tab Shall be of type @code{CHARACTER} and of default kind.
666bf11e 5632@end multitable
5633
a3c4ed23 5634@item @emph{Return value}:
cf37b737 5635Stores the value of @var{NAME} in @var{VALUE}. If @var{VALUE} is
5636not large enough to hold the data, it is truncated. If @var{NAME}
666bf11e 5637is not set, @var{VALUE} will be filled with blanks.
5638
a3c4ed23 5639@item @emph{Example}:
666bf11e 5640@smallexample
5641PROGRAM test_getenv
5642 CHARACTER(len=255) :: homedir
5643 CALL getenv("HOME", homedir)
5644 WRITE (*,*) TRIM(homedir)
5645END PROGRAM
5646@end smallexample
5647
a3c4ed23 5648@item @emph{See also}:
5649@ref{GET_ENVIRONMENT_VARIABLE}
5650@end table
5651
5652
5653
5654@node GET_ENVIRONMENT_VARIABLE
5655@section @code{GET_ENVIRONMENT_VARIABLE} --- Get an environmental variable
a1149005 5656@fnindex GET_ENVIRONMENT_VARIABLE
666bf11e 5657@cindex environment variable
a3c4ed23 5658
5659@table @asis
5660@item @emph{Description}:
cf37b737 5661Get the @var{VALUE} of the environmental variable @var{NAME}.
666bf11e 5662
026484b4 5663Note that @code{GET_ENVIRONMENT_VARIABLE} need not be thread-safe. It
5664is the responsibility of the user to ensure that the environment is
5665not being updated concurrently with a call to the
5666@code{GET_ENVIRONMENT_VARIABLE} intrinsic.
5667
a3c4ed23 5668@item @emph{Standard}:
ff4425cf 5669Fortran 2003 and later
a3c4ed23 5670
5671@item @emph{Class}:
5672Subroutine
5673
5674@item @emph{Syntax}:
cf37b737 5675@code{CALL GET_ENVIRONMENT_VARIABLE(NAME[, VALUE, LENGTH, STATUS, TRIM_NAME)}
666bf11e 5676
a3c4ed23 5677@item @emph{Arguments}:
aee612a9 5678@multitable @columnfractions .15 .70
2cd8ef8b 5679@item @var{NAME} @tab Shall be a scalar of type @code{CHARACTER}
5680and of default kind.
a9601c93 5681@item @var{VALUE} @tab (Optional) Shall be a scalar of type @code{CHARACTER}
2cd8ef8b 5682and of default kind.
a9601c93 5683@item @var{LENGTH} @tab (Optional) Shall be a scalar of type @code{INTEGER}
2cd8ef8b 5684and of default kind.
a9601c93 5685@item @var{STATUS} @tab (Optional) Shall be a scalar of type @code{INTEGER}
2cd8ef8b 5686and of default kind.
a9601c93 5687@item @var{TRIM_NAME} @tab (Optional) Shall be a scalar of type @code{LOGICAL}
2cd8ef8b 5688and of default kind.
666bf11e 5689@end multitable
5690
a3c4ed23 5691@item @emph{Return value}:
cf37b737 5692Stores the value of @var{NAME} in @var{VALUE}. If @var{VALUE} is
5693not large enough to hold the data, it is truncated. If @var{NAME}
5694is not set, @var{VALUE} will be filled with blanks. Argument @var{LENGTH}
5695contains the length needed for storing the environment variable @var{NAME}
5696or zero if it is not present. @var{STATUS} is -1 if @var{VALUE} is present
5697but too short for the environment variable; it is 1 if the environment
5698variable does not exist and 2 if the processor does not support environment
5699variables; in all other cases @var{STATUS} is zero. If @var{TRIM_NAME} is
5700present with the value @code{.FALSE.}, the trailing blanks in @var{NAME}
5701are significant; otherwise they are not part of the environment variable
5702name.
666bf11e 5703
a3c4ed23 5704@item @emph{Example}:
666bf11e 5705@smallexample
5706PROGRAM test_getenv
5707 CHARACTER(len=255) :: homedir
5708 CALL get_environment_variable("HOME", homedir)
5709 WRITE (*,*) TRIM(homedir)
5710END PROGRAM
5711@end smallexample
572d7b7f 5712@end table
5713
5714
5715
5716@node GETGID
5717@section @code{GETGID} --- Group ID function
a1149005 5718@fnindex GETGID
12786727 5719@cindex system, group ID
572d7b7f 5720
5721@table @asis
5722@item @emph{Description}:
5723Returns the numerical group ID of the current process.
5724
a3c4ed23 5725@item @emph{Standard}:
5726GNU extension
572d7b7f 5727
5728@item @emph{Class}:
138b8aca 5729Function
572d7b7f 5730
5731@item @emph{Syntax}:
4eb41f08 5732@code{RESULT = GETGID()}
572d7b7f 5733
5734@item @emph{Return value}:
5735The return value of @code{GETGID} is an @code{INTEGER} of the default
5736kind.
5737
5738
5739@item @emph{Example}:
5740See @code{GETPID} for an example.
5741
a3c4ed23 5742@item @emph{See also}:
944aa497 5743@ref{GETPID}, @ref{GETUID}
a3c4ed23 5744@end table
5745
5746
5747
5748@node GETLOG
5749@section @code{GETLOG} --- Get login name
a1149005 5750@fnindex GETLOG
5751@cindex system, login name
5752@cindex login name
a3c4ed23 5753
5754@table @asis
5755@item @emph{Description}:
944aa497 5756Gets the username under which the program is running.
5757
a3c4ed23 5758@item @emph{Standard}:
5759GNU extension
5760
5761@item @emph{Class}:
5762Subroutine
5763
5764@item @emph{Syntax}:
cf37b737 5765@code{CALL GETLOG(C)}
944aa497 5766
a3c4ed23 5767@item @emph{Arguments}:
aee612a9 5768@multitable @columnfractions .15 .70
b44437b9 5769@item @var{C} @tab Shall be of type @code{CHARACTER} and of default kind.
944aa497 5770@end multitable
5771
a3c4ed23 5772@item @emph{Return value}:
d341b099 5773Stores the current user name in @var{LOGIN}. (On systems where POSIX
5774functions @code{geteuid} and @code{getpwuid} are not available, and
5775the @code{getlogin} function is not implemented either, this will
944aa497 5776return a blank string.)
5777
a3c4ed23 5778@item @emph{Example}:
944aa497 5779@smallexample
5780PROGRAM TEST_GETLOG
5781 CHARACTER(32) :: login
5782 CALL GETLOG(login)
5783 WRITE(*,*) login
5784END PROGRAM
5785@end smallexample
5786
a3c4ed23 5787@item @emph{See also}:
944aa497 5788@ref{GETUID}
572d7b7f 5789@end table
5790
5791
5792
5793@node GETPID
5794@section @code{GETPID} --- Process ID function
a1149005 5795@fnindex GETPID
12786727 5796@cindex system, process ID
5797@cindex process ID
572d7b7f 5798
5799@table @asis
5800@item @emph{Description}:
a3c4ed23 5801Returns the numerical process identifier of the current process.
572d7b7f 5802
a3c4ed23 5803@item @emph{Standard}:
5804GNU extension
572d7b7f 5805
5806@item @emph{Class}:
138b8aca 5807Function
572d7b7f 5808
5809@item @emph{Syntax}:
4eb41f08 5810@code{RESULT = GETPID()}
572d7b7f 5811
5812@item @emph{Return value}:
5813The return value of @code{GETPID} is an @code{INTEGER} of the default
5814kind.
5815
b549d2a5 5816
5817@item @emph{Example}:
5818@smallexample
572d7b7f 5819program info
5820 print *, "The current process ID is ", getpid()
5821 print *, "Your numerical user ID is ", getuid()
5822 print *, "Your numerical group ID is ", getgid()
5823end program info
b549d2a5 5824@end smallexample
572d7b7f 5825
944aa497 5826@item @emph{See also}:
5827@ref{GETGID}, @ref{GETUID}
b549d2a5 5828@end table
2c5b695e 5829
572d7b7f 5830
5831
5832@node GETUID
5833@section @code{GETUID} --- User ID function
a1149005 5834@fnindex GETUID
12786727 5835@cindex system, user ID
a1149005 5836@cindex user id
338c728c 5837
5838@table @asis
5839@item @emph{Description}:
572d7b7f 5840Returns the numerical user ID of the current process.
5841
a3c4ed23 5842@item @emph{Standard}:
5843GNU extension
572d7b7f 5844
5845@item @emph{Class}:
138b8aca 5846Function
572d7b7f 5847
5848@item @emph{Syntax}:
4eb41f08 5849@code{RESULT = GETUID()}
572d7b7f 5850
5851@item @emph{Return value}:
5852The return value of @code{GETUID} is an @code{INTEGER} of the default
5853kind.
5854
5855
5856@item @emph{Example}:
5857See @code{GETPID} for an example.
5858
a3c4ed23 5859@item @emph{See also}:
944aa497 5860@ref{GETPID}, @ref{GETLOG}
a3c4ed23 5861@end table
5862
5863
5864
5865@node GMTIME
5866@section @code{GMTIME} --- Convert time to GMT info
a1149005 5867@fnindex GMTIME
5868@cindex time, conversion to GMT info
a3c4ed23 5869
a3c4ed23 5870@table @asis
5871@item @emph{Description}:
e8c1bbb4 5872Given a system time value @var{TIME} (as provided by the @code{TIME8}
cf37b737 5873intrinsic), fills @var{VALUES} with values extracted from it appropriate
0eb92d52 5874to the UTC time zone (Universal Coordinated Time, also known in some
5875countries as GMT, Greenwich Mean Time), using @code{gmtime(3)}.
a3c4ed23 5876
5877@item @emph{Standard}:
5878GNU extension
5879
5880@item @emph{Class}:
5881Subroutine
5882
5883@item @emph{Syntax}:
cf37b737 5884@code{CALL GMTIME(TIME, VALUES)}
0eb92d52 5885
a3c4ed23 5886@item @emph{Arguments}:
aee612a9 5887@multitable @columnfractions .15 .70
cf37b737 5888@item @var{TIME} @tab An @code{INTEGER} scalar expression
c24c5fac 5889corresponding to a system time, with @code{INTENT(IN)}.
cf37b737 5890@item @var{VALUES} @tab A default @code{INTEGER} array with 9 elements,
c24c5fac 5891with @code{INTENT(OUT)}.
0eb92d52 5892@end multitable
5893
a3c4ed23 5894@item @emph{Return value}:
cf37b737 5895The elements of @var{VALUES} are assigned as follows:
0eb92d52 5896@enumerate
5897@item Seconds after the minute, range 0--59 or 0--61 to allow for leap
c24c5fac 5898seconds
0eb92d52 5899@item Minutes after the hour, range 0--59
5900@item Hours past midnight, range 0--23
5901@item Day of month, range 0--31
5902@item Number of months since January, range 0--12
5903@item Years since 1900
5904@item Number of days since Sunday, range 0--6
5905@item Days since January 1
5906@item Daylight savings indicator: positive if daylight savings is in
c24c5fac 5907effect, zero if not, and negative if the information is not available.
0eb92d52 5908@end enumerate
5909
a3c4ed23 5910@item @emph{See also}:
0eb92d52 5911@ref{CTIME}, @ref{LTIME}, @ref{TIME}, @ref{TIME8}
a3c4ed23 5912
5913@end table
5914
5915
5916
5917@node HOSTNM
5918@section @code{HOSTNM} --- Get system host name
a1149005 5919@fnindex HOSTNM
5920@cindex system, host name
a3c4ed23 5921
5922@table @asis
5923@item @emph{Description}:
944aa497 5924Retrieves the host name of the system on which the program is running.
5925
5926This intrinsic is provided in both subroutine and function forms; however,
5927only one form can be used in any given program unit.
5928
a3c4ed23 5929@item @emph{Standard}:
5930GNU extension
5931
5932@item @emph{Class}:
944aa497 5933Subroutine, function
5934
a3c4ed23 5935@item @emph{Syntax}:
944aa497 5936@multitable @columnfractions .80
cf37b737 5937@item @code{CALL HOSTNM(C [, STATUS])}
944aa497 5938@item @code{STATUS = HOSTNM(NAME)}
5939@end multitable
5940
a3c4ed23 5941@item @emph{Arguments}:
aee612a9 5942@multitable @columnfractions .15 .70
b44437b9 5943@item @var{C} @tab Shall of type @code{CHARACTER} and of default kind.
944aa497 5944@item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
c24c5fac 5945Returns 0 on success, or a system specific error code otherwise.
944aa497 5946@end multitable
5947
a3c4ed23 5948@item @emph{Return value}:
944aa497 5949In either syntax, @var{NAME} is set to the current hostname if it can
5950be obtained, or to a blank string otherwise.
5951
572d7b7f 5952@end table
5953
5954
5955
5956@node HUGE
5957@section @code{HUGE} --- Largest number of a kind
a1149005 5958@fnindex HUGE
5959@cindex limits, largest number
5960@cindex model representation, largest number
572d7b7f 5961
5962@table @asis
5963@item @emph{Description}:
5964@code{HUGE(X)} returns the largest number that is not an infinity in
5965the model of the type of @code{X}.
338c728c 5966
a3c4ed23 5967@item @emph{Standard}:
f40b44c0 5968Fortran 95 and later
338c728c 5969
bb3d0c30 5970@item @emph{Class}:
5dce3893 5971Inquiry function
338c728c 5972
5973@item @emph{Syntax}:
4eb41f08 5974@code{RESULT = HUGE(X)}
338c728c 5975
5976@item @emph{Arguments}:
aee612a9 5977@multitable @columnfractions .15 .70
e0c54690 5978@item @var{X} @tab Shall be of type @code{REAL} or @code{INTEGER}.
338c728c 5979@end multitable
5980
5981@item @emph{Return value}:
572d7b7f 5982The return value is of the same type and kind as @var{X}
338c728c 5983
5984@item @emph{Example}:
5985@smallexample
572d7b7f 5986program test_huge_tiny
5987 print *, huge(0), huge(0.0), huge(0.0d0)
5988 print *, tiny(0.0), tiny(0.0d0)
5989end program test_huge_tiny
338c728c 5990@end smallexample
572d7b7f 5991@end table
338c728c 5992
572d7b7f 5993
5994
ff4425cf 5995@node HYPOT
5996@section @code{HYPOT} --- Euclidean distance function
5997@fnindex HYPOT
5998@cindex Euclidean distance
5999
6000@table @asis
6001@item @emph{Description}:
6002@code{HYPOT(X,Y)} is the Euclidean distance function. It is equal to
6003@math{\sqrt{X^2 + Y^2}}, without undue underflow or overflow.
6004
6005@item @emph{Standard}:
6006Fortran 2008 and later
6007
6008@item @emph{Class}:
6009Elemental function
6010
6011@item @emph{Syntax}:
cf37b737 6012@code{RESULT = HYPOT(X, Y)}
ff4425cf 6013
6014@item @emph{Arguments}:
6015@multitable @columnfractions .15 .70
6016@item @var{X} @tab The type shall be @code{REAL}.
6017@item @var{Y} @tab The type and kind type parameter shall be the same as
6018@var{X}.
6019@end multitable
6020
6021@item @emph{Return value}:
6022The return value has the same type and kind type parameter as @var{X}.
6023
6024@item @emph{Example}:
6025@smallexample
6026program test_hypot
6027 real(4) :: x = 1.e0_4, y = 0.5e0_4
6028 x = hypot(x,y)
6029end program test_hypot
6030@end smallexample
6031@end table
6032
6033
6034
572d7b7f 6035@node IACHAR
6036@section @code{IACHAR} --- Code in @acronym{ASCII} collating sequence
a1149005 6037@fnindex IACHAR
572d7b7f 6038@cindex @acronym{ASCII} collating sequence
a1149005 6039@cindex collating sequence, @acronym{ASCII}
6040@cindex conversion, to integer
572d7b7f 6041
6042@table @asis
6043@item @emph{Description}:
6044@code{IACHAR(C)} returns the code for the @acronym{ASCII} character
6045in the first character position of @code{C}.
6046
a3c4ed23 6047@item @emph{Standard}:
f40b44c0 6048Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
572d7b7f 6049
6050@item @emph{Class}:
a3c4ed23 6051Elemental function
572d7b7f 6052
6053@item @emph{Syntax}:
7fe55cc9 6054@code{RESULT = IACHAR(C [, KIND])}
572d7b7f 6055
6056@item @emph{Arguments}:
aee612a9 6057@multitable @columnfractions .15 .70
7fe55cc9 6058@item @var{C} @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
6059@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
c24c5fac 6060expression indicating the kind parameter of the result.
338c728c 6061@end multitable
572d7b7f 6062
6063@item @emph{Return value}:
7fe55cc9 6064The return value is of type @code{INTEGER} and of kind @var{KIND}. If
6065@var{KIND} is absent, the return value is of default integer kind.
572d7b7f 6066
6067@item @emph{Example}:
6068@smallexample
6069program test_iachar
6070 integer i
6071 i = iachar(' ')
6072end program test_iachar
6073@end smallexample
a3c4ed23 6074
e95fe2fe 6075@item @emph{Note}:
6076See @ref{ICHAR} for a discussion of converting between numerical values
6077and formatted string representations.
6078
a3c4ed23 6079@item @emph{See also}:
c5cb0f03 6080@ref{ACHAR}, @ref{CHAR}, @ref{ICHAR}
a3c4ed23 6081
338c728c 6082@end table
6083
6084
fe97b755 6085
9028d57d 6086@node IALL
6087@section @code{IALL} --- Bitwise AND of array elements
6088@fnindex IALL
6089@cindex array, AND
6090@cindex bits, AND of array elements
6091
6092@table @asis
6093@item @emph{Description}:
6094Reduces with bitwise AND the elements of @var{ARRAY} along dimension @var{DIM}
6095if the corresponding element in @var{MASK} is @code{TRUE}.
6096
6097@item @emph{Standard}:
6098Fortran 2008 and later
6099
6100@item @emph{Class}:
6101Transformational function
6102
6103@item @emph{Syntax}:
6104@multitable @columnfractions .80
6105@item @code{RESULT = IALL(ARRAY[, MASK])}
6106@item @code{RESULT = IALL(ARRAY, DIM[, MASK])}
6107@end multitable
6108
6109@item @emph{Arguments}:
6110@multitable @columnfractions .15 .70
6111@item @var{ARRAY} @tab Shall be an array of type @code{INTEGER}
6112@item @var{DIM} @tab (Optional) shall be a scalar of type
6113@code{INTEGER} with a value in the range from 1 to n, where n
6114equals the rank of @var{ARRAY}.
6115@item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL}
6116and either be a scalar or an array of the same shape as @var{ARRAY}.
6117@end multitable
6118
6119@item @emph{Return value}:
6120The result is of the same type as @var{ARRAY}.
6121
6122If @var{DIM} is absent, a scalar with the bitwise ALL of all elements in
6123@var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals
6124the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with
6125dimension @var{DIM} dropped is returned.
6126
6127@item @emph{Example}:
6128@smallexample
6129PROGRAM test_iall
6130 INTEGER(1) :: a(2)
6131
6132 a(1) = b'00100100'
fd77a350 6133 a(2) = b'01101010'
9028d57d 6134
6135 ! prints 00100000
6136 PRINT '(b8.8)', IALL(a)
6137END PROGRAM
6138@end smallexample
6139
6140@item @emph{See also}:
6141@ref{IANY}, @ref{IPARITY}, @ref{IAND}
6142@end table
6143
6144
6145
a3c4ed23 6146@node IAND
6147@section @code{IAND} --- Bitwise logical and
a1149005 6148@fnindex IAND
6149@cindex bitwise logical and
6150@cindex logical and, bitwise
338c728c 6151
338c728c 6152@table @asis
6153@item @emph{Description}:
666bf11e 6154Bitwise logical @code{AND}.
6155
a3c4ed23 6156@item @emph{Standard}:
f40b44c0 6157Fortran 95 and later
338c728c 6158
bb3d0c30 6159@item @emph{Class}:
a3c4ed23 6160Elemental function
338c728c 6161
6162@item @emph{Syntax}:
22f55265 6163@code{RESULT = IAND(I, J)}
666bf11e 6164
a3c4ed23 6165@item @emph{Arguments}:
aee612a9 6166@multitable @columnfractions .15 .70
e06f8026 6167@item @var{I} @tab The type shall be @code{INTEGER}.
6168@item @var{J} @tab The type shall be @code{INTEGER}, of the same
22f55265 6169kind as @var{I}. (As a GNU extension, different kinds are also
6170permitted.)
666bf11e 6171@end multitable
6172
a3c4ed23 6173@item @emph{Return value}:
e06f8026 6174The return type is @code{INTEGER}, of the same kind as the
22f55265 6175arguments. (If the argument kinds differ, it is of the same kind as
6176the larger argument.)
666bf11e 6177
a3c4ed23 6178@item @emph{Example}:
666bf11e 6179@smallexample
6180PROGRAM test_iand
6181 INTEGER :: a, b
6182 DATA a / Z'F' /, b / Z'3' /
6183 WRITE (*,*) IAND(a, b)
6184END PROGRAM
6185@end smallexample
a3c4ed23 6186
6187@item @emph{See also}:
0eb92d52 6188@ref{IOR}, @ref{IEOR}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
6189
a3c4ed23 6190@end table
6191
6192
6193
9028d57d 6194@node IANY
fd77a350 6195@section @code{IANY} --- Bitwise OR of array elements
9028d57d 6196@fnindex IANY
6197@cindex array, OR
6198@cindex bits, OR of array elements
6199
6200@table @asis
6201@item @emph{Description}:
6202Reduces with bitwise OR (inclusive or) the elements of @var{ARRAY} along
6203dimension @var{DIM} if the corresponding element in @var{MASK} is @code{TRUE}.
6204
6205@item @emph{Standard}:
6206Fortran 2008 and later
6207
6208@item @emph{Class}:
6209Transformational function
6210
6211@item @emph{Syntax}:
6212@multitable @columnfractions .80
6213@item @code{RESULT = IANY(ARRAY[, MASK])}
6214@item @code{RESULT = IANY(ARRAY, DIM[, MASK])}
6215@end multitable
6216
6217@item @emph{Arguments}:
6218@multitable @columnfractions .15 .70
6219@item @var{ARRAY} @tab Shall be an array of type @code{INTEGER}
6220@item @var{DIM} @tab (Optional) shall be a scalar of type
6221@code{INTEGER} with a value in the range from 1 to n, where n
6222equals the rank of @var{ARRAY}.
6223@item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL}
6224and either be a scalar or an array of the same shape as @var{ARRAY}.
6225@end multitable
6226
6227@item @emph{Return value}:
6228The result is of the same type as @var{ARRAY}.
6229
6230If @var{DIM} is absent, a scalar with the bitwise OR of all elements in
6231@var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals
6232the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with
6233dimension @var{DIM} dropped is returned.
6234
6235@item @emph{Example}:
6236@smallexample
6237PROGRAM test_iany
6238 INTEGER(1) :: a(2)
6239
6240 a(1) = b'00100100'
fd77a350 6241 a(2) = b'01101010'
9028d57d 6242
fd77a350 6243 ! prints 01101110
9028d57d 6244 PRINT '(b8.8)', IANY(a)
6245END PROGRAM
6246@end smallexample
6247
6248@item @emph{See also}:
6249@ref{IPARITY}, @ref{IALL}, @ref{IOR}
6250@end table
6251
6252
6253
a3c4ed23 6254@node IARGC
666bf11e 6255@section @code{IARGC} --- Get the number of command line arguments
a1149005 6256@fnindex IARGC
6257@cindex command-line arguments
6258@cindex command-line arguments, number of
6259@cindex arguments, to program
a3c4ed23 6260
6261@table @asis
6262@item @emph{Description}:
e8c1bbb4 6263@code{IARGC} returns the number of arguments passed on the
666bf11e 6264command line when the containing program was invoked.
6265
6266This intrinsic routine is provided for backwards compatibility with
6267GNU Fortran 77. In new code, programmers should consider the use of
6268the @ref{COMMAND_ARGUMENT_COUNT} intrinsic defined by the Fortran 2003
6269standard.
6270
a3c4ed23 6271@item @emph{Standard}:
6272GNU extension
6273
6274@item @emph{Class}:
138b8aca 6275Function
666bf11e 6276
a3c4ed23 6277@item @emph{Syntax}:
4eb41f08 6278@code{RESULT = IARGC()}
666bf11e 6279
a3c4ed23 6280@item @emph{Arguments}:
666bf11e 6281None.
6282
a3c4ed23 6283@item @emph{Return value}:
666bf11e 6284The number of command line arguments, type @code{INTEGER(4)}.
6285
a3c4ed23 6286@item @emph{Example}:
666bf11e 6287See @ref{GETARG}
6288
a3c4ed23 6289@item @emph{See also}:
425f0433 6290GNU Fortran 77 compatibility subroutine: @ref{GETARG}
a3c4ed23 6291
ff4425cf 6292Fortran 2003 functions and subroutines: @ref{GET_COMMAND},
6293@ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
a3c4ed23 6294@end table
6295
6296
6297
a3c4ed23 6298@node IBCLR
6299@section @code{IBCLR} --- Clear bit
a1149005 6300@fnindex IBCLR
6301@cindex bits, unset
6302@cindex bits, clear
a3c4ed23 6303
a3c4ed23 6304@table @asis
6305@item @emph{Description}:
22f55265 6306@code{IBCLR} returns the value of @var{I} with the bit at position
6307@var{POS} set to zero.
6308
a3c4ed23 6309@item @emph{Standard}:
f40b44c0 6310Fortran 95 and later
a3c4ed23 6311
6312@item @emph{Class}:
6313Elemental function
6314
6315@item @emph{Syntax}:
22f55265 6316@code{RESULT = IBCLR(I, POS)}
6317
a3c4ed23 6318@item @emph{Arguments}:
aee612a9 6319@multitable @columnfractions .15 .70
e06f8026 6320@item @var{I} @tab The type shall be @code{INTEGER}.
6321@item @var{POS} @tab The type shall be @code{INTEGER}.
22f55265 6322@end multitable
6323
a3c4ed23 6324@item @emph{Return value}:
e06f8026 6325The return value is of type @code{INTEGER} and of the same kind as
22f55265 6326@var{I}.
a3c4ed23 6327
6328@item @emph{See also}:
0eb92d52 6329@ref{IBITS}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}, @ref{MVBITS}
6330
a3c4ed23 6331@end table
6332
6333
6334
a3c4ed23 6335@node IBITS
6336@section @code{IBITS} --- Bit extraction
a1149005 6337@fnindex IBITS
6338@cindex bits, get
6339@cindex bits, extract
a3c4ed23 6340
a3c4ed23 6341@table @asis
6342@item @emph{Description}:
22f55265 6343@code{IBITS} extracts a field of length @var{LEN} from @var{I},
6344starting from bit position @var{POS} and extending left for @var{LEN}
6345bits. The result is right-justified and the remaining bits are
6346zeroed. The value of @code{POS+LEN} must be less than or equal to the
6347value @code{BIT_SIZE(I)}.
6348
a3c4ed23 6349@item @emph{Standard}:
f40b44c0 6350Fortran 95 and later
a3c4ed23 6351
6352@item @emph{Class}:
6353Elemental function
6354
6355@item @emph{Syntax}:
22f55265 6356@code{RESULT = IBITS(I, POS, LEN)}
6357
a3c4ed23 6358@item @emph{Arguments}:
aee612a9 6359@multitable @columnfractions .15 .70
cf37b737 6360@item @var{I} @tab The type shall be @code{INTEGER}.
e06f8026 6361@item @var{POS} @tab The type shall be @code{INTEGER}.
6362@item @var{LEN} @tab The type shall be @code{INTEGER}.
22f55265 6363@end multitable
6364
a3c4ed23 6365@item @emph{Return value}:
e06f8026 6366The return value is of type @code{INTEGER} and of the same kind as
22f55265 6367@var{I}.
a3c4ed23 6368
22f55265 6369@item @emph{See also}:
6370@ref{BIT_SIZE}, @ref{IBCLR}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
a3c4ed23 6371@end table
6372
6373
6374
a3c4ed23 6375@node IBSET
6376@section @code{IBSET} --- Set bit
a1149005 6377@fnindex IBSET
6378@cindex bits, set
a3c4ed23 6379
a3c4ed23 6380@table @asis
6381@item @emph{Description}:
22f55265 6382@code{IBSET} returns the value of @var{I} with the bit at position
6383@var{POS} set to one.
6384
a3c4ed23 6385@item @emph{Standard}:
f40b44c0 6386Fortran 95 and later
a3c4ed23 6387
6388@item @emph{Class}:
6389Elemental function
6390
6391@item @emph{Syntax}:
22f55265 6392@code{RESULT = IBSET(I, POS)}
6393
a3c4ed23 6394@item @emph{Arguments}:
aee612a9 6395@multitable @columnfractions .15 .70
e06f8026 6396@item @var{I} @tab The type shall be @code{INTEGER}.
6397@item @var{POS} @tab The type shall be @code{INTEGER}.
22f55265 6398@end multitable
6399
a3c4ed23 6400@item @emph{Return value}:
e06f8026 6401The return value is of type @code{INTEGER} and of the same kind as
22f55265 6402@var{I}.
a3c4ed23 6403
6404@item @emph{See also}:
0eb92d52 6405@ref{IBCLR}, @ref{IBITS}, @ref{IAND}, @ref{IOR}, @ref{IEOR}, @ref{MVBITS}
6406
a3c4ed23 6407@end table
6408
6409
6410
6411@node ICHAR
6412@section @code{ICHAR} --- Character-to-integer conversion function
a1149005 6413@fnindex ICHAR
6414@cindex conversion, to integer
a3c4ed23 6415
6416@table @asis
6417@item @emph{Description}:
6418@code{ICHAR(C)} returns the code for the character in the first character
6419position of @code{C} in the system's native character set.
6420The correspondence between characters and their codes is not necessarily
6421the same across different GNU Fortran implementations.
6422
6423@item @emph{Standard}:
5f7aa0fe 6424Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
a3c4ed23 6425
6426@item @emph{Class}:
6427Elemental function
6428
6429@item @emph{Syntax}:
7fe55cc9 6430@code{RESULT = ICHAR(C [, KIND])}
a3c4ed23 6431
338c728c 6432@item @emph{Arguments}:
aee612a9 6433@multitable @columnfractions .15 .70
7fe55cc9 6434@item @var{C} @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
6435@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
c24c5fac 6436expression indicating the kind parameter of the result.
572d7b7f 6437@end multitable
6438
6439@item @emph{Return value}:
7fe55cc9 6440The return value is of type @code{INTEGER} and of kind @var{KIND}. If
6441@var{KIND} is absent, the return value is of default integer kind.
572d7b7f 6442
6443@item @emph{Example}:
6444@smallexample
6445program test_ichar
6446 integer i
6447 i = ichar(' ')
6448end program test_ichar
6449@end smallexample
6450
7d74ce87 6451@item @emph{Specific names}:
6452@multitable @columnfractions .20 .20 .20 .25
6453@item Name @tab Argument @tab Return type @tab Standard
6454@item @code{ICHAR(C)} @tab @code{CHARACTER C} @tab @code{INTEGER(4)} @tab Fortran 77 and later
6455@end multitable
6456
572d7b7f 6457@item @emph{Note}:
e95fe2fe 6458No intrinsic exists to convert between a numeric value and a formatted
6459character string representation -- for instance, given the
6460@code{CHARACTER} value @code{'154'}, obtaining an @code{INTEGER} or
6461@code{REAL} value with the value 154, or vice versa. Instead, this
6462functionality is provided by internal-file I/O, as in the following
572d7b7f 6463example:
6464@smallexample
6465program read_val
6466 integer value
e95fe2fe 6467 character(len=10) string, string2
572d7b7f 6468 string = '154'
e95fe2fe 6469
6470 ! Convert a string to a numeric value
572d7b7f 6471 read (string,'(I10)') value
6472 print *, value
e95fe2fe 6473
6474 ! Convert a value to a formatted string
6475 write (string2,'(I10)') value
6476 print *, string2
572d7b7f 6477end program read_val
6478@end smallexample
c5cb0f03 6479
6480@item @emph{See also}:
6481@ref{ACHAR}, @ref{CHAR}, @ref{IACHAR}
6482
572d7b7f 6483@end table
6484
c5cb0f03 6485
6486
a8a6baf6 6487@node IDATE
6488@section @code{IDATE} --- Get current local time subroutine (day/month/year)
a1149005 6489@fnindex IDATE
6490@cindex date, current
6491@cindex current date
a8a6baf6 6492
6493@table @asis
6494@item @emph{Description}:
2cd8ef8b 6495@code{IDATE(VALUES)} Fills @var{VALUES} with the numerical values at the
a8a6baf6 6496current local time. The day (in the range 1-31), month (in the range 1-12),
2cd8ef8b 6497and year appear in elements 1, 2, and 3 of @var{VALUES}, respectively.
a8a6baf6 6498The year has four significant digits.
6499
a3c4ed23 6500@item @emph{Standard}:
6501GNU extension
a8a6baf6 6502
6503@item @emph{Class}:
a3c4ed23 6504Subroutine
a8a6baf6 6505
6506@item @emph{Syntax}:
cf37b737 6507@code{CALL IDATE(VALUES)}
a8a6baf6 6508
6509@item @emph{Arguments}:
aee612a9 6510@multitable @columnfractions .15 .70
cf37b737 6511@item @var{VALUES} @tab The type shall be @code{INTEGER, DIMENSION(3)} and
a8a6baf6 6512the kind shall be the default integer kind.
6513@end multitable
6514
6515@item @emph{Return value}:
57b9ac90 6516Does not return anything.
a8a6baf6 6517
6518@item @emph{Example}:
6519@smallexample
6520program test_idate
6521 integer, dimension(3) :: tarray
6522 call idate(tarray)
6523 print *, tarray(1)
6524 print *, tarray(2)
6525 print *, tarray(3)
6526end program test_idate
6527@end smallexample
6528@end table
572d7b7f 6529
6530
a3c4ed23 6531
6532@node IEOR
6533@section @code{IEOR} --- Bitwise logical exclusive or
a1149005 6534@fnindex IEOR
6535@cindex bitwise logical exclusive or
6536@cindex logical exclusive or, bitwise
a3c4ed23 6537
a3c4ed23 6538@table @asis
6539@item @emph{Description}:
5f7aa0fe 6540@code{IEOR} returns the bitwise Boolean exclusive-OR of @var{I} and
22f55265 6541@var{J}.
6542
a3c4ed23 6543@item @emph{Standard}:
f40b44c0 6544Fortran 95 and later
a3c4ed23 6545
6546@item @emph{Class}:
6547Elemental function
6548
6549@item @emph{Syntax}:
22f55265 6550@code{RESULT = IEOR(I, J)}
6551
a3c4ed23 6552@item @emph{Arguments}:
aee612a9 6553@multitable @columnfractions .15 .70
e06f8026 6554@item @var{I} @tab The type shall be @code{INTEGER}.
6555@item @var{J} @tab The type shall be @code{INTEGER}, of the same
22f55265 6556kind as @var{I}. (As a GNU extension, different kinds are also
6557permitted.)
6558@end multitable
6559
a3c4ed23 6560@item @emph{Return value}:
e06f8026 6561The return type is @code{INTEGER}, of the same kind as the
22f55265 6562arguments. (If the argument kinds differ, it is of the same kind as
6563the larger argument.)
a3c4ed23 6564
6565@item @emph{See also}:
0eb92d52 6566@ref{IOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
a3c4ed23 6567@end table
6568
6569
6570
a3c4ed23 6571@node IERRNO
6572@section @code{IERRNO} --- Get the last system error number
a1149005 6573@fnindex IERRNO
6574@cindex system, error handling
a3c4ed23 6575
6576@table @asis
6577@item @emph{Description}:
e8c1bbb4 6578Returns the last system error number, as given by the C @code{errno}
6579variable.
22f55265 6580
a3c4ed23 6581@item @emph{Standard}:
6582GNU extension
6583
6584@item @emph{Class}:
138b8aca 6585Function
22f55265 6586
a3c4ed23 6587@item @emph{Syntax}:
4eb41f08 6588@code{RESULT = IERRNO()}
22f55265 6589
a3c4ed23 6590@item @emph{Arguments}:
22f55265 6591None.
6592
a3c4ed23 6593@item @emph{Return value}:
22f55265 6594The return value is of type @code{INTEGER} and of the default integer
6595kind.
a3c4ed23 6596
6597@item @emph{See also}:
6598@ref{PERROR}
6599@end table
6600
6601
6602
9028d57d 6603@node IMAGE_INDEX
6604@section @code{IMAGE_INDEX} --- Function that converts a cosubscript to an image index
6605@fnindex IMAGE_INDEX
12786727 6606@cindex coarray, @code{IMAGE_INDEX}
9028d57d 6607@cindex images, cosubscript to image index conversion
6608
6609@table @asis
6610@item @emph{Description}:
6611Returns the image index belonging to a cosubscript.
6612
6613@item @emph{Standard}:
6614Fortran 2008 and later
6615
6616@item @emph{Class}:
6617Inquiry function.
6618
6619@item @emph{Syntax}:
6620@code{RESULT = IMAGE_INDEX(COARRAY, SUB)}
6621
6622@item @emph{Arguments}: None.
6623@multitable @columnfractions .15 .70
6624@item @var{COARRAY} @tab Coarray of any type.
6625@item @var{SUB} @tab default integer rank-1 array of a size equal to
6626the corank of @var{COARRAY}.
6627@end multitable
6628
6629
6630@item @emph{Return value}:
6631Scalar default integer with the value of the image index which corresponds
6632to the cosubscripts. For invalid cosubscripts the result is zero.
6633
6634@item @emph{Example}:
6635@smallexample
6636INTEGER :: array[2,-1:4,8,*]
6637! Writes 28 (or 0 if there are fewer than 28 images)
6638WRITE (*,*) IMAGE_INDEX (array, [2,0,3,1])
6639@end smallexample
6640
6641@item @emph{See also}:
6642@ref{THIS_IMAGE}, @ref{NUM_IMAGES}
6643@end table
6644
6645
6646
70dabb1d 6647@node INDEX intrinsic
a3c4ed23 6648@section @code{INDEX} --- Position of a substring within a string
a1149005 6649@fnindex INDEX
6650@cindex substring position
6651@cindex string, find substring
a3c4ed23 6652
6653@table @asis
6654@item @emph{Description}:
22f55265 6655Returns the position of the start of the first occurrence of string
6656@var{SUBSTRING} as a substring in @var{STRING}, counting from one. If
6657@var{SUBSTRING} is not present in @var{STRING}, zero is returned. If
6658the @var{BACK} argument is present and true, the return value is the
6659start of the last occurrence rather than the first.
6660
a3c4ed23 6661@item @emph{Standard}:
f40b44c0 6662Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later
a3c4ed23 6663
6664@item @emph{Class}:
6665Elemental function
6666
6667@item @emph{Syntax}:
7fe55cc9 6668@code{RESULT = INDEX(STRING, SUBSTRING [, BACK [, KIND]])}
22f55265 6669
a3c4ed23 6670@item @emph{Arguments}:
aee612a9 6671@multitable @columnfractions .15 .70
e06f8026 6672@item @var{STRING} @tab Shall be a scalar @code{CHARACTER}, with
22f55265 6673@code{INTENT(IN)}
e06f8026 6674@item @var{SUBSTRING} @tab Shall be a scalar @code{CHARACTER}, with
22f55265 6675@code{INTENT(IN)}
e06f8026 6676@item @var{BACK} @tab (Optional) Shall be a scalar @code{LOGICAL}, with
22f55265 6677@code{INTENT(IN)}
7fe55cc9 6678@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
c24c5fac 6679expression indicating the kind parameter of the result.
22f55265 6680@end multitable
6681
a3c4ed23 6682@item @emph{Return value}:
7fe55cc9 6683The return value is of type @code{INTEGER} and of kind @var{KIND}. If
6684@var{KIND} is absent, the return value is of default integer kind.
22f55265 6685
7d74ce87 6686@item @emph{Specific names}:
6687@multitable @columnfractions .20 .20 .20 .25
6688@item Name @tab Argument @tab Return type @tab Standard
6689@item @code{INDEX(STRING, SUBSTRING)} @tab @code{CHARACTER} @tab @code{INTEGER(4)} @tab Fortran 77 and later
6690@end multitable
6691
a3c4ed23 6692@item @emph{See also}:
8873d8a6 6693@ref{SCAN}, @ref{VERIFY}
a3c4ed23 6694@end table
6695
6696
6697
a3c4ed23 6698@node INT
6699@section @code{INT} --- Convert to integer type
a1149005 6700@fnindex INT
6701@fnindex IFIX
6702@fnindex IDINT
6703@cindex conversion, to integer
a3c4ed23 6704
6705@table @asis
6706@item @emph{Description}:
6707Convert to integer type
6708
6709@item @emph{Standard}:
f40b44c0 6710Fortran 77 and later
a3c4ed23 6711
6712@item @emph{Class}:
6713Elemental function
6714
6715@item @emph{Syntax}:
fe97b755 6716@code{RESULT = INT(A [, KIND))}
a3c4ed23 6717
6718@item @emph{Arguments}:
aee612a9 6719@multitable @columnfractions .15 .70
e06f8026 6720@item @var{A} @tab Shall be of type @code{INTEGER},
c24c5fac 6721@code{REAL}, or @code{COMPLEX}.
e06f8026 6722@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
c24c5fac 6723expression indicating the kind parameter of the result.
a3c4ed23 6724@end multitable
6725
6726@item @emph{Return value}:
e06f8026 6727These functions return a @code{INTEGER} variable or array under
a3c4ed23 6728the following rules:
6729
6730@table @asis
6731@item (A)
e06f8026 6732If @var{A} is of type @code{INTEGER}, @code{INT(A) = A}
a3c4ed23 6733@item (B)
e06f8026 6734If @var{A} is of type @code{REAL} and @math{|A| < 1}, @code{INT(A)} equals @code{0}.
fe97b755 6735If @math{|A| \geq 1}, then @code{INT(A)} equals the largest integer that does not exceed
6736the range of @var{A} and whose sign is the same as the sign of @var{A}.
a3c4ed23 6737@item (C)
e06f8026 6738If @var{A} is of type @code{COMPLEX}, rule B is applied to the real part of @var{A}.
a3c4ed23 6739@end table
6740
6741@item @emph{Example}:
6742@smallexample
6743program test_int
6744 integer :: i = 42
6745 complex :: z = (-3.7, 1.0)
6746 print *, int(i)
6747 print *, int(z), int(z,8)
6748end program
6749@end smallexample
6750
6751@item @emph{Specific names}:
aee612a9 6752@multitable @columnfractions .20 .20 .20 .25
7d74ce87 6753@item Name @tab Argument @tab Return type @tab Standard
6754@item @code{INT(A)} @tab @code{REAL(4) A} @tab @code{INTEGER} @tab Fortran 77 and later
6755@item @code{IFIX(A)} @tab @code{REAL(4) A} @tab @code{INTEGER} @tab Fortran 77 and later
6756@item @code{IDINT(A)} @tab @code{REAL(8) A} @tab @code{INTEGER} @tab Fortran 77 and later
a3c4ed23 6757@end multitable
6758
a3c4ed23 6759@end table
6760
6761
fe97b755 6762@node INT2
6763@section @code{INT2} --- Convert to 16-bit integer type
a1149005 6764@fnindex INT2
6765@fnindex SHORT
6766@cindex conversion, to integer
fe97b755 6767
6768@table @asis
6769@item @emph{Description}:
6770Convert to a @code{KIND=2} integer type. This is equivalent to the
6771standard @code{INT} intrinsic with an optional argument of
6772@code{KIND=2}, and is only included for backwards compatibility.
6773
6774The @code{SHORT} intrinsic is equivalent to @code{INT2}.
6775
6776@item @emph{Standard}:
f40b44c0 6777GNU extension
fe97b755 6778
6779@item @emph{Class}:
6780Elemental function
6781
6782@item @emph{Syntax}:
6783@code{RESULT = INT2(A)}
6784
6785@item @emph{Arguments}:
6786@multitable @columnfractions .15 .70
e06f8026 6787@item @var{A} @tab Shall be of type @code{INTEGER},
c24c5fac 6788@code{REAL}, or @code{COMPLEX}.
fe97b755 6789@end multitable
6790
6791@item @emph{Return value}:
6792The return value is a @code{INTEGER(2)} variable.
6793
8873d8a6 6794@item @emph{See also}:
fe97b755 6795@ref{INT}, @ref{INT8}, @ref{LONG}
6796@end table
6797
6798
6799
6800@node INT8
6801@section @code{INT8} --- Convert to 64-bit integer type
a1149005 6802@fnindex INT8
6803@cindex conversion, to integer
fe97b755 6804
6805@table @asis
6806@item @emph{Description}:
6807Convert to a @code{KIND=8} integer type. This is equivalent to the
6808standard @code{INT} intrinsic with an optional argument of
6809@code{KIND=8}, and is only included for backwards compatibility.
6810
6811@item @emph{Standard}:
f40b44c0 6812GNU extension
fe97b755 6813
6814@item @emph{Class}:
6815Elemental function
6816
6817@item @emph{Syntax}:
6818@code{RESULT = INT8(A)}
6819
6820@item @emph{Arguments}:
6821@multitable @columnfractions .15 .70
e06f8026 6822@item @var{A} @tab Shall be of type @code{INTEGER},
c24c5fac 6823@code{REAL}, or @code{COMPLEX}.
fe97b755 6824@end multitable
6825
6826@item @emph{Return value}:
6827The return value is a @code{INTEGER(8)} variable.
6828
8873d8a6 6829@item @emph{See also}:
fe97b755 6830@ref{INT}, @ref{INT2}, @ref{LONG}
6831@end table
6832
6833
6834
a3c4ed23 6835@node IOR
6836@section @code{IOR} --- Bitwise logical or
a1149005 6837@fnindex IOR
6838@cindex bitwise logical or
6839@cindex logical or, bitwise
a3c4ed23 6840
a3c4ed23 6841@table @asis
6842@item @emph{Description}:
5f7aa0fe 6843@code{IOR} returns the bitwise Boolean inclusive-OR of @var{I} and
22f55265 6844@var{J}.
6845
a3c4ed23 6846@item @emph{Standard}:
f40b44c0 6847Fortran 95 and later
a3c4ed23 6848
6849@item @emph{Class}:
6850Elemental function
6851
6852@item @emph{Syntax}:
980dd81f 6853@code{RESULT = IOR(I, J)}
22f55265 6854
a3c4ed23 6855@item @emph{Arguments}:
aee612a9 6856@multitable @columnfractions .15 .70
e06f8026 6857@item @var{I} @tab The type shall be @code{INTEGER}.
6858@item @var{J} @tab The type shall be @code{INTEGER}, of the same
22f55265 6859kind as @var{I}. (As a GNU extension, different kinds are also
6860permitted.)
6861@end multitable
6862
a3c4ed23 6863@item @emph{Return value}:
e06f8026 6864The return type is @code{INTEGER}, of the same kind as the
22f55265 6865arguments. (If the argument kinds differ, it is of the same kind as
6866the larger argument.)
a3c4ed23 6867
6868@item @emph{See also}:
0eb92d52 6869@ref{IEOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
a3c4ed23 6870@end table
6871
6872
6873
9028d57d 6874@node IPARITY
6875@section @code{IPARITY} --- Bitwise XOR of array elements
6876@fnindex IPARITY
6877@cindex array, parity
6878@cindex array, XOR
6879@cindex bits, XOR of array elements
6880
6881@table @asis
6882@item @emph{Description}:
6883Reduces with bitwise XOR (exclusive or) the elements of @var{ARRAY} along
6884dimension @var{DIM} if the corresponding element in @var{MASK} is @code{TRUE}.
6885
6886@item @emph{Standard}:
6887Fortran 2008 and later
6888
6889@item @emph{Class}:
6890Transformational function
6891
6892@item @emph{Syntax}:
6893@multitable @columnfractions .80
6894@item @code{RESULT = IPARITY(ARRAY[, MASK])}
6895@item @code{RESULT = IPARITY(ARRAY, DIM[, MASK])}
6896@end multitable
6897
6898@item @emph{Arguments}:
6899@multitable @columnfractions .15 .70
6900@item @var{ARRAY} @tab Shall be an array of type @code{INTEGER}
6901@item @var{DIM} @tab (Optional) shall be a scalar of type
6902@code{INTEGER} with a value in the range from 1 to n, where n
6903equals the rank of @var{ARRAY}.
6904@item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL}
6905and either be a scalar or an array of the same shape as @var{ARRAY}.
6906@end multitable
6907
6908@item @emph{Return value}:
6909The result is of the same type as @var{ARRAY}.
6910
6911If @var{DIM} is absent, a scalar with the bitwise XOR of all elements in
6912@var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals
6913the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with
6914dimension @var{DIM} dropped is returned.
6915
6916@item @emph{Example}:
6917@smallexample
6918PROGRAM test_iparity
6919 INTEGER(1) :: a(2)
6920
6921 a(1) = b'00100100'
fd77a350 6922 a(2) = b'01101010'
9028d57d 6923
fd77a350 6924 ! prints 01001110
9028d57d 6925 PRINT '(b8.8)', IPARITY(a)
6926END PROGRAM
6927@end smallexample
6928
6929@item @emph{See also}:
6930@ref{IANY}, @ref{IALL}, @ref{IEOR}, @ref{PARITY}
6931@end table
6932
6933
6934
572d7b7f 6935@node IRAND
6936@section @code{IRAND} --- Integer pseudo-random number
a1149005 6937@fnindex IRAND
6938@cindex random number generation
572d7b7f 6939
6940@table @asis
6941@item @emph{Description}:
6942@code{IRAND(FLAG)} returns a pseudo-random number from a uniform
6943distribution between 0 and a system-dependent limit (which is in most
6944cases 2147483647). If @var{FLAG} is 0, the next number
6945in the current sequence is returned; if @var{FLAG} is 1, the generator
6946is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
6947it is used as a new seed with @code{SRAND}.
6948
855b3d32 6949This intrinsic routine is provided for backwards compatibility with
6950GNU Fortran 77. It implements a simple modulo generator as provided
6951by @command{g77}. For new code, one should consider the use of
6952@ref{RANDOM_NUMBER} as it implements a superior algorithm.
6953
a3c4ed23 6954@item @emph{Standard}:
6955GNU extension
572d7b7f 6956
6957@item @emph{Class}:
138b8aca 6958Function
572d7b7f 6959
6960@item @emph{Syntax}:
cf37b737 6961@code{RESULT = IRAND(I)}
572d7b7f 6962
6963@item @emph{Arguments}:
aee612a9 6964@multitable @columnfractions .15 .70
cf37b737 6965@item @var{I} @tab Shall be a scalar @code{INTEGER} of kind 4.
572d7b7f 6966@end multitable
6967
6968@item @emph{Return value}:
6969The return value is of @code{INTEGER(kind=4)} type.
6970
6971@item @emph{Example}:
6972@smallexample
6973program test_irand
6974 integer,parameter :: seed = 86456
6975
6976 call srand(seed)
6977 print *, irand(), irand(), irand(), irand()
6978 print *, irand(seed), irand(), irand(), irand()
6979end program test_irand
6980@end smallexample
6981
6982@end table
6983
a3c4ed23 6984
6985
52ed1096 6986@node IS_IOSTAT_END
6987@section @code{IS_IOSTAT_END} --- Test for end-of-file value
6988@fnindex IS_IOSTAT_END
12786727 6989@cindex @code{IOSTAT}, end of file
52ed1096 6990
6991@table @asis
6992@item @emph{Description}:
6993@code{IS_IOSTAT_END} tests whether an variable has the value of the I/O
6994status ``end of file''. The function is equivalent to comparing the variable
6995with the @code{IOSTAT_END} parameter of the intrinsic module
6996@code{ISO_FORTRAN_ENV}.
6997
6998@item @emph{Standard}:
ff4425cf 6999Fortran 2003 and later
52ed1096 7000
7001@item @emph{Class}:
7002Elemental function
7003
7004@item @emph{Syntax}:
7005@code{RESULT = IS_IOSTAT_END(I)}
7006
7007@item @emph{Arguments}:
7008@multitable @columnfractions .15 .70
7009@item @var{I} @tab Shall be of the type @code{INTEGER}.
7010@end multitable
7011
7012@item @emph{Return value}:
7013Returns a @code{LOGICAL} of the default kind, which @code{.TRUE.} if
7014@var{I} has the value which indicates an end of file condition for
12786727 7015@code{IOSTAT=} specifiers, and is @code{.FALSE.} otherwise.
52ed1096 7016
7017@item @emph{Example}:
7018@smallexample
7019PROGRAM iostat
7020 IMPLICIT NONE
7021 INTEGER :: stat, i
7022 OPEN(88, FILE='test.dat')
7023 READ(88, *, IOSTAT=stat) i
7024 IF(IS_IOSTAT_END(stat)) STOP 'END OF FILE'
7025END PROGRAM
7026@end smallexample
7027@end table
7028
7029
7030
7031@node IS_IOSTAT_EOR
7032@section @code{IS_IOSTAT_EOR} --- Test for end-of-record value
7033@fnindex IS_IOSTAT_EOR
12786727 7034@cindex @code{IOSTAT}, end of record
52ed1096 7035
7036@table @asis
7037@item @emph{Description}:
7038@code{IS_IOSTAT_EOR} tests whether an variable has the value of the I/O
7039status ``end of record''. The function is equivalent to comparing the
7040variable with the @code{IOSTAT_EOR} parameter of the intrinsic module
7041@code{ISO_FORTRAN_ENV}.
7042
7043@item @emph{Standard}:
ff4425cf 7044Fortran 2003 and later
52ed1096 7045
7046@item @emph{Class}:
7047Elemental function
7048
7049@item @emph{Syntax}:
7050@code{RESULT = IS_IOSTAT_EOR(I)}
7051
7052@item @emph{Arguments}:
7053@multitable @columnfractions .15 .70
7054@item @var{I} @tab Shall be of the type @code{INTEGER}.
7055@end multitable
7056
7057@item @emph{Return value}:
7058Returns a @code{LOGICAL} of the default kind, which @code{.TRUE.} if
7059@var{I} has the value which indicates an end of file condition for
12786727 7060@code{IOSTAT=} specifiers, and is @code{.FALSE.} otherwise.
52ed1096 7061
7062@item @emph{Example}:
7063@smallexample
7064PROGRAM iostat
7065 IMPLICIT NONE
7066 INTEGER :: stat, i(50)
7067 OPEN(88, FILE='test.dat', FORM='UNFORMATTED')
7068 READ(88, IOSTAT=stat) i
7069 IF(IS_IOSTAT_EOR(stat)) STOP 'END OF RECORD'
7070END PROGRAM
7071@end smallexample
7072@end table
7073
7074
7075
475c7d78 7076@node ISATTY
7077@section @code{ISATTY} --- Whether a unit is a terminal device.
a1149005 7078@fnindex ISATTY
7079@cindex system, terminal
475c7d78 7080
7081@table @asis
7082@item @emph{Description}:
7083Determine whether a unit is connected to a terminal device.
7084
7085@item @emph{Standard}:
f40b44c0 7086GNU extension
475c7d78 7087
7088@item @emph{Class}:
138b8aca 7089Function
475c7d78 7090
7091@item @emph{Syntax}:
7092@code{RESULT = ISATTY(UNIT)}
7093
7094@item @emph{Arguments}:
7095@multitable @columnfractions .15 .70
e06f8026 7096@item @var{UNIT} @tab Shall be a scalar @code{INTEGER}.
475c7d78 7097@end multitable
7098
7099@item @emph{Return value}:
7100Returns @code{.TRUE.} if the @var{UNIT} is connected to a terminal
7101device, @code{.FALSE.} otherwise.
7102
7103@item @emph{Example}:
7104@smallexample
7105PROGRAM test_isatty
7106 INTEGER(kind=1) :: unit
7107 DO unit = 1, 10
7108 write(*,*) isatty(unit=unit)
7109 END DO
7110END PROGRAM
7111@end smallexample
7112@item @emph{See also}:
7113@ref{TTYNAM}
7114@end table
7115
7116
7117
a3c4ed23 7118@node ISHFT
7119@section @code{ISHFT} --- Shift bits
a1149005 7120@fnindex ISHFT
7121@cindex bits, shift
a3c4ed23 7122
a3c4ed23 7123@table @asis
7124@item @emph{Description}:
22f55265 7125@code{ISHFT} returns a value corresponding to @var{I} with all of the
7126bits shifted @var{SHIFT} places. A value of @var{SHIFT} greater than
7127zero corresponds to a left shift, a value of zero corresponds to no
7128shift, and a value less than zero corresponds to a right shift. If the
7129absolute value of @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the
7130value is undefined. Bits shifted out from the left end or right end are
7131lost; zeros are shifted in from the opposite end.
7132
a3c4ed23 7133@item @emph{Standard}:
f40b44c0 7134Fortran 95 and later
a3c4ed23 7135
7136@item @emph{Class}:
7137Elemental function
7138
7139@item @emph{Syntax}:
22f55265 7140@code{RESULT = ISHFT(I, SHIFT)}
7141
a3c4ed23 7142@item @emph{Arguments}:
aee612a9 7143@multitable @columnfractions .15 .70
e06f8026 7144@item @var{I} @tab The type shall be @code{INTEGER}.
7145@item @var{SHIFT} @tab The type shall be @code{INTEGER}.
22f55265 7146@end multitable
7147
a3c4ed23 7148@item @emph{Return value}:
e06f8026 7149The return value is of type @code{INTEGER} and of the same kind as
22f55265 7150@var{I}.
a3c4ed23 7151
7152@item @emph{See also}:
7153@ref{ISHFTC}
7154@end table
7155
7156
7157
a3c4ed23 7158@node ISHFTC
7159@section @code{ISHFTC} --- Shift bits circularly
a1149005 7160@fnindex ISHFTC
7161@cindex bits, shift circular
a3c4ed23 7162
a3c4ed23 7163@table @asis
7164@item @emph{Description}:
22f55265 7165@code{ISHFTC} returns a value corresponding to @var{I} with the
7166rightmost @var{SIZE} bits shifted circularly @var{SHIFT} places; that
7167is, bits shifted out one end are shifted into the opposite end. A value
7168of @var{SHIFT} greater than zero corresponds to a left shift, a value of
7169zero corresponds to no shift, and a value less than zero corresponds to
7170a right shift. The absolute value of @var{SHIFT} must be less than
7171@var{SIZE}. If the @var{SIZE} argument is omitted, it is taken to be
7172equivalent to @code{BIT_SIZE(I)}.
7173
a3c4ed23 7174@item @emph{Standard}:
f40b44c0 7175Fortran 95 and later
a3c4ed23 7176
7177@item @emph{Class}:
7178Elemental function
7179
7180@item @emph{Syntax}:
22f55265 7181@code{RESULT = ISHFTC(I, SHIFT [, SIZE])}
7182
a3c4ed23 7183@item @emph{Arguments}:
aee612a9 7184@multitable @columnfractions .15 .70
e06f8026 7185@item @var{I} @tab The type shall be @code{INTEGER}.
7186@item @var{SHIFT} @tab The type shall be @code{INTEGER}.
7187@item @var{SIZE} @tab (Optional) The type shall be @code{INTEGER};
22f55265 7188the value must be greater than zero and less than or equal to
7189@code{BIT_SIZE(I)}.
7190@end multitable
7191
a3c4ed23 7192@item @emph{Return value}:
e06f8026 7193The return value is of type @code{INTEGER} and of the same kind as
22f55265 7194@var{I}.
a3c4ed23 7195
7196@item @emph{See also}:
7197@ref{ISHFT}
7198@end table
7199
7200
7201
4e549567 7202@node ISNAN
7203@section @code{ISNAN} --- Test for a NaN
7204@fnindex ISNAN
7205@cindex IEEE, ISNAN
7206
7207@table @asis
7208@item @emph{Description}:
7209@code{ISNAN} tests whether a floating-point value is an IEEE
7210Not-a-Number (NaN).
7211@item @emph{Standard}:
7212GNU extension
7213
7214@item @emph{Class}:
7215Elemental function
7216
7217@item @emph{Syntax}:
7218@code{ISNAN(X)}
7219
7220@item @emph{Arguments}:
7221@multitable @columnfractions .15 .70
7222@item @var{X} @tab Variable of the type @code{REAL}.
7223
7224@end multitable
7225
7226@item @emph{Return value}:
7227Returns a default-kind @code{LOGICAL}. The returned value is @code{TRUE}
7228if @var{X} is a NaN and @code{FALSE} otherwise.
7229
7230@item @emph{Example}:
7231@smallexample
7232program test_nan
7233 implicit none
7234 real :: x
7235 x = -1.0
7236 x = sqrt(x)
7237 if (isnan(x)) stop '"x" is a NaN'
7238end program test_nan
7239@end smallexample
7240@end table
7241
7242
7243
a8a6baf6 7244@node ITIME
7245@section @code{ITIME} --- Get current local time subroutine (hour/minutes/seconds)
a1149005 7246@fnindex ITIME
7247@cindex time, current
7248@cindex current time
a8a6baf6 7249
7250@table @asis
7251@item @emph{Description}:
cf37b737 7252@code{IDATE(VALUES)} Fills @var{VALUES} with the numerical values at the
a8a6baf6 7253current local time. The hour (in the range 1-24), minute (in the range 1-60),
cf37b737 7254and seconds (in the range 1-60) appear in elements 1, 2, and 3 of @var{VALUES},
a8a6baf6 7255respectively.
7256
a3c4ed23 7257@item @emph{Standard}:
7258GNU extension
a8a6baf6 7259
7260@item @emph{Class}:
a3c4ed23 7261Subroutine
a8a6baf6 7262
7263@item @emph{Syntax}:
cf37b737 7264@code{CALL ITIME(VALUES)}
a8a6baf6 7265
7266@item @emph{Arguments}:
aee612a9 7267@multitable @columnfractions .15 .70
cf37b737 7268@item @var{VALUES} @tab The type shall be @code{INTEGER, DIMENSION(3)}
a8a6baf6 7269and the kind shall be the default integer kind.
7270@end multitable
7271
7272@item @emph{Return value}:
57b9ac90 7273Does not return anything.
a8a6baf6 7274
7275
7276@item @emph{Example}:
7277@smallexample
7278program test_itime
7279 integer, dimension(3) :: tarray
7280 call itime(tarray)
7281 print *, tarray(1)
7282 print *, tarray(2)
7283 print *, tarray(3)
7284end program test_itime
7285@end smallexample
7286@end table
572d7b7f 7287
7288
a3c4ed23 7289
7290@node KILL
7291@section @code{KILL} --- Send a signal to a process
a1149005 7292@fnindex KILL
572d7b7f 7293
7294@table @asis
7295@item @emph{Description}:
a3c4ed23 7296@item @emph{Standard}:
22f55265 7297Sends the signal specified by @var{SIGNAL} to the process @var{PID}.
7298See @code{kill(2)}.
572d7b7f 7299
138b8aca 7300This intrinsic is provided in both subroutine and function forms; however,
7301only one form can be used in any given program unit.
7302
572d7b7f 7303@item @emph{Class}:
138b8aca 7304Subroutine, function
572d7b7f 7305
7306@item @emph{Syntax}:
6c07e6d8 7307@multitable @columnfractions .80
7308@item @code{CALL KILL(C, VALUE [, STATUS])}
7309@item @code{STATUS = KILL(C, VALUE)}
7310@end multitable
22f55265 7311
572d7b7f 7312@item @emph{Arguments}:
aee612a9 7313@multitable @columnfractions .15 .70
cf37b737 7314@item @var{C} @tab Shall be a scalar @code{INTEGER}, with
22f55265 7315@code{INTENT(IN)}
cf37b737 7316@item @var{VALUE} @tab Shall be a scalar @code{INTEGER}, with
22f55265 7317@code{INTENT(IN)}
7318@item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)} or
c24c5fac 7319@code{INTEGER(8)}. Returns 0 on success, or a system-specific error code
7320otherwise.
22f55265 7321@end multitable
a3c4ed23 7322
7323@item @emph{See also}:
7324@ref{ABORT}, @ref{EXIT}
7325@end table
7326
7327
7328
7329@node KIND
7330@section @code{KIND} --- Kind of an entity
a1149005 7331@fnindex KIND
7332@cindex kind
a3c4ed23 7333
7334@table @asis
7335@item @emph{Description}:
7336@code{KIND(X)} returns the kind value of the entity @var{X}.
7337
7338@item @emph{Standard}:
f40b44c0 7339Fortran 95 and later
a3c4ed23 7340
7341@item @emph{Class}:
7342Inquiry function
7343
7344@item @emph{Syntax}:
7345@code{K = KIND(X)}
7346
7347@item @emph{Arguments}:
aee612a9 7348@multitable @columnfractions .15 .70
a3c4ed23 7349@item @var{X} @tab Shall be of type @code{LOGICAL}, @code{INTEGER},
7350@code{REAL}, @code{COMPLEX} or @code{CHARACTER}.
7351@end multitable
7352
7353@item @emph{Return value}:
7354The return value is a scalar of type @code{INTEGER} and of the default
7355integer kind.
572d7b7f 7356
7357@item @emph{Example}:
7358@smallexample
7359program test_kind
7360 integer,parameter :: kc = kind(' ')
7361 integer,parameter :: kl = kind(.true.)
7362
7363 print *, "The default character kind is ", kc
7364 print *, "The default logical kind is ", kl
7365end program test_kind
7366@end smallexample
7367
7368@end table
7369
7370
7371
a3c4ed23 7372@node LBOUND
7373@section @code{LBOUND} --- Lower dimension bounds of an array
a1149005 7374@fnindex LBOUND
7375@cindex array, lower bound
a3c4ed23 7376
7377@table @asis
7378@item @emph{Description}:
b620ae12 7379Returns the lower bounds of an array, or a single lower bound
7380along the @var{DIM} dimension.
a3c4ed23 7381@item @emph{Standard}:
f40b44c0 7382Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
a3c4ed23 7383
7384@item @emph{Class}:
7385Inquiry function
7386
7387@item @emph{Syntax}:
7fe55cc9 7388@code{RESULT = LBOUND(ARRAY [, DIM [, KIND]])}
b620ae12 7389
a3c4ed23 7390@item @emph{Arguments}:
aee612a9 7391@multitable @columnfractions .15 .70
b620ae12 7392@item @var{ARRAY} @tab Shall be an array, of any type.
e06f8026 7393@item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
7fe55cc9 7394@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
c24c5fac 7395expression indicating the kind parameter of the result.
b620ae12 7396@end multitable
7397
a3c4ed23 7398@item @emph{Return value}:
7fe55cc9 7399The return value is of type @code{INTEGER} and of kind @var{KIND}. If
7400@var{KIND} is absent, the return value is of default integer kind.
b620ae12 7401If @var{DIM} is absent, the result is an array of the lower bounds of
7402@var{ARRAY}. If @var{DIM} is present, the result is a scalar
7403corresponding to the lower bound of the array along that dimension. If
7404@var{ARRAY} is an expression rather than a whole array or array
7405structure component, or if it has a zero extent along the relevant
7406dimension, the lower bound is taken to be 1.
7407
a3c4ed23 7408@item @emph{See also}:
a250d560 7409@ref{UBOUND}, @ref{LCOBOUND}
7410@end table
7411
7412
7413
7414@node LCOBOUND
7415@section @code{LCOBOUND} --- Lower codimension bounds of an array
7416@fnindex LCOBOUND
7417@cindex coarray, lower bound
7418
7419@table @asis
7420@item @emph{Description}:
7421Returns the lower bounds of a coarray, or a single lower cobound
7422along the @var{DIM} codimension.
7423@item @emph{Standard}:
7424Fortran 2008 and later
7425
7426@item @emph{Class}:
7427Inquiry function
7428
7429@item @emph{Syntax}:
7430@code{RESULT = LCOBOUND(COARRAY [, DIM [, KIND]])}
7431
7432@item @emph{Arguments}:
7433@multitable @columnfractions .15 .70
7434@item @var{ARRAY} @tab Shall be an coarray, of any type.
7435@item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
7436@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
7437expression indicating the kind parameter of the result.
7438@end multitable
7439
7440@item @emph{Return value}:
7441The return value is of type @code{INTEGER} and of kind @var{KIND}. If
7442@var{KIND} is absent, the return value is of default integer kind.
7443If @var{DIM} is absent, the result is an array of the lower cobounds of
7444@var{COARRAY}. If @var{DIM} is present, the result is a scalar
7445corresponding to the lower cobound of the array along that codimension.
7446
7447@item @emph{See also}:
7448@ref{UCOBOUND}, @ref{LBOUND}
a3c4ed23 7449@end table
7450
7451
7452
0b820f43 7453@node LEADZ
7454@section @code{LEADZ} --- Number of leading zero bits of an integer
7455@fnindex LEADZ
7456@cindex zero bits
7457
7458@table @asis
7459@item @emph{Description}:
7460@code{LEADZ} returns the number of leading zero bits of an integer.
7461
7462@item @emph{Standard}:
7463Fortran 2008 and later
7464
7465@item @emph{Class}:
7466Elemental function
7467
7468@item @emph{Syntax}:
7469@code{RESULT = LEADZ(I)}
7470
7471@item @emph{Arguments}:
7472@multitable @columnfractions .15 .70
7473@item @var{I} @tab Shall be of type @code{INTEGER}.
7474@end multitable
7475
7476@item @emph{Return value}:
7477The type of the return value is the default @code{INTEGER}.
7478If all the bits of @code{I} are zero, the result value is @code{BIT_SIZE(I)}.
7479
7480@item @emph{Example}:
7481@smallexample
7482PROGRAM test_leadz
ad77abf5 7483 WRITE (*,*) BIT_SIZE(1) ! prints 32
7484 WRITE (*,*) LEADZ(1) ! prints 31
0b820f43 7485END PROGRAM
7486@end smallexample
7487
7488@item @emph{See also}:
41cbc93c 7489@ref{BIT_SIZE}, @ref{TRAILZ}, @ref{POPCNT}, @ref{POPPAR}
0b820f43 7490@end table
7491
7492
7493
a3c4ed23 7494@node LEN
7495@section @code{LEN} --- Length of a character entity
a1149005 7496@fnindex LEN
7497@cindex string, length
a3c4ed23 7498
7499@table @asis
7500@item @emph{Description}:
22f55265 7501Returns the length of a character string. If @var{STRING} is an array,
7502the length of an element of @var{STRING} is returned. Note that
7503@var{STRING} need not be defined when this intrinsic is invoked, since
7504only the length, not the content, of @var{STRING} is needed.
7505
a3c4ed23 7506@item @emph{Standard}:
f40b44c0 7507Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later
a3c4ed23 7508
7509@item @emph{Class}:
7510Inquiry function
7511
7512@item @emph{Syntax}:
7fe55cc9 7513@code{L = LEN(STRING [, KIND])}
22f55265 7514
a3c4ed23 7515@item @emph{Arguments}:
aee612a9 7516@multitable @columnfractions .15 .70
22f55265 7517@item @var{STRING} @tab Shall be a scalar or array of type
e06f8026 7518@code{CHARACTER}, with @code{INTENT(IN)}
7fe55cc9 7519@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
c24c5fac 7520expression indicating the kind parameter of the result.
22f55265 7521@end multitable
7522
a3c4ed23 7523@item @emph{Return value}:
7fe55cc9 7524The return value is of type @code{INTEGER} and of kind @var{KIND}. If
7525@var{KIND} is absent, the return value is of default integer kind.
a3c4ed23 7526
7d74ce87 7527
7528@item @emph{Specific names}:
7529@multitable @columnfractions .20 .20 .20 .25
7530@item Name @tab Argument @tab Return type @tab Standard
7531@item @code{LEN(STRING)} @tab @code{CHARACTER} @tab @code{INTEGER} @tab Fortran 77 and later
7532@end multitable
7533
7534
a3c4ed23 7535@item @emph{See also}:
7536@ref{LEN_TRIM}, @ref{ADJUSTL}, @ref{ADJUSTR}
7537@end table
7538
7539
7540
a3c4ed23 7541@node LEN_TRIM
7542@section @code{LEN_TRIM} --- Length of a character entity without trailing blank characters
a1149005 7543@fnindex LEN_TRIM
7544@cindex string, length, without trailing whitespace
a3c4ed23 7545
7546@table @asis
7547@item @emph{Description}:
22f55265 7548Returns the length of a character string, ignoring any trailing blanks.
7549
a3c4ed23 7550@item @emph{Standard}:
f40b44c0 7551Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
a3c4ed23 7552
7553@item @emph{Class}:
7554Elemental function
7555
7556@item @emph{Syntax}:
7fe55cc9 7557@code{RESULT = LEN_TRIM(STRING [, KIND])}
22f55265 7558
a3c4ed23 7559@item @emph{Arguments}:
aee612a9 7560@multitable @columnfractions .15 .70
e06f8026 7561@item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER},
22f55265 7562with @code{INTENT(IN)}
7fe55cc9 7563@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
c24c5fac 7564expression indicating the kind parameter of the result.
22f55265 7565@end multitable
7566
a3c4ed23 7567@item @emph{Return value}:
7fe55cc9 7568The return value is of type @code{INTEGER} and of kind @var{KIND}. If
7569@var{KIND} is absent, the return value is of default integer kind.
a3c4ed23 7570
7571@item @emph{See also}:
7572@ref{LEN}, @ref{ADJUSTL}, @ref{ADJUSTR}
7573@end table
7574
7575
7576
a3c4ed23 7577@node LGE
7578@section @code{LGE} --- Lexical greater than or equal
a1149005 7579@fnindex LGE
7580@cindex lexical comparison of strings
7581@cindex string, comparison
a3c4ed23 7582
7583@table @asis
7584@item @emph{Description}:
b620ae12 7585Determines whether one string is lexically greater than or equal to
7586another string, where the two strings are interpreted as containing
7587ASCII character codes. If the String A and String B are not the same
7588length, the shorter is compared as if spaces were appended to it to form
7589a value that has the same length as the longer.
7590
7591In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
7592@code{LLE}, and @code{LLT} differ from the corresponding intrinsic
7593operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
7594that the latter use the processor's character ordering (which is not
7595ASCII on some targets), whereas the former always use the ASCII
7596ordering.
7597
a3c4ed23 7598@item @emph{Standard}:
f40b44c0 7599Fortran 77 and later
a3c4ed23 7600
7601@item @emph{Class}:
7602Elemental function
7603
7604@item @emph{Syntax}:
4eb41f08 7605@code{RESULT = LGE(STRING_A, STRING_B)}
b620ae12 7606
a3c4ed23 7607@item @emph{Arguments}:
aee612a9 7608@multitable @columnfractions .15 .70
b620ae12 7609@item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
7610@item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
7611@end multitable
7612
a3c4ed23 7613@item @emph{Return value}:
b620ae12 7614Returns @code{.TRUE.} if @code{STRING_A >= STRING_B}, and @code{.FALSE.}
7615otherwise, based on the ASCII ordering.
a3c4ed23 7616
7d74ce87 7617@item @emph{Specific names}:
7618@multitable @columnfractions .20 .20 .20 .25
7619@item Name @tab Argument @tab Return type @tab Standard
7620@item @code{LGE(STRING_A, STRING_B)} @tab @code{CHARACTER} @tab @code{LOGICAL} @tab Fortran 77 and later
7621@end multitable
7622
a3c4ed23 7623@item @emph{See also}:
7624@ref{LGT}, @ref{LLE}, @ref{LLT}
7625@end table
7626
7627
7628
a3c4ed23 7629@node LGT
7630@section @code{LGT} --- Lexical greater than
a1149005 7631@fnindex LGT
7632@cindex lexical comparison of strings
7633@cindex string, comparison
a3c4ed23 7634
7635@table @asis
7636@item @emph{Description}:
b620ae12 7637Determines whether one string is lexically greater than another string,
7638where the two strings are interpreted as containing ASCII character
7639codes. If the String A and String B are not the same length, the
7640shorter is compared as if spaces were appended to it to form a value
7641that has the same length as the longer.
7642
7643In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
7644@code{LLE}, and @code{LLT} differ from the corresponding intrinsic
7645operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
7646that the latter use the processor's character ordering (which is not
7647ASCII on some targets), whereas the former always use the ASCII
7648ordering.
7649
a3c4ed23 7650@item @emph{Standard}:
f40b44c0 7651Fortran 77 and later
a3c4ed23 7652
7653@item @emph{Class}:
7654Elemental function
7655
7656@item @emph{Syntax}:
4eb41f08 7657@code{RESULT = LGT(STRING_A, STRING_B)}
b620ae12 7658
a3c4ed23 7659@item @emph{Arguments}:
aee612a9 7660@multitable @columnfractions .15 .70
b620ae12 7661@item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
7662@item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
7663@end multitable
7664
a3c4ed23 7665@item @emph{Return value}:
b620ae12 7666Returns @code{.TRUE.} if @code{STRING_A > STRING_B}, and @code{.FALSE.}
7667otherwise, based on the ASCII ordering.
a3c4ed23 7668
7d74ce87 7669@item @emph{Specific names}:
7670@multitable @columnfractions .20 .20 .20 .25
7671@item Name @tab Argument @tab Return type @tab Standard
7672@item @code{LGT(STRING_A, STRING_B)} @tab @code{CHARACTER} @tab @code{LOGICAL} @tab Fortran 77 and later
7673@end multitable
7674
a3c4ed23 7675@item @emph{See also}:
7676@ref{LGE}, @ref{LLE}, @ref{LLT}
7677@end table
7678
7679
7680
a3c4ed23 7681@node LINK
7682@section @code{LINK} --- Create a hard link
a1149005 7683@fnindex LINK
7684@cindex file system, create link
7685@cindex file system, hard link
a3c4ed23 7686
a3c4ed23 7687@table @asis
7688@item @emph{Description}:
2e3f30e8 7689Makes a (hard) link from file @var{PATH1} to @var{PATH2}. A null
7690character (@code{CHAR(0)}) can be used to mark the end of the names in
7691@var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
7692names are ignored. If the @var{STATUS} argument is supplied, it
7693contains 0 on success or a nonzero error code upon return; see
7694@code{link(2)}.
b620ae12 7695
31eea2fc 7696This intrinsic is provided in both subroutine and function forms;
7697however, only one form can be used in any given program unit.
7698
a3c4ed23 7699@item @emph{Standard}:
7700GNU extension
7701
7702@item @emph{Class}:
138b8aca 7703Subroutine, function
a3c4ed23 7704
7705@item @emph{Syntax}:
31eea2fc 7706@multitable @columnfractions .80
7707@item @code{CALL LINK(PATH1, PATH2 [, STATUS])}
7708@item @code{STATUS = LINK(PATH1, PATH2)}
7709@end multitable
b620ae12 7710
a3c4ed23 7711@item @emph{Arguments}:
aee612a9 7712@multitable @columnfractions .15 .70
b620ae12 7713@item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
7714@item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
7715@item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
7716@end multitable
a3c4ed23 7717
7718@item @emph{See also}:
0eb92d52 7719@ref{SYMLNK}, @ref{UNLINK}
a3c4ed23 7720@end table
7721
7722
7723
a3c4ed23 7724@node LLE
7725@section @code{LLE} --- Lexical less than or equal
a1149005 7726@fnindex LLE
7727@cindex lexical comparison of strings
7728@cindex string, comparison
a3c4ed23 7729
7730@table @asis
7731@item @emph{Description}:
b620ae12 7732Determines whether one string is lexically less than or equal to another
7733string, where the two strings are interpreted as containing ASCII
7734character codes. If the String A and String B are not the same length,
7735the shorter is compared as if spaces were appended to it to form a value
7736that has the same length as the longer.
7737
7738In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
7739@code{LLE}, and @code{LLT} differ from the corresponding intrinsic
7740operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
7741that the latter use the processor's character ordering (which is not
7742ASCII on some targets), whereas the former always use the ASCII
7743ordering.
7744
a3c4ed23 7745@item @emph{Standard}:
f40b44c0 7746Fortran 77 and later
a3c4ed23 7747
7748@item @emph{Class}:
7749Elemental function
7750
7751@item @emph{Syntax}:
4eb41f08 7752@code{RESULT = LLE(STRING_A, STRING_B)}
b620ae12 7753
a3c4ed23 7754@item @emph{Arguments}:
aee612a9 7755@multitable @columnfractions .15 .70
b620ae12 7756@item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
7757@item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
7758@end multitable
7759
a3c4ed23 7760@item @emph{Return value}:
b620ae12 7761Returns @code{.TRUE.} if @code{STRING_A <= STRING_B}, and @code{.FALSE.}
7762otherwise, based on the ASCII ordering.
a3c4ed23 7763
7d74ce87 7764@item @emph{Specific names}:
7765@multitable @columnfractions .20 .20 .20 .25
7766@item Name @tab Argument @tab Return type @tab Standard
7767@item @code{LLE(STRING_A, STRING_B)} @tab @code{CHARACTER} @tab @code{LOGICAL} @tab Fortran 77 and later
7768@end multitable
7769
a3c4ed23 7770@item @emph{See also}:
7771@ref{LGE}, @ref{LGT}, @ref{LLT}
7772@end table
7773
7774
7775
a3c4ed23 7776@node LLT
7777@section @code{LLT} --- Lexical less than
a1149005 7778@fnindex LLT
7779@cindex lexical comparison of strings
7780@cindex string, comparison
a3c4ed23 7781
a3c4ed23 7782@table @asis
7783@item @emph{Description}:
b620ae12 7784Determines whether one string is lexically less than another string,
7785where the two strings are interpreted as containing ASCII character
7786codes. If the String A and String B are not the same length, the
7787shorter is compared as if spaces were appended to it to form a value
7788that has the same length as the longer.
7789
7790In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
7791@code{LLE}, and @code{LLT} differ from the corresponding intrinsic
7792operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
7793that the latter use the processor's character ordering (which is not
7794ASCII on some targets), whereas the former always use the ASCII
7795ordering.
7796
a3c4ed23 7797@item @emph{Standard}:
f40b44c0 7798Fortran 77 and later
a3c4ed23 7799
7800@item @emph{Class}:
7801Elemental function
7802
7803@item @emph{Syntax}:
4eb41f08 7804@code{RESULT = LLT(STRING_A, STRING_B)}
b620ae12 7805
a3c4ed23 7806@item @emph{Arguments}:
aee612a9 7807@multitable @columnfractions .15 .70
b620ae12 7808@item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
7809@item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
7810@end multitable
7811
a3c4ed23 7812@item @emph{Return value}:
b620ae12 7813Returns @code{.TRUE.} if @code{STRING_A < STRING_B}, and @code{.FALSE.}
7814otherwise, based on the ASCII ordering.
a3c4ed23 7815
7d74ce87 7816@item @emph{Specific names}:
7817@multitable @columnfractions .20 .20 .20 .25
7818@item Name @tab Argument @tab Return type @tab Standard
7819@item @code{LLT(STRING_A, STRING_B)} @tab @code{CHARACTER} @tab @code{LOGICAL} @tab Fortran 77 and later
7820@end multitable
7821
a3c4ed23 7822@item @emph{See also}:
7823@ref{LGE}, @ref{LGT}, @ref{LLE}
7824@end table
7825
7826
7827
a3c4ed23 7828@node LNBLNK
7829@section @code{LNBLNK} --- Index of the last non-blank character in a string
a1149005 7830@fnindex LNBLNK
7831@cindex string, find non-blank character
a3c4ed23 7832
7833@table @asis
7834@item @emph{Description}:
b620ae12 7835Returns the length of a character string, ignoring any trailing blanks.
7836This is identical to the standard @code{LEN_TRIM} intrinsic, and is only
7837included for backwards compatibility.
7838
a3c4ed23 7839@item @emph{Standard}:
7840GNU extension
7841
7842@item @emph{Class}:
b620ae12 7843Elemental function
7844
a3c4ed23 7845@item @emph{Syntax}:
4eb41f08 7846@code{RESULT = LNBLNK(STRING)}
b620ae12 7847
a3c4ed23 7848@item @emph{Arguments}:
aee612a9 7849@multitable @columnfractions .15 .70
e06f8026 7850@item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER},
b620ae12 7851with @code{INTENT(IN)}
7852@end multitable
7853
a3c4ed23 7854@item @emph{Return value}:
b620ae12 7855The return value is of @code{INTEGER(kind=4)} type.
a3c4ed23 7856
7857@item @emph{See also}:
70dabb1d 7858@ref{INDEX intrinsic}, @ref{LEN_TRIM}
a3c4ed23 7859@end table
7860
7861
7862
572d7b7f 7863@node LOC
7864@section @code{LOC} --- Returns the address of a variable
a1149005 7865@fnindex LOC
5e246457 7866@cindex location of a variable in memory
572d7b7f 7867
7868@table @asis
7869@item @emph{Description}:
7870@code{LOC(X)} returns the address of @var{X} as an integer.
7871
a3c4ed23 7872@item @emph{Standard}:
7873GNU extension
572d7b7f 7874
7875@item @emph{Class}:
a3c4ed23 7876Inquiry function
572d7b7f 7877
7878@item @emph{Syntax}:
4eb41f08 7879@code{RESULT = LOC(X)}
572d7b7f 7880
7881@item @emph{Arguments}:
aee612a9 7882@multitable @columnfractions .15 .70
572d7b7f 7883@item @var{X} @tab Variable of any type.
7884@end multitable
7885
7886@item @emph{Return value}:
96a252c6 7887The return value is of type @code{INTEGER}, with a @code{KIND}
7888corresponding to the size (in bytes) of a memory address on the target
7889machine.
572d7b7f 7890
7891@item @emph{Example}:
7892@smallexample
7893program test_loc
7894 integer :: i
7895 real :: r
7896 i = loc(r)
7897 print *, i
7898end program test_loc
7899@end smallexample
7900@end table
7901
2e3f30e8 7902
7903
572d7b7f 7904@node LOG
e7f272a2 7905@section @code{LOG} --- Natural logarithm function
a1149005 7906@fnindex LOG
7907@fnindex ALOG
7908@fnindex DLOG
7909@fnindex CLOG
7910@fnindex ZLOG
7911@fnindex CDLOG
7912@cindex exponential function, inverse
e7f272a2 7913@cindex logarithm function
7914@cindex natural logarithm function
572d7b7f 7915
7916@table @asis
7917@item @emph{Description}:
e7f272a2 7918@code{LOG(X)} computes the natural logarithm of @var{X}, i.e. the
7919logarithm to the base @math{e}.
572d7b7f 7920
a3c4ed23 7921@item @emph{Standard}:
f40b44c0 7922Fortran 77 and later
572d7b7f 7923
7924@item @emph{Class}:
a3c4ed23 7925Elemental function
572d7b7f 7926
7927@item @emph{Syntax}:
4eb41f08 7928@code{RESULT = LOG(X)}
572d7b7f 7929
7930@item @emph{Arguments}:
aee612a9 7931@multitable @columnfractions .15 .70
e06f8026 7932@item @var{X} @tab The type shall be @code{REAL} or
7933@code{COMPLEX}.
572d7b7f 7934@end multitable
7935
7936@item @emph{Return value}:
e06f8026 7937The return value is of type @code{REAL} or @code{COMPLEX}.
572d7b7f 7938The kind type parameter is the same as @var{X}.
57b9ac90 7939If @var{X} is @code{COMPLEX}, the imaginary part @math{\omega} is in the range
7940@math{-\pi \leq \omega \leq \pi}.
572d7b7f 7941
7942@item @emph{Example}:
7943@smallexample
7944program test_log
e7f272a2 7945 real(8) :: x = 2.7182818284590451_8
572d7b7f 7946 complex :: z = (1.0, 2.0)
e7f272a2 7947 x = log(x) ! will yield (approximately) 1
572d7b7f 7948 z = log(z)
7949end program test_log
7950@end smallexample
7951
7952@item @emph{Specific names}:
aee612a9 7953@multitable @columnfractions .20 .20 .20 .25
a3c4ed23 7954@item Name @tab Argument @tab Return type @tab Standard
572d7b7f 7955@item @code{ALOG(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab f95, gnu
7956@item @code{DLOG(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
7957@item @code{CLOG(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab f95, gnu
7958@item @code{ZLOG(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
7959@item @code{CDLOG(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
7960@end multitable
7961@end table
7962
7963
7964
7965@node LOG10
7966@section @code{LOG10} --- Base 10 logarithm function
a1149005 7967@fnindex LOG10
7968@fnindex ALOG10
7969@fnindex DLOG10
7970@cindex exponential function, inverse
e7f272a2 7971@cindex logarithm function with base 10
7972@cindex base 10 logarithm function
572d7b7f 7973
7974@table @asis
7975@item @emph{Description}:
7976@code{LOG10(X)} computes the base 10 logarithm of @var{X}.
7977
a3c4ed23 7978@item @emph{Standard}:
f40b44c0 7979Fortran 77 and later
572d7b7f 7980
7981@item @emph{Class}:
a3c4ed23 7982Elemental function
572d7b7f 7983
7984@item @emph{Syntax}:
4eb41f08 7985@code{RESULT = LOG10(X)}
572d7b7f 7986
7987@item @emph{Arguments}:
aee612a9 7988@multitable @columnfractions .15 .70
e06f8026 7989@item @var{X} @tab The type shall be @code{REAL}.
572d7b7f 7990@end multitable
7991
7992@item @emph{Return value}:
e06f8026 7993The return value is of type @code{REAL} or @code{COMPLEX}.
572d7b7f 7994The kind type parameter is the same as @var{X}.
7995
7996@item @emph{Example}:
7997@smallexample
7998program test_log10
7999 real(8) :: x = 10.0_8
8000 x = log10(x)
8001end program test_log10
8002@end smallexample
8003
8004@item @emph{Specific names}:
aee612a9 8005@multitable @columnfractions .20 .20 .20 .25
a3c4ed23 8006@item Name @tab Argument @tab Return type @tab Standard
f40b44c0 8007@item @code{ALOG10(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 95 and later
8008@item @code{DLOG10(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 95 and later
572d7b7f 8009@end multitable
8010@end table
8011
8012
2e3f30e8 8013
cf37b737 8014@node LOG_GAMMA
8015@section @code{LOG_GAMMA} --- Logarithm of the Gamma function
8016@fnindex LOG_GAMMA
8017@fnindex LGAMMA
8018@fnindex ALGAMA
8019@fnindex DLGAMA
8020@cindex Gamma function, logarithm of
8021
8022@table @asis
8023@item @emph{Description}:
8024@code{LOG_GAMMA(X)} computes the natural logarithm of the absolute value
8025of the Gamma (@math{\Gamma}) function.
8026
8027@item @emph{Standard}:
8028Fortran 2008 and later
8029
8030@item @emph{Class}:
8031Elemental function
8032
8033@item @emph{Syntax}:
8034@code{X = LOG_GAMMA(X)}
8035
8036@item @emph{Arguments}:
8037@multitable @columnfractions .15 .70
8038@item @var{X} @tab Shall be of type @code{REAL} and neither zero
8039nor a negative integer.
8040@end multitable
8041
8042@item @emph{Return value}:
8043The return value is of type @code{REAL} of the same kind as @var{X}.
8044
8045@item @emph{Example}:
8046@smallexample
8047program test_log_gamma
8048 real :: x = 1.0
8049 x = lgamma(x) ! returns 0.0
8050end program test_log_gamma
8051@end smallexample
8052
8053@item @emph{Specific names}:
8054@multitable @columnfractions .20 .20 .20 .25
8055@item Name @tab Argument @tab Return type @tab Standard
8056@item @code{LGAMMA(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU Extension
8057@item @code{ALGAMA(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU Extension
8058@item @code{DLGAMA(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU Extension
8059@end multitable
8060
8061@item @emph{See also}:
8062Gamma function: @ref{GAMMA}
8063
8064@end table
8065
8066
8067
a3c4ed23 8068@node LOGICAL
8069@section @code{LOGICAL} --- Convert to logical type
a1149005 8070@fnindex LOGICAL
8071@cindex conversion, to logical
a3c4ed23 8072
a3c4ed23 8073@table @asis
8074@item @emph{Description}:
0eb92d52 8075Converts one kind of @code{LOGICAL} variable to another.
8076
a3c4ed23 8077@item @emph{Standard}:
f40b44c0 8078Fortran 95 and later
a3c4ed23 8079
8080@item @emph{Class}:
8081Elemental function
8082
8083@item @emph{Syntax}:
0eb92d52 8084@code{RESULT = LOGICAL(L [, KIND])}
8085
a3c4ed23 8086@item @emph{Arguments}:
aee612a9 8087@multitable @columnfractions .15 .70
e06f8026 8088@item @var{L} @tab The type shall be @code{LOGICAL}.
8089@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
c24c5fac 8090expression indicating the kind parameter of the result.
0eb92d52 8091@end multitable
8092
a3c4ed23 8093@item @emph{Return value}:
0eb92d52 8094The return value is a @code{LOGICAL} value equal to @var{L}, with a
8095kind corresponding to @var{KIND}, or of the default logical kind if
8096@var{KIND} is not given.
8097
a3c4ed23 8098@item @emph{See also}:
0eb92d52 8099@ref{INT}, @ref{REAL}, @ref{CMPLX}
a3c4ed23 8100@end table
8101
8102
8103
fe97b755 8104@node LONG
8105@section @code{LONG} --- Convert to integer type
a1149005 8106@fnindex LONG
8107@cindex conversion, to integer
fe97b755 8108
8109@table @asis
8110@item @emph{Description}:
8111Convert to a @code{KIND=4} integer type, which is the same size as a C
8112@code{long} integer. This is equivalent to the standard @code{INT}
8113intrinsic with an optional argument of @code{KIND=4}, and is only
8114included for backwards compatibility.
8115
8116@item @emph{Standard}:
f40b44c0 8117GNU extension
fe97b755 8118
8119@item @emph{Class}:
8120Elemental function
8121
8122@item @emph{Syntax}:
8123@code{RESULT = LONG(A)}
8124
8125@item @emph{Arguments}:
8126@multitable @columnfractions .15 .70
e06f8026 8127@item @var{A} @tab Shall be of type @code{INTEGER},
c24c5fac 8128@code{REAL}, or @code{COMPLEX}.
fe97b755 8129@end multitable
8130
8131@item @emph{Return value}:
8132The return value is a @code{INTEGER(4)} variable.
8133
8873d8a6 8134@item @emph{See also}:
fe97b755 8135@ref{INT}, @ref{INT2}, @ref{INT8}
8136@end table
8137
8138
a3c4ed23 8139
8140@node LSHIFT
8141@section @code{LSHIFT} --- Left shift bits
a1149005 8142@fnindex LSHIFT
8143@cindex bits, shift left
a3c4ed23 8144
a3c4ed23 8145@table @asis
8146@item @emph{Description}:
0eb92d52 8147@code{LSHIFT} returns a value corresponding to @var{I} with all of the
8148bits shifted left by @var{SHIFT} places. If the absolute value of
8149@var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
8150Bits shifted out from the left end are lost; zeros are shifted in from
8151the opposite end.
8152
2b9c8475 8153This function has been superseded by the @code{ISHFT} intrinsic, which
f004c7aa 8154is standard in Fortran 95 and later, and the @code{SHIFTL} intrinsic,
8155which is standard in Fortran 2008 and later.
a3c4ed23 8156
8157@item @emph{Standard}:
8158GNU extension
8159
8160@item @emph{Class}:
0eb92d52 8161Elemental function
a3c4ed23 8162
8163@item @emph{Syntax}:
0eb92d52 8164@code{RESULT = LSHIFT(I, SHIFT)}
8165
a3c4ed23 8166@item @emph{Arguments}:
aee612a9 8167@multitable @columnfractions .15 .70
e06f8026 8168@item @var{I} @tab The type shall be @code{INTEGER}.
8169@item @var{SHIFT} @tab The type shall be @code{INTEGER}.
0eb92d52 8170@end multitable
8171
a3c4ed23 8172@item @emph{Return value}:
e06f8026 8173The return value is of type @code{INTEGER} and of the same kind as
0eb92d52 8174@var{I}.
8175
a3c4ed23 8176@item @emph{See also}:
f004c7aa 8177@ref{ISHFT}, @ref{ISHFTC}, @ref{RSHIFT}, @ref{SHIFTA}, @ref{SHIFTL},
8178@ref{SHIFTR}
a3c4ed23 8179
8180@end table
8181
8182
fe97b755 8183
666bf11e 8184@node LSTAT
8185@section @code{LSTAT} --- Get file status
a1149005 8186@fnindex LSTAT
8187@cindex file system, file status
666bf11e 8188
8189@table @asis
8190@item @emph{Description}:
2cd8ef8b 8191@code{LSTAT} is identical to @ref{STAT}, except that if path is a
8192symbolic link, then the link itself is statted, not the file that it
8193refers to.
666bf11e 8194
2cd8ef8b 8195The elements in @code{VALUES} are the same as described by @ref{STAT}.
666bf11e 8196
2cd8ef8b 8197This intrinsic is provided in both subroutine and function forms;
8198however, only one form can be used in any given program unit.
138b8aca 8199
666bf11e 8200@item @emph{Standard}:
8201GNU extension
8202
8203@item @emph{Class}:
138b8aca 8204Subroutine, function
666bf11e 8205
8206@item @emph{Syntax}:
6c07e6d8 8207@multitable @columnfractions .80
8208@item @code{CALL LSTAT(NAME, VALUES [, STATUS])}
8209@item @code{STATUS = LSTAT(NAME, VALUES)}
8210@end multitable
666bf11e 8211
8212@item @emph{Arguments}:
aee612a9 8213@multitable @columnfractions .15 .70
2cd8ef8b 8214@item @var{NAME} @tab The type shall be @code{CHARACTER} of the default
b44437b9 8215kind, a valid path within the file system.
2cd8ef8b 8216@item @var{VALUES} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
b44437b9 8217@item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}.
8218Returns 0 on success and a system specific error code otherwise.
666bf11e 8219@end multitable
8220
8221@item @emph{Example}:
8222See @ref{STAT} for an example.
8223
8224@item @emph{See also}:
8225To stat an open file: @ref{FSTAT}, to stat a file: @ref{STAT}
8226@end table
8227
8228
a3c4ed23 8229
8230@node LTIME
8231@section @code{LTIME} --- Convert time to local time info
a1149005 8232@fnindex LTIME
bd84e447 8233@cindex time, conversion to local time info
a3c4ed23 8234
a3c4ed23 8235@table @asis
8236@item @emph{Description}:
e8c1bbb4 8237Given a system time value @var{TIME} (as provided by the @code{TIME8}
2cd8ef8b 8238intrinsic), fills @var{VALUES} with values extracted from it appropriate
0eb92d52 8239to the local time zone using @code{localtime(3)}.
a3c4ed23 8240
8241@item @emph{Standard}:
8242GNU extension
8243
8244@item @emph{Class}:
8245Subroutine
8246
8247@item @emph{Syntax}:
2cd8ef8b 8248@code{CALL LTIME(TIME, VALUES)}
0eb92d52 8249
a3c4ed23 8250@item @emph{Arguments}:
aee612a9 8251@multitable @columnfractions .15 .70
2cd8ef8b 8252@item @var{TIME} @tab An @code{INTEGER} scalar expression
c24c5fac 8253corresponding to a system time, with @code{INTENT(IN)}.
2cd8ef8b 8254@item @var{VALUES} @tab A default @code{INTEGER} array with 9 elements,
c24c5fac 8255with @code{INTENT(OUT)}.
0eb92d52 8256@end multitable
8257
a3c4ed23 8258@item @emph{Return value}:
2cd8ef8b 8259The elements of @var{VALUES} are assigned as follows:
0eb92d52 8260@enumerate
8261@item Seconds after the minute, range 0--59 or 0--61 to allow for leap
c24c5fac 8262seconds
0eb92d52 8263@item Minutes after the hour, range 0--59
8264@item Hours past midnight, range 0--23
8265@item Day of month, range 0--31
8266@item Number of months since January, range 0--12
8267@item Years since 1900
8268@item Number of days since Sunday, range 0--6
8269@item Days since January 1
8270@item Daylight savings indicator: positive if daylight savings is in
c24c5fac 8271effect, zero if not, and negative if the information is not available.
0eb92d52 8272@end enumerate
8273
a3c4ed23 8274@item @emph{See also}:
0eb92d52 8275@ref{CTIME}, @ref{GMTIME}, @ref{TIME}, @ref{TIME8}
a3c4ed23 8276
8277@end table
8278
8279
8280
572d7b7f 8281@node MALLOC
8282@section @code{MALLOC} --- Allocate dynamic memory
a1149005 8283@fnindex MALLOC
8284@cindex pointer, cray
572d7b7f 8285
8286@table @asis
8287@item @emph{Description}:
8288@code{MALLOC(SIZE)} allocates @var{SIZE} bytes of dynamic memory and
8289returns the address of the allocated memory. The @code{MALLOC} intrinsic
8290is an extension intended to be used with Cray pointers, and is provided
61156d26 8291in GNU Fortran to allow the user to compile legacy code. For new code
572d7b7f 8292using Fortran 95 pointers, the memory allocation intrinsic is
8293@code{ALLOCATE}.
8294
a3c4ed23 8295@item @emph{Standard}:
8296GNU extension
572d7b7f 8297
8298@item @emph{Class}:
138b8aca 8299Function
572d7b7f 8300
8301@item @emph{Syntax}:
8302@code{PTR = MALLOC(SIZE)}
8303
8304@item @emph{Arguments}:
aee612a9 8305@multitable @columnfractions .15 .70
e06f8026 8306@item @var{SIZE} @tab The type shall be @code{INTEGER}.
572d7b7f 8307@end multitable
8308
8309@item @emph{Return value}:
8310The return value is of type @code{INTEGER(K)}, with @var{K} such that
8311variables of type @code{INTEGER(K)} have the same size as
8312C pointers (@code{sizeof(void *)}).
8313
8314@item @emph{Example}:
8315The following example demonstrates the use of @code{MALLOC} and
3c3f2fcc 8316@code{FREE} with Cray pointers.
572d7b7f 8317
8318@smallexample
8319program test_malloc
3c3f2fcc 8320 implicit none
572d7b7f 8321 integer i
572d7b7f 8322 real*8 x(*), z
8323 pointer(ptr_x,x)
8324
8325 ptr_x = malloc(20*8)
8326 do i = 1, 20
8327 x(i) = sqrt(1.0d0 / i)
8328 end do
8329 z = 0
8330 do i = 1, 20
8331 z = z + x(i)
8332 print *, z
8333 end do
8334 call free(ptr_x)
8335end program test_malloc
8336@end smallexample
a3c4ed23 8337
8338@item @emph{See also}:
8339@ref{FREE}
572d7b7f 8340@end table
8341
8342
0eb92d52 8343
f004c7aa 8344@node MASKL
8345@section @code{MASKL} --- Left justified mask
8346@fnindex MASKL
8347@cindex mask, left justified
8348
8349@table @asis
8350@item @emph{Description}:
8351@code{MASKL(I[, KIND])} has its leftmost @var{I} bits set to 1, and the
8352remaining bits set to 0.
8353
8354@item @emph{Standard}:
8355Fortran 2008 and later
8356
8357@item @emph{Class}:
8358Elemental function
8359
8360@item @emph{Syntax}:
8361@code{RESULT = MASKL(I[, KIND])}
8362
8363@item @emph{Arguments}:
8364@multitable @columnfractions .15 .70
8365@item @var{I} @tab Shall be of type @code{INTEGER}.
8366@item @var{KIND} @tab Shall be a scalar constant expression of type
8367@code{INTEGER}.
8368@end multitable
8369
8370@item @emph{Return value}:
8371The return value is of type @code{INTEGER}. If @var{KIND} is present, it
8372specifies the kind value of the return type; otherwise, it is of the
8373default integer kind.
8374
8375@item @emph{See also}:
8376@ref{MASKR}
8377@end table
8378
8379
8380
8381@node MASKR
8382@section @code{MASKR} --- Right justified mask
8383@fnindex MASKR
8384@cindex mask, right justified
8385
8386@table @asis
8387@item @emph{Description}:
8388@code{MASKL(I[, KIND])} has its rightmost @var{I} bits set to 1, and the
8389remaining bits set to 0.
8390
8391@item @emph{Standard}:
8392Fortran 2008 and later
8393
8394@item @emph{Class}:
8395Elemental function
8396
8397@item @emph{Syntax}:
8398@code{RESULT = MASKR(I[, KIND])}
8399
8400@item @emph{Arguments}:
8401@multitable @columnfractions .15 .70
8402@item @var{I} @tab Shall be of type @code{INTEGER}.
8403@item @var{KIND} @tab Shall be a scalar constant expression of type
8404@code{INTEGER}.
8405@end multitable
8406
8407@item @emph{Return value}:
8408The return value is of type @code{INTEGER}. If @var{KIND} is present, it
8409specifies the kind value of the return type; otherwise, it is of the
8410default integer kind.
8411
8412@item @emph{See also}:
8413@ref{MASKL}
8414@end table
8415
8416
8417
a3c4ed23 8418@node MATMUL
8419@section @code{MATMUL} --- matrix multiplication
a1149005 8420@fnindex MATMUL
8421@cindex matrix multiplication
8422@cindex product, matrix
572d7b7f 8423
572d7b7f 8424@table @asis
8425@item @emph{Description}:
0eb92d52 8426Performs a matrix multiplication on numeric or logical arguments.
8427
a3c4ed23 8428@item @emph{Standard}:
f40b44c0 8429Fortran 95 and later
572d7b7f 8430
8431@item @emph{Class}:
a3c4ed23 8432Transformational function
572d7b7f 8433
8434@item @emph{Syntax}:
0eb92d52 8435@code{RESULT = MATMUL(MATRIX_A, MATRIX_B)}
8436
572d7b7f 8437@item @emph{Arguments}:
aee612a9 8438@multitable @columnfractions .15 .70
e06f8026 8439@item @var{MATRIX_A} @tab An array of @code{INTEGER},
c24c5fac 8440@code{REAL}, @code{COMPLEX}, or @code{LOGICAL} type, with a rank of
8441one or two.
e06f8026 8442@item @var{MATRIX_B} @tab An array of @code{INTEGER},
c24c5fac 8443@code{REAL}, or @code{COMPLEX} type if @var{MATRIX_A} is of a numeric
8444type; otherwise, an array of @code{LOGICAL} type. The rank shall be one
8445or two, and the first (or only) dimension of @var{MATRIX_B} shall be
8446equal to the last (or only) dimension of @var{MATRIX_A}.
0eb92d52 8447@end multitable
8448
572d7b7f 8449@item @emph{Return value}:
0eb92d52 8450The matrix product of @var{MATRIX_A} and @var{MATRIX_B}. The type and
8451kind of the result follow the usual type and kind promotion rules, as
8452for the @code{*} or @code{.AND.} operators.
8453
a3c4ed23 8454@item @emph{See also}:
8455@end table
8456
8457
0eb92d52 8458
a3c4ed23 8459@node MAX
8460@section @code{MAX} --- Maximum value of an argument list
a1149005 8461@fnindex MAX
8462@fnindex MAX0
8463@fnindex AMAX0
8464@fnindex MAX1
8465@fnindex AMAX1
8466@fnindex DMAX1
8467@cindex maximum value
a3c4ed23 8468
8469@table @asis
8470@item @emph{Description}:
0eb92d52 8471Returns the argument with the largest (most positive) value.
8472
a3c4ed23 8473@item @emph{Standard}:
f40b44c0 8474Fortran 77 and later
a3c4ed23 8475
8476@item @emph{Class}:
8477Elemental function
8478
8479@item @emph{Syntax}:
0eb92d52 8480@code{RESULT = MAX(A1, A2 [, A3 [, ...]])}
8481
a3c4ed23 8482@item @emph{Arguments}:
aee612a9 8483@multitable @columnfractions .15 .70
e06f8026 8484@item @var{A1} @tab The type shall be @code{INTEGER} or
c24c5fac 8485@code{REAL}.
48c4dee5 8486@item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
c24c5fac 8487as @var{A1}. (As a GNU extension, arguments of different kinds are
8488permitted.)
0eb92d52 8489@end multitable
8490
a3c4ed23 8491@item @emph{Return value}:
0eb92d52 8492The return value corresponds to the maximum value among the arguments,
8493and has the same type and kind as the first argument.
a3c4ed23 8494
8495@item @emph{Specific names}:
aee612a9 8496@multitable @columnfractions .20 .20 .20 .25
7d74ce87 8497@item Name @tab Argument @tab Return type @tab Standard
8498@item @code{MAX0(A1)} @tab @code{INTEGER(4) A1} @tab @code{INTEGER(4)} @tab Fortran 77 and later
8499@item @code{AMAX0(A1)} @tab @code{INTEGER(4) A1} @tab @code{REAL(MAX(X))} @tab Fortran 77 and later
8500@item @code{MAX1(A1)} @tab @code{REAL A1} @tab @code{INT(MAX(X))} @tab Fortran 77 and later
8501@item @code{AMAX1(A1)} @tab @code{REAL(4) A1} @tab @code{REAL(4)} @tab Fortran 77 and later
8502@item @code{DMAX1(A1)} @tab @code{REAL(8) A1} @tab @code{REAL(8)} @tab Fortran 77 and later
a3c4ed23 8503@end multitable
8504
8505@item @emph{See also}:
0eb92d52 8506@ref{MAXLOC} @ref{MAXVAL}, @ref{MIN}
8507
a3c4ed23 8508@end table
8509
8510
0eb92d52 8511
a3c4ed23 8512@node MAXEXPONENT
8513@section @code{MAXEXPONENT} --- Maximum exponent of a real kind
a1149005 8514@fnindex MAXEXPONENT
8515@cindex model representation, maximum exponent
a3c4ed23 8516
8517@table @asis
8518@item @emph{Description}:
8519@code{MAXEXPONENT(X)} returns the maximum exponent in the model of the
8520type of @code{X}.
8521
8522@item @emph{Standard}:
f40b44c0 8523Fortran 95 and later
a3c4ed23 8524
8525@item @emph{Class}:
8526Inquiry function
8527
8528@item @emph{Syntax}:
4eb41f08 8529@code{RESULT = MAXEXPONENT(X)}
a3c4ed23 8530
8531@item @emph{Arguments}:
aee612a9 8532@multitable @columnfractions .15 .70
e0c54690 8533@item @var{X} @tab Shall be of type @code{REAL}.
a3c4ed23 8534@end multitable
8535
8536@item @emph{Return value}:
8537The return value is of type @code{INTEGER} and of the default integer
8538kind.
572d7b7f 8539
8540@item @emph{Example}:
8541@smallexample
8542program exponents
8543 real(kind=4) :: x
8544 real(kind=8) :: y
8545
8546 print *, minexponent(x), maxexponent(x)
8547 print *, minexponent(y), maxexponent(y)
8548end program exponents
8549@end smallexample
8550@end table
8551
8552
0eb92d52 8553
a3c4ed23 8554@node MAXLOC
8555@section @code{MAXLOC} --- Location of the maximum value within an array
a1149005 8556@fnindex MAXLOC
8557@cindex array, location of maximum element
a3c4ed23 8558
8559@table @asis
8560@item @emph{Description}:
0eb92d52 8561Determines the location of the element in the array with the maximum
8562value, or, if the @var{DIM} argument is supplied, determines the
8563locations of the maximum element along each row of the array in the
8564@var{DIM} direction. If @var{MASK} is present, only the elements for
8565which @var{MASK} is @code{.TRUE.} are considered. If more than one
8566element in the array has the maximum value, the location returned is
8567that of the first such element in array element order. If the array has
8568zero size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
8569the result is an array of zeroes. Similarly, if @var{DIM} is supplied
8570and all of the elements of @var{MASK} along a given row are zero, the
8571result value for that row is zero.
8572
a3c4ed23 8573@item @emph{Standard}:
f40b44c0 8574Fortran 95 and later
a3c4ed23 8575
8576@item @emph{Class}:
8577Transformational function
8578
8579@item @emph{Syntax}:
0eb92d52 8580@multitable @columnfractions .80
8581@item @code{RESULT = MAXLOC(ARRAY, DIM [, MASK])}
8582@item @code{RESULT = MAXLOC(ARRAY [, MASK])}
8583@end multitable
8584
a3c4ed23 8585@item @emph{Arguments}:
aee612a9 8586@multitable @columnfractions .15 .70
38307b08 8587@item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or
8588@code{REAL}.
0eb92d52 8589@item @var{DIM} @tab (Optional) Shall be a scalar of type
c24c5fac 8590@code{INTEGER}, with a value between one and the rank of @var{ARRAY},
8591inclusive. It may not be an optional dummy argument.
e06f8026 8592@item @var{MASK} @tab Shall be an array of type @code{LOGICAL},
c24c5fac 8593and conformable with @var{ARRAY}.
0eb92d52 8594@end multitable
8595
a3c4ed23 8596@item @emph{Return value}:
0eb92d52 8597If @var{DIM} is absent, the result is a rank-one array with a length
8598equal to the rank of @var{ARRAY}. If @var{DIM} is present, the result
8599is an array with a rank one less than the rank of @var{ARRAY}, and a
8600size corresponding to the size of @var{ARRAY} with the @var{DIM}
8601dimension removed. If @var{DIM} is present and @var{ARRAY} has a rank
8602of one, the result is a scalar. In all cases, the result is of default
8603@code{INTEGER} type.
8604
a3c4ed23 8605@item @emph{See also}:
8606@ref{MAX}, @ref{MAXVAL}
0eb92d52 8607
a3c4ed23 8608@end table
8609
8610
8611
8612@node MAXVAL
8613@section @code{MAXVAL} --- Maximum value of an array
a1149005 8614@fnindex MAXVAL
8615@cindex array, maximum value
8616@cindex maximum value
a3c4ed23 8617
8618@table @asis
8619@item @emph{Description}:
0eb92d52 8620Determines the maximum value of the elements in an array value, or, if
8621the @var{DIM} argument is supplied, determines the maximum value along
8622each row of the array in the @var{DIM} direction. If @var{MASK} is
8623present, only the elements for which @var{MASK} is @code{.TRUE.} are
8624considered. If the array has zero size, or all of the elements of
57b9ac90 8625@var{MASK} are @code{.FALSE.}, then the result is @code{-HUGE(ARRAY)}
8626if @var{ARRAY} is numeric, or a string of nulls if @var{ARRAY} is of character
8627type.
a3c4ed23 8628
0eb92d52 8629@item @emph{Standard}:
f40b44c0 8630Fortran 95 and later
a3c4ed23 8631
8632@item @emph{Class}:
8633Transformational function
8634
8635@item @emph{Syntax}:
0eb92d52 8636@multitable @columnfractions .80
8637@item @code{RESULT = MAXVAL(ARRAY, DIM [, MASK])}
8638@item @code{RESULT = MAXVAL(ARRAY [, MASK])}
8639@end multitable
8640
a3c4ed23 8641@item @emph{Arguments}:
aee612a9 8642@multitable @columnfractions .15 .70
38307b08 8643@item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or
8644@code{REAL}.
0eb92d52 8645@item @var{DIM} @tab (Optional) Shall be a scalar of type
c24c5fac 8646@code{INTEGER}, with a value between one and the rank of @var{ARRAY},
8647inclusive. It may not be an optional dummy argument.
e06f8026 8648@item @var{MASK} @tab Shall be an array of type @code{LOGICAL},
c24c5fac 8649and conformable with @var{ARRAY}.
0eb92d52 8650@end multitable
8651
a3c4ed23 8652@item @emph{Return value}:
4eb41f08 8653If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
8654is a scalar. If @var{DIM} is present, the result is an array with a
8655rank one less than the rank of @var{ARRAY}, and a size corresponding to
8656the size of @var{ARRAY} with the @var{DIM} dimension removed. In all
8657cases, the result is of the same type and kind as @var{ARRAY}.
a3c4ed23 8658
8659@item @emph{See also}:
8660@ref{MAX}, @ref{MAXLOC}
8661@end table
8662
8663
8664
fe97b755 8665@node MCLOCK
8666@section @code{MCLOCK} --- Time function
a1149005 8667@fnindex MCLOCK
fe97b755 8668@cindex time, clock ticks
8669@cindex clock ticks
8670
8671@table @asis
8672@item @emph{Description}:
8673Returns the number of clock ticks since the start of the process, based
be960ff7 8674on the function @code{clock(3)} in the C standard library.
fe97b755 8675
8676This intrinsic is not fully portable, such as to systems with 32-bit
8677@code{INTEGER} types but supporting times wider than 32 bits. Therefore,
8678the values returned by this intrinsic might be, or become, negative, or
8679numerically less than previous values, during a single run of the
8680compiled program.
8681
8682@item @emph{Standard}:
8683GNU extension
8684
8685@item @emph{Class}:
138b8aca 8686Function
fe97b755 8687
8688@item @emph{Syntax}:
8689@code{RESULT = MCLOCK()}
8690
8691@item @emph{Return value}:
8692The return value is a scalar of type @code{INTEGER(4)}, equal to the
8693number of clock ticks since the start of the process, or @code{-1} if
8694the system does not support @code{clock(3)}.
8695
8696@item @emph{See also}:
8697@ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME}
8698
8699@end table
8700
8701
8702
8703@node MCLOCK8
8704@section @code{MCLOCK8} --- Time function (64-bit)
a1149005 8705@fnindex MCLOCK8
8706@cindex time, clock ticks
8707@cindex clock ticks
fe97b755 8708
8709@table @asis
8710@item @emph{Description}:
8711Returns the number of clock ticks since the start of the process, based
be960ff7 8712on the function @code{clock(3)} in the C standard library.
fe97b755 8713
8714@emph{Warning:} this intrinsic does not increase the range of the timing
8715values over that returned by @code{clock(3)}. On a system with a 32-bit
e8c1bbb4 8716@code{clock(3)}, @code{MCLOCK8} will return a 32-bit value, even though
fe97b755 8717it is converted to a 64-bit @code{INTEGER(8)} value. That means
8718overflows of the 32-bit value can still occur. Therefore, the values
8719returned by this intrinsic might be or become negative or numerically
8720less than previous values during a single run of the compiled program.
8721
8722@item @emph{Standard}:
8723GNU extension
8724
8725@item @emph{Class}:
138b8aca 8726Function
fe97b755 8727
8728@item @emph{Syntax}:
8729@code{RESULT = MCLOCK8()}
8730
8731@item @emph{Return value}:
8732The return value is a scalar of type @code{INTEGER(8)}, equal to the
8733number of clock ticks since the start of the process, or @code{-1} if
8734the system does not support @code{clock(3)}.
8735
8736@item @emph{See also}:
8737@ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME8}
8738
8739@end table
8740
8741
8742
a3c4ed23 8743@node MERGE
0eb92d52 8744@section @code{MERGE} --- Merge variables
a1149005 8745@fnindex MERGE
8746@cindex array, merge arrays
8747@cindex array, combine arrays
a3c4ed23 8748
8749@table @asis
8750@item @emph{Description}:
0eb92d52 8751Select values from two arrays according to a logical mask. The result
8752is equal to @var{TSOURCE} if @var{MASK} is @code{.TRUE.}, or equal to
8753@var{FSOURCE} if it is @code{.FALSE.}.
8754
a3c4ed23 8755@item @emph{Standard}:
f40b44c0 8756Fortran 95 and later
a3c4ed23 8757
8758@item @emph{Class}:
0eb92d52 8759Elemental function
a3c4ed23 8760
8761@item @emph{Syntax}:
0eb92d52 8762@code{RESULT = MERGE(TSOURCE, FSOURCE, MASK)}
8763
a3c4ed23 8764@item @emph{Arguments}:
aee612a9 8765@multitable @columnfractions .15 .70
0eb92d52 8766@item @var{TSOURCE} @tab May be of any type.
8767@item @var{FSOURCE} @tab Shall be of the same type and type parameters
c24c5fac 8768as @var{TSOURCE}.
e06f8026 8769@item @var{MASK} @tab Shall be of type @code{LOGICAL}.
0eb92d52 8770@end multitable
8771
a3c4ed23 8772@item @emph{Return value}:
0eb92d52 8773The result is of the same type and type parameters as @var{TSOURCE}.
8774
a3c4ed23 8775@end table
8776
8777
0eb92d52 8778
f004c7aa 8779@node MERGE_BITS
8780@section @code{MERGE_BITS} --- Merge of bits under mask
8781@fnindex MERGE_BITS
8782@cindex bits, merge
8783
8784@table @asis
8785@item @emph{Description}:
8786@code{MERGE_BITS(I, J, MASK)} merges the bits of @var{I} and @var{J}
8787as determined by the mask. The i-th bit of the result is equal to the
8788i-th bit of @var{I} if the i-th bit of @var{MASK} is 1; it is equal to
8789the i-th bit of @var{J} otherwise.
8790
8791@item @emph{Standard}:
8792Fortran 2008 and later
8793
8794@item @emph{Class}:
8795Elemental function
8796
8797@item @emph{Syntax}:
8798@code{RESULT = MERGE_BITS(I, J, MASK)}
8799
8800@item @emph{Arguments}:
8801@multitable @columnfractions .15 .70
8802@item @var{I} @tab Shall be of type @code{INTEGER}.
8803@item @var{J} @tab Shall be of type @code{INTEGER} and of the same
8804kind as @var{I}.
8805@item @var{MASK} @tab Shall be of type @code{INTEGER} and of the same
8806kind as @var{I}.
8807@end multitable
8808
8809@item @emph{Return value}:
8810The result is of the same type and kind as @var{I}.
8811
8812@end table
8813
8814
8815
a3c4ed23 8816@node MIN
8817@section @code{MIN} --- Minimum value of an argument list
a1149005 8818@fnindex MIN
8819@fnindex MIN0
8820@fnindex AMIN0
8821@fnindex MIN1
8822@fnindex AMIN1
8823@fnindex DMIN1
8824@cindex minimum value
a3c4ed23 8825
8826@table @asis
8827@item @emph{Description}:
0eb92d52 8828Returns the argument with the smallest (most negative) value.
8829
a3c4ed23 8830@item @emph{Standard}:
f40b44c0 8831Fortran 77 and later
a3c4ed23 8832
8833@item @emph{Class}:
8834Elemental function
8835
8836@item @emph{Syntax}:
4eb41f08 8837@code{RESULT = MIN(A1, A2 [, A3, ...])}
0eb92d52 8838
a3c4ed23 8839@item @emph{Arguments}:
aee612a9 8840@multitable @columnfractions .15 .70
e06f8026 8841@item @var{A1} @tab The type shall be @code{INTEGER} or
c24c5fac 8842@code{REAL}.
48c4dee5 8843@item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
c24c5fac 8844as @var{A1}. (As a GNU extension, arguments of different kinds are
8845permitted.)
0eb92d52 8846@end multitable
8847
a3c4ed23 8848@item @emph{Return value}:
0eb92d52 8849The return value corresponds to the maximum value among the arguments,
8850and has the same type and kind as the first argument.
a3c4ed23 8851
8852@item @emph{Specific names}:
aee612a9 8853@multitable @columnfractions .20 .20 .20 .25
7d74ce87 8854@item Name @tab Argument @tab Return type @tab Standard
8855@item @code{MIN0(A1)} @tab @code{INTEGER(4) A1} @tab @code{INTEGER(4)} @tab Fortran 77 and later
8856@item @code{AMIN0(A1)} @tab @code{INTEGER(4) A1} @tab @code{REAL(4)} @tab Fortran 77 and later
8857@item @code{MIN1(A1)} @tab @code{REAL A1} @tab @code{INTEGER(4)} @tab Fortran 77 and later
8858@item @code{AMIN1(A1)} @tab @code{REAL(4) A1} @tab @code{REAL(4)} @tab Fortran 77 and later
8859@item @code{DMIN1(A1)} @tab @code{REAL(8) A1} @tab @code{REAL(8)} @tab Fortran 77 and later
a3c4ed23 8860@end multitable
8861
8862@item @emph{See also}:
0eb92d52 8863@ref{MAX}, @ref{MINLOC}, @ref{MINVAL}
a3c4ed23 8864@end table
572d7b7f 8865
fe97b755 8866
8867
572d7b7f 8868@node MINEXPONENT
8869@section @code{MINEXPONENT} --- Minimum exponent of a real kind
a1149005 8870@fnindex MINEXPONENT
8871@cindex model representation, minimum exponent
572d7b7f 8872
8873@table @asis
8874@item @emph{Description}:
8875@code{MINEXPONENT(X)} returns the minimum exponent in the model of the
8876type of @code{X}.
8877
a3c4ed23 8878@item @emph{Standard}:
f40b44c0 8879Fortran 95 and later
572d7b7f 8880
8881@item @emph{Class}:
a3c4ed23 8882Inquiry function
572d7b7f 8883
8884@item @emph{Syntax}:
4eb41f08 8885@code{RESULT = MINEXPONENT(X)}
572d7b7f 8886
8887@item @emph{Arguments}:
aee612a9 8888@multitable @columnfractions .15 .70
e0c54690 8889@item @var{X} @tab Shall be of type @code{REAL}.
572d7b7f 8890@end multitable
8891
8892@item @emph{Return value}:
8893The return value is of type @code{INTEGER} and of the default integer
8894kind.
8895
8896@item @emph{Example}:
8897See @code{MAXEXPONENT} for an example.
8898@end table
8899
8900
0eb92d52 8901
a3c4ed23 8902@node MINLOC
8903@section @code{MINLOC} --- Location of the minimum value within an array
a1149005 8904@fnindex MINLOC
8905@cindex array, location of minimum element
a3c4ed23 8906
8907@table @asis
8908@item @emph{Description}:
0eb92d52 8909Determines the location of the element in the array with the minimum
8910value, or, if the @var{DIM} argument is supplied, determines the
8911locations of the minimum element along each row of the array in the
8912@var{DIM} direction. If @var{MASK} is present, only the elements for
8913which @var{MASK} is @code{.TRUE.} are considered. If more than one
8914element in the array has the minimum value, the location returned is
8915that of the first such element in array element order. If the array has
8916zero size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
8917the result is an array of zeroes. Similarly, if @var{DIM} is supplied
8918and all of the elements of @var{MASK} along a given row are zero, the
8919result value for that row is zero.
8920
a3c4ed23 8921@item @emph{Standard}:
f40b44c0 8922Fortran 95 and later
a3c4ed23 8923
8924@item @emph{Class}:
8925Transformational function
8926
8927@item @emph{Syntax}:
0eb92d52 8928@multitable @columnfractions .80
8929@item @code{RESULT = MINLOC(ARRAY, DIM [, MASK])}
8930@item @code{RESULT = MINLOC(ARRAY [, MASK])}
8931@end multitable
8932
a3c4ed23 8933@item @emph{Arguments}:
aee612a9 8934@multitable @columnfractions .15 .70
38307b08 8935@item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or
8936@code{REAL}.
0eb92d52 8937@item @var{DIM} @tab (Optional) Shall be a scalar of type
c24c5fac 8938@code{INTEGER}, with a value between one and the rank of @var{ARRAY},
8939inclusive. It may not be an optional dummy argument.
e06f8026 8940@item @var{MASK} @tab Shall be an array of type @code{LOGICAL},
c24c5fac 8941and conformable with @var{ARRAY}.
0eb92d52 8942@end multitable
8943
a3c4ed23 8944@item @emph{Return value}:
0eb92d52 8945If @var{DIM} is absent, the result is a rank-one array with a length
8946equal to the rank of @var{ARRAY}. If @var{DIM} is present, the result
8947is an array with a rank one less than the rank of @var{ARRAY}, and a
8948size corresponding to the size of @var{ARRAY} with the @var{DIM}
8949dimension removed. If @var{DIM} is present and @var{ARRAY} has a rank
8950of one, the result is a scalar. In all cases, the result is of default
8951@code{INTEGER} type.
a3c4ed23 8952
8953@item @emph{See also}:
8954@ref{MIN}, @ref{MINVAL}
8955
8956@end table
8957
8958
0eb92d52 8959
a3c4ed23 8960@node MINVAL
8961@section @code{MINVAL} --- Minimum value of an array
a1149005 8962@fnindex MINVAL
bd84e447 8963@cindex array, minimum value
a1149005 8964@cindex minimum value
a3c4ed23 8965
8966@table @asis
8967@item @emph{Description}:
0eb92d52 8968Determines the minimum value of the elements in an array value, or, if
8969the @var{DIM} argument is supplied, determines the minimum value along
8970each row of the array in the @var{DIM} direction. If @var{MASK} is
8971present, only the elements for which @var{MASK} is @code{.TRUE.} are
8972considered. If the array has zero size, or all of the elements of
8973@var{MASK} are @code{.FALSE.}, then the result is @code{HUGE(ARRAY)} if
8974@var{ARRAY} is numeric, or a string of @code{CHAR(255)} characters if
8975@var{ARRAY} is of character type.
8976
a3c4ed23 8977@item @emph{Standard}:
f40b44c0 8978Fortran 95 and later
a3c4ed23 8979
8980@item @emph{Class}:
8981Transformational function
8982
8983@item @emph{Syntax}:
0eb92d52 8984@multitable @columnfractions .80
8985@item @code{RESULT = MINVAL(ARRAY, DIM [, MASK])}
8986@item @code{RESULT = MINVAL(ARRAY [, MASK])}
8987@end multitable
8988
a3c4ed23 8989@item @emph{Arguments}:
aee612a9 8990@multitable @columnfractions .15 .70
38307b08 8991@item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or
8992@code{REAL}.
0eb92d52 8993@item @var{DIM} @tab (Optional) Shall be a scalar of type
c24c5fac 8994@code{INTEGER}, with a value between one and the rank of @var{ARRAY},
8995inclusive. It may not be an optional dummy argument.
e06f8026 8996@item @var{MASK} @tab Shall be an array of type @code{LOGICAL},
c24c5fac 8997and conformable with @var{ARRAY}.
0eb92d52 8998@end multitable
8999
a3c4ed23 9000@item @emph{Return value}:
4eb41f08 9001If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
9002is a scalar. If @var{DIM} is present, the result is an array with a
9003rank one less than the rank of @var{ARRAY}, and a size corresponding to
9004the size of @var{ARRAY} with the @var{DIM} dimension removed. In all
9005cases, the result is of the same type and kind as @var{ARRAY}.
a3c4ed23 9006
9007@item @emph{See also}:
9008@ref{MIN}, @ref{MINLOC}
a3c4ed23 9009
0eb92d52 9010@end table
a3c4ed23 9011
9012
572d7b7f 9013
9014@node MOD
9015@section @code{MOD} --- Remainder function
a1149005 9016@fnindex MOD
9017@fnindex AMOD
9018@fnindex DMOD
572d7b7f 9019@cindex remainder
a1149005 9020@cindex division, remainder
572d7b7f 9021
9022@table @asis
9023@item @emph{Description}:
fa0323b8 9024@code{MOD(A,P)} computes the remainder of the division of A by P@.
572d7b7f 9025
a3c4ed23 9026@item @emph{Standard}:
f40b44c0 9027Fortran 77 and later
572d7b7f 9028
9029@item @emph{Class}:
a3c4ed23 9030Elemental function
572d7b7f 9031
9032@item @emph{Syntax}:
4eb41f08 9033@code{RESULT = MOD(A, P)}
572d7b7f 9034
9035@item @emph{Arguments}:
aee612a9 9036@multitable @columnfractions .15 .70
fa0323b8 9037@item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL}.
9038@item @var{P} @tab Shall be a scalar of the same type and kind as @var{A}
9039and not equal to zero.
572d7b7f 9040@end multitable
9041
9042@item @emph{Return value}:
fa0323b8 9043The return value is the result of @code{A - (INT(A/P) * P)}. The type
9044and kind of the return value is the same as that of the arguments. The
9045returned value has the same sign as A and a magnitude less than the
9046magnitude of P.
572d7b7f 9047
9048@item @emph{Example}:
9049@smallexample
9050program test_mod
9051 print *, mod(17,3)
9052 print *, mod(17.5,5.5)
9053 print *, mod(17.5d0,5.5)
9054 print *, mod(17.5,5.5d0)
9055
9056 print *, mod(-17,3)
9057 print *, mod(-17.5,5.5)
9058 print *, mod(-17.5d0,5.5)
9059 print *, mod(-17.5,5.5d0)
9060
9061 print *, mod(17,-3)
9062 print *, mod(17.5,-5.5)
9063 print *, mod(17.5d0,-5.5)
9064 print *, mod(17.5,-5.5d0)
9065end program test_mod
9066@end smallexample
9067
9068@item @emph{Specific names}:
aee612a9 9069@multitable @columnfractions .20 .20 .20 .25
7d74ce87 9070@item Name @tab Arguments @tab Return type @tab Standard
9071@item @code{MOD(A,P)} @tab @code{INTEGER A,P} @tab @code{INTEGER} @tab Fortran 95 and later
9072@item @code{AMOD(A,P)} @tab @code{REAL(4) A,P} @tab @code{REAL(4)} @tab Fortran 95 and later
9073@item @code{DMOD(A,P)} @tab @code{REAL(8) A,P} @tab @code{REAL(8)} @tab Fortran 95 and later
572d7b7f 9074@end multitable
fa0323b8 9075
9076@item @emph{See also}:
9077@ref{MODULO}
9078
572d7b7f 9079@end table
9080
9081
9082
9083@node MODULO
9084@section @code{MODULO} --- Modulo function
a1149005 9085@fnindex MODULO
572d7b7f 9086@cindex modulo
a1149005 9087@cindex division, modulo
572d7b7f 9088
9089@table @asis
9090@item @emph{Description}:
9091@code{MODULO(A,P)} computes the @var{A} modulo @var{P}.
9092
a3c4ed23 9093@item @emph{Standard}:
f40b44c0 9094Fortran 95 and later
572d7b7f 9095
9096@item @emph{Class}:
a3c4ed23 9097Elemental function
572d7b7f 9098
9099@item @emph{Syntax}:
4eb41f08 9100@code{RESULT = MODULO(A, P)}
572d7b7f 9101
9102@item @emph{Arguments}:
aee612a9 9103@multitable @columnfractions .15 .70
fa0323b8 9104@item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL}.
9105@item @var{P} @tab Shall be a scalar of the same type and kind as @var{A}.
9106It shall not be zero.
572d7b7f 9107@end multitable
9108
9109@item @emph{Return value}:
9110The type and kind of the result are those of the arguments.
9111@table @asis
9112@item If @var{A} and @var{P} are of type @code{INTEGER}:
9113@code{MODULO(A,P)} has the value @var{R} such that @code{A=Q*P+R}, where
9114@var{Q} is an integer and @var{R} is between 0 (inclusive) and @var{P}
9115(exclusive).
9116@item If @var{A} and @var{P} are of type @code{REAL}:
9117@code{MODULO(A,P)} has the value of @code{A - FLOOR (A / P) * P}.
9118@end table
fa0323b8 9119The returned value has the same sign as P and a magnitude less than
9120the magnitude of P.
572d7b7f 9121
9122@item @emph{Example}:
9123@smallexample
a3c4ed23 9124program test_modulo
572d7b7f 9125 print *, modulo(17,3)
9126 print *, modulo(17.5,5.5)
9127
9128 print *, modulo(-17,3)
9129 print *, modulo(-17.5,5.5)
9130
9131 print *, modulo(17,-3)
9132 print *, modulo(17.5,-5.5)
b9f2f128 9133end program
572d7b7f 9134@end smallexample
9135
fa0323b8 9136@item @emph{See also}:
9137@ref{MOD}
9138
572d7b7f 9139@end table
9140
9141
9142
2294b616 9143@node MOVE_ALLOC
9144@section @code{MOVE_ALLOC} --- Move allocation from one object to another
a1149005 9145@fnindex MOVE_ALLOC
5e246457 9146@cindex moving allocation
9147@cindex allocation, moving
2294b616 9148
9149@table @asis
9150@item @emph{Description}:
2cd8ef8b 9151@code{MOVE_ALLOC(FROM, TO)} moves the allocation from @var{FROM} to
9152@var{TO}. @var{FROM} will become deallocated in the process.
2294b616 9153
870fe09f 9154@item @emph{Standard}:
ff4425cf 9155Fortran 2003 and later
2294b616 9156
9157@item @emph{Class}:
45c539d9 9158Pure subroutine
2294b616 9159
9160@item @emph{Syntax}:
2cd8ef8b 9161@code{CALL MOVE_ALLOC(FROM, TO)}
2294b616 9162
9163@item @emph{Arguments}:
aee612a9 9164@multitable @columnfractions .15 .70
2cd8ef8b 9165@item @var{FROM} @tab @code{ALLOCATABLE}, @code{INTENT(INOUT)}, may be
c24c5fac 9166of any type and kind.
2cd8ef8b 9167@item @var{TO} @tab @code{ALLOCATABLE}, @code{INTENT(OUT)}, shall be
9168of the same type, kind and rank as @var{FROM}.
2294b616 9169@end multitable
9170
9171@item @emph{Return value}:
9172None
9173
9174@item @emph{Example}:
9175@smallexample
9176program test_move_alloc
9177 integer, allocatable :: a(:), b(:)
9178
9179 allocate(a(3))
9180 a = [ 1, 2, 3 ]
9181 call move_alloc(a, b)
9182 print *, allocated(a), allocated(b)
9183 print *, b
9184end program test_move_alloc
9185@end smallexample
9186@end table
9187
9188
9189
0eb92d52 9190@node MVBITS
9191@section @code{MVBITS} --- Move bits from one integer to another
a1149005 9192@fnindex MVBITS
9193@cindex bits, move
0eb92d52 9194
9195@table @asis
9196@item @emph{Description}:
9197Moves @var{LEN} bits from positions @var{FROMPOS} through
9198@code{FROMPOS+LEN-1} of @var{FROM} to positions @var{TOPOS} through
9199@code{TOPOS+LEN-1} of @var{TO}. The portion of argument @var{TO} not
9200affected by the movement of bits is unchanged. The values of
9201@code{FROMPOS+LEN-1} and @code{TOPOS+LEN-1} must be less than
9202@code{BIT_SIZE(FROM)}.
9203
9204@item @emph{Standard}:
f40b44c0 9205Fortran 95 and later
0eb92d52 9206
9207@item @emph{Class}:
5dce3893 9208Elemental subroutine
0eb92d52 9209
9210@item @emph{Syntax}:
5dce3893 9211@code{CALL MVBITS(FROM, FROMPOS, LEN, TO, TOPOS)}
0eb92d52 9212
9213@item @emph{Arguments}:
aee612a9 9214@multitable @columnfractions .15 .70
e06f8026 9215@item @var{FROM} @tab The type shall be @code{INTEGER}.
9216@item @var{FROMPOS} @tab The type shall be @code{INTEGER}.
9217@item @var{LEN} @tab The type shall be @code{INTEGER}.
9218@item @var{TO} @tab The type shall be @code{INTEGER}, of the
c24c5fac 9219same kind as @var{FROM}.
e06f8026 9220@item @var{TOPOS} @tab The type shall be @code{INTEGER}.
0eb92d52 9221@end multitable
9222
0eb92d52 9223@item @emph{See also}:
9224@ref{IBCLR}, @ref{IBSET}, @ref{IBITS}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
0eb92d52 9225@end table
9226
9227
9228
572d7b7f 9229@node NEAREST
9230@section @code{NEAREST} --- Nearest representable number
a1149005 9231@fnindex NEAREST
9232@cindex real number, nearest different
9233@cindex floating point, nearest different
572d7b7f 9234
9235@table @asis
9236@item @emph{Description}:
9237@code{NEAREST(X, S)} returns the processor-representable number nearest
9238to @code{X} in the direction indicated by the sign of @code{S}.
9239
a3c4ed23 9240@item @emph{Standard}:
f40b44c0 9241Fortran 95 and later
572d7b7f 9242
9243@item @emph{Class}:
a3c4ed23 9244Elemental function
572d7b7f 9245
9246@item @emph{Syntax}:
4eb41f08 9247@code{RESULT = NEAREST(X, S)}
572d7b7f 9248
9249@item @emph{Arguments}:
aee612a9 9250@multitable @columnfractions .15 .70
e0c54690 9251@item @var{X} @tab Shall be of type @code{REAL}.
572d7b7f 9252@item @var{S} @tab (Optional) shall be of type @code{REAL} and
9253not equal to zero.
9254@end multitable
9255
9256@item @emph{Return value}:
9257The return value is of the same type as @code{X}. If @code{S} is
9258positive, @code{NEAREST} returns the processor-representable number
9259greater than @code{X} and nearest to it. If @code{S} is negative,
9260@code{NEAREST} returns the processor-representable number smaller than
9261@code{X} and nearest to it.
9262
9263@item @emph{Example}:
9264@smallexample
9265program test_nearest
9266 real :: x, y
9267 x = nearest(42.0, 1.0)
9268 y = nearest(42.0, -1.0)
9269 write (*,"(3(G20.15))") x, y, x - y
9270end program test_nearest
9271@end smallexample
9272@end table
9273
9274
9275
f4b3b5f4 9276@node NEW_LINE
9277@section @code{NEW_LINE} --- New line character
a1149005 9278@fnindex NEW_LINE
9279@cindex newline
9280@cindex output, newline
f4b3b5f4 9281
9282@table @asis
9283@item @emph{Description}:
0eb92d52 9284@code{NEW_LINE(C)} returns the new-line character.
f4b3b5f4 9285
9286@item @emph{Standard}:
ff4425cf 9287Fortran 2003 and later
f4b3b5f4 9288
9289@item @emph{Class}:
6e88b72e 9290Inquiry function
f4b3b5f4 9291
9292@item @emph{Syntax}:
4eb41f08 9293@code{RESULT = NEW_LINE(C)}
f4b3b5f4 9294
9295@item @emph{Arguments}:
aee612a9 9296@multitable @columnfractions .15 .70
f4b3b5f4 9297@item @var{C} @tab The argument shall be a scalar or array of the
c24c5fac 9298type @code{CHARACTER}.
f4b3b5f4 9299@end multitable
9300
9301@item @emph{Return value}:
9302Returns a @var{CHARACTER} scalar of length one with the new-line character of
9303the same kind as parameter @var{C}.
9304
9305@item @emph{Example}:
9306@smallexample
9307program newline
9308 implicit none
9309 write(*,'(A)') 'This is record 1.'//NEW_LINE('A')//'This is record 2.'
9310end program newline
9311@end smallexample
9312@end table
9313
9314
9315
572d7b7f 9316@node NINT
9317@section @code{NINT} --- Nearest whole number
a1149005 9318@fnindex NINT
9319@fnindex IDNINT
9320@cindex rounding, nearest whole number
572d7b7f 9321
9322@table @asis
9323@item @emph{Description}:
2cd8ef8b 9324@code{NINT(A)} rounds its argument to the nearest whole number.
572d7b7f 9325
a3c4ed23 9326@item @emph{Standard}:
f40b44c0 9327Fortran 77 and later, with @var{KIND} argument Fortran 90 and later
572d7b7f 9328
9329@item @emph{Class}:
a3c4ed23 9330Elemental function
572d7b7f 9331
9332@item @emph{Syntax}:
2cd8ef8b 9333@code{RESULT = NINT(A [, KIND])}
572d7b7f 9334
9335@item @emph{Arguments}:
aee612a9 9336@multitable @columnfractions .15 .70
2cd8ef8b 9337@item @var{A} @tab The type of the argument shall be @code{REAL}.
f40b44c0 9338@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
c24c5fac 9339expression indicating the kind parameter of the result.
572d7b7f 9340@end multitable
9341
9342@item @emph{Return value}:
9343Returns @var{A} with the fractional portion of its magnitude eliminated by
9344rounding to the nearest whole number and with its sign preserved,
9345converted to an @code{INTEGER} of the default kind.
9346
9347@item @emph{Example}:
9348@smallexample
9349program test_nint
9350 real(4) x4
9351 real(8) x8
9352 x4 = 1.234E0_4
9353 x8 = 4.321_8
9354 print *, nint(x4), idnint(x8)
9355end program test_nint
9356@end smallexample
9357
9358@item @emph{Specific names}:
7d74ce87 9359@multitable @columnfractions .20 .20 .20 .25
9360@item Name @tab Argument @tab Return Type @tab Standard
9361@item @code{NINT(A)} @tab @code{REAL(4) A} @tab @code{INTEGER} @tab Fortran 95 and later
9362@item @code{IDNINT(A)} @tab @code{REAL(8) A} @tab @code{INTEGER} @tab Fortran 95 and later
572d7b7f 9363@end multitable
a3c4ed23 9364
9365@item @emph{See also}:
9366@ref{CEILING}, @ref{FLOOR}
9367
572d7b7f 9368@end table
9369
9370
fe97b755 9371
b4ba8232 9372@node NORM2
9373@section @code{NORM2} --- Euclidean vector norms
9374@fnindex NORM2
9375@cindex Euclidean vector norm
9376@cindex L2 vector norm
9377@cindex norm, Euclidean
9378
9379@table @asis
9380@item @emph{Description}:
5f7aa0fe 9381Calculates the Euclidean vector norm (@math{L_2} norm) of
b4ba8232 9382of @var{ARRAY} along dimension @var{DIM}.
9383
9384@item @emph{Standard}:
9385Fortran 2008 and later
9386
9387@item @emph{Class}:
9388Transformational function
9389
9390@item @emph{Syntax}:
9391@multitable @columnfractions .80
9392@item @code{RESULT = NORM2(ARRAY[, DIM])}
9393@end multitable
9394
9395@item @emph{Arguments}:
9396@multitable @columnfractions .15 .70
9397@item @var{ARRAY} @tab Shall be an array of type @code{REAL}
9398@item @var{DIM} @tab (Optional) shall be a scalar of type
9399@code{INTEGER} with a value in the range from 1 to n, where n
9400equals the rank of @var{ARRAY}.
9401@end multitable
9402
9403@item @emph{Return value}:
9404The result is of the same type as @var{ARRAY}.
9405
9406If @var{DIM} is absent, a scalar with the square root of the sum of all
9407elements in @var{ARRAY} squared is returned. Otherwise, an array of
9408rank @math{n-1}, where @math{n} equals the rank of @var{ARRAY}, and a
9409shape similar to that of @var{ARRAY} with dimension @var{DIM} dropped
9410is returned.
9411
9412@item @emph{Example}:
9413@smallexample
9414PROGRAM test_sum
9415 REAL :: x(5) = [ real :: 1, 2, 3, 4, 5 ]
9416 print *, NORM2(x) ! = sqrt(55.) ~ 7.416
9417END PROGRAM
9418@end smallexample
9419@end table
9420
9421
9422
a3c4ed23 9423@node NOT
9424@section @code{NOT} --- Logical negation
a1149005 9425@fnindex NOT
9426@cindex bits, negate
9427@cindex bitwise logical not
9428@cindex logical not, bitwise
572d7b7f 9429
9430@table @asis
9431@item @emph{Description}:
5f7aa0fe 9432@code{NOT} returns the bitwise Boolean inverse of @var{I}.
0eb92d52 9433
a3c4ed23 9434@item @emph{Standard}:
f40b44c0 9435Fortran 95 and later
572d7b7f 9436
9437@item @emph{Class}:
a3c4ed23 9438Elemental function
572d7b7f 9439
9440@item @emph{Syntax}:
0eb92d52 9441@code{RESULT = NOT(I)}
9442
572d7b7f 9443@item @emph{Arguments}:
aee612a9 9444@multitable @columnfractions .15 .70
e06f8026 9445@item @var{I} @tab The type shall be @code{INTEGER}.
0eb92d52 9446@end multitable
9447
572d7b7f 9448@item @emph{Return value}:
e06f8026 9449The return type is @code{INTEGER}, of the same kind as the
0eb92d52 9450argument.
9451
a3c4ed23 9452@item @emph{See also}:
0eb92d52 9453@ref{IAND}, @ref{IEOR}, @ref{IOR}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}
9454
572d7b7f 9455@end table
9456
9457
9458
a3c4ed23 9459@node NULL
ed8f9044 9460@section @code{NULL} --- Function that returns an disassociated pointer
a1149005 9461@fnindex NULL
9462@cindex pointer, status
9463@cindex pointer, disassociated
572d7b7f 9464
9465@table @asis
9466@item @emph{Description}:
8873d8a6 9467Returns a disassociated pointer.
9468
5f7aa0fe 9469If @var{MOLD} is present, a disassociated pointer of the same type is
8873d8a6 9470returned, otherwise the type is determined by context.
9471
ff4425cf 9472In Fortran 95, @var{MOLD} is optional. Please note that Fortran 2003
9473includes cases where it is required.
8873d8a6 9474
a3c4ed23 9475@item @emph{Standard}:
f40b44c0 9476Fortran 95 and later
572d7b7f 9477
9478@item @emph{Class}:
a3c4ed23 9479Transformational function
572d7b7f 9480
9481@item @emph{Syntax}:
8873d8a6 9482@code{PTR => NULL([MOLD])}
9483
572d7b7f 9484@item @emph{Arguments}:
8873d8a6 9485@multitable @columnfractions .15 .70
9486@item @var{MOLD} @tab (Optional) shall be a pointer of any association
9487status and of any type.
9488@end multitable
9489
572d7b7f 9490@item @emph{Return value}:
8873d8a6 9491A disassociated pointer.
9492
572d7b7f 9493@item @emph{Example}:
8873d8a6 9494@smallexample
9495REAL, POINTER, DIMENSION(:) :: VEC => NULL ()
9496@end smallexample
9497
a3c4ed23 9498@item @emph{See also}:
9499@ref{ASSOCIATED}
572d7b7f 9500@end table
9501
9502
9503
c6cd3066 9504@node NUM_IMAGES
9505@section @code{NUM_IMAGES} --- Function that returns the number of images
9506@fnindex NUM_IMAGES
12786727 9507@cindex coarray, @code{NUM_IMAGES}
c6cd3066 9508@cindex images, number of
9509
9510@table @asis
9511@item @emph{Description}:
9512Returns the number of images.
9513
9514@item @emph{Standard}:
9515Fortran 2008 and later
9516
9517@item @emph{Class}:
9518Transformational function
9519
9520@item @emph{Syntax}:
9521@code{RESULT = NUM_IMAGES()}
9522
9523@item @emph{Arguments}: None.
9524
9525@item @emph{Return value}:
9526Scalar default-kind integer.
9527
9528@item @emph{Example}:
9529@smallexample
9530INTEGER :: value[*]
9531INTEGER :: i
9532value = THIS_IMAGE()
9533SYNC ALL
9534IF (THIS_IMAGE() == 1) THEN
9535 DO i = 1, NUM_IMAGES()
9536 WRITE(*,'(2(a,i0))') 'value[', i, '] is ', value[i]
9537 END DO
9538END IF
9539@end smallexample
9540
9541@item @emph{See also}:
a250d560 9542@ref{THIS_IMAGE}, @ref{IMAGE_INDEX}
c6cd3066 9543@end table
9544
9545
9546
a3c4ed23 9547@node OR
ed8f9044 9548@section @code{OR} --- Bitwise logical OR
a1149005 9549@fnindex OR
9550@cindex bitwise logical or
9551@cindex logical or, bitwise
572d7b7f 9552
9553@table @asis
9554@item @emph{Description}:
ed8f9044 9555Bitwise logical @code{OR}.
9556
9557This intrinsic routine is provided for backwards compatibility with
9558GNU Fortran 77. For integer arguments, programmers should consider
9559the use of the @ref{IOR} intrinsic defined by the Fortran standard.
9560
a3c4ed23 9561@item @emph{Standard}:
ed8f9044 9562GNU extension
572d7b7f 9563
9564@item @emph{Class}:
138b8aca 9565Function
ed8f9044 9566
572d7b7f 9567@item @emph{Syntax}:
2cd8ef8b 9568@code{RESULT = OR(I, J)}
ed8f9044 9569
572d7b7f 9570@item @emph{Arguments}:
aee612a9 9571@multitable @columnfractions .15 .70
2cd8ef8b 9572@item @var{I} @tab The type shall be either a scalar @code{INTEGER}
a48103f3 9573type or a scalar @code{LOGICAL} type.
2cd8ef8b 9574@item @var{J} @tab The type shall be the same as the type of @var{J}.
ed8f9044 9575@end multitable
9576
a3c4ed23 9577@item @emph{Return value}:
e06f8026 9578The return type is either a scalar @code{INTEGER} or a scalar
a48103f3 9579@code{LOGICAL}. If the kind type parameters differ, then the
9580smaller kind type is implicitly converted to larger kind, and the
9581return has the larger kind.
ed8f9044 9582
a3c4ed23 9583@item @emph{Example}:
ed8f9044 9584@smallexample
9585PROGRAM test_or
b9f2f128 9586 LOGICAL :: T = .TRUE., F = .FALSE.
ed8f9044 9587 INTEGER :: a, b
9588 DATA a / Z'F' /, b / Z'3' /
9589
9590 WRITE (*,*) OR(T, T), OR(T, F), OR(F, T), OR(F, F)
9591 WRITE (*,*) OR(a, b)
9592END PROGRAM
9593@end smallexample
9594
a3c4ed23 9595@item @emph{See also}:
f40b44c0 9596Fortran 95 elemental function: @ref{IOR}
a3c4ed23 9597@end table
9598
9599
9600
a3c4ed23 9601@node PACK
9602@section @code{PACK} --- Pack an array into an array of rank one
a1149005 9603@fnindex PACK
9604@cindex array, packing
9605@cindex array, reduce dimension
9606@cindex array, gather elements
a3c4ed23 9607
9608@table @asis
9609@item @emph{Description}:
8873d8a6 9610Stores the elements of @var{ARRAY} in an array of rank one.
9611
9612The beginning of the resulting array is made up of elements whose @var{MASK}
9613equals @code{TRUE}. Afterwards, positions are filled with elements taken from
9614@var{VECTOR}.
9615
a3c4ed23 9616@item @emph{Standard}:
f40b44c0 9617Fortran 95 and later
a3c4ed23 9618
9619@item @emph{Class}:
9620Transformational function
9621
9622@item @emph{Syntax}:
8873d8a6 9623@code{RESULT = PACK(ARRAY, MASK[,VECTOR]}
9624
a3c4ed23 9625@item @emph{Arguments}:
8873d8a6 9626@multitable @columnfractions .15 .70
9627@item @var{ARRAY} @tab Shall be an array of any type.
9628@item @var{MASK} @tab Shall be an array of type @code{LOGICAL} and
9629of the same size as @var{ARRAY}. Alternatively, it may be a @code{LOGICAL}
9630scalar.
9631@item @var{VECTOR} @tab (Optional) shall be an array of the same type
9632as @var{ARRAY} and of rank one. If present, the number of elements in
9633@var{VECTOR} shall be equal to or greater than the number of true elements
9634in @var{MASK}. If @var{MASK} is scalar, the number of elements in
9635@var{VECTOR} shall be equal to or greater than the number of elements in
9636@var{ARRAY}.
9637@end multitable
9638
a3c4ed23 9639@item @emph{Return value}:
8873d8a6 9640The result is an array of rank one and the same type as that of @var{ARRAY}.
9641If @var{VECTOR} is present, the result size is that of @var{VECTOR}, the
9642number of @code{TRUE} values in @var{MASK} otherwise.
9643
a3c4ed23 9644@item @emph{Example}:
a0527218 9645Gathering nonzero elements from an array:
8873d8a6 9646@smallexample
9647PROGRAM test_pack_1
9648 INTEGER :: m(6)
9649 m = (/ 1, 0, 0, 0, 5, 0 /)
9650 WRITE(*, FMT="(6(I0, ' '))") pack(m, m /= 0) ! "1 5"
9651END PROGRAM
9652@end smallexample
9653
a0527218 9654Gathering nonzero elements from an array and appending elements from @var{VECTOR}:
8873d8a6 9655@smallexample
9656PROGRAM test_pack_2
9657 INTEGER :: m(4)
9658 m = (/ 1, 0, 0, 2 /)
9659 WRITE(*, FMT="(4(I0, ' '))") pack(m, m /= 0, (/ 0, 0, 3, 4 /)) ! "1 2 3 4"
9660END PROGRAM
9661@end smallexample
9662
a3c4ed23 9663@item @emph{See also}:
9664@ref{UNPACK}
9665@end table
9666
9667
9668
b4ba8232 9669@node PARITY
9670@section @code{PARITY} --- Reduction with exclusive OR
9671@fnindex PARITY
9672@cindex Parity
9673@cindex Reduction, XOR
9674@cindex XOR reduction
9675
9676@table @asis
9677@item @emph{Description}:
5f7aa0fe 9678Calculates the parity, i.e. the reduction using @code{.XOR.},
b4ba8232 9679of @var{MASK} along dimension @var{DIM}.
9680
9681@item @emph{Standard}:
9682Fortran 2008 and later
9683
9684@item @emph{Class}:
9685Transformational function
9686
9687@item @emph{Syntax}:
9688@multitable @columnfractions .80
9689@item @code{RESULT = PARITY(MASK[, DIM])}
9690@end multitable
9691
9692@item @emph{Arguments}:
9693@multitable @columnfractions .15 .70
9694@item @var{LOGICAL} @tab Shall be an array of type @code{LOGICAL}
9695@item @var{DIM} @tab (Optional) shall be a scalar of type
9696@code{INTEGER} with a value in the range from 1 to n, where n
9697equals the rank of @var{MASK}.
9698@end multitable
9699
9700@item @emph{Return value}:
9701The result is of the same type as @var{MASK}.
9702
9703If @var{DIM} is absent, a scalar with the parity of all elements in
9704@var{MASK} is returned, i.e. true if an odd number of elements is
9705@code{.true.} and false otherwise. If @var{DIM} is present, an array
9706of rank @math{n-1}, where @math{n} equals the rank of @var{ARRAY},
9707and a shape similar to that of @var{MASK} with dimension @var{DIM}
9708dropped is returned.
9709
9710@item @emph{Example}:
9711@smallexample
9712PROGRAM test_sum
9713 LOGICAL :: x(2) = [ .true., .false. ]
9714 print *, PARITY(x) ! prints "T" (true).
9715END PROGRAM
9716@end smallexample
9717@end table
9718
9719
9720
a3c4ed23 9721@node PERROR
9722@section @code{PERROR} --- Print system error message
a1149005 9723@fnindex PERROR
9724@cindex system, error handling
a3c4ed23 9725
9726@table @asis
9727@item @emph{Description}:
0eb92d52 9728Prints (on the C @code{stderr} stream) a newline-terminated error
9729message corresponding to the last system error. This is prefixed by
9730@var{STRING}, a colon and a space. See @code{perror(3)}.
9731
a3c4ed23 9732@item @emph{Standard}:
9733GNU extension
9734
9735@item @emph{Class}:
9736Subroutine
9737
9738@item @emph{Syntax}:
0eb92d52 9739@code{CALL PERROR(STRING)}
9740
a3c4ed23 9741@item @emph{Arguments}:
aee612a9 9742@multitable @columnfractions .15 .70
b44437b9 9743@item @var{STRING} @tab A scalar of type @code{CHARACTER} and of the
9744default kind.
0eb92d52 9745@end multitable
9746
a3c4ed23 9747@item @emph{See also}:
9748@ref{IERRNO}
9749@end table
9750
9751
9752
a3c4ed23 9753@node PRECISION
9754@section @code{PRECISION} --- Decimal precision of a real kind
a1149005 9755@fnindex PRECISION
9756@cindex model representation, precision
a3c4ed23 9757
9758@table @asis
9759@item @emph{Description}:
9760@code{PRECISION(X)} returns the decimal precision in the model of the
9761type of @code{X}.
9762
9763@item @emph{Standard}:
f40b44c0 9764Fortran 95 and later
a3c4ed23 9765
9766@item @emph{Class}:
9767Inquiry function
9768
9769@item @emph{Syntax}:
4eb41f08 9770@code{RESULT = PRECISION(X)}
a3c4ed23 9771
9772@item @emph{Arguments}:
aee612a9 9773@multitable @columnfractions .15 .70
e0c54690 9774@item @var{X} @tab Shall be of type @code{REAL} or @code{COMPLEX}.
a3c4ed23 9775@end multitable
9776
9777@item @emph{Return value}:
9778The return value is of type @code{INTEGER} and of the default integer
9779kind.
9780
1011a9ca 9781@item @emph{See also}:
9782@ref{SELECTED_REAL_KIND}, @ref{RANGE}
9783
a3c4ed23 9784@item @emph{Example}:
9785@smallexample
9786program prec_and_range
9787 real(kind=4) :: x(2)
9788 complex(kind=8) :: y
9789
9790 print *, precision(x), range(x)
9791 print *, precision(y), range(y)
9792end program prec_and_range
9793@end smallexample
9794@end table
9795
9796
9797
41cbc93c 9798@node POPCNT
9799@section @code{POPCNT} --- Number of bits set
9800@fnindex POPCNT
9801@cindex binary representation
9802@cindex bits set
9803
9804@table @asis
9805@item @emph{Description}:
9806@code{POPCNT(I)} returns the number of bits set ('1' bits) in the binary
9807representation of @code{I}.
9808
9809@item @emph{Standard}:
9810Fortran 2008 and later
9811
9812@item @emph{Class}:
9813Elemental function
9814
9815@item @emph{Syntax}:
9816@code{RESULT = POPCNT(I)}
9817
9818@item @emph{Arguments}:
9819@multitable @columnfractions .15 .70
9820@item @var{I} @tab Shall be of type @code{INTEGER}.
9821@end multitable
9822
9823@item @emph{Return value}:
9824The return value is of type @code{INTEGER} and of the default integer
9825kind.
9826
9827@item @emph{See also}:
9828@ref{POPPAR}, @ref{LEADZ}, @ref{TRAILZ}
9829
9830@item @emph{Example}:
9831@smallexample
9832program test_population
9833 print *, popcnt(127), poppar(127)
9834 print *, popcnt(huge(0_4)), poppar(huge(0_4))
9835 print *, popcnt(huge(0_8)), poppar(huge(0_8))
9836end program test_population
9837@end smallexample
9838@end table
9839
9840
9841@node POPPAR
9842@section @code{POPPAR} --- Parity of the number of bits set
9843@fnindex POPPAR
9844@cindex binary representation
9845@cindex parity
9846
9847@table @asis
9848@item @emph{Description}:
9849@code{POPPAR(I)} returns parity of the integer @code{I}, i.e. the parity
9850of the number of bits set ('1' bits) in the binary representation of
9851@code{I}. It is equal to 0 if @code{I} has an even number of bits set,
9852and 1 for an odd number of '1' bits.
9853
9854@item @emph{Standard}:
9855Fortran 2008 and later
9856
9857@item @emph{Class}:
9858Elemental function
9859
9860@item @emph{Syntax}:
9861@code{RESULT = POPPAR(I)}
9862
9863@item @emph{Arguments}:
9864@multitable @columnfractions .15 .70
9865@item @var{I} @tab Shall be of type @code{INTEGER}.
9866@end multitable
9867
9868@item @emph{Return value}:
9869The return value is of type @code{INTEGER} and of the default integer
9870kind.
9871
9872@item @emph{See also}:
9873@ref{POPCNT}, @ref{LEADZ}, @ref{TRAILZ}
9874
9875@item @emph{Example}:
9876@smallexample
9877program test_population
9878 print *, popcnt(127), poppar(127)
9879 print *, popcnt(huge(0_4)), poppar(huge(0_4))
9880 print *, popcnt(huge(0_8)), poppar(huge(0_8))
9881end program test_population
9882@end smallexample
9883@end table
9884
9885
9886
a3c4ed23 9887@node PRESENT
8873d8a6 9888@section @code{PRESENT} --- Determine whether an optional dummy argument is specified
a1149005 9889@fnindex PRESENT
a3c4ed23 9890
9891@table @asis
9892@item @emph{Description}:
8873d8a6 9893Determines whether an optional dummy argument is present.
9894
a3c4ed23 9895@item @emph{Standard}:
f40b44c0 9896Fortran 95 and later
a3c4ed23 9897
9898@item @emph{Class}:
9899Inquiry function
9900
9901@item @emph{Syntax}:
8873d8a6 9902@code{RESULT = PRESENT(A)}
9903
a3c4ed23 9904@item @emph{Arguments}:
8873d8a6 9905@multitable @columnfractions .15 .70
9906@item @var{A} @tab May be of any type and may be a pointer, scalar or array
9907value, or a dummy procedure. It shall be the name of an optional dummy argument
9908accessible within the current subroutine or function.
9909@end multitable
9910
a3c4ed23 9911@item @emph{Return value}:
8873d8a6 9912Returns either @code{TRUE} if the optional argument @var{A} is present, or
9913@code{FALSE} otherwise.
9914
a3c4ed23 9915@item @emph{Example}:
8873d8a6 9916@smallexample
9917PROGRAM test_present
9918 WRITE(*,*) f(), f(42) ! "F T"
9919CONTAINS
9920 LOGICAL FUNCTION f(x)
9921 INTEGER, INTENT(IN), OPTIONAL :: x
9922 f = PRESENT(x)
9923 END FUNCTION
9924END PROGRAM
9925@end smallexample
a3c4ed23 9926@end table
9927
9928
9929
a3c4ed23 9930@node PRODUCT
9931@section @code{PRODUCT} --- Product of array elements
a1149005 9932@fnindex PRODUCT
9933@cindex array, product
9934@cindex array, multiply elements
9935@cindex array, conditionally multiply elements
9936@cindex multiply array elements
a3c4ed23 9937
9938@table @asis
9939@item @emph{Description}:
c3faa3c9 9940Multiplies the elements of @var{ARRAY} along dimension @var{DIM} if
9941the corresponding element in @var{MASK} is @code{TRUE}.
9942
a3c4ed23 9943@item @emph{Standard}:
f40b44c0 9944Fortran 95 and later
a3c4ed23 9945
9946@item @emph{Class}:
9947Transformational function
9948
9949@item @emph{Syntax}:
2cd8ef8b 9950@multitable @columnfractions .80
9951@item @code{RESULT = PRODUCT(ARRAY[, MASK])}
9952@item @code{RESULT = PRODUCT(ARRAY, DIM[, MASK])}
9953@end multitable
c3faa3c9 9954
a3c4ed23 9955@item @emph{Arguments}:
c3faa3c9 9956@multitable @columnfractions .15 .70
e06f8026 9957@item @var{ARRAY} @tab Shall be an array of type @code{INTEGER},
9958@code{REAL} or @code{COMPLEX}.
c3faa3c9 9959@item @var{DIM} @tab (Optional) shall be a scalar of type
9960@code{INTEGER} with a value in the range from 1 to n, where n
9961equals the rank of @var{ARRAY}.
9962@item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL}
9963and either be a scalar or an array of the same shape as @var{ARRAY}.
9964@end multitable
9965
a3c4ed23 9966@item @emph{Return value}:
c3faa3c9 9967The result is of the same type as @var{ARRAY}.
9968
9969If @var{DIM} is absent, a scalar with the product of all elements in
9970@var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals
9971the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with
9972dimension @var{DIM} dropped is returned.
9973
9974
a3c4ed23 9975@item @emph{Example}:
c3faa3c9 9976@smallexample
9977PROGRAM test_product
9978 INTEGER :: x(5) = (/ 1, 2, 3, 4 ,5 /)
9979 print *, PRODUCT(x) ! all elements, product = 120
9980 print *, PRODUCT(x, MASK=MOD(x, 2)==1) ! odd elements, product = 15
9981END PROGRAM
9982@end smallexample
9983
a3c4ed23 9984@item @emph{See also}:
9985@ref{SUM}
9986@end table
9987
9988
9989
a3c4ed23 9990@node RADIX
9991@section @code{RADIX} --- Base of a model number
a1149005 9992@fnindex RADIX
9993@cindex model representation, base
9994@cindex model representation, radix
a3c4ed23 9995
9996@table @asis
9997@item @emph{Description}:
9998@code{RADIX(X)} returns the base of the model representing the entity @var{X}.
9999
10000@item @emph{Standard}:
f40b44c0 10001Fortran 95 and later
a3c4ed23 10002
10003@item @emph{Class}:
10004Inquiry function
10005
10006@item @emph{Syntax}:
4eb41f08 10007@code{RESULT = RADIX(X)}
a3c4ed23 10008
10009@item @emph{Arguments}:
aee612a9 10010@multitable @columnfractions .15 .70
a3c4ed23 10011@item @var{X} @tab Shall be of type @code{INTEGER} or @code{REAL}
10012@end multitable
10013
10014@item @emph{Return value}:
10015The return value is a scalar of type @code{INTEGER} and of the default
10016integer kind.
10017
1011a9ca 10018@item @emph{See also}:
10019@ref{SELECTED_REAL_KIND}
10020
a3c4ed23 10021@item @emph{Example}:
10022@smallexample
10023program test_radix
10024 print *, "The radix for the default integer kind is", radix(0)
10025 print *, "The radix for the default real kind is", radix(0.0)
10026end program test_radix
10027@end smallexample
10028
10029@end table
10030
10031
10032
0eb92d52 10033@node RAN
10034@section @code{RAN} --- Real pseudo-random number
a1149005 10035@fnindex RAN
10036@cindex random number generation
a3c4ed23 10037
a3c4ed23 10038@table @asis
10039@item @emph{Description}:
0eb92d52 10040For compatibility with HP FORTRAN 77/iX, the @code{RAN} intrinsic is
10041provided as an alias for @code{RAND}. See @ref{RAND} for complete
10042documentation.
a3c4ed23 10043
a3c4ed23 10044@item @emph{Standard}:
0eb92d52 10045GNU extension
a3c4ed23 10046
10047@item @emph{Class}:
138b8aca 10048Function
a3c4ed23 10049
a3c4ed23 10050@item @emph{See also}:
0eb92d52 10051@ref{RAND}, @ref{RANDOM_NUMBER}
a3c4ed23 10052@end table
10053
10054
10055
a3c4ed23 10056@node RAND
10057@section @code{RAND} --- Real pseudo-random number
a1149005 10058@fnindex RAND
10059@cindex random number generation
a3c4ed23 10060
10061@table @asis
10062@item @emph{Description}:
10063@code{RAND(FLAG)} returns a pseudo-random number from a uniform
10064distribution between 0 and 1. If @var{FLAG} is 0, the next number
10065in the current sequence is returned; if @var{FLAG} is 1, the generator
10066is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
10067it is used as a new seed with @code{SRAND}.
10068
855b3d32 10069This intrinsic routine is provided for backwards compatibility with
10070GNU Fortran 77. It implements a simple modulo generator as provided
10071by @command{g77}. For new code, one should consider the use of
10072@ref{RANDOM_NUMBER} as it implements a superior algorithm.
10073
a3c4ed23 10074@item @emph{Standard}:
10075GNU extension
10076
10077@item @emph{Class}:
138b8aca 10078Function
a3c4ed23 10079
10080@item @emph{Syntax}:
2cd8ef8b 10081@code{RESULT = RAND(I)}
a3c4ed23 10082
10083@item @emph{Arguments}:
aee612a9 10084@multitable @columnfractions .15 .70
2cd8ef8b 10085@item @var{I} @tab Shall be a scalar @code{INTEGER} of kind 4.
a3c4ed23 10086@end multitable
572d7b7f 10087
10088@item @emph{Return value}:
10089The return value is of @code{REAL} type and the default kind.
10090
10091@item @emph{Example}:
10092@smallexample
10093program test_rand
10094 integer,parameter :: seed = 86456
10095
10096 call srand(seed)
10097 print *, rand(), rand(), rand(), rand()
10098 print *, rand(seed), rand(), rand(), rand()
10099end program test_rand
10100@end smallexample
10101
a3c4ed23 10102@item @emph{See also}:
10103@ref{SRAND}, @ref{RANDOM_NUMBER}
10104
572d7b7f 10105@end table
10106
10107
10108
0eb92d52 10109@node RANDOM_NUMBER
10110@section @code{RANDOM_NUMBER} --- Pseudo-random number
a1149005 10111@fnindex RANDOM_NUMBER
10112@cindex random number generation
0eb92d52 10113
0eb92d52 10114@table @asis
10115@item @emph{Description}:
7ccb40ab 10116Returns a single pseudorandom number or an array of pseudorandom numbers
10117from the uniform distribution over the range @math{ 0 \leq x < 1}.
10118
855b3d32 10119The runtime-library implements George Marsaglia's KISS (Keep It Simple
10120Stupid) random number generator (RNG). This RNG combines:
10121@enumerate
10122@item The congruential generator @math{x(n) = 69069 \cdot x(n-1) + 1327217885}
10123with a period of @math{2^{32}},
10124@item A 3-shift shift-register generator with a period of @math{2^{32} - 1},
10125@item Two 16-bit multiply-with-carry generators with a period of
10126@math{597273182964842497 > 2^{59}}.
10127@end enumerate
10128The overall period exceeds @math{2^{123}}.
10129
10130Please note, this RNG is thread safe if used within OpenMP directives,
2dd2bcbd 10131i.e., its state will be consistent while called from multiple threads.
855b3d32 10132However, the KISS generator does not create random numbers in parallel
10133from multiple sources, but in sequence from a single source. If an
10134OpenMP-enabled application heavily relies on random numbers, one should
10135consider employing a dedicated parallel random number generator instead.
10136
0eb92d52 10137@item @emph{Standard}:
f40b44c0 10138Fortran 95 and later
0eb92d52 10139
10140@item @emph{Class}:
5dce3893 10141Subroutine
0eb92d52 10142
10143@item @emph{Syntax}:
7ccb40ab 10144@code{RANDOM_NUMBER(HARVEST)}
10145
0eb92d52 10146@item @emph{Arguments}:
7ccb40ab 10147@multitable @columnfractions .15 .70
e06f8026 10148@item @var{HARVEST} @tab Shall be a scalar or an array of type @code{REAL}.
7ccb40ab 10149@end multitable
10150
0eb92d52 10151@item @emph{Example}:
7ccb40ab 10152@smallexample
10153program test_random_number
10154 REAL :: r(5,5)
10155 CALL init_random_seed() ! see example of RANDOM_SEED
10156 CALL RANDOM_NUMBER(r)
10157end program
10158@end smallexample
10159
0eb92d52 10160@item @emph{See also}:
10161@ref{RANDOM_SEED}
10162@end table
10163
10164
10165
10166@node RANDOM_SEED
10167@section @code{RANDOM_SEED} --- Initialize a pseudo-random number sequence
a1149005 10168@fnindex RANDOM_SEED
10169@cindex random number generation, seeding
10170@cindex seeding a random number generator
0eb92d52 10171
0eb92d52 10172@table @asis
10173@item @emph{Description}:
7ccb40ab 10174Restarts or queries the state of the pseudorandom number generator used by
10175@code{RANDOM_NUMBER}.
10176
10177If @code{RANDOM_SEED} is called without arguments, it is initialized to
10178a default state. The example below shows how to initialize the random
10179seed based on the system's time.
10180
0eb92d52 10181@item @emph{Standard}:
f40b44c0 10182Fortran 95 and later
0eb92d52 10183
10184@item @emph{Class}:
10185Subroutine
10186
10187@item @emph{Syntax}:
2cd8ef8b 10188@code{CALL RANDOM_SEED([SIZE, PUT, GET])}
7ccb40ab 10189
0eb92d52 10190@item @emph{Arguments}:
7ccb40ab 10191@multitable @columnfractions .15 .70
10192@item @var{SIZE} @tab (Optional) Shall be a scalar and of type default
10193@code{INTEGER}, with @code{INTENT(OUT)}. It specifies the minimum size
10194of the arrays used with the @var{PUT} and @var{GET} arguments.
10195@item @var{PUT} @tab (Optional) Shall be an array of type default
10196@code{INTEGER} and rank one. It is @code{INTENT(IN)} and the size of
10197the array must be larger than or equal to the number returned by the
10198@var{SIZE} argument.
10199@item @var{GET} @tab (Optional) Shall be an array of type default
10200@code{INTEGER} and rank one. It is @code{INTENT(OUT)} and the size
10201of the array must be larger than or equal to the number returned by
10202the @var{SIZE} argument.
10203@end multitable
10204
0eb92d52 10205@item @emph{Example}:
7ccb40ab 10206@smallexample
10207SUBROUTINE init_random_seed()
10208 INTEGER :: i, n, clock
10209 INTEGER, DIMENSION(:), ALLOCATABLE :: seed
10210
10211 CALL RANDOM_SEED(size = n)
10212 ALLOCATE(seed(n))
10213
10214 CALL SYSTEM_CLOCK(COUNT=clock)
10215
10216 seed = clock + 37 * (/ (i - 1, i = 1, n) /)
10217 CALL RANDOM_SEED(PUT = seed)
10218
10219 DEALLOCATE(seed)
10220END SUBROUTINE
10221@end smallexample
10222
0eb92d52 10223@item @emph{See also}:
10224@ref{RANDOM_NUMBER}
10225@end table
10226
10227
10228
572d7b7f 10229@node RANGE
67bc85bf 10230@section @code{RANGE} --- Decimal exponent range
a1149005 10231@fnindex RANGE
10232@cindex model representation, range
572d7b7f 10233
10234@table @asis
10235@item @emph{Description}:
10236@code{RANGE(X)} returns the decimal exponent range in the model of the
10237type of @code{X}.
10238
a3c4ed23 10239@item @emph{Standard}:
f40b44c0 10240Fortran 95 and later
572d7b7f 10241
10242@item @emph{Class}:
a3c4ed23 10243Inquiry function
572d7b7f 10244
10245@item @emph{Syntax}:
4eb41f08 10246@code{RESULT = RANGE(X)}
572d7b7f 10247
10248@item @emph{Arguments}:
aee612a9 10249@multitable @columnfractions .15 .70
67bc85bf 10250@item @var{X} @tab Shall be of type @code{INTEGER}, @code{REAL}
10251or @code{COMPLEX}.
572d7b7f 10252@end multitable
10253
10254@item @emph{Return value}:
10255The return value is of type @code{INTEGER} and of the default integer
10256kind.
10257
1011a9ca 10258@item @emph{See also}:
10259@ref{SELECTED_REAL_KIND}, @ref{PRECISION}
10260
572d7b7f 10261@item @emph{Example}:
10262See @code{PRECISION} for an example.
10263@end table
10264
10265
10266
b3a2ccd7 10267@node RANK
10268@section @code{RANK} --- Rank of a data object
10269@fnindex RANK
10270@cindex rank
10271
10272@table @asis
10273@item @emph{Description}:
10274@code{RANK(A)} returns the rank of a scalar or array data object.
10275
10276@item @emph{Standard}:
d976af8e 10277Technical Specification (TS) 29113
b3a2ccd7 10278
10279@item @emph{Class}:
10280Inquiry function
10281
10282@item @emph{Syntax}:
10283@code{RESULT = RANGE(A)}
10284
10285@item @emph{Arguments}:
10286@multitable @columnfractions .15 .70
10287@item @var{A} @tab can be of any type
10288@end multitable
10289
10290@item @emph{Return value}:
10291The return value is of type @code{INTEGER} and of the default integer
10292kind. For arrays, their rank is returned; for scalars zero is returned.
10293
10294@item @emph{Example}:
10295@smallexample
10296program test_rank
10297 integer :: a
10298 real, allocatable :: b(:,:)
10299
10300 print *, rank(a), rank(b) ! Prints: 0 3
10301end program test_rank
10302@end smallexample
10303
10304@end table
10305
10306
10307
572d7b7f 10308@node REAL
10309@section @code{REAL} --- Convert to real type
a1149005 10310@fnindex REAL
10311@fnindex REALPART
b53b53b4 10312@fnindex FLOAT
10313@fnindex DFLOAT
10314@fnindex SNGL
a1149005 10315@cindex conversion, to real
10316@cindex complex numbers, real part
572d7b7f 10317
10318@table @asis
10319@item @emph{Description}:
2cd8ef8b 10320@code{REAL(A [, KIND])} converts its argument @var{A} to a real type. The
10321@code{REALPART} function is provided for compatibility with @command{g77},
572d7b7f 10322and its use is strongly discouraged.
10323
a3c4ed23 10324@item @emph{Standard}:
f40b44c0 10325Fortran 77 and later
572d7b7f 10326
10327@item @emph{Class}:
a3c4ed23 10328Elemental function
572d7b7f 10329
10330@item @emph{Syntax}:
aee612a9 10331@multitable @columnfractions .80
2cd8ef8b 10332@item @code{RESULT = REAL(A [, KIND])}
4eb41f08 10333@item @code{RESULT = REALPART(Z)}
572d7b7f 10334@end multitable
10335
10336@item @emph{Arguments}:
aee612a9 10337@multitable @columnfractions .15 .70
2cd8ef8b 10338@item @var{A} @tab Shall be @code{INTEGER}, @code{REAL}, or
c24c5fac 10339@code{COMPLEX}.
e06f8026 10340@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
c24c5fac 10341expression indicating the kind parameter of the result.
572d7b7f 10342@end multitable
10343
10344@item @emph{Return value}:
e06f8026 10345These functions return a @code{REAL} variable or array under
572d7b7f 10346the following rules:
10347
10348@table @asis
10349@item (A)
2cd8ef8b 10350@code{REAL(A)} is converted to a default real type if @var{A} is an
572d7b7f 10351integer or real variable.
10352@item (B)
2cd8ef8b 10353@code{REAL(A)} is converted to a real type with the kind type parameter
10354of @var{A} if @var{A} is a complex variable.
572d7b7f 10355@item (C)
2cd8ef8b 10356@code{REAL(A, KIND)} is converted to a real type with kind type
10357parameter @var{KIND} if @var{A} is a complex, integer, or real
572d7b7f 10358variable.
10359@end table
10360
10361@item @emph{Example}:
10362@smallexample
10363program test_real
10364 complex :: x = (1.0, 2.0)
10365 print *, real(x), real(x,8), realpart(x)
10366end program test_real
10367@end smallexample
a3c4ed23 10368
7d74ce87 10369@item @emph{Specific names}:
10370@multitable @columnfractions .20 .20 .20 .25
b53b53b4 10371@item Name @tab Argument @tab Return type @tab Standard
10372@item @code{FLOAT(A)} @tab @code{INTEGER(4)} @tab @code{REAL(4)} @tab Fortran 77 and later
10373@item @code{DFLOAT(A)} @tab @code{INTEGER(4)} @tab @code{REAL(8)} @tab GNU extension
10374@item @code{SNGL(A)} @tab @code{INTEGER(8)} @tab @code{REAL(4)} @tab Fortran 77 and later
7d74ce87 10375@end multitable
10376
10377
a3c4ed23 10378@item @emph{See also}:
b53b53b4 10379@ref{DBLE}
a3c4ed23 10380
10381@end table
10382
10383
0eb92d52 10384
a3c4ed23 10385@node RENAME
10386@section @code{RENAME} --- Rename a file
a1149005 10387@fnindex RENAME
10388@cindex file system, rename file
a3c4ed23 10389
a3c4ed23 10390@table @asis
10391@item @emph{Description}:
0eb92d52 10392Renames a file from file @var{PATH1} to @var{PATH2}. A null
10393character (@code{CHAR(0)}) can be used to mark the end of the names in
10394@var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
10395names are ignored. If the @var{STATUS} argument is supplied, it
10396contains 0 on success or a nonzero error code upon return; see
10397@code{rename(2)}.
10398
31eea2fc 10399This intrinsic is provided in both subroutine and function forms;
10400however, only one form can be used in any given program unit.
10401
a3c4ed23 10402@item @emph{Standard}:
10403GNU extension
10404
10405@item @emph{Class}:
138b8aca 10406Subroutine, function
a3c4ed23 10407
10408@item @emph{Syntax}:
31eea2fc 10409@multitable @columnfractions .80
10410@item @code{CALL RENAME(PATH1, PATH2 [, STATUS])}
10411@item @code{STATUS = RENAME(PATH1, PATH2)}
10412@end multitable
0eb92d52 10413
a3c4ed23 10414@item @emph{Arguments}:
aee612a9 10415@multitable @columnfractions .15 .70
0eb92d52 10416@item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
10417@item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
10418@item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
10419@end multitable
10420
a3c4ed23 10421@item @emph{See also}:
0eb92d52 10422@ref{LINK}
a3c4ed23 10423
0eb92d52 10424@end table
a3c4ed23 10425
10426
10427
10428@node REPEAT
10429@section @code{REPEAT} --- Repeated string concatenation
a1149005 10430@fnindex REPEAT
10431@cindex string, repeat
10432@cindex string, concatenate
a3c4ed23 10433
a3c4ed23 10434@table @asis
10435@item @emph{Description}:
8873d8a6 10436Concatenates @var{NCOPIES} copies of a string.
10437
a3c4ed23 10438@item @emph{Standard}:
f40b44c0 10439Fortran 95 and later
a3c4ed23 10440
10441@item @emph{Class}:
10442Transformational function
10443
10444@item @emph{Syntax}:
8873d8a6 10445@code{RESULT = REPEAT(STRING, NCOPIES)}
10446
a3c4ed23 10447@item @emph{Arguments}:
8873d8a6 10448@multitable @columnfractions .15 .70
e06f8026 10449@item @var{STRING} @tab Shall be scalar and of type @code{CHARACTER}.
10450@item @var{NCOPIES} @tab Shall be scalar and of type @code{INTEGER}.
8873d8a6 10451@end multitable
10452
a3c4ed23 10453@item @emph{Return value}:
8873d8a6 10454A new scalar of type @code{CHARACTER} built up from @var{NCOPIES} copies
10455of @var{STRING}.
10456
a3c4ed23 10457@item @emph{Example}:
8873d8a6 10458@smallexample
10459program test_repeat
10460 write(*,*) repeat("x", 5) ! "xxxxx"
10461end program
10462@end smallexample
a3c4ed23 10463@end table
10464
10465
10466
a3c4ed23 10467@node RESHAPE
10468@section @code{RESHAPE} --- Function to reshape an array
a1149005 10469@fnindex RESHAPE
10470@cindex array, change dimensions
10471@cindex array, transmogrify
a3c4ed23 10472
a3c4ed23 10473@table @asis
10474@item @emph{Description}:
c3faa3c9 10475Reshapes @var{SOURCE} to correspond to @var{SHAPE}. If necessary,
10476the new array may be padded with elements from @var{PAD} or permuted
10477as defined by @var{ORDER}.
10478
a3c4ed23 10479@item @emph{Standard}:
f40b44c0 10480Fortran 95 and later
a3c4ed23 10481
10482@item @emph{Class}:
10483Transformational function
10484
10485@item @emph{Syntax}:
c3faa3c9 10486@code{RESULT = RESHAPE(SOURCE, SHAPE[, PAD, ORDER])}
10487
a3c4ed23 10488@item @emph{Arguments}:
c3faa3c9 10489@multitable @columnfractions .15 .70
10490@item @var{SOURCE} @tab Shall be an array of any type.
10491@item @var{SHAPE} @tab Shall be of type @code{INTEGER} and an
10492array of rank one. Its values must be positive or zero.
10493@item @var{PAD} @tab (Optional) shall be an array of the same
10494type as @var{SOURCE}.
10495@item @var{ORDER} @tab (Optional) shall be of type @code{INTEGER}
10496and an array of the same shape as @var{SHAPE}. Its values shall
10497be a permutation of the numbers from 1 to n, where n is the size of
10498@var{SHAPE}. If @var{ORDER} is absent, the natural ordering shall
10499be assumed.
10500@end multitable
10501
a3c4ed23 10502@item @emph{Return value}:
c3faa3c9 10503The result is an array of shape @var{SHAPE} with the same type as
10504@var{SOURCE}.
10505
a3c4ed23 10506@item @emph{Example}:
c3faa3c9 10507@smallexample
10508PROGRAM test_reshape
10509 INTEGER, DIMENSION(4) :: x
10510 WRITE(*,*) SHAPE(x) ! prints "4"
10511 WRITE(*,*) SHAPE(RESHAPE(x, (/2, 2/))) ! prints "2 2"
10512END PROGRAM
10513@end smallexample
10514
a3c4ed23 10515@item @emph{See also}:
c3faa3c9 10516@ref{SHAPE}
572d7b7f 10517@end table
10518
10519
10520
10521@node RRSPACING
10522@section @code{RRSPACING} --- Reciprocal of the relative spacing
a1149005 10523@fnindex RRSPACING
10524@cindex real number, relative spacing
10525@cindex floating point, relative spacing
10526
572d7b7f 10527
10528@table @asis
10529@item @emph{Description}:
10530@code{RRSPACING(X)} returns the reciprocal of the relative spacing of
10531model numbers near @var{X}.
10532
a3c4ed23 10533@item @emph{Standard}:
f40b44c0 10534Fortran 95 and later
572d7b7f 10535
10536@item @emph{Class}:
a3c4ed23 10537Elemental function
572d7b7f 10538
10539@item @emph{Syntax}:
4eb41f08 10540@code{RESULT = RRSPACING(X)}
572d7b7f 10541
10542@item @emph{Arguments}:
aee612a9 10543@multitable @columnfractions .15 .70
e0c54690 10544@item @var{X} @tab Shall be of type @code{REAL}.
572d7b7f 10545@end multitable
10546
10547@item @emph{Return value}:
10548The return value is of the same type and kind as @var{X}.
10549The value returned is equal to
10550@code{ABS(FRACTION(X)) * FLOAT(RADIX(X))**DIGITS(X)}.
10551
c3faa3c9 10552@item @emph{See also}:
10553@ref{SPACING}
572d7b7f 10554@end table
10555
10556
10557
a3c4ed23 10558@node RSHIFT
10559@section @code{RSHIFT} --- Right shift bits
a1149005 10560@fnindex RSHIFT
10561@cindex bits, shift right
a3c4ed23 10562
a3c4ed23 10563@table @asis
10564@item @emph{Description}:
0eb92d52 10565@code{RSHIFT} returns a value corresponding to @var{I} with all of the
10566bits shifted right by @var{SHIFT} places. If the absolute value of
15da0ca7 10567@var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
10568Bits shifted out from the right end are lost. The fill is arithmetic: the
10569bits shifted in from the left end are equal to the leftmost bit, which in
10570two's complement representation is the sign bit.
0eb92d52 10571
f004c7aa 10572This function has been superseded by the @code{SHIFTA} intrinsic, which
10573is standard in Fortran 2008 and later.
a3c4ed23 10574
10575@item @emph{Standard}:
10576GNU extension
10577
10578@item @emph{Class}:
0eb92d52 10579Elemental function
a3c4ed23 10580
10581@item @emph{Syntax}:
0eb92d52 10582@code{RESULT = RSHIFT(I, SHIFT)}
10583
a3c4ed23 10584@item @emph{Arguments}:
aee612a9 10585@multitable @columnfractions .15 .70
e06f8026 10586@item @var{I} @tab The type shall be @code{INTEGER}.
10587@item @var{SHIFT} @tab The type shall be @code{INTEGER}.
0eb92d52 10588@end multitable
10589
a3c4ed23 10590@item @emph{Return value}:
e06f8026 10591The return value is of type @code{INTEGER} and of the same kind as
0eb92d52 10592@var{I}.
10593
a3c4ed23 10594@item @emph{See also}:
f004c7aa 10595@ref{ISHFT}, @ref{ISHFTC}, @ref{LSHIFT}, @ref{SHIFTA}, @ref{SHIFTR},
10596@ref{SHIFTL}
a3c4ed23 10597
10598@end table
10599
10600
10601
24c079ad 10602@node SAME_TYPE_AS
10603@section @code{SAME_TYPE_AS} --- Query dynamic types for equality
10604@fnindex SAME_TYPE_AS
10605
10606@table @asis
10607@item @emph{Description}:
10608Query dynamic types for equality.
10609
10610@item @emph{Standard}:
10611Fortran 2003 and later
10612
10613@item @emph{Class}:
10614Inquiry function
10615
10616@item @emph{Syntax}:
10617@code{RESULT = SAME_TYPE_AS(A, B)}
10618
10619@item @emph{Arguments}:
10620@multitable @columnfractions .15 .70
10621@item @var{A} @tab Shall be an object of extensible declared type or
10622unlimited polymorphic.
10623@item @var{B} @tab Shall be an object of extensible declared type or
10624unlimited polymorphic.
10625@end multitable
10626
10627@item @emph{Return value}:
10628The return value is a scalar of type default logical. It is true if and
10629only if the dynamic type of A is the same as the dynamic type of B.
10630
10631@item @emph{See also}:
10632@ref{EXTENDS_TYPE_OF}
10633
10634@end table
10635
10636
10637
572d7b7f 10638@node SCALE
10639@section @code{SCALE} --- Scale a real value
a1149005 10640@fnindex SCALE
10641@cindex real number, scale
10642@cindex floating point, scale
572d7b7f 10643
10644@table @asis
10645@item @emph{Description}:
10646@code{SCALE(X,I)} returns @code{X * RADIX(X)**I}.
10647
a3c4ed23 10648@item @emph{Standard}:
f40b44c0 10649Fortran 95 and later
572d7b7f 10650
10651@item @emph{Class}:
a3c4ed23 10652Elemental function
572d7b7f 10653
10654@item @emph{Syntax}:
4eb41f08 10655@code{RESULT = SCALE(X, I)}
572d7b7f 10656
10657@item @emph{Arguments}:
aee612a9 10658@multitable @columnfractions .15 .70
572d7b7f 10659@item @var{X} @tab The type of the argument shall be a @code{REAL}.
10660@item @var{I} @tab The type of the argument shall be a @code{INTEGER}.
10661@end multitable
10662
10663@item @emph{Return value}:
10664The return value is of the same type and kind as @var{X}.
10665Its value is @code{X * RADIX(X)**I}.
10666
10667@item @emph{Example}:
10668@smallexample
10669program test_scale
10670 real :: x = 178.1387e-4
10671 integer :: i = 5
10672 print *, scale(x,i), x*radix(x)**i
10673end program test_scale
10674@end smallexample
a3c4ed23 10675
10676@end table
10677
10678
fe97b755 10679
a3c4ed23 10680@node SCAN
10681@section @code{SCAN} --- Scan a string for the presence of a set of characters
a1149005 10682@fnindex SCAN
10683@cindex string, find subset
a3c4ed23 10684
a3c4ed23 10685@table @asis
10686@item @emph{Description}:
8873d8a6 10687Scans a @var{STRING} for any of the characters in a @var{SET}
10688of characters.
10689
10690If @var{BACK} is either absent or equals @code{FALSE}, this function
10691returns the position of the leftmost character of @var{STRING} that is
10692in @var{SET}. If @var{BACK} equals @code{TRUE}, the rightmost position
10693is returned. If no character of @var{SET} is found in @var{STRING}, the
10694result is zero.
10695
a3c4ed23 10696@item @emph{Standard}:
f40b44c0 10697Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
a3c4ed23 10698
10699@item @emph{Class}:
10700Elemental function
10701
10702@item @emph{Syntax}:
7fe55cc9 10703@code{RESULT = SCAN(STRING, SET[, BACK [, KIND]])}
8873d8a6 10704
a3c4ed23 10705@item @emph{Arguments}:
8873d8a6 10706@multitable @columnfractions .15 .70
e06f8026 10707@item @var{STRING} @tab Shall be of type @code{CHARACTER}.
10708@item @var{SET} @tab Shall be of type @code{CHARACTER}.
8873d8a6 10709@item @var{BACK} @tab (Optional) shall be of type @code{LOGICAL}.
7fe55cc9 10710@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
c24c5fac 10711expression indicating the kind parameter of the result.
8873d8a6 10712@end multitable
10713
a3c4ed23 10714@item @emph{Return value}:
7fe55cc9 10715The return value is of type @code{INTEGER} and of kind @var{KIND}. If
10716@var{KIND} is absent, the return value is of default integer kind.
8873d8a6 10717
a3c4ed23 10718@item @emph{Example}:
8873d8a6 10719@smallexample
10720PROGRAM test_scan
10721 WRITE(*,*) SCAN("FORTRAN", "AO") ! 2, found 'O'
10722 WRITE(*,*) SCAN("FORTRAN", "AO", .TRUE.) ! 6, found 'A'
10723 WRITE(*,*) SCAN("FORTRAN", "C++") ! 0, found none
10724END PROGRAM
10725@end smallexample
10726
a3c4ed23 10727@item @emph{See also}:
70dabb1d 10728@ref{INDEX intrinsic}, @ref{VERIFY}
a3c4ed23 10729@end table
10730
10731
10732
a3c4ed23 10733@node SECNDS
10734@section @code{SECNDS} --- Time function
a1149005 10735@fnindex SECNDS
10736@cindex time, elapsed
10737@cindex elapsed time
a3c4ed23 10738
10739@table @asis
10740@item @emph{Description}:
10741@code{SECNDS(X)} gets the time in seconds from the real-time system clock.
10742@var{X} is a reference time, also in seconds. If this is zero, the time in
10743seconds from midnight is returned. This function is non-standard and its
10744use is discouraged.
10745
10746@item @emph{Standard}:
10747GNU extension
10748
10749@item @emph{Class}:
138b8aca 10750Function
a3c4ed23 10751
10752@item @emph{Syntax}:
4eb41f08 10753@code{RESULT = SECNDS (X)}
a3c4ed23 10754
10755@item @emph{Arguments}:
aee612a9 10756@multitable @columnfractions .15 .70
fe97b755 10757@item @var{T} @tab Shall be of type @code{REAL(4)}.
10758@item @var{X} @tab Shall be of type @code{REAL(4)}.
a3c4ed23 10759@end multitable
10760
10761@item @emph{Return value}:
10762None
10763
10764@item @emph{Example}:
10765@smallexample
10766program test_secnds
a1149005 10767 integer :: i
a3c4ed23 10768 real(4) :: t1, t2
10769 print *, secnds (0.0) ! seconds since midnight
10770 t1 = secnds (0.0) ! reference time
10771 do i = 1, 10000000 ! do something
10772 end do
10773 t2 = secnds (t1) ! elapsed time
10774 print *, "Something took ", t2, " seconds."
10775end program test_secnds
10776@end smallexample
572d7b7f 10777@end table
10778
10779
10780
fe97b755 10781@node SECOND
10782@section @code{SECOND} --- CPU time function
a1149005 10783@fnindex SECOND
fe97b755 10784@cindex time, elapsed
10785@cindex elapsed time
10786
10787@table @asis
10788@item @emph{Description}:
10789Returns a @code{REAL(4)} value representing the elapsed CPU time in
10790seconds. This provides the same functionality as the standard
10791@code{CPU_TIME} intrinsic, and is only included for backwards
10792compatibility.
10793
10794This intrinsic is provided in both subroutine and function forms;
10795however, only one form can be used in any given program unit.
10796
10797@item @emph{Standard}:
10798GNU extension
10799
10800@item @emph{Class}:
138b8aca 10801Subroutine, function
fe97b755 10802
10803@item @emph{Syntax}:
10804@multitable @columnfractions .80
10805@item @code{CALL SECOND(TIME)}
10806@item @code{TIME = SECOND()}
10807@end multitable
10808
10809@item @emph{Arguments}:
10810@multitable @columnfractions .15 .70
10811@item @var{TIME} @tab Shall be of type @code{REAL(4)}.
10812@end multitable
10813
10814@item @emph{Return value}:
10815In either syntax, @var{TIME} is set to the process's current runtime in
10816seconds.
10817
10818@item @emph{See also}:
10819@ref{CPU_TIME}
10820
10821@end table
10822
10823
10824
59e2a584 10825@node SELECTED_CHAR_KIND
10826@section @code{SELECTED_CHAR_KIND} --- Choose character kind
10827@fnindex SELECTED_CHAR_KIND
10828@cindex character kind
10829@cindex kind, character
10830
10831@table @asis
10832@item @emph{Description}:
10833
10834@code{SELECTED_CHAR_KIND(NAME)} returns the kind value for the character
10835set named @var{NAME}, if a character set with such a name is supported,
10836or @math{-1} otherwise. Currently, supported character sets include
8a1f3aac 10837``ASCII'' and ``DEFAULT'', which are equivalent, and ``ISO_10646''
10838(Universal Character Set, UCS-4) which is commonly known as Unicode.
59e2a584 10839
10840@item @emph{Standard}:
10841Fortran 2003 and later
10842
10843@item @emph{Class}:
10844Transformational function
10845
10846@item @emph{Syntax}:
10847@code{RESULT = SELECTED_CHAR_KIND(NAME)}
10848
10849@item @emph{Arguments}:
10850@multitable @columnfractions .15 .70
10851@item @var{NAME} @tab Shall be a scalar and of the default character type.
10852@end multitable
10853
10854@item @emph{Example}:
10855@smallexample
8a1f3aac 10856program character_kind
10857 use iso_fortran_env
10858 implicit none
10859 integer, parameter :: ascii = selected_char_kind ("ascii")
10860 integer, parameter :: ucs4 = selected_char_kind ('ISO_10646')
10861
10862 character(kind=ascii, len=26) :: alphabet
10863 character(kind=ucs4, len=30) :: hello_world
10864
10865 alphabet = ascii_"abcdefghijklmnopqrstuvwxyz"
10866 hello_world = ucs4_'Hello World and Ni Hao -- ' &
10867 // char (int (z'4F60'), ucs4) &
10868 // char (int (z'597D'), ucs4)
10869
10870 write (*,*) alphabet
59e2a584 10871
8a1f3aac 10872 open (output_unit, encoding='UTF-8')
10873 write (*,*) trim (hello_world)
10874end program character_kind
59e2a584 10875@end smallexample
10876@end table
10877
10878
10879
572d7b7f 10880@node SELECTED_INT_KIND
10881@section @code{SELECTED_INT_KIND} --- Choose integer kind
a1149005 10882@fnindex SELECTED_INT_KIND
572d7b7f 10883@cindex integer kind
a1149005 10884@cindex kind, integer
572d7b7f 10885
10886@table @asis
10887@item @emph{Description}:
2cd8ef8b 10888@code{SELECTED_INT_KIND(R)} return the kind value of the smallest integer
10889type that can represent all values ranging from @math{-10^R} (exclusive)
10890to @math{10^R} (exclusive). If there is no integer kind that accommodates
572d7b7f 10891this range, @code{SELECTED_INT_KIND} returns @math{-1}.
10892
a3c4ed23 10893@item @emph{Standard}:
f40b44c0 10894Fortran 95 and later
572d7b7f 10895
10896@item @emph{Class}:
a3c4ed23 10897Transformational function
572d7b7f 10898
10899@item @emph{Syntax}:
2cd8ef8b 10900@code{RESULT = SELECTED_INT_KIND(R)}
572d7b7f 10901
10902@item @emph{Arguments}:
aee612a9 10903@multitable @columnfractions .15 .70
2cd8ef8b 10904@item @var{R} @tab Shall be a scalar and of type @code{INTEGER}.
572d7b7f 10905@end multitable
10906
10907@item @emph{Example}:
10908@smallexample
10909program large_integers
10910 integer,parameter :: k5 = selected_int_kind(5)
10911 integer,parameter :: k15 = selected_int_kind(15)
10912 integer(kind=k5) :: i5
10913 integer(kind=k15) :: i15
10914
10915 print *, huge(i5), huge(i15)
10916
10917 ! The following inequalities are always true
10918 print *, huge(i5) >= 10_k5**5-1
10919 print *, huge(i15) >= 10_k15**15-1
10920end program large_integers
10921@end smallexample
10922@end table
10923
10924
10925
10926@node SELECTED_REAL_KIND
10927@section @code{SELECTED_REAL_KIND} --- Choose real kind
a1149005 10928@fnindex SELECTED_REAL_KIND
572d7b7f 10929@cindex real kind
a1149005 10930@cindex kind, real
1011a9ca 10931@cindex radix, real
572d7b7f 10932
10933@table @asis
10934@item @emph{Description}:
57b9ac90 10935@code{SELECTED_REAL_KIND(P,R)} returns the kind value of a real data type
1011a9ca 10936with decimal precision of at least @code{P} digits, exponent range of
10937at least @code{R}, and with a radix of @code{RADIX}.
572d7b7f 10938
a3c4ed23 10939@item @emph{Standard}:
1011a9ca 10940Fortran 95 and later, with @code{RADIX} Fortran 2008 or later
572d7b7f 10941
10942@item @emph{Class}:
a3c4ed23 10943Transformational function
572d7b7f 10944
10945@item @emph{Syntax}:
1011a9ca 10946@code{RESULT = SELECTED_REAL_KIND([P, R, RADIX])}
572d7b7f 10947
10948@item @emph{Arguments}:
aee612a9 10949@multitable @columnfractions .15 .70
572d7b7f 10950@item @var{P} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
10951@item @var{R} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
1011a9ca 10952@item @var{RADIX} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
572d7b7f 10953@end multitable
1011a9ca 10954Before Fortran 2008, at least one of the arguments @var{R} or @var{P} shall
10955be present; since Fortran 2008, they are assumed to be zero if absent.
572d7b7f 10956
10957@item @emph{Return value}:
10958
10959@code{SELECTED_REAL_KIND} returns the value of the kind type parameter of
1011a9ca 10960a real data type with decimal precision of at least @code{P} digits, a
10961decimal exponent range of at least @code{R}, and with the requested
10962@code{RADIX}. If the @code{RADIX} parameter is absent, real kinds with
10963any radix can be returned. If more than one real data type meet the
10964criteria, the kind of the data type with the smallest decimal precision
10965is returned. If no real data type matches the criteria, the result is
572d7b7f 10966@table @asis
10967@item -1 if the processor does not support a real data type with a
1011a9ca 10968precision greater than or equal to @code{P}, but the @code{R} and
10969@code{RADIX} requirements can be fulfilled
572d7b7f 10970@item -2 if the processor does not support a real type with an exponent
1011a9ca 10971range greater than or equal to @code{R}, but @code{P} and @code{RADIX}
10972are fulfillable
10973@item -3 if @code{RADIX} but not @code{P} and @code{R} requirements
10974are fulfillable
10975@item -4 if @code{RADIX} and either @code{P} or @code{R} requirements
10976are fulfillable
10977@item -5 if there is no real type with the given @code{RADIX}
572d7b7f 10978@end table
10979
1011a9ca 10980@item @emph{See also}:
10981@ref{PRECISION}, @ref{RANGE}, @ref{RADIX}
10982
572d7b7f 10983@item @emph{Example}:
10984@smallexample
10985program real_kinds
10986 integer,parameter :: p6 = selected_real_kind(6)
10987 integer,parameter :: p10r100 = selected_real_kind(10,100)
10988 integer,parameter :: r400 = selected_real_kind(r=400)
10989 real(kind=p6) :: x
10990 real(kind=p10r100) :: y
10991 real(kind=r400) :: z
10992
10993 print *, precision(x), range(x)
10994 print *, precision(y), range(y)
10995 print *, precision(z), range(z)
10996end program real_kinds
10997@end smallexample
10998@end table
10999
11000
11001
572d7b7f 11002@node SET_EXPONENT
11003@section @code{SET_EXPONENT} --- Set the exponent of the model
a1149005 11004@fnindex SET_EXPONENT
11005@cindex real number, set exponent
11006@cindex floating point, set exponent
b3d3a366 11007
11008@table @asis
11009@item @emph{Description}:
572d7b7f 11010@code{SET_EXPONENT(X, I)} returns the real number whose fractional part
5e246457 11011is that that of @var{X} and whose exponent part is @var{I}.
b3d3a366 11012
a3c4ed23 11013@item @emph{Standard}:
f40b44c0 11014Fortran 95 and later
b3d3a366 11015
11016@item @emph{Class}:
a3c4ed23 11017Elemental function
b3d3a366 11018
11019@item @emph{Syntax}:
4eb41f08 11020@code{RESULT = SET_EXPONENT(X, I)}
b3d3a366 11021
11022@item @emph{Arguments}:
aee612a9 11023@multitable @columnfractions .15 .70
e0c54690 11024@item @var{X} @tab Shall be of type @code{REAL}.
11025@item @var{I} @tab Shall be of type @code{INTEGER}.
b3d3a366 11026@end multitable
11027
11028@item @emph{Return value}:
572d7b7f 11029The return value is of the same type and kind as @var{X}.
11030The real number whose fractional part
11031is that that of @var{X} and whose exponent part if @var{I} is returned;
11032it is @code{FRACTION(X) * RADIX(X)**I}.
b3d3a366 11033
11034@item @emph{Example}:
b3d3a366 11035@smallexample
b9f2f128 11036PROGRAM test_setexp
11037 REAL :: x = 178.1387e-4
11038 INTEGER :: i = 17
11039 PRINT *, SET_EXPONENT(x, i), FRACTION(x) * RADIX(x)**i
11040END PROGRAM
b3d3a366 11041@end smallexample
572d7b7f 11042
b3d3a366 11043@end table
11044
11045
572d7b7f 11046
a3c4ed23 11047@node SHAPE
11048@section @code{SHAPE} --- Determine the shape of an array
a1149005 11049@fnindex SHAPE
11050@cindex array, shape
a3c4ed23 11051
a3c4ed23 11052@table @asis
11053@item @emph{Description}:
8873d8a6 11054Determines the shape of an array.
11055
a3c4ed23 11056@item @emph{Standard}:
ac6914b0 11057Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
a3c4ed23 11058
11059@item @emph{Class}:
11060Inquiry function
11061
11062@item @emph{Syntax}:
ac6914b0 11063@code{RESULT = SHAPE(SOURCE [, KIND])}
8873d8a6 11064
a3c4ed23 11065@item @emph{Arguments}:
8873d8a6 11066@multitable @columnfractions .15 .70
11067@item @var{SOURCE} @tab Shall be an array or scalar of any type.
11068If @var{SOURCE} is a pointer it must be associated and allocatable
11069arrays must be allocated.
ac6914b0 11070@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
11071expression indicating the kind parameter of the result.
8873d8a6 11072@end multitable
11073
a3c4ed23 11074@item @emph{Return value}:
8873d8a6 11075An @code{INTEGER} array of rank one with as many elements as @var{SOURCE}
c3faa3c9 11076has dimensions. The elements of the resulting array correspond to the extend
8873d8a6 11077of @var{SOURCE} along the respective dimensions. If @var{SOURCE} is a scalar,
ac6914b0 11078the result is the rank one array of size zero. If @var{KIND} is absent, the
11079return value has the default integer kind otherwise the specified kind.
8873d8a6 11080
a3c4ed23 11081@item @emph{Example}:
8873d8a6 11082@smallexample
11083PROGRAM test_shape
11084 INTEGER, DIMENSION(-1:1, -1:2) :: A
11085 WRITE(*,*) SHAPE(A) ! (/ 3, 4 /)
11086 WRITE(*,*) SIZE(SHAPE(42)) ! (/ /)
11087END PROGRAM
11088@end smallexample
11089
a3c4ed23 11090@item @emph{See also}:
8873d8a6 11091@ref{RESHAPE}, @ref{SIZE}
a3c4ed23 11092@end table
11093
11094
11095
f004c7aa 11096@node SHIFTA
11097@section @code{SHIFTA} --- Right shift with fill
11098@fnindex SHIFTA
11099@cindex bits, shift right
11100@cindex shift, right with fill
11101
11102@table @asis
11103@item @emph{Description}:
11104@code{SHIFTA} returns a value corresponding to @var{I} with all of the
11105bits shifted right by @var{SHIFT} places. If the absolute value of
11106@var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
11107Bits shifted out from the right end are lost. The fill is arithmetic: the
11108bits shifted in from the left end are equal to the leftmost bit, which in
11109two's complement representation is the sign bit.
11110
11111@item @emph{Standard}:
11112Fortran 2008 and later
11113
11114@item @emph{Class}:
11115Elemental function
11116
11117@item @emph{Syntax}:
11118@code{RESULT = SHIFTA(I, SHIFT)}
11119
11120@item @emph{Arguments}:
11121@multitable @columnfractions .15 .70
11122@item @var{I} @tab The type shall be @code{INTEGER}.
11123@item @var{SHIFT} @tab The type shall be @code{INTEGER}.
11124@end multitable
11125
11126@item @emph{Return value}:
11127The return value is of type @code{INTEGER} and of the same kind as
11128@var{I}.
11129
11130@item @emph{See also}:
11131@ref{SHIFTL}, @ref{SHIFTR}
11132@end table
11133
11134
11135
11136@node SHIFTL
11137@section @code{SHIFTL} --- Left shift
11138@fnindex SHIFTL
11139@cindex bits, shift left
11140@cindex shift, left
11141
11142@table @asis
11143@item @emph{Description}:
11144@code{SHIFTL} returns a value corresponding to @var{I} with all of the
11145bits shifted left by @var{SHIFT} places. If the absolute value of
11146@var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
11147Bits shifted out from the left end are lost, and bits shifted in from
11148the right end are set to 0.
11149
11150@item @emph{Standard}:
11151Fortran 2008 and later
11152
11153@item @emph{Class}:
11154Elemental function
11155
11156@item @emph{Syntax}:
11157@code{RESULT = SHIFTL(I, SHIFT)}
11158
11159@item @emph{Arguments}:
11160@multitable @columnfractions .15 .70
11161@item @var{I} @tab The type shall be @code{INTEGER}.
11162@item @var{SHIFT} @tab The type shall be @code{INTEGER}.
11163@end multitable
11164
11165@item @emph{Return value}:
11166The return value is of type @code{INTEGER} and of the same kind as
11167@var{I}.
11168
11169@item @emph{See also}:
11170@ref{SHIFTA}, @ref{SHIFTR}
11171@end table
11172
11173
11174
11175@node SHIFTR
11176@section @code{SHIFTR} --- Right shift
11177@fnindex SHIFTR
11178@cindex bits, shift right
11179@cindex shift, right
11180
11181@table @asis
11182@item @emph{Description}:
11183@code{SHIFTR} returns a value corresponding to @var{I} with all of the
11184bits shifted right by @var{SHIFT} places. If the absolute value of
11185@var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
11186Bits shifted out from the right end are lost, and bits shifted in from
11187the left end are set to 0.
11188
11189@item @emph{Standard}:
11190Fortran 2008 and later
11191
11192@item @emph{Class}:
11193Elemental function
11194
11195@item @emph{Syntax}:
11196@code{RESULT = SHIFTR(I, SHIFT)}
11197
11198@item @emph{Arguments}:
11199@multitable @columnfractions .15 .70
11200@item @var{I} @tab The type shall be @code{INTEGER}.
11201@item @var{SHIFT} @tab The type shall be @code{INTEGER}.
11202@end multitable
11203
11204@item @emph{Return value}:
11205The return value is of type @code{INTEGER} and of the same kind as
11206@var{I}.
11207
11208@item @emph{See also}:
11209@ref{SHIFTA}, @ref{SHIFTL}
11210@end table
11211
11212
11213
572d7b7f 11214@node SIGN
11215@section @code{SIGN} --- Sign copying function
a1149005 11216@fnindex SIGN
11217@fnindex ISIGN
11218@fnindex DSIGN
572d7b7f 11219@cindex sign copying
a7d25c4a 11220
11221@table @asis
11222@item @emph{Description}:
572d7b7f 11223@code{SIGN(A,B)} returns the value of @var{A} with the sign of @var{B}.
a7d25c4a 11224
a3c4ed23 11225@item @emph{Standard}:
f40b44c0 11226Fortran 77 and later
a7d25c4a 11227
11228@item @emph{Class}:
a3c4ed23 11229Elemental function
a7d25c4a 11230
11231@item @emph{Syntax}:
4eb41f08 11232@code{RESULT = SIGN(A, B)}
a7d25c4a 11233
11234@item @emph{Arguments}:
aee612a9 11235@multitable @columnfractions .15 .70
6e88b72e 11236@item @var{A} @tab Shall be of type @code{INTEGER} or @code{REAL}
11237@item @var{B} @tab Shall be of the same type and kind as @var{A}
a7d25c4a 11238@end multitable
11239
11240@item @emph{Return value}:
572d7b7f 11241The kind of the return value is that of @var{A} and @var{B}.
11242If @math{B\ge 0} then the result is @code{ABS(A)}, else
11243it is @code{-ABS(A)}.
a7d25c4a 11244
11245@item @emph{Example}:
11246@smallexample
572d7b7f 11247program test_sign
11248 print *, sign(-12,1)
11249 print *, sign(-12,0)
11250 print *, sign(-12,-1)
11251
11252 print *, sign(-12.,1.)
11253 print *, sign(-12.,0.)
11254 print *, sign(-12.,-1.)
11255end program test_sign
a7d25c4a 11256@end smallexample
572d7b7f 11257
11258@item @emph{Specific names}:
aee612a9 11259@multitable @columnfractions .20 .20 .20 .25
7d74ce87 11260@item Name @tab Arguments @tab Return type @tab Standard
11261@item @code{SIGN(A,B)} @tab @code{REAL(4) A, B} @tab @code{REAL(4)} @tab f77, gnu
11262@item @code{ISIGN(A,B)} @tab @code{INTEGER(4) A, B} @tab @code{INTEGER(4)} @tab f77, gnu
11263@item @code{DSIGN(A,B)} @tab @code{REAL(8) A, B} @tab @code{REAL(8)} @tab f77, gnu
572d7b7f 11264@end multitable
a7d25c4a 11265@end table
11266
c0075f3c 11267
247981ce 11268
11269@node SIGNAL
11270@section @code{SIGNAL} --- Signal handling subroutine (or function)
a1149005 11271@fnindex SIGNAL
11272@cindex system, signal handling
247981ce 11273
11274@table @asis
11275@item @emph{Description}:
11276@code{SIGNAL(NUMBER, HANDLER [, STATUS])} causes external subroutine
11277@var{HANDLER} to be executed with a single integer argument when signal
11278@var{NUMBER} occurs. If @var{HANDLER} is an integer, it can be used to
11279turn off handling of signal @var{NUMBER} or revert to its default
11280action. See @code{signal(2)}.
11281
11282If @code{SIGNAL} is called as a subroutine and the @var{STATUS} argument
11283is supplied, it is set to the value returned by @code{signal(2)}.
11284
a3c4ed23 11285@item @emph{Standard}:
11286GNU extension
247981ce 11287
11288@item @emph{Class}:
138b8aca 11289Subroutine, function
247981ce 11290
11291@item @emph{Syntax}:
0eb92d52 11292@multitable @columnfractions .80
4eb41f08 11293@item @code{CALL SIGNAL(NUMBER, HANDLER [, STATUS])}
5e246457 11294@item @code{STATUS = SIGNAL(NUMBER, HANDLER)}
247981ce 11295@end multitable
11296
11297@item @emph{Arguments}:
aee612a9 11298@multitable @columnfractions .15 .70
e0c54690 11299@item @var{NUMBER} @tab Shall be a scalar integer, with @code{INTENT(IN)}
247981ce 11300@item @var{HANDLER}@tab Signal handler (@code{INTEGER FUNCTION} or
11301@code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar.
11302@code{INTEGER}. It is @code{INTENT(IN)}.
11303@item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
11304integer. It has @code{INTENT(OUT)}.
11305@end multitable
57b9ac90 11306@c TODO: What should the interface of the handler be? Does it take arguments?
247981ce 11307
11308@item @emph{Return value}:
5e246457 11309The @code{SIGNAL} function returns the value returned by @code{signal(2)}.
247981ce 11310
11311@item @emph{Example}:
11312@smallexample
11313program test_signal
11314 intrinsic signal
11315 external handler_print
11316
11317 call signal (12, handler_print)
11318 call signal (10, 1)
11319
11320 call sleep (30)
11321end program test_signal
11322@end smallexample
11323@end table
11324
11325
11326
338c728c 11327@node SIN
11328@section @code{SIN} --- Sine function
a1149005 11329@fnindex SIN
11330@fnindex DSIN
11331@fnindex CSIN
11332@fnindex ZSIN
11333@fnindex CDSIN
11334@cindex trigonometric function, sine
11335@cindex sine
338c728c 11336
11337@table @asis
11338@item @emph{Description}:
11339@code{SIN(X)} computes the sine of @var{X}.
11340
a3c4ed23 11341@item @emph{Standard}:
f40b44c0 11342Fortran 77 and later
338c728c 11343
bb3d0c30 11344@item @emph{Class}:
a3c4ed23 11345Elemental function
338c728c 11346
11347@item @emph{Syntax}:
4eb41f08 11348@code{RESULT = SIN(X)}
338c728c 11349
11350@item @emph{Arguments}:
aee612a9 11351@multitable @columnfractions .15 .70
e06f8026 11352@item @var{X} @tab The type shall be @code{REAL} or
11353@code{COMPLEX}.
338c728c 11354@end multitable
11355
11356@item @emph{Return value}:
a3c4ed23 11357The return value has same type and kind as @var{X}.
338c728c 11358
11359@item @emph{Example}:
11360@smallexample
11361program test_sin
11362 real :: x = 0.0
11363 x = sin(x)
11364end program test_sin
11365@end smallexample
11366
11367@item @emph{Specific names}:
aee612a9 11368@multitable @columnfractions .20 .20 .20 .25
7d74ce87 11369@item Name @tab Argument @tab Return type @tab Standard
11370@item @code{SIN(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab f77, gnu
11371@item @code{DSIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
11372@item @code{CSIN(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab f95, gnu
11373@item @code{ZSIN(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
11374@item @code{CDSIN(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
338c728c 11375@end multitable
a3c4ed23 11376
11377@item @emph{See also}:
11378@ref{ASIN}
338c728c 11379@end table
11380
11381
11382
c0075f3c 11383@node SINH
11384@section @code{SINH} --- Hyperbolic sine function
a1149005 11385@fnindex SINH
11386@fnindex DSINH
c0075f3c 11387@cindex hyperbolic sine
a1149005 11388@cindex hyperbolic function, sine
11389@cindex sine, hyperbolic
c0075f3c 11390
11391@table @asis
11392@item @emph{Description}:
11393@code{SINH(X)} computes the hyperbolic sine of @var{X}.
11394
a3c4ed23 11395@item @emph{Standard}:
4ca842c8 11396Fortran 95 and later, for a complex argument Fortran 2008 or later
c0075f3c 11397
bb3d0c30 11398@item @emph{Class}:
a3c4ed23 11399Elemental function
c0075f3c 11400
11401@item @emph{Syntax}:
4eb41f08 11402@code{RESULT = SINH(X)}
c0075f3c 11403
11404@item @emph{Arguments}:
aee612a9 11405@multitable @columnfractions .15 .70
4ca842c8 11406@item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
c0075f3c 11407@end multitable
11408
11409@item @emph{Return value}:
4ca842c8 11410The return value has same type and kind as @var{X}.
c0075f3c 11411
11412@item @emph{Example}:
11413@smallexample
11414program test_sinh
11415 real(8) :: x = - 1.0_8
11416 x = sinh(x)
11417end program test_sinh
11418@end smallexample
11419
11420@item @emph{Specific names}:
aee612a9 11421@multitable @columnfractions .20 .20 .20 .25
a3c4ed23 11422@item Name @tab Argument @tab Return type @tab Standard
7d74ce87 11423@item @code{SINH(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 95 and later
f40b44c0 11424@item @code{DSINH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 95 and later
c0075f3c 11425@end multitable
a3c4ed23 11426
11427@item @emph{See also}:
11428@ref{ASINH}
11429@end table
11430
11431
11432
11433@node SIZE
11434@section @code{SIZE} --- Determine the size of an array
a1149005 11435@fnindex SIZE
11436@cindex array, size
11437@cindex array, number of elements
11438@cindex array, count elements
a3c4ed23 11439
a3c4ed23 11440@table @asis
11441@item @emph{Description}:
8873d8a6 11442Determine the extent of @var{ARRAY} along a specified dimension @var{DIM},
11443or the total number of elements in @var{ARRAY} if @var{DIM} is absent.
11444
a3c4ed23 11445@item @emph{Standard}:
f40b44c0 11446Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
a3c4ed23 11447
11448@item @emph{Class}:
11449Inquiry function
11450
11451@item @emph{Syntax}:
7fe55cc9 11452@code{RESULT = SIZE(ARRAY[, DIM [, KIND]])}
8873d8a6 11453
a3c4ed23 11454@item @emph{Arguments}:
8873d8a6 11455@multitable @columnfractions .15 .70
11456@item @var{ARRAY} @tab Shall be an array of any type. If @var{ARRAY} is
11457a pointer it must be associated and allocatable arrays must be allocated.
11458@item @var{DIM} @tab (Optional) shall be a scalar of type @code{INTEGER}
11459and its value shall be in the range from 1 to n, where n equals the rank
11460of @var{ARRAY}.
7fe55cc9 11461@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
c24c5fac 11462expression indicating the kind parameter of the result.
8873d8a6 11463@end multitable
11464
a3c4ed23 11465@item @emph{Return value}:
7fe55cc9 11466The return value is of type @code{INTEGER} and of kind @var{KIND}. If
11467@var{KIND} is absent, the return value is of default integer kind.
8873d8a6 11468
a3c4ed23 11469@item @emph{Example}:
8873d8a6 11470@smallexample
11471PROGRAM test_size
11472 WRITE(*,*) SIZE((/ 1, 2 /)) ! 2
11473END PROGRAM
11474@end smallexample
11475
a3c4ed23 11476@item @emph{See also}:
8873d8a6 11477@ref{SHAPE}, @ref{RESHAPE}
c0075f3c 11478@end table
11479
11480
1318f16c 11481@node SIZEOF
11482@section @code{SIZEOF} --- Size in bytes of an expression
11483@fnindex SIZEOF
11484@cindex expression size
11485@cindex size of an expression
11486
11487@table @asis
11488@item @emph{Description}:
11489@code{SIZEOF(X)} calculates the number of bytes of storage the
11490expression @code{X} occupies.
11491
11492@item @emph{Standard}:
11493GNU extension
11494
11495@item @emph{Class}:
11496Intrinsic function
11497
11498@item @emph{Syntax}:
11499@code{N = SIZEOF(X)}
11500
11501@item @emph{Arguments}:
11502@multitable @columnfractions .15 .70
11503@item @var{X} @tab The argument shall be of any type, rank or shape.
11504@end multitable
11505
11506@item @emph{Return value}:
8d71eaf7 11507The return value is of type integer and of the system-dependent kind
11508@var{C_SIZE_T} (from the @var{ISO_C_BINDING} module). Its value is the
11509number of bytes occupied by the argument. If the argument has the
11510@code{POINTER} attribute, the number of bytes of the storage area pointed
11511to is returned. If the argument is of a derived type with @code{POINTER}
6152df27 11512or @code{ALLOCATABLE} components, the return value does not account for
24c079ad 11513the sizes of the data pointed to by these components. If the argument is
e77cbaa7 11514polymorphic, the size according to the declared type is returned. The argument
11515may not be a procedure or procedure pointer.
1318f16c 11516
11517@item @emph{Example}:
11518@smallexample
11519 integer :: i
11520 real :: r, s(5)
11521 print *, (sizeof(s)/sizeof(r) == 5)
11522 end
11523@end smallexample
11524The example will print @code{.TRUE.} unless you are using a platform
11525where default @code{REAL} variables are unusually padded.
189ffda5 11526
11527@item @emph{See also}:
24c079ad 11528@ref{C_SIZEOF}, @ref{STORAGE_SIZE}
1318f16c 11529@end table
c0075f3c 11530
189ffda5 11531
5309bf0b 11532@node SLEEP
11533@section @code{SLEEP} --- Sleep for the specified number of seconds
a1149005 11534@fnindex SLEEP
11535@cindex delayed execution
5309bf0b 11536
11537@table @asis
11538@item @emph{Description}:
11539Calling this subroutine causes the process to pause for @var{SECONDS} seconds.
11540
11541@item @emph{Standard}:
11542GNU extension
11543
11544@item @emph{Class}:
11545Subroutine
11546
11547@item @emph{Syntax}:
11548@code{CALL SLEEP(SECONDS)}
11549
11550@item @emph{Arguments}:
aee612a9 11551@multitable @columnfractions .15 .70
5309bf0b 11552@item @var{SECONDS} @tab The type shall be of default @code{INTEGER}.
11553@end multitable
11554
11555@item @emph{Example}:
11556@smallexample
11557program test_sleep
11558 call sleep(5)
11559end
11560@end smallexample
11561@end table
11562
11563
11564
a3c4ed23 11565@node SPACING
11566@section @code{SPACING} --- Smallest distance between two numbers of a given type
a1149005 11567@fnindex SPACING
11568@cindex real number, relative spacing
11569@cindex floating point, relative spacing
a3c4ed23 11570
11571@table @asis
11572@item @emph{Description}:
c3faa3c9 11573Determines the distance between the argument @var{X} and the nearest
11574adjacent number of the same type.
11575
a3c4ed23 11576@item @emph{Standard}:
f40b44c0 11577Fortran 95 and later
a3c4ed23 11578
11579@item @emph{Class}:
11580Elemental function
11581
11582@item @emph{Syntax}:
c3faa3c9 11583@code{RESULT = SPACING(X)}
11584
a3c4ed23 11585@item @emph{Arguments}:
c3faa3c9 11586@multitable @columnfractions .15 .70
e06f8026 11587@item @var{X} @tab Shall be of type @code{REAL}.
c3faa3c9 11588@end multitable
11589
a3c4ed23 11590@item @emph{Return value}:
c3faa3c9 11591The result is of the same type as the input argument @var{X}.
11592
a3c4ed23 11593@item @emph{Example}:
c3faa3c9 11594@smallexample
11595PROGRAM test_spacing
11596 INTEGER, PARAMETER :: SGL = SELECTED_REAL_KIND(p=6, r=37)
11597 INTEGER, PARAMETER :: DBL = SELECTED_REAL_KIND(p=13, r=200)
11598
11599 WRITE(*,*) spacing(1.0_SGL) ! "1.1920929E-07" on i686
11600 WRITE(*,*) spacing(1.0_DBL) ! "2.220446049250313E-016" on i686
11601END PROGRAM
11602@end smallexample
11603
a3c4ed23 11604@item @emph{See also}:
c3faa3c9 11605@ref{RRSPACING}
a3c4ed23 11606@end table
11607
11608
11609
a3c4ed23 11610@node SPREAD
11611@section @code{SPREAD} --- Add a dimension to an array
a1149005 11612@fnindex SPREAD
11613@cindex array, increase dimension
bd84e447 11614@cindex array, duplicate elements
a1149005 11615@cindex array, duplicate dimensions
a3c4ed23 11616
a3c4ed23 11617@table @asis
11618@item @emph{Description}:
c3faa3c9 11619Replicates a @var{SOURCE} array @var{NCOPIES} times along a specified
11620dimension @var{DIM}.
11621
a3c4ed23 11622@item @emph{Standard}:
f40b44c0 11623Fortran 95 and later
a3c4ed23 11624
11625@item @emph{Class}:
11626Transformational function
11627
11628@item @emph{Syntax}:
c3faa3c9 11629@code{RESULT = SPREAD(SOURCE, DIM, NCOPIES)}
11630
a3c4ed23 11631@item @emph{Arguments}:
c3faa3c9 11632@multitable @columnfractions .15 .70
11633@item @var{SOURCE} @tab Shall be a scalar or an array of any type and
11634a rank less than seven.
11635@item @var{DIM} @tab Shall be a scalar of type @code{INTEGER} with a
11636value in the range from 1 to n+1, where n equals the rank of @var{SOURCE}.
11637@item @var{NCOPIES} @tab Shall be a scalar of type @code{INTEGER}.
11638@end multitable
11639
a3c4ed23 11640@item @emph{Return value}:
c3faa3c9 11641The result is an array of the same type as @var{SOURCE} and has rank n+1
11642where n equals the rank of @var{SOURCE}.
11643
a3c4ed23 11644@item @emph{Example}:
c3faa3c9 11645@smallexample
11646PROGRAM test_spread
11647 INTEGER :: a = 1, b(2) = (/ 1, 2 /)
11648 WRITE(*,*) SPREAD(A, 1, 2) ! "1 1"
11649 WRITE(*,*) SPREAD(B, 1, 2) ! "1 1 2 2"
11650END PROGRAM
11651@end smallexample
11652
a3c4ed23 11653@item @emph{See also}:
c3faa3c9 11654@ref{UNPACK}
a3c4ed23 11655@end table
11656
11657
11658
a3c4ed23 11659@node SQRT
11660@section @code{SQRT} --- Square-root function
a1149005 11661@fnindex SQRT
11662@fnindex DSQRT
11663@fnindex CSQRT
11664@fnindex ZSQRT
11665@fnindex CDSQRT
11666@cindex root
a3c4ed23 11667@cindex square-root
11668
11669@table @asis
11670@item @emph{Description}:
11671@code{SQRT(X)} computes the square root of @var{X}.
11672
11673@item @emph{Standard}:
f40b44c0 11674Fortran 77 and later
a3c4ed23 11675
11676@item @emph{Class}:
11677Elemental function
11678
11679@item @emph{Syntax}:
4eb41f08 11680@code{RESULT = SQRT(X)}
a3c4ed23 11681
11682@item @emph{Arguments}:
aee612a9 11683@multitable @columnfractions .15 .70
e06f8026 11684@item @var{X} @tab The type shall be @code{REAL} or
11685@code{COMPLEX}.
a3c4ed23 11686@end multitable
11687
11688@item @emph{Return value}:
e06f8026 11689The return value is of type @code{REAL} or @code{COMPLEX}.
a3c4ed23 11690The kind type parameter is the same as @var{X}.
11691
11692@item @emph{Example}:
11693@smallexample
11694program test_sqrt
11695 real(8) :: x = 2.0_8
11696 complex :: z = (1.0, 2.0)
11697 x = sqrt(x)
11698 z = sqrt(z)
11699end program test_sqrt
11700@end smallexample
11701
11702@item @emph{Specific names}:
aee612a9 11703@multitable @columnfractions .20 .20 .20 .25
a3c4ed23 11704@item Name @tab Argument @tab Return type @tab Standard
7d74ce87 11705@item @code{SQRT(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 95 and later
f40b44c0 11706@item @code{DSQRT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 95 and later
11707@item @code{CSQRT(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab Fortran 95 and later
a3c4ed23 11708@item @code{ZSQRT(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
11709@item @code{CDSQRT(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
11710@end multitable
11711@end table
11712
11713
11714
11715@node SRAND
11716@section @code{SRAND} --- Reinitialize the random number generator
a1149005 11717@fnindex SRAND
11718@cindex random number generation, seeding
11719@cindex seeding a random number generator
a3c4ed23 11720
11721@table @asis
11722@item @emph{Description}:
11723@code{SRAND} reinitializes the pseudo-random number generator
11724called by @code{RAND} and @code{IRAND}. The new seed used by the
11725generator is specified by the required argument @var{SEED}.
11726
11727@item @emph{Standard}:
11728GNU extension
11729
11730@item @emph{Class}:
138b8aca 11731Subroutine
a3c4ed23 11732
11733@item @emph{Syntax}:
11734@code{CALL SRAND(SEED)}
11735
11736@item @emph{Arguments}:
aee612a9 11737@multitable @columnfractions .15 .70
e0c54690 11738@item @var{SEED} @tab Shall be a scalar @code{INTEGER(kind=4)}.
a3c4ed23 11739@end multitable
11740
11741@item @emph{Return value}:
57b9ac90 11742Does not return anything.
a3c4ed23 11743
11744@item @emph{Example}:
11745See @code{RAND} and @code{IRAND} for examples.
11746
11747@item @emph{Notes}:
11748The Fortran 2003 standard specifies the intrinsic @code{RANDOM_SEED} to
11749initialize the pseudo-random numbers generator and @code{RANDOM_NUMBER}
11750to generate pseudo-random numbers. Please note that in
61156d26 11751GNU Fortran, these two sets of intrinsics (@code{RAND},
a3c4ed23 11752@code{IRAND} and @code{SRAND} on the one hand, @code{RANDOM_NUMBER} and
11753@code{RANDOM_SEED} on the other hand) access two independent
11754pseudo-random number generators.
11755
11756@item @emph{See also}:
11757@ref{RAND}, @ref{RANDOM_SEED}, @ref{RANDOM_NUMBER}
11758
11759@end table
11760
11761
0eb92d52 11762
a3c4ed23 11763@node STAT
11764@section @code{STAT} --- Get file status
a1149005 11765@fnindex STAT
11766@cindex file system, file status
a3c4ed23 11767
a3c4ed23 11768@table @asis
11769@item @emph{Description}:
666bf11e 11770This function returns information about a file. No permissions are required on
11771the file itself, but execute (search) permission is required on all of the
11772directories in path that lead to the file.
11773
2cd8ef8b 11774The elements that are obtained and stored in the array @code{VALUES}:
aee612a9 11775@multitable @columnfractions .15 .70
2cd8ef8b 11776@item @code{VALUES(1)} @tab Device ID
11777@item @code{VALUES(2)} @tab Inode number
11778@item @code{VALUES(3)} @tab File mode
11779@item @code{VALUES(4)} @tab Number of links
11780@item @code{VALUES(5)} @tab Owner's uid
11781@item @code{VALUES(6)} @tab Owner's gid
11782@item @code{VALUES(7)} @tab ID of device containing directory entry for file (0 if not available)
11783@item @code{VALUES(8)} @tab File size (bytes)
11784@item @code{VALUES(9)} @tab Last access time
11785@item @code{VALUES(10)} @tab Last modification time
11786@item @code{VALUES(11)} @tab Last file status change time
11787@item @code{VALUES(12)} @tab Preferred I/O block size (-1 if not available)
11788@item @code{VALUES(13)} @tab Number of blocks allocated (-1 if not available)
666bf11e 11789@end multitable
11790
11791Not all these elements are relevant on all systems.
11792If an element is not relevant, it is returned as 0.
11793
138b8aca 11794This intrinsic is provided in both subroutine and function forms; however,
11795only one form can be used in any given program unit.
666bf11e 11796
a3c4ed23 11797@item @emph{Standard}:
11798GNU extension
11799
11800@item @emph{Class}:
138b8aca 11801Subroutine, function
666bf11e 11802
a3c4ed23 11803@item @emph{Syntax}:
6c07e6d8 11804@multitable @columnfractions .80
11805@item @code{CALL STAT(NAME, VALUES [, STATUS])}
11806@item @code{STATUS = STAT(NAME, VALUES)}
11807@end multitable
666bf11e 11808
a3c4ed23 11809@item @emph{Arguments}:
aee612a9 11810@multitable @columnfractions .15 .70
2cd8ef8b 11811@item @var{NAME} @tab The type shall be @code{CHARACTER}, of the
b44437b9 11812default kind and a valid path within the file system.
2cd8ef8b 11813@item @var{VALUES} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
666bf11e 11814@item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0
c24c5fac 11815on success and a system specific error code otherwise.
666bf11e 11816@end multitable
11817
a3c4ed23 11818@item @emph{Example}:
666bf11e 11819@smallexample
beec09c9 11820PROGRAM test_stat
666bf11e 11821 INTEGER, DIMENSION(13) :: buff
11822 INTEGER :: status
11823
beec09c9 11824 CALL STAT("/etc/passwd", buff, status)
666bf11e 11825
11826 IF (status == 0) THEN
beec09c9 11827 WRITE (*, FMT="('Device ID:', T30, I19)") buff(1)
11828 WRITE (*, FMT="('Inode number:', T30, I19)") buff(2)
641cacd5 11829 WRITE (*, FMT="('File mode (octal):', T30, O19)") buff(3)
beec09c9 11830 WRITE (*, FMT="('Number of links:', T30, I19)") buff(4)
11831 WRITE (*, FMT="('Owner''s uid:', T30, I19)") buff(5)
11832 WRITE (*, FMT="('Owner''s gid:', T30, I19)") buff(6)
11833 WRITE (*, FMT="('Device where located:', T30, I19)") buff(7)
11834 WRITE (*, FMT="('File size:', T30, I19)") buff(8)
11835 WRITE (*, FMT="('Last access time:', T30, A19)") CTIME(buff(9))
11836 WRITE (*, FMT="('Last modification time', T30, A19)") CTIME(buff(10))
11837 WRITE (*, FMT="('Last status change time:', T30, A19)") CTIME(buff(11))
11838 WRITE (*, FMT="('Preferred block size:', T30, I19)") buff(12)
11839 WRITE (*, FMT="('No. of blocks allocated:', T30, I19)") buff(13)
666bf11e 11840 END IF
11841END PROGRAM
11842@end smallexample
11843
a3c4ed23 11844@item @emph{See also}:
666bf11e 11845To stat an open file: @ref{FSTAT}, to stat a link: @ref{LSTAT}
a3c4ed23 11846@end table
11847
11848
11849
24c079ad 11850@node STORAGE_SIZE
11851@section @code{STORAGE_SIZE} --- Storage size in bits
11852@fnindex STORAGE_SIZE
11853@cindex storage size
11854
11855@table @asis
11856@item @emph{Description}:
11857Returns the storage size of argument @var{A} in bits.
11858@item @emph{Standard}:
11859Fortran 2008 and later
11860@item @emph{Class}:
11861Inquiry function
11862@item @emph{Syntax}:
11863@code{RESULT = STORAGE_SIZE(A [, KIND])}
11864
11865@item @emph{Arguments}:
11866@multitable @columnfractions .15 .70
11867@item @var{A} @tab Shall be a scalar or array of any type.
11868@item @var{KIND} @tab (Optional) shall be a scalar integer constant expression.
11869@end multitable
11870
11871@item @emph{Return Value}:
e77cbaa7 11872The result is a scalar integer with the kind type parameter specified by KIND
11873(or default integer type if KIND is missing). The result value is the size
11874expressed in bits for an element of an array that has the dynamic type and type
11875parameters of A.
24c079ad 11876
11877@item @emph{See also}:
11878@ref{C_SIZEOF}, @ref{SIZEOF}
11879@end table
11880
11881
11882
a3c4ed23 11883@node SUM
11884@section @code{SUM} --- Sum of array elements
a1149005 11885@fnindex SUM
11886@cindex array, sum
11887@cindex array, add elements
11888@cindex array, conditionally add elements
11889@cindex sum array elements
a3c4ed23 11890
11891@table @asis
11892@item @emph{Description}:
c3faa3c9 11893Adds the elements of @var{ARRAY} along dimension @var{DIM} if
11894the corresponding element in @var{MASK} is @code{TRUE}.
11895
a3c4ed23 11896@item @emph{Standard}:
f40b44c0 11897Fortran 95 and later
a3c4ed23 11898
11899@item @emph{Class}:
11900Transformational function
11901
11902@item @emph{Syntax}:
2cd8ef8b 11903@multitable @columnfractions .80
11904@item @code{RESULT = SUM(ARRAY[, MASK])}
11905@item @code{RESULT = SUM(ARRAY, DIM[, MASK])}
11906@end multitable
c3faa3c9 11907
a3c4ed23 11908@item @emph{Arguments}:
c3faa3c9 11909@multitable @columnfractions .15 .70
e06f8026 11910@item @var{ARRAY} @tab Shall be an array of type @code{INTEGER},
11911@code{REAL} or @code{COMPLEX}.
c3faa3c9 11912@item @var{DIM} @tab (Optional) shall be a scalar of type
11913@code{INTEGER} with a value in the range from 1 to n, where n
11914equals the rank of @var{ARRAY}.
11915@item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL}
11916and either be a scalar or an array of the same shape as @var{ARRAY}.
11917@end multitable
11918
a3c4ed23 11919@item @emph{Return value}:
c3faa3c9 11920The result is of the same type as @var{ARRAY}.
11921
11922If @var{DIM} is absent, a scalar with the sum of all elements in @var{ARRAY}
11923is returned. Otherwise, an array of rank n-1, where n equals the rank of
24c079ad 11924@var{ARRAY}, and a shape similar to that of @var{ARRAY} with dimension @var{DIM}
c3faa3c9 11925dropped is returned.
11926
a3c4ed23 11927@item @emph{Example}:
c3faa3c9 11928@smallexample
11929PROGRAM test_sum
11930 INTEGER :: x(5) = (/ 1, 2, 3, 4 ,5 /)
11931 print *, SUM(x) ! all elements, sum = 15
11932 print *, SUM(x, MASK=MOD(x, 2)==1) ! odd elements, sum = 9
11933END PROGRAM
11934@end smallexample
11935
a3c4ed23 11936@item @emph{See also}:
11937@ref{PRODUCT}
11938@end table
11939
11940
11941
a3c4ed23 11942@node SYMLNK
11943@section @code{SYMLNK} --- Create a symbolic link
a1149005 11944@fnindex SYMLNK
11945@cindex file system, create link
11946@cindex file system, soft link
a3c4ed23 11947
a3c4ed23 11948@table @asis
11949@item @emph{Description}:
0eb92d52 11950Makes a symbolic link from file @var{PATH1} to @var{PATH2}. A null
11951character (@code{CHAR(0)}) can be used to mark the end of the names in
11952@var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
11953names are ignored. If the @var{STATUS} argument is supplied, it
11954contains 0 on success or a nonzero error code upon return; see
11955@code{symlink(2)}. If the system does not supply @code{symlink(2)},
11956@code{ENOSYS} is returned.
11957
31eea2fc 11958This intrinsic is provided in both subroutine and function forms;
11959however, only one form can be used in any given program unit.
11960
a3c4ed23 11961@item @emph{Standard}:
a3c4ed23 11962GNU extension
11963
0eb92d52 11964@item @emph{Class}:
138b8aca 11965Subroutine, function
0eb92d52 11966
a3c4ed23 11967@item @emph{Syntax}:
31eea2fc 11968@multitable @columnfractions .80
11969@item @code{CALL SYMLNK(PATH1, PATH2 [, STATUS])}
11970@item @code{STATUS = SYMLNK(PATH1, PATH2)}
11971@end multitable
0eb92d52 11972
572d7b7f 11973@item @emph{Arguments}:
aee612a9 11974@multitable @columnfractions .15 .70
0eb92d52 11975@item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
11976@item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
11977@item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
11978@end multitable
11979
a3c4ed23 11980@item @emph{See also}:
0eb92d52 11981@ref{LINK}, @ref{UNLINK}
572d7b7f 11982
0eb92d52 11983@end table
572d7b7f 11984
11985
a3c4ed23 11986
11987@node SYSTEM
11988@section @code{SYSTEM} --- Execute a shell command
a1149005 11989@fnindex SYSTEM
11990@cindex system, system call
338c728c 11991
11992@table @asis
11993@item @emph{Description}:
0eb92d52 11994Passes the command @var{COMMAND} to a shell (see @code{system(3)}). If
11995argument @var{STATUS} is present, it contains the value returned by
11996@code{system(3)}, which is presumably 0 if the shell command succeeded.
11997Note that which shell is used to invoke the command is system-dependent
11998and environment-dependent.
11999
31eea2fc 12000This intrinsic is provided in both subroutine and function forms;
12001however, only one form can be used in any given program unit.
12002
e8c1bbb4 12003Note that the @code{system} function need not be thread-safe. It is
12004the responsibility of the user to ensure that @code{system} is not
12005called concurrently.
026484b4 12006
a3c4ed23 12007@item @emph{Standard}:
12008GNU extension
338c728c 12009
bb3d0c30 12010@item @emph{Class}:
138b8aca 12011Subroutine, function
338c728c 12012
12013@item @emph{Syntax}:
31eea2fc 12014@multitable @columnfractions .80
12015@item @code{CALL SYSTEM(COMMAND [, STATUS])}
12016@item @code{STATUS = SYSTEM(COMMAND)}
12017@end multitable
0eb92d52 12018
338c728c 12019@item @emph{Arguments}:
aee612a9 12020@multitable @columnfractions .15 .70
0eb92d52 12021@item @var{COMMAND} @tab Shall be of default @code{CHARACTER} type.
12022@item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
12023@end multitable
12024
a3c4ed23 12025@item @emph{See also}:
fe2de951 12026@ref{EXECUTE_COMMAND_LINE}, which is part of the Fortran 2008 standard
12027and should considered in new code for future portability.
338c728c 12028@end table
12029
12030
12031
a3c4ed23 12032@node SYSTEM_CLOCK
12033@section @code{SYSTEM_CLOCK} --- Time function
a1149005 12034@fnindex SYSTEM_CLOCK
12035@cindex time, clock ticks
12036@cindex clock ticks
a3c4ed23 12037
572d7b7f 12038@table @asis
12039@item @emph{Description}:
57f34440 12040Determines the @var{COUNT} of a processor clock since an unspecified
12041time in the past modulo @var{COUNT_MAX}, @var{COUNT_RATE} determines
12042the number of clock ticks per second. If the platform supports a high
12043resolution monotonic clock, that clock is used and can provide up to
12044nanosecond resolution. If a high resolution monotonic clock is not
12045available, the implementation falls back to a potentially lower
12046resolution realtime clock.
12047
e333484f 12048@var{COUNT_RATE} is system dependent and can vary depending on the kind of the
12049arguments. For @var{kind=4} arguments, @var{COUNT} usually represents
12050milliseconds, while for @var{kind=8} arguments, @var{COUNT} typically
12051represents micro- or nanoseconds. @var{COUNT_MAX} usually equals
12052@code{HUGE(COUNT_MAX)}.
c3faa3c9 12053
12054If there is no clock, @var{COUNT} is set to @code{-HUGE(COUNT)}, and
57f34440 12055@var{COUNT_RATE} and @var{COUNT_MAX} are set to zero.
12056
12057When running on a platform using the GNU C library (glibc), or a
12058derivative thereof, the high resolution monotonic clock is available
12059only when linking with the @var{rt} library. This can be done
12060explicitly by adding the @code{-lrt} flag when linking the
12061application, but is also done implicitly when using OpenMP.
c3faa3c9 12062
a3c4ed23 12063@item @emph{Standard}:
f40b44c0 12064Fortran 95 and later
572d7b7f 12065
12066@item @emph{Class}:
a3c4ed23 12067Subroutine
572d7b7f 12068
12069@item @emph{Syntax}:
c3faa3c9 12070@code{CALL SYSTEM_CLOCK([COUNT, COUNT_RATE, COUNT_MAX])}
12071
c3faa3c9 12072@item @emph{Arguments}:
12073@multitable @columnfractions .15 .70
57f34440 12074@item @var{COUNT} @tab (Optional) shall be a scalar of type
c3faa3c9 12075@code{INTEGER} with @code{INTENT(OUT)}.
57f34440 12076@item @var{COUNT_RATE} @tab (Optional) shall be a scalar of type
c3faa3c9 12077@code{INTEGER} with @code{INTENT(OUT)}.
57f34440 12078@item @var{COUNT_MAX} @tab (Optional) shall be a scalar of type
c3faa3c9 12079@code{INTEGER} with @code{INTENT(OUT)}.
12080@end multitable
12081
572d7b7f 12082@item @emph{Example}:
c3faa3c9 12083@smallexample
12084PROGRAM test_system_clock
12085 INTEGER :: count, count_rate, count_max
12086 CALL SYSTEM_CLOCK(count, count_rate, count_max)
12087 WRITE(*,*) count, count_rate, count_max
12088END PROGRAM
12089@end smallexample
12090
a3c4ed23 12091@item @emph{See also}:
c3faa3c9 12092@ref{DATE_AND_TIME}, @ref{CPU_TIME}
572d7b7f 12093@end table
12094
12095
12096
338c728c 12097@node TAN
12098@section @code{TAN} --- Tangent function
a1149005 12099@fnindex TAN
12100@fnindex DTAN
12101@cindex trigonometric function, tangent
12102@cindex tangent
338c728c 12103
12104@table @asis
12105@item @emph{Description}:
12106@code{TAN(X)} computes the tangent of @var{X}.
12107
a3c4ed23 12108@item @emph{Standard}:
4ca842c8 12109Fortran 77 and later, for a complex argument Fortran 2008 or later
338c728c 12110
bb3d0c30 12111@item @emph{Class}:
a3c4ed23 12112Elemental function
338c728c 12113
12114@item @emph{Syntax}:
4eb41f08 12115@code{RESULT = TAN(X)}
338c728c 12116
12117@item @emph{Arguments}:
aee612a9 12118@multitable @columnfractions .15 .70
4ca842c8 12119@item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
338c728c 12120@end multitable
12121
12122@item @emph{Return value}:
4ca842c8 12123The return value has same type and kind as @var{X}.
338c728c 12124
12125@item @emph{Example}:
12126@smallexample
12127program test_tan
12128 real(8) :: x = 0.165_8
12129 x = tan(x)
12130end program test_tan
12131@end smallexample
12132
12133@item @emph{Specific names}:
aee612a9 12134@multitable @columnfractions .20 .20 .20 .25
7d74ce87 12135@item Name @tab Argument @tab Return type @tab Standard
12136@item @code{TAN(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 95 and later
12137@item @code{DTAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 95 and later
338c728c 12138@end multitable
a3c4ed23 12139
12140@item @emph{See also}:
12141@ref{ATAN}
338c728c 12142@end table
12143
12144
bb3d0c30 12145
c0075f3c 12146@node TANH
12147@section @code{TANH} --- Hyperbolic tangent function
a1149005 12148@fnindex TANH
12149@fnindex DTANH
c0075f3c 12150@cindex hyperbolic tangent
a1149005 12151@cindex hyperbolic function, tangent
12152@cindex tangent, hyperbolic
c0075f3c 12153
12154@table @asis
12155@item @emph{Description}:
12156@code{TANH(X)} computes the hyperbolic tangent of @var{X}.
12157
a3c4ed23 12158@item @emph{Standard}:
4ca842c8 12159Fortran 77 and later, for a complex argument Fortran 2008 or later
c0075f3c 12160
bb3d0c30 12161@item @emph{Class}:
a3c4ed23 12162Elemental function
c0075f3c 12163
12164@item @emph{Syntax}:
12165@code{X = TANH(X)}
12166
12167@item @emph{Arguments}:
aee612a9 12168@multitable @columnfractions .15 .70
4ca842c8 12169@item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
c0075f3c 12170@end multitable
12171
12172@item @emph{Return value}:
4ca842c8 12173The return value has same type and kind as @var{X}. If @var{X} is
12174complex, the imaginary part of the result is in radians. If @var{X}
12175is @code{REAL}, the return value lies in the range
c0075f3c 12176@math{ - 1 \leq tanh(x) \leq 1 }.
12177
12178@item @emph{Example}:
12179@smallexample
12180program test_tanh
12181 real(8) :: x = 2.1_8
12182 x = tanh(x)
12183end program test_tanh
12184@end smallexample
12185
12186@item @emph{Specific names}:
aee612a9 12187@multitable @columnfractions .20 .20 .20 .25
a3c4ed23 12188@item Name @tab Argument @tab Return type @tab Standard
7d74ce87 12189@item @code{TANH(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 95 and later
f40b44c0 12190@item @code{DTANH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 95 and later
c0075f3c 12191@end multitable
a3c4ed23 12192
12193@item @emph{See also}:
12194@ref{ATANH}
12195@end table
12196
12197
12198
a250d560 12199@node THIS_IMAGE
12200@section @code{THIS_IMAGE} --- Function that returns the cosubscript index of this image
12201@fnindex THIS_IMAGE
12786727 12202@cindex coarray, @code{THIS_IMAGE}
a250d560 12203@cindex images, index of this image
12204
12205@table @asis
12206@item @emph{Description}:
12207Returns the cosubscript for this image.
12208
12209@item @emph{Standard}:
12210Fortran 2008 and later
12211
12212@item @emph{Class}:
12213Transformational function
12214
12215@item @emph{Syntax}:
12216@multitable @columnfractions .80
12217@item @code{RESULT = THIS_IMAGE()}
12218@item @code{RESULT = THIS_IMAGE(COARRAY [, DIM])}
12219@end multitable
12220
12221@item @emph{Arguments}:
12222@multitable @columnfractions .15 .70
12223@item @var{COARRAY} @tab Coarray of any type (optional; if @var{DIM}
12224present, required).
12225@item @var{DIM} @tab default integer scalar (optional). If present,
12226@var{DIM} shall be between one and the corank of @var{COARRAY}.
12227@end multitable
12228
12229
12230@item @emph{Return value}:
12231Default integer. If @var{COARRAY} is not present, it is scalar and its value
12232is the index of the invoking image. Otherwise, if @var{DIM} is not present,
12233a rank-1 array with corank elements is returned, containing the cosubscripts
12234for @var{COARRAY} specifying the invoking image. If @var{DIM} is present,
12235a scalar is returned, with the value of the @var{DIM} element of
12236@code{THIS_IMAGE(COARRAY)}.
12237
12238@item @emph{Example}:
12239@smallexample
12240INTEGER :: value[*]
12241INTEGER :: i
12242value = THIS_IMAGE()
12243SYNC ALL
12244IF (THIS_IMAGE() == 1) THEN
12245 DO i = 1, NUM_IMAGES()
12246 WRITE(*,'(2(a,i0))') 'value[', i, '] is ', value[i]
12247 END DO
12248END IF
12249@end smallexample
12250
12251@item @emph{See also}:
12252@ref{NUM_IMAGES}, @ref{IMAGE_INDEX}
12253@end table
12254
12255
12256
a3c4ed23 12257@node TIME
12258@section @code{TIME} --- Time function
a1149005 12259@fnindex TIME
5e246457 12260@cindex time, current
12261@cindex current time
a3c4ed23 12262
0eb92d52 12263@table @asis
12264@item @emph{Description}:
12265Returns the current time encoded as an integer (in the manner of the
be960ff7 12266function @code{time(3)} in the C standard library). This value is
12267suitable for passing to @code{CTIME}, @code{GMTIME}, and @code{LTIME}.
0eb92d52 12268
12269This intrinsic is not fully portable, such as to systems with 32-bit
12270@code{INTEGER} types but supporting times wider than 32 bits. Therefore,
12271the values returned by this intrinsic might be, or become, negative, or
12272numerically less than previous values, during a single run of the
12273compiled program.
12274
12275See @ref{TIME8}, for information on a similar intrinsic that might be
12276portable to more GNU Fortran implementations, though to fewer Fortran
12277compilers.
12278
12279@item @emph{Standard}:
12280GNU extension
12281
12282@item @emph{Class}:
138b8aca 12283Function
0eb92d52 12284
12285@item @emph{Syntax}:
12286@code{RESULT = TIME()}
12287
12288@item @emph{Return value}:
12289The return value is a scalar of type @code{INTEGER(4)}.
12290
12291@item @emph{See also}:
fe97b755 12292@ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME8}
0eb92d52 12293
12294@end table
12295
12296
12297
12298@node TIME8
12299@section @code{TIME8} --- Time function (64-bit)
a1149005 12300@fnindex TIME8
0eb92d52 12301@cindex time, current
12302@cindex current time
a3c4ed23 12303
12304@table @asis
12305@item @emph{Description}:
0eb92d52 12306Returns the current time encoded as an integer (in the manner of the
be960ff7 12307function @code{time(3)} in the C standard library). This value is
12308suitable for passing to @code{CTIME}, @code{GMTIME}, and @code{LTIME}.
0eb92d52 12309
12310@emph{Warning:} this intrinsic does not increase the range of the timing
12311values over that returned by @code{time(3)}. On a system with a 32-bit
e8c1bbb4 12312@code{time(3)}, @code{TIME8} will return a 32-bit value, even though
0eb92d52 12313it is converted to a 64-bit @code{INTEGER(8)} value. That means
12314overflows of the 32-bit value can still occur. Therefore, the values
12315returned by this intrinsic might be or become negative or numerically
12316less than previous values during a single run of the compiled program.
12317
a3c4ed23 12318@item @emph{Standard}:
12319GNU extension
12320
12321@item @emph{Class}:
138b8aca 12322Function
a3c4ed23 12323
12324@item @emph{Syntax}:
0eb92d52 12325@code{RESULT = TIME8()}
12326
a3c4ed23 12327@item @emph{Return value}:
0eb92d52 12328The return value is a scalar of type @code{INTEGER(8)}.
12329
a3c4ed23 12330@item @emph{See also}:
fe97b755 12331@ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK8}, @ref{TIME}
0eb92d52 12332
c0075f3c 12333@end table
1ef88f15 12334
12335
12336
572d7b7f 12337@node TINY
12338@section @code{TINY} --- Smallest positive number of a real kind
a1149005 12339@fnindex TINY
12340@cindex limits, smallest number
12341@cindex model representation, smallest number
572d7b7f 12342
12343@table @asis
12344@item @emph{Description}:
12345@code{TINY(X)} returns the smallest positive (non zero) number
12346in the model of the type of @code{X}.
12347
a3c4ed23 12348@item @emph{Standard}:
f40b44c0 12349Fortran 95 and later
572d7b7f 12350
12351@item @emph{Class}:
5dce3893 12352Inquiry function
572d7b7f 12353
12354@item @emph{Syntax}:
4eb41f08 12355@code{RESULT = TINY(X)}
572d7b7f 12356
12357@item @emph{Arguments}:
aee612a9 12358@multitable @columnfractions .15 .70
e0c54690 12359@item @var{X} @tab Shall be of type @code{REAL}.
572d7b7f 12360@end multitable
12361
12362@item @emph{Return value}:
12363The return value is of the same type and kind as @var{X}
12364
12365@item @emph{Example}:
12366See @code{HUGE} for an example.
12367@end table
12368
12369
12370
0b820f43 12371@node TRAILZ
12372@section @code{TRAILZ} --- Number of trailing zero bits of an integer
12373@fnindex TRAILZ
12374@cindex zero bits
12375
12376@table @asis
12377@item @emph{Description}:
12378@code{TRAILZ} returns the number of trailing zero bits of an integer.
12379
12380@item @emph{Standard}:
12381Fortran 2008 and later
12382
12383@item @emph{Class}:
12384Elemental function
12385
12386@item @emph{Syntax}:
12387@code{RESULT = TRAILZ(I)}
12388
12389@item @emph{Arguments}:
12390@multitable @columnfractions .15 .70
12391@item @var{I} @tab Shall be of type @code{INTEGER}.
12392@end multitable
12393
12394@item @emph{Return value}:
12395The type of the return value is the default @code{INTEGER}.
12396If all the bits of @code{I} are zero, the result value is @code{BIT_SIZE(I)}.
12397
12398@item @emph{Example}:
12399@smallexample
12400PROGRAM test_trailz
12401 WRITE (*,*) TRAILZ(8) ! prints 3
12402END PROGRAM
12403@end smallexample
12404
12405@item @emph{See also}:
41cbc93c 12406@ref{BIT_SIZE}, @ref{LEADZ}, @ref{POPPAR}, @ref{POPCNT}
0b820f43 12407@end table
12408
12409
12410
a3c4ed23 12411@node TRANSFER
12412@section @code{TRANSFER} --- Transfer bit patterns
a1149005 12413@fnindex TRANSFER
12414@cindex bits, move
c3faa3c9 12415@cindex type cast
a3c4ed23 12416
12417@table @asis
12418@item @emph{Description}:
ae1ebe4a 12419Interprets the bitwise representation of @var{SOURCE} in memory as if it
12420is the representation of a variable or array of the same type and type
12421parameters as @var{MOLD}.
c3faa3c9 12422
ae1ebe4a 12423This is approximately equivalent to the C concept of @emph{casting} one
12424type to another.
c3faa3c9 12425
a3c4ed23 12426@item @emph{Standard}:
f40b44c0 12427Fortran 95 and later
a3c4ed23 12428
12429@item @emph{Class}:
12430Transformational function
12431
12432@item @emph{Syntax}:
c3faa3c9 12433@code{RESULT = TRANSFER(SOURCE, MOLD[, SIZE])}
12434
a3c4ed23 12435@item @emph{Arguments}:
c3faa3c9 12436@multitable @columnfractions .15 .70
12437@item @var{SOURCE} @tab Shall be a scalar or an array of any type.
12438@item @var{MOLD} @tab Shall be a scalar or an array of any type.
ae1ebe4a 12439@item @var{SIZE} @tab (Optional) shall be a scalar of type
c3faa3c9 12440@code{INTEGER}.
12441@end multitable
12442
a3c4ed23 12443@item @emph{Return value}:
ae1ebe4a 12444The result has the same type as @var{MOLD}, with the bit level
12445representation of @var{SOURCE}. If @var{SIZE} is present, the result is
12446a one-dimensional array of length @var{SIZE}. If @var{SIZE} is absent
12447but @var{MOLD} is an array (of any size or shape), the result is a one-
12448dimensional array of the minimum length needed to contain the entirety
12449of the bitwise representation of @var{SOURCE}. If @var{SIZE} is absent
12450and @var{MOLD} is a scalar, the result is a scalar.
12451
12452If the bitwise representation of the result is longer than that of
12453@var{SOURCE}, then the leading bits of the result correspond to those of
12454@var{SOURCE} and any trailing bits are filled arbitrarily.
12455
12456When the resulting bit representation does not correspond to a valid
12457representation of a variable of the same type as @var{MOLD}, the results
12458are undefined, and subsequent operations on the result cannot be
12459guaranteed to produce sensible behavior. For example, it is possible to
12460create @code{LOGICAL} variables for which @code{@var{VAR}} and
12461@code{.NOT.@var{VAR}} both appear to be true.
c3faa3c9 12462
a3c4ed23 12463@item @emph{Example}:
c3faa3c9 12464@smallexample
12465PROGRAM test_transfer
12466 integer :: x = 2143289344
12467 print *, transfer(x, 1.0) ! prints "NaN" on i686
12468END PROGRAM
12469@end smallexample
a3c4ed23 12470@end table
12471
12472
12473
a3c4ed23 12474@node TRANSPOSE
12475@section @code{TRANSPOSE} --- Transpose an array of rank two
a1149005 12476@fnindex TRANSPOSE
12477@cindex array, transpose
12478@cindex matrix, transpose
12479@cindex transpose
a3c4ed23 12480
a3c4ed23 12481@table @asis
12482@item @emph{Description}:
8873d8a6 12483Transpose an array of rank two. Element (i, j) of the result has the value
12484@code{MATRIX(j, i)}, for all i, j.
12485
a3c4ed23 12486@item @emph{Standard}:
f40b44c0 12487Fortran 95 and later
a3c4ed23 12488
12489@item @emph{Class}:
12490Transformational function
12491
12492@item @emph{Syntax}:
8873d8a6 12493@code{RESULT = TRANSPOSE(MATRIX)}
12494
a3c4ed23 12495@item @emph{Arguments}:
8873d8a6 12496@multitable @columnfractions .15 .70
12497@item @var{MATRIX} @tab Shall be an array of any type and have a rank of two.
12498@end multitable
12499
a3c4ed23 12500@item @emph{Return value}:
2dd2bcbd 12501The result has the same type as @var{MATRIX}, and has shape
8873d8a6 12502@code{(/ m, n /)} if @var{MATRIX} has shape @code{(/ n, m /)}.
a3c4ed23 12503@end table
12504
12505
12506
a3c4ed23 12507@node TRIM
8873d8a6 12508@section @code{TRIM} --- Remove trailing blank characters of a string
a1149005 12509@fnindex TRIM
12510@cindex string, remove trailing whitespace
a3c4ed23 12511
a3c4ed23 12512@table @asis
12513@item @emph{Description}:
8873d8a6 12514Removes trailing blank characters of a string.
12515
a3c4ed23 12516@item @emph{Standard}:
f40b44c0 12517Fortran 95 and later
a3c4ed23 12518
12519@item @emph{Class}:
12520Transformational function
12521
12522@item @emph{Syntax}:
8873d8a6 12523@code{RESULT = TRIM(STRING)}
12524
a3c4ed23 12525@item @emph{Arguments}:
8873d8a6 12526@multitable @columnfractions .15 .70
e06f8026 12527@item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER}.
8873d8a6 12528@end multitable
12529
a3c4ed23 12530@item @emph{Return value}:
e06f8026 12531A scalar of type @code{CHARACTER} which length is that of @var{STRING}
8873d8a6 12532less the number of trailing blanks.
12533
a3c4ed23 12534@item @emph{Example}:
8873d8a6 12535@smallexample
12536PROGRAM test_trim
12537 CHARACTER(len=10), PARAMETER :: s = "GFORTRAN "
12538 WRITE(*,*) LEN(s), LEN(TRIM(s)) ! "10 8", with/without trailing blanks
12539END PROGRAM
12540@end smallexample
12541
a3c4ed23 12542@item @emph{See also}:
8873d8a6 12543@ref{ADJUSTL}, @ref{ADJUSTR}
a3c4ed23 12544@end table
12545
12546
12547
475c7d78 12548@node TTYNAM
12549@section @code{TTYNAM} --- Get the name of a terminal device.
a1149005 12550@fnindex TTYNAM
12551@cindex system, terminal
475c7d78 12552
12553@table @asis
12554@item @emph{Description}:
12555Get the name of a terminal device. For more information,
12556see @code{ttyname(3)}.
12557
12558This intrinsic is provided in both subroutine and function forms;
12559however, only one form can be used in any given program unit.
12560
12561@item @emph{Standard}:
12562GNU extension
12563
12564@item @emph{Class}:
138b8aca 12565Subroutine, function
475c7d78 12566
12567@item @emph{Syntax}:
12568@multitable @columnfractions .80
12569@item @code{CALL TTYNAM(UNIT, NAME)}
12570@item @code{NAME = TTYNAM(UNIT)}
12571@end multitable
12572
12573@item @emph{Arguments}:
12574@multitable @columnfractions .15 .70
e06f8026 12575@item @var{UNIT} @tab Shall be a scalar @code{INTEGER}.
12576@item @var{NAME} @tab Shall be of type @code{CHARACTER}.
475c7d78 12577@end multitable
12578
12579@item @emph{Example}:
12580@smallexample
12581PROGRAM test_ttynam
12582 INTEGER :: unit
12583 DO unit = 1, 10
12584 IF (isatty(unit=unit)) write(*,*) ttynam(unit)
12585 END DO
12586END PROGRAM
12587@end smallexample
12588
12589@item @emph{See also}:
12590@ref{ISATTY}
12591@end table
12592
12593
12594
a3c4ed23 12595@node UBOUND
12596@section @code{UBOUND} --- Upper dimension bounds of an array
a1149005 12597@fnindex UBOUND
12598@cindex array, upper bound
a3c4ed23 12599
12600@table @asis
12601@item @emph{Description}:
b620ae12 12602Returns the upper bounds of an array, or a single upper bound
12603along the @var{DIM} dimension.
a3c4ed23 12604@item @emph{Standard}:
f40b44c0 12605Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
a3c4ed23 12606
12607@item @emph{Class}:
12608Inquiry function
12609
12610@item @emph{Syntax}:
7fe55cc9 12611@code{RESULT = UBOUND(ARRAY [, DIM [, KIND]])}
b620ae12 12612
a3c4ed23 12613@item @emph{Arguments}:
aee612a9 12614@multitable @columnfractions .15 .70
b620ae12 12615@item @var{ARRAY} @tab Shall be an array, of any type.
e06f8026 12616@item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
7fe55cc9 12617@item @var{KIND}@tab (Optional) An @code{INTEGER} initialization
c24c5fac 12618expression indicating the kind parameter of the result.
b620ae12 12619@end multitable
12620
a3c4ed23 12621@item @emph{Return value}:
7fe55cc9 12622The return value is of type @code{INTEGER} and of kind @var{KIND}. If
12623@var{KIND} is absent, the return value is of default integer kind.
b620ae12 12624If @var{DIM} is absent, the result is an array of the upper bounds of
12625@var{ARRAY}. If @var{DIM} is present, the result is a scalar
12626corresponding to the upper bound of the array along that dimension. If
12627@var{ARRAY} is an expression rather than a whole array or array
12628structure component, or if it has a zero extent along the relevant
12629dimension, the upper bound is taken to be the number of elements along
12630the relevant dimension.
a3c4ed23 12631
12632@item @emph{See also}:
a250d560 12633@ref{LBOUND}, @ref{LCOBOUND}
12634@end table
12635
12636
12637
12638@node UCOBOUND
12639@section @code{UCOBOUND} --- Upper codimension bounds of an array
12640@fnindex UCOBOUND
12641@cindex coarray, upper bound
12642
12643@table @asis
12644@item @emph{Description}:
12645Returns the upper cobounds of a coarray, or a single upper cobound
12646along the @var{DIM} codimension.
12647@item @emph{Standard}:
12648Fortran 2008 and later
12649
12650@item @emph{Class}:
12651Inquiry function
12652
12653@item @emph{Syntax}:
12654@code{RESULT = UCOBOUND(COARRAY [, DIM [, KIND]])}
12655
12656@item @emph{Arguments}:
12657@multitable @columnfractions .15 .70
12658@item @var{ARRAY} @tab Shall be an coarray, of any type.
12659@item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
12660@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
12661expression indicating the kind parameter of the result.
12662@end multitable
12663
12664@item @emph{Return value}:
12665The return value is of type @code{INTEGER} and of kind @var{KIND}. If
12666@var{KIND} is absent, the return value is of default integer kind.
12667If @var{DIM} is absent, the result is an array of the lower cobounds of
12668@var{COARRAY}. If @var{DIM} is present, the result is a scalar
12669corresponding to the lower cobound of the array along that codimension.
12670
12671@item @emph{See also}:
12672@ref{LCOBOUND}, @ref{LBOUND}
a3c4ed23 12673@end table
12674
12675
12676
a3c4ed23 12677@node UMASK
12678@section @code{UMASK} --- Set the file creation mask
a1149005 12679@fnindex UMASK
12680@cindex file system, file creation mask
a3c4ed23 12681
a3c4ed23 12682@table @asis
12683@item @emph{Description}:
2cd8ef8b 12684Sets the file creation mask to @var{MASK}. If called as a function, it
12685returns the old value. If called as a subroutine and argument @var{OLD}
12686if it is supplied, it is set to the old value. See @code{umask(2)}.
4eb41f08 12687
a3c4ed23 12688@item @emph{Standard}:
12689GNU extension
12690
12691@item @emph{Class}:
2cd8ef8b 12692Subroutine, function
a3c4ed23 12693
12694@item @emph{Syntax}:
6c07e6d8 12695@multitable @columnfractions .80
12696@item @code{CALL UMASK(MASK [, OLD])}
12697@item @code{OLD = UMASK(MASK)}
12698@end multitable
4eb41f08 12699
a3c4ed23 12700@item @emph{Arguments}:
aee612a9 12701@multitable @columnfractions .15 .70
e06f8026 12702@item @var{MASK} @tab Shall be a scalar of type @code{INTEGER}.
2cd8ef8b 12703@item @var{OLD} @tab (Optional) Shall be a scalar of type
c24c5fac 12704@code{INTEGER}.
4eb41f08 12705@end multitable
12706
a3c4ed23 12707@end table
12708
12709
12710
a3c4ed23 12711@node UNLINK
12712@section @code{UNLINK} --- Remove a file from the file system
a1149005 12713@fnindex UNLINK
12714@cindex file system, remove file
a3c4ed23 12715
a3c4ed23 12716@table @asis
12717@item @emph{Description}:
2e3f30e8 12718Unlinks the file @var{PATH}. A null character (@code{CHAR(0)}) can be
12719used to mark the end of the name in @var{PATH}; otherwise, trailing
12720blanks in the file name are ignored. If the @var{STATUS} argument is
12721supplied, it contains 0 on success or a nonzero error code upon return;
0eb92d52 12722see @code{unlink(2)}.
b620ae12 12723
31eea2fc 12724This intrinsic is provided in both subroutine and function forms;
12725however, only one form can be used in any given program unit.
12726
a3c4ed23 12727@item @emph{Standard}:
12728GNU extension
12729
12730@item @emph{Class}:
138b8aca 12731Subroutine, function
a3c4ed23 12732
12733@item @emph{Syntax}:
31eea2fc 12734@multitable @columnfractions .80
12735@item @code{CALL UNLINK(PATH [, STATUS])}
12736@item @code{STATUS = UNLINK(PATH)}
12737@end multitable
b620ae12 12738
a3c4ed23 12739@item @emph{Arguments}:
aee612a9 12740@multitable @columnfractions .15 .70
b620ae12 12741@item @var{PATH} @tab Shall be of default @code{CHARACTER} type.
12742@item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
12743@end multitable
a3c4ed23 12744
12745@item @emph{See also}:
0eb92d52 12746@ref{LINK}, @ref{SYMLNK}
a3c4ed23 12747@end table
12748
12749
12750
a3c4ed23 12751@node UNPACK
12752@section @code{UNPACK} --- Unpack an array of rank one into an array
a1149005 12753@fnindex UNPACK
12754@cindex array, unpacking
12755@cindex array, increase dimension
12756@cindex array, scatter elements
a3c4ed23 12757
a3c4ed23 12758@table @asis
12759@item @emph{Description}:
c3faa3c9 12760Store the elements of @var{VECTOR} in an array of higher rank.
12761
a3c4ed23 12762@item @emph{Standard}:
f40b44c0 12763Fortran 95 and later
a3c4ed23 12764
12765@item @emph{Class}:
12766Transformational function
12767
12768@item @emph{Syntax}:
c3faa3c9 12769@code{RESULT = UNPACK(VECTOR, MASK, FIELD)}
12770
a3c4ed23 12771@item @emph{Arguments}:
c3faa3c9 12772@multitable @columnfractions .15 .70
12773@item @var{VECTOR} @tab Shall be an array of any type and rank one. It
12774shall have at least as many elements as @var{MASK} has @code{TRUE} values.
12775@item @var{MASK} @tab Shall be an array of type @code{LOGICAL}.
2dd2bcbd 12776@item @var{FIELD} @tab Shall be of the same type as @var{VECTOR} and have
c3faa3c9 12777the same shape as @var{MASK}.
12778@end multitable
12779
a3c4ed23 12780@item @emph{Return value}:
c3faa3c9 12781The resulting array corresponds to @var{FIELD} with @code{TRUE} elements
12782of @var{MASK} replaced by values from @var{VECTOR} in array element order.
12783
a3c4ed23 12784@item @emph{Example}:
c3faa3c9 12785@smallexample
12786PROGRAM test_unpack
12787 integer :: vector(2) = (/1,1/)
a1149005 12788 logical :: mask(4) = (/ .TRUE., .FALSE., .FALSE., .TRUE. /)
c3faa3c9 12789 integer :: field(2,2) = 0, unity(2,2)
12790
12791 ! result: unity matrix
a1149005 12792 unity = unpack(vector, reshape(mask, (/2,2/)), field)
c3faa3c9 12793END PROGRAM
12794@end smallexample
a3c4ed23 12795
12796@item @emph{See also}:
c3faa3c9 12797@ref{PACK}, @ref{SPREAD}
a3c4ed23 12798@end table
12799
12800
12801
a3c4ed23 12802@node VERIFY
d11051b3 12803@section @code{VERIFY} --- Scan a string for characters not a given set
a1149005 12804@fnindex VERIFY
12805@cindex string, find missing set
a3c4ed23 12806
a3c4ed23 12807@table @asis
12808@item @emph{Description}:
668d2771 12809Verifies that all the characters in @var{STRING} belong to the set of
d11051b3 12810characters in @var{SET}.
8873d8a6 12811
12812If @var{BACK} is either absent or equals @code{FALSE}, this function
12813returns the position of the leftmost character of @var{STRING} that is
d11051b3 12814not in @var{SET}. If @var{BACK} equals @code{TRUE}, the rightmost
12815position is returned. If all characters of @var{STRING} are found in
12816@var{SET}, the result is zero.
8873d8a6 12817
a3c4ed23 12818@item @emph{Standard}:
f40b44c0 12819Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
a3c4ed23 12820
12821@item @emph{Class}:
12822Elemental function
12823
12824@item @emph{Syntax}:
7fe55cc9 12825@code{RESULT = VERIFY(STRING, SET[, BACK [, KIND]])}
8873d8a6 12826
a3c4ed23 12827@item @emph{Arguments}:
8873d8a6 12828@multitable @columnfractions .15 .70
e06f8026 12829@item @var{STRING} @tab Shall be of type @code{CHARACTER}.
12830@item @var{SET} @tab Shall be of type @code{CHARACTER}.
8873d8a6 12831@item @var{BACK} @tab (Optional) shall be of type @code{LOGICAL}.
7fe55cc9 12832@item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
c24c5fac 12833expression indicating the kind parameter of the result.
8873d8a6 12834@end multitable
12835
a3c4ed23 12836@item @emph{Return value}:
7fe55cc9 12837The return value is of type @code{INTEGER} and of kind @var{KIND}. If
12838@var{KIND} is absent, the return value is of default integer kind.
8873d8a6 12839
a3c4ed23 12840@item @emph{Example}:
8873d8a6 12841@smallexample
12842PROGRAM test_verify
12843 WRITE(*,*) VERIFY("FORTRAN", "AO") ! 1, found 'F'
12844 WRITE(*,*) VERIFY("FORTRAN", "FOO") ! 3, found 'R'
12845 WRITE(*,*) VERIFY("FORTRAN", "C++") ! 1, found 'F'
12846 WRITE(*,*) VERIFY("FORTRAN", "C++", .TRUE.) ! 7, found 'N'
12847 WRITE(*,*) VERIFY("FORTRAN", "FORTRAN") ! 0' found none
12848END PROGRAM
12849@end smallexample
12850
a3c4ed23 12851@item @emph{See also}:
70dabb1d 12852@ref{SCAN}, @ref{INDEX intrinsic}
a3c4ed23 12853@end table
12854
12855
0eb92d52 12856
a3c4ed23 12857@node XOR
ed8f9044 12858@section @code{XOR} --- Bitwise logical exclusive OR
a1149005 12859@fnindex XOR
12860@cindex bitwise logical exclusive or
12861@cindex logical exclusive or, bitwise
a3c4ed23 12862
12863@table @asis
12864@item @emph{Description}:
ed8f9044 12865Bitwise logical exclusive or.
12866
12867This intrinsic routine is provided for backwards compatibility with
12868GNU Fortran 77. For integer arguments, programmers should consider
266e3ca1 12869the use of the @ref{IEOR} intrinsic and for logical arguments the
12870@code{.NEQV.} operator, which are both defined by the Fortran standard.
ed8f9044 12871
a3c4ed23 12872@item @emph{Standard}:
ed8f9044 12873GNU extension
a3c4ed23 12874
12875@item @emph{Class}:
138b8aca 12876Function
ed8f9044 12877
a3c4ed23 12878@item @emph{Syntax}:
2cd8ef8b 12879@code{RESULT = XOR(I, J)}
ed8f9044 12880
a3c4ed23 12881@item @emph{Arguments}:
aee612a9 12882@multitable @columnfractions .15 .70
2cd8ef8b 12883@item @var{I} @tab The type shall be either a scalar @code{INTEGER}
a48103f3 12884type or a scalar @code{LOGICAL} type.
2cd8ef8b 12885@item @var{J} @tab The type shall be the same as the type of @var{I}.
ed8f9044 12886@end multitable
12887
a3c4ed23 12888@item @emph{Return value}:
e06f8026 12889The return type is either a scalar @code{INTEGER} or a scalar
a48103f3 12890@code{LOGICAL}. If the kind type parameters differ, then the
12891smaller kind type is implicitly converted to larger kind, and the
12892return has the larger kind.
ed8f9044 12893
a3c4ed23 12894@item @emph{Example}:
ed8f9044 12895@smallexample
12896PROGRAM test_xor
12897 LOGICAL :: T = .TRUE., F = .FALSE.
12898 INTEGER :: a, b
b9f2f128 12899 DATA a / Z'F' /, b / Z'3' /
ed8f9044 12900
12901 WRITE (*,*) XOR(T, T), XOR(T, F), XOR(F, T), XOR(F, F)
12902 WRITE (*,*) XOR(a, b)
12903END PROGRAM
12904@end smallexample
12905
a3c4ed23 12906@item @emph{See also}:
f40b44c0 12907Fortran 95 elemental function: @ref{IEOR}
a3c4ed23 12908@end table
12909
12910
ffc54dbd 12911
12912@node Intrinsic Modules
12913@chapter Intrinsic Modules
12914@cindex intrinsic Modules
12915
0c7efac1 12916@menu
12917* ISO_FORTRAN_ENV::
12918* ISO_C_BINDING::
12919* OpenMP Modules OMP_LIB and OMP_LIB_KINDS::
12920@end menu
12921
12922@node ISO_FORTRAN_ENV
ffc54dbd 12923@section @code{ISO_FORTRAN_ENV}
12924@table @asis
12925@item @emph{Standard}:
e1eea5a7 12926Fortran 2003 and later, except when otherwise noted
ffc54dbd 12927@end table
12928
12929The @code{ISO_FORTRAN_ENV} module provides the following scalar default-integer
12930named constants:
12931
12932@table @asis
e1eea5a7 12933@item @code{ATOMIC_INT_KIND}:
12934Default-kind integer constant to be used as kind parameter when defining
12935integer variables used in atomic operations. (Fortran 2008 or later.)
12936
12937@item @code{ATOMIC_LOGICAL_KIND}:
12938Default-kind integer constant to be used as kind parameter when defining
12939logical variables used in atomic operations. (Fortran 2008 or later.)
12940
cd2c99b8 12941@item @code{CHARACTER_KINDS}:
12942Default-kind integer constant array of rank one containing the supported kind
12943parameters of the @code{CHARACTER} type. (Fortran 2008 or later.)
12944
ffc54dbd 12945@item @code{CHARACTER_STORAGE_SIZE}:
12946Size in bits of the character storage unit.
12947
12948@item @code{ERROR_UNIT}:
2dd2bcbd 12949Identifies the preconnected unit used for error reporting.
ffc54dbd 12950
12951@item @code{FILE_STORAGE_SIZE}:
12952Size in bits of the file-storage unit.
12953
12954@item @code{INPUT_UNIT}:
2dd2bcbd 12955Identifies the preconnected unit identified by the asterisk
ffc54dbd 12956(@code{*}) in @code{READ} statement.
12957
e1eea5a7 12958@item @code{INT8}, @code{INT16}, @code{INT32}, @code{INT64}:
6ba3bda4 12959Kind type parameters to specify an INTEGER type with a storage
12960size of 16, 32, and 64 bits. It is negative if a target platform
e1eea5a7 12961does not support the particular kind. (Fortran 2008 or later.)
6ba3bda4 12962
cd2c99b8 12963@item @code{INTEGER_KINDS}:
12964Default-kind integer constant array of rank one containing the supported kind
12965parameters of the @code{INTEGER} type. (Fortran 2008 or later.)
12966
ffc54dbd 12967@item @code{IOSTAT_END}:
12786727 12968The value assigned to the variable passed to the @code{IOSTAT=} specifier of
ffc54dbd 12969an input/output statement if an end-of-file condition occurred.
12970
12971@item @code{IOSTAT_EOR}:
12786727 12972The value assigned to the variable passed to the @code{IOSTAT=} specifier of
ffc54dbd 12973an input/output statement if an end-of-record condition occurred.
12974
e1eea5a7 12975@item @code{IOSTAT_INQUIRE_INTERNAL_UNIT}:
12976Scalar default-integer constant, used by @code{INQUIRE} for the
12786727 12977@code{IOSTAT=} specifier to denote an that a unit number identifies an
e1eea5a7 12978internal unit. (Fortran 2008 or later.)
12979
ffc54dbd 12980@item @code{NUMERIC_STORAGE_SIZE}:
12981The size in bits of the numeric storage unit.
12982
cd2c99b8 12983@item @code{LOGICAL_KINDS}:
12984Default-kind integer constant array of rank one containing the supported kind
12985parameters of the @code{LOGICAL} type. (Fortran 2008 or later.)
12986
ffc54dbd 12987@item @code{OUTPUT_UNIT}:
2dd2bcbd 12988Identifies the preconnected unit identified by the asterisk
ffc54dbd 12989(@code{*}) in @code{WRITE} statement.
6ba3bda4 12990
e1eea5a7 12991@item @code{REAL32}, @code{REAL64}, @code{REAL128}:
6ba3bda4 12992Kind type parameters to specify a REAL type with a storage
12993size of 32, 64, and 128 bits. It is negative if a target platform
e1eea5a7 12994does not support the particular kind. (Fortran 2008 or later.)
12995
cd2c99b8 12996@item @code{REAL_KINDS}:
12997Default-kind integer constant array of rank one containing the supported kind
12998parameters of the @code{REAL} type. (Fortran 2008 or later.)
12999
e1eea5a7 13000@item @code{STAT_LOCKED}:
13001Scalar default-integer constant used as STAT= return value by @code{LOCK} to
13002denote that the lock variable is locked by the executing image. (Fortran 2008
13003or later.)
13004
13005@item @code{STAT_LOCKED_OTHER_IMAGE}:
13006Scalar default-integer constant used as STAT= return value by @code{UNLOCK} to
13007denote that the lock variable is locked by another image. (Fortran 2008 or
13008later.)
13009
13010@item @code{STAT_STOPPED_IMAGE}:
13011Positive, scalar default-integer constant used as STAT= return value if the
13012argument in the statement requires synchronisation with an image, which has
13013initiated the termination of the execution. (Fortran 2008 or later.)
13014
13015@item @code{STAT_UNLOCKED}:
13016Scalar default-integer constant used as STAT= return value by @code{UNLOCK} to
13017denote that the lock variable is unlocked. (Fortran 2008 or later.)
ffc54dbd 13018@end table
13019
c135f087 13020The module provides the following derived type:
13021
13022@table @asis
13023@item @code{LOCK_TYPE}:
13024Derived type with private components to be use with the @code{LOCK} and
13025@code{UNLOCK} statement. A variable of its type has to be always declared
13026as coarray and may not appear in a variable-definition context.
13027(Fortran 2008 or later.)
13028@end table
13029
e3d1ab2b 13030The module also provides the following intrinsic procedures:
13031@ref{COMPILER_OPTIONS} and @ref{COMPILER_VERSION}.
13032
6ba3bda4 13033
13034
0c7efac1 13035@node ISO_C_BINDING
ffc54dbd 13036@section @code{ISO_C_BINDING}
13037@table @asis
13038@item @emph{Standard}:
10fc9353 13039Fortran 2003 and later, GNU extensions
ffc54dbd 13040@end table
13041
13042The following intrinsic procedures are provided by the module; their
13043definition can be found in the section Intrinsic Procedures of this
13044manual.
13045
13046@table @asis
13047@item @code{C_ASSOCIATED}
13048@item @code{C_F_POINTER}
13049@item @code{C_F_PROCPOINTER}
13050@item @code{C_FUNLOC}
13051@item @code{C_LOC}
e3d1ab2b 13052@item @code{C_SIZEOF}
ffc54dbd 13053@end table
57b9ac90 13054@c TODO: Vertical spacing between C_FUNLOC and C_LOC wrong in PDF,
13055@c don't really know why.
ffc54dbd 13056
0c7efac1 13057The @code{ISO_C_BINDING} module provides the following named constants of
13058type default integer, which can be used as KIND type parameters.
ffc54dbd 13059
10fc9353 13060In addition to the integer named constants required by the Fortran 2003
6f88d0ff 13061standard and @code{C_PTRDIFF_T} of TS 29113, GNU Fortran provides as an
13062extension named constants for the 128-bit integer types supported by the
13063C compiler: @code{C_INT128_T, C_INT_LEAST128_T, C_INT_FAST128_T}.
13064Furthermore, if @code{__float128} is supported in C, the named constants
13065@code{C_FLOAT128, C_FLOAT128_COMPLEX} are defined.
10fc9353 13066
13067@multitable @columnfractions .15 .35 .35 .35
13068@item Fortran Type @tab Named constant @tab C type @tab Extension
ffc54dbd 13069@item @code{INTEGER}@tab @code{C_INT} @tab @code{int}
13070@item @code{INTEGER}@tab @code{C_SHORT} @tab @code{short int}
13071@item @code{INTEGER}@tab @code{C_LONG} @tab @code{long int}
13072@item @code{INTEGER}@tab @code{C_LONG_LONG} @tab @code{long long int}
13073@item @code{INTEGER}@tab @code{C_SIGNED_CHAR} @tab @code{signed char}/@code{unsigned char}
13074@item @code{INTEGER}@tab @code{C_SIZE_T} @tab @code{size_t}
13075@item @code{INTEGER}@tab @code{C_INT8_T} @tab @code{int8_t}
13076@item @code{INTEGER}@tab @code{C_INT16_T} @tab @code{int16_t}
13077@item @code{INTEGER}@tab @code{C_INT32_T} @tab @code{int32_t}
13078@item @code{INTEGER}@tab @code{C_INT64_T} @tab @code{int64_t}
0c7efac1 13079@item @code{INTEGER}@tab @code{C_INT128_T} @tab @code{int128_t} @tab Ext.
ffc54dbd 13080@item @code{INTEGER}@tab @code{C_INT_LEAST8_T} @tab @code{int_least8_t}
13081@item @code{INTEGER}@tab @code{C_INT_LEAST16_T} @tab @code{int_least16_t}
13082@item @code{INTEGER}@tab @code{C_INT_LEAST32_T} @tab @code{int_least32_t}
13083@item @code{INTEGER}@tab @code{C_INT_LEAST64_T} @tab @code{int_least64_t}
0c7efac1 13084@item @code{INTEGER}@tab @code{C_INT_LEAST128_T}@tab @code{int_least128_t} @tab Ext.
13085@item @code{INTEGER}@tab @code{C_INT_FAST8_T} @tab @code{int_fast8_t}
13086@item @code{INTEGER}@tab @code{C_INT_FAST16_T} @tab @code{int_fast16_t}
13087@item @code{INTEGER}@tab @code{C_INT_FAST32_T} @tab @code{int_fast32_t}
13088@item @code{INTEGER}@tab @code{C_INT_FAST64_T} @tab @code{int_fast64_t}
13089@item @code{INTEGER}@tab @code{C_INT_FAST128_T} @tab @code{int_fast128_t} @tab Ext.
ffc54dbd 13090@item @code{INTEGER}@tab @code{C_INTMAX_T} @tab @code{intmax_t}
13091@item @code{INTEGER}@tab @code{C_INTPTR_T} @tab @code{intptr_t}
6f88d0ff 13092@item @code{INTEGER}@tab @code{C_PTRDIFF_T} @tab @code{intptr_t} @tab TS 29113
ffc54dbd 13093@item @code{REAL} @tab @code{C_FLOAT} @tab @code{float}
13094@item @code{REAL} @tab @code{C_DOUBLE} @tab @code{double}
13095@item @code{REAL} @tab @code{C_LONG_DOUBLE} @tab @code{long double}
6387f861 13096@item @code{REAL} @tab @code{C_FLOAT128} @tab @code{__float128} @tab Ext.
ffc54dbd 13097@item @code{COMPLEX}@tab @code{C_FLOAT_COMPLEX} @tab @code{float _Complex}
13098@item @code{COMPLEX}@tab @code{C_DOUBLE_COMPLEX}@tab @code{double _Complex}
13099@item @code{COMPLEX}@tab @code{C_LONG_DOUBLE_COMPLEX}@tab @code{long double _Complex}
6387f861 13100@item @code{REAL} @tab @code{C_FLOAT128_COMPLEX} @tab @code{__float128 _Complex} @tab Ext.
ffc54dbd 13101@item @code{LOGICAL}@tab @code{C_BOOL} @tab @code{_Bool}
13102@item @code{CHARACTER}@tab @code{C_CHAR} @tab @code{char}
13103@end multitable
13104
53169279 13105Additionally, the following parameters of type @code{CHARACTER(KIND=C_CHAR)}
13106are defined.
ffc54dbd 13107
13108@multitable @columnfractions .20 .45 .15
13109@item Name @tab C definition @tab Value
13110@item @code{C_NULL_CHAR} @tab null character @tab @code{'\0'}
13111@item @code{C_ALERT} @tab alert @tab @code{'\a'}
13112@item @code{C_BACKSPACE} @tab backspace @tab @code{'\b'}
13113@item @code{C_FORM_FEED} @tab form feed @tab @code{'\f'}
13114@item @code{C_NEW_LINE} @tab new line @tab @code{'\n'}
13115@item @code{C_CARRIAGE_RETURN} @tab carriage return @tab @code{'\r'}
13116@item @code{C_HORIZONTAL_TAB} @tab horizontal tab @tab @code{'\t'}
13117@item @code{C_VERTICAL_TAB} @tab vertical tab @tab @code{'\v'}
13118@end multitable
13119
24c079ad 13120Moreover, the following two named constants are defined:
13121
13122@multitable @columnfractions .20 .80
13123@item Name @tab Type
13124@item @code{C_NULL_PTR} @tab @code{C_PTR}
13125@item @code{C_NULL_FUNPTR} @tab @code{C_FUNPTR}
13126@end multitable
13127
13128Both are equivalent to the value @code{NULL} in C.
13129
0c7efac1 13130@node OpenMP Modules OMP_LIB and OMP_LIB_KINDS
ffc54dbd 13131@section OpenMP Modules @code{OMP_LIB} and @code{OMP_LIB_KINDS}
13132@table @asis
13133@item @emph{Standard}:
2169f33b 13134OpenMP Application Program Interface v3.1
ffc54dbd 13135@end table
13136
13137
13138The OpenMP Fortran runtime library routines are provided both in
13139a form of two Fortran 90 modules, named @code{OMP_LIB} and
13140@code{OMP_LIB_KINDS}, and in a form of a Fortran @code{include} file named
13141@file{omp_lib.h}. The procedures provided by @code{OMP_LIB} can be found
13142in the @ref{Top,,Introduction,libgomp,GNU OpenMP runtime library} manual,
0c320ed3 13143the named constants defined in the modules are listed
ffc54dbd 13144below.
13145
13146For details refer to the actual
2169f33b 13147@uref{http://www.openmp.org/mp-documents/spec31.pdf,
13148OpenMP Application Program Interface v3.1}.
ffc54dbd 13149
13150@code{OMP_LIB_KINDS} provides the following scalar default-integer
13151named constants:
13152
13153@table @asis
ffc54dbd 13154@item @code{omp_lock_kind}
13155@item @code{omp_nest_lock_kind}
aaeb7d26 13156@item @code{omp_sched_kind}
ffc54dbd 13157@end table
0c320ed3 13158
13159@code{OMP_LIB} provides the scalar default-integer
13160named constant @code{openmp_version} with a value of the form
13161@var{yyyymm}, where @code{yyyy} is the year and @var{mm} the month
2169f33b 13162of the OpenMP version; for OpenMP v3.1 the value is @code{201107}.
0c320ed3 13163
13164And the following scalar integer named constants of the
13165kind @code{omp_sched_kind}:
13166
13167@table @asis
13168@item @code{omp_sched_static}
13169@item @code{omp_sched_dynamic}
13170@item @code{omp_sched_guided}
13171@item @code{omp_sched_auto}
13172@end table