2 Copyright (C) 2005-2018 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{FLOOR}: FLOOR, Integer floor function
152 * @code{FLUSH}: FLUSH, Flush I/O unit(s)
153 * @code{FNUM}: FNUM, File number function
154 * @code{FPUT}: FPUT, Write a single character in stream mode to stdout
155 * @code{FPUTC}: FPUTC, Write a single character in stream mode
156 * @code{FRACTION}: FRACTION, Fractional part of the model representation
157 * @code{FREE}: FREE, Memory de-allocation subroutine
158 * @code{FSEEK}: FSEEK, Low level file positioning subroutine
159 * @code{FSTAT}: FSTAT, Get file status
160 * @code{FTELL}: FTELL, Current stream position
161 * @code{GAMMA}: GAMMA, Gamma function
162 * @code{GERROR}: GERROR, Get last system error message
163 * @code{GETARG}: GETARG, Get command line arguments
164 * @code{GET_COMMAND}: GET_COMMAND, Get the entire command line
165 * @code{GET_COMMAND_ARGUMENT}: GET_COMMAND_ARGUMENT, Get command line arguments
166 * @code{GETCWD}: GETCWD, Get current working directory
167 * @code{GETENV}: GETENV, Get an environmental variable
168 * @code{GET_ENVIRONMENT_VARIABLE}: GET_ENVIRONMENT_VARIABLE, Get an environmental variable
169 * @code{GETGID}: GETGID, Group ID function
170 * @code{GETLOG}: GETLOG, Get login name
171 * @code{GETPID}: GETPID, Process ID function
172 * @code{GETUID}: GETUID, User ID function
173 * @code{GMTIME}: GMTIME, Convert time to GMT info
174 * @code{HOSTNM}: HOSTNM, Get system host name
175 * @code{HUGE}: HUGE, Largest number of a kind
176 * @code{HYPOT}: HYPOT, Euclidean distance function
177 * @code{IACHAR}: IACHAR, Code in @acronym{ASCII} collating sequence
178 * @code{IALL}: IALL, Bitwise AND of array elements
179 * @code{IAND}: IAND, Bitwise logical and
180 * @code{IANY}: IANY, Bitwise OR of array elements
181 * @code{IARGC}: IARGC, Get the number of command line arguments
182 * @code{IBCLR}: IBCLR, Clear bit
183 * @code{IBITS}: IBITS, Bit extraction
184 * @code{IBSET}: IBSET, Set bit
185 * @code{ICHAR}: ICHAR, Character-to-integer conversion function
186 * @code{IDATE}: IDATE, Current local time (day/month/year)
187 * @code{IEOR}: IEOR, Bitwise logical exclusive or
188 * @code{IERRNO}: IERRNO, Function to get the last system error number
189 * @code{IMAGE_INDEX}: IMAGE_INDEX, Cosubscript to image index conversion
190 * @code{INDEX}: INDEX intrinsic, Position of a substring within a string
191 * @code{INT}: INT, Convert to integer type
192 * @code{INT2}: INT2, Convert to 16-bit integer type
193 * @code{INT8}: INT8, Convert to 64-bit integer type
194 * @code{IOR}: IOR, Bitwise logical or
195 * @code{IPARITY}: IPARITY, Bitwise XOR of array elements
196 * @code{IRAND}: IRAND, Integer pseudo-random number
197 * @code{IS_IOSTAT_END}: IS_IOSTAT_END, Test for end-of-file value
198 * @code{IS_IOSTAT_EOR}: IS_IOSTAT_EOR, Test for end-of-record value
199 * @code{ISATTY}: ISATTY, Whether a unit is a terminal device
200 * @code{ISHFT}: ISHFT, Shift bits
201 * @code{ISHFTC}: ISHFTC, Shift bits circularly
202 * @code{ISNAN}: ISNAN, Tests for a NaN
203 * @code{ITIME}: ITIME, Current local time (hour/minutes/seconds)
204 * @code{KILL}: KILL, Send a signal to a process
205 * @code{KIND}: KIND, Kind of an entity
206 * @code{LBOUND}: LBOUND, Lower dimension bounds of an array
207 * @code{LCOBOUND}: LCOBOUND, Lower codimension bounds of an array
208 * @code{LEADZ}: LEADZ, Number of leading zero bits of an integer
209 * @code{LEN}: LEN, Length of a character entity
210 * @code{LEN_TRIM}: LEN_TRIM, Length of a character entity without trailing blank characters
211 * @code{LGE}: LGE, Lexical greater than or equal
212 * @code{LGT}: LGT, Lexical greater than
213 * @code{LINK}: LINK, Create a hard link
214 * @code{LLE}: LLE, Lexical less than or equal
215 * @code{LLT}: LLT, Lexical less than
216 * @code{LNBLNK}: LNBLNK, Index of the last non-blank character in a string
217 * @code{LOC}: LOC, Returns the address of a variable
218 * @code{LOG}: LOG, Logarithm function
219 * @code{LOG10}: LOG10, Base 10 logarithm function
220 * @code{LOG_GAMMA}: LOG_GAMMA, Logarithm of the Gamma function
221 * @code{LOGICAL}: LOGICAL, Convert to logical type
222 * @code{LONG}: LONG, Convert to integer type
223 * @code{LSHIFT}: LSHIFT, Left shift bits
224 * @code{LSTAT}: LSTAT, Get file status
225 * @code{LTIME}: LTIME, Convert time to local time info
226 * @code{MALLOC}: MALLOC, Dynamic memory allocation function
227 * @code{MASKL}: MASKL, Left justified mask
228 * @code{MASKR}: MASKR, Right justified mask
229 * @code{MATMUL}: MATMUL, matrix multiplication
230 * @code{MAX}: MAX, Maximum value of an argument list
231 * @code{MAXEXPONENT}: MAXEXPONENT, Maximum exponent of a real kind
232 * @code{MAXLOC}: MAXLOC, Location of the maximum value within an array
233 * @code{MAXVAL}: MAXVAL, Maximum value of an array
234 * @code{MCLOCK}: MCLOCK, Time function
235 * @code{MCLOCK8}: MCLOCK8, Time function (64-bit)
236 * @code{MERGE}: MERGE, Merge arrays
237 * @code{MERGE_BITS}: MERGE_BITS, Merge of bits under mask
238 * @code{MIN}: MIN, Minimum value of an argument list
239 * @code{MINEXPONENT}: MINEXPONENT, Minimum exponent of a real kind
240 * @code{MINLOC}: MINLOC, Location of the minimum value within an array
241 * @code{MINVAL}: MINVAL, Minimum value of an array
242 * @code{MOD}: MOD, Remainder function
243 * @code{MODULO}: MODULO, Modulo function
244 * @code{MOVE_ALLOC}: MOVE_ALLOC, Move allocation from one object to another
245 * @code{MVBITS}: MVBITS, Move bits from one integer to another
246 * @code{NEAREST}: NEAREST, Nearest representable number
247 * @code{NEW_LINE}: NEW_LINE, New line character
248 * @code{NINT}: NINT, Nearest whole number
249 * @code{NORM2}: NORM2, Euclidean vector norm
250 * @code{NOT}: NOT, Logical negation
251 * @code{NULL}: NULL, Function that returns an disassociated pointer
252 * @code{NUM_IMAGES}: NUM_IMAGES, Number of images
253 * @code{OR}: OR, Bitwise logical OR
254 * @code{PACK}: PACK, Pack an array into an array of rank one
255 * @code{PARITY}: PARITY, Reduction with exclusive OR
256 * @code{PERROR}: PERROR, Print system error message
257 * @code{POPCNT}: POPCNT, Number of bits set
258 * @code{POPPAR}: POPPAR, Parity of the number of bits set
259 * @code{PRECISION}: PRECISION, Decimal precision of a real kind
260 * @code{PRESENT}: PRESENT, Determine whether an optional dummy argument is specified
261 * @code{PRODUCT}: PRODUCT, Product of array elements
262 * @code{RADIX}: RADIX, Base of a data model
263 * @code{RAN}: RAN, Real pseudo-random number
264 * @code{RAND}: RAND, Real pseudo-random number
265 * @code{RANDOM_NUMBER}: RANDOM_NUMBER, Pseudo-random number
266 * @code{RANDOM_SEED}: RANDOM_SEED, Initialize a pseudo-random number sequence
267 * @code{RANGE}: RANGE, Decimal exponent range
268 * @code{RANK} : RANK, Rank of a data object
269 * @code{REAL}: REAL, Convert to real type
270 * @code{RENAME}: RENAME, Rename a file
271 * @code{REPEAT}: REPEAT, Repeated string concatenation
272 * @code{RESHAPE}: RESHAPE, Function to reshape an array
273 * @code{RRSPACING}: RRSPACING, Reciprocal of the relative spacing
274 * @code{RSHIFT}: RSHIFT, Right shift bits
275 * @code{SAME_TYPE_AS}: SAME_TYPE_AS, Query dynamic types for equality
276 * @code{SCALE}: SCALE, Scale a real value
277 * @code{SCAN}: SCAN, Scan a string for the presence of a set of characters
278 * @code{SECNDS}: SECNDS, Time function
279 * @code{SECOND}: SECOND, CPU time function
280 * @code{SELECTED_CHAR_KIND}: SELECTED_CHAR_KIND, Choose character kind
281 * @code{SELECTED_INT_KIND}: SELECTED_INT_KIND, Choose integer kind
282 * @code{SELECTED_REAL_KIND}: SELECTED_REAL_KIND, Choose real kind
283 * @code{SET_EXPONENT}: SET_EXPONENT, Set the exponent of the model
284 * @code{SHAPE}: SHAPE, Determine the shape of an array
285 * @code{SHIFTA}: SHIFTA, Right shift with fill
286 * @code{SHIFTL}: SHIFTL, Left shift
287 * @code{SHIFTR}: SHIFTR, Right shift
288 * @code{SIGN}: SIGN, Sign copying function
289 * @code{SIGNAL}: SIGNAL, Signal handling subroutine (or function)
290 * @code{SIN}: SIN, Sine function
291 * @code{SIND}: SIND, Sine function, degrees
292 * @code{SINH}: SINH, Hyperbolic sine function
293 * @code{SIZE}: SIZE, Function to determine the size of an array
294 * @code{SIZEOF}: SIZEOF, Determine the size in bytes of an expression
295 * @code{SLEEP}: SLEEP, Sleep for the specified number of seconds
296 * @code{SPACING}: SPACING, Smallest distance between two numbers of a given type
297 * @code{SPREAD}: SPREAD, Add a dimension to an array
298 * @code{SQRT}: SQRT, Square-root function
299 * @code{SRAND}: SRAND, Reinitialize the random number generator
300 * @code{STAT}: STAT, Get file status
301 * @code{STORAGE_SIZE}: STORAGE_SIZE, Storage size in bits
302 * @code{SUM}: SUM, Sum of array elements
303 * @code{SYMLNK}: SYMLNK, Create a symbolic link
304 * @code{SYSTEM}: SYSTEM, Execute a shell command
305 * @code{SYSTEM_CLOCK}: SYSTEM_CLOCK, Time function
306 * @code{TAN}: TAN, Tangent function
307 * @code{TAND}: TAND, Tangent function, degrees
308 * @code{TANH}: TANH, Hyperbolic tangent function
309 * @code{THIS_IMAGE}: THIS_IMAGE, Cosubscript index of this image
310 * @code{TIME}: TIME, Time function
311 * @code{TIME8}: TIME8, Time function (64-bit)
312 * @code{TINY}: TINY, Smallest positive number of a real kind
313 * @code{TRAILZ}: TRAILZ, Number of trailing zero bits of an integer
314 * @code{TRANSFER}: TRANSFER, Transfer bit patterns
315 * @code{TRANSPOSE}: TRANSPOSE, Transpose an array of rank two
316 * @code{TRIM}: TRIM, Remove trailing blank characters of a string
317 * @code{TTYNAM}: TTYNAM, Get the name of a terminal device.
318 * @code{UBOUND}: UBOUND, Upper dimension bounds of an array
319 * @code{UCOBOUND}: UCOBOUND, Upper codimension bounds of an array
320 * @code{UMASK}: UMASK, Set the file creation mask
321 * @code{UNLINK}: UNLINK, Remove a file from the file system
322 * @code{UNPACK}: UNPACK, Unpack an array of rank one into an array
323 * @code{VERIFY}: VERIFY, Scan a string for the absence of a set of characters
324 * @code{XOR}: XOR, Bitwise logical exclusive or
327 @node Introduction to Intrinsics
328 @section Introduction to intrinsic procedures
330 The intrinsic procedures provided by GNU Fortran include all of the
331 intrinsic procedures required by the Fortran 95 standard, a set of
332 intrinsic procedures for backwards compatibility with G77, and a
333 selection of intrinsic procedures from the Fortran 2003 and Fortran 2008
334 standards. Any conflict between a description here and a description in
335 either the Fortran 95 standard, the Fortran 2003 standard or the Fortran
336 2008 standard is unintentional, and the standard(s) should be considered
339 The enumeration of the @code{KIND} type parameter is processor defined in
340 the Fortran 95 standard. GNU Fortran defines the default integer type and
341 default real type by @code{INTEGER(KIND=4)} and @code{REAL(KIND=4)},
342 respectively. The standard mandates that both data types shall have
343 another kind, which have more precision. On typical target architectures
344 supported by @command{gfortran}, this kind type parameter is @code{KIND=8}.
345 Hence, @code{REAL(KIND=8)} and @code{DOUBLE PRECISION} are equivalent.
346 In the description of generic intrinsic procedures, the kind type parameter
347 will be specified by @code{KIND=*}, and in the description of specific
348 names for an intrinsic procedure the kind type parameter will be explicitly
349 given (e.g., @code{REAL(KIND=4)} or @code{REAL(KIND=8)}). Finally, for
350 brevity the optional @code{KIND=} syntax will be omitted.
352 Many of the intrinsic procedures take one or more optional arguments.
353 This document follows the convention used in the Fortran 95 standard,
354 and denotes such arguments by square brackets.
356 GNU Fortran offers the @option{-std=f95} and @option{-std=gnu} options,
357 which can be used to restrict the set of intrinsic procedures to a
358 given standard. By default, @command{gfortran} sets the @option{-std=gnu}
359 option, and so all intrinsic procedures described here are accepted. There
360 is one caveat. For a select group of intrinsic procedures, @command{g77}
361 implemented both a function and a subroutine. Both classes
362 have been implemented in @command{gfortran} for backwards compatibility
363 with @command{g77}. It is noted here that these functions and subroutines
364 cannot be intermixed in a given subprogram. In the descriptions that follow,
365 the applicable standard for each intrinsic procedure is noted.
370 @section @code{ABORT} --- Abort the program
372 @cindex program termination, with core dump
373 @cindex terminate program, with core dump
377 @item @emph{Description}:
378 @code{ABORT} causes immediate termination of the program. On operating
379 systems that support a core dump, @code{ABORT} will produce a core dump.
380 It will also print a backtrace, unless @code{-fno-backtrace} is given.
382 @item @emph{Standard}:
391 @item @emph{Return value}:
394 @item @emph{Example}:
397 integer :: i = 1, j = 2
398 if (i /= j) call abort
399 end program test_abort
402 @item @emph{See also}:
403 @ref{EXIT}, @ref{KILL}, @ref{BACKTRACE}
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 .20 .20 .25
461 @item 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{COMPLEX(8)} @tab GNU extension
471 @item @code{CDABS(A)} @tab @code{COMPLEX(8) A} @tab @code{COMPLEX(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. Tailing 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
529 @item @emph{Specific names}:
530 @item @emph{See also}:
537 @section @code{ACHAR} --- Character in @acronym{ASCII} collating sequence
539 @cindex @acronym{ASCII} collating sequence
540 @cindex collating sequence, @acronym{ASCII}
543 @item @emph{Description}:
544 @code{ACHAR(I)} returns the character located at position @code{I}
545 in the @acronym{ASCII} collating sequence.
547 @item @emph{Standard}:
548 Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later
554 @code{RESULT = ACHAR(I [, KIND])}
556 @item @emph{Arguments}:
557 @multitable @columnfractions .15 .70
558 @item @var{I} @tab The type shall be @code{INTEGER}.
559 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
560 expression indicating the kind parameter of the result.
563 @item @emph{Return value}:
564 The return value is of type @code{CHARACTER} with a length of one.
565 If the @var{KIND} argument is present, the return value is of the
566 specified kind and of the default kind otherwise.
568 @item @emph{Example}:
573 end program test_achar
577 See @ref{ICHAR} for a discussion of converting between numerical values
578 and formatted string representations.
580 @item @emph{See also}:
581 @ref{CHAR}, @ref{IACHAR}, @ref{ICHAR}
588 @section @code{ACOS} --- Arccosine function
591 @cindex trigonometric function, cosine, inverse
592 @cindex cosine, inverse
595 @item @emph{Description}:
596 @code{ACOS(X)} computes the arccosine of @var{X} (inverse of @code{COS(X)}).
598 @item @emph{Standard}:
599 Fortran 77 and later, for a complex argument Fortran 2008 or later
605 @code{RESULT = ACOS(X)}
607 @item @emph{Arguments}:
608 @multitable @columnfractions .15 .70
609 @item @var{X} @tab The type shall either be @code{REAL} with a magnitude that is
610 less than or equal to one - or the type shall be @code{COMPLEX}.
613 @item @emph{Return value}:
614 The return value is of the same type and kind as @var{X}.
615 The real part of the result is in radians and lies in the range
616 @math{0 \leq \Re \acos(x) \leq \pi}.
618 @item @emph{Example}:
621 real(8) :: x = 0.866_8
623 end program test_acos
626 @item @emph{Specific names}:
627 @multitable @columnfractions .20 .20 .20 .25
628 @item Name @tab Argument @tab Return type @tab Standard
629 @item @code{ACOS(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later
630 @item @code{DACOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
633 @item @emph{See also}:
634 Inverse function: @ref{COS}
635 Degrees function: @ref{ACOSD}
642 @section @code{ACOSD} --- Arccosine function, degrees
645 @cindex trigonometric function, cosine, inverse, degrees
646 @cindex cosine, inverse, degrees
649 @item @emph{Description}:
650 @code{ACOSD(X)} computes the arccosine of @var{X} in degrees (inverse of
653 This function is for compatibility only and should be avoided in favor of
654 standard constructs wherever possible.
656 @item @emph{Standard}:
657 GNU Extension, enabled with @option{-fdec-math}
663 @code{RESULT = ACOSD(X)}
665 @item @emph{Arguments}:
666 @multitable @columnfractions .15 .70
667 @item @var{X} @tab The type shall either be @code{REAL} with a magnitude that is
668 less than or equal to one - or the type shall be @code{COMPLEX}.
671 @item @emph{Return value}:
672 The return value is of the same type and kind as @var{X}.
673 The real part of the result is in degrees and lies in the range
674 @math{0 \leq \Re \acos(x) \leq 180}.
676 @item @emph{Example}:
679 real(8) :: x = 0.866_8
681 end program test_acosd
684 @item @emph{Specific names}:
685 @multitable @columnfractions .20 .20 .20 .25
686 @item Name @tab Argument @tab Return type @tab Standard
687 @item @code{ACOSD(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU Extension
688 @item @code{DACOSD(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU Extension
691 @item @emph{See also}:
692 Inverse function: @ref{COSD}
693 Radians function: @ref{ACOS}
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 .20 .20 .25
741 @item 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}:
746 Inverse function: @ref{COSH}
752 @section @code{ADJUSTL} --- Left adjust a string
754 @cindex string, adjust left
755 @cindex adjust string
758 @item @emph{Description}:
759 @code{ADJUSTL(STRING)} will left adjust a string by removing leading spaces.
760 Spaces are inserted at the end of the string as needed.
762 @item @emph{Standard}:
769 @code{RESULT = ADJUSTL(STRING)}
771 @item @emph{Arguments}:
772 @multitable @columnfractions .15 .70
773 @item @var{STRING} @tab The type shall be @code{CHARACTER}.
776 @item @emph{Return value}:
777 The return value is of type @code{CHARACTER} and of the same kind as
778 @var{STRING} where leading spaces are removed and the same number of
779 spaces are inserted on the end of @var{STRING}.
781 @item @emph{Example}:
784 character(len=20) :: str = ' gfortran'
787 end program test_adjustl
790 @item @emph{See also}:
791 @ref{ADJUSTR}, @ref{TRIM}
797 @section @code{ADJUSTR} --- Right adjust a string
799 @cindex string, adjust right
800 @cindex adjust string
803 @item @emph{Description}:
804 @code{ADJUSTR(STRING)} will right adjust a string by removing trailing spaces.
805 Spaces are inserted at the start of the string as needed.
807 @item @emph{Standard}:
814 @code{RESULT = ADJUSTR(STRING)}
816 @item @emph{Arguments}:
817 @multitable @columnfractions .15 .70
818 @item @var{STR} @tab The type shall be @code{CHARACTER}.
821 @item @emph{Return value}:
822 The return value is of type @code{CHARACTER} and of the same kind as
823 @var{STRING} where trailing spaces are removed and the same number of
824 spaces are inserted at the start of @var{STRING}.
826 @item @emph{Example}:
829 character(len=20) :: str = 'gfortran'
832 end program test_adjustr
835 @item @emph{See also}:
836 @ref{ADJUSTL}, @ref{TRIM}
842 @section @code{AIMAG} --- Imaginary part of complex number
847 @cindex complex numbers, imaginary part
850 @item @emph{Description}:
851 @code{AIMAG(Z)} yields the imaginary part of complex argument @code{Z}.
852 The @code{IMAG(Z)} and @code{IMAGPART(Z)} intrinsic functions are provided
853 for compatibility with @command{g77}, and their use in new code is
854 strongly discouraged.
856 @item @emph{Standard}:
857 Fortran 77 and later, has overloads that are GNU extensions
863 @code{RESULT = AIMAG(Z)}
865 @item @emph{Arguments}:
866 @multitable @columnfractions .15 .70
867 @item @var{Z} @tab The type of the argument shall be @code{COMPLEX}.
870 @item @emph{Return value}:
871 The return value is of type @code{REAL} with the
872 kind type parameter of the argument.
874 @item @emph{Example}:
879 z4 = cmplx(1.e0_4, 0.e0_4)
880 z8 = cmplx(0.e0_8, 1.e0_8)
881 print *, aimag(z4), dimag(z8)
882 end program test_aimag
885 @item @emph{Specific names}:
886 @multitable @columnfractions .20 .20 .20 .25
887 @item Name @tab Argument @tab Return type @tab Standard
888 @item @code{AIMAG(Z)} @tab @code{COMPLEX Z} @tab @code{REAL} @tab GNU extension
889 @item @code{DIMAG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{REAL(8)} @tab GNU extension
890 @item @code{IMAG(Z)} @tab @code{COMPLEX Z} @tab @code{REAL} @tab GNU extension
891 @item @code{IMAGPART(Z)} @tab @code{COMPLEX Z} @tab @code{REAL} @tab GNU extension
898 @section @code{AINT} --- Truncate to a whole number
902 @cindex rounding, floor
905 @item @emph{Description}:
906 @code{AINT(A [, KIND])} truncates its argument to a whole number.
908 @item @emph{Standard}:
915 @code{RESULT = AINT(A [, KIND])}
917 @item @emph{Arguments}:
918 @multitable @columnfractions .15 .70
919 @item @var{A} @tab The type of the argument shall be @code{REAL}.
920 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
921 expression indicating the kind parameter of the result.
924 @item @emph{Return value}:
925 The return value is of type @code{REAL} with the kind type parameter of the
926 argument if the optional @var{KIND} is absent; otherwise, the kind
927 type parameter will be given by @var{KIND}. If the magnitude of
928 @var{X} is less than one, @code{AINT(X)} returns zero. If the
929 magnitude is equal to or greater than one then it returns the largest
930 whole number that does not exceed its magnitude. The sign is the same
931 as the sign of @var{X}.
933 @item @emph{Example}:
940 print *, aint(x4), dint(x8)
942 end program test_aint
945 @item @emph{Specific names}:
946 @multitable @columnfractions .20 .20 .20 .25
947 @item Name @tab Argument @tab Return type @tab Standard
948 @item @code{AINT(A)} @tab @code{REAL(4) A} @tab @code{REAL(4)} @tab Fortran 77 and later
949 @item @code{DINT(A)} @tab @code{REAL(8) A} @tab @code{REAL(8)} @tab Fortran 77 and later
956 @section @code{ALARM} --- Execute a routine after a given delay
958 @cindex delayed execution
961 @item @emph{Description}:
962 @code{ALARM(SECONDS, HANDLER [, STATUS])} causes external subroutine @var{HANDLER}
963 to be executed after a delay of @var{SECONDS} by using @code{alarm(2)} to
964 set up a signal and @code{signal(2)} to catch it. If @var{STATUS} is
965 supplied, it will be returned with the number of seconds remaining until
966 any previously scheduled alarm was due to be delivered, or zero if there
967 was no previously scheduled alarm.
969 @item @emph{Standard}:
976 @code{CALL ALARM(SECONDS, HANDLER [, STATUS])}
978 @item @emph{Arguments}:
979 @multitable @columnfractions .15 .70
980 @item @var{SECONDS} @tab The type of the argument shall be a scalar
981 @code{INTEGER}. It is @code{INTENT(IN)}.
982 @item @var{HANDLER} @tab Signal handler (@code{INTEGER FUNCTION} or
983 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar. The scalar
984 values may be either @code{SIG_IGN=1} to ignore the alarm generated
985 or @code{SIG_DFL=0} to set the default action. It is @code{INTENT(IN)}.
986 @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
987 variable of the default @code{INTEGER} kind. It is @code{INTENT(OUT)}.
990 @item @emph{Example}:
993 external handler_print
995 call alarm (3, handler_print, i)
998 end program test_alarm
1000 This will cause the external routine @var{handler_print} to be called
1007 @section @code{ALL} --- All values in @var{MASK} along @var{DIM} are true
1009 @cindex array, apply condition
1010 @cindex array, condition testing
1013 @item @emph{Description}:
1014 @code{ALL(MASK [, DIM])} determines if all the values are true in @var{MASK}
1015 in the array along dimension @var{DIM}.
1017 @item @emph{Standard}:
1018 Fortran 95 and later
1021 Transformational function
1023 @item @emph{Syntax}:
1024 @code{RESULT = ALL(MASK [, DIM])}
1026 @item @emph{Arguments}:
1027 @multitable @columnfractions .15 .70
1028 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL} and
1029 it shall not be scalar.
1030 @item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer
1031 with a value that lies between one and the rank of @var{MASK}.
1034 @item @emph{Return value}:
1035 @code{ALL(MASK)} returns a scalar value of type @code{LOGICAL} where
1036 the kind type parameter is the same as the kind type parameter of
1037 @var{MASK}. If @var{DIM} is present, then @code{ALL(MASK, DIM)} returns
1038 an array with the rank of @var{MASK} minus 1. The shape is determined from
1039 the shape of @var{MASK} where the @var{DIM} dimension is elided.
1043 @code{ALL(MASK)} is true if all elements of @var{MASK} are true.
1044 It also is true if @var{MASK} has zero size; otherwise, it is false.
1046 If the rank of @var{MASK} is one, then @code{ALL(MASK,DIM)} is equivalent
1047 to @code{ALL(MASK)}. If the rank is greater than one, then @code{ALL(MASK,DIM)}
1048 is determined by applying @code{ALL} to the array sections.
1051 @item @emph{Example}:
1055 l = all((/.true., .true., .true./))
1060 integer a(2,3), b(2,3)
1064 print *, all(a .eq. b, 1)
1065 print *, all(a .eq. b, 2)
1066 end subroutine section
1067 end program test_all
1074 @section @code{ALLOCATED} --- Status of an allocatable entity
1076 @cindex allocation, status
1079 @item @emph{Description}:
1080 @code{ALLOCATED(ARRAY)} and @code{ALLOCATED(SCALAR)} check the allocation
1081 status of @var{ARRAY} and @var{SCALAR}, respectively.
1083 @item @emph{Standard}:
1084 Fortran 95 and later. Note, the @code{SCALAR=} keyword and allocatable
1085 scalar entities are available in Fortran 2003 and later.
1090 @item @emph{Syntax}:
1091 @multitable @columnfractions .80
1092 @item @code{RESULT = ALLOCATED(ARRAY)}
1093 @item @code{RESULT = ALLOCATED(SCALAR)}
1096 @item @emph{Arguments}:
1097 @multitable @columnfractions .15 .70
1098 @item @var{ARRAY} @tab The argument shall be an @code{ALLOCATABLE} array.
1099 @item @var{SCALAR} @tab The argument shall be an @code{ALLOCATABLE} scalar.
1102 @item @emph{Return value}:
1103 The return value is a scalar @code{LOGICAL} with the default logical
1104 kind type parameter. If the argument is allocated, then the result is
1105 @code{.TRUE.}; otherwise, it returns @code{.FALSE.}
1107 @item @emph{Example}:
1109 program test_allocated
1111 real(4), allocatable :: x(:)
1112 if (.not. allocated(x)) allocate(x(i))
1113 end program test_allocated
1120 @section @code{AND} --- Bitwise logical AND
1122 @cindex bitwise logical and
1123 @cindex logical and, bitwise
1126 @item @emph{Description}:
1127 Bitwise logical @code{AND}.
1129 This intrinsic routine is provided for backwards compatibility with
1130 GNU Fortran 77. For integer arguments, programmers should consider
1131 the use of the @ref{IAND} intrinsic defined by the Fortran standard.
1133 @item @emph{Standard}:
1139 @item @emph{Syntax}:
1140 @code{RESULT = AND(I, J)}
1142 @item @emph{Arguments}:
1143 @multitable @columnfractions .15 .70
1144 @item @var{I} @tab The type shall be either a scalar @code{INTEGER}
1145 type or a scalar @code{LOGICAL} type.
1146 @item @var{J} @tab The type shall be the same as the type of @var{I}.
1149 @item @emph{Return value}:
1150 The return type is either a scalar @code{INTEGER} or a scalar
1151 @code{LOGICAL}. If the kind type parameters differ, then the
1152 smaller kind type is implicitly converted to larger kind, and the
1153 return has the larger kind.
1155 @item @emph{Example}:
1158 LOGICAL :: T = .TRUE., F = .FALSE.
1160 DATA a / Z'F' /, b / Z'3' /
1162 WRITE (*,*) AND(T, T), AND(T, F), AND(F, T), AND(F, F)
1163 WRITE (*,*) AND(a, b)
1167 @item @emph{See also}:
1168 Fortran 95 elemental function: @ref{IAND}
1174 @section @code{ANINT} --- Nearest whole number
1178 @cindex rounding, ceiling
1181 @item @emph{Description}:
1182 @code{ANINT(A [, KIND])} rounds its argument to the nearest whole number.
1184 @item @emph{Standard}:
1185 Fortran 77 and later
1190 @item @emph{Syntax}:
1191 @code{RESULT = ANINT(A [, KIND])}
1193 @item @emph{Arguments}:
1194 @multitable @columnfractions .15 .70
1195 @item @var{A} @tab The type of the argument shall be @code{REAL}.
1196 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
1197 expression indicating the kind parameter of the result.
1200 @item @emph{Return value}:
1201 The return value is of type real with the kind type parameter of the
1202 argument if the optional @var{KIND} is absent; otherwise, the kind
1203 type parameter will be given by @var{KIND}. If @var{A} is greater than
1204 zero, @code{ANINT(A)} returns @code{AINT(X+0.5)}. If @var{A} is
1205 less than or equal to zero then it returns @code{AINT(X-0.5)}.
1207 @item @emph{Example}:
1214 print *, anint(x4), dnint(x8)
1216 end program test_anint
1219 @item @emph{Specific names}:
1220 @multitable @columnfractions .20 .20 .20 .25
1221 @item Name @tab Argument @tab Return type @tab Standard
1222 @item @code{AINT(A)} @tab @code{REAL(4) A} @tab @code{REAL(4)} @tab Fortran 77 and later
1223 @item @code{DNINT(A)} @tab @code{REAL(8) A} @tab @code{REAL(8)} @tab Fortran 77 and later
1230 @section @code{ANY} --- Any value in @var{MASK} along @var{DIM} is true
1232 @cindex array, apply condition
1233 @cindex array, condition testing
1236 @item @emph{Description}:
1237 @code{ANY(MASK [, DIM])} determines if any of the values in the logical array
1238 @var{MASK} along dimension @var{DIM} are @code{.TRUE.}.
1240 @item @emph{Standard}:
1241 Fortran 95 and later
1244 Transformational function
1246 @item @emph{Syntax}:
1247 @code{RESULT = ANY(MASK [, DIM])}
1249 @item @emph{Arguments}:
1250 @multitable @columnfractions .15 .70
1251 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL} and
1252 it shall not be scalar.
1253 @item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer
1254 with a value that lies between one and the rank of @var{MASK}.
1257 @item @emph{Return value}:
1258 @code{ANY(MASK)} returns a scalar value of type @code{LOGICAL} where
1259 the kind type parameter is the same as the kind type parameter of
1260 @var{MASK}. If @var{DIM} is present, then @code{ANY(MASK, DIM)} returns
1261 an array with the rank of @var{MASK} minus 1. The shape is determined from
1262 the shape of @var{MASK} where the @var{DIM} dimension is elided.
1266 @code{ANY(MASK)} is true if any element of @var{MASK} is true;
1267 otherwise, it is false. It also is false if @var{MASK} has zero size.
1269 If the rank of @var{MASK} is one, then @code{ANY(MASK,DIM)} is equivalent
1270 to @code{ANY(MASK)}. If the rank is greater than one, then @code{ANY(MASK,DIM)}
1271 is determined by applying @code{ANY} to the array sections.
1274 @item @emph{Example}:
1278 l = any((/.true., .true., .true./))
1283 integer a(2,3), b(2,3)
1287 print *, any(a .eq. b, 1)
1288 print *, any(a .eq. b, 2)
1289 end subroutine section
1290 end program test_any
1297 @section @code{ASIN} --- Arcsine function
1300 @cindex trigonometric function, sine, inverse
1301 @cindex sine, inverse
1304 @item @emph{Description}:
1305 @code{ASIN(X)} computes the arcsine of its @var{X} (inverse of @code{SIN(X)}).
1307 @item @emph{Standard}:
1308 Fortran 77 and later, for a complex argument Fortran 2008 or later
1313 @item @emph{Syntax}:
1314 @code{RESULT = ASIN(X)}
1316 @item @emph{Arguments}:
1317 @multitable @columnfractions .15 .70
1318 @item @var{X} @tab The type shall be either @code{REAL} and a magnitude that is
1319 less than or equal to one - or be @code{COMPLEX}.
1322 @item @emph{Return value}:
1323 The return value is of the same type and kind as @var{X}.
1324 The real part of the result is in radians and lies in the range
1325 @math{-\pi/2 \leq \Re \asin(x) \leq \pi/2}.
1327 @item @emph{Example}:
1330 real(8) :: x = 0.866_8
1332 end program test_asin
1335 @item @emph{Specific names}:
1336 @multitable @columnfractions .20 .20 .20 .25
1337 @item Name @tab Argument @tab Return type @tab Standard
1338 @item @code{ASIN(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later
1339 @item @code{DASIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
1342 @item @emph{See also}:
1343 Inverse function: @ref{SIN}
1344 Degrees function: @ref{ASIND}
1351 @section @code{ASIND} --- Arcsine function, degrees
1354 @cindex trigonometric function, sine, inverse, degrees
1355 @cindex sine, inverse, degrees
1358 @item @emph{Description}:
1359 @code{ASIND(X)} computes the arcsine of its @var{X} in degrees (inverse of
1362 This function is for compatibility only and should be avoided in favor of
1363 standard constructs wherever possible.
1365 @item @emph{Standard}:
1366 GNU Extension, enabled with @option{-fdec-math}.
1371 @item @emph{Syntax}:
1372 @code{RESULT = ASIND(X)}
1374 @item @emph{Arguments}:
1375 @multitable @columnfractions .15 .70
1376 @item @var{X} @tab The type shall be either @code{REAL} and a magnitude that is
1377 less than or equal to one - or be @code{COMPLEX}.
1380 @item @emph{Return value}:
1381 The return value is of the same type and kind as @var{X}.
1382 The real part of the result is in degrees and lies in the range
1383 @math{-90 \leq \Re \asin(x) \leq 90}.
1385 @item @emph{Example}:
1388 real(8) :: x = 0.866_8
1390 end program test_asind
1393 @item @emph{Specific names}:
1394 @multitable @columnfractions .20 .20 .20 .25
1395 @item Name @tab Argument @tab Return type @tab Standard
1396 @item @code{ASIND(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU Extension
1397 @item @code{DASIND(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU Extension
1400 @item @emph{See also}:
1401 Inverse function: @ref{SIND}
1402 Radians function: @ref{ASIN}
1409 @section @code{ASINH} --- Inverse hyperbolic sine function
1412 @cindex area hyperbolic sine
1413 @cindex inverse hyperbolic sine
1414 @cindex hyperbolic function, sine, inverse
1415 @cindex sine, hyperbolic, inverse
1418 @item @emph{Description}:
1419 @code{ASINH(X)} computes the inverse hyperbolic sine of @var{X}.
1421 @item @emph{Standard}:
1422 Fortran 2008 and later
1427 @item @emph{Syntax}:
1428 @code{RESULT = ASINH(X)}
1430 @item @emph{Arguments}:
1431 @multitable @columnfractions .15 .70
1432 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
1435 @item @emph{Return value}:
1436 The return value is of the same type and kind as @var{X}. If @var{X} is
1437 complex, the imaginary part of the result is in radians and lies between
1438 @math{-\pi/2 \leq \Im \asinh(x) \leq \pi/2}.
1440 @item @emph{Example}:
1443 REAL(8), DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1444 WRITE (*,*) ASINH(x)
1448 @item @emph{Specific names}:
1449 @multitable @columnfractions .20 .20 .20 .25
1450 @item Name @tab Argument @tab Return type @tab Standard
1451 @item @code{DASINH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension.
1454 @item @emph{See also}:
1455 Inverse function: @ref{SINH}
1461 @section @code{ASSOCIATED} --- Status of a pointer or pointer/target pair
1463 @cindex pointer, status
1464 @cindex association status
1467 @item @emph{Description}:
1468 @code{ASSOCIATED(POINTER [, TARGET])} determines the status of the pointer
1469 @var{POINTER} or if @var{POINTER} is associated with the target @var{TARGET}.
1471 @item @emph{Standard}:
1472 Fortran 95 and later
1477 @item @emph{Syntax}:
1478 @code{RESULT = ASSOCIATED(POINTER [, TARGET])}
1480 @item @emph{Arguments}:
1481 @multitable @columnfractions .15 .70
1482 @item @var{POINTER} @tab @var{POINTER} shall have the @code{POINTER} attribute
1483 and it can be of any type.
1484 @item @var{TARGET} @tab (Optional) @var{TARGET} shall be a pointer or
1485 a target. It must have the same type, kind type parameter, and
1486 array rank as @var{POINTER}.
1488 The association status of neither @var{POINTER} nor @var{TARGET} shall be
1491 @item @emph{Return value}:
1492 @code{ASSOCIATED(POINTER)} returns a scalar value of type @code{LOGICAL(4)}.
1493 There are several cases:
1495 @item (A) When the optional @var{TARGET} is not present then
1496 @code{ASSOCIATED(POINTER)} is true if @var{POINTER} is associated with a target; otherwise, it returns false.
1497 @item (B) If @var{TARGET} is present and a scalar target, the result is true if
1498 @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
1499 disassociated, the result is false.
1500 @item (C) If @var{TARGET} is present and an array target, the result is true if
1501 @var{TARGET} and @var{POINTER} have the same shape, are not zero-sized arrays,
1502 are arrays whose elements are not zero-sized storage sequences, and
1503 @var{TARGET} and @var{POINTER} occupy the same storage units in array element
1505 As in case(B), the result is false, if @var{POINTER} is disassociated.
1506 @item (D) If @var{TARGET} is present and an scalar pointer, the result is true
1507 if @var{TARGET} is associated with @var{POINTER}, the target associated with
1508 @var{TARGET} are not zero-sized storage sequences and occupy the same storage
1510 The result is false, if either @var{TARGET} or @var{POINTER} is disassociated.
1511 @item (E) If @var{TARGET} is present and an array pointer, the result is true if
1512 target associated with @var{POINTER} and the target associated with @var{TARGET}
1513 have the same shape, are not zero-sized arrays, are arrays whose elements are
1514 not zero-sized storage sequences, and @var{TARGET} and @var{POINTER} occupy
1515 the same storage units in array element order.
1516 The result is false, if either @var{TARGET} or @var{POINTER} is disassociated.
1519 @item @emph{Example}:
1521 program test_associated
1523 real, target :: tgt(2) = (/1., 2./)
1524 real, pointer :: ptr(:)
1526 if (associated(ptr) .eqv. .false.) call abort
1527 if (associated(ptr,tgt) .eqv. .false.) call abort
1528 end program test_associated
1531 @item @emph{See also}:
1538 @section @code{ATAN} --- Arctangent function
1541 @cindex trigonometric function, tangent, inverse
1542 @cindex tangent, inverse
1545 @item @emph{Description}:
1546 @code{ATAN(X)} computes the arctangent of @var{X}.
1548 @item @emph{Standard}:
1549 Fortran 77 and later, for a complex argument and for two arguments
1550 Fortran 2008 or later
1555 @item @emph{Syntax}:
1556 @multitable @columnfractions .80
1557 @item @code{RESULT = ATAN(X)}
1558 @item @code{RESULT = ATAN(Y, X)}
1561 @item @emph{Arguments}:
1562 @multitable @columnfractions .15 .70
1563 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX};
1564 if @var{Y} is present, @var{X} shall be REAL.
1565 @item @var{Y} shall be of the same type and kind as @var{X}.
1568 @item @emph{Return value}:
1569 The return value is of the same type and kind as @var{X}.
1570 If @var{Y} is present, the result is identical to @code{ATAN2(Y,X)}.
1571 Otherwise, it the arcus tangent of @var{X}, where the real part of
1572 the result is in radians and lies in the range
1573 @math{-\pi/2 \leq \Re \atan(x) \leq \pi/2}.
1575 @item @emph{Example}:
1578 real(8) :: x = 2.866_8
1580 end program test_atan
1583 @item @emph{Specific names}:
1584 @multitable @columnfractions .20 .20 .20 .25
1585 @item Name @tab Argument @tab Return type @tab Standard
1586 @item @code{ATAN(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later
1587 @item @code{DATAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
1590 @item @emph{See also}:
1591 Inverse function: @ref{TAN}
1592 Degrees function: @ref{ATAND}
1599 @section @code{ATAND} --- Arctangent function, degrees
1602 @cindex trigonometric function, tangent, inverse, degrees
1603 @cindex tangent, inverse, degrees
1606 @item @emph{Description}:
1607 @code{ATAND(X)} computes the arctangent of @var{X} in degrees (inverse of
1610 This function is for compatibility only and should be avoided in favor of
1611 standard constructs wherever possible.
1613 @item @emph{Standard}:
1614 GNU Extension, enabled with @option{-fdec-math}.
1619 @item @emph{Syntax}:
1620 @multitable @columnfractions .80
1621 @item @code{RESULT = ATAND(X)}
1622 @item @code{RESULT = ATAND(Y, X)}
1625 @item @emph{Arguments}:
1626 @multitable @columnfractions .15 .70
1627 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX};
1628 if @var{Y} is present, @var{X} shall be REAL.
1629 @item @var{Y} shall be of the same type and kind as @var{X}.
1632 @item @emph{Return value}:
1633 The return value is of the same type and kind as @var{X}.
1634 If @var{Y} is present, the result is identical to @code{ATAND2(Y,X)}.
1635 Otherwise, it is the arcus tangent of @var{X}, where the real part of
1636 the result is in degrees and lies in the range
1637 @math{-90 \leq \Re \atand(x) \leq 90}.
1639 @item @emph{Example}:
1642 real(8) :: x = 2.866_8
1644 end program test_atand
1647 @item @emph{Specific names}:
1648 @multitable @columnfractions .20 .20 .20 .25
1649 @item Name @tab Argument @tab Return type @tab Standard
1650 @item @code{ATAND(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU Extension
1651 @item @code{DATAND(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU Extension
1654 @item @emph{See also}:
1655 Inverse function: @ref{TAND}
1656 Radians function: @ref{ATAN}
1663 @section @code{ATAN2} --- Arctangent function
1666 @cindex trigonometric function, tangent, inverse
1667 @cindex tangent, inverse
1670 @item @emph{Description}:
1671 @code{ATAN2(Y, X)} computes the principal value of the argument
1672 function of the complex number @math{X + i Y}. This function can
1673 be used to transform from Cartesian into polar coordinates and
1674 allows to determine the angle in the correct quadrant.
1676 @item @emph{Standard}:
1677 Fortran 77 and later
1682 @item @emph{Syntax}:
1683 @code{RESULT = ATAN2(Y, X)}
1685 @item @emph{Arguments}:
1686 @multitable @columnfractions .15 .70
1687 @item @var{Y} @tab The type shall be @code{REAL}.
1688 @item @var{X} @tab The type and kind type parameter shall be the same as @var{Y}.
1689 If @var{Y} is zero, then @var{X} must be nonzero.
1692 @item @emph{Return value}:
1693 The return value has the same type and kind type parameter as @var{Y}. It
1694 is the principal value of the complex number @math{X + i Y}. If @var{X}
1695 is nonzero, then it lies in the range @math{-\pi \le \atan (x) \leq \pi}.
1696 The sign is positive if @var{Y} is positive. If @var{Y} is zero, then
1697 the return value is zero if @var{X} is strictly positive, @math{\pi} if
1698 @var{X} is negative and @var{Y} is positive zero (or the processor does
1699 not handle signed zeros), and @math{-\pi} if @var{X} is negative and
1700 @var{Y} is negative zero. Finally, if @var{X} is zero, then the
1701 magnitude of the result is @math{\pi/2}.
1703 @item @emph{Example}:
1706 real(4) :: x = 1.e0_4, y = 0.5e0_4
1708 end program test_atan2
1711 @item @emph{Specific names}:
1712 @multitable @columnfractions .20 .20 .20 .25
1713 @item Name @tab Argument @tab Return type @tab Standard
1714 @item @code{ATAN2(X, Y)} @tab @code{REAL(4) X, Y} @tab @code{REAL(4)} @tab Fortran 77 and later
1715 @item @code{DATAN2(X, Y)} @tab @code{REAL(8) X, Y} @tab @code{REAL(8)} @tab Fortran 77 and later
1718 @item @emph{See also}:
1720 Degrees function: @ref{ATAN2D}
1727 @section @code{ATAN2D} --- Arctangent function, degrees
1730 @cindex trigonometric function, tangent, inverse, degrees
1731 @cindex tangent, inverse, degrees
1734 @item @emph{Description}:
1735 @code{ATAN2D(Y, X)} computes the principal value of the argument
1736 function of the complex number @math{X + i Y} in degrees. This function can
1737 be used to transform from Cartesian into polar coordinates and
1738 allows to determine the angle in the correct quadrant.
1740 This function is for compatibility only and should be avoided in favor of
1741 standard constructs wherever possible.
1743 @item @emph{Standard}:
1744 GNU Extension, enabled with @option{-fdec-math}.
1749 @item @emph{Syntax}:
1750 @code{RESULT = ATAN2D(Y, X)}
1752 @item @emph{Arguments}:
1753 @multitable @columnfractions .15 .70
1754 @item @var{Y} @tab The type shall be @code{REAL}.
1755 @item @var{X} @tab The type and kind type parameter shall be the same as @var{Y}.
1756 If @var{Y} is zero, then @var{X} must be nonzero.
1759 @item @emph{Return value}:
1760 The return value has the same type and kind type parameter as @var{Y}. It
1761 is the principal value of the complex number @math{X + i Y}. If @var{X}
1762 is nonzero, then it lies in the range @math{-180 \le \atan (x) \leq 180}.
1763 The sign is positive if @var{Y} is positive. If @var{Y} is zero, then
1764 the return value is zero if @var{X} is strictly positive, @math{180} if
1765 @var{X} is negative and @var{Y} is positive zero (or the processor does
1766 not handle signed zeros), and @math{-180} if @var{X} is negative and
1767 @var{Y} is negative zero. Finally, if @var{X} is zero, then the
1768 magnitude of the result is @math{90}.
1770 @item @emph{Example}:
1773 real(4) :: x = 1.e0_4, y = 0.5e0_4
1775 end program test_atan2d
1778 @item @emph{Specific names}:
1779 @multitable @columnfractions .20 .20 .20 .25
1780 @item Name @tab Argument @tab Return type @tab Standard
1781 @item @code{ATAN2D(X, Y)} @tab @code{REAL(4) X, Y} @tab @code{REAL(4)} @tab GNU Extension
1782 @item @code{DATAN2D(X, Y)} @tab @code{REAL(8) X, Y} @tab @code{REAL(8)} @tab GNU Extension
1785 @item @emph{See also}:
1787 Radians function: @ref{ATAN2}
1794 @section @code{ATANH} --- Inverse hyperbolic tangent function
1797 @cindex area hyperbolic tangent
1798 @cindex inverse hyperbolic tangent
1799 @cindex hyperbolic function, tangent, inverse
1800 @cindex tangent, hyperbolic, inverse
1803 @item @emph{Description}:
1804 @code{ATANH(X)} computes the inverse hyperbolic tangent of @var{X}.
1806 @item @emph{Standard}:
1807 Fortran 2008 and later
1812 @item @emph{Syntax}:
1813 @code{RESULT = ATANH(X)}
1815 @item @emph{Arguments}:
1816 @multitable @columnfractions .15 .70
1817 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
1820 @item @emph{Return value}:
1821 The return value has same type and kind as @var{X}. If @var{X} is
1822 complex, the imaginary part of the result is in radians and lies between
1823 @math{-\pi/2 \leq \Im \atanh(x) \leq \pi/2}.
1825 @item @emph{Example}:
1828 REAL, DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1829 WRITE (*,*) ATANH(x)
1833 @item @emph{Specific names}:
1834 @multitable @columnfractions .20 .20 .20 .25
1835 @item Name @tab Argument @tab Return type @tab Standard
1836 @item @code{DATANH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1839 @item @emph{See also}:
1840 Inverse function: @ref{TANH}
1846 @section @code{ATOMIC_ADD} --- Atomic ADD operation
1848 @cindex Atomic subroutine, add
1851 @item @emph{Description}:
1852 @code{ATOMIC_ADD(ATOM, VALUE)} atomically adds the value of @var{VAR} to the
1853 variable @var{ATOM}. When @var{STAT} is present and the invocation was
1854 successful, it is assigned the value 0. If it is present and the invocation
1855 has failed, it is assigned a positive value; in particular, for a coindexed
1856 @var{ATOM}, if the remote image has stopped, it is assigned the value of
1857 @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has
1858 failed, the value @code{STAT_FAILED_IMAGE}.
1860 @item @emph{Standard}:
1866 @item @emph{Syntax}:
1867 @code{CALL ATOMIC_ADD (ATOM, VALUE [, STAT])}
1869 @item @emph{Arguments}:
1870 @multitable @columnfractions .15 .70
1871 @item @var{ATOM} @tab Scalar coarray or coindexed variable of integer
1872 type with @code{ATOMIC_INT_KIND} kind.
1873 @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind
1874 is different, the value is converted to the kind of @var{ATOM}.
1875 @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
1878 @item @emph{Example}:
1882 integer(atomic_int_kind) :: atom[*]
1883 call atomic_add (atom[1], this_image())
1887 @item @emph{See also}:
1888 @ref{ATOMIC_DEFINE}, @ref{ATOMIC_FETCH_ADD}, @ref{ISO_FORTRAN_ENV},
1889 @ref{ATOMIC_AND}, @ref{ATOMIC_OR}, @ref{ATOMIC_XOR}
1896 @section @code{ATOMIC_AND} --- Atomic bitwise AND operation
1898 @cindex Atomic subroutine, AND
1901 @item @emph{Description}:
1902 @code{ATOMIC_AND(ATOM, VALUE)} atomically defines @var{ATOM} with the bitwise
1903 AND between the values of @var{ATOM} and @var{VALUE}. When @var{STAT} is present
1904 and the invocation was successful, it is assigned the value 0. If it is present
1905 and the invocation has failed, it is assigned a positive value; in particular,
1906 for a coindexed @var{ATOM}, if the remote image has stopped, it is assigned the
1907 value of @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote
1908 image has failed, the value @code{STAT_FAILED_IMAGE}.
1910 @item @emph{Standard}:
1916 @item @emph{Syntax}:
1917 @code{CALL ATOMIC_AND (ATOM, VALUE [, STAT])}
1919 @item @emph{Arguments}:
1920 @multitable @columnfractions .15 .70
1921 @item @var{ATOM} @tab Scalar coarray or coindexed variable of integer
1922 type with @code{ATOMIC_INT_KIND} kind.
1923 @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind
1924 is different, the value is converted to the kind of @var{ATOM}.
1925 @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
1928 @item @emph{Example}:
1932 integer(atomic_int_kind) :: atom[*]
1933 call atomic_and (atom[1], int(b'10100011101'))
1937 @item @emph{See also}:
1938 @ref{ATOMIC_DEFINE}, @ref{ATOMIC_FETCH_AND}, @ref{ISO_FORTRAN_ENV},
1939 @ref{ATOMIC_ADD}, @ref{ATOMIC_OR}, @ref{ATOMIC_XOR}
1945 @section @code{ATOMIC_CAS} --- Atomic compare and swap
1946 @fnindex ATOMIC_DEFINE
1947 @cindex Atomic subroutine, compare and swap
1950 @item @emph{Description}:
1951 @code{ATOMIC_CAS} compares the variable @var{ATOM} with the value of
1952 @var{COMPARE}; if the value is the same, @var{ATOM} is set to the value
1953 of @var{NEW}. Additionally, @var{OLD} is set to the value of @var{ATOM}
1954 that was used for the comparison. When @var{STAT} is present and the invocation
1955 was successful, it is assigned the value 0. If it is present and the invocation
1956 has failed, it is assigned a positive value; in particular, for a coindexed
1957 @var{ATOM}, if the remote image has stopped, it is assigned the value of
1958 @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has
1959 failed, the value @code{STAT_FAILED_IMAGE}.
1961 @item @emph{Standard}:
1967 @item @emph{Syntax}:
1968 @code{CALL ATOMIC_CAS (ATOM, OLD, COMPARE, NEW [, STAT])}
1970 @item @emph{Arguments}:
1971 @multitable @columnfractions .15 .70
1972 @item @var{ATOM} @tab Scalar coarray or coindexed variable of either integer
1973 type with @code{ATOMIC_INT_KIND} kind or logical type with
1974 @code{ATOMIC_LOGICAL_KIND} kind.
1975 @item @var{OLD} @tab Scalar of the same type and kind as @var{ATOM}.
1976 @item @var{COMPARE} @tab Scalar variable of the same type and kind as
1978 @item @var{NEW} @tab Scalar variable of the same type as @var{ATOM}. If kind
1979 is different, the value is converted to the kind of @var{ATOM}.
1980 @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
1983 @item @emph{Example}:
1987 logical(atomic_logical_kind) :: atom[*], prev
1988 call atomic_cas (atom[1], prev, .false., .true.))
1992 @item @emph{See also}:
1993 @ref{ATOMIC_DEFINE}, @ref{ATOMIC_REF}, @ref{ISO_FORTRAN_ENV}
1999 @section @code{ATOMIC_DEFINE} --- Setting a variable atomically
2000 @fnindex ATOMIC_DEFINE
2001 @cindex Atomic subroutine, define
2004 @item @emph{Description}:
2005 @code{ATOMIC_DEFINE(ATOM, VALUE)} defines the variable @var{ATOM} with the value
2006 @var{VALUE} atomically. When @var{STAT} is present and the invocation was
2007 successful, it is assigned the value 0. If it is present and the invocation
2008 has failed, it is assigned a positive value; in particular, for a coindexed
2009 @var{ATOM}, if the remote image has stopped, it is assigned the value of
2010 @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has
2011 failed, the value @code{STAT_FAILED_IMAGE}.
2013 @item @emph{Standard}:
2014 Fortran 2008 and later; with @var{STAT}, TS 18508 or later
2019 @item @emph{Syntax}:
2020 @code{CALL ATOMIC_DEFINE (ATOM, VALUE [, STAT])}
2022 @item @emph{Arguments}:
2023 @multitable @columnfractions .15 .70
2024 @item @var{ATOM} @tab Scalar coarray or coindexed variable of either integer
2025 type with @code{ATOMIC_INT_KIND} kind or logical type with
2026 @code{ATOMIC_LOGICAL_KIND} kind.
2028 @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind
2029 is different, the value is converted to the kind of @var{ATOM}.
2030 @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
2033 @item @emph{Example}:
2037 integer(atomic_int_kind) :: atom[*]
2038 call atomic_define (atom[1], this_image())
2042 @item @emph{See also}:
2043 @ref{ATOMIC_REF}, @ref{ATOMIC_CAS}, @ref{ISO_FORTRAN_ENV},
2044 @ref{ATOMIC_ADD}, @ref{ATOMIC_AND}, @ref{ATOMIC_OR}, @ref{ATOMIC_XOR}
2049 @node ATOMIC_FETCH_ADD
2050 @section @code{ATOMIC_FETCH_ADD} --- Atomic ADD operation with prior fetch
2051 @fnindex ATOMIC_FETCH_ADD
2052 @cindex Atomic subroutine, ADD with fetch
2055 @item @emph{Description}:
2056 @code{ATOMIC_FETCH_ADD(ATOM, VALUE, OLD)} atomically stores the value of
2057 @var{ATOM} in @var{OLD} and adds the value of @var{VAR} to the
2058 variable @var{ATOM}. When @var{STAT} is present and the invocation was
2059 successful, it is assigned the value 0. If it is present and the invocation
2060 has failed, it is assigned a positive value; in particular, for a coindexed
2061 @var{ATOM}, if the remote image has stopped, it is assigned the value of
2062 @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has
2063 failed, the value @code{STAT_FAILED_IMAGE}.
2065 @item @emph{Standard}:
2071 @item @emph{Syntax}:
2072 @code{CALL ATOMIC_FETCH_ADD (ATOM, VALUE, old [, STAT])}
2074 @item @emph{Arguments}:
2075 @multitable @columnfractions .15 .70
2076 @item @var{ATOM} @tab Scalar coarray or coindexed variable of integer
2077 type with @code{ATOMIC_INT_KIND} kind.
2078 @code{ATOMIC_LOGICAL_KIND} kind.
2080 @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind
2081 is different, the value is converted to the kind of @var{ATOM}.
2082 @item @var{OLD} @tab Scalar of the same type and kind as @var{ATOM}.
2083 @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
2086 @item @emph{Example}:
2090 integer(atomic_int_kind) :: atom[*], old
2091 call atomic_add (atom[1], this_image(), old)
2095 @item @emph{See also}:
2096 @ref{ATOMIC_DEFINE}, @ref{ATOMIC_ADD}, @ref{ISO_FORTRAN_ENV},
2097 @ref{ATOMIC_FETCH_AND}, @ref{ATOMIC_FETCH_OR}, @ref{ATOMIC_FETCH_XOR}
2102 @node ATOMIC_FETCH_AND
2103 @section @code{ATOMIC_FETCH_AND} --- Atomic bitwise AND operation with prior fetch
2104 @fnindex ATOMIC_FETCH_AND
2105 @cindex Atomic subroutine, AND with fetch
2108 @item @emph{Description}:
2109 @code{ATOMIC_AND(ATOM, VALUE)} atomically stores the value of @var{ATOM} in
2110 @var{OLD} and defines @var{ATOM} with the bitwise AND between the values of
2111 @var{ATOM} and @var{VALUE}. When @var{STAT} is present and the invocation was
2112 successful, it is assigned the value 0. If it is present and the invocation has
2113 failed, it is assigned a positive value; in particular, for a coindexed
2114 @var{ATOM}, if the remote image has stopped, it is assigned the value of
2115 @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has
2116 failed, the value @code{STAT_FAILED_IMAGE}.
2118 @item @emph{Standard}:
2124 @item @emph{Syntax}:
2125 @code{CALL ATOMIC_FETCH_AND (ATOM, VALUE, OLD [, STAT])}
2127 @item @emph{Arguments}:
2128 @multitable @columnfractions .15 .70
2129 @item @var{ATOM} @tab Scalar coarray or coindexed variable of integer
2130 type with @code{ATOMIC_INT_KIND} kind.
2131 @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind
2132 is different, the value is converted to the kind of @var{ATOM}.
2133 @item @var{OLD} @tab Scalar of the same type and kind as @var{ATOM}.
2134 @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
2137 @item @emph{Example}:
2141 integer(atomic_int_kind) :: atom[*], old
2142 call atomic_fetch_and (atom[1], int(b'10100011101'), old)
2146 @item @emph{See also}:
2147 @ref{ATOMIC_DEFINE}, @ref{ATOMIC_AND}, @ref{ISO_FORTRAN_ENV},
2148 @ref{ATOMIC_FETCH_ADD}, @ref{ATOMIC_FETCH_OR}, @ref{ATOMIC_FETCH_XOR}
2153 @node ATOMIC_FETCH_OR
2154 @section @code{ATOMIC_FETCH_OR} --- Atomic bitwise OR operation with prior fetch
2155 @fnindex ATOMIC_FETCH_OR
2156 @cindex Atomic subroutine, OR with fetch
2159 @item @emph{Description}:
2160 @code{ATOMIC_OR(ATOM, VALUE)} atomically stores the value of @var{ATOM} in
2161 @var{OLD} and defines @var{ATOM} with the bitwise OR between the values of
2162 @var{ATOM} and @var{VALUE}. When @var{STAT} is present and the invocation was
2163 successful, it is assigned the value 0. If it is present and the invocation has
2164 failed, it is assigned a positive value; in particular, for a coindexed
2165 @var{ATOM}, if the remote image has stopped, it is assigned the value of
2166 @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has
2167 failed, the value @code{STAT_FAILED_IMAGE}.
2169 @item @emph{Standard}:
2175 @item @emph{Syntax}:
2176 @code{CALL ATOMIC_FETCH_OR (ATOM, VALUE, OLD [, STAT])}
2178 @item @emph{Arguments}:
2179 @multitable @columnfractions .15 .70
2180 @item @var{ATOM} @tab Scalar coarray or coindexed variable of integer
2181 type with @code{ATOMIC_INT_KIND} kind.
2182 @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind
2183 is different, the value is converted to the kind of @var{ATOM}.
2184 @item @var{OLD} @tab Scalar of the same type and kind as @var{ATOM}.
2185 @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
2188 @item @emph{Example}:
2192 integer(atomic_int_kind) :: atom[*], old
2193 call atomic_fetch_or (atom[1], int(b'10100011101'), old)
2197 @item @emph{See also}:
2198 @ref{ATOMIC_DEFINE}, @ref{ATOMIC_OR}, @ref{ISO_FORTRAN_ENV},
2199 @ref{ATOMIC_FETCH_ADD}, @ref{ATOMIC_FETCH_AND}, @ref{ATOMIC_FETCH_XOR}
2204 @node ATOMIC_FETCH_XOR
2205 @section @code{ATOMIC_FETCH_XOR} --- Atomic bitwise XOR operation with prior fetch
2206 @fnindex ATOMIC_FETCH_XOR
2207 @cindex Atomic subroutine, XOR with fetch
2210 @item @emph{Description}:
2211 @code{ATOMIC_XOR(ATOM, VALUE)} atomically stores the value of @var{ATOM} in
2212 @var{OLD} and defines @var{ATOM} with the bitwise XOR between the values of
2213 @var{ATOM} and @var{VALUE}. When @var{STAT} is present and the invocation was
2214 successful, it is assigned the value 0. If it is present and the invocation has
2215 failed, it is assigned a positive value; in particular, for a coindexed
2216 @var{ATOM}, if the remote image has stopped, it is assigned the value of
2217 @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image has
2218 failed, the value @code{STAT_FAILED_IMAGE}.
2220 @item @emph{Standard}:
2226 @item @emph{Syntax}:
2227 @code{CALL ATOMIC_FETCH_XOR (ATOM, VALUE, OLD [, STAT])}
2229 @item @emph{Arguments}:
2230 @multitable @columnfractions .15 .70
2231 @item @var{ATOM} @tab Scalar coarray or coindexed variable of integer
2232 type with @code{ATOMIC_INT_KIND} kind.
2233 @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind
2234 is different, the value is converted to the kind of @var{ATOM}.
2235 @item @var{OLD} @tab Scalar of the same type and kind as @var{ATOM}.
2236 @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
2239 @item @emph{Example}:
2243 integer(atomic_int_kind) :: atom[*], old
2244 call atomic_fetch_xor (atom[1], int(b'10100011101'), old)
2248 @item @emph{See also}:
2249 @ref{ATOMIC_DEFINE}, @ref{ATOMIC_XOR}, @ref{ISO_FORTRAN_ENV},
2250 @ref{ATOMIC_FETCH_ADD}, @ref{ATOMIC_FETCH_AND}, @ref{ATOMIC_FETCH_OR}
2256 @section @code{ATOMIC_OR} --- Atomic bitwise OR operation
2258 @cindex Atomic subroutine, OR
2261 @item @emph{Description}:
2262 @code{ATOMIC_OR(ATOM, VALUE)} atomically defines @var{ATOM} with the bitwise
2263 AND between the values of @var{ATOM} and @var{VALUE}. When @var{STAT} is present
2264 and the invocation was successful, it is assigned the value 0. If it is present
2265 and the invocation has failed, it is assigned a positive value; in particular,
2266 for a coindexed @var{ATOM}, if the remote image has stopped, it is assigned the
2267 value of @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote
2268 image has failed, the value @code{STAT_FAILED_IMAGE}.
2270 @item @emph{Standard}:
2276 @item @emph{Syntax}:
2277 @code{CALL ATOMIC_OR (ATOM, VALUE [, STAT])}
2279 @item @emph{Arguments}:
2280 @multitable @columnfractions .15 .70
2281 @item @var{ATOM} @tab Scalar coarray or coindexed variable of integer
2282 type with @code{ATOMIC_INT_KIND} kind.
2283 @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind
2284 is different, the value is converted to the kind of @var{ATOM}.
2285 @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
2288 @item @emph{Example}:
2292 integer(atomic_int_kind) :: atom[*]
2293 call atomic_or (atom[1], int(b'10100011101'))
2297 @item @emph{See also}:
2298 @ref{ATOMIC_DEFINE}, @ref{ATOMIC_FETCH_OR}, @ref{ISO_FORTRAN_ENV},
2299 @ref{ATOMIC_ADD}, @ref{ATOMIC_OR}, @ref{ATOMIC_XOR}
2305 @section @code{ATOMIC_REF} --- Obtaining the value of a variable atomically
2307 @cindex Atomic subroutine, reference
2310 @item @emph{Description}:
2311 @code{ATOMIC_DEFINE(ATOM, VALUE)} atomically assigns the value of the
2312 variable @var{ATOM} to @var{VALUE}. When @var{STAT} is present and the
2313 invocation was successful, it is assigned the value 0. If it is present and the
2314 invocation has failed, it is assigned a positive value; in particular, for a
2315 coindexed @var{ATOM}, if the remote image has stopped, it is assigned the value
2316 of @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote image
2317 has failed, the value @code{STAT_FAILED_IMAGE}.
2320 @item @emph{Standard}:
2321 Fortran 2008 and later; with @var{STAT}, TS 18508 or later
2326 @item @emph{Syntax}:
2327 @code{CALL ATOMIC_REF(VALUE, ATOM [, STAT])}
2329 @item @emph{Arguments}:
2330 @multitable @columnfractions .15 .70
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{ATOM} @tab Scalar coarray or coindexed variable of either integer
2334 type with @code{ATOMIC_INT_KIND} kind or logical type with
2335 @code{ATOMIC_LOGICAL_KIND} kind.
2336 @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
2339 @item @emph{Example}:
2343 logical(atomic_logical_kind) :: atom[*]
2345 call atomic_ref (atom, .false.)
2347 call atomic_ref (atom, val)
2354 @item @emph{See also}:
2355 @ref{ATOMIC_DEFINE}, @ref{ATOMIC_CAS}, @ref{ISO_FORTRAN_ENV},
2356 @ref{ATOMIC_FETCH_ADD}, @ref{ATOMIC_FETCH_AND}, @ref{ATOMIC_FETCH_OR},
2357 @ref{ATOMIC_FETCH_XOR}
2362 @section @code{ATOMIC_XOR} --- Atomic bitwise OR operation
2364 @cindex Atomic subroutine, XOR
2367 @item @emph{Description}:
2368 @code{ATOMIC_AND(ATOM, VALUE)} atomically defines @var{ATOM} with the bitwise
2369 XOR between the values of @var{ATOM} and @var{VALUE}. When @var{STAT} is present
2370 and the invocation was successful, it is assigned the value 0. If it is present
2371 and the invocation has failed, it is assigned a positive value; in particular,
2372 for a coindexed @var{ATOM}, if the remote image has stopped, it is assigned the
2373 value of @code{ISO_FORTRAN_ENV}'s @code{STAT_STOPPED_IMAGE} and if the remote
2374 image has failed, the value @code{STAT_FAILED_IMAGE}.
2376 @item @emph{Standard}:
2382 @item @emph{Syntax}:
2383 @code{CALL ATOMIC_XOR (ATOM, VALUE [, STAT])}
2385 @item @emph{Arguments}:
2386 @multitable @columnfractions .15 .70
2387 @item @var{ATOM} @tab Scalar coarray or coindexed variable of integer
2388 type with @code{ATOMIC_INT_KIND} kind.
2389 @item @var{VALUE} @tab Scalar of the same type as @var{ATOM}. If the kind
2390 is different, the value is converted to the kind of @var{ATOM}.
2391 @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
2394 @item @emph{Example}:
2398 integer(atomic_int_kind) :: atom[*]
2399 call atomic_xor (atom[1], int(b'10100011101'))
2403 @item @emph{See also}:
2404 @ref{ATOMIC_DEFINE}, @ref{ATOMIC_FETCH_XOR}, @ref{ISO_FORTRAN_ENV},
2405 @ref{ATOMIC_ADD}, @ref{ATOMIC_OR}, @ref{ATOMIC_XOR}
2410 @section @code{BACKTRACE} --- Show a backtrace
2415 @item @emph{Description}:
2416 @code{BACKTRACE} shows a backtrace at an arbitrary place in user code. Program
2417 execution continues normally afterwards. The backtrace information is printed
2418 to the unit corresponding to @code{ERROR_UNIT} in @code{ISO_FORTRAN_ENV}.
2420 @item @emph{Standard}:
2426 @item @emph{Syntax}:
2427 @code{CALL BACKTRACE}
2429 @item @emph{Arguments}:
2432 @item @emph{See also}:
2439 @section @code{BESSEL_J0} --- Bessel function of the first kind of order 0
2443 @cindex Bessel function, first kind
2446 @item @emph{Description}:
2447 @code{BESSEL_J0(X)} computes the Bessel function of the first kind of
2448 order 0 of @var{X}. This function is available under the name
2449 @code{BESJ0} as a GNU extension.
2451 @item @emph{Standard}:
2452 Fortran 2008 and later
2457 @item @emph{Syntax}:
2458 @code{RESULT = BESSEL_J0(X)}
2460 @item @emph{Arguments}:
2461 @multitable @columnfractions .15 .70
2462 @item @var{X} @tab The type shall be @code{REAL}.
2465 @item @emph{Return value}:
2466 The return value is of type @code{REAL} and lies in the
2467 range @math{ - 0.4027... \leq Bessel (0,x) \leq 1}. It has the same
2470 @item @emph{Example}:
2473 real(8) :: x = 0.0_8
2475 end program test_besj0
2478 @item @emph{Specific names}:
2479 @multitable @columnfractions .20 .20 .20 .25
2480 @item Name @tab Argument @tab Return type @tab Standard
2481 @item @code{DBESJ0(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
2488 @section @code{BESSEL_J1} --- Bessel function of the first kind of order 1
2492 @cindex Bessel function, first kind
2495 @item @emph{Description}:
2496 @code{BESSEL_J1(X)} computes the Bessel function of the first kind of
2497 order 1 of @var{X}. This function is available under the name
2498 @code{BESJ1} as a GNU extension.
2500 @item @emph{Standard}:
2506 @item @emph{Syntax}:
2507 @code{RESULT = BESSEL_J1(X)}
2509 @item @emph{Arguments}:
2510 @multitable @columnfractions .15 .70
2511 @item @var{X} @tab The type shall be @code{REAL}.
2514 @item @emph{Return value}:
2515 The return value is of type @code{REAL} and lies in the
2516 range @math{ - 0.5818... \leq Bessel (0,x) \leq 0.5818 }. It has the same
2519 @item @emph{Example}:
2522 real(8) :: x = 1.0_8
2524 end program test_besj1
2527 @item @emph{Specific names}:
2528 @multitable @columnfractions .20 .20 .20 .25
2529 @item Name @tab Argument @tab Return type @tab Standard
2530 @item @code{DBESJ1(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
2537 @section @code{BESSEL_JN} --- Bessel function of the first kind
2541 @cindex Bessel function, first kind
2544 @item @emph{Description}:
2545 @code{BESSEL_JN(N, X)} computes the Bessel function of the first kind of
2546 order @var{N} of @var{X}. This function is available under the name
2547 @code{BESJN} as a GNU extension. If @var{N} and @var{X} are arrays,
2548 their ranks and shapes shall conform.
2550 @code{BESSEL_JN(N1, N2, X)} returns an array with the Bessel functions
2551 of the first kind of the orders @var{N1} to @var{N2}.
2553 @item @emph{Standard}:
2554 Fortran 2008 and later, negative @var{N} is allowed as GNU extension
2557 Elemental function, except for the transformational function
2558 @code{BESSEL_JN(N1, N2, X)}
2560 @item @emph{Syntax}:
2561 @multitable @columnfractions .80
2562 @item @code{RESULT = BESSEL_JN(N, X)}
2563 @item @code{RESULT = BESSEL_JN(N1, N2, X)}
2566 @item @emph{Arguments}:
2567 @multitable @columnfractions .15 .70
2568 @item @var{N} @tab Shall be a scalar or an array of type @code{INTEGER}.
2569 @item @var{N1} @tab Shall be a non-negative scalar of type @code{INTEGER}.
2570 @item @var{N2} @tab Shall be a non-negative scalar of type @code{INTEGER}.
2571 @item @var{X} @tab Shall be a scalar or an array of type @code{REAL};
2572 for @code{BESSEL_JN(N1, N2, X)} it shall be scalar.
2575 @item @emph{Return value}:
2576 The return value is a scalar of type @code{REAL}. It has the same
2580 The transformational function uses a recurrence algorithm which might,
2581 for some values of @var{X}, lead to different results than calls to
2582 the elemental function.
2584 @item @emph{Example}:
2587 real(8) :: x = 1.0_8
2589 end program test_besjn
2592 @item @emph{Specific names}:
2593 @multitable @columnfractions .20 .20 .20 .25
2594 @item Name @tab Argument @tab Return type @tab Standard
2595 @item @code{DBESJN(N, X)} @tab @code{INTEGER N} @tab @code{REAL(8)} @tab GNU extension
2596 @item @tab @code{REAL(8) X} @tab @tab
2603 @section @code{BESSEL_Y0} --- Bessel function of the second kind of order 0
2607 @cindex Bessel function, second kind
2610 @item @emph{Description}:
2611 @code{BESSEL_Y0(X)} computes the Bessel function of the second kind of
2612 order 0 of @var{X}. This function is available under the name
2613 @code{BESY0} as a GNU extension.
2615 @item @emph{Standard}:
2616 Fortran 2008 and later
2621 @item @emph{Syntax}:
2622 @code{RESULT = BESSEL_Y0(X)}
2624 @item @emph{Arguments}:
2625 @multitable @columnfractions .15 .70
2626 @item @var{X} @tab The type shall be @code{REAL}.
2629 @item @emph{Return value}:
2630 The return value is of type @code{REAL}. It has the same kind as @var{X}.
2632 @item @emph{Example}:
2635 real(8) :: x = 0.0_8
2637 end program test_besy0
2640 @item @emph{Specific names}:
2641 @multitable @columnfractions .20 .20 .20 .25
2642 @item Name @tab Argument @tab Return type @tab Standard
2643 @item @code{DBESY0(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
2650 @section @code{BESSEL_Y1} --- Bessel function of the second kind of order 1
2654 @cindex Bessel function, second kind
2657 @item @emph{Description}:
2658 @code{BESSEL_Y1(X)} computes the Bessel function of the second kind of
2659 order 1 of @var{X}. This function is available under the name
2660 @code{BESY1} as a GNU extension.
2662 @item @emph{Standard}:
2663 Fortran 2008 and later
2668 @item @emph{Syntax}:
2669 @code{RESULT = BESSEL_Y1(X)}
2671 @item @emph{Arguments}:
2672 @multitable @columnfractions .15 .70
2673 @item @var{X} @tab The type shall be @code{REAL}.
2676 @item @emph{Return value}:
2677 The return value is of type @code{REAL}. It has the same kind as @var{X}.
2679 @item @emph{Example}:
2682 real(8) :: x = 1.0_8
2684 end program test_besy1
2687 @item @emph{Specific names}:
2688 @multitable @columnfractions .20 .20 .20 .25
2689 @item Name @tab Argument @tab Return type @tab Standard
2690 @item @code{DBESY1(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
2697 @section @code{BESSEL_YN} --- Bessel function of the second kind
2701 @cindex Bessel function, second kind
2704 @item @emph{Description}:
2705 @code{BESSEL_YN(N, X)} computes the Bessel function of the second kind of
2706 order @var{N} of @var{X}. This function is available under the name
2707 @code{BESYN} as a GNU extension. If @var{N} and @var{X} are arrays,
2708 their ranks and shapes shall conform.
2710 @code{BESSEL_YN(N1, N2, X)} returns an array with the Bessel functions
2711 of the first kind of the orders @var{N1} to @var{N2}.
2713 @item @emph{Standard}:
2714 Fortran 2008 and later, negative @var{N} is allowed as GNU extension
2717 Elemental function, except for the transformational function
2718 @code{BESSEL_YN(N1, N2, X)}
2720 @item @emph{Syntax}:
2721 @multitable @columnfractions .80
2722 @item @code{RESULT = BESSEL_YN(N, X)}
2723 @item @code{RESULT = BESSEL_YN(N1, N2, X)}
2726 @item @emph{Arguments}:
2727 @multitable @columnfractions .15 .70
2728 @item @var{N} @tab Shall be a scalar or an array of type @code{INTEGER} .
2729 @item @var{N1} @tab Shall be a non-negative scalar of type @code{INTEGER}.
2730 @item @var{N2} @tab Shall be a non-negative scalar of type @code{INTEGER}.
2731 @item @var{X} @tab Shall be a scalar or an array of type @code{REAL};
2732 for @code{BESSEL_YN(N1, N2, X)} it shall be scalar.
2735 @item @emph{Return value}:
2736 The return value is a scalar of type @code{REAL}. It has the same
2740 The transformational function uses a recurrence algorithm which might,
2741 for some values of @var{X}, lead to different results than calls to
2742 the elemental function.
2744 @item @emph{Example}:
2747 real(8) :: x = 1.0_8
2749 end program test_besyn
2752 @item @emph{Specific names}:
2753 @multitable @columnfractions .20 .20 .20 .25
2754 @item Name @tab Argument @tab Return type @tab Standard
2755 @item @code{DBESYN(N,X)} @tab @code{INTEGER N} @tab @code{REAL(8)} @tab GNU extension
2756 @item @tab @code{REAL(8) X} @tab @tab
2763 @section @code{BGE} --- Bitwise greater than or equal to
2765 @cindex bitwise comparison
2768 @item @emph{Description}:
2769 Determines whether an integral is a bitwise greater than or equal to
2772 @item @emph{Standard}:
2773 Fortran 2008 and later
2778 @item @emph{Syntax}:
2779 @code{RESULT = BGE(I, J)}
2781 @item @emph{Arguments}:
2782 @multitable @columnfractions .15 .70
2783 @item @var{I} @tab Shall be of @code{INTEGER} type.
2784 @item @var{J} @tab Shall be of @code{INTEGER} type, and of the same kind
2788 @item @emph{Return value}:
2789 The return value is of type @code{LOGICAL} and of the default kind.
2791 @item @emph{See also}:
2792 @ref{BGT}, @ref{BLE}, @ref{BLT}
2798 @section @code{BGT} --- Bitwise greater than
2800 @cindex bitwise comparison
2803 @item @emph{Description}:
2804 Determines whether an integral is a bitwise greater than another.
2806 @item @emph{Standard}:
2807 Fortran 2008 and later
2812 @item @emph{Syntax}:
2813 @code{RESULT = BGT(I, J)}
2815 @item @emph{Arguments}:
2816 @multitable @columnfractions .15 .70
2817 @item @var{I} @tab Shall be of @code{INTEGER} type.
2818 @item @var{J} @tab Shall be of @code{INTEGER} type, and of the same kind
2822 @item @emph{Return value}:
2823 The return value is of type @code{LOGICAL} and of the default kind.
2825 @item @emph{See also}:
2826 @ref{BGE}, @ref{BLE}, @ref{BLT}
2832 @section @code{BIT_SIZE} --- Bit size inquiry function
2834 @cindex bits, number of
2835 @cindex size of a variable, in bits
2838 @item @emph{Description}:
2839 @code{BIT_SIZE(I)} returns the number of bits (integer precision plus sign bit)
2840 represented by the type of @var{I}. The result of @code{BIT_SIZE(I)} is
2841 independent of the actual value of @var{I}.
2843 @item @emph{Standard}:
2844 Fortran 95 and later
2849 @item @emph{Syntax}:
2850 @code{RESULT = BIT_SIZE(I)}
2852 @item @emph{Arguments}:
2853 @multitable @columnfractions .15 .70
2854 @item @var{I} @tab The type shall be @code{INTEGER}.
2857 @item @emph{Return value}:
2858 The return value is of type @code{INTEGER}
2860 @item @emph{Example}:
2862 program test_bit_size
2867 end program test_bit_size
2874 @section @code{BLE} --- Bitwise less than or equal to
2876 @cindex bitwise comparison
2879 @item @emph{Description}:
2880 Determines whether an integral is a bitwise less than or equal to
2883 @item @emph{Standard}:
2884 Fortran 2008 and later
2889 @item @emph{Syntax}:
2890 @code{RESULT = BLE(I, J)}
2892 @item @emph{Arguments}:
2893 @multitable @columnfractions .15 .70
2894 @item @var{I} @tab Shall be of @code{INTEGER} type.
2895 @item @var{J} @tab Shall be of @code{INTEGER} type, and of the same kind
2899 @item @emph{Return value}:
2900 The return value is of type @code{LOGICAL} and of the default kind.
2902 @item @emph{See also}:
2903 @ref{BGT}, @ref{BGE}, @ref{BLT}
2909 @section @code{BLT} --- Bitwise less than
2911 @cindex bitwise comparison
2914 @item @emph{Description}:
2915 Determines whether an integral is a bitwise less than another.
2917 @item @emph{Standard}:
2918 Fortran 2008 and later
2923 @item @emph{Syntax}:
2924 @code{RESULT = BLT(I, J)}
2926 @item @emph{Arguments}:
2927 @multitable @columnfractions .15 .70
2928 @item @var{I} @tab Shall be of @code{INTEGER} type.
2929 @item @var{J} @tab Shall be of @code{INTEGER} type, and of the same kind
2933 @item @emph{Return value}:
2934 The return value is of type @code{LOGICAL} and of the default kind.
2936 @item @emph{See also}:
2937 @ref{BGE}, @ref{BGT}, @ref{BLE}
2943 @section @code{BTEST} --- Bit test function
2949 @cindex bits, testing
2952 @item @emph{Description}:
2953 @code{BTEST(I,POS)} returns logical @code{.TRUE.} if the bit at @var{POS}
2954 in @var{I} is set. The counting of the bits starts at 0.
2956 @item @emph{Standard}:
2957 Fortran 95 and later, has overloads that are GNU extensions
2962 @item @emph{Syntax}:
2963 @code{RESULT = BTEST(I, POS)}
2965 @item @emph{Arguments}:
2966 @multitable @columnfractions .15 .70
2967 @item @var{I} @tab The type shall be @code{INTEGER}.
2968 @item @var{POS} @tab The type shall be @code{INTEGER}.
2971 @item @emph{Return value}:
2972 The return value is of type @code{LOGICAL}
2974 @item @emph{Example}:
2977 integer :: i = 32768 + 1024 + 64
2981 bool = btest(i, pos)
2984 end program test_btest
2987 @item @emph{Specific names}:
2988 @multitable @columnfractions .20 .20 .20 .25
2989 @item Name @tab Argument @tab Return type @tab Standard
2990 @item @code{BTEST(I,POS)} @tab @code{INTEGER I,POS} @tab @code{LOGICAL} @tab F95 and later
2991 @item @code{BBTEST(I,POS)} @tab @code{INTEGER(1) I,POS} @tab @code{LOGICAL(1)} @tab GNU extension
2992 @item @code{BITEST(I,POS)} @tab @code{INTEGER(2) I,POS} @tab @code{LOGICAL(2)} @tab GNU extension
2993 @item @code{BJTEST(I,POS)} @tab @code{INTEGER(4) I,POS} @tab @code{LOGICAL(4)} @tab GNU extension
2994 @item @code{BKTEST(I,POS)} @tab @code{INTEGER(8) I,POS} @tab @code{LOGICAL(8)} @tab GNU extension
2999 @section @code{C_ASSOCIATED} --- Status of a C pointer
3000 @fnindex C_ASSOCIATED
3001 @cindex association status, C pointer
3002 @cindex pointer, C association status
3005 @item @emph{Description}:
3006 @code{C_ASSOCIATED(c_ptr_1[, c_ptr_2])} determines the status of the C pointer
3007 @var{c_ptr_1} or if @var{c_ptr_1} is associated with the target @var{c_ptr_2}.
3009 @item @emph{Standard}:
3010 Fortran 2003 and later
3015 @item @emph{Syntax}:
3016 @code{RESULT = C_ASSOCIATED(c_ptr_1[, c_ptr_2])}
3018 @item @emph{Arguments}:
3019 @multitable @columnfractions .15 .70
3020 @item @var{c_ptr_1} @tab Scalar of the type @code{C_PTR} or @code{C_FUNPTR}.
3021 @item @var{c_ptr_2} @tab (Optional) Scalar of the same type as @var{c_ptr_1}.
3024 @item @emph{Return value}:
3025 The return value is of type @code{LOGICAL}; it is @code{.false.} if either
3026 @var{c_ptr_1} is a C NULL pointer or if @var{c_ptr1} and @var{c_ptr_2}
3027 point to different addresses.
3029 @item @emph{Example}:
3031 subroutine association_test(a,b)
3032 use iso_c_binding, only: c_associated, c_loc, c_ptr
3036 if(c_associated(b, c_loc(a))) &
3037 stop 'b and a do not point to same target'
3038 end subroutine association_test
3041 @item @emph{See also}:
3042 @ref{C_LOC}, @ref{C_FUNLOC}
3047 @section @code{C_F_POINTER} --- Convert C into Fortran pointer
3048 @fnindex C_F_POINTER
3049 @cindex pointer, convert C to Fortran
3052 @item @emph{Description}:
3053 @code{C_F_POINTER(CPTR, FPTR[, SHAPE])} assigns the target of the C pointer
3054 @var{CPTR} to the Fortran pointer @var{FPTR} and specifies its shape.
3056 @item @emph{Standard}:
3057 Fortran 2003 and later
3062 @item @emph{Syntax}:
3063 @code{CALL C_F_POINTER(CPTR, FPTR[, SHAPE])}
3065 @item @emph{Arguments}:
3066 @multitable @columnfractions .15 .70
3067 @item @var{CPTR} @tab scalar of the type @code{C_PTR}. It is
3069 @item @var{FPTR} @tab pointer interoperable with @var{cptr}. It is
3071 @item @var{SHAPE} @tab (Optional) Rank-one array of type @code{INTEGER}
3072 with @code{INTENT(IN)}. It shall be present
3073 if and only if @var{fptr} is an array. The size
3074 must be equal to the rank of @var{fptr}.
3077 @item @emph{Example}:
3083 subroutine my_routine(p) bind(c,name='myC_func')
3085 type(c_ptr), intent(out) :: p
3089 real,pointer :: a(:)
3090 call my_routine(cptr)
3091 call c_f_pointer(cptr, a, [12])
3095 @item @emph{See also}:
3096 @ref{C_LOC}, @ref{C_F_PROCPOINTER}
3100 @node C_F_PROCPOINTER
3101 @section @code{C_F_PROCPOINTER} --- Convert C into Fortran procedure pointer
3102 @fnindex C_F_PROCPOINTER
3103 @cindex pointer, C address of pointers
3106 @item @emph{Description}:
3107 @code{C_F_PROCPOINTER(CPTR, FPTR)} Assign the target of the C function pointer
3108 @var{CPTR} to the Fortran procedure pointer @var{FPTR}.
3110 @item @emph{Standard}:
3111 Fortran 2003 and later
3116 @item @emph{Syntax}:
3117 @code{CALL C_F_PROCPOINTER(cptr, fptr)}
3119 @item @emph{Arguments}:
3120 @multitable @columnfractions .15 .70
3121 @item @var{CPTR} @tab scalar of the type @code{C_FUNPTR}. It is
3123 @item @var{FPTR} @tab procedure pointer interoperable with @var{cptr}. It is
3127 @item @emph{Example}:
3135 real(c_float), intent(in) :: a
3136 real(c_float) :: func
3140 function getIterFunc() bind(c,name="getIterFunc")
3142 type(c_funptr) :: getIterFunc
3145 type(c_funptr) :: cfunptr
3146 procedure(func), pointer :: myFunc
3147 cfunptr = getIterFunc()
3148 call c_f_procpointer(cfunptr, myFunc)
3152 @item @emph{See also}:
3153 @ref{C_LOC}, @ref{C_F_POINTER}
3158 @section @code{C_FUNLOC} --- Obtain the C address of a procedure
3160 @cindex pointer, C address of procedures
3163 @item @emph{Description}:
3164 @code{C_FUNLOC(x)} determines the C address of the argument.
3166 @item @emph{Standard}:
3167 Fortran 2003 and later
3172 @item @emph{Syntax}:
3173 @code{RESULT = C_FUNLOC(x)}
3175 @item @emph{Arguments}:
3176 @multitable @columnfractions .15 .70
3177 @item @var{x} @tab Interoperable function or pointer to such function.
3180 @item @emph{Return value}:
3181 The return value is of type @code{C_FUNPTR} and contains the C address
3184 @item @emph{Example}:
3190 subroutine sub(a) bind(c)
3200 subroutine my_routine(p) bind(c,name='myC_func')
3202 type(c_funptr), intent(in) :: p
3205 call my_routine(c_funloc(sub))
3209 @item @emph{See also}:
3210 @ref{C_ASSOCIATED}, @ref{C_LOC}, @ref{C_F_POINTER}, @ref{C_F_PROCPOINTER}
3215 @section @code{C_LOC} --- Obtain the C address of an object
3217 @cindex procedure pointer, convert C to Fortran
3220 @item @emph{Description}:
3221 @code{C_LOC(X)} determines the C address of the argument.
3223 @item @emph{Standard}:
3224 Fortran 2003 and later
3229 @item @emph{Syntax}:
3230 @code{RESULT = C_LOC(X)}
3232 @item @emph{Arguments}:
3233 @multitable @columnfractions .10 .75
3234 @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.
3238 @item @emph{Return value}:
3239 The return value is of type @code{C_PTR} and contains the C address
3242 @item @emph{Example}:
3244 subroutine association_test(a,b)
3245 use iso_c_binding, only: c_associated, c_loc, c_ptr
3249 if(c_associated(b, c_loc(a))) &
3250 stop 'b and a do not point to same target'
3251 end subroutine association_test
3254 @item @emph{See also}:
3255 @ref{C_ASSOCIATED}, @ref{C_FUNLOC}, @ref{C_F_POINTER}, @ref{C_F_PROCPOINTER}
3260 @section @code{C_SIZEOF} --- Size in bytes of an expression
3262 @cindex expression size
3263 @cindex size of an expression
3266 @item @emph{Description}:
3267 @code{C_SIZEOF(X)} calculates the number of bytes of storage the
3268 expression @code{X} occupies.
3270 @item @emph{Standard}:
3274 Inquiry function of the module @code{ISO_C_BINDING}
3276 @item @emph{Syntax}:
3277 @code{N = C_SIZEOF(X)}
3279 @item @emph{Arguments}:
3280 @multitable @columnfractions .15 .70
3281 @item @var{X} @tab The argument shall be an interoperable data entity.
3284 @item @emph{Return value}:
3285 The return value is of type integer and of the system-dependent kind
3286 @code{C_SIZE_T} (from the @code{ISO_C_BINDING} module). Its value is the
3287 number of bytes occupied by the argument. If the argument has the
3288 @code{POINTER} attribute, the number of bytes of the storage area pointed
3289 to is returned. If the argument is of a derived type with @code{POINTER}
3290 or @code{ALLOCATABLE} components, the return value does not account for
3291 the sizes of the data pointed to by these components.
3293 @item @emph{Example}:
3297 real(c_float) :: r, s(5)
3298 print *, (c_sizeof(s)/c_sizeof(r) == 5)
3301 The example will print @code{.TRUE.} unless you are using a platform
3302 where default @code{REAL} variables are unusually padded.
3304 @item @emph{See also}:
3305 @ref{SIZEOF}, @ref{STORAGE_SIZE}
3310 @section @code{CEILING} --- Integer ceiling function
3313 @cindex rounding, ceiling
3316 @item @emph{Description}:
3317 @code{CEILING(A)} returns the least integer greater than or equal to @var{A}.
3319 @item @emph{Standard}:
3320 Fortran 95 and later
3325 @item @emph{Syntax}:
3326 @code{RESULT = CEILING(A [, KIND])}
3328 @item @emph{Arguments}:
3329 @multitable @columnfractions .15 .70
3330 @item @var{A} @tab The type shall be @code{REAL}.
3331 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
3332 expression indicating the kind parameter of the result.
3335 @item @emph{Return value}:
3336 The return value is of type @code{INTEGER(KIND)} if @var{KIND} is present
3337 and a default-kind @code{INTEGER} otherwise.
3339 @item @emph{Example}:
3341 program test_ceiling
3344 print *, ceiling(x) ! returns 64
3345 print *, ceiling(y) ! returns -63
3346 end program test_ceiling
3349 @item @emph{See also}:
3350 @ref{FLOOR}, @ref{NINT}
3357 @section @code{CHAR} --- Character conversion function
3359 @cindex conversion, to character
3362 @item @emph{Description}:
3363 @code{CHAR(I [, KIND])} returns the character represented by the integer @var{I}.
3365 @item @emph{Standard}:
3366 Fortran 77 and later
3371 @item @emph{Syntax}:
3372 @code{RESULT = CHAR(I [, KIND])}
3374 @item @emph{Arguments}:
3375 @multitable @columnfractions .15 .70
3376 @item @var{I} @tab The type shall be @code{INTEGER}.
3377 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
3378 expression indicating the kind parameter of the result.
3381 @item @emph{Return value}:
3382 The return value is of type @code{CHARACTER(1)}
3384 @item @emph{Example}:
3390 print *, i, c ! returns 'J'
3391 end program test_char
3394 @item @emph{Specific names}:
3395 @multitable @columnfractions .20 .20 .20 .25
3396 @item Name @tab Argument @tab Return type @tab Standard
3397 @item @code{CHAR(I)} @tab @code{INTEGER I} @tab @code{CHARACTER(LEN=1)} @tab F77 and later
3401 See @ref{ICHAR} for a discussion of converting between numerical values
3402 and formatted string representations.
3404 @item @emph{See also}:
3405 @ref{ACHAR}, @ref{IACHAR}, @ref{ICHAR}
3412 @section @code{CHDIR} --- Change working directory
3414 @cindex system, working directory
3417 @item @emph{Description}:
3418 Change current working directory to a specified path.
3420 This intrinsic is provided in both subroutine and function forms; however,
3421 only one form can be used in any given program unit.
3423 @item @emph{Standard}:
3427 Subroutine, function
3429 @item @emph{Syntax}:
3430 @multitable @columnfractions .80
3431 @item @code{CALL CHDIR(NAME [, STATUS])}
3432 @item @code{STATUS = CHDIR(NAME)}
3435 @item @emph{Arguments}:
3436 @multitable @columnfractions .15 .70
3437 @item @var{NAME} @tab The type shall be @code{CHARACTER} of default
3438 kind and shall specify a valid path within the file system.
3439 @item @var{STATUS} @tab (Optional) @code{INTEGER} status flag of the default
3440 kind. Returns 0 on success, and a system specific and nonzero error code
3444 @item @emph{Example}:
3447 CHARACTER(len=255) :: path
3449 WRITE(*,*) TRIM(path)
3452 WRITE(*,*) TRIM(path)
3456 @item @emph{See also}:
3463 @section @code{CHMOD} --- Change access permissions of files
3465 @cindex file system, change access mode
3468 @item @emph{Description}:
3469 @code{CHMOD} changes the permissions of a file.
3471 This intrinsic is provided in both subroutine and function forms; however,
3472 only one form can be used in any given program unit.
3474 @item @emph{Standard}:
3478 Subroutine, function
3480 @item @emph{Syntax}:
3481 @multitable @columnfractions .80
3482 @item @code{CALL CHMOD(NAME, MODE[, STATUS])}
3483 @item @code{STATUS = CHMOD(NAME, MODE)}
3486 @item @emph{Arguments}:
3487 @multitable @columnfractions .15 .70
3489 @item @var{NAME} @tab Scalar @code{CHARACTER} of default kind with the
3490 file name. Trailing blanks are ignored unless the character
3491 @code{achar(0)} is present, then all characters up to and excluding
3492 @code{achar(0)} are used as the file name.
3494 @item @var{MODE} @tab Scalar @code{CHARACTER} of default kind giving the
3495 file permission. @var{MODE} uses the same syntax as the @code{chmod} utility
3496 as defined by the POSIX standard. The argument shall either be a string of
3497 a nonnegative octal number or a symbolic mode.
3499 @item @var{STATUS} @tab (optional) scalar @code{INTEGER}, which is
3500 @code{0} on success and nonzero otherwise.
3503 @item @emph{Return value}:
3504 In either syntax, @var{STATUS} is set to @code{0} on success and nonzero
3507 @item @emph{Example}:
3508 @code{CHMOD} as subroutine
3513 call chmod('test.dat','u+x',status)
3514 print *, 'Status: ', status
3515 end program chmod_test
3517 @code{CHMOD} as function:
3522 status = chmod('test.dat','u+x')
3523 print *, 'Status: ', status
3524 end program chmod_test
3532 @section @code{CMPLX} --- Complex conversion function
3534 @cindex complex numbers, conversion to
3535 @cindex conversion, to complex
3538 @item @emph{Description}:
3539 @code{CMPLX(X [, Y [, KIND]])} returns a complex number where @var{X} is converted to
3540 the real component. If @var{Y} is present it is converted to the imaginary
3541 component. If @var{Y} is not present then the imaginary component is set to
3542 0.0. If @var{X} is complex then @var{Y} must not be present.
3544 @item @emph{Standard}:
3545 Fortran 77 and later
3550 @item @emph{Syntax}:
3551 @code{RESULT = CMPLX(X [, Y [, KIND]])}
3553 @item @emph{Arguments}:
3554 @multitable @columnfractions .15 .70
3555 @item @var{X} @tab The type may be @code{INTEGER}, @code{REAL},
3557 @item @var{Y} @tab (Optional; only allowed if @var{X} is not
3558 @code{COMPLEX}.) May be @code{INTEGER} or @code{REAL}.
3559 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
3560 expression indicating the kind parameter of the result.
3563 @item @emph{Return value}:
3564 The return value is of @code{COMPLEX} type, with a kind equal to
3565 @var{KIND} if it is specified. If @var{KIND} is not specified, the
3566 result is of the default @code{COMPLEX} kind, regardless of the kinds of
3567 @var{X} and @var{Y}.
3569 @item @emph{Example}:
3576 print *, z, cmplx(x)
3577 end program test_cmplx
3580 @item @emph{See also}:
3587 @section @code{CO_BROADCAST} --- Copy a value to all images the current set of images
3588 @fnindex CO_BROADCAST
3589 @cindex Collectives, value broadcasting
3592 @item @emph{Description}:
3593 @code{CO_BROADCAST} copies the value of argument @var{A} on the image with
3594 image index @code{SOURCE_IMAGE} to all images in the current team. @var{A}
3595 becomes defined as if by intrinsic assignment. If the execution was
3596 successful and @var{STAT} is present, it is assigned the value zero. If the
3597 execution failed, @var{STAT} gets assigned a nonzero value and, if present,
3598 @var{ERRMSG} gets assigned a value describing the occurred error.
3600 @item @emph{Standard}:
3601 Technical Specification (TS) 18508 or later
3604 Collective subroutine
3606 @item @emph{Syntax}:
3607 @code{CALL CO_BROADCAST(A, SOURCE_IMAGE [, STAT, ERRMSG])}
3609 @item @emph{Arguments}:
3610 @multitable @columnfractions .15 .70
3611 @item @var{A} @tab INTENT(INOUT) argument; shall have the same
3612 dynamic type and type paramters on all images of the current team. If it
3613 is an array, it shall have the same shape on all images.
3614 @item @var{SOURCE_IMAGE} @tab a scalar integer expression.
3615 It shall have the same the same value on all images and refer to an
3616 image of the current team.
3617 @item @var{STAT} @tab (optional) a scalar integer variable
3618 @item @var{ERRMSG} @tab (optional) a scalar character variable
3621 @item @emph{Example}:
3625 if (this_image() == 1) then
3628 call co_broadcast (val, source_image=1)
3629 print *, this_image, ":", val
3633 @item @emph{See also}:
3634 @ref{CO_MAX}, @ref{CO_MIN}, @ref{CO_SUM}, @ref{CO_REDUCE}
3640 @section @code{CO_MAX} --- Maximal value on the current set of images
3642 @cindex Collectives, maximal value
3645 @item @emph{Description}:
3646 @code{CO_MAX} determines element-wise the maximal value of @var{A} on all
3647 images of the current team. If @var{RESULT_IMAGE} is present, the maximum
3648 values are returned in @var{A} on the specified image only and the value
3649 of @var{A} on the other images become undefined. If @var{RESULT_IMAGE} is
3650 not present, the value is returned on all images. If the execution was
3651 successful and @var{STAT} is present, it is assigned the value zero. If the
3652 execution failed, @var{STAT} gets assigned a nonzero value and, if present,
3653 @var{ERRMSG} gets assigned a value describing the occurred error.
3655 @item @emph{Standard}:
3656 Technical Specification (TS) 18508 or later
3659 Collective subroutine
3661 @item @emph{Syntax}:
3662 @code{CALL CO_MAX(A [, RESULT_IMAGE, STAT, ERRMSG])}
3664 @item @emph{Arguments}:
3665 @multitable @columnfractions .15 .70
3666 @item @var{A} @tab shall be an integer, real or character variable,
3667 which has the same type and type parameters on all images of the team.
3668 @item @var{RESULT_IMAGE} @tab (optional) a scalar integer expression; if
3669 present, it shall have the same the same value on all images and refer to an
3670 image of the current team.
3671 @item @var{STAT} @tab (optional) a scalar integer variable
3672 @item @var{ERRMSG} @tab (optional) a scalar character variable
3675 @item @emph{Example}:
3680 call co_max (val, result_image=1)
3681 if (this_image() == 1) then
3682 write(*,*) "Maximal value", val ! prints num_images()
3687 @item @emph{See also}:
3688 @ref{CO_MIN}, @ref{CO_SUM}, @ref{CO_REDUCE}, @ref{CO_BROADCAST}
3694 @section @code{CO_MIN} --- Minimal value on the current set of images
3696 @cindex Collectives, minimal value
3699 @item @emph{Description}:
3700 @code{CO_MIN} determines element-wise the minimal value of @var{A} on all
3701 images of the current team. If @var{RESULT_IMAGE} is present, the minimal
3702 values are returned in @var{A} on the specified image only and the value
3703 of @var{A} on the other images become undefined. If @var{RESULT_IMAGE} is
3704 not present, the value is returned on all images. If the execution was
3705 successful and @var{STAT} is present, it is assigned the value zero. If the
3706 execution failed, @var{STAT} gets assigned a nonzero value and, if present,
3707 @var{ERRMSG} gets assigned a value describing the occurred error.
3709 @item @emph{Standard}:
3710 Technical Specification (TS) 18508 or later
3713 Collective subroutine
3715 @item @emph{Syntax}:
3716 @code{CALL CO_MIN(A [, RESULT_IMAGE, STAT, ERRMSG])}
3718 @item @emph{Arguments}:
3719 @multitable @columnfractions .15 .70
3720 @item @var{A} @tab shall be an integer, real or character variable,
3721 which has the same type and type parameters on all images of the team.
3722 @item @var{RESULT_IMAGE} @tab (optional) a scalar integer expression; if
3723 present, it shall have the same the same value on all images and refer to an
3724 image of the current team.
3725 @item @var{STAT} @tab (optional) a scalar integer variable
3726 @item @var{ERRMSG} @tab (optional) a scalar character variable
3729 @item @emph{Example}:
3734 call co_min (val, result_image=1)
3735 if (this_image() == 1) then
3736 write(*,*) "Minimal value", val ! prints 1
3741 @item @emph{See also}:
3742 @ref{CO_MAX}, @ref{CO_SUM}, @ref{CO_REDUCE}, @ref{CO_BROADCAST}
3748 @section @code{CO_REDUCE} --- Reduction of values on the current set of images
3750 @cindex Collectives, generic reduction
3753 @item @emph{Description}:
3754 @code{CO_REDUCE} determines element-wise the reduction of the value of @var{A}
3755 on all images of the current team. The pure function passed as @var{OPERATOR}
3756 is used to pairwise reduce the values of @var{A} by passing either the value
3757 of @var{A} of different images or the result values of such a reduction as
3758 argument. If @var{A} is an array, the deduction is done element wise. If
3759 @var{RESULT_IMAGE} is present, the result values are returned in @var{A} on
3760 the specified image only and the value of @var{A} on the other images become
3761 undefined. If @var{RESULT_IMAGE} is not present, the value is returned on all
3762 images. If the execution was successful and @var{STAT} is present, it is
3763 assigned the value zero. If the execution failed, @var{STAT} gets assigned
3764 a nonzero value and, if present, @var{ERRMSG} gets assigned a value describing
3767 @item @emph{Standard}:
3768 Technical Specification (TS) 18508 or later
3771 Collective subroutine
3773 @item @emph{Syntax}:
3774 @code{CALL CO_REDUCE(A, OPERATOR, [, RESULT_IMAGE, STAT, ERRMSG])}
3776 @item @emph{Arguments}:
3777 @multitable @columnfractions .15 .70
3778 @item @var{A} @tab is an @code{INTENT(INOUT)} argument and shall be
3779 nonpolymorphic. If it is allocatable, it shall be allocated; if it is a pointer,
3780 it shall be associated. @var{A} shall have the same type and type parameters on
3781 all images of the team; if it is an array, it shall have the same shape on all
3783 @item @var{OPERATOR} @tab pure function with two scalar nonallocatable
3784 arguments, which shall be nonpolymorphic and have the same type and type
3785 parameters as @var{A}. The function shall return a nonallocatable scalar of
3786 the same type and type parameters as @var{A}. The function shall be the same on
3787 all images and with regards to the arguments mathematically commutative and
3788 associative. Note that @var{OPERATOR} may not be an elemental function, unless
3789 it is an intrisic function.
3790 @item @var{RESULT_IMAGE} @tab (optional) a scalar integer expression; if
3791 present, it shall have the same the same value on all images and refer to an
3792 image of the current team.
3793 @item @var{STAT} @tab (optional) a scalar integer variable
3794 @item @var{ERRMSG} @tab (optional) a scalar character variable
3797 @item @emph{Example}:
3802 call co_reduce (val, result_image=1, operator=myprod)
3803 if (this_image() == 1) then
3804 write(*,*) "Product value", val ! prints num_images() factorial
3807 pure function myprod(a, b)
3808 integer, value :: a, b
3816 While the rules permit in principle an intrinsic function, none of the
3817 intrinsics in the standard fulfill the criteria of having a specific
3818 function, which takes two arguments of the same type and returning that
3821 @item @emph{See also}:
3822 @ref{CO_MIN}, @ref{CO_MAX}, @ref{CO_SUM}, @ref{CO_BROADCAST}
3828 @section @code{CO_SUM} --- Sum of values on the current set of images
3830 @cindex Collectives, sum of values
3833 @item @emph{Description}:
3834 @code{CO_SUM} sums up the values of each element of @var{A} on all
3835 images of the current team. If @var{RESULT_IMAGE} is present, the summed-up
3836 values are returned in @var{A} on the specified image only and the value
3837 of @var{A} on the other images become undefined. If @var{RESULT_IMAGE} is
3838 not present, the value is returned on all images. If the execution was
3839 successful and @var{STAT} is present, it is assigned the value zero. If the
3840 execution failed, @var{STAT} gets assigned a nonzero value and, if present,
3841 @var{ERRMSG} gets assigned a value describing the occurred error.
3843 @item @emph{Standard}:
3844 Technical Specification (TS) 18508 or later
3847 Collective subroutine
3849 @item @emph{Syntax}:
3850 @code{CALL CO_MIN(A [, RESULT_IMAGE, STAT, ERRMSG])}
3852 @item @emph{Arguments}:
3853 @multitable @columnfractions .15 .70
3854 @item @var{A} @tab shall be an integer, real or complex variable,
3855 which has the same type and type parameters on all images of the team.
3856 @item @var{RESULT_IMAGE} @tab (optional) a scalar integer expression; if
3857 present, it shall have the same the same value on all images and refer to an
3858 image of the current team.
3859 @item @var{STAT} @tab (optional) a scalar integer variable
3860 @item @var{ERRMSG} @tab (optional) a scalar character variable
3863 @item @emph{Example}:
3868 call co_sum (val, result_image=1)
3869 if (this_image() == 1) then
3870 write(*,*) "The sum is ", val ! prints (n**2 + n)/2, with n = num_images()
3875 @item @emph{See also}:
3876 @ref{CO_MAX}, @ref{CO_MIN}, @ref{CO_REDUCE}, @ref{CO_BROADCAST}
3881 @node COMMAND_ARGUMENT_COUNT
3882 @section @code{COMMAND_ARGUMENT_COUNT} --- Get number of command line arguments
3883 @fnindex COMMAND_ARGUMENT_COUNT
3884 @cindex command-line arguments
3885 @cindex command-line arguments, number of
3886 @cindex arguments, to program
3889 @item @emph{Description}:
3890 @code{COMMAND_ARGUMENT_COUNT} returns the number of arguments passed on the
3891 command line when the containing program was invoked.
3893 @item @emph{Standard}:
3894 Fortran 2003 and later
3899 @item @emph{Syntax}:
3900 @code{RESULT = COMMAND_ARGUMENT_COUNT()}
3902 @item @emph{Arguments}:
3903 @multitable @columnfractions .15 .70
3907 @item @emph{Return value}:
3908 The return value is an @code{INTEGER} of default kind.
3910 @item @emph{Example}:
3912 program test_command_argument_count
3914 count = command_argument_count()
3916 end program test_command_argument_count
3919 @item @emph{See also}:
3920 @ref{GET_COMMAND}, @ref{GET_COMMAND_ARGUMENT}
3925 @node COMPILER_OPTIONS
3926 @section @code{COMPILER_OPTIONS} --- Options passed to the compiler
3927 @fnindex COMPILER_OPTIONS
3928 @cindex flags inquiry function
3929 @cindex options inquiry function
3930 @cindex compiler flags inquiry function
3933 @item @emph{Description}:
3934 @code{COMPILER_OPTIONS} returns a string with the options used for
3937 @item @emph{Standard}:
3941 Inquiry function of the module @code{ISO_FORTRAN_ENV}
3943 @item @emph{Syntax}:
3944 @code{STR = COMPILER_OPTIONS()}
3946 @item @emph{Arguments}:
3949 @item @emph{Return value}:
3950 The return value is a default-kind string with system-dependent length.
3951 It contains the compiler flags used to compile the file, which called
3952 the @code{COMPILER_OPTIONS} intrinsic.
3954 @item @emph{Example}:
3957 print '(4a)', 'This file was compiled by ', &
3958 compiler_version(), ' using the options ', &
3963 @item @emph{See also}:
3964 @ref{COMPILER_VERSION}, @ref{ISO_FORTRAN_ENV}
3969 @node COMPILER_VERSION
3970 @section @code{COMPILER_VERSION} --- Compiler version string
3971 @fnindex COMPILER_VERSION
3972 @cindex compiler, name and version
3973 @cindex version of the compiler
3976 @item @emph{Description}:
3977 @code{COMPILER_VERSION} returns a string with the name and the
3978 version of the compiler.
3980 @item @emph{Standard}:
3984 Inquiry function of the module @code{ISO_FORTRAN_ENV}
3986 @item @emph{Syntax}:
3987 @code{STR = COMPILER_VERSION()}
3989 @item @emph{Arguments}:
3992 @item @emph{Return value}:
3993 The return value is a default-kind string with system-dependent length.
3994 It contains the name of the compiler and its version number.
3996 @item @emph{Example}:
3999 print '(4a)', 'This file was compiled by ', &
4000 compiler_version(), ' using the options ', &
4005 @item @emph{See also}:
4006 @ref{COMPILER_OPTIONS}, @ref{ISO_FORTRAN_ENV}
4012 @section @code{COMPLEX} --- Complex conversion function
4014 @cindex complex numbers, conversion to
4015 @cindex conversion, to complex
4018 @item @emph{Description}:
4019 @code{COMPLEX(X, Y)} returns a complex number where @var{X} is converted
4020 to the real component and @var{Y} is converted to the imaginary
4023 @item @emph{Standard}:
4029 @item @emph{Syntax}:
4030 @code{RESULT = COMPLEX(X, Y)}
4032 @item @emph{Arguments}:
4033 @multitable @columnfractions .15 .70
4034 @item @var{X} @tab The type may be @code{INTEGER} or @code{REAL}.
4035 @item @var{Y} @tab The type may be @code{INTEGER} or @code{REAL}.
4038 @item @emph{Return value}:
4039 If @var{X} and @var{Y} are both of @code{INTEGER} type, then the return
4040 value is of default @code{COMPLEX} type.
4042 If @var{X} and @var{Y} are of @code{REAL} type, or one is of @code{REAL}
4043 type and one is of @code{INTEGER} type, then the return value is of
4044 @code{COMPLEX} type with a kind equal to that of the @code{REAL}
4045 argument with the highest precision.
4047 @item @emph{Example}:
4049 program test_complex
4052 print *, complex(i, x)
4053 end program test_complex
4056 @item @emph{See also}:
4063 @section @code{CONJG} --- Complex conjugate function
4066 @cindex complex conjugate
4069 @item @emph{Description}:
4070 @code{CONJG(Z)} returns the conjugate of @var{Z}. If @var{Z} is @code{(x, y)}
4071 then the result is @code{(x, -y)}
4073 @item @emph{Standard}:
4074 Fortran 77 and later, has overloads that are GNU extensions
4079 @item @emph{Syntax}:
4082 @item @emph{Arguments}:
4083 @multitable @columnfractions .15 .70
4084 @item @var{Z} @tab The type shall be @code{COMPLEX}.
4087 @item @emph{Return value}:
4088 The return value is of type @code{COMPLEX}.
4090 @item @emph{Example}:
4093 complex :: z = (2.0, 3.0)
4094 complex(8) :: dz = (2.71_8, -3.14_8)
4099 end program test_conjg
4102 @item @emph{Specific names}:
4103 @multitable @columnfractions .20 .20 .20 .25
4104 @item Name @tab Argument @tab Return type @tab Standard
4105 @item @code{CONJG(Z)} @tab @code{COMPLEX Z} @tab @code{COMPLEX} @tab GNU extension
4106 @item @code{DCONJG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
4113 @section @code{COS} --- Cosine function
4119 @cindex trigonometric function, cosine
4123 @item @emph{Description}:
4124 @code{COS(X)} computes the cosine of @var{X}.
4126 @item @emph{Standard}:
4127 Fortran 77 and later, has overloads that are GNU extensions
4132 @item @emph{Syntax}:
4133 @code{RESULT = COS(X)}
4135 @item @emph{Arguments}:
4136 @multitable @columnfractions .15 .70
4137 @item @var{X} @tab The type shall be @code{REAL} or
4141 @item @emph{Return value}:
4142 The return value is of the same type and kind as @var{X}. The real part
4143 of the result is in radians. If @var{X} is of the type @code{REAL},
4144 the return value lies in the range @math{ -1 \leq \cos (x) \leq 1}.
4146 @item @emph{Example}:
4151 end program test_cos
4154 @item @emph{Specific names}:
4155 @multitable @columnfractions .20 .20 .20 .25
4156 @item Name @tab Argument @tab Return type @tab Standard
4157 @item @code{COS(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later
4158 @item @code{DCOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
4159 @item @code{CCOS(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab Fortran 77 and later
4160 @item @code{ZCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
4161 @item @code{CDCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
4164 @item @emph{See also}:
4165 Inverse function: @ref{ACOS}
4166 Degrees function: @ref{COSD}
4173 @section @code{COSD} --- Cosine function, degrees
4179 @cindex trigonometric function, cosine, degrees
4180 @cindex cosine, degrees
4183 @item @emph{Description}:
4184 @code{COSD(X)} computes the cosine of @var{X} in degrees.
4186 This function is for compatibility only and should be avoided in favor of
4187 standard constructs wherever possible.
4189 @item @emph{Standard}:
4190 GNU Extension, enabled with @option{-fdec-math}.
4195 @item @emph{Syntax}:
4196 @code{RESULT = COSD(X)}
4198 @item @emph{Arguments}:
4199 @multitable @columnfractions .15 .70
4200 @item @var{X} @tab The type shall be @code{REAL} or
4204 @item @emph{Return value}:
4205 The return value is of the same type and kind as @var{X}. The real part
4206 of the result is in degrees. If @var{X} is of the type @code{REAL},
4207 the return value lies in the range @math{ -1 \leq \cosd (x) \leq 1}.
4209 @item @emph{Example}:
4214 end program test_cosd
4217 @item @emph{Specific names}:
4218 @multitable @columnfractions .20 .20 .20 .25
4219 @item Name @tab Argument @tab Return type @tab Standard
4220 @item @code{COSD(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU Extension
4221 @item @code{DCOSD(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU Extension
4222 @item @code{CCOSD(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab GNU Extension
4223 @item @code{ZCOSD(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
4224 @item @code{CDCOSD(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
4227 @item @emph{See also}:
4228 Inverse function: @ref{ACOSD}
4229 Radians function: @ref{COS}
4236 @section @code{COSH} --- Hyperbolic cosine function
4239 @cindex hyperbolic cosine
4240 @cindex hyperbolic function, cosine
4241 @cindex cosine, hyperbolic
4244 @item @emph{Description}:
4245 @code{COSH(X)} computes the hyperbolic cosine of @var{X}.
4247 @item @emph{Standard}:
4248 Fortran 77 and later, for a complex argument Fortran 2008 or later
4253 @item @emph{Syntax}:
4256 @item @emph{Arguments}:
4257 @multitable @columnfractions .15 .70
4258 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
4261 @item @emph{Return value}:
4262 The return value has same type and kind as @var{X}. If @var{X} is
4263 complex, the imaginary part of the result is in radians. If @var{X}
4264 is @code{REAL}, the return value has a lower bound of one,
4265 @math{\cosh (x) \geq 1}.
4267 @item @emph{Example}:
4270 real(8) :: x = 1.0_8
4272 end program test_cosh
4275 @item @emph{Specific names}:
4276 @multitable @columnfractions .20 .20 .20 .25
4277 @item Name @tab Argument @tab Return type @tab Standard
4278 @item @code{COSH(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later
4279 @item @code{DCOSH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
4282 @item @emph{See also}:
4283 Inverse function: @ref{ACOSH}
4290 @section @code{COTAN} --- Cotangent function
4293 @cindex trigonometric function, cotangent
4297 @item @emph{Description}:
4298 @code{COTAN(X)} computes the cotangent of @var{X}. Equivalent to @code{COS(x)}
4299 divided by @code{SIN(x)}, or @code{1 / TAN(x)}.
4301 This function is for compatibility only and should be avoided in favor of
4302 standard constructs wherever possible.
4304 @item @emph{Standard}:
4305 GNU Extension, enabled with @option{-fdec-math}.
4310 @item @emph{Syntax}:
4311 @code{RESULT = COTAN(X)}
4313 @item @emph{Arguments}:
4314 @multitable @columnfractions .15 .70
4315 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
4318 @item @emph{Return value}:
4319 The return value has same type and kind as @var{X}, and its value is in radians.
4321 @item @emph{Example}:
4324 real(8) :: x = 0.165_8
4326 end program test_cotan
4329 @item @emph{Specific names}:
4330 @multitable @columnfractions .20 .20 .20 .25
4331 @item Name @tab Argument @tab Return type @tab Standard
4332 @item @code{COTAN(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU Extension
4333 @item @code{DCOTAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU Extension
4336 @item @emph{See also}:
4337 Converse function: @ref{TAN}
4338 Degrees function: @ref{COTAND}
4344 @section @code{COTAND} --- Cotangent function, degrees
4347 @cindex trigonometric function, cotangent, degrees
4348 @cindex cotangent, degrees
4351 @item @emph{Description}:
4352 @code{COTAND(X)} computes the cotangent of @var{X} in degrees. Equivalent to
4353 @code{COSD(x)} divided by @code{SIND(x)}, or @code{1 / TAND(x)}.
4355 @item @emph{Standard}:
4356 GNU Extension, enabled with @option{-fdec-math}.
4358 This function is for compatibility only and should be avoided in favor of
4359 standard constructs wherever possible.
4364 @item @emph{Syntax}:
4365 @code{RESULT = COTAND(X)}
4367 @item @emph{Arguments}:
4368 @multitable @columnfractions .15 .70
4369 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
4372 @item @emph{Return value}:
4373 The return value has same type and kind as @var{X}, and its value is in degrees.
4375 @item @emph{Example}:
4378 real(8) :: x = 0.165_8
4380 end program test_cotand
4383 @item @emph{Specific names}:
4384 @multitable @columnfractions .20 .20 .20 .25
4385 @item Name @tab Argument @tab Return type @tab Standard
4386 @item @code{COTAND(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU Extension
4387 @item @code{DCOTAND(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU Extension
4390 @item @emph{See also}:
4391 Converse function: @ref{TAND}
4392 Radians function: @ref{COTAN}
4399 @section @code{COUNT} --- Count function
4401 @cindex array, conditionally count elements
4402 @cindex array, element counting
4403 @cindex array, number of elements
4406 @item @emph{Description}:
4408 Counts the number of @code{.TRUE.} elements in a logical @var{MASK},
4409 or, if the @var{DIM} argument is supplied, counts the number of
4410 elements along each row of the array in the @var{DIM} direction.
4411 If the array has zero size, or all of the elements of @var{MASK} are
4412 @code{.FALSE.}, then the result is @code{0}.
4414 @item @emph{Standard}:
4415 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
4418 Transformational function
4420 @item @emph{Syntax}:
4421 @code{RESULT = COUNT(MASK [, DIM, KIND])}
4423 @item @emph{Arguments}:
4424 @multitable @columnfractions .15 .70
4425 @item @var{MASK} @tab The type shall be @code{LOGICAL}.
4426 @item @var{DIM} @tab (Optional) The type shall be @code{INTEGER}.
4427 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
4428 expression indicating the kind parameter of the result.
4431 @item @emph{Return value}:
4432 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
4433 @var{KIND} is absent, the return value is of default integer kind.
4434 If @var{DIM} is present, the result is an array with a rank one less
4435 than the rank of @var{ARRAY}, and a size corresponding to the shape
4436 of @var{ARRAY} with the @var{DIM} dimension removed.
4438 @item @emph{Example}:
4441 integer, dimension(2,3) :: a, b
4442 logical, dimension(2,3) :: mask
4443 a = reshape( (/ 1, 2, 3, 4, 5, 6 /), (/ 2, 3 /))
4444 b = reshape( (/ 0, 7, 3, 4, 5, 8 /), (/ 2, 3 /))
4445 print '(3i3)', a(1,:)
4446 print '(3i3)', a(2,:)
4448 print '(3i3)', b(1,:)
4449 print '(3i3)', b(2,:)
4452 print '(3l3)', mask(1,:)
4453 print '(3l3)', mask(2,:)
4455 print '(3i3)', count(mask)
4457 print '(3i3)', count(mask, 1)
4459 print '(3i3)', count(mask, 2)
4460 end program test_count
4467 @section @code{CPU_TIME} --- CPU elapsed time in seconds
4469 @cindex time, elapsed
4472 @item @emph{Description}:
4473 Returns a @code{REAL} value representing the elapsed CPU time in
4474 seconds. This is useful for testing segments of code to determine
4477 If a time source is available, time will be reported with microsecond
4478 resolution. If no time source is available, @var{TIME} is set to
4481 Note that @var{TIME} may contain a, system dependent, arbitrary offset
4482 and may not start with @code{0.0}. For @code{CPU_TIME}, the absolute
4483 value is meaningless, only differences between subsequent calls to
4484 this subroutine, as shown in the example below, should be used.
4487 @item @emph{Standard}:
4488 Fortran 95 and later
4493 @item @emph{Syntax}:
4494 @code{CALL CPU_TIME(TIME)}
4496 @item @emph{Arguments}:
4497 @multitable @columnfractions .15 .70
4498 @item @var{TIME} @tab The type shall be @code{REAL} with @code{INTENT(OUT)}.
4501 @item @emph{Return value}:
4504 @item @emph{Example}:
4506 program test_cpu_time
4507 real :: start, finish
4508 call cpu_time(start)
4509 ! put code to test here
4510 call cpu_time(finish)
4511 print '("Time = ",f6.3," seconds.")',finish-start
4512 end program test_cpu_time
4515 @item @emph{See also}:
4516 @ref{SYSTEM_CLOCK}, @ref{DATE_AND_TIME}
4522 @section @code{CSHIFT} --- Circular shift elements of an array
4524 @cindex array, shift circularly
4525 @cindex array, permutation
4526 @cindex array, rotate
4529 @item @emph{Description}:
4530 @code{CSHIFT(ARRAY, SHIFT [, DIM])} performs a circular shift on elements of
4531 @var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is omitted it is
4532 taken to be @code{1}. @var{DIM} is a scalar of type @code{INTEGER} in the
4533 range of @math{1 \leq DIM \leq n)} where @math{n} is the rank of @var{ARRAY}.
4534 If the rank of @var{ARRAY} is one, then all elements of @var{ARRAY} are shifted
4535 by @var{SHIFT} places. If rank is greater than one, then all complete rank one
4536 sections of @var{ARRAY} along the given dimension are shifted. Elements
4537 shifted out one end of each rank one section are shifted back in the other end.
4539 @item @emph{Standard}:
4540 Fortran 95 and later
4543 Transformational function
4545 @item @emph{Syntax}:
4546 @code{RESULT = CSHIFT(ARRAY, SHIFT [, DIM])}
4548 @item @emph{Arguments}:
4549 @multitable @columnfractions .15 .70
4550 @item @var{ARRAY} @tab Shall be an array of any type.
4551 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
4552 @item @var{DIM} @tab The type shall be @code{INTEGER}.
4555 @item @emph{Return value}:
4556 Returns an array of same type and rank as the @var{ARRAY} argument.
4558 @item @emph{Example}:
4561 integer, dimension(3,3) :: a
4562 a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
4563 print '(3i3)', a(1,:)
4564 print '(3i3)', a(2,:)
4565 print '(3i3)', a(3,:)
4566 a = cshift(a, SHIFT=(/1, 2, -1/), DIM=2)
4568 print '(3i3)', a(1,:)
4569 print '(3i3)', a(2,:)
4570 print '(3i3)', a(3,:)
4571 end program test_cshift
4578 @section @code{CTIME} --- Convert a time into a string
4580 @cindex time, conversion to string
4581 @cindex conversion, to string
4584 @item @emph{Description}:
4585 @code{CTIME} converts a system time value, such as returned by
4586 @ref{TIME8}, to a string. The output will be of the form @samp{Sat
4587 Aug 19 18:13:14 1995}.
4589 This intrinsic is provided in both subroutine and function forms; however,
4590 only one form can be used in any given program unit.
4592 @item @emph{Standard}:
4596 Subroutine, function
4598 @item @emph{Syntax}:
4599 @multitable @columnfractions .80
4600 @item @code{CALL CTIME(TIME, RESULT)}.
4601 @item @code{RESULT = CTIME(TIME)}.
4604 @item @emph{Arguments}:
4605 @multitable @columnfractions .15 .70
4606 @item @var{TIME} @tab The type shall be of type @code{INTEGER}.
4607 @item @var{RESULT} @tab The type shall be of type @code{CHARACTER} and
4608 of default kind. It is an @code{INTENT(OUT)} argument. If the length
4609 of this variable is too short for the time and date string to fit
4610 completely, it will be blank on procedure return.
4613 @item @emph{Return value}:
4614 The converted date and time as a string.
4616 @item @emph{Example}:
4620 character(len=30) :: date
4623 ! Do something, main part of the program
4626 print *, 'Program was started on ', date
4627 end program test_ctime
4630 @item @emph{See Also}:
4631 @ref{DATE_AND_TIME}, @ref{GMTIME}, @ref{LTIME}, @ref{TIME}, @ref{TIME8}
4637 @section @code{DATE_AND_TIME} --- Date and time subroutine
4638 @fnindex DATE_AND_TIME
4639 @cindex date, current
4640 @cindex current date
4641 @cindex time, current
4642 @cindex current time
4645 @item @emph{Description}:
4646 @code{DATE_AND_TIME(DATE, TIME, ZONE, VALUES)} gets the corresponding date and
4647 time information from the real-time system clock. @var{DATE} is
4648 @code{INTENT(OUT)} and has form ccyymmdd. @var{TIME} is @code{INTENT(OUT)} and
4649 has form hhmmss.sss. @var{ZONE} is @code{INTENT(OUT)} and has form (+-)hhmm,
4650 representing the difference with respect to Coordinated Universal Time (UTC).
4651 Unavailable time and date parameters return blanks.
4653 @var{VALUES} is @code{INTENT(OUT)} and provides the following:
4655 @multitable @columnfractions .15 .30 .40
4656 @item @tab @code{VALUE(1)}: @tab The year
4657 @item @tab @code{VALUE(2)}: @tab The month
4658 @item @tab @code{VALUE(3)}: @tab The day of the month
4659 @item @tab @code{VALUE(4)}: @tab Time difference with UTC in minutes
4660 @item @tab @code{VALUE(5)}: @tab The hour of the day
4661 @item @tab @code{VALUE(6)}: @tab The minutes of the hour
4662 @item @tab @code{VALUE(7)}: @tab The seconds of the minute
4663 @item @tab @code{VALUE(8)}: @tab The milliseconds of the second
4666 @item @emph{Standard}:
4667 Fortran 95 and later
4672 @item @emph{Syntax}:
4673 @code{CALL DATE_AND_TIME([DATE, TIME, ZONE, VALUES])}
4675 @item @emph{Arguments}:
4676 @multitable @columnfractions .15 .70
4677 @item @var{DATE} @tab (Optional) The type shall be @code{CHARACTER(LEN=8)}
4678 or larger, and of default kind.
4679 @item @var{TIME} @tab (Optional) The type shall be @code{CHARACTER(LEN=10)}
4680 or larger, and of default kind.
4681 @item @var{ZONE} @tab (Optional) The type shall be @code{CHARACTER(LEN=5)}
4682 or larger, and of default kind.
4683 @item @var{VALUES}@tab (Optional) The type shall be @code{INTEGER(8)}.
4686 @item @emph{Return value}:
4689 @item @emph{Example}:
4691 program test_time_and_date
4692 character(8) :: date
4693 character(10) :: time
4694 character(5) :: zone
4695 integer,dimension(8) :: values
4696 ! using keyword arguments
4697 call date_and_time(date,time,zone,values)
4698 call date_and_time(DATE=date,ZONE=zone)
4699 call date_and_time(TIME=time)
4700 call date_and_time(VALUES=values)
4701 print '(a,2x,a,2x,a)', date, time, zone
4702 print '(8i5)', values
4703 end program test_time_and_date
4706 @item @emph{See also}:
4707 @ref{CPU_TIME}, @ref{SYSTEM_CLOCK}
4713 @section @code{DBLE} --- Double conversion function
4715 @cindex conversion, to real
4718 @item @emph{Description}:
4719 @code{DBLE(A)} Converts @var{A} to double precision real type.
4721 @item @emph{Standard}:
4722 Fortran 77 and later
4727 @item @emph{Syntax}:
4728 @code{RESULT = DBLE(A)}
4730 @item @emph{Arguments}:
4731 @multitable @columnfractions .15 .70
4732 @item @var{A} @tab The type shall be @code{INTEGER}, @code{REAL},
4736 @item @emph{Return value}:
4737 The return value is of type double precision real.
4739 @item @emph{Example}:
4744 complex :: z = (2.3,1.14)
4745 print *, dble(x), dble(i), dble(z)
4746 end program test_dble
4749 @item @emph{See also}:
4756 @section @code{DCMPLX} --- Double complex conversion function
4758 @cindex complex numbers, conversion to
4759 @cindex conversion, to complex
4762 @item @emph{Description}:
4763 @code{DCMPLX(X [,Y])} returns a double complex number where @var{X} is
4764 converted to the real component. If @var{Y} is present it is converted to the
4765 imaginary component. If @var{Y} is not present then the imaginary component is
4766 set to 0.0. If @var{X} is complex then @var{Y} must not be present.
4768 @item @emph{Standard}:
4774 @item @emph{Syntax}:
4775 @code{RESULT = DCMPLX(X [, Y])}
4777 @item @emph{Arguments}:
4778 @multitable @columnfractions .15 .70
4779 @item @var{X} @tab The type may be @code{INTEGER}, @code{REAL},
4781 @item @var{Y} @tab (Optional if @var{X} is not @code{COMPLEX}.) May be
4782 @code{INTEGER} or @code{REAL}.
4785 @item @emph{Return value}:
4786 The return value is of type @code{COMPLEX(8)}
4788 @item @emph{Example}:
4798 print *, dcmplx(x,i)
4799 end program test_dcmplx
4805 @section @code{DIGITS} --- Significant binary digits function
4807 @cindex model representation, significant digits
4810 @item @emph{Description}:
4811 @code{DIGITS(X)} returns the number of significant binary digits of the internal
4812 model representation of @var{X}. For example, on a system using a 32-bit
4813 floating point representation, a default real number would likely return 24.
4815 @item @emph{Standard}:
4816 Fortran 95 and later
4821 @item @emph{Syntax}:
4822 @code{RESULT = DIGITS(X)}
4824 @item @emph{Arguments}:
4825 @multitable @columnfractions .15 .70
4826 @item @var{X} @tab The type may be @code{INTEGER} or @code{REAL}.
4829 @item @emph{Return value}:
4830 The return value is of type @code{INTEGER}.
4832 @item @emph{Example}:
4835 integer :: i = 12345
4841 end program test_digits
4848 @section @code{DIM} --- Positive difference
4852 @cindex positive difference
4855 @item @emph{Description}:
4856 @code{DIM(X,Y)} returns the difference @code{X-Y} if the result is positive;
4857 otherwise returns zero.
4859 @item @emph{Standard}:
4860 Fortran 77 and later
4865 @item @emph{Syntax}:
4866 @code{RESULT = DIM(X, Y)}
4868 @item @emph{Arguments}:
4869 @multitable @columnfractions .15 .70
4870 @item @var{X} @tab The type shall be @code{INTEGER} or @code{REAL}
4871 @item @var{Y} @tab The type shall be the same type and kind as @var{X}.
4874 @item @emph{Return value}:
4875 The return value is of type @code{INTEGER} or @code{REAL}.
4877 @item @emph{Example}:
4883 x = dim(4.345_8, 2.111_8)
4886 end program test_dim
4889 @item @emph{Specific names}:
4890 @multitable @columnfractions .20 .20 .20 .25
4891 @item Name @tab Argument @tab Return type @tab Standard
4892 @item @code{DIM(X,Y)} @tab @code{REAL(4) X, Y} @tab @code{REAL(4)} @tab Fortran 77 and later
4893 @item @code{IDIM(X,Y)} @tab @code{INTEGER(4) X, Y} @tab @code{INTEGER(4)} @tab Fortran 77 and later
4894 @item @code{DDIM(X,Y)} @tab @code{REAL(8) X, Y} @tab @code{REAL(8)} @tab Fortran 77 and later
4901 @section @code{DOT_PRODUCT} --- Dot product function
4902 @fnindex DOT_PRODUCT
4904 @cindex vector product
4905 @cindex product, vector
4908 @item @emph{Description}:
4909 @code{DOT_PRODUCT(VECTOR_A, VECTOR_B)} computes the dot product multiplication
4910 of two vectors @var{VECTOR_A} and @var{VECTOR_B}. The two vectors may be
4911 either numeric or logical and must be arrays of rank one and of equal size. If
4912 the vectors are @code{INTEGER} or @code{REAL}, the result is
4913 @code{SUM(VECTOR_A*VECTOR_B)}. If the vectors are @code{COMPLEX}, the result
4914 is @code{SUM(CONJG(VECTOR_A)*VECTOR_B)}. If the vectors are @code{LOGICAL},
4915 the result is @code{ANY(VECTOR_A .AND. VECTOR_B)}.
4917 @item @emph{Standard}:
4918 Fortran 95 and later
4921 Transformational function
4923 @item @emph{Syntax}:
4924 @code{RESULT = DOT_PRODUCT(VECTOR_A, VECTOR_B)}
4926 @item @emph{Arguments}:
4927 @multitable @columnfractions .15 .70
4928 @item @var{VECTOR_A} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
4929 @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.
4932 @item @emph{Return value}:
4933 If the arguments are numeric, the return value is a scalar of numeric type,
4934 @code{INTEGER}, @code{REAL}, or @code{COMPLEX}. If the arguments are
4935 @code{LOGICAL}, the return value is @code{.TRUE.} or @code{.FALSE.}.
4937 @item @emph{Example}:
4939 program test_dot_prod
4940 integer, dimension(3) :: a, b
4947 print *, dot_product(a,b)
4948 end program test_dot_prod
4955 @section @code{DPROD} --- Double product function
4957 @cindex product, double-precision
4960 @item @emph{Description}:
4961 @code{DPROD(X,Y)} returns the product @code{X*Y}.
4963 @item @emph{Standard}:
4964 Fortran 77 and later
4969 @item @emph{Syntax}:
4970 @code{RESULT = DPROD(X, Y)}
4972 @item @emph{Arguments}:
4973 @multitable @columnfractions .15 .70
4974 @item @var{X} @tab The type shall be @code{REAL}.
4975 @item @var{Y} @tab The type shall be @code{REAL}.
4978 @item @emph{Return value}:
4979 The return value is of type @code{REAL(8)}.
4981 @item @emph{Example}:
4989 end program test_dprod
4992 @item @emph{Specific names}:
4993 @multitable @columnfractions .20 .20 .20 .25
4994 @item Name @tab Argument @tab Return type @tab Standard
4995 @item @code{DPROD(X,Y)} @tab @code{REAL(4) X, Y} @tab @code{REAL(8)} @tab Fortran 77 and later
5002 @section @code{DREAL} --- Double real part function
5004 @cindex complex numbers, real part
5007 @item @emph{Description}:
5008 @code{DREAL(Z)} returns the real part of complex variable @var{Z}.
5010 @item @emph{Standard}:
5016 @item @emph{Syntax}:
5017 @code{RESULT = DREAL(A)}
5019 @item @emph{Arguments}:
5020 @multitable @columnfractions .15 .70
5021 @item @var{A} @tab The type shall be @code{COMPLEX(8)}.
5024 @item @emph{Return value}:
5025 The return value is of type @code{REAL(8)}.
5027 @item @emph{Example}:
5030 complex(8) :: z = (1.3_8,7.2_8)
5032 end program test_dreal
5035 @item @emph{See also}:
5043 @section @code{DSHIFTL} --- Combined left shift
5045 @cindex left shift, combined
5049 @item @emph{Description}:
5050 @code{DSHIFTL(I, J, SHIFT)} combines bits of @var{I} and @var{J}. The
5051 rightmost @var{SHIFT} bits of the result are the leftmost @var{SHIFT}
5052 bits of @var{J}, and the remaining bits are the rightmost bits of
5055 @item @emph{Standard}:
5056 Fortran 2008 and later
5061 @item @emph{Syntax}:
5062 @code{RESULT = DSHIFTL(I, J, SHIFT)}
5064 @item @emph{Arguments}:
5065 @multitable @columnfractions .15 .70
5066 @item @var{I} @tab Shall be of type @code{INTEGER} or a BOZ constant.
5067 @item @var{J} @tab Shall be of type @code{INTEGER} or a BOZ constant.
5068 If both @var{I} and @var{J} have integer type, then they shall have
5069 the same kind type parameter. @var{I} and @var{J} shall not both be
5071 @item @var{SHIFT} @tab Shall be of type @code{INTEGER}. It shall
5072 be nonnegative. If @var{I} is not a BOZ constant, then @var{SHIFT}
5073 shall be less than or equal to @code{BIT_SIZE(I)}; otherwise,
5074 @var{SHIFT} shall be less than or equal to @code{BIT_SIZE(J)}.
5077 @item @emph{Return value}:
5078 If either @var{I} or @var{J} is a BOZ constant, it is first converted
5079 as if by the intrinsic function @code{INT} to an integer type with the
5080 kind type parameter of the other.
5082 @item @emph{See also}:
5088 @section @code{DSHIFTR} --- Combined right shift
5090 @cindex right shift, combined
5091 @cindex shift, right
5094 @item @emph{Description}:
5095 @code{DSHIFTR(I, J, SHIFT)} combines bits of @var{I} and @var{J}. The
5096 leftmost @var{SHIFT} bits of the result are the rightmost @var{SHIFT}
5097 bits of @var{I}, and the remaining bits are the leftmost bits of
5100 @item @emph{Standard}:
5101 Fortran 2008 and later
5106 @item @emph{Syntax}:
5107 @code{RESULT = DSHIFTR(I, J, SHIFT)}
5109 @item @emph{Arguments}:
5110 @multitable @columnfractions .15 .70
5111 @item @var{I} @tab Shall be of type @code{INTEGER} or a BOZ constant.
5112 @item @var{J} @tab Shall be of type @code{INTEGER} or a BOZ constant.
5113 If both @var{I} and @var{J} have integer type, then they shall have
5114 the same kind type parameter. @var{I} and @var{J} shall not both be
5116 @item @var{SHIFT} @tab Shall be of type @code{INTEGER}. It shall
5117 be nonnegative. If @var{I} is not a BOZ constant, then @var{SHIFT}
5118 shall be less than or equal to @code{BIT_SIZE(I)}; otherwise,
5119 @var{SHIFT} shall be less than or equal to @code{BIT_SIZE(J)}.
5122 @item @emph{Return value}:
5123 If either @var{I} or @var{J} is a BOZ constant, it is first converted
5124 as if by the intrinsic function @code{INT} to an integer type with the
5125 kind type parameter of the other.
5127 @item @emph{See also}:
5133 @section @code{DTIME} --- Execution time subroutine (or function)
5135 @cindex time, elapsed
5136 @cindex elapsed time
5139 @item @emph{Description}:
5140 @code{DTIME(VALUES, TIME)} initially returns the number of seconds of runtime
5141 since the start of the process's execution in @var{TIME}. @var{VALUES}
5142 returns the user and system components of this time in @code{VALUES(1)} and
5143 @code{VALUES(2)} respectively. @var{TIME} is equal to @code{VALUES(1) +
5146 Subsequent invocations of @code{DTIME} return values accumulated since the
5147 previous invocation.
5149 On some systems, the underlying timings are represented using types with
5150 sufficiently small limits that overflows (wrap around) are possible, such as
5151 32-bit types. Therefore, the values returned by this intrinsic might be, or
5152 become, negative, or numerically less than previous values, during a single
5153 run of the compiled program.
5155 Please note, that this implementation is thread safe if used within OpenMP
5156 directives, i.e., its state will be consistent while called from multiple
5157 threads. However, if @code{DTIME} is called from multiple threads, the result
5158 is still the time since the last invocation. This may not give the intended
5159 results. If possible, use @code{CPU_TIME} instead.
5161 This intrinsic is provided in both subroutine and function forms; however,
5162 only one form can be used in any given program unit.
5164 @var{VALUES} and @var{TIME} are @code{INTENT(OUT)} and provide the following:
5166 @multitable @columnfractions .15 .30 .40
5167 @item @tab @code{VALUES(1)}: @tab User time in seconds.
5168 @item @tab @code{VALUES(2)}: @tab System time in seconds.
5169 @item @tab @code{TIME}: @tab Run time since start in seconds.
5172 @item @emph{Standard}:
5176 Subroutine, function
5178 @item @emph{Syntax}:
5179 @multitable @columnfractions .80
5180 @item @code{CALL DTIME(VALUES, TIME)}.
5181 @item @code{TIME = DTIME(VALUES)}, (not recommended).
5184 @item @emph{Arguments}:
5185 @multitable @columnfractions .15 .70
5186 @item @var{VALUES}@tab The type shall be @code{REAL(4), DIMENSION(2)}.
5187 @item @var{TIME}@tab The type shall be @code{REAL(4)}.
5190 @item @emph{Return value}:
5191 Elapsed time in seconds since the last invocation or since the start of program
5192 execution if not called before.
5194 @item @emph{Example}:
5198 real, dimension(2) :: tarray
5200 call dtime(tarray, result)
5204 do i=1,100000000 ! Just a delay
5207 call dtime(tarray, result)
5211 end program test_dtime
5214 @item @emph{See also}:
5222 @section @code{EOSHIFT} --- End-off shift elements of an array
5224 @cindex array, shift
5227 @item @emph{Description}:
5228 @code{EOSHIFT(ARRAY, SHIFT[, BOUNDARY, DIM])} performs an end-off shift on
5229 elements of @var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is
5230 omitted it is taken to be @code{1}. @var{DIM} is a scalar of type
5231 @code{INTEGER} in the range of @math{1 \leq DIM \leq n)} where @math{n} is the
5232 rank of @var{ARRAY}. If the rank of @var{ARRAY} is one, then all elements of
5233 @var{ARRAY} are shifted by @var{SHIFT} places. If rank is greater than one,
5234 then all complete rank one sections of @var{ARRAY} along the given dimension are
5235 shifted. Elements shifted out one end of each rank one section are dropped. If
5236 @var{BOUNDARY} is present then the corresponding value of from @var{BOUNDARY}
5237 is copied back in the other end. If @var{BOUNDARY} is not present then the
5238 following are copied in depending on the type of @var{ARRAY}.
5240 @multitable @columnfractions .15 .80
5241 @item @emph{Array Type} @tab @emph{Boundary Value}
5242 @item Numeric @tab 0 of the type and kind of @var{ARRAY}.
5243 @item Logical @tab @code{.FALSE.}.
5244 @item Character(@var{len}) @tab @var{len} blanks.
5247 @item @emph{Standard}:
5248 Fortran 95 and later
5251 Transformational function
5253 @item @emph{Syntax}:
5254 @code{RESULT = EOSHIFT(ARRAY, SHIFT [, BOUNDARY, DIM])}
5256 @item @emph{Arguments}:
5257 @multitable @columnfractions .15 .70
5258 @item @var{ARRAY} @tab May be any type, not scalar.
5259 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
5260 @item @var{BOUNDARY} @tab Same type as @var{ARRAY}.
5261 @item @var{DIM} @tab The type shall be @code{INTEGER}.
5264 @item @emph{Return value}:
5265 Returns an array of same type and rank as the @var{ARRAY} argument.
5267 @item @emph{Example}:
5269 program test_eoshift
5270 integer, dimension(3,3) :: a
5271 a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
5272 print '(3i3)', a(1,:)
5273 print '(3i3)', a(2,:)
5274 print '(3i3)', a(3,:)
5275 a = EOSHIFT(a, SHIFT=(/1, 2, 1/), BOUNDARY=-5, DIM=2)
5277 print '(3i3)', a(1,:)
5278 print '(3i3)', a(2,:)
5279 print '(3i3)', a(3,:)
5280 end program test_eoshift
5287 @section @code{EPSILON} --- Epsilon function
5289 @cindex model representation, epsilon
5292 @item @emph{Description}:
5293 @code{EPSILON(X)} returns the smallest number @var{E} of the same kind
5294 as @var{X} such that @math{1 + E > 1}.
5296 @item @emph{Standard}:
5297 Fortran 95 and later
5302 @item @emph{Syntax}:
5303 @code{RESULT = EPSILON(X)}
5305 @item @emph{Arguments}:
5306 @multitable @columnfractions .15 .70
5307 @item @var{X} @tab The type shall be @code{REAL}.
5310 @item @emph{Return value}:
5311 The return value is of same type as the argument.
5313 @item @emph{Example}:
5315 program test_epsilon
5320 end program test_epsilon
5327 @section @code{ERF} --- Error function
5329 @cindex error function
5332 @item @emph{Description}:
5333 @code{ERF(X)} computes the error function of @var{X}.
5335 @item @emph{Standard}:
5336 Fortran 2008 and later
5341 @item @emph{Syntax}:
5342 @code{RESULT = ERF(X)}
5344 @item @emph{Arguments}:
5345 @multitable @columnfractions .15 .70
5346 @item @var{X} @tab The type shall be @code{REAL}.
5349 @item @emph{Return value}:
5350 The return value is of type @code{REAL}, of the same kind as
5351 @var{X} and lies in the range @math{-1 \leq erf (x) \leq 1 }.
5353 @item @emph{Example}:
5356 real(8) :: x = 0.17_8
5358 end program test_erf
5361 @item @emph{Specific names}:
5362 @multitable @columnfractions .20 .20 .20 .25
5363 @item Name @tab Argument @tab Return type @tab Standard
5364 @item @code{DERF(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
5371 @section @code{ERFC} --- Error function
5373 @cindex error function, complementary
5376 @item @emph{Description}:
5377 @code{ERFC(X)} computes the complementary error function of @var{X}.
5379 @item @emph{Standard}:
5380 Fortran 2008 and later
5385 @item @emph{Syntax}:
5386 @code{RESULT = ERFC(X)}
5388 @item @emph{Arguments}:
5389 @multitable @columnfractions .15 .70
5390 @item @var{X} @tab The type shall be @code{REAL}.
5393 @item @emph{Return value}:
5394 The return value is of type @code{REAL} and of the same kind as @var{X}.
5395 It lies in the range @math{ 0 \leq erfc (x) \leq 2 }.
5397 @item @emph{Example}:
5400 real(8) :: x = 0.17_8
5402 end program test_erfc
5405 @item @emph{Specific names}:
5406 @multitable @columnfractions .20 .20 .20 .25
5407 @item Name @tab Argument @tab Return type @tab Standard
5408 @item @code{DERFC(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
5415 @section @code{ERFC_SCALED} --- Error function
5416 @fnindex ERFC_SCALED
5417 @cindex error function, complementary, exponentially-scaled
5420 @item @emph{Description}:
5421 @code{ERFC_SCALED(X)} computes the exponentially-scaled complementary
5422 error function of @var{X}.
5424 @item @emph{Standard}:
5425 Fortran 2008 and later
5430 @item @emph{Syntax}:
5431 @code{RESULT = ERFC_SCALED(X)}
5433 @item @emph{Arguments}:
5434 @multitable @columnfractions .15 .70
5435 @item @var{X} @tab The type shall be @code{REAL}.
5438 @item @emph{Return value}:
5439 The return value is of type @code{REAL} and of the same kind as @var{X}.
5441 @item @emph{Example}:
5443 program test_erfc_scaled
5444 real(8) :: x = 0.17_8
5446 end program test_erfc_scaled
5453 @section @code{ETIME} --- Execution time subroutine (or function)
5455 @cindex time, elapsed
5458 @item @emph{Description}:
5459 @code{ETIME(VALUES, TIME)} returns the number of seconds of runtime
5460 since the start of the process's execution in @var{TIME}. @var{VALUES}
5461 returns the user and system components of this time in @code{VALUES(1)} and
5462 @code{VALUES(2)} respectively. @var{TIME} is equal to @code{VALUES(1) + VALUES(2)}.
5464 On some systems, the underlying timings are represented using types with
5465 sufficiently small limits that overflows (wrap around) are possible, such as
5466 32-bit types. Therefore, the values returned by this intrinsic might be, or
5467 become, negative, or numerically less than previous values, during a single
5468 run of the compiled program.
5470 This intrinsic is provided in both subroutine and function forms; however,
5471 only one form can be used in any given program unit.
5473 @var{VALUES} and @var{TIME} are @code{INTENT(OUT)} and provide the following:
5475 @multitable @columnfractions .15 .30 .60
5476 @item @tab @code{VALUES(1)}: @tab User time in seconds.
5477 @item @tab @code{VALUES(2)}: @tab System time in seconds.
5478 @item @tab @code{TIME}: @tab Run time since start in seconds.
5481 @item @emph{Standard}:
5485 Subroutine, function
5487 @item @emph{Syntax}:
5488 @multitable @columnfractions .80
5489 @item @code{CALL ETIME(VALUES, TIME)}.
5490 @item @code{TIME = ETIME(VALUES)}, (not recommended).
5493 @item @emph{Arguments}:
5494 @multitable @columnfractions .15 .70
5495 @item @var{VALUES}@tab The type shall be @code{REAL(4), DIMENSION(2)}.
5496 @item @var{TIME}@tab The type shall be @code{REAL(4)}.
5499 @item @emph{Return value}:
5500 Elapsed time in seconds since the start of program execution.
5502 @item @emph{Example}:
5506 real, dimension(2) :: tarray
5508 call ETIME(tarray, result)
5512 do i=1,100000000 ! Just a delay
5515 call ETIME(tarray, result)
5519 end program test_etime
5522 @item @emph{See also}:
5530 @section @code{EVENT_QUERY} --- Query whether a coarray event has occurred
5531 @fnindex EVENT_QUERY
5532 @cindex Events, EVENT_QUERY
5535 @item @emph{Description}:
5536 @code{EVENT_QUERY} assignes the number of events to @var{COUNT} which have been
5537 posted to the @var{EVENT} variable and not yet been removed by calling
5538 @code{EVENT WAIT}. When @var{STAT} is present and the invocation was successful,
5539 it is assigned the value 0. If it is present and the invocation has failed,
5540 it is assigned a positive value and @var{COUNT} is assigned the value @math{-1}.
5542 @item @emph{Standard}:
5548 @item @emph{Syntax}:
5549 @code{CALL EVENT_QUERY (EVENT, COUNT [, STAT])}
5551 @item @emph{Arguments}:
5552 @multitable @columnfractions .15 .70
5553 @item @var{EVENT} @tab (intent(IN)) Scalar of type @code{EVENT_TYPE},
5554 defined in @code{ISO_FORTRAN_ENV}; shall not be coindexed.
5555 @item @var{COUNT} @tab (intent(out))Scalar integer with at least the
5556 precision of default integer.
5557 @item @var{STAT} @tab (optional) Scalar default-kind integer variable.
5560 @item @emph{Example}:
5565 type(event_type) :: event_value_has_been_set[*]
5567 if (this_image() == 1) then
5568 call event_query (event_value_has_been_set, cnt)
5569 if (cnt > 0) write(*,*) "Value has been set"
5570 elseif (this_image() == 2) then
5571 event post (event_value_has_been_set[1])
5580 @node EXECUTE_COMMAND_LINE
5581 @section @code{EXECUTE_COMMAND_LINE} --- Execute a shell command
5582 @fnindex EXECUTE_COMMAND_LINE
5583 @cindex system, system call
5584 @cindex command line
5587 @item @emph{Description}:
5588 @code{EXECUTE_COMMAND_LINE} runs a shell command, synchronously or
5591 The @code{COMMAND} argument is passed to the shell and executed, using
5592 the C library's @code{system} call. (The shell is @code{sh} on Unix
5593 systems, and @code{cmd.exe} on Windows.) If @code{WAIT} is present
5594 and has the value false, the execution of the command is asynchronous
5595 if the system supports it; otherwise, the command is executed
5598 The three last arguments allow the user to get status information. After
5599 synchronous execution, @code{EXITSTAT} contains the integer exit code of
5600 the command, as returned by @code{system}. @code{CMDSTAT} is set to zero
5601 if the command line was executed (whatever its exit status was).
5602 @code{CMDMSG} is assigned an error message if an error has occurred.
5604 Note that the @code{system} function need not be thread-safe. It is
5605 the responsibility of the user to ensure that @code{system} is not
5606 called concurrently.
5608 @item @emph{Standard}:
5609 Fortran 2008 and later
5614 @item @emph{Syntax}:
5615 @code{CALL EXECUTE_COMMAND_LINE(COMMAND [, WAIT, EXITSTAT, CMDSTAT, CMDMSG ])}
5617 @item @emph{Arguments}:
5618 @multitable @columnfractions .15 .70
5619 @item @var{COMMAND} @tab Shall be a default @code{CHARACTER} scalar.
5620 @item @var{WAIT} @tab (Optional) Shall be a default @code{LOGICAL} scalar.
5621 @item @var{EXITSTAT} @tab (Optional) Shall be an @code{INTEGER} of the
5623 @item @var{CMDSTAT} @tab (Optional) Shall be an @code{INTEGER} of the
5625 @item @var{CMDMSG} @tab (Optional) Shall be an @code{CHARACTER} scalar of the
5629 @item @emph{Example}:
5634 call execute_command_line ("external_prog.exe", exitstat=i)
5635 print *, "Exit status of external_prog.exe was ", i
5637 call execute_command_line ("reindex_files.exe", wait=.false.)
5638 print *, "Now reindexing files in the background"
5640 end program test_exec
5646 Because this intrinsic is implemented in terms of the @code{system}
5647 function call, its behavior with respect to signaling is processor
5648 dependent. In particular, on POSIX-compliant systems, the SIGINT and
5649 SIGQUIT signals will be ignored, and the SIGCHLD will be blocked. As
5650 such, if the parent process is terminated, the child process might not be
5651 terminated alongside.
5654 @item @emph{See also}:
5661 @section @code{EXIT} --- Exit the program with status.
5663 @cindex program termination
5664 @cindex terminate program
5667 @item @emph{Description}:
5668 @code{EXIT} causes immediate termination of the program with status. If status
5669 is omitted it returns the canonical @emph{success} for the system. All Fortran
5670 I/O units are closed.
5672 @item @emph{Standard}:
5678 @item @emph{Syntax}:
5679 @code{CALL EXIT([STATUS])}
5681 @item @emph{Arguments}:
5682 @multitable @columnfractions .15 .70
5683 @item @var{STATUS} @tab Shall be an @code{INTEGER} of the default kind.
5686 @item @emph{Return value}:
5687 @code{STATUS} is passed to the parent process on exit.
5689 @item @emph{Example}:
5692 integer :: STATUS = 0
5693 print *, 'This program is going to exit.'
5695 end program test_exit
5698 @item @emph{See also}:
5699 @ref{ABORT}, @ref{KILL}
5705 @section @code{EXP} --- Exponential function
5711 @cindex exponential function
5712 @cindex logarithm function, inverse
5715 @item @emph{Description}:
5716 @code{EXP(X)} computes the base @math{e} exponential of @var{X}.
5718 @item @emph{Standard}:
5719 Fortran 77 and later, has overloads that are GNU extensions
5724 @item @emph{Syntax}:
5725 @code{RESULT = EXP(X)}
5727 @item @emph{Arguments}:
5728 @multitable @columnfractions .15 .70
5729 @item @var{X} @tab The type shall be @code{REAL} or
5733 @item @emph{Return value}:
5734 The return value has same type and kind as @var{X}.
5736 @item @emph{Example}:
5741 end program test_exp
5744 @item @emph{Specific names}:
5745 @multitable @columnfractions .20 .20 .20 .25
5746 @item Name @tab Argument @tab Return type @tab Standard
5747 @item @code{EXP(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later
5748 @item @code{DEXP(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
5749 @item @code{CEXP(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab Fortran 77 and later
5750 @item @code{ZEXP(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
5751 @item @code{CDEXP(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
5758 @section @code{EXPONENT} --- Exponent function
5760 @cindex real number, exponent
5761 @cindex floating point, exponent
5764 @item @emph{Description}:
5765 @code{EXPONENT(X)} returns the value of the exponent part of @var{X}. If @var{X}
5766 is zero the value returned is zero.
5768 @item @emph{Standard}:
5769 Fortran 95 and later
5774 @item @emph{Syntax}:
5775 @code{RESULT = EXPONENT(X)}
5777 @item @emph{Arguments}:
5778 @multitable @columnfractions .15 .70
5779 @item @var{X} @tab The type shall be @code{REAL}.
5782 @item @emph{Return value}:
5783 The return value is of type default @code{INTEGER}.
5785 @item @emph{Example}:
5787 program test_exponent
5792 print *, exponent(0.0)
5793 end program test_exponent
5799 @node EXTENDS_TYPE_OF
5800 @section @code{EXTENDS_TYPE_OF} --- Query dynamic type for extension
5801 @fnindex EXTENDS_TYPE_OF
5804 @item @emph{Description}:
5805 Query dynamic type for extension.
5807 @item @emph{Standard}:
5808 Fortran 2003 and later
5813 @item @emph{Syntax}:
5814 @code{RESULT = EXTENDS_TYPE_OF(A, MOLD)}
5816 @item @emph{Arguments}:
5817 @multitable @columnfractions .15 .70
5818 @item @var{A} @tab Shall be an object of extensible declared type or
5819 unlimited polymorphic.
5820 @item @var{MOLD} @tab Shall be an object of extensible declared type or
5821 unlimited polymorphic.
5824 @item @emph{Return value}:
5825 The return value is a scalar of type default logical. It is true if and only if
5826 the dynamic type of A is an extension type of the dynamic type of MOLD.
5829 @item @emph{See also}:
5836 @section @code{FDATE} --- Get the current time as a string
5838 @cindex time, current
5839 @cindex current time
5840 @cindex date, current
5841 @cindex current date
5844 @item @emph{Description}:
5845 @code{FDATE(DATE)} returns the current date (using the same format as
5846 @ref{CTIME}) in @var{DATE}. It is equivalent to @code{CALL CTIME(DATE,
5849 This intrinsic is provided in both subroutine and function forms; however,
5850 only one form can be used in any given program unit.
5852 @item @emph{Standard}:
5856 Subroutine, function
5858 @item @emph{Syntax}:
5859 @multitable @columnfractions .80
5860 @item @code{CALL FDATE(DATE)}.
5861 @item @code{DATE = FDATE()}.
5864 @item @emph{Arguments}:
5865 @multitable @columnfractions .15 .70
5866 @item @var{DATE}@tab The type shall be of type @code{CHARACTER} of the
5867 default kind. It is an @code{INTENT(OUT)} argument. If the length of
5868 this variable is too short for the date and time string to fit
5869 completely, it will be blank on procedure return.
5872 @item @emph{Return value}:
5873 The current date and time as a string.
5875 @item @emph{Example}:
5879 character(len=30) :: date
5881 print *, 'Program started on ', date
5882 do i = 1, 100000000 ! Just a delay
5886 print *, 'Program ended on ', date
5887 end program test_fdate
5890 @item @emph{See also}:
5891 @ref{DATE_AND_TIME}, @ref{CTIME}
5896 @section @code{FGET} --- Read a single character in stream mode from stdin
5898 @cindex read character, stream mode
5899 @cindex stream mode, read character
5900 @cindex file operation, read character
5903 @item @emph{Description}:
5904 Read a single character in stream mode from stdin by bypassing normal
5905 formatted output. Stream I/O should not be mixed with normal record-oriented
5906 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
5908 This intrinsic is provided in both subroutine and function forms; however,
5909 only one form can be used in any given program unit.
5911 Note that the @code{FGET} intrinsic is provided for backwards compatibility with
5912 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
5913 Programmers should consider the use of new stream IO feature in new code
5914 for future portability. See also @ref{Fortran 2003 status}.
5916 @item @emph{Standard}:
5920 Subroutine, function
5922 @item @emph{Syntax}:
5923 @multitable @columnfractions .80
5924 @item @code{CALL FGET(C [, STATUS])}
5925 @item @code{STATUS = FGET(C)}
5928 @item @emph{Arguments}:
5929 @multitable @columnfractions .15 .70
5930 @item @var{C} @tab The type shall be @code{CHARACTER} and of default
5932 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
5933 Returns 0 on success, -1 on end-of-file, and a system specific positive
5934 error code otherwise.
5937 @item @emph{Example}:
5940 INTEGER, PARAMETER :: strlen = 100
5941 INTEGER :: status, i = 1
5942 CHARACTER(len=strlen) :: str = ""
5944 WRITE (*,*) 'Enter text:'
5946 CALL fget(str(i:i), status)
5947 if (status /= 0 .OR. i > strlen) exit
5950 WRITE (*,*) TRIM(str)
5954 @item @emph{See also}:
5955 @ref{FGETC}, @ref{FPUT}, @ref{FPUTC}
5961 @section @code{FGETC} --- Read a single character in stream mode
5963 @cindex read character, stream mode
5964 @cindex stream mode, read character
5965 @cindex file operation, read character
5968 @item @emph{Description}:
5969 Read a single character in stream mode by bypassing normal formatted output.
5970 Stream I/O should not be mixed with normal record-oriented (formatted or
5971 unformatted) I/O on the same unit; the results are unpredictable.
5973 This intrinsic is provided in both subroutine and function forms; however,
5974 only one form can be used in any given program unit.
5976 Note that the @code{FGET} intrinsic is provided for backwards compatibility
5977 with @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
5978 Programmers should consider the use of new stream IO feature in new code
5979 for future portability. See also @ref{Fortran 2003 status}.
5981 @item @emph{Standard}:
5985 Subroutine, function
5987 @item @emph{Syntax}:
5988 @multitable @columnfractions .80
5989 @item @code{CALL FGETC(UNIT, C [, STATUS])}
5990 @item @code{STATUS = FGETC(UNIT, C)}
5993 @item @emph{Arguments}:
5994 @multitable @columnfractions .15 .70
5995 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
5996 @item @var{C} @tab The type shall be @code{CHARACTER} and of default
5998 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
5999 Returns 0 on success, -1 on end-of-file and a system specific positive
6000 error code otherwise.
6003 @item @emph{Example}:
6006 INTEGER :: fd = 42, status
6009 OPEN(UNIT=fd, FILE="/etc/passwd", ACTION="READ", STATUS = "OLD")
6011 CALL fgetc(fd, c, status)
6012 IF (status /= 0) EXIT
6019 @item @emph{See also}:
6020 @ref{FGET}, @ref{FPUT}, @ref{FPUTC}
6026 @section @code{FLOOR} --- Integer floor function
6029 @cindex rounding, floor
6032 @item @emph{Description}:
6033 @code{FLOOR(A)} returns the greatest integer less than or equal to @var{X}.
6035 @item @emph{Standard}:
6036 Fortran 95 and later
6041 @item @emph{Syntax}:
6042 @code{RESULT = FLOOR(A [, KIND])}
6044 @item @emph{Arguments}:
6045 @multitable @columnfractions .15 .70
6046 @item @var{A} @tab The type shall be @code{REAL}.
6047 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
6048 expression indicating the kind parameter of the result.
6051 @item @emph{Return value}:
6052 The return value is of type @code{INTEGER(KIND)} if @var{KIND} is present
6053 and of default-kind @code{INTEGER} otherwise.
6055 @item @emph{Example}:
6060 print *, floor(x) ! returns 63
6061 print *, floor(y) ! returns -64
6062 end program test_floor
6065 @item @emph{See also}:
6066 @ref{CEILING}, @ref{NINT}
6073 @section @code{FLUSH} --- Flush I/O unit(s)
6075 @cindex file operation, flush
6078 @item @emph{Description}:
6079 Flushes Fortran unit(s) currently open for output. Without the optional
6080 argument, all units are flushed, otherwise just the unit specified.
6082 @item @emph{Standard}:
6088 @item @emph{Syntax}:
6089 @code{CALL FLUSH(UNIT)}
6091 @item @emph{Arguments}:
6092 @multitable @columnfractions .15 .70
6093 @item @var{UNIT} @tab (Optional) The type shall be @code{INTEGER}.
6097 Beginning with the Fortran 2003 standard, there is a @code{FLUSH}
6098 statement that should be preferred over the @code{FLUSH} intrinsic.
6100 The @code{FLUSH} intrinsic and the Fortran 2003 @code{FLUSH} statement
6101 have identical effect: they flush the runtime library's I/O buffer so
6102 that the data becomes visible to other processes. This does not guarantee
6103 that the data is committed to disk.
6105 On POSIX systems, you can request that all data is transferred to the
6106 storage device by calling the @code{fsync} function, with the POSIX file
6107 descriptor of the I/O unit as argument (retrieved with GNU intrinsic
6108 @code{FNUM}). The following example shows how:
6111 ! Declare the interface for POSIX fsync function
6113 function fsync (fd) bind(c,name="fsync")
6114 use iso_c_binding, only: c_int
6115 integer(c_int), value :: fd
6116 integer(c_int) :: fsync
6120 ! Variable declaration
6124 open (10,file="foo")
6127 ! Perform I/O on unit 10
6132 ret = fsync(fnum(10))
6134 ! Handle possible error
6135 if (ret /= 0) stop "Error calling FSYNC"
6143 @section @code{FNUM} --- File number function
6145 @cindex file operation, file number
6148 @item @emph{Description}:
6149 @code{FNUM(UNIT)} returns the POSIX file descriptor number corresponding to the
6150 open Fortran I/O unit @code{UNIT}.
6152 @item @emph{Standard}:
6158 @item @emph{Syntax}:
6159 @code{RESULT = FNUM(UNIT)}
6161 @item @emph{Arguments}:
6162 @multitable @columnfractions .15 .70
6163 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
6166 @item @emph{Return value}:
6167 The return value is of type @code{INTEGER}
6169 @item @emph{Example}:
6173 open (unit=10, status = "scratch")
6177 end program test_fnum
6184 @section @code{FPUT} --- Write a single character in stream mode to stdout
6186 @cindex write character, stream mode
6187 @cindex stream mode, write character
6188 @cindex file operation, write character
6191 @item @emph{Description}:
6192 Write a single character in stream mode to stdout by bypassing normal
6193 formatted output. Stream I/O should not be mixed with normal record-oriented
6194 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
6196 This intrinsic is provided in both subroutine and function forms; however,
6197 only one form can be used in any given program unit.
6199 Note that the @code{FGET} intrinsic is provided for backwards compatibility with
6200 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
6201 Programmers should consider the use of new stream IO feature in new code
6202 for future portability. See also @ref{Fortran 2003 status}.
6204 @item @emph{Standard}:
6208 Subroutine, function
6210 @item @emph{Syntax}:
6211 @multitable @columnfractions .80
6212 @item @code{CALL FPUT(C [, STATUS])}
6213 @item @code{STATUS = FPUT(C)}
6216 @item @emph{Arguments}:
6217 @multitable @columnfractions .15 .70
6218 @item @var{C} @tab The type shall be @code{CHARACTER} and of default
6220 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
6221 Returns 0 on success, -1 on end-of-file and a system specific positive
6222 error code otherwise.
6225 @item @emph{Example}:
6228 CHARACTER(len=10) :: str = "gfortran"
6230 DO i = 1, len_trim(str)
6236 @item @emph{See also}:
6237 @ref{FPUTC}, @ref{FGET}, @ref{FGETC}
6243 @section @code{FPUTC} --- Write a single character in stream mode
6245 @cindex write character, stream mode
6246 @cindex stream mode, write character
6247 @cindex file operation, write character
6250 @item @emph{Description}:
6251 Write a single character in stream mode by bypassing normal formatted
6252 output. Stream I/O should not be mixed with normal record-oriented
6253 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
6255 This intrinsic is provided in both subroutine and function forms; however,
6256 only one form can be used in any given program unit.
6258 Note that the @code{FGET} intrinsic is provided for backwards compatibility with
6259 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
6260 Programmers should consider the use of new stream IO feature in new code
6261 for future portability. See also @ref{Fortran 2003 status}.
6263 @item @emph{Standard}:
6267 Subroutine, function
6269 @item @emph{Syntax}:
6270 @multitable @columnfractions .80
6271 @item @code{CALL FPUTC(UNIT, C [, STATUS])}
6272 @item @code{STATUS = FPUTC(UNIT, C)}
6275 @item @emph{Arguments}:
6276 @multitable @columnfractions .15 .70
6277 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
6278 @item @var{C} @tab The type shall be @code{CHARACTER} and of default
6280 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
6281 Returns 0 on success, -1 on end-of-file and a system specific positive
6282 error code otherwise.
6285 @item @emph{Example}:
6288 CHARACTER(len=10) :: str = "gfortran"
6289 INTEGER :: fd = 42, i
6291 OPEN(UNIT = fd, FILE = "out", ACTION = "WRITE", STATUS="NEW")
6292 DO i = 1, len_trim(str)
6293 CALL fputc(fd, str(i:i))
6299 @item @emph{See also}:
6300 @ref{FPUT}, @ref{FGET}, @ref{FGETC}
6306 @section @code{FRACTION} --- Fractional part of the model representation
6308 @cindex real number, fraction
6309 @cindex floating point, fraction
6312 @item @emph{Description}:
6313 @code{FRACTION(X)} returns the fractional part of the model
6314 representation of @code{X}.
6316 @item @emph{Standard}:
6317 Fortran 95 and later
6322 @item @emph{Syntax}:
6323 @code{Y = FRACTION(X)}
6325 @item @emph{Arguments}:
6326 @multitable @columnfractions .15 .70
6327 @item @var{X} @tab The type of the argument shall be a @code{REAL}.
6330 @item @emph{Return value}:
6331 The return value is of the same type and kind as the argument.
6332 The fractional part of the model representation of @code{X} is returned;
6333 it is @code{X * RADIX(X)**(-EXPONENT(X))}.
6335 @item @emph{Example}:
6337 program test_fraction
6340 print *, fraction(x), x * radix(x)**(-exponent(x))
6341 end program test_fraction
6349 @section @code{FREE} --- Frees memory
6351 @cindex pointer, cray
6354 @item @emph{Description}:
6355 Frees memory previously allocated by @code{MALLOC}. The @code{FREE}
6356 intrinsic is an extension intended to be used with Cray pointers, and is
6357 provided in GNU Fortran to allow user to compile legacy code. For
6358 new code using Fortran 95 pointers, the memory de-allocation intrinsic is
6361 @item @emph{Standard}:
6367 @item @emph{Syntax}:
6368 @code{CALL FREE(PTR)}
6370 @item @emph{Arguments}:
6371 @multitable @columnfractions .15 .70
6372 @item @var{PTR} @tab The type shall be @code{INTEGER}. It represents the
6373 location of the memory that should be de-allocated.
6376 @item @emph{Return value}:
6379 @item @emph{Example}:
6380 See @code{MALLOC} for an example.
6382 @item @emph{See also}:
6389 @section @code{FSEEK} --- Low level file positioning subroutine
6391 @cindex file operation, seek
6392 @cindex file operation, position
6395 @item @emph{Description}:
6396 Moves @var{UNIT} to the specified @var{OFFSET}. If @var{WHENCE}
6397 is set to 0, the @var{OFFSET} is taken as an absolute value @code{SEEK_SET},
6398 if set to 1, @var{OFFSET} is taken to be relative to the current position
6399 @code{SEEK_CUR}, and if set to 2 relative to the end of the file @code{SEEK_END}.
6400 On error, @var{STATUS} is set to a nonzero value. If @var{STATUS} the seek
6403 This intrinsic routine is not fully backwards compatible with @command{g77}.
6404 In @command{g77}, the @code{FSEEK} takes a statement label instead of a
6405 @var{STATUS} variable. If FSEEK is used in old code, change
6407 CALL FSEEK(UNIT, OFFSET, WHENCE, *label)
6412 CALL FSEEK(UNIT, OFFSET, WHENCE, status)
6413 IF (status /= 0) GOTO label
6416 Please note that GNU Fortran provides the Fortran 2003 Stream facility.
6417 Programmers should consider the use of new stream IO feature in new code
6418 for future portability. See also @ref{Fortran 2003 status}.
6420 @item @emph{Standard}:
6426 @item @emph{Syntax}:
6427 @code{CALL FSEEK(UNIT, OFFSET, WHENCE[, STATUS])}
6429 @item @emph{Arguments}:
6430 @multitable @columnfractions .15 .70
6431 @item @var{UNIT} @tab Shall be a scalar of type @code{INTEGER}.
6432 @item @var{OFFSET} @tab Shall be a scalar of type @code{INTEGER}.
6433 @item @var{WHENCE} @tab Shall be a scalar of type @code{INTEGER}.
6434 Its value shall be either 0, 1 or 2.
6435 @item @var{STATUS} @tab (Optional) shall be a scalar of type
6439 @item @emph{Example}:
6442 INTEGER, PARAMETER :: SEEK_SET = 0, SEEK_CUR = 1, SEEK_END = 2
6443 INTEGER :: fd, offset, ierr
6449 OPEN(UNIT=fd, FILE="fseek.test")
6450 CALL FSEEK(fd, offset, SEEK_SET, ierr) ! move to OFFSET
6451 print *, FTELL(fd), ierr
6453 CALL FSEEK(fd, 0, SEEK_END, ierr) ! move to end
6454 print *, FTELL(fd), ierr
6456 CALL FSEEK(fd, 0, SEEK_SET, ierr) ! move to beginning
6457 print *, FTELL(fd), ierr
6463 @item @emph{See also}:
6470 @section @code{FSTAT} --- Get file status
6472 @cindex file system, file status
6475 @item @emph{Description}:
6476 @code{FSTAT} is identical to @ref{STAT}, except that information about an
6477 already opened file is obtained.
6479 The elements in @code{VALUES} are the same as described by @ref{STAT}.
6481 This intrinsic is provided in both subroutine and function forms; however,
6482 only one form can be used in any given program unit.
6484 @item @emph{Standard}:
6488 Subroutine, function
6490 @item @emph{Syntax}:
6491 @multitable @columnfractions .80
6492 @item @code{CALL FSTAT(UNIT, VALUES [, STATUS])}
6493 @item @code{STATUS = FSTAT(UNIT, VALUES)}
6496 @item @emph{Arguments}:
6497 @multitable @columnfractions .15 .70
6498 @item @var{UNIT} @tab An open I/O unit number of type @code{INTEGER}.
6499 @item @var{VALUES} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
6500 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0
6501 on success and a system specific error code otherwise.
6504 @item @emph{Example}:
6505 See @ref{STAT} for an example.
6507 @item @emph{See also}:
6508 To stat a link: @ref{LSTAT}, to stat a file: @ref{STAT}
6514 @section @code{FTELL} --- Current stream position
6516 @cindex file operation, position
6519 @item @emph{Description}:
6520 Retrieves the current position within an open file.
6522 This intrinsic is provided in both subroutine and function forms; however,
6523 only one form can be used in any given program unit.
6525 @item @emph{Standard}:
6529 Subroutine, function
6531 @item @emph{Syntax}:
6532 @multitable @columnfractions .80
6533 @item @code{CALL FTELL(UNIT, OFFSET)}
6534 @item @code{OFFSET = FTELL(UNIT)}
6537 @item @emph{Arguments}:
6538 @multitable @columnfractions .15 .70
6539 @item @var{OFFSET} @tab Shall of type @code{INTEGER}.
6540 @item @var{UNIT} @tab Shall of type @code{INTEGER}.
6543 @item @emph{Return value}:
6544 In either syntax, @var{OFFSET} is set to the current offset of unit
6545 number @var{UNIT}, or to @math{-1} if the unit is not currently open.
6547 @item @emph{Example}:
6551 OPEN(10, FILE="temp.dat")
6557 @item @emph{See also}:
6564 @section @code{GAMMA} --- Gamma function
6567 @cindex Gamma function
6568 @cindex Factorial function
6571 @item @emph{Description}:
6572 @code{GAMMA(X)} computes Gamma (@math{\Gamma}) of @var{X}. For positive,
6573 integer values of @var{X} the Gamma function simplifies to the factorial
6574 function @math{\Gamma(x)=(x-1)!}.
6578 \Gamma(x) = \int_0^\infty t^{x-1}{\rm e}^{-t}\,{\rm d}t
6582 @item @emph{Standard}:
6583 Fortran 2008 and later
6588 @item @emph{Syntax}:
6591 @item @emph{Arguments}:
6592 @multitable @columnfractions .15 .70
6593 @item @var{X} @tab Shall be of type @code{REAL} and neither zero
6594 nor a negative integer.
6597 @item @emph{Return value}:
6598 The return value is of type @code{REAL} of the same kind as @var{X}.
6600 @item @emph{Example}:
6604 x = gamma(x) ! returns 1.0
6605 end program test_gamma
6608 @item @emph{Specific names}:
6609 @multitable @columnfractions .20 .20 .20 .25
6610 @item Name @tab Argument @tab Return type @tab Standard
6611 @item @code{GAMMA(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU Extension
6612 @item @code{DGAMMA(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU Extension
6615 @item @emph{See also}:
6616 Logarithm of the Gamma function: @ref{LOG_GAMMA}
6623 @section @code{GERROR} --- Get last system error message
6625 @cindex system, error handling
6628 @item @emph{Description}:
6629 Returns the system error message corresponding to the last system error.
6630 This resembles the functionality of @code{strerror(3)} in C.
6632 @item @emph{Standard}:
6638 @item @emph{Syntax}:
6639 @code{CALL GERROR(RESULT)}
6641 @item @emph{Arguments}:
6642 @multitable @columnfractions .15 .70
6643 @item @var{RESULT} @tab Shall of type @code{CHARACTER} and of default
6646 @item @emph{Example}:
6649 CHARACTER(len=100) :: msg
6655 @item @emph{See also}:
6656 @ref{IERRNO}, @ref{PERROR}
6662 @section @code{GETARG} --- Get command line arguments
6664 @cindex command-line arguments
6665 @cindex arguments, to program
6668 @item @emph{Description}:
6669 Retrieve the @var{POS}-th argument that was passed on the
6670 command line when the containing program was invoked.
6672 This intrinsic routine is provided for backwards compatibility with
6673 GNU Fortran 77. In new code, programmers should consider the use of
6674 the @ref{GET_COMMAND_ARGUMENT} intrinsic defined by the Fortran 2003
6677 @item @emph{Standard}:
6683 @item @emph{Syntax}:
6684 @code{CALL GETARG(POS, VALUE)}
6686 @item @emph{Arguments}:
6687 @multitable @columnfractions .15 .70
6688 @item @var{POS} @tab Shall be of type @code{INTEGER} and not wider than
6689 the default integer kind; @math{@var{POS} \geq 0}
6690 @item @var{VALUE} @tab Shall be of type @code{CHARACTER} and of default
6692 @item @var{VALUE} @tab Shall be of type @code{CHARACTER}.
6695 @item @emph{Return value}:
6696 After @code{GETARG} returns, the @var{VALUE} argument holds the
6697 @var{POS}th command line argument. If @var{VALUE} can not hold the
6698 argument, it is truncated to fit the length of @var{VALUE}. If there are
6699 less than @var{POS} arguments specified at the command line, @var{VALUE}
6700 will be filled with blanks. If @math{@var{POS} = 0}, @var{VALUE} is set
6701 to the name of the program (on systems that support this feature).
6703 @item @emph{Example}:
6707 CHARACTER(len=32) :: arg
6716 @item @emph{See also}:
6717 GNU Fortran 77 compatibility function: @ref{IARGC}
6719 Fortran 2003 functions and subroutines: @ref{GET_COMMAND},
6720 @ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
6726 @section @code{GET_COMMAND} --- Get the entire command line
6727 @fnindex GET_COMMAND
6728 @cindex command-line arguments
6729 @cindex arguments, to program
6732 @item @emph{Description}:
6733 Retrieve the entire command line that was used to invoke the program.
6735 @item @emph{Standard}:
6736 Fortran 2003 and later
6741 @item @emph{Syntax}:
6742 @code{CALL GET_COMMAND([COMMAND, LENGTH, STATUS])}
6744 @item @emph{Arguments}:
6745 @multitable @columnfractions .15 .70
6746 @item @var{COMMAND} @tab (Optional) shall be of type @code{CHARACTER} and
6748 @item @var{LENGTH} @tab (Optional) Shall be of type @code{INTEGER} and of
6750 @item @var{STATUS} @tab (Optional) Shall be of type @code{INTEGER} and of
6754 @item @emph{Return value}:
6755 If @var{COMMAND} is present, stores the entire command line that was used
6756 to invoke the program in @var{COMMAND}. If @var{LENGTH} is present, it is
6757 assigned the length of the command line. If @var{STATUS} is present, it
6758 is assigned 0 upon success of the command, -1 if @var{COMMAND} is too
6759 short to store the command line, or a positive value in case of an error.
6761 @item @emph{Example}:
6763 PROGRAM test_get_command
6764 CHARACTER(len=255) :: cmd
6765 CALL get_command(cmd)
6766 WRITE (*,*) TRIM(cmd)
6770 @item @emph{See also}:
6771 @ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
6776 @node GET_COMMAND_ARGUMENT
6777 @section @code{GET_COMMAND_ARGUMENT} --- Get command line arguments
6778 @fnindex GET_COMMAND_ARGUMENT
6779 @cindex command-line arguments
6780 @cindex arguments, to program
6783 @item @emph{Description}:
6784 Retrieve the @var{NUMBER}-th argument that was passed on the
6785 command line when the containing program was invoked.
6787 @item @emph{Standard}:
6788 Fortran 2003 and later
6793 @item @emph{Syntax}:
6794 @code{CALL GET_COMMAND_ARGUMENT(NUMBER [, VALUE, LENGTH, STATUS])}
6796 @item @emph{Arguments}:
6797 @multitable @columnfractions .15 .70
6798 @item @var{NUMBER} @tab Shall be a scalar of type @code{INTEGER} and of
6799 default kind, @math{@var{NUMBER} \geq 0}
6800 @item @var{VALUE} @tab (Optional) Shall be a scalar of type @code{CHARACTER}
6801 and of default kind.
6802 @item @var{LENGTH} @tab (Optional) Shall be a scalar of type @code{INTEGER}
6803 and of default kind.
6804 @item @var{STATUS} @tab (Optional) Shall be a scalar of type @code{INTEGER}
6805 and of default kind.
6808 @item @emph{Return value}:
6809 After @code{GET_COMMAND_ARGUMENT} returns, the @var{VALUE} argument holds the
6810 @var{NUMBER}-th command line argument. If @var{VALUE} can not hold the argument, it is
6811 truncated to fit the length of @var{VALUE}. If there are less than @var{NUMBER}
6812 arguments specified at the command line, @var{VALUE} will be filled with blanks.
6813 If @math{@var{NUMBER} = 0}, @var{VALUE} is set to the name of the program (on
6814 systems that support this feature). The @var{LENGTH} argument contains the
6815 length of the @var{NUMBER}-th command line argument. If the argument retrieval
6816 fails, @var{STATUS} is a positive number; if @var{VALUE} contains a truncated
6817 command line argument, @var{STATUS} is -1; and otherwise the @var{STATUS} is
6820 @item @emph{Example}:
6822 PROGRAM test_get_command_argument
6824 CHARACTER(len=32) :: arg
6828 CALL get_command_argument(i, arg)
6829 IF (LEN_TRIM(arg) == 0) EXIT
6831 WRITE (*,*) TRIM(arg)
6837 @item @emph{See also}:
6838 @ref{GET_COMMAND}, @ref{COMMAND_ARGUMENT_COUNT}
6844 @section @code{GETCWD} --- Get current working directory
6846 @cindex system, working directory
6849 @item @emph{Description}:
6850 Get current working directory.
6852 This intrinsic is provided in both subroutine and function forms; however,
6853 only one form can be used in any given program unit.
6855 @item @emph{Standard}:
6859 Subroutine, function
6861 @item @emph{Syntax}:
6862 @multitable @columnfractions .80
6863 @item @code{CALL GETCWD(C [, STATUS])}
6864 @item @code{STATUS = GETCWD(C)}
6867 @item @emph{Arguments}:
6868 @multitable @columnfractions .15 .70
6869 @item @var{C} @tab The type shall be @code{CHARACTER} and of default kind.
6870 @item @var{STATUS} @tab (Optional) status flag. Returns 0 on success,
6871 a system specific and nonzero error code otherwise.
6874 @item @emph{Example}:
6877 CHARACTER(len=255) :: cwd
6879 WRITE(*,*) TRIM(cwd)
6883 @item @emph{See also}:
6890 @section @code{GETENV} --- Get an environmental variable
6892 @cindex environment variable
6895 @item @emph{Description}:
6896 Get the @var{VALUE} of the environmental variable @var{NAME}.
6898 This intrinsic routine is provided for backwards compatibility with
6899 GNU Fortran 77. In new code, programmers should consider the use of
6900 the @ref{GET_ENVIRONMENT_VARIABLE} intrinsic defined by the Fortran
6903 Note that @code{GETENV} need not be thread-safe. It is the
6904 responsibility of the user to ensure that the environment is not being
6905 updated concurrently with a call to the @code{GETENV} intrinsic.
6907 @item @emph{Standard}:
6913 @item @emph{Syntax}:
6914 @code{CALL GETENV(NAME, VALUE)}
6916 @item @emph{Arguments}:
6917 @multitable @columnfractions .15 .70
6918 @item @var{NAME} @tab Shall be of type @code{CHARACTER} and of default kind.
6919 @item @var{VALUE} @tab Shall be of type @code{CHARACTER} and of default kind.
6922 @item @emph{Return value}:
6923 Stores the value of @var{NAME} in @var{VALUE}. If @var{VALUE} is
6924 not large enough to hold the data, it is truncated. If @var{NAME}
6925 is not set, @var{VALUE} will be filled with blanks.
6927 @item @emph{Example}:
6930 CHARACTER(len=255) :: homedir
6931 CALL getenv("HOME", homedir)
6932 WRITE (*,*) TRIM(homedir)
6936 @item @emph{See also}:
6937 @ref{GET_ENVIRONMENT_VARIABLE}
6942 @node GET_ENVIRONMENT_VARIABLE
6943 @section @code{GET_ENVIRONMENT_VARIABLE} --- Get an environmental variable
6944 @fnindex GET_ENVIRONMENT_VARIABLE
6945 @cindex environment variable
6948 @item @emph{Description}:
6949 Get the @var{VALUE} of the environmental variable @var{NAME}.
6951 Note that @code{GET_ENVIRONMENT_VARIABLE} need not be thread-safe. It
6952 is the responsibility of the user to ensure that the environment is
6953 not being updated concurrently with a call to the
6954 @code{GET_ENVIRONMENT_VARIABLE} intrinsic.
6956 @item @emph{Standard}:
6957 Fortran 2003 and later
6962 @item @emph{Syntax}:
6963 @code{CALL GET_ENVIRONMENT_VARIABLE(NAME[, VALUE, LENGTH, STATUS, TRIM_NAME)}
6965 @item @emph{Arguments}:
6966 @multitable @columnfractions .15 .70
6967 @item @var{NAME} @tab Shall be a scalar of type @code{CHARACTER}
6968 and of default kind.
6969 @item @var{VALUE} @tab (Optional) Shall be a scalar of type @code{CHARACTER}
6970 and of default kind.
6971 @item @var{LENGTH} @tab (Optional) Shall be a scalar of type @code{INTEGER}
6972 and of default kind.
6973 @item @var{STATUS} @tab (Optional) Shall be a scalar of type @code{INTEGER}
6974 and of default kind.
6975 @item @var{TRIM_NAME} @tab (Optional) Shall be a scalar of type @code{LOGICAL}
6976 and of default kind.
6979 @item @emph{Return value}:
6980 Stores the value of @var{NAME} in @var{VALUE}. If @var{VALUE} is
6981 not large enough to hold the data, it is truncated. If @var{NAME}
6982 is not set, @var{VALUE} will be filled with blanks. Argument @var{LENGTH}
6983 contains the length needed for storing the environment variable @var{NAME}
6984 or zero if it is not present. @var{STATUS} is -1 if @var{VALUE} is present
6985 but too short for the environment variable; it is 1 if the environment
6986 variable does not exist and 2 if the processor does not support environment
6987 variables; in all other cases @var{STATUS} is zero. If @var{TRIM_NAME} is
6988 present with the value @code{.FALSE.}, the trailing blanks in @var{NAME}
6989 are significant; otherwise they are not part of the environment variable
6992 @item @emph{Example}:
6995 CHARACTER(len=255) :: homedir
6996 CALL get_environment_variable("HOME", homedir)
6997 WRITE (*,*) TRIM(homedir)
7005 @section @code{GETGID} --- Group ID function
7007 @cindex system, group ID
7010 @item @emph{Description}:
7011 Returns the numerical group ID of the current process.
7013 @item @emph{Standard}:
7019 @item @emph{Syntax}:
7020 @code{RESULT = GETGID()}
7022 @item @emph{Return value}:
7023 The return value of @code{GETGID} is an @code{INTEGER} of the default
7027 @item @emph{Example}:
7028 See @code{GETPID} for an example.
7030 @item @emph{See also}:
7031 @ref{GETPID}, @ref{GETUID}
7037 @section @code{GETLOG} --- Get login name
7039 @cindex system, login name
7043 @item @emph{Description}:
7044 Gets the username under which the program is running.
7046 @item @emph{Standard}:
7052 @item @emph{Syntax}:
7053 @code{CALL GETLOG(C)}
7055 @item @emph{Arguments}:
7056 @multitable @columnfractions .15 .70
7057 @item @var{C} @tab Shall be of type @code{CHARACTER} and of default kind.
7060 @item @emph{Return value}:
7061 Stores the current user name in @var{LOGIN}. (On systems where POSIX
7062 functions @code{geteuid} and @code{getpwuid} are not available, and
7063 the @code{getlogin} function is not implemented either, this will
7064 return a blank string.)
7066 @item @emph{Example}:
7069 CHARACTER(32) :: login
7075 @item @emph{See also}:
7082 @section @code{GETPID} --- Process ID function
7084 @cindex system, process ID
7088 @item @emph{Description}:
7089 Returns the numerical process identifier of the current process.
7091 @item @emph{Standard}:
7097 @item @emph{Syntax}:
7098 @code{RESULT = GETPID()}
7100 @item @emph{Return value}:
7101 The return value of @code{GETPID} is an @code{INTEGER} of the default
7105 @item @emph{Example}:
7108 print *, "The current process ID is ", getpid()
7109 print *, "Your numerical user ID is ", getuid()
7110 print *, "Your numerical group ID is ", getgid()
7114 @item @emph{See also}:
7115 @ref{GETGID}, @ref{GETUID}
7121 @section @code{GETUID} --- User ID function
7123 @cindex system, user ID
7127 @item @emph{Description}:
7128 Returns the numerical user ID of the current process.
7130 @item @emph{Standard}:
7136 @item @emph{Syntax}:
7137 @code{RESULT = GETUID()}
7139 @item @emph{Return value}:
7140 The return value of @code{GETUID} is an @code{INTEGER} of the default
7144 @item @emph{Example}:
7145 See @code{GETPID} for an example.
7147 @item @emph{See also}:
7148 @ref{GETPID}, @ref{GETLOG}
7154 @section @code{GMTIME} --- Convert time to GMT info
7156 @cindex time, conversion to GMT info
7159 @item @emph{Description}:
7160 Given a system time value @var{TIME} (as provided by the @ref{TIME}
7161 intrinsic), fills @var{VALUES} with values extracted from it appropriate
7162 to the UTC time zone (Universal Coordinated Time, also known in some
7163 countries as GMT, Greenwich Mean Time), using @code{gmtime(3)}.
7165 This intrinsic routine is provided for backwards compatibility with
7166 GNU Fortran 77. In new code, programmers should consider the use of
7167 the @ref{DATE_AND_TIME} intrinsic defined by the Fortran 95
7170 @item @emph{Standard}:
7176 @item @emph{Syntax}:
7177 @code{CALL GMTIME(TIME, VALUES)}
7179 @item @emph{Arguments}:
7180 @multitable @columnfractions .15 .70
7181 @item @var{TIME} @tab An @code{INTEGER} scalar expression
7182 corresponding to a system time, with @code{INTENT(IN)}.
7183 @item @var{VALUES} @tab A default @code{INTEGER} array with 9 elements,
7184 with @code{INTENT(OUT)}.
7187 @item @emph{Return value}:
7188 The elements of @var{VALUES} are assigned as follows:
7190 @item Seconds after the minute, range 0--59 or 0--61 to allow for leap
7192 @item Minutes after the hour, range 0--59
7193 @item Hours past midnight, range 0--23
7194 @item Day of month, range 1--31
7195 @item Number of months since January, range 0--11
7196 @item Years since 1900
7197 @item Number of days since Sunday, range 0--6
7198 @item Days since January 1, range 0--365
7199 @item Daylight savings indicator: positive if daylight savings is in
7200 effect, zero if not, and negative if the information is not available.
7203 @item @emph{See also}:
7204 @ref{DATE_AND_TIME}, @ref{CTIME}, @ref{LTIME}, @ref{TIME}, @ref{TIME8}
7211 @section @code{HOSTNM} --- Get system host name
7213 @cindex system, host name
7216 @item @emph{Description}:
7217 Retrieves the host name of the system on which the program is running.
7219 This intrinsic is provided in both subroutine and function forms; however,
7220 only one form can be used in any given program unit.
7222 @item @emph{Standard}:
7226 Subroutine, function
7228 @item @emph{Syntax}:
7229 @multitable @columnfractions .80
7230 @item @code{CALL HOSTNM(C [, STATUS])}
7231 @item @code{STATUS = HOSTNM(NAME)}
7234 @item @emph{Arguments}:
7235 @multitable @columnfractions .15 .70
7236 @item @var{C} @tab Shall of type @code{CHARACTER} and of default kind.
7237 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
7238 Returns 0 on success, or a system specific error code otherwise.
7241 @item @emph{Return value}:
7242 In either syntax, @var{NAME} is set to the current hostname if it can
7243 be obtained, or to a blank string otherwise.
7250 @section @code{HUGE} --- Largest number of a kind
7252 @cindex limits, largest number
7253 @cindex model representation, largest number
7256 @item @emph{Description}:
7257 @code{HUGE(X)} returns the largest number that is not an infinity in
7258 the model of the type of @code{X}.
7260 @item @emph{Standard}:
7261 Fortran 95 and later
7266 @item @emph{Syntax}:
7267 @code{RESULT = HUGE(X)}
7269 @item @emph{Arguments}:
7270 @multitable @columnfractions .15 .70
7271 @item @var{X} @tab Shall be of type @code{REAL} or @code{INTEGER}.
7274 @item @emph{Return value}:
7275 The return value is of the same type and kind as @var{X}
7277 @item @emph{Example}:
7279 program test_huge_tiny
7280 print *, huge(0), huge(0.0), huge(0.0d0)
7281 print *, tiny(0.0), tiny(0.0d0)
7282 end program test_huge_tiny
7289 @section @code{HYPOT} --- Euclidean distance function
7291 @cindex Euclidean distance
7294 @item @emph{Description}:
7295 @code{HYPOT(X,Y)} is the Euclidean distance function. It is equal to
7296 @math{\sqrt{X^2 + Y^2}}, without undue underflow or overflow.
7298 @item @emph{Standard}:
7299 Fortran 2008 and later
7304 @item @emph{Syntax}:
7305 @code{RESULT = HYPOT(X, Y)}
7307 @item @emph{Arguments}:
7308 @multitable @columnfractions .15 .70
7309 @item @var{X} @tab The type shall be @code{REAL}.
7310 @item @var{Y} @tab The type and kind type parameter shall be the same as
7314 @item @emph{Return value}:
7315 The return value has the same type and kind type parameter as @var{X}.
7317 @item @emph{Example}:
7320 real(4) :: x = 1.e0_4, y = 0.5e0_4
7322 end program test_hypot
7329 @section @code{IACHAR} --- Code in @acronym{ASCII} collating sequence
7331 @cindex @acronym{ASCII} collating sequence
7332 @cindex collating sequence, @acronym{ASCII}
7333 @cindex conversion, to integer
7336 @item @emph{Description}:
7337 @code{IACHAR(C)} returns the code for the @acronym{ASCII} character
7338 in the first character position of @code{C}.
7340 @item @emph{Standard}:
7341 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
7346 @item @emph{Syntax}:
7347 @code{RESULT = IACHAR(C [, KIND])}
7349 @item @emph{Arguments}:
7350 @multitable @columnfractions .15 .70
7351 @item @var{C} @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
7352 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
7353 expression indicating the kind parameter of the result.
7356 @item @emph{Return value}:
7357 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
7358 @var{KIND} is absent, the return value is of default integer kind.
7360 @item @emph{Example}:
7365 end program test_iachar
7369 See @ref{ICHAR} for a discussion of converting between numerical values
7370 and formatted string representations.
7372 @item @emph{See also}:
7373 @ref{ACHAR}, @ref{CHAR}, @ref{ICHAR}
7380 @section @code{IALL} --- Bitwise AND of array elements
7383 @cindex bits, AND of array elements
7386 @item @emph{Description}:
7387 Reduces with bitwise AND the elements of @var{ARRAY} along dimension @var{DIM}
7388 if the corresponding element in @var{MASK} is @code{TRUE}.
7390 @item @emph{Standard}:
7391 Fortran 2008 and later
7394 Transformational function
7396 @item @emph{Syntax}:
7397 @multitable @columnfractions .80
7398 @item @code{RESULT = IALL(ARRAY[, MASK])}
7399 @item @code{RESULT = IALL(ARRAY, DIM[, MASK])}
7402 @item @emph{Arguments}:
7403 @multitable @columnfractions .15 .70
7404 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER}
7405 @item @var{DIM} @tab (Optional) shall be a scalar of type
7406 @code{INTEGER} with a value in the range from 1 to n, where n
7407 equals the rank of @var{ARRAY}.
7408 @item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL}
7409 and either be a scalar or an array of the same shape as @var{ARRAY}.
7412 @item @emph{Return value}:
7413 The result is of the same type as @var{ARRAY}.
7415 If @var{DIM} is absent, a scalar with the bitwise ALL of all elements in
7416 @var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals
7417 the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with
7418 dimension @var{DIM} dropped is returned.
7420 @item @emph{Example}:
7429 PRINT '(b8.8)', IALL(a)
7433 @item @emph{See also}:
7434 @ref{IANY}, @ref{IPARITY}, @ref{IAND}
7440 @section @code{IAND} --- Bitwise logical and
7446 @cindex bitwise logical and
7447 @cindex logical and, bitwise
7450 @item @emph{Description}:
7451 Bitwise logical @code{AND}.
7453 @item @emph{Standard}:
7454 Fortran 95 and later, has overloads that are GNU extensions
7459 @item @emph{Syntax}:
7460 @code{RESULT = IAND(I, J)}
7462 @item @emph{Arguments}:
7463 @multitable @columnfractions .15 .70
7464 @item @var{I} @tab The type shall be @code{INTEGER}.
7465 @item @var{J} @tab The type shall be @code{INTEGER}, of the same
7466 kind as @var{I}. (As a GNU extension, different kinds are also
7470 @item @emph{Return value}:
7471 The return type is @code{INTEGER}, of the same kind as the
7472 arguments. (If the argument kinds differ, it is of the same kind as
7473 the larger argument.)
7475 @item @emph{Example}:
7479 DATA a / Z'F' /, b / Z'3' /
7480 WRITE (*,*) IAND(a, b)
7484 @item @emph{Specific names}:
7485 @multitable @columnfractions .20 .20 .20 .25
7486 @item Name @tab Argument @tab Return type @tab Standard
7487 @item @code{IAND(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 95 and later
7488 @item @code{BIAND(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
7489 @item @code{IIAND(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
7490 @item @code{JIAND(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
7491 @item @code{KIAND(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
7494 @item @emph{See also}:
7495 @ref{IOR}, @ref{IEOR}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
7502 @section @code{IANY} --- Bitwise OR of array elements
7505 @cindex bits, OR of array elements
7508 @item @emph{Description}:
7509 Reduces with bitwise OR (inclusive or) the elements of @var{ARRAY} along
7510 dimension @var{DIM} if the corresponding element in @var{MASK} is @code{TRUE}.
7512 @item @emph{Standard}:
7513 Fortran 2008 and later
7516 Transformational function
7518 @item @emph{Syntax}:
7519 @multitable @columnfractions .80
7520 @item @code{RESULT = IANY(ARRAY[, MASK])}
7521 @item @code{RESULT = IANY(ARRAY, DIM[, MASK])}
7524 @item @emph{Arguments}:
7525 @multitable @columnfractions .15 .70
7526 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER}
7527 @item @var{DIM} @tab (Optional) shall be a scalar of type
7528 @code{INTEGER} with a value in the range from 1 to n, where n
7529 equals the rank of @var{ARRAY}.
7530 @item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL}
7531 and either be a scalar or an array of the same shape as @var{ARRAY}.
7534 @item @emph{Return value}:
7535 The result is of the same type as @var{ARRAY}.
7537 If @var{DIM} is absent, a scalar with the bitwise OR of all elements in
7538 @var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals
7539 the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with
7540 dimension @var{DIM} dropped is returned.
7542 @item @emph{Example}:
7551 PRINT '(b8.8)', IANY(a)
7555 @item @emph{See also}:
7556 @ref{IPARITY}, @ref{IALL}, @ref{IOR}
7562 @section @code{IARGC} --- Get the number of command line arguments
7564 @cindex command-line arguments
7565 @cindex command-line arguments, number of
7566 @cindex arguments, to program
7569 @item @emph{Description}:
7570 @code{IARGC} returns the number of arguments passed on the
7571 command line when the containing program was invoked.
7573 This intrinsic routine is provided for backwards compatibility with
7574 GNU Fortran 77. In new code, programmers should consider the use of
7575 the @ref{COMMAND_ARGUMENT_COUNT} intrinsic defined by the Fortran 2003
7578 @item @emph{Standard}:
7584 @item @emph{Syntax}:
7585 @code{RESULT = IARGC()}
7587 @item @emph{Arguments}:
7590 @item @emph{Return value}:
7591 The number of command line arguments, type @code{INTEGER(4)}.
7593 @item @emph{Example}:
7596 @item @emph{See also}:
7597 GNU Fortran 77 compatibility subroutine: @ref{GETARG}
7599 Fortran 2003 functions and subroutines: @ref{GET_COMMAND},
7600 @ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
7606 @section @code{IBCLR} --- Clear bit
7616 @item @emph{Description}:
7617 @code{IBCLR} returns the value of @var{I} with the bit at position
7618 @var{POS} set to zero.
7620 @item @emph{Standard}:
7621 Fortran 95 and later, has overloads that are GNU extensions
7626 @item @emph{Syntax}:
7627 @code{RESULT = IBCLR(I, POS)}
7629 @item @emph{Arguments}:
7630 @multitable @columnfractions .15 .70
7631 @item @var{I} @tab The type shall be @code{INTEGER}.
7632 @item @var{POS} @tab The type shall be @code{INTEGER}.
7635 @item @emph{Return value}:
7636 The return value is of type @code{INTEGER} and of the same kind as
7639 @item @emph{Specific names}:
7640 @multitable @columnfractions .20 .20 .20 .25
7641 @item Name @tab Argument @tab Return type @tab Standard
7642 @item @code{IBCLR(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 95 and later
7643 @item @code{BBCLR(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
7644 @item @code{IIBCLR(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
7645 @item @code{JIBCLR(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
7646 @item @code{KIBCLR(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
7649 @item @emph{See also}:
7650 @ref{IBITS}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}, @ref{MVBITS}
7657 @section @code{IBITS} --- Bit extraction
7664 @cindex bits, extract
7667 @item @emph{Description}:
7668 @code{IBITS} extracts a field of length @var{LEN} from @var{I},
7669 starting from bit position @var{POS} and extending left for @var{LEN}
7670 bits. The result is right-justified and the remaining bits are
7671 zeroed. The value of @code{POS+LEN} must be less than or equal to the
7672 value @code{BIT_SIZE(I)}.
7674 @item @emph{Standard}:
7675 Fortran 95 and later, has overloads that are GNU extensions
7680 @item @emph{Syntax}:
7681 @code{RESULT = IBITS(I, POS, LEN)}
7683 @item @emph{Arguments}:
7684 @multitable @columnfractions .15 .70
7685 @item @var{I} @tab The type shall be @code{INTEGER}.
7686 @item @var{POS} @tab The type shall be @code{INTEGER}.
7687 @item @var{LEN} @tab The type shall be @code{INTEGER}.
7690 @item @emph{Return value}:
7691 The return value is of type @code{INTEGER} and of the same kind as
7694 @item @emph{Specific names}:
7695 @multitable @columnfractions .20 .20 .20 .25
7696 @item Name @tab Argument @tab Return type @tab Standard
7697 @item @code{IBITS(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 95 and later
7698 @item @code{BBITS(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
7699 @item @code{IIBITS(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
7700 @item @code{JIBITS(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
7701 @item @code{KIBITS(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
7704 @item @emph{See also}:
7705 @ref{BIT_SIZE}, @ref{IBCLR}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
7711 @section @code{IBSET} --- Set bit
7720 @item @emph{Description}:
7721 @code{IBSET} returns the value of @var{I} with the bit at position
7722 @var{POS} set to one.
7724 @item @emph{Standard}:
7725 Fortran 95 and later, has overloads that are GNU extensions
7730 @item @emph{Syntax}:
7731 @code{RESULT = IBSET(I, POS)}
7733 @item @emph{Arguments}:
7734 @multitable @columnfractions .15 .70
7735 @item @var{I} @tab The type shall be @code{INTEGER}.
7736 @item @var{POS} @tab The type shall be @code{INTEGER}.
7739 @item @emph{Return value}:
7740 The return value is of type @code{INTEGER} and of the same kind as
7743 @item @emph{Specific names}:
7744 @multitable @columnfractions .20 .20 .20 .25
7745 @item Name @tab Argument @tab Return type @tab Standard
7746 @item @code{IBSET(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 95 and later
7747 @item @code{BBSET(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
7748 @item @code{IIBSET(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
7749 @item @code{JIBSET(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
7750 @item @code{KIBSET(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
7753 @item @emph{See also}:
7754 @ref{IBCLR}, @ref{IBITS}, @ref{IAND}, @ref{IOR}, @ref{IEOR}, @ref{MVBITS}
7761 @section @code{ICHAR} --- Character-to-integer conversion function
7763 @cindex conversion, to integer
7766 @item @emph{Description}:
7767 @code{ICHAR(C)} returns the code for the character in the first character
7768 position of @code{C} in the system's native character set.
7769 The correspondence between characters and their codes is not necessarily
7770 the same across different GNU Fortran implementations.
7772 @item @emph{Standard}:
7773 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
7778 @item @emph{Syntax}:
7779 @code{RESULT = ICHAR(C [, KIND])}
7781 @item @emph{Arguments}:
7782 @multitable @columnfractions .15 .70
7783 @item @var{C} @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
7784 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
7785 expression indicating the kind parameter of the result.
7788 @item @emph{Return value}:
7789 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
7790 @var{KIND} is absent, the return value is of default integer kind.
7792 @item @emph{Example}:
7797 end program test_ichar
7800 @item @emph{Specific names}:
7801 @multitable @columnfractions .20 .20 .20 .25
7802 @item Name @tab Argument @tab Return type @tab Standard
7803 @item @code{ICHAR(C)} @tab @code{CHARACTER C} @tab @code{INTEGER(4)} @tab Fortran 77 and later
7807 No intrinsic exists to convert between a numeric value and a formatted
7808 character string representation -- for instance, given the
7809 @code{CHARACTER} value @code{'154'}, obtaining an @code{INTEGER} or
7810 @code{REAL} value with the value 154, or vice versa. Instead, this
7811 functionality is provided by internal-file I/O, as in the following
7816 character(len=10) string, string2
7819 ! Convert a string to a numeric value
7820 read (string,'(I10)') value
7823 ! Convert a value to a formatted string
7824 write (string2,'(I10)') value
7826 end program read_val
7829 @item @emph{See also}:
7830 @ref{ACHAR}, @ref{CHAR}, @ref{IACHAR}
7837 @section @code{IDATE} --- Get current local time subroutine (day/month/year)
7839 @cindex date, current
7840 @cindex current date
7843 @item @emph{Description}:
7844 @code{IDATE(VALUES)} Fills @var{VALUES} with the numerical values at the
7845 current local time. The day (in the range 1-31), month (in the range 1-12),
7846 and year appear in elements 1, 2, and 3 of @var{VALUES}, respectively.
7847 The year has four significant digits.
7849 This intrinsic routine is provided for backwards compatibility with
7850 GNU Fortran 77. In new code, programmers should consider the use of
7851 the @ref{DATE_AND_TIME} intrinsic defined by the Fortran 95
7854 @item @emph{Standard}:
7860 @item @emph{Syntax}:
7861 @code{CALL IDATE(VALUES)}
7863 @item @emph{Arguments}:
7864 @multitable @columnfractions .15 .70
7865 @item @var{VALUES} @tab The type shall be @code{INTEGER, DIMENSION(3)} and
7866 the kind shall be the default integer kind.
7869 @item @emph{Return value}:
7870 Does not return anything.
7872 @item @emph{Example}:
7875 integer, dimension(3) :: tarray
7880 end program test_idate
7883 @item @emph{See also}:
7889 @section @code{IEOR} --- Bitwise logical exclusive or
7895 @cindex bitwise logical exclusive or
7896 @cindex logical exclusive or, bitwise
7899 @item @emph{Description}:
7900 @code{IEOR} returns the bitwise Boolean exclusive-OR of @var{I} and
7903 @item @emph{Standard}:
7904 Fortran 95 and later, has overloads that are GNU extensions
7909 @item @emph{Syntax}:
7910 @code{RESULT = IEOR(I, J)}
7912 @item @emph{Arguments}:
7913 @multitable @columnfractions .15 .70
7914 @item @var{I} @tab The type shall be @code{INTEGER}.
7915 @item @var{J} @tab The type shall be @code{INTEGER}, of the same
7916 kind as @var{I}. (As a GNU extension, different kinds are also
7920 @item @emph{Return value}:
7921 The return type is @code{INTEGER}, of the same kind as the
7922 arguments. (If the argument kinds differ, it is of the same kind as
7923 the larger argument.)
7925 @item @emph{Specific names}:
7926 @multitable @columnfractions .20 .20 .20 .25
7927 @item Name @tab Argument @tab Return type @tab Standard
7928 @item @code{IEOR(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 95 and later
7929 @item @code{BIEOR(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
7930 @item @code{IIEOR(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
7931 @item @code{JIEOR(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
7932 @item @code{KIEOR(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
7935 @item @emph{See also}:
7936 @ref{IOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
7942 @section @code{IERRNO} --- Get the last system error number
7944 @cindex system, error handling
7947 @item @emph{Description}:
7948 Returns the last system error number, as given by the C @code{errno}
7951 @item @emph{Standard}:
7957 @item @emph{Syntax}:
7958 @code{RESULT = IERRNO()}
7960 @item @emph{Arguments}:
7963 @item @emph{Return value}:
7964 The return value is of type @code{INTEGER} and of the default integer
7967 @item @emph{See also}:
7974 @section @code{IMAGE_INDEX} --- Function that converts a cosubscript to an image index
7975 @fnindex IMAGE_INDEX
7976 @cindex coarray, @code{IMAGE_INDEX}
7977 @cindex images, cosubscript to image index conversion
7980 @item @emph{Description}:
7981 Returns the image index belonging to a cosubscript.
7983 @item @emph{Standard}:
7984 Fortran 2008 and later
7989 @item @emph{Syntax}:
7990 @code{RESULT = IMAGE_INDEX(COARRAY, SUB)}
7992 @item @emph{Arguments}: None.
7993 @multitable @columnfractions .15 .70
7994 @item @var{COARRAY} @tab Coarray of any type.
7995 @item @var{SUB} @tab default integer rank-1 array of a size equal to
7996 the corank of @var{COARRAY}.
8000 @item @emph{Return value}:
8001 Scalar default integer with the value of the image index which corresponds
8002 to the cosubscripts. For invalid cosubscripts the result is zero.
8004 @item @emph{Example}:
8006 INTEGER :: array[2,-1:4,8,*]
8007 ! Writes 28 (or 0 if there are fewer than 28 images)
8008 WRITE (*,*) IMAGE_INDEX (array, [2,0,3,1])
8011 @item @emph{See also}:
8012 @ref{THIS_IMAGE}, @ref{NUM_IMAGES}
8017 @node INDEX intrinsic
8018 @section @code{INDEX} --- Position of a substring within a string
8020 @cindex substring position
8021 @cindex string, find substring
8024 @item @emph{Description}:
8025 Returns the position of the start of the first occurrence of string
8026 @var{SUBSTRING} as a substring in @var{STRING}, counting from one. If
8027 @var{SUBSTRING} is not present in @var{STRING}, zero is returned. If
8028 the @var{BACK} argument is present and true, the return value is the
8029 start of the last occurrence rather than the first.
8031 @item @emph{Standard}:
8032 Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later
8037 @item @emph{Syntax}:
8038 @code{RESULT = INDEX(STRING, SUBSTRING [, BACK [, KIND]])}
8040 @item @emph{Arguments}:
8041 @multitable @columnfractions .15 .70
8042 @item @var{STRING} @tab Shall be a scalar @code{CHARACTER}, with
8044 @item @var{SUBSTRING} @tab Shall be a scalar @code{CHARACTER}, with
8046 @item @var{BACK} @tab (Optional) Shall be a scalar @code{LOGICAL}, with
8048 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
8049 expression indicating the kind parameter of the result.
8052 @item @emph{Return value}:
8053 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
8054 @var{KIND} is absent, the return value is of default integer kind.
8056 @item @emph{Specific names}:
8057 @multitable @columnfractions .20 .20 .20 .25
8058 @item Name @tab Argument @tab Return type @tab Standard
8059 @item @code{INDEX(STRING, SUBSTRING)} @tab @code{CHARACTER} @tab @code{INTEGER(4)} @tab Fortran 77 and later
8062 @item @emph{See also}:
8063 @ref{SCAN}, @ref{VERIFY}
8069 @section @code{INT} --- Convert to integer type
8073 @cindex conversion, to integer
8076 @item @emph{Description}:
8077 Convert to integer type
8079 @item @emph{Standard}:
8080 Fortran 77 and later
8085 @item @emph{Syntax}:
8086 @code{RESULT = INT(A [, KIND))}
8088 @item @emph{Arguments}:
8089 @multitable @columnfractions .15 .70
8090 @item @var{A} @tab Shall be of type @code{INTEGER},
8091 @code{REAL}, or @code{COMPLEX}.
8092 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
8093 expression indicating the kind parameter of the result.
8096 @item @emph{Return value}:
8097 These functions return a @code{INTEGER} variable or array under
8098 the following rules:
8102 If @var{A} is of type @code{INTEGER}, @code{INT(A) = A}
8104 If @var{A} is of type @code{REAL} and @math{|A| < 1}, @code{INT(A)}
8105 equals @code{0}. If @math{|A| \geq 1}, then @code{INT(A)} is the integer
8106 whose magnitude is the largest integer that does not exceed the magnitude
8107 of @var{A} and whose sign is the same as the sign of @var{A}.
8109 If @var{A} is of type @code{COMPLEX}, rule B is applied to the real part of @var{A}.
8112 @item @emph{Example}:
8116 complex :: z = (-3.7, 1.0)
8118 print *, int(z), int(z,8)
8122 @item @emph{Specific names}:
8123 @multitable @columnfractions .20 .20 .20 .25
8124 @item Name @tab Argument @tab Return type @tab Standard
8125 @item @code{INT(A)} @tab @code{REAL(4) A} @tab @code{INTEGER} @tab Fortran 77 and later
8126 @item @code{IFIX(A)} @tab @code{REAL(4) A} @tab @code{INTEGER} @tab Fortran 77 and later
8127 @item @code{IDINT(A)} @tab @code{REAL(8) A} @tab @code{INTEGER} @tab Fortran 77 and later
8134 @section @code{INT2} --- Convert to 16-bit integer type
8137 @cindex conversion, to integer
8140 @item @emph{Description}:
8141 Convert to a @code{KIND=2} integer type. This is equivalent to the
8142 standard @code{INT} intrinsic with an optional argument of
8143 @code{KIND=2}, and is only included for backwards compatibility.
8145 The @code{SHORT} intrinsic is equivalent to @code{INT2}.
8147 @item @emph{Standard}:
8153 @item @emph{Syntax}:
8154 @code{RESULT = INT2(A)}
8156 @item @emph{Arguments}:
8157 @multitable @columnfractions .15 .70
8158 @item @var{A} @tab Shall be of type @code{INTEGER},
8159 @code{REAL}, or @code{COMPLEX}.
8162 @item @emph{Return value}:
8163 The return value is a @code{INTEGER(2)} variable.
8165 @item @emph{See also}:
8166 @ref{INT}, @ref{INT8}, @ref{LONG}
8172 @section @code{INT8} --- Convert to 64-bit integer type
8174 @cindex conversion, to integer
8177 @item @emph{Description}:
8178 Convert to a @code{KIND=8} integer type. This is equivalent to the
8179 standard @code{INT} intrinsic with an optional argument of
8180 @code{KIND=8}, and is only included for backwards compatibility.
8182 @item @emph{Standard}:
8188 @item @emph{Syntax}:
8189 @code{RESULT = INT8(A)}
8191 @item @emph{Arguments}:
8192 @multitable @columnfractions .15 .70
8193 @item @var{A} @tab Shall be of type @code{INTEGER},
8194 @code{REAL}, or @code{COMPLEX}.
8197 @item @emph{Return value}:
8198 The return value is a @code{INTEGER(8)} variable.
8200 @item @emph{See also}:
8201 @ref{INT}, @ref{INT2}, @ref{LONG}
8207 @section @code{IOR} --- Bitwise logical or
8213 @cindex bitwise logical or
8214 @cindex logical or, bitwise
8217 @item @emph{Description}:
8218 @code{IOR} returns the bitwise Boolean inclusive-OR of @var{I} and
8221 @item @emph{Standard}:
8222 Fortran 95 and later, has overloads that are GNU extensions
8227 @item @emph{Syntax}:
8228 @code{RESULT = IOR(I, J)}
8230 @item @emph{Arguments}:
8231 @multitable @columnfractions .15 .70
8232 @item @var{I} @tab The type shall be @code{INTEGER}.
8233 @item @var{J} @tab The type shall be @code{INTEGER}, of the same
8234 kind as @var{I}. (As a GNU extension, different kinds are also
8238 @item @emph{Return value}:
8239 The return type is @code{INTEGER}, of the same kind as the
8240 arguments. (If the argument kinds differ, it is of the same kind as
8241 the larger argument.)
8243 @item @emph{Specific names}:
8244 @multitable @columnfractions .20 .20 .20 .25
8245 @item Name @tab Argument @tab Return type @tab Standard
8246 @item @code{IOR(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 95 and later
8247 @item @code{BIOR(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
8248 @item @code{IIOR(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
8249 @item @code{JIOR(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
8250 @item @code{KIOR(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
8253 @item @emph{See also}:
8254 @ref{IEOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
8260 @section @code{IPARITY} --- Bitwise XOR of array elements
8262 @cindex array, parity
8264 @cindex bits, XOR of array elements
8267 @item @emph{Description}:
8268 Reduces with bitwise XOR (exclusive or) the elements of @var{ARRAY} along
8269 dimension @var{DIM} if the corresponding element in @var{MASK} is @code{TRUE}.
8271 @item @emph{Standard}:
8272 Fortran 2008 and later
8275 Transformational function
8277 @item @emph{Syntax}:
8278 @multitable @columnfractions .80
8279 @item @code{RESULT = IPARITY(ARRAY[, MASK])}
8280 @item @code{RESULT = IPARITY(ARRAY, DIM[, MASK])}
8283 @item @emph{Arguments}:
8284 @multitable @columnfractions .15 .70
8285 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER}
8286 @item @var{DIM} @tab (Optional) shall be a scalar of type
8287 @code{INTEGER} with a value in the range from 1 to n, where n
8288 equals the rank of @var{ARRAY}.
8289 @item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL}
8290 and either be a scalar or an array of the same shape as @var{ARRAY}.
8293 @item @emph{Return value}:
8294 The result is of the same type as @var{ARRAY}.
8296 If @var{DIM} is absent, a scalar with the bitwise XOR of all elements in
8297 @var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals
8298 the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with
8299 dimension @var{DIM} dropped is returned.
8301 @item @emph{Example}:
8303 PROGRAM test_iparity
8310 PRINT '(b8.8)', IPARITY(a)
8314 @item @emph{See also}:
8315 @ref{IANY}, @ref{IALL}, @ref{IEOR}, @ref{PARITY}
8321 @section @code{IRAND} --- Integer pseudo-random number
8323 @cindex random number generation
8326 @item @emph{Description}:
8327 @code{IRAND(FLAG)} returns a pseudo-random number from a uniform
8328 distribution between 0 and a system-dependent limit (which is in most
8329 cases 2147483647). If @var{FLAG} is 0, the next number
8330 in the current sequence is returned; if @var{FLAG} is 1, the generator
8331 is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
8332 it is used as a new seed with @code{SRAND}.
8334 This intrinsic routine is provided for backwards compatibility with
8335 GNU Fortran 77. It implements a simple modulo generator as provided
8336 by @command{g77}. For new code, one should consider the use of
8337 @ref{RANDOM_NUMBER} as it implements a superior algorithm.
8339 @item @emph{Standard}:
8345 @item @emph{Syntax}:
8346 @code{RESULT = IRAND(I)}
8348 @item @emph{Arguments}:
8349 @multitable @columnfractions .15 .70
8350 @item @var{I} @tab Shall be a scalar @code{INTEGER} of kind 4.
8353 @item @emph{Return value}:
8354 The return value is of @code{INTEGER(kind=4)} type.
8356 @item @emph{Example}:
8359 integer,parameter :: seed = 86456
8362 print *, irand(), irand(), irand(), irand()
8363 print *, irand(seed), irand(), irand(), irand()
8364 end program test_irand
8372 @section @code{IS_IOSTAT_END} --- Test for end-of-file value
8373 @fnindex IS_IOSTAT_END
8374 @cindex @code{IOSTAT}, end of file
8377 @item @emph{Description}:
8378 @code{IS_IOSTAT_END} tests whether an variable has the value of the I/O
8379 status ``end of file''. The function is equivalent to comparing the variable
8380 with the @code{IOSTAT_END} parameter of the intrinsic module
8381 @code{ISO_FORTRAN_ENV}.
8383 @item @emph{Standard}:
8384 Fortran 2003 and later
8389 @item @emph{Syntax}:
8390 @code{RESULT = IS_IOSTAT_END(I)}
8392 @item @emph{Arguments}:
8393 @multitable @columnfractions .15 .70
8394 @item @var{I} @tab Shall be of the type @code{INTEGER}.
8397 @item @emph{Return value}:
8398 Returns a @code{LOGICAL} of the default kind, which @code{.TRUE.} if
8399 @var{I} has the value which indicates an end of file condition for
8400 @code{IOSTAT=} specifiers, and is @code{.FALSE.} otherwise.
8402 @item @emph{Example}:
8407 OPEN(88, FILE='test.dat')
8408 READ(88, *, IOSTAT=stat) i
8409 IF(IS_IOSTAT_END(stat)) STOP 'END OF FILE'
8417 @section @code{IS_IOSTAT_EOR} --- Test for end-of-record value
8418 @fnindex IS_IOSTAT_EOR
8419 @cindex @code{IOSTAT}, end of record
8422 @item @emph{Description}:
8423 @code{IS_IOSTAT_EOR} tests whether an variable has the value of the I/O
8424 status ``end of record''. The function is equivalent to comparing the
8425 variable with the @code{IOSTAT_EOR} parameter of the intrinsic module
8426 @code{ISO_FORTRAN_ENV}.
8428 @item @emph{Standard}:
8429 Fortran 2003 and later
8434 @item @emph{Syntax}:
8435 @code{RESULT = IS_IOSTAT_EOR(I)}
8437 @item @emph{Arguments}:
8438 @multitable @columnfractions .15 .70
8439 @item @var{I} @tab Shall be of the type @code{INTEGER}.
8442 @item @emph{Return value}:
8443 Returns a @code{LOGICAL} of the default kind, which @code{.TRUE.} if
8444 @var{I} has the value which indicates an end of file condition for
8445 @code{IOSTAT=} specifiers, and is @code{.FALSE.} otherwise.
8447 @item @emph{Example}:
8451 INTEGER :: stat, i(50)
8452 OPEN(88, FILE='test.dat', FORM='UNFORMATTED')
8453 READ(88, IOSTAT=stat) i
8454 IF(IS_IOSTAT_EOR(stat)) STOP 'END OF RECORD'
8462 @section @code{ISATTY} --- Whether a unit is a terminal device.
8464 @cindex system, terminal
8467 @item @emph{Description}:
8468 Determine whether a unit is connected to a terminal device.
8470 @item @emph{Standard}:
8476 @item @emph{Syntax}:
8477 @code{RESULT = ISATTY(UNIT)}
8479 @item @emph{Arguments}:
8480 @multitable @columnfractions .15 .70
8481 @item @var{UNIT} @tab Shall be a scalar @code{INTEGER}.
8484 @item @emph{Return value}:
8485 Returns @code{.TRUE.} if the @var{UNIT} is connected to a terminal
8486 device, @code{.FALSE.} otherwise.
8488 @item @emph{Example}:
8491 INTEGER(kind=1) :: unit
8493 write(*,*) isatty(unit=unit)
8497 @item @emph{See also}:
8504 @section @code{ISHFT} --- Shift bits
8513 @item @emph{Description}:
8514 @code{ISHFT} returns a value corresponding to @var{I} with all of the
8515 bits shifted @var{SHIFT} places. A value of @var{SHIFT} greater than
8516 zero corresponds to a left shift, a value of zero corresponds to no
8517 shift, and a value less than zero corresponds to a right shift. If the
8518 absolute value of @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the
8519 value is undefined. Bits shifted out from the left end or right end are
8520 lost; zeros are shifted in from the opposite end.
8522 @item @emph{Standard}:
8523 Fortran 95 and later, has overloads that are GNU extensions
8528 @item @emph{Syntax}:
8529 @code{RESULT = ISHFT(I, SHIFT)}
8531 @item @emph{Arguments}:
8532 @multitable @columnfractions .15 .70
8533 @item @var{I} @tab The type shall be @code{INTEGER}.
8534 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
8537 @item @emph{Return value}:
8538 The return value is of type @code{INTEGER} and of the same kind as
8541 @item @emph{Specific names}:
8542 @multitable @columnfractions .20 .20 .20 .25
8543 @item Name @tab Argument @tab Return type @tab Standard
8544 @item @code{ISHFT(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 95 and later
8545 @item @code{BSHFT(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
8546 @item @code{IISHFT(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
8547 @item @code{JISHFT(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
8548 @item @code{KISHFT(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
8551 @item @emph{See also}:
8558 @section @code{ISHFTC} --- Shift bits circularly
8564 @cindex bits, shift circular
8567 @item @emph{Description}:
8568 @code{ISHFTC} returns a value corresponding to @var{I} with the
8569 rightmost @var{SIZE} bits shifted circularly @var{SHIFT} places; that
8570 is, bits shifted out one end are shifted into the opposite end. A value
8571 of @var{SHIFT} greater than zero corresponds to a left shift, a value of
8572 zero corresponds to no shift, and a value less than zero corresponds to
8573 a right shift. The absolute value of @var{SHIFT} must be less than
8574 @var{SIZE}. If the @var{SIZE} argument is omitted, it is taken to be
8575 equivalent to @code{BIT_SIZE(I)}.
8577 @item @emph{Standard}:
8578 Fortran 95 and later, has overloads that are GNU extensions
8583 @item @emph{Syntax}:
8584 @code{RESULT = ISHFTC(I, SHIFT [, SIZE])}
8586 @item @emph{Arguments}:
8587 @multitable @columnfractions .15 .70
8588 @item @var{I} @tab The type shall be @code{INTEGER}.
8589 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
8590 @item @var{SIZE} @tab (Optional) The type shall be @code{INTEGER};
8591 the value must be greater than zero and less than or equal to
8595 @item @emph{Return value}:
8596 The return value is of type @code{INTEGER} and of the same kind as
8599 @item @emph{Specific names}:
8600 @multitable @columnfractions .20 .20 .20 .25
8601 @item Name @tab Argument @tab Return type @tab Standard
8602 @item @code{ISHFTC(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 95 and later
8603 @item @code{BSHFTC(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
8604 @item @code{IISHFTC(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
8605 @item @code{JISHFTC(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
8606 @item @code{KISHFTC(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
8609 @item @emph{See also}:
8616 @section @code{ISNAN} --- Test for a NaN
8621 @item @emph{Description}:
8622 @code{ISNAN} tests whether a floating-point value is an IEEE
8624 @item @emph{Standard}:
8630 @item @emph{Syntax}:
8633 @item @emph{Arguments}:
8634 @multitable @columnfractions .15 .70
8635 @item @var{X} @tab Variable of the type @code{REAL}.
8639 @item @emph{Return value}:
8640 Returns a default-kind @code{LOGICAL}. The returned value is @code{TRUE}
8641 if @var{X} is a NaN and @code{FALSE} otherwise.
8643 @item @emph{Example}:
8650 if (isnan(x)) stop '"x" is a NaN'
8651 end program test_nan
8658 @section @code{ITIME} --- Get current local time subroutine (hour/minutes/seconds)
8660 @cindex time, current
8661 @cindex current time
8664 @item @emph{Description}:
8665 @code{ITIME(VALUES)} Fills @var{VALUES} with the numerical values at the
8666 current local time. The hour (in the range 1-24), minute (in the range 1-60),
8667 and seconds (in the range 1-60) appear in elements 1, 2, and 3 of @var{VALUES},
8670 This intrinsic routine is provided for backwards compatibility with
8671 GNU Fortran 77. In new code, programmers should consider the use of
8672 the @ref{DATE_AND_TIME} intrinsic defined by the Fortran 95
8675 @item @emph{Standard}:
8681 @item @emph{Syntax}:
8682 @code{CALL ITIME(VALUES)}
8684 @item @emph{Arguments}:
8685 @multitable @columnfractions .15 .70
8686 @item @var{VALUES} @tab The type shall be @code{INTEGER, DIMENSION(3)}
8687 and the kind shall be the default integer kind.
8690 @item @emph{Return value}:
8691 Does not return anything.
8694 @item @emph{Example}:
8697 integer, dimension(3) :: tarray
8702 end program test_itime
8705 @item @emph{See also}:
8712 @section @code{KILL} --- Send a signal to a process
8716 @item @emph{Description}:
8717 @item @emph{Standard}:
8718 Sends the signal specified by @var{SIG} to the process @var{PID}.
8721 This intrinsic is provided in both subroutine and function forms;
8722 however, only one form can be used in any given program unit.
8725 Subroutine, function
8727 @item @emph{Syntax}:
8728 @multitable @columnfractions .80
8729 @item @code{CALL KILL(PID, SIG [, STATUS])}
8730 @item @code{STATUS = KILL(PID, SIG)}
8733 @item @emph{Arguments}:
8734 @multitable @columnfractions .15 .70
8735 @item @var{PID} @tab Shall be a scalar @code{INTEGER} with @code{INTENT(IN)}.
8736 @item @var{SIG} @tab Shall be a scalar @code{INTEGER} with @code{INTENT(IN)}.
8737 @item @var{STATUS} @tab [Subroutine](Optional)
8738 Shall be a scalar @code{INTEGER}.
8739 Returns 0 on success; otherwise a system-specific error code is returned.
8740 @item @var{STATUS} @tab [Function] The kind type parameter is that of
8742 Returns 0 on success; otherwise a system-specific error code is returned.
8745 @item @emph{See also}:
8746 @ref{ABORT}, @ref{EXIT}
8751 @section @code{KIND} --- Kind of an entity
8756 @item @emph{Description}:
8757 @code{KIND(X)} returns the kind value of the entity @var{X}.
8759 @item @emph{Standard}:
8760 Fortran 95 and later
8765 @item @emph{Syntax}:
8768 @item @emph{Arguments}:
8769 @multitable @columnfractions .15 .70
8770 @item @var{X} @tab Shall be of type @code{LOGICAL}, @code{INTEGER},
8771 @code{REAL}, @code{COMPLEX} or @code{CHARACTER}.
8774 @item @emph{Return value}:
8775 The return value is a scalar of type @code{INTEGER} and of the default
8778 @item @emph{Example}:
8781 integer,parameter :: kc = kind(' ')
8782 integer,parameter :: kl = kind(.true.)
8784 print *, "The default character kind is ", kc
8785 print *, "The default logical kind is ", kl
8786 end program test_kind
8794 @section @code{LBOUND} --- Lower dimension bounds of an array
8796 @cindex array, lower bound
8799 @item @emph{Description}:
8800 Returns the lower bounds of an array, or a single lower bound
8801 along the @var{DIM} dimension.
8802 @item @emph{Standard}:
8803 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
8808 @item @emph{Syntax}:
8809 @code{RESULT = LBOUND(ARRAY [, DIM [, KIND]])}
8811 @item @emph{Arguments}:
8812 @multitable @columnfractions .15 .70
8813 @item @var{ARRAY} @tab Shall be an array, of any type.
8814 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
8815 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
8816 expression indicating the kind parameter of the result.
8819 @item @emph{Return value}:
8820 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
8821 @var{KIND} is absent, the return value is of default integer kind.
8822 If @var{DIM} is absent, the result is an array of the lower bounds of
8823 @var{ARRAY}. If @var{DIM} is present, the result is a scalar
8824 corresponding to the lower bound of the array along that dimension. If
8825 @var{ARRAY} is an expression rather than a whole array or array
8826 structure component, or if it has a zero extent along the relevant
8827 dimension, the lower bound is taken to be 1.
8829 @item @emph{See also}:
8830 @ref{UBOUND}, @ref{LCOBOUND}
8836 @section @code{LCOBOUND} --- Lower codimension bounds of an array
8838 @cindex coarray, lower bound
8841 @item @emph{Description}:
8842 Returns the lower bounds of a coarray, or a single lower cobound
8843 along the @var{DIM} codimension.
8844 @item @emph{Standard}:
8845 Fortran 2008 and later
8850 @item @emph{Syntax}:
8851 @code{RESULT = LCOBOUND(COARRAY [, DIM [, KIND]])}
8853 @item @emph{Arguments}:
8854 @multitable @columnfractions .15 .70
8855 @item @var{ARRAY} @tab Shall be an coarray, of any type.
8856 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
8857 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
8858 expression indicating the kind parameter of the result.
8861 @item @emph{Return value}:
8862 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
8863 @var{KIND} is absent, the return value is of default integer kind.
8864 If @var{DIM} is absent, the result is an array of the lower cobounds of
8865 @var{COARRAY}. If @var{DIM} is present, the result is a scalar
8866 corresponding to the lower cobound of the array along that codimension.
8868 @item @emph{See also}:
8869 @ref{UCOBOUND}, @ref{LBOUND}
8875 @section @code{LEADZ} --- Number of leading zero bits of an integer
8880 @item @emph{Description}:
8881 @code{LEADZ} returns the number of leading zero bits of an integer.
8883 @item @emph{Standard}:
8884 Fortran 2008 and later
8889 @item @emph{Syntax}:
8890 @code{RESULT = LEADZ(I)}
8892 @item @emph{Arguments}:
8893 @multitable @columnfractions .15 .70
8894 @item @var{I} @tab Shall be of type @code{INTEGER}.
8897 @item @emph{Return value}:
8898 The type of the return value is the default @code{INTEGER}.
8899 If all the bits of @code{I} are zero, the result value is @code{BIT_SIZE(I)}.
8901 @item @emph{Example}:
8904 WRITE (*,*) BIT_SIZE(1) ! prints 32
8905 WRITE (*,*) LEADZ(1) ! prints 31
8909 @item @emph{See also}:
8910 @ref{BIT_SIZE}, @ref{TRAILZ}, @ref{POPCNT}, @ref{POPPAR}
8916 @section @code{LEN} --- Length of a character entity
8918 @cindex string, length
8921 @item @emph{Description}:
8922 Returns the length of a character string. If @var{STRING} is an array,
8923 the length of an element of @var{STRING} is returned. Note that
8924 @var{STRING} need not be defined when this intrinsic is invoked, since
8925 only the length, not the content, of @var{STRING} is needed.
8927 @item @emph{Standard}:
8928 Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later
8933 @item @emph{Syntax}:
8934 @code{L = LEN(STRING [, KIND])}
8936 @item @emph{Arguments}:
8937 @multitable @columnfractions .15 .70
8938 @item @var{STRING} @tab Shall be a scalar or array of type
8939 @code{CHARACTER}, with @code{INTENT(IN)}
8940 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
8941 expression indicating the kind parameter of the result.
8944 @item @emph{Return value}:
8945 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
8946 @var{KIND} is absent, the return value is of default integer kind.
8949 @item @emph{Specific names}:
8950 @multitable @columnfractions .20 .20 .20 .25
8951 @item Name @tab Argument @tab Return type @tab Standard
8952 @item @code{LEN(STRING)} @tab @code{CHARACTER} @tab @code{INTEGER} @tab Fortran 77 and later
8956 @item @emph{See also}:
8957 @ref{LEN_TRIM}, @ref{ADJUSTL}, @ref{ADJUSTR}
8963 @section @code{LEN_TRIM} --- Length of a character entity without trailing blank characters
8965 @cindex string, length, without trailing whitespace
8968 @item @emph{Description}:
8969 Returns the length of a character string, ignoring any trailing blanks.
8971 @item @emph{Standard}:
8972 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
8977 @item @emph{Syntax}:
8978 @code{RESULT = LEN_TRIM(STRING [, KIND])}
8980 @item @emph{Arguments}:
8981 @multitable @columnfractions .15 .70
8982 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER},
8983 with @code{INTENT(IN)}
8984 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
8985 expression indicating the kind parameter of the result.
8988 @item @emph{Return value}:
8989 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
8990 @var{KIND} is absent, the return value is of default integer kind.
8992 @item @emph{See also}:
8993 @ref{LEN}, @ref{ADJUSTL}, @ref{ADJUSTR}
8999 @section @code{LGE} --- Lexical greater than or equal
9001 @cindex lexical comparison of strings
9002 @cindex string, comparison
9005 @item @emph{Description}:
9006 Determines whether one string is lexically greater than or equal to
9007 another string, where the two strings are interpreted as containing
9008 ASCII character codes. If the String A and String B are not the same
9009 length, the shorter is compared as if spaces were appended to it to form
9010 a value that has the same length as the longer.
9012 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
9013 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
9014 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
9015 that the latter use the processor's character ordering (which is not
9016 ASCII on some targets), whereas the former always use the ASCII
9019 @item @emph{Standard}:
9020 Fortran 77 and later
9025 @item @emph{Syntax}:
9026 @code{RESULT = LGE(STRING_A, STRING_B)}
9028 @item @emph{Arguments}:
9029 @multitable @columnfractions .15 .70
9030 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
9031 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
9034 @item @emph{Return value}:
9035 Returns @code{.TRUE.} if @code{STRING_A >= STRING_B}, and @code{.FALSE.}
9036 otherwise, based on the ASCII ordering.
9038 @item @emph{Specific names}:
9039 @multitable @columnfractions .20 .20 .20 .25
9040 @item Name @tab Argument @tab Return type @tab Standard
9041 @item @code{LGE(STRING_A, STRING_B)} @tab @code{CHARACTER} @tab @code{LOGICAL} @tab Fortran 77 and later
9044 @item @emph{See also}:
9045 @ref{LGT}, @ref{LLE}, @ref{LLT}
9051 @section @code{LGT} --- Lexical greater than
9053 @cindex lexical comparison of strings
9054 @cindex string, comparison
9057 @item @emph{Description}:
9058 Determines whether one string is lexically greater than another string,
9059 where the two strings are interpreted as containing ASCII character
9060 codes. If the String A and String B are not the same length, the
9061 shorter is compared as if spaces were appended to it to form a value
9062 that has the same length as the longer.
9064 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
9065 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
9066 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
9067 that the latter use the processor's character ordering (which is not
9068 ASCII on some targets), whereas the former always use the ASCII
9071 @item @emph{Standard}:
9072 Fortran 77 and later
9077 @item @emph{Syntax}:
9078 @code{RESULT = LGT(STRING_A, STRING_B)}
9080 @item @emph{Arguments}:
9081 @multitable @columnfractions .15 .70
9082 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
9083 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
9086 @item @emph{Return value}:
9087 Returns @code{.TRUE.} if @code{STRING_A > STRING_B}, and @code{.FALSE.}
9088 otherwise, based on the ASCII ordering.
9090 @item @emph{Specific names}:
9091 @multitable @columnfractions .20 .20 .20 .25
9092 @item Name @tab Argument @tab Return type @tab Standard
9093 @item @code{LGT(STRING_A, STRING_B)} @tab @code{CHARACTER} @tab @code{LOGICAL} @tab Fortran 77 and later
9096 @item @emph{See also}:
9097 @ref{LGE}, @ref{LLE}, @ref{LLT}
9103 @section @code{LINK} --- Create a hard link
9105 @cindex file system, create link
9106 @cindex file system, hard link
9109 @item @emph{Description}:
9110 Makes a (hard) link from file @var{PATH1} to @var{PATH2}. A null
9111 character (@code{CHAR(0)}) can be used to mark the end of the names in
9112 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
9113 names are ignored. If the @var{STATUS} argument is supplied, it
9114 contains 0 on success or a nonzero error code upon return; see
9117 This intrinsic is provided in both subroutine and function forms;
9118 however, only one form can be used in any given program unit.
9120 @item @emph{Standard}:
9124 Subroutine, function
9126 @item @emph{Syntax}:
9127 @multitable @columnfractions .80
9128 @item @code{CALL LINK(PATH1, PATH2 [, STATUS])}
9129 @item @code{STATUS = LINK(PATH1, PATH2)}
9132 @item @emph{Arguments}:
9133 @multitable @columnfractions .15 .70
9134 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
9135 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
9136 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
9139 @item @emph{See also}:
9140 @ref{SYMLNK}, @ref{UNLINK}
9146 @section @code{LLE} --- Lexical less than or equal
9148 @cindex lexical comparison of strings
9149 @cindex string, comparison
9152 @item @emph{Description}:
9153 Determines whether one string is lexically less than or equal to another
9154 string, where the two strings are interpreted as containing ASCII
9155 character codes. If the String A and String B are not the same length,
9156 the shorter is compared as if spaces were appended to it to form a value
9157 that has the same length as the longer.
9159 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
9160 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
9161 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
9162 that the latter use the processor's character ordering (which is not
9163 ASCII on some targets), whereas the former always use the ASCII
9166 @item @emph{Standard}:
9167 Fortran 77 and later
9172 @item @emph{Syntax}:
9173 @code{RESULT = LLE(STRING_A, STRING_B)}
9175 @item @emph{Arguments}:
9176 @multitable @columnfractions .15 .70
9177 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
9178 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
9181 @item @emph{Return value}:
9182 Returns @code{.TRUE.} if @code{STRING_A <= STRING_B}, and @code{.FALSE.}
9183 otherwise, based on the ASCII ordering.
9185 @item @emph{Specific names}:
9186 @multitable @columnfractions .20 .20 .20 .25
9187 @item Name @tab Argument @tab Return type @tab Standard
9188 @item @code{LLE(STRING_A, STRING_B)} @tab @code{CHARACTER} @tab @code{LOGICAL} @tab Fortran 77 and later
9191 @item @emph{See also}:
9192 @ref{LGE}, @ref{LGT}, @ref{LLT}
9198 @section @code{LLT} --- Lexical less than
9200 @cindex lexical comparison of strings
9201 @cindex string, comparison
9204 @item @emph{Description}:
9205 Determines whether one string is lexically less than another string,
9206 where the two strings are interpreted as containing ASCII character
9207 codes. If the String A and String B are not the same length, the
9208 shorter is compared as if spaces were appended to it to form a value
9209 that has the same length as the longer.
9211 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
9212 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
9213 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
9214 that the latter use the processor's character ordering (which is not
9215 ASCII on some targets), whereas the former always use the ASCII
9218 @item @emph{Standard}:
9219 Fortran 77 and later
9224 @item @emph{Syntax}:
9225 @code{RESULT = LLT(STRING_A, STRING_B)}
9227 @item @emph{Arguments}:
9228 @multitable @columnfractions .15 .70
9229 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
9230 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
9233 @item @emph{Return value}:
9234 Returns @code{.TRUE.} if @code{STRING_A < STRING_B}, and @code{.FALSE.}
9235 otherwise, based on the ASCII ordering.
9237 @item @emph{Specific names}:
9238 @multitable @columnfractions .20 .20 .20 .25
9239 @item Name @tab Argument @tab Return type @tab Standard
9240 @item @code{LLT(STRING_A, STRING_B)} @tab @code{CHARACTER} @tab @code{LOGICAL} @tab Fortran 77 and later
9243 @item @emph{See also}:
9244 @ref{LGE}, @ref{LGT}, @ref{LLE}
9250 @section @code{LNBLNK} --- Index of the last non-blank character in a string
9252 @cindex string, find non-blank character
9255 @item @emph{Description}:
9256 Returns the length of a character string, ignoring any trailing blanks.
9257 This is identical to the standard @code{LEN_TRIM} intrinsic, and is only
9258 included for backwards compatibility.
9260 @item @emph{Standard}:
9266 @item @emph{Syntax}:
9267 @code{RESULT = LNBLNK(STRING)}
9269 @item @emph{Arguments}:
9270 @multitable @columnfractions .15 .70
9271 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER},
9272 with @code{INTENT(IN)}
9275 @item @emph{Return value}:
9276 The return value is of @code{INTEGER(kind=4)} type.
9278 @item @emph{See also}:
9279 @ref{INDEX intrinsic}, @ref{LEN_TRIM}
9285 @section @code{LOC} --- Returns the address of a variable
9287 @cindex location of a variable in memory
9290 @item @emph{Description}:
9291 @code{LOC(X)} returns the address of @var{X} as an integer.
9293 @item @emph{Standard}:
9299 @item @emph{Syntax}:
9300 @code{RESULT = LOC(X)}
9302 @item @emph{Arguments}:
9303 @multitable @columnfractions .15 .70
9304 @item @var{X} @tab Variable of any type.
9307 @item @emph{Return value}:
9308 The return value is of type @code{INTEGER}, with a @code{KIND}
9309 corresponding to the size (in bytes) of a memory address on the target
9312 @item @emph{Example}:
9319 end program test_loc
9326 @section @code{LOG} --- Natural logarithm function
9333 @cindex exponential function, inverse
9334 @cindex logarithm function
9335 @cindex natural logarithm function
9338 @item @emph{Description}:
9339 @code{LOG(X)} computes the natural logarithm of @var{X}, i.e. the
9340 logarithm to the base @math{e}.
9342 @item @emph{Standard}:
9343 Fortran 77 and later
9348 @item @emph{Syntax}:
9349 @code{RESULT = LOG(X)}
9351 @item @emph{Arguments}:
9352 @multitable @columnfractions .15 .70
9353 @item @var{X} @tab The type shall be @code{REAL} or
9357 @item @emph{Return value}:
9358 The return value is of type @code{REAL} or @code{COMPLEX}.
9359 The kind type parameter is the same as @var{X}.
9360 If @var{X} is @code{COMPLEX}, the imaginary part @math{\omega} is in the range
9361 @math{-\pi < \omega \leq \pi}.
9363 @item @emph{Example}:
9366 real(8) :: x = 2.7182818284590451_8
9367 complex :: z = (1.0, 2.0)
9368 x = log(x) ! will yield (approximately) 1
9370 end program test_log
9373 @item @emph{Specific names}:
9374 @multitable @columnfractions .20 .20 .20 .25
9375 @item Name @tab Argument @tab Return type @tab Standard
9376 @item @code{ALOG(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab f95, gnu
9377 @item @code{DLOG(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
9378 @item @code{CLOG(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab f95, gnu
9379 @item @code{ZLOG(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
9380 @item @code{CDLOG(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
9387 @section @code{LOG10} --- Base 10 logarithm function
9391 @cindex exponential function, inverse
9392 @cindex logarithm function with base 10
9393 @cindex base 10 logarithm function
9396 @item @emph{Description}:
9397 @code{LOG10(X)} computes the base 10 logarithm of @var{X}.
9399 @item @emph{Standard}:
9400 Fortran 77 and later
9405 @item @emph{Syntax}:
9406 @code{RESULT = LOG10(X)}
9408 @item @emph{Arguments}:
9409 @multitable @columnfractions .15 .70
9410 @item @var{X} @tab The type shall be @code{REAL}.
9413 @item @emph{Return value}:
9414 The return value is of type @code{REAL} or @code{COMPLEX}.
9415 The kind type parameter is the same as @var{X}.
9417 @item @emph{Example}:
9420 real(8) :: x = 10.0_8
9422 end program test_log10
9425 @item @emph{Specific names}:
9426 @multitable @columnfractions .20 .20 .20 .25
9427 @item Name @tab Argument @tab Return type @tab Standard
9428 @item @code{ALOG10(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 95 and later
9429 @item @code{DLOG10(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 95 and later
9436 @section @code{LOG_GAMMA} --- Logarithm of the Gamma function
9441 @cindex Gamma function, logarithm of
9444 @item @emph{Description}:
9445 @code{LOG_GAMMA(X)} computes the natural logarithm of the absolute value
9446 of the Gamma (@math{\Gamma}) function.
9448 @item @emph{Standard}:
9449 Fortran 2008 and later
9454 @item @emph{Syntax}:
9455 @code{X = LOG_GAMMA(X)}
9457 @item @emph{Arguments}:
9458 @multitable @columnfractions .15 .70
9459 @item @var{X} @tab Shall be of type @code{REAL} and neither zero
9460 nor a negative integer.
9463 @item @emph{Return value}:
9464 The return value is of type @code{REAL} of the same kind as @var{X}.
9466 @item @emph{Example}:
9468 program test_log_gamma
9470 x = lgamma(x) ! returns 0.0
9471 end program test_log_gamma
9474 @item @emph{Specific names}:
9475 @multitable @columnfractions .20 .20 .20 .25
9476 @item Name @tab Argument @tab Return type @tab Standard
9477 @item @code{LGAMMA(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU Extension
9478 @item @code{ALGAMA(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU Extension
9479 @item @code{DLGAMA(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU Extension
9482 @item @emph{See also}:
9483 Gamma function: @ref{GAMMA}
9490 @section @code{LOGICAL} --- Convert to logical type
9492 @cindex conversion, to logical
9495 @item @emph{Description}:
9496 Converts one kind of @code{LOGICAL} variable to another.
9498 @item @emph{Standard}:
9499 Fortran 95 and later
9504 @item @emph{Syntax}:
9505 @code{RESULT = LOGICAL(L [, KIND])}
9507 @item @emph{Arguments}:
9508 @multitable @columnfractions .15 .70
9509 @item @var{L} @tab The type shall be @code{LOGICAL}.
9510 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
9511 expression indicating the kind parameter of the result.
9514 @item @emph{Return value}:
9515 The return value is a @code{LOGICAL} value equal to @var{L}, with a
9516 kind corresponding to @var{KIND}, or of the default logical kind if
9517 @var{KIND} is not given.
9519 @item @emph{See also}:
9520 @ref{INT}, @ref{REAL}, @ref{CMPLX}
9526 @section @code{LONG} --- Convert to integer type
9528 @cindex conversion, to integer
9531 @item @emph{Description}:
9532 Convert to a @code{KIND=4} integer type, which is the same size as a C
9533 @code{long} integer. This is equivalent to the standard @code{INT}
9534 intrinsic with an optional argument of @code{KIND=4}, and is only
9535 included for backwards compatibility.
9537 @item @emph{Standard}:
9543 @item @emph{Syntax}:
9544 @code{RESULT = LONG(A)}
9546 @item @emph{Arguments}:
9547 @multitable @columnfractions .15 .70
9548 @item @var{A} @tab Shall be of type @code{INTEGER},
9549 @code{REAL}, or @code{COMPLEX}.
9552 @item @emph{Return value}:
9553 The return value is a @code{INTEGER(4)} variable.
9555 @item @emph{See also}:
9556 @ref{INT}, @ref{INT2}, @ref{INT8}
9562 @section @code{LSHIFT} --- Left shift bits
9564 @cindex bits, shift left
9567 @item @emph{Description}:
9568 @code{LSHIFT} returns a value corresponding to @var{I} with all of the
9569 bits shifted left by @var{SHIFT} places. If the absolute value of
9570 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
9571 Bits shifted out from the left end are lost; zeros are shifted in from
9574 This function has been superseded by the @code{ISHFT} intrinsic, which
9575 is standard in Fortran 95 and later, and the @code{SHIFTL} intrinsic,
9576 which is standard in Fortran 2008 and later.
9578 @item @emph{Standard}:
9584 @item @emph{Syntax}:
9585 @code{RESULT = LSHIFT(I, SHIFT)}
9587 @item @emph{Arguments}:
9588 @multitable @columnfractions .15 .70
9589 @item @var{I} @tab The type shall be @code{INTEGER}.
9590 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
9593 @item @emph{Return value}:
9594 The return value is of type @code{INTEGER} and of the same kind as
9597 @item @emph{See also}:
9598 @ref{ISHFT}, @ref{ISHFTC}, @ref{RSHIFT}, @ref{SHIFTA}, @ref{SHIFTL},
9606 @section @code{LSTAT} --- Get file status
9608 @cindex file system, file status
9611 @item @emph{Description}:
9612 @code{LSTAT} is identical to @ref{STAT}, except that if path is a
9613 symbolic link, then the link itself is statted, not the file that it
9616 The elements in @code{VALUES} are the same as described by @ref{STAT}.
9618 This intrinsic is provided in both subroutine and function forms;
9619 however, only one form can be used in any given program unit.
9621 @item @emph{Standard}:
9625 Subroutine, function
9627 @item @emph{Syntax}:
9628 @multitable @columnfractions .80
9629 @item @code{CALL LSTAT(NAME, VALUES [, STATUS])}
9630 @item @code{STATUS = LSTAT(NAME, VALUES)}
9633 @item @emph{Arguments}:
9634 @multitable @columnfractions .15 .70
9635 @item @var{NAME} @tab The type shall be @code{CHARACTER} of the default
9636 kind, a valid path within the file system.
9637 @item @var{VALUES} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
9638 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}.
9639 Returns 0 on success and a system specific error code otherwise.
9642 @item @emph{Example}:
9643 See @ref{STAT} for an example.
9645 @item @emph{See also}:
9646 To stat an open file: @ref{FSTAT}, to stat a file: @ref{STAT}
9652 @section @code{LTIME} --- Convert time to local time info
9654 @cindex time, conversion to local time info
9657 @item @emph{Description}:
9658 Given a system time value @var{TIME} (as provided by the @ref{TIME}
9659 intrinsic), fills @var{VALUES} with values extracted from it appropriate
9660 to the local time zone using @code{localtime(3)}.
9662 This intrinsic routine is provided for backwards compatibility with
9663 GNU Fortran 77. In new code, programmers should consider the use of
9664 the @ref{DATE_AND_TIME} intrinsic defined by the Fortran 95
9667 @item @emph{Standard}:
9673 @item @emph{Syntax}:
9674 @code{CALL LTIME(TIME, VALUES)}
9676 @item @emph{Arguments}:
9677 @multitable @columnfractions .15 .70
9678 @item @var{TIME} @tab An @code{INTEGER} scalar expression
9679 corresponding to a system time, with @code{INTENT(IN)}.
9680 @item @var{VALUES} @tab A default @code{INTEGER} array with 9 elements,
9681 with @code{INTENT(OUT)}.
9684 @item @emph{Return value}:
9685 The elements of @var{VALUES} are assigned as follows:
9687 @item Seconds after the minute, range 0--59 or 0--61 to allow for leap
9689 @item Minutes after the hour, range 0--59
9690 @item Hours past midnight, range 0--23
9691 @item Day of month, range 1--31
9692 @item Number of months since January, range 0--11
9693 @item Years since 1900
9694 @item Number of days since Sunday, range 0--6
9695 @item Days since January 1, range 0--365
9696 @item Daylight savings indicator: positive if daylight savings is in
9697 effect, zero if not, and negative if the information is not available.
9700 @item @emph{See also}:
9701 @ref{DATE_AND_TIME}, @ref{CTIME}, @ref{GMTIME}, @ref{TIME}, @ref{TIME8}
9708 @section @code{MALLOC} --- Allocate dynamic memory
9710 @cindex pointer, cray
9713 @item @emph{Description}:
9714 @code{MALLOC(SIZE)} allocates @var{SIZE} bytes of dynamic memory and
9715 returns the address of the allocated memory. The @code{MALLOC} intrinsic
9716 is an extension intended to be used with Cray pointers, and is provided
9717 in GNU Fortran to allow the user to compile legacy code. For new code
9718 using Fortran 95 pointers, the memory allocation intrinsic is
9721 @item @emph{Standard}:
9727 @item @emph{Syntax}:
9728 @code{PTR = MALLOC(SIZE)}
9730 @item @emph{Arguments}:
9731 @multitable @columnfractions .15 .70
9732 @item @var{SIZE} @tab The type shall be @code{INTEGER}.
9735 @item @emph{Return value}:
9736 The return value is of type @code{INTEGER(K)}, with @var{K} such that
9737 variables of type @code{INTEGER(K)} have the same size as
9738 C pointers (@code{sizeof(void *)}).
9740 @item @emph{Example}:
9741 The following example demonstrates the use of @code{MALLOC} and
9742 @code{FREE} with Cray pointers.
9751 ptr_x = malloc(20*8)
9753 x(i) = sqrt(1.0d0 / i)
9761 end program test_malloc
9764 @item @emph{See also}:
9771 @section @code{MASKL} --- Left justified mask
9773 @cindex mask, left justified
9776 @item @emph{Description}:
9777 @code{MASKL(I[, KIND])} has its leftmost @var{I} bits set to 1, and the
9778 remaining bits set to 0.
9780 @item @emph{Standard}:
9781 Fortran 2008 and later
9786 @item @emph{Syntax}:
9787 @code{RESULT = MASKL(I[, KIND])}
9789 @item @emph{Arguments}:
9790 @multitable @columnfractions .15 .70
9791 @item @var{I} @tab Shall be of type @code{INTEGER}.
9792 @item @var{KIND} @tab Shall be a scalar constant expression of type
9796 @item @emph{Return value}:
9797 The return value is of type @code{INTEGER}. If @var{KIND} is present, it
9798 specifies the kind value of the return type; otherwise, it is of the
9799 default integer kind.
9801 @item @emph{See also}:
9808 @section @code{MASKR} --- Right justified mask
9810 @cindex mask, right justified
9813 @item @emph{Description}:
9814 @code{MASKL(I[, KIND])} has its rightmost @var{I} bits set to 1, and the
9815 remaining bits set to 0.
9817 @item @emph{Standard}:
9818 Fortran 2008 and later
9823 @item @emph{Syntax}:
9824 @code{RESULT = MASKR(I[, KIND])}
9826 @item @emph{Arguments}:
9827 @multitable @columnfractions .15 .70
9828 @item @var{I} @tab Shall be of type @code{INTEGER}.
9829 @item @var{KIND} @tab Shall be a scalar constant expression of type
9833 @item @emph{Return value}:
9834 The return value is of type @code{INTEGER}. If @var{KIND} is present, it
9835 specifies the kind value of the return type; otherwise, it is of the
9836 default integer kind.
9838 @item @emph{See also}:
9845 @section @code{MATMUL} --- matrix multiplication
9847 @cindex matrix multiplication
9848 @cindex product, matrix
9851 @item @emph{Description}:
9852 Performs a matrix multiplication on numeric or logical arguments.
9854 @item @emph{Standard}:
9855 Fortran 95 and later
9858 Transformational function
9860 @item @emph{Syntax}:
9861 @code{RESULT = MATMUL(MATRIX_A, MATRIX_B)}
9863 @item @emph{Arguments}:
9864 @multitable @columnfractions .15 .70
9865 @item @var{MATRIX_A} @tab An array of @code{INTEGER},
9866 @code{REAL}, @code{COMPLEX}, or @code{LOGICAL} type, with a rank of
9868 @item @var{MATRIX_B} @tab An array of @code{INTEGER},
9869 @code{REAL}, or @code{COMPLEX} type if @var{MATRIX_A} is of a numeric
9870 type; otherwise, an array of @code{LOGICAL} type. The rank shall be one
9871 or two, and the first (or only) dimension of @var{MATRIX_B} shall be
9872 equal to the last (or only) dimension of @var{MATRIX_A}.
9873 @var{MATRIX_A} and @var{MATRIX_B} shall not both be rank one arrays.
9876 @item @emph{Return value}:
9877 The matrix product of @var{MATRIX_A} and @var{MATRIX_B}. The type and
9878 kind of the result follow the usual type and kind promotion rules, as
9879 for the @code{*} or @code{.AND.} operators.
9881 @item @emph{See also}:
9887 @section @code{MAX} --- Maximum value of an argument list
9894 @cindex maximum value
9897 @item @emph{Description}:
9898 Returns the argument with the largest (most positive) value.
9900 @item @emph{Standard}:
9901 Fortran 77 and later
9906 @item @emph{Syntax}:
9907 @code{RESULT = MAX(A1, A2 [, A3 [, ...]])}
9909 @item @emph{Arguments}:
9910 @multitable @columnfractions .15 .70
9911 @item @var{A1} @tab The type shall be @code{INTEGER} or
9913 @item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
9914 as @var{A1}. (As a GNU extension, arguments of different kinds are
9918 @item @emph{Return value}:
9919 The return value corresponds to the maximum value among the arguments,
9920 and has the same type and kind as the first argument.
9922 @item @emph{Specific names}:
9923 @multitable @columnfractions .20 .20 .20 .25
9924 @item Name @tab Argument @tab Return type @tab Standard
9925 @item @code{MAX0(A1)} @tab @code{INTEGER(4) A1} @tab @code{INTEGER(4)} @tab Fortran 77 and later
9926 @item @code{AMAX0(A1)} @tab @code{INTEGER(4) A1} @tab @code{REAL(MAX(X))} @tab Fortran 77 and later
9927 @item @code{MAX1(A1)} @tab @code{REAL A1} @tab @code{INT(MAX(X))} @tab Fortran 77 and later
9928 @item @code{AMAX1(A1)} @tab @code{REAL(4) A1} @tab @code{REAL(4)} @tab Fortran 77 and later
9929 @item @code{DMAX1(A1)} @tab @code{REAL(8) A1} @tab @code{REAL(8)} @tab Fortran 77 and later
9932 @item @emph{See also}:
9933 @ref{MAXLOC} @ref{MAXVAL}, @ref{MIN}
9940 @section @code{MAXEXPONENT} --- Maximum exponent of a real kind
9941 @fnindex MAXEXPONENT
9942 @cindex model representation, maximum exponent
9945 @item @emph{Description}:
9946 @code{MAXEXPONENT(X)} returns the maximum exponent in the model of the
9949 @item @emph{Standard}:
9950 Fortran 95 and later
9955 @item @emph{Syntax}:
9956 @code{RESULT = MAXEXPONENT(X)}
9958 @item @emph{Arguments}:
9959 @multitable @columnfractions .15 .70
9960 @item @var{X} @tab Shall be of type @code{REAL}.
9963 @item @emph{Return value}:
9964 The return value is of type @code{INTEGER} and of the default integer
9967 @item @emph{Example}:
9973 print *, minexponent(x), maxexponent(x)
9974 print *, minexponent(y), maxexponent(y)
9975 end program exponents
9982 @section @code{MAXLOC} --- Location of the maximum value within an array
9984 @cindex array, location of maximum element
9987 @item @emph{Description}:
9988 Determines the location of the element in the array with the maximum
9989 value, or, if the @var{DIM} argument is supplied, determines the
9990 locations of the maximum element along each row of the array in the
9991 @var{DIM} direction. If @var{MASK} is present, only the elements for
9992 which @var{MASK} is @code{.TRUE.} are considered. If more than one
9993 element in the array has the maximum value, the location returned is
9994 that of the first such element in array element order if the
9995 @var{BACK} is not present, or if it false; otherwise, the location
9996 returned is that of the first such element. If the array has zero
9997 size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
9998 the result is an array of zeroes. Similarly, if @var{DIM} is supplied
9999 and all of the elements of @var{MASK} along a given row are zero, the
10000 result value for that row is zero.
10002 @item @emph{Standard}:
10003 Fortran 95 and later; @var{ARRAY} of @code{CHARACTER} and the
10004 @var{KIND} argument are available in Fortran 2003 and later.
10005 The @var{BACK} argument is available in Fortran 2008 and later.
10007 @item @emph{Class}:
10008 Transformational function
10010 @item @emph{Syntax}:
10011 @multitable @columnfractions .80
10012 @item @code{RESULT = MAXLOC(ARRAY, DIM [, MASK] [,KIND] [,BACK])}
10013 @item @code{RESULT = MAXLOC(ARRAY [, MASK] [,KIND] [,BACK])}
10016 @item @emph{Arguments}:
10017 @multitable @columnfractions .15 .70
10018 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or
10020 @item @var{DIM} @tab (Optional) Shall be a scalar of type
10021 @code{INTEGER}, with a value between one and the rank of @var{ARRAY},
10022 inclusive. It may not be an optional dummy argument.
10023 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL},
10024 and conformable with @var{ARRAY}.
10025 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
10026 expression indicating the kind parameter of the result.
10027 @item @var{BACK} @tab (Optional) A scalar of type @code{LOGICAL}.
10030 @item @emph{Return value}:
10031 If @var{DIM} is absent, the result is a rank-one array with a length
10032 equal to the rank of @var{ARRAY}. If @var{DIM} is present, the result
10033 is an array with a rank one less than the rank of @var{ARRAY}, and a
10034 size corresponding to the size of @var{ARRAY} with the @var{DIM}
10035 dimension removed. If @var{DIM} is present and @var{ARRAY} has a rank
10036 of one, the result is a scalar. If the optional argument @var{KIND}
10037 is present, the result is an integer of kind @var{KIND}, otherwise it
10038 is of default kind.
10040 @item @emph{See also}:
10041 @ref{MAX}, @ref{MAXVAL}
10048 @section @code{MAXVAL} --- Maximum value of an array
10050 @cindex array, maximum value
10051 @cindex maximum value
10054 @item @emph{Description}:
10055 Determines the maximum value of the elements in an array value, or, if
10056 the @var{DIM} argument is supplied, determines the maximum value along
10057 each row of the array in the @var{DIM} direction. If @var{MASK} is
10058 present, only the elements for which @var{MASK} is @code{.TRUE.} are
10059 considered. If the array has zero size, or all of the elements of
10060 @var{MASK} are @code{.FALSE.}, then the result is @code{-HUGE(ARRAY)}
10061 if @var{ARRAY} is numeric, or a string of nulls if @var{ARRAY} is of character
10064 @item @emph{Standard}:
10065 Fortran 95 and later
10067 @item @emph{Class}:
10068 Transformational function
10070 @item @emph{Syntax}:
10071 @multitable @columnfractions .80
10072 @item @code{RESULT = MAXVAL(ARRAY, DIM [, MASK])}
10073 @item @code{RESULT = MAXVAL(ARRAY [, MASK])}
10076 @item @emph{Arguments}:
10077 @multitable @columnfractions .15 .70
10078 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or
10080 @item @var{DIM} @tab (Optional) Shall be a scalar of type
10081 @code{INTEGER}, with a value between one and the rank of @var{ARRAY},
10082 inclusive. It may not be an optional dummy argument.
10083 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL},
10084 and conformable with @var{ARRAY}.
10087 @item @emph{Return value}:
10088 If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
10089 is a scalar. If @var{DIM} is present, the result is an array with a
10090 rank one less than the rank of @var{ARRAY}, and a size corresponding to
10091 the size of @var{ARRAY} with the @var{DIM} dimension removed. In all
10092 cases, the result is of the same type and kind as @var{ARRAY}.
10094 @item @emph{See also}:
10095 @ref{MAX}, @ref{MAXLOC}
10101 @section @code{MCLOCK} --- Time function
10103 @cindex time, clock ticks
10104 @cindex clock ticks
10107 @item @emph{Description}:
10108 Returns the number of clock ticks since the start of the process, based
10109 on the function @code{clock(3)} in the C standard library.
10111 This intrinsic is not fully portable, such as to systems with 32-bit
10112 @code{INTEGER} types but supporting times wider than 32 bits. Therefore,
10113 the values returned by this intrinsic might be, or become, negative, or
10114 numerically less than previous values, during a single run of the
10117 @item @emph{Standard}:
10120 @item @emph{Class}:
10123 @item @emph{Syntax}:
10124 @code{RESULT = MCLOCK()}
10126 @item @emph{Return value}:
10127 The return value is a scalar of type @code{INTEGER(4)}, equal to the
10128 number of clock ticks since the start of the process, or @code{-1} if
10129 the system does not support @code{clock(3)}.
10131 @item @emph{See also}:
10132 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME}
10139 @section @code{MCLOCK8} --- Time function (64-bit)
10141 @cindex time, clock ticks
10142 @cindex clock ticks
10145 @item @emph{Description}:
10146 Returns the number of clock ticks since the start of the process, based
10147 on the function @code{clock(3)} in the C standard library.
10149 @emph{Warning:} this intrinsic does not increase the range of the timing
10150 values over that returned by @code{clock(3)}. On a system with a 32-bit
10151 @code{clock(3)}, @code{MCLOCK8} will return a 32-bit value, even though
10152 it is converted to a 64-bit @code{INTEGER(8)} value. That means
10153 overflows of the 32-bit value can still occur. Therefore, the values
10154 returned by this intrinsic might be or become negative or numerically
10155 less than previous values during a single run of the compiled program.
10157 @item @emph{Standard}:
10160 @item @emph{Class}:
10163 @item @emph{Syntax}:
10164 @code{RESULT = MCLOCK8()}
10166 @item @emph{Return value}:
10167 The return value is a scalar of type @code{INTEGER(8)}, equal to the
10168 number of clock ticks since the start of the process, or @code{-1} if
10169 the system does not support @code{clock(3)}.
10171 @item @emph{See also}:
10172 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME8}
10179 @section @code{MERGE} --- Merge variables
10181 @cindex array, merge arrays
10182 @cindex array, combine arrays
10185 @item @emph{Description}:
10186 Select values from two arrays according to a logical mask. The result
10187 is equal to @var{TSOURCE} if @var{MASK} is @code{.TRUE.}, or equal to
10188 @var{FSOURCE} if it is @code{.FALSE.}.
10190 @item @emph{Standard}:
10191 Fortran 95 and later
10193 @item @emph{Class}:
10196 @item @emph{Syntax}:
10197 @code{RESULT = MERGE(TSOURCE, FSOURCE, MASK)}
10199 @item @emph{Arguments}:
10200 @multitable @columnfractions .15 .70
10201 @item @var{TSOURCE} @tab May be of any type.
10202 @item @var{FSOURCE} @tab Shall be of the same type and type parameters
10204 @item @var{MASK} @tab Shall be of type @code{LOGICAL}.
10207 @item @emph{Return value}:
10208 The result is of the same type and type parameters as @var{TSOURCE}.
10215 @section @code{MERGE_BITS} --- Merge of bits under mask
10216 @fnindex MERGE_BITS
10217 @cindex bits, merge
10220 @item @emph{Description}:
10221 @code{MERGE_BITS(I, J, MASK)} merges the bits of @var{I} and @var{J}
10222 as determined by the mask. The i-th bit of the result is equal to the
10223 i-th bit of @var{I} if the i-th bit of @var{MASK} is 1; it is equal to
10224 the i-th bit of @var{J} otherwise.
10226 @item @emph{Standard}:
10227 Fortran 2008 and later
10229 @item @emph{Class}:
10232 @item @emph{Syntax}:
10233 @code{RESULT = MERGE_BITS(I, J, MASK)}
10235 @item @emph{Arguments}:
10236 @multitable @columnfractions .15 .70
10237 @item @var{I} @tab Shall be of type @code{INTEGER}.
10238 @item @var{J} @tab Shall be of type @code{INTEGER} and of the same
10240 @item @var{MASK} @tab Shall be of type @code{INTEGER} and of the same
10244 @item @emph{Return value}:
10245 The result is of the same type and kind as @var{I}.
10252 @section @code{MIN} --- Minimum value of an argument list
10259 @cindex minimum value
10262 @item @emph{Description}:
10263 Returns the argument with the smallest (most negative) value.
10265 @item @emph{Standard}:
10266 Fortran 77 and later
10268 @item @emph{Class}:
10271 @item @emph{Syntax}:
10272 @code{RESULT = MIN(A1, A2 [, A3, ...])}
10274 @item @emph{Arguments}:
10275 @multitable @columnfractions .15 .70
10276 @item @var{A1} @tab The type shall be @code{INTEGER} or
10278 @item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
10279 as @var{A1}. (As a GNU extension, arguments of different kinds are
10283 @item @emph{Return value}:
10284 The return value corresponds to the maximum value among the arguments,
10285 and has the same type and kind as the first argument.
10287 @item @emph{Specific names}:
10288 @multitable @columnfractions .20 .20 .20 .25
10289 @item Name @tab Argument @tab Return type @tab Standard
10290 @item @code{MIN0(A1)} @tab @code{INTEGER(4) A1} @tab @code{INTEGER(4)} @tab Fortran 77 and later
10291 @item @code{AMIN0(A1)} @tab @code{INTEGER(4) A1} @tab @code{REAL(4)} @tab Fortran 77 and later
10292 @item @code{MIN1(A1)} @tab @code{REAL A1} @tab @code{INTEGER(4)} @tab Fortran 77 and later
10293 @item @code{AMIN1(A1)} @tab @code{REAL(4) A1} @tab @code{REAL(4)} @tab Fortran 77 and later
10294 @item @code{DMIN1(A1)} @tab @code{REAL(8) A1} @tab @code{REAL(8)} @tab Fortran 77 and later
10297 @item @emph{See also}:
10298 @ref{MAX}, @ref{MINLOC}, @ref{MINVAL}
10304 @section @code{MINEXPONENT} --- Minimum exponent of a real kind
10305 @fnindex MINEXPONENT
10306 @cindex model representation, minimum exponent
10309 @item @emph{Description}:
10310 @code{MINEXPONENT(X)} returns the minimum exponent in the model of the
10313 @item @emph{Standard}:
10314 Fortran 95 and later
10316 @item @emph{Class}:
10319 @item @emph{Syntax}:
10320 @code{RESULT = MINEXPONENT(X)}
10322 @item @emph{Arguments}:
10323 @multitable @columnfractions .15 .70
10324 @item @var{X} @tab Shall be of type @code{REAL}.
10327 @item @emph{Return value}:
10328 The return value is of type @code{INTEGER} and of the default integer
10331 @item @emph{Example}:
10332 See @code{MAXEXPONENT} for an example.
10338 @section @code{MINLOC} --- Location of the minimum value within an array
10340 @cindex array, location of minimum element
10343 @item @emph{Description}:
10344 Determines the location of the element in the array with the minimum
10345 value, or, if the @var{DIM} argument is supplied, determines the
10346 locations of the minimum element along each row of the array in the
10347 @var{DIM} direction. If @var{MASK} is present, only the elements for
10348 which @var{MASK} is @code{.TRUE.} are considered. If more than one
10349 element in the array has the minimum value, the location returned is
10350 that of the first such element in array element order if the
10351 @var{BACK} is not present, or if it false; otherwise, the location
10352 returned is that of the first such element. If the array has
10353 zero size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
10354 the result is an array of zeroes. Similarly, if @var{DIM} is supplied
10355 and all of the elements of @var{MASK} along a given row are zero, the
10356 result value for that row is zero.
10358 @item @emph{Standard}:
10359 Fortran 95 and later; @var{ARRAY} of @code{CHARACTER} and the
10360 @var{KIND} argument are available in Fortran 2003 and later.
10361 The @var{BACK} argument is available in Fortran 2008 and later.
10363 @item @emph{Class}:
10364 Transformational function
10366 @item @emph{Syntax}:
10367 @multitable @columnfractions .80
10368 @item @code{RESULT = MINLOC(ARRAY, DIM [, MASK] [,KIND] [,BACK])}
10369 @item @code{RESULT = MINLOC(ARRAY [, MASK], [,KIND] [,BACK])}
10372 @item @emph{Arguments}:
10373 @multitable @columnfractions .15 .70
10374 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER},
10375 @code{REAL} or @code{CHARACTER}.
10376 @item @var{DIM} @tab (Optional) Shall be a scalar of type
10377 @code{INTEGER}, with a value between one and the rank of @var{ARRAY},
10378 inclusive. It may not be an optional dummy argument.
10379 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL},
10380 and conformable with @var{ARRAY}.
10381 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
10382 expression indicating the kind parameter of the result.
10383 @item @var{BACK} @tab (Optional) A scalar of type @code{LOGICAL}.
10386 @item @emph{Return value}:
10387 If @var{DIM} is absent, the result is a rank-one array with a length
10388 equal to the rank of @var{ARRAY}. If @var{DIM} is present, the result
10389 is an array with a rank one less than the rank of @var{ARRAY}, and a
10390 size corresponding to the size of @var{ARRAY} with the @var{DIM}
10391 dimension removed. If @var{DIM} is present and @var{ARRAY} has a rank
10392 of one, the result is a scalar. If the optional argument @var{KIND}
10393 is present, the result is an integer of kind @var{KIND}, otherwise it
10394 is of default kind.
10396 @item @emph{See also}:
10397 @ref{MIN}, @ref{MINVAL}
10404 @section @code{MINVAL} --- Minimum value of an array
10406 @cindex array, minimum value
10407 @cindex minimum value
10410 @item @emph{Description}:
10411 Determines the minimum value of the elements in an array value, or, if
10412 the @var{DIM} argument is supplied, determines the minimum value along
10413 each row of the array in the @var{DIM} direction. If @var{MASK} is
10414 present, only the elements for which @var{MASK} is @code{.TRUE.} are
10415 considered. If the array has zero size, or all of the elements of
10416 @var{MASK} are @code{.FALSE.}, then the result is @code{HUGE(ARRAY)} if
10417 @var{ARRAY} is numeric, or a string of @code{CHAR(255)} characters if
10418 @var{ARRAY} is of character type.
10420 @item @emph{Standard}:
10421 Fortran 95 and later
10423 @item @emph{Class}:
10424 Transformational function
10426 @item @emph{Syntax}:
10427 @multitable @columnfractions .80
10428 @item @code{RESULT = MINVAL(ARRAY, DIM [, MASK])}
10429 @item @code{RESULT = MINVAL(ARRAY [, MASK])}
10432 @item @emph{Arguments}:
10433 @multitable @columnfractions .15 .70
10434 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER} or
10436 @item @var{DIM} @tab (Optional) Shall be a scalar of type
10437 @code{INTEGER}, with a value between one and the rank of @var{ARRAY},
10438 inclusive. It may not be an optional dummy argument.
10439 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL},
10440 and conformable with @var{ARRAY}.
10443 @item @emph{Return value}:
10444 If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
10445 is a scalar. If @var{DIM} is present, the result is an array with a
10446 rank one less than the rank of @var{ARRAY}, and a size corresponding to
10447 the size of @var{ARRAY} with the @var{DIM} dimension removed. In all
10448 cases, the result is of the same type and kind as @var{ARRAY}.
10450 @item @emph{See also}:
10451 @ref{MIN}, @ref{MINLOC}
10458 @section @code{MOD} --- Remainder function
10467 @cindex division, remainder
10470 @item @emph{Description}:
10471 @code{MOD(A,P)} computes the remainder of the division of A by P@.
10473 @item @emph{Standard}:
10474 Fortran 77 and later, has overloads that are GNU extensions
10476 @item @emph{Class}:
10479 @item @emph{Syntax}:
10480 @code{RESULT = MOD(A, P)}
10482 @item @emph{Arguments}:
10483 @multitable @columnfractions .15 .70
10484 @item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL}.
10485 @item @var{P} @tab Shall be a scalar of the same type and kind as @var{A}
10486 and not equal to zero.
10489 @item @emph{Return value}:
10490 The return value is the result of @code{A - (INT(A/P) * P)}. The type
10491 and kind of the return value is the same as that of the arguments. The
10492 returned value has the same sign as A and a magnitude less than the
10495 @item @emph{Example}:
10499 print *, mod(17.5,5.5)
10500 print *, mod(17.5d0,5.5)
10501 print *, mod(17.5,5.5d0)
10503 print *, mod(-17,3)
10504 print *, mod(-17.5,5.5)
10505 print *, mod(-17.5d0,5.5)
10506 print *, mod(-17.5,5.5d0)
10508 print *, mod(17,-3)
10509 print *, mod(17.5,-5.5)
10510 print *, mod(17.5d0,-5.5)
10511 print *, mod(17.5,-5.5d0)
10512 end program test_mod
10515 @item @emph{Specific names}:
10516 @multitable @columnfractions .20 .20 .20 .25
10517 @item Name @tab Arguments @tab Return type @tab Standard
10518 @item @code{MOD(A,P)} @tab @code{INTEGER A,P} @tab @code{INTEGER} @tab Fortran 95 and later
10519 @item @code{AMOD(A,P)} @tab @code{REAL(4) A,P} @tab @code{REAL(4)} @tab Fortran 95 and later
10520 @item @code{DMOD(A,P)} @tab @code{REAL(8) A,P} @tab @code{REAL(8)} @tab Fortran 95 and later
10521 @item @code{BMOD(A,P)} @tab @code{INTEGER(1) A,P} @tab @code{INTEGER(1)} @tab GNU extension
10522 @item @code{IMOD(A,P)} @tab @code{INTEGER(2) A,P} @tab @code{INTEGER(2)} @tab GNU extension
10523 @item @code{JMOD(A,P)} @tab @code{INTEGER(4) A,P} @tab @code{INTEGER(4)} @tab GNU extension
10524 @item @code{KMOD(A,P)} @tab @code{INTEGER(8) A,P} @tab @code{INTEGER(8)} @tab GNU extension
10527 @item @emph{See also}:
10535 @section @code{MODULO} --- Modulo function
10538 @cindex division, modulo
10541 @item @emph{Description}:
10542 @code{MODULO(A,P)} computes the @var{A} modulo @var{P}.
10544 @item @emph{Standard}:
10545 Fortran 95 and later
10547 @item @emph{Class}:
10550 @item @emph{Syntax}:
10551 @code{RESULT = MODULO(A, P)}
10553 @item @emph{Arguments}:
10554 @multitable @columnfractions .15 .70
10555 @item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL}.
10556 @item @var{P} @tab Shall be a scalar of the same type and kind as @var{A}.
10557 It shall not be zero.
10560 @item @emph{Return value}:
10561 The type and kind of the result are those of the arguments.
10563 @item If @var{A} and @var{P} are of type @code{INTEGER}:
10564 @code{MODULO(A,P)} has the value @var{R} such that @code{A=Q*P+R}, where
10565 @var{Q} is an integer and @var{R} is between 0 (inclusive) and @var{P}
10567 @item If @var{A} and @var{P} are of type @code{REAL}:
10568 @code{MODULO(A,P)} has the value of @code{A - FLOOR (A / P) * P}.
10570 The returned value has the same sign as P and a magnitude less than
10571 the magnitude of P.
10573 @item @emph{Example}:
10575 program test_modulo
10576 print *, modulo(17,3)
10577 print *, modulo(17.5,5.5)
10579 print *, modulo(-17,3)
10580 print *, modulo(-17.5,5.5)
10582 print *, modulo(17,-3)
10583 print *, modulo(17.5,-5.5)
10587 @item @emph{See also}:
10595 @section @code{MOVE_ALLOC} --- Move allocation from one object to another
10596 @fnindex MOVE_ALLOC
10597 @cindex moving allocation
10598 @cindex allocation, moving
10601 @item @emph{Description}:
10602 @code{MOVE_ALLOC(FROM, TO)} moves the allocation from @var{FROM} to
10603 @var{TO}. @var{FROM} will become deallocated in the process.
10605 @item @emph{Standard}:
10606 Fortran 2003 and later
10608 @item @emph{Class}:
10611 @item @emph{Syntax}:
10612 @code{CALL MOVE_ALLOC(FROM, TO)}
10614 @item @emph{Arguments}:
10615 @multitable @columnfractions .15 .70
10616 @item @var{FROM} @tab @code{ALLOCATABLE}, @code{INTENT(INOUT)}, may be
10617 of any type and kind.
10618 @item @var{TO} @tab @code{ALLOCATABLE}, @code{INTENT(OUT)}, shall be
10619 of the same type, kind and rank as @var{FROM}.
10622 @item @emph{Return value}:
10625 @item @emph{Example}:
10627 program test_move_alloc
10628 integer, allocatable :: a(:), b(:)
10632 call move_alloc(a, b)
10633 print *, allocated(a), allocated(b)
10635 end program test_move_alloc
10642 @section @code{MVBITS} --- Move bits from one integer to another
10651 @item @emph{Description}:
10652 Moves @var{LEN} bits from positions @var{FROMPOS} through
10653 @code{FROMPOS+LEN-1} of @var{FROM} to positions @var{TOPOS} through
10654 @code{TOPOS+LEN-1} of @var{TO}. The portion of argument @var{TO} not
10655 affected by the movement of bits is unchanged. The values of
10656 @code{FROMPOS+LEN-1} and @code{TOPOS+LEN-1} must be less than
10657 @code{BIT_SIZE(FROM)}.
10659 @item @emph{Standard}:
10660 Fortran 95 and later, has overloads that are GNU extensions
10662 @item @emph{Class}:
10663 Elemental subroutine
10665 @item @emph{Syntax}:
10666 @code{CALL MVBITS(FROM, FROMPOS, LEN, TO, TOPOS)}
10668 @item @emph{Arguments}:
10669 @multitable @columnfractions .15 .70
10670 @item @var{FROM} @tab The type shall be @code{INTEGER}.
10671 @item @var{FROMPOS} @tab The type shall be @code{INTEGER}.
10672 @item @var{LEN} @tab The type shall be @code{INTEGER}.
10673 @item @var{TO} @tab The type shall be @code{INTEGER}, of the
10674 same kind as @var{FROM}.
10675 @item @var{TOPOS} @tab The type shall be @code{INTEGER}.
10678 @item @emph{Specific names}:
10679 @multitable @columnfractions .20 .20 .20 .25
10680 @item Name @tab Argument @tab Return type @tab Standard
10681 @item @code{MVBITS(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 95 and later
10682 @item @code{BMVBITS(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
10683 @item @code{IMVBITS(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
10684 @item @code{JMVBITS(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
10685 @item @code{KMVBITS(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
10688 @item @emph{See also}:
10689 @ref{IBCLR}, @ref{IBSET}, @ref{IBITS}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
10695 @section @code{NEAREST} --- Nearest representable number
10697 @cindex real number, nearest different
10698 @cindex floating point, nearest different
10701 @item @emph{Description}:
10702 @code{NEAREST(X, S)} returns the processor-representable number nearest
10703 to @code{X} in the direction indicated by the sign of @code{S}.
10705 @item @emph{Standard}:
10706 Fortran 95 and later
10708 @item @emph{Class}:
10711 @item @emph{Syntax}:
10712 @code{RESULT = NEAREST(X, S)}
10714 @item @emph{Arguments}:
10715 @multitable @columnfractions .15 .70
10716 @item @var{X} @tab Shall be of type @code{REAL}.
10717 @item @var{S} @tab Shall be of type @code{REAL} and
10721 @item @emph{Return value}:
10722 The return value is of the same type as @code{X}. If @code{S} is
10723 positive, @code{NEAREST} returns the processor-representable number
10724 greater than @code{X} and nearest to it. If @code{S} is negative,
10725 @code{NEAREST} returns the processor-representable number smaller than
10726 @code{X} and nearest to it.
10728 @item @emph{Example}:
10730 program test_nearest
10732 x = nearest(42.0, 1.0)
10733 y = nearest(42.0, -1.0)
10734 write (*,"(3(G20.15))") x, y, x - y
10735 end program test_nearest
10742 @section @code{NEW_LINE} --- New line character
10745 @cindex output, newline
10748 @item @emph{Description}:
10749 @code{NEW_LINE(C)} returns the new-line character.
10751 @item @emph{Standard}:
10752 Fortran 2003 and later
10754 @item @emph{Class}:
10757 @item @emph{Syntax}:
10758 @code{RESULT = NEW_LINE(C)}
10760 @item @emph{Arguments}:
10761 @multitable @columnfractions .15 .70
10762 @item @var{C} @tab The argument shall be a scalar or array of the
10763 type @code{CHARACTER}.
10766 @item @emph{Return value}:
10767 Returns a @var{CHARACTER} scalar of length one with the new-line character of
10768 the same kind as parameter @var{C}.
10770 @item @emph{Example}:
10774 write(*,'(A)') 'This is record 1.'//NEW_LINE('A')//'This is record 2.'
10775 end program newline
10782 @section @code{NINT} --- Nearest whole number
10785 @cindex rounding, nearest whole number
10788 @item @emph{Description}:
10789 @code{NINT(A)} rounds its argument to the nearest whole number.
10791 @item @emph{Standard}:
10792 Fortran 77 and later, with @var{KIND} argument Fortran 90 and later
10794 @item @emph{Class}:
10797 @item @emph{Syntax}:
10798 @code{RESULT = NINT(A [, KIND])}
10800 @item @emph{Arguments}:
10801 @multitable @columnfractions .15 .70
10802 @item @var{A} @tab The type of the argument shall be @code{REAL}.
10803 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
10804 expression indicating the kind parameter of the result.
10807 @item @emph{Return value}:
10808 Returns @var{A} with the fractional portion of its magnitude eliminated by
10809 rounding to the nearest whole number and with its sign preserved,
10810 converted to an @code{INTEGER} of the default kind.
10812 @item @emph{Example}:
10819 print *, nint(x4), idnint(x8)
10820 end program test_nint
10823 @item @emph{Specific names}:
10824 @multitable @columnfractions .20 .20 .20 .25
10825 @item Name @tab Argument @tab Return Type @tab Standard
10826 @item @code{NINT(A)} @tab @code{REAL(4) A} @tab @code{INTEGER} @tab Fortran 95 and later
10827 @item @code{IDNINT(A)} @tab @code{REAL(8) A} @tab @code{INTEGER} @tab Fortran 95 and later
10830 @item @emph{See also}:
10831 @ref{CEILING}, @ref{FLOOR}
10838 @section @code{NORM2} --- Euclidean vector norms
10840 @cindex Euclidean vector norm
10841 @cindex L2 vector norm
10842 @cindex norm, Euclidean
10845 @item @emph{Description}:
10846 Calculates the Euclidean vector norm (@math{L_2} norm) of
10847 of @var{ARRAY} along dimension @var{DIM}.
10849 @item @emph{Standard}:
10850 Fortran 2008 and later
10852 @item @emph{Class}:
10853 Transformational function
10855 @item @emph{Syntax}:
10856 @multitable @columnfractions .80
10857 @item @code{RESULT = NORM2(ARRAY[, DIM])}
10860 @item @emph{Arguments}:
10861 @multitable @columnfractions .15 .70
10862 @item @var{ARRAY} @tab Shall be an array of type @code{REAL}
10863 @item @var{DIM} @tab (Optional) shall be a scalar of type
10864 @code{INTEGER} with a value in the range from 1 to n, where n
10865 equals the rank of @var{ARRAY}.
10868 @item @emph{Return value}:
10869 The result is of the same type as @var{ARRAY}.
10871 If @var{DIM} is absent, a scalar with the square root of the sum of all
10872 elements in @var{ARRAY} squared is returned. Otherwise, an array of
10873 rank @math{n-1}, where @math{n} equals the rank of @var{ARRAY}, and a
10874 shape similar to that of @var{ARRAY} with dimension @var{DIM} dropped
10877 @item @emph{Example}:
10880 REAL :: x(5) = [ real :: 1, 2, 3, 4, 5 ]
10881 print *, NORM2(x) ! = sqrt(55.) ~ 7.416
10889 @section @code{NOT} --- Logical negation
10895 @cindex bits, negate
10896 @cindex bitwise logical not
10897 @cindex logical not, bitwise
10900 @item @emph{Description}:
10901 @code{NOT} returns the bitwise Boolean inverse of @var{I}.
10903 @item @emph{Standard}:
10904 Fortran 95 and later, has overloads that are GNU extensions
10906 @item @emph{Class}:
10909 @item @emph{Syntax}:
10910 @code{RESULT = NOT(I)}
10912 @item @emph{Arguments}:
10913 @multitable @columnfractions .15 .70
10914 @item @var{I} @tab The type shall be @code{INTEGER}.
10917 @item @emph{Return value}:
10918 The return type is @code{INTEGER}, of the same kind as the
10921 @item @emph{Specific names}:
10922 @multitable @columnfractions .20 .20 .20 .25
10923 @item Name @tab Argument @tab Return type @tab Standard
10924 @item @code{NOT(A)} @tab @code{INTEGER A} @tab @code{INTEGER} @tab Fortran 95 and later
10925 @item @code{BNOT(A)} @tab @code{INTEGER(1) A} @tab @code{INTEGER(1)} @tab GNU extension
10926 @item @code{INOT(A)} @tab @code{INTEGER(2) A} @tab @code{INTEGER(2)} @tab GNU extension
10927 @item @code{JNOT(A)} @tab @code{INTEGER(4) A} @tab @code{INTEGER(4)} @tab GNU extension
10928 @item @code{KNOT(A)} @tab @code{INTEGER(8) A} @tab @code{INTEGER(8)} @tab GNU extension
10931 @item @emph{See also}:
10932 @ref{IAND}, @ref{IEOR}, @ref{IOR}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}
10939 @section @code{NULL} --- Function that returns an disassociated pointer
10941 @cindex pointer, status
10942 @cindex pointer, disassociated
10945 @item @emph{Description}:
10946 Returns a disassociated pointer.
10948 If @var{MOLD} is present, a disassociated pointer of the same type is
10949 returned, otherwise the type is determined by context.
10951 In Fortran 95, @var{MOLD} is optional. Please note that Fortran 2003
10952 includes cases where it is required.
10954 @item @emph{Standard}:
10955 Fortran 95 and later
10957 @item @emph{Class}:
10958 Transformational function
10960 @item @emph{Syntax}:
10961 @code{PTR => NULL([MOLD])}
10963 @item @emph{Arguments}:
10964 @multitable @columnfractions .15 .70
10965 @item @var{MOLD} @tab (Optional) shall be a pointer of any association
10966 status and of any type.
10969 @item @emph{Return value}:
10970 A disassociated pointer.
10972 @item @emph{Example}:
10974 REAL, POINTER, DIMENSION(:) :: VEC => NULL ()
10977 @item @emph{See also}:
10984 @section @code{NUM_IMAGES} --- Function that returns the number of images
10985 @fnindex NUM_IMAGES
10986 @cindex coarray, @code{NUM_IMAGES}
10987 @cindex images, number of
10990 @item @emph{Description}:
10991 Returns the number of images.
10993 @item @emph{Standard}:
10994 Fortran 2008 and later. With @var{DISTANCE} or @var{FAILED} argument,
10995 Technical Specification (TS) 18508 or later
10998 @item @emph{Class}:
10999 Transformational function
11001 @item @emph{Syntax}:
11002 @code{RESULT = NUM_IMAGES(DISTANCE, FAILED)}
11004 @item @emph{Arguments}:
11005 @multitable @columnfractions .15 .70
11006 @item @var{DISTANCE} @tab (optional, intent(in)) Nonnegative scalar integer
11007 @item @var{FAILED} @tab (optional, intent(in)) Scalar logical expression
11010 @item @emph{Return value}:
11011 Scalar default-kind integer. If @var{DISTANCE} is not present or has value 0,
11012 the number of images in the current team is returned. For values smaller or
11013 equal distance to the initial team, it returns the number of images index
11014 on the ancestor team which has a distance of @var{DISTANCE} from the invoking
11015 team. If @var{DISTANCE} is larger than the distance to the initial team, the
11016 number of images of the initial team is returned. If @var{FAILED} is not present
11017 the total number of images is returned; if it has the value @code{.TRUE.},
11018 the number of failed images is returned, otherwise, the number of images which
11019 do have not the failed status.
11021 @item @emph{Example}:
11023 INTEGER :: value[*]
11025 value = THIS_IMAGE()
11027 IF (THIS_IMAGE() == 1) THEN
11028 DO i = 1, NUM_IMAGES()
11029 WRITE(*,'(2(a,i0))') 'value[', i, '] is ', value[i]
11034 @item @emph{See also}:
11035 @ref{THIS_IMAGE}, @ref{IMAGE_INDEX}
11041 @section @code{OR} --- Bitwise logical OR
11043 @cindex bitwise logical or
11044 @cindex logical or, bitwise
11047 @item @emph{Description}:
11048 Bitwise logical @code{OR}.
11050 This intrinsic routine is provided for backwards compatibility with
11051 GNU Fortran 77. For integer arguments, programmers should consider
11052 the use of the @ref{IOR} intrinsic defined by the Fortran standard.
11054 @item @emph{Standard}:
11057 @item @emph{Class}:
11060 @item @emph{Syntax}:
11061 @code{RESULT = OR(I, J)}
11063 @item @emph{Arguments}:
11064 @multitable @columnfractions .15 .70
11065 @item @var{I} @tab The type shall be either a scalar @code{INTEGER}
11066 type or a scalar @code{LOGICAL} type.
11067 @item @var{J} @tab The type shall be the same as the type of @var{J}.
11070 @item @emph{Return value}:
11071 The return type is either a scalar @code{INTEGER} or a scalar
11072 @code{LOGICAL}. If the kind type parameters differ, then the
11073 smaller kind type is implicitly converted to larger kind, and the
11074 return has the larger kind.
11076 @item @emph{Example}:
11079 LOGICAL :: T = .TRUE., F = .FALSE.
11081 DATA a / Z'F' /, b / Z'3' /
11083 WRITE (*,*) OR(T, T), OR(T, F), OR(F, T), OR(F, F)
11084 WRITE (*,*) OR(a, b)
11088 @item @emph{See also}:
11089 Fortran 95 elemental function: @ref{IOR}
11095 @section @code{PACK} --- Pack an array into an array of rank one
11097 @cindex array, packing
11098 @cindex array, reduce dimension
11099 @cindex array, gather elements
11102 @item @emph{Description}:
11103 Stores the elements of @var{ARRAY} in an array of rank one.
11105 The beginning of the resulting array is made up of elements whose @var{MASK}
11106 equals @code{TRUE}. Afterwards, positions are filled with elements taken from
11109 @item @emph{Standard}:
11110 Fortran 95 and later
11112 @item @emph{Class}:
11113 Transformational function
11115 @item @emph{Syntax}:
11116 @code{RESULT = PACK(ARRAY, MASK[,VECTOR])}
11118 @item @emph{Arguments}:
11119 @multitable @columnfractions .15 .70
11120 @item @var{ARRAY} @tab Shall be an array of any type.
11121 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL} and
11122 of the same size as @var{ARRAY}. Alternatively, it may be a @code{LOGICAL}
11124 @item @var{VECTOR} @tab (Optional) shall be an array of the same type
11125 as @var{ARRAY} and of rank one. If present, the number of elements in
11126 @var{VECTOR} shall be equal to or greater than the number of true elements
11127 in @var{MASK}. If @var{MASK} is scalar, the number of elements in
11128 @var{VECTOR} shall be equal to or greater than the number of elements in
11132 @item @emph{Return value}:
11133 The result is an array of rank one and the same type as that of @var{ARRAY}.
11134 If @var{VECTOR} is present, the result size is that of @var{VECTOR}, the
11135 number of @code{TRUE} values in @var{MASK} otherwise.
11137 @item @emph{Example}:
11138 Gathering nonzero elements from an array:
11140 PROGRAM test_pack_1
11142 m = (/ 1, 0, 0, 0, 5, 0 /)
11143 WRITE(*, FMT="(6(I0, ' '))") pack(m, m /= 0) ! "1 5"
11147 Gathering nonzero elements from an array and appending elements from @var{VECTOR}:
11149 PROGRAM test_pack_2
11151 m = (/ 1, 0, 0, 2 /)
11152 WRITE(*, FMT="(4(I0, ' '))") pack(m, m /= 0, (/ 0, 0, 3, 4 /)) ! "1 2 3 4"
11156 @item @emph{See also}:
11163 @section @code{PARITY} --- Reduction with exclusive OR
11166 @cindex Reduction, XOR
11167 @cindex XOR reduction
11170 @item @emph{Description}:
11171 Calculates the parity, i.e. the reduction using @code{.XOR.},
11172 of @var{MASK} along dimension @var{DIM}.
11174 @item @emph{Standard}:
11175 Fortran 2008 and later
11177 @item @emph{Class}:
11178 Transformational function
11180 @item @emph{Syntax}:
11181 @multitable @columnfractions .80
11182 @item @code{RESULT = PARITY(MASK[, DIM])}
11185 @item @emph{Arguments}:
11186 @multitable @columnfractions .15 .70
11187 @item @var{LOGICAL} @tab Shall be an array of type @code{LOGICAL}
11188 @item @var{DIM} @tab (Optional) shall be a scalar of type
11189 @code{INTEGER} with a value in the range from 1 to n, where n
11190 equals the rank of @var{MASK}.
11193 @item @emph{Return value}:
11194 The result is of the same type as @var{MASK}.
11196 If @var{DIM} is absent, a scalar with the parity of all elements in
11197 @var{MASK} is returned, i.e. true if an odd number of elements is
11198 @code{.true.} and false otherwise. If @var{DIM} is present, an array
11199 of rank @math{n-1}, where @math{n} equals the rank of @var{ARRAY},
11200 and a shape similar to that of @var{MASK} with dimension @var{DIM}
11201 dropped is returned.
11203 @item @emph{Example}:
11206 LOGICAL :: x(2) = [ .true., .false. ]
11207 print *, PARITY(x) ! prints "T" (true).
11215 @section @code{PERROR} --- Print system error message
11217 @cindex system, error handling
11220 @item @emph{Description}:
11221 Prints (on the C @code{stderr} stream) a newline-terminated error
11222 message corresponding to the last system error. This is prefixed by
11223 @var{STRING}, a colon and a space. See @code{perror(3)}.
11225 @item @emph{Standard}:
11228 @item @emph{Class}:
11231 @item @emph{Syntax}:
11232 @code{CALL PERROR(STRING)}
11234 @item @emph{Arguments}:
11235 @multitable @columnfractions .15 .70
11236 @item @var{STRING} @tab A scalar of type @code{CHARACTER} and of the
11240 @item @emph{See also}:
11247 @section @code{POPCNT} --- Number of bits set
11249 @cindex binary representation
11253 @item @emph{Description}:
11254 @code{POPCNT(I)} returns the number of bits set ('1' bits) in the binary
11255 representation of @code{I}.
11257 @item @emph{Standard}:
11258 Fortran 2008 and later
11260 @item @emph{Class}:
11263 @item @emph{Syntax}:
11264 @code{RESULT = POPCNT(I)}
11266 @item @emph{Arguments}:
11267 @multitable @columnfractions .15 .70
11268 @item @var{I} @tab Shall be of type @code{INTEGER}.
11271 @item @emph{Return value}:
11272 The return value is of type @code{INTEGER} and of the default integer
11275 @item @emph{See also}:
11276 @ref{POPPAR}, @ref{LEADZ}, @ref{TRAILZ}
11278 @item @emph{Example}:
11280 program test_population
11281 print *, popcnt(127), poppar(127)
11282 print *, popcnt(huge(0_4)), poppar(huge(0_4))
11283 print *, popcnt(huge(0_8)), poppar(huge(0_8))
11284 end program test_population
11290 @section @code{POPPAR} --- Parity of the number of bits set
11292 @cindex binary representation
11296 @item @emph{Description}:
11297 @code{POPPAR(I)} returns parity of the integer @code{I}, i.e. the parity
11298 of the number of bits set ('1' bits) in the binary representation of
11299 @code{I}. It is equal to 0 if @code{I} has an even number of bits set,
11300 and 1 for an odd number of '1' bits.
11302 @item @emph{Standard}:
11303 Fortran 2008 and later
11305 @item @emph{Class}:
11308 @item @emph{Syntax}:
11309 @code{RESULT = POPPAR(I)}
11311 @item @emph{Arguments}:
11312 @multitable @columnfractions .15 .70
11313 @item @var{I} @tab Shall be of type @code{INTEGER}.
11316 @item @emph{Return value}:
11317 The return value is of type @code{INTEGER} and of the default integer
11320 @item @emph{See also}:
11321 @ref{POPCNT}, @ref{LEADZ}, @ref{TRAILZ}
11323 @item @emph{Example}:
11325 program test_population
11326 print *, popcnt(127), poppar(127)
11327 print *, popcnt(huge(0_4)), poppar(huge(0_4))
11328 print *, popcnt(huge(0_8)), poppar(huge(0_8))
11329 end program test_population
11336 @section @code{PRECISION} --- Decimal precision of a real kind
11338 @cindex model representation, precision
11341 @item @emph{Description}:
11342 @code{PRECISION(X)} returns the decimal precision in the model of the
11345 @item @emph{Standard}:
11346 Fortran 95 and later
11348 @item @emph{Class}:
11351 @item @emph{Syntax}:
11352 @code{RESULT = PRECISION(X)}
11354 @item @emph{Arguments}:
11355 @multitable @columnfractions .15 .70
11356 @item @var{X} @tab Shall be of type @code{REAL} or @code{COMPLEX}.
11359 @item @emph{Return value}:
11360 The return value is of type @code{INTEGER} and of the default integer
11363 @item @emph{See also}:
11364 @ref{SELECTED_REAL_KIND}, @ref{RANGE}
11366 @item @emph{Example}:
11368 program prec_and_range
11369 real(kind=4) :: x(2)
11370 complex(kind=8) :: y
11372 print *, precision(x), range(x)
11373 print *, precision(y), range(y)
11374 end program prec_and_range
11381 @section @code{PRESENT} --- Determine whether an optional dummy argument is specified
11385 @item @emph{Description}:
11386 Determines whether an optional dummy argument is present.
11388 @item @emph{Standard}:
11389 Fortran 95 and later
11391 @item @emph{Class}:
11394 @item @emph{Syntax}:
11395 @code{RESULT = PRESENT(A)}
11397 @item @emph{Arguments}:
11398 @multitable @columnfractions .15 .70
11399 @item @var{A} @tab May be of any type and may be a pointer, scalar or array
11400 value, or a dummy procedure. It shall be the name of an optional dummy argument
11401 accessible within the current subroutine or function.
11404 @item @emph{Return value}:
11405 Returns either @code{TRUE} if the optional argument @var{A} is present, or
11406 @code{FALSE} otherwise.
11408 @item @emph{Example}:
11410 PROGRAM test_present
11411 WRITE(*,*) f(), f(42) ! "F T"
11413 LOGICAL FUNCTION f(x)
11414 INTEGER, INTENT(IN), OPTIONAL :: x
11424 @section @code{PRODUCT} --- Product of array elements
11426 @cindex array, product
11427 @cindex array, multiply elements
11428 @cindex array, conditionally multiply elements
11429 @cindex multiply array elements
11432 @item @emph{Description}:
11433 Multiplies the elements of @var{ARRAY} along dimension @var{DIM} if
11434 the corresponding element in @var{MASK} is @code{TRUE}.
11436 @item @emph{Standard}:
11437 Fortran 95 and later
11439 @item @emph{Class}:
11440 Transformational function
11442 @item @emph{Syntax}:
11443 @multitable @columnfractions .80
11444 @item @code{RESULT = PRODUCT(ARRAY[, MASK])}
11445 @item @code{RESULT = PRODUCT(ARRAY, DIM[, MASK])}
11448 @item @emph{Arguments}:
11449 @multitable @columnfractions .15 .70
11450 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER},
11451 @code{REAL} or @code{COMPLEX}.
11452 @item @var{DIM} @tab (Optional) shall be a scalar of type
11453 @code{INTEGER} with a value in the range from 1 to n, where n
11454 equals the rank of @var{ARRAY}.
11455 @item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL}
11456 and either be a scalar or an array of the same shape as @var{ARRAY}.
11459 @item @emph{Return value}:
11460 The result is of the same type as @var{ARRAY}.
11462 If @var{DIM} is absent, a scalar with the product of all elements in
11463 @var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals
11464 the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with
11465 dimension @var{DIM} dropped is returned.
11468 @item @emph{Example}:
11470 PROGRAM test_product
11471 INTEGER :: x(5) = (/ 1, 2, 3, 4 ,5 /)
11472 print *, PRODUCT(x) ! all elements, product = 120
11473 print *, PRODUCT(x, MASK=MOD(x, 2)==1) ! odd elements, product = 15
11477 @item @emph{See also}:
11484 @section @code{RADIX} --- Base of a model number
11486 @cindex model representation, base
11487 @cindex model representation, radix
11490 @item @emph{Description}:
11491 @code{RADIX(X)} returns the base of the model representing the entity @var{X}.
11493 @item @emph{Standard}:
11494 Fortran 95 and later
11496 @item @emph{Class}:
11499 @item @emph{Syntax}:
11500 @code{RESULT = RADIX(X)}
11502 @item @emph{Arguments}:
11503 @multitable @columnfractions .15 .70
11504 @item @var{X} @tab Shall be of type @code{INTEGER} or @code{REAL}
11507 @item @emph{Return value}:
11508 The return value is a scalar of type @code{INTEGER} and of the default
11511 @item @emph{See also}:
11512 @ref{SELECTED_REAL_KIND}
11514 @item @emph{Example}:
11517 print *, "The radix for the default integer kind is", radix(0)
11518 print *, "The radix for the default real kind is", radix(0.0)
11519 end program test_radix
11527 @section @code{RAN} --- Real pseudo-random number
11529 @cindex random number generation
11532 @item @emph{Description}:
11533 For compatibility with HP FORTRAN 77/iX, the @code{RAN} intrinsic is
11534 provided as an alias for @code{RAND}. See @ref{RAND} for complete
11537 @item @emph{Standard}:
11540 @item @emph{Class}:
11543 @item @emph{See also}:
11544 @ref{RAND}, @ref{RANDOM_NUMBER}
11550 @section @code{RAND} --- Real pseudo-random number
11552 @cindex random number generation
11555 @item @emph{Description}:
11556 @code{RAND(FLAG)} returns a pseudo-random number from a uniform
11557 distribution between 0 and 1. If @var{FLAG} is 0, the next number
11558 in the current sequence is returned; if @var{FLAG} is 1, the generator
11559 is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
11560 it is used as a new seed with @code{SRAND}.
11562 This intrinsic routine is provided for backwards compatibility with
11563 GNU Fortran 77. It implements a simple modulo generator as provided
11564 by @command{g77}. For new code, one should consider the use of
11565 @ref{RANDOM_NUMBER} as it implements a superior algorithm.
11567 @item @emph{Standard}:
11570 @item @emph{Class}:
11573 @item @emph{Syntax}:
11574 @code{RESULT = RAND(I)}
11576 @item @emph{Arguments}:
11577 @multitable @columnfractions .15 .70
11578 @item @var{I} @tab Shall be a scalar @code{INTEGER} of kind 4.
11581 @item @emph{Return value}:
11582 The return value is of @code{REAL} type and the default kind.
11584 @item @emph{Example}:
11587 integer,parameter :: seed = 86456
11590 print *, rand(), rand(), rand(), rand()
11591 print *, rand(seed), rand(), rand(), rand()
11592 end program test_rand
11595 @item @emph{See also}:
11596 @ref{SRAND}, @ref{RANDOM_NUMBER}
11602 @node RANDOM_NUMBER
11603 @section @code{RANDOM_NUMBER} --- Pseudo-random number
11604 @fnindex RANDOM_NUMBER
11605 @cindex random number generation
11608 @item @emph{Description}:
11609 Returns a single pseudorandom number or an array of pseudorandom numbers
11610 from the uniform distribution over the range @math{ 0 \leq x < 1}.
11612 The runtime-library implements the xorshift1024* random number
11613 generator (RNG). This generator has a period of @math{2^{1024} - 1},
11614 and when using multiple threads up to @math{2^{512}} threads can each
11615 generate @math{2^{512}} random numbers before any aliasing occurs.
11617 Note that in a multi-threaded program (e.g. using OpenMP directives),
11618 each thread will have its own random number state. For details of the
11619 seeding procedure, see the documentation for the @code{RANDOM_SEED}
11623 @item @emph{Standard}:
11624 Fortran 95 and later
11626 @item @emph{Class}:
11629 @item @emph{Syntax}:
11630 @code{RANDOM_NUMBER(HARVEST)}
11632 @item @emph{Arguments}:
11633 @multitable @columnfractions .15 .70
11634 @item @var{HARVEST} @tab Shall be a scalar or an array of type @code{REAL}.
11637 @item @emph{Example}:
11639 program test_random_number
11641 CALL RANDOM_NUMBER(r)
11645 @item @emph{See also}:
11652 @section @code{RANDOM_SEED} --- Initialize a pseudo-random number sequence
11653 @fnindex RANDOM_SEED
11654 @cindex random number generation, seeding
11655 @cindex seeding a random number generator
11658 @item @emph{Description}:
11659 Restarts or queries the state of the pseudorandom number generator used by
11660 @code{RANDOM_NUMBER}.
11662 If @code{RANDOM_SEED} is called without arguments, it is seeded with
11663 random data retrieved from the operating system.
11665 As an extension to the Fortran standard, the GFortran
11666 @code{RANDOM_NUMBER} supports multiple threads. Each thread in a
11667 multi-threaded program has its own seed. When @code{RANDOM_SEED} is
11668 called either without arguments or with the @var{PUT} argument, the
11669 given seed is copied into a master seed as well as the seed of the
11670 current thread. When a new thread uses @code{RANDOM_NUMBER} for the
11671 first time, the seed is copied from the master seed, and forwarded
11672 @math{N * 2^{512}} steps to guarantee that the random stream does not
11673 alias any other stream in the system, where @var{N} is the number of
11674 threads that have used @code{RANDOM_NUMBER} so far during the program
11677 @item @emph{Standard}:
11678 Fortran 95 and later
11680 @item @emph{Class}:
11683 @item @emph{Syntax}:
11684 @code{CALL RANDOM_SEED([SIZE, PUT, GET])}
11686 @item @emph{Arguments}:
11687 @multitable @columnfractions .15 .70
11688 @item @var{SIZE} @tab (Optional) Shall be a scalar and of type default
11689 @code{INTEGER}, with @code{INTENT(OUT)}. It specifies the minimum size
11690 of the arrays used with the @var{PUT} and @var{GET} arguments.
11691 @item @var{PUT} @tab (Optional) Shall be an array of type default
11692 @code{INTEGER} and rank one. It is @code{INTENT(IN)} and the size of
11693 the array must be larger than or equal to the number returned by the
11694 @var{SIZE} argument.
11695 @item @var{GET} @tab (Optional) Shall be an array of type default
11696 @code{INTEGER} and rank one. It is @code{INTENT(OUT)} and the size
11697 of the array must be larger than or equal to the number returned by
11698 the @var{SIZE} argument.
11701 @item @emph{Example}:
11703 program test_random_seed
11705 integer, allocatable :: seed(:)
11708 call random_seed(size = n)
11710 call random_seed(get=seed)
11712 end program test_random_seed
11715 @item @emph{See also}:
11716 @ref{RANDOM_NUMBER}
11722 @section @code{RANGE} --- Decimal exponent range
11724 @cindex model representation, range
11727 @item @emph{Description}:
11728 @code{RANGE(X)} returns the decimal exponent range in the model of the
11731 @item @emph{Standard}:
11732 Fortran 95 and later
11734 @item @emph{Class}:
11737 @item @emph{Syntax}:
11738 @code{RESULT = RANGE(X)}
11740 @item @emph{Arguments}:
11741 @multitable @columnfractions .15 .70
11742 @item @var{X} @tab Shall be of type @code{INTEGER}, @code{REAL}
11746 @item @emph{Return value}:
11747 The return value is of type @code{INTEGER} and of the default integer
11750 @item @emph{See also}:
11751 @ref{SELECTED_REAL_KIND}, @ref{PRECISION}
11753 @item @emph{Example}:
11754 See @code{PRECISION} for an example.
11760 @section @code{RANK} --- Rank of a data object
11765 @item @emph{Description}:
11766 @code{RANK(A)} returns the rank of a scalar or array data object.
11768 @item @emph{Standard}:
11769 Technical Specification (TS) 29113
11771 @item @emph{Class}:
11774 @item @emph{Syntax}:
11775 @code{RESULT = RANK(A)}
11777 @item @emph{Arguments}:
11778 @multitable @columnfractions .15 .70
11779 @item @var{A} @tab can be of any type
11782 @item @emph{Return value}:
11783 The return value is of type @code{INTEGER} and of the default integer
11784 kind. For arrays, their rank is returned; for scalars zero is returned.
11786 @item @emph{Example}:
11790 real, allocatable :: b(:,:)
11792 print *, rank(a), rank(b) ! Prints: 0 2
11793 end program test_rank
11801 @section @code{REAL} --- Convert to real type
11810 @cindex conversion, to real
11811 @cindex complex numbers, real part
11814 @item @emph{Description}:
11815 @code{REAL(A [, KIND])} converts its argument @var{A} to a real type. The
11816 @code{REALPART} function is provided for compatibility with @command{g77},
11817 and its use is strongly discouraged.
11819 @item @emph{Standard}:
11820 Fortran 77 and later
11822 @item @emph{Class}:
11825 @item @emph{Syntax}:
11826 @multitable @columnfractions .80
11827 @item @code{RESULT = REAL(A [, KIND])}
11828 @item @code{RESULT = REALPART(Z)}
11831 @item @emph{Arguments}:
11832 @multitable @columnfractions .15 .70
11833 @item @var{A} @tab Shall be @code{INTEGER}, @code{REAL}, or
11835 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
11836 expression indicating the kind parameter of the result.
11839 @item @emph{Return value}:
11840 These functions return a @code{REAL} variable or array under
11841 the following rules:
11845 @code{REAL(A)} is converted to a default real type if @var{A} is an
11846 integer or real variable.
11848 @code{REAL(A)} is converted to a real type with the kind type parameter
11849 of @var{A} if @var{A} is a complex variable.
11851 @code{REAL(A, KIND)} is converted to a real type with kind type
11852 parameter @var{KIND} if @var{A} is a complex, integer, or real
11856 @item @emph{Example}:
11859 complex :: x = (1.0, 2.0)
11860 print *, real(x), real(x,8), realpart(x)
11861 end program test_real
11864 @item @emph{Specific names}:
11865 @multitable @columnfractions .20 .20 .20 .25
11866 @item Name @tab Argument @tab Return type @tab Standard
11867 @item @code{FLOAT(A)} @tab @code{INTEGER(4)} @tab @code{REAL(4)} @tab Fortran 77 and later
11868 @item @code{DFLOAT(A)} @tab @code{INTEGER(4)} @tab @code{REAL(8)} @tab GNU extension
11869 @item @code{FLOATI(A)} @tab @code{INTEGER(2)} @tab @code{REAL(4)} @tab GNU extension
11870 @item @code{FLOATJ(A)} @tab @code{INTEGER(4)} @tab @code{REAL(4)} @tab GNU extension
11871 @item @code{FLOATK(A)} @tab @code{INTEGER(8)} @tab @code{REAL(4)} @tab GNU extension
11872 @item @code{SNGL(A)} @tab @code{INTEGER(8)} @tab @code{REAL(4)} @tab Fortran 77 and later
11876 @item @emph{See also}:
11884 @section @code{RENAME} --- Rename a file
11886 @cindex file system, rename file
11889 @item @emph{Description}:
11890 Renames a file from file @var{PATH1} to @var{PATH2}. A null
11891 character (@code{CHAR(0)}) can be used to mark the end of the names in
11892 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
11893 names are ignored. If the @var{STATUS} argument is supplied, it
11894 contains 0 on success or a nonzero error code upon return; see
11897 This intrinsic is provided in both subroutine and function forms;
11898 however, only one form can be used in any given program unit.
11900 @item @emph{Standard}:
11903 @item @emph{Class}:
11904 Subroutine, function
11906 @item @emph{Syntax}:
11907 @multitable @columnfractions .80
11908 @item @code{CALL RENAME(PATH1, PATH2 [, STATUS])}
11909 @item @code{STATUS = RENAME(PATH1, PATH2)}
11912 @item @emph{Arguments}:
11913 @multitable @columnfractions .15 .70
11914 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
11915 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
11916 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
11919 @item @emph{See also}:
11927 @section @code{REPEAT} --- Repeated string concatenation
11929 @cindex string, repeat
11930 @cindex string, concatenate
11933 @item @emph{Description}:
11934 Concatenates @var{NCOPIES} copies of a string.
11936 @item @emph{Standard}:
11937 Fortran 95 and later
11939 @item @emph{Class}:
11940 Transformational function
11942 @item @emph{Syntax}:
11943 @code{RESULT = REPEAT(STRING, NCOPIES)}
11945 @item @emph{Arguments}:
11946 @multitable @columnfractions .15 .70
11947 @item @var{STRING} @tab Shall be scalar and of type @code{CHARACTER}.
11948 @item @var{NCOPIES} @tab Shall be scalar and of type @code{INTEGER}.
11951 @item @emph{Return value}:
11952 A new scalar of type @code{CHARACTER} built up from @var{NCOPIES} copies
11955 @item @emph{Example}:
11957 program test_repeat
11958 write(*,*) repeat("x", 5) ! "xxxxx"
11966 @section @code{RESHAPE} --- Function to reshape an array
11968 @cindex array, change dimensions
11969 @cindex array, transmogrify
11972 @item @emph{Description}:
11973 Reshapes @var{SOURCE} to correspond to @var{SHAPE}. If necessary,
11974 the new array may be padded with elements from @var{PAD} or permuted
11975 as defined by @var{ORDER}.
11977 @item @emph{Standard}:
11978 Fortran 95 and later
11980 @item @emph{Class}:
11981 Transformational function
11983 @item @emph{Syntax}:
11984 @code{RESULT = RESHAPE(SOURCE, SHAPE[, PAD, ORDER])}
11986 @item @emph{Arguments}:
11987 @multitable @columnfractions .15 .70
11988 @item @var{SOURCE} @tab Shall be an array of any type.
11989 @item @var{SHAPE} @tab Shall be of type @code{INTEGER} and an
11990 array of rank one. Its values must be positive or zero.
11991 @item @var{PAD} @tab (Optional) shall be an array of the same
11992 type as @var{SOURCE}.
11993 @item @var{ORDER} @tab (Optional) shall be of type @code{INTEGER}
11994 and an array of the same shape as @var{SHAPE}. Its values shall
11995 be a permutation of the numbers from 1 to n, where n is the size of
11996 @var{SHAPE}. If @var{ORDER} is absent, the natural ordering shall
12000 @item @emph{Return value}:
12001 The result is an array of shape @var{SHAPE} with the same type as
12004 @item @emph{Example}:
12006 PROGRAM test_reshape
12007 INTEGER, DIMENSION(4) :: x
12008 WRITE(*,*) SHAPE(x) ! prints "4"
12009 WRITE(*,*) SHAPE(RESHAPE(x, (/2, 2/))) ! prints "2 2"
12013 @item @emph{See also}:
12020 @section @code{RRSPACING} --- Reciprocal of the relative spacing
12022 @cindex real number, relative spacing
12023 @cindex floating point, relative spacing
12027 @item @emph{Description}:
12028 @code{RRSPACING(X)} returns the reciprocal of the relative spacing of
12029 model numbers near @var{X}.
12031 @item @emph{Standard}:
12032 Fortran 95 and later
12034 @item @emph{Class}:
12037 @item @emph{Syntax}:
12038 @code{RESULT = RRSPACING(X)}
12040 @item @emph{Arguments}:
12041 @multitable @columnfractions .15 .70
12042 @item @var{X} @tab Shall be of type @code{REAL}.
12045 @item @emph{Return value}:
12046 The return value is of the same type and kind as @var{X}.
12047 The value returned is equal to
12048 @code{ABS(FRACTION(X)) * FLOAT(RADIX(X))**DIGITS(X)}.
12050 @item @emph{See also}:
12057 @section @code{RSHIFT} --- Right shift bits
12059 @cindex bits, shift right
12062 @item @emph{Description}:
12063 @code{RSHIFT} returns a value corresponding to @var{I} with all of the
12064 bits shifted right by @var{SHIFT} places. If the absolute value of
12065 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
12066 Bits shifted out from the right end are lost. The fill is arithmetic: the
12067 bits shifted in from the left end are equal to the leftmost bit, which in
12068 two's complement representation is the sign bit.
12070 This function has been superseded by the @code{SHIFTA} intrinsic, which
12071 is standard in Fortran 2008 and later.
12073 @item @emph{Standard}:
12076 @item @emph{Class}:
12079 @item @emph{Syntax}:
12080 @code{RESULT = RSHIFT(I, SHIFT)}
12082 @item @emph{Arguments}:
12083 @multitable @columnfractions .15 .70
12084 @item @var{I} @tab The type shall be @code{INTEGER}.
12085 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
12088 @item @emph{Return value}:
12089 The return value is of type @code{INTEGER} and of the same kind as
12092 @item @emph{See also}:
12093 @ref{ISHFT}, @ref{ISHFTC}, @ref{LSHIFT}, @ref{SHIFTA}, @ref{SHIFTR},
12101 @section @code{SAME_TYPE_AS} --- Query dynamic types for equality
12102 @fnindex SAME_TYPE_AS
12105 @item @emph{Description}:
12106 Query dynamic types for equality.
12108 @item @emph{Standard}:
12109 Fortran 2003 and later
12111 @item @emph{Class}:
12114 @item @emph{Syntax}:
12115 @code{RESULT = SAME_TYPE_AS(A, B)}
12117 @item @emph{Arguments}:
12118 @multitable @columnfractions .15 .70
12119 @item @var{A} @tab Shall be an object of extensible declared type or
12120 unlimited polymorphic.
12121 @item @var{B} @tab Shall be an object of extensible declared type or
12122 unlimited polymorphic.
12125 @item @emph{Return value}:
12126 The return value is a scalar of type default logical. It is true if and
12127 only if the dynamic type of A is the same as the dynamic type of B.
12129 @item @emph{See also}:
12130 @ref{EXTENDS_TYPE_OF}
12137 @section @code{SCALE} --- Scale a real value
12139 @cindex real number, scale
12140 @cindex floating point, scale
12143 @item @emph{Description}:
12144 @code{SCALE(X,I)} returns @code{X * RADIX(X)**I}.
12146 @item @emph{Standard}:
12147 Fortran 95 and later
12149 @item @emph{Class}:
12152 @item @emph{Syntax}:
12153 @code{RESULT = SCALE(X, I)}
12155 @item @emph{Arguments}:
12156 @multitable @columnfractions .15 .70
12157 @item @var{X} @tab The type of the argument shall be a @code{REAL}.
12158 @item @var{I} @tab The type of the argument shall be a @code{INTEGER}.
12161 @item @emph{Return value}:
12162 The return value is of the same type and kind as @var{X}.
12163 Its value is @code{X * RADIX(X)**I}.
12165 @item @emph{Example}:
12168 real :: x = 178.1387e-4
12170 print *, scale(x,i), x*radix(x)**i
12171 end program test_scale
12179 @section @code{SCAN} --- Scan a string for the presence of a set of characters
12181 @cindex string, find subset
12184 @item @emph{Description}:
12185 Scans a @var{STRING} for any of the characters in a @var{SET}
12188 If @var{BACK} is either absent or equals @code{FALSE}, this function
12189 returns the position of the leftmost character of @var{STRING} that is
12190 in @var{SET}. If @var{BACK} equals @code{TRUE}, the rightmost position
12191 is returned. If no character of @var{SET} is found in @var{STRING}, the
12194 @item @emph{Standard}:
12195 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
12197 @item @emph{Class}:
12200 @item @emph{Syntax}:
12201 @code{RESULT = SCAN(STRING, SET[, BACK [, KIND]])}
12203 @item @emph{Arguments}:
12204 @multitable @columnfractions .15 .70
12205 @item @var{STRING} @tab Shall be of type @code{CHARACTER}.
12206 @item @var{SET} @tab Shall be of type @code{CHARACTER}.
12207 @item @var{BACK} @tab (Optional) shall be of type @code{LOGICAL}.
12208 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
12209 expression indicating the kind parameter of the result.
12212 @item @emph{Return value}:
12213 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
12214 @var{KIND} is absent, the return value is of default integer kind.
12216 @item @emph{Example}:
12219 WRITE(*,*) SCAN("FORTRAN", "AO") ! 2, found 'O'
12220 WRITE(*,*) SCAN("FORTRAN", "AO", .TRUE.) ! 6, found 'A'
12221 WRITE(*,*) SCAN("FORTRAN", "C++") ! 0, found none
12225 @item @emph{See also}:
12226 @ref{INDEX intrinsic}, @ref{VERIFY}
12232 @section @code{SECNDS} --- Time function
12234 @cindex time, elapsed
12235 @cindex elapsed time
12238 @item @emph{Description}:
12239 @code{SECNDS(X)} gets the time in seconds from the real-time system clock.
12240 @var{X} is a reference time, also in seconds. If this is zero, the time in
12241 seconds from midnight is returned. This function is non-standard and its
12242 use is discouraged.
12244 @item @emph{Standard}:
12247 @item @emph{Class}:
12250 @item @emph{Syntax}:
12251 @code{RESULT = SECNDS (X)}
12253 @item @emph{Arguments}:
12254 @multitable @columnfractions .15 .70
12255 @item @var{T} @tab Shall be of type @code{REAL(4)}.
12256 @item @var{X} @tab Shall be of type @code{REAL(4)}.
12259 @item @emph{Return value}:
12262 @item @emph{Example}:
12264 program test_secnds
12267 print *, secnds (0.0) ! seconds since midnight
12268 t1 = secnds (0.0) ! reference time
12269 do i = 1, 10000000 ! do something
12271 t2 = secnds (t1) ! elapsed time
12272 print *, "Something took ", t2, " seconds."
12273 end program test_secnds
12280 @section @code{SECOND} --- CPU time function
12282 @cindex time, elapsed
12283 @cindex elapsed time
12286 @item @emph{Description}:
12287 Returns a @code{REAL(4)} value representing the elapsed CPU time in
12288 seconds. This provides the same functionality as the standard
12289 @code{CPU_TIME} intrinsic, and is only included for backwards
12292 This intrinsic is provided in both subroutine and function forms;
12293 however, only one form can be used in any given program unit.
12295 @item @emph{Standard}:
12298 @item @emph{Class}:
12299 Subroutine, function
12301 @item @emph{Syntax}:
12302 @multitable @columnfractions .80
12303 @item @code{CALL SECOND(TIME)}
12304 @item @code{TIME = SECOND()}
12307 @item @emph{Arguments}:
12308 @multitable @columnfractions .15 .70
12309 @item @var{TIME} @tab Shall be of type @code{REAL(4)}.
12312 @item @emph{Return value}:
12313 In either syntax, @var{TIME} is set to the process's current runtime in
12316 @item @emph{See also}:
12323 @node SELECTED_CHAR_KIND
12324 @section @code{SELECTED_CHAR_KIND} --- Choose character kind
12325 @fnindex SELECTED_CHAR_KIND
12326 @cindex character kind
12327 @cindex kind, character
12330 @item @emph{Description}:
12332 @code{SELECTED_CHAR_KIND(NAME)} returns the kind value for the character
12333 set named @var{NAME}, if a character set with such a name is supported,
12334 or @math{-1} otherwise. Currently, supported character sets include
12335 ``ASCII'' and ``DEFAULT'', which are equivalent, and ``ISO_10646''
12336 (Universal Character Set, UCS-4) which is commonly known as Unicode.
12338 @item @emph{Standard}:
12339 Fortran 2003 and later
12341 @item @emph{Class}:
12342 Transformational function
12344 @item @emph{Syntax}:
12345 @code{RESULT = SELECTED_CHAR_KIND(NAME)}
12347 @item @emph{Arguments}:
12348 @multitable @columnfractions .15 .70
12349 @item @var{NAME} @tab Shall be a scalar and of the default character type.
12352 @item @emph{Example}:
12354 program character_kind
12355 use iso_fortran_env
12357 integer, parameter :: ascii = selected_char_kind ("ascii")
12358 integer, parameter :: ucs4 = selected_char_kind ('ISO_10646')
12360 character(kind=ascii, len=26) :: alphabet
12361 character(kind=ucs4, len=30) :: hello_world
12363 alphabet = ascii_"abcdefghijklmnopqrstuvwxyz"
12364 hello_world = ucs4_'Hello World and Ni Hao -- ' &
12365 // char (int (z'4F60'), ucs4) &
12366 // char (int (z'597D'), ucs4)
12368 write (*,*) alphabet
12370 open (output_unit, encoding='UTF-8')
12371 write (*,*) trim (hello_world)
12372 end program character_kind
12378 @node SELECTED_INT_KIND
12379 @section @code{SELECTED_INT_KIND} --- Choose integer kind
12380 @fnindex SELECTED_INT_KIND
12381 @cindex integer kind
12382 @cindex kind, integer
12385 @item @emph{Description}:
12386 @code{SELECTED_INT_KIND(R)} return the kind value of the smallest integer
12387 type that can represent all values ranging from @math{-10^R} (exclusive)
12388 to @math{10^R} (exclusive). If there is no integer kind that accommodates
12389 this range, @code{SELECTED_INT_KIND} returns @math{-1}.
12391 @item @emph{Standard}:
12392 Fortran 95 and later
12394 @item @emph{Class}:
12395 Transformational function
12397 @item @emph{Syntax}:
12398 @code{RESULT = SELECTED_INT_KIND(R)}
12400 @item @emph{Arguments}:
12401 @multitable @columnfractions .15 .70
12402 @item @var{R} @tab Shall be a scalar and of type @code{INTEGER}.
12405 @item @emph{Example}:
12407 program large_integers
12408 integer,parameter :: k5 = selected_int_kind(5)
12409 integer,parameter :: k15 = selected_int_kind(15)
12410 integer(kind=k5) :: i5
12411 integer(kind=k15) :: i15
12413 print *, huge(i5), huge(i15)
12415 ! The following inequalities are always true
12416 print *, huge(i5) >= 10_k5**5-1
12417 print *, huge(i15) >= 10_k15**15-1
12418 end program large_integers
12424 @node SELECTED_REAL_KIND
12425 @section @code{SELECTED_REAL_KIND} --- Choose real kind
12426 @fnindex SELECTED_REAL_KIND
12429 @cindex radix, real
12432 @item @emph{Description}:
12433 @code{SELECTED_REAL_KIND(P,R)} returns the kind value of a real data type
12434 with decimal precision of at least @code{P} digits, exponent range of
12435 at least @code{R}, and with a radix of @code{RADIX}.
12437 @item @emph{Standard}:
12438 Fortran 95 and later, with @code{RADIX} Fortran 2008 or later
12440 @item @emph{Class}:
12441 Transformational function
12443 @item @emph{Syntax}:
12444 @code{RESULT = SELECTED_REAL_KIND([P, R, RADIX])}
12446 @item @emph{Arguments}:
12447 @multitable @columnfractions .15 .70
12448 @item @var{P} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
12449 @item @var{R} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
12450 @item @var{RADIX} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
12452 Before Fortran 2008, at least one of the arguments @var{R} or @var{P} shall
12453 be present; since Fortran 2008, they are assumed to be zero if absent.
12455 @item @emph{Return value}:
12457 @code{SELECTED_REAL_KIND} returns the value of the kind type parameter of
12458 a real data type with decimal precision of at least @code{P} digits, a
12459 decimal exponent range of at least @code{R}, and with the requested
12460 @code{RADIX}. If the @code{RADIX} parameter is absent, real kinds with
12461 any radix can be returned. If more than one real data type meet the
12462 criteria, the kind of the data type with the smallest decimal precision
12463 is returned. If no real data type matches the criteria, the result is
12465 @item -1 if the processor does not support a real data type with a
12466 precision greater than or equal to @code{P}, but the @code{R} and
12467 @code{RADIX} requirements can be fulfilled
12468 @item -2 if the processor does not support a real type with an exponent
12469 range greater than or equal to @code{R}, but @code{P} and @code{RADIX}
12471 @item -3 if @code{RADIX} but not @code{P} and @code{R} requirements
12473 @item -4 if @code{RADIX} and either @code{P} or @code{R} requirements
12475 @item -5 if there is no real type with the given @code{RADIX}
12478 @item @emph{See also}:
12479 @ref{PRECISION}, @ref{RANGE}, @ref{RADIX}
12481 @item @emph{Example}:
12484 integer,parameter :: p6 = selected_real_kind(6)
12485 integer,parameter :: p10r100 = selected_real_kind(10,100)
12486 integer,parameter :: r400 = selected_real_kind(r=400)
12488 real(kind=p10r100) :: y
12489 real(kind=r400) :: z
12491 print *, precision(x), range(x)
12492 print *, precision(y), range(y)
12493 print *, precision(z), range(z)
12494 end program real_kinds
12501 @section @code{SET_EXPONENT} --- Set the exponent of the model
12502 @fnindex SET_EXPONENT
12503 @cindex real number, set exponent
12504 @cindex floating point, set exponent
12507 @item @emph{Description}:
12508 @code{SET_EXPONENT(X, I)} returns the real number whose fractional part
12509 is that that of @var{X} and whose exponent part is @var{I}.
12511 @item @emph{Standard}:
12512 Fortran 95 and later
12514 @item @emph{Class}:
12517 @item @emph{Syntax}:
12518 @code{RESULT = SET_EXPONENT(X, I)}
12520 @item @emph{Arguments}:
12521 @multitable @columnfractions .15 .70
12522 @item @var{X} @tab Shall be of type @code{REAL}.
12523 @item @var{I} @tab Shall be of type @code{INTEGER}.
12526 @item @emph{Return value}:
12527 The return value is of the same type and kind as @var{X}.
12528 The real number whose fractional part
12529 is that that of @var{X} and whose exponent part if @var{I} is returned;
12530 it is @code{FRACTION(X) * RADIX(X)**I}.
12532 @item @emph{Example}:
12534 PROGRAM test_setexp
12535 REAL :: x = 178.1387e-4
12537 PRINT *, SET_EXPONENT(x, i), FRACTION(x) * RADIX(x)**i
12546 @section @code{SHAPE} --- Determine the shape of an array
12548 @cindex array, shape
12551 @item @emph{Description}:
12552 Determines the shape of an array.
12554 @item @emph{Standard}:
12555 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
12557 @item @emph{Class}:
12560 @item @emph{Syntax}:
12561 @code{RESULT = SHAPE(SOURCE [, KIND])}
12563 @item @emph{Arguments}:
12564 @multitable @columnfractions .15 .70
12565 @item @var{SOURCE} @tab Shall be an array or scalar of any type.
12566 If @var{SOURCE} is a pointer it must be associated and allocatable
12567 arrays must be allocated.
12568 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
12569 expression indicating the kind parameter of the result.
12572 @item @emph{Return value}:
12573 An @code{INTEGER} array of rank one with as many elements as @var{SOURCE}
12574 has dimensions. The elements of the resulting array correspond to the extend
12575 of @var{SOURCE} along the respective dimensions. If @var{SOURCE} is a scalar,
12576 the result is the rank one array of size zero. If @var{KIND} is absent, the
12577 return value has the default integer kind otherwise the specified kind.
12579 @item @emph{Example}:
12582 INTEGER, DIMENSION(-1:1, -1:2) :: A
12583 WRITE(*,*) SHAPE(A) ! (/ 3, 4 /)
12584 WRITE(*,*) SIZE(SHAPE(42)) ! (/ /)
12588 @item @emph{See also}:
12589 @ref{RESHAPE}, @ref{SIZE}
12595 @section @code{SHIFTA} --- Right shift with fill
12597 @cindex bits, shift right
12598 @cindex shift, right with fill
12601 @item @emph{Description}:
12602 @code{SHIFTA} returns a value corresponding to @var{I} with all of the
12603 bits shifted right by @var{SHIFT} places. If the absolute value of
12604 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
12605 Bits shifted out from the right end are lost. The fill is arithmetic: the
12606 bits shifted in from the left end are equal to the leftmost bit, which in
12607 two's complement representation is the sign bit.
12609 @item @emph{Standard}:
12610 Fortran 2008 and later
12612 @item @emph{Class}:
12615 @item @emph{Syntax}:
12616 @code{RESULT = SHIFTA(I, SHIFT)}
12618 @item @emph{Arguments}:
12619 @multitable @columnfractions .15 .70
12620 @item @var{I} @tab The type shall be @code{INTEGER}.
12621 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
12624 @item @emph{Return value}:
12625 The return value is of type @code{INTEGER} and of the same kind as
12628 @item @emph{See also}:
12629 @ref{SHIFTL}, @ref{SHIFTR}
12635 @section @code{SHIFTL} --- Left shift
12637 @cindex bits, shift left
12638 @cindex shift, left
12641 @item @emph{Description}:
12642 @code{SHIFTL} returns a value corresponding to @var{I} with all of the
12643 bits shifted left by @var{SHIFT} places. If the absolute value of
12644 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
12645 Bits shifted out from the left end are lost, and bits shifted in from
12646 the right end are set to 0.
12648 @item @emph{Standard}:
12649 Fortran 2008 and later
12651 @item @emph{Class}:
12654 @item @emph{Syntax}:
12655 @code{RESULT = SHIFTL(I, SHIFT)}
12657 @item @emph{Arguments}:
12658 @multitable @columnfractions .15 .70
12659 @item @var{I} @tab The type shall be @code{INTEGER}.
12660 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
12663 @item @emph{Return value}:
12664 The return value is of type @code{INTEGER} and of the same kind as
12667 @item @emph{See also}:
12668 @ref{SHIFTA}, @ref{SHIFTR}
12674 @section @code{SHIFTR} --- Right shift
12676 @cindex bits, shift right
12677 @cindex shift, right
12680 @item @emph{Description}:
12681 @code{SHIFTR} returns a value corresponding to @var{I} with all of the
12682 bits shifted right by @var{SHIFT} places. If the absolute value of
12683 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
12684 Bits shifted out from the right end are lost, and bits shifted in from
12685 the left end are set to 0.
12687 @item @emph{Standard}:
12688 Fortran 2008 and later
12690 @item @emph{Class}:
12693 @item @emph{Syntax}:
12694 @code{RESULT = SHIFTR(I, SHIFT)}
12696 @item @emph{Arguments}:
12697 @multitable @columnfractions .15 .70
12698 @item @var{I} @tab The type shall be @code{INTEGER}.
12699 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
12702 @item @emph{Return value}:
12703 The return value is of type @code{INTEGER} and of the same kind as
12706 @item @emph{See also}:
12707 @ref{SHIFTA}, @ref{SHIFTL}
12713 @section @code{SIGN} --- Sign copying function
12717 @cindex sign copying
12720 @item @emph{Description}:
12721 @code{SIGN(A,B)} returns the value of @var{A} with the sign of @var{B}.
12723 @item @emph{Standard}:
12724 Fortran 77 and later
12726 @item @emph{Class}:
12729 @item @emph{Syntax}:
12730 @code{RESULT = SIGN(A, B)}
12732 @item @emph{Arguments}:
12733 @multitable @columnfractions .15 .70
12734 @item @var{A} @tab Shall be of type @code{INTEGER} or @code{REAL}
12735 @item @var{B} @tab Shall be of the same type and kind as @var{A}
12738 @item @emph{Return value}:
12739 The kind of the return value is that of @var{A} and @var{B}.
12740 If @math{B\ge 0} then the result is @code{ABS(A)}, else
12741 it is @code{-ABS(A)}.
12743 @item @emph{Example}:
12746 print *, sign(-12,1)
12747 print *, sign(-12,0)
12748 print *, sign(-12,-1)
12750 print *, sign(-12.,1.)
12751 print *, sign(-12.,0.)
12752 print *, sign(-12.,-1.)
12753 end program test_sign
12756 @item @emph{Specific names}:
12757 @multitable @columnfractions .20 .20 .20 .25
12758 @item Name @tab Arguments @tab Return type @tab Standard
12759 @item @code{SIGN(A,B)} @tab @code{REAL(4) A, B} @tab @code{REAL(4)} @tab f77, gnu
12760 @item @code{ISIGN(A,B)} @tab @code{INTEGER(4) A, B} @tab @code{INTEGER(4)} @tab f77, gnu
12761 @item @code{DSIGN(A,B)} @tab @code{REAL(8) A, B} @tab @code{REAL(8)} @tab f77, gnu
12768 @section @code{SIGNAL} --- Signal handling subroutine (or function)
12770 @cindex system, signal handling
12773 @item @emph{Description}:
12774 @code{SIGNAL(NUMBER, HANDLER [, STATUS])} causes external subroutine
12775 @var{HANDLER} to be executed with a single integer argument when signal
12776 @var{NUMBER} occurs. If @var{HANDLER} is an integer, it can be used to
12777 turn off handling of signal @var{NUMBER} or revert to its default
12778 action. See @code{signal(2)}.
12780 If @code{SIGNAL} is called as a subroutine and the @var{STATUS} argument
12781 is supplied, it is set to the value returned by @code{signal(2)}.
12783 @item @emph{Standard}:
12786 @item @emph{Class}:
12787 Subroutine, function
12789 @item @emph{Syntax}:
12790 @multitable @columnfractions .80
12791 @item @code{CALL SIGNAL(NUMBER, HANDLER [, STATUS])}
12792 @item @code{STATUS = SIGNAL(NUMBER, HANDLER)}
12795 @item @emph{Arguments}:
12796 @multitable @columnfractions .15 .70
12797 @item @var{NUMBER} @tab Shall be a scalar integer, with @code{INTENT(IN)}
12798 @item @var{HANDLER}@tab Signal handler (@code{INTEGER FUNCTION} or
12799 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar.
12800 @code{INTEGER}. It is @code{INTENT(IN)}.
12801 @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
12802 integer. It has @code{INTENT(OUT)}.
12804 @c TODO: What should the interface of the handler be? Does it take arguments?
12806 @item @emph{Return value}:
12807 The @code{SIGNAL} function returns the value returned by @code{signal(2)}.
12809 @item @emph{Example}:
12811 program test_signal
12813 external handler_print
12815 call signal (12, handler_print)
12816 call signal (10, 1)
12819 end program test_signal
12826 @section @code{SIN} --- Sine function
12832 @cindex trigonometric function, sine
12836 @item @emph{Description}:
12837 @code{SIN(X)} computes the sine of @var{X}.
12839 @item @emph{Standard}:
12840 Fortran 77 and later
12842 @item @emph{Class}:
12845 @item @emph{Syntax}:
12846 @code{RESULT = SIN(X)}
12848 @item @emph{Arguments}:
12849 @multitable @columnfractions .15 .70
12850 @item @var{X} @tab The type shall be @code{REAL} or
12854 @item @emph{Return value}:
12855 The return value has same type and kind as @var{X}.
12857 @item @emph{Example}:
12862 end program test_sin
12865 @item @emph{Specific names}:
12866 @multitable @columnfractions .20 .20 .20 .25
12867 @item Name @tab Argument @tab Return type @tab Standard
12868 @item @code{SIN(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab f77, gnu
12869 @item @code{DSIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
12870 @item @code{CSIN(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab f95, gnu
12871 @item @code{ZSIN(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
12872 @item @code{CDSIN(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
12875 @item @emph{See also}:
12876 Inverse function: @ref{ASIN}
12877 Degrees function: @ref{SIND}
12883 @section @code{SIND} --- Sine function, degrees
12889 @cindex trigonometric function, sine, degrees
12890 @cindex sine, degrees
12893 @item @emph{Description}:
12894 @code{SIND(X)} computes the sine of @var{X} in degrees.
12896 This function is for compatibility only and should be avoided in favor of
12897 standard constructs wherever possible.
12899 @item @emph{Standard}:
12900 GNU Extension, enabled with @option{-fdec-math}.
12902 @item @emph{Class}:
12905 @item @emph{Syntax}:
12906 @code{RESULT = SIND(X)}
12908 @item @emph{Arguments}:
12909 @multitable @columnfractions .15 .70
12910 @item @var{X} @tab The type shall be @code{REAL} or
12914 @item @emph{Return value}:
12915 The return value has same type and kind as @var{X}, and its value is in degrees.
12917 @item @emph{Example}:
12922 end program test_sind
12925 @item @emph{Specific names}:
12926 @multitable @columnfractions .20 .20 .20 .25
12927 @item Name @tab Argument @tab Return type @tab Standard
12928 @item @code{SIND(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU Extension
12929 @item @code{DSIND(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU Extension
12930 @item @code{CSIND(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab GNU Extension
12931 @item @code{ZSIND(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU Extension
12932 @item @code{CDSIND(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU Extension
12935 @item @emph{See also}:
12936 Inverse function: @ref{ASIND}
12937 Radians function: @ref{SIN}
12944 @section @code{SINH} --- Hyperbolic sine function
12947 @cindex hyperbolic sine
12948 @cindex hyperbolic function, sine
12949 @cindex sine, hyperbolic
12952 @item @emph{Description}:
12953 @code{SINH(X)} computes the hyperbolic sine of @var{X}.
12955 @item @emph{Standard}:
12956 Fortran 95 and later, for a complex argument Fortran 2008 or later
12958 @item @emph{Class}:
12961 @item @emph{Syntax}:
12962 @code{RESULT = SINH(X)}
12964 @item @emph{Arguments}:
12965 @multitable @columnfractions .15 .70
12966 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
12969 @item @emph{Return value}:
12970 The return value has same type and kind as @var{X}.
12972 @item @emph{Example}:
12975 real(8) :: x = - 1.0_8
12977 end program test_sinh
12980 @item @emph{Specific names}:
12981 @multitable @columnfractions .20 .20 .20 .25
12982 @item Name @tab Argument @tab Return type @tab Standard
12983 @item @code{SINH(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 95 and later
12984 @item @code{DSINH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 95 and later
12987 @item @emph{See also}:
12994 @section @code{SIZE} --- Determine the size of an array
12996 @cindex array, size
12997 @cindex array, number of elements
12998 @cindex array, count elements
13001 @item @emph{Description}:
13002 Determine the extent of @var{ARRAY} along a specified dimension @var{DIM},
13003 or the total number of elements in @var{ARRAY} if @var{DIM} is absent.
13005 @item @emph{Standard}:
13006 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
13008 @item @emph{Class}:
13011 @item @emph{Syntax}:
13012 @code{RESULT = SIZE(ARRAY[, DIM [, KIND]])}
13014 @item @emph{Arguments}:
13015 @multitable @columnfractions .15 .70
13016 @item @var{ARRAY} @tab Shall be an array of any type. If @var{ARRAY} is
13017 a pointer it must be associated and allocatable arrays must be allocated.
13018 @item @var{DIM} @tab (Optional) shall be a scalar of type @code{INTEGER}
13019 and its value shall be in the range from 1 to n, where n equals the rank
13021 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
13022 expression indicating the kind parameter of the result.
13025 @item @emph{Return value}:
13026 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
13027 @var{KIND} is absent, the return value is of default integer kind.
13029 @item @emph{Example}:
13032 WRITE(*,*) SIZE((/ 1, 2 /)) ! 2
13036 @item @emph{See also}:
13037 @ref{SHAPE}, @ref{RESHAPE}
13042 @section @code{SIZEOF} --- Size in bytes of an expression
13044 @cindex expression size
13045 @cindex size of an expression
13048 @item @emph{Description}:
13049 @code{SIZEOF(X)} calculates the number of bytes of storage the
13050 expression @code{X} occupies.
13052 @item @emph{Standard}:
13055 @item @emph{Class}:
13058 @item @emph{Syntax}:
13059 @code{N = SIZEOF(X)}
13061 @item @emph{Arguments}:
13062 @multitable @columnfractions .15 .70
13063 @item @var{X} @tab The argument shall be of any type, rank or shape.
13066 @item @emph{Return value}:
13067 The return value is of type integer and of the system-dependent kind
13068 @var{C_SIZE_T} (from the @var{ISO_C_BINDING} module). Its value is the
13069 number of bytes occupied by the argument. If the argument has the
13070 @code{POINTER} attribute, the number of bytes of the storage area pointed
13071 to is returned. If the argument is of a derived type with @code{POINTER}
13072 or @code{ALLOCATABLE} components, the return value does not account for
13073 the sizes of the data pointed to by these components. If the argument is
13074 polymorphic, the size according to the dynamic type is returned. The argument
13075 may not be a procedure or procedure pointer. Note that the code assumes for
13076 arrays that those are contiguous; for contiguous arrays, it returns the
13077 storage or an array element multiplied by the size of the array.
13079 @item @emph{Example}:
13083 print *, (sizeof(s)/sizeof(r) == 5)
13086 The example will print @code{.TRUE.} unless you are using a platform
13087 where default @code{REAL} variables are unusually padded.
13089 @item @emph{See also}:
13090 @ref{C_SIZEOF}, @ref{STORAGE_SIZE}
13095 @section @code{SLEEP} --- Sleep for the specified number of seconds
13097 @cindex delayed execution
13100 @item @emph{Description}:
13101 Calling this subroutine causes the process to pause for @var{SECONDS} seconds.
13103 @item @emph{Standard}:
13106 @item @emph{Class}:
13109 @item @emph{Syntax}:
13110 @code{CALL SLEEP(SECONDS)}
13112 @item @emph{Arguments}:
13113 @multitable @columnfractions .15 .70
13114 @item @var{SECONDS} @tab The type shall be of default @code{INTEGER}.
13117 @item @emph{Example}:
13128 @section @code{SPACING} --- Smallest distance between two numbers of a given type
13130 @cindex real number, relative spacing
13131 @cindex floating point, relative spacing
13134 @item @emph{Description}:
13135 Determines the distance between the argument @var{X} and the nearest
13136 adjacent number of the same type.
13138 @item @emph{Standard}:
13139 Fortran 95 and later
13141 @item @emph{Class}:
13144 @item @emph{Syntax}:
13145 @code{RESULT = SPACING(X)}
13147 @item @emph{Arguments}:
13148 @multitable @columnfractions .15 .70
13149 @item @var{X} @tab Shall be of type @code{REAL}.
13152 @item @emph{Return value}:
13153 The result is of the same type as the input argument @var{X}.
13155 @item @emph{Example}:
13157 PROGRAM test_spacing
13158 INTEGER, PARAMETER :: SGL = SELECTED_REAL_KIND(p=6, r=37)
13159 INTEGER, PARAMETER :: DBL = SELECTED_REAL_KIND(p=13, r=200)
13161 WRITE(*,*) spacing(1.0_SGL) ! "1.1920929E-07" on i686
13162 WRITE(*,*) spacing(1.0_DBL) ! "2.220446049250313E-016" on i686
13166 @item @emph{See also}:
13173 @section @code{SPREAD} --- Add a dimension to an array
13175 @cindex array, increase dimension
13176 @cindex array, duplicate elements
13177 @cindex array, duplicate dimensions
13180 @item @emph{Description}:
13181 Replicates a @var{SOURCE} array @var{NCOPIES} times along a specified
13182 dimension @var{DIM}.
13184 @item @emph{Standard}:
13185 Fortran 95 and later
13187 @item @emph{Class}:
13188 Transformational function
13190 @item @emph{Syntax}:
13191 @code{RESULT = SPREAD(SOURCE, DIM, NCOPIES)}
13193 @item @emph{Arguments}:
13194 @multitable @columnfractions .15 .70
13195 @item @var{SOURCE} @tab Shall be a scalar or an array of any type and
13196 a rank less than seven.
13197 @item @var{DIM} @tab Shall be a scalar of type @code{INTEGER} with a
13198 value in the range from 1 to n+1, where n equals the rank of @var{SOURCE}.
13199 @item @var{NCOPIES} @tab Shall be a scalar of type @code{INTEGER}.
13202 @item @emph{Return value}:
13203 The result is an array of the same type as @var{SOURCE} and has rank n+1
13204 where n equals the rank of @var{SOURCE}.
13206 @item @emph{Example}:
13208 PROGRAM test_spread
13209 INTEGER :: a = 1, b(2) = (/ 1, 2 /)
13210 WRITE(*,*) SPREAD(A, 1, 2) ! "1 1"
13211 WRITE(*,*) SPREAD(B, 1, 2) ! "1 1 2 2"
13215 @item @emph{See also}:
13222 @section @code{SQRT} --- Square-root function
13229 @cindex square-root
13232 @item @emph{Description}:
13233 @code{SQRT(X)} computes the square root of @var{X}.
13235 @item @emph{Standard}:
13236 Fortran 77 and later
13238 @item @emph{Class}:
13241 @item @emph{Syntax}:
13242 @code{RESULT = SQRT(X)}
13244 @item @emph{Arguments}:
13245 @multitable @columnfractions .15 .70
13246 @item @var{X} @tab The type shall be @code{REAL} or
13250 @item @emph{Return value}:
13251 The return value is of type @code{REAL} or @code{COMPLEX}.
13252 The kind type parameter is the same as @var{X}.
13254 @item @emph{Example}:
13257 real(8) :: x = 2.0_8
13258 complex :: z = (1.0, 2.0)
13261 end program test_sqrt
13264 @item @emph{Specific names}:
13265 @multitable @columnfractions .20 .20 .20 .25
13266 @item Name @tab Argument @tab Return type @tab Standard
13267 @item @code{SQRT(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 95 and later
13268 @item @code{DSQRT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 95 and later
13269 @item @code{CSQRT(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab Fortran 95 and later
13270 @item @code{ZSQRT(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
13271 @item @code{CDSQRT(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
13278 @section @code{SRAND} --- Reinitialize the random number generator
13280 @cindex random number generation, seeding
13281 @cindex seeding a random number generator
13284 @item @emph{Description}:
13285 @code{SRAND} reinitializes the pseudo-random number generator
13286 called by @code{RAND} and @code{IRAND}. The new seed used by the
13287 generator is specified by the required argument @var{SEED}.
13289 @item @emph{Standard}:
13292 @item @emph{Class}:
13295 @item @emph{Syntax}:
13296 @code{CALL SRAND(SEED)}
13298 @item @emph{Arguments}:
13299 @multitable @columnfractions .15 .70
13300 @item @var{SEED} @tab Shall be a scalar @code{INTEGER(kind=4)}.
13303 @item @emph{Return value}:
13304 Does not return anything.
13306 @item @emph{Example}:
13307 See @code{RAND} and @code{IRAND} for examples.
13309 @item @emph{Notes}:
13310 The Fortran standard specifies the intrinsic subroutines
13311 @code{RANDOM_SEED} to initialize the pseudo-random number
13312 generator and @code{RANDOM_NUMBER} to generate pseudo-random numbers.
13313 These subroutines should be used in new codes.
13315 Please note that in GNU Fortran, these two sets of intrinsics (@code{RAND},
13316 @code{IRAND} and @code{SRAND} on the one hand, @code{RANDOM_NUMBER} and
13317 @code{RANDOM_SEED} on the other hand) access two independent
13318 pseudo-random number generators.
13320 @item @emph{See also}:
13321 @ref{RAND}, @ref{RANDOM_SEED}, @ref{RANDOM_NUMBER}
13328 @section @code{STAT} --- Get file status
13330 @cindex file system, file status
13333 @item @emph{Description}:
13334 This function returns information about a file. No permissions are required on
13335 the file itself, but execute (search) permission is required on all of the
13336 directories in path that lead to the file.
13338 The elements that are obtained and stored in the array @code{VALUES}:
13339 @multitable @columnfractions .15 .70
13340 @item @code{VALUES(1)} @tab Device ID
13341 @item @code{VALUES(2)} @tab Inode number
13342 @item @code{VALUES(3)} @tab File mode
13343 @item @code{VALUES(4)} @tab Number of links
13344 @item @code{VALUES(5)} @tab Owner's uid
13345 @item @code{VALUES(6)} @tab Owner's gid
13346 @item @code{VALUES(7)} @tab ID of device containing directory entry for file (0 if not available)
13347 @item @code{VALUES(8)} @tab File size (bytes)
13348 @item @code{VALUES(9)} @tab Last access time
13349 @item @code{VALUES(10)} @tab Last modification time
13350 @item @code{VALUES(11)} @tab Last file status change time
13351 @item @code{VALUES(12)} @tab Preferred I/O block size (-1 if not available)
13352 @item @code{VALUES(13)} @tab Number of blocks allocated (-1 if not available)
13355 Not all these elements are relevant on all systems.
13356 If an element is not relevant, it is returned as 0.
13358 This intrinsic is provided in both subroutine and function forms; however,
13359 only one form can be used in any given program unit.
13361 @item @emph{Standard}:
13364 @item @emph{Class}:
13365 Subroutine, function
13367 @item @emph{Syntax}:
13368 @multitable @columnfractions .80
13369 @item @code{CALL STAT(NAME, VALUES [, STATUS])}
13370 @item @code{STATUS = STAT(NAME, VALUES)}
13373 @item @emph{Arguments}:
13374 @multitable @columnfractions .15 .70
13375 @item @var{NAME} @tab The type shall be @code{CHARACTER}, of the
13376 default kind and a valid path within the file system.
13377 @item @var{VALUES} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
13378 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0
13379 on success and a system specific error code otherwise.
13382 @item @emph{Example}:
13385 INTEGER, DIMENSION(13) :: buff
13388 CALL STAT("/etc/passwd", buff, status)
13390 IF (status == 0) THEN
13391 WRITE (*, FMT="('Device ID:', T30, I19)") buff(1)
13392 WRITE (*, FMT="('Inode number:', T30, I19)") buff(2)
13393 WRITE (*, FMT="('File mode (octal):', T30, O19)") buff(3)
13394 WRITE (*, FMT="('Number of links:', T30, I19)") buff(4)
13395 WRITE (*, FMT="('Owner''s uid:', T30, I19)") buff(5)
13396 WRITE (*, FMT="('Owner''s gid:', T30, I19)") buff(6)
13397 WRITE (*, FMT="('Device where located:', T30, I19)") buff(7)
13398 WRITE (*, FMT="('File size:', T30, I19)") buff(8)
13399 WRITE (*, FMT="('Last access time:', T30, A19)") CTIME(buff(9))
13400 WRITE (*, FMT="('Last modification time', T30, A19)") CTIME(buff(10))
13401 WRITE (*, FMT="('Last status change time:', T30, A19)") CTIME(buff(11))
13402 WRITE (*, FMT="('Preferred block size:', T30, I19)") buff(12)
13403 WRITE (*, FMT="('No. of blocks allocated:', T30, I19)") buff(13)
13408 @item @emph{See also}:
13409 To stat an open file: @ref{FSTAT}, to stat a link: @ref{LSTAT}
13415 @section @code{STORAGE_SIZE} --- Storage size in bits
13416 @fnindex STORAGE_SIZE
13417 @cindex storage size
13420 @item @emph{Description}:
13421 Returns the storage size of argument @var{A} in bits.
13422 @item @emph{Standard}:
13423 Fortran 2008 and later
13424 @item @emph{Class}:
13426 @item @emph{Syntax}:
13427 @code{RESULT = STORAGE_SIZE(A [, KIND])}
13429 @item @emph{Arguments}:
13430 @multitable @columnfractions .15 .70
13431 @item @var{A} @tab Shall be a scalar or array of any type.
13432 @item @var{KIND} @tab (Optional) shall be a scalar integer constant expression.
13435 @item @emph{Return Value}:
13436 The result is a scalar integer with the kind type parameter specified by KIND
13437 (or default integer type if KIND is missing). The result value is the size
13438 expressed in bits for an element of an array that has the dynamic type and type
13441 @item @emph{See also}:
13442 @ref{C_SIZEOF}, @ref{SIZEOF}
13448 @section @code{SUM} --- Sum of array elements
13451 @cindex array, add elements
13452 @cindex array, conditionally add elements
13453 @cindex sum array elements
13456 @item @emph{Description}:
13457 Adds the elements of @var{ARRAY} along dimension @var{DIM} if
13458 the corresponding element in @var{MASK} is @code{TRUE}.
13460 @item @emph{Standard}:
13461 Fortran 95 and later
13463 @item @emph{Class}:
13464 Transformational function
13466 @item @emph{Syntax}:
13467 @multitable @columnfractions .80
13468 @item @code{RESULT = SUM(ARRAY[, MASK])}
13469 @item @code{RESULT = SUM(ARRAY, DIM[, MASK])}
13472 @item @emph{Arguments}:
13473 @multitable @columnfractions .15 .70
13474 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER},
13475 @code{REAL} or @code{COMPLEX}.
13476 @item @var{DIM} @tab (Optional) shall be a scalar of type
13477 @code{INTEGER} with a value in the range from 1 to n, where n
13478 equals the rank of @var{ARRAY}.
13479 @item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL}
13480 and either be a scalar or an array of the same shape as @var{ARRAY}.
13483 @item @emph{Return value}:
13484 The result is of the same type as @var{ARRAY}.
13486 If @var{DIM} is absent, a scalar with the sum of all elements in @var{ARRAY}
13487 is returned. Otherwise, an array of rank n-1, where n equals the rank of
13488 @var{ARRAY}, and a shape similar to that of @var{ARRAY} with dimension @var{DIM}
13489 dropped is returned.
13491 @item @emph{Example}:
13494 INTEGER :: x(5) = (/ 1, 2, 3, 4 ,5 /)
13495 print *, SUM(x) ! all elements, sum = 15
13496 print *, SUM(x, MASK=MOD(x, 2)==1) ! odd elements, sum = 9
13500 @item @emph{See also}:
13507 @section @code{SYMLNK} --- Create a symbolic link
13509 @cindex file system, create link
13510 @cindex file system, soft link
13513 @item @emph{Description}:
13514 Makes a symbolic link from file @var{PATH1} to @var{PATH2}. A null
13515 character (@code{CHAR(0)}) can be used to mark the end of the names in
13516 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
13517 names are ignored. If the @var{STATUS} argument is supplied, it
13518 contains 0 on success or a nonzero error code upon return; see
13519 @code{symlink(2)}. If the system does not supply @code{symlink(2)},
13520 @code{ENOSYS} is returned.
13522 This intrinsic is provided in both subroutine and function forms;
13523 however, only one form can be used in any given program unit.
13525 @item @emph{Standard}:
13528 @item @emph{Class}:
13529 Subroutine, function
13531 @item @emph{Syntax}:
13532 @multitable @columnfractions .80
13533 @item @code{CALL SYMLNK(PATH1, PATH2 [, STATUS])}
13534 @item @code{STATUS = SYMLNK(PATH1, PATH2)}
13537 @item @emph{Arguments}:
13538 @multitable @columnfractions .15 .70
13539 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
13540 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
13541 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
13544 @item @emph{See also}:
13545 @ref{LINK}, @ref{UNLINK}
13552 @section @code{SYSTEM} --- Execute a shell command
13554 @cindex system, system call
13557 @item @emph{Description}:
13558 Passes the command @var{COMMAND} to a shell (see @code{system(3)}). If
13559 argument @var{STATUS} is present, it contains the value returned by
13560 @code{system(3)}, which is presumably 0 if the shell command succeeded.
13561 Note that which shell is used to invoke the command is system-dependent
13562 and environment-dependent.
13564 This intrinsic is provided in both subroutine and function forms;
13565 however, only one form can be used in any given program unit.
13567 Note that the @code{system} function need not be thread-safe. It is
13568 the responsibility of the user to ensure that @code{system} is not
13569 called concurrently.
13571 @item @emph{Standard}:
13574 @item @emph{Class}:
13575 Subroutine, function
13577 @item @emph{Syntax}:
13578 @multitable @columnfractions .80
13579 @item @code{CALL SYSTEM(COMMAND [, STATUS])}
13580 @item @code{STATUS = SYSTEM(COMMAND)}
13583 @item @emph{Arguments}:
13584 @multitable @columnfractions .15 .70
13585 @item @var{COMMAND} @tab Shall be of default @code{CHARACTER} type.
13586 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
13589 @item @emph{See also}:
13590 @ref{EXECUTE_COMMAND_LINE}, which is part of the Fortran 2008 standard
13591 and should considered in new code for future portability.
13597 @section @code{SYSTEM_CLOCK} --- Time function
13598 @fnindex SYSTEM_CLOCK
13599 @cindex time, clock ticks
13600 @cindex clock ticks
13603 @item @emph{Description}:
13604 Determines the @var{COUNT} of a processor clock since an unspecified
13605 time in the past modulo @var{COUNT_MAX}, @var{COUNT_RATE} determines
13606 the number of clock ticks per second. If the platform supports a
13607 monotonic clock, that clock is used and can, depending on the platform
13608 clock implementation, provide up to nanosecond resolution. If a
13609 monotonic clock is not available, the implementation falls back to a
13612 @var{COUNT_RATE} is system dependent and can vary depending on the kind of
13613 the arguments. For @var{kind=4} arguments (and smaller integer kinds),
13614 @var{COUNT} represents milliseconds, while for @var{kind=8} arguments (and
13615 larger integer kinds), @var{COUNT} typically represents micro- or
13616 nanoseconds depending on resolution of the underlying platform clock.
13617 @var{COUNT_MAX} usually equals @code{HUGE(COUNT_MAX)}. Note that the
13618 millisecond resolution of the @var{kind=4} version implies that the
13619 @var{COUNT} will wrap around in roughly 25 days. In order to avoid issues
13620 with the wrap around and for more precise timing, please use the
13621 @var{kind=8} version.
13623 If there is no clock, or querying the clock fails, @var{COUNT} is set
13624 to @code{-HUGE(COUNT)}, and @var{COUNT_RATE} and @var{COUNT_MAX} are
13627 When running on a platform using the GNU C library (glibc) version
13628 2.16 or older, or a derivative thereof, the high resolution monotonic
13629 clock is available only when linking with the @var{rt} library. This
13630 can be done explicitly by adding the @code{-lrt} flag when linking the
13631 application, but is also done implicitly when using OpenMP.
13633 On the Windows platform, the version with @var{kind=4} arguments uses
13634 the @code{GetTickCount} function, whereas the @var{kind=8} version
13635 uses @code{QueryPerformanceCounter} and
13636 @code{QueryPerformanceCounterFrequency}. For more information, and
13637 potential caveats, please see the platform documentation.
13639 @item @emph{Standard}:
13640 Fortran 95 and later
13642 @item @emph{Class}:
13645 @item @emph{Syntax}:
13646 @code{CALL SYSTEM_CLOCK([COUNT, COUNT_RATE, COUNT_MAX])}
13648 @item @emph{Arguments}:
13649 @multitable @columnfractions .15 .70
13650 @item @var{COUNT} @tab (Optional) shall be a scalar of type
13651 @code{INTEGER} with @code{INTENT(OUT)}.
13652 @item @var{COUNT_RATE} @tab (Optional) shall be a scalar of type
13653 @code{INTEGER} or @code{REAL}, with @code{INTENT(OUT)}.
13654 @item @var{COUNT_MAX} @tab (Optional) shall be a scalar of type
13655 @code{INTEGER} with @code{INTENT(OUT)}.
13658 @item @emph{Example}:
13660 PROGRAM test_system_clock
13661 INTEGER :: count, count_rate, count_max
13662 CALL SYSTEM_CLOCK(count, count_rate, count_max)
13663 WRITE(*,*) count, count_rate, count_max
13667 @item @emph{See also}:
13668 @ref{DATE_AND_TIME}, @ref{CPU_TIME}
13674 @section @code{TAN} --- Tangent function
13677 @cindex trigonometric function, tangent
13681 @item @emph{Description}:
13682 @code{TAN(X)} computes the tangent of @var{X}.
13684 @item @emph{Standard}:
13685 Fortran 77 and later, for a complex argument Fortran 2008 or later
13687 @item @emph{Class}:
13690 @item @emph{Syntax}:
13691 @code{RESULT = TAN(X)}
13693 @item @emph{Arguments}:
13694 @multitable @columnfractions .15 .70
13695 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
13698 @item @emph{Return value}:
13699 The return value has same type and kind as @var{X}, and its value is in radians.
13701 @item @emph{Example}:
13704 real(8) :: x = 0.165_8
13706 end program test_tan
13709 @item @emph{Specific names}:
13710 @multitable @columnfractions .20 .20 .20 .25
13711 @item Name @tab Argument @tab Return type @tab Standard
13712 @item @code{TAN(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 95 and later
13713 @item @code{DTAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 95 and later
13716 @item @emph{See also}:
13717 Inverse function: @ref{ATAN}
13718 Degrees function: @ref{TAND}
13724 @section @code{TAND} --- Tangent function, degrees
13727 @cindex trigonometric function, tangent, degrees
13728 @cindex tangent, degrees
13731 @item @emph{Description}:
13732 @code{TAND(X)} computes the tangent of @var{X} in degrees.
13734 This function is for compatibility only and should be avoided in favor of
13735 standard constructs wherever possible.
13737 @item @emph{Standard}:
13738 GNU Extension, enabled with @option{-fdec-math}.
13740 @item @emph{Class}:
13743 @item @emph{Syntax}:
13744 @code{RESULT = TAND(X)}
13746 @item @emph{Arguments}:
13747 @multitable @columnfractions .15 .70
13748 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
13751 @item @emph{Return value}:
13752 The return value has same type and kind as @var{X}, and its value is in degrees.
13754 @item @emph{Example}:
13757 real(8) :: x = 0.165_8
13759 end program test_tand
13762 @item @emph{Specific names}:
13763 @multitable @columnfractions .20 .20 .20 .25
13764 @item Name @tab Argument @tab Return type @tab Standard
13765 @item @code{TAND(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU Extension
13766 @item @code{DTAND(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU Extension
13769 @item @emph{See also}:
13770 Inverse function: @ref{ATAND}
13771 Radians function: @ref{TAN}
13777 @section @code{TANH} --- Hyperbolic tangent function
13780 @cindex hyperbolic tangent
13781 @cindex hyperbolic function, tangent
13782 @cindex tangent, hyperbolic
13785 @item @emph{Description}:
13786 @code{TANH(X)} computes the hyperbolic tangent of @var{X}.
13788 @item @emph{Standard}:
13789 Fortran 77 and later, for a complex argument Fortran 2008 or later
13791 @item @emph{Class}:
13794 @item @emph{Syntax}:
13797 @item @emph{Arguments}:
13798 @multitable @columnfractions .15 .70
13799 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
13802 @item @emph{Return value}:
13803 The return value has same type and kind as @var{X}. If @var{X} is
13804 complex, the imaginary part of the result is in radians. If @var{X}
13805 is @code{REAL}, the return value lies in the range
13806 @math{ - 1 \leq tanh(x) \leq 1 }.
13808 @item @emph{Example}:
13811 real(8) :: x = 2.1_8
13813 end program test_tanh
13816 @item @emph{Specific names}:
13817 @multitable @columnfractions .20 .20 .20 .25
13818 @item Name @tab Argument @tab Return type @tab Standard
13819 @item @code{TANH(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 95 and later
13820 @item @code{DTANH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 95 and later
13823 @item @emph{See also}:
13830 @section @code{THIS_IMAGE} --- Function that returns the cosubscript index of this image
13831 @fnindex THIS_IMAGE
13832 @cindex coarray, @code{THIS_IMAGE}
13833 @cindex images, index of this image
13836 @item @emph{Description}:
13837 Returns the cosubscript for this image.
13839 @item @emph{Standard}:
13840 Fortran 2008 and later. With @var{DISTANCE} argument,
13841 Technical Specification (TS) 18508 or later
13843 @item @emph{Class}:
13844 Transformational function
13846 @item @emph{Syntax}:
13847 @multitable @columnfractions .80
13848 @item @code{RESULT = THIS_IMAGE()}
13849 @item @code{RESULT = THIS_IMAGE(DISTANCE)}
13850 @item @code{RESULT = THIS_IMAGE(COARRAY [, DIM])}
13853 @item @emph{Arguments}:
13854 @multitable @columnfractions .15 .70
13855 @item @var{DISTANCE} @tab (optional, intent(in)) Nonnegative scalar integer
13856 (not permitted together with @var{COARRAY}).
13857 @item @var{COARRAY} @tab Coarray of any type (optional; if @var{DIM}
13858 present, required).
13859 @item @var{DIM} @tab default integer scalar (optional). If present,
13860 @var{DIM} shall be between one and the corank of @var{COARRAY}.
13864 @item @emph{Return value}:
13865 Default integer. If @var{COARRAY} is not present, it is scalar; if
13866 @var{DISTANCE} is not present or has value 0, its value is the image index on
13867 the invoking image for the current team, for values smaller or equal
13868 distance to the initial team, it returns the image index on the ancestor team
13869 which has a distance of @var{DISTANCE} from the invoking team. If
13870 @var{DISTANCE} is larger than the distance to the initial team, the image
13871 index of the initial team is returned. Otherwise when the @var{COARRAY} is
13872 present, if @var{DIM} is not present, a rank-1 array with corank elements is
13873 returned, containing the cosubscripts for @var{COARRAY} specifying the invoking
13874 image. If @var{DIM} is present, a scalar is returned, with the value of
13875 the @var{DIM} element of @code{THIS_IMAGE(COARRAY)}.
13877 @item @emph{Example}:
13879 INTEGER :: value[*]
13881 value = THIS_IMAGE()
13883 IF (THIS_IMAGE() == 1) THEN
13884 DO i = 1, NUM_IMAGES()
13885 WRITE(*,'(2(a,i0))') 'value[', i, '] is ', value[i]
13889 ! Check whether the current image is the initial image
13890 IF (THIS_IMAGE(HUGE(1)) /= THIS_IMAGE())
13891 error stop "something is rotten here"
13894 @item @emph{See also}:
13895 @ref{NUM_IMAGES}, @ref{IMAGE_INDEX}
13901 @section @code{TIME} --- Time function
13903 @cindex time, current
13904 @cindex current time
13907 @item @emph{Description}:
13908 Returns the current time encoded as an integer (in the manner of the
13909 function @code{time(3)} in the C standard library). This value is
13910 suitable for passing to @ref{CTIME}, @ref{GMTIME}, and @ref{LTIME}.
13912 This intrinsic is not fully portable, such as to systems with 32-bit
13913 @code{INTEGER} types but supporting times wider than 32 bits. Therefore,
13914 the values returned by this intrinsic might be, or become, negative, or
13915 numerically less than previous values, during a single run of the
13918 See @ref{TIME8}, for information on a similar intrinsic that might be
13919 portable to more GNU Fortran implementations, though to fewer Fortran
13922 @item @emph{Standard}:
13925 @item @emph{Class}:
13928 @item @emph{Syntax}:
13929 @code{RESULT = TIME()}
13931 @item @emph{Return value}:
13932 The return value is a scalar of type @code{INTEGER(4)}.
13934 @item @emph{See also}:
13935 @ref{DATE_AND_TIME}, @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME8}
13942 @section @code{TIME8} --- Time function (64-bit)
13944 @cindex time, current
13945 @cindex current time
13948 @item @emph{Description}:
13949 Returns the current time encoded as an integer (in the manner of the
13950 function @code{time(3)} in the C standard library). This value is
13951 suitable for passing to @ref{CTIME}, @ref{GMTIME}, and @ref{LTIME}.
13953 @emph{Warning:} this intrinsic does not increase the range of the timing
13954 values over that returned by @code{time(3)}. On a system with a 32-bit
13955 @code{time(3)}, @code{TIME8} will return a 32-bit value, even though
13956 it is converted to a 64-bit @code{INTEGER(8)} value. That means
13957 overflows of the 32-bit value can still occur. Therefore, the values
13958 returned by this intrinsic might be or become negative or numerically
13959 less than previous values during a single run of the compiled program.
13961 @item @emph{Standard}:
13964 @item @emph{Class}:
13967 @item @emph{Syntax}:
13968 @code{RESULT = TIME8()}
13970 @item @emph{Return value}:
13971 The return value is a scalar of type @code{INTEGER(8)}.
13973 @item @emph{See also}:
13974 @ref{DATE_AND_TIME}, @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK8}, @ref{TIME}
13981 @section @code{TINY} --- Smallest positive number of a real kind
13983 @cindex limits, smallest number
13984 @cindex model representation, smallest number
13987 @item @emph{Description}:
13988 @code{TINY(X)} returns the smallest positive (non zero) number
13989 in the model of the type of @code{X}.
13991 @item @emph{Standard}:
13992 Fortran 95 and later
13994 @item @emph{Class}:
13997 @item @emph{Syntax}:
13998 @code{RESULT = TINY(X)}
14000 @item @emph{Arguments}:
14001 @multitable @columnfractions .15 .70
14002 @item @var{X} @tab Shall be of type @code{REAL}.
14005 @item @emph{Return value}:
14006 The return value is of the same type and kind as @var{X}
14008 @item @emph{Example}:
14009 See @code{HUGE} for an example.
14015 @section @code{TRAILZ} --- Number of trailing zero bits of an integer
14020 @item @emph{Description}:
14021 @code{TRAILZ} returns the number of trailing zero bits of an integer.
14023 @item @emph{Standard}:
14024 Fortran 2008 and later
14026 @item @emph{Class}:
14029 @item @emph{Syntax}:
14030 @code{RESULT = TRAILZ(I)}
14032 @item @emph{Arguments}:
14033 @multitable @columnfractions .15 .70
14034 @item @var{I} @tab Shall be of type @code{INTEGER}.
14037 @item @emph{Return value}:
14038 The type of the return value is the default @code{INTEGER}.
14039 If all the bits of @code{I} are zero, the result value is @code{BIT_SIZE(I)}.
14041 @item @emph{Example}:
14043 PROGRAM test_trailz
14044 WRITE (*,*) TRAILZ(8) ! prints 3
14048 @item @emph{See also}:
14049 @ref{BIT_SIZE}, @ref{LEADZ}, @ref{POPPAR}, @ref{POPCNT}
14055 @section @code{TRANSFER} --- Transfer bit patterns
14061 @item @emph{Description}:
14062 Interprets the bitwise representation of @var{SOURCE} in memory as if it
14063 is the representation of a variable or array of the same type and type
14064 parameters as @var{MOLD}.
14066 This is approximately equivalent to the C concept of @emph{casting} one
14069 @item @emph{Standard}:
14070 Fortran 95 and later
14072 @item @emph{Class}:
14073 Transformational function
14075 @item @emph{Syntax}:
14076 @code{RESULT = TRANSFER(SOURCE, MOLD[, SIZE])}
14078 @item @emph{Arguments}:
14079 @multitable @columnfractions .15 .70
14080 @item @var{SOURCE} @tab Shall be a scalar or an array of any type.
14081 @item @var{MOLD} @tab Shall be a scalar or an array of any type.
14082 @item @var{SIZE} @tab (Optional) shall be a scalar of type
14086 @item @emph{Return value}:
14087 The result has the same type as @var{MOLD}, with the bit level
14088 representation of @var{SOURCE}. If @var{SIZE} is present, the result is
14089 a one-dimensional array of length @var{SIZE}. If @var{SIZE} is absent
14090 but @var{MOLD} is an array (of any size or shape), the result is a one-
14091 dimensional array of the minimum length needed to contain the entirety
14092 of the bitwise representation of @var{SOURCE}. If @var{SIZE} is absent
14093 and @var{MOLD} is a scalar, the result is a scalar.
14095 If the bitwise representation of the result is longer than that of
14096 @var{SOURCE}, then the leading bits of the result correspond to those of
14097 @var{SOURCE} and any trailing bits are filled arbitrarily.
14099 When the resulting bit representation does not correspond to a valid
14100 representation of a variable of the same type as @var{MOLD}, the results
14101 are undefined, and subsequent operations on the result cannot be
14102 guaranteed to produce sensible behavior. For example, it is possible to
14103 create @code{LOGICAL} variables for which @code{@var{VAR}} and
14104 @code{.NOT.@var{VAR}} both appear to be true.
14106 @item @emph{Example}:
14108 PROGRAM test_transfer
14109 integer :: x = 2143289344
14110 print *, transfer(x, 1.0) ! prints "NaN" on i686
14118 @section @code{TRANSPOSE} --- Transpose an array of rank two
14120 @cindex array, transpose
14121 @cindex matrix, transpose
14125 @item @emph{Description}:
14126 Transpose an array of rank two. Element (i, j) of the result has the value
14127 @code{MATRIX(j, i)}, for all i, j.
14129 @item @emph{Standard}:
14130 Fortran 95 and later
14132 @item @emph{Class}:
14133 Transformational function
14135 @item @emph{Syntax}:
14136 @code{RESULT = TRANSPOSE(MATRIX)}
14138 @item @emph{Arguments}:
14139 @multitable @columnfractions .15 .70
14140 @item @var{MATRIX} @tab Shall be an array of any type and have a rank of two.
14143 @item @emph{Return value}:
14144 The result has the same type as @var{MATRIX}, and has shape
14145 @code{(/ m, n /)} if @var{MATRIX} has shape @code{(/ n, m /)}.
14151 @section @code{TRIM} --- Remove trailing blank characters of a string
14153 @cindex string, remove trailing whitespace
14156 @item @emph{Description}:
14157 Removes trailing blank characters of a string.
14159 @item @emph{Standard}:
14160 Fortran 95 and later
14162 @item @emph{Class}:
14163 Transformational function
14165 @item @emph{Syntax}:
14166 @code{RESULT = TRIM(STRING)}
14168 @item @emph{Arguments}:
14169 @multitable @columnfractions .15 .70
14170 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER}.
14173 @item @emph{Return value}:
14174 A scalar of type @code{CHARACTER} which length is that of @var{STRING}
14175 less the number of trailing blanks.
14177 @item @emph{Example}:
14180 CHARACTER(len=10), PARAMETER :: s = "GFORTRAN "
14181 WRITE(*,*) LEN(s), LEN(TRIM(s)) ! "10 8", with/without trailing blanks
14185 @item @emph{See also}:
14186 @ref{ADJUSTL}, @ref{ADJUSTR}
14192 @section @code{TTYNAM} --- Get the name of a terminal device.
14194 @cindex system, terminal
14197 @item @emph{Description}:
14198 Get the name of a terminal device. For more information,
14199 see @code{ttyname(3)}.
14201 This intrinsic is provided in both subroutine and function forms;
14202 however, only one form can be used in any given program unit.
14204 @item @emph{Standard}:
14207 @item @emph{Class}:
14208 Subroutine, function
14210 @item @emph{Syntax}:
14211 @multitable @columnfractions .80
14212 @item @code{CALL TTYNAM(UNIT, NAME)}
14213 @item @code{NAME = TTYNAM(UNIT)}
14216 @item @emph{Arguments}:
14217 @multitable @columnfractions .15 .70
14218 @item @var{UNIT} @tab Shall be a scalar @code{INTEGER}.
14219 @item @var{NAME} @tab Shall be of type @code{CHARACTER}.
14222 @item @emph{Example}:
14224 PROGRAM test_ttynam
14227 IF (isatty(unit=unit)) write(*,*) ttynam(unit)
14232 @item @emph{See also}:
14239 @section @code{UBOUND} --- Upper dimension bounds of an array
14241 @cindex array, upper bound
14244 @item @emph{Description}:
14245 Returns the upper bounds of an array, or a single upper bound
14246 along the @var{DIM} dimension.
14247 @item @emph{Standard}:
14248 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
14250 @item @emph{Class}:
14253 @item @emph{Syntax}:
14254 @code{RESULT = UBOUND(ARRAY [, DIM [, KIND]])}
14256 @item @emph{Arguments}:
14257 @multitable @columnfractions .15 .70
14258 @item @var{ARRAY} @tab Shall be an array, of any type.
14259 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
14260 @item @var{KIND}@tab (Optional) An @code{INTEGER} initialization
14261 expression indicating the kind parameter of the result.
14264 @item @emph{Return value}:
14265 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
14266 @var{KIND} is absent, the return value is of default integer kind.
14267 If @var{DIM} is absent, the result is an array of the upper bounds of
14268 @var{ARRAY}. If @var{DIM} is present, the result is a scalar
14269 corresponding to the upper bound of the array along that dimension. If
14270 @var{ARRAY} is an expression rather than a whole array or array
14271 structure component, or if it has a zero extent along the relevant
14272 dimension, the upper bound is taken to be the number of elements along
14273 the relevant dimension.
14275 @item @emph{See also}:
14276 @ref{LBOUND}, @ref{LCOBOUND}
14282 @section @code{UCOBOUND} --- Upper codimension bounds of an array
14284 @cindex coarray, upper bound
14287 @item @emph{Description}:
14288 Returns the upper cobounds of a coarray, or a single upper cobound
14289 along the @var{DIM} codimension.
14290 @item @emph{Standard}:
14291 Fortran 2008 and later
14293 @item @emph{Class}:
14296 @item @emph{Syntax}:
14297 @code{RESULT = UCOBOUND(COARRAY [, DIM [, KIND]])}
14299 @item @emph{Arguments}:
14300 @multitable @columnfractions .15 .70
14301 @item @var{ARRAY} @tab Shall be an coarray, of any type.
14302 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
14303 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
14304 expression indicating the kind parameter of the result.
14307 @item @emph{Return value}:
14308 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
14309 @var{KIND} is absent, the return value is of default integer kind.
14310 If @var{DIM} is absent, the result is an array of the lower cobounds of
14311 @var{COARRAY}. If @var{DIM} is present, the result is a scalar
14312 corresponding to the lower cobound of the array along that codimension.
14314 @item @emph{See also}:
14315 @ref{LCOBOUND}, @ref{LBOUND}
14321 @section @code{UMASK} --- Set the file creation mask
14323 @cindex file system, file creation mask
14326 @item @emph{Description}:
14327 Sets the file creation mask to @var{MASK}. If called as a function, it
14328 returns the old value. If called as a subroutine and argument @var{OLD}
14329 if it is supplied, it is set to the old value. See @code{umask(2)}.
14331 @item @emph{Standard}:
14334 @item @emph{Class}:
14335 Subroutine, function
14337 @item @emph{Syntax}:
14338 @multitable @columnfractions .80
14339 @item @code{CALL UMASK(MASK [, OLD])}
14340 @item @code{OLD = UMASK(MASK)}
14343 @item @emph{Arguments}:
14344 @multitable @columnfractions .15 .70
14345 @item @var{MASK} @tab Shall be a scalar of type @code{INTEGER}.
14346 @item @var{OLD} @tab (Optional) Shall be a scalar of type
14355 @section @code{UNLINK} --- Remove a file from the file system
14357 @cindex file system, remove file
14360 @item @emph{Description}:
14361 Unlinks the file @var{PATH}. A null character (@code{CHAR(0)}) can be
14362 used to mark the end of the name in @var{PATH}; otherwise, trailing
14363 blanks in the file name are ignored. If the @var{STATUS} argument is
14364 supplied, it contains 0 on success or a nonzero error code upon return;
14365 see @code{unlink(2)}.
14367 This intrinsic is provided in both subroutine and function forms;
14368 however, only one form can be used in any given program unit.
14370 @item @emph{Standard}:
14373 @item @emph{Class}:
14374 Subroutine, function
14376 @item @emph{Syntax}:
14377 @multitable @columnfractions .80
14378 @item @code{CALL UNLINK(PATH [, STATUS])}
14379 @item @code{STATUS = UNLINK(PATH)}
14382 @item @emph{Arguments}:
14383 @multitable @columnfractions .15 .70
14384 @item @var{PATH} @tab Shall be of default @code{CHARACTER} type.
14385 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
14388 @item @emph{See also}:
14389 @ref{LINK}, @ref{SYMLNK}
14395 @section @code{UNPACK} --- Unpack an array of rank one into an array
14397 @cindex array, unpacking
14398 @cindex array, increase dimension
14399 @cindex array, scatter elements
14402 @item @emph{Description}:
14403 Store the elements of @var{VECTOR} in an array of higher rank.
14405 @item @emph{Standard}:
14406 Fortran 95 and later
14408 @item @emph{Class}:
14409 Transformational function
14411 @item @emph{Syntax}:
14412 @code{RESULT = UNPACK(VECTOR, MASK, FIELD)}
14414 @item @emph{Arguments}:
14415 @multitable @columnfractions .15 .70
14416 @item @var{VECTOR} @tab Shall be an array of any type and rank one. It
14417 shall have at least as many elements as @var{MASK} has @code{TRUE} values.
14418 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL}.
14419 @item @var{FIELD} @tab Shall be of the same type as @var{VECTOR} and have
14420 the same shape as @var{MASK}.
14423 @item @emph{Return value}:
14424 The resulting array corresponds to @var{FIELD} with @code{TRUE} elements
14425 of @var{MASK} replaced by values from @var{VECTOR} in array element order.
14427 @item @emph{Example}:
14429 PROGRAM test_unpack
14430 integer :: vector(2) = (/1,1/)
14431 logical :: mask(4) = (/ .TRUE., .FALSE., .FALSE., .TRUE. /)
14432 integer :: field(2,2) = 0, unity(2,2)
14434 ! result: unity matrix
14435 unity = unpack(vector, reshape(mask, (/2,2/)), field)
14439 @item @emph{See also}:
14440 @ref{PACK}, @ref{SPREAD}
14446 @section @code{VERIFY} --- Scan a string for characters not a given set
14448 @cindex string, find missing set
14451 @item @emph{Description}:
14452 Verifies that all the characters in @var{STRING} belong to the set of
14453 characters in @var{SET}.
14455 If @var{BACK} is either absent or equals @code{FALSE}, this function
14456 returns the position of the leftmost character of @var{STRING} that is
14457 not in @var{SET}. If @var{BACK} equals @code{TRUE}, the rightmost
14458 position is returned. If all characters of @var{STRING} are found in
14459 @var{SET}, the result is zero.
14461 @item @emph{Standard}:
14462 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
14464 @item @emph{Class}:
14467 @item @emph{Syntax}:
14468 @code{RESULT = VERIFY(STRING, SET[, BACK [, KIND]])}
14470 @item @emph{Arguments}:
14471 @multitable @columnfractions .15 .70
14472 @item @var{STRING} @tab Shall be of type @code{CHARACTER}.
14473 @item @var{SET} @tab Shall be of type @code{CHARACTER}.
14474 @item @var{BACK} @tab (Optional) shall be of type @code{LOGICAL}.
14475 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
14476 expression indicating the kind parameter of the result.
14479 @item @emph{Return value}:
14480 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
14481 @var{KIND} is absent, the return value is of default integer kind.
14483 @item @emph{Example}:
14485 PROGRAM test_verify
14486 WRITE(*,*) VERIFY("FORTRAN", "AO") ! 1, found 'F'
14487 WRITE(*,*) VERIFY("FORTRAN", "FOO") ! 3, found 'R'
14488 WRITE(*,*) VERIFY("FORTRAN", "C++") ! 1, found 'F'
14489 WRITE(*,*) VERIFY("FORTRAN", "C++", .TRUE.) ! 7, found 'N'
14490 WRITE(*,*) VERIFY("FORTRAN", "FORTRAN") ! 0' found none
14494 @item @emph{See also}:
14495 @ref{SCAN}, @ref{INDEX intrinsic}
14501 @section @code{XOR} --- Bitwise logical exclusive OR
14503 @cindex bitwise logical exclusive or
14504 @cindex logical exclusive or, bitwise
14507 @item @emph{Description}:
14508 Bitwise logical exclusive or.
14510 This intrinsic routine is provided for backwards compatibility with
14511 GNU Fortran 77. For integer arguments, programmers should consider
14512 the use of the @ref{IEOR} intrinsic and for logical arguments the
14513 @code{.NEQV.} operator, which are both defined by the Fortran standard.
14515 @item @emph{Standard}:
14518 @item @emph{Class}:
14521 @item @emph{Syntax}:
14522 @code{RESULT = XOR(I, J)}
14524 @item @emph{Arguments}:
14525 @multitable @columnfractions .15 .70
14526 @item @var{I} @tab The type shall be either a scalar @code{INTEGER}
14527 type or a scalar @code{LOGICAL} type.
14528 @item @var{J} @tab The type shall be the same as the type of @var{I}.
14531 @item @emph{Return value}:
14532 The return type is either a scalar @code{INTEGER} or a scalar
14533 @code{LOGICAL}. If the kind type parameters differ, then the
14534 smaller kind type is implicitly converted to larger kind, and the
14535 return has the larger kind.
14537 @item @emph{Example}:
14540 LOGICAL :: T = .TRUE., F = .FALSE.
14542 DATA a / Z'F' /, b / Z'3' /
14544 WRITE (*,*) XOR(T, T), XOR(T, F), XOR(F, T), XOR(F, F)
14545 WRITE (*,*) XOR(a, b)
14549 @item @emph{See also}:
14550 Fortran 95 elemental function: @ref{IEOR}
14555 @node Intrinsic Modules
14556 @chapter Intrinsic Modules
14557 @cindex intrinsic Modules
14560 * ISO_FORTRAN_ENV::
14563 * OpenMP Modules OMP_LIB and OMP_LIB_KINDS::
14564 * OpenACC Module OPENACC::
14567 @node ISO_FORTRAN_ENV
14568 @section @code{ISO_FORTRAN_ENV}
14570 @item @emph{Standard}:
14571 Fortran 2003 and later, except when otherwise noted
14574 The @code{ISO_FORTRAN_ENV} module provides the following scalar default-integer
14578 @item @code{ATOMIC_INT_KIND}:
14579 Default-kind integer constant to be used as kind parameter when defining
14580 integer variables used in atomic operations. (Fortran 2008 or later.)
14582 @item @code{ATOMIC_LOGICAL_KIND}:
14583 Default-kind integer constant to be used as kind parameter when defining
14584 logical variables used in atomic operations. (Fortran 2008 or later.)
14586 @item @code{CHARACTER_KINDS}:
14587 Default-kind integer constant array of rank one containing the supported kind
14588 parameters of the @code{CHARACTER} type. (Fortran 2008 or later.)
14590 @item @code{CHARACTER_STORAGE_SIZE}:
14591 Size in bits of the character storage unit.
14593 @item @code{ERROR_UNIT}:
14594 Identifies the preconnected unit used for error reporting.
14596 @item @code{FILE_STORAGE_SIZE}:
14597 Size in bits of the file-storage unit.
14599 @item @code{INPUT_UNIT}:
14600 Identifies the preconnected unit identified by the asterisk
14601 (@code{*}) in @code{READ} statement.
14603 @item @code{INT8}, @code{INT16}, @code{INT32}, @code{INT64}:
14604 Kind type parameters to specify an INTEGER type with a storage
14605 size of 16, 32, and 64 bits. It is negative if a target platform
14606 does not support the particular kind. (Fortran 2008 or later.)
14608 @item @code{INTEGER_KINDS}:
14609 Default-kind integer constant array of rank one containing the supported kind
14610 parameters of the @code{INTEGER} type. (Fortran 2008 or later.)
14612 @item @code{IOSTAT_END}:
14613 The value assigned to the variable passed to the @code{IOSTAT=} specifier of
14614 an input/output statement if an end-of-file condition occurred.
14616 @item @code{IOSTAT_EOR}:
14617 The value assigned to the variable passed to the @code{IOSTAT=} specifier of
14618 an input/output statement if an end-of-record condition occurred.
14620 @item @code{IOSTAT_INQUIRE_INTERNAL_UNIT}:
14621 Scalar default-integer constant, used by @code{INQUIRE} for the
14622 @code{IOSTAT=} specifier to denote an that a unit number identifies an
14623 internal unit. (Fortran 2008 or later.)
14625 @item @code{NUMERIC_STORAGE_SIZE}:
14626 The size in bits of the numeric storage unit.
14628 @item @code{LOGICAL_KINDS}:
14629 Default-kind integer constant array of rank one containing the supported kind
14630 parameters of the @code{LOGICAL} type. (Fortran 2008 or later.)
14632 @item @code{OUTPUT_UNIT}:
14633 Identifies the preconnected unit identified by the asterisk
14634 (@code{*}) in @code{WRITE} statement.
14636 @item @code{REAL32}, @code{REAL64}, @code{REAL128}:
14637 Kind type parameters to specify a REAL type with a storage
14638 size of 32, 64, and 128 bits. It is negative if a target platform
14639 does not support the particular kind. (Fortran 2008 or later.)
14641 @item @code{REAL_KINDS}:
14642 Default-kind integer constant array of rank one containing the supported kind
14643 parameters of the @code{REAL} type. (Fortran 2008 or later.)
14645 @item @code{STAT_LOCKED}:
14646 Scalar default-integer constant used as STAT= return value by @code{LOCK} to
14647 denote that the lock variable is locked by the executing image. (Fortran 2008
14650 @item @code{STAT_LOCKED_OTHER_IMAGE}:
14651 Scalar default-integer constant used as STAT= return value by @code{UNLOCK} to
14652 denote that the lock variable is locked by another image. (Fortran 2008 or
14655 @item @code{STAT_STOPPED_IMAGE}:
14656 Positive, scalar default-integer constant used as STAT= return value if the
14657 argument in the statement requires synchronisation with an image, which has
14658 initiated the termination of the execution. (Fortran 2008 or later.)
14660 @item @code{STAT_FAILED_IMAGE}:
14661 Positive, scalar default-integer constant used as STAT= return value if the
14662 argument in the statement requires communication with an image, which has
14663 is in the failed state. (TS 18508 or later.)
14665 @item @code{STAT_UNLOCKED}:
14666 Scalar default-integer constant used as STAT= return value by @code{UNLOCK} to
14667 denote that the lock variable is unlocked. (Fortran 2008 or later.)
14670 The module provides the following derived type:
14673 @item @code{LOCK_TYPE}:
14674 Derived type with private components to be use with the @code{LOCK} and
14675 @code{UNLOCK} statement. A variable of its type has to be always declared
14676 as coarray and may not appear in a variable-definition context.
14677 (Fortran 2008 or later.)
14680 The module also provides the following intrinsic procedures:
14681 @ref{COMPILER_OPTIONS} and @ref{COMPILER_VERSION}.
14685 @node ISO_C_BINDING
14686 @section @code{ISO_C_BINDING}
14688 @item @emph{Standard}:
14689 Fortran 2003 and later, GNU extensions
14692 The following intrinsic procedures are provided by the module; their
14693 definition can be found in the section Intrinsic Procedures of this
14697 @item @code{C_ASSOCIATED}
14698 @item @code{C_F_POINTER}
14699 @item @code{C_F_PROCPOINTER}
14700 @item @code{C_FUNLOC}
14702 @item @code{C_SIZEOF}
14704 @c TODO: Vertical spacing between C_FUNLOC and C_LOC wrong in PDF,
14705 @c don't really know why.
14707 The @code{ISO_C_BINDING} module provides the following named constants of
14708 type default integer, which can be used as KIND type parameters.
14710 In addition to the integer named constants required by the Fortran 2003
14711 standard and @code{C_PTRDIFF_T} of TS 29113, GNU Fortran provides as an
14712 extension named constants for the 128-bit integer types supported by the
14713 C compiler: @code{C_INT128_T, C_INT_LEAST128_T, C_INT_FAST128_T}.
14714 Furthermore, if @code{__float128} is supported in C, the named constants
14715 @code{C_FLOAT128, C_FLOAT128_COMPLEX} are defined.
14717 @multitable @columnfractions .15 .35 .35 .35
14718 @item Fortran Type @tab Named constant @tab C type @tab Extension
14719 @item @code{INTEGER}@tab @code{C_INT} @tab @code{int}
14720 @item @code{INTEGER}@tab @code{C_SHORT} @tab @code{short int}
14721 @item @code{INTEGER}@tab @code{C_LONG} @tab @code{long int}
14722 @item @code{INTEGER}@tab @code{C_LONG_LONG} @tab @code{long long int}
14723 @item @code{INTEGER}@tab @code{C_SIGNED_CHAR} @tab @code{signed char}/@code{unsigned char}
14724 @item @code{INTEGER}@tab @code{C_SIZE_T} @tab @code{size_t}
14725 @item @code{INTEGER}@tab @code{C_INT8_T} @tab @code{int8_t}
14726 @item @code{INTEGER}@tab @code{C_INT16_T} @tab @code{int16_t}
14727 @item @code{INTEGER}@tab @code{C_INT32_T} @tab @code{int32_t}
14728 @item @code{INTEGER}@tab @code{C_INT64_T} @tab @code{int64_t}
14729 @item @code{INTEGER}@tab @code{C_INT128_T} @tab @code{int128_t} @tab Ext.
14730 @item @code{INTEGER}@tab @code{C_INT_LEAST8_T} @tab @code{int_least8_t}
14731 @item @code{INTEGER}@tab @code{C_INT_LEAST16_T} @tab @code{int_least16_t}
14732 @item @code{INTEGER}@tab @code{C_INT_LEAST32_T} @tab @code{int_least32_t}
14733 @item @code{INTEGER}@tab @code{C_INT_LEAST64_T} @tab @code{int_least64_t}
14734 @item @code{INTEGER}@tab @code{C_INT_LEAST128_T}@tab @code{int_least128_t} @tab Ext.
14735 @item @code{INTEGER}@tab @code{C_INT_FAST8_T} @tab @code{int_fast8_t}
14736 @item @code{INTEGER}@tab @code{C_INT_FAST16_T} @tab @code{int_fast16_t}
14737 @item @code{INTEGER}@tab @code{C_INT_FAST32_T} @tab @code{int_fast32_t}
14738 @item @code{INTEGER}@tab @code{C_INT_FAST64_T} @tab @code{int_fast64_t}
14739 @item @code{INTEGER}@tab @code{C_INT_FAST128_T} @tab @code{int_fast128_t} @tab Ext.
14740 @item @code{INTEGER}@tab @code{C_INTMAX_T} @tab @code{intmax_t}
14741 @item @code{INTEGER}@tab @code{C_INTPTR_T} @tab @code{intptr_t}
14742 @item @code{INTEGER}@tab @code{C_PTRDIFF_T} @tab @code{ptrdiff_t} @tab TS 29113
14743 @item @code{REAL} @tab @code{C_FLOAT} @tab @code{float}
14744 @item @code{REAL} @tab @code{C_DOUBLE} @tab @code{double}
14745 @item @code{REAL} @tab @code{C_LONG_DOUBLE} @tab @code{long double}
14746 @item @code{REAL} @tab @code{C_FLOAT128} @tab @code{__float128} @tab Ext.
14747 @item @code{COMPLEX}@tab @code{C_FLOAT_COMPLEX} @tab @code{float _Complex}
14748 @item @code{COMPLEX}@tab @code{C_DOUBLE_COMPLEX}@tab @code{double _Complex}
14749 @item @code{COMPLEX}@tab @code{C_LONG_DOUBLE_COMPLEX}@tab @code{long double _Complex}
14750 @item @code{REAL} @tab @code{C_FLOAT128_COMPLEX} @tab @code{__float128 _Complex} @tab Ext.
14751 @item @code{LOGICAL}@tab @code{C_BOOL} @tab @code{_Bool}
14752 @item @code{CHARACTER}@tab @code{C_CHAR} @tab @code{char}
14755 Additionally, the following parameters of type @code{CHARACTER(KIND=C_CHAR)}
14758 @multitable @columnfractions .20 .45 .15
14759 @item Name @tab C definition @tab Value
14760 @item @code{C_NULL_CHAR} @tab null character @tab @code{'\0'}
14761 @item @code{C_ALERT} @tab alert @tab @code{'\a'}
14762 @item @code{C_BACKSPACE} @tab backspace @tab @code{'\b'}
14763 @item @code{C_FORM_FEED} @tab form feed @tab @code{'\f'}
14764 @item @code{C_NEW_LINE} @tab new line @tab @code{'\n'}
14765 @item @code{C_CARRIAGE_RETURN} @tab carriage return @tab @code{'\r'}
14766 @item @code{C_HORIZONTAL_TAB} @tab horizontal tab @tab @code{'\t'}
14767 @item @code{C_VERTICAL_TAB} @tab vertical tab @tab @code{'\v'}
14770 Moreover, the following two named constants are defined:
14772 @multitable @columnfractions .20 .80
14773 @item Name @tab Type
14774 @item @code{C_NULL_PTR} @tab @code{C_PTR}
14775 @item @code{C_NULL_FUNPTR} @tab @code{C_FUNPTR}
14778 Both are equivalent to the value @code{NULL} in C.
14783 @section IEEE modules: @code{IEEE_EXCEPTIONS}, @code{IEEE_ARITHMETIC}, and @code{IEEE_FEATURES}
14785 @item @emph{Standard}:
14786 Fortran 2003 and later
14789 The @code{IEEE_EXCEPTIONS}, @code{IEEE_ARITHMETIC}, and @code{IEEE_FEATURES}
14790 intrinsic modules provide support for exceptions and IEEE arithmetic, as
14791 defined in Fortran 2003 and later standards, and the IEC 60559:1989 standard
14792 (@emph{Binary floating-point arithmetic for microprocessor systems}). These
14793 modules are only provided on the following supported platforms:
14796 @item i386 and x86_64 processors
14797 @item platforms which use the GNU C Library (glibc)
14798 @item platforms with support for SysV/386 routines for floating point
14799 interface (including Solaris and BSDs)
14800 @item platforms with the AIX OS
14803 For full compliance with the Fortran standards, code using the
14804 @code{IEEE_EXCEPTIONS} or @code{IEEE_ARITHMETIC} modules should be compiled
14805 with the following options: @code{-fno-unsafe-math-optimizations
14806 -frounding-math -fsignaling-nans}.
14810 @node OpenMP Modules OMP_LIB and OMP_LIB_KINDS
14811 @section OpenMP Modules @code{OMP_LIB} and @code{OMP_LIB_KINDS}
14813 @item @emph{Standard}:
14814 OpenMP Application Program Interface v4.5
14818 The OpenMP Fortran runtime library routines are provided both in
14819 a form of two Fortran 90 modules, named @code{OMP_LIB} and
14820 @code{OMP_LIB_KINDS}, and in a form of a Fortran @code{include} file named
14821 @file{omp_lib.h}. The procedures provided by @code{OMP_LIB} can be found
14822 in the @ref{Top,,Introduction,libgomp,GNU Offloading and Multi
14823 Processing Runtime Library} manual,
14824 the named constants defined in the modules are listed
14827 For details refer to the actual
14828 @uref{http://www.openmp.org/wp-content/uploads/openmp-4.5.pdf,
14829 OpenMP Application Program Interface v4.5}.
14831 @code{OMP_LIB_KINDS} provides the following scalar default-integer
14835 @item @code{omp_lock_kind}
14836 @item @code{omp_nest_lock_kind}
14837 @item @code{omp_proc_bind_kind}
14838 @item @code{omp_sched_kind}
14841 @code{OMP_LIB} provides the scalar default-integer
14842 named constant @code{openmp_version} with a value of the form
14843 @var{yyyymm}, where @code{yyyy} is the year and @var{mm} the month
14844 of the OpenMP version; for OpenMP v4.5 the value is @code{201511}.
14846 The following scalar integer named constants of the
14847 kind @code{omp_sched_kind}:
14850 @item @code{omp_sched_static}
14851 @item @code{omp_sched_dynamic}
14852 @item @code{omp_sched_guided}
14853 @item @code{omp_sched_auto}
14856 And the following scalar integer named constants of the
14857 kind @code{omp_proc_bind_kind}:
14860 @item @code{omp_proc_bind_false}
14861 @item @code{omp_proc_bind_true}
14862 @item @code{omp_proc_bind_master}
14863 @item @code{omp_proc_bind_close}
14864 @item @code{omp_proc_bind_spread}
14869 @node OpenACC Module OPENACC
14870 @section OpenACC Module @code{OPENACC}
14872 @item @emph{Standard}:
14873 OpenACC Application Programming Interface v2.0
14877 The OpenACC Fortran runtime library routines are provided both in a
14878 form of a Fortran 90 module, named @code{OPENACC}, and in form of a
14879 Fortran @code{include} file named @file{openacc_lib.h}. The
14880 procedures provided by @code{OPENACC} can be found in the
14881 @ref{Top,,Introduction,libgomp,GNU Offloading and Multi Processing
14882 Runtime Library} manual, the named constants defined in the modules
14885 For details refer to the actual
14886 @uref{http://www.openacc.org/,
14887 OpenACC Application Programming Interface v2.0}.
14889 @code{OPENACC} provides the scalar default-integer
14890 named constant @code{openacc_version} with a value of the form
14891 @var{yyyymm}, where @code{yyyy} is the year and @var{mm} the month
14892 of the OpenACC version; for OpenACC v2.0 the value is @code{201306}.