2 Copyright (C) 2005-2023 Free Software Foundation, Inc.
3 This is part of the GNU Fortran manual.
4 For copying conditions, see the file gfortran.texi.
6 Permission is granted to copy, distribute and/or modify this document
7 under the terms of the GNU Free Documentation License, Version 1.3 or
8 any later version published by the Free Software Foundation; with the
9 Invariant Sections being ``Funding Free Software'', the Front-Cover
10 Texts being (a) (see below), and with the Back-Cover Texts being (b)
11 (see below). A copy of the license is included in the gfdl(7) man page.
14 Some basic guidelines for editing this document:
16 (1) The intrinsic procedures are to be listed in alphabetical order.
17 (2) The generic name is to be used.
18 (3) The specific names are included in the function index and in a
19 table at the end of the node (See ABS entry).
20 (4) Try to maintain the same style for each entry.
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}
39 @node Intrinsic Procedures
40 @chapter Intrinsic Procedures
41 @cindex intrinsic procedures
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{LSHIFT}: LSHIFT, Left shift bits
225 * @code{LSTAT}: LSTAT, Get file status
226 * @code{LTIME}: LTIME, Convert time to local time info
227 * @code{MALLOC}: MALLOC, Dynamic memory allocation function
228 * @code{MASKL}: MASKL, Left justified mask
229 * @code{MASKR}: MASKR, Right justified mask
230 * @code{MATMUL}: MATMUL, matrix multiplication
231 * @code{MAX}: MAX, Maximum value of an argument list
232 * @code{MAXEXPONENT}: MAXEXPONENT, Maximum exponent of a real kind
233 * @code{MAXLOC}: MAXLOC, Location of the maximum value within an array
234 * @code{MAXVAL}: MAXVAL, Maximum value of an array
235 * @code{MCLOCK}: MCLOCK, Time function
236 * @code{MCLOCK8}: MCLOCK8, Time function (64-bit)
237 * @code{MERGE}: MERGE, Merge arrays
238 * @code{MERGE_BITS}: MERGE_BITS, Merge of bits under mask
239 * @code{MIN}: MIN, Minimum value of an argument list
240 * @code{MINEXPONENT}: MINEXPONENT, Minimum exponent of a real kind
241 * @code{MINLOC}: MINLOC, Location of the minimum value within an array
242 * @code{MINVAL}: MINVAL, Minimum value of an array
243 * @code{MOD}: MOD, Remainder function
244 * @code{MODULO}: MODULO, Modulo function
245 * @code{MOVE_ALLOC}: MOVE_ALLOC, Move allocation from one object to another
246 * @code{MVBITS}: MVBITS, Move bits from one integer to another
247 * @code{NEAREST}: NEAREST, Nearest representable number
248 * @code{NEW_LINE}: NEW_LINE, New line character
249 * @code{NINT}: NINT, Nearest whole number
250 * @code{NORM2}: NORM2, Euclidean vector norm
251 * @code{NOT}: NOT, Logical negation
252 * @code{NULL}: NULL, Function that returns an disassociated pointer
253 * @code{NUM_IMAGES}: NUM_IMAGES, Number of images
254 * @code{OR}: OR, Bitwise logical OR
255 * @code{PACK}: PACK, Pack an array into an array of rank one
256 * @code{PARITY}: PARITY, Reduction with exclusive OR
257 * @code{PERROR}: PERROR, Print system error message
258 * @code{POPCNT}: POPCNT, Number of bits set
259 * @code{POPPAR}: POPPAR, Parity of the number of bits set
260 * @code{PRECISION}: PRECISION, Decimal precision of a real kind
261 * @code{PRESENT}: PRESENT, Determine whether an optional dummy argument is specified
262 * @code{PRODUCT}: PRODUCT, Product of array elements
263 * @code{RADIX}: RADIX, Base of a data model
264 * @code{RAN}: RAN, Real pseudo-random number
265 * @code{RAND}: RAND, Real pseudo-random number
266 * @code{RANDOM_INIT}: RANDOM_INIT, Initialize pseudo-random number generator
267 * @code{RANDOM_NUMBER}: RANDOM_NUMBER, Pseudo-random number
268 * @code{RANDOM_SEED}: RANDOM_SEED, Initialize a pseudo-random number sequence
269 * @code{RANGE}: RANGE, Decimal exponent range
270 * @code{RANK} : RANK, Rank of a data object
271 * @code{REAL}: REAL, Convert to real type
272 * @code{RENAME}: RENAME, Rename a file
273 * @code{REPEAT}: REPEAT, Repeated string concatenation
274 * @code{RESHAPE}: RESHAPE, Function to reshape an array
275 * @code{RRSPACING}: RRSPACING, Reciprocal of the relative spacing
276 * @code{RSHIFT}: RSHIFT, Right shift bits
277 * @code{SAME_TYPE_AS}: SAME_TYPE_AS, Query dynamic types for equality
278 * @code{SCALE}: SCALE, Scale a real value
279 * @code{SCAN}: SCAN, Scan a string for the presence of a set of characters
280 * @code{SECNDS}: SECNDS, Time function
281 * @code{SECOND}: SECOND, CPU time function
282 * @code{SELECTED_CHAR_KIND}: SELECTED_CHAR_KIND, Choose character kind
283 * @code{SELECTED_INT_KIND}: SELECTED_INT_KIND, Choose integer kind
284 * @code{SELECTED_REAL_KIND}: SELECTED_REAL_KIND, Choose real kind
285 * @code{SET_EXPONENT}: SET_EXPONENT, Set the exponent of the model
286 * @code{SHAPE}: SHAPE, Determine the shape of an array
287 * @code{SHIFTA}: SHIFTA, Right shift with fill
288 * @code{SHIFTL}: SHIFTL, Left shift
289 * @code{SHIFTR}: SHIFTR, Right shift
290 * @code{SIGN}: SIGN, Sign copying function
291 * @code{SIGNAL}: SIGNAL, Signal handling subroutine (or function)
292 * @code{SIN}: SIN, Sine function
293 * @code{SIND}: SIND, Sine function, degrees
294 * @code{SINH}: SINH, Hyperbolic sine function
295 * @code{SIZE}: SIZE, Function to determine the size of an array
296 * @code{SIZEOF}: SIZEOF, Determine the size in bytes of an expression
297 * @code{SLEEP}: SLEEP, Sleep for the specified number of seconds
298 * @code{SPACING}: SPACING, Smallest distance between two numbers of a given type
299 * @code{SPREAD}: SPREAD, Add a dimension to an array
300 * @code{SQRT}: SQRT, Square-root function
301 * @code{SRAND}: SRAND, Reinitialize the random number generator
302 * @code{STAT}: STAT, Get file status
303 * @code{STORAGE_SIZE}: STORAGE_SIZE, Storage size in bits
304 * @code{SUM}: SUM, Sum of array elements
305 * @code{SYMLNK}: SYMLNK, Create a symbolic link
306 * @code{SYSTEM}: SYSTEM, Execute a shell command
307 * @code{SYSTEM_CLOCK}: SYSTEM_CLOCK, Time function
308 * @code{TAN}: TAN, Tangent function
309 * @code{TAND}: TAND, Tangent function, degrees
310 * @code{TANH}: TANH, Hyperbolic tangent function
311 * @code{THIS_IMAGE}: THIS_IMAGE, Cosubscript index of this image
312 * @code{TIME}: TIME, Time function
313 * @code{TIME8}: TIME8, Time function (64-bit)
314 * @code{TINY}: TINY, Smallest positive number of a real kind
315 * @code{TRAILZ}: TRAILZ, Number of trailing zero bits of an integer
316 * @code{TRANSFER}: TRANSFER, Transfer bit patterns
317 * @code{TRANSPOSE}: TRANSPOSE, Transpose an array of rank two
318 * @code{TRIM}: TRIM, Remove trailing blank characters of a string
319 * @code{TTYNAM}: TTYNAM, Get the name of a terminal device
320 * @code{UBOUND}: UBOUND, Upper dimension bounds of an array
321 * @code{UCOBOUND}: UCOBOUND, Upper codimension bounds of an array
322 * @code{UMASK}: UMASK, Set the file creation mask
323 * @code{UNLINK}: UNLINK, Remove a file from the file system
324 * @code{UNPACK}: UNPACK, Unpack an array of rank one into an array
325 * @code{VERIFY}: VERIFY, Scan a string for the absence of a set of characters
326 * @code{XOR}: XOR, Bitwise logical exclusive or
329 @node Introduction to Intrinsics
330 @section Introduction to intrinsic procedures
332 The intrinsic procedures provided by GNU Fortran include procedures required
333 by the Fortran 95 and later supported standards, and a set of intrinsic
334 procedures for backwards compatibility with G77. Any conflict between
335 a description here and a description in the Fortran standards is
336 unintentional, and the standard(s) should be considered authoritative.
338 The enumeration of the @code{KIND} type parameter is processor defined in
339 the Fortran 95 standard. GNU Fortran defines the default integer type and
340 default real type by @code{INTEGER(KIND=4)} and @code{REAL(KIND=4)},
341 respectively. The standard mandates that both data types shall have
342 another kind, which have more precision. On typical target architectures
343 supported by @command{gfortran}, this kind type parameter is @code{KIND=8}.
344 Hence, @code{REAL(KIND=8)} and @code{DOUBLE PRECISION} are equivalent.
345 In the description of generic intrinsic procedures, the kind type parameter
346 will be specified by @code{KIND=*}, and in the description of specific
347 names for an intrinsic procedure the kind type parameter will be explicitly
348 given (e.g., @code{REAL(KIND=4)} or @code{REAL(KIND=8)}). Finally, for
349 brevity the optional @code{KIND=} syntax will be omitted.
351 Many of the intrinsic procedures take one or more optional arguments.
352 This document follows the convention used in the Fortran 95 standard,
353 and denotes such arguments by square brackets.
355 GNU Fortran offers the @option{-std=} command-line option,
356 which can be used to restrict the set of intrinsic procedures to a
357 given standard. By default, @command{gfortran} sets the @option{-std=gnu}
358 option, and so all intrinsic procedures described here are accepted. There
359 is one caveat. For a select group of intrinsic procedures, @command{g77}
360 implemented both a function and a subroutine. Both classes
361 have been implemented in @command{gfortran} for backwards compatibility
362 with @command{g77}. It is noted here that these functions and subroutines
363 cannot be intermixed in a given subprogram. In the descriptions that follow,
364 the applicable standard for each intrinsic procedure is noted.
369 @section @code{ABORT} --- Abort the program
371 @cindex program termination, with core dump
372 @cindex terminate program, with core dump
376 @item @emph{Description}:
377 @code{ABORT} causes immediate termination of the program. On operating
378 systems that support a core dump, @code{ABORT} will produce a core dump.
379 It will also print a backtrace, unless @code{-fno-backtrace} is given.
381 @item @emph{Standard}:
390 @item @emph{Return value}:
393 @item @emph{Example}:
396 integer :: i = 1, j = 2
397 if (i /= j) call abort
398 end program test_abort
401 @item @emph{See also}:
410 @section @code{ABS} --- Absolute value
421 @cindex absolute value
424 @item @emph{Description}:
425 @code{ABS(A)} computes the absolute value of @code{A}.
427 @item @emph{Standard}:
428 Fortran 77 and later, has overloads that are GNU extensions
434 @code{RESULT = ABS(A)}
436 @item @emph{Arguments}:
437 @multitable @columnfractions .15 .70
438 @item @var{A} @tab The type of the argument shall be an @code{INTEGER},
439 @code{REAL}, or @code{COMPLEX}.
442 @item @emph{Return value}:
443 The return value is of the same type and
444 kind as the argument except the return value is @code{REAL} for a
445 @code{COMPLEX} argument.
447 @item @emph{Example}:
452 complex :: z = (-1.e0,0.e0)
459 @item @emph{Specific names}:
460 @multitable @columnfractions .20 .23 .20 .33
461 @headitem Name @tab Argument @tab Return type @tab Standard
462 @item @code{ABS(A)} @tab @code{REAL(4) A} @tab @code{REAL(4)} @tab Fortran 77 and later
463 @item @code{CABS(A)} @tab @code{COMPLEX(4) A} @tab @code{REAL(4)} @tab Fortran 77 and later
464 @item @code{DABS(A)} @tab @code{REAL(8) A} @tab @code{REAL(8)} @tab Fortran 77 and later
465 @item @code{IABS(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab Fortran 77 and later
466 @item @code{BABS(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
467 @item @code{IIABS(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
468 @item @code{JIABS(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
469 @item @code{KIABS(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
470 @item @code{ZABS(A)} @tab @code{COMPLEX(8) A} @tab @code{REAL(8)} @tab GNU extension
471 @item @code{CDABS(A)} @tab @code{COMPLEX(8) A} @tab @code{REAL(8)} @tab GNU extension
478 @section @code{ACCESS} --- Checks file access modes
480 @cindex file system, access mode
483 @item @emph{Description}:
484 @code{ACCESS(NAME, MODE)} checks whether the file @var{NAME}
485 exists, is readable, writable or executable. Except for the
486 executable check, @code{ACCESS} can be replaced by
487 Fortran 95's @code{INQUIRE}.
489 @item @emph{Standard}:
496 @code{RESULT = ACCESS(NAME, MODE)}
498 @item @emph{Arguments}:
499 @multitable @columnfractions .15 .70
500 @item @var{NAME} @tab Scalar @code{CHARACTER} of default kind with the
501 file name. Trailing blank are ignored unless the character @code{achar(0)}
502 is present, then all characters up to and excluding @code{achar(0)} are
504 @item @var{MODE} @tab Scalar @code{CHARACTER} of default kind with the
505 file access mode, may be any concatenation of @code{"r"} (readable),
506 @code{"w"} (writable) and @code{"x"} (executable), or @code{" "} to check
510 @item @emph{Return value}:
511 Returns a scalar @code{INTEGER}, which is @code{0} if the file is
512 accessible in the given mode; otherwise or if an invalid argument
513 has been given for @code{MODE} the value @code{1} is returned.
515 @item @emph{Example}:
519 character(len=*), parameter :: file = 'test.dat'
520 character(len=*), parameter :: file2 = 'test.dat '//achar(0)
521 if(access(file,' ') == 0) print *, trim(file),' is exists'
522 if(access(file,'r') == 0) print *, trim(file),' is readable'
523 if(access(file,'w') == 0) print *, trim(file),' is writable'
524 if(access(file,'x') == 0) print *, trim(file),' is executable'
525 if(access(file2,'rwx') == 0) &
526 print *, trim(file2),' is readable, writable and executable'
527 end program access_test
534 @section @code{ACHAR} --- Character in @acronym{ASCII} collating sequence
536 @cindex @acronym{ASCII} collating sequence
537 @cindex collating sequence, @acronym{ASCII}
540 @item @emph{Description}:
541 @code{ACHAR(I)} returns the character located at position @code{I}
542 in the @acronym{ASCII} collating sequence.
544 @item @emph{Standard}:
545 Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later
551 @code{RESULT = ACHAR(I [, KIND])}
553 @item @emph{Arguments}:
554 @multitable @columnfractions .15 .70
555 @item @var{I} @tab The type shall be @code{INTEGER}.
556 @item @var{KIND} @tab (Optional) A scalar @code{INTEGER} constant
557 expression indicating the kind parameter of the result.
560 @item @emph{Return value}:
561 The return value is of type @code{CHARACTER} with a length of one.
562 If the @var{KIND} argument is present, the return value is of the
563 specified kind and of the default kind otherwise.
565 @item @emph{Example}:
570 end program test_achar
574 See @ref{ICHAR} for a discussion of converting between numerical values
575 and formatted string representations.
577 @item @emph{See also}:
586 @section @code{ACOS} --- Arccosine function
589 @cindex trigonometric function, cosine, inverse
590 @cindex cosine, inverse
593 @item @emph{Description}:
594 @code{ACOS(X)} computes the arccosine of @var{X} (inverse of @code{COS(X)}).
596 @item @emph{Standard}:
597 Fortran 77 and later, for a complex argument Fortran 2008 or later
603 @code{RESULT = ACOS(X)}
605 @item @emph{Arguments}:
606 @multitable @columnfractions .15 .70
607 @item @var{X} @tab The type shall either be @code{REAL} with a magnitude that is
608 less than or equal to one - or the type shall be @code{COMPLEX}.
611 @item @emph{Return value}:
612 The return value is of the same type and kind as @var{X}.
613 The real part of the result is in radians and lies in the range
614 @math{0 \leq \Re \acos(x) \leq \pi}.
616 @item @emph{Example}:
619 real(8) :: x = 0.866_8
621 end program test_acos
624 @item @emph{Specific names}:
625 @multitable @columnfractions .20 .23 .20 .33
626 @headitem Name @tab Argument @tab Return type @tab Standard
627 @item @code{ACOS(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later
628 @item @code{DACOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
631 @item @emph{See also}:
641 @section @code{ACOSD} --- Arccosine function, degrees
644 @cindex trigonometric function, cosine, inverse, degrees
645 @cindex cosine, inverse, degrees
648 @item @emph{Description}:
649 @code{ACOSD(X)} computes the arccosine of @var{X} in degrees (inverse of
652 This function is for compatibility only and should be avoided in favor of
653 standard constructs wherever possible.
655 @item @emph{Standard}:
656 GNU extension, enabled with @option{-fdec-math}
662 @code{RESULT = ACOSD(X)}
664 @item @emph{Arguments}:
665 @multitable @columnfractions .15 .70
666 @item @var{X} @tab The type shall either be @code{REAL} with a magnitude that is
667 less than or equal to one - or the type shall be @code{COMPLEX}.
670 @item @emph{Return value}:
671 The return value is of the same type and kind as @var{X}.
672 The real part of the result is in degrees and lies in the range
673 @math{0 \leq \Re \acos(x) \leq 180}.
675 @item @emph{Example}:
678 real(8) :: x = 0.866_8
680 end program test_acosd
683 @item @emph{Specific names}:
684 @multitable @columnfractions .20 .23 .20 .33
685 @headitem Name @tab Argument @tab Return type @tab Standard
686 @item @code{ACOSD(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU extension
687 @item @code{DACOSD(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
690 @item @emph{See also}:
700 @section @code{ACOSH} --- Inverse hyperbolic cosine function
703 @cindex area hyperbolic cosine
704 @cindex inverse hyperbolic cosine
705 @cindex hyperbolic function, cosine, inverse
706 @cindex cosine, hyperbolic, inverse
709 @item @emph{Description}:
710 @code{ACOSH(X)} computes the inverse hyperbolic cosine of @var{X}.
712 @item @emph{Standard}:
713 Fortran 2008 and later
719 @code{RESULT = ACOSH(X)}
721 @item @emph{Arguments}:
722 @multitable @columnfractions .15 .70
723 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
726 @item @emph{Return value}:
727 The return value has the same type and kind as @var{X}. If @var{X} is
728 complex, the imaginary part of the result is in radians and lies between
729 @math{ 0 \leq \Im \acosh(x) \leq \pi}.
731 @item @emph{Example}:
734 REAL(8), DIMENSION(3) :: x = (/ 1.0, 2.0, 3.0 /)
739 @item @emph{Specific names}:
740 @multitable @columnfractions .20 .23 .20 .33
741 @headitem Name @tab Argument @tab Return type @tab Standard
742 @item @code{DACOSH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
745 @item @emph{See also}:
753 @section @code{ADJUSTL} --- Left adjust a string
755 @cindex string, adjust left
756 @cindex adjust string
759 @item @emph{Description}:
760 @code{ADJUSTL(STRING)} will left adjust a string by removing leading spaces.
761 Spaces are inserted at the end of the string as needed.
763 @item @emph{Standard}:
770 @code{RESULT = ADJUSTL(STRING)}
772 @item @emph{Arguments}:
773 @multitable @columnfractions .15 .70
774 @item @var{STRING} @tab The type shall be @code{CHARACTER}.
777 @item @emph{Return value}:
778 The return value is of type @code{CHARACTER} and of the same kind as
779 @var{STRING} where leading spaces are removed and the same number of
780 spaces are inserted on the end of @var{STRING}.
782 @item @emph{Example}:
785 character(len=20) :: str = ' gfortran'
788 end program test_adjustl
791 @item @emph{See also}:
799 @section @code{ADJUSTR} --- Right adjust a string
801 @cindex string, adjust right
802 @cindex adjust string
805 @item @emph{Description}:
806 @code{ADJUSTR(STRING)} will right adjust a string by removing trailing spaces.
807 Spaces are inserted at the start of the string as needed.
809 @item @emph{Standard}:
816 @code{RESULT = ADJUSTR(STRING)}
818 @item @emph{Arguments}:
819 @multitable @columnfractions .15 .70
820 @item @var{STR} @tab The type shall be @code{CHARACTER}.
823 @item @emph{Return value}:
824 The return value is of type @code{CHARACTER} and of the same kind as
825 @var{STRING} where trailing spaces are removed and the same number of
826 spaces are inserted at the start of @var{STRING}.
828 @item @emph{Example}:
831 character(len=20) :: str = 'gfortran'
834 end program test_adjustr
837 @item @emph{See also}:
845 @section @code{AIMAG} --- Imaginary part of complex number
850 @cindex complex numbers, imaginary part
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.
859 @item @emph{Standard}:
860 Fortran 77 and later, has overloads that are GNU extensions
866 @code{RESULT = AIMAG(Z)}
868 @item @emph{Arguments}:
869 @multitable @columnfractions .15 .70
870 @item @var{Z} @tab The type of the argument shall be @code{COMPLEX}.
873 @item @emph{Return value}:
874 The return value is of type @code{REAL} with the
875 kind type parameter of the argument.
877 @item @emph{Example}:
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
888 @item @emph{Specific names}:
889 @multitable @columnfractions .20 .23 .20 .33
890 @headitem Name @tab Argument @tab Return type @tab Standard
891 @item @code{AIMAG(Z)} @tab @code{COMPLEX Z} @tab @code{REAL} @tab Fortran 77 and later
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
901 @section @code{AINT} --- Truncate to a whole number
905 @cindex rounding, floor
908 @item @emph{Description}:
909 @code{AINT(A [, KIND])} truncates its argument to a whole number.
911 @item @emph{Standard}:
918 @code{RESULT = AINT(A [, KIND])}
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) A scalar @code{INTEGER} constant
924 expression indicating the kind parameter of the result.
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}.
936 @item @emph{Example}:
943 print *, aint(x4), dint(x8)
945 end program test_aint
948 @item @emph{Specific names}:
949 @multitable @columnfractions .20 .23 .20 .33
950 @headitem 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
959 @section @code{ALARM} --- Execute a routine after a given delay
961 @cindex delayed execution
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.
972 @item @emph{Standard}:
979 @code{CALL ALARM(SECONDS, HANDLER [, STATUS])}
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)}.
993 @item @emph{Example}:
996 external handler_print
998 call alarm (3, handler_print, i)
1001 end program test_alarm
1003 This will cause the external routine @var{handler_print} to be called
1010 @section @code{ALL} --- All values in @var{MASK} along @var{DIM} are true
1012 @cindex array, apply condition
1013 @cindex array, condition testing
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}.
1020 @item @emph{Standard}:
1021 Fortran 90 and later
1024 Transformational function
1026 @item @emph{Syntax}:
1027 @code{RESULT = ALL(MASK [, DIM])}
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}.
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.
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.
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.
1054 @item @emph{Example}:
1058 l = all((/.true., .true., .true./))
1063 integer a(2,3), b(2,3)
1067 print *, all(a .eq. b, 1)
1068 print *, all(a .eq. b, 2)
1069 end subroutine section
1070 end program test_all
1077 @section @code{ALLOCATED} --- Status of an allocatable entity
1079 @cindex allocation, status
1082 @item @emph{Description}:
1083 @code{ALLOCATED(ARRAY)} and @code{ALLOCATED(SCALAR)} check the allocation
1084 status of @var{ARRAY} and @var{SCALAR}, respectively.
1086 @item @emph{Standard}:
1087 Fortran 90 and later. Note, the @code{SCALAR=} keyword and allocatable
1088 scalar entities are available in Fortran 2003 and later.
1093 @item @emph{Syntax}:
1094 @multitable @columnfractions .80
1095 @item @code{RESULT = ALLOCATED(ARRAY)}
1096 @item @code{RESULT = ALLOCATED(SCALAR)}
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.
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.}
1110 @item @emph{Example}:
1112 program test_allocated
1114 real(4), allocatable :: x(:)
1115 if (.not. allocated(x)) allocate(x(i))
1116 end program test_allocated
1123 @section @code{AND} --- Bitwise logical AND
1125 @cindex bitwise logical and
1126 @cindex logical and, bitwise
1129 @item @emph{Description}:
1130 Bitwise logical @code{AND}.
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.
1136 @item @emph{Standard}:
1142 @item @emph{Syntax}:
1143 @code{RESULT = AND(I, J)}
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}.
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.
1163 @item @emph{Example}:
1166 LOGICAL :: T = .TRUE., F = .FALSE.
1168 DATA a / Z'F' /, b / Z'3' /
1170 WRITE (*,*) AND(T, T), AND(T, F), AND(F, T), AND(F, F)
1171 WRITE (*,*) AND(a, b)
1175 @item @emph{See also}:
1176 Fortran 95 elemental function: @*
1183 @section @code{ANINT} --- Nearest whole number
1187 @cindex rounding, ceiling
1190 @item @emph{Description}:
1191 @code{ANINT(A [, KIND])} rounds its argument to the nearest whole number.
1193 @item @emph{Standard}:
1194 Fortran 77 and later
1199 @item @emph{Syntax}:
1200 @code{RESULT = ANINT(A [, KIND])}
1202 @item @emph{Arguments}:
1203 @multitable @columnfractions .15 .70
1204 @item @var{A} @tab The type of the argument shall be @code{REAL}.
1205 @item @var{KIND} @tab (Optional) A scalar @code{INTEGER} constant
1206 expression indicating the kind parameter of the result.
1209 @item @emph{Return value}:
1210 The return value is of type real with the kind type parameter of the
1211 argument if the optional @var{KIND} is absent; otherwise, the kind
1212 type parameter will be given by @var{KIND}. If @var{A} is greater than
1213 zero, @code{ANINT(A)} returns @code{AINT(X+0.5)}. If @var{A} is
1214 less than or equal to zero then it returns @code{AINT(X-0.5)}.
1216 @item @emph{Example}:
1223 print *, anint(x4), dnint(x8)
1225 end program test_anint
1228 @item @emph{Specific names}:
1229 @multitable @columnfractions .20 .23 .20 .33
1230 @headitem Name @tab Argument @tab Return type @tab Standard
1231 @item @code{ANINT(A)} @tab @code{REAL(4) A} @tab @code{REAL(4)} @tab Fortran 77 and later
1232 @item @code{DNINT(A)} @tab @code{REAL(8) A} @tab @code{REAL(8)} @tab Fortran 77 and later
1239 @section @code{ANY} --- Any value in @var{MASK} along @var{DIM} is true
1241 @cindex array, apply condition
1242 @cindex array, condition testing
1245 @item @emph{Description}:
1246 @code{ANY(MASK [, DIM])} determines if any of the values in the logical array
1247 @var{MASK} along dimension @var{DIM} are @code{.TRUE.}.
1249 @item @emph{Standard}:
1250 Fortran 90 and later
1253 Transformational function
1255 @item @emph{Syntax}:
1256 @code{RESULT = ANY(MASK [, DIM])}
1258 @item @emph{Arguments}:
1259 @multitable @columnfractions .15 .70
1260 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL} and
1261 it shall not be scalar.
1262 @item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer
1263 with a value that lies between one and the rank of @var{MASK}.
1266 @item @emph{Return value}:
1267 @code{ANY(MASK)} returns a scalar value of type @code{LOGICAL} where
1268 the kind type parameter is the same as the kind type parameter of
1269 @var{MASK}. If @var{DIM} is present, then @code{ANY(MASK, DIM)} returns
1270 an array with the rank of @var{MASK} minus 1. The shape is determined from
1271 the shape of @var{MASK} where the @var{DIM} dimension is elided.
1275 @code{ANY(MASK)} is true if any element of @var{MASK} is true;
1276 otherwise, it is false. It also is false if @var{MASK} has zero size.
1278 If the rank of @var{MASK} is one, then @code{ANY(MASK,DIM)} is equivalent
1279 to @code{ANY(MASK)}. If the rank is greater than one, then @code{ANY(MASK,DIM)}
1280 is determined by applying @code{ANY} to the array sections.
1283 @item @emph{Example}:
1287 l = any((/.true., .true., .true./))
1292 integer a(2,3), b(2,3)
1296 print *, any(a .eq. b, 1)
1297 print *, any(a .eq. b, 2)
1298 end subroutine section
1299 end program test_any
1306 @section @code{ASIN} --- Arcsine function
1309 @cindex trigonometric function, sine, inverse
1310 @cindex sine, inverse
1313 @item @emph{Description}:
1314 @code{ASIN(X)} computes the arcsine of its @var{X} (inverse of @code{SIN(X)}).
1316 @item @emph{Standard}:
1317 Fortran 77 and later, for a complex argument Fortran 2008 or later
1322 @item @emph{Syntax}:
1323 @code{RESULT = ASIN(X)}
1325 @item @emph{Arguments}:
1326 @multitable @columnfractions .15 .70
1327 @item @var{X} @tab The type shall be either @code{REAL} and a magnitude that is
1328 less than or equal to one - or be @code{COMPLEX}.
1331 @item @emph{Return value}:
1332 The return value is of the same type and kind as @var{X}.
1333 The real part of the result is in radians and lies in the range
1334 @math{-\pi/2 \leq \Re \asin(x) \leq \pi/2}.
1336 @item @emph{Example}:
1339 real(8) :: x = 0.866_8
1341 end program test_asin
1344 @item @emph{Specific names}:
1345 @multitable @columnfractions .20 .23 .20 .33
1346 @headitem Name @tab Argument @tab Return type @tab Standard
1347 @item @code{ASIN(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later
1348 @item @code{DASIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
1351 @item @emph{See also}:
1352 Inverse function: @*
1354 Degrees function: @*
1361 @section @code{ASIND} --- Arcsine function, degrees
1364 @cindex trigonometric function, sine, inverse, degrees
1365 @cindex sine, inverse, degrees
1368 @item @emph{Description}:
1369 @code{ASIND(X)} computes the arcsine of its @var{X} in degrees (inverse of
1372 This function is for compatibility only and should be avoided in favor of
1373 standard constructs wherever possible.
1375 @item @emph{Standard}:
1376 GNU extension, enabled with @option{-fdec-math}.
1381 @item @emph{Syntax}:
1382 @code{RESULT = ASIND(X)}
1384 @item @emph{Arguments}:
1385 @multitable @columnfractions .15 .70
1386 @item @var{X} @tab The type shall be either @code{REAL} and a magnitude that is
1387 less than or equal to one - or be @code{COMPLEX}.
1390 @item @emph{Return value}:
1391 The return value is of the same type and kind as @var{X}.
1392 The real part of the result is in degrees and lies in the range
1393 @math{-90 \leq \Re \asin(x) \leq 90}.
1395 @item @emph{Example}:
1398 real(8) :: x = 0.866_8
1400 end program test_asind
1403 @item @emph{Specific names}:
1404 @multitable @columnfractions .20 .23 .20 .33
1405 @headitem Name @tab Argument @tab Return type @tab Standard
1406 @item @code{ASIND(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU extension
1407 @item @code{DASIND(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1410 @item @emph{See also}:
1411 Inverse function: @*
1413 Radians function: @*
1420 @section @code{ASINH} --- Inverse hyperbolic sine function
1423 @cindex area hyperbolic sine
1424 @cindex inverse hyperbolic sine
1425 @cindex hyperbolic function, sine, inverse
1426 @cindex sine, hyperbolic, inverse
1429 @item @emph{Description}:
1430 @code{ASINH(X)} computes the inverse hyperbolic sine of @var{X}.
1432 @item @emph{Standard}:
1433 Fortran 2008 and later
1438 @item @emph{Syntax}:
1439 @code{RESULT = ASINH(X)}
1441 @item @emph{Arguments}:
1442 @multitable @columnfractions .15 .70
1443 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
1446 @item @emph{Return value}:
1447 The return value is of the same type and kind as @var{X}. If @var{X} is
1448 complex, the imaginary part of the result is in radians and lies between
1449 @math{-\pi/2 \leq \Im \asinh(x) \leq \pi/2}.
1451 @item @emph{Example}:
1454 REAL(8), DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1455 WRITE (*,*) ASINH(x)
1459 @item @emph{Specific names}:
1460 @multitable @columnfractions .20 .23 .20 .33
1461 @headitem Name @tab Argument @tab Return type @tab Standard
1462 @item @code{DASINH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension.
1465 @item @emph{See also}:
1466 Inverse function: @*
1473 @section @code{ASSOCIATED} --- Status of a pointer or pointer/target pair
1475 @cindex pointer, status
1476 @cindex association status
1479 @item @emph{Description}:
1480 @code{ASSOCIATED(POINTER [, TARGET])} determines the status of the pointer
1481 @var{POINTER} or if @var{POINTER} is associated with the target @var{TARGET}.
1483 @item @emph{Standard}:
1484 Fortran 90 and later
1489 @item @emph{Syntax}:
1490 @code{RESULT = ASSOCIATED(POINTER [, TARGET])}
1492 @item @emph{Arguments}:
1493 @multitable @columnfractions .15 .70
1494 @item @var{POINTER} @tab @var{POINTER} shall have the @code{POINTER} attribute
1495 and it can be of any type.
1496 @item @var{TARGET} @tab (Optional) @var{TARGET} shall be a pointer or
1497 a target. It must have the same type, kind type parameter, and
1498 array rank as @var{POINTER}.
1500 The association status of neither @var{POINTER} nor @var{TARGET} shall be
1503 @item @emph{Return value}:
1504 @code{ASSOCIATED(POINTER)} returns a scalar value of type @code{LOGICAL(4)}.
1505 There are several cases:
1507 @item (A) When the optional @var{TARGET} is not present then
1508 @code{ASSOCIATED(POINTER)} is true if @var{POINTER} is associated with a target; otherwise, it returns false.
1509 @item (B) If @var{TARGET} is present and a scalar target, the result is true if
1510 @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
1511 disassociated, the result is false.
1512 @item (C) If @var{TARGET} is present and an array target, the result is true if
1513 @var{TARGET} and @var{POINTER} have the same shape, are not zero-sized arrays,
1514 are arrays whose elements are not zero-sized storage sequences, and
1515 @var{TARGET} and @var{POINTER} occupy the same storage units in array element
1517 As in case(B), the result is false, if @var{POINTER} is disassociated.
1518 @item (D) If @var{TARGET} is present and an scalar pointer, the result is true
1519 if @var{TARGET} is associated with @var{POINTER}, the target associated with
1520 @var{TARGET} are not zero-sized storage sequences and occupy the same storage
1522 The result is false, if either @var{TARGET} or @var{POINTER} is disassociated.
1523 @item (E) If @var{TARGET} is present and an array pointer, the result is true if
1524 target associated with @var{POINTER} and the target associated with @var{TARGET}
1525 have the same shape, are not zero-sized arrays, are arrays whose elements are
1526 not zero-sized storage sequences, and @var{TARGET} and @var{POINTER} occupy
1527 the same storage units in array element order.
1528 The result is false, if either @var{TARGET} or @var{POINTER} is disassociated.
1531 @item @emph{Example}:
1533 program test_associated
1535 real, target :: tgt(2) = (/1., 2./)
1536 real, pointer :: ptr(:)
1538 if (associated(ptr) .eqv. .false.) call abort
1539 if (associated(ptr,tgt) .eqv. .false.) call abort
1540 end program test_associated
1543 @item @emph{See also}:
1550 @section @code{ATAN} --- Arctangent function
1553 @cindex trigonometric function, tangent, inverse
1554 @cindex tangent, inverse
1557 @item @emph{Description}:
1558 @code{ATAN(X)} computes the arctangent of @var{X}.
1560 @item @emph{Standard}:
1561 Fortran 77 and later, for a complex argument and for two arguments
1562 Fortran 2008 or later
1567 @item @emph{Syntax}:
1568 @multitable @columnfractions .80
1569 @item @code{RESULT = ATAN(X)}
1570 @item @code{RESULT = ATAN(Y, X)}
1573 @item @emph{Arguments}:
1574 @multitable @columnfractions .15 .70
1575 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX};
1576 if @var{Y} is present, @var{X} shall be REAL.
1577 @item @var{Y} @tab The type and kind type parameter shall be the same as @var{X}.
1580 @item @emph{Return value}:
1581 The return value is of the same type and kind as @var{X}.
1582 If @var{Y} is present, the result is identical to @code{ATAN2(Y,X)}.
1583 Otherwise, it the arcus tangent of @var{X}, where the real part of
1584 the result is in radians and lies in the range
1585 @math{-\pi/2 \leq \Re \atan(x) \leq \pi/2}.
1587 @item @emph{Example}:
1590 real(8) :: x = 2.866_8
1592 end program test_atan
1595 @item @emph{Specific names}:
1596 @multitable @columnfractions .20 .23 .20 .33
1597 @headitem Name @tab Argument @tab Return type @tab Standard
1598 @item @code{ATAN(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later
1599 @item @code{DATAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
1602 @item @emph{See also}:
1603 Inverse function: @*
1605 Degrees function: @*
1612 @section @code{ATAND} --- Arctangent function, degrees
1615 @cindex trigonometric function, tangent, inverse, degrees
1616 @cindex tangent, inverse, degrees
1619 @item @emph{Description}:
1620 @code{ATAND(X)} computes the arctangent of @var{X} in degrees (inverse of
1623 This function is for compatibility only and should be avoided in favor of
1624 standard constructs wherever possible.
1626 @item @emph{Standard}:
1627 GNU extension, enabled with @option{-fdec-math}.
1632 @item @emph{Syntax}:
1633 @multitable @columnfractions .80
1634 @item @code{RESULT = ATAND(X)}
1635 @item @code{RESULT = ATAND(Y, X)}
1638 @item @emph{Arguments}:
1639 @multitable @columnfractions .15 .70
1640 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX};
1641 if @var{Y} is present, @var{X} shall be REAL.
1642 @item @var{Y} @tab The type and kind type parameter shall be the same as @var{X}.
1645 @item @emph{Return value}:
1646 The return value is of the same type and kind as @var{X}.
1647 If @var{Y} is present, the result is identical to @code{ATAND2(Y,X)}.
1648 Otherwise, it is the arcus tangent of @var{X}, where the real part of
1649 the result is in degrees and lies in the range
1650 @math{-90 \leq \Re \atand(x) \leq 90}.
1652 @item @emph{Example}:
1655 real(8) :: x = 2.866_8
1657 end program test_atand
1660 @item @emph{Specific names}:
1661 @multitable @columnfractions .23 .23 .20 .30
1662 @headitem Name @tab Argument @tab Return type @tab Standard
1663 @item @code{ATAND(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU extension
1664 @item @code{DATAND(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1667 @item @emph{See also}:
1668 Inverse function: @*
1670 Radians function: @*
1677 @section @code{ATAN2} --- Arctangent function
1680 @cindex trigonometric function, tangent, inverse
1681 @cindex tangent, inverse
1684 @item @emph{Description}:
1685 @code{ATAN2(Y, X)} computes the principal value of the argument
1686 function of the complex number @math{X + i Y}. This function can
1687 be used to transform from Cartesian into polar coordinates and
1688 allows to determine the angle in the correct quadrant.
1690 @item @emph{Standard}:
1691 Fortran 77 and later
1696 @item @emph{Syntax}:
1697 @code{RESULT = ATAN2(Y, X)}
1699 @item @emph{Arguments}:
1700 @multitable @columnfractions .15 .70
1701 @item @var{Y} @tab The type shall be @code{REAL}.
1702 @item @var{X} @tab The type and kind type parameter shall be the same as @var{Y}.
1703 If @var{Y} is zero, then @var{X} must be nonzero.
1706 @item @emph{Return value}:
1707 The return value has the same type and kind type parameter as @var{Y}. It
1708 is the principal value of the complex number @math{X + i Y}. If @var{X}
1709 is nonzero, then it lies in the range @math{-\pi \le \atan (x) \leq \pi}.
1710 The sign is positive if @var{Y} is positive. If @var{Y} is zero, then
1711 the return value is zero if @var{X} is strictly positive, @math{\pi} if
1712 @var{X} is negative and @var{Y} is positive zero (or the processor does
1713 not handle signed zeros), and @math{-\pi} if @var{X} is negative and
1714 @var{Y} is negative zero. Finally, if @var{X} is zero, then the
1715 magnitude of the result is @math{\pi/2}.
1717 @item @emph{Example}:
1720 real(4) :: x = 1.e0_4, y = 0.5e0_4
1722 end program test_atan2
1725 @item @emph{Specific names}:
1726 @multitable @columnfractions .22 .22 .20 .32
1727 @headitem Name @tab Argument @tab Return type @tab Standard
1728 @item @code{ATAN2(X, Y)} @tab @code{REAL(4) X, Y} @tab @code{REAL(4)} @tab Fortran 77 and later
1729 @item @code{DATAN2(X, Y)} @tab @code{REAL(8) X, Y} @tab @code{REAL(8)} @tab Fortran 77 and later
1732 @item @emph{See also}:
1735 Degrees function: @*
1742 @section @code{ATAN2D} --- Arctangent function, degrees
1745 @cindex trigonometric function, tangent, inverse, degrees
1746 @cindex tangent, inverse, degrees
1749 @item @emph{Description}:
1750 @code{ATAN2D(Y, X)} computes the principal value of the argument
1751 function of the complex number @math{X + i Y} in degrees. This function can
1752 be used to transform from Cartesian into polar coordinates and
1753 allows to determine the angle in the correct quadrant.
1755 This function is for compatibility only and should be avoided in favor of
1756 standard constructs wherever possible.
1758 @item @emph{Standard}:
1759 GNU extension, enabled with @option{-fdec-math}.
1764 @item @emph{Syntax}:
1765 @code{RESULT = ATAN2D(Y, X)}
1767 @item @emph{Arguments}:
1768 @multitable @columnfractions .15 .70
1769 @item @var{Y} @tab The type shall be @code{REAL}.
1770 @item @var{X} @tab The type and kind type parameter shall be the same as @var{Y}.
1771 If @var{Y} is zero, then @var{X} must be nonzero.
1774 @item @emph{Return value}:
1775 The return value has the same type and kind type parameter as @var{Y}. It
1776 is the principal value of the complex number @math{X + i Y}. If @var{X}
1777 is nonzero, then it lies in the range @math{-180 \le \atan (x) \leq 180}.
1778 The sign is positive if @var{Y} is positive. If @var{Y} is zero, then
1779 the return value is zero if @var{X} is strictly positive, @math{180} if
1780 @var{X} is negative and @var{Y} is positive zero (or the processor does
1781 not handle signed zeros), and @math{-180} if @var{X} is negative and
1782 @var{Y} is negative zero. Finally, if @var{X} is zero, then the
1783 magnitude of the result is @math{90}.
1785 @item @emph{Example}:
1788 real(4) :: x = 1.e0_4, y = 0.5e0_4
1790 end program test_atan2d
1793 @item @emph{Specific names}:
1794 @multitable @columnfractions .23 .23 .20 .30
1795 @headitem Name @tab Argument @tab Return type @tab Standard
1796 @item @code{ATAN2D(X, Y)} @tab @code{REAL(4) X, Y} @tab @code{REAL(4)} @tab GNU extension
1797 @item @code{DATAN2D(X, Y)} @tab @code{REAL(8) X, Y} @tab @code{REAL(8)} @tab GNU extension
1800 @item @emph{See also}:
1803 Radians function: @*
1810 @section @code{ATANH} --- Inverse hyperbolic tangent function
1813 @cindex area hyperbolic tangent
1814 @cindex inverse hyperbolic tangent
1815 @cindex hyperbolic function, tangent, inverse
1816 @cindex tangent, hyperbolic, inverse
1819 @item @emph{Description}:
1820 @code{ATANH(X)} computes the inverse hyperbolic tangent of @var{X}.
1822 @item @emph{Standard}:
1823 Fortran 2008 and later
1828 @item @emph{Syntax}:
1829 @code{RESULT = ATANH(X)}
1831 @item @emph{Arguments}:
1832 @multitable @columnfractions .15 .70
1833 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
1836 @item @emph{Return value}:
1837 The return value has same type and kind as @var{X}. If @var{X} is
1838 complex, the imaginary part of the result is in radians and lies between
1839 @math{-\pi/2 \leq \Im \atanh(x) \leq \pi/2}.
1841 @item @emph{Example}:
1844 REAL, DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1845 WRITE (*,*) ATANH(x)
1849 @item @emph{Specific names}:
1850 @multitable @columnfractions .20 .23 .20 .33
1851 @headitem Name @tab Argument @tab Return type @tab Standard
1852 @item @code{DATANH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1855 @item @emph{See also}:
1856 Inverse function: @*
1863 @section @code{ATOMIC_ADD} --- Atomic ADD operation
1865 @cindex Atomic subroutine, add
1868 @item @emph{Description}:
1869 @code{ATOMIC_ADD(ATOM, VALUE)} atomically adds the value of @var{VALUE} to the
1870 variable @var{ATOM}. When @var{STAT} is present and the invocation was
1871 successful, it is assigned the value 0. If it is present and the invocation
1872 has failed, it is assigned a positive value; in particular, for a coindexed
1873 @var{ATOM}, if the remote image has stopped, it is assigned the value of
1874 @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has
1875 failed, the value @code{STAT_FAILED_IMAGE}.
1877 @item @emph{Standard}:
1883 @item @emph{Syntax}:
1884 @code{CALL ATOMIC_ADD (ATOM, VALUE [, STAT])}
1886 @item @emph{Arguments}:
1887 @multitable @columnfractions .15 .70
1888 @item @var{ATOM} @tab Scalar coarray or coindexed variable of integer
1889 type with @code{ATOMIC_INT_KIND} kind.
1890 @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind
1891 is different, the value is converted to the kind of @var{ATOM}.
1892 @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
1895 @item @emph{Example}:
1899 integer(atomic_int_kind) :: atom[*]
1900 call atomic_add (atom[1], this_image())
1904 @item @emph{See also}:
1905 @ref{ATOMIC_DEFINE}, @*
1906 @ref{ATOMIC_FETCH_ADD}, @*
1907 @ref{ISO_FORTRAN_ENV}, @*
1908 @ref{ATOMIC_AND}, @*
1917 @section @code{ATOMIC_AND} --- Atomic bitwise AND operation
1919 @cindex Atomic subroutine, AND
1922 @item @emph{Description}:
1923 @code{ATOMIC_AND(ATOM, VALUE)} atomically defines @var{ATOM} with the bitwise
1924 AND between the values of @var{ATOM} and @var{VALUE}. When @var{STAT} is present
1925 and the invocation was successful, it is assigned the value 0. If it is present
1926 and the invocation has failed, it is assigned a positive value; in particular,
1927 for a coindexed @var{ATOM}, if the remote image has stopped, it is assigned the
1928 value of @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote
1929 image has failed, the value @code{STAT_FAILED_IMAGE}.
1931 @item @emph{Standard}:
1937 @item @emph{Syntax}:
1938 @code{CALL ATOMIC_AND (ATOM, VALUE [, STAT])}
1940 @item @emph{Arguments}:
1941 @multitable @columnfractions .15 .70
1942 @item @var{ATOM} @tab Scalar coarray or coindexed variable of integer
1943 type with @code{ATOMIC_INT_KIND} kind.
1944 @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind
1945 is different, the value is converted to the kind of @var{ATOM}.
1946 @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
1949 @item @emph{Example}:
1953 integer(atomic_int_kind) :: atom[*]
1954 call atomic_and (atom[1], int(b'10100011101'))
1958 @item @emph{See also}:
1959 @ref{ATOMIC_DEFINE}, @*
1960 @ref{ATOMIC_FETCH_AND}, @*
1961 @ref{ISO_FORTRAN_ENV}, @*
1962 @ref{ATOMIC_ADD}, @*
1970 @section @code{ATOMIC_CAS} --- Atomic compare and swap
1971 @fnindex ATOMIC_DEFINE
1972 @cindex Atomic subroutine, compare and swap
1975 @item @emph{Description}:
1976 @code{ATOMIC_CAS} compares the variable @var{ATOM} with the value of
1977 @var{COMPARE}; if the value is the same, @var{ATOM} is set to the value
1978 of @var{NEW}. Additionally, @var{OLD} is set to the value of @var{ATOM}
1979 that was used for the comparison. When @var{STAT} is present and the invocation
1980 was successful, it is assigned the value 0. If it is present and the invocation
1981 has failed, it is assigned a positive value; in particular, for a coindexed
1982 @var{ATOM}, if the remote image has stopped, it is assigned the value of
1983 @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has
1984 failed, the value @code{STAT_FAILED_IMAGE}.
1986 @item @emph{Standard}:
1992 @item @emph{Syntax}:
1993 @code{CALL ATOMIC_CAS (ATOM, OLD, COMPARE, NEW [, STAT])}
1995 @item @emph{Arguments}:
1996 @multitable @columnfractions .15 .70
1997 @item @var{ATOM} @tab Scalar coarray or coindexed variable of either integer
1998 type with @code{ATOMIC_INT_KIND} kind or logical type with
1999 @code{ATOMIC_LOGICAL_KIND} kind.
2000 @item @var{OLD} @tab Scalar of the same type and kind as @var{ATOM}.
2001 @item @var{COMPARE} @tab Scalar variable of the same type and kind as
2003 @item @var{NEW} @tab Scalar variable of the same type as @var{ATOM}. If kind
2004 is different, the value is converted to the kind of @var{ATOM}.
2005 @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
2008 @item @emph{Example}:
2012 logical(atomic_logical_kind) :: atom[*], prev
2013 call atomic_cas (atom[1], prev, .false., .true.))
2017 @item @emph{See also}:
2018 @ref{ATOMIC_DEFINE}, @*
2019 @ref{ATOMIC_REF}, @*
2020 @ref{ISO_FORTRAN_ENV}
2026 @section @code{ATOMIC_DEFINE} --- Setting a variable atomically
2027 @fnindex ATOMIC_DEFINE
2028 @cindex Atomic subroutine, define
2031 @item @emph{Description}:
2032 @code{ATOMIC_DEFINE(ATOM, VALUE)} defines the variable @var{ATOM} with the value
2033 @var{VALUE} atomically. When @var{STAT} is present and the invocation was
2034 successful, it is assigned the value 0. If it is present and the invocation
2035 has failed, it is assigned a positive value; in particular, for a coindexed
2036 @var{ATOM}, if the remote image has stopped, it is assigned the value of
2037 @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has
2038 failed, the value @code{STAT_FAILED_IMAGE}.
2040 @item @emph{Standard}:
2041 Fortran 2008 and later; with @var{STAT}, TS 18508 or later
2046 @item @emph{Syntax}:
2047 @code{CALL ATOMIC_DEFINE (ATOM, VALUE [, STAT])}
2049 @item @emph{Arguments}:
2050 @multitable @columnfractions .15 .70
2051 @item @var{ATOM} @tab Scalar coarray or coindexed variable of either integer
2052 type with @code{ATOMIC_INT_KIND} kind or logical type with
2053 @code{ATOMIC_LOGICAL_KIND} kind.
2055 @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind
2056 is different, the value is converted to the kind of @var{ATOM}.
2057 @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
2060 @item @emph{Example}:
2064 integer(atomic_int_kind) :: atom[*]
2065 call atomic_define (atom[1], this_image())
2069 @item @emph{See also}:
2070 @ref{ATOMIC_REF}, @*
2071 @ref{ATOMIC_CAS}, @*
2072 @ref{ISO_FORTRAN_ENV}, @*
2073 @ref{ATOMIC_ADD}, @*
2074 @ref{ATOMIC_AND}, @*
2081 @node ATOMIC_FETCH_ADD
2082 @section @code{ATOMIC_FETCH_ADD} --- Atomic ADD operation with prior fetch
2083 @fnindex ATOMIC_FETCH_ADD
2084 @cindex Atomic subroutine, ADD with fetch
2087 @item @emph{Description}:
2088 @code{ATOMIC_FETCH_ADD(ATOM, VALUE, OLD)} atomically stores the value of
2089 @var{ATOM} in @var{OLD} and adds the value of @var{VALUE} to the
2090 variable @var{ATOM}. When @var{STAT} is present and the invocation was
2091 successful, it is assigned the value 0. If it is present and the invocation
2092 has failed, it is assigned a positive value; in particular, for a coindexed
2093 @var{ATOM}, if the remote image has stopped, it is assigned the value of
2094 @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has
2095 failed, the value @code{STAT_FAILED_IMAGE}.
2097 @item @emph{Standard}:
2103 @item @emph{Syntax}:
2104 @code{CALL ATOMIC_FETCH_ADD (ATOM, VALUE, old [, STAT])}
2106 @item @emph{Arguments}:
2107 @multitable @columnfractions .15 .70
2108 @item @var{ATOM} @tab Scalar coarray or coindexed variable of integer
2109 type with @code{ATOMIC_INT_KIND} kind.
2110 @code{ATOMIC_LOGICAL_KIND} kind.
2112 @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind
2113 is different, the value is converted to the kind of @var{ATOM}.
2114 @item @var{OLD} @tab Scalar of the same type and kind as @var{ATOM}.
2115 @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
2118 @item @emph{Example}:
2122 integer(atomic_int_kind) :: atom[*], old
2123 call atomic_add (atom[1], this_image(), old)
2127 @item @emph{See also}:
2128 @ref{ATOMIC_DEFINE}, @*
2129 @ref{ATOMIC_ADD}, @*
2130 @ref{ISO_FORTRAN_ENV}, @*
2131 @ref{ATOMIC_FETCH_AND}, @*
2132 @ref{ATOMIC_FETCH_OR}, @*
2133 @ref{ATOMIC_FETCH_XOR}
2138 @node ATOMIC_FETCH_AND
2139 @section @code{ATOMIC_FETCH_AND} --- Atomic bitwise AND operation with prior fetch
2140 @fnindex ATOMIC_FETCH_AND
2141 @cindex Atomic subroutine, AND with fetch
2144 @item @emph{Description}:
2145 @code{ATOMIC_AND(ATOM, VALUE)} atomically stores the value of @var{ATOM} in
2146 @var{OLD} and defines @var{ATOM} with the bitwise AND between the values of
2147 @var{ATOM} and @var{VALUE}. When @var{STAT} is present and the invocation was
2148 successful, it is assigned the value 0. If it is present and the invocation has
2149 failed, it is assigned a positive value; in particular, for a coindexed
2150 @var{ATOM}, if the remote image has stopped, it is assigned the value of
2151 @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has
2152 failed, the value @code{STAT_FAILED_IMAGE}.
2154 @item @emph{Standard}:
2160 @item @emph{Syntax}:
2161 @code{CALL ATOMIC_FETCH_AND (ATOM, VALUE, OLD [, STAT])}
2163 @item @emph{Arguments}:
2164 @multitable @columnfractions .15 .70
2165 @item @var{ATOM} @tab Scalar coarray or coindexed variable of integer
2166 type with @code{ATOMIC_INT_KIND} kind.
2167 @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind
2168 is different, the value is converted to the kind of @var{ATOM}.
2169 @item @var{OLD} @tab Scalar of the same type and kind as @var{ATOM}.
2170 @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
2173 @item @emph{Example}:
2177 integer(atomic_int_kind) :: atom[*], old
2178 call atomic_fetch_and (atom[1], int(b'10100011101'), old)
2182 @item @emph{See also}:
2183 @ref{ATOMIC_DEFINE}, @*
2184 @ref{ATOMIC_AND}, @*
2185 @ref{ISO_FORTRAN_ENV}, @*
2186 @ref{ATOMIC_FETCH_ADD}, @*
2187 @ref{ATOMIC_FETCH_OR}, @*
2188 @ref{ATOMIC_FETCH_XOR}
2193 @node ATOMIC_FETCH_OR
2194 @section @code{ATOMIC_FETCH_OR} --- Atomic bitwise OR operation with prior fetch
2195 @fnindex ATOMIC_FETCH_OR
2196 @cindex Atomic subroutine, OR with fetch
2199 @item @emph{Description}:
2200 @code{ATOMIC_OR(ATOM, VALUE)} atomically stores the value of @var{ATOM} in
2201 @var{OLD} and defines @var{ATOM} with the bitwise OR between the values of
2202 @var{ATOM} and @var{VALUE}. When @var{STAT} is present and the invocation was
2203 successful, it is assigned the value 0. If it is present and the invocation has
2204 failed, it is assigned a positive value; in particular, for a coindexed
2205 @var{ATOM}, if the remote image has stopped, it is assigned the value of
2206 @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has
2207 failed, the value @code{STAT_FAILED_IMAGE}.
2209 @item @emph{Standard}:
2215 @item @emph{Syntax}:
2216 @code{CALL ATOMIC_FETCH_OR (ATOM, VALUE, OLD [, STAT])}
2218 @item @emph{Arguments}:
2219 @multitable @columnfractions .15 .70
2220 @item @var{ATOM} @tab Scalar coarray or coindexed variable of integer
2221 type with @code{ATOMIC_INT_KIND} kind.
2222 @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind
2223 is different, the value is converted to the kind of @var{ATOM}.
2224 @item @var{OLD} @tab Scalar of the same type and kind as @var{ATOM}.
2225 @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
2228 @item @emph{Example}:
2232 integer(atomic_int_kind) :: atom[*], old
2233 call atomic_fetch_or (atom[1], int(b'10100011101'), old)
2237 @item @emph{See also}:
2238 @ref{ATOMIC_DEFINE}, @*
2240 @ref{ISO_FORTRAN_ENV}, @*
2241 @ref{ATOMIC_FETCH_ADD}, @*
2242 @ref{ATOMIC_FETCH_AND}, @*
2243 @ref{ATOMIC_FETCH_XOR}
2248 @node ATOMIC_FETCH_XOR
2249 @section @code{ATOMIC_FETCH_XOR} --- Atomic bitwise XOR operation with prior fetch
2250 @fnindex ATOMIC_FETCH_XOR
2251 @cindex Atomic subroutine, XOR with fetch
2254 @item @emph{Description}:
2255 @code{ATOMIC_XOR(ATOM, VALUE)} atomically stores the value of @var{ATOM} in
2256 @var{OLD} and defines @var{ATOM} with the bitwise XOR between the values of
2257 @var{ATOM} and @var{VALUE}. When @var{STAT} is present and the invocation was
2258 successful, it is assigned the value 0. If it is present and the invocation has
2259 failed, it is assigned a positive value; in particular, for a coindexed
2260 @var{ATOM}, if the remote image has stopped, it is assigned the value of
2261 @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has
2262 failed, the value @code{STAT_FAILED_IMAGE}.
2264 @item @emph{Standard}:
2270 @item @emph{Syntax}:
2271 @code{CALL ATOMIC_FETCH_XOR (ATOM, VALUE, OLD [, STAT])}
2273 @item @emph{Arguments}:
2274 @multitable @columnfractions .15 .70
2275 @item @var{ATOM} @tab Scalar coarray or coindexed variable of integer
2276 type with @code{ATOMIC_INT_KIND} kind.
2277 @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind
2278 is different, the value is converted to the kind of @var{ATOM}.
2279 @item @var{OLD} @tab Scalar of the same type and kind as @var{ATOM}.
2280 @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
2283 @item @emph{Example}:
2287 integer(atomic_int_kind) :: atom[*], old
2288 call atomic_fetch_xor (atom[1], int(b'10100011101'), old)
2292 @item @emph{See also}:
2293 @ref{ATOMIC_DEFINE}, @*
2294 @ref{ATOMIC_XOR}, @*
2295 @ref{ISO_FORTRAN_ENV}, @*
2296 @ref{ATOMIC_FETCH_ADD}, @*
2297 @ref{ATOMIC_FETCH_AND}, @*
2298 @ref{ATOMIC_FETCH_OR}
2304 @section @code{ATOMIC_OR} --- Atomic bitwise OR operation
2306 @cindex Atomic subroutine, OR
2309 @item @emph{Description}:
2310 @code{ATOMIC_OR(ATOM, VALUE)} atomically defines @var{ATOM} with the bitwise
2311 AND between the values of @var{ATOM} and @var{VALUE}. When @var{STAT} is present
2312 and the invocation was successful, it is assigned the value 0. If it is present
2313 and the invocation has failed, it is assigned a positive value; in particular,
2314 for a coindexed @var{ATOM}, if the remote image has stopped, it is assigned the
2315 value of @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote
2316 image has failed, the value @code{STAT_FAILED_IMAGE}.
2318 @item @emph{Standard}:
2324 @item @emph{Syntax}:
2325 @code{CALL ATOMIC_OR (ATOM, VALUE [, STAT])}
2327 @item @emph{Arguments}:
2328 @multitable @columnfractions .15 .70
2329 @item @var{ATOM} @tab Scalar coarray or coindexed variable of integer
2330 type with @code{ATOMIC_INT_KIND} kind.
2331 @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind
2332 is different, the value is converted to the kind of @var{ATOM}.
2333 @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
2336 @item @emph{Example}:
2340 integer(atomic_int_kind) :: atom[*]
2341 call atomic_or (atom[1], int(b'10100011101'))
2345 @item @emph{See also}:
2346 @ref{ATOMIC_DEFINE}, @*
2347 @ref{ATOMIC_FETCH_OR}, @*
2348 @ref{ISO_FORTRAN_ENV}, @*
2349 @ref{ATOMIC_ADD}, @*
2357 @section @code{ATOMIC_REF} --- Obtaining the value of a variable atomically
2359 @cindex Atomic subroutine, reference
2362 @item @emph{Description}:
2363 @code{ATOMIC_DEFINE(ATOM, VALUE)} atomically assigns the value of the
2364 variable @var{ATOM} to @var{VALUE}. When @var{STAT} is present and the
2365 invocation was successful, it is assigned the value 0. If it is present and the
2366 invocation has failed, it is assigned a positive value; in particular, for a
2367 coindexed @var{ATOM}, if the remote image has stopped, it is assigned the value
2368 of @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image
2369 has failed, the value @code{STAT_FAILED_IMAGE}.
2372 @item @emph{Standard}:
2373 Fortran 2008 and later; with @var{STAT}, TS 18508 or later
2378 @item @emph{Syntax}:
2379 @code{CALL ATOMIC_REF(VALUE, ATOM [, STAT])}
2381 @item @emph{Arguments}:
2382 @multitable @columnfractions .15 .70
2383 @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind
2384 is different, the value is converted to the kind of @var{ATOM}.
2385 @item @var{ATOM} @tab Scalar coarray or coindexed variable of either integer
2386 type with @code{ATOMIC_INT_KIND} kind or logical type with
2387 @code{ATOMIC_LOGICAL_KIND} kind.
2388 @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
2391 @item @emph{Example}:
2395 logical(atomic_logical_kind) :: atom[*]
2397 call atomic_ref (atom, .false.)
2399 call atomic_ref (atom, val)
2406 @item @emph{See also}:
2407 @ref{ATOMIC_DEFINE}, @*
2408 @ref{ATOMIC_CAS}, @*
2409 @ref{ISO_FORTRAN_ENV}, @*
2410 @ref{ATOMIC_FETCH_ADD}, @*
2411 @ref{ATOMIC_FETCH_AND}, @*
2412 @ref{ATOMIC_FETCH_OR}, @*
2413 @ref{ATOMIC_FETCH_XOR}
2418 @section @code{ATOMIC_XOR} --- Atomic bitwise OR operation
2420 @cindex Atomic subroutine, XOR
2423 @item @emph{Description}:
2424 @code{ATOMIC_AND(ATOM, VALUE)} atomically defines @var{ATOM} with the bitwise
2425 XOR between the values of @var{ATOM} and @var{VALUE}. When @var{STAT} is present
2426 and the invocation was successful, it is assigned the value 0. If it is present
2427 and the invocation has failed, it is assigned a positive value; in particular,
2428 for a coindexed @var{ATOM}, if the remote image has stopped, it is assigned the
2429 value of @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote
2430 image has failed, the value @code{STAT_FAILED_IMAGE}.
2432 @item @emph{Standard}:
2438 @item @emph{Syntax}:
2439 @code{CALL ATOMIC_XOR (ATOM, VALUE [, STAT])}
2441 @item @emph{Arguments}:
2442 @multitable @columnfractions .15 .70
2443 @item @var{ATOM} @tab Scalar coarray or coindexed variable of integer
2444 type with @code{ATOMIC_INT_KIND} kind.
2445 @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind
2446 is different, the value is converted to the kind of @var{ATOM}.
2447 @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
2450 @item @emph{Example}:
2454 integer(atomic_int_kind) :: atom[*]
2455 call atomic_xor (atom[1], int(b'10100011101'))
2459 @item @emph{See also}:
2460 @ref{ATOMIC_DEFINE}, @*
2461 @ref{ATOMIC_FETCH_XOR}, @*
2462 @ref{ISO_FORTRAN_ENV}, @*
2463 @ref{ATOMIC_ADD}, @*
2470 @section @code{BACKTRACE} --- Show a backtrace
2475 @item @emph{Description}:
2476 @code{BACKTRACE} shows a backtrace at an arbitrary place in user code. Program
2477 execution continues normally afterwards. The backtrace information is printed
2478 to the unit corresponding to @code{ERROR_UNIT} in @code{ISO_FORTRAN_ENV}.
2480 @item @emph{Standard}:
2486 @item @emph{Syntax}:
2487 @code{CALL BACKTRACE}
2489 @item @emph{Arguments}:
2492 @item @emph{See also}:
2499 @section @code{BESSEL_J0} --- Bessel function of the first kind of order 0
2503 @cindex Bessel function, first kind
2506 @item @emph{Description}:
2507 @code{BESSEL_J0(X)} computes the Bessel function of the first kind of
2508 order 0 of @var{X}. This function is available under the name
2509 @code{BESJ0} as a GNU extension.
2511 @item @emph{Standard}:
2512 Fortran 2008 and later
2517 @item @emph{Syntax}:
2518 @code{RESULT = BESSEL_J0(X)}
2520 @item @emph{Arguments}:
2521 @multitable @columnfractions .15 .70
2522 @item @var{X} @tab The type shall be @code{REAL}.
2525 @item @emph{Return value}:
2526 The return value is of type @code{REAL} and lies in the
2527 range @math{ - 0.4027... \leq Bessel (0,x) \leq 1}. It has the same
2530 @item @emph{Example}:
2533 real(8) :: x = 0.0_8
2535 end program test_besj0
2538 @item @emph{Specific names}:
2539 @multitable @columnfractions .21 .22 .20 .33
2540 @headitem Name @tab Argument @tab Return type @tab Standard
2541 @item @code{DBESJ0(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
2548 @section @code{BESSEL_J1} --- Bessel function of the first kind of order 1
2552 @cindex Bessel function, first kind
2555 @item @emph{Description}:
2556 @code{BESSEL_J1(X)} computes the Bessel function of the first kind of
2557 order 1 of @var{X}. This function is available under the name
2558 @code{BESJ1} as a GNU extension.
2560 @item @emph{Standard}:
2566 @item @emph{Syntax}:
2567 @code{RESULT = BESSEL_J1(X)}
2569 @item @emph{Arguments}:
2570 @multitable @columnfractions .15 .70
2571 @item @var{X} @tab The type shall be @code{REAL}.
2574 @item @emph{Return value}:
2575 The return value is of type @code{REAL} and lies in the
2576 range @math{ - 0.5818... \leq Bessel (0,x) \leq 0.5818 }. It has the same
2579 @item @emph{Example}:
2582 real(8) :: x = 1.0_8
2584 end program test_besj1
2587 @item @emph{Specific names}:
2588 @multitable @columnfractions .20 .23 .20 .33
2589 @headitem Name @tab Argument @tab Return type @tab Standard
2590 @item @code{DBESJ1(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
2597 @section @code{BESSEL_JN} --- Bessel function of the first kind
2601 @cindex Bessel function, first kind
2604 @item @emph{Description}:
2605 @code{BESSEL_JN(N, X)} computes the Bessel function of the first kind of
2606 order @var{N} of @var{X}. This function is available under the name
2607 @code{BESJN} as a GNU extension. If @var{N} and @var{X} are arrays,
2608 their ranks and shapes shall conform.
2610 @code{BESSEL_JN(N1, N2, X)} returns an array with the Bessel functions
2611 of the first kind of the orders @var{N1} to @var{N2}.
2613 @item @emph{Standard}:
2614 Fortran 2008 and later, negative @var{N} is allowed as GNU extension
2617 Elemental function, except for the transformational function
2618 @code{BESSEL_JN(N1, N2, X)}
2620 @item @emph{Syntax}:
2621 @multitable @columnfractions .80
2622 @item @code{RESULT = BESSEL_JN(N, X)}
2623 @item @code{RESULT = BESSEL_JN(N1, N2, X)}
2626 @item @emph{Arguments}:
2627 @multitable @columnfractions .15 .70
2628 @item @var{N} @tab Shall be a scalar or an array of type @code{INTEGER}.
2629 @item @var{N1} @tab Shall be a non-negative scalar of type @code{INTEGER}.
2630 @item @var{N2} @tab Shall be a non-negative scalar of type @code{INTEGER}.
2631 @item @var{X} @tab Shall be a scalar or an array of type @code{REAL};
2632 for @code{BESSEL_JN(N1, N2, X)} it shall be scalar.
2635 @item @emph{Return value}:
2636 The return value is a scalar of type @code{REAL}. It has the same
2640 The transformational function uses a recurrence algorithm which might,
2641 for some values of @var{X}, lead to different results than calls to
2642 the elemental function.
2644 @item @emph{Example}:
2647 real(8) :: x = 1.0_8
2649 end program test_besjn
2652 @item @emph{Specific names}:
2653 @multitable @columnfractions .22 .22 .20 .32
2654 @headitem Name @tab Argument @tab Return type @tab Standard
2655 @item @code{DBESJN(N, X)} @tab @code{INTEGER N} @tab @code{REAL(8)} @tab GNU extension
2656 @item @tab @code{REAL(8) X} @tab @tab
2663 @section @code{BESSEL_Y0} --- Bessel function of the second kind of order 0
2667 @cindex Bessel function, second kind
2670 @item @emph{Description}:
2671 @code{BESSEL_Y0(X)} computes the Bessel function of the second kind of
2672 order 0 of @var{X}. This function is available under the name
2673 @code{BESY0} as a GNU extension.
2675 @item @emph{Standard}:
2676 Fortran 2008 and later
2681 @item @emph{Syntax}:
2682 @code{RESULT = BESSEL_Y0(X)}
2684 @item @emph{Arguments}:
2685 @multitable @columnfractions .15 .70
2686 @item @var{X} @tab The type shall be @code{REAL}.
2689 @item @emph{Return value}:
2690 The return value is of type @code{REAL}. It has the same kind as @var{X}.
2692 @item @emph{Example}:
2695 real(8) :: x = 0.0_8
2697 end program test_besy0
2700 @item @emph{Specific names}:
2701 @multitable @columnfractions .20 .23 .20 .33
2702 @headitem Name @tab Argument @tab Return type @tab Standard
2703 @item @code{DBESY0(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
2710 @section @code{BESSEL_Y1} --- Bessel function of the second kind of order 1
2714 @cindex Bessel function, second kind
2717 @item @emph{Description}:
2718 @code{BESSEL_Y1(X)} computes the Bessel function of the second kind of
2719 order 1 of @var{X}. This function is available under the name
2720 @code{BESY1} as a GNU extension.
2722 @item @emph{Standard}:
2723 Fortran 2008 and later
2728 @item @emph{Syntax}:
2729 @code{RESULT = BESSEL_Y1(X)}
2731 @item @emph{Arguments}:
2732 @multitable @columnfractions .15 .70
2733 @item @var{X} @tab The type shall be @code{REAL}.
2736 @item @emph{Return value}:
2737 The return value is of type @code{REAL}. It has the same kind as @var{X}.
2739 @item @emph{Example}:
2742 real(8) :: x = 1.0_8
2744 end program test_besy1
2747 @item @emph{Specific names}:
2748 @multitable @columnfractions .20 .23 .20 .33
2749 @headitem Name @tab Argument @tab Return type @tab Standard
2750 @item @code{DBESY1(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
2757 @section @code{BESSEL_YN} --- Bessel function of the second kind
2761 @cindex Bessel function, second kind
2764 @item @emph{Description}:
2765 @code{BESSEL_YN(N, X)} computes the Bessel function of the second kind of
2766 order @var{N} of @var{X}. This function is available under the name
2767 @code{BESYN} as a GNU extension. If @var{N} and @var{X} are arrays,
2768 their ranks and shapes shall conform.
2770 @code{BESSEL_YN(N1, N2, X)} returns an array with the Bessel functions
2771 of the first kind of the orders @var{N1} to @var{N2}.
2773 @item @emph{Standard}:
2774 Fortran 2008 and later, negative @var{N} is allowed as GNU extension
2777 Elemental function, except for the transformational function
2778 @code{BESSEL_YN(N1, N2, X)}
2780 @item @emph{Syntax}:
2781 @multitable @columnfractions .80
2782 @item @code{RESULT = BESSEL_YN(N, X)}
2783 @item @code{RESULT = BESSEL_YN(N1, N2, X)}
2786 @item @emph{Arguments}:
2787 @multitable @columnfractions .15 .70
2788 @item @var{N} @tab Shall be a scalar or an array of type @code{INTEGER} .
2789 @item @var{N1} @tab Shall be a non-negative scalar of type @code{INTEGER}.
2790 @item @var{N2} @tab Shall be a non-negative scalar of type @code{INTEGER}.
2791 @item @var{X} @tab Shall be a scalar or an array of type @code{REAL};
2792 for @code{BESSEL_YN(N1, N2, X)} it shall be scalar.
2795 @item @emph{Return value}:
2796 The return value is a scalar of type @code{REAL}. It has the same
2800 The transformational function uses a recurrence algorithm which might,
2801 for some values of @var{X}, lead to different results than calls to
2802 the elemental function.
2804 @item @emph{Example}:
2807 real(8) :: x = 1.0_8
2809 end program test_besyn
2812 @item @emph{Specific names}:
2813 @multitable @columnfractions .20 .23 .20 .33
2814 @headitem Name @tab Argument @tab Return type @tab Standard
2815 @item @code{DBESYN(N,X)} @tab @code{INTEGER N} @tab @code{REAL(8)} @tab GNU extension
2816 @item @tab @code{REAL(8) X} @tab @tab
2823 @section @code{BGE} --- Bitwise greater than or equal to
2825 @cindex bitwise comparison
2828 @item @emph{Description}:
2829 Determines whether an integral is a bitwise greater than or equal to
2832 @item @emph{Standard}:
2833 Fortran 2008 and later
2838 @item @emph{Syntax}:
2839 @code{RESULT = BGE(I, J)}
2841 @item @emph{Arguments}:
2842 @multitable @columnfractions .15 .70
2843 @item @var{I} @tab Shall be of @code{INTEGER} type.
2844 @item @var{J} @tab Shall be of @code{INTEGER} type, and of the same kind
2848 @item @emph{Return value}:
2849 The return value is of type @code{LOGICAL} and of the default kind.
2851 @item @emph{See also}:
2860 @section @code{BGT} --- Bitwise greater than
2862 @cindex bitwise comparison
2865 @item @emph{Description}:
2866 Determines whether an integral is a bitwise greater than another.
2868 @item @emph{Standard}:
2869 Fortran 2008 and later
2874 @item @emph{Syntax}:
2875 @code{RESULT = BGT(I, J)}
2877 @item @emph{Arguments}:
2878 @multitable @columnfractions .15 .70
2879 @item @var{I} @tab Shall be of @code{INTEGER} type.
2880 @item @var{J} @tab Shall be of @code{INTEGER} type, and of the same kind
2884 @item @emph{Return value}:
2885 The return value is of type @code{LOGICAL} and of the default kind.
2887 @item @emph{See also}:
2896 @section @code{BIT_SIZE} --- Bit size inquiry function
2898 @cindex bits, number of
2899 @cindex size of a variable, in bits
2902 @item @emph{Description}:
2903 @code{BIT_SIZE(I)} returns the number of bits (integer precision plus sign bit)
2904 represented by the type of @var{I}. The result of @code{BIT_SIZE(I)} is
2905 independent of the actual value of @var{I}.
2907 @item @emph{Standard}:
2908 Fortran 90 and later
2913 @item @emph{Syntax}:
2914 @code{RESULT = BIT_SIZE(I)}
2916 @item @emph{Arguments}:
2917 @multitable @columnfractions .15 .70
2918 @item @var{I} @tab The type shall be @code{INTEGER}.
2921 @item @emph{Return value}:
2922 The return value is of type @code{INTEGER}
2924 @item @emph{Example}:
2926 program test_bit_size
2931 end program test_bit_size
2938 @section @code{BLE} --- Bitwise less than or equal to
2940 @cindex bitwise comparison
2943 @item @emph{Description}:
2944 Determines whether an integral is a bitwise less than or equal to
2947 @item @emph{Standard}:
2948 Fortran 2008 and later
2953 @item @emph{Syntax}:
2954 @code{RESULT = BLE(I, J)}
2956 @item @emph{Arguments}:
2957 @multitable @columnfractions .15 .70
2958 @item @var{I} @tab Shall be of @code{INTEGER} type.
2959 @item @var{J} @tab Shall be of @code{INTEGER} type, and of the same kind
2963 @item @emph{Return value}:
2964 The return value is of type @code{LOGICAL} and of the default kind.
2966 @item @emph{See also}:
2975 @section @code{BLT} --- Bitwise less than
2977 @cindex bitwise comparison
2980 @item @emph{Description}:
2981 Determines whether an integral is a bitwise less than another.
2983 @item @emph{Standard}:
2984 Fortran 2008 and later
2989 @item @emph{Syntax}:
2990 @code{RESULT = BLT(I, J)}
2992 @item @emph{Arguments}:
2993 @multitable @columnfractions .15 .70
2994 @item @var{I} @tab Shall be of @code{INTEGER} type.
2995 @item @var{J} @tab Shall be of @code{INTEGER} type, and of the same kind
2999 @item @emph{Return value}:
3000 The return value is of type @code{LOGICAL} and of the default kind.
3002 @item @emph{See also}:
3011 @section @code{BTEST} --- Bit test function
3017 @cindex bits, testing
3020 @item @emph{Description}:
3021 @code{BTEST(I,POS)} returns logical @code{.TRUE.} if the bit at @var{POS}
3022 in @var{I} is set. The counting of the bits starts at 0.
3024 @item @emph{Standard}:
3025 Fortran 90 and later, has overloads that are GNU extensions
3030 @item @emph{Syntax}:
3031 @code{RESULT = BTEST(I, POS)}
3033 @item @emph{Arguments}:
3034 @multitable @columnfractions .15 .70
3035 @item @var{I} @tab The type shall be @code{INTEGER}.
3036 @item @var{POS} @tab The type shall be @code{INTEGER}.
3039 @item @emph{Return value}:
3040 The return value is of type @code{LOGICAL}
3042 @item @emph{Example}:
3045 integer :: i = 32768 + 1024 + 64
3049 bool = btest(i, pos)
3052 end program test_btest
3055 @item @emph{Specific names}:
3056 @multitable @columnfractions .21 .28 .18 .30
3057 @headitem Name @tab Argument @tab Return type @tab Standard
3058 @item @code{BTEST(I,POS)} @tab @code{INTEGER I,POS} @tab @code{LOGICAL} @tab Fortran 95 and later
3059 @item @code{BBTEST(I,POS)} @tab @code{INTEGER(1) I,POS} @tab @code{LOGICAL(1)} @tab GNU extension
3060 @item @code{BITEST(I,POS)} @tab @code{INTEGER(2) I,POS} @tab @code{LOGICAL(2)} @tab GNU extension
3061 @item @code{BJTEST(I,POS)} @tab @code{INTEGER(4) I,POS} @tab @code{LOGICAL(4)} @tab GNU extension
3062 @item @code{BKTEST(I,POS)} @tab @code{INTEGER(8) I,POS} @tab @code{LOGICAL(8)} @tab GNU extension
3067 @section @code{C_ASSOCIATED} --- Status of a C pointer
3068 @fnindex C_ASSOCIATED
3069 @cindex association status, C pointer
3070 @cindex pointer, C association status
3073 @item @emph{Description}:
3074 @code{C_ASSOCIATED(c_ptr_1[, c_ptr_2])} determines the status of the C pointer
3075 @var{c_ptr_1} or if @var{c_ptr_1} is associated with the target @var{c_ptr_2}.
3077 @item @emph{Standard}:
3078 Fortran 2003 and later
3083 @item @emph{Syntax}:
3084 @code{RESULT = C_ASSOCIATED(c_ptr_1[, c_ptr_2])}
3086 @item @emph{Arguments}:
3087 @multitable @columnfractions .15 .70
3088 @item @var{c_ptr_1} @tab Scalar of the type @code{C_PTR} or @code{C_FUNPTR}.
3089 @item @var{c_ptr_2} @tab (Optional) Scalar of the same type as @var{c_ptr_1}.
3092 @item @emph{Return value}:
3093 The return value is of type @code{LOGICAL}; it is @code{.false.} if either
3094 @var{c_ptr_1} is a C NULL pointer or if @var{c_ptr1} and @var{c_ptr_2}
3095 point to different addresses.
3097 @item @emph{Example}:
3099 subroutine association_test(a,b)
3100 use iso_c_binding, only: c_associated, c_loc, c_ptr
3104 if(c_associated(b, c_loc(a))) &
3105 stop 'b and a do not point to same target'
3106 end subroutine association_test
3109 @item @emph{See also}:
3116 @section @code{C_F_POINTER} --- Convert C into Fortran pointer
3117 @fnindex C_F_POINTER
3118 @cindex pointer, convert C to Fortran
3121 @item @emph{Description}:
3122 @code{C_F_POINTER(CPTR, FPTR[, SHAPE])} assigns the target of the C pointer
3123 @var{CPTR} to the Fortran pointer @var{FPTR} and specifies its shape.
3125 @item @emph{Standard}:
3126 Fortran 2003 and later
3131 @item @emph{Syntax}:
3132 @code{CALL C_F_POINTER(CPTR, FPTR[, SHAPE])}
3134 @item @emph{Arguments}:
3135 @multitable @columnfractions .15 .70
3136 @item @var{CPTR} @tab scalar of the type @code{C_PTR}. It is
3138 @item @var{FPTR} @tab pointer interoperable with @var{cptr}. It is
3140 @item @var{SHAPE} @tab (Optional) Rank-one array of type @code{INTEGER}
3141 with @code{INTENT(IN)}. It shall be present
3142 if and only if @var{fptr} is an array. The size
3143 must be equal to the rank of @var{fptr}.
3146 @item @emph{Example}:
3152 subroutine my_routine(p) bind(c,name='myC_func')
3154 type(c_ptr), intent(out) :: p
3158 real,pointer :: a(:)
3159 call my_routine(cptr)
3160 call c_f_pointer(cptr, a, [12])
3164 @item @emph{See also}:
3166 @ref{C_F_PROCPOINTER}
3170 @node C_F_PROCPOINTER
3171 @section @code{C_F_PROCPOINTER} --- Convert C into Fortran procedure pointer
3172 @fnindex C_F_PROCPOINTER
3173 @cindex pointer, C address of pointers
3176 @item @emph{Description}:
3177 @code{C_F_PROCPOINTER(CPTR, FPTR)} Assign the target of the C function pointer
3178 @var{CPTR} to the Fortran procedure pointer @var{FPTR}.
3180 @item @emph{Standard}:
3181 Fortran 2003 and later
3186 @item @emph{Syntax}:
3187 @code{CALL C_F_PROCPOINTER(cptr, fptr)}
3189 @item @emph{Arguments}:
3190 @multitable @columnfractions .15 .70
3191 @item @var{CPTR} @tab scalar of the type @code{C_FUNPTR}. It is
3193 @item @var{FPTR} @tab procedure pointer interoperable with @var{cptr}. It is
3197 @item @emph{Example}:
3205 real(c_float), intent(in) :: a
3206 real(c_float) :: func
3210 function getIterFunc() bind(c,name="getIterFunc")
3212 type(c_funptr) :: getIterFunc
3215 type(c_funptr) :: cfunptr
3216 procedure(func), pointer :: myFunc
3217 cfunptr = getIterFunc()
3218 call c_f_procpointer(cfunptr, myFunc)
3222 @item @emph{See also}:
3229 @section @code{C_FUNLOC} --- Obtain the C address of a procedure
3231 @cindex pointer, C address of procedures
3234 @item @emph{Description}:
3235 @code{C_FUNLOC(x)} determines the C address of the argument.
3237 @item @emph{Standard}:
3238 Fortran 2003 and later
3243 @item @emph{Syntax}:
3244 @code{RESULT = C_FUNLOC(x)}
3246 @item @emph{Arguments}:
3247 @multitable @columnfractions .15 .70
3248 @item @var{x} @tab Interoperable function or pointer to such function.
3251 @item @emph{Return value}:
3252 The return value is of type @code{C_FUNPTR} and contains the C address
3255 @item @emph{Example}:
3261 subroutine sub(a) bind(c)
3271 subroutine my_routine(p) bind(c,name='myC_func')
3273 type(c_funptr), intent(in) :: p
3276 call my_routine(c_funloc(sub))
3280 @item @emph{See also}:
3281 @ref{C_ASSOCIATED}, @*
3283 @ref{C_F_POINTER}, @*
3284 @ref{C_F_PROCPOINTER}
3289 @section @code{C_LOC} --- Obtain the C address of an object
3291 @cindex procedure pointer, convert C to Fortran
3294 @item @emph{Description}:
3295 @code{C_LOC(X)} determines the C address of the argument.
3297 @item @emph{Standard}:
3298 Fortran 2003 and later
3303 @item @emph{Syntax}:
3304 @code{RESULT = C_LOC(X)}
3306 @item @emph{Arguments}:
3307 @multitable @columnfractions .10 .75
3308 @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.
3312 @item @emph{Return value}:
3313 The return value is of type @code{C_PTR} and contains the C address
3316 @item @emph{Example}:
3318 subroutine association_test(a,b)
3319 use iso_c_binding, only: c_associated, c_loc, c_ptr
3323 if(c_associated(b, c_loc(a))) &
3324 stop 'b and a do not point to same target'
3325 end subroutine association_test
3328 @item @emph{See also}:
3329 @ref{C_ASSOCIATED}, @*
3331 @ref{C_F_POINTER}, @*
3332 @ref{C_F_PROCPOINTER}
3337 @section @code{C_SIZEOF} --- Size in bytes of an expression
3339 @cindex expression size
3340 @cindex size of an expression
3343 @item @emph{Description}:
3344 @code{C_SIZEOF(X)} calculates the number of bytes of storage the
3345 expression @code{X} occupies.
3347 @item @emph{Standard}:
3351 Inquiry function of the module @code{ISO_C_BINDING}
3353 @item @emph{Syntax}:
3354 @code{N = C_SIZEOF(X)}
3356 @item @emph{Arguments}:
3357 @multitable @columnfractions .15 .70
3358 @item @var{X} @tab The argument shall be an interoperable data entity.
3361 @item @emph{Return value}:
3362 The return value is of type integer and of the system-dependent kind
3363 @code{C_SIZE_T} (from the @code{ISO_C_BINDING} module). Its value is the
3364 number of bytes occupied by the argument. If the argument has the
3365 @code{POINTER} attribute, the number of bytes of the storage area pointed
3366 to is returned. If the argument is of a derived type with @code{POINTER}
3367 or @code{ALLOCATABLE} components, the return value does not account for
3368 the sizes of the data pointed to by these components.
3370 @item @emph{Example}:
3374 real(c_float) :: r, s(5)
3375 print *, (c_sizeof(s)/c_sizeof(r) == 5)
3378 The example will print @code{T} unless you are using a platform
3379 where default @code{REAL} variables are unusually padded.
3381 @item @emph{See also}:
3388 @section @code{CEILING} --- Integer ceiling function
3391 @cindex rounding, ceiling
3394 @item @emph{Description}:
3395 @code{CEILING(A)} returns the least integer greater than or equal to @var{A}.
3397 @item @emph{Standard}:
3398 Fortran 95 and later
3403 @item @emph{Syntax}:
3404 @code{RESULT = CEILING(A [, KIND])}
3406 @item @emph{Arguments}:
3407 @multitable @columnfractions .15 .70
3408 @item @var{A} @tab The type shall be @code{REAL}.
3409 @item @var{KIND} @tab (Optional) A scalar @code{INTEGER} constant
3410 expression indicating the kind parameter of the result.
3413 @item @emph{Return value}:
3414 The return value is of type @code{INTEGER(KIND)} if @var{KIND} is present
3415 and a default-kind @code{INTEGER} otherwise.
3417 @item @emph{Example}:
3419 program test_ceiling
3422 print *, ceiling(x) ! returns 64
3423 print *, ceiling(y) ! returns -63
3424 end program test_ceiling
3427 @item @emph{See also}:
3435 @section @code{CHAR} --- Character conversion function
3437 @cindex conversion, to character
3440 @item @emph{Description}:
3441 @code{CHAR(I [, KIND])} returns the character represented by the integer @var{I}.
3443 @item @emph{Standard}:
3444 Fortran 77 and later
3449 @item @emph{Syntax}:
3450 @code{RESULT = CHAR(I [, KIND])}
3452 @item @emph{Arguments}:
3453 @multitable @columnfractions .15 .70
3454 @item @var{I} @tab The type shall be @code{INTEGER}.
3455 @item @var{KIND} @tab (Optional) A scalar @code{INTEGER} constant
3456 expression indicating the kind parameter of the result.
3459 @item @emph{Return value}:
3460 The return value is of type @code{CHARACTER(1)}
3462 @item @emph{Example}:
3468 print *, i, c ! returns 'J'
3469 end program test_char
3472 @item @emph{Specific names}:
3473 @multitable @columnfractions .19 .19 .25 .33
3474 @headitem Name @tab Argument @tab Return type @tab Standard
3475 @item @code{CHAR(I)} @tab @code{INTEGER I} @tab @code{CHARACTER(LEN=1)} @tab Fortran 77 and later
3479 See @ref{ICHAR} for a discussion of converting between numerical values
3480 and formatted string representations.
3482 @item @emph{See also}:
3492 @section @code{CHDIR} --- Change working directory
3494 @cindex system, working directory
3497 @item @emph{Description}:
3498 Change current working directory to a specified path.
3500 This intrinsic is provided in both subroutine and function forms; however,
3501 only one form can be used in any given program unit.
3503 @item @emph{Standard}:
3507 Subroutine, function
3509 @item @emph{Syntax}:
3510 @multitable @columnfractions .80
3511 @item @code{CALL CHDIR(NAME [, STATUS])}
3512 @item @code{STATUS = CHDIR(NAME)}
3515 @item @emph{Arguments}:
3516 @multitable @columnfractions .15 .70
3517 @item @var{NAME} @tab The type shall be @code{CHARACTER} of default
3518 kind and shall specify a valid path within the file system.
3519 @item @var{STATUS} @tab (Optional) @code{INTEGER} status flag of the default
3520 kind. Returns 0 on success, and a system specific and nonzero error code
3524 @item @emph{Example}:
3527 CHARACTER(len=255) :: path
3529 WRITE(*,*) TRIM(path)
3532 WRITE(*,*) TRIM(path)
3536 @item @emph{See also}:
3543 @section @code{CHMOD} --- Change access permissions of files
3545 @cindex file system, change access mode
3548 @item @emph{Description}:
3549 @code{CHMOD} changes the permissions of a file.
3551 This intrinsic is provided in both subroutine and function forms; however,
3552 only one form can be used in any given program unit.
3554 @item @emph{Standard}:
3558 Subroutine, function
3560 @item @emph{Syntax}:
3561 @multitable @columnfractions .80
3562 @item @code{CALL CHMOD(NAME, MODE[, STATUS])}
3563 @item @code{STATUS = CHMOD(NAME, MODE)}
3566 @item @emph{Arguments}:
3567 @multitable @columnfractions .15 .70
3569 @item @var{NAME} @tab Scalar @code{CHARACTER} of default kind with the
3570 file name. Trailing blanks are ignored unless the character
3571 @code{achar(0)} is present, then all characters up to and excluding
3572 @code{achar(0)} are used as the file name.
3574 @item @var{MODE} @tab Scalar @code{CHARACTER} of default kind giving the
3575 file permission. @var{MODE} uses the same syntax as the @code{chmod} utility
3576 as defined by the POSIX standard. The argument shall either be a string of
3577 a nonnegative octal number or a symbolic mode.
3579 @item @var{STATUS} @tab (optional) scalar @code{INTEGER}, which is
3580 @code{0} on success and nonzero otherwise.
3583 @item @emph{Return value}:
3584 In either syntax, @var{STATUS} is set to @code{0} on success and nonzero
3587 @item @emph{Example}:
3588 @code{CHMOD} as subroutine
3593 call chmod('test.dat','u+x',status)
3594 print *, 'Status: ', status
3595 end program chmod_test
3597 @code{CHMOD} as function:
3602 status = chmod('test.dat','u+x')
3603 print *, 'Status: ', status
3604 end program chmod_test
3612 @section @code{CMPLX} --- Complex conversion function
3614 @cindex complex numbers, conversion to
3615 @cindex conversion, to complex
3618 @item @emph{Description}:
3619 @code{CMPLX(X [, Y [, KIND]])} returns a complex number where @var{X} is converted to
3620 the real component. If @var{Y} is present it is converted to the imaginary
3621 component. If @var{Y} is not present then the imaginary component is set to
3622 0.0. If @var{X} is complex then @var{Y} must not be present.
3624 @item @emph{Standard}:
3625 Fortran 77 and later
3630 @item @emph{Syntax}:
3631 @code{RESULT = CMPLX(X [, Y [, KIND]])}
3633 @item @emph{Arguments}:
3634 @multitable @columnfractions .15 .70
3635 @item @var{X} @tab The type may be @code{INTEGER}, @code{REAL},
3637 @item @var{Y} @tab (Optional; only allowed if @var{X} is not
3638 @code{COMPLEX}.) May be @code{INTEGER} or @code{REAL}.
3639 @item @var{KIND} @tab (Optional) A scalar @code{INTEGER} constant
3640 expression indicating the kind parameter of the result.
3643 @item @emph{Return value}:
3644 The return value is of @code{COMPLEX} type, with a kind equal to
3645 @var{KIND} if it is specified. If @var{KIND} is not specified, the
3646 result is of the default @code{COMPLEX} kind, regardless of the kinds of
3647 @var{X} and @var{Y}.
3649 @item @emph{Example}:
3656 print *, z, cmplx(x)
3657 end program test_cmplx
3660 @item @emph{See also}:
3667 @section @code{CO_BROADCAST} --- Copy a value to all images the current set of images
3668 @fnindex CO_BROADCAST
3669 @cindex Collectives, value broadcasting
3672 @item @emph{Description}:
3673 @code{CO_BROADCAST} copies the value of argument @var{A} on the image with
3674 image index @code{SOURCE_IMAGE} to all images in the current team. @var{A}
3675 becomes defined as if by intrinsic assignment. If the execution was
3676 successful and @var{STAT} is present, it is assigned the value zero. If the
3677 execution failed, @var{STAT} gets assigned a nonzero value and, if present,
3678 @var{ERRMSG} gets assigned a value describing the occurred error.
3680 @item @emph{Standard}:
3681 Technical Specification (TS) 18508 or later
3684 Collective subroutine
3686 @item @emph{Syntax}:
3687 @code{CALL CO_BROADCAST(A, SOURCE_IMAGE [, STAT, ERRMSG])}
3689 @item @emph{Arguments}:
3690 @multitable @columnfractions .20 .65
3691 @item @var{A} @tab INTENT(INOUT) argument; shall have the same
3692 dynamic type and type parameters on all images of the current team. If it
3693 is an array, it shall have the same shape on all images.
3694 @item @var{SOURCE_IMAGE} @tab a scalar integer expression.
3695 It shall have the same value on all images and refer to an
3696 image of the current team.
3697 @item @var{STAT} @tab (optional) a scalar integer variable
3698 @item @var{ERRMSG} @tab (optional) a scalar character variable
3701 @item @emph{Example}:
3705 if (this_image() == 1) then
3708 call co_broadcast (val, source_image=1)
3709 print *, this_image, ":", val
3713 @item @emph{See also}:
3723 @section @code{CO_MAX} --- Maximal value on the current set of images
3725 @cindex Collectives, maximal value
3728 @item @emph{Description}:
3729 @code{CO_MAX} determines element-wise the maximal value of @var{A} on all
3730 images of the current team. If @var{RESULT_IMAGE} is present, the maximum
3731 values are returned in @var{A} on the specified image only and the value
3732 of @var{A} on the other images become undefined. If @var{RESULT_IMAGE} is
3733 not present, the value is returned on all images. If the execution was
3734 successful and @var{STAT} is present, it is assigned the value zero. If the
3735 execution failed, @var{STAT} gets assigned a nonzero value and, if present,
3736 @var{ERRMSG} gets assigned a value describing the occurred error.
3738 @item @emph{Standard}:
3739 Technical Specification (TS) 18508 or later
3742 Collective subroutine
3744 @item @emph{Syntax}:
3745 @code{CALL CO_MAX(A [, RESULT_IMAGE, STAT, ERRMSG])}
3747 @item @emph{Arguments}:
3748 @multitable @columnfractions .20 .65
3749 @item @var{A} @tab shall be an integer, real or character variable,
3750 which has the same type and type parameters on all images of the team.
3751 @item @var{RESULT_IMAGE} @tab (optional) a scalar integer expression; if
3752 present, it shall have the same value on all images and refer to an
3753 image of the current team.
3754 @item @var{STAT} @tab (optional) a scalar integer variable
3755 @item @var{ERRMSG} @tab (optional) a scalar character variable
3758 @item @emph{Example}:
3763 call co_max (val, result_image=1)
3764 if (this_image() == 1) then
3765 write(*,*) "Maximal value", val ! prints num_images()
3770 @item @emph{See also}:
3780 @section @code{CO_MIN} --- Minimal value on the current set of images
3782 @cindex Collectives, minimal value
3785 @item @emph{Description}:
3786 @code{CO_MIN} determines element-wise the minimal value of @var{A} on all
3787 images of the current team. If @var{RESULT_IMAGE} is present, the minimal
3788 values are returned in @var{A} on the specified image only and the value
3789 of @var{A} on the other images become undefined. If @var{RESULT_IMAGE} is
3790 not present, the value is returned on all images. If the execution was
3791 successful and @var{STAT} is present, it is assigned the value zero. If the
3792 execution failed, @var{STAT} gets assigned a nonzero value and, if present,
3793 @var{ERRMSG} gets assigned a value describing the occurred error.
3795 @item @emph{Standard}:
3796 Technical Specification (TS) 18508 or later
3799 Collective subroutine
3801 @item @emph{Syntax}:
3802 @code{CALL CO_MIN(A [, RESULT_IMAGE, STAT, ERRMSG])}
3804 @item @emph{Arguments}:
3805 @multitable @columnfractions .20 .65
3806 @item @var{A} @tab shall be an integer, real or character variable,
3807 which has the same type and type parameters on all images of the team.
3808 @item @var{RESULT_IMAGE} @tab (optional) a scalar integer expression; if
3809 present, it shall have the same value on all images and refer to an
3810 image of the current team.
3811 @item @var{STAT} @tab (optional) a scalar integer variable
3812 @item @var{ERRMSG} @tab (optional) a scalar character variable
3815 @item @emph{Example}:
3820 call co_min (val, result_image=1)
3821 if (this_image() == 1) then
3822 write(*,*) "Minimal value", val ! prints 1
3827 @item @emph{See also}:
3837 @section @code{CO_REDUCE} --- Reduction of values on the current set of images
3839 @cindex Collectives, generic reduction
3842 @item @emph{Description}:
3843 @code{CO_REDUCE} determines element-wise the reduction of the value of @var{A}
3844 on all images of the current team. The pure function passed as @var{OPERATION}
3845 is used to pairwise reduce the values of @var{A} by passing either the value
3846 of @var{A} of different images or the result values of such a reduction as
3847 argument. If @var{A} is an array, the deduction is done element wise. If
3848 @var{RESULT_IMAGE} is present, the result values are returned in @var{A} on
3849 the specified image only and the value of @var{A} on the other images become
3850 undefined. If @var{RESULT_IMAGE} is not present, the value is returned on all
3851 images. If the execution was successful and @var{STAT} is present, it is
3852 assigned the value zero. If the execution failed, @var{STAT} gets assigned
3853 a nonzero value and, if present, @var{ERRMSG} gets assigned a value describing
3856 @item @emph{Standard}:
3857 Technical Specification (TS) 18508 or later
3860 Collective subroutine
3862 @item @emph{Syntax}:
3863 @code{CALL CO_REDUCE(A, OPERATION, [, RESULT_IMAGE, STAT, ERRMSG])}
3865 @item @emph{Arguments}:
3866 @multitable @columnfractions .20 .65
3867 @item @var{A} @tab is an @code{INTENT(INOUT)} argument and shall be
3868 nonpolymorphic. If it is allocatable, it shall be allocated; if it is a pointer,
3869 it shall be associated. @var{A} shall have the same type and type parameters on
3870 all images of the team; if it is an array, it shall have the same shape on all
3872 @item @var{OPERATION} @tab pure function with two scalar nonallocatable
3873 arguments, which shall be nonpolymorphic and have the same type and type
3874 parameters as @var{A}. The function shall return a nonallocatable scalar of
3875 the same type and type parameters as @var{A}. The function shall be the same on
3876 all images and with regards to the arguments mathematically commutative and
3877 associative. Note that @var{OPERATION} may not be an elemental function, unless
3878 it is an intrisic function.
3879 @item @var{RESULT_IMAGE} @tab (optional) a scalar integer expression; if
3880 present, it shall have the same value on all images and refer to an
3881 image of the current team.
3882 @item @var{STAT} @tab (optional) a scalar integer variable
3883 @item @var{ERRMSG} @tab (optional) a scalar character variable
3886 @item @emph{Example}:
3891 call co_reduce (val, result_image=1, operation=myprod)
3892 if (this_image() == 1) then
3893 write(*,*) "Product value", val ! prints num_images() factorial
3896 pure function myprod(a, b)
3897 integer, value :: a, b
3905 While the rules permit in principle an intrinsic function, none of the
3906 intrinsics in the standard fulfill the criteria of having a specific
3907 function, which takes two arguments of the same type and returning that
3910 @item @emph{See also}:
3920 @section @code{CO_SUM} --- Sum of values on the current set of images
3922 @cindex Collectives, sum of values
3925 @item @emph{Description}:
3926 @code{CO_SUM} sums up the values of each element of @var{A} on all
3927 images of the current team. If @var{RESULT_IMAGE} is present, the summed-up
3928 values are returned in @var{A} on the specified image only and the value
3929 of @var{A} on the other images become undefined. If @var{RESULT_IMAGE} is
3930 not present, the value is returned on all images. If the execution was
3931 successful and @var{STAT} is present, it is assigned the value zero. If the
3932 execution failed, @var{STAT} gets assigned a nonzero value and, if present,
3933 @var{ERRMSG} gets assigned a value describing the occurred error.
3935 @item @emph{Standard}:
3936 Technical Specification (TS) 18508 or later
3939 Collective subroutine
3941 @item @emph{Syntax}:
3942 @code{CALL CO_SUM(A [, RESULT_IMAGE, STAT, ERRMSG])}
3944 @item @emph{Arguments}:
3945 @multitable @columnfractions .20 .65
3946 @item @var{A} @tab shall be an integer, real or complex variable,
3947 which has the same type and type parameters on all images of the team.
3948 @item @var{RESULT_IMAGE} @tab (optional) a scalar integer expression; if
3949 present, it shall have the same value on all images and refer to an
3950 image of the current team.
3951 @item @var{STAT} @tab (optional) a scalar integer variable
3952 @item @var{ERRMSG} @tab (optional) a scalar character variable
3955 @item @emph{Example}:
3960 call co_sum (val, result_image=1)
3961 if (this_image() == 1) then
3962 write(*,*) "The sum is ", val ! prints (n**2 + n)/2,
3963 ! with n = num_images()
3968 @item @emph{See also}:
3977 @node COMMAND_ARGUMENT_COUNT
3978 @section @code{COMMAND_ARGUMENT_COUNT} --- Get number of command line arguments
3979 @fnindex COMMAND_ARGUMENT_COUNT
3980 @cindex command-line arguments
3981 @cindex command-line arguments, number of
3982 @cindex arguments, to program
3985 @item @emph{Description}:
3986 @code{COMMAND_ARGUMENT_COUNT} returns the number of arguments passed on the
3987 command line when the containing program was invoked.
3989 @item @emph{Standard}:
3990 Fortran 2003 and later
3995 @item @emph{Syntax}:
3996 @code{RESULT = COMMAND_ARGUMENT_COUNT()}
3998 @item @emph{Arguments}:
3999 @multitable @columnfractions .15 .70
4003 @item @emph{Return value}:
4004 The return value is an @code{INTEGER} of default kind.
4006 @item @emph{Example}:
4008 program test_command_argument_count
4010 count = command_argument_count()
4012 end program test_command_argument_count
4015 @item @emph{See also}:
4016 @ref{GET_COMMAND}, @*
4017 @ref{GET_COMMAND_ARGUMENT}
4022 @node COMPILER_OPTIONS
4023 @section @code{COMPILER_OPTIONS} --- Options passed to the compiler
4024 @fnindex COMPILER_OPTIONS
4025 @cindex flags inquiry function
4026 @cindex options inquiry function
4027 @cindex compiler flags inquiry function
4030 @item @emph{Description}:
4031 @code{COMPILER_OPTIONS} returns a string with the options used for
4034 @item @emph{Standard}:
4038 Inquiry function of the module @code{ISO_FORTRAN_ENV}
4040 @item @emph{Syntax}:
4041 @code{STR = COMPILER_OPTIONS()}
4043 @item @emph{Arguments}:
4046 @item @emph{Return value}:
4047 The return value is a default-kind string with system-dependent length.
4048 It contains the compiler flags used to compile the file, which called
4049 the @code{COMPILER_OPTIONS} intrinsic.
4051 @item @emph{Example}:
4054 print '(4a)', 'This file was compiled by ', &
4055 compiler_version(), ' using the options ', &
4060 @item @emph{See also}:
4061 @ref{COMPILER_VERSION}, @*
4062 @ref{ISO_FORTRAN_ENV}
4067 @node COMPILER_VERSION
4068 @section @code{COMPILER_VERSION} --- Compiler version string
4069 @fnindex COMPILER_VERSION
4070 @cindex compiler, name and version
4071 @cindex version of the compiler
4074 @item @emph{Description}:
4075 @code{COMPILER_VERSION} returns a string with the name and the
4076 version of the compiler.
4078 @item @emph{Standard}:
4082 Inquiry function of the module @code{ISO_FORTRAN_ENV}
4084 @item @emph{Syntax}:
4085 @code{STR = COMPILER_VERSION()}
4087 @item @emph{Arguments}:
4090 @item @emph{Return value}:
4091 The return value is a default-kind string with system-dependent length.
4092 It contains the name of the compiler and its version number.
4094 @item @emph{Example}:
4097 print '(4a)', 'This file was compiled by ', &
4098 compiler_version(), ' using the options ', &
4103 @item @emph{See also}:
4104 @ref{COMPILER_OPTIONS}, @*
4105 @ref{ISO_FORTRAN_ENV}
4111 @section @code{COMPLEX} --- Complex conversion function
4113 @cindex complex numbers, conversion to
4114 @cindex conversion, to complex
4117 @item @emph{Description}:
4118 @code{COMPLEX(X, Y)} returns a complex number where @var{X} is converted
4119 to the real component and @var{Y} is converted to the imaginary
4122 @item @emph{Standard}:
4128 @item @emph{Syntax}:
4129 @code{RESULT = COMPLEX(X, Y)}
4131 @item @emph{Arguments}:
4132 @multitable @columnfractions .15 .70
4133 @item @var{X} @tab The type may be @code{INTEGER} or @code{REAL}.
4134 @item @var{Y} @tab The type may be @code{INTEGER} or @code{REAL}.
4137 @item @emph{Return value}:
4138 If @var{X} and @var{Y} are both of @code{INTEGER} type, then the return
4139 value is of default @code{COMPLEX} type.
4141 If @var{X} and @var{Y} are of @code{REAL} type, or one is of @code{REAL}
4142 type and one is of @code{INTEGER} type, then the return value is of
4143 @code{COMPLEX} type with a kind equal to that of the @code{REAL}
4144 argument with the highest precision.
4146 @item @emph{Example}:
4148 program test_complex
4151 print *, complex(i, x)
4152 end program test_complex
4155 @item @emph{See also}:
4162 @section @code{CONJG} --- Complex conjugate function
4165 @cindex complex conjugate
4168 @item @emph{Description}:
4169 @code{CONJG(Z)} returns the conjugate of @var{Z}. If @var{Z} is @code{(x, y)}
4170 then the result is @code{(x, -y)}
4172 @item @emph{Standard}:
4173 Fortran 77 and later, has an overload that is a GNU extension
4178 @item @emph{Syntax}:
4181 @item @emph{Arguments}:
4182 @multitable @columnfractions .15 .70
4183 @item @var{Z} @tab The type shall be @code{COMPLEX}.
4186 @item @emph{Return value}:
4187 The return value is of type @code{COMPLEX}.
4189 @item @emph{Example}:
4192 complex :: z = (2.0, 3.0)
4193 complex(8) :: dz = (2.71_8, -3.14_8)
4198 end program test_conjg
4201 @item @emph{Specific names}:
4202 @multitable @columnfractions .20 .23 .20 .33
4203 @headitem Name @tab Argument @tab Return type @tab Standard
4204 @item @code{DCONJG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
4211 @section @code{COS} --- Cosine function
4217 @cindex trigonometric function, cosine
4221 @item @emph{Description}:
4222 @code{COS(X)} computes the cosine of @var{X}.
4224 @item @emph{Standard}:
4225 Fortran 77 and later, has overloads that are GNU extensions
4230 @item @emph{Syntax}:
4231 @code{RESULT = COS(X)}
4233 @item @emph{Arguments}:
4234 @multitable @columnfractions .15 .70
4235 @item @var{X} @tab The type shall be @code{REAL} or
4239 @item @emph{Return value}:
4240 The return value is of the same type and kind as @var{X}. The real part
4241 of the result is in radians. If @var{X} is of the type @code{REAL},
4242 the return value lies in the range @math{ -1 \leq \cos (x) \leq 1}.
4244 @item @emph{Example}:
4249 end program test_cos
4252 @item @emph{Specific names}:
4253 @multitable @columnfractions .20 .23 .20 .33
4254 @headitem Name @tab Argument @tab Return type @tab Standard
4255 @item @code{COS(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later
4256 @item @code{DCOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
4257 @item @code{CCOS(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab Fortran 77 and later
4258 @item @code{ZCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
4259 @item @code{CDCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
4262 @item @emph{See also}:
4263 Inverse function: @*
4265 Degrees function: @*
4272 @section @code{COSD} --- Cosine function, degrees
4278 @cindex trigonometric function, cosine, degrees
4279 @cindex cosine, degrees
4282 @item @emph{Description}:
4283 @code{COSD(X)} computes the cosine of @var{X} in degrees.
4285 This function is for compatibility only and should be avoided in favor of
4286 standard constructs wherever possible.
4288 @item @emph{Standard}:
4289 GNU extension, enabled with @option{-fdec-math}.
4294 @item @emph{Syntax}:
4295 @code{RESULT = COSD(X)}
4297 @item @emph{Arguments}:
4298 @multitable @columnfractions .15 .70
4299 @item @var{X} @tab The type shall be @code{REAL} or
4303 @item @emph{Return value}:
4304 The return value is of the same type and kind as @var{X}. The real part
4305 of the result is in degrees. If @var{X} is of the type @code{REAL},
4306 the return value lies in the range @math{ -1 \leq \cosd (x) \leq 1}.
4308 @item @emph{Example}:
4313 end program test_cosd
4316 @item @emph{Specific names}:
4317 @multitable @columnfractions .20 .23 .20 .33
4318 @headitem Name @tab Argument @tab Return type @tab Standard
4319 @item @code{COSD(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU extension
4320 @item @code{DCOSD(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
4321 @item @code{CCOSD(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab GNU extension
4322 @item @code{ZCOSD(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
4323 @item @code{CDCOSD(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
4326 @item @emph{See also}:
4327 Inverse function: @*
4329 Radians function: @*
4336 @section @code{COSH} --- Hyperbolic cosine function
4339 @cindex hyperbolic cosine
4340 @cindex hyperbolic function, cosine
4341 @cindex cosine, hyperbolic
4344 @item @emph{Description}:
4345 @code{COSH(X)} computes the hyperbolic cosine of @var{X}.
4347 @item @emph{Standard}:
4348 Fortran 77 and later, for a complex argument Fortran 2008 or later
4353 @item @emph{Syntax}:
4356 @item @emph{Arguments}:
4357 @multitable @columnfractions .15 .70
4358 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
4361 @item @emph{Return value}:
4362 The return value has same type and kind as @var{X}. If @var{X} is
4363 complex, the imaginary part of the result is in radians. If @var{X}
4364 is @code{REAL}, the return value has a lower bound of one,
4365 @math{\cosh (x) \geq 1}.
4367 @item @emph{Example}:
4370 real(8) :: x = 1.0_8
4372 end program test_cosh
4375 @item @emph{Specific names}:
4376 @multitable @columnfractions .20 .23 .20 .33
4377 @headitem Name @tab Argument @tab Return type @tab Standard
4378 @item @code{COSH(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later
4379 @item @code{DCOSH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
4382 @item @emph{See also}:
4383 Inverse function: @*
4390 @section @code{COTAN} --- Cotangent function
4393 @cindex trigonometric function, cotangent
4397 @item @emph{Description}:
4398 @code{COTAN(X)} computes the cotangent of @var{X}. Equivalent to @code{COS(x)}
4399 divided by @code{SIN(x)}, or @code{1 / TAN(x)}.
4401 This function is for compatibility only and should be avoided in favor of
4402 standard constructs wherever possible.
4404 @item @emph{Standard}:
4405 GNU extension, enabled with @option{-fdec-math}.
4410 @item @emph{Syntax}:
4411 @code{RESULT = COTAN(X)}
4413 @item @emph{Arguments}:
4414 @multitable @columnfractions .15 .70
4415 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
4418 @item @emph{Return value}:
4419 The return value has same type and kind as @var{X}, and its value is in radians.
4421 @item @emph{Example}:
4424 real(8) :: x = 0.165_8
4426 end program test_cotan
4429 @item @emph{Specific names}:
4430 @multitable @columnfractions .20 .23 .20 .33
4431 @headitem Name @tab Argument @tab Return type @tab Standard
4432 @item @code{COTAN(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU extension
4433 @item @code{DCOTAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
4436 @item @emph{See also}:
4437 Converse function: @*
4439 Degrees function: @*
4446 @section @code{COTAND} --- Cotangent function, degrees
4449 @cindex trigonometric function, cotangent, degrees
4450 @cindex cotangent, degrees
4453 @item @emph{Description}:
4454 @code{COTAND(X)} computes the cotangent of @var{X} in degrees. Equivalent to
4455 @code{COSD(x)} divided by @code{SIND(x)}, or @code{1 / TAND(x)}.
4457 @item @emph{Standard}:
4458 GNU extension, enabled with @option{-fdec-math}.
4460 This function is for compatibility only and should be avoided in favor of
4461 standard constructs wherever possible.
4466 @item @emph{Syntax}:
4467 @code{RESULT = COTAND(X)}
4469 @item @emph{Arguments}:
4470 @multitable @columnfractions .15 .70
4471 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
4474 @item @emph{Return value}:
4475 The return value has same type and kind as @var{X}, and its value is in degrees.
4477 @item @emph{Example}:
4480 real(8) :: x = 0.165_8
4482 end program test_cotand
4485 @item @emph{Specific names}:
4486 @multitable @columnfractions .20 .23 .20 .33
4487 @headitem Name @tab Argument @tab Return type @tab Standard
4488 @item @code{COTAND(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU extension
4489 @item @code{DCOTAND(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
4492 @item @emph{See also}:
4493 Converse function: @*
4495 Radians function: @*
4502 @section @code{COUNT} --- Count function
4504 @cindex array, conditionally count elements
4505 @cindex array, element counting
4506 @cindex array, number of elements
4509 @item @emph{Description}:
4511 Counts the number of @code{.TRUE.} elements in a logical @var{MASK},
4512 or, if the @var{DIM} argument is supplied, counts the number of
4513 elements along each row of the array in the @var{DIM} direction.
4514 If the array has zero size, or all of the elements of @var{MASK} are
4515 @code{.FALSE.}, then the result is @code{0}.
4517 @item @emph{Standard}:
4518 Fortran 90 and later, with @var{KIND} argument Fortran 2003 and later
4521 Transformational function
4523 @item @emph{Syntax}:
4524 @code{RESULT = COUNT(MASK [, DIM, KIND])}
4526 @item @emph{Arguments}:
4527 @multitable @columnfractions .15 .70
4528 @item @var{MASK} @tab The type shall be @code{LOGICAL}.
4529 @item @var{DIM} @tab (Optional) The type shall be @code{INTEGER}.
4530 @item @var{KIND} @tab (Optional) A scalar @code{INTEGER} constant
4531 expression indicating the kind parameter of the result.
4534 @item @emph{Return value}:
4535 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
4536 @var{KIND} is absent, the return value is of default integer kind.
4537 If @var{DIM} is present, the result is an array with a rank one less
4538 than the rank of @var{ARRAY}, and a size corresponding to the shape
4539 of @var{ARRAY} with the @var{DIM} dimension removed.
4541 @item @emph{Example}:
4544 integer, dimension(2,3) :: a, b
4545 logical, dimension(2,3) :: mask
4546 a = reshape( (/ 1, 2, 3, 4, 5, 6 /), (/ 2, 3 /))
4547 b = reshape( (/ 0, 7, 3, 4, 5, 8 /), (/ 2, 3 /))
4548 print '(3i3)', a(1,:)
4549 print '(3i3)', a(2,:)
4551 print '(3i3)', b(1,:)
4552 print '(3i3)', b(2,:)
4555 print '(3l3)', mask(1,:)
4556 print '(3l3)', mask(2,:)
4558 print '(3i3)', count(mask)
4560 print '(3i3)', count(mask, 1)
4562 print '(3i3)', count(mask, 2)
4563 end program test_count
4570 @section @code{CPU_TIME} --- CPU elapsed time in seconds
4572 @cindex time, elapsed
4575 @item @emph{Description}:
4576 Returns a @code{REAL} value representing the elapsed CPU time in
4577 seconds. This is useful for testing segments of code to determine
4580 If a time source is available, time will be reported with microsecond
4581 resolution. If no time source is available, @var{TIME} is set to
4584 Note that @var{TIME} may contain a, system dependent, arbitrary offset
4585 and may not start with @code{0.0}. For @code{CPU_TIME}, the absolute
4586 value is meaningless, only differences between subsequent calls to
4587 this subroutine, as shown in the example below, should be used.
4590 @item @emph{Standard}:
4591 Fortran 95 and later
4596 @item @emph{Syntax}:
4597 @code{CALL CPU_TIME(TIME)}
4599 @item @emph{Arguments}:
4600 @multitable @columnfractions .15 .70
4601 @item @var{TIME} @tab The type shall be @code{REAL} with @code{INTENT(OUT)}.
4604 @item @emph{Return value}:
4607 @item @emph{Example}:
4609 program test_cpu_time
4610 real :: start, finish
4611 call cpu_time(start)
4612 ! put code to test here
4613 call cpu_time(finish)
4614 print '("Time = ",f6.3," seconds.")',finish-start
4615 end program test_cpu_time
4618 @item @emph{See also}:
4619 @ref{SYSTEM_CLOCK}, @*
4626 @section @code{CSHIFT} --- Circular shift elements of an array
4628 @cindex array, shift circularly
4629 @cindex array, permutation
4630 @cindex array, rotate
4633 @item @emph{Description}:
4634 @code{CSHIFT(ARRAY, SHIFT [, DIM])} performs a circular shift on elements of
4635 @var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is omitted it is
4636 taken to be @code{1}. @var{DIM} is a scalar of type @code{INTEGER} in the
4637 range of @math{1 \leq DIM \leq n)} where @math{n} is the rank of @var{ARRAY}.
4638 If the rank of @var{ARRAY} is one, then all elements of @var{ARRAY} are shifted
4639 by @var{SHIFT} places. If rank is greater than one, then all complete rank one
4640 sections of @var{ARRAY} along the given dimension are shifted. Elements
4641 shifted out one end of each rank one section are shifted back in the other end.
4643 @item @emph{Standard}:
4644 Fortran 90 and later
4647 Transformational function
4649 @item @emph{Syntax}:
4650 @code{RESULT = CSHIFT(ARRAY, SHIFT [, DIM])}
4652 @item @emph{Arguments}:
4653 @multitable @columnfractions .15 .70
4654 @item @var{ARRAY} @tab Shall be an array of any type.
4655 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
4656 @item @var{DIM} @tab The type shall be @code{INTEGER}.
4659 @item @emph{Return value}:
4660 Returns an array of same type and rank as the @var{ARRAY} argument.
4662 @item @emph{Example}:
4665 integer, dimension(3,3) :: a
4666 a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
4667 print '(3i3)', a(1,:)
4668 print '(3i3)', a(2,:)
4669 print '(3i3)', a(3,:)
4670 a = cshift(a, SHIFT=(/1, 2, -1/), DIM=2)
4672 print '(3i3)', a(1,:)
4673 print '(3i3)', a(2,:)
4674 print '(3i3)', a(3,:)
4675 end program test_cshift
4682 @section @code{CTIME} --- Convert a time into a string
4684 @cindex time, conversion to string
4685 @cindex conversion, to string
4688 @item @emph{Description}:
4689 @code{CTIME} converts a system time value, such as returned by
4690 @ref{TIME8}, to a string. The output will be of the form @samp{Sat
4691 Aug 19 18:13:14 1995}.
4693 This intrinsic is provided in both subroutine and function forms; however,
4694 only one form can be used in any given program unit.
4696 @item @emph{Standard}:
4700 Subroutine, function
4702 @item @emph{Syntax}:
4703 @multitable @columnfractions .80
4704 @item @code{CALL CTIME(TIME, RESULT)}.
4705 @item @code{RESULT = CTIME(TIME)}.
4708 @item @emph{Arguments}:
4709 @multitable @columnfractions .15 .70
4710 @item @var{TIME} @tab The type shall be of type @code{INTEGER}.
4711 @item @var{RESULT} @tab The type shall be of type @code{CHARACTER} and
4712 of default kind. It is an @code{INTENT(OUT)} argument. If the length
4713 of this variable is too short for the time and date string to fit
4714 completely, it will be blank on procedure return.
4717 @item @emph{Return value}:
4718 The converted date and time as a string.
4720 @item @emph{Example}:
4724 character(len=30) :: date
4727 ! Do something, main part of the program
4730 print *, 'Program was started on ', date
4731 end program test_ctime
4734 @item @emph{See Also}:
4735 @ref{DATE_AND_TIME}, @*
4745 @section @code{DATE_AND_TIME} --- Date and time subroutine
4746 @fnindex DATE_AND_TIME
4747 @cindex date, current
4748 @cindex current date
4749 @cindex time, current
4750 @cindex current time
4753 @item @emph{Description}:
4754 @code{DATE_AND_TIME(DATE, TIME, ZONE, VALUES)} gets the corresponding date and
4755 time information from the real-time system clock. @var{DATE} is
4756 @code{INTENT(OUT)} and has form ccyymmdd. @var{TIME} is @code{INTENT(OUT)} and
4757 has form hhmmss.sss. @var{ZONE} is @code{INTENT(OUT)} and has form (+-)hhmm,
4758 representing the difference with respect to Coordinated Universal Time (UTC).
4759 Unavailable time and date parameters return blanks.
4761 @var{VALUES} is @code{INTENT(OUT)} and provides the following:
4763 @multitable @columnfractions .15 .70
4764 @item @code{VALUE(1)}: @tab The year
4765 @item @code{VALUE(2)}: @tab The month
4766 @item @code{VALUE(3)}: @tab The day of the month
4767 @item @code{VALUE(4)}: @tab Time difference with UTC in minutes
4768 @item @code{VALUE(5)}: @tab The hour of the day
4769 @item @code{VALUE(6)}: @tab The minutes of the hour
4770 @item @code{VALUE(7)}: @tab The seconds of the minute
4771 @item @code{VALUE(8)}: @tab The milliseconds of the second
4774 @item @emph{Standard}:
4775 Fortran 90 and later
4780 @item @emph{Syntax}:
4781 @code{CALL DATE_AND_TIME([DATE, TIME, ZONE, VALUES])}
4783 @item @emph{Arguments}:
4784 @multitable @columnfractions .15 .70
4785 @item @var{DATE} @tab (Optional) The type shall be @code{CHARACTER(LEN=8)}
4786 or larger, and of default kind.
4787 @item @var{TIME} @tab (Optional) The type shall be @code{CHARACTER(LEN=10)}
4788 or larger, and of default kind.
4789 @item @var{ZONE} @tab (Optional) The type shall be @code{CHARACTER(LEN=5)}
4790 or larger, and of default kind.
4791 @item @var{VALUES}@tab (Optional) The type shall be @code{INTEGER(8)}.
4794 @item @emph{Return value}:
4797 @item @emph{Example}:
4799 program test_time_and_date
4800 character(8) :: date
4801 character(10) :: time
4802 character(5) :: zone
4803 integer,dimension(8) :: values
4804 ! using keyword arguments
4805 call date_and_time(date,time,zone,values)
4806 call date_and_time(DATE=date,ZONE=zone)
4807 call date_and_time(TIME=time)
4808 call date_and_time(VALUES=values)
4809 print '(a,2x,a,2x,a)', date, time, zone
4810 print '(8i5)', values
4811 end program test_time_and_date
4814 @item @emph{See also}:
4822 @section @code{DBLE} --- Double conversion function
4824 @cindex conversion, to real
4827 @item @emph{Description}:
4828 @code{DBLE(A)} Converts @var{A} to double precision real type.
4830 @item @emph{Standard}:
4831 Fortran 77 and later
4836 @item @emph{Syntax}:
4837 @code{RESULT = DBLE(A)}
4839 @item @emph{Arguments}:
4840 @multitable @columnfractions .15 .70
4841 @item @var{A} @tab The type shall be @code{INTEGER}, @code{REAL},
4845 @item @emph{Return value}:
4846 The return value is of type double precision real.
4848 @item @emph{Example}:
4853 complex :: z = (2.3,1.14)
4854 print *, dble(x), dble(i), dble(z)
4855 end program test_dble
4858 @item @emph{See also}:
4865 @section @code{DCMPLX} --- Double complex conversion function
4867 @cindex complex numbers, conversion to
4868 @cindex conversion, to complex
4871 @item @emph{Description}:
4872 @code{DCMPLX(X [,Y])} returns a double complex number where @var{X} is
4873 converted to the real component. If @var{Y} is present it is converted to the
4874 imaginary component. If @var{Y} is not present then the imaginary component is
4875 set to 0.0. If @var{X} is complex then @var{Y} must not be present.
4877 @item @emph{Standard}:
4883 @item @emph{Syntax}:
4884 @code{RESULT = DCMPLX(X [, Y])}
4886 @item @emph{Arguments}:
4887 @multitable @columnfractions .15 .70
4888 @item @var{X} @tab The type may be @code{INTEGER}, @code{REAL},
4890 @item @var{Y} @tab (Optional if @var{X} is not @code{COMPLEX}.) May be
4891 @code{INTEGER} or @code{REAL}.
4894 @item @emph{Return value}:
4895 The return value is of type @code{COMPLEX(8)}
4897 @item @emph{Example}:
4907 print *, dcmplx(x,i)
4908 end program test_dcmplx
4914 @section @code{DIGITS} --- Significant binary digits function
4916 @cindex model representation, significant digits
4919 @item @emph{Description}:
4920 @code{DIGITS(X)} returns the number of significant binary digits of the internal
4921 model representation of @var{X}. For example, on a system using a 32-bit
4922 floating point representation, a default real number would likely return 24.
4924 @item @emph{Standard}:
4925 Fortran 90 and later
4930 @item @emph{Syntax}:
4931 @code{RESULT = DIGITS(X)}
4933 @item @emph{Arguments}:
4934 @multitable @columnfractions .15 .70
4935 @item @var{X} @tab The type may be @code{INTEGER} or @code{REAL}.
4938 @item @emph{Return value}:
4939 The return value is of type @code{INTEGER}.
4941 @item @emph{Example}:
4944 integer :: i = 12345
4950 end program test_digits
4957 @section @code{DIM} --- Positive difference
4961 @cindex positive difference
4964 @item @emph{Description}:
4965 @code{DIM(X,Y)} returns the difference @code{X-Y} if the result is positive;
4966 otherwise returns zero.
4968 @item @emph{Standard}:
4969 Fortran 77 and later
4974 @item @emph{Syntax}:
4975 @code{RESULT = DIM(X, Y)}
4977 @item @emph{Arguments}:
4978 @multitable @columnfractions .15 .70
4979 @item @var{X} @tab The type shall be @code{INTEGER} or @code{REAL}
4980 @item @var{Y} @tab The type shall be the same type and kind as @var{X}. (As
4981 a GNU extension, arguments of different kinds are permitted.)
4984 @item @emph{Return value}:
4985 The return value is of type @code{INTEGER} or @code{REAL}. (As a GNU
4986 extension, kind is the largest kind of the actual arguments.)
4988 @item @emph{Example}:
4994 x = dim(4.345_8, 2.111_8)
4997 end program test_dim
5000 @item @emph{Specific names}:
5001 @multitable @columnfractions .20 .26 .20 .30
5002 @headitem Name @tab Argument @tab Return type @tab Standard
5003 @item @code{DIM(X,Y)} @tab @code{REAL(4) X, Y} @tab @code{REAL(4)} @tab Fortran 77 and later
5004 @item @code{IDIM(X,Y)} @tab @code{INTEGER(4) X, Y} @tab @code{INTEGER(4)} @tab Fortran 77 and later
5005 @item @code{DDIM(X,Y)} @tab @code{REAL(8) X, Y} @tab @code{REAL(8)} @tab Fortran 77 and later
5012 @section @code{DOT_PRODUCT} --- Dot product function
5013 @fnindex DOT_PRODUCT
5015 @cindex vector product
5016 @cindex product, vector
5019 @item @emph{Description}:
5020 @code{DOT_PRODUCT(VECTOR_A, VECTOR_B)} computes the dot product multiplication
5021 of two vectors @var{VECTOR_A} and @var{VECTOR_B}. The two vectors may be
5022 either numeric or logical and must be arrays of rank one and of equal size. If
5023 the vectors are @code{INTEGER} or @code{REAL}, the result is
5024 @code{SUM(VECTOR_A*VECTOR_B)}. If the vectors are @code{COMPLEX}, the result
5025 is @code{SUM(CONJG(VECTOR_A)*VECTOR_B)}. If the vectors are @code{LOGICAL},
5026 the result is @code{ANY(VECTOR_A .AND. VECTOR_B)}.
5028 @item @emph{Standard}:
5029 Fortran 90 and later
5032 Transformational function
5034 @item @emph{Syntax}:
5035 @code{RESULT = DOT_PRODUCT(VECTOR_A, VECTOR_B)}
5037 @item @emph{Arguments}:
5038 @multitable @columnfractions .15 .70
5039 @item @var{VECTOR_A} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
5040 @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.
5043 @item @emph{Return value}:
5044 If the arguments are numeric, the return value is a scalar of numeric type,
5045 @code{INTEGER}, @code{REAL}, or @code{COMPLEX}. If the arguments are
5046 @code{LOGICAL}, the return value is @code{.TRUE.} or @code{.FALSE.}.
5048 @item @emph{Example}:
5050 program test_dot_prod
5051 integer, dimension(3) :: a, b
5058 print *, dot_product(a,b)
5059 end program test_dot_prod
5066 @section @code{DPROD} --- Double product function
5068 @cindex product, double-precision
5071 @item @emph{Description}:
5072 @code{DPROD(X,Y)} returns the product @code{X*Y}.
5074 @item @emph{Standard}:
5075 Fortran 77 and later
5080 @item @emph{Syntax}:
5081 @code{RESULT = DPROD(X, Y)}
5083 @item @emph{Arguments}:
5084 @multitable @columnfractions .15 .70
5085 @item @var{X} @tab The type shall be @code{REAL}.
5086 @item @var{Y} @tab The type shall be @code{REAL}.
5089 @item @emph{Return value}:
5090 The return value is of type @code{REAL(8)}.
5092 @item @emph{Example}:
5100 end program test_dprod
5103 @item @emph{Specific names}:
5104 @multitable @columnfractions .20 .23 .20 .33
5105 @headitem Name @tab Argument @tab Return type @tab Standard
5106 @item @code{DPROD(X,Y)} @tab @code{REAL(4) X, Y} @tab @code{REAL(8)} @tab Fortran 77 and later
5113 @section @code{DREAL} --- Double real part function
5115 @cindex complex numbers, real part
5118 @item @emph{Description}:
5119 @code{DREAL(Z)} returns the real part of complex variable @var{Z}.
5121 @item @emph{Standard}:
5127 @item @emph{Syntax}:
5128 @code{RESULT = DREAL(A)}
5130 @item @emph{Arguments}:
5131 @multitable @columnfractions .15 .70
5132 @item @var{A} @tab The type shall be @code{COMPLEX(8)}.
5135 @item @emph{Return value}:
5136 The return value is of type @code{REAL(8)}.
5138 @item @emph{Example}:
5141 complex(8) :: z = (1.3_8,7.2_8)
5143 end program test_dreal
5146 @item @emph{See also}:
5154 @section @code{DSHIFTL} --- Combined left shift
5156 @cindex left shift, combined
5160 @item @emph{Description}:
5161 @code{DSHIFTL(I, J, SHIFT)} combines bits of @var{I} and @var{J}. The
5162 rightmost @var{SHIFT} bits of the result are the leftmost @var{SHIFT}
5163 bits of @var{J}, and the remaining bits are the rightmost bits of
5166 @item @emph{Standard}:
5167 Fortran 2008 and later
5172 @item @emph{Syntax}:
5173 @code{RESULT = DSHIFTL(I, J, SHIFT)}
5175 @item @emph{Arguments}:
5176 @multitable @columnfractions .15 .70
5177 @item @var{I} @tab Shall be of type @code{INTEGER} or a BOZ constant.
5178 @item @var{J} @tab Shall be of type @code{INTEGER} or a BOZ constant.
5179 If both @var{I} and @var{J} have integer type, then they shall have
5180 the same kind type parameter. @var{I} and @var{J} shall not both be
5182 @item @var{SHIFT} @tab Shall be of type @code{INTEGER}. It shall
5183 be nonnegative. If @var{I} is not a BOZ constant, then @var{SHIFT}
5184 shall be less than or equal to @code{BIT_SIZE(I)}; otherwise,
5185 @var{SHIFT} shall be less than or equal to @code{BIT_SIZE(J)}.
5188 @item @emph{Return value}:
5189 If either @var{I} or @var{J} is a BOZ constant, it is first converted
5190 as if by the intrinsic function @code{INT} to an integer type with the
5191 kind type parameter of the other.
5193 @item @emph{See also}:
5199 @section @code{DSHIFTR} --- Combined right shift
5201 @cindex right shift, combined
5202 @cindex shift, right
5205 @item @emph{Description}:
5206 @code{DSHIFTR(I, J, SHIFT)} combines bits of @var{I} and @var{J}. The
5207 leftmost @var{SHIFT} bits of the result are the rightmost @var{SHIFT}
5208 bits of @var{I}, and the remaining bits are the leftmost bits of
5211 @item @emph{Standard}:
5212 Fortran 2008 and later
5217 @item @emph{Syntax}:
5218 @code{RESULT = DSHIFTR(I, J, SHIFT)}
5220 @item @emph{Arguments}:
5221 @multitable @columnfractions .15 .70
5222 @item @var{I} @tab Shall be of type @code{INTEGER} or a BOZ constant.
5223 @item @var{J} @tab Shall be of type @code{INTEGER} or a BOZ constant.
5224 If both @var{I} and @var{J} have integer type, then they shall have
5225 the same kind type parameter. @var{I} and @var{J} shall not both be
5227 @item @var{SHIFT} @tab Shall be of type @code{INTEGER}. It shall
5228 be nonnegative. If @var{I} is not a BOZ constant, then @var{SHIFT}
5229 shall be less than or equal to @code{BIT_SIZE(I)}; otherwise,
5230 @var{SHIFT} shall be less than or equal to @code{BIT_SIZE(J)}.
5233 @item @emph{Return value}:
5234 If either @var{I} or @var{J} is a BOZ constant, it is first converted
5235 as if by the intrinsic function @code{INT} to an integer type with the
5236 kind type parameter of the other.
5238 @item @emph{See also}:
5244 @section @code{DTIME} --- Execution time subroutine (or function)
5246 @cindex time, elapsed
5247 @cindex elapsed time
5250 @item @emph{Description}:
5251 @code{DTIME(VALUES, TIME)} initially returns the number of seconds of runtime
5252 since the start of the process's execution in @var{TIME}. @var{VALUES}
5253 returns the user and system components of this time in @code{VALUES(1)} and
5254 @code{VALUES(2)} respectively. @var{TIME} is equal to @code{VALUES(1) +
5257 Subsequent invocations of @code{DTIME} return values accumulated since the
5258 previous invocation.
5260 On some systems, the underlying timings are represented using types with
5261 sufficiently small limits that overflows (wrap around) are possible, such as
5262 32-bit types. Therefore, the values returned by this intrinsic might be, or
5263 become, negative, or numerically less than previous values, during a single
5264 run of the compiled program.
5266 Please note, that this implementation is thread safe if used within OpenMP
5267 directives, i.e., its state will be consistent while called from multiple
5268 threads. However, if @code{DTIME} is called from multiple threads, the result
5269 is still the time since the last invocation. This may not give the intended
5270 results. If possible, use @code{CPU_TIME} instead.
5272 This intrinsic is provided in both subroutine and function forms; however,
5273 only one form can be used in any given program unit.
5275 @var{VALUES} and @var{TIME} are @code{INTENT(OUT)} and provide the following:
5277 @multitable @columnfractions .15 .70
5278 @item @code{VALUES(1)}: @tab User time in seconds.
5279 @item @code{VALUES(2)}: @tab System time in seconds.
5280 @item @code{TIME}: @tab Run time since start in seconds.
5283 @item @emph{Standard}:
5287 Subroutine, function
5289 @item @emph{Syntax}:
5290 @multitable @columnfractions .80
5291 @item @code{CALL DTIME(VALUES, TIME)}.
5292 @item @code{TIME = DTIME(VALUES)}, (not recommended).
5295 @item @emph{Arguments}:
5296 @multitable @columnfractions .15 .70
5297 @item @var{VALUES}@tab The type shall be @code{REAL(4), DIMENSION(2)}.
5298 @item @var{TIME}@tab The type shall be @code{REAL(4)}.
5301 @item @emph{Return value}:
5302 Elapsed time in seconds since the last invocation or since the start of program
5303 execution if not called before.
5305 @item @emph{Example}:
5309 real, dimension(2) :: tarray
5311 call dtime(tarray, result)
5315 do i=1,100000000 ! Just a delay
5318 call dtime(tarray, result)
5322 end program test_dtime
5325 @item @emph{See also}:
5333 @section @code{EOSHIFT} --- End-off shift elements of an array
5335 @cindex array, shift
5338 @item @emph{Description}:
5339 @code{EOSHIFT(ARRAY, SHIFT[, BOUNDARY, DIM])} performs an end-off shift on
5340 elements of @var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is
5341 omitted it is taken to be @code{1}. @var{DIM} is a scalar of type
5342 @code{INTEGER} in the range of @math{1 \leq DIM \leq n)} where @math{n} is the
5343 rank of @var{ARRAY}. If the rank of @var{ARRAY} is one, then all elements of
5344 @var{ARRAY} are shifted by @var{SHIFT} places. If rank is greater than one,
5345 then all complete rank one sections of @var{ARRAY} along the given dimension are
5346 shifted. Elements shifted out one end of each rank one section are dropped. If
5347 @var{BOUNDARY} is present then the corresponding value of from @var{BOUNDARY}
5348 is copied back in the other end. If @var{BOUNDARY} is not present then the
5349 following are copied in depending on the type of @var{ARRAY}.
5351 @multitable @columnfractions .15 .80
5352 @item @emph{Array Type} @tab @emph{Boundary Value}
5353 @item Numeric @tab 0 of the type and kind of @var{ARRAY}.
5354 @item Logical @tab @code{.FALSE.}.
5355 @item Character(@var{len}) @tab @var{len} blanks.
5358 @item @emph{Standard}:
5359 Fortran 90 and later
5362 Transformational function
5364 @item @emph{Syntax}:
5365 @code{RESULT = EOSHIFT(ARRAY, SHIFT [, BOUNDARY, DIM])}
5367 @item @emph{Arguments}:
5368 @multitable @columnfractions .15 .70
5369 @item @var{ARRAY} @tab May be any type, not scalar.
5370 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
5371 @item @var{BOUNDARY} @tab Same type as @var{ARRAY}.
5372 @item @var{DIM} @tab The type shall be @code{INTEGER}.
5375 @item @emph{Return value}:
5376 Returns an array of same type and rank as the @var{ARRAY} argument.
5378 @item @emph{Example}:
5380 program test_eoshift
5381 integer, dimension(3,3) :: a
5382 a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
5383 print '(3i3)', a(1,:)
5384 print '(3i3)', a(2,:)
5385 print '(3i3)', a(3,:)
5386 a = EOSHIFT(a, SHIFT=(/1, 2, 1/), BOUNDARY=-5, DIM=2)
5388 print '(3i3)', a(1,:)
5389 print '(3i3)', a(2,:)
5390 print '(3i3)', a(3,:)
5391 end program test_eoshift
5398 @section @code{EPSILON} --- Epsilon function
5400 @cindex model representation, epsilon
5403 @item @emph{Description}:
5404 @code{EPSILON(X)} returns the smallest number @var{E} of the same kind
5405 as @var{X} such that @math{1 + E > 1}.
5407 @item @emph{Standard}:
5408 Fortran 90 and later
5413 @item @emph{Syntax}:
5414 @code{RESULT = EPSILON(X)}
5416 @item @emph{Arguments}:
5417 @multitable @columnfractions .15 .70
5418 @item @var{X} @tab The type shall be @code{REAL}.
5421 @item @emph{Return value}:
5422 The return value is of same type as the argument.
5424 @item @emph{Example}:
5426 program test_epsilon
5431 end program test_epsilon
5438 @section @code{ERF} --- Error function
5440 @cindex error function
5443 @item @emph{Description}:
5444 @code{ERF(X)} computes the error function of @var{X}.
5446 @item @emph{Standard}:
5447 Fortran 2008 and later
5452 @item @emph{Syntax}:
5453 @code{RESULT = ERF(X)}
5455 @item @emph{Arguments}:
5456 @multitable @columnfractions .15 .70
5457 @item @var{X} @tab The type shall be @code{REAL}.
5460 @item @emph{Return value}:
5461 The return value is of type @code{REAL}, of the same kind as
5462 @var{X} and lies in the range @math{-1 \leq erf (x) \leq 1 }.
5464 @item @emph{Example}:
5467 real(8) :: x = 0.17_8
5469 end program test_erf
5472 @item @emph{Specific names}:
5473 @multitable @columnfractions .20 .23 .20 .33
5474 @headitem Name @tab Argument @tab Return type @tab Standard
5475 @item @code{DERF(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
5482 @section @code{ERFC} --- Error function
5484 @cindex error function, complementary
5487 @item @emph{Description}:
5488 @code{ERFC(X)} computes the complementary error function of @var{X}.
5490 @item @emph{Standard}:
5491 Fortran 2008 and later
5496 @item @emph{Syntax}:
5497 @code{RESULT = ERFC(X)}
5499 @item @emph{Arguments}:
5500 @multitable @columnfractions .15 .70
5501 @item @var{X} @tab The type shall be @code{REAL}.
5504 @item @emph{Return value}:
5505 The return value is of type @code{REAL} and of the same kind as @var{X}.
5506 It lies in the range @math{ 0 \leq erfc (x) \leq 2 }.
5508 @item @emph{Example}:
5511 real(8) :: x = 0.17_8
5513 end program test_erfc
5516 @item @emph{Specific names}:
5517 @multitable @columnfractions .20 .23 .20 .33
5518 @headitem Name @tab Argument @tab Return type @tab Standard
5519 @item @code{DERFC(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
5526 @section @code{ERFC_SCALED} --- Error function
5527 @fnindex ERFC_SCALED
5528 @cindex error function, complementary, exponentially-scaled
5531 @item @emph{Description}:
5532 @code{ERFC_SCALED(X)} computes the exponentially-scaled complementary
5533 error function of @var{X}.
5535 @item @emph{Standard}:
5536 Fortran 2008 and later
5541 @item @emph{Syntax}:
5542 @code{RESULT = ERFC_SCALED(X)}
5544 @item @emph{Arguments}:
5545 @multitable @columnfractions .15 .70
5546 @item @var{X} @tab The type shall be @code{REAL}.
5549 @item @emph{Return value}:
5550 The return value is of type @code{REAL} and of the same kind as @var{X}.
5552 @item @emph{Example}:
5554 program test_erfc_scaled
5555 real(8) :: x = 0.17_8
5557 end program test_erfc_scaled
5564 @section @code{ETIME} --- Execution time subroutine (or function)
5566 @cindex time, elapsed
5569 @item @emph{Description}:
5570 @code{ETIME(VALUES, TIME)} returns the number of seconds of runtime
5571 since the start of the process's execution in @var{TIME}. @var{VALUES}
5572 returns the user and system components of this time in @code{VALUES(1)} and
5573 @code{VALUES(2)} respectively. @var{TIME} is equal to @code{VALUES(1) + VALUES(2)}.
5575 On some systems, the underlying timings are represented using types with
5576 sufficiently small limits that overflows (wrap around) are possible, such as
5577 32-bit types. Therefore, the values returned by this intrinsic might be, or
5578 become, negative, or numerically less than previous values, during a single
5579 run of the compiled program.
5581 This intrinsic is provided in both subroutine and function forms; however,
5582 only one form can be used in any given program unit.
5584 @var{VALUES} and @var{TIME} are @code{INTENT(OUT)} and provide the following:
5586 @multitable @columnfractions .15 .70
5587 @item @code{VALUES(1)}: @tab User time in seconds.
5588 @item @code{VALUES(2)}: @tab System time in seconds.
5589 @item @code{TIME}: @tab Run time since start in seconds.
5592 @item @emph{Standard}:
5596 Subroutine, function
5598 @item @emph{Syntax}:
5599 @multitable @columnfractions .80
5600 @item @code{CALL ETIME(VALUES, TIME)}.
5601 @item @code{TIME = ETIME(VALUES)}, (not recommended).
5604 @item @emph{Arguments}:
5605 @multitable @columnfractions .15 .70
5606 @item @var{VALUES}@tab The type shall be @code{REAL(4), DIMENSION(2)}.
5607 @item @var{TIME}@tab The type shall be @code{REAL(4)}.
5610 @item @emph{Return value}:
5611 Elapsed time in seconds since the start of program execution.
5613 @item @emph{Example}:
5617 real, dimension(2) :: tarray
5619 call ETIME(tarray, result)
5623 do i=1,100000000 ! Just a delay
5626 call ETIME(tarray, result)
5630 end program test_etime
5633 @item @emph{See also}:
5641 @section @code{EVENT_QUERY} --- Query whether a coarray event has occurred
5642 @fnindex EVENT_QUERY
5643 @cindex Events, EVENT_QUERY
5646 @item @emph{Description}:
5647 @code{EVENT_QUERY} assignes the number of events to @var{COUNT} which have been
5648 posted to the @var{EVENT} variable and not yet been removed by calling
5649 @code{EVENT WAIT}. When @var{STAT} is present and the invocation was successful,
5650 it is assigned the value 0. If it is present and the invocation has failed,
5651 it is assigned a positive value and @var{COUNT} is assigned the value @math{-1}.
5653 @item @emph{Standard}:
5659 @item @emph{Syntax}:
5660 @code{CALL EVENT_QUERY (EVENT, COUNT [, STAT])}
5662 @item @emph{Arguments}:
5663 @multitable @columnfractions .15 .70
5664 @item @var{EVENT} @tab (intent(IN)) Scalar of type @code{EVENT_TYPE},
5665 defined in @code{ISO_FORTRAN_ENV}; shall not be coindexed.
5666 @item @var{COUNT} @tab (intent(out))Scalar integer with at least the
5667 precision of default integer.
5668 @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
5671 @item @emph{Example}:
5676 type(event_type) :: event_value_has_been_set[*]
5678 if (this_image() == 1) then
5679 call event_query (event_value_has_been_set, cnt)
5680 if (cnt > 0) write(*,*) "Value has been set"
5681 elseif (this_image() == 2) then
5682 event post (event_value_has_been_set[1])
5691 @node EXECUTE_COMMAND_LINE
5692 @section @code{EXECUTE_COMMAND_LINE} --- Execute a shell command
5693 @fnindex EXECUTE_COMMAND_LINE
5694 @cindex system, system call
5695 @cindex command line
5698 @item @emph{Description}:
5699 @code{EXECUTE_COMMAND_LINE} runs a shell command, synchronously or
5702 The @code{COMMAND} argument is passed to the shell and executed (The
5703 shell is @code{sh} on Unix systems, and @code{cmd.exe} on Windows.).
5704 If @code{WAIT} is present and has the value false, the execution of
5705 the command is asynchronous if the system supports it; otherwise, the
5706 command is executed synchronously using the C library's @code{system}
5709 The three last arguments allow the user to get status information. After
5710 synchronous execution, @code{EXITSTAT} contains the integer exit code of
5711 the command, as returned by @code{system}. @code{CMDSTAT} is set to zero
5712 if the command line was executed (whatever its exit status was).
5713 @code{CMDMSG} is assigned an error message if an error has occurred.
5715 Note that the @code{system} function need not be thread-safe. It is
5716 the responsibility of the user to ensure that @code{system} is not
5717 called concurrently.
5719 For asynchronous execution on supported targets, the POSIX
5720 @code{posix_spawn} or @code{fork} functions are used. Also, a signal
5721 handler for the @code{SIGCHLD} signal is installed.
5723 @item @emph{Standard}:
5724 Fortran 2008 and later
5729 @item @emph{Syntax}:
5730 @code{CALL EXECUTE_COMMAND_LINE(COMMAND [, WAIT, EXITSTAT, CMDSTAT, CMDMSG ])}
5732 @item @emph{Arguments}:
5733 @multitable @columnfractions .15 .70
5734 @item @var{COMMAND} @tab Shall be a default @code{CHARACTER} scalar.
5735 @item @var{WAIT} @tab (Optional) Shall be a default @code{LOGICAL} scalar.
5736 @item @var{EXITSTAT} @tab (Optional) Shall be an @code{INTEGER} of the
5738 @item @var{CMDSTAT} @tab (Optional) Shall be an @code{INTEGER} of the
5740 @item @var{CMDMSG} @tab (Optional) Shall be an @code{CHARACTER} scalar of the
5744 @item @emph{Example}:
5749 call execute_command_line ("external_prog.exe", exitstat=i)
5750 print *, "Exit status of external_prog.exe was ", i
5752 call execute_command_line ("reindex_files.exe", wait=.false.)
5753 print *, "Now reindexing files in the background"
5755 end program test_exec
5761 Because this intrinsic is implemented in terms of the @code{system}
5762 function call, its behavior with respect to signaling is processor
5763 dependent. In particular, on POSIX-compliant systems, the SIGINT and
5764 SIGQUIT signals will be ignored, and the SIGCHLD will be blocked. As
5765 such, if the parent process is terminated, the child process might not be
5766 terminated alongside.
5769 @item @emph{See also}:
5776 @section @code{EXIT} --- Exit the program with status.
5778 @cindex program termination
5779 @cindex terminate program
5782 @item @emph{Description}:
5783 @code{EXIT} causes immediate termination of the program with status. If status
5784 is omitted it returns the canonical @emph{success} for the system. All Fortran
5785 I/O units are closed.
5787 @item @emph{Standard}:
5793 @item @emph{Syntax}:
5794 @code{CALL EXIT([STATUS])}
5796 @item @emph{Arguments}:
5797 @multitable @columnfractions .15 .70
5798 @item @var{STATUS} @tab Shall be an @code{INTEGER} of the default kind.
5801 @item @emph{Return value}:
5802 @code{STATUS} is passed to the parent process on exit.
5804 @item @emph{Example}:
5807 integer :: STATUS = 0
5808 print *, 'This program is going to exit.'
5810 end program test_exit
5813 @item @emph{See also}:
5821 @section @code{EXP} --- Exponential function
5827 @cindex exponential function
5828 @cindex logarithm function, inverse
5831 @item @emph{Description}:
5832 @code{EXP(X)} computes the base @math{e} exponential of @var{X}.
5834 @item @emph{Standard}:
5835 Fortran 77 and later, has overloads that are GNU extensions
5840 @item @emph{Syntax}:
5841 @code{RESULT = EXP(X)}
5843 @item @emph{Arguments}:
5844 @multitable @columnfractions .15 .70
5845 @item @var{X} @tab The type shall be @code{REAL} or
5849 @item @emph{Return value}:
5850 The return value has same type and kind as @var{X}.
5852 @item @emph{Example}:
5857 end program test_exp
5860 @item @emph{Specific names}:
5861 @multitable @columnfractions .20 .23 .20 .33
5862 @headitem Name @tab Argument @tab Return type @tab Standard
5863 @item @code{EXP(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later
5864 @item @code{DEXP(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
5865 @item @code{CEXP(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab Fortran 77 and later
5866 @item @code{ZEXP(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
5867 @item @code{CDEXP(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
5874 @section @code{EXPONENT} --- Exponent function
5876 @cindex real number, exponent
5877 @cindex floating point, exponent
5880 @item @emph{Description}:
5881 @code{EXPONENT(X)} returns the value of the exponent part of @var{X}. If @var{X}
5882 is zero the value returned is zero.
5884 @item @emph{Standard}:
5885 Fortran 90 and later
5890 @item @emph{Syntax}:
5891 @code{RESULT = EXPONENT(X)}
5893 @item @emph{Arguments}:
5894 @multitable @columnfractions .15 .70
5895 @item @var{X} @tab The type shall be @code{REAL}.
5898 @item @emph{Return value}:
5899 The return value is of type default @code{INTEGER}.
5901 @item @emph{Example}:
5903 program test_exponent
5908 print *, exponent(0.0)
5909 end program test_exponent
5915 @node EXTENDS_TYPE_OF
5916 @section @code{EXTENDS_TYPE_OF} --- Query dynamic type for extension
5917 @fnindex EXTENDS_TYPE_OF
5920 @item @emph{Description}:
5921 Query dynamic type for extension.
5923 @item @emph{Standard}:
5924 Fortran 2003 and later
5929 @item @emph{Syntax}:
5930 @code{RESULT = EXTENDS_TYPE_OF(A, MOLD)}
5932 @item @emph{Arguments}:
5933 @multitable @columnfractions .15 .70
5934 @item @var{A} @tab Shall be an object of extensible declared type or
5935 unlimited polymorphic.
5936 @item @var{MOLD} @tab Shall be an object of extensible declared type or
5937 unlimited polymorphic.
5940 @item @emph{Return value}:
5941 The return value is a scalar of type default logical. It is true if and only if
5942 the dynamic type of A is an extension type of the dynamic type of MOLD.
5945 @item @emph{See also}:
5952 @section @code{FDATE} --- Get the current time as a string
5954 @cindex time, current
5955 @cindex current time
5956 @cindex date, current
5957 @cindex current date
5960 @item @emph{Description}:
5961 @code{FDATE(DATE)} returns the current date (using the same format as
5962 @ref{CTIME}) in @var{DATE}. It is equivalent to @code{CALL CTIME(DATE,
5965 This intrinsic is provided in both subroutine and function forms; however,
5966 only one form can be used in any given program unit.
5968 @item @emph{Standard}:
5972 Subroutine, function
5974 @item @emph{Syntax}:
5975 @multitable @columnfractions .80
5976 @item @code{CALL FDATE(DATE)}.
5977 @item @code{DATE = FDATE()}.
5980 @item @emph{Arguments}:
5981 @multitable @columnfractions .15 .70
5982 @item @var{DATE}@tab The type shall be of type @code{CHARACTER} of the
5983 default kind. It is an @code{INTENT(OUT)} argument. If the length of
5984 this variable is too short for the date and time string to fit
5985 completely, it will be blank on procedure return.
5988 @item @emph{Return value}:
5989 The current date and time as a string.
5991 @item @emph{Example}:
5995 character(len=30) :: date
5997 print *, 'Program started on ', date
5998 do i = 1, 100000000 ! Just a delay
6002 print *, 'Program ended on ', date
6003 end program test_fdate
6006 @item @emph{See also}:
6007 @ref{DATE_AND_TIME}, @*
6013 @section @code{FGET} --- Read a single character in stream mode from stdin
6015 @cindex read character, stream mode
6016 @cindex stream mode, read character
6017 @cindex file operation, read character
6020 @item @emph{Description}:
6021 Read a single character in stream mode from stdin by bypassing normal
6022 formatted output. Stream I/O should not be mixed with normal record-oriented
6023 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
6025 This intrinsic is provided in both subroutine and function forms; however,
6026 only one form can be used in any given program unit.
6028 Note that the @code{FGET} intrinsic is provided for backwards compatibility with
6029 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
6030 Programmers should consider the use of new stream IO feature in new code
6031 for future portability. See also @ref{Fortran 2003 status}.
6033 @item @emph{Standard}:
6037 Subroutine, function
6039 @item @emph{Syntax}:
6040 @multitable @columnfractions .80
6041 @item @code{CALL FGET(C [, STATUS])}
6042 @item @code{STATUS = FGET(C)}
6045 @item @emph{Arguments}:
6046 @multitable @columnfractions .15 .70
6047 @item @var{C} @tab The type shall be @code{CHARACTER} and of default
6049 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
6050 Returns 0 on success, -1 on end-of-file, and a system specific positive
6051 error code otherwise.
6054 @item @emph{Example}:
6057 INTEGER, PARAMETER :: strlen = 100
6058 INTEGER :: status, i = 1
6059 CHARACTER(len=strlen) :: str = ""
6061 WRITE (*,*) 'Enter text:'
6063 CALL fget(str(i:i), status)
6064 if (status /= 0 .OR. i > strlen) exit
6067 WRITE (*,*) TRIM(str)
6071 @item @emph{See also}:
6080 @section @code{FGETC} --- Read a single character in stream mode
6082 @cindex read character, stream mode
6083 @cindex stream mode, read character
6084 @cindex file operation, read character
6087 @item @emph{Description}:
6088 Read a single character in stream mode by bypassing normal formatted output.
6089 Stream I/O should not be mixed with normal record-oriented (formatted or
6090 unformatted) I/O on the same unit; the results are unpredictable.
6092 This intrinsic is provided in both subroutine and function forms; however,
6093 only one form can be used in any given program unit.
6095 Note that the @code{FGET} intrinsic is provided for backwards compatibility
6096 with @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
6097 Programmers should consider the use of new stream IO feature in new code
6098 for future portability. See also @ref{Fortran 2003 status}.
6100 @item @emph{Standard}:
6104 Subroutine, function
6106 @item @emph{Syntax}:
6107 @multitable @columnfractions .80
6108 @item @code{CALL FGETC(UNIT, C [, STATUS])}
6109 @item @code{STATUS = FGETC(UNIT, C)}
6112 @item @emph{Arguments}:
6113 @multitable @columnfractions .15 .70
6114 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
6115 @item @var{C} @tab The type shall be @code{CHARACTER} and of default
6117 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
6118 Returns 0 on success, -1 on end-of-file and a system specific positive
6119 error code otherwise.
6122 @item @emph{Example}:
6125 INTEGER :: fd = 42, status
6128 OPEN(UNIT=fd, FILE="/etc/passwd", ACTION="READ", STATUS = "OLD")
6130 CALL fgetc(fd, c, status)
6131 IF (status /= 0) EXIT
6138 @item @emph{See also}:
6145 @section @code{FINDLOC} --- Search an array for a value
6150 @item @emph{Description}:
6151 Determines the location of the element in the array with the value
6152 given in the @var{VALUE} argument, or, if the @var{DIM} argument is
6153 supplied, determines the locations of the elements equal to the
6154 @var{VALUE} argument element along each
6155 row of the array in the @var{DIM} direction. If @var{MASK} is
6156 present, only the elements for which @var{MASK} is @code{.TRUE.} are
6157 considered. If more than one element in the array has the value
6158 @var{VALUE}, the location returned is that of the first such element
6159 in array element order if the @var{BACK} is not present or if it is
6160 @code{.FALSE.}. If @var{BACK} is true, the location returned is that
6161 of the last such element. If the array has zero size, or all of the
6162 elements of @var{MASK} are @code{.FALSE.}, then the result is an array
6163 of zeroes. Similarly, if @var{DIM} is supplied and all of the
6164 elements of @var{MASK} along a given row are zero, the result value
6165 for that row is zero.
6167 @item @emph{Standard}:
6168 Fortran 2008 and later.
6171 Transformational function
6173 @item @emph{Syntax}:
6174 @multitable @columnfractions .80
6175 @item @code{RESULT = FINDLOC(ARRAY, VALUE, DIM [, MASK] [,KIND] [,BACK])}
6176 @item @code{RESULT = FINDLOC(ARRAY, VALUE, [, MASK] [,KIND] [,BACK])}
6179 @item @emph{Arguments}:
6180 @multitable @columnfractions .15 .70
6181 @item @var{ARRAY} @tab Shall be an array of intrinsic type.
6182 @item @var{VALUE} @tab A scalar of intrinsic type which is in type
6183 conformance with @var{ARRAY}.
6184 @item @var{DIM} @tab (Optional) Shall be a scalar of type
6185 @code{INTEGER}, with a value between one and the rank of @var{ARRAY},
6186 inclusive. It may not be an optional dummy argument.
6187 @item @var{MASK} @tab (Optional) Shall be of type @code{LOGICAL},
6188 and conformable with @var{ARRAY}.
6189 @item @var{KIND} @tab (Optional) A scalar @code{INTEGER} constant
6190 expression indicating the kind parameter of the result.
6191 @item @var{BACK} @tab (Optional) A scalar of type @code{LOGICAL}.
6194 @item @emph{Return value}:
6195 If @var{DIM} is absent, the result is a rank-one array with a length
6196 equal to the rank of @var{ARRAY}. If @var{DIM} is present, the result
6197 is an array with a rank one less than the rank of @var{ARRAY}, and a
6198 size corresponding to the size of @var{ARRAY} with the @var{DIM}
6199 dimension removed. If @var{DIM} is present and @var{ARRAY} has a rank
6200 of one, the result is a scalar. If the optional argument @var{KIND}
6201 is present, the result is an integer of kind @var{KIND}, otherwise it
6204 @item @emph{See also}:
6211 @section @code{FLOOR} --- Integer floor function
6214 @cindex rounding, floor
6217 @item @emph{Description}:
6218 @code{FLOOR(A)} returns the greatest integer less than or equal to @var{A}.
6220 @item @emph{Standard}:
6221 Fortran 95 and later
6226 @item @emph{Syntax}:
6227 @code{RESULT = FLOOR(A [, KIND])}
6229 @item @emph{Arguments}:
6230 @multitable @columnfractions .15 .70
6231 @item @var{A} @tab The type shall be @code{REAL}.
6232 @item @var{KIND} @tab (Optional) A scalar @code{INTEGER} constant
6233 expression indicating the kind parameter of the result.
6236 @item @emph{Return value}:
6237 The return value is of type @code{INTEGER(KIND)} if @var{KIND} is present
6238 and of default-kind @code{INTEGER} otherwise.
6240 @item @emph{Example}:
6245 print *, floor(x) ! returns 63
6246 print *, floor(y) ! returns -64
6247 end program test_floor
6250 @item @emph{See also}:
6258 @section @code{FLUSH} --- Flush I/O unit(s)
6260 @cindex file operation, flush
6263 @item @emph{Description}:
6264 Flushes Fortran unit(s) currently open for output. Without the optional
6265 argument, all units are flushed, otherwise just the unit specified.
6267 @item @emph{Standard}:
6273 @item @emph{Syntax}:
6274 @code{CALL FLUSH(UNIT)}
6276 @item @emph{Arguments}:
6277 @multitable @columnfractions .15 .70
6278 @item @var{UNIT} @tab (Optional) The type shall be @code{INTEGER}.
6282 Beginning with the Fortran 2003 standard, there is a @code{FLUSH}
6283 statement that should be preferred over the @code{FLUSH} intrinsic.
6285 The @code{FLUSH} intrinsic and the Fortran 2003 @code{FLUSH} statement
6286 have identical effect: they flush the runtime library's I/O buffer so
6287 that the data becomes visible to other processes. This does not guarantee
6288 that the data is committed to disk.
6290 On POSIX systems, you can request that all data is transferred to the
6291 storage device by calling the @code{fsync} function, with the POSIX file
6292 descriptor of the I/O unit as argument (retrieved with GNU intrinsic
6293 @code{FNUM}). The following example shows how:
6296 ! Declare the interface for POSIX fsync function
6298 function fsync (fd) bind(c,name="fsync")
6299 use iso_c_binding, only: c_int
6300 integer(c_int), value :: fd
6301 integer(c_int) :: fsync
6305 ! Variable declaration
6309 open (10,file="foo")
6312 ! Perform I/O on unit 10
6317 ret = fsync(fnum(10))
6319 ! Handle possible error
6320 if (ret /= 0) stop "Error calling FSYNC"
6328 @section @code{FNUM} --- File number function
6330 @cindex file operation, file number
6333 @item @emph{Description}:
6334 @code{FNUM(UNIT)} returns the POSIX file descriptor number corresponding to the
6335 open Fortran I/O unit @code{UNIT}.
6337 @item @emph{Standard}:
6343 @item @emph{Syntax}:
6344 @code{RESULT = FNUM(UNIT)}
6346 @item @emph{Arguments}:
6347 @multitable @columnfractions .15 .70
6348 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
6351 @item @emph{Return value}:
6352 The return value is of type @code{INTEGER}
6354 @item @emph{Example}:
6358 open (unit=10, status = "scratch")
6362 end program test_fnum
6369 @section @code{FPUT} --- Write a single character in stream mode to stdout
6371 @cindex write character, stream mode
6372 @cindex stream mode, write character
6373 @cindex file operation, write character
6376 @item @emph{Description}:
6377 Write a single character in stream mode to stdout by bypassing normal
6378 formatted output. Stream I/O should not be mixed with normal record-oriented
6379 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
6381 This intrinsic is provided in both subroutine and function forms; however,
6382 only one form can be used in any given program unit.
6384 Note that the @code{FGET} intrinsic is provided for backwards compatibility with
6385 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
6386 Programmers should consider the use of new stream IO feature in new code
6387 for future portability. See also @ref{Fortran 2003 status}.
6389 @item @emph{Standard}:
6393 Subroutine, function
6395 @item @emph{Syntax}:
6396 @multitable @columnfractions .80
6397 @item @code{CALL FPUT(C [, STATUS])}
6398 @item @code{STATUS = FPUT(C)}
6401 @item @emph{Arguments}:
6402 @multitable @columnfractions .15 .70
6403 @item @var{C} @tab The type shall be @code{CHARACTER} and of default
6405 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
6406 Returns 0 on success, -1 on end-of-file and a system specific positive
6407 error code otherwise.
6410 @item @emph{Example}:
6413 CHARACTER(len=10) :: str = "gfortran"
6415 DO i = 1, len_trim(str)
6421 @item @emph{See also}:
6430 @section @code{FPUTC} --- Write a single character in stream mode
6432 @cindex write character, stream mode
6433 @cindex stream mode, write character
6434 @cindex file operation, write character
6437 @item @emph{Description}:
6438 Write a single character in stream mode by bypassing normal formatted
6439 output. Stream I/O should not be mixed with normal record-oriented
6440 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
6442 This intrinsic is provided in both subroutine and function forms; however,
6443 only one form can be used in any given program unit.
6445 Note that the @code{FGET} intrinsic is provided for backwards compatibility with
6446 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
6447 Programmers should consider the use of new stream IO feature in new code
6448 for future portability. See also @ref{Fortran 2003 status}.
6450 @item @emph{Standard}:
6454 Subroutine, function
6456 @item @emph{Syntax}:
6457 @multitable @columnfractions .80
6458 @item @code{CALL FPUTC(UNIT, C [, STATUS])}
6459 @item @code{STATUS = FPUTC(UNIT, C)}
6462 @item @emph{Arguments}:
6463 @multitable @columnfractions .15 .70
6464 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
6465 @item @var{C} @tab The type shall be @code{CHARACTER} and of default
6467 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
6468 Returns 0 on success, -1 on end-of-file and a system specific positive
6469 error code otherwise.
6472 @item @emph{Example}:
6475 CHARACTER(len=10) :: str = "gfortran"
6476 INTEGER :: fd = 42, i
6478 OPEN(UNIT = fd, FILE = "out", ACTION = "WRITE", STATUS="NEW")
6479 DO i = 1, len_trim(str)
6480 CALL fputc(fd, str(i:i))
6486 @item @emph{See also}:
6495 @section @code{FRACTION} --- Fractional part of the model representation
6497 @cindex real number, fraction
6498 @cindex floating point, fraction
6501 @item @emph{Description}:
6502 @code{FRACTION(X)} returns the fractional part of the model
6503 representation of @code{X}.
6505 @item @emph{Standard}:
6506 Fortran 90 and later
6511 @item @emph{Syntax}:
6512 @code{Y = FRACTION(X)}
6514 @item @emph{Arguments}:
6515 @multitable @columnfractions .15 .70
6516 @item @var{X} @tab The type of the argument shall be a @code{REAL}.
6519 @item @emph{Return value}:
6520 The return value is of the same type and kind as the argument.
6521 The fractional part of the model representation of @code{X} is returned;
6522 it is @code{X * RADIX(X)**(-EXPONENT(X))}.
6524 @item @emph{Example}:
6526 program test_fraction
6529 print *, fraction(x), x * radix(x)**(-exponent(x))
6530 end program test_fraction
6538 @section @code{FREE} --- Frees memory
6540 @cindex pointer, cray
6543 @item @emph{Description}:
6544 Frees memory previously allocated by @code{MALLOC}. The @code{FREE}
6545 intrinsic is an extension intended to be used with Cray pointers, and is
6546 provided in GNU Fortran to allow user to compile legacy code. For
6547 new code using Fortran 95 pointers, the memory de-allocation intrinsic is
6550 @item @emph{Standard}:
6556 @item @emph{Syntax}:
6557 @code{CALL FREE(PTR)}
6559 @item @emph{Arguments}:
6560 @multitable @columnfractions .15 .70
6561 @item @var{PTR} @tab The type shall be @code{INTEGER}. It represents the
6562 location of the memory that should be de-allocated.
6565 @item @emph{Return value}:
6568 @item @emph{Example}:
6569 See @code{MALLOC} for an example.
6571 @item @emph{See also}:
6578 @section @code{FSEEK} --- Low level file positioning subroutine
6580 @cindex file operation, seek
6581 @cindex file operation, position
6584 @item @emph{Description}:
6585 Moves @var{UNIT} to the specified @var{OFFSET}. If @var{WHENCE}
6586 is set to 0, the @var{OFFSET} is taken as an absolute value @code{SEEK_SET},
6587 if set to 1, @var{OFFSET} is taken to be relative to the current position
6588 @code{SEEK_CUR}, and if set to 2 relative to the end of the file @code{SEEK_END}.
6589 On error, @var{STATUS} is set to a nonzero value. If @var{STATUS} the seek
6592 This intrinsic routine is not fully backwards compatible with @command{g77}.
6593 In @command{g77}, the @code{FSEEK} takes a statement label instead of a
6594 @var{STATUS} variable. If FSEEK is used in old code, change
6596 CALL FSEEK(UNIT, OFFSET, WHENCE, *label)
6601 CALL FSEEK(UNIT, OFFSET, WHENCE, status)
6602 IF (status /= 0) GOTO label
6605 Please note that GNU Fortran provides the Fortran 2003 Stream facility.
6606 Programmers should consider the use of new stream IO feature in new code
6607 for future portability. See also @ref{Fortran 2003 status}.
6609 @item @emph{Standard}:
6615 @item @emph{Syntax}:
6616 @code{CALL FSEEK(UNIT, OFFSET, WHENCE[, STATUS])}
6618 @item @emph{Arguments}:
6619 @multitable @columnfractions .15 .70
6620 @item @var{UNIT} @tab Shall be a scalar of type @code{INTEGER}.
6621 @item @var{OFFSET} @tab Shall be a scalar of type @code{INTEGER}.
6622 @item @var{WHENCE} @tab Shall be a scalar of type @code{INTEGER}.
6623 Its value shall be either 0, 1 or 2.
6624 @item @var{STATUS} @tab (Optional) shall be a scalar of type
6628 @item @emph{Example}:
6631 INTEGER, PARAMETER :: SEEK_SET = 0, SEEK_CUR = 1, SEEK_END = 2
6632 INTEGER :: fd, offset, ierr
6638 OPEN(UNIT=fd, FILE="fseek.test")
6639 CALL FSEEK(fd, offset, SEEK_SET, ierr) ! move to OFFSET
6640 print *, FTELL(fd), ierr
6642 CALL FSEEK(fd, 0, SEEK_END, ierr) ! move to end
6643 print *, FTELL(fd), ierr
6645 CALL FSEEK(fd, 0, SEEK_SET, ierr) ! move to beginning
6646 print *, FTELL(fd), ierr
6652 @item @emph{See also}:
6659 @section @code{FSTAT} --- Get file status
6661 @cindex file system, file status
6664 @item @emph{Description}:
6665 @code{FSTAT} is identical to @ref{STAT}, except that information about an
6666 already opened file is obtained.
6668 The elements in @code{VALUES} are the same as described by @ref{STAT}.
6670 This intrinsic is provided in both subroutine and function forms; however,
6671 only one form can be used in any given program unit.
6673 @item @emph{Standard}:
6677 Subroutine, function
6679 @item @emph{Syntax}:
6680 @multitable @columnfractions .80
6681 @item @code{CALL FSTAT(UNIT, VALUES [, STATUS])}
6682 @item @code{STATUS = FSTAT(UNIT, VALUES)}
6685 @item @emph{Arguments}:
6686 @multitable @columnfractions .15 .70
6687 @item @var{UNIT} @tab An open I/O unit number of type @code{INTEGER}.
6688 @item @var{VALUES} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
6689 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0
6690 on success and a system specific error code otherwise.
6693 @item @emph{Example}:
6694 See @ref{STAT} for an example.
6696 @item @emph{See also}:
6706 @section @code{FTELL} --- Current stream position
6708 @cindex file operation, position
6711 @item @emph{Description}:
6712 Retrieves the current position within an open file.
6714 This intrinsic is provided in both subroutine and function forms; however,
6715 only one form can be used in any given program unit.
6717 @item @emph{Standard}:
6721 Subroutine, function
6723 @item @emph{Syntax}:
6724 @multitable @columnfractions .80
6725 @item @code{CALL FTELL(UNIT, OFFSET)}
6726 @item @code{OFFSET = FTELL(UNIT)}
6729 @item @emph{Arguments}:
6730 @multitable @columnfractions .15 .70
6731 @item @var{OFFSET} @tab Shall of type @code{INTEGER}.
6732 @item @var{UNIT} @tab Shall of type @code{INTEGER}.
6735 @item @emph{Return value}:
6736 In either syntax, @var{OFFSET} is set to the current offset of unit
6737 number @var{UNIT}, or to @math{-1} if the unit is not currently open.
6739 @item @emph{Example}:
6743 OPEN(10, FILE="temp.dat")
6749 @item @emph{See also}:
6756 @section @code{GAMMA} --- Gamma function
6759 @cindex Gamma function
6760 @cindex Factorial function
6763 @item @emph{Description}:
6764 @code{GAMMA(X)} computes Gamma (@math{\Gamma}) of @var{X}. For positive,
6765 integer values of @var{X} the Gamma function simplifies to the factorial
6766 function @math{\Gamma(x)=(x-1)!}.
6770 \Gamma(x) = \int_0^\infty t^{x-1}{\rm e}^{-t}\,{\rm d}t
6774 @item @emph{Standard}:
6775 Fortran 2008 and later
6780 @item @emph{Syntax}:
6783 @item @emph{Arguments}:
6784 @multitable @columnfractions .15 .70
6785 @item @var{X} @tab Shall be of type @code{REAL} and neither zero
6786 nor a negative integer.
6789 @item @emph{Return value}:
6790 The return value is of type @code{REAL} of the same kind as @var{X}.
6792 @item @emph{Example}:
6796 x = gamma(x) ! returns 1.0
6797 end program test_gamma
6800 @item @emph{Specific names}:
6801 @multitable @columnfractions .20 .23 .20 .33
6802 @headitem Name @tab Argument @tab Return type @tab Standard
6803 @item @code{DGAMMA(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
6806 @item @emph{See also}:
6807 Logarithm of the Gamma function: @*
6814 @section @code{GERROR} --- Get last system error message
6816 @cindex system, error handling
6819 @item @emph{Description}:
6820 Returns the system error message corresponding to the last system error.
6821 This resembles the functionality of @code{strerror(3)} in C.
6823 @item @emph{Standard}:
6829 @item @emph{Syntax}:
6830 @code{CALL GERROR(RESULT)}
6832 @item @emph{Arguments}:
6833 @multitable @columnfractions .15 .70
6834 @item @var{RESULT} @tab Shall be of type @code{CHARACTER} and of default kind.
6837 @item @emph{Example}:
6840 CHARACTER(len=100) :: msg
6846 @item @emph{See also}:
6854 @section @code{GETARG} --- Get command line arguments
6856 @cindex command-line arguments
6857 @cindex arguments, to program
6860 @item @emph{Description}:
6861 Retrieve the @var{POS}-th argument that was passed on the
6862 command line when the containing program was invoked.
6864 This intrinsic routine is provided for backwards compatibility with
6865 GNU Fortran 77. In new code, programmers should consider the use of
6866 the @ref{GET_COMMAND_ARGUMENT} intrinsic defined by the Fortran 2003
6869 @item @emph{Standard}:
6875 @item @emph{Syntax}:
6876 @code{CALL GETARG(POS, VALUE)}
6878 @item @emph{Arguments}:
6879 @multitable @columnfractions .15 .70
6880 @item @var{POS} @tab Shall be of type @code{INTEGER} and not wider than
6881 the default integer kind; @math{@var{POS} \geq 0}
6882 @item @var{VALUE} @tab Shall be of type @code{CHARACTER} and of default
6886 @item @emph{Return value}:
6887 After @code{GETARG} returns, the @var{VALUE} argument holds the
6888 @var{POS}th command line argument. If @var{VALUE} cannot hold the
6889 argument, it is truncated to fit the length of @var{VALUE}. If there are
6890 less than @var{POS} arguments specified at the command line, @var{VALUE}
6891 will be filled with blanks. If @math{@var{POS} = 0}, @var{VALUE} is set
6892 to the name of the program (on systems that support this feature).
6894 @item @emph{Example}:
6898 CHARACTER(len=32) :: arg
6907 @item @emph{See also}:
6908 GNU Fortran 77 compatibility function: @*
6910 Fortran 2003 functions and subroutines: @*
6911 @ref{GET_COMMAND}, @*
6912 @ref{GET_COMMAND_ARGUMENT}, @*
6913 @ref{COMMAND_ARGUMENT_COUNT}
6919 @section @code{GET_COMMAND} --- Get the entire command line
6920 @fnindex GET_COMMAND
6921 @cindex command-line arguments
6922 @cindex arguments, to program
6925 @item @emph{Description}:
6926 Retrieve the entire command line that was used to invoke the program.
6928 @item @emph{Standard}:
6929 Fortran 2003 and later
6934 @item @emph{Syntax}:
6935 @code{CALL GET_COMMAND([COMMAND, LENGTH, STATUS])}
6937 @item @emph{Arguments}:
6938 @multitable @columnfractions .15 .70
6939 @item @var{COMMAND} @tab (Optional) shall be of type @code{CHARACTER} and
6941 @item @var{LENGTH} @tab (Optional) Shall be of type @code{INTEGER} and of
6943 @item @var{STATUS} @tab (Optional) Shall be of type @code{INTEGER} and of
6947 @item @emph{Return value}:
6948 If @var{COMMAND} is present, stores the entire command line that was used
6949 to invoke the program in @var{COMMAND}. If @var{LENGTH} is present, it is
6950 assigned the length of the command line. If @var{STATUS} is present, it
6951 is assigned 0 upon success of the command, -1 if @var{COMMAND} is too
6952 short to store the command line, or a positive value in case of an error.
6954 @item @emph{Example}:
6956 PROGRAM test_get_command
6957 CHARACTER(len=255) :: cmd
6958 CALL get_command(cmd)
6959 WRITE (*,*) TRIM(cmd)
6963 @item @emph{See also}:
6964 @ref{GET_COMMAND_ARGUMENT}, @*
6965 @ref{COMMAND_ARGUMENT_COUNT}
6970 @node GET_COMMAND_ARGUMENT
6971 @section @code{GET_COMMAND_ARGUMENT} --- Get command line arguments
6972 @fnindex GET_COMMAND_ARGUMENT
6973 @cindex command-line arguments
6974 @cindex arguments, to program
6977 @item @emph{Description}:
6978 Retrieve the @var{NUMBER}-th argument that was passed on the
6979 command line when the containing program was invoked.
6981 @item @emph{Standard}:
6982 Fortran 2003 and later
6987 @item @emph{Syntax}:
6988 @code{CALL GET_COMMAND_ARGUMENT(NUMBER [, VALUE, LENGTH, STATUS])}
6990 @item @emph{Arguments}:
6991 @multitable @columnfractions .15 .70
6992 @item @var{NUMBER} @tab Shall be a scalar of type @code{INTEGER} and of
6993 default kind, @math{@var{NUMBER} \geq 0}
6994 @item @var{VALUE} @tab (Optional) Shall be a scalar of type @code{CHARACTER}
6995 and of default kind.
6996 @item @var{LENGTH} @tab (Optional) Shall be a scalar of type @code{INTEGER}
6997 and of default kind.
6998 @item @var{STATUS} @tab (Optional) Shall be a scalar of type @code{INTEGER}
6999 and of default kind.
7002 @item @emph{Return value}:
7003 After @code{GET_COMMAND_ARGUMENT} returns, the @var{VALUE} argument holds the
7004 @var{NUMBER}-th command line argument. If @var{VALUE} cannot hold the argument, it is
7005 truncated to fit the length of @var{VALUE}. If there are less than @var{NUMBER}
7006 arguments specified at the command line, @var{VALUE} will be filled with blanks.
7007 If @math{@var{NUMBER} = 0}, @var{VALUE} is set to the name of the program (on
7008 systems that support this feature). The @var{LENGTH} argument contains the
7009 length of the @var{NUMBER}-th command line argument. If the argument retrieval
7010 fails, @var{STATUS} is a positive number; if @var{VALUE} contains a truncated
7011 command line argument, @var{STATUS} is -1; and otherwise the @var{STATUS} is
7014 @item @emph{Example}:
7016 PROGRAM test_get_command_argument
7018 CHARACTER(len=32) :: arg
7022 CALL get_command_argument(i, arg)
7023 IF (LEN_TRIM(arg) == 0) EXIT
7025 WRITE (*,*) TRIM(arg)
7031 @item @emph{See also}:
7032 @ref{GET_COMMAND}, @*
7033 @ref{COMMAND_ARGUMENT_COUNT}
7039 @section @code{GETCWD} --- Get current working directory
7041 @cindex system, working directory
7044 @item @emph{Description}:
7045 Get current working directory.
7047 This intrinsic is provided in both subroutine and function forms; however,
7048 only one form can be used in any given program unit.
7050 @item @emph{Standard}:
7054 Subroutine, function
7056 @item @emph{Syntax}:
7057 @multitable @columnfractions .80
7058 @item @code{CALL GETCWD(C [, STATUS])}
7059 @item @code{STATUS = GETCWD(C)}
7062 @item @emph{Arguments}:
7063 @multitable @columnfractions .15 .70
7064 @item @var{C} @tab The type shall be @code{CHARACTER} and of default kind.
7065 @item @var{STATUS} @tab (Optional) status flag. Returns 0 on success,
7066 a system specific and nonzero error code otherwise.
7069 @item @emph{Example}:
7072 CHARACTER(len=255) :: cwd
7074 WRITE(*,*) TRIM(cwd)
7078 @item @emph{See also}:
7085 @section @code{GETENV} --- Get an environmental variable
7087 @cindex environment variable
7090 @item @emph{Description}:
7091 Get the @var{VALUE} of the environmental variable @var{NAME}.
7093 This intrinsic routine is provided for backwards compatibility with
7094 GNU Fortran 77. In new code, programmers should consider the use of
7095 the @ref{GET_ENVIRONMENT_VARIABLE} intrinsic defined by the Fortran
7098 Note that @code{GETENV} need not be thread-safe. It is the
7099 responsibility of the user to ensure that the environment is not being
7100 updated concurrently with a call to the @code{GETENV} intrinsic.
7102 @item @emph{Standard}:
7108 @item @emph{Syntax}:
7109 @code{CALL GETENV(NAME, VALUE)}
7111 @item @emph{Arguments}:
7112 @multitable @columnfractions .15 .70
7113 @item @var{NAME} @tab Shall be of type @code{CHARACTER} and of default kind.
7114 @item @var{VALUE} @tab Shall be of type @code{CHARACTER} and of default kind.
7117 @item @emph{Return value}:
7118 Stores the value of @var{NAME} in @var{VALUE}. If @var{VALUE} is
7119 not large enough to hold the data, it is truncated. If @var{NAME}
7120 is not set, @var{VALUE} will be filled with blanks.
7122 @item @emph{Example}:
7125 CHARACTER(len=255) :: homedir
7126 CALL getenv("HOME", homedir)
7127 WRITE (*,*) TRIM(homedir)
7131 @item @emph{See also}:
7132 @ref{GET_ENVIRONMENT_VARIABLE}
7137 @node GET_ENVIRONMENT_VARIABLE
7138 @section @code{GET_ENVIRONMENT_VARIABLE} --- Get an environmental variable
7139 @fnindex GET_ENVIRONMENT_VARIABLE
7140 @cindex environment variable
7143 @item @emph{Description}:
7144 Get the @var{VALUE} of the environmental variable @var{NAME}.
7146 Note that @code{GET_ENVIRONMENT_VARIABLE} need not be thread-safe. It
7147 is the responsibility of the user to ensure that the environment is
7148 not being updated concurrently with a call to the
7149 @code{GET_ENVIRONMENT_VARIABLE} intrinsic.
7151 @item @emph{Standard}:
7152 Fortran 2003 and later
7157 @item @emph{Syntax}:
7158 @code{CALL GET_ENVIRONMENT_VARIABLE(NAME[, VALUE, LENGTH, STATUS, TRIM_NAME)}
7160 @item @emph{Arguments}:
7161 @multitable @columnfractions .15 .70
7162 @item @var{NAME} @tab Shall be a scalar of type @code{CHARACTER}
7163 and of default kind.
7164 @item @var{VALUE} @tab (Optional) Shall be a scalar of type @code{CHARACTER}
7165 and of default kind.
7166 @item @var{LENGTH} @tab (Optional) Shall be a scalar of type @code{INTEGER}
7167 and of default kind.
7168 @item @var{STATUS} @tab (Optional) Shall be a scalar of type @code{INTEGER}
7169 and of default kind.
7170 @item @var{TRIM_NAME} @tab (Optional) Shall be a scalar of type @code{LOGICAL}
7171 and of default kind.
7174 @item @emph{Return value}:
7175 Stores the value of @var{NAME} in @var{VALUE}. If @var{VALUE} is
7176 not large enough to hold the data, it is truncated. If @var{NAME}
7177 is not set, @var{VALUE} will be filled with blanks. Argument @var{LENGTH}
7178 contains the length needed for storing the environment variable @var{NAME}
7179 or zero if it is not present. @var{STATUS} is -1 if @var{VALUE} is present
7180 but too short for the environment variable; it is 1 if the environment
7181 variable does not exist and 2 if the processor does not support environment
7182 variables; in all other cases @var{STATUS} is zero. If @var{TRIM_NAME} is
7183 present with the value @code{.FALSE.}, the trailing blanks in @var{NAME}
7184 are significant; otherwise they are not part of the environment variable
7187 @item @emph{Example}:
7190 CHARACTER(len=255) :: homedir
7191 CALL get_environment_variable("HOME", homedir)
7192 WRITE (*,*) TRIM(homedir)
7200 @section @code{GETGID} --- Group ID function
7202 @cindex system, group ID
7205 @item @emph{Description}:
7206 Returns the numerical group ID of the current process.
7208 @item @emph{Standard}:
7214 @item @emph{Syntax}:
7215 @code{RESULT = GETGID()}
7217 @item @emph{Return value}:
7218 The return value of @code{GETGID} is an @code{INTEGER} of the default
7222 @item @emph{Example}:
7223 See @code{GETPID} for an example.
7225 @item @emph{See also}:
7233 @section @code{GETLOG} --- Get login name
7235 @cindex system, login name
7239 @item @emph{Description}:
7240 Gets the username under which the program is running.
7242 @item @emph{Standard}:
7248 @item @emph{Syntax}:
7249 @code{CALL GETLOG(C)}
7251 @item @emph{Arguments}:
7252 @multitable @columnfractions .15 .70
7253 @item @var{C} @tab Shall be of type @code{CHARACTER} and of default kind.
7256 @item @emph{Return value}:
7257 Stores the current user name in @var{C}. (On systems where POSIX
7258 functions @code{geteuid} and @code{getpwuid} are not available, and
7259 the @code{getlogin} function is not implemented either, this will
7260 return a blank string.)
7262 @item @emph{Example}:
7265 CHARACTER(32) :: login
7271 @item @emph{See also}:
7278 @section @code{GETPID} --- Process ID function
7280 @cindex system, process ID
7284 @item @emph{Description}:
7285 Returns the numerical process identifier of the current process.
7287 @item @emph{Standard}:
7293 @item @emph{Syntax}:
7294 @code{RESULT = GETPID()}
7296 @item @emph{Return value}:
7297 The return value of @code{GETPID} is an @code{INTEGER} of the default
7301 @item @emph{Example}:
7304 print *, "The current process ID is ", getpid()
7305 print *, "Your numerical user ID is ", getuid()
7306 print *, "Your numerical group ID is ", getgid()
7310 @item @emph{See also}:
7318 @section @code{GETUID} --- User ID function
7320 @cindex system, user ID
7324 @item @emph{Description}:
7325 Returns the numerical user ID of the current process.
7327 @item @emph{Standard}:
7333 @item @emph{Syntax}:
7334 @code{RESULT = GETUID()}
7336 @item @emph{Return value}:
7337 The return value of @code{GETUID} is an @code{INTEGER} of the default
7341 @item @emph{Example}:
7342 See @code{GETPID} for an example.
7344 @item @emph{See also}:
7352 @section @code{GMTIME} --- Convert time to GMT info
7354 @cindex time, conversion to GMT info
7357 @item @emph{Description}:
7358 Given a system time value @var{TIME} (as provided by the @ref{TIME}
7359 intrinsic), fills @var{VALUES} with values extracted from it appropriate
7360 to the UTC time zone (Universal Coordinated Time, also known in some
7361 countries as GMT, Greenwich Mean Time), using @code{gmtime(3)}.
7363 This intrinsic routine is provided for backwards compatibility with
7364 GNU Fortran 77. In new code, programmers should consider the use of
7365 the @ref{DATE_AND_TIME} intrinsic defined by the Fortran 95
7368 @item @emph{Standard}:
7374 @item @emph{Syntax}:
7375 @code{CALL GMTIME(TIME, VALUES)}
7377 @item @emph{Arguments}:
7378 @multitable @columnfractions .15 .70
7379 @item @var{TIME} @tab An @code{INTEGER} scalar expression
7380 corresponding to a system time, with @code{INTENT(IN)}.
7381 @item @var{VALUES} @tab A default @code{INTEGER} array with 9 elements,
7382 with @code{INTENT(OUT)}.
7385 @item @emph{Return value}:
7386 The elements of @var{VALUES} are assigned as follows:
7388 @item Seconds after the minute, range 0--59 or 0--61 to allow for leap
7390 @item Minutes after the hour, range 0--59
7391 @item Hours past midnight, range 0--23
7392 @item Day of month, range 1--31
7393 @item Number of months since January, range 0--11
7394 @item Years since 1900
7395 @item Number of days since Sunday, range 0--6
7396 @item Days since January 1, range 0--365
7397 @item Daylight savings indicator: positive if daylight savings is in
7398 effect, zero if not, and negative if the information is not available.
7401 @item @emph{See also}:
7402 @ref{DATE_AND_TIME}, @*
7412 @section @code{HOSTNM} --- Get system host name
7414 @cindex system, host name
7417 @item @emph{Description}:
7418 Retrieves the host name of the system on which the program is running.
7420 This intrinsic is provided in both subroutine and function forms; however,
7421 only one form can be used in any given program unit.
7423 @item @emph{Standard}:
7427 Subroutine, function
7429 @item @emph{Syntax}:
7430 @multitable @columnfractions .80
7431 @item @code{CALL HOSTNM(C [, STATUS])}
7432 @item @code{STATUS = HOSTNM(NAME)}
7435 @item @emph{Arguments}:
7436 @multitable @columnfractions .15 .70
7437 @item @var{C} @tab Shall of type @code{CHARACTER} and of default kind.
7438 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
7439 Returns 0 on success, or a system specific error code otherwise.
7442 @item @emph{Return value}:
7443 In either syntax, @var{NAME} is set to the current hostname if it can
7444 be obtained, or to a blank string otherwise.
7451 @section @code{HUGE} --- Largest number of a kind
7453 @cindex limits, largest number
7454 @cindex model representation, largest number
7457 @item @emph{Description}:
7458 @code{HUGE(X)} returns the largest number that is not an infinity in
7459 the model of the type of @code{X}.
7461 @item @emph{Standard}:
7462 Fortran 90 and later
7467 @item @emph{Syntax}:
7468 @code{RESULT = HUGE(X)}
7470 @item @emph{Arguments}:
7471 @multitable @columnfractions .15 .70
7472 @item @var{X} @tab Shall be of type @code{REAL} or @code{INTEGER}.
7475 @item @emph{Return value}:
7476 The return value is of the same type and kind as @var{X}
7478 @item @emph{Example}:
7480 program test_huge_tiny
7481 print *, huge(0), huge(0.0), huge(0.0d0)
7482 print *, tiny(0.0), tiny(0.0d0)
7483 end program test_huge_tiny
7490 @section @code{HYPOT} --- Euclidean distance function
7492 @cindex Euclidean distance
7495 @item @emph{Description}:
7496 @code{HYPOT(X,Y)} is the Euclidean distance function. It is equal to
7497 @math{\sqrt{X^2 + Y^2}}, without undue underflow or overflow.
7499 @item @emph{Standard}:
7500 Fortran 2008 and later
7505 @item @emph{Syntax}:
7506 @code{RESULT = HYPOT(X, Y)}
7508 @item @emph{Arguments}:
7509 @multitable @columnfractions .15 .70
7510 @item @var{X} @tab The type shall be @code{REAL}.
7511 @item @var{Y} @tab The type and kind type parameter shall be the same as
7515 @item @emph{Return value}:
7516 The return value has the same type and kind type parameter as @var{X}.
7518 @item @emph{Example}:
7521 real(4) :: x = 1.e0_4, y = 0.5e0_4
7523 end program test_hypot
7530 @section @code{IACHAR} --- Code in @acronym{ASCII} collating sequence
7532 @cindex @acronym{ASCII} collating sequence
7533 @cindex collating sequence, @acronym{ASCII}
7534 @cindex conversion, to integer
7537 @item @emph{Description}:
7538 @code{IACHAR(C)} returns the code for the @acronym{ASCII} character
7539 in the first character position of @code{C}.
7541 @item @emph{Standard}:
7542 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
7547 @item @emph{Syntax}:
7548 @code{RESULT = IACHAR(C [, KIND])}
7550 @item @emph{Arguments}:
7551 @multitable @columnfractions .15 .70
7552 @item @var{C} @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
7553 @item @var{KIND} @tab (Optional) A scalar @code{INTEGER} constant
7554 expression indicating the kind parameter of the result.
7557 @item @emph{Return value}:
7558 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
7559 @var{KIND} is absent, the return value is of default integer kind.
7561 @item @emph{Example}:
7566 end program test_iachar
7570 See @ref{ICHAR} for a discussion of converting between numerical values
7571 and formatted string representations.
7573 @item @emph{See also}:
7582 @section @code{IALL} --- Bitwise AND of array elements
7585 @cindex bits, AND of array elements
7588 @item @emph{Description}:
7589 Reduces with bitwise AND the elements of @var{ARRAY} along dimension @var{DIM}
7590 if the corresponding element in @var{MASK} is @code{TRUE}.
7592 @item @emph{Standard}:
7593 Fortran 2008 and later
7596 Transformational function
7598 @item @emph{Syntax}:
7599 @multitable @columnfractions .80
7600 @item @code{RESULT = IALL(ARRAY[, MASK])}
7601 @item @code{RESULT = IALL(ARRAY, DIM[, MASK])}
7604 @item @emph{Arguments}:
7605 @multitable @columnfractions .15 .70
7606 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER}
7607 @item @var{DIM} @tab (Optional) shall be a scalar of type
7608 @code{INTEGER} with a value in the range from 1 to n, where n
7609 equals the rank of @var{ARRAY}.
7610 @item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL}
7611 and either be a scalar or an array of the same shape as @var{ARRAY}.
7614 @item @emph{Return value}:
7615 The result is of the same type as @var{ARRAY}.
7617 If @var{DIM} is absent, a scalar with the bitwise ALL of all elements in
7618 @var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals
7619 the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with
7620 dimension @var{DIM} dropped is returned.
7622 @item @emph{Example}:
7631 PRINT '(b8.8)', IALL(a)
7635 @item @emph{See also}:
7644 @section @code{IAND} --- Bitwise logical and
7650 @cindex bitwise logical and
7651 @cindex logical and, bitwise
7654 @item @emph{Description}:
7655 Bitwise logical @code{AND}.
7657 @item @emph{Standard}:
7658 Fortran 90 and later, with boz-literal-constant Fortran 2008 and later, has overloads that are GNU extensions
7663 @item @emph{Syntax}:
7664 @code{RESULT = IAND(I, J)}
7666 @item @emph{Arguments}:
7667 @multitable @columnfractions .15 .70
7668 @item @var{I} @tab The type shall be @code{INTEGER} or a boz-literal-constant.
7669 @item @var{J} @tab The type shall be @code{INTEGER} with the same
7670 kind type parameter as @var{I} or a boz-literal-constant.
7671 @var{I} and @var{J} shall not both be boz-literal-constants.
7674 @item @emph{Return value}:
7675 The return type is @code{INTEGER} with the kind type parameter of the
7677 A boz-literal-constant is converted to an @code{INTEGER} with the kind
7678 type parameter of the other argument as-if a call to @ref{INT} occurred.
7680 @item @emph{Example}:
7684 DATA a / Z'F' /, b / Z'3' /
7685 WRITE (*,*) IAND(a, b)
7689 @item @emph{Specific names}:
7690 @multitable @columnfractions .20 .23 .20 .33
7691 @headitem Name @tab Argument @tab Return type @tab Standard
7692 @item @code{IAND(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 90 and later
7693 @item @code{BIAND(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
7694 @item @code{IIAND(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
7695 @item @code{JIAND(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
7696 @item @code{KIAND(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
7699 @item @emph{See also}:
7711 @section @code{IANY} --- Bitwise OR of array elements
7714 @cindex bits, OR of array elements
7717 @item @emph{Description}:
7718 Reduces with bitwise OR (inclusive or) the elements of @var{ARRAY} along
7719 dimension @var{DIM} if the corresponding element in @var{MASK} is @code{TRUE}.
7721 @item @emph{Standard}:
7722 Fortran 2008 and later
7725 Transformational function
7727 @item @emph{Syntax}:
7728 @multitable @columnfractions .80
7729 @item @code{RESULT = IANY(ARRAY[, MASK])}
7730 @item @code{RESULT = IANY(ARRAY, DIM[, MASK])}
7733 @item @emph{Arguments}:
7734 @multitable @columnfractions .15 .70
7735 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER}
7736 @item @var{DIM} @tab (Optional) shall be a scalar of type
7737 @code{INTEGER} with a value in the range from 1 to n, where n
7738 equals the rank of @var{ARRAY}.
7739 @item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL}
7740 and either be a scalar or an array of the same shape as @var{ARRAY}.
7743 @item @emph{Return value}:
7744 The result is of the same type as @var{ARRAY}.
7746 If @var{DIM} is absent, a scalar with the bitwise OR of all elements in
7747 @var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals
7748 the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with
7749 dimension @var{DIM} dropped is returned.
7751 @item @emph{Example}:
7760 PRINT '(b8.8)', IANY(a)
7764 @item @emph{See also}:
7773 @section @code{IARGC} --- Get the number of command line arguments
7775 @cindex command-line arguments
7776 @cindex command-line arguments, number of
7777 @cindex arguments, to program
7780 @item @emph{Description}:
7781 @code{IARGC} returns the number of arguments passed on the
7782 command line when the containing program was invoked.
7784 This intrinsic routine is provided for backwards compatibility with
7785 GNU Fortran 77. In new code, programmers should consider the use of
7786 the @ref{COMMAND_ARGUMENT_COUNT} intrinsic defined by the Fortran 2003
7789 @item @emph{Standard}:
7795 @item @emph{Syntax}:
7796 @code{RESULT = IARGC()}
7798 @item @emph{Arguments}:
7801 @item @emph{Return value}:
7802 The number of command line arguments, type @code{INTEGER(4)}.
7804 @item @emph{Example}:
7807 @item @emph{See also}:
7808 GNU Fortran 77 compatibility subroutine: @*
7810 Fortran 2003 functions and subroutines: @*
7811 @ref{GET_COMMAND}, @*
7812 @ref{GET_COMMAND_ARGUMENT}, @*
7813 @ref{COMMAND_ARGUMENT_COUNT}
7819 @section @code{IBCLR} --- Clear bit
7829 @item @emph{Description}:
7830 @code{IBCLR} returns the value of @var{I} with the bit at position
7831 @var{POS} set to zero.
7833 @item @emph{Standard}:
7834 Fortran 90 and later, has overloads that are GNU extensions
7839 @item @emph{Syntax}:
7840 @code{RESULT = IBCLR(I, POS)}
7842 @item @emph{Arguments}:
7843 @multitable @columnfractions .15 .70
7844 @item @var{I} @tab The type shall be @code{INTEGER}.
7845 @item @var{POS} @tab The type shall be @code{INTEGER}.
7848 @item @emph{Return value}:
7849 The return value is of type @code{INTEGER} and of the same kind as
7852 @item @emph{Specific names}:
7853 @multitable @columnfractions .20 .23 .20 .33
7854 @headitem Name @tab Argument @tab Return type @tab Standard
7855 @item @code{IBCLR(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 90 and later
7856 @item @code{BBCLR(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
7857 @item @code{IIBCLR(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
7858 @item @code{JIBCLR(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
7859 @item @code{KIBCLR(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
7862 @item @emph{See also}:
7874 @section @code{IBITS} --- Bit extraction
7881 @cindex bits, extract
7884 @item @emph{Description}:
7885 @code{IBITS} extracts a field of length @var{LEN} from @var{I},
7886 starting from bit position @var{POS} and extending left for @var{LEN}
7887 bits. The result is right-justified and the remaining bits are
7888 zeroed. The value of @code{POS+LEN} must be less than or equal to the
7889 value @code{BIT_SIZE(I)}.
7891 @item @emph{Standard}:
7892 Fortran 90 and later, has overloads that are GNU extensions
7897 @item @emph{Syntax}:
7898 @code{RESULT = IBITS(I, POS, LEN)}
7900 @item @emph{Arguments}:
7901 @multitable @columnfractions .15 .70
7902 @item @var{I} @tab The type shall be @code{INTEGER}.
7903 @item @var{POS} @tab The type shall be @code{INTEGER}.
7904 @item @var{LEN} @tab The type shall be @code{INTEGER}.
7907 @item @emph{Return value}:
7908 The return value is of type @code{INTEGER} and of the same kind as
7911 @item @emph{Specific names}:
7912 @multitable @columnfractions .20 .23 .20 .33
7913 @headitem Name @tab Argument @tab Return type @tab Standard
7914 @item @code{IBITS(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 90 and later
7915 @item @code{BBITS(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
7916 @item @code{IIBITS(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
7917 @item @code{JIBITS(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
7918 @item @code{KIBITS(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
7921 @item @emph{See also}:
7933 @section @code{IBSET} --- Set bit
7942 @item @emph{Description}:
7943 @code{IBSET} returns the value of @var{I} with the bit at position
7944 @var{POS} set to one.
7946 @item @emph{Standard}:
7947 Fortran 90 and later, has overloads that are GNU extensions
7952 @item @emph{Syntax}:
7953 @code{RESULT = IBSET(I, POS)}
7955 @item @emph{Arguments}:
7956 @multitable @columnfractions .15 .70
7957 @item @var{I} @tab The type shall be @code{INTEGER}.
7958 @item @var{POS} @tab The type shall be @code{INTEGER}.
7961 @item @emph{Return value}:
7962 The return value is of type @code{INTEGER} and of the same kind as
7965 @item @emph{Specific names}:
7966 @multitable @columnfractions .20 .23 .20 .33
7967 @headitem Name @tab Argument @tab Return type @tab Standard
7968 @item @code{IBSET(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 90 and later
7969 @item @code{BBSET(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
7970 @item @code{IIBSET(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
7971 @item @code{JIBSET(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
7972 @item @code{KIBSET(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
7975 @item @emph{See also}:
7987 @section @code{ICHAR} --- Character-to-integer conversion function
7989 @cindex conversion, to integer
7992 @item @emph{Description}:
7993 @code{ICHAR(C)} returns the code for the character in the first character
7994 position of @code{C} in the system's native character set.
7995 The correspondence between characters and their codes is not necessarily
7996 the same across different GNU Fortran implementations.
7998 @item @emph{Standard}:
7999 Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later
8004 @item @emph{Syntax}:
8005 @code{RESULT = ICHAR(C [, KIND])}
8007 @item @emph{Arguments}:
8008 @multitable @columnfractions .15 .70
8009 @item @var{C} @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
8010 @item @var{KIND} @tab (Optional) A scalar @code{INTEGER} constant
8011 expression indicating the kind parameter of the result.
8014 @item @emph{Return value}:
8015 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
8016 @var{KIND} is absent, the return value is of default integer kind.
8018 @item @emph{Example}:
8023 end program test_ichar
8026 @item @emph{Specific names}:
8027 @multitable @columnfractions .20 .23 .20 .33
8028 @headitem Name @tab Argument @tab Return type @tab Standard
8029 @item @code{ICHAR(C)} @tab @code{CHARACTER C} @tab @code{INTEGER(4)} @tab Fortran 77 and later
8033 No intrinsic exists to convert between a numeric value and a formatted
8034 character string representation -- for instance, given the
8035 @code{CHARACTER} value @code{'154'}, obtaining an @code{INTEGER} or
8036 @code{REAL} value with the value 154, or vice versa. Instead, this
8037 functionality is provided by internal-file I/O, as in the following
8042 character(len=10) string, string2
8045 ! Convert a string to a numeric value
8046 read (string,'(I10)') value
8049 ! Convert a value to a formatted string
8050 write (string2,'(I10)') value
8052 end program read_val
8055 @item @emph{See also}:
8064 @section @code{IDATE} --- Get current local time subroutine (day/month/year)
8066 @cindex date, current
8067 @cindex current date
8070 @item @emph{Description}:
8071 @code{IDATE(VALUES)} Fills @var{VALUES} with the numerical values at the
8072 current local time. The day (in the range 1-31), month (in the range 1-12),
8073 and year appear in elements 1, 2, and 3 of @var{VALUES}, respectively.
8074 The year has four significant digits.
8076 This intrinsic routine is provided for backwards compatibility with
8077 GNU Fortran 77. In new code, programmers should consider the use of
8078 the @ref{DATE_AND_TIME} intrinsic defined by the Fortran 95
8081 @item @emph{Standard}:
8087 @item @emph{Syntax}:
8088 @code{CALL IDATE(VALUES)}
8090 @item @emph{Arguments}:
8091 @multitable @columnfractions .15 .70
8092 @item @var{VALUES} @tab The type shall be @code{INTEGER, DIMENSION(3)} and
8093 the kind shall be the default integer kind.
8096 @item @emph{Return value}:
8097 Does not return anything.
8099 @item @emph{Example}:
8102 integer, dimension(3) :: tarray
8107 end program test_idate
8110 @item @emph{See also}:
8116 @section @code{IEOR} --- Bitwise logical exclusive or
8122 @cindex bitwise logical exclusive or
8123 @cindex logical exclusive or, bitwise
8126 @item @emph{Description}:
8127 @code{IEOR} returns the bitwise Boolean exclusive-OR of @var{I} and
8130 @item @emph{Standard}:
8131 Fortran 90 and later, with boz-literal-constant Fortran 2008 and later, has overloads that are GNU extensions
8136 @item @emph{Syntax}:
8137 @code{RESULT = IEOR(I, J)}
8139 @item @emph{Arguments}:
8140 @multitable @columnfractions .15 .70
8141 @item @var{I} @tab The type shall be @code{INTEGER} or a boz-literal-constant.
8142 @item @var{J} @tab The type shall be @code{INTEGER} with the same
8143 kind type parameter as @var{I} or a boz-literal-constant.
8144 @var{I} and @var{J} shall not both be boz-literal-constants.
8147 @item @emph{Return value}:
8148 The return type is @code{INTEGER} with the kind type parameter of the
8150 A boz-literal-constant is converted to an @code{INTEGER} with the kind
8151 type parameter of the other argument as-if a call to @ref{INT} occurred.
8153 @item @emph{Specific names}:
8154 @multitable @columnfractions .20 .23 .20 .33
8155 @headitem Name @tab Argument @tab Return type @tab Standard
8156 @item @code{IEOR(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 90 and later
8157 @item @code{BIEOR(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
8158 @item @code{IIEOR(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
8159 @item @code{JIEOR(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
8160 @item @code{KIEOR(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
8163 @item @emph{See also}:
8175 @section @code{IERRNO} --- Get the last system error number
8177 @cindex system, error handling
8180 @item @emph{Description}:
8181 Returns the last system error number, as given by the C @code{errno}
8184 @item @emph{Standard}:
8190 @item @emph{Syntax}:
8191 @code{RESULT = IERRNO()}
8193 @item @emph{Arguments}:
8196 @item @emph{Return value}:
8197 The return value is of type @code{INTEGER} and of the default integer
8200 @item @emph{See also}:
8207 @section @code{IMAGE_INDEX} --- Function that converts a cosubscript to an image index
8208 @fnindex IMAGE_INDEX
8209 @cindex coarray, @code{IMAGE_INDEX}
8210 @cindex images, cosubscript to image index conversion
8213 @item @emph{Description}:
8214 Returns the image index belonging to a cosubscript.
8216 @item @emph{Standard}:
8217 Fortran 2008 and later
8222 @item @emph{Syntax}:
8223 @code{RESULT = IMAGE_INDEX(COARRAY, SUB)}
8225 @item @emph{Arguments}:
8226 @multitable @columnfractions .15 .70
8227 @item @var{COARRAY} @tab Coarray of any type.
8228 @item @var{SUB} @tab default integer rank-1 array of a size equal to
8229 the corank of @var{COARRAY}.
8233 @item @emph{Return value}:
8234 Scalar default integer with the value of the image index which corresponds
8235 to the cosubscripts. For invalid cosubscripts the result is zero.
8237 @item @emph{Example}:
8239 INTEGER :: array[2,-1:4,8,*]
8240 ! Writes 28 (or 0 if there are fewer than 28 images)
8241 WRITE (*,*) IMAGE_INDEX (array, [2,0,3,1])
8244 @item @emph{See also}:
8245 @ref{THIS_IMAGE}, @*
8251 @node INDEX intrinsic
8252 @section @code{INDEX} --- Position of a substring within a string
8254 @cindex substring position
8255 @cindex string, find substring
8258 @item @emph{Description}:
8259 Returns the position of the start of the first occurrence of string
8260 @var{SUBSTRING} as a substring in @var{STRING}, counting from one. If
8261 @var{SUBSTRING} is not present in @var{STRING}, zero is returned. If
8262 the @var{BACK} argument is present and true, the return value is the
8263 start of the last occurrence rather than the first.
8265 @item @emph{Standard}:
8266 Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later
8271 @item @emph{Syntax}:
8272 @code{RESULT = INDEX(STRING, SUBSTRING [, BACK [, KIND]])}
8274 @item @emph{Arguments}:
8275 @multitable @columnfractions .15 .70
8276 @item @var{STRING} @tab Shall be a scalar @code{CHARACTER}, with
8278 @item @var{SUBSTRING} @tab Shall be a scalar @code{CHARACTER}, with
8280 @item @var{BACK} @tab (Optional) Shall be a scalar @code{LOGICAL}, with
8282 @item @var{KIND} @tab (Optional) A scalar @code{INTEGER} constant
8283 expression indicating the kind parameter of the result.
8286 @item @emph{Return value}:
8287 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
8288 @var{KIND} is absent, the return value is of default integer kind.
8290 @item @emph{Specific names}:
8291 @multitable @columnfractions .35 .15 .17 .30
8292 @headitem Name @tab Argument @tab Return type @tab Standard
8293 @item @code{INDEX(STRING,SUBSTRING)} @tab @code{CHARACTER} @tab @code{INTEGER(4)} @tab Fortran 77 and later
8296 @item @emph{See also}:
8304 @section @code{INT} --- Convert to integer type
8308 @cindex conversion, to integer
8311 @item @emph{Description}:
8312 Convert to integer type
8314 @item @emph{Standard}:
8315 Fortran 77 and later, with boz-literal-constant Fortran 2008 and later.
8320 @item @emph{Syntax}:
8321 @code{RESULT = INT(A [, KIND))}
8323 @item @emph{Arguments}:
8324 @multitable @columnfractions .15 .70
8325 @item @var{A} @tab Shall be of type @code{INTEGER},
8326 @code{REAL}, or @code{COMPLEX} or a boz-literal-constant.
8327 @item @var{KIND} @tab (Optional) A scalar @code{INTEGER} constant
8328 expression indicating the kind parameter of the result.
8331 @item @emph{Return value}:
8332 These functions return a @code{INTEGER} variable or array under
8333 the following rules:
8337 If @var{A} is of type @code{INTEGER}, @code{INT(A) = A}
8339 If @var{A} is of type @code{REAL} and @math{|A| < 1}, @code{INT(A)}
8340 equals @code{0}. If @math{|A| \geq 1}, then @code{INT(A)} is the integer
8341 whose magnitude is the largest integer that does not exceed the magnitude
8342 of @var{A} and whose sign is the same as the sign of @var{A}.
8344 If @var{A} is of type @code{COMPLEX}, rule B is applied to the real part of @var{A}.
8347 @item @emph{Example}:
8351 complex :: z = (-3.7, 1.0)
8353 print *, int(z), int(z,8)
8357 @item @emph{Specific names}:
8358 @multitable @columnfractions .20 .23 .20 .33
8359 @headitem Name @tab Argument @tab Return type @tab Standard
8360 @item @code{INT(A)} @tab @code{REAL(4) A} @tab @code{INTEGER} @tab Fortran 77 and later
8361 @item @code{IFIX(A)} @tab @code{REAL(4) A} @tab @code{INTEGER} @tab Fortran 77 and later
8362 @item @code{IDINT(A)} @tab @code{REAL(8) A} @tab @code{INTEGER} @tab Fortran 77 and later
8369 @section @code{INT2} --- Convert to 16-bit integer type
8371 @cindex conversion, to integer
8374 @item @emph{Description}:
8375 Convert to a @code{KIND=2} integer type. This is equivalent to the
8376 standard @code{INT} intrinsic with an optional argument of
8377 @code{KIND=2}, and is only included for backwards compatibility.
8379 @item @emph{Standard}:
8385 @item @emph{Syntax}:
8386 @code{RESULT = INT2(A)}
8388 @item @emph{Arguments}:
8389 @multitable @columnfractions .15 .70
8390 @item @var{A} @tab Shall be of type @code{INTEGER},
8391 @code{REAL}, or @code{COMPLEX}.
8394 @item @emph{Return value}:
8395 The return value is a @code{INTEGER(2)} variable.
8397 @item @emph{See also}:
8405 @section @code{INT8} --- Convert to 64-bit integer type
8407 @cindex conversion, to integer
8410 @item @emph{Description}:
8411 Convert to a @code{KIND=8} integer type. This is equivalent to the
8412 standard @code{INT} intrinsic with an optional argument of
8413 @code{KIND=8}, and is only included for backwards compatibility.
8415 @item @emph{Standard}:
8421 @item @emph{Syntax}:
8422 @code{RESULT = INT8(A)}
8424 @item @emph{Arguments}:
8425 @multitable @columnfractions .15 .70
8426 @item @var{A} @tab Shall be of type @code{INTEGER},
8427 @code{REAL}, or @code{COMPLEX}.
8430 @item @emph{Return value}:
8431 The return value is a @code{INTEGER(8)} variable.
8433 @item @emph{See also}:
8441 @section @code{IOR} --- Bitwise logical or
8447 @cindex bitwise logical or
8448 @cindex logical or, bitwise
8451 @item @emph{Description}:
8452 @code{IOR} returns the bitwise Boolean inclusive-OR of @var{I} and
8455 @item @emph{Standard}:
8456 Fortran 90 and later, with boz-literal-constant Fortran 2008 and later, has overloads that are GNU extensions
8461 @item @emph{Syntax}:
8462 @code{RESULT = IOR(I, J)}
8464 @item @emph{Arguments}:
8465 @multitable @columnfractions .15 .70
8466 @item @var{I} @tab The type shall be @code{INTEGER} or a boz-literal-constant.
8467 @item @var{J} @tab The type shall be @code{INTEGER} with the same
8468 kind type parameter as @var{I} or a boz-literal-constant.
8469 @var{I} and @var{J} shall not both be boz-literal-constants.
8472 @item @emph{Return value}:
8473 The return type is @code{INTEGER} with the kind type parameter of the
8475 A boz-literal-constant is converted to an @code{INTEGER} with the kind
8476 type parameter of the other argument as-if a call to @ref{INT} occurred.
8478 @item @emph{Specific names}:
8479 @multitable @columnfractions .20 .23 .20 .33
8480 @headitem Name @tab Argument @tab Return type @tab Standard
8481 @item @code{IOR(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 90 and later
8482 @item @code{BIOR(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
8483 @item @code{IIOR(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
8484 @item @code{JIOR(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
8485 @item @code{KIOR(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
8488 @item @emph{See also}:
8500 @section @code{IPARITY} --- Bitwise XOR of array elements
8502 @cindex array, parity
8504 @cindex bits, XOR of array elements
8507 @item @emph{Description}:
8508 Reduces with bitwise XOR (exclusive or) the elements of @var{ARRAY} along
8509 dimension @var{DIM} if the corresponding element in @var{MASK} is @code{TRUE}.
8511 @item @emph{Standard}:
8512 Fortran 2008 and later
8515 Transformational function
8517 @item @emph{Syntax}:
8518 @multitable @columnfractions .80
8519 @item @code{RESULT = IPARITY(ARRAY[, MASK])}
8520 @item @code{RESULT = IPARITY(ARRAY, DIM[, MASK])}
8523 @item @emph{Arguments}:
8524 @multitable @columnfractions .15 .70
8525 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER}
8526 @item @var{DIM} @tab (Optional) shall be a scalar of type
8527 @code{INTEGER} with a value in the range from 1 to n, where n
8528 equals the rank of @var{ARRAY}.
8529 @item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL}
8530 and either be a scalar or an array of the same shape as @var{ARRAY}.
8533 @item @emph{Return value}:
8534 The result is of the same type as @var{ARRAY}.
8536 If @var{DIM} is absent, a scalar with the bitwise XOR of all elements in
8537 @var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals
8538 the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with
8539 dimension @var{DIM} dropped is returned.
8541 @item @emph{Example}:
8543 PROGRAM test_iparity
8546 a(1) = int(b'00100100', 1)
8547 a(2) = int(b'01101010', 1)
8550 PRINT '(b8.8)', IPARITY(a)
8554 @item @emph{See also}:
8564 @section @code{IRAND} --- Integer pseudo-random number
8566 @cindex random number generation
8569 @item @emph{Description}:
8570 @code{IRAND(FLAG)} returns a pseudo-random number from a uniform
8571 distribution between 0 and a system-dependent limit (which is in most
8572 cases 2147483647). If @var{FLAG} is 0, the next number
8573 in the current sequence is returned; if @var{FLAG} is 1, the generator
8574 is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
8575 it is used as a new seed with @code{SRAND}.
8577 This intrinsic routine is provided for backwards compatibility with
8578 GNU Fortran 77. It implements a simple modulo generator as provided
8579 by @command{g77}. For new code, one should consider the use of
8580 @ref{RANDOM_NUMBER} as it implements a superior algorithm.
8582 @item @emph{Standard}:
8588 @item @emph{Syntax}:
8589 @code{RESULT = IRAND(I)}
8591 @item @emph{Arguments}:
8592 @multitable @columnfractions .15 .70
8593 @item @var{I} @tab Shall be a scalar @code{INTEGER} of kind 4.
8596 @item @emph{Return value}:
8597 The return value is of @code{INTEGER(kind=4)} type.
8599 @item @emph{Example}:
8602 integer,parameter :: seed = 86456
8605 print *, irand(), irand(), irand(), irand()
8606 print *, irand(seed), irand(), irand(), irand()
8607 end program test_irand
8615 @section @code{IS_CONTIGUOUS} --- Test whether an array is contiguous
8616 @fnindex IS_IOSTAT_EOR
8617 @cindex array, contiguity
8620 @item @emph{Description}:
8621 @code{IS_CONTIGUOUS} tests whether an array is contiguous.
8623 @item @emph{Standard}:
8624 Fortran 2008 and later
8629 @item @emph{Syntax}:
8630 @code{RESULT = IS_CONTIGUOUS(ARRAY)}
8632 @item @emph{Arguments}:
8633 @multitable @columnfractions .15 .70
8634 @item @var{ARRAY} @tab Shall be an array of any type.
8637 @item @emph{Return value}:
8638 Returns a @code{LOGICAL} of the default kind, which @code{.TRUE.} if
8639 @var{ARRAY} is contiguous and false otherwise.
8641 @item @emph{Example}:
8645 a = [1,2,3,4,5,6,7,8,9,10]
8646 call sub (a) ! every element, is contiguous
8647 call sub (a(::2)) ! every other element, is noncontiguous
8651 if (is_contiguous (x)) then
8652 write (*,*) 'X is contiguous'
8654 write (*,*) 'X is not contiguous'
8664 @section @code{IS_IOSTAT_END} --- Test for end-of-file value
8665 @fnindex IS_IOSTAT_END
8666 @cindex @code{IOSTAT}, end of file
8669 @item @emph{Description}:
8670 @code{IS_IOSTAT_END} tests whether an variable has the value of the I/O
8671 status ``end of file''. The function is equivalent to comparing the variable
8672 with the @code{IOSTAT_END} parameter of the intrinsic module
8673 @code{ISO_FORTRAN_ENV}.
8675 @item @emph{Standard}:
8676 Fortran 2003 and later
8681 @item @emph{Syntax}:
8682 @code{RESULT = IS_IOSTAT_END(I)}
8684 @item @emph{Arguments}:
8685 @multitable @columnfractions .15 .70
8686 @item @var{I} @tab Shall be of the type @code{INTEGER}.
8689 @item @emph{Return value}:
8690 Returns a @code{LOGICAL} of the default kind, which @code{.TRUE.} if
8691 @var{I} has the value which indicates an end of file condition for
8692 @code{IOSTAT=} specifiers, and is @code{.FALSE.} otherwise.
8694 @item @emph{Example}:
8699 OPEN(88, FILE='test.dat')
8700 READ(88, *, IOSTAT=stat) i
8701 IF(IS_IOSTAT_END(stat)) STOP 'END OF FILE'
8709 @section @code{IS_IOSTAT_EOR} --- Test for end-of-record value
8710 @fnindex IS_IOSTAT_EOR
8711 @cindex @code{IOSTAT}, end of record
8714 @item @emph{Description}:
8715 @code{IS_IOSTAT_EOR} tests whether an variable has the value of the I/O
8716 status ``end of record''. The function is equivalent to comparing the
8717 variable with the @code{IOSTAT_EOR} parameter of the intrinsic module
8718 @code{ISO_FORTRAN_ENV}.
8720 @item @emph{Standard}:
8721 Fortran 2003 and later
8726 @item @emph{Syntax}:
8727 @code{RESULT = IS_IOSTAT_EOR(I)}
8729 @item @emph{Arguments}:
8730 @multitable @columnfractions .15 .70
8731 @item @var{I} @tab Shall be of the type @code{INTEGER}.
8734 @item @emph{Return value}:
8735 Returns a @code{LOGICAL} of the default kind, which @code{.TRUE.} if
8736 @var{I} has the value which indicates an end of file condition for
8737 @code{IOSTAT=} specifiers, and is @code{.FALSE.} otherwise.
8739 @item @emph{Example}:
8743 INTEGER :: stat, i(50)
8744 OPEN(88, FILE='test.dat', FORM='UNFORMATTED')
8745 READ(88, IOSTAT=stat) i
8746 IF(IS_IOSTAT_EOR(stat)) STOP 'END OF RECORD'
8753 @section @code{ISATTY} --- Whether a unit is a terminal device
8755 @cindex system, terminal
8758 @item @emph{Description}:
8759 Determine whether a unit is connected to a terminal device.
8761 @item @emph{Standard}:
8767 @item @emph{Syntax}:
8768 @code{RESULT = ISATTY(UNIT)}
8770 @item @emph{Arguments}:
8771 @multitable @columnfractions .15 .70
8772 @item @var{UNIT} @tab Shall be a scalar @code{INTEGER}.
8775 @item @emph{Return value}:
8776 Returns @code{.TRUE.} if the @var{UNIT} is connected to a terminal
8777 device, @code{.FALSE.} otherwise.
8779 @item @emph{Example}:
8782 INTEGER(kind=1) :: unit
8784 write(*,*) isatty(unit=unit)
8788 @item @emph{See also}:
8795 @section @code{ISHFT} --- Shift bits
8804 @item @emph{Description}:
8805 @code{ISHFT} returns a value corresponding to @var{I} with all of the
8806 bits shifted @var{SHIFT} places. A value of @var{SHIFT} greater than
8807 zero corresponds to a left shift, a value of zero corresponds to no
8808 shift, and a value less than zero corresponds to a right shift. If the
8809 absolute value of @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the
8810 value is undefined. Bits shifted out from the left end or right end are
8811 lost; zeros are shifted in from the opposite end.
8813 @item @emph{Standard}:
8814 Fortran 90 and later, has overloads that are GNU extensions
8819 @item @emph{Syntax}:
8820 @code{RESULT = ISHFT(I, SHIFT)}
8822 @item @emph{Arguments}:
8823 @multitable @columnfractions .15 .70
8824 @item @var{I} @tab The type shall be @code{INTEGER}.
8825 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
8828 @item @emph{Return value}:
8829 The return value is of type @code{INTEGER} and of the same kind as
8832 @item @emph{Specific names}:
8833 @multitable @columnfractions .20 .23 .20 .33
8834 @headitem Name @tab Argument @tab Return type @tab Standard
8835 @item @code{ISHFT(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 90 and later
8836 @item @code{BSHFT(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
8837 @item @code{IISHFT(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
8838 @item @code{JISHFT(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
8839 @item @code{KISHFT(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
8842 @item @emph{See also}:
8849 @section @code{ISHFTC} --- Shift bits circularly
8855 @cindex bits, shift circular
8858 @item @emph{Description}:
8859 @code{ISHFTC} returns a value corresponding to @var{I} with the
8860 rightmost @var{SIZE} bits shifted circularly @var{SHIFT} places; that
8861 is, bits shifted out one end are shifted into the opposite end. A value
8862 of @var{SHIFT} greater than zero corresponds to a left shift, a value of
8863 zero corresponds to no shift, and a value less than zero corresponds to
8864 a right shift. The absolute value of @var{SHIFT} must be less than
8865 @var{SIZE}. If the @var{SIZE} argument is omitted, it is taken to be
8866 equivalent to @code{BIT_SIZE(I)}.
8868 @item @emph{Standard}:
8869 Fortran 90 and later, has overloads that are GNU extensions
8874 @item @emph{Syntax}:
8875 @code{RESULT = ISHFTC(I, SHIFT [, SIZE])}
8877 @item @emph{Arguments}:
8878 @multitable @columnfractions .15 .70
8879 @item @var{I} @tab The type shall be @code{INTEGER}.
8880 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
8881 @item @var{SIZE} @tab (Optional) The type shall be @code{INTEGER};
8882 the value must be greater than zero and less than or equal to
8886 @item @emph{Return value}:
8887 The return value is of type @code{INTEGER} and of the same kind as
8890 @item @emph{Specific names}:
8891 @multitable @columnfractions .20 .23 .20 .33
8892 @headitem Name @tab Argument @tab Return type @tab Standard
8893 @item @code{ISHFTC(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 90 and later
8894 @item @code{BSHFTC(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
8895 @item @code{IISHFTC(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
8896 @item @code{JISHFTC(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
8897 @item @code{KISHFTC(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
8900 @item @emph{See also}:
8907 @section @code{ISNAN} --- Test for a NaN
8912 @item @emph{Description}:
8913 @code{ISNAN} tests whether a floating-point value is an IEEE
8915 @item @emph{Standard}:
8921 @item @emph{Syntax}:
8924 @item @emph{Arguments}:
8925 @multitable @columnfractions .15 .70
8926 @item @var{X} @tab Variable of the type @code{REAL}.
8930 @item @emph{Return value}:
8931 Returns a default-kind @code{LOGICAL}. The returned value is @code{TRUE}
8932 if @var{X} is a NaN and @code{FALSE} otherwise.
8934 @item @emph{Example}:
8941 if (isnan(x)) stop '"x" is a NaN'
8942 end program test_nan
8949 @section @code{ITIME} --- Get current local time subroutine (hour/minutes/seconds)
8951 @cindex time, current
8952 @cindex current time
8955 @item @emph{Description}:
8956 @code{ITIME(VALUES)} Fills @var{VALUES} with the numerical values at the
8957 current local time. The hour (in the range 1-24), minute (in the range 1-60),
8958 and seconds (in the range 1-60) appear in elements 1, 2, and 3 of @var{VALUES},
8961 This intrinsic routine is provided for backwards compatibility with
8962 GNU Fortran 77. In new code, programmers should consider the use of
8963 the @ref{DATE_AND_TIME} intrinsic defined by the Fortran 95
8966 @item @emph{Standard}:
8972 @item @emph{Syntax}:
8973 @code{CALL ITIME(VALUES)}
8975 @item @emph{Arguments}:
8976 @multitable @columnfractions .15 .70
8977 @item @var{VALUES} @tab The type shall be @code{INTEGER, DIMENSION(3)}
8978 and the kind shall be the default integer kind.
8981 @item @emph{Return value}:
8982 Does not return anything.
8985 @item @emph{Example}:
8988 integer, dimension(3) :: tarray
8993 end program test_itime
8996 @item @emph{See also}:
9003 @section @code{KILL} --- Send a signal to a process
9007 @item @emph{Description}:
9008 Sends the signal specified by @var{SIG} to the process @var{PID}.
9011 This intrinsic is provided in both subroutine and function forms;
9012 however, only one form can be used in any given program unit.
9013 @item @emph{Standard}:
9016 @item @emph{Standard}:
9020 Subroutine, function
9022 @item @emph{Syntax}:
9023 @multitable @columnfractions .80
9024 @item @code{CALL KILL(PID, SIG [, STATUS])}
9025 @item @code{STATUS = KILL(PID, SIG)}
9028 @item @emph{Arguments}:
9029 @multitable @columnfractions .15 .70
9030 @item @var{PID} @tab Shall be a scalar @code{INTEGER} with @code{INTENT(IN)}.
9031 @item @var{SIG} @tab Shall be a scalar @code{INTEGER} with @code{INTENT(IN)}.
9032 @item @var{STATUS} @tab [Subroutine](Optional)
9033 Shall be a scalar @code{INTEGER}.
9034 Returns 0 on success; otherwise a system-specific error code is returned.
9035 @item @var{STATUS} @tab [Function] The kind type parameter is that of
9037 Returns 0 on success; otherwise a system-specific error code is returned.
9040 @item @emph{See also}:
9047 @section @code{KIND} --- Kind of an entity
9052 @item @emph{Description}:
9053 @code{KIND(X)} returns the kind value of the entity @var{X}.
9055 @item @emph{Standard}:
9056 Fortran 95 and later
9061 @item @emph{Syntax}:
9064 @item @emph{Arguments}:
9065 @multitable @columnfractions .15 .70
9066 @item @var{X} @tab Shall be of type @code{LOGICAL}, @code{INTEGER},
9067 @code{REAL}, @code{COMPLEX} or @code{CHARACTER}. It may be scalar or
9071 @item @emph{Return value}:
9072 The return value is a scalar of type @code{INTEGER} and of the default
9075 @item @emph{Example}:
9078 integer,parameter :: kc = kind(' ')
9079 integer,parameter :: kl = kind(.true.)
9081 print *, "The default character kind is ", kc
9082 print *, "The default logical kind is ", kl
9083 end program test_kind
9091 @section @code{LBOUND} --- Lower dimension bounds of an array
9093 @cindex array, lower bound
9096 @item @emph{Description}:
9097 Returns the lower bounds of an array, or a single lower bound
9098 along the @var{DIM} dimension.
9099 @item @emph{Standard}:
9100 Fortran 90 and later, with @var{KIND} argument Fortran 2003 and later
9105 @item @emph{Syntax}:
9106 @code{RESULT = LBOUND(ARRAY [, DIM [, KIND]])}
9108 @item @emph{Arguments}:
9109 @multitable @columnfractions .15 .70
9110 @item @var{ARRAY} @tab Shall be an array, of any type.
9111 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
9112 @item @var{KIND} @tab (Optional) A scalar @code{INTEGER} constant
9113 expression indicating the kind parameter of the result.
9116 @item @emph{Return value}:
9117 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
9118 @var{KIND} is absent, the return value is of default integer kind.
9119 If @var{DIM} is absent, the result is an array of the lower bounds of
9120 @var{ARRAY}. If @var{DIM} is present, the result is a scalar
9121 corresponding to the lower bound of the array along that dimension. If
9122 @var{ARRAY} is an expression rather than a whole array or array
9123 structure component, or if it has a zero extent along the relevant
9124 dimension, the lower bound is taken to be 1.
9126 @item @emph{See also}:
9134 @section @code{LCOBOUND} --- Lower codimension bounds of an array
9136 @cindex coarray, lower bound
9139 @item @emph{Description}:
9140 Returns the lower bounds of a coarray, or a single lower cobound
9141 along the @var{DIM} codimension.
9142 @item @emph{Standard}:
9143 Fortran 2008 and later
9148 @item @emph{Syntax}:
9149 @code{RESULT = LCOBOUND(COARRAY [, DIM [, KIND]])}
9151 @item @emph{Arguments}:
9152 @multitable @columnfractions .15 .70
9153 @item @var{ARRAY} @tab Shall be an coarray, of any type.
9154 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
9155 @item @var{KIND} @tab (Optional) A scalar @code{INTEGER} constant
9156 expression indicating the kind parameter of the result.
9159 @item @emph{Return value}:
9160 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
9161 @var{KIND} is absent, the return value is of default integer kind.
9162 If @var{DIM} is absent, the result is an array of the lower cobounds of
9163 @var{COARRAY}. If @var{DIM} is present, the result is a scalar
9164 corresponding to the lower cobound of the array along that codimension.
9166 @item @emph{See also}:
9174 @section @code{LEADZ} --- Number of leading zero bits of an integer
9179 @item @emph{Description}:
9180 @code{LEADZ} returns the number of leading zero bits of an integer.
9182 @item @emph{Standard}:
9183 Fortran 2008 and later
9188 @item @emph{Syntax}:
9189 @code{RESULT = LEADZ(I)}
9191 @item @emph{Arguments}:
9192 @multitable @columnfractions .15 .70
9193 @item @var{I} @tab Shall be of type @code{INTEGER}.
9196 @item @emph{Return value}:
9197 The type of the return value is the default @code{INTEGER}.
9198 If all the bits of @code{I} are zero, the result value is @code{BIT_SIZE(I)}.
9200 @item @emph{Example}:
9203 WRITE (*,*) BIT_SIZE(1) ! prints 32
9204 WRITE (*,*) LEADZ(1) ! prints 31
9208 @item @emph{See also}:
9218 @section @code{LEN} --- Length of a character entity
9220 @cindex string, length
9223 @item @emph{Description}:
9224 Returns the length of a character string. If @var{STRING} is an array,
9225 the length of an element of @var{STRING} is returned. Note that
9226 @var{STRING} need not be defined when this intrinsic is invoked, since
9227 only the length, not the content, of @var{STRING} is needed.
9229 @item @emph{Standard}:
9230 Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later
9235 @item @emph{Syntax}:
9236 @code{L = LEN(STRING [, KIND])}
9238 @item @emph{Arguments}:
9239 @multitable @columnfractions .15 .70
9240 @item @var{STRING} @tab Shall be a scalar or array of type
9241 @code{CHARACTER}, with @code{INTENT(IN)}
9242 @item @var{KIND} @tab (Optional) A scalar @code{INTEGER} constant
9243 expression indicating the kind parameter of the result.
9246 @item @emph{Return value}:
9247 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
9248 @var{KIND} is absent, the return value is of default integer kind.
9251 @item @emph{Specific names}:
9252 @multitable @columnfractions .20 .23 .20 .33
9253 @headitem Name @tab Argument @tab Return type @tab Standard
9254 @item @code{LEN(STRING)} @tab @code{CHARACTER} @tab @code{INTEGER} @tab Fortran 77 and later
9258 @item @emph{See also}:
9267 @section @code{LEN_TRIM} --- Length of a character entity without trailing blank characters
9269 @cindex string, length, without trailing whitespace
9272 @item @emph{Description}:
9273 Returns the length of a character string, ignoring any trailing blanks.
9275 @item @emph{Standard}:
9276 Fortran 90 and later, with @var{KIND} argument Fortran 2003 and later
9281 @item @emph{Syntax}:
9282 @code{RESULT = LEN_TRIM(STRING [, KIND])}
9284 @item @emph{Arguments}:
9285 @multitable @columnfractions .15 .70
9286 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER},
9287 with @code{INTENT(IN)}
9288 @item @var{KIND} @tab (Optional) A scalar @code{INTEGER} constant
9289 expression indicating the kind parameter of the result.
9292 @item @emph{Return value}:
9293 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
9294 @var{KIND} is absent, the return value is of default integer kind.
9296 @item @emph{See also}:
9305 @section @code{LGE} --- Lexical greater than or equal
9307 @cindex lexical comparison of strings
9308 @cindex string, comparison
9311 @item @emph{Description}:
9312 Determines whether one string is lexically greater than or equal to
9313 another string, where the two strings are interpreted as containing
9314 ASCII character codes. If the String A and String B are not the same
9315 length, the shorter is compared as if spaces were appended to it to form
9316 a value that has the same length as the longer.
9318 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
9319 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
9320 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
9321 that the latter use the processor's character ordering (which is not
9322 ASCII on some targets), whereas the former always use the ASCII
9325 @item @emph{Standard}:
9326 Fortran 77 and later
9331 @item @emph{Syntax}:
9332 @code{RESULT = LGE(STRING_A, STRING_B)}
9334 @item @emph{Arguments}:
9335 @multitable @columnfractions .15 .70
9336 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
9337 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
9340 @item @emph{Return value}:
9341 Returns @code{.TRUE.} if @code{STRING_A >= STRING_B}, and @code{.FALSE.}
9342 otherwise, based on the ASCII ordering.
9344 @item @emph{Specific names}:
9345 @multitable @columnfractions .34 .16 .17 .30
9346 @headitem Name @tab Argument @tab Return type @tab Standard
9347 @item @code{LGE(STRING_A,STRING_B)} @tab @code{CHARACTER} @tab @code{LOGICAL} @tab Fortran 77 and later
9350 @item @emph{See also}:
9359 @section @code{LGT} --- Lexical greater than
9361 @cindex lexical comparison of strings
9362 @cindex string, comparison
9365 @item @emph{Description}:
9366 Determines whether one string is lexically greater than another string,
9367 where the two strings are interpreted as containing ASCII character
9368 codes. If the String A and String B are not the same length, the
9369 shorter is compared as if spaces were appended to it to form a value
9370 that has the same length as the longer.
9372 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
9373 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
9374 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
9375 that the latter use the processor's character ordering (which is not
9376 ASCII on some targets), whereas the former always use the ASCII
9379 @item @emph{Standard}:
9380 Fortran 77 and later
9385 @item @emph{Syntax}:
9386 @code{RESULT = LGT(STRING_A, STRING_B)}
9388 @item @emph{Arguments}:
9389 @multitable @columnfractions .15 .70
9390 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
9391 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
9394 @item @emph{Return value}:
9395 Returns @code{.TRUE.} if @code{STRING_A > STRING_B}, and @code{.FALSE.}
9396 otherwise, based on the ASCII ordering.
9398 @item @emph{Specific names}:
9399 @multitable @columnfractions .34 .16 .17 .30
9400 @headitem Name @tab Argument @tab Return type @tab Standard
9401 @item @code{LGT(STRING_A,STRING_B)} @tab @code{CHARACTER} @tab @code{LOGICAL} @tab Fortran 77 and later
9404 @item @emph{See also}:
9413 @section @code{LINK} --- Create a hard link
9415 @cindex file system, create link
9416 @cindex file system, hard link
9419 @item @emph{Description}:
9420 Makes a (hard) link from file @var{PATH1} to @var{PATH2}. A null
9421 character (@code{CHAR(0)}) can be used to mark the end of the names in
9422 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
9423 names are ignored. If the @var{STATUS} argument is supplied, it
9424 contains 0 on success or a nonzero error code upon return; see
9427 This intrinsic is provided in both subroutine and function forms;
9428 however, only one form can be used in any given program unit.
9430 @item @emph{Standard}:
9434 Subroutine, function
9436 @item @emph{Syntax}:
9437 @multitable @columnfractions .80
9438 @item @code{CALL LINK(PATH1, PATH2 [, STATUS])}
9439 @item @code{STATUS = LINK(PATH1, PATH2)}
9442 @item @emph{Arguments}:
9443 @multitable @columnfractions .15 .70
9444 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
9445 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
9446 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
9449 @item @emph{See also}:
9457 @section @code{LLE} --- Lexical less than or equal
9459 @cindex lexical comparison of strings
9460 @cindex string, comparison
9463 @item @emph{Description}:
9464 Determines whether one string is lexically less than or equal to another
9465 string, where the two strings are interpreted as containing ASCII
9466 character codes. If the String A and String B are not the same length,
9467 the shorter is compared as if spaces were appended to it to form a value
9468 that has the same length as the longer.
9470 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
9471 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
9472 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
9473 that the latter use the processor's character ordering (which is not
9474 ASCII on some targets), whereas the former always use the ASCII
9477 @item @emph{Standard}:
9478 Fortran 77 and later
9483 @item @emph{Syntax}:
9484 @code{RESULT = LLE(STRING_A, STRING_B)}
9486 @item @emph{Arguments}:
9487 @multitable @columnfractions .15 .70
9488 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
9489 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
9492 @item @emph{Return value}:
9493 Returns @code{.TRUE.} if @code{STRING_A <= STRING_B}, and @code{.FALSE.}
9494 otherwise, based on the ASCII ordering.
9496 @item @emph{Specific names}:
9497 @multitable @columnfractions .34 .16 .17 .30
9498 @headitem Name @tab Argument @tab Return type @tab Standard
9499 @item @code{LLE(STRING_A,STRING_B)} @tab @code{CHARACTER} @tab @code{LOGICAL} @tab Fortran 77 and later
9502 @item @emph{See also}:
9511 @section @code{LLT} --- Lexical less than
9513 @cindex lexical comparison of strings
9514 @cindex string, comparison
9517 @item @emph{Description}:
9518 Determines whether one string is lexically less than another string,
9519 where the two strings are interpreted as containing ASCII character
9520 codes. If the String A and String B are not the same length, the
9521 shorter is compared as if spaces were appended to it to form a value
9522 that has the same length as the longer.
9524 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
9525 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
9526 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
9527 that the latter use the processor's character ordering (which is not
9528 ASCII on some targets), whereas the former always use the ASCII
9531 @item @emph{Standard}:
9532 Fortran 77 and later
9537 @item @emph{Syntax}:
9538 @code{RESULT = LLT(STRING_A, STRING_B)}
9540 @item @emph{Arguments}:
9541 @multitable @columnfractions .15 .70
9542 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
9543 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
9546 @item @emph{Return value}:
9547 Returns @code{.TRUE.} if @code{STRING_A < STRING_B}, and @code{.FALSE.}
9548 otherwise, based on the ASCII ordering.
9550 @item @emph{Specific names}:
9551 @multitable @columnfractions .34 .16 .17 .30
9552 @headitem Name @tab Argument @tab Return type @tab Standard
9553 @item @code{LLT(STRING_A,STRING_B)} @tab @code{CHARACTER} @tab @code{LOGICAL} @tab Fortran 77 and later
9556 @item @emph{See also}:
9565 @section @code{LNBLNK} --- Index of the last non-blank character in a string
9567 @cindex string, find non-blank character
9570 @item @emph{Description}:
9571 Returns the length of a character string, ignoring any trailing blanks.
9572 This is identical to the standard @code{LEN_TRIM} intrinsic, and is only
9573 included for backwards compatibility.
9575 @item @emph{Standard}:
9581 @item @emph{Syntax}:
9582 @code{RESULT = LNBLNK(STRING)}
9584 @item @emph{Arguments}:
9585 @multitable @columnfractions .15 .70
9586 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER},
9587 with @code{INTENT(IN)}
9590 @item @emph{Return value}:
9591 The return value is of @code{INTEGER(kind=4)} type.
9593 @item @emph{See also}:
9594 @ref{INDEX intrinsic}, @*
9601 @section @code{LOC} --- Returns the address of a variable
9603 @cindex location of a variable in memory
9606 @item @emph{Description}:
9607 @code{LOC(X)} returns the address of @var{X} as an integer.
9609 @item @emph{Standard}:
9615 @item @emph{Syntax}:
9616 @code{RESULT = LOC(X)}
9618 @item @emph{Arguments}:
9619 @multitable @columnfractions .15 .70
9620 @item @var{X} @tab Variable of any type.
9623 @item @emph{Return value}:
9624 The return value is of type @code{INTEGER}, with a @code{KIND}
9625 corresponding to the size (in bytes) of a memory address on the target
9628 @item @emph{Example}:
9635 end program test_loc
9642 @section @code{LOG} --- Natural logarithm function
9649 @cindex exponential function, inverse
9650 @cindex logarithm function
9651 @cindex natural logarithm function
9654 @item @emph{Description}:
9655 @code{LOG(X)} computes the natural logarithm of @var{X}, i.e. the
9656 logarithm to the base @math{e}.
9658 @item @emph{Standard}:
9659 Fortran 77 and later, has GNU extensions
9664 @item @emph{Syntax}:
9665 @code{RESULT = LOG(X)}
9667 @item @emph{Arguments}:
9668 @multitable @columnfractions .15 .70
9669 @item @var{X} @tab The type shall be @code{REAL} or
9673 @item @emph{Return value}:
9674 The return value is of type @code{REAL} or @code{COMPLEX}.
9675 The kind type parameter is the same as @var{X}.
9676 If @var{X} is @code{COMPLEX}, the imaginary part @math{\omega} is in the range
9677 @math{-\pi < \omega \leq \pi}.
9679 @item @emph{Example}:
9682 real(8) :: x = 2.7182818284590451_8
9683 complex :: z = (1.0, 2.0)
9684 x = log(x) ! will yield (approximately) 1
9686 end program test_log
9689 @item @emph{Specific names}:
9690 @multitable @columnfractions .20 .23 .20 .33
9691 @headitem Name @tab Argument @tab Return type @tab Standard
9692 @item @code{ALOG(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 or later
9693 @item @code{DLOG(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 or later
9694 @item @code{CLOG(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab Fortran 77 or later
9695 @item @code{ZLOG(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
9696 @item @code{CDLOG(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
9703 @section @code{LOG10} --- Base 10 logarithm function
9707 @cindex exponential function, inverse
9708 @cindex logarithm function with base 10
9709 @cindex base 10 logarithm function
9712 @item @emph{Description}:
9713 @code{LOG10(X)} computes the base 10 logarithm of @var{X}.
9715 @item @emph{Standard}:
9716 Fortran 77 and later
9721 @item @emph{Syntax}:
9722 @code{RESULT = LOG10(X)}
9724 @item @emph{Arguments}:
9725 @multitable @columnfractions .15 .70
9726 @item @var{X} @tab The type shall be @code{REAL}.
9729 @item @emph{Return value}:
9730 The return value is of type @code{REAL} or @code{COMPLEX}.
9731 The kind type parameter is the same as @var{X}.
9733 @item @emph{Example}:
9736 real(8) :: x = 10.0_8
9738 end program test_log10
9741 @item @emph{Specific names}:
9742 @multitable @columnfractions .20 .23 .20 .33
9743 @headitem Name @tab Argument @tab Return type @tab Standard
9744 @item @code{ALOG10(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later
9745 @item @code{DLOG10(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
9752 @section @code{LOG_GAMMA} --- Logarithm of the Gamma function
9757 @cindex Gamma function, logarithm of
9760 @item @emph{Description}:
9761 @code{LOG_GAMMA(X)} computes the natural logarithm of the absolute value
9762 of the Gamma (@math{\Gamma}) function.
9764 @item @emph{Standard}:
9765 Fortran 2008 and later
9770 @item @emph{Syntax}:
9771 @code{X = LOG_GAMMA(X)}
9773 @item @emph{Arguments}:
9774 @multitable @columnfractions .15 .70
9775 @item @var{X} @tab Shall be of type @code{REAL} and neither zero
9776 nor a negative integer.
9779 @item @emph{Return value}:
9780 The return value is of type @code{REAL} of the same kind as @var{X}.
9782 @item @emph{Example}:
9784 program test_log_gamma
9786 x = lgamma(x) ! returns 0.0
9787 end program test_log_gamma
9790 @item @emph{Specific names}:
9791 @multitable @columnfractions .20 .23 .20 .33
9792 @headitem Name @tab Argument @tab Return type @tab Standard
9793 @item @code{LGAMMA(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU extension
9794 @item @code{ALGAMA(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU extension
9795 @item @code{DLGAMA(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
9798 @item @emph{See also}:
9806 @section @code{LOGICAL} --- Convert to logical type
9808 @cindex conversion, to logical
9811 @item @emph{Description}:
9812 Converts one kind of @code{LOGICAL} variable to another.
9814 @item @emph{Standard}:
9815 Fortran 90 and later
9820 @item @emph{Syntax}:
9821 @code{RESULT = LOGICAL(L [, KIND])}
9823 @item @emph{Arguments}:
9824 @multitable @columnfractions .15 .70
9825 @item @var{L} @tab The type shall be @code{LOGICAL}.
9826 @item @var{KIND} @tab (Optional) A scalar @code{INTEGER} constant
9827 expression indicating the kind parameter of the result.
9830 @item @emph{Return value}:
9831 The return value is a @code{LOGICAL} value equal to @var{L}, with a
9832 kind corresponding to @var{KIND}, or of the default logical kind if
9833 @var{KIND} is not given.
9835 @item @emph{See also}:
9844 @section @code{LSHIFT} --- Left shift bits
9846 @cindex bits, shift left
9849 @item @emph{Description}:
9850 @code{LSHIFT} returns a value corresponding to @var{I} with all of the
9851 bits shifted left by @var{SHIFT} places. @var{SHIFT} shall be
9852 nonnegative and less than or equal to @code{BIT_SIZE(I)}, otherwise
9853 the result value is undefined. Bits shifted out from the left end are
9854 lost; zeros are shifted in from the opposite end.
9856 This function has been superseded by the @code{ISHFT} intrinsic, which
9857 is standard in Fortran 95 and later, and the @code{SHIFTL} intrinsic,
9858 which is standard in Fortran 2008 and later.
9860 @item @emph{Standard}:
9866 @item @emph{Syntax}:
9867 @code{RESULT = LSHIFT(I, SHIFT)}
9869 @item @emph{Arguments}:
9870 @multitable @columnfractions .15 .70
9871 @item @var{I} @tab The type shall be @code{INTEGER}.
9872 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
9875 @item @emph{Return value}:
9876 The return value is of type @code{INTEGER} and of the same kind as
9879 @item @emph{See also}:
9891 @section @code{LSTAT} --- Get file status
9893 @cindex file system, file status
9896 @item @emph{Description}:
9897 @code{LSTAT} is identical to @ref{STAT}, except that if path is a
9898 symbolic link, then the link itself is statted, not the file that it
9901 The elements in @code{VALUES} are the same as described by @ref{STAT}.
9903 This intrinsic is provided in both subroutine and function forms;
9904 however, only one form can be used in any given program unit.
9906 @item @emph{Standard}:
9910 Subroutine, function
9912 @item @emph{Syntax}:
9913 @multitable @columnfractions .80
9914 @item @code{CALL LSTAT(NAME, VALUES [, STATUS])}
9915 @item @code{STATUS = LSTAT(NAME, VALUES)}
9918 @item @emph{Arguments}:
9919 @multitable @columnfractions .15 .70
9920 @item @var{NAME} @tab The type shall be @code{CHARACTER} of the default
9921 kind, a valid path within the file system.
9922 @item @var{VALUES} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
9923 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}.
9924 Returns 0 on success and a system specific error code otherwise.
9927 @item @emph{Example}:
9928 See @ref{STAT} for an example.
9930 @item @emph{See also}:
9931 To stat an open file: @*
9940 @section @code{LTIME} --- Convert time to local time info
9942 @cindex time, conversion to local time info
9945 @item @emph{Description}:
9946 Given a system time value @var{TIME} (as provided by the @ref{TIME}
9947 intrinsic), fills @var{VALUES} with values extracted from it appropriate
9948 to the local time zone using @code{localtime(3)}.
9950 This intrinsic routine is provided for backwards compatibility with
9951 GNU Fortran 77. In new code, programmers should consider the use of
9952 the @ref{DATE_AND_TIME} intrinsic defined by the Fortran 95
9955 @item @emph{Standard}:
9961 @item @emph{Syntax}:
9962 @code{CALL LTIME(TIME, VALUES)}
9964 @item @emph{Arguments}:
9965 @multitable @columnfractions .15 .70
9966 @item @var{TIME} @tab An @code{INTEGER} scalar expression
9967 corresponding to a system time, with @code{INTENT(IN)}.
9968 @item @var{VALUES} @tab A default @code{INTEGER} array with 9 elements,
9969 with @code{INTENT(OUT)}.
9972 @item @emph{Return value}:
9973 The elements of @var{VALUES} are assigned as follows:
9975 @item Seconds after the minute, range 0--59 or 0--61 to allow for leap
9977 @item Minutes after the hour, range 0--59
9978 @item Hours past midnight, range 0--23
9979 @item Day of month, range 1--31
9980 @item Number of months since January, range 0--11
9981 @item Years since 1900
9982 @item Number of days since Sunday, range 0--6
9983 @item Days since January 1, range 0--365
9984 @item Daylight savings indicator: positive if daylight savings is in
9985 effect, zero if not, and negative if the information is not available.
9988 @item @emph{See also}:
9989 @ref{DATE_AND_TIME}, @*
9999 @section @code{MALLOC} --- Allocate dynamic memory
10001 @cindex pointer, cray
10004 @item @emph{Description}:
10005 @code{MALLOC(SIZE)} allocates @var{SIZE} bytes of dynamic memory and
10006 returns the address of the allocated memory. The @code{MALLOC} intrinsic
10007 is an extension intended to be used with Cray pointers, and is provided
10008 in GNU Fortran to allow the user to compile legacy code. For new code
10009 using Fortran 95 pointers, the memory allocation intrinsic is
10012 @item @emph{Standard}:
10015 @item @emph{Class}:
10018 @item @emph{Syntax}:
10019 @code{PTR = MALLOC(SIZE)}
10021 @item @emph{Arguments}:
10022 @multitable @columnfractions .15 .70
10023 @item @var{SIZE} @tab The type shall be @code{INTEGER}.
10026 @item @emph{Return value}:
10027 The return value is of type @code{INTEGER(K)}, with @var{K} such that
10028 variables of type @code{INTEGER(K)} have the same size as
10029 C pointers (@code{sizeof(void *)}).
10031 @item @emph{Example}:
10032 The following example demonstrates the use of @code{MALLOC} and
10033 @code{FREE} with Cray pointers.
10036 program test_malloc
10042 ptr_x = malloc(20*8)
10044 x(i) = sqrt(1.0d0 / i)
10052 end program test_malloc
10055 @item @emph{See also}:
10062 @section @code{MASKL} --- Left justified mask
10064 @cindex mask, left justified
10067 @item @emph{Description}:
10068 @code{MASKL(I[, KIND])} has its leftmost @var{I} bits set to 1, and the
10069 remaining bits set to 0.
10071 @item @emph{Standard}:
10072 Fortran 2008 and later
10074 @item @emph{Class}:
10077 @item @emph{Syntax}:
10078 @code{RESULT = MASKL(I[, KIND])}
10080 @item @emph{Arguments}:
10081 @multitable @columnfractions .15 .70
10082 @item @var{I} @tab Shall be of type @code{INTEGER}.
10083 @item @var{KIND} @tab Shall be a scalar constant expression of type
10087 @item @emph{Return value}:
10088 The return value is of type @code{INTEGER}. If @var{KIND} is present, it
10089 specifies the kind value of the return type; otherwise, it is of the
10090 default integer kind.
10092 @item @emph{See also}:
10099 @section @code{MASKR} --- Right justified mask
10101 @cindex mask, right justified
10104 @item @emph{Description}:
10105 @code{MASKL(I[, KIND])} has its rightmost @var{I} bits set to 1, and the
10106 remaining bits set to 0.
10108 @item @emph{Standard}:
10109 Fortran 2008 and later
10111 @item @emph{Class}:
10114 @item @emph{Syntax}:
10115 @code{RESULT = MASKR(I[, KIND])}
10117 @item @emph{Arguments}:
10118 @multitable @columnfractions .15 .70
10119 @item @var{I} @tab Shall be of type @code{INTEGER}.
10120 @item @var{KIND} @tab Shall be a scalar constant expression of type
10124 @item @emph{Return value}:
10125 The return value is of type @code{INTEGER}. If @var{KIND} is present, it
10126 specifies the kind value of the return type; otherwise, it is of the
10127 default integer kind.
10129 @item @emph{See also}:
10136 @section @code{MATMUL} --- matrix multiplication
10138 @cindex matrix multiplication
10139 @cindex product, matrix
10142 @item @emph{Description}:
10143 Performs a matrix multiplication on numeric or logical arguments.
10145 @item @emph{Standard}:
10146 Fortran 90 and later
10148 @item @emph{Class}:
10149 Transformational function
10151 @item @emph{Syntax}:
10152 @code{RESULT = MATMUL(MATRIX_A, MATRIX_B)}
10154 @item @emph{Arguments}:
10155 @multitable @columnfractions .15 .70
10156 @item @var{MATRIX_A} @tab An array of @code{INTEGER},
10157 @code{REAL}, @code{COMPLEX}, or @code{LOGICAL} type, with a rank of
10159 @item @var{MATRIX_B} @tab An array of @code{INTEGER},
10160 @code{REAL}, or @code{COMPLEX} type if @var{MATRIX_A} is of a numeric
10161 type; otherwise, an array of @code{LOGICAL} type. The rank shall be one
10162 or two, and the first (or only) dimension of @var{MATRIX_B} shall be
10163 equal to the last (or only) dimension of @var{MATRIX_A}.
10164 @var{MATRIX_A} and @var{MATRIX_B} shall not both be rank one arrays.
10167 @item @emph{Return value}:
10168 The matrix product of @var{MATRIX_A} and @var{MATRIX_B}. The type and
10169 kind of the result follow the usual type and kind promotion rules, as
10170 for the @code{*} or @code{.AND.} operators.
10176 @section @code{MAX} --- Maximum value of an argument list
10183 @cindex maximum value
10186 @item @emph{Description}:
10187 Returns the argument with the largest (most positive) value.
10189 @item @emph{Standard}:
10190 Fortran 77 and later
10192 @item @emph{Class}:
10195 @item @emph{Syntax}:
10196 @code{RESULT = MAX(A1, A2 [, A3 [, ...]])}
10198 @item @emph{Arguments}:
10199 @multitable @columnfractions .15 .70
10200 @item @var{A1} @tab The type shall be @code{INTEGER} or
10202 @item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
10203 as @var{A1}. (As a GNU extension, arguments of different kinds are
10207 @item @emph{Return value}:
10208 The return value corresponds to the maximum value among the arguments,
10209 and has the same type and kind as the first argument.
10211 @item @emph{Specific names}:
10212 @multitable @columnfractions .20 .23 .20 .33
10213 @headitem Name @tab Argument @tab Return type @tab Standard
10214 @item @code{MAX0(A1)} @tab @code{INTEGER(4) A1} @tab @code{INTEGER(4)} @tab Fortran 77 and later
10215 @item @code{AMAX0(A1)} @tab @code{INTEGER(4) A1} @tab @code{REAL(MAX(X))} @tab Fortran 77 and later
10216 @item @code{MAX1(A1)} @tab @code{REAL A1} @tab @code{INT(MAX(X))} @tab Fortran 77 and later
10217 @item @code{AMAX1(A1)} @tab @code{REAL(4) A1} @tab @code{REAL(4)} @tab Fortran 77 and later
10218 @item @code{DMAX1(A1)} @tab @code{REAL(8) A1} @tab @code{REAL(8)} @tab Fortran 77 and later
10221 @item @emph{See also}:
10230 @section @code{MAXEXPONENT} --- Maximum exponent of a real kind
10231 @fnindex MAXEXPONENT
10232 @cindex model representation, maximum exponent
10235 @item @emph{Description}:
10236 @code{MAXEXPONENT(X)} returns the maximum exponent in the model of the
10239 @item @emph{Standard}:
10240 Fortran 90 and later
10242 @item @emph{Class}:
10245 @item @emph{Syntax}:
10246 @code{RESULT = MAXEXPONENT(X)}
10248 @item @emph{Arguments}:
10249 @multitable @columnfractions .15 .70
10250 @item @var{X} @tab Shall be of type @code{REAL}.
10253 @item @emph{Return value}:
10254 The return value is of type @code{INTEGER} and of the default integer
10257 @item @emph{Example}:
10263 print *, minexponent(x), maxexponent(x)
10264 print *, minexponent(y), maxexponent(y)
10265 end program exponents
10272 @section @code{MAXLOC} --- Location of the maximum value within an array
10274 @cindex array, location of maximum element
10277 @item @emph{Description}:
10278 Determines the location of the element in the array with the maximum
10279 value, or, if the @var{DIM} argument is supplied, determines the
10280 locations of the maximum element along each row of the array in the
10281 @var{DIM} direction. If @var{MASK} is present, only the elements for
10282 which @var{MASK} is @code{.TRUE.} are considered. If more than one
10283 element in the array has the maximum value, the location returned is
10284 that of the first such element in array element order if the
10285 @var{BACK} is not present, or is false; if @var{BACK} is true, the location
10286 returned is that of the last such element. If the array has zero
10287 size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
10288 the result is an array of zeroes. Similarly, if @var{DIM} is supplied
10289 and all of the elements of @var{MASK} along a given row are zero, the
10290 result value for that row is zero.
10292 @item @emph{Standard}:
10293 Fortran 95 and later; @var{ARRAY} of @code{CHARACTER} and the
10294 @var{KIND} argument are available in Fortran 2003 and later.
10295 The @var{BACK} argument is available in Fortran 2008 and later.
10297 @item @emph{Class}:
10298 Transformational function
10300 @item @emph{Syntax}:
10301 @multitable @columnfractions .80
10302 @item @code{RESULT = MAXLOC(ARRAY, DIM [, MASK] [,KIND] [,BACK])}
10303 @item @code{RESULT = MAXLOC(ARRAY [, MASK] [,KIND] [,BACK])}
10306 @item @emph{Arguments}:
10307 @multitable @columnfractions .15 .70
10308 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or
10310 @item @var{DIM} @tab (Optional) Shall be a scalar of type
10311 @code{INTEGER}, with a value between one and the rank of @var{ARRAY},
10312 inclusive. It may not be an optional dummy argument.
10313 @item @var{MASK} @tab Shall be of type @code{LOGICAL},
10314 and conformable with @var{ARRAY}.
10315 @item @var{KIND} @tab (Optional) A scalar @code{INTEGER} constant
10316 expression indicating the kind parameter of the result.
10317 @item @var{BACK} @tab (Optional) A scalar of type @code{LOGICAL}.
10320 @item @emph{Return value}:
10321 If @var{DIM} is absent, the result is a rank-one array with a length
10322 equal to the rank of @var{ARRAY}. If @var{DIM} is present, the result
10323 is an array with a rank one less than the rank of @var{ARRAY}, and a
10324 size corresponding to the size of @var{ARRAY} with the @var{DIM}
10325 dimension removed. If @var{DIM} is present and @var{ARRAY} has a rank
10326 of one, the result is a scalar. If the optional argument @var{KIND}
10327 is present, the result is an integer of kind @var{KIND}, otherwise it
10328 is of default kind.
10330 @item @emph{See also}:
10339 @section @code{MAXVAL} --- Maximum value of an array
10341 @cindex array, maximum value
10342 @cindex maximum value
10345 @item @emph{Description}:
10346 Determines the maximum value of the elements in an array value, or, if
10347 the @var{DIM} argument is supplied, determines the maximum value along
10348 each row of the array in the @var{DIM} direction. If @var{MASK} is
10349 present, only the elements for which @var{MASK} is @code{.TRUE.} are
10350 considered. If the array has zero size, or all of the elements of
10351 @var{MASK} are @code{.FALSE.}, then the result is @code{-HUGE(ARRAY)}
10352 if @var{ARRAY} is numeric, or a string of nulls if @var{ARRAY} is of character
10355 @item @emph{Standard}:
10356 Fortran 90 and later
10358 @item @emph{Class}:
10359 Transformational function
10361 @item @emph{Syntax}:
10362 @multitable @columnfractions .80
10363 @item @code{RESULT = MAXVAL(ARRAY, DIM [, MASK])}
10364 @item @code{RESULT = MAXVAL(ARRAY [, MASK])}
10367 @item @emph{Arguments}:
10368 @multitable @columnfractions .15 .70
10369 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or
10371 @item @var{DIM} @tab (Optional) Shall be a scalar of type
10372 @code{INTEGER}, with a value between one and the rank of @var{ARRAY},
10373 inclusive. It may not be an optional dummy argument.
10374 @item @var{MASK} @tab (Optional) Shall be of type @code{LOGICAL},
10375 and conformable with @var{ARRAY}.
10378 @item @emph{Return value}:
10379 If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
10380 is a scalar. If @var{DIM} is present, the result is an array with a
10381 rank one less than the rank of @var{ARRAY}, and a size corresponding to
10382 the size of @var{ARRAY} with the @var{DIM} dimension removed. In all
10383 cases, the result is of the same type and kind as @var{ARRAY}.
10385 @item @emph{See also}:
10393 @section @code{MCLOCK} --- Time function
10395 @cindex time, clock ticks
10396 @cindex clock ticks
10399 @item @emph{Description}:
10400 Returns the number of clock ticks since the start of the process, based
10401 on the function @code{clock(3)} in the C standard library.
10403 This intrinsic is not fully portable, such as to systems with 32-bit
10404 @code{INTEGER} types but supporting times wider than 32 bits. Therefore,
10405 the values returned by this intrinsic might be, or become, negative, or
10406 numerically less than previous values, during a single run of the
10409 @item @emph{Standard}:
10412 @item @emph{Class}:
10415 @item @emph{Syntax}:
10416 @code{RESULT = MCLOCK()}
10418 @item @emph{Return value}:
10419 The return value is a scalar of type @code{INTEGER(4)}, equal to the
10420 number of clock ticks since the start of the process, or @code{-1} if
10421 the system does not support @code{clock(3)}.
10423 @item @emph{See also}:
10434 @section @code{MCLOCK8} --- Time function (64-bit)
10436 @cindex time, clock ticks
10437 @cindex clock ticks
10440 @item @emph{Description}:
10441 Returns the number of clock ticks since the start of the process, based
10442 on the function @code{clock(3)} in the C standard library.
10444 @emph{Warning:} this intrinsic does not increase the range of the timing
10445 values over that returned by @code{clock(3)}. On a system with a 32-bit
10446 @code{clock(3)}, @code{MCLOCK8} will return a 32-bit value, even though
10447 it is converted to a 64-bit @code{INTEGER(8)} value. That means
10448 overflows of the 32-bit value can still occur. Therefore, the values
10449 returned by this intrinsic might be or become negative or numerically
10450 less than previous values during a single run of the compiled program.
10452 @item @emph{Standard}:
10455 @item @emph{Class}:
10458 @item @emph{Syntax}:
10459 @code{RESULT = MCLOCK8()}
10461 @item @emph{Return value}:
10462 The return value is a scalar of type @code{INTEGER(8)}, equal to the
10463 number of clock ticks since the start of the process, or @code{-1} if
10464 the system does not support @code{clock(3)}.
10466 @item @emph{See also}:
10477 @section @code{MERGE} --- Merge variables
10479 @cindex array, merge arrays
10480 @cindex array, combine arrays
10483 @item @emph{Description}:
10484 Select values from two arrays according to a logical mask. The result
10485 is equal to @var{TSOURCE} if @var{MASK} is @code{.TRUE.}, or equal to
10486 @var{FSOURCE} if it is @code{.FALSE.}.
10488 @item @emph{Standard}:
10489 Fortran 90 and later
10491 @item @emph{Class}:
10494 @item @emph{Syntax}:
10495 @code{RESULT = MERGE(TSOURCE, FSOURCE, MASK)}
10497 @item @emph{Arguments}:
10498 @multitable @columnfractions .15 .70
10499 @item @var{TSOURCE} @tab May be of any type.
10500 @item @var{FSOURCE} @tab Shall be of the same type and type parameters
10502 @item @var{MASK} @tab Shall be of type @code{LOGICAL}.
10505 @item @emph{Return value}:
10506 The result is of the same type and type parameters as @var{TSOURCE}.
10513 @section @code{MERGE_BITS} --- Merge of bits under mask
10514 @fnindex MERGE_BITS
10515 @cindex bits, merge
10518 @item @emph{Description}:
10519 @code{MERGE_BITS(I, J, MASK)} merges the bits of @var{I} and @var{J}
10520 as determined by the mask. The i-th bit of the result is equal to the
10521 i-th bit of @var{I} if the i-th bit of @var{MASK} is 1; it is equal to
10522 the i-th bit of @var{J} otherwise.
10524 @item @emph{Standard}:
10525 Fortran 2008 and later
10527 @item @emph{Class}:
10530 @item @emph{Syntax}:
10531 @code{RESULT = MERGE_BITS(I, J, MASK)}
10533 @item @emph{Arguments}:
10534 @multitable @columnfractions .15 .70
10535 @item @var{I} @tab Shall be of type @code{INTEGER} or a boz-literal-constant.
10536 @item @var{J} @tab Shall be of type @code{INTEGER} with the same
10537 kind type parameter as @var{I} or a boz-literal-constant.
10538 @var{I} and @var{J} shall not both be boz-literal-constants.
10539 @item @var{MASK} @tab Shall be of type @code{INTEGER} or a boz-literal-constant
10540 and of the same kind as @var{I}.
10543 @item @emph{Return value}:
10544 The result is of the same type and kind as @var{I}.
10551 @section @code{MIN} --- Minimum value of an argument list
10558 @cindex minimum value
10561 @item @emph{Description}:
10562 Returns the argument with the smallest (most negative) value.
10564 @item @emph{Standard}:
10565 Fortran 77 and later
10567 @item @emph{Class}:
10570 @item @emph{Syntax}:
10571 @code{RESULT = MIN(A1, A2 [, A3, ...])}
10573 @item @emph{Arguments}:
10574 @multitable @columnfractions .15 .70
10575 @item @var{A1} @tab The type shall be @code{INTEGER} or
10577 @item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
10578 as @var{A1}. (As a GNU extension, arguments of different kinds are
10582 @item @emph{Return value}:
10583 The return value corresponds to the minimum value among the arguments,
10584 and has the same type and kind as the first argument.
10586 @item @emph{Specific names}:
10587 @multitable @columnfractions .20 .23 .20 .33
10588 @headitem Name @tab Argument @tab Return type @tab Standard
10589 @item @code{MIN0(A1)} @tab @code{INTEGER(4) A1} @tab @code{INTEGER(4)} @tab Fortran 77 and later
10590 @item @code{AMIN0(A1)} @tab @code{INTEGER(4) A1} @tab @code{REAL(4)} @tab Fortran 77 and later
10591 @item @code{MIN1(A1)} @tab @code{REAL A1} @tab @code{INTEGER(4)} @tab Fortran 77 and later
10592 @item @code{AMIN1(A1)} @tab @code{REAL(4) A1} @tab @code{REAL(4)} @tab Fortran 77 and later
10593 @item @code{DMIN1(A1)} @tab @code{REAL(8) A1} @tab @code{REAL(8)} @tab Fortran 77 and later
10596 @item @emph{See also}:
10605 @section @code{MINEXPONENT} --- Minimum exponent of a real kind
10606 @fnindex MINEXPONENT
10607 @cindex model representation, minimum exponent
10610 @item @emph{Description}:
10611 @code{MINEXPONENT(X)} returns the minimum exponent in the model of the
10614 @item @emph{Standard}:
10615 Fortran 90 and later
10617 @item @emph{Class}:
10620 @item @emph{Syntax}:
10621 @code{RESULT = MINEXPONENT(X)}
10623 @item @emph{Arguments}:
10624 @multitable @columnfractions .15 .70
10625 @item @var{X} @tab Shall be of type @code{REAL}.
10628 @item @emph{Return value}:
10629 The return value is of type @code{INTEGER} and of the default integer
10632 @item @emph{Example}:
10633 See @code{MAXEXPONENT} for an example.
10639 @section @code{MINLOC} --- Location of the minimum value within an array
10641 @cindex array, location of minimum element
10644 @item @emph{Description}:
10645 Determines the location of the element in the array with the minimum
10646 value, or, if the @var{DIM} argument is supplied, determines the
10647 locations of the minimum element along each row of the array in the
10648 @var{DIM} direction. If @var{MASK} is present, only the elements for
10649 which @var{MASK} is @code{.TRUE.} are considered. If more than one
10650 element in the array has the minimum value, the location returned is
10651 that of the first such element in array element order if the
10652 @var{BACK} is not present, or is false; if @var{BACK} is true, the location
10653 returned is that of the last such element. If the array has
10654 zero size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
10655 the result is an array of zeroes. Similarly, if @var{DIM} is supplied
10656 and all of the elements of @var{MASK} along a given row are zero, the
10657 result value for that row is zero.
10659 @item @emph{Standard}:
10660 Fortran 90 and later; @var{ARRAY} of @code{CHARACTER} and the
10661 @var{KIND} argument are available in Fortran 2003 and later.
10662 The @var{BACK} argument is available in Fortran 2008 and later.
10664 @item @emph{Class}:
10665 Transformational function
10667 @item @emph{Syntax}:
10668 @multitable @columnfractions .80
10669 @item @code{RESULT = MINLOC(ARRAY, DIM [, MASK] [,KIND] [,BACK])}
10670 @item @code{RESULT = MINLOC(ARRAY [, MASK], [,KIND] [,BACK])}
10673 @item @emph{Arguments}:
10674 @multitable @columnfractions .15 .70
10675 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER},
10676 @code{REAL} or @code{CHARACTER}.
10677 @item @var{DIM} @tab (Optional) Shall be a scalar of type
10678 @code{INTEGER}, with a value between one and the rank of @var{ARRAY},
10679 inclusive. It may not be an optional dummy argument.
10680 @item @var{MASK} @tab Shall be of type @code{LOGICAL},
10681 and conformable with @var{ARRAY}.
10682 @item @var{KIND} @tab (Optional) A scalar @code{INTEGER} constant
10683 expression indicating the kind parameter of the result.
10684 @item @var{BACK} @tab (Optional) A scalar of type @code{LOGICAL}.
10687 @item @emph{Return value}:
10688 If @var{DIM} is absent, the result is a rank-one array with a length
10689 equal to the rank of @var{ARRAY}. If @var{DIM} is present, the result
10690 is an array with a rank one less than the rank of @var{ARRAY}, and a
10691 size corresponding to the size of @var{ARRAY} with the @var{DIM}
10692 dimension removed. If @var{DIM} is present and @var{ARRAY} has a rank
10693 of one, the result is a scalar. If the optional argument @var{KIND}
10694 is present, the result is an integer of kind @var{KIND}, otherwise it
10695 is of default kind.
10697 @item @emph{See also}:
10706 @section @code{MINVAL} --- Minimum value of an array
10708 @cindex array, minimum value
10709 @cindex minimum value
10712 @item @emph{Description}:
10713 Determines the minimum value of the elements in an array value, or, if
10714 the @var{DIM} argument is supplied, determines the minimum value along
10715 each row of the array in the @var{DIM} direction. If @var{MASK} is
10716 present, only the elements for which @var{MASK} is @code{.TRUE.} are
10717 considered. If the array has zero size, or all of the elements of
10718 @var{MASK} are @code{.FALSE.}, then the result is @code{HUGE(ARRAY)} if
10719 @var{ARRAY} is numeric, or a string of @code{CHAR(255)} characters if
10720 @var{ARRAY} is of character type.
10722 @item @emph{Standard}:
10723 Fortran 90 and later
10725 @item @emph{Class}:
10726 Transformational function
10728 @item @emph{Syntax}:
10729 @multitable @columnfractions .80
10730 @item @code{RESULT = MINVAL(ARRAY, DIM [, MASK])}
10731 @item @code{RESULT = MINVAL(ARRAY [, MASK])}
10734 @item @emph{Arguments}:
10735 @multitable @columnfractions .15 .70
10736 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or
10738 @item @var{DIM} @tab (Optional) Shall be a scalar of type
10739 @code{INTEGER}, with a value between one and the rank of @var{ARRAY},
10740 inclusive. It may not be an optional dummy argument.
10741 @item @var{MASK} @tab Shall be of type @code{LOGICAL},
10742 and conformable with @var{ARRAY}.
10745 @item @emph{Return value}:
10746 If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
10747 is a scalar. If @var{DIM} is present, the result is an array with a
10748 rank one less than the rank of @var{ARRAY}, and a size corresponding to
10749 the size of @var{ARRAY} with the @var{DIM} dimension removed. In all
10750 cases, the result is of the same type and kind as @var{ARRAY}.
10752 @item @emph{See also}:
10760 @section @code{MOD} --- Remainder function
10769 @cindex division, remainder
10772 @item @emph{Description}:
10773 @code{MOD(A,P)} computes the remainder of the division of A by P@.
10775 @item @emph{Standard}:
10776 Fortran 77 and later, has overloads that are GNU extensions
10778 @item @emph{Class}:
10781 @item @emph{Syntax}:
10782 @code{RESULT = MOD(A, P)}
10784 @item @emph{Arguments}:
10785 @multitable @columnfractions .15 .70
10786 @item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL}.
10787 @item @var{P} @tab Shall be a scalar of the same type and kind as @var{A}
10788 and not equal to zero. (As a GNU extension, arguments of different kinds are
10792 @item @emph{Return value}:
10793 The return value is the result of @code{A - (INT(A/P) * P)}. The type
10794 and kind of the return value is the same as that of the arguments. The
10795 returned value has the same sign as A and a magnitude less than the
10796 magnitude of P. (As a GNU extension, kind is the largest kind of the actual
10799 @item @emph{Example}:
10803 print *, mod(17.5,5.5)
10804 print *, mod(17.5d0,5.5)
10805 print *, mod(17.5,5.5d0)
10807 print *, mod(-17,3)
10808 print *, mod(-17.5,5.5)
10809 print *, mod(-17.5d0,5.5)
10810 print *, mod(-17.5,5.5d0)
10812 print *, mod(17,-3)
10813 print *, mod(17.5,-5.5)
10814 print *, mod(17.5d0,-5.5)
10815 print *, mod(17.5,-5.5d0)
10816 end program test_mod
10819 @item @emph{Specific names}:
10820 @multitable @columnfractions .20 .25 .20 .31
10821 @headitem Name @tab Arguments @tab Return type @tab Standard
10822 @item @code{MOD(A,P)} @tab @code{INTEGER A,P} @tab @code{INTEGER} @tab Fortran 77 and later
10823 @item @code{AMOD(A,P)} @tab @code{REAL(4) A,P} @tab @code{REAL(4)} @tab Fortran 77 and later
10824 @item @code{DMOD(A,P)} @tab @code{REAL(8) A,P} @tab @code{REAL(8)} @tab Fortran 77 and later
10825 @item @code{BMOD(A,P)} @tab @code{INTEGER(1) A,P} @tab @code{INTEGER(1)} @tab GNU extension
10826 @item @code{IMOD(A,P)} @tab @code{INTEGER(2) A,P} @tab @code{INTEGER(2)} @tab GNU extension
10827 @item @code{JMOD(A,P)} @tab @code{INTEGER(4) A,P} @tab @code{INTEGER(4)} @tab GNU extension
10828 @item @code{KMOD(A,P)} @tab @code{INTEGER(8) A,P} @tab @code{INTEGER(8)} @tab GNU extension
10831 @item @emph{See also}:
10839 @section @code{MODULO} --- Modulo function
10842 @cindex division, modulo
10845 @item @emph{Description}:
10846 @code{MODULO(A,P)} computes the @var{A} modulo @var{P}.
10848 @item @emph{Standard}:
10849 Fortran 95 and later
10851 @item @emph{Class}:
10854 @item @emph{Syntax}:
10855 @code{RESULT = MODULO(A, P)}
10857 @item @emph{Arguments}:
10858 @multitable @columnfractions .15 .70
10859 @item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL}.
10860 @item @var{P} @tab Shall be a scalar of the same type and kind as @var{A}.
10861 It shall not be zero. (As a GNU extension, arguments of different kinds are
10865 @item @emph{Return value}:
10866 The type and kind of the result are those of the arguments. (As a GNU
10867 extension, kind is the largest kind of the actual arguments.)
10869 @item If @var{A} and @var{P} are of type @code{INTEGER}:
10870 @code{MODULO(A,P)} has the value @var{R} such that @code{A=Q*P+R}, where
10871 @var{Q} is an integer and @var{R} is between 0 (inclusive) and @var{P}
10873 @item If @var{A} and @var{P} are of type @code{REAL}:
10874 @code{MODULO(A,P)} has the value of @code{A - FLOOR (A / P) * P}.
10876 The returned value has the same sign as P and a magnitude less than
10877 the magnitude of P.
10879 @item @emph{Example}:
10881 program test_modulo
10882 print *, modulo(17,3)
10883 print *, modulo(17.5,5.5)
10885 print *, modulo(-17,3)
10886 print *, modulo(-17.5,5.5)
10888 print *, modulo(17,-3)
10889 print *, modulo(17.5,-5.5)
10893 @item @emph{See also}:
10901 @section @code{MOVE_ALLOC} --- Move allocation from one object to another
10902 @fnindex MOVE_ALLOC
10903 @cindex moving allocation
10904 @cindex allocation, moving
10907 @item @emph{Description}:
10908 @code{MOVE_ALLOC(FROM, TO)} moves the allocation from @var{FROM} to
10909 @var{TO}. @var{FROM} will become deallocated in the process.
10911 @item @emph{Standard}:
10912 Fortran 2003 and later
10914 @item @emph{Class}:
10917 @item @emph{Syntax}:
10918 @code{CALL MOVE_ALLOC(FROM, TO)}
10920 @item @emph{Arguments}:
10921 @multitable @columnfractions .15 .70
10922 @item @var{FROM} @tab @code{ALLOCATABLE}, @code{INTENT(INOUT)}, may be
10923 of any type and kind.
10924 @item @var{TO} @tab @code{ALLOCATABLE}, @code{INTENT(OUT)}, shall be
10925 of the same type, kind and rank as @var{FROM}.
10928 @item @emph{Return value}:
10931 @item @emph{Example}:
10933 program test_move_alloc
10934 integer, allocatable :: a(:), b(:)
10938 call move_alloc(a, b)
10939 print *, allocated(a), allocated(b)
10941 end program test_move_alloc
10948 @section @code{MVBITS} --- Move bits from one integer to another
10957 @item @emph{Description}:
10958 Moves @var{LEN} bits from positions @var{FROMPOS} through
10959 @code{FROMPOS+LEN-1} of @var{FROM} to positions @var{TOPOS} through
10960 @code{TOPOS+LEN-1} of @var{TO}. The portion of argument @var{TO} not
10961 affected by the movement of bits is unchanged. The values of
10962 @code{FROMPOS+LEN-1} and @code{TOPOS+LEN-1} must be less than
10963 @code{BIT_SIZE(FROM)}.
10965 @item @emph{Standard}:
10966 Fortran 90 and later, has overloads that are GNU extensions
10968 @item @emph{Class}:
10969 Elemental subroutine
10971 @item @emph{Syntax}:
10972 @code{CALL MVBITS(FROM, FROMPOS, LEN, TO, TOPOS)}
10974 @item @emph{Arguments}:
10975 @multitable @columnfractions .15 .70
10976 @item @var{FROM} @tab The type shall be @code{INTEGER}.
10977 @item @var{FROMPOS} @tab The type shall be @code{INTEGER}.
10978 @item @var{LEN} @tab The type shall be @code{INTEGER}.
10979 @item @var{TO} @tab The type shall be @code{INTEGER}, of the
10980 same kind as @var{FROM}.
10981 @item @var{TOPOS} @tab The type shall be @code{INTEGER}.
10984 @item @emph{Specific names}:
10985 @multitable @columnfractions .20 .23 .20 .33
10986 @headitem Name @tab Argument @tab Return type @tab Standard
10987 @item @code{MVBITS(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 90 and later
10988 @item @code{BMVBITS(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
10989 @item @code{IMVBITS(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
10990 @item @code{JMVBITS(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
10991 @item @code{KMVBITS(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
10994 @item @emph{See also}:
11006 @section @code{NEAREST} --- Nearest representable number
11008 @cindex real number, nearest different
11009 @cindex floating point, nearest different
11012 @item @emph{Description}:
11013 @code{NEAREST(X, S)} returns the processor-representable number nearest
11014 to @code{X} in the direction indicated by the sign of @code{S}.
11016 @item @emph{Standard}:
11017 Fortran 90 and later
11019 @item @emph{Class}:
11022 @item @emph{Syntax}:
11023 @code{RESULT = NEAREST(X, S)}
11025 @item @emph{Arguments}:
11026 @multitable @columnfractions .15 .70
11027 @item @var{X} @tab Shall be of type @code{REAL}.
11028 @item @var{S} @tab Shall be of type @code{REAL} and
11032 @item @emph{Return value}:
11033 The return value is of the same type as @code{X}. If @code{S} is
11034 positive, @code{NEAREST} returns the processor-representable number
11035 greater than @code{X} and nearest to it. If @code{S} is negative,
11036 @code{NEAREST} returns the processor-representable number smaller than
11037 @code{X} and nearest to it.
11039 @item @emph{Example}:
11041 program test_nearest
11043 x = nearest(42.0, 1.0)
11044 y = nearest(42.0, -1.0)
11045 write (*,"(3(G20.15))") x, y, x - y
11046 end program test_nearest
11053 @section @code{NEW_LINE} --- New line character
11056 @cindex output, newline
11059 @item @emph{Description}:
11060 @code{NEW_LINE(C)} returns the new-line character.
11062 @item @emph{Standard}:
11063 Fortran 2003 and later
11065 @item @emph{Class}:
11068 @item @emph{Syntax}:
11069 @code{RESULT = NEW_LINE(C)}
11071 @item @emph{Arguments}:
11072 @multitable @columnfractions .15 .70
11073 @item @var{C} @tab The argument shall be a scalar or array of the
11074 type @code{CHARACTER}.
11077 @item @emph{Return value}:
11078 Returns a @var{CHARACTER} scalar of length one with the new-line character of
11079 the same kind as parameter @var{C}.
11081 @item @emph{Example}:
11085 write(*,'(A)') 'This is record 1.'//NEW_LINE('A')//'This is record 2.'
11086 end program newline
11093 @section @code{NINT} --- Nearest whole number
11096 @cindex rounding, nearest whole number
11099 @item @emph{Description}:
11100 @code{NINT(A)} rounds its argument to the nearest whole number.
11102 @item @emph{Standard}:
11103 Fortran 77 and later, with @var{KIND} argument Fortran 90 and later
11105 @item @emph{Class}:
11108 @item @emph{Syntax}:
11109 @code{RESULT = NINT(A [, KIND])}
11111 @item @emph{Arguments}:
11112 @multitable @columnfractions .15 .70
11113 @item @var{A} @tab The type of the argument shall be @code{REAL}.
11114 @item @var{KIND} @tab (Optional) A scalar @code{INTEGER} constant
11115 expression indicating the kind parameter of the result.
11118 @item @emph{Return value}:
11119 Returns @var{A} with the fractional portion of its magnitude eliminated by
11120 rounding to the nearest whole number and with its sign preserved,
11121 converted to an @code{INTEGER} of the default kind.
11123 @item @emph{Example}:
11130 print *, nint(x4), idnint(x8)
11131 end program test_nint
11134 @item @emph{Specific names}:
11135 @multitable @columnfractions .20 .23 .20 .33
11136 @headitem Name @tab Argument @tab Return Type @tab Standard
11137 @item @code{NINT(A)} @tab @code{REAL(4) A} @tab @code{INTEGER} @tab Fortran 77 and later
11138 @item @code{IDNINT(A)} @tab @code{REAL(8) A} @tab @code{INTEGER} @tab Fortran 77 and later
11141 @item @emph{See also}:
11149 @section @code{NORM2} --- Euclidean vector norms
11151 @cindex Euclidean vector norm
11152 @cindex L2 vector norm
11153 @cindex norm, Euclidean
11156 @item @emph{Description}:
11157 Calculates the Euclidean vector norm (@math{L_2} norm)
11158 of @var{ARRAY} along dimension @var{DIM}.
11160 @item @emph{Standard}:
11161 Fortran 2008 and later
11163 @item @emph{Class}:
11164 Transformational function
11166 @item @emph{Syntax}:
11167 @multitable @columnfractions .80
11168 @item @code{RESULT = NORM2(ARRAY[, DIM])}
11171 @item @emph{Arguments}:
11172 @multitable @columnfractions .15 .70
11173 @item @var{ARRAY} @tab Shall be an array of type @code{REAL}
11174 @item @var{DIM} @tab (Optional) shall be a scalar of type
11175 @code{INTEGER} with a value in the range from 1 to n, where n
11176 equals the rank of @var{ARRAY}.
11179 @item @emph{Return value}:
11180 The result is of the same type as @var{ARRAY}.
11182 If @var{DIM} is absent, a scalar with the square root of the sum of all
11183 elements in @var{ARRAY} squared is returned. Otherwise, an array of
11184 rank @math{n-1}, where @math{n} equals the rank of @var{ARRAY}, and a
11185 shape similar to that of @var{ARRAY} with dimension @var{DIM} dropped
11188 @item @emph{Example}:
11191 REAL :: x(5) = [ real :: 1, 2, 3, 4, 5 ]
11192 print *, NORM2(x) ! = sqrt(55.) ~ 7.416
11200 @section @code{NOT} --- Logical negation
11206 @cindex bits, negate
11207 @cindex bitwise logical not
11208 @cindex logical not, bitwise
11211 @item @emph{Description}:
11212 @code{NOT} returns the bitwise Boolean inverse of @var{I}.
11214 @item @emph{Standard}:
11215 Fortran 90 and later, has overloads that are GNU extensions
11217 @item @emph{Class}:
11220 @item @emph{Syntax}:
11221 @code{RESULT = NOT(I)}
11223 @item @emph{Arguments}:
11224 @multitable @columnfractions .15 .70
11225 @item @var{I} @tab The type shall be @code{INTEGER}.
11228 @item @emph{Return value}:
11229 The return type is @code{INTEGER}, of the same kind as the
11232 @item @emph{Specific names}:
11233 @multitable @columnfractions .20 .23 .20 .33
11234 @headitem Name @tab Argument @tab Return type @tab Standard
11235 @item @code{NOT(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 95 and later
11236 @item @code{BNOT(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
11237 @item @code{INOT(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
11238 @item @code{JNOT(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
11239 @item @code{KNOT(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
11242 @item @emph{See also}:
11254 @section @code{NULL} --- Function that returns an disassociated pointer
11256 @cindex pointer, status
11257 @cindex pointer, disassociated
11260 @item @emph{Description}:
11261 Returns a disassociated pointer.
11263 If @var{MOLD} is present, a disassociated pointer of the same type is
11264 returned, otherwise the type is determined by context.
11266 In Fortran 95, @var{MOLD} is optional. Please note that Fortran 2003
11267 includes cases where it is required.
11269 @item @emph{Standard}:
11270 Fortran 95 and later
11272 @item @emph{Class}:
11273 Transformational function
11275 @item @emph{Syntax}:
11276 @code{PTR => NULL([MOLD])}
11278 @item @emph{Arguments}:
11279 @multitable @columnfractions .15 .70
11280 @item @var{MOLD} @tab (Optional) shall be a pointer of any association
11281 status and of any type.
11284 @item @emph{Return value}:
11285 A disassociated pointer.
11287 @item @emph{Example}:
11289 REAL, POINTER, DIMENSION(:) :: VEC => NULL ()
11292 @item @emph{See also}:
11299 @section @code{NUM_IMAGES} --- Function that returns the number of images
11300 @fnindex NUM_IMAGES
11301 @cindex coarray, @code{NUM_IMAGES}
11302 @cindex images, number of
11305 @item @emph{Description}:
11306 Returns the number of images.
11308 @item @emph{Standard}:
11309 Fortran 2008 and later. With @var{DISTANCE} or @var{FAILED} argument,
11310 Technical Specification (TS) 18508 or later
11313 @item @emph{Class}:
11314 Transformational function
11316 @item @emph{Syntax}:
11317 @code{RESULT = NUM_IMAGES(DISTANCE, FAILED)}
11319 @item @emph{Arguments}:
11320 @multitable @columnfractions .15 .70
11321 @item @var{DISTANCE} @tab (optional, intent(in)) Nonnegative scalar integer
11322 @item @var{FAILED} @tab (optional, intent(in)) Scalar logical expression
11325 @item @emph{Return value}:
11326 Scalar default-kind integer. If @var{DISTANCE} is not present or has value 0,
11327 the number of images in the current team is returned. For values smaller or
11328 equal distance to the initial team, it returns the number of images index
11329 on the ancestor team which has a distance of @var{DISTANCE} from the invoking
11330 team. If @var{DISTANCE} is larger than the distance to the initial team, the
11331 number of images of the initial team is returned. If @var{FAILED} is not present
11332 the total number of images is returned; if it has the value @code{.TRUE.},
11333 the number of failed images is returned, otherwise, the number of images which
11334 do have not the failed status.
11336 @item @emph{Example}:
11338 INTEGER :: value[*]
11340 value = THIS_IMAGE()
11342 IF (THIS_IMAGE() == 1) THEN
11343 DO i = 1, NUM_IMAGES()
11344 WRITE(*,'(2(a,i0))') 'value[', i, '] is ', value[i]
11349 @item @emph{See also}:
11350 @ref{THIS_IMAGE}, @*
11357 @section @code{OR} --- Bitwise logical OR
11359 @cindex bitwise logical or
11360 @cindex logical or, bitwise
11363 @item @emph{Description}:
11364 Bitwise logical @code{OR}.
11366 This intrinsic routine is provided for backwards compatibility with
11367 GNU Fortran 77. For integer arguments, programmers should consider
11368 the use of the @ref{IOR} intrinsic defined by the Fortran standard.
11370 @item @emph{Standard}:
11373 @item @emph{Class}:
11376 @item @emph{Syntax}:
11377 @code{RESULT = OR(I, J)}
11379 @item @emph{Arguments}:
11380 @multitable @columnfractions .15 .70
11381 @item @var{I} @tab The type shall be either a scalar @code{INTEGER}
11382 type or a scalar @code{LOGICAL} type or a boz-literal-constant.
11383 @item @var{J} @tab The type shall be the same as the type of @var{I} or
11384 a boz-literal-constant. @var{I} and @var{J} shall not both be
11385 boz-literal-constants. If either @var{I} and @var{J} is a
11386 boz-literal-constant, then the other argument must be a scalar @code{INTEGER}.
11389 @item @emph{Return value}:
11390 The return type is either a scalar @code{INTEGER} or a scalar
11391 @code{LOGICAL}. If the kind type parameters differ, then the
11392 smaller kind type is implicitly converted to larger kind, and the
11393 return has the larger kind. A boz-literal-constant is
11394 converted to an @code{INTEGER} with the kind type parameter of
11395 the other argument as-if a call to @ref{INT} occurred.
11397 @item @emph{Example}:
11400 LOGICAL :: T = .TRUE., F = .FALSE.
11402 DATA a / Z'F' /, b / Z'3' /
11404 WRITE (*,*) OR(T, T), OR(T, F), OR(F, T), OR(F, F)
11405 WRITE (*,*) OR(a, b)
11409 @item @emph{See also}:
11410 Fortran 95 elemental function: @*
11417 @section @code{PACK} --- Pack an array into an array of rank one
11419 @cindex array, packing
11420 @cindex array, reduce dimension
11421 @cindex array, gather elements
11424 @item @emph{Description}:
11425 Stores the elements of @var{ARRAY} in an array of rank one.
11427 The beginning of the resulting array is made up of elements whose @var{MASK}
11428 equals @code{TRUE}. Afterwards, positions are filled with elements taken from
11431 @item @emph{Standard}:
11432 Fortran 90 and later
11434 @item @emph{Class}:
11435 Transformational function
11437 @item @emph{Syntax}:
11438 @code{RESULT = PACK(ARRAY, MASK[,VECTOR])}
11440 @item @emph{Arguments}:
11441 @multitable @columnfractions .15 .70
11442 @item @var{ARRAY} @tab Shall be an array of any type.
11443 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL} and
11444 of the same size as @var{ARRAY}. Alternatively, it may be a @code{LOGICAL}
11446 @item @var{VECTOR} @tab (Optional) shall be an array of the same type
11447 as @var{ARRAY} and of rank one. If present, the number of elements in
11448 @var{VECTOR} shall be equal to or greater than the number of true elements
11449 in @var{MASK}. If @var{MASK} is scalar, the number of elements in
11450 @var{VECTOR} shall be equal to or greater than the number of elements in
11454 @item @emph{Return value}:
11455 The result is an array of rank one and the same type as that of @var{ARRAY}.
11456 If @var{VECTOR} is present, the result size is that of @var{VECTOR}, the
11457 number of @code{TRUE} values in @var{MASK} otherwise.
11459 @item @emph{Example}:
11460 Gathering nonzero elements from an array:
11462 PROGRAM test_pack_1
11464 m = (/ 1, 0, 0, 0, 5, 0 /)
11465 WRITE(*, FMT="(6(I0, ' '))") pack(m, m /= 0) ! "1 5"
11469 Gathering nonzero elements from an array and appending elements from @var{VECTOR}:
11471 PROGRAM test_pack_2
11473 m = (/ 1, 0, 0, 2 /)
11474 ! The following results in "1 2 3 4"
11475 WRITE(*, FMT="(4(I0, ' '))") pack(m, m /= 0, (/ 0, 0, 3, 4 /))
11479 @item @emph{See also}:
11486 @section @code{PARITY} --- Reduction with exclusive OR
11489 @cindex Reduction, XOR
11490 @cindex XOR reduction
11493 @item @emph{Description}:
11494 Calculates the parity, i.e. the reduction using @code{.XOR.},
11495 of @var{MASK} along dimension @var{DIM}.
11497 @item @emph{Standard}:
11498 Fortran 2008 and later
11500 @item @emph{Class}:
11501 Transformational function
11503 @item @emph{Syntax}:
11504 @multitable @columnfractions .80
11505 @item @code{RESULT = PARITY(MASK[, DIM])}
11508 @item @emph{Arguments}:
11509 @multitable @columnfractions .15 .70
11510 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL}
11511 @item @var{DIM} @tab (Optional) shall be a scalar of type
11512 @code{INTEGER} with a value in the range from 1 to n, where n
11513 equals the rank of @var{MASK}.
11516 @item @emph{Return value}:
11517 The result is of the same type as @var{MASK}.
11519 If @var{DIM} is absent, a scalar with the parity of all elements in
11520 @var{MASK} is returned, i.e. true if an odd number of elements is
11521 @code{.true.} and false otherwise. If @var{DIM} is present, an array
11522 of rank @math{n-1}, where @math{n} equals the rank of @var{ARRAY},
11523 and a shape similar to that of @var{MASK} with dimension @var{DIM}
11524 dropped is returned.
11526 @item @emph{Example}:
11529 LOGICAL :: x(2) = [ .true., .false. ]
11530 print *, PARITY(x) ! prints "T" (true).
11538 @section @code{PERROR} --- Print system error message
11540 @cindex system, error handling
11543 @item @emph{Description}:
11544 Prints (on the C @code{stderr} stream) a newline-terminated error
11545 message corresponding to the last system error. This is prefixed by
11546 @var{STRING}, a colon and a space. See @code{perror(3)}.
11548 @item @emph{Standard}:
11551 @item @emph{Class}:
11554 @item @emph{Syntax}:
11555 @code{CALL PERROR(STRING)}
11557 @item @emph{Arguments}:
11558 @multitable @columnfractions .15 .70
11559 @item @var{STRING} @tab A scalar of type @code{CHARACTER} and of the
11563 @item @emph{See also}:
11570 @section @code{POPCNT} --- Number of bits set
11572 @cindex binary representation
11576 @item @emph{Description}:
11577 @code{POPCNT(I)} returns the number of bits set ('1' bits) in the binary
11578 representation of @code{I}.
11580 @item @emph{Standard}:
11581 Fortran 2008 and later
11583 @item @emph{Class}:
11586 @item @emph{Syntax}:
11587 @code{RESULT = POPCNT(I)}
11589 @item @emph{Arguments}:
11590 @multitable @columnfractions .15 .70
11591 @item @var{I} @tab Shall be of type @code{INTEGER}.
11594 @item @emph{Return value}:
11595 The return value is of type @code{INTEGER} and of the default integer
11598 @item @emph{Example}:
11600 program test_population
11601 print *, popcnt(127), poppar(127)
11602 print *, popcnt(huge(0_4)), poppar(huge(0_4))
11603 print *, popcnt(huge(0_8)), poppar(huge(0_8))
11604 end program test_population
11606 @item @emph{See also}:
11615 @section @code{POPPAR} --- Parity of the number of bits set
11617 @cindex binary representation
11621 @item @emph{Description}:
11622 @code{POPPAR(I)} returns parity of the integer @code{I}, i.e. the parity
11623 of the number of bits set ('1' bits) in the binary representation of
11624 @code{I}. It is equal to 0 if @code{I} has an even number of bits set,
11625 and 1 for an odd number of '1' bits.
11627 @item @emph{Standard}:
11628 Fortran 2008 and later
11630 @item @emph{Class}:
11633 @item @emph{Syntax}:
11634 @code{RESULT = POPPAR(I)}
11636 @item @emph{Arguments}:
11637 @multitable @columnfractions .15 .70
11638 @item @var{I} @tab Shall be of type @code{INTEGER}.
11641 @item @emph{Return value}:
11642 The return value is of type @code{INTEGER} and of the default integer
11645 @item @emph{Example}:
11647 program test_population
11648 print *, popcnt(127), poppar(127)
11649 print *, popcnt(huge(0_4)), poppar(huge(0_4))
11650 print *, popcnt(huge(0_8)), poppar(huge(0_8))
11651 end program test_population
11653 @item @emph{See also}:
11662 @section @code{PRECISION} --- Decimal precision of a real kind
11664 @cindex model representation, precision
11667 @item @emph{Description}:
11668 @code{PRECISION(X)} returns the decimal precision in the model of the
11671 @item @emph{Standard}:
11672 Fortran 90 and later
11674 @item @emph{Class}:
11677 @item @emph{Syntax}:
11678 @code{RESULT = PRECISION(X)}
11680 @item @emph{Arguments}:
11681 @multitable @columnfractions .15 .70
11682 @item @var{X} @tab Shall be of type @code{REAL} or @code{COMPLEX}. It may
11683 be scalar or valued.
11686 @item @emph{Return value}:
11687 The return value is of type @code{INTEGER} and of the default integer
11690 @item @emph{Example}:
11692 program prec_and_range
11693 real(kind=4) :: x(2)
11694 complex(kind=8) :: y
11696 print *, precision(x), range(x)
11697 print *, precision(y), range(y)
11698 end program prec_and_range
11700 @item @emph{See also}:
11701 @ref{SELECTED_REAL_KIND}, @*
11708 @section @code{PRESENT} --- Determine whether an optional dummy argument is specified
11712 @item @emph{Description}:
11713 Determines whether an optional dummy argument is present.
11715 @item @emph{Standard}:
11716 Fortran 90 and later
11718 @item @emph{Class}:
11721 @item @emph{Syntax}:
11722 @code{RESULT = PRESENT(A)}
11724 @item @emph{Arguments}:
11725 @multitable @columnfractions .15 .70
11726 @item @var{A} @tab May be of any type and may be a pointer, scalar or array
11727 value, or a dummy procedure. It shall be the name of an optional dummy argument
11728 accessible within the current subroutine or function.
11731 @item @emph{Return value}:
11732 Returns either @code{TRUE} if the optional argument @var{A} is present, or
11733 @code{FALSE} otherwise.
11735 @item @emph{Example}:
11737 PROGRAM test_present
11738 WRITE(*,*) f(), f(42) ! "F T"
11740 LOGICAL FUNCTION f(x)
11741 INTEGER, INTENT(IN), OPTIONAL :: x
11751 @section @code{PRODUCT} --- Product of array elements
11753 @cindex array, product
11754 @cindex array, multiply elements
11755 @cindex array, conditionally multiply elements
11756 @cindex multiply array elements
11759 @item @emph{Description}:
11760 Multiplies the elements of @var{ARRAY} along dimension @var{DIM} if
11761 the corresponding element in @var{MASK} is @code{TRUE}.
11763 @item @emph{Standard}:
11764 Fortran 90 and later
11766 @item @emph{Class}:
11767 Transformational function
11769 @item @emph{Syntax}:
11770 @multitable @columnfractions .80
11771 @item @code{RESULT = PRODUCT(ARRAY[, MASK])}
11772 @item @code{RESULT = PRODUCT(ARRAY, DIM[, MASK])}
11775 @item @emph{Arguments}:
11776 @multitable @columnfractions .15 .70
11777 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER},
11778 @code{REAL} or @code{COMPLEX}.
11779 @item @var{DIM} @tab (Optional) shall be a scalar of type
11780 @code{INTEGER} with a value in the range from 1 to n, where n
11781 equals the rank of @var{ARRAY}.
11782 @item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL}
11783 and either be a scalar or an array of the same shape as @var{ARRAY}.
11786 @item @emph{Return value}:
11787 The result is of the same type as @var{ARRAY}.
11789 If @var{DIM} is absent, a scalar with the product of all elements in
11790 @var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals
11791 the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with
11792 dimension @var{DIM} dropped is returned.
11795 @item @emph{Example}:
11797 PROGRAM test_product
11798 INTEGER :: x(5) = (/ 1, 2, 3, 4 ,5 /)
11799 print *, PRODUCT(x) ! all elements, product = 120
11800 print *, PRODUCT(x, MASK=MOD(x, 2)==1) ! odd elements, product = 15
11804 @item @emph{See also}:
11811 @section @code{RADIX} --- Base of a model number
11813 @cindex model representation, base
11814 @cindex model representation, radix
11817 @item @emph{Description}:
11818 @code{RADIX(X)} returns the base of the model representing the entity @var{X}.
11820 @item @emph{Standard}:
11821 Fortran 90 and later
11823 @item @emph{Class}:
11826 @item @emph{Syntax}:
11827 @code{RESULT = RADIX(X)}
11829 @item @emph{Arguments}:
11830 @multitable @columnfractions .15 .70
11831 @item @var{X} @tab Shall be of type @code{INTEGER} or @code{REAL}
11834 @item @emph{Return value}:
11835 The return value is a scalar of type @code{INTEGER} and of the default
11838 @item @emph{Example}:
11841 print *, "The radix for the default integer kind is", radix(0)
11842 print *, "The radix for the default real kind is", radix(0.0)
11843 end program test_radix
11845 @item @emph{See also}:
11846 @ref{SELECTED_REAL_KIND}
11852 @section @code{RAN} --- Real pseudo-random number
11854 @cindex random number generation
11857 @item @emph{Description}:
11858 For compatibility with HP FORTRAN 77/iX, the @code{RAN} intrinsic is
11859 provided as an alias for @code{RAND}. See @ref{RAND} for complete
11862 @item @emph{Standard}:
11865 @item @emph{Class}:
11868 @item @emph{See also}:
11870 @ref{RANDOM_NUMBER}
11876 @section @code{RAND} --- Real pseudo-random number
11878 @cindex random number generation
11881 @item @emph{Description}:
11882 @code{RAND(FLAG)} returns a pseudo-random number from a uniform
11883 distribution between 0 and 1. If @var{FLAG} is 0, the next number
11884 in the current sequence is returned; if @var{FLAG} is 1, the generator
11885 is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
11886 it is used as a new seed with @code{SRAND}.
11888 This intrinsic routine is provided for backwards compatibility with
11889 GNU Fortran 77. It implements a simple modulo generator as provided
11890 by @command{g77}. For new code, one should consider the use of
11891 @ref{RANDOM_NUMBER} as it implements a superior algorithm.
11893 @item @emph{Standard}:
11896 @item @emph{Class}:
11899 @item @emph{Syntax}:
11900 @code{RESULT = RAND(I)}
11902 @item @emph{Arguments}:
11903 @multitable @columnfractions .15 .70
11904 @item @var{I} @tab Shall be a scalar @code{INTEGER} of kind 4.
11907 @item @emph{Return value}:
11908 The return value is of @code{REAL} type and the default kind.
11910 @item @emph{Example}:
11913 integer,parameter :: seed = 86456
11916 print *, rand(), rand(), rand(), rand()
11917 print *, rand(seed), rand(), rand(), rand()
11918 end program test_rand
11921 @item @emph{See also}:
11923 @ref{RANDOM_NUMBER}
11929 @section @code{RANDOM_INIT} --- Initialize a pseudo-random number generator
11930 @fnindex RANDOM_INIT
11931 @cindex random number generation, initialization
11934 @item @emph{Description}:
11935 Initializes the state of the pseudorandom number generator used by
11936 @code{RANDOM_NUMBER}.
11938 @item @emph{Standard}:
11941 @item @emph{Class}:
11944 @item @emph{Syntax}:
11945 @code{CALL RANDOM_INIT(REPEATABLE, IMAGE_DISTINCT)}
11947 @item @emph{Arguments}:
11948 @multitable @columnfractions .25 .70
11949 @item @var{REPEATABLE} @tab Shall be a scalar with a @code{LOGICAL} type,
11950 and it is @code{INTENT(IN)}. If it is @code{.true.}, the seed is set to
11951 a processor-dependent value that is the same each time @code{RANDOM_INIT}
11952 is called from the same image. The term ``same image'' means a single
11953 instance of program execution. The sequence of random numbers is different
11954 for repeated execution of the program. If it is @code{.false.}, the seed
11955 is set to a processor-dependent value.
11956 @item @var{IMAGE_DISTINCT} @tab Shall be a scalar with a
11957 @code{LOGICAL} type, and it is @code{INTENT(IN)}. If it is @code{.true.},
11958 the seed is set to a processor-dependent value that is distinct from th
11959 seed set by a call to @code{RANDOM_INIT} in another image. If it is
11960 @code{.false.}, the seed is set to a value that does depend which image called
11961 @code{RANDOM_INIT}.
11964 @item @emph{Example}:
11966 program test_random_seed
11969 call random_init(.true., .true.)
11970 call random_number(x)
11971 call random_init(.true., .true.)
11972 call random_number(y)
11973 ! x and y are the same sequence
11974 if (any(x /= y)) call abort
11975 end program test_random_seed
11978 @item @emph{See also}:
11979 @ref{RANDOM_NUMBER}, @*
11984 @node RANDOM_NUMBER
11985 @section @code{RANDOM_NUMBER} --- Pseudo-random number
11986 @fnindex RANDOM_NUMBER
11987 @cindex random number generation
11990 @item @emph{Description}:
11991 Returns a single pseudorandom number or an array of pseudorandom numbers
11992 from the uniform distribution over the range @math{ 0 \leq x < 1}.
11994 The runtime-library implements the xoshiro256** pseudorandom number
11995 generator (PRNG). This generator has a period of @math{2^{256} - 1},
11996 and when using multiple threads up to @math{2^{128}} threads can each
11997 generate @math{2^{128}} random numbers before any aliasing occurs.
11999 Note that in a multi-threaded program (e.g. using OpenMP directives),
12000 each thread will have its own random number state. For details of the
12001 seeding procedure, see the documentation for the @code{RANDOM_SEED}
12005 @item @emph{Standard}:
12006 Fortran 90 and later
12008 @item @emph{Class}:
12011 @item @emph{Syntax}:
12012 @code{CALL RANDOM_NUMBER(HARVEST)}
12014 @item @emph{Arguments}:
12015 @multitable @columnfractions .15 .70
12016 @item @var{HARVEST} @tab Shall be a scalar or an array of type @code{REAL}.
12019 @item @emph{Example}:
12021 program test_random_number
12023 CALL RANDOM_NUMBER(r)
12027 @item @emph{See also}:
12028 @ref{RANDOM_SEED}, @*
12035 @section @code{RANDOM_SEED} --- Initialize a pseudo-random number sequence
12036 @fnindex RANDOM_SEED
12037 @cindex random number generation, seeding
12038 @cindex seeding a random number generator
12041 @item @emph{Description}:
12042 Restarts or queries the state of the pseudorandom number generator used by
12043 @code{RANDOM_NUMBER}.
12045 If @code{RANDOM_SEED} is called without arguments, it is seeded with
12046 random data retrieved from the operating system.
12048 As an extension to the Fortran standard, the GFortran
12049 @code{RANDOM_NUMBER} supports multiple threads. Each thread in a
12050 multi-threaded program has its own seed. When @code{RANDOM_SEED} is
12051 called either without arguments or with the @var{PUT} argument, the
12052 given seed is copied into a master seed as well as the seed of the
12053 current thread. When a new thread uses @code{RANDOM_NUMBER} for the
12054 first time, the seed is copied from the master seed, and forwarded
12055 @math{N * 2^{128}} steps to guarantee that the random stream does not
12056 alias any other stream in the system, where @var{N} is the number of
12057 threads that have used @code{RANDOM_NUMBER} so far during the program
12060 @item @emph{Standard}:
12061 Fortran 90 and later
12063 @item @emph{Class}:
12066 @item @emph{Syntax}:
12067 @code{CALL RANDOM_SEED([SIZE, PUT, GET])}
12069 @item @emph{Arguments}:
12070 @multitable @columnfractions .15 .70
12071 @item @var{SIZE} @tab (Optional) Shall be a scalar and of type default
12072 @code{INTEGER}, with @code{INTENT(OUT)}. It specifies the minimum size
12073 of the arrays used with the @var{PUT} and @var{GET} arguments.
12074 @item @var{PUT} @tab (Optional) Shall be an array of type default
12075 @code{INTEGER} and rank one. It is @code{INTENT(IN)} and the size of
12076 the array must be larger than or equal to the number returned by the
12077 @var{SIZE} argument.
12078 @item @var{GET} @tab (Optional) Shall be an array of type default
12079 @code{INTEGER} and rank one. It is @code{INTENT(OUT)} and the size
12080 of the array must be larger than or equal to the number returned by
12081 the @var{SIZE} argument.
12084 @item @emph{Example}:
12086 program test_random_seed
12088 integer, allocatable :: seed(:)
12091 call random_seed(size = n)
12093 call random_seed(get=seed)
12095 end program test_random_seed
12098 @item @emph{See also}:
12099 @ref{RANDOM_NUMBER}, @*
12106 @section @code{RANGE} --- Decimal exponent range
12108 @cindex model representation, range
12111 @item @emph{Description}:
12112 @code{RANGE(X)} returns the decimal exponent range in the model of the
12115 @item @emph{Standard}:
12116 Fortran 90 and later
12118 @item @emph{Class}:
12121 @item @emph{Syntax}:
12122 @code{RESULT = RANGE(X)}
12124 @item @emph{Arguments}:
12125 @multitable @columnfractions .15 .70
12126 @item @var{X} @tab Shall be of type @code{INTEGER}, @code{REAL}
12130 @item @emph{Return value}:
12131 The return value is of type @code{INTEGER} and of the default integer
12134 @item @emph{Example}:
12135 See @code{PRECISION} for an example.
12136 @item @emph{See also}:
12137 @ref{SELECTED_REAL_KIND}, @*
12144 @section @code{RANK} --- Rank of a data object
12149 @item @emph{Description}:
12150 @code{RANK(A)} returns the rank of a scalar or array data object.
12152 @item @emph{Standard}:
12153 Technical Specification (TS) 29113
12155 @item @emph{Class}:
12158 @item @emph{Syntax}:
12159 @code{RESULT = RANK(A)}
12161 @item @emph{Arguments}:
12162 @multitable @columnfractions .15 .70
12163 @item @var{A} @tab can be of any type
12166 @item @emph{Return value}:
12167 The return value is of type @code{INTEGER} and of the default integer
12168 kind. For arrays, their rank is returned; for scalars zero is returned.
12170 @item @emph{Example}:
12174 real, allocatable :: b(:,:)
12176 print *, rank(a), rank(b) ! Prints: 0 2
12177 end program test_rank
12185 @section @code{REAL} --- Convert to real type
12194 @cindex conversion, to real
12195 @cindex complex numbers, real part
12198 @item @emph{Description}:
12199 @code{REAL(A [, KIND])} converts its argument @var{A} to a real type. The
12200 @code{REALPART} function is provided for compatibility with @command{g77},
12201 and its use is strongly discouraged.
12203 @item @emph{Standard}:
12204 Fortran 77 and later, with @var{KIND} argument Fortran 90 and later, has GNU extensions
12206 @item @emph{Class}:
12209 @item @emph{Syntax}:
12210 @multitable @columnfractions .80
12211 @item @code{RESULT = REAL(A [, KIND])}
12212 @item @code{RESULT = REALPART(Z)}
12215 @item @emph{Arguments}:
12216 @multitable @columnfractions .15 .70
12217 @item @var{A} @tab Shall be @code{INTEGER}, @code{REAL}, or
12219 @item @var{KIND} @tab (Optional) A scalar @code{INTEGER} constant
12220 expression indicating the kind parameter of the result.
12223 @item @emph{Return value}:
12224 These functions return a @code{REAL} variable or array under
12225 the following rules:
12229 @code{REAL(A)} is converted to a default real type if @var{A} is an
12230 integer or real variable.
12232 @code{REAL(A)} is converted to a real type with the kind type parameter
12233 of @var{A} if @var{A} is a complex variable.
12235 @code{REAL(A, KIND)} is converted to a real type with kind type
12236 parameter @var{KIND} if @var{A} is a complex, integer, or real
12240 @item @emph{Example}:
12243 complex :: x = (1.0, 2.0)
12244 print *, real(x), real(x,8), realpart(x)
12245 end program test_real
12248 @item @emph{Specific names}:
12249 @multitable @columnfractions .20 .23 .20 .33
12250 @headitem Name @tab Argument @tab Return type @tab Standard
12251 @item @code{FLOAT(A)} @tab @code{INTEGER(4)} @tab @code{REAL(4)} @tab Fortran 77 and later
12252 @item @code{DFLOAT(A)} @tab @code{INTEGER(4)} @tab @code{REAL(8)} @tab GNU extension
12253 @item @code{FLOATI(A)} @tab @code{INTEGER(2)} @tab @code{REAL(4)} @tab GNU extension (-fdec)
12254 @item @code{FLOATJ(A)} @tab @code{INTEGER(4)} @tab @code{REAL(4)} @tab GNU extension (-fdec)
12255 @item @code{FLOATK(A)} @tab @code{INTEGER(8)} @tab @code{REAL(4)} @tab GNU extension (-fdec)
12256 @item @code{SNGL(A)} @tab @code{REAL(8)} @tab @code{REAL(4)} @tab Fortran 77 and later
12260 @item @emph{See also}:
12268 @section @code{RENAME} --- Rename a file
12270 @cindex file system, rename file
12273 @item @emph{Description}:
12274 Renames a file from file @var{PATH1} to @var{PATH2}. A null
12275 character (@code{CHAR(0)}) can be used to mark the end of the names in
12276 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
12277 names are ignored. If the @var{STATUS} argument is supplied, it
12278 contains 0 on success or a nonzero error code upon return; see
12281 This intrinsic is provided in both subroutine and function forms;
12282 however, only one form can be used in any given program unit.
12284 @item @emph{Standard}:
12287 @item @emph{Class}:
12288 Subroutine, function
12290 @item @emph{Syntax}:
12291 @multitable @columnfractions .80
12292 @item @code{CALL RENAME(PATH1, PATH2 [, STATUS])}
12293 @item @code{STATUS = RENAME(PATH1, PATH2)}
12296 @item @emph{Arguments}:
12297 @multitable @columnfractions .15 .70
12298 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
12299 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
12300 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
12303 @item @emph{See also}:
12311 @section @code{REPEAT} --- Repeated string concatenation
12313 @cindex string, repeat
12314 @cindex string, concatenate
12317 @item @emph{Description}:
12318 Concatenates @var{NCOPIES} copies of a string.
12320 @item @emph{Standard}:
12321 Fortran 90 and later
12323 @item @emph{Class}:
12324 Transformational function
12326 @item @emph{Syntax}:
12327 @code{RESULT = REPEAT(STRING, NCOPIES)}
12329 @item @emph{Arguments}:
12330 @multitable @columnfractions .15 .70
12331 @item @var{STRING} @tab Shall be scalar and of type @code{CHARACTER}.
12332 @item @var{NCOPIES} @tab Shall be scalar and of type @code{INTEGER}.
12335 @item @emph{Return value}:
12336 A new scalar of type @code{CHARACTER} built up from @var{NCOPIES} copies
12339 @item @emph{Example}:
12341 program test_repeat
12342 write(*,*) repeat("x", 5) ! "xxxxx"
12350 @section @code{RESHAPE} --- Function to reshape an array
12352 @cindex array, change dimensions
12353 @cindex array, transmogrify
12356 @item @emph{Description}:
12357 Reshapes @var{SOURCE} to correspond to @var{SHAPE}. If necessary,
12358 the new array may be padded with elements from @var{PAD} or permuted
12359 as defined by @var{ORDER}.
12361 @item @emph{Standard}:
12362 Fortran 90 and later
12364 @item @emph{Class}:
12365 Transformational function
12367 @item @emph{Syntax}:
12368 @code{RESULT = RESHAPE(SOURCE, SHAPE[, PAD, ORDER])}
12370 @item @emph{Arguments}:
12371 @multitable @columnfractions .15 .70
12372 @item @var{SOURCE} @tab Shall be an array of any type.
12373 @item @var{SHAPE} @tab Shall be of type @code{INTEGER} and an
12374 array of rank one. Its values must be positive or zero.
12375 @item @var{PAD} @tab (Optional) shall be an array of the same
12376 type as @var{SOURCE}.
12377 @item @var{ORDER} @tab (Optional) shall be of type @code{INTEGER}
12378 and an array of the same shape as @var{SHAPE}. Its values shall
12379 be a permutation of the numbers from 1 to n, where n is the size of
12380 @var{SHAPE}. If @var{ORDER} is absent, the natural ordering shall
12384 @item @emph{Return value}:
12385 The result is an array of shape @var{SHAPE} with the same type as
12388 @item @emph{Example}:
12390 PROGRAM test_reshape
12391 INTEGER, DIMENSION(4) :: x
12392 WRITE(*,*) SHAPE(x) ! prints "4"
12393 WRITE(*,*) SHAPE(RESHAPE(x, (/2, 2/))) ! prints "2 2"
12397 @item @emph{See also}:
12404 @section @code{RRSPACING} --- Reciprocal of the relative spacing
12406 @cindex real number, relative spacing
12407 @cindex floating point, relative spacing
12411 @item @emph{Description}:
12412 @code{RRSPACING(X)} returns the reciprocal of the relative spacing of
12413 model numbers near @var{X}.
12415 @item @emph{Standard}:
12416 Fortran 90 and later
12418 @item @emph{Class}:
12421 @item @emph{Syntax}:
12422 @code{RESULT = RRSPACING(X)}
12424 @item @emph{Arguments}:
12425 @multitable @columnfractions .15 .70
12426 @item @var{X} @tab Shall be of type @code{REAL}.
12429 @item @emph{Return value}:
12430 The return value is of the same type and kind as @var{X}.
12431 The value returned is equal to
12432 @code{ABS(FRACTION(X)) * FLOAT(RADIX(X))**DIGITS(X)}.
12434 @item @emph{See also}:
12441 @section @code{RSHIFT} --- Right shift bits
12443 @cindex bits, shift right
12446 @item @emph{Description}:
12447 @code{RSHIFT} returns a value corresponding to @var{I} with all of the
12448 bits shifted right by @var{SHIFT} places. @var{SHIFT} shall be
12449 nonnegative and less than or equal to @code{BIT_SIZE(I)}, otherwise
12450 the result value is undefined. Bits shifted out from the right end
12451 are lost. The fill is arithmetic: the bits shifted in from the left
12452 end are equal to the leftmost bit, which in two's complement
12453 representation is the sign bit.
12455 This function has been superseded by the @code{SHIFTA} intrinsic, which
12456 is standard in Fortran 2008 and later.
12458 @item @emph{Standard}:
12461 @item @emph{Class}:
12464 @item @emph{Syntax}:
12465 @code{RESULT = RSHIFT(I, SHIFT)}
12467 @item @emph{Arguments}:
12468 @multitable @columnfractions .15 .70
12469 @item @var{I} @tab The type shall be @code{INTEGER}.
12470 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
12473 @item @emph{Return value}:
12474 The return value is of type @code{INTEGER} and of the same kind as
12477 @item @emph{See also}:
12490 @section @code{SAME_TYPE_AS} --- Query dynamic types for equality
12491 @fnindex SAME_TYPE_AS
12494 @item @emph{Description}:
12495 Query dynamic types for equality.
12497 @item @emph{Standard}:
12498 Fortran 2003 and later
12500 @item @emph{Class}:
12503 @item @emph{Syntax}:
12504 @code{RESULT = SAME_TYPE_AS(A, B)}
12506 @item @emph{Arguments}:
12507 @multitable @columnfractions .15 .70
12508 @item @var{A} @tab Shall be an object of extensible declared type or
12509 unlimited polymorphic.
12510 @item @var{B} @tab Shall be an object of extensible declared type or
12511 unlimited polymorphic.
12514 @item @emph{Return value}:
12515 The return value is a scalar of type default logical. It is true if and
12516 only if the dynamic type of A is the same as the dynamic type of B.
12518 @item @emph{See also}:
12519 @ref{EXTENDS_TYPE_OF}
12526 @section @code{SCALE} --- Scale a real value
12528 @cindex real number, scale
12529 @cindex floating point, scale
12532 @item @emph{Description}:
12533 @code{SCALE(X,I)} returns @code{X * RADIX(X)**I}.
12535 @item @emph{Standard}:
12536 Fortran 90 and later
12538 @item @emph{Class}:
12541 @item @emph{Syntax}:
12542 @code{RESULT = SCALE(X, I)}
12544 @item @emph{Arguments}:
12545 @multitable @columnfractions .15 .70
12546 @item @var{X} @tab The type of the argument shall be a @code{REAL}.
12547 @item @var{I} @tab The type of the argument shall be a @code{INTEGER}.
12550 @item @emph{Return value}:
12551 The return value is of the same type and kind as @var{X}.
12552 Its value is @code{X * RADIX(X)**I}.
12554 @item @emph{Example}:
12557 real :: x = 178.1387e-4
12559 print *, scale(x,i), x*radix(x)**i
12560 end program test_scale
12568 @section @code{SCAN} --- Scan a string for the presence of a set of characters
12570 @cindex string, find subset
12573 @item @emph{Description}:
12574 Scans a @var{STRING} for any of the characters in a @var{SET}
12577 If @var{BACK} is either absent or equals @code{FALSE}, this function
12578 returns the position of the leftmost character of @var{STRING} that is
12579 in @var{SET}. If @var{BACK} equals @code{TRUE}, the rightmost position
12580 is returned. If no character of @var{SET} is found in @var{STRING}, the
12583 @item @emph{Standard}:
12584 Fortran 90 and later, with @var{KIND} argument Fortran 2003 and later
12586 @item @emph{Class}:
12589 @item @emph{Syntax}:
12590 @code{RESULT = SCAN(STRING, SET[, BACK [, KIND]])}
12592 @item @emph{Arguments}:
12593 @multitable @columnfractions .15 .70
12594 @item @var{STRING} @tab Shall be of type @code{CHARACTER}.
12595 @item @var{SET} @tab Shall be of type @code{CHARACTER}.
12596 @item @var{BACK} @tab (Optional) shall be of type @code{LOGICAL}.
12597 @item @var{KIND} @tab (Optional) A scalar @code{INTEGER} constant
12598 expression indicating the kind parameter of the result.
12601 @item @emph{Return value}:
12602 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
12603 @var{KIND} is absent, the return value is of default integer kind.
12605 @item @emph{Example}:
12608 WRITE(*,*) SCAN("FORTRAN", "AO") ! 2, found 'O'
12609 WRITE(*,*) SCAN("FORTRAN", "AO", .TRUE.) ! 6, found 'A'
12610 WRITE(*,*) SCAN("FORTRAN", "C++") ! 0, found none
12614 @item @emph{See also}:
12615 @ref{INDEX intrinsic}, @*
12622 @section @code{SECNDS} --- Time function
12624 @cindex time, elapsed
12625 @cindex elapsed time
12628 @item @emph{Description}:
12629 @code{SECNDS(X)} gets the time in seconds from the real-time system clock.
12630 @var{X} is a reference time, also in seconds. If this is zero, the time in
12631 seconds from midnight is returned. This function is non-standard and its
12632 use is discouraged.
12634 @item @emph{Standard}:
12637 @item @emph{Class}:
12640 @item @emph{Syntax}:
12641 @code{RESULT = SECNDS (X)}
12643 @item @emph{Arguments}:
12644 @multitable @columnfractions .15 .70
12645 @item @var{T} @tab Shall be of type @code{REAL(4)}.
12646 @item @var{X} @tab Shall be of type @code{REAL(4)}.
12649 @item @emph{Return value}:
12652 @item @emph{Example}:
12654 program test_secnds
12657 print *, secnds (0.0) ! seconds since midnight
12658 t1 = secnds (0.0) ! reference time
12659 do i = 1, 10000000 ! do something
12661 t2 = secnds (t1) ! elapsed time
12662 print *, "Something took ", t2, " seconds."
12663 end program test_secnds
12670 @section @code{SECOND} --- CPU time function
12672 @cindex time, elapsed
12673 @cindex elapsed time
12676 @item @emph{Description}:
12677 Returns a @code{REAL(4)} value representing the elapsed CPU time in
12678 seconds. This provides the same functionality as the standard
12679 @code{CPU_TIME} intrinsic, and is only included for backwards
12682 This intrinsic is provided in both subroutine and function forms;
12683 however, only one form can be used in any given program unit.
12685 @item @emph{Standard}:
12688 @item @emph{Class}:
12689 Subroutine, function
12691 @item @emph{Syntax}:
12692 @multitable @columnfractions .80
12693 @item @code{CALL SECOND(TIME)}
12694 @item @code{TIME = SECOND()}
12697 @item @emph{Arguments}:
12698 @multitable @columnfractions .15 .70
12699 @item @var{TIME} @tab Shall be of type @code{REAL(4)}.
12702 @item @emph{Return value}:
12703 In either syntax, @var{TIME} is set to the process's current runtime in
12706 @item @emph{See also}:
12713 @node SELECTED_CHAR_KIND
12714 @section @code{SELECTED_CHAR_KIND} --- Choose character kind
12715 @fnindex SELECTED_CHAR_KIND
12716 @cindex character kind
12717 @cindex kind, character
12720 @item @emph{Description}:
12722 @code{SELECTED_CHAR_KIND(NAME)} returns the kind value for the character
12723 set named @var{NAME}, if a character set with such a name is supported,
12724 or @math{-1} otherwise. Currently, supported character sets include
12725 ``ASCII'' and ``DEFAULT'', which are equivalent, and ``ISO_10646''
12726 (Universal Character Set, UCS-4) which is commonly known as Unicode.
12728 @item @emph{Standard}:
12729 Fortran 2003 and later
12731 @item @emph{Class}:
12732 Transformational function
12734 @item @emph{Syntax}:
12735 @code{RESULT = SELECTED_CHAR_KIND(NAME)}
12737 @item @emph{Arguments}:
12738 @multitable @columnfractions .15 .70
12739 @item @var{NAME} @tab Shall be a scalar and of the default character type.
12742 @item @emph{Example}:
12744 program character_kind
12745 use iso_fortran_env
12747 integer, parameter :: ascii = selected_char_kind ("ascii")
12748 integer, parameter :: ucs4 = selected_char_kind ('ISO_10646')
12750 character(kind=ascii, len=26) :: alphabet
12751 character(kind=ucs4, len=30) :: hello_world
12753 alphabet = ascii_"abcdefghijklmnopqrstuvwxyz"
12754 hello_world = ucs4_'Hello World and Ni Hao -- ' &
12755 // char (int (z'4F60'), ucs4) &
12756 // char (int (z'597D'), ucs4)
12758 write (*,*) alphabet
12760 open (output_unit, encoding='UTF-8')
12761 write (*,*) trim (hello_world)
12762 end program character_kind
12768 @node SELECTED_INT_KIND
12769 @section @code{SELECTED_INT_KIND} --- Choose integer kind
12770 @fnindex SELECTED_INT_KIND
12771 @cindex integer kind
12772 @cindex kind, integer
12775 @item @emph{Description}:
12776 @code{SELECTED_INT_KIND(R)} return the kind value of the smallest integer
12777 type that can represent all values ranging from @math{-10^R} (exclusive)
12778 to @math{10^R} (exclusive). If there is no integer kind that accommodates
12779 this range, @code{SELECTED_INT_KIND} returns @math{-1}.
12781 @item @emph{Standard}:
12782 Fortran 90 and later
12784 @item @emph{Class}:
12785 Transformational function
12787 @item @emph{Syntax}:
12788 @code{RESULT = SELECTED_INT_KIND(R)}
12790 @item @emph{Arguments}:
12791 @multitable @columnfractions .15 .70
12792 @item @var{R} @tab Shall be a scalar and of type @code{INTEGER}.
12795 @item @emph{Example}:
12797 program large_integers
12798 integer,parameter :: k5 = selected_int_kind(5)
12799 integer,parameter :: k15 = selected_int_kind(15)
12800 integer(kind=k5) :: i5
12801 integer(kind=k15) :: i15
12803 print *, huge(i5), huge(i15)
12805 ! The following inequalities are always true
12806 print *, huge(i5) >= 10_k5**5-1
12807 print *, huge(i15) >= 10_k15**15-1
12808 end program large_integers
12814 @node SELECTED_REAL_KIND
12815 @section @code{SELECTED_REAL_KIND} --- Choose real kind
12816 @fnindex SELECTED_REAL_KIND
12819 @cindex radix, real
12822 @item @emph{Description}:
12823 @code{SELECTED_REAL_KIND(P,R)} returns the kind value of a real data type
12824 with decimal precision of at least @code{P} digits, exponent range of
12825 at least @code{R}, and with a radix of @code{RADIX}.
12827 @item @emph{Standard}:
12828 Fortran 90 and later, with @code{RADIX} Fortran 2008 or later
12830 @item @emph{Class}:
12831 Transformational function
12833 @item @emph{Syntax}:
12834 @code{RESULT = SELECTED_REAL_KIND([P, R, RADIX])}
12836 @item @emph{Arguments}:
12837 @multitable @columnfractions .15 .70
12838 @item @var{P} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
12839 @item @var{R} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
12840 @item @var{RADIX} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
12842 Before Fortran 2008, at least one of the arguments @var{R} or @var{P} shall
12843 be present; since Fortran 2008, they are assumed to be zero if absent.
12845 @item @emph{Return value}:
12847 @code{SELECTED_REAL_KIND} returns the value of the kind type parameter of
12848 a real data type with decimal precision of at least @code{P} digits, a
12849 decimal exponent range of at least @code{R}, and with the requested
12850 @code{RADIX}. If the @code{RADIX} parameter is absent, real kinds with
12851 any radix can be returned. If more than one real data type meet the
12852 criteria, the kind of the data type with the smallest decimal precision
12853 is returned. If no real data type matches the criteria, the result is
12855 @item -1 if the processor does not support a real data type with a
12856 precision greater than or equal to @code{P}, but the @code{R} and
12857 @code{RADIX} requirements can be fulfilled
12858 @item -2 if the processor does not support a real type with an exponent
12859 range greater than or equal to @code{R}, but @code{P} and @code{RADIX}
12861 @item -3 if @code{RADIX} but not @code{P} and @code{R} requirements
12863 @item -4 if @code{RADIX} and either @code{P} or @code{R} requirements
12865 @item -5 if there is no real type with the given @code{RADIX}
12868 @item @emph{Example}:
12871 integer,parameter :: p6 = selected_real_kind(6)
12872 integer,parameter :: p10r100 = selected_real_kind(10,100)
12873 integer,parameter :: r400 = selected_real_kind(r=400)
12875 real(kind=p10r100) :: y
12876 real(kind=r400) :: z
12878 print *, precision(x), range(x)
12879 print *, precision(y), range(y)
12880 print *, precision(z), range(z)
12881 end program real_kinds
12883 @item @emph{See also}:
12884 @ref{PRECISION}, @*
12892 @section @code{SET_EXPONENT} --- Set the exponent of the model
12893 @fnindex SET_EXPONENT
12894 @cindex real number, set exponent
12895 @cindex floating point, set exponent
12898 @item @emph{Description}:
12899 @code{SET_EXPONENT(X, I)} returns the real number whose fractional part
12900 is that of @var{X} and whose exponent part is @var{I}.
12902 @item @emph{Standard}:
12903 Fortran 90 and later
12905 @item @emph{Class}:
12908 @item @emph{Syntax}:
12909 @code{RESULT = SET_EXPONENT(X, I)}
12911 @item @emph{Arguments}:
12912 @multitable @columnfractions .15 .70
12913 @item @var{X} @tab Shall be of type @code{REAL}.
12914 @item @var{I} @tab Shall be of type @code{INTEGER}.
12917 @item @emph{Return value}:
12918 The return value is of the same type and kind as @var{X}.
12919 The real number whose fractional part
12920 is that of @var{X} and whose exponent part if @var{I} is returned;
12921 it is @code{FRACTION(X) * RADIX(X)**I}.
12923 @item @emph{Example}:
12925 PROGRAM test_setexp
12926 REAL :: x = 178.1387e-4
12928 PRINT *, SET_EXPONENT(x, i), FRACTION(x) * RADIX(x)**i
12937 @section @code{SHAPE} --- Determine the shape of an array
12939 @cindex array, shape
12942 @item @emph{Description}:
12943 Determines the shape of an array.
12945 @item @emph{Standard}:
12946 Fortran 90 and later, with @var{KIND} argument Fortran 2003 and later
12948 @item @emph{Class}:
12951 @item @emph{Syntax}:
12952 @code{RESULT = SHAPE(SOURCE [, KIND])}
12954 @item @emph{Arguments}:
12955 @multitable @columnfractions .15 .70
12956 @item @var{SOURCE} @tab Shall be an array or scalar of any type.
12957 If @var{SOURCE} is a pointer it must be associated and allocatable
12958 arrays must be allocated.
12959 @item @var{KIND} @tab (Optional) A scalar @code{INTEGER} constant
12960 expression indicating the kind parameter of the result.
12963 @item @emph{Return value}:
12964 An @code{INTEGER} array of rank one with as many elements as @var{SOURCE}
12965 has dimensions. The elements of the resulting array correspond to the extend
12966 of @var{SOURCE} along the respective dimensions. If @var{SOURCE} is a scalar,
12967 the result is the rank one array of size zero. If @var{KIND} is absent, the
12968 return value has the default integer kind otherwise the specified kind.
12970 @item @emph{Example}:
12973 INTEGER, DIMENSION(-1:1, -1:2) :: A
12974 WRITE(*,*) SHAPE(A) ! (/ 3, 4 /)
12975 WRITE(*,*) SIZE(SHAPE(42)) ! (/ /)
12979 @item @emph{See also}:
12987 @section @code{SHIFTA} --- Right shift with fill
12989 @cindex bits, shift right
12990 @cindex shift, right with fill
12993 @item @emph{Description}:
12994 @code{SHIFTA} returns a value corresponding to @var{I} with all of the
12995 bits shifted right by @var{SHIFT} places. @var{SHIFT} that be
12996 nonnegative and less than or equal to @code{BIT_SIZE(I)}, otherwise
12997 the result value is undefined. Bits shifted out from the right end
12998 are lost. The fill is arithmetic: the bits shifted in from the left
12999 end are equal to the leftmost bit, which in two's complement
13000 representation is the sign bit.
13002 @item @emph{Standard}:
13003 Fortran 2008 and later
13005 @item @emph{Class}:
13008 @item @emph{Syntax}:
13009 @code{RESULT = SHIFTA(I, SHIFT)}
13011 @item @emph{Arguments}:
13012 @multitable @columnfractions .15 .70
13013 @item @var{I} @tab The type shall be @code{INTEGER}.
13014 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
13017 @item @emph{Return value}:
13018 The return value is of type @code{INTEGER} and of the same kind as
13021 @item @emph{See also}:
13029 @section @code{SHIFTL} --- Left shift
13031 @cindex bits, shift left
13032 @cindex shift, left
13035 @item @emph{Description}:
13036 @code{SHIFTL} returns a value corresponding to @var{I} with all of the
13037 bits shifted left by @var{SHIFT} places. @var{SHIFT} shall be
13038 nonnegative and less than or equal to @code{BIT_SIZE(I)}, otherwise
13039 the result value is undefined. Bits shifted out from the left end are
13040 lost, and bits shifted in from the right end are set to 0.
13042 @item @emph{Standard}:
13043 Fortran 2008 and later
13045 @item @emph{Class}:
13048 @item @emph{Syntax}:
13049 @code{RESULT = SHIFTL(I, SHIFT)}
13051 @item @emph{Arguments}:
13052 @multitable @columnfractions .15 .70
13053 @item @var{I} @tab The type shall be @code{INTEGER}.
13054 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
13057 @item @emph{Return value}:
13058 The return value is of type @code{INTEGER} and of the same kind as
13061 @item @emph{See also}:
13069 @section @code{SHIFTR} --- Right shift
13071 @cindex bits, shift right
13072 @cindex shift, right
13075 @item @emph{Description}:
13076 @code{SHIFTR} returns a value corresponding to @var{I} with all of the
13077 bits shifted right by @var{SHIFT} places. @var{SHIFT} shall be
13078 nonnegative and less than or equal to @code{BIT_SIZE(I)}, otherwise
13079 the result value is undefined. Bits shifted out from the right end
13080 are lost, and bits shifted in from the left end are set to 0.
13082 @item @emph{Standard}:
13083 Fortran 2008 and later
13085 @item @emph{Class}:
13088 @item @emph{Syntax}:
13089 @code{RESULT = SHIFTR(I, SHIFT)}
13091 @item @emph{Arguments}:
13092 @multitable @columnfractions .15 .70
13093 @item @var{I} @tab The type shall be @code{INTEGER}.
13094 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
13097 @item @emph{Return value}:
13098 The return value is of type @code{INTEGER} and of the same kind as
13101 @item @emph{See also}:
13109 @section @code{SIGN} --- Sign copying function
13113 @cindex sign copying
13116 @item @emph{Description}:
13117 @code{SIGN(A,B)} returns the value of @var{A} with the sign of @var{B}.
13119 @item @emph{Standard}:
13120 Fortran 77 and later
13122 @item @emph{Class}:
13125 @item @emph{Syntax}:
13126 @code{RESULT = SIGN(A, B)}
13128 @item @emph{Arguments}:
13129 @multitable @columnfractions .15 .70
13130 @item @var{A} @tab Shall be of type @code{INTEGER} or @code{REAL}
13131 @item @var{B} @tab Shall be of the same type and kind as @var{A}.
13134 @item @emph{Return value}:
13135 The kind of the return value is that of @var{A} and @var{B}.
13136 If @math{B \ge 0} then the result is @code{ABS(A)}, else
13137 it is @code{-ABS(A)}.
13139 @item @emph{Example}:
13142 print *, sign(-12,1)
13143 print *, sign(-12,0)
13144 print *, sign(-12,-1)
13146 print *, sign(-12.,1.)
13147 print *, sign(-12.,0.)
13148 print *, sign(-12.,-1.)
13149 end program test_sign
13152 @item @emph{Specific names}:
13153 @multitable @columnfractions .20 .26 .20 .30
13154 @headitem Name @tab Arguments @tab Return type @tab Standard
13155 @item @code{SIGN(A,B)} @tab @code{REAL(4) A, B} @tab @code{REAL(4)} @tab Fortran 77 and later
13156 @item @code{ISIGN(A,B)} @tab @code{INTEGER(4) A, B} @tab @code{INTEGER(4)} @tab Fortran 77 and later
13157 @item @code{DSIGN(A,B)} @tab @code{REAL(8) A, B} @tab @code{REAL(8)} @tab Fortran 77 and later
13164 @section @code{SIGNAL} --- Signal handling subroutine (or function)
13166 @cindex system, signal handling
13169 @item @emph{Description}:
13170 @code{SIGNAL(NUMBER, HANDLER [, STATUS])} causes external subroutine
13171 @var{HANDLER} to be executed with a single integer argument passed by
13172 value when signal @var{NUMBER} occurs. If @var{HANDLER} is an integer,
13173 it can be used to turn off handling of signal @var{NUMBER} or revert to
13174 its default action. See @code{signal(2)}.
13176 If @code{SIGNAL} is called as a subroutine and the @var{STATUS} argument
13177 is supplied, it is set to the value returned by @code{signal(2)}.
13179 @item @emph{Standard}:
13182 @item @emph{Class}:
13183 Subroutine, function
13185 @item @emph{Syntax}:
13186 @multitable @columnfractions .80
13187 @item @code{CALL SIGNAL(NUMBER, HANDLER [, STATUS])}
13188 @item @code{STATUS = SIGNAL(NUMBER, HANDLER)}
13191 @item @emph{Arguments}:
13192 @multitable @columnfractions .15 .70
13193 @item @var{NUMBER} @tab Shall be a scalar integer, with @code{INTENT(IN)}
13194 @item @var{HANDLER}@tab Signal handler (@code{INTEGER FUNCTION} or
13195 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar.
13196 @code{INTEGER}. It is @code{INTENT(IN)}.
13197 @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
13198 integer. It has @code{INTENT(OUT)}.
13201 @item @emph{Return value}:
13202 The @code{SIGNAL} function returns the value returned by @code{signal(2)}.
13204 @item @emph{Example}:
13208 ! POSIX.1-2017: void (*func)(int)
13209 subroutine handler_print(signum) bind(C)
13210 use iso_c_binding, only: c_int
13211 integer(c_int), value :: signum
13212 print *, 'handler_print invoked with signum =', signum
13215 program test_signal
13217 intrinsic :: signal, sleep
13218 call signal (12, handler_print) ! 12 = SIGUSR2 (on some systems)
13219 call signal (10, 1) ! 10 = SIGUSR1 and 1 = SIG_IGN (on some systems)
13222 end program test_signal
13229 @section @code{SIN} --- Sine function
13235 @cindex trigonometric function, sine
13239 @item @emph{Description}:
13240 @code{SIN(X)} computes the sine of @var{X}.
13242 @item @emph{Standard}:
13243 Fortran 77 and later
13245 @item @emph{Class}:
13248 @item @emph{Syntax}:
13249 @code{RESULT = SIN(X)}
13251 @item @emph{Arguments}:
13252 @multitable @columnfractions .15 .70
13253 @item @var{X} @tab The type shall be @code{REAL} or
13257 @item @emph{Return value}:
13258 The return value has same type and kind as @var{X}.
13260 @item @emph{Example}:
13265 end program test_sin
13268 @item @emph{Specific names}:
13269 @multitable @columnfractions .20 .23 .20 .33
13270 @headitem Name @tab Argument @tab Return type @tab Standard
13271 @item @code{SIN(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later
13272 @item @code{DSIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
13273 @item @code{CSIN(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab Fortran 77 and later
13274 @item @code{ZSIN(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
13275 @item @code{CDSIN(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
13278 @item @emph{See also}:
13279 Inverse function: @*
13281 Degrees function: @*
13288 @section @code{SIND} --- Sine function, degrees
13294 @cindex trigonometric function, sine, degrees
13295 @cindex sine, degrees
13298 @item @emph{Description}:
13299 @code{SIND(X)} computes the sine of @var{X} in degrees.
13301 This function is for compatibility only and should be avoided in favor of
13302 standard constructs wherever possible.
13304 @item @emph{Standard}:
13305 GNU extension, enabled with @option{-fdec-math}.
13307 @item @emph{Class}:
13310 @item @emph{Syntax}:
13311 @code{RESULT = SIND(X)}
13313 @item @emph{Arguments}:
13314 @multitable @columnfractions .15 .70
13315 @item @var{X} @tab The type shall be @code{REAL} or
13319 @item @emph{Return value}:
13320 The return value has same type and kind as @var{X}, and its value is in degrees.
13322 @item @emph{Example}:
13327 end program test_sind
13330 @item @emph{Specific names}:
13331 @multitable @columnfractions .20 .23 .20 .33
13332 @headitem Name @tab Argument @tab Return type @tab Standard
13333 @item @code{SIND(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU extension
13334 @item @code{DSIND(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
13335 @item @code{CSIND(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab GNU extension
13336 @item @code{ZSIND(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
13337 @item @code{CDSIND(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
13340 @item @emph{See also}:
13341 Inverse function: @*
13343 Radians function: @*
13350 @section @code{SINH} --- Hyperbolic sine function
13353 @cindex hyperbolic sine
13354 @cindex hyperbolic function, sine
13355 @cindex sine, hyperbolic
13358 @item @emph{Description}:
13359 @code{SINH(X)} computes the hyperbolic sine of @var{X}.
13361 @item @emph{Standard}:
13362 Fortran 90 and later, for a complex argument Fortran 2008 or later, has
13365 @item @emph{Class}:
13368 @item @emph{Syntax}:
13369 @code{RESULT = SINH(X)}
13371 @item @emph{Arguments}:
13372 @multitable @columnfractions .15 .70
13373 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
13376 @item @emph{Return value}:
13377 The return value has same type and kind as @var{X}.
13379 @item @emph{Example}:
13382 real(8) :: x = - 1.0_8
13384 end program test_sinh
13387 @item @emph{Specific names}:
13388 @multitable @columnfractions .20 .23 .20 .33
13389 @headitem Name @tab Argument @tab Return type @tab Standard
13390 @item @code{DSINH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 90 and later
13393 @item @emph{See also}:
13400 @section @code{SIZE} --- Determine the size of an array
13402 @cindex array, size
13403 @cindex array, number of elements
13404 @cindex array, count elements
13407 @item @emph{Description}:
13408 Determine the extent of @var{ARRAY} along a specified dimension @var{DIM},
13409 or the total number of elements in @var{ARRAY} if @var{DIM} is absent.
13411 @item @emph{Standard}:
13412 Fortran 90 and later, with @var{KIND} argument Fortran 2003 and later
13414 @item @emph{Class}:
13417 @item @emph{Syntax}:
13418 @code{RESULT = SIZE(ARRAY[, DIM [, KIND]])}
13420 @item @emph{Arguments}:
13421 @multitable @columnfractions .15 .70
13422 @item @var{ARRAY} @tab Shall be an array of any type. If @var{ARRAY} is
13423 a pointer it must be associated and allocatable arrays must be allocated.
13424 @item @var{DIM} @tab (Optional) shall be a scalar of type @code{INTEGER}
13425 and its value shall be in the range from 1 to n, where n equals the rank
13427 @item @var{KIND} @tab (Optional) A scalar @code{INTEGER} constant
13428 expression indicating the kind parameter of the result.
13431 @item @emph{Return value}:
13432 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
13433 @var{KIND} is absent, the return value is of default integer kind.
13435 @item @emph{Example}:
13438 WRITE(*,*) SIZE((/ 1, 2 /)) ! 2
13442 @item @emph{See also}:
13449 @section @code{SIZEOF} --- Size in bytes of an expression
13451 @cindex expression size
13452 @cindex size of an expression
13455 @item @emph{Description}:
13456 @code{SIZEOF(X)} calculates the number of bytes of storage the
13457 expression @code{X} occupies.
13459 @item @emph{Standard}:
13462 @item @emph{Class}:
13465 @item @emph{Syntax}:
13466 @code{N = SIZEOF(X)}
13468 @item @emph{Arguments}:
13469 @multitable @columnfractions .15 .70
13470 @item @var{X} @tab The argument shall be of any type, rank or shape.
13473 @item @emph{Return value}:
13474 The return value is of type integer and of the system-dependent kind
13475 @var{C_SIZE_T} (from the @var{ISO_C_BINDING} module). Its value is the
13476 number of bytes occupied by the argument. If the argument has the
13477 @code{POINTER} attribute, the number of bytes of the storage area pointed
13478 to is returned. If the argument is of a derived type with @code{POINTER}
13479 or @code{ALLOCATABLE} components, the return value does not account for
13480 the sizes of the data pointed to by these components. If the argument is
13481 polymorphic, the size according to the dynamic type is returned. The argument
13482 may not be a procedure or procedure pointer. Note that the code assumes for
13483 arrays that those are contiguous; for contiguous arrays, it returns the
13484 storage or an array element multiplied by the size of the array.
13486 @item @emph{Example}:
13490 print *, (sizeof(s)/sizeof(r) == 5)
13493 The example will print @code{.TRUE.} unless you are using a platform
13494 where default @code{REAL} variables are unusually padded.
13496 @item @emph{See also}:
13503 @section @code{SLEEP} --- Sleep for the specified number of seconds
13505 @cindex delayed execution
13508 @item @emph{Description}:
13509 Calling this subroutine causes the process to pause for @var{SECONDS} seconds.
13511 @item @emph{Standard}:
13514 @item @emph{Class}:
13517 @item @emph{Syntax}:
13518 @code{CALL SLEEP(SECONDS)}
13520 @item @emph{Arguments}:
13521 @multitable @columnfractions .15 .70
13522 @item @var{SECONDS} @tab The type shall be of default @code{INTEGER}.
13525 @item @emph{Example}:
13536 @section @code{SPACING} --- Smallest distance between two numbers of a given type
13538 @cindex real number, relative spacing
13539 @cindex floating point, relative spacing
13542 @item @emph{Description}:
13543 Determines the distance between the argument @var{X} and the nearest
13544 adjacent number of the same type.
13546 @item @emph{Standard}:
13547 Fortran 90 and later
13549 @item @emph{Class}:
13552 @item @emph{Syntax}:
13553 @code{RESULT = SPACING(X)}
13555 @item @emph{Arguments}:
13556 @multitable @columnfractions .15 .70
13557 @item @var{X} @tab Shall be of type @code{REAL}.
13560 @item @emph{Return value}:
13561 The result is of the same type as the input argument @var{X}.
13563 @item @emph{Example}:
13565 PROGRAM test_spacing
13566 INTEGER, PARAMETER :: SGL = SELECTED_REAL_KIND(p=6, r=37)
13567 INTEGER, PARAMETER :: DBL = SELECTED_REAL_KIND(p=13, r=200)
13569 WRITE(*,*) spacing(1.0_SGL) ! "1.1920929E-07" on i686
13570 WRITE(*,*) spacing(1.0_DBL) ! "2.220446049250313E-016" on i686
13574 @item @emph{See also}:
13581 @section @code{SPREAD} --- Add a dimension to an array
13583 @cindex array, increase dimension
13584 @cindex array, duplicate elements
13585 @cindex array, duplicate dimensions
13588 @item @emph{Description}:
13589 Replicates a @var{SOURCE} array @var{NCOPIES} times along a specified
13590 dimension @var{DIM}.
13592 @item @emph{Standard}:
13593 Fortran 90 and later
13595 @item @emph{Class}:
13596 Transformational function
13598 @item @emph{Syntax}:
13599 @code{RESULT = SPREAD(SOURCE, DIM, NCOPIES)}
13601 @item @emph{Arguments}:
13602 @multitable @columnfractions .15 .70
13603 @item @var{SOURCE} @tab Shall be a scalar or an array of any type and
13604 a rank less than seven.
13605 @item @var{DIM} @tab Shall be a scalar of type @code{INTEGER} with a
13606 value in the range from 1 to n+1, where n equals the rank of @var{SOURCE}.
13607 @item @var{NCOPIES} @tab Shall be a scalar of type @code{INTEGER}.
13610 @item @emph{Return value}:
13611 The result is an array of the same type as @var{SOURCE} and has rank n+1
13612 where n equals the rank of @var{SOURCE}.
13614 @item @emph{Example}:
13616 PROGRAM test_spread
13617 INTEGER :: a = 1, b(2) = (/ 1, 2 /)
13618 WRITE(*,*) SPREAD(A, 1, 2) ! "1 1"
13619 WRITE(*,*) SPREAD(B, 1, 2) ! "1 1 2 2"
13623 @item @emph{See also}:
13630 @section @code{SQRT} --- Square-root function
13637 @cindex square-root
13640 @item @emph{Description}:
13641 @code{SQRT(X)} computes the square root of @var{X}.
13643 @item @emph{Standard}:
13644 Fortran 77 and later
13646 @item @emph{Class}:
13649 @item @emph{Syntax}:
13650 @code{RESULT = SQRT(X)}
13652 @item @emph{Arguments}:
13653 @multitable @columnfractions .15 .70
13654 @item @var{X} @tab The type shall be @code{REAL} or
13658 @item @emph{Return value}:
13659 The return value is of type @code{REAL} or @code{COMPLEX}.
13660 The kind type parameter is the same as @var{X}.
13662 @item @emph{Example}:
13665 real(8) :: x = 2.0_8
13666 complex :: z = (1.0, 2.0)
13669 end program test_sqrt
13672 @item @emph{Specific names}:
13673 @multitable @columnfractions .20 .23 .20 .33
13674 @headitem Name @tab Argument @tab Return type @tab Standard
13675 @item @code{SQRT(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later
13676 @item @code{DSQRT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
13677 @item @code{CSQRT(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab Fortran 77 and later
13678 @item @code{ZSQRT(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
13679 @item @code{CDSQRT(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
13686 @section @code{SRAND} --- Reinitialize the random number generator
13688 @cindex random number generation, seeding
13689 @cindex seeding a random number generator
13692 @item @emph{Description}:
13693 @code{SRAND} reinitializes the pseudo-random number generator
13694 called by @code{RAND} and @code{IRAND}. The new seed used by the
13695 generator is specified by the required argument @var{SEED}.
13697 @item @emph{Standard}:
13700 @item @emph{Class}:
13703 @item @emph{Syntax}:
13704 @code{CALL SRAND(SEED)}
13706 @item @emph{Arguments}:
13707 @multitable @columnfractions .15 .70
13708 @item @var{SEED} @tab Shall be a scalar @code{INTEGER(kind=4)}.
13711 @item @emph{Return value}:
13712 Does not return anything.
13714 @item @emph{Example}:
13715 See @code{RAND} and @code{IRAND} for examples.
13717 @item @emph{Notes}:
13718 The Fortran standard specifies the intrinsic subroutines
13719 @code{RANDOM_SEED} to initialize the pseudo-random number
13720 generator and @code{RANDOM_NUMBER} to generate pseudo-random numbers.
13721 These subroutines should be used in new codes.
13723 Please note that in GNU Fortran, these two sets of intrinsics (@code{RAND},
13724 @code{IRAND} and @code{SRAND} on the one hand, @code{RANDOM_NUMBER} and
13725 @code{RANDOM_SEED} on the other hand) access two independent
13726 pseudo-random number generators.
13728 @item @emph{See also}:
13730 @ref{RANDOM_SEED}, @*
13731 @ref{RANDOM_NUMBER}
13737 @section @code{STAT} --- Get file status
13739 @cindex file system, file status
13742 @item @emph{Description}:
13743 This function returns information about a file. No permissions are required on
13744 the file itself, but execute (search) permission is required on all of the
13745 directories in path that lead to the file.
13747 The elements that are obtained and stored in the array @code{VALUES}:
13748 @multitable @columnfractions .15 .70
13749 @item @code{VALUES(1)} @tab Device ID
13750 @item @code{VALUES(2)} @tab Inode number
13751 @item @code{VALUES(3)} @tab File mode
13752 @item @code{VALUES(4)} @tab Number of links
13753 @item @code{VALUES(5)} @tab Owner's uid
13754 @item @code{VALUES(6)} @tab Owner's gid
13755 @item @code{VALUES(7)} @tab ID of device containing directory entry for file (0 if not available)
13756 @item @code{VALUES(8)} @tab File size (bytes)
13757 @item @code{VALUES(9)} @tab Last access time
13758 @item @code{VALUES(10)} @tab Last modification time
13759 @item @code{VALUES(11)} @tab Last file status change time
13760 @item @code{VALUES(12)} @tab Preferred I/O block size (-1 if not available)
13761 @item @code{VALUES(13)} @tab Number of blocks allocated (-1 if not available)
13764 Not all these elements are relevant on all systems.
13765 If an element is not relevant, it is returned as 0.
13767 This intrinsic is provided in both subroutine and function forms; however,
13768 only one form can be used in any given program unit.
13770 @item @emph{Standard}:
13773 @item @emph{Class}:
13774 Subroutine, function
13776 @item @emph{Syntax}:
13777 @multitable @columnfractions .80
13778 @item @code{CALL STAT(NAME, VALUES [, STATUS])}
13779 @item @code{STATUS = STAT(NAME, VALUES)}
13782 @item @emph{Arguments}:
13783 @multitable @columnfractions .15 .70
13784 @item @var{NAME} @tab The type shall be @code{CHARACTER}, of the
13785 default kind and a valid path within the file system.
13786 @item @var{VALUES} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
13787 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0
13788 on success and a system specific error code otherwise.
13791 @item @emph{Example}:
13794 INTEGER, DIMENSION(13) :: buff
13797 CALL STAT("/etc/passwd", buff, status)
13799 IF (status == 0) THEN
13800 WRITE (*, FMT="('Device ID:', T30, I19)") buff(1)
13801 WRITE (*, FMT="('Inode number:', T30, I19)") buff(2)
13802 WRITE (*, FMT="('File mode (octal):', T30, O19)") buff(3)
13803 WRITE (*, FMT="('Number of links:', T30, I19)") buff(4)
13804 WRITE (*, FMT="('Owner''s uid:', T30, I19)") buff(5)
13805 WRITE (*, FMT="('Owner''s gid:', T30, I19)") buff(6)
13806 WRITE (*, FMT="('Device where located:', T30, I19)") buff(7)
13807 WRITE (*, FMT="('File size:', T30, I19)") buff(8)
13808 WRITE (*, FMT="('Last access time:', T30, A19)") CTIME(buff(9))
13809 WRITE (*, FMT="('Last modification time', T30, A19)") CTIME(buff(10))
13810 WRITE (*, FMT="('Last status change time:', T30, A19)") CTIME(buff(11))
13811 WRITE (*, FMT="('Preferred block size:', T30, I19)") buff(12)
13812 WRITE (*, FMT="('No. of blocks allocated:', T30, I19)") buff(13)
13817 @item @emph{See also}:
13818 To stat an open file: @*
13827 @section @code{STORAGE_SIZE} --- Storage size in bits
13828 @fnindex STORAGE_SIZE
13829 @cindex storage size
13832 @item @emph{Description}:
13833 Returns the storage size of argument @var{A} in bits.
13834 @item @emph{Standard}:
13835 Fortran 2008 and later
13836 @item @emph{Class}:
13838 @item @emph{Syntax}:
13839 @code{RESULT = STORAGE_SIZE(A [, KIND])}
13841 @item @emph{Arguments}:
13842 @multitable @columnfractions .15 .70
13843 @item @var{A} @tab Shall be a scalar or array of any type.
13844 @item @var{KIND} @tab (Optional) shall be a scalar integer constant expression.
13847 @item @emph{Return Value}:
13848 The result is a scalar integer with the kind type parameter specified by KIND
13849 (or default integer type if KIND is missing). The result value is the size
13850 expressed in bits for an element of an array that has the dynamic type and type
13853 @item @emph{See also}:
13861 @section @code{SUM} --- Sum of array elements
13864 @cindex array, add elements
13865 @cindex array, conditionally add elements
13866 @cindex sum array elements
13869 @item @emph{Description}:
13870 Adds the elements of @var{ARRAY} along dimension @var{DIM} if
13871 the corresponding element in @var{MASK} is @code{TRUE}.
13873 @item @emph{Standard}:
13874 Fortran 90 and later
13876 @item @emph{Class}:
13877 Transformational function
13879 @item @emph{Syntax}:
13880 @multitable @columnfractions .80
13881 @item @code{RESULT = SUM(ARRAY[, MASK])}
13882 @item @code{RESULT = SUM(ARRAY, DIM[, MASK])}
13885 @item @emph{Arguments}:
13886 @multitable @columnfractions .15 .70
13887 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER},
13888 @code{REAL} or @code{COMPLEX}.
13889 @item @var{DIM} @tab (Optional) shall be a scalar of type
13890 @code{INTEGER} with a value in the range from 1 to n, where n
13891 equals the rank of @var{ARRAY}.
13892 @item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL}
13893 and either be a scalar or an array of the same shape as @var{ARRAY}.
13896 @item @emph{Return value}:
13897 The result is of the same type as @var{ARRAY}.
13899 If @var{DIM} is absent, a scalar with the sum of all elements in @var{ARRAY}
13900 is returned. Otherwise, an array of rank n-1, where n equals the rank of
13901 @var{ARRAY}, and a shape similar to that of @var{ARRAY} with dimension @var{DIM}
13902 dropped is returned.
13904 @item @emph{Example}:
13907 INTEGER :: x(5) = (/ 1, 2, 3, 4 ,5 /)
13908 print *, SUM(x) ! all elements, sum = 15
13909 print *, SUM(x, MASK=MOD(x, 2)==1) ! odd elements, sum = 9
13913 @item @emph{See also}:
13920 @section @code{SYMLNK} --- Create a symbolic link
13922 @cindex file system, create link
13923 @cindex file system, soft link
13926 @item @emph{Description}:
13927 Makes a symbolic link from file @var{PATH1} to @var{PATH2}. A null
13928 character (@code{CHAR(0)}) can be used to mark the end of the names in
13929 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
13930 names are ignored. If the @var{STATUS} argument is supplied, it
13931 contains 0 on success or a nonzero error code upon return; see
13932 @code{symlink(2)}. If the system does not supply @code{symlink(2)},
13933 @code{ENOSYS} is returned.
13935 This intrinsic is provided in both subroutine and function forms;
13936 however, only one form can be used in any given program unit.
13938 @item @emph{Standard}:
13941 @item @emph{Class}:
13942 Subroutine, function
13944 @item @emph{Syntax}:
13945 @multitable @columnfractions .80
13946 @item @code{CALL SYMLNK(PATH1, PATH2 [, STATUS])}
13947 @item @code{STATUS = SYMLNK(PATH1, PATH2)}
13950 @item @emph{Arguments}:
13951 @multitable @columnfractions .15 .70
13952 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
13953 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
13954 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
13957 @item @emph{See also}:
13965 @section @code{SYSTEM} --- Execute a shell command
13967 @cindex system, system call
13970 @item @emph{Description}:
13971 Passes the command @var{COMMAND} to a shell (see @code{system(3)}). If
13972 argument @var{STATUS} is present, it contains the value returned by
13973 @code{system(3)}, which is presumably 0 if the shell command succeeded.
13974 Note that which shell is used to invoke the command is system-dependent
13975 and environment-dependent.
13977 This intrinsic is provided in both subroutine and function forms;
13978 however, only one form can be used in any given program unit.
13980 Note that the @code{system} function need not be thread-safe. It is
13981 the responsibility of the user to ensure that @code{system} is not
13982 called concurrently.
13984 @item @emph{Standard}:
13987 @item @emph{Class}:
13988 Subroutine, function
13990 @item @emph{Syntax}:
13991 @multitable @columnfractions .80
13992 @item @code{CALL SYSTEM(COMMAND [, STATUS])}
13993 @item @code{STATUS = SYSTEM(COMMAND)}
13996 @item @emph{Arguments}:
13997 @multitable @columnfractions .15 .70
13998 @item @var{COMMAND} @tab Shall be of default @code{CHARACTER} type.
13999 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
14002 @item @emph{See also}:
14003 @ref{EXECUTE_COMMAND_LINE}, which is part of the Fortran 2008 standard
14004 and should considered in new code for future portability.
14010 @section @code{SYSTEM_CLOCK} --- Time function
14011 @fnindex SYSTEM_CLOCK
14012 @cindex time, clock ticks
14013 @cindex clock ticks
14016 @item @emph{Description}:
14017 Determines the @var{COUNT} of a processor clock since an unspecified
14018 time in the past modulo @var{COUNT_MAX}, @var{COUNT_RATE} determines
14019 the number of clock ticks per second. If the platform supports a
14020 monotonic clock, that clock is used and can, depending on the platform
14021 clock implementation, provide up to nanosecond resolution. If a
14022 monotonic clock is not available, the implementation falls back to a
14025 @var{COUNT_RATE} is system dependent and can vary depending on the kind of
14026 the arguments. For @var{kind=4} arguments (and smaller integer kinds),
14027 @var{COUNT} represents milliseconds, while for @var{kind=8} arguments (and
14028 larger integer kinds), @var{COUNT} typically represents micro- or
14029 nanoseconds depending on resolution of the underlying platform clock.
14030 @var{COUNT_MAX} usually equals @code{HUGE(COUNT_MAX)}. Note that the
14031 millisecond resolution of the @var{kind=4} version implies that the
14032 @var{COUNT} will wrap around in roughly 25 days. In order to avoid issues
14033 with the wrap around and for more precise timing, please use the
14034 @var{kind=8} version.
14036 If there is no clock, or querying the clock fails, @var{COUNT} is set
14037 to @code{-HUGE(COUNT)}, and @var{COUNT_RATE} and @var{COUNT_MAX} are
14040 When running on a platform using the GNU C library (glibc) version
14041 2.16 or older, or a derivative thereof, the high resolution monotonic
14042 clock is available only when linking with the @var{rt} library. This
14043 can be done explicitly by adding the @code{-lrt} flag when linking the
14044 application, but is also done implicitly when using OpenMP.
14046 On the Windows platform, the version with @var{kind=4} arguments uses
14047 the @code{GetTickCount} function, whereas the @var{kind=8} version
14048 uses @code{QueryPerformanceCounter} and
14049 @code{QueryPerformanceCounterFrequency}. For more information, and
14050 potential caveats, please see the platform documentation.
14052 @item @emph{Standard}:
14053 Fortran 90 and later
14055 @item @emph{Class}:
14058 @item @emph{Syntax}:
14059 @code{CALL SYSTEM_CLOCK([COUNT, COUNT_RATE, COUNT_MAX])}
14061 @item @emph{Arguments}:
14062 @multitable @columnfractions .20 .65
14063 @item @var{COUNT} @tab (Optional) shall be a scalar of type
14064 @code{INTEGER} with @code{INTENT(OUT)}.
14065 @item @var{COUNT_RATE} @tab (Optional) shall be a scalar of type
14066 @code{INTEGER} or @code{REAL}, with @code{INTENT(OUT)}.
14067 @item @var{COUNT_MAX} @tab (Optional) shall be a scalar of type
14068 @code{INTEGER} with @code{INTENT(OUT)}.
14071 @item @emph{Example}:
14073 PROGRAM test_system_clock
14074 INTEGER :: count, count_rate, count_max
14075 CALL SYSTEM_CLOCK(count, count_rate, count_max)
14076 WRITE(*,*) count, count_rate, count_max
14080 @item @emph{See also}:
14081 @ref{DATE_AND_TIME}, @*
14088 @section @code{TAN} --- Tangent function
14091 @cindex trigonometric function, tangent
14095 @item @emph{Description}:
14096 @code{TAN(X)} computes the tangent of @var{X}.
14098 @item @emph{Standard}:
14099 Fortran 77 and later, for a complex argument Fortran 2008 or later
14101 @item @emph{Class}:
14104 @item @emph{Syntax}:
14105 @code{RESULT = TAN(X)}
14107 @item @emph{Arguments}:
14108 @multitable @columnfractions .15 .70
14109 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
14112 @item @emph{Return value}:
14113 The return value has same type and kind as @var{X}, and its value is in radians.
14115 @item @emph{Example}:
14118 real(8) :: x = 0.165_8
14120 end program test_tan
14123 @item @emph{Specific names}:
14124 @multitable @columnfractions .20 .23 .20 .33
14125 @headitem Name @tab Argument @tab Return type @tab Standard
14126 @item @code{TAN(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later
14127 @item @code{DTAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
14130 @item @emph{See also}:
14131 Inverse function: @*
14133 Degrees function: @*
14140 @section @code{TAND} --- Tangent function, degrees
14143 @cindex trigonometric function, tangent, degrees
14144 @cindex tangent, degrees
14147 @item @emph{Description}:
14148 @code{TAND(X)} computes the tangent of @var{X} in degrees.
14150 This function is for compatibility only and should be avoided in favor of
14151 standard constructs wherever possible.
14153 @item @emph{Standard}:
14154 GNU extension, enabled with @option{-fdec-math}.
14156 @item @emph{Class}:
14159 @item @emph{Syntax}:
14160 @code{RESULT = TAND(X)}
14162 @item @emph{Arguments}:
14163 @multitable @columnfractions .15 .70
14164 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
14167 @item @emph{Return value}:
14168 The return value has same type and kind as @var{X}, and its value is in degrees.
14170 @item @emph{Example}:
14173 real(8) :: x = 0.165_8
14175 end program test_tand
14178 @item @emph{Specific names}:
14179 @multitable @columnfractions .20 .23 .20 .33
14180 @headitem Name @tab Argument @tab Return type @tab Standard
14181 @item @code{TAND(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU extension
14182 @item @code{DTAND(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
14185 @item @emph{See also}:
14186 Inverse function: @*
14188 Radians function: @*
14195 @section @code{TANH} --- Hyperbolic tangent function
14198 @cindex hyperbolic tangent
14199 @cindex hyperbolic function, tangent
14200 @cindex tangent, hyperbolic
14203 @item @emph{Description}:
14204 @code{TANH(X)} computes the hyperbolic tangent of @var{X}.
14206 @item @emph{Standard}:
14207 Fortran 77 and later, for a complex argument Fortran 2008 or later
14209 @item @emph{Class}:
14212 @item @emph{Syntax}:
14215 @item @emph{Arguments}:
14216 @multitable @columnfractions .15 .70
14217 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
14220 @item @emph{Return value}:
14221 The return value has same type and kind as @var{X}. If @var{X} is
14222 complex, the imaginary part of the result is in radians. If @var{X}
14223 is @code{REAL}, the return value lies in the range
14224 @math{ - 1 \leq tanh(x) \leq 1 }.
14226 @item @emph{Example}:
14229 real(8) :: x = 2.1_8
14231 end program test_tanh
14234 @item @emph{Specific names}:
14235 @multitable @columnfractions .20 .23 .20 .33
14236 @headitem Name @tab Argument @tab Return type @tab Standard
14237 @item @code{TANH(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later
14238 @item @code{DTANH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
14241 @item @emph{See also}:
14248 @section @code{THIS_IMAGE} --- Function that returns the cosubscript index of this image
14249 @fnindex THIS_IMAGE
14250 @cindex coarray, @code{THIS_IMAGE}
14251 @cindex images, index of this image
14254 @item @emph{Description}:
14255 Returns the cosubscript for this image.
14257 @item @emph{Standard}:
14258 Fortran 2008 and later. With @var{DISTANCE} argument,
14259 Technical Specification (TS) 18508 or later
14261 @item @emph{Class}:
14262 Transformational function
14264 @item @emph{Syntax}:
14265 @multitable @columnfractions .80
14266 @item @code{RESULT = THIS_IMAGE()}
14267 @item @code{RESULT = THIS_IMAGE(DISTANCE)}
14268 @item @code{RESULT = THIS_IMAGE(COARRAY [, DIM])}
14271 @item @emph{Arguments}:
14272 @multitable @columnfractions .15 .70
14273 @item @var{DISTANCE} @tab (optional, intent(in)) Nonnegative scalar integer
14274 (not permitted together with @var{COARRAY}).
14275 @item @var{COARRAY} @tab Coarray of any type (optional; if @var{DIM}
14276 present, required).
14277 @item @var{DIM} @tab default integer scalar (optional). If present,
14278 @var{DIM} shall be between one and the corank of @var{COARRAY}.
14282 @item @emph{Return value}:
14283 Default integer. If @var{COARRAY} is not present, it is scalar; if
14284 @var{DISTANCE} is not present or has value 0, its value is the image index on
14285 the invoking image for the current team, for values smaller or equal
14286 distance to the initial team, it returns the image index on the ancestor team
14287 which has a distance of @var{DISTANCE} from the invoking team. If
14288 @var{DISTANCE} is larger than the distance to the initial team, the image
14289 index of the initial team is returned. Otherwise when the @var{COARRAY} is
14290 present, if @var{DIM} is not present, a rank-1 array with corank elements is
14291 returned, containing the cosubscripts for @var{COARRAY} specifying the invoking
14292 image. If @var{DIM} is present, a scalar is returned, with the value of
14293 the @var{DIM} element of @code{THIS_IMAGE(COARRAY)}.
14295 @item @emph{Example}:
14297 INTEGER :: value[*]
14299 value = THIS_IMAGE()
14301 IF (THIS_IMAGE() == 1) THEN
14302 DO i = 1, NUM_IMAGES()
14303 WRITE(*,'(2(a,i0))') 'value[', i, '] is ', value[i]
14307 ! Check whether the current image is the initial image
14308 IF (THIS_IMAGE(HUGE(1)) /= THIS_IMAGE())
14309 error stop "something is rotten here"
14312 @item @emph{See also}:
14313 @ref{NUM_IMAGES}, @*
14320 @section @code{TIME} --- Time function
14322 @cindex time, current
14323 @cindex current time
14326 @item @emph{Description}:
14327 Returns the current time encoded as an integer (in the manner of the
14328 function @code{time(3)} in the C standard library). This value is
14329 suitable for passing to @ref{CTIME}, @ref{GMTIME}, and @ref{LTIME}.
14331 This intrinsic is not fully portable, such as to systems with 32-bit
14332 @code{INTEGER} types but supporting times wider than 32 bits. Therefore,
14333 the values returned by this intrinsic might be, or become, negative, or
14334 numerically less than previous values, during a single run of the
14337 See @ref{TIME8}, for information on a similar intrinsic that might be
14338 portable to more GNU Fortran implementations, though to fewer Fortran
14341 @item @emph{Standard}:
14344 @item @emph{Class}:
14347 @item @emph{Syntax}:
14348 @code{RESULT = TIME()}
14350 @item @emph{Return value}:
14351 The return value is a scalar of type @code{INTEGER(4)}.
14353 @item @emph{See also}:
14354 @ref{DATE_AND_TIME}, @*
14365 @section @code{TIME8} --- Time function (64-bit)
14367 @cindex time, current
14368 @cindex current time
14371 @item @emph{Description}:
14372 Returns the current time encoded as an integer (in the manner of the
14373 function @code{time(3)} in the C standard library). This value is
14374 suitable for passing to @ref{CTIME}, @ref{GMTIME}, and @ref{LTIME}.
14376 @emph{Warning:} this intrinsic does not increase the range of the timing
14377 values over that returned by @code{time(3)}. On a system with a 32-bit
14378 @code{time(3)}, @code{TIME8} will return a 32-bit value, even though
14379 it is converted to a 64-bit @code{INTEGER(8)} value. That means
14380 overflows of the 32-bit value can still occur. Therefore, the values
14381 returned by this intrinsic might be or become negative or numerically
14382 less than previous values during a single run of the compiled program.
14384 @item @emph{Standard}:
14387 @item @emph{Class}:
14390 @item @emph{Syntax}:
14391 @code{RESULT = TIME8()}
14393 @item @emph{Return value}:
14394 The return value is a scalar of type @code{INTEGER(8)}.
14396 @item @emph{See also}:
14397 @ref{DATE_AND_TIME}, @*
14408 @section @code{TINY} --- Smallest positive number of a real kind
14410 @cindex limits, smallest number
14411 @cindex model representation, smallest number
14414 @item @emph{Description}:
14415 @code{TINY(X)} returns the smallest positive (non zero) number
14416 in the model of the type of @code{X}.
14418 @item @emph{Standard}:
14419 Fortran 90 and later
14421 @item @emph{Class}:
14424 @item @emph{Syntax}:
14425 @code{RESULT = TINY(X)}
14427 @item @emph{Arguments}:
14428 @multitable @columnfractions .15 .70
14429 @item @var{X} @tab Shall be of type @code{REAL}.
14432 @item @emph{Return value}:
14433 The return value is of the same type and kind as @var{X}
14435 @item @emph{Example}:
14436 See @code{HUGE} for an example.
14442 @section @code{TRAILZ} --- Number of trailing zero bits of an integer
14447 @item @emph{Description}:
14448 @code{TRAILZ} returns the number of trailing zero bits of an integer.
14450 @item @emph{Standard}:
14451 Fortran 2008 and later
14453 @item @emph{Class}:
14456 @item @emph{Syntax}:
14457 @code{RESULT = TRAILZ(I)}
14459 @item @emph{Arguments}:
14460 @multitable @columnfractions .15 .70
14461 @item @var{I} @tab Shall be of type @code{INTEGER}.
14464 @item @emph{Return value}:
14465 The type of the return value is the default @code{INTEGER}.
14466 If all the bits of @code{I} are zero, the result value is @code{BIT_SIZE(I)}.
14468 @item @emph{Example}:
14470 PROGRAM test_trailz
14471 WRITE (*,*) TRAILZ(8) ! prints 3
14475 @item @emph{See also}:
14485 @section @code{TRANSFER} --- Transfer bit patterns
14491 @item @emph{Description}:
14492 Interprets the bitwise representation of @var{SOURCE} in memory as if it
14493 is the representation of a variable or array of the same type and type
14494 parameters as @var{MOLD}.
14496 This is approximately equivalent to the C concept of @emph{casting} one
14499 @item @emph{Standard}:
14500 Fortran 90 and later
14502 @item @emph{Class}:
14503 Transformational function
14505 @item @emph{Syntax}:
14506 @code{RESULT = TRANSFER(SOURCE, MOLD[, SIZE])}
14508 @item @emph{Arguments}:
14509 @multitable @columnfractions .15 .70
14510 @item @var{SOURCE} @tab Shall be a scalar or an array of any type.
14511 @item @var{MOLD} @tab Shall be a scalar or an array of any type.
14512 @item @var{SIZE} @tab (Optional) shall be a scalar of type
14516 @item @emph{Return value}:
14517 The result has the same type as @var{MOLD}, with the bit level
14518 representation of @var{SOURCE}. If @var{SIZE} is present, the result is
14519 a one-dimensional array of length @var{SIZE}. If @var{SIZE} is absent
14520 but @var{MOLD} is an array (of any size or shape), the result is a one-
14521 dimensional array of the minimum length needed to contain the entirety
14522 of the bitwise representation of @var{SOURCE}. If @var{SIZE} is absent
14523 and @var{MOLD} is a scalar, the result is a scalar.
14525 If the bitwise representation of the result is longer than that of
14526 @var{SOURCE}, then the leading bits of the result correspond to those of
14527 @var{SOURCE} and any trailing bits are filled arbitrarily.
14529 When the resulting bit representation does not correspond to a valid
14530 representation of a variable of the same type as @var{MOLD}, the results
14531 are undefined, and subsequent operations on the result cannot be
14532 guaranteed to produce sensible behavior. For example, it is possible to
14533 create @code{LOGICAL} variables for which @code{@var{VAR}} and
14534 @code{.NOT.@var{VAR}} both appear to be true.
14536 @item @emph{Example}:
14538 PROGRAM test_transfer
14539 integer :: x = 2143289344
14540 print *, transfer(x, 1.0) ! prints "NaN" on i686
14548 @section @code{TRANSPOSE} --- Transpose an array of rank two
14550 @cindex array, transpose
14551 @cindex matrix, transpose
14555 @item @emph{Description}:
14556 Transpose an array of rank two. Element (i, j) of the result has the value
14557 @code{MATRIX(j, i)}, for all i, j.
14559 @item @emph{Standard}:
14560 Fortran 90 and later
14562 @item @emph{Class}:
14563 Transformational function
14565 @item @emph{Syntax}:
14566 @code{RESULT = TRANSPOSE(MATRIX)}
14568 @item @emph{Arguments}:
14569 @multitable @columnfractions .15 .70
14570 @item @var{MATRIX} @tab Shall be an array of any type and have a rank of two.
14573 @item @emph{Return value}:
14574 The result has the same type as @var{MATRIX}, and has shape
14575 @code{(/ m, n /)} if @var{MATRIX} has shape @code{(/ n, m /)}.
14581 @section @code{TRIM} --- Remove trailing blank characters of a string
14583 @cindex string, remove trailing whitespace
14586 @item @emph{Description}:
14587 Removes trailing blank characters of a string.
14589 @item @emph{Standard}:
14590 Fortran 90 and later
14592 @item @emph{Class}:
14593 Transformational function
14595 @item @emph{Syntax}:
14596 @code{RESULT = TRIM(STRING)}
14598 @item @emph{Arguments}:
14599 @multitable @columnfractions .15 .70
14600 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER}.
14603 @item @emph{Return value}:
14604 A scalar of type @code{CHARACTER} which length is that of @var{STRING}
14605 less the number of trailing blanks.
14607 @item @emph{Example}:
14610 CHARACTER(len=10), PARAMETER :: s = "GFORTRAN "
14611 WRITE(*,*) LEN(s), LEN(TRIM(s)) ! "10 8", with/without trailing blanks
14615 @item @emph{See also}:
14623 @section @code{TTYNAM} --- Get the name of a terminal device
14625 @cindex system, terminal
14628 @item @emph{Description}:
14629 Get the name of a terminal device. For more information,
14630 see @code{ttyname(3)}.
14632 This intrinsic is provided in both subroutine and function forms;
14633 however, only one form can be used in any given program unit.
14635 @item @emph{Standard}:
14638 @item @emph{Class}:
14639 Subroutine, function
14641 @item @emph{Syntax}:
14642 @multitable @columnfractions .80
14643 @item @code{CALL TTYNAM(UNIT, NAME)}
14644 @item @code{NAME = TTYNAM(UNIT)}
14647 @item @emph{Arguments}:
14648 @multitable @columnfractions .15 .70
14649 @item @var{UNIT} @tab Shall be a scalar @code{INTEGER}.
14650 @item @var{NAME} @tab Shall be of type @code{CHARACTER}.
14653 @item @emph{Example}:
14655 PROGRAM test_ttynam
14658 IF (isatty(unit=unit)) write(*,*) ttynam(unit)
14663 @item @emph{See also}:
14670 @section @code{UBOUND} --- Upper dimension bounds of an array
14672 @cindex array, upper bound
14675 @item @emph{Description}:
14676 Returns the upper bounds of an array, or a single upper bound
14677 along the @var{DIM} dimension.
14678 @item @emph{Standard}:
14679 Fortran 90 and later, with @var{KIND} argument Fortran 2003 and later
14681 @item @emph{Class}:
14684 @item @emph{Syntax}:
14685 @code{RESULT = UBOUND(ARRAY [, DIM [, KIND]])}
14687 @item @emph{Arguments}:
14688 @multitable @columnfractions .15 .70
14689 @item @var{ARRAY} @tab Shall be an array, of any type.
14690 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
14691 @item @var{KIND} @tab (Optional) A scalar @code{INTEGER} constant
14692 expression indicating the kind parameter of the result.
14695 @item @emph{Return value}:
14696 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
14697 @var{KIND} is absent, the return value is of default integer kind.
14698 If @var{DIM} is absent, the result is an array of the upper bounds of
14699 @var{ARRAY}. If @var{DIM} is present, the result is a scalar
14700 corresponding to the upper bound of the array along that dimension. If
14701 @var{ARRAY} is an expression rather than a whole array or array
14702 structure component, or if it has a zero extent along the relevant
14703 dimension, the upper bound is taken to be the number of elements along
14704 the relevant dimension.
14706 @item @emph{See also}:
14714 @section @code{UCOBOUND} --- Upper codimension bounds of an array
14716 @cindex coarray, upper bound
14719 @item @emph{Description}:
14720 Returns the upper cobounds of a coarray, or a single upper cobound
14721 along the @var{DIM} codimension.
14722 @item @emph{Standard}:
14723 Fortran 2008 and later
14725 @item @emph{Class}:
14728 @item @emph{Syntax}:
14729 @code{RESULT = UCOBOUND(COARRAY [, DIM [, KIND]])}
14731 @item @emph{Arguments}:
14732 @multitable @columnfractions .15 .70
14733 @item @var{ARRAY} @tab Shall be an coarray, of any type.
14734 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
14735 @item @var{KIND} @tab (Optional) A scalar @code{INTEGER} constant
14736 expression indicating the kind parameter of the result.
14739 @item @emph{Return value}:
14740 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
14741 @var{KIND} is absent, the return value is of default integer kind.
14742 If @var{DIM} is absent, the result is an array of the lower cobounds of
14743 @var{COARRAY}. If @var{DIM} is present, the result is a scalar
14744 corresponding to the lower cobound of the array along that codimension.
14746 @item @emph{See also}:
14754 @section @code{UMASK} --- Set the file creation mask
14756 @cindex file system, file creation mask
14759 @item @emph{Description}:
14760 Sets the file creation mask to @var{MASK}. If called as a function, it
14761 returns the old value. If called as a subroutine and argument @var{OLD}
14762 if it is supplied, it is set to the old value. See @code{umask(2)}.
14764 @item @emph{Standard}:
14767 @item @emph{Class}:
14768 Subroutine, function
14770 @item @emph{Syntax}:
14771 @multitable @columnfractions .80
14772 @item @code{CALL UMASK(MASK [, OLD])}
14773 @item @code{OLD = UMASK(MASK)}
14776 @item @emph{Arguments}:
14777 @multitable @columnfractions .15 .70
14778 @item @var{MASK} @tab Shall be a scalar of type @code{INTEGER}.
14779 @item @var{OLD} @tab (Optional) Shall be a scalar of type
14788 @section @code{UNLINK} --- Remove a file from the file system
14790 @cindex file system, remove file
14793 @item @emph{Description}:
14794 Unlinks the file @var{PATH}. A null character (@code{CHAR(0)}) can be
14795 used to mark the end of the name in @var{PATH}; otherwise, trailing
14796 blanks in the file name are ignored. If the @var{STATUS} argument is
14797 supplied, it contains 0 on success or a nonzero error code upon return;
14798 see @code{unlink(2)}.
14800 This intrinsic is provided in both subroutine and function forms;
14801 however, only one form can be used in any given program unit.
14803 @item @emph{Standard}:
14806 @item @emph{Class}:
14807 Subroutine, function
14809 @item @emph{Syntax}:
14810 @multitable @columnfractions .80
14811 @item @code{CALL UNLINK(PATH [, STATUS])}
14812 @item @code{STATUS = UNLINK(PATH)}
14815 @item @emph{Arguments}:
14816 @multitable @columnfractions .15 .70
14817 @item @var{PATH} @tab Shall be of default @code{CHARACTER} type.
14818 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
14821 @item @emph{See also}:
14829 @section @code{UNPACK} --- Unpack an array of rank one into an array
14831 @cindex array, unpacking
14832 @cindex array, increase dimension
14833 @cindex array, scatter elements
14836 @item @emph{Description}:
14837 Store the elements of @var{VECTOR} in an array of higher rank.
14839 @item @emph{Standard}:
14840 Fortran 90 and later
14842 @item @emph{Class}:
14843 Transformational function
14845 @item @emph{Syntax}:
14846 @code{RESULT = UNPACK(VECTOR, MASK, FIELD)}
14848 @item @emph{Arguments}:
14849 @multitable @columnfractions .15 .70
14850 @item @var{VECTOR} @tab Shall be an array of any type and rank one. It
14851 shall have at least as many elements as @var{MASK} has @code{TRUE} values.
14852 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL}.
14853 @item @var{FIELD} @tab Shall be of the same type as @var{VECTOR} and have
14854 the same shape as @var{MASK}.
14857 @item @emph{Return value}:
14858 The resulting array corresponds to @var{FIELD} with @code{TRUE} elements
14859 of @var{MASK} replaced by values from @var{VECTOR} in array element order.
14861 @item @emph{Example}:
14863 PROGRAM test_unpack
14864 integer :: vector(2) = (/1,1/)
14865 logical :: mask(4) = (/ .TRUE., .FALSE., .FALSE., .TRUE. /)
14866 integer :: field(2,2) = 0, unity(2,2)
14868 ! result: unity matrix
14869 unity = unpack(vector, reshape(mask, (/2,2/)), field)
14873 @item @emph{See also}:
14881 @section @code{VERIFY} --- Scan a string for characters not a given set
14883 @cindex string, find missing set
14886 @item @emph{Description}:
14887 Verifies that all the characters in @var{STRING} belong to the set of
14888 characters in @var{SET}.
14890 If @var{BACK} is either absent or equals @code{FALSE}, this function
14891 returns the position of the leftmost character of @var{STRING} that is
14892 not in @var{SET}. If @var{BACK} equals @code{TRUE}, the rightmost
14893 position is returned. If all characters of @var{STRING} are found in
14894 @var{SET}, the result is zero.
14896 @item @emph{Standard}:
14897 Fortran 90 and later, with @var{KIND} argument Fortran 2003 and later
14899 @item @emph{Class}:
14902 @item @emph{Syntax}:
14903 @code{RESULT = VERIFY(STRING, SET[, BACK [, KIND]])}
14905 @item @emph{Arguments}:
14906 @multitable @columnfractions .15 .70
14907 @item @var{STRING} @tab Shall be of type @code{CHARACTER}.
14908 @item @var{SET} @tab Shall be of type @code{CHARACTER}.
14909 @item @var{BACK} @tab (Optional) shall be of type @code{LOGICAL}.
14910 @item @var{KIND} @tab (Optional) A scalar @code{INTEGER} constant
14911 expression indicating the kind parameter of the result.
14914 @item @emph{Return value}:
14915 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
14916 @var{KIND} is absent, the return value is of default integer kind.
14918 @item @emph{Example}:
14920 PROGRAM test_verify
14921 WRITE(*,*) VERIFY("FORTRAN", "AO") ! 1, found 'F'
14922 WRITE(*,*) VERIFY("FORTRAN", "FOO") ! 3, found 'R'
14923 WRITE(*,*) VERIFY("FORTRAN", "C++") ! 1, found 'F'
14924 WRITE(*,*) VERIFY("FORTRAN", "C++", .TRUE.) ! 7, found 'N'
14925 WRITE(*,*) VERIFY("FORTRAN", "FORTRAN") ! 0' found none
14929 @item @emph{See also}:
14931 @ref{INDEX intrinsic}
14937 @section @code{XOR} --- Bitwise logical exclusive OR
14939 @cindex bitwise logical exclusive or
14940 @cindex logical exclusive or, bitwise
14943 @item @emph{Description}:
14944 Bitwise logical exclusive or.
14946 This intrinsic routine is provided for backwards compatibility with
14947 GNU Fortran 77. For integer arguments, programmers should consider
14948 the use of the @ref{IEOR} intrinsic and for logical arguments the
14949 @code{.NEQV.} operator, which are both defined by the Fortran standard.
14951 @item @emph{Standard}:
14954 @item @emph{Class}:
14957 @item @emph{Syntax}:
14958 @code{RESULT = XOR(I, J)}
14960 @item @emph{Arguments}:
14961 @multitable @columnfractions .15 .70
14962 @item @var{I} @tab The type shall be either a scalar @code{INTEGER}
14963 type or a scalar @code{LOGICAL} type or a boz-literal-constant.
14964 @item @var{J} @tab The type shall be the same as the type of @var{I} or
14965 a boz-literal-constant. @var{I} and @var{J} shall not both be
14966 boz-literal-constants. If either @var{I} and @var{J} is a
14967 boz-literal-constant, then the other argument must be a scalar @code{INTEGER}.
14970 @item @emph{Return value}:
14971 The return type is either a scalar @code{INTEGER} or a scalar
14972 @code{LOGICAL}. If the kind type parameters differ, then the
14973 smaller kind type is implicitly converted to larger kind, and the
14974 return has the larger kind. A boz-literal-constant is
14975 converted to an @code{INTEGER} with the kind type parameter of
14976 the other argument as-if a call to @ref{INT} occurred.
14978 @item @emph{Example}:
14981 LOGICAL :: T = .TRUE., F = .FALSE.
14983 DATA a / Z'F' /, b / Z'3' /
14985 WRITE (*,*) XOR(T, T), XOR(T, F), XOR(F, T), XOR(F, F)
14986 WRITE (*,*) XOR(a, b)
14990 @item @emph{See also}:
14991 Fortran 95 elemental function: @*
14997 @node Intrinsic Modules
14998 @chapter Intrinsic Modules
14999 @cindex intrinsic Modules
15002 * ISO_FORTRAN_ENV::
15005 * OpenMP Modules OMP_LIB and OMP_LIB_KINDS::
15006 * OpenACC Module OPENACC::
15009 @node ISO_FORTRAN_ENV
15010 @section @code{ISO_FORTRAN_ENV}
15012 @item @emph{Standard}:
15013 Fortran 2003 and later, except when otherwise noted
15016 The @code{ISO_FORTRAN_ENV} module provides the following scalar default-integer
15020 @item @code{ATOMIC_INT_KIND}:
15021 Default-kind integer constant to be used as kind parameter when defining
15022 integer variables used in atomic operations. (Fortran 2008 or later.)
15024 @item @code{ATOMIC_LOGICAL_KIND}:
15025 Default-kind integer constant to be used as kind parameter when defining
15026 logical variables used in atomic operations. (Fortran 2008 or later.)
15028 @item @code{CHARACTER_KINDS}:
15029 Default-kind integer constant array of rank one containing the supported kind
15030 parameters of the @code{CHARACTER} type. (Fortran 2008 or later.)
15032 @item @code{CHARACTER_STORAGE_SIZE}:
15033 Size in bits of the character storage unit.
15035 @item @code{ERROR_UNIT}:
15036 Identifies the preconnected unit used for error reporting.
15038 @item @code{FILE_STORAGE_SIZE}:
15039 Size in bits of the file-storage unit.
15041 @item @code{INPUT_UNIT}:
15042 Identifies the preconnected unit identified by the asterisk
15043 (@code{*}) in @code{READ} statement.
15045 @item @code{INT8}, @code{INT16}, @code{INT32}, @code{INT64}:
15046 Kind type parameters to specify an INTEGER type with a storage
15047 size of 16, 32, and 64 bits. It is negative if a target platform
15048 does not support the particular kind. (Fortran 2008 or later.)
15050 @item @code{INTEGER_KINDS}:
15051 Default-kind integer constant array of rank one containing the supported kind
15052 parameters of the @code{INTEGER} type. (Fortran 2008 or later.)
15054 @item @code{IOSTAT_END}:
15055 The value assigned to the variable passed to the @code{IOSTAT=} specifier of
15056 an input/output statement if an end-of-file condition occurred.
15058 @item @code{IOSTAT_EOR}:
15059 The value assigned to the variable passed to the @code{IOSTAT=} specifier of
15060 an input/output statement if an end-of-record condition occurred.
15062 @item @code{IOSTAT_INQUIRE_INTERNAL_UNIT}:
15063 Scalar default-integer constant, used by @code{INQUIRE} for the
15064 @code{IOSTAT=} specifier to denote an that a unit number identifies an
15065 internal unit. (Fortran 2008 or later.)
15067 @item @code{NUMERIC_STORAGE_SIZE}:
15068 The size in bits of the numeric storage unit.
15070 @item @code{LOGICAL_KINDS}:
15071 Default-kind integer constant array of rank one containing the supported kind
15072 parameters of the @code{LOGICAL} type. (Fortran 2008 or later.)
15074 @item @code{OUTPUT_UNIT}:
15075 Identifies the preconnected unit identified by the asterisk
15076 (@code{*}) in @code{WRITE} statement.
15078 @item @code{REAL32}, @code{REAL64}, @code{REAL128}:
15079 Kind type parameters to specify a REAL type with a storage
15080 size of 32, 64, and 128 bits. It is negative if a target platform
15081 does not support the particular kind. (Fortran 2008 or later.)
15083 @item @code{REAL_KINDS}:
15084 Default-kind integer constant array of rank one containing the supported kind
15085 parameters of the @code{REAL} type. (Fortran 2008 or later.)
15087 @item @code{STAT_LOCKED}:
15088 Scalar default-integer constant used as STAT= return value by @code{LOCK} to
15089 denote that the lock variable is locked by the executing image. (Fortran 2008
15092 @item @code{STAT_LOCKED_OTHER_IMAGE}:
15093 Scalar default-integer constant used as STAT= return value by @code{UNLOCK} to
15094 denote that the lock variable is locked by another image. (Fortran 2008 or
15097 @item @code{STAT_STOPPED_IMAGE}:
15098 Positive, scalar default-integer constant used as STAT= return value if the
15099 argument in the statement requires synchronisation with an image, which has
15100 initiated the termination of the execution. (Fortran 2008 or later.)
15102 @item @code{STAT_FAILED_IMAGE}:
15103 Positive, scalar default-integer constant used as STAT= return value if the
15104 argument in the statement requires communication with an image, which has
15105 is in the failed state. (TS 18508 or later.)
15107 @item @code{STAT_UNLOCKED}:
15108 Scalar default-integer constant used as STAT= return value by @code{UNLOCK} to
15109 denote that the lock variable is unlocked. (Fortran 2008 or later.)
15112 The module provides the following derived type:
15115 @item @code{LOCK_TYPE}:
15116 Derived type with private components to be use with the @code{LOCK} and
15117 @code{UNLOCK} statement. A variable of its type has to be always declared
15118 as coarray and may not appear in a variable-definition context.
15119 (Fortran 2008 or later.)
15122 The module also provides the following intrinsic procedures:
15123 @ref{COMPILER_OPTIONS} and @ref{COMPILER_VERSION}.
15127 @node ISO_C_BINDING
15128 @section @code{ISO_C_BINDING}
15130 @item @emph{Standard}:
15131 Fortran 2003 and later, GNU extensions
15134 The following intrinsic procedures are provided by the module; their
15135 definition can be found in the section Intrinsic Procedures of this
15139 @item @code{C_ASSOCIATED}
15140 @item @code{C_F_POINTER}
15141 @item @code{C_F_PROCPOINTER}
15142 @item @code{C_FUNLOC}
15144 @item @code{C_SIZEOF}
15146 @c TODO: Vertical spacing between C_FUNLOC and C_LOC wrong in PDF,
15147 @c don't really know why.
15149 The @code{ISO_C_BINDING} module provides the following named constants of
15150 type default integer, which can be used as KIND type parameters.
15152 In addition to the integer named constants required by the Fortran 2003
15153 standard and @code{C_PTRDIFF_T} of TS 29113, GNU Fortran provides as an
15154 extension named constants for the 128-bit integer types supported by the
15155 C compiler: @code{C_INT128_T, C_INT_LEAST128_T, C_INT_FAST128_T}.
15156 Furthermore, if @code{_Float128} is supported in C, the named constants
15157 @code{C_FLOAT128} and @code{C_FLOAT128_COMPLEX} are defined.
15159 @multitable @columnfractions .19 .32 .34 .15
15160 @headitem Fortran Type @tab Named constant @tab C type @tab Extension
15161 @item @code{INTEGER}@tab @code{C_INT} @tab @code{int}
15162 @item @code{INTEGER}@tab @code{C_SHORT} @tab @code{short int}
15163 @item @code{INTEGER}@tab @code{C_LONG} @tab @code{long int}
15164 @item @code{INTEGER}@tab @code{C_LONG_LONG} @tab @code{long long int}
15165 @item @code{INTEGER}@tab @code{C_SIGNED_CHAR} @tab @code{signed char}/@code{unsigned char}
15166 @item @code{INTEGER}@tab @code{C_SIZE_T} @tab @code{size_t}
15167 @item @code{INTEGER}@tab @code{C_INT8_T} @tab @code{int8_t}
15168 @item @code{INTEGER}@tab @code{C_INT16_T} @tab @code{int16_t}
15169 @item @code{INTEGER}@tab @code{C_INT32_T} @tab @code{int32_t}
15170 @item @code{INTEGER}@tab @code{C_INT64_T} @tab @code{int64_t}
15171 @item @code{INTEGER}@tab @code{C_INT128_T} @tab @code{int128_t} @tab Ext.
15172 @item @code{INTEGER}@tab @code{C_INT_LEAST8_T} @tab @code{int_least8_t}
15173 @item @code{INTEGER}@tab @code{C_INT_LEAST16_T} @tab @code{int_least16_t}
15174 @item @code{INTEGER}@tab @code{C_INT_LEAST32_T} @tab @code{int_least32_t}
15175 @item @code{INTEGER}@tab @code{C_INT_LEAST64_T} @tab @code{int_least64_t}
15176 @item @code{INTEGER}@tab @code{C_INT_LEAST128_T}@tab @code{int_least128_t} @tab Ext.
15177 @item @code{INTEGER}@tab @code{C_INT_FAST8_T} @tab @code{int_fast8_t}
15178 @item @code{INTEGER}@tab @code{C_INT_FAST16_T} @tab @code{int_fast16_t}
15179 @item @code{INTEGER}@tab @code{C_INT_FAST32_T} @tab @code{int_fast32_t}
15180 @item @code{INTEGER}@tab @code{C_INT_FAST64_T} @tab @code{int_fast64_t}
15181 @item @code{INTEGER}@tab @code{C_INT_FAST128_T} @tab @code{int_fast128_t} @tab Ext.
15182 @item @code{INTEGER}@tab @code{C_INTMAX_T} @tab @code{intmax_t}
15183 @item @code{INTEGER}@tab @code{C_INTPTR_T} @tab @code{intptr_t}
15184 @item @code{INTEGER}@tab @code{C_PTRDIFF_T} @tab @code{ptrdiff_t} @tab TS 29113
15185 @item @code{REAL} @tab @code{C_FLOAT} @tab @code{float}
15186 @item @code{REAL} @tab @code{C_DOUBLE} @tab @code{double}
15187 @item @code{REAL} @tab @code{C_LONG_DOUBLE} @tab @code{long double}
15188 @item @code{REAL} @tab @code{C_FLOAT128} @tab @code{_Float128} @tab Ext.
15189 @item @code{COMPLEX}@tab @code{C_FLOAT_COMPLEX} @tab @code{float _Complex}
15190 @item @code{COMPLEX}@tab @code{C_DOUBLE_COMPLEX}@tab @code{double _Complex}
15191 @item @code{COMPLEX}@tab @code{C_LONG_DOUBLE_COMPLEX}@tab @code{long double _Complex}
15192 @item @code{COMPLEX}@tab @code{C_FLOAT128_COMPLEX} @tab @code{_Float128 _Complex} @tab Ext.
15193 @item @code{LOGICAL}@tab @code{C_BOOL} @tab @code{_Bool}
15194 @item @code{CHARACTER}@tab @code{C_CHAR} @tab @code{char}
15197 Additionally, the following parameters of type @code{CHARACTER(KIND=C_CHAR)}
15200 @multitable @columnfractions .20 .45 .15
15201 @headitem Name @tab C definition @tab Value
15202 @item @code{C_NULL_CHAR} @tab null character @tab @code{'\0'}
15203 @item @code{C_ALERT} @tab alert @tab @code{'\a'}
15204 @item @code{C_BACKSPACE} @tab backspace @tab @code{'\b'}
15205 @item @code{C_FORM_FEED} @tab form feed @tab @code{'\f'}
15206 @item @code{C_NEW_LINE} @tab new line @tab @code{'\n'}
15207 @item @code{C_CARRIAGE_RETURN} @tab carriage return @tab @code{'\r'}
15208 @item @code{C_HORIZONTAL_TAB} @tab horizontal tab @tab @code{'\t'}
15209 @item @code{C_VERTICAL_TAB} @tab vertical tab @tab @code{'\v'}
15212 Moreover, the following two named constants are defined:
15214 @multitable @columnfractions .20 .80
15215 @headitem Name @tab Type
15216 @item @code{C_NULL_PTR} @tab @code{C_PTR}
15217 @item @code{C_NULL_FUNPTR} @tab @code{C_FUNPTR}
15220 Both are equivalent to the value @code{NULL} in C.
15225 @section IEEE modules: @code{IEEE_EXCEPTIONS}, @code{IEEE_ARITHMETIC}, and @code{IEEE_FEATURES}
15227 @item @emph{Standard}:
15228 Fortran 2003 and later
15231 The @code{IEEE_EXCEPTIONS}, @code{IEEE_ARITHMETIC}, and @code{IEEE_FEATURES}
15232 intrinsic modules provide support for exceptions and IEEE arithmetic, as
15233 defined in Fortran 2003 and later standards, and the IEC 60559:1989 standard
15234 (@emph{Binary floating-point arithmetic for microprocessor systems}). These
15235 modules are only provided on the following supported platforms:
15238 @item i386 and x86_64 processors
15239 @item platforms which use the GNU C Library (glibc)
15240 @item platforms with support for SysV/386 routines for floating point
15241 interface (including Solaris and BSDs)
15242 @item platforms with the AIX OS
15245 For full compliance with the Fortran standards, code using the
15246 @code{IEEE_EXCEPTIONS} or @code{IEEE_ARITHMETIC} modules should be compiled
15247 with the following options: @code{-fno-unsafe-math-optimizations
15248 -frounding-math -fsignaling-nans}.
15252 @node OpenMP Modules OMP_LIB and OMP_LIB_KINDS
15253 @section OpenMP Modules @code{OMP_LIB} and @code{OMP_LIB_KINDS}
15255 @item @emph{Standard}:
15256 OpenMP Application Program Interface v4.5,
15257 OpenMP Application Program Interface v5.0 (partially supported),
15258 OpenMP Application Program Interface v5.1 (partially supported) and
15259 OpenMP Application Program Interface v5.2 (partially supported).
15262 The OpenMP Fortran runtime library routines are provided both in
15263 a form of two Fortran modules, named @code{OMP_LIB} and
15264 @code{OMP_LIB_KINDS}, and in a form of a Fortran @code{include} file named
15265 @file{omp_lib.h}. The procedures provided by @code{OMP_LIB} can be found
15266 in the @ref{Top,,Introduction,libgomp,GNU Offloading and Multi
15267 Processing Runtime Library} manual,
15268 the named constants defined in the modules are listed
15271 For details refer to the actual
15272 @uref{https://www.openmp.org/wp-content/uploads/openmp-4.5.pdf,
15273 OpenMP Application Program Interface v4.5},
15274 @uref{https://www.openmp.org/wp-content/uploads/OpenMP-API-Specification-5.0.pdf,
15275 OpenMP Application Program Interface v5.0},
15276 @uref{https://www.openmp.org/wp-content/uploads/OpenMP-API-Specification-5-1.pdf,
15277 OpenMP Application Program Interface v5.1} and
15278 @uref{https://www.openmp.org/wp-content/uploads/OpenMP-API-Specification-5-2.pdf,
15279 OpenMP Application Program Interface v5.2}.
15281 @code{OMP_LIB_KINDS} provides the following scalar default-integer
15285 @item @code{omp_allocator_handle_kind}
15286 @item @code{omp_alloctrait_key_kind}
15287 @item @code{omp_alloctrait_val_kind}
15288 @item @code{omp_depend_kind}
15289 @item @code{omp_lock_kind}
15290 @item @code{omp_lock_hint_kind}
15291 @item @code{omp_nest_lock_kind}
15292 @item @code{omp_pause_resource_kind}
15293 @item @code{omp_memspace_handle_kind}
15294 @item @code{omp_proc_bind_kind}
15295 @item @code{omp_sched_kind}
15296 @item @code{omp_sync_hint_kind}
15299 @code{OMP_LIB} provides the scalar default-integer
15300 named constant @code{openmp_version} with a value of the form
15301 @var{yyyymm}, where @code{yyyy} is the year and @var{mm} the month
15302 of the OpenMP version; for OpenMP v4.5 the value is @code{201511}.
15304 The following derived type:
15307 @item @code{omp_alloctrait}
15310 The following scalar default-integer named constants:
15312 @item @code{omp_initial_device}
15313 @item @code{omp_invalid_device}
15317 The following scalar integer named constants of the
15318 kind @code{omp_sched_kind}:
15321 @item @code{omp_sched_static}
15322 @item @code{omp_sched_dynamic}
15323 @item @code{omp_sched_guided}
15324 @item @code{omp_sched_auto}
15327 And the following scalar integer named constants of the
15328 kind @code{omp_proc_bind_kind}:
15331 @item @code{omp_proc_bind_false}
15332 @item @code{omp_proc_bind_true}
15333 @item @code{omp_proc_bind_primary}
15334 @item @code{omp_proc_bind_master}
15335 @item @code{omp_proc_bind_close}
15336 @item @code{omp_proc_bind_spread}
15339 The following scalar integer named constants are of the
15340 kind @code{omp_lock_hint_kind}:
15343 @item @code{omp_lock_hint_none}
15344 @item @code{omp_lock_hint_uncontended}
15345 @item @code{omp_lock_hint_contended}
15346 @item @code{omp_lock_hint_nonspeculative}
15347 @item @code{omp_lock_hint_speculative}
15348 @item @code{omp_sync_hint_none}
15349 @item @code{omp_sync_hint_uncontended}
15350 @item @code{omp_sync_hint_contended}
15351 @item @code{omp_sync_hint_nonspeculative}
15352 @item @code{omp_sync_hint_speculative}
15355 And the following two scalar integer named constants are of the
15356 kind @code{omp_pause_resource_kind}:
15359 @item @code{omp_pause_soft}
15360 @item @code{omp_pause_hard}
15363 The following scalar integer named constants are of the kind
15364 @code{omp_alloctrait_key_kind}:
15367 @item @code{omp_atk_sync_hint}
15368 @item @code{omp_atk_alignment}
15369 @item @code{omp_atk_access}
15370 @item @code{omp_atk_pool_size}
15371 @item @code{omp_atk_fallback}
15372 @item @code{omp_atk_fb_data}
15373 @item @code{omp_atk_pinned}
15374 @item @code{omp_atk_partition}
15377 The following scalar integer named constants are of the kind
15378 @code{omp_alloctrait_val_kind}:
15381 @code{omp_alloctrait_key_kind}:
15382 @item @code{omp_atv_default}
15383 @item @code{omp_atv_false}
15384 @item @code{omp_atv_true}
15385 @item @code{omp_atv_contended}
15386 @item @code{omp_atv_uncontended}
15387 @item @code{omp_atv_serialized}
15388 @item @code{omp_atv_sequential}
15389 @item @code{omp_atv_private}
15390 @item @code{omp_atv_all}
15391 @item @code{omp_atv_thread}
15392 @item @code{omp_atv_pteam}
15393 @item @code{omp_atv_cgroup}
15394 @item @code{omp_atv_default_mem_fb}
15395 @item @code{omp_atv_null_fb}
15396 @item @code{omp_atv_abort_fb}
15397 @item @code{omp_atv_allocator_fb}
15398 @item @code{omp_atv_environment}
15399 @item @code{omp_atv_nearest}
15400 @item @code{omp_atv_blocked}
15403 The following scalar integer named constants are of the kind
15404 @code{omp_allocator_handle_kind}:
15407 @item @code{omp_null_allocator}
15408 @item @code{omp_default_mem_alloc}
15409 @item @code{omp_large_cap_mem_alloc}
15410 @item @code{omp_const_mem_alloc}
15411 @item @code{omp_high_bw_mem_alloc}
15412 @item @code{omp_low_lat_mem_alloc}
15413 @item @code{omp_cgroup_mem_alloc}
15414 @item @code{omp_pteam_mem_alloc}
15415 @item @code{omp_thread_mem_alloc}
15418 The following scalar integer named constants are of the kind
15419 @code{omp_memspace_handle_kind}:
15422 @item @code{omp_default_mem_space}
15423 @item @code{omp_large_cap_mem_space}
15424 @item @code{omp_const_mem_space}
15425 @item @code{omp_high_bw_mem_space}
15426 @item @code{omp_low_lat_mem_space}
15431 @node OpenACC Module OPENACC
15432 @section OpenACC Module @code{OPENACC}
15434 @item @emph{Standard}:
15435 OpenACC Application Programming Interface v2.6
15439 The OpenACC Fortran runtime library routines are provided both in a
15440 form of a Fortran 90 module, named @code{OPENACC}, and in form of a
15441 Fortran @code{include} file named @file{openacc_lib.h}. The
15442 procedures provided by @code{OPENACC} can be found in the
15443 @ref{Top,,Introduction,libgomp,GNU Offloading and Multi Processing
15444 Runtime Library} manual, the named constants defined in the modules
15447 For details refer to the actual
15448 @uref{https://www.openacc.org/,
15449 OpenACC Application Programming Interface v2.6}.
15451 @code{OPENACC} provides the scalar default-integer
15452 named constant @code{openacc_version} with a value of the form
15453 @var{yyyymm}, where @code{yyyy} is the year and @var{mm} the month
15454 of the OpenACC version; for OpenACC v2.6 the value is @code{201711}.