]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/fortran/intrinsic.texi
re PR fortran/45424 ([F08] Add IS_CONTIGUOUS intrinsic)
[thirdparty/gcc.git] / gcc / fortran / intrinsic.texi
1 @ignore
2 Copyright (C) 2005-2019 Free Software Foundation, Inc.
3 This is part of the GNU Fortran manual.
4 For copying conditions, see the file gfortran.texi.
5
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.
12
13
14 Some basic guidelines for editing this document:
15
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.
21
22
23 @end ignore
24
25 @tex
26 \gdef\acosd{\mathop{\rm acosd}\nolimits}
27 \gdef\asind{\mathop{\rm asind}\nolimits}
28 \gdef\atand{\mathop{\rm atand}\nolimits}
29 \gdef\acos{\mathop{\rm acos}\nolimits}
30 \gdef\asin{\mathop{\rm asin}\nolimits}
31 \gdef\atan{\mathop{\rm atan}\nolimits}
32 \gdef\acosh{\mathop{\rm acosh}\nolimits}
33 \gdef\asinh{\mathop{\rm asinh}\nolimits}
34 \gdef\atanh{\mathop{\rm atanh}\nolimits}
35 \gdef\cosd{\mathop{\rm cosd}\nolimits}
36 @end tex
37
38
39 @node Intrinsic Procedures
40 @chapter Intrinsic Procedures
41 @cindex intrinsic procedures
42
43 @menu
44 * Introduction: Introduction to Intrinsics
45 * @code{ABORT}: ABORT, Abort the program
46 * @code{ABS}: ABS, Absolute value
47 * @code{ACCESS}: ACCESS, Checks file access modes
48 * @code{ACHAR}: ACHAR, Character in @acronym{ASCII} collating sequence
49 * @code{ACOS}: ACOS, Arccosine function
50 * @code{ACOSD}: ACOSD, Arccosine function, degrees
51 * @code{ACOSH}: ACOSH, Inverse hyperbolic cosine function
52 * @code{ADJUSTL}: ADJUSTL, Left adjust a string
53 * @code{ADJUSTR}: ADJUSTR, Right adjust a string
54 * @code{AIMAG}: AIMAG, Imaginary part of complex number
55 * @code{AINT}: AINT, Truncate to a whole number
56 * @code{ALARM}: ALARM, Set an alarm clock
57 * @code{ALL}: ALL, Determine if all values are true
58 * @code{ALLOCATED}: ALLOCATED, Status of allocatable entity
59 * @code{AND}: AND, Bitwise logical AND
60 * @code{ANINT}: ANINT, Nearest whole number
61 * @code{ANY}: ANY, Determine if any values are true
62 * @code{ASIN}: ASIN, Arcsine function
63 * @code{ASIND}: ASIND, Arcsine function, degrees
64 * @code{ASINH}: ASINH, Inverse hyperbolic sine function
65 * @code{ASSOCIATED}: ASSOCIATED, Status of a pointer or pointer/target pair
66 * @code{ATAN}: ATAN, Arctangent function
67 * @code{ATAND}: ATAND, Arctangent function, degrees
68 * @code{ATAN2}: ATAN2, Arctangent function
69 * @code{ATAN2D}: ATAN2D, Arctangent function, degrees
70 * @code{ATANH}: ATANH, Inverse hyperbolic tangent function
71 * @code{ATOMIC_ADD}: ATOMIC_ADD, Atomic ADD operation
72 * @code{ATOMIC_AND}: ATOMIC_AND, Atomic bitwise AND operation
73 * @code{ATOMIC_CAS}: ATOMIC_CAS, Atomic compare and swap
74 * @code{ATOMIC_DEFINE}: ATOMIC_DEFINE, Setting a variable atomically
75 * @code{ATOMIC_FETCH_ADD}: ATOMIC_FETCH_ADD, Atomic ADD operation with prior fetch
76 * @code{ATOMIC_FETCH_AND}: ATOMIC_FETCH_AND, Atomic bitwise AND operation with prior fetch
77 * @code{ATOMIC_FETCH_OR}: ATOMIC_FETCH_OR, Atomic bitwise OR operation with prior fetch
78 * @code{ATOMIC_FETCH_XOR}: ATOMIC_FETCH_XOR, Atomic bitwise XOR operation with prior fetch
79 * @code{ATOMIC_OR}: ATOMIC_OR, Atomic bitwise OR operation
80 * @code{ATOMIC_REF}: ATOMIC_REF, Obtaining the value of a variable atomically
81 * @code{ATOMIC_XOR}: ATOMIC_XOR, Atomic bitwise OR operation
82 * @code{BACKTRACE}: BACKTRACE, Show a backtrace
83 * @code{BESSEL_J0}: BESSEL_J0, Bessel function of the first kind of order 0
84 * @code{BESSEL_J1}: BESSEL_J1, Bessel function of the first kind of order 1
85 * @code{BESSEL_JN}: BESSEL_JN, Bessel function of the first kind
86 * @code{BESSEL_Y0}: BESSEL_Y0, Bessel function of the second kind of order 0
87 * @code{BESSEL_Y1}: BESSEL_Y1, Bessel function of the second kind of order 1
88 * @code{BESSEL_YN}: BESSEL_YN, Bessel function of the second kind
89 * @code{BGE}: BGE, Bitwise greater than or equal to
90 * @code{BGT}: BGT, Bitwise greater than
91 * @code{BIT_SIZE}: BIT_SIZE, Bit size inquiry function
92 * @code{BLE}: BLE, Bitwise less than or equal to
93 * @code{BLT}: BLT, Bitwise less than
94 * @code{BTEST}: BTEST, Bit test function
95 * @code{C_ASSOCIATED}: C_ASSOCIATED, Status of a C pointer
96 * @code{C_F_POINTER}: C_F_POINTER, Convert C into Fortran pointer
97 * @code{C_F_PROCPOINTER}: C_F_PROCPOINTER, Convert C into Fortran procedure pointer
98 * @code{C_FUNLOC}: C_FUNLOC, Obtain the C address of a procedure
99 * @code{C_LOC}: C_LOC, Obtain the C address of an object
100 * @code{C_SIZEOF}: C_SIZEOF, Size in bytes of an expression
101 * @code{CEILING}: CEILING, Integer ceiling function
102 * @code{CHAR}: CHAR, Integer-to-character conversion function
103 * @code{CHDIR}: CHDIR, Change working directory
104 * @code{CHMOD}: CHMOD, Change access permissions of files
105 * @code{CMPLX}: CMPLX, Complex conversion function
106 * @code{CO_BROADCAST}: CO_BROADCAST, Copy a value to all images the current set of images
107 * @code{CO_MAX}: CO_MAX, Maximal value on the current set of images
108 * @code{CO_MIN}: CO_MIN, Minimal value on the current set of images
109 * @code{CO_REDUCE}: CO_REDUCE, Reduction of values on the current set of images
110 * @code{CO_SUM}: CO_SUM, Sum of values on the current set of images
111 * @code{COMMAND_ARGUMENT_COUNT}: COMMAND_ARGUMENT_COUNT, Get number of command line arguments
112 * @code{COMPILER_OPTIONS}: COMPILER_OPTIONS, Options passed to the compiler
113 * @code{COMPILER_VERSION}: COMPILER_VERSION, Compiler version string
114 * @code{COMPLEX}: COMPLEX, Complex conversion function
115 * @code{CONJG}: CONJG, Complex conjugate function
116 * @code{COS}: COS, Cosine function
117 * @code{COSD}: COSD, Cosine function, degrees
118 * @code{COSH}: COSH, Hyperbolic cosine function
119 * @code{COTAN}: COTAN, Cotangent function
120 * @code{COTAND}: COTAND, Cotangent function, degrees
121 * @code{COUNT}: COUNT, Count occurrences of TRUE in an array
122 * @code{CPU_TIME}: CPU_TIME, CPU time subroutine
123 * @code{CSHIFT}: CSHIFT, Circular shift elements of an array
124 * @code{CTIME}: CTIME, Subroutine (or function) to convert a time into a string
125 * @code{DATE_AND_TIME}: DATE_AND_TIME, Date and time subroutine
126 * @code{DBLE}: DBLE, Double precision conversion function
127 * @code{DCMPLX}: DCMPLX, Double complex conversion function
128 * @code{DIGITS}: DIGITS, Significant digits function
129 * @code{DIM}: DIM, Positive difference
130 * @code{DOT_PRODUCT}: DOT_PRODUCT, Dot product function
131 * @code{DPROD}: DPROD, Double product function
132 * @code{DREAL}: DREAL, Double real part function
133 * @code{DSHIFTL}: DSHIFTL, Combined left shift
134 * @code{DSHIFTR}: DSHIFTR, Combined right shift
135 * @code{DTIME}: DTIME, Execution time subroutine (or function)
136 * @code{EOSHIFT}: EOSHIFT, End-off shift elements of an array
137 * @code{EPSILON}: EPSILON, Epsilon function
138 * @code{ERF}: ERF, Error function
139 * @code{ERFC}: ERFC, Complementary error function
140 * @code{ERFC_SCALED}: ERFC_SCALED, Exponentially-scaled complementary error function
141 * @code{ETIME}: ETIME, Execution time subroutine (or function)
142 * @code{EVENT_QUERY}: EVENT_QUERY, Query whether a coarray event has occurred
143 * @code{EXECUTE_COMMAND_LINE}: EXECUTE_COMMAND_LINE, Execute a shell command
144 * @code{EXIT}: EXIT, Exit the program with status.
145 * @code{EXP}: EXP, Exponential function
146 * @code{EXPONENT}: EXPONENT, Exponent function
147 * @code{EXTENDS_TYPE_OF}: EXTENDS_TYPE_OF, Query dynamic type for extension
148 * @code{FDATE}: FDATE, Subroutine (or function) to get the current time as a string
149 * @code{FGET}: FGET, Read a single character in stream mode from stdin
150 * @code{FGETC}: FGETC, Read a single character in stream mode
151 * @code{FINDLOC}: FINDLOC, Search an array for a value
152 * @code{FLOOR}: FLOOR, Integer floor function
153 * @code{FLUSH}: FLUSH, Flush I/O unit(s)
154 * @code{FNUM}: FNUM, File number function
155 * @code{FPUT}: FPUT, Write a single character in stream mode to stdout
156 * @code{FPUTC}: FPUTC, Write a single character in stream mode
157 * @code{FRACTION}: FRACTION, Fractional part of the model representation
158 * @code{FREE}: FREE, Memory de-allocation subroutine
159 * @code{FSEEK}: FSEEK, Low level file positioning subroutine
160 * @code{FSTAT}: FSTAT, Get file status
161 * @code{FTELL}: FTELL, Current stream position
162 * @code{GAMMA}: GAMMA, Gamma function
163 * @code{GERROR}: GERROR, Get last system error message
164 * @code{GETARG}: GETARG, Get command line arguments
165 * @code{GET_COMMAND}: GET_COMMAND, Get the entire command line
166 * @code{GET_COMMAND_ARGUMENT}: GET_COMMAND_ARGUMENT, Get command line arguments
167 * @code{GETCWD}: GETCWD, Get current working directory
168 * @code{GETENV}: GETENV, Get an environmental variable
169 * @code{GET_ENVIRONMENT_VARIABLE}: GET_ENVIRONMENT_VARIABLE, Get an environmental variable
170 * @code{GETGID}: GETGID, Group ID function
171 * @code{GETLOG}: GETLOG, Get login name
172 * @code{GETPID}: GETPID, Process ID function
173 * @code{GETUID}: GETUID, User ID function
174 * @code{GMTIME}: GMTIME, Convert time to GMT info
175 * @code{HOSTNM}: HOSTNM, Get system host name
176 * @code{HUGE}: HUGE, Largest number of a kind
177 * @code{HYPOT}: HYPOT, Euclidean distance function
178 * @code{IACHAR}: IACHAR, Code in @acronym{ASCII} collating sequence
179 * @code{IALL}: IALL, Bitwise AND of array elements
180 * @code{IAND}: IAND, Bitwise logical and
181 * @code{IANY}: IANY, Bitwise OR of array elements
182 * @code{IARGC}: IARGC, Get the number of command line arguments
183 * @code{IBCLR}: IBCLR, Clear bit
184 * @code{IBITS}: IBITS, Bit extraction
185 * @code{IBSET}: IBSET, Set bit
186 * @code{ICHAR}: ICHAR, Character-to-integer conversion function
187 * @code{IDATE}: IDATE, Current local time (day/month/year)
188 * @code{IEOR}: IEOR, Bitwise logical exclusive or
189 * @code{IERRNO}: IERRNO, Function to get the last system error number
190 * @code{IMAGE_INDEX}: IMAGE_INDEX, Cosubscript to image index conversion
191 * @code{INDEX}: INDEX intrinsic, Position of a substring within a string
192 * @code{INT}: INT, Convert to integer type
193 * @code{INT2}: INT2, Convert to 16-bit integer type
194 * @code{INT8}: INT8, Convert to 64-bit integer type
195 * @code{IOR}: IOR, Bitwise logical or
196 * @code{IPARITY}: IPARITY, Bitwise XOR of array elements
197 * @code{IRAND}: IRAND, Integer pseudo-random number
198 * @code{IS_CONTIGUOUS}: IS_CONTIGUOUS, Test whether an array is contiguous
199 * @code{IS_IOSTAT_END}: IS_IOSTAT_END, Test for end-of-file value
200 * @code{IS_IOSTAT_EOR}: IS_IOSTAT_EOR, Test for end-of-record value
201 * @code{ISATTY}: ISATTY, Whether a unit is a terminal device
202 * @code{ISHFT}: ISHFT, Shift bits
203 * @code{ISHFTC}: ISHFTC, Shift bits circularly
204 * @code{ISNAN}: ISNAN, Tests for a NaN
205 * @code{ITIME}: ITIME, Current local time (hour/minutes/seconds)
206 * @code{KILL}: KILL, Send a signal to a process
207 * @code{KIND}: KIND, Kind of an entity
208 * @code{LBOUND}: LBOUND, Lower dimension bounds of an array
209 * @code{LCOBOUND}: LCOBOUND, Lower codimension bounds of an array
210 * @code{LEADZ}: LEADZ, Number of leading zero bits of an integer
211 * @code{LEN}: LEN, Length of a character entity
212 * @code{LEN_TRIM}: LEN_TRIM, Length of a character entity without trailing blank characters
213 * @code{LGE}: LGE, Lexical greater than or equal
214 * @code{LGT}: LGT, Lexical greater than
215 * @code{LINK}: LINK, Create a hard link
216 * @code{LLE}: LLE, Lexical less than or equal
217 * @code{LLT}: LLT, Lexical less than
218 * @code{LNBLNK}: LNBLNK, Index of the last non-blank character in a string
219 * @code{LOC}: LOC, Returns the address of a variable
220 * @code{LOG}: LOG, Logarithm function
221 * @code{LOG10}: LOG10, Base 10 logarithm function
222 * @code{LOG_GAMMA}: LOG_GAMMA, Logarithm of the Gamma function
223 * @code{LOGICAL}: LOGICAL, Convert to logical type
224 * @code{LONG}: LONG, Convert to integer type
225 * @code{LSHIFT}: LSHIFT, Left shift bits
226 * @code{LSTAT}: LSTAT, Get file status
227 * @code{LTIME}: LTIME, Convert time to local time info
228 * @code{MALLOC}: MALLOC, Dynamic memory allocation function
229 * @code{MASKL}: MASKL, Left justified mask
230 * @code{MASKR}: MASKR, Right justified mask
231 * @code{MATMUL}: MATMUL, matrix multiplication
232 * @code{MAX}: MAX, Maximum value of an argument list
233 * @code{MAXEXPONENT}: MAXEXPONENT, Maximum exponent of a real kind
234 * @code{MAXLOC}: MAXLOC, Location of the maximum value within an array
235 * @code{MAXVAL}: MAXVAL, Maximum value of an array
236 * @code{MCLOCK}: MCLOCK, Time function
237 * @code{MCLOCK8}: MCLOCK8, Time function (64-bit)
238 * @code{MERGE}: MERGE, Merge arrays
239 * @code{MERGE_BITS}: MERGE_BITS, Merge of bits under mask
240 * @code{MIN}: MIN, Minimum value of an argument list
241 * @code{MINEXPONENT}: MINEXPONENT, Minimum exponent of a real kind
242 * @code{MINLOC}: MINLOC, Location of the minimum value within an array
243 * @code{MINVAL}: MINVAL, Minimum value of an array
244 * @code{MOD}: MOD, Remainder function
245 * @code{MODULO}: MODULO, Modulo function
246 * @code{MOVE_ALLOC}: MOVE_ALLOC, Move allocation from one object to another
247 * @code{MVBITS}: MVBITS, Move bits from one integer to another
248 * @code{NEAREST}: NEAREST, Nearest representable number
249 * @code{NEW_LINE}: NEW_LINE, New line character
250 * @code{NINT}: NINT, Nearest whole number
251 * @code{NORM2}: NORM2, Euclidean vector norm
252 * @code{NOT}: NOT, Logical negation
253 * @code{NULL}: NULL, Function that returns an disassociated pointer
254 * @code{NUM_IMAGES}: NUM_IMAGES, Number of images
255 * @code{OR}: OR, Bitwise logical OR
256 * @code{PACK}: PACK, Pack an array into an array of rank one
257 * @code{PARITY}: PARITY, Reduction with exclusive OR
258 * @code{PERROR}: PERROR, Print system error message
259 * @code{POPCNT}: POPCNT, Number of bits set
260 * @code{POPPAR}: POPPAR, Parity of the number of bits set
261 * @code{PRECISION}: PRECISION, Decimal precision of a real kind
262 * @code{PRESENT}: PRESENT, Determine whether an optional dummy argument is specified
263 * @code{PRODUCT}: PRODUCT, Product of array elements
264 * @code{RADIX}: RADIX, Base of a data model
265 * @code{RAN}: RAN, Real pseudo-random number
266 * @code{RAND}: RAND, Real pseudo-random number
267 * @code{RANDOM_INIT}: RANDOM_INIT, Initialize pseudo-random number generator
268 * @code{RANDOM_NUMBER}: RANDOM_NUMBER, Pseudo-random number
269 * @code{RANDOM_SEED}: RANDOM_SEED, Initialize a pseudo-random number sequence
270 * @code{RANGE}: RANGE, Decimal exponent range
271 * @code{RANK} : RANK, Rank of a data object
272 * @code{REAL}: REAL, Convert to real type
273 * @code{RENAME}: RENAME, Rename a file
274 * @code{REPEAT}: REPEAT, Repeated string concatenation
275 * @code{RESHAPE}: RESHAPE, Function to reshape an array
276 * @code{RRSPACING}: RRSPACING, Reciprocal of the relative spacing
277 * @code{RSHIFT}: RSHIFT, Right shift bits
278 * @code{SAME_TYPE_AS}: SAME_TYPE_AS, Query dynamic types for equality
279 * @code{SCALE}: SCALE, Scale a real value
280 * @code{SCAN}: SCAN, Scan a string for the presence of a set of characters
281 * @code{SECNDS}: SECNDS, Time function
282 * @code{SECOND}: SECOND, CPU time function
283 * @code{SELECTED_CHAR_KIND}: SELECTED_CHAR_KIND, Choose character kind
284 * @code{SELECTED_INT_KIND}: SELECTED_INT_KIND, Choose integer kind
285 * @code{SELECTED_REAL_KIND}: SELECTED_REAL_KIND, Choose real kind
286 * @code{SET_EXPONENT}: SET_EXPONENT, Set the exponent of the model
287 * @code{SHAPE}: SHAPE, Determine the shape of an array
288 * @code{SHIFTA}: SHIFTA, Right shift with fill
289 * @code{SHIFTL}: SHIFTL, Left shift
290 * @code{SHIFTR}: SHIFTR, Right shift
291 * @code{SIGN}: SIGN, Sign copying function
292 * @code{SIGNAL}: SIGNAL, Signal handling subroutine (or function)
293 * @code{SIN}: SIN, Sine function
294 * @code{SIND}: SIND, Sine function, degrees
295 * @code{SINH}: SINH, Hyperbolic sine function
296 * @code{SIZE}: SIZE, Function to determine the size of an array
297 * @code{SIZEOF}: SIZEOF, Determine the size in bytes of an expression
298 * @code{SLEEP}: SLEEP, Sleep for the specified number of seconds
299 * @code{SPACING}: SPACING, Smallest distance between two numbers of a given type
300 * @code{SPREAD}: SPREAD, Add a dimension to an array
301 * @code{SQRT}: SQRT, Square-root function
302 * @code{SRAND}: SRAND, Reinitialize the random number generator
303 * @code{STAT}: STAT, Get file status
304 * @code{STORAGE_SIZE}: STORAGE_SIZE, Storage size in bits
305 * @code{SUM}: SUM, Sum of array elements
306 * @code{SYMLNK}: SYMLNK, Create a symbolic link
307 * @code{SYSTEM}: SYSTEM, Execute a shell command
308 * @code{SYSTEM_CLOCK}: SYSTEM_CLOCK, Time function
309 * @code{TAN}: TAN, Tangent function
310 * @code{TAND}: TAND, Tangent function, degrees
311 * @code{TANH}: TANH, Hyperbolic tangent function
312 * @code{THIS_IMAGE}: THIS_IMAGE, Cosubscript index of this image
313 * @code{TIME}: TIME, Time function
314 * @code{TIME8}: TIME8, Time function (64-bit)
315 * @code{TINY}: TINY, Smallest positive number of a real kind
316 * @code{TRAILZ}: TRAILZ, Number of trailing zero bits of an integer
317 * @code{TRANSFER}: TRANSFER, Transfer bit patterns
318 * @code{TRANSPOSE}: TRANSPOSE, Transpose an array of rank two
319 * @code{TRIM}: TRIM, Remove trailing blank characters of a string
320 * @code{TTYNAM}: TTYNAM, Get the name of a terminal device.
321 * @code{UBOUND}: UBOUND, Upper dimension bounds of an array
322 * @code{UCOBOUND}: UCOBOUND, Upper codimension bounds of an array
323 * @code{UMASK}: UMASK, Set the file creation mask
324 * @code{UNLINK}: UNLINK, Remove a file from the file system
325 * @code{UNPACK}: UNPACK, Unpack an array of rank one into an array
326 * @code{VERIFY}: VERIFY, Scan a string for the absence of a set of characters
327 * @code{XOR}: XOR, Bitwise logical exclusive or
328 @end menu
329
330 @node Introduction to Intrinsics
331 @section Introduction to intrinsic procedures
332
333 The intrinsic procedures provided by GNU Fortran include all of the
334 intrinsic procedures required by the Fortran 95 standard, a set of
335 intrinsic procedures for backwards compatibility with G77, and a
336 selection of intrinsic procedures from the Fortran 2003 and Fortran 2008
337 standards. Any conflict between a description here and a description in
338 either the Fortran 95 standard, the Fortran 2003 standard or the Fortran
339 2008 standard is unintentional, and the standard(s) should be considered
340 authoritative.
341
342 The enumeration of the @code{KIND} type parameter is processor defined in
343 the Fortran 95 standard. GNU Fortran defines the default integer type and
344 default real type by @code{INTEGER(KIND=4)} and @code{REAL(KIND=4)},
345 respectively. The standard mandates that both data types shall have
346 another kind, which have more precision. On typical target architectures
347 supported by @command{gfortran}, this kind type parameter is @code{KIND=8}.
348 Hence, @code{REAL(KIND=8)} and @code{DOUBLE PRECISION} are equivalent.
349 In the description of generic intrinsic procedures, the kind type parameter
350 will be specified by @code{KIND=*}, and in the description of specific
351 names for an intrinsic procedure the kind type parameter will be explicitly
352 given (e.g., @code{REAL(KIND=4)} or @code{REAL(KIND=8)}). Finally, for
353 brevity the optional @code{KIND=} syntax will be omitted.
354
355 Many of the intrinsic procedures take one or more optional arguments.
356 This document follows the convention used in the Fortran 95 standard,
357 and denotes such arguments by square brackets.
358
359 GNU Fortran offers the @option{-std=f95} and @option{-std=gnu} options,
360 which can be used to restrict the set of intrinsic procedures to a
361 given standard. By default, @command{gfortran} sets the @option{-std=gnu}
362 option, and so all intrinsic procedures described here are accepted. There
363 is one caveat. For a select group of intrinsic procedures, @command{g77}
364 implemented both a function and a subroutine. Both classes
365 have been implemented in @command{gfortran} for backwards compatibility
366 with @command{g77}. It is noted here that these functions and subroutines
367 cannot be intermixed in a given subprogram. In the descriptions that follow,
368 the applicable standard for each intrinsic procedure is noted.
369
370
371
372 @node ABORT
373 @section @code{ABORT} --- Abort the program
374 @fnindex ABORT
375 @cindex program termination, with core dump
376 @cindex terminate program, with core dump
377 @cindex core, dump
378
379 @table @asis
380 @item @emph{Description}:
381 @code{ABORT} causes immediate termination of the program. On operating
382 systems that support a core dump, @code{ABORT} will produce a core dump.
383 It will also print a backtrace, unless @code{-fno-backtrace} is given.
384
385 @item @emph{Standard}:
386 GNU extension
387
388 @item @emph{Class}:
389 Subroutine
390
391 @item @emph{Syntax}:
392 @code{CALL ABORT}
393
394 @item @emph{Return value}:
395 Does not return.
396
397 @item @emph{Example}:
398 @smallexample
399 program test_abort
400 integer :: i = 1, j = 2
401 if (i /= j) call abort
402 end program test_abort
403 @end smallexample
404
405 @item @emph{See also}:
406 @ref{EXIT}, @ref{KILL}, @ref{BACKTRACE}
407
408 @end table
409
410
411
412 @node ABS
413 @section @code{ABS} --- Absolute value
414 @fnindex ABS
415 @fnindex CABS
416 @fnindex DABS
417 @fnindex IABS
418 @fnindex ZABS
419 @fnindex CDABS
420 @fnindex BABS
421 @fnindex IIABS
422 @fnindex JIABS
423 @fnindex KIABS
424 @cindex absolute value
425
426 @table @asis
427 @item @emph{Description}:
428 @code{ABS(A)} computes the absolute value of @code{A}.
429
430 @item @emph{Standard}:
431 Fortran 77 and later, has overloads that are GNU extensions
432
433 @item @emph{Class}:
434 Elemental function
435
436 @item @emph{Syntax}:
437 @code{RESULT = ABS(A)}
438
439 @item @emph{Arguments}:
440 @multitable @columnfractions .15 .70
441 @item @var{A} @tab The type of the argument shall be an @code{INTEGER},
442 @code{REAL}, or @code{COMPLEX}.
443 @end multitable
444
445 @item @emph{Return value}:
446 The return value is of the same type and
447 kind as the argument except the return value is @code{REAL} for a
448 @code{COMPLEX} argument.
449
450 @item @emph{Example}:
451 @smallexample
452 program test_abs
453 integer :: i = -1
454 real :: x = -1.e0
455 complex :: z = (-1.e0,0.e0)
456 i = abs(i)
457 x = abs(x)
458 x = abs(z)
459 end program test_abs
460 @end smallexample
461
462 @item @emph{Specific names}:
463 @multitable @columnfractions .20 .20 .20 .25
464 @item Name @tab Argument @tab Return type @tab Standard
465 @item @code{ABS(A)} @tab @code{REAL(4) A} @tab @code{REAL(4)} @tab Fortran 77 and later
466 @item @code{CABS(A)} @tab @code{COMPLEX(4) A} @tab @code{REAL(4)} @tab Fortran 77 and later
467 @item @code{DABS(A)} @tab @code{REAL(8) A} @tab @code{REAL(8)} @tab Fortran 77 and later
468 @item @code{IABS(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab Fortran 77 and later
469 @item @code{BABS(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
470 @item @code{IIABS(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
471 @item @code{JIABS(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
472 @item @code{KIABS(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
473 @item @code{ZABS(A)} @tab @code{COMPLEX(8) A} @tab @code{COMPLEX(8)} @tab GNU extension
474 @item @code{CDABS(A)} @tab @code{COMPLEX(8) A} @tab @code{COMPLEX(8)} @tab GNU extension
475 @end multitable
476 @end table
477
478
479
480 @node ACCESS
481 @section @code{ACCESS} --- Checks file access modes
482 @fnindex ACCESS
483 @cindex file system, access mode
484
485 @table @asis
486 @item @emph{Description}:
487 @code{ACCESS(NAME, MODE)} checks whether the file @var{NAME}
488 exists, is readable, writable or executable. Except for the
489 executable check, @code{ACCESS} can be replaced by
490 Fortran 95's @code{INQUIRE}.
491
492 @item @emph{Standard}:
493 GNU extension
494
495 @item @emph{Class}:
496 Inquiry function
497
498 @item @emph{Syntax}:
499 @code{RESULT = ACCESS(NAME, MODE)}
500
501 @item @emph{Arguments}:
502 @multitable @columnfractions .15 .70
503 @item @var{NAME} @tab Scalar @code{CHARACTER} of default kind with the
504 file name. Tailing blank are ignored unless the character @code{achar(0)}
505 is present, then all characters up to and excluding @code{achar(0)} are
506 used as file name.
507 @item @var{MODE} @tab Scalar @code{CHARACTER} of default kind with the
508 file access mode, may be any concatenation of @code{"r"} (readable),
509 @code{"w"} (writable) and @code{"x"} (executable), or @code{" "} to check
510 for existence.
511 @end multitable
512
513 @item @emph{Return value}:
514 Returns a scalar @code{INTEGER}, which is @code{0} if the file is
515 accessible in the given mode; otherwise or if an invalid argument
516 has been given for @code{MODE} the value @code{1} is returned.
517
518 @item @emph{Example}:
519 @smallexample
520 program access_test
521 implicit none
522 character(len=*), parameter :: file = 'test.dat'
523 character(len=*), parameter :: file2 = 'test.dat '//achar(0)
524 if(access(file,' ') == 0) print *, trim(file),' is exists'
525 if(access(file,'r') == 0) print *, trim(file),' is readable'
526 if(access(file,'w') == 0) print *, trim(file),' is writable'
527 if(access(file,'x') == 0) print *, trim(file),' is executable'
528 if(access(file2,'rwx') == 0) &
529 print *, trim(file2),' is readable, writable and executable'
530 end program access_test
531 @end smallexample
532 @item @emph{Specific names}:
533 @item @emph{See also}:
534
535 @end table
536
537
538
539 @node ACHAR
540 @section @code{ACHAR} --- Character in @acronym{ASCII} collating sequence
541 @fnindex ACHAR
542 @cindex @acronym{ASCII} collating sequence
543 @cindex collating sequence, @acronym{ASCII}
544
545 @table @asis
546 @item @emph{Description}:
547 @code{ACHAR(I)} returns the character located at position @code{I}
548 in the @acronym{ASCII} collating sequence.
549
550 @item @emph{Standard}:
551 Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later
552
553 @item @emph{Class}:
554 Elemental function
555
556 @item @emph{Syntax}:
557 @code{RESULT = ACHAR(I [, KIND])}
558
559 @item @emph{Arguments}:
560 @multitable @columnfractions .15 .70
561 @item @var{I} @tab The type shall be @code{INTEGER}.
562 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
563 expression indicating the kind parameter of the result.
564 @end multitable
565
566 @item @emph{Return value}:
567 The return value is of type @code{CHARACTER} with a length of one.
568 If the @var{KIND} argument is present, the return value is of the
569 specified kind and of the default kind otherwise.
570
571 @item @emph{Example}:
572 @smallexample
573 program test_achar
574 character c
575 c = achar(32)
576 end program test_achar
577 @end smallexample
578
579 @item @emph{Note}:
580 See @ref{ICHAR} for a discussion of converting between numerical values
581 and formatted string representations.
582
583 @item @emph{See also}:
584 @ref{CHAR}, @ref{IACHAR}, @ref{ICHAR}
585
586 @end table
587
588
589
590 @node ACOS
591 @section @code{ACOS} --- Arccosine function
592 @fnindex ACOS
593 @fnindex DACOS
594 @cindex trigonometric function, cosine, inverse
595 @cindex cosine, inverse
596
597 @table @asis
598 @item @emph{Description}:
599 @code{ACOS(X)} computes the arccosine of @var{X} (inverse of @code{COS(X)}).
600
601 @item @emph{Standard}:
602 Fortran 77 and later, for a complex argument Fortran 2008 or later
603
604 @item @emph{Class}:
605 Elemental function
606
607 @item @emph{Syntax}:
608 @code{RESULT = ACOS(X)}
609
610 @item @emph{Arguments}:
611 @multitable @columnfractions .15 .70
612 @item @var{X} @tab The type shall either be @code{REAL} with a magnitude that is
613 less than or equal to one - or the type shall be @code{COMPLEX}.
614 @end multitable
615
616 @item @emph{Return value}:
617 The return value is of the same type and kind as @var{X}.
618 The real part of the result is in radians and lies in the range
619 @math{0 \leq \Re \acos(x) \leq \pi}.
620
621 @item @emph{Example}:
622 @smallexample
623 program test_acos
624 real(8) :: x = 0.866_8
625 x = acos(x)
626 end program test_acos
627 @end smallexample
628
629 @item @emph{Specific names}:
630 @multitable @columnfractions .20 .20 .20 .25
631 @item Name @tab Argument @tab Return type @tab Standard
632 @item @code{ACOS(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later
633 @item @code{DACOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
634 @end multitable
635
636 @item @emph{See also}:
637 Inverse function: @ref{COS}
638 Degrees function: @ref{ACOSD}
639
640 @end table
641
642
643
644 @node ACOSD
645 @section @code{ACOSD} --- Arccosine function, degrees
646 @fnindex ACOSD
647 @fnindex DACOSD
648 @cindex trigonometric function, cosine, inverse, degrees
649 @cindex cosine, inverse, degrees
650
651 @table @asis
652 @item @emph{Description}:
653 @code{ACOSD(X)} computes the arccosine of @var{X} in degrees (inverse of
654 @code{COSD(X)}).
655
656 This function is for compatibility only and should be avoided in favor of
657 standard constructs wherever possible.
658
659 @item @emph{Standard}:
660 GNU Extension, enabled with @option{-fdec-math}
661
662 @item @emph{Class}:
663 Elemental function
664
665 @item @emph{Syntax}:
666 @code{RESULT = ACOSD(X)}
667
668 @item @emph{Arguments}:
669 @multitable @columnfractions .15 .70
670 @item @var{X} @tab The type shall either be @code{REAL} with a magnitude that is
671 less than or equal to one - or the type shall be @code{COMPLEX}.
672 @end multitable
673
674 @item @emph{Return value}:
675 The return value is of the same type and kind as @var{X}.
676 The real part of the result is in degrees and lies in the range
677 @math{0 \leq \Re \acos(x) \leq 180}.
678
679 @item @emph{Example}:
680 @smallexample
681 program test_acosd
682 real(8) :: x = 0.866_8
683 x = acosd(x)
684 end program test_acosd
685 @end smallexample
686
687 @item @emph{Specific names}:
688 @multitable @columnfractions .20 .20 .20 .25
689 @item Name @tab Argument @tab Return type @tab Standard
690 @item @code{ACOSD(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU Extension
691 @item @code{DACOSD(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU Extension
692 @end multitable
693
694 @item @emph{See also}:
695 Inverse function: @ref{COSD}
696 Radians function: @ref{ACOS}
697
698 @end table
699
700
701
702 @node ACOSH
703 @section @code{ACOSH} --- Inverse hyperbolic cosine function
704 @fnindex ACOSH
705 @fnindex DACOSH
706 @cindex area hyperbolic cosine
707 @cindex inverse hyperbolic cosine
708 @cindex hyperbolic function, cosine, inverse
709 @cindex cosine, hyperbolic, inverse
710
711 @table @asis
712 @item @emph{Description}:
713 @code{ACOSH(X)} computes the inverse hyperbolic cosine of @var{X}.
714
715 @item @emph{Standard}:
716 Fortran 2008 and later
717
718 @item @emph{Class}:
719 Elemental function
720
721 @item @emph{Syntax}:
722 @code{RESULT = ACOSH(X)}
723
724 @item @emph{Arguments}:
725 @multitable @columnfractions .15 .70
726 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
727 @end multitable
728
729 @item @emph{Return value}:
730 The return value has the same type and kind as @var{X}. If @var{X} is
731 complex, the imaginary part of the result is in radians and lies between
732 @math{ 0 \leq \Im \acosh(x) \leq \pi}.
733
734 @item @emph{Example}:
735 @smallexample
736 PROGRAM test_acosh
737 REAL(8), DIMENSION(3) :: x = (/ 1.0, 2.0, 3.0 /)
738 WRITE (*,*) ACOSH(x)
739 END PROGRAM
740 @end smallexample
741
742 @item @emph{Specific names}:
743 @multitable @columnfractions .20 .20 .20 .25
744 @item Name @tab Argument @tab Return type @tab Standard
745 @item @code{DACOSH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
746 @end multitable
747
748 @item @emph{See also}:
749 Inverse function: @ref{COSH}
750 @end table
751
752
753
754 @node ADJUSTL
755 @section @code{ADJUSTL} --- Left adjust a string
756 @fnindex ADJUSTL
757 @cindex string, adjust left
758 @cindex adjust string
759
760 @table @asis
761 @item @emph{Description}:
762 @code{ADJUSTL(STRING)} will left adjust a string by removing leading spaces.
763 Spaces are inserted at the end of the string as needed.
764
765 @item @emph{Standard}:
766 Fortran 90 and later
767
768 @item @emph{Class}:
769 Elemental function
770
771 @item @emph{Syntax}:
772 @code{RESULT = ADJUSTL(STRING)}
773
774 @item @emph{Arguments}:
775 @multitable @columnfractions .15 .70
776 @item @var{STRING} @tab The type shall be @code{CHARACTER}.
777 @end multitable
778
779 @item @emph{Return value}:
780 The return value is of type @code{CHARACTER} and of the same kind as
781 @var{STRING} where leading spaces are removed and the same number of
782 spaces are inserted on the end of @var{STRING}.
783
784 @item @emph{Example}:
785 @smallexample
786 program test_adjustl
787 character(len=20) :: str = ' gfortran'
788 str = adjustl(str)
789 print *, str
790 end program test_adjustl
791 @end smallexample
792
793 @item @emph{See also}:
794 @ref{ADJUSTR}, @ref{TRIM}
795 @end table
796
797
798
799 @node ADJUSTR
800 @section @code{ADJUSTR} --- Right adjust a string
801 @fnindex ADJUSTR
802 @cindex string, adjust right
803 @cindex adjust string
804
805 @table @asis
806 @item @emph{Description}:
807 @code{ADJUSTR(STRING)} will right adjust a string by removing trailing spaces.
808 Spaces are inserted at the start of the string as needed.
809
810 @item @emph{Standard}:
811 Fortran 95 and later
812
813 @item @emph{Class}:
814 Elemental function
815
816 @item @emph{Syntax}:
817 @code{RESULT = ADJUSTR(STRING)}
818
819 @item @emph{Arguments}:
820 @multitable @columnfractions .15 .70
821 @item @var{STR} @tab The type shall be @code{CHARACTER}.
822 @end multitable
823
824 @item @emph{Return value}:
825 The return value is of type @code{CHARACTER} and of the same kind as
826 @var{STRING} where trailing spaces are removed and the same number of
827 spaces are inserted at the start of @var{STRING}.
828
829 @item @emph{Example}:
830 @smallexample
831 program test_adjustr
832 character(len=20) :: str = 'gfortran'
833 str = adjustr(str)
834 print *, str
835 end program test_adjustr
836 @end smallexample
837
838 @item @emph{See also}:
839 @ref{ADJUSTL}, @ref{TRIM}
840 @end table
841
842
843
844 @node AIMAG
845 @section @code{AIMAG} --- Imaginary part of complex number
846 @fnindex AIMAG
847 @fnindex DIMAG
848 @fnindex IMAG
849 @fnindex IMAGPART
850 @cindex complex numbers, imaginary part
851
852 @table @asis
853 @item @emph{Description}:
854 @code{AIMAG(Z)} yields the imaginary part of complex argument @code{Z}.
855 The @code{IMAG(Z)} and @code{IMAGPART(Z)} intrinsic functions are provided
856 for compatibility with @command{g77}, and their use in new code is
857 strongly discouraged.
858
859 @item @emph{Standard}:
860 Fortran 77 and later, has overloads that are GNU extensions
861
862 @item @emph{Class}:
863 Elemental function
864
865 @item @emph{Syntax}:
866 @code{RESULT = AIMAG(Z)}
867
868 @item @emph{Arguments}:
869 @multitable @columnfractions .15 .70
870 @item @var{Z} @tab The type of the argument shall be @code{COMPLEX}.
871 @end multitable
872
873 @item @emph{Return value}:
874 The return value is of type @code{REAL} with the
875 kind type parameter of the argument.
876
877 @item @emph{Example}:
878 @smallexample
879 program test_aimag
880 complex(4) z4
881 complex(8) z8
882 z4 = cmplx(1.e0_4, 0.e0_4)
883 z8 = cmplx(0.e0_8, 1.e0_8)
884 print *, aimag(z4), dimag(z8)
885 end program test_aimag
886 @end smallexample
887
888 @item @emph{Specific names}:
889 @multitable @columnfractions .20 .20 .20 .25
890 @item Name @tab Argument @tab Return type @tab Standard
891 @item @code{AIMAG(Z)} @tab @code{COMPLEX Z} @tab @code{REAL} @tab GNU extension
892 @item @code{DIMAG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{REAL(8)} @tab GNU extension
893 @item @code{IMAG(Z)} @tab @code{COMPLEX Z} @tab @code{REAL} @tab GNU extension
894 @item @code{IMAGPART(Z)} @tab @code{COMPLEX Z} @tab @code{REAL} @tab GNU extension
895 @end multitable
896 @end table
897
898
899
900 @node AINT
901 @section @code{AINT} --- Truncate to a whole number
902 @fnindex AINT
903 @fnindex DINT
904 @cindex floor
905 @cindex rounding, floor
906
907 @table @asis
908 @item @emph{Description}:
909 @code{AINT(A [, KIND])} truncates its argument to a whole number.
910
911 @item @emph{Standard}:
912 Fortran 77 and later
913
914 @item @emph{Class}:
915 Elemental function
916
917 @item @emph{Syntax}:
918 @code{RESULT = AINT(A [, KIND])}
919
920 @item @emph{Arguments}:
921 @multitable @columnfractions .15 .70
922 @item @var{A} @tab The type of the argument shall be @code{REAL}.
923 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
924 expression indicating the kind parameter of the result.
925 @end multitable
926
927 @item @emph{Return value}:
928 The return value is of type @code{REAL} with the kind type parameter of the
929 argument if the optional @var{KIND} is absent; otherwise, the kind
930 type parameter will be given by @var{KIND}. If the magnitude of
931 @var{X} is less than one, @code{AINT(X)} returns zero. If the
932 magnitude is equal to or greater than one then it returns the largest
933 whole number that does not exceed its magnitude. The sign is the same
934 as the sign of @var{X}.
935
936 @item @emph{Example}:
937 @smallexample
938 program test_aint
939 real(4) x4
940 real(8) x8
941 x4 = 1.234E0_4
942 x8 = 4.321_8
943 print *, aint(x4), dint(x8)
944 x8 = aint(x4,8)
945 end program test_aint
946 @end smallexample
947
948 @item @emph{Specific names}:
949 @multitable @columnfractions .20 .20 .20 .25
950 @item Name @tab Argument @tab Return type @tab Standard
951 @item @code{AINT(A)} @tab @code{REAL(4) A} @tab @code{REAL(4)} @tab Fortran 77 and later
952 @item @code{DINT(A)} @tab @code{REAL(8) A} @tab @code{REAL(8)} @tab Fortran 77 and later
953 @end multitable
954 @end table
955
956
957
958 @node ALARM
959 @section @code{ALARM} --- Execute a routine after a given delay
960 @fnindex ALARM
961 @cindex delayed execution
962
963 @table @asis
964 @item @emph{Description}:
965 @code{ALARM(SECONDS, HANDLER [, STATUS])} causes external subroutine @var{HANDLER}
966 to be executed after a delay of @var{SECONDS} by using @code{alarm(2)} to
967 set up a signal and @code{signal(2)} to catch it. If @var{STATUS} is
968 supplied, it will be returned with the number of seconds remaining until
969 any previously scheduled alarm was due to be delivered, or zero if there
970 was no previously scheduled alarm.
971
972 @item @emph{Standard}:
973 GNU extension
974
975 @item @emph{Class}:
976 Subroutine
977
978 @item @emph{Syntax}:
979 @code{CALL ALARM(SECONDS, HANDLER [, STATUS])}
980
981 @item @emph{Arguments}:
982 @multitable @columnfractions .15 .70
983 @item @var{SECONDS} @tab The type of the argument shall be a scalar
984 @code{INTEGER}. It is @code{INTENT(IN)}.
985 @item @var{HANDLER} @tab Signal handler (@code{INTEGER FUNCTION} or
986 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar. The scalar
987 values may be either @code{SIG_IGN=1} to ignore the alarm generated
988 or @code{SIG_DFL=0} to set the default action. It is @code{INTENT(IN)}.
989 @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
990 variable of the default @code{INTEGER} kind. It is @code{INTENT(OUT)}.
991 @end multitable
992
993 @item @emph{Example}:
994 @smallexample
995 program test_alarm
996 external handler_print
997 integer i
998 call alarm (3, handler_print, i)
999 print *, i
1000 call sleep(10)
1001 end program test_alarm
1002 @end smallexample
1003 This will cause the external routine @var{handler_print} to be called
1004 after 3 seconds.
1005 @end table
1006
1007
1008
1009 @node ALL
1010 @section @code{ALL} --- All values in @var{MASK} along @var{DIM} are true
1011 @fnindex ALL
1012 @cindex array, apply condition
1013 @cindex array, condition testing
1014
1015 @table @asis
1016 @item @emph{Description}:
1017 @code{ALL(MASK [, DIM])} determines if all the values are true in @var{MASK}
1018 in the array along dimension @var{DIM}.
1019
1020 @item @emph{Standard}:
1021 Fortran 95 and later
1022
1023 @item @emph{Class}:
1024 Transformational function
1025
1026 @item @emph{Syntax}:
1027 @code{RESULT = ALL(MASK [, DIM])}
1028
1029 @item @emph{Arguments}:
1030 @multitable @columnfractions .15 .70
1031 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL} and
1032 it shall not be scalar.
1033 @item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer
1034 with a value that lies between one and the rank of @var{MASK}.
1035 @end multitable
1036
1037 @item @emph{Return value}:
1038 @code{ALL(MASK)} returns a scalar value of type @code{LOGICAL} where
1039 the kind type parameter is the same as the kind type parameter of
1040 @var{MASK}. If @var{DIM} is present, then @code{ALL(MASK, DIM)} returns
1041 an array with the rank of @var{MASK} minus 1. The shape is determined from
1042 the shape of @var{MASK} where the @var{DIM} dimension is elided.
1043
1044 @table @asis
1045 @item (A)
1046 @code{ALL(MASK)} is true if all elements of @var{MASK} are true.
1047 It also is true if @var{MASK} has zero size; otherwise, it is false.
1048 @item (B)
1049 If the rank of @var{MASK} is one, then @code{ALL(MASK,DIM)} is equivalent
1050 to @code{ALL(MASK)}. If the rank is greater than one, then @code{ALL(MASK,DIM)}
1051 is determined by applying @code{ALL} to the array sections.
1052 @end table
1053
1054 @item @emph{Example}:
1055 @smallexample
1056 program test_all
1057 logical l
1058 l = all((/.true., .true., .true./))
1059 print *, l
1060 call section
1061 contains
1062 subroutine section
1063 integer a(2,3), b(2,3)
1064 a = 1
1065 b = 1
1066 b(2,2) = 2
1067 print *, all(a .eq. b, 1)
1068 print *, all(a .eq. b, 2)
1069 end subroutine section
1070 end program test_all
1071 @end smallexample
1072 @end table
1073
1074
1075
1076 @node ALLOCATED
1077 @section @code{ALLOCATED} --- Status of an allocatable entity
1078 @fnindex ALLOCATED
1079 @cindex allocation, status
1080
1081 @table @asis
1082 @item @emph{Description}:
1083 @code{ALLOCATED(ARRAY)} and @code{ALLOCATED(SCALAR)} check the allocation
1084 status of @var{ARRAY} and @var{SCALAR}, respectively.
1085
1086 @item @emph{Standard}:
1087 Fortran 95 and later. Note, the @code{SCALAR=} keyword and allocatable
1088 scalar entities are available in Fortran 2003 and later.
1089
1090 @item @emph{Class}:
1091 Inquiry function
1092
1093 @item @emph{Syntax}:
1094 @multitable @columnfractions .80
1095 @item @code{RESULT = ALLOCATED(ARRAY)}
1096 @item @code{RESULT = ALLOCATED(SCALAR)}
1097 @end multitable
1098
1099 @item @emph{Arguments}:
1100 @multitable @columnfractions .15 .70
1101 @item @var{ARRAY} @tab The argument shall be an @code{ALLOCATABLE} array.
1102 @item @var{SCALAR} @tab The argument shall be an @code{ALLOCATABLE} scalar.
1103 @end multitable
1104
1105 @item @emph{Return value}:
1106 The return value is a scalar @code{LOGICAL} with the default logical
1107 kind type parameter. If the argument is allocated, then the result is
1108 @code{.TRUE.}; otherwise, it returns @code{.FALSE.}
1109
1110 @item @emph{Example}:
1111 @smallexample
1112 program test_allocated
1113 integer :: i = 4
1114 real(4), allocatable :: x(:)
1115 if (.not. allocated(x)) allocate(x(i))
1116 end program test_allocated
1117 @end smallexample
1118 @end table
1119
1120
1121
1122 @node AND
1123 @section @code{AND} --- Bitwise logical AND
1124 @fnindex AND
1125 @cindex bitwise logical and
1126 @cindex logical and, bitwise
1127
1128 @table @asis
1129 @item @emph{Description}:
1130 Bitwise logical @code{AND}.
1131
1132 This intrinsic routine is provided for backwards compatibility with
1133 GNU Fortran 77. For integer arguments, programmers should consider
1134 the use of the @ref{IAND} intrinsic defined by the Fortran standard.
1135
1136 @item @emph{Standard}:
1137 GNU extension
1138
1139 @item @emph{Class}:
1140 Function
1141
1142 @item @emph{Syntax}:
1143 @code{RESULT = AND(I, J)}
1144
1145 @item @emph{Arguments}:
1146 @multitable @columnfractions .15 .70
1147 @item @var{I} @tab The type shall be either a scalar @code{INTEGER}
1148 type or a scalar @code{LOGICAL} type or a boz-literal-constant.
1149 @item @var{J} @tab The type shall be the same as the type of @var{I} or
1150 a boz-literal-constant. @var{I} and @var{J} shall not both be
1151 boz-literal-constants. If either @var{I} or @var{J} is a
1152 boz-literal-constant, then the other argument must be a scalar @code{INTEGER}.
1153 @end multitable
1154
1155 @item @emph{Return value}:
1156 The return type is either a scalar @code{INTEGER} or a scalar
1157 @code{LOGICAL}. If the kind type parameters differ, then the
1158 smaller kind type is implicitly converted to larger kind, and the
1159 return has the larger kind. A boz-literal-constant is
1160 converted to an @code{INTEGER} with the kind type parameter of
1161 the other argument as-if a call to @ref{INT} occurred.
1162
1163 @item @emph{Example}:
1164 @smallexample
1165 PROGRAM test_and
1166 LOGICAL :: T = .TRUE., F = .FALSE.
1167 INTEGER :: a, b
1168 DATA a / Z'F' /, b / Z'3' /
1169
1170 WRITE (*,*) AND(T, T), AND(T, F), AND(F, T), AND(F, F)
1171 WRITE (*,*) AND(a, b)
1172 END PROGRAM
1173 @end smallexample
1174
1175 @item @emph{See also}:
1176 Fortran 95 elemental function: @ref{IAND}
1177 @end table
1178
1179
1180
1181 @node ANINT
1182 @section @code{ANINT} --- Nearest whole number
1183 @fnindex ANINT
1184 @fnindex DNINT
1185 @cindex ceiling
1186 @cindex rounding, ceiling
1187
1188 @table @asis
1189 @item @emph{Description}:
1190 @code{ANINT(A [, KIND])} rounds its argument to the nearest whole number.
1191
1192 @item @emph{Standard}:
1193 Fortran 77 and later
1194
1195 @item @emph{Class}:
1196 Elemental function
1197
1198 @item @emph{Syntax}:
1199 @code{RESULT = ANINT(A [, KIND])}
1200
1201 @item @emph{Arguments}:
1202 @multitable @columnfractions .15 .70
1203 @item @var{A} @tab The type of the argument shall be @code{REAL}.
1204 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
1205 expression indicating the kind parameter of the result.
1206 @end multitable
1207
1208 @item @emph{Return value}:
1209 The return value is of type real with the kind type parameter of the
1210 argument if the optional @var{KIND} is absent; otherwise, the kind
1211 type parameter will be given by @var{KIND}. If @var{A} is greater than
1212 zero, @code{ANINT(A)} returns @code{AINT(X+0.5)}. If @var{A} is
1213 less than or equal to zero then it returns @code{AINT(X-0.5)}.
1214
1215 @item @emph{Example}:
1216 @smallexample
1217 program test_anint
1218 real(4) x4
1219 real(8) x8
1220 x4 = 1.234E0_4
1221 x8 = 4.321_8
1222 print *, anint(x4), dnint(x8)
1223 x8 = anint(x4,8)
1224 end program test_anint
1225 @end smallexample
1226
1227 @item @emph{Specific names}:
1228 @multitable @columnfractions .20 .20 .20 .25
1229 @item Name @tab Argument @tab Return type @tab Standard
1230 @item @code{AINT(A)} @tab @code{REAL(4) A} @tab @code{REAL(4)} @tab Fortran 77 and later
1231 @item @code{DNINT(A)} @tab @code{REAL(8) A} @tab @code{REAL(8)} @tab Fortran 77 and later
1232 @end multitable
1233 @end table
1234
1235
1236
1237 @node ANY
1238 @section @code{ANY} --- Any value in @var{MASK} along @var{DIM} is true
1239 @fnindex ANY
1240 @cindex array, apply condition
1241 @cindex array, condition testing
1242
1243 @table @asis
1244 @item @emph{Description}:
1245 @code{ANY(MASK [, DIM])} determines if any of the values in the logical array
1246 @var{MASK} along dimension @var{DIM} are @code{.TRUE.}.
1247
1248 @item @emph{Standard}:
1249 Fortran 95 and later
1250
1251 @item @emph{Class}:
1252 Transformational function
1253
1254 @item @emph{Syntax}:
1255 @code{RESULT = ANY(MASK [, DIM])}
1256
1257 @item @emph{Arguments}:
1258 @multitable @columnfractions .15 .70
1259 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL} and
1260 it shall not be scalar.
1261 @item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer
1262 with a value that lies between one and the rank of @var{MASK}.
1263 @end multitable
1264
1265 @item @emph{Return value}:
1266 @code{ANY(MASK)} returns a scalar value of type @code{LOGICAL} where
1267 the kind type parameter is the same as the kind type parameter of
1268 @var{MASK}. If @var{DIM} is present, then @code{ANY(MASK, DIM)} returns
1269 an array with the rank of @var{MASK} minus 1. The shape is determined from
1270 the shape of @var{MASK} where the @var{DIM} dimension is elided.
1271
1272 @table @asis
1273 @item (A)
1274 @code{ANY(MASK)} is true if any element of @var{MASK} is true;
1275 otherwise, it is false. It also is false if @var{MASK} has zero size.
1276 @item (B)
1277 If the rank of @var{MASK} is one, then @code{ANY(MASK,DIM)} is equivalent
1278 to @code{ANY(MASK)}. If the rank is greater than one, then @code{ANY(MASK,DIM)}
1279 is determined by applying @code{ANY} to the array sections.
1280 @end table
1281
1282 @item @emph{Example}:
1283 @smallexample
1284 program test_any
1285 logical l
1286 l = any((/.true., .true., .true./))
1287 print *, l
1288 call section
1289 contains
1290 subroutine section
1291 integer a(2,3), b(2,3)
1292 a = 1
1293 b = 1
1294 b(2,2) = 2
1295 print *, any(a .eq. b, 1)
1296 print *, any(a .eq. b, 2)
1297 end subroutine section
1298 end program test_any
1299 @end smallexample
1300 @end table
1301
1302
1303
1304 @node ASIN
1305 @section @code{ASIN} --- Arcsine function
1306 @fnindex ASIN
1307 @fnindex DASIN
1308 @cindex trigonometric function, sine, inverse
1309 @cindex sine, inverse
1310
1311 @table @asis
1312 @item @emph{Description}:
1313 @code{ASIN(X)} computes the arcsine of its @var{X} (inverse of @code{SIN(X)}).
1314
1315 @item @emph{Standard}:
1316 Fortran 77 and later, for a complex argument Fortran 2008 or later
1317
1318 @item @emph{Class}:
1319 Elemental function
1320
1321 @item @emph{Syntax}:
1322 @code{RESULT = ASIN(X)}
1323
1324 @item @emph{Arguments}:
1325 @multitable @columnfractions .15 .70
1326 @item @var{X} @tab The type shall be either @code{REAL} and a magnitude that is
1327 less than or equal to one - or be @code{COMPLEX}.
1328 @end multitable
1329
1330 @item @emph{Return value}:
1331 The return value is of the same type and kind as @var{X}.
1332 The real part of the result is in radians and lies in the range
1333 @math{-\pi/2 \leq \Re \asin(x) \leq \pi/2}.
1334
1335 @item @emph{Example}:
1336 @smallexample
1337 program test_asin
1338 real(8) :: x = 0.866_8
1339 x = asin(x)
1340 end program test_asin
1341 @end smallexample
1342
1343 @item @emph{Specific names}:
1344 @multitable @columnfractions .20 .20 .20 .25
1345 @item Name @tab Argument @tab Return type @tab Standard
1346 @item @code{ASIN(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later
1347 @item @code{DASIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
1348 @end multitable
1349
1350 @item @emph{See also}:
1351 Inverse function: @ref{SIN}
1352 Degrees function: @ref{ASIND}
1353
1354 @end table
1355
1356
1357
1358 @node ASIND
1359 @section @code{ASIND} --- Arcsine function, degrees
1360 @fnindex ASIND
1361 @fnindex DASIND
1362 @cindex trigonometric function, sine, inverse, degrees
1363 @cindex sine, inverse, degrees
1364
1365 @table @asis
1366 @item @emph{Description}:
1367 @code{ASIND(X)} computes the arcsine of its @var{X} in degrees (inverse of
1368 @code{SIND(X)}).
1369
1370 This function is for compatibility only and should be avoided in favor of
1371 standard constructs wherever possible.
1372
1373 @item @emph{Standard}:
1374 GNU Extension, enabled with @option{-fdec-math}.
1375
1376 @item @emph{Class}:
1377 Elemental function
1378
1379 @item @emph{Syntax}:
1380 @code{RESULT = ASIND(X)}
1381
1382 @item @emph{Arguments}:
1383 @multitable @columnfractions .15 .70
1384 @item @var{X} @tab The type shall be either @code{REAL} and a magnitude that is
1385 less than or equal to one - or be @code{COMPLEX}.
1386 @end multitable
1387
1388 @item @emph{Return value}:
1389 The return value is of the same type and kind as @var{X}.
1390 The real part of the result is in degrees and lies in the range
1391 @math{-90 \leq \Re \asin(x) \leq 90}.
1392
1393 @item @emph{Example}:
1394 @smallexample
1395 program test_asind
1396 real(8) :: x = 0.866_8
1397 x = asind(x)
1398 end program test_asind
1399 @end smallexample
1400
1401 @item @emph{Specific names}:
1402 @multitable @columnfractions .20 .20 .20 .25
1403 @item Name @tab Argument @tab Return type @tab Standard
1404 @item @code{ASIND(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU Extension
1405 @item @code{DASIND(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU Extension
1406 @end multitable
1407
1408 @item @emph{See also}:
1409 Inverse function: @ref{SIND}
1410 Radians function: @ref{ASIN}
1411
1412 @end table
1413
1414
1415
1416 @node ASINH
1417 @section @code{ASINH} --- Inverse hyperbolic sine function
1418 @fnindex ASINH
1419 @fnindex DASINH
1420 @cindex area hyperbolic sine
1421 @cindex inverse hyperbolic sine
1422 @cindex hyperbolic function, sine, inverse
1423 @cindex sine, hyperbolic, inverse
1424
1425 @table @asis
1426 @item @emph{Description}:
1427 @code{ASINH(X)} computes the inverse hyperbolic sine of @var{X}.
1428
1429 @item @emph{Standard}:
1430 Fortran 2008 and later
1431
1432 @item @emph{Class}:
1433 Elemental function
1434
1435 @item @emph{Syntax}:
1436 @code{RESULT = ASINH(X)}
1437
1438 @item @emph{Arguments}:
1439 @multitable @columnfractions .15 .70
1440 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
1441 @end multitable
1442
1443 @item @emph{Return value}:
1444 The return value is of the same type and kind as @var{X}. If @var{X} is
1445 complex, the imaginary part of the result is in radians and lies between
1446 @math{-\pi/2 \leq \Im \asinh(x) \leq \pi/2}.
1447
1448 @item @emph{Example}:
1449 @smallexample
1450 PROGRAM test_asinh
1451 REAL(8), DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1452 WRITE (*,*) ASINH(x)
1453 END PROGRAM
1454 @end smallexample
1455
1456 @item @emph{Specific names}:
1457 @multitable @columnfractions .20 .20 .20 .25
1458 @item Name @tab Argument @tab Return type @tab Standard
1459 @item @code{DASINH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension.
1460 @end multitable
1461
1462 @item @emph{See also}:
1463 Inverse function: @ref{SINH}
1464 @end table
1465
1466
1467
1468 @node ASSOCIATED
1469 @section @code{ASSOCIATED} --- Status of a pointer or pointer/target pair
1470 @fnindex ASSOCIATED
1471 @cindex pointer, status
1472 @cindex association status
1473
1474 @table @asis
1475 @item @emph{Description}:
1476 @code{ASSOCIATED(POINTER [, TARGET])} determines the status of the pointer
1477 @var{POINTER} or if @var{POINTER} is associated with the target @var{TARGET}.
1478
1479 @item @emph{Standard}:
1480 Fortran 95 and later
1481
1482 @item @emph{Class}:
1483 Inquiry function
1484
1485 @item @emph{Syntax}:
1486 @code{RESULT = ASSOCIATED(POINTER [, TARGET])}
1487
1488 @item @emph{Arguments}:
1489 @multitable @columnfractions .15 .70
1490 @item @var{POINTER} @tab @var{POINTER} shall have the @code{POINTER} attribute
1491 and it can be of any type.
1492 @item @var{TARGET} @tab (Optional) @var{TARGET} shall be a pointer or
1493 a target. It must have the same type, kind type parameter, and
1494 array rank as @var{POINTER}.
1495 @end multitable
1496 The association status of neither @var{POINTER} nor @var{TARGET} shall be
1497 undefined.
1498
1499 @item @emph{Return value}:
1500 @code{ASSOCIATED(POINTER)} returns a scalar value of type @code{LOGICAL(4)}.
1501 There are several cases:
1502 @table @asis
1503 @item (A) When the optional @var{TARGET} is not present then
1504 @code{ASSOCIATED(POINTER)} is true if @var{POINTER} is associated with a target; otherwise, it returns false.
1505 @item (B) If @var{TARGET} is present and a scalar target, the result is true if
1506 @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
1507 disassociated, the result is false.
1508 @item (C) If @var{TARGET} is present and an array target, the result is true if
1509 @var{TARGET} and @var{POINTER} have the same shape, are not zero-sized arrays,
1510 are arrays whose elements are not zero-sized storage sequences, and
1511 @var{TARGET} and @var{POINTER} occupy the same storage units in array element
1512 order.
1513 As in case(B), the result is false, if @var{POINTER} is disassociated.
1514 @item (D) If @var{TARGET} is present and an scalar pointer, the result is true
1515 if @var{TARGET} is associated with @var{POINTER}, the target associated with
1516 @var{TARGET} are not zero-sized storage sequences and occupy the same storage
1517 units.
1518 The result is false, if either @var{TARGET} or @var{POINTER} is disassociated.
1519 @item (E) If @var{TARGET} is present and an array pointer, the result is true if
1520 target associated with @var{POINTER} and the target associated with @var{TARGET}
1521 have the same shape, are not zero-sized arrays, are arrays whose elements are
1522 not zero-sized storage sequences, and @var{TARGET} and @var{POINTER} occupy
1523 the same storage units in array element order.
1524 The result is false, if either @var{TARGET} or @var{POINTER} is disassociated.
1525 @end table
1526
1527 @item @emph{Example}:
1528 @smallexample
1529 program test_associated
1530 implicit none
1531 real, target :: tgt(2) = (/1., 2./)
1532 real, pointer :: ptr(:)
1533 ptr => tgt
1534 if (associated(ptr) .eqv. .false.) call abort
1535 if (associated(ptr,tgt) .eqv. .false.) call abort
1536 end program test_associated
1537 @end smallexample
1538
1539 @item @emph{See also}:
1540 @ref{NULL}
1541 @end table
1542
1543
1544
1545 @node ATAN
1546 @section @code{ATAN} --- Arctangent function
1547 @fnindex ATAN
1548 @fnindex DATAN
1549 @cindex trigonometric function, tangent, inverse
1550 @cindex tangent, inverse
1551
1552 @table @asis
1553 @item @emph{Description}:
1554 @code{ATAN(X)} computes the arctangent of @var{X}.
1555
1556 @item @emph{Standard}:
1557 Fortran 77 and later, for a complex argument and for two arguments
1558 Fortran 2008 or later
1559
1560 @item @emph{Class}:
1561 Elemental function
1562
1563 @item @emph{Syntax}:
1564 @multitable @columnfractions .80
1565 @item @code{RESULT = ATAN(X)}
1566 @item @code{RESULT = ATAN(Y, X)}
1567 @end multitable
1568
1569 @item @emph{Arguments}:
1570 @multitable @columnfractions .15 .70
1571 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX};
1572 if @var{Y} is present, @var{X} shall be REAL.
1573 @item @var{Y} shall be of the same type and kind as @var{X}.
1574 @end multitable
1575
1576 @item @emph{Return value}:
1577 The return value is of the same type and kind as @var{X}.
1578 If @var{Y} is present, the result is identical to @code{ATAN2(Y,X)}.
1579 Otherwise, it the arcus tangent of @var{X}, where the real part of
1580 the result is in radians and lies in the range
1581 @math{-\pi/2 \leq \Re \atan(x) \leq \pi/2}.
1582
1583 @item @emph{Example}:
1584 @smallexample
1585 program test_atan
1586 real(8) :: x = 2.866_8
1587 x = atan(x)
1588 end program test_atan
1589 @end smallexample
1590
1591 @item @emph{Specific names}:
1592 @multitable @columnfractions .20 .20 .20 .25
1593 @item Name @tab Argument @tab Return type @tab Standard
1594 @item @code{ATAN(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later
1595 @item @code{DATAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
1596 @end multitable
1597
1598 @item @emph{See also}:
1599 Inverse function: @ref{TAN}
1600 Degrees function: @ref{ATAND}
1601
1602 @end table
1603
1604
1605
1606 @node ATAND
1607 @section @code{ATAND} --- Arctangent function, degrees
1608 @fnindex ATAND
1609 @fnindex DATAND
1610 @cindex trigonometric function, tangent, inverse, degrees
1611 @cindex tangent, inverse, degrees
1612
1613 @table @asis
1614 @item @emph{Description}:
1615 @code{ATAND(X)} computes the arctangent of @var{X} in degrees (inverse of
1616 @ref{TAND}).
1617
1618 This function is for compatibility only and should be avoided in favor of
1619 standard constructs wherever possible.
1620
1621 @item @emph{Standard}:
1622 GNU Extension, enabled with @option{-fdec-math}.
1623
1624 @item @emph{Class}:
1625 Elemental function
1626
1627 @item @emph{Syntax}:
1628 @multitable @columnfractions .80
1629 @item @code{RESULT = ATAND(X)}
1630 @item @code{RESULT = ATAND(Y, X)}
1631 @end multitable
1632
1633 @item @emph{Arguments}:
1634 @multitable @columnfractions .15 .70
1635 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX};
1636 if @var{Y} is present, @var{X} shall be REAL.
1637 @item @var{Y} shall be of the same type and kind as @var{X}.
1638 @end multitable
1639
1640 @item @emph{Return value}:
1641 The return value is of the same type and kind as @var{X}.
1642 If @var{Y} is present, the result is identical to @code{ATAND2(Y,X)}.
1643 Otherwise, it is the arcus tangent of @var{X}, where the real part of
1644 the result is in degrees and lies in the range
1645 @math{-90 \leq \Re \atand(x) \leq 90}.
1646
1647 @item @emph{Example}:
1648 @smallexample
1649 program test_atand
1650 real(8) :: x = 2.866_8
1651 x = atand(x)
1652 end program test_atand
1653 @end smallexample
1654
1655 @item @emph{Specific names}:
1656 @multitable @columnfractions .20 .20 .20 .25
1657 @item Name @tab Argument @tab Return type @tab Standard
1658 @item @code{ATAND(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU Extension
1659 @item @code{DATAND(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU Extension
1660 @end multitable
1661
1662 @item @emph{See also}:
1663 Inverse function: @ref{TAND}
1664 Radians function: @ref{ATAN}
1665
1666 @end table
1667
1668
1669
1670 @node ATAN2
1671 @section @code{ATAN2} --- Arctangent function
1672 @fnindex ATAN2
1673 @fnindex DATAN2
1674 @cindex trigonometric function, tangent, inverse
1675 @cindex tangent, inverse
1676
1677 @table @asis
1678 @item @emph{Description}:
1679 @code{ATAN2(Y, X)} computes the principal value of the argument
1680 function of the complex number @math{X + i Y}. This function can
1681 be used to transform from Cartesian into polar coordinates and
1682 allows to determine the angle in the correct quadrant.
1683
1684 @item @emph{Standard}:
1685 Fortran 77 and later
1686
1687 @item @emph{Class}:
1688 Elemental function
1689
1690 @item @emph{Syntax}:
1691 @code{RESULT = ATAN2(Y, X)}
1692
1693 @item @emph{Arguments}:
1694 @multitable @columnfractions .15 .70
1695 @item @var{Y} @tab The type shall be @code{REAL}.
1696 @item @var{X} @tab The type and kind type parameter shall be the same as @var{Y}.
1697 If @var{Y} is zero, then @var{X} must be nonzero.
1698 @end multitable
1699
1700 @item @emph{Return value}:
1701 The return value has the same type and kind type parameter as @var{Y}. It
1702 is the principal value of the complex number @math{X + i Y}. If @var{X}
1703 is nonzero, then it lies in the range @math{-\pi \le \atan (x) \leq \pi}.
1704 The sign is positive if @var{Y} is positive. If @var{Y} is zero, then
1705 the return value is zero if @var{X} is strictly positive, @math{\pi} if
1706 @var{X} is negative and @var{Y} is positive zero (or the processor does
1707 not handle signed zeros), and @math{-\pi} if @var{X} is negative and
1708 @var{Y} is negative zero. Finally, if @var{X} is zero, then the
1709 magnitude of the result is @math{\pi/2}.
1710
1711 @item @emph{Example}:
1712 @smallexample
1713 program test_atan2
1714 real(4) :: x = 1.e0_4, y = 0.5e0_4
1715 x = atan2(y,x)
1716 end program test_atan2
1717 @end smallexample
1718
1719 @item @emph{Specific names}:
1720 @multitable @columnfractions .20 .20 .20 .25
1721 @item Name @tab Argument @tab Return type @tab Standard
1722 @item @code{ATAN2(X, Y)} @tab @code{REAL(4) X, Y} @tab @code{REAL(4)} @tab Fortran 77 and later
1723 @item @code{DATAN2(X, Y)} @tab @code{REAL(8) X, Y} @tab @code{REAL(8)} @tab Fortran 77 and later
1724 @end multitable
1725
1726 @item @emph{See also}:
1727 Alias: @ref{ATAN}
1728 Degrees function: @ref{ATAN2D}
1729
1730 @end table
1731
1732
1733
1734 @node ATAN2D
1735 @section @code{ATAN2D} --- Arctangent function, degrees
1736 @fnindex ATAN2D
1737 @fnindex DATAN2D
1738 @cindex trigonometric function, tangent, inverse, degrees
1739 @cindex tangent, inverse, degrees
1740
1741 @table @asis
1742 @item @emph{Description}:
1743 @code{ATAN2D(Y, X)} computes the principal value of the argument
1744 function of the complex number @math{X + i Y} in degrees. This function can
1745 be used to transform from Cartesian into polar coordinates and
1746 allows to determine the angle in the correct quadrant.
1747
1748 This function is for compatibility only and should be avoided in favor of
1749 standard constructs wherever possible.
1750
1751 @item @emph{Standard}:
1752 GNU Extension, enabled with @option{-fdec-math}.
1753
1754 @item @emph{Class}:
1755 Elemental function
1756
1757 @item @emph{Syntax}:
1758 @code{RESULT = ATAN2D(Y, X)}
1759
1760 @item @emph{Arguments}:
1761 @multitable @columnfractions .15 .70
1762 @item @var{Y} @tab The type shall be @code{REAL}.
1763 @item @var{X} @tab The type and kind type parameter shall be the same as @var{Y}.
1764 If @var{Y} is zero, then @var{X} must be nonzero.
1765 @end multitable
1766
1767 @item @emph{Return value}:
1768 The return value has the same type and kind type parameter as @var{Y}. It
1769 is the principal value of the complex number @math{X + i Y}. If @var{X}
1770 is nonzero, then it lies in the range @math{-180 \le \atan (x) \leq 180}.
1771 The sign is positive if @var{Y} is positive. If @var{Y} is zero, then
1772 the return value is zero if @var{X} is strictly positive, @math{180} if
1773 @var{X} is negative and @var{Y} is positive zero (or the processor does
1774 not handle signed zeros), and @math{-180} if @var{X} is negative and
1775 @var{Y} is negative zero. Finally, if @var{X} is zero, then the
1776 magnitude of the result is @math{90}.
1777
1778 @item @emph{Example}:
1779 @smallexample
1780 program test_atan2d
1781 real(4) :: x = 1.e0_4, y = 0.5e0_4
1782 x = atan2d(y,x)
1783 end program test_atan2d
1784 @end smallexample
1785
1786 @item @emph{Specific names}:
1787 @multitable @columnfractions .20 .20 .20 .25
1788 @item Name @tab Argument @tab Return type @tab Standard
1789 @item @code{ATAN2D(X, Y)} @tab @code{REAL(4) X, Y} @tab @code{REAL(4)} @tab GNU Extension
1790 @item @code{DATAN2D(X, Y)} @tab @code{REAL(8) X, Y} @tab @code{REAL(8)} @tab GNU Extension
1791 @end multitable
1792
1793 @item @emph{See also}:
1794 Alias: @ref{ATAND}
1795 Radians function: @ref{ATAN2}
1796
1797 @end table
1798
1799
1800
1801 @node ATANH
1802 @section @code{ATANH} --- Inverse hyperbolic tangent function
1803 @fnindex ATANH
1804 @fnindex DATANH
1805 @cindex area hyperbolic tangent
1806 @cindex inverse hyperbolic tangent
1807 @cindex hyperbolic function, tangent, inverse
1808 @cindex tangent, hyperbolic, inverse
1809
1810 @table @asis
1811 @item @emph{Description}:
1812 @code{ATANH(X)} computes the inverse hyperbolic tangent of @var{X}.
1813
1814 @item @emph{Standard}:
1815 Fortran 2008 and later
1816
1817 @item @emph{Class}:
1818 Elemental function
1819
1820 @item @emph{Syntax}:
1821 @code{RESULT = ATANH(X)}
1822
1823 @item @emph{Arguments}:
1824 @multitable @columnfractions .15 .70
1825 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
1826 @end multitable
1827
1828 @item @emph{Return value}:
1829 The return value has same type and kind as @var{X}. If @var{X} is
1830 complex, the imaginary part of the result is in radians and lies between
1831 @math{-\pi/2 \leq \Im \atanh(x) \leq \pi/2}.
1832
1833 @item @emph{Example}:
1834 @smallexample
1835 PROGRAM test_atanh
1836 REAL, DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1837 WRITE (*,*) ATANH(x)
1838 END PROGRAM
1839 @end smallexample
1840
1841 @item @emph{Specific names}:
1842 @multitable @columnfractions .20 .20 .20 .25
1843 @item Name @tab Argument @tab Return type @tab Standard
1844 @item @code{DATANH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1845 @end multitable
1846
1847 @item @emph{See also}:
1848 Inverse function: @ref{TANH}
1849 @end table
1850
1851
1852
1853 @node ATOMIC_ADD
1854 @section @code{ATOMIC_ADD} --- Atomic ADD operation
1855 @fnindex ATOMIC_ADD
1856 @cindex Atomic subroutine, add
1857
1858 @table @asis
1859 @item @emph{Description}:
1860 @code{ATOMIC_ADD(ATOM, VALUE)} atomically adds the value of @var{VAR} to the
1861 variable @var{ATOM}. When @var{STAT} is present and the invocation was
1862 successful, it is assigned the value 0. If it is present and the invocation
1863 has failed, it is assigned a positive value; in particular, for a coindexed
1864 @var{ATOM}, if the remote image has stopped, it is assigned the value of
1865 @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has
1866 failed, the value @code{STAT_FAILED_IMAGE}.
1867
1868 @item @emph{Standard}:
1869 TS 18508 or later
1870
1871 @item @emph{Class}:
1872 Atomic subroutine
1873
1874 @item @emph{Syntax}:
1875 @code{CALL ATOMIC_ADD (ATOM, VALUE [, STAT])}
1876
1877 @item @emph{Arguments}:
1878 @multitable @columnfractions .15 .70
1879 @item @var{ATOM} @tab Scalar coarray or coindexed variable of integer
1880 type with @code{ATOMIC_INT_KIND} kind.
1881 @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind
1882 is different, the value is converted to the kind of @var{ATOM}.
1883 @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
1884 @end multitable
1885
1886 @item @emph{Example}:
1887 @smallexample
1888 program atomic
1889 use iso_fortran_env
1890 integer(atomic_int_kind) :: atom[*]
1891 call atomic_add (atom[1], this_image())
1892 end program atomic
1893 @end smallexample
1894
1895 @item @emph{See also}:
1896 @ref{ATOMIC_DEFINE}, @ref{ATOMIC_FETCH_ADD}, @ref{ISO_FORTRAN_ENV},
1897 @ref{ATOMIC_AND}, @ref{ATOMIC_OR}, @ref{ATOMIC_XOR}
1898 @end table
1899
1900
1901
1902
1903 @node ATOMIC_AND
1904 @section @code{ATOMIC_AND} --- Atomic bitwise AND operation
1905 @fnindex ATOMIC_AND
1906 @cindex Atomic subroutine, AND
1907
1908 @table @asis
1909 @item @emph{Description}:
1910 @code{ATOMIC_AND(ATOM, VALUE)} atomically defines @var{ATOM} with the bitwise
1911 AND between the values of @var{ATOM} and @var{VALUE}. When @var{STAT} is present
1912 and the invocation was successful, it is assigned the value 0. If it is present
1913 and the invocation has failed, it is assigned a positive value; in particular,
1914 for a coindexed @var{ATOM}, if the remote image has stopped, it is assigned the
1915 value of @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote
1916 image has failed, the value @code{STAT_FAILED_IMAGE}.
1917
1918 @item @emph{Standard}:
1919 TS 18508 or later
1920
1921 @item @emph{Class}:
1922 Atomic subroutine
1923
1924 @item @emph{Syntax}:
1925 @code{CALL ATOMIC_AND (ATOM, VALUE [, STAT])}
1926
1927 @item @emph{Arguments}:
1928 @multitable @columnfractions .15 .70
1929 @item @var{ATOM} @tab Scalar coarray or coindexed variable of integer
1930 type with @code{ATOMIC_INT_KIND} kind.
1931 @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind
1932 is different, the value is converted to the kind of @var{ATOM}.
1933 @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
1934 @end multitable
1935
1936 @item @emph{Example}:
1937 @smallexample
1938 program atomic
1939 use iso_fortran_env
1940 integer(atomic_int_kind) :: atom[*]
1941 call atomic_and (atom[1], int(b'10100011101'))
1942 end program atomic
1943 @end smallexample
1944
1945 @item @emph{See also}:
1946 @ref{ATOMIC_DEFINE}, @ref{ATOMIC_FETCH_AND}, @ref{ISO_FORTRAN_ENV},
1947 @ref{ATOMIC_ADD}, @ref{ATOMIC_OR}, @ref{ATOMIC_XOR}
1948 @end table
1949
1950
1951
1952 @node ATOMIC_CAS
1953 @section @code{ATOMIC_CAS} --- Atomic compare and swap
1954 @fnindex ATOMIC_DEFINE
1955 @cindex Atomic subroutine, compare and swap
1956
1957 @table @asis
1958 @item @emph{Description}:
1959 @code{ATOMIC_CAS} compares the variable @var{ATOM} with the value of
1960 @var{COMPARE}; if the value is the same, @var{ATOM} is set to the value
1961 of @var{NEW}. Additionally, @var{OLD} is set to the value of @var{ATOM}
1962 that was used for the comparison. When @var{STAT} is present and the invocation
1963 was successful, it is assigned the value 0. If it is present and the invocation
1964 has failed, it is assigned a positive value; in particular, for a coindexed
1965 @var{ATOM}, if the remote image has stopped, it is assigned the value of
1966 @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has
1967 failed, the value @code{STAT_FAILED_IMAGE}.
1968
1969 @item @emph{Standard}:
1970 TS 18508 or later
1971
1972 @item @emph{Class}:
1973 Atomic subroutine
1974
1975 @item @emph{Syntax}:
1976 @code{CALL ATOMIC_CAS (ATOM, OLD, COMPARE, NEW [, STAT])}
1977
1978 @item @emph{Arguments}:
1979 @multitable @columnfractions .15 .70
1980 @item @var{ATOM} @tab Scalar coarray or coindexed variable of either integer
1981 type with @code{ATOMIC_INT_KIND} kind or logical type with
1982 @code{ATOMIC_LOGICAL_KIND} kind.
1983 @item @var{OLD} @tab Scalar of the same type and kind as @var{ATOM}.
1984 @item @var{COMPARE} @tab Scalar variable of the same type and kind as
1985 @var{ATOM}.
1986 @item @var{NEW} @tab Scalar variable of the same type as @var{ATOM}. If kind
1987 is different, the value is converted to the kind of @var{ATOM}.
1988 @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
1989 @end multitable
1990
1991 @item @emph{Example}:
1992 @smallexample
1993 program atomic
1994 use iso_fortran_env
1995 logical(atomic_logical_kind) :: atom[*], prev
1996 call atomic_cas (atom[1], prev, .false., .true.))
1997 end program atomic
1998 @end smallexample
1999
2000 @item @emph{See also}:
2001 @ref{ATOMIC_DEFINE}, @ref{ATOMIC_REF}, @ref{ISO_FORTRAN_ENV}
2002 @end table
2003
2004
2005
2006 @node ATOMIC_DEFINE
2007 @section @code{ATOMIC_DEFINE} --- Setting a variable atomically
2008 @fnindex ATOMIC_DEFINE
2009 @cindex Atomic subroutine, define
2010
2011 @table @asis
2012 @item @emph{Description}:
2013 @code{ATOMIC_DEFINE(ATOM, VALUE)} defines the variable @var{ATOM} with the value
2014 @var{VALUE} atomically. When @var{STAT} is present and the invocation was
2015 successful, it is assigned the value 0. If it is present and the invocation
2016 has failed, it is assigned a positive value; in particular, for a coindexed
2017 @var{ATOM}, if the remote image has stopped, it is assigned the value of
2018 @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has
2019 failed, the value @code{STAT_FAILED_IMAGE}.
2020
2021 @item @emph{Standard}:
2022 Fortran 2008 and later; with @var{STAT}, TS 18508 or later
2023
2024 @item @emph{Class}:
2025 Atomic subroutine
2026
2027 @item @emph{Syntax}:
2028 @code{CALL ATOMIC_DEFINE (ATOM, VALUE [, STAT])}
2029
2030 @item @emph{Arguments}:
2031 @multitable @columnfractions .15 .70
2032 @item @var{ATOM} @tab Scalar coarray or coindexed variable of either integer
2033 type with @code{ATOMIC_INT_KIND} kind or logical type with
2034 @code{ATOMIC_LOGICAL_KIND} kind.
2035
2036 @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind
2037 is different, the value is converted to the kind of @var{ATOM}.
2038 @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
2039 @end multitable
2040
2041 @item @emph{Example}:
2042 @smallexample
2043 program atomic
2044 use iso_fortran_env
2045 integer(atomic_int_kind) :: atom[*]
2046 call atomic_define (atom[1], this_image())
2047 end program atomic
2048 @end smallexample
2049
2050 @item @emph{See also}:
2051 @ref{ATOMIC_REF}, @ref{ATOMIC_CAS}, @ref{ISO_FORTRAN_ENV},
2052 @ref{ATOMIC_ADD}, @ref{ATOMIC_AND}, @ref{ATOMIC_OR}, @ref{ATOMIC_XOR}
2053 @end table
2054
2055
2056
2057 @node ATOMIC_FETCH_ADD
2058 @section @code{ATOMIC_FETCH_ADD} --- Atomic ADD operation with prior fetch
2059 @fnindex ATOMIC_FETCH_ADD
2060 @cindex Atomic subroutine, ADD with fetch
2061
2062 @table @asis
2063 @item @emph{Description}:
2064 @code{ATOMIC_FETCH_ADD(ATOM, VALUE, OLD)} atomically stores the value of
2065 @var{ATOM} in @var{OLD} and adds the value of @var{VAR} to the
2066 variable @var{ATOM}. When @var{STAT} is present and the invocation was
2067 successful, it is assigned the value 0. If it is present and the invocation
2068 has failed, it is assigned a positive value; in particular, for a coindexed
2069 @var{ATOM}, if the remote image has stopped, it is assigned the value of
2070 @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has
2071 failed, the value @code{STAT_FAILED_IMAGE}.
2072
2073 @item @emph{Standard}:
2074 TS 18508 or later
2075
2076 @item @emph{Class}:
2077 Atomic subroutine
2078
2079 @item @emph{Syntax}:
2080 @code{CALL ATOMIC_FETCH_ADD (ATOM, VALUE, old [, STAT])}
2081
2082 @item @emph{Arguments}:
2083 @multitable @columnfractions .15 .70
2084 @item @var{ATOM} @tab Scalar coarray or coindexed variable of integer
2085 type with @code{ATOMIC_INT_KIND} kind.
2086 @code{ATOMIC_LOGICAL_KIND} kind.
2087
2088 @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind
2089 is different, the value is converted to the kind of @var{ATOM}.
2090 @item @var{OLD} @tab Scalar of the same type and kind as @var{ATOM}.
2091 @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
2092 @end multitable
2093
2094 @item @emph{Example}:
2095 @smallexample
2096 program atomic
2097 use iso_fortran_env
2098 integer(atomic_int_kind) :: atom[*], old
2099 call atomic_add (atom[1], this_image(), old)
2100 end program atomic
2101 @end smallexample
2102
2103 @item @emph{See also}:
2104 @ref{ATOMIC_DEFINE}, @ref{ATOMIC_ADD}, @ref{ISO_FORTRAN_ENV},
2105 @ref{ATOMIC_FETCH_AND}, @ref{ATOMIC_FETCH_OR}, @ref{ATOMIC_FETCH_XOR}
2106 @end table
2107
2108
2109
2110 @node ATOMIC_FETCH_AND
2111 @section @code{ATOMIC_FETCH_AND} --- Atomic bitwise AND operation with prior fetch
2112 @fnindex ATOMIC_FETCH_AND
2113 @cindex Atomic subroutine, AND with fetch
2114
2115 @table @asis
2116 @item @emph{Description}:
2117 @code{ATOMIC_AND(ATOM, VALUE)} atomically stores the value of @var{ATOM} in
2118 @var{OLD} and defines @var{ATOM} with the bitwise AND between the values of
2119 @var{ATOM} and @var{VALUE}. When @var{STAT} is present and the invocation was
2120 successful, it is assigned the value 0. If it is present and the invocation has
2121 failed, it is assigned a positive value; in particular, for a coindexed
2122 @var{ATOM}, if the remote image has stopped, it is assigned the value of
2123 @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has
2124 failed, the value @code{STAT_FAILED_IMAGE}.
2125
2126 @item @emph{Standard}:
2127 TS 18508 or later
2128
2129 @item @emph{Class}:
2130 Atomic subroutine
2131
2132 @item @emph{Syntax}:
2133 @code{CALL ATOMIC_FETCH_AND (ATOM, VALUE, OLD [, STAT])}
2134
2135 @item @emph{Arguments}:
2136 @multitable @columnfractions .15 .70
2137 @item @var{ATOM} @tab Scalar coarray or coindexed variable of integer
2138 type with @code{ATOMIC_INT_KIND} kind.
2139 @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind
2140 is different, the value is converted to the kind of @var{ATOM}.
2141 @item @var{OLD} @tab Scalar of the same type and kind as @var{ATOM}.
2142 @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
2143 @end multitable
2144
2145 @item @emph{Example}:
2146 @smallexample
2147 program atomic
2148 use iso_fortran_env
2149 integer(atomic_int_kind) :: atom[*], old
2150 call atomic_fetch_and (atom[1], int(b'10100011101'), old)
2151 end program atomic
2152 @end smallexample
2153
2154 @item @emph{See also}:
2155 @ref{ATOMIC_DEFINE}, @ref{ATOMIC_AND}, @ref{ISO_FORTRAN_ENV},
2156 @ref{ATOMIC_FETCH_ADD}, @ref{ATOMIC_FETCH_OR}, @ref{ATOMIC_FETCH_XOR}
2157 @end table
2158
2159
2160
2161 @node ATOMIC_FETCH_OR
2162 @section @code{ATOMIC_FETCH_OR} --- Atomic bitwise OR operation with prior fetch
2163 @fnindex ATOMIC_FETCH_OR
2164 @cindex Atomic subroutine, OR with fetch
2165
2166 @table @asis
2167 @item @emph{Description}:
2168 @code{ATOMIC_OR(ATOM, VALUE)} atomically stores the value of @var{ATOM} in
2169 @var{OLD} and defines @var{ATOM} with the bitwise OR between the values of
2170 @var{ATOM} and @var{VALUE}. When @var{STAT} is present and the invocation was
2171 successful, it is assigned the value 0. If it is present and the invocation has
2172 failed, it is assigned a positive value; in particular, for a coindexed
2173 @var{ATOM}, if the remote image has stopped, it is assigned the value of
2174 @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has
2175 failed, the value @code{STAT_FAILED_IMAGE}.
2176
2177 @item @emph{Standard}:
2178 TS 18508 or later
2179
2180 @item @emph{Class}:
2181 Atomic subroutine
2182
2183 @item @emph{Syntax}:
2184 @code{CALL ATOMIC_FETCH_OR (ATOM, VALUE, OLD [, STAT])}
2185
2186 @item @emph{Arguments}:
2187 @multitable @columnfractions .15 .70
2188 @item @var{ATOM} @tab Scalar coarray or coindexed variable of integer
2189 type with @code{ATOMIC_INT_KIND} kind.
2190 @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind
2191 is different, the value is converted to the kind of @var{ATOM}.
2192 @item @var{OLD} @tab Scalar of the same type and kind as @var{ATOM}.
2193 @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
2194 @end multitable
2195
2196 @item @emph{Example}:
2197 @smallexample
2198 program atomic
2199 use iso_fortran_env
2200 integer(atomic_int_kind) :: atom[*], old
2201 call atomic_fetch_or (atom[1], int(b'10100011101'), old)
2202 end program atomic
2203 @end smallexample
2204
2205 @item @emph{See also}:
2206 @ref{ATOMIC_DEFINE}, @ref{ATOMIC_OR}, @ref{ISO_FORTRAN_ENV},
2207 @ref{ATOMIC_FETCH_ADD}, @ref{ATOMIC_FETCH_AND}, @ref{ATOMIC_FETCH_XOR}
2208 @end table
2209
2210
2211
2212 @node ATOMIC_FETCH_XOR
2213 @section @code{ATOMIC_FETCH_XOR} --- Atomic bitwise XOR operation with prior fetch
2214 @fnindex ATOMIC_FETCH_XOR
2215 @cindex Atomic subroutine, XOR with fetch
2216
2217 @table @asis
2218 @item @emph{Description}:
2219 @code{ATOMIC_XOR(ATOM, VALUE)} atomically stores the value of @var{ATOM} in
2220 @var{OLD} and defines @var{ATOM} with the bitwise XOR between the values of
2221 @var{ATOM} and @var{VALUE}. When @var{STAT} is present and the invocation was
2222 successful, it is assigned the value 0. If it is present and the invocation has
2223 failed, it is assigned a positive value; in particular, for a coindexed
2224 @var{ATOM}, if the remote image has stopped, it is assigned the value of
2225 @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has
2226 failed, the value @code{STAT_FAILED_IMAGE}.
2227
2228 @item @emph{Standard}:
2229 TS 18508 or later
2230
2231 @item @emph{Class}:
2232 Atomic subroutine
2233
2234 @item @emph{Syntax}:
2235 @code{CALL ATOMIC_FETCH_XOR (ATOM, VALUE, OLD [, STAT])}
2236
2237 @item @emph{Arguments}:
2238 @multitable @columnfractions .15 .70
2239 @item @var{ATOM} @tab Scalar coarray or coindexed variable of integer
2240 type with @code{ATOMIC_INT_KIND} kind.
2241 @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind
2242 is different, the value is converted to the kind of @var{ATOM}.
2243 @item @var{OLD} @tab Scalar of the same type and kind as @var{ATOM}.
2244 @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
2245 @end multitable
2246
2247 @item @emph{Example}:
2248 @smallexample
2249 program atomic
2250 use iso_fortran_env
2251 integer(atomic_int_kind) :: atom[*], old
2252 call atomic_fetch_xor (atom[1], int(b'10100011101'), old)
2253 end program atomic
2254 @end smallexample
2255
2256 @item @emph{See also}:
2257 @ref{ATOMIC_DEFINE}, @ref{ATOMIC_XOR}, @ref{ISO_FORTRAN_ENV},
2258 @ref{ATOMIC_FETCH_ADD}, @ref{ATOMIC_FETCH_AND}, @ref{ATOMIC_FETCH_OR}
2259 @end table
2260
2261
2262
2263 @node ATOMIC_OR
2264 @section @code{ATOMIC_OR} --- Atomic bitwise OR operation
2265 @fnindex ATOMIC_OR
2266 @cindex Atomic subroutine, OR
2267
2268 @table @asis
2269 @item @emph{Description}:
2270 @code{ATOMIC_OR(ATOM, VALUE)} atomically defines @var{ATOM} with the bitwise
2271 AND between the values of @var{ATOM} and @var{VALUE}. When @var{STAT} is present
2272 and the invocation was successful, it is assigned the value 0. If it is present
2273 and the invocation has failed, it is assigned a positive value; in particular,
2274 for a coindexed @var{ATOM}, if the remote image has stopped, it is assigned the
2275 value of @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote
2276 image has failed, the value @code{STAT_FAILED_IMAGE}.
2277
2278 @item @emph{Standard}:
2279 TS 18508 or later
2280
2281 @item @emph{Class}:
2282 Atomic subroutine
2283
2284 @item @emph{Syntax}:
2285 @code{CALL ATOMIC_OR (ATOM, VALUE [, STAT])}
2286
2287 @item @emph{Arguments}:
2288 @multitable @columnfractions .15 .70
2289 @item @var{ATOM} @tab Scalar coarray or coindexed variable of integer
2290 type with @code{ATOMIC_INT_KIND} kind.
2291 @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind
2292 is different, the value is converted to the kind of @var{ATOM}.
2293 @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
2294 @end multitable
2295
2296 @item @emph{Example}:
2297 @smallexample
2298 program atomic
2299 use iso_fortran_env
2300 integer(atomic_int_kind) :: atom[*]
2301 call atomic_or (atom[1], int(b'10100011101'))
2302 end program atomic
2303 @end smallexample
2304
2305 @item @emph{See also}:
2306 @ref{ATOMIC_DEFINE}, @ref{ATOMIC_FETCH_OR}, @ref{ISO_FORTRAN_ENV},
2307 @ref{ATOMIC_ADD}, @ref{ATOMIC_OR}, @ref{ATOMIC_XOR}
2308 @end table
2309
2310
2311
2312 @node ATOMIC_REF
2313 @section @code{ATOMIC_REF} --- Obtaining the value of a variable atomically
2314 @fnindex ATOMIC_REF
2315 @cindex Atomic subroutine, reference
2316
2317 @table @asis
2318 @item @emph{Description}:
2319 @code{ATOMIC_DEFINE(ATOM, VALUE)} atomically assigns the value of the
2320 variable @var{ATOM} to @var{VALUE}. When @var{STAT} is present and the
2321 invocation was successful, it is assigned the value 0. If it is present and the
2322 invocation has failed, it is assigned a positive value; in particular, for a
2323 coindexed @var{ATOM}, if the remote image has stopped, it is assigned the value
2324 of @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image
2325 has failed, the value @code{STAT_FAILED_IMAGE}.
2326
2327
2328 @item @emph{Standard}:
2329 Fortran 2008 and later; with @var{STAT}, TS 18508 or later
2330
2331 @item @emph{Class}:
2332 Atomic subroutine
2333
2334 @item @emph{Syntax}:
2335 @code{CALL ATOMIC_REF(VALUE, ATOM [, STAT])}
2336
2337 @item @emph{Arguments}:
2338 @multitable @columnfractions .15 .70
2339 @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind
2340 is different, the value is converted to the kind of @var{ATOM}.
2341 @item @var{ATOM} @tab Scalar coarray or coindexed variable of either integer
2342 type with @code{ATOMIC_INT_KIND} kind or logical type with
2343 @code{ATOMIC_LOGICAL_KIND} kind.
2344 @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
2345 @end multitable
2346
2347 @item @emph{Example}:
2348 @smallexample
2349 program atomic
2350 use iso_fortran_env
2351 logical(atomic_logical_kind) :: atom[*]
2352 logical :: val
2353 call atomic_ref (atom, .false.)
2354 ! ...
2355 call atomic_ref (atom, val)
2356 if (val) then
2357 print *, "Obtained"
2358 end if
2359 end program atomic
2360 @end smallexample
2361
2362 @item @emph{See also}:
2363 @ref{ATOMIC_DEFINE}, @ref{ATOMIC_CAS}, @ref{ISO_FORTRAN_ENV},
2364 @ref{ATOMIC_FETCH_ADD}, @ref{ATOMIC_FETCH_AND}, @ref{ATOMIC_FETCH_OR},
2365 @ref{ATOMIC_FETCH_XOR}
2366 @end table
2367
2368
2369 @node ATOMIC_XOR
2370 @section @code{ATOMIC_XOR} --- Atomic bitwise OR operation
2371 @fnindex ATOMIC_XOR
2372 @cindex Atomic subroutine, XOR
2373
2374 @table @asis
2375 @item @emph{Description}:
2376 @code{ATOMIC_AND(ATOM, VALUE)} atomically defines @var{ATOM} with the bitwise
2377 XOR between the values of @var{ATOM} and @var{VALUE}. When @var{STAT} is present
2378 and the invocation was successful, it is assigned the value 0. If it is present
2379 and the invocation has failed, it is assigned a positive value; in particular,
2380 for a coindexed @var{ATOM}, if the remote image has stopped, it is assigned the
2381 value of @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote
2382 image has failed, the value @code{STAT_FAILED_IMAGE}.
2383
2384 @item @emph{Standard}:
2385 TS 18508 or later
2386
2387 @item @emph{Class}:
2388 Atomic subroutine
2389
2390 @item @emph{Syntax}:
2391 @code{CALL ATOMIC_XOR (ATOM, VALUE [, STAT])}
2392
2393 @item @emph{Arguments}:
2394 @multitable @columnfractions .15 .70
2395 @item @var{ATOM} @tab Scalar coarray or coindexed variable of integer
2396 type with @code{ATOMIC_INT_KIND} kind.
2397 @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind
2398 is different, the value is converted to the kind of @var{ATOM}.
2399 @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
2400 @end multitable
2401
2402 @item @emph{Example}:
2403 @smallexample
2404 program atomic
2405 use iso_fortran_env
2406 integer(atomic_int_kind) :: atom[*]
2407 call atomic_xor (atom[1], int(b'10100011101'))
2408 end program atomic
2409 @end smallexample
2410
2411 @item @emph{See also}:
2412 @ref{ATOMIC_DEFINE}, @ref{ATOMIC_FETCH_XOR}, @ref{ISO_FORTRAN_ENV},
2413 @ref{ATOMIC_ADD}, @ref{ATOMIC_OR}, @ref{ATOMIC_XOR}
2414 @end table
2415
2416
2417 @node BACKTRACE
2418 @section @code{BACKTRACE} --- Show a backtrace
2419 @fnindex BACKTRACE
2420 @cindex backtrace
2421
2422 @table @asis
2423 @item @emph{Description}:
2424 @code{BACKTRACE} shows a backtrace at an arbitrary place in user code. Program
2425 execution continues normally afterwards. The backtrace information is printed
2426 to the unit corresponding to @code{ERROR_UNIT} in @code{ISO_FORTRAN_ENV}.
2427
2428 @item @emph{Standard}:
2429 GNU Extension
2430
2431 @item @emph{Class}:
2432 Subroutine
2433
2434 @item @emph{Syntax}:
2435 @code{CALL BACKTRACE}
2436
2437 @item @emph{Arguments}:
2438 None
2439
2440 @item @emph{See also}:
2441 @ref{ABORT}
2442 @end table
2443
2444
2445
2446 @node BESSEL_J0
2447 @section @code{BESSEL_J0} --- Bessel function of the first kind of order 0
2448 @fnindex BESSEL_J0
2449 @fnindex BESJ0
2450 @fnindex DBESJ0
2451 @cindex Bessel function, first kind
2452
2453 @table @asis
2454 @item @emph{Description}:
2455 @code{BESSEL_J0(X)} computes the Bessel function of the first kind of
2456 order 0 of @var{X}. This function is available under the name
2457 @code{BESJ0} as a GNU extension.
2458
2459 @item @emph{Standard}:
2460 Fortran 2008 and later
2461
2462 @item @emph{Class}:
2463 Elemental function
2464
2465 @item @emph{Syntax}:
2466 @code{RESULT = BESSEL_J0(X)}
2467
2468 @item @emph{Arguments}:
2469 @multitable @columnfractions .15 .70
2470 @item @var{X} @tab The type shall be @code{REAL}.
2471 @end multitable
2472
2473 @item @emph{Return value}:
2474 The return value is of type @code{REAL} and lies in the
2475 range @math{ - 0.4027... \leq Bessel (0,x) \leq 1}. It has the same
2476 kind as @var{X}.
2477
2478 @item @emph{Example}:
2479 @smallexample
2480 program test_besj0
2481 real(8) :: x = 0.0_8
2482 x = bessel_j0(x)
2483 end program test_besj0
2484 @end smallexample
2485
2486 @item @emph{Specific names}:
2487 @multitable @columnfractions .20 .20 .20 .25
2488 @item Name @tab Argument @tab Return type @tab Standard
2489 @item @code{DBESJ0(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
2490 @end multitable
2491 @end table
2492
2493
2494
2495 @node BESSEL_J1
2496 @section @code{BESSEL_J1} --- Bessel function of the first kind of order 1
2497 @fnindex BESSEL_J1
2498 @fnindex BESJ1
2499 @fnindex DBESJ1
2500 @cindex Bessel function, first kind
2501
2502 @table @asis
2503 @item @emph{Description}:
2504 @code{BESSEL_J1(X)} computes the Bessel function of the first kind of
2505 order 1 of @var{X}. This function is available under the name
2506 @code{BESJ1} as a GNU extension.
2507
2508 @item @emph{Standard}:
2509 Fortran 2008
2510
2511 @item @emph{Class}:
2512 Elemental function
2513
2514 @item @emph{Syntax}:
2515 @code{RESULT = BESSEL_J1(X)}
2516
2517 @item @emph{Arguments}:
2518 @multitable @columnfractions .15 .70
2519 @item @var{X} @tab The type shall be @code{REAL}.
2520 @end multitable
2521
2522 @item @emph{Return value}:
2523 The return value is of type @code{REAL} and lies in the
2524 range @math{ - 0.5818... \leq Bessel (0,x) \leq 0.5818 }. It has the same
2525 kind as @var{X}.
2526
2527 @item @emph{Example}:
2528 @smallexample
2529 program test_besj1
2530 real(8) :: x = 1.0_8
2531 x = bessel_j1(x)
2532 end program test_besj1
2533 @end smallexample
2534
2535 @item @emph{Specific names}:
2536 @multitable @columnfractions .20 .20 .20 .25
2537 @item Name @tab Argument @tab Return type @tab Standard
2538 @item @code{DBESJ1(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
2539 @end multitable
2540 @end table
2541
2542
2543
2544 @node BESSEL_JN
2545 @section @code{BESSEL_JN} --- Bessel function of the first kind
2546 @fnindex BESSEL_JN
2547 @fnindex BESJN
2548 @fnindex DBESJN
2549 @cindex Bessel function, first kind
2550
2551 @table @asis
2552 @item @emph{Description}:
2553 @code{BESSEL_JN(N, X)} computes the Bessel function of the first kind of
2554 order @var{N} of @var{X}. This function is available under the name
2555 @code{BESJN} as a GNU extension. If @var{N} and @var{X} are arrays,
2556 their ranks and shapes shall conform.
2557
2558 @code{BESSEL_JN(N1, N2, X)} returns an array with the Bessel functions
2559 of the first kind of the orders @var{N1} to @var{N2}.
2560
2561 @item @emph{Standard}:
2562 Fortran 2008 and later, negative @var{N} is allowed as GNU extension
2563
2564 @item @emph{Class}:
2565 Elemental function, except for the transformational function
2566 @code{BESSEL_JN(N1, N2, X)}
2567
2568 @item @emph{Syntax}:
2569 @multitable @columnfractions .80
2570 @item @code{RESULT = BESSEL_JN(N, X)}
2571 @item @code{RESULT = BESSEL_JN(N1, N2, X)}
2572 @end multitable
2573
2574 @item @emph{Arguments}:
2575 @multitable @columnfractions .15 .70
2576 @item @var{N} @tab Shall be a scalar or an array of type @code{INTEGER}.
2577 @item @var{N1} @tab Shall be a non-negative scalar of type @code{INTEGER}.
2578 @item @var{N2} @tab Shall be a non-negative scalar of type @code{INTEGER}.
2579 @item @var{X} @tab Shall be a scalar or an array of type @code{REAL};
2580 for @code{BESSEL_JN(N1, N2, X)} it shall be scalar.
2581 @end multitable
2582
2583 @item @emph{Return value}:
2584 The return value is a scalar of type @code{REAL}. It has the same
2585 kind as @var{X}.
2586
2587 @item @emph{Note}:
2588 The transformational function uses a recurrence algorithm which might,
2589 for some values of @var{X}, lead to different results than calls to
2590 the elemental function.
2591
2592 @item @emph{Example}:
2593 @smallexample
2594 program test_besjn
2595 real(8) :: x = 1.0_8
2596 x = bessel_jn(5,x)
2597 end program test_besjn
2598 @end smallexample
2599
2600 @item @emph{Specific names}:
2601 @multitable @columnfractions .20 .20 .20 .25
2602 @item Name @tab Argument @tab Return type @tab Standard
2603 @item @code{DBESJN(N, X)} @tab @code{INTEGER N} @tab @code{REAL(8)} @tab GNU extension
2604 @item @tab @code{REAL(8) X} @tab @tab
2605 @end multitable
2606 @end table
2607
2608
2609
2610 @node BESSEL_Y0
2611 @section @code{BESSEL_Y0} --- Bessel function of the second kind of order 0
2612 @fnindex BESSEL_Y0
2613 @fnindex BESY0
2614 @fnindex DBESY0
2615 @cindex Bessel function, second kind
2616
2617 @table @asis
2618 @item @emph{Description}:
2619 @code{BESSEL_Y0(X)} computes the Bessel function of the second kind of
2620 order 0 of @var{X}. This function is available under the name
2621 @code{BESY0} as a GNU extension.
2622
2623 @item @emph{Standard}:
2624 Fortran 2008 and later
2625
2626 @item @emph{Class}:
2627 Elemental function
2628
2629 @item @emph{Syntax}:
2630 @code{RESULT = BESSEL_Y0(X)}
2631
2632 @item @emph{Arguments}:
2633 @multitable @columnfractions .15 .70
2634 @item @var{X} @tab The type shall be @code{REAL}.
2635 @end multitable
2636
2637 @item @emph{Return value}:
2638 The return value is of type @code{REAL}. It has the same kind as @var{X}.
2639
2640 @item @emph{Example}:
2641 @smallexample
2642 program test_besy0
2643 real(8) :: x = 0.0_8
2644 x = bessel_y0(x)
2645 end program test_besy0
2646 @end smallexample
2647
2648 @item @emph{Specific names}:
2649 @multitable @columnfractions .20 .20 .20 .25
2650 @item Name @tab Argument @tab Return type @tab Standard
2651 @item @code{DBESY0(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
2652 @end multitable
2653 @end table
2654
2655
2656
2657 @node BESSEL_Y1
2658 @section @code{BESSEL_Y1} --- Bessel function of the second kind of order 1
2659 @fnindex BESSEL_Y1
2660 @fnindex BESY1
2661 @fnindex DBESY1
2662 @cindex Bessel function, second kind
2663
2664 @table @asis
2665 @item @emph{Description}:
2666 @code{BESSEL_Y1(X)} computes the Bessel function of the second kind of
2667 order 1 of @var{X}. This function is available under the name
2668 @code{BESY1} as a GNU extension.
2669
2670 @item @emph{Standard}:
2671 Fortran 2008 and later
2672
2673 @item @emph{Class}:
2674 Elemental function
2675
2676 @item @emph{Syntax}:
2677 @code{RESULT = BESSEL_Y1(X)}
2678
2679 @item @emph{Arguments}:
2680 @multitable @columnfractions .15 .70
2681 @item @var{X} @tab The type shall be @code{REAL}.
2682 @end multitable
2683
2684 @item @emph{Return value}:
2685 The return value is of type @code{REAL}. It has the same kind as @var{X}.
2686
2687 @item @emph{Example}:
2688 @smallexample
2689 program test_besy1
2690 real(8) :: x = 1.0_8
2691 x = bessel_y1(x)
2692 end program test_besy1
2693 @end smallexample
2694
2695 @item @emph{Specific names}:
2696 @multitable @columnfractions .20 .20 .20 .25
2697 @item Name @tab Argument @tab Return type @tab Standard
2698 @item @code{DBESY1(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
2699 @end multitable
2700 @end table
2701
2702
2703
2704 @node BESSEL_YN
2705 @section @code{BESSEL_YN} --- Bessel function of the second kind
2706 @fnindex BESSEL_YN
2707 @fnindex BESYN
2708 @fnindex DBESYN
2709 @cindex Bessel function, second kind
2710
2711 @table @asis
2712 @item @emph{Description}:
2713 @code{BESSEL_YN(N, X)} computes the Bessel function of the second kind of
2714 order @var{N} of @var{X}. This function is available under the name
2715 @code{BESYN} as a GNU extension. If @var{N} and @var{X} are arrays,
2716 their ranks and shapes shall conform.
2717
2718 @code{BESSEL_YN(N1, N2, X)} returns an array with the Bessel functions
2719 of the first kind of the orders @var{N1} to @var{N2}.
2720
2721 @item @emph{Standard}:
2722 Fortran 2008 and later, negative @var{N} is allowed as GNU extension
2723
2724 @item @emph{Class}:
2725 Elemental function, except for the transformational function
2726 @code{BESSEL_YN(N1, N2, X)}
2727
2728 @item @emph{Syntax}:
2729 @multitable @columnfractions .80
2730 @item @code{RESULT = BESSEL_YN(N, X)}
2731 @item @code{RESULT = BESSEL_YN(N1, N2, X)}
2732 @end multitable
2733
2734 @item @emph{Arguments}:
2735 @multitable @columnfractions .15 .70
2736 @item @var{N} @tab Shall be a scalar or an array of type @code{INTEGER} .
2737 @item @var{N1} @tab Shall be a non-negative scalar of type @code{INTEGER}.
2738 @item @var{N2} @tab Shall be a non-negative scalar of type @code{INTEGER}.
2739 @item @var{X} @tab Shall be a scalar or an array of type @code{REAL};
2740 for @code{BESSEL_YN(N1, N2, X)} it shall be scalar.
2741 @end multitable
2742
2743 @item @emph{Return value}:
2744 The return value is a scalar of type @code{REAL}. It has the same
2745 kind as @var{X}.
2746
2747 @item @emph{Note}:
2748 The transformational function uses a recurrence algorithm which might,
2749 for some values of @var{X}, lead to different results than calls to
2750 the elemental function.
2751
2752 @item @emph{Example}:
2753 @smallexample
2754 program test_besyn
2755 real(8) :: x = 1.0_8
2756 x = bessel_yn(5,x)
2757 end program test_besyn
2758 @end smallexample
2759
2760 @item @emph{Specific names}:
2761 @multitable @columnfractions .20 .20 .20 .25
2762 @item Name @tab Argument @tab Return type @tab Standard
2763 @item @code{DBESYN(N,X)} @tab @code{INTEGER N} @tab @code{REAL(8)} @tab GNU extension
2764 @item @tab @code{REAL(8) X} @tab @tab
2765 @end multitable
2766 @end table
2767
2768
2769
2770 @node BGE
2771 @section @code{BGE} --- Bitwise greater than or equal to
2772 @fnindex BGE
2773 @cindex bitwise comparison
2774
2775 @table @asis
2776 @item @emph{Description}:
2777 Determines whether an integral is a bitwise greater than or equal to
2778 another.
2779
2780 @item @emph{Standard}:
2781 Fortran 2008 and later
2782
2783 @item @emph{Class}:
2784 Elemental function
2785
2786 @item @emph{Syntax}:
2787 @code{RESULT = BGE(I, J)}
2788
2789 @item @emph{Arguments}:
2790 @multitable @columnfractions .15 .70
2791 @item @var{I} @tab Shall be of @code{INTEGER} type.
2792 @item @var{J} @tab Shall be of @code{INTEGER} type, and of the same kind
2793 as @var{I}.
2794 @end multitable
2795
2796 @item @emph{Return value}:
2797 The return value is of type @code{LOGICAL} and of the default kind.
2798
2799 @item @emph{See also}:
2800 @ref{BGT}, @ref{BLE}, @ref{BLT}
2801 @end table
2802
2803
2804
2805 @node BGT
2806 @section @code{BGT} --- Bitwise greater than
2807 @fnindex BGT
2808 @cindex bitwise comparison
2809
2810 @table @asis
2811 @item @emph{Description}:
2812 Determines whether an integral is a bitwise greater than another.
2813
2814 @item @emph{Standard}:
2815 Fortran 2008 and later
2816
2817 @item @emph{Class}:
2818 Elemental function
2819
2820 @item @emph{Syntax}:
2821 @code{RESULT = BGT(I, J)}
2822
2823 @item @emph{Arguments}:
2824 @multitable @columnfractions .15 .70
2825 @item @var{I} @tab Shall be of @code{INTEGER} type.
2826 @item @var{J} @tab Shall be of @code{INTEGER} type, and of the same kind
2827 as @var{I}.
2828 @end multitable
2829
2830 @item @emph{Return value}:
2831 The return value is of type @code{LOGICAL} and of the default kind.
2832
2833 @item @emph{See also}:
2834 @ref{BGE}, @ref{BLE}, @ref{BLT}
2835 @end table
2836
2837
2838
2839 @node BIT_SIZE
2840 @section @code{BIT_SIZE} --- Bit size inquiry function
2841 @fnindex BIT_SIZE
2842 @cindex bits, number of
2843 @cindex size of a variable, in bits
2844
2845 @table @asis
2846 @item @emph{Description}:
2847 @code{BIT_SIZE(I)} returns the number of bits (integer precision plus sign bit)
2848 represented by the type of @var{I}. The result of @code{BIT_SIZE(I)} is
2849 independent of the actual value of @var{I}.
2850
2851 @item @emph{Standard}:
2852 Fortran 95 and later
2853
2854 @item @emph{Class}:
2855 Inquiry function
2856
2857 @item @emph{Syntax}:
2858 @code{RESULT = BIT_SIZE(I)}
2859
2860 @item @emph{Arguments}:
2861 @multitable @columnfractions .15 .70
2862 @item @var{I} @tab The type shall be @code{INTEGER}.
2863 @end multitable
2864
2865 @item @emph{Return value}:
2866 The return value is of type @code{INTEGER}
2867
2868 @item @emph{Example}:
2869 @smallexample
2870 program test_bit_size
2871 integer :: i = 123
2872 integer :: size
2873 size = bit_size(i)
2874 print *, size
2875 end program test_bit_size
2876 @end smallexample
2877 @end table
2878
2879
2880
2881 @node BLE
2882 @section @code{BLE} --- Bitwise less than or equal to
2883 @fnindex BLE
2884 @cindex bitwise comparison
2885
2886 @table @asis
2887 @item @emph{Description}:
2888 Determines whether an integral is a bitwise less than or equal to
2889 another.
2890
2891 @item @emph{Standard}:
2892 Fortran 2008 and later
2893
2894 @item @emph{Class}:
2895 Elemental function
2896
2897 @item @emph{Syntax}:
2898 @code{RESULT = BLE(I, J)}
2899
2900 @item @emph{Arguments}:
2901 @multitable @columnfractions .15 .70
2902 @item @var{I} @tab Shall be of @code{INTEGER} type.
2903 @item @var{J} @tab Shall be of @code{INTEGER} type, and of the same kind
2904 as @var{I}.
2905 @end multitable
2906
2907 @item @emph{Return value}:
2908 The return value is of type @code{LOGICAL} and of the default kind.
2909
2910 @item @emph{See also}:
2911 @ref{BGT}, @ref{BGE}, @ref{BLT}
2912 @end table
2913
2914
2915
2916 @node BLT
2917 @section @code{BLT} --- Bitwise less than
2918 @fnindex BLT
2919 @cindex bitwise comparison
2920
2921 @table @asis
2922 @item @emph{Description}:
2923 Determines whether an integral is a bitwise less than another.
2924
2925 @item @emph{Standard}:
2926 Fortran 2008 and later
2927
2928 @item @emph{Class}:
2929 Elemental function
2930
2931 @item @emph{Syntax}:
2932 @code{RESULT = BLT(I, J)}
2933
2934 @item @emph{Arguments}:
2935 @multitable @columnfractions .15 .70
2936 @item @var{I} @tab Shall be of @code{INTEGER} type.
2937 @item @var{J} @tab Shall be of @code{INTEGER} type, and of the same kind
2938 as @var{I}.
2939 @end multitable
2940
2941 @item @emph{Return value}:
2942 The return value is of type @code{LOGICAL} and of the default kind.
2943
2944 @item @emph{See also}:
2945 @ref{BGE}, @ref{BGT}, @ref{BLE}
2946 @end table
2947
2948
2949
2950 @node BTEST
2951 @section @code{BTEST} --- Bit test function
2952 @fnindex BTEST
2953 @fnindex BBTEST
2954 @fnindex BITEST
2955 @fnindex BJTEST
2956 @fnindex BKTEST
2957 @cindex bits, testing
2958
2959 @table @asis
2960 @item @emph{Description}:
2961 @code{BTEST(I,POS)} returns logical @code{.TRUE.} if the bit at @var{POS}
2962 in @var{I} is set. The counting of the bits starts at 0.
2963
2964 @item @emph{Standard}:
2965 Fortran 95 and later, has overloads that are GNU extensions
2966
2967 @item @emph{Class}:
2968 Elemental function
2969
2970 @item @emph{Syntax}:
2971 @code{RESULT = BTEST(I, POS)}
2972
2973 @item @emph{Arguments}:
2974 @multitable @columnfractions .15 .70
2975 @item @var{I} @tab The type shall be @code{INTEGER}.
2976 @item @var{POS} @tab The type shall be @code{INTEGER}.
2977 @end multitable
2978
2979 @item @emph{Return value}:
2980 The return value is of type @code{LOGICAL}
2981
2982 @item @emph{Example}:
2983 @smallexample
2984 program test_btest
2985 integer :: i = 32768 + 1024 + 64
2986 integer :: pos
2987 logical :: bool
2988 do pos=0,16
2989 bool = btest(i, pos)
2990 print *, pos, bool
2991 end do
2992 end program test_btest
2993 @end smallexample
2994
2995 @item @emph{Specific names}:
2996 @multitable @columnfractions .20 .20 .20 .25
2997 @item Name @tab Argument @tab Return type @tab Standard
2998 @item @code{BTEST(I,POS)} @tab @code{INTEGER I,POS} @tab @code{LOGICAL} @tab F95 and later
2999 @item @code{BBTEST(I,POS)} @tab @code{INTEGER(1) I,POS} @tab @code{LOGICAL(1)} @tab GNU extension
3000 @item @code{BITEST(I,POS)} @tab @code{INTEGER(2) I,POS} @tab @code{LOGICAL(2)} @tab GNU extension
3001 @item @code{BJTEST(I,POS)} @tab @code{INTEGER(4) I,POS} @tab @code{LOGICAL(4)} @tab GNU extension
3002 @item @code{BKTEST(I,POS)} @tab @code{INTEGER(8) I,POS} @tab @code{LOGICAL(8)} @tab GNU extension
3003 @end multitable
3004 @end table
3005
3006 @node C_ASSOCIATED
3007 @section @code{C_ASSOCIATED} --- Status of a C pointer
3008 @fnindex C_ASSOCIATED
3009 @cindex association status, C pointer
3010 @cindex pointer, C association status
3011
3012 @table @asis
3013 @item @emph{Description}:
3014 @code{C_ASSOCIATED(c_ptr_1[, c_ptr_2])} determines the status of the C pointer
3015 @var{c_ptr_1} or if @var{c_ptr_1} is associated with the target @var{c_ptr_2}.
3016
3017 @item @emph{Standard}:
3018 Fortran 2003 and later
3019
3020 @item @emph{Class}:
3021 Inquiry function
3022
3023 @item @emph{Syntax}:
3024 @code{RESULT = C_ASSOCIATED(c_ptr_1[, c_ptr_2])}
3025
3026 @item @emph{Arguments}:
3027 @multitable @columnfractions .15 .70
3028 @item @var{c_ptr_1} @tab Scalar of the type @code{C_PTR} or @code{C_FUNPTR}.
3029 @item @var{c_ptr_2} @tab (Optional) Scalar of the same type as @var{c_ptr_1}.
3030 @end multitable
3031
3032 @item @emph{Return value}:
3033 The return value is of type @code{LOGICAL}; it is @code{.false.} if either
3034 @var{c_ptr_1} is a C NULL pointer or if @var{c_ptr1} and @var{c_ptr_2}
3035 point to different addresses.
3036
3037 @item @emph{Example}:
3038 @smallexample
3039 subroutine association_test(a,b)
3040 use iso_c_binding, only: c_associated, c_loc, c_ptr
3041 implicit none
3042 real, pointer :: a
3043 type(c_ptr) :: b
3044 if(c_associated(b, c_loc(a))) &
3045 stop 'b and a do not point to same target'
3046 end subroutine association_test
3047 @end smallexample
3048
3049 @item @emph{See also}:
3050 @ref{C_LOC}, @ref{C_FUNLOC}
3051 @end table
3052
3053
3054 @node C_F_POINTER
3055 @section @code{C_F_POINTER} --- Convert C into Fortran pointer
3056 @fnindex C_F_POINTER
3057 @cindex pointer, convert C to Fortran
3058
3059 @table @asis
3060 @item @emph{Description}:
3061 @code{C_F_POINTER(CPTR, FPTR[, SHAPE])} assigns the target of the C pointer
3062 @var{CPTR} to the Fortran pointer @var{FPTR} and specifies its shape.
3063
3064 @item @emph{Standard}:
3065 Fortran 2003 and later
3066
3067 @item @emph{Class}:
3068 Subroutine
3069
3070 @item @emph{Syntax}:
3071 @code{CALL C_F_POINTER(CPTR, FPTR[, SHAPE])}
3072
3073 @item @emph{Arguments}:
3074 @multitable @columnfractions .15 .70
3075 @item @var{CPTR} @tab scalar of the type @code{C_PTR}. It is
3076 @code{INTENT(IN)}.
3077 @item @var{FPTR} @tab pointer interoperable with @var{cptr}. It is
3078 @code{INTENT(OUT)}.
3079 @item @var{SHAPE} @tab (Optional) Rank-one array of type @code{INTEGER}
3080 with @code{INTENT(IN)}. It shall be present
3081 if and only if @var{fptr} is an array. The size
3082 must be equal to the rank of @var{fptr}.
3083 @end multitable
3084
3085 @item @emph{Example}:
3086 @smallexample
3087 program main
3088 use iso_c_binding
3089 implicit none
3090 interface
3091 subroutine my_routine(p) bind(c,name='myC_func')
3092 import :: c_ptr
3093 type(c_ptr), intent(out) :: p
3094 end subroutine
3095 end interface
3096 type(c_ptr) :: cptr
3097 real,pointer :: a(:)
3098 call my_routine(cptr)
3099 call c_f_pointer(cptr, a, [12])
3100 end program main
3101 @end smallexample
3102
3103 @item @emph{See also}:
3104 @ref{C_LOC}, @ref{C_F_PROCPOINTER}
3105 @end table
3106
3107
3108 @node C_F_PROCPOINTER
3109 @section @code{C_F_PROCPOINTER} --- Convert C into Fortran procedure pointer
3110 @fnindex C_F_PROCPOINTER
3111 @cindex pointer, C address of pointers
3112
3113 @table @asis
3114 @item @emph{Description}:
3115 @code{C_F_PROCPOINTER(CPTR, FPTR)} Assign the target of the C function pointer
3116 @var{CPTR} to the Fortran procedure pointer @var{FPTR}.
3117
3118 @item @emph{Standard}:
3119 Fortran 2003 and later
3120
3121 @item @emph{Class}:
3122 Subroutine
3123
3124 @item @emph{Syntax}:
3125 @code{CALL C_F_PROCPOINTER(cptr, fptr)}
3126
3127 @item @emph{Arguments}:
3128 @multitable @columnfractions .15 .70
3129 @item @var{CPTR} @tab scalar of the type @code{C_FUNPTR}. It is
3130 @code{INTENT(IN)}.
3131 @item @var{FPTR} @tab procedure pointer interoperable with @var{cptr}. It is
3132 @code{INTENT(OUT)}.
3133 @end multitable
3134
3135 @item @emph{Example}:
3136 @smallexample
3137 program main
3138 use iso_c_binding
3139 implicit none
3140 abstract interface
3141 function func(a)
3142 import :: c_float
3143 real(c_float), intent(in) :: a
3144 real(c_float) :: func
3145 end function
3146 end interface
3147 interface
3148 function getIterFunc() bind(c,name="getIterFunc")
3149 import :: c_funptr
3150 type(c_funptr) :: getIterFunc
3151 end function
3152 end interface
3153 type(c_funptr) :: cfunptr
3154 procedure(func), pointer :: myFunc
3155 cfunptr = getIterFunc()
3156 call c_f_procpointer(cfunptr, myFunc)
3157 end program main
3158 @end smallexample
3159
3160 @item @emph{See also}:
3161 @ref{C_LOC}, @ref{C_F_POINTER}
3162 @end table
3163
3164
3165 @node C_FUNLOC
3166 @section @code{C_FUNLOC} --- Obtain the C address of a procedure
3167 @fnindex C_FUNLOC
3168 @cindex pointer, C address of procedures
3169
3170 @table @asis
3171 @item @emph{Description}:
3172 @code{C_FUNLOC(x)} determines the C address of the argument.
3173
3174 @item @emph{Standard}:
3175 Fortran 2003 and later
3176
3177 @item @emph{Class}:
3178 Inquiry function
3179
3180 @item @emph{Syntax}:
3181 @code{RESULT = C_FUNLOC(x)}
3182
3183 @item @emph{Arguments}:
3184 @multitable @columnfractions .15 .70
3185 @item @var{x} @tab Interoperable function or pointer to such function.
3186 @end multitable
3187
3188 @item @emph{Return value}:
3189 The return value is of type @code{C_FUNPTR} and contains the C address
3190 of the argument.
3191
3192 @item @emph{Example}:
3193 @smallexample
3194 module x
3195 use iso_c_binding
3196 implicit none
3197 contains
3198 subroutine sub(a) bind(c)
3199 real(c_float) :: a
3200 a = sqrt(a)+5.0
3201 end subroutine sub
3202 end module x
3203 program main
3204 use iso_c_binding
3205 use x
3206 implicit none
3207 interface
3208 subroutine my_routine(p) bind(c,name='myC_func')
3209 import :: c_funptr
3210 type(c_funptr), intent(in) :: p
3211 end subroutine
3212 end interface
3213 call my_routine(c_funloc(sub))
3214 end program main
3215 @end smallexample
3216
3217 @item @emph{See also}:
3218 @ref{C_ASSOCIATED}, @ref{C_LOC}, @ref{C_F_POINTER}, @ref{C_F_PROCPOINTER}
3219 @end table
3220
3221
3222 @node C_LOC
3223 @section @code{C_LOC} --- Obtain the C address of an object
3224 @fnindex C_LOC
3225 @cindex procedure pointer, convert C to Fortran
3226
3227 @table @asis
3228 @item @emph{Description}:
3229 @code{C_LOC(X)} determines the C address of the argument.
3230
3231 @item @emph{Standard}:
3232 Fortran 2003 and later
3233
3234 @item @emph{Class}:
3235 Inquiry function
3236
3237 @item @emph{Syntax}:
3238 @code{RESULT = C_LOC(X)}
3239
3240 @item @emph{Arguments}:
3241 @multitable @columnfractions .10 .75
3242 @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.
3243
3244 @end multitable
3245
3246 @item @emph{Return value}:
3247 The return value is of type @code{C_PTR} and contains the C address
3248 of the argument.
3249
3250 @item @emph{Example}:
3251 @smallexample
3252 subroutine association_test(a,b)
3253 use iso_c_binding, only: c_associated, c_loc, c_ptr
3254 implicit none
3255 real, pointer :: a
3256 type(c_ptr) :: b
3257 if(c_associated(b, c_loc(a))) &
3258 stop 'b and a do not point to same target'
3259 end subroutine association_test
3260 @end smallexample
3261
3262 @item @emph{See also}:
3263 @ref{C_ASSOCIATED}, @ref{C_FUNLOC}, @ref{C_F_POINTER}, @ref{C_F_PROCPOINTER}
3264 @end table
3265
3266
3267 @node C_SIZEOF
3268 @section @code{C_SIZEOF} --- Size in bytes of an expression
3269 @fnindex C_SIZEOF
3270 @cindex expression size
3271 @cindex size of an expression
3272
3273 @table @asis
3274 @item @emph{Description}:
3275 @code{C_SIZEOF(X)} calculates the number of bytes of storage the
3276 expression @code{X} occupies.
3277
3278 @item @emph{Standard}:
3279 Fortran 2008
3280
3281 @item @emph{Class}:
3282 Inquiry function of the module @code{ISO_C_BINDING}
3283
3284 @item @emph{Syntax}:
3285 @code{N = C_SIZEOF(X)}
3286
3287 @item @emph{Arguments}:
3288 @multitable @columnfractions .15 .70
3289 @item @var{X} @tab The argument shall be an interoperable data entity.
3290 @end multitable
3291
3292 @item @emph{Return value}:
3293 The return value is of type integer and of the system-dependent kind
3294 @code{C_SIZE_T} (from the @code{ISO_C_BINDING} module). Its value is the
3295 number of bytes occupied by the argument. If the argument has the
3296 @code{POINTER} attribute, the number of bytes of the storage area pointed
3297 to is returned. If the argument is of a derived type with @code{POINTER}
3298 or @code{ALLOCATABLE} components, the return value does not account for
3299 the sizes of the data pointed to by these components.
3300
3301 @item @emph{Example}:
3302 @smallexample
3303 use iso_c_binding
3304 integer(c_int) :: i
3305 real(c_float) :: r, s(5)
3306 print *, (c_sizeof(s)/c_sizeof(r) == 5)
3307 end
3308 @end smallexample
3309 The example will print @code{.TRUE.} unless you are using a platform
3310 where default @code{REAL} variables are unusually padded.
3311
3312 @item @emph{See also}:
3313 @ref{SIZEOF}, @ref{STORAGE_SIZE}
3314 @end table
3315
3316
3317 @node CEILING
3318 @section @code{CEILING} --- Integer ceiling function
3319 @fnindex CEILING
3320 @cindex ceiling
3321 @cindex rounding, ceiling
3322
3323 @table @asis
3324 @item @emph{Description}:
3325 @code{CEILING(A)} returns the least integer greater than or equal to @var{A}.
3326
3327 @item @emph{Standard}:
3328 Fortran 95 and later
3329
3330 @item @emph{Class}:
3331 Elemental function
3332
3333 @item @emph{Syntax}:
3334 @code{RESULT = CEILING(A [, KIND])}
3335
3336 @item @emph{Arguments}:
3337 @multitable @columnfractions .15 .70
3338 @item @var{A} @tab The type shall be @code{REAL}.
3339 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
3340 expression indicating the kind parameter of the result.
3341 @end multitable
3342
3343 @item @emph{Return value}:
3344 The return value is of type @code{INTEGER(KIND)} if @var{KIND} is present
3345 and a default-kind @code{INTEGER} otherwise.
3346
3347 @item @emph{Example}:
3348 @smallexample
3349 program test_ceiling
3350 real :: x = 63.29
3351 real :: y = -63.59
3352 print *, ceiling(x) ! returns 64
3353 print *, ceiling(y) ! returns -63
3354 end program test_ceiling
3355 @end smallexample
3356
3357 @item @emph{See also}:
3358 @ref{FLOOR}, @ref{NINT}
3359
3360 @end table
3361
3362
3363
3364 @node CHAR
3365 @section @code{CHAR} --- Character conversion function
3366 @fnindex CHAR
3367 @cindex conversion, to character
3368
3369 @table @asis
3370 @item @emph{Description}:
3371 @code{CHAR(I [, KIND])} returns the character represented by the integer @var{I}.
3372
3373 @item @emph{Standard}:
3374 Fortran 77 and later
3375
3376 @item @emph{Class}:
3377 Elemental function
3378
3379 @item @emph{Syntax}:
3380 @code{RESULT = CHAR(I [, KIND])}
3381
3382 @item @emph{Arguments}:
3383 @multitable @columnfractions .15 .70
3384 @item @var{I} @tab The type shall be @code{INTEGER}.
3385 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
3386 expression indicating the kind parameter of the result.
3387 @end multitable
3388
3389 @item @emph{Return value}:
3390 The return value is of type @code{CHARACTER(1)}
3391
3392 @item @emph{Example}:
3393 @smallexample
3394 program test_char
3395 integer :: i = 74
3396 character(1) :: c
3397 c = char(i)
3398 print *, i, c ! returns 'J'
3399 end program test_char
3400 @end smallexample
3401
3402 @item @emph{Specific names}:
3403 @multitable @columnfractions .20 .20 .20 .25
3404 @item Name @tab Argument @tab Return type @tab Standard
3405 @item @code{CHAR(I)} @tab @code{INTEGER I} @tab @code{CHARACTER(LEN=1)} @tab F77 and later
3406 @end multitable
3407
3408 @item @emph{Note}:
3409 See @ref{ICHAR} for a discussion of converting between numerical values
3410 and formatted string representations.
3411
3412 @item @emph{See also}:
3413 @ref{ACHAR}, @ref{IACHAR}, @ref{ICHAR}
3414
3415 @end table
3416
3417
3418
3419 @node CHDIR
3420 @section @code{CHDIR} --- Change working directory
3421 @fnindex CHDIR
3422 @cindex system, working directory
3423
3424 @table @asis
3425 @item @emph{Description}:
3426 Change current working directory to a specified path.
3427
3428 This intrinsic is provided in both subroutine and function forms; however,
3429 only one form can be used in any given program unit.
3430
3431 @item @emph{Standard}:
3432 GNU extension
3433
3434 @item @emph{Class}:
3435 Subroutine, function
3436
3437 @item @emph{Syntax}:
3438 @multitable @columnfractions .80
3439 @item @code{CALL CHDIR(NAME [, STATUS])}
3440 @item @code{STATUS = CHDIR(NAME)}
3441 @end multitable
3442
3443 @item @emph{Arguments}:
3444 @multitable @columnfractions .15 .70
3445 @item @var{NAME} @tab The type shall be @code{CHARACTER} of default
3446 kind and shall specify a valid path within the file system.
3447 @item @var{STATUS} @tab (Optional) @code{INTEGER} status flag of the default
3448 kind. Returns 0 on success, and a system specific and nonzero error code
3449 otherwise.
3450 @end multitable
3451
3452 @item @emph{Example}:
3453 @smallexample
3454 PROGRAM test_chdir
3455 CHARACTER(len=255) :: path
3456 CALL getcwd(path)
3457 WRITE(*,*) TRIM(path)
3458 CALL chdir("/tmp")
3459 CALL getcwd(path)
3460 WRITE(*,*) TRIM(path)
3461 END PROGRAM
3462 @end smallexample
3463
3464 @item @emph{See also}:
3465 @ref{GETCWD}
3466 @end table
3467
3468
3469
3470 @node CHMOD
3471 @section @code{CHMOD} --- Change access permissions of files
3472 @fnindex CHMOD
3473 @cindex file system, change access mode
3474
3475 @table @asis
3476 @item @emph{Description}:
3477 @code{CHMOD} changes the permissions of a file.
3478
3479 This intrinsic is provided in both subroutine and function forms; however,
3480 only one form can be used in any given program unit.
3481
3482 @item @emph{Standard}:
3483 GNU extension
3484
3485 @item @emph{Class}:
3486 Subroutine, function
3487
3488 @item @emph{Syntax}:
3489 @multitable @columnfractions .80
3490 @item @code{CALL CHMOD(NAME, MODE[, STATUS])}
3491 @item @code{STATUS = CHMOD(NAME, MODE)}
3492 @end multitable
3493
3494 @item @emph{Arguments}:
3495 @multitable @columnfractions .15 .70
3496
3497 @item @var{NAME} @tab Scalar @code{CHARACTER} of default kind with the
3498 file name. Trailing blanks are ignored unless the character
3499 @code{achar(0)} is present, then all characters up to and excluding
3500 @code{achar(0)} are used as the file name.
3501
3502 @item @var{MODE} @tab Scalar @code{CHARACTER} of default kind giving the
3503 file permission. @var{MODE} uses the same syntax as the @code{chmod} utility
3504 as defined by the POSIX standard. The argument shall either be a string of
3505 a nonnegative octal number or a symbolic mode.
3506
3507 @item @var{STATUS} @tab (optional) scalar @code{INTEGER}, which is
3508 @code{0} on success and nonzero otherwise.
3509 @end multitable
3510
3511 @item @emph{Return value}:
3512 In either syntax, @var{STATUS} is set to @code{0} on success and nonzero
3513 otherwise.
3514
3515 @item @emph{Example}:
3516 @code{CHMOD} as subroutine
3517 @smallexample
3518 program chmod_test
3519 implicit none
3520 integer :: status
3521 call chmod('test.dat','u+x',status)
3522 print *, 'Status: ', status
3523 end program chmod_test
3524 @end smallexample
3525 @code{CHMOD} as function:
3526 @smallexample
3527 program chmod_test
3528 implicit none
3529 integer :: status
3530 status = chmod('test.dat','u+x')
3531 print *, 'Status: ', status
3532 end program chmod_test
3533 @end smallexample
3534
3535 @end table
3536
3537
3538
3539 @node CMPLX
3540 @section @code{CMPLX} --- Complex conversion function
3541 @fnindex CMPLX
3542 @cindex complex numbers, conversion to
3543 @cindex conversion, to complex
3544
3545 @table @asis
3546 @item @emph{Description}:
3547 @code{CMPLX(X [, Y [, KIND]])} returns a complex number where @var{X} is converted to
3548 the real component. If @var{Y} is present it is converted to the imaginary
3549 component. If @var{Y} is not present then the imaginary component is set to
3550 0.0. If @var{X} is complex then @var{Y} must not be present.
3551
3552 @item @emph{Standard}:
3553 Fortran 77 and later
3554
3555 @item @emph{Class}:
3556 Elemental function
3557
3558 @item @emph{Syntax}:
3559 @code{RESULT = CMPLX(X [, Y [, KIND]])}
3560
3561 @item @emph{Arguments}:
3562 @multitable @columnfractions .15 .70
3563 @item @var{X} @tab The type may be @code{INTEGER}, @code{REAL},
3564 or @code{COMPLEX}.
3565 @item @var{Y} @tab (Optional; only allowed if @var{X} is not
3566 @code{COMPLEX}.) May be @code{INTEGER} or @code{REAL}.
3567 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
3568 expression indicating the kind parameter of the result.
3569 @end multitable
3570
3571 @item @emph{Return value}:
3572 The return value is of @code{COMPLEX} type, with a kind equal to
3573 @var{KIND} if it is specified. If @var{KIND} is not specified, the
3574 result is of the default @code{COMPLEX} kind, regardless of the kinds of
3575 @var{X} and @var{Y}.
3576
3577 @item @emph{Example}:
3578 @smallexample
3579 program test_cmplx
3580 integer :: i = 42
3581 real :: x = 3.14
3582 complex :: z
3583 z = cmplx(i, x)
3584 print *, z, cmplx(x)
3585 end program test_cmplx
3586 @end smallexample
3587
3588 @item @emph{See also}:
3589 @ref{COMPLEX}
3590 @end table
3591
3592
3593
3594 @node CO_BROADCAST
3595 @section @code{CO_BROADCAST} --- Copy a value to all images the current set of images
3596 @fnindex CO_BROADCAST
3597 @cindex Collectives, value broadcasting
3598
3599 @table @asis
3600 @item @emph{Description}:
3601 @code{CO_BROADCAST} copies the value of argument @var{A} on the image with
3602 image index @code{SOURCE_IMAGE} to all images in the current team. @var{A}
3603 becomes defined as if by intrinsic assignment. If the execution was
3604 successful and @var{STAT} is present, it is assigned the value zero. If the
3605 execution failed, @var{STAT} gets assigned a nonzero value and, if present,
3606 @var{ERRMSG} gets assigned a value describing the occurred error.
3607
3608 @item @emph{Standard}:
3609 Technical Specification (TS) 18508 or later
3610
3611 @item @emph{Class}:
3612 Collective subroutine
3613
3614 @item @emph{Syntax}:
3615 @code{CALL CO_BROADCAST(A, SOURCE_IMAGE [, STAT, ERRMSG])}
3616
3617 @item @emph{Arguments}:
3618 @multitable @columnfractions .15 .70
3619 @item @var{A} @tab INTENT(INOUT) argument; shall have the same
3620 dynamic type and type paramters on all images of the current team. If it
3621 is an array, it shall have the same shape on all images.
3622 @item @var{SOURCE_IMAGE} @tab a scalar integer expression.
3623 It shall have the same the same value on all images and refer to an
3624 image of the current team.
3625 @item @var{STAT} @tab (optional) a scalar integer variable
3626 @item @var{ERRMSG} @tab (optional) a scalar character variable
3627 @end multitable
3628
3629 @item @emph{Example}:
3630 @smallexample
3631 program test
3632 integer :: val(3)
3633 if (this_image() == 1) then
3634 val = [1, 5, 3]
3635 end if
3636 call co_broadcast (val, source_image=1)
3637 print *, this_image, ":", val
3638 end program test
3639 @end smallexample
3640
3641 @item @emph{See also}:
3642 @ref{CO_MAX}, @ref{CO_MIN}, @ref{CO_SUM}, @ref{CO_REDUCE}
3643 @end table
3644
3645
3646
3647 @node CO_MAX
3648 @section @code{CO_MAX} --- Maximal value on the current set of images
3649 @fnindex CO_MAX
3650 @cindex Collectives, maximal value
3651
3652 @table @asis
3653 @item @emph{Description}:
3654 @code{CO_MAX} determines element-wise the maximal value of @var{A} on all
3655 images of the current team. If @var{RESULT_IMAGE} is present, the maximum
3656 values are returned in @var{A} on the specified image only and the value
3657 of @var{A} on the other images become undefined. If @var{RESULT_IMAGE} is
3658 not present, the value is returned on all images. If the execution was
3659 successful and @var{STAT} is present, it is assigned the value zero. If the
3660 execution failed, @var{STAT} gets assigned a nonzero value and, if present,
3661 @var{ERRMSG} gets assigned a value describing the occurred error.
3662
3663 @item @emph{Standard}:
3664 Technical Specification (TS) 18508 or later
3665
3666 @item @emph{Class}:
3667 Collective subroutine
3668
3669 @item @emph{Syntax}:
3670 @code{CALL CO_MAX(A [, RESULT_IMAGE, STAT, ERRMSG])}
3671
3672 @item @emph{Arguments}:
3673 @multitable @columnfractions .15 .70
3674 @item @var{A} @tab shall be an integer, real or character variable,
3675 which has the same type and type parameters on all images of the team.
3676 @item @var{RESULT_IMAGE} @tab (optional) a scalar integer expression; if
3677 present, it shall have the same the same value on all images and refer to an
3678 image of the current team.
3679 @item @var{STAT} @tab (optional) a scalar integer variable
3680 @item @var{ERRMSG} @tab (optional) a scalar character variable
3681 @end multitable
3682
3683 @item @emph{Example}:
3684 @smallexample
3685 program test
3686 integer :: val
3687 val = this_image ()
3688 call co_max (val, result_image=1)
3689 if (this_image() == 1) then
3690 write(*,*) "Maximal value", val ! prints num_images()
3691 end if
3692 end program test
3693 @end smallexample
3694
3695 @item @emph{See also}:
3696 @ref{CO_MIN}, @ref{CO_SUM}, @ref{CO_REDUCE}, @ref{CO_BROADCAST}
3697 @end table
3698
3699
3700
3701 @node CO_MIN
3702 @section @code{CO_MIN} --- Minimal value on the current set of images
3703 @fnindex CO_MIN
3704 @cindex Collectives, minimal value
3705
3706 @table @asis
3707 @item @emph{Description}:
3708 @code{CO_MIN} determines element-wise the minimal value of @var{A} on all
3709 images of the current team. If @var{RESULT_IMAGE} is present, the minimal
3710 values are returned in @var{A} on the specified image only and the value
3711 of @var{A} on the other images become undefined. If @var{RESULT_IMAGE} is
3712 not present, the value is returned on all images. If the execution was
3713 successful and @var{STAT} is present, it is assigned the value zero. If the
3714 execution failed, @var{STAT} gets assigned a nonzero value and, if present,
3715 @var{ERRMSG} gets assigned a value describing the occurred error.
3716
3717 @item @emph{Standard}:
3718 Technical Specification (TS) 18508 or later
3719
3720 @item @emph{Class}:
3721 Collective subroutine
3722
3723 @item @emph{Syntax}:
3724 @code{CALL CO_MIN(A [, RESULT_IMAGE, STAT, ERRMSG])}
3725
3726 @item @emph{Arguments}:
3727 @multitable @columnfractions .15 .70
3728 @item @var{A} @tab shall be an integer, real or character variable,
3729 which has the same type and type parameters on all images of the team.
3730 @item @var{RESULT_IMAGE} @tab (optional) a scalar integer expression; if
3731 present, it shall have the same the same value on all images and refer to an
3732 image of the current team.
3733 @item @var{STAT} @tab (optional) a scalar integer variable
3734 @item @var{ERRMSG} @tab (optional) a scalar character variable
3735 @end multitable
3736
3737 @item @emph{Example}:
3738 @smallexample
3739 program test
3740 integer :: val
3741 val = this_image ()
3742 call co_min (val, result_image=1)
3743 if (this_image() == 1) then
3744 write(*,*) "Minimal value", val ! prints 1
3745 end if
3746 end program test
3747 @end smallexample
3748
3749 @item @emph{See also}:
3750 @ref{CO_MAX}, @ref{CO_SUM}, @ref{CO_REDUCE}, @ref{CO_BROADCAST}
3751 @end table
3752
3753
3754
3755 @node CO_REDUCE
3756 @section @code{CO_REDUCE} --- Reduction of values on the current set of images
3757 @fnindex CO_REDUCE
3758 @cindex Collectives, generic reduction
3759
3760 @table @asis
3761 @item @emph{Description}:
3762 @code{CO_REDUCE} determines element-wise the reduction of the value of @var{A}
3763 on all images of the current team. The pure function passed as @var{OPERATOR}
3764 is used to pairwise reduce the values of @var{A} by passing either the value
3765 of @var{A} of different images or the result values of such a reduction as
3766 argument. If @var{A} is an array, the deduction is done element wise. If
3767 @var{RESULT_IMAGE} is present, the result values are returned in @var{A} on
3768 the specified image only and the value of @var{A} on the other images become
3769 undefined. If @var{RESULT_IMAGE} is not present, the value is returned on all
3770 images. If the execution was successful and @var{STAT} is present, it is
3771 assigned the value zero. If the execution failed, @var{STAT} gets assigned
3772 a nonzero value and, if present, @var{ERRMSG} gets assigned a value describing
3773 the occurred error.
3774
3775 @item @emph{Standard}:
3776 Technical Specification (TS) 18508 or later
3777
3778 @item @emph{Class}:
3779 Collective subroutine
3780
3781 @item @emph{Syntax}:
3782 @code{CALL CO_REDUCE(A, OPERATOR, [, RESULT_IMAGE, STAT, ERRMSG])}
3783
3784 @item @emph{Arguments}:
3785 @multitable @columnfractions .15 .70
3786 @item @var{A} @tab is an @code{INTENT(INOUT)} argument and shall be
3787 nonpolymorphic. If it is allocatable, it shall be allocated; if it is a pointer,
3788 it shall be associated. @var{A} shall have the same type and type parameters on
3789 all images of the team; if it is an array, it shall have the same shape on all
3790 images.
3791 @item @var{OPERATOR} @tab pure function with two scalar nonallocatable
3792 arguments, which shall be nonpolymorphic and have the same type and type
3793 parameters as @var{A}. The function shall return a nonallocatable scalar of
3794 the same type and type parameters as @var{A}. The function shall be the same on
3795 all images and with regards to the arguments mathematically commutative and
3796 associative. Note that @var{OPERATOR} may not be an elemental function, unless
3797 it is an intrisic function.
3798 @item @var{RESULT_IMAGE} @tab (optional) a scalar integer expression; if
3799 present, it shall have the same the same value on all images and refer to an
3800 image of the current team.
3801 @item @var{STAT} @tab (optional) a scalar integer variable
3802 @item @var{ERRMSG} @tab (optional) a scalar character variable
3803 @end multitable
3804
3805 @item @emph{Example}:
3806 @smallexample
3807 program test
3808 integer :: val
3809 val = this_image ()
3810 call co_reduce (val, result_image=1, operator=myprod)
3811 if (this_image() == 1) then
3812 write(*,*) "Product value", val ! prints num_images() factorial
3813 end if
3814 contains
3815 pure function myprod(a, b)
3816 integer, value :: a, b
3817 integer :: myprod
3818 myprod = a * b
3819 end function myprod
3820 end program test
3821 @end smallexample
3822
3823 @item @emph{Note}:
3824 While the rules permit in principle an intrinsic function, none of the
3825 intrinsics in the standard fulfill the criteria of having a specific
3826 function, which takes two arguments of the same type and returning that
3827 type as result.
3828
3829 @item @emph{See also}:
3830 @ref{CO_MIN}, @ref{CO_MAX}, @ref{CO_SUM}, @ref{CO_BROADCAST}
3831 @end table
3832
3833
3834
3835 @node CO_SUM
3836 @section @code{CO_SUM} --- Sum of values on the current set of images
3837 @fnindex CO_SUM
3838 @cindex Collectives, sum of values
3839
3840 @table @asis
3841 @item @emph{Description}:
3842 @code{CO_SUM} sums up the values of each element of @var{A} on all
3843 images of the current team. If @var{RESULT_IMAGE} is present, the summed-up
3844 values are returned in @var{A} on the specified image only and the value
3845 of @var{A} on the other images become undefined. If @var{RESULT_IMAGE} is
3846 not present, the value is returned on all images. If the execution was
3847 successful and @var{STAT} is present, it is assigned the value zero. If the
3848 execution failed, @var{STAT} gets assigned a nonzero value and, if present,
3849 @var{ERRMSG} gets assigned a value describing the occurred error.
3850
3851 @item @emph{Standard}:
3852 Technical Specification (TS) 18508 or later
3853
3854 @item @emph{Class}:
3855 Collective subroutine
3856
3857 @item @emph{Syntax}:
3858 @code{CALL CO_MIN(A [, RESULT_IMAGE, STAT, ERRMSG])}
3859
3860 @item @emph{Arguments}:
3861 @multitable @columnfractions .15 .70
3862 @item @var{A} @tab shall be an integer, real or complex variable,
3863 which has the same type and type parameters on all images of the team.
3864 @item @var{RESULT_IMAGE} @tab (optional) a scalar integer expression; if
3865 present, it shall have the same the same value on all images and refer to an
3866 image of the current team.
3867 @item @var{STAT} @tab (optional) a scalar integer variable
3868 @item @var{ERRMSG} @tab (optional) a scalar character variable
3869 @end multitable
3870
3871 @item @emph{Example}:
3872 @smallexample
3873 program test
3874 integer :: val
3875 val = this_image ()
3876 call co_sum (val, result_image=1)
3877 if (this_image() == 1) then
3878 write(*,*) "The sum is ", val ! prints (n**2 + n)/2, with n = num_images()
3879 end if
3880 end program test
3881 @end smallexample
3882
3883 @item @emph{See also}:
3884 @ref{CO_MAX}, @ref{CO_MIN}, @ref{CO_REDUCE}, @ref{CO_BROADCAST}
3885 @end table
3886
3887
3888
3889 @node COMMAND_ARGUMENT_COUNT
3890 @section @code{COMMAND_ARGUMENT_COUNT} --- Get number of command line arguments
3891 @fnindex COMMAND_ARGUMENT_COUNT
3892 @cindex command-line arguments
3893 @cindex command-line arguments, number of
3894 @cindex arguments, to program
3895
3896 @table @asis
3897 @item @emph{Description}:
3898 @code{COMMAND_ARGUMENT_COUNT} returns the number of arguments passed on the
3899 command line when the containing program was invoked.
3900
3901 @item @emph{Standard}:
3902 Fortran 2003 and later
3903
3904 @item @emph{Class}:
3905 Inquiry function
3906
3907 @item @emph{Syntax}:
3908 @code{RESULT = COMMAND_ARGUMENT_COUNT()}
3909
3910 @item @emph{Arguments}:
3911 @multitable @columnfractions .15 .70
3912 @item None
3913 @end multitable
3914
3915 @item @emph{Return value}:
3916 The return value is an @code{INTEGER} of default kind.
3917
3918 @item @emph{Example}:
3919 @smallexample
3920 program test_command_argument_count
3921 integer :: count
3922 count = command_argument_count()
3923 print *, count
3924 end program test_command_argument_count
3925 @end smallexample
3926
3927 @item @emph{See also}:
3928 @ref{GET_COMMAND}, @ref{GET_COMMAND_ARGUMENT}
3929 @end table
3930
3931
3932
3933 @node COMPILER_OPTIONS
3934 @section @code{COMPILER_OPTIONS} --- Options passed to the compiler
3935 @fnindex COMPILER_OPTIONS
3936 @cindex flags inquiry function
3937 @cindex options inquiry function
3938 @cindex compiler flags inquiry function
3939
3940 @table @asis
3941 @item @emph{Description}:
3942 @code{COMPILER_OPTIONS} returns a string with the options used for
3943 compiling.
3944
3945 @item @emph{Standard}:
3946 Fortran 2008
3947
3948 @item @emph{Class}:
3949 Inquiry function of the module @code{ISO_FORTRAN_ENV}
3950
3951 @item @emph{Syntax}:
3952 @code{STR = COMPILER_OPTIONS()}
3953
3954 @item @emph{Arguments}:
3955 None.
3956
3957 @item @emph{Return value}:
3958 The return value is a default-kind string with system-dependent length.
3959 It contains the compiler flags used to compile the file, which called
3960 the @code{COMPILER_OPTIONS} intrinsic.
3961
3962 @item @emph{Example}:
3963 @smallexample
3964 use iso_fortran_env
3965 print '(4a)', 'This file was compiled by ', &
3966 compiler_version(), ' using the options ', &
3967 compiler_options()
3968 end
3969 @end smallexample
3970
3971 @item @emph{See also}:
3972 @ref{COMPILER_VERSION}, @ref{ISO_FORTRAN_ENV}
3973 @end table
3974
3975
3976
3977 @node COMPILER_VERSION
3978 @section @code{COMPILER_VERSION} --- Compiler version string
3979 @fnindex COMPILER_VERSION
3980 @cindex compiler, name and version
3981 @cindex version of the compiler
3982
3983 @table @asis
3984 @item @emph{Description}:
3985 @code{COMPILER_VERSION} returns a string with the name and the
3986 version of the compiler.
3987
3988 @item @emph{Standard}:
3989 Fortran 2008
3990
3991 @item @emph{Class}:
3992 Inquiry function of the module @code{ISO_FORTRAN_ENV}
3993
3994 @item @emph{Syntax}:
3995 @code{STR = COMPILER_VERSION()}
3996
3997 @item @emph{Arguments}:
3998 None.
3999
4000 @item @emph{Return value}:
4001 The return value is a default-kind string with system-dependent length.
4002 It contains the name of the compiler and its version number.
4003
4004 @item @emph{Example}:
4005 @smallexample
4006 use iso_fortran_env
4007 print '(4a)', 'This file was compiled by ', &
4008 compiler_version(), ' using the options ', &
4009 compiler_options()
4010 end
4011 @end smallexample
4012
4013 @item @emph{See also}:
4014 @ref{COMPILER_OPTIONS}, @ref{ISO_FORTRAN_ENV}
4015 @end table
4016
4017
4018
4019 @node COMPLEX
4020 @section @code{COMPLEX} --- Complex conversion function
4021 @fnindex COMPLEX
4022 @cindex complex numbers, conversion to
4023 @cindex conversion, to complex
4024
4025 @table @asis
4026 @item @emph{Description}:
4027 @code{COMPLEX(X, Y)} returns a complex number where @var{X} is converted
4028 to the real component and @var{Y} is converted to the imaginary
4029 component.
4030
4031 @item @emph{Standard}:
4032 GNU extension
4033
4034 @item @emph{Class}:
4035 Elemental function
4036
4037 @item @emph{Syntax}:
4038 @code{RESULT = COMPLEX(X, Y)}
4039
4040 @item @emph{Arguments}:
4041 @multitable @columnfractions .15 .70
4042 @item @var{X} @tab The type may be @code{INTEGER} or @code{REAL}.
4043 @item @var{Y} @tab The type may be @code{INTEGER} or @code{REAL}.
4044 @end multitable
4045
4046 @item @emph{Return value}:
4047 If @var{X} and @var{Y} are both of @code{INTEGER} type, then the return
4048 value is of default @code{COMPLEX} type.
4049
4050 If @var{X} and @var{Y} are of @code{REAL} type, or one is of @code{REAL}
4051 type and one is of @code{INTEGER} type, then the return value is of
4052 @code{COMPLEX} type with a kind equal to that of the @code{REAL}
4053 argument with the highest precision.
4054
4055 @item @emph{Example}:
4056 @smallexample
4057 program test_complex
4058 integer :: i = 42
4059 real :: x = 3.14
4060 print *, complex(i, x)
4061 end program test_complex
4062 @end smallexample
4063
4064 @item @emph{See also}:
4065 @ref{CMPLX}
4066 @end table
4067
4068
4069
4070 @node CONJG
4071 @section @code{CONJG} --- Complex conjugate function
4072 @fnindex CONJG
4073 @fnindex DCONJG
4074 @cindex complex conjugate
4075
4076 @table @asis
4077 @item @emph{Description}:
4078 @code{CONJG(Z)} returns the conjugate of @var{Z}. If @var{Z} is @code{(x, y)}
4079 then the result is @code{(x, -y)}
4080
4081 @item @emph{Standard}:
4082 Fortran 77 and later, has overloads that are GNU extensions
4083
4084 @item @emph{Class}:
4085 Elemental function
4086
4087 @item @emph{Syntax}:
4088 @code{Z = CONJG(Z)}
4089
4090 @item @emph{Arguments}:
4091 @multitable @columnfractions .15 .70
4092 @item @var{Z} @tab The type shall be @code{COMPLEX}.
4093 @end multitable
4094
4095 @item @emph{Return value}:
4096 The return value is of type @code{COMPLEX}.
4097
4098 @item @emph{Example}:
4099 @smallexample
4100 program test_conjg
4101 complex :: z = (2.0, 3.0)
4102 complex(8) :: dz = (2.71_8, -3.14_8)
4103 z= conjg(z)
4104 print *, z
4105 dz = dconjg(dz)
4106 print *, dz
4107 end program test_conjg
4108 @end smallexample
4109
4110 @item @emph{Specific names}:
4111 @multitable @columnfractions .20 .20 .20 .25
4112 @item Name @tab Argument @tab Return type @tab Standard
4113 @item @code{CONJG(Z)} @tab @code{COMPLEX Z} @tab @code{COMPLEX} @tab GNU extension
4114 @item @code{DCONJG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
4115 @end multitable
4116 @end table
4117
4118
4119
4120 @node COS
4121 @section @code{COS} --- Cosine function
4122 @fnindex COS
4123 @fnindex DCOS
4124 @fnindex CCOS
4125 @fnindex ZCOS
4126 @fnindex CDCOS
4127 @cindex trigonometric function, cosine
4128 @cindex cosine
4129
4130 @table @asis
4131 @item @emph{Description}:
4132 @code{COS(X)} computes the cosine of @var{X}.
4133
4134 @item @emph{Standard}:
4135 Fortran 77 and later, has overloads that are GNU extensions
4136
4137 @item @emph{Class}:
4138 Elemental function
4139
4140 @item @emph{Syntax}:
4141 @code{RESULT = COS(X)}
4142
4143 @item @emph{Arguments}:
4144 @multitable @columnfractions .15 .70
4145 @item @var{X} @tab The type shall be @code{REAL} or
4146 @code{COMPLEX}.
4147 @end multitable
4148
4149 @item @emph{Return value}:
4150 The return value is of the same type and kind as @var{X}. The real part
4151 of the result is in radians. If @var{X} is of the type @code{REAL},
4152 the return value lies in the range @math{ -1 \leq \cos (x) \leq 1}.
4153
4154 @item @emph{Example}:
4155 @smallexample
4156 program test_cos
4157 real :: x = 0.0
4158 x = cos(x)
4159 end program test_cos
4160 @end smallexample
4161
4162 @item @emph{Specific names}:
4163 @multitable @columnfractions .20 .20 .20 .25
4164 @item Name @tab Argument @tab Return type @tab Standard
4165 @item @code{COS(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later
4166 @item @code{DCOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
4167 @item @code{CCOS(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab Fortran 77 and later
4168 @item @code{ZCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
4169 @item @code{CDCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
4170 @end multitable
4171
4172 @item @emph{See also}:
4173 Inverse function: @ref{ACOS}
4174 Degrees function: @ref{COSD}
4175
4176 @end table
4177
4178
4179
4180 @node COSD
4181 @section @code{COSD} --- Cosine function, degrees
4182 @fnindex COSD
4183 @fnindex DCOSD
4184 @fnindex CCOSD
4185 @fnindex ZCOSD
4186 @fnindex CDCOSD
4187 @cindex trigonometric function, cosine, degrees
4188 @cindex cosine, degrees
4189
4190 @table @asis
4191 @item @emph{Description}:
4192 @code{COSD(X)} computes the cosine of @var{X} in degrees.
4193
4194 This function is for compatibility only and should be avoided in favor of
4195 standard constructs wherever possible.
4196
4197 @item @emph{Standard}:
4198 GNU Extension, enabled with @option{-fdec-math}.
4199
4200 @item @emph{Class}:
4201 Elemental function
4202
4203 @item @emph{Syntax}:
4204 @code{RESULT = COSD(X)}
4205
4206 @item @emph{Arguments}:
4207 @multitable @columnfractions .15 .70
4208 @item @var{X} @tab The type shall be @code{REAL} or
4209 @code{COMPLEX}.
4210 @end multitable
4211
4212 @item @emph{Return value}:
4213 The return value is of the same type and kind as @var{X}. The real part
4214 of the result is in degrees. If @var{X} is of the type @code{REAL},
4215 the return value lies in the range @math{ -1 \leq \cosd (x) \leq 1}.
4216
4217 @item @emph{Example}:
4218 @smallexample
4219 program test_cosd
4220 real :: x = 0.0
4221 x = cosd(x)
4222 end program test_cosd
4223 @end smallexample
4224
4225 @item @emph{Specific names}:
4226 @multitable @columnfractions .20 .20 .20 .25
4227 @item Name @tab Argument @tab Return type @tab Standard
4228 @item @code{COSD(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU Extension
4229 @item @code{DCOSD(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU Extension
4230 @item @code{CCOSD(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab GNU Extension
4231 @item @code{ZCOSD(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
4232 @item @code{CDCOSD(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
4233 @end multitable
4234
4235 @item @emph{See also}:
4236 Inverse function: @ref{ACOSD}
4237 Radians function: @ref{COS}
4238
4239 @end table
4240
4241
4242
4243 @node COSH
4244 @section @code{COSH} --- Hyperbolic cosine function
4245 @fnindex COSH
4246 @fnindex DCOSH
4247 @cindex hyperbolic cosine
4248 @cindex hyperbolic function, cosine
4249 @cindex cosine, hyperbolic
4250
4251 @table @asis
4252 @item @emph{Description}:
4253 @code{COSH(X)} computes the hyperbolic cosine of @var{X}.
4254
4255 @item @emph{Standard}:
4256 Fortran 77 and later, for a complex argument Fortran 2008 or later
4257
4258 @item @emph{Class}:
4259 Elemental function
4260
4261 @item @emph{Syntax}:
4262 @code{X = COSH(X)}
4263
4264 @item @emph{Arguments}:
4265 @multitable @columnfractions .15 .70
4266 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
4267 @end multitable
4268
4269 @item @emph{Return value}:
4270 The return value has same type and kind as @var{X}. If @var{X} is
4271 complex, the imaginary part of the result is in radians. If @var{X}
4272 is @code{REAL}, the return value has a lower bound of one,
4273 @math{\cosh (x) \geq 1}.
4274
4275 @item @emph{Example}:
4276 @smallexample
4277 program test_cosh
4278 real(8) :: x = 1.0_8
4279 x = cosh(x)
4280 end program test_cosh
4281 @end smallexample
4282
4283 @item @emph{Specific names}:
4284 @multitable @columnfractions .20 .20 .20 .25
4285 @item Name @tab Argument @tab Return type @tab Standard
4286 @item @code{COSH(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later
4287 @item @code{DCOSH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
4288 @end multitable
4289
4290 @item @emph{See also}:
4291 Inverse function: @ref{ACOSH}
4292
4293 @end table
4294
4295
4296
4297 @node COTAN
4298 @section @code{COTAN} --- Cotangent function
4299 @fnindex COTAN
4300 @fnindex DCOTAN
4301 @cindex trigonometric function, cotangent
4302 @cindex cotangent
4303
4304 @table @asis
4305 @item @emph{Description}:
4306 @code{COTAN(X)} computes the cotangent of @var{X}. Equivalent to @code{COS(x)}
4307 divided by @code{SIN(x)}, or @code{1 / TAN(x)}.
4308
4309 This function is for compatibility only and should be avoided in favor of
4310 standard constructs wherever possible.
4311
4312 @item @emph{Standard}:
4313 GNU Extension, enabled with @option{-fdec-math}.
4314
4315 @item @emph{Class}:
4316 Elemental function
4317
4318 @item @emph{Syntax}:
4319 @code{RESULT = COTAN(X)}
4320
4321 @item @emph{Arguments}:
4322 @multitable @columnfractions .15 .70
4323 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
4324 @end multitable
4325
4326 @item @emph{Return value}:
4327 The return value has same type and kind as @var{X}, and its value is in radians.
4328
4329 @item @emph{Example}:
4330 @smallexample
4331 program test_cotan
4332 real(8) :: x = 0.165_8
4333 x = cotan(x)
4334 end program test_cotan
4335 @end smallexample
4336
4337 @item @emph{Specific names}:
4338 @multitable @columnfractions .20 .20 .20 .25
4339 @item Name @tab Argument @tab Return type @tab Standard
4340 @item @code{COTAN(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU Extension
4341 @item @code{DCOTAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU Extension
4342 @end multitable
4343
4344 @item @emph{See also}:
4345 Converse function: @ref{TAN}
4346 Degrees function: @ref{COTAND}
4347 @end table
4348
4349
4350
4351 @node COTAND
4352 @section @code{COTAND} --- Cotangent function, degrees
4353 @fnindex COTAND
4354 @fnindex DCOTAND
4355 @cindex trigonometric function, cotangent, degrees
4356 @cindex cotangent, degrees
4357
4358 @table @asis
4359 @item @emph{Description}:
4360 @code{COTAND(X)} computes the cotangent of @var{X} in degrees. Equivalent to
4361 @code{COSD(x)} divided by @code{SIND(x)}, or @code{1 / TAND(x)}.
4362
4363 @item @emph{Standard}:
4364 GNU Extension, enabled with @option{-fdec-math}.
4365
4366 This function is for compatibility only and should be avoided in favor of
4367 standard constructs wherever possible.
4368
4369 @item @emph{Class}:
4370 Elemental function
4371
4372 @item @emph{Syntax}:
4373 @code{RESULT = COTAND(X)}
4374
4375 @item @emph{Arguments}:
4376 @multitable @columnfractions .15 .70
4377 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
4378 @end multitable
4379
4380 @item @emph{Return value}:
4381 The return value has same type and kind as @var{X}, and its value is in degrees.
4382
4383 @item @emph{Example}:
4384 @smallexample
4385 program test_cotand
4386 real(8) :: x = 0.165_8
4387 x = cotand(x)
4388 end program test_cotand
4389 @end smallexample
4390
4391 @item @emph{Specific names}:
4392 @multitable @columnfractions .20 .20 .20 .25
4393 @item Name @tab Argument @tab Return type @tab Standard
4394 @item @code{COTAND(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU Extension
4395 @item @code{DCOTAND(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU Extension
4396 @end multitable
4397
4398 @item @emph{See also}:
4399 Converse function: @ref{TAND}
4400 Radians function: @ref{COTAN}
4401
4402 @end table
4403
4404
4405
4406 @node COUNT
4407 @section @code{COUNT} --- Count function
4408 @fnindex COUNT
4409 @cindex array, conditionally count elements
4410 @cindex array, element counting
4411 @cindex array, number of elements
4412
4413 @table @asis
4414 @item @emph{Description}:
4415
4416 Counts the number of @code{.TRUE.} elements in a logical @var{MASK},
4417 or, if the @var{DIM} argument is supplied, counts the number of
4418 elements along each row of the array in the @var{DIM} direction.
4419 If the array has zero size, or all of the elements of @var{MASK} are
4420 @code{.FALSE.}, then the result is @code{0}.
4421
4422 @item @emph{Standard}:
4423 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
4424
4425 @item @emph{Class}:
4426 Transformational function
4427
4428 @item @emph{Syntax}:
4429 @code{RESULT = COUNT(MASK [, DIM, KIND])}
4430
4431 @item @emph{Arguments}:
4432 @multitable @columnfractions .15 .70
4433 @item @var{MASK} @tab The type shall be @code{LOGICAL}.
4434 @item @var{DIM} @tab (Optional) The type shall be @code{INTEGER}.
4435 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
4436 expression indicating the kind parameter of the result.
4437 @end multitable
4438
4439 @item @emph{Return value}:
4440 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
4441 @var{KIND} is absent, the return value is of default integer kind.
4442 If @var{DIM} is present, the result is an array with a rank one less
4443 than the rank of @var{ARRAY}, and a size corresponding to the shape
4444 of @var{ARRAY} with the @var{DIM} dimension removed.
4445
4446 @item @emph{Example}:
4447 @smallexample
4448 program test_count
4449 integer, dimension(2,3) :: a, b
4450 logical, dimension(2,3) :: mask
4451 a = reshape( (/ 1, 2, 3, 4, 5, 6 /), (/ 2, 3 /))
4452 b = reshape( (/ 0, 7, 3, 4, 5, 8 /), (/ 2, 3 /))
4453 print '(3i3)', a(1,:)
4454 print '(3i3)', a(2,:)
4455 print *
4456 print '(3i3)', b(1,:)
4457 print '(3i3)', b(2,:)
4458 print *
4459 mask = a.ne.b
4460 print '(3l3)', mask(1,:)
4461 print '(3l3)', mask(2,:)
4462 print *
4463 print '(3i3)', count(mask)
4464 print *
4465 print '(3i3)', count(mask, 1)
4466 print *
4467 print '(3i3)', count(mask, 2)
4468 end program test_count
4469 @end smallexample
4470 @end table
4471
4472
4473
4474 @node CPU_TIME
4475 @section @code{CPU_TIME} --- CPU elapsed time in seconds
4476 @fnindex CPU_TIME
4477 @cindex time, elapsed
4478
4479 @table @asis
4480 @item @emph{Description}:
4481 Returns a @code{REAL} value representing the elapsed CPU time in
4482 seconds. This is useful for testing segments of code to determine
4483 execution time.
4484
4485 If a time source is available, time will be reported with microsecond
4486 resolution. If no time source is available, @var{TIME} is set to
4487 @code{-1.0}.
4488
4489 Note that @var{TIME} may contain a, system dependent, arbitrary offset
4490 and may not start with @code{0.0}. For @code{CPU_TIME}, the absolute
4491 value is meaningless, only differences between subsequent calls to
4492 this subroutine, as shown in the example below, should be used.
4493
4494
4495 @item @emph{Standard}:
4496 Fortran 95 and later
4497
4498 @item @emph{Class}:
4499 Subroutine
4500
4501 @item @emph{Syntax}:
4502 @code{CALL CPU_TIME(TIME)}
4503
4504 @item @emph{Arguments}:
4505 @multitable @columnfractions .15 .70
4506 @item @var{TIME} @tab The type shall be @code{REAL} with @code{INTENT(OUT)}.
4507 @end multitable
4508
4509 @item @emph{Return value}:
4510 None
4511
4512 @item @emph{Example}:
4513 @smallexample
4514 program test_cpu_time
4515 real :: start, finish
4516 call cpu_time(start)
4517 ! put code to test here
4518 call cpu_time(finish)
4519 print '("Time = ",f6.3," seconds.")',finish-start
4520 end program test_cpu_time
4521 @end smallexample
4522
4523 @item @emph{See also}:
4524 @ref{SYSTEM_CLOCK}, @ref{DATE_AND_TIME}
4525 @end table
4526
4527
4528
4529 @node CSHIFT
4530 @section @code{CSHIFT} --- Circular shift elements of an array
4531 @fnindex CSHIFT
4532 @cindex array, shift circularly
4533 @cindex array, permutation
4534 @cindex array, rotate
4535
4536 @table @asis
4537 @item @emph{Description}:
4538 @code{CSHIFT(ARRAY, SHIFT [, DIM])} performs a circular shift on elements of
4539 @var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is omitted it is
4540 taken to be @code{1}. @var{DIM} is a scalar of type @code{INTEGER} in the
4541 range of @math{1 \leq DIM \leq n)} where @math{n} is the rank of @var{ARRAY}.
4542 If the rank of @var{ARRAY} is one, then all elements of @var{ARRAY} are shifted
4543 by @var{SHIFT} places. If rank is greater than one, then all complete rank one
4544 sections of @var{ARRAY} along the given dimension are shifted. Elements
4545 shifted out one end of each rank one section are shifted back in the other end.
4546
4547 @item @emph{Standard}:
4548 Fortran 95 and later
4549
4550 @item @emph{Class}:
4551 Transformational function
4552
4553 @item @emph{Syntax}:
4554 @code{RESULT = CSHIFT(ARRAY, SHIFT [, DIM])}
4555
4556 @item @emph{Arguments}:
4557 @multitable @columnfractions .15 .70
4558 @item @var{ARRAY} @tab Shall be an array of any type.
4559 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
4560 @item @var{DIM} @tab The type shall be @code{INTEGER}.
4561 @end multitable
4562
4563 @item @emph{Return value}:
4564 Returns an array of same type and rank as the @var{ARRAY} argument.
4565
4566 @item @emph{Example}:
4567 @smallexample
4568 program test_cshift
4569 integer, dimension(3,3) :: a
4570 a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
4571 print '(3i3)', a(1,:)
4572 print '(3i3)', a(2,:)
4573 print '(3i3)', a(3,:)
4574 a = cshift(a, SHIFT=(/1, 2, -1/), DIM=2)
4575 print *
4576 print '(3i3)', a(1,:)
4577 print '(3i3)', a(2,:)
4578 print '(3i3)', a(3,:)
4579 end program test_cshift
4580 @end smallexample
4581 @end table
4582
4583
4584
4585 @node CTIME
4586 @section @code{CTIME} --- Convert a time into a string
4587 @fnindex CTIME
4588 @cindex time, conversion to string
4589 @cindex conversion, to string
4590
4591 @table @asis
4592 @item @emph{Description}:
4593 @code{CTIME} converts a system time value, such as returned by
4594 @ref{TIME8}, to a string. The output will be of the form @samp{Sat
4595 Aug 19 18:13:14 1995}.
4596
4597 This intrinsic is provided in both subroutine and function forms; however,
4598 only one form can be used in any given program unit.
4599
4600 @item @emph{Standard}:
4601 GNU extension
4602
4603 @item @emph{Class}:
4604 Subroutine, function
4605
4606 @item @emph{Syntax}:
4607 @multitable @columnfractions .80
4608 @item @code{CALL CTIME(TIME, RESULT)}.
4609 @item @code{RESULT = CTIME(TIME)}.
4610 @end multitable
4611
4612 @item @emph{Arguments}:
4613 @multitable @columnfractions .15 .70
4614 @item @var{TIME} @tab The type shall be of type @code{INTEGER}.
4615 @item @var{RESULT} @tab The type shall be of type @code{CHARACTER} and
4616 of default kind. It is an @code{INTENT(OUT)} argument. If the length
4617 of this variable is too short for the time and date string to fit
4618 completely, it will be blank on procedure return.
4619 @end multitable
4620
4621 @item @emph{Return value}:
4622 The converted date and time as a string.
4623
4624 @item @emph{Example}:
4625 @smallexample
4626 program test_ctime
4627 integer(8) :: i
4628 character(len=30) :: date
4629 i = time8()
4630
4631 ! Do something, main part of the program
4632
4633 call ctime(i,date)
4634 print *, 'Program was started on ', date
4635 end program test_ctime
4636 @end smallexample
4637
4638 @item @emph{See Also}:
4639 @ref{DATE_AND_TIME}, @ref{GMTIME}, @ref{LTIME}, @ref{TIME}, @ref{TIME8}
4640 @end table
4641
4642
4643
4644 @node DATE_AND_TIME
4645 @section @code{DATE_AND_TIME} --- Date and time subroutine
4646 @fnindex DATE_AND_TIME
4647 @cindex date, current
4648 @cindex current date
4649 @cindex time, current
4650 @cindex current time
4651
4652 @table @asis
4653 @item @emph{Description}:
4654 @code{DATE_AND_TIME(DATE, TIME, ZONE, VALUES)} gets the corresponding date and
4655 time information from the real-time system clock. @var{DATE} is
4656 @code{INTENT(OUT)} and has form ccyymmdd. @var{TIME} is @code{INTENT(OUT)} and
4657 has form hhmmss.sss. @var{ZONE} is @code{INTENT(OUT)} and has form (+-)hhmm,
4658 representing the difference with respect to Coordinated Universal Time (UTC).
4659 Unavailable time and date parameters return blanks.
4660
4661 @var{VALUES} is @code{INTENT(OUT)} and provides the following:
4662
4663 @multitable @columnfractions .15 .30 .40
4664 @item @tab @code{VALUE(1)}: @tab The year
4665 @item @tab @code{VALUE(2)}: @tab The month
4666 @item @tab @code{VALUE(3)}: @tab The day of the month
4667 @item @tab @code{VALUE(4)}: @tab Time difference with UTC in minutes
4668 @item @tab @code{VALUE(5)}: @tab The hour of the day
4669 @item @tab @code{VALUE(6)}: @tab The minutes of the hour
4670 @item @tab @code{VALUE(7)}: @tab The seconds of the minute
4671 @item @tab @code{VALUE(8)}: @tab The milliseconds of the second
4672 @end multitable
4673
4674 @item @emph{Standard}:
4675 Fortran 95 and later
4676
4677 @item @emph{Class}:
4678 Subroutine
4679
4680 @item @emph{Syntax}:
4681 @code{CALL DATE_AND_TIME([DATE, TIME, ZONE, VALUES])}
4682
4683 @item @emph{Arguments}:
4684 @multitable @columnfractions .15 .70
4685 @item @var{DATE} @tab (Optional) The type shall be @code{CHARACTER(LEN=8)}
4686 or larger, and of default kind.
4687 @item @var{TIME} @tab (Optional) The type shall be @code{CHARACTER(LEN=10)}
4688 or larger, and of default kind.
4689 @item @var{ZONE} @tab (Optional) The type shall be @code{CHARACTER(LEN=5)}
4690 or larger, and of default kind.
4691 @item @var{VALUES}@tab (Optional) The type shall be @code{INTEGER(8)}.
4692 @end multitable
4693
4694 @item @emph{Return value}:
4695 None
4696
4697 @item @emph{Example}:
4698 @smallexample
4699 program test_time_and_date
4700 character(8) :: date
4701 character(10) :: time
4702 character(5) :: zone
4703 integer,dimension(8) :: values
4704 ! using keyword arguments
4705 call date_and_time(date,time,zone,values)
4706 call date_and_time(DATE=date,ZONE=zone)
4707 call date_and_time(TIME=time)
4708 call date_and_time(VALUES=values)
4709 print '(a,2x,a,2x,a)', date, time, zone
4710 print '(8i5)', values
4711 end program test_time_and_date
4712 @end smallexample
4713
4714 @item @emph{See also}:
4715 @ref{CPU_TIME}, @ref{SYSTEM_CLOCK}
4716 @end table
4717
4718
4719
4720 @node DBLE
4721 @section @code{DBLE} --- Double conversion function
4722 @fnindex DBLE
4723 @cindex conversion, to real
4724
4725 @table @asis
4726 @item @emph{Description}:
4727 @code{DBLE(A)} Converts @var{A} to double precision real type.
4728
4729 @item @emph{Standard}:
4730 Fortran 77 and later
4731
4732 @item @emph{Class}:
4733 Elemental function
4734
4735 @item @emph{Syntax}:
4736 @code{RESULT = DBLE(A)}
4737
4738 @item @emph{Arguments}:
4739 @multitable @columnfractions .15 .70
4740 @item @var{A} @tab The type shall be @code{INTEGER}, @code{REAL},
4741 or @code{COMPLEX}.
4742 @end multitable
4743
4744 @item @emph{Return value}:
4745 The return value is of type double precision real.
4746
4747 @item @emph{Example}:
4748 @smallexample
4749 program test_dble
4750 real :: x = 2.18
4751 integer :: i = 5
4752 complex :: z = (2.3,1.14)
4753 print *, dble(x), dble(i), dble(z)
4754 end program test_dble
4755 @end smallexample
4756
4757 @item @emph{See also}:
4758 @ref{REAL}
4759 @end table
4760
4761
4762
4763 @node DCMPLX
4764 @section @code{DCMPLX} --- Double complex conversion function
4765 @fnindex DCMPLX
4766 @cindex complex numbers, conversion to
4767 @cindex conversion, to complex
4768
4769 @table @asis
4770 @item @emph{Description}:
4771 @code{DCMPLX(X [,Y])} returns a double complex number where @var{X} is
4772 converted to the real component. If @var{Y} is present it is converted to the
4773 imaginary component. If @var{Y} is not present then the imaginary component is
4774 set to 0.0. If @var{X} is complex then @var{Y} must not be present.
4775
4776 @item @emph{Standard}:
4777 GNU extension
4778
4779 @item @emph{Class}:
4780 Elemental function
4781
4782 @item @emph{Syntax}:
4783 @code{RESULT = DCMPLX(X [, Y])}
4784
4785 @item @emph{Arguments}:
4786 @multitable @columnfractions .15 .70
4787 @item @var{X} @tab The type may be @code{INTEGER}, @code{REAL},
4788 or @code{COMPLEX}.
4789 @item @var{Y} @tab (Optional if @var{X} is not @code{COMPLEX}.) May be
4790 @code{INTEGER} or @code{REAL}.
4791 @end multitable
4792
4793 @item @emph{Return value}:
4794 The return value is of type @code{COMPLEX(8)}
4795
4796 @item @emph{Example}:
4797 @smallexample
4798 program test_dcmplx
4799 integer :: i = 42
4800 real :: x = 3.14
4801 complex :: z
4802 z = cmplx(i, x)
4803 print *, dcmplx(i)
4804 print *, dcmplx(x)
4805 print *, dcmplx(z)
4806 print *, dcmplx(x,i)
4807 end program test_dcmplx
4808 @end smallexample
4809 @end table
4810
4811
4812 @node DIGITS
4813 @section @code{DIGITS} --- Significant binary digits function
4814 @fnindex DIGITS
4815 @cindex model representation, significant digits
4816
4817 @table @asis
4818 @item @emph{Description}:
4819 @code{DIGITS(X)} returns the number of significant binary digits of the internal
4820 model representation of @var{X}. For example, on a system using a 32-bit
4821 floating point representation, a default real number would likely return 24.
4822
4823 @item @emph{Standard}:
4824 Fortran 95 and later
4825
4826 @item @emph{Class}:
4827 Inquiry function
4828
4829 @item @emph{Syntax}:
4830 @code{RESULT = DIGITS(X)}
4831
4832 @item @emph{Arguments}:
4833 @multitable @columnfractions .15 .70
4834 @item @var{X} @tab The type may be @code{INTEGER} or @code{REAL}.
4835 @end multitable
4836
4837 @item @emph{Return value}:
4838 The return value is of type @code{INTEGER}.
4839
4840 @item @emph{Example}:
4841 @smallexample
4842 program test_digits
4843 integer :: i = 12345
4844 real :: x = 3.143
4845 real(8) :: y = 2.33
4846 print *, digits(i)
4847 print *, digits(x)
4848 print *, digits(y)
4849 end program test_digits
4850 @end smallexample
4851 @end table
4852
4853
4854
4855 @node DIM
4856 @section @code{DIM} --- Positive difference
4857 @fnindex DIM
4858 @fnindex IDIM
4859 @fnindex DDIM
4860 @cindex positive difference
4861
4862 @table @asis
4863 @item @emph{Description}:
4864 @code{DIM(X,Y)} returns the difference @code{X-Y} if the result is positive;
4865 otherwise returns zero.
4866
4867 @item @emph{Standard}:
4868 Fortran 77 and later
4869
4870 @item @emph{Class}:
4871 Elemental function
4872
4873 @item @emph{Syntax}:
4874 @code{RESULT = DIM(X, Y)}
4875
4876 @item @emph{Arguments}:
4877 @multitable @columnfractions .15 .70
4878 @item @var{X} @tab The type shall be @code{INTEGER} or @code{REAL}
4879 @item @var{Y} @tab The type shall be the same type and kind as @var{X}.
4880 @end multitable
4881
4882 @item @emph{Return value}:
4883 The return value is of type @code{INTEGER} or @code{REAL}.
4884
4885 @item @emph{Example}:
4886 @smallexample
4887 program test_dim
4888 integer :: i
4889 real(8) :: x
4890 i = dim(4, 15)
4891 x = dim(4.345_8, 2.111_8)
4892 print *, i
4893 print *, x
4894 end program test_dim
4895 @end smallexample
4896
4897 @item @emph{Specific names}:
4898 @multitable @columnfractions .20 .20 .20 .25
4899 @item Name @tab Argument @tab Return type @tab Standard
4900 @item @code{DIM(X,Y)} @tab @code{REAL(4) X, Y} @tab @code{REAL(4)} @tab Fortran 77 and later
4901 @item @code{IDIM(X,Y)} @tab @code{INTEGER(4) X, Y} @tab @code{INTEGER(4)} @tab Fortran 77 and later
4902 @item @code{DDIM(X,Y)} @tab @code{REAL(8) X, Y} @tab @code{REAL(8)} @tab Fortran 77 and later
4903 @end multitable
4904 @end table
4905
4906
4907
4908 @node DOT_PRODUCT
4909 @section @code{DOT_PRODUCT} --- Dot product function
4910 @fnindex DOT_PRODUCT
4911 @cindex dot product
4912 @cindex vector product
4913 @cindex product, vector
4914
4915 @table @asis
4916 @item @emph{Description}:
4917 @code{DOT_PRODUCT(VECTOR_A, VECTOR_B)} computes the dot product multiplication
4918 of two vectors @var{VECTOR_A} and @var{VECTOR_B}. The two vectors may be
4919 either numeric or logical and must be arrays of rank one and of equal size. If
4920 the vectors are @code{INTEGER} or @code{REAL}, the result is
4921 @code{SUM(VECTOR_A*VECTOR_B)}. If the vectors are @code{COMPLEX}, the result
4922 is @code{SUM(CONJG(VECTOR_A)*VECTOR_B)}. If the vectors are @code{LOGICAL},
4923 the result is @code{ANY(VECTOR_A .AND. VECTOR_B)}.
4924
4925 @item @emph{Standard}:
4926 Fortran 95 and later
4927
4928 @item @emph{Class}:
4929 Transformational function
4930
4931 @item @emph{Syntax}:
4932 @code{RESULT = DOT_PRODUCT(VECTOR_A, VECTOR_B)}
4933
4934 @item @emph{Arguments}:
4935 @multitable @columnfractions .15 .70
4936 @item @var{VECTOR_A} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
4937 @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.
4938 @end multitable
4939
4940 @item @emph{Return value}:
4941 If the arguments are numeric, the return value is a scalar of numeric type,
4942 @code{INTEGER}, @code{REAL}, or @code{COMPLEX}. If the arguments are
4943 @code{LOGICAL}, the return value is @code{.TRUE.} or @code{.FALSE.}.
4944
4945 @item @emph{Example}:
4946 @smallexample
4947 program test_dot_prod
4948 integer, dimension(3) :: a, b
4949 a = (/ 1, 2, 3 /)
4950 b = (/ 4, 5, 6 /)
4951 print '(3i3)', a
4952 print *
4953 print '(3i3)', b
4954 print *
4955 print *, dot_product(a,b)
4956 end program test_dot_prod
4957 @end smallexample
4958 @end table
4959
4960
4961
4962 @node DPROD
4963 @section @code{DPROD} --- Double product function
4964 @fnindex DPROD
4965 @cindex product, double-precision
4966
4967 @table @asis
4968 @item @emph{Description}:
4969 @code{DPROD(X,Y)} returns the product @code{X*Y}.
4970
4971 @item @emph{Standard}:
4972 Fortran 77 and later
4973
4974 @item @emph{Class}:
4975 Elemental function
4976
4977 @item @emph{Syntax}:
4978 @code{RESULT = DPROD(X, Y)}
4979
4980 @item @emph{Arguments}:
4981 @multitable @columnfractions .15 .70
4982 @item @var{X} @tab The type shall be @code{REAL}.
4983 @item @var{Y} @tab The type shall be @code{REAL}.
4984 @end multitable
4985
4986 @item @emph{Return value}:
4987 The return value is of type @code{REAL(8)}.
4988
4989 @item @emph{Example}:
4990 @smallexample
4991 program test_dprod
4992 real :: x = 5.2
4993 real :: y = 2.3
4994 real(8) :: d
4995 d = dprod(x,y)
4996 print *, d
4997 end program test_dprod
4998 @end smallexample
4999
5000 @item @emph{Specific names}:
5001 @multitable @columnfractions .20 .20 .20 .25
5002 @item Name @tab Argument @tab Return type @tab Standard
5003 @item @code{DPROD(X,Y)} @tab @code{REAL(4) X, Y} @tab @code{REAL(8)} @tab Fortran 77 and later
5004 @end multitable
5005
5006 @end table
5007
5008
5009 @node DREAL
5010 @section @code{DREAL} --- Double real part function
5011 @fnindex DREAL
5012 @cindex complex numbers, real part
5013
5014 @table @asis
5015 @item @emph{Description}:
5016 @code{DREAL(Z)} returns the real part of complex variable @var{Z}.
5017
5018 @item @emph{Standard}:
5019 GNU extension
5020
5021 @item @emph{Class}:
5022 Elemental function
5023
5024 @item @emph{Syntax}:
5025 @code{RESULT = DREAL(A)}
5026
5027 @item @emph{Arguments}:
5028 @multitable @columnfractions .15 .70
5029 @item @var{A} @tab The type shall be @code{COMPLEX(8)}.
5030 @end multitable
5031
5032 @item @emph{Return value}:
5033 The return value is of type @code{REAL(8)}.
5034
5035 @item @emph{Example}:
5036 @smallexample
5037 program test_dreal
5038 complex(8) :: z = (1.3_8,7.2_8)
5039 print *, dreal(z)
5040 end program test_dreal
5041 @end smallexample
5042
5043 @item @emph{See also}:
5044 @ref{AIMAG}
5045
5046 @end table
5047
5048
5049
5050 @node DSHIFTL
5051 @section @code{DSHIFTL} --- Combined left shift
5052 @fnindex DSHIFTL
5053 @cindex left shift, combined
5054 @cindex shift, left
5055
5056 @table @asis
5057 @item @emph{Description}:
5058 @code{DSHIFTL(I, J, SHIFT)} combines bits of @var{I} and @var{J}. The
5059 rightmost @var{SHIFT} bits of the result are the leftmost @var{SHIFT}
5060 bits of @var{J}, and the remaining bits are the rightmost bits of
5061 @var{I}.
5062
5063 @item @emph{Standard}:
5064 Fortran 2008 and later
5065
5066 @item @emph{Class}:
5067 Elemental function
5068
5069 @item @emph{Syntax}:
5070 @code{RESULT = DSHIFTL(I, J, SHIFT)}
5071
5072 @item @emph{Arguments}:
5073 @multitable @columnfractions .15 .70
5074 @item @var{I} @tab Shall be of type @code{INTEGER} or a BOZ constant.
5075 @item @var{J} @tab Shall be of type @code{INTEGER} or a BOZ constant.
5076 If both @var{I} and @var{J} have integer type, then they shall have
5077 the same kind type parameter. @var{I} and @var{J} shall not both be
5078 BOZ constants.
5079 @item @var{SHIFT} @tab Shall be of type @code{INTEGER}. It shall
5080 be nonnegative. If @var{I} is not a BOZ constant, then @var{SHIFT}
5081 shall be less than or equal to @code{BIT_SIZE(I)}; otherwise,
5082 @var{SHIFT} shall be less than or equal to @code{BIT_SIZE(J)}.
5083 @end multitable
5084
5085 @item @emph{Return value}:
5086 If either @var{I} or @var{J} is a BOZ constant, it is first converted
5087 as if by the intrinsic function @code{INT} to an integer type with the
5088 kind type parameter of the other.
5089
5090 @item @emph{See also}:
5091 @ref{DSHIFTR}
5092 @end table
5093
5094
5095 @node DSHIFTR
5096 @section @code{DSHIFTR} --- Combined right shift
5097 @fnindex DSHIFTR
5098 @cindex right shift, combined
5099 @cindex shift, right
5100
5101 @table @asis
5102 @item @emph{Description}:
5103 @code{DSHIFTR(I, J, SHIFT)} combines bits of @var{I} and @var{J}. The
5104 leftmost @var{SHIFT} bits of the result are the rightmost @var{SHIFT}
5105 bits of @var{I}, and the remaining bits are the leftmost bits of
5106 @var{J}.
5107
5108 @item @emph{Standard}:
5109 Fortran 2008 and later
5110
5111 @item @emph{Class}:
5112 Elemental function
5113
5114 @item @emph{Syntax}:
5115 @code{RESULT = DSHIFTR(I, J, SHIFT)}
5116
5117 @item @emph{Arguments}:
5118 @multitable @columnfractions .15 .70
5119 @item @var{I} @tab Shall be of type @code{INTEGER} or a BOZ constant.
5120 @item @var{J} @tab Shall be of type @code{INTEGER} or a BOZ constant.
5121 If both @var{I} and @var{J} have integer type, then they shall have
5122 the same kind type parameter. @var{I} and @var{J} shall not both be
5123 BOZ constants.
5124 @item @var{SHIFT} @tab Shall be of type @code{INTEGER}. It shall
5125 be nonnegative. If @var{I} is not a BOZ constant, then @var{SHIFT}
5126 shall be less than or equal to @code{BIT_SIZE(I)}; otherwise,
5127 @var{SHIFT} shall be less than or equal to @code{BIT_SIZE(J)}.
5128 @end multitable
5129
5130 @item @emph{Return value}:
5131 If either @var{I} or @var{J} is a BOZ constant, it is first converted
5132 as if by the intrinsic function @code{INT} to an integer type with the
5133 kind type parameter of the other.
5134
5135 @item @emph{See also}:
5136 @ref{DSHIFTL}
5137 @end table
5138
5139
5140 @node DTIME
5141 @section @code{DTIME} --- Execution time subroutine (or function)
5142 @fnindex DTIME
5143 @cindex time, elapsed
5144 @cindex elapsed time
5145
5146 @table @asis
5147 @item @emph{Description}:
5148 @code{DTIME(VALUES, TIME)} initially returns the number of seconds of runtime
5149 since the start of the process's execution in @var{TIME}. @var{VALUES}
5150 returns the user and system components of this time in @code{VALUES(1)} and
5151 @code{VALUES(2)} respectively. @var{TIME} is equal to @code{VALUES(1) +
5152 VALUES(2)}.
5153
5154 Subsequent invocations of @code{DTIME} return values accumulated since the
5155 previous invocation.
5156
5157 On some systems, the underlying timings are represented using types with
5158 sufficiently small limits that overflows (wrap around) are possible, such as
5159 32-bit types. Therefore, the values returned by this intrinsic might be, or
5160 become, negative, or numerically less than previous values, during a single
5161 run of the compiled program.
5162
5163 Please note, that this implementation is thread safe if used within OpenMP
5164 directives, i.e., its state will be consistent while called from multiple
5165 threads. However, if @code{DTIME} is called from multiple threads, the result
5166 is still the time since the last invocation. This may not give the intended
5167 results. If possible, use @code{CPU_TIME} instead.
5168
5169 This intrinsic is provided in both subroutine and function forms; however,
5170 only one form can be used in any given program unit.
5171
5172 @var{VALUES} and @var{TIME} are @code{INTENT(OUT)} and provide the following:
5173
5174 @multitable @columnfractions .15 .30 .40
5175 @item @tab @code{VALUES(1)}: @tab User time in seconds.
5176 @item @tab @code{VALUES(2)}: @tab System time in seconds.
5177 @item @tab @code{TIME}: @tab Run time since start in seconds.
5178 @end multitable
5179
5180 @item @emph{Standard}:
5181 GNU extension
5182
5183 @item @emph{Class}:
5184 Subroutine, function
5185
5186 @item @emph{Syntax}:
5187 @multitable @columnfractions .80
5188 @item @code{CALL DTIME(VALUES, TIME)}.
5189 @item @code{TIME = DTIME(VALUES)}, (not recommended).
5190 @end multitable
5191
5192 @item @emph{Arguments}:
5193 @multitable @columnfractions .15 .70
5194 @item @var{VALUES}@tab The type shall be @code{REAL(4), DIMENSION(2)}.
5195 @item @var{TIME}@tab The type shall be @code{REAL(4)}.
5196 @end multitable
5197
5198 @item @emph{Return value}:
5199 Elapsed time in seconds since the last invocation or since the start of program
5200 execution if not called before.
5201
5202 @item @emph{Example}:
5203 @smallexample
5204 program test_dtime
5205 integer(8) :: i, j
5206 real, dimension(2) :: tarray
5207 real :: result
5208 call dtime(tarray, result)
5209 print *, result
5210 print *, tarray(1)
5211 print *, tarray(2)
5212 do i=1,100000000 ! Just a delay
5213 j = i * i - i
5214 end do
5215 call dtime(tarray, result)
5216 print *, result
5217 print *, tarray(1)
5218 print *, tarray(2)
5219 end program test_dtime
5220 @end smallexample
5221
5222 @item @emph{See also}:
5223 @ref{CPU_TIME}
5224
5225 @end table
5226
5227
5228
5229 @node EOSHIFT
5230 @section @code{EOSHIFT} --- End-off shift elements of an array
5231 @fnindex EOSHIFT
5232 @cindex array, shift
5233
5234 @table @asis
5235 @item @emph{Description}:
5236 @code{EOSHIFT(ARRAY, SHIFT[, BOUNDARY, DIM])} performs an end-off shift on
5237 elements of @var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is
5238 omitted it is taken to be @code{1}. @var{DIM} is a scalar of type
5239 @code{INTEGER} in the range of @math{1 \leq DIM \leq n)} where @math{n} is the
5240 rank of @var{ARRAY}. If the rank of @var{ARRAY} is one, then all elements of
5241 @var{ARRAY} are shifted by @var{SHIFT} places. If rank is greater than one,
5242 then all complete rank one sections of @var{ARRAY} along the given dimension are
5243 shifted. Elements shifted out one end of each rank one section are dropped. If
5244 @var{BOUNDARY} is present then the corresponding value of from @var{BOUNDARY}
5245 is copied back in the other end. If @var{BOUNDARY} is not present then the
5246 following are copied in depending on the type of @var{ARRAY}.
5247
5248 @multitable @columnfractions .15 .80
5249 @item @emph{Array Type} @tab @emph{Boundary Value}
5250 @item Numeric @tab 0 of the type and kind of @var{ARRAY}.
5251 @item Logical @tab @code{.FALSE.}.
5252 @item Character(@var{len}) @tab @var{len} blanks.
5253 @end multitable
5254
5255 @item @emph{Standard}:
5256 Fortran 95 and later
5257
5258 @item @emph{Class}:
5259 Transformational function
5260
5261 @item @emph{Syntax}:
5262 @code{RESULT = EOSHIFT(ARRAY, SHIFT [, BOUNDARY, DIM])}
5263
5264 @item @emph{Arguments}:
5265 @multitable @columnfractions .15 .70
5266 @item @var{ARRAY} @tab May be any type, not scalar.
5267 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
5268 @item @var{BOUNDARY} @tab Same type as @var{ARRAY}.
5269 @item @var{DIM} @tab The type shall be @code{INTEGER}.
5270 @end multitable
5271
5272 @item @emph{Return value}:
5273 Returns an array of same type and rank as the @var{ARRAY} argument.
5274
5275 @item @emph{Example}:
5276 @smallexample
5277 program test_eoshift
5278 integer, dimension(3,3) :: a
5279 a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
5280 print '(3i3)', a(1,:)
5281 print '(3i3)', a(2,:)
5282 print '(3i3)', a(3,:)
5283 a = EOSHIFT(a, SHIFT=(/1, 2, 1/), BOUNDARY=-5, DIM=2)
5284 print *
5285 print '(3i3)', a(1,:)
5286 print '(3i3)', a(2,:)
5287 print '(3i3)', a(3,:)
5288 end program test_eoshift
5289 @end smallexample
5290 @end table
5291
5292
5293
5294 @node EPSILON
5295 @section @code{EPSILON} --- Epsilon function
5296 @fnindex EPSILON
5297 @cindex model representation, epsilon
5298
5299 @table @asis
5300 @item @emph{Description}:
5301 @code{EPSILON(X)} returns the smallest number @var{E} of the same kind
5302 as @var{X} such that @math{1 + E > 1}.
5303
5304 @item @emph{Standard}:
5305 Fortran 95 and later
5306
5307 @item @emph{Class}:
5308 Inquiry function
5309
5310 @item @emph{Syntax}:
5311 @code{RESULT = EPSILON(X)}
5312
5313 @item @emph{Arguments}:
5314 @multitable @columnfractions .15 .70
5315 @item @var{X} @tab The type shall be @code{REAL}.
5316 @end multitable
5317
5318 @item @emph{Return value}:
5319 The return value is of same type as the argument.
5320
5321 @item @emph{Example}:
5322 @smallexample
5323 program test_epsilon
5324 real :: x = 3.143
5325 real(8) :: y = 2.33
5326 print *, EPSILON(x)
5327 print *, EPSILON(y)
5328 end program test_epsilon
5329 @end smallexample
5330 @end table
5331
5332
5333
5334 @node ERF
5335 @section @code{ERF} --- Error function
5336 @fnindex ERF
5337 @cindex error function
5338
5339 @table @asis
5340 @item @emph{Description}:
5341 @code{ERF(X)} computes the error function of @var{X}.
5342
5343 @item @emph{Standard}:
5344 Fortran 2008 and later
5345
5346 @item @emph{Class}:
5347 Elemental function
5348
5349 @item @emph{Syntax}:
5350 @code{RESULT = ERF(X)}
5351
5352 @item @emph{Arguments}:
5353 @multitable @columnfractions .15 .70
5354 @item @var{X} @tab The type shall be @code{REAL}.
5355 @end multitable
5356
5357 @item @emph{Return value}:
5358 The return value is of type @code{REAL}, of the same kind as
5359 @var{X} and lies in the range @math{-1 \leq erf (x) \leq 1 }.
5360
5361 @item @emph{Example}:
5362 @smallexample
5363 program test_erf
5364 real(8) :: x = 0.17_8
5365 x = erf(x)
5366 end program test_erf
5367 @end smallexample
5368
5369 @item @emph{Specific names}:
5370 @multitable @columnfractions .20 .20 .20 .25
5371 @item Name @tab Argument @tab Return type @tab Standard
5372 @item @code{DERF(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
5373 @end multitable
5374 @end table
5375
5376
5377
5378 @node ERFC
5379 @section @code{ERFC} --- Error function
5380 @fnindex ERFC
5381 @cindex error function, complementary
5382
5383 @table @asis
5384 @item @emph{Description}:
5385 @code{ERFC(X)} computes the complementary error function of @var{X}.
5386
5387 @item @emph{Standard}:
5388 Fortran 2008 and later
5389
5390 @item @emph{Class}:
5391 Elemental function
5392
5393 @item @emph{Syntax}:
5394 @code{RESULT = ERFC(X)}
5395
5396 @item @emph{Arguments}:
5397 @multitable @columnfractions .15 .70
5398 @item @var{X} @tab The type shall be @code{REAL}.
5399 @end multitable
5400
5401 @item @emph{Return value}:
5402 The return value is of type @code{REAL} and of the same kind as @var{X}.
5403 It lies in the range @math{ 0 \leq erfc (x) \leq 2 }.
5404
5405 @item @emph{Example}:
5406 @smallexample
5407 program test_erfc
5408 real(8) :: x = 0.17_8
5409 x = erfc(x)
5410 end program test_erfc
5411 @end smallexample
5412
5413 @item @emph{Specific names}:
5414 @multitable @columnfractions .20 .20 .20 .25
5415 @item Name @tab Argument @tab Return type @tab Standard
5416 @item @code{DERFC(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
5417 @end multitable
5418 @end table
5419
5420
5421
5422 @node ERFC_SCALED
5423 @section @code{ERFC_SCALED} --- Error function
5424 @fnindex ERFC_SCALED
5425 @cindex error function, complementary, exponentially-scaled
5426
5427 @table @asis
5428 @item @emph{Description}:
5429 @code{ERFC_SCALED(X)} computes the exponentially-scaled complementary
5430 error function of @var{X}.
5431
5432 @item @emph{Standard}:
5433 Fortran 2008 and later
5434
5435 @item @emph{Class}:
5436 Elemental function
5437
5438 @item @emph{Syntax}:
5439 @code{RESULT = ERFC_SCALED(X)}
5440
5441 @item @emph{Arguments}:
5442 @multitable @columnfractions .15 .70
5443 @item @var{X} @tab The type shall be @code{REAL}.
5444 @end multitable
5445
5446 @item @emph{Return value}:
5447 The return value is of type @code{REAL} and of the same kind as @var{X}.
5448
5449 @item @emph{Example}:
5450 @smallexample
5451 program test_erfc_scaled
5452 real(8) :: x = 0.17_8
5453 x = erfc_scaled(x)
5454 end program test_erfc_scaled
5455 @end smallexample
5456 @end table
5457
5458
5459
5460 @node ETIME
5461 @section @code{ETIME} --- Execution time subroutine (or function)
5462 @fnindex ETIME
5463 @cindex time, elapsed
5464
5465 @table @asis
5466 @item @emph{Description}:
5467 @code{ETIME(VALUES, TIME)} returns the number of seconds of runtime
5468 since the start of the process's execution in @var{TIME}. @var{VALUES}
5469 returns the user and system components of this time in @code{VALUES(1)} and
5470 @code{VALUES(2)} respectively. @var{TIME} is equal to @code{VALUES(1) + VALUES(2)}.
5471
5472 On some systems, the underlying timings are represented using types with
5473 sufficiently small limits that overflows (wrap around) are possible, such as
5474 32-bit types. Therefore, the values returned by this intrinsic might be, or
5475 become, negative, or numerically less than previous values, during a single
5476 run of the compiled program.
5477
5478 This intrinsic is provided in both subroutine and function forms; however,
5479 only one form can be used in any given program unit.
5480
5481 @var{VALUES} and @var{TIME} are @code{INTENT(OUT)} and provide the following:
5482
5483 @multitable @columnfractions .15 .30 .60
5484 @item @tab @code{VALUES(1)}: @tab User time in seconds.
5485 @item @tab @code{VALUES(2)}: @tab System time in seconds.
5486 @item @tab @code{TIME}: @tab Run time since start in seconds.
5487 @end multitable
5488
5489 @item @emph{Standard}:
5490 GNU extension
5491
5492 @item @emph{Class}:
5493 Subroutine, function
5494
5495 @item @emph{Syntax}:
5496 @multitable @columnfractions .80
5497 @item @code{CALL ETIME(VALUES, TIME)}.
5498 @item @code{TIME = ETIME(VALUES)}, (not recommended).
5499 @end multitable
5500
5501 @item @emph{Arguments}:
5502 @multitable @columnfractions .15 .70
5503 @item @var{VALUES}@tab The type shall be @code{REAL(4), DIMENSION(2)}.
5504 @item @var{TIME}@tab The type shall be @code{REAL(4)}.
5505 @end multitable
5506
5507 @item @emph{Return value}:
5508 Elapsed time in seconds since the start of program execution.
5509
5510 @item @emph{Example}:
5511 @smallexample
5512 program test_etime
5513 integer(8) :: i, j
5514 real, dimension(2) :: tarray
5515 real :: result
5516 call ETIME(tarray, result)
5517 print *, result
5518 print *, tarray(1)
5519 print *, tarray(2)
5520 do i=1,100000000 ! Just a delay
5521 j = i * i - i
5522 end do
5523 call ETIME(tarray, result)
5524 print *, result
5525 print *, tarray(1)
5526 print *, tarray(2)
5527 end program test_etime
5528 @end smallexample
5529
5530 @item @emph{See also}:
5531 @ref{CPU_TIME}
5532
5533 @end table
5534
5535
5536
5537 @node EVENT_QUERY
5538 @section @code{EVENT_QUERY} --- Query whether a coarray event has occurred
5539 @fnindex EVENT_QUERY
5540 @cindex Events, EVENT_QUERY
5541
5542 @table @asis
5543 @item @emph{Description}:
5544 @code{EVENT_QUERY} assignes the number of events to @var{COUNT} which have been
5545 posted to the @var{EVENT} variable and not yet been removed by calling
5546 @code{EVENT WAIT}. When @var{STAT} is present and the invocation was successful,
5547 it is assigned the value 0. If it is present and the invocation has failed,
5548 it is assigned a positive value and @var{COUNT} is assigned the value @math{-1}.
5549
5550 @item @emph{Standard}:
5551 TS 18508 or later
5552
5553 @item @emph{Class}:
5554 subroutine
5555
5556 @item @emph{Syntax}:
5557 @code{CALL EVENT_QUERY (EVENT, COUNT [, STAT])}
5558
5559 @item @emph{Arguments}:
5560 @multitable @columnfractions .15 .70
5561 @item @var{EVENT} @tab (intent(IN)) Scalar of type @code{EVENT_TYPE},
5562 defined in @code{ISO_FORTRAN_ENV}; shall not be coindexed.
5563 @item @var{COUNT} @tab (intent(out))Scalar integer with at least the
5564 precision of default integer.
5565 @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
5566 @end multitable
5567
5568 @item @emph{Example}:
5569 @smallexample
5570 program atomic
5571 use iso_fortran_env
5572 implicit none
5573 type(event_type) :: event_value_has_been_set[*]
5574 integer :: cnt
5575 if (this_image() == 1) then
5576 call event_query (event_value_has_been_set, cnt)
5577 if (cnt > 0) write(*,*) "Value has been set"
5578 elseif (this_image() == 2) then
5579 event post (event_value_has_been_set[1])
5580 end if
5581 end program atomic
5582 @end smallexample
5583
5584 @end table
5585
5586
5587
5588 @node EXECUTE_COMMAND_LINE
5589 @section @code{EXECUTE_COMMAND_LINE} --- Execute a shell command
5590 @fnindex EXECUTE_COMMAND_LINE
5591 @cindex system, system call
5592 @cindex command line
5593
5594 @table @asis
5595 @item @emph{Description}:
5596 @code{EXECUTE_COMMAND_LINE} runs a shell command, synchronously or
5597 asynchronously.
5598
5599 The @code{COMMAND} argument is passed to the shell and executed, using
5600 the C library's @code{system} call. (The shell is @code{sh} on Unix
5601 systems, and @code{cmd.exe} on Windows.) If @code{WAIT} is present
5602 and has the value false, the execution of the command is asynchronous
5603 if the system supports it; otherwise, the command is executed
5604 synchronously.
5605
5606 The three last arguments allow the user to get status information. After
5607 synchronous execution, @code{EXITSTAT} contains the integer exit code of
5608 the command, as returned by @code{system}. @code{CMDSTAT} is set to zero
5609 if the command line was executed (whatever its exit status was).
5610 @code{CMDMSG} is assigned an error message if an error has occurred.
5611
5612 Note that the @code{system} function need not be thread-safe. It is
5613 the responsibility of the user to ensure that @code{system} is not
5614 called concurrently.
5615
5616 @item @emph{Standard}:
5617 Fortran 2008 and later
5618
5619 @item @emph{Class}:
5620 Subroutine
5621
5622 @item @emph{Syntax}:
5623 @code{CALL EXECUTE_COMMAND_LINE(COMMAND [, WAIT, EXITSTAT, CMDSTAT, CMDMSG ])}
5624
5625 @item @emph{Arguments}:
5626 @multitable @columnfractions .15 .70
5627 @item @var{COMMAND} @tab Shall be a default @code{CHARACTER} scalar.
5628 @item @var{WAIT} @tab (Optional) Shall be a default @code{LOGICAL} scalar.
5629 @item @var{EXITSTAT} @tab (Optional) Shall be an @code{INTEGER} of the
5630 default kind.
5631 @item @var{CMDSTAT} @tab (Optional) Shall be an @code{INTEGER} of the
5632 default kind.
5633 @item @var{CMDMSG} @tab (Optional) Shall be an @code{CHARACTER} scalar of the
5634 default kind.
5635 @end multitable
5636
5637 @item @emph{Example}:
5638 @smallexample
5639 program test_exec
5640 integer :: i
5641
5642 call execute_command_line ("external_prog.exe", exitstat=i)
5643 print *, "Exit status of external_prog.exe was ", i
5644
5645 call execute_command_line ("reindex_files.exe", wait=.false.)
5646 print *, "Now reindexing files in the background"
5647
5648 end program test_exec
5649 @end smallexample
5650
5651
5652 @item @emph{Note}:
5653
5654 Because this intrinsic is implemented in terms of the @code{system}
5655 function call, its behavior with respect to signaling is processor
5656 dependent. In particular, on POSIX-compliant systems, the SIGINT and
5657 SIGQUIT signals will be ignored, and the SIGCHLD will be blocked. As
5658 such, if the parent process is terminated, the child process might not be
5659 terminated alongside.
5660
5661
5662 @item @emph{See also}:
5663 @ref{SYSTEM}
5664 @end table
5665
5666
5667
5668 @node EXIT
5669 @section @code{EXIT} --- Exit the program with status.
5670 @fnindex EXIT
5671 @cindex program termination
5672 @cindex terminate program
5673
5674 @table @asis
5675 @item @emph{Description}:
5676 @code{EXIT} causes immediate termination of the program with status. If status
5677 is omitted it returns the canonical @emph{success} for the system. All Fortran
5678 I/O units are closed.
5679
5680 @item @emph{Standard}:
5681 GNU extension
5682
5683 @item @emph{Class}:
5684 Subroutine
5685
5686 @item @emph{Syntax}:
5687 @code{CALL EXIT([STATUS])}
5688
5689 @item @emph{Arguments}:
5690 @multitable @columnfractions .15 .70
5691 @item @var{STATUS} @tab Shall be an @code{INTEGER} of the default kind.
5692 @end multitable
5693
5694 @item @emph{Return value}:
5695 @code{STATUS} is passed to the parent process on exit.
5696
5697 @item @emph{Example}:
5698 @smallexample
5699 program test_exit
5700 integer :: STATUS = 0
5701 print *, 'This program is going to exit.'
5702 call EXIT(STATUS)
5703 end program test_exit
5704 @end smallexample
5705
5706 @item @emph{See also}:
5707 @ref{ABORT}, @ref{KILL}
5708 @end table
5709
5710
5711
5712 @node EXP
5713 @section @code{EXP} --- Exponential function
5714 @fnindex EXP
5715 @fnindex DEXP
5716 @fnindex CEXP
5717 @fnindex ZEXP
5718 @fnindex CDEXP
5719 @cindex exponential function
5720 @cindex logarithm function, inverse
5721
5722 @table @asis
5723 @item @emph{Description}:
5724 @code{EXP(X)} computes the base @math{e} exponential of @var{X}.
5725
5726 @item @emph{Standard}:
5727 Fortran 77 and later, has overloads that are GNU extensions
5728
5729 @item @emph{Class}:
5730 Elemental function
5731
5732 @item @emph{Syntax}:
5733 @code{RESULT = EXP(X)}
5734
5735 @item @emph{Arguments}:
5736 @multitable @columnfractions .15 .70
5737 @item @var{X} @tab The type shall be @code{REAL} or
5738 @code{COMPLEX}.
5739 @end multitable
5740
5741 @item @emph{Return value}:
5742 The return value has same type and kind as @var{X}.
5743
5744 @item @emph{Example}:
5745 @smallexample
5746 program test_exp
5747 real :: x = 1.0
5748 x = exp(x)
5749 end program test_exp
5750 @end smallexample
5751
5752 @item @emph{Specific names}:
5753 @multitable @columnfractions .20 .20 .20 .25
5754 @item Name @tab Argument @tab Return type @tab Standard
5755 @item @code{EXP(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later
5756 @item @code{DEXP(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
5757 @item @code{CEXP(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab Fortran 77 and later
5758 @item @code{ZEXP(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
5759 @item @code{CDEXP(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
5760 @end multitable
5761 @end table
5762
5763
5764
5765 @node EXPONENT
5766 @section @code{EXPONENT} --- Exponent function
5767 @fnindex EXPONENT
5768 @cindex real number, exponent
5769 @cindex floating point, exponent
5770
5771 @table @asis
5772 @item @emph{Description}:
5773 @code{EXPONENT(X)} returns the value of the exponent part of @var{X}. If @var{X}
5774 is zero the value returned is zero.
5775
5776 @item @emph{Standard}:
5777 Fortran 95 and later
5778
5779 @item @emph{Class}:
5780 Elemental function
5781
5782 @item @emph{Syntax}:
5783 @code{RESULT = EXPONENT(X)}
5784
5785 @item @emph{Arguments}:
5786 @multitable @columnfractions .15 .70
5787 @item @var{X} @tab The type shall be @code{REAL}.
5788 @end multitable
5789
5790 @item @emph{Return value}:
5791 The return value is of type default @code{INTEGER}.
5792
5793 @item @emph{Example}:
5794 @smallexample
5795 program test_exponent
5796 real :: x = 1.0
5797 integer :: i
5798 i = exponent(x)
5799 print *, i
5800 print *, exponent(0.0)
5801 end program test_exponent
5802 @end smallexample
5803 @end table
5804
5805
5806
5807 @node EXTENDS_TYPE_OF
5808 @section @code{EXTENDS_TYPE_OF} --- Query dynamic type for extension
5809 @fnindex EXTENDS_TYPE_OF
5810
5811 @table @asis
5812 @item @emph{Description}:
5813 Query dynamic type for extension.
5814
5815 @item @emph{Standard}:
5816 Fortran 2003 and later
5817
5818 @item @emph{Class}:
5819 Inquiry function
5820
5821 @item @emph{Syntax}:
5822 @code{RESULT = EXTENDS_TYPE_OF(A, MOLD)}
5823
5824 @item @emph{Arguments}:
5825 @multitable @columnfractions .15 .70
5826 @item @var{A} @tab Shall be an object of extensible declared type or
5827 unlimited polymorphic.
5828 @item @var{MOLD} @tab Shall be an object of extensible declared type or
5829 unlimited polymorphic.
5830 @end multitable
5831
5832 @item @emph{Return value}:
5833 The return value is a scalar of type default logical. It is true if and only if
5834 the dynamic type of A is an extension type of the dynamic type of MOLD.
5835
5836
5837 @item @emph{See also}:
5838 @ref{SAME_TYPE_AS}
5839 @end table
5840
5841
5842
5843 @node FDATE
5844 @section @code{FDATE} --- Get the current time as a string
5845 @fnindex FDATE
5846 @cindex time, current
5847 @cindex current time
5848 @cindex date, current
5849 @cindex current date
5850
5851 @table @asis
5852 @item @emph{Description}:
5853 @code{FDATE(DATE)} returns the current date (using the same format as
5854 @ref{CTIME}) in @var{DATE}. It is equivalent to @code{CALL CTIME(DATE,
5855 TIME())}.
5856
5857 This intrinsic is provided in both subroutine and function forms; however,
5858 only one form can be used in any given program unit.
5859
5860 @item @emph{Standard}:
5861 GNU extension
5862
5863 @item @emph{Class}:
5864 Subroutine, function
5865
5866 @item @emph{Syntax}:
5867 @multitable @columnfractions .80
5868 @item @code{CALL FDATE(DATE)}.
5869 @item @code{DATE = FDATE()}.
5870 @end multitable
5871
5872 @item @emph{Arguments}:
5873 @multitable @columnfractions .15 .70
5874 @item @var{DATE}@tab The type shall be of type @code{CHARACTER} of the
5875 default kind. It is an @code{INTENT(OUT)} argument. If the length of
5876 this variable is too short for the date and time string to fit
5877 completely, it will be blank on procedure return.
5878 @end multitable
5879
5880 @item @emph{Return value}:
5881 The current date and time as a string.
5882
5883 @item @emph{Example}:
5884 @smallexample
5885 program test_fdate
5886 integer(8) :: i, j
5887 character(len=30) :: date
5888 call fdate(date)
5889 print *, 'Program started on ', date
5890 do i = 1, 100000000 ! Just a delay
5891 j = i * i - i
5892 end do
5893 call fdate(date)
5894 print *, 'Program ended on ', date
5895 end program test_fdate
5896 @end smallexample
5897
5898 @item @emph{See also}:
5899 @ref{DATE_AND_TIME}, @ref{CTIME}
5900 @end table
5901
5902
5903 @node FGET
5904 @section @code{FGET} --- Read a single character in stream mode from stdin
5905 @fnindex FGET
5906 @cindex read character, stream mode
5907 @cindex stream mode, read character
5908 @cindex file operation, read character
5909
5910 @table @asis
5911 @item @emph{Description}:
5912 Read a single character in stream mode from stdin by bypassing normal
5913 formatted output. Stream I/O should not be mixed with normal record-oriented
5914 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
5915
5916 This intrinsic is provided in both subroutine and function forms; however,
5917 only one form can be used in any given program unit.
5918
5919 Note that the @code{FGET} intrinsic is provided for backwards compatibility with
5920 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
5921 Programmers should consider the use of new stream IO feature in new code
5922 for future portability. See also @ref{Fortran 2003 status}.
5923
5924 @item @emph{Standard}:
5925 GNU extension
5926
5927 @item @emph{Class}:
5928 Subroutine, function
5929
5930 @item @emph{Syntax}:
5931 @multitable @columnfractions .80
5932 @item @code{CALL FGET(C [, STATUS])}
5933 @item @code{STATUS = FGET(C)}
5934 @end multitable
5935
5936 @item @emph{Arguments}:
5937 @multitable @columnfractions .15 .70
5938 @item @var{C} @tab The type shall be @code{CHARACTER} and of default
5939 kind.
5940 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
5941 Returns 0 on success, -1 on end-of-file, and a system specific positive
5942 error code otherwise.
5943 @end multitable
5944
5945 @item @emph{Example}:
5946 @smallexample
5947 PROGRAM test_fget
5948 INTEGER, PARAMETER :: strlen = 100
5949 INTEGER :: status, i = 1
5950 CHARACTER(len=strlen) :: str = ""
5951
5952 WRITE (*,*) 'Enter text:'
5953 DO
5954 CALL fget(str(i:i), status)
5955 if (status /= 0 .OR. i > strlen) exit
5956 i = i + 1
5957 END DO
5958 WRITE (*,*) TRIM(str)
5959 END PROGRAM
5960 @end smallexample
5961
5962 @item @emph{See also}:
5963 @ref{FGETC}, @ref{FPUT}, @ref{FPUTC}
5964 @end table
5965
5966
5967
5968 @node FGETC
5969 @section @code{FGETC} --- Read a single character in stream mode
5970 @fnindex FGETC
5971 @cindex read character, stream mode
5972 @cindex stream mode, read character
5973 @cindex file operation, read character
5974
5975 @table @asis
5976 @item @emph{Description}:
5977 Read a single character in stream mode by bypassing normal formatted output.
5978 Stream I/O should not be mixed with normal record-oriented (formatted or
5979 unformatted) I/O on the same unit; the results are unpredictable.
5980
5981 This intrinsic is provided in both subroutine and function forms; however,
5982 only one form can be used in any given program unit.
5983
5984 Note that the @code{FGET} intrinsic is provided for backwards compatibility
5985 with @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
5986 Programmers should consider the use of new stream IO feature in new code
5987 for future portability. See also @ref{Fortran 2003 status}.
5988
5989 @item @emph{Standard}:
5990 GNU extension
5991
5992 @item @emph{Class}:
5993 Subroutine, function
5994
5995 @item @emph{Syntax}:
5996 @multitable @columnfractions .80
5997 @item @code{CALL FGETC(UNIT, C [, STATUS])}
5998 @item @code{STATUS = FGETC(UNIT, C)}
5999 @end multitable
6000
6001 @item @emph{Arguments}:
6002 @multitable @columnfractions .15 .70
6003 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
6004 @item @var{C} @tab The type shall be @code{CHARACTER} and of default
6005 kind.
6006 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
6007 Returns 0 on success, -1 on end-of-file and a system specific positive
6008 error code otherwise.
6009 @end multitable
6010
6011 @item @emph{Example}:
6012 @smallexample
6013 PROGRAM test_fgetc
6014 INTEGER :: fd = 42, status
6015 CHARACTER :: c
6016
6017 OPEN(UNIT=fd, FILE="/etc/passwd", ACTION="READ", STATUS = "OLD")
6018 DO
6019 CALL fgetc(fd, c, status)
6020 IF (status /= 0) EXIT
6021 call fput(c)
6022 END DO
6023 CLOSE(UNIT=fd)
6024 END PROGRAM
6025 @end smallexample
6026
6027 @item @emph{See also}:
6028 @ref{FGET}, @ref{FPUT}, @ref{FPUTC}
6029 @end table
6030
6031 @node FINDLOC
6032 @section @code{FINDLOC} --- Search an array for a value
6033 @fnindex FINDLOC
6034 @cindex findloc
6035
6036 @table @asis
6037 @item @emph{Description}:
6038 Determines the location of the element in the array with the value
6039 given in the @var{VALUE} argument, or, if the @var{DIM} argument is
6040 supplied, determines the locations of the maximum element along each
6041 row of the array in the @var{DIM} direction. If @var{MASK} is
6042 present, only the elements for which @var{MASK} is @code{.TRUE.} are
6043 considered. If more than one element in the array has the value
6044 @var{VALUE}, the location returned is that of the first such element
6045 in array element order if the @var{BACK} is not present or if it is
6046 @code{.FALSE.}. If @var{BACK} is true, the location returned is that
6047 of the last such element. If the array has zero size, or all of the
6048 elements of @var{MASK} are @code{.FALSE.}, then the result is an array
6049 of zeroes. Similarly, if @var{DIM} is supplied and all of the
6050 elements of @var{MASK} along a given row are zero, the result value
6051 for that row is zero.
6052
6053 @item @emph{Standard}:
6054 Fortran 2008 and later.
6055
6056 @item @emph{Class}:
6057 Transformational function
6058
6059 @item @emph{Syntax}:
6060 @multitable @columnfractions .80
6061 @item @code{RESULT = FINDLOC(ARRAY, VALUE, DIM [, MASK] [,KIND] [,BACK])}
6062 @item @code{RESULT = FINDLOC(ARRAY, VALUE, [, MASK] [,KIND] [,BACK])}
6063 @end multitable
6064
6065 @item @emph{Arguments}:
6066 @multitable @columnfractions .15 .70
6067 @item @var{ARRAY} @tab Shall be an array of intrinsic type.
6068 @item @var{VALUE} @tab A scalar of intrinsic type which is in type
6069 conformance with @var{ARRAY}.
6070 @item @var{DIM} @tab (Optional) Shall be a scalar of type
6071 @code{INTEGER}, with a value between one and the rank of @var{ARRAY},
6072 inclusive. It may not be an optional dummy argument.
6073 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
6074 expression indicating the kind parameter of the result.
6075 @item @var{BACK} @tab (Optional) A scalar of type @code{LOGICAL}.
6076 @end multitable
6077
6078 @item @emph{Return value}:
6079 If @var{DIM} is absent, the result is a rank-one array with a length
6080 equal to the rank of @var{ARRAY}. If @var{DIM} is present, the result
6081 is an array with a rank one less than the rank of @var{ARRAY}, and a
6082 size corresponding to the size of @var{ARRAY} with the @var{DIM}
6083 dimension removed. If @var{DIM} is present and @var{ARRAY} has a rank
6084 of one, the result is a scalar. If the optional argument @var{KIND}
6085 is present, the result is an integer of kind @var{KIND}, otherwise it
6086 is of default kind.
6087
6088 @item @emph{See also}:
6089 @ref{MAXLOC}, @ref{MINLOC}
6090
6091 @end table
6092
6093 @node FLOOR
6094 @section @code{FLOOR} --- Integer floor function
6095 @fnindex FLOOR
6096 @cindex floor
6097 @cindex rounding, floor
6098
6099 @table @asis
6100 @item @emph{Description}:
6101 @code{FLOOR(A)} returns the greatest integer less than or equal to @var{X}.
6102
6103 @item @emph{Standard}:
6104 Fortran 95 and later
6105
6106 @item @emph{Class}:
6107 Elemental function
6108
6109 @item @emph{Syntax}:
6110 @code{RESULT = FLOOR(A [, KIND])}
6111
6112 @item @emph{Arguments}:
6113 @multitable @columnfractions .15 .70
6114 @item @var{A} @tab The type shall be @code{REAL}.
6115 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
6116 expression indicating the kind parameter of the result.
6117 @end multitable
6118
6119 @item @emph{Return value}:
6120 The return value is of type @code{INTEGER(KIND)} if @var{KIND} is present
6121 and of default-kind @code{INTEGER} otherwise.
6122
6123 @item @emph{Example}:
6124 @smallexample
6125 program test_floor
6126 real :: x = 63.29
6127 real :: y = -63.59
6128 print *, floor(x) ! returns 63
6129 print *, floor(y) ! returns -64
6130 end program test_floor
6131 @end smallexample
6132
6133 @item @emph{See also}:
6134 @ref{CEILING}, @ref{NINT}
6135
6136 @end table
6137
6138
6139
6140 @node FLUSH
6141 @section @code{FLUSH} --- Flush I/O unit(s)
6142 @fnindex FLUSH
6143 @cindex file operation, flush
6144
6145 @table @asis
6146 @item @emph{Description}:
6147 Flushes Fortran unit(s) currently open for output. Without the optional
6148 argument, all units are flushed, otherwise just the unit specified.
6149
6150 @item @emph{Standard}:
6151 GNU extension
6152
6153 @item @emph{Class}:
6154 Subroutine
6155
6156 @item @emph{Syntax}:
6157 @code{CALL FLUSH(UNIT)}
6158
6159 @item @emph{Arguments}:
6160 @multitable @columnfractions .15 .70
6161 @item @var{UNIT} @tab (Optional) The type shall be @code{INTEGER}.
6162 @end multitable
6163
6164 @item @emph{Note}:
6165 Beginning with the Fortran 2003 standard, there is a @code{FLUSH}
6166 statement that should be preferred over the @code{FLUSH} intrinsic.
6167
6168 The @code{FLUSH} intrinsic and the Fortran 2003 @code{FLUSH} statement
6169 have identical effect: they flush the runtime library's I/O buffer so
6170 that the data becomes visible to other processes. This does not guarantee
6171 that the data is committed to disk.
6172
6173 On POSIX systems, you can request that all data is transferred to the
6174 storage device by calling the @code{fsync} function, with the POSIX file
6175 descriptor of the I/O unit as argument (retrieved with GNU intrinsic
6176 @code{FNUM}). The following example shows how:
6177
6178 @smallexample
6179 ! Declare the interface for POSIX fsync function
6180 interface
6181 function fsync (fd) bind(c,name="fsync")
6182 use iso_c_binding, only: c_int
6183 integer(c_int), value :: fd
6184 integer(c_int) :: fsync
6185 end function fsync
6186 end interface
6187
6188 ! Variable declaration
6189 integer :: ret
6190
6191 ! Opening unit 10
6192 open (10,file="foo")
6193
6194 ! ...
6195 ! Perform I/O on unit 10
6196 ! ...
6197
6198 ! Flush and sync
6199 flush(10)
6200 ret = fsync(fnum(10))
6201
6202 ! Handle possible error
6203 if (ret /= 0) stop "Error calling FSYNC"
6204 @end smallexample
6205
6206 @end table
6207
6208
6209
6210 @node FNUM
6211 @section @code{FNUM} --- File number function
6212 @fnindex FNUM
6213 @cindex file operation, file number
6214
6215 @table @asis
6216 @item @emph{Description}:
6217 @code{FNUM(UNIT)} returns the POSIX file descriptor number corresponding to the
6218 open Fortran I/O unit @code{UNIT}.
6219
6220 @item @emph{Standard}:
6221 GNU extension
6222
6223 @item @emph{Class}:
6224 Function
6225
6226 @item @emph{Syntax}:
6227 @code{RESULT = FNUM(UNIT)}
6228
6229 @item @emph{Arguments}:
6230 @multitable @columnfractions .15 .70
6231 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
6232 @end multitable
6233
6234 @item @emph{Return value}:
6235 The return value is of type @code{INTEGER}
6236
6237 @item @emph{Example}:
6238 @smallexample
6239 program test_fnum
6240 integer :: i
6241 open (unit=10, status = "scratch")
6242 i = fnum(10)
6243 print *, i
6244 close (10)
6245 end program test_fnum
6246 @end smallexample
6247 @end table
6248
6249
6250
6251 @node FPUT
6252 @section @code{FPUT} --- Write a single character in stream mode to stdout
6253 @fnindex FPUT
6254 @cindex write character, stream mode
6255 @cindex stream mode, write character
6256 @cindex file operation, write character
6257
6258 @table @asis
6259 @item @emph{Description}:
6260 Write a single character in stream mode to stdout by bypassing normal
6261 formatted output. Stream I/O should not be mixed with normal record-oriented
6262 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
6263
6264 This intrinsic is provided in both subroutine and function forms; however,
6265 only one form can be used in any given program unit.
6266
6267 Note that the @code{FGET} intrinsic is provided for backwards compatibility with
6268 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
6269 Programmers should consider the use of new stream IO feature in new code
6270 for future portability. See also @ref{Fortran 2003 status}.
6271
6272 @item @emph{Standard}:
6273 GNU extension
6274
6275 @item @emph{Class}:
6276 Subroutine, function
6277
6278 @item @emph{Syntax}:
6279 @multitable @columnfractions .80
6280 @item @code{CALL FPUT(C [, STATUS])}
6281 @item @code{STATUS = FPUT(C)}
6282 @end multitable
6283
6284 @item @emph{Arguments}:
6285 @multitable @columnfractions .15 .70
6286 @item @var{C} @tab The type shall be @code{CHARACTER} and of default
6287 kind.
6288 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
6289 Returns 0 on success, -1 on end-of-file and a system specific positive
6290 error code otherwise.
6291 @end multitable
6292
6293 @item @emph{Example}:
6294 @smallexample
6295 PROGRAM test_fput
6296 CHARACTER(len=10) :: str = "gfortran"
6297 INTEGER :: i
6298 DO i = 1, len_trim(str)
6299 CALL fput(str(i:i))
6300 END DO
6301 END PROGRAM
6302 @end smallexample
6303
6304 @item @emph{See also}:
6305 @ref{FPUTC}, @ref{FGET}, @ref{FGETC}
6306 @end table
6307
6308
6309
6310 @node FPUTC
6311 @section @code{FPUTC} --- Write a single character in stream mode
6312 @fnindex FPUTC
6313 @cindex write character, stream mode
6314 @cindex stream mode, write character
6315 @cindex file operation, write character
6316
6317 @table @asis
6318 @item @emph{Description}:
6319 Write a single character in stream mode by bypassing normal formatted
6320 output. Stream I/O should not be mixed with normal record-oriented
6321 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
6322
6323 This intrinsic is provided in both subroutine and function forms; however,
6324 only one form can be used in any given program unit.
6325
6326 Note that the @code{FGET} intrinsic is provided for backwards compatibility with
6327 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
6328 Programmers should consider the use of new stream IO feature in new code
6329 for future portability. See also @ref{Fortran 2003 status}.
6330
6331 @item @emph{Standard}:
6332 GNU extension
6333
6334 @item @emph{Class}:
6335 Subroutine, function
6336
6337 @item @emph{Syntax}:
6338 @multitable @columnfractions .80
6339 @item @code{CALL FPUTC(UNIT, C [, STATUS])}
6340 @item @code{STATUS = FPUTC(UNIT, C)}
6341 @end multitable
6342
6343 @item @emph{Arguments}:
6344 @multitable @columnfractions .15 .70
6345 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
6346 @item @var{C} @tab The type shall be @code{CHARACTER} and of default
6347 kind.
6348 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
6349 Returns 0 on success, -1 on end-of-file and a system specific positive
6350 error code otherwise.
6351 @end multitable
6352
6353 @item @emph{Example}:
6354 @smallexample
6355 PROGRAM test_fputc
6356 CHARACTER(len=10) :: str = "gfortran"
6357 INTEGER :: fd = 42, i
6358
6359 OPEN(UNIT = fd, FILE = "out", ACTION = "WRITE", STATUS="NEW")
6360 DO i = 1, len_trim(str)
6361 CALL fputc(fd, str(i:i))
6362 END DO
6363 CLOSE(fd)
6364 END PROGRAM
6365 @end smallexample
6366
6367 @item @emph{See also}:
6368 @ref{FPUT}, @ref{FGET}, @ref{FGETC}
6369 @end table
6370
6371
6372
6373 @node FRACTION
6374 @section @code{FRACTION} --- Fractional part of the model representation
6375 @fnindex FRACTION
6376 @cindex real number, fraction
6377 @cindex floating point, fraction
6378
6379 @table @asis
6380 @item @emph{Description}:
6381 @code{FRACTION(X)} returns the fractional part of the model
6382 representation of @code{X}.
6383
6384 @item @emph{Standard}:
6385 Fortran 95 and later
6386
6387 @item @emph{Class}:
6388 Elemental function
6389
6390 @item @emph{Syntax}:
6391 @code{Y = FRACTION(X)}
6392
6393 @item @emph{Arguments}:
6394 @multitable @columnfractions .15 .70
6395 @item @var{X} @tab The type of the argument shall be a @code{REAL}.
6396 @end multitable
6397
6398 @item @emph{Return value}:
6399 The return value is of the same type and kind as the argument.
6400 The fractional part of the model representation of @code{X} is returned;
6401 it is @code{X * RADIX(X)**(-EXPONENT(X))}.
6402
6403 @item @emph{Example}:
6404 @smallexample
6405 program test_fraction
6406 real :: x
6407 x = 178.1387e-4
6408 print *, fraction(x), x * radix(x)**(-exponent(x))
6409 end program test_fraction
6410 @end smallexample
6411
6412 @end table
6413
6414
6415
6416 @node FREE
6417 @section @code{FREE} --- Frees memory
6418 @fnindex FREE
6419 @cindex pointer, cray
6420
6421 @table @asis
6422 @item @emph{Description}:
6423 Frees memory previously allocated by @code{MALLOC}. The @code{FREE}
6424 intrinsic is an extension intended to be used with Cray pointers, and is
6425 provided in GNU Fortran to allow user to compile legacy code. For
6426 new code using Fortran 95 pointers, the memory de-allocation intrinsic is
6427 @code{DEALLOCATE}.
6428
6429 @item @emph{Standard}:
6430 GNU extension
6431
6432 @item @emph{Class}:
6433 Subroutine
6434
6435 @item @emph{Syntax}:
6436 @code{CALL FREE(PTR)}
6437
6438 @item @emph{Arguments}:
6439 @multitable @columnfractions .15 .70
6440 @item @var{PTR} @tab The type shall be @code{INTEGER}. It represents the
6441 location of the memory that should be de-allocated.
6442 @end multitable
6443
6444 @item @emph{Return value}:
6445 None
6446
6447 @item @emph{Example}:
6448 See @code{MALLOC} for an example.
6449
6450 @item @emph{See also}:
6451 @ref{MALLOC}
6452 @end table
6453
6454
6455
6456 @node FSEEK
6457 @section @code{FSEEK} --- Low level file positioning subroutine
6458 @fnindex FSEEK
6459 @cindex file operation, seek
6460 @cindex file operation, position
6461
6462 @table @asis
6463 @item @emph{Description}:
6464 Moves @var{UNIT} to the specified @var{OFFSET}. If @var{WHENCE}
6465 is set to 0, the @var{OFFSET} is taken as an absolute value @code{SEEK_SET},
6466 if set to 1, @var{OFFSET} is taken to be relative to the current position
6467 @code{SEEK_CUR}, and if set to 2 relative to the end of the file @code{SEEK_END}.
6468 On error, @var{STATUS} is set to a nonzero value. If @var{STATUS} the seek
6469 fails silently.
6470
6471 This intrinsic routine is not fully backwards compatible with @command{g77}.
6472 In @command{g77}, the @code{FSEEK} takes a statement label instead of a
6473 @var{STATUS} variable. If FSEEK is used in old code, change
6474 @smallexample
6475 CALL FSEEK(UNIT, OFFSET, WHENCE, *label)
6476 @end smallexample
6477 to
6478 @smallexample
6479 INTEGER :: status
6480 CALL FSEEK(UNIT, OFFSET, WHENCE, status)
6481 IF (status /= 0) GOTO label
6482 @end smallexample
6483
6484 Please note that GNU Fortran provides the Fortran 2003 Stream facility.
6485 Programmers should consider the use of new stream IO feature in new code
6486 for future portability. See also @ref{Fortran 2003 status}.
6487
6488 @item @emph{Standard}:
6489 GNU extension
6490
6491 @item @emph{Class}:
6492 Subroutine
6493
6494 @item @emph{Syntax}:
6495 @code{CALL FSEEK(UNIT, OFFSET, WHENCE[, STATUS])}
6496
6497 @item @emph{Arguments}:
6498 @multitable @columnfractions .15 .70
6499 @item @var{UNIT} @tab Shall be a scalar of type @code{INTEGER}.
6500 @item @var{OFFSET} @tab Shall be a scalar of type @code{INTEGER}.
6501 @item @var{WHENCE} @tab Shall be a scalar of type @code{INTEGER}.
6502 Its value shall be either 0, 1 or 2.
6503 @item @var{STATUS} @tab (Optional) shall be a scalar of type
6504 @code{INTEGER(4)}.
6505 @end multitable
6506
6507 @item @emph{Example}:
6508 @smallexample
6509 PROGRAM test_fseek
6510 INTEGER, PARAMETER :: SEEK_SET = 0, SEEK_CUR = 1, SEEK_END = 2
6511 INTEGER :: fd, offset, ierr
6512
6513 ierr = 0
6514 offset = 5
6515 fd = 10
6516
6517 OPEN(UNIT=fd, FILE="fseek.test")
6518 CALL FSEEK(fd, offset, SEEK_SET, ierr) ! move to OFFSET
6519 print *, FTELL(fd), ierr
6520
6521 CALL FSEEK(fd, 0, SEEK_END, ierr) ! move to end
6522 print *, FTELL(fd), ierr
6523
6524 CALL FSEEK(fd, 0, SEEK_SET, ierr) ! move to beginning
6525 print *, FTELL(fd), ierr
6526
6527 CLOSE(UNIT=fd)
6528 END PROGRAM
6529 @end smallexample
6530
6531 @item @emph{See also}:
6532 @ref{FTELL}
6533 @end table
6534
6535
6536
6537 @node FSTAT
6538 @section @code{FSTAT} --- Get file status
6539 @fnindex FSTAT
6540 @cindex file system, file status
6541
6542 @table @asis
6543 @item @emph{Description}:
6544 @code{FSTAT} is identical to @ref{STAT}, except that information about an
6545 already opened file is obtained.
6546
6547 The elements in @code{VALUES} are the same as described by @ref{STAT}.
6548
6549 This intrinsic is provided in both subroutine and function forms; however,
6550 only one form can be used in any given program unit.
6551
6552 @item @emph{Standard}:
6553 GNU extension
6554
6555 @item @emph{Class}:
6556 Subroutine, function
6557
6558 @item @emph{Syntax}:
6559 @multitable @columnfractions .80
6560 @item @code{CALL FSTAT(UNIT, VALUES [, STATUS])}
6561 @item @code{STATUS = FSTAT(UNIT, VALUES)}
6562 @end multitable
6563
6564 @item @emph{Arguments}:
6565 @multitable @columnfractions .15 .70
6566 @item @var{UNIT} @tab An open I/O unit number of type @code{INTEGER}.
6567 @item @var{VALUES} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
6568 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0
6569 on success and a system specific error code otherwise.
6570 @end multitable
6571
6572 @item @emph{Example}:
6573 See @ref{STAT} for an example.
6574
6575 @item @emph{See also}:
6576 To stat a link: @ref{LSTAT}, to stat a file: @ref{STAT}
6577 @end table
6578
6579
6580
6581 @node FTELL
6582 @section @code{FTELL} --- Current stream position
6583 @fnindex FTELL
6584 @cindex file operation, position
6585
6586 @table @asis
6587 @item @emph{Description}:
6588 Retrieves the current position within an open file.
6589
6590 This intrinsic is provided in both subroutine and function forms; however,
6591 only one form can be used in any given program unit.
6592
6593 @item @emph{Standard}:
6594 GNU extension
6595
6596 @item @emph{Class}:
6597 Subroutine, function
6598
6599 @item @emph{Syntax}:
6600 @multitable @columnfractions .80
6601 @item @code{CALL FTELL(UNIT, OFFSET)}
6602 @item @code{OFFSET = FTELL(UNIT)}
6603 @end multitable
6604
6605 @item @emph{Arguments}:
6606 @multitable @columnfractions .15 .70
6607 @item @var{OFFSET} @tab Shall of type @code{INTEGER}.
6608 @item @var{UNIT} @tab Shall of type @code{INTEGER}.
6609 @end multitable
6610
6611 @item @emph{Return value}:
6612 In either syntax, @var{OFFSET} is set to the current offset of unit
6613 number @var{UNIT}, or to @math{-1} if the unit is not currently open.
6614
6615 @item @emph{Example}:
6616 @smallexample
6617 PROGRAM test_ftell
6618 INTEGER :: i
6619 OPEN(10, FILE="temp.dat")
6620 CALL ftell(10,i)
6621 WRITE(*,*) i
6622 END PROGRAM
6623 @end smallexample
6624
6625 @item @emph{See also}:
6626 @ref{FSEEK}
6627 @end table
6628
6629
6630
6631 @node GAMMA
6632 @section @code{GAMMA} --- Gamma function
6633 @fnindex GAMMA
6634 @fnindex DGAMMA
6635 @cindex Gamma function
6636 @cindex Factorial function
6637
6638 @table @asis
6639 @item @emph{Description}:
6640 @code{GAMMA(X)} computes Gamma (@math{\Gamma}) of @var{X}. For positive,
6641 integer values of @var{X} the Gamma function simplifies to the factorial
6642 function @math{\Gamma(x)=(x-1)!}.
6643
6644 @tex
6645 $$
6646 \Gamma(x) = \int_0^\infty t^{x-1}{\rm e}^{-t}\,{\rm d}t
6647 $$
6648 @end tex
6649
6650 @item @emph{Standard}:
6651 Fortran 2008 and later
6652
6653 @item @emph{Class}:
6654 Elemental function
6655
6656 @item @emph{Syntax}:
6657 @code{X = GAMMA(X)}
6658
6659 @item @emph{Arguments}:
6660 @multitable @columnfractions .15 .70
6661 @item @var{X} @tab Shall be of type @code{REAL} and neither zero
6662 nor a negative integer.
6663 @end multitable
6664
6665 @item @emph{Return value}:
6666 The return value is of type @code{REAL} of the same kind as @var{X}.
6667
6668 @item @emph{Example}:
6669 @smallexample
6670 program test_gamma
6671 real :: x = 1.0
6672 x = gamma(x) ! returns 1.0
6673 end program test_gamma
6674 @end smallexample
6675
6676 @item @emph{Specific names}:
6677 @multitable @columnfractions .20 .20 .20 .25
6678 @item Name @tab Argument @tab Return type @tab Standard
6679 @item @code{GAMMA(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU Extension
6680 @item @code{DGAMMA(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU Extension
6681 @end multitable
6682
6683 @item @emph{See also}:
6684 Logarithm of the Gamma function: @ref{LOG_GAMMA}
6685
6686 @end table
6687
6688
6689
6690 @node GERROR
6691 @section @code{GERROR} --- Get last system error message
6692 @fnindex GERROR
6693 @cindex system, error handling
6694
6695 @table @asis
6696 @item @emph{Description}:
6697 Returns the system error message corresponding to the last system error.
6698 This resembles the functionality of @code{strerror(3)} in C.
6699
6700 @item @emph{Standard}:
6701 GNU extension
6702
6703 @item @emph{Class}:
6704 Subroutine
6705
6706 @item @emph{Syntax}:
6707 @code{CALL GERROR(RESULT)}
6708
6709 @item @emph{Arguments}:
6710 @multitable @columnfractions .15 .70
6711 @item @var{RESULT} @tab Shall of type @code{CHARACTER} and of default
6712 @end multitable
6713
6714 @item @emph{Example}:
6715 @smallexample
6716 PROGRAM test_gerror
6717 CHARACTER(len=100) :: msg
6718 CALL gerror(msg)
6719 WRITE(*,*) msg
6720 END PROGRAM
6721 @end smallexample
6722
6723 @item @emph{See also}:
6724 @ref{IERRNO}, @ref{PERROR}
6725 @end table
6726
6727
6728
6729 @node GETARG
6730 @section @code{GETARG} --- Get command line arguments
6731 @fnindex GETARG
6732 @cindex command-line arguments
6733 @cindex arguments, to program
6734
6735 @table @asis
6736 @item @emph{Description}:
6737 Retrieve the @var{POS}-th argument that was passed on the
6738 command line when the containing program was invoked.
6739
6740 This intrinsic routine is provided for backwards compatibility with
6741 GNU Fortran 77. In new code, programmers should consider the use of
6742 the @ref{GET_COMMAND_ARGUMENT} intrinsic defined by the Fortran 2003
6743 standard.
6744
6745 @item @emph{Standard}:
6746 GNU extension
6747
6748 @item @emph{Class}:
6749 Subroutine
6750
6751 @item @emph{Syntax}:
6752 @code{CALL GETARG(POS, VALUE)}
6753
6754 @item @emph{Arguments}:
6755 @multitable @columnfractions .15 .70
6756 @item @var{POS} @tab Shall be of type @code{INTEGER} and not wider than
6757 the default integer kind; @math{@var{POS} \geq 0}
6758 @item @var{VALUE} @tab Shall be of type @code{CHARACTER} and of default
6759 kind.
6760 @item @var{VALUE} @tab Shall be of type @code{CHARACTER}.
6761 @end multitable
6762
6763 @item @emph{Return value}:
6764 After @code{GETARG} returns, the @var{VALUE} argument holds the
6765 @var{POS}th command line argument. If @var{VALUE} can not hold the
6766 argument, it is truncated to fit the length of @var{VALUE}. If there are
6767 less than @var{POS} arguments specified at the command line, @var{VALUE}
6768 will be filled with blanks. If @math{@var{POS} = 0}, @var{VALUE} is set
6769 to the name of the program (on systems that support this feature).
6770
6771 @item @emph{Example}:
6772 @smallexample
6773 PROGRAM test_getarg
6774 INTEGER :: i
6775 CHARACTER(len=32) :: arg
6776
6777 DO i = 1, iargc()
6778 CALL getarg(i, arg)
6779 WRITE (*,*) arg
6780 END DO
6781 END PROGRAM
6782 @end smallexample
6783
6784 @item @emph{See also}:
6785 GNU Fortran 77 compatibility function: @ref{IARGC}
6786
6787 Fortran 2003 functions and subroutines: @ref{GET_COMMAND},
6788 @ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
6789 @end table
6790
6791
6792
6793 @node GET_COMMAND
6794 @section @code{GET_COMMAND} --- Get the entire command line
6795 @fnindex GET_COMMAND
6796 @cindex command-line arguments
6797 @cindex arguments, to program
6798
6799 @table @asis
6800 @item @emph{Description}:
6801 Retrieve the entire command line that was used to invoke the program.
6802
6803 @item @emph{Standard}:
6804 Fortran 2003 and later
6805
6806 @item @emph{Class}:
6807 Subroutine
6808
6809 @item @emph{Syntax}:
6810 @code{CALL GET_COMMAND([COMMAND, LENGTH, STATUS])}
6811
6812 @item @emph{Arguments}:
6813 @multitable @columnfractions .15 .70
6814 @item @var{COMMAND} @tab (Optional) shall be of type @code{CHARACTER} and
6815 of default kind.
6816 @item @var{LENGTH} @tab (Optional) Shall be of type @code{INTEGER} and of
6817 default kind.
6818 @item @var{STATUS} @tab (Optional) Shall be of type @code{INTEGER} and of
6819 default kind.
6820 @end multitable
6821
6822 @item @emph{Return value}:
6823 If @var{COMMAND} is present, stores the entire command line that was used
6824 to invoke the program in @var{COMMAND}. If @var{LENGTH} is present, it is
6825 assigned the length of the command line. If @var{STATUS} is present, it
6826 is assigned 0 upon success of the command, -1 if @var{COMMAND} is too
6827 short to store the command line, or a positive value in case of an error.
6828
6829 @item @emph{Example}:
6830 @smallexample
6831 PROGRAM test_get_command
6832 CHARACTER(len=255) :: cmd
6833 CALL get_command(cmd)
6834 WRITE (*,*) TRIM(cmd)
6835 END PROGRAM
6836 @end smallexample
6837
6838 @item @emph{See also}:
6839 @ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
6840 @end table
6841
6842
6843
6844 @node GET_COMMAND_ARGUMENT
6845 @section @code{GET_COMMAND_ARGUMENT} --- Get command line arguments
6846 @fnindex GET_COMMAND_ARGUMENT
6847 @cindex command-line arguments
6848 @cindex arguments, to program
6849
6850 @table @asis
6851 @item @emph{Description}:
6852 Retrieve the @var{NUMBER}-th argument that was passed on the
6853 command line when the containing program was invoked.
6854
6855 @item @emph{Standard}:
6856 Fortran 2003 and later
6857
6858 @item @emph{Class}:
6859 Subroutine
6860
6861 @item @emph{Syntax}:
6862 @code{CALL GET_COMMAND_ARGUMENT(NUMBER [, VALUE, LENGTH, STATUS])}
6863
6864 @item @emph{Arguments}:
6865 @multitable @columnfractions .15 .70
6866 @item @var{NUMBER} @tab Shall be a scalar of type @code{INTEGER} and of
6867 default kind, @math{@var{NUMBER} \geq 0}
6868 @item @var{VALUE} @tab (Optional) Shall be a scalar of type @code{CHARACTER}
6869 and of default kind.
6870 @item @var{LENGTH} @tab (Optional) Shall be a scalar of type @code{INTEGER}
6871 and of default kind.
6872 @item @var{STATUS} @tab (Optional) Shall be a scalar of type @code{INTEGER}
6873 and of default kind.
6874 @end multitable
6875
6876 @item @emph{Return value}:
6877 After @code{GET_COMMAND_ARGUMENT} returns, the @var{VALUE} argument holds the
6878 @var{NUMBER}-th command line argument. If @var{VALUE} can not hold the argument, it is
6879 truncated to fit the length of @var{VALUE}. If there are less than @var{NUMBER}
6880 arguments specified at the command line, @var{VALUE} will be filled with blanks.
6881 If @math{@var{NUMBER} = 0}, @var{VALUE} is set to the name of the program (on
6882 systems that support this feature). The @var{LENGTH} argument contains the
6883 length of the @var{NUMBER}-th command line argument. If the argument retrieval
6884 fails, @var{STATUS} is a positive number; if @var{VALUE} contains a truncated
6885 command line argument, @var{STATUS} is -1; and otherwise the @var{STATUS} is
6886 zero.
6887
6888 @item @emph{Example}:
6889 @smallexample
6890 PROGRAM test_get_command_argument
6891 INTEGER :: i
6892 CHARACTER(len=32) :: arg
6893
6894 i = 0
6895 DO
6896 CALL get_command_argument(i, arg)
6897 IF (LEN_TRIM(arg) == 0) EXIT
6898
6899 WRITE (*,*) TRIM(arg)
6900 i = i+1
6901 END DO
6902 END PROGRAM
6903 @end smallexample
6904
6905 @item @emph{See also}:
6906 @ref{GET_COMMAND}, @ref{COMMAND_ARGUMENT_COUNT}
6907 @end table
6908
6909
6910
6911 @node GETCWD
6912 @section @code{GETCWD} --- Get current working directory
6913 @fnindex GETCWD
6914 @cindex system, working directory
6915
6916 @table @asis
6917 @item @emph{Description}:
6918 Get current working directory.
6919
6920 This intrinsic is provided in both subroutine and function forms; however,
6921 only one form can be used in any given program unit.
6922
6923 @item @emph{Standard}:
6924 GNU extension
6925
6926 @item @emph{Class}:
6927 Subroutine, function
6928
6929 @item @emph{Syntax}:
6930 @multitable @columnfractions .80
6931 @item @code{CALL GETCWD(C [, STATUS])}
6932 @item @code{STATUS = GETCWD(C)}
6933 @end multitable
6934
6935 @item @emph{Arguments}:
6936 @multitable @columnfractions .15 .70
6937 @item @var{C} @tab The type shall be @code{CHARACTER} and of default kind.
6938 @item @var{STATUS} @tab (Optional) status flag. Returns 0 on success,
6939 a system specific and nonzero error code otherwise.
6940 @end multitable
6941
6942 @item @emph{Example}:
6943 @smallexample
6944 PROGRAM test_getcwd
6945 CHARACTER(len=255) :: cwd
6946 CALL getcwd(cwd)
6947 WRITE(*,*) TRIM(cwd)
6948 END PROGRAM
6949 @end smallexample
6950
6951 @item @emph{See also}:
6952 @ref{CHDIR}
6953 @end table
6954
6955
6956
6957 @node GETENV
6958 @section @code{GETENV} --- Get an environmental variable
6959 @fnindex GETENV
6960 @cindex environment variable
6961
6962 @table @asis
6963 @item @emph{Description}:
6964 Get the @var{VALUE} of the environmental variable @var{NAME}.
6965
6966 This intrinsic routine is provided for backwards compatibility with
6967 GNU Fortran 77. In new code, programmers should consider the use of
6968 the @ref{GET_ENVIRONMENT_VARIABLE} intrinsic defined by the Fortran
6969 2003 standard.
6970
6971 Note that @code{GETENV} need not be thread-safe. It is the
6972 responsibility of the user to ensure that the environment is not being
6973 updated concurrently with a call to the @code{GETENV} intrinsic.
6974
6975 @item @emph{Standard}:
6976 GNU extension
6977
6978 @item @emph{Class}:
6979 Subroutine
6980
6981 @item @emph{Syntax}:
6982 @code{CALL GETENV(NAME, VALUE)}
6983
6984 @item @emph{Arguments}:
6985 @multitable @columnfractions .15 .70
6986 @item @var{NAME} @tab Shall be of type @code{CHARACTER} and of default kind.
6987 @item @var{VALUE} @tab Shall be of type @code{CHARACTER} and of default kind.
6988 @end multitable
6989
6990 @item @emph{Return value}:
6991 Stores the value of @var{NAME} in @var{VALUE}. If @var{VALUE} is
6992 not large enough to hold the data, it is truncated. If @var{NAME}
6993 is not set, @var{VALUE} will be filled with blanks.
6994
6995 @item @emph{Example}:
6996 @smallexample
6997 PROGRAM test_getenv
6998 CHARACTER(len=255) :: homedir
6999 CALL getenv("HOME", homedir)
7000 WRITE (*,*) TRIM(homedir)
7001 END PROGRAM
7002 @end smallexample
7003
7004 @item @emph{See also}:
7005 @ref{GET_ENVIRONMENT_VARIABLE}
7006 @end table
7007
7008
7009
7010 @node GET_ENVIRONMENT_VARIABLE
7011 @section @code{GET_ENVIRONMENT_VARIABLE} --- Get an environmental variable
7012 @fnindex GET_ENVIRONMENT_VARIABLE
7013 @cindex environment variable
7014
7015 @table @asis
7016 @item @emph{Description}:
7017 Get the @var{VALUE} of the environmental variable @var{NAME}.
7018
7019 Note that @code{GET_ENVIRONMENT_VARIABLE} need not be thread-safe. It
7020 is the responsibility of the user to ensure that the environment is
7021 not being updated concurrently with a call to the
7022 @code{GET_ENVIRONMENT_VARIABLE} intrinsic.
7023
7024 @item @emph{Standard}:
7025 Fortran 2003 and later
7026
7027 @item @emph{Class}:
7028 Subroutine
7029
7030 @item @emph{Syntax}:
7031 @code{CALL GET_ENVIRONMENT_VARIABLE(NAME[, VALUE, LENGTH, STATUS, TRIM_NAME)}
7032
7033 @item @emph{Arguments}:
7034 @multitable @columnfractions .15 .70
7035 @item @var{NAME} @tab Shall be a scalar of type @code{CHARACTER}
7036 and of default kind.
7037 @item @var{VALUE} @tab (Optional) Shall be a scalar of type @code{CHARACTER}
7038 and of default kind.
7039 @item @var{LENGTH} @tab (Optional) Shall be a scalar of type @code{INTEGER}
7040 and of default kind.
7041 @item @var{STATUS} @tab (Optional) Shall be a scalar of type @code{INTEGER}
7042 and of default kind.
7043 @item @var{TRIM_NAME} @tab (Optional) Shall be a scalar of type @code{LOGICAL}
7044 and of default kind.
7045 @end multitable
7046
7047 @item @emph{Return value}:
7048 Stores the value of @var{NAME} in @var{VALUE}. If @var{VALUE} is
7049 not large enough to hold the data, it is truncated. If @var{NAME}
7050 is not set, @var{VALUE} will be filled with blanks. Argument @var{LENGTH}
7051 contains the length needed for storing the environment variable @var{NAME}
7052 or zero if it is not present. @var{STATUS} is -1 if @var{VALUE} is present
7053 but too short for the environment variable; it is 1 if the environment
7054 variable does not exist and 2 if the processor does not support environment
7055 variables; in all other cases @var{STATUS} is zero. If @var{TRIM_NAME} is
7056 present with the value @code{.FALSE.}, the trailing blanks in @var{NAME}
7057 are significant; otherwise they are not part of the environment variable
7058 name.
7059
7060 @item @emph{Example}:
7061 @smallexample
7062 PROGRAM test_getenv
7063 CHARACTER(len=255) :: homedir
7064 CALL get_environment_variable("HOME", homedir)
7065 WRITE (*,*) TRIM(homedir)
7066 END PROGRAM
7067 @end smallexample
7068 @end table
7069
7070
7071
7072 @node GETGID
7073 @section @code{GETGID} --- Group ID function
7074 @fnindex GETGID
7075 @cindex system, group ID
7076
7077 @table @asis
7078 @item @emph{Description}:
7079 Returns the numerical group ID of the current process.
7080
7081 @item @emph{Standard}:
7082 GNU extension
7083
7084 @item @emph{Class}:
7085 Function
7086
7087 @item @emph{Syntax}:
7088 @code{RESULT = GETGID()}
7089
7090 @item @emph{Return value}:
7091 The return value of @code{GETGID} is an @code{INTEGER} of the default
7092 kind.
7093
7094
7095 @item @emph{Example}:
7096 See @code{GETPID} for an example.
7097
7098 @item @emph{See also}:
7099 @ref{GETPID}, @ref{GETUID}
7100 @end table
7101
7102
7103
7104 @node GETLOG
7105 @section @code{GETLOG} --- Get login name
7106 @fnindex GETLOG
7107 @cindex system, login name
7108 @cindex login name
7109
7110 @table @asis
7111 @item @emph{Description}:
7112 Gets the username under which the program is running.
7113
7114 @item @emph{Standard}:
7115 GNU extension
7116
7117 @item @emph{Class}:
7118 Subroutine
7119
7120 @item @emph{Syntax}:
7121 @code{CALL GETLOG(C)}
7122
7123 @item @emph{Arguments}:
7124 @multitable @columnfractions .15 .70
7125 @item @var{C} @tab Shall be of type @code{CHARACTER} and of default kind.
7126 @end multitable
7127
7128 @item @emph{Return value}:
7129 Stores the current user name in @var{LOGIN}. (On systems where POSIX
7130 functions @code{geteuid} and @code{getpwuid} are not available, and
7131 the @code{getlogin} function is not implemented either, this will
7132 return a blank string.)
7133
7134 @item @emph{Example}:
7135 @smallexample
7136 PROGRAM TEST_GETLOG
7137 CHARACTER(32) :: login
7138 CALL GETLOG(login)
7139 WRITE(*,*) login
7140 END PROGRAM
7141 @end smallexample
7142
7143 @item @emph{See also}:
7144 @ref{GETUID}
7145 @end table
7146
7147
7148
7149 @node GETPID
7150 @section @code{GETPID} --- Process ID function
7151 @fnindex GETPID
7152 @cindex system, process ID
7153 @cindex process ID
7154
7155 @table @asis
7156 @item @emph{Description}:
7157 Returns the numerical process identifier of the current process.
7158
7159 @item @emph{Standard}:
7160 GNU extension
7161
7162 @item @emph{Class}:
7163 Function
7164
7165 @item @emph{Syntax}:
7166 @code{RESULT = GETPID()}
7167
7168 @item @emph{Return value}:
7169 The return value of @code{GETPID} is an @code{INTEGER} of the default
7170 kind.
7171
7172
7173 @item @emph{Example}:
7174 @smallexample
7175 program info
7176 print *, "The current process ID is ", getpid()
7177 print *, "Your numerical user ID is ", getuid()
7178 print *, "Your numerical group ID is ", getgid()
7179 end program info
7180 @end smallexample
7181
7182 @item @emph{See also}:
7183 @ref{GETGID}, @ref{GETUID}
7184 @end table
7185
7186
7187
7188 @node GETUID
7189 @section @code{GETUID} --- User ID function
7190 @fnindex GETUID
7191 @cindex system, user ID
7192 @cindex user id
7193
7194 @table @asis
7195 @item @emph{Description}:
7196 Returns the numerical user ID of the current process.
7197
7198 @item @emph{Standard}:
7199 GNU extension
7200
7201 @item @emph{Class}:
7202 Function
7203
7204 @item @emph{Syntax}:
7205 @code{RESULT = GETUID()}
7206
7207 @item @emph{Return value}:
7208 The return value of @code{GETUID} is an @code{INTEGER} of the default
7209 kind.
7210
7211
7212 @item @emph{Example}:
7213 See @code{GETPID} for an example.
7214
7215 @item @emph{See also}:
7216 @ref{GETPID}, @ref{GETLOG}
7217 @end table
7218
7219
7220
7221 @node GMTIME
7222 @section @code{GMTIME} --- Convert time to GMT info
7223 @fnindex GMTIME
7224 @cindex time, conversion to GMT info
7225
7226 @table @asis
7227 @item @emph{Description}:
7228 Given a system time value @var{TIME} (as provided by the @ref{TIME}
7229 intrinsic), fills @var{VALUES} with values extracted from it appropriate
7230 to the UTC time zone (Universal Coordinated Time, also known in some
7231 countries as GMT, Greenwich Mean Time), using @code{gmtime(3)}.
7232
7233 This intrinsic routine is provided for backwards compatibility with
7234 GNU Fortran 77. In new code, programmers should consider the use of
7235 the @ref{DATE_AND_TIME} intrinsic defined by the Fortran 95
7236 standard.
7237
7238 @item @emph{Standard}:
7239 GNU extension
7240
7241 @item @emph{Class}:
7242 Subroutine
7243
7244 @item @emph{Syntax}:
7245 @code{CALL GMTIME(TIME, VALUES)}
7246
7247 @item @emph{Arguments}:
7248 @multitable @columnfractions .15 .70
7249 @item @var{TIME} @tab An @code{INTEGER} scalar expression
7250 corresponding to a system time, with @code{INTENT(IN)}.
7251 @item @var{VALUES} @tab A default @code{INTEGER} array with 9 elements,
7252 with @code{INTENT(OUT)}.
7253 @end multitable
7254
7255 @item @emph{Return value}:
7256 The elements of @var{VALUES} are assigned as follows:
7257 @enumerate
7258 @item Seconds after the minute, range 0--59 or 0--61 to allow for leap
7259 seconds
7260 @item Minutes after the hour, range 0--59
7261 @item Hours past midnight, range 0--23
7262 @item Day of month, range 1--31
7263 @item Number of months since January, range 0--11
7264 @item Years since 1900
7265 @item Number of days since Sunday, range 0--6
7266 @item Days since January 1, range 0--365
7267 @item Daylight savings indicator: positive if daylight savings is in
7268 effect, zero if not, and negative if the information is not available.
7269 @end enumerate
7270
7271 @item @emph{See also}:
7272 @ref{DATE_AND_TIME}, @ref{CTIME}, @ref{LTIME}, @ref{TIME}, @ref{TIME8}
7273
7274 @end table
7275
7276
7277
7278 @node HOSTNM
7279 @section @code{HOSTNM} --- Get system host name
7280 @fnindex HOSTNM
7281 @cindex system, host name
7282
7283 @table @asis
7284 @item @emph{Description}:
7285 Retrieves the host name of the system on which the program is running.
7286
7287 This intrinsic is provided in both subroutine and function forms; however,
7288 only one form can be used in any given program unit.
7289
7290 @item @emph{Standard}:
7291 GNU extension
7292
7293 @item @emph{Class}:
7294 Subroutine, function
7295
7296 @item @emph{Syntax}:
7297 @multitable @columnfractions .80
7298 @item @code{CALL HOSTNM(C [, STATUS])}
7299 @item @code{STATUS = HOSTNM(NAME)}
7300 @end multitable
7301
7302 @item @emph{Arguments}:
7303 @multitable @columnfractions .15 .70
7304 @item @var{C} @tab Shall of type @code{CHARACTER} and of default kind.
7305 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
7306 Returns 0 on success, or a system specific error code otherwise.
7307 @end multitable
7308
7309 @item @emph{Return value}:
7310 In either syntax, @var{NAME} is set to the current hostname if it can
7311 be obtained, or to a blank string otherwise.
7312
7313 @end table
7314
7315
7316
7317 @node HUGE
7318 @section @code{HUGE} --- Largest number of a kind
7319 @fnindex HUGE
7320 @cindex limits, largest number
7321 @cindex model representation, largest number
7322
7323 @table @asis
7324 @item @emph{Description}:
7325 @code{HUGE(X)} returns the largest number that is not an infinity in
7326 the model of the type of @code{X}.
7327
7328 @item @emph{Standard}:
7329 Fortran 95 and later
7330
7331 @item @emph{Class}:
7332 Inquiry function
7333
7334 @item @emph{Syntax}:
7335 @code{RESULT = HUGE(X)}
7336
7337 @item @emph{Arguments}:
7338 @multitable @columnfractions .15 .70
7339 @item @var{X} @tab Shall be of type @code{REAL} or @code{INTEGER}.
7340 @end multitable
7341
7342 @item @emph{Return value}:
7343 The return value is of the same type and kind as @var{X}
7344
7345 @item @emph{Example}:
7346 @smallexample
7347 program test_huge_tiny
7348 print *, huge(0), huge(0.0), huge(0.0d0)
7349 print *, tiny(0.0), tiny(0.0d0)
7350 end program test_huge_tiny
7351 @end smallexample
7352 @end table
7353
7354
7355
7356 @node HYPOT
7357 @section @code{HYPOT} --- Euclidean distance function
7358 @fnindex HYPOT
7359 @cindex Euclidean distance
7360
7361 @table @asis
7362 @item @emph{Description}:
7363 @code{HYPOT(X,Y)} is the Euclidean distance function. It is equal to
7364 @math{\sqrt{X^2 + Y^2}}, without undue underflow or overflow.
7365
7366 @item @emph{Standard}:
7367 Fortran 2008 and later
7368
7369 @item @emph{Class}:
7370 Elemental function
7371
7372 @item @emph{Syntax}:
7373 @code{RESULT = HYPOT(X, Y)}
7374
7375 @item @emph{Arguments}:
7376 @multitable @columnfractions .15 .70
7377 @item @var{X} @tab The type shall be @code{REAL}.
7378 @item @var{Y} @tab The type and kind type parameter shall be the same as
7379 @var{X}.
7380 @end multitable
7381
7382 @item @emph{Return value}:
7383 The return value has the same type and kind type parameter as @var{X}.
7384
7385 @item @emph{Example}:
7386 @smallexample
7387 program test_hypot
7388 real(4) :: x = 1.e0_4, y = 0.5e0_4
7389 x = hypot(x,y)
7390 end program test_hypot
7391 @end smallexample
7392 @end table
7393
7394
7395
7396 @node IACHAR
7397 @section @code{IACHAR} --- Code in @acronym{ASCII} collating sequence
7398 @fnindex IACHAR
7399 @cindex @acronym{ASCII} collating sequence
7400 @cindex collating sequence, @acronym{ASCII}
7401 @cindex conversion, to integer
7402
7403 @table @asis
7404 @item @emph{Description}:
7405 @code{IACHAR(C)} returns the code for the @acronym{ASCII} character
7406 in the first character position of @code{C}.
7407
7408 @item @emph{Standard}:
7409 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
7410
7411 @item @emph{Class}:
7412 Elemental function
7413
7414 @item @emph{Syntax}:
7415 @code{RESULT = IACHAR(C [, KIND])}
7416
7417 @item @emph{Arguments}:
7418 @multitable @columnfractions .15 .70
7419 @item @var{C} @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
7420 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
7421 expression indicating the kind parameter of the result.
7422 @end multitable
7423
7424 @item @emph{Return value}:
7425 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
7426 @var{KIND} is absent, the return value is of default integer kind.
7427
7428 @item @emph{Example}:
7429 @smallexample
7430 program test_iachar
7431 integer i
7432 i = iachar(' ')
7433 end program test_iachar
7434 @end smallexample
7435
7436 @item @emph{Note}:
7437 See @ref{ICHAR} for a discussion of converting between numerical values
7438 and formatted string representations.
7439
7440 @item @emph{See also}:
7441 @ref{ACHAR}, @ref{CHAR}, @ref{ICHAR}
7442
7443 @end table
7444
7445
7446
7447 @node IALL
7448 @section @code{IALL} --- Bitwise AND of array elements
7449 @fnindex IALL
7450 @cindex array, AND
7451 @cindex bits, AND of array elements
7452
7453 @table @asis
7454 @item @emph{Description}:
7455 Reduces with bitwise AND the elements of @var{ARRAY} along dimension @var{DIM}
7456 if the corresponding element in @var{MASK} is @code{TRUE}.
7457
7458 @item @emph{Standard}:
7459 Fortran 2008 and later
7460
7461 @item @emph{Class}:
7462 Transformational function
7463
7464 @item @emph{Syntax}:
7465 @multitable @columnfractions .80
7466 @item @code{RESULT = IALL(ARRAY[, MASK])}
7467 @item @code{RESULT = IALL(ARRAY, DIM[, MASK])}
7468 @end multitable
7469
7470 @item @emph{Arguments}:
7471 @multitable @columnfractions .15 .70
7472 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER}
7473 @item @var{DIM} @tab (Optional) shall be a scalar of type
7474 @code{INTEGER} with a value in the range from 1 to n, where n
7475 equals the rank of @var{ARRAY}.
7476 @item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL}
7477 and either be a scalar or an array of the same shape as @var{ARRAY}.
7478 @end multitable
7479
7480 @item @emph{Return value}:
7481 The result is of the same type as @var{ARRAY}.
7482
7483 If @var{DIM} is absent, a scalar with the bitwise ALL of all elements in
7484 @var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals
7485 the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with
7486 dimension @var{DIM} dropped is returned.
7487
7488 @item @emph{Example}:
7489 @smallexample
7490 PROGRAM test_iall
7491 INTEGER(1) :: a(2)
7492
7493 a(1) = b'00100100'
7494 a(2) = b'01101010'
7495
7496 ! prints 00100000
7497 PRINT '(b8.8)', IALL(a)
7498 END PROGRAM
7499 @end smallexample
7500
7501 @item @emph{See also}:
7502 @ref{IANY}, @ref{IPARITY}, @ref{IAND}
7503 @end table
7504
7505
7506
7507 @node IAND
7508 @section @code{IAND} --- Bitwise logical and
7509 @fnindex IAND
7510 @fnindex BIAND
7511 @fnindex IIAND
7512 @fnindex JIAND
7513 @fnindex KIAND
7514 @cindex bitwise logical and
7515 @cindex logical and, bitwise
7516
7517 @table @asis
7518 @item @emph{Description}:
7519 Bitwise logical @code{AND}.
7520
7521 @item @emph{Standard}:
7522 Fortran 95 and later, has overloads that are GNU extensions
7523
7524 @item @emph{Class}:
7525 Elemental function
7526
7527 @item @emph{Syntax}:
7528 @code{RESULT = IAND(I, J)}
7529
7530 @item @emph{Arguments}:
7531 @multitable @columnfractions .15 .70
7532 @item @var{I} @tab The type shall be @code{INTEGER} or a boz-literal-constant.
7533 @item @var{J} @tab The type shall be @code{INTEGER} with the same
7534 kind type parameter as @var{I} or a boz-literal-constant.
7535 @var{I} and @var{J} shall not both be boz-literal-constants.
7536 @end multitable
7537
7538 @item @emph{Return value}:
7539 The return type is @code{INTEGER} with the kind type parameter of the
7540 arguments.
7541 A boz-literal-constant is converted to an @code{INTEGER} with the kind
7542 type parameter of the other argument as-if a call to @ref{INT} occurred.
7543
7544 @item @emph{Example}:
7545 @smallexample
7546 PROGRAM test_iand
7547 INTEGER :: a, b
7548 DATA a / Z'F' /, b / Z'3' /
7549 WRITE (*,*) IAND(a, b)
7550 END PROGRAM
7551 @end smallexample
7552
7553 @item @emph{Specific names}:
7554 @multitable @columnfractions .20 .20 .20 .25
7555 @item Name @tab Argument @tab Return type @tab Standard
7556 @item @code{IAND(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 95 and later
7557 @item @code{BIAND(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
7558 @item @code{IIAND(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
7559 @item @code{JIAND(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
7560 @item @code{KIAND(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
7561 @end multitable
7562
7563 @item @emph{See also}:
7564 @ref{IOR}, @ref{IEOR}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
7565
7566 @end table
7567
7568
7569
7570 @node IANY
7571 @section @code{IANY} --- Bitwise OR of array elements
7572 @fnindex IANY
7573 @cindex array, OR
7574 @cindex bits, OR of array elements
7575
7576 @table @asis
7577 @item @emph{Description}:
7578 Reduces with bitwise OR (inclusive or) the elements of @var{ARRAY} along
7579 dimension @var{DIM} if the corresponding element in @var{MASK} is @code{TRUE}.
7580
7581 @item @emph{Standard}:
7582 Fortran 2008 and later
7583
7584 @item @emph{Class}:
7585 Transformational function
7586
7587 @item @emph{Syntax}:
7588 @multitable @columnfractions .80
7589 @item @code{RESULT = IANY(ARRAY[, MASK])}
7590 @item @code{RESULT = IANY(ARRAY, DIM[, MASK])}
7591 @end multitable
7592
7593 @item @emph{Arguments}:
7594 @multitable @columnfractions .15 .70
7595 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER}
7596 @item @var{DIM} @tab (Optional) shall be a scalar of type
7597 @code{INTEGER} with a value in the range from 1 to n, where n
7598 equals the rank of @var{ARRAY}.
7599 @item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL}
7600 and either be a scalar or an array of the same shape as @var{ARRAY}.
7601 @end multitable
7602
7603 @item @emph{Return value}:
7604 The result is of the same type as @var{ARRAY}.
7605
7606 If @var{DIM} is absent, a scalar with the bitwise OR of all elements in
7607 @var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals
7608 the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with
7609 dimension @var{DIM} dropped is returned.
7610
7611 @item @emph{Example}:
7612 @smallexample
7613 PROGRAM test_iany
7614 INTEGER(1) :: a(2)
7615
7616 a(1) = b'00100100'
7617 a(2) = b'01101010'
7618
7619 ! prints 01101110
7620 PRINT '(b8.8)', IANY(a)
7621 END PROGRAM
7622 @end smallexample
7623
7624 @item @emph{See also}:
7625 @ref{IPARITY}, @ref{IALL}, @ref{IOR}
7626 @end table
7627
7628
7629
7630 @node IARGC
7631 @section @code{IARGC} --- Get the number of command line arguments
7632 @fnindex IARGC
7633 @cindex command-line arguments
7634 @cindex command-line arguments, number of
7635 @cindex arguments, to program
7636
7637 @table @asis
7638 @item @emph{Description}:
7639 @code{IARGC} returns the number of arguments passed on the
7640 command line when the containing program was invoked.
7641
7642 This intrinsic routine is provided for backwards compatibility with
7643 GNU Fortran 77. In new code, programmers should consider the use of
7644 the @ref{COMMAND_ARGUMENT_COUNT} intrinsic defined by the Fortran 2003
7645 standard.
7646
7647 @item @emph{Standard}:
7648 GNU extension
7649
7650 @item @emph{Class}:
7651 Function
7652
7653 @item @emph{Syntax}:
7654 @code{RESULT = IARGC()}
7655
7656 @item @emph{Arguments}:
7657 None.
7658
7659 @item @emph{Return value}:
7660 The number of command line arguments, type @code{INTEGER(4)}.
7661
7662 @item @emph{Example}:
7663 See @ref{GETARG}
7664
7665 @item @emph{See also}:
7666 GNU Fortran 77 compatibility subroutine: @ref{GETARG}
7667
7668 Fortran 2003 functions and subroutines: @ref{GET_COMMAND},
7669 @ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
7670 @end table
7671
7672
7673
7674 @node IBCLR
7675 @section @code{IBCLR} --- Clear bit
7676 @fnindex IBCLR
7677 @fnindex BBCLR
7678 @fnindex IIBCLR
7679 @fnindex JIBCLR
7680 @fnindex KIBCLR
7681 @cindex bits, unset
7682 @cindex bits, clear
7683
7684 @table @asis
7685 @item @emph{Description}:
7686 @code{IBCLR} returns the value of @var{I} with the bit at position
7687 @var{POS} set to zero.
7688
7689 @item @emph{Standard}:
7690 Fortran 95 and later, has overloads that are GNU extensions
7691
7692 @item @emph{Class}:
7693 Elemental function
7694
7695 @item @emph{Syntax}:
7696 @code{RESULT = IBCLR(I, POS)}
7697
7698 @item @emph{Arguments}:
7699 @multitable @columnfractions .15 .70
7700 @item @var{I} @tab The type shall be @code{INTEGER}.
7701 @item @var{POS} @tab The type shall be @code{INTEGER}.
7702 @end multitable
7703
7704 @item @emph{Return value}:
7705 The return value is of type @code{INTEGER} and of the same kind as
7706 @var{I}.
7707
7708 @item @emph{Specific names}:
7709 @multitable @columnfractions .20 .20 .20 .25
7710 @item Name @tab Argument @tab Return type @tab Standard
7711 @item @code{IBCLR(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 95 and later
7712 @item @code{BBCLR(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
7713 @item @code{IIBCLR(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
7714 @item @code{JIBCLR(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
7715 @item @code{KIBCLR(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
7716 @end multitable
7717
7718 @item @emph{See also}:
7719 @ref{IBITS}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}, @ref{MVBITS}
7720
7721 @end table
7722
7723
7724
7725 @node IBITS
7726 @section @code{IBITS} --- Bit extraction
7727 @fnindex IBITS
7728 @fnindex BBITS
7729 @fnindex IIBITS
7730 @fnindex JIBITS
7731 @fnindex KIBITS
7732 @cindex bits, get
7733 @cindex bits, extract
7734
7735 @table @asis
7736 @item @emph{Description}:
7737 @code{IBITS} extracts a field of length @var{LEN} from @var{I},
7738 starting from bit position @var{POS} and extending left for @var{LEN}
7739 bits. The result is right-justified and the remaining bits are
7740 zeroed. The value of @code{POS+LEN} must be less than or equal to the
7741 value @code{BIT_SIZE(I)}.
7742
7743 @item @emph{Standard}:
7744 Fortran 95 and later, has overloads that are GNU extensions
7745
7746 @item @emph{Class}:
7747 Elemental function
7748
7749 @item @emph{Syntax}:
7750 @code{RESULT = IBITS(I, POS, LEN)}
7751
7752 @item @emph{Arguments}:
7753 @multitable @columnfractions .15 .70
7754 @item @var{I} @tab The type shall be @code{INTEGER}.
7755 @item @var{POS} @tab The type shall be @code{INTEGER}.
7756 @item @var{LEN} @tab The type shall be @code{INTEGER}.
7757 @end multitable
7758
7759 @item @emph{Return value}:
7760 The return value is of type @code{INTEGER} and of the same kind as
7761 @var{I}.
7762
7763 @item @emph{Specific names}:
7764 @multitable @columnfractions .20 .20 .20 .25
7765 @item Name @tab Argument @tab Return type @tab Standard
7766 @item @code{IBITS(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 95 and later
7767 @item @code{BBITS(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
7768 @item @code{IIBITS(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
7769 @item @code{JIBITS(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
7770 @item @code{KIBITS(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
7771 @end multitable
7772
7773 @item @emph{See also}:
7774 @ref{BIT_SIZE}, @ref{IBCLR}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
7775 @end table
7776
7777
7778
7779 @node IBSET
7780 @section @code{IBSET} --- Set bit
7781 @fnindex IBSET
7782 @fnindex BBSET
7783 @fnindex IIBSET
7784 @fnindex JIBSET
7785 @fnindex KIBSET
7786 @cindex bits, set
7787
7788 @table @asis
7789 @item @emph{Description}:
7790 @code{IBSET} returns the value of @var{I} with the bit at position
7791 @var{POS} set to one.
7792
7793 @item @emph{Standard}:
7794 Fortran 95 and later, has overloads that are GNU extensions
7795
7796 @item @emph{Class}:
7797 Elemental function
7798
7799 @item @emph{Syntax}:
7800 @code{RESULT = IBSET(I, POS)}
7801
7802 @item @emph{Arguments}:
7803 @multitable @columnfractions .15 .70
7804 @item @var{I} @tab The type shall be @code{INTEGER}.
7805 @item @var{POS} @tab The type shall be @code{INTEGER}.
7806 @end multitable
7807
7808 @item @emph{Return value}:
7809 The return value is of type @code{INTEGER} and of the same kind as
7810 @var{I}.
7811
7812 @item @emph{Specific names}:
7813 @multitable @columnfractions .20 .20 .20 .25
7814 @item Name @tab Argument @tab Return type @tab Standard
7815 @item @code{IBSET(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 95 and later
7816 @item @code{BBSET(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
7817 @item @code{IIBSET(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
7818 @item @code{JIBSET(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
7819 @item @code{KIBSET(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
7820 @end multitable
7821
7822 @item @emph{See also}:
7823 @ref{IBCLR}, @ref{IBITS}, @ref{IAND}, @ref{IOR}, @ref{IEOR}, @ref{MVBITS}
7824
7825 @end table
7826
7827
7828
7829 @node ICHAR
7830 @section @code{ICHAR} --- Character-to-integer conversion function
7831 @fnindex ICHAR
7832 @cindex conversion, to integer
7833
7834 @table @asis
7835 @item @emph{Description}:
7836 @code{ICHAR(C)} returns the code for the character in the first character
7837 position of @code{C} in the system's native character set.
7838 The correspondence between characters and their codes is not necessarily
7839 the same across different GNU Fortran implementations.
7840
7841 @item @emph{Standard}:
7842 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
7843
7844 @item @emph{Class}:
7845 Elemental function
7846
7847 @item @emph{Syntax}:
7848 @code{RESULT = ICHAR(C [, KIND])}
7849
7850 @item @emph{Arguments}:
7851 @multitable @columnfractions .15 .70
7852 @item @var{C} @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
7853 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
7854 expression indicating the kind parameter of the result.
7855 @end multitable
7856
7857 @item @emph{Return value}:
7858 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
7859 @var{KIND} is absent, the return value is of default integer kind.
7860
7861 @item @emph{Example}:
7862 @smallexample
7863 program test_ichar
7864 integer i
7865 i = ichar(' ')
7866 end program test_ichar
7867 @end smallexample
7868
7869 @item @emph{Specific names}:
7870 @multitable @columnfractions .20 .20 .20 .25
7871 @item Name @tab Argument @tab Return type @tab Standard
7872 @item @code{ICHAR(C)} @tab @code{CHARACTER C} @tab @code{INTEGER(4)} @tab Fortran 77 and later
7873 @end multitable
7874
7875 @item @emph{Note}:
7876 No intrinsic exists to convert between a numeric value and a formatted
7877 character string representation -- for instance, given the
7878 @code{CHARACTER} value @code{'154'}, obtaining an @code{INTEGER} or
7879 @code{REAL} value with the value 154, or vice versa. Instead, this
7880 functionality is provided by internal-file I/O, as in the following
7881 example:
7882 @smallexample
7883 program read_val
7884 integer value
7885 character(len=10) string, string2
7886 string = '154'
7887
7888 ! Convert a string to a numeric value
7889 read (string,'(I10)') value
7890 print *, value
7891
7892 ! Convert a value to a formatted string
7893 write (string2,'(I10)') value
7894 print *, string2
7895 end program read_val
7896 @end smallexample
7897
7898 @item @emph{See also}:
7899 @ref{ACHAR}, @ref{CHAR}, @ref{IACHAR}
7900
7901 @end table
7902
7903
7904
7905 @node IDATE
7906 @section @code{IDATE} --- Get current local time subroutine (day/month/year)
7907 @fnindex IDATE
7908 @cindex date, current
7909 @cindex current date
7910
7911 @table @asis
7912 @item @emph{Description}:
7913 @code{IDATE(VALUES)} Fills @var{VALUES} with the numerical values at the
7914 current local time. The day (in the range 1-31), month (in the range 1-12),
7915 and year appear in elements 1, 2, and 3 of @var{VALUES}, respectively.
7916 The year has four significant digits.
7917
7918 This intrinsic routine is provided for backwards compatibility with
7919 GNU Fortran 77. In new code, programmers should consider the use of
7920 the @ref{DATE_AND_TIME} intrinsic defined by the Fortran 95
7921 standard.
7922
7923 @item @emph{Standard}:
7924 GNU extension
7925
7926 @item @emph{Class}:
7927 Subroutine
7928
7929 @item @emph{Syntax}:
7930 @code{CALL IDATE(VALUES)}
7931
7932 @item @emph{Arguments}:
7933 @multitable @columnfractions .15 .70
7934 @item @var{VALUES} @tab The type shall be @code{INTEGER, DIMENSION(3)} and
7935 the kind shall be the default integer kind.
7936 @end multitable
7937
7938 @item @emph{Return value}:
7939 Does not return anything.
7940
7941 @item @emph{Example}:
7942 @smallexample
7943 program test_idate
7944 integer, dimension(3) :: tarray
7945 call idate(tarray)
7946 print *, tarray(1)
7947 print *, tarray(2)
7948 print *, tarray(3)
7949 end program test_idate
7950 @end smallexample
7951
7952 @item @emph{See also}:
7953 @ref{DATE_AND_TIME}
7954 @end table
7955
7956
7957 @node IEOR
7958 @section @code{IEOR} --- Bitwise logical exclusive or
7959 @fnindex IEOR
7960 @fnindex BIEOR
7961 @fnindex IIEOR
7962 @fnindex JIEOR
7963 @fnindex KIEOR
7964 @cindex bitwise logical exclusive or
7965 @cindex logical exclusive or, bitwise
7966
7967 @table @asis
7968 @item @emph{Description}:
7969 @code{IEOR} returns the bitwise Boolean exclusive-OR of @var{I} and
7970 @var{J}.
7971
7972 @item @emph{Standard}:
7973 Fortran 95 and later, has overloads that are GNU extensions
7974
7975 @item @emph{Class}:
7976 Elemental function
7977
7978 @item @emph{Syntax}:
7979 @code{RESULT = IEOR(I, J)}
7980
7981 @item @emph{Arguments}:
7982 @multitable @columnfractions .15 .70
7983 @item @var{I} @tab The type shall be @code{INTEGER} or a boz-literal-constant.
7984 @item @var{J} @tab The type shall be @code{INTEGER} with the same
7985 kind type parameter as @var{I} or a boz-literal-constant.
7986 @var{I} and @var{J} shall not both be boz-literal-constants.
7987 @end multitable
7988
7989 @item @emph{Return value}:
7990 The return type is @code{INTEGER} with the kind type parameter of the
7991 arguments.
7992 A boz-literal-constant is converted to an @code{INTEGER} with the kind
7993 type parameter of the other argument as-if a call to @ref{INT} occurred.
7994
7995 @item @emph{Specific names}:
7996 @multitable @columnfractions .20 .20 .20 .25
7997 @item Name @tab Argument @tab Return type @tab Standard
7998 @item @code{IEOR(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 95 and later
7999 @item @code{BIEOR(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
8000 @item @code{IIEOR(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
8001 @item @code{JIEOR(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
8002 @item @code{KIEOR(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
8003 @end multitable
8004
8005 @item @emph{See also}:
8006 @ref{IOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
8007 @end table
8008
8009
8010
8011 @node IERRNO
8012 @section @code{IERRNO} --- Get the last system error number
8013 @fnindex IERRNO
8014 @cindex system, error handling
8015
8016 @table @asis
8017 @item @emph{Description}:
8018 Returns the last system error number, as given by the C @code{errno}
8019 variable.
8020
8021 @item @emph{Standard}:
8022 GNU extension
8023
8024 @item @emph{Class}:
8025 Function
8026
8027 @item @emph{Syntax}:
8028 @code{RESULT = IERRNO()}
8029
8030 @item @emph{Arguments}:
8031 None.
8032
8033 @item @emph{Return value}:
8034 The return value is of type @code{INTEGER} and of the default integer
8035 kind.
8036
8037 @item @emph{See also}:
8038 @ref{PERROR}
8039 @end table
8040
8041
8042
8043 @node IMAGE_INDEX
8044 @section @code{IMAGE_INDEX} --- Function that converts a cosubscript to an image index
8045 @fnindex IMAGE_INDEX
8046 @cindex coarray, @code{IMAGE_INDEX}
8047 @cindex images, cosubscript to image index conversion
8048
8049 @table @asis
8050 @item @emph{Description}:
8051 Returns the image index belonging to a cosubscript.
8052
8053 @item @emph{Standard}:
8054 Fortran 2008 and later
8055
8056 @item @emph{Class}:
8057 Inquiry function.
8058
8059 @item @emph{Syntax}:
8060 @code{RESULT = IMAGE_INDEX(COARRAY, SUB)}
8061
8062 @item @emph{Arguments}: None.
8063 @multitable @columnfractions .15 .70
8064 @item @var{COARRAY} @tab Coarray of any type.
8065 @item @var{SUB} @tab default integer rank-1 array of a size equal to
8066 the corank of @var{COARRAY}.
8067 @end multitable
8068
8069
8070 @item @emph{Return value}:
8071 Scalar default integer with the value of the image index which corresponds
8072 to the cosubscripts. For invalid cosubscripts the result is zero.
8073
8074 @item @emph{Example}:
8075 @smallexample
8076 INTEGER :: array[2,-1:4,8,*]
8077 ! Writes 28 (or 0 if there are fewer than 28 images)
8078 WRITE (*,*) IMAGE_INDEX (array, [2,0,3,1])
8079 @end smallexample
8080
8081 @item @emph{See also}:
8082 @ref{THIS_IMAGE}, @ref{NUM_IMAGES}
8083 @end table
8084
8085
8086
8087 @node INDEX intrinsic
8088 @section @code{INDEX} --- Position of a substring within a string
8089 @fnindex INDEX
8090 @cindex substring position
8091 @cindex string, find substring
8092
8093 @table @asis
8094 @item @emph{Description}:
8095 Returns the position of the start of the first occurrence of string
8096 @var{SUBSTRING} as a substring in @var{STRING}, counting from one. If
8097 @var{SUBSTRING} is not present in @var{STRING}, zero is returned. If
8098 the @var{BACK} argument is present and true, the return value is the
8099 start of the last occurrence rather than the first.
8100
8101 @item @emph{Standard}:
8102 Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later
8103
8104 @item @emph{Class}:
8105 Elemental function
8106
8107 @item @emph{Syntax}:
8108 @code{RESULT = INDEX(STRING, SUBSTRING [, BACK [, KIND]])}
8109
8110 @item @emph{Arguments}:
8111 @multitable @columnfractions .15 .70
8112 @item @var{STRING} @tab Shall be a scalar @code{CHARACTER}, with
8113 @code{INTENT(IN)}
8114 @item @var{SUBSTRING} @tab Shall be a scalar @code{CHARACTER}, with
8115 @code{INTENT(IN)}
8116 @item @var{BACK} @tab (Optional) Shall be a scalar @code{LOGICAL}, with
8117 @code{INTENT(IN)}
8118 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
8119 expression indicating the kind parameter of the result.
8120 @end multitable
8121
8122 @item @emph{Return value}:
8123 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
8124 @var{KIND} is absent, the return value is of default integer kind.
8125
8126 @item @emph{Specific names}:
8127 @multitable @columnfractions .20 .20 .20 .25
8128 @item Name @tab Argument @tab Return type @tab Standard
8129 @item @code{INDEX(STRING, SUBSTRING)} @tab @code{CHARACTER} @tab @code{INTEGER(4)} @tab Fortran 77 and later
8130 @end multitable
8131
8132 @item @emph{See also}:
8133 @ref{SCAN}, @ref{VERIFY}
8134 @end table
8135
8136
8137
8138 @node INT
8139 @section @code{INT} --- Convert to integer type
8140 @fnindex INT
8141 @fnindex IFIX
8142 @fnindex IDINT
8143 @cindex conversion, to integer
8144
8145 @table @asis
8146 @item @emph{Description}:
8147 Convert to integer type
8148
8149 @item @emph{Standard}:
8150 Fortran 77 and later
8151
8152 @item @emph{Class}:
8153 Elemental function
8154
8155 @item @emph{Syntax}:
8156 @code{RESULT = INT(A [, KIND))}
8157
8158 @item @emph{Arguments}:
8159 @multitable @columnfractions .15 .70
8160 @item @var{A} @tab Shall be of type @code{INTEGER},
8161 @code{REAL}, or @code{COMPLEX}.
8162 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
8163 expression indicating the kind parameter of the result.
8164 @end multitable
8165
8166 @item @emph{Return value}:
8167 These functions return a @code{INTEGER} variable or array under
8168 the following rules:
8169
8170 @table @asis
8171 @item (A)
8172 If @var{A} is of type @code{INTEGER}, @code{INT(A) = A}
8173 @item (B)
8174 If @var{A} is of type @code{REAL} and @math{|A| < 1}, @code{INT(A)}
8175 equals @code{0}. If @math{|A| \geq 1}, then @code{INT(A)} is the integer
8176 whose magnitude is the largest integer that does not exceed the magnitude
8177 of @var{A} and whose sign is the same as the sign of @var{A}.
8178 @item (C)
8179 If @var{A} is of type @code{COMPLEX}, rule B is applied to the real part of @var{A}.
8180 @end table
8181
8182 @item @emph{Example}:
8183 @smallexample
8184 program test_int
8185 integer :: i = 42
8186 complex :: z = (-3.7, 1.0)
8187 print *, int(i)
8188 print *, int(z), int(z,8)
8189 end program
8190 @end smallexample
8191
8192 @item @emph{Specific names}:
8193 @multitable @columnfractions .20 .20 .20 .25
8194 @item Name @tab Argument @tab Return type @tab Standard
8195 @item @code{INT(A)} @tab @code{REAL(4) A} @tab @code{INTEGER} @tab Fortran 77 and later
8196 @item @code{IFIX(A)} @tab @code{REAL(4) A} @tab @code{INTEGER} @tab Fortran 77 and later
8197 @item @code{IDINT(A)} @tab @code{REAL(8) A} @tab @code{INTEGER} @tab Fortran 77 and later
8198 @end multitable
8199
8200 @end table
8201
8202
8203 @node INT2
8204 @section @code{INT2} --- Convert to 16-bit integer type
8205 @fnindex INT2
8206 @fnindex SHORT
8207 @cindex conversion, to integer
8208
8209 @table @asis
8210 @item @emph{Description}:
8211 Convert to a @code{KIND=2} integer type. This is equivalent to the
8212 standard @code{INT} intrinsic with an optional argument of
8213 @code{KIND=2}, and is only included for backwards compatibility.
8214
8215 The @code{SHORT} intrinsic is equivalent to @code{INT2}.
8216
8217 @item @emph{Standard}:
8218 GNU extension
8219
8220 @item @emph{Class}:
8221 Elemental function
8222
8223 @item @emph{Syntax}:
8224 @code{RESULT = INT2(A)}
8225
8226 @item @emph{Arguments}:
8227 @multitable @columnfractions .15 .70
8228 @item @var{A} @tab Shall be of type @code{INTEGER},
8229 @code{REAL}, or @code{COMPLEX}.
8230 @end multitable
8231
8232 @item @emph{Return value}:
8233 The return value is a @code{INTEGER(2)} variable.
8234
8235 @item @emph{See also}:
8236 @ref{INT}, @ref{INT8}, @ref{LONG}
8237 @end table
8238
8239
8240
8241 @node INT8
8242 @section @code{INT8} --- Convert to 64-bit integer type
8243 @fnindex INT8
8244 @cindex conversion, to integer
8245
8246 @table @asis
8247 @item @emph{Description}:
8248 Convert to a @code{KIND=8} integer type. This is equivalent to the
8249 standard @code{INT} intrinsic with an optional argument of
8250 @code{KIND=8}, and is only included for backwards compatibility.
8251
8252 @item @emph{Standard}:
8253 GNU extension
8254
8255 @item @emph{Class}:
8256 Elemental function
8257
8258 @item @emph{Syntax}:
8259 @code{RESULT = INT8(A)}
8260
8261 @item @emph{Arguments}:
8262 @multitable @columnfractions .15 .70
8263 @item @var{A} @tab Shall be of type @code{INTEGER},
8264 @code{REAL}, or @code{COMPLEX}.
8265 @end multitable
8266
8267 @item @emph{Return value}:
8268 The return value is a @code{INTEGER(8)} variable.
8269
8270 @item @emph{See also}:
8271 @ref{INT}, @ref{INT2}, @ref{LONG}
8272 @end table
8273
8274
8275
8276 @node IOR
8277 @section @code{IOR} --- Bitwise logical or
8278 @fnindex IOR
8279 @fnindex BIOR
8280 @fnindex IIOR
8281 @fnindex JIOR
8282 @fnindex KIOR
8283 @cindex bitwise logical or
8284 @cindex logical or, bitwise
8285
8286 @table @asis
8287 @item @emph{Description}:
8288 @code{IOR} returns the bitwise Boolean inclusive-OR of @var{I} and
8289 @var{J}.
8290
8291 @item @emph{Standard}:
8292 Fortran 95 and later, has overloads that are GNU extensions
8293
8294 @item @emph{Class}:
8295 Elemental function
8296
8297 @item @emph{Syntax}:
8298 @code{RESULT = IOR(I, J)}
8299
8300 @item @emph{Arguments}:
8301 @multitable @columnfractions .15 .70
8302 @item @var{I} @tab The type shall be @code{INTEGER} or a boz-literal-constant.
8303 @item @var{J} @tab The type shall be @code{INTEGER} with the same
8304 kind type parameter as @var{I} or a boz-literal-constant.
8305 @var{I} and @var{J} shall not both be boz-literal-constants.
8306 @end multitable
8307
8308 @item @emph{Return value}:
8309 The return type is @code{INTEGER} with the kind type parameter of the
8310 arguments.
8311 A boz-literal-constant is converted to an @code{INTEGER} with the kind
8312 type parameter of the other argument as-if a call to @ref{INT} occurred.
8313
8314 @item @emph{Specific names}:
8315 @multitable @columnfractions .20 .20 .20 .25
8316 @item Name @tab Argument @tab Return type @tab Standard
8317 @item @code{IOR(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 95 and later
8318 @item @code{BIOR(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
8319 @item @code{IIOR(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
8320 @item @code{JIOR(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
8321 @item @code{KIOR(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
8322 @end multitable
8323
8324 @item @emph{See also}:
8325 @ref{IEOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
8326 @end table
8327
8328
8329
8330 @node IPARITY
8331 @section @code{IPARITY} --- Bitwise XOR of array elements
8332 @fnindex IPARITY
8333 @cindex array, parity
8334 @cindex array, XOR
8335 @cindex bits, XOR of array elements
8336
8337 @table @asis
8338 @item @emph{Description}:
8339 Reduces with bitwise XOR (exclusive or) the elements of @var{ARRAY} along
8340 dimension @var{DIM} if the corresponding element in @var{MASK} is @code{TRUE}.
8341
8342 @item @emph{Standard}:
8343 Fortran 2008 and later
8344
8345 @item @emph{Class}:
8346 Transformational function
8347
8348 @item @emph{Syntax}:
8349 @multitable @columnfractions .80
8350 @item @code{RESULT = IPARITY(ARRAY[, MASK])}
8351 @item @code{RESULT = IPARITY(ARRAY, DIM[, MASK])}
8352 @end multitable
8353
8354 @item @emph{Arguments}:
8355 @multitable @columnfractions .15 .70
8356 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER}
8357 @item @var{DIM} @tab (Optional) shall be a scalar of type
8358 @code{INTEGER} with a value in the range from 1 to n, where n
8359 equals the rank of @var{ARRAY}.
8360 @item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL}
8361 and either be a scalar or an array of the same shape as @var{ARRAY}.
8362 @end multitable
8363
8364 @item @emph{Return value}:
8365 The result is of the same type as @var{ARRAY}.
8366
8367 If @var{DIM} is absent, a scalar with the bitwise XOR of all elements in
8368 @var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals
8369 the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with
8370 dimension @var{DIM} dropped is returned.
8371
8372 @item @emph{Example}:
8373 @smallexample
8374 PROGRAM test_iparity
8375 INTEGER(1) :: a(2)
8376
8377 a(1) = b'00100100'
8378 a(2) = b'01101010'
8379
8380 ! prints 01001110
8381 PRINT '(b8.8)', IPARITY(a)
8382 END PROGRAM
8383 @end smallexample
8384
8385 @item @emph{See also}:
8386 @ref{IANY}, @ref{IALL}, @ref{IEOR}, @ref{PARITY}
8387 @end table
8388
8389
8390
8391 @node IRAND
8392 @section @code{IRAND} --- Integer pseudo-random number
8393 @fnindex IRAND
8394 @cindex random number generation
8395
8396 @table @asis
8397 @item @emph{Description}:
8398 @code{IRAND(FLAG)} returns a pseudo-random number from a uniform
8399 distribution between 0 and a system-dependent limit (which is in most
8400 cases 2147483647). If @var{FLAG} is 0, the next number
8401 in the current sequence is returned; if @var{FLAG} is 1, the generator
8402 is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
8403 it is used as a new seed with @code{SRAND}.
8404
8405 This intrinsic routine is provided for backwards compatibility with
8406 GNU Fortran 77. It implements a simple modulo generator as provided
8407 by @command{g77}. For new code, one should consider the use of
8408 @ref{RANDOM_NUMBER} as it implements a superior algorithm.
8409
8410 @item @emph{Standard}:
8411 GNU extension
8412
8413 @item @emph{Class}:
8414 Function
8415
8416 @item @emph{Syntax}:
8417 @code{RESULT = IRAND(I)}
8418
8419 @item @emph{Arguments}:
8420 @multitable @columnfractions .15 .70
8421 @item @var{I} @tab Shall be a scalar @code{INTEGER} of kind 4.
8422 @end multitable
8423
8424 @item @emph{Return value}:
8425 The return value is of @code{INTEGER(kind=4)} type.
8426
8427 @item @emph{Example}:
8428 @smallexample
8429 program test_irand
8430 integer,parameter :: seed = 86456
8431
8432 call srand(seed)
8433 print *, irand(), irand(), irand(), irand()
8434 print *, irand(seed), irand(), irand(), irand()
8435 end program test_irand
8436 @end smallexample
8437
8438 @end table
8439
8440
8441
8442 @node IS_CONTIGUOUS
8443 @section @code{IS_CONTIGUOUS} --- Test whether an array is contiguous
8444 @fnindex IS_IOSTAT_EOR
8445 @cindex array, contiguity
8446
8447 @table @asis
8448 @item @emph{Description}:
8449 @code{IS_CONTIGUOUS} tests whether an array is contiguous.
8450
8451 @item @emph{Standard}:
8452 Fortran 2008 and later
8453
8454 @item @emph{Class}:
8455 Inquiry function
8456
8457 @item @emph{Syntax}:
8458 @code{RESULT = IS_CONTIGUOUS(ARRAY)}
8459
8460 @item @emph{Arguments}:
8461 @multitable @columnfractions .15 .70
8462 @item @var{ARRAY} @tab Shall be an array of any type.
8463 @end multitable
8464
8465 @item @emph{Return value}:
8466 Returns a @code{LOGICAL} of the default kind, which @code{.TRUE.} if
8467 @var{ARRAY} is contiguous and false otherwise.
8468
8469 @item @emph{Example}:
8470 @smallexample
8471 program test
8472 integer :: a(10)
8473 a = [1,2,3,4,5,6,7,8,9,10]
8474 call sub (a) ! every element, is contiguous
8475 call sub (a(::2)) ! every other element, is noncontiguous
8476 contains
8477 subroutine sub (x)
8478 integer :: x(:)
8479 if (is_contiguous (x)) then
8480 write (*,*) 'X is contiguous'
8481 else
8482 write (*,*) 'X is not contiguous'
8483 end if
8484 end subroutine sub
8485 end program test
8486 @end smallexample
8487 @end table
8488
8489
8490
8491 @node IS_IOSTAT_END
8492 @section @code{IS_IOSTAT_END} --- Test for end-of-file value
8493 @fnindex IS_IOSTAT_END
8494 @cindex @code{IOSTAT}, end of file
8495
8496 @table @asis
8497 @item @emph{Description}:
8498 @code{IS_IOSTAT_END} tests whether an variable has the value of the I/O
8499 status ``end of file''. The function is equivalent to comparing the variable
8500 with the @code{IOSTAT_END} parameter of the intrinsic module
8501 @code{ISO_FORTRAN_ENV}.
8502
8503 @item @emph{Standard}:
8504 Fortran 2003 and later
8505
8506 @item @emph{Class}:
8507 Elemental function
8508
8509 @item @emph{Syntax}:
8510 @code{RESULT = IS_IOSTAT_END(I)}
8511
8512 @item @emph{Arguments}:
8513 @multitable @columnfractions .15 .70
8514 @item @var{I} @tab Shall be of the type @code{INTEGER}.
8515 @end multitable
8516
8517 @item @emph{Return value}:
8518 Returns a @code{LOGICAL} of the default kind, which @code{.TRUE.} if
8519 @var{I} has the value which indicates an end of file condition for
8520 @code{IOSTAT=} specifiers, and is @code{.FALSE.} otherwise.
8521
8522 @item @emph{Example}:
8523 @smallexample
8524 PROGRAM iostat
8525 IMPLICIT NONE
8526 INTEGER :: stat, i
8527 OPEN(88, FILE='test.dat')
8528 READ(88, *, IOSTAT=stat) i
8529 IF(IS_IOSTAT_END(stat)) STOP 'END OF FILE'
8530 END PROGRAM
8531 @end smallexample
8532 @end table
8533
8534
8535
8536 @node IS_IOSTAT_EOR
8537 @section @code{IS_IOSTAT_EOR} --- Test for end-of-record value
8538 @fnindex IS_IOSTAT_EOR
8539 @cindex @code{IOSTAT}, end of record
8540
8541 @table @asis
8542 @item @emph{Description}:
8543 @code{IS_IOSTAT_EOR} tests whether an variable has the value of the I/O
8544 status ``end of record''. The function is equivalent to comparing the
8545 variable with the @code{IOSTAT_EOR} parameter of the intrinsic module
8546 @code{ISO_FORTRAN_ENV}.
8547
8548 @item @emph{Standard}:
8549 Fortran 2003 and later
8550
8551 @item @emph{Class}:
8552 Elemental function
8553
8554 @item @emph{Syntax}:
8555 @code{RESULT = IS_IOSTAT_EOR(I)}
8556
8557 @item @emph{Arguments}:
8558 @multitable @columnfractions .15 .70
8559 @item @var{I} @tab Shall be of the type @code{INTEGER}.
8560 @end multitable
8561
8562 @item @emph{Return value}:
8563 Returns a @code{LOGICAL} of the default kind, which @code{.TRUE.} if
8564 @var{I} has the value which indicates an end of file condition for
8565 @code{IOSTAT=} specifiers, and is @code{.FALSE.} otherwise.
8566
8567 @item @emph{Example}:
8568 @smallexample
8569 PROGRAM iostat
8570 IMPLICIT NONE
8571 INTEGER :: stat, i(50)
8572 OPEN(88, FILE='test.dat', FORM='UNFORMATTED')
8573 READ(88, IOSTAT=stat) i
8574 IF(IS_IOSTAT_EOR(stat)) STOP 'END OF RECORD'
8575 END PROGRAM
8576 @end smallexample
8577 @end table
8578
8579
8580 @node ISATTY
8581 @section @code{ISATTY} --- Whether a unit is a terminal device.
8582 @fnindex ISATTY
8583 @cindex system, terminal
8584
8585 @table @asis
8586 @item @emph{Description}:
8587 Determine whether a unit is connected to a terminal device.
8588
8589 @item @emph{Standard}:
8590 GNU extension
8591
8592 @item @emph{Class}:
8593 Function
8594
8595 @item @emph{Syntax}:
8596 @code{RESULT = ISATTY(UNIT)}
8597
8598 @item @emph{Arguments}:
8599 @multitable @columnfractions .15 .70
8600 @item @var{UNIT} @tab Shall be a scalar @code{INTEGER}.
8601 @end multitable
8602
8603 @item @emph{Return value}:
8604 Returns @code{.TRUE.} if the @var{UNIT} is connected to a terminal
8605 device, @code{.FALSE.} otherwise.
8606
8607 @item @emph{Example}:
8608 @smallexample
8609 PROGRAM test_isatty
8610 INTEGER(kind=1) :: unit
8611 DO unit = 1, 10
8612 write(*,*) isatty(unit=unit)
8613 END DO
8614 END PROGRAM
8615 @end smallexample
8616 @item @emph{See also}:
8617 @ref{TTYNAM}
8618 @end table
8619
8620
8621
8622 @node ISHFT
8623 @section @code{ISHFT} --- Shift bits
8624 @fnindex ISHFT
8625 @fnindex BSHFT
8626 @fnindex IISHFT
8627 @fnindex JISHFT
8628 @fnindex KISHFT
8629 @cindex bits, shift
8630
8631 @table @asis
8632 @item @emph{Description}:
8633 @code{ISHFT} returns a value corresponding to @var{I} with all of the
8634 bits shifted @var{SHIFT} places. A value of @var{SHIFT} greater than
8635 zero corresponds to a left shift, a value of zero corresponds to no
8636 shift, and a value less than zero corresponds to a right shift. If the
8637 absolute value of @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the
8638 value is undefined. Bits shifted out from the left end or right end are
8639 lost; zeros are shifted in from the opposite end.
8640
8641 @item @emph{Standard}:
8642 Fortran 95 and later, has overloads that are GNU extensions
8643
8644 @item @emph{Class}:
8645 Elemental function
8646
8647 @item @emph{Syntax}:
8648 @code{RESULT = ISHFT(I, SHIFT)}
8649
8650 @item @emph{Arguments}:
8651 @multitable @columnfractions .15 .70
8652 @item @var{I} @tab The type shall be @code{INTEGER}.
8653 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
8654 @end multitable
8655
8656 @item @emph{Return value}:
8657 The return value is of type @code{INTEGER} and of the same kind as
8658 @var{I}.
8659
8660 @item @emph{Specific names}:
8661 @multitable @columnfractions .20 .20 .20 .25
8662 @item Name @tab Argument @tab Return type @tab Standard
8663 @item @code{ISHFT(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 95 and later
8664 @item @code{BSHFT(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
8665 @item @code{IISHFT(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
8666 @item @code{JISHFT(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
8667 @item @code{KISHFT(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
8668 @end multitable
8669
8670 @item @emph{See also}:
8671 @ref{ISHFTC}
8672 @end table
8673
8674
8675
8676 @node ISHFTC
8677 @section @code{ISHFTC} --- Shift bits circularly
8678 @fnindex ISHFTC
8679 @fnindex BSHFTC
8680 @fnindex IISHFTC
8681 @fnindex JISHFTC
8682 @fnindex KISHFTC
8683 @cindex bits, shift circular
8684
8685 @table @asis
8686 @item @emph{Description}:
8687 @code{ISHFTC} returns a value corresponding to @var{I} with the
8688 rightmost @var{SIZE} bits shifted circularly @var{SHIFT} places; that
8689 is, bits shifted out one end are shifted into the opposite end. A value
8690 of @var{SHIFT} greater than zero corresponds to a left shift, a value of
8691 zero corresponds to no shift, and a value less than zero corresponds to
8692 a right shift. The absolute value of @var{SHIFT} must be less than
8693 @var{SIZE}. If the @var{SIZE} argument is omitted, it is taken to be
8694 equivalent to @code{BIT_SIZE(I)}.
8695
8696 @item @emph{Standard}:
8697 Fortran 95 and later, has overloads that are GNU extensions
8698
8699 @item @emph{Class}:
8700 Elemental function
8701
8702 @item @emph{Syntax}:
8703 @code{RESULT = ISHFTC(I, SHIFT [, SIZE])}
8704
8705 @item @emph{Arguments}:
8706 @multitable @columnfractions .15 .70
8707 @item @var{I} @tab The type shall be @code{INTEGER}.
8708 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
8709 @item @var{SIZE} @tab (Optional) The type shall be @code{INTEGER};
8710 the value must be greater than zero and less than or equal to
8711 @code{BIT_SIZE(I)}.
8712 @end multitable
8713
8714 @item @emph{Return value}:
8715 The return value is of type @code{INTEGER} and of the same kind as
8716 @var{I}.
8717
8718 @item @emph{Specific names}:
8719 @multitable @columnfractions .20 .20 .20 .25
8720 @item Name @tab Argument @tab Return type @tab Standard
8721 @item @code{ISHFTC(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 95 and later
8722 @item @code{BSHFTC(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
8723 @item @code{IISHFTC(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
8724 @item @code{JISHFTC(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
8725 @item @code{KISHFTC(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
8726 @end multitable
8727
8728 @item @emph{See also}:
8729 @ref{ISHFT}
8730 @end table
8731
8732
8733
8734 @node ISNAN
8735 @section @code{ISNAN} --- Test for a NaN
8736 @fnindex ISNAN
8737 @cindex IEEE, ISNAN
8738
8739 @table @asis
8740 @item @emph{Description}:
8741 @code{ISNAN} tests whether a floating-point value is an IEEE
8742 Not-a-Number (NaN).
8743 @item @emph{Standard}:
8744 GNU extension
8745
8746 @item @emph{Class}:
8747 Elemental function
8748
8749 @item @emph{Syntax}:
8750 @code{ISNAN(X)}
8751
8752 @item @emph{Arguments}:
8753 @multitable @columnfractions .15 .70
8754 @item @var{X} @tab Variable of the type @code{REAL}.
8755
8756 @end multitable
8757
8758 @item @emph{Return value}:
8759 Returns a default-kind @code{LOGICAL}. The returned value is @code{TRUE}
8760 if @var{X} is a NaN and @code{FALSE} otherwise.
8761
8762 @item @emph{Example}:
8763 @smallexample
8764 program test_nan
8765 implicit none
8766 real :: x
8767 x = -1.0
8768 x = sqrt(x)
8769 if (isnan(x)) stop '"x" is a NaN'
8770 end program test_nan
8771 @end smallexample
8772 @end table
8773
8774
8775
8776 @node ITIME
8777 @section @code{ITIME} --- Get current local time subroutine (hour/minutes/seconds)
8778 @fnindex ITIME
8779 @cindex time, current
8780 @cindex current time
8781
8782 @table @asis
8783 @item @emph{Description}:
8784 @code{ITIME(VALUES)} Fills @var{VALUES} with the numerical values at the
8785 current local time. The hour (in the range 1-24), minute (in the range 1-60),
8786 and seconds (in the range 1-60) appear in elements 1, 2, and 3 of @var{VALUES},
8787 respectively.
8788
8789 This intrinsic routine is provided for backwards compatibility with
8790 GNU Fortran 77. In new code, programmers should consider the use of
8791 the @ref{DATE_AND_TIME} intrinsic defined by the Fortran 95
8792 standard.
8793
8794 @item @emph{Standard}:
8795 GNU extension
8796
8797 @item @emph{Class}:
8798 Subroutine
8799
8800 @item @emph{Syntax}:
8801 @code{CALL ITIME(VALUES)}
8802
8803 @item @emph{Arguments}:
8804 @multitable @columnfractions .15 .70
8805 @item @var{VALUES} @tab The type shall be @code{INTEGER, DIMENSION(3)}
8806 and the kind shall be the default integer kind.
8807 @end multitable
8808
8809 @item @emph{Return value}:
8810 Does not return anything.
8811
8812
8813 @item @emph{Example}:
8814 @smallexample
8815 program test_itime
8816 integer, dimension(3) :: tarray
8817 call itime(tarray)
8818 print *, tarray(1)
8819 print *, tarray(2)
8820 print *, tarray(3)
8821 end program test_itime
8822 @end smallexample
8823
8824 @item @emph{See also}:
8825 @ref{DATE_AND_TIME}
8826 @end table
8827
8828
8829
8830 @node KILL
8831 @section @code{KILL} --- Send a signal to a process
8832 @fnindex KILL
8833
8834 @table @asis
8835 @item @emph{Description}:
8836 @item @emph{Standard}:
8837 Sends the signal specified by @var{SIG} to the process @var{PID}.
8838 See @code{kill(2)}.
8839
8840 This intrinsic is provided in both subroutine and function forms;
8841 however, only one form can be used in any given program unit.
8842
8843 @item @emph{Class}:
8844 Subroutine, function
8845
8846 @item @emph{Syntax}:
8847 @multitable @columnfractions .80
8848 @item @code{CALL KILL(PID, SIG [, STATUS])}
8849 @item @code{STATUS = KILL(PID, SIG)}
8850 @end multitable
8851
8852 @item @emph{Arguments}:
8853 @multitable @columnfractions .15 .70
8854 @item @var{PID} @tab Shall be a scalar @code{INTEGER} with @code{INTENT(IN)}.
8855 @item @var{SIG} @tab Shall be a scalar @code{INTEGER} with @code{INTENT(IN)}.
8856 @item @var{STATUS} @tab [Subroutine](Optional)
8857 Shall be a scalar @code{INTEGER}.
8858 Returns 0 on success; otherwise a system-specific error code is returned.
8859 @item @var{STATUS} @tab [Function] The kind type parameter is that of
8860 @code{pid}.
8861 Returns 0 on success; otherwise a system-specific error code is returned.
8862 @end multitable
8863
8864 @item @emph{See also}:
8865 @ref{ABORT}, @ref{EXIT}
8866 @end table
8867
8868
8869 @node KIND
8870 @section @code{KIND} --- Kind of an entity
8871 @fnindex KIND
8872 @cindex kind
8873
8874 @table @asis
8875 @item @emph{Description}:
8876 @code{KIND(X)} returns the kind value of the entity @var{X}.
8877
8878 @item @emph{Standard}:
8879 Fortran 95 and later
8880
8881 @item @emph{Class}:
8882 Inquiry function
8883
8884 @item @emph{Syntax}:
8885 @code{K = KIND(X)}
8886
8887 @item @emph{Arguments}:
8888 @multitable @columnfractions .15 .70
8889 @item @var{X} @tab Shall be of type @code{LOGICAL}, @code{INTEGER},
8890 @code{REAL}, @code{COMPLEX} or @code{CHARACTER}.
8891 @end multitable
8892
8893 @item @emph{Return value}:
8894 The return value is a scalar of type @code{INTEGER} and of the default
8895 integer kind.
8896
8897 @item @emph{Example}:
8898 @smallexample
8899 program test_kind
8900 integer,parameter :: kc = kind(' ')
8901 integer,parameter :: kl = kind(.true.)
8902
8903 print *, "The default character kind is ", kc
8904 print *, "The default logical kind is ", kl
8905 end program test_kind
8906 @end smallexample
8907
8908 @end table
8909
8910
8911
8912 @node LBOUND
8913 @section @code{LBOUND} --- Lower dimension bounds of an array
8914 @fnindex LBOUND
8915 @cindex array, lower bound
8916
8917 @table @asis
8918 @item @emph{Description}:
8919 Returns the lower bounds of an array, or a single lower bound
8920 along the @var{DIM} dimension.
8921 @item @emph{Standard}:
8922 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
8923
8924 @item @emph{Class}:
8925 Inquiry function
8926
8927 @item @emph{Syntax}:
8928 @code{RESULT = LBOUND(ARRAY [, DIM [, KIND]])}
8929
8930 @item @emph{Arguments}:
8931 @multitable @columnfractions .15 .70
8932 @item @var{ARRAY} @tab Shall be an array, of any type.
8933 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
8934 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
8935 expression indicating the kind parameter of the result.
8936 @end multitable
8937
8938 @item @emph{Return value}:
8939 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
8940 @var{KIND} is absent, the return value is of default integer kind.
8941 If @var{DIM} is absent, the result is an array of the lower bounds of
8942 @var{ARRAY}. If @var{DIM} is present, the result is a scalar
8943 corresponding to the lower bound of the array along that dimension. If
8944 @var{ARRAY} is an expression rather than a whole array or array
8945 structure component, or if it has a zero extent along the relevant
8946 dimension, the lower bound is taken to be 1.
8947
8948 @item @emph{See also}:
8949 @ref{UBOUND}, @ref{LCOBOUND}
8950 @end table
8951
8952
8953
8954 @node LCOBOUND
8955 @section @code{LCOBOUND} --- Lower codimension bounds of an array
8956 @fnindex LCOBOUND
8957 @cindex coarray, lower bound
8958
8959 @table @asis
8960 @item @emph{Description}:
8961 Returns the lower bounds of a coarray, or a single lower cobound
8962 along the @var{DIM} codimension.
8963 @item @emph{Standard}:
8964 Fortran 2008 and later
8965
8966 @item @emph{Class}:
8967 Inquiry function
8968
8969 @item @emph{Syntax}:
8970 @code{RESULT = LCOBOUND(COARRAY [, DIM [, KIND]])}
8971
8972 @item @emph{Arguments}:
8973 @multitable @columnfractions .15 .70
8974 @item @var{ARRAY} @tab Shall be an coarray, of any type.
8975 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
8976 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
8977 expression indicating the kind parameter of the result.
8978 @end multitable
8979
8980 @item @emph{Return value}:
8981 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
8982 @var{KIND} is absent, the return value is of default integer kind.
8983 If @var{DIM} is absent, the result is an array of the lower cobounds of
8984 @var{COARRAY}. If @var{DIM} is present, the result is a scalar
8985 corresponding to the lower cobound of the array along that codimension.
8986
8987 @item @emph{See also}:
8988 @ref{UCOBOUND}, @ref{LBOUND}
8989 @end table
8990
8991
8992
8993 @node LEADZ
8994 @section @code{LEADZ} --- Number of leading zero bits of an integer
8995 @fnindex LEADZ
8996 @cindex zero bits
8997
8998 @table @asis
8999 @item @emph{Description}:
9000 @code{LEADZ} returns the number of leading zero bits of an integer.
9001
9002 @item @emph{Standard}:
9003 Fortran 2008 and later
9004
9005 @item @emph{Class}:
9006 Elemental function
9007
9008 @item @emph{Syntax}:
9009 @code{RESULT = LEADZ(I)}
9010
9011 @item @emph{Arguments}:
9012 @multitable @columnfractions .15 .70
9013 @item @var{I} @tab Shall be of type @code{INTEGER}.
9014 @end multitable
9015
9016 @item @emph{Return value}:
9017 The type of the return value is the default @code{INTEGER}.
9018 If all the bits of @code{I} are zero, the result value is @code{BIT_SIZE(I)}.
9019
9020 @item @emph{Example}:
9021 @smallexample
9022 PROGRAM test_leadz
9023 WRITE (*,*) BIT_SIZE(1) ! prints 32
9024 WRITE (*,*) LEADZ(1) ! prints 31
9025 END PROGRAM
9026 @end smallexample
9027
9028 @item @emph{See also}:
9029 @ref{BIT_SIZE}, @ref{TRAILZ}, @ref{POPCNT}, @ref{POPPAR}
9030 @end table
9031
9032
9033
9034 @node LEN
9035 @section @code{LEN} --- Length of a character entity
9036 @fnindex LEN
9037 @cindex string, length
9038
9039 @table @asis
9040 @item @emph{Description}:
9041 Returns the length of a character string. If @var{STRING} is an array,
9042 the length of an element of @var{STRING} is returned. Note that
9043 @var{STRING} need not be defined when this intrinsic is invoked, since
9044 only the length, not the content, of @var{STRING} is needed.
9045
9046 @item @emph{Standard}:
9047 Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later
9048
9049 @item @emph{Class}:
9050 Inquiry function
9051
9052 @item @emph{Syntax}:
9053 @code{L = LEN(STRING [, KIND])}
9054
9055 @item @emph{Arguments}:
9056 @multitable @columnfractions .15 .70
9057 @item @var{STRING} @tab Shall be a scalar or array of type
9058 @code{CHARACTER}, with @code{INTENT(IN)}
9059 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
9060 expression indicating the kind parameter of the result.
9061 @end multitable
9062
9063 @item @emph{Return value}:
9064 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
9065 @var{KIND} is absent, the return value is of default integer kind.
9066
9067
9068 @item @emph{Specific names}:
9069 @multitable @columnfractions .20 .20 .20 .25
9070 @item Name @tab Argument @tab Return type @tab Standard
9071 @item @code{LEN(STRING)} @tab @code{CHARACTER} @tab @code{INTEGER} @tab Fortran 77 and later
9072 @end multitable
9073
9074
9075 @item @emph{See also}:
9076 @ref{LEN_TRIM}, @ref{ADJUSTL}, @ref{ADJUSTR}
9077 @end table
9078
9079
9080
9081 @node LEN_TRIM
9082 @section @code{LEN_TRIM} --- Length of a character entity without trailing blank characters
9083 @fnindex LEN_TRIM
9084 @cindex string, length, without trailing whitespace
9085
9086 @table @asis
9087 @item @emph{Description}:
9088 Returns the length of a character string, ignoring any trailing blanks.
9089
9090 @item @emph{Standard}:
9091 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
9092
9093 @item @emph{Class}:
9094 Elemental function
9095
9096 @item @emph{Syntax}:
9097 @code{RESULT = LEN_TRIM(STRING [, KIND])}
9098
9099 @item @emph{Arguments}:
9100 @multitable @columnfractions .15 .70
9101 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER},
9102 with @code{INTENT(IN)}
9103 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
9104 expression indicating the kind parameter of the result.
9105 @end multitable
9106
9107 @item @emph{Return value}:
9108 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
9109 @var{KIND} is absent, the return value is of default integer kind.
9110
9111 @item @emph{See also}:
9112 @ref{LEN}, @ref{ADJUSTL}, @ref{ADJUSTR}
9113 @end table
9114
9115
9116
9117 @node LGE
9118 @section @code{LGE} --- Lexical greater than or equal
9119 @fnindex LGE
9120 @cindex lexical comparison of strings
9121 @cindex string, comparison
9122
9123 @table @asis
9124 @item @emph{Description}:
9125 Determines whether one string is lexically greater than or equal to
9126 another string, where the two strings are interpreted as containing
9127 ASCII character codes. If the String A and String B are not the same
9128 length, the shorter is compared as if spaces were appended to it to form
9129 a value that has the same length as the longer.
9130
9131 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
9132 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
9133 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
9134 that the latter use the processor's character ordering (which is not
9135 ASCII on some targets), whereas the former always use the ASCII
9136 ordering.
9137
9138 @item @emph{Standard}:
9139 Fortran 77 and later
9140
9141 @item @emph{Class}:
9142 Elemental function
9143
9144 @item @emph{Syntax}:
9145 @code{RESULT = LGE(STRING_A, STRING_B)}
9146
9147 @item @emph{Arguments}:
9148 @multitable @columnfractions .15 .70
9149 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
9150 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
9151 @end multitable
9152
9153 @item @emph{Return value}:
9154 Returns @code{.TRUE.} if @code{STRING_A >= STRING_B}, and @code{.FALSE.}
9155 otherwise, based on the ASCII ordering.
9156
9157 @item @emph{Specific names}:
9158 @multitable @columnfractions .20 .20 .20 .25
9159 @item Name @tab Argument @tab Return type @tab Standard
9160 @item @code{LGE(STRING_A, STRING_B)} @tab @code{CHARACTER} @tab @code{LOGICAL} @tab Fortran 77 and later
9161 @end multitable
9162
9163 @item @emph{See also}:
9164 @ref{LGT}, @ref{LLE}, @ref{LLT}
9165 @end table
9166
9167
9168
9169 @node LGT
9170 @section @code{LGT} --- Lexical greater than
9171 @fnindex LGT
9172 @cindex lexical comparison of strings
9173 @cindex string, comparison
9174
9175 @table @asis
9176 @item @emph{Description}:
9177 Determines whether one string is lexically greater than another string,
9178 where the two strings are interpreted as containing ASCII character
9179 codes. If the String A and String B are not the same length, the
9180 shorter is compared as if spaces were appended to it to form a value
9181 that has the same length as the longer.
9182
9183 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
9184 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
9185 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
9186 that the latter use the processor's character ordering (which is not
9187 ASCII on some targets), whereas the former always use the ASCII
9188 ordering.
9189
9190 @item @emph{Standard}:
9191 Fortran 77 and later
9192
9193 @item @emph{Class}:
9194 Elemental function
9195
9196 @item @emph{Syntax}:
9197 @code{RESULT = LGT(STRING_A, STRING_B)}
9198
9199 @item @emph{Arguments}:
9200 @multitable @columnfractions .15 .70
9201 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
9202 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
9203 @end multitable
9204
9205 @item @emph{Return value}:
9206 Returns @code{.TRUE.} if @code{STRING_A > STRING_B}, and @code{.FALSE.}
9207 otherwise, based on the ASCII ordering.
9208
9209 @item @emph{Specific names}:
9210 @multitable @columnfractions .20 .20 .20 .25
9211 @item Name @tab Argument @tab Return type @tab Standard
9212 @item @code{LGT(STRING_A, STRING_B)} @tab @code{CHARACTER} @tab @code{LOGICAL} @tab Fortran 77 and later
9213 @end multitable
9214
9215 @item @emph{See also}:
9216 @ref{LGE}, @ref{LLE}, @ref{LLT}
9217 @end table
9218
9219
9220
9221 @node LINK
9222 @section @code{LINK} --- Create a hard link
9223 @fnindex LINK
9224 @cindex file system, create link
9225 @cindex file system, hard link
9226
9227 @table @asis
9228 @item @emph{Description}:
9229 Makes a (hard) link from file @var{PATH1} to @var{PATH2}. A null
9230 character (@code{CHAR(0)}) can be used to mark the end of the names in
9231 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
9232 names are ignored. If the @var{STATUS} argument is supplied, it
9233 contains 0 on success or a nonzero error code upon return; see
9234 @code{link(2)}.
9235
9236 This intrinsic is provided in both subroutine and function forms;
9237 however, only one form can be used in any given program unit.
9238
9239 @item @emph{Standard}:
9240 GNU extension
9241
9242 @item @emph{Class}:
9243 Subroutine, function
9244
9245 @item @emph{Syntax}:
9246 @multitable @columnfractions .80
9247 @item @code{CALL LINK(PATH1, PATH2 [, STATUS])}
9248 @item @code{STATUS = LINK(PATH1, PATH2)}
9249 @end multitable
9250
9251 @item @emph{Arguments}:
9252 @multitable @columnfractions .15 .70
9253 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
9254 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
9255 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
9256 @end multitable
9257
9258 @item @emph{See also}:
9259 @ref{SYMLNK}, @ref{UNLINK}
9260 @end table
9261
9262
9263
9264 @node LLE
9265 @section @code{LLE} --- Lexical less than or equal
9266 @fnindex LLE
9267 @cindex lexical comparison of strings
9268 @cindex string, comparison
9269
9270 @table @asis
9271 @item @emph{Description}:
9272 Determines whether one string is lexically less than or equal to another
9273 string, where the two strings are interpreted as containing ASCII
9274 character codes. If the String A and String B are not the same length,
9275 the shorter is compared as if spaces were appended to it to form a value
9276 that has the same length as the longer.
9277
9278 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
9279 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
9280 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
9281 that the latter use the processor's character ordering (which is not
9282 ASCII on some targets), whereas the former always use the ASCII
9283 ordering.
9284
9285 @item @emph{Standard}:
9286 Fortran 77 and later
9287
9288 @item @emph{Class}:
9289 Elemental function
9290
9291 @item @emph{Syntax}:
9292 @code{RESULT = LLE(STRING_A, STRING_B)}
9293
9294 @item @emph{Arguments}:
9295 @multitable @columnfractions .15 .70
9296 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
9297 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
9298 @end multitable
9299
9300 @item @emph{Return value}:
9301 Returns @code{.TRUE.} if @code{STRING_A <= STRING_B}, and @code{.FALSE.}
9302 otherwise, based on the ASCII ordering.
9303
9304 @item @emph{Specific names}:
9305 @multitable @columnfractions .20 .20 .20 .25
9306 @item Name @tab Argument @tab Return type @tab Standard
9307 @item @code{LLE(STRING_A, STRING_B)} @tab @code{CHARACTER} @tab @code{LOGICAL} @tab Fortran 77 and later
9308 @end multitable
9309
9310 @item @emph{See also}:
9311 @ref{LGE}, @ref{LGT}, @ref{LLT}
9312 @end table
9313
9314
9315
9316 @node LLT
9317 @section @code{LLT} --- Lexical less than
9318 @fnindex LLT
9319 @cindex lexical comparison of strings
9320 @cindex string, comparison
9321
9322 @table @asis
9323 @item @emph{Description}:
9324 Determines whether one string is lexically less than another string,
9325 where the two strings are interpreted as containing ASCII character
9326 codes. If the String A and String B are not the same length, the
9327 shorter is compared as if spaces were appended to it to form a value
9328 that has the same length as the longer.
9329
9330 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
9331 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
9332 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
9333 that the latter use the processor's character ordering (which is not
9334 ASCII on some targets), whereas the former always use the ASCII
9335 ordering.
9336
9337 @item @emph{Standard}:
9338 Fortran 77 and later
9339
9340 @item @emph{Class}:
9341 Elemental function
9342
9343 @item @emph{Syntax}:
9344 @code{RESULT = LLT(STRING_A, STRING_B)}
9345
9346 @item @emph{Arguments}:
9347 @multitable @columnfractions .15 .70
9348 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
9349 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
9350 @end multitable
9351
9352 @item @emph{Return value}:
9353 Returns @code{.TRUE.} if @code{STRING_A < STRING_B}, and @code{.FALSE.}
9354 otherwise, based on the ASCII ordering.
9355
9356 @item @emph{Specific names}:
9357 @multitable @columnfractions .20 .20 .20 .25
9358 @item Name @tab Argument @tab Return type @tab Standard
9359 @item @code{LLT(STRING_A, STRING_B)} @tab @code{CHARACTER} @tab @code{LOGICAL} @tab Fortran 77 and later
9360 @end multitable
9361
9362 @item @emph{See also}:
9363 @ref{LGE}, @ref{LGT}, @ref{LLE}
9364 @end table
9365
9366
9367
9368 @node LNBLNK
9369 @section @code{LNBLNK} --- Index of the last non-blank character in a string
9370 @fnindex LNBLNK
9371 @cindex string, find non-blank character
9372
9373 @table @asis
9374 @item @emph{Description}:
9375 Returns the length of a character string, ignoring any trailing blanks.
9376 This is identical to the standard @code{LEN_TRIM} intrinsic, and is only
9377 included for backwards compatibility.
9378
9379 @item @emph{Standard}:
9380 GNU extension
9381
9382 @item @emph{Class}:
9383 Elemental function
9384
9385 @item @emph{Syntax}:
9386 @code{RESULT = LNBLNK(STRING)}
9387
9388 @item @emph{Arguments}:
9389 @multitable @columnfractions .15 .70
9390 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER},
9391 with @code{INTENT(IN)}
9392 @end multitable
9393
9394 @item @emph{Return value}:
9395 The return value is of @code{INTEGER(kind=4)} type.
9396
9397 @item @emph{See also}:
9398 @ref{INDEX intrinsic}, @ref{LEN_TRIM}
9399 @end table
9400
9401
9402
9403 @node LOC
9404 @section @code{LOC} --- Returns the address of a variable
9405 @fnindex LOC
9406 @cindex location of a variable in memory
9407
9408 @table @asis
9409 @item @emph{Description}:
9410 @code{LOC(X)} returns the address of @var{X} as an integer.
9411
9412 @item @emph{Standard}:
9413 GNU extension
9414
9415 @item @emph{Class}:
9416 Inquiry function
9417
9418 @item @emph{Syntax}:
9419 @code{RESULT = LOC(X)}
9420
9421 @item @emph{Arguments}:
9422 @multitable @columnfractions .15 .70
9423 @item @var{X} @tab Variable of any type.
9424 @end multitable
9425
9426 @item @emph{Return value}:
9427 The return value is of type @code{INTEGER}, with a @code{KIND}
9428 corresponding to the size (in bytes) of a memory address on the target
9429 machine.
9430
9431 @item @emph{Example}:
9432 @smallexample
9433 program test_loc
9434 integer :: i
9435 real :: r
9436 i = loc(r)
9437 print *, i
9438 end program test_loc
9439 @end smallexample
9440 @end table
9441
9442
9443
9444 @node LOG
9445 @section @code{LOG} --- Natural logarithm function
9446 @fnindex LOG
9447 @fnindex ALOG
9448 @fnindex DLOG
9449 @fnindex CLOG
9450 @fnindex ZLOG
9451 @fnindex CDLOG
9452 @cindex exponential function, inverse
9453 @cindex logarithm function
9454 @cindex natural logarithm function
9455
9456 @table @asis
9457 @item @emph{Description}:
9458 @code{LOG(X)} computes the natural logarithm of @var{X}, i.e. the
9459 logarithm to the base @math{e}.
9460
9461 @item @emph{Standard}:
9462 Fortran 77 and later
9463
9464 @item @emph{Class}:
9465 Elemental function
9466
9467 @item @emph{Syntax}:
9468 @code{RESULT = LOG(X)}
9469
9470 @item @emph{Arguments}:
9471 @multitable @columnfractions .15 .70
9472 @item @var{X} @tab The type shall be @code{REAL} or
9473 @code{COMPLEX}.
9474 @end multitable
9475
9476 @item @emph{Return value}:
9477 The return value is of type @code{REAL} or @code{COMPLEX}.
9478 The kind type parameter is the same as @var{X}.
9479 If @var{X} is @code{COMPLEX}, the imaginary part @math{\omega} is in the range
9480 @math{-\pi < \omega \leq \pi}.
9481
9482 @item @emph{Example}:
9483 @smallexample
9484 program test_log
9485 real(8) :: x = 2.7182818284590451_8
9486 complex :: z = (1.0, 2.0)
9487 x = log(x) ! will yield (approximately) 1
9488 z = log(z)
9489 end program test_log
9490 @end smallexample
9491
9492 @item @emph{Specific names}:
9493 @multitable @columnfractions .20 .20 .20 .25
9494 @item Name @tab Argument @tab Return type @tab Standard
9495 @item @code{ALOG(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab f95, gnu
9496 @item @code{DLOG(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
9497 @item @code{CLOG(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab f95, gnu
9498 @item @code{ZLOG(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
9499 @item @code{CDLOG(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
9500 @end multitable
9501 @end table
9502
9503
9504
9505 @node LOG10
9506 @section @code{LOG10} --- Base 10 logarithm function
9507 @fnindex LOG10
9508 @fnindex ALOG10
9509 @fnindex DLOG10
9510 @cindex exponential function, inverse
9511 @cindex logarithm function with base 10
9512 @cindex base 10 logarithm function
9513
9514 @table @asis
9515 @item @emph{Description}:
9516 @code{LOG10(X)} computes the base 10 logarithm of @var{X}.
9517
9518 @item @emph{Standard}:
9519 Fortran 77 and later
9520
9521 @item @emph{Class}:
9522 Elemental function
9523
9524 @item @emph{Syntax}:
9525 @code{RESULT = LOG10(X)}
9526
9527 @item @emph{Arguments}:
9528 @multitable @columnfractions .15 .70
9529 @item @var{X} @tab The type shall be @code{REAL}.
9530 @end multitable
9531
9532 @item @emph{Return value}:
9533 The return value is of type @code{REAL} or @code{COMPLEX}.
9534 The kind type parameter is the same as @var{X}.
9535
9536 @item @emph{Example}:
9537 @smallexample
9538 program test_log10
9539 real(8) :: x = 10.0_8
9540 x = log10(x)
9541 end program test_log10
9542 @end smallexample
9543
9544 @item @emph{Specific names}:
9545 @multitable @columnfractions .20 .20 .20 .25
9546 @item Name @tab Argument @tab Return type @tab Standard
9547 @item @code{ALOG10(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 95 and later
9548 @item @code{DLOG10(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 95 and later
9549 @end multitable
9550 @end table
9551
9552
9553
9554 @node LOG_GAMMA
9555 @section @code{LOG_GAMMA} --- Logarithm of the Gamma function
9556 @fnindex LOG_GAMMA
9557 @fnindex LGAMMA
9558 @fnindex ALGAMA
9559 @fnindex DLGAMA
9560 @cindex Gamma function, logarithm of
9561
9562 @table @asis
9563 @item @emph{Description}:
9564 @code{LOG_GAMMA(X)} computes the natural logarithm of the absolute value
9565 of the Gamma (@math{\Gamma}) function.
9566
9567 @item @emph{Standard}:
9568 Fortran 2008 and later
9569
9570 @item @emph{Class}:
9571 Elemental function
9572
9573 @item @emph{Syntax}:
9574 @code{X = LOG_GAMMA(X)}
9575
9576 @item @emph{Arguments}:
9577 @multitable @columnfractions .15 .70
9578 @item @var{X} @tab Shall be of type @code{REAL} and neither zero
9579 nor a negative integer.
9580 @end multitable
9581
9582 @item @emph{Return value}:
9583 The return value is of type @code{REAL} of the same kind as @var{X}.
9584
9585 @item @emph{Example}:
9586 @smallexample
9587 program test_log_gamma
9588 real :: x = 1.0
9589 x = lgamma(x) ! returns 0.0
9590 end program test_log_gamma
9591 @end smallexample
9592
9593 @item @emph{Specific names}:
9594 @multitable @columnfractions .20 .20 .20 .25
9595 @item Name @tab Argument @tab Return type @tab Standard
9596 @item @code{LGAMMA(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU Extension
9597 @item @code{ALGAMA(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU Extension
9598 @item @code{DLGAMA(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU Extension
9599 @end multitable
9600
9601 @item @emph{See also}:
9602 Gamma function: @ref{GAMMA}
9603
9604 @end table
9605
9606
9607
9608 @node LOGICAL
9609 @section @code{LOGICAL} --- Convert to logical type
9610 @fnindex LOGICAL
9611 @cindex conversion, to logical
9612
9613 @table @asis
9614 @item @emph{Description}:
9615 Converts one kind of @code{LOGICAL} variable to another.
9616
9617 @item @emph{Standard}:
9618 Fortran 95 and later
9619
9620 @item @emph{Class}:
9621 Elemental function
9622
9623 @item @emph{Syntax}:
9624 @code{RESULT = LOGICAL(L [, KIND])}
9625
9626 @item @emph{Arguments}:
9627 @multitable @columnfractions .15 .70
9628 @item @var{L} @tab The type shall be @code{LOGICAL}.
9629 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
9630 expression indicating the kind parameter of the result.
9631 @end multitable
9632
9633 @item @emph{Return value}:
9634 The return value is a @code{LOGICAL} value equal to @var{L}, with a
9635 kind corresponding to @var{KIND}, or of the default logical kind if
9636 @var{KIND} is not given.
9637
9638 @item @emph{See also}:
9639 @ref{INT}, @ref{REAL}, @ref{CMPLX}
9640 @end table
9641
9642
9643
9644 @node LONG
9645 @section @code{LONG} --- Convert to integer type
9646 @fnindex LONG
9647 @cindex conversion, to integer
9648
9649 @table @asis
9650 @item @emph{Description}:
9651 Convert to a @code{KIND=4} integer type, which is the same size as a C
9652 @code{long} integer. This is equivalent to the standard @code{INT}
9653 intrinsic with an optional argument of @code{KIND=4}, and is only
9654 included for backwards compatibility.
9655
9656 @item @emph{Standard}:
9657 GNU extension
9658
9659 @item @emph{Class}:
9660 Elemental function
9661
9662 @item @emph{Syntax}:
9663 @code{RESULT = LONG(A)}
9664
9665 @item @emph{Arguments}:
9666 @multitable @columnfractions .15 .70
9667 @item @var{A} @tab Shall be of type @code{INTEGER},
9668 @code{REAL}, or @code{COMPLEX}.
9669 @end multitable
9670
9671 @item @emph{Return value}:
9672 The return value is a @code{INTEGER(4)} variable.
9673
9674 @item @emph{See also}:
9675 @ref{INT}, @ref{INT2}, @ref{INT8}
9676 @end table
9677
9678
9679
9680 @node LSHIFT
9681 @section @code{LSHIFT} --- Left shift bits
9682 @fnindex LSHIFT
9683 @cindex bits, shift left
9684
9685 @table @asis
9686 @item @emph{Description}:
9687 @code{LSHIFT} returns a value corresponding to @var{I} with all of the
9688 bits shifted left by @var{SHIFT} places. If the absolute value of
9689 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
9690 Bits shifted out from the left end are lost; zeros are shifted in from
9691 the opposite end.
9692
9693 This function has been superseded by the @code{ISHFT} intrinsic, which
9694 is standard in Fortran 95 and later, and the @code{SHIFTL} intrinsic,
9695 which is standard in Fortran 2008 and later.
9696
9697 @item @emph{Standard}:
9698 GNU extension
9699
9700 @item @emph{Class}:
9701 Elemental function
9702
9703 @item @emph{Syntax}:
9704 @code{RESULT = LSHIFT(I, SHIFT)}
9705
9706 @item @emph{Arguments}:
9707 @multitable @columnfractions .15 .70
9708 @item @var{I} @tab The type shall be @code{INTEGER}.
9709 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
9710 @end multitable
9711
9712 @item @emph{Return value}:
9713 The return value is of type @code{INTEGER} and of the same kind as
9714 @var{I}.
9715
9716 @item @emph{See also}:
9717 @ref{ISHFT}, @ref{ISHFTC}, @ref{RSHIFT}, @ref{SHIFTA}, @ref{SHIFTL},
9718 @ref{SHIFTR}
9719
9720 @end table
9721
9722
9723
9724 @node LSTAT
9725 @section @code{LSTAT} --- Get file status
9726 @fnindex LSTAT
9727 @cindex file system, file status
9728
9729 @table @asis
9730 @item @emph{Description}:
9731 @code{LSTAT} is identical to @ref{STAT}, except that if path is a
9732 symbolic link, then the link itself is statted, not the file that it
9733 refers to.
9734
9735 The elements in @code{VALUES} are the same as described by @ref{STAT}.
9736
9737 This intrinsic is provided in both subroutine and function forms;
9738 however, only one form can be used in any given program unit.
9739
9740 @item @emph{Standard}:
9741 GNU extension
9742
9743 @item @emph{Class}:
9744 Subroutine, function
9745
9746 @item @emph{Syntax}:
9747 @multitable @columnfractions .80
9748 @item @code{CALL LSTAT(NAME, VALUES [, STATUS])}
9749 @item @code{STATUS = LSTAT(NAME, VALUES)}
9750 @end multitable
9751
9752 @item @emph{Arguments}:
9753 @multitable @columnfractions .15 .70
9754 @item @var{NAME} @tab The type shall be @code{CHARACTER} of the default
9755 kind, a valid path within the file system.
9756 @item @var{VALUES} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
9757 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}.
9758 Returns 0 on success and a system specific error code otherwise.
9759 @end multitable
9760
9761 @item @emph{Example}:
9762 See @ref{STAT} for an example.
9763
9764 @item @emph{See also}:
9765 To stat an open file: @ref{FSTAT}, to stat a file: @ref{STAT}
9766 @end table
9767
9768
9769
9770 @node LTIME
9771 @section @code{LTIME} --- Convert time to local time info
9772 @fnindex LTIME
9773 @cindex time, conversion to local time info
9774
9775 @table @asis
9776 @item @emph{Description}:
9777 Given a system time value @var{TIME} (as provided by the @ref{TIME}
9778 intrinsic), fills @var{VALUES} with values extracted from it appropriate
9779 to the local time zone using @code{localtime(3)}.
9780
9781 This intrinsic routine is provided for backwards compatibility with
9782 GNU Fortran 77. In new code, programmers should consider the use of
9783 the @ref{DATE_AND_TIME} intrinsic defined by the Fortran 95
9784 standard.
9785
9786 @item @emph{Standard}:
9787 GNU extension
9788
9789 @item @emph{Class}:
9790 Subroutine
9791
9792 @item @emph{Syntax}:
9793 @code{CALL LTIME(TIME, VALUES)}
9794
9795 @item @emph{Arguments}:
9796 @multitable @columnfractions .15 .70
9797 @item @var{TIME} @tab An @code{INTEGER} scalar expression
9798 corresponding to a system time, with @code{INTENT(IN)}.
9799 @item @var{VALUES} @tab A default @code{INTEGER} array with 9 elements,
9800 with @code{INTENT(OUT)}.
9801 @end multitable
9802
9803 @item @emph{Return value}:
9804 The elements of @var{VALUES} are assigned as follows:
9805 @enumerate
9806 @item Seconds after the minute, range 0--59 or 0--61 to allow for leap
9807 seconds
9808 @item Minutes after the hour, range 0--59
9809 @item Hours past midnight, range 0--23
9810 @item Day of month, range 1--31
9811 @item Number of months since January, range 0--11
9812 @item Years since 1900
9813 @item Number of days since Sunday, range 0--6
9814 @item Days since January 1, range 0--365
9815 @item Daylight savings indicator: positive if daylight savings is in
9816 effect, zero if not, and negative if the information is not available.
9817 @end enumerate
9818
9819 @item @emph{See also}:
9820 @ref{DATE_AND_TIME}, @ref{CTIME}, @ref{GMTIME}, @ref{TIME}, @ref{TIME8}
9821
9822 @end table
9823
9824
9825
9826 @node MALLOC
9827 @section @code{MALLOC} --- Allocate dynamic memory
9828 @fnindex MALLOC
9829 @cindex pointer, cray
9830
9831 @table @asis
9832 @item @emph{Description}:
9833 @code{MALLOC(SIZE)} allocates @var{SIZE} bytes of dynamic memory and
9834 returns the address of the allocated memory. The @code{MALLOC} intrinsic
9835 is an extension intended to be used with Cray pointers, and is provided
9836 in GNU Fortran to allow the user to compile legacy code. For new code
9837 using Fortran 95 pointers, the memory allocation intrinsic is
9838 @code{ALLOCATE}.
9839
9840 @item @emph{Standard}:
9841 GNU extension
9842
9843 @item @emph{Class}:
9844 Function
9845
9846 @item @emph{Syntax}:
9847 @code{PTR = MALLOC(SIZE)}
9848
9849 @item @emph{Arguments}:
9850 @multitable @columnfractions .15 .70
9851 @item @var{SIZE} @tab The type shall be @code{INTEGER}.
9852 @end multitable
9853
9854 @item @emph{Return value}:
9855 The return value is of type @code{INTEGER(K)}, with @var{K} such that
9856 variables of type @code{INTEGER(K)} have the same size as
9857 C pointers (@code{sizeof(void *)}).
9858
9859 @item @emph{Example}:
9860 The following example demonstrates the use of @code{MALLOC} and
9861 @code{FREE} with Cray pointers.
9862
9863 @smallexample
9864 program test_malloc
9865 implicit none
9866 integer i
9867 real*8 x(*), z
9868 pointer(ptr_x,x)
9869
9870 ptr_x = malloc(20*8)
9871 do i = 1, 20
9872 x(i) = sqrt(1.0d0 / i)
9873 end do
9874 z = 0
9875 do i = 1, 20
9876 z = z + x(i)
9877 print *, z
9878 end do
9879 call free(ptr_x)
9880 end program test_malloc
9881 @end smallexample
9882
9883 @item @emph{See also}:
9884 @ref{FREE}
9885 @end table
9886
9887
9888
9889 @node MASKL
9890 @section @code{MASKL} --- Left justified mask
9891 @fnindex MASKL
9892 @cindex mask, left justified
9893
9894 @table @asis
9895 @item @emph{Description}:
9896 @code{MASKL(I[, KIND])} has its leftmost @var{I} bits set to 1, and the
9897 remaining bits set to 0.
9898
9899 @item @emph{Standard}:
9900 Fortran 2008 and later
9901
9902 @item @emph{Class}:
9903 Elemental function
9904
9905 @item @emph{Syntax}:
9906 @code{RESULT = MASKL(I[, KIND])}
9907
9908 @item @emph{Arguments}:
9909 @multitable @columnfractions .15 .70
9910 @item @var{I} @tab Shall be of type @code{INTEGER}.
9911 @item @var{KIND} @tab Shall be a scalar constant expression of type
9912 @code{INTEGER}.
9913 @end multitable
9914
9915 @item @emph{Return value}:
9916 The return value is of type @code{INTEGER}. If @var{KIND} is present, it
9917 specifies the kind value of the return type; otherwise, it is of the
9918 default integer kind.
9919
9920 @item @emph{See also}:
9921 @ref{MASKR}
9922 @end table
9923
9924
9925
9926 @node MASKR
9927 @section @code{MASKR} --- Right justified mask
9928 @fnindex MASKR
9929 @cindex mask, right justified
9930
9931 @table @asis
9932 @item @emph{Description}:
9933 @code{MASKL(I[, KIND])} has its rightmost @var{I} bits set to 1, and the
9934 remaining bits set to 0.
9935
9936 @item @emph{Standard}:
9937 Fortran 2008 and later
9938
9939 @item @emph{Class}:
9940 Elemental function
9941
9942 @item @emph{Syntax}:
9943 @code{RESULT = MASKR(I[, KIND])}
9944
9945 @item @emph{Arguments}:
9946 @multitable @columnfractions .15 .70
9947 @item @var{I} @tab Shall be of type @code{INTEGER}.
9948 @item @var{KIND} @tab Shall be a scalar constant expression of type
9949 @code{INTEGER}.
9950 @end multitable
9951
9952 @item @emph{Return value}:
9953 The return value is of type @code{INTEGER}. If @var{KIND} is present, it
9954 specifies the kind value of the return type; otherwise, it is of the
9955 default integer kind.
9956
9957 @item @emph{See also}:
9958 @ref{MASKL}
9959 @end table
9960
9961
9962
9963 @node MATMUL
9964 @section @code{MATMUL} --- matrix multiplication
9965 @fnindex MATMUL
9966 @cindex matrix multiplication
9967 @cindex product, matrix
9968
9969 @table @asis
9970 @item @emph{Description}:
9971 Performs a matrix multiplication on numeric or logical arguments.
9972
9973 @item @emph{Standard}:
9974 Fortran 95 and later
9975
9976 @item @emph{Class}:
9977 Transformational function
9978
9979 @item @emph{Syntax}:
9980 @code{RESULT = MATMUL(MATRIX_A, MATRIX_B)}
9981
9982 @item @emph{Arguments}:
9983 @multitable @columnfractions .15 .70
9984 @item @var{MATRIX_A} @tab An array of @code{INTEGER},
9985 @code{REAL}, @code{COMPLEX}, or @code{LOGICAL} type, with a rank of
9986 one or two.
9987 @item @var{MATRIX_B} @tab An array of @code{INTEGER},
9988 @code{REAL}, or @code{COMPLEX} type if @var{MATRIX_A} is of a numeric
9989 type; otherwise, an array of @code{LOGICAL} type. The rank shall be one
9990 or two, and the first (or only) dimension of @var{MATRIX_B} shall be
9991 equal to the last (or only) dimension of @var{MATRIX_A}.
9992 @var{MATRIX_A} and @var{MATRIX_B} shall not both be rank one arrays.
9993 @end multitable
9994
9995 @item @emph{Return value}:
9996 The matrix product of @var{MATRIX_A} and @var{MATRIX_B}. The type and
9997 kind of the result follow the usual type and kind promotion rules, as
9998 for the @code{*} or @code{.AND.} operators.
9999
10000 @item @emph{See also}:
10001 @end table
10002
10003
10004
10005 @node MAX
10006 @section @code{MAX} --- Maximum value of an argument list
10007 @fnindex MAX
10008 @fnindex MAX0
10009 @fnindex AMAX0
10010 @fnindex MAX1
10011 @fnindex AMAX1
10012 @fnindex DMAX1
10013 @cindex maximum value
10014
10015 @table @asis
10016 @item @emph{Description}:
10017 Returns the argument with the largest (most positive) value.
10018
10019 @item @emph{Standard}:
10020 Fortran 77 and later
10021
10022 @item @emph{Class}:
10023 Elemental function
10024
10025 @item @emph{Syntax}:
10026 @code{RESULT = MAX(A1, A2 [, A3 [, ...]])}
10027
10028 @item @emph{Arguments}:
10029 @multitable @columnfractions .15 .70
10030 @item @var{A1} @tab The type shall be @code{INTEGER} or
10031 @code{REAL}.
10032 @item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
10033 as @var{A1}. (As a GNU extension, arguments of different kinds are
10034 permitted.)
10035 @end multitable
10036
10037 @item @emph{Return value}:
10038 The return value corresponds to the maximum value among the arguments,
10039 and has the same type and kind as the first argument.
10040
10041 @item @emph{Specific names}:
10042 @multitable @columnfractions .20 .20 .20 .25
10043 @item Name @tab Argument @tab Return type @tab Standard
10044 @item @code{MAX0(A1)} @tab @code{INTEGER(4) A1} @tab @code{INTEGER(4)} @tab Fortran 77 and later
10045 @item @code{AMAX0(A1)} @tab @code{INTEGER(4) A1} @tab @code{REAL(MAX(X))} @tab Fortran 77 and later
10046 @item @code{MAX1(A1)} @tab @code{REAL A1} @tab @code{INT(MAX(X))} @tab Fortran 77 and later
10047 @item @code{AMAX1(A1)} @tab @code{REAL(4) A1} @tab @code{REAL(4)} @tab Fortran 77 and later
10048 @item @code{DMAX1(A1)} @tab @code{REAL(8) A1} @tab @code{REAL(8)} @tab Fortran 77 and later
10049 @end multitable
10050
10051 @item @emph{See also}:
10052 @ref{MAXLOC} @ref{MAXVAL}, @ref{MIN}
10053
10054 @end table
10055
10056
10057
10058 @node MAXEXPONENT
10059 @section @code{MAXEXPONENT} --- Maximum exponent of a real kind
10060 @fnindex MAXEXPONENT
10061 @cindex model representation, maximum exponent
10062
10063 @table @asis
10064 @item @emph{Description}:
10065 @code{MAXEXPONENT(X)} returns the maximum exponent in the model of the
10066 type of @code{X}.
10067
10068 @item @emph{Standard}:
10069 Fortran 95 and later
10070
10071 @item @emph{Class}:
10072 Inquiry function
10073
10074 @item @emph{Syntax}:
10075 @code{RESULT = MAXEXPONENT(X)}
10076
10077 @item @emph{Arguments}:
10078 @multitable @columnfractions .15 .70
10079 @item @var{X} @tab Shall be of type @code{REAL}.
10080 @end multitable
10081
10082 @item @emph{Return value}:
10083 The return value is of type @code{INTEGER} and of the default integer
10084 kind.
10085
10086 @item @emph{Example}:
10087 @smallexample
10088 program exponents
10089 real(kind=4) :: x
10090 real(kind=8) :: y
10091
10092 print *, minexponent(x), maxexponent(x)
10093 print *, minexponent(y), maxexponent(y)
10094 end program exponents
10095 @end smallexample
10096 @end table
10097
10098
10099
10100 @node MAXLOC
10101 @section @code{MAXLOC} --- Location of the maximum value within an array
10102 @fnindex MAXLOC
10103 @cindex array, location of maximum element
10104
10105 @table @asis
10106 @item @emph{Description}:
10107 Determines the location of the element in the array with the maximum
10108 value, or, if the @var{DIM} argument is supplied, determines the
10109 locations of the maximum element along each row of the array in the
10110 @var{DIM} direction. If @var{MASK} is present, only the elements for
10111 which @var{MASK} is @code{.TRUE.} are considered. If more than one
10112 element in the array has the maximum value, the location returned is
10113 that of the first such element in array element order if the
10114 @var{BACK} is not present, or if it false; otherwise, the location
10115 returned is that of the first such element. If the array has zero
10116 size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
10117 the result is an array of zeroes. Similarly, if @var{DIM} is supplied
10118 and all of the elements of @var{MASK} along a given row are zero, the
10119 result value for that row is zero.
10120
10121 @item @emph{Standard}:
10122 Fortran 95 and later; @var{ARRAY} of @code{CHARACTER} and the
10123 @var{KIND} argument are available in Fortran 2003 and later.
10124 The @var{BACK} argument is available in Fortran 2008 and later.
10125
10126 @item @emph{Class}:
10127 Transformational function
10128
10129 @item @emph{Syntax}:
10130 @multitable @columnfractions .80
10131 @item @code{RESULT = MAXLOC(ARRAY, DIM [, MASK] [,KIND] [,BACK])}
10132 @item @code{RESULT = MAXLOC(ARRAY [, MASK] [,KIND] [,BACK])}
10133 @end multitable
10134
10135 @item @emph{Arguments}:
10136 @multitable @columnfractions .15 .70
10137 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or
10138 @code{REAL}.
10139 @item @var{DIM} @tab (Optional) Shall be a scalar of type
10140 @code{INTEGER}, with a value between one and the rank of @var{ARRAY},
10141 inclusive. It may not be an optional dummy argument.
10142 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL},
10143 and conformable with @var{ARRAY}.
10144 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
10145 expression indicating the kind parameter of the result.
10146 @item @var{BACK} @tab (Optional) A scalar of type @code{LOGICAL}.
10147 @end multitable
10148
10149 @item @emph{Return value}:
10150 If @var{DIM} is absent, the result is a rank-one array with a length
10151 equal to the rank of @var{ARRAY}. If @var{DIM} is present, the result
10152 is an array with a rank one less than the rank of @var{ARRAY}, and a
10153 size corresponding to the size of @var{ARRAY} with the @var{DIM}
10154 dimension removed. If @var{DIM} is present and @var{ARRAY} has a rank
10155 of one, the result is a scalar. If the optional argument @var{KIND}
10156 is present, the result is an integer of kind @var{KIND}, otherwise it
10157 is of default kind.
10158
10159 @item @emph{See also}:
10160 @ref{FINDLOC}, @ref{MAX}, @ref{MAXVAL}
10161
10162 @end table
10163
10164
10165
10166 @node MAXVAL
10167 @section @code{MAXVAL} --- Maximum value of an array
10168 @fnindex MAXVAL
10169 @cindex array, maximum value
10170 @cindex maximum value
10171
10172 @table @asis
10173 @item @emph{Description}:
10174 Determines the maximum value of the elements in an array value, or, if
10175 the @var{DIM} argument is supplied, determines the maximum value along
10176 each row of the array in the @var{DIM} direction. If @var{MASK} is
10177 present, only the elements for which @var{MASK} is @code{.TRUE.} are
10178 considered. If the array has zero size, or all of the elements of
10179 @var{MASK} are @code{.FALSE.}, then the result is @code{-HUGE(ARRAY)}
10180 if @var{ARRAY} is numeric, or a string of nulls if @var{ARRAY} is of character
10181 type.
10182
10183 @item @emph{Standard}:
10184 Fortran 95 and later
10185
10186 @item @emph{Class}:
10187 Transformational function
10188
10189 @item @emph{Syntax}:
10190 @multitable @columnfractions .80
10191 @item @code{RESULT = MAXVAL(ARRAY, DIM [, MASK])}
10192 @item @code{RESULT = MAXVAL(ARRAY [, MASK])}
10193 @end multitable
10194
10195 @item @emph{Arguments}:
10196 @multitable @columnfractions .15 .70
10197 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or
10198 @code{REAL}.
10199 @item @var{DIM} @tab (Optional) Shall be a scalar of type
10200 @code{INTEGER}, with a value between one and the rank of @var{ARRAY},
10201 inclusive. It may not be an optional dummy argument.
10202 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL},
10203 and conformable with @var{ARRAY}.
10204 @end multitable
10205
10206 @item @emph{Return value}:
10207 If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
10208 is a scalar. If @var{DIM} is present, the result is an array with a
10209 rank one less than the rank of @var{ARRAY}, and a size corresponding to
10210 the size of @var{ARRAY} with the @var{DIM} dimension removed. In all
10211 cases, the result is of the same type and kind as @var{ARRAY}.
10212
10213 @item @emph{See also}:
10214 @ref{MAX}, @ref{MAXLOC}
10215 @end table
10216
10217
10218
10219 @node MCLOCK
10220 @section @code{MCLOCK} --- Time function
10221 @fnindex MCLOCK
10222 @cindex time, clock ticks
10223 @cindex clock ticks
10224
10225 @table @asis
10226 @item @emph{Description}:
10227 Returns the number of clock ticks since the start of the process, based
10228 on the function @code{clock(3)} in the C standard library.
10229
10230 This intrinsic is not fully portable, such as to systems with 32-bit
10231 @code{INTEGER} types but supporting times wider than 32 bits. Therefore,
10232 the values returned by this intrinsic might be, or become, negative, or
10233 numerically less than previous values, during a single run of the
10234 compiled program.
10235
10236 @item @emph{Standard}:
10237 GNU extension
10238
10239 @item @emph{Class}:
10240 Function
10241
10242 @item @emph{Syntax}:
10243 @code{RESULT = MCLOCK()}
10244
10245 @item @emph{Return value}:
10246 The return value is a scalar of type @code{INTEGER(4)}, equal to the
10247 number of clock ticks since the start of the process, or @code{-1} if
10248 the system does not support @code{clock(3)}.
10249
10250 @item @emph{See also}:
10251 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME}
10252
10253 @end table
10254
10255
10256
10257 @node MCLOCK8
10258 @section @code{MCLOCK8} --- Time function (64-bit)
10259 @fnindex MCLOCK8
10260 @cindex time, clock ticks
10261 @cindex clock ticks
10262
10263 @table @asis
10264 @item @emph{Description}:
10265 Returns the number of clock ticks since the start of the process, based
10266 on the function @code{clock(3)} in the C standard library.
10267
10268 @emph{Warning:} this intrinsic does not increase the range of the timing
10269 values over that returned by @code{clock(3)}. On a system with a 32-bit
10270 @code{clock(3)}, @code{MCLOCK8} will return a 32-bit value, even though
10271 it is converted to a 64-bit @code{INTEGER(8)} value. That means
10272 overflows of the 32-bit value can still occur. Therefore, the values
10273 returned by this intrinsic might be or become negative or numerically
10274 less than previous values during a single run of the compiled program.
10275
10276 @item @emph{Standard}:
10277 GNU extension
10278
10279 @item @emph{Class}:
10280 Function
10281
10282 @item @emph{Syntax}:
10283 @code{RESULT = MCLOCK8()}
10284
10285 @item @emph{Return value}:
10286 The return value is a scalar of type @code{INTEGER(8)}, equal to the
10287 number of clock ticks since the start of the process, or @code{-1} if
10288 the system does not support @code{clock(3)}.
10289
10290 @item @emph{See also}:
10291 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME8}
10292
10293 @end table
10294
10295
10296
10297 @node MERGE
10298 @section @code{MERGE} --- Merge variables
10299 @fnindex MERGE
10300 @cindex array, merge arrays
10301 @cindex array, combine arrays
10302
10303 @table @asis
10304 @item @emph{Description}:
10305 Select values from two arrays according to a logical mask. The result
10306 is equal to @var{TSOURCE} if @var{MASK} is @code{.TRUE.}, or equal to
10307 @var{FSOURCE} if it is @code{.FALSE.}.
10308
10309 @item @emph{Standard}:
10310 Fortran 95 and later
10311
10312 @item @emph{Class}:
10313 Elemental function
10314
10315 @item @emph{Syntax}:
10316 @code{RESULT = MERGE(TSOURCE, FSOURCE, MASK)}
10317
10318 @item @emph{Arguments}:
10319 @multitable @columnfractions .15 .70
10320 @item @var{TSOURCE} @tab May be of any type.
10321 @item @var{FSOURCE} @tab Shall be of the same type and type parameters
10322 as @var{TSOURCE}.
10323 @item @var{MASK} @tab Shall be of type @code{LOGICAL}.
10324 @end multitable
10325
10326 @item @emph{Return value}:
10327 The result is of the same type and type parameters as @var{TSOURCE}.
10328
10329 @end table
10330
10331
10332
10333 @node MERGE_BITS
10334 @section @code{MERGE_BITS} --- Merge of bits under mask
10335 @fnindex MERGE_BITS
10336 @cindex bits, merge
10337
10338 @table @asis
10339 @item @emph{Description}:
10340 @code{MERGE_BITS(I, J, MASK)} merges the bits of @var{I} and @var{J}
10341 as determined by the mask. The i-th bit of the result is equal to the
10342 i-th bit of @var{I} if the i-th bit of @var{MASK} is 1; it is equal to
10343 the i-th bit of @var{J} otherwise.
10344
10345 @item @emph{Standard}:
10346 Fortran 2008 and later
10347
10348 @item @emph{Class}:
10349 Elemental function
10350
10351 @item @emph{Syntax}:
10352 @code{RESULT = MERGE_BITS(I, J, MASK)}
10353
10354 @item @emph{Arguments}:
10355 @multitable @columnfractions .15 .70
10356 @item @var{I} @tab Shall be of type @code{INTEGER} or a boz-literal-constant.
10357 @item @var{J} @tab Shall be of type @code{INTEGER} with the same
10358 kind type parameter as @var{I} or a boz-literal-constant.
10359 @var{I} and @var{J} shall not both be boz-literal-constants.
10360 @item @var{MASK} @tab Shall be of type @code{INTEGER} or a boz-literal-constant
10361 and of the same kind as @var{I}.
10362 @end multitable
10363
10364 @item @emph{Return value}:
10365 The result is of the same type and kind as @var{I}.
10366
10367 @end table
10368
10369
10370
10371 @node MIN
10372 @section @code{MIN} --- Minimum value of an argument list
10373 @fnindex MIN
10374 @fnindex MIN0
10375 @fnindex AMIN0
10376 @fnindex MIN1
10377 @fnindex AMIN1
10378 @fnindex DMIN1
10379 @cindex minimum value
10380
10381 @table @asis
10382 @item @emph{Description}:
10383 Returns the argument with the smallest (most negative) value.
10384
10385 @item @emph{Standard}:
10386 Fortran 77 and later
10387
10388 @item @emph{Class}:
10389 Elemental function
10390
10391 @item @emph{Syntax}:
10392 @code{RESULT = MIN(A1, A2 [, A3, ...])}
10393
10394 @item @emph{Arguments}:
10395 @multitable @columnfractions .15 .70
10396 @item @var{A1} @tab The type shall be @code{INTEGER} or
10397 @code{REAL}.
10398 @item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
10399 as @var{A1}. (As a GNU extension, arguments of different kinds are
10400 permitted.)
10401 @end multitable
10402
10403 @item @emph{Return value}:
10404 The return value corresponds to the maximum value among the arguments,
10405 and has the same type and kind as the first argument.
10406
10407 @item @emph{Specific names}:
10408 @multitable @columnfractions .20 .20 .20 .25
10409 @item Name @tab Argument @tab Return type @tab Standard
10410 @item @code{MIN0(A1)} @tab @code{INTEGER(4) A1} @tab @code{INTEGER(4)} @tab Fortran 77 and later
10411 @item @code{AMIN0(A1)} @tab @code{INTEGER(4) A1} @tab @code{REAL(4)} @tab Fortran 77 and later
10412 @item @code{MIN1(A1)} @tab @code{REAL A1} @tab @code{INTEGER(4)} @tab Fortran 77 and later
10413 @item @code{AMIN1(A1)} @tab @code{REAL(4) A1} @tab @code{REAL(4)} @tab Fortran 77 and later
10414 @item @code{DMIN1(A1)} @tab @code{REAL(8) A1} @tab @code{REAL(8)} @tab Fortran 77 and later
10415 @end multitable
10416
10417 @item @emph{See also}:
10418 @ref{MAX}, @ref{MINLOC}, @ref{MINVAL}
10419 @end table
10420
10421
10422
10423 @node MINEXPONENT
10424 @section @code{MINEXPONENT} --- Minimum exponent of a real kind
10425 @fnindex MINEXPONENT
10426 @cindex model representation, minimum exponent
10427
10428 @table @asis
10429 @item @emph{Description}:
10430 @code{MINEXPONENT(X)} returns the minimum exponent in the model of the
10431 type of @code{X}.
10432
10433 @item @emph{Standard}:
10434 Fortran 95 and later
10435
10436 @item @emph{Class}:
10437 Inquiry function
10438
10439 @item @emph{Syntax}:
10440 @code{RESULT = MINEXPONENT(X)}
10441
10442 @item @emph{Arguments}:
10443 @multitable @columnfractions .15 .70
10444 @item @var{X} @tab Shall be of type @code{REAL}.
10445 @end multitable
10446
10447 @item @emph{Return value}:
10448 The return value is of type @code{INTEGER} and of the default integer
10449 kind.
10450
10451 @item @emph{Example}:
10452 See @code{MAXEXPONENT} for an example.
10453 @end table
10454
10455
10456
10457 @node MINLOC
10458 @section @code{MINLOC} --- Location of the minimum value within an array
10459 @fnindex MINLOC
10460 @cindex array, location of minimum element
10461
10462 @table @asis
10463 @item @emph{Description}:
10464 Determines the location of the element in the array with the minimum
10465 value, or, if the @var{DIM} argument is supplied, determines the
10466 locations of the minimum element along each row of the array in the
10467 @var{DIM} direction. If @var{MASK} is present, only the elements for
10468 which @var{MASK} is @code{.TRUE.} are considered. If more than one
10469 element in the array has the minimum value, the location returned is
10470 that of the first such element in array element order if the
10471 @var{BACK} is not present, or if it false; otherwise, the location
10472 returned is that of the first such element. If the array has
10473 zero size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
10474 the result is an array of zeroes. Similarly, if @var{DIM} is supplied
10475 and all of the elements of @var{MASK} along a given row are zero, the
10476 result value for that row is zero.
10477
10478 @item @emph{Standard}:
10479 Fortran 95 and later; @var{ARRAY} of @code{CHARACTER} and the
10480 @var{KIND} argument are available in Fortran 2003 and later.
10481 The @var{BACK} argument is available in Fortran 2008 and later.
10482
10483 @item @emph{Class}:
10484 Transformational function
10485
10486 @item @emph{Syntax}:
10487 @multitable @columnfractions .80
10488 @item @code{RESULT = MINLOC(ARRAY, DIM [, MASK] [,KIND] [,BACK])}
10489 @item @code{RESULT = MINLOC(ARRAY [, MASK], [,KIND] [,BACK])}
10490 @end multitable
10491
10492 @item @emph{Arguments}:
10493 @multitable @columnfractions .15 .70
10494 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER},
10495 @code{REAL} or @code{CHARACTER}.
10496 @item @var{DIM} @tab (Optional) Shall be a scalar of type
10497 @code{INTEGER}, with a value between one and the rank of @var{ARRAY},
10498 inclusive. It may not be an optional dummy argument.
10499 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL},
10500 and conformable with @var{ARRAY}.
10501 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
10502 expression indicating the kind parameter of the result.
10503 @item @var{BACK} @tab (Optional) A scalar of type @code{LOGICAL}.
10504 @end multitable
10505
10506 @item @emph{Return value}:
10507 If @var{DIM} is absent, the result is a rank-one array with a length
10508 equal to the rank of @var{ARRAY}. If @var{DIM} is present, the result
10509 is an array with a rank one less than the rank of @var{ARRAY}, and a
10510 size corresponding to the size of @var{ARRAY} with the @var{DIM}
10511 dimension removed. If @var{DIM} is present and @var{ARRAY} has a rank
10512 of one, the result is a scalar. If the optional argument @var{KIND}
10513 is present, the result is an integer of kind @var{KIND}, otherwise it
10514 is of default kind.
10515
10516 @item @emph{See also}:
10517 @ref{FINDLOC}, @ref{MIN}, @ref{MINVAL}
10518
10519 @end table
10520
10521
10522
10523 @node MINVAL
10524 @section @code{MINVAL} --- Minimum value of an array
10525 @fnindex MINVAL
10526 @cindex array, minimum value
10527 @cindex minimum value
10528
10529 @table @asis
10530 @item @emph{Description}:
10531 Determines the minimum value of the elements in an array value, or, if
10532 the @var{DIM} argument is supplied, determines the minimum value along
10533 each row of the array in the @var{DIM} direction. If @var{MASK} is
10534 present, only the elements for which @var{MASK} is @code{.TRUE.} are
10535 considered. If the array has zero size, or all of the elements of
10536 @var{MASK} are @code{.FALSE.}, then the result is @code{HUGE(ARRAY)} if
10537 @var{ARRAY} is numeric, or a string of @code{CHAR(255)} characters if
10538 @var{ARRAY} is of character type.
10539
10540 @item @emph{Standard}:
10541 Fortran 95 and later
10542
10543 @item @emph{Class}:
10544 Transformational function
10545
10546 @item @emph{Syntax}:
10547 @multitable @columnfractions .80
10548 @item @code{RESULT = MINVAL(ARRAY, DIM [, MASK])}
10549 @item @code{RESULT = MINVAL(ARRAY [, MASK])}
10550 @end multitable
10551
10552 @item @emph{Arguments}:
10553 @multitable @columnfractions .15 .70
10554 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or
10555 @code{REAL}.
10556 @item @var{DIM} @tab (Optional) Shall be a scalar of type
10557 @code{INTEGER}, with a value between one and the rank of @var{ARRAY},
10558 inclusive. It may not be an optional dummy argument.
10559 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL},
10560 and conformable with @var{ARRAY}.
10561 @end multitable
10562
10563 @item @emph{Return value}:
10564 If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
10565 is a scalar. If @var{DIM} is present, the result is an array with a
10566 rank one less than the rank of @var{ARRAY}, and a size corresponding to
10567 the size of @var{ARRAY} with the @var{DIM} dimension removed. In all
10568 cases, the result is of the same type and kind as @var{ARRAY}.
10569
10570 @item @emph{See also}:
10571 @ref{MIN}, @ref{MINLOC}
10572
10573 @end table
10574
10575
10576
10577 @node MOD
10578 @section @code{MOD} --- Remainder function
10579 @fnindex MOD
10580 @fnindex AMOD
10581 @fnindex DMOD
10582 @fnindex BMOD
10583 @fnindex IMOD
10584 @fnindex JMOD
10585 @fnindex KMOD
10586 @cindex remainder
10587 @cindex division, remainder
10588
10589 @table @asis
10590 @item @emph{Description}:
10591 @code{MOD(A,P)} computes the remainder of the division of A by P@.
10592
10593 @item @emph{Standard}:
10594 Fortran 77 and later, has overloads that are GNU extensions
10595
10596 @item @emph{Class}:
10597 Elemental function
10598
10599 @item @emph{Syntax}:
10600 @code{RESULT = MOD(A, P)}
10601
10602 @item @emph{Arguments}:
10603 @multitable @columnfractions .15 .70
10604 @item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL}.
10605 @item @var{P} @tab Shall be a scalar of the same type and kind as @var{A}
10606 and not equal to zero.
10607 @end multitable
10608
10609 @item @emph{Return value}:
10610 The return value is the result of @code{A - (INT(A/P) * P)}. The type
10611 and kind of the return value is the same as that of the arguments. The
10612 returned value has the same sign as A and a magnitude less than the
10613 magnitude of P.
10614
10615 @item @emph{Example}:
10616 @smallexample
10617 program test_mod
10618 print *, mod(17,3)
10619 print *, mod(17.5,5.5)
10620 print *, mod(17.5d0,5.5)
10621 print *, mod(17.5,5.5d0)
10622
10623 print *, mod(-17,3)
10624 print *, mod(-17.5,5.5)
10625 print *, mod(-17.5d0,5.5)
10626 print *, mod(-17.5,5.5d0)
10627
10628 print *, mod(17,-3)
10629 print *, mod(17.5,-5.5)
10630 print *, mod(17.5d0,-5.5)
10631 print *, mod(17.5,-5.5d0)
10632 end program test_mod
10633 @end smallexample
10634
10635 @item @emph{Specific names}:
10636 @multitable @columnfractions .20 .20 .20 .25
10637 @item Name @tab Arguments @tab Return type @tab Standard
10638 @item @code{MOD(A,P)} @tab @code{INTEGER A,P} @tab @code{INTEGER} @tab Fortran 95 and later
10639 @item @code{AMOD(A,P)} @tab @code{REAL(4) A,P} @tab @code{REAL(4)} @tab Fortran 95 and later
10640 @item @code{DMOD(A,P)} @tab @code{REAL(8) A,P} @tab @code{REAL(8)} @tab Fortran 95 and later
10641 @item @code{BMOD(A,P)} @tab @code{INTEGER(1) A,P} @tab @code{INTEGER(1)} @tab GNU extension
10642 @item @code{IMOD(A,P)} @tab @code{INTEGER(2) A,P} @tab @code{INTEGER(2)} @tab GNU extension
10643 @item @code{JMOD(A,P)} @tab @code{INTEGER(4) A,P} @tab @code{INTEGER(4)} @tab GNU extension
10644 @item @code{KMOD(A,P)} @tab @code{INTEGER(8) A,P} @tab @code{INTEGER(8)} @tab GNU extension
10645 @end multitable
10646
10647 @item @emph{See also}:
10648 @ref{MODULO}
10649
10650 @end table
10651
10652
10653
10654 @node MODULO
10655 @section @code{MODULO} --- Modulo function
10656 @fnindex MODULO
10657 @cindex modulo
10658 @cindex division, modulo
10659
10660 @table @asis
10661 @item @emph{Description}:
10662 @code{MODULO(A,P)} computes the @var{A} modulo @var{P}.
10663
10664 @item @emph{Standard}:
10665 Fortran 95 and later
10666
10667 @item @emph{Class}:
10668 Elemental function
10669
10670 @item @emph{Syntax}:
10671 @code{RESULT = MODULO(A, P)}
10672
10673 @item @emph{Arguments}:
10674 @multitable @columnfractions .15 .70
10675 @item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL}.
10676 @item @var{P} @tab Shall be a scalar of the same type and kind as @var{A}.
10677 It shall not be zero.
10678 @end multitable
10679
10680 @item @emph{Return value}:
10681 The type and kind of the result are those of the arguments.
10682 @table @asis
10683 @item If @var{A} and @var{P} are of type @code{INTEGER}:
10684 @code{MODULO(A,P)} has the value @var{R} such that @code{A=Q*P+R}, where
10685 @var{Q} is an integer and @var{R} is between 0 (inclusive) and @var{P}
10686 (exclusive).
10687 @item If @var{A} and @var{P} are of type @code{REAL}:
10688 @code{MODULO(A,P)} has the value of @code{A - FLOOR (A / P) * P}.
10689 @end table
10690 The returned value has the same sign as P and a magnitude less than
10691 the magnitude of P.
10692
10693 @item @emph{Example}:
10694 @smallexample
10695 program test_modulo
10696 print *, modulo(17,3)
10697 print *, modulo(17.5,5.5)
10698
10699 print *, modulo(-17,3)
10700 print *, modulo(-17.5,5.5)
10701
10702 print *, modulo(17,-3)
10703 print *, modulo(17.5,-5.5)
10704 end program
10705 @end smallexample
10706
10707 @item @emph{See also}:
10708 @ref{MOD}
10709
10710 @end table
10711
10712
10713
10714 @node MOVE_ALLOC
10715 @section @code{MOVE_ALLOC} --- Move allocation from one object to another
10716 @fnindex MOVE_ALLOC
10717 @cindex moving allocation
10718 @cindex allocation, moving
10719
10720 @table @asis
10721 @item @emph{Description}:
10722 @code{MOVE_ALLOC(FROM, TO)} moves the allocation from @var{FROM} to
10723 @var{TO}. @var{FROM} will become deallocated in the process.
10724
10725 @item @emph{Standard}:
10726 Fortran 2003 and later
10727
10728 @item @emph{Class}:
10729 Pure subroutine
10730
10731 @item @emph{Syntax}:
10732 @code{CALL MOVE_ALLOC(FROM, TO)}
10733
10734 @item @emph{Arguments}:
10735 @multitable @columnfractions .15 .70
10736 @item @var{FROM} @tab @code{ALLOCATABLE}, @code{INTENT(INOUT)}, may be
10737 of any type and kind.
10738 @item @var{TO} @tab @code{ALLOCATABLE}, @code{INTENT(OUT)}, shall be
10739 of the same type, kind and rank as @var{FROM}.
10740 @end multitable
10741
10742 @item @emph{Return value}:
10743 None
10744
10745 @item @emph{Example}:
10746 @smallexample
10747 program test_move_alloc
10748 integer, allocatable :: a(:), b(:)
10749
10750 allocate(a(3))
10751 a = [ 1, 2, 3 ]
10752 call move_alloc(a, b)
10753 print *, allocated(a), allocated(b)
10754 print *, b
10755 end program test_move_alloc
10756 @end smallexample
10757 @end table
10758
10759
10760
10761 @node MVBITS
10762 @section @code{MVBITS} --- Move bits from one integer to another
10763 @fnindex MVBITS
10764 @fnindex BMVBITS
10765 @fnindex IMVBITS
10766 @fnindex JMVBITS
10767 @fnindex KMVBITS
10768 @cindex bits, move
10769
10770 @table @asis
10771 @item @emph{Description}:
10772 Moves @var{LEN} bits from positions @var{FROMPOS} through
10773 @code{FROMPOS+LEN-1} of @var{FROM} to positions @var{TOPOS} through
10774 @code{TOPOS+LEN-1} of @var{TO}. The portion of argument @var{TO} not
10775 affected by the movement of bits is unchanged. The values of
10776 @code{FROMPOS+LEN-1} and @code{TOPOS+LEN-1} must be less than
10777 @code{BIT_SIZE(FROM)}.
10778
10779 @item @emph{Standard}:
10780 Fortran 95 and later, has overloads that are GNU extensions
10781
10782 @item @emph{Class}:
10783 Elemental subroutine
10784
10785 @item @emph{Syntax}:
10786 @code{CALL MVBITS(FROM, FROMPOS, LEN, TO, TOPOS)}
10787
10788 @item @emph{Arguments}:
10789 @multitable @columnfractions .15 .70
10790 @item @var{FROM} @tab The type shall be @code{INTEGER}.
10791 @item @var{FROMPOS} @tab The type shall be @code{INTEGER}.
10792 @item @var{LEN} @tab The type shall be @code{INTEGER}.
10793 @item @var{TO} @tab The type shall be @code{INTEGER}, of the
10794 same kind as @var{FROM}.
10795 @item @var{TOPOS} @tab The type shall be @code{INTEGER}.
10796 @end multitable
10797
10798 @item @emph{Specific names}:
10799 @multitable @columnfractions .20 .20 .20 .25
10800 @item Name @tab Argument @tab Return type @tab Standard
10801 @item @code{MVBITS(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 95 and later
10802 @item @code{BMVBITS(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
10803 @item @code{IMVBITS(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
10804 @item @code{JMVBITS(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
10805 @item @code{KMVBITS(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
10806 @end multitable
10807
10808 @item @emph{See also}:
10809 @ref{IBCLR}, @ref{IBSET}, @ref{IBITS}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
10810 @end table
10811
10812
10813
10814 @node NEAREST
10815 @section @code{NEAREST} --- Nearest representable number
10816 @fnindex NEAREST
10817 @cindex real number, nearest different
10818 @cindex floating point, nearest different
10819
10820 @table @asis
10821 @item @emph{Description}:
10822 @code{NEAREST(X, S)} returns the processor-representable number nearest
10823 to @code{X} in the direction indicated by the sign of @code{S}.
10824
10825 @item @emph{Standard}:
10826 Fortran 95 and later
10827
10828 @item @emph{Class}:
10829 Elemental function
10830
10831 @item @emph{Syntax}:
10832 @code{RESULT = NEAREST(X, S)}
10833
10834 @item @emph{Arguments}:
10835 @multitable @columnfractions .15 .70
10836 @item @var{X} @tab Shall be of type @code{REAL}.
10837 @item @var{S} @tab Shall be of type @code{REAL} and
10838 not equal to zero.
10839 @end multitable
10840
10841 @item @emph{Return value}:
10842 The return value is of the same type as @code{X}. If @code{S} is
10843 positive, @code{NEAREST} returns the processor-representable number
10844 greater than @code{X} and nearest to it. If @code{S} is negative,
10845 @code{NEAREST} returns the processor-representable number smaller than
10846 @code{X} and nearest to it.
10847
10848 @item @emph{Example}:
10849 @smallexample
10850 program test_nearest
10851 real :: x, y
10852 x = nearest(42.0, 1.0)
10853 y = nearest(42.0, -1.0)
10854 write (*,"(3(G20.15))") x, y, x - y
10855 end program test_nearest
10856 @end smallexample
10857 @end table
10858
10859
10860
10861 @node NEW_LINE
10862 @section @code{NEW_LINE} --- New line character
10863 @fnindex NEW_LINE
10864 @cindex newline
10865 @cindex output, newline
10866
10867 @table @asis
10868 @item @emph{Description}:
10869 @code{NEW_LINE(C)} returns the new-line character.
10870
10871 @item @emph{Standard}:
10872 Fortran 2003 and later
10873
10874 @item @emph{Class}:
10875 Inquiry function
10876
10877 @item @emph{Syntax}:
10878 @code{RESULT = NEW_LINE(C)}
10879
10880 @item @emph{Arguments}:
10881 @multitable @columnfractions .15 .70
10882 @item @var{C} @tab The argument shall be a scalar or array of the
10883 type @code{CHARACTER}.
10884 @end multitable
10885
10886 @item @emph{Return value}:
10887 Returns a @var{CHARACTER} scalar of length one with the new-line character of
10888 the same kind as parameter @var{C}.
10889
10890 @item @emph{Example}:
10891 @smallexample
10892 program newline
10893 implicit none
10894 write(*,'(A)') 'This is record 1.'//NEW_LINE('A')//'This is record 2.'
10895 end program newline
10896 @end smallexample
10897 @end table
10898
10899
10900
10901 @node NINT
10902 @section @code{NINT} --- Nearest whole number
10903 @fnindex NINT
10904 @fnindex IDNINT
10905 @cindex rounding, nearest whole number
10906
10907 @table @asis
10908 @item @emph{Description}:
10909 @code{NINT(A)} rounds its argument to the nearest whole number.
10910
10911 @item @emph{Standard}:
10912 Fortran 77 and later, with @var{KIND} argument Fortran 90 and later
10913
10914 @item @emph{Class}:
10915 Elemental function
10916
10917 @item @emph{Syntax}:
10918 @code{RESULT = NINT(A [, KIND])}
10919
10920 @item @emph{Arguments}:
10921 @multitable @columnfractions .15 .70
10922 @item @var{A} @tab The type of the argument shall be @code{REAL}.
10923 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
10924 expression indicating the kind parameter of the result.
10925 @end multitable
10926
10927 @item @emph{Return value}:
10928 Returns @var{A} with the fractional portion of its magnitude eliminated by
10929 rounding to the nearest whole number and with its sign preserved,
10930 converted to an @code{INTEGER} of the default kind.
10931
10932 @item @emph{Example}:
10933 @smallexample
10934 program test_nint
10935 real(4) x4
10936 real(8) x8
10937 x4 = 1.234E0_4
10938 x8 = 4.321_8
10939 print *, nint(x4), idnint(x8)
10940 end program test_nint
10941 @end smallexample
10942
10943 @item @emph{Specific names}:
10944 @multitable @columnfractions .20 .20 .20 .25
10945 @item Name @tab Argument @tab Return Type @tab Standard
10946 @item @code{NINT(A)} @tab @code{REAL(4) A} @tab @code{INTEGER} @tab Fortran 95 and later
10947 @item @code{IDNINT(A)} @tab @code{REAL(8) A} @tab @code{INTEGER} @tab Fortran 95 and later
10948 @end multitable
10949
10950 @item @emph{See also}:
10951 @ref{CEILING}, @ref{FLOOR}
10952
10953 @end table
10954
10955
10956
10957 @node NORM2
10958 @section @code{NORM2} --- Euclidean vector norms
10959 @fnindex NORM2
10960 @cindex Euclidean vector norm
10961 @cindex L2 vector norm
10962 @cindex norm, Euclidean
10963
10964 @table @asis
10965 @item @emph{Description}:
10966 Calculates the Euclidean vector norm (@math{L_2} norm) of
10967 of @var{ARRAY} along dimension @var{DIM}.
10968
10969 @item @emph{Standard}:
10970 Fortran 2008 and later
10971
10972 @item @emph{Class}:
10973 Transformational function
10974
10975 @item @emph{Syntax}:
10976 @multitable @columnfractions .80
10977 @item @code{RESULT = NORM2(ARRAY[, DIM])}
10978 @end multitable
10979
10980 @item @emph{Arguments}:
10981 @multitable @columnfractions .15 .70
10982 @item @var{ARRAY} @tab Shall be an array of type @code{REAL}
10983 @item @var{DIM} @tab (Optional) shall be a scalar of type
10984 @code{INTEGER} with a value in the range from 1 to n, where n
10985 equals the rank of @var{ARRAY}.
10986 @end multitable
10987
10988 @item @emph{Return value}:
10989 The result is of the same type as @var{ARRAY}.
10990
10991 If @var{DIM} is absent, a scalar with the square root of the sum of all
10992 elements in @var{ARRAY} squared is returned. Otherwise, an array of
10993 rank @math{n-1}, where @math{n} equals the rank of @var{ARRAY}, and a
10994 shape similar to that of @var{ARRAY} with dimension @var{DIM} dropped
10995 is returned.
10996
10997 @item @emph{Example}:
10998 @smallexample
10999 PROGRAM test_sum
11000 REAL :: x(5) = [ real :: 1, 2, 3, 4, 5 ]
11001 print *, NORM2(x) ! = sqrt(55.) ~ 7.416
11002 END PROGRAM
11003 @end smallexample
11004 @end table
11005
11006
11007
11008 @node NOT
11009 @section @code{NOT} --- Logical negation
11010 @fnindex NOT
11011 @fnindex BNOT
11012 @fnindex INOT
11013 @fnindex JNOT
11014 @fnindex KNOT
11015 @cindex bits, negate
11016 @cindex bitwise logical not
11017 @cindex logical not, bitwise
11018
11019 @table @asis
11020 @item @emph{Description}:
11021 @code{NOT} returns the bitwise Boolean inverse of @var{I}.
11022
11023 @item @emph{Standard}:
11024 Fortran 95 and later, has overloads that are GNU extensions
11025
11026 @item @emph{Class}:
11027 Elemental function
11028
11029 @item @emph{Syntax}:
11030 @code{RESULT = NOT(I)}
11031
11032 @item @emph{Arguments}:
11033 @multitable @columnfractions .15 .70
11034 @item @var{I} @tab The type shall be @code{INTEGER}.
11035 @end multitable
11036
11037 @item @emph{Return value}:
11038 The return type is @code{INTEGER}, of the same kind as the
11039 argument.
11040
11041 @item @emph{Specific names}:
11042 @multitable @columnfractions .20 .20 .20 .25
11043 @item Name @tab Argument @tab Return type @tab Standard
11044 @item @code{NOT(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 95 and later
11045 @item @code{BNOT(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
11046 @item @code{INOT(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
11047 @item @code{JNOT(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
11048 @item @code{KNOT(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
11049 @end multitable
11050
11051 @item @emph{See also}:
11052 @ref{IAND}, @ref{IEOR}, @ref{IOR}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}
11053
11054 @end table
11055
11056
11057
11058 @node NULL
11059 @section @code{NULL} --- Function that returns an disassociated pointer
11060 @fnindex NULL
11061 @cindex pointer, status
11062 @cindex pointer, disassociated
11063
11064 @table @asis
11065 @item @emph{Description}:
11066 Returns a disassociated pointer.
11067
11068 If @var{MOLD} is present, a disassociated pointer of the same type is
11069 returned, otherwise the type is determined by context.
11070
11071 In Fortran 95, @var{MOLD} is optional. Please note that Fortran 2003
11072 includes cases where it is required.
11073
11074 @item @emph{Standard}:
11075 Fortran 95 and later
11076
11077 @item @emph{Class}:
11078 Transformational function
11079
11080 @item @emph{Syntax}:
11081 @code{PTR => NULL([MOLD])}
11082
11083 @item @emph{Arguments}:
11084 @multitable @columnfractions .15 .70
11085 @item @var{MOLD} @tab (Optional) shall be a pointer of any association
11086 status and of any type.
11087 @end multitable
11088
11089 @item @emph{Return value}:
11090 A disassociated pointer.
11091
11092 @item @emph{Example}:
11093 @smallexample
11094 REAL, POINTER, DIMENSION(:) :: VEC => NULL ()
11095 @end smallexample
11096
11097 @item @emph{See also}:
11098 @ref{ASSOCIATED}
11099 @end table
11100
11101
11102
11103 @node NUM_IMAGES
11104 @section @code{NUM_IMAGES} --- Function that returns the number of images
11105 @fnindex NUM_IMAGES
11106 @cindex coarray, @code{NUM_IMAGES}
11107 @cindex images, number of
11108
11109 @table @asis
11110 @item @emph{Description}:
11111 Returns the number of images.
11112
11113 @item @emph{Standard}:
11114 Fortran 2008 and later. With @var{DISTANCE} or @var{FAILED} argument,
11115 Technical Specification (TS) 18508 or later
11116
11117
11118 @item @emph{Class}:
11119 Transformational function
11120
11121 @item @emph{Syntax}:
11122 @code{RESULT = NUM_IMAGES(DISTANCE, FAILED)}
11123
11124 @item @emph{Arguments}:
11125 @multitable @columnfractions .15 .70
11126 @item @var{DISTANCE} @tab (optional, intent(in)) Nonnegative scalar integer
11127 @item @var{FAILED} @tab (optional, intent(in)) Scalar logical expression
11128 @end multitable
11129
11130 @item @emph{Return value}:
11131 Scalar default-kind integer. If @var{DISTANCE} is not present or has value 0,
11132 the number of images in the current team is returned. For values smaller or
11133 equal distance to the initial team, it returns the number of images index
11134 on the ancestor team which has a distance of @var{DISTANCE} from the invoking
11135 team. If @var{DISTANCE} is larger than the distance to the initial team, the
11136 number of images of the initial team is returned. If @var{FAILED} is not present
11137 the total number of images is returned; if it has the value @code{.TRUE.},
11138 the number of failed images is returned, otherwise, the number of images which
11139 do have not the failed status.
11140
11141 @item @emph{Example}:
11142 @smallexample
11143 INTEGER :: value[*]
11144 INTEGER :: i
11145 value = THIS_IMAGE()
11146 SYNC ALL
11147 IF (THIS_IMAGE() == 1) THEN
11148 DO i = 1, NUM_IMAGES()
11149 WRITE(*,'(2(a,i0))') 'value[', i, '] is ', value[i]
11150 END DO
11151 END IF
11152 @end smallexample
11153
11154 @item @emph{See also}:
11155 @ref{THIS_IMAGE}, @ref{IMAGE_INDEX}
11156 @end table
11157
11158
11159
11160 @node OR
11161 @section @code{OR} --- Bitwise logical OR
11162 @fnindex OR
11163 @cindex bitwise logical or
11164 @cindex logical or, bitwise
11165
11166 @table @asis
11167 @item @emph{Description}:
11168 Bitwise logical @code{OR}.
11169
11170 This intrinsic routine is provided for backwards compatibility with
11171 GNU Fortran 77. For integer arguments, programmers should consider
11172 the use of the @ref{IOR} intrinsic defined by the Fortran standard.
11173
11174 @item @emph{Standard}:
11175 GNU extension
11176
11177 @item @emph{Class}:
11178 Function
11179
11180 @item @emph{Syntax}:
11181 @code{RESULT = OR(I, J)}
11182
11183 @item @emph{Arguments}:
11184 @multitable @columnfractions .15 .70
11185 @item @var{I} @tab The type shall be either a scalar @code{INTEGER}
11186 type or a scalar @code{LOGICAL} type or a boz-literal-constant.
11187 @item @var{J} @tab The type shall be the same as the type of @var{I} or
11188 a boz-literal-constant. @var{I} and @var{J} shall not both be
11189 boz-literal-constants. If either @var{I} and @var{J} is a
11190 boz-literal-constant, then the other argument must be a scalar @code{INTEGER}.
11191 @end multitable
11192
11193 @item @emph{Return value}:
11194 The return type is either a scalar @code{INTEGER} or a scalar
11195 @code{LOGICAL}. If the kind type parameters differ, then the
11196 smaller kind type is implicitly converted to larger kind, and the
11197 return has the larger kind. A boz-literal-constant is
11198 converted to an @code{INTEGER} with the kind type parameter of
11199 the other argument as-if a call to @ref{INT} occurred.
11200
11201 @item @emph{Example}:
11202 @smallexample
11203 PROGRAM test_or
11204 LOGICAL :: T = .TRUE., F = .FALSE.
11205 INTEGER :: a, b
11206 DATA a / Z'F' /, b / Z'3' /
11207
11208 WRITE (*,*) OR(T, T), OR(T, F), OR(F, T), OR(F, F)
11209 WRITE (*,*) OR(a, b)
11210 END PROGRAM
11211 @end smallexample
11212
11213 @item @emph{See also}:
11214 Fortran 95 elemental function: @ref{IOR}
11215 @end table
11216
11217
11218
11219 @node PACK
11220 @section @code{PACK} --- Pack an array into an array of rank one
11221 @fnindex PACK
11222 @cindex array, packing
11223 @cindex array, reduce dimension
11224 @cindex array, gather elements
11225
11226 @table @asis
11227 @item @emph{Description}:
11228 Stores the elements of @var{ARRAY} in an array of rank one.
11229
11230 The beginning of the resulting array is made up of elements whose @var{MASK}
11231 equals @code{TRUE}. Afterwards, positions are filled with elements taken from
11232 @var{VECTOR}.
11233
11234 @item @emph{Standard}:
11235 Fortran 95 and later
11236
11237 @item @emph{Class}:
11238 Transformational function
11239
11240 @item @emph{Syntax}:
11241 @code{RESULT = PACK(ARRAY, MASK[,VECTOR])}
11242
11243 @item @emph{Arguments}:
11244 @multitable @columnfractions .15 .70
11245 @item @var{ARRAY} @tab Shall be an array of any type.
11246 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL} and
11247 of the same size as @var{ARRAY}. Alternatively, it may be a @code{LOGICAL}
11248 scalar.
11249 @item @var{VECTOR} @tab (Optional) shall be an array of the same type
11250 as @var{ARRAY} and of rank one. If present, the number of elements in
11251 @var{VECTOR} shall be equal to or greater than the number of true elements
11252 in @var{MASK}. If @var{MASK} is scalar, the number of elements in
11253 @var{VECTOR} shall be equal to or greater than the number of elements in
11254 @var{ARRAY}.
11255 @end multitable
11256
11257 @item @emph{Return value}:
11258 The result is an array of rank one and the same type as that of @var{ARRAY}.
11259 If @var{VECTOR} is present, the result size is that of @var{VECTOR}, the
11260 number of @code{TRUE} values in @var{MASK} otherwise.
11261
11262 @item @emph{Example}:
11263 Gathering nonzero elements from an array:
11264 @smallexample
11265 PROGRAM test_pack_1
11266 INTEGER :: m(6)
11267 m = (/ 1, 0, 0, 0, 5, 0 /)
11268 WRITE(*, FMT="(6(I0, ' '))") pack(m, m /= 0) ! "1 5"
11269 END PROGRAM
11270 @end smallexample
11271
11272 Gathering nonzero elements from an array and appending elements from @var{VECTOR}:
11273 @smallexample
11274 PROGRAM test_pack_2
11275 INTEGER :: m(4)
11276 m = (/ 1, 0, 0, 2 /)
11277 WRITE(*, FMT="(4(I0, ' '))") pack(m, m /= 0, (/ 0, 0, 3, 4 /)) ! "1 2 3 4"
11278 END PROGRAM
11279 @end smallexample
11280
11281 @item @emph{See also}:
11282 @ref{UNPACK}
11283 @end table
11284
11285
11286
11287 @node PARITY
11288 @section @code{PARITY} --- Reduction with exclusive OR
11289 @fnindex PARITY
11290 @cindex Parity
11291 @cindex Reduction, XOR
11292 @cindex XOR reduction
11293
11294 @table @asis
11295 @item @emph{Description}:
11296 Calculates the parity, i.e. the reduction using @code{.XOR.},
11297 of @var{MASK} along dimension @var{DIM}.
11298
11299 @item @emph{Standard}:
11300 Fortran 2008 and later
11301
11302 @item @emph{Class}:
11303 Transformational function
11304
11305 @item @emph{Syntax}:
11306 @multitable @columnfractions .80
11307 @item @code{RESULT = PARITY(MASK[, DIM])}
11308 @end multitable
11309
11310 @item @emph{Arguments}:
11311 @multitable @columnfractions .15 .70
11312 @item @var{LOGICAL} @tab Shall be an array of type @code{LOGICAL}
11313 @item @var{DIM} @tab (Optional) shall be a scalar of type
11314 @code{INTEGER} with a value in the range from 1 to n, where n
11315 equals the rank of @var{MASK}.
11316 @end multitable
11317
11318 @item @emph{Return value}:
11319 The result is of the same type as @var{MASK}.
11320
11321 If @var{DIM} is absent, a scalar with the parity of all elements in
11322 @var{MASK} is returned, i.e. true if an odd number of elements is
11323 @code{.true.} and false otherwise. If @var{DIM} is present, an array
11324 of rank @math{n-1}, where @math{n} equals the rank of @var{ARRAY},
11325 and a shape similar to that of @var{MASK} with dimension @var{DIM}
11326 dropped is returned.
11327
11328 @item @emph{Example}:
11329 @smallexample
11330 PROGRAM test_sum
11331 LOGICAL :: x(2) = [ .true., .false. ]
11332 print *, PARITY(x) ! prints "T" (true).
11333 END PROGRAM
11334 @end smallexample
11335 @end table
11336
11337
11338
11339 @node PERROR
11340 @section @code{PERROR} --- Print system error message
11341 @fnindex PERROR
11342 @cindex system, error handling
11343
11344 @table @asis
11345 @item @emph{Description}:
11346 Prints (on the C @code{stderr} stream) a newline-terminated error
11347 message corresponding to the last system error. This is prefixed by
11348 @var{STRING}, a colon and a space. See @code{perror(3)}.
11349
11350 @item @emph{Standard}:
11351 GNU extension
11352
11353 @item @emph{Class}:
11354 Subroutine
11355
11356 @item @emph{Syntax}:
11357 @code{CALL PERROR(STRING)}
11358
11359 @item @emph{Arguments}:
11360 @multitable @columnfractions .15 .70
11361 @item @var{STRING} @tab A scalar of type @code{CHARACTER} and of the
11362 default kind.
11363 @end multitable
11364
11365 @item @emph{See also}:
11366 @ref{IERRNO}
11367 @end table
11368
11369
11370
11371 @node POPCNT
11372 @section @code{POPCNT} --- Number of bits set
11373 @fnindex POPCNT
11374 @cindex binary representation
11375 @cindex bits set
11376
11377 @table @asis
11378 @item @emph{Description}:
11379 @code{POPCNT(I)} returns the number of bits set ('1' bits) in the binary
11380 representation of @code{I}.
11381
11382 @item @emph{Standard}:
11383 Fortran 2008 and later
11384
11385 @item @emph{Class}:
11386 Elemental function
11387
11388 @item @emph{Syntax}:
11389 @code{RESULT = POPCNT(I)}
11390
11391 @item @emph{Arguments}:
11392 @multitable @columnfractions .15 .70
11393 @item @var{I} @tab Shall be of type @code{INTEGER}.
11394 @end multitable
11395
11396 @item @emph{Return value}:
11397 The return value is of type @code{INTEGER} and of the default integer
11398 kind.
11399
11400 @item @emph{See also}:
11401 @ref{POPPAR}, @ref{LEADZ}, @ref{TRAILZ}
11402
11403 @item @emph{Example}:
11404 @smallexample
11405 program test_population
11406 print *, popcnt(127), poppar(127)
11407 print *, popcnt(huge(0_4)), poppar(huge(0_4))
11408 print *, popcnt(huge(0_8)), poppar(huge(0_8))
11409 end program test_population
11410 @end smallexample
11411 @end table
11412
11413
11414 @node POPPAR
11415 @section @code{POPPAR} --- Parity of the number of bits set
11416 @fnindex POPPAR
11417 @cindex binary representation
11418 @cindex parity
11419
11420 @table @asis
11421 @item @emph{Description}:
11422 @code{POPPAR(I)} returns parity of the integer @code{I}, i.e. the parity
11423 of the number of bits set ('1' bits) in the binary representation of
11424 @code{I}. It is equal to 0 if @code{I} has an even number of bits set,
11425 and 1 for an odd number of '1' bits.
11426
11427 @item @emph{Standard}:
11428 Fortran 2008 and later
11429
11430 @item @emph{Class}:
11431 Elemental function
11432
11433 @item @emph{Syntax}:
11434 @code{RESULT = POPPAR(I)}
11435
11436 @item @emph{Arguments}:
11437 @multitable @columnfractions .15 .70
11438 @item @var{I} @tab Shall be of type @code{INTEGER}.
11439 @end multitable
11440
11441 @item @emph{Return value}:
11442 The return value is of type @code{INTEGER} and of the default integer
11443 kind.
11444
11445 @item @emph{See also}:
11446 @ref{POPCNT}, @ref{LEADZ}, @ref{TRAILZ}
11447
11448 @item @emph{Example}:
11449 @smallexample
11450 program test_population
11451 print *, popcnt(127), poppar(127)
11452 print *, popcnt(huge(0_4)), poppar(huge(0_4))
11453 print *, popcnt(huge(0_8)), poppar(huge(0_8))
11454 end program test_population
11455 @end smallexample
11456 @end table
11457
11458
11459
11460 @node PRECISION
11461 @section @code{PRECISION} --- Decimal precision of a real kind
11462 @fnindex PRECISION
11463 @cindex model representation, precision
11464
11465 @table @asis
11466 @item @emph{Description}:
11467 @code{PRECISION(X)} returns the decimal precision in the model of the
11468 type of @code{X}.
11469
11470 @item @emph{Standard}:
11471 Fortran 95 and later
11472
11473 @item @emph{Class}:
11474 Inquiry function
11475
11476 @item @emph{Syntax}:
11477 @code{RESULT = PRECISION(X)}
11478
11479 @item @emph{Arguments}:
11480 @multitable @columnfractions .15 .70
11481 @item @var{X} @tab Shall be of type @code{REAL} or @code{COMPLEX}.
11482 @end multitable
11483
11484 @item @emph{Return value}:
11485 The return value is of type @code{INTEGER} and of the default integer
11486 kind.
11487
11488 @item @emph{See also}:
11489 @ref{SELECTED_REAL_KIND}, @ref{RANGE}
11490
11491 @item @emph{Example}:
11492 @smallexample
11493 program prec_and_range
11494 real(kind=4) :: x(2)
11495 complex(kind=8) :: y
11496
11497 print *, precision(x), range(x)
11498 print *, precision(y), range(y)
11499 end program prec_and_range
11500 @end smallexample
11501 @end table
11502
11503
11504
11505 @node PRESENT
11506 @section @code{PRESENT} --- Determine whether an optional dummy argument is specified
11507 @fnindex PRESENT
11508
11509 @table @asis
11510 @item @emph{Description}:
11511 Determines whether an optional dummy argument is present.
11512
11513 @item @emph{Standard}:
11514 Fortran 95 and later
11515
11516 @item @emph{Class}:
11517 Inquiry function
11518
11519 @item @emph{Syntax}:
11520 @code{RESULT = PRESENT(A)}
11521
11522 @item @emph{Arguments}:
11523 @multitable @columnfractions .15 .70
11524 @item @var{A} @tab May be of any type and may be a pointer, scalar or array
11525 value, or a dummy procedure. It shall be the name of an optional dummy argument
11526 accessible within the current subroutine or function.
11527 @end multitable
11528
11529 @item @emph{Return value}:
11530 Returns either @code{TRUE} if the optional argument @var{A} is present, or
11531 @code{FALSE} otherwise.
11532
11533 @item @emph{Example}:
11534 @smallexample
11535 PROGRAM test_present
11536 WRITE(*,*) f(), f(42) ! "F T"
11537 CONTAINS
11538 LOGICAL FUNCTION f(x)
11539 INTEGER, INTENT(IN), OPTIONAL :: x
11540 f = PRESENT(x)
11541 END FUNCTION
11542 END PROGRAM
11543 @end smallexample
11544 @end table
11545
11546
11547
11548 @node PRODUCT
11549 @section @code{PRODUCT} --- Product of array elements
11550 @fnindex PRODUCT
11551 @cindex array, product
11552 @cindex array, multiply elements
11553 @cindex array, conditionally multiply elements
11554 @cindex multiply array elements
11555
11556 @table @asis
11557 @item @emph{Description}:
11558 Multiplies the elements of @var{ARRAY} along dimension @var{DIM} if
11559 the corresponding element in @var{MASK} is @code{TRUE}.
11560
11561 @item @emph{Standard}:
11562 Fortran 95 and later
11563
11564 @item @emph{Class}:
11565 Transformational function
11566
11567 @item @emph{Syntax}:
11568 @multitable @columnfractions .80
11569 @item @code{RESULT = PRODUCT(ARRAY[, MASK])}
11570 @item @code{RESULT = PRODUCT(ARRAY, DIM[, MASK])}
11571 @end multitable
11572
11573 @item @emph{Arguments}:
11574 @multitable @columnfractions .15 .70
11575 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER},
11576 @code{REAL} or @code{COMPLEX}.
11577 @item @var{DIM} @tab (Optional) shall be a scalar of type
11578 @code{INTEGER} with a value in the range from 1 to n, where n
11579 equals the rank of @var{ARRAY}.
11580 @item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL}
11581 and either be a scalar or an array of the same shape as @var{ARRAY}.
11582 @end multitable
11583
11584 @item @emph{Return value}:
11585 The result is of the same type as @var{ARRAY}.
11586
11587 If @var{DIM} is absent, a scalar with the product of all elements in
11588 @var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals
11589 the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with
11590 dimension @var{DIM} dropped is returned.
11591
11592
11593 @item @emph{Example}:
11594 @smallexample
11595 PROGRAM test_product
11596 INTEGER :: x(5) = (/ 1, 2, 3, 4 ,5 /)
11597 print *, PRODUCT(x) ! all elements, product = 120
11598 print *, PRODUCT(x, MASK=MOD(x, 2)==1) ! odd elements, product = 15
11599 END PROGRAM
11600 @end smallexample
11601
11602 @item @emph{See also}:
11603 @ref{SUM}
11604 @end table
11605
11606
11607
11608 @node RADIX
11609 @section @code{RADIX} --- Base of a model number
11610 @fnindex RADIX
11611 @cindex model representation, base
11612 @cindex model representation, radix
11613
11614 @table @asis
11615 @item @emph{Description}:
11616 @code{RADIX(X)} returns the base of the model representing the entity @var{X}.
11617
11618 @item @emph{Standard}:
11619 Fortran 95 and later
11620
11621 @item @emph{Class}:
11622 Inquiry function
11623
11624 @item @emph{Syntax}:
11625 @code{RESULT = RADIX(X)}
11626
11627 @item @emph{Arguments}:
11628 @multitable @columnfractions .15 .70
11629 @item @var{X} @tab Shall be of type @code{INTEGER} or @code{REAL}
11630 @end multitable
11631
11632 @item @emph{Return value}:
11633 The return value is a scalar of type @code{INTEGER} and of the default
11634 integer kind.
11635
11636 @item @emph{See also}:
11637 @ref{SELECTED_REAL_KIND}
11638
11639 @item @emph{Example}:
11640 @smallexample
11641 program test_radix
11642 print *, "The radix for the default integer kind is", radix(0)
11643 print *, "The radix for the default real kind is", radix(0.0)
11644 end program test_radix
11645 @end smallexample
11646
11647 @end table
11648
11649
11650
11651 @node RAN
11652 @section @code{RAN} --- Real pseudo-random number
11653 @fnindex RAN
11654 @cindex random number generation
11655
11656 @table @asis
11657 @item @emph{Description}:
11658 For compatibility with HP FORTRAN 77/iX, the @code{RAN} intrinsic is
11659 provided as an alias for @code{RAND}. See @ref{RAND} for complete
11660 documentation.
11661
11662 @item @emph{Standard}:
11663 GNU extension
11664
11665 @item @emph{Class}:
11666 Function
11667
11668 @item @emph{See also}:
11669 @ref{RAND}, @ref{RANDOM_NUMBER}
11670 @end table
11671
11672
11673
11674 @node RAND
11675 @section @code{RAND} --- Real pseudo-random number
11676 @fnindex RAND
11677 @cindex random number generation
11678
11679 @table @asis
11680 @item @emph{Description}:
11681 @code{RAND(FLAG)} returns a pseudo-random number from a uniform
11682 distribution between 0 and 1. If @var{FLAG} is 0, the next number
11683 in the current sequence is returned; if @var{FLAG} is 1, the generator
11684 is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
11685 it is used as a new seed with @code{SRAND}.
11686
11687 This intrinsic routine is provided for backwards compatibility with
11688 GNU Fortran 77. It implements a simple modulo generator as provided
11689 by @command{g77}. For new code, one should consider the use of
11690 @ref{RANDOM_NUMBER} as it implements a superior algorithm.
11691
11692 @item @emph{Standard}:
11693 GNU extension
11694
11695 @item @emph{Class}:
11696 Function
11697
11698 @item @emph{Syntax}:
11699 @code{RESULT = RAND(I)}
11700
11701 @item @emph{Arguments}:
11702 @multitable @columnfractions .15 .70
11703 @item @var{I} @tab Shall be a scalar @code{INTEGER} of kind 4.
11704 @end multitable
11705
11706 @item @emph{Return value}:
11707 The return value is of @code{REAL} type and the default kind.
11708
11709 @item @emph{Example}:
11710 @smallexample
11711 program test_rand
11712 integer,parameter :: seed = 86456
11713
11714 call srand(seed)
11715 print *, rand(), rand(), rand(), rand()
11716 print *, rand(seed), rand(), rand(), rand()
11717 end program test_rand
11718 @end smallexample
11719
11720 @item @emph{See also}:
11721 @ref{SRAND}, @ref{RANDOM_NUMBER}
11722
11723 @end table
11724
11725
11726 @node RANDOM_INIT
11727 @section @code{RANDOM_INIT} --- Initialize a pseudo-random number generator
11728 @fnindex RANDOM_INIT
11729 @cindex random number generation, initialization
11730
11731 @table @asis
11732 @item @emph{Description}:
11733 Initializes the state of the pseudorandom number generator used by
11734 @code{RANDOM_NUMBER}.
11735
11736 @item @emph{Standard}:
11737 Fortran 2018
11738
11739 @item @emph{Class}:
11740 Subroutine
11741
11742 @item @emph{Syntax}:
11743 @code{CALL RANDOM_INIT(REPEATABLE, IMAGE_DISTINCT)}
11744
11745 @item @emph{Arguments}:
11746 @multitable @columnfractions .20 .75
11747 @item @var{REPEATABLE} @tab Shall be a scalar with a @code{LOGICAL} type,
11748 and it is @code{INTENT(IN)}. If it is @code{.true.}, the seed is set to
11749 a processor-dependent value that is the same each time @code{RANDOM_INIT}
11750 is called from the same image. The term ``same image'' means a single
11751 instance of program execution. The sequence of random numbers is different
11752 for repeated execution of the program. If it is @code{.false.}, the seed
11753 is set to a processor-dependent value.
11754 @item @var{IMAGE_DISTINCT} @tab Shall be a scalar with a
11755 @code{LOGICAL} type, and it is @code{INTENT(IN)}. If it is @code{.true.},
11756 the seed is set to a processor-dependent value that is distinct from th
11757 seed set by a call to @code{RANDOM_INIT} in another image. If it is
11758 @code{.false.}, the seed is set value that does depend which image called
11759 @code{RANDOM_INIT}.
11760 @end multitable
11761
11762 @item @emph{Example}:
11763 @smallexample
11764 program test_random_seed
11765 implicit none
11766 real x(3), y(3)
11767 call random_init(.true., .true.)
11768 call random_number(x)
11769 call random_init(.true., .true.)
11770 call random_number(y)
11771 ! x and y are the same sequence
11772 if (any(x /= y)) call abort
11773 end program test_random_seed
11774 @end smallexample
11775
11776 @item @emph{See also}:
11777 @ref{RANDOM_NUMBER}, @ref{RANDOM_SEED}
11778 @end table
11779
11780
11781 @node RANDOM_NUMBER
11782 @section @code{RANDOM_NUMBER} --- Pseudo-random number
11783 @fnindex RANDOM_NUMBER
11784 @cindex random number generation
11785
11786 @table @asis
11787 @item @emph{Description}:
11788 Returns a single pseudorandom number or an array of pseudorandom numbers
11789 from the uniform distribution over the range @math{ 0 \leq x < 1}.
11790
11791 The runtime-library implements the xorshift1024* random number
11792 generator (RNG). This generator has a period of @math{2^{1024} - 1},
11793 and when using multiple threads up to @math{2^{512}} threads can each
11794 generate @math{2^{512}} random numbers before any aliasing occurs.
11795
11796 Note that in a multi-threaded program (e.g. using OpenMP directives),
11797 each thread will have its own random number state. For details of the
11798 seeding procedure, see the documentation for the @code{RANDOM_SEED}
11799 intrinsic.
11800
11801
11802 @item @emph{Standard}:
11803 Fortran 95 and later
11804
11805 @item @emph{Class}:
11806 Subroutine
11807
11808 @item @emph{Syntax}:
11809 @code{RANDOM_NUMBER(HARVEST)}
11810
11811 @item @emph{Arguments}:
11812 @multitable @columnfractions .15 .70
11813 @item @var{HARVEST} @tab Shall be a scalar or an array of type @code{REAL}.
11814 @end multitable
11815
11816 @item @emph{Example}:
11817 @smallexample
11818 program test_random_number
11819 REAL :: r(5,5)
11820 CALL RANDOM_NUMBER(r)
11821 end program
11822 @end smallexample
11823
11824 @item @emph{See also}:
11825 @ref{RANDOM_SEED}, @ref{RANDOM_INIT}
11826 @end table
11827
11828
11829
11830 @node RANDOM_SEED
11831 @section @code{RANDOM_SEED} --- Initialize a pseudo-random number sequence
11832 @fnindex RANDOM_SEED
11833 @cindex random number generation, seeding
11834 @cindex seeding a random number generator
11835
11836 @table @asis
11837 @item @emph{Description}:
11838 Restarts or queries the state of the pseudorandom number generator used by
11839 @code{RANDOM_NUMBER}.
11840
11841 If @code{RANDOM_SEED} is called without arguments, it is seeded with
11842 random data retrieved from the operating system.
11843
11844 As an extension to the Fortran standard, the GFortran
11845 @code{RANDOM_NUMBER} supports multiple threads. Each thread in a
11846 multi-threaded program has its own seed. When @code{RANDOM_SEED} is
11847 called either without arguments or with the @var{PUT} argument, the
11848 given seed is copied into a master seed as well as the seed of the
11849 current thread. When a new thread uses @code{RANDOM_NUMBER} for the
11850 first time, the seed is copied from the master seed, and forwarded
11851 @math{N * 2^{512}} steps to guarantee that the random stream does not
11852 alias any other stream in the system, where @var{N} is the number of
11853 threads that have used @code{RANDOM_NUMBER} so far during the program
11854 execution.
11855
11856 @item @emph{Standard}:
11857 Fortran 95 and later
11858
11859 @item @emph{Class}:
11860 Subroutine
11861
11862 @item @emph{Syntax}:
11863 @code{CALL RANDOM_SEED([SIZE, PUT, GET])}
11864
11865 @item @emph{Arguments}:
11866 @multitable @columnfractions .15 .70
11867 @item @var{SIZE} @tab (Optional) Shall be a scalar and of type default
11868 @code{INTEGER}, with @code{INTENT(OUT)}. It specifies the minimum size
11869 of the arrays used with the @var{PUT} and @var{GET} arguments.
11870 @item @var{PUT} @tab (Optional) Shall be an array of type default
11871 @code{INTEGER} and rank one. It is @code{INTENT(IN)} and the size of
11872 the array must be larger than or equal to the number returned by the
11873 @var{SIZE} argument.
11874 @item @var{GET} @tab (Optional) Shall be an array of type default
11875 @code{INTEGER} and rank one. It is @code{INTENT(OUT)} and the size
11876 of the array must be larger than or equal to the number returned by
11877 the @var{SIZE} argument.
11878 @end multitable
11879
11880 @item @emph{Example}:
11881 @smallexample
11882 program test_random_seed
11883 implicit none
11884 integer, allocatable :: seed(:)
11885 integer :: n
11886
11887 call random_seed(size = n)
11888 allocate(seed(n))
11889 call random_seed(get=seed)
11890 write (*, *) seed
11891 end program test_random_seed
11892 @end smallexample
11893
11894 @item @emph{See also}:
11895 @ref{RANDOM_NUMBER}, @ref{RANDOM_INIT}
11896 @end table
11897
11898
11899
11900 @node RANGE
11901 @section @code{RANGE} --- Decimal exponent range
11902 @fnindex RANGE
11903 @cindex model representation, range
11904
11905 @table @asis
11906 @item @emph{Description}:
11907 @code{RANGE(X)} returns the decimal exponent range in the model of the
11908 type of @code{X}.
11909
11910 @item @emph{Standard}:
11911 Fortran 95 and later
11912
11913 @item @emph{Class}:
11914 Inquiry function
11915
11916 @item @emph{Syntax}:
11917 @code{RESULT = RANGE(X)}
11918
11919 @item @emph{Arguments}:
11920 @multitable @columnfractions .15 .70
11921 @item @var{X} @tab Shall be of type @code{INTEGER}, @code{REAL}
11922 or @code{COMPLEX}.
11923 @end multitable
11924
11925 @item @emph{Return value}:
11926 The return value is of type @code{INTEGER} and of the default integer
11927 kind.
11928
11929 @item @emph{See also}:
11930 @ref{SELECTED_REAL_KIND}, @ref{PRECISION}
11931
11932 @item @emph{Example}:
11933 See @code{PRECISION} for an example.
11934 @end table
11935
11936
11937
11938 @node RANK
11939 @section @code{RANK} --- Rank of a data object
11940 @fnindex RANK
11941 @cindex rank
11942
11943 @table @asis
11944 @item @emph{Description}:
11945 @code{RANK(A)} returns the rank of a scalar or array data object.
11946
11947 @item @emph{Standard}:
11948 Technical Specification (TS) 29113
11949
11950 @item @emph{Class}:
11951 Inquiry function
11952
11953 @item @emph{Syntax}:
11954 @code{RESULT = RANK(A)}
11955
11956 @item @emph{Arguments}:
11957 @multitable @columnfractions .15 .70
11958 @item @var{A} @tab can be of any type
11959 @end multitable
11960
11961 @item @emph{Return value}:
11962 The return value is of type @code{INTEGER} and of the default integer
11963 kind. For arrays, their rank is returned; for scalars zero is returned.
11964
11965 @item @emph{Example}:
11966 @smallexample
11967 program test_rank
11968 integer :: a
11969 real, allocatable :: b(:,:)
11970
11971 print *, rank(a), rank(b) ! Prints: 0 2
11972 end program test_rank
11973 @end smallexample
11974
11975 @end table
11976
11977
11978
11979 @node REAL
11980 @section @code{REAL} --- Convert to real type
11981 @fnindex REAL
11982 @fnindex REALPART
11983 @fnindex FLOAT
11984 @fnindex DFLOAT
11985 @fnindex FLOATI
11986 @fnindex FLOATJ
11987 @fnindex FLOATK
11988 @fnindex SNGL
11989 @cindex conversion, to real
11990 @cindex complex numbers, real part
11991
11992 @table @asis
11993 @item @emph{Description}:
11994 @code{REAL(A [, KIND])} converts its argument @var{A} to a real type. The
11995 @code{REALPART} function is provided for compatibility with @command{g77},
11996 and its use is strongly discouraged.
11997
11998 @item @emph{Standard}:
11999 Fortran 77 and later
12000
12001 @item @emph{Class}:
12002 Elemental function
12003
12004 @item @emph{Syntax}:
12005 @multitable @columnfractions .80
12006 @item @code{RESULT = REAL(A [, KIND])}
12007 @item @code{RESULT = REALPART(Z)}
12008 @end multitable
12009
12010 @item @emph{Arguments}:
12011 @multitable @columnfractions .15 .70
12012 @item @var{A} @tab Shall be @code{INTEGER}, @code{REAL}, or
12013 @code{COMPLEX}.
12014 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
12015 expression indicating the kind parameter of the result.
12016 @end multitable
12017
12018 @item @emph{Return value}:
12019 These functions return a @code{REAL} variable or array under
12020 the following rules:
12021
12022 @table @asis
12023 @item (A)
12024 @code{REAL(A)} is converted to a default real type if @var{A} is an
12025 integer or real variable.
12026 @item (B)
12027 @code{REAL(A)} is converted to a real type with the kind type parameter
12028 of @var{A} if @var{A} is a complex variable.
12029 @item (C)
12030 @code{REAL(A, KIND)} is converted to a real type with kind type
12031 parameter @var{KIND} if @var{A} is a complex, integer, or real
12032 variable.
12033 @end table
12034
12035 @item @emph{Example}:
12036 @smallexample
12037 program test_real
12038 complex :: x = (1.0, 2.0)
12039 print *, real(x), real(x,8), realpart(x)
12040 end program test_real
12041 @end smallexample
12042
12043 @item @emph{Specific names}:
12044 @multitable @columnfractions .20 .20 .20 .25
12045 @item Name @tab Argument @tab Return type @tab Standard
12046 @item @code{FLOAT(A)} @tab @code{INTEGER(4)} @tab @code{REAL(4)} @tab Fortran 77 and later
12047 @item @code{DFLOAT(A)} @tab @code{INTEGER(4)} @tab @code{REAL(8)} @tab GNU extension
12048 @item @code{FLOATI(A)} @tab @code{INTEGER(2)} @tab @code{REAL(4)} @tab GNU extension
12049 @item @code{FLOATJ(A)} @tab @code{INTEGER(4)} @tab @code{REAL(4)} @tab GNU extension
12050 @item @code{FLOATK(A)} @tab @code{INTEGER(8)} @tab @code{REAL(4)} @tab GNU extension
12051 @item @code{SNGL(A)} @tab @code{INTEGER(8)} @tab @code{REAL(4)} @tab Fortran 77 and later
12052 @end multitable
12053
12054
12055 @item @emph{See also}:
12056 @ref{DBLE}
12057
12058 @end table
12059
12060
12061
12062 @node RENAME
12063 @section @code{RENAME} --- Rename a file
12064 @fnindex RENAME
12065 @cindex file system, rename file
12066
12067 @table @asis
12068 @item @emph{Description}:
12069 Renames a file from file @var{PATH1} to @var{PATH2}. A null
12070 character (@code{CHAR(0)}) can be used to mark the end of the names in
12071 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
12072 names are ignored. If the @var{STATUS} argument is supplied, it
12073 contains 0 on success or a nonzero error code upon return; see
12074 @code{rename(2)}.
12075
12076 This intrinsic is provided in both subroutine and function forms;
12077 however, only one form can be used in any given program unit.
12078
12079 @item @emph{Standard}:
12080 GNU extension
12081
12082 @item @emph{Class}:
12083 Subroutine, function
12084
12085 @item @emph{Syntax}:
12086 @multitable @columnfractions .80
12087 @item @code{CALL RENAME(PATH1, PATH2 [, STATUS])}
12088 @item @code{STATUS = RENAME(PATH1, PATH2)}
12089 @end multitable
12090
12091 @item @emph{Arguments}:
12092 @multitable @columnfractions .15 .70
12093 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
12094 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
12095 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
12096 @end multitable
12097
12098 @item @emph{See also}:
12099 @ref{LINK}
12100
12101 @end table
12102
12103
12104
12105 @node REPEAT
12106 @section @code{REPEAT} --- Repeated string concatenation
12107 @fnindex REPEAT
12108 @cindex string, repeat
12109 @cindex string, concatenate
12110
12111 @table @asis
12112 @item @emph{Description}:
12113 Concatenates @var{NCOPIES} copies of a string.
12114
12115 @item @emph{Standard}:
12116 Fortran 95 and later
12117
12118 @item @emph{Class}:
12119 Transformational function
12120
12121 @item @emph{Syntax}:
12122 @code{RESULT = REPEAT(STRING, NCOPIES)}
12123
12124 @item @emph{Arguments}:
12125 @multitable @columnfractions .15 .70
12126 @item @var{STRING} @tab Shall be scalar and of type @code{CHARACTER}.
12127 @item @var{NCOPIES} @tab Shall be scalar and of type @code{INTEGER}.
12128 @end multitable
12129
12130 @item @emph{Return value}:
12131 A new scalar of type @code{CHARACTER} built up from @var{NCOPIES} copies
12132 of @var{STRING}.
12133
12134 @item @emph{Example}:
12135 @smallexample
12136 program test_repeat
12137 write(*,*) repeat("x", 5) ! "xxxxx"
12138 end program
12139 @end smallexample
12140 @end table
12141
12142
12143
12144 @node RESHAPE
12145 @section @code{RESHAPE} --- Function to reshape an array
12146 @fnindex RESHAPE
12147 @cindex array, change dimensions
12148 @cindex array, transmogrify
12149
12150 @table @asis
12151 @item @emph{Description}:
12152 Reshapes @var{SOURCE} to correspond to @var{SHAPE}. If necessary,
12153 the new array may be padded with elements from @var{PAD} or permuted
12154 as defined by @var{ORDER}.
12155
12156 @item @emph{Standard}:
12157 Fortran 95 and later
12158
12159 @item @emph{Class}:
12160 Transformational function
12161
12162 @item @emph{Syntax}:
12163 @code{RESULT = RESHAPE(SOURCE, SHAPE[, PAD, ORDER])}
12164
12165 @item @emph{Arguments}:
12166 @multitable @columnfractions .15 .70
12167 @item @var{SOURCE} @tab Shall be an array of any type.
12168 @item @var{SHAPE} @tab Shall be of type @code{INTEGER} and an
12169 array of rank one. Its values must be positive or zero.
12170 @item @var{PAD} @tab (Optional) shall be an array of the same
12171 type as @var{SOURCE}.
12172 @item @var{ORDER} @tab (Optional) shall be of type @code{INTEGER}
12173 and an array of the same shape as @var{SHAPE}. Its values shall
12174 be a permutation of the numbers from 1 to n, where n is the size of
12175 @var{SHAPE}. If @var{ORDER} is absent, the natural ordering shall
12176 be assumed.
12177 @end multitable
12178
12179 @item @emph{Return value}:
12180 The result is an array of shape @var{SHAPE} with the same type as
12181 @var{SOURCE}.
12182
12183 @item @emph{Example}:
12184 @smallexample
12185 PROGRAM test_reshape
12186 INTEGER, DIMENSION(4) :: x
12187 WRITE(*,*) SHAPE(x) ! prints "4"
12188 WRITE(*,*) SHAPE(RESHAPE(x, (/2, 2/))) ! prints "2 2"
12189 END PROGRAM
12190 @end smallexample
12191
12192 @item @emph{See also}:
12193 @ref{SHAPE}
12194 @end table
12195
12196
12197
12198 @node RRSPACING
12199 @section @code{RRSPACING} --- Reciprocal of the relative spacing
12200 @fnindex RRSPACING
12201 @cindex real number, relative spacing
12202 @cindex floating point, relative spacing
12203
12204
12205 @table @asis
12206 @item @emph{Description}:
12207 @code{RRSPACING(X)} returns the reciprocal of the relative spacing of
12208 model numbers near @var{X}.
12209
12210 @item @emph{Standard}:
12211 Fortran 95 and later
12212
12213 @item @emph{Class}:
12214 Elemental function
12215
12216 @item @emph{Syntax}:
12217 @code{RESULT = RRSPACING(X)}
12218
12219 @item @emph{Arguments}:
12220 @multitable @columnfractions .15 .70
12221 @item @var{X} @tab Shall be of type @code{REAL}.
12222 @end multitable
12223
12224 @item @emph{Return value}:
12225 The return value is of the same type and kind as @var{X}.
12226 The value returned is equal to
12227 @code{ABS(FRACTION(X)) * FLOAT(RADIX(X))**DIGITS(X)}.
12228
12229 @item @emph{See also}:
12230 @ref{SPACING}
12231 @end table
12232
12233
12234
12235 @node RSHIFT
12236 @section @code{RSHIFT} --- Right shift bits
12237 @fnindex RSHIFT
12238 @cindex bits, shift right
12239
12240 @table @asis
12241 @item @emph{Description}:
12242 @code{RSHIFT} returns a value corresponding to @var{I} with all of the
12243 bits shifted right by @var{SHIFT} places. If the absolute value of
12244 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
12245 Bits shifted out from the right end are lost. The fill is arithmetic: the
12246 bits shifted in from the left end are equal to the leftmost bit, which in
12247 two's complement representation is the sign bit.
12248
12249 This function has been superseded by the @code{SHIFTA} intrinsic, which
12250 is standard in Fortran 2008 and later.
12251
12252 @item @emph{Standard}:
12253 GNU extension
12254
12255 @item @emph{Class}:
12256 Elemental function
12257
12258 @item @emph{Syntax}:
12259 @code{RESULT = RSHIFT(I, SHIFT)}
12260
12261 @item @emph{Arguments}:
12262 @multitable @columnfractions .15 .70
12263 @item @var{I} @tab The type shall be @code{INTEGER}.
12264 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
12265 @end multitable
12266
12267 @item @emph{Return value}:
12268 The return value is of type @code{INTEGER} and of the same kind as
12269 @var{I}.
12270
12271 @item @emph{See also}:
12272 @ref{ISHFT}, @ref{ISHFTC}, @ref{LSHIFT}, @ref{SHIFTA}, @ref{SHIFTR},
12273 @ref{SHIFTL}
12274
12275 @end table
12276
12277
12278
12279 @node SAME_TYPE_AS
12280 @section @code{SAME_TYPE_AS} --- Query dynamic types for equality
12281 @fnindex SAME_TYPE_AS
12282
12283 @table @asis
12284 @item @emph{Description}:
12285 Query dynamic types for equality.
12286
12287 @item @emph{Standard}:
12288 Fortran 2003 and later
12289
12290 @item @emph{Class}:
12291 Inquiry function
12292
12293 @item @emph{Syntax}:
12294 @code{RESULT = SAME_TYPE_AS(A, B)}
12295
12296 @item @emph{Arguments}:
12297 @multitable @columnfractions .15 .70
12298 @item @var{A} @tab Shall be an object of extensible declared type or
12299 unlimited polymorphic.
12300 @item @var{B} @tab Shall be an object of extensible declared type or
12301 unlimited polymorphic.
12302 @end multitable
12303
12304 @item @emph{Return value}:
12305 The return value is a scalar of type default logical. It is true if and
12306 only if the dynamic type of A is the same as the dynamic type of B.
12307
12308 @item @emph{See also}:
12309 @ref{EXTENDS_TYPE_OF}
12310
12311 @end table
12312
12313
12314
12315 @node SCALE
12316 @section @code{SCALE} --- Scale a real value
12317 @fnindex SCALE
12318 @cindex real number, scale
12319 @cindex floating point, scale
12320
12321 @table @asis
12322 @item @emph{Description}:
12323 @code{SCALE(X,I)} returns @code{X * RADIX(X)**I}.
12324
12325 @item @emph{Standard}:
12326 Fortran 95 and later
12327
12328 @item @emph{Class}:
12329 Elemental function
12330
12331 @item @emph{Syntax}:
12332 @code{RESULT = SCALE(X, I)}
12333
12334 @item @emph{Arguments}:
12335 @multitable @columnfractions .15 .70
12336 @item @var{X} @tab The type of the argument shall be a @code{REAL}.
12337 @item @var{I} @tab The type of the argument shall be a @code{INTEGER}.
12338 @end multitable
12339
12340 @item @emph{Return value}:
12341 The return value is of the same type and kind as @var{X}.
12342 Its value is @code{X * RADIX(X)**I}.
12343
12344 @item @emph{Example}:
12345 @smallexample
12346 program test_scale
12347 real :: x = 178.1387e-4
12348 integer :: i = 5
12349 print *, scale(x,i), x*radix(x)**i
12350 end program test_scale
12351 @end smallexample
12352
12353 @end table
12354
12355
12356
12357 @node SCAN
12358 @section @code{SCAN} --- Scan a string for the presence of a set of characters
12359 @fnindex SCAN
12360 @cindex string, find subset
12361
12362 @table @asis
12363 @item @emph{Description}:
12364 Scans a @var{STRING} for any of the characters in a @var{SET}
12365 of characters.
12366
12367 If @var{BACK} is either absent or equals @code{FALSE}, this function
12368 returns the position of the leftmost character of @var{STRING} that is
12369 in @var{SET}. If @var{BACK} equals @code{TRUE}, the rightmost position
12370 is returned. If no character of @var{SET} is found in @var{STRING}, the
12371 result is zero.
12372
12373 @item @emph{Standard}:
12374 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
12375
12376 @item @emph{Class}:
12377 Elemental function
12378
12379 @item @emph{Syntax}:
12380 @code{RESULT = SCAN(STRING, SET[, BACK [, KIND]])}
12381
12382 @item @emph{Arguments}:
12383 @multitable @columnfractions .15 .70
12384 @item @var{STRING} @tab Shall be of type @code{CHARACTER}.
12385 @item @var{SET} @tab Shall be of type @code{CHARACTER}.
12386 @item @var{BACK} @tab (Optional) shall be of type @code{LOGICAL}.
12387 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
12388 expression indicating the kind parameter of the result.
12389 @end multitable
12390
12391 @item @emph{Return value}:
12392 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
12393 @var{KIND} is absent, the return value is of default integer kind.
12394
12395 @item @emph{Example}:
12396 @smallexample
12397 PROGRAM test_scan
12398 WRITE(*,*) SCAN("FORTRAN", "AO") ! 2, found 'O'
12399 WRITE(*,*) SCAN("FORTRAN", "AO", .TRUE.) ! 6, found 'A'
12400 WRITE(*,*) SCAN("FORTRAN", "C++") ! 0, found none
12401 END PROGRAM
12402 @end smallexample
12403
12404 @item @emph{See also}:
12405 @ref{INDEX intrinsic}, @ref{VERIFY}
12406 @end table
12407
12408
12409
12410 @node SECNDS
12411 @section @code{SECNDS} --- Time function
12412 @fnindex SECNDS
12413 @cindex time, elapsed
12414 @cindex elapsed time
12415
12416 @table @asis
12417 @item @emph{Description}:
12418 @code{SECNDS(X)} gets the time in seconds from the real-time system clock.
12419 @var{X} is a reference time, also in seconds. If this is zero, the time in
12420 seconds from midnight is returned. This function is non-standard and its
12421 use is discouraged.
12422
12423 @item @emph{Standard}:
12424 GNU extension
12425
12426 @item @emph{Class}:
12427 Function
12428
12429 @item @emph{Syntax}:
12430 @code{RESULT = SECNDS (X)}
12431
12432 @item @emph{Arguments}:
12433 @multitable @columnfractions .15 .70
12434 @item @var{T} @tab Shall be of type @code{REAL(4)}.
12435 @item @var{X} @tab Shall be of type @code{REAL(4)}.
12436 @end multitable
12437
12438 @item @emph{Return value}:
12439 None
12440
12441 @item @emph{Example}:
12442 @smallexample
12443 program test_secnds
12444 integer :: i
12445 real(4) :: t1, t2
12446 print *, secnds (0.0) ! seconds since midnight
12447 t1 = secnds (0.0) ! reference time
12448 do i = 1, 10000000 ! do something
12449 end do
12450 t2 = secnds (t1) ! elapsed time
12451 print *, "Something took ", t2, " seconds."
12452 end program test_secnds
12453 @end smallexample
12454 @end table
12455
12456
12457
12458 @node SECOND
12459 @section @code{SECOND} --- CPU time function
12460 @fnindex SECOND
12461 @cindex time, elapsed
12462 @cindex elapsed time
12463
12464 @table @asis
12465 @item @emph{Description}:
12466 Returns a @code{REAL(4)} value representing the elapsed CPU time in
12467 seconds. This provides the same functionality as the standard
12468 @code{CPU_TIME} intrinsic, and is only included for backwards
12469 compatibility.
12470
12471 This intrinsic is provided in both subroutine and function forms;
12472 however, only one form can be used in any given program unit.
12473
12474 @item @emph{Standard}:
12475 GNU extension
12476
12477 @item @emph{Class}:
12478 Subroutine, function
12479
12480 @item @emph{Syntax}:
12481 @multitable @columnfractions .80
12482 @item @code{CALL SECOND(TIME)}
12483 @item @code{TIME = SECOND()}
12484 @end multitable
12485
12486 @item @emph{Arguments}:
12487 @multitable @columnfractions .15 .70
12488 @item @var{TIME} @tab Shall be of type @code{REAL(4)}.
12489 @end multitable
12490
12491 @item @emph{Return value}:
12492 In either syntax, @var{TIME} is set to the process's current runtime in
12493 seconds.
12494
12495 @item @emph{See also}:
12496 @ref{CPU_TIME}
12497
12498 @end table
12499
12500
12501
12502 @node SELECTED_CHAR_KIND
12503 @section @code{SELECTED_CHAR_KIND} --- Choose character kind
12504 @fnindex SELECTED_CHAR_KIND
12505 @cindex character kind
12506 @cindex kind, character
12507
12508 @table @asis
12509 @item @emph{Description}:
12510
12511 @code{SELECTED_CHAR_KIND(NAME)} returns the kind value for the character
12512 set named @var{NAME}, if a character set with such a name is supported,
12513 or @math{-1} otherwise. Currently, supported character sets include
12514 ``ASCII'' and ``DEFAULT'', which are equivalent, and ``ISO_10646''
12515 (Universal Character Set, UCS-4) which is commonly known as Unicode.
12516
12517 @item @emph{Standard}:
12518 Fortran 2003 and later
12519
12520 @item @emph{Class}:
12521 Transformational function
12522
12523 @item @emph{Syntax}:
12524 @code{RESULT = SELECTED_CHAR_KIND(NAME)}
12525
12526 @item @emph{Arguments}:
12527 @multitable @columnfractions .15 .70
12528 @item @var{NAME} @tab Shall be a scalar and of the default character type.
12529 @end multitable
12530
12531 @item @emph{Example}:
12532 @smallexample
12533 program character_kind
12534 use iso_fortran_env
12535 implicit none
12536 integer, parameter :: ascii = selected_char_kind ("ascii")
12537 integer, parameter :: ucs4 = selected_char_kind ('ISO_10646')
12538
12539 character(kind=ascii, len=26) :: alphabet
12540 character(kind=ucs4, len=30) :: hello_world
12541
12542 alphabet = ascii_"abcdefghijklmnopqrstuvwxyz"
12543 hello_world = ucs4_'Hello World and Ni Hao -- ' &
12544 // char (int (z'4F60'), ucs4) &
12545 // char (int (z'597D'), ucs4)
12546
12547 write (*,*) alphabet
12548
12549 open (output_unit, encoding='UTF-8')
12550 write (*,*) trim (hello_world)
12551 end program character_kind
12552 @end smallexample
12553 @end table
12554
12555
12556
12557 @node SELECTED_INT_KIND
12558 @section @code{SELECTED_INT_KIND} --- Choose integer kind
12559 @fnindex SELECTED_INT_KIND
12560 @cindex integer kind
12561 @cindex kind, integer
12562
12563 @table @asis
12564 @item @emph{Description}:
12565 @code{SELECTED_INT_KIND(R)} return the kind value of the smallest integer
12566 type that can represent all values ranging from @math{-10^R} (exclusive)
12567 to @math{10^R} (exclusive). If there is no integer kind that accommodates
12568 this range, @code{SELECTED_INT_KIND} returns @math{-1}.
12569
12570 @item @emph{Standard}:
12571 Fortran 95 and later
12572
12573 @item @emph{Class}:
12574 Transformational function
12575
12576 @item @emph{Syntax}:
12577 @code{RESULT = SELECTED_INT_KIND(R)}
12578
12579 @item @emph{Arguments}:
12580 @multitable @columnfractions .15 .70
12581 @item @var{R} @tab Shall be a scalar and of type @code{INTEGER}.
12582 @end multitable
12583
12584 @item @emph{Example}:
12585 @smallexample
12586 program large_integers
12587 integer,parameter :: k5 = selected_int_kind(5)
12588 integer,parameter :: k15 = selected_int_kind(15)
12589 integer(kind=k5) :: i5
12590 integer(kind=k15) :: i15
12591
12592 print *, huge(i5), huge(i15)
12593
12594 ! The following inequalities are always true
12595 print *, huge(i5) >= 10_k5**5-1
12596 print *, huge(i15) >= 10_k15**15-1
12597 end program large_integers
12598 @end smallexample
12599 @end table
12600
12601
12602
12603 @node SELECTED_REAL_KIND
12604 @section @code{SELECTED_REAL_KIND} --- Choose real kind
12605 @fnindex SELECTED_REAL_KIND
12606 @cindex real kind
12607 @cindex kind, real
12608 @cindex radix, real
12609
12610 @table @asis
12611 @item @emph{Description}:
12612 @code{SELECTED_REAL_KIND(P,R)} returns the kind value of a real data type
12613 with decimal precision of at least @code{P} digits, exponent range of
12614 at least @code{R}, and with a radix of @code{RADIX}.
12615
12616 @item @emph{Standard}:
12617 Fortran 95 and later, with @code{RADIX} Fortran 2008 or later
12618
12619 @item @emph{Class}:
12620 Transformational function
12621
12622 @item @emph{Syntax}:
12623 @code{RESULT = SELECTED_REAL_KIND([P, R, RADIX])}
12624
12625 @item @emph{Arguments}:
12626 @multitable @columnfractions .15 .70
12627 @item @var{P} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
12628 @item @var{R} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
12629 @item @var{RADIX} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
12630 @end multitable
12631 Before Fortran 2008, at least one of the arguments @var{R} or @var{P} shall
12632 be present; since Fortran 2008, they are assumed to be zero if absent.
12633
12634 @item @emph{Return value}:
12635
12636 @code{SELECTED_REAL_KIND} returns the value of the kind type parameter of
12637 a real data type with decimal precision of at least @code{P} digits, a
12638 decimal exponent range of at least @code{R}, and with the requested
12639 @code{RADIX}. If the @code{RADIX} parameter is absent, real kinds with
12640 any radix can be returned. If more than one real data type meet the
12641 criteria, the kind of the data type with the smallest decimal precision
12642 is returned. If no real data type matches the criteria, the result is
12643 @table @asis
12644 @item -1 if the processor does not support a real data type with a
12645 precision greater than or equal to @code{P}, but the @code{R} and
12646 @code{RADIX} requirements can be fulfilled
12647 @item -2 if the processor does not support a real type with an exponent
12648 range greater than or equal to @code{R}, but @code{P} and @code{RADIX}
12649 are fulfillable
12650 @item -3 if @code{RADIX} but not @code{P} and @code{R} requirements
12651 are fulfillable
12652 @item -4 if @code{RADIX} and either @code{P} or @code{R} requirements
12653 are fulfillable
12654 @item -5 if there is no real type with the given @code{RADIX}
12655 @end table
12656
12657 @item @emph{See also}:
12658 @ref{PRECISION}, @ref{RANGE}, @ref{RADIX}
12659
12660 @item @emph{Example}:
12661 @smallexample
12662 program real_kinds
12663 integer,parameter :: p6 = selected_real_kind(6)
12664 integer,parameter :: p10r100 = selected_real_kind(10,100)
12665 integer,parameter :: r400 = selected_real_kind(r=400)
12666 real(kind=p6) :: x
12667 real(kind=p10r100) :: y
12668 real(kind=r400) :: z
12669
12670 print *, precision(x), range(x)
12671 print *, precision(y), range(y)
12672 print *, precision(z), range(z)
12673 end program real_kinds
12674 @end smallexample
12675 @end table
12676
12677
12678
12679 @node SET_EXPONENT
12680 @section @code{SET_EXPONENT} --- Set the exponent of the model
12681 @fnindex SET_EXPONENT
12682 @cindex real number, set exponent
12683 @cindex floating point, set exponent
12684
12685 @table @asis
12686 @item @emph{Description}:
12687 @code{SET_EXPONENT(X, I)} returns the real number whose fractional part
12688 is that that of @var{X} and whose exponent part is @var{I}.
12689
12690 @item @emph{Standard}:
12691 Fortran 95 and later
12692
12693 @item @emph{Class}:
12694 Elemental function
12695
12696 @item @emph{Syntax}:
12697 @code{RESULT = SET_EXPONENT(X, I)}
12698
12699 @item @emph{Arguments}:
12700 @multitable @columnfractions .15 .70
12701 @item @var{X} @tab Shall be of type @code{REAL}.
12702 @item @var{I} @tab Shall be of type @code{INTEGER}.
12703 @end multitable
12704
12705 @item @emph{Return value}:
12706 The return value is of the same type and kind as @var{X}.
12707 The real number whose fractional part
12708 is that that of @var{X} and whose exponent part if @var{I} is returned;
12709 it is @code{FRACTION(X) * RADIX(X)**I}.
12710
12711 @item @emph{Example}:
12712 @smallexample
12713 PROGRAM test_setexp
12714 REAL :: x = 178.1387e-4
12715 INTEGER :: i = 17
12716 PRINT *, SET_EXPONENT(x, i), FRACTION(x) * RADIX(x)**i
12717 END PROGRAM
12718 @end smallexample
12719
12720 @end table
12721
12722
12723
12724 @node SHAPE
12725 @section @code{SHAPE} --- Determine the shape of an array
12726 @fnindex SHAPE
12727 @cindex array, shape
12728
12729 @table @asis
12730 @item @emph{Description}:
12731 Determines the shape of an array.
12732
12733 @item @emph{Standard}:
12734 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
12735
12736 @item @emph{Class}:
12737 Inquiry function
12738
12739 @item @emph{Syntax}:
12740 @code{RESULT = SHAPE(SOURCE [, KIND])}
12741
12742 @item @emph{Arguments}:
12743 @multitable @columnfractions .15 .70
12744 @item @var{SOURCE} @tab Shall be an array or scalar of any type.
12745 If @var{SOURCE} is a pointer it must be associated and allocatable
12746 arrays must be allocated.
12747 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
12748 expression indicating the kind parameter of the result.
12749 @end multitable
12750
12751 @item @emph{Return value}:
12752 An @code{INTEGER} array of rank one with as many elements as @var{SOURCE}
12753 has dimensions. The elements of the resulting array correspond to the extend
12754 of @var{SOURCE} along the respective dimensions. If @var{SOURCE} is a scalar,
12755 the result is the rank one array of size zero. If @var{KIND} is absent, the
12756 return value has the default integer kind otherwise the specified kind.
12757
12758 @item @emph{Example}:
12759 @smallexample
12760 PROGRAM test_shape
12761 INTEGER, DIMENSION(-1:1, -1:2) :: A
12762 WRITE(*,*) SHAPE(A) ! (/ 3, 4 /)
12763 WRITE(*,*) SIZE(SHAPE(42)) ! (/ /)
12764 END PROGRAM
12765 @end smallexample
12766
12767 @item @emph{See also}:
12768 @ref{RESHAPE}, @ref{SIZE}
12769 @end table
12770
12771
12772
12773 @node SHIFTA
12774 @section @code{SHIFTA} --- Right shift with fill
12775 @fnindex SHIFTA
12776 @cindex bits, shift right
12777 @cindex shift, right with fill
12778
12779 @table @asis
12780 @item @emph{Description}:
12781 @code{SHIFTA} returns a value corresponding to @var{I} with all of the
12782 bits shifted right by @var{SHIFT} places. If the absolute value of
12783 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
12784 Bits shifted out from the right end are lost. The fill is arithmetic: the
12785 bits shifted in from the left end are equal to the leftmost bit, which in
12786 two's complement representation is the sign bit.
12787
12788 @item @emph{Standard}:
12789 Fortran 2008 and later
12790
12791 @item @emph{Class}:
12792 Elemental function
12793
12794 @item @emph{Syntax}:
12795 @code{RESULT = SHIFTA(I, SHIFT)}
12796
12797 @item @emph{Arguments}:
12798 @multitable @columnfractions .15 .70
12799 @item @var{I} @tab The type shall be @code{INTEGER}.
12800 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
12801 @end multitable
12802
12803 @item @emph{Return value}:
12804 The return value is of type @code{INTEGER} and of the same kind as
12805 @var{I}.
12806
12807 @item @emph{See also}:
12808 @ref{SHIFTL}, @ref{SHIFTR}
12809 @end table
12810
12811
12812
12813 @node SHIFTL
12814 @section @code{SHIFTL} --- Left shift
12815 @fnindex SHIFTL
12816 @cindex bits, shift left
12817 @cindex shift, left
12818
12819 @table @asis
12820 @item @emph{Description}:
12821 @code{SHIFTL} returns a value corresponding to @var{I} with all of the
12822 bits shifted left by @var{SHIFT} places. If the absolute value of
12823 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
12824 Bits shifted out from the left end are lost, and bits shifted in from
12825 the right end are set to 0.
12826
12827 @item @emph{Standard}:
12828 Fortran 2008 and later
12829
12830 @item @emph{Class}:
12831 Elemental function
12832
12833 @item @emph{Syntax}:
12834 @code{RESULT = SHIFTL(I, SHIFT)}
12835
12836 @item @emph{Arguments}:
12837 @multitable @columnfractions .15 .70
12838 @item @var{I} @tab The type shall be @code{INTEGER}.
12839 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
12840 @end multitable
12841
12842 @item @emph{Return value}:
12843 The return value is of type @code{INTEGER} and of the same kind as
12844 @var{I}.
12845
12846 @item @emph{See also}:
12847 @ref{SHIFTA}, @ref{SHIFTR}
12848 @end table
12849
12850
12851
12852 @node SHIFTR
12853 @section @code{SHIFTR} --- Right shift
12854 @fnindex SHIFTR
12855 @cindex bits, shift right
12856 @cindex shift, right
12857
12858 @table @asis
12859 @item @emph{Description}:
12860 @code{SHIFTR} returns a value corresponding to @var{I} with all of the
12861 bits shifted right by @var{SHIFT} places. If the absolute value of
12862 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
12863 Bits shifted out from the right end are lost, and bits shifted in from
12864 the left end are set to 0.
12865
12866 @item @emph{Standard}:
12867 Fortran 2008 and later
12868
12869 @item @emph{Class}:
12870 Elemental function
12871
12872 @item @emph{Syntax}:
12873 @code{RESULT = SHIFTR(I, SHIFT)}
12874
12875 @item @emph{Arguments}:
12876 @multitable @columnfractions .15 .70
12877 @item @var{I} @tab The type shall be @code{INTEGER}.
12878 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
12879 @end multitable
12880
12881 @item @emph{Return value}:
12882 The return value is of type @code{INTEGER} and of the same kind as
12883 @var{I}.
12884
12885 @item @emph{See also}:
12886 @ref{SHIFTA}, @ref{SHIFTL}
12887 @end table
12888
12889
12890
12891 @node SIGN
12892 @section @code{SIGN} --- Sign copying function
12893 @fnindex SIGN
12894 @fnindex ISIGN
12895 @fnindex DSIGN
12896 @cindex sign copying
12897
12898 @table @asis
12899 @item @emph{Description}:
12900 @code{SIGN(A,B)} returns the value of @var{A} with the sign of @var{B}.
12901
12902 @item @emph{Standard}:
12903 Fortran 77 and later
12904
12905 @item @emph{Class}:
12906 Elemental function
12907
12908 @item @emph{Syntax}:
12909 @code{RESULT = SIGN(A, B)}
12910
12911 @item @emph{Arguments}:
12912 @multitable @columnfractions .15 .70
12913 @item @var{A} @tab Shall be of type @code{INTEGER} or @code{REAL}
12914 @item @var{B} @tab Shall be of the same type and kind as @var{A}
12915 @end multitable
12916
12917 @item @emph{Return value}:
12918 The kind of the return value is that of @var{A} and @var{B}.
12919 If @math{B\ge 0} then the result is @code{ABS(A)}, else
12920 it is @code{-ABS(A)}.
12921
12922 @item @emph{Example}:
12923 @smallexample
12924 program test_sign
12925 print *, sign(-12,1)
12926 print *, sign(-12,0)
12927 print *, sign(-12,-1)
12928
12929 print *, sign(-12.,1.)
12930 print *, sign(-12.,0.)
12931 print *, sign(-12.,-1.)
12932 end program test_sign
12933 @end smallexample
12934
12935 @item @emph{Specific names}:
12936 @multitable @columnfractions .20 .20 .20 .25
12937 @item Name @tab Arguments @tab Return type @tab Standard
12938 @item @code{SIGN(A,B)} @tab @code{REAL(4) A, B} @tab @code{REAL(4)} @tab f77, gnu
12939 @item @code{ISIGN(A,B)} @tab @code{INTEGER(4) A, B} @tab @code{INTEGER(4)} @tab f77, gnu
12940 @item @code{DSIGN(A,B)} @tab @code{REAL(8) A, B} @tab @code{REAL(8)} @tab f77, gnu
12941 @end multitable
12942 @end table
12943
12944
12945
12946 @node SIGNAL
12947 @section @code{SIGNAL} --- Signal handling subroutine (or function)
12948 @fnindex SIGNAL
12949 @cindex system, signal handling
12950
12951 @table @asis
12952 @item @emph{Description}:
12953 @code{SIGNAL(NUMBER, HANDLER [, STATUS])} causes external subroutine
12954 @var{HANDLER} to be executed with a single integer argument when signal
12955 @var{NUMBER} occurs. If @var{HANDLER} is an integer, it can be used to
12956 turn off handling of signal @var{NUMBER} or revert to its default
12957 action. See @code{signal(2)}.
12958
12959 If @code{SIGNAL} is called as a subroutine and the @var{STATUS} argument
12960 is supplied, it is set to the value returned by @code{signal(2)}.
12961
12962 @item @emph{Standard}:
12963 GNU extension
12964
12965 @item @emph{Class}:
12966 Subroutine, function
12967
12968 @item @emph{Syntax}:
12969 @multitable @columnfractions .80
12970 @item @code{CALL SIGNAL(NUMBER, HANDLER [, STATUS])}
12971 @item @code{STATUS = SIGNAL(NUMBER, HANDLER)}
12972 @end multitable
12973
12974 @item @emph{Arguments}:
12975 @multitable @columnfractions .15 .70
12976 @item @var{NUMBER} @tab Shall be a scalar integer, with @code{INTENT(IN)}
12977 @item @var{HANDLER}@tab Signal handler (@code{INTEGER FUNCTION} or
12978 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar.
12979 @code{INTEGER}. It is @code{INTENT(IN)}.
12980 @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
12981 integer. It has @code{INTENT(OUT)}.
12982 @end multitable
12983 @c TODO: What should the interface of the handler be? Does it take arguments?
12984
12985 @item @emph{Return value}:
12986 The @code{SIGNAL} function returns the value returned by @code{signal(2)}.
12987
12988 @item @emph{Example}:
12989 @smallexample
12990 program test_signal
12991 intrinsic signal
12992 external handler_print
12993
12994 call signal (12, handler_print)
12995 call signal (10, 1)
12996
12997 call sleep (30)
12998 end program test_signal
12999 @end smallexample
13000 @end table
13001
13002
13003
13004 @node SIN
13005 @section @code{SIN} --- Sine function
13006 @fnindex SIN
13007 @fnindex DSIN
13008 @fnindex CSIN
13009 @fnindex ZSIN
13010 @fnindex CDSIN
13011 @cindex trigonometric function, sine
13012 @cindex sine
13013
13014 @table @asis
13015 @item @emph{Description}:
13016 @code{SIN(X)} computes the sine of @var{X}.
13017
13018 @item @emph{Standard}:
13019 Fortran 77 and later
13020
13021 @item @emph{Class}:
13022 Elemental function
13023
13024 @item @emph{Syntax}:
13025 @code{RESULT = SIN(X)}
13026
13027 @item @emph{Arguments}:
13028 @multitable @columnfractions .15 .70
13029 @item @var{X} @tab The type shall be @code{REAL} or
13030 @code{COMPLEX}.
13031 @end multitable
13032
13033 @item @emph{Return value}:
13034 The return value has same type and kind as @var{X}.
13035
13036 @item @emph{Example}:
13037 @smallexample
13038 program test_sin
13039 real :: x = 0.0
13040 x = sin(x)
13041 end program test_sin
13042 @end smallexample
13043
13044 @item @emph{Specific names}:
13045 @multitable @columnfractions .20 .20 .20 .25
13046 @item Name @tab Argument @tab Return type @tab Standard
13047 @item @code{SIN(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab f77, gnu
13048 @item @code{DSIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
13049 @item @code{CSIN(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab f95, gnu
13050 @item @code{ZSIN(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
13051 @item @code{CDSIN(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
13052 @end multitable
13053
13054 @item @emph{See also}:
13055 Inverse function: @ref{ASIN}
13056 Degrees function: @ref{SIND}
13057 @end table
13058
13059
13060
13061 @node SIND
13062 @section @code{SIND} --- Sine function, degrees
13063 @fnindex SIND
13064 @fnindex DSIND
13065 @fnindex CSIND
13066 @fnindex ZSIND
13067 @fnindex CDSIND
13068 @cindex trigonometric function, sine, degrees
13069 @cindex sine, degrees
13070
13071 @table @asis
13072 @item @emph{Description}:
13073 @code{SIND(X)} computes the sine of @var{X} in degrees.
13074
13075 This function is for compatibility only and should be avoided in favor of
13076 standard constructs wherever possible.
13077
13078 @item @emph{Standard}:
13079 GNU Extension, enabled with @option{-fdec-math}.
13080
13081 @item @emph{Class}:
13082 Elemental function
13083
13084 @item @emph{Syntax}:
13085 @code{RESULT = SIND(X)}
13086
13087 @item @emph{Arguments}:
13088 @multitable @columnfractions .15 .70
13089 @item @var{X} @tab The type shall be @code{REAL} or
13090 @code{COMPLEX}.
13091 @end multitable
13092
13093 @item @emph{Return value}:
13094 The return value has same type and kind as @var{X}, and its value is in degrees.
13095
13096 @item @emph{Example}:
13097 @smallexample
13098 program test_sind
13099 real :: x = 0.0
13100 x = sind(x)
13101 end program test_sind
13102 @end smallexample
13103
13104 @item @emph{Specific names}:
13105 @multitable @columnfractions .20 .20 .20 .25
13106 @item Name @tab Argument @tab Return type @tab Standard
13107 @item @code{SIND(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU Extension
13108 @item @code{DSIND(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU Extension
13109 @item @code{CSIND(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab GNU Extension
13110 @item @code{ZSIND(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU Extension
13111 @item @code{CDSIND(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU Extension
13112 @end multitable
13113
13114 @item @emph{See also}:
13115 Inverse function: @ref{ASIND}
13116 Radians function: @ref{SIN}
13117
13118 @end table
13119
13120
13121
13122 @node SINH
13123 @section @code{SINH} --- Hyperbolic sine function
13124 @fnindex SINH
13125 @fnindex DSINH
13126 @cindex hyperbolic sine
13127 @cindex hyperbolic function, sine
13128 @cindex sine, hyperbolic
13129
13130 @table @asis
13131 @item @emph{Description}:
13132 @code{SINH(X)} computes the hyperbolic sine of @var{X}.
13133
13134 @item @emph{Standard}:
13135 Fortran 95 and later, for a complex argument Fortran 2008 or later
13136
13137 @item @emph{Class}:
13138 Elemental function
13139
13140 @item @emph{Syntax}:
13141 @code{RESULT = SINH(X)}
13142
13143 @item @emph{Arguments}:
13144 @multitable @columnfractions .15 .70
13145 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
13146 @end multitable
13147
13148 @item @emph{Return value}:
13149 The return value has same type and kind as @var{X}.
13150
13151 @item @emph{Example}:
13152 @smallexample
13153 program test_sinh
13154 real(8) :: x = - 1.0_8
13155 x = sinh(x)
13156 end program test_sinh
13157 @end smallexample
13158
13159 @item @emph{Specific names}:
13160 @multitable @columnfractions .20 .20 .20 .25
13161 @item Name @tab Argument @tab Return type @tab Standard
13162 @item @code{SINH(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 95 and later
13163 @item @code{DSINH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 95 and later
13164 @end multitable
13165
13166 @item @emph{See also}:
13167 @ref{ASINH}
13168 @end table
13169
13170
13171
13172 @node SIZE
13173 @section @code{SIZE} --- Determine the size of an array
13174 @fnindex SIZE
13175 @cindex array, size
13176 @cindex array, number of elements
13177 @cindex array, count elements
13178
13179 @table @asis
13180 @item @emph{Description}:
13181 Determine the extent of @var{ARRAY} along a specified dimension @var{DIM},
13182 or the total number of elements in @var{ARRAY} if @var{DIM} is absent.
13183
13184 @item @emph{Standard}:
13185 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
13186
13187 @item @emph{Class}:
13188 Inquiry function
13189
13190 @item @emph{Syntax}:
13191 @code{RESULT = SIZE(ARRAY[, DIM [, KIND]])}
13192
13193 @item @emph{Arguments}:
13194 @multitable @columnfractions .15 .70
13195 @item @var{ARRAY} @tab Shall be an array of any type. If @var{ARRAY} is
13196 a pointer it must be associated and allocatable arrays must be allocated.
13197 @item @var{DIM} @tab (Optional) shall be a scalar of type @code{INTEGER}
13198 and its value shall be in the range from 1 to n, where n equals the rank
13199 of @var{ARRAY}.
13200 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
13201 expression indicating the kind parameter of the result.
13202 @end multitable
13203
13204 @item @emph{Return value}:
13205 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
13206 @var{KIND} is absent, the return value is of default integer kind.
13207
13208 @item @emph{Example}:
13209 @smallexample
13210 PROGRAM test_size
13211 WRITE(*,*) SIZE((/ 1, 2 /)) ! 2
13212 END PROGRAM
13213 @end smallexample
13214
13215 @item @emph{See also}:
13216 @ref{SHAPE}, @ref{RESHAPE}
13217 @end table
13218
13219
13220 @node SIZEOF
13221 @section @code{SIZEOF} --- Size in bytes of an expression
13222 @fnindex SIZEOF
13223 @cindex expression size
13224 @cindex size of an expression
13225
13226 @table @asis
13227 @item @emph{Description}:
13228 @code{SIZEOF(X)} calculates the number of bytes of storage the
13229 expression @code{X} occupies.
13230
13231 @item @emph{Standard}:
13232 GNU extension
13233
13234 @item @emph{Class}:
13235 Inquiry function
13236
13237 @item @emph{Syntax}:
13238 @code{N = SIZEOF(X)}
13239
13240 @item @emph{Arguments}:
13241 @multitable @columnfractions .15 .70
13242 @item @var{X} @tab The argument shall be of any type, rank or shape.
13243 @end multitable
13244
13245 @item @emph{Return value}:
13246 The return value is of type integer and of the system-dependent kind
13247 @var{C_SIZE_T} (from the @var{ISO_C_BINDING} module). Its value is the
13248 number of bytes occupied by the argument. If the argument has the
13249 @code{POINTER} attribute, the number of bytes of the storage area pointed
13250 to is returned. If the argument is of a derived type with @code{POINTER}
13251 or @code{ALLOCATABLE} components, the return value does not account for
13252 the sizes of the data pointed to by these components. If the argument is
13253 polymorphic, the size according to the dynamic type is returned. The argument
13254 may not be a procedure or procedure pointer. Note that the code assumes for
13255 arrays that those are contiguous; for contiguous arrays, it returns the
13256 storage or an array element multiplied by the size of the array.
13257
13258 @item @emph{Example}:
13259 @smallexample
13260 integer :: i
13261 real :: r, s(5)
13262 print *, (sizeof(s)/sizeof(r) == 5)
13263 end
13264 @end smallexample
13265 The example will print @code{.TRUE.} unless you are using a platform
13266 where default @code{REAL} variables are unusually padded.
13267
13268 @item @emph{See also}:
13269 @ref{C_SIZEOF}, @ref{STORAGE_SIZE}
13270 @end table
13271
13272
13273 @node SLEEP
13274 @section @code{SLEEP} --- Sleep for the specified number of seconds
13275 @fnindex SLEEP
13276 @cindex delayed execution
13277
13278 @table @asis
13279 @item @emph{Description}:
13280 Calling this subroutine causes the process to pause for @var{SECONDS} seconds.
13281
13282 @item @emph{Standard}:
13283 GNU extension
13284
13285 @item @emph{Class}:
13286 Subroutine
13287
13288 @item @emph{Syntax}:
13289 @code{CALL SLEEP(SECONDS)}
13290
13291 @item @emph{Arguments}:
13292 @multitable @columnfractions .15 .70
13293 @item @var{SECONDS} @tab The type shall be of default @code{INTEGER}.
13294 @end multitable
13295
13296 @item @emph{Example}:
13297 @smallexample
13298 program test_sleep
13299 call sleep(5)
13300 end
13301 @end smallexample
13302 @end table
13303
13304
13305
13306 @node SPACING
13307 @section @code{SPACING} --- Smallest distance between two numbers of a given type
13308 @fnindex SPACING
13309 @cindex real number, relative spacing
13310 @cindex floating point, relative spacing
13311
13312 @table @asis
13313 @item @emph{Description}:
13314 Determines the distance between the argument @var{X} and the nearest
13315 adjacent number of the same type.
13316
13317 @item @emph{Standard}:
13318 Fortran 95 and later
13319
13320 @item @emph{Class}:
13321 Elemental function
13322
13323 @item @emph{Syntax}:
13324 @code{RESULT = SPACING(X)}
13325
13326 @item @emph{Arguments}:
13327 @multitable @columnfractions .15 .70
13328 @item @var{X} @tab Shall be of type @code{REAL}.
13329 @end multitable
13330
13331 @item @emph{Return value}:
13332 The result is of the same type as the input argument @var{X}.
13333
13334 @item @emph{Example}:
13335 @smallexample
13336 PROGRAM test_spacing
13337 INTEGER, PARAMETER :: SGL = SELECTED_REAL_KIND(p=6, r=37)
13338 INTEGER, PARAMETER :: DBL = SELECTED_REAL_KIND(p=13, r=200)
13339
13340 WRITE(*,*) spacing(1.0_SGL) ! "1.1920929E-07" on i686
13341 WRITE(*,*) spacing(1.0_DBL) ! "2.220446049250313E-016" on i686
13342 END PROGRAM
13343 @end smallexample
13344
13345 @item @emph{See also}:
13346 @ref{RRSPACING}
13347 @end table
13348
13349
13350
13351 @node SPREAD
13352 @section @code{SPREAD} --- Add a dimension to an array
13353 @fnindex SPREAD
13354 @cindex array, increase dimension
13355 @cindex array, duplicate elements
13356 @cindex array, duplicate dimensions
13357
13358 @table @asis
13359 @item @emph{Description}:
13360 Replicates a @var{SOURCE} array @var{NCOPIES} times along a specified
13361 dimension @var{DIM}.
13362
13363 @item @emph{Standard}:
13364 Fortran 95 and later
13365
13366 @item @emph{Class}:
13367 Transformational function
13368
13369 @item @emph{Syntax}:
13370 @code{RESULT = SPREAD(SOURCE, DIM, NCOPIES)}
13371
13372 @item @emph{Arguments}:
13373 @multitable @columnfractions .15 .70
13374 @item @var{SOURCE} @tab Shall be a scalar or an array of any type and
13375 a rank less than seven.
13376 @item @var{DIM} @tab Shall be a scalar of type @code{INTEGER} with a
13377 value in the range from 1 to n+1, where n equals the rank of @var{SOURCE}.
13378 @item @var{NCOPIES} @tab Shall be a scalar of type @code{INTEGER}.
13379 @end multitable
13380
13381 @item @emph{Return value}:
13382 The result is an array of the same type as @var{SOURCE} and has rank n+1
13383 where n equals the rank of @var{SOURCE}.
13384
13385 @item @emph{Example}:
13386 @smallexample
13387 PROGRAM test_spread
13388 INTEGER :: a = 1, b(2) = (/ 1, 2 /)
13389 WRITE(*,*) SPREAD(A, 1, 2) ! "1 1"
13390 WRITE(*,*) SPREAD(B, 1, 2) ! "1 1 2 2"
13391 END PROGRAM
13392 @end smallexample
13393
13394 @item @emph{See also}:
13395 @ref{UNPACK}
13396 @end table
13397
13398
13399
13400 @node SQRT
13401 @section @code{SQRT} --- Square-root function
13402 @fnindex SQRT
13403 @fnindex DSQRT
13404 @fnindex CSQRT
13405 @fnindex ZSQRT
13406 @fnindex CDSQRT
13407 @cindex root
13408 @cindex square-root
13409
13410 @table @asis
13411 @item @emph{Description}:
13412 @code{SQRT(X)} computes the square root of @var{X}.
13413
13414 @item @emph{Standard}:
13415 Fortran 77 and later
13416
13417 @item @emph{Class}:
13418 Elemental function
13419
13420 @item @emph{Syntax}:
13421 @code{RESULT = SQRT(X)}
13422
13423 @item @emph{Arguments}:
13424 @multitable @columnfractions .15 .70
13425 @item @var{X} @tab The type shall be @code{REAL} or
13426 @code{COMPLEX}.
13427 @end multitable
13428
13429 @item @emph{Return value}:
13430 The return value is of type @code{REAL} or @code{COMPLEX}.
13431 The kind type parameter is the same as @var{X}.
13432
13433 @item @emph{Example}:
13434 @smallexample
13435 program test_sqrt
13436 real(8) :: x = 2.0_8
13437 complex :: z = (1.0, 2.0)
13438 x = sqrt(x)
13439 z = sqrt(z)
13440 end program test_sqrt
13441 @end smallexample
13442
13443 @item @emph{Specific names}:
13444 @multitable @columnfractions .20 .20 .20 .25
13445 @item Name @tab Argument @tab Return type @tab Standard
13446 @item @code{SQRT(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 95 and later
13447 @item @code{DSQRT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 95 and later
13448 @item @code{CSQRT(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab Fortran 95 and later
13449 @item @code{ZSQRT(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
13450 @item @code{CDSQRT(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
13451 @end multitable
13452 @end table
13453
13454
13455
13456 @node SRAND
13457 @section @code{SRAND} --- Reinitialize the random number generator
13458 @fnindex SRAND
13459 @cindex random number generation, seeding
13460 @cindex seeding a random number generator
13461
13462 @table @asis
13463 @item @emph{Description}:
13464 @code{SRAND} reinitializes the pseudo-random number generator
13465 called by @code{RAND} and @code{IRAND}. The new seed used by the
13466 generator is specified by the required argument @var{SEED}.
13467
13468 @item @emph{Standard}:
13469 GNU extension
13470
13471 @item @emph{Class}:
13472 Subroutine
13473
13474 @item @emph{Syntax}:
13475 @code{CALL SRAND(SEED)}
13476
13477 @item @emph{Arguments}:
13478 @multitable @columnfractions .15 .70
13479 @item @var{SEED} @tab Shall be a scalar @code{INTEGER(kind=4)}.
13480 @end multitable
13481
13482 @item @emph{Return value}:
13483 Does not return anything.
13484
13485 @item @emph{Example}:
13486 See @code{RAND} and @code{IRAND} for examples.
13487
13488 @item @emph{Notes}:
13489 The Fortran standard specifies the intrinsic subroutines
13490 @code{RANDOM_SEED} to initialize the pseudo-random number
13491 generator and @code{RANDOM_NUMBER} to generate pseudo-random numbers.
13492 These subroutines should be used in new codes.
13493
13494 Please note that in GNU Fortran, these two sets of intrinsics (@code{RAND},
13495 @code{IRAND} and @code{SRAND} on the one hand, @code{RANDOM_NUMBER} and
13496 @code{RANDOM_SEED} on the other hand) access two independent
13497 pseudo-random number generators.
13498
13499 @item @emph{See also}:
13500 @ref{RAND}, @ref{RANDOM_SEED}, @ref{RANDOM_NUMBER}
13501
13502 @end table
13503
13504
13505
13506 @node STAT
13507 @section @code{STAT} --- Get file status
13508 @fnindex STAT
13509 @cindex file system, file status
13510
13511 @table @asis
13512 @item @emph{Description}:
13513 This function returns information about a file. No permissions are required on
13514 the file itself, but execute (search) permission is required on all of the
13515 directories in path that lead to the file.
13516
13517 The elements that are obtained and stored in the array @code{VALUES}:
13518 @multitable @columnfractions .15 .70
13519 @item @code{VALUES(1)} @tab Device ID
13520 @item @code{VALUES(2)} @tab Inode number
13521 @item @code{VALUES(3)} @tab File mode
13522 @item @code{VALUES(4)} @tab Number of links
13523 @item @code{VALUES(5)} @tab Owner's uid
13524 @item @code{VALUES(6)} @tab Owner's gid
13525 @item @code{VALUES(7)} @tab ID of device containing directory entry for file (0 if not available)
13526 @item @code{VALUES(8)} @tab File size (bytes)
13527 @item @code{VALUES(9)} @tab Last access time
13528 @item @code{VALUES(10)} @tab Last modification time
13529 @item @code{VALUES(11)} @tab Last file status change time
13530 @item @code{VALUES(12)} @tab Preferred I/O block size (-1 if not available)
13531 @item @code{VALUES(13)} @tab Number of blocks allocated (-1 if not available)
13532 @end multitable
13533
13534 Not all these elements are relevant on all systems.
13535 If an element is not relevant, it is returned as 0.
13536
13537 This intrinsic is provided in both subroutine and function forms; however,
13538 only one form can be used in any given program unit.
13539
13540 @item @emph{Standard}:
13541 GNU extension
13542
13543 @item @emph{Class}:
13544 Subroutine, function
13545
13546 @item @emph{Syntax}:
13547 @multitable @columnfractions .80
13548 @item @code{CALL STAT(NAME, VALUES [, STATUS])}
13549 @item @code{STATUS = STAT(NAME, VALUES)}
13550 @end multitable
13551
13552 @item @emph{Arguments}:
13553 @multitable @columnfractions .15 .70
13554 @item @var{NAME} @tab The type shall be @code{CHARACTER}, of the
13555 default kind and a valid path within the file system.
13556 @item @var{VALUES} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
13557 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0
13558 on success and a system specific error code otherwise.
13559 @end multitable
13560
13561 @item @emph{Example}:
13562 @smallexample
13563 PROGRAM test_stat
13564 INTEGER, DIMENSION(13) :: buff
13565 INTEGER :: status
13566
13567 CALL STAT("/etc/passwd", buff, status)
13568
13569 IF (status == 0) THEN
13570 WRITE (*, FMT="('Device ID:', T30, I19)") buff(1)
13571 WRITE (*, FMT="('Inode number:', T30, I19)") buff(2)
13572 WRITE (*, FMT="('File mode (octal):', T30, O19)") buff(3)
13573 WRITE (*, FMT="('Number of links:', T30, I19)") buff(4)
13574 WRITE (*, FMT="('Owner''s uid:', T30, I19)") buff(5)
13575 WRITE (*, FMT="('Owner''s gid:', T30, I19)") buff(6)
13576 WRITE (*, FMT="('Device where located:', T30, I19)") buff(7)
13577 WRITE (*, FMT="('File size:', T30, I19)") buff(8)
13578 WRITE (*, FMT="('Last access time:', T30, A19)") CTIME(buff(9))
13579 WRITE (*, FMT="('Last modification time', T30, A19)") CTIME(buff(10))
13580 WRITE (*, FMT="('Last status change time:', T30, A19)") CTIME(buff(11))
13581 WRITE (*, FMT="('Preferred block size:', T30, I19)") buff(12)
13582 WRITE (*, FMT="('No. of blocks allocated:', T30, I19)") buff(13)
13583 END IF
13584 END PROGRAM
13585 @end smallexample
13586
13587 @item @emph{See also}:
13588 To stat an open file: @ref{FSTAT}, to stat a link: @ref{LSTAT}
13589 @end table
13590
13591
13592
13593 @node STORAGE_SIZE
13594 @section @code{STORAGE_SIZE} --- Storage size in bits
13595 @fnindex STORAGE_SIZE
13596 @cindex storage size
13597
13598 @table @asis
13599 @item @emph{Description}:
13600 Returns the storage size of argument @var{A} in bits.
13601 @item @emph{Standard}:
13602 Fortran 2008 and later
13603 @item @emph{Class}:
13604 Inquiry function
13605 @item @emph{Syntax}:
13606 @code{RESULT = STORAGE_SIZE(A [, KIND])}
13607
13608 @item @emph{Arguments}:
13609 @multitable @columnfractions .15 .70
13610 @item @var{A} @tab Shall be a scalar or array of any type.
13611 @item @var{KIND} @tab (Optional) shall be a scalar integer constant expression.
13612 @end multitable
13613
13614 @item @emph{Return Value}:
13615 The result is a scalar integer with the kind type parameter specified by KIND
13616 (or default integer type if KIND is missing). The result value is the size
13617 expressed in bits for an element of an array that has the dynamic type and type
13618 parameters of A.
13619
13620 @item @emph{See also}:
13621 @ref{C_SIZEOF}, @ref{SIZEOF}
13622 @end table
13623
13624
13625
13626 @node SUM
13627 @section @code{SUM} --- Sum of array elements
13628 @fnindex SUM
13629 @cindex array, sum
13630 @cindex array, add elements
13631 @cindex array, conditionally add elements
13632 @cindex sum array elements
13633
13634 @table @asis
13635 @item @emph{Description}:
13636 Adds the elements of @var{ARRAY} along dimension @var{DIM} if
13637 the corresponding element in @var{MASK} is @code{TRUE}.
13638
13639 @item @emph{Standard}:
13640 Fortran 95 and later
13641
13642 @item @emph{Class}:
13643 Transformational function
13644
13645 @item @emph{Syntax}:
13646 @multitable @columnfractions .80
13647 @item @code{RESULT = SUM(ARRAY[, MASK])}
13648 @item @code{RESULT = SUM(ARRAY, DIM[, MASK])}
13649 @end multitable
13650
13651 @item @emph{Arguments}:
13652 @multitable @columnfractions .15 .70
13653 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER},
13654 @code{REAL} or @code{COMPLEX}.
13655 @item @var{DIM} @tab (Optional) shall be a scalar of type
13656 @code{INTEGER} with a value in the range from 1 to n, where n
13657 equals the rank of @var{ARRAY}.
13658 @item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL}
13659 and either be a scalar or an array of the same shape as @var{ARRAY}.
13660 @end multitable
13661
13662 @item @emph{Return value}:
13663 The result is of the same type as @var{ARRAY}.
13664
13665 If @var{DIM} is absent, a scalar with the sum of all elements in @var{ARRAY}
13666 is returned. Otherwise, an array of rank n-1, where n equals the rank of
13667 @var{ARRAY}, and a shape similar to that of @var{ARRAY} with dimension @var{DIM}
13668 dropped is returned.
13669
13670 @item @emph{Example}:
13671 @smallexample
13672 PROGRAM test_sum
13673 INTEGER :: x(5) = (/ 1, 2, 3, 4 ,5 /)
13674 print *, SUM(x) ! all elements, sum = 15
13675 print *, SUM(x, MASK=MOD(x, 2)==1) ! odd elements, sum = 9
13676 END PROGRAM
13677 @end smallexample
13678
13679 @item @emph{See also}:
13680 @ref{PRODUCT}
13681 @end table
13682
13683
13684
13685 @node SYMLNK
13686 @section @code{SYMLNK} --- Create a symbolic link
13687 @fnindex SYMLNK
13688 @cindex file system, create link
13689 @cindex file system, soft link
13690
13691 @table @asis
13692 @item @emph{Description}:
13693 Makes a symbolic link from file @var{PATH1} to @var{PATH2}. A null
13694 character (@code{CHAR(0)}) can be used to mark the end of the names in
13695 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
13696 names are ignored. If the @var{STATUS} argument is supplied, it
13697 contains 0 on success or a nonzero error code upon return; see
13698 @code{symlink(2)}. If the system does not supply @code{symlink(2)},
13699 @code{ENOSYS} is returned.
13700
13701 This intrinsic is provided in both subroutine and function forms;
13702 however, only one form can be used in any given program unit.
13703
13704 @item @emph{Standard}:
13705 GNU extension
13706
13707 @item @emph{Class}:
13708 Subroutine, function
13709
13710 @item @emph{Syntax}:
13711 @multitable @columnfractions .80
13712 @item @code{CALL SYMLNK(PATH1, PATH2 [, STATUS])}
13713 @item @code{STATUS = SYMLNK(PATH1, PATH2)}
13714 @end multitable
13715
13716 @item @emph{Arguments}:
13717 @multitable @columnfractions .15 .70
13718 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
13719 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
13720 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
13721 @end multitable
13722
13723 @item @emph{See also}:
13724 @ref{LINK}, @ref{UNLINK}
13725
13726 @end table
13727
13728
13729
13730 @node SYSTEM
13731 @section @code{SYSTEM} --- Execute a shell command
13732 @fnindex SYSTEM
13733 @cindex system, system call
13734
13735 @table @asis
13736 @item @emph{Description}:
13737 Passes the command @var{COMMAND} to a shell (see @code{system(3)}). If
13738 argument @var{STATUS} is present, it contains the value returned by
13739 @code{system(3)}, which is presumably 0 if the shell command succeeded.
13740 Note that which shell is used to invoke the command is system-dependent
13741 and environment-dependent.
13742
13743 This intrinsic is provided in both subroutine and function forms;
13744 however, only one form can be used in any given program unit.
13745
13746 Note that the @code{system} function need not be thread-safe. It is
13747 the responsibility of the user to ensure that @code{system} is not
13748 called concurrently.
13749
13750 @item @emph{Standard}:
13751 GNU extension
13752
13753 @item @emph{Class}:
13754 Subroutine, function
13755
13756 @item @emph{Syntax}:
13757 @multitable @columnfractions .80
13758 @item @code{CALL SYSTEM(COMMAND [, STATUS])}
13759 @item @code{STATUS = SYSTEM(COMMAND)}
13760 @end multitable
13761
13762 @item @emph{Arguments}:
13763 @multitable @columnfractions .15 .70
13764 @item @var{COMMAND} @tab Shall be of default @code{CHARACTER} type.
13765 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
13766 @end multitable
13767
13768 @item @emph{See also}:
13769 @ref{EXECUTE_COMMAND_LINE}, which is part of the Fortran 2008 standard
13770 and should considered in new code for future portability.
13771 @end table
13772
13773
13774
13775 @node SYSTEM_CLOCK
13776 @section @code{SYSTEM_CLOCK} --- Time function
13777 @fnindex SYSTEM_CLOCK
13778 @cindex time, clock ticks
13779 @cindex clock ticks
13780
13781 @table @asis
13782 @item @emph{Description}:
13783 Determines the @var{COUNT} of a processor clock since an unspecified
13784 time in the past modulo @var{COUNT_MAX}, @var{COUNT_RATE} determines
13785 the number of clock ticks per second. If the platform supports a
13786 monotonic clock, that clock is used and can, depending on the platform
13787 clock implementation, provide up to nanosecond resolution. If a
13788 monotonic clock is not available, the implementation falls back to a
13789 realtime clock.
13790
13791 @var{COUNT_RATE} is system dependent and can vary depending on the kind of
13792 the arguments. For @var{kind=4} arguments (and smaller integer kinds),
13793 @var{COUNT} represents milliseconds, while for @var{kind=8} arguments (and
13794 larger integer kinds), @var{COUNT} typically represents micro- or
13795 nanoseconds depending on resolution of the underlying platform clock.
13796 @var{COUNT_MAX} usually equals @code{HUGE(COUNT_MAX)}. Note that the
13797 millisecond resolution of the @var{kind=4} version implies that the
13798 @var{COUNT} will wrap around in roughly 25 days. In order to avoid issues
13799 with the wrap around and for more precise timing, please use the
13800 @var{kind=8} version.
13801
13802 If there is no clock, or querying the clock fails, @var{COUNT} is set
13803 to @code{-HUGE(COUNT)}, and @var{COUNT_RATE} and @var{COUNT_MAX} are
13804 set to zero.
13805
13806 When running on a platform using the GNU C library (glibc) version
13807 2.16 or older, or a derivative thereof, the high resolution monotonic
13808 clock is available only when linking with the @var{rt} library. This
13809 can be done explicitly by adding the @code{-lrt} flag when linking the
13810 application, but is also done implicitly when using OpenMP.
13811
13812 On the Windows platform, the version with @var{kind=4} arguments uses
13813 the @code{GetTickCount} function, whereas the @var{kind=8} version
13814 uses @code{QueryPerformanceCounter} and
13815 @code{QueryPerformanceCounterFrequency}. For more information, and
13816 potential caveats, please see the platform documentation.
13817
13818 @item @emph{Standard}:
13819 Fortran 95 and later
13820
13821 @item @emph{Class}:
13822 Subroutine
13823
13824 @item @emph{Syntax}:
13825 @code{CALL SYSTEM_CLOCK([COUNT, COUNT_RATE, COUNT_MAX])}
13826
13827 @item @emph{Arguments}:
13828 @multitable @columnfractions .15 .70
13829 @item @var{COUNT} @tab (Optional) shall be a scalar of type
13830 @code{INTEGER} with @code{INTENT(OUT)}.
13831 @item @var{COUNT_RATE} @tab (Optional) shall be a scalar of type
13832 @code{INTEGER} or @code{REAL}, with @code{INTENT(OUT)}.
13833 @item @var{COUNT_MAX} @tab (Optional) shall be a scalar of type
13834 @code{INTEGER} with @code{INTENT(OUT)}.
13835 @end multitable
13836
13837 @item @emph{Example}:
13838 @smallexample
13839 PROGRAM test_system_clock
13840 INTEGER :: count, count_rate, count_max
13841 CALL SYSTEM_CLOCK(count, count_rate, count_max)
13842 WRITE(*,*) count, count_rate, count_max
13843 END PROGRAM
13844 @end smallexample
13845
13846 @item @emph{See also}:
13847 @ref{DATE_AND_TIME}, @ref{CPU_TIME}
13848 @end table
13849
13850
13851
13852 @node TAN
13853 @section @code{TAN} --- Tangent function
13854 @fnindex TAN
13855 @fnindex DTAN
13856 @cindex trigonometric function, tangent
13857 @cindex tangent
13858
13859 @table @asis
13860 @item @emph{Description}:
13861 @code{TAN(X)} computes the tangent of @var{X}.
13862
13863 @item @emph{Standard}:
13864 Fortran 77 and later, for a complex argument Fortran 2008 or later
13865
13866 @item @emph{Class}:
13867 Elemental function
13868
13869 @item @emph{Syntax}:
13870 @code{RESULT = TAN(X)}
13871
13872 @item @emph{Arguments}:
13873 @multitable @columnfractions .15 .70
13874 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
13875 @end multitable
13876
13877 @item @emph{Return value}:
13878 The return value has same type and kind as @var{X}, and its value is in radians.
13879
13880 @item @emph{Example}:
13881 @smallexample
13882 program test_tan
13883 real(8) :: x = 0.165_8
13884 x = tan(x)
13885 end program test_tan
13886 @end smallexample
13887
13888 @item @emph{Specific names}:
13889 @multitable @columnfractions .20 .20 .20 .25
13890 @item Name @tab Argument @tab Return type @tab Standard
13891 @item @code{TAN(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 95 and later
13892 @item @code{DTAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 95 and later
13893 @end multitable
13894
13895 @item @emph{See also}:
13896 Inverse function: @ref{ATAN}
13897 Degrees function: @ref{TAND}
13898 @end table
13899
13900
13901
13902 @node TAND
13903 @section @code{TAND} --- Tangent function, degrees
13904 @fnindex TAND
13905 @fnindex DTAND
13906 @cindex trigonometric function, tangent, degrees
13907 @cindex tangent, degrees
13908
13909 @table @asis
13910 @item @emph{Description}:
13911 @code{TAND(X)} computes the tangent of @var{X} in degrees.
13912
13913 This function is for compatibility only and should be avoided in favor of
13914 standard constructs wherever possible.
13915
13916 @item @emph{Standard}:
13917 GNU Extension, enabled with @option{-fdec-math}.
13918
13919 @item @emph{Class}:
13920 Elemental function
13921
13922 @item @emph{Syntax}:
13923 @code{RESULT = TAND(X)}
13924
13925 @item @emph{Arguments}:
13926 @multitable @columnfractions .15 .70
13927 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
13928 @end multitable
13929
13930 @item @emph{Return value}:
13931 The return value has same type and kind as @var{X}, and its value is in degrees.
13932
13933 @item @emph{Example}:
13934 @smallexample
13935 program test_tand
13936 real(8) :: x = 0.165_8
13937 x = tand(x)
13938 end program test_tand
13939 @end smallexample
13940
13941 @item @emph{Specific names}:
13942 @multitable @columnfractions .20 .20 .20 .25
13943 @item Name @tab Argument @tab Return type @tab Standard
13944 @item @code{TAND(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU Extension
13945 @item @code{DTAND(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU Extension
13946 @end multitable
13947
13948 @item @emph{See also}:
13949 Inverse function: @ref{ATAND}
13950 Radians function: @ref{TAN}
13951 @end table
13952
13953
13954
13955 @node TANH
13956 @section @code{TANH} --- Hyperbolic tangent function
13957 @fnindex TANH
13958 @fnindex DTANH
13959 @cindex hyperbolic tangent
13960 @cindex hyperbolic function, tangent
13961 @cindex tangent, hyperbolic
13962
13963 @table @asis
13964 @item @emph{Description}:
13965 @code{TANH(X)} computes the hyperbolic tangent of @var{X}.
13966
13967 @item @emph{Standard}:
13968 Fortran 77 and later, for a complex argument Fortran 2008 or later
13969
13970 @item @emph{Class}:
13971 Elemental function
13972
13973 @item @emph{Syntax}:
13974 @code{X = TANH(X)}
13975
13976 @item @emph{Arguments}:
13977 @multitable @columnfractions .15 .70
13978 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
13979 @end multitable
13980
13981 @item @emph{Return value}:
13982 The return value has same type and kind as @var{X}. If @var{X} is
13983 complex, the imaginary part of the result is in radians. If @var{X}
13984 is @code{REAL}, the return value lies in the range
13985 @math{ - 1 \leq tanh(x) \leq 1 }.
13986
13987 @item @emph{Example}:
13988 @smallexample
13989 program test_tanh
13990 real(8) :: x = 2.1_8
13991 x = tanh(x)
13992 end program test_tanh
13993 @end smallexample
13994
13995 @item @emph{Specific names}:
13996 @multitable @columnfractions .20 .20 .20 .25
13997 @item Name @tab Argument @tab Return type @tab Standard
13998 @item @code{TANH(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 95 and later
13999 @item @code{DTANH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 95 and later
14000 @end multitable
14001
14002 @item @emph{See also}:
14003 @ref{ATANH}
14004 @end table
14005
14006
14007
14008 @node THIS_IMAGE
14009 @section @code{THIS_IMAGE} --- Function that returns the cosubscript index of this image
14010 @fnindex THIS_IMAGE
14011 @cindex coarray, @code{THIS_IMAGE}
14012 @cindex images, index of this image
14013
14014 @table @asis
14015 @item @emph{Description}:
14016 Returns the cosubscript for this image.
14017
14018 @item @emph{Standard}:
14019 Fortran 2008 and later. With @var{DISTANCE} argument,
14020 Technical Specification (TS) 18508 or later
14021
14022 @item @emph{Class}:
14023 Transformational function
14024
14025 @item @emph{Syntax}:
14026 @multitable @columnfractions .80
14027 @item @code{RESULT = THIS_IMAGE()}
14028 @item @code{RESULT = THIS_IMAGE(DISTANCE)}
14029 @item @code{RESULT = THIS_IMAGE(COARRAY [, DIM])}
14030 @end multitable
14031
14032 @item @emph{Arguments}:
14033 @multitable @columnfractions .15 .70
14034 @item @var{DISTANCE} @tab (optional, intent(in)) Nonnegative scalar integer
14035 (not permitted together with @var{COARRAY}).
14036 @item @var{COARRAY} @tab Coarray of any type (optional; if @var{DIM}
14037 present, required).
14038 @item @var{DIM} @tab default integer scalar (optional). If present,
14039 @var{DIM} shall be between one and the corank of @var{COARRAY}.
14040 @end multitable
14041
14042
14043 @item @emph{Return value}:
14044 Default integer. If @var{COARRAY} is not present, it is scalar; if
14045 @var{DISTANCE} is not present or has value 0, its value is the image index on
14046 the invoking image for the current team, for values smaller or equal
14047 distance to the initial team, it returns the image index on the ancestor team
14048 which has a distance of @var{DISTANCE} from the invoking team. If
14049 @var{DISTANCE} is larger than the distance to the initial team, the image
14050 index of the initial team is returned. Otherwise when the @var{COARRAY} is
14051 present, if @var{DIM} is not present, a rank-1 array with corank elements is
14052 returned, containing the cosubscripts for @var{COARRAY} specifying the invoking
14053 image. If @var{DIM} is present, a scalar is returned, with the value of
14054 the @var{DIM} element of @code{THIS_IMAGE(COARRAY)}.
14055
14056 @item @emph{Example}:
14057 @smallexample
14058 INTEGER :: value[*]
14059 INTEGER :: i
14060 value = THIS_IMAGE()
14061 SYNC ALL
14062 IF (THIS_IMAGE() == 1) THEN
14063 DO i = 1, NUM_IMAGES()
14064 WRITE(*,'(2(a,i0))') 'value[', i, '] is ', value[i]
14065 END DO
14066 END IF
14067
14068 ! Check whether the current image is the initial image
14069 IF (THIS_IMAGE(HUGE(1)) /= THIS_IMAGE())
14070 error stop "something is rotten here"
14071 @end smallexample
14072
14073 @item @emph{See also}:
14074 @ref{NUM_IMAGES}, @ref{IMAGE_INDEX}
14075 @end table
14076
14077
14078
14079 @node TIME
14080 @section @code{TIME} --- Time function
14081 @fnindex TIME
14082 @cindex time, current
14083 @cindex current time
14084
14085 @table @asis
14086 @item @emph{Description}:
14087 Returns the current time encoded as an integer (in the manner of the
14088 function @code{time(3)} in the C standard library). This value is
14089 suitable for passing to @ref{CTIME}, @ref{GMTIME}, and @ref{LTIME}.
14090
14091 This intrinsic is not fully portable, such as to systems with 32-bit
14092 @code{INTEGER} types but supporting times wider than 32 bits. Therefore,
14093 the values returned by this intrinsic might be, or become, negative, or
14094 numerically less than previous values, during a single run of the
14095 compiled program.
14096
14097 See @ref{TIME8}, for information on a similar intrinsic that might be
14098 portable to more GNU Fortran implementations, though to fewer Fortran
14099 compilers.
14100
14101 @item @emph{Standard}:
14102 GNU extension
14103
14104 @item @emph{Class}:
14105 Function
14106
14107 @item @emph{Syntax}:
14108 @code{RESULT = TIME()}
14109
14110 @item @emph{Return value}:
14111 The return value is a scalar of type @code{INTEGER(4)}.
14112
14113 @item @emph{See also}:
14114 @ref{DATE_AND_TIME}, @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME8}
14115
14116 @end table
14117
14118
14119
14120 @node TIME8
14121 @section @code{TIME8} --- Time function (64-bit)
14122 @fnindex TIME8
14123 @cindex time, current
14124 @cindex current time
14125
14126 @table @asis
14127 @item @emph{Description}:
14128 Returns the current time encoded as an integer (in the manner of the
14129 function @code{time(3)} in the C standard library). This value is
14130 suitable for passing to @ref{CTIME}, @ref{GMTIME}, and @ref{LTIME}.
14131
14132 @emph{Warning:} this intrinsic does not increase the range of the timing
14133 values over that returned by @code{time(3)}. On a system with a 32-bit
14134 @code{time(3)}, @code{TIME8} will return a 32-bit value, even though
14135 it is converted to a 64-bit @code{INTEGER(8)} value. That means
14136 overflows of the 32-bit value can still occur. Therefore, the values
14137 returned by this intrinsic might be or become negative or numerically
14138 less than previous values during a single run of the compiled program.
14139
14140 @item @emph{Standard}:
14141 GNU extension
14142
14143 @item @emph{Class}:
14144 Function
14145
14146 @item @emph{Syntax}:
14147 @code{RESULT = TIME8()}
14148
14149 @item @emph{Return value}:
14150 The return value is a scalar of type @code{INTEGER(8)}.
14151
14152 @item @emph{See also}:
14153 @ref{DATE_AND_TIME}, @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK8}, @ref{TIME}
14154
14155 @end table
14156
14157
14158
14159 @node TINY
14160 @section @code{TINY} --- Smallest positive number of a real kind
14161 @fnindex TINY
14162 @cindex limits, smallest number
14163 @cindex model representation, smallest number
14164
14165 @table @asis
14166 @item @emph{Description}:
14167 @code{TINY(X)} returns the smallest positive (non zero) number
14168 in the model of the type of @code{X}.
14169
14170 @item @emph{Standard}:
14171 Fortran 95 and later
14172
14173 @item @emph{Class}:
14174 Inquiry function
14175
14176 @item @emph{Syntax}:
14177 @code{RESULT = TINY(X)}
14178
14179 @item @emph{Arguments}:
14180 @multitable @columnfractions .15 .70
14181 @item @var{X} @tab Shall be of type @code{REAL}.
14182 @end multitable
14183
14184 @item @emph{Return value}:
14185 The return value is of the same type and kind as @var{X}
14186
14187 @item @emph{Example}:
14188 See @code{HUGE} for an example.
14189 @end table
14190
14191
14192
14193 @node TRAILZ
14194 @section @code{TRAILZ} --- Number of trailing zero bits of an integer
14195 @fnindex TRAILZ
14196 @cindex zero bits
14197
14198 @table @asis
14199 @item @emph{Description}:
14200 @code{TRAILZ} returns the number of trailing zero bits of an integer.
14201
14202 @item @emph{Standard}:
14203 Fortran 2008 and later
14204
14205 @item @emph{Class}:
14206 Elemental function
14207
14208 @item @emph{Syntax}:
14209 @code{RESULT = TRAILZ(I)}
14210
14211 @item @emph{Arguments}:
14212 @multitable @columnfractions .15 .70
14213 @item @var{I} @tab Shall be of type @code{INTEGER}.
14214 @end multitable
14215
14216 @item @emph{Return value}:
14217 The type of the return value is the default @code{INTEGER}.
14218 If all the bits of @code{I} are zero, the result value is @code{BIT_SIZE(I)}.
14219
14220 @item @emph{Example}:
14221 @smallexample
14222 PROGRAM test_trailz
14223 WRITE (*,*) TRAILZ(8) ! prints 3
14224 END PROGRAM
14225 @end smallexample
14226
14227 @item @emph{See also}:
14228 @ref{BIT_SIZE}, @ref{LEADZ}, @ref{POPPAR}, @ref{POPCNT}
14229 @end table
14230
14231
14232
14233 @node TRANSFER
14234 @section @code{TRANSFER} --- Transfer bit patterns
14235 @fnindex TRANSFER
14236 @cindex bits, move
14237 @cindex type cast
14238
14239 @table @asis
14240 @item @emph{Description}:
14241 Interprets the bitwise representation of @var{SOURCE} in memory as if it
14242 is the representation of a variable or array of the same type and type
14243 parameters as @var{MOLD}.
14244
14245 This is approximately equivalent to the C concept of @emph{casting} one
14246 type to another.
14247
14248 @item @emph{Standard}:
14249 Fortran 95 and later
14250
14251 @item @emph{Class}:
14252 Transformational function
14253
14254 @item @emph{Syntax}:
14255 @code{RESULT = TRANSFER(SOURCE, MOLD[, SIZE])}
14256
14257 @item @emph{Arguments}:
14258 @multitable @columnfractions .15 .70
14259 @item @var{SOURCE} @tab Shall be a scalar or an array of any type.
14260 @item @var{MOLD} @tab Shall be a scalar or an array of any type.
14261 @item @var{SIZE} @tab (Optional) shall be a scalar of type
14262 @code{INTEGER}.
14263 @end multitable
14264
14265 @item @emph{Return value}:
14266 The result has the same type as @var{MOLD}, with the bit level
14267 representation of @var{SOURCE}. If @var{SIZE} is present, the result is
14268 a one-dimensional array of length @var{SIZE}. If @var{SIZE} is absent
14269 but @var{MOLD} is an array (of any size or shape), the result is a one-
14270 dimensional array of the minimum length needed to contain the entirety
14271 of the bitwise representation of @var{SOURCE}. If @var{SIZE} is absent
14272 and @var{MOLD} is a scalar, the result is a scalar.
14273
14274 If the bitwise representation of the result is longer than that of
14275 @var{SOURCE}, then the leading bits of the result correspond to those of
14276 @var{SOURCE} and any trailing bits are filled arbitrarily.
14277
14278 When the resulting bit representation does not correspond to a valid
14279 representation of a variable of the same type as @var{MOLD}, the results
14280 are undefined, and subsequent operations on the result cannot be
14281 guaranteed to produce sensible behavior. For example, it is possible to
14282 create @code{LOGICAL} variables for which @code{@var{VAR}} and
14283 @code{.NOT.@var{VAR}} both appear to be true.
14284
14285 @item @emph{Example}:
14286 @smallexample
14287 PROGRAM test_transfer
14288 integer :: x = 2143289344
14289 print *, transfer(x, 1.0) ! prints "NaN" on i686
14290 END PROGRAM
14291 @end smallexample
14292 @end table
14293
14294
14295
14296 @node TRANSPOSE
14297 @section @code{TRANSPOSE} --- Transpose an array of rank two
14298 @fnindex TRANSPOSE
14299 @cindex array, transpose
14300 @cindex matrix, transpose
14301 @cindex transpose
14302
14303 @table @asis
14304 @item @emph{Description}:
14305 Transpose an array of rank two. Element (i, j) of the result has the value
14306 @code{MATRIX(j, i)}, for all i, j.
14307
14308 @item @emph{Standard}:
14309 Fortran 95 and later
14310
14311 @item @emph{Class}:
14312 Transformational function
14313
14314 @item @emph{Syntax}:
14315 @code{RESULT = TRANSPOSE(MATRIX)}
14316
14317 @item @emph{Arguments}:
14318 @multitable @columnfractions .15 .70
14319 @item @var{MATRIX} @tab Shall be an array of any type and have a rank of two.
14320 @end multitable
14321
14322 @item @emph{Return value}:
14323 The result has the same type as @var{MATRIX}, and has shape
14324 @code{(/ m, n /)} if @var{MATRIX} has shape @code{(/ n, m /)}.
14325 @end table
14326
14327
14328
14329 @node TRIM
14330 @section @code{TRIM} --- Remove trailing blank characters of a string
14331 @fnindex TRIM
14332 @cindex string, remove trailing whitespace
14333
14334 @table @asis
14335 @item @emph{Description}:
14336 Removes trailing blank characters of a string.
14337
14338 @item @emph{Standard}:
14339 Fortran 95 and later
14340
14341 @item @emph{Class}:
14342 Transformational function
14343
14344 @item @emph{Syntax}:
14345 @code{RESULT = TRIM(STRING)}
14346
14347 @item @emph{Arguments}:
14348 @multitable @columnfractions .15 .70
14349 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER}.
14350 @end multitable
14351
14352 @item @emph{Return value}:
14353 A scalar of type @code{CHARACTER} which length is that of @var{STRING}
14354 less the number of trailing blanks.
14355
14356 @item @emph{Example}:
14357 @smallexample
14358 PROGRAM test_trim
14359 CHARACTER(len=10), PARAMETER :: s = "GFORTRAN "
14360 WRITE(*,*) LEN(s), LEN(TRIM(s)) ! "10 8", with/without trailing blanks
14361 END PROGRAM
14362 @end smallexample
14363
14364 @item @emph{See also}:
14365 @ref{ADJUSTL}, @ref{ADJUSTR}
14366 @end table
14367
14368
14369
14370 @node TTYNAM
14371 @section @code{TTYNAM} --- Get the name of a terminal device.
14372 @fnindex TTYNAM
14373 @cindex system, terminal
14374
14375 @table @asis
14376 @item @emph{Description}:
14377 Get the name of a terminal device. For more information,
14378 see @code{ttyname(3)}.
14379
14380 This intrinsic is provided in both subroutine and function forms;
14381 however, only one form can be used in any given program unit.
14382
14383 @item @emph{Standard}:
14384 GNU extension
14385
14386 @item @emph{Class}:
14387 Subroutine, function
14388
14389 @item @emph{Syntax}:
14390 @multitable @columnfractions .80
14391 @item @code{CALL TTYNAM(UNIT, NAME)}
14392 @item @code{NAME = TTYNAM(UNIT)}
14393 @end multitable
14394
14395 @item @emph{Arguments}:
14396 @multitable @columnfractions .15 .70
14397 @item @var{UNIT} @tab Shall be a scalar @code{INTEGER}.
14398 @item @var{NAME} @tab Shall be of type @code{CHARACTER}.
14399 @end multitable
14400
14401 @item @emph{Example}:
14402 @smallexample
14403 PROGRAM test_ttynam
14404 INTEGER :: unit
14405 DO unit = 1, 10
14406 IF (isatty(unit=unit)) write(*,*) ttynam(unit)
14407 END DO
14408 END PROGRAM
14409 @end smallexample
14410
14411 @item @emph{See also}:
14412 @ref{ISATTY}
14413 @end table
14414
14415
14416
14417 @node UBOUND
14418 @section @code{UBOUND} --- Upper dimension bounds of an array
14419 @fnindex UBOUND
14420 @cindex array, upper bound
14421
14422 @table @asis
14423 @item @emph{Description}:
14424 Returns the upper bounds of an array, or a single upper bound
14425 along the @var{DIM} dimension.
14426 @item @emph{Standard}:
14427 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
14428
14429 @item @emph{Class}:
14430 Inquiry function
14431
14432 @item @emph{Syntax}:
14433 @code{RESULT = UBOUND(ARRAY [, DIM [, KIND]])}
14434
14435 @item @emph{Arguments}:
14436 @multitable @columnfractions .15 .70
14437 @item @var{ARRAY} @tab Shall be an array, of any type.
14438 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
14439 @item @var{KIND}@tab (Optional) An @code{INTEGER} initialization
14440 expression indicating the kind parameter of the result.
14441 @end multitable
14442
14443 @item @emph{Return value}:
14444 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
14445 @var{KIND} is absent, the return value is of default integer kind.
14446 If @var{DIM} is absent, the result is an array of the upper bounds of
14447 @var{ARRAY}. If @var{DIM} is present, the result is a scalar
14448 corresponding to the upper bound of the array along that dimension. If
14449 @var{ARRAY} is an expression rather than a whole array or array
14450 structure component, or if it has a zero extent along the relevant
14451 dimension, the upper bound is taken to be the number of elements along
14452 the relevant dimension.
14453
14454 @item @emph{See also}:
14455 @ref{LBOUND}, @ref{LCOBOUND}
14456 @end table
14457
14458
14459
14460 @node UCOBOUND
14461 @section @code{UCOBOUND} --- Upper codimension bounds of an array
14462 @fnindex UCOBOUND
14463 @cindex coarray, upper bound
14464
14465 @table @asis
14466 @item @emph{Description}:
14467 Returns the upper cobounds of a coarray, or a single upper cobound
14468 along the @var{DIM} codimension.
14469 @item @emph{Standard}:
14470 Fortran 2008 and later
14471
14472 @item @emph{Class}:
14473 Inquiry function
14474
14475 @item @emph{Syntax}:
14476 @code{RESULT = UCOBOUND(COARRAY [, DIM [, KIND]])}
14477
14478 @item @emph{Arguments}:
14479 @multitable @columnfractions .15 .70
14480 @item @var{ARRAY} @tab Shall be an coarray, of any type.
14481 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
14482 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
14483 expression indicating the kind parameter of the result.
14484 @end multitable
14485
14486 @item @emph{Return value}:
14487 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
14488 @var{KIND} is absent, the return value is of default integer kind.
14489 If @var{DIM} is absent, the result is an array of the lower cobounds of
14490 @var{COARRAY}. If @var{DIM} is present, the result is a scalar
14491 corresponding to the lower cobound of the array along that codimension.
14492
14493 @item @emph{See also}:
14494 @ref{LCOBOUND}, @ref{LBOUND}
14495 @end table
14496
14497
14498
14499 @node UMASK
14500 @section @code{UMASK} --- Set the file creation mask
14501 @fnindex UMASK
14502 @cindex file system, file creation mask
14503
14504 @table @asis
14505 @item @emph{Description}:
14506 Sets the file creation mask to @var{MASK}. If called as a function, it
14507 returns the old value. If called as a subroutine and argument @var{OLD}
14508 if it is supplied, it is set to the old value. See @code{umask(2)}.
14509
14510 @item @emph{Standard}:
14511 GNU extension
14512
14513 @item @emph{Class}:
14514 Subroutine, function
14515
14516 @item @emph{Syntax}:
14517 @multitable @columnfractions .80
14518 @item @code{CALL UMASK(MASK [, OLD])}
14519 @item @code{OLD = UMASK(MASK)}
14520 @end multitable
14521
14522 @item @emph{Arguments}:
14523 @multitable @columnfractions .15 .70
14524 @item @var{MASK} @tab Shall be a scalar of type @code{INTEGER}.
14525 @item @var{OLD} @tab (Optional) Shall be a scalar of type
14526 @code{INTEGER}.
14527 @end multitable
14528
14529 @end table
14530
14531
14532
14533 @node UNLINK
14534 @section @code{UNLINK} --- Remove a file from the file system
14535 @fnindex UNLINK
14536 @cindex file system, remove file
14537
14538 @table @asis
14539 @item @emph{Description}:
14540 Unlinks the file @var{PATH}. A null character (@code{CHAR(0)}) can be
14541 used to mark the end of the name in @var{PATH}; otherwise, trailing
14542 blanks in the file name are ignored. If the @var{STATUS} argument is
14543 supplied, it contains 0 on success or a nonzero error code upon return;
14544 see @code{unlink(2)}.
14545
14546 This intrinsic is provided in both subroutine and function forms;
14547 however, only one form can be used in any given program unit.
14548
14549 @item @emph{Standard}:
14550 GNU extension
14551
14552 @item @emph{Class}:
14553 Subroutine, function
14554
14555 @item @emph{Syntax}:
14556 @multitable @columnfractions .80
14557 @item @code{CALL UNLINK(PATH [, STATUS])}
14558 @item @code{STATUS = UNLINK(PATH)}
14559 @end multitable
14560
14561 @item @emph{Arguments}:
14562 @multitable @columnfractions .15 .70
14563 @item @var{PATH} @tab Shall be of default @code{CHARACTER} type.
14564 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
14565 @end multitable
14566
14567 @item @emph{See also}:
14568 @ref{LINK}, @ref{SYMLNK}
14569 @end table
14570
14571
14572
14573 @node UNPACK
14574 @section @code{UNPACK} --- Unpack an array of rank one into an array
14575 @fnindex UNPACK
14576 @cindex array, unpacking
14577 @cindex array, increase dimension
14578 @cindex array, scatter elements
14579
14580 @table @asis
14581 @item @emph{Description}:
14582 Store the elements of @var{VECTOR} in an array of higher rank.
14583
14584 @item @emph{Standard}:
14585 Fortran 95 and later
14586
14587 @item @emph{Class}:
14588 Transformational function
14589
14590 @item @emph{Syntax}:
14591 @code{RESULT = UNPACK(VECTOR, MASK, FIELD)}
14592
14593 @item @emph{Arguments}:
14594 @multitable @columnfractions .15 .70
14595 @item @var{VECTOR} @tab Shall be an array of any type and rank one. It
14596 shall have at least as many elements as @var{MASK} has @code{TRUE} values.
14597 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL}.
14598 @item @var{FIELD} @tab Shall be of the same type as @var{VECTOR} and have
14599 the same shape as @var{MASK}.
14600 @end multitable
14601
14602 @item @emph{Return value}:
14603 The resulting array corresponds to @var{FIELD} with @code{TRUE} elements
14604 of @var{MASK} replaced by values from @var{VECTOR} in array element order.
14605
14606 @item @emph{Example}:
14607 @smallexample
14608 PROGRAM test_unpack
14609 integer :: vector(2) = (/1,1/)
14610 logical :: mask(4) = (/ .TRUE., .FALSE., .FALSE., .TRUE. /)
14611 integer :: field(2,2) = 0, unity(2,2)
14612
14613 ! result: unity matrix
14614 unity = unpack(vector, reshape(mask, (/2,2/)), field)
14615 END PROGRAM
14616 @end smallexample
14617
14618 @item @emph{See also}:
14619 @ref{PACK}, @ref{SPREAD}
14620 @end table
14621
14622
14623
14624 @node VERIFY
14625 @section @code{VERIFY} --- Scan a string for characters not a given set
14626 @fnindex VERIFY
14627 @cindex string, find missing set
14628
14629 @table @asis
14630 @item @emph{Description}:
14631 Verifies that all the characters in @var{STRING} belong to the set of
14632 characters in @var{SET}.
14633
14634 If @var{BACK} is either absent or equals @code{FALSE}, this function
14635 returns the position of the leftmost character of @var{STRING} that is
14636 not in @var{SET}. If @var{BACK} equals @code{TRUE}, the rightmost
14637 position is returned. If all characters of @var{STRING} are found in
14638 @var{SET}, the result is zero.
14639
14640 @item @emph{Standard}:
14641 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
14642
14643 @item @emph{Class}:
14644 Elemental function
14645
14646 @item @emph{Syntax}:
14647 @code{RESULT = VERIFY(STRING, SET[, BACK [, KIND]])}
14648
14649 @item @emph{Arguments}:
14650 @multitable @columnfractions .15 .70
14651 @item @var{STRING} @tab Shall be of type @code{CHARACTER}.
14652 @item @var{SET} @tab Shall be of type @code{CHARACTER}.
14653 @item @var{BACK} @tab (Optional) shall be of type @code{LOGICAL}.
14654 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
14655 expression indicating the kind parameter of the result.
14656 @end multitable
14657
14658 @item @emph{Return value}:
14659 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
14660 @var{KIND} is absent, the return value is of default integer kind.
14661
14662 @item @emph{Example}:
14663 @smallexample
14664 PROGRAM test_verify
14665 WRITE(*,*) VERIFY("FORTRAN", "AO") ! 1, found 'F'
14666 WRITE(*,*) VERIFY("FORTRAN", "FOO") ! 3, found 'R'
14667 WRITE(*,*) VERIFY("FORTRAN", "C++") ! 1, found 'F'
14668 WRITE(*,*) VERIFY("FORTRAN", "C++", .TRUE.) ! 7, found 'N'
14669 WRITE(*,*) VERIFY("FORTRAN", "FORTRAN") ! 0' found none
14670 END PROGRAM
14671 @end smallexample
14672
14673 @item @emph{See also}:
14674 @ref{SCAN}, @ref{INDEX intrinsic}
14675 @end table
14676
14677
14678
14679 @node XOR
14680 @section @code{XOR} --- Bitwise logical exclusive OR
14681 @fnindex XOR
14682 @cindex bitwise logical exclusive or
14683 @cindex logical exclusive or, bitwise
14684
14685 @table @asis
14686 @item @emph{Description}:
14687 Bitwise logical exclusive or.
14688
14689 This intrinsic routine is provided for backwards compatibility with
14690 GNU Fortran 77. For integer arguments, programmers should consider
14691 the use of the @ref{IEOR} intrinsic and for logical arguments the
14692 @code{.NEQV.} operator, which are both defined by the Fortran standard.
14693
14694 @item @emph{Standard}:
14695 GNU extension
14696
14697 @item @emph{Class}:
14698 Function
14699
14700 @item @emph{Syntax}:
14701 @code{RESULT = XOR(I, J)}
14702
14703 @item @emph{Arguments}:
14704 @multitable @columnfractions .15 .70
14705 @item @var{I} @tab The type shall be either a scalar @code{INTEGER}
14706 type or a scalar @code{LOGICAL} type or a boz-literal-constant.
14707 @item @var{J} @tab The type shall be the same as the type of @var{I} or
14708 a boz-literal-constant. @var{I} and @var{J} shall not both be
14709 boz-literal-constants. If either @var{I} and @var{J} is a
14710 boz-literal-constant, then the other argument must be a scalar @code{INTEGER}.
14711 @end multitable
14712
14713 @item @emph{Return value}:
14714 The return type is either a scalar @code{INTEGER} or a scalar
14715 @code{LOGICAL}. If the kind type parameters differ, then the
14716 smaller kind type is implicitly converted to larger kind, and the
14717 return has the larger kind. A boz-literal-constant is
14718 converted to an @code{INTEGER} with the kind type parameter of
14719 the other argument as-if a call to @ref{INT} occurred.
14720
14721 @item @emph{Example}:
14722 @smallexample
14723 PROGRAM test_xor
14724 LOGICAL :: T = .TRUE., F = .FALSE.
14725 INTEGER :: a, b
14726 DATA a / Z'F' /, b / Z'3' /
14727
14728 WRITE (*,*) XOR(T, T), XOR(T, F), XOR(F, T), XOR(F, F)
14729 WRITE (*,*) XOR(a, b)
14730 END PROGRAM
14731 @end smallexample
14732
14733 @item @emph{See also}:
14734 Fortran 95 elemental function: @ref{IEOR}
14735 @end table
14736
14737
14738
14739 @node Intrinsic Modules
14740 @chapter Intrinsic Modules
14741 @cindex intrinsic Modules
14742
14743 @menu
14744 * ISO_FORTRAN_ENV::
14745 * ISO_C_BINDING::
14746 * IEEE modules::
14747 * OpenMP Modules OMP_LIB and OMP_LIB_KINDS::
14748 * OpenACC Module OPENACC::
14749 @end menu
14750
14751 @node ISO_FORTRAN_ENV
14752 @section @code{ISO_FORTRAN_ENV}
14753 @table @asis
14754 @item @emph{Standard}:
14755 Fortran 2003 and later, except when otherwise noted
14756 @end table
14757
14758 The @code{ISO_FORTRAN_ENV} module provides the following scalar default-integer
14759 named constants:
14760
14761 @table @asis
14762 @item @code{ATOMIC_INT_KIND}:
14763 Default-kind integer constant to be used as kind parameter when defining
14764 integer variables used in atomic operations. (Fortran 2008 or later.)
14765
14766 @item @code{ATOMIC_LOGICAL_KIND}:
14767 Default-kind integer constant to be used as kind parameter when defining
14768 logical variables used in atomic operations. (Fortran 2008 or later.)
14769
14770 @item @code{CHARACTER_KINDS}:
14771 Default-kind integer constant array of rank one containing the supported kind
14772 parameters of the @code{CHARACTER} type. (Fortran 2008 or later.)
14773
14774 @item @code{CHARACTER_STORAGE_SIZE}:
14775 Size in bits of the character storage unit.
14776
14777 @item @code{ERROR_UNIT}:
14778 Identifies the preconnected unit used for error reporting.
14779
14780 @item @code{FILE_STORAGE_SIZE}:
14781 Size in bits of the file-storage unit.
14782
14783 @item @code{INPUT_UNIT}:
14784 Identifies the preconnected unit identified by the asterisk
14785 (@code{*}) in @code{READ} statement.
14786
14787 @item @code{INT8}, @code{INT16}, @code{INT32}, @code{INT64}:
14788 Kind type parameters to specify an INTEGER type with a storage
14789 size of 16, 32, and 64 bits. It is negative if a target platform
14790 does not support the particular kind. (Fortran 2008 or later.)
14791
14792 @item @code{INTEGER_KINDS}:
14793 Default-kind integer constant array of rank one containing the supported kind
14794 parameters of the @code{INTEGER} type. (Fortran 2008 or later.)
14795
14796 @item @code{IOSTAT_END}:
14797 The value assigned to the variable passed to the @code{IOSTAT=} specifier of
14798 an input/output statement if an end-of-file condition occurred.
14799
14800 @item @code{IOSTAT_EOR}:
14801 The value assigned to the variable passed to the @code{IOSTAT=} specifier of
14802 an input/output statement if an end-of-record condition occurred.
14803
14804 @item @code{IOSTAT_INQUIRE_INTERNAL_UNIT}:
14805 Scalar default-integer constant, used by @code{INQUIRE} for the
14806 @code{IOSTAT=} specifier to denote an that a unit number identifies an
14807 internal unit. (Fortran 2008 or later.)
14808
14809 @item @code{NUMERIC_STORAGE_SIZE}:
14810 The size in bits of the numeric storage unit.
14811
14812 @item @code{LOGICAL_KINDS}:
14813 Default-kind integer constant array of rank one containing the supported kind
14814 parameters of the @code{LOGICAL} type. (Fortran 2008 or later.)
14815
14816 @item @code{OUTPUT_UNIT}:
14817 Identifies the preconnected unit identified by the asterisk
14818 (@code{*}) in @code{WRITE} statement.
14819
14820 @item @code{REAL32}, @code{REAL64}, @code{REAL128}:
14821 Kind type parameters to specify a REAL type with a storage
14822 size of 32, 64, and 128 bits. It is negative if a target platform
14823 does not support the particular kind. (Fortran 2008 or later.)
14824
14825 @item @code{REAL_KINDS}:
14826 Default-kind integer constant array of rank one containing the supported kind
14827 parameters of the @code{REAL} type. (Fortran 2008 or later.)
14828
14829 @item @code{STAT_LOCKED}:
14830 Scalar default-integer constant used as STAT= return value by @code{LOCK} to
14831 denote that the lock variable is locked by the executing image. (Fortran 2008
14832 or later.)
14833
14834 @item @code{STAT_LOCKED_OTHER_IMAGE}:
14835 Scalar default-integer constant used as STAT= return value by @code{UNLOCK} to
14836 denote that the lock variable is locked by another image. (Fortran 2008 or
14837 later.)
14838
14839 @item @code{STAT_STOPPED_IMAGE}:
14840 Positive, scalar default-integer constant used as STAT= return value if the
14841 argument in the statement requires synchronisation with an image, which has
14842 initiated the termination of the execution. (Fortran 2008 or later.)
14843
14844 @item @code{STAT_FAILED_IMAGE}:
14845 Positive, scalar default-integer constant used as STAT= return value if the
14846 argument in the statement requires communication with an image, which has
14847 is in the failed state. (TS 18508 or later.)
14848
14849 @item @code{STAT_UNLOCKED}:
14850 Scalar default-integer constant used as STAT= return value by @code{UNLOCK} to
14851 denote that the lock variable is unlocked. (Fortran 2008 or later.)
14852 @end table
14853
14854 The module provides the following derived type:
14855
14856 @table @asis
14857 @item @code{LOCK_TYPE}:
14858 Derived type with private components to be use with the @code{LOCK} and
14859 @code{UNLOCK} statement. A variable of its type has to be always declared
14860 as coarray and may not appear in a variable-definition context.
14861 (Fortran 2008 or later.)
14862 @end table
14863
14864 The module also provides the following intrinsic procedures:
14865 @ref{COMPILER_OPTIONS} and @ref{COMPILER_VERSION}.
14866
14867
14868
14869 @node ISO_C_BINDING
14870 @section @code{ISO_C_BINDING}
14871 @table @asis
14872 @item @emph{Standard}:
14873 Fortran 2003 and later, GNU extensions
14874 @end table
14875
14876 The following intrinsic procedures are provided by the module; their
14877 definition can be found in the section Intrinsic Procedures of this
14878 manual.
14879
14880 @table @asis
14881 @item @code{C_ASSOCIATED}
14882 @item @code{C_F_POINTER}
14883 @item @code{C_F_PROCPOINTER}
14884 @item @code{C_FUNLOC}
14885 @item @code{C_LOC}
14886 @item @code{C_SIZEOF}
14887 @end table
14888 @c TODO: Vertical spacing between C_FUNLOC and C_LOC wrong in PDF,
14889 @c don't really know why.
14890
14891 The @code{ISO_C_BINDING} module provides the following named constants of
14892 type default integer, which can be used as KIND type parameters.
14893
14894 In addition to the integer named constants required by the Fortran 2003
14895 standard and @code{C_PTRDIFF_T} of TS 29113, GNU Fortran provides as an
14896 extension named constants for the 128-bit integer types supported by the
14897 C compiler: @code{C_INT128_T, C_INT_LEAST128_T, C_INT_FAST128_T}.
14898 Furthermore, if @code{__float128} is supported in C, the named constants
14899 @code{C_FLOAT128, C_FLOAT128_COMPLEX} are defined.
14900
14901 @multitable @columnfractions .15 .35 .35 .35
14902 @item Fortran Type @tab Named constant @tab C type @tab Extension
14903 @item @code{INTEGER}@tab @code{C_INT} @tab @code{int}
14904 @item @code{INTEGER}@tab @code{C_SHORT} @tab @code{short int}
14905 @item @code{INTEGER}@tab @code{C_LONG} @tab @code{long int}
14906 @item @code{INTEGER}@tab @code{C_LONG_LONG} @tab @code{long long int}
14907 @item @code{INTEGER}@tab @code{C_SIGNED_CHAR} @tab @code{signed char}/@code{unsigned char}
14908 @item @code{INTEGER}@tab @code{C_SIZE_T} @tab @code{size_t}
14909 @item @code{INTEGER}@tab @code{C_INT8_T} @tab @code{int8_t}
14910 @item @code{INTEGER}@tab @code{C_INT16_T} @tab @code{int16_t}
14911 @item @code{INTEGER}@tab @code{C_INT32_T} @tab @code{int32_t}
14912 @item @code{INTEGER}@tab @code{C_INT64_T} @tab @code{int64_t}
14913 @item @code{INTEGER}@tab @code{C_INT128_T} @tab @code{int128_t} @tab Ext.
14914 @item @code{INTEGER}@tab @code{C_INT_LEAST8_T} @tab @code{int_least8_t}
14915 @item @code{INTEGER}@tab @code{C_INT_LEAST16_T} @tab @code{int_least16_t}
14916 @item @code{INTEGER}@tab @code{C_INT_LEAST32_T} @tab @code{int_least32_t}
14917 @item @code{INTEGER}@tab @code{C_INT_LEAST64_T} @tab @code{int_least64_t}
14918 @item @code{INTEGER}@tab @code{C_INT_LEAST128_T}@tab @code{int_least128_t} @tab Ext.
14919 @item @code{INTEGER}@tab @code{C_INT_FAST8_T} @tab @code{int_fast8_t}
14920 @item @code{INTEGER}@tab @code{C_INT_FAST16_T} @tab @code{int_fast16_t}
14921 @item @code{INTEGER}@tab @code{C_INT_FAST32_T} @tab @code{int_fast32_t}
14922 @item @code{INTEGER}@tab @code{C_INT_FAST64_T} @tab @code{int_fast64_t}
14923 @item @code{INTEGER}@tab @code{C_INT_FAST128_T} @tab @code{int_fast128_t} @tab Ext.
14924 @item @code{INTEGER}@tab @code{C_INTMAX_T} @tab @code{intmax_t}
14925 @item @code{INTEGER}@tab @code{C_INTPTR_T} @tab @code{intptr_t}
14926 @item @code{INTEGER}@tab @code{C_PTRDIFF_T} @tab @code{ptrdiff_t} @tab TS 29113
14927 @item @code{REAL} @tab @code{C_FLOAT} @tab @code{float}
14928 @item @code{REAL} @tab @code{C_DOUBLE} @tab @code{double}
14929 @item @code{REAL} @tab @code{C_LONG_DOUBLE} @tab @code{long double}
14930 @item @code{REAL} @tab @code{C_FLOAT128} @tab @code{__float128} @tab Ext.
14931 @item @code{COMPLEX}@tab @code{C_FLOAT_COMPLEX} @tab @code{float _Complex}
14932 @item @code{COMPLEX}@tab @code{C_DOUBLE_COMPLEX}@tab @code{double _Complex}
14933 @item @code{COMPLEX}@tab @code{C_LONG_DOUBLE_COMPLEX}@tab @code{long double _Complex}
14934 @item @code{REAL} @tab @code{C_FLOAT128_COMPLEX} @tab @code{__float128 _Complex} @tab Ext.
14935 @item @code{LOGICAL}@tab @code{C_BOOL} @tab @code{_Bool}
14936 @item @code{CHARACTER}@tab @code{C_CHAR} @tab @code{char}
14937 @end multitable
14938
14939 Additionally, the following parameters of type @code{CHARACTER(KIND=C_CHAR)}
14940 are defined.
14941
14942 @multitable @columnfractions .20 .45 .15
14943 @item Name @tab C definition @tab Value
14944 @item @code{C_NULL_CHAR} @tab null character @tab @code{'\0'}
14945 @item @code{C_ALERT} @tab alert @tab @code{'\a'}
14946 @item @code{C_BACKSPACE} @tab backspace @tab @code{'\b'}
14947 @item @code{C_FORM_FEED} @tab form feed @tab @code{'\f'}
14948 @item @code{C_NEW_LINE} @tab new line @tab @code{'\n'}
14949 @item @code{C_CARRIAGE_RETURN} @tab carriage return @tab @code{'\r'}
14950 @item @code{C_HORIZONTAL_TAB} @tab horizontal tab @tab @code{'\t'}
14951 @item @code{C_VERTICAL_TAB} @tab vertical tab @tab @code{'\v'}
14952 @end multitable
14953
14954 Moreover, the following two named constants are defined:
14955
14956 @multitable @columnfractions .20 .80
14957 @item Name @tab Type
14958 @item @code{C_NULL_PTR} @tab @code{C_PTR}
14959 @item @code{C_NULL_FUNPTR} @tab @code{C_FUNPTR}
14960 @end multitable
14961
14962 Both are equivalent to the value @code{NULL} in C.
14963
14964
14965
14966 @node IEEE modules
14967 @section IEEE modules: @code{IEEE_EXCEPTIONS}, @code{IEEE_ARITHMETIC}, and @code{IEEE_FEATURES}
14968 @table @asis
14969 @item @emph{Standard}:
14970 Fortran 2003 and later
14971 @end table
14972
14973 The @code{IEEE_EXCEPTIONS}, @code{IEEE_ARITHMETIC}, and @code{IEEE_FEATURES}
14974 intrinsic modules provide support for exceptions and IEEE arithmetic, as
14975 defined in Fortran 2003 and later standards, and the IEC 60559:1989 standard
14976 (@emph{Binary floating-point arithmetic for microprocessor systems}). These
14977 modules are only provided on the following supported platforms:
14978
14979 @itemize @bullet
14980 @item i386 and x86_64 processors
14981 @item platforms which use the GNU C Library (glibc)
14982 @item platforms with support for SysV/386 routines for floating point
14983 interface (including Solaris and BSDs)
14984 @item platforms with the AIX OS
14985 @end itemize
14986
14987 For full compliance with the Fortran standards, code using the
14988 @code{IEEE_EXCEPTIONS} or @code{IEEE_ARITHMETIC} modules should be compiled
14989 with the following options: @code{-fno-unsafe-math-optimizations
14990 -frounding-math -fsignaling-nans}.
14991
14992
14993
14994 @node OpenMP Modules OMP_LIB and OMP_LIB_KINDS
14995 @section OpenMP Modules @code{OMP_LIB} and @code{OMP_LIB_KINDS}
14996 @table @asis
14997 @item @emph{Standard}:
14998 OpenMP Application Program Interface v4.5
14999 @end table
15000
15001
15002 The OpenMP Fortran runtime library routines are provided both in
15003 a form of two Fortran 90 modules, named @code{OMP_LIB} and
15004 @code{OMP_LIB_KINDS}, and in a form of a Fortran @code{include} file named
15005 @file{omp_lib.h}. The procedures provided by @code{OMP_LIB} can be found
15006 in the @ref{Top,,Introduction,libgomp,GNU Offloading and Multi
15007 Processing Runtime Library} manual,
15008 the named constants defined in the modules are listed
15009 below.
15010
15011 For details refer to the actual
15012 @uref{http://www.openmp.org/wp-content/uploads/openmp-4.5.pdf,
15013 OpenMP Application Program Interface v4.5}.
15014
15015 @code{OMP_LIB_KINDS} provides the following scalar default-integer
15016 named constants:
15017
15018 @table @asis
15019 @item @code{omp_lock_kind}
15020 @item @code{omp_nest_lock_kind}
15021 @item @code{omp_proc_bind_kind}
15022 @item @code{omp_sched_kind}
15023 @end table
15024
15025 @code{OMP_LIB} provides the scalar default-integer
15026 named constant @code{openmp_version} with a value of the form
15027 @var{yyyymm}, where @code{yyyy} is the year and @var{mm} the month
15028 of the OpenMP version; for OpenMP v4.5 the value is @code{201511}.
15029
15030 The following scalar integer named constants of the
15031 kind @code{omp_sched_kind}:
15032
15033 @table @asis
15034 @item @code{omp_sched_static}
15035 @item @code{omp_sched_dynamic}
15036 @item @code{omp_sched_guided}
15037 @item @code{omp_sched_auto}
15038 @end table
15039
15040 And the following scalar integer named constants of the
15041 kind @code{omp_proc_bind_kind}:
15042
15043 @table @asis
15044 @item @code{omp_proc_bind_false}
15045 @item @code{omp_proc_bind_true}
15046 @item @code{omp_proc_bind_master}
15047 @item @code{omp_proc_bind_close}
15048 @item @code{omp_proc_bind_spread}
15049 @end table
15050
15051
15052
15053 @node OpenACC Module OPENACC
15054 @section OpenACC Module @code{OPENACC}
15055 @table @asis
15056 @item @emph{Standard}:
15057 OpenACC Application Programming Interface v2.0
15058 @end table
15059
15060
15061 The OpenACC Fortran runtime library routines are provided both in a
15062 form of a Fortran 90 module, named @code{OPENACC}, and in form of a
15063 Fortran @code{include} file named @file{openacc_lib.h}. The
15064 procedures provided by @code{OPENACC} can be found in the
15065 @ref{Top,,Introduction,libgomp,GNU Offloading and Multi Processing
15066 Runtime Library} manual, the named constants defined in the modules
15067 are listed below.
15068
15069 For details refer to the actual
15070 @uref{http://www.openacc.org/,
15071 OpenACC Application Programming Interface v2.0}.
15072
15073 @code{OPENACC} provides the scalar default-integer
15074 named constant @code{openacc_version} with a value of the form
15075 @var{yyyymm}, where @code{yyyy} is the year and @var{mm} the month
15076 of the OpenACC version; for OpenACC v2.0 the value is @code{201306}.