2 Copyright (C) 2005, 2006, 2007, 2008
3 Free Software Foundation, Inc.
4 This is part of the GNU Fortran manual.
5 For copying conditions, see the file gfortran.texi.
7 Permission is granted to copy, distribute and/or modify this document
8 under the terms of the GNU Free Documentation License, Version 1.2 or
9 any later version published by the Free Software Foundation; with the
10 Invariant Sections being ``GNU General Public License'' and ``Funding
11 Free Software'', the Front-Cover texts being (a) (see below), and with
12 the Back-Cover Texts being (b) (see below). A copy of the license is
13 included in the gfdl(7) man page.
16 Some basic guidelines for editing this document:
18 (1) The intrinsic procedures are to be listed in alphabetical order.
19 (2) The generic name is to be used.
20 (3) The specific names are included in the function index and in a
21 table at the end of the node (See ABS entry).
22 (4) Try to maintain the same style for each entry.
28 \gdef\acos{\mathop{\rm acos}\nolimits}
29 \gdef\asin{\mathop{\rm asin}\nolimits}
30 \gdef\atan{\mathop{\rm atan}\nolimits}
31 \gdef\acosh{\mathop{\rm acosh}\nolimits}
32 \gdef\asinh{\mathop{\rm asinh}\nolimits}
33 \gdef\atanh{\mathop{\rm atanh}\nolimits}
37 @node Intrinsic Procedures
38 @chapter Intrinsic Procedures
39 @cindex intrinsic procedures
42 * Introduction: Introduction to Intrinsics
43 * @code{ABORT}: ABORT, Abort the program
44 * @code{ABS}: ABS, Absolute value
45 * @code{ACCESS}: ACCESS, Checks file access modes
46 * @code{ACHAR}: ACHAR, Character in @acronym{ASCII} collating sequence
47 * @code{ACOS}: ACOS, Arccosine function
48 * @code{ACOSH}: ACOSH, Hyperbolic arccosine function
49 * @code{ADJUSTL}: ADJUSTL, Left adjust a string
50 * @code{ADJUSTR}: ADJUSTR, Right adjust a string
51 * @code{AIMAG}: AIMAG, Imaginary part of complex number
52 * @code{AINT}: AINT, Truncate to a whole number
53 * @code{ALARM}: ALARM, Set an alarm clock
54 * @code{ALL}: ALL, Determine if all values are true
55 * @code{ALLOCATED}: ALLOCATED, Status of allocatable entity
56 * @code{AND}: AND, Bitwise logical AND
57 * @code{ANINT}: ANINT, Nearest whole number
58 * @code{ANY}: ANY, Determine if any values are true
59 * @code{ASIN}: ASIN, Arcsine function
60 * @code{ASINH}: ASINH, Hyperbolic arcsine function
61 * @code{ASSOCIATED}: ASSOCIATED, Status of a pointer or pointer/target pair
62 * @code{ATAN}: ATAN, Arctangent function
63 * @code{ATAN2}: ATAN2, Arctangent function
64 * @code{ATANH}: ATANH, Hyperbolic arctangent function
65 * @code{BESSEL_J0}: BESSEL_J0, Bessel function of the first kind of order 0
66 * @code{BESSEL_J1}: BESSEL_J1, Bessel function of the first kind of order 1
67 * @code{BESSEL_JN}: BESSEL_JN, Bessel function of the first kind
68 * @code{BESSEL_Y0}: BESSEL_Y0, Bessel function of the second kind of order 0
69 * @code{BESSEL_Y1}: BESSEL_Y1, Bessel function of the second kind of order 1
70 * @code{BESSEL_YN}: BESSEL_YN, Bessel function of the second kind
71 * @code{BIT_SIZE}: BIT_SIZE, Bit size inquiry function
72 * @code{BTEST}: BTEST, Bit test function
73 * @code{C_ASSOCIATED}: C_ASSOCIATED, Status of a C pointer
74 * @code{C_F_POINTER}: C_F_POINTER, Convert C into Fortran pointer
75 * @code{C_F_PROCPOINTER}: C_F_PROCPOINTER, Convert C into Fortran procedure pointer
76 * @code{C_FUNLOC}: C_FUNLOC, Obtain the C address of a procedure
77 * @code{C_LOC}: C_LOC, Obtain the C address of an object
78 * @code{C_SIZEOF}: C_SIZEOF, Size in bytes of an expression
79 * @code{CEILING}: CEILING, Integer ceiling function
80 * @code{CHAR}: CHAR, Integer-to-character conversion function
81 * @code{CHDIR}: CHDIR, Change working directory
82 * @code{CHMOD}: CHMOD, Change access permissions of files
83 * @code{CMPLX}: CMPLX, Complex conversion function
84 * @code{COMMAND_ARGUMENT_COUNT}: COMMAND_ARGUMENT_COUNT, Get number of command line arguments
85 * @code{COMPLEX}: COMPLEX, Complex conversion function
86 * @code{CONJG}: CONJG, Complex conjugate function
87 * @code{COS}: COS, Cosine function
88 * @code{COSH}: COSH, Hyperbolic cosine function
89 * @code{COUNT}: COUNT, Count occurrences of TRUE in an array
90 * @code{CPU_TIME}: CPU_TIME, CPU time subroutine
91 * @code{CSHIFT}: CSHIFT, Circular shift elements of an array
92 * @code{CTIME}: CTIME, Subroutine (or function) to convert a time into a string
93 * @code{DATE_AND_TIME}: DATE_AND_TIME, Date and time subroutine
94 * @code{DBLE}: DBLE, Double precision conversion function
95 * @code{DCMPLX}: DCMPLX, Double complex conversion function
96 * @code{DFLOAT}: DFLOAT, Double precision conversion function
97 * @code{DIGITS}: DIGITS, Significant digits function
98 * @code{DIM}: DIM, Positive difference
99 * @code{DOT_PRODUCT}: DOT_PRODUCT, Dot product function
100 * @code{DPROD}: DPROD, Double product function
101 * @code{DREAL}: DREAL, Double real part function
102 * @code{DTIME}: DTIME, Execution time subroutine (or function)
103 * @code{EOSHIFT}: EOSHIFT, End-off shift elements of an array
104 * @code{EPSILON}: EPSILON, Epsilon function
105 * @code{ERF}: ERF, Error function
106 * @code{ERFC}: ERFC, Complementary error function
107 * @code{ERFC_SCALED}: ERFC_SCALED, Exponentially-scaled complementary error function
108 * @code{ETIME}: ETIME, Execution time subroutine (or function)
109 * @code{EXIT}: EXIT, Exit the program with status.
110 * @code{EXP}: EXP, Exponential function
111 * @code{EXPONENT}: EXPONENT, Exponent function
112 * @code{FDATE}: FDATE, Subroutine (or function) to get the current time as a string
113 * @code{FGET}: FGET, Read a single character in stream mode from stdin
114 * @code{FGETC}: FGETC, Read a single character in stream mode
115 * @code{FLOAT}: FLOAT, Convert integer to default real
116 * @code{FLOOR}: FLOOR, Integer floor function
117 * @code{FLUSH}: FLUSH, Flush I/O unit(s)
118 * @code{FNUM}: FNUM, File number function
119 * @code{FPUT}: FPUT, Write a single character in stream mode to stdout
120 * @code{FPUTC}: FPUTC, Write a single character in stream mode
121 * @code{FRACTION}: FRACTION, Fractional part of the model representation
122 * @code{FREE}: FREE, Memory de-allocation subroutine
123 * @code{FSEEK}: FSEEK, Low level file positioning subroutine
124 * @code{FSTAT}: FSTAT, Get file status
125 * @code{FTELL}: FTELL, Current stream position
126 * @code{GAMMA}: GAMMA, Gamma function
127 * @code{GERROR}: GERROR, Get last system error message
128 * @code{GETARG}: GETARG, Get command line arguments
129 * @code{GET_COMMAND}: GET_COMMAND, Get the entire command line
130 * @code{GET_COMMAND_ARGUMENT}: GET_COMMAND_ARGUMENT, Get command line arguments
131 * @code{GETCWD}: GETCWD, Get current working directory
132 * @code{GETENV}: GETENV, Get an environmental variable
133 * @code{GET_ENVIRONMENT_VARIABLE}: GET_ENVIRONMENT_VARIABLE, Get an environmental variable
134 * @code{GETGID}: GETGID, Group ID function
135 * @code{GETLOG}: GETLOG, Get login name
136 * @code{GETPID}: GETPID, Process ID function
137 * @code{GETUID}: GETUID, User ID function
138 * @code{GMTIME}: GMTIME, Convert time to GMT info
139 * @code{HOSTNM}: HOSTNM, Get system host name
140 * @code{HUGE}: HUGE, Largest number of a kind
141 * @code{HYPOT}: HYPOT, Euclidian distance function
142 * @code{IACHAR}: IACHAR, Code in @acronym{ASCII} collating sequence
143 * @code{IAND}: IAND, Bitwise logical and
144 * @code{IARGC}: IARGC, Get the number of command line arguments
145 * @code{IBCLR}: IBCLR, Clear bit
146 * @code{IBITS}: IBITS, Bit extraction
147 * @code{IBSET}: IBSET, Set bit
148 * @code{ICHAR}: ICHAR, Character-to-integer conversion function
149 * @code{IDATE}: IDATE, Current local time (day/month/year)
150 * @code{IEOR}: IEOR, Bitwise logical exclusive or
151 * @code{IERRNO}: IERRNO, Function to get the last system error number
152 * @code{INDEX}: INDEX intrinsic, Position of a substring within a string
153 * @code{INT}: INT, Convert to integer type
154 * @code{INT2}: INT2, Convert to 16-bit integer type
155 * @code{INT8}: INT8, Convert to 64-bit integer type
156 * @code{IOR}: IOR, Bitwise logical or
157 * @code{IRAND}: IRAND, Integer pseudo-random number
158 * @code{IS_IOSTAT_END}: IS_IOSTAT_END, Test for end-of-file value
159 * @code{IS_IOSTAT_EOR}: IS_IOSTAT_EOR, Test for end-of-record value
160 * @code{ISATTY}: ISATTY, Whether a unit is a terminal device
161 * @code{ISHFT}: ISHFT, Shift bits
162 * @code{ISHFTC}: ISHFTC, Shift bits circularly
163 * @code{ISNAN}: ISNAN, Tests for a NaN
164 * @code{ITIME}: ITIME, Current local time (hour/minutes/seconds)
165 * @code{KILL}: KILL, Send a signal to a process
166 * @code{KIND}: KIND, Kind of an entity
167 * @code{LBOUND}: LBOUND, Lower dimension bounds of an array
168 * @code{LEN}: LEN, Length of a character entity
169 * @code{LEN_TRIM}: LEN_TRIM, Length of a character entity without trailing blank characters
170 * @code{LOG_GAMMA}: LOG_GAMMA, Logarithm of the Gamma function
171 * @code{LGE}: LGE, Lexical greater than or equal
172 * @code{LGT}: LGT, Lexical greater than
173 * @code{LINK}: LINK, Create a hard link
174 * @code{LLE}: LLE, Lexical less than or equal
175 * @code{LLT}: LLT, Lexical less than
176 * @code{LNBLNK}: LNBLNK, Index of the last non-blank character in a string
177 * @code{LOC}: LOC, Returns the address of a variable
178 * @code{LOG}: LOG, Logarithm function
179 * @code{LOG10}: LOG10, Base 10 logarithm function
180 * @code{LOGICAL}: LOGICAL, Convert to logical type
181 * @code{LONG}: LONG, Convert to integer type
182 * @code{LSHIFT}: LSHIFT, Left shift bits
183 * @code{LSTAT}: LSTAT, Get file status
184 * @code{LTIME}: LTIME, Convert time to local time info
185 * @code{MALLOC}: MALLOC, Dynamic memory allocation function
186 * @code{MATMUL}: MATMUL, matrix multiplication
187 * @code{MAX}: MAX, Maximum value of an argument list
188 * @code{MAXEXPONENT}: MAXEXPONENT, Maximum exponent of a real kind
189 * @code{MAXLOC}: MAXLOC, Location of the maximum value within an array
190 * @code{MAXVAL}: MAXVAL, Maximum value of an array
191 * @code{MCLOCK}: MCLOCK, Time function
192 * @code{MCLOCK8}: MCLOCK8, Time function (64-bit)
193 * @code{MERGE}: MERGE, Merge arrays
194 * @code{MIN}: MIN, Minimum value of an argument list
195 * @code{MINEXPONENT}: MINEXPONENT, Minimum exponent of a real kind
196 * @code{MINLOC}: MINLOC, Location of the minimum value within an array
197 * @code{MINVAL}: MINVAL, Minimum value of an array
198 * @code{MOD}: MOD, Remainder function
199 * @code{MODULO}: MODULO, Modulo function
200 * @code{MOVE_ALLOC}: MOVE_ALLOC, Move allocation from one object to another
201 * @code{MVBITS}: MVBITS, Move bits from one integer to another
202 * @code{NEAREST}: NEAREST, Nearest representable number
203 * @code{NEW_LINE}: NEW_LINE, New line character
204 * @code{NINT}: NINT, Nearest whole number
205 * @code{NOT}: NOT, Logical negation
206 * @code{NULL}: NULL, Function that returns an disassociated pointer
207 * @code{OR}: OR, Bitwise logical OR
208 * @code{PACK}: PACK, Pack an array into an array of rank one
209 * @code{PERROR}: PERROR, Print system error message
210 * @code{PRECISION}: PRECISION, Decimal precision of a real kind
211 * @code{PRESENT}: PRESENT, Determine whether an optional dummy argument is specified
212 * @code{PRODUCT}: PRODUCT, Product of array elements
213 * @code{RADIX}: RADIX, Base of a data model
214 * @code{RANDOM_NUMBER}: RANDOM_NUMBER, Pseudo-random number
215 * @code{RANDOM_SEED}: RANDOM_SEED, Initialize a pseudo-random number sequence
216 * @code{RAND}: RAND, Real pseudo-random number
217 * @code{RANGE}: RANGE, Decimal exponent range of a real kind
218 * @code{RAN}: RAN, Real pseudo-random number
219 * @code{REAL}: REAL, Convert to real type
220 * @code{RENAME}: RENAME, Rename a file
221 * @code{REPEAT}: REPEAT, Repeated string concatenation
222 * @code{RESHAPE}: RESHAPE, Function to reshape an array
223 * @code{RRSPACING}: RRSPACING, Reciprocal of the relative spacing
224 * @code{RSHIFT}: RSHIFT, Right shift bits
225 * @code{SCALE}: SCALE, Scale a real value
226 * @code{SCAN}: SCAN, Scan a string for the presence of a set of characters
227 * @code{SECNDS}: SECNDS, Time function
228 * @code{SECOND}: SECOND, CPU time function
229 * @code{SELECTED_CHAR_KIND}: SELECTED_CHAR_KIND, Choose character kind
230 * @code{SELECTED_INT_KIND}: SELECTED_INT_KIND, Choose integer kind
231 * @code{SELECTED_REAL_KIND}: SELECTED_REAL_KIND, Choose real kind
232 * @code{SET_EXPONENT}: SET_EXPONENT, Set the exponent of the model
233 * @code{SHAPE}: SHAPE, Determine the shape of an array
234 * @code{SIGN}: SIGN, Sign copying function
235 * @code{SIGNAL}: SIGNAL, Signal handling subroutine (or function)
236 * @code{SIN}: SIN, Sine function
237 * @code{SINH}: SINH, Hyperbolic sine function
238 * @code{SIZE}: SIZE, Function to determine the size of an array
239 * @code{SIZEOF}: SIZEOF, Determine the size in bytes of an expression
240 * @code{SLEEP}: SLEEP, Sleep for the specified number of seconds
241 * @code{SNGL}: SNGL, Convert double precision real to default real
242 * @code{SPACING}: SPACING, Smallest distance between two numbers of a given type
243 * @code{SPREAD}: SPREAD, Add a dimension to an array
244 * @code{SQRT}: SQRT, Square-root function
245 * @code{SRAND}: SRAND, Reinitialize the random number generator
246 * @code{STAT}: STAT, Get file status
247 * @code{SUM}: SUM, Sum of array elements
248 * @code{SYMLNK}: SYMLNK, Create a symbolic link
249 * @code{SYSTEM}: SYSTEM, Execute a shell command
250 * @code{SYSTEM_CLOCK}: SYSTEM_CLOCK, Time function
251 * @code{TAN}: TAN, Tangent function
252 * @code{TANH}: TANH, Hyperbolic tangent function
253 * @code{TIME}: TIME, Time function
254 * @code{TIME8}: TIME8, Time function (64-bit)
255 * @code{TINY}: TINY, Smallest positive number of a real kind
256 * @code{TRANSFER}: TRANSFER, Transfer bit patterns
257 * @code{TRANSPOSE}: TRANSPOSE, Transpose an array of rank two
258 * @code{TRIM}: TRIM, Remove trailing blank characters of a string
259 * @code{TTYNAM}: TTYNAM, Get the name of a terminal device.
260 * @code{UBOUND}: UBOUND, Upper dimension bounds of an array
261 * @code{UMASK}: UMASK, Set the file creation mask
262 * @code{UNLINK}: UNLINK, Remove a file from the file system
263 * @code{UNPACK}: UNPACK, Unpack an array of rank one into an array
264 * @code{VERIFY}: VERIFY, Scan a string for the absence of a set of characters
265 * @code{XOR}: XOR, Bitwise logical exclusive or
268 @node Introduction to Intrinsics
269 @section Introduction to intrinsic procedures
271 The intrinsic procedures provided by GNU Fortran include all of the
272 intrinsic procedures required by the Fortran 95 standard, a set of
273 intrinsic procedures for backwards compatibility with G77, and a
274 selection of intrinsic procedures from the Fortran 2003 and Fortran 2008
275 standards. Any conflict between a description here and a description in
276 either the Fortran 95 standard, the Fortran 2003 standard or the Fortran
277 2008 standard is unintentional, and the standard(s) should be considered
280 The enumeration of the @code{KIND} type parameter is processor defined in
281 the Fortran 95 standard. GNU Fortran defines the default integer type and
282 default real type by @code{INTEGER(KIND=4)} and @code{REAL(KIND=4)},
283 respectively. The standard mandates that both data types shall have
284 another kind, which have more precision. On typical target architectures
285 supported by @command{gfortran}, this kind type parameter is @code{KIND=8}.
286 Hence, @code{REAL(KIND=8)} and @code{DOUBLE PRECISION} are equivalent.
287 In the description of generic intrinsic procedures, the kind type parameter
288 will be specified by @code{KIND=*}, and in the description of specific
289 names for an intrinsic procedure the kind type parameter will be explicitly
290 given (e.g., @code{REAL(KIND=4)} or @code{REAL(KIND=8)}). Finally, for
291 brevity the optional @code{KIND=} syntax will be omitted.
293 Many of the intrinsic procedures take one or more optional arguments.
294 This document follows the convention used in the Fortran 95 standard,
295 and denotes such arguments by square brackets.
297 GNU Fortran offers the @option{-std=f95} and @option{-std=gnu} options,
298 which can be used to restrict the set of intrinsic procedures to a
299 given standard. By default, @command{gfortran} sets the @option{-std=gnu}
300 option, and so all intrinsic procedures described here are accepted. There
301 is one caveat. For a select group of intrinsic procedures, @command{g77}
302 implemented both a function and a subroutine. Both classes
303 have been implemented in @command{gfortran} for backwards compatibility
304 with @command{g77}. It is noted here that these functions and subroutines
305 cannot be intermixed in a given subprogram. In the descriptions that follow,
306 the applicable standard for each intrinsic procedure is noted.
311 @section @code{ABORT} --- Abort the program
313 @cindex program termination, with core dump
314 @cindex terminate program, with core dump
318 @item @emph{Description}:
319 @code{ABORT} causes immediate termination of the program. On operating
320 systems that support a core dump, @code{ABORT} will produce a core dump,
321 which is suitable for debugging purposes.
323 @item @emph{Standard}:
332 @item @emph{Return value}:
335 @item @emph{Example}:
338 integer :: i = 1, j = 2
339 if (i /= j) call abort
340 end program test_abort
343 @item @emph{See also}:
344 @ref{EXIT}, @ref{KILL}
351 @section @code{ABS} --- Absolute value
358 @cindex absolute value
361 @item @emph{Description}:
362 @code{ABS(A)} computes the absolute value of @code{A}.
364 @item @emph{Standard}:
365 Fortran 77 and later, has overloads that are GNU extensions
371 @code{RESULT = ABS(A)}
373 @item @emph{Arguments}:
374 @multitable @columnfractions .15 .70
375 @item @var{A} @tab The type of the argument shall be an @code{INTEGER},
376 @code{REAL}, or @code{COMPLEX}.
379 @item @emph{Return value}:
380 The return value is of the same type and
381 kind as the argument except the return value is @code{REAL} for a
382 @code{COMPLEX} argument.
384 @item @emph{Example}:
389 complex :: z = (-1.e0,0.e0)
396 @item @emph{Specific names}:
397 @multitable @columnfractions .20 .20 .20 .25
398 @item Name @tab Argument @tab Return type @tab Standard
399 @item @code{CABS(A)} @tab @code{COMPLEX(4) Z} @tab @code{REAL(4)} @tab Fortran 77 and later
400 @item @code{DABS(A)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
401 @item @code{IABS(A)} @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)} @tab Fortran 77 and later
402 @item @code{ZABS(A)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
403 @item @code{CDABS(A)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
410 @section @code{ACCESS} --- Checks file access modes
412 @cindex file system, access mode
415 @item @emph{Description}:
416 @code{ACCESS(NAME, MODE)} checks whether the file @var{NAME}
417 exists, is readable, writable or executable. Except for the
418 executable check, @code{ACCESS} can be replaced by
419 Fortran 95's @code{INQUIRE}.
421 @item @emph{Standard}:
428 @code{RESULT = ACCESS(NAME, MODE)}
430 @item @emph{Arguments}:
431 @multitable @columnfractions .15 .70
432 @item @var{NAME} @tab Scalar @code{CHARACTER} of default kind with the
433 file name. Tailing blank are ignored unless the character @code{achar(0)}
434 is present, then all characters up to and excluding @code{achar(0)} are
436 @item @var{MODE} @tab Scalar @code{CHARACTER} of default kind with the
437 file access mode, may be any concatenation of @code{"r"} (readable),
438 @code{"w"} (writable) and @code{"x"} (executable), or @code{" "} to check
442 @item @emph{Return value}:
443 Returns a scalar @code{INTEGER}, which is @code{0} if the file is
444 accessible in the given mode; otherwise or if an invalid argument
445 has been given for @code{MODE} the value @code{1} is returned.
447 @item @emph{Example}:
451 character(len=*), parameter :: file = 'test.dat'
452 character(len=*), parameter :: file2 = 'test.dat '//achar(0)
453 if(access(file,' ') == 0) print *, trim(file),' is exists'
454 if(access(file,'r') == 0) print *, trim(file),' is readable'
455 if(access(file,'w') == 0) print *, trim(file),' is writable'
456 if(access(file,'x') == 0) print *, trim(file),' is executable'
457 if(access(file2,'rwx') == 0) &
458 print *, trim(file2),' is readable, writable and executable'
459 end program access_test
461 @item @emph{Specific names}:
462 @item @emph{See also}:
469 @section @code{ACHAR} --- Character in @acronym{ASCII} collating sequence
471 @cindex @acronym{ASCII} collating sequence
472 @cindex collating sequence, @acronym{ASCII}
475 @item @emph{Description}:
476 @code{ACHAR(I)} returns the character located at position @code{I}
477 in the @acronym{ASCII} collating sequence.
479 @item @emph{Standard}:
480 Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later
486 @code{RESULT = ACHAR(I [, KIND])}
488 @item @emph{Arguments}:
489 @multitable @columnfractions .15 .70
490 @item @var{I} @tab The type shall be @code{INTEGER}.
491 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
492 expression indicating the kind parameter of
496 @item @emph{Return value}:
497 The return value is of type @code{CHARACTER} with a length of one.
498 If the @var{KIND} argument is present, the return value is of the
499 specified kind and of the default kind otherwise.
501 @item @emph{Example}:
506 end program test_achar
510 See @ref{ICHAR} for a discussion of converting between numerical values
511 and formatted string representations.
513 @item @emph{See also}:
514 @ref{CHAR}, @ref{IACHAR}, @ref{ICHAR}
521 @section @code{ACOS} --- Arccosine function
524 @cindex trigonometric function, cosine, inverse
525 @cindex cosine, inverse
528 @item @emph{Description}:
529 @code{ACOS(X)} computes the arccosine of @var{X} (inverse of @code{COS(X)}).
531 @item @emph{Standard}:
538 @code{RESULT = ACOS(X)}
540 @item @emph{Arguments}:
541 @multitable @columnfractions .15 .70
542 @item @var{X} @tab The type shall be @code{REAL} with a magnitude that is
546 @item @emph{Return value}:
547 The return value is of type @code{REAL} and it lies in the
548 range @math{ 0 \leq \acos(x) \leq \pi}. The return value if of the same
551 @item @emph{Example}:
554 real(8) :: x = 0.866_8
556 end program test_acos
559 @item @emph{Specific names}:
560 @multitable @columnfractions .20 .20 .20 .25
561 @item Name @tab Argument @tab Return type @tab Standard
562 @item @code{DACOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
565 @item @emph{See also}:
566 Inverse function: @ref{COS}
573 @section @code{ACOSH} --- Hyperbolic arccosine function
576 @cindex area hyperbolic cosine
577 @cindex hyperbolic arccosine
578 @cindex hyperbolic function, cosine, inverse
579 @cindex cosine, hyperbolic, inverse
582 @item @emph{Description}:
583 @code{ACOSH(X)} computes the hyperbolic arccosine of @var{X} (inverse of
586 @item @emph{Standard}:
587 Fortran 2008 and later
593 @code{RESULT = ACOSH(X)}
595 @item @emph{Arguments}:
596 @multitable @columnfractions .15 .70
597 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
600 @item @emph{Return value}:
601 The return value has the same type and kind as @var{X}
603 @item @emph{Example}:
606 REAL(8), DIMENSION(3) :: x = (/ 1.0, 2.0, 3.0 /)
611 @item @emph{Specific names}:
612 @multitable @columnfractions .20 .20 .20 .25
613 @item Name @tab Argument @tab Return type @tab Standard
614 @item @code{DACOSH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
617 @item @emph{See also}:
618 Inverse function: @ref{COSH}
624 @section @code{ADJUSTL} --- Left adjust a string
626 @cindex string, adjust left
627 @cindex adjust string
630 @item @emph{Description}:
631 @code{ADJUSTL(STRING)} will left adjust a string by removing leading spaces.
632 Spaces are inserted at the end of the string as needed.
634 @item @emph{Standard}:
641 @code{RESULT = ADJUSTL(STRING)}
643 @item @emph{Arguments}:
644 @multitable @columnfractions .15 .70
645 @item @var{STRING} @tab The type shall be @code{CHARACTER}.
648 @item @emph{Return value}:
649 The return value is of type @code{CHARACTER} and of the same kind as
650 @var{STRING} where leading spaces are removed and the same number of
651 spaces are inserted on the end of @var{STRING}.
653 @item @emph{Example}:
656 character(len=20) :: str = ' gfortran'
659 end program test_adjustl
662 @item @emph{See also}:
663 @ref{ADJUSTR}, @ref{TRIM}
669 @section @code{ADJUSTR} --- Right adjust a string
671 @cindex string, adjust right
672 @cindex adjust string
675 @item @emph{Description}:
676 @code{ADJUSTR(STRING)} will right adjust a string by removing trailing spaces.
677 Spaces are inserted at the start of the string as needed.
679 @item @emph{Standard}:
686 @code{RESULT = ADJUSTR(STRING)}
688 @item @emph{Arguments}:
689 @multitable @columnfractions .15 .70
690 @item @var{STR} @tab The type shall be @code{CHARACTER}.
693 @item @emph{Return value}:
694 The return value is of type @code{CHARACTER} and of the same kind as
695 @var{STRING} where trailing spaces are removed and the same number of
696 spaces are inserted at the start of @var{STRING}.
698 @item @emph{Example}:
701 character(len=20) :: str = 'gfortran'
704 end program test_adjustr
707 @item @emph{See also}:
708 @ref{ADJUSTL}, @ref{TRIM}
714 @section @code{AIMAG} --- Imaginary part of complex number
719 @cindex complex numbers, imaginary part
722 @item @emph{Description}:
723 @code{AIMAG(Z)} yields the imaginary part of complex argument @code{Z}.
724 The @code{IMAG(Z)} and @code{IMAGPART(Z)} intrinsic functions are provided
725 for compatibility with @command{g77}, and their use in new code is
726 strongly discouraged.
728 @item @emph{Standard}:
729 Fortran 77 and later, has overloads that are GNU extensions
735 @code{RESULT = AIMAG(Z)}
737 @item @emph{Arguments}:
738 @multitable @columnfractions .15 .70
739 @item @var{Z} @tab The type of the argument shall be @code{COMPLEX}.
742 @item @emph{Return value}:
743 The return value is of type @code{REAL} with the
744 kind type parameter of the argument.
746 @item @emph{Example}:
751 z4 = cmplx(1.e0_4, 0.e0_4)
752 z8 = cmplx(0.e0_8, 1.e0_8)
753 print *, aimag(z4), dimag(z8)
754 end program test_aimag
757 @item @emph{Specific names}:
758 @multitable @columnfractions .20 .20 .20 .25
759 @item Name @tab Argument @tab Return type @tab Standard
760 @item @code{DIMAG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{REAL(8)} @tab GNU extension
761 @item @code{IMAG(Z)} @tab @code{COMPLEX Z} @tab @code{REAL} @tab GNU extension
762 @item @code{IMAGPART(Z)} @tab @code{COMPLEX Z} @tab @code{REAL} @tab GNU extension
769 @section @code{AINT} --- Truncate to a whole number
773 @cindex rounding, floor
776 @item @emph{Description}:
777 @code{AINT(A [, KIND])} truncates its argument to a whole number.
779 @item @emph{Standard}:
786 @code{RESULT = AINT(A [, KIND])}
788 @item @emph{Arguments}:
789 @multitable @columnfractions .15 .70
790 @item @var{A} @tab The type of the argument shall be @code{REAL}.
791 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
792 expression indicating the kind parameter of
796 @item @emph{Return value}:
797 The return value is of type @code{REAL} with the kind type parameter of the
798 argument if the optional @var{KIND} is absent; otherwise, the kind
799 type parameter will be given by @var{KIND}. If the magnitude of
800 @var{X} is less than one, @code{AINT(X)} returns zero. If the
801 magnitude is equal to or greater than one then it returns the largest
802 whole number that does not exceed its magnitude. The sign is the same
803 as the sign of @var{X}.
805 @item @emph{Example}:
812 print *, aint(x4), dint(x8)
814 end program test_aint
817 @item @emph{Specific names}:
818 @multitable @columnfractions .20 .20 .20 .25
819 @item Name @tab Argument @tab Return type @tab Standard
820 @item @code{DINT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
827 @section @code{ALARM} --- Execute a routine after a given delay
829 @cindex delayed execution
832 @item @emph{Description}:
833 @code{ALARM(SECONDS, HANDLER [, STATUS])} causes external subroutine @var{HANDLER}
834 to be executed after a delay of @var{SECONDS} by using @code{alarm(2)} to
835 set up a signal and @code{signal(2)} to catch it. If @var{STATUS} is
836 supplied, it will be returned with the number of seconds remaining until
837 any previously scheduled alarm was due to be delivered, or zero if there
838 was no previously scheduled alarm.
840 @item @emph{Standard}:
847 @code{CALL ALARM(SECONDS, HANDLER [, STATUS])}
849 @item @emph{Arguments}:
850 @multitable @columnfractions .15 .70
851 @item @var{SECONDS} @tab The type of the argument shall be a scalar
852 @code{INTEGER}. It is @code{INTENT(IN)}.
853 @item @var{HANDLER} @tab Signal handler (@code{INTEGER FUNCTION} or
854 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar. The scalar
855 values may be either @code{SIG_IGN=1} to ignore the alarm generated
856 or @code{SIG_DFL=0} to set the default action. It is @code{INTENT(IN)}.
857 @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
858 variable of the default @code{INTEGER} kind. It is @code{INTENT(OUT)}.
861 @item @emph{Example}:
864 external handler_print
866 call alarm (3, handler_print, i)
869 end program test_alarm
871 This will cause the external routine @var{handler_print} to be called
878 @section @code{ALL} --- All values in @var{MASK} along @var{DIM} are true
880 @cindex array, apply condition
881 @cindex array, condition testing
884 @item @emph{Description}:
885 @code{ALL(MASK [, DIM])} determines if all the values are true in @var{MASK}
886 in the array along dimension @var{DIM}.
888 @item @emph{Standard}:
892 Transformational function
895 @code{RESULT = ALL(MASK [, DIM])}
897 @item @emph{Arguments}:
898 @multitable @columnfractions .15 .70
899 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL} and
900 it shall not be scalar.
901 @item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer
902 with a value that lies between one and the rank of @var{MASK}.
905 @item @emph{Return value}:
906 @code{ALL(MASK)} returns a scalar value of type @code{LOGICAL} where
907 the kind type parameter is the same as the kind type parameter of
908 @var{MASK}. If @var{DIM} is present, then @code{ALL(MASK, DIM)} returns
909 an array with the rank of @var{MASK} minus 1. The shape is determined from
910 the shape of @var{MASK} where the @var{DIM} dimension is elided.
914 @code{ALL(MASK)} is true if all elements of @var{MASK} are true.
915 It also is true if @var{MASK} has zero size; otherwise, it is false.
917 If the rank of @var{MASK} is one, then @code{ALL(MASK,DIM)} is equivalent
918 to @code{ALL(MASK)}. If the rank is greater than one, then @code{ALL(MASK,DIM)}
919 is determined by applying @code{ALL} to the array sections.
922 @item @emph{Example}:
926 l = all((/.true., .true., .true./))
931 integer a(2,3), b(2,3)
935 print *, all(a .eq. b, 1)
936 print *, all(a .eq. b, 2)
937 end subroutine section
945 @section @code{ALLOCATED} --- Status of an allocatable entity
947 @cindex allocation, status
950 @item @emph{Description}:
951 @code{ALLOCATED(ARRAY)} checks the status of whether @var{X} is allocated.
953 @item @emph{Standard}:
960 @code{RESULT = ALLOCATED(ARRAY)}
962 @item @emph{Arguments}:
963 @multitable @columnfractions .15 .70
964 @item @var{ARRAY} @tab The argument shall be an @code{ALLOCATABLE} array.
967 @item @emph{Return value}:
968 The return value is a scalar @code{LOGICAL} with the default logical
969 kind type parameter. If @var{ARRAY} is allocated, @code{ALLOCATED(ARRAY)}
970 is @code{.TRUE.}; otherwise, it returns @code{.FALSE.}
972 @item @emph{Example}:
974 program test_allocated
976 real(4), allocatable :: x(:)
977 if (allocated(x) .eqv. .false.) allocate(x(i))
978 end program test_allocated
985 @section @code{AND} --- Bitwise logical AND
987 @cindex bitwise logical and
988 @cindex logical and, bitwise
991 @item @emph{Description}:
992 Bitwise logical @code{AND}.
994 This intrinsic routine is provided for backwards compatibility with
995 GNU Fortran 77. For integer arguments, programmers should consider
996 the use of the @ref{IAND} intrinsic defined by the Fortran standard.
998 @item @emph{Standard}:
1004 @item @emph{Syntax}:
1005 @code{RESULT = AND(I, J)}
1007 @item @emph{Arguments}:
1008 @multitable @columnfractions .15 .70
1009 @item @var{I} @tab The type shall be either a scalar @code{INTEGER}
1010 type or a scalar @code{LOGICAL} type.
1011 @item @var{J} @tab The type shall be the same as the type of @var{I}.
1014 @item @emph{Return value}:
1015 The return type is either a scalar @code{INTEGER} or a scalar
1016 @code{LOGICAL}. If the kind type parameters differ, then the
1017 smaller kind type is implicitly converted to larger kind, and the
1018 return has the larger kind.
1020 @item @emph{Example}:
1023 LOGICAL :: T = .TRUE., F = .FALSE.
1025 DATA a / Z'F' /, b / Z'3' /
1027 WRITE (*,*) AND(T, T), AND(T, F), AND(F, T), AND(F, F)
1028 WRITE (*,*) AND(a, b)
1032 @item @emph{See also}:
1033 Fortran 95 elemental function: @ref{IAND}
1039 @section @code{ANINT} --- Nearest whole number
1043 @cindex rounding, ceiling
1046 @item @emph{Description}:
1047 @code{ANINT(A [, KIND])} rounds its argument to the nearest whole number.
1049 @item @emph{Standard}:
1050 Fortran 77 and later
1055 @item @emph{Syntax}:
1056 @code{RESULT = ANINT(A [, KIND])}
1058 @item @emph{Arguments}:
1059 @multitable @columnfractions .15 .70
1060 @item @var{A} @tab The type of the argument shall be @code{REAL}.
1061 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
1062 expression indicating the kind parameter of
1066 @item @emph{Return value}:
1067 The return value is of type real with the kind type parameter of the
1068 argument if the optional @var{KIND} is absent; otherwise, the kind
1069 type parameter will be given by @var{KIND}. If @var{A} is greater than
1070 zero, @code{ANINT(A)} returns @code{AINT(X+0.5)}. If @var{A} is
1071 less than or equal to zero then it returns @code{AINT(X-0.5)}.
1073 @item @emph{Example}:
1080 print *, anint(x4), dnint(x8)
1082 end program test_anint
1085 @item @emph{Specific names}:
1086 @multitable @columnfractions .20 .20 .20 .25
1087 @item Name @tab Argument @tab Return type @tab Standard
1088 @item @code{DNINT(A)} @tab @code{REAL(8) A} @tab @code{REAL(8)} @tab Fortran 77 and later
1095 @section @code{ANY} --- Any value in @var{MASK} along @var{DIM} is true
1097 @cindex array, apply condition
1098 @cindex array, condition testing
1101 @item @emph{Description}:
1102 @code{ANY(MASK [, DIM])} determines if any of the values in the logical array
1103 @var{MASK} along dimension @var{DIM} are @code{.TRUE.}.
1105 @item @emph{Standard}:
1106 Fortran 95 and later
1109 Transformational function
1111 @item @emph{Syntax}:
1112 @code{RESULT = ANY(MASK [, DIM])}
1114 @item @emph{Arguments}:
1115 @multitable @columnfractions .15 .70
1116 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL} and
1117 it shall not be scalar.
1118 @item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer
1119 with a value that lies between one and the rank of @var{MASK}.
1122 @item @emph{Return value}:
1123 @code{ANY(MASK)} returns a scalar value of type @code{LOGICAL} where
1124 the kind type parameter is the same as the kind type parameter of
1125 @var{MASK}. If @var{DIM} is present, then @code{ANY(MASK, DIM)} returns
1126 an array with the rank of @var{MASK} minus 1. The shape is determined from
1127 the shape of @var{MASK} where the @var{DIM} dimension is elided.
1131 @code{ANY(MASK)} is true if any element of @var{MASK} is true;
1132 otherwise, it is false. It also is false if @var{MASK} has zero size.
1134 If the rank of @var{MASK} is one, then @code{ANY(MASK,DIM)} is equivalent
1135 to @code{ANY(MASK)}. If the rank is greater than one, then @code{ANY(MASK,DIM)}
1136 is determined by applying @code{ANY} to the array sections.
1139 @item @emph{Example}:
1143 l = any((/.true., .true., .true./))
1148 integer a(2,3), b(2,3)
1152 print *, any(a .eq. b, 1)
1153 print *, any(a .eq. b, 2)
1154 end subroutine section
1155 end program test_any
1162 @section @code{ASIN} --- Arcsine function
1165 @cindex trigonometric function, sine, inverse
1166 @cindex sine, inverse
1169 @item @emph{Description}:
1170 @code{ASIN(X)} computes the arcsine of its @var{X} (inverse of @code{SIN(X)}).
1172 @item @emph{Standard}:
1173 Fortran 77 and later
1178 @item @emph{Syntax}:
1179 @code{RESULT = ASIN(X)}
1181 @item @emph{Arguments}:
1182 @multitable @columnfractions .15 .70
1183 @item @var{X} @tab The type shall be @code{REAL}, and a magnitude that is
1187 @item @emph{Return value}:
1188 The return value is of type @code{REAL} and it lies in the
1189 range @math{-\pi / 2 \leq \asin (x) \leq \pi / 2}. The kind type
1190 parameter is the same as @var{X}.
1192 @item @emph{Example}:
1195 real(8) :: x = 0.866_8
1197 end program test_asin
1200 @item @emph{Specific names}:
1201 @multitable @columnfractions .20 .20 .20 .25
1202 @item Name @tab Argument @tab Return type @tab Standard
1203 @item @code{DASIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
1206 @item @emph{See also}:
1207 Inverse function: @ref{SIN}
1214 @section @code{ASINH} --- Hyperbolic arcsine function
1217 @cindex area hyperbolic sine
1218 @cindex hyperbolic arcsine
1219 @cindex hyperbolic function, sine, inverse
1220 @cindex sine, hyperbolic, inverse
1223 @item @emph{Description}:
1224 @code{ASINH(X)} computes the hyperbolic arcsine of @var{X} (inverse of @code{SINH(X)}).
1226 @item @emph{Standard}:
1227 Fortran 2008 and later
1232 @item @emph{Syntax}:
1233 @code{RESULT = ASINH(X)}
1235 @item @emph{Arguments}:
1236 @multitable @columnfractions .15 .70
1237 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
1240 @item @emph{Return value}:
1241 The return value is of the same type and kind as @var{X}.
1243 @item @emph{Example}:
1246 REAL(8), DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1247 WRITE (*,*) ASINH(x)
1251 @item @emph{Specific names}:
1252 @multitable @columnfractions .20 .20 .20 .25
1253 @item Name @tab Argument @tab Return type @tab Standard
1254 @item @code{DASINH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension.
1257 @item @emph{See also}:
1258 Inverse function: @ref{SINH}
1264 @section @code{ASSOCIATED} --- Status of a pointer or pointer/target pair
1266 @cindex pointer, status
1267 @cindex association status
1270 @item @emph{Description}:
1271 @code{ASSOCIATED(POINTER [, TARGET])} determines the status of the pointer
1272 @var{POINTER} or if @var{POINTER} is associated with the target @var{TARGET}.
1274 @item @emph{Standard}:
1275 Fortran 95 and later
1280 @item @emph{Syntax}:
1281 @code{RESULT = ASSOCIATED(POINTER [, TARGET])}
1283 @item @emph{Arguments}:
1284 @multitable @columnfractions .15 .70
1285 @item @var{POINTER} @tab @var{POINTER} shall have the @code{POINTER} attribute
1286 and it can be of any type.
1287 @item @var{TARGET} @tab (Optional) @var{TARGET} shall be a pointer or
1288 a target. It must have the same type, kind type parameter, and
1289 array rank as @var{POINTER}.
1291 The association status of neither @var{POINTER} nor @var{TARGET} shall be
1294 @item @emph{Return value}:
1295 @code{ASSOCIATED(POINTER)} returns a scalar value of type @code{LOGICAL(4)}.
1296 There are several cases:
1298 @item (A) When the optional @var{TARGET} is not present then
1299 @code{ASSOCIATED(POINTER)} is true if @var{POINTER} is associated with a target; otherwise, it returns false.
1300 @item (B) If @var{TARGET} is present and a scalar target, the result is true if
1301 @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
1302 disassociated, the result is false.
1303 @item (C) If @var{TARGET} is present and an array target, the result is true if
1304 @var{TARGET} and @var{POINTER} have the same shape, are not zero-sized arrays,
1305 are arrays whose elements are not zero-sized storage sequences, and
1306 @var{TARGET} and @var{POINTER} occupy the same storage units in array element
1308 As in case(B), the result is false, if @var{POINTER} is disassociated.
1309 @item (D) If @var{TARGET} is present and an scalar pointer, the result is true
1310 if @var{TARGET} is associated with @var{POINTER}, the target associated with
1311 @var{TARGET} are not zero-sized storage sequences and occupy the same storage
1313 The result is false, if either @var{TARGET} or @var{POINTER} is disassociated.
1314 @item (E) If @var{TARGET} is present and an array pointer, the result is true if
1315 target associated with @var{POINTER} and the target associated with @var{TARGET}
1316 have the same shape, are not zero-sized arrays, are arrays whose elements are
1317 not zero-sized storage sequences, and @var{TARGET} and @var{POINTER} occupy
1318 the same storage units in array element order.
1319 The result is false, if either @var{TARGET} or @var{POINTER} is disassociated.
1322 @item @emph{Example}:
1324 program test_associated
1326 real, target :: tgt(2) = (/1., 2./)
1327 real, pointer :: ptr(:)
1329 if (associated(ptr) .eqv. .false.) call abort
1330 if (associated(ptr,tgt) .eqv. .false.) call abort
1331 end program test_associated
1334 @item @emph{See also}:
1341 @section @code{ATAN} --- Arctangent function
1344 @cindex trigonometric function, tangent, inverse
1345 @cindex tangent, inverse
1348 @item @emph{Description}:
1349 @code{ATAN(X)} computes the arctangent of @var{X}.
1351 @item @emph{Standard}:
1352 Fortran 77 and later
1357 @item @emph{Syntax}:
1358 @code{RESULT = ATAN(X)}
1360 @item @emph{Arguments}:
1361 @multitable @columnfractions .15 .70
1362 @item @var{X} @tab The type shall be @code{REAL}.
1365 @item @emph{Return value}:
1366 The return value is of type @code{REAL} and it lies in the
1367 range @math{ - \pi / 2 \leq \atan (x) \leq \pi / 2}.
1369 @item @emph{Example}:
1372 real(8) :: x = 2.866_8
1374 end program test_atan
1377 @item @emph{Specific names}:
1378 @multitable @columnfractions .20 .20 .20 .25
1379 @item Name @tab Argument @tab Return type @tab Standard
1380 @item @code{DATAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
1383 @item @emph{See also}:
1384 Inverse function: @ref{TAN}
1391 @section @code{ATAN2} --- Arctangent function
1394 @cindex trigonometric function, tangent, inverse
1395 @cindex tangent, inverse
1398 @item @emph{Description}:
1399 @code{ATAN2(Y, X)} computes the arctangent of the complex number
1402 @item @emph{Standard}:
1403 Fortran 77 and later
1408 @item @emph{Syntax}:
1409 @code{RESULT = ATAN2(Y, X)}
1411 @item @emph{Arguments}:
1412 @multitable @columnfractions .15 .70
1413 @item @var{Y} @tab The type shall be @code{REAL}.
1414 @item @var{X} @tab The type and kind type parameter shall be the same as @var{Y}.
1415 If @var{Y} is zero, then @var{X} must be nonzero.
1418 @item @emph{Return value}:
1419 The return value has the same type and kind type parameter as @var{Y}.
1420 It is the principal value of the complex number @math{X + i Y}. If
1421 @var{X} is nonzero, then it lies in the range @math{-\pi \le \atan (x) \leq \pi}.
1422 The sign is positive if @var{Y} is positive. If @var{Y} is zero, then
1423 the return value is zero if @var{X} is positive and @math{\pi} if @var{X}
1424 is negative. Finally, if @var{X} is zero, then the magnitude of the result
1427 @item @emph{Example}:
1430 real(4) :: x = 1.e0_4, y = 0.5e0_4
1432 end program test_atan2
1435 @item @emph{Specific names}:
1436 @multitable @columnfractions .20 .20 .20 .25
1437 @item Name @tab Argument @tab Return type @tab Standard
1438 @item @code{DATAN2(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
1445 @section @code{ATANH} --- Hyperbolic arctangent function
1448 @cindex area hyperbolic tangent
1449 @cindex hyperbolic arctangent
1450 @cindex hyperbolic function, tangent, inverse
1451 @cindex tangent, hyperbolic, inverse
1454 @item @emph{Description}:
1455 @code{ATANH(X)} computes the hyperbolic arctangent of @var{X} (inverse
1458 @item @emph{Standard}:
1459 Fortran 2008 and later
1464 @item @emph{Syntax}:
1465 @code{RESULT = ATANH(X)}
1467 @item @emph{Arguments}:
1468 @multitable @columnfractions .15 .70
1469 @item @var{X} @tab The type shall be @code{REAL} or @code{COMPLEX}.
1472 @item @emph{Return value}:
1473 The return value has same type and kind as @var{X}.
1475 @item @emph{Example}:
1478 REAL, DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1479 WRITE (*,*) ATANH(x)
1483 @item @emph{Specific names}:
1484 @multitable @columnfractions .20 .20 .20 .25
1485 @item Name @tab Argument @tab Return type @tab Standard
1486 @item @code{DATANH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1489 @item @emph{See also}:
1490 Inverse function: @ref{TANH}
1496 @section @code{BESSEL_J0} --- Bessel function of the first kind of order 0
1500 @cindex Bessel function, first kind
1503 @item @emph{Description}:
1504 @code{BESSEL_J0(X)} computes the Bessel function of the first kind of
1505 order 0 of @var{X}. This function is available under the name
1506 @code{BESJ0} as a GNU extension.
1508 @item @emph{Standard}:
1509 Fortran 2008 and later
1514 @item @emph{Syntax}:
1515 @code{RESULT = BESSEL_J0(X)}
1517 @item @emph{Arguments}:
1518 @multitable @columnfractions .15 .70
1519 @item @var{X} @tab The type shall be @code{REAL}, and it shall be scalar.
1522 @item @emph{Return value}:
1523 The return value is of type @code{REAL} and lies in the
1524 range @math{ - 0.4027... \leq Bessel (0,x) \leq 1}. It has the same
1527 @item @emph{Example}:
1530 real(8) :: x = 0.0_8
1532 end program test_besj0
1535 @item @emph{Specific names}:
1536 @multitable @columnfractions .20 .20 .20 .25
1537 @item Name @tab Argument @tab Return type @tab Standard
1538 @item @code{DBESJ0(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1545 @section @code{BESSEL_J1} --- Bessel function of the first kind of order 1
1549 @cindex Bessel function, first kind
1552 @item @emph{Description}:
1553 @code{BESSEL_J1(X)} computes the Bessel function of the first kind of
1554 order 1 of @var{X}. This function is available under the name
1555 @code{BESJ1} as a GNU extension.
1557 @item @emph{Standard}:
1563 @item @emph{Syntax}:
1564 @code{RESULT = BESSEL_J1(X)}
1566 @item @emph{Arguments}:
1567 @multitable @columnfractions .15 .70
1568 @item @var{X} @tab The type shall be @code{REAL}, and it shall be scalar.
1571 @item @emph{Return value}:
1572 The return value is of type @code{REAL} and it lies in the
1573 range @math{ - 0.5818... \leq Bessel (0,x) \leq 0.5818 }. It has the same
1576 @item @emph{Example}:
1579 real(8) :: x = 1.0_8
1581 end program test_besj1
1584 @item @emph{Specific names}:
1585 @multitable @columnfractions .20 .20 .20 .25
1586 @item Name @tab Argument @tab Return type @tab Standard
1587 @item @code{DBESJ1(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1594 @section @code{BESSEL_JN} --- Bessel function of the first kind
1598 @cindex Bessel function, first kind
1601 @item @emph{Description}:
1602 @code{BESSEL_JN(N, X)} computes the Bessel function of the first kind of
1603 order @var{N} of @var{X}. This function is available under the name
1604 @code{BESJN} as a GNU extension.
1606 If both arguments are arrays, their ranks and shapes shall conform.
1608 @item @emph{Standard}:
1609 Fortran 2008 and later
1614 @item @emph{Syntax}:
1615 @code{RESULT = BESSEL_JN(N, X)}
1617 @item @emph{Arguments}:
1618 @multitable @columnfractions .15 .70
1619 @item @var{N} @tab Shall be a scalar or an array of type @code{INTEGER}.
1620 @item @var{X} @tab Shall be a scalar or an array of type @code{REAL}.
1623 @item @emph{Return value}:
1624 The return value is a scalar of type @code{REAL}. It has the same
1627 @item @emph{Example}:
1630 real(8) :: x = 1.0_8
1632 end program test_besjn
1635 @item @emph{Specific names}:
1636 @multitable @columnfractions .20 .20 .20 .25
1637 @item Name @tab Argument @tab Return type @tab Standard
1638 @item @code{DBESJN(X)} @tab @code{INTEGER N} @tab @code{REAL(8)} @tab GNU extension
1639 @item @tab @code{REAL(8) X} @tab @tab
1646 @section @code{BESSEL_Y0} --- Bessel function of the second kind of order 0
1650 @cindex Bessel function, second kind
1653 @item @emph{Description}:
1654 @code{BESSEL_Y0(X)} computes the Bessel function of the second kind of
1655 order 0 of @var{X}. This function is available under the name
1656 @code{BESY0} as a GNU extension.
1658 @item @emph{Standard}:
1659 Fortran 2008 and later
1664 @item @emph{Syntax}:
1665 @code{RESULT = BESSEL_Y0(X)}
1667 @item @emph{Arguments}:
1668 @multitable @columnfractions .15 .70
1669 @item @var{X} @tab The type shall be @code{REAL}, and it shall be scalar.
1672 @item @emph{Return value}:
1673 The return value is a scalar of type @code{REAL}. It has the same
1676 @item @emph{Example}:
1679 real(8) :: x = 0.0_8
1681 end program test_besy0
1684 @item @emph{Specific names}:
1685 @multitable @columnfractions .20 .20 .20 .25
1686 @item Name @tab Argument @tab Return type @tab Standard
1687 @item @code{DBESY0(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1694 @section @code{BESSEL_Y1} --- Bessel function of the second kind of order 1
1698 @cindex Bessel function, second kind
1701 @item @emph{Description}:
1702 @code{BESSEL_Y1(X)} computes the Bessel function of the second kind of
1703 order 1 of @var{X}. This function is available under the name
1704 @code{BESY1} as a GNU extension.
1706 @item @emph{Standard}:
1707 Fortran 2008 and later
1712 @item @emph{Syntax}:
1713 @code{RESULT = BESSEL_Y1(X)}
1715 @item @emph{Arguments}:
1716 @multitable @columnfractions .15 .70
1717 @item @var{X} @tab The type shall be @code{REAL}, and it shall be scalar.
1720 @item @emph{Return value}:
1721 The return value is a scalar of type @code{REAL}. It has the same
1724 @item @emph{Example}:
1727 real(8) :: x = 1.0_8
1729 end program test_besy1
1732 @item @emph{Specific names}:
1733 @multitable @columnfractions .20 .20 .20 .25
1734 @item Name @tab Argument @tab Return type @tab Standard
1735 @item @code{DBESY1(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1742 @section @code{BESSEL_YN} --- Bessel function of the second kind
1746 @cindex Bessel function, second kind
1749 @item @emph{Description}:
1750 @code{BESSEL_YN(N, X)} computes the Bessel function of the second kind of
1751 order @var{N} of @var{X}. This function is available under the name
1752 @code{BESYN} as a GNU extension.
1754 If both arguments are arrays, their ranks and shapes shall conform.
1756 @item @emph{Standard}:
1757 Fortran 2008 and later
1762 @item @emph{Syntax}:
1763 @code{RESULT = BESSEL_YN(N, X)}
1765 @item @emph{Arguments}:
1766 @multitable @columnfractions .15 .70
1767 @item @var{N} @tab Shall be a scalar or an array of type @code{INTEGER}.
1768 @item @var{X} @tab Shall be a scalar or an array of type @code{REAL}.
1771 @item @emph{Return value}:
1772 The return value is a scalar of type @code{REAL}. It has the same
1775 @item @emph{Example}:
1778 real(8) :: x = 1.0_8
1780 end program test_besyn
1783 @item @emph{Specific names}:
1784 @multitable @columnfractions .20 .20 .20 .25
1785 @item Name @tab Argument @tab Return type @tab Standard
1786 @item @code{DBESYN(N,X)} @tab @code{INTEGER N} @tab @code{REAL(8)} @tab GNU extension
1787 @item @tab @code{REAL(8) X} @tab @tab
1794 @section @code{BIT_SIZE} --- Bit size inquiry function
1796 @cindex bits, number of
1797 @cindex size of a variable, in bits
1800 @item @emph{Description}:
1801 @code{BIT_SIZE(I)} returns the number of bits (integer precision plus sign bit)
1802 represented by the type of @var{I}.
1804 @item @emph{Standard}:
1805 Fortran 95 and later
1810 @item @emph{Syntax}:
1811 @code{RESULT = BIT_SIZE(I)}
1813 @item @emph{Arguments}:
1814 @multitable @columnfractions .15 .70
1815 @item @var{I} @tab The type shall be @code{INTEGER}.
1818 @item @emph{Return value}:
1819 The return value is of type @code{INTEGER}
1821 @item @emph{Example}:
1823 program test_bit_size
1828 end program test_bit_size
1835 @section @code{BTEST} --- Bit test function
1837 @cindex bits, testing
1840 @item @emph{Description}:
1841 @code{BTEST(I,POS)} returns logical @code{.TRUE.} if the bit at @var{POS}
1844 @item @emph{Standard}:
1845 Fortran 95 and later
1850 @item @emph{Syntax}:
1851 @code{RESULT = BTEST(I, POS)}
1853 @item @emph{Arguments}:
1854 @multitable @columnfractions .15 .70
1855 @item @var{I} @tab The type shall be @code{INTEGER}.
1856 @item @var{POS} @tab The type shall be @code{INTEGER}.
1859 @item @emph{Return value}:
1860 The return value is of type @code{LOGICAL}
1862 @item @emph{Example}:
1865 integer :: i = 32768 + 1024 + 64
1869 bool = btest(i, pos)
1872 end program test_btest
1878 @section @code{C_ASSOCIATED} --- Status of a C pointer
1879 @fnindex C_ASSOCIATED
1880 @cindex association status, C pointer
1881 @cindex pointer, C association status
1884 @item @emph{Description}:
1885 @code{C_ASSOCIATED(c_prt_1[, c_ptr_2])} determines the status of the C pointer
1886 @var{c_ptr_1} or if @var{c_ptr_1} is associated with the target @var{c_ptr_2}.
1888 @item @emph{Standard}:
1889 Fortran 2003 and later
1894 @item @emph{Syntax}:
1895 @code{RESULT = C_ASSOCIATED(c_prt_1[, c_ptr_2])}
1897 @item @emph{Arguments}:
1898 @multitable @columnfractions .15 .70
1899 @item @var{c_ptr_1} @tab Scalar of the type @code{C_PTR} or @code{C_FUNPTR}.
1900 @item @var{c_ptr_2} @tab (Optional) Scalar of the same type as @var{c_ptr_1}.
1903 @item @emph{Return value}:
1904 The return value is of type @code{LOGICAL}; it is @code{.false.} if either
1905 @var{c_ptr_1} is a C NULL pointer or if @var{c_ptr1} and @var{c_ptr_2}
1906 point to different addresses.
1908 @item @emph{Example}:
1910 subroutine association_test(a,b)
1911 use iso_c_binding, only: c_associated, c_loc, c_ptr
1915 if(c_associated(b, c_loc(a))) &
1916 stop 'b and a do not point to same target'
1917 end subroutine association_test
1920 @item @emph{See also}:
1921 @ref{C_LOC}, @ref{C_FUNLOC}
1926 @section @code{C_FUNLOC} --- Obtain the C address of a procedure
1928 @cindex pointer, C address of procedures
1931 @item @emph{Description}:
1932 @code{C_FUNLOC(x)} determines the C address of the argument.
1934 @item @emph{Standard}:
1935 Fortran 2003 and later
1940 @item @emph{Syntax}:
1941 @code{RESULT = C_FUNLOC(x)}
1943 @item @emph{Arguments}:
1944 @multitable @columnfractions .15 .70
1945 @item @var{x} @tab Interoperable function or pointer to such function.
1948 @item @emph{Return value}:
1949 The return value is of type @code{C_FUNPTR} and contains the C address
1952 @item @emph{Example}:
1958 subroutine sub(a) bind(c)
1968 subroutine my_routine(p) bind(c,name='myC_func')
1970 type(c_funptr), intent(in) :: p
1973 call my_routine(c_funloc(sub))
1977 @item @emph{See also}:
1978 @ref{C_ASSOCIATED}, @ref{C_LOC}, @ref{C_F_POINTER}, @ref{C_F_PROCPOINTER}
1982 @node C_F_PROCPOINTER
1983 @section @code{C_F_PROCPOINTER} --- Convert C into Fortran procedure pointer
1984 @fnindex C_F_PROCPOINTER
1985 @cindex pointer, C address of pointers
1988 @item @emph{Description}:
1989 @code{C_F_PROCPOINTER(CPTR, FPTR)} Assign the target of the C function pointer
1990 @var{CPTR} to the Fortran procedure pointer @var{FPTR}.
1992 Note: Due to the currently lacking support of procedure pointers in GNU Fortran
1993 this function is not fully operable.
1995 @item @emph{Standard}:
1996 Fortran 2003 and later
2001 @item @emph{Syntax}:
2002 @code{CALL C_F_PROCPOINTER(cptr, fptr)}
2004 @item @emph{Arguments}:
2005 @multitable @columnfractions .15 .70
2006 @item @var{CPTR} @tab scalar of the type @code{C_FUNPTR}. It is
2008 @item @var{FPTR} @tab procedure pointer interoperable with @var{cptr}. It is
2012 @item @emph{Example}:
2020 real(c_float), intent(in) :: a
2021 real(c_float) :: func
2025 function getIterFunc() bind(c,name="getIterFunc")
2027 type(c_funptr) :: getIterFunc
2030 type(c_funptr) :: cfunptr
2031 procedure(func), pointer :: myFunc
2032 cfunptr = getIterFunc()
2033 call c_f_procpointer(cfunptr, myFunc)
2037 @item @emph{See also}:
2038 @ref{C_LOC}, @ref{C_F_POINTER}
2043 @section @code{C_F_POINTER} --- Convert C into Fortran pointer
2044 @fnindex C_F_POINTER
2045 @cindex pointer, convert C to Fortran
2048 @item @emph{Description}:
2049 @code{C_F_POINTER(CPTR, FPTR[, SHAPE])} Assign the target the C pointer
2050 @var{CPTR} to the Fortran pointer @var{FPTR} and specify its
2053 @item @emph{Standard}:
2054 Fortran 2003 and later
2059 @item @emph{Syntax}:
2060 @code{CALL C_F_POINTER(CPTR, FPTR[, SHAPE])}
2062 @item @emph{Arguments}:
2063 @multitable @columnfractions .15 .70
2064 @item @var{CPTR} @tab scalar of the type @code{C_PTR}. It is
2066 @item @var{FPTR} @tab pointer interoperable with @var{cptr}. It is
2068 @item @var{SHAPE} @tab (Optional) Rank-one array of type @code{INTEGER}
2069 with @code{INTENT(IN)}. It shall be present
2070 if and only if @var{fptr} is an array. The size
2071 must be equal to the rank of @var{fptr}.
2074 @item @emph{Example}:
2080 subroutine my_routine(p) bind(c,name='myC_func')
2082 type(c_ptr), intent(out) :: p
2086 real,pointer :: a(:)
2087 call my_routine(cptr)
2088 call c_f_pointer(cptr, a, [12])
2092 @item @emph{See also}:
2093 @ref{C_LOC}, @ref{C_F_PROCPOINTER}
2098 @section @code{C_LOC} --- Obtain the C address of an object
2100 @cindex procedure pointer, convert C to Fortran
2103 @item @emph{Description}:
2104 @code{C_LOC(X)} determines the C address of the argument.
2106 @item @emph{Standard}:
2107 Fortran 2003 and later
2112 @item @emph{Syntax}:
2113 @code{RESULT = C_LOC(X)}
2115 @item @emph{Arguments}:
2116 @multitable @columnfractions .15 .70
2117 @item @var{X} @tab Associated scalar pointer or interoperable scalar
2118 or allocated allocatable variable with @code{TARGET}
2122 @item @emph{Return value}:
2123 The return value is of type @code{C_PTR} and contains the C address
2126 @item @emph{Example}:
2128 subroutine association_test(a,b)
2129 use iso_c_binding, only: c_associated, c_loc, c_ptr
2133 if(c_associated(b, c_loc(a))) &
2134 stop 'b and a do not point to same target'
2135 end subroutine association_test
2138 @item @emph{See also}:
2139 @ref{C_ASSOCIATED}, @ref{C_FUNLOC}, @ref{C_F_POINTER}, @ref{C_F_PROCPOINTER}
2144 @section @code{C_SIZEOF} --- Size in bytes of an expression
2146 @cindex expression size
2147 @cindex size of an expression
2150 @item @emph{Description}:
2151 @code{C_SIZEOF(X)} calculates the number of bytes of storage the
2152 expression @code{X} occupies.
2154 @item @emph{Standard}:
2160 @item @emph{Syntax}:
2161 @code{N = C_SIZEOF(X)}
2163 @item @emph{Arguments}:
2164 @multitable @columnfractions .15 .70
2165 @item @var{X} @tab The argument shall be of any type, rank or shape.
2168 @item @emph{Return value}:
2169 The return value is of type integer and of the system-dependent kind
2170 @var{C_SIZE_T} (from the @var{ISO_C_BINDING} module). Its value is the
2171 number of bytes occupied by the argument. If the argument has the
2172 @code{POINTER} attribute, the number of bytes of the storage area pointed
2173 to is returned. If the argument is of a derived type with @code{POINTER}
2174 or @code{ALLOCATABLE} components, the return value doesn't account for
2175 the sizes of the data pointed to by these components.
2177 @item @emph{Example}:
2181 real(c_float) :: r, s(5)
2182 print *, (c_sizeof(s)/c_sizeof(r) == 5)
2185 The example will print @code{.TRUE.} unless you are using a platform
2186 where default @code{REAL} variables are unusually padded.
2188 @item @emph{See also}:
2194 @section @code{CEILING} --- Integer ceiling function
2197 @cindex rounding, ceiling
2200 @item @emph{Description}:
2201 @code{CEILING(A)} returns the least integer greater than or equal to @var{A}.
2203 @item @emph{Standard}:
2204 Fortran 95 and later
2209 @item @emph{Syntax}:
2210 @code{RESULT = CEILING(A [, KIND])}
2212 @item @emph{Arguments}:
2213 @multitable @columnfractions .15 .70
2214 @item @var{A} @tab The type shall be @code{REAL}.
2215 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
2216 expression indicating the kind parameter of
2220 @item @emph{Return value}:
2221 The return value is of type @code{INTEGER(KIND)} if @var{KIND} is present
2222 and a default-kind @code{INTEGER} otherwise.
2224 @item @emph{Example}:
2226 program test_ceiling
2229 print *, ceiling(x) ! returns 64
2230 print *, ceiling(y) ! returns -63
2231 end program test_ceiling
2234 @item @emph{See also}:
2235 @ref{FLOOR}, @ref{NINT}
2242 @section @code{CHAR} --- Character conversion function
2244 @cindex conversion, to character
2247 @item @emph{Description}:
2248 @code{CHAR(I [, KIND])} returns the character represented by the integer @var{I}.
2250 @item @emph{Standard}:
2251 Fortran 77 and later
2256 @item @emph{Syntax}:
2257 @code{RESULT = CHAR(I [, KIND])}
2259 @item @emph{Arguments}:
2260 @multitable @columnfractions .15 .70
2261 @item @var{I} @tab The type shall be @code{INTEGER}.
2262 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
2263 expression indicating the kind parameter of
2267 @item @emph{Return value}:
2268 The return value is of type @code{CHARACTER(1)}
2270 @item @emph{Example}:
2276 print *, i, c ! returns 'J'
2277 end program test_char
2281 See @ref{ICHAR} for a discussion of converting between numerical values
2282 and formatted string representations.
2284 @item @emph{See also}:
2285 @ref{ACHAR}, @ref{IACHAR}, @ref{ICHAR}
2292 @section @code{CHDIR} --- Change working directory
2294 @cindex system, working directory
2297 @item @emph{Description}:
2298 Change current working directory to a specified path.
2300 This intrinsic is provided in both subroutine and function forms; however,
2301 only one form can be used in any given program unit.
2303 @item @emph{Standard}:
2307 Subroutine, function
2309 @item @emph{Syntax}:
2310 @multitable @columnfractions .80
2311 @item @code{CALL CHDIR(NAME [, STATUS])}
2312 @item @code{STATUS = CHDIR(NAME)}
2315 @item @emph{Arguments}:
2316 @multitable @columnfractions .15 .70
2317 @item @var{NAME} @tab The type shall be @code{CHARACTER} of default
2318 kind and shall specify a valid path within the
2320 @item @var{STATUS} @tab (Optional) @code{INTEGER} status flag of the default
2321 kind. Returns 0 on success, and a system specific
2322 and nonzero error code otherwise.
2325 @item @emph{Example}:
2328 CHARACTER(len=255) :: path
2330 WRITE(*,*) TRIM(path)
2333 WRITE(*,*) TRIM(path)
2337 @item @emph{See also}:
2344 @section @code{CHMOD} --- Change access permissions of files
2346 @cindex file system, change access mode
2349 @item @emph{Description}:
2350 @code{CHMOD} changes the permissions of a file. This function invokes
2351 @code{/bin/chmod} and might therefore not work on all platforms.
2353 This intrinsic is provided in both subroutine and function forms; however,
2354 only one form can be used in any given program unit.
2356 @item @emph{Standard}:
2360 Subroutine, function
2362 @item @emph{Syntax}:
2363 @multitable @columnfractions .80
2364 @item @code{CALL CHMOD(NAME, MODE[, STATUS])}
2365 @item @code{STATUS = CHMOD(NAME, MODE)}
2368 @item @emph{Arguments}:
2369 @multitable @columnfractions .15 .70
2371 @item @var{NAME} @tab Scalar @code{CHARACTER} of default kind with the
2372 file name. Trailing blanks are ignored unless the character
2373 @code{achar(0)} is present, then all characters up to and excluding
2374 @code{achar(0)} are used as the file name.
2376 @item @var{MODE} @tab Scalar @code{CHARACTER} of default kind giving the
2377 file permission. @var{MODE} uses the same syntax as the @var{MODE}
2378 argument of @code{/bin/chmod}.
2380 @item @var{STATUS} @tab (optional) scalar @code{INTEGER}, which is
2381 @code{0} on success and nonzero otherwise.
2384 @item @emph{Return value}:
2385 In either syntax, @var{STATUS} is set to @code{0} on success and nonzero
2388 @item @emph{Example}:
2389 @code{CHMOD} as subroutine
2394 call chmod('test.dat','u+x',status)
2395 print *, 'Status: ', status
2396 end program chmod_test
2398 @code{CHMOD} as function:
2403 status = chmod('test.dat','u+x')
2404 print *, 'Status: ', status
2405 end program chmod_test
2413 @section @code{CMPLX} --- Complex conversion function
2415 @cindex complex numbers, conversion to
2416 @cindex conversion, to complex
2419 @item @emph{Description}:
2420 @code{CMPLX(X [, Y [, KIND]])} returns a complex number where @var{X} is converted to
2421 the real component. If @var{Y} is present it is converted to the imaginary
2422 component. If @var{Y} is not present then the imaginary component is set to
2423 0.0. If @var{X} is complex then @var{Y} must not be present.
2425 @item @emph{Standard}:
2426 Fortran 77 and later
2431 @item @emph{Syntax}:
2432 @code{RESULT = CMPLX(X [, Y [, KIND]])}
2434 @item @emph{Arguments}:
2435 @multitable @columnfractions .15 .70
2436 @item @var{X} @tab The type may be @code{INTEGER}, @code{REAL},
2438 @item @var{Y} @tab (Optional; only allowed if @var{X} is not
2439 @code{COMPLEX}.) May be @code{INTEGER}
2441 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
2442 expression indicating the kind parameter of
2446 @item @emph{Return value}:
2447 The return value is of @code{COMPLEX} type, with a kind equal to
2448 @var{KIND} if it is specified. If @var{KIND} is not specified, the
2449 result is of the default @code{COMPLEX} kind, regardless of the kinds of
2450 @var{X} and @var{Y}.
2452 @item @emph{Example}:
2459 print *, z, cmplx(x)
2460 end program test_cmplx
2463 @item @emph{See also}:
2469 @node COMMAND_ARGUMENT_COUNT
2470 @section @code{COMMAND_ARGUMENT_COUNT} --- Get number of command line arguments
2471 @fnindex COMMAND_ARGUMENT_COUNT
2472 @cindex command-line arguments
2473 @cindex command-line arguments, number of
2474 @cindex arguments, to program
2477 @item @emph{Description}:
2478 @code{COMMAND_ARGUMENT_COUNT()} returns the number of arguments passed on the
2479 command line when the containing program was invoked.
2481 @item @emph{Standard}:
2482 Fortran 2003 and later
2487 @item @emph{Syntax}:
2488 @code{RESULT = COMMAND_ARGUMENT_COUNT()}
2490 @item @emph{Arguments}:
2491 @multitable @columnfractions .15 .70
2495 @item @emph{Return value}:
2496 The return value is of type @code{INTEGER(4)}
2498 @item @emph{Example}:
2500 program test_command_argument_count
2502 count = command_argument_count()
2504 end program test_command_argument_count
2507 @item @emph{See also}:
2508 @ref{GET_COMMAND}, @ref{GET_COMMAND_ARGUMENT}
2514 @section @code{COMPLEX} --- Complex conversion function
2516 @cindex complex numbers, conversion to
2517 @cindex conversion, to complex
2520 @item @emph{Description}:
2521 @code{COMPLEX(X, Y)} returns a complex number where @var{X} is converted
2522 to the real component and @var{Y} is converted to the imaginary
2525 @item @emph{Standard}:
2531 @item @emph{Syntax}:
2532 @code{RESULT = COMPLEX(X, Y)}
2534 @item @emph{Arguments}:
2535 @multitable @columnfractions .15 .70
2536 @item @var{X} @tab The type may be @code{INTEGER} or @code{REAL}.
2537 @item @var{Y} @tab The type may be @code{INTEGER} or @code{REAL}.
2540 @item @emph{Return value}:
2541 If @var{X} and @var{Y} are both of @code{INTEGER} type, then the return
2542 value is of default @code{COMPLEX} type.
2544 If @var{X} and @var{Y} are of @code{REAL} type, or one is of @code{REAL}
2545 type and one is of @code{INTEGER} type, then the return value is of
2546 @code{COMPLEX} type with a kind equal to that of the @code{REAL}
2547 argument with the highest precision.
2549 @item @emph{Example}:
2551 program test_complex
2554 print *, complex(i, x)
2555 end program test_complex
2558 @item @emph{See also}:
2565 @section @code{CONJG} --- Complex conjugate function
2568 @cindex complex conjugate
2571 @item @emph{Description}:
2572 @code{CONJG(Z)} returns the conjugate of @var{Z}. If @var{Z} is @code{(x, y)}
2573 then the result is @code{(x, -y)}
2575 @item @emph{Standard}:
2576 Fortran 77 and later, has overloads that are GNU extensions
2581 @item @emph{Syntax}:
2584 @item @emph{Arguments}:
2585 @multitable @columnfractions .15 .70
2586 @item @var{Z} @tab The type shall be @code{COMPLEX}.
2589 @item @emph{Return value}:
2590 The return value is of type @code{COMPLEX}.
2592 @item @emph{Example}:
2595 complex :: z = (2.0, 3.0)
2596 complex(8) :: dz = (2.71_8, -3.14_8)
2601 end program test_conjg
2604 @item @emph{Specific names}:
2605 @multitable @columnfractions .20 .20 .20 .25
2606 @item Name @tab Argument @tab Return type @tab Standard
2607 @item @code{DCONJG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
2614 @section @code{COS} --- Cosine function
2620 @cindex trigonometric function, cosine
2624 @item @emph{Description}:
2625 @code{COS(X)} computes the cosine of @var{X}.
2627 @item @emph{Standard}:
2628 Fortran 77 and later, has overloads that are GNU extensions
2633 @item @emph{Syntax}:
2634 @code{RESULT = COS(X)}
2636 @item @emph{Arguments}:
2637 @multitable @columnfractions .15 .70
2638 @item @var{X} @tab The type shall be @code{REAL} or
2642 @item @emph{Return value}:
2643 The return value is of type @code{REAL} and it lies in the
2644 range @math{ -1 \leq \cos (x) \leq 1}. The kind type
2645 parameter is the same as @var{X}.
2647 @item @emph{Example}:
2652 end program test_cos
2655 @item @emph{Specific names}:
2656 @multitable @columnfractions .20 .20 .20 .25
2657 @item Name @tab Argument @tab Return type @tab Standard
2658 @item @code{DCOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
2659 @item @code{CCOS(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab Fortran 77 and later
2660 @item @code{ZCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
2661 @item @code{CDCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
2664 @item @emph{See also}:
2665 Inverse function: @ref{ACOS}
2672 @section @code{COSH} --- Hyperbolic cosine function
2675 @cindex hyperbolic cosine
2676 @cindex hyperbolic function, cosine
2677 @cindex cosine, hyperbolic
2680 @item @emph{Description}:
2681 @code{COSH(X)} computes the hyperbolic cosine of @var{X}.
2683 @item @emph{Standard}:
2684 Fortran 77 and later
2689 @item @emph{Syntax}:
2692 @item @emph{Arguments}:
2693 @multitable @columnfractions .15 .70
2694 @item @var{X} @tab The type shall be @code{REAL}.
2697 @item @emph{Return value}:
2698 The return value is of type @code{REAL} and it is positive
2699 (@math{ \cosh (x) \geq 0 }. The return value is of the same
2702 @item @emph{Example}:
2705 real(8) :: x = 1.0_8
2707 end program test_cosh
2710 @item @emph{Specific names}:
2711 @multitable @columnfractions .20 .20 .20 .25
2712 @item Name @tab Argument @tab Return type @tab Standard
2713 @item @code{DCOSH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
2716 @item @emph{See also}:
2717 Inverse function: @ref{ACOSH}
2724 @section @code{COUNT} --- Count function
2726 @cindex array, conditionally count elements
2727 @cindex array, element counting
2728 @cindex array, number of elements
2731 @item @emph{Description}:
2733 @code{COUNT(MASK [, DIM [, KIND]])} counts the number of @code{.TRUE.}
2734 elements of @var{MASK} along the dimension of @var{DIM}. If @var{DIM} is
2735 omitted it is taken to be @code{1}. @var{DIM} is a scaler of type
2736 @code{INTEGER} in the range of @math{1 /leq DIM /leq n)} where @math{n}
2737 is the rank of @var{MASK}.
2739 @item @emph{Standard}:
2740 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
2743 Transformational function
2745 @item @emph{Syntax}:
2746 @code{RESULT = COUNT(MASK [, DIM [, KIND]])}
2748 @item @emph{Arguments}:
2749 @multitable @columnfractions .15 .70
2750 @item @var{MASK} @tab The type shall be @code{LOGICAL}.
2751 @item @var{DIM} @tab (Optional) The type shall be @code{INTEGER}.
2752 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
2753 expression indicating the kind parameter of
2757 @item @emph{Return value}:
2758 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
2759 @var{KIND} is absent, the return value is of default integer kind.
2760 The result has a rank equal to that of @var{MASK}.
2762 @item @emph{Example}:
2765 integer, dimension(2,3) :: a, b
2766 logical, dimension(2,3) :: mask
2767 a = reshape( (/ 1, 2, 3, 4, 5, 6 /), (/ 2, 3 /))
2768 b = reshape( (/ 0, 7, 3, 4, 5, 8 /), (/ 2, 3 /))
2769 print '(3i3)', a(1,:)
2770 print '(3i3)', a(2,:)
2772 print '(3i3)', b(1,:)
2773 print '(3i3)', b(2,:)
2776 print '(3l3)', mask(1,:)
2777 print '(3l3)', mask(2,:)
2779 print '(3i3)', count(mask)
2781 print '(3i3)', count(mask, 1)
2783 print '(3i3)', count(mask, 2)
2784 end program test_count
2791 @section @code{CPU_TIME} --- CPU elapsed time in seconds
2793 @cindex time, elapsed
2796 @item @emph{Description}:
2797 Returns a @code{REAL} value representing the elapsed CPU time in
2798 seconds. This is useful for testing segments of code to determine
2801 If a time source is available, time will be reported with microsecond
2802 resolution. If no time source is available, @var{TIME} is set to
2805 Note that @var{TIME} may contain a, system dependent, arbitrary offset
2806 and may not start with @code{0.0}. For @code{CPU_TIME}, the absolute
2807 value is meaningless, only differences between subsequent calls to
2808 this subroutine, as shown in the example below, should be used.
2811 @item @emph{Standard}:
2812 Fortran 95 and later
2817 @item @emph{Syntax}:
2818 @code{CALL CPU_TIME(TIME)}
2820 @item @emph{Arguments}:
2821 @multitable @columnfractions .15 .70
2822 @item @var{TIME} @tab The type shall be @code{REAL} with @code{INTENT(OUT)}.
2825 @item @emph{Return value}:
2828 @item @emph{Example}:
2830 program test_cpu_time
2831 real :: start, finish
2832 call cpu_time(start)
2833 ! put code to test here
2834 call cpu_time(finish)
2835 print '("Time = ",f6.3," seconds.")',finish-start
2836 end program test_cpu_time
2839 @item @emph{See also}:
2840 @ref{SYSTEM_CLOCK}, @ref{DATE_AND_TIME}
2846 @section @code{CSHIFT} --- Circular shift elements of an array
2848 @cindex array, shift circularly
2849 @cindex array, permutation
2850 @cindex array, rotate
2853 @item @emph{Description}:
2854 @code{CSHIFT(ARRAY, SHIFT [, DIM])} performs a circular shift on elements of
2855 @var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is omitted it is
2856 taken to be @code{1}. @var{DIM} is a scaler of type @code{INTEGER} in the
2857 range of @math{1 /leq DIM /leq n)} where @math{n} is the rank of @var{ARRAY}.
2858 If the rank of @var{ARRAY} is one, then all elements of @var{ARRAY} are shifted
2859 by @var{SHIFT} places. If rank is greater than one, then all complete rank one
2860 sections of @var{ARRAY} along the given dimension are shifted. Elements
2861 shifted out one end of each rank one section are shifted back in the other end.
2863 @item @emph{Standard}:
2864 Fortran 95 and later
2867 Transformational function
2869 @item @emph{Syntax}:
2870 @code{RESULT = CSHIFT(ARRAY, SHIFT [, DIM])}
2872 @item @emph{Arguments}:
2873 @multitable @columnfractions .15 .70
2874 @item @var{ARRAY} @tab Shall be an array of any type.
2875 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
2876 @item @var{DIM} @tab The type shall be @code{INTEGER}.
2879 @item @emph{Return value}:
2880 Returns an array of same type and rank as the @var{ARRAY} argument.
2882 @item @emph{Example}:
2885 integer, dimension(3,3) :: a
2886 a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
2887 print '(3i3)', a(1,:)
2888 print '(3i3)', a(2,:)
2889 print '(3i3)', a(3,:)
2890 a = cshift(a, SHIFT=(/1, 2, -1/), DIM=2)
2892 print '(3i3)', a(1,:)
2893 print '(3i3)', a(2,:)
2894 print '(3i3)', a(3,:)
2895 end program test_cshift
2902 @section @code{CTIME} --- Convert a time into a string
2904 @cindex time, conversion to string
2905 @cindex conversion, to string
2908 @item @emph{Description}:
2909 @code{CTIME} converts a system time value, such as returned by
2910 @code{TIME8()}, to a string of the form @samp{Sat Aug 19 18:13:14 1995}.
2912 This intrinsic is provided in both subroutine and function forms; however,
2913 only one form can be used in any given program unit.
2915 @item @emph{Standard}:
2919 Subroutine, function
2921 @item @emph{Syntax}:
2922 @multitable @columnfractions .80
2923 @item @code{CALL CTIME(TIME, RESULT)}.
2924 @item @code{RESULT = CTIME(TIME)}, (not recommended).
2927 @item @emph{Arguments}:
2928 @multitable @columnfractions .15 .70
2929 @item @var{TIME} @tab The type shall be of type @code{INTEGER(KIND=8)}.
2930 @item @var{RESULT} @tab The type shall be of type @code{CHARACTER} and
2934 @item @emph{Return value}:
2935 The converted date and time as a string.
2937 @item @emph{Example}:
2941 character(len=30) :: date
2944 ! Do something, main part of the program
2947 print *, 'Program was started on ', date
2948 end program test_ctime
2951 @item @emph{See Also}:
2952 @ref{GMTIME}, @ref{LTIME}, @ref{TIME}, @ref{TIME8}
2958 @section @code{DATE_AND_TIME} --- Date and time subroutine
2959 @fnindex DATE_AND_TIME
2960 @cindex date, current
2961 @cindex current date
2962 @cindex time, current
2963 @cindex current time
2966 @item @emph{Description}:
2967 @code{DATE_AND_TIME(DATE, TIME, ZONE, VALUES)} gets the corresponding date and
2968 time information from the real-time system clock. @var{DATE} is
2969 @code{INTENT(OUT)} and has form ccyymmdd. @var{TIME} is @code{INTENT(OUT)} and
2970 has form hhmmss.sss. @var{ZONE} is @code{INTENT(OUT)} and has form (+-)hhmm,
2971 representing the difference with respect to Coordinated Universal Time (UTC).
2972 Unavailable time and date parameters return blanks.
2974 @var{VALUES} is @code{INTENT(OUT)} and provides the following:
2976 @multitable @columnfractions .15 .30 .40
2977 @item @tab @code{VALUE(1)}: @tab The year
2978 @item @tab @code{VALUE(2)}: @tab The month
2979 @item @tab @code{VALUE(3)}: @tab The day of the month
2980 @item @tab @code{VALUE(4)}: @tab Time difference with UTC in minutes
2981 @item @tab @code{VALUE(5)}: @tab The hour of the day
2982 @item @tab @code{VALUE(6)}: @tab The minutes of the hour
2983 @item @tab @code{VALUE(7)}: @tab The seconds of the minute
2984 @item @tab @code{VALUE(8)}: @tab The milliseconds of the second
2987 @item @emph{Standard}:
2988 Fortran 95 and later
2993 @item @emph{Syntax}:
2994 @code{CALL DATE_AND_TIME([DATE, TIME, ZONE, VALUES])}
2996 @item @emph{Arguments}:
2997 @multitable @columnfractions .15 .70
2998 @item @var{DATE} @tab (Optional) The type shall be @code{CHARACTER(LEN=8)}
2999 or larger, and of default kind.
3000 @item @var{TIME} @tab (Optional) The type shall be @code{CHARACTER(LEN=10)}
3001 or larger, and of default kind.
3002 @item @var{ZONE} @tab (Optional) The type shall be @code{CHARACTER(LEN=5)}
3003 or larger, and of default kind.
3004 @item @var{VALUES}@tab (Optional) The type shall be @code{INTEGER(8)}.
3007 @item @emph{Return value}:
3010 @item @emph{Example}:
3012 program test_time_and_date
3013 character(8) :: date
3014 character(10) :: time
3015 character(5) :: zone
3016 integer,dimension(8) :: values
3017 ! using keyword arguments
3018 call date_and_time(date,time,zone,values)
3019 call date_and_time(DATE=date,ZONE=zone)
3020 call date_and_time(TIME=time)
3021 call date_and_time(VALUES=values)
3022 print '(a,2x,a,2x,a)', date, time, zone
3023 print '(8i5))', values
3024 end program test_time_and_date
3027 @item @emph{See also}:
3028 @ref{CPU_TIME}, @ref{SYSTEM_CLOCK}
3034 @section @code{DBLE} --- Double conversion function
3036 @cindex conversion, to real
3039 @item @emph{Description}:
3040 @code{DBLE(A)} Converts @var{A} to double precision real type.
3042 @item @emph{Standard}:
3043 Fortran 77 and later
3048 @item @emph{Syntax}:
3049 @code{RESULT = DBLE(A)}
3051 @item @emph{Arguments}:
3052 @multitable @columnfractions .15 .70
3053 @item @var{A} @tab The type shall be @code{INTEGER}, @code{REAL},
3057 @item @emph{Return value}:
3058 The return value is of type double precision real.
3060 @item @emph{Example}:
3065 complex :: z = (2.3,1.14)
3066 print *, dble(x), dble(i), dble(z)
3067 end program test_dble
3070 @item @emph{See also}:
3071 @ref{DFLOAT}, @ref{FLOAT}, @ref{REAL}
3077 @section @code{DCMPLX} --- Double complex conversion function
3079 @cindex complex numbers, conversion to
3080 @cindex conversion, to complex
3083 @item @emph{Description}:
3084 @code{DCMPLX(X [,Y])} returns a double complex number where @var{X} is
3085 converted to the real component. If @var{Y} is present it is converted to the
3086 imaginary component. If @var{Y} is not present then the imaginary component is
3087 set to 0.0. If @var{X} is complex then @var{Y} must not be present.
3089 @item @emph{Standard}:
3095 @item @emph{Syntax}:
3096 @code{RESULT = DCMPLX(X [, Y])}
3098 @item @emph{Arguments}:
3099 @multitable @columnfractions .15 .70
3100 @item @var{X} @tab The type may be @code{INTEGER}, @code{REAL},
3102 @item @var{Y} @tab (Optional if @var{X} is not @code{COMPLEX}.) May be
3103 @code{INTEGER} or @code{REAL}.
3106 @item @emph{Return value}:
3107 The return value is of type @code{COMPLEX(8)}
3109 @item @emph{Example}:
3119 print *, dcmplx(x,i)
3120 end program test_dcmplx
3127 @section @code{DFLOAT} --- Double conversion function
3129 @cindex conversion, to real
3132 @item @emph{Description}:
3133 @code{DFLOAT(A)} Converts @var{A} to double precision real type.
3135 @item @emph{Standard}:
3141 @item @emph{Syntax}:
3142 @code{RESULT = DFLOAT(A)}
3144 @item @emph{Arguments}:
3145 @multitable @columnfractions .15 .70
3146 @item @var{A} @tab The type shall be @code{INTEGER}.
3149 @item @emph{Return value}:
3150 The return value is of type double precision real.
3152 @item @emph{Example}:
3157 end program test_dfloat
3160 @item @emph{See also}:
3161 @ref{DBLE}, @ref{FLOAT}, @ref{REAL}
3167 @section @code{DIGITS} --- Significant digits function
3169 @cindex model representation, significant digits
3172 @item @emph{Description}:
3173 @code{DIGITS(X)} returns the number of significant digits of the internal model
3174 representation of @var{X}. For example, on a system using a 32-bit
3175 floating point representation, a default real number would likely return 24.
3177 @item @emph{Standard}:
3178 Fortran 95 and later
3183 @item @emph{Syntax}:
3184 @code{RESULT = DIGITS(X)}
3186 @item @emph{Arguments}:
3187 @multitable @columnfractions .15 .70
3188 @item @var{X} @tab The type may be @code{INTEGER} or @code{REAL}.
3191 @item @emph{Return value}:
3192 The return value is of type @code{INTEGER}.
3194 @item @emph{Example}:
3197 integer :: i = 12345
3203 end program test_digits
3210 @section @code{DIM} --- Positive difference
3214 @cindex positive difference
3217 @item @emph{Description}:
3218 @code{DIM(X,Y)} returns the difference @code{X-Y} if the result is positive;
3219 otherwise returns zero.
3221 @item @emph{Standard}:
3222 Fortran 77 and later
3227 @item @emph{Syntax}:
3228 @code{RESULT = DIM(X, Y)}
3230 @item @emph{Arguments}:
3231 @multitable @columnfractions .15 .70
3232 @item @var{X} @tab The type shall be @code{INTEGER} or @code{REAL}
3233 @item @var{Y} @tab The type shall be the same type and kind as @var{X}.
3236 @item @emph{Return value}:
3237 The return value is of type @code{INTEGER} or @code{REAL}.
3239 @item @emph{Example}:
3245 x = dim(4.345_8, 2.111_8)
3248 end program test_dim
3251 @item @emph{Specific names}:
3252 @multitable @columnfractions .20 .20 .20 .25
3253 @item Name @tab Argument @tab Return type @tab Standard
3254 @item @code{IDIM(X,Y)} @tab @code{INTEGER(4) X,Y} @tab @code{INTEGER(4)} @tab Fortran 77 and later
3255 @item @code{DDIM(X,Y)} @tab @code{REAL(8) X,Y} @tab @code{REAL(8)} @tab Fortran 77 and later
3262 @section @code{DOT_PRODUCT} --- Dot product function
3263 @fnindex DOT_PRODUCT
3265 @cindex vector product
3266 @cindex product, vector
3269 @item @emph{Description}:
3270 @code{DOT_PRODUCT(VECTOR_A, VECTOR_B)} computes the dot product multiplication
3271 of two vectors @var{VECTOR_A} and @var{VECTOR_B}. The two vectors may be
3272 either numeric or logical and must be arrays of rank one and of equal size. If
3273 the vectors are @code{INTEGER} or @code{REAL}, the result is
3274 @code{SUM(VECTOR_A*VECTOR_B)}. If the vectors are @code{COMPLEX}, the result
3275 is @code{SUM(CONJG(VECTOR_A)*VECTOR_B)}. If the vectors are @code{LOGICAL},
3276 the result is @code{ANY(VECTOR_A .AND. VECTOR_B)}.
3278 @item @emph{Standard}:
3279 Fortran 95 and later
3282 Transformational function
3284 @item @emph{Syntax}:
3285 @code{RESULT = DOT_PRODUCT(VECTOR_A, VECTOR_B)}
3287 @item @emph{Arguments}:
3288 @multitable @columnfractions .15 .70
3289 @item @var{VECTOR_A} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
3290 @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.
3293 @item @emph{Return value}:
3294 If the arguments are numeric, the return value is a scaler of numeric type,
3295 @code{INTEGER}, @code{REAL}, or @code{COMPLEX}. If the arguments are
3296 @code{LOGICAL}, the return value is @code{.TRUE.} or @code{.FALSE.}.
3298 @item @emph{Example}:
3300 program test_dot_prod
3301 integer, dimension(3) :: a, b
3308 print *, dot_product(a,b)
3309 end program test_dot_prod
3316 @section @code{DPROD} --- Double product function
3318 @cindex product, double-precision
3321 @item @emph{Description}:
3322 @code{DPROD(X,Y)} returns the product @code{X*Y}.
3324 @item @emph{Standard}:
3325 Fortran 77 and later
3330 @item @emph{Syntax}:
3331 @code{RESULT = DPROD(X, Y)}
3333 @item @emph{Arguments}:
3334 @multitable @columnfractions .15 .70
3335 @item @var{X} @tab The type shall be @code{REAL}.
3336 @item @var{Y} @tab The type shall be @code{REAL}.
3339 @item @emph{Return value}:
3340 The return value is of type @code{REAL(8)}.
3342 @item @emph{Example}:
3350 end program test_dprod
3357 @section @code{DREAL} --- Double real part function
3359 @cindex complex numbers, real part
3362 @item @emph{Description}:
3363 @code{DREAL(Z)} returns the real part of complex variable @var{Z}.
3365 @item @emph{Standard}:
3371 @item @emph{Syntax}:
3372 @code{RESULT = DREAL(A)}
3374 @item @emph{Arguments}:
3375 @multitable @columnfractions .15 .70
3376 @item @var{A} @tab The type shall be @code{COMPLEX(8)}.
3379 @item @emph{Return value}:
3380 The return value is of type @code{REAL(8)}.
3382 @item @emph{Example}:
3385 complex(8) :: z = (1.3_8,7.2_8)
3387 end program test_dreal
3390 @item @emph{See also}:
3398 @section @code{DTIME} --- Execution time subroutine (or function)
3400 @cindex time, elapsed
3401 @cindex elapsed time
3404 @item @emph{Description}:
3405 @code{DTIME(TARRAY, RESULT)} initially returns the number of seconds of runtime
3406 since the start of the process's execution in @var{RESULT}. @var{TARRAY}
3407 returns the user and system components of this time in @code{TARRAY(1)} and
3408 @code{TARRAY(2)} respectively. @var{RESULT} is equal to @code{TARRAY(1) +
3411 Subsequent invocations of @code{DTIME} return values accumulated since the
3412 previous invocation.
3414 On some systems, the underlying timings are represented using types with
3415 sufficiently small limits that overflows (wrap around) are possible, such as
3416 32-bit types. Therefore, the values returned by this intrinsic might be, or
3417 become, negative, or numerically less than previous values, during a single
3418 run of the compiled program.
3420 Please note, that this implementation is thread safe if used within OpenMP
3421 directives, i.e., its state will be consistent while called from multiple
3422 threads. However, if @code{DTIME} is called from multiple threads, the result
3423 is still the time since the last invocation. This may not give the intended
3424 results. If possible, use @code{CPU_TIME} instead.
3426 This intrinsic is provided in both subroutine and function forms; however,
3427 only one form can be used in any given program unit.
3429 @var{TARRAY} and @var{RESULT} are @code{INTENT(OUT)} and provide the following:
3431 @multitable @columnfractions .15 .30 .40
3432 @item @tab @code{TARRAY(1)}: @tab User time in seconds.
3433 @item @tab @code{TARRAY(2)}: @tab System time in seconds.
3434 @item @tab @code{RESULT}: @tab Run time since start in seconds.
3437 @item @emph{Standard}:
3441 Subroutine, function
3443 @item @emph{Syntax}:
3444 @multitable @columnfractions .80
3445 @item @code{CALL DTIME(TARRAY, RESULT)}.
3446 @item @code{RESULT = DTIME(TARRAY)}, (not recommended).
3449 @item @emph{Arguments}:
3450 @multitable @columnfractions .15 .70
3451 @item @var{TARRAY}@tab The type shall be @code{REAL, DIMENSION(2)}.
3452 @item @var{RESULT}@tab The type shall be @code{REAL}.
3455 @item @emph{Return value}:
3456 Elapsed time in seconds since the last invocation or since the start of program
3457 execution if not called before.
3459 @item @emph{Example}:
3463 real, dimension(2) :: tarray
3465 call dtime(tarray, result)
3469 do i=1,100000000 ! Just a delay
3472 call dtime(tarray, result)
3476 end program test_dtime
3479 @item @emph{See also}:
3487 @section @code{EOSHIFT} --- End-off shift elements of an array
3489 @cindex array, shift
3492 @item @emph{Description}:
3493 @code{EOSHIFT(ARRAY, SHIFT[, BOUNDARY, DIM])} performs an end-off shift on
3494 elements of @var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is
3495 omitted it is taken to be @code{1}. @var{DIM} is a scaler of type
3496 @code{INTEGER} in the range of @math{1 /leq DIM /leq n)} where @math{n} is the
3497 rank of @var{ARRAY}. If the rank of @var{ARRAY} is one, then all elements of
3498 @var{ARRAY} are shifted by @var{SHIFT} places. If rank is greater than one,
3499 then all complete rank one sections of @var{ARRAY} along the given dimension are
3500 shifted. Elements shifted out one end of each rank one section are dropped. If
3501 @var{BOUNDARY} is present then the corresponding value of from @var{BOUNDARY}
3502 is copied back in the other end. If @var{BOUNDARY} is not present then the
3503 following are copied in depending on the type of @var{ARRAY}.
3505 @multitable @columnfractions .15 .80
3506 @item @emph{Array Type} @tab @emph{Boundary Value}
3507 @item Numeric @tab 0 of the type and kind of @var{ARRAY}.
3508 @item Logical @tab @code{.FALSE.}.
3509 @item Character(@var{len}) @tab @var{len} blanks.
3512 @item @emph{Standard}:
3513 Fortran 95 and later
3516 Transformational function
3518 @item @emph{Syntax}:
3519 @code{RESULT = EOSHIFT(ARRAY, SHIFT [, BOUNDARY, DIM])}
3521 @item @emph{Arguments}:
3522 @multitable @columnfractions .15 .70
3523 @item @var{ARRAY} @tab May be any type, not scaler.
3524 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
3525 @item @var{BOUNDARY} @tab Same type as @var{ARRAY}.
3526 @item @var{DIM} @tab The type shall be @code{INTEGER}.
3529 @item @emph{Return value}:
3530 Returns an array of same type and rank as the @var{ARRAY} argument.
3532 @item @emph{Example}:
3534 program test_eoshift
3535 integer, dimension(3,3) :: a
3536 a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
3537 print '(3i3)', a(1,:)
3538 print '(3i3)', a(2,:)
3539 print '(3i3)', a(3,:)
3540 a = EOSHIFT(a, SHIFT=(/1, 2, 1/), BOUNDARY=-5, DIM=2)
3542 print '(3i3)', a(1,:)
3543 print '(3i3)', a(2,:)
3544 print '(3i3)', a(3,:)
3545 end program test_eoshift
3552 @section @code{EPSILON} --- Epsilon function
3554 @cindex model representation, epsilon
3557 @item @emph{Description}:
3558 @code{EPSILON(X)} returns a nearly negligible number relative to @code{1}.
3560 @item @emph{Standard}:
3561 Fortran 95 and later
3566 @item @emph{Syntax}:
3567 @code{RESULT = EPSILON(X)}
3569 @item @emph{Arguments}:
3570 @multitable @columnfractions .15 .70
3571 @item @var{X} @tab The type shall be @code{REAL}.
3574 @item @emph{Return value}:
3575 The return value is of same type as the argument.
3577 @item @emph{Example}:
3579 program test_epsilon
3584 end program test_epsilon
3591 @section @code{ERF} --- Error function
3593 @cindex error function
3596 @item @emph{Description}:
3597 @code{ERF(X)} computes the error function of @var{X}.
3599 @item @emph{Standard}:
3600 Fortran 2008 and later
3605 @item @emph{Syntax}:
3606 @code{RESULT = ERF(X)}
3608 @item @emph{Arguments}:
3609 @multitable @columnfractions .15 .70
3610 @item @var{X} @tab The type shall be @code{REAL}.
3613 @item @emph{Return value}:
3614 The return value is of type @code{REAL}, of the same kind as
3615 @var{X} and lies in the range @math{-1 \leq erf (x) \leq 1 }.
3617 @item @emph{Example}:
3620 real(8) :: x = 0.17_8
3622 end program test_erf
3625 @item @emph{Specific names}:
3626 @multitable @columnfractions .20 .20 .20 .25
3627 @item Name @tab Argument @tab Return type @tab Standard
3628 @item @code{DERF(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
3635 @section @code{ERFC} --- Error function
3637 @cindex error function, complementary
3640 @item @emph{Description}:
3641 @code{ERFC(X)} computes the complementary error function of @var{X}.
3643 @item @emph{Standard}:
3644 Fortran 2008 and later
3649 @item @emph{Syntax}:
3650 @code{RESULT = ERFC(X)}
3652 @item @emph{Arguments}:
3653 @multitable @columnfractions .15 .70
3654 @item @var{X} @tab The type shall be @code{REAL}.
3657 @item @emph{Return value}:
3658 The return value is of type @code{REAL} and of the same kind as @var{X}.
3659 It lies in the range @math{ 0 \leq erfc (x) \leq 2 }.
3661 @item @emph{Example}:
3664 real(8) :: x = 0.17_8
3666 end program test_erfc
3669 @item @emph{Specific names}:
3670 @multitable @columnfractions .20 .20 .20 .25
3671 @item Name @tab Argument @tab Return type @tab Standard
3672 @item @code{DERFC(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
3679 @section @code{ERFC_SCALED} --- Error function
3680 @fnindex ERFC_SCALED
3681 @cindex error function, complementary, exponentially-scaled
3684 @item @emph{Description}:
3685 @code{ERFC_SCALED(X)} computes the exponentially-scaled complementary
3686 error function of @var{X}.
3688 @item @emph{Standard}:
3689 Fortran 2008 and later
3694 @item @emph{Syntax}:
3695 @code{RESULT = ERFC_SCALED(X)}
3697 @item @emph{Arguments}:
3698 @multitable @columnfractions .15 .70
3699 @item @var{X} @tab The type shall be @code{REAL}.
3702 @item @emph{Return value}:
3703 The return value is of type @code{REAL} and of the same kind as @var{X}.
3705 @item @emph{Example}:
3707 program test_erfc_scaled
3708 real(8) :: x = 0.17_8
3710 end program test_erfc_scaled
3717 @section @code{ETIME} --- Execution time subroutine (or function)
3719 @cindex time, elapsed
3722 @item @emph{Description}:
3723 @code{ETIME(TARRAY, RESULT)} returns the number of seconds of runtime
3724 since the start of the process's execution in @var{RESULT}. @var{TARRAY}
3725 returns the user and system components of this time in @code{TARRAY(1)} and
3726 @code{TARRAY(2)} respectively. @var{RESULT} is equal to @code{TARRAY(1) + TARRAY(2)}.
3728 On some systems, the underlying timings are represented using types with
3729 sufficiently small limits that overflows (wrap around) are possible, such as
3730 32-bit types. Therefore, the values returned by this intrinsic might be, or
3731 become, negative, or numerically less than previous values, during a single
3732 run of the compiled program.
3734 This intrinsic is provided in both subroutine and function forms; however,
3735 only one form can be used in any given program unit.
3737 @var{TARRAY} and @var{RESULT} are @code{INTENT(OUT)} and provide the following:
3739 @multitable @columnfractions .15 .30 .60
3740 @item @tab @code{TARRAY(1)}: @tab User time in seconds.
3741 @item @tab @code{TARRAY(2)}: @tab System time in seconds.
3742 @item @tab @code{RESULT}: @tab Run time since start in seconds.
3745 @item @emph{Standard}:
3749 Subroutine, function
3751 @item @emph{Syntax}:
3752 @multitable @columnfractions .80
3753 @item @code{CALL ETIME(TARRAY, RESULT)}.
3754 @item @code{RESULT = ETIME(TARRAY)}, (not recommended).
3757 @item @emph{Arguments}:
3758 @multitable @columnfractions .15 .70
3759 @item @var{TARRAY}@tab The type shall be @code{REAL, DIMENSION(2)}.
3760 @item @var{RESULT}@tab The type shall be @code{REAL}.
3763 @item @emph{Return value}:
3764 Elapsed time in seconds since the start of program execution.
3766 @item @emph{Example}:
3770 real, dimension(2) :: tarray
3772 call ETIME(tarray, result)
3776 do i=1,100000000 ! Just a delay
3779 call ETIME(tarray, result)
3783 end program test_etime
3786 @item @emph{See also}:
3794 @section @code{EXIT} --- Exit the program with status.
3796 @cindex program termination
3797 @cindex terminate program
3800 @item @emph{Description}:
3801 @code{EXIT} causes immediate termination of the program with status. If status
3802 is omitted it returns the canonical @emph{success} for the system. All Fortran
3803 I/O units are closed.
3805 @item @emph{Standard}:
3811 @item @emph{Syntax}:
3812 @code{CALL EXIT([STATUS])}
3814 @item @emph{Arguments}:
3815 @multitable @columnfractions .15 .70
3816 @item @var{STATUS} @tab Shall be an @code{INTEGER} of the default kind.
3819 @item @emph{Return value}:
3820 @code{STATUS} is passed to the parent process on exit.
3822 @item @emph{Example}:
3825 integer :: STATUS = 0
3826 print *, 'This program is going to exit.'
3828 end program test_exit
3831 @item @emph{See also}:
3832 @ref{ABORT}, @ref{KILL}
3838 @section @code{EXP} --- Exponential function
3844 @cindex exponential function
3845 @cindex logarithmic function, inverse
3848 @item @emph{Description}:
3849 @code{EXP(X)} computes the base @math{e} exponential of @var{X}.
3851 @item @emph{Standard}:
3852 Fortran 77 and later, has overloads that are GNU extensions
3857 @item @emph{Syntax}:
3858 @code{RESULT = EXP(X)}
3860 @item @emph{Arguments}:
3861 @multitable @columnfractions .15 .70
3862 @item @var{X} @tab The type shall be @code{REAL} or
3866 @item @emph{Return value}:
3867 The return value has same type and kind as @var{X}.
3869 @item @emph{Example}:
3874 end program test_exp
3877 @item @emph{Specific names}:
3878 @multitable @columnfractions .20 .20 .20 .25
3879 @item Name @tab Argument @tab Return type @tab Standard
3880 @item @code{DEXP(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
3881 @item @code{CEXP(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab Fortran 77 and later
3882 @item @code{ZEXP(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
3883 @item @code{CDEXP(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
3890 @section @code{EXPONENT} --- Exponent function
3892 @cindex real number, exponent
3893 @cindex floating point, exponent
3896 @item @emph{Description}:
3897 @code{EXPONENT(X)} returns the value of the exponent part of @var{X}. If @var{X}
3898 is zero the value returned is zero.
3900 @item @emph{Standard}:
3901 Fortran 95 and later
3906 @item @emph{Syntax}:
3907 @code{RESULT = EXPONENT(X)}
3909 @item @emph{Arguments}:
3910 @multitable @columnfractions .15 .70
3911 @item @var{X} @tab The type shall be @code{REAL}.
3914 @item @emph{Return value}:
3915 The return value is of type default @code{INTEGER}.
3917 @item @emph{Example}:
3919 program test_exponent
3924 print *, exponent(0.0)
3925 end program test_exponent
3932 @section @code{FDATE} --- Get the current time as a string
3934 @cindex time, current
3935 @cindex current time
3936 @cindex date, current
3937 @cindex current date
3940 @item @emph{Description}:
3941 @code{FDATE(DATE)} returns the current date (using the same format as
3942 @code{CTIME}) in @var{DATE}. It is equivalent to @code{CALL CTIME(DATE,
3945 This intrinsic is provided in both subroutine and function forms; however,
3946 only one form can be used in any given program unit.
3948 @var{DATE} is an @code{INTENT(OUT)} @code{CHARACTER} variable of the
3951 @item @emph{Standard}:
3955 Subroutine, function
3957 @item @emph{Syntax}:
3958 @multitable @columnfractions .80
3959 @item @code{CALL FDATE(DATE)}.
3960 @item @code{DATE = FDATE()}, (not recommended).
3963 @item @emph{Arguments}:
3964 @multitable @columnfractions .15 .70
3965 @item @var{DATE}@tab The type shall be of type @code{CHARACTER} of the
3969 @item @emph{Return value}:
3970 The current date as a string.
3972 @item @emph{Example}:
3976 character(len=30) :: date
3978 print *, 'Program started on ', date
3979 do i = 1, 100000000 ! Just a delay
3983 print *, 'Program ended on ', date
3984 end program test_fdate
3991 @section @code{FLOAT} --- Convert integer to default real
3993 @cindex conversion, to real
3996 @item @emph{Description}:
3997 @code{FLOAT(A)} converts the integer @var{A} to a default real value.
3999 @item @emph{Standard}:
4000 Fortran 77 and later
4005 @item @emph{Syntax}:
4006 @code{RESULT = FLOAT(A)}
4008 @item @emph{Arguments}:
4009 @multitable @columnfractions .15 .70
4010 @item @var{A} @tab The type shall be @code{INTEGER}.
4013 @item @emph{Return value}:
4014 The return value is of type default @code{REAL}.
4016 @item @emph{Example}:
4020 if (float(i) /= 1.) call abort
4021 end program test_float
4024 @item @emph{See also}:
4025 @ref{DBLE}, @ref{DFLOAT}, @ref{REAL}
4031 @section @code{FGET} --- Read a single character in stream mode from stdin
4033 @cindex read character, stream mode
4034 @cindex stream mode, read character
4035 @cindex file operation, read character
4038 @item @emph{Description}:
4039 Read a single character in stream mode from stdin by bypassing normal
4040 formatted output. Stream I/O should not be mixed with normal record-oriented
4041 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
4043 This intrinsic is provided in both subroutine and function forms; however,
4044 only one form can be used in any given program unit.
4046 Note that the @code{FGET} intrinsic is provided for backwards compatibility with
4047 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
4048 Programmers should consider the use of new stream IO feature in new code
4049 for future portability. See also @ref{Fortran 2003 status}.
4051 @item @emph{Standard}:
4055 Subroutine, function
4057 @item @emph{Syntax}:
4058 @code{CALL FGET(C [, STATUS])}
4060 @item @emph{Arguments}:
4061 @multitable @columnfractions .15 .70
4062 @item @var{C} @tab The type shall be @code{CHARACTER} and of default
4064 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
4065 Returns 0 on success, -1 on end-of-file, and a
4066 system specific positive error code otherwise.
4069 @item @emph{Example}:
4072 INTEGER, PARAMETER :: strlen = 100
4073 INTEGER :: status, i = 1
4074 CHARACTER(len=strlen) :: str = ""
4076 WRITE (*,*) 'Enter text:'
4078 CALL fget(str(i:i), status)
4079 if (status /= 0 .OR. i > strlen) exit
4082 WRITE (*,*) TRIM(str)
4086 @item @emph{See also}:
4087 @ref{FGETC}, @ref{FPUT}, @ref{FPUTC}
4093 @section @code{FGETC} --- Read a single character in stream mode
4095 @cindex read character, stream mode
4096 @cindex stream mode, read character
4097 @cindex file operation, read character
4100 @item @emph{Description}:
4101 Read a single character in stream mode by bypassing normal formatted output.
4102 Stream I/O should not be mixed with normal record-oriented (formatted or
4103 unformatted) I/O on the same unit; the results are unpredictable.
4105 This intrinsic is provided in both subroutine and function forms; however,
4106 only one form can be used in any given program unit.
4108 Note that the @code{FGET} intrinsic is provided for backwards compatibility
4109 with @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
4110 Programmers should consider the use of new stream IO feature in new code
4111 for future portability. See also @ref{Fortran 2003 status}.
4113 @item @emph{Standard}:
4117 Subroutine, function
4119 @item @emph{Syntax}:
4120 @code{CALL FGETC(UNIT, C [, STATUS])}
4122 @item @emph{Arguments}:
4123 @multitable @columnfractions .15 .70
4124 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
4125 @item @var{C} @tab The type shall be @code{CHARACTER} and of default
4127 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
4128 Returns 0 on success, -1 on end-of-file and a
4129 system specific positive error code otherwise.
4132 @item @emph{Example}:
4135 INTEGER :: fd = 42, status
4138 OPEN(UNIT=fd, FILE="/etc/passwd", ACTION="READ", STATUS = "OLD")
4140 CALL fgetc(fd, c, status)
4141 IF (status /= 0) EXIT
4148 @item @emph{See also}:
4149 @ref{FGET}, @ref{FPUT}, @ref{FPUTC}
4155 @section @code{FLOOR} --- Integer floor function
4158 @cindex rounding, floor
4161 @item @emph{Description}:
4162 @code{FLOOR(A)} returns the greatest integer less than or equal to @var{X}.
4164 @item @emph{Standard}:
4165 Fortran 95 and later
4170 @item @emph{Syntax}:
4171 @code{RESULT = FLOOR(A [, KIND])}
4173 @item @emph{Arguments}:
4174 @multitable @columnfractions .15 .70
4175 @item @var{A} @tab The type shall be @code{REAL}.
4176 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
4177 expression indicating the kind parameter of
4181 @item @emph{Return value}:
4182 The return value is of type @code{INTEGER(KIND)} if @var{KIND} is present
4183 and of default-kind @code{INTEGER} otherwise.
4185 @item @emph{Example}:
4190 print *, floor(x) ! returns 63
4191 print *, floor(y) ! returns -64
4192 end program test_floor
4195 @item @emph{See also}:
4196 @ref{CEILING}, @ref{NINT}
4203 @section @code{FLUSH} --- Flush I/O unit(s)
4205 @cindex file operation, flush
4208 @item @emph{Description}:
4209 Flushes Fortran unit(s) currently open for output. Without the optional
4210 argument, all units are flushed, otherwise just the unit specified.
4212 @item @emph{Standard}:
4218 @item @emph{Syntax}:
4219 @code{CALL FLUSH(UNIT)}
4221 @item @emph{Arguments}:
4222 @multitable @columnfractions .15 .70
4223 @item @var{UNIT} @tab (Optional) The type shall be @code{INTEGER}.
4227 Beginning with the Fortran 2003 standard, there is a @code{FLUSH}
4228 statement that should be preferred over the @code{FLUSH} intrinsic.
4235 @section @code{FNUM} --- File number function
4237 @cindex file operation, file number
4240 @item @emph{Description}:
4241 @code{FNUM(UNIT)} returns the POSIX file descriptor number corresponding to the
4242 open Fortran I/O unit @code{UNIT}.
4244 @item @emph{Standard}:
4250 @item @emph{Syntax}:
4251 @code{RESULT = FNUM(UNIT)}
4253 @item @emph{Arguments}:
4254 @multitable @columnfractions .15 .70
4255 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
4258 @item @emph{Return value}:
4259 The return value is of type @code{INTEGER}
4261 @item @emph{Example}:
4265 open (unit=10, status = "scratch")
4269 end program test_fnum
4276 @section @code{FPUT} --- Write a single character in stream mode to stdout
4278 @cindex write character, stream mode
4279 @cindex stream mode, write character
4280 @cindex file operation, write character
4283 @item @emph{Description}:
4284 Write a single character in stream mode to stdout by bypassing normal
4285 formatted output. Stream I/O should not be mixed with normal record-oriented
4286 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
4288 This intrinsic is provided in both subroutine and function forms; however,
4289 only one form can be used in any given program unit.
4291 Note that the @code{FGET} intrinsic is provided for backwards compatibility with
4292 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
4293 Programmers should consider the use of new stream IO feature in new code
4294 for future portability. See also @ref{Fortran 2003 status}.
4296 @item @emph{Standard}:
4300 Subroutine, function
4302 @item @emph{Syntax}:
4303 @code{CALL FPUT(C [, STATUS])}
4305 @item @emph{Arguments}:
4306 @multitable @columnfractions .15 .70
4307 @item @var{C} @tab The type shall be @code{CHARACTER} and of default
4309 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
4310 Returns 0 on success, -1 on end-of-file and a
4311 system specific positive error code otherwise.
4314 @item @emph{Example}:
4317 CHARACTER(len=10) :: str = "gfortran"
4319 DO i = 1, len_trim(str)
4325 @item @emph{See also}:
4326 @ref{FPUTC}, @ref{FGET}, @ref{FGETC}
4332 @section @code{FPUTC} --- Write a single character in stream mode
4334 @cindex write character, stream mode
4335 @cindex stream mode, write character
4336 @cindex file operation, write character
4339 @item @emph{Description}:
4340 Write a single character in stream mode by bypassing normal formatted
4341 output. Stream I/O should not be mixed with normal record-oriented
4342 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
4344 This intrinsic is provided in both subroutine and function forms; however,
4345 only one form can be used in any given program unit.
4347 Note that the @code{FGET} intrinsic is provided for backwards compatibility with
4348 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
4349 Programmers should consider the use of new stream IO feature in new code
4350 for future portability. See also @ref{Fortran 2003 status}.
4352 @item @emph{Standard}:
4356 Subroutine, function
4358 @item @emph{Syntax}:
4359 @code{CALL FPUTC(UNIT, C [, STATUS])}
4361 @item @emph{Arguments}:
4362 @multitable @columnfractions .15 .70
4363 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
4364 @item @var{C} @tab The type shall be @code{CHARACTER} and of default
4366 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
4367 Returns 0 on success, -1 on end-of-file and a
4368 system specific positive error code otherwise.
4371 @item @emph{Example}:
4374 CHARACTER(len=10) :: str = "gfortran"
4375 INTEGER :: fd = 42, i
4377 OPEN(UNIT = fd, FILE = "out", ACTION = "WRITE", STATUS="NEW")
4378 DO i = 1, len_trim(str)
4379 CALL fputc(fd, str(i:i))
4385 @item @emph{See also}:
4386 @ref{FPUT}, @ref{FGET}, @ref{FGETC}
4392 @section @code{FRACTION} --- Fractional part of the model representation
4394 @cindex real number, fraction
4395 @cindex floating point, fraction
4398 @item @emph{Description}:
4399 @code{FRACTION(X)} returns the fractional part of the model
4400 representation of @code{X}.
4402 @item @emph{Standard}:
4403 Fortran 95 and later
4408 @item @emph{Syntax}:
4409 @code{Y = FRACTION(X)}
4411 @item @emph{Arguments}:
4412 @multitable @columnfractions .15 .70
4413 @item @var{X} @tab The type of the argument shall be a @code{REAL}.
4416 @item @emph{Return value}:
4417 The return value is of the same type and kind as the argument.
4418 The fractional part of the model representation of @code{X} is returned;
4419 it is @code{X * RADIX(X)**(-EXPONENT(X))}.
4421 @item @emph{Example}:
4423 program test_fraction
4426 print *, fraction(x), x * radix(x)**(-exponent(x))
4427 end program test_fraction
4435 @section @code{FREE} --- Frees memory
4437 @cindex pointer, cray
4440 @item @emph{Description}:
4441 Frees memory previously allocated by @code{MALLOC()}. The @code{FREE}
4442 intrinsic is an extension intended to be used with Cray pointers, and is
4443 provided in GNU Fortran to allow user to compile legacy code. For
4444 new code using Fortran 95 pointers, the memory de-allocation intrinsic is
4447 @item @emph{Standard}:
4453 @item @emph{Syntax}:
4454 @code{CALL FREE(PTR)}
4456 @item @emph{Arguments}:
4457 @multitable @columnfractions .15 .70
4458 @item @var{PTR} @tab The type shall be @code{INTEGER}. It represents the
4459 location of the memory that should be de-allocated.
4462 @item @emph{Return value}:
4465 @item @emph{Example}:
4466 See @code{MALLOC} for an example.
4468 @item @emph{See also}:
4475 @section @code{FSEEK} --- Low level file positioning subroutine
4477 @cindex file operation, seek
4478 @cindex file operation, position
4481 @item @emph{Description}:
4482 Moves @var{UNIT} to the specified @var{OFFSET}. If @var{WHENCE}
4483 is set to 0, the @var{OFFSET} is taken as an absolute value @code{SEEK_SET},
4484 if set to 1, @var{OFFSET} is taken to be relative to the current position
4485 @code{SEEK_CUR}, and if set to 2 relative to the end of the file @code{SEEK_END}.
4486 On error, @var{STATUS} is set to a nonzero value. If @var{STATUS} the seek
4489 This intrinsic routine is not fully backwards compatible with @command{g77}.
4490 In @command{g77}, the @code{FSEEK} takes a statement label instead of a
4491 @var{STATUS} variable. If FSEEK is used in old code, change
4493 CALL FSEEK(UNIT, OFFSET, WHENCE, *label)
4498 CALL FSEEK(UNIT, OFFSET, WHENCE, status)
4499 IF (status /= 0) GOTO label
4502 Please note that GNU Fortran provides the Fortran 2003 Stream facility.
4503 Programmers should consider the use of new stream IO feature in new code
4504 for future portability. See also @ref{Fortran 2003 status}.
4506 @item @emph{Standard}:
4512 @item @emph{Syntax}:
4513 @code{CALL FSEEK(UNIT, OFFSET, WHENCE[, STATUS])}
4515 @item @emph{Arguments}:
4516 @multitable @columnfractions .15 .70
4517 @item @var{UNIT} @tab Shall be a scalar of type @code{INTEGER}.
4518 @item @var{OFFSET} @tab Shall be a scalar of type @code{INTEGER}.
4519 @item @var{WHENCE} @tab Shall be a scalar of type @code{INTEGER}.
4520 Its value shall be either 0, 1 or 2.
4521 @item @var{STATUS} @tab (Optional) shall be a scalar of type
4525 @item @emph{Example}:
4528 INTEGER, PARAMETER :: SEEK_SET = 0, SEEK_CUR = 1, SEEK_END = 2
4529 INTEGER :: fd, offset, ierr
4535 OPEN(UNIT=fd, FILE="fseek.test")
4536 CALL FSEEK(fd, offset, SEEK_SET, ierr) ! move to OFFSET
4537 print *, FTELL(fd), ierr
4539 CALL FSEEK(fd, 0, SEEK_END, ierr) ! move to end
4540 print *, FTELL(fd), ierr
4542 CALL FSEEK(fd, 0, SEEK_SET, ierr) ! move to beginning
4543 print *, FTELL(fd), ierr
4549 @item @emph{See also}:
4556 @section @code{FSTAT} --- Get file status
4558 @cindex file system, file status
4561 @item @emph{Description}:
4562 @code{FSTAT} is identical to @ref{STAT}, except that information about an
4563 already opened file is obtained.
4565 The elements in @code{BUFF} are the same as described by @ref{STAT}.
4567 This intrinsic is provided in both subroutine and function forms; however,
4568 only one form can be used in any given program unit.
4570 @item @emph{Standard}:
4574 Subroutine, function
4576 @item @emph{Syntax}:
4577 @code{CALL FSTAT(UNIT, BUFF [, STATUS])}
4579 @item @emph{Arguments}:
4580 @multitable @columnfractions .15 .70
4581 @item @var{UNIT} @tab An open I/O unit number of type @code{INTEGER}.
4582 @item @var{BUFF} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
4583 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0
4584 on success and a system specific error code otherwise.
4587 @item @emph{Example}:
4588 See @ref{STAT} for an example.
4590 @item @emph{See also}:
4591 To stat a link: @ref{LSTAT}, to stat a file: @ref{STAT}
4597 @section @code{FTELL} --- Current stream position
4599 @cindex file operation, position
4602 @item @emph{Description}:
4603 Retrieves the current position within an open file.
4605 This intrinsic is provided in both subroutine and function forms; however,
4606 only one form can be used in any given program unit.
4608 @item @emph{Standard}:
4612 Subroutine, function
4614 @item @emph{Syntax}:
4615 @multitable @columnfractions .80
4616 @item @code{CALL FTELL(UNIT, OFFSET)}
4617 @item @code{OFFSET = FTELL(UNIT)}
4620 @item @emph{Arguments}:
4621 @multitable @columnfractions .15 .70
4622 @item @var{OFFSET} @tab Shall of type @code{INTEGER}.
4623 @item @var{UNIT} @tab Shall of type @code{INTEGER}.
4626 @item @emph{Return value}:
4627 In either syntax, @var{OFFSET} is set to the current offset of unit
4628 number @var{UNIT}, or to @math{-1} if the unit is not currently open.
4630 @item @emph{Example}:
4634 OPEN(10, FILE="temp.dat")
4640 @item @emph{See also}:
4647 @section @code{GAMMA} --- Gamma function
4650 @cindex Gamma function
4651 @cindex Factorial function
4654 @item @emph{Description}:
4655 @code{GAMMA(X)} computes Gamma (@math{\Gamma}) of @var{X}. For positive,
4656 integer values of @var{X} the Gamma function simplifies to the factorial
4657 function @math{\Gamma(x)=(x-1)!}.
4661 \Gamma(x) = \int_0^\infty t^{x-1}{\rm e}^{-t}\,{\rm d}t
4665 @item @emph{Standard}:
4666 Fortran 2008 and later
4671 @item @emph{Syntax}:
4674 @item @emph{Arguments}:
4675 @multitable @columnfractions .15 .70
4676 @item @var{X} @tab Shall be of type @code{REAL} and neither zero
4677 nor a negative integer.
4680 @item @emph{Return value}:
4681 The return value is of type @code{REAL} of the same kind as @var{X}.
4683 @item @emph{Example}:
4687 x = gamma(x) ! returns 1.0
4688 end program test_gamma
4691 @item @emph{Specific names}:
4692 @multitable @columnfractions .20 .20 .20 .25
4693 @item Name @tab Argument @tab Return type @tab Standard
4694 @item @code{GAMMA(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU Extension
4695 @item @code{DGAMMA(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU Extension
4698 @item @emph{See also}:
4699 Logarithm of the Gamma function: @ref{LOG_GAMMA}
4706 @section @code{GERROR} --- Get last system error message
4708 @cindex system, error handling
4711 @item @emph{Description}:
4712 Returns the system error message corresponding to the last system error.
4713 This resembles the functionality of @code{strerror(3)} in C.
4715 @item @emph{Standard}:
4721 @item @emph{Syntax}:
4722 @code{CALL GERROR(RESULT)}
4724 @item @emph{Arguments}:
4725 @multitable @columnfractions .15 .70
4726 @item @var{RESULT} @tab Shall of type @code{CHARACTER} and of default
4729 @item @emph{Example}:
4732 CHARACTER(len=100) :: msg
4738 @item @emph{See also}:
4739 @ref{IERRNO}, @ref{PERROR}
4745 @section @code{GETARG} --- Get command line arguments
4747 @cindex command-line arguments
4748 @cindex arguments, to program
4751 @item @emph{Description}:
4752 Retrieve the @var{POS}-th argument that was passed on the
4753 command line when the containing program was invoked.
4755 This intrinsic routine is provided for backwards compatibility with
4756 GNU Fortran 77. In new code, programmers should consider the use of
4757 the @ref{GET_COMMAND_ARGUMENT} intrinsic defined by the Fortran 2003
4760 @item @emph{Standard}:
4766 @item @emph{Syntax}:
4767 @code{CALL GETARG(POS, VALUE)}
4769 @item @emph{Arguments}:
4770 @multitable @columnfractions .15 .70
4771 @item @var{POS} @tab Shall be of type @code{INTEGER} and not wider than
4772 the default integer kind; @math{@var{POS} \geq 0}
4773 @item @var{VALUE} @tab Shall be of type @code{CHARACTER} and of default
4775 @item @var{VALUE} @tab Shall be of type @code{CHARACTER}.
4778 @item @emph{Return value}:
4779 After @code{GETARG} returns, the @var{VALUE} argument holds the
4780 @var{POS}th command line argument. If @var{VALUE} can not hold the
4781 argument, it is truncated to fit the length of @var{VALUE}. If there are
4782 less than @var{POS} arguments specified at the command line, @var{VALUE}
4783 will be filled with blanks. If @math{@var{POS} = 0}, @var{VALUE} is set
4784 to the name of the program (on systems that support this feature).
4786 @item @emph{Example}:
4790 CHARACTER(len=32) :: arg
4799 @item @emph{See also}:
4800 GNU Fortran 77 compatibility function: @ref{IARGC}
4802 Fortran 2003 functions and subroutines: @ref{GET_COMMAND},
4803 @ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
4809 @section @code{GET_COMMAND} --- Get the entire command line
4810 @fnindex GET_COMMAND
4811 @cindex command-line arguments
4812 @cindex arguments, to program
4815 @item @emph{Description}:
4816 Retrieve the entire command line that was used to invoke the program.
4818 @item @emph{Standard}:
4819 Fortran 2003 and later
4824 @item @emph{Syntax}:
4825 @code{CALL GET_COMMAND(COMMAND)}
4827 @item @emph{Arguments}:
4828 @multitable @columnfractions .15 .70
4829 @item @var{COMMAND} @tab Shall be of type @code{CHARACTER} and of default
4833 @item @emph{Return value}:
4834 Stores the entire command line that was used to invoke the program in
4835 @var{COMMAND}. If @var{COMMAND} is not large enough, the command will be
4838 @item @emph{Example}:
4840 PROGRAM test_get_command
4841 CHARACTER(len=255) :: cmd
4842 CALL get_command(cmd)
4843 WRITE (*,*) TRIM(cmd)
4847 @item @emph{See also}:
4848 @ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
4853 @node GET_COMMAND_ARGUMENT
4854 @section @code{GET_COMMAND_ARGUMENT} --- Get command line arguments
4855 @fnindex GET_COMMAND_ARGUMENT
4856 @cindex command-line arguments
4857 @cindex arguments, to program
4860 @item @emph{Description}:
4861 Retrieve the @var{NUMBER}-th argument that was passed on the
4862 command line when the containing program was invoked.
4864 @item @emph{Standard}:
4865 Fortran 2003 and later
4870 @item @emph{Syntax}:
4871 @code{CALL GET_COMMAND_ARGUMENT(NUMBER [, VALUE, LENGTH, STATUS])}
4873 @item @emph{Arguments}:
4874 @multitable @columnfractions .15 .70
4875 @item @var{NUMBER} @tab Shall be a scalar of type @code{INTEGER(4)},
4876 @math{@var{NUMBER} \geq 0}
4877 @item @var{VALUE} @tab Shall be a scalar of type @code{CHARACTER}
4878 and of default kind.
4879 @item @var{LENGTH} @tab (Option) Shall be a scalar of type @code{INTEGER(4)}.
4880 @item @var{STATUS} @tab (Option) Shall be a scalar of type @code{INTEGER(4)}.
4883 @item @emph{Return value}:
4884 After @code{GET_COMMAND_ARGUMENT} returns, the @var{VALUE} argument holds the
4885 @var{NUMBER}-th command line argument. If @var{VALUE} can not hold the argument, it is
4886 truncated to fit the length of @var{VALUE}. If there are less than @var{NUMBER}
4887 arguments specified at the command line, @var{VALUE} will be filled with blanks.
4888 If @math{@var{NUMBER} = 0}, @var{VALUE} is set to the name of the program (on systems
4889 that support this feature). The @var{LENGTH} argument contains the length of the
4890 @var{NUMBER}-th command line argument. If the argument retrival fails, @var{STATUS}
4891 is a positiv number; if @var{VALUE} contains a truncated command line argument,
4892 @var{STATUS} is -1; and otherwise the @var{STATUS} is zero.
4894 @item @emph{Example}:
4896 PROGRAM test_get_command_argument
4898 CHARACTER(len=32) :: arg
4902 CALL get_command_argument(i, arg)
4903 IF (LEN_TRIM(arg) == 0) EXIT
4905 WRITE (*,*) TRIM(arg)
4911 @item @emph{See also}:
4912 @ref{GET_COMMAND}, @ref{COMMAND_ARGUMENT_COUNT}
4918 @section @code{GETCWD} --- Get current working directory
4920 @cindex system, working directory
4923 @item @emph{Description}:
4924 Get current working directory.
4926 This intrinsic is provided in both subroutine and function forms; however,
4927 only one form can be used in any given program unit.
4929 @item @emph{Standard}:
4933 Subroutine, function
4935 @item @emph{Syntax}:
4936 @code{CALL GETCWD(C [, STATUS])}
4938 @item @emph{Arguments}:
4939 @multitable @columnfractions .15 .70
4940 @item @var{C} @tab The type shall be @code{CHARACTER} and of default kind.
4941 @item @var{STATUS} @tab (Optional) status flag. Returns 0 on success,
4942 a system specific and nonzero error code otherwise.
4945 @item @emph{Example}:
4948 CHARACTER(len=255) :: cwd
4950 WRITE(*,*) TRIM(cwd)
4954 @item @emph{See also}:
4961 @section @code{GETENV} --- Get an environmental variable
4963 @cindex environment variable
4966 @item @emph{Description}:
4967 Get the @var{VALUE} of the environmental variable @var{NAME}.
4969 This intrinsic routine is provided for backwards compatibility with
4970 GNU Fortran 77. In new code, programmers should consider the use of
4971 the @ref{GET_ENVIRONMENT_VARIABLE} intrinsic defined by the Fortran
4974 @item @emph{Standard}:
4980 @item @emph{Syntax}:
4981 @code{CALL GETENV(NAME, VALUE)}
4983 @item @emph{Arguments}:
4984 @multitable @columnfractions .15 .70
4985 @item @var{NAME} @tab Shall be of type @code{CHARACTER} and of default kind.
4986 @item @var{VALUE} @tab Shall be of type @code{CHARACTER} and of default kind.
4989 @item @emph{Return value}:
4990 Stores the value of @var{NAME} in @var{VALUE}. If @var{VALUE} is
4991 not large enough to hold the data, it is truncated. If @var{NAME}
4992 is not set, @var{VALUE} will be filled with blanks.
4994 @item @emph{Example}:
4997 CHARACTER(len=255) :: homedir
4998 CALL getenv("HOME", homedir)
4999 WRITE (*,*) TRIM(homedir)
5003 @item @emph{See also}:
5004 @ref{GET_ENVIRONMENT_VARIABLE}
5009 @node GET_ENVIRONMENT_VARIABLE
5010 @section @code{GET_ENVIRONMENT_VARIABLE} --- Get an environmental variable
5011 @fnindex GET_ENVIRONMENT_VARIABLE
5012 @cindex environment variable
5015 @item @emph{Description}:
5016 Get the @var{VALUE} of the environmental variable @var{NAME}.
5018 @item @emph{Standard}:
5019 Fortran 2003 and later
5024 @item @emph{Syntax}:
5025 @code{CALL GET_ENVIRONMENT_VARIABLE(NAME[, VALUE, LENGTH, STATUS, TRIM_NAME)}
5027 @item @emph{Arguments}:
5028 @multitable @columnfractions .15 .70
5029 @item @var{NAME} @tab Shall be a scalar of type @code{CHARACTER(1)}.
5030 @item @var{VALUE} @tab Shall be a scalar of type @code{CHARACTER(1)}.
5031 @item @var{LENGTH} @tab Shall be a scalar of type @code{INTEGER(4)}.
5032 @item @var{STATUS} @tab Shall be a scalar of type @code{INTEGER(4)}.
5033 @item @var{TRIM_NAME} @tab Shall be a scalar of type @code{LOGICAL(4)}.
5036 @item @emph{Return value}:
5037 Stores the value of @var{NAME} in @var{VALUE}. If @var{VALUE} is
5038 not large enough to hold the data, it is truncated. If @var{NAME}
5039 is not set, @var{VALUE} will be filled with blanks. Argument @var{LENGTH}
5040 contains the length needed for storing the environment variable @var{NAME}
5041 or zero if it is not present. @var{STATUS} is -1 if @var{VALUE} is present
5042 but too short for the environment variable; it is 1 if the environment
5043 variable does not exist and 2 if the processor does not support environment
5044 variables; in all other cases @var{STATUS} is zero. If @var{TRIM_NAME} is
5045 present with the value @code{.FALSE.}, the trailing blanks in @var{NAME}
5046 are significant; otherwise they are not part of the environment variable
5049 @item @emph{Example}:
5052 CHARACTER(len=255) :: homedir
5053 CALL get_environment_variable("HOME", homedir)
5054 WRITE (*,*) TRIM(homedir)
5062 @section @code{GETGID} --- Group ID function
5064 @cindex system, group id
5067 @item @emph{Description}:
5068 Returns the numerical group ID of the current process.
5070 @item @emph{Standard}:
5076 @item @emph{Syntax}:
5077 @code{RESULT = GETGID()}
5079 @item @emph{Return value}:
5080 The return value of @code{GETGID} is an @code{INTEGER} of the default
5084 @item @emph{Example}:
5085 See @code{GETPID} for an example.
5087 @item @emph{See also}:
5088 @ref{GETPID}, @ref{GETUID}
5094 @section @code{GETLOG} --- Get login name
5096 @cindex system, login name
5100 @item @emph{Description}:
5101 Gets the username under which the program is running.
5103 @item @emph{Standard}:
5109 @item @emph{Syntax}:
5110 @code{CALL GETLOG(C)}
5112 @item @emph{Arguments}:
5113 @multitable @columnfractions .15 .70
5114 @item @var{C} @tab Shall be of type @code{CHARACTER} and of default kind.
5117 @item @emph{Return value}:
5118 Stores the current user name in @var{LOGIN}. (On systems where POSIX
5119 functions @code{geteuid} and @code{getpwuid} are not available, and
5120 the @code{getlogin} function is not implemented either, this will
5121 return a blank string.)
5123 @item @emph{Example}:
5126 CHARACTER(32) :: login
5132 @item @emph{See also}:
5139 @section @code{GETPID} --- Process ID function
5141 @cindex system, process id
5145 @item @emph{Description}:
5146 Returns the numerical process identifier of the current process.
5148 @item @emph{Standard}:
5154 @item @emph{Syntax}:
5155 @code{RESULT = GETPID()}
5157 @item @emph{Return value}:
5158 The return value of @code{GETPID} is an @code{INTEGER} of the default
5162 @item @emph{Example}:
5165 print *, "The current process ID is ", getpid()
5166 print *, "Your numerical user ID is ", getuid()
5167 print *, "Your numerical group ID is ", getgid()
5171 @item @emph{See also}:
5172 @ref{GETGID}, @ref{GETUID}
5178 @section @code{GETUID} --- User ID function
5180 @cindex system, user id
5184 @item @emph{Description}:
5185 Returns the numerical user ID of the current process.
5187 @item @emph{Standard}:
5193 @item @emph{Syntax}:
5194 @code{RESULT = GETUID()}
5196 @item @emph{Return value}:
5197 The return value of @code{GETUID} is an @code{INTEGER} of the default
5201 @item @emph{Example}:
5202 See @code{GETPID} for an example.
5204 @item @emph{See also}:
5205 @ref{GETPID}, @ref{GETLOG}
5211 @section @code{GMTIME} --- Convert time to GMT info
5213 @cindex time, conversion to GMT info
5216 @item @emph{Description}:
5217 Given a system time value @var{TIME} (as provided by the @code{TIME8()}
5218 intrinsic), fills @var{VALUES} with values extracted from it appropriate
5219 to the UTC time zone (Universal Coordinated Time, also known in some
5220 countries as GMT, Greenwich Mean Time), using @code{gmtime(3)}.
5222 @item @emph{Standard}:
5228 @item @emph{Syntax}:
5229 @code{CALL GMTIME(TIME, VALUES)}
5231 @item @emph{Arguments}:
5232 @multitable @columnfractions .15 .70
5233 @item @var{TIME} @tab An @code{INTEGER} scalar expression
5234 corresponding to a system time, with
5236 @item @var{VALUES} @tab A default @code{INTEGER} array with 9 elements,
5237 with @code{INTENT(OUT)}.
5240 @item @emph{Return value}:
5241 The elements of @var{VALUES} are assigned as follows:
5243 @item Seconds after the minute, range 0--59 or 0--61 to allow for leap
5245 @item Minutes after the hour, range 0--59
5246 @item Hours past midnight, range 0--23
5247 @item Day of month, range 0--31
5248 @item Number of months since January, range 0--12
5249 @item Years since 1900
5250 @item Number of days since Sunday, range 0--6
5251 @item Days since January 1
5252 @item Daylight savings indicator: positive if daylight savings is in
5253 effect, zero if not, and negative if the information is not
5257 @item @emph{See also}:
5258 @ref{CTIME}, @ref{LTIME}, @ref{TIME}, @ref{TIME8}
5265 @section @code{HOSTNM} --- Get system host name
5267 @cindex system, host name
5270 @item @emph{Description}:
5271 Retrieves the host name of the system on which the program is running.
5273 This intrinsic is provided in both subroutine and function forms; however,
5274 only one form can be used in any given program unit.
5276 @item @emph{Standard}:
5280 Subroutine, function
5282 @item @emph{Syntax}:
5283 @multitable @columnfractions .80
5284 @item @code{CALL HOSTNM(C [, STATUS])}
5285 @item @code{STATUS = HOSTNM(NAME)}
5288 @item @emph{Arguments}:
5289 @multitable @columnfractions .15 .70
5290 @item @var{C} @tab Shall of type @code{CHARACTER} and of default kind.
5291 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
5292 Returns 0 on success, or a system specific error
5296 @item @emph{Return value}:
5297 In either syntax, @var{NAME} is set to the current hostname if it can
5298 be obtained, or to a blank string otherwise.
5305 @section @code{HUGE} --- Largest number of a kind
5307 @cindex limits, largest number
5308 @cindex model representation, largest number
5311 @item @emph{Description}:
5312 @code{HUGE(X)} returns the largest number that is not an infinity in
5313 the model of the type of @code{X}.
5315 @item @emph{Standard}:
5316 Fortran 95 and later
5321 @item @emph{Syntax}:
5322 @code{RESULT = HUGE(X)}
5324 @item @emph{Arguments}:
5325 @multitable @columnfractions .15 .70
5326 @item @var{X} @tab Shall be of type @code{REAL} or @code{INTEGER}.
5329 @item @emph{Return value}:
5330 The return value is of the same type and kind as @var{X}
5332 @item @emph{Example}:
5334 program test_huge_tiny
5335 print *, huge(0), huge(0.0), huge(0.0d0)
5336 print *, tiny(0.0), tiny(0.0d0)
5337 end program test_huge_tiny
5344 @section @code{HYPOT} --- Euclidean distance function
5346 @cindex Euclidean distance
5349 @item @emph{Description}:
5350 @code{HYPOT(X,Y)} is the Euclidean distance function. It is equal to
5351 @math{\sqrt{X^2 + Y^2}}, without undue underflow or overflow.
5353 @item @emph{Standard}:
5354 Fortran 2008 and later
5359 @item @emph{Syntax}:
5360 @code{RESULT = HYPOT(X, Y)}
5362 @item @emph{Arguments}:
5363 @multitable @columnfractions .15 .70
5364 @item @var{X} @tab The type shall be @code{REAL}.
5365 @item @var{Y} @tab The type and kind type parameter shall be the same as
5369 @item @emph{Return value}:
5370 The return value has the same type and kind type parameter as @var{X}.
5372 @item @emph{Example}:
5375 real(4) :: x = 1.e0_4, y = 0.5e0_4
5377 end program test_hypot
5384 @section @code{IACHAR} --- Code in @acronym{ASCII} collating sequence
5386 @cindex @acronym{ASCII} collating sequence
5387 @cindex collating sequence, @acronym{ASCII}
5388 @cindex conversion, to integer
5391 @item @emph{Description}:
5392 @code{IACHAR(C)} returns the code for the @acronym{ASCII} character
5393 in the first character position of @code{C}.
5395 @item @emph{Standard}:
5396 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
5401 @item @emph{Syntax}:
5402 @code{RESULT = IACHAR(C [, KIND])}
5404 @item @emph{Arguments}:
5405 @multitable @columnfractions .15 .70
5406 @item @var{C} @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
5407 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
5408 expression indicating the kind parameter of
5412 @item @emph{Return value}:
5413 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
5414 @var{KIND} is absent, the return value is of default integer kind.
5416 @item @emph{Example}:
5421 end program test_iachar
5425 See @ref{ICHAR} for a discussion of converting between numerical values
5426 and formatted string representations.
5428 @item @emph{See also}:
5429 @ref{ACHAR}, @ref{CHAR}, @ref{ICHAR}
5436 @section @code{IAND} --- Bitwise logical and
5438 @cindex bitwise logical and
5439 @cindex logical and, bitwise
5442 @item @emph{Description}:
5443 Bitwise logical @code{AND}.
5445 @item @emph{Standard}:
5446 Fortran 95 and later
5451 @item @emph{Syntax}:
5452 @code{RESULT = IAND(I, J)}
5454 @item @emph{Arguments}:
5455 @multitable @columnfractions .15 .70
5456 @item @var{I} @tab The type shall be @code{INTEGER}.
5457 @item @var{J} @tab The type shall be @code{INTEGER}, of the same
5458 kind as @var{I}. (As a GNU extension, different kinds are also
5462 @item @emph{Return value}:
5463 The return type is @code{INTEGER}, of the same kind as the
5464 arguments. (If the argument kinds differ, it is of the same kind as
5465 the larger argument.)
5467 @item @emph{Example}:
5471 DATA a / Z'F' /, b / Z'3' /
5472 WRITE (*,*) IAND(a, b)
5476 @item @emph{See also}:
5477 @ref{IOR}, @ref{IEOR}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
5484 @section @code{IARGC} --- Get the number of command line arguments
5486 @cindex command-line arguments
5487 @cindex command-line arguments, number of
5488 @cindex arguments, to program
5491 @item @emph{Description}:
5492 @code{IARGC()} returns the number of arguments passed on the
5493 command line when the containing program was invoked.
5495 This intrinsic routine is provided for backwards compatibility with
5496 GNU Fortran 77. In new code, programmers should consider the use of
5497 the @ref{COMMAND_ARGUMENT_COUNT} intrinsic defined by the Fortran 2003
5500 @item @emph{Standard}:
5506 @item @emph{Syntax}:
5507 @code{RESULT = IARGC()}
5509 @item @emph{Arguments}:
5512 @item @emph{Return value}:
5513 The number of command line arguments, type @code{INTEGER(4)}.
5515 @item @emph{Example}:
5518 @item @emph{See also}:
5519 GNU Fortran 77 compatibility subroutine: @ref{GETARG}
5521 Fortran 2003 functions and subroutines: @ref{GET_COMMAND},
5522 @ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
5528 @section @code{IBCLR} --- Clear bit
5534 @item @emph{Description}:
5535 @code{IBCLR} returns the value of @var{I} with the bit at position
5536 @var{POS} set to zero.
5538 @item @emph{Standard}:
5539 Fortran 95 and later
5544 @item @emph{Syntax}:
5545 @code{RESULT = IBCLR(I, POS)}
5547 @item @emph{Arguments}:
5548 @multitable @columnfractions .15 .70
5549 @item @var{I} @tab The type shall be @code{INTEGER}.
5550 @item @var{POS} @tab The type shall be @code{INTEGER}.
5553 @item @emph{Return value}:
5554 The return value is of type @code{INTEGER} and of the same kind as
5557 @item @emph{See also}:
5558 @ref{IBITS}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}, @ref{MVBITS}
5565 @section @code{IBITS} --- Bit extraction
5568 @cindex bits, extract
5571 @item @emph{Description}:
5572 @code{IBITS} extracts a field of length @var{LEN} from @var{I},
5573 starting from bit position @var{POS} and extending left for @var{LEN}
5574 bits. The result is right-justified and the remaining bits are
5575 zeroed. The value of @code{POS+LEN} must be less than or equal to the
5576 value @code{BIT_SIZE(I)}.
5578 @item @emph{Standard}:
5579 Fortran 95 and later
5584 @item @emph{Syntax}:
5585 @code{RESULT = IBITS(I, POS, LEN)}
5587 @item @emph{Arguments}:
5588 @multitable @columnfractions .15 .70
5589 @item @var{I} @tab The type shall be @code{INTEGER}.
5590 @item @var{POS} @tab The type shall be @code{INTEGER}.
5591 @item @var{LEN} @tab The type shall be @code{INTEGER}.
5594 @item @emph{Return value}:
5595 The return value is of type @code{INTEGER} and of the same kind as
5598 @item @emph{See also}:
5599 @ref{BIT_SIZE}, @ref{IBCLR}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
5605 @section @code{IBSET} --- Set bit
5610 @item @emph{Description}:
5611 @code{IBSET} returns the value of @var{I} with the bit at position
5612 @var{POS} set to one.
5614 @item @emph{Standard}:
5615 Fortran 95 and later
5620 @item @emph{Syntax}:
5621 @code{RESULT = IBSET(I, POS)}
5623 @item @emph{Arguments}:
5624 @multitable @columnfractions .15 .70
5625 @item @var{I} @tab The type shall be @code{INTEGER}.
5626 @item @var{POS} @tab The type shall be @code{INTEGER}.
5629 @item @emph{Return value}:
5630 The return value is of type @code{INTEGER} and of the same kind as
5633 @item @emph{See also}:
5634 @ref{IBCLR}, @ref{IBITS}, @ref{IAND}, @ref{IOR}, @ref{IEOR}, @ref{MVBITS}
5641 @section @code{ICHAR} --- Character-to-integer conversion function
5643 @cindex conversion, to integer
5646 @item @emph{Description}:
5647 @code{ICHAR(C)} returns the code for the character in the first character
5648 position of @code{C} in the system's native character set.
5649 The correspondence between characters and their codes is not necessarily
5650 the same across different GNU Fortran implementations.
5652 @item @emph{Standard}:
5653 Fortan 95 and later, with @var{KIND} argument Fortran 2003 and later
5658 @item @emph{Syntax}:
5659 @code{RESULT = ICHAR(C [, KIND])}
5661 @item @emph{Arguments}:
5662 @multitable @columnfractions .15 .70
5663 @item @var{C} @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
5664 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
5665 expression indicating the kind parameter of
5669 @item @emph{Return value}:
5670 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
5671 @var{KIND} is absent, the return value is of default integer kind.
5673 @item @emph{Example}:
5678 end program test_ichar
5682 No intrinsic exists to convert between a numeric value and a formatted
5683 character string representation -- for instance, given the
5684 @code{CHARACTER} value @code{'154'}, obtaining an @code{INTEGER} or
5685 @code{REAL} value with the value 154, or vice versa. Instead, this
5686 functionality is provided by internal-file I/O, as in the following
5691 character(len=10) string, string2
5694 ! Convert a string to a numeric value
5695 read (string,'(I10)') value
5698 ! Convert a value to a formatted string
5699 write (string2,'(I10)') value
5701 end program read_val
5704 @item @emph{See also}:
5705 @ref{ACHAR}, @ref{CHAR}, @ref{IACHAR}
5712 @section @code{IDATE} --- Get current local time subroutine (day/month/year)
5714 @cindex date, current
5715 @cindex current date
5718 @item @emph{Description}:
5719 @code{IDATE(TARRAY)} Fills @var{TARRAY} with the numerical values at the
5720 current local time. The day (in the range 1-31), month (in the range 1-12),
5721 and year appear in elements 1, 2, and 3 of @var{TARRAY}, respectively.
5722 The year has four significant digits.
5724 @item @emph{Standard}:
5730 @item @emph{Syntax}:
5731 @code{CALL IDATE(VALUES)}
5733 @item @emph{Arguments}:
5734 @multitable @columnfractions .15 .70
5735 @item @var{VALUES} @tab The type shall be @code{INTEGER, DIMENSION(3)} and
5736 the kind shall be the default integer kind.
5739 @item @emph{Return value}:
5742 @item @emph{Example}:
5745 integer, dimension(3) :: tarray
5750 end program test_idate
5757 @section @code{IEOR} --- Bitwise logical exclusive or
5759 @cindex bitwise logical exclusive or
5760 @cindex logical exclusive or, bitwise
5763 @item @emph{Description}:
5764 @code{IEOR} returns the bitwise boolean exclusive-OR of @var{I} and
5767 @item @emph{Standard}:
5768 Fortran 95 and later
5773 @item @emph{Syntax}:
5774 @code{RESULT = IEOR(I, J)}
5776 @item @emph{Arguments}:
5777 @multitable @columnfractions .15 .70
5778 @item @var{I} @tab The type shall be @code{INTEGER}.
5779 @item @var{J} @tab The type shall be @code{INTEGER}, of the same
5780 kind as @var{I}. (As a GNU extension, different kinds are also
5784 @item @emph{Return value}:
5785 The return type is @code{INTEGER}, of the same kind as the
5786 arguments. (If the argument kinds differ, it is of the same kind as
5787 the larger argument.)
5789 @item @emph{See also}:
5790 @ref{IOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
5796 @section @code{IERRNO} --- Get the last system error number
5798 @cindex system, error handling
5801 @item @emph{Description}:
5802 Returns the last system error number, as given by the C @code{errno()}
5805 @item @emph{Standard}:
5811 @item @emph{Syntax}:
5812 @code{RESULT = IERRNO()}
5814 @item @emph{Arguments}:
5817 @item @emph{Return value}:
5818 The return value is of type @code{INTEGER} and of the default integer
5821 @item @emph{See also}:
5827 @node INDEX intrinsic
5828 @section @code{INDEX} --- Position of a substring within a string
5830 @cindex substring position
5831 @cindex string, find substring
5834 @item @emph{Description}:
5835 Returns the position of the start of the first occurrence of string
5836 @var{SUBSTRING} as a substring in @var{STRING}, counting from one. If
5837 @var{SUBSTRING} is not present in @var{STRING}, zero is returned. If
5838 the @var{BACK} argument is present and true, the return value is the
5839 start of the last occurrence rather than the first.
5841 @item @emph{Standard}:
5842 Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later
5847 @item @emph{Syntax}:
5848 @code{RESULT = INDEX(STRING, SUBSTRING [, BACK [, KIND]])}
5850 @item @emph{Arguments}:
5851 @multitable @columnfractions .15 .70
5852 @item @var{STRING} @tab Shall be a scalar @code{CHARACTER}, with
5854 @item @var{SUBSTRING} @tab Shall be a scalar @code{CHARACTER}, with
5856 @item @var{BACK} @tab (Optional) Shall be a scalar @code{LOGICAL}, with
5858 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
5859 expression indicating the kind parameter of
5863 @item @emph{Return value}:
5864 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
5865 @var{KIND} is absent, the return value is of default integer kind.
5867 @item @emph{See also}:
5868 @ref{SCAN}, @ref{VERIFY}
5874 @section @code{INT} --- Convert to integer type
5878 @cindex conversion, to integer
5881 @item @emph{Description}:
5882 Convert to integer type
5884 @item @emph{Standard}:
5885 Fortran 77 and later
5890 @item @emph{Syntax}:
5891 @code{RESULT = INT(A [, KIND))}
5893 @item @emph{Arguments}:
5894 @multitable @columnfractions .15 .70
5895 @item @var{A} @tab Shall be of type @code{INTEGER},
5896 @code{REAL}, or @code{COMPLEX}.
5897 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
5898 expression indicating the kind parameter of
5902 @item @emph{Return value}:
5903 These functions return a @code{INTEGER} variable or array under
5904 the following rules:
5908 If @var{A} is of type @code{INTEGER}, @code{INT(A) = A}
5910 If @var{A} is of type @code{REAL} and @math{|A| < 1}, @code{INT(A)} equals @code{0}.
5911 If @math{|A| \geq 1}, then @code{INT(A)} equals the largest integer that does not exceed
5912 the range of @var{A} and whose sign is the same as the sign of @var{A}.
5914 If @var{A} is of type @code{COMPLEX}, rule B is applied to the real part of @var{A}.
5917 @item @emph{Example}:
5921 complex :: z = (-3.7, 1.0)
5923 print *, int(z), int(z,8)
5927 @item @emph{Specific names}:
5928 @multitable @columnfractions .20 .20 .20 .25
5929 @item Name @tab Argument @tab Return type @tab Standard
5930 @item @code{IFIX(A)} @tab @code{REAL(4) A} @tab @code{INTEGER} @tab Fortran 77 and later
5931 @item @code{IDINT(A)} @tab @code{REAL(8) A} @tab @code{INTEGER} @tab Fortran 77 and later
5939 @section @code{INT2} --- Convert to 16-bit integer type
5942 @cindex conversion, to integer
5945 @item @emph{Description}:
5946 Convert to a @code{KIND=2} integer type. This is equivalent to the
5947 standard @code{INT} intrinsic with an optional argument of
5948 @code{KIND=2}, and is only included for backwards compatibility.
5950 The @code{SHORT} intrinsic is equivalent to @code{INT2}.
5952 @item @emph{Standard}:
5958 @item @emph{Syntax}:
5959 @code{RESULT = INT2(A)}
5961 @item @emph{Arguments}:
5962 @multitable @columnfractions .15 .70
5963 @item @var{A} @tab Shall be of type @code{INTEGER},
5964 @code{REAL}, or @code{COMPLEX}.
5967 @item @emph{Return value}:
5968 The return value is a @code{INTEGER(2)} variable.
5970 @item @emph{See also}:
5971 @ref{INT}, @ref{INT8}, @ref{LONG}
5977 @section @code{INT8} --- Convert to 64-bit integer type
5979 @cindex conversion, to integer
5982 @item @emph{Description}:
5983 Convert to a @code{KIND=8} integer type. This is equivalent to the
5984 standard @code{INT} intrinsic with an optional argument of
5985 @code{KIND=8}, and is only included for backwards compatibility.
5987 @item @emph{Standard}:
5993 @item @emph{Syntax}:
5994 @code{RESULT = INT8(A)}
5996 @item @emph{Arguments}:
5997 @multitable @columnfractions .15 .70
5998 @item @var{A} @tab Shall be of type @code{INTEGER},
5999 @code{REAL}, or @code{COMPLEX}.
6002 @item @emph{Return value}:
6003 The return value is a @code{INTEGER(8)} variable.
6005 @item @emph{See also}:
6006 @ref{INT}, @ref{INT2}, @ref{LONG}
6012 @section @code{IOR} --- Bitwise logical or
6014 @cindex bitwise logical or
6015 @cindex logical or, bitwise
6018 @item @emph{Description}:
6019 @code{IOR} returns the bitwise boolean inclusive-OR of @var{I} and
6022 @item @emph{Standard}:
6023 Fortran 95 and later
6028 @item @emph{Syntax}:
6029 @code{RESULT = IOR(I, J)}
6031 @item @emph{Arguments}:
6032 @multitable @columnfractions .15 .70
6033 @item @var{I} @tab The type shall be @code{INTEGER}.
6034 @item @var{J} @tab The type shall be @code{INTEGER}, of the same
6035 kind as @var{I}. (As a GNU extension, different kinds are also
6039 @item @emph{Return value}:
6040 The return type is @code{INTEGER}, of the same kind as the
6041 arguments. (If the argument kinds differ, it is of the same kind as
6042 the larger argument.)
6044 @item @emph{See also}:
6045 @ref{IEOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
6051 @section @code{IRAND} --- Integer pseudo-random number
6053 @cindex random number generation
6056 @item @emph{Description}:
6057 @code{IRAND(FLAG)} returns a pseudo-random number from a uniform
6058 distribution between 0 and a system-dependent limit (which is in most
6059 cases 2147483647). If @var{FLAG} is 0, the next number
6060 in the current sequence is returned; if @var{FLAG} is 1, the generator
6061 is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
6062 it is used as a new seed with @code{SRAND}.
6064 This intrinsic routine is provided for backwards compatibility with
6065 GNU Fortran 77. It implements a simple modulo generator as provided
6066 by @command{g77}. For new code, one should consider the use of
6067 @ref{RANDOM_NUMBER} as it implements a superior algorithm.
6069 @item @emph{Standard}:
6075 @item @emph{Syntax}:
6076 @code{RESULT = IRAND(I)}
6078 @item @emph{Arguments}:
6079 @multitable @columnfractions .15 .70
6080 @item @var{I} @tab Shall be a scalar @code{INTEGER} of kind 4.
6083 @item @emph{Return value}:
6084 The return value is of @code{INTEGER(kind=4)} type.
6086 @item @emph{Example}:
6089 integer,parameter :: seed = 86456
6092 print *, irand(), irand(), irand(), irand()
6093 print *, irand(seed), irand(), irand(), irand()
6094 end program test_irand
6102 @section @code{IS_IOSTAT_END} --- Test for end-of-file value
6103 @fnindex IS_IOSTAT_END
6104 @cindex IOSTAT, end of file
6107 @item @emph{Description}:
6108 @code{IS_IOSTAT_END} tests whether an variable has the value of the I/O
6109 status ``end of file''. The function is equivalent to comparing the variable
6110 with the @code{IOSTAT_END} parameter of the intrinsic module
6111 @code{ISO_FORTRAN_ENV}.
6113 @item @emph{Standard}:
6114 Fortran 2003 and later
6119 @item @emph{Syntax}:
6120 @code{RESULT = IS_IOSTAT_END(I)}
6122 @item @emph{Arguments}:
6123 @multitable @columnfractions .15 .70
6124 @item @var{I} @tab Shall be of the type @code{INTEGER}.
6127 @item @emph{Return value}:
6128 Returns a @code{LOGICAL} of the default kind, which @code{.TRUE.} if
6129 @var{I} has the value which indicates an end of file condition for
6130 IOSTAT= specifiers, and is @code{.FALSE.} otherwise.
6132 @item @emph{Example}:
6137 OPEN(88, FILE='test.dat')
6138 READ(88, *, IOSTAT=stat) i
6139 IF(IS_IOSTAT_END(stat)) STOP 'END OF FILE'
6147 @section @code{IS_IOSTAT_EOR} --- Test for end-of-record value
6148 @fnindex IS_IOSTAT_EOR
6149 @cindex IOSTAT, end of record
6152 @item @emph{Description}:
6153 @code{IS_IOSTAT_EOR} tests whether an variable has the value of the I/O
6154 status ``end of record''. The function is equivalent to comparing the
6155 variable with the @code{IOSTAT_EOR} parameter of the intrinsic module
6156 @code{ISO_FORTRAN_ENV}.
6158 @item @emph{Standard}:
6159 Fortran 2003 and later
6164 @item @emph{Syntax}:
6165 @code{RESULT = IS_IOSTAT_EOR(I)}
6167 @item @emph{Arguments}:
6168 @multitable @columnfractions .15 .70
6169 @item @var{I} @tab Shall be of the type @code{INTEGER}.
6172 @item @emph{Return value}:
6173 Returns a @code{LOGICAL} of the default kind, which @code{.TRUE.} if
6174 @var{I} has the value which indicates an end of file condition for
6175 IOSTAT= specifiers, and is @code{.FALSE.} otherwise.
6177 @item @emph{Example}:
6181 INTEGER :: stat, i(50)
6182 OPEN(88, FILE='test.dat', FORM='UNFORMATTED')
6183 READ(88, IOSTAT=stat) i
6184 IF(IS_IOSTAT_EOR(stat)) STOP 'END OF RECORD'
6192 @section @code{ISATTY} --- Whether a unit is a terminal device.
6194 @cindex system, terminal
6197 @item @emph{Description}:
6198 Determine whether a unit is connected to a terminal device.
6200 @item @emph{Standard}:
6206 @item @emph{Syntax}:
6207 @code{RESULT = ISATTY(UNIT)}
6209 @item @emph{Arguments}:
6210 @multitable @columnfractions .15 .70
6211 @item @var{UNIT} @tab Shall be a scalar @code{INTEGER}.
6214 @item @emph{Return value}:
6215 Returns @code{.TRUE.} if the @var{UNIT} is connected to a terminal
6216 device, @code{.FALSE.} otherwise.
6218 @item @emph{Example}:
6221 INTEGER(kind=1) :: unit
6223 write(*,*) isatty(unit=unit)
6227 @item @emph{See also}:
6234 @section @code{ISHFT} --- Shift bits
6239 @item @emph{Description}:
6240 @code{ISHFT} returns a value corresponding to @var{I} with all of the
6241 bits shifted @var{SHIFT} places. A value of @var{SHIFT} greater than
6242 zero corresponds to a left shift, a value of zero corresponds to no
6243 shift, and a value less than zero corresponds to a right shift. If the
6244 absolute value of @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the
6245 value is undefined. Bits shifted out from the left end or right end are
6246 lost; zeros are shifted in from the opposite end.
6248 @item @emph{Standard}:
6249 Fortran 95 and later
6254 @item @emph{Syntax}:
6255 @code{RESULT = ISHFT(I, SHIFT)}
6257 @item @emph{Arguments}:
6258 @multitable @columnfractions .15 .70
6259 @item @var{I} @tab The type shall be @code{INTEGER}.
6260 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
6263 @item @emph{Return value}:
6264 The return value is of type @code{INTEGER} and of the same kind as
6267 @item @emph{See also}:
6274 @section @code{ISHFTC} --- Shift bits circularly
6276 @cindex bits, shift circular
6279 @item @emph{Description}:
6280 @code{ISHFTC} returns a value corresponding to @var{I} with the
6281 rightmost @var{SIZE} bits shifted circularly @var{SHIFT} places; that
6282 is, bits shifted out one end are shifted into the opposite end. A value
6283 of @var{SHIFT} greater than zero corresponds to a left shift, a value of
6284 zero corresponds to no shift, and a value less than zero corresponds to
6285 a right shift. The absolute value of @var{SHIFT} must be less than
6286 @var{SIZE}. If the @var{SIZE} argument is omitted, it is taken to be
6287 equivalent to @code{BIT_SIZE(I)}.
6289 @item @emph{Standard}:
6290 Fortran 95 and later
6295 @item @emph{Syntax}:
6296 @code{RESULT = ISHFTC(I, SHIFT [, SIZE])}
6298 @item @emph{Arguments}:
6299 @multitable @columnfractions .15 .70
6300 @item @var{I} @tab The type shall be @code{INTEGER}.
6301 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
6302 @item @var{SIZE} @tab (Optional) The type shall be @code{INTEGER};
6303 the value must be greater than zero and less than or equal to
6307 @item @emph{Return value}:
6308 The return value is of type @code{INTEGER} and of the same kind as
6311 @item @emph{See also}:
6318 @section @code{ISNAN} --- Test for a NaN
6323 @item @emph{Description}:
6324 @code{ISNAN} tests whether a floating-point value is an IEEE
6326 @item @emph{Standard}:
6332 @item @emph{Syntax}:
6335 @item @emph{Arguments}:
6336 @multitable @columnfractions .15 .70
6337 @item @var{X} @tab Variable of the type @code{REAL}.
6341 @item @emph{Return value}:
6342 Returns a default-kind @code{LOGICAL}. The returned value is @code{TRUE}
6343 if @var{X} is a NaN and @code{FALSE} otherwise.
6345 @item @emph{Example}:
6352 if (isnan(x)) stop '"x" is a NaN'
6353 end program test_nan
6360 @section @code{ITIME} --- Get current local time subroutine (hour/minutes/seconds)
6362 @cindex time, current
6363 @cindex current time
6366 @item @emph{Description}:
6367 @code{IDATE(VALUES)} Fills @var{VALUES} with the numerical values at the
6368 current local time. The hour (in the range 1-24), minute (in the range 1-60),
6369 and seconds (in the range 1-60) appear in elements 1, 2, and 3 of @var{VALUES},
6372 @item @emph{Standard}:
6378 @item @emph{Syntax}:
6379 @code{CALL ITIME(VALUES)}
6381 @item @emph{Arguments}:
6382 @multitable @columnfractions .15 .70
6383 @item @var{VALUES} @tab The type shall be @code{INTEGER, DIMENSION(3)}
6384 and the kind shall be the default integer kind.
6387 @item @emph{Return value}:
6391 @item @emph{Example}:
6394 integer, dimension(3) :: tarray
6399 end program test_itime
6406 @section @code{KILL} --- Send a signal to a process
6410 @item @emph{Description}:
6411 @item @emph{Standard}:
6412 Sends the signal specified by @var{SIGNAL} to the process @var{PID}.
6415 This intrinsic is provided in both subroutine and function forms; however,
6416 only one form can be used in any given program unit.
6419 Subroutine, function
6421 @item @emph{Syntax}:
6422 @code{CALL KILL(C, VALUE [, STATUS])}
6424 @item @emph{Arguments}:
6425 @multitable @columnfractions .15 .70
6426 @item @var{C} @tab Shall be a scalar @code{INTEGER}, with
6428 @item @var{VALUE} @tab Shall be a scalar @code{INTEGER}, with
6430 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)} or
6431 @code{INTEGER(8)}. Returns 0 on success, or a
6432 system-specific error code otherwise.
6435 @item @emph{See also}:
6436 @ref{ABORT}, @ref{EXIT}
6442 @section @code{KIND} --- Kind of an entity
6447 @item @emph{Description}:
6448 @code{KIND(X)} returns the kind value of the entity @var{X}.
6450 @item @emph{Standard}:
6451 Fortran 95 and later
6456 @item @emph{Syntax}:
6459 @item @emph{Arguments}:
6460 @multitable @columnfractions .15 .70
6461 @item @var{X} @tab Shall be of type @code{LOGICAL}, @code{INTEGER},
6462 @code{REAL}, @code{COMPLEX} or @code{CHARACTER}.
6465 @item @emph{Return value}:
6466 The return value is a scalar of type @code{INTEGER} and of the default
6469 @item @emph{Example}:
6472 integer,parameter :: kc = kind(' ')
6473 integer,parameter :: kl = kind(.true.)
6475 print *, "The default character kind is ", kc
6476 print *, "The default logical kind is ", kl
6477 end program test_kind
6485 @section @code{LBOUND} --- Lower dimension bounds of an array
6487 @cindex array, lower bound
6490 @item @emph{Description}:
6491 Returns the lower bounds of an array, or a single lower bound
6492 along the @var{DIM} dimension.
6493 @item @emph{Standard}:
6494 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
6499 @item @emph{Syntax}:
6500 @code{RESULT = LBOUND(ARRAY [, DIM [, KIND]])}
6502 @item @emph{Arguments}:
6503 @multitable @columnfractions .15 .70
6504 @item @var{ARRAY} @tab Shall be an array, of any type.
6505 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
6506 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
6507 expression indicating the kind parameter of
6511 @item @emph{Return value}:
6512 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
6513 @var{KIND} is absent, the return value is of default integer kind.
6514 If @var{DIM} is absent, the result is an array of the lower bounds of
6515 @var{ARRAY}. If @var{DIM} is present, the result is a scalar
6516 corresponding to the lower bound of the array along that dimension. If
6517 @var{ARRAY} is an expression rather than a whole array or array
6518 structure component, or if it has a zero extent along the relevant
6519 dimension, the lower bound is taken to be 1.
6521 @item @emph{See also}:
6528 @section @code{LEN} --- Length of a character entity
6530 @cindex string, length
6533 @item @emph{Description}:
6534 Returns the length of a character string. If @var{STRING} is an array,
6535 the length of an element of @var{STRING} is returned. Note that
6536 @var{STRING} need not be defined when this intrinsic is invoked, since
6537 only the length, not the content, of @var{STRING} is needed.
6539 @item @emph{Standard}:
6540 Fortran 77 and later, with @var{KIND} argument Fortran 2003 and later
6545 @item @emph{Syntax}:
6546 @code{L = LEN(STRING [, KIND])}
6548 @item @emph{Arguments}:
6549 @multitable @columnfractions .15 .70
6550 @item @var{STRING} @tab Shall be a scalar or array of type
6551 @code{CHARACTER}, with @code{INTENT(IN)}
6552 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
6553 expression indicating the kind parameter of
6557 @item @emph{Return value}:
6558 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
6559 @var{KIND} is absent, the return value is of default integer kind.
6561 @item @emph{See also}:
6562 @ref{LEN_TRIM}, @ref{ADJUSTL}, @ref{ADJUSTR}
6568 @section @code{LEN_TRIM} --- Length of a character entity without trailing blank characters
6570 @cindex string, length, without trailing whitespace
6573 @item @emph{Description}:
6574 Returns the length of a character string, ignoring any trailing blanks.
6576 @item @emph{Standard}:
6577 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
6582 @item @emph{Syntax}:
6583 @code{RESULT = LEN_TRIM(STRING [, KIND])}
6585 @item @emph{Arguments}:
6586 @multitable @columnfractions .15 .70
6587 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER},
6588 with @code{INTENT(IN)}
6589 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
6590 expression indicating the kind parameter of
6594 @item @emph{Return value}:
6595 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
6596 @var{KIND} is absent, the return value is of default integer kind.
6598 @item @emph{See also}:
6599 @ref{LEN}, @ref{ADJUSTL}, @ref{ADJUSTR}
6605 @section @code{LGE} --- Lexical greater than or equal
6607 @cindex lexical comparison of strings
6608 @cindex string, comparison
6611 @item @emph{Description}:
6612 Determines whether one string is lexically greater than or equal to
6613 another string, where the two strings are interpreted as containing
6614 ASCII character codes. If the String A and String B are not the same
6615 length, the shorter is compared as if spaces were appended to it to form
6616 a value that has the same length as the longer.
6618 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
6619 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
6620 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
6621 that the latter use the processor's character ordering (which is not
6622 ASCII on some targets), whereas the former always use the ASCII
6625 @item @emph{Standard}:
6626 Fortran 77 and later
6631 @item @emph{Syntax}:
6632 @code{RESULT = LGE(STRING_A, STRING_B)}
6634 @item @emph{Arguments}:
6635 @multitable @columnfractions .15 .70
6636 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
6637 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
6640 @item @emph{Return value}:
6641 Returns @code{.TRUE.} if @code{STRING_A >= STRING_B}, and @code{.FALSE.}
6642 otherwise, based on the ASCII ordering.
6644 @item @emph{See also}:
6645 @ref{LGT}, @ref{LLE}, @ref{LLT}
6651 @section @code{LGT} --- Lexical greater than
6653 @cindex lexical comparison of strings
6654 @cindex string, comparison
6657 @item @emph{Description}:
6658 Determines whether one string is lexically greater than another string,
6659 where the two strings are interpreted as containing ASCII character
6660 codes. If the String A and String B are not the same length, the
6661 shorter is compared as if spaces were appended to it to form a value
6662 that has the same length as the longer.
6664 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
6665 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
6666 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
6667 that the latter use the processor's character ordering (which is not
6668 ASCII on some targets), whereas the former always use the ASCII
6671 @item @emph{Standard}:
6672 Fortran 77 and later
6677 @item @emph{Syntax}:
6678 @code{RESULT = LGT(STRING_A, STRING_B)}
6680 @item @emph{Arguments}:
6681 @multitable @columnfractions .15 .70
6682 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
6683 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
6686 @item @emph{Return value}:
6687 Returns @code{.TRUE.} if @code{STRING_A > STRING_B}, and @code{.FALSE.}
6688 otherwise, based on the ASCII ordering.
6690 @item @emph{See also}:
6691 @ref{LGE}, @ref{LLE}, @ref{LLT}
6697 @section @code{LINK} --- Create a hard link
6699 @cindex file system, create link
6700 @cindex file system, hard link
6703 @item @emph{Description}:
6704 Makes a (hard) link from file @var{PATH1} to @var{PATH2}. A null
6705 character (@code{CHAR(0)}) can be used to mark the end of the names in
6706 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
6707 names are ignored. If the @var{STATUS} argument is supplied, it
6708 contains 0 on success or a nonzero error code upon return; see
6711 This intrinsic is provided in both subroutine and function forms;
6712 however, only one form can be used in any given program unit.
6714 @item @emph{Standard}:
6718 Subroutine, function
6720 @item @emph{Syntax}:
6721 @multitable @columnfractions .80
6722 @item @code{CALL LINK(PATH1, PATH2 [, STATUS])}
6723 @item @code{STATUS = LINK(PATH1, PATH2)}
6726 @item @emph{Arguments}:
6727 @multitable @columnfractions .15 .70
6728 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
6729 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
6730 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
6733 @item @emph{See also}:
6734 @ref{SYMLNK}, @ref{UNLINK}
6740 @section @code{LLE} --- Lexical less than or equal
6742 @cindex lexical comparison of strings
6743 @cindex string, comparison
6746 @item @emph{Description}:
6747 Determines whether one string is lexically less than or equal to another
6748 string, where the two strings are interpreted as containing ASCII
6749 character codes. If the String A and String B are not the same length,
6750 the shorter is compared as if spaces were appended to it to form a value
6751 that has the same length as the longer.
6753 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
6754 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
6755 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
6756 that the latter use the processor's character ordering (which is not
6757 ASCII on some targets), whereas the former always use the ASCII
6760 @item @emph{Standard}:
6761 Fortran 77 and later
6766 @item @emph{Syntax}:
6767 @code{RESULT = LLE(STRING_A, STRING_B)}
6769 @item @emph{Arguments}:
6770 @multitable @columnfractions .15 .70
6771 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
6772 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
6775 @item @emph{Return value}:
6776 Returns @code{.TRUE.} if @code{STRING_A <= STRING_B}, and @code{.FALSE.}
6777 otherwise, based on the ASCII ordering.
6779 @item @emph{See also}:
6780 @ref{LGE}, @ref{LGT}, @ref{LLT}
6786 @section @code{LLT} --- Lexical less than
6788 @cindex lexical comparison of strings
6789 @cindex string, comparison
6792 @item @emph{Description}:
6793 Determines whether one string is lexically less than another string,
6794 where the two strings are interpreted as containing ASCII character
6795 codes. If the String A and String B are not the same length, the
6796 shorter is compared as if spaces were appended to it to form a value
6797 that has the same length as the longer.
6799 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
6800 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
6801 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
6802 that the latter use the processor's character ordering (which is not
6803 ASCII on some targets), whereas the former always use the ASCII
6806 @item @emph{Standard}:
6807 Fortran 77 and later
6812 @item @emph{Syntax}:
6813 @code{RESULT = LLT(STRING_A, STRING_B)}
6815 @item @emph{Arguments}:
6816 @multitable @columnfractions .15 .70
6817 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
6818 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
6821 @item @emph{Return value}:
6822 Returns @code{.TRUE.} if @code{STRING_A < STRING_B}, and @code{.FALSE.}
6823 otherwise, based on the ASCII ordering.
6825 @item @emph{See also}:
6826 @ref{LGE}, @ref{LGT}, @ref{LLE}
6832 @section @code{LNBLNK} --- Index of the last non-blank character in a string
6834 @cindex string, find non-blank character
6837 @item @emph{Description}:
6838 Returns the length of a character string, ignoring any trailing blanks.
6839 This is identical to the standard @code{LEN_TRIM} intrinsic, and is only
6840 included for backwards compatibility.
6842 @item @emph{Standard}:
6848 @item @emph{Syntax}:
6849 @code{RESULT = LNBLNK(STRING)}
6851 @item @emph{Arguments}:
6852 @multitable @columnfractions .15 .70
6853 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER},
6854 with @code{INTENT(IN)}
6857 @item @emph{Return value}:
6858 The return value is of @code{INTEGER(kind=4)} type.
6860 @item @emph{See also}:
6861 @ref{INDEX intrinsic}, @ref{LEN_TRIM}
6867 @section @code{LOC} --- Returns the address of a variable
6869 @cindex location of a variable in memory
6872 @item @emph{Description}:
6873 @code{LOC(X)} returns the address of @var{X} as an integer.
6875 @item @emph{Standard}:
6881 @item @emph{Syntax}:
6882 @code{RESULT = LOC(X)}
6884 @item @emph{Arguments}:
6885 @multitable @columnfractions .15 .70
6886 @item @var{X} @tab Variable of any type.
6889 @item @emph{Return value}:
6890 The return value is of type @code{INTEGER}, with a @code{KIND}
6891 corresponding to the size (in bytes) of a memory address on the target
6894 @item @emph{Example}:
6901 end program test_loc
6908 @section @code{LOG} --- Logarithm function
6915 @cindex exponential function, inverse
6916 @cindex logarithmic function
6919 @item @emph{Description}:
6920 @code{LOG(X)} computes the logarithm of @var{X}.
6922 @item @emph{Standard}:
6923 Fortran 77 and later
6928 @item @emph{Syntax}:
6929 @code{RESULT = LOG(X)}
6931 @item @emph{Arguments}:
6932 @multitable @columnfractions .15 .70
6933 @item @var{X} @tab The type shall be @code{REAL} or
6937 @item @emph{Return value}:
6938 The return value is of type @code{REAL} or @code{COMPLEX}.
6939 The kind type parameter is the same as @var{X}.
6941 @item @emph{Example}:
6944 real(8) :: x = 1.0_8
6945 complex :: z = (1.0, 2.0)
6948 end program test_log
6951 @item @emph{Specific names}:
6952 @multitable @columnfractions .20 .20 .20 .25
6953 @item Name @tab Argument @tab Return type @tab Standard
6954 @item @code{ALOG(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab f95, gnu
6955 @item @code{DLOG(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
6956 @item @code{CLOG(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab f95, gnu
6957 @item @code{ZLOG(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
6958 @item @code{CDLOG(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
6965 @section @code{LOG10} --- Base 10 logarithm function
6969 @cindex exponential function, inverse
6970 @cindex logarithmic function
6973 @item @emph{Description}:
6974 @code{LOG10(X)} computes the base 10 logarithm of @var{X}.
6976 @item @emph{Standard}:
6977 Fortran 77 and later
6982 @item @emph{Syntax}:
6983 @code{RESULT = LOG10(X)}
6985 @item @emph{Arguments}:
6986 @multitable @columnfractions .15 .70
6987 @item @var{X} @tab The type shall be @code{REAL}.
6990 @item @emph{Return value}:
6991 The return value is of type @code{REAL} or @code{COMPLEX}.
6992 The kind type parameter is the same as @var{X}.
6994 @item @emph{Example}:
6997 real(8) :: x = 10.0_8
6999 end program test_log10
7002 @item @emph{Specific names}:
7003 @multitable @columnfractions .20 .20 .20 .25
7004 @item Name @tab Argument @tab Return type @tab Standard
7005 @item @code{ALOG10(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 95 and later
7006 @item @code{DLOG10(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 95 and later
7013 @section @code{LOG_GAMMA} --- Logarithm of the Gamma function
7018 @cindex Gamma function, logarithm of
7021 @item @emph{Description}:
7022 @code{LOG_GAMMA(X)} computes the natural logarithm of the absolute value
7023 of the Gamma (@math{\Gamma}) function.
7025 @item @emph{Standard}:
7026 Fortran 2008 and later
7031 @item @emph{Syntax}:
7032 @code{X = LOG_GAMMA(X)}
7034 @item @emph{Arguments}:
7035 @multitable @columnfractions .15 .70
7036 @item @var{X} @tab Shall be of type @code{REAL} and neither zero
7037 nor a negative integer.
7040 @item @emph{Return value}:
7041 The return value is of type @code{REAL} of the same kind as @var{X}.
7043 @item @emph{Example}:
7045 program test_log_gamma
7047 x = lgamma(x) ! returns 0.0
7048 end program test_log_gamma
7051 @item @emph{Specific names}:
7052 @multitable @columnfractions .20 .20 .20 .25
7053 @item Name @tab Argument @tab Return type @tab Standard
7054 @item @code{LGAMMA(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU Extension
7055 @item @code{ALGAMA(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU Extension
7056 @item @code{DLGAMA(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU Extension
7059 @item @emph{See also}:
7060 Gamma function: @ref{GAMMA}
7067 @section @code{LOGICAL} --- Convert to logical type
7069 @cindex conversion, to logical
7072 @item @emph{Description}:
7073 Converts one kind of @code{LOGICAL} variable to another.
7075 @item @emph{Standard}:
7076 Fortran 95 and later
7081 @item @emph{Syntax}:
7082 @code{RESULT = LOGICAL(L [, KIND])}
7084 @item @emph{Arguments}:
7085 @multitable @columnfractions .15 .70
7086 @item @var{L} @tab The type shall be @code{LOGICAL}.
7087 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
7088 expression indicating the kind parameter of
7092 @item @emph{Return value}:
7093 The return value is a @code{LOGICAL} value equal to @var{L}, with a
7094 kind corresponding to @var{KIND}, or of the default logical kind if
7095 @var{KIND} is not given.
7097 @item @emph{See also}:
7098 @ref{INT}, @ref{REAL}, @ref{CMPLX}
7104 @section @code{LONG} --- Convert to integer type
7106 @cindex conversion, to integer
7109 @item @emph{Description}:
7110 Convert to a @code{KIND=4} integer type, which is the same size as a C
7111 @code{long} integer. This is equivalent to the standard @code{INT}
7112 intrinsic with an optional argument of @code{KIND=4}, and is only
7113 included for backwards compatibility.
7115 @item @emph{Standard}:
7121 @item @emph{Syntax}:
7122 @code{RESULT = LONG(A)}
7124 @item @emph{Arguments}:
7125 @multitable @columnfractions .15 .70
7126 @item @var{A} @tab Shall be of type @code{INTEGER},
7127 @code{REAL}, or @code{COMPLEX}.
7130 @item @emph{Return value}:
7131 The return value is a @code{INTEGER(4)} variable.
7133 @item @emph{See also}:
7134 @ref{INT}, @ref{INT2}, @ref{INT8}
7140 @section @code{LSHIFT} --- Left shift bits
7142 @cindex bits, shift left
7145 @item @emph{Description}:
7146 @code{LSHIFT} returns a value corresponding to @var{I} with all of the
7147 bits shifted left by @var{SHIFT} places. If the absolute value of
7148 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
7149 Bits shifted out from the left end are lost; zeros are shifted in from
7152 This function has been superseded by the @code{ISHFT} intrinsic, which
7153 is standard in Fortran 95 and later.
7155 @item @emph{Standard}:
7161 @item @emph{Syntax}:
7162 @code{RESULT = LSHIFT(I, SHIFT)}
7164 @item @emph{Arguments}:
7165 @multitable @columnfractions .15 .70
7166 @item @var{I} @tab The type shall be @code{INTEGER}.
7167 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
7170 @item @emph{Return value}:
7171 The return value is of type @code{INTEGER} and of the same kind as
7174 @item @emph{See also}:
7175 @ref{ISHFT}, @ref{ISHFTC}, @ref{RSHIFT}
7182 @section @code{LSTAT} --- Get file status
7184 @cindex file system, file status
7187 @item @emph{Description}:
7188 @code{LSTAT} is identical to @ref{STAT}, except that if path is a symbolic link,
7189 then the link itself is statted, not the file that it refers to.
7191 The elements in @code{BUFF} are the same as described by @ref{STAT}.
7193 This intrinsic is provided in both subroutine and function forms; however,
7194 only one form can be used in any given program unit.
7196 @item @emph{Standard}:
7200 Subroutine, function
7202 @item @emph{Syntax}:
7203 @code{CALL LSTAT(FILE, BUFF [, STATUS])}
7205 @item @emph{Arguments}:
7206 @multitable @columnfractions .15 .70
7207 @item @var{FILE} @tab The type shall be @code{CHARACTER} of the default
7208 kind, a valid path within the file system.
7209 @item @var{BUFF} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
7210 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}.
7211 Returns 0 on success and a system specific error code otherwise.
7214 @item @emph{Example}:
7215 See @ref{STAT} for an example.
7217 @item @emph{See also}:
7218 To stat an open file: @ref{FSTAT}, to stat a file: @ref{STAT}
7224 @section @code{LTIME} --- Convert time to local time info
7226 @cindex time, conversion to local time info
7229 @item @emph{Description}:
7230 Given a system time value @var{STIME} (as provided by the @code{TIME8()}
7231 intrinsic), fills @var{TARRAY} with values extracted from it appropriate
7232 to the local time zone using @code{localtime(3)}.
7234 @item @emph{Standard}:
7240 @item @emph{Syntax}:
7241 @code{CALL LTIME(STIME, TARRAY)}
7243 @item @emph{Arguments}:
7244 @multitable @columnfractions .15 .70
7245 @item @var{STIME} @tab An @code{INTEGER} scalar expression
7246 corresponding to a system time, with
7248 @item @var{TARRAY} @tab A default @code{INTEGER} array with 9 elements,
7249 with @code{INTENT(OUT)}.
7252 @item @emph{Return value}:
7253 The elements of @var{TARRAY} are assigned as follows:
7255 @item Seconds after the minute, range 0--59 or 0--61 to allow for leap
7257 @item Minutes after the hour, range 0--59
7258 @item Hours past midnight, range 0--23
7259 @item Day of month, range 0--31
7260 @item Number of months since January, range 0--12
7261 @item Years since 1900
7262 @item Number of days since Sunday, range 0--6
7263 @item Days since January 1
7264 @item Daylight savings indicator: positive if daylight savings is in
7265 effect, zero if not, and negative if the information is not
7269 @item @emph{See also}:
7270 @ref{CTIME}, @ref{GMTIME}, @ref{TIME}, @ref{TIME8}
7277 @section @code{MALLOC} --- Allocate dynamic memory
7279 @cindex pointer, cray
7282 @item @emph{Description}:
7283 @code{MALLOC(SIZE)} allocates @var{SIZE} bytes of dynamic memory and
7284 returns the address of the allocated memory. The @code{MALLOC} intrinsic
7285 is an extension intended to be used with Cray pointers, and is provided
7286 in GNU Fortran to allow the user to compile legacy code. For new code
7287 using Fortran 95 pointers, the memory allocation intrinsic is
7290 @item @emph{Standard}:
7296 @item @emph{Syntax}:
7297 @code{PTR = MALLOC(SIZE)}
7299 @item @emph{Arguments}:
7300 @multitable @columnfractions .15 .70
7301 @item @var{SIZE} @tab The type shall be @code{INTEGER}.
7304 @item @emph{Return value}:
7305 The return value is of type @code{INTEGER(K)}, with @var{K} such that
7306 variables of type @code{INTEGER(K)} have the same size as
7307 C pointers (@code{sizeof(void *)}).
7309 @item @emph{Example}:
7310 The following example demonstrates the use of @code{MALLOC} and
7311 @code{FREE} with Cray pointers. This example is intended to run on
7312 32-bit systems, where the default integer kind is suitable to store
7313 pointers; on 64-bit systems, ptr_x would need to be declared as
7314 @code{integer(kind=8)}.
7323 ptr_x = malloc(20*8)
7325 x(i) = sqrt(1.0d0 / i)
7333 end program test_malloc
7336 @item @emph{See also}:
7343 @section @code{MATMUL} --- matrix multiplication
7345 @cindex matrix multiplication
7346 @cindex product, matrix
7349 @item @emph{Description}:
7350 Performs a matrix multiplication on numeric or logical arguments.
7352 @item @emph{Standard}:
7353 Fortran 95 and later
7356 Transformational function
7358 @item @emph{Syntax}:
7359 @code{RESULT = MATMUL(MATRIX_A, MATRIX_B)}
7361 @item @emph{Arguments}:
7362 @multitable @columnfractions .15 .70
7363 @item @var{MATRIX_A} @tab An array of @code{INTEGER},
7364 @code{REAL}, @code{COMPLEX}, or
7365 @code{LOGICAL} type, with a rank of
7367 @item @var{MATRIX_B} @tab An array of @code{INTEGER},
7368 @code{REAL}, or @code{COMPLEX} type if
7369 @var{MATRIX_A} is of a numeric type;
7370 otherwise, an array of @code{LOGICAL}
7371 type. The rank shall be one or two, and the
7372 first (or only) dimension of @var{MATRIX_B}
7373 shall be equal to the last (or only)
7374 dimension of @var{MATRIX_A}.
7377 @item @emph{Return value}:
7378 The matrix product of @var{MATRIX_A} and @var{MATRIX_B}. The type and
7379 kind of the result follow the usual type and kind promotion rules, as
7380 for the @code{*} or @code{.AND.} operators.
7382 @item @emph{See also}:
7388 @section @code{MAX} --- Maximum value of an argument list
7395 @cindex maximum value
7398 @item @emph{Description}:
7399 Returns the argument with the largest (most positive) value.
7401 @item @emph{Standard}:
7402 Fortran 77 and later
7407 @item @emph{Syntax}:
7408 @code{RESULT = MAX(A1, A2 [, A3 [, ...]])}
7410 @item @emph{Arguments}:
7411 @multitable @columnfractions .15 .70
7412 @item @var{A1} @tab The type shall be @code{INTEGER} or
7414 @item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
7415 as @var{A1}. (As a GNU extension,
7416 arguments of different kinds are
7420 @item @emph{Return value}:
7421 The return value corresponds to the maximum value among the arguments,
7422 and has the same type and kind as the first argument.
7424 @item @emph{Specific names}:
7425 @multitable @columnfractions .20 .20 .20 .25
7426 @item Name @tab Argument @tab Return type @tab Standard
7427 @item @code{MAX0(I)} @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)} @tab Fortran 77 and later
7428 @item @code{AMAX0(I)} @tab @code{INTEGER(4) I} @tab @code{REAL(MAX(X))} @tab Fortran 77 and later
7429 @item @code{MAX1(X)} @tab @code{REAL X} @tab @code{INT(MAX(X))} @tab Fortran 77 and later
7430 @item @code{AMAX1(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later
7431 @item @code{DMAX1(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
7434 @item @emph{See also}:
7435 @ref{MAXLOC} @ref{MAXVAL}, @ref{MIN}
7442 @section @code{MAXEXPONENT} --- Maximum exponent of a real kind
7443 @fnindex MAXEXPONENT
7444 @cindex model representation, maximum exponent
7447 @item @emph{Description}:
7448 @code{MAXEXPONENT(X)} returns the maximum exponent in the model of the
7451 @item @emph{Standard}:
7452 Fortran 95 and later
7457 @item @emph{Syntax}:
7458 @code{RESULT = MAXEXPONENT(X)}
7460 @item @emph{Arguments}:
7461 @multitable @columnfractions .15 .70
7462 @item @var{X} @tab Shall be of type @code{REAL}.
7465 @item @emph{Return value}:
7466 The return value is of type @code{INTEGER} and of the default integer
7469 @item @emph{Example}:
7475 print *, minexponent(x), maxexponent(x)
7476 print *, minexponent(y), maxexponent(y)
7477 end program exponents
7484 @section @code{MAXLOC} --- Location of the maximum value within an array
7486 @cindex array, location of maximum element
7489 @item @emph{Description}:
7490 Determines the location of the element in the array with the maximum
7491 value, or, if the @var{DIM} argument is supplied, determines the
7492 locations of the maximum element along each row of the array in the
7493 @var{DIM} direction. If @var{MASK} is present, only the elements for
7494 which @var{MASK} is @code{.TRUE.} are considered. If more than one
7495 element in the array has the maximum value, the location returned is
7496 that of the first such element in array element order. If the array has
7497 zero size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
7498 the result is an array of zeroes. Similarly, if @var{DIM} is supplied
7499 and all of the elements of @var{MASK} along a given row are zero, the
7500 result value for that row is zero.
7502 @item @emph{Standard}:
7503 Fortran 95 and later
7506 Transformational function
7508 @item @emph{Syntax}:
7509 @multitable @columnfractions .80
7510 @item @code{RESULT = MAXLOC(ARRAY, DIM [, MASK])}
7511 @item @code{RESULT = MAXLOC(ARRAY [, MASK])}
7514 @item @emph{Arguments}:
7515 @multitable @columnfractions .15 .70
7516 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER},
7517 @code{REAL}, or @code{CHARACTER}.
7518 @item @var{DIM} @tab (Optional) Shall be a scalar of type
7519 @code{INTEGER}, with a value between one
7520 and the rank of @var{ARRAY}, inclusive. It
7521 may not be an optional dummy argument.
7522 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL},
7523 and conformable with @var{ARRAY}.
7526 @item @emph{Return value}:
7527 If @var{DIM} is absent, the result is a rank-one array with a length
7528 equal to the rank of @var{ARRAY}. If @var{DIM} is present, the result
7529 is an array with a rank one less than the rank of @var{ARRAY}, and a
7530 size corresponding to the size of @var{ARRAY} with the @var{DIM}
7531 dimension removed. If @var{DIM} is present and @var{ARRAY} has a rank
7532 of one, the result is a scalar. In all cases, the result is of default
7533 @code{INTEGER} type.
7535 @item @emph{See also}:
7536 @ref{MAX}, @ref{MAXVAL}
7543 @section @code{MAXVAL} --- Maximum value of an array
7545 @cindex array, maximum value
7546 @cindex maximum value
7549 @item @emph{Description}:
7550 Determines the maximum value of the elements in an array value, or, if
7551 the @var{DIM} argument is supplied, determines the maximum value along
7552 each row of the array in the @var{DIM} direction. If @var{MASK} is
7553 present, only the elements for which @var{MASK} is @code{.TRUE.} are
7554 considered. If the array has zero size, or all of the elements of
7555 @var{MASK} are @code{.FALSE.}, then the result is the most negative
7556 number of the type and kind of @var{ARRAY} if @var{ARRAY} is numeric, or
7557 a string of nulls if @var{ARRAY} is of character type.
7559 @item @emph{Standard}:
7560 Fortran 95 and later
7563 Transformational function
7565 @item @emph{Syntax}:
7566 @multitable @columnfractions .80
7567 @item @code{RESULT = MAXVAL(ARRAY, DIM [, MASK])}
7568 @item @code{RESULT = MAXVAL(ARRAY [, MASK])}
7571 @item @emph{Arguments}:
7572 @multitable @columnfractions .15 .70
7573 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER},
7574 @code{REAL}, or @code{CHARACTER}.
7575 @item @var{DIM} @tab (Optional) Shall be a scalar of type
7576 @code{INTEGER}, with a value between one
7577 and the rank of @var{ARRAY}, inclusive. It
7578 may not be an optional dummy argument.
7579 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL},
7580 and conformable with @var{ARRAY}.
7583 @item @emph{Return value}:
7584 If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
7585 is a scalar. If @var{DIM} is present, the result is an array with a
7586 rank one less than the rank of @var{ARRAY}, and a size corresponding to
7587 the size of @var{ARRAY} with the @var{DIM} dimension removed. In all
7588 cases, the result is of the same type and kind as @var{ARRAY}.
7590 @item @emph{See also}:
7591 @ref{MAX}, @ref{MAXLOC}
7597 @section @code{MCLOCK} --- Time function
7599 @cindex time, clock ticks
7603 @item @emph{Description}:
7604 Returns the number of clock ticks since the start of the process, based
7605 on the UNIX function @code{clock(3)}.
7607 This intrinsic is not fully portable, such as to systems with 32-bit
7608 @code{INTEGER} types but supporting times wider than 32 bits. Therefore,
7609 the values returned by this intrinsic might be, or become, negative, or
7610 numerically less than previous values, during a single run of the
7613 @item @emph{Standard}:
7619 @item @emph{Syntax}:
7620 @code{RESULT = MCLOCK()}
7622 @item @emph{Return value}:
7623 The return value is a scalar of type @code{INTEGER(4)}, equal to the
7624 number of clock ticks since the start of the process, or @code{-1} if
7625 the system does not support @code{clock(3)}.
7627 @item @emph{See also}:
7628 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME}
7635 @section @code{MCLOCK8} --- Time function (64-bit)
7637 @cindex time, clock ticks
7641 @item @emph{Description}:
7642 Returns the number of clock ticks since the start of the process, based
7643 on the UNIX function @code{clock(3)}.
7645 @emph{Warning:} this intrinsic does not increase the range of the timing
7646 values over that returned by @code{clock(3)}. On a system with a 32-bit
7647 @code{clock(3)}, @code{MCLOCK8()} will return a 32-bit value, even though
7648 it is converted to a 64-bit @code{INTEGER(8)} value. That means
7649 overflows of the 32-bit value can still occur. Therefore, the values
7650 returned by this intrinsic might be or become negative or numerically
7651 less than previous values during a single run of the compiled program.
7653 @item @emph{Standard}:
7659 @item @emph{Syntax}:
7660 @code{RESULT = MCLOCK8()}
7662 @item @emph{Return value}:
7663 The return value is a scalar of type @code{INTEGER(8)}, equal to the
7664 number of clock ticks since the start of the process, or @code{-1} if
7665 the system does not support @code{clock(3)}.
7667 @item @emph{See also}:
7668 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME8}
7675 @section @code{MERGE} --- Merge variables
7677 @cindex array, merge arrays
7678 @cindex array, combine arrays
7681 @item @emph{Description}:
7682 Select values from two arrays according to a logical mask. The result
7683 is equal to @var{TSOURCE} if @var{MASK} is @code{.TRUE.}, or equal to
7684 @var{FSOURCE} if it is @code{.FALSE.}.
7686 @item @emph{Standard}:
7687 Fortran 95 and later
7692 @item @emph{Syntax}:
7693 @code{RESULT = MERGE(TSOURCE, FSOURCE, MASK)}
7695 @item @emph{Arguments}:
7696 @multitable @columnfractions .15 .70
7697 @item @var{TSOURCE} @tab May be of any type.
7698 @item @var{FSOURCE} @tab Shall be of the same type and type parameters
7700 @item @var{MASK} @tab Shall be of type @code{LOGICAL}.
7703 @item @emph{Return value}:
7704 The result is of the same type and type parameters as @var{TSOURCE}.
7711 @section @code{MIN} --- Minimum value of an argument list
7718 @cindex minimum value
7721 @item @emph{Description}:
7722 Returns the argument with the smallest (most negative) value.
7724 @item @emph{Standard}:
7725 Fortran 77 and later
7730 @item @emph{Syntax}:
7731 @code{RESULT = MIN(A1, A2 [, A3, ...])}
7733 @item @emph{Arguments}:
7734 @multitable @columnfractions .15 .70
7735 @item @var{A1} @tab The type shall be @code{INTEGER} or
7737 @item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
7738 as @var{A1}. (As a GNU extension,
7739 arguments of different kinds are
7743 @item @emph{Return value}:
7744 The return value corresponds to the maximum value among the arguments,
7745 and has the same type and kind as the first argument.
7747 @item @emph{Specific names}:
7748 @multitable @columnfractions .20 .20 .20 .25
7749 @item Name @tab Argument @tab Return type @tab Standard
7750 @item @code{MIN0(I)} @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)} @tab Fortran 77 and later
7751 @item @code{AMIN0(I)} @tab @code{INTEGER(4) I} @tab @code{REAL(MIN(X))} @tab Fortran 77 and later
7752 @item @code{MIN1(X)} @tab @code{REAL X} @tab @code{INT(MIN(X))} @tab Fortran 77 and later
7753 @item @code{AMIN1(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab Fortran 77 and later
7754 @item @code{DMIN1(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 77 and later
7757 @item @emph{See also}:
7758 @ref{MAX}, @ref{MINLOC}, @ref{MINVAL}
7764 @section @code{MINEXPONENT} --- Minimum exponent of a real kind
7765 @fnindex MINEXPONENT
7766 @cindex model representation, minimum exponent
7769 @item @emph{Description}:
7770 @code{MINEXPONENT(X)} returns the minimum exponent in the model of the
7773 @item @emph{Standard}:
7774 Fortran 95 and later
7779 @item @emph{Syntax}:
7780 @code{RESULT = MINEXPONENT(X)}
7782 @item @emph{Arguments}:
7783 @multitable @columnfractions .15 .70
7784 @item @var{X} @tab Shall be of type @code{REAL}.
7787 @item @emph{Return value}:
7788 The return value is of type @code{INTEGER} and of the default integer
7791 @item @emph{Example}:
7792 See @code{MAXEXPONENT} for an example.
7798 @section @code{MINLOC} --- Location of the minimum value within an array
7800 @cindex array, location of minimum element
7803 @item @emph{Description}:
7804 Determines the location of the element in the array with the minimum
7805 value, or, if the @var{DIM} argument is supplied, determines the
7806 locations of the minimum element along each row of the array in the
7807 @var{DIM} direction. If @var{MASK} is present, only the elements for
7808 which @var{MASK} is @code{.TRUE.} are considered. If more than one
7809 element in the array has the minimum value, the location returned is
7810 that of the first such element in array element order. If the array has
7811 zero size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
7812 the result is an array of zeroes. Similarly, if @var{DIM} is supplied
7813 and all of the elements of @var{MASK} along a given row are zero, the
7814 result value for that row is zero.
7816 @item @emph{Standard}:
7817 Fortran 95 and later
7820 Transformational function
7822 @item @emph{Syntax}:
7823 @multitable @columnfractions .80
7824 @item @code{RESULT = MINLOC(ARRAY, DIM [, MASK])}
7825 @item @code{RESULT = MINLOC(ARRAY [, MASK])}
7828 @item @emph{Arguments}:
7829 @multitable @columnfractions .15 .70
7830 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER},
7831 @code{REAL}, or @code{CHARACTER}.
7832 @item @var{DIM} @tab (Optional) Shall be a scalar of type
7833 @code{INTEGER}, with a value between one
7834 and the rank of @var{ARRAY}, inclusive. It
7835 may not be an optional dummy argument.
7836 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL},
7837 and conformable with @var{ARRAY}.
7840 @item @emph{Return value}:
7841 If @var{DIM} is absent, the result is a rank-one array with a length
7842 equal to the rank of @var{ARRAY}. If @var{DIM} is present, the result
7843 is an array with a rank one less than the rank of @var{ARRAY}, and a
7844 size corresponding to the size of @var{ARRAY} with the @var{DIM}
7845 dimension removed. If @var{DIM} is present and @var{ARRAY} has a rank
7846 of one, the result is a scalar. In all cases, the result is of default
7847 @code{INTEGER} type.
7849 @item @emph{See also}:
7850 @ref{MIN}, @ref{MINVAL}
7857 @section @code{MINVAL} --- Minimum value of an array
7859 @cindex array, minimum value
7860 @cindex minimum value
7863 @item @emph{Description}:
7864 Determines the minimum value of the elements in an array value, or, if
7865 the @var{DIM} argument is supplied, determines the minimum value along
7866 each row of the array in the @var{DIM} direction. If @var{MASK} is
7867 present, only the elements for which @var{MASK} is @code{.TRUE.} are
7868 considered. If the array has zero size, or all of the elements of
7869 @var{MASK} are @code{.FALSE.}, then the result is @code{HUGE(ARRAY)} if
7870 @var{ARRAY} is numeric, or a string of @code{CHAR(255)} characters if
7871 @var{ARRAY} is of character type.
7873 @item @emph{Standard}:
7874 Fortran 95 and later
7877 Transformational function
7879 @item @emph{Syntax}:
7880 @multitable @columnfractions .80
7881 @item @code{RESULT = MINVAL(ARRAY, DIM [, MASK])}
7882 @item @code{RESULT = MINVAL(ARRAY [, MASK])}
7885 @item @emph{Arguments}:
7886 @multitable @columnfractions .15 .70
7887 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER},
7888 @code{REAL}, or @code{CHARACTER}.
7889 @item @var{DIM} @tab (Optional) Shall be a scalar of type
7890 @code{INTEGER}, with a value between one
7891 and the rank of @var{ARRAY}, inclusive. It
7892 may not be an optional dummy argument.
7893 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL},
7894 and conformable with @var{ARRAY}.
7897 @item @emph{Return value}:
7898 If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
7899 is a scalar. If @var{DIM} is present, the result is an array with a
7900 rank one less than the rank of @var{ARRAY}, and a size corresponding to
7901 the size of @var{ARRAY} with the @var{DIM} dimension removed. In all
7902 cases, the result is of the same type and kind as @var{ARRAY}.
7904 @item @emph{See also}:
7905 @ref{MIN}, @ref{MINLOC}
7912 @section @code{MOD} --- Remainder function
7917 @cindex division, remainder
7920 @item @emph{Description}:
7921 @code{MOD(A,P)} computes the remainder of the division of A by P@. It is
7922 calculated as @code{A - (INT(A/P) * P)}.
7924 @item @emph{Standard}:
7925 Fortran 77 and later
7930 @item @emph{Syntax}:
7931 @code{RESULT = MOD(A, P)}
7933 @item @emph{Arguments}:
7934 @multitable @columnfractions .15 .70
7935 @item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL}
7936 @item @var{P} @tab Shall be a scalar of the same type as @var{A} and not
7940 @item @emph{Return value}:
7941 The kind of the return value is the result of cross-promoting
7942 the kinds of the arguments.
7944 @item @emph{Example}:
7948 print *, mod(17.5,5.5)
7949 print *, mod(17.5d0,5.5)
7950 print *, mod(17.5,5.5d0)
7953 print *, mod(-17.5,5.5)
7954 print *, mod(-17.5d0,5.5)
7955 print *, mod(-17.5,5.5d0)
7958 print *, mod(17.5,-5.5)
7959 print *, mod(17.5d0,-5.5)
7960 print *, mod(17.5,-5.5d0)
7961 end program test_mod
7964 @item @emph{Specific names}:
7965 @multitable @columnfractions .20 .20 .20 .25
7966 @item Name @tab Arguments @tab Return type @tab Standard
7967 @item @code{AMOD(A,P)} @tab @code{REAL(4)} @tab @code{REAL(4)} @tab Fortran 95 and later
7968 @item @code{DMOD(A,P)} @tab @code{REAL(8)} @tab @code{REAL(8)} @tab Fortran 95 and later
7975 @section @code{MODULO} --- Modulo function
7978 @cindex division, modulo
7981 @item @emph{Description}:
7982 @code{MODULO(A,P)} computes the @var{A} modulo @var{P}.
7984 @item @emph{Standard}:
7985 Fortran 95 and later
7990 @item @emph{Syntax}:
7991 @code{RESULT = MODULO(A, P)}
7993 @item @emph{Arguments}:
7994 @multitable @columnfractions .15 .70
7995 @item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL}
7996 @item @var{P} @tab Shall be a scalar of the same type and kind as @var{A}
7999 @item @emph{Return value}:
8000 The type and kind of the result are those of the arguments.
8002 @item If @var{A} and @var{P} are of type @code{INTEGER}:
8003 @code{MODULO(A,P)} has the value @var{R} such that @code{A=Q*P+R}, where
8004 @var{Q} is an integer and @var{R} is between 0 (inclusive) and @var{P}
8006 @item If @var{A} and @var{P} are of type @code{REAL}:
8007 @code{MODULO(A,P)} has the value of @code{A - FLOOR (A / P) * P}.
8009 In all cases, if @var{P} is zero the result is processor-dependent.
8011 @item @emph{Example}:
8014 print *, modulo(17,3)
8015 print *, modulo(17.5,5.5)
8017 print *, modulo(-17,3)
8018 print *, modulo(-17.5,5.5)
8020 print *, modulo(17,-3)
8021 print *, modulo(17.5,-5.5)
8030 @section @code{MOVE_ALLOC} --- Move allocation from one object to another
8032 @cindex moving allocation
8033 @cindex allocation, moving
8036 @item @emph{Description}:
8037 @code{MOVE_ALLOC(SRC, DEST)} moves the allocation from @var{SRC} to
8038 @var{DEST}. @var{SRC} will become deallocated in the process.
8040 @item @emph{Standard}:
8041 Fortran 2003 and later
8046 @item @emph{Syntax}:
8047 @code{CALL MOVE_ALLOC(SRC, DEST)}
8049 @item @emph{Arguments}:
8050 @multitable @columnfractions .15 .70
8051 @item @var{SRC} @tab @code{ALLOCATABLE}, @code{INTENT(INOUT)}, may be
8052 of any type and kind.
8053 @item @var{DEST} @tab @code{ALLOCATABLE}, @code{INTENT(OUT)}, shall be
8054 of the same type, kind and rank as @var{SRC}
8057 @item @emph{Return value}:
8060 @item @emph{Example}:
8062 program test_move_alloc
8063 integer, allocatable :: a(:), b(:)
8067 call move_alloc(a, b)
8068 print *, allocated(a), allocated(b)
8070 end program test_move_alloc
8077 @section @code{MVBITS} --- Move bits from one integer to another
8082 @item @emph{Description}:
8083 Moves @var{LEN} bits from positions @var{FROMPOS} through
8084 @code{FROMPOS+LEN-1} of @var{FROM} to positions @var{TOPOS} through
8085 @code{TOPOS+LEN-1} of @var{TO}. The portion of argument @var{TO} not
8086 affected by the movement of bits is unchanged. The values of
8087 @code{FROMPOS+LEN-1} and @code{TOPOS+LEN-1} must be less than
8088 @code{BIT_SIZE(FROM)}.
8090 @item @emph{Standard}:
8091 Fortran 95 and later
8094 Elemental subroutine
8096 @item @emph{Syntax}:
8097 @code{CALL MVBITS(FROM, FROMPOS, LEN, TO, TOPOS)}
8099 @item @emph{Arguments}:
8100 @multitable @columnfractions .15 .70
8101 @item @var{FROM} @tab The type shall be @code{INTEGER}.
8102 @item @var{FROMPOS} @tab The type shall be @code{INTEGER}.
8103 @item @var{LEN} @tab The type shall be @code{INTEGER}.
8104 @item @var{TO} @tab The type shall be @code{INTEGER}, of the
8105 same kind as @var{FROM}.
8106 @item @var{TOPOS} @tab The type shall be @code{INTEGER}.
8109 @item @emph{See also}:
8110 @ref{IBCLR}, @ref{IBSET}, @ref{IBITS}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
8116 @section @code{NEAREST} --- Nearest representable number
8118 @cindex real number, nearest different
8119 @cindex floating point, nearest different
8122 @item @emph{Description}:
8123 @code{NEAREST(X, S)} returns the processor-representable number nearest
8124 to @code{X} in the direction indicated by the sign of @code{S}.
8126 @item @emph{Standard}:
8127 Fortran 95 and later
8132 @item @emph{Syntax}:
8133 @code{RESULT = NEAREST(X, S)}
8135 @item @emph{Arguments}:
8136 @multitable @columnfractions .15 .70
8137 @item @var{X} @tab Shall be of type @code{REAL}.
8138 @item @var{S} @tab (Optional) shall be of type @code{REAL} and
8142 @item @emph{Return value}:
8143 The return value is of the same type as @code{X}. If @code{S} is
8144 positive, @code{NEAREST} returns the processor-representable number
8145 greater than @code{X} and nearest to it. If @code{S} is negative,
8146 @code{NEAREST} returns the processor-representable number smaller than
8147 @code{X} and nearest to it.
8149 @item @emph{Example}:
8151 program test_nearest
8153 x = nearest(42.0, 1.0)
8154 y = nearest(42.0, -1.0)
8155 write (*,"(3(G20.15))") x, y, x - y
8156 end program test_nearest
8163 @section @code{NEW_LINE} --- New line character
8166 @cindex output, newline
8169 @item @emph{Description}:
8170 @code{NEW_LINE(C)} returns the new-line character.
8172 @item @emph{Standard}:
8173 Fortran 2003 and later
8178 @item @emph{Syntax}:
8179 @code{RESULT = NEW_LINE(C)}
8181 @item @emph{Arguments}:
8182 @multitable @columnfractions .15 .70
8183 @item @var{C} @tab The argument shall be a scalar or array of the
8184 type @code{CHARACTER}.
8187 @item @emph{Return value}:
8188 Returns a @var{CHARACTER} scalar of length one with the new-line character of
8189 the same kind as parameter @var{C}.
8191 @item @emph{Example}:
8195 write(*,'(A)') 'This is record 1.'//NEW_LINE('A')//'This is record 2.'
8203 @section @code{NINT} --- Nearest whole number
8206 @cindex rounding, nearest whole number
8209 @item @emph{Description}:
8210 @code{NINT(X)} rounds its argument to the nearest whole number.
8212 @item @emph{Standard}:
8213 Fortran 77 and later, with @var{KIND} argument Fortran 90 and later
8218 @item @emph{Syntax}:
8219 @code{RESULT = NINT(X [, KIND])}
8221 @item @emph{Arguments}:
8222 @multitable @columnfractions .15 .70
8223 @item @var{X} @tab The type of the argument shall be @code{REAL}.
8224 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
8225 expression indicating the kind parameter of
8229 @item @emph{Return value}:
8230 Returns @var{A} with the fractional portion of its magnitude eliminated by
8231 rounding to the nearest whole number and with its sign preserved,
8232 converted to an @code{INTEGER} of the default kind.
8234 @item @emph{Example}:
8241 print *, nint(x4), idnint(x8)
8242 end program test_nint
8245 @item @emph{Specific names}:
8246 @multitable @columnfractions .25 .25 .25
8247 @item Name @tab Argument @tab Standard
8248 @item @code{IDNINT(X)} @tab @code{REAL(8)} @tab Fortran 95 and later
8251 @item @emph{See also}:
8252 @ref{CEILING}, @ref{FLOOR}
8259 @section @code{NOT} --- Logical negation
8261 @cindex bits, negate
8262 @cindex bitwise logical not
8263 @cindex logical not, bitwise
8266 @item @emph{Description}:
8267 @code{NOT} returns the bitwise boolean inverse of @var{I}.
8269 @item @emph{Standard}:
8270 Fortran 95 and later
8275 @item @emph{Syntax}:
8276 @code{RESULT = NOT(I)}
8278 @item @emph{Arguments}:
8279 @multitable @columnfractions .15 .70
8280 @item @var{I} @tab The type shall be @code{INTEGER}.
8283 @item @emph{Return value}:
8284 The return type is @code{INTEGER}, of the same kind as the
8287 @item @emph{See also}:
8288 @ref{IAND}, @ref{IEOR}, @ref{IOR}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}
8295 @section @code{NULL} --- Function that returns an disassociated pointer
8297 @cindex pointer, status
8298 @cindex pointer, disassociated
8301 @item @emph{Description}:
8302 Returns a disassociated pointer.
8304 If @var{MOLD} is present, a dissassociated pointer of the same type is
8305 returned, otherwise the type is determined by context.
8307 In Fortran 95, @var{MOLD} is optional. Please note that Fortran 2003
8308 includes cases where it is required.
8310 @item @emph{Standard}:
8311 Fortran 95 and later
8314 Transformational function
8316 @item @emph{Syntax}:
8317 @code{PTR => NULL([MOLD])}
8319 @item @emph{Arguments}:
8320 @multitable @columnfractions .15 .70
8321 @item @var{MOLD} @tab (Optional) shall be a pointer of any association
8322 status and of any type.
8325 @item @emph{Return value}:
8326 A disassociated pointer.
8328 @item @emph{Example}:
8330 REAL, POINTER, DIMENSION(:) :: VEC => NULL ()
8333 @item @emph{See also}:
8340 @section @code{OR} --- Bitwise logical OR
8342 @cindex bitwise logical or
8343 @cindex logical or, bitwise
8346 @item @emph{Description}:
8347 Bitwise logical @code{OR}.
8349 This intrinsic routine is provided for backwards compatibility with
8350 GNU Fortran 77. For integer arguments, programmers should consider
8351 the use of the @ref{IOR} intrinsic defined by the Fortran standard.
8353 @item @emph{Standard}:
8359 @item @emph{Syntax}:
8360 @code{RESULT = OR(X, Y)}
8362 @item @emph{Arguments}:
8363 @multitable @columnfractions .15 .70
8364 @item @var{X} @tab The type shall be either a scalar @code{INTEGER}
8365 type or a scalar @code{LOGICAL} type.
8366 @item @var{Y} @tab The type shall be the same as the type of @var{X}.
8369 @item @emph{Return value}:
8370 The return type is either a scalar @code{INTEGER} or a scalar
8371 @code{LOGICAL}. If the kind type parameters differ, then the
8372 smaller kind type is implicitly converted to larger kind, and the
8373 return has the larger kind.
8375 @item @emph{Example}:
8378 LOGICAL :: T = .TRUE., F = .FALSE.
8380 DATA a / Z'F' /, b / Z'3' /
8382 WRITE (*,*) OR(T, T), OR(T, F), OR(F, T), OR(F, F)
8383 WRITE (*,*) OR(a, b)
8387 @item @emph{See also}:
8388 Fortran 95 elemental function: @ref{IOR}
8394 @section @code{PACK} --- Pack an array into an array of rank one
8396 @cindex array, packing
8397 @cindex array, reduce dimension
8398 @cindex array, gather elements
8401 @item @emph{Description}:
8402 Stores the elements of @var{ARRAY} in an array of rank one.
8404 The beginning of the resulting array is made up of elements whose @var{MASK}
8405 equals @code{TRUE}. Afterwards, positions are filled with elements taken from
8408 @item @emph{Standard}:
8409 Fortran 95 and later
8412 Transformational function
8414 @item @emph{Syntax}:
8415 @code{RESULT = PACK(ARRAY, MASK[,VECTOR]}
8417 @item @emph{Arguments}:
8418 @multitable @columnfractions .15 .70
8419 @item @var{ARRAY} @tab Shall be an array of any type.
8420 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL} and
8421 of the same size as @var{ARRAY}. Alternatively, it may be a @code{LOGICAL}
8423 @item @var{VECTOR} @tab (Optional) shall be an array of the same type
8424 as @var{ARRAY} and of rank one. If present, the number of elements in
8425 @var{VECTOR} shall be equal to or greater than the number of true elements
8426 in @var{MASK}. If @var{MASK} is scalar, the number of elements in
8427 @var{VECTOR} shall be equal to or greater than the number of elements in
8431 @item @emph{Return value}:
8432 The result is an array of rank one and the same type as that of @var{ARRAY}.
8433 If @var{VECTOR} is present, the result size is that of @var{VECTOR}, the
8434 number of @code{TRUE} values in @var{MASK} otherwise.
8436 @item @emph{Example}:
8437 Gathering nonzero elements from an array:
8441 m = (/ 1, 0, 0, 0, 5, 0 /)
8442 WRITE(*, FMT="(6(I0, ' '))") pack(m, m /= 0) ! "1 5"
8446 Gathering nonzero elements from an array and appending elements from @var{VECTOR}:
8450 m = (/ 1, 0, 0, 2 /)
8451 WRITE(*, FMT="(4(I0, ' '))") pack(m, m /= 0, (/ 0, 0, 3, 4 /)) ! "1 2 3 4"
8455 @item @emph{See also}:
8462 @section @code{PERROR} --- Print system error message
8464 @cindex system, error handling
8467 @item @emph{Description}:
8468 Prints (on the C @code{stderr} stream) a newline-terminated error
8469 message corresponding to the last system error. This is prefixed by
8470 @var{STRING}, a colon and a space. See @code{perror(3)}.
8472 @item @emph{Standard}:
8478 @item @emph{Syntax}:
8479 @code{CALL PERROR(STRING)}
8481 @item @emph{Arguments}:
8482 @multitable @columnfractions .15 .70
8483 @item @var{STRING} @tab A scalar of type @code{CHARACTER} and of the
8487 @item @emph{See also}:
8494 @section @code{PRECISION} --- Decimal precision of a real kind
8496 @cindex model representation, precision
8499 @item @emph{Description}:
8500 @code{PRECISION(X)} returns the decimal precision in the model of the
8503 @item @emph{Standard}:
8504 Fortran 95 and later
8509 @item @emph{Syntax}:
8510 @code{RESULT = PRECISION(X)}
8512 @item @emph{Arguments}:
8513 @multitable @columnfractions .15 .70
8514 @item @var{X} @tab Shall be of type @code{REAL} or @code{COMPLEX}.
8517 @item @emph{Return value}:
8518 The return value is of type @code{INTEGER} and of the default integer
8521 @item @emph{Example}:
8523 program prec_and_range
8524 real(kind=4) :: x(2)
8525 complex(kind=8) :: y
8527 print *, precision(x), range(x)
8528 print *, precision(y), range(y)
8529 end program prec_and_range
8536 @section @code{PRESENT} --- Determine whether an optional dummy argument is specified
8540 @item @emph{Description}:
8541 Determines whether an optional dummy argument is present.
8543 @item @emph{Standard}:
8544 Fortran 95 and later
8549 @item @emph{Syntax}:
8550 @code{RESULT = PRESENT(A)}
8552 @item @emph{Arguments}:
8553 @multitable @columnfractions .15 .70
8554 @item @var{A} @tab May be of any type and may be a pointer, scalar or array
8555 value, or a dummy procedure. It shall be the name of an optional dummy argument
8556 accessible within the current subroutine or function.
8559 @item @emph{Return value}:
8560 Returns either @code{TRUE} if the optional argument @var{A} is present, or
8561 @code{FALSE} otherwise.
8563 @item @emph{Example}:
8565 PROGRAM test_present
8566 WRITE(*,*) f(), f(42) ! "F T"
8568 LOGICAL FUNCTION f(x)
8569 INTEGER, INTENT(IN), OPTIONAL :: x
8579 @section @code{PRODUCT} --- Product of array elements
8581 @cindex array, product
8582 @cindex array, multiply elements
8583 @cindex array, conditionally multiply elements
8584 @cindex multiply array elements
8587 @item @emph{Description}:
8588 Multiplies the elements of @var{ARRAY} along dimension @var{DIM} if
8589 the corresponding element in @var{MASK} is @code{TRUE}.
8591 @item @emph{Standard}:
8592 Fortran 95 and later
8595 Transformational function
8597 @item @emph{Syntax}:
8598 @code{RESULT = PRODUCT(ARRAY[, MASK])}
8599 @code{RESULT = PRODUCT(ARRAY, DIM[, MASK])}
8601 @item @emph{Arguments}:
8602 @multitable @columnfractions .15 .70
8603 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER},
8604 @code{REAL} or @code{COMPLEX}.
8605 @item @var{DIM} @tab (Optional) shall be a scalar of type
8606 @code{INTEGER} with a value in the range from 1 to n, where n
8607 equals the rank of @var{ARRAY}.
8608 @item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL}
8609 and either be a scalar or an array of the same shape as @var{ARRAY}.
8612 @item @emph{Return value}:
8613 The result is of the same type as @var{ARRAY}.
8615 If @var{DIM} is absent, a scalar with the product of all elements in
8616 @var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals
8617 the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with
8618 dimension @var{DIM} dropped is returned.
8621 @item @emph{Example}:
8623 PROGRAM test_product
8624 INTEGER :: x(5) = (/ 1, 2, 3, 4 ,5 /)
8625 print *, PRODUCT(x) ! all elements, product = 120
8626 print *, PRODUCT(x, MASK=MOD(x, 2)==1) ! odd elements, product = 15
8630 @item @emph{See also}:
8637 @section @code{RADIX} --- Base of a model number
8639 @cindex model representation, base
8640 @cindex model representation, radix
8643 @item @emph{Description}:
8644 @code{RADIX(X)} returns the base of the model representing the entity @var{X}.
8646 @item @emph{Standard}:
8647 Fortran 95 and later
8652 @item @emph{Syntax}:
8653 @code{RESULT = RADIX(X)}
8655 @item @emph{Arguments}:
8656 @multitable @columnfractions .15 .70
8657 @item @var{X} @tab Shall be of type @code{INTEGER} or @code{REAL}
8660 @item @emph{Return value}:
8661 The return value is a scalar of type @code{INTEGER} and of the default
8664 @item @emph{Example}:
8667 print *, "The radix for the default integer kind is", radix(0)
8668 print *, "The radix for the default real kind is", radix(0.0)
8669 end program test_radix
8677 @section @code{RAN} --- Real pseudo-random number
8679 @cindex random number generation
8682 @item @emph{Description}:
8683 For compatibility with HP FORTRAN 77/iX, the @code{RAN} intrinsic is
8684 provided as an alias for @code{RAND}. See @ref{RAND} for complete
8687 @item @emph{Standard}:
8693 @item @emph{See also}:
8694 @ref{RAND}, @ref{RANDOM_NUMBER}
8700 @section @code{RAND} --- Real pseudo-random number
8702 @cindex random number generation
8705 @item @emph{Description}:
8706 @code{RAND(FLAG)} returns a pseudo-random number from a uniform
8707 distribution between 0 and 1. If @var{FLAG} is 0, the next number
8708 in the current sequence is returned; if @var{FLAG} is 1, the generator
8709 is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
8710 it is used as a new seed with @code{SRAND}.
8712 This intrinsic routine is provided for backwards compatibility with
8713 GNU Fortran 77. It implements a simple modulo generator as provided
8714 by @command{g77}. For new code, one should consider the use of
8715 @ref{RANDOM_NUMBER} as it implements a superior algorithm.
8717 @item @emph{Standard}:
8723 @item @emph{Syntax}:
8724 @code{RESULT = RAND(FLAG)}
8726 @item @emph{Arguments}:
8727 @multitable @columnfractions .15 .70
8728 @item @var{FLAG} @tab Shall be a scalar @code{INTEGER} of kind 4.
8731 @item @emph{Return value}:
8732 The return value is of @code{REAL} type and the default kind.
8734 @item @emph{Example}:
8737 integer,parameter :: seed = 86456
8740 print *, rand(), rand(), rand(), rand()
8741 print *, rand(seed), rand(), rand(), rand()
8742 end program test_rand
8745 @item @emph{See also}:
8746 @ref{SRAND}, @ref{RANDOM_NUMBER}
8753 @section @code{RANDOM_NUMBER} --- Pseudo-random number
8754 @fnindex RANDOM_NUMBER
8755 @cindex random number generation
8758 @item @emph{Description}:
8759 Returns a single pseudorandom number or an array of pseudorandom numbers
8760 from the uniform distribution over the range @math{ 0 \leq x < 1}.
8762 The runtime-library implements George Marsaglia's KISS (Keep It Simple
8763 Stupid) random number generator (RNG). This RNG combines:
8765 @item The congruential generator @math{x(n) = 69069 \cdot x(n-1) + 1327217885}
8766 with a period of @math{2^{32}},
8767 @item A 3-shift shift-register generator with a period of @math{2^{32} - 1},
8768 @item Two 16-bit multiply-with-carry generators with a period of
8769 @math{597273182964842497 > 2^{59}}.
8771 The overall period exceeds @math{2^{123}}.
8773 Please note, this RNG is thread safe if used within OpenMP directives,
8774 i.e., its state will be consistent while called from multiple threads.
8775 However, the KISS generator does not create random numbers in parallel
8776 from multiple sources, but in sequence from a single source. If an
8777 OpenMP-enabled application heavily relies on random numbers, one should
8778 consider employing a dedicated parallel random number generator instead.
8780 @item @emph{Standard}:
8781 Fortran 95 and later
8786 @item @emph{Syntax}:
8787 @code{RANDOM_NUMBER(HARVEST)}
8789 @item @emph{Arguments}:
8790 @multitable @columnfractions .15 .70
8791 @item @var{HARVEST} @tab Shall be a scalar or an array of type @code{REAL}.
8794 @item @emph{Example}:
8796 program test_random_number
8798 CALL init_random_seed() ! see example of RANDOM_SEED
8799 CALL RANDOM_NUMBER(r)
8803 @item @emph{See also}:
8810 @section @code{RANDOM_SEED} --- Initialize a pseudo-random number sequence
8811 @fnindex RANDOM_SEED
8812 @cindex random number generation, seeding
8813 @cindex seeding a random number generator
8816 @item @emph{Description}:
8817 Restarts or queries the state of the pseudorandom number generator used by
8818 @code{RANDOM_NUMBER}.
8820 If @code{RANDOM_SEED} is called without arguments, it is initialized to
8821 a default state. The example below shows how to initialize the random
8822 seed based on the system's time.
8824 @item @emph{Standard}:
8825 Fortran 95 and later
8830 @item @emph{Syntax}:
8831 @code{CALL RANDOM_SEED(SIZE, PUT, GET)}
8833 @item @emph{Arguments}:
8834 @multitable @columnfractions .15 .70
8835 @item @var{SIZE} @tab (Optional) Shall be a scalar and of type default
8836 @code{INTEGER}, with @code{INTENT(OUT)}. It specifies the minimum size
8837 of the arrays used with the @var{PUT} and @var{GET} arguments.
8838 @item @var{PUT} @tab (Optional) Shall be an array of type default
8839 @code{INTEGER} and rank one. It is @code{INTENT(IN)} and the size of
8840 the array must be larger than or equal to the number returned by the
8841 @var{SIZE} argument.
8842 @item @var{GET} @tab (Optional) Shall be an array of type default
8843 @code{INTEGER} and rank one. It is @code{INTENT(OUT)} and the size
8844 of the array must be larger than or equal to the number returned by
8845 the @var{SIZE} argument.
8848 @item @emph{Example}:
8850 SUBROUTINE init_random_seed()
8851 INTEGER :: i, n, clock
8852 INTEGER, DIMENSION(:), ALLOCATABLE :: seed
8854 CALL RANDOM_SEED(size = n)
8857 CALL SYSTEM_CLOCK(COUNT=clock)
8859 seed = clock + 37 * (/ (i - 1, i = 1, n) /)
8860 CALL RANDOM_SEED(PUT = seed)
8866 @item @emph{See also}:
8873 @section @code{RANGE} --- Decimal exponent range of a real kind
8875 @cindex model representation, range
8878 @item @emph{Description}:
8879 @code{RANGE(X)} returns the decimal exponent range in the model of the
8882 @item @emph{Standard}:
8883 Fortran 95 and later
8888 @item @emph{Syntax}:
8889 @code{RESULT = RANGE(X)}
8891 @item @emph{Arguments}:
8892 @multitable @columnfractions .15 .70
8893 @item @var{X} @tab Shall be of type @code{REAL} or @code{COMPLEX}.
8896 @item @emph{Return value}:
8897 The return value is of type @code{INTEGER} and of the default integer
8900 @item @emph{Example}:
8901 See @code{PRECISION} for an example.
8907 @section @code{REAL} --- Convert to real type
8910 @cindex conversion, to real
8911 @cindex complex numbers, real part
8914 @item @emph{Description}:
8915 @code{REAL(X [, KIND])} converts its argument @var{X} to a real type. The
8916 @code{REALPART(X)} function is provided for compatibility with @command{g77},
8917 and its use is strongly discouraged.
8919 @item @emph{Standard}:
8920 Fortran 77 and later
8925 @item @emph{Syntax}:
8926 @multitable @columnfractions .80
8927 @item @code{RESULT = REAL(X [, KIND])}
8928 @item @code{RESULT = REALPART(Z)}
8931 @item @emph{Arguments}:
8932 @multitable @columnfractions .15 .70
8933 @item @var{X} @tab Shall be @code{INTEGER}, @code{REAL}, or
8935 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
8936 expression indicating the kind parameter of
8940 @item @emph{Return value}:
8941 These functions return a @code{REAL} variable or array under
8942 the following rules:
8946 @code{REAL(X)} is converted to a default real type if @var{X} is an
8947 integer or real variable.
8949 @code{REAL(X)} is converted to a real type with the kind type parameter
8950 of @var{X} if @var{X} is a complex variable.
8952 @code{REAL(X, KIND)} is converted to a real type with kind type
8953 parameter @var{KIND} if @var{X} is a complex, integer, or real
8957 @item @emph{Example}:
8960 complex :: x = (1.0, 2.0)
8961 print *, real(x), real(x,8), realpart(x)
8962 end program test_real
8965 @item @emph{See also}:
8966 @ref{DBLE}, @ref{DFLOAT}, @ref{FLOAT}
8973 @section @code{RENAME} --- Rename a file
8975 @cindex file system, rename file
8978 @item @emph{Description}:
8979 Renames a file from file @var{PATH1} to @var{PATH2}. A null
8980 character (@code{CHAR(0)}) can be used to mark the end of the names in
8981 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
8982 names are ignored. If the @var{STATUS} argument is supplied, it
8983 contains 0 on success or a nonzero error code upon return; see
8986 This intrinsic is provided in both subroutine and function forms;
8987 however, only one form can be used in any given program unit.
8989 @item @emph{Standard}:
8993 Subroutine, function
8995 @item @emph{Syntax}:
8996 @multitable @columnfractions .80
8997 @item @code{CALL RENAME(PATH1, PATH2 [, STATUS])}
8998 @item @code{STATUS = RENAME(PATH1, PATH2)}
9001 @item @emph{Arguments}:
9002 @multitable @columnfractions .15 .70
9003 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
9004 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
9005 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
9008 @item @emph{See also}:
9016 @section @code{REPEAT} --- Repeated string concatenation
9018 @cindex string, repeat
9019 @cindex string, concatenate
9022 @item @emph{Description}:
9023 Concatenates @var{NCOPIES} copies of a string.
9025 @item @emph{Standard}:
9026 Fortran 95 and later
9029 Transformational function
9031 @item @emph{Syntax}:
9032 @code{RESULT = REPEAT(STRING, NCOPIES)}
9034 @item @emph{Arguments}:
9035 @multitable @columnfractions .15 .70
9036 @item @var{STRING} @tab Shall be scalar and of type @code{CHARACTER}.
9037 @item @var{NCOPIES} @tab Shall be scalar and of type @code{INTEGER}.
9040 @item @emph{Return value}:
9041 A new scalar of type @code{CHARACTER} built up from @var{NCOPIES} copies
9044 @item @emph{Example}:
9047 write(*,*) repeat("x", 5) ! "xxxxx"
9055 @section @code{RESHAPE} --- Function to reshape an array
9057 @cindex array, change dimensions
9058 @cindex array, transmogrify
9061 @item @emph{Description}:
9062 Reshapes @var{SOURCE} to correspond to @var{SHAPE}. If necessary,
9063 the new array may be padded with elements from @var{PAD} or permuted
9064 as defined by @var{ORDER}.
9066 @item @emph{Standard}:
9067 Fortran 95 and later
9070 Transformational function
9072 @item @emph{Syntax}:
9073 @code{RESULT = RESHAPE(SOURCE, SHAPE[, PAD, ORDER])}
9075 @item @emph{Arguments}:
9076 @multitable @columnfractions .15 .70
9077 @item @var{SOURCE} @tab Shall be an array of any type.
9078 @item @var{SHAPE} @tab Shall be of type @code{INTEGER} and an
9079 array of rank one. Its values must be positive or zero.
9080 @item @var{PAD} @tab (Optional) shall be an array of the same
9081 type as @var{SOURCE}.
9082 @item @var{ORDER} @tab (Optional) shall be of type @code{INTEGER}
9083 and an array of the same shape as @var{SHAPE}. Its values shall
9084 be a permutation of the numbers from 1 to n, where n is the size of
9085 @var{SHAPE}. If @var{ORDER} is absent, the natural ordering shall
9089 @item @emph{Return value}:
9090 The result is an array of shape @var{SHAPE} with the same type as
9093 @item @emph{Example}:
9095 PROGRAM test_reshape
9096 INTEGER, DIMENSION(4) :: x
9097 WRITE(*,*) SHAPE(x) ! prints "4"
9098 WRITE(*,*) SHAPE(RESHAPE(x, (/2, 2/))) ! prints "2 2"
9102 @item @emph{See also}:
9109 @section @code{RRSPACING} --- Reciprocal of the relative spacing
9111 @cindex real number, relative spacing
9112 @cindex floating point, relative spacing
9116 @item @emph{Description}:
9117 @code{RRSPACING(X)} returns the reciprocal of the relative spacing of
9118 model numbers near @var{X}.
9120 @item @emph{Standard}:
9121 Fortran 95 and later
9126 @item @emph{Syntax}:
9127 @code{RESULT = RRSPACING(X)}
9129 @item @emph{Arguments}:
9130 @multitable @columnfractions .15 .70
9131 @item @var{X} @tab Shall be of type @code{REAL}.
9134 @item @emph{Return value}:
9135 The return value is of the same type and kind as @var{X}.
9136 The value returned is equal to
9137 @code{ABS(FRACTION(X)) * FLOAT(RADIX(X))**DIGITS(X)}.
9139 @item @emph{See also}:
9146 @section @code{RSHIFT} --- Right shift bits
9148 @cindex bits, shift right
9151 @item @emph{Description}:
9152 @code{RSHIFT} returns a value corresponding to @var{I} with all of the
9153 bits shifted right by @var{SHIFT} places. If the absolute value of
9154 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
9155 Bits shifted out from the left end are lost; zeros are shifted in from
9158 This function has been superseded by the @code{ISHFT} intrinsic, which
9159 is standard in Fortran 95 and later.
9161 @item @emph{Standard}:
9167 @item @emph{Syntax}:
9168 @code{RESULT = RSHIFT(I, SHIFT)}
9170 @item @emph{Arguments}:
9171 @multitable @columnfractions .15 .70
9172 @item @var{I} @tab The type shall be @code{INTEGER}.
9173 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
9176 @item @emph{Return value}:
9177 The return value is of type @code{INTEGER} and of the same kind as
9180 @item @emph{See also}:
9181 @ref{ISHFT}, @ref{ISHFTC}, @ref{LSHIFT}
9188 @section @code{SCALE} --- Scale a real value
9190 @cindex real number, scale
9191 @cindex floating point, scale
9194 @item @emph{Description}:
9195 @code{SCALE(X,I)} returns @code{X * RADIX(X)**I}.
9197 @item @emph{Standard}:
9198 Fortran 95 and later
9203 @item @emph{Syntax}:
9204 @code{RESULT = SCALE(X, I)}
9206 @item @emph{Arguments}:
9207 @multitable @columnfractions .15 .70
9208 @item @var{X} @tab The type of the argument shall be a @code{REAL}.
9209 @item @var{I} @tab The type of the argument shall be a @code{INTEGER}.
9212 @item @emph{Return value}:
9213 The return value is of the same type and kind as @var{X}.
9214 Its value is @code{X * RADIX(X)**I}.
9216 @item @emph{Example}:
9219 real :: x = 178.1387e-4
9221 print *, scale(x,i), x*radix(x)**i
9222 end program test_scale
9230 @section @code{SCAN} --- Scan a string for the presence of a set of characters
9232 @cindex string, find subset
9235 @item @emph{Description}:
9236 Scans a @var{STRING} for any of the characters in a @var{SET}
9239 If @var{BACK} is either absent or equals @code{FALSE}, this function
9240 returns the position of the leftmost character of @var{STRING} that is
9241 in @var{SET}. If @var{BACK} equals @code{TRUE}, the rightmost position
9242 is returned. If no character of @var{SET} is found in @var{STRING}, the
9245 @item @emph{Standard}:
9246 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
9251 @item @emph{Syntax}:
9252 @code{RESULT = SCAN(STRING, SET[, BACK [, KIND]])}
9254 @item @emph{Arguments}:
9255 @multitable @columnfractions .15 .70
9256 @item @var{STRING} @tab Shall be of type @code{CHARACTER}.
9257 @item @var{SET} @tab Shall be of type @code{CHARACTER}.
9258 @item @var{BACK} @tab (Optional) shall be of type @code{LOGICAL}.
9259 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
9260 expression indicating the kind parameter of
9264 @item @emph{Return value}:
9265 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
9266 @var{KIND} is absent, the return value is of default integer kind.
9268 @item @emph{Example}:
9271 WRITE(*,*) SCAN("FORTRAN", "AO") ! 2, found 'O'
9272 WRITE(*,*) SCAN("FORTRAN", "AO", .TRUE.) ! 6, found 'A'
9273 WRITE(*,*) SCAN("FORTRAN", "C++") ! 0, found none
9277 @item @emph{See also}:
9278 @ref{INDEX intrinsic}, @ref{VERIFY}
9284 @section @code{SECNDS} --- Time function
9286 @cindex time, elapsed
9287 @cindex elapsed time
9290 @item @emph{Description}:
9291 @code{SECNDS(X)} gets the time in seconds from the real-time system clock.
9292 @var{X} is a reference time, also in seconds. If this is zero, the time in
9293 seconds from midnight is returned. This function is non-standard and its
9296 @item @emph{Standard}:
9302 @item @emph{Syntax}:
9303 @code{RESULT = SECNDS (X)}
9305 @item @emph{Arguments}:
9306 @multitable @columnfractions .15 .70
9307 @item @var{T} @tab Shall be of type @code{REAL(4)}.
9308 @item @var{X} @tab Shall be of type @code{REAL(4)}.
9311 @item @emph{Return value}:
9314 @item @emph{Example}:
9319 print *, secnds (0.0) ! seconds since midnight
9320 t1 = secnds (0.0) ! reference time
9321 do i = 1, 10000000 ! do something
9323 t2 = secnds (t1) ! elapsed time
9324 print *, "Something took ", t2, " seconds."
9325 end program test_secnds
9332 @section @code{SECOND} --- CPU time function
9334 @cindex time, elapsed
9335 @cindex elapsed time
9338 @item @emph{Description}:
9339 Returns a @code{REAL(4)} value representing the elapsed CPU time in
9340 seconds. This provides the same functionality as the standard
9341 @code{CPU_TIME} intrinsic, and is only included for backwards
9344 This intrinsic is provided in both subroutine and function forms;
9345 however, only one form can be used in any given program unit.
9347 @item @emph{Standard}:
9351 Subroutine, function
9353 @item @emph{Syntax}:
9354 @multitable @columnfractions .80
9355 @item @code{CALL SECOND(TIME)}
9356 @item @code{TIME = SECOND()}
9359 @item @emph{Arguments}:
9360 @multitable @columnfractions .15 .70
9361 @item @var{TIME} @tab Shall be of type @code{REAL(4)}.
9364 @item @emph{Return value}:
9365 In either syntax, @var{TIME} is set to the process's current runtime in
9368 @item @emph{See also}:
9375 @node SELECTED_CHAR_KIND
9376 @section @code{SELECTED_CHAR_KIND} --- Choose character kind
9377 @fnindex SELECTED_CHAR_KIND
9378 @cindex character kind
9379 @cindex kind, character
9382 @item @emph{Description}:
9384 @code{SELECTED_CHAR_KIND(NAME)} returns the kind value for the character
9385 set named @var{NAME}, if a character set with such a name is supported,
9386 or @math{-1} otherwise. Currently, supported character sets include
9387 ``ASCII'' and ``DEFAULT'', which are equivalent.
9389 @item @emph{Standard}:
9390 Fortran 2003 and later
9393 Transformational function
9395 @item @emph{Syntax}:
9396 @code{RESULT = SELECTED_CHAR_KIND(NAME)}
9398 @item @emph{Arguments}:
9399 @multitable @columnfractions .15 .70
9400 @item @var{NAME} @tab Shall be a scalar and of the default character type.
9403 @item @emph{Example}:
9406 integer,parameter :: ascii = selected_char_kind("ascii")
9407 character(kind=ascii, len=26) :: s
9409 s = ascii_"abcdefghijklmnopqrstuvwxyz"
9411 end program ascii_kind
9417 @node SELECTED_INT_KIND
9418 @section @code{SELECTED_INT_KIND} --- Choose integer kind
9419 @fnindex SELECTED_INT_KIND
9420 @cindex integer kind
9421 @cindex kind, integer
9424 @item @emph{Description}:
9425 @code{SELECTED_INT_KIND(I)} return the kind value of the smallest integer
9426 type that can represent all values ranging from @math{-10^I} (exclusive)
9427 to @math{10^I} (exclusive). If there is no integer kind that accommodates
9428 this range, @code{SELECTED_INT_KIND} returns @math{-1}.
9430 @item @emph{Standard}:
9431 Fortran 95 and later
9434 Transformational function
9436 @item @emph{Syntax}:
9437 @code{RESULT = SELECTED_INT_KIND(I)}
9439 @item @emph{Arguments}:
9440 @multitable @columnfractions .15 .70
9441 @item @var{I} @tab Shall be a scalar and of type @code{INTEGER}.
9444 @item @emph{Example}:
9446 program large_integers
9447 integer,parameter :: k5 = selected_int_kind(5)
9448 integer,parameter :: k15 = selected_int_kind(15)
9449 integer(kind=k5) :: i5
9450 integer(kind=k15) :: i15
9452 print *, huge(i5), huge(i15)
9454 ! The following inequalities are always true
9455 print *, huge(i5) >= 10_k5**5-1
9456 print *, huge(i15) >= 10_k15**15-1
9457 end program large_integers
9463 @node SELECTED_REAL_KIND
9464 @section @code{SELECTED_REAL_KIND} --- Choose real kind
9465 @fnindex SELECTED_REAL_KIND
9470 @item @emph{Description}:
9471 @code{SELECTED_REAL_KIND(P,R)} return the kind value of a real data type
9472 with decimal precision greater of at least @code{P} digits and exponent
9473 range greater at least @code{R}.
9475 @item @emph{Standard}:
9476 Fortran 95 and later
9479 Transformational function
9481 @item @emph{Syntax}:
9482 @code{RESULT = SELECTED_REAL_KIND(P, R)}
9484 @item @emph{Arguments}:
9485 @multitable @columnfractions .15 .70
9486 @item @var{P} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
9487 @item @var{R} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
9489 At least one argument shall be present.
9491 @item @emph{Return value}:
9493 @code{SELECTED_REAL_KIND} returns the value of the kind type parameter of
9494 a real data type with decimal precision of at least @code{P} digits and a
9495 decimal exponent range of at least @code{R}. If more than one real data
9496 type meet the criteria, the kind of the data type with the smallest
9497 decimal precision is returned. If no real data type matches the criteria,
9500 @item -1 if the processor does not support a real data type with a
9501 precision greater than or equal to @code{P}
9502 @item -2 if the processor does not support a real type with an exponent
9503 range greater than or equal to @code{R}
9504 @item -3 if neither is supported.
9507 @item @emph{Example}:
9510 integer,parameter :: p6 = selected_real_kind(6)
9511 integer,parameter :: p10r100 = selected_real_kind(10,100)
9512 integer,parameter :: r400 = selected_real_kind(r=400)
9514 real(kind=p10r100) :: y
9515 real(kind=r400) :: z
9517 print *, precision(x), range(x)
9518 print *, precision(y), range(y)
9519 print *, precision(z), range(z)
9520 end program real_kinds
9527 @section @code{SET_EXPONENT} --- Set the exponent of the model
9528 @fnindex SET_EXPONENT
9529 @cindex real number, set exponent
9530 @cindex floating point, set exponent
9533 @item @emph{Description}:
9534 @code{SET_EXPONENT(X, I)} returns the real number whose fractional part
9535 is that that of @var{X} and whose exponent part is @var{I}.
9537 @item @emph{Standard}:
9538 Fortran 95 and later
9543 @item @emph{Syntax}:
9544 @code{RESULT = SET_EXPONENT(X, I)}
9546 @item @emph{Arguments}:
9547 @multitable @columnfractions .15 .70
9548 @item @var{X} @tab Shall be of type @code{REAL}.
9549 @item @var{I} @tab Shall be of type @code{INTEGER}.
9552 @item @emph{Return value}:
9553 The return value is of the same type and kind as @var{X}.
9554 The real number whose fractional part
9555 is that that of @var{X} and whose exponent part if @var{I} is returned;
9556 it is @code{FRACTION(X) * RADIX(X)**I}.
9558 @item @emph{Example}:
9561 REAL :: x = 178.1387e-4
9563 PRINT *, SET_EXPONENT(x, i), FRACTION(x) * RADIX(x)**i
9572 @section @code{SHAPE} --- Determine the shape of an array
9574 @cindex array, shape
9577 @item @emph{Description}:
9578 Determines the shape of an array.
9580 @item @emph{Standard}:
9581 Fortran 95 and later
9586 @item @emph{Syntax}:
9587 @code{RESULT = SHAPE(SOURCE)}
9589 @item @emph{Arguments}:
9590 @multitable @columnfractions .15 .70
9591 @item @var{SOURCE} @tab Shall be an array or scalar of any type.
9592 If @var{SOURCE} is a pointer it must be associated and allocatable
9593 arrays must be allocated.
9596 @item @emph{Return value}:
9597 An @code{INTEGER} array of rank one with as many elements as @var{SOURCE}
9598 has dimensions. The elements of the resulting array correspond to the extend
9599 of @var{SOURCE} along the respective dimensions. If @var{SOURCE} is a scalar,
9600 the result is the rank one array of size zero.
9602 @item @emph{Example}:
9605 INTEGER, DIMENSION(-1:1, -1:2) :: A
9606 WRITE(*,*) SHAPE(A) ! (/ 3, 4 /)
9607 WRITE(*,*) SIZE(SHAPE(42)) ! (/ /)
9611 @item @emph{See also}:
9612 @ref{RESHAPE}, @ref{SIZE}
9618 @section @code{SIGN} --- Sign copying function
9622 @cindex sign copying
9625 @item @emph{Description}:
9626 @code{SIGN(A,B)} returns the value of @var{A} with the sign of @var{B}.
9628 @item @emph{Standard}:
9629 Fortran 77 and later
9634 @item @emph{Syntax}:
9635 @code{RESULT = SIGN(A, B)}
9637 @item @emph{Arguments}:
9638 @multitable @columnfractions .15 .70
9639 @item @var{A} @tab Shall be of type @code{INTEGER} or @code{REAL}
9640 @item @var{B} @tab Shall be of the same type and kind as @var{A}
9643 @item @emph{Return value}:
9644 The kind of the return value is that of @var{A} and @var{B}.
9645 If @math{B\ge 0} then the result is @code{ABS(A)}, else
9646 it is @code{-ABS(A)}.
9648 @item @emph{Example}:
9651 print *, sign(-12,1)
9652 print *, sign(-12,0)
9653 print *, sign(-12,-1)
9655 print *, sign(-12.,1.)
9656 print *, sign(-12.,0.)
9657 print *, sign(-12.,-1.)
9658 end program test_sign
9661 @item @emph{Specific names}:
9662 @multitable @columnfractions .20 .20 .20 .25
9663 @item Name @tab Arguments @tab Return type @tab Standard
9664 @item @code{ISIGN(A,P)} @tab @code{INTEGER(4)} @tab @code{INTEGER(4)} @tab f95, gnu
9665 @item @code{DSIGN(A,P)} @tab @code{REAL(8)} @tab @code{REAL(8)} @tab f95, gnu
9672 @section @code{SIGNAL} --- Signal handling subroutine (or function)
9674 @cindex system, signal handling
9677 @item @emph{Description}:
9678 @code{SIGNAL(NUMBER, HANDLER [, STATUS])} causes external subroutine
9679 @var{HANDLER} to be executed with a single integer argument when signal
9680 @var{NUMBER} occurs. If @var{HANDLER} is an integer, it can be used to
9681 turn off handling of signal @var{NUMBER} or revert to its default
9682 action. See @code{signal(2)}.
9684 If @code{SIGNAL} is called as a subroutine and the @var{STATUS} argument
9685 is supplied, it is set to the value returned by @code{signal(2)}.
9687 @item @emph{Standard}:
9691 Subroutine, function
9693 @item @emph{Syntax}:
9694 @multitable @columnfractions .80
9695 @item @code{CALL SIGNAL(NUMBER, HANDLER [, STATUS])}
9696 @item @code{STATUS = SIGNAL(NUMBER, HANDLER)}
9699 @item @emph{Arguments}:
9700 @multitable @columnfractions .15 .70
9701 @item @var{NUMBER} @tab Shall be a scalar integer, with @code{INTENT(IN)}
9702 @item @var{HANDLER}@tab Signal handler (@code{INTEGER FUNCTION} or
9703 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar.
9704 @code{INTEGER}. It is @code{INTENT(IN)}.
9705 @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
9706 integer. It has @code{INTENT(OUT)}.
9709 @item @emph{Return value}:
9710 The @code{SIGNAL} function returns the value returned by @code{signal(2)}.
9712 @item @emph{Example}:
9716 external handler_print
9718 call signal (12, handler_print)
9722 end program test_signal
9729 @section @code{SIN} --- Sine function
9735 @cindex trigonometric function, sine
9739 @item @emph{Description}:
9740 @code{SIN(X)} computes the sine of @var{X}.
9742 @item @emph{Standard}:
9743 Fortran 77 and later
9748 @item @emph{Syntax}:
9749 @code{RESULT = SIN(X)}
9751 @item @emph{Arguments}:
9752 @multitable @columnfractions .15 .70
9753 @item @var{X} @tab The type shall be @code{REAL} or
9757 @item @emph{Return value}:
9758 The return value has same type and kind as @var{X}.
9760 @item @emph{Example}:
9765 end program test_sin
9768 @item @emph{Specific names}:
9769 @multitable @columnfractions .20 .20 .20 .25
9770 @item Name @tab Argument @tab Return type @tab Standard
9771 @item @code{DSIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
9772 @item @code{CSIN(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab f95, gnu
9773 @item @code{ZSIN(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
9774 @item @code{CDSIN(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
9777 @item @emph{See also}:
9784 @section @code{SINH} --- Hyperbolic sine function
9787 @cindex hyperbolic sine
9788 @cindex hyperbolic function, sine
9789 @cindex sine, hyperbolic
9792 @item @emph{Description}:
9793 @code{SINH(X)} computes the hyperbolic sine of @var{X}.
9795 @item @emph{Standard}:
9796 Fortran 95 and later
9801 @item @emph{Syntax}:
9802 @code{RESULT = SINH(X)}
9804 @item @emph{Arguments}:
9805 @multitable @columnfractions .15 .70
9806 @item @var{X} @tab The type shall be @code{REAL}.
9809 @item @emph{Return value}:
9810 The return value is of type @code{REAL}.
9812 @item @emph{Example}:
9815 real(8) :: x = - 1.0_8
9817 end program test_sinh
9820 @item @emph{Specific names}:
9821 @multitable @columnfractions .20 .20 .20 .25
9822 @item Name @tab Argument @tab Return type @tab Standard
9823 @item @code{DSINH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 95 and later
9826 @item @emph{See also}:
9833 @section @code{SIZE} --- Determine the size of an array
9836 @cindex array, number of elements
9837 @cindex array, count elements
9840 @item @emph{Description}:
9841 Determine the extent of @var{ARRAY} along a specified dimension @var{DIM},
9842 or the total number of elements in @var{ARRAY} if @var{DIM} is absent.
9844 @item @emph{Standard}:
9845 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
9850 @item @emph{Syntax}:
9851 @code{RESULT = SIZE(ARRAY[, DIM [, KIND]])}
9853 @item @emph{Arguments}:
9854 @multitable @columnfractions .15 .70
9855 @item @var{ARRAY} @tab Shall be an array of any type. If @var{ARRAY} is
9856 a pointer it must be associated and allocatable arrays must be allocated.
9857 @item @var{DIM} @tab (Optional) shall be a scalar of type @code{INTEGER}
9858 and its value shall be in the range from 1 to n, where n equals the rank
9860 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
9861 expression indicating the kind parameter of
9865 @item @emph{Return value}:
9866 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
9867 @var{KIND} is absent, the return value is of default integer kind.
9869 @item @emph{Example}:
9872 WRITE(*,*) SIZE((/ 1, 2 /)) ! 2
9876 @item @emph{See also}:
9877 @ref{SHAPE}, @ref{RESHAPE}
9882 @section @code{SIZEOF} --- Size in bytes of an expression
9884 @cindex expression size
9885 @cindex size of an expression
9888 @item @emph{Description}:
9889 @code{SIZEOF(X)} calculates the number of bytes of storage the
9890 expression @code{X} occupies.
9892 @item @emph{Standard}:
9898 @item @emph{Syntax}:
9899 @code{N = SIZEOF(X)}
9901 @item @emph{Arguments}:
9902 @multitable @columnfractions .15 .70
9903 @item @var{X} @tab The argument shall be of any type, rank or shape.
9906 @item @emph{Return value}:
9907 The return value is of type integer and of the system-dependent kind
9908 @var{C_SIZE_T} (from the @var{ISO_C_BINDING} module). Its value is the
9909 number of bytes occupied by the argument. If the argument has the
9910 @code{POINTER} attribute, the number of bytes of the storage area pointed
9911 to is returned. If the argument is of a derived type with @code{POINTER}
9912 or @code{ALLOCATABLE} components, the return value doesn't account for
9913 the sizes of the data pointed to by these components.
9915 @item @emph{Example}:
9919 print *, (sizeof(s)/sizeof(r) == 5)
9922 The example will print @code{.TRUE.} unless you are using a platform
9923 where default @code{REAL} variables are unusually padded.
9925 @item @emph{See also}:
9931 @section @code{SLEEP} --- Sleep for the specified number of seconds
9933 @cindex delayed execution
9936 @item @emph{Description}:
9937 Calling this subroutine causes the process to pause for @var{SECONDS} seconds.
9939 @item @emph{Standard}:
9945 @item @emph{Syntax}:
9946 @code{CALL SLEEP(SECONDS)}
9948 @item @emph{Arguments}:
9949 @multitable @columnfractions .15 .70
9950 @item @var{SECONDS} @tab The type shall be of default @code{INTEGER}.
9953 @item @emph{Example}:
9964 @section @code{SNGL} --- Convert double precision real to default real
9966 @cindex conversion, to real
9969 @item @emph{Description}:
9970 @code{SNGL(A)} converts the double precision real @var{A}
9971 to a default real value. This is an archaic form of @code{REAL}
9972 that is specific to one type for @var{A}.
9974 @item @emph{Standard}:
9975 Fortran 77 and later
9980 @item @emph{Syntax}:
9981 @code{RESULT = SNGL(A)}
9983 @item @emph{Arguments}:
9984 @multitable @columnfractions .15 .70
9985 @item @var{A} @tab The type shall be a double precision @code{REAL}.
9988 @item @emph{Return value}:
9989 The return value is of type default @code{REAL}.
9991 @item @emph{See also}:
9998 @section @code{SPACING} --- Smallest distance between two numbers of a given type
10000 @cindex real number, relative spacing
10001 @cindex floating point, relative spacing
10004 @item @emph{Description}:
10005 Determines the distance between the argument @var{X} and the nearest
10006 adjacent number of the same type.
10008 @item @emph{Standard}:
10009 Fortran 95 and later
10011 @item @emph{Class}:
10014 @item @emph{Syntax}:
10015 @code{RESULT = SPACING(X)}
10017 @item @emph{Arguments}:
10018 @multitable @columnfractions .15 .70
10019 @item @var{X} @tab Shall be of type @code{REAL}.
10022 @item @emph{Return value}:
10023 The result is of the same type as the input argument @var{X}.
10025 @item @emph{Example}:
10027 PROGRAM test_spacing
10028 INTEGER, PARAMETER :: SGL = SELECTED_REAL_KIND(p=6, r=37)
10029 INTEGER, PARAMETER :: DBL = SELECTED_REAL_KIND(p=13, r=200)
10031 WRITE(*,*) spacing(1.0_SGL) ! "1.1920929E-07" on i686
10032 WRITE(*,*) spacing(1.0_DBL) ! "2.220446049250313E-016" on i686
10036 @item @emph{See also}:
10043 @section @code{SPREAD} --- Add a dimension to an array
10045 @cindex array, increase dimension
10046 @cindex array, duplicate elements
10047 @cindex array, duplicate dimensions
10050 @item @emph{Description}:
10051 Replicates a @var{SOURCE} array @var{NCOPIES} times along a specified
10052 dimension @var{DIM}.
10054 @item @emph{Standard}:
10055 Fortran 95 and later
10057 @item @emph{Class}:
10058 Transformational function
10060 @item @emph{Syntax}:
10061 @code{RESULT = SPREAD(SOURCE, DIM, NCOPIES)}
10063 @item @emph{Arguments}:
10064 @multitable @columnfractions .15 .70
10065 @item @var{SOURCE} @tab Shall be a scalar or an array of any type and
10066 a rank less than seven.
10067 @item @var{DIM} @tab Shall be a scalar of type @code{INTEGER} with a
10068 value in the range from 1 to n+1, where n equals the rank of @var{SOURCE}.
10069 @item @var{NCOPIES} @tab Shall be a scalar of type @code{INTEGER}.
10072 @item @emph{Return value}:
10073 The result is an array of the same type as @var{SOURCE} and has rank n+1
10074 where n equals the rank of @var{SOURCE}.
10076 @item @emph{Example}:
10078 PROGRAM test_spread
10079 INTEGER :: a = 1, b(2) = (/ 1, 2 /)
10080 WRITE(*,*) SPREAD(A, 1, 2) ! "1 1"
10081 WRITE(*,*) SPREAD(B, 1, 2) ! "1 1 2 2"
10085 @item @emph{See also}:
10092 @section @code{SQRT} --- Square-root function
10099 @cindex square-root
10102 @item @emph{Description}:
10103 @code{SQRT(X)} computes the square root of @var{X}.
10105 @item @emph{Standard}:
10106 Fortran 77 and later
10108 @item @emph{Class}:
10111 @item @emph{Syntax}:
10112 @code{RESULT = SQRT(X)}
10114 @item @emph{Arguments}:
10115 @multitable @columnfractions .15 .70
10116 @item @var{X} @tab The type shall be @code{REAL} or
10120 @item @emph{Return value}:
10121 The return value is of type @code{REAL} or @code{COMPLEX}.
10122 The kind type parameter is the same as @var{X}.
10124 @item @emph{Example}:
10127 real(8) :: x = 2.0_8
10128 complex :: z = (1.0, 2.0)
10131 end program test_sqrt
10134 @item @emph{Specific names}:
10135 @multitable @columnfractions .20 .20 .20 .25
10136 @item Name @tab Argument @tab Return type @tab Standard
10137 @item @code{DSQRT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 95 and later
10138 @item @code{CSQRT(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab Fortran 95 and later
10139 @item @code{ZSQRT(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
10140 @item @code{CDSQRT(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
10147 @section @code{SRAND} --- Reinitialize the random number generator
10149 @cindex random number generation, seeding
10150 @cindex seeding a random number generator
10153 @item @emph{Description}:
10154 @code{SRAND} reinitializes the pseudo-random number generator
10155 called by @code{RAND} and @code{IRAND}. The new seed used by the
10156 generator is specified by the required argument @var{SEED}.
10158 @item @emph{Standard}:
10161 @item @emph{Class}:
10164 @item @emph{Syntax}:
10165 @code{CALL SRAND(SEED)}
10167 @item @emph{Arguments}:
10168 @multitable @columnfractions .15 .70
10169 @item @var{SEED} @tab Shall be a scalar @code{INTEGER(kind=4)}.
10172 @item @emph{Return value}:
10175 @item @emph{Example}:
10176 See @code{RAND} and @code{IRAND} for examples.
10178 @item @emph{Notes}:
10179 The Fortran 2003 standard specifies the intrinsic @code{RANDOM_SEED} to
10180 initialize the pseudo-random numbers generator and @code{RANDOM_NUMBER}
10181 to generate pseudo-random numbers. Please note that in
10182 GNU Fortran, these two sets of intrinsics (@code{RAND},
10183 @code{IRAND} and @code{SRAND} on the one hand, @code{RANDOM_NUMBER} and
10184 @code{RANDOM_SEED} on the other hand) access two independent
10185 pseudo-random number generators.
10187 @item @emph{See also}:
10188 @ref{RAND}, @ref{RANDOM_SEED}, @ref{RANDOM_NUMBER}
10195 @section @code{STAT} --- Get file status
10197 @cindex file system, file status
10200 @item @emph{Description}:
10201 This function returns information about a file. No permissions are required on
10202 the file itself, but execute (search) permission is required on all of the
10203 directories in path that lead to the file.
10205 The elements that are obtained and stored in the array @code{BUFF}:
10206 @multitable @columnfractions .15 .70
10207 @item @code{buff(1)} @tab Device ID
10208 @item @code{buff(2)} @tab Inode number
10209 @item @code{buff(3)} @tab File mode
10210 @item @code{buff(4)} @tab Number of links
10211 @item @code{buff(5)} @tab Owner's uid
10212 @item @code{buff(6)} @tab Owner's gid
10213 @item @code{buff(7)} @tab ID of device containing directory entry for file (0 if not available)
10214 @item @code{buff(8)} @tab File size (bytes)
10215 @item @code{buff(9)} @tab Last access time
10216 @item @code{buff(10)} @tab Last modification time
10217 @item @code{buff(11)} @tab Last file status change time
10218 @item @code{buff(12)} @tab Preferred I/O block size (-1 if not available)
10219 @item @code{buff(13)} @tab Number of blocks allocated (-1 if not available)
10222 Not all these elements are relevant on all systems.
10223 If an element is not relevant, it is returned as 0.
10225 This intrinsic is provided in both subroutine and function forms; however,
10226 only one form can be used in any given program unit.
10228 @item @emph{Standard}:
10231 @item @emph{Class}:
10232 Subroutine, function
10234 @item @emph{Syntax}:
10235 @code{CALL STAT(FILE,BUFF[,STATUS])}
10237 @item @emph{Arguments}:
10238 @multitable @columnfractions .15 .70
10239 @item @var{FILE} @tab The type shall be @code{CHARACTER}, of the
10240 default kind and a valid path within the file system.
10241 @item @var{BUFF} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
10242 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0
10243 on success and a system specific error code otherwise.
10246 @item @emph{Example}:
10249 INTEGER, DIMENSION(13) :: buff
10252 CALL STAT("/etc/passwd", buff, status)
10254 IF (status == 0) THEN
10255 WRITE (*, FMT="('Device ID:', T30, I19)") buff(1)
10256 WRITE (*, FMT="('Inode number:', T30, I19)") buff(2)
10257 WRITE (*, FMT="('File mode (octal):', T30, O19)") buff(3)
10258 WRITE (*, FMT="('Number of links:', T30, I19)") buff(4)
10259 WRITE (*, FMT="('Owner''s uid:', T30, I19)") buff(5)
10260 WRITE (*, FMT="('Owner''s gid:', T30, I19)") buff(6)
10261 WRITE (*, FMT="('Device where located:', T30, I19)") buff(7)
10262 WRITE (*, FMT="('File size:', T30, I19)") buff(8)
10263 WRITE (*, FMT="('Last access time:', T30, A19)") CTIME(buff(9))
10264 WRITE (*, FMT="('Last modification time', T30, A19)") CTIME(buff(10))
10265 WRITE (*, FMT="('Last status change time:', T30, A19)") CTIME(buff(11))
10266 WRITE (*, FMT="('Preferred block size:', T30, I19)") buff(12)
10267 WRITE (*, FMT="('No. of blocks allocated:', T30, I19)") buff(13)
10272 @item @emph{See also}:
10273 To stat an open file: @ref{FSTAT}, to stat a link: @ref{LSTAT}
10279 @section @code{SUM} --- Sum of array elements
10282 @cindex array, add elements
10283 @cindex array, conditionally add elements
10284 @cindex sum array elements
10287 @item @emph{Description}:
10288 Adds the elements of @var{ARRAY} along dimension @var{DIM} if
10289 the corresponding element in @var{MASK} is @code{TRUE}.
10291 @item @emph{Standard}:
10292 Fortran 95 and later
10294 @item @emph{Class}:
10295 Transformational function
10297 @item @emph{Syntax}:
10298 @code{RESULT = SUM(ARRAY[, MASK])}
10299 @code{RESULT = SUM(ARRAY, DIM[, MASK])}
10301 @item @emph{Arguments}:
10302 @multitable @columnfractions .15 .70
10303 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER},
10304 @code{REAL} or @code{COMPLEX}.
10305 @item @var{DIM} @tab (Optional) shall be a scalar of type
10306 @code{INTEGER} with a value in the range from 1 to n, where n
10307 equals the rank of @var{ARRAY}.
10308 @item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL}
10309 and either be a scalar or an array of the same shape as @var{ARRAY}.
10312 @item @emph{Return value}:
10313 The result is of the same type as @var{ARRAY}.
10315 If @var{DIM} is absent, a scalar with the sum of all elements in @var{ARRAY}
10316 is returned. Otherwise, an array of rank n-1, where n equals the rank of
10317 @var{ARRAY},and a shape similar to that of @var{ARRAY} with dimension @var{DIM}
10318 dropped is returned.
10320 @item @emph{Example}:
10323 INTEGER :: x(5) = (/ 1, 2, 3, 4 ,5 /)
10324 print *, SUM(x) ! all elements, sum = 15
10325 print *, SUM(x, MASK=MOD(x, 2)==1) ! odd elements, sum = 9
10329 @item @emph{See also}:
10336 @section @code{SYMLNK} --- Create a symbolic link
10338 @cindex file system, create link
10339 @cindex file system, soft link
10342 @item @emph{Description}:
10343 Makes a symbolic link from file @var{PATH1} to @var{PATH2}. A null
10344 character (@code{CHAR(0)}) can be used to mark the end of the names in
10345 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
10346 names are ignored. If the @var{STATUS} argument is supplied, it
10347 contains 0 on success or a nonzero error code upon return; see
10348 @code{symlink(2)}. If the system does not supply @code{symlink(2)},
10349 @code{ENOSYS} is returned.
10351 This intrinsic is provided in both subroutine and function forms;
10352 however, only one form can be used in any given program unit.
10354 @item @emph{Standard}:
10357 @item @emph{Class}:
10358 Subroutine, function
10360 @item @emph{Syntax}:
10361 @multitable @columnfractions .80
10362 @item @code{CALL SYMLNK(PATH1, PATH2 [, STATUS])}
10363 @item @code{STATUS = SYMLNK(PATH1, PATH2)}
10366 @item @emph{Arguments}:
10367 @multitable @columnfractions .15 .70
10368 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
10369 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
10370 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
10373 @item @emph{See also}:
10374 @ref{LINK}, @ref{UNLINK}
10381 @section @code{SYSTEM} --- Execute a shell command
10383 @cindex system, system call
10386 @item @emph{Description}:
10387 Passes the command @var{COMMAND} to a shell (see @code{system(3)}). If
10388 argument @var{STATUS} is present, it contains the value returned by
10389 @code{system(3)}, which is presumably 0 if the shell command succeeded.
10390 Note that which shell is used to invoke the command is system-dependent
10391 and environment-dependent.
10393 This intrinsic is provided in both subroutine and function forms;
10394 however, only one form can be used in any given program unit.
10396 @item @emph{Standard}:
10399 @item @emph{Class}:
10400 Subroutine, function
10402 @item @emph{Syntax}:
10403 @multitable @columnfractions .80
10404 @item @code{CALL SYSTEM(COMMAND [, STATUS])}
10405 @item @code{STATUS = SYSTEM(COMMAND)}
10408 @item @emph{Arguments}:
10409 @multitable @columnfractions .15 .70
10410 @item @var{COMMAND} @tab Shall be of default @code{CHARACTER} type.
10411 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
10414 @item @emph{See also}:
10420 @section @code{SYSTEM_CLOCK} --- Time function
10421 @fnindex SYSTEM_CLOCK
10422 @cindex time, clock ticks
10423 @cindex clock ticks
10426 @item @emph{Description}:
10427 Determines the @var{COUNT} of milliseconds of wall clock time since
10428 the Epoch (00:00:00 UTC, January 1, 1970) modulo @var{COUNT_MAX},
10429 @var{COUNT_RATE} determines the number of clock ticks per second.
10430 @var{COUNT_RATE} and @var{COUNT_MAX} are constant and specific to
10431 @command{gfortran}.
10433 If there is no clock, @var{COUNT} is set to @code{-HUGE(COUNT)}, and
10434 @var{COUNT_RATE} and @var{COUNT_MAX} are set to zero
10436 @item @emph{Standard}:
10437 Fortran 95 and later
10439 @item @emph{Class}:
10442 @item @emph{Syntax}:
10443 @code{CALL SYSTEM_CLOCK([COUNT, COUNT_RATE, COUNT_MAX])}
10445 @item @emph{Arguments}:
10446 @item @emph{Arguments}:
10447 @multitable @columnfractions .15 .70
10448 @item @var{COUNT} @tab (Optional) shall be a scalar of type default
10449 @code{INTEGER} with @code{INTENT(OUT)}.
10450 @item @var{COUNT_RATE} @tab (Optional) shall be a scalar of type default
10451 @code{INTEGER} with @code{INTENT(OUT)}.
10452 @item @var{COUNT_MAX} @tab (Optional) shall be a scalar of type default
10453 @code{INTEGER} with @code{INTENT(OUT)}.
10456 @item @emph{Example}:
10458 PROGRAM test_system_clock
10459 INTEGER :: count, count_rate, count_max
10460 CALL SYSTEM_CLOCK(count, count_rate, count_max)
10461 WRITE(*,*) count, count_rate, count_max
10465 @item @emph{See also}:
10466 @ref{DATE_AND_TIME}, @ref{CPU_TIME}
10472 @section @code{TAN} --- Tangent function
10475 @cindex trigonometric function, tangent
10479 @item @emph{Description}:
10480 @code{TAN(X)} computes the tangent of @var{X}.
10482 @item @emph{Standard}:
10483 Fortran 77 and later
10485 @item @emph{Class}:
10488 @item @emph{Syntax}:
10489 @code{RESULT = TAN(X)}
10491 @item @emph{Arguments}:
10492 @multitable @columnfractions .15 .70
10493 @item @var{X} @tab The type shall be @code{REAL}.
10496 @item @emph{Return value}:
10497 The return value is of type @code{REAL}. The kind type parameter is
10498 the same as @var{X}.
10500 @item @emph{Example}:
10503 real(8) :: x = 0.165_8
10505 end program test_tan
10508 @item @emph{Specific names}:
10509 @multitable @columnfractions .20 .20 .20 .25
10510 @item Name @tab Argument @tab Return type @tab Standard
10511 @item @code{DTAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 95 and later
10514 @item @emph{See also}:
10521 @section @code{TANH} --- Hyperbolic tangent function
10524 @cindex hyperbolic tangent
10525 @cindex hyperbolic function, tangent
10526 @cindex tangent, hyperbolic
10529 @item @emph{Description}:
10530 @code{TANH(X)} computes the hyperbolic tangent of @var{X}.
10532 @item @emph{Standard}:
10533 Fortran 77 and later
10535 @item @emph{Class}:
10538 @item @emph{Syntax}:
10541 @item @emph{Arguments}:
10542 @multitable @columnfractions .15 .70
10543 @item @var{X} @tab The type shall be @code{REAL}.
10546 @item @emph{Return value}:
10547 The return value is of type @code{REAL} and lies in the range
10548 @math{ - 1 \leq tanh(x) \leq 1 }.
10550 @item @emph{Example}:
10553 real(8) :: x = 2.1_8
10555 end program test_tanh
10558 @item @emph{Specific names}:
10559 @multitable @columnfractions .20 .20 .20 .25
10560 @item Name @tab Argument @tab Return type @tab Standard
10561 @item @code{DTANH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab Fortran 95 and later
10564 @item @emph{See also}:
10571 @section @code{TIME} --- Time function
10573 @cindex time, current
10574 @cindex current time
10577 @item @emph{Description}:
10578 Returns the current time encoded as an integer (in the manner of the
10579 UNIX function @code{time(3)}). This value is suitable for passing to
10580 @code{CTIME()}, @code{GMTIME()}, and @code{LTIME()}.
10582 This intrinsic is not fully portable, such as to systems with 32-bit
10583 @code{INTEGER} types but supporting times wider than 32 bits. Therefore,
10584 the values returned by this intrinsic might be, or become, negative, or
10585 numerically less than previous values, during a single run of the
10588 See @ref{TIME8}, for information on a similar intrinsic that might be
10589 portable to more GNU Fortran implementations, though to fewer Fortran
10592 @item @emph{Standard}:
10595 @item @emph{Class}:
10598 @item @emph{Syntax}:
10599 @code{RESULT = TIME()}
10601 @item @emph{Return value}:
10602 The return value is a scalar of type @code{INTEGER(4)}.
10604 @item @emph{See also}:
10605 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME8}
10612 @section @code{TIME8} --- Time function (64-bit)
10614 @cindex time, current
10615 @cindex current time
10618 @item @emph{Description}:
10619 Returns the current time encoded as an integer (in the manner of the
10620 UNIX function @code{time(3)}). This value is suitable for passing to
10621 @code{CTIME()}, @code{GMTIME()}, and @code{LTIME()}.
10623 @emph{Warning:} this intrinsic does not increase the range of the timing
10624 values over that returned by @code{time(3)}. On a system with a 32-bit
10625 @code{time(3)}, @code{TIME8()} will return a 32-bit value, even though
10626 it is converted to a 64-bit @code{INTEGER(8)} value. That means
10627 overflows of the 32-bit value can still occur. Therefore, the values
10628 returned by this intrinsic might be or become negative or numerically
10629 less than previous values during a single run of the compiled program.
10631 @item @emph{Standard}:
10634 @item @emph{Class}:
10637 @item @emph{Syntax}:
10638 @code{RESULT = TIME8()}
10640 @item @emph{Return value}:
10641 The return value is a scalar of type @code{INTEGER(8)}.
10643 @item @emph{See also}:
10644 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK8}, @ref{TIME}
10651 @section @code{TINY} --- Smallest positive number of a real kind
10653 @cindex limits, smallest number
10654 @cindex model representation, smallest number
10657 @item @emph{Description}:
10658 @code{TINY(X)} returns the smallest positive (non zero) number
10659 in the model of the type of @code{X}.
10661 @item @emph{Standard}:
10662 Fortran 95 and later
10664 @item @emph{Class}:
10667 @item @emph{Syntax}:
10668 @code{RESULT = TINY(X)}
10670 @item @emph{Arguments}:
10671 @multitable @columnfractions .15 .70
10672 @item @var{X} @tab Shall be of type @code{REAL}.
10675 @item @emph{Return value}:
10676 The return value is of the same type and kind as @var{X}
10678 @item @emph{Example}:
10679 See @code{HUGE} for an example.
10685 @section @code{TRANSFER} --- Transfer bit patterns
10691 @item @emph{Description}:
10692 Interprets the bitwise representation of @var{SOURCE} in memory as if it
10693 is the representation of a variable or array of the same type and type
10694 parameters as @var{MOLD}.
10696 This is approximately equivalent to the C concept of @emph{casting} one
10699 @item @emph{Standard}:
10700 Fortran 95 and later
10702 @item @emph{Class}:
10703 Transformational function
10705 @item @emph{Syntax}:
10706 @code{RESULT = TRANSFER(SOURCE, MOLD[, SIZE])}
10708 @item @emph{Arguments}:
10709 @multitable @columnfractions .15 .70
10710 @item @var{SOURCE} @tab Shall be a scalar or an array of any type.
10711 @item @var{MOLD} @tab Shall be a scalar or an array of any type.
10712 @item @var{SIZE} @tab (Optional) shall be a scalar of type
10716 @item @emph{Return value}:
10717 The result has the same type as @var{MOLD}, with the bit level
10718 representation of @var{SOURCE}. If @var{SIZE} is present, the result is
10719 a one-dimensional array of length @var{SIZE}. If @var{SIZE} is absent
10720 but @var{MOLD} is an array (of any size or shape), the result is a one-
10721 dimensional array of the minimum length needed to contain the entirety
10722 of the bitwise representation of @var{SOURCE}. If @var{SIZE} is absent
10723 and @var{MOLD} is a scalar, the result is a scalar.
10725 If the bitwise representation of the result is longer than that of
10726 @var{SOURCE}, then the leading bits of the result correspond to those of
10727 @var{SOURCE} and any trailing bits are filled arbitrarily.
10729 When the resulting bit representation does not correspond to a valid
10730 representation of a variable of the same type as @var{MOLD}, the results
10731 are undefined, and subsequent operations on the result cannot be
10732 guaranteed to produce sensible behavior. For example, it is possible to
10733 create @code{LOGICAL} variables for which @code{@var{VAR}} and
10734 @code{.NOT.@var{VAR}} both appear to be true.
10736 @item @emph{Example}:
10738 PROGRAM test_transfer
10739 integer :: x = 2143289344
10740 print *, transfer(x, 1.0) ! prints "NaN" on i686
10748 @section @code{TRANSPOSE} --- Transpose an array of rank two
10750 @cindex array, transpose
10751 @cindex matrix, transpose
10755 @item @emph{Description}:
10756 Transpose an array of rank two. Element (i, j) of the result has the value
10757 @code{MATRIX(j, i)}, for all i, j.
10759 @item @emph{Standard}:
10760 Fortran 95 and later
10762 @item @emph{Class}:
10763 Transformational function
10765 @item @emph{Syntax}:
10766 @code{RESULT = TRANSPOSE(MATRIX)}
10768 @item @emph{Arguments}:
10769 @multitable @columnfractions .15 .70
10770 @item @var{MATRIX} @tab Shall be an array of any type and have a rank of two.
10773 @item @emph{Return value}:
10774 The result has the same type as @var{MATRIX}, and has shape
10775 @code{(/ m, n /)} if @var{MATRIX} has shape @code{(/ n, m /)}.
10781 @section @code{TRIM} --- Remove trailing blank characters of a string
10783 @cindex string, remove trailing whitespace
10786 @item @emph{Description}:
10787 Removes trailing blank characters of a string.
10789 @item @emph{Standard}:
10790 Fortran 95 and later
10792 @item @emph{Class}:
10793 Transformational function
10795 @item @emph{Syntax}:
10796 @code{RESULT = TRIM(STRING)}
10798 @item @emph{Arguments}:
10799 @multitable @columnfractions .15 .70
10800 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER}.
10803 @item @emph{Return value}:
10804 A scalar of type @code{CHARACTER} which length is that of @var{STRING}
10805 less the number of trailing blanks.
10807 @item @emph{Example}:
10810 CHARACTER(len=10), PARAMETER :: s = "GFORTRAN "
10811 WRITE(*,*) LEN(s), LEN(TRIM(s)) ! "10 8", with/without trailing blanks
10815 @item @emph{See also}:
10816 @ref{ADJUSTL}, @ref{ADJUSTR}
10822 @section @code{TTYNAM} --- Get the name of a terminal device.
10824 @cindex system, terminal
10827 @item @emph{Description}:
10828 Get the name of a terminal device. For more information,
10829 see @code{ttyname(3)}.
10831 This intrinsic is provided in both subroutine and function forms;
10832 however, only one form can be used in any given program unit.
10834 @item @emph{Standard}:
10837 @item @emph{Class}:
10838 Subroutine, function
10840 @item @emph{Syntax}:
10841 @multitable @columnfractions .80
10842 @item @code{CALL TTYNAM(UNIT, NAME)}
10843 @item @code{NAME = TTYNAM(UNIT)}
10846 @item @emph{Arguments}:
10847 @multitable @columnfractions .15 .70
10848 @item @var{UNIT} @tab Shall be a scalar @code{INTEGER}.
10849 @item @var{NAME} @tab Shall be of type @code{CHARACTER}.
10852 @item @emph{Example}:
10854 PROGRAM test_ttynam
10857 IF (isatty(unit=unit)) write(*,*) ttynam(unit)
10862 @item @emph{See also}:
10869 @section @code{UBOUND} --- Upper dimension bounds of an array
10871 @cindex array, upper bound
10874 @item @emph{Description}:
10875 Returns the upper bounds of an array, or a single upper bound
10876 along the @var{DIM} dimension.
10877 @item @emph{Standard}:
10878 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
10880 @item @emph{Class}:
10883 @item @emph{Syntax}:
10884 @code{RESULT = UBOUND(ARRAY [, DIM [, KIND]])}
10886 @item @emph{Arguments}:
10887 @multitable @columnfractions .15 .70
10888 @item @var{ARRAY} @tab Shall be an array, of any type.
10889 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER}.
10890 @item @var{KIND}@tab (Optional) An @code{INTEGER} initialization
10891 expression indicating the kind parameter of
10895 @item @emph{Return value}:
10896 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
10897 @var{KIND} is absent, the return value is of default integer kind.
10898 If @var{DIM} is absent, the result is an array of the upper bounds of
10899 @var{ARRAY}. If @var{DIM} is present, the result is a scalar
10900 corresponding to the upper bound of the array along that dimension. If
10901 @var{ARRAY} is an expression rather than a whole array or array
10902 structure component, or if it has a zero extent along the relevant
10903 dimension, the upper bound is taken to be the number of elements along
10904 the relevant dimension.
10906 @item @emph{See also}:
10913 @section @code{UMASK} --- Set the file creation mask
10915 @cindex file system, file creation mask
10918 @item @emph{Description}:
10919 Sets the file creation mask to @var{MASK} and returns the old value in
10920 argument @var{OLD} if it is supplied. See @code{umask(2)}.
10922 @item @emph{Standard}:
10925 @item @emph{Class}:
10928 @item @emph{Syntax}:
10929 @code{CALL UMASK(MASK [, OLD])}
10931 @item @emph{Arguments}:
10932 @multitable @columnfractions .15 .70
10933 @item @var{MASK} @tab Shall be a scalar of type @code{INTEGER}.
10934 @item @var{MASK} @tab (Optional) Shall be a scalar of type
10943 @section @code{UNLINK} --- Remove a file from the file system
10945 @cindex file system, remove file
10948 @item @emph{Description}:
10949 Unlinks the file @var{PATH}. A null character (@code{CHAR(0)}) can be
10950 used to mark the end of the name in @var{PATH}; otherwise, trailing
10951 blanks in the file name are ignored. If the @var{STATUS} argument is
10952 supplied, it contains 0 on success or a nonzero error code upon return;
10953 see @code{unlink(2)}.
10955 This intrinsic is provided in both subroutine and function forms;
10956 however, only one form can be used in any given program unit.
10958 @item @emph{Standard}:
10961 @item @emph{Class}:
10962 Subroutine, function
10964 @item @emph{Syntax}:
10965 @multitable @columnfractions .80
10966 @item @code{CALL UNLINK(PATH [, STATUS])}
10967 @item @code{STATUS = UNLINK(PATH)}
10970 @item @emph{Arguments}:
10971 @multitable @columnfractions .15 .70
10972 @item @var{PATH} @tab Shall be of default @code{CHARACTER} type.
10973 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
10976 @item @emph{See also}:
10977 @ref{LINK}, @ref{SYMLNK}
10983 @section @code{UNPACK} --- Unpack an array of rank one into an array
10985 @cindex array, unpacking
10986 @cindex array, increase dimension
10987 @cindex array, scatter elements
10990 @item @emph{Description}:
10991 Store the elements of @var{VECTOR} in an array of higher rank.
10993 @item @emph{Standard}:
10994 Fortran 95 and later
10996 @item @emph{Class}:
10997 Transformational function
10999 @item @emph{Syntax}:
11000 @code{RESULT = UNPACK(VECTOR, MASK, FIELD)}
11002 @item @emph{Arguments}:
11003 @multitable @columnfractions .15 .70
11004 @item @var{VECTOR} @tab Shall be an array of any type and rank one. It
11005 shall have at least as many elements as @var{MASK} has @code{TRUE} values.
11006 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL}.
11007 @item @var{FIELD} @tab Shall be of the same type as @var{VECTOR} and have
11008 the same shape as @var{MASK}.
11011 @item @emph{Return value}:
11012 The resulting array corresponds to @var{FIELD} with @code{TRUE} elements
11013 of @var{MASK} replaced by values from @var{VECTOR} in array element order.
11015 @item @emph{Example}:
11017 PROGRAM test_unpack
11018 integer :: vector(2) = (/1,1/)
11019 logical :: mask(4) = (/ .TRUE., .FALSE., .FALSE., .TRUE. /)
11020 integer :: field(2,2) = 0, unity(2,2)
11022 ! result: unity matrix
11023 unity = unpack(vector, reshape(mask, (/2,2/)), field)
11027 @item @emph{See also}:
11028 @ref{PACK}, @ref{SPREAD}
11034 @section @code{VERIFY} --- Scan a string for the absence of a set of characters
11036 @cindex string, find missing set
11039 @item @emph{Description}:
11040 Verifies that all the characters in a @var{SET} are present in a @var{STRING}.
11042 If @var{BACK} is either absent or equals @code{FALSE}, this function
11043 returns the position of the leftmost character of @var{STRING} that is
11044 not in @var{SET}. If @var{BACK} equals @code{TRUE}, the rightmost position
11045 is returned. If all characters of @var{SET} are found in @var{STRING}, the
11048 @item @emph{Standard}:
11049 Fortran 95 and later, with @var{KIND} argument Fortran 2003 and later
11051 @item @emph{Class}:
11054 @item @emph{Syntax}:
11055 @code{RESULT = VERIFY(STRING, SET[, BACK [, KIND]])}
11057 @item @emph{Arguments}:
11058 @multitable @columnfractions .15 .70
11059 @item @var{STRING} @tab Shall be of type @code{CHARACTER}.
11060 @item @var{SET} @tab Shall be of type @code{CHARACTER}.
11061 @item @var{BACK} @tab (Optional) shall be of type @code{LOGICAL}.
11062 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
11063 expression indicating the kind parameter of
11067 @item @emph{Return value}:
11068 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
11069 @var{KIND} is absent, the return value is of default integer kind.
11071 @item @emph{Example}:
11073 PROGRAM test_verify
11074 WRITE(*,*) VERIFY("FORTRAN", "AO") ! 1, found 'F'
11075 WRITE(*,*) VERIFY("FORTRAN", "FOO") ! 3, found 'R'
11076 WRITE(*,*) VERIFY("FORTRAN", "C++") ! 1, found 'F'
11077 WRITE(*,*) VERIFY("FORTRAN", "C++", .TRUE.) ! 7, found 'N'
11078 WRITE(*,*) VERIFY("FORTRAN", "FORTRAN") ! 0' found none
11082 @item @emph{See also}:
11083 @ref{SCAN}, @ref{INDEX intrinsic}
11089 @section @code{XOR} --- Bitwise logical exclusive OR
11091 @cindex bitwise logical exclusive or
11092 @cindex logical exclusive or, bitwise
11095 @item @emph{Description}:
11096 Bitwise logical exclusive or.
11098 This intrinsic routine is provided for backwards compatibility with
11099 GNU Fortran 77. For integer arguments, programmers should consider
11100 the use of the @ref{IEOR} intrinsic defined by the Fortran standard.
11102 @item @emph{Standard}:
11105 @item @emph{Class}:
11108 @item @emph{Syntax}:
11109 @code{RESULT = XOR(X, Y)}
11111 @item @emph{Arguments}:
11112 @multitable @columnfractions .15 .70
11113 @item @var{X} @tab The type shall be either a scalar @code{INTEGER}
11114 type or a scalar @code{LOGICAL} type.
11115 @item @var{Y} @tab The type shall be the same as the type of @var{I}.
11118 @item @emph{Return value}:
11119 The return type is either a scalar @code{INTEGER} or a scalar
11120 @code{LOGICAL}. If the kind type parameters differ, then the
11121 smaller kind type is implicitly converted to larger kind, and the
11122 return has the larger kind.
11124 @item @emph{Example}:
11127 LOGICAL :: T = .TRUE., F = .FALSE.
11129 DATA a / Z'F' /, b / Z'3' /
11131 WRITE (*,*) XOR(T, T), XOR(T, F), XOR(F, T), XOR(F, F)
11132 WRITE (*,*) XOR(a, b)
11136 @item @emph{See also}:
11137 Fortran 95 elemental function: @ref{IEOR}
11142 @node Intrinsic Modules
11143 @chapter Intrinsic Modules
11144 @cindex intrinsic Modules
11146 @c @node ISO_FORTRAN_ENV
11147 @section @code{ISO_FORTRAN_ENV}
11149 @item @emph{Standard}:
11150 Fortran 2003 and later
11153 The @code{ISO_FORTRAN_ENV} module provides the following scalar default-integer
11157 @item @code{CHARACTER_STORAGE_SIZE}:
11158 Size in bits of the character storage unit.
11160 @item @code{ERROR_UNIT}:
11161 Identifies the preconnected unit used for error reporting.
11163 @item @code{FILE_STORAGE_SIZE}:
11164 Size in bits of the file-storage unit.
11166 @item @code{INPUT_UNIT}:
11167 Identifies the preconnected unit identified by the asterisk
11168 (@code{*}) in @code{READ} statement.
11170 @item @code{IOSTAT_END}:
11171 The value assigned to the variable passed to the IOSTAT= specifier of
11172 an input/output statement if an end-of-file condition occurred.
11174 @item @code{IOSTAT_EOR}:
11175 The value assigned to the variable passed to the IOSTAT= specifier of
11176 an input/output statement if an end-of-record condition occurred.
11178 @item @code{NUMERIC_STORAGE_SIZE}:
11179 The size in bits of the numeric storage unit.
11181 @item @code{OUTPUT_UNIT}:
11182 Identifies the preconnected unit identified by the asterisk
11183 (@code{*}) in @code{WRITE} statement.
11186 @c @node ISO_C_BINDING
11187 @section @code{ISO_C_BINDING}
11189 @item @emph{Standard}:
11190 Fortran 2003 and later, GNU extensions
11193 The following intrinsic procedures are provided by the module; their
11194 definition can be found in the section Intrinsic Procedures of this
11198 @item @code{C_ASSOCIATED}
11199 @item @code{C_F_POINTER}
11200 @item @code{C_F_PROCPOINTER}
11201 @item @code{C_FUNLOC}
11205 The @code{ISO_C_BINDING} module provides the following named constants of the
11206 type integer, which can be used as KIND type parameter. Note that GNU
11207 Fortran currently does not support the @code{C_INT_FAST...} KIND type
11208 parameters (marked by an asterisk (@code{*}) in the list below).
11209 The @code{C_INT_FAST...} parameters have therefore the value @math{-2}
11210 and cannot be used as KIND type parameter of the @code{INTEGER} type.
11212 In addition to the integer named constants required by the Fortran 2003
11213 standard, GNU Fortran provides as an extension named constants for the
11214 128-bit integer types supported by the C compiler: @code{C_INT128_T,
11215 C_INT_LEAST128_T, C_INT_FAST128_T}.
11217 @multitable @columnfractions .15 .35 .35 .35
11218 @item Fortran Type @tab Named constant @tab C type @tab Extension
11219 @item @code{INTEGER}@tab @code{C_INT} @tab @code{int}
11220 @item @code{INTEGER}@tab @code{C_SHORT} @tab @code{short int}
11221 @item @code{INTEGER}@tab @code{C_LONG} @tab @code{long int}
11222 @item @code{INTEGER}@tab @code{C_LONG_LONG} @tab @code{long long int}
11223 @item @code{INTEGER}@tab @code{C_SIGNED_CHAR} @tab @code{signed char}/@code{unsigned char}
11224 @item @code{INTEGER}@tab @code{C_SIZE_T} @tab @code{size_t}
11225 @item @code{INTEGER}@tab @code{C_INT8_T} @tab @code{int8_t}
11226 @item @code{INTEGER}@tab @code{C_INT16_T} @tab @code{int16_t}
11227 @item @code{INTEGER}@tab @code{C_INT32_T} @tab @code{int32_t}
11228 @item @code{INTEGER}@tab @code{C_INT64_T} @tab @code{int64_t}
11229 @item @code{INTEGER}@tab @code{C_INT128_T} @tab @code{int128_t} @tab Ext.
11230 @item @code{INTEGER}@tab @code{C_INT_LEAST8_T} @tab @code{int_least8_t}
11231 @item @code{INTEGER}@tab @code{C_INT_LEAST16_T} @tab @code{int_least16_t}
11232 @item @code{INTEGER}@tab @code{C_INT_LEAST32_T} @tab @code{int_least32_t}
11233 @item @code{INTEGER}@tab @code{C_INT_LEAST64_T} @tab @code{int_least64_t}
11234 @item @code{INTEGER}@tab @code{C_INT_LEAST128_T} @tab @code{int_least128_t} @tab Ext.
11235 @item @code{INTEGER}@tab @code{C_INT_FAST8_T}* @tab @code{int_fast8_t}
11236 @item @code{INTEGER}@tab @code{C_INT_FAST16_T}* @tab @code{int_fast16_t}
11237 @item @code{INTEGER}@tab @code{C_INT_FAST32_T}* @tab @code{int_fast32_t}
11238 @item @code{INTEGER}@tab @code{C_INT_FAST64_T}* @tab @code{int_fast64_t}
11239 @item @code{INTEGER}@tab @code{C_INT_FAST128_T}* @tab @code{int_fast128_t} @tab Ext.
11240 @item @code{INTEGER}@tab @code{C_INTMAX_T} @tab @code{intmax_t}
11241 @item @code{INTEGER}@tab @code{C_INTPTR_T} @tab @code{intptr_t}
11242 @item @code{REAL} @tab @code{C_FLOAT} @tab @code{float}
11243 @item @code{REAL} @tab @code{C_DOUBLE} @tab @code{double}
11244 @item @code{REAL} @tab @code{C_LONG_DOUBLE} @tab @code{long double}
11245 @item @code{COMPLEX}@tab @code{C_FLOAT_COMPLEX} @tab @code{float _Complex}
11246 @item @code{COMPLEX}@tab @code{C_DOUBLE_COMPLEX}@tab @code{double _Complex}
11247 @item @code{COMPLEX}@tab @code{C_LONG_DOUBLE_COMPLEX}@tab @code{long double _Complex}
11248 @item @code{LOGICAL}@tab @code{C_BOOL} @tab @code{_Bool}
11249 @item @code{CHARACTER}@tab @code{C_CHAR} @tab @code{char}
11252 Additionally, the following @code{(CHARACTER(KIND=C_CHAR)} are
11255 @multitable @columnfractions .20 .45 .15
11256 @item Name @tab C definition @tab Value
11257 @item @code{C_NULL_CHAR} @tab null character @tab @code{'\0'}
11258 @item @code{C_ALERT} @tab alert @tab @code{'\a'}
11259 @item @code{C_BACKSPACE} @tab backspace @tab @code{'\b'}
11260 @item @code{C_FORM_FEED} @tab form feed @tab @code{'\f'}
11261 @item @code{C_NEW_LINE} @tab new line @tab @code{'\n'}
11262 @item @code{C_CARRIAGE_RETURN} @tab carriage return @tab @code{'\r'}
11263 @item @code{C_HORIZONTAL_TAB} @tab horizontal tab @tab @code{'\t'}
11264 @item @code{C_VERTICAL_TAB} @tab vertical tab @tab @code{'\v'}
11267 @c @node OpenMP Modules OMP_LIB and OMP_LIB_KINDS
11268 @section OpenMP Modules @code{OMP_LIB} and @code{OMP_LIB_KINDS}
11270 @item @emph{Standard}:
11271 OpenMP Application Program Interface v2.5
11275 The OpenMP Fortran runtime library routines are provided both in
11276 a form of two Fortran 90 modules, named @code{OMP_LIB} and
11277 @code{OMP_LIB_KINDS}, and in a form of a Fortran @code{include} file named
11278 @file{omp_lib.h}. The procedures provided by @code{OMP_LIB} can be found
11279 in the @ref{Top,,Introduction,libgomp,GNU OpenMP runtime library} manual,
11280 the named constants defined in the @code{OMP_LIB_KINDS} module are listed
11283 For details refer to the actual
11284 @uref{http://www.openmp.org/drupal/mp-documents/spec25.pdf,
11285 OpenMP Application Program Interface v2.5}.
11287 @code{OMP_LIB_KINDS} provides the following scalar default-integer
11291 @item @code{omp_integer_kind}
11292 @item @code{omp_logical_kind}
11293 @item @code{omp_lock_kind}
11294 @item @code{omp_nest_lock_kind}