2 Copyright (C) 2005, 2006, 2007
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{BESJ0}: BESJ0, Bessel function of the first kind of order 0
66 * @code{BESJ1}: BESJ1, Bessel function of the first kind of order 1
67 * @code{BESJN}: BESJN, Bessel function of the first kind
68 * @code{BESY0}: BESY0, Bessel function of the second kind of order 0
69 * @code{BESY1}: BESY1, Bessel function of the second kind of order 1
70 * @code{BESYN}: BESYN, 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{CEILING}: CEILING, Integer ceiling function
79 * @code{CHAR}: CHAR, Integer-to-character conversion function
80 * @code{CHDIR}: CHDIR, Change working directory
81 * @code{CHMOD}: CHMOD, Change access permissions of files
82 * @code{CMPLX}: CMPLX, Complex conversion function
83 * @code{COMMAND_ARGUMENT_COUNT}: COMMAND_ARGUMENT_COUNT, Get number of command line arguments
84 * @code{COMPLEX}: COMPLEX, Complex conversion function
85 * @code{CONJG}: CONJG, Complex conjugate function
86 * @code{COS}: COS, Cosine function
87 * @code{COSH}: COSH, Hyperbolic cosine function
88 * @code{COUNT}: COUNT, Count occurrences of TRUE in an array
89 * @code{CPU_TIME}: CPU_TIME, CPU time subroutine
90 * @code{CSHIFT}: CSHIFT, Circular shift elements of an array
91 * @code{CTIME}: CTIME, Subroutine (or function) to convert a time into a string
92 * @code{DATE_AND_TIME}: DATE_AND_TIME, Date and time subroutine
93 * @code{DBLE}: DBLE, Double precision conversion function
94 * @code{DCMPLX}: DCMPLX, Double complex conversion function
95 * @code{DFLOAT}: DFLOAT, Double precision conversion function
96 * @code{DIGITS}: DIGITS, Significant digits function
97 * @code{DIM}: DIM, Positive difference
98 * @code{DOT_PRODUCT}: DOT_PRODUCT, Dot product function
99 * @code{DPROD}: DPROD, Double product function
100 * @code{DREAL}: DREAL, Double real part function
101 * @code{DTIME}: DTIME, Execution time subroutine (or function)
102 * @code{EOSHIFT}: EOSHIFT, End-off shift elements of an array
103 * @code{EPSILON}: EPSILON, Epsilon function
104 * @code{ERF}: ERF, Error function
105 * @code{ERFC}: ERFC, Complementary error function
106 * @code{ETIME}: ETIME, Execution time subroutine (or function)
107 * @code{EXIT}: EXIT, Exit the program with status.
108 * @code{EXP}: EXP, Exponential function
109 * @code{EXPONENT}: EXPONENT, Exponent function
110 * @code{FDATE}: FDATE, Subroutine (or function) to get the current time as a string
111 * @code{FGET}: FGET, Read a single character in stream mode from stdin
112 * @code{FGETC}: FGETC, Read a single character in stream mode
113 * @code{FLOAT}: FLOAT, Convert integer to default real
114 * @code{FLOOR}: FLOOR, Integer floor function
115 * @code{FLUSH}: FLUSH, Flush I/O unit(s)
116 * @code{FNUM}: FNUM, File number function
117 * @code{FPUT}: FPUT, Write a single character in stream mode to stdout
118 * @code{FPUTC}: FPUTC, Write a single character in stream mode
119 * @code{FRACTION}: FRACTION, Fractional part of the model representation
120 * @code{FREE}: FREE, Memory de-allocation subroutine
121 * @code{FSEEK}: FSEEK, Low level file positioning subroutine
122 * @code{FSTAT}: FSTAT, Get file status
123 * @code{FTELL}: FTELL, Current stream position
124 * @code{GAMMA}: GAMMA, Gamma function
125 * @code{GERROR}: GERROR, Get last system error message
126 * @code{GETARG}: GETARG, Get command line arguments
127 * @code{GET_COMMAND}: GET_COMMAND, Get the entire command line
128 * @code{GET_COMMAND_ARGUMENT}: GET_COMMAND_ARGUMENT, Get command line arguments
129 * @code{GETCWD}: GETCWD, Get current working directory
130 * @code{GETENV}: GETENV, Get an environmental variable
131 * @code{GET_ENVIRONMENT_VARIABLE}: GET_ENVIRONMENT_VARIABLE, Get an environmental variable
132 * @code{GETGID}: GETGID, Group ID function
133 * @code{GETLOG}: GETLOG, Get login name
134 * @code{GETPID}: GETPID, Process ID function
135 * @code{GETUID}: GETUID, User ID function
136 * @code{GMTIME}: GMTIME, Convert time to GMT info
137 * @code{HOSTNM}: HOSTNM, Get system host name
138 * @code{HUGE}: HUGE, Largest number of a kind
139 * @code{IACHAR}: IACHAR, Code in @acronym{ASCII} collating sequence
140 * @code{IAND}: IAND, Bitwise logical and
141 * @code{IARGC}: IARGC, Get the number of command line arguments
142 * @code{IBCLR}: IBCLR, Clear bit
143 * @code{IBITS}: IBITS, Bit extraction
144 * @code{IBSET}: IBSET, Set bit
145 * @code{ICHAR}: ICHAR, Character-to-integer conversion function
146 * @code{IDATE}: IDATE, Current local time (day/month/year)
147 * @code{IEOR}: IEOR, Bitwise logical exclusive or
148 * @code{IERRNO}: IERRNO, Function to get the last system error number
149 * @code{INDEX}: INDEX, Position of a substring within a string
150 * @code{INT}: INT, Convert to integer type
151 * @code{INT2}: INT2, Convert to 16-bit integer type
152 * @code{INT8}: INT8, Convert to 64-bit integer type
153 * @code{IOR}: IOR, Bitwise logical or
154 * @code{IRAND}: IRAND, Integer pseudo-random number
155 * @code{IS_IOSTAT_END}: IS_IOSTAT_END, Test for end-of-file value
156 * @code{IS_IOSTAT_EOR}: IS_IOSTAT_EOR, Test for end-of-record value
157 * @code{ISATTY}: ISATTY, Whether a unit is a terminal device
158 * @code{ISHFT}: ISHFT, Shift bits
159 * @code{ISHFTC}: ISHFTC, Shift bits circularly
160 * @code{ISNAN}: ISNAN, Tests for a NaN
161 * @code{ITIME}: ITIME, Current local time (hour/minutes/seconds)
162 * @code{KILL}: KILL, Send a signal to a process
163 * @code{KIND}: KIND, Kind of an entity
164 * @code{LBOUND}: LBOUND, Lower dimension bounds of an array
165 * @code{LEN}: LEN, Length of a character entity
166 * @code{LEN_TRIM}: LEN_TRIM, Length of a character entity without trailing blank characters
167 * @code{LGAMMA}: LGAMMA, Logarithm of the Gamma function
168 * @code{LGE}: LGE, Lexical greater than or equal
169 * @code{LGT}: LGT, Lexical greater than
170 * @code{LINK}: LINK, Create a hard link
171 * @code{LLE}: LLE, Lexical less than or equal
172 * @code{LLT}: LLT, Lexical less than
173 * @code{LNBLNK}: LNBLNK, Index of the last non-blank character in a string
174 * @code{LOC}: LOC, Returns the address of a variable
175 * @code{LOG}: LOG, Logarithm function
176 * @code{LOG10}: LOG10, Base 10 logarithm function
177 * @code{LOGICAL}: LOGICAL, Convert to logical type
178 * @code{LONG}: LONG, Convert to integer type
179 * @code{LSHIFT}: LSHIFT, Left shift bits
180 * @code{LSTAT}: LSTAT, Get file status
181 * @code{LTIME}: LTIME, Convert time to local time info
182 * @code{MALLOC}: MALLOC, Dynamic memory allocation function
183 * @code{MATMUL}: MATMUL, matrix multiplication
184 * @code{MAX}: MAX, Maximum value of an argument list
185 * @code{MAXEXPONENT}: MAXEXPONENT, Maximum exponent of a real kind
186 * @code{MAXLOC}: MAXLOC, Location of the maximum value within an array
187 * @code{MAXVAL}: MAXVAL, Maximum value of an array
188 * @code{MCLOCK}: MCLOCK, Time function
189 * @code{MCLOCK8}: MCLOCK8, Time function (64-bit)
190 * @code{MERGE}: MERGE, Merge arrays
191 * @code{MIN}: MIN, Minimum value of an argument list
192 * @code{MINEXPONENT}: MINEXPONENT, Minimum exponent of a real kind
193 * @code{MINLOC}: MINLOC, Location of the minimum value within an array
194 * @code{MINVAL}: MINVAL, Minimum value of an array
195 * @code{MOD}: MOD, Remainder function
196 * @code{MODULO}: MODULO, Modulo function
197 * @code{MOVE_ALLOC}: MOVE_ALLOC, Move allocation from one object to another
198 * @code{MVBITS}: MVBITS, Move bits from one integer to another
199 * @code{NEAREST}: NEAREST, Nearest representable number
200 * @code{NEW_LINE}: NEW_LINE, New line character
201 * @code{NINT}: NINT, Nearest whole number
202 * @code{NOT}: NOT, Logical negation
203 * @code{NULL}: NULL, Function that returns an disassociated pointer
204 * @code{OR}: OR, Bitwise logical OR
205 * @code{PACK}: PACK, Pack an array into an array of rank one
206 * @code{PERROR}: PERROR, Print system error message
207 * @code{PRECISION}: PRECISION, Decimal precision of a real kind
208 * @code{PRESENT}: PRESENT, Determine whether an optional dummy argument is specified
209 * @code{PRODUCT}: PRODUCT, Product of array elements
210 * @code{RADIX}: RADIX, Base of a data model
211 * @code{RANDOM_NUMBER}: RANDOM_NUMBER, Pseudo-random number
212 * @code{RANDOM_SEED}: RANDOM_SEED, Initialize a pseudo-random number sequence
213 * @code{RAND}: RAND, Real pseudo-random number
214 * @code{RANGE}: RANGE, Decimal exponent range of a real kind
215 * @code{RAN}: RAN, Real pseudo-random number
216 * @code{REAL}: REAL, Convert to real type
217 * @code{RENAME}: RENAME, Rename a file
218 * @code{REPEAT}: REPEAT, Repeated string concatenation
219 * @code{RESHAPE}: RESHAPE, Function to reshape an array
220 * @code{RRSPACING}: RRSPACING, Reciprocal of the relative spacing
221 * @code{RSHIFT}: RSHIFT, Right shift bits
222 * @code{SCALE}: SCALE, Scale a real value
223 * @code{SCAN}: SCAN, Scan a string for the presence of a set of characters
224 * @code{SECNDS}: SECNDS, Time function
225 * @code{SECOND}: SECOND, CPU time function
226 * @code{SELECTED_INT_KIND}: SELECTED_INT_KIND, Choose integer kind
227 * @code{SELECTED_REAL_KIND}: SELECTED_REAL_KIND, Choose real kind
228 * @code{SET_EXPONENT}: SET_EXPONENT, Set the exponent of the model
229 * @code{SHAPE}: SHAPE, Determine the shape of an array
230 * @code{SIGN}: SIGN, Sign copying function
231 * @code{SIGNAL}: SIGNAL, Signal handling subroutine (or function)
232 * @code{SIN}: SIN, Sine function
233 * @code{SINH}: SINH, Hyperbolic sine function
234 * @code{SIZE}: SIZE, Function to determine the size of an array
235 * @code{SIZEOF}: SIZEOF, Determine the size in bytes of an expression
236 * @code{SLEEP}: SLEEP, Sleep for the specified number of seconds
237 * @code{SNGL}: SNGL, Convert double precision real to default real
238 * @code{SPACING}: SPACING, Smallest distance between two numbers of a given type
239 * @code{SPREAD}: SPREAD, Add a dimension to an array
240 * @code{SQRT}: SQRT, Square-root function
241 * @code{SRAND}: SRAND, Reinitialize the random number generator
242 * @code{STAT}: STAT, Get file status
243 * @code{SUM}: SUM, Sum of array elements
244 * @code{SYMLNK}: SYMLNK, Create a symbolic link
245 * @code{SYSTEM}: SYSTEM, Execute a shell command
246 * @code{SYSTEM_CLOCK}: SYSTEM_CLOCK, Time function
247 * @code{TAN}: TAN, Tangent function
248 * @code{TANH}: TANH, Hyperbolic tangent function
249 * @code{TIME}: TIME, Time function
250 * @code{TIME8}: TIME8, Time function (64-bit)
251 * @code{TINY}: TINY, Smallest positive number of a real kind
252 * @code{TRANSFER}: TRANSFER, Transfer bit patterns
253 * @code{TRANSPOSE}: TRANSPOSE, Transpose an array of rank two
254 * @code{TRIM}: TRIM, Remove trailing blank characters of a string
255 * @code{TTYNAM}: TTYNAM, Get the name of a terminal device.
256 * @code{UBOUND}: UBOUND, Upper dimension bounds of an array
257 * @code{UMASK}: UMASK, Set the file creation mask
258 * @code{UNLINK}: UNLINK, Remove a file from the file system
259 * @code{UNPACK}: UNPACK, Unpack an array of rank one into an array
260 * @code{VERIFY}: VERIFY, Scan a string for the absence of a set of characters
261 * @code{XOR}: XOR, Bitwise logical exclusive or
264 @node Introduction to Intrinsics
265 @section Introduction to intrinsic procedures
267 The intrinsic procedures provided by GNU Fortran include all of the
268 intrinsic procedures required by the Fortran 95 standard, a set of
269 intrinsic procedures for backwards compatibility with G77, and a small
270 selection of intrinsic procedures from the Fortran 2003 standard. Any
271 conflict between a description here and a description in either the
272 Fortran 95 standard or the Fortran 2003 standard is unintentional, and
273 the standard(s) should be considered authoritative.
275 The enumeration of the @code{KIND} type parameter is processor defined in
276 the Fortran 95 standard. GNU Fortran defines the default integer type and
277 default real type by @code{INTEGER(KIND=4)} and @code{REAL(KIND=4)},
278 respectively. The standard mandates that both data types shall have
279 another kind, which have more precision. On typical target architectures
280 supported by @command{gfortran}, this kind type parameter is @code{KIND=8}.
281 Hence, @code{REAL(KIND=8)} and @code{DOUBLE PRECISION} are equivalent.
282 In the description of generic intrinsic procedures, the kind type parameter
283 will be specified by @code{KIND=*}, and in the description of specific
284 names for an intrinsic procedure the kind type parameter will be explicitly
285 given (e.g., @code{REAL(KIND=4)} or @code{REAL(KIND=8)}). Finally, for
286 brevity the optional @code{KIND=} syntax will be omitted.
288 Many of the intrinsic procedures take one or more optional arguments.
289 This document follows the convention used in the Fortran 95 standard,
290 and denotes such arguments by square brackets.
292 GNU Fortran offers the @option{-std=f95} and @option{-std=gnu} options,
293 which can be used to restrict the set of intrinsic procedures to a
294 given standard. By default, @command{gfortran} sets the @option{-std=gnu}
295 option, and so all intrinsic procedures described here are accepted. There
296 is one caveat. For a select group of intrinsic procedures, @command{g77}
297 implemented both a function and a subroutine. Both classes
298 have been implemented in @command{gfortran} for backwards compatibility
299 with @command{g77}. It is noted here that these functions and subroutines
300 cannot be intermixed in a given subprogram. In the descriptions that follow,
301 the applicable standard for each intrinsic procedure is noted.
306 @section @code{ABORT} --- Abort the program
308 @cindex program termination, with core dump
309 @cindex terminate program, with core dump
313 @item @emph{Description}:
314 @code{ABORT} causes immediate termination of the program. On operating
315 systems that support a core dump, @code{ABORT} will produce a core dump,
316 which is suitable for debugging purposes.
318 @item @emph{Standard}:
327 @item @emph{Return value}:
330 @item @emph{Example}:
333 integer :: i = 1, j = 2
334 if (i /= j) call abort
335 end program test_abort
338 @item @emph{See also}:
339 @ref{EXIT}, @ref{KILL}
346 @section @code{ABS} --- Absolute value
353 @cindex absolute value
356 @item @emph{Description}:
357 @code{ABS(X)} computes the absolute value of @code{X}.
359 @item @emph{Standard}:
360 F77 and later, has overloads that are GNU extensions
366 @code{RESULT = ABS(X)}
368 @item @emph{Arguments}:
369 @multitable @columnfractions .15 .70
370 @item @var{X} @tab The type of the argument shall be an @code{INTEGER(*)},
371 @code{REAL(*)}, or @code{COMPLEX(*)}.
374 @item @emph{Return value}:
375 The return value is of the same type and
376 kind as the argument except the return value is @code{REAL(*)} for a
377 @code{COMPLEX(*)} argument.
379 @item @emph{Example}:
384 complex :: z = (-1.e0,0.e0)
391 @item @emph{Specific names}:
392 @multitable @columnfractions .20 .20 .20 .25
393 @item Name @tab Argument @tab Return type @tab Standard
394 @item @code{CABS(Z)} @tab @code{COMPLEX(4) Z} @tab @code{REAL(4)} @tab F77 and later
395 @item @code{DABS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
396 @item @code{IABS(I)} @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)} @tab F77 and later
397 @item @code{ZABS(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
398 @item @code{CDABS(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
405 @section @code{ACCESS} --- Checks file access modes
407 @cindex file system, access mode
410 @item @emph{Description}:
411 @code{ACCESS(NAME, MODE)} checks whether the file @var{NAME}
412 exists, is readable, writable or executable. Except for the
413 executable check, @code{ACCESS} can be replaced by
414 Fortran 95's @code{INQUIRE}.
416 @item @emph{Standard}:
423 @code{RESULT = ACCESS(NAME, MODE)}
425 @item @emph{Arguments}:
426 @multitable @columnfractions .15 .70
427 @item @var{NAME} @tab Scalar @code{CHARACTER} with the file name.
428 Tailing blank are ignored unless the character @code{achar(0)} is
429 present, then all characters up to and excluding @code{achar(0)} are
431 @item @var{MODE} @tab Scalar @code{CHARACTER} with the file access mode,
432 may be any concatenation of @code{"r"} (readable), @code{"w"} (writable)
433 and @code{"x"} (executable), or @code{" "} to check for existence.
436 @item @emph{Return value}:
437 Returns a scalar @code{INTEGER}, which is @code{0} if the file is
438 accessible in the given mode; otherwise or if an invalid argument
439 has been given for @code{MODE} the value @code{1} is returned.
441 @item @emph{Example}:
445 character(len=*), parameter :: file = 'test.dat'
446 character(len=*), parameter :: file2 = 'test.dat '//achar(0)
447 if(access(file,' ') == 0) print *, trim(file),' is exists'
448 if(access(file,'r') == 0) print *, trim(file),' is readable'
449 if(access(file,'w') == 0) print *, trim(file),' is writable'
450 if(access(file,'x') == 0) print *, trim(file),' is executable'
451 if(access(file2,'rwx') == 0) &
452 print *, trim(file2),' is readable, writable and executable'
453 end program access_test
455 @item @emph{Specific names}:
456 @item @emph{See also}:
463 @section @code{ACHAR} --- Character in @acronym{ASCII} collating sequence
465 @cindex @acronym{ASCII} collating sequence
466 @cindex collating sequence, @acronym{ASCII}
469 @item @emph{Description}:
470 @code{ACHAR(I)} returns the character located at position @code{I}
471 in the @acronym{ASCII} collating sequence.
473 @item @emph{Standard}:
480 @code{RESULT = ACHAR(I)}
482 @item @emph{Arguments}:
483 @multitable @columnfractions .15 .70
484 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
487 @item @emph{Return value}:
488 The return value is of type @code{CHARACTER} with a length of one. The
489 kind type parameter is the same as @code{KIND('A')}.
491 @item @emph{Example}:
496 end program test_achar
500 See @ref{ICHAR} for a discussion of converting between numerical values
501 and formatted string representations.
503 @item @emph{See also}:
504 @ref{CHAR}, @ref{IACHAR}, @ref{ICHAR}
511 @section @code{ACOS} --- Arccosine function
514 @cindex trigonometric function, cosine, inverse
515 @cindex cosine, inverse
518 @item @emph{Description}:
519 @code{ACOS(X)} computes the arccosine of @var{X} (inverse of @code{COS(X)}).
521 @item @emph{Standard}:
528 @code{RESULT = ACOS(X)}
530 @item @emph{Arguments}:
531 @multitable @columnfractions .15 .70
532 @item @var{X} @tab The type shall be @code{REAL(*)} with a magnitude that is
536 @item @emph{Return value}:
537 The return value is of type @code{REAL(*)} and it lies in the
538 range @math{ 0 \leq \acos(x) \leq \pi}. The kind type parameter
539 is the same as @var{X}.
541 @item @emph{Example}:
544 real(8) :: x = 0.866_8
546 end program test_acos
549 @item @emph{Specific names}:
550 @multitable @columnfractions .20 .20 .20 .25
551 @item Name @tab Argument @tab Return type @tab Standard
552 @item @code{DACOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
555 @item @emph{See also}:
556 Inverse function: @ref{COS}
563 @section @code{ACOSH} --- Hyperbolic arccosine function
566 @cindex area hyperbolic cosine
567 @cindex hyperbolic arccosine
568 @cindex hyperbolic function, cosine, inverse
569 @cindex cosine, hyperbolic, inverse
572 @item @emph{Description}:
573 @code{ACOSH(X)} computes the hyperbolic arccosine of @var{X} (inverse of
576 @item @emph{Standard}:
583 @code{RESULT = ACOSH(X)}
585 @item @emph{Arguments}:
586 @multitable @columnfractions .15 .70
587 @item @var{X} @tab The type shall be @code{REAL(*)} with a magnitude that is
588 greater or equal to one.
591 @item @emph{Return value}:
592 The return value is of type @code{REAL(*)} and it lies in the
593 range @math{0 \leq \acosh (x) \leq \infty}.
595 @item @emph{Example}:
598 REAL(8), DIMENSION(3) :: x = (/ 1.0, 2.0, 3.0 /)
603 @item @emph{Specific names}:
604 @multitable @columnfractions .20 .20 .20 .25
605 @item Name @tab Argument @tab Return type @tab Standard
606 @item @code{DACOSH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
609 @item @emph{See also}:
610 Inverse function: @ref{COSH}
616 @section @code{ADJUSTL} --- Left adjust a string
618 @cindex string, adjust left
619 @cindex adjust string
622 @item @emph{Description}:
623 @code{ADJUSTL(STR)} will left adjust a string by removing leading spaces.
624 Spaces are inserted at the end of the string as needed.
626 @item @emph{Standard}:
633 @code{RESULT = ADJUSTL(STR)}
635 @item @emph{Arguments}:
636 @multitable @columnfractions .15 .70
637 @item @var{STR} @tab The type shall be @code{CHARACTER}.
640 @item @emph{Return value}:
641 The return value is of type @code{CHARACTER} where leading spaces
642 are removed and the same number of spaces are inserted on the end
645 @item @emph{Example}:
648 character(len=20) :: str = ' gfortran'
651 end program test_adjustl
654 @item @emph{See also}:
655 @ref{ADJUSTR}, @ref{TRIM}
661 @section @code{ADJUSTR} --- Right adjust a string
663 @cindex string, adjust right
664 @cindex adjust string
667 @item @emph{Description}:
668 @code{ADJUSTR(STR)} will right adjust a string by removing trailing spaces.
669 Spaces are inserted at the start of the string as needed.
671 @item @emph{Standard}:
678 @code{RESULT = ADJUSTR(STR)}
680 @item @emph{Arguments}:
681 @multitable @columnfractions .15 .70
682 @item @var{STR} @tab The type shall be @code{CHARACTER}.
685 @item @emph{Return value}:
686 The return value is of type @code{CHARACTER} where trailing spaces
687 are removed and the same number of spaces are inserted at the start
690 @item @emph{Example}:
693 character(len=20) :: str = 'gfortran'
696 end program test_adjustr
699 @item @emph{See also}:
700 @ref{ADJUSTL}, @ref{TRIM}
706 @section @code{AIMAG} --- Imaginary part of complex number
711 @cindex complex numbers, imaginary part
714 @item @emph{Description}:
715 @code{AIMAG(Z)} yields the imaginary part of complex argument @code{Z}.
716 The @code{IMAG(Z)} and @code{IMAGPART(Z)} intrinsic functions are provided
717 for compatibility with @command{g77}, and their use in new code is
718 strongly discouraged.
720 @item @emph{Standard}:
721 F77 and later, has overloads that are GNU extensions
727 @code{RESULT = AIMAG(Z)}
729 @item @emph{Arguments}:
730 @multitable @columnfractions .15 .70
731 @item @var{Z} @tab The type of the argument shall be @code{COMPLEX(*)}.
734 @item @emph{Return value}:
735 The return value is of type real with the
736 kind type parameter of the argument.
738 @item @emph{Example}:
743 z4 = cmplx(1.e0_4, 0.e0_4)
744 z8 = cmplx(0.e0_8, 1.e0_8)
745 print *, aimag(z4), dimag(z8)
746 end program test_aimag
749 @item @emph{Specific names}:
750 @multitable @columnfractions .20 .20 .20 .25
751 @item Name @tab Argument @tab Return type @tab Standard
752 @item @code{DIMAG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{REAL(8)} @tab GNU extension
753 @item @code{IMAG(Z)} @tab @code{COMPLEX(*) Z} @tab @code{REAL(*)} @tab GNU extension
754 @item @code{IMAGPART(Z)} @tab @code{COMPLEX(*) Z} @tab @code{REAL(*)} @tab GNU extension
761 @section @code{AINT} --- Truncate to a whole number
765 @cindex rounding, floor
768 @item @emph{Description}:
769 @code{AINT(X [, KIND])} truncates its argument to a whole number.
771 @item @emph{Standard}:
778 @code{RESULT = AINT(X [, KIND])}
780 @item @emph{Arguments}:
781 @multitable @columnfractions .15 .70
782 @item @var{X} @tab The type of the argument shall be @code{REAL(*)}.
783 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
784 expression indicating the kind parameter of
788 @item @emph{Return value}:
789 The return value is of type real with the kind type parameter of the
790 argument if the optional @var{KIND} is absent; otherwise, the kind
791 type parameter will be given by @var{KIND}. If the magnitude of
792 @var{X} is less than one, then @code{AINT(X)} returns zero. If the
793 magnitude is equal to or greater than one, then it returns the largest
794 whole number that does not exceed its magnitude. The sign is the same
795 as the sign of @var{X}.
797 @item @emph{Example}:
804 print *, aint(x4), dint(x8)
806 end program test_aint
809 @item @emph{Specific names}:
810 @multitable @columnfractions .20 .20 .20 .25
811 @item Name @tab Argument @tab Return type @tab Standard
812 @item @code{DINT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
819 @section @code{ALARM} --- Execute a routine after a given delay
821 @cindex delayed execution
824 @item @emph{Description}:
825 @code{ALARM(SECONDS, HANDLER [, STATUS])} causes external subroutine @var{HANDLER}
826 to be executed after a delay of @var{SECONDS} by using @code{alarm(2)} to
827 set up a signal and @code{signal(2)} to catch it. If @var{STATUS} is
828 supplied, it will be returned with the number of seconds remaining until
829 any previously scheduled alarm was due to be delivered, or zero if there
830 was no previously scheduled alarm.
832 @item @emph{Standard}:
839 @code{CALL ALARM(SECONDS, HANDLER [, STATUS])}
841 @item @emph{Arguments}:
842 @multitable @columnfractions .15 .70
843 @item @var{SECONDS} @tab The type of the argument shall be a scalar
844 @code{INTEGER}. It is @code{INTENT(IN)}.
845 @item @var{HANDLER} @tab Signal handler (@code{INTEGER FUNCTION} or
846 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar. The scalar
847 values may be either @code{SIG_IGN=1} to ignore the alarm generated
848 or @code{SIG_DFL=0} to set the default action. It is @code{INTENT(IN)}.
849 @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
850 variable of the default @code{INTEGER} kind. It is @code{INTENT(OUT)}.
853 @item @emph{Example}:
856 external handler_print
858 call alarm (3, handler_print, i)
861 end program test_alarm
863 This will cause the external routine @var{handler_print} to be called
870 @section @code{ALL} --- All values in @var{MASK} along @var{DIM} are true
872 @cindex array, apply condition
873 @cindex array, condition testing
876 @item @emph{Description}:
877 @code{ALL(MASK [, DIM])} determines if all the values are true in @var{MASK}
878 in the array along dimension @var{DIM}.
880 @item @emph{Standard}:
884 Transformational function
887 @code{RESULT = ALL(MASK [, DIM])}
889 @item @emph{Arguments}:
890 @multitable @columnfractions .15 .70
891 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL(*)} and
892 it shall not be scalar.
893 @item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer
894 with a value that lies between one and the rank of @var{MASK}.
897 @item @emph{Return value}:
898 @code{ALL(MASK)} returns a scalar value of type @code{LOGICAL(*)} where
899 the kind type parameter is the same as the kind type parameter of
900 @var{MASK}. If @var{DIM} is present, then @code{ALL(MASK, DIM)} returns
901 an array with the rank of @var{MASK} minus 1. The shape is determined from
902 the shape of @var{MASK} where the @var{DIM} dimension is elided.
906 @code{ALL(MASK)} is true if all elements of @var{MASK} are true.
907 It also is true if @var{MASK} has zero size; otherwise, it is false.
909 If the rank of @var{MASK} is one, then @code{ALL(MASK,DIM)} is equivalent
910 to @code{ALL(MASK)}. If the rank is greater than one, then @code{ALL(MASK,DIM)}
911 is determined by applying @code{ALL} to the array sections.
914 @item @emph{Example}:
918 l = all((/.true., .true., .true./))
923 integer a(2,3), b(2,3)
927 print *, all(a .eq. b, 1)
928 print *, all(a .eq. b, 2)
929 end subroutine section
937 @section @code{ALLOCATED} --- Status of an allocatable entity
939 @cindex allocation, status
942 @item @emph{Description}:
943 @code{ALLOCATED(X)} checks the status of whether @var{X} is allocated.
945 @item @emph{Standard}:
952 @code{RESULT = ALLOCATED(X)}
954 @item @emph{Arguments}:
955 @multitable @columnfractions .15 .70
956 @item @var{X} @tab The argument shall be an @code{ALLOCATABLE} array.
959 @item @emph{Return value}:
960 The return value is a scalar @code{LOGICAL} with the default logical
961 kind type parameter. If @var{X} is allocated, @code{ALLOCATED(X)}
962 is @code{.TRUE.}; otherwise, it returns the @code{.TRUE.}
964 @item @emph{Example}:
966 program test_allocated
968 real(4), allocatable :: x(:)
969 if (allocated(x) .eqv. .false.) allocate(x(i))
970 end program test_allocated
977 @section @code{AND} --- Bitwise logical AND
979 @cindex bitwise logical and
980 @cindex logical and, bitwise
983 @item @emph{Description}:
984 Bitwise logical @code{AND}.
986 This intrinsic routine is provided for backwards compatibility with
987 GNU Fortran 77. For integer arguments, programmers should consider
988 the use of the @ref{IAND} intrinsic defined by the Fortran standard.
990 @item @emph{Standard}:
997 @code{RESULT = AND(I, J)}
999 @item @emph{Arguments}:
1000 @multitable @columnfractions .15 .70
1001 @item @var{I} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
1002 @item @var{J} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
1005 @item @emph{Return value}:
1006 The return type is either @code{INTEGER(*)} or @code{LOGICAL} after
1007 cross-promotion of the arguments.
1009 @item @emph{Example}:
1012 LOGICAL :: T = .TRUE., F = .FALSE.
1014 DATA a / Z'F' /, b / Z'3' /
1016 WRITE (*,*) AND(T, T), AND(T, F), AND(F, T), AND(F, F)
1017 WRITE (*,*) AND(a, b)
1021 @item @emph{See also}:
1022 F95 elemental function: @ref{IAND}
1028 @section @code{ANINT} --- Nearest whole number
1032 @cindex rounding, ceiling
1035 @item @emph{Description}:
1036 @code{ANINT(X [, KIND])} rounds its argument to the nearest whole number.
1038 @item @emph{Standard}:
1044 @item @emph{Syntax}:
1045 @code{RESULT = ANINT(X [, KIND])}
1047 @item @emph{Arguments}:
1048 @multitable @columnfractions .15 .70
1049 @item @var{X} @tab The type of the argument shall be @code{REAL(*)}.
1050 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
1051 expression indicating the kind parameter of
1055 @item @emph{Return value}:
1056 The return value is of type real with the kind type parameter of the
1057 argument if the optional @var{KIND} is absent; otherwise, the kind
1058 type parameter will be given by @var{KIND}. If @var{X} is greater than
1059 zero, then @code{ANINT(X)} returns @code{AINT(X+0.5)}. If @var{X} is
1060 less than or equal to zero, then it returns @code{AINT(X-0.5)}.
1062 @item @emph{Example}:
1069 print *, anint(x4), dnint(x8)
1071 end program test_anint
1074 @item @emph{Specific names}:
1075 @multitable @columnfractions .20 .20 .20 .25
1076 @item Name @tab Argument @tab Return type @tab Standard
1077 @item @code{DNINT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1084 @section @code{ANY} --- Any value in @var{MASK} along @var{DIM} is true
1086 @cindex array, apply condition
1087 @cindex array, condition testing
1090 @item @emph{Description}:
1091 @code{ANY(MASK [, DIM])} determines if any of the values in the logical array
1092 @var{MASK} along dimension @var{DIM} are @code{.TRUE.}.
1094 @item @emph{Standard}:
1098 Transformational function
1100 @item @emph{Syntax}:
1101 @code{RESULT = ANY(MASK [, DIM])}
1103 @item @emph{Arguments}:
1104 @multitable @columnfractions .15 .70
1105 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL(*)} and
1106 it shall not be scalar.
1107 @item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer
1108 with a value that lies between one and the rank of @var{MASK}.
1111 @item @emph{Return value}:
1112 @code{ANY(MASK)} returns a scalar value of type @code{LOGICAL(*)} where
1113 the kind type parameter is the same as the kind type parameter of
1114 @var{MASK}. If @var{DIM} is present, then @code{ANY(MASK, DIM)} returns
1115 an array with the rank of @var{MASK} minus 1. The shape is determined from
1116 the shape of @var{MASK} where the @var{DIM} dimension is elided.
1120 @code{ANY(MASK)} is true if any element of @var{MASK} is true;
1121 otherwise, it is false. It also is false if @var{MASK} has zero size.
1123 If the rank of @var{MASK} is one, then @code{ANY(MASK,DIM)} is equivalent
1124 to @code{ANY(MASK)}. If the rank is greater than one, then @code{ANY(MASK,DIM)}
1125 is determined by applying @code{ANY} to the array sections.
1128 @item @emph{Example}:
1132 l = any((/.true., .true., .true./))
1137 integer a(2,3), b(2,3)
1141 print *, any(a .eq. b, 1)
1142 print *, any(a .eq. b, 2)
1143 end subroutine section
1144 end program test_any
1151 @section @code{ASIN} --- Arcsine function
1154 @cindex trigonometric function, sine, inverse
1155 @cindex sine, inverse
1158 @item @emph{Description}:
1159 @code{ASIN(X)} computes the arcsine of its @var{X} (inverse of @code{SIN(X)}).
1161 @item @emph{Standard}:
1167 @item @emph{Syntax}:
1168 @code{RESULT = ASIN(X)}
1170 @item @emph{Arguments}:
1171 @multitable @columnfractions .15 .70
1172 @item @var{X} @tab The type shall be @code{REAL(*)}, and a magnitude that is
1176 @item @emph{Return value}:
1177 The return value is of type @code{REAL(*)} and it lies in the
1178 range @math{-\pi / 2 \leq \asin (x) \leq \pi / 2}. The kind type
1179 parameter is the same as @var{X}.
1181 @item @emph{Example}:
1184 real(8) :: x = 0.866_8
1186 end program test_asin
1189 @item @emph{Specific names}:
1190 @multitable @columnfractions .20 .20 .20 .25
1191 @item Name @tab Argument @tab Return type @tab Standard
1192 @item @code{DASIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1195 @item @emph{See also}:
1196 Inverse function: @ref{SIN}
1203 @section @code{ASINH} --- Hyperbolic arcsine function
1206 @cindex area hyperbolic sine
1207 @cindex hyperbolic arcsine
1208 @cindex hyperbolic function, sine, inverse
1209 @cindex sine, hyperbolic, inverse
1212 @item @emph{Description}:
1213 @code{ASINH(X)} computes the hyperbolic arcsine of @var{X} (inverse of @code{SINH(X)}).
1215 @item @emph{Standard}:
1221 @item @emph{Syntax}:
1222 @code{RESULT = ASINH(X)}
1224 @item @emph{Arguments}:
1225 @multitable @columnfractions .15 .70
1226 @item @var{X} @tab The type shall be @code{REAL(*)}, with @var{X} a real number.
1229 @item @emph{Return value}:
1230 The return value is of type @code{REAL(*)} and it lies in the
1231 range @math{-\infty \leq \asinh (x) \leq \infty}.
1233 @item @emph{Example}:
1236 REAL(8), DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1237 WRITE (*,*) ASINH(x)
1241 @item @emph{Specific names}:
1242 @multitable @columnfractions .20 .20 .20 .25
1243 @item Name @tab Argument @tab Return type @tab Standard
1244 @item @code{DASINH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension.
1247 @item @emph{See also}:
1248 Inverse function: @ref{SINH}
1254 @section @code{ASSOCIATED} --- Status of a pointer or pointer/target pair
1256 @cindex pointer, status
1257 @cindex association status
1260 @item @emph{Description}:
1261 @code{ASSOCIATED(PTR [, TGT])} determines the status of the pointer @var{PTR}
1262 or if @var{PTR} is associated with the target @var{TGT}.
1264 @item @emph{Standard}:
1270 @item @emph{Syntax}:
1271 @code{RESULT = ASSOCIATED(PTR [, TGT])}
1273 @item @emph{Arguments}:
1274 @multitable @columnfractions .15 .70
1275 @item @var{PTR} @tab @var{PTR} shall have the @code{POINTER} attribute and
1276 it can be of any type.
1277 @item @var{TGT} @tab (Optional) @var{TGT} shall be a @code{POINTER} or
1278 a @code{TARGET}. It must have the same type, kind type parameter, and
1279 array rank as @var{PTR}.
1281 The status of neither @var{PTR} nor @var{TGT} can be undefined.
1283 @item @emph{Return value}:
1284 @code{ASSOCIATED(PTR)} returns a scalar value of type @code{LOGICAL(4)}.
1285 There are several cases:
1287 @item (A) If the optional @var{TGT} is not present, then @code{ASSOCIATED(PTR)}
1288 is true if @var{PTR} is associated with a target; otherwise, it returns false.
1289 @item (B) If @var{TGT} is present and a scalar target, the result is true if
1291 is not a 0 sized storage sequence and the target associated with @var{PTR}
1292 occupies the same storage units. If @var{PTR} is disassociated, then the
1294 @item (C) If @var{TGT} is present and an array target, the result is true if
1295 @var{TGT} and @var{PTR} have the same shape, are not 0 sized arrays, are
1296 arrays whose elements are not 0 sized storage sequences, and @var{TGT} and
1297 @var{PTR} occupy the same storage units in array element order.
1298 As in case(B), the result is false, if @var{PTR} is disassociated.
1299 @item (D) If @var{TGT} is present and an scalar pointer, the result is true if
1300 target associated with @var{PTR} and the target associated with @var{TGT}
1301 are not 0 sized storage sequences and occupy the same storage units.
1302 The result is false, if either @var{TGT} or @var{PTR} is disassociated.
1303 @item (E) If @var{TGT} is present and an array pointer, the result is true if
1304 target associated with @var{PTR} and the target associated with @var{TGT}
1305 have the same shape, are not 0 sized arrays, are arrays whose elements are
1306 not 0 sized storage sequences, and @var{TGT} and @var{PTR} occupy the same
1307 storage units in array element order.
1308 The result is false, if either @var{TGT} or @var{PTR} is disassociated.
1311 @item @emph{Example}:
1313 program test_associated
1315 real, target :: tgt(2) = (/1., 2./)
1316 real, pointer :: ptr(:)
1318 if (associated(ptr) .eqv. .false.) call abort
1319 if (associated(ptr,tgt) .eqv. .false.) call abort
1320 end program test_associated
1323 @item @emph{See also}:
1330 @section @code{ATAN} --- Arctangent function
1333 @cindex trigonometric function, tangent, inverse
1334 @cindex tangent, inverse
1337 @item @emph{Description}:
1338 @code{ATAN(X)} computes the arctangent of @var{X}.
1340 @item @emph{Standard}:
1346 @item @emph{Syntax}:
1347 @code{RESULT = ATAN(X)}
1349 @item @emph{Arguments}:
1350 @multitable @columnfractions .15 .70
1351 @item @var{X} @tab The type shall be @code{REAL(*)}.
1354 @item @emph{Return value}:
1355 The return value is of type @code{REAL(*)} and it lies in the
1356 range @math{ - \pi / 2 \leq \atan (x) \leq \pi / 2}.
1358 @item @emph{Example}:
1361 real(8) :: x = 2.866_8
1363 end program test_atan
1366 @item @emph{Specific names}:
1367 @multitable @columnfractions .20 .20 .20 .25
1368 @item Name @tab Argument @tab Return type @tab Standard
1369 @item @code{DATAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1372 @item @emph{See also}:
1373 Inverse function: @ref{TAN}
1380 @section @code{ATAN2} --- Arctangent function
1383 @cindex trigonometric function, tangent, inverse
1384 @cindex tangent, inverse
1387 @item @emph{Description}:
1388 @code{ATAN2(Y,X)} computes the arctangent of the complex number
1391 @item @emph{Standard}:
1397 @item @emph{Syntax}:
1398 @code{RESULT = ATAN2(Y,X)}
1400 @item @emph{Arguments}:
1401 @multitable @columnfractions .15 .70
1402 @item @var{Y} @tab The type shall be @code{REAL(*)}.
1403 @item @var{X} @tab The type and kind type parameter shall be the same as @var{Y}.
1404 If @var{Y} is zero, then @var{X} must be nonzero.
1407 @item @emph{Return value}:
1408 The return value has the same type and kind type parameter as @var{Y}.
1409 It is the principal value of the complex number @math{X + i Y}. If
1410 @var{X} is nonzero, then it lies in the range @math{-\pi \le \atan (x) \leq \pi}.
1411 The sign is positive if @var{Y} is positive. If @var{Y} is zero, then
1412 the return value is zero if @var{X} is positive and @math{\pi} if @var{X}
1413 is negative. Finally, if @var{X} is zero, then the magnitude of the result
1416 @item @emph{Example}:
1419 real(4) :: x = 1.e0_4, y = 0.5e0_4
1421 end program test_atan2
1424 @item @emph{Specific names}:
1425 @multitable @columnfractions .20 .20 .20 .25
1426 @item Name @tab Argument @tab Return type @tab Standard
1427 @item @code{DATAN2(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1434 @section @code{ATANH} --- Hyperbolic arctangent function
1437 @cindex area hyperbolic tangent
1438 @cindex hyperbolic arctangent
1439 @cindex hyperbolic function, tangent, inverse
1440 @cindex tangent, hyperbolic, inverse
1443 @item @emph{Description}:
1444 @code{ATANH(X)} computes the hyperbolic arctangent of @var{X} (inverse
1447 @item @emph{Standard}:
1453 @item @emph{Syntax}:
1454 @code{RESULT = ATANH(X)}
1456 @item @emph{Arguments}:
1457 @multitable @columnfractions .15 .70
1458 @item @var{X} @tab The type shall be @code{REAL(*)} with a magnitude
1459 that is less than or equal to one.
1462 @item @emph{Return value}:
1463 The return value is of type @code{REAL(*)} and it lies in the
1464 range @math{-\infty \leq \atanh(x) \leq \infty}.
1466 @item @emph{Example}:
1469 REAL, DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1470 WRITE (*,*) ATANH(x)
1474 @item @emph{Specific names}:
1475 @multitable @columnfractions .20 .20 .20 .25
1476 @item Name @tab Argument @tab Return type @tab Standard
1477 @item @code{DATANH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1480 @item @emph{See also}:
1481 Inverse function: @ref{TANH}
1487 @section @code{BESJ0} --- Bessel function of the first kind of order 0
1490 @cindex Bessel function, first kind
1493 @item @emph{Description}:
1494 @code{BESJ0(X)} computes the Bessel function of the first kind of order 0
1497 @item @emph{Standard}:
1503 @item @emph{Syntax}:
1504 @code{RESULT = BESJ0(X)}
1506 @item @emph{Arguments}:
1507 @multitable @columnfractions .15 .70
1508 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1511 @item @emph{Return value}:
1512 The return value is of type @code{REAL(*)} and it lies in the
1513 range @math{ - 0.4027... \leq Bessel (0,x) \leq 1}.
1515 @item @emph{Example}:
1518 real(8) :: x = 0.0_8
1520 end program test_besj0
1523 @item @emph{Specific names}:
1524 @multitable @columnfractions .20 .20 .20 .25
1525 @item Name @tab Argument @tab Return type @tab Standard
1526 @item @code{DBESJ0(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1533 @section @code{BESJ1} --- Bessel function of the first kind of order 1
1536 @cindex Bessel function, first kind
1539 @item @emph{Description}:
1540 @code{BESJ1(X)} computes the Bessel function of the first kind of order 1
1543 @item @emph{Standard}:
1549 @item @emph{Syntax}:
1550 @code{RESULT = BESJ1(X)}
1552 @item @emph{Arguments}:
1553 @multitable @columnfractions .15 .70
1554 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1557 @item @emph{Return value}:
1558 The return value is of type @code{REAL(*)} and it lies in the
1559 range @math{ - 0.5818... \leq Bessel (0,x) \leq 0.5818 }.
1561 @item @emph{Example}:
1564 real(8) :: x = 1.0_8
1566 end program test_besj1
1569 @item @emph{Specific names}:
1570 @multitable @columnfractions .20 .20 .20 .25
1571 @item Name @tab Argument @tab Return type @tab Standard
1572 @item @code{DBESJ1(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1579 @section @code{BESJN} --- Bessel function of the first kind
1582 @cindex Bessel function, first kind
1585 @item @emph{Description}:
1586 @code{BESJN(N, X)} computes the Bessel function of the first kind of order
1589 If both arguments are arrays, their ranks and shapes shall conform.
1591 @item @emph{Standard}:
1597 @item @emph{Syntax}:
1598 @code{RESULT = BESJN(N, X)}
1600 @item @emph{Arguments}:
1601 @multitable @columnfractions .15 .70
1602 @item @var{N} @tab Shall be a scalar or an array of type @code{INTEGER(*)}.
1603 @item @var{X} @tab Shall be a scalar or an array of type @code{REAL(*)}.
1606 @item @emph{Return value}:
1607 The return value is a scalar of type @code{REAL(*)}.
1609 @item @emph{Example}:
1612 real(8) :: x = 1.0_8
1614 end program test_besjn
1617 @item @emph{Specific names}:
1618 @multitable @columnfractions .20 .20 .20 .25
1619 @item Name @tab Argument @tab Return type @tab Standard
1620 @item @code{DBESJN(X)} @tab @code{INTEGER(*) N} @tab @code{REAL(8)} @tab GNU extension
1621 @item @tab @code{REAL(8) X} @tab @tab
1628 @section @code{BESY0} --- Bessel function of the second kind of order 0
1631 @cindex Bessel function, second kind
1634 @item @emph{Description}:
1635 @code{BESY0(X)} computes the Bessel function of the second kind of order 0
1638 @item @emph{Standard}:
1644 @item @emph{Syntax}:
1645 @code{RESULT = BESY0(X)}
1647 @item @emph{Arguments}:
1648 @multitable @columnfractions .15 .70
1649 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1652 @item @emph{Return value}:
1653 The return value is a scalar of type @code{REAL(*)}.
1655 @item @emph{Example}:
1658 real(8) :: x = 0.0_8
1660 end program test_besy0
1663 @item @emph{Specific names}:
1664 @multitable @columnfractions .20 .20 .20 .25
1665 @item Name @tab Argument @tab Return type @tab Standard
1666 @item @code{DBESY0(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1673 @section @code{BESY1} --- Bessel function of the second kind of order 1
1676 @cindex Bessel function, second kind
1679 @item @emph{Description}:
1680 @code{BESY1(X)} computes the Bessel function of the second kind of order 1
1683 @item @emph{Standard}:
1689 @item @emph{Syntax}:
1690 @code{RESULT = BESY1(X)}
1692 @item @emph{Arguments}:
1693 @multitable @columnfractions .15 .70
1694 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1697 @item @emph{Return value}:
1698 The return value is a scalar of type @code{REAL(*)}.
1700 @item @emph{Example}:
1703 real(8) :: x = 1.0_8
1705 end program test_besy1
1708 @item @emph{Specific names}:
1709 @multitable @columnfractions .20 .20 .20 .25
1710 @item Name @tab Argument @tab Return type @tab Standard
1711 @item @code{DBESY1(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1718 @section @code{BESYN} --- Bessel function of the second kind
1721 @cindex Bessel function, second kind
1724 @item @emph{Description}:
1725 @code{BESYN(N, X)} computes the Bessel function of the second kind of order
1728 If both arguments are arrays, their ranks and shapes shall conform.
1730 @item @emph{Standard}:
1736 @item @emph{Syntax}:
1737 @code{RESULT = BESYN(N, X)}
1739 @item @emph{Arguments}:
1740 @multitable @columnfractions .15 .70
1741 @item @var{N} @tab Shall be a scalar or an array of type @code{INTEGER(*)}.
1742 @item @var{X} @tab Shall be a scalar or an array of type @code{REAL(*)}.
1745 @item @emph{Return value}:
1746 The return value is a scalar of type @code{REAL(*)}.
1748 @item @emph{Example}:
1751 real(8) :: x = 1.0_8
1753 end program test_besyn
1756 @item @emph{Specific names}:
1757 @multitable @columnfractions .20 .20 .20 .25
1758 @item Name @tab Argument @tab Return type @tab Standard
1759 @item @code{DBESYN(N,X)} @tab @code{INTEGER(*) N} @tab @code{REAL(8)} @tab GNU extension
1760 @item @tab @code{REAL(8) X} @tab @tab
1767 @section @code{BIT_SIZE} --- Bit size inquiry function
1769 @cindex bits, number of
1770 @cindex size of a variable, in bits
1773 @item @emph{Description}:
1774 @code{BIT_SIZE(I)} returns the number of bits (integer precision plus sign bit)
1775 represented by the type of @var{I}.
1777 @item @emph{Standard}:
1783 @item @emph{Syntax}:
1784 @code{RESULT = BIT_SIZE(I)}
1786 @item @emph{Arguments}:
1787 @multitable @columnfractions .15 .70
1788 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1791 @item @emph{Return value}:
1792 The return value is of type @code{INTEGER(*)}
1794 @item @emph{Example}:
1796 program test_bit_size
1801 end program test_bit_size
1808 @section @code{BTEST} --- Bit test function
1810 @cindex bits, testing
1813 @item @emph{Description}:
1814 @code{BTEST(I,POS)} returns logical @code{.TRUE.} if the bit at @var{POS}
1817 @item @emph{Standard}:
1823 @item @emph{Syntax}:
1824 @code{RESULT = BTEST(I, POS)}
1826 @item @emph{Arguments}:
1827 @multitable @columnfractions .15 .70
1828 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1829 @item @var{POS} @tab The type shall be @code{INTEGER(*)}.
1832 @item @emph{Return value}:
1833 The return value is of type @code{LOGICAL}
1835 @item @emph{Example}:
1838 integer :: i = 32768 + 1024 + 64
1842 bool = btest(i, pos)
1845 end program test_btest
1851 @section @code{C_ASSOCIATED} --- Status of a C pointer
1852 @fnindex C_ASSOCIATED
1853 @cindex association status, C pointer
1854 @cindex pointer, C association status
1857 @item @emph{Description}:
1858 @code{C_ASSOICATED(c_prt1[, c_ptr2])} determines the status of the C pointer @var{c_ptr1}
1859 or if @var{c_ptr1} is associated with the target @var{c_ptr2}.
1861 @item @emph{Standard}:
1867 @item @emph{Syntax}:
1868 @code{RESULT = C_ASSOICATED(c_prt1[, c_ptr2])}
1870 @item @emph{Arguments}:
1871 @multitable @columnfractions .15 .70
1872 @item @var{c_ptr1} @tab Scalar of the type @code{C_PTR} or @code{C_FUNPTR}.
1873 @item @var{c_ptr2} @tab (Optional) Scalar of the same type as @var{c_ptr1}.
1876 @item @emph{Return value}:
1877 The return value is of type @code{LOGICAL}; it is @code{.false.} if either
1878 @var{c_ptr1} is a C NULL pointer or if @var{c_ptr1} and @var{c_ptr2}
1879 point to different addresses.
1881 @item @emph{Example}:
1883 subroutine association_test(a,b)
1884 use iso_c_binding, only: c_associated, c_loc, c_ptr
1888 if(c_associated(b, c_loc(a))) &
1889 stop 'b and a do not point to same target'
1890 end subroutine association_test
1893 @item @emph{See also}:
1894 @ref{C_LOC}, @ref{C_FUNLOC}
1899 @section @code{C_FUNLOC} --- Obtain the C address of a procedure
1901 @cindex pointer, C address of procedures
1904 @item @emph{Description}:
1905 @code{C_FUNLOC(x)} determines the C address of the argument.
1907 @item @emph{Standard}:
1913 @item @emph{Syntax}:
1914 @code{RESULT = C_FUNLOC(x)}
1916 @item @emph{Arguments}:
1917 @multitable @columnfractions .15 .70
1918 @item @var{x} @tab Interoperable function or pointer to such function.
1921 @item @emph{Return value}:
1922 The return value is of type @code{C_FUNPTR} and contains the C address
1925 @item @emph{Example}:
1931 subroutine sub(a) bind(c)
1941 subroutine my_routine(p) bind(c,name='myC_func')
1943 type(c_funptr), intent(in) :: p
1946 call my_routine(c_funloc(sub))
1950 @item @emph{See also}:
1951 @ref{C_ASSOCIATED}, @ref{C_LOC}, @ref{C_F_POINTER}, @ref{C_F_PROCPOINTER}
1955 @node C_F_PROCPOINTER
1956 @section @code{C_F_PROCPOINTER} --- Convert C into Fortran procedure pointer
1957 @fnindex C_F_PROCPOINTER
1958 @cindex pointer, C address of pointers
1961 @item @emph{Description}:
1962 @code{C_F_PROCPOINTER(cptr, fptr)} Assign the target of the C function pointer
1963 @var{cptr} to the Fortran procedure pointer @var{fptr}.
1965 Note: Due to the currently lacking support of procedure pointers in GNU Fortran
1966 this function is not fully operable.
1968 @item @emph{Standard}:
1974 @item @emph{Syntax}:
1975 @code{CALL C_F_PROCPOINTER(cptr, fptr)}
1977 @item @emph{Arguments}:
1978 @multitable @columnfractions .15 .70
1979 @item @var{cptr} @tab scalar of the type @code{C_FUNPTR}. It is
1981 @item @var{fptr} @tab procedure pointer interoperable with @var{cptr}. It is
1985 @item @emph{Example}:
1993 real(c_float), intent(in) :: a
1994 real(c_float) :: func
1998 function getIterFunc() bind(c,name="getIterFunc")
2000 type(c_funptr) :: getIterFunc
2003 type(c_funptr) :: cfunptr
2004 procedure(func), pointer :: myFunc
2005 cfunptr = getIterFunc()
2006 call c_f_procpointer(cfunptr, myFunc)
2010 @item @emph{See also}:
2011 @ref{C_LOC}, @ref{C_F_POINTER}
2016 @section @code{C_F_POINTER} --- Convert C into Fortran pointer
2017 @fnindex C_F_POINTER
2018 @cindex pointer, convert C to Fortran
2021 @item @emph{Description}:
2022 @code{C_F_POINTER(cptr, fptr[, shape])} Assign the target the C pointer
2023 @var{cptr} to the Fortran pointer @var{fptr} and specify its
2026 @item @emph{Standard}:
2032 @item @emph{Syntax}:
2033 @code{CALL C_F_POINTER(cptr, fptr[, shape])}
2035 @item @emph{Arguments}:
2036 @multitable @columnfractions .15 .70
2037 @item @var{cptr} @tab scalar of the type @code{C_PTR}. It is
2039 @item @var{fptr} @tab pointer interoperable with @var{cptr}. It is
2041 @item @var{shape} @tab (Optional) Rank-one array of type @code{INTEGER}
2042 with @code{INTENT(IN)}. It shall be present
2043 if and only if @var{fptr} is an array. The size
2044 must be equal to the rank of @var{fptr}.
2047 @item @emph{Example}:
2053 subroutine my_routine(p) bind(c,name='myC_func')
2055 type(c_ptr), intent(out) :: p
2059 real,pointer :: a(:)
2060 call my_routine(cptr)
2061 call c_f_pointer(cptr, a, [12])
2065 @item @emph{See also}:
2066 @ref{C_LOC}, @ref{C_F_PROCPOINTER}
2071 @section @code{C_LOC} --- Obtain the C address of an object
2073 @cindex procedure pointer, convert C to Fortran
2076 @item @emph{Description}:
2077 @code{C_LOC(x)} determines the C address of the argument.
2079 @item @emph{Standard}:
2085 @item @emph{Syntax}:
2086 @code{RESULT = C_LOC(x)}
2088 @item @emph{Arguments}:
2089 @multitable @columnfractions .15 .70
2090 @item @var{x} @tab Associated scalar pointer or interoperable scalar
2091 or allocated allocatable variable with @code{TARGET}
2095 @item @emph{Return value}:
2096 The return value is of type @code{C_PTR} and contains the C address
2099 @item @emph{Example}:
2101 subroutine association_test(a,b)
2102 use iso_c_binding, only: c_associated, c_loc, c_ptr
2106 if(c_associated(b, c_loc(a))) &
2107 stop 'b and a do not point to same target'
2108 end subroutine association_test
2111 @item @emph{See also}:
2112 @ref{C_ASSOCIATED}, @ref{C_FUNLOC}, @ref{C_F_POINTER}, @ref{C_F_PROCPOINTER}
2117 @section @code{CEILING} --- Integer ceiling function
2120 @cindex rounding, ceiling
2123 @item @emph{Description}:
2124 @code{CEILING(X)} returns the least integer greater than or equal to @var{X}.
2126 @item @emph{Standard}:
2132 @item @emph{Syntax}:
2133 @code{RESULT = CEILING(X [, KIND])}
2135 @item @emph{Arguments}:
2136 @multitable @columnfractions .15 .70
2137 @item @var{X} @tab The type shall be @code{REAL(*)}.
2138 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
2139 expression indicating the kind parameter of
2143 @item @emph{Return value}:
2144 The return value is of type @code{INTEGER(KIND)}
2146 @item @emph{Example}:
2148 program test_ceiling
2151 print *, ceiling(x) ! returns 64
2152 print *, ceiling(y) ! returns -63
2153 end program test_ceiling
2156 @item @emph{See also}:
2157 @ref{FLOOR}, @ref{NINT}
2164 @section @code{CHAR} --- Character conversion function
2166 @cindex conversion, to character
2169 @item @emph{Description}:
2170 @code{CHAR(I [, KIND])} returns the character represented by the integer @var{I}.
2172 @item @emph{Standard}:
2178 @item @emph{Syntax}:
2179 @code{RESULT = CHAR(I [, KIND])}
2181 @item @emph{Arguments}:
2182 @multitable @columnfractions .15 .70
2183 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
2184 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
2185 expression indicating the kind parameter of
2189 @item @emph{Return value}:
2190 The return value is of type @code{CHARACTER(1)}
2192 @item @emph{Example}:
2198 print *, i, c ! returns 'J'
2199 end program test_char
2203 See @ref{ICHAR} for a discussion of converting between numerical values
2204 and formatted string representations.
2206 @item @emph{See also}:
2207 @ref{ACHAR}, @ref{IACHAR}, @ref{ICHAR}
2214 @section @code{CHDIR} --- Change working directory
2216 @cindex system, working directory
2219 @item @emph{Description}:
2220 Change current working directory to a specified path.
2222 This intrinsic is provided in both subroutine and function forms; however,
2223 only one form can be used in any given program unit.
2225 @item @emph{Standard}:
2229 Subroutine, function
2231 @item @emph{Syntax}:
2232 @multitable @columnfractions .80
2233 @item @code{CALL CHDIR(NAME [, STATUS])}
2234 @item @code{STATUS = CHDIR(NAME)}
2237 @item @emph{Arguments}:
2238 @multitable @columnfractions .15 .70
2239 @item @var{NAME} @tab The type shall be @code{CHARACTER(*)} and shall
2240 specify a valid path within the file system.
2241 @item @var{STATUS} @tab (Optional) @code{INTEGER} status flag of the default
2242 kind. Returns 0 on success, and a system specific
2243 and nonzero error code otherwise.
2246 @item @emph{Example}:
2249 CHARACTER(len=255) :: path
2251 WRITE(*,*) TRIM(path)
2254 WRITE(*,*) TRIM(path)
2258 @item @emph{See also}:
2265 @section @code{CHMOD} --- Change access permissions of files
2267 @cindex file system, change access mode
2270 @item @emph{Description}:
2271 @code{CHMOD} changes the permissions of a file. This function invokes
2272 @code{/bin/chmod} and might therefore not work on all platforms.
2274 This intrinsic is provided in both subroutine and function forms; however,
2275 only one form can be used in any given program unit.
2277 @item @emph{Standard}:
2281 Subroutine, function
2283 @item @emph{Syntax}:
2284 @multitable @columnfractions .80
2285 @item @code{CALL CHMOD(NAME, MODE[, STATUS])}
2286 @item @code{STATUS = CHMOD(NAME, MODE)}
2289 @item @emph{Arguments}:
2290 @multitable @columnfractions .15 .70
2291 @item @var{NAME} @tab Scalar @code{CHARACTER} with the file name.
2292 Trailing blanks are ignored unless the character @code{achar(0)} is
2293 present, then all characters up to and excluding @code{achar(0)} are
2294 used as the file name.
2296 @item @var{MODE} @tab Scalar @code{CHARACTER} giving the file permission.
2297 @var{MODE} uses the same syntax as the @var{MODE} argument of
2300 @item @var{STATUS} @tab (optional) scalar @code{INTEGER}, which is
2301 @code{0} on success and nonzero otherwise.
2304 @item @emph{Return value}:
2305 In either syntax, @var{STATUS} is set to @code{0} on success and nonzero
2308 @item @emph{Example}:
2309 @code{CHMOD} as subroutine
2314 call chmod('test.dat','u+x',status)
2315 print *, 'Status: ', status
2316 end program chmod_test
2318 @code{CHMOD} as function:
2323 status = chmod('test.dat','u+x')
2324 print *, 'Status: ', status
2325 end program chmod_test
2333 @section @code{CMPLX} --- Complex conversion function
2335 @cindex complex numbers, conversion to
2336 @cindex conversion, to complex
2339 @item @emph{Description}:
2340 @code{CMPLX(X [, Y [, KIND]])} returns a complex number where @var{X} is converted to
2341 the real component. If @var{Y} is present it is converted to the imaginary
2342 component. If @var{Y} is not present then the imaginary component is set to
2343 0.0. If @var{X} is complex then @var{Y} must not be present.
2345 @item @emph{Standard}:
2351 @item @emph{Syntax}:
2352 @code{RESULT = CMPLX(X [, Y [, KIND]])}
2354 @item @emph{Arguments}:
2355 @multitable @columnfractions .15 .70
2356 @item @var{X} @tab The type may be @code{INTEGER(*)}, @code{REAL(*)},
2357 or @code{COMPLEX(*)}.
2358 @item @var{Y} @tab (Optional; only allowed if @var{X} is not
2359 @code{COMPLEX(*)}.) May be @code{INTEGER(*)}
2361 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
2362 expression indicating the kind parameter of
2366 @item @emph{Return value}:
2367 The return value is of @code{COMPLEX} type, with a kind equal to
2368 @var{KIND} if it is specified. If @var{KIND} is not specified, the
2369 result is of the default @code{COMPLEX} kind, regardless of the kinds of
2370 @var{X} and @var{Y}.
2372 @item @emph{Example}:
2379 print *, z, cmplx(x)
2380 end program test_cmplx
2383 @item @emph{See also}:
2389 @node COMMAND_ARGUMENT_COUNT
2390 @section @code{COMMAND_ARGUMENT_COUNT} --- Get number of command line arguments
2391 @fnindex COMMAND_ARGUMENT_COUNT
2392 @cindex command-line arguments
2393 @cindex command-line arguments, number of
2394 @cindex arguments, to program
2397 @item @emph{Description}:
2398 @code{COMMAND_ARGUMENT_COUNT()} returns the number of arguments passed on the
2399 command line when the containing program was invoked.
2401 @item @emph{Standard}:
2407 @item @emph{Syntax}:
2408 @code{RESULT = COMMAND_ARGUMENT_COUNT()}
2410 @item @emph{Arguments}:
2411 @multitable @columnfractions .15 .70
2415 @item @emph{Return value}:
2416 The return value is of type @code{INTEGER(4)}
2418 @item @emph{Example}:
2420 program test_command_argument_count
2422 count = command_argument_count()
2424 end program test_command_argument_count
2427 @item @emph{See also}:
2428 @ref{GET_COMMAND}, @ref{GET_COMMAND_ARGUMENT}
2434 @section @code{COMPLEX} --- Complex conversion function
2436 @cindex complex numbers, conversion to
2437 @cindex conversion, to complex
2440 @item @emph{Description}:
2441 @code{COMPLEX(X, Y)} returns a complex number where @var{X} is converted
2442 to the real component and @var{Y} is converted to the imaginary
2445 @item @emph{Standard}:
2451 @item @emph{Syntax}:
2452 @code{RESULT = COMPLEX(X, Y)}
2454 @item @emph{Arguments}:
2455 @multitable @columnfractions .15 .70
2456 @item @var{X} @tab The type may be @code{INTEGER(*)} or @code{REAL(*)}.
2457 @item @var{Y} @tab The type may be @code{INTEGER(*)} or @code{REAL(*)}.
2460 @item @emph{Return value}:
2461 If @var{X} and @var{Y} are both of @code{INTEGER} type, then the return
2462 value is of default @code{COMPLEX} type.
2464 If @var{X} and @var{Y} are of @code{REAL} type, or one is of @code{REAL}
2465 type and one is of @code{INTEGER} type, then the return value is of
2466 @code{COMPLEX} type with a kind equal to that of the @code{REAL}
2467 argument with the highest precision.
2469 @item @emph{Example}:
2471 program test_complex
2474 print *, complex(i, x)
2475 end program test_complex
2478 @item @emph{See also}:
2485 @section @code{CONJG} --- Complex conjugate function
2488 @cindex complex conjugate
2491 @item @emph{Description}:
2492 @code{CONJG(Z)} returns the conjugate of @var{Z}. If @var{Z} is @code{(x, y)}
2493 then the result is @code{(x, -y)}
2495 @item @emph{Standard}:
2496 F77 and later, has overloads that are GNU extensions
2501 @item @emph{Syntax}:
2504 @item @emph{Arguments}:
2505 @multitable @columnfractions .15 .70
2506 @item @var{Z} @tab The type shall be @code{COMPLEX(*)}.
2509 @item @emph{Return value}:
2510 The return value is of type @code{COMPLEX(*)}.
2512 @item @emph{Example}:
2515 complex :: z = (2.0, 3.0)
2516 complex(8) :: dz = (2.71_8, -3.14_8)
2521 end program test_conjg
2524 @item @emph{Specific names}:
2525 @multitable @columnfractions .20 .20 .20 .25
2526 @item Name @tab Argument @tab Return type @tab Standard
2527 @item @code{DCONJG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
2534 @section @code{COS} --- Cosine function
2540 @cindex trigonometric function, cosine
2544 @item @emph{Description}:
2545 @code{COS(X)} computes the cosine of @var{X}.
2547 @item @emph{Standard}:
2548 F77 and later, has overloads that are GNU extensions
2553 @item @emph{Syntax}:
2554 @code{RESULT = COS(X)}
2556 @item @emph{Arguments}:
2557 @multitable @columnfractions .15 .70
2558 @item @var{X} @tab The type shall be @code{REAL(*)} or
2562 @item @emph{Return value}:
2563 The return value is of type @code{REAL(*)} and it lies in the
2564 range @math{ -1 \leq \cos (x) \leq 1}. The kind type
2565 parameter is the same as @var{X}.
2567 @item @emph{Example}:
2572 end program test_cos
2575 @item @emph{Specific names}:
2576 @multitable @columnfractions .20 .20 .20 .25
2577 @item Name @tab Argument @tab Return type @tab Standard
2578 @item @code{DCOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
2579 @item @code{CCOS(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab F77 and later
2580 @item @code{ZCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
2581 @item @code{CDCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
2584 @item @emph{See also}:
2585 Inverse function: @ref{ACOS}
2592 @section @code{COSH} --- Hyperbolic cosine function
2595 @cindex hyperbolic cosine
2596 @cindex hyperbolic function, cosine
2597 @cindex cosine, hyperbolic
2600 @item @emph{Description}:
2601 @code{COSH(X)} computes the hyperbolic cosine of @var{X}.
2603 @item @emph{Standard}:
2609 @item @emph{Syntax}:
2612 @item @emph{Arguments}:
2613 @multitable @columnfractions .15 .70
2614 @item @var{X} @tab The type shall be @code{REAL(*)}.
2617 @item @emph{Return value}:
2618 The return value is of type @code{REAL(*)} and it is positive
2619 (@math{ \cosh (x) \geq 0 }.
2621 @item @emph{Example}:
2624 real(8) :: x = 1.0_8
2626 end program test_cosh
2629 @item @emph{Specific names}:
2630 @multitable @columnfractions .20 .20 .20 .25
2631 @item Name @tab Argument @tab Return type @tab Standard
2632 @item @code{DCOSH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
2635 @item @emph{See also}:
2636 Inverse function: @ref{ACOSH}
2643 @section @code{COUNT} --- Count function
2645 @cindex array, conditionally count elements
2646 @cindex array, element counting
2647 @cindex array, number of elements
2650 @item @emph{Description}:
2652 @code{COUNT(MASK [, DIM [, KIND]])} counts the number of @code{.TRUE.}
2653 elements of @var{MASK} along the dimension of @var{DIM}. If @var{DIM} is
2654 omitted it is taken to be @code{1}. @var{DIM} is a scaler of type
2655 @code{INTEGER} in the range of @math{1 /leq DIM /leq n)} where @math{n}
2656 is the rank of @var{MASK}.
2658 @item @emph{Standard}:
2662 Transformational function
2664 @item @emph{Syntax}:
2665 @code{RESULT = COUNT(MASK [, DIM [, KIND]])}
2667 @item @emph{Arguments}:
2668 @multitable @columnfractions .15 .70
2669 @item @var{MASK} @tab The type shall be @code{LOGICAL}.
2670 @item @var{DIM} @tab (Optional) The type shall be @code{INTEGER}.
2671 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
2672 expression indicating the kind parameter of
2676 @item @emph{Return value}:
2677 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
2678 @var{KIND} is absent, the return value is of default integer kind.
2679 The result has a rank equal to that of @var{MASK}.
2681 @item @emph{Example}:
2684 integer, dimension(2,3) :: a, b
2685 logical, dimension(2,3) :: mask
2686 a = reshape( (/ 1, 2, 3, 4, 5, 6 /), (/ 2, 3 /))
2687 b = reshape( (/ 0, 7, 3, 4, 5, 8 /), (/ 2, 3 /))
2688 print '(3i3)', a(1,:)
2689 print '(3i3)', a(2,:)
2691 print '(3i3)', b(1,:)
2692 print '(3i3)', b(2,:)
2695 print '(3l3)', mask(1,:)
2696 print '(3l3)', mask(2,:)
2698 print '(3i3)', count(mask)
2700 print '(3i3)', count(mask, 1)
2702 print '(3i3)', count(mask, 2)
2703 end program test_count
2710 @section @code{CPU_TIME} --- CPU elapsed time in seconds
2712 @cindex time, elapsed
2715 @item @emph{Description}:
2716 Returns a @code{REAL(*)} value representing the elapsed CPU time in
2717 seconds. This is useful for testing segments of code to determine
2720 @item @emph{Standard}:
2726 @item @emph{Syntax}:
2727 @code{CALL CPU_TIME(TIME)}
2729 @item @emph{Arguments}:
2730 @multitable @columnfractions .15 .70
2731 @item @var{TIME} @tab The type shall be @code{REAL(*)} with @code{INTENT(OUT)}.
2734 @item @emph{Return value}:
2737 @item @emph{Example}:
2739 program test_cpu_time
2740 real :: start, finish
2741 call cpu_time(start)
2742 ! put code to test here
2743 call cpu_time(finish)
2744 print '("Time = ",f6.3," seconds.")',finish-start
2745 end program test_cpu_time
2748 @item @emph{See also}:
2749 @ref{SYSTEM_CLOCK}, @ref{DATE_AND_TIME}
2755 @section @code{CSHIFT} --- Circular shift elements of an array
2757 @cindex array, shift circularly
2758 @cindex array, permutation
2759 @cindex array, rotate
2762 @item @emph{Description}:
2763 @code{CSHIFT(ARRAY, SHIFT [, DIM])} performs a circular shift on elements of
2764 @var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is omitted it is
2765 taken to be @code{1}. @var{DIM} is a scaler of type @code{INTEGER} in the
2766 range of @math{1 /leq DIM /leq n)} where @math{n} is the rank of @var{ARRAY}.
2767 If the rank of @var{ARRAY} is one, then all elements of @var{ARRAY} are shifted
2768 by @var{SHIFT} places. If rank is greater than one, then all complete rank one
2769 sections of @var{ARRAY} along the given dimension are shifted. Elements
2770 shifted out one end of each rank one section are shifted back in the other end.
2772 @item @emph{Standard}:
2776 Transformational function
2778 @item @emph{Syntax}:
2779 @code{RESULT = CSHIFT(ARRAY, SHIFT [, DIM])}
2781 @item @emph{Arguments}:
2782 @multitable @columnfractions .15 .70
2783 @item @var{ARRAY} @tab Shall be an array of any type.
2784 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
2785 @item @var{DIM} @tab The type shall be @code{INTEGER}.
2788 @item @emph{Return value}:
2789 Returns an array of same type and rank as the @var{ARRAY} argument.
2791 @item @emph{Example}:
2794 integer, dimension(3,3) :: a
2795 a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
2796 print '(3i3)', a(1,:)
2797 print '(3i3)', a(2,:)
2798 print '(3i3)', a(3,:)
2799 a = cshift(a, SHIFT=(/1, 2, -1/), DIM=2)
2801 print '(3i3)', a(1,:)
2802 print '(3i3)', a(2,:)
2803 print '(3i3)', a(3,:)
2804 end program test_cshift
2811 @section @code{CTIME} --- Convert a time into a string
2813 @cindex time, conversion to string
2814 @cindex conversion, to string
2817 @item @emph{Description}:
2818 @code{CTIME} converts a system time value, such as returned by
2819 @code{TIME8()}, to a string of the form @samp{Sat Aug 19 18:13:14 1995}.
2821 This intrinsic is provided in both subroutine and function forms; however,
2822 only one form can be used in any given program unit.
2824 @item @emph{Standard}:
2828 Subroutine, function
2830 @item @emph{Syntax}:
2831 @multitable @columnfractions .80
2832 @item @code{CALL CTIME(TIME, RESULT)}.
2833 @item @code{RESULT = CTIME(TIME)}, (not recommended).
2836 @item @emph{Arguments}:
2837 @multitable @columnfractions .15 .70
2838 @item @var{TIME} @tab The type shall be of type @code{INTEGER(KIND=8)}.
2839 @item @var{RESULT} @tab The type shall be of type @code{CHARACTER}.
2842 @item @emph{Return value}:
2843 The converted date and time as a string.
2845 @item @emph{Example}:
2849 character(len=30) :: date
2852 ! Do something, main part of the program
2855 print *, 'Program was started on ', date
2856 end program test_ctime
2859 @item @emph{See Also}:
2860 @ref{GMTIME}, @ref{LTIME}, @ref{TIME}, @ref{TIME8}
2866 @section @code{DATE_AND_TIME} --- Date and time subroutine
2867 @fnindex DATE_AND_TIME
2868 @cindex date, current
2869 @cindex current date
2870 @cindex time, current
2871 @cindex current time
2874 @item @emph{Description}:
2875 @code{DATE_AND_TIME(DATE, TIME, ZONE, VALUES)} gets the corresponding date and
2876 time information from the real-time system clock. @var{DATE} is
2877 @code{INTENT(OUT)} and has form ccyymmdd. @var{TIME} is @code{INTENT(OUT)} and
2878 has form hhmmss.sss. @var{ZONE} is @code{INTENT(OUT)} and has form (+-)hhmm,
2879 representing the difference with respect to Coordinated Universal Time (UTC).
2880 Unavailable time and date parameters return blanks.
2882 @var{VALUES} is @code{INTENT(OUT)} and provides the following:
2884 @multitable @columnfractions .15 .30 .40
2885 @item @tab @code{VALUE(1)}: @tab The year
2886 @item @tab @code{VALUE(2)}: @tab The month
2887 @item @tab @code{VALUE(3)}: @tab The day of the month
2888 @item @tab @code{VALUE(4)}: @tab Time difference with UTC in minutes
2889 @item @tab @code{VALUE(5)}: @tab The hour of the day
2890 @item @tab @code{VALUE(6)}: @tab The minutes of the hour
2891 @item @tab @code{VALUE(7)}: @tab The seconds of the minute
2892 @item @tab @code{VALUE(8)}: @tab The milliseconds of the second
2895 @item @emph{Standard}:
2901 @item @emph{Syntax}:
2902 @code{CALL DATE_AND_TIME([DATE, TIME, ZONE, VALUES])}
2904 @item @emph{Arguments}:
2905 @multitable @columnfractions .15 .70
2906 @item @var{DATE} @tab (Optional) The type shall be @code{CHARACTER(8)} or larger.
2907 @item @var{TIME} @tab (Optional) The type shall be @code{CHARACTER(10)} or larger.
2908 @item @var{ZONE} @tab (Optional) The type shall be @code{CHARACTER(5)} or larger.
2909 @item @var{VALUES}@tab (Optional) The type shall be @code{INTEGER(8)}.
2912 @item @emph{Return value}:
2915 @item @emph{Example}:
2917 program test_time_and_date
2918 character(8) :: date
2919 character(10) :: time
2920 character(5) :: zone
2921 integer,dimension(8) :: values
2922 ! using keyword arguments
2923 call date_and_time(date,time,zone,values)
2924 call date_and_time(DATE=date,ZONE=zone)
2925 call date_and_time(TIME=time)
2926 call date_and_time(VALUES=values)
2927 print '(a,2x,a,2x,a)', date, time, zone
2928 print '(8i5))', values
2929 end program test_time_and_date
2932 @item @emph{See also}:
2933 @ref{CPU_TIME}, @ref{SYSTEM_CLOCK}
2939 @section @code{DBLE} --- Double conversion function
2941 @cindex conversion, to real
2944 @item @emph{Description}:
2945 @code{DBLE(X)} Converts @var{X} to double precision real type.
2947 @item @emph{Standard}:
2953 @item @emph{Syntax}:
2954 @code{RESULT = DBLE(X)}
2956 @item @emph{Arguments}:
2957 @multitable @columnfractions .15 .70
2958 @item @var{X} @tab The type shall be @code{INTEGER(*)}, @code{REAL(*)},
2959 or @code{COMPLEX(*)}.
2962 @item @emph{Return value}:
2963 The return value is of type double precision real.
2965 @item @emph{Example}:
2970 complex :: z = (2.3,1.14)
2971 print *, dble(x), dble(i), dble(z)
2972 end program test_dble
2975 @item @emph{See also}:
2976 @ref{DFLOAT}, @ref{FLOAT}, @ref{REAL}
2982 @section @code{DCMPLX} --- Double complex conversion function
2984 @cindex complex numbers, conversion to
2985 @cindex conversion, to complex
2988 @item @emph{Description}:
2989 @code{DCMPLX(X [,Y])} returns a double complex number where @var{X} is
2990 converted to the real component. If @var{Y} is present it is converted to the
2991 imaginary component. If @var{Y} is not present then the imaginary component is
2992 set to 0.0. If @var{X} is complex then @var{Y} must not be present.
2994 @item @emph{Standard}:
3000 @item @emph{Syntax}:
3001 @code{RESULT = DCMPLX(X [, Y])}
3003 @item @emph{Arguments}:
3004 @multitable @columnfractions .15 .70
3005 @item @var{X} @tab The type may be @code{INTEGER(*)}, @code{REAL(*)},
3006 or @code{COMPLEX(*)}.
3007 @item @var{Y} @tab (Optional if @var{X} is not @code{COMPLEX(*)}.) May be
3008 @code{INTEGER(*)} or @code{REAL(*)}.
3011 @item @emph{Return value}:
3012 The return value is of type @code{COMPLEX(8)}
3014 @item @emph{Example}:
3024 print *, dcmplx(x,i)
3025 end program test_dcmplx
3032 @section @code{DFLOAT} --- Double conversion function
3034 @cindex conversion, to real
3037 @item @emph{Description}:
3038 @code{DFLOAT(X)} Converts @var{X} to double precision real type.
3040 @item @emph{Standard}:
3046 @item @emph{Syntax}:
3047 @code{RESULT = DFLOAT(X)}
3049 @item @emph{Arguments}:
3050 @multitable @columnfractions .15 .70
3051 @item @var{X} @tab The type shall be @code{INTEGER(*)}.
3054 @item @emph{Return value}:
3055 The return value is of type double precision real.
3057 @item @emph{Example}:
3062 end program test_dfloat
3065 @item @emph{See also}:
3066 @ref{DBLE}, @ref{FLOAT}, @ref{REAL}
3072 @section @code{DIGITS} --- Significant digits function
3074 @cindex model representation, significant digits
3077 @item @emph{Description}:
3078 @code{DIGITS(X)} returns the number of significant digits of the internal model
3079 representation of @var{X}. For example, on a system using a 32-bit
3080 floating point representation, a default real number would likely return 24.
3082 @item @emph{Standard}:
3088 @item @emph{Syntax}:
3089 @code{RESULT = DIGITS(X)}
3091 @item @emph{Arguments}:
3092 @multitable @columnfractions .15 .70
3093 @item @var{X} @tab The type may be @code{INTEGER(*)} or @code{REAL(*)}.
3096 @item @emph{Return value}:
3097 The return value is of type @code{INTEGER}.
3099 @item @emph{Example}:
3102 integer :: i = 12345
3108 end program test_digits
3115 @section @code{DIM} --- Positive difference
3119 @cindex positive difference
3122 @item @emph{Description}:
3123 @code{DIM(X,Y)} returns the difference @code{X-Y} if the result is positive;
3124 otherwise returns zero.
3126 @item @emph{Standard}:
3132 @item @emph{Syntax}:
3133 @code{RESULT = DIM(X, Y)}
3135 @item @emph{Arguments}:
3136 @multitable @columnfractions .15 .70
3137 @item @var{X} @tab The type shall be @code{INTEGER(*)} or @code{REAL(*)}
3138 @item @var{Y} @tab The type shall be the same type and kind as @var{X}.
3141 @item @emph{Return value}:
3142 The return value is of type @code{INTEGER(*)} or @code{REAL(*)}.
3144 @item @emph{Example}:
3150 x = dim(4.345_8, 2.111_8)
3153 end program test_dim
3156 @item @emph{Specific names}:
3157 @multitable @columnfractions .20 .20 .20 .25
3158 @item Name @tab Argument @tab Return type @tab Standard
3159 @item @code{IDIM(X,Y)} @tab @code{INTEGER(4) X,Y} @tab @code{INTEGER(4)} @tab F77 and later
3160 @item @code{DDIM(X,Y)} @tab @code{REAL(8) X,Y} @tab @code{REAL(8)} @tab F77 and later
3167 @section @code{DOT_PRODUCT} --- Dot product function
3168 @fnindex DOT_PRODUCT
3170 @cindex vector product
3171 @cindex product, vector
3174 @item @emph{Description}:
3175 @code{DOT_PRODUCT(X,Y)} computes the dot product multiplication of two vectors
3176 @var{X} and @var{Y}. The two vectors may be either numeric or logical
3177 and must be arrays of rank one and of equal size. If the vectors are
3178 @code{INTEGER(*)} or @code{REAL(*)}, the result is @code{SUM(X*Y)}. If the
3179 vectors are @code{COMPLEX(*)}, the result is @code{SUM(CONJG(X)*Y)}. If the
3180 vectors are @code{LOGICAL}, the result is @code{ANY(X.AND.Y)}.
3182 @item @emph{Standard}:
3186 Transformational function
3188 @item @emph{Syntax}:
3189 @code{RESULT = DOT_PRODUCT(X, Y)}
3191 @item @emph{Arguments}:
3192 @multitable @columnfractions .15 .70
3193 @item @var{X} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
3194 @item @var{Y} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
3197 @item @emph{Return value}:
3198 If the arguments are numeric, the return value is a scaler of numeric type,
3199 @code{INTEGER(*)}, @code{REAL(*)}, or @code{COMPLEX(*)}. If the arguments are
3200 @code{LOGICAL}, the return value is @code{.TRUE.} or @code{.FALSE.}.
3202 @item @emph{Example}:
3204 program test_dot_prod
3205 integer, dimension(3) :: a, b
3212 print *, dot_product(a,b)
3213 end program test_dot_prod
3220 @section @code{DPROD} --- Double product function
3222 @cindex product, double-precision
3225 @item @emph{Description}:
3226 @code{DPROD(X,Y)} returns the product @code{X*Y}.
3228 @item @emph{Standard}:
3234 @item @emph{Syntax}:
3235 @code{RESULT = DPROD(X, Y)}
3237 @item @emph{Arguments}:
3238 @multitable @columnfractions .15 .70
3239 @item @var{X} @tab The type shall be @code{REAL}.
3240 @item @var{Y} @tab The type shall be @code{REAL}.
3243 @item @emph{Return value}:
3244 The return value is of type @code{REAL(8)}.
3246 @item @emph{Example}:
3254 end program test_dprod
3261 @section @code{DREAL} --- Double real part function
3263 @cindex complex numbers, real part
3266 @item @emph{Description}:
3267 @code{DREAL(Z)} returns the real part of complex variable @var{Z}.
3269 @item @emph{Standard}:
3275 @item @emph{Syntax}:
3276 @code{RESULT = DREAL(Z)}
3278 @item @emph{Arguments}:
3279 @multitable @columnfractions .15 .70
3280 @item @var{Z} @tab The type shall be @code{COMPLEX(8)}.
3283 @item @emph{Return value}:
3284 The return value is of type @code{REAL(8)}.
3286 @item @emph{Example}:
3289 complex(8) :: z = (1.3_8,7.2_8)
3291 end program test_dreal
3294 @item @emph{See also}:
3302 @section @code{DTIME} --- Execution time subroutine (or function)
3304 @cindex time, elapsed
3305 @cindex elapsed time
3308 @item @emph{Description}:
3309 @code{DTIME(TARRAY, RESULT)} initially returns the number of seconds of runtime
3310 since the start of the process's execution in @var{RESULT}. @var{TARRAY}
3311 returns the user and system components of this time in @code{TARRAY(1)} and
3312 @code{TARRAY(2)} respectively. @var{RESULT} is equal to @code{TARRAY(1) +
3315 Subsequent invocations of @code{DTIME} return values accumulated since the
3316 previous invocation.
3318 On some systems, the underlying timings are represented using types with
3319 sufficiently small limits that overflows (wrap around) are possible, such as
3320 32-bit types. Therefore, the values returned by this intrinsic might be, or
3321 become, negative, or numerically less than previous values, during a single
3322 run of the compiled program.
3324 This intrinsic is provided in both subroutine and function forms; however,
3325 only one form can be used in any given program unit.
3327 @var{TARRAY} and @var{RESULT} are @code{INTENT(OUT)} and provide the following:
3329 @multitable @columnfractions .15 .30 .40
3330 @item @tab @code{TARRAY(1)}: @tab User time in seconds.
3331 @item @tab @code{TARRAY(2)}: @tab System time in seconds.
3332 @item @tab @code{RESULT}: @tab Run time since start in seconds.
3335 @item @emph{Standard}:
3339 Subroutine, function
3341 @item @emph{Syntax}:
3342 @multitable @columnfractions .80
3343 @item @code{CALL DTIME(TARRAY, RESULT)}.
3344 @item @code{RESULT = DTIME(TARRAY)}, (not recommended).
3347 @item @emph{Arguments}:
3348 @multitable @columnfractions .15 .70
3349 @item @var{TARRAY}@tab The type shall be @code{REAL, DIMENSION(2)}.
3350 @item @var{RESULT}@tab The type shall be @code{REAL}.
3353 @item @emph{Return value}:
3354 Elapsed time in seconds since the start of program execution.
3356 @item @emph{Example}:
3360 real, dimension(2) :: tarray
3362 call dtime(tarray, result)
3366 do i=1,100000000 ! Just a delay
3369 call dtime(tarray, result)
3373 end program test_dtime
3380 @section @code{EOSHIFT} --- End-off shift elements of an array
3382 @cindex array, shift
3385 @item @emph{Description}:
3386 @code{EOSHIFT(ARRAY, SHIFT[,BOUNDARY, DIM])} performs an end-off shift on
3387 elements of @var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is
3388 omitted it is taken to be @code{1}. @var{DIM} is a scaler of type
3389 @code{INTEGER} in the range of @math{1 /leq DIM /leq n)} where @math{n} is the
3390 rank of @var{ARRAY}. If the rank of @var{ARRAY} is one, then all elements of
3391 @var{ARRAY} are shifted by @var{SHIFT} places. If rank is greater than one,
3392 then all complete rank one sections of @var{ARRAY} along the given dimension are
3393 shifted. Elements shifted out one end of each rank one section are dropped. If
3394 @var{BOUNDARY} is present then the corresponding value of from @var{BOUNDARY}
3395 is copied back in the other end. If @var{BOUNDARY} is not present then the
3396 following are copied in depending on the type of @var{ARRAY}.
3398 @multitable @columnfractions .15 .80
3399 @item @emph{Array Type} @tab @emph{Boundary Value}
3400 @item Numeric @tab 0 of the type and kind of @var{ARRAY}.
3401 @item Logical @tab @code{.FALSE.}.
3402 @item Character(@var{len}) @tab @var{len} blanks.
3405 @item @emph{Standard}:
3409 Transformational function
3411 @item @emph{Syntax}:
3412 @code{RESULT = EOSHIFT(ARRAY, SHIFT [, BOUNDARY, DIM])}
3414 @item @emph{Arguments}:
3415 @multitable @columnfractions .15 .70
3416 @item @var{ARRAY} @tab May be any type, not scaler.
3417 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
3418 @item @var{BOUNDARY} @tab Same type as @var{ARRAY}.
3419 @item @var{DIM} @tab The type shall be @code{INTEGER}.
3422 @item @emph{Return value}:
3423 Returns an array of same type and rank as the @var{ARRAY} argument.
3425 @item @emph{Example}:
3427 program test_eoshift
3428 integer, dimension(3,3) :: a
3429 a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
3430 print '(3i3)', a(1,:)
3431 print '(3i3)', a(2,:)
3432 print '(3i3)', a(3,:)
3433 a = EOSHIFT(a, SHIFT=(/1, 2, 1/), BOUNDARY=-5, DIM=2)
3435 print '(3i3)', a(1,:)
3436 print '(3i3)', a(2,:)
3437 print '(3i3)', a(3,:)
3438 end program test_eoshift
3445 @section @code{EPSILON} --- Epsilon function
3447 @cindex model representation, epsilon
3450 @item @emph{Description}:
3451 @code{EPSILON(X)} returns a nearly negligible number relative to @code{1}.
3453 @item @emph{Standard}:
3459 @item @emph{Syntax}:
3460 @code{RESULT = EPSILON(X)}
3462 @item @emph{Arguments}:
3463 @multitable @columnfractions .15 .70
3464 @item @var{X} @tab The type shall be @code{REAL(*)}.
3467 @item @emph{Return value}:
3468 The return value is of same type as the argument.
3470 @item @emph{Example}:
3472 program test_epsilon
3477 end program test_epsilon
3484 @section @code{ERF} --- Error function
3486 @cindex error function
3489 @item @emph{Description}:
3490 @code{ERF(X)} computes the error function of @var{X}.
3492 @item @emph{Standard}:
3498 @item @emph{Syntax}:
3499 @code{RESULT = ERF(X)}
3501 @item @emph{Arguments}:
3502 @multitable @columnfractions .15 .70
3503 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
3506 @item @emph{Return value}:
3507 The return value is a scalar of type @code{REAL(*)} and it is positive
3508 (@math{ - 1 \leq erf (x) \leq 1 }.
3510 @item @emph{Example}:
3513 real(8) :: x = 0.17_8
3515 end program test_erf
3518 @item @emph{Specific names}:
3519 @multitable @columnfractions .20 .20 .20 .25
3520 @item Name @tab Argument @tab Return type @tab Standard
3521 @item @code{DERF(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
3528 @section @code{ERFC} --- Error function
3530 @cindex error function, complementary
3533 @item @emph{Description}:
3534 @code{ERFC(X)} computes the complementary error function of @var{X}.
3536 @item @emph{Standard}:
3542 @item @emph{Syntax}:
3543 @code{RESULT = ERFC(X)}
3545 @item @emph{Arguments}:
3546 @multitable @columnfractions .15 .70
3547 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
3550 @item @emph{Return value}:
3551 The return value is a scalar of type @code{REAL(*)} and it is positive
3552 (@math{ 0 \leq erfc (x) \leq 2 }.
3554 @item @emph{Example}:
3557 real(8) :: x = 0.17_8
3559 end program test_erfc
3562 @item @emph{Specific names}:
3563 @multitable @columnfractions .20 .20 .20 .25
3564 @item Name @tab Argument @tab Return type @tab Standard
3565 @item @code{DERFC(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
3572 @section @code{ETIME} --- Execution time subroutine (or function)
3574 @cindex time, elapsed
3577 @item @emph{Description}:
3578 @code{ETIME(TARRAY, RESULT)} returns the number of seconds of runtime
3579 since the start of the process's execution in @var{RESULT}. @var{TARRAY}
3580 returns the user and system components of this time in @code{TARRAY(1)} and
3581 @code{TARRAY(2)} respectively. @var{RESULT} is equal to @code{TARRAY(1) + TARRAY(2)}.
3583 On some systems, the underlying timings are represented using types with
3584 sufficiently small limits that overflows (wrap around) are possible, such as
3585 32-bit types. Therefore, the values returned by this intrinsic might be, or
3586 become, negative, or numerically less than previous values, during a single
3587 run of the compiled program.
3589 This intrinsic is provided in both subroutine and function forms; however,
3590 only one form can be used in any given program unit.
3592 @var{TARRAY} and @var{RESULT} are @code{INTENT(OUT)} and provide the following:
3594 @multitable @columnfractions .15 .30 .60
3595 @item @tab @code{TARRAY(1)}: @tab User time in seconds.
3596 @item @tab @code{TARRAY(2)}: @tab System time in seconds.
3597 @item @tab @code{RESULT}: @tab Run time since start in seconds.
3600 @item @emph{Standard}:
3604 Subroutine, function
3606 @item @emph{Syntax}:
3607 @multitable @columnfractions .80
3608 @item @code{CALL ETIME(TARRAY, RESULT)}.
3609 @item @code{RESULT = ETIME(TARRAY)}, (not recommended).
3612 @item @emph{Arguments}:
3613 @multitable @columnfractions .15 .70
3614 @item @var{TARRAY}@tab The type shall be @code{REAL, DIMENSION(2)}.
3615 @item @var{RESULT}@tab The type shall be @code{REAL}.
3618 @item @emph{Return value}:
3619 Elapsed time in seconds since the start of program execution.
3621 @item @emph{Example}:
3625 real, dimension(2) :: tarray
3627 call ETIME(tarray, result)
3631 do i=1,100000000 ! Just a delay
3634 call ETIME(tarray, result)
3638 end program test_etime
3641 @item @emph{See also}:
3649 @section @code{EXIT} --- Exit the program with status.
3651 @cindex program termination
3652 @cindex terminate program
3655 @item @emph{Description}:
3656 @code{EXIT} causes immediate termination of the program with status. If status
3657 is omitted it returns the canonical @emph{success} for the system. All Fortran
3658 I/O units are closed.
3660 @item @emph{Standard}:
3666 @item @emph{Syntax}:
3667 @code{CALL EXIT([STATUS])}
3669 @item @emph{Arguments}:
3670 @multitable @columnfractions .15 .70
3671 @item @var{STATUS} @tab Shall be an @code{INTEGER} of the default kind.
3674 @item @emph{Return value}:
3675 @code{STATUS} is passed to the parent process on exit.
3677 @item @emph{Example}:
3680 integer :: STATUS = 0
3681 print *, 'This program is going to exit.'
3683 end program test_exit
3686 @item @emph{See also}:
3687 @ref{ABORT}, @ref{KILL}
3693 @section @code{EXP} --- Exponential function
3699 @cindex exponential function
3700 @cindex logarithmic function, inverse
3703 @item @emph{Description}:
3704 @code{EXP(X)} computes the base @math{e} exponential of @var{X}.
3706 @item @emph{Standard}:
3707 F77 and later, has overloads that are GNU extensions
3712 @item @emph{Syntax}:
3713 @code{RESULT = EXP(X)}
3715 @item @emph{Arguments}:
3716 @multitable @columnfractions .15 .70
3717 @item @var{X} @tab The type shall be @code{REAL(*)} or
3721 @item @emph{Return value}:
3722 The return value has same type and kind as @var{X}.
3724 @item @emph{Example}:
3729 end program test_exp
3732 @item @emph{Specific names}:
3733 @multitable @columnfractions .20 .20 .20 .25
3734 @item Name @tab Argument @tab Return type @tab Standard
3735 @item @code{DEXP(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
3736 @item @code{CEXP(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab F77 and later
3737 @item @code{ZEXP(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
3738 @item @code{CDEXP(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
3745 @section @code{EXPONENT} --- Exponent function
3747 @cindex real number, exponent
3748 @cindex floating point, exponent
3751 @item @emph{Description}:
3752 @code{EXPONENT(X)} returns the value of the exponent part of @var{X}. If @var{X}
3753 is zero the value returned is zero.
3755 @item @emph{Standard}:
3761 @item @emph{Syntax}:
3762 @code{RESULT = EXPONENT(X)}
3764 @item @emph{Arguments}:
3765 @multitable @columnfractions .15 .70
3766 @item @var{X} @tab The type shall be @code{REAL(*)}.
3769 @item @emph{Return value}:
3770 The return value is of type default @code{INTEGER}.
3772 @item @emph{Example}:
3774 program test_exponent
3779 print *, exponent(0.0)
3780 end program test_exponent
3787 @section @code{FDATE} --- Get the current time as a string
3789 @cindex time, current
3790 @cindex current time
3791 @cindex date, current
3792 @cindex current date
3795 @item @emph{Description}:
3796 @code{FDATE(DATE)} returns the current date (using the same format as
3797 @code{CTIME}) in @var{DATE}. It is equivalent to @code{CALL CTIME(DATE,
3800 This intrinsic is provided in both subroutine and function forms; however,
3801 only one form can be used in any given program unit.
3803 @var{DATE} is an @code{INTENT(OUT)} @code{CHARACTER} variable.
3805 @item @emph{Standard}:
3809 Subroutine, function
3811 @item @emph{Syntax}:
3812 @multitable @columnfractions .80
3813 @item @code{CALL FDATE(DATE)}.
3814 @item @code{DATE = FDATE()}, (not recommended).
3817 @item @emph{Arguments}:
3818 @multitable @columnfractions .15 .70
3819 @item @var{DATE}@tab The type shall be of type @code{CHARACTER}.
3822 @item @emph{Return value}:
3823 The current date as a string.
3825 @item @emph{Example}:
3829 character(len=30) :: date
3831 print *, 'Program started on ', date
3832 do i = 1, 100000000 ! Just a delay
3836 print *, 'Program ended on ', date
3837 end program test_fdate
3844 @section @code{FLOAT} --- Convert integer to default real
3846 @cindex conversion, to real
3849 @item @emph{Description}:
3850 @code{FLOAT(I)} converts the integer @var{I} to a default real value.
3852 @item @emph{Standard}:
3858 @item @emph{Syntax}:
3859 @code{RESULT = FLOAT(I)}
3861 @item @emph{Arguments}:
3862 @multitable @columnfractions .15 .70
3863 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
3866 @item @emph{Return value}:
3867 The return value is of type default @code{REAL}.
3869 @item @emph{Example}:
3873 if (float(i) /= 1.) call abort
3874 end program test_float
3877 @item @emph{See also}:
3878 @ref{DBLE}, @ref{DFLOAT}, @ref{REAL}
3884 @section @code{FGET} --- Read a single character in stream mode from stdin
3886 @cindex read character, stream mode
3887 @cindex stream mode, read character
3888 @cindex file operation, read character
3891 @item @emph{Description}:
3892 Read a single character in stream mode from stdin by bypassing normal
3893 formatted output. Stream I/O should not be mixed with normal record-oriented
3894 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
3896 This intrinsic is provided in both subroutine and function forms; however,
3897 only one form can be used in any given program unit.
3899 Note that the @code{FGET} intrinsic is provided for backwards compatibility with
3900 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
3901 Programmers should consider the use of new stream IO feature in new code
3902 for future portability. See also @ref{Fortran 2003 status}.
3904 @item @emph{Standard}:
3908 Subroutine, function
3910 @item @emph{Syntax}:
3911 @code{CALL FGET(C [, STATUS])}
3913 @item @emph{Arguments}:
3914 @multitable @columnfractions .15 .70
3915 @item @var{C} @tab The type shall be @code{CHARACTER}.
3916 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
3917 Returns 0 on success, -1 on end-of-file, and a
3918 system specific positive error code otherwise.
3921 @item @emph{Example}:
3924 INTEGER, PARAMETER :: strlen = 100
3925 INTEGER :: status, i = 1
3926 CHARACTER(len=strlen) :: str = ""
3928 WRITE (*,*) 'Enter text:'
3930 CALL fget(str(i:i), status)
3931 if (status /= 0 .OR. i > strlen) exit
3934 WRITE (*,*) TRIM(str)
3938 @item @emph{See also}:
3939 @ref{FGETC}, @ref{FPUT}, @ref{FPUTC}
3945 @section @code{FGETC} --- Read a single character in stream mode
3947 @cindex read character, stream mode
3948 @cindex stream mode, read character
3949 @cindex file operation, read character
3952 @item @emph{Description}:
3953 Read a single character in stream mode by bypassing normal formatted output.
3954 Stream I/O should not be mixed with normal record-oriented (formatted or
3955 unformatted) I/O on the same unit; the results are unpredictable.
3957 This intrinsic is provided in both subroutine and function forms; however,
3958 only one form can be used in any given program unit.
3960 Note that the @code{FGET} intrinsic is provided for backwards compatibility
3961 with @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
3962 Programmers should consider the use of new stream IO feature in new code
3963 for future portability. See also @ref{Fortran 2003 status}.
3965 @item @emph{Standard}:
3969 Subroutine, function
3971 @item @emph{Syntax}:
3972 @code{CALL FGETC(UNIT, C [, STATUS])}
3974 @item @emph{Arguments}:
3975 @multitable @columnfractions .15 .70
3976 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
3977 @item @var{C} @tab The type shall be @code{CHARACTER}.
3978 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. Returns 0 on success,
3979 -1 on end-of-file and a system specific positive error code otherwise.
3982 @item @emph{Example}:
3985 INTEGER :: fd = 42, status
3988 OPEN(UNIT=fd, FILE="/etc/passwd", ACTION="READ", STATUS = "OLD")
3990 CALL fgetc(fd, c, status)
3991 IF (status /= 0) EXIT
3998 @item @emph{See also}:
3999 @ref{FGET}, @ref{FPUT}, @ref{FPUTC}
4005 @section @code{FLOOR} --- Integer floor function
4008 @cindex rounding, floor
4011 @item @emph{Description}:
4012 @code{FLOOR(X)} returns the greatest integer less than or equal to @var{X}.
4014 @item @emph{Standard}:
4020 @item @emph{Syntax}:
4021 @code{RESULT = FLOOR(X [, KIND])}
4023 @item @emph{Arguments}:
4024 @multitable @columnfractions .15 .70
4025 @item @var{X} @tab The type shall be @code{REAL(*)}.
4026 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
4027 expression indicating the kind parameter of
4031 @item @emph{Return value}:
4032 The return value is of type @code{INTEGER(KIND)}
4034 @item @emph{Example}:
4039 print *, floor(x) ! returns 63
4040 print *, floor(y) ! returns -64
4041 end program test_floor
4044 @item @emph{See also}:
4045 @ref{CEILING}, @ref{NINT}
4052 @section @code{FLUSH} --- Flush I/O unit(s)
4054 @cindex file operation, flush
4057 @item @emph{Description}:
4058 Flushes Fortran unit(s) currently open for output. Without the optional
4059 argument, all units are flushed, otherwise just the unit specified.
4061 @item @emph{Standard}:
4067 @item @emph{Syntax}:
4068 @code{CALL FLUSH(UNIT)}
4070 @item @emph{Arguments}:
4071 @multitable @columnfractions .15 .70
4072 @item @var{UNIT} @tab (Optional) The type shall be @code{INTEGER}.
4076 Beginning with the Fortran 2003 standard, there is a @code{FLUSH}
4077 statement that should be preferred over the @code{FLUSH} intrinsic.
4084 @section @code{FNUM} --- File number function
4086 @cindex file operation, file number
4089 @item @emph{Description}:
4090 @code{FNUM(UNIT)} returns the POSIX file descriptor number corresponding to the
4091 open Fortran I/O unit @code{UNIT}.
4093 @item @emph{Standard}:
4099 @item @emph{Syntax}:
4100 @code{RESULT = FNUM(UNIT)}
4102 @item @emph{Arguments}:
4103 @multitable @columnfractions .15 .70
4104 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
4107 @item @emph{Return value}:
4108 The return value is of type @code{INTEGER}
4110 @item @emph{Example}:
4114 open (unit=10, status = "scratch")
4118 end program test_fnum
4125 @section @code{FPUT} --- Write a single character in stream mode to stdout
4127 @cindex write character, stream mode
4128 @cindex stream mode, write character
4129 @cindex file operation, write character
4132 @item @emph{Description}:
4133 Write a single character in stream mode to stdout by bypassing normal
4134 formatted output. Stream I/O should not be mixed with normal record-oriented
4135 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
4137 This intrinsic is provided in both subroutine and function forms; however,
4138 only one form can be used in any given program unit.
4140 Note that the @code{FGET} intrinsic is provided for backwards compatibility with
4141 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
4142 Programmers should consider the use of new stream IO feature in new code
4143 for future portability. See also @ref{Fortran 2003 status}.
4145 @item @emph{Standard}:
4149 Subroutine, function
4151 @item @emph{Syntax}:
4152 @code{CALL FPUT(C [, STATUS])}
4154 @item @emph{Arguments}:
4155 @multitable @columnfractions .15 .70
4156 @item @var{C} @tab The type shall be @code{CHARACTER}.
4157 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. Returns 0 on success,
4158 -1 on end-of-file and a system specific positive error code otherwise.
4161 @item @emph{Example}:
4164 CHARACTER(len=10) :: str = "gfortran"
4166 DO i = 1, len_trim(str)
4172 @item @emph{See also}:
4173 @ref{FPUTC}, @ref{FGET}, @ref{FGETC}
4179 @section @code{FPUTC} --- Write a single character in stream mode
4181 @cindex write character, stream mode
4182 @cindex stream mode, write character
4183 @cindex file operation, write character
4186 @item @emph{Description}:
4187 Write a single character in stream mode by bypassing normal formatted
4188 output. Stream I/O should not be mixed with normal record-oriented
4189 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
4191 This intrinsic is provided in both subroutine and function forms; however,
4192 only one form can be used in any given program unit.
4194 Note that the @code{FGET} intrinsic is provided for backwards compatibility with
4195 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
4196 Programmers should consider the use of new stream IO feature in new code
4197 for future portability. See also @ref{Fortran 2003 status}.
4199 @item @emph{Standard}:
4203 Subroutine, function
4205 @item @emph{Syntax}:
4206 @code{CALL FPUTC(UNIT, C [, STATUS])}
4208 @item @emph{Arguments}:
4209 @multitable @columnfractions .15 .70
4210 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
4211 @item @var{C} @tab The type shall be @code{CHARACTER}.
4212 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. Returns 0 on success,
4213 -1 on end-of-file and a system specific positive error code otherwise.
4216 @item @emph{Example}:
4219 CHARACTER(len=10) :: str = "gfortran"
4220 INTEGER :: fd = 42, i
4222 OPEN(UNIT = fd, FILE = "out", ACTION = "WRITE", STATUS="NEW")
4223 DO i = 1, len_trim(str)
4224 CALL fputc(fd, str(i:i))
4230 @item @emph{See also}:
4231 @ref{FPUT}, @ref{FGET}, @ref{FGETC}
4237 @section @code{FRACTION} --- Fractional part of the model representation
4239 @cindex real number, fraction
4240 @cindex floating point, fraction
4243 @item @emph{Description}:
4244 @code{FRACTION(X)} returns the fractional part of the model
4245 representation of @code{X}.
4247 @item @emph{Standard}:
4253 @item @emph{Syntax}:
4254 @code{Y = FRACTION(X)}
4256 @item @emph{Arguments}:
4257 @multitable @columnfractions .15 .70
4258 @item @var{X} @tab The type of the argument shall be a @code{REAL}.
4261 @item @emph{Return value}:
4262 The return value is of the same type and kind as the argument.
4263 The fractional part of the model representation of @code{X} is returned;
4264 it is @code{X * RADIX(X)**(-EXPONENT(X))}.
4266 @item @emph{Example}:
4268 program test_fraction
4271 print *, fraction(x), x * radix(x)**(-exponent(x))
4272 end program test_fraction
4280 @section @code{FREE} --- Frees memory
4282 @cindex pointer, cray
4285 @item @emph{Description}:
4286 Frees memory previously allocated by @code{MALLOC()}. The @code{FREE}
4287 intrinsic is an extension intended to be used with Cray pointers, and is
4288 provided in GNU Fortran to allow user to compile legacy code. For
4289 new code using Fortran 95 pointers, the memory de-allocation intrinsic is
4292 @item @emph{Standard}:
4298 @item @emph{Syntax}:
4299 @code{CALL FREE(PTR)}
4301 @item @emph{Arguments}:
4302 @multitable @columnfractions .15 .70
4303 @item @var{PTR} @tab The type shall be @code{INTEGER}. It represents the
4304 location of the memory that should be de-allocated.
4307 @item @emph{Return value}:
4310 @item @emph{Example}:
4311 See @code{MALLOC} for an example.
4313 @item @emph{See also}:
4320 @section @code{FSEEK} --- Low level file positioning subroutine
4322 @cindex file operation, seek
4323 @cindex file operation, position
4326 @item @emph{Description}:
4327 Moves @var{UNIT} to the specified @var{OFFSET}. If @var{WHENCE}
4328 is set to 0, the @var{OFFSET} is taken as an absolute value @code{SEEK_SET},
4329 if set to 1, @var{OFFSET} is taken to be relative to the current position
4330 @code{SEEK_CUR}, and if set to 2 relative to the end of the file @code{SEEK_END}.
4331 On error, @var{STATUS} is set to a nonzero value. If @var{STATUS} the seek
4334 This intrinsic routine is not fully backwards compatible with @command{g77}.
4335 In @command{g77}, the @code{FSEEK} takes a statement label instead of a
4336 @var{STATUS} variable. If FSEEK is used in old code, change
4338 CALL FSEEK(UNIT, OFFSET, WHENCE, *label)
4343 CALL FSEEK(UNIT, OFFSET, WHENCE, status)
4344 IF (status /= 0) GOTO label
4347 Please note that GNU Fortran provides the Fortran 2003 Stream facility.
4348 Programmers should consider the use of new stream IO feature in new code
4349 for future portability. See also @ref{Fortran 2003 status}.
4351 @item @emph{Standard}:
4357 @item @emph{Syntax}:
4358 @code{CALL FSEEK(UNIT, OFFSET, WHENCE[, STATUS])}
4360 @item @emph{Arguments}:
4361 @multitable @columnfractions .15 .70
4362 @item @var{UNIT} @tab Shall be a scalar of type @code{INTEGER}.
4363 @item @var{OFFSET} @tab Shall be a scalar of type @code{INTEGER}.
4364 @item @var{WHENCE} @tab Shall be a scalar of type @code{INTEGER}.
4365 Its value shall be either 0, 1 or 2.
4366 @item @var{STATUS} @tab (Optional) shall be a scalar of type
4370 @item @emph{Example}:
4373 INTEGER, PARAMETER :: SEEK_SET = 0, SEEK_CUR = 1, SEEK_END = 2
4374 INTEGER :: fd, offset, ierr
4380 OPEN(UNIT=fd, FILE="fseek.test")
4381 CALL FSEEK(fd, offset, SEEK_SET, ierr) ! move to OFFSET
4382 print *, FTELL(fd), ierr
4384 CALL FSEEK(fd, 0, SEEK_END, ierr) ! move to end
4385 print *, FTELL(fd), ierr
4387 CALL FSEEK(fd, 0, SEEK_SET, ierr) ! move to beginning
4388 print *, FTELL(fd), ierr
4394 @item @emph{See also}:
4401 @section @code{FSTAT} --- Get file status
4403 @cindex file system, file status
4406 @item @emph{Description}:
4407 @code{FSTAT} is identical to @ref{STAT}, except that information about an
4408 already opened file is obtained.
4410 The elements in @code{BUFF} are the same as described by @ref{STAT}.
4412 This intrinsic is provided in both subroutine and function forms; however,
4413 only one form can be used in any given program unit.
4415 @item @emph{Standard}:
4419 Subroutine, function
4421 @item @emph{Syntax}:
4422 @code{CALL FSTAT(UNIT, BUFF [, STATUS])}
4424 @item @emph{Arguments}:
4425 @multitable @columnfractions .15 .70
4426 @item @var{UNIT} @tab An open I/O unit number of type @code{INTEGER}.
4427 @item @var{BUFF} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
4428 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0
4429 on success and a system specific error code otherwise.
4432 @item @emph{Example}:
4433 See @ref{STAT} for an example.
4435 @item @emph{See also}:
4436 To stat a link: @ref{LSTAT}, to stat a file: @ref{STAT}
4442 @section @code{FTELL} --- Current stream position
4444 @cindex file operation, position
4447 @item @emph{Description}:
4448 Retrieves the current position within an open file.
4450 This intrinsic is provided in both subroutine and function forms; however,
4451 only one form can be used in any given program unit.
4453 @item @emph{Standard}:
4457 Subroutine, function
4459 @item @emph{Syntax}:
4460 @multitable @columnfractions .80
4461 @item @code{CALL FTELL(UNIT, OFFSET)}
4462 @item @code{OFFSET = FTELL(UNIT)}
4465 @item @emph{Arguments}:
4466 @multitable @columnfractions .15 .70
4467 @item @var{OFFSET} @tab Shall of type @code{INTEGER}.
4468 @item @var{UNIT} @tab Shall of type @code{INTEGER}.
4471 @item @emph{Return value}:
4472 In either syntax, @var{OFFSET} is set to the current offset of unit
4473 number @var{UNIT}, or to @math{-1} if the unit is not currently open.
4475 @item @emph{Example}:
4479 OPEN(10, FILE="temp.dat")
4485 @item @emph{See also}:
4492 @section @code{GAMMA} --- Gamma function
4495 @cindex Gamma function
4496 @cindex Factorial function
4499 @item @emph{Description}:
4500 @code{GAMMA(X)} computes Gamma (@math{\Gamma}) of @var{X}. For positive,
4501 integer values of @var{X} the Gamma function simplifies to the factorial
4502 function @math{\Gamma(x)=(x-1)!}.
4506 \Gamma(x) = \int_0^\infty t^{x-1}{\rm e}^{-t}\,{\rm d}t
4510 @item @emph{Standard}:
4516 @item @emph{Syntax}:
4519 @item @emph{Arguments}:
4520 @multitable @columnfractions .15 .70
4521 @item @var{X} @tab Shall be of type @code{REAL} and neither zero
4522 nor a negative integer.
4525 @item @emph{Return value}:
4526 The return value is of type @code{REAL} of the same kind as @var{X}.
4528 @item @emph{Example}:
4532 x = gamma(x) ! returns 1.0
4533 end program test_gamma
4536 @item @emph{Specific names}:
4537 @multitable @columnfractions .20 .20 .20 .25
4538 @item Name @tab Argument @tab Return type @tab Standard
4539 @item @code{GAMMA(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU Extension
4540 @item @code{DGAMMA(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU Extension
4543 @item @emph{See also}:
4544 Logarithm of the Gamma function: @ref{LGAMMA}
4551 @section @code{GERROR} --- Get last system error message
4553 @cindex system, error handling
4556 @item @emph{Description}:
4557 Returns the system error message corresponding to the last system error.
4558 This resembles the functionality of @code{strerror(3)} in C.
4560 @item @emph{Standard}:
4566 @item @emph{Syntax}:
4567 @code{CALL GERROR(RESULT)}
4569 @item @emph{Arguments}:
4570 @multitable @columnfractions .15 .70
4571 @item @var{RESULT} @tab Shall of type @code{CHARACTER(*)}.
4574 @item @emph{Example}:
4577 CHARACTER(len=100) :: msg
4583 @item @emph{See also}:
4584 @ref{IERRNO}, @ref{PERROR}
4590 @section @code{GETARG} --- Get command line arguments
4592 @cindex command-line arguments
4593 @cindex arguments, to program
4596 @item @emph{Description}:
4597 Retrieve the @var{N}th argument that was passed on the
4598 command line when the containing program was invoked.
4600 This intrinsic routine is provided for backwards compatibility with
4601 GNU Fortran 77. In new code, programmers should consider the use of
4602 the @ref{GET_COMMAND_ARGUMENT} intrinsic defined by the Fortran 2003
4605 @item @emph{Standard}:
4611 @item @emph{Syntax}:
4612 @code{CALL GETARG(POS, VALUE)}
4614 @item @emph{Arguments}:
4615 @multitable @columnfractions .15 .70
4616 @item @var{POS} @tab Shall be of type @code{INTEGER} and not wider than
4617 the default integer kind; @math{@var{POS} \geq 0}
4618 @item @var{VALUE} @tab Shall be of type @code{CHARACTER(*)}.
4621 @item @emph{Return value}:
4622 After @code{GETARG} returns, the @var{VALUE} argument holds the
4623 @var{POS}th command line argument. If @var{VALUE} can not hold the
4624 argument, it is truncated to fit the length of @var{VALUE}. If there are
4625 less than @var{POS} arguments specified at the command line, @var{VALUE}
4626 will be filled with blanks. If @math{@var{POS} = 0}, @var{VALUE} is set
4627 to the name of the program (on systems that support this feature).
4629 @item @emph{Example}:
4633 CHARACTER(len=32) :: arg
4642 @item @emph{See also}:
4643 GNU Fortran 77 compatibility function: @ref{IARGC}
4645 F2003 functions and subroutines: @ref{GET_COMMAND}, @ref{GET_COMMAND_ARGUMENT},
4646 @ref{COMMAND_ARGUMENT_COUNT}
4652 @section @code{GET_COMMAND} --- Get the entire command line
4653 @fnindex GET_COMMAND
4654 @cindex command-line arguments
4655 @cindex arguments, to program
4658 @item @emph{Description}:
4659 Retrieve the entire command line that was used to invoke the program.
4661 @item @emph{Standard}:
4667 @item @emph{Syntax}:
4668 @code{CALL GET_COMMAND(CMD)}
4670 @item @emph{Arguments}:
4671 @multitable @columnfractions .15 .70
4672 @item @var{CMD} @tab Shall be of type @code{CHARACTER(*)}.
4675 @item @emph{Return value}:
4676 Stores the entire command line that was used to invoke the program in @var{ARG}.
4677 If @var{ARG} is not large enough, the command will be truncated.
4679 @item @emph{Example}:
4681 PROGRAM test_get_command
4682 CHARACTER(len=255) :: cmd
4683 CALL get_command(cmd)
4684 WRITE (*,*) TRIM(cmd)
4688 @item @emph{See also}:
4689 @ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
4694 @node GET_COMMAND_ARGUMENT
4695 @section @code{GET_COMMAND_ARGUMENT} --- Get command line arguments
4696 @fnindex GET_COMMAND_ARGUMENT
4697 @cindex command-line arguments
4698 @cindex arguments, to program
4701 @item @emph{Description}:
4702 Retrieve the @var{N}th argument that was passed on the
4703 command line when the containing program was invoked.
4705 @item @emph{Standard}:
4711 @item @emph{Syntax}:
4712 @code{CALL GET_COMMAND_ARGUMENT(N, ARG)}
4714 @item @emph{Arguments}:
4715 @multitable @columnfractions .15 .70
4716 @item @var{N} @tab Shall be of type @code{INTEGER(4)}, @math{@var{N} \geq 0}
4717 @item @var{ARG} @tab Shall be of type @code{CHARACTER(*)}.
4720 @item @emph{Return value}:
4721 After @code{GET_COMMAND_ARGUMENT} returns, the @var{ARG} argument holds the
4722 @var{N}th command line argument. If @var{ARG} can not hold the argument, it is
4723 truncated to fit the length of @var{ARG}. If there are less than @var{N}
4724 arguments specified at the command line, @var{ARG} will be filled with blanks.
4725 If @math{@var{N} = 0}, @var{ARG} is set to the name of the program (on systems
4726 that support this feature).
4728 @item @emph{Example}:
4730 PROGRAM test_get_command_argument
4732 CHARACTER(len=32) :: arg
4736 CALL get_command_argument(i, arg)
4737 IF (LEN_TRIM(arg) == 0) EXIT
4739 WRITE (*,*) TRIM(arg)
4745 @item @emph{See also}:
4746 @ref{GET_COMMAND}, @ref{COMMAND_ARGUMENT_COUNT}
4752 @section @code{GETCWD} --- Get current working directory
4754 @cindex system, working directory
4757 @item @emph{Description}:
4758 Get current working directory.
4760 This intrinsic is provided in both subroutine and function forms; however,
4761 only one form can be used in any given program unit.
4763 @item @emph{Standard}:
4767 Subroutine, function
4769 @item @emph{Syntax}:
4770 @code{CALL GETCWD(CWD [, STATUS])}
4772 @item @emph{Arguments}:
4773 @multitable @columnfractions .15 .70
4774 @item @var{CWD} @tab The type shall be @code{CHARACTER(*)}.
4775 @item @var{STATUS} @tab (Optional) status flag. Returns 0 on success,
4776 a system specific and nonzero error code otherwise.
4779 @item @emph{Example}:
4782 CHARACTER(len=255) :: cwd
4784 WRITE(*,*) TRIM(cwd)
4788 @item @emph{See also}:
4795 @section @code{GETENV} --- Get an environmental variable
4797 @cindex environment variable
4800 @item @emph{Description}:
4801 Get the @var{VALUE} of the environmental variable @var{ENVVAR}.
4803 This intrinsic routine is provided for backwards compatibility with
4804 GNU Fortran 77. In new code, programmers should consider the use of
4805 the @ref{GET_ENVIRONMENT_VARIABLE} intrinsic defined by the Fortran
4808 @item @emph{Standard}:
4814 @item @emph{Syntax}:
4815 @code{CALL GETENV(ENVVAR, VALUE)}
4817 @item @emph{Arguments}:
4818 @multitable @columnfractions .15 .70
4819 @item @var{ENVVAR} @tab Shall be of type @code{CHARACTER(*)}.
4820 @item @var{VALUE} @tab Shall be of type @code{CHARACTER(*)}.
4823 @item @emph{Return value}:
4824 Stores the value of @var{ENVVAR} in @var{VALUE}. If @var{VALUE} is
4825 not large enough to hold the data, it is truncated. If @var{ENVVAR}
4826 is not set, @var{VALUE} will be filled with blanks.
4828 @item @emph{Example}:
4831 CHARACTER(len=255) :: homedir
4832 CALL getenv("HOME", homedir)
4833 WRITE (*,*) TRIM(homedir)
4837 @item @emph{See also}:
4838 @ref{GET_ENVIRONMENT_VARIABLE}
4843 @node GET_ENVIRONMENT_VARIABLE
4844 @section @code{GET_ENVIRONMENT_VARIABLE} --- Get an environmental variable
4845 @fnindex GET_ENVIRONMENT_VARIABLE
4846 @cindex environment variable
4849 @item @emph{Description}:
4850 Get the @var{VALUE} of the environmental variable @var{ENVVAR}.
4852 @item @emph{Standard}:
4858 @item @emph{Syntax}:
4859 @code{CALL GET_ENVIRONMENT_VARIABLE(ENVVAR, VALUE)}
4861 @item @emph{Arguments}:
4862 @multitable @columnfractions .15 .70
4863 @item @var{ENVVAR} @tab Shall be of type @code{CHARACTER(*)}.
4864 @item @var{VALUE} @tab Shall be of type @code{CHARACTER(*)}.
4867 @item @emph{Return value}:
4868 Stores the value of @var{ENVVAR} in @var{VALUE}. If @var{VALUE} is
4869 not large enough to hold the data, it is truncated. If @var{ENVVAR}
4870 is not set, @var{VALUE} will be filled with blanks.
4872 @item @emph{Example}:
4875 CHARACTER(len=255) :: homedir
4876 CALL get_environment_variable("HOME", homedir)
4877 WRITE (*,*) TRIM(homedir)
4885 @section @code{GETGID} --- Group ID function
4887 @cindex system, group id
4890 @item @emph{Description}:
4891 Returns the numerical group ID of the current process.
4893 @item @emph{Standard}:
4899 @item @emph{Syntax}:
4900 @code{RESULT = GETGID()}
4902 @item @emph{Return value}:
4903 The return value of @code{GETGID} is an @code{INTEGER} of the default
4907 @item @emph{Example}:
4908 See @code{GETPID} for an example.
4910 @item @emph{See also}:
4911 @ref{GETPID}, @ref{GETUID}
4917 @section @code{GETLOG} --- Get login name
4919 @cindex system, login name
4923 @item @emph{Description}:
4924 Gets the username under which the program is running.
4926 @item @emph{Standard}:
4932 @item @emph{Syntax}:
4933 @code{CALL GETLOG(LOGIN)}
4935 @item @emph{Arguments}:
4936 @multitable @columnfractions .15 .70
4937 @item @var{LOGIN} @tab Shall be of type @code{CHARACTER(*)}.
4940 @item @emph{Return value}:
4941 Stores the current user name in @var{LOGIN}. (On systems where POSIX
4942 functions @code{geteuid} and @code{getpwuid} are not available, and
4943 the @code{getlogin} function is not implemented either, this will
4944 return a blank string.)
4946 @item @emph{Example}:
4949 CHARACTER(32) :: login
4955 @item @emph{See also}:
4962 @section @code{GETPID} --- Process ID function
4964 @cindex system, process id
4968 @item @emph{Description}:
4969 Returns the numerical process identifier of the current process.
4971 @item @emph{Standard}:
4977 @item @emph{Syntax}:
4978 @code{RESULT = GETPID()}
4980 @item @emph{Return value}:
4981 The return value of @code{GETPID} is an @code{INTEGER} of the default
4985 @item @emph{Example}:
4988 print *, "The current process ID is ", getpid()
4989 print *, "Your numerical user ID is ", getuid()
4990 print *, "Your numerical group ID is ", getgid()
4994 @item @emph{See also}:
4995 @ref{GETGID}, @ref{GETUID}
5001 @section @code{GETUID} --- User ID function
5003 @cindex system, user id
5007 @item @emph{Description}:
5008 Returns the numerical user ID of the current process.
5010 @item @emph{Standard}:
5016 @item @emph{Syntax}:
5017 @code{RESULT = GETUID()}
5019 @item @emph{Return value}:
5020 The return value of @code{GETUID} is an @code{INTEGER} of the default
5024 @item @emph{Example}:
5025 See @code{GETPID} for an example.
5027 @item @emph{See also}:
5028 @ref{GETPID}, @ref{GETLOG}
5034 @section @code{GMTIME} --- Convert time to GMT info
5036 @cindex time, conversion to GMT info
5039 @item @emph{Description}:
5040 Given a system time value @var{STIME} (as provided by the @code{TIME8()}
5041 intrinsic), fills @var{TARRAY} with values extracted from it appropriate
5042 to the UTC time zone (Universal Coordinated Time, also known in some
5043 countries as GMT, Greenwich Mean Time), using @code{gmtime(3)}.
5045 @item @emph{Standard}:
5051 @item @emph{Syntax}:
5052 @code{CALL GMTIME(STIME, TARRAY)}
5054 @item @emph{Arguments}:
5055 @multitable @columnfractions .15 .70
5056 @item @var{STIME} @tab An @code{INTEGER(*)} scalar expression
5057 corresponding to a system time, with
5059 @item @var{TARRAY} @tab A default @code{INTEGER} array with 9 elements,
5060 with @code{INTENT(OUT)}.
5063 @item @emph{Return value}:
5064 The elements of @var{TARRAY} are assigned as follows:
5066 @item Seconds after the minute, range 0--59 or 0--61 to allow for leap
5068 @item Minutes after the hour, range 0--59
5069 @item Hours past midnight, range 0--23
5070 @item Day of month, range 0--31
5071 @item Number of months since January, range 0--12
5072 @item Years since 1900
5073 @item Number of days since Sunday, range 0--6
5074 @item Days since January 1
5075 @item Daylight savings indicator: positive if daylight savings is in
5076 effect, zero if not, and negative if the information is not
5080 @item @emph{See also}:
5081 @ref{CTIME}, @ref{LTIME}, @ref{TIME}, @ref{TIME8}
5088 @section @code{HOSTNM} --- Get system host name
5090 @cindex system, host name
5093 @item @emph{Description}:
5094 Retrieves the host name of the system on which the program is running.
5096 This intrinsic is provided in both subroutine and function forms; however,
5097 only one form can be used in any given program unit.
5099 @item @emph{Standard}:
5103 Subroutine, function
5105 @item @emph{Syntax}:
5106 @multitable @columnfractions .80
5107 @item @code{CALL HOSTNM(NAME[, STATUS])}
5108 @item @code{STATUS = HOSTNM(NAME)}
5111 @item @emph{Arguments}:
5112 @multitable @columnfractions .15 .70
5113 @item @var{NAME} @tab Shall of type @code{CHARACTER(*)}.
5114 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
5115 Returns 0 on success, or a system specific error
5119 @item @emph{Return value}:
5120 In either syntax, @var{NAME} is set to the current hostname if it can
5121 be obtained, or to a blank string otherwise.
5128 @section @code{HUGE} --- Largest number of a kind
5130 @cindex limits, largest number
5131 @cindex model representation, largest number
5134 @item @emph{Description}:
5135 @code{HUGE(X)} returns the largest number that is not an infinity in
5136 the model of the type of @code{X}.
5138 @item @emph{Standard}:
5144 @item @emph{Syntax}:
5145 @code{RESULT = HUGE(X)}
5147 @item @emph{Arguments}:
5148 @multitable @columnfractions .15 .70
5149 @item @var{X} @tab Shall be of type @code{REAL} or @code{INTEGER}.
5152 @item @emph{Return value}:
5153 The return value is of the same type and kind as @var{X}
5155 @item @emph{Example}:
5157 program test_huge_tiny
5158 print *, huge(0), huge(0.0), huge(0.0d0)
5159 print *, tiny(0.0), tiny(0.0d0)
5160 end program test_huge_tiny
5167 @section @code{IACHAR} --- Code in @acronym{ASCII} collating sequence
5169 @cindex @acronym{ASCII} collating sequence
5170 @cindex collating sequence, @acronym{ASCII}
5171 @cindex conversion, to integer
5174 @item @emph{Description}:
5175 @code{IACHAR(C)} returns the code for the @acronym{ASCII} character
5176 in the first character position of @code{C}.
5178 @item @emph{Standard}:
5184 @item @emph{Syntax}:
5185 @code{RESULT = IACHAR(C [, KIND])}
5187 @item @emph{Arguments}:
5188 @multitable @columnfractions .15 .70
5189 @item @var{C} @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
5190 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
5191 expression indicating the kind parameter of
5195 @item @emph{Return value}:
5196 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
5197 @var{KIND} is absent, the return value is of default integer kind.
5199 @item @emph{Example}:
5204 end program test_iachar
5208 See @ref{ICHAR} for a discussion of converting between numerical values
5209 and formatted string representations.
5211 @item @emph{See also}:
5212 @ref{ACHAR}, @ref{CHAR}, @ref{ICHAR}
5219 @section @code{IAND} --- Bitwise logical and
5221 @cindex bitwise logical and
5222 @cindex logical and, bitwise
5225 @item @emph{Description}:
5226 Bitwise logical @code{AND}.
5228 @item @emph{Standard}:
5234 @item @emph{Syntax}:
5235 @code{RESULT = IAND(I, J)}
5237 @item @emph{Arguments}:
5238 @multitable @columnfractions .15 .70
5239 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
5240 @item @var{J} @tab The type shall be @code{INTEGER(*)}, of the same
5241 kind as @var{I}. (As a GNU extension, different kinds are also
5245 @item @emph{Return value}:
5246 The return type is @code{INTEGER(*)}, of the same kind as the
5247 arguments. (If the argument kinds differ, it is of the same kind as
5248 the larger argument.)
5250 @item @emph{Example}:
5254 DATA a / Z'F' /, b / Z'3' /
5255 WRITE (*,*) IAND(a, b)
5259 @item @emph{See also}:
5260 @ref{IOR}, @ref{IEOR}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
5267 @section @code{IARGC} --- Get the number of command line arguments
5269 @cindex command-line arguments
5270 @cindex command-line arguments, number of
5271 @cindex arguments, to program
5274 @item @emph{Description}:
5275 @code{IARGC()} returns the number of arguments passed on the
5276 command line when the containing program was invoked.
5278 This intrinsic routine is provided for backwards compatibility with
5279 GNU Fortran 77. In new code, programmers should consider the use of
5280 the @ref{COMMAND_ARGUMENT_COUNT} intrinsic defined by the Fortran 2003
5283 @item @emph{Standard}:
5289 @item @emph{Syntax}:
5290 @code{RESULT = IARGC()}
5292 @item @emph{Arguments}:
5295 @item @emph{Return value}:
5296 The number of command line arguments, type @code{INTEGER(4)}.
5298 @item @emph{Example}:
5301 @item @emph{See also}:
5302 GNU Fortran 77 compatibility subroutine: @ref{GETARG}
5304 F2003 functions and subroutines: @ref{GET_COMMAND}, @ref{GET_COMMAND_ARGUMENT},
5305 @ref{COMMAND_ARGUMENT_COUNT}
5311 @section @code{IBCLR} --- Clear bit
5317 @item @emph{Description}:
5318 @code{IBCLR} returns the value of @var{I} with the bit at position
5319 @var{POS} set to zero.
5321 @item @emph{Standard}:
5327 @item @emph{Syntax}:
5328 @code{RESULT = IBCLR(I, POS)}
5330 @item @emph{Arguments}:
5331 @multitable @columnfractions .15 .70
5332 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
5333 @item @var{POS} @tab The type shall be @code{INTEGER(*)}.
5336 @item @emph{Return value}:
5337 The return value is of type @code{INTEGER(*)} and of the same kind as
5340 @item @emph{See also}:
5341 @ref{IBITS}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}, @ref{MVBITS}
5348 @section @code{IBITS} --- Bit extraction
5351 @cindex bits, extract
5354 @item @emph{Description}:
5355 @code{IBITS} extracts a field of length @var{LEN} from @var{I},
5356 starting from bit position @var{POS} and extending left for @var{LEN}
5357 bits. The result is right-justified and the remaining bits are
5358 zeroed. The value of @code{POS+LEN} must be less than or equal to the
5359 value @code{BIT_SIZE(I)}.
5361 @item @emph{Standard}:
5367 @item @emph{Syntax}:
5368 @code{RESULT = IBITS(I, POS, LEN)}
5370 @item @emph{Arguments}:
5371 @multitable @columnfractions .15 .70
5372 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
5373 @item @var{POS} @tab The type shall be @code{INTEGER(*)}.
5374 @item @var{LEN} @tab The type shall be @code{INTEGER(*)}.
5377 @item @emph{Return value}:
5378 The return value is of type @code{INTEGER(*)} and of the same kind as
5381 @item @emph{See also}:
5382 @ref{BIT_SIZE}, @ref{IBCLR}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
5388 @section @code{IBSET} --- Set bit
5393 @item @emph{Description}:
5394 @code{IBSET} returns the value of @var{I} with the bit at position
5395 @var{POS} set to one.
5397 @item @emph{Standard}:
5403 @item @emph{Syntax}:
5404 @code{RESULT = IBSET(I, POS)}
5406 @item @emph{Arguments}:
5407 @multitable @columnfractions .15 .70
5408 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
5409 @item @var{POS} @tab The type shall be @code{INTEGER(*)}.
5412 @item @emph{Return value}:
5413 The return value is of type @code{INTEGER(*)} and of the same kind as
5416 @item @emph{See also}:
5417 @ref{IBCLR}, @ref{IBITS}, @ref{IAND}, @ref{IOR}, @ref{IEOR}, @ref{MVBITS}
5424 @section @code{ICHAR} --- Character-to-integer conversion function
5426 @cindex conversion, to integer
5429 @item @emph{Description}:
5430 @code{ICHAR(C)} returns the code for the character in the first character
5431 position of @code{C} in the system's native character set.
5432 The correspondence between characters and their codes is not necessarily
5433 the same across different GNU Fortran implementations.
5435 @item @emph{Standard}:
5441 @item @emph{Syntax}:
5442 @code{RESULT = ICHAR(C [, KIND])}
5444 @item @emph{Arguments}:
5445 @multitable @columnfractions .15 .70
5446 @item @var{C} @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
5447 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
5448 expression indicating the kind parameter of
5452 @item @emph{Return value}:
5453 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
5454 @var{KIND} is absent, the return value is of default integer kind.
5456 @item @emph{Example}:
5461 end program test_ichar
5465 No intrinsic exists to convert between a numeric value and a formatted
5466 character string representation -- for instance, given the
5467 @code{CHARACTER} value @code{'154'}, obtaining an @code{INTEGER} or
5468 @code{REAL} value with the value 154, or vice versa. Instead, this
5469 functionality is provided by internal-file I/O, as in the following
5474 character(len=10) string, string2
5477 ! Convert a string to a numeric value
5478 read (string,'(I10)') value
5481 ! Convert a value to a formatted string
5482 write (string2,'(I10)') value
5484 end program read_val
5487 @item @emph{See also}:
5488 @ref{ACHAR}, @ref{CHAR}, @ref{IACHAR}
5495 @section @code{IDATE} --- Get current local time subroutine (day/month/year)
5497 @cindex date, current
5498 @cindex current date
5501 @item @emph{Description}:
5502 @code{IDATE(TARRAY)} Fills @var{TARRAY} with the numerical values at the
5503 current local time. The day (in the range 1-31), month (in the range 1-12),
5504 and year appear in elements 1, 2, and 3 of @var{TARRAY}, respectively.
5505 The year has four significant digits.
5507 @item @emph{Standard}:
5513 @item @emph{Syntax}:
5514 @code{CALL IDATE(TARRAY)}
5516 @item @emph{Arguments}:
5517 @multitable @columnfractions .15 .70
5518 @item @var{TARRAY} @tab The type shall be @code{INTEGER, DIMENSION(3)} and
5519 the kind shall be the default integer kind.
5522 @item @emph{Return value}:
5525 @item @emph{Example}:
5528 integer, dimension(3) :: tarray
5533 end program test_idate
5540 @section @code{IEOR} --- Bitwise logical exclusive or
5542 @cindex bitwise logical exclusive or
5543 @cindex logical exclusive or, bitwise
5546 @item @emph{Description}:
5547 @code{IEOR} returns the bitwise boolean exclusive-OR of @var{I} and
5550 @item @emph{Standard}:
5556 @item @emph{Syntax}:
5557 @code{RESULT = IEOR(I, J)}
5559 @item @emph{Arguments}:
5560 @multitable @columnfractions .15 .70
5561 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
5562 @item @var{J} @tab The type shall be @code{INTEGER(*)}, of the same
5563 kind as @var{I}. (As a GNU extension, different kinds are also
5567 @item @emph{Return value}:
5568 The return type is @code{INTEGER(*)}, of the same kind as the
5569 arguments. (If the argument kinds differ, it is of the same kind as
5570 the larger argument.)
5572 @item @emph{See also}:
5573 @ref{IOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
5579 @section @code{IERRNO} --- Get the last system error number
5581 @cindex system, error handling
5584 @item @emph{Description}:
5585 Returns the last system error number, as given by the C @code{errno()}
5588 @item @emph{Standard}:
5594 @item @emph{Syntax}:
5595 @code{RESULT = IERRNO()}
5597 @item @emph{Arguments}:
5600 @item @emph{Return value}:
5601 The return value is of type @code{INTEGER} and of the default integer
5604 @item @emph{See also}:
5611 @section @code{INDEX} --- Position of a substring within a string
5613 @cindex substring position
5614 @cindex string, find substring
5617 @item @emph{Description}:
5618 Returns the position of the start of the first occurrence of string
5619 @var{SUBSTRING} as a substring in @var{STRING}, counting from one. If
5620 @var{SUBSTRING} is not present in @var{STRING}, zero is returned. If
5621 the @var{BACK} argument is present and true, the return value is the
5622 start of the last occurrence rather than the first.
5624 @item @emph{Standard}:
5630 @item @emph{Syntax}:
5631 @code{RESULT = INDEX(STRING, SUBSTRING [, BACK [, KIND]])}
5633 @item @emph{Arguments}:
5634 @multitable @columnfractions .15 .70
5635 @item @var{STRING} @tab Shall be a scalar @code{CHARACTER(*)}, with
5637 @item @var{SUBSTRING} @tab Shall be a scalar @code{CHARACTER(*)}, with
5639 @item @var{BACK} @tab (Optional) Shall be a scalar @code{LOGICAL(*)}, with
5641 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
5642 expression indicating the kind parameter of
5646 @item @emph{Return value}:
5647 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
5648 @var{KIND} is absent, the return value is of default integer kind.
5650 @item @emph{See also}:
5651 @ref{SCAN}, @ref{VERIFY}
5657 @section @code{INT} --- Convert to integer type
5661 @cindex conversion, to integer
5664 @item @emph{Description}:
5665 Convert to integer type
5667 @item @emph{Standard}:
5673 @item @emph{Syntax}:
5674 @code{RESULT = INT(A [, KIND))}
5676 @item @emph{Arguments}:
5677 @multitable @columnfractions .15 .70
5678 @item @var{A} @tab Shall be of type @code{INTEGER(*)},
5679 @code{REAL(*)}, or @code{COMPLEX(*)}.
5680 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
5681 expression indicating the kind parameter of
5685 @item @emph{Return value}:
5686 These functions return a @code{INTEGER(*)} variable or array under
5687 the following rules:
5691 If @var{A} is of type @code{INTEGER(*)}, @code{INT(A) = A}
5693 If @var{A} is of type @code{REAL(*)} and @math{|A| < 1}, @code{INT(A)} equals @code{0}.
5694 If @math{|A| \geq 1}, then @code{INT(A)} equals the largest integer that does not exceed
5695 the range of @var{A} and whose sign is the same as the sign of @var{A}.
5697 If @var{A} is of type @code{COMPLEX(*)}, rule B is applied to the real part of @var{A}.
5700 @item @emph{Example}:
5704 complex :: z = (-3.7, 1.0)
5706 print *, int(z), int(z,8)
5710 @item @emph{Specific names}:
5711 @multitable @columnfractions .20 .20 .20 .25
5712 @item Name @tab Argument @tab Return type @tab Standard
5713 @item @code{IFIX(A)} @tab @code{REAL(4) A} @tab @code{INTEGER} @tab F77 and later
5714 @item @code{IDINT(A)} @tab @code{REAL(8) A} @tab @code{INTEGER} @tab F77 and later
5722 @section @code{INT2} --- Convert to 16-bit integer type
5725 @cindex conversion, to integer
5728 @item @emph{Description}:
5729 Convert to a @code{KIND=2} integer type. This is equivalent to the
5730 standard @code{INT} intrinsic with an optional argument of
5731 @code{KIND=2}, and is only included for backwards compatibility.
5733 The @code{SHORT} intrinsic is equivalent to @code{INT2}.
5735 @item @emph{Standard}:
5741 @item @emph{Syntax}:
5742 @code{RESULT = INT2(A)}
5744 @item @emph{Arguments}:
5745 @multitable @columnfractions .15 .70
5746 @item @var{A} @tab Shall be of type @code{INTEGER(*)},
5747 @code{REAL(*)}, or @code{COMPLEX(*)}.
5750 @item @emph{Return value}:
5751 The return value is a @code{INTEGER(2)} variable.
5753 @item @emph{See also}:
5754 @ref{INT}, @ref{INT8}, @ref{LONG}
5760 @section @code{INT8} --- Convert to 64-bit integer type
5762 @cindex conversion, to integer
5765 @item @emph{Description}:
5766 Convert to a @code{KIND=8} integer type. This is equivalent to the
5767 standard @code{INT} intrinsic with an optional argument of
5768 @code{KIND=8}, and is only included for backwards compatibility.
5770 @item @emph{Standard}:
5776 @item @emph{Syntax}:
5777 @code{RESULT = INT8(A)}
5779 @item @emph{Arguments}:
5780 @multitable @columnfractions .15 .70
5781 @item @var{A} @tab Shall be of type @code{INTEGER(*)},
5782 @code{REAL(*)}, or @code{COMPLEX(*)}.
5785 @item @emph{Return value}:
5786 The return value is a @code{INTEGER(8)} variable.
5788 @item @emph{See also}:
5789 @ref{INT}, @ref{INT2}, @ref{LONG}
5795 @section @code{IOR} --- Bitwise logical or
5797 @cindex bitwise logical or
5798 @cindex logical or, bitwise
5801 @item @emph{Description}:
5802 @code{IEOR} returns the bitwise boolean OR of @var{I} and
5805 @item @emph{Standard}:
5811 @item @emph{Syntax}:
5812 @code{RESULT = IEOR(I, J)}
5814 @item @emph{Arguments}:
5815 @multitable @columnfractions .15 .70
5816 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
5817 @item @var{J} @tab The type shall be @code{INTEGER(*)}, of the same
5818 kind as @var{I}. (As a GNU extension, different kinds are also
5822 @item @emph{Return value}:
5823 The return type is @code{INTEGER(*)}, of the same kind as the
5824 arguments. (If the argument kinds differ, it is of the same kind as
5825 the larger argument.)
5827 @item @emph{See also}:
5828 @ref{IEOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
5834 @section @code{IRAND} --- Integer pseudo-random number
5836 @cindex random number generation
5839 @item @emph{Description}:
5840 @code{IRAND(FLAG)} returns a pseudo-random number from a uniform
5841 distribution between 0 and a system-dependent limit (which is in most
5842 cases 2147483647). If @var{FLAG} is 0, the next number
5843 in the current sequence is returned; if @var{FLAG} is 1, the generator
5844 is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
5845 it is used as a new seed with @code{SRAND}.
5847 This intrinsic routine is provided for backwards compatibility with
5848 GNU Fortran 77. It implements a simple modulo generator as provided
5849 by @command{g77}. For new code, one should consider the use of
5850 @ref{RANDOM_NUMBER} as it implements a superior algorithm.
5852 @item @emph{Standard}:
5858 @item @emph{Syntax}:
5859 @code{RESULT = IRAND(FLAG)}
5861 @item @emph{Arguments}:
5862 @multitable @columnfractions .15 .70
5863 @item @var{FLAG} @tab Shall be a scalar @code{INTEGER} of kind 4.
5866 @item @emph{Return value}:
5867 The return value is of @code{INTEGER(kind=4)} type.
5869 @item @emph{Example}:
5872 integer,parameter :: seed = 86456
5875 print *, irand(), irand(), irand(), irand()
5876 print *, irand(seed), irand(), irand(), irand()
5877 end program test_irand
5885 @section @code{IS_IOSTAT_END} --- Test for end-of-file value
5886 @fnindex IS_IOSTAT_END
5887 @cindex IOSTAT, end of file
5890 @item @emph{Description}:
5891 @code{IS_IOSTAT_END} tests whether an variable has the value of the I/O
5892 status ``end of file''. The function is equivalent to comparing the variable
5893 with the @code{IOSTAT_END} parameter of the intrinsic module
5894 @code{ISO_FORTRAN_ENV}.
5896 @item @emph{Standard}:
5902 @item @emph{Syntax}:
5903 @code{RESULT = IS_IOSTAT_END(I)}
5905 @item @emph{Arguments}:
5906 @multitable @columnfractions .15 .70
5907 @item @var{I} @tab Shall be of the type @code{INTEGER}.
5910 @item @emph{Return value}:
5911 Returns a @code{LOGICAL} of the default kind, which @code{.TRUE.} if
5912 @var{I} has the value which indicates an end of file condition for
5913 IOSTAT= specifiers, and is @code{.FALSE.} otherwise.
5915 @item @emph{Example}:
5920 OPEN(88, FILE='test.dat')
5921 READ(88, *, IOSTAT=stat) i
5922 IF(IS_IOSTAT_END(stat)) STOP 'END OF FILE'
5930 @section @code{IS_IOSTAT_EOR} --- Test for end-of-record value
5931 @fnindex IS_IOSTAT_EOR
5932 @cindex IOSTAT, end of record
5935 @item @emph{Description}:
5936 @code{IS_IOSTAT_EOR} tests whether an variable has the value of the I/O
5937 status ``end of record''. The function is equivalent to comparing the
5938 variable with the @code{IOSTAT_EOR} parameter of the intrinsic module
5939 @code{ISO_FORTRAN_ENV}.
5941 @item @emph{Standard}:
5947 @item @emph{Syntax}:
5948 @code{RESULT = IS_IOSTAT_EOR(I)}
5950 @item @emph{Arguments}:
5951 @multitable @columnfractions .15 .70
5952 @item @var{I} @tab Shall be of the type @code{INTEGER}.
5955 @item @emph{Return value}:
5956 Returns a @code{LOGICAL} of the default kind, which @code{.TRUE.} if
5957 @var{I} has the value which indicates an end of file condition for
5958 IOSTAT= specifiers, and is @code{.FALSE.} otherwise.
5960 @item @emph{Example}:
5964 INTEGER :: stat, i(50)
5965 OPEN(88, FILE='test.dat', FORM='UNFORMATTED')
5966 READ(88, IOSTAT=stat) i
5967 IF(IS_IOSTAT_EOR(stat)) STOP 'END OF RECORD'
5975 @section @code{ISATTY} --- Whether a unit is a terminal device.
5977 @cindex system, terminal
5980 @item @emph{Description}:
5981 Determine whether a unit is connected to a terminal device.
5983 @item @emph{Standard}:
5989 @item @emph{Syntax}:
5990 @code{RESULT = ISATTY(UNIT)}
5992 @item @emph{Arguments}:
5993 @multitable @columnfractions .15 .70
5994 @item @var{UNIT} @tab Shall be a scalar @code{INTEGER(*)}.
5997 @item @emph{Return value}:
5998 Returns @code{.TRUE.} if the @var{UNIT} is connected to a terminal
5999 device, @code{.FALSE.} otherwise.
6001 @item @emph{Example}:
6004 INTEGER(kind=1) :: unit
6006 write(*,*) isatty(unit=unit)
6010 @item @emph{See also}:
6017 @section @code{ISHFT} --- Shift bits
6022 @item @emph{Description}:
6023 @code{ISHFT} returns a value corresponding to @var{I} with all of the
6024 bits shifted @var{SHIFT} places. A value of @var{SHIFT} greater than
6025 zero corresponds to a left shift, a value of zero corresponds to no
6026 shift, and a value less than zero corresponds to a right shift. If the
6027 absolute value of @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the
6028 value is undefined. Bits shifted out from the left end or right end are
6029 lost; zeros are shifted in from the opposite end.
6031 @item @emph{Standard}:
6037 @item @emph{Syntax}:
6038 @code{RESULT = ISHFT(I, SHIFT)}
6040 @item @emph{Arguments}:
6041 @multitable @columnfractions .15 .70
6042 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
6043 @item @var{SHIFT} @tab The type shall be @code{INTEGER(*)}.
6046 @item @emph{Return value}:
6047 The return value is of type @code{INTEGER(*)} and of the same kind as
6050 @item @emph{See also}:
6057 @section @code{ISHFTC} --- Shift bits circularly
6059 @cindex bits, shift circular
6062 @item @emph{Description}:
6063 @code{ISHFTC} returns a value corresponding to @var{I} with the
6064 rightmost @var{SIZE} bits shifted circularly @var{SHIFT} places; that
6065 is, bits shifted out one end are shifted into the opposite end. A value
6066 of @var{SHIFT} greater than zero corresponds to a left shift, a value of
6067 zero corresponds to no shift, and a value less than zero corresponds to
6068 a right shift. The absolute value of @var{SHIFT} must be less than
6069 @var{SIZE}. If the @var{SIZE} argument is omitted, it is taken to be
6070 equivalent to @code{BIT_SIZE(I)}.
6072 @item @emph{Standard}:
6078 @item @emph{Syntax}:
6079 @code{RESULT = ISHFTC(I, SHIFT [, SIZE])}
6081 @item @emph{Arguments}:
6082 @multitable @columnfractions .15 .70
6083 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
6084 @item @var{SHIFT} @tab The type shall be @code{INTEGER(*)}.
6085 @item @var{SIZE} @tab (Optional) The type shall be @code{INTEGER(*)};
6086 the value must be greater than zero and less than or equal to
6090 @item @emph{Return value}:
6091 The return value is of type @code{INTEGER(*)} and of the same kind as
6094 @item @emph{See also}:
6101 @section @code{ISNAN} --- Test for a NaN
6106 @item @emph{Description}:
6107 @code{ISNAN} tests whether a floating-point value is an IEEE
6109 @item @emph{Standard}:
6115 @item @emph{Syntax}:
6118 @item @emph{Arguments}:
6119 @multitable @columnfractions .15 .70
6120 @item @var{X} @tab Variable of the type @code{REAL}.
6124 @item @emph{Return value}:
6125 Returns a default-kind @code{LOGICAL}. The returned value is @code{TRUE}
6126 if @var{X} is a NaN and @code{FALSE} otherwise.
6128 @item @emph{Example}:
6135 if (isnan(x)) stop '"x" is a NaN'
6136 end program test_nan
6143 @section @code{ITIME} --- Get current local time subroutine (hour/minutes/seconds)
6145 @cindex time, current
6146 @cindex current time
6149 @item @emph{Description}:
6150 @code{IDATE(TARRAY)} Fills @var{TARRAY} with the numerical values at the
6151 current local time. The hour (in the range 1-24), minute (in the range 1-60),
6152 and seconds (in the range 1-60) appear in elements 1, 2, and 3 of @var{TARRAY},
6155 @item @emph{Standard}:
6161 @item @emph{Syntax}:
6162 @code{CALL ITIME(TARRAY)}
6164 @item @emph{Arguments}:
6165 @multitable @columnfractions .15 .70
6166 @item @var{TARRAY} @tab The type shall be @code{INTEGER, DIMENSION(3)}
6167 and the kind shall be the default integer kind.
6170 @item @emph{Return value}:
6174 @item @emph{Example}:
6177 integer, dimension(3) :: tarray
6182 end program test_itime
6189 @section @code{KILL} --- Send a signal to a process
6193 @item @emph{Description}:
6194 @item @emph{Standard}:
6195 Sends the signal specified by @var{SIGNAL} to the process @var{PID}.
6198 This intrinsic is provided in both subroutine and function forms; however,
6199 only one form can be used in any given program unit.
6202 Subroutine, function
6204 @item @emph{Syntax}:
6205 @code{CALL KILL(PID, SIGNAL [, STATUS])}
6207 @item @emph{Arguments}:
6208 @multitable @columnfractions .15 .70
6209 @item @var{PID} @tab Shall be a scalar @code{INTEGER}, with
6211 @item @var{SIGNAL} @tab Shall be a scalar @code{INTEGER}, with
6213 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)} or
6214 @code{INTEGER(8)}. Returns 0 on success, or a
6215 system-specific error code otherwise.
6218 @item @emph{See also}:
6219 @ref{ABORT}, @ref{EXIT}
6225 @section @code{KIND} --- Kind of an entity
6230 @item @emph{Description}:
6231 @code{KIND(X)} returns the kind value of the entity @var{X}.
6233 @item @emph{Standard}:
6239 @item @emph{Syntax}:
6242 @item @emph{Arguments}:
6243 @multitable @columnfractions .15 .70
6244 @item @var{X} @tab Shall be of type @code{LOGICAL}, @code{INTEGER},
6245 @code{REAL}, @code{COMPLEX} or @code{CHARACTER}.
6248 @item @emph{Return value}:
6249 The return value is a scalar of type @code{INTEGER} and of the default
6252 @item @emph{Example}:
6255 integer,parameter :: kc = kind(' ')
6256 integer,parameter :: kl = kind(.true.)
6258 print *, "The default character kind is ", kc
6259 print *, "The default logical kind is ", kl
6260 end program test_kind
6268 @section @code{LBOUND} --- Lower dimension bounds of an array
6270 @cindex array, lower bound
6273 @item @emph{Description}:
6274 Returns the lower bounds of an array, or a single lower bound
6275 along the @var{DIM} dimension.
6276 @item @emph{Standard}:
6282 @item @emph{Syntax}:
6283 @code{RESULT = LBOUND(ARRAY [, DIM [, KIND]])}
6285 @item @emph{Arguments}:
6286 @multitable @columnfractions .15 .70
6287 @item @var{ARRAY} @tab Shall be an array, of any type.
6288 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER(*)}.
6289 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
6290 expression indicating the kind parameter of
6294 @item @emph{Return value}:
6295 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
6296 @var{KIND} is absent, the return value is of default integer kind.
6297 If @var{DIM} is absent, the result is an array of the lower bounds of
6298 @var{ARRAY}. If @var{DIM} is present, the result is a scalar
6299 corresponding to the lower bound of the array along that dimension. If
6300 @var{ARRAY} is an expression rather than a whole array or array
6301 structure component, or if it has a zero extent along the relevant
6302 dimension, the lower bound is taken to be 1.
6304 @item @emph{See also}:
6311 @section @code{LEN} --- Length of a character entity
6313 @cindex string, length
6316 @item @emph{Description}:
6317 Returns the length of a character string. If @var{STRING} is an array,
6318 the length of an element of @var{STRING} is returned. Note that
6319 @var{STRING} need not be defined when this intrinsic is invoked, since
6320 only the length, not the content, of @var{STRING} is needed.
6322 @item @emph{Standard}:
6328 @item @emph{Syntax}:
6329 @code{L = LEN(STRING [, KIND])}
6331 @item @emph{Arguments}:
6332 @multitable @columnfractions .15 .70
6333 @item @var{STRING} @tab Shall be a scalar or array of type
6334 @code{CHARACTER(*)}, with @code{INTENT(IN)}
6335 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
6336 expression indicating the kind parameter of
6340 @item @emph{Return value}:
6341 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
6342 @var{KIND} is absent, the return value is of default integer kind.
6344 @item @emph{See also}:
6345 @ref{LEN_TRIM}, @ref{ADJUSTL}, @ref{ADJUSTR}
6351 @section @code{LEN_TRIM} --- Length of a character entity without trailing blank characters
6353 @cindex string, length, without trailing whitespace
6356 @item @emph{Description}:
6357 Returns the length of a character string, ignoring any trailing blanks.
6359 @item @emph{Standard}:
6365 @item @emph{Syntax}:
6366 @code{RESULT = LEN_TRIM(STRING [, KIND])}
6368 @item @emph{Arguments}:
6369 @multitable @columnfractions .15 .70
6370 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER(*)},
6371 with @code{INTENT(IN)}
6372 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
6373 expression indicating the kind parameter of
6377 @item @emph{Return value}:
6378 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
6379 @var{KIND} is absent, the return value is of default integer kind.
6381 @item @emph{See also}:
6382 @ref{LEN}, @ref{ADJUSTL}, @ref{ADJUSTR}
6388 @section @code{LGAMMA} --- Logarithm of the Gamma function
6392 @cindex Gamma function, logarithm of
6395 @item @emph{Description}:
6396 @code{GAMMA(X)} computes the natural logrithm of the absolute value of the
6397 Gamma (@math{\Gamma}) function.
6399 @item @emph{Standard}:
6405 @item @emph{Syntax}:
6406 @code{X = LGAMMA(X)}
6408 @item @emph{Arguments}:
6409 @multitable @columnfractions .15 .70
6410 @item @var{X} @tab Shall be of type @code{REAL} and neither zero
6411 nor a negative integer.
6414 @item @emph{Return value}:
6415 The return value is of type @code{REAL} of the same kind as @var{X}.
6417 @item @emph{Example}:
6419 program test_log_gamma
6421 x = lgamma(x) ! returns 0.0
6422 end program test_log_gamma
6425 @item @emph{Specific names}:
6426 @multitable @columnfractions .20 .20 .20 .25
6427 @item Name @tab Argument @tab Return type @tab Standard
6428 @item @code{LGAMMA(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU Extension
6429 @item @code{ALGAMA(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab GNU Extension
6430 @item @code{DLGAMA(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU Extension
6433 @item @emph{See also}:
6434 Gamma function: @ref{GAMMA}
6441 @section @code{LGE} --- Lexical greater than or equal
6443 @cindex lexical comparison of strings
6444 @cindex string, comparison
6447 @item @emph{Description}:
6448 Determines whether one string is lexically greater than or equal to
6449 another string, where the two strings are interpreted as containing
6450 ASCII character codes. If the String A and String B are not the same
6451 length, the shorter is compared as if spaces were appended to it to form
6452 a value that has the same length as the longer.
6454 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
6455 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
6456 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
6457 that the latter use the processor's character ordering (which is not
6458 ASCII on some targets), whereas the former always use the ASCII
6461 @item @emph{Standard}:
6467 @item @emph{Syntax}:
6468 @code{RESULT = LGE(STRING_A, STRING_B)}
6470 @item @emph{Arguments}:
6471 @multitable @columnfractions .15 .70
6472 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
6473 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
6476 @item @emph{Return value}:
6477 Returns @code{.TRUE.} if @code{STRING_A >= STRING_B}, and @code{.FALSE.}
6478 otherwise, based on the ASCII ordering.
6480 @item @emph{See also}:
6481 @ref{LGT}, @ref{LLE}, @ref{LLT}
6487 @section @code{LGT} --- Lexical greater than
6489 @cindex lexical comparison of strings
6490 @cindex string, comparison
6493 @item @emph{Description}:
6494 Determines whether one string is lexically greater than another string,
6495 where the two strings are interpreted as containing ASCII character
6496 codes. If the String A and String B are not the same length, the
6497 shorter is compared as if spaces were appended to it to form a value
6498 that has the same length as the longer.
6500 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
6501 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
6502 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
6503 that the latter use the processor's character ordering (which is not
6504 ASCII on some targets), whereas the former always use the ASCII
6507 @item @emph{Standard}:
6513 @item @emph{Syntax}:
6514 @code{RESULT = LGT(STRING_A, STRING_B)}
6516 @item @emph{Arguments}:
6517 @multitable @columnfractions .15 .70
6518 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
6519 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
6522 @item @emph{Return value}:
6523 Returns @code{.TRUE.} if @code{STRING_A > STRING_B}, and @code{.FALSE.}
6524 otherwise, based on the ASCII ordering.
6526 @item @emph{See also}:
6527 @ref{LGE}, @ref{LLE}, @ref{LLT}
6533 @section @code{LINK} --- Create a hard link
6535 @cindex file system, create link
6536 @cindex file system, hard link
6539 @item @emph{Description}:
6540 Makes a (hard) link from file @var{PATH1} to @var{PATH2}. A null
6541 character (@code{CHAR(0)}) can be used to mark the end of the names in
6542 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
6543 names are ignored. If the @var{STATUS} argument is supplied, it
6544 contains 0 on success or a nonzero error code upon return; see
6547 This intrinsic is provided in both subroutine and function forms;
6548 however, only one form can be used in any given program unit.
6550 @item @emph{Standard}:
6554 Subroutine, function
6556 @item @emph{Syntax}:
6557 @multitable @columnfractions .80
6558 @item @code{CALL LINK(PATH1, PATH2 [, STATUS])}
6559 @item @code{STATUS = LINK(PATH1, PATH2)}
6562 @item @emph{Arguments}:
6563 @multitable @columnfractions .15 .70
6564 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
6565 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
6566 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
6569 @item @emph{See also}:
6570 @ref{SYMLNK}, @ref{UNLINK}
6576 @section @code{LLE} --- Lexical less than or equal
6578 @cindex lexical comparison of strings
6579 @cindex string, comparison
6582 @item @emph{Description}:
6583 Determines whether one string is lexically less than or equal to another
6584 string, where the two strings are interpreted as containing ASCII
6585 character codes. If the String A and String B are not the same length,
6586 the shorter is compared as if spaces were appended to it to form a value
6587 that has the same length as the longer.
6589 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
6590 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
6591 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
6592 that the latter use the processor's character ordering (which is not
6593 ASCII on some targets), whereas the former always use the ASCII
6596 @item @emph{Standard}:
6602 @item @emph{Syntax}:
6603 @code{RESULT = LLE(STRING_A, STRING_B)}
6605 @item @emph{Arguments}:
6606 @multitable @columnfractions .15 .70
6607 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
6608 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
6611 @item @emph{Return value}:
6612 Returns @code{.TRUE.} if @code{STRING_A <= STRING_B}, and @code{.FALSE.}
6613 otherwise, based on the ASCII ordering.
6615 @item @emph{See also}:
6616 @ref{LGE}, @ref{LGT}, @ref{LLT}
6622 @section @code{LLT} --- Lexical less than
6624 @cindex lexical comparison of strings
6625 @cindex string, comparison
6628 @item @emph{Description}:
6629 Determines whether one string is lexically less than another string,
6630 where the two strings are interpreted as containing ASCII character
6631 codes. If the String A and String B are not the same length, the
6632 shorter is compared as if spaces were appended to it to form a value
6633 that has the same length as the longer.
6635 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
6636 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
6637 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
6638 that the latter use the processor's character ordering (which is not
6639 ASCII on some targets), whereas the former always use the ASCII
6642 @item @emph{Standard}:
6648 @item @emph{Syntax}:
6649 @code{RESULT = LLT(STRING_A, STRING_B)}
6651 @item @emph{Arguments}:
6652 @multitable @columnfractions .15 .70
6653 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
6654 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
6657 @item @emph{Return value}:
6658 Returns @code{.TRUE.} if @code{STRING_A < STRING_B}, and @code{.FALSE.}
6659 otherwise, based on the ASCII ordering.
6661 @item @emph{See also}:
6662 @ref{LGE}, @ref{LGT}, @ref{LLE}
6668 @section @code{LNBLNK} --- Index of the last non-blank character in a string
6670 @cindex string, find non-blank character
6673 @item @emph{Description}:
6674 Returns the length of a character string, ignoring any trailing blanks.
6675 This is identical to the standard @code{LEN_TRIM} intrinsic, and is only
6676 included for backwards compatibility.
6678 @item @emph{Standard}:
6684 @item @emph{Syntax}:
6685 @code{RESULT = LNBLNK(STRING)}
6687 @item @emph{Arguments}:
6688 @multitable @columnfractions .15 .70
6689 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER(*)},
6690 with @code{INTENT(IN)}
6693 @item @emph{Return value}:
6694 The return value is of @code{INTEGER(kind=4)} type.
6696 @item @emph{See also}:
6697 @ref{INDEX}, @ref{LEN_TRIM}
6703 @section @code{LOC} --- Returns the address of a variable
6705 @cindex location of a variable in memory
6708 @item @emph{Description}:
6709 @code{LOC(X)} returns the address of @var{X} as an integer.
6711 @item @emph{Standard}:
6717 @item @emph{Syntax}:
6718 @code{RESULT = LOC(X)}
6720 @item @emph{Arguments}:
6721 @multitable @columnfractions .15 .70
6722 @item @var{X} @tab Variable of any type.
6725 @item @emph{Return value}:
6726 The return value is of type @code{INTEGER}, with a @code{KIND}
6727 corresponding to the size (in bytes) of a memory address on the target
6730 @item @emph{Example}:
6737 end program test_loc
6744 @section @code{LOG} --- Logarithm function
6751 @cindex exponential function, inverse
6752 @cindex logarithmic function
6755 @item @emph{Description}:
6756 @code{LOG(X)} computes the logarithm of @var{X}.
6758 @item @emph{Standard}:
6764 @item @emph{Syntax}:
6765 @code{RESULT = LOG(X)}
6767 @item @emph{Arguments}:
6768 @multitable @columnfractions .15 .70
6769 @item @var{X} @tab The type shall be @code{REAL(*)} or
6773 @item @emph{Return value}:
6774 The return value is of type @code{REAL(*)} or @code{COMPLEX(*)}.
6775 The kind type parameter is the same as @var{X}.
6777 @item @emph{Example}:
6780 real(8) :: x = 1.0_8
6781 complex :: z = (1.0, 2.0)
6784 end program test_log
6787 @item @emph{Specific names}:
6788 @multitable @columnfractions .20 .20 .20 .25
6789 @item Name @tab Argument @tab Return type @tab Standard
6790 @item @code{ALOG(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab f95, gnu
6791 @item @code{DLOG(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
6792 @item @code{CLOG(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab f95, gnu
6793 @item @code{ZLOG(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
6794 @item @code{CDLOG(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
6801 @section @code{LOG10} --- Base 10 logarithm function
6805 @cindex exponential function, inverse
6806 @cindex logarithmic function
6809 @item @emph{Description}:
6810 @code{LOG10(X)} computes the base 10 logarithm of @var{X}.
6812 @item @emph{Standard}:
6818 @item @emph{Syntax}:
6819 @code{RESULT = LOG10(X)}
6821 @item @emph{Arguments}:
6822 @multitable @columnfractions .15 .70
6823 @item @var{X} @tab The type shall be @code{REAL(*)}.
6826 @item @emph{Return value}:
6827 The return value is of type @code{REAL(*)} or @code{COMPLEX(*)}.
6828 The kind type parameter is the same as @var{X}.
6830 @item @emph{Example}:
6833 real(8) :: x = 10.0_8
6835 end program test_log10
6838 @item @emph{Specific names}:
6839 @multitable @columnfractions .20 .20 .20 .25
6840 @item Name @tab Argument @tab Return type @tab Standard
6841 @item @code{ALOG10(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab F95 and later
6842 @item @code{DLOG10(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
6849 @section @code{LOGICAL} --- Convert to logical type
6851 @cindex conversion, to logical
6854 @item @emph{Description}:
6855 Converts one kind of @code{LOGICAL} variable to another.
6857 @item @emph{Standard}:
6863 @item @emph{Syntax}:
6864 @code{RESULT = LOGICAL(L [, KIND])}
6866 @item @emph{Arguments}:
6867 @multitable @columnfractions .15 .70
6868 @item @var{L} @tab The type shall be @code{LOGICAL(*)}.
6869 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
6870 expression indicating the kind parameter of
6874 @item @emph{Return value}:
6875 The return value is a @code{LOGICAL} value equal to @var{L}, with a
6876 kind corresponding to @var{KIND}, or of the default logical kind if
6877 @var{KIND} is not given.
6879 @item @emph{See also}:
6880 @ref{INT}, @ref{REAL}, @ref{CMPLX}
6886 @section @code{LONG} --- Convert to integer type
6888 @cindex conversion, to integer
6891 @item @emph{Description}:
6892 Convert to a @code{KIND=4} integer type, which is the same size as a C
6893 @code{long} integer. This is equivalent to the standard @code{INT}
6894 intrinsic with an optional argument of @code{KIND=4}, and is only
6895 included for backwards compatibility.
6897 @item @emph{Standard}:
6903 @item @emph{Syntax}:
6904 @code{RESULT = LONG(A)}
6906 @item @emph{Arguments}:
6907 @multitable @columnfractions .15 .70
6908 @item @var{A} @tab Shall be of type @code{INTEGER(*)},
6909 @code{REAL(*)}, or @code{COMPLEX(*)}.
6912 @item @emph{Return value}:
6913 The return value is a @code{INTEGER(4)} variable.
6915 @item @emph{See also}:
6916 @ref{INT}, @ref{INT2}, @ref{INT8}
6922 @section @code{LSHIFT} --- Left shift bits
6924 @cindex bits, shift left
6927 @item @emph{Description}:
6928 @code{LSHIFT} returns a value corresponding to @var{I} with all of the
6929 bits shifted left by @var{SHIFT} places. If the absolute value of
6930 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
6931 Bits shifted out from the left end are lost; zeros are shifted in from
6934 This function has been superseded by the @code{ISHFT} intrinsic, which
6935 is standard in Fortran 95 and later.
6937 @item @emph{Standard}:
6943 @item @emph{Syntax}:
6944 @code{RESULT = LSHIFT(I, SHIFT)}
6946 @item @emph{Arguments}:
6947 @multitable @columnfractions .15 .70
6948 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
6949 @item @var{SHIFT} @tab The type shall be @code{INTEGER(*)}.
6952 @item @emph{Return value}:
6953 The return value is of type @code{INTEGER(*)} and of the same kind as
6956 @item @emph{See also}:
6957 @ref{ISHFT}, @ref{ISHFTC}, @ref{RSHIFT}
6964 @section @code{LSTAT} --- Get file status
6966 @cindex file system, file status
6969 @item @emph{Description}:
6970 @code{LSTAT} is identical to @ref{STAT}, except that if path is a symbolic link,
6971 then the link itself is statted, not the file that it refers to.
6973 The elements in @code{BUFF} are the same as described by @ref{STAT}.
6975 This intrinsic is provided in both subroutine and function forms; however,
6976 only one form can be used in any given program unit.
6978 @item @emph{Standard}:
6982 Subroutine, function
6984 @item @emph{Syntax}:
6985 @code{CALL LSTAT(FILE, BUFF [, STATUS])}
6987 @item @emph{Arguments}:
6988 @multitable @columnfractions .15 .70
6989 @item @var{FILE} @tab The type shall be @code{CHARACTER(*)}, a valid path within the file system.
6990 @item @var{BUFF} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
6991 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0
6992 on success and a system specific error code otherwise.
6995 @item @emph{Example}:
6996 See @ref{STAT} for an example.
6998 @item @emph{See also}:
6999 To stat an open file: @ref{FSTAT}, to stat a file: @ref{STAT}
7005 @section @code{LTIME} --- Convert time to local time info
7007 @cindex time, conversion to local time info
7010 @item @emph{Description}:
7011 Given a system time value @var{STIME} (as provided by the @code{TIME8()}
7012 intrinsic), fills @var{TARRAY} with values extracted from it appropriate
7013 to the local time zone using @code{localtime(3)}.
7015 @item @emph{Standard}:
7021 @item @emph{Syntax}:
7022 @code{CALL LTIME(STIME, TARRAY)}
7024 @item @emph{Arguments}:
7025 @multitable @columnfractions .15 .70
7026 @item @var{STIME} @tab An @code{INTEGER(*)} scalar expression
7027 corresponding to a system time, with
7029 @item @var{TARRAY} @tab A default @code{INTEGER} array with 9 elements,
7030 with @code{INTENT(OUT)}.
7033 @item @emph{Return value}:
7034 The elements of @var{TARRAY} are assigned as follows:
7036 @item Seconds after the minute, range 0--59 or 0--61 to allow for leap
7038 @item Minutes after the hour, range 0--59
7039 @item Hours past midnight, range 0--23
7040 @item Day of month, range 0--31
7041 @item Number of months since January, range 0--12
7042 @item Years since 1900
7043 @item Number of days since Sunday, range 0--6
7044 @item Days since January 1
7045 @item Daylight savings indicator: positive if daylight savings is in
7046 effect, zero if not, and negative if the information is not
7050 @item @emph{See also}:
7051 @ref{CTIME}, @ref{GMTIME}, @ref{TIME}, @ref{TIME8}
7058 @section @code{MALLOC} --- Allocate dynamic memory
7060 @cindex pointer, cray
7063 @item @emph{Description}:
7064 @code{MALLOC(SIZE)} allocates @var{SIZE} bytes of dynamic memory and
7065 returns the address of the allocated memory. The @code{MALLOC} intrinsic
7066 is an extension intended to be used with Cray pointers, and is provided
7067 in GNU Fortran to allow the user to compile legacy code. For new code
7068 using Fortran 95 pointers, the memory allocation intrinsic is
7071 @item @emph{Standard}:
7077 @item @emph{Syntax}:
7078 @code{PTR = MALLOC(SIZE)}
7080 @item @emph{Arguments}:
7081 @multitable @columnfractions .15 .70
7082 @item @var{SIZE} @tab The type shall be @code{INTEGER(*)}.
7085 @item @emph{Return value}:
7086 The return value is of type @code{INTEGER(K)}, with @var{K} such that
7087 variables of type @code{INTEGER(K)} have the same size as
7088 C pointers (@code{sizeof(void *)}).
7090 @item @emph{Example}:
7091 The following example demonstrates the use of @code{MALLOC} and
7092 @code{FREE} with Cray pointers. This example is intended to run on
7093 32-bit systems, where the default integer kind is suitable to store
7094 pointers; on 64-bit systems, ptr_x would need to be declared as
7095 @code{integer(kind=8)}.
7104 ptr_x = malloc(20*8)
7106 x(i) = sqrt(1.0d0 / i)
7114 end program test_malloc
7117 @item @emph{See also}:
7124 @section @code{MATMUL} --- matrix multiplication
7126 @cindex matrix multiplication
7127 @cindex product, matrix
7130 @item @emph{Description}:
7131 Performs a matrix multiplication on numeric or logical arguments.
7133 @item @emph{Standard}:
7137 Transformational function
7139 @item @emph{Syntax}:
7140 @code{RESULT = MATMUL(MATRIX_A, MATRIX_B)}
7142 @item @emph{Arguments}:
7143 @multitable @columnfractions .15 .70
7144 @item @var{MATRIX_A} @tab An array of @code{INTEGER(*)},
7145 @code{REAL(*)}, @code{COMPLEX(*)}, or
7146 @code{LOGICAL(*)} type, with a rank of
7148 @item @var{MATRIX_B} @tab An array of @code{INTEGER(*)},
7149 @code{REAL(*)}, or @code{COMPLEX(*)} type if
7150 @var{MATRIX_A} is of a numeric type;
7151 otherwise, an array of @code{LOGICAL(*)}
7152 type. The rank shall be one or two, and the
7153 first (or only) dimension of @var{MATRIX_B}
7154 shall be equal to the last (or only)
7155 dimension of @var{MATRIX_A}.
7158 @item @emph{Return value}:
7159 The matrix product of @var{MATRIX_A} and @var{MATRIX_B}. The type and
7160 kind of the result follow the usual type and kind promotion rules, as
7161 for the @code{*} or @code{.AND.} operators.
7163 @item @emph{See also}:
7169 @section @code{MAX} --- Maximum value of an argument list
7176 @cindex maximum value
7179 @item @emph{Description}:
7180 Returns the argument with the largest (most positive) value.
7182 @item @emph{Standard}:
7188 @item @emph{Syntax}:
7189 @code{RESULT = MAX(A1, A2 [, A3 [, ...]])}
7191 @item @emph{Arguments}:
7192 @multitable @columnfractions .15 .70
7193 @item @var{A1} @tab The type shall be @code{INTEGER(*)} or
7195 @item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
7196 as @var{A1}. (As a GNU extension,
7197 arguments of different kinds are
7201 @item @emph{Return value}:
7202 The return value corresponds to the maximum value among the arguments,
7203 and has the same type and kind as the first argument.
7205 @item @emph{Specific names}:
7206 @multitable @columnfractions .20 .20 .20 .25
7207 @item Name @tab Argument @tab Return type @tab Standard
7208 @item @code{MAX0(I)} @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)} @tab F77 and later
7209 @item @code{AMAX0(I)} @tab @code{INTEGER(4) I} @tab @code{REAL(MAX(X))} @tab F77 and later
7210 @item @code{MAX1(X)} @tab @code{REAL(*) X} @tab @code{INT(MAX(X))} @tab F77 and later
7211 @item @code{AMAX1(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab F77 and later
7212 @item @code{DMAX1(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
7215 @item @emph{See also}:
7216 @ref{MAXLOC} @ref{MAXVAL}, @ref{MIN}
7223 @section @code{MAXEXPONENT} --- Maximum exponent of a real kind
7224 @fnindex MAXEXPONENT
7225 @cindex model representation, maximum exponent
7228 @item @emph{Description}:
7229 @code{MAXEXPONENT(X)} returns the maximum exponent in the model of the
7232 @item @emph{Standard}:
7238 @item @emph{Syntax}:
7239 @code{RESULT = MAXEXPONENT(X)}
7241 @item @emph{Arguments}:
7242 @multitable @columnfractions .15 .70
7243 @item @var{X} @tab Shall be of type @code{REAL}.
7246 @item @emph{Return value}:
7247 The return value is of type @code{INTEGER} and of the default integer
7250 @item @emph{Example}:
7256 print *, minexponent(x), maxexponent(x)
7257 print *, minexponent(y), maxexponent(y)
7258 end program exponents
7265 @section @code{MAXLOC} --- Location of the maximum value within an array
7267 @cindex array, location of maximum element
7270 @item @emph{Description}:
7271 Determines the location of the element in the array with the maximum
7272 value, or, if the @var{DIM} argument is supplied, determines the
7273 locations of the maximum element along each row of the array in the
7274 @var{DIM} direction. If @var{MASK} is present, only the elements for
7275 which @var{MASK} is @code{.TRUE.} are considered. If more than one
7276 element in the array has the maximum value, the location returned is
7277 that of the first such element in array element order. If the array has
7278 zero size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
7279 the result is an array of zeroes. Similarly, if @var{DIM} is supplied
7280 and all of the elements of @var{MASK} along a given row are zero, the
7281 result value for that row is zero.
7283 @item @emph{Standard}:
7287 Transformational function
7289 @item @emph{Syntax}:
7290 @multitable @columnfractions .80
7291 @item @code{RESULT = MAXLOC(ARRAY, DIM [, MASK])}
7292 @item @code{RESULT = MAXLOC(ARRAY [, MASK])}
7295 @item @emph{Arguments}:
7296 @multitable @columnfractions .15 .70
7297 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER(*)},
7298 @code{REAL(*)}, or @code{CHARACTER(*)}.
7299 @item @var{DIM} @tab (Optional) Shall be a scalar of type
7300 @code{INTEGER(*)}, with a value between one
7301 and the rank of @var{ARRAY}, inclusive. It
7302 may not be an optional dummy argument.
7303 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL(*)},
7304 and conformable with @var{ARRAY}.
7307 @item @emph{Return value}:
7308 If @var{DIM} is absent, the result is a rank-one array with a length
7309 equal to the rank of @var{ARRAY}. If @var{DIM} is present, the result
7310 is an array with a rank one less than the rank of @var{ARRAY}, and a
7311 size corresponding to the size of @var{ARRAY} with the @var{DIM}
7312 dimension removed. If @var{DIM} is present and @var{ARRAY} has a rank
7313 of one, the result is a scalar. In all cases, the result is of default
7314 @code{INTEGER} type.
7316 @item @emph{See also}:
7317 @ref{MAX}, @ref{MAXVAL}
7324 @section @code{MAXVAL} --- Maximum value of an array
7326 @cindex array, maximum value
7327 @cindex maximum value
7330 @item @emph{Description}:
7331 Determines the maximum value of the elements in an array value, or, if
7332 the @var{DIM} argument is supplied, determines the maximum value along
7333 each row of the array in the @var{DIM} direction. If @var{MASK} is
7334 present, only the elements for which @var{MASK} is @code{.TRUE.} are
7335 considered. If the array has zero size, or all of the elements of
7336 @var{MASK} are @code{.FALSE.}, then the result is the most negative
7337 number of the type and kind of @var{ARRAY} if @var{ARRAY} is numeric, or
7338 a string of nulls if @var{ARRAY} is of character type.
7340 @item @emph{Standard}:
7344 Transformational function
7346 @item @emph{Syntax}:
7347 @multitable @columnfractions .80
7348 @item @code{RESULT = MAXVAL(ARRAY, DIM [, MASK])}
7349 @item @code{RESULT = MAXVAL(ARRAY [, MASK])}
7352 @item @emph{Arguments}:
7353 @multitable @columnfractions .15 .70
7354 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER(*)},
7355 @code{REAL(*)}, or @code{CHARACTER(*)}.
7356 @item @var{DIM} @tab (Optional) Shall be a scalar of type
7357 @code{INTEGER(*)}, with a value between one
7358 and the rank of @var{ARRAY}, inclusive. It
7359 may not be an optional dummy argument.
7360 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL(*)},
7361 and conformable with @var{ARRAY}.
7364 @item @emph{Return value}:
7365 If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
7366 is a scalar. If @var{DIM} is present, the result is an array with a
7367 rank one less than the rank of @var{ARRAY}, and a size corresponding to
7368 the size of @var{ARRAY} with the @var{DIM} dimension removed. In all
7369 cases, the result is of the same type and kind as @var{ARRAY}.
7371 @item @emph{See also}:
7372 @ref{MAX}, @ref{MAXLOC}
7378 @section @code{MCLOCK} --- Time function
7380 @cindex time, clock ticks
7384 @item @emph{Description}:
7385 Returns the number of clock ticks since the start of the process, based
7386 on the UNIX function @code{clock(3)}.
7388 This intrinsic is not fully portable, such as to systems with 32-bit
7389 @code{INTEGER} types but supporting times wider than 32 bits. Therefore,
7390 the values returned by this intrinsic might be, or become, negative, or
7391 numerically less than previous values, during a single run of the
7394 @item @emph{Standard}:
7400 @item @emph{Syntax}:
7401 @code{RESULT = MCLOCK()}
7403 @item @emph{Return value}:
7404 The return value is a scalar of type @code{INTEGER(4)}, equal to the
7405 number of clock ticks since the start of the process, or @code{-1} if
7406 the system does not support @code{clock(3)}.
7408 @item @emph{See also}:
7409 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME}
7416 @section @code{MCLOCK8} --- Time function (64-bit)
7418 @cindex time, clock ticks
7422 @item @emph{Description}:
7423 Returns the number of clock ticks since the start of the process, based
7424 on the UNIX function @code{clock(3)}.
7426 @emph{Warning:} this intrinsic does not increase the range of the timing
7427 values over that returned by @code{clock(3)}. On a system with a 32-bit
7428 @code{clock(3)}, @code{MCLOCK8()} will return a 32-bit value, even though
7429 it is converted to a 64-bit @code{INTEGER(8)} value. That means
7430 overflows of the 32-bit value can still occur. Therefore, the values
7431 returned by this intrinsic might be or become negative or numerically
7432 less than previous values during a single run of the compiled program.
7434 @item @emph{Standard}:
7440 @item @emph{Syntax}:
7441 @code{RESULT = MCLOCK8()}
7443 @item @emph{Return value}:
7444 The return value is a scalar of type @code{INTEGER(8)}, equal to the
7445 number of clock ticks since the start of the process, or @code{-1} if
7446 the system does not support @code{clock(3)}.
7448 @item @emph{See also}:
7449 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME8}
7456 @section @code{MERGE} --- Merge variables
7458 @cindex array, merge arrays
7459 @cindex array, combine arrays
7462 @item @emph{Description}:
7463 Select values from two arrays according to a logical mask. The result
7464 is equal to @var{TSOURCE} if @var{MASK} is @code{.TRUE.}, or equal to
7465 @var{FSOURCE} if it is @code{.FALSE.}.
7467 @item @emph{Standard}:
7473 @item @emph{Syntax}:
7474 @code{RESULT = MERGE(TSOURCE, FSOURCE, MASK)}
7476 @item @emph{Arguments}:
7477 @multitable @columnfractions .15 .70
7478 @item @var{TSOURCE} @tab May be of any type.
7479 @item @var{FSOURCE} @tab Shall be of the same type and type parameters
7481 @item @var{MASK} @tab Shall be of type @code{LOGICAL(*)}.
7484 @item @emph{Return value}:
7485 The result is of the same type and type parameters as @var{TSOURCE}.
7492 @section @code{MIN} --- Minimum value of an argument list
7499 @cindex minimum value
7502 @item @emph{Description}:
7503 Returns the argument with the smallest (most negative) value.
7505 @item @emph{Standard}:
7511 @item @emph{Syntax}:
7512 @code{RESULT = MIN(A1, A2 [, A3, ...])}
7514 @item @emph{Arguments}:
7515 @multitable @columnfractions .15 .70
7516 @item @var{A1} @tab The type shall be @code{INTEGER(*)} or
7518 @item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
7519 as @var{A1}. (As a GNU extension,
7520 arguments of different kinds are
7524 @item @emph{Return value}:
7525 The return value corresponds to the maximum value among the arguments,
7526 and has the same type and kind as the first argument.
7528 @item @emph{Specific names}:
7529 @multitable @columnfractions .20 .20 .20 .25
7530 @item Name @tab Argument @tab Return type @tab Standard
7531 @item @code{MIN0(I)} @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)} @tab F77 and later
7532 @item @code{AMIN0(I)} @tab @code{INTEGER(4) I} @tab @code{REAL(MIN(X))} @tab F77 and later
7533 @item @code{MIN1(X)} @tab @code{REAL(*) X} @tab @code{INT(MIN(X))} @tab F77 and later
7534 @item @code{AMIN1(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab F77 and later
7535 @item @code{DMIN1(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
7538 @item @emph{See also}:
7539 @ref{MAX}, @ref{MINLOC}, @ref{MINVAL}
7545 @section @code{MINEXPONENT} --- Minimum exponent of a real kind
7546 @fnindex MINEXPONENT
7547 @cindex model representation, minimum exponent
7550 @item @emph{Description}:
7551 @code{MINEXPONENT(X)} returns the minimum exponent in the model of the
7554 @item @emph{Standard}:
7560 @item @emph{Syntax}:
7561 @code{RESULT = MINEXPONENT(X)}
7563 @item @emph{Arguments}:
7564 @multitable @columnfractions .15 .70
7565 @item @var{X} @tab Shall be of type @code{REAL}.
7568 @item @emph{Return value}:
7569 The return value is of type @code{INTEGER} and of the default integer
7572 @item @emph{Example}:
7573 See @code{MAXEXPONENT} for an example.
7579 @section @code{MINLOC} --- Location of the minimum value within an array
7581 @cindex array, location of minimum element
7584 @item @emph{Description}:
7585 Determines the location of the element in the array with the minimum
7586 value, or, if the @var{DIM} argument is supplied, determines the
7587 locations of the minimum element along each row of the array in the
7588 @var{DIM} direction. If @var{MASK} is present, only the elements for
7589 which @var{MASK} is @code{.TRUE.} are considered. If more than one
7590 element in the array has the minimum value, the location returned is
7591 that of the first such element in array element order. If the array has
7592 zero size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
7593 the result is an array of zeroes. Similarly, if @var{DIM} is supplied
7594 and all of the elements of @var{MASK} along a given row are zero, the
7595 result value for that row is zero.
7597 @item @emph{Standard}:
7601 Transformational function
7603 @item @emph{Syntax}:
7604 @multitable @columnfractions .80
7605 @item @code{RESULT = MINLOC(ARRAY, DIM [, MASK])}
7606 @item @code{RESULT = MINLOC(ARRAY [, MASK])}
7609 @item @emph{Arguments}:
7610 @multitable @columnfractions .15 .70
7611 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER(*)},
7612 @code{REAL(*)}, or @code{CHARACTER(*)}.
7613 @item @var{DIM} @tab (Optional) Shall be a scalar of type
7614 @code{INTEGER(*)}, with a value between one
7615 and the rank of @var{ARRAY}, inclusive. It
7616 may not be an optional dummy argument.
7617 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL(*)},
7618 and conformable with @var{ARRAY}.
7621 @item @emph{Return value}:
7622 If @var{DIM} is absent, the result is a rank-one array with a length
7623 equal to the rank of @var{ARRAY}. If @var{DIM} is present, the result
7624 is an array with a rank one less than the rank of @var{ARRAY}, and a
7625 size corresponding to the size of @var{ARRAY} with the @var{DIM}
7626 dimension removed. If @var{DIM} is present and @var{ARRAY} has a rank
7627 of one, the result is a scalar. In all cases, the result is of default
7628 @code{INTEGER} type.
7630 @item @emph{See also}:
7631 @ref{MIN}, @ref{MINVAL}
7638 @section @code{MINVAL} --- Minimum value of an array
7640 @cindex array, minimum value
7641 @cindex minimum value
7644 @item @emph{Description}:
7645 Determines the minimum value of the elements in an array value, or, if
7646 the @var{DIM} argument is supplied, determines the minimum value along
7647 each row of the array in the @var{DIM} direction. If @var{MASK} is
7648 present, only the elements for which @var{MASK} is @code{.TRUE.} are
7649 considered. If the array has zero size, or all of the elements of
7650 @var{MASK} are @code{.FALSE.}, then the result is @code{HUGE(ARRAY)} if
7651 @var{ARRAY} is numeric, or a string of @code{CHAR(255)} characters if
7652 @var{ARRAY} is of character type.
7654 @item @emph{Standard}:
7658 Transformational function
7660 @item @emph{Syntax}:
7661 @multitable @columnfractions .80
7662 @item @code{RESULT = MINVAL(ARRAY, DIM [, MASK])}
7663 @item @code{RESULT = MINVAL(ARRAY [, MASK])}
7666 @item @emph{Arguments}:
7667 @multitable @columnfractions .15 .70
7668 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER(*)},
7669 @code{REAL(*)}, or @code{CHARACTER(*)}.
7670 @item @var{DIM} @tab (Optional) Shall be a scalar of type
7671 @code{INTEGER(*)}, with a value between one
7672 and the rank of @var{ARRAY}, inclusive. It
7673 may not be an optional dummy argument.
7674 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL(*)},
7675 and conformable with @var{ARRAY}.
7678 @item @emph{Return value}:
7679 If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
7680 is a scalar. If @var{DIM} is present, the result is an array with a
7681 rank one less than the rank of @var{ARRAY}, and a size corresponding to
7682 the size of @var{ARRAY} with the @var{DIM} dimension removed. In all
7683 cases, the result is of the same type and kind as @var{ARRAY}.
7685 @item @emph{See also}:
7686 @ref{MIN}, @ref{MINLOC}
7693 @section @code{MOD} --- Remainder function
7698 @cindex division, remainder
7701 @item @emph{Description}:
7702 @code{MOD(A,P)} computes the remainder of the division of A by P. It is
7703 calculated as @code{A - (INT(A/P) * P)}.
7705 @item @emph{Standard}:
7711 @item @emph{Syntax}:
7712 @code{RESULT = MOD(A, P)}
7714 @item @emph{Arguments}:
7715 @multitable @columnfractions .15 .70
7716 @item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL}
7717 @item @var{P} @tab Shall be a scalar of the same type as @var{A} and not
7721 @item @emph{Return value}:
7722 The kind of the return value is the result of cross-promoting
7723 the kinds of the arguments.
7725 @item @emph{Example}:
7729 print *, mod(17.5,5.5)
7730 print *, mod(17.5d0,5.5)
7731 print *, mod(17.5,5.5d0)
7734 print *, mod(-17.5,5.5)
7735 print *, mod(-17.5d0,5.5)
7736 print *, mod(-17.5,5.5d0)
7739 print *, mod(17.5,-5.5)
7740 print *, mod(17.5d0,-5.5)
7741 print *, mod(17.5,-5.5d0)
7742 end program test_mod
7745 @item @emph{Specific names}:
7746 @multitable @columnfractions .20 .20 .20 .25
7747 @item Name @tab Arguments @tab Return type @tab Standard
7748 @item @code{AMOD(A,P)} @tab @code{REAL(4)} @tab @code{REAL(4)} @tab F95 and later
7749 @item @code{DMOD(A,P)} @tab @code{REAL(8)} @tab @code{REAL(8)} @tab F95 and later
7756 @section @code{MODULO} --- Modulo function
7759 @cindex division, modulo
7762 @item @emph{Description}:
7763 @code{MODULO(A,P)} computes the @var{A} modulo @var{P}.
7765 @item @emph{Standard}:
7771 @item @emph{Syntax}:
7772 @code{RESULT = MODULO(A, P)}
7774 @item @emph{Arguments}:
7775 @multitable @columnfractions .15 .70
7776 @item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL}
7777 @item @var{P} @tab Shall be a scalar of the same type and kind as @var{A}
7780 @item @emph{Return value}:
7781 The type and kind of the result are those of the arguments.
7783 @item If @var{A} and @var{P} are of type @code{INTEGER}:
7784 @code{MODULO(A,P)} has the value @var{R} such that @code{A=Q*P+R}, where
7785 @var{Q} is an integer and @var{R} is between 0 (inclusive) and @var{P}
7787 @item If @var{A} and @var{P} are of type @code{REAL}:
7788 @code{MODULO(A,P)} has the value of @code{A - FLOOR (A / P) * P}.
7790 In all cases, if @var{P} is zero the result is processor-dependent.
7792 @item @emph{Example}:
7795 print *, modulo(17,3)
7796 print *, modulo(17.5,5.5)
7798 print *, modulo(-17,3)
7799 print *, modulo(-17.5,5.5)
7801 print *, modulo(17,-3)
7802 print *, modulo(17.5,-5.5)
7811 @section @code{MOVE_ALLOC} --- Move allocation from one object to another
7813 @cindex moving allocation
7814 @cindex allocation, moving
7817 @item @emph{Description}:
7818 @code{MOVE_ALLOC(SRC, DEST)} moves the allocation from @var{SRC} to
7819 @var{DEST}. @var{SRC} will become deallocated in the process.
7821 @item @emph{Standard}:
7827 @item @emph{Syntax}:
7828 @code{CALL MOVE_ALLOC(SRC, DEST)}
7830 @item @emph{Arguments}:
7831 @multitable @columnfractions .15 .70
7832 @item @var{SRC} @tab @code{ALLOCATABLE}, @code{INTENT(INOUT)}, may be
7833 of any type and kind.
7834 @item @var{DEST} @tab @code{ALLOCATABLE}, @code{INTENT(OUT)}, shall be
7835 of the same type, kind and rank as @var{SRC}
7838 @item @emph{Return value}:
7841 @item @emph{Example}:
7843 program test_move_alloc
7844 integer, allocatable :: a(:), b(:)
7848 call move_alloc(a, b)
7849 print *, allocated(a), allocated(b)
7851 end program test_move_alloc
7858 @section @code{MVBITS} --- Move bits from one integer to another
7863 @item @emph{Description}:
7864 Moves @var{LEN} bits from positions @var{FROMPOS} through
7865 @code{FROMPOS+LEN-1} of @var{FROM} to positions @var{TOPOS} through
7866 @code{TOPOS+LEN-1} of @var{TO}. The portion of argument @var{TO} not
7867 affected by the movement of bits is unchanged. The values of
7868 @code{FROMPOS+LEN-1} and @code{TOPOS+LEN-1} must be less than
7869 @code{BIT_SIZE(FROM)}.
7871 @item @emph{Standard}:
7875 Elemental subroutine
7877 @item @emph{Syntax}:
7878 @code{CALL MVBITS(FROM, FROMPOS, LEN, TO, TOPOS)}
7880 @item @emph{Arguments}:
7881 @multitable @columnfractions .15 .70
7882 @item @var{FROM} @tab The type shall be @code{INTEGER(*)}.
7883 @item @var{FROMPOS} @tab The type shall be @code{INTEGER(*)}.
7884 @item @var{LEN} @tab The type shall be @code{INTEGER(*)}.
7885 @item @var{TO} @tab The type shall be @code{INTEGER(*)}, of the
7886 same kind as @var{FROM}.
7887 @item @var{TOPOS} @tab The type shall be @code{INTEGER(*)}.
7890 @item @emph{See also}:
7891 @ref{IBCLR}, @ref{IBSET}, @ref{IBITS}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
7897 @section @code{NEAREST} --- Nearest representable number
7899 @cindex real number, nearest different
7900 @cindex floating point, nearest different
7903 @item @emph{Description}:
7904 @code{NEAREST(X, S)} returns the processor-representable number nearest
7905 to @code{X} in the direction indicated by the sign of @code{S}.
7907 @item @emph{Standard}:
7913 @item @emph{Syntax}:
7914 @code{RESULT = NEAREST(X, S)}
7916 @item @emph{Arguments}:
7917 @multitable @columnfractions .15 .70
7918 @item @var{X} @tab Shall be of type @code{REAL}.
7919 @item @var{S} @tab (Optional) shall be of type @code{REAL} and
7923 @item @emph{Return value}:
7924 The return value is of the same type as @code{X}. If @code{S} is
7925 positive, @code{NEAREST} returns the processor-representable number
7926 greater than @code{X} and nearest to it. If @code{S} is negative,
7927 @code{NEAREST} returns the processor-representable number smaller than
7928 @code{X} and nearest to it.
7930 @item @emph{Example}:
7932 program test_nearest
7934 x = nearest(42.0, 1.0)
7935 y = nearest(42.0, -1.0)
7936 write (*,"(3(G20.15))") x, y, x - y
7937 end program test_nearest
7944 @section @code{NEW_LINE} --- New line character
7947 @cindex output, newline
7950 @item @emph{Description}:
7951 @code{NEW_LINE(C)} returns the new-line character.
7953 @item @emph{Standard}:
7959 @item @emph{Syntax}:
7960 @code{RESULT = NEW_LINE(C)}
7962 @item @emph{Arguments}:
7963 @multitable @columnfractions .15 .70
7964 @item @var{C} @tab The argument shall be a scalar or array of the
7965 type @code{CHARACTER}.
7968 @item @emph{Return value}:
7969 Returns a @var{CHARACTER} scalar of length one with the new-line character of
7970 the same kind as parameter @var{C}.
7972 @item @emph{Example}:
7976 write(*,'(A)') 'This is record 1.'//NEW_LINE('A')//'This is record 2.'
7984 @section @code{NINT} --- Nearest whole number
7987 @cindex rounding, nearest whole number
7990 @item @emph{Description}:
7991 @code{NINT(X)} rounds its argument to the nearest whole number.
7993 @item @emph{Standard}:
7999 @item @emph{Syntax}:
8000 @code{RESULT = NINT(X)}
8002 @item @emph{Arguments}:
8003 @multitable @columnfractions .15 .70
8004 @item @var{X} @tab The type of the argument shall be @code{REAL}.
8007 @item @emph{Return value}:
8008 Returns @var{A} with the fractional portion of its magnitude eliminated by
8009 rounding to the nearest whole number and with its sign preserved,
8010 converted to an @code{INTEGER} of the default kind.
8012 @item @emph{Example}:
8019 print *, nint(x4), idnint(x8)
8020 end program test_nint
8023 @item @emph{Specific names}:
8024 @multitable @columnfractions .25 .25 .25
8025 @item Name @tab Argument @tab Standard
8026 @item @code{IDNINT(X)} @tab @code{REAL(8)} @tab F95 and later
8029 @item @emph{See also}:
8030 @ref{CEILING}, @ref{FLOOR}
8037 @section @code{NOT} --- Logical negation
8039 @cindex bits, negate
8040 @cindex bitwise logical not
8041 @cindex logical not, bitwise
8044 @item @emph{Description}:
8045 @code{NOT} returns the bitwise boolean inverse of @var{I}.
8047 @item @emph{Standard}:
8053 @item @emph{Syntax}:
8054 @code{RESULT = NOT(I)}
8056 @item @emph{Arguments}:
8057 @multitable @columnfractions .15 .70
8058 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
8061 @item @emph{Return value}:
8062 The return type is @code{INTEGER(*)}, of the same kind as the
8065 @item @emph{See also}:
8066 @ref{IAND}, @ref{IEOR}, @ref{IOR}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}
8073 @section @code{NULL} --- Function that returns an disassociated pointer
8075 @cindex pointer, status
8076 @cindex pointer, disassociated
8079 @item @emph{Description}:
8080 Returns a disassociated pointer.
8082 If @var{MOLD} is present, a dissassociated pointer of the same type is
8083 returned, otherwise the type is determined by context.
8085 In Fortran 95, @var{MOLD} is optional. Please note that F2003 includes
8086 cases where it is required.
8088 @item @emph{Standard}:
8092 Transformational function
8094 @item @emph{Syntax}:
8095 @code{PTR => NULL([MOLD])}
8097 @item @emph{Arguments}:
8098 @multitable @columnfractions .15 .70
8099 @item @var{MOLD} @tab (Optional) shall be a pointer of any association
8100 status and of any type.
8103 @item @emph{Return value}:
8104 A disassociated pointer.
8106 @item @emph{Example}:
8108 REAL, POINTER, DIMENSION(:) :: VEC => NULL ()
8111 @item @emph{See also}:
8118 @section @code{OR} --- Bitwise logical OR
8120 @cindex bitwise logical or
8121 @cindex logical or, bitwise
8124 @item @emph{Description}:
8125 Bitwise logical @code{OR}.
8127 This intrinsic routine is provided for backwards compatibility with
8128 GNU Fortran 77. For integer arguments, programmers should consider
8129 the use of the @ref{IOR} intrinsic defined by the Fortran standard.
8131 @item @emph{Standard}:
8137 @item @emph{Syntax}:
8138 @code{RESULT = OR(X, Y)}
8140 @item @emph{Arguments}:
8141 @multitable @columnfractions .15 .70
8142 @item @var{X} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
8143 @item @var{Y} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
8146 @item @emph{Return value}:
8147 The return type is either @code{INTEGER(*)} or @code{LOGICAL}
8148 after cross-promotion of the arguments.
8150 @item @emph{Example}:
8153 LOGICAL :: T = .TRUE., F = .FALSE.
8155 DATA a / Z'F' /, b / Z'3' /
8157 WRITE (*,*) OR(T, T), OR(T, F), OR(F, T), OR(F, F)
8158 WRITE (*,*) OR(a, b)
8162 @item @emph{See also}:
8163 F95 elemental function: @ref{IOR}
8169 @section @code{PACK} --- Pack an array into an array of rank one
8171 @cindex array, packing
8172 @cindex array, reduce dimension
8173 @cindex array, gather elements
8176 @item @emph{Description}:
8177 Stores the elements of @var{ARRAY} in an array of rank one.
8179 The beginning of the resulting array is made up of elements whose @var{MASK}
8180 equals @code{TRUE}. Afterwards, positions are filled with elements taken from
8183 @item @emph{Standard}:
8187 Transformational function
8189 @item @emph{Syntax}:
8190 @code{RESULT = PACK(ARRAY, MASK[,VECTOR]}
8192 @item @emph{Arguments}:
8193 @multitable @columnfractions .15 .70
8194 @item @var{ARRAY} @tab Shall be an array of any type.
8195 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL} and
8196 of the same size as @var{ARRAY}. Alternatively, it may be a @code{LOGICAL}
8198 @item @var{VECTOR} @tab (Optional) shall be an array of the same type
8199 as @var{ARRAY} and of rank one. If present, the number of elements in
8200 @var{VECTOR} shall be equal to or greater than the number of true elements
8201 in @var{MASK}. If @var{MASK} is scalar, the number of elements in
8202 @var{VECTOR} shall be equal to or greater than the number of elements in
8206 @item @emph{Return value}:
8207 The result is an array of rank one and the same type as that of @var{ARRAY}.
8208 If @var{VECTOR} is present, the result size is that of @var{VECTOR}, the
8209 number of @code{TRUE} values in @var{MASK} otherwise.
8211 @item @emph{Example}:
8212 Gathering nonzero elements from an array:
8216 m = (/ 1, 0, 0, 0, 5, 0 /)
8217 WRITE(*, FMT="(6(I0, ' '))") pack(m, m /= 0) ! "1 5"
8221 Gathering nonzero elements from an array and appending elements from @var{VECTOR}:
8225 m = (/ 1, 0, 0, 2 /)
8226 WRITE(*, FMT="(4(I0, ' '))") pack(m, m /= 0, (/ 0, 0, 3, 4 /)) ! "1 2 3 4"
8230 @item @emph{See also}:
8237 @section @code{PERROR} --- Print system error message
8239 @cindex system, error handling
8242 @item @emph{Description}:
8243 Prints (on the C @code{stderr} stream) a newline-terminated error
8244 message corresponding to the last system error. This is prefixed by
8245 @var{STRING}, a colon and a space. See @code{perror(3)}.
8247 @item @emph{Standard}:
8253 @item @emph{Syntax}:
8254 @code{CALL PERROR(STRING)}
8256 @item @emph{Arguments}:
8257 @multitable @columnfractions .15 .70
8258 @item @var{STRING} @tab A scalar of default @code{CHARACTER} type.
8261 @item @emph{See also}:
8268 @section @code{PRECISION} --- Decimal precision of a real kind
8270 @cindex model representation, precision
8273 @item @emph{Description}:
8274 @code{PRECISION(X)} returns the decimal precision in the model of the
8277 @item @emph{Standard}:
8283 @item @emph{Syntax}:
8284 @code{RESULT = PRECISION(X)}
8286 @item @emph{Arguments}:
8287 @multitable @columnfractions .15 .70
8288 @item @var{X} @tab Shall be of type @code{REAL} or @code{COMPLEX}.
8291 @item @emph{Return value}:
8292 The return value is of type @code{INTEGER} and of the default integer
8295 @item @emph{Example}:
8297 program prec_and_range
8298 real(kind=4) :: x(2)
8299 complex(kind=8) :: y
8301 print *, precision(x), range(x)
8302 print *, precision(y), range(y)
8303 end program prec_and_range
8310 @section @code{PRESENT} --- Determine whether an optional dummy argument is specified
8314 @item @emph{Description}:
8315 Determines whether an optional dummy argument is present.
8317 @item @emph{Standard}:
8323 @item @emph{Syntax}:
8324 @code{RESULT = PRESENT(A)}
8326 @item @emph{Arguments}:
8327 @multitable @columnfractions .15 .70
8328 @item @var{A} @tab May be of any type and may be a pointer, scalar or array
8329 value, or a dummy procedure. It shall be the name of an optional dummy argument
8330 accessible within the current subroutine or function.
8333 @item @emph{Return value}:
8334 Returns either @code{TRUE} if the optional argument @var{A} is present, or
8335 @code{FALSE} otherwise.
8337 @item @emph{Example}:
8339 PROGRAM test_present
8340 WRITE(*,*) f(), f(42) ! "F T"
8342 LOGICAL FUNCTION f(x)
8343 INTEGER, INTENT(IN), OPTIONAL :: x
8353 @section @code{PRODUCT} --- Product of array elements
8355 @cindex array, product
8356 @cindex array, multiply elements
8357 @cindex array, conditionally multiply elements
8358 @cindex multiply array elements
8361 @item @emph{Description}:
8362 Multiplies the elements of @var{ARRAY} along dimension @var{DIM} if
8363 the corresponding element in @var{MASK} is @code{TRUE}.
8365 @item @emph{Standard}:
8369 Transformational function
8371 @item @emph{Syntax}:
8372 @code{RESULT = PRODUCT(ARRAY[, MASK])}
8373 @code{RESULT = PRODUCT(ARRAY, DIM[, MASK])}
8375 @item @emph{Arguments}:
8376 @multitable @columnfractions .15 .70
8377 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER(*)},
8378 @code{REAL(*)} or @code{COMPLEX(*)}.
8379 @item @var{DIM} @tab (Optional) shall be a scalar of type
8380 @code{INTEGER} with a value in the range from 1 to n, where n
8381 equals the rank of @var{ARRAY}.
8382 @item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL}
8383 and either be a scalar or an array of the same shape as @var{ARRAY}.
8386 @item @emph{Return value}:
8387 The result is of the same type as @var{ARRAY}.
8389 If @var{DIM} is absent, a scalar with the product of all elements in
8390 @var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals
8391 the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with
8392 dimension @var{DIM} dropped is returned.
8395 @item @emph{Example}:
8397 PROGRAM test_product
8398 INTEGER :: x(5) = (/ 1, 2, 3, 4 ,5 /)
8399 print *, PRODUCT(x) ! all elements, product = 120
8400 print *, PRODUCT(x, MASK=MOD(x, 2)==1) ! odd elements, product = 15
8404 @item @emph{See also}:
8411 @section @code{RADIX} --- Base of a model number
8413 @cindex model representation, base
8414 @cindex model representation, radix
8417 @item @emph{Description}:
8418 @code{RADIX(X)} returns the base of the model representing the entity @var{X}.
8420 @item @emph{Standard}:
8426 @item @emph{Syntax}:
8427 @code{RESULT = RADIX(X)}
8429 @item @emph{Arguments}:
8430 @multitable @columnfractions .15 .70
8431 @item @var{X} @tab Shall be of type @code{INTEGER} or @code{REAL}
8434 @item @emph{Return value}:
8435 The return value is a scalar of type @code{INTEGER} and of the default
8438 @item @emph{Example}:
8441 print *, "The radix for the default integer kind is", radix(0)
8442 print *, "The radix for the default real kind is", radix(0.0)
8443 end program test_radix
8451 @section @code{RAN} --- Real pseudo-random number
8453 @cindex random number generation
8456 @item @emph{Description}:
8457 For compatibility with HP FORTRAN 77/iX, the @code{RAN} intrinsic is
8458 provided as an alias for @code{RAND}. See @ref{RAND} for complete
8461 @item @emph{Standard}:
8467 @item @emph{See also}:
8468 @ref{RAND}, @ref{RANDOM_NUMBER}
8474 @section @code{RAND} --- Real pseudo-random number
8476 @cindex random number generation
8479 @item @emph{Description}:
8480 @code{RAND(FLAG)} returns a pseudo-random number from a uniform
8481 distribution between 0 and 1. If @var{FLAG} is 0, the next number
8482 in the current sequence is returned; if @var{FLAG} is 1, the generator
8483 is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
8484 it is used as a new seed with @code{SRAND}.
8486 This intrinsic routine is provided for backwards compatibility with
8487 GNU Fortran 77. It implements a simple modulo generator as provided
8488 by @command{g77}. For new code, one should consider the use of
8489 @ref{RANDOM_NUMBER} as it implements a superior algorithm.
8491 @item @emph{Standard}:
8497 @item @emph{Syntax}:
8498 @code{RESULT = RAND(FLAG)}
8500 @item @emph{Arguments}:
8501 @multitable @columnfractions .15 .70
8502 @item @var{FLAG} @tab Shall be a scalar @code{INTEGER} of kind 4.
8505 @item @emph{Return value}:
8506 The return value is of @code{REAL} type and the default kind.
8508 @item @emph{Example}:
8511 integer,parameter :: seed = 86456
8514 print *, rand(), rand(), rand(), rand()
8515 print *, rand(seed), rand(), rand(), rand()
8516 end program test_rand
8519 @item @emph{See also}:
8520 @ref{SRAND}, @ref{RANDOM_NUMBER}
8527 @section @code{RANDOM_NUMBER} --- Pseudo-random number
8528 @fnindex RANDOM_NUMBER
8529 @cindex random number generation
8532 @item @emph{Description}:
8533 Returns a single pseudorandom number or an array of pseudorandom numbers
8534 from the uniform distribution over the range @math{ 0 \leq x < 1}.
8536 The runtime-library implements George Marsaglia's KISS (Keep It Simple
8537 Stupid) random number generator (RNG). This RNG combines:
8539 @item The congruential generator @math{x(n) = 69069 \cdot x(n-1) + 1327217885}
8540 with a period of @math{2^{32}},
8541 @item A 3-shift shift-register generator with a period of @math{2^{32} - 1},
8542 @item Two 16-bit multiply-with-carry generators with a period of
8543 @math{597273182964842497 > 2^{59}}.
8545 The overall period exceeds @math{2^{123}}.
8547 Please note, this RNG is thread safe if used within OpenMP directives,
8548 i. e. its state will be consistent while called from multiple threads.
8549 However, the KISS generator does not create random numbers in parallel
8550 from multiple sources, but in sequence from a single source. If an
8551 OpenMP-enabled application heavily relies on random numbers, one should
8552 consider employing a dedicated parallel random number generator instead.
8554 @item @emph{Standard}:
8560 @item @emph{Syntax}:
8561 @code{RANDOM_NUMBER(HARVEST)}
8563 @item @emph{Arguments}:
8564 @multitable @columnfractions .15 .70
8565 @item @var{HARVEST} @tab Shall be a scalar or an array of type @code{REAL(*)}.
8568 @item @emph{Example}:
8570 program test_random_number
8572 CALL init_random_seed() ! see example of RANDOM_SEED
8573 CALL RANDOM_NUMBER(r)
8577 @item @emph{See also}:
8584 @section @code{RANDOM_SEED} --- Initialize a pseudo-random number sequence
8585 @fnindex RANDOM_SEED
8586 @cindex random number generation, seeding
8587 @cindex seeding a random number generator
8590 @item @emph{Description}:
8591 Restarts or queries the state of the pseudorandom number generator used by
8592 @code{RANDOM_NUMBER}.
8594 If @code{RANDOM_SEED} is called without arguments, it is initialized to
8595 a default state. The example below shows how to initialize the random
8596 seed based on the system's time.
8598 @item @emph{Standard}:
8604 @item @emph{Syntax}:
8605 @code{CALL RANDOM_SEED(SIZE, PUT, GET)}
8607 @item @emph{Arguments}:
8608 @multitable @columnfractions .15 .70
8609 @item @var{SIZE} @tab (Optional) Shall be a scalar and of type default
8610 @code{INTEGER}, with @code{INTENT(OUT)}. It specifies the minimum size
8611 of the arrays used with the @var{PUT} and @var{GET} arguments.
8612 @item @var{PUT} @tab (Optional) Shall be an array of type default
8613 @code{INTEGER} and rank one. It is @code{INTENT(IN)} and the size of
8614 the array must be larger than or equal to the number returned by the
8615 @var{SIZE} argument.
8616 @item @var{GET} @tab (Optional) Shall be an array of type default
8617 @code{INTEGER} and rank one. It is @code{INTENT(OUT)} and the size
8618 of the array must be larger than or equal to the number returned by
8619 the @var{SIZE} argument.
8622 @item @emph{Example}:
8624 SUBROUTINE init_random_seed()
8625 INTEGER :: i, n, clock
8626 INTEGER, DIMENSION(:), ALLOCATABLE :: seed
8628 CALL RANDOM_SEED(size = n)
8631 CALL SYSTEM_CLOCK(COUNT=clock)
8633 seed = clock + 37 * (/ (i - 1, i = 1, n) /)
8634 CALL RANDOM_SEED(PUT = seed)
8640 @item @emph{See also}:
8647 @section @code{RANGE} --- Decimal exponent range of a real kind
8649 @cindex model representation, range
8652 @item @emph{Description}:
8653 @code{RANGE(X)} returns the decimal exponent range in the model of the
8656 @item @emph{Standard}:
8662 @item @emph{Syntax}:
8663 @code{RESULT = RANGE(X)}
8665 @item @emph{Arguments}:
8666 @multitable @columnfractions .15 .70
8667 @item @var{X} @tab Shall be of type @code{REAL} or @code{COMPLEX}.
8670 @item @emph{Return value}:
8671 The return value is of type @code{INTEGER} and of the default integer
8674 @item @emph{Example}:
8675 See @code{PRECISION} for an example.
8681 @section @code{REAL} --- Convert to real type
8684 @cindex conversion, to real
8685 @cindex complex numbers, real part
8688 @item @emph{Description}:
8689 @code{REAL(X [, KIND])} converts its argument @var{X} to a real type. The
8690 @code{REALPART(X)} function is provided for compatibility with @command{g77},
8691 and its use is strongly discouraged.
8693 @item @emph{Standard}:
8699 @item @emph{Syntax}:
8700 @multitable @columnfractions .80
8701 @item @code{RESULT = REAL(X [, KIND])}
8702 @item @code{RESULT = REALPART(Z)}
8705 @item @emph{Arguments}:
8706 @multitable @columnfractions .15 .70
8707 @item @var{X} @tab Shall be @code{INTEGER(*)}, @code{REAL(*)}, or
8709 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
8710 expression indicating the kind parameter of
8714 @item @emph{Return value}:
8715 These functions return a @code{REAL(*)} variable or array under
8716 the following rules:
8720 @code{REAL(X)} is converted to a default real type if @var{X} is an
8721 integer or real variable.
8723 @code{REAL(X)} is converted to a real type with the kind type parameter
8724 of @var{X} if @var{X} is a complex variable.
8726 @code{REAL(X, KIND)} is converted to a real type with kind type
8727 parameter @var{KIND} if @var{X} is a complex, integer, or real
8731 @item @emph{Example}:
8734 complex :: x = (1.0, 2.0)
8735 print *, real(x), real(x,8), realpart(x)
8736 end program test_real
8739 @item @emph{See also}:
8740 @ref{DBLE}, @ref{DFLOAT}, @ref{FLOAT}
8747 @section @code{RENAME} --- Rename a file
8749 @cindex file system, rename file
8752 @item @emph{Description}:
8753 Renames a file from file @var{PATH1} to @var{PATH2}. A null
8754 character (@code{CHAR(0)}) can be used to mark the end of the names in
8755 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
8756 names are ignored. If the @var{STATUS} argument is supplied, it
8757 contains 0 on success or a nonzero error code upon return; see
8760 This intrinsic is provided in both subroutine and function forms;
8761 however, only one form can be used in any given program unit.
8763 @item @emph{Standard}:
8767 Subroutine, function
8769 @item @emph{Syntax}:
8770 @multitable @columnfractions .80
8771 @item @code{CALL RENAME(PATH1, PATH2 [, STATUS])}
8772 @item @code{STATUS = RENAME(PATH1, PATH2)}
8775 @item @emph{Arguments}:
8776 @multitable @columnfractions .15 .70
8777 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
8778 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
8779 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
8782 @item @emph{See also}:
8790 @section @code{REPEAT} --- Repeated string concatenation
8792 @cindex string, repeat
8793 @cindex string, concatenate
8796 @item @emph{Description}:
8797 Concatenates @var{NCOPIES} copies of a string.
8799 @item @emph{Standard}:
8803 Transformational function
8805 @item @emph{Syntax}:
8806 @code{RESULT = REPEAT(STRING, NCOPIES)}
8808 @item @emph{Arguments}:
8809 @multitable @columnfractions .15 .70
8810 @item @var{STRING} @tab Shall be scalar and of type @code{CHARACTER(*)}.
8811 @item @var{NCOPIES} @tab Shall be scalar and of type @code{INTEGER(*)}.
8814 @item @emph{Return value}:
8815 A new scalar of type @code{CHARACTER} built up from @var{NCOPIES} copies
8818 @item @emph{Example}:
8821 write(*,*) repeat("x", 5) ! "xxxxx"
8829 @section @code{RESHAPE} --- Function to reshape an array
8831 @cindex array, change dimensions
8832 @cindex array, transmogrify
8835 @item @emph{Description}:
8836 Reshapes @var{SOURCE} to correspond to @var{SHAPE}. If necessary,
8837 the new array may be padded with elements from @var{PAD} or permuted
8838 as defined by @var{ORDER}.
8840 @item @emph{Standard}:
8844 Transformational function
8846 @item @emph{Syntax}:
8847 @code{RESULT = RESHAPE(SOURCE, SHAPE[, PAD, ORDER])}
8849 @item @emph{Arguments}:
8850 @multitable @columnfractions .15 .70
8851 @item @var{SOURCE} @tab Shall be an array of any type.
8852 @item @var{SHAPE} @tab Shall be of type @code{INTEGER} and an
8853 array of rank one. Its values must be positive or zero.
8854 @item @var{PAD} @tab (Optional) shall be an array of the same
8855 type as @var{SOURCE}.
8856 @item @var{ORDER} @tab (Optional) shall be of type @code{INTEGER}
8857 and an array of the same shape as @var{SHAPE}. Its values shall
8858 be a permutation of the numbers from 1 to n, where n is the size of
8859 @var{SHAPE}. If @var{ORDER} is absent, the natural ordering shall
8863 @item @emph{Return value}:
8864 The result is an array of shape @var{SHAPE} with the same type as
8867 @item @emph{Example}:
8869 PROGRAM test_reshape
8870 INTEGER, DIMENSION(4) :: x
8871 WRITE(*,*) SHAPE(x) ! prints "4"
8872 WRITE(*,*) SHAPE(RESHAPE(x, (/2, 2/))) ! prints "2 2"
8876 @item @emph{See also}:
8883 @section @code{RRSPACING} --- Reciprocal of the relative spacing
8885 @cindex real number, relative spacing
8886 @cindex floating point, relative spacing
8890 @item @emph{Description}:
8891 @code{RRSPACING(X)} returns the reciprocal of the relative spacing of
8892 model numbers near @var{X}.
8894 @item @emph{Standard}:
8900 @item @emph{Syntax}:
8901 @code{RESULT = RRSPACING(X)}
8903 @item @emph{Arguments}:
8904 @multitable @columnfractions .15 .70
8905 @item @var{X} @tab Shall be of type @code{REAL}.
8908 @item @emph{Return value}:
8909 The return value is of the same type and kind as @var{X}.
8910 The value returned is equal to
8911 @code{ABS(FRACTION(X)) * FLOAT(RADIX(X))**DIGITS(X)}.
8913 @item @emph{See also}:
8920 @section @code{RSHIFT} --- Right shift bits
8922 @cindex bits, shift right
8925 @item @emph{Description}:
8926 @code{RSHIFT} returns a value corresponding to @var{I} with all of the
8927 bits shifted right by @var{SHIFT} places. If the absolute value of
8928 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
8929 Bits shifted out from the left end are lost; zeros are shifted in from
8932 This function has been superseded by the @code{ISHFT} intrinsic, which
8933 is standard in Fortran 95 and later.
8935 @item @emph{Standard}:
8941 @item @emph{Syntax}:
8942 @code{RESULT = RSHIFT(I, SHIFT)}
8944 @item @emph{Arguments}:
8945 @multitable @columnfractions .15 .70
8946 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
8947 @item @var{SHIFT} @tab The type shall be @code{INTEGER(*)}.
8950 @item @emph{Return value}:
8951 The return value is of type @code{INTEGER(*)} and of the same kind as
8954 @item @emph{See also}:
8955 @ref{ISHFT}, @ref{ISHFTC}, @ref{LSHIFT}
8962 @section @code{SCALE} --- Scale a real value
8964 @cindex real number, scale
8965 @cindex floating point, scale
8968 @item @emph{Description}:
8969 @code{SCALE(X,I)} returns @code{X * RADIX(X)**I}.
8971 @item @emph{Standard}:
8977 @item @emph{Syntax}:
8978 @code{RESULT = SCALE(X, I)}
8980 @item @emph{Arguments}:
8981 @multitable @columnfractions .15 .70
8982 @item @var{X} @tab The type of the argument shall be a @code{REAL}.
8983 @item @var{I} @tab The type of the argument shall be a @code{INTEGER}.
8986 @item @emph{Return value}:
8987 The return value is of the same type and kind as @var{X}.
8988 Its value is @code{X * RADIX(X)**I}.
8990 @item @emph{Example}:
8993 real :: x = 178.1387e-4
8995 print *, scale(x,i), x*radix(x)**i
8996 end program test_scale
9004 @section @code{SCAN} --- Scan a string for the presence of a set of characters
9006 @cindex string, find subset
9009 @item @emph{Description}:
9010 Scans a @var{STRING} for any of the characters in a @var{SET}
9013 If @var{BACK} is either absent or equals @code{FALSE}, this function
9014 returns the position of the leftmost character of @var{STRING} that is
9015 in @var{SET}. If @var{BACK} equals @code{TRUE}, the rightmost position
9016 is returned. If no character of @var{SET} is found in @var{STRING}, the
9019 @item @emph{Standard}:
9025 @item @emph{Syntax}:
9026 @code{RESULT = SCAN(STRING, SET[, BACK [, KIND]])}
9028 @item @emph{Arguments}:
9029 @multitable @columnfractions .15 .70
9030 @item @var{STRING} @tab Shall be of type @code{CHARACTER(*)}.
9031 @item @var{SET} @tab Shall be of type @code{CHARACTER(*)}.
9032 @item @var{BACK} @tab (Optional) shall be of type @code{LOGICAL}.
9033 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
9034 expression indicating the kind parameter of
9038 @item @emph{Return value}:
9039 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
9040 @var{KIND} is absent, the return value is of default integer kind.
9042 @item @emph{Example}:
9045 WRITE(*,*) SCAN("FORTRAN", "AO") ! 2, found 'O'
9046 WRITE(*,*) SCAN("FORTRAN", "AO", .TRUE.) ! 6, found 'A'
9047 WRITE(*,*) SCAN("FORTRAN", "C++") ! 0, found none
9051 @item @emph{See also}:
9052 @ref{INDEX}, @ref{VERIFY}
9058 @section @code{SECNDS} --- Time function
9060 @cindex time, elapsed
9061 @cindex elapsed time
9064 @item @emph{Description}:
9065 @code{SECNDS(X)} gets the time in seconds from the real-time system clock.
9066 @var{X} is a reference time, also in seconds. If this is zero, the time in
9067 seconds from midnight is returned. This function is non-standard and its
9070 @item @emph{Standard}:
9076 @item @emph{Syntax}:
9077 @code{RESULT = SECNDS (X)}
9079 @item @emph{Arguments}:
9080 @multitable @columnfractions .15 .70
9081 @item @var{T} @tab Shall be of type @code{REAL(4)}.
9082 @item @var{X} @tab Shall be of type @code{REAL(4)}.
9085 @item @emph{Return value}:
9088 @item @emph{Example}:
9093 print *, secnds (0.0) ! seconds since midnight
9094 t1 = secnds (0.0) ! reference time
9095 do i = 1, 10000000 ! do something
9097 t2 = secnds (t1) ! elapsed time
9098 print *, "Something took ", t2, " seconds."
9099 end program test_secnds
9106 @section @code{SECOND} --- CPU time function
9108 @cindex time, elapsed
9109 @cindex elapsed time
9112 @item @emph{Description}:
9113 Returns a @code{REAL(4)} value representing the elapsed CPU time in
9114 seconds. This provides the same functionality as the standard
9115 @code{CPU_TIME} intrinsic, and is only included for backwards
9118 This intrinsic is provided in both subroutine and function forms;
9119 however, only one form can be used in any given program unit.
9121 @item @emph{Standard}:
9125 Subroutine, function
9127 @item @emph{Syntax}:
9128 @multitable @columnfractions .80
9129 @item @code{CALL SECOND(TIME)}
9130 @item @code{TIME = SECOND()}
9133 @item @emph{Arguments}:
9134 @multitable @columnfractions .15 .70
9135 @item @var{TIME} @tab Shall be of type @code{REAL(4)}.
9138 @item @emph{Return value}:
9139 In either syntax, @var{TIME} is set to the process's current runtime in
9142 @item @emph{See also}:
9149 @node SELECTED_INT_KIND
9150 @section @code{SELECTED_INT_KIND} --- Choose integer kind
9151 @fnindex SELECTED_INT_KIND
9152 @cindex integer kind
9153 @cindex kind, integer
9156 @item @emph{Description}:
9157 @code{SELECTED_INT_KIND(I)} return the kind value of the smallest integer
9158 type that can represent all values ranging from @math{-10^I} (exclusive)
9159 to @math{10^I} (exclusive). If there is no integer kind that accommodates
9160 this range, @code{SELECTED_INT_KIND} returns @math{-1}.
9162 @item @emph{Standard}:
9166 Transformational function
9168 @item @emph{Syntax}:
9169 @code{RESULT = SELECTED_INT_KIND(I)}
9171 @item @emph{Arguments}:
9172 @multitable @columnfractions .15 .70
9173 @item @var{I} @tab Shall be a scalar and of type @code{INTEGER}.
9176 @item @emph{Example}:
9178 program large_integers
9179 integer,parameter :: k5 = selected_int_kind(5)
9180 integer,parameter :: k15 = selected_int_kind(15)
9181 integer(kind=k5) :: i5
9182 integer(kind=k15) :: i15
9184 print *, huge(i5), huge(i15)
9186 ! The following inequalities are always true
9187 print *, huge(i5) >= 10_k5**5-1
9188 print *, huge(i15) >= 10_k15**15-1
9189 end program large_integers
9195 @node SELECTED_REAL_KIND
9196 @section @code{SELECTED_REAL_KIND} --- Choose real kind
9197 @fnindex SELECTED_REAL_KIND
9202 @item @emph{Description}:
9203 @code{SELECTED_REAL_KIND(P,R)} return the kind value of a real data type
9204 with decimal precision greater of at least @code{P} digits and exponent
9205 range greater at least @code{R}.
9207 @item @emph{Standard}:
9211 Transformational function
9213 @item @emph{Syntax}:
9214 @code{RESULT = SELECTED_REAL_KIND(P, R)}
9216 @item @emph{Arguments}:
9217 @multitable @columnfractions .15 .70
9218 @item @var{P} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
9219 @item @var{R} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
9221 At least one argument shall be present.
9223 @item @emph{Return value}:
9225 @code{SELECTED_REAL_KIND} returns the value of the kind type parameter of
9226 a real data type with decimal precision of at least @code{P} digits and a
9227 decimal exponent range of at least @code{R}. If more than one real data
9228 type meet the criteria, the kind of the data type with the smallest
9229 decimal precision is returned. If no real data type matches the criteria,
9232 @item -1 if the processor does not support a real data type with a
9233 precision greater than or equal to @code{P}
9234 @item -2 if the processor does not support a real type with an exponent
9235 range greater than or equal to @code{R}
9236 @item -3 if neither is supported.
9239 @item @emph{Example}:
9242 integer,parameter :: p6 = selected_real_kind(6)
9243 integer,parameter :: p10r100 = selected_real_kind(10,100)
9244 integer,parameter :: r400 = selected_real_kind(r=400)
9246 real(kind=p10r100) :: y
9247 real(kind=r400) :: z
9249 print *, precision(x), range(x)
9250 print *, precision(y), range(y)
9251 print *, precision(z), range(z)
9252 end program real_kinds
9259 @section @code{SET_EXPONENT} --- Set the exponent of the model
9260 @fnindex SET_EXPONENT
9261 @cindex real number, set exponent
9262 @cindex floating point, set exponent
9265 @item @emph{Description}:
9266 @code{SET_EXPONENT(X, I)} returns the real number whose fractional part
9267 is that that of @var{X} and whose exponent part is @var{I}.
9269 @item @emph{Standard}:
9275 @item @emph{Syntax}:
9276 @code{RESULT = SET_EXPONENT(X, I)}
9278 @item @emph{Arguments}:
9279 @multitable @columnfractions .15 .70
9280 @item @var{X} @tab Shall be of type @code{REAL}.
9281 @item @var{I} @tab Shall be of type @code{INTEGER}.
9284 @item @emph{Return value}:
9285 The return value is of the same type and kind as @var{X}.
9286 The real number whose fractional part
9287 is that that of @var{X} and whose exponent part if @var{I} is returned;
9288 it is @code{FRACTION(X) * RADIX(X)**I}.
9290 @item @emph{Example}:
9293 REAL :: x = 178.1387e-4
9295 PRINT *, SET_EXPONENT(x, i), FRACTION(x) * RADIX(x)**i
9304 @section @code{SHAPE} --- Determine the shape of an array
9306 @cindex array, shape
9309 @item @emph{Description}:
9310 Determines the shape of an array.
9312 @item @emph{Standard}:
9318 @item @emph{Syntax}:
9319 @code{RESULT = SHAPE(SOURCE)}
9321 @item @emph{Arguments}:
9322 @multitable @columnfractions .15 .70
9323 @item @var{SOURCE} @tab Shall be an array or scalar of any type.
9324 If @var{SOURCE} is a pointer it must be associated and allocatable
9325 arrays must be allocated.
9328 @item @emph{Return value}:
9329 An @code{INTEGER} array of rank one with as many elements as @var{SOURCE}
9330 has dimensions. The elements of the resulting array correspond to the extend
9331 of @var{SOURCE} along the respective dimensions. If @var{SOURCE} is a scalar,
9332 the result is the rank one array of size zero.
9334 @item @emph{Example}:
9337 INTEGER, DIMENSION(-1:1, -1:2) :: A
9338 WRITE(*,*) SHAPE(A) ! (/ 3, 4 /)
9339 WRITE(*,*) SIZE(SHAPE(42)) ! (/ /)
9343 @item @emph{See also}:
9344 @ref{RESHAPE}, @ref{SIZE}
9350 @section @code{SIGN} --- Sign copying function
9354 @cindex sign copying
9357 @item @emph{Description}:
9358 @code{SIGN(A,B)} returns the value of @var{A} with the sign of @var{B}.
9360 @item @emph{Standard}:
9366 @item @emph{Syntax}:
9367 @code{RESULT = SIGN(A, B)}
9369 @item @emph{Arguments}:
9370 @multitable @columnfractions .15 .70
9371 @item @var{A} @tab Shall be of type @code{INTEGER} or @code{REAL}
9372 @item @var{B} @tab Shall be of the same type and kind as @var{A}
9375 @item @emph{Return value}:
9376 The kind of the return value is that of @var{A} and @var{B}.
9377 If @math{B\ge 0} then the result is @code{ABS(A)}, else
9378 it is @code{-ABS(A)}.
9380 @item @emph{Example}:
9383 print *, sign(-12,1)
9384 print *, sign(-12,0)
9385 print *, sign(-12,-1)
9387 print *, sign(-12.,1.)
9388 print *, sign(-12.,0.)
9389 print *, sign(-12.,-1.)
9390 end program test_sign
9393 @item @emph{Specific names}:
9394 @multitable @columnfractions .20 .20 .20 .25
9395 @item Name @tab Arguments @tab Return type @tab Standard
9396 @item @code{ISIGN(A,P)} @tab @code{INTEGER(4)} @tab @code{INTEGER(4)} @tab f95, gnu
9397 @item @code{DSIGN(A,P)} @tab @code{REAL(8)} @tab @code{REAL(8)} @tab f95, gnu
9404 @section @code{SIGNAL} --- Signal handling subroutine (or function)
9406 @cindex system, signal handling
9409 @item @emph{Description}:
9410 @code{SIGNAL(NUMBER, HANDLER [, STATUS])} causes external subroutine
9411 @var{HANDLER} to be executed with a single integer argument when signal
9412 @var{NUMBER} occurs. If @var{HANDLER} is an integer, it can be used to
9413 turn off handling of signal @var{NUMBER} or revert to its default
9414 action. See @code{signal(2)}.
9416 If @code{SIGNAL} is called as a subroutine and the @var{STATUS} argument
9417 is supplied, it is set to the value returned by @code{signal(2)}.
9419 @item @emph{Standard}:
9423 Subroutine, function
9425 @item @emph{Syntax}:
9426 @multitable @columnfractions .80
9427 @item @code{CALL SIGNAL(NUMBER, HANDLER [, STATUS])}
9428 @item @code{STATUS = SIGNAL(NUMBER, HANDLER)}
9431 @item @emph{Arguments}:
9432 @multitable @columnfractions .15 .70
9433 @item @var{NUMBER} @tab Shall be a scalar integer, with @code{INTENT(IN)}
9434 @item @var{HANDLER}@tab Signal handler (@code{INTEGER FUNCTION} or
9435 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar.
9436 @code{INTEGER}. It is @code{INTENT(IN)}.
9437 @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
9438 integer. It has @code{INTENT(OUT)}.
9441 @item @emph{Return value}:
9442 The @code{SIGNAL} function returns the value returned by @code{signal(2)}.
9444 @item @emph{Example}:
9448 external handler_print
9450 call signal (12, handler_print)
9454 end program test_signal
9461 @section @code{SIN} --- Sine function
9467 @cindex trigonometric function, sine
9471 @item @emph{Description}:
9472 @code{SIN(X)} computes the sine of @var{X}.
9474 @item @emph{Standard}:
9480 @item @emph{Syntax}:
9481 @code{RESULT = SIN(X)}
9483 @item @emph{Arguments}:
9484 @multitable @columnfractions .15 .70
9485 @item @var{X} @tab The type shall be @code{REAL(*)} or
9489 @item @emph{Return value}:
9490 The return value has same type and kind as @var{X}.
9492 @item @emph{Example}:
9497 end program test_sin
9500 @item @emph{Specific names}:
9501 @multitable @columnfractions .20 .20 .20 .25
9502 @item Name @tab Argument @tab Return type @tab Standard
9503 @item @code{DSIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
9504 @item @code{CSIN(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab f95, gnu
9505 @item @code{ZSIN(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
9506 @item @code{CDSIN(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
9509 @item @emph{See also}:
9516 @section @code{SINH} --- Hyperbolic sine function
9519 @cindex hyperbolic sine
9520 @cindex hyperbolic function, sine
9521 @cindex sine, hyperbolic
9524 @item @emph{Description}:
9525 @code{SINH(X)} computes the hyperbolic sine of @var{X}.
9527 @item @emph{Standard}:
9533 @item @emph{Syntax}:
9534 @code{RESULT = SINH(X)}
9536 @item @emph{Arguments}:
9537 @multitable @columnfractions .15 .70
9538 @item @var{X} @tab The type shall be @code{REAL(*)}.
9541 @item @emph{Return value}:
9542 The return value is of type @code{REAL(*)}.
9544 @item @emph{Example}:
9547 real(8) :: x = - 1.0_8
9549 end program test_sinh
9552 @item @emph{Specific names}:
9553 @multitable @columnfractions .20 .20 .20 .25
9554 @item Name @tab Argument @tab Return type @tab Standard
9555 @item @code{DSINH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
9558 @item @emph{See also}:
9565 @section @code{SIZE} --- Determine the size of an array
9568 @cindex array, number of elements
9569 @cindex array, count elements
9572 @item @emph{Description}:
9573 Determine the extent of @var{ARRAY} along a specified dimension @var{DIM},
9574 or the total number of elements in @var{ARRAY} if @var{DIM} is absent.
9576 @item @emph{Standard}:
9582 @item @emph{Syntax}:
9583 @code{RESULT = SIZE(ARRAY[, DIM [, KIND]])}
9585 @item @emph{Arguments}:
9586 @multitable @columnfractions .15 .70
9587 @item @var{ARRAY} @tab Shall be an array of any type. If @var{ARRAY} is
9588 a pointer it must be associated and allocatable arrays must be allocated.
9589 @item @var{DIM} @tab (Optional) shall be a scalar of type @code{INTEGER}
9590 and its value shall be in the range from 1 to n, where n equals the rank
9592 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
9593 expression indicating the kind parameter of
9597 @item @emph{Return value}:
9598 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
9599 @var{KIND} is absent, the return value is of default integer kind.
9601 @item @emph{Example}:
9604 WRITE(*,*) SIZE((/ 1, 2 /)) ! 2
9608 @item @emph{See also}:
9609 @ref{SHAPE}, @ref{RESHAPE}
9614 @section @code{SIZEOF} --- Size in bytes of an expression
9616 @cindex expression size
9617 @cindex size of an expression
9620 @item @emph{Description}:
9621 @code{SIZEOF(X)} calculates the number of bytes of storage the
9622 expression @code{X} occupies.
9624 @item @emph{Standard}:
9630 @item @emph{Syntax}:
9631 @code{N = SIZEOF(X)}
9633 @item @emph{Arguments}:
9634 @multitable @columnfractions .15 .70
9635 @item @var{X} @tab The argument shall be of any type, rank or shape.
9638 @item @emph{Return value}:
9639 The return value is of type integer and of the system-dependent kind
9640 @var{C_SIZE_T} (from the @var{ISO_C_BINDING} module). Its value is the
9641 number of bytes occupied by the argument. If the argument has the
9642 @code{POINTER} attribute, the number of bytes of the storage area pointed
9643 to is returned. If the argument is of a derived type with @code{POINTER}
9644 or @code{ALLOCATABLE} components, the return value doesn't account for
9645 the sizes of the data pointed to by these components.
9647 @item @emph{Example}:
9651 print *, (sizeof(s)/sizeof(r) == 5)
9654 The example will print @code{.TRUE.} unless you are using a platform
9655 where default @code{REAL} variables are unusually padded.
9659 @section @code{SLEEP} --- Sleep for the specified number of seconds
9661 @cindex delayed execution
9664 @item @emph{Description}:
9665 Calling this subroutine causes the process to pause for @var{SECONDS} seconds.
9667 @item @emph{Standard}:
9673 @item @emph{Syntax}:
9674 @code{CALL SLEEP(SECONDS)}
9676 @item @emph{Arguments}:
9677 @multitable @columnfractions .15 .70
9678 @item @var{SECONDS} @tab The type shall be of default @code{INTEGER}.
9681 @item @emph{Example}:
9692 @section @code{SNGL} --- Convert double precision real to default real
9694 @cindex conversion, to real
9697 @item @emph{Description}:
9698 @code{SNGL(A)} converts the double precision real @var{A}
9699 to a default real value. This is an archaic form of @code{REAL}
9700 that is specific to one type for @var{A}.
9702 @item @emph{Standard}:
9708 @item @emph{Syntax}:
9709 @code{RESULT = SNGL(A)}
9711 @item @emph{Arguments}:
9712 @multitable @columnfractions .15 .70
9713 @item @var{A} @tab The type shall be a double precision @code{REAL}.
9716 @item @emph{Return value}:
9717 The return value is of type default @code{REAL}.
9719 @item @emph{See also}:
9726 @section @code{SPACING} --- Smallest distance between two numbers of a given type
9728 @cindex real number, relative spacing
9729 @cindex floating point, relative spacing
9732 @item @emph{Description}:
9733 Determines the distance between the argument @var{X} and the nearest
9734 adjacent number of the same type.
9736 @item @emph{Standard}:
9742 @item @emph{Syntax}:
9743 @code{RESULT = SPACING(X)}
9745 @item @emph{Arguments}:
9746 @multitable @columnfractions .15 .70
9747 @item @var{X} @tab Shall be of type @code{REAL(*)}.
9750 @item @emph{Return value}:
9751 The result is of the same type as the input argument @var{X}.
9753 @item @emph{Example}:
9755 PROGRAM test_spacing
9756 INTEGER, PARAMETER :: SGL = SELECTED_REAL_KIND(p=6, r=37)
9757 INTEGER, PARAMETER :: DBL = SELECTED_REAL_KIND(p=13, r=200)
9759 WRITE(*,*) spacing(1.0_SGL) ! "1.1920929E-07" on i686
9760 WRITE(*,*) spacing(1.0_DBL) ! "2.220446049250313E-016" on i686
9764 @item @emph{See also}:
9771 @section @code{SPREAD} --- Add a dimension to an array
9773 @cindex array, increase dimension
9774 @cindex array, duplicate elements
9775 @cindex array, duplicate dimensions
9778 @item @emph{Description}:
9779 Replicates a @var{SOURCE} array @var{NCOPIES} times along a specified
9780 dimension @var{DIM}.
9782 @item @emph{Standard}:
9786 Transformational function
9788 @item @emph{Syntax}:
9789 @code{RESULT = SPREAD(SOURCE, DIM, NCOPIES)}
9791 @item @emph{Arguments}:
9792 @multitable @columnfractions .15 .70
9793 @item @var{SOURCE} @tab Shall be a scalar or an array of any type and
9794 a rank less than seven.
9795 @item @var{DIM} @tab Shall be a scalar of type @code{INTEGER} with a
9796 value in the range from 1 to n+1, where n equals the rank of @var{SOURCE}.
9797 @item @var{NCOPIES} @tab Shall be a scalar of type @code{INTEGER}.
9800 @item @emph{Return value}:
9801 The result is an array of the same type as @var{SOURCE} and has rank n+1
9802 where n equals the rank of @var{SOURCE}.
9804 @item @emph{Example}:
9807 INTEGER :: a = 1, b(2) = (/ 1, 2 /)
9808 WRITE(*,*) SPREAD(A, 1, 2) ! "1 1"
9809 WRITE(*,*) SPREAD(B, 1, 2) ! "1 1 2 2"
9813 @item @emph{See also}:
9820 @section @code{SQRT} --- Square-root function
9830 @item @emph{Description}:
9831 @code{SQRT(X)} computes the square root of @var{X}.
9833 @item @emph{Standard}:
9839 @item @emph{Syntax}:
9840 @code{RESULT = SQRT(X)}
9842 @item @emph{Arguments}:
9843 @multitable @columnfractions .15 .70
9844 @item @var{X} @tab The type shall be @code{REAL(*)} or
9848 @item @emph{Return value}:
9849 The return value is of type @code{REAL(*)} or @code{COMPLEX(*)}.
9850 The kind type parameter is the same as @var{X}.
9852 @item @emph{Example}:
9855 real(8) :: x = 2.0_8
9856 complex :: z = (1.0, 2.0)
9859 end program test_sqrt
9862 @item @emph{Specific names}:
9863 @multitable @columnfractions .20 .20 .20 .25
9864 @item Name @tab Argument @tab Return type @tab Standard
9865 @item @code{DSQRT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
9866 @item @code{CSQRT(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab F95 and later
9867 @item @code{ZSQRT(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
9868 @item @code{CDSQRT(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
9875 @section @code{SRAND} --- Reinitialize the random number generator
9877 @cindex random number generation, seeding
9878 @cindex seeding a random number generator
9881 @item @emph{Description}:
9882 @code{SRAND} reinitializes the pseudo-random number generator
9883 called by @code{RAND} and @code{IRAND}. The new seed used by the
9884 generator is specified by the required argument @var{SEED}.
9886 @item @emph{Standard}:
9892 @item @emph{Syntax}:
9893 @code{CALL SRAND(SEED)}
9895 @item @emph{Arguments}:
9896 @multitable @columnfractions .15 .70
9897 @item @var{SEED} @tab Shall be a scalar @code{INTEGER(kind=4)}.
9900 @item @emph{Return value}:
9903 @item @emph{Example}:
9904 See @code{RAND} and @code{IRAND} for examples.
9907 The Fortran 2003 standard specifies the intrinsic @code{RANDOM_SEED} to
9908 initialize the pseudo-random numbers generator and @code{RANDOM_NUMBER}
9909 to generate pseudo-random numbers. Please note that in
9910 GNU Fortran, these two sets of intrinsics (@code{RAND},
9911 @code{IRAND} and @code{SRAND} on the one hand, @code{RANDOM_NUMBER} and
9912 @code{RANDOM_SEED} on the other hand) access two independent
9913 pseudo-random number generators.
9915 @item @emph{See also}:
9916 @ref{RAND}, @ref{RANDOM_SEED}, @ref{RANDOM_NUMBER}
9923 @section @code{STAT} --- Get file status
9925 @cindex file system, file status
9928 @item @emph{Description}:
9929 This function returns information about a file. No permissions are required on
9930 the file itself, but execute (search) permission is required on all of the
9931 directories in path that lead to the file.
9933 The elements that are obtained and stored in the array @code{BUFF}:
9934 @multitable @columnfractions .15 .70
9935 @item @code{buff(1)} @tab Device ID
9936 @item @code{buff(2)} @tab Inode number
9937 @item @code{buff(3)} @tab File mode
9938 @item @code{buff(4)} @tab Number of links
9939 @item @code{buff(5)} @tab Owner's uid
9940 @item @code{buff(6)} @tab Owner's gid
9941 @item @code{buff(7)} @tab ID of device containing directory entry for file (0 if not available)
9942 @item @code{buff(8)} @tab File size (bytes)
9943 @item @code{buff(9)} @tab Last access time
9944 @item @code{buff(10)} @tab Last modification time
9945 @item @code{buff(11)} @tab Last file status change time
9946 @item @code{buff(12)} @tab Preferred I/O block size (-1 if not available)
9947 @item @code{buff(13)} @tab Number of blocks allocated (-1 if not available)
9950 Not all these elements are relevant on all systems.
9951 If an element is not relevant, it is returned as 0.
9953 This intrinsic is provided in both subroutine and function forms; however,
9954 only one form can be used in any given program unit.
9956 @item @emph{Standard}:
9960 Subroutine, function
9962 @item @emph{Syntax}:
9963 @code{CALL STAT(FILE,BUFF[,STATUS])}
9965 @item @emph{Arguments}:
9966 @multitable @columnfractions .15 .70
9967 @item @var{FILE} @tab The type shall be @code{CHARACTER(*)}, a valid path within the file system.
9968 @item @var{BUFF} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
9969 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0
9970 on success and a system specific error code otherwise.
9973 @item @emph{Example}:
9976 INTEGER, DIMENSION(13) :: buff
9979 CALL STAT("/etc/passwd", buff, status)
9981 IF (status == 0) THEN
9982 WRITE (*, FMT="('Device ID:', T30, I19)") buff(1)
9983 WRITE (*, FMT="('Inode number:', T30, I19)") buff(2)
9984 WRITE (*, FMT="('File mode (octal):', T30, O19)") buff(3)
9985 WRITE (*, FMT="('Number of links:', T30, I19)") buff(4)
9986 WRITE (*, FMT="('Owner''s uid:', T30, I19)") buff(5)
9987 WRITE (*, FMT="('Owner''s gid:', T30, I19)") buff(6)
9988 WRITE (*, FMT="('Device where located:', T30, I19)") buff(7)
9989 WRITE (*, FMT="('File size:', T30, I19)") buff(8)
9990 WRITE (*, FMT="('Last access time:', T30, A19)") CTIME(buff(9))
9991 WRITE (*, FMT="('Last modification time', T30, A19)") CTIME(buff(10))
9992 WRITE (*, FMT="('Last status change time:', T30, A19)") CTIME(buff(11))
9993 WRITE (*, FMT="('Preferred block size:', T30, I19)") buff(12)
9994 WRITE (*, FMT="('No. of blocks allocated:', T30, I19)") buff(13)
9999 @item @emph{See also}:
10000 To stat an open file: @ref{FSTAT}, to stat a link: @ref{LSTAT}
10006 @section @code{SUM} --- Sum of array elements
10009 @cindex array, add elements
10010 @cindex array, conditionally add elements
10011 @cindex sum array elements
10014 @item @emph{Description}:
10015 Adds the elements of @var{ARRAY} along dimension @var{DIM} if
10016 the corresponding element in @var{MASK} is @code{TRUE}.
10018 @item @emph{Standard}:
10021 @item @emph{Class}:
10022 Transformational function
10024 @item @emph{Syntax}:
10025 @code{RESULT = SUM(ARRAY[, MASK])}
10026 @code{RESULT = SUM(ARRAY, DIM[, MASK])}
10028 @item @emph{Arguments}:
10029 @multitable @columnfractions .15 .70
10030 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER(*)},
10031 @code{REAL(*)} or @code{COMPLEX(*)}.
10032 @item @var{DIM} @tab (Optional) shall be a scalar of type
10033 @code{INTEGER} with a value in the range from 1 to n, where n
10034 equals the rank of @var{ARRAY}.
10035 @item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL}
10036 and either be a scalar or an array of the same shape as @var{ARRAY}.
10039 @item @emph{Return value}:
10040 The result is of the same type as @var{ARRAY}.
10042 If @var{DIM} is absent, a scalar with the sum of all elements in @var{ARRAY}
10043 is returned. Otherwise, an array of rank n-1, where n equals the rank of
10044 @var{ARRAY},and a shape similar to that of @var{ARRAY} with dimension @var{DIM}
10045 dropped is returned.
10047 @item @emph{Example}:
10050 INTEGER :: x(5) = (/ 1, 2, 3, 4 ,5 /)
10051 print *, SUM(x) ! all elements, sum = 15
10052 print *, SUM(x, MASK=MOD(x, 2)==1) ! odd elements, sum = 9
10056 @item @emph{See also}:
10063 @section @code{SYMLNK} --- Create a symbolic link
10065 @cindex file system, create link
10066 @cindex file system, soft link
10069 @item @emph{Description}:
10070 Makes a symbolic link from file @var{PATH1} to @var{PATH2}. A null
10071 character (@code{CHAR(0)}) can be used to mark the end of the names in
10072 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
10073 names are ignored. If the @var{STATUS} argument is supplied, it
10074 contains 0 on success or a nonzero error code upon return; see
10075 @code{symlink(2)}. If the system does not supply @code{symlink(2)},
10076 @code{ENOSYS} is returned.
10078 This intrinsic is provided in both subroutine and function forms;
10079 however, only one form can be used in any given program unit.
10081 @item @emph{Standard}:
10084 @item @emph{Class}:
10085 Subroutine, function
10087 @item @emph{Syntax}:
10088 @multitable @columnfractions .80
10089 @item @code{CALL SYMLNK(PATH1, PATH2 [, STATUS])}
10090 @item @code{STATUS = SYMLNK(PATH1, PATH2)}
10093 @item @emph{Arguments}:
10094 @multitable @columnfractions .15 .70
10095 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
10096 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
10097 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
10100 @item @emph{See also}:
10101 @ref{LINK}, @ref{UNLINK}
10108 @section @code{SYSTEM} --- Execute a shell command
10110 @cindex system, system call
10113 @item @emph{Description}:
10114 Passes the command @var{COMMAND} to a shell (see @code{system(3)}). If
10115 argument @var{STATUS} is present, it contains the value returned by
10116 @code{system(3)}, which is presumably 0 if the shell command succeeded.
10117 Note that which shell is used to invoke the command is system-dependent
10118 and environment-dependent.
10120 This intrinsic is provided in both subroutine and function forms;
10121 however, only one form can be used in any given program unit.
10123 @item @emph{Standard}:
10126 @item @emph{Class}:
10127 Subroutine, function
10129 @item @emph{Syntax}:
10130 @multitable @columnfractions .80
10131 @item @code{CALL SYSTEM(COMMAND [, STATUS])}
10132 @item @code{STATUS = SYSTEM(COMMAND)}
10135 @item @emph{Arguments}:
10136 @multitable @columnfractions .15 .70
10137 @item @var{COMMAND} @tab Shall be of default @code{CHARACTER} type.
10138 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
10141 @item @emph{See also}:
10147 @section @code{SYSTEM_CLOCK} --- Time function
10148 @fnindex SYSTEM_CLOCK
10149 @cindex time, clock ticks
10150 @cindex clock ticks
10153 @item @emph{Description}:
10154 Determines the @var{COUNT} of milliseconds of wall clock time since
10155 the Epoch (00:00:00 UTC, January 1, 1970) modulo @var{COUNT_MAX},
10156 @var{COUNT_RATE} determines the number of clock ticks per second.
10157 @var{COUNT_RATE} and @var{COUNT_MAX} are constant and specific to
10158 @command{gfortran}.
10160 If there is no clock, @var{COUNT} is set to @code{-HUGE(COUNT)}, and
10161 @var{COUNT_RATE} and @var{COUNT_MAX} are set to zero
10163 @item @emph{Standard}:
10166 @item @emph{Class}:
10169 @item @emph{Syntax}:
10170 @code{CALL SYSTEM_CLOCK([COUNT, COUNT_RATE, COUNT_MAX])}
10172 @item @emph{Arguments}:
10173 @item @emph{Arguments}:
10174 @multitable @columnfractions .15 .70
10175 @item @var{COUNT} @tab (Optional) shall be a scalar of type default
10176 @code{INTEGER} with @code{INTENT(OUT)}.
10177 @item @var{COUNT_RATE} @tab (Optional) shall be a scalar of type default
10178 @code{INTEGER} with @code{INTENT(OUT)}.
10179 @item @var{COUNT_MAX} @tab (Optional) shall be a scalar of type default
10180 @code{INTEGER} with @code{INTENT(OUT)}.
10183 @item @emph{Example}:
10185 PROGRAM test_system_clock
10186 INTEGER :: count, count_rate, count_max
10187 CALL SYSTEM_CLOCK(count, count_rate, count_max)
10188 WRITE(*,*) count, count_rate, count_max
10192 @item @emph{See also}:
10193 @ref{DATE_AND_TIME}, @ref{CPU_TIME}
10199 @section @code{TAN} --- Tangent function
10202 @cindex trigonometric function, tangent
10206 @item @emph{Description}:
10207 @code{TAN(X)} computes the tangent of @var{X}.
10209 @item @emph{Standard}:
10212 @item @emph{Class}:
10215 @item @emph{Syntax}:
10216 @code{RESULT = TAN(X)}
10218 @item @emph{Arguments}:
10219 @multitable @columnfractions .15 .70
10220 @item @var{X} @tab The type shall be @code{REAL(*)}.
10223 @item @emph{Return value}:
10224 The return value is of type @code{REAL(*)}. The kind type parameter is
10225 the same as @var{X}.
10227 @item @emph{Example}:
10230 real(8) :: x = 0.165_8
10232 end program test_tan
10235 @item @emph{Specific names}:
10236 @multitable @columnfractions .20 .20 .20 .25
10237 @item Name @tab Argument @tab Return type @tab Standard
10238 @item @code{DTAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
10241 @item @emph{See also}:
10248 @section @code{TANH} --- Hyperbolic tangent function
10251 @cindex hyperbolic tangent
10252 @cindex hyperbolic function, tangent
10253 @cindex tangent, hyperbolic
10256 @item @emph{Description}:
10257 @code{TANH(X)} computes the hyperbolic tangent of @var{X}.
10259 @item @emph{Standard}:
10262 @item @emph{Class}:
10265 @item @emph{Syntax}:
10268 @item @emph{Arguments}:
10269 @multitable @columnfractions .15 .70
10270 @item @var{X} @tab The type shall be @code{REAL(*)}.
10273 @item @emph{Return value}:
10274 The return value is of type @code{REAL(*)} and lies in the range
10275 @math{ - 1 \leq tanh(x) \leq 1 }.
10277 @item @emph{Example}:
10280 real(8) :: x = 2.1_8
10282 end program test_tanh
10285 @item @emph{Specific names}:
10286 @multitable @columnfractions .20 .20 .20 .25
10287 @item Name @tab Argument @tab Return type @tab Standard
10288 @item @code{DTANH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
10291 @item @emph{See also}:
10298 @section @code{TIME} --- Time function
10300 @cindex time, current
10301 @cindex current time
10304 @item @emph{Description}:
10305 Returns the current time encoded as an integer (in the manner of the
10306 UNIX function @code{time(3)}). This value is suitable for passing to
10307 @code{CTIME()}, @code{GMTIME()}, and @code{LTIME()}.
10309 This intrinsic is not fully portable, such as to systems with 32-bit
10310 @code{INTEGER} types but supporting times wider than 32 bits. Therefore,
10311 the values returned by this intrinsic might be, or become, negative, or
10312 numerically less than previous values, during a single run of the
10315 See @ref{TIME8}, for information on a similar intrinsic that might be
10316 portable to more GNU Fortran implementations, though to fewer Fortran
10319 @item @emph{Standard}:
10322 @item @emph{Class}:
10325 @item @emph{Syntax}:
10326 @code{RESULT = TIME()}
10328 @item @emph{Return value}:
10329 The return value is a scalar of type @code{INTEGER(4)}.
10331 @item @emph{See also}:
10332 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME8}
10339 @section @code{TIME8} --- Time function (64-bit)
10341 @cindex time, current
10342 @cindex current time
10345 @item @emph{Description}:
10346 Returns the current time encoded as an integer (in the manner of the
10347 UNIX function @code{time(3)}). This value is suitable for passing to
10348 @code{CTIME()}, @code{GMTIME()}, and @code{LTIME()}.
10350 @emph{Warning:} this intrinsic does not increase the range of the timing
10351 values over that returned by @code{time(3)}. On a system with a 32-bit
10352 @code{time(3)}, @code{TIME8()} will return a 32-bit value, even though
10353 it is converted to a 64-bit @code{INTEGER(8)} value. That means
10354 overflows of the 32-bit value can still occur. Therefore, the values
10355 returned by this intrinsic might be or become negative or numerically
10356 less than previous values during a single run of the compiled program.
10358 @item @emph{Standard}:
10361 @item @emph{Class}:
10364 @item @emph{Syntax}:
10365 @code{RESULT = TIME8()}
10367 @item @emph{Return value}:
10368 The return value is a scalar of type @code{INTEGER(8)}.
10370 @item @emph{See also}:
10371 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK8}, @ref{TIME}
10378 @section @code{TINY} --- Smallest positive number of a real kind
10380 @cindex limits, smallest number
10381 @cindex model representation, smallest number
10384 @item @emph{Description}:
10385 @code{TINY(X)} returns the smallest positive (non zero) number
10386 in the model of the type of @code{X}.
10388 @item @emph{Standard}:
10391 @item @emph{Class}:
10394 @item @emph{Syntax}:
10395 @code{RESULT = TINY(X)}
10397 @item @emph{Arguments}:
10398 @multitable @columnfractions .15 .70
10399 @item @var{X} @tab Shall be of type @code{REAL}.
10402 @item @emph{Return value}:
10403 The return value is of the same type and kind as @var{X}
10405 @item @emph{Example}:
10406 See @code{HUGE} for an example.
10412 @section @code{TRANSFER} --- Transfer bit patterns
10418 @item @emph{Description}:
10419 Interprets the bitwise representation of @var{SOURCE} in memory as if it
10420 is the representation of a variable or array of the same type and type
10421 parameters as @var{MOLD}.
10423 This is approximately equivalent to the C concept of @emph{casting} one
10426 @item @emph{Standard}:
10429 @item @emph{Class}:
10430 Transformational function
10432 @item @emph{Syntax}:
10433 @code{RESULT = TRANSFER(SOURCE, MOLD[, SIZE])}
10435 @item @emph{Arguments}:
10436 @multitable @columnfractions .15 .70
10437 @item @var{SOURCE} @tab Shall be a scalar or an array of any type.
10438 @item @var{MOLD} @tab Shall be a scalar or an array of any type.
10439 @item @var{SIZE} @tab (Optional) shall be a scalar of type
10443 @item @emph{Return value}:
10444 The result has the same type as @var{MOLD}, with the bit level
10445 representation of @var{SOURCE}. If @var{SIZE} is present, the result is
10446 a one-dimensional array of length @var{SIZE}. If @var{SIZE} is absent
10447 but @var{MOLD} is an array (of any size or shape), the result is a one-
10448 dimensional array of the minimum length needed to contain the entirety
10449 of the bitwise representation of @var{SOURCE}. If @var{SIZE} is absent
10450 and @var{MOLD} is a scalar, the result is a scalar.
10452 If the bitwise representation of the result is longer than that of
10453 @var{SOURCE}, then the leading bits of the result correspond to those of
10454 @var{SOURCE} and any trailing bits are filled arbitrarily.
10456 When the resulting bit representation does not correspond to a valid
10457 representation of a variable of the same type as @var{MOLD}, the results
10458 are undefined, and subsequent operations on the result cannot be
10459 guaranteed to produce sensible behavior. For example, it is possible to
10460 create @code{LOGICAL} variables for which @code{@var{VAR}} and
10461 @code{.NOT.@var{VAR}} both appear to be true.
10463 @item @emph{Example}:
10465 PROGRAM test_transfer
10466 integer :: x = 2143289344
10467 print *, transfer(x, 1.0) ! prints "NaN" on i686
10475 @section @code{TRANSPOSE} --- Transpose an array of rank two
10477 @cindex array, transpose
10478 @cindex matrix, transpose
10482 @item @emph{Description}:
10483 Transpose an array of rank two. Element (i, j) of the result has the value
10484 @code{MATRIX(j, i)}, for all i, j.
10486 @item @emph{Standard}:
10489 @item @emph{Class}:
10490 Transformational function
10492 @item @emph{Syntax}:
10493 @code{RESULT = TRANSPOSE(MATRIX)}
10495 @item @emph{Arguments}:
10496 @multitable @columnfractions .15 .70
10497 @item @var{MATRIX} @tab Shall be an array of any type and have a rank of two.
10500 @item @emph{Return value}:
10501 The result has the the same type as @var{MATRIX}, and has shape
10502 @code{(/ m, n /)} if @var{MATRIX} has shape @code{(/ n, m /)}.
10508 @section @code{TRIM} --- Remove trailing blank characters of a string
10510 @cindex string, remove trailing whitespace
10513 @item @emph{Description}:
10514 Removes trailing blank characters of a string.
10516 @item @emph{Standard}:
10519 @item @emph{Class}:
10520 Transformational function
10522 @item @emph{Syntax}:
10523 @code{RESULT = TRIM(STRING)}
10525 @item @emph{Arguments}:
10526 @multitable @columnfractions .15 .70
10527 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER(*)}.
10530 @item @emph{Return value}:
10531 A scalar of type @code{CHARACTER(*)} which length is that of @var{STRING}
10532 less the number of trailing blanks.
10534 @item @emph{Example}:
10537 CHARACTER(len=10), PARAMETER :: s = "GFORTRAN "
10538 WRITE(*,*) LEN(s), LEN(TRIM(s)) ! "10 8", with/without trailing blanks
10542 @item @emph{See also}:
10543 @ref{ADJUSTL}, @ref{ADJUSTR}
10549 @section @code{TTYNAM} --- Get the name of a terminal device.
10551 @cindex system, terminal
10554 @item @emph{Description}:
10555 Get the name of a terminal device. For more information,
10556 see @code{ttyname(3)}.
10558 This intrinsic is provided in both subroutine and function forms;
10559 however, only one form can be used in any given program unit.
10561 @item @emph{Standard}:
10564 @item @emph{Class}:
10565 Subroutine, function
10567 @item @emph{Syntax}:
10568 @multitable @columnfractions .80
10569 @item @code{CALL TTYNAM(UNIT, NAME)}
10570 @item @code{NAME = TTYNAM(UNIT)}
10573 @item @emph{Arguments}:
10574 @multitable @columnfractions .15 .70
10575 @item @var{UNIT} @tab Shall be a scalar @code{INTEGER(*)}.
10576 @item @var{NAME} @tab Shall be of type @code{CHARACTER(*)}.
10579 @item @emph{Example}:
10581 PROGRAM test_ttynam
10584 IF (isatty(unit=unit)) write(*,*) ttynam(unit)
10589 @item @emph{See also}:
10596 @section @code{UBOUND} --- Upper dimension bounds of an array
10598 @cindex array, upper bound
10601 @item @emph{Description}:
10602 Returns the upper bounds of an array, or a single upper bound
10603 along the @var{DIM} dimension.
10604 @item @emph{Standard}:
10607 @item @emph{Class}:
10610 @item @emph{Syntax}:
10611 @code{RESULT = UBOUND(ARRAY [, DIM [, KIND]])}
10613 @item @emph{Arguments}:
10614 @multitable @columnfractions .15 .70
10615 @item @var{ARRAY} @tab Shall be an array, of any type.
10616 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER(*)}.
10617 @item @var{KIND}@tab (Optional) An @code{INTEGER} initialization
10618 expression indicating the kind parameter of
10622 @item @emph{Return value}:
10623 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
10624 @var{KIND} is absent, the return value is of default integer kind.
10625 If @var{DIM} is absent, the result is an array of the upper bounds of
10626 @var{ARRAY}. If @var{DIM} is present, the result is a scalar
10627 corresponding to the upper bound of the array along that dimension. If
10628 @var{ARRAY} is an expression rather than a whole array or array
10629 structure component, or if it has a zero extent along the relevant
10630 dimension, the upper bound is taken to be the number of elements along
10631 the relevant dimension.
10633 @item @emph{See also}:
10640 @section @code{UMASK} --- Set the file creation mask
10642 @cindex file system, file creation mask
10645 @item @emph{Description}:
10646 Sets the file creation mask to @var{MASK} and returns the old value in
10647 argument @var{OLD} if it is supplied. See @code{umask(2)}.
10649 @item @emph{Standard}:
10652 @item @emph{Class}:
10655 @item @emph{Syntax}:
10656 @code{CALL UMASK(MASK [, OLD])}
10658 @item @emph{Arguments}:
10659 @multitable @columnfractions .15 .70
10660 @item @var{MASK} @tab Shall be a scalar of type @code{INTEGER(*)}.
10661 @item @var{MASK} @tab (Optional) Shall be a scalar of type
10670 @section @code{UNLINK} --- Remove a file from the file system
10672 @cindex file system, remove file
10675 @item @emph{Description}:
10676 Unlinks the file @var{PATH}. A null character (@code{CHAR(0)}) can be
10677 used to mark the end of the name in @var{PATH}; otherwise, trailing
10678 blanks in the file name are ignored. If the @var{STATUS} argument is
10679 supplied, it contains 0 on success or a nonzero error code upon return;
10680 see @code{unlink(2)}.
10682 This intrinsic is provided in both subroutine and function forms;
10683 however, only one form can be used in any given program unit.
10685 @item @emph{Standard}:
10688 @item @emph{Class}:
10689 Subroutine, function
10691 @item @emph{Syntax}:
10692 @multitable @columnfractions .80
10693 @item @code{CALL UNLINK(PATH [, STATUS])}
10694 @item @code{STATUS = UNLINK(PATH)}
10697 @item @emph{Arguments}:
10698 @multitable @columnfractions .15 .70
10699 @item @var{PATH} @tab Shall be of default @code{CHARACTER} type.
10700 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
10703 @item @emph{See also}:
10704 @ref{LINK}, @ref{SYMLNK}
10710 @section @code{UNPACK} --- Unpack an array of rank one into an array
10712 @cindex array, unpacking
10713 @cindex array, increase dimension
10714 @cindex array, scatter elements
10717 @item @emph{Description}:
10718 Store the elements of @var{VECTOR} in an array of higher rank.
10720 @item @emph{Standard}:
10723 @item @emph{Class}:
10724 Transformational function
10726 @item @emph{Syntax}:
10727 @code{RESULT = UNPACK(VECTOR, MASK, FIELD)}
10729 @item @emph{Arguments}:
10730 @multitable @columnfractions .15 .70
10731 @item @var{VECTOR} @tab Shall be an array of any type and rank one. It
10732 shall have at least as many elements as @var{MASK} has @code{TRUE} values.
10733 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL}.
10734 @item @var{FIELD} @tab Shall be of the sam type as @var{VECTOR} and have
10735 the same shape as @var{MASK}.
10738 @item @emph{Return value}:
10739 The resulting array corresponds to @var{FIELD} with @code{TRUE} elements
10740 of @var{MASK} replaced by values from @var{VECTOR} in array element order.
10742 @item @emph{Example}:
10744 PROGRAM test_unpack
10745 integer :: vector(2) = (/1,1/)
10746 logical :: mask(4) = (/ .TRUE., .FALSE., .FALSE., .TRUE. /)
10747 integer :: field(2,2) = 0, unity(2,2)
10749 ! result: unity matrix
10750 unity = unpack(vector, reshape(mask, (/2,2/)), field)
10754 @item @emph{See also}:
10755 @ref{PACK}, @ref{SPREAD}
10761 @section @code{VERIFY} --- Scan a string for the absence of a set of characters
10763 @cindex string, find missing set
10766 @item @emph{Description}:
10767 Verifies that all the characters in a @var{SET} are present in a @var{STRING}.
10769 If @var{BACK} is either absent or equals @code{FALSE}, this function
10770 returns the position of the leftmost character of @var{STRING} that is
10771 not in @var{SET}. If @var{BACK} equals @code{TRUE}, the rightmost position
10772 is returned. If all characters of @var{SET} are found in @var{STRING}, the
10775 @item @emph{Standard}:
10778 @item @emph{Class}:
10781 @item @emph{Syntax}:
10782 @code{RESULT = VERIFY(STRING, SET[, BACK [, KIND]])}
10784 @item @emph{Arguments}:
10785 @multitable @columnfractions .15 .70
10786 @item @var{STRING} @tab Shall be of type @code{CHARACTER(*)}.
10787 @item @var{SET} @tab Shall be of type @code{CHARACTER(*)}.
10788 @item @var{BACK} @tab (Optional) shall be of type @code{LOGICAL}.
10789 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
10790 expression indicating the kind parameter of
10794 @item @emph{Return value}:
10795 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
10796 @var{KIND} is absent, the return value is of default integer kind.
10798 @item @emph{Example}:
10800 PROGRAM test_verify
10801 WRITE(*,*) VERIFY("FORTRAN", "AO") ! 1, found 'F'
10802 WRITE(*,*) VERIFY("FORTRAN", "FOO") ! 3, found 'R'
10803 WRITE(*,*) VERIFY("FORTRAN", "C++") ! 1, found 'F'
10804 WRITE(*,*) VERIFY("FORTRAN", "C++", .TRUE.) ! 7, found 'N'
10805 WRITE(*,*) VERIFY("FORTRAN", "FORTRAN") ! 0' found none
10809 @item @emph{See also}:
10810 @ref{SCAN}, @ref{INDEX}
10816 @section @code{XOR} --- Bitwise logical exclusive OR
10818 @cindex bitwise logical exclusive or
10819 @cindex logical exclusive or, bitwise
10822 @item @emph{Description}:
10823 Bitwise logical exclusive or.
10825 This intrinsic routine is provided for backwards compatibility with
10826 GNU Fortran 77. For integer arguments, programmers should consider
10827 the use of the @ref{IEOR} intrinsic defined by the Fortran standard.
10829 @item @emph{Standard}:
10832 @item @emph{Class}:
10835 @item @emph{Syntax}:
10836 @code{RESULT = XOR(X, Y)}
10838 @item @emph{Arguments}:
10839 @multitable @columnfractions .15 .70
10840 @item @var{X} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
10841 @item @var{Y} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
10844 @item @emph{Return value}:
10845 The return type is either @code{INTEGER(*)} or @code{LOGICAL}
10846 after cross-promotion of the arguments.
10848 @item @emph{Example}:
10851 LOGICAL :: T = .TRUE., F = .FALSE.
10853 DATA a / Z'F' /, b / Z'3' /
10855 WRITE (*,*) XOR(T, T), XOR(T, F), XOR(F, T), XOR(F, F)
10856 WRITE (*,*) XOR(a, b)
10860 @item @emph{See also}:
10861 F95 elemental function: @ref{IEOR}