2015-05-05 Yvan Roux <yvan.roux@linaro.org>
[official-gcc.git] / gcc / fortran / intrinsic.texi
blobc071d46cbc18e23e2b41b87f31fae86292fe54fd
1 @ignore
2 Copyright (C) 2005-2015 Free Software Foundation, Inc.
3 This is part of the GNU Fortran manual.   
4 For copying conditions, see the file gfortran.texi.
6 Permission is granted to copy, distribute and/or modify this document
7 under the terms of the GNU Free Documentation License, Version 1.3 or
8 any later version published by the Free Software Foundation; with the
9 Invariant Sections being ``Funding Free Software'', the Front-Cover
10 Texts being (a) (see below), and with the Back-Cover Texts being (b)
11 (see below).  A copy of the license is included in the gfdl(7) man page.
14 Some basic guidelines for editing this document:
16   (1) The intrinsic procedures are to be listed in alphabetical order.
17   (2) The generic name is to be used.
18   (3) The specific names are included in the function index and in a
19       table at the end of the node (See ABS entry).
20   (4) Try to maintain the same style for each entry.
23 @end ignore
25 @tex
26 \gdef\acos{\mathop{\rm acos}\nolimits}
27 \gdef\asin{\mathop{\rm asin}\nolimits}
28 \gdef\atan{\mathop{\rm atan}\nolimits}
29 \gdef\acosh{\mathop{\rm acosh}\nolimits}
30 \gdef\asinh{\mathop{\rm asinh}\nolimits}
31 \gdef\atanh{\mathop{\rm atanh}\nolimits}
32 @end tex
35 @node Intrinsic Procedures
36 @chapter Intrinsic Procedures
37 @cindex intrinsic procedures
39 @menu
40 * Introduction:         Introduction to Intrinsics
41 * @code{ABORT}:         ABORT,     Abort the program     
42 * @code{ABS}:           ABS,       Absolute value     
43 * @code{ACCESS}:        ACCESS,    Checks file access modes
44 * @code{ACHAR}:         ACHAR,     Character in @acronym{ASCII} collating sequence
45 * @code{ACOS}:          ACOS,      Arccosine function
46 * @code{ACOSH}:         ACOSH,     Inverse hyperbolic cosine function
47 * @code{ADJUSTL}:       ADJUSTL,   Left adjust a string
48 * @code{ADJUSTR}:       ADJUSTR,   Right adjust a string
49 * @code{AIMAG}:         AIMAG,     Imaginary part of complex number
50 * @code{AINT}:          AINT,      Truncate to a whole number
51 * @code{ALARM}:         ALARM,     Set an alarm clock
52 * @code{ALL}:           ALL,       Determine if all values are true
53 * @code{ALLOCATED}:     ALLOCATED, Status of allocatable entity
54 * @code{AND}:           AND,       Bitwise logical AND
55 * @code{ANINT}:         ANINT,     Nearest whole number
56 * @code{ANY}:           ANY,       Determine if any values are true
57 * @code{ASIN}:          ASIN,      Arcsine function
58 * @code{ASINH}:         ASINH,     Inverse hyperbolic sine function
59 * @code{ASSOCIATED}:    ASSOCIATED, Status of a pointer or pointer/target pair
60 * @code{ATAN}:          ATAN,      Arctangent function
61 * @code{ATAN2}:         ATAN2,     Arctangent function
62 * @code{ATANH}:         ATANH,     Inverse hyperbolic tangent function
63 * @code{ATOMIC_ADD}:    ATOMIC_ADD, Atomic ADD operation
64 * @code{ATOMIC_AND}:    ATOMIC_AND, Atomic bitwise AND operation
65 * @code{ATOMIC_CAS}:    ATOMIC_CAS, Atomic compare and swap
66 * @code{ATOMIC_DEFINE}: ATOMIC_DEFINE, Setting a variable atomically
67 * @code{ATOMIC_FETCH_ADD}: ATOMIC_FETCH_ADD, Atomic ADD operation with prior fetch
68 * @code{ATOMIC_FETCH_AND}: ATOMIC_FETCH_AND, Atomic bitwise AND operation with prior fetch
69 * @code{ATOMIC_FETCH_OR}: ATOMIC_FETCH_OR, Atomic bitwise OR operation with prior fetch
70 * @code{ATOMIC_FETCH_XOR}: ATOMIC_FETCH_XOR, Atomic bitwise XOR operation with prior fetch
71 * @code{ATOMIC_OR}:     ATOMIC_OR, Atomic bitwise OR operation
72 * @code{ATOMIC_REF}:    ATOMIC_REF, Obtaining the value of a variable atomically
73 * @code{ATOMIC_XOR}:    ATOMIC_XOR, Atomic bitwise OR operation
74 * @code{BACKTRACE}:     BACKTRACE, Show a backtrace
75 * @code{BESSEL_J0}:     BESSEL_J0, Bessel function of the first kind of order 0
76 * @code{BESSEL_J1}:     BESSEL_J1, Bessel function of the first kind of order 1
77 * @code{BESSEL_JN}:     BESSEL_JN, Bessel function of the first kind
78 * @code{BESSEL_Y0}:     BESSEL_Y0, Bessel function of the second kind of order 0
79 * @code{BESSEL_Y1}:     BESSEL_Y1, Bessel function of the second kind of order 1
80 * @code{BESSEL_YN}:     BESSEL_YN, Bessel function of the second kind
81 * @code{BGE}:           BGE,       Bitwise greater than or equal to
82 * @code{BGT}:           BGT,       Bitwise greater than
83 * @code{BIT_SIZE}:      BIT_SIZE,  Bit size inquiry function
84 * @code{BLE}:           BLE,       Bitwise less than or equal to
85 * @code{BLT}:           BLT,       Bitwise less than
86 * @code{BTEST}:         BTEST,     Bit test function
87 * @code{C_ASSOCIATED}:  C_ASSOCIATED, Status of a C pointer
88 * @code{C_F_POINTER}:   C_F_POINTER, Convert C into Fortran pointer
89 * @code{C_F_PROCPOINTER}: C_F_PROCPOINTER, Convert C into Fortran procedure pointer
90 * @code{C_FUNLOC}:      C_FUNLOC,  Obtain the C address of a procedure
91 * @code{C_LOC}:         C_LOC,     Obtain the C address of an object
92 * @code{C_SIZEOF}:      C_SIZEOF,  Size in bytes of an expression
93 * @code{CEILING}:       CEILING,   Integer ceiling function
94 * @code{CHAR}:          CHAR,      Integer-to-character conversion function
95 * @code{CHDIR}:         CHDIR,     Change working directory
96 * @code{CHMOD}:         CHMOD,     Change access permissions of files
97 * @code{CMPLX}:         CMPLX,     Complex conversion function
98 * @code{CO_BROADCAST}:  CO_BROADCAST, Copy a value to all images the current set of images
99 * @code{CO_MAX}:        CO_MAX,    Maximal value on the current set of images
100 * @code{CO_MIN}:        CO_MIN,    Minimal value on the current set of images
101 * @code{CO_REDUCE}:     CO_REDUCE, Reduction of values on the current set of images
102 * @code{CO_SUM}:        CO_SUM,    Sum of values on the current set of images
103 * @code{COMMAND_ARGUMENT_COUNT}: COMMAND_ARGUMENT_COUNT, Get number of command line arguments
104 * @code{COMPILER_OPTIONS}: COMPILER_OPTIONS, Options passed to the compiler
105 * @code{COMPILER_VERSION}: COMPILER_VERSION, Compiler version string
106 * @code{COMPLEX}:       COMPLEX,   Complex conversion function
107 * @code{CONJG}:         CONJG,     Complex conjugate function
108 * @code{COS}:           COS,       Cosine function
109 * @code{COSH}:          COSH,      Hyperbolic cosine function
110 * @code{COUNT}:         COUNT,     Count occurrences of TRUE in an array
111 * @code{CPU_TIME}:      CPU_TIME,  CPU time subroutine
112 * @code{CSHIFT}:        CSHIFT,    Circular shift elements of an array
113 * @code{CTIME}:         CTIME,     Subroutine (or function) to convert a time into a string
114 * @code{DATE_AND_TIME}: DATE_AND_TIME, Date and time subroutine
115 * @code{DBLE}:          DBLE,      Double precision conversion function
116 * @code{DCMPLX}:        DCMPLX,    Double complex conversion function
117 * @code{DIGITS}:        DIGITS,    Significant digits function
118 * @code{DIM}:           DIM,       Positive difference
119 * @code{DOT_PRODUCT}:   DOT_PRODUCT, Dot product function
120 * @code{DPROD}:         DPROD,     Double product function
121 * @code{DREAL}:         DREAL,     Double real part function
122 * @code{DSHIFTL}:       DSHIFTL,   Combined left shift
123 * @code{DSHIFTR}:       DSHIFTR,   Combined right shift
124 * @code{DTIME}:         DTIME,     Execution time subroutine (or function)
125 * @code{EOSHIFT}:       EOSHIFT,   End-off shift elements of an array
126 * @code{EPSILON}:       EPSILON,   Epsilon function
127 * @code{ERF}:           ERF,       Error function
128 * @code{ERFC}:          ERFC,      Complementary error function
129 * @code{ERFC_SCALED}:   ERFC_SCALED, Exponentially-scaled complementary error function
130 * @code{ETIME}:         ETIME,     Execution time subroutine (or function)
131 * @code{EXECUTE_COMMAND_LINE}: EXECUTE_COMMAND_LINE, Execute a shell command
132 * @code{EXIT}:          EXIT,      Exit the program with status.
133 * @code{EXP}:           EXP,       Exponential function
134 * @code{EXPONENT}:      EXPONENT,  Exponent function
135 * @code{EXTENDS_TYPE_OF}: EXTENDS_TYPE_OF,  Query dynamic type for extension
136 * @code{FDATE}:         FDATE,     Subroutine (or function) to get the current time as a string
137 * @code{FGET}:          FGET,      Read a single character in stream mode from stdin
138 * @code{FGETC}:         FGETC,     Read a single character in stream mode
139 * @code{FLOOR}:         FLOOR,     Integer floor function
140 * @code{FLUSH}:         FLUSH,     Flush I/O unit(s)
141 * @code{FNUM}:          FNUM,      File number function
142 * @code{FPUT}:          FPUT,      Write a single character in stream mode to stdout
143 * @code{FPUTC}:         FPUTC,     Write a single character in stream mode
144 * @code{FRACTION}:      FRACTION,  Fractional part of the model representation
145 * @code{FREE}:          FREE,      Memory de-allocation subroutine
146 * @code{FSEEK}:         FSEEK,     Low level file positioning subroutine
147 * @code{FSTAT}:         FSTAT,     Get file status
148 * @code{FTELL}:         FTELL,     Current stream position
149 * @code{GAMMA}:         GAMMA,     Gamma function
150 * @code{GERROR}:        GERROR,    Get last system error message
151 * @code{GETARG}:        GETARG,    Get command line arguments
152 * @code{GET_COMMAND}:   GET_COMMAND, Get the entire command line
153 * @code{GET_COMMAND_ARGUMENT}: GET_COMMAND_ARGUMENT, Get command line arguments
154 * @code{GETCWD}:        GETCWD,    Get current working directory
155 * @code{GETENV}:        GETENV,    Get an environmental variable
156 * @code{GET_ENVIRONMENT_VARIABLE}: GET_ENVIRONMENT_VARIABLE, Get an environmental variable
157 * @code{GETGID}:        GETGID,    Group ID function
158 * @code{GETLOG}:        GETLOG,    Get login name
159 * @code{GETPID}:        GETPID,    Process ID function
160 * @code{GETUID}:        GETUID,    User ID function
161 * @code{GMTIME}:        GMTIME,    Convert time to GMT info
162 * @code{HOSTNM}:        HOSTNM,    Get system host name
163 * @code{HUGE}:          HUGE,      Largest number of a kind
164 * @code{HYPOT}:         HYPOT,     Euclidean distance function
165 * @code{IACHAR}:        IACHAR,    Code in @acronym{ASCII} collating sequence
166 * @code{IALL}:          IALL,      Bitwise AND of array elements
167 * @code{IAND}:          IAND,      Bitwise logical and
168 * @code{IANY}:          IANY,      Bitwise OR of array elements
169 * @code{IARGC}:         IARGC,     Get the number of command line arguments
170 * @code{IBCLR}:         IBCLR,     Clear bit
171 * @code{IBITS}:         IBITS,     Bit extraction
172 * @code{IBSET}:         IBSET,     Set bit
173 * @code{ICHAR}:         ICHAR,     Character-to-integer conversion function
174 * @code{IDATE}:         IDATE,     Current local time (day/month/year)
175 * @code{IEOR}:          IEOR,      Bitwise logical exclusive or
176 * @code{IERRNO}:        IERRNO,    Function to get the last system error number
177 * @code{IMAGE_INDEX}:   IMAGE_INDEX, Cosubscript to image index conversion
178 * @code{INDEX}:         INDEX intrinsic, Position of a substring within a string
179 * @code{INT}:           INT,       Convert to integer type
180 * @code{INT2}:          INT2,      Convert to 16-bit integer type
181 * @code{INT8}:          INT8,      Convert to 64-bit integer type
182 * @code{IOR}:           IOR,       Bitwise logical or
183 * @code{IPARITY}:       IPARITY,   Bitwise XOR of array elements
184 * @code{IRAND}:         IRAND,     Integer pseudo-random number
185 * @code{IS_IOSTAT_END}:  IS_IOSTAT_END, Test for end-of-file value
186 * @code{IS_IOSTAT_EOR}:  IS_IOSTAT_EOR, Test for end-of-record value
187 * @code{ISATTY}:        ISATTY,    Whether a unit is a terminal device
188 * @code{ISHFT}:         ISHFT,     Shift bits
189 * @code{ISHFTC}:        ISHFTC,    Shift bits circularly
190 * @code{ISNAN}:         ISNAN,     Tests for a NaN
191 * @code{ITIME}:         ITIME,     Current local time (hour/minutes/seconds)
192 * @code{KILL}:          KILL,      Send a signal to a process
193 * @code{KIND}:          KIND,      Kind of an entity
194 * @code{LBOUND}:        LBOUND,    Lower dimension bounds of an array
195 * @code{LCOBOUND}:      LCOBOUND,  Lower codimension bounds of an array
196 * @code{LEADZ}:         LEADZ,     Number of leading zero bits of an integer
197 * @code{LEN}:           LEN,       Length of a character entity
198 * @code{LEN_TRIM}:      LEN_TRIM,  Length of a character entity without trailing blank characters
199 * @code{LGE}:           LGE,       Lexical greater than or equal
200 * @code{LGT}:           LGT,       Lexical greater than
201 * @code{LINK}:          LINK,      Create a hard link
202 * @code{LLE}:           LLE,       Lexical less than or equal
203 * @code{LLT}:           LLT,       Lexical less than
204 * @code{LNBLNK}:        LNBLNK,    Index of the last non-blank character in a string
205 * @code{LOC}:           LOC,       Returns the address of a variable
206 * @code{LOG}:           LOG,       Logarithm function
207 * @code{LOG10}:         LOG10,     Base 10 logarithm function 
208 * @code{LOG_GAMMA}:     LOG_GAMMA, Logarithm of the Gamma function
209 * @code{LOGICAL}:       LOGICAL,   Convert to logical type
210 * @code{LONG}:          LONG,      Convert to integer type
211 * @code{LSHIFT}:        LSHIFT,    Left shift bits
212 * @code{LSTAT}:         LSTAT,     Get file status
213 * @code{LTIME}:         LTIME,     Convert time to local time info
214 * @code{MALLOC}:        MALLOC,    Dynamic memory allocation function
215 * @code{MASKL}:         MASKL,     Left justified mask
216 * @code{MASKR}:         MASKR,     Right justified mask
217 * @code{MATMUL}:        MATMUL,    matrix multiplication
218 * @code{MAX}:           MAX,       Maximum value of an argument list
219 * @code{MAXEXPONENT}:   MAXEXPONENT, Maximum exponent of a real kind
220 * @code{MAXLOC}:        MAXLOC,    Location of the maximum value within an array
221 * @code{MAXVAL}:        MAXVAL,    Maximum value of an array
222 * @code{MCLOCK}:        MCLOCK,    Time function
223 * @code{MCLOCK8}:       MCLOCK8,   Time function (64-bit)
224 * @code{MERGE}:         MERGE,     Merge arrays
225 * @code{MERGE_BITS}:    MERGE_BITS, Merge of bits under mask
226 * @code{MIN}:           MIN,       Minimum value of an argument list
227 * @code{MINEXPONENT}:   MINEXPONENT, Minimum exponent of a real kind
228 * @code{MINLOC}:        MINLOC,    Location of the minimum value within an array
229 * @code{MINVAL}:        MINVAL,    Minimum value of an array
230 * @code{MOD}:           MOD,       Remainder function
231 * @code{MODULO}:        MODULO,    Modulo function
232 * @code{MOVE_ALLOC}:    MOVE_ALLOC, Move allocation from one object to another
233 * @code{MVBITS}:        MVBITS,    Move bits from one integer to another
234 * @code{NEAREST}:       NEAREST,   Nearest representable number
235 * @code{NEW_LINE}:      NEW_LINE,  New line character
236 * @code{NINT}:          NINT,      Nearest whole number
237 * @code{NORM2}:         NORM2,     Euclidean vector norm
238 * @code{NOT}:           NOT,       Logical negation
239 * @code{NULL}:          NULL,      Function that returns an disassociated pointer
240 * @code{NUM_IMAGES}:    NUM_IMAGES, Number of images
241 * @code{OR}:            OR,        Bitwise logical OR
242 * @code{PACK}:          PACK,      Pack an array into an array of rank one
243 * @code{PARITY}:        PARITY,    Reduction with exclusive OR
244 * @code{PERROR}:        PERROR,    Print system error message
245 * @code{POPCNT}:        POPCNT,    Number of bits set
246 * @code{POPPAR}:        POPPAR,    Parity of the number of bits set
247 * @code{PRECISION}:     PRECISION, Decimal precision of a real kind
248 * @code{PRESENT}:       PRESENT,   Determine whether an optional dummy argument is specified
249 * @code{PRODUCT}:       PRODUCT,   Product of array elements
250 * @code{RADIX}:         RADIX,     Base of a data model
251 * @code{RAN}:           RAN,       Real pseudo-random number
252 * @code{RAND}:          RAND,      Real pseudo-random number
253 * @code{RANDOM_NUMBER}: RANDOM_NUMBER, Pseudo-random number
254 * @code{RANDOM_SEED}:   RANDOM_SEED, Initialize a pseudo-random number sequence
255 * @code{RANGE}:         RANGE,     Decimal exponent range
256 * @code{RANK} :         RANK,      Rank of a data object
257 * @code{REAL}:          REAL,      Convert to real type 
258 * @code{RENAME}:        RENAME,    Rename a file
259 * @code{REPEAT}:        REPEAT,    Repeated string concatenation
260 * @code{RESHAPE}:       RESHAPE,   Function to reshape an array
261 * @code{RRSPACING}:     RRSPACING, Reciprocal of the relative spacing
262 * @code{RSHIFT}:        RSHIFT,    Right shift bits
263 * @code{SAME_TYPE_AS}:  SAME_TYPE_AS,  Query dynamic types for equality
264 * @code{SCALE}:         SCALE,     Scale a real value
265 * @code{SCAN}:          SCAN,      Scan a string for the presence of a set of characters
266 * @code{SECNDS}:        SECNDS,    Time function
267 * @code{SECOND}:        SECOND,    CPU time function
268 * @code{SELECTED_CHAR_KIND}: SELECTED_CHAR_KIND,  Choose character kind
269 * @code{SELECTED_INT_KIND}: SELECTED_INT_KIND,  Choose integer kind
270 * @code{SELECTED_REAL_KIND}: SELECTED_REAL_KIND,  Choose real kind
271 * @code{SET_EXPONENT}:  SET_EXPONENT, Set the exponent of the model
272 * @code{SHAPE}:         SHAPE,     Determine the shape of an array
273 * @code{SHIFTA}:        SHIFTA,    Right shift with fill
274 * @code{SHIFTL}:        SHIFTL,    Left shift
275 * @code{SHIFTR}:        SHIFTR,    Right shift
276 * @code{SIGN}:          SIGN,      Sign copying function
277 * @code{SIGNAL}:        SIGNAL,    Signal handling subroutine (or function)
278 * @code{SIN}:           SIN,       Sine function
279 * @code{SINH}:          SINH,      Hyperbolic sine function
280 * @code{SIZE}:          SIZE,      Function to determine the size of an array
281 * @code{SIZEOF}:        SIZEOF,    Determine the size in bytes of an expression
282 * @code{SLEEP}:         SLEEP,     Sleep for the specified number of seconds
283 * @code{SPACING}:       SPACING,   Smallest distance between two numbers of a given type
284 * @code{SPREAD}:        SPREAD,    Add a dimension to an array 
285 * @code{SQRT}:          SQRT,      Square-root function
286 * @code{SRAND}:         SRAND,     Reinitialize the random number generator
287 * @code{STAT}:          STAT,      Get file status
288 * @code{STORAGE_SIZE}:  STORAGE_SIZE, Storage size in bits
289 * @code{SUM}:           SUM,       Sum of array elements
290 * @code{SYMLNK}:        SYMLNK,    Create a symbolic link
291 * @code{SYSTEM}:        SYSTEM,    Execute a shell command
292 * @code{SYSTEM_CLOCK}:  SYSTEM_CLOCK, Time function
293 * @code{TAN}:           TAN,       Tangent function
294 * @code{TANH}:          TANH,      Hyperbolic tangent function
295 * @code{THIS_IMAGE}:    THIS_IMAGE, Cosubscript index of this image
296 * @code{TIME}:          TIME,      Time function
297 * @code{TIME8}:         TIME8,     Time function (64-bit)
298 * @code{TINY}:          TINY,      Smallest positive number of a real kind
299 * @code{TRAILZ}:        TRAILZ,    Number of trailing zero bits of an integer
300 * @code{TRANSFER}:      TRANSFER,  Transfer bit patterns
301 * @code{TRANSPOSE}:     TRANSPOSE, Transpose an array of rank two
302 * @code{TRIM}:          TRIM,      Remove trailing blank characters of a string
303 * @code{TTYNAM}:        TTYNAM,    Get the name of a terminal device.
304 * @code{UBOUND}:        UBOUND,    Upper dimension bounds of an array
305 * @code{UCOBOUND}:      UCOBOUND,  Upper codimension bounds of an array
306 * @code{UMASK}:         UMASK,     Set the file creation mask
307 * @code{UNLINK}:        UNLINK,    Remove a file from the file system
308 * @code{UNPACK}:        UNPACK,    Unpack an array of rank one into an array
309 * @code{VERIFY}:        VERIFY,    Scan a string for the absence of a set of characters
310 * @code{XOR}:           XOR,       Bitwise logical exclusive or
311 @end menu
313 @node Introduction to Intrinsics
314 @section Introduction to intrinsic procedures
316 The intrinsic procedures provided by GNU Fortran include all of the
317 intrinsic procedures required by the Fortran 95 standard, a set of
318 intrinsic procedures for backwards compatibility with G77, and a
319 selection of intrinsic procedures from the Fortran 2003 and Fortran 2008
320 standards.  Any conflict between a description here and a description in
321 either the Fortran 95 standard, the Fortran 2003 standard or the Fortran
322 2008 standard is unintentional, and the standard(s) should be considered
323 authoritative.
325 The enumeration of the @code{KIND} type parameter is processor defined in
326 the Fortran 95 standard.  GNU Fortran defines the default integer type and
327 default real type by @code{INTEGER(KIND=4)} and @code{REAL(KIND=4)},
328 respectively.  The standard mandates that both data types shall have
329 another kind, which have more precision.  On typical target architectures
330 supported by @command{gfortran}, this kind type parameter is @code{KIND=8}.
331 Hence, @code{REAL(KIND=8)} and @code{DOUBLE PRECISION} are equivalent.
332 In the description of generic intrinsic procedures, the kind type parameter
333 will be specified by @code{KIND=*}, and in the description of specific
334 names for an intrinsic procedure the kind type parameter will be explicitly
335 given (e.g., @code{REAL(KIND=4)} or @code{REAL(KIND=8)}).  Finally, for
336 brevity the optional @code{KIND=} syntax will be omitted.
338 Many of the intrinsic procedures take one or more optional arguments.
339 This document follows the convention used in the Fortran 95 standard,
340 and denotes such arguments by square brackets.
342 GNU Fortran offers the @option{-std=f95} and @option{-std=gnu} options,
343 which can be used to restrict the set of intrinsic procedures to a 
344 given standard.  By default, @command{gfortran} sets the @option{-std=gnu}
345 option, and so all intrinsic procedures described here are accepted.  There
346 is one caveat.  For a select group of intrinsic procedures, @command{g77}
347 implemented both a function and a subroutine.  Both classes 
348 have been implemented in @command{gfortran} for backwards compatibility
349 with @command{g77}.  It is noted here that these functions and subroutines
350 cannot be intermixed in a given subprogram.  In the descriptions that follow,
351 the applicable standard for each intrinsic procedure is noted.
355 @node ABORT
356 @section @code{ABORT} --- Abort the program
357 @fnindex ABORT
358 @cindex program termination, with core dump
359 @cindex terminate program, with core dump
360 @cindex core, dump
362 @table @asis
363 @item @emph{Description}:
364 @code{ABORT} causes immediate termination of the program.  On operating
365 systems that support a core dump, @code{ABORT} will produce a core dump.
366 It will also print a backtrace, unless @code{-fno-backtrace} is given.
368 @item @emph{Standard}:
369 GNU extension
371 @item @emph{Class}:
372 Subroutine
374 @item @emph{Syntax}:
375 @code{CALL ABORT}
377 @item @emph{Return value}:
378 Does not return.
380 @item @emph{Example}:
381 @smallexample
382 program test_abort
383   integer :: i = 1, j = 2
384   if (i /= j) call abort
385 end program test_abort
386 @end smallexample
388 @item @emph{See also}:
389 @ref{EXIT}, @ref{KILL}, @ref{BACKTRACE}
391 @end table
395 @node ABS
396 @section @code{ABS} --- Absolute value
397 @fnindex ABS
398 @fnindex CABS
399 @fnindex DABS
400 @fnindex IABS
401 @fnindex ZABS
402 @fnindex CDABS
403 @cindex absolute value
405 @table @asis
406 @item @emph{Description}:
407 @code{ABS(A)} computes the absolute value of @code{A}.
409 @item @emph{Standard}:
410 Fortran 77 and later, has overloads that are GNU extensions
412 @item @emph{Class}:
413 Elemental function
415 @item @emph{Syntax}:
416 @code{RESULT = ABS(A)}
418 @item @emph{Arguments}:
419 @multitable @columnfractions .15 .70
420 @item @var{A} @tab The type of the argument shall be an @code{INTEGER},
421 @code{REAL}, or @code{COMPLEX}.
422 @end multitable
424 @item @emph{Return value}:
425 The return value is of the same type and
426 kind as the argument except the return value is @code{REAL} for a
427 @code{COMPLEX} argument.
429 @item @emph{Example}:
430 @smallexample
431 program test_abs
432   integer :: i = -1
433   real :: x = -1.e0
434   complex :: z = (-1.e0,0.e0)
435   i = abs(i)
436   x = abs(x)
437   x = abs(z)
438 end program test_abs
439 @end smallexample
441 @item @emph{Specific names}:
442 @multitable @columnfractions .20 .20 .20 .25
443 @item Name            @tab Argument            @tab Return type       @tab Standard
444 @item @code{ABS(A)}   @tab @code{REAL(4) A}    @tab @code{REAL(4)}    @tab Fortran 77 and later
445 @item @code{CABS(A)}  @tab @code{COMPLEX(4) A} @tab @code{REAL(4)}    @tab Fortran 77 and later
446 @item @code{DABS(A)}  @tab @code{REAL(8) A}    @tab @code{REAL(8)}    @tab Fortran 77 and later
447 @item @code{IABS(A)}  @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab Fortran 77 and later
448 @item @code{ZABS(A)}  @tab @code{COMPLEX(8) A} @tab @code{COMPLEX(8)} @tab GNU extension
449 @item @code{CDABS(A)} @tab @code{COMPLEX(8) A} @tab @code{COMPLEX(8)} @tab GNU extension
450 @end multitable
451 @end table
455 @node ACCESS
456 @section @code{ACCESS} --- Checks file access modes
457 @fnindex ACCESS
458 @cindex file system, access mode
460 @table @asis
461 @item @emph{Description}:
462 @code{ACCESS(NAME, MODE)} checks whether the file @var{NAME} 
463 exists, is readable, writable or executable. Except for the
464 executable check, @code{ACCESS} can be replaced by
465 Fortran 95's @code{INQUIRE}.
467 @item @emph{Standard}:
468 GNU extension
470 @item @emph{Class}:
471 Inquiry function
473 @item @emph{Syntax}:
474 @code{RESULT = ACCESS(NAME, MODE)}
476 @item @emph{Arguments}:
477 @multitable @columnfractions .15 .70
478 @item @var{NAME} @tab Scalar @code{CHARACTER} of default kind with the
479 file name. Tailing blank are ignored unless the character @code{achar(0)}
480 is present, then all characters up to and excluding @code{achar(0)} are
481 used as file name.
482 @item @var{MODE} @tab Scalar @code{CHARACTER} of default kind with the
483 file access mode, may be any concatenation of @code{"r"} (readable),
484 @code{"w"} (writable) and @code{"x"} (executable), or @code{" "} to check
485 for existence.
486 @end multitable
488 @item @emph{Return value}:
489 Returns a scalar @code{INTEGER}, which is @code{0} if the file is
490 accessible in the given mode; otherwise or if an invalid argument
491 has been given for @code{MODE} the value @code{1} is returned.
493 @item @emph{Example}:
494 @smallexample
495 program access_test
496   implicit none
497   character(len=*), parameter :: file  = 'test.dat'
498   character(len=*), parameter :: file2 = 'test.dat  '//achar(0)
499   if(access(file,' ') == 0) print *, trim(file),' is exists'
500   if(access(file,'r') == 0) print *, trim(file),' is readable'
501   if(access(file,'w') == 0) print *, trim(file),' is writable'
502   if(access(file,'x') == 0) print *, trim(file),' is executable'
503   if(access(file2,'rwx') == 0) &
504     print *, trim(file2),' is readable, writable and executable'
505 end program access_test
506 @end smallexample
507 @item @emph{Specific names}:
508 @item @emph{See also}:
510 @end table
514 @node ACHAR
515 @section @code{ACHAR} --- Character in @acronym{ASCII} collating sequence 
516 @fnindex ACHAR
517 @cindex @acronym{ASCII} collating sequence
518 @cindex collating sequence, @acronym{ASCII}
520 @table @asis
521 @item @emph{Description}:
522 @code{ACHAR(I)} returns the character located at position @code{I}
523 in the @acronym{ASCII} collating sequence.
525 @item @emph{Standard}:
526 Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later
528 @item @emph{Class}:
529 Elemental function
531 @item @emph{Syntax}:
532 @code{RESULT = ACHAR(I [, KIND])}
534 @item @emph{Arguments}:
535 @multitable @columnfractions .15 .70
536 @item @var{I}    @tab The type shall be @code{INTEGER}.
537 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
538 expression indicating the kind parameter of the result.
539 @end multitable
541 @item @emph{Return value}:
542 The return value is of type @code{CHARACTER} with a length of one.
543 If the @var{KIND} argument is present, the return value is of the
544 specified kind and of the default kind otherwise.
546 @item @emph{Example}:
547 @smallexample
548 program test_achar
549   character c
550   c = achar(32)
551 end program test_achar
552 @end smallexample
554 @item @emph{Note}:
555 See @ref{ICHAR} for a discussion of converting between numerical values
556 and formatted string representations.
558 @item @emph{See also}:
559 @ref{CHAR}, @ref{IACHAR}, @ref{ICHAR}
561 @end table
565 @node ACOS
566 @section @code{ACOS} --- Arccosine function 
567 @fnindex ACOS
568 @fnindex DACOS
569 @cindex trigonometric function, cosine, inverse
570 @cindex cosine, inverse
572 @table @asis
573 @item @emph{Description}:
574 @code{ACOS(X)} computes the arccosine of @var{X} (inverse of @code{COS(X)}).
576 @item @emph{Standard}:
577 Fortran 77 and later, for a complex argument Fortran 2008 or later
579 @item @emph{Class}:
580 Elemental function
582 @item @emph{Syntax}:
583 @code{RESULT = ACOS(X)}
585 @item @emph{Arguments}:
586 @multitable @columnfractions .15 .70
587 @item @var{X} @tab The type shall either be @code{REAL} with a magnitude that is
588 less than or equal to one - or the type shall be @code{COMPLEX}.
589 @end multitable
591 @item @emph{Return value}:
592 The return value is of the same type and kind as @var{X}.
593 The real part of the result is in radians and lies in the range
594 @math{0 \leq \Re \acos(x) \leq \pi}.
596 @item @emph{Example}:
597 @smallexample
598 program test_acos
599   real(8) :: x = 0.866_8
600   x = acos(x)
601 end program test_acos
602 @end smallexample
604 @item @emph{Specific names}:
605 @multitable @columnfractions .20 .20 .20 .25
606 @item Name            @tab Argument         @tab Return type     @tab Standard
607 @item @code{ACOS(X)}  @tab @code{REAL(4) X} @tab @code{REAL(4)}  @tab Fortran 77 and later
608 @item @code{DACOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)}  @tab Fortran 77 and later
609 @end multitable
611 @item @emph{See also}:
612 Inverse function: @ref{COS}
614 @end table
618 @node ACOSH
619 @section @code{ACOSH} --- Inverse hyperbolic cosine function
620 @fnindex ACOSH
621 @fnindex DACOSH
622 @cindex area hyperbolic cosine
623 @cindex inverse hyperbolic cosine
624 @cindex hyperbolic function, cosine, inverse
625 @cindex cosine, hyperbolic, inverse
627 @table @asis
628 @item @emph{Description}:
629 @code{ACOSH(X)} computes the inverse hyperbolic cosine of @var{X}.
631 @item @emph{Standard}:
632 Fortran 2008 and later
634 @item @emph{Class}:
635 Elemental function
637 @item @emph{Syntax}:
638 @code{RESULT = ACOSH(X)}
640 @item @emph{Arguments}:
641 @multitable @columnfractions .15 .70
642 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
643 @end multitable
645 @item @emph{Return value}:
646 The return value has the same type and kind as @var{X}. If @var{X} is
647 complex, the imaginary part of the result is in radians and lies between
648 @math{ 0 \leq \Im \acosh(x) \leq \pi}.
650 @item @emph{Example}:
651 @smallexample
652 PROGRAM test_acosh
653   REAL(8), DIMENSION(3) :: x = (/ 1.0, 2.0, 3.0 /)
654   WRITE (*,*) ACOSH(x)
655 END PROGRAM
656 @end smallexample
658 @item @emph{Specific names}:
659 @multitable @columnfractions .20 .20 .20 .25
660 @item Name             @tab Argument          @tab Return type       @tab Standard
661 @item @code{DACOSH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
662 @end multitable
664 @item @emph{See also}:
665 Inverse function: @ref{COSH}
666 @end table
670 @node ADJUSTL
671 @section @code{ADJUSTL} --- Left adjust a string 
672 @fnindex ADJUSTL
673 @cindex string, adjust left
674 @cindex adjust string
676 @table @asis
677 @item @emph{Description}:
678 @code{ADJUSTL(STRING)} will left adjust a string by removing leading spaces.
679 Spaces are inserted at the end of the string as needed.
681 @item @emph{Standard}:
682 Fortran 90 and later
684 @item @emph{Class}:
685 Elemental function
687 @item @emph{Syntax}:
688 @code{RESULT = ADJUSTL(STRING)}
690 @item @emph{Arguments}:
691 @multitable @columnfractions .15 .70
692 @item @var{STRING} @tab The type shall be @code{CHARACTER}.
693 @end multitable
695 @item @emph{Return value}:
696 The return value is of type @code{CHARACTER} and of the same kind as
697 @var{STRING} where leading spaces are removed and the same number of
698 spaces are inserted on the end of @var{STRING}.
700 @item @emph{Example}:
701 @smallexample
702 program test_adjustl
703   character(len=20) :: str = '   gfortran'
704   str = adjustl(str)
705   print *, str
706 end program test_adjustl
707 @end smallexample
709 @item @emph{See also}:
710 @ref{ADJUSTR}, @ref{TRIM}
711 @end table
715 @node ADJUSTR
716 @section @code{ADJUSTR} --- Right adjust a string 
717 @fnindex ADJUSTR
718 @cindex string, adjust right
719 @cindex adjust string
721 @table @asis
722 @item @emph{Description}:
723 @code{ADJUSTR(STRING)} will right adjust a string by removing trailing spaces.
724 Spaces are inserted at the start of the string as needed.
726 @item @emph{Standard}:
727 Fortran 95 and later
729 @item @emph{Class}:
730 Elemental function
732 @item @emph{Syntax}:
733 @code{RESULT = ADJUSTR(STRING)}
735 @item @emph{Arguments}:
736 @multitable @columnfractions .15 .70
737 @item @var{STR} @tab The type shall be @code{CHARACTER}.
738 @end multitable
740 @item @emph{Return value}:
741 The return value is of type @code{CHARACTER} and of the same kind as
742 @var{STRING} where trailing spaces are removed and the same number of
743 spaces are inserted at the start of @var{STRING}.
745 @item @emph{Example}:
746 @smallexample
747 program test_adjustr
748   character(len=20) :: str = 'gfortran'
749   str = adjustr(str)
750   print *, str
751 end program test_adjustr
752 @end smallexample
754 @item @emph{See also}:
755 @ref{ADJUSTL}, @ref{TRIM}
756 @end table
760 @node AIMAG
761 @section @code{AIMAG} --- Imaginary part of complex number  
762 @fnindex AIMAG
763 @fnindex DIMAG
764 @fnindex IMAG
765 @fnindex IMAGPART
766 @cindex complex numbers, imaginary part
768 @table @asis
769 @item @emph{Description}:
770 @code{AIMAG(Z)} yields the imaginary part of complex argument @code{Z}.
771 The @code{IMAG(Z)} and @code{IMAGPART(Z)} intrinsic functions are provided
772 for compatibility with @command{g77}, and their use in new code is 
773 strongly discouraged.
775 @item @emph{Standard}:
776 Fortran 77 and later, has overloads that are GNU extensions
778 @item @emph{Class}:
779 Elemental function
781 @item @emph{Syntax}:
782 @code{RESULT = AIMAG(Z)}
784 @item @emph{Arguments}:
785 @multitable @columnfractions .15 .70
786 @item @var{Z} @tab The type of the argument shall be @code{COMPLEX}.
787 @end multitable
789 @item @emph{Return value}:
790 The return value is of type @code{REAL} with the
791 kind type parameter of the argument.
793 @item @emph{Example}:
794 @smallexample
795 program test_aimag
796   complex(4) z4
797   complex(8) z8
798   z4 = cmplx(1.e0_4, 0.e0_4)
799   z8 = cmplx(0.e0_8, 1.e0_8)
800   print *, aimag(z4), dimag(z8)
801 end program test_aimag
802 @end smallexample
804 @item @emph{Specific names}:
805 @multitable @columnfractions .20 .20 .20 .25
806 @item Name               @tab Argument            @tab Return type     @tab Standard
807 @item @code{AIMAG(Z)}    @tab @code{COMPLEX Z}    @tab @code{REAL}     @tab GNU extension
808 @item @code{DIMAG(Z)}    @tab @code{COMPLEX(8) Z} @tab @code{REAL(8)}  @tab GNU extension
809 @item @code{IMAG(Z)}     @tab @code{COMPLEX Z}    @tab @code{REAL}     @tab GNU extension
810 @item @code{IMAGPART(Z)} @tab @code{COMPLEX Z}    @tab @code{REAL}     @tab GNU extension
811 @end multitable
812 @end table
816 @node AINT
817 @section @code{AINT} --- Truncate to a whole number
818 @fnindex AINT
819 @fnindex DINT
820 @cindex floor
821 @cindex rounding, floor
823 @table @asis
824 @item @emph{Description}:
825 @code{AINT(A [, KIND])} truncates its argument to a whole number.
827 @item @emph{Standard}:
828 Fortran 77 and later
830 @item @emph{Class}:
831 Elemental function
833 @item @emph{Syntax}:
834 @code{RESULT = AINT(A [, KIND])} 
836 @item @emph{Arguments}:
837 @multitable @columnfractions .15 .70
838 @item @var{A}    @tab The type of the argument shall be @code{REAL}.
839 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
840 expression indicating the kind parameter of the result.
841 @end multitable
843 @item @emph{Return value}:
844 The return value is of type @code{REAL} with the kind type parameter of the
845 argument if the optional @var{KIND} is absent; otherwise, the kind
846 type parameter will be given by @var{KIND}.  If the magnitude of 
847 @var{X} is less than one, @code{AINT(X)} returns zero.  If the
848 magnitude is equal to or greater than one then it returns the largest
849 whole number that does not exceed its magnitude.  The sign is the same
850 as the sign of @var{X}. 
852 @item @emph{Example}:
853 @smallexample
854 program test_aint
855   real(4) x4
856   real(8) x8
857   x4 = 1.234E0_4
858   x8 = 4.321_8
859   print *, aint(x4), dint(x8)
860   x8 = aint(x4,8)
861 end program test_aint
862 @end smallexample
864 @item @emph{Specific names}:
865 @multitable @columnfractions .20 .20 .20 .25
866 @item Name           @tab Argument         @tab Return type      @tab Standard
867 @item @code{AINT(A)} @tab @code{REAL(4) A} @tab @code{REAL(4)}   @tab Fortran 77 and later
868 @item @code{DINT(A)} @tab @code{REAL(8) A} @tab @code{REAL(8)}   @tab Fortran 77 and later
869 @end multitable
870 @end table
874 @node ALARM
875 @section @code{ALARM} --- Execute a routine after a given delay
876 @fnindex ALARM
877 @cindex delayed execution
879 @table @asis
880 @item @emph{Description}:
881 @code{ALARM(SECONDS, HANDLER [, STATUS])} causes external subroutine @var{HANDLER}
882 to be executed after a delay of @var{SECONDS} by using @code{alarm(2)} to
883 set up a signal and @code{signal(2)} to catch it. If @var{STATUS} is
884 supplied, it will be returned with the number of seconds remaining until
885 any previously scheduled alarm was due to be delivered, or zero if there
886 was no previously scheduled alarm.
888 @item @emph{Standard}:
889 GNU extension
891 @item @emph{Class}:
892 Subroutine
894 @item @emph{Syntax}:
895 @code{CALL ALARM(SECONDS, HANDLER [, STATUS])}
897 @item @emph{Arguments}:
898 @multitable @columnfractions .15 .70
899 @item @var{SECONDS} @tab The type of the argument shall be a scalar
900 @code{INTEGER}. It is @code{INTENT(IN)}.
901 @item @var{HANDLER} @tab Signal handler (@code{INTEGER FUNCTION} or
902 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar. The scalar 
903 values may be either @code{SIG_IGN=1} to ignore the alarm generated 
904 or @code{SIG_DFL=0} to set the default action. It is @code{INTENT(IN)}.
905 @item @var{STATUS}  @tab (Optional) @var{STATUS} shall be a scalar
906 variable of the default @code{INTEGER} kind. It is @code{INTENT(OUT)}.
907 @end multitable
909 @item @emph{Example}:
910 @smallexample
911 program test_alarm
912   external handler_print
913   integer i
914   call alarm (3, handler_print, i)
915   print *, i
916   call sleep(10)
917 end program test_alarm
918 @end smallexample
919 This will cause the external routine @var{handler_print} to be called
920 after 3 seconds.
921 @end table
925 @node ALL
926 @section @code{ALL} --- All values in @var{MASK} along @var{DIM} are true 
927 @fnindex ALL
928 @cindex array, apply condition
929 @cindex array, condition testing
931 @table @asis
932 @item @emph{Description}:
933 @code{ALL(MASK [, DIM])} determines if all the values are true in @var{MASK}
934 in the array along dimension @var{DIM}.
936 @item @emph{Standard}:
937 Fortran 95 and later
939 @item @emph{Class}:
940 Transformational function
942 @item @emph{Syntax}:
943 @code{RESULT = ALL(MASK [, DIM])}
945 @item @emph{Arguments}:
946 @multitable @columnfractions .15 .70
947 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL} and
948 it shall not be scalar.
949 @item @var{DIM}  @tab (Optional) @var{DIM} shall be a scalar integer
950 with a value that lies between one and the rank of @var{MASK}.
951 @end multitable
953 @item @emph{Return value}:
954 @code{ALL(MASK)} returns a scalar value of type @code{LOGICAL} where
955 the kind type parameter is the same as the kind type parameter of
956 @var{MASK}.  If @var{DIM} is present, then @code{ALL(MASK, DIM)} returns
957 an array with the rank of @var{MASK} minus 1.  The shape is determined from
958 the shape of @var{MASK} where the @var{DIM} dimension is elided. 
960 @table @asis
961 @item (A)
962 @code{ALL(MASK)} is true if all elements of @var{MASK} are true.
963 It also is true if @var{MASK} has zero size; otherwise, it is false.
964 @item (B)
965 If the rank of @var{MASK} is one, then @code{ALL(MASK,DIM)} is equivalent
966 to @code{ALL(MASK)}.  If the rank is greater than one, then @code{ALL(MASK,DIM)}
967 is determined by applying @code{ALL} to the array sections.
968 @end table
970 @item @emph{Example}:
971 @smallexample
972 program test_all
973   logical l
974   l = all((/.true., .true., .true./))
975   print *, l
976   call section
977   contains
978     subroutine section
979       integer a(2,3), b(2,3)
980       a = 1
981       b = 1
982       b(2,2) = 2
983       print *, all(a .eq. b, 1)
984       print *, all(a .eq. b, 2)
985     end subroutine section
986 end program test_all
987 @end smallexample
988 @end table
992 @node ALLOCATED
993 @section @code{ALLOCATED} --- Status of an allocatable entity
994 @fnindex ALLOCATED
995 @cindex allocation, status
997 @table @asis
998 @item @emph{Description}:
999 @code{ALLOCATED(ARRAY)} and @code{ALLOCATED(SCALAR)} check the allocation
1000 status of @var{ARRAY} and @var{SCALAR}, respectively.
1002 @item @emph{Standard}:
1003 Fortran 95 and later.  Note, the @code{SCALAR=} keyword and allocatable
1004 scalar entities are available in Fortran 2003 and later.
1006 @item @emph{Class}:
1007 Inquiry function
1009 @item @emph{Syntax}:
1010 @multitable @columnfractions .80
1011 @item @code{RESULT = ALLOCATED(ARRAY)}
1012 @item @code{RESULT = ALLOCATED(SCALAR)} 
1013 @end multitable
1015 @item @emph{Arguments}:
1016 @multitable @columnfractions .15 .70
1017 @item @var{ARRAY}    @tab The argument shall be an @code{ALLOCATABLE} array.
1018 @item @var{SCALAR}   @tab The argument shall be an @code{ALLOCATABLE} scalar.
1019 @end multitable
1021 @item @emph{Return value}:
1022 The return value is a scalar @code{LOGICAL} with the default logical
1023 kind type parameter.  If the argument is allocated, then the result is
1024 @code{.TRUE.}; otherwise, it returns @code{.FALSE.} 
1026 @item @emph{Example}:
1027 @smallexample
1028 program test_allocated
1029   integer :: i = 4
1030   real(4), allocatable :: x(:)
1031   if (.not. allocated(x)) allocate(x(i))
1032 end program test_allocated
1033 @end smallexample
1034 @end table
1038 @node AND
1039 @section @code{AND} --- Bitwise logical AND
1040 @fnindex AND
1041 @cindex bitwise logical and
1042 @cindex logical and, bitwise
1044 @table @asis
1045 @item @emph{Description}:
1046 Bitwise logical @code{AND}.
1048 This intrinsic routine is provided for backwards compatibility with 
1049 GNU Fortran 77.  For integer arguments, programmers should consider
1050 the use of the @ref{IAND} intrinsic defined by the Fortran standard.
1052 @item @emph{Standard}:
1053 GNU extension
1055 @item @emph{Class}:
1056 Function
1058 @item @emph{Syntax}:
1059 @code{RESULT = AND(I, J)}
1061 @item @emph{Arguments}:
1062 @multitable @columnfractions .15 .70
1063 @item @var{I} @tab The type shall be either a scalar @code{INTEGER}
1064 type or a scalar @code{LOGICAL} type.
1065 @item @var{J} @tab The type shall be the same as the type of @var{I}.
1066 @end multitable
1068 @item @emph{Return value}:
1069 The return type is either a scalar @code{INTEGER} or a scalar
1070 @code{LOGICAL}.  If the kind type parameters differ, then the
1071 smaller kind type is implicitly converted to larger kind, and the 
1072 return has the larger kind.
1074 @item @emph{Example}:
1075 @smallexample
1076 PROGRAM test_and
1077   LOGICAL :: T = .TRUE., F = .FALSE.
1078   INTEGER :: a, b
1079   DATA a / Z'F' /, b / Z'3' /
1081   WRITE (*,*) AND(T, T), AND(T, F), AND(F, T), AND(F, F)
1082   WRITE (*,*) AND(a, b)
1083 END PROGRAM
1084 @end smallexample
1086 @item @emph{See also}:
1087 Fortran 95 elemental function: @ref{IAND}
1088 @end table
1092 @node ANINT
1093 @section @code{ANINT} --- Nearest whole number
1094 @fnindex ANINT
1095 @fnindex DNINT
1096 @cindex ceiling
1097 @cindex rounding, ceiling
1099 @table @asis
1100 @item @emph{Description}:
1101 @code{ANINT(A [, KIND])} rounds its argument to the nearest whole number.
1103 @item @emph{Standard}:
1104 Fortran 77 and later
1106 @item @emph{Class}:
1107 Elemental function
1109 @item @emph{Syntax}:
1110 @code{RESULT = ANINT(A [, KIND])}
1112 @item @emph{Arguments}:
1113 @multitable @columnfractions .15 .70
1114 @item @var{A}    @tab The type of the argument shall be @code{REAL}.
1115 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
1116 expression indicating the kind parameter of the result.
1117 @end multitable
1119 @item @emph{Return value}:
1120 The return value is of type real with the kind type parameter of the
1121 argument if the optional @var{KIND} is absent; otherwise, the kind
1122 type parameter will be given by @var{KIND}.  If @var{A} is greater than
1123 zero, @code{ANINT(A)} returns @code{AINT(X+0.5)}.  If @var{A} is
1124 less than or equal to zero then it returns @code{AINT(X-0.5)}.
1126 @item @emph{Example}:
1127 @smallexample
1128 program test_anint
1129   real(4) x4
1130   real(8) x8
1131   x4 = 1.234E0_4
1132   x8 = 4.321_8
1133   print *, anint(x4), dnint(x8)
1134   x8 = anint(x4,8)
1135 end program test_anint
1136 @end smallexample
1138 @item @emph{Specific names}:
1139 @multitable @columnfractions .20 .20 .20 .25
1140 @item Name            @tab Argument         @tab Return type      @tab Standard
1141 @item @code{AINT(A)}  @tab @code{REAL(4) A} @tab @code{REAL(4)}   @tab Fortran 77 and later
1142 @item @code{DNINT(A)} @tab @code{REAL(8) A} @tab @code{REAL(8)}   @tab Fortran 77 and later
1143 @end multitable
1144 @end table
1148 @node ANY
1149 @section @code{ANY} --- Any value in @var{MASK} along @var{DIM} is true 
1150 @fnindex ANY
1151 @cindex array, apply condition
1152 @cindex array, condition testing
1154 @table @asis
1155 @item @emph{Description}:
1156 @code{ANY(MASK [, DIM])} determines if any of the values in the logical array
1157 @var{MASK} along dimension @var{DIM} are @code{.TRUE.}.
1159 @item @emph{Standard}:
1160 Fortran 95 and later
1162 @item @emph{Class}:
1163 Transformational function
1165 @item @emph{Syntax}:
1166 @code{RESULT = ANY(MASK [, DIM])}
1168 @item @emph{Arguments}:
1169 @multitable @columnfractions .15 .70
1170 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL} and
1171 it shall not be scalar.
1172 @item @var{DIM}  @tab (Optional) @var{DIM} shall be a scalar integer
1173 with a value that lies between one and the rank of @var{MASK}.
1174 @end multitable
1176 @item @emph{Return value}:
1177 @code{ANY(MASK)} returns a scalar value of type @code{LOGICAL} where
1178 the kind type parameter is the same as the kind type parameter of
1179 @var{MASK}.  If @var{DIM} is present, then @code{ANY(MASK, DIM)} returns
1180 an array with the rank of @var{MASK} minus 1.  The shape is determined from
1181 the shape of @var{MASK} where the @var{DIM} dimension is elided. 
1183 @table @asis
1184 @item (A)
1185 @code{ANY(MASK)} is true if any element of @var{MASK} is true;
1186 otherwise, it is false.  It also is false if @var{MASK} has zero size.
1187 @item (B)
1188 If the rank of @var{MASK} is one, then @code{ANY(MASK,DIM)} is equivalent
1189 to @code{ANY(MASK)}.  If the rank is greater than one, then @code{ANY(MASK,DIM)}
1190 is determined by applying @code{ANY} to the array sections.
1191 @end table
1193 @item @emph{Example}:
1194 @smallexample
1195 program test_any
1196   logical l
1197   l = any((/.true., .true., .true./))
1198   print *, l
1199   call section
1200   contains
1201     subroutine section
1202       integer a(2,3), b(2,3)
1203       a = 1
1204       b = 1
1205       b(2,2) = 2
1206       print *, any(a .eq. b, 1)
1207       print *, any(a .eq. b, 2)
1208     end subroutine section
1209 end program test_any
1210 @end smallexample
1211 @end table
1215 @node ASIN
1216 @section @code{ASIN} --- Arcsine function 
1217 @fnindex ASIN
1218 @fnindex DASIN
1219 @cindex trigonometric function, sine, inverse
1220 @cindex sine, inverse
1222 @table @asis
1223 @item @emph{Description}:
1224 @code{ASIN(X)} computes the arcsine of its @var{X} (inverse of @code{SIN(X)}).
1226 @item @emph{Standard}:
1227 Fortran 77 and later, for a complex argument Fortran 2008 or later
1229 @item @emph{Class}:
1230 Elemental function
1232 @item @emph{Syntax}:
1233 @code{RESULT = ASIN(X)}
1235 @item @emph{Arguments}:
1236 @multitable @columnfractions .15 .70
1237 @item @var{X} @tab The type shall be either @code{REAL} and a magnitude that is
1238 less than or equal to one - or be @code{COMPLEX}.
1239 @end multitable
1241 @item @emph{Return value}:
1242 The return value is of the same type and kind as @var{X}.
1243 The real part of the result is in radians and lies in the range
1244 @math{-\pi/2 \leq \Re \asin(x) \leq \pi/2}.
1246 @item @emph{Example}:
1247 @smallexample
1248 program test_asin
1249   real(8) :: x = 0.866_8
1250   x = asin(x)
1251 end program test_asin
1252 @end smallexample
1254 @item @emph{Specific names}:
1255 @multitable @columnfractions .20 .20 .20 .25
1256 @item Name            @tab Argument          @tab Return type       @tab Standard
1257 @item @code{ASIN(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab Fortran 77 and later
1258 @item @code{DASIN(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab Fortran 77 and later
1259 @end multitable
1261 @item @emph{See also}:
1262 Inverse function: @ref{SIN}
1264 @end table
1268 @node ASINH
1269 @section @code{ASINH} --- Inverse hyperbolic sine function
1270 @fnindex ASINH
1271 @fnindex DASINH
1272 @cindex area hyperbolic sine
1273 @cindex inverse hyperbolic sine
1274 @cindex hyperbolic function, sine, inverse
1275 @cindex sine, hyperbolic, inverse
1277 @table @asis
1278 @item @emph{Description}:
1279 @code{ASINH(X)} computes the inverse hyperbolic sine of @var{X}.
1281 @item @emph{Standard}:
1282 Fortran 2008 and later
1284 @item @emph{Class}:
1285 Elemental function
1287 @item @emph{Syntax}:
1288 @code{RESULT = ASINH(X)}
1290 @item @emph{Arguments}:
1291 @multitable @columnfractions .15 .70
1292 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
1293 @end multitable
1295 @item @emph{Return value}:
1296 The return value is of the same type and kind as  @var{X}. If @var{X} is
1297 complex, the imaginary part of the result is in radians and lies between
1298 @math{-\pi/2 \leq \Im \asinh(x) \leq \pi/2}.
1300 @item @emph{Example}:
1301 @smallexample
1302 PROGRAM test_asinh
1303   REAL(8), DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1304   WRITE (*,*) ASINH(x)
1305 END PROGRAM
1306 @end smallexample
1308 @item @emph{Specific names}:
1309 @multitable @columnfractions .20 .20 .20 .25
1310 @item Name             @tab Argument          @tab Return type       @tab Standard
1311 @item @code{DASINH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension.
1312 @end multitable
1314 @item @emph{See also}:
1315 Inverse function: @ref{SINH}
1316 @end table
1320 @node ASSOCIATED
1321 @section @code{ASSOCIATED} --- Status of a pointer or pointer/target pair 
1322 @fnindex ASSOCIATED
1323 @cindex pointer, status
1324 @cindex association status
1326 @table @asis
1327 @item @emph{Description}:
1328 @code{ASSOCIATED(POINTER [, TARGET])} determines the status of the pointer
1329 @var{POINTER} or if @var{POINTER} is associated with the target @var{TARGET}.
1331 @item @emph{Standard}:
1332 Fortran 95 and later
1334 @item @emph{Class}:
1335 Inquiry function
1337 @item @emph{Syntax}:
1338 @code{RESULT = ASSOCIATED(POINTER [, TARGET])}
1340 @item @emph{Arguments}:
1341 @multitable @columnfractions .15 .70
1342 @item @var{POINTER} @tab @var{POINTER} shall have the @code{POINTER} attribute
1343 and it can be of any type.
1344 @item @var{TARGET} @tab (Optional) @var{TARGET} shall be a pointer or
1345 a target.  It must have the same type, kind type parameter, and
1346 array rank as @var{POINTER}.
1347 @end multitable
1348 The association status of neither @var{POINTER} nor @var{TARGET} shall be
1349 undefined.
1351 @item @emph{Return value}:
1352 @code{ASSOCIATED(POINTER)} returns a scalar value of type @code{LOGICAL(4)}.
1353 There are several cases:
1354 @table @asis
1355 @item (A) When the optional @var{TARGET} is not present then
1356 @code{ASSOCIATED(POINTER)} is true if @var{POINTER} is associated with a target; otherwise, it returns false.
1357 @item (B) If @var{TARGET} is present and a scalar target, the result is true if
1358 @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
1359 disassociated, the result is false.
1360 @item (C) If @var{TARGET} is present and an array target, the result is true if
1361 @var{TARGET} and @var{POINTER} have the same shape, are not zero-sized arrays,
1362 are arrays whose elements are not zero-sized storage sequences, and
1363 @var{TARGET} and @var{POINTER} occupy the same storage units in array element
1364 order.
1365 As in case(B), the result is false, if @var{POINTER} is disassociated.
1366 @item (D) If @var{TARGET} is present and an scalar pointer, the result is true
1367 if @var{TARGET} is associated with @var{POINTER}, the target associated with
1368 @var{TARGET} are not zero-sized storage sequences and occupy the same storage
1369 units.
1370 The result is false, if either @var{TARGET} or @var{POINTER} is disassociated.
1371 @item (E) If @var{TARGET} is present and an array pointer, the result is true if
1372 target associated with @var{POINTER} and the target associated with @var{TARGET}
1373 have the same shape, are not zero-sized arrays, are arrays whose elements are
1374 not zero-sized storage sequences, and @var{TARGET} and @var{POINTER} occupy
1375 the same storage units in array element order.
1376 The result is false, if either @var{TARGET} or @var{POINTER} is disassociated.
1377 @end table
1379 @item @emph{Example}:
1380 @smallexample
1381 program test_associated
1382    implicit none
1383    real, target  :: tgt(2) = (/1., 2./)
1384    real, pointer :: ptr(:)
1385    ptr => tgt
1386    if (associated(ptr)     .eqv. .false.) call abort
1387    if (associated(ptr,tgt) .eqv. .false.) call abort
1388 end program test_associated
1389 @end smallexample
1391 @item @emph{See also}:
1392 @ref{NULL}
1393 @end table
1397 @node ATAN
1398 @section @code{ATAN} --- Arctangent function 
1399 @fnindex ATAN
1400 @fnindex DATAN
1401 @cindex trigonometric function, tangent, inverse
1402 @cindex tangent, inverse
1404 @table @asis
1405 @item @emph{Description}:
1406 @code{ATAN(X)} computes the arctangent of @var{X}.
1408 @item @emph{Standard}:
1409 Fortran 77 and later, for a complex argument and for two arguments
1410 Fortran 2008 or later
1412 @item @emph{Class}:
1413 Elemental function
1415 @item @emph{Syntax}:
1416 @multitable @columnfractions .80
1417 @item @code{RESULT = ATAN(X)}
1418 @item @code{RESULT = ATAN(Y, X)}
1419 @end multitable
1421 @item @emph{Arguments}:
1422 @multitable @columnfractions .15 .70
1423 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX};
1424 if @var{Y} is present, @var{X} shall be REAL.
1425 @item @var{Y} shall be of the same type and kind as @var{X}.
1426 @end multitable
1428 @item @emph{Return value}:
1429 The return value is of the same type and kind as @var{X}.
1430 If @var{Y} is present, the result is identical to @code{ATAN2(Y,X)}.
1431 Otherwise, it the arcus tangent of @var{X}, where the real part of
1432 the result is in radians and lies in the range
1433 @math{-\pi/2 \leq \Re \atan(x) \leq \pi/2}.
1435 @item @emph{Example}:
1436 @smallexample
1437 program test_atan
1438   real(8) :: x = 2.866_8
1439   x = atan(x)
1440 end program test_atan
1441 @end smallexample
1443 @item @emph{Specific names}:
1444 @multitable @columnfractions .20 .20 .20 .25
1445 @item Name            @tab Argument          @tab Return type       @tab Standard
1446 @item @code{ATAN(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab Fortran 77 and later
1447 @item @code{DATAN(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab Fortran 77 and later
1448 @end multitable
1450 @item @emph{See also}:
1451 Inverse function: @ref{TAN}
1453 @end table
1457 @node ATAN2
1458 @section @code{ATAN2} --- Arctangent function 
1459 @fnindex ATAN2
1460 @fnindex DATAN2
1461 @cindex trigonometric function, tangent, inverse
1462 @cindex tangent, inverse
1464 @table @asis
1465 @item @emph{Description}:
1466 @code{ATAN2(Y, X)} computes the principal value of the argument
1467 function of the complex number @math{X + i Y}. This function can
1468 be used to transform from Cartesian into polar coordinates and
1469 allows to determine the angle in the correct quadrant.
1471 @item @emph{Standard}:
1472 Fortran 77 and later
1474 @item @emph{Class}:
1475 Elemental function
1477 @item @emph{Syntax}:
1478 @code{RESULT = ATAN2(Y, X)}
1480 @item @emph{Arguments}:
1481 @multitable @columnfractions .15 .70
1482 @item @var{Y} @tab The type shall be @code{REAL}.
1483 @item @var{X} @tab The type and kind type parameter shall be the same as @var{Y}.
1484 If @var{Y} is zero, then @var{X} must be nonzero.
1485 @end multitable
1487 @item @emph{Return value}:
1488 The return value has the same type and kind type parameter as @var{Y}. It
1489 is the principal value of the complex number @math{X + i Y}.  If @var{X}
1490 is nonzero, then it lies in the range @math{-\pi \le \atan (x) \leq \pi}.
1491 The sign is positive if @var{Y} is positive.  If @var{Y} is zero, then
1492 the return value is zero if @var{X} is strictly positive, @math{\pi} if
1493 @var{X} is negative and @var{Y} is positive zero (or the processor does
1494 not handle signed zeros), and @math{-\pi} if @var{X} is negative and
1495 @var{Y} is negative zero.  Finally, if @var{X} is zero, then the
1496 magnitude of the result is @math{\pi/2}.
1498 @item @emph{Example}:
1499 @smallexample
1500 program test_atan2
1501   real(4) :: x = 1.e0_4, y = 0.5e0_4
1502   x = atan2(y,x)
1503 end program test_atan2
1504 @end smallexample
1506 @item @emph{Specific names}:
1507 @multitable @columnfractions .20 .20 .20 .25
1508 @item Name                @tab Argument            @tab Return type    @tab Standard
1509 @item @code{ATAN2(X, Y)}  @tab @code{REAL(4) X, Y} @tab @code{REAL(4)} @tab Fortran 77 and later
1510 @item @code{DATAN2(X, Y)} @tab @code{REAL(8) X, Y} @tab @code{REAL(8)} @tab Fortran 77 and later
1511 @end multitable
1512 @end table
1516 @node ATANH
1517 @section @code{ATANH} --- Inverse hyperbolic tangent function
1518 @fnindex ATANH
1519 @fnindex DATANH
1520 @cindex area hyperbolic tangent
1521 @cindex inverse hyperbolic tangent
1522 @cindex hyperbolic function, tangent, inverse
1523 @cindex tangent, hyperbolic, inverse
1525 @table @asis
1526 @item @emph{Description}:
1527 @code{ATANH(X)} computes the inverse hyperbolic tangent of @var{X}.
1529 @item @emph{Standard}:
1530 Fortran 2008 and later
1532 @item @emph{Class}:
1533 Elemental function
1535 @item @emph{Syntax}:
1536 @code{RESULT = ATANH(X)}
1538 @item @emph{Arguments}:
1539 @multitable @columnfractions .15 .70
1540 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
1541 @end multitable
1543 @item @emph{Return value}:
1544 The return value has same type and kind as @var{X}. If @var{X} is
1545 complex, the imaginary part of the result is in radians and lies between
1546 @math{-\pi/2 \leq \Im \atanh(x) \leq \pi/2}.
1548 @item @emph{Example}:
1549 @smallexample
1550 PROGRAM test_atanh
1551   REAL, DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1552   WRITE (*,*) ATANH(x)
1553 END PROGRAM
1554 @end smallexample
1556 @item @emph{Specific names}:
1557 @multitable @columnfractions .20 .20 .20 .25
1558 @item Name             @tab Argument          @tab Return type       @tab Standard
1559 @item @code{DATANH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
1560 @end multitable
1562 @item @emph{See also}:
1563 Inverse function: @ref{TANH}
1564 @end table
1568 @node ATOMIC_ADD
1569 @section @code{ATOMIC_ADD} --- Atomic ADD operation
1570 @fnindex ATOMIC_ADD
1571 @cindex Atomic subroutine, add
1573 @table @asis
1574 @item @emph{Description}:
1575 @code{ATOMIC_ADD(ATOM, VALUE)} atomically adds the value of @var{VAR} to the
1576 variable @var{ATOM}. When @var{STAT} is present and the invokation was
1577 successful, it is assigned the value 0. If it is present and the invokation
1578 has failed, it is assigned a positive value; in particular, for a coindexed
1579 @var{ATOM}, if the remote image has stopped, it is assigned the value of
1580 @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has
1581 failed, the value @code{STAT_FAILED_IMAGE}.
1583 @item @emph{Standard}:
1584 TS 18508 or later
1586 @item @emph{Class}:
1587 Atomic subroutine
1589 @item @emph{Syntax}:
1590 @code{CALL ATOMIC_ADD (ATOM, VALUE [, STAT])}
1592 @item @emph{Arguments}:
1593 @multitable @columnfractions .15 .70
1594 @item @var{ATOM}   @tab Scalar coarray or coindexed variable of integer
1595 type with @code{ATOMIC_INT_KIND} kind.
1596 @item @var{VALUE}  @tab Scalar of the same type as @var{ATOM}. If the kind
1597 is different, the value is converted to the kind of @var{ATOM}.
1598 @item @var{STAT}   @tab (optional) Scalar default-kind integer variable.
1599 @end multitable
1601 @item @emph{Example}:
1602 @smallexample
1603 program atomic
1604   use iso_fortran_env
1605   integer(atomic_int_kind) :: atom[*]
1606   call atomic_add (atom[1], this_image())
1607 end program atomic
1608 @end smallexample
1610 @item @emph{See also}:
1611 @ref{ATOMIC_DEFINE}, @ref{ATOMIC_FETCH_ADD}, @ref{ISO_FORTRAN_ENV},
1612 @ref{ATOMIC_AND}, @ref{ATOMIC_OR}, @ref{ATOMIC_XOR}
1613 @end table
1618 @node ATOMIC_AND
1619 @section @code{ATOMIC_AND} --- Atomic bitwise AND operation
1620 @fnindex ATOMIC_AND
1621 @cindex Atomic subroutine, AND
1623 @table @asis
1624 @item @emph{Description}:
1625 @code{ATOMIC_AND(ATOM, VALUE)} atomically defines @var{ATOM} with the bitwise
1626 AND between the values of @var{ATOM} and @var{VALUE}. When @var{STAT} is present
1627 and the invokation was successful, it is assigned the value 0. If it is present
1628 and the invokation has failed, it is assigned a positive value; in particular,
1629 for a coindexed @var{ATOM}, if the remote image has stopped, it is assigned the
1630 value of @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote
1631 image has failed, the value @code{STAT_FAILED_IMAGE}.
1633 @item @emph{Standard}:
1634 TS 18508 or later
1636 @item @emph{Class}:
1637 Atomic subroutine
1639 @item @emph{Syntax}:
1640 @code{CALL ATOMIC_AND (ATOM, VALUE [, STAT])}
1642 @item @emph{Arguments}:
1643 @multitable @columnfractions .15 .70
1644 @item @var{ATOM}   @tab Scalar coarray or coindexed variable of integer
1645 type with @code{ATOMIC_INT_KIND} kind.
1646 @item @var{VALUE}  @tab Scalar of the same type as @var{ATOM}. If the kind
1647 is different, the value is converted to the kind of @var{ATOM}.
1648 @item @var{STAT}   @tab (optional) Scalar default-kind integer variable.
1649 @end multitable
1651 @item @emph{Example}:
1652 @smallexample
1653 program atomic
1654   use iso_fortran_env
1655   integer(atomic_int_kind) :: atom[*]
1656   call atomic_and (atom[1], int(b'10100011101'))
1657 end program atomic
1658 @end smallexample
1660 @item @emph{See also}:
1661 @ref{ATOMIC_DEFINE}, @ref{ATOMIC_FETCH_AND}, @ref{ISO_FORTRAN_ENV},
1662 @ref{ATOMIC_ADD}, @ref{ATOMIC_OR}, @ref{ATOMIC_XOR}
1663 @end table
1667 @node ATOMIC_CAS
1668 @section @code{ATOMIC_CAS} --- Atomic compare and swap
1669 @fnindex ATOMIC_DEFINE
1670 @cindex Atomic subroutine, compare and swap
1672 @table @asis
1673 @item @emph{Description}:
1674 @code{ATOMIC_CAS} compares the variable @var{ATOM} with the value of
1675 @var{COMPARE}; if the value is the same, @var{ATOM} is set to the value
1676 of @var{NEW}. Additionally, @var{OLD} is set to the value of @var{ATOM}
1677 that was used for the comparison.  When @var{STAT} is present and the invokation
1678 was successful, it is assigned the value 0. If it is present and the invokation
1679 has failed, it is assigned a positive value; in particular, for a coindexed
1680 @var{ATOM}, if the remote image has stopped, it is assigned the value of
1681 @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has
1682 failed, the value @code{STAT_FAILED_IMAGE}.
1684 @item @emph{Standard}:
1685 TS 18508 or later
1687 @item @emph{Class}:
1688 Atomic subroutine
1690 @item @emph{Syntax}:
1691 @code{CALL ATOMIC_CAS (ATOM, OLD, COMPARE, NEW [, STAT])}
1693 @item @emph{Arguments}:
1694 @multitable @columnfractions .15 .70
1695 @item @var{ATOM}    @tab Scalar coarray or coindexed variable of either integer
1696 type with @code{ATOMIC_INT_KIND} kind or logical type with
1697 @code{ATOMIC_LOGICAL_KIND} kind.
1698 @item @var{OLD}     @tab Scalar of the same type and kind as @var{ATOM}.
1699 @item @var{COMPARE} @tab Scalar variable of the same type and kind as
1700 @var{ATOM}.
1701 @item @var{NEW}     @tab Scalar variable of the same type as @var{ATOM}. If kind
1702 is different, the value is converted to the kind of @var{ATOM}.
1703 @item @var{STAT}    @tab (optional) Scalar default-kind integer variable.
1704 @end multitable
1706 @item @emph{Example}:
1707 @smallexample
1708 program atomic
1709   use iso_fortran_env
1710   logical(atomic_logical_kind) :: atom[*], prev
1711   call atomic_cas (atom[1], prev, .false., .true.))
1712 end program atomic
1713 @end smallexample
1715 @item @emph{See also}:
1716 @ref{ATOMIC_DEFINE}, @ref{ATOMIC_REF}, @ref{ISO_FORTRAN_ENV}
1717 @end table
1721 @node ATOMIC_DEFINE
1722 @section @code{ATOMIC_DEFINE} --- Setting a variable atomically
1723 @fnindex ATOMIC_DEFINE
1724 @cindex Atomic subroutine, define
1726 @table @asis
1727 @item @emph{Description}:
1728 @code{ATOMIC_DEFINE(ATOM, VALUE)} defines the variable @var{ATOM} with the value
1729 @var{VALUE} atomically. When @var{STAT} is present and the invokation was
1730 successful, it is assigned the value 0. If it is present and the invokation
1731 has failed, it is assigned a positive value; in particular, for a coindexed
1732 @var{ATOM}, if the remote image has stopped, it is assigned the value of
1733 @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has
1734 failed, the value @code{STAT_FAILED_IMAGE}.
1736 @item @emph{Standard}:
1737 Fortran 2008 and later; with @var{STAT}, TS 18508 or later
1739 @item @emph{Class}:
1740 Atomic subroutine
1742 @item @emph{Syntax}:
1743 @code{CALL ATOMIC_DEFINE (ATOM, VALUE [, STAT])}
1745 @item @emph{Arguments}:
1746 @multitable @columnfractions .15 .70
1747 @item @var{ATOM}   @tab Scalar coarray or coindexed variable of either integer
1748 type with @code{ATOMIC_INT_KIND} kind or logical type with
1749 @code{ATOMIC_LOGICAL_KIND} kind.
1751 @item @var{VALUE}  @tab Scalar of the same type as @var{ATOM}. If the kind
1752 is different, the value is converted to the kind of @var{ATOM}.
1753 @item @var{STAT}   @tab (optional) Scalar default-kind integer variable.
1754 @end multitable
1756 @item @emph{Example}:
1757 @smallexample
1758 program atomic
1759   use iso_fortran_env
1760   integer(atomic_int_kind) :: atom[*]
1761   call atomic_define (atom[1], this_image())
1762 end program atomic
1763 @end smallexample
1765 @item @emph{See also}:
1766 @ref{ATOMIC_REF}, @ref{ATOMIC_CAS}, @ref{ISO_FORTRAN_ENV},
1767 @ref{ATOMIC_ADD}, @ref{ATOMIC_AND}, @ref{ATOMIC_OR}, @ref{ATOMIC_XOR}
1768 @end table
1772 @node ATOMIC_FETCH_ADD
1773 @section @code{ATOMIC_FETCH_ADD} --- Atomic ADD operation with prior fetch
1774 @fnindex ATOMIC_FETCH_ADD
1775 @cindex Atomic subroutine, ADD with fetch
1777 @table @asis
1778 @item @emph{Description}:
1779 @code{ATOMIC_FETCH_ADD(ATOM, VALUE, OLD)} atomically stores the value of
1780 @var{ATOM} in @var{OLD} and adds the value of @var{VAR} to the
1781 variable @var{ATOM}. When @var{STAT} is present and the invokation was
1782 successful, it is assigned the value 0. If it is present and the invokation
1783 has failed, it is assigned a positive value; in particular, for a coindexed
1784 @var{ATOM}, if the remote image has stopped, it is assigned the value of
1785 @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has
1786 failed, the value @code{STAT_FAILED_IMAGE}.
1788 @item @emph{Standard}:
1789 TS 18508 or later
1791 @item @emph{Class}:
1792 Atomic subroutine
1794 @item @emph{Syntax}:
1795 @code{CALL ATOMIC_FETCH_ADD (ATOM, VALUE, old [, STAT])}
1797 @item @emph{Arguments}:
1798 @multitable @columnfractions .15 .70
1799 @item @var{ATOM}   @tab Scalar coarray or coindexed variable of integer
1800 type with @code{ATOMIC_INT_KIND} kind.
1801 @code{ATOMIC_LOGICAL_KIND} kind.
1803 @item @var{VALUE}  @tab Scalar of the same type as @var{ATOM}. If the kind
1804 is different, the value is converted to the kind of @var{ATOM}.
1805 @item @var{OLD}    @tab Scalar of the same type and kind as @var{ATOM}.
1806 @item @var{STAT}   @tab (optional) Scalar default-kind integer variable.
1807 @end multitable
1809 @item @emph{Example}:
1810 @smallexample
1811 program atomic
1812   use iso_fortran_env
1813   integer(atomic_int_kind) :: atom[*], old
1814   call atomic_add (atom[1], this_image(), old)
1815 end program atomic
1816 @end smallexample
1818 @item @emph{See also}:
1819 @ref{ATOMIC_DEFINE}, @ref{ATOMIC_ADD}, @ref{ISO_FORTRAN_ENV},
1820 @ref{ATOMIC_FETCH_AND}, @ref{ATOMIC_FETCH_OR}, @ref{ATOMIC_FETCH_XOR}
1821 @end table
1825 @node ATOMIC_FETCH_AND
1826 @section @code{ATOMIC_FETCH_AND} --- Atomic bitwise AND operation with prior fetch
1827 @fnindex ATOMIC_FETCH_AND
1828 @cindex Atomic subroutine, AND with fetch
1830 @table @asis
1831 @item @emph{Description}:
1832 @code{ATOMIC_AND(ATOM, VALUE)} atomically stores the value of @var{ATOM} in
1833 @var{OLD} and defines @var{ATOM} with the bitwise AND between the values of
1834 @var{ATOM} and @var{VALUE}. When @var{STAT} is present and the invokation was
1835 successful, it is assigned the value 0. If it is present and the invokation has
1836 failed, it is assigned a positive value; in particular, for a coindexed
1837 @var{ATOM}, if the remote image has stopped, it is assigned the value of
1838 @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has
1839 failed, the value @code{STAT_FAILED_IMAGE}.
1841 @item @emph{Standard}:
1842 TS 18508 or later
1844 @item @emph{Class}:
1845 Atomic subroutine
1847 @item @emph{Syntax}:
1848 @code{CALL ATOMIC_FETCH_AND (ATOM, VALUE, OLD [, STAT])}
1850 @item @emph{Arguments}:
1851 @multitable @columnfractions .15 .70
1852 @item @var{ATOM}   @tab Scalar coarray or coindexed variable of integer
1853 type with @code{ATOMIC_INT_KIND} kind.
1854 @item @var{VALUE}  @tab Scalar of the same type as @var{ATOM}. If the kind
1855 is different, the value is converted to the kind of @var{ATOM}.
1856 @item @var{OLD}    @tab Scalar of the same type and kind as @var{ATOM}.
1857 @item @var{STAT}   @tab (optional) Scalar default-kind integer variable.
1858 @end multitable
1860 @item @emph{Example}:
1861 @smallexample
1862 program atomic
1863   use iso_fortran_env
1864   integer(atomic_int_kind) :: atom[*], old
1865   call atomic_fetch_and (atom[1], int(b'10100011101'), old)
1866 end program atomic
1867 @end smallexample
1869 @item @emph{See also}:
1870 @ref{ATOMIC_DEFINE}, @ref{ATOMIC_AND}, @ref{ISO_FORTRAN_ENV},
1871 @ref{ATOMIC_FETCH_ADD}, @ref{ATOMIC_FETCH_OR}, @ref{ATOMIC_FETCH_XOR}
1872 @end table
1876 @node ATOMIC_FETCH_OR
1877 @section @code{ATOMIC_FETCH_OR} --- Atomic bitwise OR operation with prior fetch
1878 @fnindex ATOMIC_FETCH_OR
1879 @cindex Atomic subroutine, OR with fetch
1881 @table @asis
1882 @item @emph{Description}:
1883 @code{ATOMIC_OR(ATOM, VALUE)} atomically stores the value of @var{ATOM} in
1884 @var{OLD} and defines @var{ATOM} with the bitwise OR between the values of
1885 @var{ATOM} and @var{VALUE}. When @var{STAT} is present and the invokation was
1886 successful, it is assigned the value 0. If it is present and the invokation has
1887 failed, it is assigned a positive value; in particular, for a coindexed
1888 @var{ATOM}, if the remote image has stopped, it is assigned the value of
1889 @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has
1890 failed, the value @code{STAT_FAILED_IMAGE}.
1892 @item @emph{Standard}:
1893 TS 18508 or later
1895 @item @emph{Class}:
1896 Atomic subroutine
1898 @item @emph{Syntax}:
1899 @code{CALL ATOMIC_FETCH_OR (ATOM, VALUE, OLD [, STAT])}
1901 @item @emph{Arguments}:
1902 @multitable @columnfractions .15 .70
1903 @item @var{ATOM}   @tab Scalar coarray or coindexed variable of integer
1904 type with @code{ATOMIC_INT_KIND} kind.
1905 @item @var{VALUE}  @tab Scalar of the same type as @var{ATOM}. If the kind
1906 is different, the value is converted to the kind of @var{ATOM}.
1907 @item @var{OLD}    @tab Scalar of the same type and kind as @var{ATOM}.
1908 @item @var{STAT}   @tab (optional) Scalar default-kind integer variable.
1909 @end multitable
1911 @item @emph{Example}:
1912 @smallexample
1913 program atomic
1914   use iso_fortran_env
1915   integer(atomic_int_kind) :: atom[*], old
1916   call atomic_fetch_or (atom[1], int(b'10100011101'), old)
1917 end program atomic
1918 @end smallexample
1920 @item @emph{See also}:
1921 @ref{ATOMIC_DEFINE}, @ref{ATOMIC_OR}, @ref{ISO_FORTRAN_ENV},
1922 @ref{ATOMIC_FETCH_ADD}, @ref{ATOMIC_FETCH_AND}, @ref{ATOMIC_FETCH_XOR}
1923 @end table
1927 @node ATOMIC_FETCH_XOR
1928 @section @code{ATOMIC_FETCH_XOR} --- Atomic bitwise XOR operation with prior fetch
1929 @fnindex ATOMIC_FETCH_XOR
1930 @cindex Atomic subroutine, XOR with fetch
1932 @table @asis
1933 @item @emph{Description}:
1934 @code{ATOMIC_XOR(ATOM, VALUE)} atomically stores the value of @var{ATOM} in
1935 @var{OLD} and defines @var{ATOM} with the bitwise XOR between the values of
1936 @var{ATOM} and @var{VALUE}. When @var{STAT} is present and the invokation was
1937 successful, it is assigned the value 0. If it is present and the invokation has
1938 failed, it is assigned a positive value; in particular, for a coindexed
1939 @var{ATOM}, if the remote image has stopped, it is assigned the value of
1940 @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has
1941 failed, the value @code{STAT_FAILED_IMAGE}.
1943 @item @emph{Standard}:
1944 TS 18508 or later
1946 @item @emph{Class}:
1947 Atomic subroutine
1949 @item @emph{Syntax}:
1950 @code{CALL ATOMIC_FETCH_XOR (ATOM, VALUE, OLD [, STAT])}
1952 @item @emph{Arguments}:
1953 @multitable @columnfractions .15 .70
1954 @item @var{ATOM}   @tab Scalar coarray or coindexed variable of integer
1955 type with @code{ATOMIC_INT_KIND} kind.
1956 @item @var{VALUE}  @tab Scalar of the same type as @var{ATOM}. If the kind
1957 is different, the value is converted to the kind of @var{ATOM}.
1958 @item @var{OLD}    @tab Scalar of the same type and kind as @var{ATOM}.
1959 @item @var{STAT}   @tab (optional) Scalar default-kind integer variable.
1960 @end multitable
1962 @item @emph{Example}:
1963 @smallexample
1964 program atomic
1965   use iso_fortran_env
1966   integer(atomic_int_kind) :: atom[*], old
1967   call atomic_fetch_xor (atom[1], int(b'10100011101'), old)
1968 end program atomic
1969 @end smallexample
1971 @item @emph{See also}:
1972 @ref{ATOMIC_DEFINE}, @ref{ATOMIC_XOR}, @ref{ISO_FORTRAN_ENV},
1973 @ref{ATOMIC_FETCH_ADD}, @ref{ATOMIC_FETCH_AND}, @ref{ATOMIC_FETCH_OR}
1974 @end table
1978 @node ATOMIC_OR
1979 @section @code{ATOMIC_OR} --- Atomic bitwise OR operation
1980 @fnindex ATOMIC_OR
1981 @cindex Atomic subroutine, OR
1983 @table @asis
1984 @item @emph{Description}:
1985 @code{ATOMIC_OR(ATOM, VALUE)} atomically defines @var{ATOM} with the bitwise
1986 AND between the values of @var{ATOM} and @var{VALUE}. When @var{STAT} is present
1987 and the invokation was successful, it is assigned the value 0. If it is present
1988 and the invokation has failed, it is assigned a positive value; in particular,
1989 for a coindexed @var{ATOM}, if the remote image has stopped, it is assigned the
1990 value of @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote
1991 image has failed, the value @code{STAT_FAILED_IMAGE}.
1993 @item @emph{Standard}:
1994 TS 18508 or later
1996 @item @emph{Class}:
1997 Atomic subroutine
1999 @item @emph{Syntax}:
2000 @code{CALL ATOMIC_OR (ATOM, VALUE [, STAT])}
2002 @item @emph{Arguments}:
2003 @multitable @columnfractions .15 .70
2004 @item @var{ATOM}   @tab Scalar coarray or coindexed variable of integer
2005 type with @code{ATOMIC_INT_KIND} kind.
2006 @item @var{VALUE}  @tab Scalar of the same type as @var{ATOM}. If the kind
2007 is different, the value is converted to the kind of @var{ATOM}.
2008 @item @var{STAT}   @tab (optional) Scalar default-kind integer variable.
2009 @end multitable
2011 @item @emph{Example}:
2012 @smallexample
2013 program atomic
2014   use iso_fortran_env
2015   integer(atomic_int_kind) :: atom[*]
2016   call atomic_or (atom[1], int(b'10100011101'))
2017 end program atomic
2018 @end smallexample
2020 @item @emph{See also}:
2021 @ref{ATOMIC_DEFINE}, @ref{ATOMIC_FETCH_OR}, @ref{ISO_FORTRAN_ENV},
2022 @ref{ATOMIC_ADD}, @ref{ATOMIC_OR}, @ref{ATOMIC_XOR}
2023 @end table
2027 @node ATOMIC_REF
2028 @section @code{ATOMIC_REF} --- Obtaining the value of a variable atomically
2029 @fnindex ATOMIC_REF
2030 @cindex Atomic subroutine, reference
2032 @table @asis
2033 @item @emph{Description}:
2034 @code{ATOMIC_DEFINE(ATOM, VALUE)} atomically assigns the value of the
2035 variable @var{ATOM} to @var{VALUE}. When @var{STAT} is present and the
2036 invokation was successful, it is assigned the value 0. If it is present and the
2037 invokation has failed, it is assigned a positive value; in particular, for a
2038 coindexed @var{ATOM}, if the remote image has stopped, it is assigned the value
2039 of @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image
2040 has failed, the value @code{STAT_FAILED_IMAGE}.
2043 @item @emph{Standard}:
2044 Fortran 2008 and later; with @var{STAT}, TS 18508 or later
2046 @item @emph{Class}:
2047 Atomic subroutine
2049 @item @emph{Syntax}:
2050 @code{CALL ATOMIC_REF(VALUE, ATOM [, STAT])}
2052 @item @emph{Arguments}:
2053 @multitable @columnfractions .15 .70
2054 @item @var{VALUE}  @tab Scalar of the same type as @var{ATOM}. If the kind
2055 is different, the value is converted to the kind of @var{ATOM}.
2056 @item @var{ATOM}   @tab Scalar coarray or coindexed variable of either integer
2057 type with @code{ATOMIC_INT_KIND} kind or logical type with
2058 @code{ATOMIC_LOGICAL_KIND} kind.
2059 @item @var{STAT}   @tab (optional) Scalar default-kind integer variable.
2060 @end multitable
2062 @item @emph{Example}:
2063 @smallexample
2064 program atomic
2065   use iso_fortran_env
2066   logical(atomic_logical_kind) :: atom[*]
2067   logical :: val
2068   call atomic_ref (atom, .false.)
2069   ! ...
2070   call atomic_ref (atom, val)
2071   if (val) then
2072     print *, "Obtained"
2073   end if
2074 end program atomic
2075 @end smallexample
2077 @item @emph{See also}:
2078 @ref{ATOMIC_DEFINE}, @ref{ATOMIC_CAS}, @ref{ISO_FORTRAN_ENV},
2079 @ref{ATOMIC_FETCH_ADD}, @ref{ATOMIC_FETCH_AND}, @ref{ATOMIC_FETCH_OR},
2080 @ref{ATOMIC_FETCH_XOR}
2081 @end table
2084 @node ATOMIC_XOR
2085 @section @code{ATOMIC_XOR} --- Atomic bitwise OR operation
2086 @fnindex ATOMIC_XOR
2087 @cindex Atomic subroutine, XOR
2089 @table @asis
2090 @item @emph{Description}:
2091 @code{ATOMIC_AND(ATOM, VALUE)} atomically defines @var{ATOM} with the bitwise
2092 XOR between the values of @var{ATOM} and @var{VALUE}. When @var{STAT} is present
2093 and the invokation was successful, it is assigned the value 0. If it is present
2094 and the invokation has failed, it is assigned a positive value; in particular,
2095 for a coindexed @var{ATOM}, if the remote image has stopped, it is assigned the
2096 value of @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote
2097 image has failed, the value @code{STAT_FAILED_IMAGE}.
2099 @item @emph{Standard}:
2100 TS 18508 or later
2102 @item @emph{Class}:
2103 Atomic subroutine
2105 @item @emph{Syntax}:
2106 @code{CALL ATOMIC_XOR (ATOM, VALUE [, STAT])}
2108 @item @emph{Arguments}:
2109 @multitable @columnfractions .15 .70
2110 @item @var{ATOM}   @tab Scalar coarray or coindexed variable of integer
2111 type with @code{ATOMIC_INT_KIND} kind.
2112 @item @var{VALUE}  @tab Scalar of the same type as @var{ATOM}. If the kind
2113 is different, the value is converted to the kind of @var{ATOM}.
2114 @item @var{STAT}   @tab (optional) Scalar default-kind integer variable.
2115 @end multitable
2117 @item @emph{Example}:
2118 @smallexample
2119 program atomic
2120   use iso_fortran_env
2121   integer(atomic_int_kind) :: atom[*]
2122   call atomic_xor (atom[1], int(b'10100011101'))
2123 end program atomic
2124 @end smallexample
2126 @item @emph{See also}:
2127 @ref{ATOMIC_DEFINE}, @ref{ATOMIC_FETCH_XOR}, @ref{ISO_FORTRAN_ENV},
2128 @ref{ATOMIC_ADD}, @ref{ATOMIC_OR}, @ref{ATOMIC_XOR}
2129 @end table
2132 @node BACKTRACE
2133 @section @code{BACKTRACE} --- Show a backtrace
2134 @fnindex BACKTRACE
2135 @cindex backtrace
2137 @table @asis
2138 @item @emph{Description}:
2139 @code{BACKTRACE} shows a backtrace at an arbitrary place in user code. Program
2140 execution continues normally afterwards. The backtrace information is printed
2141 to the unit corresponding to @code{ERROR_UNIT} in @code{ISO_FORTRAN_ENV}.
2143 @item @emph{Standard}:
2144 GNU Extension
2146 @item @emph{Class}:
2147 Subroutine
2149 @item @emph{Syntax}:
2150 @code{CALL BACKTRACE}
2152 @item @emph{Arguments}:
2153 None
2155 @item @emph{See also}:
2156 @ref{ABORT}
2157 @end table
2161 @node BESSEL_J0
2162 @section @code{BESSEL_J0} --- Bessel function of the first kind of order 0
2163 @fnindex BESSEL_J0
2164 @fnindex BESJ0
2165 @fnindex DBESJ0
2166 @cindex Bessel function, first kind
2168 @table @asis
2169 @item @emph{Description}:
2170 @code{BESSEL_J0(X)} computes the Bessel function of the first kind of
2171 order 0 of @var{X}. This function is available under the name
2172 @code{BESJ0} as a GNU extension.
2174 @item @emph{Standard}:
2175 Fortran 2008 and later
2177 @item @emph{Class}:
2178 Elemental function
2180 @item @emph{Syntax}:
2181 @code{RESULT = BESSEL_J0(X)}
2183 @item @emph{Arguments}:
2184 @multitable @columnfractions .15 .70
2185 @item @var{X} @tab The type shall be @code{REAL}.
2186 @end multitable
2188 @item @emph{Return value}:
2189 The return value is of type @code{REAL} and lies in the
2190 range @math{ - 0.4027... \leq Bessel (0,x) \leq 1}. It has the same
2191 kind as @var{X}.
2193 @item @emph{Example}:
2194 @smallexample
2195 program test_besj0
2196   real(8) :: x = 0.0_8
2197   x = bessel_j0(x)
2198 end program test_besj0
2199 @end smallexample
2201 @item @emph{Specific names}:
2202 @multitable @columnfractions .20 .20 .20 .25
2203 @item Name            @tab Argument          @tab Return type       @tab Standard
2204 @item @code{DBESJ0(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}   @tab GNU extension
2205 @end multitable
2206 @end table
2210 @node BESSEL_J1
2211 @section @code{BESSEL_J1} --- Bessel function of the first kind of order 1
2212 @fnindex BESSEL_J1
2213 @fnindex BESJ1
2214 @fnindex DBESJ1
2215 @cindex Bessel function, first kind
2217 @table @asis
2218 @item @emph{Description}:
2219 @code{BESSEL_J1(X)} computes the Bessel function of the first kind of
2220 order 1 of @var{X}. This function is available under the name
2221 @code{BESJ1} as a GNU extension.
2223 @item @emph{Standard}:
2224 Fortran 2008
2226 @item @emph{Class}:
2227 Elemental function
2229 @item @emph{Syntax}:
2230 @code{RESULT = BESSEL_J1(X)}
2232 @item @emph{Arguments}:
2233 @multitable @columnfractions .15 .70
2234 @item @var{X} @tab The type shall be @code{REAL}.
2235 @end multitable
2237 @item @emph{Return value}:
2238 The return value is of type @code{REAL} and lies in the
2239 range @math{ - 0.5818... \leq Bessel (0,x) \leq 0.5818 }. It has the same
2240 kind as @var{X}.
2242 @item @emph{Example}:
2243 @smallexample
2244 program test_besj1
2245   real(8) :: x = 1.0_8
2246   x = bessel_j1(x)
2247 end program test_besj1
2248 @end smallexample
2250 @item @emph{Specific names}:
2251 @multitable @columnfractions .20 .20 .20 .25
2252 @item Name             @tab Argument          @tab Return type       @tab Standard
2253 @item @code{DBESJ1(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
2254 @end multitable
2255 @end table
2259 @node BESSEL_JN
2260 @section @code{BESSEL_JN} --- Bessel function of the first kind
2261 @fnindex BESSEL_JN
2262 @fnindex BESJN
2263 @fnindex DBESJN
2264 @cindex Bessel function, first kind
2266 @table @asis
2267 @item @emph{Description}:
2268 @code{BESSEL_JN(N, X)} computes the Bessel function of the first kind of
2269 order @var{N} of @var{X}. This function is available under the name
2270 @code{BESJN} as a GNU extension.  If @var{N} and @var{X} are arrays,
2271 their ranks and shapes shall conform.  
2273 @code{BESSEL_JN(N1, N2, X)} returns an array with the Bessel functions
2274 of the first kind of the orders @var{N1} to @var{N2}.
2276 @item @emph{Standard}:
2277 Fortran 2008 and later, negative @var{N} is allowed as GNU extension
2279 @item @emph{Class}:
2280 Elemental function, except for the transformational function
2281 @code{BESSEL_JN(N1, N2, X)}
2283 @item @emph{Syntax}:
2284 @multitable @columnfractions .80
2285 @item @code{RESULT = BESSEL_JN(N, X)}
2286 @item @code{RESULT = BESSEL_JN(N1, N2, X)}
2287 @end multitable
2289 @item @emph{Arguments}:
2290 @multitable @columnfractions .15 .70
2291 @item @var{N} @tab Shall be a scalar or an array of type  @code{INTEGER}.
2292 @item @var{N1} @tab Shall be a non-negative scalar of type  @code{INTEGER}.
2293 @item @var{N2} @tab Shall be a non-negative scalar of type  @code{INTEGER}.
2294 @item @var{X} @tab Shall be a scalar or an array of type  @code{REAL};
2295 for @code{BESSEL_JN(N1, N2, X)} it shall be scalar.
2296 @end multitable
2298 @item @emph{Return value}:
2299 The return value is a scalar of type @code{REAL}. It has the same
2300 kind as @var{X}.
2302 @item @emph{Note}:
2303 The transformational function uses a recurrence algorithm which might,
2304 for some values of @var{X}, lead to different results than calls to
2305 the elemental function.
2307 @item @emph{Example}:
2308 @smallexample
2309 program test_besjn
2310   real(8) :: x = 1.0_8
2311   x = bessel_jn(5,x)
2312 end program test_besjn
2313 @end smallexample
2315 @item @emph{Specific names}:
2316 @multitable @columnfractions .20 .20 .20 .25
2317 @item Name                @tab Argument            @tab Return type       @tab Standard
2318 @item @code{DBESJN(N, X)} @tab @code{INTEGER N}    @tab @code{REAL(8)}    @tab GNU extension
2319 @item                     @tab @code{REAL(8) X}    @tab                   @tab
2320 @end multitable
2321 @end table
2325 @node BESSEL_Y0
2326 @section @code{BESSEL_Y0} --- Bessel function of the second kind of order 0
2327 @fnindex BESSEL_Y0
2328 @fnindex BESY0
2329 @fnindex DBESY0
2330 @cindex Bessel function, second kind
2332 @table @asis
2333 @item @emph{Description}:
2334 @code{BESSEL_Y0(X)} computes the Bessel function of the second kind of
2335 order 0 of @var{X}. This function is available under the name
2336 @code{BESY0} as a GNU extension.
2338 @item @emph{Standard}:
2339 Fortran 2008 and later
2341 @item @emph{Class}:
2342 Elemental function
2344 @item @emph{Syntax}:
2345 @code{RESULT = BESSEL_Y0(X)}
2347 @item @emph{Arguments}:
2348 @multitable @columnfractions .15 .70
2349 @item @var{X} @tab The type shall be @code{REAL}.
2350 @end multitable
2352 @item @emph{Return value}:
2353 The return value is of type @code{REAL}. It has the same kind as @var{X}.
2355 @item @emph{Example}:
2356 @smallexample
2357 program test_besy0
2358   real(8) :: x = 0.0_8
2359   x = bessel_y0(x)
2360 end program test_besy0
2361 @end smallexample
2363 @item @emph{Specific names}:
2364 @multitable @columnfractions .20 .20 .20 .25
2365 @item Name            @tab Argument          @tab Return type       @tab Standard
2366 @item @code{DBESY0(X)}@tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
2367 @end multitable
2368 @end table
2372 @node BESSEL_Y1
2373 @section @code{BESSEL_Y1} --- Bessel function of the second kind of order 1
2374 @fnindex BESSEL_Y1
2375 @fnindex BESY1
2376 @fnindex DBESY1
2377 @cindex Bessel function, second kind
2379 @table @asis
2380 @item @emph{Description}:
2381 @code{BESSEL_Y1(X)} computes the Bessel function of the second kind of
2382 order 1 of @var{X}. This function is available under the name
2383 @code{BESY1} as a GNU extension.
2385 @item @emph{Standard}:
2386 Fortran 2008 and later
2388 @item @emph{Class}:
2389 Elemental function
2391 @item @emph{Syntax}:
2392 @code{RESULT = BESSEL_Y1(X)}
2394 @item @emph{Arguments}:
2395 @multitable @columnfractions .15 .70
2396 @item @var{X} @tab The type shall be @code{REAL}.
2397 @end multitable
2399 @item @emph{Return value}:
2400 The return value is of type @code{REAL}. It has the same kind as @var{X}.
2402 @item @emph{Example}:
2403 @smallexample
2404 program test_besy1
2405   real(8) :: x = 1.0_8
2406   x = bessel_y1(x)
2407 end program test_besy1
2408 @end smallexample
2410 @item @emph{Specific names}:
2411 @multitable @columnfractions .20 .20 .20 .25
2412 @item Name            @tab Argument          @tab Return type       @tab Standard
2413 @item @code{DBESY1(X)}@tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
2414 @end multitable
2415 @end table
2419 @node BESSEL_YN
2420 @section @code{BESSEL_YN} --- Bessel function of the second kind
2421 @fnindex BESSEL_YN
2422 @fnindex BESYN
2423 @fnindex DBESYN
2424 @cindex Bessel function, second kind
2426 @table @asis
2427 @item @emph{Description}:
2428 @code{BESSEL_YN(N, X)} computes the Bessel function of the second kind of
2429 order @var{N} of @var{X}. This function is available under the name
2430 @code{BESYN} as a GNU extension.  If @var{N} and @var{X} are arrays,
2431 their ranks and shapes shall conform.  
2433 @code{BESSEL_YN(N1, N2, X)} returns an array with the Bessel functions
2434 of the first kind of the orders @var{N1} to @var{N2}.
2436 @item @emph{Standard}:
2437 Fortran 2008 and later, negative @var{N} is allowed as GNU extension
2439 @item @emph{Class}:
2440 Elemental function, except for the transformational function
2441 @code{BESSEL_YN(N1, N2, X)}
2443 @item @emph{Syntax}:
2444 @multitable @columnfractions .80
2445 @item @code{RESULT = BESSEL_YN(N, X)}
2446 @item @code{RESULT = BESSEL_YN(N1, N2, X)}
2447 @end multitable
2449 @item @emph{Arguments}:
2450 @multitable @columnfractions .15 .70
2451 @item @var{N} @tab Shall be a scalar or an array of type  @code{INTEGER} .
2452 @item @var{N1} @tab Shall be a non-negative scalar of type  @code{INTEGER}.
2453 @item @var{N2} @tab Shall be a non-negative scalar of type  @code{INTEGER}.
2454 @item @var{X} @tab Shall be a scalar or an array of type  @code{REAL};
2455 for @code{BESSEL_YN(N1, N2, X)} it shall be scalar.
2456 @end multitable
2458 @item @emph{Return value}:
2459 The return value is a scalar of type @code{REAL}. It has the same
2460 kind as @var{X}.
2462 @item @emph{Note}:
2463 The transformational function uses a recurrence algorithm which might,
2464 for some values of @var{X}, lead to different results than calls to
2465 the elemental function.
2467 @item @emph{Example}:
2468 @smallexample
2469 program test_besyn
2470   real(8) :: x = 1.0_8
2471   x = bessel_yn(5,x)
2472 end program test_besyn
2473 @end smallexample
2475 @item @emph{Specific names}:
2476 @multitable @columnfractions .20 .20 .20 .25
2477 @item Name               @tab Argument            @tab Return type     @tab Standard
2478 @item @code{DBESYN(N,X)} @tab @code{INTEGER N} @tab @code{REAL(8)}  @tab GNU extension
2479 @item                    @tab @code{REAL(8) X} @tab                 @tab 
2480 @end multitable
2481 @end table
2485 @node BGE
2486 @section @code{BGE} --- Bitwise greater than or equal to
2487 @fnindex BGE
2488 @cindex bitwise comparison
2490 @table @asis
2491 @item @emph{Description}:
2492 Determines whether an integral is a bitwise greater than or equal to
2493 another.
2495 @item @emph{Standard}:
2496 Fortran 2008 and later
2498 @item @emph{Class}:
2499 Elemental function
2501 @item @emph{Syntax}:
2502 @code{RESULT = BGE(I, J)}
2504 @item @emph{Arguments}:
2505 @multitable @columnfractions .15 .70
2506 @item @var{I} @tab Shall be of @code{INTEGER} type.
2507 @item @var{J} @tab Shall be of @code{INTEGER} type, and of the same kind
2508 as @var{I}.
2509 @end multitable
2511 @item @emph{Return value}:
2512 The return value is of type @code{LOGICAL} and of the default kind.
2514 @item @emph{See also}:
2515 @ref{BGT}, @ref{BLE}, @ref{BLT}
2516 @end table
2520 @node BGT
2521 @section @code{BGT} --- Bitwise greater than
2522 @fnindex BGT
2523 @cindex bitwise comparison
2525 @table @asis
2526 @item @emph{Description}:
2527 Determines whether an integral is a bitwise greater than another.
2529 @item @emph{Standard}:
2530 Fortran 2008 and later
2532 @item @emph{Class}:
2533 Elemental function
2535 @item @emph{Syntax}:
2536 @code{RESULT = BGT(I, J)}
2538 @item @emph{Arguments}:
2539 @multitable @columnfractions .15 .70
2540 @item @var{I} @tab Shall be of @code{INTEGER} type.
2541 @item @var{J} @tab Shall be of @code{INTEGER} type, and of the same kind
2542 as @var{I}.
2543 @end multitable
2545 @item @emph{Return value}:
2546 The return value is of type @code{LOGICAL} and of the default kind.
2548 @item @emph{See also}:
2549 @ref{BGE}, @ref{BLE}, @ref{BLT}
2550 @end table
2554 @node BIT_SIZE
2555 @section @code{BIT_SIZE} --- Bit size inquiry function
2556 @fnindex BIT_SIZE
2557 @cindex bits, number of
2558 @cindex size of a variable, in bits
2560 @table @asis
2561 @item @emph{Description}:
2562 @code{BIT_SIZE(I)} returns the number of bits (integer precision plus sign bit)
2563 represented by the type of @var{I}.  The result of @code{BIT_SIZE(I)} is
2564 independent of the actual value of @var{I}.
2566 @item @emph{Standard}:
2567 Fortran 95 and later
2569 @item @emph{Class}:
2570 Inquiry function
2572 @item @emph{Syntax}:
2573 @code{RESULT = BIT_SIZE(I)}
2575 @item @emph{Arguments}:
2576 @multitable @columnfractions .15 .70
2577 @item @var{I} @tab The type shall be @code{INTEGER}.
2578 @end multitable
2580 @item @emph{Return value}:
2581 The return value is of type @code{INTEGER}
2583 @item @emph{Example}:
2584 @smallexample
2585 program test_bit_size
2586     integer :: i = 123
2587     integer :: size
2588     size = bit_size(i)
2589     print *, size
2590 end program test_bit_size
2591 @end smallexample
2592 @end table
2596 @node BLE
2597 @section @code{BLE} --- Bitwise less than or equal to
2598 @fnindex BLE
2599 @cindex bitwise comparison
2601 @table @asis
2602 @item @emph{Description}:
2603 Determines whether an integral is a bitwise less than or equal to
2604 another.
2606 @item @emph{Standard}:
2607 Fortran 2008 and later
2609 @item @emph{Class}:
2610 Elemental function
2612 @item @emph{Syntax}:
2613 @code{RESULT = BLE(I, J)}
2615 @item @emph{Arguments}:
2616 @multitable @columnfractions .15 .70
2617 @item @var{I} @tab Shall be of @code{INTEGER} type.
2618 @item @var{J} @tab Shall be of @code{INTEGER} type, and of the same kind
2619 as @var{I}.
2620 @end multitable
2622 @item @emph{Return value}:
2623 The return value is of type @code{LOGICAL} and of the default kind.
2625 @item @emph{See also}:
2626 @ref{BGT}, @ref{BGE}, @ref{BLT}
2627 @end table
2631 @node BLT
2632 @section @code{BLT} --- Bitwise less than
2633 @fnindex BLT
2634 @cindex bitwise comparison
2636 @table @asis
2637 @item @emph{Description}:
2638 Determines whether an integral is a bitwise less than another.
2640 @item @emph{Standard}:
2641 Fortran 2008 and later
2643 @item @emph{Class}:
2644 Elemental function
2646 @item @emph{Syntax}:
2647 @code{RESULT = BLT(I, J)}
2649 @item @emph{Arguments}:
2650 @multitable @columnfractions .15 .70
2651 @item @var{I} @tab Shall be of @code{INTEGER} type.
2652 @item @var{J} @tab Shall be of @code{INTEGER} type, and of the same kind
2653 as @var{I}.
2654 @end multitable
2656 @item @emph{Return value}:
2657 The return value is of type @code{LOGICAL} and of the default kind.
2659 @item @emph{See also}:
2660 @ref{BGE}, @ref{BGT}, @ref{BLE}
2661 @end table
2665 @node BTEST
2666 @section @code{BTEST} --- Bit test function
2667 @fnindex BTEST
2668 @cindex bits, testing
2670 @table @asis
2671 @item @emph{Description}:
2672 @code{BTEST(I,POS)} returns logical @code{.TRUE.} if the bit at @var{POS}
2673 in @var{I} is set.  The counting of the bits starts at 0.
2675 @item @emph{Standard}:
2676 Fortran 95 and later
2678 @item @emph{Class}:
2679 Elemental function
2681 @item @emph{Syntax}:
2682 @code{RESULT = BTEST(I, POS)}
2684 @item @emph{Arguments}:
2685 @multitable @columnfractions .15 .70
2686 @item @var{I} @tab The type shall be @code{INTEGER}.
2687 @item @var{POS} @tab The type shall be @code{INTEGER}.
2688 @end multitable
2690 @item @emph{Return value}:
2691 The return value is of type @code{LOGICAL}
2693 @item @emph{Example}:
2694 @smallexample
2695 program test_btest
2696     integer :: i = 32768 + 1024 + 64
2697     integer :: pos
2698     logical :: bool
2699     do pos=0,16
2700         bool = btest(i, pos) 
2701         print *, pos, bool
2702     end do
2703 end program test_btest
2704 @end smallexample
2705 @end table
2708 @node C_ASSOCIATED
2709 @section @code{C_ASSOCIATED} --- Status of a C pointer
2710 @fnindex C_ASSOCIATED
2711 @cindex association status, C pointer
2712 @cindex pointer, C association status
2714 @table @asis
2715 @item @emph{Description}:
2716 @code{C_ASSOCIATED(c_ptr_1[, c_ptr_2])} determines the status of the C pointer
2717 @var{c_ptr_1} or if @var{c_ptr_1} is associated with the target @var{c_ptr_2}.
2719 @item @emph{Standard}:
2720 Fortran 2003 and later
2722 @item @emph{Class}:
2723 Inquiry function
2725 @item @emph{Syntax}:
2726 @code{RESULT = C_ASSOCIATED(c_ptr_1[, c_ptr_2])}
2728 @item @emph{Arguments}:
2729 @multitable @columnfractions .15 .70
2730 @item @var{c_ptr_1} @tab Scalar of the type @code{C_PTR} or @code{C_FUNPTR}.
2731 @item @var{c_ptr_2} @tab (Optional) Scalar of the same type as @var{c_ptr_1}.
2732 @end multitable
2734 @item @emph{Return value}:
2735 The return value is of type @code{LOGICAL}; it is @code{.false.} if either
2736 @var{c_ptr_1} is a C NULL pointer or if @var{c_ptr1} and @var{c_ptr_2}
2737 point to different addresses.
2739 @item @emph{Example}:
2740 @smallexample
2741 subroutine association_test(a,b)
2742   use iso_c_binding, only: c_associated, c_loc, c_ptr
2743   implicit none
2744   real, pointer :: a
2745   type(c_ptr) :: b
2746   if(c_associated(b, c_loc(a))) &
2747      stop 'b and a do not point to same target'
2748 end subroutine association_test
2749 @end smallexample
2751 @item @emph{See also}:
2752 @ref{C_LOC}, @ref{C_FUNLOC}
2753 @end table
2756 @node C_F_POINTER
2757 @section @code{C_F_POINTER} --- Convert C into Fortran pointer
2758 @fnindex C_F_POINTER
2759 @cindex pointer, convert C to Fortran
2761 @table @asis
2762 @item @emph{Description}:
2763 @code{C_F_POINTER(CPTR, FPTR[, SHAPE])} assigns the target of the C pointer
2764 @var{CPTR} to the Fortran pointer @var{FPTR} and specifies its shape.
2766 @item @emph{Standard}:
2767 Fortran 2003 and later
2769 @item @emph{Class}:
2770 Subroutine
2772 @item @emph{Syntax}:
2773 @code{CALL C_F_POINTER(CPTR, FPTR[, SHAPE])}
2775 @item @emph{Arguments}:
2776 @multitable @columnfractions .15 .70
2777 @item @var{CPTR}  @tab scalar of the type @code{C_PTR}. It is
2778 @code{INTENT(IN)}.
2779 @item @var{FPTR}  @tab pointer interoperable with @var{cptr}. It is
2780 @code{INTENT(OUT)}.
2781 @item @var{SHAPE} @tab (Optional) Rank-one array of type @code{INTEGER}
2782 with @code{INTENT(IN)}. It shall be present
2783 if and only if @var{fptr} is an array. The size
2784 must be equal to the rank of @var{fptr}.
2785 @end multitable
2787 @item @emph{Example}:
2788 @smallexample
2789 program main
2790   use iso_c_binding
2791   implicit none
2792   interface
2793     subroutine my_routine(p) bind(c,name='myC_func')
2794       import :: c_ptr
2795       type(c_ptr), intent(out) :: p
2796     end subroutine
2797   end interface
2798   type(c_ptr) :: cptr
2799   real,pointer :: a(:)
2800   call my_routine(cptr)
2801   call c_f_pointer(cptr, a, [12])
2802 end program main
2803 @end smallexample
2805 @item @emph{See also}:
2806 @ref{C_LOC}, @ref{C_F_PROCPOINTER}
2807 @end table
2810 @node C_F_PROCPOINTER
2811 @section @code{C_F_PROCPOINTER} --- Convert C into Fortran procedure pointer
2812 @fnindex C_F_PROCPOINTER
2813 @cindex pointer, C address of pointers
2815 @table @asis
2816 @item @emph{Description}:
2817 @code{C_F_PROCPOINTER(CPTR, FPTR)} Assign the target of the C function pointer
2818 @var{CPTR} to the Fortran procedure pointer @var{FPTR}.
2820 @item @emph{Standard}:
2821 Fortran 2003 and later
2823 @item @emph{Class}:
2824 Subroutine
2826 @item @emph{Syntax}:
2827 @code{CALL C_F_PROCPOINTER(cptr, fptr)}
2829 @item @emph{Arguments}:
2830 @multitable @columnfractions .15 .70
2831 @item @var{CPTR}  @tab scalar of the type @code{C_FUNPTR}. It is
2832 @code{INTENT(IN)}.
2833 @item @var{FPTR}  @tab procedure pointer interoperable with @var{cptr}. It is
2834 @code{INTENT(OUT)}.
2835 @end multitable
2837 @item @emph{Example}:
2838 @smallexample
2839 program main
2840   use iso_c_binding
2841   implicit none
2842   abstract interface
2843     function func(a)
2844       import :: c_float
2845       real(c_float), intent(in) :: a
2846       real(c_float) :: func
2847     end function
2848   end interface
2849   interface
2850      function getIterFunc() bind(c,name="getIterFunc")
2851        import :: c_funptr
2852        type(c_funptr) :: getIterFunc
2853      end function
2854   end interface
2855   type(c_funptr) :: cfunptr
2856   procedure(func), pointer :: myFunc
2857   cfunptr = getIterFunc()
2858   call c_f_procpointer(cfunptr, myFunc)
2859 end program main
2860 @end smallexample
2862 @item @emph{See also}:
2863 @ref{C_LOC}, @ref{C_F_POINTER}
2864 @end table
2867 @node C_FUNLOC
2868 @section @code{C_FUNLOC} --- Obtain the C address of a procedure
2869 @fnindex C_FUNLOC
2870 @cindex pointer, C address of procedures
2872 @table @asis
2873 @item @emph{Description}:
2874 @code{C_FUNLOC(x)} determines the C address of the argument.
2876 @item @emph{Standard}:
2877 Fortran 2003 and later
2879 @item @emph{Class}:
2880 Inquiry function
2882 @item @emph{Syntax}:
2883 @code{RESULT = C_FUNLOC(x)}
2885 @item @emph{Arguments}:
2886 @multitable @columnfractions .15 .70
2887 @item @var{x} @tab Interoperable function or pointer to such function.
2888 @end multitable
2890 @item @emph{Return value}:
2891 The return value is of type @code{C_FUNPTR} and contains the C address
2892 of the argument.
2894 @item @emph{Example}:
2895 @smallexample
2896 module x
2897   use iso_c_binding
2898   implicit none
2899 contains
2900   subroutine sub(a) bind(c)
2901     real(c_float) :: a
2902     a = sqrt(a)+5.0
2903   end subroutine sub
2904 end module x
2905 program main
2906   use iso_c_binding
2907   use x
2908   implicit none
2909   interface
2910     subroutine my_routine(p) bind(c,name='myC_func')
2911       import :: c_funptr
2912       type(c_funptr), intent(in) :: p
2913     end subroutine
2914   end interface
2915   call my_routine(c_funloc(sub))
2916 end program main
2917 @end smallexample
2919 @item @emph{See also}:
2920 @ref{C_ASSOCIATED}, @ref{C_LOC}, @ref{C_F_POINTER}, @ref{C_F_PROCPOINTER}
2921 @end table
2924 @node C_LOC
2925 @section @code{C_LOC} --- Obtain the C address of an object
2926 @fnindex C_LOC
2927 @cindex procedure pointer, convert C to Fortran
2929 @table @asis
2930 @item @emph{Description}:
2931 @code{C_LOC(X)} determines the C address of the argument.
2933 @item @emph{Standard}:
2934 Fortran 2003 and later
2936 @item @emph{Class}:
2937 Inquiry function
2939 @item @emph{Syntax}:
2940 @code{RESULT = C_LOC(X)}
2942 @item @emph{Arguments}:
2943 @multitable @columnfractions .10 .75
2944 @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.
2946 @end multitable
2948 @item @emph{Return value}:
2949 The return value is of type @code{C_PTR} and contains the C address
2950 of the argument.
2952 @item @emph{Example}:
2953 @smallexample
2954 subroutine association_test(a,b)
2955   use iso_c_binding, only: c_associated, c_loc, c_ptr
2956   implicit none
2957   real, pointer :: a
2958   type(c_ptr) :: b
2959   if(c_associated(b, c_loc(a))) &
2960      stop 'b and a do not point to same target'
2961 end subroutine association_test
2962 @end smallexample
2964 @item @emph{See also}:
2965 @ref{C_ASSOCIATED}, @ref{C_FUNLOC}, @ref{C_F_POINTER}, @ref{C_F_PROCPOINTER}
2966 @end table
2969 @node C_SIZEOF
2970 @section @code{C_SIZEOF} --- Size in bytes of an expression
2971 @fnindex C_SIZEOF
2972 @cindex expression size
2973 @cindex size of an expression
2975 @table @asis
2976 @item @emph{Description}:
2977 @code{C_SIZEOF(X)} calculates the number of bytes of storage the
2978 expression @code{X} occupies.
2980 @item @emph{Standard}:
2981 Fortran 2008
2983 @item @emph{Class}:
2984 Inquiry function of the module @code{ISO_C_BINDING}
2986 @item @emph{Syntax}:
2987 @code{N = C_SIZEOF(X)}
2989 @item @emph{Arguments}:
2990 @multitable @columnfractions .15 .70
2991 @item @var{X} @tab The argument shall be an interoperable data entity.
2992 @end multitable
2994 @item @emph{Return value}:
2995 The return value is of type integer and of the system-dependent kind
2996 @code{C_SIZE_T} (from the @code{ISO_C_BINDING} module). Its value is the
2997 number of bytes occupied by the argument.  If the argument has the
2998 @code{POINTER} attribute, the number of bytes of the storage area pointed
2999 to is returned.  If the argument is of a derived type with @code{POINTER}
3000 or @code{ALLOCATABLE} components, the return value does not account for
3001 the sizes of the data pointed to by these components.
3003 @item @emph{Example}:
3004 @smallexample
3005    use iso_c_binding
3006    integer(c_int) :: i
3007    real(c_float) :: r, s(5)
3008    print *, (c_sizeof(s)/c_sizeof(r) == 5)
3009    end
3010 @end smallexample
3011 The example will print @code{.TRUE.} unless you are using a platform
3012 where default @code{REAL} variables are unusually padded.
3014 @item @emph{See also}:
3015 @ref{SIZEOF}, @ref{STORAGE_SIZE}
3016 @end table
3019 @node CEILING
3020 @section @code{CEILING} --- Integer ceiling function
3021 @fnindex CEILING
3022 @cindex ceiling
3023 @cindex rounding, ceiling
3025 @table @asis
3026 @item @emph{Description}:
3027 @code{CEILING(A)} returns the least integer greater than or equal to @var{A}.
3029 @item @emph{Standard}:
3030 Fortran 95 and later
3032 @item @emph{Class}:
3033 Elemental function
3035 @item @emph{Syntax}:
3036 @code{RESULT = CEILING(A [, KIND])}
3038 @item @emph{Arguments}:
3039 @multitable @columnfractions .15 .70
3040 @item @var{A} @tab The type shall be @code{REAL}.
3041 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
3042 expression indicating the kind parameter of the result.
3043 @end multitable
3045 @item @emph{Return value}:
3046 The return value is of type @code{INTEGER(KIND)} if @var{KIND} is present
3047 and a default-kind @code{INTEGER} otherwise.
3049 @item @emph{Example}:
3050 @smallexample
3051 program test_ceiling
3052     real :: x = 63.29
3053     real :: y = -63.59
3054     print *, ceiling(x) ! returns 64
3055     print *, ceiling(y) ! returns -63
3056 end program test_ceiling
3057 @end smallexample
3059 @item @emph{See also}:
3060 @ref{FLOOR}, @ref{NINT}
3062 @end table
3066 @node CHAR
3067 @section @code{CHAR} --- Character conversion function
3068 @fnindex CHAR
3069 @cindex conversion, to character
3071 @table @asis
3072 @item @emph{Description}:
3073 @code{CHAR(I [, KIND])} returns the character represented by the integer @var{I}.
3075 @item @emph{Standard}:
3076 Fortran 77 and later
3078 @item @emph{Class}:
3079 Elemental function
3081 @item @emph{Syntax}:
3082 @code{RESULT = CHAR(I [, KIND])}
3084 @item @emph{Arguments}:
3085 @multitable @columnfractions .15 .70
3086 @item @var{I} @tab The type shall be @code{INTEGER}.
3087 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
3088 expression indicating the kind parameter of the result.
3089 @end multitable
3091 @item @emph{Return value}:
3092 The return value is of type @code{CHARACTER(1)}
3094 @item @emph{Example}:
3095 @smallexample
3096 program test_char
3097     integer :: i = 74
3098     character(1) :: c
3099     c = char(i)
3100     print *, i, c ! returns 'J'
3101 end program test_char
3102 @end smallexample
3104 @item @emph{Specific names}:
3105 @multitable @columnfractions .20 .20 .20 .25
3106 @item Name           @tab Argument         @tab Return type             @tab Standard
3107 @item @code{CHAR(I)} @tab @code{INTEGER I} @tab @code{CHARACTER(LEN=1)} @tab F77 and later
3108 @end multitable
3110 @item @emph{Note}:
3111 See @ref{ICHAR} for a discussion of converting between numerical values
3112 and formatted string representations.
3114 @item @emph{See also}:
3115 @ref{ACHAR}, @ref{IACHAR}, @ref{ICHAR}
3117 @end table
3121 @node CHDIR
3122 @section @code{CHDIR} --- Change working directory
3123 @fnindex CHDIR
3124 @cindex system, working directory
3126 @table @asis
3127 @item @emph{Description}:
3128 Change current working directory to a specified path.
3130 This intrinsic is provided in both subroutine and function forms; however,
3131 only one form can be used in any given program unit.
3133 @item @emph{Standard}:
3134 GNU extension
3136 @item @emph{Class}:
3137 Subroutine, function
3139 @item @emph{Syntax}:
3140 @multitable @columnfractions .80
3141 @item @code{CALL CHDIR(NAME [, STATUS])}
3142 @item @code{STATUS = CHDIR(NAME)}
3143 @end multitable
3145 @item @emph{Arguments}:
3146 @multitable @columnfractions .15 .70
3147 @item @var{NAME}   @tab The type shall be @code{CHARACTER} of default
3148 kind and shall specify a valid path within the file system.
3149 @item @var{STATUS} @tab (Optional) @code{INTEGER} status flag of the default
3150 kind.  Returns 0 on success, and a system specific and nonzero error code
3151 otherwise.
3152 @end multitable
3154 @item @emph{Example}:
3155 @smallexample
3156 PROGRAM test_chdir
3157   CHARACTER(len=255) :: path
3158   CALL getcwd(path)
3159   WRITE(*,*) TRIM(path)
3160   CALL chdir("/tmp")
3161   CALL getcwd(path)
3162   WRITE(*,*) TRIM(path)
3163 END PROGRAM
3164 @end smallexample
3166 @item @emph{See also}:
3167 @ref{GETCWD}
3168 @end table
3172 @node CHMOD
3173 @section @code{CHMOD} --- Change access permissions of files
3174 @fnindex CHMOD
3175 @cindex file system, change access mode
3177 @table @asis
3178 @item @emph{Description}:
3179 @code{CHMOD} changes the permissions of a file.
3181 This intrinsic is provided in both subroutine and function forms; however,
3182 only one form can be used in any given program unit.
3184 @item @emph{Standard}:
3185 GNU extension
3187 @item @emph{Class}:
3188 Subroutine, function
3190 @item @emph{Syntax}:
3191 @multitable @columnfractions .80
3192 @item @code{CALL CHMOD(NAME, MODE[, STATUS])}
3193 @item @code{STATUS = CHMOD(NAME, MODE)}
3194 @end multitable
3196 @item @emph{Arguments}:
3197 @multitable @columnfractions .15 .70
3199 @item @var{NAME} @tab Scalar @code{CHARACTER} of default kind with the
3200 file name. Trailing blanks are ignored unless the character
3201 @code{achar(0)} is present, then all characters up to and excluding
3202 @code{achar(0)} are used as the file name.
3204 @item @var{MODE} @tab Scalar @code{CHARACTER} of default kind giving the
3205 file permission. @var{MODE} uses the same syntax as the @code{chmod} utility
3206 as defined by the POSIX standard. The argument shall either be a string of
3207 a nonnegative octal number or a symbolic mode.
3209 @item @var{STATUS} @tab (optional) scalar @code{INTEGER}, which is
3210 @code{0} on success and nonzero otherwise.
3211 @end multitable
3213 @item @emph{Return value}:
3214 In either syntax, @var{STATUS} is set to @code{0} on success and nonzero
3215 otherwise.
3217 @item @emph{Example}:
3218 @code{CHMOD} as subroutine
3219 @smallexample
3220 program chmod_test
3221   implicit none
3222   integer :: status
3223   call chmod('test.dat','u+x',status)
3224   print *, 'Status: ', status
3225 end program chmod_test
3226 @end smallexample
3227 @code{CHMOD} as function:
3228 @smallexample
3229 program chmod_test
3230   implicit none
3231   integer :: status
3232   status = chmod('test.dat','u+x')
3233   print *, 'Status: ', status
3234 end program chmod_test
3235 @end smallexample
3237 @end table
3241 @node CMPLX
3242 @section @code{CMPLX} --- Complex conversion function
3243 @fnindex CMPLX
3244 @cindex complex numbers, conversion to
3245 @cindex conversion, to complex
3247 @table @asis
3248 @item @emph{Description}:
3249 @code{CMPLX(X [, Y [, KIND]])} returns a complex number where @var{X} is converted to
3250 the real component.  If @var{Y} is present it is converted to the imaginary
3251 component.  If @var{Y} is not present then the imaginary component is set to
3252 0.0.  If @var{X} is complex then @var{Y} must not be present.
3254 @item @emph{Standard}:
3255 Fortran 77 and later
3257 @item @emph{Class}:
3258 Elemental function
3260 @item @emph{Syntax}:
3261 @code{RESULT = CMPLX(X [, Y [, KIND]])}
3263 @item @emph{Arguments}:
3264 @multitable @columnfractions .15 .70
3265 @item @var{X} @tab The type may be @code{INTEGER}, @code{REAL},
3266 or @code{COMPLEX}.
3267 @item @var{Y} @tab (Optional; only allowed if @var{X} is not
3268 @code{COMPLEX}.)  May be @code{INTEGER} or @code{REAL}.
3269 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
3270 expression indicating the kind parameter of the result.
3271 @end multitable
3273 @item @emph{Return value}:
3274 The return value is of @code{COMPLEX} type, with a kind equal to
3275 @var{KIND} if it is specified.  If @var{KIND} is not specified, the
3276 result is of the default @code{COMPLEX} kind, regardless of the kinds of
3277 @var{X} and @var{Y}. 
3279 @item @emph{Example}:
3280 @smallexample
3281 program test_cmplx
3282     integer :: i = 42
3283     real :: x = 3.14
3284     complex :: z
3285     z = cmplx(i, x)
3286     print *, z, cmplx(x)
3287 end program test_cmplx
3288 @end smallexample
3290 @item @emph{See also}:
3291 @ref{COMPLEX}
3292 @end table
3296 @node CO_BROADCAST
3297 @section @code{CO_BROADCAST} --- Copy a value to all images the current set of images
3298 @fnindex CO_BROADCAST
3299 @cindex Collectives, value broadcasting
3301 @table @asis
3302 @item @emph{Description}:
3303 @code{CO_BROADCAST} copies the value of argument @var{A} on the image with
3304 image index @code{SOURCE_IMAGE} to all images in the current team.  @var{A}
3305 becomes defined as if by intrinsic assignment.  If the execution was
3306 successful and @var{STAT} is present, it is assigned the value zero.  If the
3307 execution failed, @var{STAT} gets assigned a nonzero value and, if present,
3308 @var{ERRMSG} gets assigned a value describing the occurred error.
3310 @item @emph{Standard}:
3311 Technical Specification (TS) 18508 or later
3313 @item @emph{Class}:
3314 Collective subroutine
3316 @item @emph{Syntax}:
3317 @code{CALL CO_BROADCAST(A, SOURCE_IMAGE [, STAT, ERRMSG])}
3319 @item @emph{Arguments}:
3320 @multitable @columnfractions .15 .70
3321 @item @var{A}            @tab INTENT(INOUT) argument; shall have the same
3322 dynamic type and type paramters on all images of the current team. If it
3323 is an array, it shall have the same shape on all images.
3324 @item @var{SOURCE_IMAGE} @tab a scalar integer expression.
3325 It shall have the same the same value on all images and refer to an
3326 image of the current team.
3327 @item @var{STAT}         @tab (optional) a scalar integer variable
3328 @item @var{ERRMSG}       @tab (optional) a scalar character variable
3329 @end multitable
3331 @item @emph{Example}:
3332 @smallexample
3333 program test
3334   integer :: val(3)
3335   if (this_image() == 1) then
3336     val = [1, 5, 3]
3337   end if
3338   call co_broadcast (val, source_image=1)
3339   print *, this_image, ":", val
3340 end program test
3341 @end smallexample
3343 @item @emph{See also}:
3344 @ref{CO_MAX}, @ref{CO_MIN}, @ref{CO_SUM}, @ref{CO_REDUCE}
3345 @end table
3349 @node CO_MAX
3350 @section @code{CO_MAX} --- Maximal value on the current set of images
3351 @fnindex CO_MAX
3352 @cindex Collectives, maximal value
3354 @table @asis
3355 @item @emph{Description}:
3356 @code{CO_MAX} determines element-wise the maximal value of @var{A} on all
3357 images of the current team.  If @var{RESULT_IMAGE} is present, the maximum
3358 values are returned in @var{A} on the specified image only and the value
3359 of @var{A} on the other images become undefined.  If @var{RESULT_IMAGE} is
3360 not present, the value is returned on all images.  If the execution was
3361 successful and @var{STAT} is present, it is assigned the value zero.  If the
3362 execution failed, @var{STAT} gets assigned a nonzero value and, if present,
3363 @var{ERRMSG} gets assigned a value describing the occurred error.
3365 @item @emph{Standard}:
3366 Technical Specification (TS) 18508 or later
3368 @item @emph{Class}:
3369 Collective subroutine
3371 @item @emph{Syntax}:
3372 @code{CALL CO_MAX(A [, RESULT_IMAGE, STAT, ERRMSG])}
3374 @item @emph{Arguments}:
3375 @multitable @columnfractions .15 .70
3376 @item @var{A}            @tab shall be an integer, real or character variable,
3377 which has the same type and type parameters on all images of the team.
3378 @item @var{RESULT_IMAGE} @tab (optional) a scalar integer expression; if
3379 present, it shall have the same the same value on all images and refer to an
3380 image of the current team.
3381 @item @var{STAT}         @tab (optional) a scalar integer variable
3382 @item @var{ERRMSG}       @tab (optional) a scalar character variable
3383 @end multitable
3385 @item @emph{Example}:
3386 @smallexample
3387 program test
3388   integer :: val
3389   val = this_image ()
3390   call co_max (val, result_image=1)
3391   if (this_image() == 1) then
3392     write(*,*) "Maximal value", val  ! prints num_images()
3393   end if
3394 end program test
3395 @end smallexample
3397 @item @emph{See also}:
3398 @ref{CO_MIN}, @ref{CO_SUM}, @ref{CO_REDUCE}, @ref{CO_BROADCAST}
3399 @end table
3403 @node CO_MIN
3404 @section @code{CO_MIN} --- Minimal value on the current set of images
3405 @fnindex CO_MIN
3406 @cindex Collectives, minimal value
3408 @table @asis
3409 @item @emph{Description}:
3410 @code{CO_MIN} determines element-wise the minimal value of @var{A} on all
3411 images of the current team.  If @var{RESULT_IMAGE} is present, the minimal
3412 values are returned in @var{A} on the specified image only and the value
3413 of @var{A} on the other images become undefined.  If @var{RESULT_IMAGE} is
3414 not present, the value is returned on all images.  If the execution was
3415 successful and @var{STAT} is present, it is assigned the value zero.  If the
3416 execution failed, @var{STAT} gets assigned a nonzero value and, if present,
3417 @var{ERRMSG} gets assigned a value describing the occurred error.
3419 @item @emph{Standard}:
3420 Technical Specification (TS) 18508 or later
3422 @item @emph{Class}:
3423 Collective subroutine
3425 @item @emph{Syntax}:
3426 @code{CALL CO_MIN(A [, RESULT_IMAGE, STAT, ERRMSG])}
3428 @item @emph{Arguments}:
3429 @multitable @columnfractions .15 .70
3430 @item @var{A}            @tab shall be an integer, real or character variable,
3431 which has the same type and type parameters on all images of the team.
3432 @item @var{RESULT_IMAGE} @tab (optional) a scalar integer expression; if
3433 present, it shall have the same the same value on all images and refer to an
3434 image of the current team.
3435 @item @var{STAT}         @tab (optional) a scalar integer variable
3436 @item @var{ERRMSG}       @tab (optional) a scalar character variable
3437 @end multitable
3439 @item @emph{Example}:
3440 @smallexample
3441 program test
3442   integer :: val
3443   val = this_image ()
3444   call co_min (val, result_image=1)
3445   if (this_image() == 1) then
3446     write(*,*) "Minimal value", val  ! prints 1
3447   end if
3448 end program test
3449 @end smallexample
3451 @item @emph{See also}:
3452 @ref{CO_MAX}, @ref{CO_SUM}, @ref{CO_REDUCE}, @ref{CO_BROADCAST}
3453 @end table
3457 @node CO_REDUCE
3458 @section @code{CO_REDUCE} --- Reduction of values on the current set of images
3459 @fnindex CO_REDUCE
3460 @cindex Collectives, generic reduction
3462 @table @asis
3463 @item @emph{Description}:
3464 @code{CO_REDUCE} determines element-wise the reduction of the value of @var{A}
3465 on all images of the current team.  The pure function passed as @var{OPERATOR}
3466 is used to pairwise reduce the values of @var{A} by passing either the value
3467 of @var{A} of different images or the result values of such a reduction as
3468 argument.  If @var{A} is an array, the deduction is done element wise. If
3469 @var{RESULT_IMAGE} is present, the result values are returned in @var{A} on
3470 the specified image only and the value of @var{A} on the other images become
3471 undefined.  If @var{RESULT_IMAGE} is not present, the value is returned on all
3472 images.  If the execution was successful and @var{STAT} is present, it is
3473 assigned the value zero.  If the execution failed, @var{STAT} gets assigned
3474 a nonzero value and, if present, @var{ERRMSG} gets assigned a value describing
3475 the occurred error.
3477 @item @emph{Standard}:
3478 Technical Specification (TS) 18508 or later
3480 @item @emph{Class}:
3481 Collective subroutine
3483 @item @emph{Syntax}:
3484 @code{CALL CO_REDUCE(A, OPERATOR, [, RESULT_IMAGE, STAT, ERRMSG])}
3486 @item @emph{Arguments}:
3487 @multitable @columnfractions .15 .70
3488 @item @var{A}            @tab is an @code{INTENT(INOUT)} argument and shall be
3489 nonpolymorphic. If it is allocatable, it shall be allocated; if it is a pointer,
3490 it shall be associated.  @var{A} shall have the same type and type parameters on
3491 all images of the team; if it is an array, it shall have the same shape on all
3492 images.
3493 @item @var{OPERATOR}     @tab pure function with two scalar nonallocatable
3494 arguments, which shall be nonpolymorphic and have the same type and type
3495 parameters as @var{A}.  The function shall return a nonallocatable scalar of
3496 the same type and type parameters as @var{A}.  The function shall be the same on
3497 all images and with regards to the arguments mathematically commutative and
3498 associative.  Note that @var{OPERATOR} may not be an elemental function, unless
3499 it is an intrisic function.
3500 @item @var{RESULT_IMAGE} @tab (optional) a scalar integer expression; if
3501 present, it shall have the same the same value on all images and refer to an
3502 image of the current team.
3503 @item @var{STAT}         @tab (optional) a scalar integer variable
3504 @item @var{ERRMSG}       @tab (optional) a scalar character variable
3505 @end multitable
3507 @item @emph{Example}:
3508 @smallexample
3509 program test
3510   integer :: val
3511   val = this_image ()
3512   call co_reduce (val, result_image=1, operator=myprod)
3513   if (this_image() == 1) then
3514     write(*,*) "Product value", val  ! prints num_images() factorial
3515   end if
3516 contains
3517   pure function myprod(a, b)
3518     integer, value :: a, b
3519     integer :: myprod
3520     myprod = a * b
3521   end function myprod
3522 end program test
3523 @end smallexample
3525 @item @emph{Note}:
3526 While the rules permit in principle an intrinsic function, none of the
3527 intrinsics in the standard fulfill the criteria of having a specific
3528 function, which takes two arguments of the same type and returning that
3529 type as result.
3531 @item @emph{See also}:
3532 @ref{CO_MIN}, @ref{CO_MAX}, @ref{CO_SUM}, @ref{CO_BROADCAST}
3533 @end table
3537 @node CO_SUM
3538 @section @code{CO_SUM} --- Sum of values on the current set of images
3539 @fnindex CO_SUM
3540 @cindex Collectives, sum of values
3542 @table @asis
3543 @item @emph{Description}:
3544 @code{CO_SUM} sums up the values of each element of @var{A} on all
3545 images of the current team.  If @var{RESULT_IMAGE} is present, the summed-up
3546 values are returned in @var{A} on the specified image only and the value
3547 of @var{A} on the other images become undefined.  If @var{RESULT_IMAGE} is
3548 not present, the value is returned on all images.  If the execution was
3549 successful and @var{STAT} is present, it is assigned the value zero.  If the
3550 execution failed, @var{STAT} gets assigned a nonzero value and, if present,
3551 @var{ERRMSG} gets assigned a value describing the occurred error.
3553 @item @emph{Standard}:
3554 Technical Specification (TS) 18508 or later
3556 @item @emph{Class}:
3557 Collective subroutine
3559 @item @emph{Syntax}:
3560 @code{CALL CO_MIN(A [, RESULT_IMAGE, STAT, ERRMSG])}
3562 @item @emph{Arguments}:
3563 @multitable @columnfractions .15 .70
3564 @item @var{A}            @tab shall be an integer, real or complex variable,
3565 which has the same type and type parameters on all images of the team.
3566 @item @var{RESULT_IMAGE} @tab (optional) a scalar integer expression; if
3567 present, it shall have the same the same value on all images and refer to an
3568 image of the current team.
3569 @item @var{STAT}         @tab (optional) a scalar integer variable
3570 @item @var{ERRMSG}       @tab (optional) a scalar character variable
3571 @end multitable
3573 @item @emph{Example}:
3574 @smallexample
3575 program test
3576   integer :: val
3577   val = this_image ()
3578   call co_sum (val, result_image=1)
3579   if (this_image() == 1) then
3580     write(*,*) "The sum is ", val ! prints (n**2 + n)/2, with n = num_images()
3581   end if
3582 end program test
3583 @end smallexample
3585 @item @emph{See also}:
3586 @ref{CO_MAX}, @ref{CO_MIN}, @ref{CO_REDUCE}, @ref{CO_BROADCAST}
3587 @end table
3591 @node COMMAND_ARGUMENT_COUNT
3592 @section @code{COMMAND_ARGUMENT_COUNT} --- Get number of command line arguments
3593 @fnindex COMMAND_ARGUMENT_COUNT
3594 @cindex command-line arguments
3595 @cindex command-line arguments, number of
3596 @cindex arguments, to program
3598 @table @asis
3599 @item @emph{Description}:
3600 @code{COMMAND_ARGUMENT_COUNT} returns the number of arguments passed on the
3601 command line when the containing program was invoked.
3603 @item @emph{Standard}:
3604 Fortran 2003 and later
3606 @item @emph{Class}:
3607 Inquiry function
3609 @item @emph{Syntax}:
3610 @code{RESULT = COMMAND_ARGUMENT_COUNT()}
3612 @item @emph{Arguments}:
3613 @multitable @columnfractions .15 .70
3614 @item None
3615 @end multitable
3617 @item @emph{Return value}:
3618 The return value is an @code{INTEGER} of default kind.
3620 @item @emph{Example}:
3621 @smallexample
3622 program test_command_argument_count
3623     integer :: count
3624     count = command_argument_count()
3625     print *, count
3626 end program test_command_argument_count
3627 @end smallexample
3629 @item @emph{See also}:
3630 @ref{GET_COMMAND}, @ref{GET_COMMAND_ARGUMENT}
3631 @end table
3635 @node COMPILER_OPTIONS
3636 @section @code{COMPILER_OPTIONS} --- Options passed to the compiler
3637 @fnindex COMPILER_OPTIONS
3638 @cindex flags inquiry function
3639 @cindex options inquiry function
3640 @cindex compiler flags inquiry function
3642 @table @asis
3643 @item @emph{Description}:
3644 @code{COMPILER_OPTIONS} returns a string with the options used for
3645 compiling.
3647 @item @emph{Standard}:
3648 Fortran 2008
3650 @item @emph{Class}:
3651 Inquiry function of the module @code{ISO_FORTRAN_ENV}
3653 @item @emph{Syntax}:
3654 @code{STR = COMPILER_OPTIONS()}
3656 @item @emph{Arguments}:
3657 None.
3659 @item @emph{Return value}:
3660 The return value is a default-kind string with system-dependent length.
3661 It contains the compiler flags used to compile the file, which called
3662 the @code{COMPILER_OPTIONS} intrinsic.
3664 @item @emph{Example}:
3665 @smallexample
3666    use iso_fortran_env
3667    print '(4a)', 'This file was compiled by ', &
3668                  compiler_version(), ' using the options ', &
3669                  compiler_options()
3670    end
3671 @end smallexample
3673 @item @emph{See also}:
3674 @ref{COMPILER_VERSION}, @ref{ISO_FORTRAN_ENV}
3675 @end table
3679 @node COMPILER_VERSION
3680 @section @code{COMPILER_VERSION} --- Compiler version string
3681 @fnindex COMPILER_VERSION
3682 @cindex compiler, name and version
3683 @cindex version of the compiler
3685 @table @asis
3686 @item @emph{Description}:
3687 @code{COMPILER_VERSION} returns a string with the name and the
3688 version of the compiler.
3690 @item @emph{Standard}:
3691 Fortran 2008
3693 @item @emph{Class}:
3694 Inquiry function of the module @code{ISO_FORTRAN_ENV}
3696 @item @emph{Syntax}:
3697 @code{STR = COMPILER_VERSION()}
3699 @item @emph{Arguments}:
3700 None.
3702 @item @emph{Return value}:
3703 The return value is a default-kind string with system-dependent length.
3704 It contains the name of the compiler and its version number.
3706 @item @emph{Example}:
3707 @smallexample
3708    use iso_fortran_env
3709    print '(4a)', 'This file was compiled by ', &
3710                  compiler_version(), ' using the options ', &
3711                  compiler_options()
3712    end
3713 @end smallexample
3715 @item @emph{See also}:
3716 @ref{COMPILER_OPTIONS}, @ref{ISO_FORTRAN_ENV}
3717 @end table
3721 @node COMPLEX
3722 @section @code{COMPLEX} --- Complex conversion function
3723 @fnindex COMPLEX
3724 @cindex complex numbers, conversion to
3725 @cindex conversion, to complex
3727 @table @asis
3728 @item @emph{Description}:
3729 @code{COMPLEX(X, Y)} returns a complex number where @var{X} is converted
3730 to the real component and @var{Y} is converted to the imaginary
3731 component.
3733 @item @emph{Standard}:
3734 GNU extension
3736 @item @emph{Class}:
3737 Elemental function
3739 @item @emph{Syntax}:
3740 @code{RESULT = COMPLEX(X, Y)}
3742 @item @emph{Arguments}:
3743 @multitable @columnfractions .15 .70
3744 @item @var{X} @tab The type may be @code{INTEGER} or @code{REAL}.
3745 @item @var{Y} @tab The type may be @code{INTEGER} or @code{REAL}.
3746 @end multitable
3748 @item @emph{Return value}:
3749 If @var{X} and @var{Y} are both of @code{INTEGER} type, then the return
3750 value is of default @code{COMPLEX} type.
3752 If @var{X} and @var{Y} are of @code{REAL} type, or one is of @code{REAL}
3753 type and one is of @code{INTEGER} type, then the return value is of
3754 @code{COMPLEX} type with a kind equal to that of the @code{REAL}
3755 argument with the highest precision.
3757 @item @emph{Example}:
3758 @smallexample
3759 program test_complex
3760     integer :: i = 42
3761     real :: x = 3.14
3762     print *, complex(i, x)
3763 end program test_complex
3764 @end smallexample
3766 @item @emph{See also}:
3767 @ref{CMPLX}
3768 @end table
3772 @node CONJG
3773 @section @code{CONJG} --- Complex conjugate function
3774 @fnindex CONJG
3775 @fnindex DCONJG
3776 @cindex complex conjugate
3778 @table @asis
3779 @item @emph{Description}:
3780 @code{CONJG(Z)} returns the conjugate of @var{Z}.  If @var{Z} is @code{(x, y)}
3781 then the result is @code{(x, -y)}
3783 @item @emph{Standard}:
3784 Fortran 77 and later, has overloads that are GNU extensions
3786 @item @emph{Class}:
3787 Elemental function
3789 @item @emph{Syntax}:
3790 @code{Z = CONJG(Z)}
3792 @item @emph{Arguments}:
3793 @multitable @columnfractions .15 .70
3794 @item @var{Z} @tab The type shall be @code{COMPLEX}.
3795 @end multitable
3797 @item @emph{Return value}:
3798 The return value is of type @code{COMPLEX}.
3800 @item @emph{Example}:
3801 @smallexample
3802 program test_conjg
3803     complex :: z = (2.0, 3.0)
3804     complex(8) :: dz = (2.71_8, -3.14_8)
3805     z= conjg(z)
3806     print *, z
3807     dz = dconjg(dz)
3808     print *, dz
3809 end program test_conjg
3810 @end smallexample
3812 @item @emph{Specific names}:
3813 @multitable @columnfractions .20 .20 .20 .25
3814 @item Name             @tab Argument             @tab Return type       @tab Standard
3815 @item @code{CONJG(Z)}  @tab @code{COMPLEX Z}     @tab @code{COMPLEX}    @tab GNU extension
3816 @item @code{DCONJG(Z)} @tab @code{COMPLEX(8) Z}  @tab @code{COMPLEX(8)} @tab GNU extension
3817 @end multitable
3818 @end table
3822 @node COS
3823 @section @code{COS} --- Cosine function
3824 @fnindex COS
3825 @fnindex DCOS
3826 @fnindex CCOS
3827 @fnindex ZCOS
3828 @fnindex CDCOS
3829 @cindex trigonometric function, cosine
3830 @cindex cosine
3832 @table @asis
3833 @item @emph{Description}:
3834 @code{COS(X)} computes the cosine of @var{X}.
3836 @item @emph{Standard}:
3837 Fortran 77 and later, has overloads that are GNU extensions
3839 @item @emph{Class}:
3840 Elemental function
3842 @item @emph{Syntax}:
3843 @code{RESULT = COS(X)}
3845 @item @emph{Arguments}:
3846 @multitable @columnfractions .15 .70
3847 @item @var{X} @tab The type shall be @code{REAL} or
3848 @code{COMPLEX}.
3849 @end multitable
3851 @item @emph{Return value}:
3852 The return value is of the same type and kind as @var{X}. The real part
3853 of the result is in radians. If @var{X} is of the type @code{REAL},
3854 the return value lies in the range @math{ -1 \leq \cos (x) \leq 1}.
3856 @item @emph{Example}:
3857 @smallexample
3858 program test_cos
3859   real :: x = 0.0
3860   x = cos(x)
3861 end program test_cos
3862 @end smallexample
3864 @item @emph{Specific names}:
3865 @multitable @columnfractions .20 .20 .20 .25
3866 @item Name            @tab Argument            @tab Return type       @tab Standard
3867 @item @code{COS(X)}   @tab @code{REAL(4) X}    @tab @code{REAL(4)}    @tab Fortran 77 and later
3868 @item @code{DCOS(X)}  @tab @code{REAL(8) X}    @tab @code{REAL(8)}    @tab Fortran 77 and later
3869 @item @code{CCOS(X)}  @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab Fortran 77 and later
3870 @item @code{ZCOS(X)}  @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
3871 @item @code{CDCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
3872 @end multitable
3874 @item @emph{See also}:
3875 Inverse function: @ref{ACOS}
3877 @end table
3881 @node COSH
3882 @section @code{COSH} --- Hyperbolic cosine function
3883 @fnindex COSH
3884 @fnindex DCOSH
3885 @cindex hyperbolic cosine
3886 @cindex hyperbolic function, cosine
3887 @cindex cosine, hyperbolic
3889 @table @asis
3890 @item @emph{Description}:
3891 @code{COSH(X)} computes the hyperbolic cosine of @var{X}.
3893 @item @emph{Standard}:
3894 Fortran 77 and later, for a complex argument Fortran 2008 or later
3896 @item @emph{Class}:
3897 Elemental function
3899 @item @emph{Syntax}:
3900 @code{X = COSH(X)}
3902 @item @emph{Arguments}:
3903 @multitable @columnfractions .15 .70
3904 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
3905 @end multitable
3907 @item @emph{Return value}:
3908 The return value has same type and kind as @var{X}. If @var{X} is
3909 complex, the imaginary part of the result is in radians. If @var{X}
3910 is @code{REAL}, the return value has a lower bound of one,
3911 @math{\cosh (x) \geq 1}.
3913 @item @emph{Example}:
3914 @smallexample
3915 program test_cosh
3916   real(8) :: x = 1.0_8
3917   x = cosh(x)
3918 end program test_cosh
3919 @end smallexample
3921 @item @emph{Specific names}:
3922 @multitable @columnfractions .20 .20 .20 .25
3923 @item Name            @tab Argument          @tab Return type       @tab Standard
3924 @item @code{COSH(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab Fortran 77 and later
3925 @item @code{DCOSH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab Fortran 77 and later
3926 @end multitable
3928 @item @emph{See also}:
3929 Inverse function: @ref{ACOSH}
3931 @end table
3935 @node COUNT
3936 @section @code{COUNT} --- Count function
3937 @fnindex COUNT
3938 @cindex array, conditionally count elements
3939 @cindex array, element counting
3940 @cindex array, number of elements
3942 @table @asis
3943 @item @emph{Description}:
3945 Counts the number of @code{.TRUE.} elements in a logical @var{MASK},
3946 or, if the @var{DIM} argument is supplied, counts the number of
3947 elements along each row of the array in the @var{DIM} direction.
3948 If the array has zero size, or all of the elements of @var{MASK} are
3949 @code{.FALSE.}, then the result is @code{0}.
3951 @item @emph{Standard}:
3952 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
3954 @item @emph{Class}:
3955 Transformational function
3957 @item @emph{Syntax}:
3958 @code{RESULT = COUNT(MASK [, DIM, KIND])}
3960 @item @emph{Arguments}:
3961 @multitable @columnfractions .15 .70
3962 @item @var{MASK} @tab The type shall be @code{LOGICAL}.
3963 @item @var{DIM}  @tab (Optional) The type shall be @code{INTEGER}.
3964 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
3965 expression indicating the kind parameter of the result.
3966 @end multitable
3968 @item @emph{Return value}:
3969 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
3970 @var{KIND} is absent, the return value is of default integer kind.
3971 If @var{DIM} is present, the result is an array with a rank one less
3972 than the rank of @var{ARRAY}, and a size corresponding to the shape
3973 of @var{ARRAY} with the @var{DIM} dimension removed.
3975 @item @emph{Example}:
3976 @smallexample
3977 program test_count
3978     integer, dimension(2,3) :: a, b
3979     logical, dimension(2,3) :: mask
3980     a = reshape( (/ 1, 2, 3, 4, 5, 6 /), (/ 2, 3 /))
3981     b = reshape( (/ 0, 7, 3, 4, 5, 8 /), (/ 2, 3 /))
3982     print '(3i3)', a(1,:)
3983     print '(3i3)', a(2,:)
3984     print *
3985     print '(3i3)', b(1,:)
3986     print '(3i3)', b(2,:)
3987     print *
3988     mask = a.ne.b
3989     print '(3l3)', mask(1,:)
3990     print '(3l3)', mask(2,:)
3991     print *
3992     print '(3i3)', count(mask)
3993     print *
3994     print '(3i3)', count(mask, 1)
3995     print *
3996     print '(3i3)', count(mask, 2)
3997 end program test_count
3998 @end smallexample
3999 @end table
4003 @node CPU_TIME
4004 @section @code{CPU_TIME} --- CPU elapsed time in seconds
4005 @fnindex CPU_TIME
4006 @cindex time, elapsed
4008 @table @asis
4009 @item @emph{Description}:
4010 Returns a @code{REAL} value representing the elapsed CPU time in
4011 seconds.  This is useful for testing segments of code to determine
4012 execution time.
4014 If a time source is available, time will be reported with microsecond
4015 resolution. If no time source is available, @var{TIME} is set to
4016 @code{-1.0}.
4018 Note that @var{TIME} may contain a, system dependent, arbitrary offset
4019 and may not start with @code{0.0}. For @code{CPU_TIME}, the absolute
4020 value is meaningless, only differences between subsequent calls to
4021 this subroutine, as shown in the example below, should be used.
4024 @item @emph{Standard}:
4025 Fortran 95 and later
4027 @item @emph{Class}:
4028 Subroutine
4030 @item @emph{Syntax}:
4031 @code{CALL CPU_TIME(TIME)}
4033 @item @emph{Arguments}:
4034 @multitable @columnfractions .15 .70
4035 @item @var{TIME} @tab The type shall be @code{REAL} with @code{INTENT(OUT)}.
4036 @end multitable
4038 @item @emph{Return value}:
4039 None
4041 @item @emph{Example}:
4042 @smallexample
4043 program test_cpu_time
4044     real :: start, finish
4045     call cpu_time(start)
4046         ! put code to test here
4047     call cpu_time(finish)
4048     print '("Time = ",f6.3," seconds.")',finish-start
4049 end program test_cpu_time
4050 @end smallexample
4052 @item @emph{See also}:
4053 @ref{SYSTEM_CLOCK}, @ref{DATE_AND_TIME}
4054 @end table
4058 @node CSHIFT
4059 @section @code{CSHIFT} --- Circular shift elements of an array
4060 @fnindex CSHIFT
4061 @cindex array, shift circularly
4062 @cindex array, permutation
4063 @cindex array, rotate
4065 @table @asis
4066 @item @emph{Description}:
4067 @code{CSHIFT(ARRAY, SHIFT [, DIM])} performs a circular shift on elements of
4068 @var{ARRAY} along the dimension of @var{DIM}.  If @var{DIM} is omitted it is
4069 taken to be @code{1}.  @var{DIM} is a scalar of type @code{INTEGER} in the
4070 range of @math{1 \leq DIM \leq n)} where @math{n} is the rank of @var{ARRAY}.
4071 If the rank of @var{ARRAY} is one, then all elements of @var{ARRAY} are shifted
4072 by @var{SHIFT} places.  If rank is greater than one, then all complete rank one
4073 sections of @var{ARRAY} along the given dimension are shifted.  Elements
4074 shifted out one end of each rank one section are shifted back in the other end.
4076 @item @emph{Standard}:
4077 Fortran 95 and later
4079 @item @emph{Class}:
4080 Transformational function
4082 @item @emph{Syntax}:
4083 @code{RESULT = CSHIFT(ARRAY, SHIFT [, DIM])}
4085 @item @emph{Arguments}:
4086 @multitable @columnfractions .15 .70
4087 @item @var{ARRAY}  @tab Shall be an array of any type.
4088 @item @var{SHIFT}  @tab The type shall be @code{INTEGER}.
4089 @item @var{DIM}    @tab The type shall be @code{INTEGER}.
4090 @end multitable
4092 @item @emph{Return value}:
4093 Returns an array of same type and rank as the @var{ARRAY} argument.
4095 @item @emph{Example}:
4096 @smallexample
4097 program test_cshift
4098     integer, dimension(3,3) :: a
4099     a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
4100     print '(3i3)', a(1,:)
4101     print '(3i3)', a(2,:)
4102     print '(3i3)', a(3,:)    
4103     a = cshift(a, SHIFT=(/1, 2, -1/), DIM=2)
4104     print *
4105     print '(3i3)', a(1,:)
4106     print '(3i3)', a(2,:)
4107     print '(3i3)', a(3,:)
4108 end program test_cshift
4109 @end smallexample
4110 @end table
4114 @node CTIME
4115 @section @code{CTIME} --- Convert a time into a string
4116 @fnindex CTIME
4117 @cindex time, conversion to string
4118 @cindex conversion, to string
4120 @table @asis
4121 @item @emph{Description}:
4122 @code{CTIME} converts a system time value, such as returned by
4123 @code{TIME8}, to a string. The output will be of the form @samp{Sat
4124 Aug 19 18:13:14 1995}.
4126 This intrinsic is provided in both subroutine and function forms; however,
4127 only one form can be used in any given program unit.
4129 @item @emph{Standard}:
4130 GNU extension
4132 @item @emph{Class}:
4133 Subroutine, function
4135 @item @emph{Syntax}:
4136 @multitable @columnfractions .80
4137 @item @code{CALL CTIME(TIME, RESULT)}.
4138 @item @code{RESULT = CTIME(TIME)}.
4139 @end multitable
4141 @item @emph{Arguments}:
4142 @multitable @columnfractions .15 .70
4143 @item @var{TIME}    @tab The type shall be of type @code{INTEGER}.
4144 @item @var{RESULT}  @tab The type shall be of type @code{CHARACTER} and
4145 of default kind. It is an @code{INTENT(OUT)} argument. If the length
4146 of this variable is too short for the time and date string to fit
4147 completely, it will be blank on procedure return.
4148 @end multitable
4150 @item @emph{Return value}:
4151 The converted date and time as a string. 
4153 @item @emph{Example}:
4154 @smallexample
4155 program test_ctime
4156     integer(8) :: i
4157     character(len=30) :: date
4158     i = time8()
4160     ! Do something, main part of the program
4161     
4162     call ctime(i,date)
4163     print *, 'Program was started on ', date
4164 end program test_ctime
4165 @end smallexample
4167 @item @emph{See Also}:
4168 @ref{DATE_AND_TIME}, @ref{GMTIME}, @ref{LTIME}, @ref{TIME}, @ref{TIME8}
4169 @end table
4173 @node DATE_AND_TIME
4174 @section @code{DATE_AND_TIME} --- Date and time subroutine
4175 @fnindex DATE_AND_TIME
4176 @cindex date, current
4177 @cindex current date
4178 @cindex time, current
4179 @cindex current time
4181 @table @asis
4182 @item @emph{Description}:
4183 @code{DATE_AND_TIME(DATE, TIME, ZONE, VALUES)} gets the corresponding date and
4184 time information from the real-time system clock.  @var{DATE} is
4185 @code{INTENT(OUT)} and has form ccyymmdd.  @var{TIME} is @code{INTENT(OUT)} and
4186 has form hhmmss.sss.  @var{ZONE} is @code{INTENT(OUT)} and has form (+-)hhmm,
4187 representing the difference with respect to Coordinated Universal Time (UTC).
4188 Unavailable time and date parameters return blanks.
4190 @var{VALUES} is @code{INTENT(OUT)} and provides the following:
4192 @multitable @columnfractions .15 .30 .40
4193 @item @tab @code{VALUE(1)}: @tab The year
4194 @item @tab @code{VALUE(2)}: @tab The month
4195 @item @tab @code{VALUE(3)}: @tab The day of the month
4196 @item @tab @code{VALUE(4)}: @tab Time difference with UTC in minutes
4197 @item @tab @code{VALUE(5)}: @tab The hour of the day
4198 @item @tab @code{VALUE(6)}: @tab The minutes of the hour
4199 @item @tab @code{VALUE(7)}: @tab The seconds of the minute
4200 @item @tab @code{VALUE(8)}: @tab The milliseconds of the second
4201 @end multitable
4203 @item @emph{Standard}:
4204 Fortran 95 and later
4206 @item @emph{Class}:
4207 Subroutine
4209 @item @emph{Syntax}:
4210 @code{CALL DATE_AND_TIME([DATE, TIME, ZONE, VALUES])}
4212 @item @emph{Arguments}:
4213 @multitable @columnfractions .15 .70
4214 @item @var{DATE}  @tab (Optional) The type shall be @code{CHARACTER(LEN=8)}
4215 or larger, and of default kind.
4216 @item @var{TIME}  @tab (Optional) The type shall be @code{CHARACTER(LEN=10)}
4217 or larger, and of default kind.
4218 @item @var{ZONE}  @tab (Optional) The type shall be @code{CHARACTER(LEN=5)}
4219 or larger, and of default kind.
4220 @item @var{VALUES}@tab (Optional) The type shall be @code{INTEGER(8)}.
4221 @end multitable
4223 @item @emph{Return value}:
4224 None
4226 @item @emph{Example}:
4227 @smallexample
4228 program test_time_and_date
4229     character(8)  :: date
4230     character(10) :: time
4231     character(5)  :: zone
4232     integer,dimension(8) :: values
4233     ! using keyword arguments
4234     call date_and_time(date,time,zone,values)
4235     call date_and_time(DATE=date,ZONE=zone)
4236     call date_and_time(TIME=time)
4237     call date_and_time(VALUES=values)
4238     print '(a,2x,a,2x,a)', date, time, zone
4239     print '(8i5)', values
4240 end program test_time_and_date
4241 @end smallexample
4243 @item @emph{See also}:
4244 @ref{CPU_TIME}, @ref{SYSTEM_CLOCK}
4245 @end table
4249 @node DBLE
4250 @section @code{DBLE} --- Double conversion function
4251 @fnindex DBLE
4252 @cindex conversion, to real
4254 @table @asis
4255 @item @emph{Description}:
4256 @code{DBLE(A)} Converts @var{A} to double precision real type.
4258 @item @emph{Standard}:
4259 Fortran 77 and later
4261 @item @emph{Class}:
4262 Elemental function
4264 @item @emph{Syntax}:
4265 @code{RESULT = DBLE(A)}
4267 @item @emph{Arguments}:
4268 @multitable @columnfractions .15 .70
4269 @item @var{A} @tab The type shall be @code{INTEGER}, @code{REAL},
4270 or @code{COMPLEX}.
4271 @end multitable
4273 @item @emph{Return value}:
4274 The return value is of type double precision real.
4276 @item @emph{Example}:
4277 @smallexample
4278 program test_dble
4279     real    :: x = 2.18
4280     integer :: i = 5
4281     complex :: z = (2.3,1.14)
4282     print *, dble(x), dble(i), dble(z)
4283 end program test_dble
4284 @end smallexample
4286 @item @emph{See also}:
4287 @ref{REAL}
4288 @end table
4292 @node DCMPLX
4293 @section @code{DCMPLX} --- Double complex conversion function
4294 @fnindex DCMPLX
4295 @cindex complex numbers, conversion to
4296 @cindex conversion, to complex
4298 @table @asis
4299 @item @emph{Description}:
4300 @code{DCMPLX(X [,Y])} returns a double complex number where @var{X} is
4301 converted to the real component.  If @var{Y} is present it is converted to the
4302 imaginary component.  If @var{Y} is not present then the imaginary component is
4303 set to 0.0.  If @var{X} is complex then @var{Y} must not be present.
4305 @item @emph{Standard}:
4306 GNU extension
4308 @item @emph{Class}:
4309 Elemental function
4311 @item @emph{Syntax}:
4312 @code{RESULT = DCMPLX(X [, Y])}
4314 @item @emph{Arguments}:
4315 @multitable @columnfractions .15 .70
4316 @item @var{X} @tab The type may be @code{INTEGER}, @code{REAL},
4317 or @code{COMPLEX}.
4318 @item @var{Y} @tab (Optional if @var{X} is not @code{COMPLEX}.) May be
4319 @code{INTEGER} or @code{REAL}. 
4320 @end multitable
4322 @item @emph{Return value}:
4323 The return value is of type @code{COMPLEX(8)}
4325 @item @emph{Example}:
4326 @smallexample
4327 program test_dcmplx
4328     integer :: i = 42
4329     real :: x = 3.14
4330     complex :: z
4331     z = cmplx(i, x)
4332     print *, dcmplx(i)
4333     print *, dcmplx(x)
4334     print *, dcmplx(z)
4335     print *, dcmplx(x,i)
4336 end program test_dcmplx
4337 @end smallexample
4338 @end table
4341 @node DIGITS
4342 @section @code{DIGITS} --- Significant binary digits function
4343 @fnindex DIGITS
4344 @cindex model representation, significant digits
4346 @table @asis
4347 @item @emph{Description}:
4348 @code{DIGITS(X)} returns the number of significant binary digits of the internal
4349 model representation of @var{X}.  For example, on a system using a 32-bit
4350 floating point representation, a default real number would likely return 24.
4352 @item @emph{Standard}:
4353 Fortran 95 and later
4355 @item @emph{Class}:
4356 Inquiry function
4358 @item @emph{Syntax}:
4359 @code{RESULT = DIGITS(X)}
4361 @item @emph{Arguments}:
4362 @multitable @columnfractions .15 .70
4363 @item @var{X} @tab The type may be @code{INTEGER} or @code{REAL}.
4364 @end multitable
4366 @item @emph{Return value}:
4367 The return value is of type @code{INTEGER}.
4369 @item @emph{Example}:
4370 @smallexample
4371 program test_digits
4372     integer :: i = 12345
4373     real :: x = 3.143
4374     real(8) :: y = 2.33
4375     print *, digits(i)
4376     print *, digits(x)
4377     print *, digits(y)
4378 end program test_digits
4379 @end smallexample
4380 @end table
4384 @node DIM
4385 @section @code{DIM} --- Positive difference
4386 @fnindex DIM
4387 @fnindex IDIM
4388 @fnindex DDIM
4389 @cindex positive difference
4391 @table @asis
4392 @item @emph{Description}:
4393 @code{DIM(X,Y)} returns the difference @code{X-Y} if the result is positive;
4394 otherwise returns zero.
4396 @item @emph{Standard}:
4397 Fortran 77 and later
4399 @item @emph{Class}:
4400 Elemental function
4402 @item @emph{Syntax}:
4403 @code{RESULT = DIM(X, Y)}
4405 @item @emph{Arguments}:
4406 @multitable @columnfractions .15 .70
4407 @item @var{X} @tab The type shall be @code{INTEGER} or @code{REAL}
4408 @item @var{Y} @tab The type shall be the same type and kind as @var{X}.
4409 @end multitable
4411 @item @emph{Return value}:
4412 The return value is of type @code{INTEGER} or @code{REAL}.
4414 @item @emph{Example}:
4415 @smallexample
4416 program test_dim
4417     integer :: i
4418     real(8) :: x
4419     i = dim(4, 15)
4420     x = dim(4.345_8, 2.111_8)
4421     print *, i
4422     print *, x
4423 end program test_dim
4424 @end smallexample
4426 @item @emph{Specific names}:
4427 @multitable @columnfractions .20 .20 .20 .25
4428 @item Name             @tab Argument               @tab Return type       @tab Standard
4429 @item @code{DIM(X,Y)}  @tab @code{REAL(4) X, Y}    @tab @code{REAL(4)}    @tab Fortran 77 and later
4430 @item @code{IDIM(X,Y)} @tab @code{INTEGER(4) X, Y} @tab @code{INTEGER(4)} @tab Fortran 77 and later
4431 @item @code{DDIM(X,Y)} @tab @code{REAL(8) X, Y}    @tab @code{REAL(8)}    @tab Fortran 77 and later
4432 @end multitable
4433 @end table
4437 @node DOT_PRODUCT
4438 @section @code{DOT_PRODUCT} --- Dot product function
4439 @fnindex DOT_PRODUCT
4440 @cindex dot product
4441 @cindex vector product
4442 @cindex product, vector
4444 @table @asis
4445 @item @emph{Description}:
4446 @code{DOT_PRODUCT(VECTOR_A, VECTOR_B)} computes the dot product multiplication
4447 of two vectors @var{VECTOR_A} and @var{VECTOR_B}.  The two vectors may be
4448 either numeric or logical and must be arrays of rank one and of equal size. If
4449 the vectors are @code{INTEGER} or @code{REAL}, the result is
4450 @code{SUM(VECTOR_A*VECTOR_B)}. If the vectors are @code{COMPLEX}, the result
4451 is @code{SUM(CONJG(VECTOR_A)*VECTOR_B)}. If the vectors are @code{LOGICAL},
4452 the result is @code{ANY(VECTOR_A .AND. VECTOR_B)}.  
4454 @item @emph{Standard}:
4455 Fortran 95 and later
4457 @item @emph{Class}:
4458 Transformational function
4460 @item @emph{Syntax}:
4461 @code{RESULT = DOT_PRODUCT(VECTOR_A, VECTOR_B)}
4463 @item @emph{Arguments}:
4464 @multitable @columnfractions .15 .70
4465 @item @var{VECTOR_A} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
4466 @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.
4467 @end multitable
4469 @item @emph{Return value}:
4470 If the arguments are numeric, the return value is a scalar of numeric type,
4471 @code{INTEGER}, @code{REAL}, or @code{COMPLEX}.  If the arguments are
4472 @code{LOGICAL}, the return value is @code{.TRUE.} or @code{.FALSE.}.
4474 @item @emph{Example}:
4475 @smallexample
4476 program test_dot_prod
4477     integer, dimension(3) :: a, b
4478     a = (/ 1, 2, 3 /)
4479     b = (/ 4, 5, 6 /)
4480     print '(3i3)', a
4481     print *
4482     print '(3i3)', b
4483     print *
4484     print *, dot_product(a,b)
4485 end program test_dot_prod
4486 @end smallexample
4487 @end table
4491 @node DPROD
4492 @section @code{DPROD} --- Double product function
4493 @fnindex DPROD
4494 @cindex product, double-precision
4496 @table @asis
4497 @item @emph{Description}:
4498 @code{DPROD(X,Y)} returns the product @code{X*Y}.
4500 @item @emph{Standard}:
4501 Fortran 77 and later
4503 @item @emph{Class}:
4504 Elemental function
4506 @item @emph{Syntax}:
4507 @code{RESULT = DPROD(X, Y)}
4509 @item @emph{Arguments}:
4510 @multitable @columnfractions .15 .70
4511 @item @var{X} @tab The type shall be @code{REAL}.
4512 @item @var{Y} @tab The type shall be @code{REAL}.
4513 @end multitable
4515 @item @emph{Return value}:
4516 The return value is of type @code{REAL(8)}.
4518 @item @emph{Example}:
4519 @smallexample
4520 program test_dprod
4521     real :: x = 5.2
4522     real :: y = 2.3
4523     real(8) :: d
4524     d = dprod(x,y)
4525     print *, d
4526 end program test_dprod
4527 @end smallexample
4529 @item @emph{Specific names}:
4530 @multitable @columnfractions .20 .20 .20 .25
4531 @item Name              @tab Argument               @tab Return type       @tab Standard
4532 @item @code{DPROD(X,Y)} @tab @code{REAL(4) X, Y}    @tab @code{REAL(8)}    @tab Fortran 77 and later
4533 @end multitable
4535 @end table
4538 @node DREAL
4539 @section @code{DREAL} --- Double real part function
4540 @fnindex DREAL
4541 @cindex complex numbers, real part
4543 @table @asis
4544 @item @emph{Description}:
4545 @code{DREAL(Z)} returns the real part of complex variable @var{Z}.
4547 @item @emph{Standard}:
4548 GNU extension
4550 @item @emph{Class}:
4551 Elemental function
4553 @item @emph{Syntax}:
4554 @code{RESULT = DREAL(A)}
4556 @item @emph{Arguments}:
4557 @multitable @columnfractions .15 .70
4558 @item @var{A} @tab The type shall be @code{COMPLEX(8)}.
4559 @end multitable
4561 @item @emph{Return value}:
4562 The return value is of type @code{REAL(8)}.
4564 @item @emph{Example}:
4565 @smallexample
4566 program test_dreal
4567     complex(8) :: z = (1.3_8,7.2_8)
4568     print *, dreal(z)
4569 end program test_dreal
4570 @end smallexample
4572 @item @emph{See also}:
4573 @ref{AIMAG}
4575 @end table
4579 @node DSHIFTL
4580 @section @code{DSHIFTL} --- Combined left shift
4581 @fnindex DSHIFTL
4582 @cindex left shift, combined
4583 @cindex shift, left
4585 @table @asis
4586 @item @emph{Description}:
4587 @code{DSHIFTL(I, J, SHIFT)} combines bits of @var{I} and @var{J}. The
4588 rightmost @var{SHIFT} bits of the result are the leftmost @var{SHIFT}
4589 bits of @var{J}, and the remaining bits are the rightmost bits of
4590 @var{I}.
4592 @item @emph{Standard}:
4593 Fortran 2008 and later
4595 @item @emph{Class}:
4596 Elemental function
4598 @item @emph{Syntax}:
4599 @code{RESULT = DSHIFTL(I, J, SHIFT)}
4601 @item @emph{Arguments}:
4602 @multitable @columnfractions .15 .70
4603 @item @var{I} @tab Shall be of type @code{INTEGER} or a BOZ constant.
4604 @item @var{J} @tab Shall be of type @code{INTEGER} or a BOZ constant.
4605 If both @var{I} and @var{J} have integer type, then they shall have
4606 the same kind type parameter. @var{I} and @var{J} shall not both be
4607 BOZ constants.
4608 @item @var{SHIFT} @tab Shall be of type @code{INTEGER}. It shall
4609 be nonnegative.  If @var{I} is not a BOZ constant, then @var{SHIFT}
4610 shall be less than or equal to @code{BIT_SIZE(I)}; otherwise,
4611 @var{SHIFT} shall be less than or equal to @code{BIT_SIZE(J)}.
4612 @end multitable
4614 @item @emph{Return value}:
4615 If either @var{I} or @var{J} is a BOZ constant, it is first converted
4616 as if by the intrinsic function @code{INT} to an integer type with the
4617 kind type parameter of the other.
4619 @item @emph{See also}:
4620 @ref{DSHIFTR}
4621 @end table
4624 @node DSHIFTR
4625 @section @code{DSHIFTR} --- Combined right shift
4626 @fnindex DSHIFTR
4627 @cindex right shift, combined
4628 @cindex shift, right
4630 @table @asis
4631 @item @emph{Description}:
4632 @code{DSHIFTR(I, J, SHIFT)} combines bits of @var{I} and @var{J}. The
4633 leftmost @var{SHIFT} bits of the result are the rightmost @var{SHIFT}
4634 bits of @var{I}, and the remaining bits are the leftmost bits of
4635 @var{J}.
4637 @item @emph{Standard}:
4638 Fortran 2008 and later
4640 @item @emph{Class}:
4641 Elemental function
4643 @item @emph{Syntax}:
4644 @code{RESULT = DSHIFTR(I, J, SHIFT)}
4646 @item @emph{Arguments}:
4647 @multitable @columnfractions .15 .70
4648 @item @var{I} @tab Shall be of type @code{INTEGER} or a BOZ constant.
4649 @item @var{J} @tab Shall be of type @code{INTEGER} or a BOZ constant.
4650 If both @var{I} and @var{J} have integer type, then they shall have
4651 the same kind type parameter. @var{I} and @var{J} shall not both be
4652 BOZ constants.
4653 @item @var{SHIFT} @tab Shall be of type @code{INTEGER}. It shall
4654 be nonnegative.  If @var{I} is not a BOZ constant, then @var{SHIFT}
4655 shall be less than or equal to @code{BIT_SIZE(I)}; otherwise,
4656 @var{SHIFT} shall be less than or equal to @code{BIT_SIZE(J)}.
4657 @end multitable
4659 @item @emph{Return value}:
4660 If either @var{I} or @var{J} is a BOZ constant, it is first converted
4661 as if by the intrinsic function @code{INT} to an integer type with the
4662 kind type parameter of the other.
4664 @item @emph{See also}:
4665 @ref{DSHIFTL}
4666 @end table
4669 @node DTIME
4670 @section @code{DTIME} --- Execution time subroutine (or function)
4671 @fnindex DTIME
4672 @cindex time, elapsed
4673 @cindex elapsed time
4675 @table @asis
4676 @item @emph{Description}:
4677 @code{DTIME(VALUES, TIME)} initially returns the number of seconds of runtime
4678 since the start of the process's execution in @var{TIME}.  @var{VALUES}
4679 returns the user and system components of this time in @code{VALUES(1)} and
4680 @code{VALUES(2)} respectively. @var{TIME} is equal to @code{VALUES(1) +
4681 VALUES(2)}.
4683 Subsequent invocations of @code{DTIME} return values accumulated since the
4684 previous invocation.
4686 On some systems, the underlying timings are represented using types with
4687 sufficiently small limits that overflows (wrap around) are possible, such as
4688 32-bit types. Therefore, the values returned by this intrinsic might be, or
4689 become, negative, or numerically less than previous values, during a single
4690 run of the compiled program.
4692 Please note, that this implementation is thread safe if used within OpenMP
4693 directives, i.e., its state will be consistent while called from multiple
4694 threads. However, if @code{DTIME} is called from multiple threads, the result
4695 is still the time since the last invocation. This may not give the intended
4696 results. If possible, use @code{CPU_TIME} instead.
4698 This intrinsic is provided in both subroutine and function forms; however,
4699 only one form can be used in any given program unit.
4701 @var{VALUES} and @var{TIME} are @code{INTENT(OUT)} and provide the following:
4703 @multitable @columnfractions .15 .30 .40
4704 @item @tab @code{VALUES(1)}: @tab User time in seconds.
4705 @item @tab @code{VALUES(2)}: @tab System time in seconds.
4706 @item @tab @code{TIME}: @tab Run time since start in seconds.
4707 @end multitable
4709 @item @emph{Standard}:
4710 GNU extension
4712 @item @emph{Class}:
4713 Subroutine, function
4715 @item @emph{Syntax}:
4716 @multitable @columnfractions .80
4717 @item @code{CALL DTIME(VALUES, TIME)}.
4718 @item @code{TIME = DTIME(VALUES)}, (not recommended).
4719 @end multitable
4721 @item @emph{Arguments}:
4722 @multitable @columnfractions .15 .70
4723 @item @var{VALUES}@tab The type shall be @code{REAL(4), DIMENSION(2)}.
4724 @item @var{TIME}@tab The type shall be @code{REAL(4)}.
4725 @end multitable
4727 @item @emph{Return value}:
4728 Elapsed time in seconds since the last invocation or since the start of program
4729 execution if not called before.
4731 @item @emph{Example}:
4732 @smallexample
4733 program test_dtime
4734     integer(8) :: i, j
4735     real, dimension(2) :: tarray
4736     real :: result
4737     call dtime(tarray, result)
4738     print *, result
4739     print *, tarray(1)
4740     print *, tarray(2)   
4741     do i=1,100000000    ! Just a delay
4742         j = i * i - i
4743     end do
4744     call dtime(tarray, result)
4745     print *, result
4746     print *, tarray(1)
4747     print *, tarray(2)
4748 end program test_dtime
4749 @end smallexample
4751 @item @emph{See also}:
4752 @ref{CPU_TIME}
4754 @end table
4758 @node EOSHIFT
4759 @section @code{EOSHIFT} --- End-off shift elements of an array
4760 @fnindex EOSHIFT
4761 @cindex array, shift
4763 @table @asis
4764 @item @emph{Description}:
4765 @code{EOSHIFT(ARRAY, SHIFT[, BOUNDARY, DIM])} performs an end-off shift on
4766 elements of @var{ARRAY} along the dimension of @var{DIM}.  If @var{DIM} is
4767 omitted it is taken to be @code{1}.  @var{DIM} is a scalar of type
4768 @code{INTEGER} in the range of @math{1 \leq DIM \leq n)} where @math{n} is the
4769 rank of @var{ARRAY}.  If the rank of @var{ARRAY} is one, then all elements of
4770 @var{ARRAY} are shifted by @var{SHIFT} places.  If rank is greater than one,
4771 then all complete rank one sections of @var{ARRAY} along the given dimension are
4772 shifted.  Elements shifted out one end of each rank one section are dropped.  If
4773 @var{BOUNDARY} is present then the corresponding value of from @var{BOUNDARY}
4774 is copied back in the other end.  If @var{BOUNDARY} is not present then the
4775 following are copied in depending on the type of @var{ARRAY}.
4777 @multitable @columnfractions .15 .80
4778 @item @emph{Array Type} @tab @emph{Boundary Value}
4779 @item Numeric  @tab 0 of the type and kind of @var{ARRAY}.
4780 @item Logical  @tab @code{.FALSE.}.
4781 @item Character(@var{len}) @tab @var{len} blanks.
4782 @end multitable
4784 @item @emph{Standard}:
4785 Fortran 95 and later
4787 @item @emph{Class}:
4788 Transformational function
4790 @item @emph{Syntax}:
4791 @code{RESULT = EOSHIFT(ARRAY, SHIFT [, BOUNDARY, DIM])}
4793 @item @emph{Arguments}:
4794 @multitable @columnfractions .15 .70
4795 @item @var{ARRAY}  @tab May be any type, not scalar.
4796 @item @var{SHIFT}  @tab The type shall be @code{INTEGER}.
4797 @item @var{BOUNDARY} @tab Same type as @var{ARRAY}. 
4798 @item @var{DIM}    @tab The type shall be @code{INTEGER}.
4799 @end multitable
4801 @item @emph{Return value}:
4802 Returns an array of same type and rank as the @var{ARRAY} argument.
4804 @item @emph{Example}:
4805 @smallexample
4806 program test_eoshift
4807     integer, dimension(3,3) :: a
4808     a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
4809     print '(3i3)', a(1,:)
4810     print '(3i3)', a(2,:)
4811     print '(3i3)', a(3,:)    
4812     a = EOSHIFT(a, SHIFT=(/1, 2, 1/), BOUNDARY=-5, DIM=2)
4813     print *
4814     print '(3i3)', a(1,:)
4815     print '(3i3)', a(2,:)
4816     print '(3i3)', a(3,:)
4817 end program test_eoshift
4818 @end smallexample
4819 @end table
4823 @node EPSILON
4824 @section @code{EPSILON} --- Epsilon function
4825 @fnindex EPSILON
4826 @cindex model representation, epsilon
4828 @table @asis
4829 @item @emph{Description}:
4830 @code{EPSILON(X)} returns the smallest number @var{E} of the same kind
4831 as @var{X} such that @math{1 + E > 1}.
4833 @item @emph{Standard}:
4834 Fortran 95 and later
4836 @item @emph{Class}:
4837 Inquiry function
4839 @item @emph{Syntax}:
4840 @code{RESULT = EPSILON(X)}
4842 @item @emph{Arguments}:
4843 @multitable @columnfractions .15 .70
4844 @item @var{X} @tab The type shall be @code{REAL}.
4845 @end multitable
4847 @item @emph{Return value}:
4848 The return value is of same type as the argument.
4850 @item @emph{Example}:
4851 @smallexample
4852 program test_epsilon
4853     real :: x = 3.143
4854     real(8) :: y = 2.33
4855     print *, EPSILON(x)
4856     print *, EPSILON(y)
4857 end program test_epsilon
4858 @end smallexample
4859 @end table
4863 @node ERF
4864 @section @code{ERF} --- Error function 
4865 @fnindex ERF
4866 @cindex error function
4868 @table @asis
4869 @item @emph{Description}:
4870 @code{ERF(X)} computes the error function of @var{X}.
4872 @item @emph{Standard}:
4873 Fortran 2008 and later
4875 @item @emph{Class}:
4876 Elemental function
4878 @item @emph{Syntax}:
4879 @code{RESULT = ERF(X)}
4881 @item @emph{Arguments}:
4882 @multitable @columnfractions .15 .70
4883 @item @var{X} @tab The type shall be @code{REAL}.
4884 @end multitable
4886 @item @emph{Return value}:
4887 The return value is of type @code{REAL}, of the same kind as
4888 @var{X} and lies in the range @math{-1 \leq erf (x) \leq 1 }.
4890 @item @emph{Example}:
4891 @smallexample
4892 program test_erf
4893   real(8) :: x = 0.17_8
4894   x = erf(x)
4895 end program test_erf
4896 @end smallexample
4898 @item @emph{Specific names}:
4899 @multitable @columnfractions .20 .20 .20 .25
4900 @item Name            @tab Argument          @tab Return type       @tab Standard
4901 @item @code{DERF(X)}  @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
4902 @end multitable
4903 @end table
4907 @node ERFC
4908 @section @code{ERFC} --- Error function 
4909 @fnindex ERFC
4910 @cindex error function, complementary
4912 @table @asis
4913 @item @emph{Description}:
4914 @code{ERFC(X)} computes the complementary error function of @var{X}.
4916 @item @emph{Standard}:
4917 Fortran 2008 and later
4919 @item @emph{Class}:
4920 Elemental function
4922 @item @emph{Syntax}:
4923 @code{RESULT = ERFC(X)}
4925 @item @emph{Arguments}:
4926 @multitable @columnfractions .15 .70
4927 @item @var{X} @tab The type shall be @code{REAL}.
4928 @end multitable
4930 @item @emph{Return value}:
4931 The return value is of type @code{REAL} and of the same kind as @var{X}.
4932 It lies in the range @math{ 0 \leq erfc (x) \leq 2 }.
4934 @item @emph{Example}:
4935 @smallexample
4936 program test_erfc
4937   real(8) :: x = 0.17_8
4938   x = erfc(x)
4939 end program test_erfc
4940 @end smallexample
4942 @item @emph{Specific names}:
4943 @multitable @columnfractions .20 .20 .20 .25
4944 @item Name            @tab Argument          @tab Return type       @tab Standard
4945 @item @code{DERFC(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab GNU extension
4946 @end multitable
4947 @end table
4951 @node ERFC_SCALED
4952 @section @code{ERFC_SCALED} --- Error function 
4953 @fnindex ERFC_SCALED
4954 @cindex error function, complementary, exponentially-scaled
4956 @table @asis
4957 @item @emph{Description}:
4958 @code{ERFC_SCALED(X)} computes the exponentially-scaled complementary
4959 error function of @var{X}.
4961 @item @emph{Standard}:
4962 Fortran 2008 and later
4964 @item @emph{Class}:
4965 Elemental function
4967 @item @emph{Syntax}:
4968 @code{RESULT = ERFC_SCALED(X)}
4970 @item @emph{Arguments}:
4971 @multitable @columnfractions .15 .70
4972 @item @var{X} @tab The type shall be @code{REAL}.
4973 @end multitable
4975 @item @emph{Return value}:
4976 The return value is of type @code{REAL} and of the same kind as @var{X}.
4978 @item @emph{Example}:
4979 @smallexample
4980 program test_erfc_scaled
4981   real(8) :: x = 0.17_8
4982   x = erfc_scaled(x)
4983 end program test_erfc_scaled
4984 @end smallexample
4985 @end table
4989 @node ETIME
4990 @section @code{ETIME} --- Execution time subroutine (or function)
4991 @fnindex ETIME
4992 @cindex time, elapsed
4994 @table @asis
4995 @item @emph{Description}:
4996 @code{ETIME(VALUES, TIME)} returns the number of seconds of runtime
4997 since the start of the process's execution in @var{TIME}.  @var{VALUES}
4998 returns the user and system components of this time in @code{VALUES(1)} and
4999 @code{VALUES(2)} respectively. @var{TIME} is equal to @code{VALUES(1) + VALUES(2)}.
5001 On some systems, the underlying timings are represented using types with
5002 sufficiently small limits that overflows (wrap around) are possible, such as
5003 32-bit types. Therefore, the values returned by this intrinsic might be, or
5004 become, negative, or numerically less than previous values, during a single
5005 run of the compiled program.
5007 This intrinsic is provided in both subroutine and function forms; however,
5008 only one form can be used in any given program unit.
5010 @var{VALUES} and @var{TIME} are @code{INTENT(OUT)} and provide the following:
5012 @multitable @columnfractions .15 .30 .60
5013 @item @tab @code{VALUES(1)}: @tab User time in seconds.
5014 @item @tab @code{VALUES(2)}: @tab System time in seconds.
5015 @item @tab @code{TIME}: @tab Run time since start in seconds.
5016 @end multitable
5018 @item @emph{Standard}:
5019 GNU extension
5021 @item @emph{Class}:
5022 Subroutine, function
5024 @item @emph{Syntax}:
5025 @multitable @columnfractions .80
5026 @item @code{CALL ETIME(VALUES, TIME)}.
5027 @item @code{TIME = ETIME(VALUES)}, (not recommended).
5028 @end multitable
5030 @item @emph{Arguments}:
5031 @multitable @columnfractions .15 .70
5032 @item @var{VALUES}@tab The type shall be @code{REAL(4), DIMENSION(2)}.
5033 @item @var{TIME}@tab The type shall be @code{REAL(4)}.
5034 @end multitable
5036 @item @emph{Return value}:
5037 Elapsed time in seconds since the start of program execution.
5039 @item @emph{Example}:
5040 @smallexample
5041 program test_etime
5042     integer(8) :: i, j
5043     real, dimension(2) :: tarray
5044     real :: result
5045     call ETIME(tarray, result)
5046     print *, result
5047     print *, tarray(1)
5048     print *, tarray(2)   
5049     do i=1,100000000    ! Just a delay
5050         j = i * i - i
5051     end do
5052     call ETIME(tarray, result)
5053     print *, result
5054     print *, tarray(1)
5055     print *, tarray(2)
5056 end program test_etime
5057 @end smallexample
5059 @item @emph{See also}:
5060 @ref{CPU_TIME}
5062 @end table
5066 @node EXECUTE_COMMAND_LINE
5067 @section @code{EXECUTE_COMMAND_LINE} --- Execute a shell command
5068 @fnindex EXECUTE_COMMAND_LINE
5069 @cindex system, system call
5070 @cindex command line
5072 @table @asis
5073 @item @emph{Description}:
5074 @code{EXECUTE_COMMAND_LINE} runs a shell command, synchronously or
5075 asynchronously.
5077 The @code{COMMAND} argument is passed to the shell and executed, using
5078 the C library's @code{system} call.  (The shell is @code{sh} on Unix
5079 systems, and @code{cmd.exe} on Windows.)  If @code{WAIT} is present
5080 and has the value false, the execution of the command is asynchronous
5081 if the system supports it; otherwise, the command is executed
5082 synchronously.
5084 The three last arguments allow the user to get status information.  After
5085 synchronous execution, @code{EXITSTAT} contains the integer exit code of
5086 the command, as returned by @code{system}.  @code{CMDSTAT} is set to zero
5087 if the command line was executed (whatever its exit status was).
5088 @code{CMDMSG} is assigned an error message if an error has occurred.
5090 Note that the @code{system} function need not be thread-safe. It is
5091 the responsibility of the user to ensure that @code{system} is not
5092 called concurrently.
5094 @item @emph{Standard}:
5095 Fortran 2008 and later
5097 @item @emph{Class}:
5098 Subroutine
5100 @item @emph{Syntax}:
5101 @code{CALL EXECUTE_COMMAND_LINE(COMMAND [, WAIT, EXITSTAT, CMDSTAT, CMDMSG ])}
5103 @item @emph{Arguments}:
5104 @multitable @columnfractions .15 .70
5105 @item @var{COMMAND} @tab Shall be a default @code{CHARACTER} scalar.
5106 @item @var{WAIT} @tab (Optional) Shall be a default @code{LOGICAL} scalar.
5107 @item @var{EXITSTAT} @tab (Optional) Shall be an @code{INTEGER} of the
5108 default kind.
5109 @item @var{CMDSTAT} @tab (Optional) Shall be an @code{INTEGER} of the
5110 default kind.
5111 @item @var{CMDMSG} @tab (Optional) Shall be an @code{CHARACTER} scalar of the
5112 default kind.
5113 @end multitable
5115 @item @emph{Example}:
5116 @smallexample
5117 program test_exec
5118   integer :: i
5120   call execute_command_line ("external_prog.exe", exitstat=i)
5121   print *, "Exit status of external_prog.exe was ", i
5123   call execute_command_line ("reindex_files.exe", wait=.false.)
5124   print *, "Now reindexing files in the background"
5126 end program test_exec
5127 @end smallexample
5130 @item @emph{Note}:
5132 Because this intrinsic is implemented in terms of the @code{system}
5133 function call, its behavior with respect to signaling is processor
5134 dependent. In particular, on POSIX-compliant systems, the SIGINT and
5135 SIGQUIT signals will be ignored, and the SIGCHLD will be blocked. As
5136 such, if the parent process is terminated, the child process might not be
5137 terminated alongside.
5140 @item @emph{See also}:
5141 @ref{SYSTEM}
5142 @end table
5146 @node EXIT
5147 @section @code{EXIT} --- Exit the program with status. 
5148 @fnindex EXIT
5149 @cindex program termination
5150 @cindex terminate program
5152 @table @asis
5153 @item @emph{Description}:
5154 @code{EXIT} causes immediate termination of the program with status.  If status
5155 is omitted it returns the canonical @emph{success} for the system.  All Fortran
5156 I/O units are closed. 
5158 @item @emph{Standard}:
5159 GNU extension
5161 @item @emph{Class}:
5162 Subroutine
5164 @item @emph{Syntax}:
5165 @code{CALL EXIT([STATUS])}
5167 @item @emph{Arguments}:
5168 @multitable @columnfractions .15 .70
5169 @item @var{STATUS} @tab Shall be an @code{INTEGER} of the default kind.
5170 @end multitable
5172 @item @emph{Return value}:
5173 @code{STATUS} is passed to the parent process on exit.
5175 @item @emph{Example}:
5176 @smallexample
5177 program test_exit
5178   integer :: STATUS = 0
5179   print *, 'This program is going to exit.'
5180   call EXIT(STATUS)
5181 end program test_exit
5182 @end smallexample
5184 @item @emph{See also}:
5185 @ref{ABORT}, @ref{KILL}
5186 @end table
5190 @node EXP
5191 @section @code{EXP} --- Exponential function 
5192 @fnindex EXP
5193 @fnindex DEXP
5194 @fnindex CEXP
5195 @fnindex ZEXP
5196 @fnindex CDEXP
5197 @cindex exponential function
5198 @cindex logarithm function, inverse
5200 @table @asis
5201 @item @emph{Description}:
5202 @code{EXP(X)} computes the base @math{e} exponential of @var{X}.
5204 @item @emph{Standard}:
5205 Fortran 77 and later, has overloads that are GNU extensions
5207 @item @emph{Class}:
5208 Elemental function
5210 @item @emph{Syntax}:
5211 @code{RESULT = EXP(X)}
5213 @item @emph{Arguments}:
5214 @multitable @columnfractions .15 .70
5215 @item @var{X} @tab The type shall be @code{REAL} or
5216 @code{COMPLEX}.
5217 @end multitable
5219 @item @emph{Return value}:
5220 The return value has same type and kind as @var{X}.
5222 @item @emph{Example}:
5223 @smallexample
5224 program test_exp
5225   real :: x = 1.0
5226   x = exp(x)
5227 end program test_exp
5228 @end smallexample
5230 @item @emph{Specific names}:
5231 @multitable @columnfractions .20 .20 .20 .25
5232 @item Name            @tab Argument             @tab Return type         @tab Standard
5233 @item @code{EXP(X)}   @tab @code{REAL(4) X}     @tab @code{REAL(4)}      @tab Fortran 77 and later
5234 @item @code{DEXP(X)}  @tab @code{REAL(8) X}     @tab @code{REAL(8)}      @tab Fortran 77 and later
5235 @item @code{CEXP(X)}  @tab @code{COMPLEX(4) X}  @tab @code{COMPLEX(4)}   @tab Fortran 77 and later
5236 @item @code{ZEXP(X)}  @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}   @tab GNU extension
5237 @item @code{CDEXP(X)} @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}   @tab GNU extension
5238 @end multitable
5239 @end table
5243 @node EXPONENT
5244 @section @code{EXPONENT} --- Exponent function 
5245 @fnindex EXPONENT
5246 @cindex real number, exponent
5247 @cindex floating point, exponent
5249 @table @asis
5250 @item @emph{Description}:
5251 @code{EXPONENT(X)} returns the value of the exponent part of @var{X}. If @var{X}
5252 is zero the value returned is zero. 
5254 @item @emph{Standard}:
5255 Fortran 95 and later
5257 @item @emph{Class}:
5258 Elemental function
5260 @item @emph{Syntax}:
5261 @code{RESULT = EXPONENT(X)}
5263 @item @emph{Arguments}:
5264 @multitable @columnfractions .15 .70
5265 @item @var{X} @tab The type shall be @code{REAL}.
5266 @end multitable
5268 @item @emph{Return value}:
5269 The return value is of type default @code{INTEGER}.
5271 @item @emph{Example}:
5272 @smallexample
5273 program test_exponent
5274   real :: x = 1.0
5275   integer :: i
5276   i = exponent(x)
5277   print *, i
5278   print *, exponent(0.0)
5279 end program test_exponent
5280 @end smallexample
5281 @end table
5285 @node EXTENDS_TYPE_OF
5286 @section @code{EXTENDS_TYPE_OF} ---  Query dynamic type for extension
5287 @fnindex EXTENDS_TYPE_OF
5289 @table @asis
5290 @item @emph{Description}:
5291 Query dynamic type for extension.
5293 @item @emph{Standard}:
5294 Fortran 2003 and later
5296 @item @emph{Class}:
5297 Inquiry function
5299 @item @emph{Syntax}:
5300 @code{RESULT = EXTENDS_TYPE_OF(A, MOLD)}
5302 @item @emph{Arguments}:
5303 @multitable @columnfractions .15 .70
5304 @item @var{A} @tab Shall be an object of extensible declared type or
5305 unlimited polymorphic. 
5306 @item @var{MOLD} @tab Shall be an object of extensible declared type or
5307 unlimited polymorphic. 
5308 @end multitable
5310 @item @emph{Return value}:
5311 The return value is a scalar of type default logical. It is true if and only if
5312 the dynamic type of A is an extension type of the dynamic type of MOLD.
5315 @item @emph{See also}:
5316 @ref{SAME_TYPE_AS}
5317 @end table
5321 @node FDATE
5322 @section @code{FDATE} --- Get the current time as a string
5323 @fnindex FDATE
5324 @cindex time, current
5325 @cindex current time
5326 @cindex date, current
5327 @cindex current date
5329 @table @asis
5330 @item @emph{Description}:
5331 @code{FDATE(DATE)} returns the current date (using the same format as
5332 @code{CTIME}) in @var{DATE}. It is equivalent to @code{CALL CTIME(DATE,
5333 TIME())}.
5335 This intrinsic is provided in both subroutine and function forms; however,
5336 only one form can be used in any given program unit.
5338 @item @emph{Standard}:
5339 GNU extension
5341 @item @emph{Class}:
5342 Subroutine, function
5344 @item @emph{Syntax}:
5345 @multitable @columnfractions .80
5346 @item @code{CALL FDATE(DATE)}.
5347 @item @code{DATE = FDATE()}.
5348 @end multitable
5350 @item @emph{Arguments}:
5351 @multitable @columnfractions .15 .70
5352 @item @var{DATE}@tab The type shall be of type @code{CHARACTER} of the
5353 default kind. It is an @code{INTENT(OUT)} argument.  If the length of
5354 this variable is too short for the date and time string to fit
5355 completely, it will be blank on procedure return.
5356 @end multitable
5358 @item @emph{Return value}:
5359 The current date and time as a string.
5361 @item @emph{Example}:
5362 @smallexample
5363 program test_fdate
5364     integer(8) :: i, j
5365     character(len=30) :: date
5366     call fdate(date)
5367     print *, 'Program started on ', date
5368     do i = 1, 100000000 ! Just a delay
5369         j = i * i - i
5370     end do
5371     call fdate(date)
5372     print *, 'Program ended on ', date
5373 end program test_fdate
5374 @end smallexample
5376 @item @emph{See also}:
5377 @ref{DATE_AND_TIME}, @ref{CTIME}
5378 @end table
5381 @node FGET
5382 @section @code{FGET} --- Read a single character in stream mode from stdin 
5383 @fnindex FGET
5384 @cindex read character, stream mode
5385 @cindex stream mode, read character
5386 @cindex file operation, read character
5388 @table @asis
5389 @item @emph{Description}:
5390 Read a single character in stream mode from stdin by bypassing normal 
5391 formatted output. Stream I/O should not be mixed with normal record-oriented 
5392 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
5394 This intrinsic is provided in both subroutine and function forms; however,
5395 only one form can be used in any given program unit.
5397 Note that the @code{FGET} intrinsic is provided for backwards compatibility with 
5398 @command{g77}.  GNU Fortran provides the Fortran 2003 Stream facility.
5399 Programmers should consider the use of new stream IO feature in new code 
5400 for future portability. See also @ref{Fortran 2003 status}.
5402 @item @emph{Standard}:
5403 GNU extension
5405 @item @emph{Class}:
5406 Subroutine, function
5408 @item @emph{Syntax}:
5409 @multitable @columnfractions .80
5410 @item @code{CALL FGET(C [, STATUS])}
5411 @item @code{STATUS = FGET(C)}
5412 @end multitable
5414 @item @emph{Arguments}:
5415 @multitable @columnfractions .15 .70
5416 @item @var{C}      @tab The type shall be @code{CHARACTER} and of default
5417 kind.
5418 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
5419 Returns 0 on success, -1 on end-of-file, and a system specific positive
5420 error code otherwise.
5421 @end multitable
5423 @item @emph{Example}:
5424 @smallexample
5425 PROGRAM test_fget
5426   INTEGER, PARAMETER :: strlen = 100
5427   INTEGER :: status, i = 1
5428   CHARACTER(len=strlen) :: str = ""
5430   WRITE (*,*) 'Enter text:'
5431   DO
5432     CALL fget(str(i:i), status)
5433     if (status /= 0 .OR. i > strlen) exit
5434     i = i + 1
5435   END DO
5436   WRITE (*,*) TRIM(str)
5437 END PROGRAM
5438 @end smallexample
5440 @item @emph{See also}:
5441 @ref{FGETC}, @ref{FPUT}, @ref{FPUTC}
5442 @end table
5446 @node FGETC
5447 @section @code{FGETC} --- Read a single character in stream mode
5448 @fnindex FGETC
5449 @cindex read character, stream mode
5450 @cindex stream mode, read character
5451 @cindex file operation, read character
5453 @table @asis
5454 @item @emph{Description}:
5455 Read a single character in stream mode by bypassing normal formatted output. 
5456 Stream I/O should not be mixed with normal record-oriented (formatted or 
5457 unformatted) I/O on the same unit; the results are unpredictable.
5459 This intrinsic is provided in both subroutine and function forms; however,
5460 only one form can be used in any given program unit.
5462 Note that the @code{FGET} intrinsic is provided for backwards compatibility
5463 with @command{g77}.  GNU Fortran provides the Fortran 2003 Stream facility.
5464 Programmers should consider the use of new stream IO feature in new code 
5465 for future portability. See also @ref{Fortran 2003 status}.
5467 @item @emph{Standard}:
5468 GNU extension
5470 @item @emph{Class}:
5471 Subroutine, function
5473 @item @emph{Syntax}:
5474 @multitable @columnfractions .80
5475 @item @code{CALL FGETC(UNIT, C [, STATUS])}
5476 @item @code{STATUS = FGETC(UNIT, C)}
5477 @end multitable
5479 @item @emph{Arguments}:
5480 @multitable @columnfractions .15 .70
5481 @item @var{UNIT}   @tab The type shall be @code{INTEGER}.
5482 @item @var{C}      @tab The type shall be @code{CHARACTER} and of default
5483 kind.
5484 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
5485 Returns 0 on success, -1 on end-of-file and a system specific positive
5486 error code otherwise.
5487 @end multitable
5489 @item @emph{Example}:
5490 @smallexample
5491 PROGRAM test_fgetc
5492   INTEGER :: fd = 42, status
5493   CHARACTER :: c
5495   OPEN(UNIT=fd, FILE="/etc/passwd", ACTION="READ", STATUS = "OLD")
5496   DO
5497     CALL fgetc(fd, c, status)
5498     IF (status /= 0) EXIT
5499     call fput(c)
5500   END DO
5501   CLOSE(UNIT=fd)
5502 END PROGRAM
5503 @end smallexample
5505 @item @emph{See also}:
5506 @ref{FGET}, @ref{FPUT}, @ref{FPUTC}
5507 @end table
5511 @node FLOOR
5512 @section @code{FLOOR} --- Integer floor function
5513 @fnindex FLOOR
5514 @cindex floor
5515 @cindex rounding, floor
5517 @table @asis
5518 @item @emph{Description}:
5519 @code{FLOOR(A)} returns the greatest integer less than or equal to @var{X}.
5521 @item @emph{Standard}:
5522 Fortran 95 and later
5524 @item @emph{Class}:
5525 Elemental function
5527 @item @emph{Syntax}:
5528 @code{RESULT = FLOOR(A [, KIND])}
5530 @item @emph{Arguments}:
5531 @multitable @columnfractions .15 .70
5532 @item @var{A} @tab The type shall be @code{REAL}.
5533 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
5534 expression indicating the kind parameter of the result.
5535 @end multitable
5537 @item @emph{Return value}:
5538 The return value is of type @code{INTEGER(KIND)} if @var{KIND} is present
5539 and of default-kind @code{INTEGER} otherwise.
5541 @item @emph{Example}:
5542 @smallexample
5543 program test_floor
5544     real :: x = 63.29
5545     real :: y = -63.59
5546     print *, floor(x) ! returns 63
5547     print *, floor(y) ! returns -64
5548 end program test_floor
5549 @end smallexample
5551 @item @emph{See also}:
5552 @ref{CEILING}, @ref{NINT}
5554 @end table
5558 @node FLUSH
5559 @section @code{FLUSH} --- Flush I/O unit(s)
5560 @fnindex FLUSH
5561 @cindex file operation, flush
5563 @table @asis
5564 @item @emph{Description}:
5565 Flushes Fortran unit(s) currently open for output. Without the optional
5566 argument, all units are flushed, otherwise just the unit specified.
5568 @item @emph{Standard}:
5569 GNU extension
5571 @item @emph{Class}:
5572 Subroutine
5574 @item @emph{Syntax}:
5575 @code{CALL FLUSH(UNIT)}
5577 @item @emph{Arguments}:
5578 @multitable @columnfractions .15 .70
5579 @item @var{UNIT} @tab (Optional) The type shall be @code{INTEGER}.
5580 @end multitable
5582 @item @emph{Note}:
5583 Beginning with the Fortran 2003 standard, there is a @code{FLUSH}
5584 statement that should be preferred over the @code{FLUSH} intrinsic.
5586 The @code{FLUSH} intrinsic and the Fortran 2003 @code{FLUSH} statement
5587 have identical effect: they flush the runtime library's I/O buffer so
5588 that the data becomes visible to other processes. This does not guarantee
5589 that the data is committed to disk.
5591 On POSIX systems, you can request that all data is transferred  to  the
5592 storage device by calling the @code{fsync} function, with the POSIX file
5593 descriptor of the I/O unit as argument (retrieved with GNU intrinsic
5594 @code{FNUM}). The following example shows how:
5596 @smallexample
5597   ! Declare the interface for POSIX fsync function
5598   interface
5599     function fsync (fd) bind(c,name="fsync")
5600     use iso_c_binding, only: c_int
5601       integer(c_int), value :: fd
5602       integer(c_int) :: fsync
5603     end function fsync
5604   end interface
5606   ! Variable declaration
5607   integer :: ret
5609   ! Opening unit 10
5610   open (10,file="foo")
5612   ! ...
5613   ! Perform I/O on unit 10
5614   ! ...
5616   ! Flush and sync
5617   flush(10)
5618   ret = fsync(fnum(10))
5620   ! Handle possible error
5621   if (ret /= 0) stop "Error calling FSYNC"
5622 @end smallexample
5624 @end table
5628 @node FNUM
5629 @section @code{FNUM} --- File number function
5630 @fnindex FNUM
5631 @cindex file operation, file number
5633 @table @asis
5634 @item @emph{Description}:
5635 @code{FNUM(UNIT)} returns the POSIX file descriptor number corresponding to the
5636 open Fortran I/O unit @code{UNIT}.
5638 @item @emph{Standard}:
5639 GNU extension
5641 @item @emph{Class}:
5642 Function
5644 @item @emph{Syntax}:
5645 @code{RESULT = FNUM(UNIT)}
5647 @item @emph{Arguments}:
5648 @multitable @columnfractions .15 .70
5649 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
5650 @end multitable
5652 @item @emph{Return value}:
5653 The return value is of type @code{INTEGER}
5655 @item @emph{Example}:
5656 @smallexample
5657 program test_fnum
5658   integer :: i
5659   open (unit=10, status = "scratch")
5660   i = fnum(10)
5661   print *, i
5662   close (10)
5663 end program test_fnum
5664 @end smallexample
5665 @end table
5669 @node FPUT
5670 @section @code{FPUT} --- Write a single character in stream mode to stdout 
5671 @fnindex FPUT
5672 @cindex write character, stream mode
5673 @cindex stream mode, write character
5674 @cindex file operation, write character
5676 @table @asis
5677 @item @emph{Description}:
5678 Write a single character in stream mode to stdout by bypassing normal 
5679 formatted output. Stream I/O should not be mixed with normal record-oriented 
5680 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
5682 This intrinsic is provided in both subroutine and function forms; however,
5683 only one form can be used in any given program unit.
5685 Note that the @code{FGET} intrinsic is provided for backwards compatibility with 
5686 @command{g77}.  GNU Fortran provides the Fortran 2003 Stream facility.
5687 Programmers should consider the use of new stream IO feature in new code 
5688 for future portability. See also @ref{Fortran 2003 status}.
5690 @item @emph{Standard}:
5691 GNU extension
5693 @item @emph{Class}:
5694 Subroutine, function
5696 @item @emph{Syntax}:
5697 @multitable @columnfractions .80
5698 @item @code{CALL FPUT(C [, STATUS])}
5699 @item @code{STATUS = FPUT(C)}
5700 @end multitable
5702 @item @emph{Arguments}:
5703 @multitable @columnfractions .15 .70
5704 @item @var{C}      @tab The type shall be @code{CHARACTER} and of default
5705 kind.
5706 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
5707 Returns 0 on success, -1 on end-of-file and a system specific positive
5708 error code otherwise.
5709 @end multitable
5711 @item @emph{Example}:
5712 @smallexample
5713 PROGRAM test_fput
5714   CHARACTER(len=10) :: str = "gfortran"
5715   INTEGER :: i
5716   DO i = 1, len_trim(str)
5717     CALL fput(str(i:i))
5718   END DO
5719 END PROGRAM
5720 @end smallexample
5722 @item @emph{See also}:
5723 @ref{FPUTC}, @ref{FGET}, @ref{FGETC}
5724 @end table
5728 @node FPUTC
5729 @section @code{FPUTC} --- Write a single character in stream mode
5730 @fnindex FPUTC
5731 @cindex write character, stream mode
5732 @cindex stream mode, write character
5733 @cindex file operation, write character
5735 @table @asis
5736 @item @emph{Description}:
5737 Write a single character in stream mode by bypassing normal formatted 
5738 output. Stream I/O should not be mixed with normal record-oriented 
5739 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
5741 This intrinsic is provided in both subroutine and function forms; however,
5742 only one form can be used in any given program unit.
5744 Note that the @code{FGET} intrinsic is provided for backwards compatibility with 
5745 @command{g77}.  GNU Fortran provides the Fortran 2003 Stream facility.
5746 Programmers should consider the use of new stream IO feature in new code 
5747 for future portability. See also @ref{Fortran 2003 status}.
5749 @item @emph{Standard}:
5750 GNU extension
5752 @item @emph{Class}:
5753 Subroutine, function
5755 @item @emph{Syntax}:
5756 @multitable @columnfractions .80
5757 @item @code{CALL FPUTC(UNIT, C [, STATUS])}
5758 @item @code{STATUS = FPUTC(UNIT, C)}
5759 @end multitable
5761 @item @emph{Arguments}:
5762 @multitable @columnfractions .15 .70
5763 @item @var{UNIT}   @tab The type shall be @code{INTEGER}.
5764 @item @var{C}      @tab The type shall be @code{CHARACTER} and of default
5765 kind.
5766 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
5767 Returns 0 on success, -1 on end-of-file and a system specific positive
5768 error code otherwise.
5769 @end multitable
5771 @item @emph{Example}:
5772 @smallexample
5773 PROGRAM test_fputc
5774   CHARACTER(len=10) :: str = "gfortran"
5775   INTEGER :: fd = 42, i
5777   OPEN(UNIT = fd, FILE = "out", ACTION = "WRITE", STATUS="NEW")
5778   DO i = 1, len_trim(str)
5779     CALL fputc(fd, str(i:i))
5780   END DO
5781   CLOSE(fd)
5782 END PROGRAM
5783 @end smallexample
5785 @item @emph{See also}:
5786 @ref{FPUT}, @ref{FGET}, @ref{FGETC}
5787 @end table
5791 @node FRACTION
5792 @section @code{FRACTION} --- Fractional part of the model representation
5793 @fnindex FRACTION
5794 @cindex real number, fraction
5795 @cindex floating point, fraction
5797 @table @asis
5798 @item @emph{Description}:
5799 @code{FRACTION(X)} returns the fractional part of the model
5800 representation of @code{X}.
5802 @item @emph{Standard}:
5803 Fortran 95 and later
5805 @item @emph{Class}:
5806 Elemental function
5808 @item @emph{Syntax}:
5809 @code{Y = FRACTION(X)}
5811 @item @emph{Arguments}:
5812 @multitable @columnfractions .15 .70
5813 @item @var{X} @tab The type of the argument shall be a @code{REAL}.
5814 @end multitable
5816 @item @emph{Return value}:
5817 The return value is of the same type and kind as the argument.
5818 The fractional part of the model representation of @code{X} is returned;
5819 it is @code{X * RADIX(X)**(-EXPONENT(X))}.
5821 @item @emph{Example}:
5822 @smallexample
5823 program test_fraction
5824   real :: x
5825   x = 178.1387e-4
5826   print *, fraction(x), x * radix(x)**(-exponent(x))
5827 end program test_fraction
5828 @end smallexample
5830 @end table
5834 @node FREE
5835 @section @code{FREE} --- Frees memory
5836 @fnindex FREE
5837 @cindex pointer, cray
5839 @table @asis
5840 @item @emph{Description}:
5841 Frees memory previously allocated by @code{MALLOC}. The @code{FREE}
5842 intrinsic is an extension intended to be used with Cray pointers, and is
5843 provided in GNU Fortran to allow user to compile legacy code. For
5844 new code using Fortran 95 pointers, the memory de-allocation intrinsic is
5845 @code{DEALLOCATE}.
5847 @item @emph{Standard}:
5848 GNU extension
5850 @item @emph{Class}:
5851 Subroutine
5853 @item @emph{Syntax}:
5854 @code{CALL FREE(PTR)}
5856 @item @emph{Arguments}:
5857 @multitable @columnfractions .15 .70
5858 @item @var{PTR} @tab The type shall be @code{INTEGER}. It represents the
5859 location of the memory that should be de-allocated.
5860 @end multitable
5862 @item @emph{Return value}:
5863 None
5865 @item @emph{Example}:
5866 See @code{MALLOC} for an example.
5868 @item @emph{See also}:
5869 @ref{MALLOC}
5870 @end table
5874 @node FSEEK
5875 @section @code{FSEEK} --- Low level file positioning subroutine
5876 @fnindex FSEEK
5877 @cindex file operation, seek
5878 @cindex file operation, position
5880 @table @asis
5881 @item @emph{Description}:
5882 Moves @var{UNIT} to the specified @var{OFFSET}. If @var{WHENCE} 
5883 is set to 0, the @var{OFFSET} is taken as an absolute value @code{SEEK_SET},
5884 if set to 1, @var{OFFSET} is taken to be relative to the current position 
5885 @code{SEEK_CUR}, and if set to 2 relative to the end of the file @code{SEEK_END}.
5886 On error, @var{STATUS} is set to a nonzero value. If @var{STATUS} the seek 
5887 fails silently.
5889 This intrinsic routine is not fully backwards compatible with @command{g77}. 
5890 In @command{g77}, the @code{FSEEK} takes a statement label instead of a 
5891 @var{STATUS} variable. If FSEEK is used in old code, change
5892 @smallexample
5893   CALL FSEEK(UNIT, OFFSET, WHENCE, *label)
5894 @end smallexample 
5896 @smallexample
5897   INTEGER :: status
5898   CALL FSEEK(UNIT, OFFSET, WHENCE, status)
5899   IF (status /= 0) GOTO label
5900 @end smallexample 
5902 Please note that GNU Fortran provides the Fortran 2003 Stream facility.
5903 Programmers should consider the use of new stream IO feature in new code 
5904 for future portability. See also @ref{Fortran 2003 status}.
5906 @item @emph{Standard}:
5907 GNU extension
5909 @item @emph{Class}:
5910 Subroutine
5912 @item @emph{Syntax}:
5913 @code{CALL FSEEK(UNIT, OFFSET, WHENCE[, STATUS])}
5915 @item @emph{Arguments}:
5916 @multitable @columnfractions .15 .70
5917 @item @var{UNIT}   @tab Shall be a scalar of type @code{INTEGER}.
5918 @item @var{OFFSET} @tab Shall be a scalar of type @code{INTEGER}.
5919 @item @var{WHENCE} @tab Shall be a scalar of type @code{INTEGER}.
5920 Its value shall be either 0, 1 or 2.
5921 @item @var{STATUS} @tab (Optional) shall be a scalar of type 
5922 @code{INTEGER(4)}.
5923 @end multitable
5925 @item @emph{Example}:
5926 @smallexample
5927 PROGRAM test_fseek
5928   INTEGER, PARAMETER :: SEEK_SET = 0, SEEK_CUR = 1, SEEK_END = 2
5929   INTEGER :: fd, offset, ierr
5931   ierr   = 0
5932   offset = 5
5933   fd     = 10
5935   OPEN(UNIT=fd, FILE="fseek.test")
5936   CALL FSEEK(fd, offset, SEEK_SET, ierr)  ! move to OFFSET
5937   print *, FTELL(fd), ierr
5939   CALL FSEEK(fd, 0, SEEK_END, ierr)       ! move to end
5940   print *, FTELL(fd), ierr
5942   CALL FSEEK(fd, 0, SEEK_SET, ierr)       ! move to beginning
5943   print *, FTELL(fd), ierr
5945   CLOSE(UNIT=fd)
5946 END PROGRAM
5947 @end smallexample
5949 @item @emph{See also}:
5950 @ref{FTELL}
5951 @end table
5955 @node FSTAT
5956 @section @code{FSTAT} --- Get file status
5957 @fnindex FSTAT
5958 @cindex file system, file status
5960 @table @asis
5961 @item @emph{Description}:
5962 @code{FSTAT} is identical to @ref{STAT}, except that information about an 
5963 already opened file is obtained.
5965 The elements in @code{VALUES} are the same as described by @ref{STAT}.
5967 This intrinsic is provided in both subroutine and function forms; however,
5968 only one form can be used in any given program unit.
5970 @item @emph{Standard}:
5971 GNU extension
5973 @item @emph{Class}:
5974 Subroutine, function
5976 @item @emph{Syntax}:
5977 @multitable @columnfractions .80
5978 @item @code{CALL FSTAT(UNIT, VALUES [, STATUS])}
5979 @item @code{STATUS = FSTAT(UNIT, VALUES)}
5980 @end multitable
5982 @item @emph{Arguments}:
5983 @multitable @columnfractions .15 .70
5984 @item @var{UNIT}   @tab An open I/O unit number of type @code{INTEGER}.
5985 @item @var{VALUES} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
5986 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0 
5987 on success and a system specific error code otherwise.
5988 @end multitable
5990 @item @emph{Example}:
5991 See @ref{STAT} for an example.
5993 @item @emph{See also}:
5994 To stat a link: @ref{LSTAT}, to stat a file: @ref{STAT}
5995 @end table
5999 @node FTELL
6000 @section @code{FTELL} --- Current stream position
6001 @fnindex FTELL
6002 @cindex file operation, position
6004 @table @asis
6005 @item @emph{Description}:
6006 Retrieves the current position within an open file.
6008 This intrinsic is provided in both subroutine and function forms; however,
6009 only one form can be used in any given program unit.
6011 @item @emph{Standard}:
6012 GNU extension
6014 @item @emph{Class}:
6015 Subroutine, function
6017 @item @emph{Syntax}:
6018 @multitable @columnfractions .80
6019 @item @code{CALL FTELL(UNIT, OFFSET)}
6020 @item @code{OFFSET = FTELL(UNIT)}
6021 @end multitable
6023 @item @emph{Arguments}:
6024 @multitable @columnfractions .15 .70
6025 @item @var{OFFSET}  @tab Shall of type @code{INTEGER}.
6026 @item @var{UNIT}    @tab Shall of type @code{INTEGER}.
6027 @end multitable
6029 @item @emph{Return value}:
6030 In either syntax, @var{OFFSET} is set to the current offset of unit
6031 number @var{UNIT}, or to @math{-1} if the unit is not currently open.
6033 @item @emph{Example}:
6034 @smallexample
6035 PROGRAM test_ftell
6036   INTEGER :: i
6037   OPEN(10, FILE="temp.dat")
6038   CALL ftell(10,i)
6039   WRITE(*,*) i
6040 END PROGRAM
6041 @end smallexample
6043 @item @emph{See also}:
6044 @ref{FSEEK}
6045 @end table
6049 @node GAMMA
6050 @section @code{GAMMA} --- Gamma function
6051 @fnindex GAMMA
6052 @fnindex DGAMMA
6053 @cindex Gamma function
6054 @cindex Factorial function
6056 @table @asis
6057 @item @emph{Description}:
6058 @code{GAMMA(X)} computes Gamma (@math{\Gamma}) of @var{X}. For positive,
6059 integer values of @var{X} the Gamma function simplifies to the factorial
6060 function @math{\Gamma(x)=(x-1)!}.
6062 @tex
6064 \Gamma(x) = \int_0^\infty t^{x-1}{\rm e}^{-t}\,{\rm d}t
6066 @end tex
6068 @item @emph{Standard}:
6069 Fortran 2008 and later
6071 @item @emph{Class}:
6072 Elemental function
6074 @item @emph{Syntax}:
6075 @code{X = GAMMA(X)}
6077 @item @emph{Arguments}:
6078 @multitable @columnfractions .15 .70
6079 @item @var{X} @tab Shall be of type @code{REAL} and neither zero
6080 nor a negative integer.
6081 @end multitable
6083 @item @emph{Return value}:
6084 The return value is of type @code{REAL} of the same kind as @var{X}.
6086 @item @emph{Example}:
6087 @smallexample
6088 program test_gamma
6089   real :: x = 1.0
6090   x = gamma(x) ! returns 1.0
6091 end program test_gamma
6092 @end smallexample
6094 @item @emph{Specific names}:
6095 @multitable @columnfractions .20 .20 .20 .25
6096 @item Name             @tab Argument         @tab Return type       @tab Standard
6097 @item @code{GAMMA(X)}  @tab @code{REAL(4) X} @tab @code{REAL(4)}    @tab GNU Extension
6098 @item @code{DGAMMA(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)}    @tab GNU Extension
6099 @end multitable
6101 @item @emph{See also}:
6102 Logarithm of the Gamma function: @ref{LOG_GAMMA}
6104 @end table
6108 @node GERROR
6109 @section @code{GERROR} --- Get last system error message
6110 @fnindex GERROR
6111 @cindex system, error handling
6113 @table @asis
6114 @item @emph{Description}:
6115 Returns the system error message corresponding to the last system error.
6116 This resembles the functionality of @code{strerror(3)} in C.
6118 @item @emph{Standard}:
6119 GNU extension
6121 @item @emph{Class}:
6122 Subroutine
6124 @item @emph{Syntax}:
6125 @code{CALL GERROR(RESULT)}
6127 @item @emph{Arguments}:
6128 @multitable @columnfractions .15 .70
6129 @item @var{RESULT}  @tab Shall of type @code{CHARACTER} and of default
6130 @end multitable
6132 @item @emph{Example}:
6133 @smallexample
6134 PROGRAM test_gerror
6135   CHARACTER(len=100) :: msg
6136   CALL gerror(msg)
6137   WRITE(*,*) msg
6138 END PROGRAM
6139 @end smallexample
6141 @item @emph{See also}:
6142 @ref{IERRNO}, @ref{PERROR}
6143 @end table
6147 @node GETARG
6148 @section @code{GETARG} --- Get command line arguments
6149 @fnindex GETARG
6150 @cindex command-line arguments
6151 @cindex arguments, to program
6153 @table @asis
6154 @item @emph{Description}:
6155 Retrieve the @var{POS}-th argument that was passed on the
6156 command line when the containing program was invoked.
6158 This intrinsic routine is provided for backwards compatibility with 
6159 GNU Fortran 77.  In new code, programmers should consider the use of 
6160 the @ref{GET_COMMAND_ARGUMENT} intrinsic defined by the Fortran 2003 
6161 standard.
6163 @item @emph{Standard}:
6164 GNU extension
6166 @item @emph{Class}:
6167 Subroutine
6169 @item @emph{Syntax}:
6170 @code{CALL GETARG(POS, VALUE)}
6172 @item @emph{Arguments}:
6173 @multitable @columnfractions .15 .70
6174 @item @var{POS}   @tab Shall be of type @code{INTEGER} and not wider than
6175 the default integer kind; @math{@var{POS} \geq 0}
6176 @item @var{VALUE} @tab Shall be of type @code{CHARACTER} and of default
6177 kind.
6178 @item @var{VALUE} @tab Shall be of type @code{CHARACTER}. 
6179 @end multitable
6181 @item @emph{Return value}:
6182 After @code{GETARG} returns, the @var{VALUE} argument holds the
6183 @var{POS}th command line argument. If @var{VALUE} can not hold the
6184 argument, it is truncated to fit the length of @var{VALUE}. If there are
6185 less than @var{POS} arguments specified at the command line, @var{VALUE}
6186 will be filled with blanks. If @math{@var{POS} = 0}, @var{VALUE} is set
6187 to the name of the program (on systems that support this feature).
6189 @item @emph{Example}:
6190 @smallexample
6191 PROGRAM test_getarg
6192   INTEGER :: i
6193   CHARACTER(len=32) :: arg
6195   DO i = 1, iargc()
6196     CALL getarg(i, arg)
6197     WRITE (*,*) arg
6198   END DO
6199 END PROGRAM
6200 @end smallexample
6202 @item @emph{See also}:
6203 GNU Fortran 77 compatibility function: @ref{IARGC}
6205 Fortran 2003 functions and subroutines: @ref{GET_COMMAND},
6206 @ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
6207 @end table
6211 @node GET_COMMAND
6212 @section @code{GET_COMMAND} --- Get the entire command line
6213 @fnindex GET_COMMAND
6214 @cindex command-line arguments
6215 @cindex arguments, to program
6217 @table @asis
6218 @item @emph{Description}:
6219 Retrieve the entire command line that was used to invoke the program.
6221 @item @emph{Standard}:
6222 Fortran 2003 and later
6224 @item @emph{Class}:
6225 Subroutine
6227 @item @emph{Syntax}:
6228 @code{CALL GET_COMMAND([COMMAND, LENGTH, STATUS])}
6230 @item @emph{Arguments}:
6231 @multitable @columnfractions .15 .70
6232 @item @var{COMMAND} @tab (Optional) shall be of type @code{CHARACTER} and
6233 of default kind.
6234 @item @var{LENGTH} @tab (Optional) Shall be of type @code{INTEGER} and of
6235 default kind.
6236 @item @var{STATUS} @tab (Optional) Shall be of type @code{INTEGER} and of
6237 default kind.
6238 @end multitable
6240 @item @emph{Return value}:
6241 If @var{COMMAND} is present, stores the entire command line that was used
6242 to invoke the program in @var{COMMAND}. If @var{LENGTH} is present, it is
6243 assigned the length of the command line. If @var{STATUS} is present, it
6244 is assigned 0 upon success of the command, -1 if @var{COMMAND} is too
6245 short to store the command line, or a positive value in case of an error.
6247 @item @emph{Example}:
6248 @smallexample
6249 PROGRAM test_get_command
6250   CHARACTER(len=255) :: cmd
6251   CALL get_command(cmd)
6252   WRITE (*,*) TRIM(cmd)
6253 END PROGRAM
6254 @end smallexample
6256 @item @emph{See also}:
6257 @ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
6258 @end table
6262 @node GET_COMMAND_ARGUMENT
6263 @section @code{GET_COMMAND_ARGUMENT} --- Get command line arguments
6264 @fnindex GET_COMMAND_ARGUMENT
6265 @cindex command-line arguments
6266 @cindex arguments, to program
6268 @table @asis
6269 @item @emph{Description}:
6270 Retrieve the @var{NUMBER}-th argument that was passed on the
6271 command line when the containing program was invoked.
6273 @item @emph{Standard}:
6274 Fortran 2003 and later
6276 @item @emph{Class}:
6277 Subroutine
6279 @item @emph{Syntax}:
6280 @code{CALL GET_COMMAND_ARGUMENT(NUMBER [, VALUE, LENGTH, STATUS])}
6282 @item @emph{Arguments}:
6283 @multitable @columnfractions .15 .70
6284 @item @var{NUMBER} @tab Shall be a scalar of type @code{INTEGER} and of
6285 default kind, @math{@var{NUMBER} \geq 0}
6286 @item @var{VALUE}  @tab (Optional) Shall be a scalar of type @code{CHARACTER}
6287 and of default kind.
6288 @item @var{LENGTH} @tab (Optional) Shall be a scalar of type @code{INTEGER}
6289 and of default kind.
6290 @item @var{STATUS} @tab (Optional) Shall be a scalar of type @code{INTEGER}
6291 and of default kind.
6292 @end multitable
6294 @item @emph{Return value}:
6295 After @code{GET_COMMAND_ARGUMENT} returns, the @var{VALUE} argument holds the 
6296 @var{NUMBER}-th command line argument. If @var{VALUE} can not hold the argument, it is 
6297 truncated to fit the length of @var{VALUE}. If there are less than @var{NUMBER}
6298 arguments specified at the command line, @var{VALUE} will be filled with blanks. 
6299 If @math{@var{NUMBER} = 0}, @var{VALUE} is set to the name of the program (on
6300 systems that support this feature). The @var{LENGTH} argument contains the
6301 length of the @var{NUMBER}-th command line argument. If the argument retrieval
6302 fails, @var{STATUS} is a positive number; if @var{VALUE} contains a truncated
6303 command line argument, @var{STATUS} is -1; and otherwise the @var{STATUS} is
6304 zero.
6306 @item @emph{Example}:
6307 @smallexample
6308 PROGRAM test_get_command_argument
6309   INTEGER :: i
6310   CHARACTER(len=32) :: arg
6312   i = 0
6313   DO
6314     CALL get_command_argument(i, arg)
6315     IF (LEN_TRIM(arg) == 0) EXIT
6317     WRITE (*,*) TRIM(arg)
6318     i = i+1
6319   END DO
6320 END PROGRAM
6321 @end smallexample
6323 @item @emph{See also}:
6324 @ref{GET_COMMAND}, @ref{COMMAND_ARGUMENT_COUNT}
6325 @end table
6329 @node GETCWD
6330 @section @code{GETCWD} --- Get current working directory
6331 @fnindex GETCWD
6332 @cindex system, working directory
6334 @table @asis
6335 @item @emph{Description}:
6336 Get current working directory.
6338 This intrinsic is provided in both subroutine and function forms; however,
6339 only one form can be used in any given program unit.
6341 @item @emph{Standard}:
6342 GNU extension
6344 @item @emph{Class}:
6345 Subroutine, function
6347 @item @emph{Syntax}:
6348 @multitable @columnfractions .80
6349 @item @code{CALL GETCWD(C [, STATUS])}
6350 @item @code{STATUS = GETCWD(C)}
6351 @end multitable
6353 @item @emph{Arguments}:
6354 @multitable @columnfractions .15 .70
6355 @item @var{C} @tab The type shall be @code{CHARACTER} and of default kind.
6356 @item @var{STATUS} @tab (Optional) status flag. Returns 0 on success, 
6357 a system specific and nonzero error code otherwise.
6358 @end multitable
6360 @item @emph{Example}:
6361 @smallexample
6362 PROGRAM test_getcwd
6363   CHARACTER(len=255) :: cwd
6364   CALL getcwd(cwd)
6365   WRITE(*,*) TRIM(cwd)
6366 END PROGRAM
6367 @end smallexample
6369 @item @emph{See also}:
6370 @ref{CHDIR}
6371 @end table
6375 @node GETENV
6376 @section @code{GETENV} --- Get an environmental variable
6377 @fnindex GETENV
6378 @cindex environment variable
6380 @table @asis
6381 @item @emph{Description}:
6382 Get the @var{VALUE} of the environmental variable @var{NAME}.
6384 This intrinsic routine is provided for backwards compatibility with
6385 GNU Fortran 77.  In new code, programmers should consider the use of
6386 the @ref{GET_ENVIRONMENT_VARIABLE} intrinsic defined by the Fortran
6387 2003 standard.
6389 Note that @code{GETENV} need not be thread-safe. It is the
6390 responsibility of the user to ensure that the environment is not being
6391 updated concurrently with a call to the @code{GETENV} intrinsic.
6393 @item @emph{Standard}:
6394 GNU extension
6396 @item @emph{Class}:
6397 Subroutine
6399 @item @emph{Syntax}:
6400 @code{CALL GETENV(NAME, VALUE)}
6402 @item @emph{Arguments}:
6403 @multitable @columnfractions .15 .70
6404 @item @var{NAME}  @tab Shall be of type @code{CHARACTER} and of default kind.
6405 @item @var{VALUE} @tab Shall be of type @code{CHARACTER} and of default kind.
6406 @end multitable
6408 @item @emph{Return value}:
6409 Stores the value of @var{NAME} in @var{VALUE}. If @var{VALUE} is 
6410 not large enough to hold the data, it is truncated. If @var{NAME}
6411 is not set, @var{VALUE} will be filled with blanks.
6413 @item @emph{Example}:
6414 @smallexample
6415 PROGRAM test_getenv
6416   CHARACTER(len=255) :: homedir
6417   CALL getenv("HOME", homedir)
6418   WRITE (*,*) TRIM(homedir)
6419 END PROGRAM
6420 @end smallexample
6422 @item @emph{See also}:
6423 @ref{GET_ENVIRONMENT_VARIABLE}
6424 @end table
6428 @node GET_ENVIRONMENT_VARIABLE
6429 @section @code{GET_ENVIRONMENT_VARIABLE} --- Get an environmental variable
6430 @fnindex GET_ENVIRONMENT_VARIABLE
6431 @cindex environment variable
6433 @table @asis
6434 @item @emph{Description}:
6435 Get the @var{VALUE} of the environmental variable @var{NAME}.
6437 Note that @code{GET_ENVIRONMENT_VARIABLE} need not be thread-safe. It
6438 is the responsibility of the user to ensure that the environment is
6439 not being updated concurrently with a call to the
6440 @code{GET_ENVIRONMENT_VARIABLE} intrinsic.
6442 @item @emph{Standard}:
6443 Fortran 2003 and later
6445 @item @emph{Class}:
6446 Subroutine
6448 @item @emph{Syntax}:
6449 @code{CALL GET_ENVIRONMENT_VARIABLE(NAME[, VALUE, LENGTH, STATUS, TRIM_NAME)}
6451 @item @emph{Arguments}:
6452 @multitable @columnfractions .15 .70
6453 @item @var{NAME}      @tab Shall be a scalar of type @code{CHARACTER}
6454 and of default kind.
6455 @item @var{VALUE}     @tab (Optional) Shall be a scalar of type @code{CHARACTER}
6456 and of default kind.
6457 @item @var{LENGTH}    @tab (Optional) Shall be a scalar of type @code{INTEGER}
6458 and of default kind.
6459 @item @var{STATUS}    @tab (Optional) Shall be a scalar of type @code{INTEGER}
6460 and of default kind.
6461 @item @var{TRIM_NAME} @tab (Optional) Shall be a scalar of type @code{LOGICAL}
6462 and of default kind.
6463 @end multitable
6465 @item @emph{Return value}:
6466 Stores the value of @var{NAME} in @var{VALUE}. If @var{VALUE} is 
6467 not large enough to hold the data, it is truncated. If @var{NAME}
6468 is not set, @var{VALUE} will be filled with blanks. Argument @var{LENGTH}
6469 contains the length needed for storing the environment variable @var{NAME}
6470 or zero if it is not present. @var{STATUS} is -1 if @var{VALUE} is present
6471 but too short for the environment variable; it is 1 if the environment
6472 variable does not exist and 2 if the processor does not support environment
6473 variables; in all other cases @var{STATUS} is zero. If @var{TRIM_NAME} is
6474 present with the value @code{.FALSE.}, the trailing blanks in @var{NAME}
6475 are significant; otherwise they are not part of the environment variable
6476 name.
6478 @item @emph{Example}:
6479 @smallexample
6480 PROGRAM test_getenv
6481   CHARACTER(len=255) :: homedir
6482   CALL get_environment_variable("HOME", homedir)
6483   WRITE (*,*) TRIM(homedir)
6484 END PROGRAM
6485 @end smallexample
6486 @end table
6490 @node GETGID
6491 @section @code{GETGID} --- Group ID function
6492 @fnindex GETGID
6493 @cindex system, group ID
6495 @table @asis
6496 @item @emph{Description}:
6497 Returns the numerical group ID of the current process.
6499 @item @emph{Standard}:
6500 GNU extension
6502 @item @emph{Class}:
6503 Function
6505 @item @emph{Syntax}:
6506 @code{RESULT = GETGID()}
6508 @item @emph{Return value}:
6509 The return value of @code{GETGID} is an @code{INTEGER} of the default
6510 kind.
6513 @item @emph{Example}:
6514 See @code{GETPID} for an example.
6516 @item @emph{See also}:
6517 @ref{GETPID}, @ref{GETUID}
6518 @end table
6522 @node GETLOG
6523 @section @code{GETLOG} --- Get login name
6524 @fnindex GETLOG
6525 @cindex system, login name
6526 @cindex login name
6528 @table @asis
6529 @item @emph{Description}:
6530 Gets the username under which the program is running.
6532 @item @emph{Standard}:
6533 GNU extension
6535 @item @emph{Class}:
6536 Subroutine
6538 @item @emph{Syntax}:
6539 @code{CALL GETLOG(C)}
6541 @item @emph{Arguments}:
6542 @multitable @columnfractions .15 .70
6543 @item @var{C} @tab Shall be of type @code{CHARACTER} and of default kind.
6544 @end multitable
6546 @item @emph{Return value}:
6547 Stores the current user name in @var{LOGIN}.  (On systems where POSIX
6548 functions @code{geteuid} and @code{getpwuid} are not available, and 
6549 the @code{getlogin} function is not implemented either, this will
6550 return a blank string.)
6552 @item @emph{Example}:
6553 @smallexample
6554 PROGRAM TEST_GETLOG
6555   CHARACTER(32) :: login
6556   CALL GETLOG(login)
6557   WRITE(*,*) login
6558 END PROGRAM
6559 @end smallexample
6561 @item @emph{See also}:
6562 @ref{GETUID}
6563 @end table
6567 @node GETPID
6568 @section @code{GETPID} --- Process ID function
6569 @fnindex GETPID
6570 @cindex system, process ID
6571 @cindex process ID
6573 @table @asis
6574 @item @emph{Description}:
6575 Returns the numerical process identifier of the current process.
6577 @item @emph{Standard}:
6578 GNU extension
6580 @item @emph{Class}:
6581 Function
6583 @item @emph{Syntax}:
6584 @code{RESULT = GETPID()}
6586 @item @emph{Return value}:
6587 The return value of @code{GETPID} is an @code{INTEGER} of the default
6588 kind.
6591 @item @emph{Example}:
6592 @smallexample
6593 program info
6594   print *, "The current process ID is ", getpid()
6595   print *, "Your numerical user ID is ", getuid()
6596   print *, "Your numerical group ID is ", getgid()
6597 end program info
6598 @end smallexample
6600 @item @emph{See also}:
6601 @ref{GETGID}, @ref{GETUID}
6602 @end table
6606 @node GETUID
6607 @section @code{GETUID} --- User ID function
6608 @fnindex GETUID
6609 @cindex system, user ID
6610 @cindex user id
6612 @table @asis
6613 @item @emph{Description}:
6614 Returns the numerical user ID of the current process.
6616 @item @emph{Standard}:
6617 GNU extension
6619 @item @emph{Class}:
6620 Function
6622 @item @emph{Syntax}:
6623 @code{RESULT = GETUID()}
6625 @item @emph{Return value}:
6626 The return value of @code{GETUID} is an @code{INTEGER} of the default
6627 kind.
6630 @item @emph{Example}:
6631 See @code{GETPID} for an example.
6633 @item @emph{See also}:
6634 @ref{GETPID}, @ref{GETLOG}
6635 @end table
6639 @node GMTIME
6640 @section @code{GMTIME} --- Convert time to GMT info
6641 @fnindex GMTIME
6642 @cindex time, conversion to GMT info
6644 @table @asis
6645 @item @emph{Description}:
6646 Given a system time value @var{TIME} (as provided by the @code{TIME8}
6647 intrinsic), fills @var{VALUES} with values extracted from it appropriate
6648 to the UTC time zone (Universal Coordinated Time, also known in some
6649 countries as GMT, Greenwich Mean Time), using @code{gmtime(3)}.
6651 @item @emph{Standard}:
6652 GNU extension
6654 @item @emph{Class}:
6655 Subroutine
6657 @item @emph{Syntax}:
6658 @code{CALL GMTIME(TIME, VALUES)}
6660 @item @emph{Arguments}:
6661 @multitable @columnfractions .15 .70
6662 @item @var{TIME}   @tab An @code{INTEGER} scalar expression
6663 corresponding to a system time, with @code{INTENT(IN)}.
6664 @item @var{VALUES} @tab A default @code{INTEGER} array with 9 elements,
6665 with @code{INTENT(OUT)}.
6666 @end multitable
6668 @item @emph{Return value}:
6669 The elements of @var{VALUES} are assigned as follows:
6670 @enumerate
6671 @item Seconds after the minute, range 0--59 or 0--61 to allow for leap
6672 seconds
6673 @item Minutes after the hour, range 0--59
6674 @item Hours past midnight, range 0--23
6675 @item Day of month, range 0--31
6676 @item Number of months since January, range 0--12
6677 @item Years since 1900
6678 @item Number of days since Sunday, range 0--6
6679 @item Days since January 1
6680 @item Daylight savings indicator: positive if daylight savings is in
6681 effect, zero if not, and negative if the information is not available.
6682 @end enumerate
6684 @item @emph{See also}:
6685 @ref{CTIME}, @ref{LTIME}, @ref{TIME}, @ref{TIME8}
6687 @end table
6691 @node HOSTNM
6692 @section @code{HOSTNM} --- Get system host name
6693 @fnindex HOSTNM
6694 @cindex system, host name
6696 @table @asis
6697 @item @emph{Description}:
6698 Retrieves the host name of the system on which the program is running.
6700 This intrinsic is provided in both subroutine and function forms; however,
6701 only one form can be used in any given program unit.
6703 @item @emph{Standard}:
6704 GNU extension
6706 @item @emph{Class}:
6707 Subroutine, function
6709 @item @emph{Syntax}:
6710 @multitable @columnfractions .80
6711 @item @code{CALL HOSTNM(C [, STATUS])}
6712 @item @code{STATUS = HOSTNM(NAME)}
6713 @end multitable
6715 @item @emph{Arguments}:
6716 @multitable @columnfractions .15 .70
6717 @item @var{C}    @tab Shall of type @code{CHARACTER} and of default kind.
6718 @item @var{STATUS}  @tab (Optional) status flag of type @code{INTEGER}.
6719 Returns 0 on success, or a system specific error code otherwise.
6720 @end multitable
6722 @item @emph{Return value}:
6723 In either syntax, @var{NAME} is set to the current hostname if it can
6724 be obtained, or to a blank string otherwise.
6726 @end table
6730 @node HUGE
6731 @section @code{HUGE} --- Largest number of a kind
6732 @fnindex HUGE
6733 @cindex limits, largest number
6734 @cindex model representation, largest number
6736 @table @asis
6737 @item @emph{Description}:
6738 @code{HUGE(X)} returns the largest number that is not an infinity in
6739 the model of the type of @code{X}.
6741 @item @emph{Standard}:
6742 Fortran 95 and later
6744 @item @emph{Class}:
6745 Inquiry function
6747 @item @emph{Syntax}:
6748 @code{RESULT = HUGE(X)}
6750 @item @emph{Arguments}:
6751 @multitable @columnfractions .15 .70
6752 @item @var{X} @tab Shall be of type @code{REAL} or @code{INTEGER}.
6753 @end multitable
6755 @item @emph{Return value}:
6756 The return value is of the same type and kind as @var{X}
6758 @item @emph{Example}:
6759 @smallexample
6760 program test_huge_tiny
6761   print *, huge(0), huge(0.0), huge(0.0d0)
6762   print *, tiny(0.0), tiny(0.0d0)
6763 end program test_huge_tiny
6764 @end smallexample
6765 @end table
6769 @node HYPOT
6770 @section @code{HYPOT} --- Euclidean distance function
6771 @fnindex HYPOT
6772 @cindex Euclidean distance
6774 @table @asis
6775 @item @emph{Description}:
6776 @code{HYPOT(X,Y)} is the Euclidean distance function. It is equal to
6777 @math{\sqrt{X^2 + Y^2}}, without undue underflow or overflow.
6779 @item @emph{Standard}:
6780 Fortran 2008 and later
6782 @item @emph{Class}:
6783 Elemental function
6785 @item @emph{Syntax}:
6786 @code{RESULT = HYPOT(X, Y)}
6788 @item @emph{Arguments}:
6789 @multitable @columnfractions .15 .70
6790 @item @var{X} @tab The type shall be @code{REAL}.
6791 @item @var{Y} @tab The type and kind type parameter shall be the same as
6792 @var{X}.
6793 @end multitable
6795 @item @emph{Return value}:
6796 The return value has the same type and kind type parameter as @var{X}.
6798 @item @emph{Example}:
6799 @smallexample
6800 program test_hypot
6801   real(4) :: x = 1.e0_4, y = 0.5e0_4
6802   x = hypot(x,y)
6803 end program test_hypot
6804 @end smallexample
6805 @end table
6809 @node IACHAR
6810 @section @code{IACHAR} --- Code in @acronym{ASCII} collating sequence 
6811 @fnindex IACHAR
6812 @cindex @acronym{ASCII} collating sequence
6813 @cindex collating sequence, @acronym{ASCII}
6814 @cindex conversion, to integer
6816 @table @asis
6817 @item @emph{Description}:
6818 @code{IACHAR(C)} returns the code for the @acronym{ASCII} character
6819 in the first character position of @code{C}.
6821 @item @emph{Standard}:
6822 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
6824 @item @emph{Class}:
6825 Elemental function
6827 @item @emph{Syntax}:
6828 @code{RESULT = IACHAR(C [, KIND])}
6830 @item @emph{Arguments}:
6831 @multitable @columnfractions .15 .70
6832 @item @var{C}    @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
6833 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
6834 expression indicating the kind parameter of the result.
6835 @end multitable
6837 @item @emph{Return value}:
6838 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
6839 @var{KIND} is absent, the return value is of default integer kind.
6841 @item @emph{Example}:
6842 @smallexample
6843 program test_iachar
6844   integer i
6845   i = iachar(' ')
6846 end program test_iachar
6847 @end smallexample
6849 @item @emph{Note}:
6850 See @ref{ICHAR} for a discussion of converting between numerical values
6851 and formatted string representations.
6853 @item @emph{See also}:
6854 @ref{ACHAR}, @ref{CHAR}, @ref{ICHAR}
6856 @end table
6860 @node IALL
6861 @section @code{IALL} --- Bitwise AND of array elements
6862 @fnindex IALL
6863 @cindex array, AND
6864 @cindex bits, AND of array elements
6866 @table @asis
6867 @item @emph{Description}:
6868 Reduces with bitwise AND the elements of @var{ARRAY} along dimension @var{DIM}
6869 if the corresponding element in @var{MASK} is @code{TRUE}.
6871 @item @emph{Standard}:
6872 Fortran 2008 and later
6874 @item @emph{Class}:
6875 Transformational function
6877 @item @emph{Syntax}:
6878 @multitable @columnfractions .80
6879 @item @code{RESULT = IALL(ARRAY[, MASK])}
6880 @item @code{RESULT = IALL(ARRAY, DIM[, MASK])}
6881 @end multitable
6883 @item @emph{Arguments}:
6884 @multitable @columnfractions .15 .70
6885 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER}
6886 @item @var{DIM}   @tab (Optional) shall be a scalar of type 
6887 @code{INTEGER} with a value in the range from 1 to n, where n 
6888 equals the rank of @var{ARRAY}.
6889 @item @var{MASK}  @tab (Optional) shall be of type @code{LOGICAL} 
6890 and either be a scalar or an array of the same shape as @var{ARRAY}.
6891 @end multitable
6893 @item @emph{Return value}:
6894 The result is of the same type as @var{ARRAY}.
6896 If @var{DIM} is absent, a scalar with the bitwise ALL of all elements in
6897 @var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals
6898 the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with
6899 dimension @var{DIM} dropped is returned.
6901 @item @emph{Example}:
6902 @smallexample
6903 PROGRAM test_iall
6904   INTEGER(1) :: a(2)
6906   a(1) = b'00100100'
6907   a(2) = b'01101010'
6909   ! prints 00100000
6910   PRINT '(b8.8)', IALL(a)
6911 END PROGRAM
6912 @end smallexample
6914 @item @emph{See also}:
6915 @ref{IANY}, @ref{IPARITY}, @ref{IAND}
6916 @end table
6920 @node IAND
6921 @section @code{IAND} --- Bitwise logical and
6922 @fnindex IAND
6923 @cindex bitwise logical and
6924 @cindex logical and, bitwise
6926 @table @asis
6927 @item @emph{Description}:
6928 Bitwise logical @code{AND}.
6930 @item @emph{Standard}:
6931 Fortran 95 and later
6933 @item @emph{Class}:
6934 Elemental function
6936 @item @emph{Syntax}:
6937 @code{RESULT = IAND(I, J)}
6939 @item @emph{Arguments}:
6940 @multitable @columnfractions .15 .70
6941 @item @var{I} @tab The type shall be @code{INTEGER}.
6942 @item @var{J} @tab The type shall be @code{INTEGER}, of the same
6943 kind as @var{I}.  (As a GNU extension, different kinds are also 
6944 permitted.)
6945 @end multitable
6947 @item @emph{Return value}:
6948 The return type is @code{INTEGER}, of the same kind as the
6949 arguments.  (If the argument kinds differ, it is of the same kind as
6950 the larger argument.)
6952 @item @emph{Example}:
6953 @smallexample
6954 PROGRAM test_iand
6955   INTEGER :: a, b
6956   DATA a / Z'F' /, b / Z'3' /
6957   WRITE (*,*) IAND(a, b)
6958 END PROGRAM
6959 @end smallexample
6961 @item @emph{See also}:
6962 @ref{IOR}, @ref{IEOR}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
6964 @end table
6968 @node IANY
6969 @section @code{IANY} --- Bitwise OR of array elements
6970 @fnindex IANY
6971 @cindex array, OR
6972 @cindex bits, OR of array elements
6974 @table @asis
6975 @item @emph{Description}:
6976 Reduces with bitwise OR (inclusive or) the elements of @var{ARRAY} along
6977 dimension @var{DIM} if the corresponding element in @var{MASK} is @code{TRUE}.
6979 @item @emph{Standard}:
6980 Fortran 2008 and later
6982 @item @emph{Class}:
6983 Transformational function
6985 @item @emph{Syntax}:
6986 @multitable @columnfractions .80
6987 @item @code{RESULT = IANY(ARRAY[, MASK])}
6988 @item @code{RESULT = IANY(ARRAY, DIM[, MASK])}
6989 @end multitable
6991 @item @emph{Arguments}:
6992 @multitable @columnfractions .15 .70
6993 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER}
6994 @item @var{DIM}   @tab (Optional) shall be a scalar of type 
6995 @code{INTEGER} with a value in the range from 1 to n, where n 
6996 equals the rank of @var{ARRAY}.
6997 @item @var{MASK}  @tab (Optional) shall be of type @code{LOGICAL} 
6998 and either be a scalar or an array of the same shape as @var{ARRAY}.
6999 @end multitable
7001 @item @emph{Return value}:
7002 The result is of the same type as @var{ARRAY}.
7004 If @var{DIM} is absent, a scalar with the bitwise OR of all elements in
7005 @var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals
7006 the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with
7007 dimension @var{DIM} dropped is returned.
7009 @item @emph{Example}:
7010 @smallexample
7011 PROGRAM test_iany
7012   INTEGER(1) :: a(2)
7014   a(1) = b'00100100'
7015   a(2) = b'01101010'
7017   ! prints 01101110
7018   PRINT '(b8.8)', IANY(a)
7019 END PROGRAM
7020 @end smallexample
7022 @item @emph{See also}:
7023 @ref{IPARITY}, @ref{IALL}, @ref{IOR}
7024 @end table
7028 @node IARGC
7029 @section @code{IARGC} --- Get the number of command line arguments
7030 @fnindex IARGC
7031 @cindex command-line arguments
7032 @cindex command-line arguments, number of
7033 @cindex arguments, to program
7035 @table @asis
7036 @item @emph{Description}:
7037 @code{IARGC} returns the number of arguments passed on the
7038 command line when the containing program was invoked.
7040 This intrinsic routine is provided for backwards compatibility with 
7041 GNU Fortran 77.  In new code, programmers should consider the use of 
7042 the @ref{COMMAND_ARGUMENT_COUNT} intrinsic defined by the Fortran 2003 
7043 standard.
7045 @item @emph{Standard}:
7046 GNU extension
7048 @item @emph{Class}:
7049 Function
7051 @item @emph{Syntax}:
7052 @code{RESULT = IARGC()}
7054 @item @emph{Arguments}:
7055 None.
7057 @item @emph{Return value}:
7058 The number of command line arguments, type @code{INTEGER(4)}.
7060 @item @emph{Example}:
7061 See @ref{GETARG}
7063 @item @emph{See also}:
7064 GNU Fortran 77 compatibility subroutine: @ref{GETARG}
7066 Fortran 2003 functions and subroutines: @ref{GET_COMMAND},
7067 @ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
7068 @end table
7072 @node IBCLR
7073 @section @code{IBCLR} --- Clear bit
7074 @fnindex IBCLR
7075 @cindex bits, unset
7076 @cindex bits, clear
7078 @table @asis
7079 @item @emph{Description}:
7080 @code{IBCLR} returns the value of @var{I} with the bit at position
7081 @var{POS} set to zero.
7083 @item @emph{Standard}:
7084 Fortran 95 and later
7086 @item @emph{Class}:
7087 Elemental function
7089 @item @emph{Syntax}:
7090 @code{RESULT = IBCLR(I, POS)}
7092 @item @emph{Arguments}:
7093 @multitable @columnfractions .15 .70
7094 @item @var{I} @tab The type shall be @code{INTEGER}.
7095 @item @var{POS} @tab The type shall be @code{INTEGER}.
7096 @end multitable
7098 @item @emph{Return value}:
7099 The return value is of type @code{INTEGER} and of the same kind as
7100 @var{I}.
7102 @item @emph{See also}:
7103 @ref{IBITS}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}, @ref{MVBITS}
7105 @end table
7109 @node IBITS
7110 @section @code{IBITS} --- Bit extraction
7111 @fnindex IBITS
7112 @cindex bits, get
7113 @cindex bits, extract
7115 @table @asis
7116 @item @emph{Description}:
7117 @code{IBITS} extracts a field of length @var{LEN} from @var{I},
7118 starting from bit position @var{POS} and extending left for @var{LEN}
7119 bits.  The result is right-justified and the remaining bits are
7120 zeroed.  The value of @code{POS+LEN} must be less than or equal to the
7121 value @code{BIT_SIZE(I)}.
7123 @item @emph{Standard}:
7124 Fortran 95 and later
7126 @item @emph{Class}:
7127 Elemental function
7129 @item @emph{Syntax}:
7130 @code{RESULT = IBITS(I, POS, LEN)}
7132 @item @emph{Arguments}:
7133 @multitable @columnfractions .15 .70
7134 @item @var{I}   @tab The type shall be @code{INTEGER}.
7135 @item @var{POS} @tab The type shall be @code{INTEGER}.
7136 @item @var{LEN} @tab The type shall be @code{INTEGER}.
7137 @end multitable
7139 @item @emph{Return value}:
7140 The return value is of type @code{INTEGER} and of the same kind as
7141 @var{I}.
7143 @item @emph{See also}:
7144 @ref{BIT_SIZE}, @ref{IBCLR}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
7145 @end table
7149 @node IBSET
7150 @section @code{IBSET} --- Set bit
7151 @fnindex IBSET
7152 @cindex bits, set
7154 @table @asis
7155 @item @emph{Description}:
7156 @code{IBSET} returns the value of @var{I} with the bit at position
7157 @var{POS} set to one.
7159 @item @emph{Standard}:
7160 Fortran 95 and later
7162 @item @emph{Class}:
7163 Elemental function
7165 @item @emph{Syntax}:
7166 @code{RESULT = IBSET(I, POS)}
7168 @item @emph{Arguments}:
7169 @multitable @columnfractions .15 .70
7170 @item @var{I} @tab The type shall be @code{INTEGER}.
7171 @item @var{POS} @tab The type shall be @code{INTEGER}.
7172 @end multitable
7174 @item @emph{Return value}:
7175 The return value is of type @code{INTEGER} and of the same kind as
7176 @var{I}.
7178 @item @emph{See also}:
7179 @ref{IBCLR}, @ref{IBITS}, @ref{IAND}, @ref{IOR}, @ref{IEOR}, @ref{MVBITS}
7181 @end table
7185 @node ICHAR
7186 @section @code{ICHAR} --- Character-to-integer conversion function
7187 @fnindex ICHAR
7188 @cindex conversion, to integer
7190 @table @asis
7191 @item @emph{Description}:
7192 @code{ICHAR(C)} returns the code for the character in the first character
7193 position of @code{C} in the system's native character set.
7194 The correspondence between characters and their codes is not necessarily
7195 the same across different GNU Fortran implementations.
7197 @item @emph{Standard}:
7198 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
7200 @item @emph{Class}:
7201 Elemental function
7203 @item @emph{Syntax}:
7204 @code{RESULT = ICHAR(C [, KIND])}
7206 @item @emph{Arguments}:
7207 @multitable @columnfractions .15 .70
7208 @item @var{C}    @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
7209 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
7210 expression indicating the kind parameter of the result.
7211 @end multitable
7213 @item @emph{Return value}:
7214 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
7215 @var{KIND} is absent, the return value is of default integer kind.
7217 @item @emph{Example}:
7218 @smallexample
7219 program test_ichar
7220   integer i
7221   i = ichar(' ')
7222 end program test_ichar
7223 @end smallexample
7225 @item @emph{Specific names}:
7226 @multitable @columnfractions .20 .20 .20 .25
7227 @item Name             @tab Argument             @tab Return type       @tab Standard
7228 @item @code{ICHAR(C)}  @tab @code{CHARACTER C}   @tab @code{INTEGER(4)}    @tab Fortran 77 and later
7229 @end multitable
7231 @item @emph{Note}:
7232 No intrinsic exists to convert between a numeric value and a formatted
7233 character string representation -- for instance, given the
7234 @code{CHARACTER} value @code{'154'}, obtaining an @code{INTEGER} or
7235 @code{REAL} value with the value 154, or vice versa. Instead, this
7236 functionality is provided by internal-file I/O, as in the following
7237 example:
7238 @smallexample
7239 program read_val
7240   integer value
7241   character(len=10) string, string2
7242   string = '154'
7243   
7244   ! Convert a string to a numeric value
7245   read (string,'(I10)') value
7246   print *, value
7247   
7248   ! Convert a value to a formatted string
7249   write (string2,'(I10)') value
7250   print *, string2
7251 end program read_val
7252 @end smallexample
7254 @item @emph{See also}:
7255 @ref{ACHAR}, @ref{CHAR}, @ref{IACHAR}
7257 @end table
7261 @node IDATE
7262 @section @code{IDATE} --- Get current local time subroutine (day/month/year) 
7263 @fnindex IDATE
7264 @cindex date, current
7265 @cindex current date
7267 @table @asis
7268 @item @emph{Description}:
7269 @code{IDATE(VALUES)} Fills @var{VALUES} with the numerical values at the  
7270 current local time. The day (in the range 1-31), month (in the range 1-12), 
7271 and year appear in elements 1, 2, and 3 of @var{VALUES}, respectively. 
7272 The year has four significant digits.
7274 @item @emph{Standard}:
7275 GNU extension
7277 @item @emph{Class}:
7278 Subroutine
7280 @item @emph{Syntax}:
7281 @code{CALL IDATE(VALUES)}
7283 @item @emph{Arguments}:
7284 @multitable @columnfractions .15 .70
7285 @item @var{VALUES} @tab The type shall be @code{INTEGER, DIMENSION(3)} and
7286 the kind shall be the default integer kind.
7287 @end multitable
7289 @item @emph{Return value}:
7290 Does not return anything.
7292 @item @emph{Example}:
7293 @smallexample
7294 program test_idate
7295   integer, dimension(3) :: tarray
7296   call idate(tarray)
7297   print *, tarray(1)
7298   print *, tarray(2)
7299   print *, tarray(3)
7300 end program test_idate
7301 @end smallexample
7302 @end table
7306 @node IEOR
7307 @section @code{IEOR} --- Bitwise logical exclusive or
7308 @fnindex IEOR
7309 @cindex bitwise logical exclusive or
7310 @cindex logical exclusive or, bitwise
7312 @table @asis
7313 @item @emph{Description}:
7314 @code{IEOR} returns the bitwise Boolean exclusive-OR of @var{I} and
7315 @var{J}.
7317 @item @emph{Standard}:
7318 Fortran 95 and later
7320 @item @emph{Class}:
7321 Elemental function
7323 @item @emph{Syntax}:
7324 @code{RESULT = IEOR(I, J)}
7326 @item @emph{Arguments}:
7327 @multitable @columnfractions .15 .70
7328 @item @var{I} @tab The type shall be @code{INTEGER}.
7329 @item @var{J} @tab The type shall be @code{INTEGER}, of the same
7330 kind as @var{I}.  (As a GNU extension, different kinds are also 
7331 permitted.)
7332 @end multitable
7334 @item @emph{Return value}:
7335 The return type is @code{INTEGER}, of the same kind as the
7336 arguments.  (If the argument kinds differ, it is of the same kind as
7337 the larger argument.)
7339 @item @emph{See also}:
7340 @ref{IOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
7341 @end table
7345 @node IERRNO
7346 @section @code{IERRNO} --- Get the last system error number
7347 @fnindex IERRNO
7348 @cindex system, error handling
7350 @table @asis
7351 @item @emph{Description}:
7352 Returns the last system error number, as given by the C @code{errno}
7353 variable.
7355 @item @emph{Standard}:
7356 GNU extension
7358 @item @emph{Class}:
7359 Function
7361 @item @emph{Syntax}:
7362 @code{RESULT = IERRNO()}
7364 @item @emph{Arguments}:
7365 None.
7367 @item @emph{Return value}:
7368 The return value is of type @code{INTEGER} and of the default integer
7369 kind.
7371 @item @emph{See also}:
7372 @ref{PERROR}
7373 @end table
7377 @node IMAGE_INDEX
7378 @section @code{IMAGE_INDEX} --- Function that converts a cosubscript to an image index
7379 @fnindex IMAGE_INDEX
7380 @cindex coarray, @code{IMAGE_INDEX}
7381 @cindex images, cosubscript to image index conversion
7383 @table @asis
7384 @item @emph{Description}:
7385 Returns the image index belonging to a cosubscript.
7387 @item @emph{Standard}:
7388 Fortran 2008 and later
7390 @item @emph{Class}:
7391 Inquiry function.
7393 @item @emph{Syntax}:
7394 @code{RESULT = IMAGE_INDEX(COARRAY, SUB)}
7396 @item @emph{Arguments}: None.
7397 @multitable @columnfractions .15 .70
7398 @item @var{COARRAY} @tab Coarray of any type.
7399 @item @var{SUB}     @tab default integer rank-1 array of a size equal to
7400 the corank of @var{COARRAY}.
7401 @end multitable
7404 @item @emph{Return value}:
7405 Scalar default integer with the value of the image index which corresponds
7406 to the cosubscripts. For invalid cosubscripts the result is zero.
7408 @item @emph{Example}:
7409 @smallexample
7410 INTEGER :: array[2,-1:4,8,*]
7411 ! Writes  28 (or 0 if there are fewer than 28 images)
7412 WRITE (*,*) IMAGE_INDEX (array, [2,0,3,1])
7413 @end smallexample
7415 @item @emph{See also}:
7416 @ref{THIS_IMAGE}, @ref{NUM_IMAGES}
7417 @end table
7421 @node INDEX intrinsic
7422 @section @code{INDEX} --- Position of a substring within a string
7423 @fnindex INDEX
7424 @cindex substring position
7425 @cindex string, find substring
7427 @table @asis
7428 @item @emph{Description}:
7429 Returns the position of the start of the first occurrence of string
7430 @var{SUBSTRING} as a substring in @var{STRING}, counting from one.  If
7431 @var{SUBSTRING} is not present in @var{STRING}, zero is returned.  If 
7432 the @var{BACK} argument is present and true, the return value is the
7433 start of the last occurrence rather than the first.
7435 @item @emph{Standard}:
7436 Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later
7438 @item @emph{Class}:
7439 Elemental function
7441 @item @emph{Syntax}:
7442 @code{RESULT = INDEX(STRING, SUBSTRING [, BACK [, KIND]])}
7444 @item @emph{Arguments}:
7445 @multitable @columnfractions .15 .70
7446 @item @var{STRING} @tab Shall be a scalar @code{CHARACTER}, with
7447 @code{INTENT(IN)}
7448 @item @var{SUBSTRING} @tab Shall be a scalar @code{CHARACTER}, with
7449 @code{INTENT(IN)}
7450 @item @var{BACK} @tab (Optional) Shall be a scalar @code{LOGICAL}, with
7451 @code{INTENT(IN)}
7452 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
7453 expression indicating the kind parameter of the result.
7454 @end multitable
7456 @item @emph{Return value}:
7457 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
7458 @var{KIND} is absent, the return value is of default integer kind.
7460 @item @emph{Specific names}:
7461 @multitable @columnfractions .20 .20 .20 .25
7462 @item Name                            @tab Argument           @tab Return type       @tab Standard
7463 @item @code{INDEX(STRING, SUBSTRING)} @tab @code{CHARACTER}   @tab @code{INTEGER(4)} @tab Fortran 77 and later
7464 @end multitable
7466 @item @emph{See also}:
7467 @ref{SCAN}, @ref{VERIFY}
7468 @end table
7472 @node INT
7473 @section @code{INT} --- Convert to integer type
7474 @fnindex INT
7475 @fnindex IFIX
7476 @fnindex IDINT
7477 @cindex conversion, to integer
7479 @table @asis
7480 @item @emph{Description}:
7481 Convert to integer type
7483 @item @emph{Standard}:
7484 Fortran 77 and later
7486 @item @emph{Class}:
7487 Elemental function
7489 @item @emph{Syntax}:
7490 @code{RESULT = INT(A [, KIND))}
7492 @item @emph{Arguments}:
7493 @multitable @columnfractions .15 .70
7494 @item @var{A}    @tab Shall be of type @code{INTEGER},
7495 @code{REAL}, or @code{COMPLEX}.
7496 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
7497 expression indicating the kind parameter of the result.
7498 @end multitable
7500 @item @emph{Return value}:
7501 These functions return a @code{INTEGER} variable or array under 
7502 the following rules: 
7504 @table @asis
7505 @item (A)
7506 If @var{A} is of type @code{INTEGER}, @code{INT(A) = A} 
7507 @item (B)
7508 If @var{A} is of type @code{REAL} and @math{|A| < 1}, @code{INT(A)}
7509 equals @code{0}. If @math{|A| \geq 1}, then @code{INT(A)} is the integer
7510 whose magnitude is the largest integer that does not exceed the magnitude
7511 of @var{A} and whose sign is the same as the sign of @var{A}.
7512 @item (C)
7513 If @var{A} is of type @code{COMPLEX}, rule B is applied to the real part of @var{A}.
7514 @end table
7516 @item @emph{Example}:
7517 @smallexample
7518 program test_int
7519   integer :: i = 42
7520   complex :: z = (-3.7, 1.0)
7521   print *, int(i)
7522   print *, int(z), int(z,8)
7523 end program
7524 @end smallexample
7526 @item @emph{Specific names}:
7527 @multitable @columnfractions .20 .20 .20 .25
7528 @item Name            @tab Argument          @tab Return type       @tab Standard
7529 @item @code{INT(A)}   @tab @code{REAL(4) A}  @tab @code{INTEGER}    @tab Fortran 77 and later
7530 @item @code{IFIX(A)}  @tab @code{REAL(4) A}  @tab @code{INTEGER}    @tab Fortran 77 and later
7531 @item @code{IDINT(A)} @tab @code{REAL(8) A}  @tab @code{INTEGER}    @tab Fortran 77 and later
7532 @end multitable
7534 @end table
7537 @node INT2
7538 @section @code{INT2} --- Convert to 16-bit integer type
7539 @fnindex INT2
7540 @fnindex SHORT
7541 @cindex conversion, to integer
7543 @table @asis
7544 @item @emph{Description}:
7545 Convert to a @code{KIND=2} integer type. This is equivalent to the
7546 standard @code{INT} intrinsic with an optional argument of
7547 @code{KIND=2}, and is only included for backwards compatibility.
7549 The @code{SHORT} intrinsic is equivalent to @code{INT2}.
7551 @item @emph{Standard}:
7552 GNU extension
7554 @item @emph{Class}:
7555 Elemental function
7557 @item @emph{Syntax}:
7558 @code{RESULT = INT2(A)}
7560 @item @emph{Arguments}:
7561 @multitable @columnfractions .15 .70
7562 @item @var{A}    @tab Shall be of type @code{INTEGER},
7563 @code{REAL}, or @code{COMPLEX}.
7564 @end multitable
7566 @item @emph{Return value}:
7567 The return value is a @code{INTEGER(2)} variable.
7569 @item @emph{See also}:
7570 @ref{INT}, @ref{INT8}, @ref{LONG}
7571 @end table
7575 @node INT8
7576 @section @code{INT8} --- Convert to 64-bit integer type
7577 @fnindex INT8
7578 @cindex conversion, to integer
7580 @table @asis
7581 @item @emph{Description}:
7582 Convert to a @code{KIND=8} integer type. This is equivalent to the
7583 standard @code{INT} intrinsic with an optional argument of
7584 @code{KIND=8}, and is only included for backwards compatibility.
7586 @item @emph{Standard}:
7587 GNU extension
7589 @item @emph{Class}:
7590 Elemental function
7592 @item @emph{Syntax}:
7593 @code{RESULT = INT8(A)}
7595 @item @emph{Arguments}:
7596 @multitable @columnfractions .15 .70
7597 @item @var{A}    @tab Shall be of type @code{INTEGER},
7598 @code{REAL}, or @code{COMPLEX}.
7599 @end multitable
7601 @item @emph{Return value}:
7602 The return value is a @code{INTEGER(8)} variable.
7604 @item @emph{See also}:
7605 @ref{INT}, @ref{INT2}, @ref{LONG}
7606 @end table
7610 @node IOR
7611 @section @code{IOR} --- Bitwise logical or
7612 @fnindex IOR
7613 @cindex bitwise logical or
7614 @cindex logical or, bitwise
7616 @table @asis
7617 @item @emph{Description}:
7618 @code{IOR} returns the bitwise Boolean inclusive-OR of @var{I} and
7619 @var{J}.
7621 @item @emph{Standard}:
7622 Fortran 95 and later
7624 @item @emph{Class}:
7625 Elemental function
7627 @item @emph{Syntax}:
7628 @code{RESULT = IOR(I, J)}
7630 @item @emph{Arguments}:
7631 @multitable @columnfractions .15 .70
7632 @item @var{I} @tab The type shall be @code{INTEGER}.
7633 @item @var{J} @tab The type shall be @code{INTEGER}, of the same
7634 kind as @var{I}.  (As a GNU extension, different kinds are also 
7635 permitted.)
7636 @end multitable
7638 @item @emph{Return value}:
7639 The return type is @code{INTEGER}, of the same kind as the
7640 arguments.  (If the argument kinds differ, it is of the same kind as
7641 the larger argument.)
7643 @item @emph{See also}:
7644 @ref{IEOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
7645 @end table
7649 @node IPARITY
7650 @section @code{IPARITY} --- Bitwise XOR of array elements
7651 @fnindex IPARITY
7652 @cindex array, parity
7653 @cindex array, XOR
7654 @cindex bits, XOR of array elements
7656 @table @asis
7657 @item @emph{Description}:
7658 Reduces with bitwise XOR (exclusive or) the elements of @var{ARRAY} along
7659 dimension @var{DIM} if the corresponding element in @var{MASK} is @code{TRUE}.
7661 @item @emph{Standard}:
7662 Fortran 2008 and later
7664 @item @emph{Class}:
7665 Transformational function
7667 @item @emph{Syntax}:
7668 @multitable @columnfractions .80
7669 @item @code{RESULT = IPARITY(ARRAY[, MASK])}
7670 @item @code{RESULT = IPARITY(ARRAY, DIM[, MASK])}
7671 @end multitable
7673 @item @emph{Arguments}:
7674 @multitable @columnfractions .15 .70
7675 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER}
7676 @item @var{DIM}   @tab (Optional) shall be a scalar of type 
7677 @code{INTEGER} with a value in the range from 1 to n, where n 
7678 equals the rank of @var{ARRAY}.
7679 @item @var{MASK}  @tab (Optional) shall be of type @code{LOGICAL} 
7680 and either be a scalar or an array of the same shape as @var{ARRAY}.
7681 @end multitable
7683 @item @emph{Return value}:
7684 The result is of the same type as @var{ARRAY}.
7686 If @var{DIM} is absent, a scalar with the bitwise XOR of all elements in
7687 @var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals
7688 the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with
7689 dimension @var{DIM} dropped is returned.
7691 @item @emph{Example}:
7692 @smallexample
7693 PROGRAM test_iparity
7694   INTEGER(1) :: a(2)
7696   a(1) = b'00100100'
7697   a(2) = b'01101010'
7699   ! prints 01001110
7700   PRINT '(b8.8)', IPARITY(a)
7701 END PROGRAM
7702 @end smallexample
7704 @item @emph{See also}:
7705 @ref{IANY}, @ref{IALL}, @ref{IEOR}, @ref{PARITY}
7706 @end table
7710 @node IRAND
7711 @section @code{IRAND} --- Integer pseudo-random number
7712 @fnindex IRAND
7713 @cindex random number generation
7715 @table @asis
7716 @item @emph{Description}:
7717 @code{IRAND(FLAG)} returns a pseudo-random number from a uniform
7718 distribution between 0 and a system-dependent limit (which is in most
7719 cases 2147483647). If @var{FLAG} is 0, the next number
7720 in the current sequence is returned; if @var{FLAG} is 1, the generator
7721 is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
7722 it is used as a new seed with @code{SRAND}.
7724 This intrinsic routine is provided for backwards compatibility with
7725 GNU Fortran 77. It implements a simple modulo generator as provided 
7726 by @command{g77}. For new code, one should consider the use of 
7727 @ref{RANDOM_NUMBER} as it implements a superior algorithm.
7729 @item @emph{Standard}:
7730 GNU extension
7732 @item @emph{Class}:
7733 Function
7735 @item @emph{Syntax}:
7736 @code{RESULT = IRAND(I)}
7738 @item @emph{Arguments}:
7739 @multitable @columnfractions .15 .70
7740 @item @var{I} @tab Shall be a scalar @code{INTEGER} of kind 4.
7741 @end multitable
7743 @item @emph{Return value}:
7744 The return value is of @code{INTEGER(kind=4)} type.
7746 @item @emph{Example}:
7747 @smallexample
7748 program test_irand
7749   integer,parameter :: seed = 86456
7750   
7751   call srand(seed)
7752   print *, irand(), irand(), irand(), irand()
7753   print *, irand(seed), irand(), irand(), irand()
7754 end program test_irand
7755 @end smallexample
7757 @end table
7761 @node IS_IOSTAT_END
7762 @section @code{IS_IOSTAT_END} --- Test for end-of-file value
7763 @fnindex IS_IOSTAT_END
7764 @cindex @code{IOSTAT}, end of file
7766 @table @asis
7767 @item @emph{Description}:
7768 @code{IS_IOSTAT_END} tests whether an variable has the value of the I/O
7769 status ``end of file''. The function is equivalent to comparing the variable
7770 with the @code{IOSTAT_END} parameter of the intrinsic module
7771 @code{ISO_FORTRAN_ENV}.
7773 @item @emph{Standard}:
7774 Fortran 2003 and later
7776 @item @emph{Class}:
7777 Elemental function
7779 @item @emph{Syntax}:
7780 @code{RESULT = IS_IOSTAT_END(I)}
7782 @item @emph{Arguments}:
7783 @multitable @columnfractions .15 .70
7784 @item @var{I} @tab Shall be of the type @code{INTEGER}.
7785 @end multitable
7787 @item @emph{Return value}:
7788 Returns a @code{LOGICAL} of the default kind, which @code{.TRUE.} if
7789 @var{I} has the value which indicates an end of file condition for
7790 @code{IOSTAT=} specifiers, and is @code{.FALSE.} otherwise.
7792 @item @emph{Example}:
7793 @smallexample
7794 PROGRAM iostat
7795   IMPLICIT NONE
7796   INTEGER :: stat, i
7797   OPEN(88, FILE='test.dat')
7798   READ(88, *, IOSTAT=stat) i
7799   IF(IS_IOSTAT_END(stat)) STOP 'END OF FILE'
7800 END PROGRAM
7801 @end smallexample
7802 @end table
7806 @node IS_IOSTAT_EOR
7807 @section @code{IS_IOSTAT_EOR} --- Test for end-of-record value
7808 @fnindex IS_IOSTAT_EOR
7809 @cindex @code{IOSTAT}, end of record
7811 @table @asis
7812 @item @emph{Description}:
7813 @code{IS_IOSTAT_EOR} tests whether an variable has the value of the I/O
7814 status ``end of record''. The function is equivalent to comparing the
7815 variable with the @code{IOSTAT_EOR} parameter of the intrinsic module
7816 @code{ISO_FORTRAN_ENV}.
7818 @item @emph{Standard}:
7819 Fortran 2003 and later
7821 @item @emph{Class}:
7822 Elemental function
7824 @item @emph{Syntax}:
7825 @code{RESULT = IS_IOSTAT_EOR(I)}
7827 @item @emph{Arguments}:
7828 @multitable @columnfractions .15 .70
7829 @item @var{I} @tab Shall be of the type @code{INTEGER}.
7830 @end multitable
7832 @item @emph{Return value}:
7833 Returns a @code{LOGICAL} of the default kind, which @code{.TRUE.} if
7834 @var{I} has the value which indicates an end of file condition for
7835 @code{IOSTAT=} specifiers, and is @code{.FALSE.} otherwise.
7837 @item @emph{Example}:
7838 @smallexample
7839 PROGRAM iostat
7840   IMPLICIT NONE
7841   INTEGER :: stat, i(50)
7842   OPEN(88, FILE='test.dat', FORM='UNFORMATTED')
7843   READ(88, IOSTAT=stat) i
7844   IF(IS_IOSTAT_EOR(stat)) STOP 'END OF RECORD'
7845 END PROGRAM
7846 @end smallexample
7847 @end table
7851 @node ISATTY
7852 @section @code{ISATTY} --- Whether a unit is a terminal device.
7853 @fnindex ISATTY
7854 @cindex system, terminal
7856 @table @asis
7857 @item @emph{Description}:
7858 Determine whether a unit is connected to a terminal device.
7860 @item @emph{Standard}:
7861 GNU extension
7863 @item @emph{Class}:
7864 Function
7866 @item @emph{Syntax}:
7867 @code{RESULT = ISATTY(UNIT)}
7869 @item @emph{Arguments}:
7870 @multitable @columnfractions .15 .70
7871 @item @var{UNIT} @tab Shall be a scalar @code{INTEGER}.
7872 @end multitable
7874 @item @emph{Return value}:
7875 Returns @code{.TRUE.} if the @var{UNIT} is connected to a terminal 
7876 device, @code{.FALSE.} otherwise.
7878 @item @emph{Example}:
7879 @smallexample
7880 PROGRAM test_isatty
7881   INTEGER(kind=1) :: unit
7882   DO unit = 1, 10
7883     write(*,*) isatty(unit=unit)
7884   END DO
7885 END PROGRAM
7886 @end smallexample
7887 @item @emph{See also}:
7888 @ref{TTYNAM}
7889 @end table
7893 @node ISHFT
7894 @section @code{ISHFT} --- Shift bits
7895 @fnindex ISHFT
7896 @cindex bits, shift
7898 @table @asis
7899 @item @emph{Description}:
7900 @code{ISHFT} returns a value corresponding to @var{I} with all of the
7901 bits shifted @var{SHIFT} places.  A value of @var{SHIFT} greater than
7902 zero corresponds to a left shift, a value of zero corresponds to no
7903 shift, and a value less than zero corresponds to a right shift.  If the
7904 absolute value of @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the
7905 value is undefined.  Bits shifted out from the left end or right end are
7906 lost; zeros are shifted in from the opposite end.
7908 @item @emph{Standard}:
7909 Fortran 95 and later
7911 @item @emph{Class}:
7912 Elemental function
7914 @item @emph{Syntax}:
7915 @code{RESULT = ISHFT(I, SHIFT)}
7917 @item @emph{Arguments}:
7918 @multitable @columnfractions .15 .70
7919 @item @var{I} @tab The type shall be @code{INTEGER}.
7920 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
7921 @end multitable
7923 @item @emph{Return value}:
7924 The return value is of type @code{INTEGER} and of the same kind as
7925 @var{I}.
7927 @item @emph{See also}:
7928 @ref{ISHFTC}
7929 @end table
7933 @node ISHFTC
7934 @section @code{ISHFTC} --- Shift bits circularly
7935 @fnindex ISHFTC
7936 @cindex bits, shift circular
7938 @table @asis
7939 @item @emph{Description}:
7940 @code{ISHFTC} returns a value corresponding to @var{I} with the
7941 rightmost @var{SIZE} bits shifted circularly @var{SHIFT} places; that
7942 is, bits shifted out one end are shifted into the opposite end.  A value
7943 of @var{SHIFT} greater than zero corresponds to a left shift, a value of
7944 zero corresponds to no shift, and a value less than zero corresponds to
7945 a right shift.  The absolute value of @var{SHIFT} must be less than
7946 @var{SIZE}.  If the @var{SIZE} argument is omitted, it is taken to be
7947 equivalent to @code{BIT_SIZE(I)}.
7949 @item @emph{Standard}:
7950 Fortran 95 and later
7952 @item @emph{Class}:
7953 Elemental function
7955 @item @emph{Syntax}:
7956 @code{RESULT = ISHFTC(I, SHIFT [, SIZE])}
7958 @item @emph{Arguments}:
7959 @multitable @columnfractions .15 .70
7960 @item @var{I} @tab The type shall be @code{INTEGER}.
7961 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
7962 @item @var{SIZE} @tab (Optional) The type shall be @code{INTEGER};
7963 the value must be greater than zero and less than or equal to
7964 @code{BIT_SIZE(I)}.
7965 @end multitable
7967 @item @emph{Return value}:
7968 The return value is of type @code{INTEGER} and of the same kind as
7969 @var{I}.
7971 @item @emph{See also}:
7972 @ref{ISHFT}
7973 @end table
7977 @node ISNAN
7978 @section @code{ISNAN} --- Test for a NaN
7979 @fnindex ISNAN
7980 @cindex IEEE, ISNAN
7982 @table @asis
7983 @item @emph{Description}:
7984 @code{ISNAN} tests whether a floating-point value is an IEEE
7985 Not-a-Number (NaN).
7986 @item @emph{Standard}:
7987 GNU extension
7989 @item @emph{Class}:
7990 Elemental function
7992 @item @emph{Syntax}:
7993 @code{ISNAN(X)}
7995 @item @emph{Arguments}:
7996 @multitable @columnfractions .15 .70
7997 @item @var{X} @tab Variable of the type @code{REAL}.
7999 @end multitable
8001 @item @emph{Return value}:
8002 Returns a default-kind @code{LOGICAL}. The returned value is @code{TRUE}
8003 if @var{X} is a NaN and @code{FALSE} otherwise.
8005 @item @emph{Example}:
8006 @smallexample
8007 program test_nan
8008   implicit none
8009   real :: x
8010   x = -1.0
8011   x = sqrt(x)
8012   if (isnan(x)) stop '"x" is a NaN'
8013 end program test_nan
8014 @end smallexample
8015 @end table
8019 @node ITIME
8020 @section @code{ITIME} --- Get current local time subroutine (hour/minutes/seconds) 
8021 @fnindex ITIME
8022 @cindex time, current
8023 @cindex current time
8025 @table @asis
8026 @item @emph{Description}:
8027 @code{IDATE(VALUES)} Fills @var{VALUES} with the numerical values at the  
8028 current local time. The hour (in the range 1-24), minute (in the range 1-60), 
8029 and seconds (in the range 1-60) appear in elements 1, 2, and 3 of @var{VALUES}, 
8030 respectively.
8032 @item @emph{Standard}:
8033 GNU extension
8035 @item @emph{Class}:
8036 Subroutine
8038 @item @emph{Syntax}:
8039 @code{CALL ITIME(VALUES)}
8041 @item @emph{Arguments}:
8042 @multitable @columnfractions .15 .70
8043 @item @var{VALUES} @tab The type shall be @code{INTEGER, DIMENSION(3)}
8044 and the kind shall be the default integer kind.
8045 @end multitable
8047 @item @emph{Return value}:
8048 Does not return anything.
8051 @item @emph{Example}:
8052 @smallexample
8053 program test_itime
8054   integer, dimension(3) :: tarray
8055   call itime(tarray)
8056   print *, tarray(1)
8057   print *, tarray(2)
8058   print *, tarray(3)
8059 end program test_itime
8060 @end smallexample
8061 @end table
8065 @node KILL
8066 @section @code{KILL} --- Send a signal to a process
8067 @fnindex KILL
8069 @table @asis
8070 @item @emph{Description}:
8071 @item @emph{Standard}:
8072 Sends the signal specified by @var{SIGNAL} to the process @var{PID}.
8073 See @code{kill(2)}.
8075 This intrinsic is provided in both subroutine and function forms; however,
8076 only one form can be used in any given program unit.
8078 @item @emph{Class}:
8079 Subroutine, function
8081 @item @emph{Syntax}:
8082 @multitable @columnfractions .80
8083 @item @code{CALL KILL(C, VALUE [, STATUS])}
8084 @item @code{STATUS = KILL(C, VALUE)}
8085 @end multitable
8087 @item @emph{Arguments}:
8088 @multitable @columnfractions .15 .70
8089 @item @var{C} @tab Shall be a scalar @code{INTEGER}, with
8090 @code{INTENT(IN)}
8091 @item @var{VALUE} @tab Shall be a scalar @code{INTEGER}, with
8092 @code{INTENT(IN)}
8093 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)} or
8094 @code{INTEGER(8)}. Returns 0 on success, or a system-specific error code
8095 otherwise.
8096 @end multitable
8098 @item @emph{See also}:
8099 @ref{ABORT}, @ref{EXIT}
8100 @end table
8104 @node KIND
8105 @section @code{KIND} --- Kind of an entity
8106 @fnindex KIND
8107 @cindex kind
8109 @table @asis
8110 @item @emph{Description}:
8111 @code{KIND(X)} returns the kind value of the entity @var{X}.
8113 @item @emph{Standard}:
8114 Fortran 95 and later
8116 @item @emph{Class}:
8117 Inquiry function
8119 @item @emph{Syntax}:
8120 @code{K = KIND(X)}
8122 @item @emph{Arguments}:
8123 @multitable @columnfractions .15 .70
8124 @item @var{X} @tab Shall be of type @code{LOGICAL}, @code{INTEGER},
8125 @code{REAL}, @code{COMPLEX} or @code{CHARACTER}.
8126 @end multitable
8128 @item @emph{Return value}:
8129 The return value is a scalar of type @code{INTEGER} and of the default
8130 integer kind.
8132 @item @emph{Example}:
8133 @smallexample
8134 program test_kind
8135   integer,parameter :: kc = kind(' ')
8136   integer,parameter :: kl = kind(.true.)
8138   print *, "The default character kind is ", kc
8139   print *, "The default logical kind is ", kl
8140 end program test_kind
8141 @end smallexample
8143 @end table
8147 @node LBOUND
8148 @section @code{LBOUND} --- Lower dimension bounds of an array
8149 @fnindex LBOUND
8150 @cindex array, lower bound
8152 @table @asis
8153 @item @emph{Description}:
8154 Returns the lower bounds of an array, or a single lower bound
8155 along the @var{DIM} dimension.
8156 @item @emph{Standard}:
8157 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
8159 @item @emph{Class}:
8160 Inquiry function
8162 @item @emph{Syntax}:
8163 @code{RESULT = LBOUND(ARRAY [, DIM [, KIND]])}
8165 @item @emph{Arguments}:
8166 @multitable @columnfractions .15 .70
8167 @item @var{ARRAY} @tab Shall be an array, of any type.
8168 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
8169 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
8170 expression indicating the kind parameter of the result.
8171 @end multitable
8173 @item @emph{Return value}:
8174 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
8175 @var{KIND} is absent, the return value is of default integer kind.
8176 If @var{DIM} is absent, the result is an array of the lower bounds of
8177 @var{ARRAY}.  If @var{DIM} is present, the result is a scalar
8178 corresponding to the lower bound of the array along that dimension.  If
8179 @var{ARRAY} is an expression rather than a whole array or array
8180 structure component, or if it has a zero extent along the relevant
8181 dimension, the lower bound is taken to be 1.
8183 @item @emph{See also}:
8184 @ref{UBOUND}, @ref{LCOBOUND}
8185 @end table
8189 @node LCOBOUND
8190 @section @code{LCOBOUND} --- Lower codimension bounds of an array
8191 @fnindex LCOBOUND
8192 @cindex coarray, lower bound
8194 @table @asis
8195 @item @emph{Description}:
8196 Returns the lower bounds of a coarray, or a single lower cobound
8197 along the @var{DIM} codimension.
8198 @item @emph{Standard}:
8199 Fortran 2008 and later
8201 @item @emph{Class}:
8202 Inquiry function
8204 @item @emph{Syntax}:
8205 @code{RESULT = LCOBOUND(COARRAY [, DIM [, KIND]])}
8207 @item @emph{Arguments}:
8208 @multitable @columnfractions .15 .70
8209 @item @var{ARRAY} @tab Shall be an coarray, of any type.
8210 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
8211 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
8212 expression indicating the kind parameter of the result.
8213 @end multitable
8215 @item @emph{Return value}:
8216 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
8217 @var{KIND} is absent, the return value is of default integer kind.
8218 If @var{DIM} is absent, the result is an array of the lower cobounds of
8219 @var{COARRAY}.  If @var{DIM} is present, the result is a scalar
8220 corresponding to the lower cobound of the array along that codimension.
8222 @item @emph{See also}:
8223 @ref{UCOBOUND}, @ref{LBOUND}
8224 @end table
8228 @node LEADZ
8229 @section @code{LEADZ} --- Number of leading zero bits of an integer
8230 @fnindex LEADZ
8231 @cindex zero bits
8233 @table @asis
8234 @item @emph{Description}:
8235 @code{LEADZ} returns the number of leading zero bits of an integer.
8237 @item @emph{Standard}:
8238 Fortran 2008 and later
8240 @item @emph{Class}:
8241 Elemental function
8243 @item @emph{Syntax}:
8244 @code{RESULT = LEADZ(I)}
8246 @item @emph{Arguments}:
8247 @multitable @columnfractions .15 .70
8248 @item @var{I} @tab Shall be of type @code{INTEGER}.
8249 @end multitable
8251 @item @emph{Return value}:
8252 The type of the return value is the default @code{INTEGER}.
8253 If all the bits of @code{I} are zero, the result value is @code{BIT_SIZE(I)}.
8255 @item @emph{Example}:
8256 @smallexample
8257 PROGRAM test_leadz
8258   WRITE (*,*) BIT_SIZE(1)  ! prints 32
8259   WRITE (*,*) LEADZ(1)     ! prints 31
8260 END PROGRAM
8261 @end smallexample
8263 @item @emph{See also}:
8264 @ref{BIT_SIZE}, @ref{TRAILZ}, @ref{POPCNT}, @ref{POPPAR}
8265 @end table
8269 @node LEN
8270 @section @code{LEN} --- Length of a character entity
8271 @fnindex LEN
8272 @cindex string, length
8274 @table @asis
8275 @item @emph{Description}:
8276 Returns the length of a character string.  If @var{STRING} is an array,
8277 the length of an element of @var{STRING} is returned.  Note that
8278 @var{STRING} need not be defined when this intrinsic is invoked, since
8279 only the length, not the content, of @var{STRING} is needed.
8281 @item @emph{Standard}:
8282 Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later
8284 @item @emph{Class}:
8285 Inquiry function
8287 @item @emph{Syntax}:
8288 @code{L = LEN(STRING [, KIND])}
8290 @item @emph{Arguments}:
8291 @multitable @columnfractions .15 .70
8292 @item @var{STRING} @tab Shall be a scalar or array of type
8293 @code{CHARACTER}, with @code{INTENT(IN)}
8294 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
8295 expression indicating the kind parameter of the result.
8296 @end multitable
8298 @item @emph{Return value}:
8299 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
8300 @var{KIND} is absent, the return value is of default integer kind.
8303 @item @emph{Specific names}:
8304 @multitable @columnfractions .20 .20 .20 .25
8305 @item Name               @tab Argument          @tab Return type       @tab Standard
8306 @item @code{LEN(STRING)} @tab @code{CHARACTER}  @tab @code{INTEGER}    @tab Fortran 77 and later
8307 @end multitable
8310 @item @emph{See also}:
8311 @ref{LEN_TRIM}, @ref{ADJUSTL}, @ref{ADJUSTR}
8312 @end table
8316 @node LEN_TRIM
8317 @section @code{LEN_TRIM} --- Length of a character entity without trailing blank characters
8318 @fnindex LEN_TRIM
8319 @cindex string, length, without trailing whitespace
8321 @table @asis
8322 @item @emph{Description}:
8323 Returns the length of a character string, ignoring any trailing blanks.
8325 @item @emph{Standard}:
8326 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
8328 @item @emph{Class}:
8329 Elemental function
8331 @item @emph{Syntax}:
8332 @code{RESULT = LEN_TRIM(STRING [, KIND])}
8334 @item @emph{Arguments}:
8335 @multitable @columnfractions .15 .70
8336 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER},
8337 with @code{INTENT(IN)}
8338 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
8339 expression indicating the kind parameter of the result.
8340 @end multitable
8342 @item @emph{Return value}:
8343 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
8344 @var{KIND} is absent, the return value is of default integer kind.
8346 @item @emph{See also}:
8347 @ref{LEN}, @ref{ADJUSTL}, @ref{ADJUSTR}
8348 @end table
8352 @node LGE
8353 @section @code{LGE} --- Lexical greater than or equal
8354 @fnindex LGE
8355 @cindex lexical comparison of strings
8356 @cindex string, comparison
8358 @table @asis
8359 @item @emph{Description}:
8360 Determines whether one string is lexically greater than or equal to
8361 another string, where the two strings are interpreted as containing
8362 ASCII character codes.  If the String A and String B are not the same
8363 length, the shorter is compared as if spaces were appended to it to form
8364 a value that has the same length as the longer.
8366 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
8367 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
8368 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
8369 that the latter use the processor's character ordering (which is not
8370 ASCII on some targets), whereas the former always use the ASCII
8371 ordering.
8373 @item @emph{Standard}:
8374 Fortran 77 and later
8376 @item @emph{Class}:
8377 Elemental function
8379 @item @emph{Syntax}:
8380 @code{RESULT = LGE(STRING_A, STRING_B)}
8382 @item @emph{Arguments}:
8383 @multitable @columnfractions .15 .70
8384 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
8385 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
8386 @end multitable
8388 @item @emph{Return value}:
8389 Returns @code{.TRUE.} if @code{STRING_A >= STRING_B}, and @code{.FALSE.}
8390 otherwise, based on the ASCII ordering.
8392 @item @emph{Specific names}:
8393 @multitable @columnfractions .20 .20 .20 .25
8394 @item Name                           @tab Argument          @tab Return type       @tab Standard
8395 @item @code{LGE(STRING_A, STRING_B)} @tab @code{CHARACTER}  @tab @code{LOGICAL}    @tab Fortran 77 and later
8396 @end multitable
8398 @item @emph{See also}:
8399 @ref{LGT}, @ref{LLE}, @ref{LLT}
8400 @end table
8404 @node LGT
8405 @section @code{LGT} --- Lexical greater than
8406 @fnindex LGT
8407 @cindex lexical comparison of strings
8408 @cindex string, comparison
8410 @table @asis
8411 @item @emph{Description}:
8412 Determines whether one string is lexically greater than another string,
8413 where the two strings are interpreted as containing ASCII character
8414 codes.  If the String A and String B are not the same length, the
8415 shorter is compared as if spaces were appended to it to form a value
8416 that has the same length as the longer.
8418 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
8419 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
8420 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
8421 that the latter use the processor's character ordering (which is not
8422 ASCII on some targets), whereas the former always use the ASCII
8423 ordering.
8425 @item @emph{Standard}:
8426 Fortran 77 and later
8428 @item @emph{Class}:
8429 Elemental function
8431 @item @emph{Syntax}:
8432 @code{RESULT = LGT(STRING_A, STRING_B)}
8434 @item @emph{Arguments}:
8435 @multitable @columnfractions .15 .70
8436 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
8437 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
8438 @end multitable
8440 @item @emph{Return value}:
8441 Returns @code{.TRUE.} if @code{STRING_A > STRING_B}, and @code{.FALSE.}
8442 otherwise, based on the ASCII ordering.
8444 @item @emph{Specific names}:
8445 @multitable @columnfractions .20 .20 .20 .25
8446 @item Name                           @tab Argument          @tab Return type       @tab Standard
8447 @item @code{LGT(STRING_A, STRING_B)} @tab @code{CHARACTER}  @tab @code{LOGICAL}    @tab Fortran 77 and later
8448 @end multitable
8450 @item @emph{See also}:
8451 @ref{LGE}, @ref{LLE}, @ref{LLT}
8452 @end table
8456 @node LINK
8457 @section @code{LINK} --- Create a hard link
8458 @fnindex LINK
8459 @cindex file system, create link
8460 @cindex file system, hard link
8462 @table @asis
8463 @item @emph{Description}:
8464 Makes a (hard) link from file @var{PATH1} to @var{PATH2}. A null
8465 character (@code{CHAR(0)}) can be used to mark the end of the names in
8466 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
8467 names are ignored.  If the @var{STATUS} argument is supplied, it
8468 contains 0 on success or a nonzero error code upon return; see
8469 @code{link(2)}.
8471 This intrinsic is provided in both subroutine and function forms;
8472 however, only one form can be used in any given program unit.
8474 @item @emph{Standard}:
8475 GNU extension
8477 @item @emph{Class}:
8478 Subroutine, function
8480 @item @emph{Syntax}:
8481 @multitable @columnfractions .80
8482 @item @code{CALL LINK(PATH1, PATH2 [, STATUS])}
8483 @item @code{STATUS = LINK(PATH1, PATH2)}
8484 @end multitable
8486 @item @emph{Arguments}:
8487 @multitable @columnfractions .15 .70
8488 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
8489 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
8490 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
8491 @end multitable
8493 @item @emph{See also}:
8494 @ref{SYMLNK}, @ref{UNLINK}
8495 @end table
8499 @node LLE
8500 @section @code{LLE} --- Lexical less than or equal
8501 @fnindex LLE
8502 @cindex lexical comparison of strings
8503 @cindex string, comparison
8505 @table @asis
8506 @item @emph{Description}:
8507 Determines whether one string is lexically less than or equal to another
8508 string, where the two strings are interpreted as containing ASCII
8509 character codes.  If the String A and String B are not the same length,
8510 the shorter is compared as if spaces were appended to it to form a value
8511 that has the same length as the longer.
8513 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
8514 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
8515 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
8516 that the latter use the processor's character ordering (which is not
8517 ASCII on some targets), whereas the former always use the ASCII
8518 ordering.
8520 @item @emph{Standard}:
8521 Fortran 77 and later
8523 @item @emph{Class}:
8524 Elemental function
8526 @item @emph{Syntax}:
8527 @code{RESULT = LLE(STRING_A, STRING_B)}
8529 @item @emph{Arguments}:
8530 @multitable @columnfractions .15 .70
8531 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
8532 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
8533 @end multitable
8535 @item @emph{Return value}:
8536 Returns @code{.TRUE.} if @code{STRING_A <= STRING_B}, and @code{.FALSE.}
8537 otherwise, based on the ASCII ordering.
8539 @item @emph{Specific names}:
8540 @multitable @columnfractions .20 .20 .20 .25
8541 @item Name                           @tab Argument          @tab Return type       @tab Standard
8542 @item @code{LLE(STRING_A, STRING_B)} @tab @code{CHARACTER}  @tab @code{LOGICAL}    @tab Fortran 77 and later
8543 @end multitable
8545 @item @emph{See also}:
8546 @ref{LGE}, @ref{LGT}, @ref{LLT}
8547 @end table
8551 @node LLT
8552 @section @code{LLT} --- Lexical less than
8553 @fnindex LLT
8554 @cindex lexical comparison of strings
8555 @cindex string, comparison
8557 @table @asis
8558 @item @emph{Description}:
8559 Determines whether one string is lexically less than another string,
8560 where the two strings are interpreted as containing ASCII character
8561 codes.  If the String A and String B are not the same length, the
8562 shorter is compared as if spaces were appended to it to form a value
8563 that has the same length as the longer.
8565 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
8566 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
8567 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
8568 that the latter use the processor's character ordering (which is not
8569 ASCII on some targets), whereas the former always use the ASCII
8570 ordering.
8572 @item @emph{Standard}:
8573 Fortran 77 and later
8575 @item @emph{Class}:
8576 Elemental function
8578 @item @emph{Syntax}:
8579 @code{RESULT = LLT(STRING_A, STRING_B)}
8581 @item @emph{Arguments}:
8582 @multitable @columnfractions .15 .70
8583 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
8584 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
8585 @end multitable
8587 @item @emph{Return value}:
8588 Returns @code{.TRUE.} if @code{STRING_A < STRING_B}, and @code{.FALSE.}
8589 otherwise, based on the ASCII ordering.
8591 @item @emph{Specific names}:
8592 @multitable @columnfractions .20 .20 .20 .25
8593 @item Name                           @tab Argument          @tab Return type       @tab Standard
8594 @item @code{LLT(STRING_A, STRING_B)} @tab @code{CHARACTER}  @tab @code{LOGICAL}    @tab Fortran 77 and later
8595 @end multitable
8597 @item @emph{See also}:
8598 @ref{LGE}, @ref{LGT}, @ref{LLE}
8599 @end table
8603 @node LNBLNK
8604 @section @code{LNBLNK} --- Index of the last non-blank character in a string
8605 @fnindex LNBLNK
8606 @cindex string, find non-blank character
8608 @table @asis
8609 @item @emph{Description}:
8610 Returns the length of a character string, ignoring any trailing blanks.
8611 This is identical to the standard @code{LEN_TRIM} intrinsic, and is only
8612 included for backwards compatibility.
8614 @item @emph{Standard}:
8615 GNU extension
8617 @item @emph{Class}:
8618 Elemental function
8620 @item @emph{Syntax}:
8621 @code{RESULT = LNBLNK(STRING)}
8623 @item @emph{Arguments}:
8624 @multitable @columnfractions .15 .70
8625 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER},
8626 with @code{INTENT(IN)}
8627 @end multitable
8629 @item @emph{Return value}:
8630 The return value is of @code{INTEGER(kind=4)} type.
8632 @item @emph{See also}:
8633 @ref{INDEX intrinsic}, @ref{LEN_TRIM}
8634 @end table
8638 @node LOC
8639 @section @code{LOC} --- Returns the address of a variable
8640 @fnindex LOC
8641 @cindex location of a variable in memory
8643 @table @asis
8644 @item @emph{Description}:
8645 @code{LOC(X)} returns the address of @var{X} as an integer.
8647 @item @emph{Standard}:
8648 GNU extension
8650 @item @emph{Class}:
8651 Inquiry function
8653 @item @emph{Syntax}:
8654 @code{RESULT = LOC(X)}
8656 @item @emph{Arguments}:
8657 @multitable @columnfractions .15 .70
8658 @item @var{X} @tab Variable of any type.
8659 @end multitable
8661 @item @emph{Return value}:
8662 The return value is of type @code{INTEGER}, with a @code{KIND}
8663 corresponding to the size (in bytes) of a memory address on the target
8664 machine.
8666 @item @emph{Example}:
8667 @smallexample
8668 program test_loc
8669   integer :: i
8670   real :: r
8671   i = loc(r)
8672   print *, i
8673 end program test_loc
8674 @end smallexample
8675 @end table
8679 @node LOG
8680 @section @code{LOG} --- Natural logarithm function
8681 @fnindex LOG
8682 @fnindex ALOG
8683 @fnindex DLOG
8684 @fnindex CLOG
8685 @fnindex ZLOG
8686 @fnindex CDLOG
8687 @cindex exponential function, inverse
8688 @cindex logarithm function
8689 @cindex natural logarithm function
8691 @table @asis
8692 @item @emph{Description}:
8693 @code{LOG(X)} computes the natural logarithm of @var{X}, i.e. the
8694 logarithm to the base @math{e}.
8696 @item @emph{Standard}:
8697 Fortran 77 and later
8699 @item @emph{Class}:
8700 Elemental function
8702 @item @emph{Syntax}:
8703 @code{RESULT = LOG(X)}
8705 @item @emph{Arguments}:
8706 @multitable @columnfractions .15 .70
8707 @item @var{X} @tab The type shall be @code{REAL} or
8708 @code{COMPLEX}.
8709 @end multitable
8711 @item @emph{Return value}:
8712 The return value is of type @code{REAL} or @code{COMPLEX}.
8713 The kind type parameter is the same as @var{X}.
8714 If @var{X} is @code{COMPLEX}, the imaginary part @math{\omega} is in the range
8715 @math{-\pi \leq \omega \leq \pi}.
8717 @item @emph{Example}:
8718 @smallexample
8719 program test_log
8720   real(8) :: x = 2.7182818284590451_8
8721   complex :: z = (1.0, 2.0)
8722   x = log(x)    ! will yield (approximately) 1
8723   z = log(z)
8724 end program test_log
8725 @end smallexample
8727 @item @emph{Specific names}:
8728 @multitable @columnfractions .20 .20 .20 .25
8729 @item Name            @tab Argument          @tab Return type       @tab Standard
8730 @item @code{ALOG(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab f95, gnu
8731 @item @code{DLOG(X)}  @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab f95, gnu
8732 @item @code{CLOG(X)}  @tab @code{COMPLEX(4) X}  @tab @code{COMPLEX(4)}    @tab f95, gnu
8733 @item @code{ZLOG(X)}  @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab f95, gnu
8734 @item @code{CDLOG(X)} @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab f95, gnu
8735 @end multitable
8736 @end table
8740 @node LOG10
8741 @section @code{LOG10} --- Base 10 logarithm function
8742 @fnindex LOG10
8743 @fnindex ALOG10
8744 @fnindex DLOG10
8745 @cindex exponential function, inverse
8746 @cindex logarithm function with base 10
8747 @cindex base 10 logarithm function
8749 @table @asis
8750 @item @emph{Description}:
8751 @code{LOG10(X)} computes the base 10 logarithm of @var{X}.
8753 @item @emph{Standard}:
8754 Fortran 77 and later
8756 @item @emph{Class}:
8757 Elemental function
8759 @item @emph{Syntax}:
8760 @code{RESULT = LOG10(X)}
8762 @item @emph{Arguments}:
8763 @multitable @columnfractions .15 .70
8764 @item @var{X} @tab The type shall be @code{REAL}.
8765 @end multitable
8767 @item @emph{Return value}:
8768 The return value is of type @code{REAL} or @code{COMPLEX}.
8769 The kind type parameter is the same as @var{X}.
8771 @item @emph{Example}:
8772 @smallexample
8773 program test_log10
8774   real(8) :: x = 10.0_8
8775   x = log10(x)
8776 end program test_log10
8777 @end smallexample
8779 @item @emph{Specific names}:
8780 @multitable @columnfractions .20 .20 .20 .25
8781 @item Name            @tab Argument          @tab Return type       @tab Standard
8782 @item @code{ALOG10(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab Fortran 95 and later
8783 @item @code{DLOG10(X)}  @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab Fortran 95 and later
8784 @end multitable
8785 @end table
8789 @node LOG_GAMMA
8790 @section @code{LOG_GAMMA} --- Logarithm of the Gamma function
8791 @fnindex LOG_GAMMA
8792 @fnindex LGAMMA
8793 @fnindex ALGAMA
8794 @fnindex DLGAMA
8795 @cindex Gamma function, logarithm of
8797 @table @asis
8798 @item @emph{Description}:
8799 @code{LOG_GAMMA(X)} computes the natural logarithm of the absolute value
8800 of the Gamma (@math{\Gamma}) function.
8802 @item @emph{Standard}:
8803 Fortran 2008 and later
8805 @item @emph{Class}:
8806 Elemental function
8808 @item @emph{Syntax}:
8809 @code{X = LOG_GAMMA(X)}
8811 @item @emph{Arguments}:
8812 @multitable @columnfractions .15 .70
8813 @item @var{X} @tab Shall be of type @code{REAL} and neither zero
8814 nor a negative integer.
8815 @end multitable
8817 @item @emph{Return value}:
8818 The return value is of type @code{REAL} of the same kind as @var{X}.
8820 @item @emph{Example}:
8821 @smallexample
8822 program test_log_gamma
8823   real :: x = 1.0
8824   x = lgamma(x) ! returns 0.0
8825 end program test_log_gamma
8826 @end smallexample
8828 @item @emph{Specific names}:
8829 @multitable @columnfractions .20 .20 .20 .25
8830 @item Name             @tab Argument         @tab Return type       @tab Standard
8831 @item @code{LGAMMA(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)}    @tab GNU Extension
8832 @item @code{ALGAMA(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)}    @tab GNU Extension
8833 @item @code{DLGAMA(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)}    @tab GNU Extension
8834 @end multitable
8836 @item @emph{See also}:
8837 Gamma function: @ref{GAMMA}
8839 @end table
8843 @node LOGICAL
8844 @section @code{LOGICAL} --- Convert to logical type
8845 @fnindex LOGICAL
8846 @cindex conversion, to logical
8848 @table @asis
8849 @item @emph{Description}:
8850 Converts one kind of @code{LOGICAL} variable to another.
8852 @item @emph{Standard}:
8853 Fortran 95 and later
8855 @item @emph{Class}:
8856 Elemental function
8858 @item @emph{Syntax}:
8859 @code{RESULT = LOGICAL(L [, KIND])}
8861 @item @emph{Arguments}:
8862 @multitable @columnfractions .15 .70
8863 @item @var{L}    @tab The type shall be @code{LOGICAL}.
8864 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
8865 expression indicating the kind parameter of the result.
8866 @end multitable
8868 @item @emph{Return value}:
8869 The return value is a @code{LOGICAL} value equal to @var{L}, with a
8870 kind corresponding to @var{KIND}, or of the default logical kind if
8871 @var{KIND} is not given.
8873 @item @emph{See also}:
8874 @ref{INT}, @ref{REAL}, @ref{CMPLX}
8875 @end table
8879 @node LONG
8880 @section @code{LONG} --- Convert to integer type
8881 @fnindex LONG
8882 @cindex conversion, to integer
8884 @table @asis
8885 @item @emph{Description}:
8886 Convert to a @code{KIND=4} integer type, which is the same size as a C
8887 @code{long} integer.  This is equivalent to the standard @code{INT}
8888 intrinsic with an optional argument of @code{KIND=4}, and is only
8889 included for backwards compatibility.
8891 @item @emph{Standard}:
8892 GNU extension
8894 @item @emph{Class}:
8895 Elemental function
8897 @item @emph{Syntax}:
8898 @code{RESULT = LONG(A)}
8900 @item @emph{Arguments}:
8901 @multitable @columnfractions .15 .70
8902 @item @var{A}    @tab Shall be of type @code{INTEGER},
8903 @code{REAL}, or @code{COMPLEX}.
8904 @end multitable
8906 @item @emph{Return value}:
8907 The return value is a @code{INTEGER(4)} variable.
8909 @item @emph{See also}:
8910 @ref{INT}, @ref{INT2}, @ref{INT8}
8911 @end table
8915 @node LSHIFT
8916 @section @code{LSHIFT} --- Left shift bits
8917 @fnindex LSHIFT
8918 @cindex bits, shift left
8920 @table @asis
8921 @item @emph{Description}:
8922 @code{LSHIFT} returns a value corresponding to @var{I} with all of the
8923 bits shifted left by @var{SHIFT} places.  If the absolute value of
8924 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined. 
8925 Bits shifted out from the left end are lost; zeros are shifted in from
8926 the opposite end.
8928 This function has been superseded by the @code{ISHFT} intrinsic, which
8929 is standard in Fortran 95 and later, and the @code{SHIFTL} intrinsic,
8930 which is standard in Fortran 2008 and later.
8932 @item @emph{Standard}:
8933 GNU extension
8935 @item @emph{Class}:
8936 Elemental function
8938 @item @emph{Syntax}:
8939 @code{RESULT = LSHIFT(I, SHIFT)}
8941 @item @emph{Arguments}:
8942 @multitable @columnfractions .15 .70
8943 @item @var{I} @tab The type shall be @code{INTEGER}.
8944 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
8945 @end multitable
8947 @item @emph{Return value}:
8948 The return value is of type @code{INTEGER} and of the same kind as
8949 @var{I}.
8951 @item @emph{See also}:
8952 @ref{ISHFT}, @ref{ISHFTC}, @ref{RSHIFT}, @ref{SHIFTA}, @ref{SHIFTL},
8953 @ref{SHIFTR}
8955 @end table
8959 @node LSTAT
8960 @section @code{LSTAT} --- Get file status
8961 @fnindex LSTAT
8962 @cindex file system, file status
8964 @table @asis
8965 @item @emph{Description}:
8966 @code{LSTAT} is identical to @ref{STAT}, except that if path is a
8967 symbolic link, then the link itself is statted, not the file that it
8968 refers to.
8970 The elements in @code{VALUES} are the same as described by @ref{STAT}.
8972 This intrinsic is provided in both subroutine and function forms;
8973 however, only one form can be used in any given program unit.
8975 @item @emph{Standard}:
8976 GNU extension
8978 @item @emph{Class}:
8979 Subroutine, function
8981 @item @emph{Syntax}:
8982 @multitable @columnfractions .80
8983 @item @code{CALL LSTAT(NAME, VALUES [, STATUS])}
8984 @item @code{STATUS = LSTAT(NAME, VALUES)}
8985 @end multitable
8987 @item @emph{Arguments}:
8988 @multitable @columnfractions .15 .70
8989 @item @var{NAME}   @tab The type shall be @code{CHARACTER} of the default
8990 kind, a valid path within the file system.
8991 @item @var{VALUES} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
8992 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}.
8993 Returns 0 on success and a system specific error code otherwise.
8994 @end multitable
8996 @item @emph{Example}:
8997 See @ref{STAT} for an example.
8999 @item @emph{See also}:
9000 To stat an open file: @ref{FSTAT}, to stat a file: @ref{STAT}
9001 @end table
9005 @node LTIME
9006 @section @code{LTIME} --- Convert time to local time info
9007 @fnindex LTIME
9008 @cindex time, conversion to local time info
9010 @table @asis
9011 @item @emph{Description}:
9012 Given a system time value @var{TIME} (as provided by the @code{TIME8}
9013 intrinsic), fills @var{VALUES} with values extracted from it appropriate
9014 to the local time zone using @code{localtime(3)}.
9016 @item @emph{Standard}:
9017 GNU extension
9019 @item @emph{Class}:
9020 Subroutine
9022 @item @emph{Syntax}:
9023 @code{CALL LTIME(TIME, VALUES)}
9025 @item @emph{Arguments}:
9026 @multitable @columnfractions .15 .70
9027 @item @var{TIME}  @tab An @code{INTEGER} scalar expression
9028 corresponding to a system time, with @code{INTENT(IN)}.
9029 @item @var{VALUES} @tab A default @code{INTEGER} array with 9 elements,
9030 with @code{INTENT(OUT)}.
9031 @end multitable
9033 @item @emph{Return value}:
9034 The elements of @var{VALUES} are assigned as follows:
9035 @enumerate
9036 @item Seconds after the minute, range 0--59 or 0--61 to allow for leap
9037 seconds
9038 @item Minutes after the hour, range 0--59
9039 @item Hours past midnight, range 0--23
9040 @item Day of month, range 0--31
9041 @item Number of months since January, range 0--12
9042 @item Years since 1900
9043 @item Number of days since Sunday, range 0--6
9044 @item Days since January 1
9045 @item Daylight savings indicator: positive if daylight savings is in
9046 effect, zero if not, and negative if the information is not available.
9047 @end enumerate
9049 @item @emph{See also}:
9050 @ref{CTIME}, @ref{GMTIME}, @ref{TIME}, @ref{TIME8}
9052 @end table
9056 @node MALLOC
9057 @section @code{MALLOC} --- Allocate dynamic memory
9058 @fnindex MALLOC
9059 @cindex pointer, cray
9061 @table @asis
9062 @item @emph{Description}:
9063 @code{MALLOC(SIZE)} allocates @var{SIZE} bytes of dynamic memory and
9064 returns the address of the allocated memory. The @code{MALLOC} intrinsic
9065 is an extension intended to be used with Cray pointers, and is provided
9066 in GNU Fortran to allow the user to compile legacy code. For new code
9067 using Fortran 95 pointers, the memory allocation intrinsic is
9068 @code{ALLOCATE}.
9070 @item @emph{Standard}:
9071 GNU extension
9073 @item @emph{Class}:
9074 Function
9076 @item @emph{Syntax}:
9077 @code{PTR = MALLOC(SIZE)}
9079 @item @emph{Arguments}:
9080 @multitable @columnfractions .15 .70
9081 @item @var{SIZE} @tab The type shall be @code{INTEGER}.
9082 @end multitable
9084 @item @emph{Return value}:
9085 The return value is of type @code{INTEGER(K)}, with @var{K} such that
9086 variables of type @code{INTEGER(K)} have the same size as
9087 C pointers (@code{sizeof(void *)}).
9089 @item @emph{Example}:
9090 The following example demonstrates the use of @code{MALLOC} and
9091 @code{FREE} with Cray pointers.
9093 @smallexample
9094 program test_malloc
9095   implicit none
9096   integer i
9097   real*8 x(*), z
9098   pointer(ptr_x,x)
9100   ptr_x = malloc(20*8)
9101   do i = 1, 20
9102     x(i) = sqrt(1.0d0 / i)
9103   end do
9104   z = 0
9105   do i = 1, 20
9106     z = z + x(i)
9107     print *, z
9108   end do
9109   call free(ptr_x)
9110 end program test_malloc
9111 @end smallexample
9113 @item @emph{See also}:
9114 @ref{FREE}
9115 @end table
9119 @node MASKL
9120 @section @code{MASKL} --- Left justified mask
9121 @fnindex MASKL
9122 @cindex mask, left justified
9124 @table @asis
9125 @item @emph{Description}:
9126 @code{MASKL(I[, KIND])} has its leftmost @var{I} bits set to 1, and the
9127 remaining bits set to 0.
9129 @item @emph{Standard}:
9130 Fortran 2008 and later
9132 @item @emph{Class}:
9133 Elemental function
9135 @item @emph{Syntax}:
9136 @code{RESULT = MASKL(I[, KIND])}
9138 @item @emph{Arguments}:
9139 @multitable @columnfractions .15 .70
9140 @item @var{I} @tab Shall be of type @code{INTEGER}.
9141 @item @var{KIND} @tab Shall be a scalar constant expression of type
9142 @code{INTEGER}.
9143 @end multitable
9145 @item @emph{Return value}:
9146 The return value is of type @code{INTEGER}. If @var{KIND} is present, it
9147 specifies the kind value of the return type; otherwise, it is of the
9148 default integer kind.
9150 @item @emph{See also}:
9151 @ref{MASKR}
9152 @end table
9156 @node MASKR
9157 @section @code{MASKR} --- Right justified mask
9158 @fnindex MASKR
9159 @cindex mask, right justified
9161 @table @asis
9162 @item @emph{Description}:
9163 @code{MASKL(I[, KIND])} has its rightmost @var{I} bits set to 1, and the
9164 remaining bits set to 0.
9166 @item @emph{Standard}:
9167 Fortran 2008 and later
9169 @item @emph{Class}:
9170 Elemental function
9172 @item @emph{Syntax}:
9173 @code{RESULT = MASKR(I[, KIND])}
9175 @item @emph{Arguments}:
9176 @multitable @columnfractions .15 .70
9177 @item @var{I} @tab Shall be of type @code{INTEGER}.
9178 @item @var{KIND} @tab Shall be a scalar constant expression of type
9179 @code{INTEGER}.
9180 @end multitable
9182 @item @emph{Return value}:
9183 The return value is of type @code{INTEGER}. If @var{KIND} is present, it
9184 specifies the kind value of the return type; otherwise, it is of the
9185 default integer kind.
9187 @item @emph{See also}:
9188 @ref{MASKL}
9189 @end table
9193 @node MATMUL
9194 @section @code{MATMUL} --- matrix multiplication
9195 @fnindex MATMUL
9196 @cindex matrix multiplication
9197 @cindex product, matrix
9199 @table @asis
9200 @item @emph{Description}:
9201 Performs a matrix multiplication on numeric or logical arguments.
9203 @item @emph{Standard}:
9204 Fortran 95 and later
9206 @item @emph{Class}:
9207 Transformational function
9209 @item @emph{Syntax}:
9210 @code{RESULT = MATMUL(MATRIX_A, MATRIX_B)}
9212 @item @emph{Arguments}:
9213 @multitable @columnfractions .15 .70
9214 @item @var{MATRIX_A} @tab An array of @code{INTEGER},
9215 @code{REAL}, @code{COMPLEX}, or @code{LOGICAL} type, with a rank of
9216 one or two.
9217 @item @var{MATRIX_B} @tab An array of @code{INTEGER},
9218 @code{REAL}, or @code{COMPLEX} type if @var{MATRIX_A} is of a numeric
9219 type; otherwise, an array of @code{LOGICAL} type. The rank shall be one
9220 or two, and the first (or only) dimension of @var{MATRIX_B} shall be
9221 equal to the last (or only) dimension of @var{MATRIX_A}.
9222 @end multitable
9224 @item @emph{Return value}:
9225 The matrix product of @var{MATRIX_A} and @var{MATRIX_B}.  The type and
9226 kind of the result follow the usual type and kind promotion rules, as
9227 for the @code{*} or @code{.AND.} operators.
9229 @item @emph{See also}:
9230 @end table
9234 @node MAX
9235 @section @code{MAX} --- Maximum value of an argument list
9236 @fnindex MAX
9237 @fnindex MAX0
9238 @fnindex AMAX0
9239 @fnindex MAX1
9240 @fnindex AMAX1
9241 @fnindex DMAX1
9242 @cindex maximum value
9244 @table @asis
9245 @item @emph{Description}:
9246 Returns the argument with the largest (most positive) value.
9248 @item @emph{Standard}:
9249 Fortran 77 and later
9251 @item @emph{Class}:
9252 Elemental function
9254 @item @emph{Syntax}:
9255 @code{RESULT = MAX(A1, A2 [, A3 [, ...]])}
9257 @item @emph{Arguments}:
9258 @multitable @columnfractions .15 .70
9259 @item @var{A1}          @tab The type shall be @code{INTEGER} or
9260 @code{REAL}.
9261 @item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
9262 as @var{A1}.  (As a GNU extension, arguments of different kinds are
9263 permitted.)
9264 @end multitable
9266 @item @emph{Return value}:
9267 The return value corresponds to the maximum value among the arguments,
9268 and has the same type and kind as the first argument.
9270 @item @emph{Specific names}:
9271 @multitable @columnfractions .20 .20 .20 .25
9272 @item Name             @tab Argument             @tab Return type         @tab Standard
9273 @item @code{MAX0(A1)}  @tab @code{INTEGER(4) A1} @tab @code{INTEGER(4)}   @tab Fortran 77 and later
9274 @item @code{AMAX0(A1)} @tab @code{INTEGER(4) A1} @tab @code{REAL(MAX(X))} @tab Fortran 77 and later
9275 @item @code{MAX1(A1)}  @tab @code{REAL A1}       @tab @code{INT(MAX(X))}  @tab Fortran 77 and later
9276 @item @code{AMAX1(A1)} @tab @code{REAL(4) A1}    @tab @code{REAL(4)}      @tab Fortran 77 and later
9277 @item @code{DMAX1(A1)} @tab @code{REAL(8) A1}    @tab @code{REAL(8)}      @tab Fortran 77 and later
9278 @end multitable
9280 @item @emph{See also}:
9281 @ref{MAXLOC} @ref{MAXVAL}, @ref{MIN}
9283 @end table
9287 @node MAXEXPONENT
9288 @section @code{MAXEXPONENT} --- Maximum exponent of a real kind
9289 @fnindex MAXEXPONENT
9290 @cindex model representation, maximum exponent
9292 @table @asis
9293 @item @emph{Description}:
9294 @code{MAXEXPONENT(X)} returns the maximum exponent in the model of the
9295 type of @code{X}.
9297 @item @emph{Standard}:
9298 Fortran 95 and later
9300 @item @emph{Class}:
9301 Inquiry function
9303 @item @emph{Syntax}:
9304 @code{RESULT = MAXEXPONENT(X)}
9306 @item @emph{Arguments}:
9307 @multitable @columnfractions .15 .70
9308 @item @var{X} @tab Shall be of type @code{REAL}.
9309 @end multitable
9311 @item @emph{Return value}:
9312 The return value is of type @code{INTEGER} and of the default integer
9313 kind.
9315 @item @emph{Example}:
9316 @smallexample
9317 program exponents
9318   real(kind=4) :: x
9319   real(kind=8) :: y
9321   print *, minexponent(x), maxexponent(x)
9322   print *, minexponent(y), maxexponent(y)
9323 end program exponents
9324 @end smallexample
9325 @end table
9329 @node MAXLOC
9330 @section @code{MAXLOC} --- Location of the maximum value within an array
9331 @fnindex MAXLOC
9332 @cindex array, location of maximum element
9334 @table @asis
9335 @item @emph{Description}:
9336 Determines the location of the element in the array with the maximum
9337 value, or, if the @var{DIM} argument is supplied, determines the
9338 locations of the maximum element along each row of the array in the
9339 @var{DIM} direction.  If @var{MASK} is present, only the elements for
9340 which @var{MASK} is @code{.TRUE.} are considered.  If more than one
9341 element in the array has the maximum value, the location returned is
9342 that of the first such element in array element order.  If the array has
9343 zero size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
9344 the result is an array of zeroes.  Similarly, if @var{DIM} is supplied
9345 and all of the elements of @var{MASK} along a given row are zero, the
9346 result value for that row is zero.
9348 @item @emph{Standard}:
9349 Fortran 95 and later
9351 @item @emph{Class}:
9352 Transformational function
9354 @item @emph{Syntax}:
9355 @multitable @columnfractions .80
9356 @item @code{RESULT = MAXLOC(ARRAY, DIM [, MASK])}
9357 @item @code{RESULT = MAXLOC(ARRAY [, MASK])}
9358 @end multitable
9360 @item @emph{Arguments}:
9361 @multitable @columnfractions .15 .70
9362 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or
9363 @code{REAL}.
9364 @item @var{DIM}   @tab (Optional) Shall be a scalar of type
9365 @code{INTEGER}, with a value between one and the rank of @var{ARRAY},
9366 inclusive.  It may not be an optional dummy argument.
9367 @item @var{MASK}  @tab Shall be an array of type @code{LOGICAL},
9368 and conformable with @var{ARRAY}.
9369 @end multitable
9371 @item @emph{Return value}:
9372 If @var{DIM} is absent, the result is a rank-one array with a length
9373 equal to the rank of @var{ARRAY}.  If @var{DIM} is present, the result
9374 is an array with a rank one less than the rank of @var{ARRAY}, and a
9375 size corresponding to the size of @var{ARRAY} with the @var{DIM}
9376 dimension removed.  If @var{DIM} is present and @var{ARRAY} has a rank
9377 of one, the result is a scalar.  In all cases, the result is of default
9378 @code{INTEGER} type.
9380 @item @emph{See also}:
9381 @ref{MAX}, @ref{MAXVAL}
9383 @end table
9387 @node MAXVAL
9388 @section @code{MAXVAL} --- Maximum value of an array
9389 @fnindex MAXVAL
9390 @cindex array, maximum value
9391 @cindex maximum value
9393 @table @asis
9394 @item @emph{Description}:
9395 Determines the maximum value of the elements in an array value, or, if
9396 the @var{DIM} argument is supplied, determines the maximum value along
9397 each row of the array in the @var{DIM} direction.  If @var{MASK} is
9398 present, only the elements for which @var{MASK} is @code{.TRUE.} are
9399 considered.  If the array has zero size, or all of the elements of
9400 @var{MASK} are @code{.FALSE.}, then the result is @code{-HUGE(ARRAY)}
9401 if @var{ARRAY} is numeric, or a string of nulls if @var{ARRAY} is of character
9402 type.
9404 @item @emph{Standard}:
9405 Fortran 95 and later
9407 @item @emph{Class}:
9408 Transformational function
9410 @item @emph{Syntax}:
9411 @multitable @columnfractions .80
9412 @item @code{RESULT = MAXVAL(ARRAY, DIM [, MASK])}
9413 @item @code{RESULT = MAXVAL(ARRAY [, MASK])}
9414 @end multitable
9416 @item @emph{Arguments}:
9417 @multitable @columnfractions .15 .70
9418 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or
9419 @code{REAL}.
9420 @item @var{DIM}   @tab (Optional) Shall be a scalar of type
9421 @code{INTEGER}, with a value between one and the rank of @var{ARRAY},
9422 inclusive.  It may not be an optional dummy argument.
9423 @item @var{MASK}  @tab Shall be an array of type @code{LOGICAL},
9424 and conformable with @var{ARRAY}.
9425 @end multitable
9427 @item @emph{Return value}:
9428 If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
9429 is a scalar.  If @var{DIM} is present, the result is an array with a
9430 rank one less than the rank of @var{ARRAY}, and a size corresponding to
9431 the size of @var{ARRAY} with the @var{DIM} dimension removed.  In all
9432 cases, the result is of the same type and kind as @var{ARRAY}.
9434 @item @emph{See also}:
9435 @ref{MAX}, @ref{MAXLOC}
9436 @end table
9440 @node MCLOCK
9441 @section @code{MCLOCK} --- Time function
9442 @fnindex MCLOCK
9443 @cindex time, clock ticks
9444 @cindex clock ticks
9446 @table @asis
9447 @item @emph{Description}:
9448 Returns the number of clock ticks since the start of the process, based
9449 on the function @code{clock(3)} in the C standard library.
9451 This intrinsic is not fully portable, such as to systems with 32-bit
9452 @code{INTEGER} types but supporting times wider than 32 bits. Therefore,
9453 the values returned by this intrinsic might be, or become, negative, or
9454 numerically less than previous values, during a single run of the
9455 compiled program.
9457 @item @emph{Standard}:
9458 GNU extension
9460 @item @emph{Class}:
9461 Function
9463 @item @emph{Syntax}:
9464 @code{RESULT = MCLOCK()}
9466 @item @emph{Return value}:
9467 The return value is a scalar of type @code{INTEGER(4)}, equal to the
9468 number of clock ticks since the start of the process, or @code{-1} if
9469 the system does not support @code{clock(3)}.
9471 @item @emph{See also}:
9472 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME}
9474 @end table
9478 @node MCLOCK8
9479 @section @code{MCLOCK8} --- Time function (64-bit)
9480 @fnindex MCLOCK8
9481 @cindex time, clock ticks
9482 @cindex clock ticks
9484 @table @asis
9485 @item @emph{Description}:
9486 Returns the number of clock ticks since the start of the process, based
9487 on the function @code{clock(3)} in the C standard library.
9489 @emph{Warning:} this intrinsic does not increase the range of the timing
9490 values over that returned by @code{clock(3)}. On a system with a 32-bit
9491 @code{clock(3)}, @code{MCLOCK8} will return a 32-bit value, even though
9492 it is converted to a 64-bit @code{INTEGER(8)} value. That means
9493 overflows of the 32-bit value can still occur. Therefore, the values
9494 returned by this intrinsic might be or become negative or numerically
9495 less than previous values during a single run of the compiled program.
9497 @item @emph{Standard}:
9498 GNU extension
9500 @item @emph{Class}:
9501 Function
9503 @item @emph{Syntax}:
9504 @code{RESULT = MCLOCK8()}
9506 @item @emph{Return value}:
9507 The return value is a scalar of type @code{INTEGER(8)}, equal to the
9508 number of clock ticks since the start of the process, or @code{-1} if
9509 the system does not support @code{clock(3)}.
9511 @item @emph{See also}:
9512 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME8}
9514 @end table
9518 @node MERGE
9519 @section @code{MERGE} --- Merge variables
9520 @fnindex MERGE
9521 @cindex array, merge arrays
9522 @cindex array, combine arrays
9524 @table @asis
9525 @item @emph{Description}:
9526 Select values from two arrays according to a logical mask.  The result
9527 is equal to @var{TSOURCE} if @var{MASK} is @code{.TRUE.}, or equal to
9528 @var{FSOURCE} if it is @code{.FALSE.}.
9530 @item @emph{Standard}:
9531 Fortran 95 and later
9533 @item @emph{Class}:
9534 Elemental function
9536 @item @emph{Syntax}:
9537 @code{RESULT = MERGE(TSOURCE, FSOURCE, MASK)}
9539 @item @emph{Arguments}:
9540 @multitable @columnfractions .15 .70
9541 @item @var{TSOURCE} @tab May be of any type.
9542 @item @var{FSOURCE} @tab Shall be of the same type and type parameters
9543 as @var{TSOURCE}.
9544 @item @var{MASK}    @tab Shall be of type @code{LOGICAL}.
9545 @end multitable
9547 @item @emph{Return value}:
9548 The result is of the same type and type parameters as @var{TSOURCE}.
9550 @end table
9554 @node MERGE_BITS
9555 @section @code{MERGE_BITS} --- Merge of bits under mask
9556 @fnindex MERGE_BITS
9557 @cindex bits, merge
9559 @table @asis
9560 @item @emph{Description}:
9561 @code{MERGE_BITS(I, J, MASK)} merges the bits of @var{I} and @var{J}
9562 as determined by the mask.  The i-th bit of the result is equal to the 
9563 i-th bit of @var{I} if the i-th bit of @var{MASK} is 1; it is equal to
9564 the i-th bit of @var{J} otherwise.
9566 @item @emph{Standard}:
9567 Fortran 2008 and later
9569 @item @emph{Class}:
9570 Elemental function
9572 @item @emph{Syntax}:
9573 @code{RESULT = MERGE_BITS(I, J, MASK)}
9575 @item @emph{Arguments}:
9576 @multitable @columnfractions .15 .70
9577 @item @var{I}    @tab Shall be of type @code{INTEGER}.
9578 @item @var{J}    @tab Shall be of type @code{INTEGER} and of the same
9579 kind as @var{I}.
9580 @item @var{MASK} @tab Shall be of type @code{INTEGER} and of the same
9581 kind as @var{I}.
9582 @end multitable
9584 @item @emph{Return value}:
9585 The result is of the same type and kind as @var{I}.
9587 @end table
9591 @node MIN
9592 @section @code{MIN} --- Minimum value of an argument list
9593 @fnindex MIN
9594 @fnindex MIN0
9595 @fnindex AMIN0
9596 @fnindex MIN1
9597 @fnindex AMIN1
9598 @fnindex DMIN1
9599 @cindex minimum value
9601 @table @asis
9602 @item @emph{Description}:
9603 Returns the argument with the smallest (most negative) value.
9605 @item @emph{Standard}:
9606 Fortran 77 and later
9608 @item @emph{Class}:
9609 Elemental function
9611 @item @emph{Syntax}:
9612 @code{RESULT = MIN(A1, A2 [, A3, ...])}
9614 @item @emph{Arguments}:
9615 @multitable @columnfractions .15 .70
9616 @item @var{A1}          @tab The type shall be @code{INTEGER} or
9617 @code{REAL}.
9618 @item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
9619 as @var{A1}.  (As a GNU extension, arguments of different kinds are
9620 permitted.)
9621 @end multitable
9623 @item @emph{Return value}:
9624 The return value corresponds to the maximum value among the arguments,
9625 and has the same type and kind as the first argument.
9627 @item @emph{Specific names}:
9628 @multitable @columnfractions .20 .20 .20 .25
9629 @item Name              @tab Argument             @tab Return type        @tab Standard
9630 @item @code{MIN0(A1)}   @tab @code{INTEGER(4) A1} @tab @code{INTEGER(4)}  @tab Fortran 77 and later
9631 @item @code{AMIN0(A1)}  @tab @code{INTEGER(4) A1} @tab @code{REAL(4)}     @tab Fortran 77 and later
9632 @item @code{MIN1(A1)}   @tab @code{REAL A1}       @tab @code{INTEGER(4)}  @tab Fortran 77 and later
9633 @item @code{AMIN1(A1)}  @tab @code{REAL(4) A1}    @tab @code{REAL(4)}     @tab Fortran 77 and later
9634 @item @code{DMIN1(A1)}  @tab @code{REAL(8) A1}    @tab @code{REAL(8)}     @tab Fortran 77 and later
9635 @end multitable
9637 @item @emph{See also}:
9638 @ref{MAX}, @ref{MINLOC}, @ref{MINVAL}
9639 @end table
9643 @node MINEXPONENT
9644 @section @code{MINEXPONENT} --- Minimum exponent of a real kind
9645 @fnindex MINEXPONENT
9646 @cindex model representation, minimum exponent
9648 @table @asis
9649 @item @emph{Description}:
9650 @code{MINEXPONENT(X)} returns the minimum exponent in the model of the
9651 type of @code{X}.
9653 @item @emph{Standard}:
9654 Fortran 95 and later
9656 @item @emph{Class}:
9657 Inquiry function
9659 @item @emph{Syntax}:
9660 @code{RESULT = MINEXPONENT(X)}
9662 @item @emph{Arguments}:
9663 @multitable @columnfractions .15 .70
9664 @item @var{X} @tab Shall be of type @code{REAL}.
9665 @end multitable
9667 @item @emph{Return value}:
9668 The return value is of type @code{INTEGER} and of the default integer
9669 kind.
9671 @item @emph{Example}:
9672 See @code{MAXEXPONENT} for an example.
9673 @end table
9677 @node MINLOC
9678 @section @code{MINLOC} --- Location of the minimum value within an array
9679 @fnindex MINLOC
9680 @cindex array, location of minimum element
9682 @table @asis
9683 @item @emph{Description}:
9684 Determines the location of the element in the array with the minimum
9685 value, or, if the @var{DIM} argument is supplied, determines the
9686 locations of the minimum element along each row of the array in the
9687 @var{DIM} direction.  If @var{MASK} is present, only the elements for
9688 which @var{MASK} is @code{.TRUE.} are considered.  If more than one
9689 element in the array has the minimum value, the location returned is
9690 that of the first such element in array element order.  If the array has
9691 zero size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
9692 the result is an array of zeroes.  Similarly, if @var{DIM} is supplied
9693 and all of the elements of @var{MASK} along a given row are zero, the
9694 result value for that row is zero.
9696 @item @emph{Standard}:
9697 Fortran 95 and later
9699 @item @emph{Class}:
9700 Transformational function
9702 @item @emph{Syntax}:
9703 @multitable @columnfractions .80
9704 @item @code{RESULT = MINLOC(ARRAY, DIM [, MASK])}
9705 @item @code{RESULT = MINLOC(ARRAY [, MASK])}
9706 @end multitable
9708 @item @emph{Arguments}:
9709 @multitable @columnfractions .15 .70
9710 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or
9711 @code{REAL}.
9712 @item @var{DIM}   @tab (Optional) Shall be a scalar of type
9713 @code{INTEGER}, with a value between one and the rank of @var{ARRAY},
9714 inclusive.  It may not be an optional dummy argument.
9715 @item @var{MASK}  @tab Shall be an array of type @code{LOGICAL},
9716 and conformable with @var{ARRAY}.
9717 @end multitable
9719 @item @emph{Return value}:
9720 If @var{DIM} is absent, the result is a rank-one array with a length
9721 equal to the rank of @var{ARRAY}.  If @var{DIM} is present, the result
9722 is an array with a rank one less than the rank of @var{ARRAY}, and a
9723 size corresponding to the size of @var{ARRAY} with the @var{DIM}
9724 dimension removed.  If @var{DIM} is present and @var{ARRAY} has a rank
9725 of one, the result is a scalar.  In all cases, the result is of default
9726 @code{INTEGER} type.
9728 @item @emph{See also}:
9729 @ref{MIN}, @ref{MINVAL}
9731 @end table
9735 @node MINVAL
9736 @section @code{MINVAL} --- Minimum value of an array
9737 @fnindex MINVAL
9738 @cindex array, minimum value
9739 @cindex minimum value
9741 @table @asis
9742 @item @emph{Description}:
9743 Determines the minimum value of the elements in an array value, or, if
9744 the @var{DIM} argument is supplied, determines the minimum value along
9745 each row of the array in the @var{DIM} direction.  If @var{MASK} is
9746 present, only the elements for which @var{MASK} is @code{.TRUE.} are
9747 considered.  If the array has zero size, or all of the elements of
9748 @var{MASK} are @code{.FALSE.}, then the result is @code{HUGE(ARRAY)} if
9749 @var{ARRAY} is numeric, or a string of @code{CHAR(255)} characters if
9750 @var{ARRAY} is of character type.
9752 @item @emph{Standard}:
9753 Fortran 95 and later
9755 @item @emph{Class}:
9756 Transformational function
9758 @item @emph{Syntax}:
9759 @multitable @columnfractions .80
9760 @item @code{RESULT = MINVAL(ARRAY, DIM [, MASK])}
9761 @item @code{RESULT = MINVAL(ARRAY [, MASK])}
9762 @end multitable
9764 @item @emph{Arguments}:
9765 @multitable @columnfractions .15 .70
9766 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or
9767 @code{REAL}.
9768 @item @var{DIM}   @tab (Optional) Shall be a scalar of type
9769 @code{INTEGER}, with a value between one and the rank of @var{ARRAY},
9770 inclusive.  It may not be an optional dummy argument.
9771 @item @var{MASK}  @tab Shall be an array of type @code{LOGICAL},
9772 and conformable with @var{ARRAY}.
9773 @end multitable
9775 @item @emph{Return value}:
9776 If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
9777 is a scalar.  If @var{DIM} is present, the result is an array with a
9778 rank one less than the rank of @var{ARRAY}, and a size corresponding to
9779 the size of @var{ARRAY} with the @var{DIM} dimension removed.  In all
9780 cases, the result is of the same type and kind as @var{ARRAY}.
9782 @item @emph{See also}:
9783 @ref{MIN}, @ref{MINLOC}
9785 @end table
9789 @node MOD
9790 @section @code{MOD} --- Remainder function
9791 @fnindex MOD
9792 @fnindex AMOD
9793 @fnindex DMOD
9794 @cindex remainder
9795 @cindex division, remainder
9797 @table @asis
9798 @item @emph{Description}:
9799 @code{MOD(A,P)} computes the remainder of the division of A by P@. 
9801 @item @emph{Standard}:
9802 Fortran 77 and later
9804 @item @emph{Class}:
9805 Elemental function
9807 @item @emph{Syntax}:
9808 @code{RESULT = MOD(A, P)}
9810 @item @emph{Arguments}:
9811 @multitable @columnfractions .15 .70
9812 @item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL}.
9813 @item @var{P} @tab Shall be a scalar of the same type and kind as @var{A} 
9814 and not equal to zero.
9815 @end multitable
9817 @item @emph{Return value}:
9818 The return value is the result of @code{A - (INT(A/P) * P)}. The type
9819 and kind of the return value is the same as that of the arguments. The
9820 returned value has the same sign as A and a magnitude less than the
9821 magnitude of P.
9823 @item @emph{Example}:
9824 @smallexample
9825 program test_mod
9826   print *, mod(17,3)
9827   print *, mod(17.5,5.5)
9828   print *, mod(17.5d0,5.5)
9829   print *, mod(17.5,5.5d0)
9831   print *, mod(-17,3)
9832   print *, mod(-17.5,5.5)
9833   print *, mod(-17.5d0,5.5)
9834   print *, mod(-17.5,5.5d0)
9836   print *, mod(17,-3)
9837   print *, mod(17.5,-5.5)
9838   print *, mod(17.5d0,-5.5)
9839   print *, mod(17.5,-5.5d0)
9840 end program test_mod
9841 @end smallexample
9843 @item @emph{Specific names}:
9844 @multitable @columnfractions .20 .20 .20 .25
9845 @item Name             @tab Arguments          @tab Return type    @tab Standard
9846 @item @code{MOD(A,P)}  @tab @code{INTEGER A,P} @tab @code{INTEGER} @tab Fortran 95 and later
9847 @item @code{AMOD(A,P)} @tab @code{REAL(4) A,P} @tab @code{REAL(4)} @tab Fortran 95 and later
9848 @item @code{DMOD(A,P)} @tab @code{REAL(8) A,P} @tab @code{REAL(8)} @tab Fortran 95 and later
9849 @end multitable
9851 @item @emph{See also}:
9852 @ref{MODULO}
9854 @end table
9858 @node MODULO
9859 @section @code{MODULO} --- Modulo function
9860 @fnindex MODULO
9861 @cindex modulo
9862 @cindex division, modulo
9864 @table @asis
9865 @item @emph{Description}:
9866 @code{MODULO(A,P)} computes the @var{A} modulo @var{P}.
9868 @item @emph{Standard}:
9869 Fortran 95 and later
9871 @item @emph{Class}:
9872 Elemental function
9874 @item @emph{Syntax}:
9875 @code{RESULT = MODULO(A, P)}
9877 @item @emph{Arguments}:
9878 @multitable @columnfractions .15 .70
9879 @item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL}.
9880 @item @var{P} @tab Shall be a scalar of the same type and kind as @var{A}. 
9881 It shall not be zero.
9882 @end multitable
9884 @item @emph{Return value}:
9885 The type and kind of the result are those of the arguments.
9886 @table @asis
9887 @item If @var{A} and @var{P} are of type @code{INTEGER}:
9888 @code{MODULO(A,P)} has the value @var{R} such that @code{A=Q*P+R}, where
9889 @var{Q} is an integer and @var{R} is between 0 (inclusive) and @var{P}
9890 (exclusive).
9891 @item If @var{A} and @var{P} are of type @code{REAL}:
9892 @code{MODULO(A,P)} has the value of @code{A - FLOOR (A / P) * P}.
9893 @end table
9894 The returned value has the same sign as P and a magnitude less than
9895 the magnitude of P.
9897 @item @emph{Example}:
9898 @smallexample
9899 program test_modulo
9900   print *, modulo(17,3)
9901   print *, modulo(17.5,5.5)
9903   print *, modulo(-17,3)
9904   print *, modulo(-17.5,5.5)
9906   print *, modulo(17,-3)
9907   print *, modulo(17.5,-5.5)
9908 end program
9909 @end smallexample
9911 @item @emph{See also}:
9912 @ref{MOD}
9914 @end table
9918 @node MOVE_ALLOC
9919 @section @code{MOVE_ALLOC} --- Move allocation from one object to another
9920 @fnindex MOVE_ALLOC
9921 @cindex moving allocation
9922 @cindex allocation, moving
9924 @table @asis
9925 @item @emph{Description}:
9926 @code{MOVE_ALLOC(FROM, TO)} moves the allocation from @var{FROM} to
9927 @var{TO}.  @var{FROM} will become deallocated in the process.
9929 @item @emph{Standard}:
9930 Fortran 2003 and later
9932 @item @emph{Class}:
9933 Pure subroutine
9935 @item @emph{Syntax}:
9936 @code{CALL MOVE_ALLOC(FROM, TO)}
9938 @item @emph{Arguments}:
9939 @multitable @columnfractions .15 .70
9940 @item @var{FROM}  @tab @code{ALLOCATABLE}, @code{INTENT(INOUT)}, may be
9941 of any type and kind.
9942 @item @var{TO} @tab @code{ALLOCATABLE}, @code{INTENT(OUT)}, shall be
9943 of the same type, kind and rank as @var{FROM}.
9944 @end multitable
9946 @item @emph{Return value}:
9947 None
9949 @item @emph{Example}:
9950 @smallexample
9951 program test_move_alloc
9952     integer, allocatable :: a(:), b(:)
9954     allocate(a(3))
9955     a = [ 1, 2, 3 ]
9956     call move_alloc(a, b)
9957     print *, allocated(a), allocated(b)
9958     print *, b
9959 end program test_move_alloc
9960 @end smallexample
9961 @end table
9965 @node MVBITS
9966 @section @code{MVBITS} --- Move bits from one integer to another
9967 @fnindex MVBITS
9968 @cindex bits, move
9970 @table @asis
9971 @item @emph{Description}:
9972 Moves @var{LEN} bits from positions @var{FROMPOS} through
9973 @code{FROMPOS+LEN-1} of @var{FROM} to positions @var{TOPOS} through
9974 @code{TOPOS+LEN-1} of @var{TO}. The portion of argument @var{TO} not
9975 affected by the movement of bits is unchanged. The values of
9976 @code{FROMPOS+LEN-1} and @code{TOPOS+LEN-1} must be less than
9977 @code{BIT_SIZE(FROM)}.
9979 @item @emph{Standard}:
9980 Fortran 95 and later
9982 @item @emph{Class}:
9983 Elemental subroutine
9985 @item @emph{Syntax}:
9986 @code{CALL MVBITS(FROM, FROMPOS, LEN, TO, TOPOS)}
9988 @item @emph{Arguments}:
9989 @multitable @columnfractions .15 .70
9990 @item @var{FROM}    @tab The type shall be @code{INTEGER}.
9991 @item @var{FROMPOS} @tab The type shall be @code{INTEGER}.
9992 @item @var{LEN}     @tab The type shall be @code{INTEGER}.
9993 @item @var{TO}      @tab The type shall be @code{INTEGER}, of the
9994 same kind as @var{FROM}.
9995 @item @var{TOPOS}   @tab The type shall be @code{INTEGER}.
9996 @end multitable
9998 @item @emph{See also}:
9999 @ref{IBCLR}, @ref{IBSET}, @ref{IBITS}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
10000 @end table
10004 @node NEAREST
10005 @section @code{NEAREST} --- Nearest representable number
10006 @fnindex NEAREST
10007 @cindex real number, nearest different
10008 @cindex floating point, nearest different
10010 @table @asis
10011 @item @emph{Description}:
10012 @code{NEAREST(X, S)} returns the processor-representable number nearest
10013 to @code{X} in the direction indicated by the sign of @code{S}.
10015 @item @emph{Standard}:
10016 Fortran 95 and later
10018 @item @emph{Class}:
10019 Elemental function
10021 @item @emph{Syntax}:
10022 @code{RESULT = NEAREST(X, S)}
10024 @item @emph{Arguments}:
10025 @multitable @columnfractions .15 .70
10026 @item @var{X} @tab Shall be of type @code{REAL}.
10027 @item @var{S} @tab Shall be of type @code{REAL} and
10028 not equal to zero.
10029 @end multitable
10031 @item @emph{Return value}:
10032 The return value is of the same type as @code{X}. If @code{S} is
10033 positive, @code{NEAREST} returns the processor-representable number
10034 greater than @code{X} and nearest to it. If @code{S} is negative,
10035 @code{NEAREST} returns the processor-representable number smaller than
10036 @code{X} and nearest to it.
10038 @item @emph{Example}:
10039 @smallexample
10040 program test_nearest
10041   real :: x, y
10042   x = nearest(42.0, 1.0)
10043   y = nearest(42.0, -1.0)
10044   write (*,"(3(G20.15))") x, y, x - y
10045 end program test_nearest
10046 @end smallexample
10047 @end table
10051 @node NEW_LINE
10052 @section @code{NEW_LINE} --- New line character
10053 @fnindex NEW_LINE
10054 @cindex newline
10055 @cindex output, newline
10057 @table @asis
10058 @item @emph{Description}:
10059 @code{NEW_LINE(C)} returns the new-line character.
10061 @item @emph{Standard}:
10062 Fortran 2003 and later
10064 @item @emph{Class}:
10065 Inquiry function
10067 @item @emph{Syntax}:
10068 @code{RESULT = NEW_LINE(C)}
10070 @item @emph{Arguments}:
10071 @multitable @columnfractions .15 .70
10072 @item @var{C}    @tab The argument shall be a scalar or array of the
10073 type @code{CHARACTER}.
10074 @end multitable
10076 @item @emph{Return value}:
10077 Returns a @var{CHARACTER} scalar of length one with the new-line character of
10078 the same kind as parameter @var{C}.
10080 @item @emph{Example}:
10081 @smallexample
10082 program newline
10083   implicit none
10084   write(*,'(A)') 'This is record 1.'//NEW_LINE('A')//'This is record 2.'
10085 end program newline
10086 @end smallexample
10087 @end table
10091 @node NINT
10092 @section @code{NINT} --- Nearest whole number
10093 @fnindex NINT
10094 @fnindex IDNINT
10095 @cindex rounding, nearest whole number
10097 @table @asis
10098 @item @emph{Description}:
10099 @code{NINT(A)} rounds its argument to the nearest whole number.
10101 @item @emph{Standard}:
10102 Fortran 77 and later, with @var{KIND} argument Fortran 90 and later
10104 @item @emph{Class}:
10105 Elemental function
10107 @item @emph{Syntax}:
10108 @code{RESULT = NINT(A [, KIND])}
10110 @item @emph{Arguments}:
10111 @multitable @columnfractions .15 .70
10112 @item @var{A}    @tab The type of the argument shall be @code{REAL}.
10113 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
10114 expression indicating the kind parameter of the result.
10115 @end multitable
10117 @item @emph{Return value}:
10118 Returns @var{A} with the fractional portion of its magnitude eliminated by
10119 rounding to the nearest whole number and with its sign preserved,
10120 converted to an @code{INTEGER} of the default kind.
10122 @item @emph{Example}:
10123 @smallexample
10124 program test_nint
10125   real(4) x4
10126   real(8) x8
10127   x4 = 1.234E0_4
10128   x8 = 4.321_8
10129   print *, nint(x4), idnint(x8)
10130 end program test_nint
10131 @end smallexample
10133 @item @emph{Specific names}:
10134 @multitable @columnfractions .20 .20 .20 .25
10135 @item Name             @tab Argument           @tab Return Type     @tab Standard
10136 @item @code{NINT(A)}   @tab @code{REAL(4) A}   @tab  @code{INTEGER} @tab Fortran 95 and later
10137 @item @code{IDNINT(A)} @tab @code{REAL(8) A}   @tab  @code{INTEGER} @tab Fortran 95 and later
10138 @end multitable
10140 @item @emph{See also}:
10141 @ref{CEILING}, @ref{FLOOR}
10143 @end table
10147 @node NORM2
10148 @section @code{NORM2} --- Euclidean vector norms
10149 @fnindex NORM2
10150 @cindex Euclidean vector norm
10151 @cindex L2 vector norm
10152 @cindex norm, Euclidean
10154 @table @asis
10155 @item @emph{Description}:
10156 Calculates the Euclidean vector norm (@math{L_2} norm) of
10157 of @var{ARRAY} along dimension @var{DIM}.
10159 @item @emph{Standard}:
10160 Fortran 2008 and later
10162 @item @emph{Class}:
10163 Transformational function
10165 @item @emph{Syntax}:
10166 @multitable @columnfractions .80
10167 @item @code{RESULT = NORM2(ARRAY[, DIM])}
10168 @end multitable
10170 @item @emph{Arguments}:
10171 @multitable @columnfractions .15 .70
10172 @item @var{ARRAY} @tab Shall be an array of type @code{REAL}
10173 @item @var{DIM}   @tab (Optional) shall be a scalar of type 
10174 @code{INTEGER} with a value in the range from 1 to n, where n 
10175 equals the rank of @var{ARRAY}.
10176 @end multitable
10178 @item @emph{Return value}:
10179 The result is of the same type as @var{ARRAY}.
10181 If @var{DIM} is absent, a scalar with the square root of the sum of all
10182 elements in @var{ARRAY} squared  is returned. Otherwise, an array of
10183 rank @math{n-1}, where @math{n} equals the rank of @var{ARRAY}, and a
10184 shape similar to that of @var{ARRAY} with dimension @var{DIM} dropped
10185 is returned.
10187 @item @emph{Example}:
10188 @smallexample
10189 PROGRAM test_sum
10190   REAL :: x(5) = [ real :: 1, 2, 3, 4, 5 ]
10191   print *, NORM2(x)  ! = sqrt(55.) ~ 7.416
10192 END PROGRAM
10193 @end smallexample
10194 @end table
10198 @node NOT
10199 @section @code{NOT} --- Logical negation
10200 @fnindex NOT
10201 @cindex bits, negate
10202 @cindex bitwise logical not
10203 @cindex logical not, bitwise
10205 @table @asis
10206 @item @emph{Description}:
10207 @code{NOT} returns the bitwise Boolean inverse of @var{I}.
10209 @item @emph{Standard}:
10210 Fortran 95 and later
10212 @item @emph{Class}:
10213 Elemental function
10215 @item @emph{Syntax}:
10216 @code{RESULT = NOT(I)}
10218 @item @emph{Arguments}:
10219 @multitable @columnfractions .15 .70
10220 @item @var{I} @tab The type shall be @code{INTEGER}.
10221 @end multitable
10223 @item @emph{Return value}:
10224 The return type is @code{INTEGER}, of the same kind as the
10225 argument.
10227 @item @emph{See also}:
10228 @ref{IAND}, @ref{IEOR}, @ref{IOR}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}
10230 @end table
10234 @node NULL
10235 @section @code{NULL} --- Function that returns an disassociated pointer
10236 @fnindex NULL
10237 @cindex pointer, status
10238 @cindex pointer, disassociated
10240 @table @asis
10241 @item @emph{Description}:
10242 Returns a disassociated pointer.
10244 If @var{MOLD} is present, a disassociated pointer of the same type is
10245 returned, otherwise the type is determined by context.
10247 In Fortran 95, @var{MOLD} is optional. Please note that Fortran 2003
10248 includes cases where it is required.
10250 @item @emph{Standard}:
10251 Fortran 95 and later
10253 @item @emph{Class}:
10254 Transformational function
10256 @item @emph{Syntax}:
10257 @code{PTR => NULL([MOLD])}
10259 @item @emph{Arguments}:
10260 @multitable @columnfractions .15 .70
10261 @item @var{MOLD} @tab (Optional) shall be a pointer of any association
10262 status and of any type.
10263 @end multitable
10265 @item @emph{Return value}:
10266 A disassociated pointer.
10268 @item @emph{Example}:
10269 @smallexample
10270 REAL, POINTER, DIMENSION(:) :: VEC => NULL ()
10271 @end smallexample
10273 @item @emph{See also}:
10274 @ref{ASSOCIATED}
10275 @end table
10279 @node NUM_IMAGES
10280 @section @code{NUM_IMAGES} --- Function that returns the number of images
10281 @fnindex NUM_IMAGES
10282 @cindex coarray, @code{NUM_IMAGES}
10283 @cindex images, number of
10285 @table @asis
10286 @item @emph{Description}:
10287 Returns the number of images.
10289 @item @emph{Standard}:
10290 Fortran 2008 and later. With @var{DISTANCE} or @var{FAILED} argument, 
10291 Technical Specification (TS) 18508 or later
10294 @item @emph{Class}:
10295 Transformational function
10297 @item @emph{Syntax}:
10298 @code{RESULT = NUM_IMAGES(DISTANCE, FAILED)}
10300 @item @emph{Arguments}:
10301 @multitable @columnfractions .15 .70
10302 @item @var{DISTANCE} @tab (optional, intent(in)) Nonnegative scalar integer
10303 @item @var{FAILED}   @tab (optional, intent(in)) Scalar logical expression
10304 @end multitable
10306 @item @emph{Return value}:
10307 Scalar default-kind integer.  If @var{DISTANCE} is not present or has value 0,
10308 the number of images in the current team is returned. For values smaller or
10309 equal distance to the initial team, it returns the number of images index
10310 on the ancestor team which has a distance of @var{DISTANCE} from the invoking
10311 team. If @var{DISTANCE} is larger than the distance to the initial team, the
10312 number of images of the initial team is returned. If @var{FAILED} is not present
10313 the total number of images is returned; if it has the value @code{.TRUE.},
10314 the number of failed images is returned, otherwise, the number of images which
10315 do have not the failed status.
10317 @item @emph{Example}:
10318 @smallexample
10319 INTEGER :: value[*]
10320 INTEGER :: i
10321 value = THIS_IMAGE()
10322 SYNC ALL
10323 IF (THIS_IMAGE() == 1) THEN
10324   DO i = 1, NUM_IMAGES()
10325     WRITE(*,'(2(a,i0))') 'value[', i, '] is ', value[i]
10326   END DO
10327 END IF
10328 @end smallexample
10330 @item @emph{See also}:
10331 @ref{THIS_IMAGE}, @ref{IMAGE_INDEX}
10332 @end table
10336 @node OR
10337 @section @code{OR} --- Bitwise logical OR
10338 @fnindex OR
10339 @cindex bitwise logical or
10340 @cindex logical or, bitwise
10342 @table @asis
10343 @item @emph{Description}:
10344 Bitwise logical @code{OR}.
10346 This intrinsic routine is provided for backwards compatibility with 
10347 GNU Fortran 77.  For integer arguments, programmers should consider
10348 the use of the @ref{IOR} intrinsic defined by the Fortran standard.
10350 @item @emph{Standard}:
10351 GNU extension
10353 @item @emph{Class}:
10354 Function
10356 @item @emph{Syntax}:
10357 @code{RESULT = OR(I, J)}
10359 @item @emph{Arguments}:
10360 @multitable @columnfractions .15 .70
10361 @item @var{I} @tab The type shall be either a scalar @code{INTEGER}
10362 type or a scalar @code{LOGICAL} type.
10363 @item @var{J} @tab The type shall be the same as the type of @var{J}.
10364 @end multitable
10366 @item @emph{Return value}:
10367 The return type is either a scalar @code{INTEGER} or a scalar
10368 @code{LOGICAL}.  If the kind type parameters differ, then the
10369 smaller kind type is implicitly converted to larger kind, and the 
10370 return has the larger kind.
10372 @item @emph{Example}:
10373 @smallexample
10374 PROGRAM test_or
10375   LOGICAL :: T = .TRUE., F = .FALSE.
10376   INTEGER :: a, b
10377   DATA a / Z'F' /, b / Z'3' /
10379   WRITE (*,*) OR(T, T), OR(T, F), OR(F, T), OR(F, F)
10380   WRITE (*,*) OR(a, b)
10381 END PROGRAM
10382 @end smallexample
10384 @item @emph{See also}:
10385 Fortran 95 elemental function: @ref{IOR}
10386 @end table
10390 @node PACK
10391 @section @code{PACK} --- Pack an array into an array of rank one
10392 @fnindex PACK
10393 @cindex array, packing
10394 @cindex array, reduce dimension
10395 @cindex array, gather elements
10397 @table @asis
10398 @item @emph{Description}:
10399 Stores the elements of @var{ARRAY} in an array of rank one.
10401 The beginning of the resulting array is made up of elements whose @var{MASK} 
10402 equals @code{TRUE}. Afterwards, positions are filled with elements taken from
10403 @var{VECTOR}.
10405 @item @emph{Standard}:
10406 Fortran 95 and later
10408 @item @emph{Class}:
10409 Transformational function
10411 @item @emph{Syntax}:
10412 @code{RESULT = PACK(ARRAY, MASK[,VECTOR])}
10414 @item @emph{Arguments}:
10415 @multitable @columnfractions .15 .70
10416 @item @var{ARRAY}  @tab Shall be an array of any type.
10417 @item @var{MASK}   @tab Shall be an array of type @code{LOGICAL} and 
10418 of the same size as @var{ARRAY}. Alternatively, it may be a @code{LOGICAL} 
10419 scalar.
10420 @item @var{VECTOR} @tab (Optional) shall be an array of the same type 
10421 as @var{ARRAY} and of rank one. If present, the number of elements in 
10422 @var{VECTOR} shall be equal to or greater than the number of true elements 
10423 in @var{MASK}. If @var{MASK} is scalar, the number of elements in 
10424 @var{VECTOR} shall be equal to or greater than the number of elements in
10425 @var{ARRAY}.
10426 @end multitable
10428 @item @emph{Return value}:
10429 The result is an array of rank one and the same type as that of @var{ARRAY}.
10430 If @var{VECTOR} is present, the result size is that of @var{VECTOR}, the
10431 number of @code{TRUE} values in @var{MASK} otherwise.
10433 @item @emph{Example}:
10434 Gathering nonzero elements from an array:
10435 @smallexample
10436 PROGRAM test_pack_1
10437   INTEGER :: m(6)
10438   m = (/ 1, 0, 0, 0, 5, 0 /)
10439   WRITE(*, FMT="(6(I0, ' '))") pack(m, m /= 0)  ! "1 5"
10440 END PROGRAM
10441 @end smallexample
10443 Gathering nonzero elements from an array and appending elements from @var{VECTOR}:
10444 @smallexample
10445 PROGRAM test_pack_2
10446   INTEGER :: m(4)
10447   m = (/ 1, 0, 0, 2 /)
10448   WRITE(*, FMT="(4(I0, ' '))") pack(m, m /= 0, (/ 0, 0, 3, 4 /))  ! "1 2 3 4"
10449 END PROGRAM
10450 @end smallexample
10452 @item @emph{See also}:
10453 @ref{UNPACK}
10454 @end table
10458 @node PARITY
10459 @section @code{PARITY} --- Reduction with exclusive OR
10460 @fnindex PARITY
10461 @cindex Parity
10462 @cindex Reduction, XOR
10463 @cindex XOR reduction
10465 @table @asis
10466 @item @emph{Description}:
10467 Calculates the parity, i.e. the reduction using @code{.XOR.},
10468 of @var{MASK} along dimension @var{DIM}.
10470 @item @emph{Standard}:
10471 Fortran 2008 and later
10473 @item @emph{Class}:
10474 Transformational function
10476 @item @emph{Syntax}:
10477 @multitable @columnfractions .80
10478 @item @code{RESULT = PARITY(MASK[, DIM])}
10479 @end multitable
10481 @item @emph{Arguments}:
10482 @multitable @columnfractions .15 .70
10483 @item @var{LOGICAL} @tab Shall be an array of type @code{LOGICAL}
10484 @item @var{DIM}   @tab (Optional) shall be a scalar of type 
10485 @code{INTEGER} with a value in the range from 1 to n, where n 
10486 equals the rank of @var{MASK}.
10487 @end multitable
10489 @item @emph{Return value}:
10490 The result is of the same type as @var{MASK}.
10492 If @var{DIM} is absent, a scalar with the parity of all elements in
10493 @var{MASK} is returned, i.e. true if an odd number of elements is
10494 @code{.true.} and false otherwise.  If @var{DIM} is present, an array
10495 of rank @math{n-1}, where @math{n} equals the rank of @var{ARRAY},
10496 and a shape similar to that of @var{MASK} with dimension @var{DIM}
10497 dropped is returned.
10499 @item @emph{Example}:
10500 @smallexample
10501 PROGRAM test_sum
10502   LOGICAL :: x(2) = [ .true., .false. ]
10503   print *, PARITY(x) ! prints "T" (true).
10504 END PROGRAM
10505 @end smallexample
10506 @end table
10510 @node PERROR
10511 @section @code{PERROR} --- Print system error message
10512 @fnindex PERROR
10513 @cindex system, error handling
10515 @table @asis
10516 @item @emph{Description}:
10517 Prints (on the C @code{stderr} stream) a newline-terminated error
10518 message corresponding to the last system error. This is prefixed by
10519 @var{STRING}, a colon and a space. See @code{perror(3)}.
10521 @item @emph{Standard}:
10522 GNU extension
10524 @item @emph{Class}:
10525 Subroutine
10527 @item @emph{Syntax}:
10528 @code{CALL PERROR(STRING)}
10530 @item @emph{Arguments}:
10531 @multitable @columnfractions .15 .70
10532 @item @var{STRING} @tab A scalar of type @code{CHARACTER} and of the
10533 default kind.
10534 @end multitable
10536 @item @emph{See also}:
10537 @ref{IERRNO}
10538 @end table
10542 @node POPCNT
10543 @section @code{POPCNT} --- Number of bits set
10544 @fnindex POPCNT
10545 @cindex binary representation
10546 @cindex bits set
10548 @table @asis
10549 @item @emph{Description}:
10550 @code{POPCNT(I)} returns the number of bits set ('1' bits) in the binary
10551 representation of @code{I}.
10553 @item @emph{Standard}:
10554 Fortran 2008 and later
10556 @item @emph{Class}:
10557 Elemental function
10559 @item @emph{Syntax}:
10560 @code{RESULT = POPCNT(I)}
10562 @item @emph{Arguments}:
10563 @multitable @columnfractions .15 .70
10564 @item @var{I} @tab Shall be of type @code{INTEGER}.
10565 @end multitable
10567 @item @emph{Return value}:
10568 The return value is of type @code{INTEGER} and of the default integer
10569 kind.
10571 @item @emph{See also}:
10572 @ref{POPPAR}, @ref{LEADZ}, @ref{TRAILZ}
10574 @item @emph{Example}:
10575 @smallexample
10576 program test_population
10577   print *, popcnt(127),       poppar(127)
10578   print *, popcnt(huge(0_4)), poppar(huge(0_4))
10579   print *, popcnt(huge(0_8)), poppar(huge(0_8))
10580 end program test_population
10581 @end smallexample
10582 @end table
10585 @node POPPAR
10586 @section @code{POPPAR} --- Parity of the number of bits set
10587 @fnindex POPPAR
10588 @cindex binary representation
10589 @cindex parity
10591 @table @asis
10592 @item @emph{Description}:
10593 @code{POPPAR(I)} returns parity of the integer @code{I}, i.e. the parity
10594 of the number of bits set ('1' bits) in the binary representation of
10595 @code{I}. It is equal to 0 if @code{I} has an even number of bits set,
10596 and 1 for an odd number of '1' bits.
10598 @item @emph{Standard}:
10599 Fortran 2008 and later
10601 @item @emph{Class}:
10602 Elemental function
10604 @item @emph{Syntax}:
10605 @code{RESULT = POPPAR(I)}
10607 @item @emph{Arguments}:
10608 @multitable @columnfractions .15 .70
10609 @item @var{I} @tab Shall be of type @code{INTEGER}.
10610 @end multitable
10612 @item @emph{Return value}:
10613 The return value is of type @code{INTEGER} and of the default integer
10614 kind.
10616 @item @emph{See also}:
10617 @ref{POPCNT}, @ref{LEADZ}, @ref{TRAILZ}
10619 @item @emph{Example}:
10620 @smallexample
10621 program test_population
10622   print *, popcnt(127),       poppar(127)
10623   print *, popcnt(huge(0_4)), poppar(huge(0_4))
10624   print *, popcnt(huge(0_8)), poppar(huge(0_8))
10625 end program test_population
10626 @end smallexample
10627 @end table
10631 @node PRECISION
10632 @section @code{PRECISION} --- Decimal precision of a real kind
10633 @fnindex PRECISION
10634 @cindex model representation, precision
10636 @table @asis
10637 @item @emph{Description}:
10638 @code{PRECISION(X)} returns the decimal precision in the model of the
10639 type of @code{X}.
10641 @item @emph{Standard}:
10642 Fortran 95 and later
10644 @item @emph{Class}:
10645 Inquiry function
10647 @item @emph{Syntax}:
10648 @code{RESULT = PRECISION(X)}
10650 @item @emph{Arguments}:
10651 @multitable @columnfractions .15 .70
10652 @item @var{X} @tab Shall be of type @code{REAL} or @code{COMPLEX}.
10653 @end multitable
10655 @item @emph{Return value}:
10656 The return value is of type @code{INTEGER} and of the default integer
10657 kind.
10659 @item @emph{See also}:
10660 @ref{SELECTED_REAL_KIND}, @ref{RANGE}
10662 @item @emph{Example}:
10663 @smallexample
10664 program prec_and_range
10665   real(kind=4) :: x(2)
10666   complex(kind=8) :: y
10668   print *, precision(x), range(x)
10669   print *, precision(y), range(y)
10670 end program prec_and_range
10671 @end smallexample
10672 @end table
10676 @node PRESENT
10677 @section @code{PRESENT} --- Determine whether an optional dummy argument is specified
10678 @fnindex PRESENT
10680 @table @asis
10681 @item @emph{Description}:
10682 Determines whether an optional dummy argument is present.
10684 @item @emph{Standard}:
10685 Fortran 95 and later
10687 @item @emph{Class}:
10688 Inquiry function
10690 @item @emph{Syntax}:
10691 @code{RESULT = PRESENT(A)}
10693 @item @emph{Arguments}:
10694 @multitable @columnfractions .15 .70
10695 @item @var{A} @tab May be of any type and may be a pointer, scalar or array
10696 value, or a dummy procedure. It shall be the name of an optional dummy argument
10697 accessible within the current subroutine or function.
10698 @end multitable
10700 @item @emph{Return value}:
10701 Returns either @code{TRUE} if the optional argument @var{A} is present, or
10702 @code{FALSE} otherwise.
10704 @item @emph{Example}:
10705 @smallexample
10706 PROGRAM test_present
10707   WRITE(*,*) f(), f(42)      ! "F T"
10708 CONTAINS
10709   LOGICAL FUNCTION f(x)
10710     INTEGER, INTENT(IN), OPTIONAL :: x
10711     f = PRESENT(x)
10712   END FUNCTION
10713 END PROGRAM
10714 @end smallexample
10715 @end table
10719 @node PRODUCT
10720 @section @code{PRODUCT} --- Product of array elements
10721 @fnindex PRODUCT
10722 @cindex array, product
10723 @cindex array, multiply elements
10724 @cindex array, conditionally multiply elements
10725 @cindex multiply array elements
10727 @table @asis
10728 @item @emph{Description}:
10729 Multiplies the elements of @var{ARRAY} along dimension @var{DIM} if
10730 the corresponding element in @var{MASK} is @code{TRUE}.
10732 @item @emph{Standard}:
10733 Fortran 95 and later
10735 @item @emph{Class}:
10736 Transformational function
10738 @item @emph{Syntax}:
10739 @multitable @columnfractions .80
10740 @item @code{RESULT = PRODUCT(ARRAY[, MASK])}
10741 @item @code{RESULT = PRODUCT(ARRAY, DIM[, MASK])}
10742 @end multitable
10744 @item @emph{Arguments}:
10745 @multitable @columnfractions .15 .70
10746 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER}, 
10747 @code{REAL} or @code{COMPLEX}.
10748 @item @var{DIM}   @tab (Optional) shall be a scalar of type 
10749 @code{INTEGER} with a value in the range from 1 to n, where n 
10750 equals the rank of @var{ARRAY}.
10751 @item @var{MASK}  @tab (Optional) shall be of type @code{LOGICAL} 
10752 and either be a scalar or an array of the same shape as @var{ARRAY}.
10753 @end multitable
10755 @item @emph{Return value}:
10756 The result is of the same type as @var{ARRAY}.
10758 If @var{DIM} is absent, a scalar with the product of all elements in 
10759 @var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals 
10760 the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with 
10761 dimension @var{DIM} dropped is returned.
10764 @item @emph{Example}:
10765 @smallexample
10766 PROGRAM test_product
10767   INTEGER :: x(5) = (/ 1, 2, 3, 4 ,5 /)
10768   print *, PRODUCT(x)                    ! all elements, product = 120
10769   print *, PRODUCT(x, MASK=MOD(x, 2)==1) ! odd elements, product = 15
10770 END PROGRAM
10771 @end smallexample
10773 @item @emph{See also}:
10774 @ref{SUM}
10775 @end table
10779 @node RADIX
10780 @section @code{RADIX} --- Base of a model number
10781 @fnindex RADIX
10782 @cindex model representation, base
10783 @cindex model representation, radix
10785 @table @asis
10786 @item @emph{Description}:
10787 @code{RADIX(X)} returns the base of the model representing the entity @var{X}.
10789 @item @emph{Standard}:
10790 Fortran 95 and later
10792 @item @emph{Class}:
10793 Inquiry function
10795 @item @emph{Syntax}:
10796 @code{RESULT = RADIX(X)}
10798 @item @emph{Arguments}:
10799 @multitable @columnfractions .15 .70
10800 @item @var{X} @tab Shall be of type @code{INTEGER} or @code{REAL}
10801 @end multitable
10803 @item @emph{Return value}:
10804 The return value is a scalar of type @code{INTEGER} and of the default
10805 integer kind.
10807 @item @emph{See also}:
10808 @ref{SELECTED_REAL_KIND}
10810 @item @emph{Example}:
10811 @smallexample
10812 program test_radix
10813   print *, "The radix for the default integer kind is", radix(0)
10814   print *, "The radix for the default real kind is", radix(0.0)
10815 end program test_radix
10816 @end smallexample
10818 @end table
10822 @node RAN
10823 @section @code{RAN} --- Real pseudo-random number
10824 @fnindex RAN
10825 @cindex random number generation
10827 @table @asis
10828 @item @emph{Description}:
10829 For compatibility with HP FORTRAN 77/iX, the @code{RAN} intrinsic is
10830 provided as an alias for @code{RAND}.  See @ref{RAND} for complete
10831 documentation.
10833 @item @emph{Standard}:
10834 GNU extension
10836 @item @emph{Class}:
10837 Function
10839 @item @emph{See also}:
10840 @ref{RAND}, @ref{RANDOM_NUMBER}
10841 @end table
10845 @node RAND
10846 @section @code{RAND} --- Real pseudo-random number
10847 @fnindex RAND
10848 @cindex random number generation
10850 @table @asis
10851 @item @emph{Description}:
10852 @code{RAND(FLAG)} returns a pseudo-random number from a uniform
10853 distribution between 0 and 1. If @var{FLAG} is 0, the next number
10854 in the current sequence is returned; if @var{FLAG} is 1, the generator
10855 is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
10856 it is used as a new seed with @code{SRAND}.
10858 This intrinsic routine is provided for backwards compatibility with
10859 GNU Fortran 77. It implements a simple modulo generator as provided 
10860 by @command{g77}. For new code, one should consider the use of 
10861 @ref{RANDOM_NUMBER} as it implements a superior algorithm.
10863 @item @emph{Standard}:
10864 GNU extension
10866 @item @emph{Class}:
10867 Function
10869 @item @emph{Syntax}:
10870 @code{RESULT = RAND(I)}
10872 @item @emph{Arguments}:
10873 @multitable @columnfractions .15 .70
10874 @item @var{I} @tab Shall be a scalar @code{INTEGER} of kind 4.
10875 @end multitable
10877 @item @emph{Return value}:
10878 The return value is of @code{REAL} type and the default kind.
10880 @item @emph{Example}:
10881 @smallexample
10882 program test_rand
10883   integer,parameter :: seed = 86456
10884   
10885   call srand(seed)
10886   print *, rand(), rand(), rand(), rand()
10887   print *, rand(seed), rand(), rand(), rand()
10888 end program test_rand
10889 @end smallexample
10891 @item @emph{See also}:
10892 @ref{SRAND}, @ref{RANDOM_NUMBER}
10894 @end table
10898 @node RANDOM_NUMBER
10899 @section @code{RANDOM_NUMBER} --- Pseudo-random number
10900 @fnindex RANDOM_NUMBER
10901 @cindex random number generation
10903 @table @asis
10904 @item @emph{Description}:
10905 Returns a single pseudorandom number or an array of pseudorandom numbers
10906 from the uniform distribution over the range @math{ 0 \leq x < 1}.
10908 The runtime-library implements George Marsaglia's KISS (Keep It Simple 
10909 Stupid) random number generator (RNG). This RNG combines:
10910 @enumerate
10911 @item The congruential generator @math{x(n) = 69069 \cdot x(n-1) + 1327217885}
10912 with a period of @math{2^{32}},
10913 @item A 3-shift shift-register generator with a period of @math{2^{32} - 1},
10914 @item  Two 16-bit multiply-with-carry generators with a period of
10915 @math{597273182964842497 > 2^{59}}.
10916 @end enumerate
10917 The overall period exceeds @math{2^{123}}.
10919 Please note, this RNG is thread safe if used within OpenMP directives,
10920 i.e., its state will be consistent while called from multiple threads.
10921 However, the KISS generator does not create random numbers in parallel 
10922 from multiple sources, but in sequence from a single source. If an
10923 OpenMP-enabled application heavily relies on random numbers, one should 
10924 consider employing a dedicated parallel random number generator instead.
10926 @item @emph{Standard}:
10927 Fortran 95 and later
10929 @item @emph{Class}:
10930 Subroutine
10932 @item @emph{Syntax}:
10933 @code{RANDOM_NUMBER(HARVEST)}
10935 @item @emph{Arguments}:
10936 @multitable @columnfractions .15 .70
10937 @item @var{HARVEST} @tab Shall be a scalar or an array of type @code{REAL}.
10938 @end multitable
10940 @item @emph{Example}:
10941 @smallexample
10942 program test_random_number
10943   REAL :: r(5,5)
10944   CALL init_random_seed()         ! see example of RANDOM_SEED
10945   CALL RANDOM_NUMBER(r)
10946 end program
10947 @end smallexample
10949 @item @emph{See also}:
10950 @ref{RANDOM_SEED}
10951 @end table
10955 @node RANDOM_SEED
10956 @section @code{RANDOM_SEED} --- Initialize a pseudo-random number sequence
10957 @fnindex RANDOM_SEED
10958 @cindex random number generation, seeding
10959 @cindex seeding a random number generator
10961 @table @asis
10962 @item @emph{Description}:
10963 Restarts or queries the state of the pseudorandom number generator used by 
10964 @code{RANDOM_NUMBER}.
10966 If @code{RANDOM_SEED} is called without arguments, it is initialized
10967 to a default state. The example below shows how to initialize the
10968 random seed with a varying seed in order to ensure a different random
10969 number sequence for each invocation of the program. Note that setting
10970 any of the seed values to zero should be avoided as it can result in
10971 poor quality random numbers being generated.
10973 @item @emph{Standard}:
10974 Fortran 95 and later
10976 @item @emph{Class}:
10977 Subroutine
10979 @item @emph{Syntax}:
10980 @code{CALL RANDOM_SEED([SIZE, PUT, GET])}
10982 @item @emph{Arguments}:
10983 @multitable @columnfractions .15 .70
10984 @item @var{SIZE} @tab (Optional) Shall be a scalar and of type default 
10985 @code{INTEGER}, with @code{INTENT(OUT)}. It specifies the minimum size 
10986 of the arrays used with the @var{PUT} and @var{GET} arguments.
10987 @item @var{PUT}  @tab (Optional) Shall be an array of type default 
10988 @code{INTEGER} and rank one. It is @code{INTENT(IN)} and the size of 
10989 the array must be larger than or equal to the number returned by the 
10990 @var{SIZE} argument.
10991 @item @var{GET}  @tab (Optional) Shall be an array of type default 
10992 @code{INTEGER} and rank one. It is @code{INTENT(OUT)} and the size 
10993 of the array must be larger than or equal to the number returned by 
10994 the @var{SIZE} argument.
10995 @end multitable
10997 @item @emph{Example}:
10998 @smallexample
10999 subroutine init_random_seed()
11000   use iso_fortran_env, only: int64
11001   implicit none
11002   integer, allocatable :: seed(:)
11003   integer :: i, n, un, istat, dt(8), pid
11004   integer(int64) :: t
11006   call random_seed(size = n)
11007   allocate(seed(n))
11008   ! First try if the OS provides a random number generator
11009   open(newunit=un, file="/dev/urandom", access="stream", &
11010        form="unformatted", action="read", status="old", iostat=istat)
11011   if (istat == 0) then
11012      read(un) seed
11013      close(un)
11014   else
11015      ! Fallback to XOR:ing the current time and pid. The PID is
11016      ! useful in case one launches multiple instances of the same
11017      ! program in parallel.
11018      call system_clock(t)
11019      if (t == 0) then
11020         call date_and_time(values=dt)
11021         t = (dt(1) - 1970) * 365_int64 * 24 * 60 * 60 * 1000 &
11022              + dt(2) * 31_int64 * 24 * 60 * 60 * 1000 &
11023              + dt(3) * 24_int64 * 60 * 60 * 1000 &
11024              + dt(5) * 60 * 60 * 1000 &
11025              + dt(6) * 60 * 1000 + dt(7) * 1000 &
11026              + dt(8)
11027      end if
11028      pid = getpid()
11029      t = ieor(t, int(pid, kind(t)))
11030      do i = 1, n
11031         seed(i) = lcg(t)
11032      end do
11033   end if
11034   call random_seed(put=seed)
11035 contains
11036   ! This simple PRNG might not be good enough for real work, but is
11037   ! sufficient for seeding a better PRNG.
11038   function lcg(s)
11039     integer :: lcg
11040     integer(int64) :: s
11041     if (s == 0) then
11042        s = 104729
11043     else
11044        s = mod(s, 4294967296_int64)
11045     end if
11046     s = mod(s * 279470273_int64, 4294967291_int64)
11047     lcg = int(mod(s, int(huge(0), int64)), kind(0))
11048   end function lcg
11049 end subroutine init_random_seed
11050 @end smallexample
11052 @item @emph{See also}:
11053 @ref{RANDOM_NUMBER}
11054 @end table
11058 @node RANGE
11059 @section @code{RANGE} --- Decimal exponent range
11060 @fnindex RANGE
11061 @cindex model representation, range
11063 @table @asis
11064 @item @emph{Description}:
11065 @code{RANGE(X)} returns the decimal exponent range in the model of the
11066 type of @code{X}.
11068 @item @emph{Standard}:
11069 Fortran 95 and later
11071 @item @emph{Class}:
11072 Inquiry function
11074 @item @emph{Syntax}:
11075 @code{RESULT = RANGE(X)}
11077 @item @emph{Arguments}:
11078 @multitable @columnfractions .15 .70
11079 @item @var{X} @tab Shall be of type @code{INTEGER}, @code{REAL}
11080 or @code{COMPLEX}.
11081 @end multitable
11083 @item @emph{Return value}:
11084 The return value is of type @code{INTEGER} and of the default integer
11085 kind.
11087 @item @emph{See also}:
11088 @ref{SELECTED_REAL_KIND}, @ref{PRECISION}
11090 @item @emph{Example}:
11091 See @code{PRECISION} for an example.
11092 @end table
11096 @node RANK
11097 @section @code{RANK} --- Rank of a data object
11098 @fnindex RANK
11099 @cindex rank
11101 @table @asis
11102 @item @emph{Description}:
11103 @code{RANK(A)} returns the rank of a scalar or array data object.
11105 @item @emph{Standard}:
11106 Technical Specification (TS) 29113
11108 @item @emph{Class}:
11109 Inquiry function
11111 @item @emph{Syntax}:
11112 @code{RESULT = RANK(A)}
11114 @item @emph{Arguments}:
11115 @multitable @columnfractions .15 .70
11116 @item @var{A} @tab can be of any type
11117 @end multitable
11119 @item @emph{Return value}:
11120 The return value is of type @code{INTEGER} and of the default integer
11121 kind. For arrays, their rank is returned; for scalars zero is returned.
11123 @item @emph{Example}:
11124 @smallexample
11125 program test_rank
11126   integer :: a
11127   real, allocatable :: b(:,:)
11129   print *, rank(a), rank(b) ! Prints:  0  2
11130 end program test_rank
11131 @end smallexample
11133 @end table
11137 @node REAL
11138 @section @code{REAL} --- Convert to real type 
11139 @fnindex REAL
11140 @fnindex REALPART
11141 @fnindex FLOAT
11142 @fnindex DFLOAT
11143 @fnindex SNGL
11144 @cindex conversion, to real
11145 @cindex complex numbers, real part
11147 @table @asis
11148 @item @emph{Description}:
11149 @code{REAL(A [, KIND])} converts its argument @var{A} to a real type.  The
11150 @code{REALPART} function is provided for compatibility with @command{g77},
11151 and its use is strongly discouraged.
11153 @item @emph{Standard}:
11154 Fortran 77 and later
11156 @item @emph{Class}:
11157 Elemental function
11159 @item @emph{Syntax}:
11160 @multitable @columnfractions .80
11161 @item @code{RESULT = REAL(A [, KIND])}
11162 @item @code{RESULT = REALPART(Z)}
11163 @end multitable
11165 @item @emph{Arguments}:
11166 @multitable @columnfractions .15 .70
11167 @item @var{A}    @tab Shall be @code{INTEGER}, @code{REAL}, or
11168 @code{COMPLEX}.
11169 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
11170 expression indicating the kind parameter of the result.
11171 @end multitable
11173 @item @emph{Return value}:
11174 These functions return a @code{REAL} variable or array under
11175 the following rules: 
11177 @table @asis
11178 @item (A)
11179 @code{REAL(A)} is converted to a default real type if @var{A} is an 
11180 integer or real variable.
11181 @item (B)
11182 @code{REAL(A)} is converted to a real type with the kind type parameter
11183 of @var{A} if @var{A} is a complex variable.
11184 @item (C)
11185 @code{REAL(A, KIND)} is converted to a real type with kind type
11186 parameter @var{KIND} if @var{A} is a complex, integer, or real
11187 variable.
11188 @end table
11190 @item @emph{Example}:
11191 @smallexample
11192 program test_real
11193   complex :: x = (1.0, 2.0)
11194   print *, real(x), real(x,8), realpart(x)
11195 end program test_real
11196 @end smallexample
11198 @item @emph{Specific names}:
11199 @multitable @columnfractions .20 .20 .20 .25
11200 @item Name             @tab Argument           @tab Return type     @tab Standard
11201 @item @code{FLOAT(A)}  @tab @code{INTEGER(4)}  @tab @code{REAL(4)}  @tab Fortran 77 and later
11202 @item @code{DFLOAT(A)} @tab @code{INTEGER(4)}  @tab @code{REAL(8)}  @tab GNU extension
11203 @item @code{SNGL(A)}   @tab @code{INTEGER(8)}  @tab @code{REAL(4)}  @tab Fortran 77 and later
11204 @end multitable
11207 @item @emph{See also}:
11208 @ref{DBLE}
11210 @end table
11214 @node RENAME
11215 @section @code{RENAME} --- Rename a file
11216 @fnindex RENAME
11217 @cindex file system, rename file
11219 @table @asis
11220 @item @emph{Description}:
11221 Renames a file from file @var{PATH1} to @var{PATH2}. A null
11222 character (@code{CHAR(0)}) can be used to mark the end of the names in
11223 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
11224 names are ignored.  If the @var{STATUS} argument is supplied, it
11225 contains 0 on success or a nonzero error code upon return; see
11226 @code{rename(2)}.
11228 This intrinsic is provided in both subroutine and function forms;
11229 however, only one form can be used in any given program unit.
11231 @item @emph{Standard}:
11232 GNU extension
11234 @item @emph{Class}:
11235 Subroutine, function
11237 @item @emph{Syntax}:
11238 @multitable @columnfractions .80
11239 @item @code{CALL RENAME(PATH1, PATH2 [, STATUS])}
11240 @item @code{STATUS = RENAME(PATH1, PATH2)}
11241 @end multitable
11243 @item @emph{Arguments}:
11244 @multitable @columnfractions .15 .70
11245 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
11246 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
11247 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
11248 @end multitable
11250 @item @emph{See also}:
11251 @ref{LINK}
11253 @end table
11257 @node REPEAT
11258 @section @code{REPEAT} --- Repeated string concatenation 
11259 @fnindex REPEAT
11260 @cindex string, repeat
11261 @cindex string, concatenate
11263 @table @asis
11264 @item @emph{Description}:
11265 Concatenates @var{NCOPIES} copies of a string.
11267 @item @emph{Standard}:
11268 Fortran 95 and later
11270 @item @emph{Class}:
11271 Transformational function
11273 @item @emph{Syntax}:
11274 @code{RESULT = REPEAT(STRING, NCOPIES)}
11276 @item @emph{Arguments}:
11277 @multitable @columnfractions .15 .70
11278 @item @var{STRING}  @tab Shall be scalar and of type @code{CHARACTER}.
11279 @item @var{NCOPIES} @tab Shall be scalar and of type @code{INTEGER}.
11280 @end multitable
11282 @item @emph{Return value}:
11283 A new scalar of type @code{CHARACTER} built up from @var{NCOPIES} copies 
11284 of @var{STRING}.
11286 @item @emph{Example}:
11287 @smallexample
11288 program test_repeat
11289   write(*,*) repeat("x", 5)   ! "xxxxx"
11290 end program
11291 @end smallexample
11292 @end table
11296 @node RESHAPE
11297 @section @code{RESHAPE} --- Function to reshape an array
11298 @fnindex RESHAPE
11299 @cindex array, change dimensions
11300 @cindex array, transmogrify
11302 @table @asis
11303 @item @emph{Description}:
11304 Reshapes @var{SOURCE} to correspond to @var{SHAPE}. If necessary,
11305 the new array may be padded with elements from @var{PAD} or permuted
11306 as defined by @var{ORDER}.
11308 @item @emph{Standard}:
11309 Fortran 95 and later
11311 @item @emph{Class}:
11312 Transformational function
11314 @item @emph{Syntax}:
11315 @code{RESULT = RESHAPE(SOURCE, SHAPE[, PAD, ORDER])}
11317 @item @emph{Arguments}:
11318 @multitable @columnfractions .15 .70
11319 @item @var{SOURCE} @tab Shall be an array of any type.
11320 @item @var{SHAPE}  @tab Shall be of type @code{INTEGER} and an 
11321 array of rank one. Its values must be positive or zero.
11322 @item @var{PAD}    @tab (Optional) shall be an array of the same 
11323 type as @var{SOURCE}.
11324 @item @var{ORDER}  @tab (Optional) shall be of type @code{INTEGER}
11325 and an array of the same shape as @var{SHAPE}. Its values shall
11326 be a permutation of the numbers from 1 to n, where n is the size of 
11327 @var{SHAPE}. If @var{ORDER} is absent, the natural ordering shall
11328 be assumed.
11329 @end multitable
11331 @item @emph{Return value}:
11332 The result is an array of shape @var{SHAPE} with the same type as 
11333 @var{SOURCE}. 
11335 @item @emph{Example}:
11336 @smallexample
11337 PROGRAM test_reshape
11338   INTEGER, DIMENSION(4) :: x
11339   WRITE(*,*) SHAPE(x)                       ! prints "4"
11340   WRITE(*,*) SHAPE(RESHAPE(x, (/2, 2/)))    ! prints "2 2"
11341 END PROGRAM
11342 @end smallexample
11344 @item @emph{See also}:
11345 @ref{SHAPE}
11346 @end table
11350 @node RRSPACING
11351 @section @code{RRSPACING} --- Reciprocal of the relative spacing
11352 @fnindex RRSPACING
11353 @cindex real number, relative spacing
11354 @cindex floating point, relative spacing
11357 @table @asis
11358 @item @emph{Description}:
11359 @code{RRSPACING(X)} returns the  reciprocal of the relative spacing of
11360 model numbers near @var{X}.
11362 @item @emph{Standard}:
11363 Fortran 95 and later
11365 @item @emph{Class}:
11366 Elemental function
11368 @item @emph{Syntax}:
11369 @code{RESULT = RRSPACING(X)}
11371 @item @emph{Arguments}:
11372 @multitable @columnfractions .15 .70
11373 @item @var{X} @tab Shall be of type @code{REAL}.
11374 @end multitable
11376 @item @emph{Return value}:
11377 The return value is of the same type and kind as @var{X}.
11378 The value returned is equal to
11379 @code{ABS(FRACTION(X)) * FLOAT(RADIX(X))**DIGITS(X)}.
11381 @item @emph{See also}:
11382 @ref{SPACING}
11383 @end table
11387 @node RSHIFT
11388 @section @code{RSHIFT} --- Right shift bits
11389 @fnindex RSHIFT
11390 @cindex bits, shift right
11392 @table @asis
11393 @item @emph{Description}:
11394 @code{RSHIFT} returns a value corresponding to @var{I} with all of the
11395 bits shifted right by @var{SHIFT} places.  If the absolute value of
11396 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
11397 Bits shifted out from the right end are lost. The fill is arithmetic: the
11398 bits shifted in from the left end are equal to the leftmost bit, which in
11399 two's complement representation is the sign bit.
11401 This function has been superseded by the @code{SHIFTA} intrinsic, which
11402 is standard in Fortran 2008 and later.
11404 @item @emph{Standard}:
11405 GNU extension
11407 @item @emph{Class}:
11408 Elemental function
11410 @item @emph{Syntax}:
11411 @code{RESULT = RSHIFT(I, SHIFT)}
11413 @item @emph{Arguments}:
11414 @multitable @columnfractions .15 .70
11415 @item @var{I} @tab The type shall be @code{INTEGER}.
11416 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
11417 @end multitable
11419 @item @emph{Return value}:
11420 The return value is of type @code{INTEGER} and of the same kind as
11421 @var{I}.
11423 @item @emph{See also}:
11424 @ref{ISHFT}, @ref{ISHFTC}, @ref{LSHIFT}, @ref{SHIFTA}, @ref{SHIFTR},
11425 @ref{SHIFTL}
11427 @end table
11431 @node SAME_TYPE_AS
11432 @section @code{SAME_TYPE_AS} ---  Query dynamic types for equality
11433 @fnindex SAME_TYPE_AS
11435 @table @asis
11436 @item @emph{Description}:
11437 Query dynamic types for equality.
11439 @item @emph{Standard}:
11440 Fortran 2003 and later
11442 @item @emph{Class}:
11443 Inquiry function
11445 @item @emph{Syntax}:
11446 @code{RESULT = SAME_TYPE_AS(A, B)}
11448 @item @emph{Arguments}:
11449 @multitable @columnfractions .15 .70
11450 @item @var{A} @tab Shall be an object of extensible declared type or
11451 unlimited polymorphic.
11452 @item @var{B} @tab Shall be an object of extensible declared type or
11453 unlimited polymorphic.
11454 @end multitable
11456 @item @emph{Return value}:
11457 The return value is a scalar of type default logical. It is true if and
11458 only if the dynamic type of A is the same as the dynamic type of B.
11460 @item @emph{See also}:
11461 @ref{EXTENDS_TYPE_OF}
11463 @end table
11467 @node SCALE
11468 @section @code{SCALE} --- Scale a real value
11469 @fnindex SCALE
11470 @cindex real number, scale
11471 @cindex floating point, scale
11473 @table @asis
11474 @item @emph{Description}:
11475 @code{SCALE(X,I)} returns @code{X * RADIX(X)**I}.
11477 @item @emph{Standard}:
11478 Fortran 95 and later
11480 @item @emph{Class}:
11481 Elemental function
11483 @item @emph{Syntax}:
11484 @code{RESULT = SCALE(X, I)}
11486 @item @emph{Arguments}:
11487 @multitable @columnfractions .15 .70
11488 @item @var{X} @tab The type of the argument shall be a @code{REAL}.
11489 @item @var{I} @tab The type of the argument shall be a @code{INTEGER}.
11490 @end multitable
11492 @item @emph{Return value}:
11493 The return value is of the same type and kind as @var{X}.
11494 Its value is @code{X * RADIX(X)**I}.
11496 @item @emph{Example}:
11497 @smallexample
11498 program test_scale
11499   real :: x = 178.1387e-4
11500   integer :: i = 5
11501   print *, scale(x,i), x*radix(x)**i
11502 end program test_scale
11503 @end smallexample
11505 @end table
11509 @node SCAN
11510 @section @code{SCAN} --- Scan a string for the presence of a set of characters
11511 @fnindex SCAN
11512 @cindex string, find subset
11514 @table @asis
11515 @item @emph{Description}:
11516 Scans a @var{STRING} for any of the characters in a @var{SET} 
11517 of characters.
11519 If @var{BACK} is either absent or equals @code{FALSE}, this function
11520 returns the position of the leftmost character of @var{STRING} that is
11521 in @var{SET}. If @var{BACK} equals @code{TRUE}, the rightmost position
11522 is returned. If no character of @var{SET} is found in @var{STRING}, the 
11523 result is zero.
11525 @item @emph{Standard}:
11526 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
11528 @item @emph{Class}:
11529 Elemental function
11531 @item @emph{Syntax}:
11532 @code{RESULT = SCAN(STRING, SET[, BACK [, KIND]])}
11534 @item @emph{Arguments}:
11535 @multitable @columnfractions .15 .70
11536 @item @var{STRING} @tab Shall be of type @code{CHARACTER}.
11537 @item @var{SET}    @tab Shall be of type @code{CHARACTER}.
11538 @item @var{BACK}   @tab (Optional) shall be of type @code{LOGICAL}.
11539 @item @var{KIND}   @tab (Optional) An @code{INTEGER} initialization
11540 expression indicating the kind parameter of the result.
11541 @end multitable
11543 @item @emph{Return value}:
11544 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
11545 @var{KIND} is absent, the return value is of default integer kind.
11547 @item @emph{Example}:
11548 @smallexample
11549 PROGRAM test_scan
11550   WRITE(*,*) SCAN("FORTRAN", "AO")          ! 2, found 'O'
11551   WRITE(*,*) SCAN("FORTRAN", "AO", .TRUE.)  ! 6, found 'A'
11552   WRITE(*,*) SCAN("FORTRAN", "C++")         ! 0, found none
11553 END PROGRAM
11554 @end smallexample
11556 @item @emph{See also}:
11557 @ref{INDEX intrinsic}, @ref{VERIFY}
11558 @end table
11562 @node SECNDS
11563 @section @code{SECNDS} --- Time function
11564 @fnindex SECNDS
11565 @cindex time, elapsed
11566 @cindex elapsed time
11568 @table @asis
11569 @item @emph{Description}:
11570 @code{SECNDS(X)} gets the time in seconds from the real-time system clock.
11571 @var{X} is a reference time, also in seconds. If this is zero, the time in
11572 seconds from midnight is returned. This function is non-standard and its
11573 use is discouraged.
11575 @item @emph{Standard}:
11576 GNU extension
11578 @item @emph{Class}:
11579 Function
11581 @item @emph{Syntax}:
11582 @code{RESULT = SECNDS (X)}
11584 @item @emph{Arguments}:
11585 @multitable @columnfractions .15 .70
11586 @item @var{T}     @tab Shall be of type @code{REAL(4)}.
11587 @item @var{X}     @tab Shall be of type @code{REAL(4)}.
11588 @end multitable
11590 @item @emph{Return value}:
11591 None
11593 @item @emph{Example}:
11594 @smallexample
11595 program test_secnds
11596     integer :: i
11597     real(4) :: t1, t2
11598     print *, secnds (0.0)   ! seconds since midnight
11599     t1 = secnds (0.0)       ! reference time
11600     do i = 1, 10000000      ! do something
11601     end do
11602     t2 = secnds (t1)        ! elapsed time
11603     print *, "Something took ", t2, " seconds."
11604 end program test_secnds
11605 @end smallexample
11606 @end table
11610 @node SECOND
11611 @section @code{SECOND} --- CPU time function
11612 @fnindex SECOND
11613 @cindex time, elapsed
11614 @cindex elapsed time
11616 @table @asis
11617 @item @emph{Description}:
11618 Returns a @code{REAL(4)} value representing the elapsed CPU time in
11619 seconds.  This provides the same functionality as the standard
11620 @code{CPU_TIME} intrinsic, and is only included for backwards
11621 compatibility.
11623 This intrinsic is provided in both subroutine and function forms;
11624 however, only one form can be used in any given program unit.
11626 @item @emph{Standard}:
11627 GNU extension
11629 @item @emph{Class}:
11630 Subroutine, function
11632 @item @emph{Syntax}:
11633 @multitable @columnfractions .80
11634 @item @code{CALL SECOND(TIME)}
11635 @item @code{TIME = SECOND()}
11636 @end multitable
11638 @item @emph{Arguments}:
11639 @multitable @columnfractions .15 .70
11640 @item @var{TIME}  @tab Shall be of type @code{REAL(4)}.
11641 @end multitable
11643 @item @emph{Return value}:
11644 In either syntax, @var{TIME} is set to the process's current runtime in
11645 seconds.
11647 @item @emph{See also}:
11648 @ref{CPU_TIME}
11650 @end table
11654 @node SELECTED_CHAR_KIND
11655 @section @code{SELECTED_CHAR_KIND} --- Choose character kind
11656 @fnindex SELECTED_CHAR_KIND
11657 @cindex character kind
11658 @cindex kind, character
11660 @table @asis
11661 @item @emph{Description}:
11663 @code{SELECTED_CHAR_KIND(NAME)} returns the kind value for the character
11664 set named @var{NAME}, if a character set with such a name is supported,
11665 or @math{-1} otherwise. Currently, supported character sets include
11666 ``ASCII'' and ``DEFAULT'', which are equivalent, and ``ISO_10646''
11667 (Universal Character Set, UCS-4) which is commonly known as Unicode.
11669 @item @emph{Standard}:
11670 Fortran 2003 and later
11672 @item @emph{Class}:
11673 Transformational function
11675 @item @emph{Syntax}:
11676 @code{RESULT = SELECTED_CHAR_KIND(NAME)}
11678 @item @emph{Arguments}:
11679 @multitable @columnfractions .15 .70
11680 @item @var{NAME} @tab Shall be a scalar and of the default character type.
11681 @end multitable
11683 @item @emph{Example}:
11684 @smallexample
11685 program character_kind
11686   use iso_fortran_env
11687   implicit none
11688   integer, parameter :: ascii = selected_char_kind ("ascii")
11689   integer, parameter :: ucs4  = selected_char_kind ('ISO_10646')
11691   character(kind=ascii, len=26) :: alphabet
11692   character(kind=ucs4,  len=30) :: hello_world
11694   alphabet = ascii_"abcdefghijklmnopqrstuvwxyz"
11695   hello_world = ucs4_'Hello World and Ni Hao -- ' &
11696                 // char (int (z'4F60'), ucs4)     &
11697                 // char (int (z'597D'), ucs4)
11699   write (*,*) alphabet
11701   open (output_unit, encoding='UTF-8')
11702   write (*,*) trim (hello_world)
11703 end program character_kind
11704 @end smallexample
11705 @end table
11709 @node SELECTED_INT_KIND
11710 @section @code{SELECTED_INT_KIND} --- Choose integer kind
11711 @fnindex SELECTED_INT_KIND
11712 @cindex integer kind
11713 @cindex kind, integer
11715 @table @asis
11716 @item @emph{Description}:
11717 @code{SELECTED_INT_KIND(R)} return the kind value of the smallest integer
11718 type that can represent all values ranging from @math{-10^R} (exclusive)
11719 to @math{10^R} (exclusive). If there is no integer kind that accommodates
11720 this range, @code{SELECTED_INT_KIND} returns @math{-1}.
11722 @item @emph{Standard}:
11723 Fortran 95 and later
11725 @item @emph{Class}:
11726 Transformational function
11728 @item @emph{Syntax}:
11729 @code{RESULT = SELECTED_INT_KIND(R)}
11731 @item @emph{Arguments}:
11732 @multitable @columnfractions .15 .70
11733 @item @var{R} @tab Shall be a scalar and of type @code{INTEGER}.
11734 @end multitable
11736 @item @emph{Example}:
11737 @smallexample
11738 program large_integers
11739   integer,parameter :: k5 = selected_int_kind(5)
11740   integer,parameter :: k15 = selected_int_kind(15)
11741   integer(kind=k5) :: i5
11742   integer(kind=k15) :: i15
11744   print *, huge(i5), huge(i15)
11746   ! The following inequalities are always true
11747   print *, huge(i5) >= 10_k5**5-1
11748   print *, huge(i15) >= 10_k15**15-1
11749 end program large_integers
11750 @end smallexample
11751 @end table
11755 @node SELECTED_REAL_KIND
11756 @section @code{SELECTED_REAL_KIND} --- Choose real kind
11757 @fnindex SELECTED_REAL_KIND
11758 @cindex real kind
11759 @cindex kind, real
11760 @cindex radix, real
11762 @table @asis
11763 @item @emph{Description}:
11764 @code{SELECTED_REAL_KIND(P,R)} returns the kind value of a real data type
11765 with decimal precision of at least @code{P} digits, exponent range of
11766 at least @code{R}, and with a radix of @code{RADIX}.
11768 @item @emph{Standard}:
11769 Fortran 95 and later, with @code{RADIX} Fortran 2008 or later
11771 @item @emph{Class}:
11772 Transformational function
11774 @item @emph{Syntax}:
11775 @code{RESULT = SELECTED_REAL_KIND([P, R, RADIX])}
11777 @item @emph{Arguments}:
11778 @multitable @columnfractions .15 .70
11779 @item @var{P} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
11780 @item @var{R} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
11781 @item @var{RADIX} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
11782 @end multitable
11783 Before Fortran 2008, at least one of the arguments @var{R} or @var{P} shall
11784 be present; since Fortran 2008, they are assumed to be zero if absent.
11786 @item @emph{Return value}:
11788 @code{SELECTED_REAL_KIND} returns the value of the kind type parameter of
11789 a real data type with decimal precision of at least @code{P} digits, a
11790 decimal exponent range of at least @code{R}, and with the requested
11791 @code{RADIX}. If the @code{RADIX} parameter is absent, real kinds with
11792 any radix can be returned. If more than one real data type meet the
11793 criteria, the kind of the data type with the smallest decimal precision
11794 is returned. If no real data type matches the criteria, the result is
11795 @table @asis
11796 @item -1 if the processor does not support a real data type with a
11797 precision greater than or equal to @code{P}, but the @code{R} and
11798 @code{RADIX} requirements can be fulfilled
11799 @item -2 if the processor does not support a real type with an exponent
11800 range greater than or equal to @code{R}, but @code{P} and @code{RADIX}
11801 are fulfillable
11802 @item -3 if @code{RADIX} but not @code{P} and @code{R} requirements
11803 are fulfillable
11804 @item -4 if @code{RADIX} and either @code{P} or @code{R} requirements
11805 are fulfillable
11806 @item -5 if there is no real type with the given @code{RADIX}
11807 @end table
11809 @item @emph{See also}:
11810 @ref{PRECISION}, @ref{RANGE}, @ref{RADIX}
11812 @item @emph{Example}:
11813 @smallexample
11814 program real_kinds
11815   integer,parameter :: p6 = selected_real_kind(6)
11816   integer,parameter :: p10r100 = selected_real_kind(10,100)
11817   integer,parameter :: r400 = selected_real_kind(r=400)
11818   real(kind=p6) :: x
11819   real(kind=p10r100) :: y
11820   real(kind=r400) :: z
11822   print *, precision(x), range(x)
11823   print *, precision(y), range(y)
11824   print *, precision(z), range(z)
11825 end program real_kinds
11826 @end smallexample
11827 @end table
11831 @node SET_EXPONENT
11832 @section @code{SET_EXPONENT} --- Set the exponent of the model
11833 @fnindex SET_EXPONENT
11834 @cindex real number, set exponent
11835 @cindex floating point, set exponent
11837 @table @asis
11838 @item @emph{Description}:
11839 @code{SET_EXPONENT(X, I)} returns the real number whose fractional part
11840 is that that of @var{X} and whose exponent part is @var{I}.
11842 @item @emph{Standard}:
11843 Fortran 95 and later
11845 @item @emph{Class}:
11846 Elemental function
11848 @item @emph{Syntax}:
11849 @code{RESULT = SET_EXPONENT(X, I)}
11851 @item @emph{Arguments}:
11852 @multitable @columnfractions .15 .70
11853 @item @var{X} @tab Shall be of type @code{REAL}.
11854 @item @var{I} @tab Shall be of type @code{INTEGER}.
11855 @end multitable
11857 @item @emph{Return value}:
11858 The return value is of the same type and kind as @var{X}.
11859 The real number whose fractional part
11860 is that that of @var{X} and whose exponent part if @var{I} is returned;
11861 it is @code{FRACTION(X) * RADIX(X)**I}.
11863 @item @emph{Example}:
11864 @smallexample
11865 PROGRAM test_setexp
11866   REAL :: x = 178.1387e-4
11867   INTEGER :: i = 17
11868   PRINT *, SET_EXPONENT(x, i), FRACTION(x) * RADIX(x)**i
11869 END PROGRAM
11870 @end smallexample
11872 @end table
11876 @node SHAPE
11877 @section @code{SHAPE} --- Determine the shape of an array
11878 @fnindex SHAPE
11879 @cindex array, shape
11881 @table @asis
11882 @item @emph{Description}:
11883 Determines the shape of an array.
11885 @item @emph{Standard}:
11886 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
11888 @item @emph{Class}:
11889 Inquiry function
11891 @item @emph{Syntax}:
11892 @code{RESULT = SHAPE(SOURCE [, KIND])}
11894 @item @emph{Arguments}:
11895 @multitable @columnfractions .15 .70
11896 @item @var{SOURCE} @tab Shall be an array or scalar of any type. 
11897 If @var{SOURCE} is a pointer it must be associated and allocatable 
11898 arrays must be allocated.
11899 @item @var{KIND}   @tab (Optional) An @code{INTEGER} initialization
11900 expression indicating the kind parameter of the result.
11901 @end multitable
11903 @item @emph{Return value}:
11904 An @code{INTEGER} array of rank one with as many elements as @var{SOURCE} 
11905 has dimensions. The elements of the resulting array correspond to the extend
11906 of @var{SOURCE} along the respective dimensions. If @var{SOURCE} is a scalar,
11907 the result is the rank one array of size zero. If @var{KIND} is absent, the
11908 return value has the default integer kind otherwise the specified kind.
11910 @item @emph{Example}:
11911 @smallexample
11912 PROGRAM test_shape
11913   INTEGER, DIMENSION(-1:1, -1:2) :: A
11914   WRITE(*,*) SHAPE(A)             ! (/ 3, 4 /)
11915   WRITE(*,*) SIZE(SHAPE(42))      ! (/ /)
11916 END PROGRAM
11917 @end smallexample
11919 @item @emph{See also}:
11920 @ref{RESHAPE}, @ref{SIZE}
11921 @end table
11925 @node SHIFTA
11926 @section @code{SHIFTA} --- Right shift with fill
11927 @fnindex SHIFTA
11928 @cindex bits, shift right
11929 @cindex shift, right with fill
11931 @table @asis
11932 @item @emph{Description}:
11933 @code{SHIFTA} returns a value corresponding to @var{I} with all of the
11934 bits shifted right by @var{SHIFT} places.  If the absolute value of
11935 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
11936 Bits shifted out from the right end are lost. The fill is arithmetic: the
11937 bits shifted in from the left end are equal to the leftmost bit, which in
11938 two's complement representation is the sign bit.
11940 @item @emph{Standard}:
11941 Fortran 2008 and later
11943 @item @emph{Class}:
11944 Elemental function
11946 @item @emph{Syntax}:
11947 @code{RESULT = SHIFTA(I, SHIFT)}
11949 @item @emph{Arguments}:
11950 @multitable @columnfractions .15 .70
11951 @item @var{I} @tab The type shall be @code{INTEGER}.
11952 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
11953 @end multitable
11955 @item @emph{Return value}:
11956 The return value is of type @code{INTEGER} and of the same kind as
11957 @var{I}.
11959 @item @emph{See also}:
11960 @ref{SHIFTL}, @ref{SHIFTR}
11961 @end table
11965 @node SHIFTL
11966 @section @code{SHIFTL} --- Left shift
11967 @fnindex SHIFTL
11968 @cindex bits, shift left
11969 @cindex shift, left
11971 @table @asis
11972 @item @emph{Description}:
11973 @code{SHIFTL} returns a value corresponding to @var{I} with all of the
11974 bits shifted left by @var{SHIFT} places.  If the absolute value of
11975 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
11976 Bits shifted out from the left end are lost, and bits shifted in from
11977 the right end are set to 0.
11979 @item @emph{Standard}:
11980 Fortran 2008 and later
11982 @item @emph{Class}:
11983 Elemental function
11985 @item @emph{Syntax}:
11986 @code{RESULT = SHIFTL(I, SHIFT)}
11988 @item @emph{Arguments}:
11989 @multitable @columnfractions .15 .70
11990 @item @var{I} @tab The type shall be @code{INTEGER}.
11991 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
11992 @end multitable
11994 @item @emph{Return value}:
11995 The return value is of type @code{INTEGER} and of the same kind as
11996 @var{I}.
11998 @item @emph{See also}:
11999 @ref{SHIFTA}, @ref{SHIFTR}
12000 @end table
12004 @node SHIFTR
12005 @section @code{SHIFTR} --- Right shift
12006 @fnindex SHIFTR
12007 @cindex bits, shift right
12008 @cindex shift, right
12010 @table @asis
12011 @item @emph{Description}:
12012 @code{SHIFTR} returns a value corresponding to @var{I} with all of the
12013 bits shifted right by @var{SHIFT} places.  If the absolute value of
12014 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
12015 Bits shifted out from the right end are lost, and bits shifted in from
12016 the left end are set to 0.
12018 @item @emph{Standard}:
12019 Fortran 2008 and later
12021 @item @emph{Class}:
12022 Elemental function
12024 @item @emph{Syntax}:
12025 @code{RESULT = SHIFTR(I, SHIFT)}
12027 @item @emph{Arguments}:
12028 @multitable @columnfractions .15 .70
12029 @item @var{I} @tab The type shall be @code{INTEGER}.
12030 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
12031 @end multitable
12033 @item @emph{Return value}:
12034 The return value is of type @code{INTEGER} and of the same kind as
12035 @var{I}.
12037 @item @emph{See also}:
12038 @ref{SHIFTA}, @ref{SHIFTL}
12039 @end table
12043 @node SIGN
12044 @section @code{SIGN} --- Sign copying function
12045 @fnindex SIGN
12046 @fnindex ISIGN
12047 @fnindex DSIGN
12048 @cindex sign copying
12050 @table @asis
12051 @item @emph{Description}:
12052 @code{SIGN(A,B)} returns the value of @var{A} with the sign of @var{B}.
12054 @item @emph{Standard}:
12055 Fortran 77 and later
12057 @item @emph{Class}:
12058 Elemental function
12060 @item @emph{Syntax}:
12061 @code{RESULT = SIGN(A, B)}
12063 @item @emph{Arguments}:
12064 @multitable @columnfractions .15 .70
12065 @item @var{A} @tab Shall be of type @code{INTEGER} or @code{REAL}
12066 @item @var{B} @tab Shall be of the same type and kind as @var{A}
12067 @end multitable
12069 @item @emph{Return value}:
12070 The kind of the return value is that of @var{A} and @var{B}.
12071 If @math{B\ge 0} then the result is @code{ABS(A)}, else
12072 it is @code{-ABS(A)}.
12074 @item @emph{Example}:
12075 @smallexample
12076 program test_sign
12077   print *, sign(-12,1)
12078   print *, sign(-12,0)
12079   print *, sign(-12,-1)
12081   print *, sign(-12.,1.)
12082   print *, sign(-12.,0.)
12083   print *, sign(-12.,-1.)
12084 end program test_sign
12085 @end smallexample
12087 @item @emph{Specific names}:
12088 @multitable @columnfractions .20 .20 .20 .25
12089 @item Name              @tab Arguments              @tab Return type       @tab Standard
12090 @item @code{SIGN(A,B)}  @tab @code{REAL(4) A, B}    @tab @code{REAL(4)}    @tab f77, gnu
12091 @item @code{ISIGN(A,B)} @tab @code{INTEGER(4) A, B} @tab @code{INTEGER(4)} @tab f77, gnu
12092 @item @code{DSIGN(A,B)} @tab @code{REAL(8) A, B}    @tab @code{REAL(8)}    @tab f77, gnu
12093 @end multitable
12094 @end table
12098 @node SIGNAL
12099 @section @code{SIGNAL} --- Signal handling subroutine (or function)
12100 @fnindex SIGNAL
12101 @cindex system, signal handling
12103 @table @asis
12104 @item @emph{Description}:
12105 @code{SIGNAL(NUMBER, HANDLER [, STATUS])} causes external subroutine
12106 @var{HANDLER} to be executed with a single integer argument when signal
12107 @var{NUMBER} occurs.  If @var{HANDLER} is an integer, it can be used to
12108 turn off handling of signal @var{NUMBER} or revert to its default
12109 action.  See @code{signal(2)}.
12111 If @code{SIGNAL} is called as a subroutine and the @var{STATUS} argument
12112 is supplied, it is set to the value returned by @code{signal(2)}.
12114 @item @emph{Standard}:
12115 GNU extension
12117 @item @emph{Class}:
12118 Subroutine, function
12120 @item @emph{Syntax}:
12121 @multitable @columnfractions .80
12122 @item @code{CALL SIGNAL(NUMBER, HANDLER [, STATUS])}
12123 @item @code{STATUS = SIGNAL(NUMBER, HANDLER)}
12124 @end multitable
12126 @item @emph{Arguments}:
12127 @multitable @columnfractions .15 .70
12128 @item @var{NUMBER} @tab Shall be a scalar integer, with @code{INTENT(IN)}
12129 @item @var{HANDLER}@tab Signal handler (@code{INTEGER FUNCTION} or
12130 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar.
12131 @code{INTEGER}. It is @code{INTENT(IN)}.
12132 @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
12133 integer. It has @code{INTENT(OUT)}.
12134 @end multitable
12135 @c TODO: What should the interface of the handler be?  Does it take arguments?
12137 @item @emph{Return value}:
12138 The @code{SIGNAL} function returns the value returned by @code{signal(2)}.
12140 @item @emph{Example}:
12141 @smallexample
12142 program test_signal
12143   intrinsic signal
12144   external handler_print
12146   call signal (12, handler_print)
12147   call signal (10, 1)
12149   call sleep (30)
12150 end program test_signal
12151 @end smallexample
12152 @end table
12156 @node SIN
12157 @section @code{SIN} --- Sine function 
12158 @fnindex SIN
12159 @fnindex DSIN
12160 @fnindex CSIN
12161 @fnindex ZSIN
12162 @fnindex CDSIN
12163 @cindex trigonometric function, sine
12164 @cindex sine
12166 @table @asis
12167 @item @emph{Description}:
12168 @code{SIN(X)} computes the sine of @var{X}.
12170 @item @emph{Standard}:
12171 Fortran 77 and later
12173 @item @emph{Class}:
12174 Elemental function
12176 @item @emph{Syntax}:
12177 @code{RESULT = SIN(X)}
12179 @item @emph{Arguments}:
12180 @multitable @columnfractions .15 .70
12181 @item @var{X} @tab The type shall be @code{REAL} or
12182 @code{COMPLEX}.
12183 @end multitable
12185 @item @emph{Return value}:
12186 The return value has same type and kind as @var{X}.
12188 @item @emph{Example}:
12189 @smallexample
12190 program test_sin
12191   real :: x = 0.0
12192   x = sin(x)
12193 end program test_sin
12194 @end smallexample
12196 @item @emph{Specific names}:
12197 @multitable @columnfractions .20 .20 .20 .25
12198 @item Name            @tab Argument             @tab Return type       @tab Standard
12199 @item @code{SIN(X)}   @tab @code{REAL(4) X}     @tab @code{REAL(4)}    @tab f77, gnu
12200 @item @code{DSIN(X)}  @tab @code{REAL(8) X}     @tab @code{REAL(8)}    @tab f95, gnu
12201 @item @code{CSIN(X)}  @tab @code{COMPLEX(4) X}  @tab @code{COMPLEX(4)} @tab f95, gnu
12202 @item @code{ZSIN(X)}  @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)} @tab f95, gnu
12203 @item @code{CDSIN(X)} @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)} @tab f95, gnu
12204 @end multitable
12206 @item @emph{See also}:
12207 @ref{ASIN}
12208 @end table
12212 @node SINH
12213 @section @code{SINH} --- Hyperbolic sine function 
12214 @fnindex SINH
12215 @fnindex DSINH
12216 @cindex hyperbolic sine
12217 @cindex hyperbolic function, sine
12218 @cindex sine, hyperbolic
12220 @table @asis
12221 @item @emph{Description}:
12222 @code{SINH(X)} computes the hyperbolic sine of @var{X}.
12224 @item @emph{Standard}:
12225 Fortran 95 and later, for a complex argument Fortran 2008 or later
12227 @item @emph{Class}:
12228 Elemental function
12230 @item @emph{Syntax}:
12231 @code{RESULT = SINH(X)}
12233 @item @emph{Arguments}:
12234 @multitable @columnfractions .15 .70
12235 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
12236 @end multitable
12238 @item @emph{Return value}:
12239 The return value has same type and kind as @var{X}.
12241 @item @emph{Example}:
12242 @smallexample
12243 program test_sinh
12244   real(8) :: x = - 1.0_8
12245   x = sinh(x)
12246 end program test_sinh
12247 @end smallexample
12249 @item @emph{Specific names}:
12250 @multitable @columnfractions .20 .20 .20 .25
12251 @item Name            @tab Argument          @tab Return type       @tab Standard
12252 @item @code{SINH(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab Fortran 95 and later
12253 @item @code{DSINH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab Fortran 95 and later
12254 @end multitable
12256 @item @emph{See also}:
12257 @ref{ASINH}
12258 @end table
12262 @node SIZE
12263 @section @code{SIZE} --- Determine the size of an array
12264 @fnindex SIZE
12265 @cindex array, size
12266 @cindex array, number of elements
12267 @cindex array, count elements
12269 @table @asis
12270 @item @emph{Description}:
12271 Determine the extent of @var{ARRAY} along a specified dimension @var{DIM},
12272 or the total number of elements in @var{ARRAY} if @var{DIM} is absent.
12274 @item @emph{Standard}:
12275 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
12277 @item @emph{Class}:
12278 Inquiry function
12280 @item @emph{Syntax}:
12281 @code{RESULT = SIZE(ARRAY[, DIM [, KIND]])}
12283 @item @emph{Arguments}:
12284 @multitable @columnfractions .15 .70
12285 @item @var{ARRAY} @tab Shall be an array of any type. If @var{ARRAY} is
12286 a pointer it must be associated and allocatable arrays must be allocated.
12287 @item @var{DIM}   @tab (Optional) shall be a scalar of type @code{INTEGER} 
12288 and its value shall be in the range from 1 to n, where n equals the rank 
12289 of @var{ARRAY}.
12290 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
12291 expression indicating the kind parameter of the result.
12292 @end multitable
12294 @item @emph{Return value}:
12295 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
12296 @var{KIND} is absent, the return value is of default integer kind.
12298 @item @emph{Example}:
12299 @smallexample
12300 PROGRAM test_size
12301   WRITE(*,*) SIZE((/ 1, 2 /))    ! 2
12302 END PROGRAM
12303 @end smallexample
12305 @item @emph{See also}:
12306 @ref{SHAPE}, @ref{RESHAPE}
12307 @end table
12310 @node SIZEOF
12311 @section @code{SIZEOF} --- Size in bytes of an expression
12312 @fnindex SIZEOF
12313 @cindex expression size
12314 @cindex size of an expression
12316 @table @asis
12317 @item @emph{Description}:
12318 @code{SIZEOF(X)} calculates the number of bytes of storage the
12319 expression @code{X} occupies.
12321 @item @emph{Standard}:
12322 GNU extension
12324 @item @emph{Class}:
12325 Inquiry function
12327 @item @emph{Syntax}:
12328 @code{N = SIZEOF(X)}
12330 @item @emph{Arguments}:
12331 @multitable @columnfractions .15 .70
12332 @item @var{X} @tab The argument shall be of any type, rank or shape.
12333 @end multitable
12335 @item @emph{Return value}:
12336 The return value is of type integer and of the system-dependent kind
12337 @var{C_SIZE_T} (from the @var{ISO_C_BINDING} module). Its value is the
12338 number of bytes occupied by the argument.  If the argument has the
12339 @code{POINTER} attribute, the number of bytes of the storage area pointed
12340 to is returned.  If the argument is of a derived type with @code{POINTER}
12341 or @code{ALLOCATABLE} components, the return value does not account for
12342 the sizes of the data pointed to by these components. If the argument is
12343 polymorphic, the size according to the dynamic type is returned. The argument
12344 may not be a procedure or procedure pointer. Note that the code assumes for
12345 arrays that those are contiguous; for contiguous arrays, it returns the
12346 storage or an array element multiplied by the size of the array.
12348 @item @emph{Example}:
12349 @smallexample
12350    integer :: i
12351    real :: r, s(5)
12352    print *, (sizeof(s)/sizeof(r) == 5)
12353    end
12354 @end smallexample
12355 The example will print @code{.TRUE.} unless you are using a platform
12356 where default @code{REAL} variables are unusually padded.
12358 @item @emph{See also}:
12359 @ref{C_SIZEOF}, @ref{STORAGE_SIZE}
12360 @end table
12363 @node SLEEP
12364 @section @code{SLEEP} --- Sleep for the specified number of seconds
12365 @fnindex SLEEP
12366 @cindex delayed execution
12368 @table @asis
12369 @item @emph{Description}:
12370 Calling this subroutine causes the process to pause for @var{SECONDS} seconds.
12372 @item @emph{Standard}:
12373 GNU extension
12375 @item @emph{Class}:
12376 Subroutine
12378 @item @emph{Syntax}:
12379 @code{CALL SLEEP(SECONDS)}
12381 @item @emph{Arguments}:
12382 @multitable @columnfractions .15 .70
12383 @item @var{SECONDS} @tab The type shall be of default @code{INTEGER}.
12384 @end multitable
12386 @item @emph{Example}:
12387 @smallexample
12388 program test_sleep
12389   call sleep(5)
12391 @end smallexample
12392 @end table
12396 @node SPACING
12397 @section @code{SPACING} --- Smallest distance between two numbers of a given type
12398 @fnindex SPACING
12399 @cindex real number, relative spacing
12400 @cindex floating point, relative spacing
12402 @table @asis
12403 @item @emph{Description}:
12404 Determines the distance between the argument @var{X} and the nearest 
12405 adjacent number of the same type.
12407 @item @emph{Standard}:
12408 Fortran 95 and later
12410 @item @emph{Class}:
12411 Elemental function
12413 @item @emph{Syntax}:
12414 @code{RESULT = SPACING(X)}
12416 @item @emph{Arguments}:
12417 @multitable @columnfractions .15 .70
12418 @item @var{X} @tab Shall be of type @code{REAL}.
12419 @end multitable
12421 @item @emph{Return value}:
12422 The result is of the same type as the input argument @var{X}.
12424 @item @emph{Example}:
12425 @smallexample
12426 PROGRAM test_spacing
12427   INTEGER, PARAMETER :: SGL = SELECTED_REAL_KIND(p=6, r=37)
12428   INTEGER, PARAMETER :: DBL = SELECTED_REAL_KIND(p=13, r=200)
12430   WRITE(*,*) spacing(1.0_SGL)      ! "1.1920929E-07"          on i686
12431   WRITE(*,*) spacing(1.0_DBL)      ! "2.220446049250313E-016" on i686
12432 END PROGRAM
12433 @end smallexample
12435 @item @emph{See also}:
12436 @ref{RRSPACING}
12437 @end table
12441 @node SPREAD
12442 @section @code{SPREAD} --- Add a dimension to an array
12443 @fnindex SPREAD
12444 @cindex array, increase dimension
12445 @cindex array, duplicate elements
12446 @cindex array, duplicate dimensions
12448 @table @asis
12449 @item @emph{Description}:
12450 Replicates a @var{SOURCE} array @var{NCOPIES} times along a specified 
12451 dimension @var{DIM}.
12453 @item @emph{Standard}:
12454 Fortran 95 and later
12456 @item @emph{Class}:
12457 Transformational function
12459 @item @emph{Syntax}:
12460 @code{RESULT = SPREAD(SOURCE, DIM, NCOPIES)}
12462 @item @emph{Arguments}:
12463 @multitable @columnfractions .15 .70
12464 @item @var{SOURCE}  @tab Shall be a scalar or an array of any type and 
12465 a rank less than seven.
12466 @item @var{DIM}     @tab Shall be a scalar of type @code{INTEGER} with a 
12467 value in the range from 1 to n+1, where n equals the rank of @var{SOURCE}.
12468 @item @var{NCOPIES} @tab Shall be a scalar of type @code{INTEGER}.
12469 @end multitable
12471 @item @emph{Return value}:
12472 The result is an array of the same type as @var{SOURCE} and has rank n+1
12473 where n equals the rank of @var{SOURCE}.
12475 @item @emph{Example}:
12476 @smallexample
12477 PROGRAM test_spread
12478   INTEGER :: a = 1, b(2) = (/ 1, 2 /)
12479   WRITE(*,*) SPREAD(A, 1, 2)            ! "1 1"
12480   WRITE(*,*) SPREAD(B, 1, 2)            ! "1 1 2 2"
12481 END PROGRAM
12482 @end smallexample
12484 @item @emph{See also}:
12485 @ref{UNPACK}
12486 @end table
12490 @node SQRT
12491 @section @code{SQRT} --- Square-root function
12492 @fnindex SQRT
12493 @fnindex DSQRT
12494 @fnindex CSQRT
12495 @fnindex ZSQRT
12496 @fnindex CDSQRT
12497 @cindex root
12498 @cindex square-root
12500 @table @asis
12501 @item @emph{Description}:
12502 @code{SQRT(X)} computes the square root of @var{X}.
12504 @item @emph{Standard}:
12505 Fortran 77 and later
12507 @item @emph{Class}:
12508 Elemental function
12510 @item @emph{Syntax}:
12511 @code{RESULT = SQRT(X)}
12513 @item @emph{Arguments}:
12514 @multitable @columnfractions .15 .70
12515 @item @var{X} @tab The type shall be @code{REAL} or
12516 @code{COMPLEX}.
12517 @end multitable
12519 @item @emph{Return value}:
12520 The return value is of type @code{REAL} or @code{COMPLEX}.
12521 The kind type parameter is the same as @var{X}.
12523 @item @emph{Example}:
12524 @smallexample
12525 program test_sqrt
12526   real(8) :: x = 2.0_8
12527   complex :: z = (1.0, 2.0)
12528   x = sqrt(x)
12529   z = sqrt(z)
12530 end program test_sqrt
12531 @end smallexample
12533 @item @emph{Specific names}:
12534 @multitable @columnfractions .20 .20 .20 .25
12535 @item Name             @tab Argument             @tab Return type          @tab Standard
12536 @item @code{SQRT(X)}   @tab @code{REAL(4) X}     @tab @code{REAL(4)}       @tab Fortran 95 and later
12537 @item @code{DSQRT(X)}  @tab @code{REAL(8) X}     @tab @code{REAL(8)}       @tab Fortran 95 and later
12538 @item @code{CSQRT(X)}  @tab @code{COMPLEX(4) X}  @tab @code{COMPLEX(4)}    @tab Fortran 95 and later
12539 @item @code{ZSQRT(X)}  @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab GNU extension
12540 @item @code{CDSQRT(X)} @tab @code{COMPLEX(8) X}  @tab @code{COMPLEX(8)}    @tab GNU extension
12541 @end multitable
12542 @end table
12546 @node SRAND
12547 @section @code{SRAND} --- Reinitialize the random number generator
12548 @fnindex SRAND
12549 @cindex random number generation, seeding
12550 @cindex seeding a random number generator
12552 @table @asis
12553 @item @emph{Description}:
12554 @code{SRAND} reinitializes the pseudo-random number generator
12555 called by @code{RAND} and @code{IRAND}. The new seed used by the
12556 generator is specified by the required argument @var{SEED}.
12558 @item @emph{Standard}:
12559 GNU extension
12561 @item @emph{Class}:
12562 Subroutine
12564 @item @emph{Syntax}:
12565 @code{CALL SRAND(SEED)}
12567 @item @emph{Arguments}:
12568 @multitable @columnfractions .15 .70
12569 @item @var{SEED} @tab Shall be a scalar @code{INTEGER(kind=4)}.
12570 @end multitable
12572 @item @emph{Return value}:
12573 Does not return anything.
12575 @item @emph{Example}:
12576 See @code{RAND} and @code{IRAND} for examples.
12578 @item @emph{Notes}:
12579 The Fortran 2003 standard specifies the intrinsic @code{RANDOM_SEED} to
12580 initialize the pseudo-random numbers generator and @code{RANDOM_NUMBER}
12581 to generate pseudo-random numbers. Please note that in
12582 GNU Fortran, these two sets of intrinsics (@code{RAND},
12583 @code{IRAND} and @code{SRAND} on the one hand, @code{RANDOM_NUMBER} and
12584 @code{RANDOM_SEED} on the other hand) access two independent
12585 pseudo-random number generators.
12587 @item @emph{See also}:
12588 @ref{RAND}, @ref{RANDOM_SEED}, @ref{RANDOM_NUMBER}
12590 @end table
12594 @node STAT
12595 @section @code{STAT} --- Get file status
12596 @fnindex STAT
12597 @cindex file system, file status
12599 @table @asis
12600 @item @emph{Description}:
12601 This function returns information about a file. No permissions are required on 
12602 the file itself, but execute (search) permission is required on all of the 
12603 directories in path that lead to the file.
12605 The elements that are obtained and stored in the array @code{VALUES}:
12606 @multitable @columnfractions .15 .70
12607 @item @code{VALUES(1)}   @tab  Device ID 
12608 @item @code{VALUES(2)}   @tab  Inode number 
12609 @item @code{VALUES(3)}   @tab  File mode 
12610 @item @code{VALUES(4)}   @tab  Number of links 
12611 @item @code{VALUES(5)}   @tab  Owner's uid 
12612 @item @code{VALUES(6)}   @tab  Owner's gid 
12613 @item @code{VALUES(7)}   @tab  ID of device containing directory entry for file (0 if not available) 
12614 @item @code{VALUES(8)}   @tab  File size (bytes) 
12615 @item @code{VALUES(9)}   @tab  Last access time 
12616 @item @code{VALUES(10)}  @tab  Last modification time 
12617 @item @code{VALUES(11)}  @tab  Last file status change time 
12618 @item @code{VALUES(12)}  @tab  Preferred I/O block size (-1 if not available) 
12619 @item @code{VALUES(13)}  @tab  Number of blocks allocated (-1 if not available)
12620 @end multitable
12622 Not all these elements are relevant on all systems. 
12623 If an element is not relevant, it is returned as 0.
12625 This intrinsic is provided in both subroutine and function forms; however,
12626 only one form can be used in any given program unit.
12628 @item @emph{Standard}:
12629 GNU extension
12631 @item @emph{Class}:
12632 Subroutine, function
12634 @item @emph{Syntax}:
12635 @multitable @columnfractions .80
12636 @item @code{CALL STAT(NAME, VALUES [, STATUS])}
12637 @item @code{STATUS = STAT(NAME, VALUES)}
12638 @end multitable
12640 @item @emph{Arguments}:
12641 @multitable @columnfractions .15 .70
12642 @item @var{NAME}   @tab The type shall be @code{CHARACTER}, of the
12643 default kind and a valid path within the file system.
12644 @item @var{VALUES} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
12645 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0 
12646 on success and a system specific error code otherwise.
12647 @end multitable
12649 @item @emph{Example}:
12650 @smallexample
12651 PROGRAM test_stat
12652   INTEGER, DIMENSION(13) :: buff
12653   INTEGER :: status
12655   CALL STAT("/etc/passwd", buff, status)
12657   IF (status == 0) THEN
12658     WRITE (*, FMT="('Device ID:',               T30, I19)") buff(1)
12659     WRITE (*, FMT="('Inode number:',            T30, I19)") buff(2)
12660     WRITE (*, FMT="('File mode (octal):',       T30, O19)") buff(3)
12661     WRITE (*, FMT="('Number of links:',         T30, I19)") buff(4)
12662     WRITE (*, FMT="('Owner''s uid:',            T30, I19)") buff(5)
12663     WRITE (*, FMT="('Owner''s gid:',            T30, I19)") buff(6)
12664     WRITE (*, FMT="('Device where located:',    T30, I19)") buff(7)
12665     WRITE (*, FMT="('File size:',               T30, I19)") buff(8)
12666     WRITE (*, FMT="('Last access time:',        T30, A19)") CTIME(buff(9))
12667     WRITE (*, FMT="('Last modification time',   T30, A19)") CTIME(buff(10))
12668     WRITE (*, FMT="('Last status change time:', T30, A19)") CTIME(buff(11))
12669     WRITE (*, FMT="('Preferred block size:',    T30, I19)") buff(12)
12670     WRITE (*, FMT="('No. of blocks allocated:', T30, I19)") buff(13)
12671   END IF
12672 END PROGRAM
12673 @end smallexample
12675 @item @emph{See also}:
12676 To stat an open file: @ref{FSTAT}, to stat a link: @ref{LSTAT}
12677 @end table
12681 @node STORAGE_SIZE
12682 @section @code{STORAGE_SIZE} --- Storage size in bits
12683 @fnindex STORAGE_SIZE
12684 @cindex storage size
12686 @table @asis
12687 @item @emph{Description}:
12688 Returns the storage size of argument @var{A} in bits.
12689 @item @emph{Standard}:
12690 Fortran 2008 and later
12691 @item @emph{Class}:
12692 Inquiry function
12693 @item @emph{Syntax}:
12694 @code{RESULT = STORAGE_SIZE(A [, KIND])}
12696 @item @emph{Arguments}:
12697 @multitable @columnfractions .15 .70
12698 @item @var{A} @tab Shall be a scalar or array of any type.
12699 @item @var{KIND} @tab (Optional) shall be a scalar integer constant expression.
12700 @end multitable
12702 @item @emph{Return Value}:
12703 The result is a scalar integer with the kind type parameter specified by KIND
12704 (or default integer type if KIND is missing). The result value is the size
12705 expressed in bits for an element of an array that has the dynamic type and type
12706 parameters of A.
12708 @item @emph{See also}:
12709 @ref{C_SIZEOF}, @ref{SIZEOF}
12710 @end table
12714 @node SUM
12715 @section @code{SUM} --- Sum of array elements
12716 @fnindex SUM
12717 @cindex array, sum
12718 @cindex array, add elements
12719 @cindex array, conditionally add elements
12720 @cindex sum array elements
12722 @table @asis
12723 @item @emph{Description}:
12724 Adds the elements of @var{ARRAY} along dimension @var{DIM} if
12725 the corresponding element in @var{MASK} is @code{TRUE}.
12727 @item @emph{Standard}:
12728 Fortran 95 and later
12730 @item @emph{Class}:
12731 Transformational function
12733 @item @emph{Syntax}:
12734 @multitable @columnfractions .80
12735 @item @code{RESULT = SUM(ARRAY[, MASK])}
12736 @item @code{RESULT = SUM(ARRAY, DIM[, MASK])}
12737 @end multitable
12739 @item @emph{Arguments}:
12740 @multitable @columnfractions .15 .70
12741 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER}, 
12742 @code{REAL} or @code{COMPLEX}.
12743 @item @var{DIM}   @tab (Optional) shall be a scalar of type 
12744 @code{INTEGER} with a value in the range from 1 to n, where n 
12745 equals the rank of @var{ARRAY}.
12746 @item @var{MASK}  @tab (Optional) shall be of type @code{LOGICAL} 
12747 and either be a scalar or an array of the same shape as @var{ARRAY}.
12748 @end multitable
12750 @item @emph{Return value}:
12751 The result is of the same type as @var{ARRAY}.
12753 If @var{DIM} is absent, a scalar with the sum of all elements in @var{ARRAY}
12754 is returned. Otherwise, an array of rank n-1, where n equals the rank of 
12755 @var{ARRAY}, and a shape similar to that of @var{ARRAY} with dimension @var{DIM} 
12756 dropped is returned.
12758 @item @emph{Example}:
12759 @smallexample
12760 PROGRAM test_sum
12761   INTEGER :: x(5) = (/ 1, 2, 3, 4 ,5 /)
12762   print *, SUM(x)                        ! all elements, sum = 15
12763   print *, SUM(x, MASK=MOD(x, 2)==1)     ! odd elements, sum = 9
12764 END PROGRAM
12765 @end smallexample
12767 @item @emph{See also}:
12768 @ref{PRODUCT}
12769 @end table
12773 @node SYMLNK
12774 @section @code{SYMLNK} --- Create a symbolic link
12775 @fnindex SYMLNK
12776 @cindex file system, create link
12777 @cindex file system, soft link
12779 @table @asis
12780 @item @emph{Description}:
12781 Makes a symbolic link from file @var{PATH1} to @var{PATH2}. A null
12782 character (@code{CHAR(0)}) can be used to mark the end of the names in
12783 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
12784 names are ignored.  If the @var{STATUS} argument is supplied, it
12785 contains 0 on success or a nonzero error code upon return; see
12786 @code{symlink(2)}.  If the system does not supply @code{symlink(2)}, 
12787 @code{ENOSYS} is returned.
12789 This intrinsic is provided in both subroutine and function forms;
12790 however, only one form can be used in any given program unit.
12792 @item @emph{Standard}:
12793 GNU extension
12795 @item @emph{Class}:
12796 Subroutine, function
12798 @item @emph{Syntax}:
12799 @multitable @columnfractions .80
12800 @item @code{CALL SYMLNK(PATH1, PATH2 [, STATUS])}
12801 @item @code{STATUS = SYMLNK(PATH1, PATH2)}
12802 @end multitable
12804 @item @emph{Arguments}:
12805 @multitable @columnfractions .15 .70
12806 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
12807 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
12808 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
12809 @end multitable
12811 @item @emph{See also}:
12812 @ref{LINK}, @ref{UNLINK}
12814 @end table
12818 @node SYSTEM
12819 @section @code{SYSTEM} --- Execute a shell command
12820 @fnindex SYSTEM
12821 @cindex system, system call
12823 @table @asis
12824 @item @emph{Description}:
12825 Passes the command @var{COMMAND} to a shell (see @code{system(3)}). If
12826 argument @var{STATUS} is present, it contains the value returned by
12827 @code{system(3)}, which is presumably 0 if the shell command succeeded.
12828 Note that which shell is used to invoke the command is system-dependent
12829 and environment-dependent.
12831 This intrinsic is provided in both subroutine and function forms;
12832 however, only one form can be used in any given program unit.
12834 Note that the @code{system} function need not be thread-safe. It is
12835 the responsibility of the user to ensure that @code{system} is not
12836 called concurrently.
12838 @item @emph{Standard}:
12839 GNU extension
12841 @item @emph{Class}:
12842 Subroutine, function
12844 @item @emph{Syntax}:
12845 @multitable @columnfractions .80
12846 @item @code{CALL SYSTEM(COMMAND [, STATUS])}
12847 @item @code{STATUS = SYSTEM(COMMAND)}
12848 @end multitable
12850 @item @emph{Arguments}:
12851 @multitable @columnfractions .15 .70
12852 @item @var{COMMAND} @tab Shall be of default @code{CHARACTER} type.
12853 @item @var{STATUS}  @tab (Optional) Shall be of default @code{INTEGER} type.
12854 @end multitable
12856 @item @emph{See also}:
12857 @ref{EXECUTE_COMMAND_LINE}, which is part of the Fortran 2008 standard
12858 and should considered in new code for future portability.
12859 @end table
12863 @node SYSTEM_CLOCK
12864 @section @code{SYSTEM_CLOCK} --- Time function
12865 @fnindex SYSTEM_CLOCK
12866 @cindex time, clock ticks
12867 @cindex clock ticks
12869 @table @asis
12870 @item @emph{Description}:
12871 Determines the @var{COUNT} of a processor clock since an unspecified
12872 time in the past modulo @var{COUNT_MAX}, @var{COUNT_RATE} determines
12873 the number of clock ticks per second.  If the platform supports a
12874 monotonic clock, that clock is used and can, depending on the platform
12875 clock implementation, provide up to nanosecond resolution.  If a
12876 monotonic clock is not available, the implementation falls back to a
12877 realtime clock.
12879 @var{COUNT_RATE} is system dependent and can vary depending on the kind of
12880 the arguments. For @var{kind=4} arguments (and smaller integer kinds),
12881 @var{COUNT} represents milliseconds, while for @var{kind=8} arguments (and
12882 larger integer kinds), @var{COUNT} typically represents micro- or
12883 nanoseconds depending on resolution of the underlying platform clock.
12884 @var{COUNT_MAX} usually equals @code{HUGE(COUNT_MAX)}. Note that the
12885 millisecond resolution of the @var{kind=4} version implies that the
12886 @var{COUNT} will wrap around in roughly 25 days. In order to avoid issues
12887 with the wrap around and for more precise timing, please use the
12888 @var{kind=8} version.
12890 If there is no clock, or querying the clock fails, @var{COUNT} is set
12891 to @code{-HUGE(COUNT)}, and @var{COUNT_RATE} and @var{COUNT_MAX} are
12892 set to zero.
12894 When running on a platform using the GNU C library (glibc) version
12895 2.16 or older, or a derivative thereof, the high resolution monotonic
12896 clock is available only when linking with the @var{rt} library.  This
12897 can be done explicitly by adding the @code{-lrt} flag when linking the
12898 application, but is also done implicitly when using OpenMP.
12900 On the Windows platform, the version with @var{kind=4} arguments uses
12901 the @code{GetTickCount} function, whereas the @var{kind=8} version
12902 uses @code{QueryPerformanceCounter} and
12903 @code{QueryPerformanceCounterFrequency}. For more information, and
12904 potential caveats, please see the platform documentation.
12906 @item @emph{Standard}:
12907 Fortran 95 and later
12909 @item @emph{Class}:
12910 Subroutine
12912 @item @emph{Syntax}:
12913 @code{CALL SYSTEM_CLOCK([COUNT, COUNT_RATE, COUNT_MAX])}
12915 @item @emph{Arguments}:
12916 @multitable @columnfractions .15 .70
12917 @item @var{COUNT}      @tab (Optional) shall be a scalar of type 
12918 @code{INTEGER} with @code{INTENT(OUT)}.
12919 @item @var{COUNT_RATE} @tab (Optional) shall be a scalar of type 
12920 @code{INTEGER} or @code{REAL}, with @code{INTENT(OUT)}.
12921 @item @var{COUNT_MAX}  @tab (Optional) shall be a scalar of type 
12922 @code{INTEGER} with @code{INTENT(OUT)}.
12923 @end multitable
12925 @item @emph{Example}:
12926 @smallexample
12927 PROGRAM test_system_clock
12928   INTEGER :: count, count_rate, count_max
12929   CALL SYSTEM_CLOCK(count, count_rate, count_max)
12930   WRITE(*,*) count, count_rate, count_max
12931 END PROGRAM
12932 @end smallexample
12934 @item @emph{See also}:
12935 @ref{DATE_AND_TIME}, @ref{CPU_TIME}
12936 @end table
12940 @node TAN
12941 @section @code{TAN} --- Tangent function
12942 @fnindex TAN
12943 @fnindex DTAN
12944 @cindex trigonometric function, tangent
12945 @cindex tangent
12947 @table @asis
12948 @item @emph{Description}:
12949 @code{TAN(X)} computes the tangent of @var{X}.
12951 @item @emph{Standard}:
12952 Fortran 77 and later, for a complex argument Fortran 2008 or later
12954 @item @emph{Class}:
12955 Elemental function
12957 @item @emph{Syntax}:
12958 @code{RESULT = TAN(X)}
12960 @item @emph{Arguments}:
12961 @multitable @columnfractions .15 .70
12962 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
12963 @end multitable
12965 @item @emph{Return value}:
12966 The return value has same type and kind as @var{X}.
12968 @item @emph{Example}:
12969 @smallexample
12970 program test_tan
12971   real(8) :: x = 0.165_8
12972   x = tan(x)
12973 end program test_tan
12974 @end smallexample
12976 @item @emph{Specific names}:
12977 @multitable @columnfractions .20 .20 .20 .25
12978 @item Name            @tab Argument          @tab Return type     @tab Standard
12979 @item @code{TAN(X)}   @tab @code{REAL(4) X}  @tab @code{REAL(4)}  @tab Fortran 95 and later
12980 @item @code{DTAN(X)}  @tab @code{REAL(8) X}  @tab @code{REAL(8)}  @tab Fortran 95 and later
12981 @end multitable
12983 @item @emph{See also}:
12984 @ref{ATAN}
12985 @end table
12989 @node TANH
12990 @section @code{TANH} --- Hyperbolic tangent function 
12991 @fnindex TANH
12992 @fnindex DTANH
12993 @cindex hyperbolic tangent
12994 @cindex hyperbolic function, tangent
12995 @cindex tangent, hyperbolic
12997 @table @asis
12998 @item @emph{Description}:
12999 @code{TANH(X)} computes the hyperbolic tangent of @var{X}.
13001 @item @emph{Standard}:
13002 Fortran 77 and later, for a complex argument Fortran 2008 or later
13004 @item @emph{Class}:
13005 Elemental function
13007 @item @emph{Syntax}:
13008 @code{X = TANH(X)}
13010 @item @emph{Arguments}:
13011 @multitable @columnfractions .15 .70
13012 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
13013 @end multitable
13015 @item @emph{Return value}:
13016 The return value has same type and kind as @var{X}. If @var{X} is
13017 complex, the imaginary part of the result is in radians. If @var{X}
13018 is @code{REAL}, the return value lies in the range
13019 @math{ - 1 \leq tanh(x) \leq 1 }.
13021 @item @emph{Example}:
13022 @smallexample
13023 program test_tanh
13024   real(8) :: x = 2.1_8
13025   x = tanh(x)
13026 end program test_tanh
13027 @end smallexample
13029 @item @emph{Specific names}:
13030 @multitable @columnfractions .20 .20 .20 .25
13031 @item Name            @tab Argument          @tab Return type       @tab Standard
13032 @item @code{TANH(X)}  @tab @code{REAL(4) X}  @tab @code{REAL(4)}    @tab Fortran 95 and later
13033 @item @code{DTANH(X)} @tab @code{REAL(8) X}  @tab @code{REAL(8)}    @tab Fortran 95 and later
13034 @end multitable
13036 @item @emph{See also}:
13037 @ref{ATANH}
13038 @end table
13042 @node THIS_IMAGE
13043 @section @code{THIS_IMAGE} --- Function that returns the cosubscript index of this image
13044 @fnindex THIS_IMAGE
13045 @cindex coarray, @code{THIS_IMAGE}
13046 @cindex images, index of this image
13048 @table @asis
13049 @item @emph{Description}:
13050 Returns the cosubscript for this image.
13052 @item @emph{Standard}:
13053 Fortran 2008 and later. With @var{DISTANCE} argument, 
13054 Technical Specification (TS) 18508 or later
13056 @item @emph{Class}:
13057 Transformational function
13059 @item @emph{Syntax}:
13060 @multitable @columnfractions .80
13061 @item @code{RESULT = THIS_IMAGE()}
13062 @item @code{RESULT = THIS_IMAGE(DISTANCE)}
13063 @item @code{RESULT = THIS_IMAGE(COARRAY [, DIM])}
13064 @end multitable
13066 @item @emph{Arguments}:
13067 @multitable @columnfractions .15 .70
13068 @item @var{DISTANCE} @tab (optional, intent(in)) Nonnegative scalar integer
13069 (not permitted together with @var{COARRAY}).
13070 @item @var{COARRAY} @tab Coarray of any type  (optional; if @var{DIM}
13071 present, required).
13072 @item @var{DIM}     @tab default integer scalar (optional). If present,
13073 @var{DIM} shall be between one and the corank of @var{COARRAY}.
13074 @end multitable
13077 @item @emph{Return value}:
13078 Default integer. If @var{COARRAY} is not present, it is scalar; if
13079 @var{DISTANCE} is not present or has value 0, its value is the image index on
13080 the invoking image for the current team, for values smaller or equal
13081 distance to the initial team, it returns the image index on the ancestor team
13082 which has a distance of @var{DISTANCE} from the invoking team. If
13083 @var{DISTANCE} is larger than the distance to the initial team, the image
13084 index of the initial team is returned. Otherwise when the @var{COARRAY} is
13085 present, if @var{DIM} is not present, a rank-1 array with corank elements is
13086 returned, containing the cosubscripts for @var{COARRAY} specifying the invoking
13087 image. If @var{DIM} is present, a scalar is returned, with the value of
13088 the @var{DIM} element of @code{THIS_IMAGE(COARRAY)}.
13090 @item @emph{Example}:
13091 @smallexample
13092 INTEGER :: value[*]
13093 INTEGER :: i
13094 value = THIS_IMAGE()
13095 SYNC ALL
13096 IF (THIS_IMAGE() == 1) THEN
13097   DO i = 1, NUM_IMAGES()
13098     WRITE(*,'(2(a,i0))') 'value[', i, '] is ', value[i]
13099   END DO
13100 END IF
13102 ! Check whether the current image is the initial image
13103 IF (THIS_IMAGE(HUGE(1)) /= THIS_IMAGE())
13104   error stop "something is rotten here"
13105 @end smallexample
13107 @item @emph{See also}:
13108 @ref{NUM_IMAGES}, @ref{IMAGE_INDEX}
13109 @end table
13113 @node TIME
13114 @section @code{TIME} --- Time function
13115 @fnindex TIME
13116 @cindex time, current
13117 @cindex current time
13119 @table @asis
13120 @item @emph{Description}:
13121 Returns the current time encoded as an integer (in the manner of the
13122 function @code{time(3)} in the C standard library). This value is
13123 suitable for passing to @code{CTIME}, @code{GMTIME}, and @code{LTIME}.
13125 This intrinsic is not fully portable, such as to systems with 32-bit
13126 @code{INTEGER} types but supporting times wider than 32 bits. Therefore,
13127 the values returned by this intrinsic might be, or become, negative, or
13128 numerically less than previous values, during a single run of the
13129 compiled program.
13131 See @ref{TIME8}, for information on a similar intrinsic that might be
13132 portable to more GNU Fortran implementations, though to fewer Fortran
13133 compilers.
13135 @item @emph{Standard}:
13136 GNU extension
13138 @item @emph{Class}:
13139 Function
13141 @item @emph{Syntax}:
13142 @code{RESULT = TIME()}
13144 @item @emph{Return value}:
13145 The return value is a scalar of type @code{INTEGER(4)}.
13147 @item @emph{See also}:
13148 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME8}
13150 @end table
13154 @node TIME8
13155 @section @code{TIME8} --- Time function (64-bit)
13156 @fnindex TIME8
13157 @cindex time, current
13158 @cindex current time
13160 @table @asis
13161 @item @emph{Description}:
13162 Returns the current time encoded as an integer (in the manner of the
13163 function @code{time(3)} in the C standard library). This value is
13164 suitable for passing to @code{CTIME}, @code{GMTIME}, and @code{LTIME}.
13166 @emph{Warning:} this intrinsic does not increase the range of the timing
13167 values over that returned by @code{time(3)}. On a system with a 32-bit
13168 @code{time(3)}, @code{TIME8} will return a 32-bit value, even though
13169 it is converted to a 64-bit @code{INTEGER(8)} value. That means
13170 overflows of the 32-bit value can still occur. Therefore, the values
13171 returned by this intrinsic might be or become negative or numerically
13172 less than previous values during a single run of the compiled program.
13174 @item @emph{Standard}:
13175 GNU extension
13177 @item @emph{Class}:
13178 Function
13180 @item @emph{Syntax}:
13181 @code{RESULT = TIME8()}
13183 @item @emph{Return value}:
13184 The return value is a scalar of type @code{INTEGER(8)}.
13186 @item @emph{See also}:
13187 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK8}, @ref{TIME}
13189 @end table
13193 @node TINY
13194 @section @code{TINY} --- Smallest positive number of a real kind
13195 @fnindex TINY
13196 @cindex limits, smallest number
13197 @cindex model representation, smallest number
13199 @table @asis
13200 @item @emph{Description}:
13201 @code{TINY(X)} returns the smallest positive (non zero) number
13202 in the model of the type of @code{X}.
13204 @item @emph{Standard}:
13205 Fortran 95 and later
13207 @item @emph{Class}:
13208 Inquiry function
13210 @item @emph{Syntax}:
13211 @code{RESULT = TINY(X)}
13213 @item @emph{Arguments}:
13214 @multitable @columnfractions .15 .70
13215 @item @var{X} @tab Shall be of type @code{REAL}.
13216 @end multitable
13218 @item @emph{Return value}:
13219 The return value is of the same type and kind as @var{X}
13221 @item @emph{Example}:
13222 See @code{HUGE} for an example.
13223 @end table
13227 @node TRAILZ
13228 @section @code{TRAILZ} --- Number of trailing zero bits of an integer
13229 @fnindex TRAILZ
13230 @cindex zero bits
13232 @table @asis
13233 @item @emph{Description}:
13234 @code{TRAILZ} returns the number of trailing zero bits of an integer.
13236 @item @emph{Standard}:
13237 Fortran 2008 and later
13239 @item @emph{Class}:
13240 Elemental function
13242 @item @emph{Syntax}:
13243 @code{RESULT = TRAILZ(I)}
13245 @item @emph{Arguments}:
13246 @multitable @columnfractions .15 .70
13247 @item @var{I} @tab Shall be of type @code{INTEGER}.
13248 @end multitable
13250 @item @emph{Return value}:
13251 The type of the return value is the default @code{INTEGER}.
13252 If all the bits of @code{I} are zero, the result value is @code{BIT_SIZE(I)}.
13254 @item @emph{Example}:
13255 @smallexample
13256 PROGRAM test_trailz
13257   WRITE (*,*) TRAILZ(8)  ! prints 3
13258 END PROGRAM
13259 @end smallexample
13261 @item @emph{See also}:
13262 @ref{BIT_SIZE}, @ref{LEADZ}, @ref{POPPAR}, @ref{POPCNT}
13263 @end table
13267 @node TRANSFER
13268 @section @code{TRANSFER} --- Transfer bit patterns
13269 @fnindex TRANSFER
13270 @cindex bits, move
13271 @cindex type cast
13273 @table @asis
13274 @item @emph{Description}:
13275 Interprets the bitwise representation of @var{SOURCE} in memory as if it
13276 is the representation of a variable or array of the same type and type
13277 parameters as @var{MOLD}.
13279 This is approximately equivalent to the C concept of @emph{casting} one
13280 type to another.
13282 @item @emph{Standard}:
13283 Fortran 95 and later
13285 @item @emph{Class}:
13286 Transformational function
13288 @item @emph{Syntax}:
13289 @code{RESULT = TRANSFER(SOURCE, MOLD[, SIZE])}
13291 @item @emph{Arguments}:
13292 @multitable @columnfractions .15 .70
13293 @item @var{SOURCE} @tab Shall be a scalar or an array of any type.
13294 @item @var{MOLD}   @tab Shall be a scalar or an array of any type.
13295 @item @var{SIZE}   @tab (Optional) shall be a scalar of type 
13296 @code{INTEGER}.
13297 @end multitable
13299 @item @emph{Return value}:
13300 The result has the same type as @var{MOLD}, with the bit level
13301 representation of @var{SOURCE}.  If @var{SIZE} is present, the result is
13302 a one-dimensional array of length @var{SIZE}.  If @var{SIZE} is absent
13303 but @var{MOLD} is an array (of any size or shape), the result is a one-
13304 dimensional array of the minimum length needed to contain the entirety
13305 of the bitwise representation of @var{SOURCE}.   If @var{SIZE} is absent
13306 and @var{MOLD} is a scalar, the result is a scalar.
13308 If the bitwise representation of the result is longer than that of
13309 @var{SOURCE}, then the leading bits of the result correspond to those of
13310 @var{SOURCE} and any trailing bits are filled arbitrarily.
13312 When the resulting bit representation does not correspond to a valid
13313 representation of a variable of the same type as @var{MOLD}, the results
13314 are undefined, and subsequent operations on the result cannot be
13315 guaranteed to produce sensible behavior.  For example, it is possible to
13316 create @code{LOGICAL} variables for which @code{@var{VAR}} and
13317 @code{.NOT.@var{VAR}} both appear to be true.
13319 @item @emph{Example}:
13320 @smallexample
13321 PROGRAM test_transfer
13322   integer :: x = 2143289344
13323   print *, transfer(x, 1.0)    ! prints "NaN" on i686
13324 END PROGRAM
13325 @end smallexample
13326 @end table
13330 @node TRANSPOSE
13331 @section @code{TRANSPOSE} --- Transpose an array of rank two
13332 @fnindex TRANSPOSE
13333 @cindex array, transpose
13334 @cindex matrix, transpose
13335 @cindex transpose
13337 @table @asis
13338 @item @emph{Description}:
13339 Transpose an array of rank two. Element (i, j) of the result has the value 
13340 @code{MATRIX(j, i)}, for all i, j.
13342 @item @emph{Standard}:
13343 Fortran 95 and later
13345 @item @emph{Class}:
13346 Transformational function
13348 @item @emph{Syntax}:
13349 @code{RESULT = TRANSPOSE(MATRIX)}
13351 @item @emph{Arguments}:
13352 @multitable @columnfractions .15 .70
13353 @item @var{MATRIX} @tab Shall be an array of any type and have a rank of two.
13354 @end multitable
13356 @item @emph{Return value}:
13357 The result has the same type as @var{MATRIX}, and has shape 
13358 @code{(/ m, n /)} if @var{MATRIX} has shape @code{(/ n, m /)}.
13359 @end table
13363 @node TRIM
13364 @section @code{TRIM} --- Remove trailing blank characters of a string
13365 @fnindex TRIM
13366 @cindex string, remove trailing whitespace
13368 @table @asis
13369 @item @emph{Description}:
13370 Removes trailing blank characters of a string.
13372 @item @emph{Standard}:
13373 Fortran 95 and later
13375 @item @emph{Class}:
13376 Transformational function
13378 @item @emph{Syntax}:
13379 @code{RESULT = TRIM(STRING)}
13381 @item @emph{Arguments}:
13382 @multitable @columnfractions .15 .70
13383 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER}.
13384 @end multitable
13386 @item @emph{Return value}:
13387 A scalar of type @code{CHARACTER} which length is that of @var{STRING}
13388 less the number of trailing blanks.
13390 @item @emph{Example}:
13391 @smallexample
13392 PROGRAM test_trim
13393   CHARACTER(len=10), PARAMETER :: s = "GFORTRAN  "
13394   WRITE(*,*) LEN(s), LEN(TRIM(s))  ! "10 8", with/without trailing blanks
13395 END PROGRAM
13396 @end smallexample
13398 @item @emph{See also}:
13399 @ref{ADJUSTL}, @ref{ADJUSTR}
13400 @end table
13404 @node TTYNAM
13405 @section @code{TTYNAM} --- Get the name of a terminal device.
13406 @fnindex TTYNAM
13407 @cindex system, terminal
13409 @table @asis
13410 @item @emph{Description}:
13411 Get the name of a terminal device. For more information, 
13412 see @code{ttyname(3)}.
13414 This intrinsic is provided in both subroutine and function forms; 
13415 however, only one form can be used in any given program unit. 
13417 @item @emph{Standard}:
13418 GNU extension
13420 @item @emph{Class}:
13421 Subroutine, function
13423 @item @emph{Syntax}:
13424 @multitable @columnfractions .80
13425 @item @code{CALL TTYNAM(UNIT, NAME)}
13426 @item @code{NAME = TTYNAM(UNIT)}
13427 @end multitable
13429 @item @emph{Arguments}:
13430 @multitable @columnfractions .15 .70
13431 @item @var{UNIT} @tab Shall be a scalar @code{INTEGER}.
13432 @item @var{NAME} @tab Shall be of type @code{CHARACTER}.
13433 @end multitable
13435 @item @emph{Example}:
13436 @smallexample
13437 PROGRAM test_ttynam
13438   INTEGER :: unit
13439   DO unit = 1, 10
13440     IF (isatty(unit=unit)) write(*,*) ttynam(unit)
13441   END DO
13442 END PROGRAM
13443 @end smallexample
13445 @item @emph{See also}:
13446 @ref{ISATTY}
13447 @end table
13451 @node UBOUND
13452 @section @code{UBOUND} --- Upper dimension bounds of an array
13453 @fnindex UBOUND
13454 @cindex array, upper bound
13456 @table @asis
13457 @item @emph{Description}:
13458 Returns the upper bounds of an array, or a single upper bound
13459 along the @var{DIM} dimension.
13460 @item @emph{Standard}:
13461 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
13463 @item @emph{Class}:
13464 Inquiry function
13466 @item @emph{Syntax}:
13467 @code{RESULT = UBOUND(ARRAY [, DIM [, KIND]])}
13469 @item @emph{Arguments}:
13470 @multitable @columnfractions .15 .70
13471 @item @var{ARRAY} @tab Shall be an array, of any type.
13472 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
13473 @item @var{KIND}@tab (Optional) An @code{INTEGER} initialization
13474 expression indicating the kind parameter of the result.
13475 @end multitable
13477 @item @emph{Return value}:
13478 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
13479 @var{KIND} is absent, the return value is of default integer kind.
13480 If @var{DIM} is absent, the result is an array of the upper bounds of
13481 @var{ARRAY}.  If @var{DIM} is present, the result is a scalar
13482 corresponding to the upper bound of the array along that dimension.  If
13483 @var{ARRAY} is an expression rather than a whole array or array
13484 structure component, or if it has a zero extent along the relevant
13485 dimension, the upper bound is taken to be the number of elements along
13486 the relevant dimension.
13488 @item @emph{See also}:
13489 @ref{LBOUND}, @ref{LCOBOUND}
13490 @end table
13494 @node UCOBOUND
13495 @section @code{UCOBOUND} --- Upper codimension bounds of an array
13496 @fnindex UCOBOUND
13497 @cindex coarray, upper bound
13499 @table @asis
13500 @item @emph{Description}:
13501 Returns the upper cobounds of a coarray, or a single upper cobound
13502 along the @var{DIM} codimension.
13503 @item @emph{Standard}:
13504 Fortran 2008 and later
13506 @item @emph{Class}:
13507 Inquiry function
13509 @item @emph{Syntax}:
13510 @code{RESULT = UCOBOUND(COARRAY [, DIM [, KIND]])}
13512 @item @emph{Arguments}:
13513 @multitable @columnfractions .15 .70
13514 @item @var{ARRAY} @tab Shall be an coarray, of any type.
13515 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
13516 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
13517 expression indicating the kind parameter of the result.
13518 @end multitable
13520 @item @emph{Return value}:
13521 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
13522 @var{KIND} is absent, the return value is of default integer kind.
13523 If @var{DIM} is absent, the result is an array of the lower cobounds of
13524 @var{COARRAY}.  If @var{DIM} is present, the result is a scalar
13525 corresponding to the lower cobound of the array along that codimension.
13527 @item @emph{See also}:
13528 @ref{LCOBOUND}, @ref{LBOUND}
13529 @end table
13533 @node UMASK
13534 @section @code{UMASK} --- Set the file creation mask
13535 @fnindex UMASK
13536 @cindex file system, file creation mask
13538 @table @asis
13539 @item @emph{Description}:
13540 Sets the file creation mask to @var{MASK}. If called as a function, it
13541 returns the old value. If called as a subroutine and argument @var{OLD}
13542 if it is supplied, it is set to the old value. See @code{umask(2)}.
13544 @item @emph{Standard}:
13545 GNU extension
13547 @item @emph{Class}:
13548 Subroutine, function
13550 @item @emph{Syntax}:
13551 @multitable @columnfractions .80
13552 @item @code{CALL UMASK(MASK [, OLD])}
13553 @item @code{OLD = UMASK(MASK)}
13554 @end multitable
13556 @item @emph{Arguments}:
13557 @multitable @columnfractions .15 .70
13558 @item @var{MASK} @tab Shall be a scalar of type @code{INTEGER}.
13559 @item @var{OLD} @tab (Optional) Shall be a scalar of type
13560 @code{INTEGER}.
13561 @end multitable
13563 @end table
13567 @node UNLINK
13568 @section @code{UNLINK} --- Remove a file from the file system
13569 @fnindex UNLINK
13570 @cindex file system, remove file
13572 @table @asis
13573 @item @emph{Description}:
13574 Unlinks the file @var{PATH}. A null character (@code{CHAR(0)}) can be
13575 used to mark the end of the name in @var{PATH}; otherwise, trailing
13576 blanks in the file name are ignored.  If the @var{STATUS} argument is
13577 supplied, it contains 0 on success or a nonzero error code upon return;
13578 see @code{unlink(2)}.
13580 This intrinsic is provided in both subroutine and function forms;
13581 however, only one form can be used in any given program unit.
13583 @item @emph{Standard}:
13584 GNU extension
13586 @item @emph{Class}:
13587 Subroutine, function
13589 @item @emph{Syntax}:
13590 @multitable @columnfractions .80
13591 @item @code{CALL UNLINK(PATH [, STATUS])}
13592 @item @code{STATUS = UNLINK(PATH)}
13593 @end multitable
13595 @item @emph{Arguments}:
13596 @multitable @columnfractions .15 .70
13597 @item @var{PATH} @tab Shall be of default @code{CHARACTER} type.
13598 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
13599 @end multitable
13601 @item @emph{See also}:
13602 @ref{LINK}, @ref{SYMLNK}
13603 @end table
13607 @node UNPACK
13608 @section @code{UNPACK} --- Unpack an array of rank one into an array
13609 @fnindex UNPACK
13610 @cindex array, unpacking
13611 @cindex array, increase dimension
13612 @cindex array, scatter elements
13614 @table @asis
13615 @item @emph{Description}:
13616 Store the elements of @var{VECTOR} in an array of higher rank.
13618 @item @emph{Standard}:
13619 Fortran 95 and later
13621 @item @emph{Class}:
13622 Transformational function
13624 @item @emph{Syntax}:
13625 @code{RESULT = UNPACK(VECTOR, MASK, FIELD)}
13627 @item @emph{Arguments}:
13628 @multitable @columnfractions .15 .70
13629 @item @var{VECTOR} @tab Shall be an array of any type and rank one. It 
13630 shall have at least as many elements as @var{MASK} has @code{TRUE} values.
13631 @item @var{MASK}   @tab Shall be an array of type @code{LOGICAL}.
13632 @item @var{FIELD}  @tab Shall be of the same type as @var{VECTOR} and have
13633 the same shape as @var{MASK}.
13634 @end multitable
13636 @item @emph{Return value}:
13637 The resulting array corresponds to @var{FIELD} with @code{TRUE} elements
13638 of @var{MASK} replaced by values from @var{VECTOR} in array element order.
13640 @item @emph{Example}:
13641 @smallexample
13642 PROGRAM test_unpack
13643   integer :: vector(2)  = (/1,1/)
13644   logical :: mask(4)  = (/ .TRUE., .FALSE., .FALSE., .TRUE. /)
13645   integer :: field(2,2) = 0, unity(2,2)
13647   ! result: unity matrix
13648   unity = unpack(vector, reshape(mask, (/2,2/)), field)
13649 END PROGRAM
13650 @end smallexample
13652 @item @emph{See also}:
13653 @ref{PACK}, @ref{SPREAD}
13654 @end table
13658 @node VERIFY
13659 @section @code{VERIFY} --- Scan a string for characters not a given set
13660 @fnindex VERIFY
13661 @cindex string, find missing set
13663 @table @asis
13664 @item @emph{Description}:
13665 Verifies that all the characters in @var{STRING} belong to the set of
13666 characters in @var{SET}.
13668 If @var{BACK} is either absent or equals @code{FALSE}, this function
13669 returns the position of the leftmost character of @var{STRING} that is
13670 not in @var{SET}. If @var{BACK} equals @code{TRUE}, the rightmost
13671 position is returned. If all characters of @var{STRING} are found in
13672 @var{SET}, the result is zero.
13674 @item @emph{Standard}:
13675 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
13677 @item @emph{Class}:
13678 Elemental function
13680 @item @emph{Syntax}:
13681 @code{RESULT = VERIFY(STRING, SET[, BACK [, KIND]])}
13683 @item @emph{Arguments}:
13684 @multitable @columnfractions .15 .70
13685 @item @var{STRING} @tab Shall be of type @code{CHARACTER}.
13686 @item @var{SET}    @tab Shall be of type @code{CHARACTER}.
13687 @item @var{BACK}   @tab (Optional) shall be of type @code{LOGICAL}.
13688 @item @var{KIND}   @tab (Optional) An @code{INTEGER} initialization
13689 expression indicating the kind parameter of the result.
13690 @end multitable
13692 @item @emph{Return value}:
13693 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
13694 @var{KIND} is absent, the return value is of default integer kind.
13696 @item @emph{Example}:
13697 @smallexample
13698 PROGRAM test_verify
13699   WRITE(*,*) VERIFY("FORTRAN", "AO")           ! 1, found 'F'
13700   WRITE(*,*) VERIFY("FORTRAN", "FOO")          ! 3, found 'R'
13701   WRITE(*,*) VERIFY("FORTRAN", "C++")          ! 1, found 'F'
13702   WRITE(*,*) VERIFY("FORTRAN", "C++", .TRUE.)  ! 7, found 'N'
13703   WRITE(*,*) VERIFY("FORTRAN", "FORTRAN")      ! 0' found none
13704 END PROGRAM
13705 @end smallexample
13707 @item @emph{See also}:
13708 @ref{SCAN}, @ref{INDEX intrinsic}
13709 @end table
13713 @node XOR
13714 @section @code{XOR} --- Bitwise logical exclusive OR
13715 @fnindex XOR
13716 @cindex bitwise logical exclusive or
13717 @cindex logical exclusive or, bitwise
13719 @table @asis
13720 @item @emph{Description}:
13721 Bitwise logical exclusive or. 
13723 This intrinsic routine is provided for backwards compatibility with 
13724 GNU Fortran 77.  For integer arguments, programmers should consider
13725 the use of the @ref{IEOR} intrinsic and for logical arguments the
13726 @code{.NEQV.} operator, which are both defined by the Fortran standard.
13728 @item @emph{Standard}:
13729 GNU extension
13731 @item @emph{Class}:
13732 Function
13734 @item @emph{Syntax}:
13735 @code{RESULT = XOR(I, J)}
13737 @item @emph{Arguments}:
13738 @multitable @columnfractions .15 .70
13739 @item @var{I} @tab The type shall be either  a scalar @code{INTEGER}
13740 type or a scalar @code{LOGICAL} type.
13741 @item @var{J} @tab The type shall be the same as the type of @var{I}.
13742 @end multitable
13744 @item @emph{Return value}:
13745 The return type is either a scalar @code{INTEGER} or a scalar
13746 @code{LOGICAL}.  If the kind type parameters differ, then the
13747 smaller kind type is implicitly converted to larger kind, and the 
13748 return has the larger kind.
13750 @item @emph{Example}:
13751 @smallexample
13752 PROGRAM test_xor
13753   LOGICAL :: T = .TRUE., F = .FALSE.
13754   INTEGER :: a, b
13755   DATA a / Z'F' /, b / Z'3' /
13757   WRITE (*,*) XOR(T, T), XOR(T, F), XOR(F, T), XOR(F, F)
13758   WRITE (*,*) XOR(a, b)
13759 END PROGRAM
13760 @end smallexample
13762 @item @emph{See also}:
13763 Fortran 95 elemental function: @ref{IEOR}
13764 @end table
13768 @node Intrinsic Modules
13769 @chapter Intrinsic Modules
13770 @cindex intrinsic Modules
13772 @menu
13773 * ISO_FORTRAN_ENV::
13774 * ISO_C_BINDING::
13775 * IEEE modules::
13776 * OpenMP Modules OMP_LIB and OMP_LIB_KINDS::
13777 * OpenACC Module OPENACC::
13778 @end menu
13780 @node ISO_FORTRAN_ENV
13781 @section @code{ISO_FORTRAN_ENV}
13782 @table @asis
13783 @item @emph{Standard}:
13784 Fortran 2003 and later, except when otherwise noted
13785 @end table
13787 The @code{ISO_FORTRAN_ENV} module provides the following scalar default-integer
13788 named constants:
13790 @table @asis
13791 @item @code{ATOMIC_INT_KIND}:
13792 Default-kind integer constant to be used as kind parameter when defining
13793 integer variables used in atomic operations. (Fortran 2008 or later.)
13795 @item @code{ATOMIC_LOGICAL_KIND}:
13796 Default-kind integer constant to be used as kind parameter when defining
13797 logical variables used in atomic operations. (Fortran 2008 or later.)
13799 @item @code{CHARACTER_KINDS}:
13800 Default-kind integer constant array of rank one containing the supported kind
13801 parameters of the @code{CHARACTER} type. (Fortran 2008 or later.)
13803 @item @code{CHARACTER_STORAGE_SIZE}:
13804 Size in bits of the character storage unit.
13806 @item @code{ERROR_UNIT}:
13807 Identifies the preconnected unit used for error reporting.
13809 @item @code{FILE_STORAGE_SIZE}:
13810 Size in bits of the file-storage unit.
13812 @item @code{INPUT_UNIT}:
13813 Identifies the preconnected unit identified by the asterisk
13814 (@code{*}) in @code{READ} statement.
13816 @item @code{INT8}, @code{INT16}, @code{INT32}, @code{INT64}:
13817 Kind type parameters to specify an INTEGER type with a storage
13818 size of 16, 32, and 64 bits. It is negative if a target platform
13819 does not support the particular kind. (Fortran 2008 or later.)
13821 @item @code{INTEGER_KINDS}:
13822 Default-kind integer constant array of rank one containing the supported kind
13823 parameters of the @code{INTEGER} type. (Fortran 2008 or later.)
13825 @item @code{IOSTAT_END}:
13826 The value assigned to the variable passed to the @code{IOSTAT=} specifier of
13827 an input/output statement if an end-of-file condition occurred.
13829 @item @code{IOSTAT_EOR}:
13830 The value assigned to the variable passed to the @code{IOSTAT=} specifier of
13831 an input/output statement if an end-of-record condition occurred.
13833 @item @code{IOSTAT_INQUIRE_INTERNAL_UNIT}:
13834 Scalar default-integer constant, used by @code{INQUIRE} for the
13835 @code{IOSTAT=} specifier to denote an that a unit number identifies an
13836 internal unit. (Fortran 2008 or later.)
13838 @item @code{NUMERIC_STORAGE_SIZE}:
13839 The size in bits of the numeric storage unit.
13841 @item @code{LOGICAL_KINDS}:
13842 Default-kind integer constant array of rank one containing the supported kind
13843 parameters of the @code{LOGICAL} type. (Fortran 2008 or later.)
13845 @item @code{OUTPUT_UNIT}:
13846 Identifies the preconnected unit identified by the asterisk
13847 (@code{*}) in @code{WRITE} statement.
13849 @item @code{REAL32}, @code{REAL64}, @code{REAL128}:
13850 Kind type parameters to specify a REAL type with a storage
13851 size of 32, 64, and 128 bits. It is negative if a target platform
13852 does not support the particular kind. (Fortran 2008 or later.)
13854 @item @code{REAL_KINDS}:
13855 Default-kind integer constant array of rank one containing the supported kind
13856 parameters of the @code{REAL} type. (Fortran 2008 or later.)
13858 @item @code{STAT_LOCKED}:
13859 Scalar default-integer constant used as STAT= return value by @code{LOCK} to
13860 denote that the lock variable is locked by the executing image. (Fortran 2008
13861 or later.)
13863 @item @code{STAT_LOCKED_OTHER_IMAGE}:
13864 Scalar default-integer constant used as STAT= return value by @code{UNLOCK} to
13865 denote that the lock variable is locked by another image. (Fortran 2008 or
13866 later.)
13868 @item @code{STAT_STOPPED_IMAGE}:
13869 Positive, scalar default-integer constant used as STAT= return value if the
13870 argument in the statement requires synchronisation with an image, which has
13871 initiated the termination of the execution. (Fortran 2008 or later.)
13873 @item @code{STAT_FAILED_IMAGE}:
13874 Positive, scalar default-integer constant used as STAT= return value if the
13875 argument in the statement requires communication with an image, which has
13876 is in the failed state. (TS 18508 or later.)
13878 @item @code{STAT_UNLOCKED}:
13879 Scalar default-integer constant used as STAT= return value by @code{UNLOCK} to
13880 denote that the lock variable is unlocked. (Fortran 2008 or later.)
13881 @end table
13883 The module provides the following derived type:
13885 @table @asis
13886 @item @code{LOCK_TYPE}:
13887 Derived type with private components to be use with the @code{LOCK} and
13888 @code{UNLOCK} statement. A variable of its type has to be always declared
13889 as coarray and may not appear in a variable-definition context.
13890 (Fortran 2008 or later.)
13891 @end table
13893 The module also provides the following intrinsic procedures:
13894 @ref{COMPILER_OPTIONS} and @ref{COMPILER_VERSION}.
13898 @node ISO_C_BINDING
13899 @section @code{ISO_C_BINDING}
13900 @table @asis
13901 @item @emph{Standard}:
13902 Fortran 2003 and later, GNU extensions
13903 @end table
13905 The following intrinsic procedures are provided by the module; their
13906 definition can be found in the section Intrinsic Procedures of this
13907 manual.
13909 @table @asis
13910 @item @code{C_ASSOCIATED}
13911 @item @code{C_F_POINTER}
13912 @item @code{C_F_PROCPOINTER}
13913 @item @code{C_FUNLOC}
13914 @item @code{C_LOC}
13915 @item @code{C_SIZEOF}
13916 @end table
13917 @c TODO: Vertical spacing between C_FUNLOC and C_LOC wrong in PDF,
13918 @c don't really know why.
13920 The @code{ISO_C_BINDING} module provides the following named constants of
13921 type default integer, which can be used as KIND type parameters.
13923 In addition to the integer named constants required by the Fortran 2003 
13924 standard and @code{C_PTRDIFF_T} of TS 29113, GNU Fortran provides as an
13925 extension named constants for the 128-bit integer types supported by the
13926 C compiler: @code{C_INT128_T, C_INT_LEAST128_T, C_INT_FAST128_T}.
13927 Furthermore, if @code{__float128} is supported in C, the named constants
13928 @code{C_FLOAT128, C_FLOAT128_COMPLEX} are defined.
13930 @multitable @columnfractions .15 .35 .35 .35
13931 @item Fortran Type  @tab Named constant         @tab C type                                @tab Extension
13932 @item @code{INTEGER}@tab @code{C_INT}           @tab @code{int}
13933 @item @code{INTEGER}@tab @code{C_SHORT}         @tab @code{short int}
13934 @item @code{INTEGER}@tab @code{C_LONG}          @tab @code{long int}
13935 @item @code{INTEGER}@tab @code{C_LONG_LONG}     @tab @code{long long int}
13936 @item @code{INTEGER}@tab @code{C_SIGNED_CHAR}   @tab @code{signed char}/@code{unsigned char}
13937 @item @code{INTEGER}@tab @code{C_SIZE_T}        @tab @code{size_t}
13938 @item @code{INTEGER}@tab @code{C_INT8_T}        @tab @code{int8_t}
13939 @item @code{INTEGER}@tab @code{C_INT16_T}       @tab @code{int16_t}
13940 @item @code{INTEGER}@tab @code{C_INT32_T}       @tab @code{int32_t}
13941 @item @code{INTEGER}@tab @code{C_INT64_T}       @tab @code{int64_t}
13942 @item @code{INTEGER}@tab @code{C_INT128_T}      @tab @code{int128_t}                      @tab Ext.
13943 @item @code{INTEGER}@tab @code{C_INT_LEAST8_T}  @tab @code{int_least8_t}
13944 @item @code{INTEGER}@tab @code{C_INT_LEAST16_T} @tab @code{int_least16_t}
13945 @item @code{INTEGER}@tab @code{C_INT_LEAST32_T} @tab @code{int_least32_t}
13946 @item @code{INTEGER}@tab @code{C_INT_LEAST64_T} @tab @code{int_least64_t}
13947 @item @code{INTEGER}@tab @code{C_INT_LEAST128_T}@tab @code{int_least128_t}                @tab Ext.
13948 @item @code{INTEGER}@tab @code{C_INT_FAST8_T}   @tab @code{int_fast8_t}
13949 @item @code{INTEGER}@tab @code{C_INT_FAST16_T}  @tab @code{int_fast16_t}
13950 @item @code{INTEGER}@tab @code{C_INT_FAST32_T}  @tab @code{int_fast32_t}
13951 @item @code{INTEGER}@tab @code{C_INT_FAST64_T}  @tab @code{int_fast64_t}
13952 @item @code{INTEGER}@tab @code{C_INT_FAST128_T} @tab @code{int_fast128_t}                 @tab Ext.
13953 @item @code{INTEGER}@tab @code{C_INTMAX_T}      @tab @code{intmax_t}
13954 @item @code{INTEGER}@tab @code{C_INTPTR_T}      @tab @code{intptr_t}
13955 @item @code{INTEGER}@tab @code{C_PTRDIFF_T}     @tab @code{intptr_t}                      @tab TS 29113
13956 @item @code{REAL}   @tab @code{C_FLOAT}         @tab @code{float}
13957 @item @code{REAL}   @tab @code{C_DOUBLE}        @tab @code{double}
13958 @item @code{REAL}   @tab @code{C_LONG_DOUBLE}   @tab @code{long double}
13959 @item @code{REAL}   @tab @code{C_FLOAT128}      @tab @code{__float128}                    @tab Ext.
13960 @item @code{COMPLEX}@tab @code{C_FLOAT_COMPLEX} @tab @code{float _Complex}
13961 @item @code{COMPLEX}@tab @code{C_DOUBLE_COMPLEX}@tab @code{double _Complex}
13962 @item @code{COMPLEX}@tab @code{C_LONG_DOUBLE_COMPLEX}@tab @code{long double _Complex}
13963 @item @code{REAL}   @tab @code{C_FLOAT128_COMPLEX}   @tab @code{__float128 _Complex}      @tab Ext.
13964 @item @code{LOGICAL}@tab @code{C_BOOL}          @tab @code{_Bool}
13965 @item @code{CHARACTER}@tab @code{C_CHAR}        @tab @code{char}
13966 @end multitable
13968 Additionally, the following parameters of type @code{CHARACTER(KIND=C_CHAR)}
13969 are defined.
13971 @multitable @columnfractions .20 .45 .15
13972 @item Name                     @tab C definition    @tab Value
13973 @item @code{C_NULL_CHAR}       @tab null character  @tab @code{'\0'}
13974 @item @code{C_ALERT}           @tab alert           @tab @code{'\a'}
13975 @item @code{C_BACKSPACE}       @tab backspace       @tab @code{'\b'}
13976 @item @code{C_FORM_FEED}       @tab form feed       @tab @code{'\f'}
13977 @item @code{C_NEW_LINE}        @tab new line        @tab @code{'\n'}
13978 @item @code{C_CARRIAGE_RETURN} @tab carriage return @tab @code{'\r'}
13979 @item @code{C_HORIZONTAL_TAB}  @tab horizontal tab  @tab @code{'\t'}
13980 @item @code{C_VERTICAL_TAB}    @tab vertical tab    @tab @code{'\v'}
13981 @end multitable
13983 Moreover, the following two named constants are defined:
13985 @multitable @columnfractions .20 .80
13986 @item Name                 @tab Type
13987 @item @code{C_NULL_PTR}    @tab @code{C_PTR}
13988 @item @code{C_NULL_FUNPTR} @tab @code{C_FUNPTR}
13989 @end multitable
13991 Both are equivalent to the value @code{NULL} in C.
13995 @node IEEE modules
13996 @section IEEE modules: @code{IEEE_EXCEPTIONS}, @code{IEEE_ARITHMETIC}, and @code{IEEE_FEATURES}
13997 @table @asis
13998 @item @emph{Standard}:
13999 Fortran 2003 and later
14000 @end table
14002 The @code{IEEE_EXCEPTIONS}, @code{IEEE_ARITHMETIC}, and @code{IEEE_FEATURES}
14003 intrinsic modules provide support for exceptions and IEEE arithmetic, as
14004 defined in Fortran 2003 and later standards, and the IEC 60559:1989 standard
14005 (@emph{Binary floating-point arithmetic for microprocessor systems}). These
14006 modules are only provided on the following supported platforms:
14008 @itemize @bullet
14009 @item i386 and x86_64 processors
14010 @item platforms which use the GNU C Library (glibc)
14011 @item platforms with support for SysV/386 routines for floating point
14012 interface (including Solaris and BSDs)
14013 @item platforms with the AIX OS
14014 @end itemize
14016 For full compliance with the Fortran standards, code using the
14017 @code{IEEE_EXCEPTIONS} or @code{IEEE_ARITHMETIC} modules should be compiled
14018 with the following options: @code{-fno-unsafe-math-optimizations
14019 -frounding-math -fsignaling-nans}.
14023 @node OpenMP Modules OMP_LIB and OMP_LIB_KINDS
14024 @section OpenMP Modules @code{OMP_LIB} and @code{OMP_LIB_KINDS}
14025 @table @asis
14026 @item @emph{Standard}:
14027 OpenMP Application Program Interface v4.0
14028 @end table
14031 The OpenMP Fortran runtime library routines are provided both in
14032 a form of two Fortran 90 modules, named @code{OMP_LIB} and 
14033 @code{OMP_LIB_KINDS}, and in a form of a Fortran @code{include} file named
14034 @file{omp_lib.h}. The procedures provided by @code{OMP_LIB} can be found
14035 in the @ref{Top,,Introduction,libgomp,GNU Offloading and Multi
14036 Processing Runtime Library} manual,
14037 the named constants defined in the modules are listed
14038 below.
14040 For details refer to the actual
14041 @uref{http://www.openmp.org/mp-documents/OpenMP4.0.0.pdf,
14042 OpenMP Application Program Interface v4.0}.
14044 @code{OMP_LIB_KINDS} provides the following scalar default-integer
14045 named constants:
14047 @table @asis
14048 @item @code{omp_lock_kind}
14049 @item @code{omp_nest_lock_kind}
14050 @item @code{omp_proc_bind_kind}
14051 @item @code{omp_sched_kind}
14052 @end table
14054 @code{OMP_LIB} provides the scalar default-integer
14055 named constant @code{openmp_version} with a value of the form
14056 @var{yyyymm}, where @code{yyyy} is the year and @var{mm} the month
14057 of the OpenMP version; for OpenMP v4.0 the value is @code{201307}.
14059 The following scalar integer named constants of the
14060 kind @code{omp_sched_kind}:
14062 @table @asis
14063 @item @code{omp_sched_static}
14064 @item @code{omp_sched_dynamic}
14065 @item @code{omp_sched_guided}
14066 @item @code{omp_sched_auto}
14067 @end table
14069 And the following scalar integer named constants of the 
14070 kind @code{omp_proc_bind_kind}:
14072 @table @asis
14073 @item @code{omp_proc_bind_false}
14074 @item @code{omp_proc_bind_true}
14075 @item @code{omp_proc_bind_master}
14076 @item @code{omp_proc_bind_close}
14077 @item @code{omp_proc_bind_spread}
14078 @end table
14082 @node OpenACC Module OPENACC
14083 @section OpenACC Module @code{OPENACC}
14084 @table @asis
14085 @item @emph{Standard}:
14086 OpenACC Application Programming Interface v2.0
14087 @end table
14090 The OpenACC Fortran runtime library routines are provided both in a
14091 form of a Fortran 90 module, named @code{OPENACC}, and in form of a
14092 Fortran @code{include} file named @file{openacc_lib.h}.  The
14093 procedures provided by @code{OPENACC} can be found in the
14094 @ref{Top,,Introduction,libgomp,GNU Offloading and Multi Processing
14095 Runtime Library} manual, the named constants defined in the modules
14096 are listed below.
14098 For details refer to the actual
14099 @uref{http://www.openacc.org/,
14100 OpenACC Application Programming Interface v2.0}.
14102 @code{OPENACC} provides the scalar default-integer
14103 named constant @code{openacc_version} with a value of the form
14104 @var{yyyymm}, where @code{yyyy} is the year and @var{mm} the month
14105 of the OpenACC version; for OpenACC v2.0 the value is @code{201306}.