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{CEILING}: CEILING, Integer ceiling function
74 * @code{CHAR}: CHAR, Integer-to-character conversion function
75 * @code{CHDIR}: CHDIR, Change working directory
76 * @code{CHMOD}: CHMOD, Change access permissions of files
77 * @code{CMPLX}: CMPLX, Complex conversion function
78 * @code{COMMAND_ARGUMENT_COUNT}: COMMAND_ARGUMENT_COUNT, Get number of command line arguments
79 * @code{CONJG}: CONJG, Complex conjugate function
80 * @code{COS}: COS, Cosine function
81 * @code{COSH}: COSH, Hyperbolic cosine function
82 * @code{COUNT}: COUNT, Count occurrences of TRUE in an array
83 * @code{CPU_TIME}: CPU_TIME, CPU time subroutine
84 * @code{CSHIFT}: CSHIFT, Circular shift elements of an array
85 * @code{CTIME}: CTIME, Subroutine (or function) to convert a time into a string
86 * @code{DATE_AND_TIME}: DATE_AND_TIME, Date and time subroutine
87 * @code{DBLE}: DBLE, Double precision conversion function
88 * @code{DCMPLX}: DCMPLX, Double complex conversion function
89 * @code{DFLOAT}: DFLOAT, Double precision conversion function
90 * @code{DIGITS}: DIGITS, Significant digits function
91 * @code{DIM}: DIM, Positive difference
92 * @code{DOT_PRODUCT}: DOT_PRODUCT, Dot product function
93 * @code{DPROD}: DPROD, Double product function
94 * @code{DREAL}: DREAL, Double real part function
95 * @code{DTIME}: DTIME, Execution time subroutine (or function)
96 * @code{EOSHIFT}: EOSHIFT, End-off shift elements of an array
97 * @code{EPSILON}: EPSILON, Epsilon function
98 * @code{ERF}: ERF, Error function
99 * @code{ERFC}: ERFC, Complementary error function
100 * @code{ETIME}: ETIME, Execution time subroutine (or function)
101 * @code{EXIT}: EXIT, Exit the program with status.
102 * @code{EXP}: EXP, Exponential function
103 * @code{EXPONENT}: EXPONENT, Exponent function
104 * @code{FDATE}: FDATE, Subroutine (or function) to get the current time as a string
105 * @code{FGET}: FGET, Read a single character in stream mode from stdin
106 * @code{FGETC}: FGETC, Read a single character in stream mode
107 * @code{FLOAT}: FLOAT, Convert integer to default real
108 * @code{FLOOR}: FLOOR, Integer floor function
109 * @code{FLUSH}: FLUSH, Flush I/O unit(s)
110 * @code{FNUM}: FNUM, File number function
111 * @code{FPUT}: FPUT, Write a single character in stream mode to stdout
112 * @code{FPUTC}: FPUTC, Write a single character in stream mode
113 * @code{FRACTION}: FRACTION, Fractional part of the model representation
114 * @code{FREE}: FREE, Memory de-allocation subroutine
115 * @code{FSEEK}: FSEEK, Low level file positioning subroutine
116 * @code{FSTAT}: FSTAT, Get file status
117 * @code{FTELL}: FTELL, Current stream position
118 * @code{GERROR}: GERROR, Get last system error message
119 * @code{GETARG}: GETARG, Get command line arguments
120 * @code{GET_COMMAND}: GET_COMMAND, Get the entire command line
121 * @code{GET_COMMAND_ARGUMENT}: GET_COMMAND_ARGUMENT, Get command line arguments
122 * @code{GETCWD}: GETCWD, Get current working directory
123 * @code{GETENV}: GETENV, Get an environmental variable
124 * @code{GET_ENVIRONMENT_VARIABLE}: GET_ENVIRONMENT_VARIABLE, Get an environmental variable
125 * @code{GETGID}: GETGID, Group ID function
126 * @code{GETLOG}: GETLOG, Get login name
127 * @code{GETPID}: GETPID, Process ID function
128 * @code{GETUID}: GETUID, User ID function
129 * @code{GMTIME}: GMTIME, Convert time to GMT info
130 * @code{HOSTNM}: HOSTNM, Get system host name
131 * @code{HUGE}: HUGE, Largest number of a kind
132 * @code{IACHAR}: IACHAR, Code in @acronym{ASCII} collating sequence
133 * @code{IAND}: IAND, Bitwise logical and
134 * @code{IARGC}: IARGC, Get the number of command line arguments
135 * @code{IBCLR}: IBCLR, Clear bit
136 * @code{IBITS}: IBITS, Bit extraction
137 * @code{IBSET}: IBSET, Set bit
138 * @code{ICHAR}: ICHAR, Character-to-integer conversion function
139 * @code{IDATE}: IDATE, Current local time (day/month/year)
140 * @code{IEOR}: IEOR, Bitwise logical exclusive or
141 * @code{IERRNO}: IERRNO, Function to get the last system error number
142 * @code{INDEX}: INDEX, Position of a substring within a string
143 * @code{INT}: INT, Convert to integer type
144 * @code{INT2}: INT2, Convert to 16-bit integer type
145 * @code{INT8}: INT8, Convert to 64-bit integer type
146 * @code{IOR}: IOR, Bitwise logical or
147 * @code{IRAND}: IRAND, Integer pseudo-random number
148 * @code{ISATTY}: ISATTY, Whether a unit is a terminal device
149 * @code{ISHFT}: ISHFT, Shift bits
150 * @code{ISHFTC}: ISHFTC, Shift bits circularly
151 * @code{ITIME}: ITIME, Current local time (hour/minutes/seconds)
152 * @code{KILL}: KILL, Send a signal to a process
153 * @code{KIND}: KIND, Kind of an entity
154 * @code{LBOUND}: LBOUND, Lower dimension bounds of an array
155 * @code{LEN}: LEN, Length of a character entity
156 * @code{LEN_TRIM}: LEN_TRIM, Length of a character entity without trailing blank characters
157 * @code{LGE}: LGE, Lexical greater than or equal
158 * @code{LGT}: LGT, Lexical greater than
159 * @code{LINK}: LINK, Create a hard link
160 * @code{LLE}: LLE, Lexical less than or equal
161 * @code{LLT}: LLT, Lexical less than
162 * @code{LNBLNK}: LNBLNK, Index of the last non-blank character in a string
163 * @code{LOC}: LOC, Returns the address of a variable
164 * @code{LOG}: LOG, Logarithm function
165 * @code{LOG10}: LOG10, Base 10 logarithm function
166 * @code{LOGICAL}: LOGICAL, Convert to logical type
167 * @code{LONG}: LONG, Convert to integer type
168 * @code{LSHIFT}: LSHIFT, Left shift bits
169 * @code{LSTAT}: LSTAT, Get file status
170 * @code{LTIME}: LTIME, Convert time to local time info
171 * @code{MALLOC}: MALLOC, Dynamic memory allocation function
172 * @code{MATMUL}: MATMUL, matrix multiplication
173 * @code{MAX}: MAX, Maximum value of an argument list
174 * @code{MAXEXPONENT}: MAXEXPONENT, Maximum exponent of a real kind
175 * @code{MAXLOC}: MAXLOC, Location of the maximum value within an array
176 * @code{MAXVAL}: MAXVAL, Maximum value of an array
177 * @code{MCLOCK}: MCLOCK, Time function
178 * @code{MCLOCK8}: MCLOCK8, Time function (64-bit)
179 * @code{MERGE}: MERGE, Merge arrays
180 * @code{MIN}: MIN, Minimum value of an argument list
181 * @code{MINEXPONENT}: MINEXPONENT, Minimum exponent of a real kind
182 * @code{MINLOC}: MINLOC, Location of the minimum value within an array
183 * @code{MINVAL}: MINVAL, Minimum value of an array
184 * @code{MOD}: MOD, Remainder function
185 * @code{MODULO}: MODULO, Modulo function
186 * @code{MOVE_ALLOC}: MOVE_ALLOC, Move allocation from one object to another
187 * @code{MVBITS}: MVBITS, Move bits from one integer to another
188 * @code{NEAREST}: NEAREST, Nearest representable number
189 * @code{NEW_LINE}: NEW_LINE, New line character
190 * @code{NINT}: NINT, Nearest whole number
191 * @code{NOT}: NOT, Logical negation
192 * @code{NULL}: NULL, Function that returns an disassociated pointer
193 * @code{OR}: OR, Bitwise logical OR
194 * @code{PACK}: PACK, Pack an array into an array of rank one
195 * @code{PERROR}: PERROR, Print system error message
196 * @code{PRECISION}: PRECISION, Decimal precision of a real kind
197 * @code{PRESENT}: PRESENT, Determine whether an optional dummy argument is specified
198 * @code{PRODUCT}: PRODUCT, Product of array elements
199 * @code{RADIX}: RADIX, Base of a data model
200 * @code{RANDOM_NUMBER}: RANDOM_NUMBER, Pseudo-random number
201 * @code{RANDOM_SEED}: RANDOM_SEED, Initialize a pseudo-random number sequence
202 * @code{RAND}: RAND, Real pseudo-random number
203 * @code{RANGE}: RANGE, Decimal exponent range of a real kind
204 * @code{RAN}: RAN, Real pseudo-random number
205 * @code{REAL}: REAL, Convert to real type
206 * @code{RENAME}: RENAME, Rename a file
207 * @code{REPEAT}: REPEAT, Repeated string concatenation
208 * @code{RESHAPE}: RESHAPE, Function to reshape an array
209 * @code{RRSPACING}: RRSPACING, Reciprocal of the relative spacing
210 * @code{RSHIFT}: RSHIFT, Right shift bits
211 * @code{SCALE}: SCALE, Scale a real value
212 * @code{SCAN}: SCAN, Scan a string for the presence of a set of characters
213 * @code{SECNDS}: SECNDS, Time function
214 * @code{SECOND}: SECOND, CPU time function
215 * @code{SELECTED_INT_KIND}: SELECTED_INT_KIND, Choose integer kind
216 * @code{SELECTED_REAL_KIND}: SELECTED_REAL_KIND, Choose real kind
217 * @code{SET_EXPONENT}: SET_EXPONENT, Set the exponent of the model
218 * @code{SHAPE}: SHAPE, Determine the shape of an array
219 * @code{SIGN}: SIGN, Sign copying function
220 * @code{SIGNAL}: SIGNAL, Signal handling subroutine (or function)
221 * @code{SIN}: SIN, Sine function
222 * @code{SINH}: SINH, Hyperbolic sine function
223 * @code{SIZE}: SIZE, Function to determine the size of an array
224 * @code{SLEEP}: SLEEP, Sleep for the specified number of seconds
225 * @code{SNGL}: SNGL, Convert double precision real to default real
226 * @code{SPACING}: SPACING, Smallest distance between two numbers of a given type
227 * @code{SPREAD}: SPREAD, Add a dimension to an array
228 * @code{SQRT}: SQRT, Square-root function
229 * @code{SRAND}: SRAND, Reinitialize the random number generator
230 * @code{STAT}: STAT, Get file status
231 * @code{SUM}: SUM, Sum of array elements
232 * @code{SYMLNK}: SYMLNK, Create a symbolic link
233 * @code{SYSTEM}: SYSTEM, Execute a shell command
234 * @code{SYSTEM_CLOCK}: SYSTEM_CLOCK, Time function
235 * @code{TAN}: TAN, Tangent function
236 * @code{TANH}: TANH, Hyperbolic tangent function
237 * @code{TIME}: TIME, Time function
238 * @code{TIME8}: TIME8, Time function (64-bit)
239 * @code{TINY}: TINY, Smallest positive number of a real kind
240 * @code{TRANSFER}: TRANSFER, Transfer bit patterns
241 * @code{TRANSPOSE}: TRANSPOSE, Transpose an array of rank two
242 * @code{TRIM}: TRIM, Remove trailing blank characters of a string
243 * @code{TTYNAM}: TTYNAM, Get the name of a terminal device.
244 * @code{UBOUND}: UBOUND, Upper dimension bounds of an array
245 * @code{UMASK}: UMASK, Set the file creation mask
246 * @code{UNLINK}: UNLINK, Remove a file from the file system
247 * @code{UNPACK}: UNPACK, Unpack an array of rank one into an array
248 * @code{VERIFY}: VERIFY, Scan a string for the absence of a set of characters
249 * @code{XOR}: XOR, Bitwise logical exclusive or
252 @node Introduction to Intrinsics
253 @section Introduction to intrinsic procedures
255 The intrinsic procedures provided by GNU Fortran include all of the
256 intrinsic procedures required by the Fortran 95 standard, a set of
257 intrinsic procedures for backwards compatibility with G77, and a small
258 selection of intrinsic procedures from the Fortran 2003 standard. Any
259 conflict between a description here and a description in either the
260 Fortran 95 standard or the Fortran 2003 standard is unintentional, and
261 the standard(s) should be considered authoritative.
263 The enumeration of the @code{KIND} type parameter is processor defined in
264 the Fortran 95 standard. GNU Fortran defines the default integer type and
265 default real type by @code{INTEGER(KIND=4)} and @code{REAL(KIND=4)},
266 respectively. The standard mandates that both data types shall have
267 another kind, which have more precision. On typical target architectures
268 supported by @command{gfortran}, this kind type parameter is @code{KIND=8}.
269 Hence, @code{REAL(KIND=8)} and @code{DOUBLE PRECISION} are equivalent.
270 In the description of generic intrinsic procedures, the kind type parameter
271 will be specified by @code{KIND=*}, and in the description of specific
272 names for an intrinsic procedure the kind type parameter will be explicitly
273 given (e.g., @code{REAL(KIND=4)} or @code{REAL(KIND=8)}). Finally, for
274 brevity the optional @code{KIND=} syntax will be omitted.
276 Many of the intrinsic procedures take one or more optional arguments.
277 This document follows the convention used in the Fortran 95 standard,
278 and denotes such arguments by square brackets.
280 GNU Fortran offers the @option{-std=f95} and @option{-std=gnu} options,
281 which can be used to restrict the set of intrinsic procedures to a
282 given standard. By default, @command{gfortran} sets the @option{-std=gnu}
283 option, and so all intrinsic procedures described here are accepted. There
284 is one caveat. For a select group of intrinsic procedures, @command{g77}
285 implemented both a function and a subroutine. Both classes
286 have been implemented in @command{gfortran} for backwards compatibility
287 with @command{g77}. It is noted here that these functions and subroutines
288 cannot be intermixed in a given subprogram. In the descriptions that follow,
289 the applicable standard for each intrinsic procedure is noted.
294 @section @code{ABORT} --- Abort the program
296 @cindex program termination, with core dump
297 @cindex terminate program, with core dump
301 @item @emph{Description}:
302 @code{ABORT} causes immediate termination of the program. On operating
303 systems that support a core dump, @code{ABORT} will produce a core dump,
304 which is suitable for debugging purposes.
306 @item @emph{Standard}:
310 Non-elemental subroutine
315 @item @emph{Return value}:
318 @item @emph{Example}:
321 integer :: i = 1, j = 2
322 if (i /= j) call abort
323 end program test_abort
326 @item @emph{See also}:
327 @ref{EXIT}, @ref{KILL}
334 @section @code{ABS} --- Absolute value
341 @cindex absolute value
344 @item @emph{Description}:
345 @code{ABS(X)} computes the absolute value of @code{X}.
347 @item @emph{Standard}:
348 F77 and later, has overloads that are GNU extensions
354 @code{RESULT = ABS(X)}
356 @item @emph{Arguments}:
357 @multitable @columnfractions .15 .70
358 @item @var{X} @tab The type of the argument shall be an @code{INTEGER(*)},
359 @code{REAL(*)}, or @code{COMPLEX(*)}.
362 @item @emph{Return value}:
363 The return value is of the same type and
364 kind as the argument except the return value is @code{REAL(*)} for a
365 @code{COMPLEX(*)} argument.
367 @item @emph{Example}:
372 complex :: z = (-1.e0,0.e0)
379 @item @emph{Specific names}:
380 @multitable @columnfractions .20 .20 .20 .25
381 @item Name @tab Argument @tab Return type @tab Standard
382 @item @code{CABS(Z)} @tab @code{COMPLEX(4) Z} @tab @code{REAL(4)} @tab F77 and later
383 @item @code{DABS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
384 @item @code{IABS(I)} @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)} @tab F77 and later
385 @item @code{ZABS(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
386 @item @code{CDABS(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
393 @section @code{ACCESS} --- Checks file access modes
395 @cindex file system, access mode
398 @item @emph{Description}:
399 @code{ACCESS(NAME, MODE)} checks whether the file @var{NAME}
400 exists, is readable, writable or executable. Except for the
401 executable check, @code{ACCESS} can be replaced by
402 Fortran 95's @code{INQUIRE}.
404 @item @emph{Standard}:
411 @code{RESULT = ACCESS(NAME, MODE)}
413 @item @emph{Arguments}:
414 @multitable @columnfractions .15 .70
415 @item @var{NAME} @tab Scalar @code{CHARACTER} with the file name.
416 Tailing blank are ignored unless the character @code{achar(0)} is
417 present, then all characters up to and excluding @code{achar(0)} are
419 @item @var{MODE} @tab Scalar @code{CHARACTER} with the file access mode,
420 may be any concatenation of @code{"r"} (readable), @code{"w"} (writable)
421 and @code{"x"} (executable), or @code{" "} to check for existence.
424 @item @emph{Return value}:
425 Returns a scalar @code{INTEGER}, which is @code{0} if the file is
426 accessible in the given mode; otherwise or if an invalid argument
427 has been given for @code{MODE} the value @code{1} is returned.
429 @item @emph{Example}:
433 character(len=*), parameter :: file = 'test.dat'
434 character(len=*), parameter :: file2 = 'test.dat '//achar(0)
435 if(access(file,' ') == 0) print *, trim(file),' is exists'
436 if(access(file,'r') == 0) print *, trim(file),' is readable'
437 if(access(file,'w') == 0) print *, trim(file),' is writable'
438 if(access(file,'x') == 0) print *, trim(file),' is executable'
439 if(access(file2,'rwx') == 0) &
440 print *, trim(file2),' is readable, writable and executable'
441 end program access_test
443 @item @emph{Specific names}:
444 @item @emph{See also}:
451 @section @code{ACHAR} --- Character in @acronym{ASCII} collating sequence
453 @cindex @acronym{ASCII} collating sequence
454 @cindex collating sequence, @acronym{ASCII}
457 @item @emph{Description}:
458 @code{ACHAR(I)} returns the character located at position @code{I}
459 in the @acronym{ASCII} collating sequence.
461 @item @emph{Standard}:
468 @code{RESULT = ACHAR(I)}
470 @item @emph{Arguments}:
471 @multitable @columnfractions .15 .70
472 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
475 @item @emph{Return value}:
476 The return value is of type @code{CHARACTER} with a length of one. The
477 kind type parameter is the same as @code{KIND('A')}.
479 @item @emph{Example}:
484 end program test_achar
488 See @ref{ICHAR} for a discussion of converting between numerical values
489 and formatted string representations.
491 @item @emph{See also}:
492 @ref{CHAR}, @ref{IACHAR}, @ref{ICHAR}
499 @section @code{ACOS} --- Arccosine function
502 @cindex trigonometric function, cosine, inverse
503 @cindex cosine, inverse
506 @item @emph{Description}:
507 @code{ACOS(X)} computes the arccosine of @var{X} (inverse of @code{COS(X)}).
509 @item @emph{Standard}:
516 @code{RESULT = ACOS(X)}
518 @item @emph{Arguments}:
519 @multitable @columnfractions .15 .70
520 @item @var{X} @tab The type shall be @code{REAL(*)} with a magnitude that is
524 @item @emph{Return value}:
525 The return value is of type @code{REAL(*)} and it lies in the
526 range @math{ 0 \leq \acos(x) \leq \pi}. The kind type parameter
527 is the same as @var{X}.
529 @item @emph{Example}:
532 real(8) :: x = 0.866_8
534 end program test_acos
537 @item @emph{Specific names}:
538 @multitable @columnfractions .20 .20 .20 .25
539 @item Name @tab Argument @tab Return type @tab Standard
540 @item @code{DACOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
543 @item @emph{See also}:
544 Inverse function: @ref{COS}
551 @section @code{ACOSH} --- Hyperbolic arccosine function
554 @cindex area hyperbolic cosine
555 @cindex hyperbolic arccosine
556 @cindex hyperbolic function, cosine, inverse
557 @cindex cosine, hyperbolic, inverse
560 @item @emph{Description}:
561 @code{ACOSH(X)} computes the hyperbolic arccosine of @var{X} (inverse of
564 @item @emph{Standard}:
571 @code{RESULT = ACOSH(X)}
573 @item @emph{Arguments}:
574 @multitable @columnfractions .15 .70
575 @item @var{X} @tab The type shall be @code{REAL(*)} with a magnitude that is
576 greater or equal to one.
579 @item @emph{Return value}:
580 The return value is of type @code{REAL(*)} and it lies in the
581 range @math{0 \leq \acosh (x) \leq \infty}.
583 @item @emph{Example}:
586 REAL(8), DIMENSION(3) :: x = (/ 1.0, 2.0, 3.0 /)
591 @item @emph{Specific names}:
592 @multitable @columnfractions .20 .20 .20 .25
593 @item Name @tab Argument @tab Return type @tab Standard
594 @item @code{DACOSH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
597 @item @emph{See also}:
598 Inverse function: @ref{COSH}
604 @section @code{ADJUSTL} --- Left adjust a string
606 @cindex string, adjust left
607 @cindex adjust string
610 @item @emph{Description}:
611 @code{ADJUSTL(STR)} will left adjust a string by removing leading spaces.
612 Spaces are inserted at the end of the string as needed.
614 @item @emph{Standard}:
621 @code{RESULT = ADJUSTL(STR)}
623 @item @emph{Arguments}:
624 @multitable @columnfractions .15 .70
625 @item @var{STR} @tab The type shall be @code{CHARACTER}.
628 @item @emph{Return value}:
629 The return value is of type @code{CHARACTER} where leading spaces
630 are removed and the same number of spaces are inserted on the end
633 @item @emph{Example}:
636 character(len=20) :: str = ' gfortran'
639 end program test_adjustl
642 @item @emph{See also}:
643 @ref{ADJUSTR}, @ref{TRIM}
649 @section @code{ADJUSTR} --- Right adjust a string
651 @cindex string, adjust right
652 @cindex adjust string
655 @item @emph{Description}:
656 @code{ADJUSTR(STR)} will right adjust a string by removing trailing spaces.
657 Spaces are inserted at the start of the string as needed.
659 @item @emph{Standard}:
666 @code{RESULT = ADJUSTR(STR)}
668 @item @emph{Arguments}:
669 @multitable @columnfractions .15 .70
670 @item @var{STR} @tab The type shall be @code{CHARACTER}.
673 @item @emph{Return value}:
674 The return value is of type @code{CHARACTER} where trailing spaces
675 are removed and the same number of spaces are inserted at the start
678 @item @emph{Example}:
681 character(len=20) :: str = 'gfortran'
684 end program test_adjustr
687 @item @emph{See also}:
688 @ref{ADJUSTL}, @ref{TRIM}
694 @section @code{AIMAG} --- Imaginary part of complex number
699 @cindex complex numbers, imaginary part
702 @item @emph{Description}:
703 @code{AIMAG(Z)} yields the imaginary part of complex argument @code{Z}.
704 The @code{IMAG(Z)} and @code{IMAGPART(Z)} intrinsic functions are provided
705 for compatibility with @command{g77}, and their use in new code is
706 strongly discouraged.
708 @item @emph{Standard}:
709 F77 and later, has overloads that are GNU extensions
715 @code{RESULT = AIMAG(Z)}
717 @item @emph{Arguments}:
718 @multitable @columnfractions .15 .70
719 @item @var{Z} @tab The type of the argument shall be @code{COMPLEX(*)}.
722 @item @emph{Return value}:
723 The return value is of type real with the
724 kind type parameter of the argument.
726 @item @emph{Example}:
731 z4 = cmplx(1.e0_4, 0.e0_4)
732 z8 = cmplx(0.e0_8, 1.e0_8)
733 print *, aimag(z4), dimag(z8)
734 end program test_aimag
737 @item @emph{Specific names}:
738 @multitable @columnfractions .20 .20 .20 .25
739 @item Name @tab Argument @tab Return type @tab Standard
740 @item @code{DIMAG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{REAL(8)} @tab GNU extension
741 @item @code{IMAG(Z)} @tab @code{COMPLEX(*) Z} @tab @code{REAL(*)} @tab GNU extension
742 @item @code{IMAGPART(Z)} @tab @code{COMPLEX(*) Z} @tab @code{REAL(*)} @tab GNU extension
749 @section @code{AINT} --- Truncate to a whole number
753 @cindex rounding, floor
756 @item @emph{Description}:
757 @code{AINT(X [, KIND])} truncates its argument to a whole number.
759 @item @emph{Standard}:
766 @code{RESULT = AINT(X [, KIND])}
768 @item @emph{Arguments}:
769 @multitable @columnfractions .15 .70
770 @item @var{X} @tab The type of the argument shall be @code{REAL(*)}.
771 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
772 expression indicating the kind parameter of
776 @item @emph{Return value}:
777 The return value is of type real with the kind type parameter of the
778 argument if the optional @var{KIND} is absent; otherwise, the kind
779 type parameter will be given by @var{KIND}. If the magnitude of
780 @var{X} is less than one, then @code{AINT(X)} returns zero. If the
781 magnitude is equal to or greater than one, then it returns the largest
782 whole number that does not exceed its magnitude. The sign is the same
783 as the sign of @var{X}.
785 @item @emph{Example}:
792 print *, aint(x4), dint(x8)
794 end program test_aint
797 @item @emph{Specific names}:
798 @multitable @columnfractions .20 .20 .20 .25
799 @item Name @tab Argument @tab Return type @tab Standard
800 @item @code{DINT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
807 @section @code{ALARM} --- Execute a routine after a given delay
809 @cindex delayed execution
812 @item @emph{Description}:
813 @code{ALARM(SECONDS, HANDLER [, STATUS])} causes external subroutine @var{HANDLER}
814 to be executed after a delay of @var{SECONDS} by using @code{alarm(2)} to
815 set up a signal and @code{signal(2)} to catch it. If @var{STATUS} is
816 supplied, it will be returned with the number of seconds remaining until
817 any previously scheduled alarm was due to be delivered, or zero if there
818 was no previously scheduled alarm.
820 @item @emph{Standard}:
827 @code{CALL ALARM(SECONDS, HANDLER [, STATUS])}
829 @item @emph{Arguments}:
830 @multitable @columnfractions .15 .70
831 @item @var{SECONDS} @tab The type of the argument shall be a scalar
832 @code{INTEGER}. It is @code{INTENT(IN)}.
833 @item @var{HANDLER} @tab Signal handler (@code{INTEGER FUNCTION} or
834 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar. The scalar
835 values may be either @code{SIG_IGN=1} to ignore the alarm generated
836 or @code{SIG_DFL=0} to set the default action. It is @code{INTENT(IN)}.
837 @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
838 variable of the default @code{INTEGER} kind. It is @code{INTENT(OUT)}.
841 @item @emph{Example}:
844 external handler_print
846 call alarm (3, handler_print, i)
849 end program test_alarm
851 This will cause the external routine @var{handler_print} to be called
858 @section @code{ALL} --- All values in @var{MASK} along @var{DIM} are true
860 @cindex array, apply condition
861 @cindex array, condition testing
864 @item @emph{Description}:
865 @code{ALL(MASK [, DIM])} determines if all the values are true in @var{MASK}
866 in the array along dimension @var{DIM}.
868 @item @emph{Standard}:
872 transformational function
875 @code{RESULT = ALL(MASK [, DIM])}
877 @item @emph{Arguments}:
878 @multitable @columnfractions .15 .70
879 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL(*)} and
880 it shall not be scalar.
881 @item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer
882 with a value that lies between one and the rank of @var{MASK}.
885 @item @emph{Return value}:
886 @code{ALL(MASK)} returns a scalar value of type @code{LOGICAL(*)} where
887 the kind type parameter is the same as the kind type parameter of
888 @var{MASK}. If @var{DIM} is present, then @code{ALL(MASK, DIM)} returns
889 an array with the rank of @var{MASK} minus 1. The shape is determined from
890 the shape of @var{MASK} where the @var{DIM} dimension is elided.
894 @code{ALL(MASK)} is true if all elements of @var{MASK} are true.
895 It also is true if @var{MASK} has zero size; otherwise, it is false.
897 If the rank of @var{MASK} is one, then @code{ALL(MASK,DIM)} is equivalent
898 to @code{ALL(MASK)}. If the rank is greater than one, then @code{ALL(MASK,DIM)}
899 is determined by applying @code{ALL} to the array sections.
902 @item @emph{Example}:
906 l = all((/.true., .true., .true./))
911 integer a(2,3), b(2,3)
915 print *, all(a .eq. b, 1)
916 print *, all(a .eq. b, 2)
917 end subroutine section
925 @section @code{ALLOCATED} --- Status of an allocatable entity
927 @cindex allocation, status
930 @item @emph{Description}:
931 @code{ALLOCATED(X)} checks the status of whether @var{X} is allocated.
933 @item @emph{Standard}:
940 @code{RESULT = ALLOCATED(X)}
942 @item @emph{Arguments}:
943 @multitable @columnfractions .15 .70
944 @item @var{X} @tab The argument shall be an @code{ALLOCATABLE} array.
947 @item @emph{Return value}:
948 The return value is a scalar @code{LOGICAL} with the default logical
949 kind type parameter. If @var{X} is allocated, @code{ALLOCATED(X)}
950 is @code{.TRUE.}; otherwise, it returns the @code{.TRUE.}
952 @item @emph{Example}:
954 program test_allocated
956 real(4), allocatable :: x(:)
957 if (allocated(x) .eqv. .false.) allocate(x(i))
958 end program test_allocated
965 @section @code{AND} --- Bitwise logical AND
967 @cindex bitwise logical and
968 @cindex logical and, bitwise
971 @item @emph{Description}:
972 Bitwise logical @code{AND}.
974 This intrinsic routine is provided for backwards compatibility with
975 GNU Fortran 77. For integer arguments, programmers should consider
976 the use of the @ref{IAND} intrinsic defined by the Fortran standard.
978 @item @emph{Standard}:
982 Non-elemental function
985 @code{RESULT = AND(I, J)}
987 @item @emph{Arguments}:
988 @multitable @columnfractions .15 .70
989 @item @var{I} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
990 @item @var{J} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
993 @item @emph{Return value}:
994 The return type is either @code{INTEGER(*)} or @code{LOGICAL} after
995 cross-promotion of the arguments.
997 @item @emph{Example}:
1000 LOGICAL :: T = .TRUE., F = .FALSE.
1002 DATA a / Z'F' /, b / Z'3' /
1004 WRITE (*,*) AND(T, T), AND(T, F), AND(F, T), AND(F, F)
1005 WRITE (*,*) AND(a, b)
1009 @item @emph{See also}:
1010 F95 elemental function: @ref{IAND}
1016 @section @code{ANINT} --- Nearest whole number
1020 @cindex rounding, ceiling
1023 @item @emph{Description}:
1024 @code{ANINT(X [, KIND])} rounds its argument to the nearest whole number.
1026 @item @emph{Standard}:
1032 @item @emph{Syntax}:
1033 @code{RESULT = ANINT(X [, KIND])}
1035 @item @emph{Arguments}:
1036 @multitable @columnfractions .15 .70
1037 @item @var{X} @tab The type of the argument shall be @code{REAL(*)}.
1038 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
1039 expression indicating the kind parameter of
1043 @item @emph{Return value}:
1044 The return value is of type real with the kind type parameter of the
1045 argument if the optional @var{KIND} is absent; otherwise, the kind
1046 type parameter will be given by @var{KIND}. If @var{X} is greater than
1047 zero, then @code{ANINT(X)} returns @code{AINT(X+0.5)}. If @var{X} is
1048 less than or equal to zero, then it returns @code{AINT(X-0.5)}.
1050 @item @emph{Example}:
1057 print *, anint(x4), dnint(x8)
1059 end program test_anint
1062 @item @emph{Specific names}:
1063 @multitable @columnfractions .20 .20 .20 .25
1064 @item Name @tab Argument @tab Return type @tab Standard
1065 @item @code{DNINT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1072 @section @code{ANY} --- Any value in @var{MASK} along @var{DIM} is true
1074 @cindex array, apply condition
1075 @cindex array, condition testing
1078 @item @emph{Description}:
1079 @code{ANY(MASK [, DIM])} determines if any of the values in the logical array
1080 @var{MASK} along dimension @var{DIM} are @code{.TRUE.}.
1082 @item @emph{Standard}:
1086 transformational function
1088 @item @emph{Syntax}:
1089 @code{RESULT = ANY(MASK [, DIM])}
1091 @item @emph{Arguments}:
1092 @multitable @columnfractions .15 .70
1093 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL(*)} and
1094 it shall not be scalar.
1095 @item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer
1096 with a value that lies between one and the rank of @var{MASK}.
1099 @item @emph{Return value}:
1100 @code{ANY(MASK)} returns a scalar value of type @code{LOGICAL(*)} where
1101 the kind type parameter is the same as the kind type parameter of
1102 @var{MASK}. If @var{DIM} is present, then @code{ANY(MASK, DIM)} returns
1103 an array with the rank of @var{MASK} minus 1. The shape is determined from
1104 the shape of @var{MASK} where the @var{DIM} dimension is elided.
1108 @code{ANY(MASK)} is true if any element of @var{MASK} is true;
1109 otherwise, it is false. It also is false if @var{MASK} has zero size.
1111 If the rank of @var{MASK} is one, then @code{ANY(MASK,DIM)} is equivalent
1112 to @code{ANY(MASK)}. If the rank is greater than one, then @code{ANY(MASK,DIM)}
1113 is determined by applying @code{ANY} to the array sections.
1116 @item @emph{Example}:
1120 l = any((/.true., .true., .true./))
1125 integer a(2,3), b(2,3)
1129 print *, any(a .eq. b, 1)
1130 print *, any(a .eq. b, 2)
1131 end subroutine section
1132 end program test_any
1139 @section @code{ASIN} --- Arcsine function
1142 @cindex trigonometric function, sine, inverse
1143 @cindex sine, inverse
1146 @item @emph{Description}:
1147 @code{ASIN(X)} computes the arcsine of its @var{X} (inverse of @code{SIN(X)}).
1149 @item @emph{Standard}:
1155 @item @emph{Syntax}:
1156 @code{RESULT = ASIN(X)}
1158 @item @emph{Arguments}:
1159 @multitable @columnfractions .15 .70
1160 @item @var{X} @tab The type shall be @code{REAL(*)}, and a magnitude that is
1164 @item @emph{Return value}:
1165 The return value is of type @code{REAL(*)} and it lies in the
1166 range @math{-\pi / 2 \leq \asin (x) \leq \pi / 2}. The kind type
1167 parameter is the same as @var{X}.
1169 @item @emph{Example}:
1172 real(8) :: x = 0.866_8
1174 end program test_asin
1177 @item @emph{Specific names}:
1178 @multitable @columnfractions .20 .20 .20 .25
1179 @item Name @tab Argument @tab Return type @tab Standard
1180 @item @code{DASIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1183 @item @emph{See also}:
1184 Inverse function: @ref{SIN}
1191 @section @code{ASINH} --- Hyperbolic arcsine function
1194 @cindex area hyperbolic sine
1195 @cindex hyperbolic arcsine
1196 @cindex hyperbolic function, sine, inverse
1197 @cindex sine, hyperbolic, inverse
1200 @item @emph{Description}:
1201 @code{ASINH(X)} computes the hyperbolic arcsine of @var{X} (inverse of @code{SINH(X)}).
1203 @item @emph{Standard}:
1209 @item @emph{Syntax}:
1210 @code{RESULT = ASINH(X)}
1212 @item @emph{Arguments}:
1213 @multitable @columnfractions .15 .70
1214 @item @var{X} @tab The type shall be @code{REAL(*)}, with @var{X} a real number.
1217 @item @emph{Return value}:
1218 The return value is of type @code{REAL(*)} and it lies in the
1219 range @math{-\infty \leq \asinh (x) \leq \infty}.
1221 @item @emph{Example}:
1224 REAL(8), DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1225 WRITE (*,*) ASINH(x)
1229 @item @emph{Specific names}:
1230 @multitable @columnfractions .20 .20 .20 .25
1231 @item Name @tab Argument @tab Return type @tab Standard
1232 @item @code{DASINH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension.
1235 @item @emph{See also}:
1236 Inverse function: @ref{SINH}
1242 @section @code{ASSOCIATED} --- Status of a pointer or pointer/target pair
1244 @cindex pointer, status
1245 @cindex association status
1248 @item @emph{Description}:
1249 @code{ASSOCIATED(PTR [, TGT])} determines the status of the pointer @var{PTR}
1250 or if @var{PTR} is associated with the target @var{TGT}.
1252 @item @emph{Standard}:
1258 @item @emph{Syntax}:
1259 @code{RESULT = ASSOCIATED(PTR [, TGT])}
1261 @item @emph{Arguments}:
1262 @multitable @columnfractions .15 .70
1263 @item @var{PTR} @tab @var{PTR} shall have the @code{POINTER} attribute and
1264 it can be of any type.
1265 @item @var{TGT} @tab (Optional) @var{TGT} shall be a @code{POINTER} or
1266 a @code{TARGET}. It must have the same type, kind type parameter, and
1267 array rank as @var{PTR}.
1269 The status of neither @var{PTR} nor @var{TGT} can be undefined.
1271 @item @emph{Return value}:
1272 @code{ASSOCIATED(PTR)} returns a scalar value of type @code{LOGICAL(4)}.
1273 There are several cases:
1275 @item (A) If the optional @var{TGT} is not present, then @code{ASSOCIATED(PTR)}
1276 is true if @var{PTR} is associated with a target; otherwise, it returns false.
1277 @item (B) If @var{TGT} is present and a scalar target, the result is true if
1279 is not a 0 sized storage sequence and the target associated with @var{PTR}
1280 occupies the same storage units. If @var{PTR} is disassociated, then the
1282 @item (C) If @var{TGT} is present and an array target, the result is true if
1283 @var{TGT} and @var{PTR} have the same shape, are not 0 sized arrays, are
1284 arrays whose elements are not 0 sized storage sequences, and @var{TGT} and
1285 @var{PTR} occupy the same storage units in array element order.
1286 As in case(B), the result is false, if @var{PTR} is disassociated.
1287 @item (D) If @var{TGT} is present and an scalar pointer, the result is true if
1288 target associated with @var{PTR} and the target associated with @var{TGT}
1289 are not 0 sized storage sequences and occupy the same storage units.
1290 The result is false, if either @var{TGT} or @var{PTR} is disassociated.
1291 @item (E) If @var{TGT} is present and an array pointer, the result is true if
1292 target associated with @var{PTR} and the target associated with @var{TGT}
1293 have the same shape, are not 0 sized arrays, are arrays whose elements are
1294 not 0 sized storage sequences, and @var{TGT} and @var{PTR} occupy the same
1295 storage units in array element order.
1296 The result is false, if either @var{TGT} or @var{PTR} is disassociated.
1299 @item @emph{Example}:
1301 program test_associated
1303 real, target :: tgt(2) = (/1., 2./)
1304 real, pointer :: ptr(:)
1306 if (associated(ptr) .eqv. .false.) call abort
1307 if (associated(ptr,tgt) .eqv. .false.) call abort
1308 end program test_associated
1311 @item @emph{See also}:
1318 @section @code{ATAN} --- Arctangent function
1321 @cindex trigonometric function, tangent, inverse
1322 @cindex tangent, inverse
1325 @item @emph{Description}:
1326 @code{ATAN(X)} computes the arctangent of @var{X}.
1328 @item @emph{Standard}:
1334 @item @emph{Syntax}:
1335 @code{RESULT = ATAN(X)}
1337 @item @emph{Arguments}:
1338 @multitable @columnfractions .15 .70
1339 @item @var{X} @tab The type shall be @code{REAL(*)}.
1342 @item @emph{Return value}:
1343 The return value is of type @code{REAL(*)} and it lies in the
1344 range @math{ - \pi / 2 \leq \atan (x) \leq \pi / 2}.
1346 @item @emph{Example}:
1349 real(8) :: x = 2.866_8
1351 end program test_atan
1354 @item @emph{Specific names}:
1355 @multitable @columnfractions .20 .20 .20 .25
1356 @item Name @tab Argument @tab Return type @tab Standard
1357 @item @code{DATAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1360 @item @emph{See also}:
1361 Inverse function: @ref{TAN}
1368 @section @code{ATAN2} --- Arctangent function
1371 @cindex trigonometric function, tangent, inverse
1372 @cindex tangent, inverse
1375 @item @emph{Description}:
1376 @code{ATAN2(Y,X)} computes the arctangent of the complex number
1379 @item @emph{Standard}:
1385 @item @emph{Syntax}:
1386 @code{RESULT = ATAN2(Y,X)}
1388 @item @emph{Arguments}:
1389 @multitable @columnfractions .15 .70
1390 @item @var{Y} @tab The type shall be @code{REAL(*)}.
1391 @item @var{X} @tab The type and kind type parameter shall be the same as @var{Y}.
1392 If @var{Y} is zero, then @var{X} must be nonzero.
1395 @item @emph{Return value}:
1396 The return value has the same type and kind type parameter as @var{Y}.
1397 It is the principal value of the complex number @math{X + i Y}. If
1398 @var{X} is nonzero, then it lies in the range @math{-\pi \le \atan (x) \leq \pi}.
1399 The sign is positive if @var{Y} is positive. If @var{Y} is zero, then
1400 the return value is zero if @var{X} is positive and @math{\pi} if @var{X}
1401 is negative. Finally, if @var{X} is zero, then the magnitude of the result
1404 @item @emph{Example}:
1407 real(4) :: x = 1.e0_4, y = 0.5e0_4
1409 end program test_atan2
1412 @item @emph{Specific names}:
1413 @multitable @columnfractions .20 .20 .20 .25
1414 @item Name @tab Argument @tab Return type @tab Standard
1415 @item @code{DATAN2(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1422 @section @code{ATANH} --- Hyperbolic arctangent function
1425 @cindex area hyperbolic tangent
1426 @cindex hyperbolic arctangent
1427 @cindex hyperbolic function, tangent, inverse
1428 @cindex tangent, hyperbolic, inverse
1431 @item @emph{Description}:
1432 @code{ATANH(X)} computes the hyperbolic arctangent of @var{X} (inverse
1435 @item @emph{Standard}:
1441 @item @emph{Syntax}:
1442 @code{RESULT = ATANH(X)}
1444 @item @emph{Arguments}:
1445 @multitable @columnfractions .15 .70
1446 @item @var{X} @tab The type shall be @code{REAL(*)} with a magnitude
1447 that is less than or equal to one.
1450 @item @emph{Return value}:
1451 The return value is of type @code{REAL(*)} and it lies in the
1452 range @math{-\infty \leq \atanh(x) \leq \infty}.
1454 @item @emph{Example}:
1457 REAL, DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1458 WRITE (*,*) ATANH(x)
1462 @item @emph{Specific names}:
1463 @multitable @columnfractions .20 .20 .20 .25
1464 @item Name @tab Argument @tab Return type @tab Standard
1465 @item @code{DATANH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1468 @item @emph{See also}:
1469 Inverse function: @ref{TANH}
1475 @section @code{BESJ0} --- Bessel function of the first kind of order 0
1478 @cindex Bessel function, first kind
1481 @item @emph{Description}:
1482 @code{BESJ0(X)} computes the Bessel function of the first kind of order 0
1485 @item @emph{Standard}:
1491 @item @emph{Syntax}:
1492 @code{RESULT = BESJ0(X)}
1494 @item @emph{Arguments}:
1495 @multitable @columnfractions .15 .70
1496 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1499 @item @emph{Return value}:
1500 The return value is of type @code{REAL(*)} and it lies in the
1501 range @math{ - 0.4027... \leq Bessel (0,x) \leq 1}.
1503 @item @emph{Example}:
1506 real(8) :: x = 0.0_8
1508 end program test_besj0
1511 @item @emph{Specific names}:
1512 @multitable @columnfractions .20 .20 .20 .25
1513 @item Name @tab Argument @tab Return type @tab Standard
1514 @item @code{DBESJ0(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1521 @section @code{BESJ1} --- Bessel function of the first kind of order 1
1524 @cindex Bessel function, first kind
1527 @item @emph{Description}:
1528 @code{BESJ1(X)} computes the Bessel function of the first kind of order 1
1531 @item @emph{Standard}:
1537 @item @emph{Syntax}:
1538 @code{RESULT = BESJ1(X)}
1540 @item @emph{Arguments}:
1541 @multitable @columnfractions .15 .70
1542 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1545 @item @emph{Return value}:
1546 The return value is of type @code{REAL(*)} and it lies in the
1547 range @math{ - 0.5818... \leq Bessel (0,x) \leq 0.5818 }.
1549 @item @emph{Example}:
1552 real(8) :: x = 1.0_8
1554 end program test_besj1
1557 @item @emph{Specific names}:
1558 @multitable @columnfractions .20 .20 .20 .25
1559 @item Name @tab Argument @tab Return type @tab Standard
1560 @item @code{DBESJ1(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1567 @section @code{BESJN} --- Bessel function of the first kind
1570 @cindex Bessel function, first kind
1573 @item @emph{Description}:
1574 @code{BESJN(N, X)} computes the Bessel function of the first kind of order
1577 @item @emph{Standard}:
1583 @item @emph{Syntax}:
1584 @code{RESULT = BESJN(N, X)}
1586 @item @emph{Arguments}:
1587 @multitable @columnfractions .15 .70
1588 @item @var{N} @tab The type shall be @code{INTEGER(*)}, and it shall be scalar.
1589 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1592 @item @emph{Return value}:
1593 The return value is a scalar of type @code{REAL(*)}.
1595 @item @emph{Example}:
1598 real(8) :: x = 1.0_8
1600 end program test_besjn
1603 @item @emph{Specific names}:
1604 @multitable @columnfractions .20 .20 .20 .25
1605 @item Name @tab Argument @tab Return type @tab Standard
1606 @item @code{DBESJN(X)} @tab @code{INTEGER(*) N} @tab @code{REAL(8)} @tab GNU extension
1607 @item @tab @code{REAL(8) X} @tab @tab
1614 @section @code{BESY0} --- Bessel function of the second kind of order 0
1617 @cindex Bessel function, second kind
1620 @item @emph{Description}:
1621 @code{BESY0(X)} computes the Bessel function of the second kind of order 0
1624 @item @emph{Standard}:
1630 @item @emph{Syntax}:
1631 @code{RESULT = BESY0(X)}
1633 @item @emph{Arguments}:
1634 @multitable @columnfractions .15 .70
1635 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1638 @item @emph{Return value}:
1639 The return value is a scalar of type @code{REAL(*)}.
1641 @item @emph{Example}:
1644 real(8) :: x = 0.0_8
1646 end program test_besy0
1649 @item @emph{Specific names}:
1650 @multitable @columnfractions .20 .20 .20 .25
1651 @item Name @tab Argument @tab Return type @tab Standard
1652 @item @code{DBESY0(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1659 @section @code{BESY1} --- Bessel function of the second kind of order 1
1662 @cindex Bessel function, second kind
1665 @item @emph{Description}:
1666 @code{BESY1(X)} computes the Bessel function of the second kind of order 1
1669 @item @emph{Standard}:
1675 @item @emph{Syntax}:
1676 @code{RESULT = BESY1(X)}
1678 @item @emph{Arguments}:
1679 @multitable @columnfractions .15 .70
1680 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1683 @item @emph{Return value}:
1684 The return value is a scalar of type @code{REAL(*)}.
1686 @item @emph{Example}:
1689 real(8) :: x = 1.0_8
1691 end program test_besy1
1694 @item @emph{Specific names}:
1695 @multitable @columnfractions .20 .20 .20 .25
1696 @item Name @tab Argument @tab Return type @tab Standard
1697 @item @code{DBESY1(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1704 @section @code{BESYN} --- Bessel function of the second kind
1707 @cindex Bessel function, second kind
1710 @item @emph{Description}:
1711 @code{BESYN(N, X)} computes the Bessel function of the second kind of order
1714 @item @emph{Standard}:
1720 @item @emph{Syntax}:
1721 @code{RESULT = BESYN(N, X)}
1723 @item @emph{Arguments}:
1724 @multitable @columnfractions .15 .70
1725 @item @var{N} @tab The type shall be @code{INTEGER(*)}, and it shall be scalar.
1726 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1729 @item @emph{Return value}:
1730 The return value is a scalar of type @code{REAL(*)}.
1732 @item @emph{Example}:
1735 real(8) :: x = 1.0_8
1737 end program test_besyn
1740 @item @emph{Specific names}:
1741 @multitable @columnfractions .20 .20 .20 .25
1742 @item Name @tab Argument @tab Return type @tab Standard
1743 @item @code{DBESYN(N,X)} @tab @code{INTEGER(*) N} @tab @code{REAL(8)} @tab GNU extension
1744 @item @tab @code{REAL(8) X} @tab @tab
1751 @section @code{BIT_SIZE} --- Bit size inquiry function
1753 @cindex bits, number of
1754 @cindex size of a variable, in bits
1757 @item @emph{Description}:
1758 @code{BIT_SIZE(I)} returns the number of bits (integer precision plus sign bit)
1759 represented by the type of @var{I}.
1761 @item @emph{Standard}:
1767 @item @emph{Syntax}:
1768 @code{RESULT = BIT_SIZE(I)}
1770 @item @emph{Arguments}:
1771 @multitable @columnfractions .15 .70
1772 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1775 @item @emph{Return value}:
1776 The return value is of type @code{INTEGER(*)}
1778 @item @emph{Example}:
1780 program test_bit_size
1785 end program test_bit_size
1792 @section @code{BTEST} --- Bit test function
1794 @cindex bits, testing
1797 @item @emph{Description}:
1798 @code{BTEST(I,POS)} returns logical @code{.TRUE.} if the bit at @var{POS}
1801 @item @emph{Standard}:
1807 @item @emph{Syntax}:
1808 @code{RESULT = BTEST(I, POS)}
1810 @item @emph{Arguments}:
1811 @multitable @columnfractions .15 .70
1812 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1813 @item @var{POS} @tab The type shall be @code{INTEGER(*)}.
1816 @item @emph{Return value}:
1817 The return value is of type @code{LOGICAL}
1819 @item @emph{Example}:
1822 integer :: i = 32768 + 1024 + 64
1826 bool = btest(i, pos)
1829 end program test_btest
1836 @section @code{CEILING} --- Integer ceiling function
1839 @cindex rounding, ceiling
1842 @item @emph{Description}:
1843 @code{CEILING(X)} returns the least integer greater than or equal to @var{X}.
1845 @item @emph{Standard}:
1851 @item @emph{Syntax}:
1852 @code{RESULT = CEILING(X [, KIND])}
1854 @item @emph{Arguments}:
1855 @multitable @columnfractions .15 .70
1856 @item @var{X} @tab The type shall be @code{REAL(*)}.
1857 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
1858 expression indicating the kind parameter of
1862 @item @emph{Return value}:
1863 The return value is of type @code{INTEGER(KIND)}
1865 @item @emph{Example}:
1867 program test_ceiling
1870 print *, ceiling(x) ! returns 64
1871 print *, ceiling(y) ! returns -63
1872 end program test_ceiling
1875 @item @emph{See also}:
1876 @ref{FLOOR}, @ref{NINT}
1883 @section @code{CHAR} --- Character conversion function
1885 @cindex conversion, to character
1888 @item @emph{Description}:
1889 @code{CHAR(I [, KIND])} returns the character represented by the integer @var{I}.
1891 @item @emph{Standard}:
1897 @item @emph{Syntax}:
1898 @code{RESULT = CHAR(I [, KIND])}
1900 @item @emph{Arguments}:
1901 @multitable @columnfractions .15 .70
1902 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1903 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
1904 expression indicating the kind parameter of
1908 @item @emph{Return value}:
1909 The return value is of type @code{CHARACTER(1)}
1911 @item @emph{Example}:
1917 print *, i, c ! returns 'J'
1918 end program test_char
1922 See @ref{ICHAR} for a discussion of converting between numerical values
1923 and formatted string representations.
1925 @item @emph{See also}:
1926 @ref{ACHAR}, @ref{IACHAR}, @ref{ICHAR}
1933 @section @code{CHDIR} --- Change working directory
1935 @cindex system, working directory
1938 @item @emph{Description}:
1939 Change current working directory to a specified path.
1941 This intrinsic is provided in both subroutine and function forms; however,
1942 only one form can be used in any given program unit.
1944 @item @emph{Standard}:
1948 Subroutine, non-elemental function
1950 @item @emph{Syntax}:
1951 @multitable @columnfractions .80
1952 @item @code{CALL CHDIR(NAME [, STATUS])}
1953 @item @code{STATUS = CHDIR(NAME)}
1956 @item @emph{Arguments}:
1957 @multitable @columnfractions .15 .70
1958 @item @var{NAME} @tab The type shall be @code{CHARACTER(*)} and shall
1959 specify a valid path within the file system.
1960 @item @var{STATUS} @tab (Optional) @code{INTEGER} status flag of the default
1961 kind. Returns 0 on success, and a system specific
1962 and non-zero error code otherwise.
1965 @item @emph{Example}:
1968 CHARACTER(len=255) :: path
1970 WRITE(*,*) TRIM(path)
1973 WRITE(*,*) TRIM(path)
1977 @item @emph{See also}:
1984 @section @code{CHMOD} --- Change access permissions of files
1986 @cindex file system, change access mode
1989 @item @emph{Description}:
1990 @code{CHMOD} changes the permissions of a file. This function invokes
1991 @code{/bin/chmod} and might therefore not work on all platforms.
1993 This intrinsic is provided in both subroutine and function forms; however,
1994 only one form can be used in any given program unit.
1996 @item @emph{Standard}:
2000 Subroutine, non-elemental function
2002 @item @emph{Syntax}:
2003 @multitable @columnfractions .80
2004 @item @code{CALL CHMOD(NAME, MODE[, STATUS])}
2005 @item @code{STATUS = CHMOD(NAME, MODE)}
2008 @item @emph{Arguments}:
2009 @multitable @columnfractions .15 .70
2010 @item @var{NAME} @tab Scalar @code{CHARACTER} with the file name.
2011 Trailing blanks are ignored unless the character @code{achar(0)} is
2012 present, then all characters up to and excluding @code{achar(0)} are
2013 used as the file name.
2015 @item @var{MODE} @tab Scalar @code{CHARACTER} giving the file permission.
2016 @var{MODE} uses the same syntax as the @var{MODE} argument of
2019 @item @var{STATUS} @tab (optional) scalar @code{INTEGER}, which is
2020 @code{0} on success and non-zero otherwise.
2023 @item @emph{Return value}:
2024 In either syntax, @var{STATUS} is set to @code{0} on success and non-zero
2027 @item @emph{Example}:
2028 @code{CHMOD} as subroutine
2033 call chmod('test.dat','u+x',status)
2034 print *, 'Status: ', status
2035 end program chmod_test
2037 @code{CHMOD} as non-elemental function:
2042 status = chmod('test.dat','u+x')
2043 print *, 'Status: ', status
2044 end program chmod_test
2052 @section @code{CMPLX} --- Complex conversion function
2054 @cindex complex numbers, conversion to
2055 @cindex conversion, to complex
2058 @item @emph{Description}:
2059 @code{CMPLX(X [, Y [, KIND]])} returns a complex number where @var{X} is converted to
2060 the real component. If @var{Y} is present it is converted to the imaginary
2061 component. If @var{Y} is not present then the imaginary component is set to
2062 0.0. If @var{X} is complex then @var{Y} must not be present.
2064 @item @emph{Standard}:
2070 @item @emph{Syntax}:
2071 @code{RESULT = CMPLX(X [, Y [, KIND]])}
2073 @item @emph{Arguments}:
2074 @multitable @columnfractions .15 .70
2075 @item @var{X} @tab The type may be @code{INTEGER(*)}, @code{REAL(*)},
2076 or @code{COMPLEX(*)}.
2077 @item @var{Y} @tab (Optional; only allowed if @var{X} is not
2078 @code{COMPLEX(*)}.) May be @code{INTEGER(*)}
2080 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
2081 expression indicating the kind parameter of
2085 @item @emph{Return value}:
2086 The return value is of type @code{COMPLEX(*)}
2088 @item @emph{Example}:
2095 print *, z, cmplx(x)
2096 end program test_cmplx
2102 @node COMMAND_ARGUMENT_COUNT
2103 @section @code{COMMAND_ARGUMENT_COUNT} --- Get number of command line arguments
2104 @fnindex COMMAND_ARGUMENT_COUNT
2105 @cindex command-line arguments
2106 @cindex command-line arguments, number of
2107 @cindex arguments, to program
2110 @item @emph{Description}:
2111 @code{COMMAND_ARGUMENT_COUNT()} returns the number of arguments passed on the
2112 command line when the containing program was invoked.
2114 @item @emph{Standard}:
2120 @item @emph{Syntax}:
2121 @code{RESULT = COMMAND_ARGUMENT_COUNT()}
2123 @item @emph{Arguments}:
2124 @multitable @columnfractions .15 .70
2128 @item @emph{Return value}:
2129 The return value is of type @code{INTEGER(4)}
2131 @item @emph{Example}:
2133 program test_command_argument_count
2135 count = command_argument_count()
2137 end program test_command_argument_count
2140 @item @emph{See also}:
2141 @ref{GET_COMMAND}, @ref{GET_COMMAND_ARGUMENT}
2147 @section @code{CONJG} --- Complex conjugate function
2150 @cindex complex conjugate
2153 @item @emph{Description}:
2154 @code{CONJG(Z)} returns the conjugate of @var{Z}. If @var{Z} is @code{(x, y)}
2155 then the result is @code{(x, -y)}
2157 @item @emph{Standard}:
2158 F77 and later, has overloads that are GNU extensions
2163 @item @emph{Syntax}:
2166 @item @emph{Arguments}:
2167 @multitable @columnfractions .15 .70
2168 @item @var{Z} @tab The type shall be @code{COMPLEX(*)}.
2171 @item @emph{Return value}:
2172 The return value is of type @code{COMPLEX(*)}.
2174 @item @emph{Example}:
2177 complex :: z = (2.0, 3.0)
2178 complex(8) :: dz = (2.71_8, -3.14_8)
2183 end program test_conjg
2186 @item @emph{Specific names}:
2187 @multitable @columnfractions .20 .20 .20 .25
2188 @item Name @tab Argument @tab Return type @tab Standard
2189 @item @code{DCONJG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
2196 @section @code{COS} --- Cosine function
2202 @cindex trigonometric function, cosine
2206 @item @emph{Description}:
2207 @code{COS(X)} computes the cosine of @var{X}.
2209 @item @emph{Standard}:
2210 F77 and later, has overloads that are GNU extensions
2215 @item @emph{Syntax}:
2216 @code{RESULT = COS(X)}
2218 @item @emph{Arguments}:
2219 @multitable @columnfractions .15 .70
2220 @item @var{X} @tab The type shall be @code{REAL(*)} or
2224 @item @emph{Return value}:
2225 The return value is of type @code{REAL(*)} and it lies in the
2226 range @math{ -1 \leq \cos (x) \leq 1}. The kind type
2227 parameter is the same as @var{X}.
2229 @item @emph{Example}:
2234 end program test_cos
2237 @item @emph{Specific names}:
2238 @multitable @columnfractions .20 .20 .20 .25
2239 @item Name @tab Argument @tab Return type @tab Standard
2240 @item @code{DCOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
2241 @item @code{CCOS(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab F77 and later
2242 @item @code{ZCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
2243 @item @code{CDCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
2246 @item @emph{See also}:
2247 Inverse function: @ref{ACOS}
2254 @section @code{COSH} --- Hyperbolic cosine function
2257 @cindex hyperbolic cosine
2258 @cindex hyperbolic function, cosine
2259 @cindex cosine, hyperbolic
2262 @item @emph{Description}:
2263 @code{COSH(X)} computes the hyperbolic cosine of @var{X}.
2265 @item @emph{Standard}:
2271 @item @emph{Syntax}:
2274 @item @emph{Arguments}:
2275 @multitable @columnfractions .15 .70
2276 @item @var{X} @tab The type shall be @code{REAL(*)}.
2279 @item @emph{Return value}:
2280 The return value is of type @code{REAL(*)} and it is positive
2281 (@math{ \cosh (x) \geq 0 }.
2283 @item @emph{Example}:
2286 real(8) :: x = 1.0_8
2288 end program test_cosh
2291 @item @emph{Specific names}:
2292 @multitable @columnfractions .20 .20 .20 .25
2293 @item Name @tab Argument @tab Return type @tab Standard
2294 @item @code{DCOSH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
2297 @item @emph{See also}:
2298 Inverse function: @ref{ACOSH}
2305 @section @code{COUNT} --- Count function
2307 @cindex array, conditionally count elements
2308 @cindex array, element counting
2309 @cindex array, number of elements
2312 @item @emph{Description}:
2313 @code{COUNT(MASK [, DIM])} counts the number of @code{.TRUE.} elements of
2314 @var{MASK} along the dimension of @var{DIM}. If @var{DIM} is omitted it is
2315 taken to be @code{1}. @var{DIM} is a scaler of type @code{INTEGER} in the
2316 range of @math{1 /leq DIM /leq n)} where @math{n} is the rank of @var{MASK}.
2318 @item @emph{Standard}:
2322 transformational function
2324 @item @emph{Syntax}:
2325 @code{RESULT = COUNT(MASK [, DIM])}
2327 @item @emph{Arguments}:
2328 @multitable @columnfractions .15 .70
2329 @item @var{MASK} @tab The type shall be @code{LOGICAL}.
2330 @item @var{DIM} @tab The type shall be @code{INTEGER}.
2333 @item @emph{Return value}:
2334 The return value is of type @code{INTEGER} with rank equal to that of
2337 @item @emph{Example}:
2340 integer, dimension(2,3) :: a, b
2341 logical, dimension(2,3) :: mask
2342 a = reshape( (/ 1, 2, 3, 4, 5, 6 /), (/ 2, 3 /))
2343 b = reshape( (/ 0, 7, 3, 4, 5, 8 /), (/ 2, 3 /))
2344 print '(3i3)', a(1,:)
2345 print '(3i3)', a(2,:)
2347 print '(3i3)', b(1,:)
2348 print '(3i3)', b(2,:)
2351 print '(3l3)', mask(1,:)
2352 print '(3l3)', mask(2,:)
2354 print '(3i3)', count(mask)
2356 print '(3i3)', count(mask, 1)
2358 print '(3i3)', count(mask, 2)
2359 end program test_count
2366 @section @code{CPU_TIME} --- CPU elapsed time in seconds
2368 @cindex time, elapsed
2371 @item @emph{Description}:
2372 Returns a @code{REAL(*)} value representing the elapsed CPU time in
2373 seconds. This is useful for testing segments of code to determine
2376 @item @emph{Standard}:
2382 @item @emph{Syntax}:
2383 @code{CALL CPU_TIME(TIME)}
2385 @item @emph{Arguments}:
2386 @multitable @columnfractions .15 .70
2387 @item @var{TIME} @tab The type shall be @code{REAL(*)} with @code{INTENT(OUT)}.
2390 @item @emph{Return value}:
2393 @item @emph{Example}:
2395 program test_cpu_time
2396 real :: start, finish
2397 call cpu_time(start)
2398 ! put code to test here
2399 call cpu_time(finish)
2400 print '("Time = ",f6.3," seconds.")',finish-start
2401 end program test_cpu_time
2404 @item @emph{See also}:
2405 @ref{SYSTEM_CLOCK}, @ref{DATE_AND_TIME}
2411 @section @code{CSHIFT} --- Circular shift elements of an array
2413 @cindex array, shift circularly
2414 @cindex array, permutation
2415 @cindex array, rotate
2418 @item @emph{Description}:
2419 @code{CSHIFT(ARRAY, SHIFT [, DIM])} performs a circular shift on elements of
2420 @var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is omitted it is
2421 taken to be @code{1}. @var{DIM} is a scaler of type @code{INTEGER} in the
2422 range of @math{1 /leq DIM /leq n)} where @math{n} is the rank of @var{ARRAY}.
2423 If the rank of @var{ARRAY} is one, then all elements of @var{ARRAY} are shifted
2424 by @var{SHIFT} places. If rank is greater than one, then all complete rank one
2425 sections of @var{ARRAY} along the given dimension are shifted. Elements
2426 shifted out one end of each rank one section are shifted back in the other end.
2428 @item @emph{Standard}:
2432 transformational function
2434 @item @emph{Syntax}:
2435 @code{RESULT = CSHIFT(A, SHIFT [, DIM])}
2437 @item @emph{Arguments}:
2438 @multitable @columnfractions .15 .70
2439 @item @var{ARRAY} @tab May be any type, not scaler.
2440 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
2441 @item @var{DIM} @tab The type shall be @code{INTEGER}.
2444 @item @emph{Return value}:
2445 Returns an array of same type and rank as the @var{ARRAY} argument.
2447 @item @emph{Example}:
2450 integer, dimension(3,3) :: a
2451 a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
2452 print '(3i3)', a(1,:)
2453 print '(3i3)', a(2,:)
2454 print '(3i3)', a(3,:)
2455 a = cshift(a, SHIFT=(/1, 2, -1/), DIM=2)
2457 print '(3i3)', a(1,:)
2458 print '(3i3)', a(2,:)
2459 print '(3i3)', a(3,:)
2460 end program test_cshift
2467 @section @code{CTIME} --- Convert a time into a string
2469 @cindex time, conversion to string
2470 @cindex conversion, to string
2473 @item @emph{Description}:
2474 @code{CTIME} converts a system time value, such as returned by
2475 @code{TIME8()}, to a string of the form @samp{Sat Aug 19 18:13:14 1995}.
2477 This intrinsic is provided in both subroutine and function forms; however,
2478 only one form can be used in any given program unit.
2480 @item @emph{Standard}:
2486 @item @emph{Syntax}:
2487 @multitable @columnfractions .80
2488 @item @code{CALL CTIME(TIME, RESULT)}.
2489 @item @code{RESULT = CTIME(TIME)}, (not recommended).
2492 @item @emph{Arguments}:
2493 @multitable @columnfractions .15 .70
2494 @item @var{TIME} @tab The type shall be of type @code{INTEGER(KIND=8)}.
2495 @item @var{RESULT} @tab The type shall be of type @code{CHARACTER}.
2498 @item @emph{Return value}:
2499 The converted date and time as a string.
2501 @item @emph{Example}:
2505 character(len=30) :: date
2508 ! Do something, main part of the program
2511 print *, 'Program was started on ', date
2512 end program test_ctime
2515 @item @emph{See Also}:
2516 @ref{GMTIME}, @ref{LTIME}, @ref{TIME}, @ref{TIME8}
2522 @section @code{DATE_AND_TIME} --- Date and time subroutine
2523 @fnindex DATE_AND_TIME
2524 @cindex date, current
2525 @cindex current date
2526 @cindex time, current
2527 @cindex current time
2530 @item @emph{Description}:
2531 @code{DATE_AND_TIME(DATE, TIME, ZONE, VALUES)} gets the corresponding date and
2532 time information from the real-time system clock. @var{DATE} is
2533 @code{INTENT(OUT)} and has form ccyymmdd. @var{TIME} is @code{INTENT(OUT)} and
2534 has form hhmmss.sss. @var{ZONE} is @code{INTENT(OUT)} and has form (+-)hhmm,
2535 representing the difference with respect to Coordinated Universal Time (UTC).
2536 Unavailable time and date parameters return blanks.
2538 @var{VALUES} is @code{INTENT(OUT)} and provides the following:
2540 @multitable @columnfractions .15 .30 .40
2541 @item @tab @code{VALUE(1)}: @tab The year
2542 @item @tab @code{VALUE(2)}: @tab The month
2543 @item @tab @code{VALUE(3)}: @tab The day of the month
2544 @item @tab @code{VALUE(4)}: @tab Time difference with UTC in minutes
2545 @item @tab @code{VALUE(5)}: @tab The hour of the day
2546 @item @tab @code{VALUE(6)}: @tab The minutes of the hour
2547 @item @tab @code{VALUE(7)}: @tab The seconds of the minute
2548 @item @tab @code{VALUE(8)}: @tab The milliseconds of the second
2551 @item @emph{Standard}:
2557 @item @emph{Syntax}:
2558 @code{CALL DATE_AND_TIME([DATE, TIME, ZONE, VALUES])}
2560 @item @emph{Arguments}:
2561 @multitable @columnfractions .15 .70
2562 @item @var{DATE} @tab (Optional) The type shall be @code{CHARACTER(8)} or larger.
2563 @item @var{TIME} @tab (Optional) The type shall be @code{CHARACTER(10)} or larger.
2564 @item @var{ZONE} @tab (Optional) The type shall be @code{CHARACTER(5)} or larger.
2565 @item @var{VALUES}@tab (Optional) The type shall be @code{INTEGER(8)}.
2568 @item @emph{Return value}:
2571 @item @emph{Example}:
2573 program test_time_and_date
2574 character(8) :: date
2575 character(10) :: time
2576 character(5) :: zone
2577 integer,dimension(8) :: values
2578 ! using keyword arguments
2579 call date_and_time(date,time,zone,values)
2580 call date_and_time(DATE=date,ZONE=zone)
2581 call date_and_time(TIME=time)
2582 call date_and_time(VALUES=values)
2583 print '(a,2x,a,2x,a)', date, time, zone
2584 print '(8i5))', values
2585 end program test_time_and_date
2588 @item @emph{See also}:
2589 @ref{CPU_TIME}, @ref{SYSTEM_CLOCK}
2595 @section @code{DBLE} --- Double conversion function
2597 @cindex conversion, to real
2600 @item @emph{Description}:
2601 @code{DBLE(X)} Converts @var{X} to double precision real type.
2603 @item @emph{Standard}:
2609 @item @emph{Syntax}:
2610 @code{RESULT = DBLE(X)}
2612 @item @emph{Arguments}:
2613 @multitable @columnfractions .15 .70
2614 @item @var{X} @tab The type shall be @code{INTEGER(*)}, @code{REAL(*)},
2615 or @code{COMPLEX(*)}.
2618 @item @emph{Return value}:
2619 The return value is of type double precision real.
2621 @item @emph{Example}:
2626 complex :: z = (2.3,1.14)
2627 print *, dble(x), dble(i), dble(z)
2628 end program test_dble
2631 @item @emph{See also}:
2632 @ref{DFLOAT}, @ref{FLOAT}, @ref{REAL}
2638 @section @code{DCMPLX} --- Double complex conversion function
2640 @cindex complex numbers, conversion to
2641 @cindex conversion, to complex
2644 @item @emph{Description}:
2645 @code{DCMPLX(X [,Y])} returns a double complex number where @var{X} is
2646 converted to the real component. If @var{Y} is present it is converted to the
2647 imaginary component. If @var{Y} is not present then the imaginary component is
2648 set to 0.0. If @var{X} is complex then @var{Y} must not be present.
2650 @item @emph{Standard}:
2656 @item @emph{Syntax}:
2657 @code{RESULT = DCMPLX(X [, Y])}
2659 @item @emph{Arguments}:
2660 @multitable @columnfractions .15 .70
2661 @item @var{X} @tab The type may be @code{INTEGER(*)}, @code{REAL(*)},
2662 or @code{COMPLEX(*)}.
2663 @item @var{Y} @tab (Optional if @var{X} is not @code{COMPLEX(*)}.) May be
2664 @code{INTEGER(*)} or @code{REAL(*)}.
2667 @item @emph{Return value}:
2668 The return value is of type @code{COMPLEX(8)}
2670 @item @emph{Example}:
2680 print *, dcmplx(x,i)
2681 end program test_dcmplx
2688 @section @code{DFLOAT} --- Double conversion function
2690 @cindex conversion, to real
2693 @item @emph{Description}:
2694 @code{DFLOAT(X)} Converts @var{X} to double precision real type.
2696 @item @emph{Standard}:
2702 @item @emph{Syntax}:
2703 @code{RESULT = DFLOAT(X)}
2705 @item @emph{Arguments}:
2706 @multitable @columnfractions .15 .70
2707 @item @var{X} @tab The type shall be @code{INTEGER(*)}.
2710 @item @emph{Return value}:
2711 The return value is of type double precision real.
2713 @item @emph{Example}:
2718 end program test_dfloat
2721 @item @emph{See also}:
2722 @ref{DBLE}, @ref{FLOAT}, @ref{REAL}
2728 @section @code{DIGITS} --- Significant digits function
2730 @cindex model representation, significant digits
2733 @item @emph{Description}:
2734 @code{DIGITS(X)} returns the number of significant digits of the internal model
2735 representation of @var{X}. For example, on a system using a 32-bit
2736 floating point representation, a default real number would likely return 24.
2738 @item @emph{Standard}:
2744 @item @emph{Syntax}:
2745 @code{RESULT = DIGITS(X)}
2747 @item @emph{Arguments}:
2748 @multitable @columnfractions .15 .70
2749 @item @var{X} @tab The type may be @code{INTEGER(*)} or @code{REAL(*)}.
2752 @item @emph{Return value}:
2753 The return value is of type @code{INTEGER}.
2755 @item @emph{Example}:
2758 integer :: i = 12345
2764 end program test_digits
2771 @section @code{DIM} --- Positive difference
2775 @cindex positive difference
2778 @item @emph{Description}:
2779 @code{DIM(X,Y)} returns the difference @code{X-Y} if the result is positive;
2780 otherwise returns zero.
2782 @item @emph{Standard}:
2788 @item @emph{Syntax}:
2789 @code{RESULT = DIM(X, Y)}
2791 @item @emph{Arguments}:
2792 @multitable @columnfractions .15 .70
2793 @item @var{X} @tab The type shall be @code{INTEGER(*)} or @code{REAL(*)}
2794 @item @var{Y} @tab The type shall be the same type and kind as @var{X}.
2797 @item @emph{Return value}:
2798 The return value is of type @code{INTEGER(*)} or @code{REAL(*)}.
2800 @item @emph{Example}:
2806 x = dim(4.345_8, 2.111_8)
2809 end program test_dim
2812 @item @emph{Specific names}:
2813 @multitable @columnfractions .20 .20 .20 .25
2814 @item Name @tab Argument @tab Return type @tab Standard
2815 @item @code{IDIM(X,Y)} @tab @code{INTEGER(4) X,Y} @tab @code{INTEGER(4)} @tab F77 and later
2816 @item @code{DDIM(X,Y)} @tab @code{REAL(8) X,Y} @tab @code{REAL(8)} @tab F77 and later
2823 @section @code{DOT_PRODUCT} --- Dot product function
2824 @fnindex DOT_PRODUCT
2826 @cindex vector product
2827 @cindex product, vector
2830 @item @emph{Description}:
2831 @code{DOT_PRODUCT(X,Y)} computes the dot product multiplication of two vectors
2832 @var{X} and @var{Y}. The two vectors may be either numeric or logical
2833 and must be arrays of rank one and of equal size. If the vectors are
2834 @code{INTEGER(*)} or @code{REAL(*)}, the result is @code{SUM(X*Y)}. If the
2835 vectors are @code{COMPLEX(*)}, the result is @code{SUM(CONJG(X)*Y)}. If the
2836 vectors are @code{LOGICAL}, the result is @code{ANY(X.AND.Y)}.
2838 @item @emph{Standard}:
2842 transformational function
2844 @item @emph{Syntax}:
2845 @code{RESULT = DOT_PRODUCT(X, Y)}
2847 @item @emph{Arguments}:
2848 @multitable @columnfractions .15 .70
2849 @item @var{X} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
2850 @item @var{Y} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
2853 @item @emph{Return value}:
2854 If the arguments are numeric, the return value is a scaler of numeric type,
2855 @code{INTEGER(*)}, @code{REAL(*)}, or @code{COMPLEX(*)}. If the arguments are
2856 @code{LOGICAL}, the return value is @code{.TRUE.} or @code{.FALSE.}.
2858 @item @emph{Example}:
2860 program test_dot_prod
2861 integer, dimension(3) :: a, b
2868 print *, dot_product(a,b)
2869 end program test_dot_prod
2876 @section @code{DPROD} --- Double product function
2878 @cindex product, double-precision
2881 @item @emph{Description}:
2882 @code{DPROD(X,Y)} returns the product @code{X*Y}.
2884 @item @emph{Standard}:
2890 @item @emph{Syntax}:
2891 @code{RESULT = DPROD(X, Y)}
2893 @item @emph{Arguments}:
2894 @multitable @columnfractions .15 .70
2895 @item @var{X} @tab The type shall be @code{REAL}.
2896 @item @var{Y} @tab The type shall be @code{REAL}.
2899 @item @emph{Return value}:
2900 The return value is of type @code{REAL(8)}.
2902 @item @emph{Example}:
2910 end program test_dprod
2917 @section @code{DREAL} --- Double real part function
2919 @cindex complex numbers, real part
2922 @item @emph{Description}:
2923 @code{DREAL(Z)} returns the real part of complex variable @var{Z}.
2925 @item @emph{Standard}:
2931 @item @emph{Syntax}:
2932 @code{RESULT = DREAL(Z)}
2934 @item @emph{Arguments}:
2935 @multitable @columnfractions .15 .70
2936 @item @var{Z} @tab The type shall be @code{COMPLEX(8)}.
2939 @item @emph{Return value}:
2940 The return value is of type @code{REAL(8)}.
2942 @item @emph{Example}:
2945 complex(8) :: z = (1.3_8,7.2_8)
2947 end program test_dreal
2950 @item @emph{See also}:
2958 @section @code{DTIME} --- Execution time subroutine (or function)
2960 @cindex time, elapsed
2961 @cindex elapsed time
2964 @item @emph{Description}:
2965 @code{DTIME(TARRAY, RESULT)} initially returns the number of seconds of runtime
2966 since the start of the process's execution in @var{RESULT}. @var{TARRAY}
2967 returns the user and system components of this time in @code{TARRAY(1)} and
2968 @code{TARRAY(2)} respectively. @var{RESULT} is equal to @code{TARRAY(1) +
2971 Subsequent invocations of @code{DTIME} return values accumulated since the
2972 previous invocation.
2974 On some systems, the underlying timings are represented using types with
2975 sufficiently small limits that overflows (wrap around) are possible, such as
2976 32-bit types. Therefore, the values returned by this intrinsic might be, or
2977 become, negative, or numerically less than previous values, during a single
2978 run of the compiled program.
2980 If @code{DTIME} is invoked as a function, it can not be invoked as a
2981 subroutine, and vice versa.
2983 @var{TARRAY} and @var{RESULT} are @code{INTENT(OUT)} and provide the following:
2985 @multitable @columnfractions .15 .30 .40
2986 @item @tab @code{TARRAY(1)}: @tab User time in seconds.
2987 @item @tab @code{TARRAY(2)}: @tab System time in seconds.
2988 @item @tab @code{RESULT}: @tab Run time since start in seconds.
2991 @item @emph{Standard}:
2997 @item @emph{Syntax}:
2998 @multitable @columnfractions .80
2999 @item @code{CALL DTIME(TARRAY, RESULT)}.
3000 @item @code{RESULT = DTIME(TARRAY)}, (not recommended).
3003 @item @emph{Arguments}:
3004 @multitable @columnfractions .15 .70
3005 @item @var{TARRAY}@tab The type shall be @code{REAL, DIMENSION(2)}.
3006 @item @var{RESULT}@tab The type shall be @code{REAL}.
3009 @item @emph{Return value}:
3010 Elapsed time in seconds since the start of program execution.
3012 @item @emph{Example}:
3016 real, dimension(2) :: tarray
3018 call dtime(tarray, result)
3022 do i=1,100000000 ! Just a delay
3025 call dtime(tarray, result)
3029 end program test_dtime
3036 @section @code{EOSHIFT} --- End-off shift elements of an array
3038 @cindex array, shift
3041 @item @emph{Description}:
3042 @code{EOSHIFT(ARRAY, SHIFT[,BOUNDARY, DIM])} performs an end-off shift on
3043 elements of @var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is
3044 omitted it is taken to be @code{1}. @var{DIM} is a scaler of type
3045 @code{INTEGER} in the range of @math{1 /leq DIM /leq n)} where @math{n} is the
3046 rank of @var{ARRAY}. If the rank of @var{ARRAY} is one, then all elements of
3047 @var{ARRAY} are shifted by @var{SHIFT} places. If rank is greater than one,
3048 then all complete rank one sections of @var{ARRAY} along the given dimension are
3049 shifted. Elements shifted out one end of each rank one section are dropped. If
3050 @var{BOUNDARY} is present then the corresponding value of from @var{BOUNDARY}
3051 is copied back in the other end. If @var{BOUNDARY} is not present then the
3052 following are copied in depending on the type of @var{ARRAY}.
3054 @multitable @columnfractions .15 .80
3055 @item @emph{Array Type} @tab @emph{Boundary Value}
3056 @item Numeric @tab 0 of the type and kind of @var{ARRAY}.
3057 @item Logical @tab @code{.FALSE.}.
3058 @item Character(@var{len}) @tab @var{len} blanks.
3061 @item @emph{Standard}:
3065 transformational function
3067 @item @emph{Syntax}:
3068 @code{RESULT = EOSHIFT(A, SHIFT [, BOUNDARY, DIM])}
3070 @item @emph{Arguments}:
3071 @multitable @columnfractions .15 .70
3072 @item @var{ARRAY} @tab May be any type, not scaler.
3073 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
3074 @item @var{BOUNDARY} @tab Same type as @var{ARRAY}.
3075 @item @var{DIM} @tab The type shall be @code{INTEGER}.
3078 @item @emph{Return value}:
3079 Returns an array of same type and rank as the @var{ARRAY} argument.
3081 @item @emph{Example}:
3083 program test_eoshift
3084 integer, dimension(3,3) :: a
3085 a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
3086 print '(3i3)', a(1,:)
3087 print '(3i3)', a(2,:)
3088 print '(3i3)', a(3,:)
3089 a = EOSHIFT(a, SHIFT=(/1, 2, 1/), BOUNDARY=-5, DIM=2)
3091 print '(3i3)', a(1,:)
3092 print '(3i3)', a(2,:)
3093 print '(3i3)', a(3,:)
3094 end program test_eoshift
3101 @section @code{EPSILON} --- Epsilon function
3103 @cindex model representation, epsilon
3106 @item @emph{Description}:
3107 @code{EPSILON(X)} returns a nearly negligible number relative to @code{1}.
3109 @item @emph{Standard}:
3115 @item @emph{Syntax}:
3116 @code{RESULT = EPSILON(X)}
3118 @item @emph{Arguments}:
3119 @multitable @columnfractions .15 .70
3120 @item @var{X} @tab The type shall be @code{REAL(*)}.
3123 @item @emph{Return value}:
3124 The return value is of same type as the argument.
3126 @item @emph{Example}:
3128 program test_epsilon
3133 end program test_epsilon
3140 @section @code{ERF} --- Error function
3142 @cindex error function
3145 @item @emph{Description}:
3146 @code{ERF(X)} computes the error function of @var{X}.
3148 @item @emph{Standard}:
3154 @item @emph{Syntax}:
3155 @code{RESULT = ERF(X)}
3157 @item @emph{Arguments}:
3158 @multitable @columnfractions .15 .70
3159 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
3162 @item @emph{Return value}:
3163 The return value is a scalar of type @code{REAL(*)} and it is positive
3164 (@math{ - 1 \leq erf (x) \leq 1 }.
3166 @item @emph{Example}:
3169 real(8) :: x = 0.17_8
3171 end program test_erf
3174 @item @emph{Specific names}:
3175 @multitable @columnfractions .20 .20 .20 .25
3176 @item Name @tab Argument @tab Return type @tab Standard
3177 @item @code{DERF(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
3184 @section @code{ERFC} --- Error function
3186 @cindex error function, complementary
3189 @item @emph{Description}:
3190 @code{ERFC(X)} computes the complementary error function of @var{X}.
3192 @item @emph{Standard}:
3198 @item @emph{Syntax}:
3199 @code{RESULT = ERFC(X)}
3201 @item @emph{Arguments}:
3202 @multitable @columnfractions .15 .70
3203 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
3206 @item @emph{Return value}:
3207 The return value is a scalar of type @code{REAL(*)} and it is positive
3208 (@math{ 0 \leq erfc (x) \leq 2 }.
3210 @item @emph{Example}:
3213 real(8) :: x = 0.17_8
3215 end program test_erfc
3218 @item @emph{Specific names}:
3219 @multitable @columnfractions .20 .20 .20 .25
3220 @item Name @tab Argument @tab Return type @tab Standard
3221 @item @code{DERFC(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
3228 @section @code{ETIME} --- Execution time subroutine (or function)
3230 @cindex time, elapsed
3233 @item @emph{Description}:
3234 @code{ETIME(TARRAY, RESULT)} returns the number of seconds of runtime
3235 since the start of the process's execution in @var{RESULT}. @var{TARRAY}
3236 returns the user and system components of this time in @code{TARRAY(1)} and
3237 @code{TARRAY(2)} respectively. @var{RESULT} is equal to @code{TARRAY(1) + TARRAY(2)}.
3239 On some systems, the underlying timings are represented using types with
3240 sufficiently small limits that overflows (wrap around) are possible, such as
3241 32-bit types. Therefore, the values returned by this intrinsic might be, or
3242 become, negative, or numerically less than previous values, during a single
3243 run of the compiled program.
3245 If @code{ETIME} is invoked as a function, it can not be invoked as a
3246 subroutine, and vice versa.
3248 @var{TARRAY} and @var{RESULT} are @code{INTENT(OUT)} and provide the following:
3250 @multitable @columnfractions .15 .30 .60
3251 @item @tab @code{TARRAY(1)}: @tab User time in seconds.
3252 @item @tab @code{TARRAY(2)}: @tab System time in seconds.
3253 @item @tab @code{RESULT}: @tab Run time since start in seconds.
3256 @item @emph{Standard}:
3262 @item @emph{Syntax}:
3263 @multitable @columnfractions .80
3264 @item @code{CALL ETIME(TARRAY, RESULT)}.
3265 @item @code{RESULT = ETIME(TARRAY)}, (not recommended).
3268 @item @emph{Arguments}:
3269 @multitable @columnfractions .15 .70
3270 @item @var{TARRAY}@tab The type shall be @code{REAL, DIMENSION(2)}.
3271 @item @var{RESULT}@tab The type shall be @code{REAL}.
3274 @item @emph{Return value}:
3275 Elapsed time in seconds since the start of program execution.
3277 @item @emph{Example}:
3281 real, dimension(2) :: tarray
3283 call ETIME(tarray, result)
3287 do i=1,100000000 ! Just a delay
3290 call ETIME(tarray, result)
3294 end program test_etime
3297 @item @emph{See also}:
3305 @section @code{EXIT} --- Exit the program with status.
3307 @cindex program termination
3308 @cindex terminate program
3311 @item @emph{Description}:
3312 @code{EXIT} causes immediate termination of the program with status. If status
3313 is omitted it returns the canonical @emph{success} for the system. All Fortran
3314 I/O units are closed.
3316 @item @emph{Standard}:
3322 @item @emph{Syntax}:
3323 @code{CALL EXIT([STATUS])}
3325 @item @emph{Arguments}:
3326 @multitable @columnfractions .15 .70
3327 @item @var{STATUS} @tab Shall be an @code{INTEGER} of the default kind.
3330 @item @emph{Return value}:
3331 @code{STATUS} is passed to the parent process on exit.
3333 @item @emph{Example}:
3336 integer :: STATUS = 0
3337 print *, 'This program is going to exit.'
3339 end program test_exit
3342 @item @emph{See also}:
3343 @ref{ABORT}, @ref{KILL}
3349 @section @code{EXP} --- Exponential function
3355 @cindex exponential function
3356 @cindex logarithmic function, inverse
3359 @item @emph{Description}:
3360 @code{EXP(X)} computes the base @math{e} exponential of @var{X}.
3362 @item @emph{Standard}:
3363 F77 and later, has overloads that are GNU extensions
3368 @item @emph{Syntax}:
3369 @code{RESULT = EXP(X)}
3371 @item @emph{Arguments}:
3372 @multitable @columnfractions .15 .70
3373 @item @var{X} @tab The type shall be @code{REAL(*)} or
3377 @item @emph{Return value}:
3378 The return value has same type and kind as @var{X}.
3380 @item @emph{Example}:
3385 end program test_exp
3388 @item @emph{Specific names}:
3389 @multitable @columnfractions .20 .20 .20 .25
3390 @item Name @tab Argument @tab Return type @tab Standard
3391 @item @code{DEXP(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
3392 @item @code{CEXP(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab F77 and later
3393 @item @code{ZEXP(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
3394 @item @code{CDEXP(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
3401 @section @code{EXPONENT} --- Exponent function
3403 @cindex real number, exponent
3404 @cindex floating point, exponent
3407 @item @emph{Description}:
3408 @code{EXPONENT(X)} returns the value of the exponent part of @var{X}. If @var{X}
3409 is zero the value returned is zero.
3411 @item @emph{Standard}:
3417 @item @emph{Syntax}:
3418 @code{RESULT = EXPONENT(X)}
3420 @item @emph{Arguments}:
3421 @multitable @columnfractions .15 .70
3422 @item @var{X} @tab The type shall be @code{REAL(*)}.
3425 @item @emph{Return value}:
3426 The return value is of type default @code{INTEGER}.
3428 @item @emph{Example}:
3430 program test_exponent
3435 print *, exponent(0.0)
3436 end program test_exponent
3443 @section @code{FDATE} --- Get the current time as a string
3445 @cindex time, current
3446 @cindex current time
3447 @cindex date, current
3448 @cindex current date
3451 @item @emph{Description}:
3452 @code{FDATE(DATE)} returns the current date (using the same format as
3453 @code{CTIME}) in @var{DATE}. It is equivalent to @code{CALL CTIME(DATE,
3456 If @code{FDATE} is invoked as a function, it can not be invoked as a
3457 subroutine, and vice versa.
3459 @var{DATE} is an @code{INTENT(OUT)} @code{CHARACTER} variable.
3461 @item @emph{Standard}:
3467 @item @emph{Syntax}:
3468 @multitable @columnfractions .80
3469 @item @code{CALL FDATE(DATE)}.
3470 @item @code{DATE = FDATE()}, (not recommended).
3473 @item @emph{Arguments}:
3474 @multitable @columnfractions .15 .70
3475 @item @var{DATE}@tab The type shall be of type @code{CHARACTER}.
3478 @item @emph{Return value}:
3479 The current date as a string.
3481 @item @emph{Example}:
3485 character(len=30) :: date
3487 print *, 'Program started on ', date
3488 do i = 1, 100000000 ! Just a delay
3492 print *, 'Program ended on ', date
3493 end program test_fdate
3500 @section @code{FLOAT} --- Convert integer to default real
3502 @cindex conversion, to real
3505 @item @emph{Description}:
3506 @code{FLOAT(I)} converts the integer @var{I} to a default real value.
3508 @item @emph{Standard}:
3514 @item @emph{Syntax}:
3515 @code{RESULT = FLOAT(I)}
3517 @item @emph{Arguments}:
3518 @multitable @columnfractions .15 .70
3519 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
3522 @item @emph{Return value}:
3523 The return value is of type default @code{REAL}.
3525 @item @emph{Example}:
3529 if (float(i) /= 1.) call abort
3530 end program test_float
3533 @item @emph{See also}:
3534 @ref{DBLE}, @ref{DFLOAT}, @ref{REAL}
3540 @section @code{FGET} --- Read a single character in stream mode from stdin
3542 @cindex read character, stream mode
3543 @cindex stream mode, read character
3544 @cindex file operation, read character
3547 @item @emph{Description}:
3548 Read a single character in stream mode from stdin by bypassing normal
3549 formatted output. Stream I/O should not be mixed with normal record-oriented
3550 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
3552 This intrinsic routine is provided for backwards compatibility with
3553 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
3554 Programmers should consider the use of new stream IO feature in new code
3555 for future portability. See also @ref{Fortran 2003 status}.
3557 @item @emph{Standard}:
3561 Non-elemental subroutine
3563 @item @emph{Syntax}:
3564 @code{CALL FGET(C [, STATUS])}
3566 @item @emph{Arguments}:
3567 @multitable @columnfractions .15 .70
3568 @item @var{C} @tab The type shall be @code{CHARACTER}.
3569 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
3570 Returns 0 on success, -1 on end-of-file, and a
3571 system specific positive error code otherwise.
3574 @item @emph{Example}:
3577 INTEGER, PARAMETER :: strlen = 100
3578 INTEGER :: status, i = 1
3579 CHARACTER(len=strlen) :: str = ""
3581 WRITE (*,*) 'Enter text:'
3583 CALL fget(str(i:i), status)
3584 if (status /= 0 .OR. i > strlen) exit
3587 WRITE (*,*) TRIM(str)
3591 @item @emph{See also}:
3592 @ref{FGETC}, @ref{FPUT}, @ref{FPUTC}
3598 @section @code{FGETC} --- Read a single character in stream mode
3600 @cindex read character, stream mode
3601 @cindex stream mode, read character
3602 @cindex file operation, read character
3605 @item @emph{Description}:
3606 Read a single character in stream mode by bypassing normal formatted output.
3607 Stream I/O should not be mixed with normal record-oriented (formatted or
3608 unformatted) I/O on the same unit; the results are unpredictable.
3610 This intrinsic routine is provided for backwards compatibility with
3611 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
3612 Programmers should consider the use of new stream IO feature in new code
3613 for future portability. See also @ref{Fortran 2003 status}.
3615 @item @emph{Standard}:
3619 Non-elemental subroutine
3621 @item @emph{Syntax}:
3622 @code{CALL FGETC(UNIT, C [, STATUS])}
3624 @item @emph{Arguments}:
3625 @multitable @columnfractions .15 .70
3626 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
3627 @item @var{C} @tab The type shall be @code{CHARACTER}.
3628 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. Returns 0 on success,
3629 -1 on end-of-file and a system specific positive error code otherwise.
3632 @item @emph{Example}:
3635 INTEGER :: fd = 42, status
3638 OPEN(UNIT=fd, FILE="/etc/passwd", ACTION="READ", STATUS = "OLD")
3640 CALL fgetc(fd, c, status)
3641 IF (status /= 0) EXIT
3648 @item @emph{See also}:
3649 @ref{FGET}, @ref{FPUT}, @ref{FPUTC}
3655 @section @code{FLOOR} --- Integer floor function
3658 @cindex rounding, floor
3661 @item @emph{Description}:
3662 @code{FLOOR(X)} returns the greatest integer less than or equal to @var{X}.
3664 @item @emph{Standard}:
3670 @item @emph{Syntax}:
3671 @code{RESULT = FLOOR(X [, KIND])}
3673 @item @emph{Arguments}:
3674 @multitable @columnfractions .15 .70
3675 @item @var{X} @tab The type shall be @code{REAL(*)}.
3676 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
3677 expression indicating the kind parameter of
3681 @item @emph{Return value}:
3682 The return value is of type @code{INTEGER(KIND)}
3684 @item @emph{Example}:
3689 print *, floor(x) ! returns 63
3690 print *, floor(y) ! returns -64
3691 end program test_floor
3694 @item @emph{See also}:
3695 @ref{CEILING}, @ref{NINT}
3702 @section @code{FLUSH} --- Flush I/O unit(s)
3704 @cindex file operation, flush
3707 @item @emph{Description}:
3708 Flushes Fortran unit(s) currently open for output. Without the optional
3709 argument, all units are flushed, otherwise just the unit specified.
3711 @item @emph{Standard}:
3715 Non-elemental subroutine
3717 @item @emph{Syntax}:
3718 @code{CALL FLUSH(UNIT)}
3720 @item @emph{Arguments}:
3721 @multitable @columnfractions .15 .70
3722 @item @var{UNIT} @tab (Optional) The type shall be @code{INTEGER}.
3726 Beginning with the Fortran 2003 standard, there is a @code{FLUSH}
3727 statement that should be preferred over the @code{FLUSH} intrinsic.
3734 @section @code{FNUM} --- File number function
3736 @cindex file operation, file number
3739 @item @emph{Description}:
3740 @code{FNUM(UNIT)} returns the POSIX file descriptor number corresponding to the
3741 open Fortran I/O unit @code{UNIT}.
3743 @item @emph{Standard}:
3747 Non-elemental function
3749 @item @emph{Syntax}:
3750 @code{RESULT = FNUM(UNIT)}
3752 @item @emph{Arguments}:
3753 @multitable @columnfractions .15 .70
3754 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
3757 @item @emph{Return value}:
3758 The return value is of type @code{INTEGER}
3760 @item @emph{Example}:
3764 open (unit=10, status = "scratch")
3768 end program test_fnum
3775 @section @code{FPUT} --- Write a single character in stream mode to stdout
3777 @cindex write character, stream mode
3778 @cindex stream mode, write character
3779 @cindex file operation, write character
3782 @item @emph{Description}:
3783 Write a single character in stream mode to stdout by bypassing normal
3784 formatted output. Stream I/O should not be mixed with normal record-oriented
3785 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
3787 This intrinsic routine is provided for backwards compatibility with
3788 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
3789 Programmers should consider the use of new stream IO feature in new code
3790 for future portability. See also @ref{Fortran 2003 status}.
3792 @item @emph{Standard}:
3796 Non-elemental subroutine
3798 @item @emph{Syntax}:
3799 @code{CALL FPUT(C [, STATUS])}
3801 @item @emph{Arguments}:
3802 @multitable @columnfractions .15 .70
3803 @item @var{C} @tab The type shall be @code{CHARACTER}.
3804 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. Returns 0 on success,
3805 -1 on end-of-file and a system specific positive error code otherwise.
3808 @item @emph{Example}:
3811 CHARACTER(len=10) :: str = "gfortran"
3813 DO i = 1, len_trim(str)
3819 @item @emph{See also}:
3820 @ref{FPUTC}, @ref{FGET}, @ref{FGETC}
3826 @section @code{FPUTC} --- Write a single character in stream mode
3828 @cindex write character, stream mode
3829 @cindex stream mode, write character
3830 @cindex file operation, write character
3833 @item @emph{Description}:
3834 Write a single character in stream mode by bypassing normal formatted
3835 output. Stream I/O should not be mixed with normal record-oriented
3836 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
3838 This intrinsic routine is provided for backwards compatibility with
3839 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
3840 Programmers should consider the use of new stream IO feature in new code
3841 for future portability. See also @ref{Fortran 2003 status}.
3843 @item @emph{Standard}:
3847 Non-elemental subroutine
3849 @item @emph{Syntax}:
3850 @code{CALL FPUTC(UNIT, C [, STATUS])}
3852 @item @emph{Arguments}:
3853 @multitable @columnfractions .15 .70
3854 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
3855 @item @var{C} @tab The type shall be @code{CHARACTER}.
3856 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. Returns 0 on success,
3857 -1 on end-of-file and a system specific positive error code otherwise.
3860 @item @emph{Example}:
3863 CHARACTER(len=10) :: str = "gfortran"
3864 INTEGER :: fd = 42, i
3866 OPEN(UNIT = fd, FILE = "out", ACTION = "WRITE", STATUS="NEW")
3867 DO i = 1, len_trim(str)
3868 CALL fputc(fd, str(i:i))
3874 @item @emph{See also}:
3875 @ref{FPUT}, @ref{FGET}, @ref{FGETC}
3881 @section @code{FRACTION} --- Fractional part of the model representation
3883 @cindex real number, fraction
3884 @cindex floating point, fraction
3887 @item @emph{Description}:
3888 @code{FRACTION(X)} returns the fractional part of the model
3889 representation of @code{X}.
3891 @item @emph{Standard}:
3897 @item @emph{Syntax}:
3898 @code{Y = FRACTION(X)}
3900 @item @emph{Arguments}:
3901 @multitable @columnfractions .15 .70
3902 @item @var{X} @tab The type of the argument shall be a @code{REAL}.
3905 @item @emph{Return value}:
3906 The return value is of the same type and kind as the argument.
3907 The fractional part of the model representation of @code{X} is returned;
3908 it is @code{X * RADIX(X)**(-EXPONENT(X))}.
3910 @item @emph{Example}:
3912 program test_fraction
3915 print *, fraction(x), x * radix(x)**(-exponent(x))
3916 end program test_fraction
3924 @section @code{FREE} --- Frees memory
3926 @cindex pointer, cray
3929 @item @emph{Description}:
3930 Frees memory previously allocated by @code{MALLOC()}. The @code{FREE}
3931 intrinsic is an extension intended to be used with Cray pointers, and is
3932 provided in GNU Fortran to allow user to compile legacy code. For
3933 new code using Fortran 95 pointers, the memory de-allocation intrinsic is
3936 @item @emph{Standard}:
3942 @item @emph{Syntax}:
3943 @code{CALL FREE(PTR)}
3945 @item @emph{Arguments}:
3946 @multitable @columnfractions .15 .70
3947 @item @var{PTR} @tab The type shall be @code{INTEGER}. It represents the
3948 location of the memory that should be de-allocated.
3951 @item @emph{Return value}:
3954 @item @emph{Example}:
3955 See @code{MALLOC} for an example.
3957 @item @emph{See also}:
3964 @section @code{FSEEK} --- Low level file positioning subroutine
3966 @cindex file operation, seek
3967 @cindex file operation, position
3970 @item @emph{Description}:
3971 Moves @var{UNIT} to the specified @var{OFFSET}. If @var{WHENCE}
3972 is set to 0, the @var{OFFSET} is taken as an absolute value @code{SEEK_SET},
3973 if set to 1, @var{OFFSET} is taken to be relative to the current position
3974 @code{SEEK_CUR}, and if set to 2 relative to the end of the file @code{SEEK_END}.
3975 On error, @var{STATUS} is set to a non-zero value. If @var{STATUS} the seek
3978 This intrinsic routine is not fully backwards compatible with @command{g77}.
3979 In @command{g77}, the @code{FSEEK} takes a statement label instead of a
3980 @var{STATUS} variable. If FSEEK is used in old code, change
3982 CALL FSEEK(UNIT, OFFSET, WHENCE, *label)
3987 CALL FSEEK(UNIT, OFFSET, WHENCE, status)
3988 IF (status /= 0) GOTO label
3991 Please note that GNU Fortran provides the Fortran 2003 Stream facility.
3992 Programmers should consider the use of new stream IO feature in new code
3993 for future portability. See also @ref{Fortran 2003 status}.
3995 @item @emph{Standard}:
4001 @item @emph{Syntax}:
4002 @code{CALL FSEEK(UNIT, OFFSET, WHENCE[, STATUS])}
4004 @item @emph{Arguments}:
4005 @multitable @columnfractions .15 .70
4006 @item @var{UNIT} @tab Shall be a scalar of type @code{INTEGER}.
4007 @item @var{OFFSET} @tab Shall be a scalar of type @code{INTEGER}.
4008 @item @var{WHENCE} @tab Shall be a scalar of type @code{INTEGER}.
4009 Its value shall be either 0, 1 or 2.
4010 @item @var{STATUS} @tab (Optional) shall be a scalar of type
4014 @item @emph{Example}:
4017 INTEGER, PARAMETER :: SEEK_SET = 0, SEEK_CUR = 1, SEEK_END = 2
4018 INTEGER :: fd, offset, ierr
4024 OPEN(UNIT=fd, FILE="fseek.test")
4025 CALL FSEEK(fd, offset, SEEK_SET, ierr) ! move to OFFSET
4026 print *, FTELL(fd), ierr
4028 CALL FSEEK(fd, 0, SEEK_END, ierr) ! move to end
4029 print *, FTELL(fd), ierr
4031 CALL FSEEK(fd, 0, SEEK_SET, ierr) ! move to beginning
4032 print *, FTELL(fd), ierr
4038 @item @emph{See also}:
4045 @section @code{FSTAT} --- Get file status
4047 @cindex file system, file status
4050 @item @emph{Description}:
4051 @code{FSTAT} is identical to @ref{STAT}, except that information about an
4052 already opened file is obtained.
4054 The elements in @code{BUFF} are the same as described by @ref{STAT}.
4056 @item @emph{Standard}:
4060 Non-elemental subroutine
4062 @item @emph{Syntax}:
4063 @code{CALL FSTAT(UNIT, BUFF [, STATUS])}
4065 @item @emph{Arguments}:
4066 @multitable @columnfractions .15 .70
4067 @item @var{UNIT} @tab An open I/O unit number of type @code{INTEGER}.
4068 @item @var{BUFF} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
4069 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0
4070 on success and a system specific error code otherwise.
4073 @item @emph{Example}:
4074 See @ref{STAT} for an example.
4076 @item @emph{See also}:
4077 To stat a link: @ref{LSTAT}, to stat a file: @ref{STAT}
4083 @section @code{FTELL} --- Current stream position
4085 @cindex file operation, position
4088 @item @emph{Description}:
4089 Retrieves the current position within an open file.
4091 This intrinsic is provided in both subroutine and function forms; however,
4092 only one form can be used in any given program unit.
4094 @item @emph{Standard}:
4098 Subroutine, function
4100 @item @emph{Syntax}:
4101 @multitable @columnfractions .80
4102 @item @code{CALL FTELL(UNIT, OFFSET)}
4103 @item @code{OFFSET = FTELL(UNIT)}
4106 @item @emph{Arguments}:
4107 @multitable @columnfractions .15 .70
4108 @item @var{OFFSET} @tab Shall of type @code{INTEGER}.
4109 @item @var{UNIT} @tab Shall of type @code{INTEGER}.
4112 @item @emph{Return value}:
4113 In either syntax, @var{OFFSET} is set to the current offset of unit
4114 number @var{UNIT}, or to @math{-1} if the unit is not currently open.
4116 @item @emph{Example}:
4120 OPEN(10, FILE="temp.dat")
4126 @item @emph{See also}:
4133 @section @code{GERROR} --- Get last system error message
4135 @cindex system, error handling
4138 @item @emph{Description}:
4139 Returns the system error message corresponding to the last system error.
4140 This resembles the functionality of @code{strerror(3)} in C.
4142 @item @emph{Standard}:
4148 @item @emph{Syntax}:
4149 @code{CALL GERROR(RESULT)}
4151 @item @emph{Arguments}:
4152 @multitable @columnfractions .15 .70
4153 @item @var{RESULT} @tab Shall of type @code{CHARACTER(*)}.
4156 @item @emph{Example}:
4159 CHARACTER(len=100) :: msg
4165 @item @emph{See also}:
4166 @ref{IERRNO}, @ref{PERROR}
4172 @section @code{GETARG} --- Get command line arguments
4174 @cindex command-line arguments
4175 @cindex arguments, to program
4178 @item @emph{Description}:
4179 Retrieve the @var{N}th argument that was passed on the
4180 command line when the containing program was invoked.
4182 This intrinsic routine is provided for backwards compatibility with
4183 GNU Fortran 77. In new code, programmers should consider the use of
4184 the @ref{GET_COMMAND_ARGUMENT} intrinsic defined by the Fortran 2003
4187 @item @emph{Standard}:
4193 @item @emph{Syntax}:
4194 @code{CALL GETARG(N, ARG)}
4196 @item @emph{Arguments}:
4197 @multitable @columnfractions .15 .70
4198 @item @var{N} @tab Shall be of type @code{INTEGER(4)}, @math{@var{N} \geq 0}
4199 @item @var{ARG} @tab Shall be of type @code{CHARACTER(*)}.
4202 @item @emph{Return value}:
4203 After @code{GETARG} returns, the @var{ARG} argument holds the @var{N}th
4204 command line argument. If @var{ARG} can not hold the argument, it is
4205 truncated to fit the length of @var{ARG}. If there are less than @var{N}
4206 arguments specified at the command line, @var{ARG} will be filled with blanks.
4207 If @math{@var{N} = 0}, @var{ARG} is set to the name of the program (on systems
4208 that support this feature).
4210 @item @emph{Example}:
4214 CHARACTER(len=32) :: arg
4223 @item @emph{See also}:
4224 GNU Fortran 77 compatibility function: @ref{IARGC}
4226 F2003 functions and subroutines: @ref{GET_COMMAND}, @ref{GET_COMMAND_ARGUMENT},
4227 @ref{COMMAND_ARGUMENT_COUNT}
4233 @section @code{GET_COMMAND} --- Get the entire command line
4234 @fnindex GET_COMMAND
4235 @cindex command-line arguments
4236 @cindex arguments, to program
4239 @item @emph{Description}:
4240 Retrieve the entire command line that was used to invoke the program.
4242 @item @emph{Standard}:
4248 @item @emph{Syntax}:
4249 @code{CALL GET_COMMAND(CMD)}
4251 @item @emph{Arguments}:
4252 @multitable @columnfractions .15 .70
4253 @item @var{CMD} @tab Shall be of type @code{CHARACTER(*)}.
4256 @item @emph{Return value}:
4257 Stores the entire command line that was used to invoke the program in @var{ARG}.
4258 If @var{ARG} is not large enough, the command will be truncated.
4260 @item @emph{Example}:
4262 PROGRAM test_get_command
4263 CHARACTER(len=255) :: cmd
4264 CALL get_command(cmd)
4265 WRITE (*,*) TRIM(cmd)
4269 @item @emph{See also}:
4270 @ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
4275 @node GET_COMMAND_ARGUMENT
4276 @section @code{GET_COMMAND_ARGUMENT} --- Get command line arguments
4277 @fnindex GET_COMMAND_ARGUMENT
4278 @cindex command-line arguments
4279 @cindex arguments, to program
4282 @item @emph{Description}:
4283 Retrieve the @var{N}th argument that was passed on the
4284 command line when the containing program was invoked.
4286 @item @emph{Standard}:
4292 @item @emph{Syntax}:
4293 @code{CALL GET_COMMAND_ARGUMENT(N, ARG)}
4295 @item @emph{Arguments}:
4296 @multitable @columnfractions .15 .70
4297 @item @var{N} @tab Shall be of type @code{INTEGER(4)}, @math{@var{N} \geq 0}
4298 @item @var{ARG} @tab Shall be of type @code{CHARACTER(*)}.
4301 @item @emph{Return value}:
4302 After @code{GET_COMMAND_ARGUMENT} returns, the @var{ARG} argument holds the
4303 @var{N}th command line argument. If @var{ARG} can not hold the argument, it is
4304 truncated to fit the length of @var{ARG}. If there are less than @var{N}
4305 arguments specified at the command line, @var{ARG} will be filled with blanks.
4306 If @math{@var{N} = 0}, @var{ARG} is set to the name of the program (on systems
4307 that support this feature).
4309 @item @emph{Example}:
4311 PROGRAM test_get_command_argument
4313 CHARACTER(len=32) :: arg
4317 CALL get_command_argument(i, arg)
4318 IF (LEN_TRIM(arg) == 0) EXIT
4320 WRITE (*,*) TRIM(arg)
4326 @item @emph{See also}:
4327 @ref{GET_COMMAND}, @ref{COMMAND_ARGUMENT_COUNT}
4333 @section @code{GETCWD} --- Get current working directory
4335 @cindex system, working directory
4338 @item @emph{Description}:
4339 Get current working directory.
4341 @item @emph{Standard}:
4345 Non-elemental subroutine.
4347 @item @emph{Syntax}:
4348 @code{CALL GETCWD(CWD [, STATUS])}
4350 @item @emph{Arguments}:
4351 @multitable @columnfractions .15 .70
4352 @item @var{CWD} @tab The type shall be @code{CHARACTER(*)}.
4353 @item @var{STATUS} @tab (Optional) status flag. Returns 0 on success,
4354 a system specific and non-zero error code otherwise.
4357 @item @emph{Example}:
4360 CHARACTER(len=255) :: cwd
4362 WRITE(*,*) TRIM(cwd)
4366 @item @emph{See also}:
4373 @section @code{GETENV} --- Get an environmental variable
4375 @cindex environment variable
4378 @item @emph{Description}:
4379 Get the @var{VALUE} of the environmental variable @var{ENVVAR}.
4381 This intrinsic routine is provided for backwards compatibility with
4382 GNU Fortran 77. In new code, programmers should consider the use of
4383 the @ref{GET_ENVIRONMENT_VARIABLE} intrinsic defined by the Fortran
4386 @item @emph{Standard}:
4392 @item @emph{Syntax}:
4393 @code{CALL GETENV(ENVVAR, VALUE)}
4395 @item @emph{Arguments}:
4396 @multitable @columnfractions .15 .70
4397 @item @var{ENVVAR} @tab Shall be of type @code{CHARACTER(*)}.
4398 @item @var{VALUE} @tab Shall be of type @code{CHARACTER(*)}.
4401 @item @emph{Return value}:
4402 Stores the value of @var{ENVVAR} in @var{VALUE}. If @var{VALUE} is
4403 not large enough to hold the data, it is truncated. If @var{ENVVAR}
4404 is not set, @var{VALUE} will be filled with blanks.
4406 @item @emph{Example}:
4409 CHARACTER(len=255) :: homedir
4410 CALL getenv("HOME", homedir)
4411 WRITE (*,*) TRIM(homedir)
4415 @item @emph{See also}:
4416 @ref{GET_ENVIRONMENT_VARIABLE}
4421 @node GET_ENVIRONMENT_VARIABLE
4422 @section @code{GET_ENVIRONMENT_VARIABLE} --- Get an environmental variable
4423 @fnindex GET_ENVIRONMENT_VARIABLE
4424 @cindex environment variable
4427 @item @emph{Description}:
4428 Get the @var{VALUE} of the environmental variable @var{ENVVAR}.
4430 @item @emph{Standard}:
4436 @item @emph{Syntax}:
4437 @code{CALL GET_ENVIRONMENT_VARIABLE(ENVVAR, VALUE)}
4439 @item @emph{Arguments}:
4440 @multitable @columnfractions .15 .70
4441 @item @var{ENVVAR} @tab Shall be of type @code{CHARACTER(*)}.
4442 @item @var{VALUE} @tab Shall be of type @code{CHARACTER(*)}.
4445 @item @emph{Return value}:
4446 Stores the value of @var{ENVVAR} in @var{VALUE}. If @var{VALUE} is
4447 not large enough to hold the data, it is truncated. If @var{ENVVAR}
4448 is not set, @var{VALUE} will be filled with blanks.
4450 @item @emph{Example}:
4453 CHARACTER(len=255) :: homedir
4454 CALL get_environment_variable("HOME", homedir)
4455 WRITE (*,*) TRIM(homedir)
4463 @section @code{GETGID} --- Group ID function
4465 @cindex system, group id
4468 @item @emph{Description}:
4469 Returns the numerical group ID of the current process.
4471 @item @emph{Standard}:
4477 @item @emph{Syntax}:
4478 @code{RESULT = GETGID()}
4480 @item @emph{Return value}:
4481 The return value of @code{GETGID} is an @code{INTEGER} of the default
4485 @item @emph{Example}:
4486 See @code{GETPID} for an example.
4488 @item @emph{See also}:
4489 @ref{GETPID}, @ref{GETUID}
4495 @section @code{GETLOG} --- Get login name
4497 @cindex system, login name
4501 @item @emph{Description}:
4502 Gets the username under which the program is running.
4504 @item @emph{Standard}:
4510 @item @emph{Syntax}:
4511 @code{CALL GETLOG(LOGIN)}
4513 @item @emph{Arguments}:
4514 @multitable @columnfractions .15 .70
4515 @item @var{LOGIN} @tab Shall be of type @code{CHARACTER(*)}.
4518 @item @emph{Return value}:
4519 Stores the current user name in @var{LOGIN}. (On systems where POSIX
4520 functions @code{geteuid} and @code{getpwuid} are not available, and
4521 the @code{getlogin} function is not implemented either, this will
4522 return a blank string.)
4524 @item @emph{Example}:
4527 CHARACTER(32) :: login
4533 @item @emph{See also}:
4540 @section @code{GETPID} --- Process ID function
4542 @cindex system, process id
4546 @item @emph{Description}:
4547 Returns the numerical process identifier of the current process.
4549 @item @emph{Standard}:
4555 @item @emph{Syntax}:
4556 @code{RESULT = GETPID()}
4558 @item @emph{Return value}:
4559 The return value of @code{GETPID} is an @code{INTEGER} of the default
4563 @item @emph{Example}:
4566 print *, "The current process ID is ", getpid()
4567 print *, "Your numerical user ID is ", getuid()
4568 print *, "Your numerical group ID is ", getgid()
4572 @item @emph{See also}:
4573 @ref{GETGID}, @ref{GETUID}
4579 @section @code{GETUID} --- User ID function
4581 @cindex system, user id
4585 @item @emph{Description}:
4586 Returns the numerical user ID of the current process.
4588 @item @emph{Standard}:
4594 @item @emph{Syntax}:
4595 @code{RESULT = GETUID()}
4597 @item @emph{Return value}:
4598 The return value of @code{GETUID} is an @code{INTEGER} of the default
4602 @item @emph{Example}:
4603 See @code{GETPID} for an example.
4605 @item @emph{See also}:
4606 @ref{GETPID}, @ref{GETLOG}
4612 @section @code{GMTIME} --- Convert time to GMT info
4614 @cindex time, conversion to GMT info
4617 @item @emph{Description}:
4618 Given a system time value @var{STIME} (as provided by the @code{TIME8()}
4619 intrinsic), fills @var{TARRAY} with values extracted from it appropriate
4620 to the UTC time zone (Universal Coordinated Time, also known in some
4621 countries as GMT, Greenwich Mean Time), using @code{gmtime(3)}.
4623 @item @emph{Standard}:
4629 @item @emph{Syntax}:
4630 @code{CALL GMTIME(STIME, TARRAY)}
4632 @item @emph{Arguments}:
4633 @multitable @columnfractions .15 .70
4634 @item @var{STIME} @tab An @code{INTEGER(*)} scalar expression
4635 corresponding to a system time, with
4637 @item @var{TARRAY} @tab A default @code{INTEGER} array with 9 elements,
4638 with @code{INTENT(OUT)}.
4641 @item @emph{Return value}:
4642 The elements of @var{TARRAY} are assigned as follows:
4644 @item Seconds after the minute, range 0--59 or 0--61 to allow for leap
4646 @item Minutes after the hour, range 0--59
4647 @item Hours past midnight, range 0--23
4648 @item Day of month, range 0--31
4649 @item Number of months since January, range 0--12
4650 @item Years since 1900
4651 @item Number of days since Sunday, range 0--6
4652 @item Days since January 1
4653 @item Daylight savings indicator: positive if daylight savings is in
4654 effect, zero if not, and negative if the information is not
4658 @item @emph{See also}:
4659 @ref{CTIME}, @ref{LTIME}, @ref{TIME}, @ref{TIME8}
4666 @section @code{HOSTNM} --- Get system host name
4668 @cindex system, host name
4671 @item @emph{Description}:
4672 Retrieves the host name of the system on which the program is running.
4674 This intrinsic is provided in both subroutine and function forms; however,
4675 only one form can be used in any given program unit.
4677 @item @emph{Standard}:
4681 Subroutine, function
4683 @item @emph{Syntax}:
4684 @multitable @columnfractions .80
4685 @item @code{CALL HOSTNM(NAME[, STATUS])}
4686 @item @code{STATUS = HOSTNM(NAME)}
4689 @item @emph{Arguments}:
4690 @multitable @columnfractions .15 .70
4691 @item @var{NAME} @tab Shall of type @code{CHARACTER(*)}.
4692 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
4693 Returns 0 on success, or a system specific error
4697 @item @emph{Return value}:
4698 In either syntax, @var{NAME} is set to the current hostname if it can
4699 be obtained, or to a blank string otherwise.
4706 @section @code{HUGE} --- Largest number of a kind
4708 @cindex limits, largest number
4709 @cindex model representation, largest number
4712 @item @emph{Description}:
4713 @code{HUGE(X)} returns the largest number that is not an infinity in
4714 the model of the type of @code{X}.
4716 @item @emph{Standard}:
4722 @item @emph{Syntax}:
4723 @code{RESULT = HUGE(X)}
4725 @item @emph{Arguments}:
4726 @multitable @columnfractions .15 .70
4727 @item @var{X} @tab Shall be of type @code{REAL} or @code{INTEGER}.
4730 @item @emph{Return value}:
4731 The return value is of the same type and kind as @var{X}
4733 @item @emph{Example}:
4735 program test_huge_tiny
4736 print *, huge(0), huge(0.0), huge(0.0d0)
4737 print *, tiny(0.0), tiny(0.0d0)
4738 end program test_huge_tiny
4745 @section @code{IACHAR} --- Code in @acronym{ASCII} collating sequence
4747 @cindex @acronym{ASCII} collating sequence
4748 @cindex collating sequence, @acronym{ASCII}
4749 @cindex conversion, to integer
4752 @item @emph{Description}:
4753 @code{IACHAR(C)} returns the code for the @acronym{ASCII} character
4754 in the first character position of @code{C}.
4756 @item @emph{Standard}:
4762 @item @emph{Syntax}:
4763 @code{RESULT = IACHAR(C)}
4765 @item @emph{Arguments}:
4766 @multitable @columnfractions .15 .70
4767 @item @var{C} @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
4770 @item @emph{Return value}:
4771 The return value is of type @code{INTEGER} and of the default integer
4774 @item @emph{Example}:
4779 end program test_iachar
4783 See @ref{ICHAR} for a discussion of converting between numerical values
4784 and formatted string representations.
4786 @item @emph{See also}:
4787 @ref{ACHAR}, @ref{CHAR}, @ref{ICHAR}
4794 @section @code{IAND} --- Bitwise logical and
4796 @cindex bitwise logical and
4797 @cindex logical and, bitwise
4800 @item @emph{Description}:
4801 Bitwise logical @code{AND}.
4803 @item @emph{Standard}:
4809 @item @emph{Syntax}:
4810 @code{RESULT = IAND(I, J)}
4812 @item @emph{Arguments}:
4813 @multitable @columnfractions .15 .70
4814 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
4815 @item @var{J} @tab The type shall be @code{INTEGER(*)}, of the same
4816 kind as @var{I}. (As a GNU extension, different kinds are also
4820 @item @emph{Return value}:
4821 The return type is @code{INTEGER(*)}, of the same kind as the
4822 arguments. (If the argument kinds differ, it is of the same kind as
4823 the larger argument.)
4825 @item @emph{Example}:
4829 DATA a / Z'F' /, b / Z'3' /
4830 WRITE (*,*) IAND(a, b)
4834 @item @emph{See also}:
4835 @ref{IOR}, @ref{IEOR}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
4842 @section @code{IARGC} --- Get the number of command line arguments
4844 @cindex command-line arguments
4845 @cindex command-line arguments, number of
4846 @cindex arguments, to program
4849 @item @emph{Description}:
4850 @code{IARGC()} returns the number of arguments passed on the
4851 command line when the containing program was invoked.
4853 This intrinsic routine is provided for backwards compatibility with
4854 GNU Fortran 77. In new code, programmers should consider the use of
4855 the @ref{COMMAND_ARGUMENT_COUNT} intrinsic defined by the Fortran 2003
4858 @item @emph{Standard}:
4862 Non-elemental Function
4864 @item @emph{Syntax}:
4865 @code{RESULT = IARGC()}
4867 @item @emph{Arguments}:
4870 @item @emph{Return value}:
4871 The number of command line arguments, type @code{INTEGER(4)}.
4873 @item @emph{Example}:
4876 @item @emph{See also}:
4877 GNU Fortran 77 compatibility subroutine: @ref{GETARG}
4879 F2003 functions and subroutines: @ref{GET_COMMAND}, @ref{GET_COMMAND_ARGUMENT},
4880 @ref{COMMAND_ARGUMENT_COUNT}
4886 @section @code{IBCLR} --- Clear bit
4892 @item @emph{Description}:
4893 @code{IBCLR} returns the value of @var{I} with the bit at position
4894 @var{POS} set to zero.
4896 @item @emph{Standard}:
4902 @item @emph{Syntax}:
4903 @code{RESULT = IBCLR(I, POS)}
4905 @item @emph{Arguments}:
4906 @multitable @columnfractions .15 .70
4907 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
4908 @item @var{POS} @tab The type shall be @code{INTEGER(*)}.
4911 @item @emph{Return value}:
4912 The return value is of type @code{INTEGER(*)} and of the same kind as
4915 @item @emph{See also}:
4916 @ref{IBITS}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}, @ref{MVBITS}
4923 @section @code{IBITS} --- Bit extraction
4926 @cindex bits, extract
4929 @item @emph{Description}:
4930 @code{IBITS} extracts a field of length @var{LEN} from @var{I},
4931 starting from bit position @var{POS} and extending left for @var{LEN}
4932 bits. The result is right-justified and the remaining bits are
4933 zeroed. The value of @code{POS+LEN} must be less than or equal to the
4934 value @code{BIT_SIZE(I)}.
4936 @item @emph{Standard}:
4942 @item @emph{Syntax}:
4943 @code{RESULT = IBITS(I, POS, LEN)}
4945 @item @emph{Arguments}:
4946 @multitable @columnfractions .15 .70
4947 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
4948 @item @var{POS} @tab The type shall be @code{INTEGER(*)}.
4949 @item @var{LEN} @tab The type shall be @code{INTEGER(*)}.
4952 @item @emph{Return value}:
4953 The return value is of type @code{INTEGER(*)} and of the same kind as
4956 @item @emph{See also}:
4957 @ref{BIT_SIZE}, @ref{IBCLR}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
4963 @section @code{IBSET} --- Set bit
4968 @item @emph{Description}:
4969 @code{IBSET} returns the value of @var{I} with the bit at position
4970 @var{POS} set to one.
4972 @item @emph{Standard}:
4978 @item @emph{Syntax}:
4979 @code{RESULT = IBSET(I, POS)}
4981 @item @emph{Arguments}:
4982 @multitable @columnfractions .15 .70
4983 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
4984 @item @var{POS} @tab The type shall be @code{INTEGER(*)}.
4987 @item @emph{Return value}:
4988 The return value is of type @code{INTEGER(*)} and of the same kind as
4991 @item @emph{See also}:
4992 @ref{IBCLR}, @ref{IBITS}, @ref{IAND}, @ref{IOR}, @ref{IEOR}, @ref{MVBITS}
4999 @section @code{ICHAR} --- Character-to-integer conversion function
5001 @cindex conversion, to integer
5004 @item @emph{Description}:
5005 @code{ICHAR(C)} returns the code for the character in the first character
5006 position of @code{C} in the system's native character set.
5007 The correspondence between characters and their codes is not necessarily
5008 the same across different GNU Fortran implementations.
5010 @item @emph{Standard}:
5016 @item @emph{Syntax}:
5017 @code{RESULT = ICHAR(C)}
5019 @item @emph{Arguments}:
5020 @multitable @columnfractions .15 .70
5021 @item @var{C} @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
5024 @item @emph{Return value}:
5025 The return value is of type @code{INTEGER} and of the default integer
5028 @item @emph{Example}:
5033 end program test_ichar
5037 No intrinsic exists to convert between a numeric value and a formatted
5038 character string representation -- for instance, given the
5039 @code{CHARACTER} value @code{'154'}, obtaining an @code{INTEGER} or
5040 @code{REAL} value with the value 154, or vice versa. Instead, this
5041 functionality is provided by internal-file I/O, as in the following
5046 character(len=10) string, string2
5049 ! Convert a string to a numeric value
5050 read (string,'(I10)') value
5053 ! Convert a value to a formatted string
5054 write (string2,'(I10)') value
5056 end program read_val
5059 @item @emph{See also}:
5060 @ref{ACHAR}, @ref{CHAR}, @ref{IACHAR}
5067 @section @code{IDATE} --- Get current local time subroutine (day/month/year)
5069 @cindex date, current
5070 @cindex current date
5073 @item @emph{Description}:
5074 @code{IDATE(TARRAY)} Fills @var{TARRAY} with the numerical values at the
5075 current local time. The day (in the range 1-31), month (in the range 1-12),
5076 and year appear in elements 1, 2, and 3 of @var{TARRAY}, respectively.
5077 The year has four significant digits.
5079 @item @emph{Standard}:
5085 @item @emph{Syntax}:
5086 @code{CALL IDATE(TARRAY)}
5088 @item @emph{Arguments}:
5089 @multitable @columnfractions .15 .70
5090 @item @var{TARRAY} @tab The type shall be @code{INTEGER, DIMENSION(3)} and
5091 the kind shall be the default integer kind.
5094 @item @emph{Return value}:
5097 @item @emph{Example}:
5100 integer, dimension(3) :: tarray
5105 end program test_idate
5112 @section @code{IEOR} --- Bitwise logical exclusive or
5114 @cindex bitwise logical exclusive or
5115 @cindex logical exclusive or, bitwise
5118 @item @emph{Description}:
5119 @code{IEOR} returns the bitwise boolean exclusive-OR of @var{I} and
5122 @item @emph{Standard}:
5128 @item @emph{Syntax}:
5129 @code{RESULT = IEOR(I, J)}
5131 @item @emph{Arguments}:
5132 @multitable @columnfractions .15 .70
5133 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
5134 @item @var{J} @tab The type shall be @code{INTEGER(*)}, of the same
5135 kind as @var{I}. (As a GNU extension, different kinds are also
5139 @item @emph{Return value}:
5140 The return type is @code{INTEGER(*)}, of the same kind as the
5141 arguments. (If the argument kinds differ, it is of the same kind as
5142 the larger argument.)
5144 @item @emph{See also}:
5145 @ref{IOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
5151 @section @code{IERRNO} --- Get the last system error number
5153 @cindex system, error handling
5156 @item @emph{Description}:
5157 Returns the last system error number, as given by the C @code{errno()}
5160 @item @emph{Standard}:
5164 Non-elemental function
5166 @item @emph{Syntax}:
5167 @code{RESULT = IERRNO()}
5169 @item @emph{Arguments}:
5172 @item @emph{Return value}:
5173 The return value is of type @code{INTEGER} and of the default integer
5176 @item @emph{See also}:
5183 @section @code{INDEX} --- Position of a substring within a string
5185 @cindex substring position
5186 @cindex string, find substring
5189 @item @emph{Description}:
5190 Returns the position of the start of the first occurrence of string
5191 @var{SUBSTRING} as a substring in @var{STRING}, counting from one. If
5192 @var{SUBSTRING} is not present in @var{STRING}, zero is returned. If
5193 the @var{BACK} argument is present and true, the return value is the
5194 start of the last occurrence rather than the first.
5196 @item @emph{Standard}:
5202 @item @emph{Syntax}:
5203 @code{RESULT = INDEX(STRING, SUBSTRING [, BACK])}
5205 @item @emph{Arguments}:
5206 @multitable @columnfractions .15 .70
5207 @item @var{STRING} @tab Shall be a scalar @code{CHARACTER(*)}, with
5209 @item @var{SUBSTRING} @tab Shall be a scalar @code{CHARACTER(*)}, with
5211 @item @var{BACK} @tab (Optional) Shall be a scalar @code{LOGICAL(*)}, with
5215 @item @emph{Return value}:
5216 The return value is of type @code{INTEGER} and of the default integer
5219 @item @emph{See also}:
5220 @ref{SCAN}, @ref{VERIFY}
5226 @section @code{INT} --- Convert to integer type
5230 @cindex conversion, to integer
5233 @item @emph{Description}:
5234 Convert to integer type
5236 @item @emph{Standard}:
5242 @item @emph{Syntax}:
5243 @code{RESULT = INT(A [, KIND))}
5245 @item @emph{Arguments}:
5246 @multitable @columnfractions .15 .70
5247 @item @var{A} @tab Shall be of type @code{INTEGER(*)},
5248 @code{REAL(*)}, or @code{COMPLEX(*)}.
5249 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
5250 expression indicating the kind parameter of
5254 @item @emph{Return value}:
5255 These functions return a @code{INTEGER(*)} variable or array under
5256 the following rules:
5260 If @var{A} is of type @code{INTEGER(*)}, @code{INT(A) = A}
5262 If @var{A} is of type @code{REAL(*)} and @math{|A| < 1}, @code{INT(A)} equals @code{0}.
5263 If @math{|A| \geq 1}, then @code{INT(A)} equals the largest integer that does not exceed
5264 the range of @var{A} and whose sign is the same as the sign of @var{A}.
5266 If @var{A} is of type @code{COMPLEX(*)}, rule B is applied to the real part of @var{A}.
5269 @item @emph{Example}:
5273 complex :: z = (-3.7, 1.0)
5275 print *, int(z), int(z,8)
5279 @item @emph{Specific names}:
5280 @multitable @columnfractions .20 .20 .20 .25
5281 @item Name @tab Argument @tab Return type @tab Standard
5282 @item @code{IFIX(A)} @tab @code{REAL(4) A} @tab @code{INTEGER} @tab F77 and later
5283 @item @code{IDINT(A)} @tab @code{REAL(8) A} @tab @code{INTEGER} @tab F77 and later
5291 @section @code{INT2} --- Convert to 16-bit integer type
5294 @cindex conversion, to integer
5297 @item @emph{Description}:
5298 Convert to a @code{KIND=2} integer type. This is equivalent to the
5299 standard @code{INT} intrinsic with an optional argument of
5300 @code{KIND=2}, and is only included for backwards compatibility.
5302 The @code{SHORT} intrinsic is equivalent to @code{INT2}.
5304 @item @emph{Standard}:
5310 @item @emph{Syntax}:
5311 @code{RESULT = INT2(A)}
5313 @item @emph{Arguments}:
5314 @multitable @columnfractions .15 .70
5315 @item @var{A} @tab Shall be of type @code{INTEGER(*)},
5316 @code{REAL(*)}, or @code{COMPLEX(*)}.
5319 @item @emph{Return value}:
5320 The return value is a @code{INTEGER(2)} variable.
5322 @item @emph{See also}:
5323 @ref{INT}, @ref{INT8}, @ref{LONG}
5329 @section @code{INT8} --- Convert to 64-bit integer type
5331 @cindex conversion, to integer
5334 @item @emph{Description}:
5335 Convert to a @code{KIND=8} integer type. This is equivalent to the
5336 standard @code{INT} intrinsic with an optional argument of
5337 @code{KIND=8}, and is only included for backwards compatibility.
5339 @item @emph{Standard}:
5345 @item @emph{Syntax}:
5346 @code{RESULT = INT8(A)}
5348 @item @emph{Arguments}:
5349 @multitable @columnfractions .15 .70
5350 @item @var{A} @tab Shall be of type @code{INTEGER(*)},
5351 @code{REAL(*)}, or @code{COMPLEX(*)}.
5354 @item @emph{Return value}:
5355 The return value is a @code{INTEGER(8)} variable.
5357 @item @emph{See also}:
5358 @ref{INT}, @ref{INT2}, @ref{LONG}
5364 @section @code{IOR} --- Bitwise logical or
5366 @cindex bitwise logical or
5367 @cindex logical or, bitwise
5370 @item @emph{Description}:
5371 @code{IEOR} returns the bitwise boolean OR of @var{I} and
5374 @item @emph{Standard}:
5380 @item @emph{Syntax}:
5381 @code{RESULT = IEOR(I, J)}
5383 @item @emph{Arguments}:
5384 @multitable @columnfractions .15 .70
5385 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
5386 @item @var{J} @tab The type shall be @code{INTEGER(*)}, of the same
5387 kind as @var{I}. (As a GNU extension, different kinds are also
5391 @item @emph{Return value}:
5392 The return type is @code{INTEGER(*)}, of the same kind as the
5393 arguments. (If the argument kinds differ, it is of the same kind as
5394 the larger argument.)
5396 @item @emph{See also}:
5397 @ref{IEOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
5403 @section @code{IRAND} --- Integer pseudo-random number
5405 @cindex random number generation
5408 @item @emph{Description}:
5409 @code{IRAND(FLAG)} returns a pseudo-random number from a uniform
5410 distribution between 0 and a system-dependent limit (which is in most
5411 cases 2147483647). If @var{FLAG} is 0, the next number
5412 in the current sequence is returned; if @var{FLAG} is 1, the generator
5413 is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
5414 it is used as a new seed with @code{SRAND}.
5416 @item @emph{Standard}:
5420 Non-elemental function
5422 @item @emph{Syntax}:
5423 @code{RESULT = IRAND(FLAG)}
5425 @item @emph{Arguments}:
5426 @multitable @columnfractions .15 .70
5427 @item @var{FLAG} @tab Shall be a scalar @code{INTEGER} of kind 4.
5430 @item @emph{Return value}:
5431 The return value is of @code{INTEGER(kind=4)} type.
5433 @item @emph{Example}:
5436 integer,parameter :: seed = 86456
5439 print *, irand(), irand(), irand(), irand()
5440 print *, irand(seed), irand(), irand(), irand()
5441 end program test_irand
5449 @section @code{ISATTY} --- Whether a unit is a terminal device.
5451 @cindex system, terminal
5454 @item @emph{Description}:
5455 Determine whether a unit is connected to a terminal device.
5457 @item @emph{Standard}:
5461 Non-elemental function.
5463 @item @emph{Syntax}:
5464 @code{RESULT = ISATTY(UNIT)}
5466 @item @emph{Arguments}:
5467 @multitable @columnfractions .15 .70
5468 @item @var{UNIT} @tab Shall be a scalar @code{INTEGER(*)}.
5471 @item @emph{Return value}:
5472 Returns @code{.TRUE.} if the @var{UNIT} is connected to a terminal
5473 device, @code{.FALSE.} otherwise.
5475 @item @emph{Example}:
5478 INTEGER(kind=1) :: unit
5480 write(*,*) isatty(unit=unit)
5484 @item @emph{See also}:
5491 @section @code{ISHFT} --- Shift bits
5496 @item @emph{Description}:
5497 @code{ISHFT} returns a value corresponding to @var{I} with all of the
5498 bits shifted @var{SHIFT} places. A value of @var{SHIFT} greater than
5499 zero corresponds to a left shift, a value of zero corresponds to no
5500 shift, and a value less than zero corresponds to a right shift. If the
5501 absolute value of @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the
5502 value is undefined. Bits shifted out from the left end or right end are
5503 lost; zeros are shifted in from the opposite end.
5505 @item @emph{Standard}:
5511 @item @emph{Syntax}:
5512 @code{RESULT = ISHFT(I, SHIFT)}
5514 @item @emph{Arguments}:
5515 @multitable @columnfractions .15 .70
5516 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
5517 @item @var{SHIFT} @tab The type shall be @code{INTEGER(*)}.
5520 @item @emph{Return value}:
5521 The return value is of type @code{INTEGER(*)} and of the same kind as
5524 @item @emph{See also}:
5531 @section @code{ISHFTC} --- Shift bits circularly
5533 @cindex bits, shift circular
5536 @item @emph{Description}:
5537 @code{ISHFTC} returns a value corresponding to @var{I} with the
5538 rightmost @var{SIZE} bits shifted circularly @var{SHIFT} places; that
5539 is, bits shifted out one end are shifted into the opposite end. A value
5540 of @var{SHIFT} greater than zero corresponds to a left shift, a value of
5541 zero corresponds to no shift, and a value less than zero corresponds to
5542 a right shift. The absolute value of @var{SHIFT} must be less than
5543 @var{SIZE}. If the @var{SIZE} argument is omitted, it is taken to be
5544 equivalent to @code{BIT_SIZE(I)}.
5546 @item @emph{Standard}:
5552 @item @emph{Syntax}:
5553 @code{RESULT = ISHFTC(I, SHIFT [, SIZE])}
5555 @item @emph{Arguments}:
5556 @multitable @columnfractions .15 .70
5557 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
5558 @item @var{SHIFT} @tab The type shall be @code{INTEGER(*)}.
5559 @item @var{SIZE} @tab (Optional) The type shall be @code{INTEGER(*)};
5560 the value must be greater than zero and less than or equal to
5564 @item @emph{Return value}:
5565 The return value is of type @code{INTEGER(*)} and of the same kind as
5568 @item @emph{See also}:
5575 @section @code{ITIME} --- Get current local time subroutine (hour/minutes/seconds)
5577 @cindex time, current
5578 @cindex current time
5581 @item @emph{Description}:
5582 @code{IDATE(TARRAY)} Fills @var{TARRAY} with the numerical values at the
5583 current local time. The hour (in the range 1-24), minute (in the range 1-60),
5584 and seconds (in the range 1-60) appear in elements 1, 2, and 3 of @var{TARRAY},
5587 @item @emph{Standard}:
5593 @item @emph{Syntax}:
5594 @code{CALL ITIME(TARRAY)}
5596 @item @emph{Arguments}:
5597 @multitable @columnfractions .15 .70
5598 @item @var{TARRAY} @tab The type shall be @code{INTEGER, DIMENSION(3)}
5599 and the kind shall be the default integer kind.
5602 @item @emph{Return value}:
5606 @item @emph{Example}:
5609 integer, dimension(3) :: tarray
5614 end program test_itime
5621 @section @code{KILL} --- Send a signal to a process
5625 @item @emph{Description}:
5626 @item @emph{Standard}:
5627 Sends the signal specified by @var{SIGNAL} to the process @var{PID}.
5633 @item @emph{Syntax}:
5634 @code{CALL KILL(PID, SIGNAL [, STATUS])}
5636 @item @emph{Arguments}:
5637 @multitable @columnfractions .15 .70
5638 @item @var{PID} @tab Shall be a scalar @code{INTEGER}, with
5640 @item @var{SIGNAL} @tab Shall be a scalar @code{INTEGER}, with
5642 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)} or
5643 @code{INTEGER(8)}. Returns 0 on success, or a
5644 system-specific error code otherwise.
5647 @item @emph{See also}:
5648 @ref{ABORT}, @ref{EXIT}
5654 @section @code{KIND} --- Kind of an entity
5659 @item @emph{Description}:
5660 @code{KIND(X)} returns the kind value of the entity @var{X}.
5662 @item @emph{Standard}:
5668 @item @emph{Syntax}:
5671 @item @emph{Arguments}:
5672 @multitable @columnfractions .15 .70
5673 @item @var{X} @tab Shall be of type @code{LOGICAL}, @code{INTEGER},
5674 @code{REAL}, @code{COMPLEX} or @code{CHARACTER}.
5677 @item @emph{Return value}:
5678 The return value is a scalar of type @code{INTEGER} and of the default
5681 @item @emph{Example}:
5684 integer,parameter :: kc = kind(' ')
5685 integer,parameter :: kl = kind(.true.)
5687 print *, "The default character kind is ", kc
5688 print *, "The default logical kind is ", kl
5689 end program test_kind
5697 @section @code{LBOUND} --- Lower dimension bounds of an array
5699 @cindex array, lower bound
5702 @item @emph{Description}:
5703 Returns the lower bounds of an array, or a single lower bound
5704 along the @var{DIM} dimension.
5705 @item @emph{Standard}:
5711 @item @emph{Syntax}:
5712 @code{RESULT = LBOUND(ARRAY [, DIM])}
5714 @item @emph{Arguments}:
5715 @multitable @columnfractions .15 .70
5716 @item @var{ARRAY} @tab Shall be an array, of any type.
5717 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER(*)}.
5720 @item @emph{Return value}:
5721 If @var{DIM} is absent, the result is an array of the lower bounds of
5722 @var{ARRAY}. If @var{DIM} is present, the result is a scalar
5723 corresponding to the lower bound of the array along that dimension. If
5724 @var{ARRAY} is an expression rather than a whole array or array
5725 structure component, or if it has a zero extent along the relevant
5726 dimension, the lower bound is taken to be 1.
5728 @item @emph{See also}:
5735 @section @code{LEN} --- Length of a character entity
5737 @cindex string, length
5740 @item @emph{Description}:
5741 Returns the length of a character string. If @var{STRING} is an array,
5742 the length of an element of @var{STRING} is returned. Note that
5743 @var{STRING} need not be defined when this intrinsic is invoked, since
5744 only the length, not the content, of @var{STRING} is needed.
5746 @item @emph{Standard}:
5752 @item @emph{Syntax}:
5753 @code{L = LEN(STRING)}
5755 @item @emph{Arguments}:
5756 @multitable @columnfractions .15 .70
5757 @item @var{STRING} @tab Shall be a scalar or array of type
5758 @code{CHARACTER(*)}, with @code{INTENT(IN)}
5761 @item @emph{Return value}:
5762 The return value is an @code{INTEGER} of the default kind.
5764 @item @emph{See also}:
5765 @ref{LEN_TRIM}, @ref{ADJUSTL}, @ref{ADJUSTR}
5771 @section @code{LEN_TRIM} --- Length of a character entity without trailing blank characters
5773 @cindex string, length, without trailing whitespace
5776 @item @emph{Description}:
5777 Returns the length of a character string, ignoring any trailing blanks.
5779 @item @emph{Standard}:
5785 @item @emph{Syntax}:
5786 @code{RESULT = LEN_TRIM(STRING)}
5788 @item @emph{Arguments}:
5789 @multitable @columnfractions .15 .70
5790 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER(*)},
5791 with @code{INTENT(IN)}
5794 @item @emph{Return value}:
5795 The return value is an @code{INTEGER} of the default kind.
5797 @item @emph{See also}:
5798 @ref{LEN}, @ref{ADJUSTL}, @ref{ADJUSTR}
5804 @section @code{LGE} --- Lexical greater than or equal
5806 @cindex lexical comparison of strings
5807 @cindex string, comparison
5810 @item @emph{Description}:
5811 Determines whether one string is lexically greater than or equal to
5812 another string, where the two strings are interpreted as containing
5813 ASCII character codes. If the String A and String B are not the same
5814 length, the shorter is compared as if spaces were appended to it to form
5815 a value that has the same length as the longer.
5817 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
5818 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
5819 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
5820 that the latter use the processor's character ordering (which is not
5821 ASCII on some targets), whereas the former always use the ASCII
5824 @item @emph{Standard}:
5830 @item @emph{Syntax}:
5831 @code{RESULT = LGE(STRING_A, STRING_B)}
5833 @item @emph{Arguments}:
5834 @multitable @columnfractions .15 .70
5835 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
5836 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
5839 @item @emph{Return value}:
5840 Returns @code{.TRUE.} if @code{STRING_A >= STRING_B}, and @code{.FALSE.}
5841 otherwise, based on the ASCII ordering.
5843 @item @emph{See also}:
5844 @ref{LGT}, @ref{LLE}, @ref{LLT}
5850 @section @code{LGT} --- Lexical greater than
5852 @cindex lexical comparison of strings
5853 @cindex string, comparison
5856 @item @emph{Description}:
5857 Determines whether one string is lexically greater than another string,
5858 where the two strings are interpreted as containing ASCII character
5859 codes. If the String A and String B are not the same length, the
5860 shorter is compared as if spaces were appended to it to form a value
5861 that has the same length as the longer.
5863 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
5864 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
5865 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
5866 that the latter use the processor's character ordering (which is not
5867 ASCII on some targets), whereas the former always use the ASCII
5870 @item @emph{Standard}:
5876 @item @emph{Syntax}:
5877 @code{RESULT = LGT(STRING_A, STRING_B)}
5879 @item @emph{Arguments}:
5880 @multitable @columnfractions .15 .70
5881 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
5882 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
5885 @item @emph{Return value}:
5886 Returns @code{.TRUE.} if @code{STRING_A > STRING_B}, and @code{.FALSE.}
5887 otherwise, based on the ASCII ordering.
5889 @item @emph{See also}:
5890 @ref{LGE}, @ref{LLE}, @ref{LLT}
5896 @section @code{LINK} --- Create a hard link
5898 @cindex file system, create link
5899 @cindex file system, hard link
5902 @item @emph{Description}:
5903 Makes a (hard) link from file @var{PATH1} to @var{PATH2}. A null
5904 character (@code{CHAR(0)}) can be used to mark the end of the names in
5905 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
5906 names are ignored. If the @var{STATUS} argument is supplied, it
5907 contains 0 on success or a nonzero error code upon return; see
5910 This intrinsic is provided in both subroutine and function forms;
5911 however, only one form can be used in any given program unit.
5913 @item @emph{Standard}:
5917 Subroutine, non-elemental function
5919 @item @emph{Syntax}:
5920 @multitable @columnfractions .80
5921 @item @code{CALL LINK(PATH1, PATH2 [, STATUS])}
5922 @item @code{STATUS = LINK(PATH1, PATH2)}
5925 @item @emph{Arguments}:
5926 @multitable @columnfractions .15 .70
5927 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
5928 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
5929 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
5932 @item @emph{See also}:
5933 @ref{SYMLNK}, @ref{UNLINK}
5939 @section @code{LLE} --- Lexical less than or equal
5941 @cindex lexical comparison of strings
5942 @cindex string, comparison
5945 @item @emph{Description}:
5946 Determines whether one string is lexically less than or equal to another
5947 string, where the two strings are interpreted as containing ASCII
5948 character codes. If the String A and String B are not the same length,
5949 the shorter is compared as if spaces were appended to it to form a value
5950 that has the same length as the longer.
5952 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
5953 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
5954 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
5955 that the latter use the processor's character ordering (which is not
5956 ASCII on some targets), whereas the former always use the ASCII
5959 @item @emph{Standard}:
5965 @item @emph{Syntax}:
5966 @code{RESULT = LLE(STRING_A, STRING_B)}
5968 @item @emph{Arguments}:
5969 @multitable @columnfractions .15 .70
5970 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
5971 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
5974 @item @emph{Return value}:
5975 Returns @code{.TRUE.} if @code{STRING_A <= STRING_B}, and @code{.FALSE.}
5976 otherwise, based on the ASCII ordering.
5978 @item @emph{See also}:
5979 @ref{LGE}, @ref{LGT}, @ref{LLT}
5985 @section @code{LLT} --- Lexical less than
5987 @cindex lexical comparison of strings
5988 @cindex string, comparison
5991 @item @emph{Description}:
5992 Determines whether one string is lexically less than another string,
5993 where the two strings are interpreted as containing ASCII character
5994 codes. If the String A and String B are not the same length, the
5995 shorter is compared as if spaces were appended to it to form a value
5996 that has the same length as the longer.
5998 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
5999 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
6000 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
6001 that the latter use the processor's character ordering (which is not
6002 ASCII on some targets), whereas the former always use the ASCII
6005 @item @emph{Standard}:
6011 @item @emph{Syntax}:
6012 @code{RESULT = LLT(STRING_A, STRING_B)}
6014 @item @emph{Arguments}:
6015 @multitable @columnfractions .15 .70
6016 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
6017 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
6020 @item @emph{Return value}:
6021 Returns @code{.TRUE.} if @code{STRING_A < STRING_B}, and @code{.FALSE.}
6022 otherwise, based on the ASCII ordering.
6024 @item @emph{See also}:
6025 @ref{LGE}, @ref{LGT}, @ref{LLE}
6031 @section @code{LNBLNK} --- Index of the last non-blank character in a string
6033 @cindex string, find non-blank character
6036 @item @emph{Description}:
6037 Returns the length of a character string, ignoring any trailing blanks.
6038 This is identical to the standard @code{LEN_TRIM} intrinsic, and is only
6039 included for backwards compatibility.
6041 @item @emph{Standard}:
6047 @item @emph{Syntax}:
6048 @code{RESULT = LNBLNK(STRING)}
6050 @item @emph{Arguments}:
6051 @multitable @columnfractions .15 .70
6052 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER(*)},
6053 with @code{INTENT(IN)}
6056 @item @emph{Return value}:
6057 The return value is of @code{INTEGER(kind=4)} type.
6059 @item @emph{See also}:
6060 @ref{INDEX}, @ref{LEN_TRIM}
6066 @section @code{LOC} --- Returns the address of a variable
6068 @cindex location of a variable in memory
6071 @item @emph{Description}:
6072 @code{LOC(X)} returns the address of @var{X} as an integer.
6074 @item @emph{Standard}:
6080 @item @emph{Syntax}:
6081 @code{RESULT = LOC(X)}
6083 @item @emph{Arguments}:
6084 @multitable @columnfractions .15 .70
6085 @item @var{X} @tab Variable of any type.
6088 @item @emph{Return value}:
6089 The return value is of type @code{INTEGER}, with a @code{KIND}
6090 corresponding to the size (in bytes) of a memory address on the target
6093 @item @emph{Example}:
6100 end program test_loc
6107 @section @code{LOG} --- Logarithm function
6114 @cindex exponential function, inverse
6115 @cindex logarithmic function
6118 @item @emph{Description}:
6119 @code{LOG(X)} computes the logarithm of @var{X}.
6121 @item @emph{Standard}:
6127 @item @emph{Syntax}:
6128 @code{RESULT = LOG(X)}
6130 @item @emph{Arguments}:
6131 @multitable @columnfractions .15 .70
6132 @item @var{X} @tab The type shall be @code{REAL(*)} or
6136 @item @emph{Return value}:
6137 The return value is of type @code{REAL(*)} or @code{COMPLEX(*)}.
6138 The kind type parameter is the same as @var{X}.
6140 @item @emph{Example}:
6143 real(8) :: x = 1.0_8
6144 complex :: z = (1.0, 2.0)
6147 end program test_log
6150 @item @emph{Specific names}:
6151 @multitable @columnfractions .20 .20 .20 .25
6152 @item Name @tab Argument @tab Return type @tab Standard
6153 @item @code{ALOG(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab f95, gnu
6154 @item @code{DLOG(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
6155 @item @code{CLOG(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab f95, gnu
6156 @item @code{ZLOG(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
6157 @item @code{CDLOG(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
6164 @section @code{LOG10} --- Base 10 logarithm function
6168 @cindex exponential function, inverse
6169 @cindex logarithmic function
6172 @item @emph{Description}:
6173 @code{LOG10(X)} computes the base 10 logarithm of @var{X}.
6175 @item @emph{Standard}:
6181 @item @emph{Syntax}:
6182 @code{RESULT = LOG10(X)}
6184 @item @emph{Arguments}:
6185 @multitable @columnfractions .15 .70
6186 @item @var{X} @tab The type shall be @code{REAL(*)}.
6189 @item @emph{Return value}:
6190 The return value is of type @code{REAL(*)} or @code{COMPLEX(*)}.
6191 The kind type parameter is the same as @var{X}.
6193 @item @emph{Example}:
6196 real(8) :: x = 10.0_8
6198 end program test_log10
6201 @item @emph{Specific names}:
6202 @multitable @columnfractions .20 .20 .20 .25
6203 @item Name @tab Argument @tab Return type @tab Standard
6204 @item @code{ALOG10(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab F95 and later
6205 @item @code{DLOG10(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
6212 @section @code{LOGICAL} --- Convert to logical type
6214 @cindex conversion, to logical
6217 @item @emph{Description}:
6218 Converts one kind of @code{LOGICAL} variable to another.
6220 @item @emph{Standard}:
6226 @item @emph{Syntax}:
6227 @code{RESULT = LOGICAL(L [, KIND])}
6229 @item @emph{Arguments}:
6230 @multitable @columnfractions .15 .70
6231 @item @var{L} @tab The type shall be @code{LOGICAL(*)}.
6232 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
6233 expression indicating the kind parameter of
6237 @item @emph{Return value}:
6238 The return value is a @code{LOGICAL} value equal to @var{L}, with a
6239 kind corresponding to @var{KIND}, or of the default logical kind if
6240 @var{KIND} is not given.
6242 @item @emph{See also}:
6243 @ref{INT}, @ref{REAL}, @ref{CMPLX}
6249 @section @code{LONG} --- Convert to integer type
6251 @cindex conversion, to integer
6254 @item @emph{Description}:
6255 Convert to a @code{KIND=4} integer type, which is the same size as a C
6256 @code{long} integer. This is equivalent to the standard @code{INT}
6257 intrinsic with an optional argument of @code{KIND=4}, and is only
6258 included for backwards compatibility.
6260 @item @emph{Standard}:
6266 @item @emph{Syntax}:
6267 @code{RESULT = LONG(A)}
6269 @item @emph{Arguments}:
6270 @multitable @columnfractions .15 .70
6271 @item @var{A} @tab Shall be of type @code{INTEGER(*)},
6272 @code{REAL(*)}, or @code{COMPLEX(*)}.
6275 @item @emph{Return value}:
6276 The return value is a @code{INTEGER(4)} variable.
6278 @item @emph{See also}:
6279 @ref{INT}, @ref{INT2}, @ref{INT8}
6285 @section @code{LSHIFT} --- Left shift bits
6287 @cindex bits, shift left
6290 @item @emph{Description}:
6291 @code{LSHIFT} returns a value corresponding to @var{I} with all of the
6292 bits shifted left by @var{SHIFT} places. If the absolute value of
6293 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
6294 Bits shifted out from the left end are lost; zeros are shifted in from
6297 This function has been superseded by the @code{ISHFT} intrinsic, which
6298 is standard in Fortran 95 and later.
6300 @item @emph{Standard}:
6306 @item @emph{Syntax}:
6307 @code{RESULT = LSHIFT(I, SHIFT)}
6309 @item @emph{Arguments}:
6310 @multitable @columnfractions .15 .70
6311 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
6312 @item @var{SHIFT} @tab The type shall be @code{INTEGER(*)}.
6315 @item @emph{Return value}:
6316 The return value is of type @code{INTEGER(*)} and of the same kind as
6319 @item @emph{See also}:
6320 @ref{ISHFT}, @ref{ISHFTC}, @ref{RSHIFT}
6327 @section @code{LSTAT} --- Get file status
6329 @cindex file system, file status
6332 @item @emph{Description}:
6333 @code{LSTAT} is identical to @ref{STAT}, except that if path is a symbolic link,
6334 then the link itself is statted, not the file that it refers to.
6336 The elements in @code{BUFF} are the same as described by @ref{STAT}.
6338 @item @emph{Standard}:
6342 Non-elemental subroutine
6344 @item @emph{Syntax}:
6345 @code{CALL LSTAT(FILE, BUFF [, STATUS])}
6347 @item @emph{Arguments}:
6348 @multitable @columnfractions .15 .70
6349 @item @var{FILE} @tab The type shall be @code{CHARACTER(*)}, a valid path within the file system.
6350 @item @var{BUFF} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
6351 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0
6352 on success and a system specific error code otherwise.
6355 @item @emph{Example}:
6356 See @ref{STAT} for an example.
6358 @item @emph{See also}:
6359 To stat an open file: @ref{FSTAT}, to stat a file: @ref{STAT}
6365 @section @code{LTIME} --- Convert time to local time info
6367 @cindex time, converstion to local time info
6370 @item @emph{Description}:
6371 Given a system time value @var{STIME} (as provided by the @code{TIME8()}
6372 intrinsic), fills @var{TARRAY} with values extracted from it appropriate
6373 to the local time zone using @code{localtime(3)}.
6375 @item @emph{Standard}:
6381 @item @emph{Syntax}:
6382 @code{CALL LTIME(STIME, TARRAY)}
6384 @item @emph{Arguments}:
6385 @multitable @columnfractions .15 .70
6386 @item @var{STIME} @tab An @code{INTEGER(*)} scalar expression
6387 corresponding to a system time, with
6389 @item @var{TARRAY} @tab A default @code{INTEGER} array with 9 elements,
6390 with @code{INTENT(OUT)}.
6393 @item @emph{Return value}:
6394 The elements of @var{TARRAY} are assigned as follows:
6396 @item Seconds after the minute, range 0--59 or 0--61 to allow for leap
6398 @item Minutes after the hour, range 0--59
6399 @item Hours past midnight, range 0--23
6400 @item Day of month, range 0--31
6401 @item Number of months since January, range 0--12
6402 @item Years since 1900
6403 @item Number of days since Sunday, range 0--6
6404 @item Days since January 1
6405 @item Daylight savings indicator: positive if daylight savings is in
6406 effect, zero if not, and negative if the information is not
6410 @item @emph{See also}:
6411 @ref{CTIME}, @ref{GMTIME}, @ref{TIME}, @ref{TIME8}
6418 @section @code{MALLOC} --- Allocate dynamic memory
6420 @cindex pointer, cray
6423 @item @emph{Description}:
6424 @code{MALLOC(SIZE)} allocates @var{SIZE} bytes of dynamic memory and
6425 returns the address of the allocated memory. The @code{MALLOC} intrinsic
6426 is an extension intended to be used with Cray pointers, and is provided
6427 in GNU Fortran to allow the user to compile legacy code. For new code
6428 using Fortran 95 pointers, the memory allocation intrinsic is
6431 @item @emph{Standard}:
6435 Non-elemental function
6437 @item @emph{Syntax}:
6438 @code{PTR = MALLOC(SIZE)}
6440 @item @emph{Arguments}:
6441 @multitable @columnfractions .15 .70
6442 @item @var{SIZE} @tab The type shall be @code{INTEGER(*)}.
6445 @item @emph{Return value}:
6446 The return value is of type @code{INTEGER(K)}, with @var{K} such that
6447 variables of type @code{INTEGER(K)} have the same size as
6448 C pointers (@code{sizeof(void *)}).
6450 @item @emph{Example}:
6451 The following example demonstrates the use of @code{MALLOC} and
6452 @code{FREE} with Cray pointers. This example is intended to run on
6453 32-bit systems, where the default integer kind is suitable to store
6454 pointers; on 64-bit systems, ptr_x would need to be declared as
6455 @code{integer(kind=8)}.
6464 ptr_x = malloc(20*8)
6466 x(i) = sqrt(1.0d0 / i)
6474 end program test_malloc
6477 @item @emph{See also}:
6484 @section @code{MATMUL} --- matrix multiplication
6486 @cindex matrix multiplication
6487 @cindex product, matrix
6490 @item @emph{Description}:
6491 Performs a matrix multiplication on numeric or logical arguments.
6493 @item @emph{Standard}:
6497 Transformational function
6499 @item @emph{Syntax}:
6500 @code{RESULT = MATMUL(MATRIX_A, MATRIX_B)}
6502 @item @emph{Arguments}:
6503 @multitable @columnfractions .15 .70
6504 @item @var{MATRIX_A} @tab An array of @code{INTEGER(*)},
6505 @code{REAL(*)}, @code{COMPLEX(*)}, or
6506 @code{LOGICAL(*)} type, with a rank of
6508 @item @var{MATRIX_B} @tab An array of @code{INTEGER(*)},
6509 @code{REAL(*)}, or @code{COMPLEX(*)} type if
6510 @var{MATRIX_A} is of a numeric type;
6511 otherwise, an array of @code{LOGICAL(*)}
6512 type. The rank shall be one or two, and the
6513 first (or only) dimension of @var{MATRIX_B}
6514 shall be equal to the last (or only)
6515 dimension of @var{MATRIX_A}.
6518 @item @emph{Return value}:
6519 The matrix product of @var{MATRIX_A} and @var{MATRIX_B}. The type and
6520 kind of the result follow the usual type and kind promotion rules, as
6521 for the @code{*} or @code{.AND.} operators.
6523 @item @emph{See also}:
6529 @section @code{MAX} --- Maximum value of an argument list
6536 @cindex maximum value
6539 @item @emph{Description}:
6540 Returns the argument with the largest (most positive) value.
6542 @item @emph{Standard}:
6548 @item @emph{Syntax}:
6549 @code{RESULT = MAX(A1, A2 [, A3 [, ...]])}
6551 @item @emph{Arguments}:
6552 @multitable @columnfractions .15 .70
6553 @item @var{A1} @tab The type shall be @code{INTEGER(*)} or
6555 @item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
6556 as @var{A1}. (As a GNU extension,
6557 arguments of different kinds are
6561 @item @emph{Return value}:
6562 The return value corresponds to the maximum value among the arguments,
6563 and has the same type and kind as the first argument.
6565 @item @emph{Specific names}:
6566 @multitable @columnfractions .20 .20 .20 .25
6567 @item Name @tab Argument @tab Return type @tab Standard
6568 @item @code{MAX0(I)} @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)} @tab F77 and later
6569 @item @code{AMAX0(I)} @tab @code{INTEGER(4) I} @tab @code{REAL(MAX(X))} @tab F77 and later
6570 @item @code{MAX1(X)} @tab @code{REAL(*) X} @tab @code{INT(MAX(X))} @tab F77 and later
6571 @item @code{AMAX1(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab F77 and later
6572 @item @code{DMAX1(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
6575 @item @emph{See also}:
6576 @ref{MAXLOC} @ref{MAXVAL}, @ref{MIN}
6583 @section @code{MAXEXPONENT} --- Maximum exponent of a real kind
6584 @fnindex MAXEXPONENT
6585 @cindex model representation, maximum exponent
6588 @item @emph{Description}:
6589 @code{MAXEXPONENT(X)} returns the maximum exponent in the model of the
6592 @item @emph{Standard}:
6598 @item @emph{Syntax}:
6599 @code{RESULT = MAXEXPONENT(X)}
6601 @item @emph{Arguments}:
6602 @multitable @columnfractions .15 .70
6603 @item @var{X} @tab Shall be of type @code{REAL}.
6606 @item @emph{Return value}:
6607 The return value is of type @code{INTEGER} and of the default integer
6610 @item @emph{Example}:
6616 print *, minexponent(x), maxexponent(x)
6617 print *, minexponent(y), maxexponent(y)
6618 end program exponents
6625 @section @code{MAXLOC} --- Location of the maximum value within an array
6627 @cindex array, location of maximum element
6630 @item @emph{Description}:
6631 Determines the location of the element in the array with the maximum
6632 value, or, if the @var{DIM} argument is supplied, determines the
6633 locations of the maximum element along each row of the array in the
6634 @var{DIM} direction. If @var{MASK} is present, only the elements for
6635 which @var{MASK} is @code{.TRUE.} are considered. If more than one
6636 element in the array has the maximum value, the location returned is
6637 that of the first such element in array element order. If the array has
6638 zero size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
6639 the result is an array of zeroes. Similarly, if @var{DIM} is supplied
6640 and all of the elements of @var{MASK} along a given row are zero, the
6641 result value for that row is zero.
6643 @item @emph{Standard}:
6647 Transformational function
6649 @item @emph{Syntax}:
6650 @multitable @columnfractions .80
6651 @item @code{RESULT = MAXLOC(ARRAY, DIM [, MASK])}
6652 @item @code{RESULT = MAXLOC(ARRAY [, MASK])}
6655 @item @emph{Arguments}:
6656 @multitable @columnfractions .15 .70
6657 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER(*)},
6658 @code{REAL(*)}, or @code{CHARACTER(*)}.
6659 @item @var{DIM} @tab (Optional) Shall be a scalar of type
6660 @code{INTEGER(*)}, with a value between one
6661 and the rank of @var{ARRAY}, inclusive. It
6662 may not be an optional dummy argument.
6663 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL(*)},
6664 and conformable with @var{ARRAY}.
6667 @item @emph{Return value}:
6668 If @var{DIM} is absent, the result is a rank-one array with a length
6669 equal to the rank of @var{ARRAY}. If @var{DIM} is present, the result
6670 is an array with a rank one less than the rank of @var{ARRAY}, and a
6671 size corresponding to the size of @var{ARRAY} with the @var{DIM}
6672 dimension removed. If @var{DIM} is present and @var{ARRAY} has a rank
6673 of one, the result is a scalar. In all cases, the result is of default
6674 @code{INTEGER} type.
6676 @item @emph{See also}:
6677 @ref{MAX}, @ref{MAXVAL}
6684 @section @code{MAXVAL} --- Maximum value of an array
6686 @cindex array, maximum value
6687 @cindex maximum value
6690 @item @emph{Description}:
6691 Determines the maximum value of the elements in an array value, or, if
6692 the @var{DIM} argument is supplied, determines the maximum value along
6693 each row of the array in the @var{DIM} direction. If @var{MASK} is
6694 present, only the elements for which @var{MASK} is @code{.TRUE.} are
6695 considered. If the array has zero size, or all of the elements of
6696 @var{MASK} are @code{.FALSE.}, then the result is the most negative
6697 number of the type and kind of @var{ARRAY} if @var{ARRAY} is numeric, or
6698 a string of nulls if @var{ARRAY} is of character type.
6700 @item @emph{Standard}:
6704 Transformational function
6706 @item @emph{Syntax}:
6707 @multitable @columnfractions .80
6708 @item @code{RESULT = MAXVAL(ARRAY, DIM [, MASK])}
6709 @item @code{RESULT = MAXVAL(ARRAY [, MASK])}
6712 @item @emph{Arguments}:
6713 @multitable @columnfractions .15 .70
6714 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER(*)},
6715 @code{REAL(*)}, or @code{CHARACTER(*)}.
6716 @item @var{DIM} @tab (Optional) Shall be a scalar of type
6717 @code{INTEGER(*)}, with a value between one
6718 and the rank of @var{ARRAY}, inclusive. It
6719 may not be an optional dummy argument.
6720 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL(*)},
6721 and conformable with @var{ARRAY}.
6724 @item @emph{Return value}:
6725 If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
6726 is a scalar. If @var{DIM} is present, the result is an array with a
6727 rank one less than the rank of @var{ARRAY}, and a size corresponding to
6728 the size of @var{ARRAY} with the @var{DIM} dimension removed. In all
6729 cases, the result is of the same type and kind as @var{ARRAY}.
6731 @item @emph{See also}:
6732 @ref{MAX}, @ref{MAXLOC}
6738 @section @code{MCLOCK} --- Time function
6740 @cindex time, clock ticks
6744 @item @emph{Description}:
6745 Returns the number of clock ticks since the start of the process, based
6746 on the UNIX function @code{clock(3)}.
6748 This intrinsic is not fully portable, such as to systems with 32-bit
6749 @code{INTEGER} types but supporting times wider than 32 bits. Therefore,
6750 the values returned by this intrinsic might be, or become, negative, or
6751 numerically less than previous values, during a single run of the
6754 @item @emph{Standard}:
6758 Non-elemental function
6760 @item @emph{Syntax}:
6761 @code{RESULT = MCLOCK()}
6763 @item @emph{Return value}:
6764 The return value is a scalar of type @code{INTEGER(4)}, equal to the
6765 number of clock ticks since the start of the process, or @code{-1} if
6766 the system does not support @code{clock(3)}.
6768 @item @emph{See also}:
6769 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME}
6776 @section @code{MCLOCK8} --- Time function (64-bit)
6778 @cindex time, clock ticks
6782 @item @emph{Description}:
6783 Returns the number of clock ticks since the start of the process, based
6784 on the UNIX function @code{clock(3)}.
6786 @emph{Warning:} this intrinsic does not increase the range of the timing
6787 values over that returned by @code{clock(3)}. On a system with a 32-bit
6788 @code{clock(3)}, @code{MCLOCK8()} will return a 32-bit value, even though
6789 it is converted to a 64-bit @code{INTEGER(8)} value. That means
6790 overflows of the 32-bit value can still occur. Therefore, the values
6791 returned by this intrinsic might be or become negative or numerically
6792 less than previous values during a single run of the compiled program.
6794 @item @emph{Standard}:
6798 Non-elemental function
6800 @item @emph{Syntax}:
6801 @code{RESULT = MCLOCK8()}
6803 @item @emph{Return value}:
6804 The return value is a scalar of type @code{INTEGER(8)}, equal to the
6805 number of clock ticks since the start of the process, or @code{-1} if
6806 the system does not support @code{clock(3)}.
6808 @item @emph{See also}:
6809 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME8}
6816 @section @code{MERGE} --- Merge variables
6818 @cindex array, merge arrays
6819 @cindex array, combine arrays
6822 @item @emph{Description}:
6823 Select values from two arrays according to a logical mask. The result
6824 is equal to @var{TSOURCE} if @var{MASK} is @code{.TRUE.}, or equal to
6825 @var{FSOURCE} if it is @code{.FALSE.}.
6827 @item @emph{Standard}:
6833 @item @emph{Syntax}:
6834 @code{RESULT = MERGE(TSOURCE, FSOURCE, MASK)}
6836 @item @emph{Arguments}:
6837 @multitable @columnfractions .15 .70
6838 @item @var{TSOURCE} @tab May be of any type.
6839 @item @var{FSOURCE} @tab Shall be of the same type and type parameters
6841 @item @var{MASK} @tab Shall be of type @code{LOGICAL(*)}.
6844 @item @emph{Return value}:
6845 The result is of the same type and type parameters as @var{TSOURCE}.
6852 @section @code{MIN} --- Minimum value of an argument list
6859 @cindex minimum value
6862 @item @emph{Description}:
6863 Returns the argument with the smallest (most negative) value.
6865 @item @emph{Standard}:
6871 @item @emph{Syntax}:
6872 @code{RESULT = MIN(A1, A2 [, A3, ...])}
6874 @item @emph{Arguments}:
6875 @multitable @columnfractions .15 .70
6876 @item @var{A1} @tab The type shall be @code{INTEGER(*)} or
6878 @item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
6879 as @var{A1}. (As a GNU extension,
6880 arguments of different kinds are
6884 @item @emph{Return value}:
6885 The return value corresponds to the maximum value among the arguments,
6886 and has the same type and kind as the first argument.
6888 @item @emph{Specific names}:
6889 @multitable @columnfractions .20 .20 .20 .25
6890 @item Name @tab Argument @tab Return type @tab Standard
6891 @item @code{MIN0(I)} @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)} @tab F77 and later
6892 @item @code{AMIN0(I)} @tab @code{INTEGER(4) I} @tab @code{REAL(MIN(X))} @tab F77 and later
6893 @item @code{MIN1(X)} @tab @code{REAL(*) X} @tab @code{INT(MIN(X))} @tab F77 and later
6894 @item @code{AMIN1(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab F77 and later
6895 @item @code{DMIN1(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
6898 @item @emph{See also}:
6899 @ref{MAX}, @ref{MINLOC}, @ref{MINVAL}
6905 @section @code{MINEXPONENT} --- Minimum exponent of a real kind
6906 @fnindex MINEXPONENT
6907 @cindex model representation, minimum exponent
6910 @item @emph{Description}:
6911 @code{MINEXPONENT(X)} returns the minimum exponent in the model of the
6914 @item @emph{Standard}:
6920 @item @emph{Syntax}:
6921 @code{RESULT = MINEXPONENT(X)}
6923 @item @emph{Arguments}:
6924 @multitable @columnfractions .15 .70
6925 @item @var{X} @tab Shall be of type @code{REAL}.
6928 @item @emph{Return value}:
6929 The return value is of type @code{INTEGER} and of the default integer
6932 @item @emph{Example}:
6933 See @code{MAXEXPONENT} for an example.
6939 @section @code{MINLOC} --- Location of the minimum value within an array
6941 @cindex array, location of minimum element
6944 @item @emph{Description}:
6945 Determines the location of the element in the array with the minimum
6946 value, or, if the @var{DIM} argument is supplied, determines the
6947 locations of the minimum element along each row of the array in the
6948 @var{DIM} direction. If @var{MASK} is present, only the elements for
6949 which @var{MASK} is @code{.TRUE.} are considered. If more than one
6950 element in the array has the minimum value, the location returned is
6951 that of the first such element in array element order. If the array has
6952 zero size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
6953 the result is an array of zeroes. Similarly, if @var{DIM} is supplied
6954 and all of the elements of @var{MASK} along a given row are zero, the
6955 result value for that row is zero.
6957 @item @emph{Standard}:
6961 Transformational function
6963 @item @emph{Syntax}:
6964 @multitable @columnfractions .80
6965 @item @code{RESULT = MINLOC(ARRAY, DIM [, MASK])}
6966 @item @code{RESULT = MINLOC(ARRAY [, MASK])}
6969 @item @emph{Arguments}:
6970 @multitable @columnfractions .15 .70
6971 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER(*)},
6972 @code{REAL(*)}, or @code{CHARACTER(*)}.
6973 @item @var{DIM} @tab (Optional) Shall be a scalar of type
6974 @code{INTEGER(*)}, with a value between one
6975 and the rank of @var{ARRAY}, inclusive. It
6976 may not be an optional dummy argument.
6977 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL(*)},
6978 and conformable with @var{ARRAY}.
6981 @item @emph{Return value}:
6982 If @var{DIM} is absent, the result is a rank-one array with a length
6983 equal to the rank of @var{ARRAY}. If @var{DIM} is present, the result
6984 is an array with a rank one less than the rank of @var{ARRAY}, and a
6985 size corresponding to the size of @var{ARRAY} with the @var{DIM}
6986 dimension removed. If @var{DIM} is present and @var{ARRAY} has a rank
6987 of one, the result is a scalar. In all cases, the result is of default
6988 @code{INTEGER} type.
6990 @item @emph{See also}:
6991 @ref{MIN}, @ref{MINVAL}
6998 @section @code{MINVAL} --- Minimum value of an array
7000 @cindex array, minmum value
7001 @cindex minimum value
7004 @item @emph{Description}:
7005 Determines the minimum value of the elements in an array value, or, if
7006 the @var{DIM} argument is supplied, determines the minimum value along
7007 each row of the array in the @var{DIM} direction. If @var{MASK} is
7008 present, only the elements for which @var{MASK} is @code{.TRUE.} are
7009 considered. If the array has zero size, or all of the elements of
7010 @var{MASK} are @code{.FALSE.}, then the result is @code{HUGE(ARRAY)} if
7011 @var{ARRAY} is numeric, or a string of @code{CHAR(255)} characters if
7012 @var{ARRAY} is of character type.
7014 @item @emph{Standard}:
7018 Transformational function
7020 @item @emph{Syntax}:
7021 @multitable @columnfractions .80
7022 @item @code{RESULT = MINVAL(ARRAY, DIM [, MASK])}
7023 @item @code{RESULT = MINVAL(ARRAY [, MASK])}
7026 @item @emph{Arguments}:
7027 @multitable @columnfractions .15 .70
7028 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER(*)},
7029 @code{REAL(*)}, or @code{CHARACTER(*)}.
7030 @item @var{DIM} @tab (Optional) Shall be a scalar of type
7031 @code{INTEGER(*)}, with a value between one
7032 and the rank of @var{ARRAY}, inclusive. It
7033 may not be an optional dummy argument.
7034 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL(*)},
7035 and conformable with @var{ARRAY}.
7038 @item @emph{Return value}:
7039 If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
7040 is a scalar. If @var{DIM} is present, the result is an array with a
7041 rank one less than the rank of @var{ARRAY}, and a size corresponding to
7042 the size of @var{ARRAY} with the @var{DIM} dimension removed. In all
7043 cases, the result is of the same type and kind as @var{ARRAY}.
7045 @item @emph{See also}:
7046 @ref{MIN}, @ref{MINLOC}
7053 @section @code{MOD} --- Remainder function
7058 @cindex division, remainder
7061 @item @emph{Description}:
7062 @code{MOD(A,P)} computes the remainder of the division of A by P. It is
7063 calculated as @code{A - (INT(A/P) * P)}.
7065 @item @emph{Standard}:
7071 @item @emph{Syntax}:
7072 @code{RESULT = MOD(A, P)}
7074 @item @emph{Arguments}:
7075 @multitable @columnfractions .15 .70
7076 @item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL}
7077 @item @var{P} @tab Shall be a scalar of the same type as @var{A} and not
7081 @item @emph{Return value}:
7082 The kind of the return value is the result of cross-promoting
7083 the kinds of the arguments.
7085 @item @emph{Example}:
7089 print *, mod(17.5,5.5)
7090 print *, mod(17.5d0,5.5)
7091 print *, mod(17.5,5.5d0)
7094 print *, mod(-17.5,5.5)
7095 print *, mod(-17.5d0,5.5)
7096 print *, mod(-17.5,5.5d0)
7099 print *, mod(17.5,-5.5)
7100 print *, mod(17.5d0,-5.5)
7101 print *, mod(17.5,-5.5d0)
7102 end program test_mod
7105 @item @emph{Specific names}:
7106 @multitable @columnfractions .20 .20 .20 .25
7107 @item Name @tab Arguments @tab Return type @tab Standard
7108 @item @code{AMOD(A,P)} @tab @code{REAL(4)} @tab @code{REAL(4)} @tab F95 and later
7109 @item @code{DMOD(A,P)} @tab @code{REAL(8)} @tab @code{REAL(8)} @tab F95 and later
7116 @section @code{MODULO} --- Modulo function
7119 @cindex division, modulo
7122 @item @emph{Description}:
7123 @code{MODULO(A,P)} computes the @var{A} modulo @var{P}.
7125 @item @emph{Standard}:
7131 @item @emph{Syntax}:
7132 @code{RESULT = MODULO(A, P)}
7134 @item @emph{Arguments}:
7135 @multitable @columnfractions .15 .70
7136 @item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL}
7137 @item @var{P} @tab Shall be a scalar of the same type and kind as @var{A}
7140 @item @emph{Return value}:
7141 The type and kind of the result are those of the arguments.
7143 @item If @var{A} and @var{P} are of type @code{INTEGER}:
7144 @code{MODULO(A,P)} has the value @var{R} such that @code{A=Q*P+R}, where
7145 @var{Q} is an integer and @var{R} is between 0 (inclusive) and @var{P}
7147 @item If @var{A} and @var{P} are of type @code{REAL}:
7148 @code{MODULO(A,P)} has the value of @code{A - FLOOR (A / P) * P}.
7150 In all cases, if @var{P} is zero the result is processor-dependent.
7152 @item @emph{Example}:
7155 print *, modulo(17,3)
7156 print *, modulo(17.5,5.5)
7158 print *, modulo(-17,3)
7159 print *, modulo(-17.5,5.5)
7161 print *, modulo(17,-3)
7162 print *, modulo(17.5,-5.5)
7171 @section @code{MOVE_ALLOC} --- Move allocation from one object to another
7173 @cindex moving allocation
7174 @cindex allocation, moving
7177 @item @emph{Description}:
7178 @code{MOVE_ALLOC(SRC, DEST)} moves the allocation from @var{SRC} to
7179 @var{DEST}. @var{SRC} will become deallocated in the process.
7181 @item @emph{Standard}:
7187 @item @emph{Syntax}:
7188 @code{CALL MOVE_ALLOC(SRC, DEST)}
7190 @item @emph{Arguments}:
7191 @multitable @columnfractions .15 .70
7192 @item @var{SRC} @tab @code{ALLOCATABLE}, @code{INTENT(INOUT)}, may be
7193 of any type and kind.
7194 @item @var{DEST} @tab @code{ALLOCATABLE}, @code{INTENT(OUT)}, shall be
7195 of the same type, kind and rank as @var{SRC}
7198 @item @emph{Return value}:
7201 @item @emph{Example}:
7203 program test_move_alloc
7204 integer, allocatable :: a(:), b(:)
7208 call move_alloc(a, b)
7209 print *, allocated(a), allocated(b)
7211 end program test_move_alloc
7218 @section @code{MVBITS} --- Move bits from one integer to another
7223 @item @emph{Description}:
7224 Moves @var{LEN} bits from positions @var{FROMPOS} through
7225 @code{FROMPOS+LEN-1} of @var{FROM} to positions @var{TOPOS} through
7226 @code{TOPOS+LEN-1} of @var{TO}. The portion of argument @var{TO} not
7227 affected by the movement of bits is unchanged. The values of
7228 @code{FROMPOS+LEN-1} and @code{TOPOS+LEN-1} must be less than
7229 @code{BIT_SIZE(FROM)}.
7231 @item @emph{Standard}:
7235 Elemental subroutine
7237 @item @emph{Syntax}:
7238 @code{CALL MVBITS(FROM, FROMPOS, LEN, TO, TOPOS)}
7240 @item @emph{Arguments}:
7241 @multitable @columnfractions .15 .70
7242 @item @var{FROM} @tab The type shall be @code{INTEGER(*)}.
7243 @item @var{FROMPOS} @tab The type shall be @code{INTEGER(*)}.
7244 @item @var{LEN} @tab The type shall be @code{INTEGER(*)}.
7245 @item @var{TO} @tab The type shall be @code{INTEGER(*)}, of the
7246 same kind as @var{FROM}.
7247 @item @var{TOPOS} @tab The type shall be @code{INTEGER(*)}.
7250 @item @emph{See also}:
7251 @ref{IBCLR}, @ref{IBSET}, @ref{IBITS}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
7257 @section @code{NEAREST} --- Nearest representable number
7259 @cindex real number, nearest different
7260 @cindex floating point, nearest different
7263 @item @emph{Description}:
7264 @code{NEAREST(X, S)} returns the processor-representable number nearest
7265 to @code{X} in the direction indicated by the sign of @code{S}.
7267 @item @emph{Standard}:
7273 @item @emph{Syntax}:
7274 @code{RESULT = NEAREST(X, S)}
7276 @item @emph{Arguments}:
7277 @multitable @columnfractions .15 .70
7278 @item @var{X} @tab Shall be of type @code{REAL}.
7279 @item @var{S} @tab (Optional) shall be of type @code{REAL} and
7283 @item @emph{Return value}:
7284 The return value is of the same type as @code{X}. If @code{S} is
7285 positive, @code{NEAREST} returns the processor-representable number
7286 greater than @code{X} and nearest to it. If @code{S} is negative,
7287 @code{NEAREST} returns the processor-representable number smaller than
7288 @code{X} and nearest to it.
7290 @item @emph{Example}:
7292 program test_nearest
7294 x = nearest(42.0, 1.0)
7295 y = nearest(42.0, -1.0)
7296 write (*,"(3(G20.15))") x, y, x - y
7297 end program test_nearest
7304 @section @code{NEW_LINE} --- New line character
7307 @cindex output, newline
7310 @item @emph{Description}:
7311 @code{NEW_LINE(C)} returns the new-line character.
7313 @item @emph{Standard}:
7319 @item @emph{Syntax}:
7320 @code{RESULT = NEW_LINE(C)}
7322 @item @emph{Arguments}:
7323 @multitable @columnfractions .15 .70
7324 @item @var{C} @tab The argument shall be a scalar or array of the
7325 type @code{CHARACTER}.
7328 @item @emph{Return value}:
7329 Returns a @var{CHARACTER} scalar of length one with the new-line character of
7330 the same kind as parameter @var{C}.
7332 @item @emph{Example}:
7336 write(*,'(A)') 'This is record 1.'//NEW_LINE('A')//'This is record 2.'
7344 @section @code{NINT} --- Nearest whole number
7347 @cindex rounding, nearest whole number
7350 @item @emph{Description}:
7351 @code{NINT(X)} rounds its argument to the nearest whole number.
7353 @item @emph{Standard}:
7359 @item @emph{Syntax}:
7360 @code{RESULT = NINT(X)}
7362 @item @emph{Arguments}:
7363 @multitable @columnfractions .15 .70
7364 @item @var{X} @tab The type of the argument shall be @code{REAL}.
7367 @item @emph{Return value}:
7368 Returns @var{A} with the fractional portion of its magnitude eliminated by
7369 rounding to the nearest whole number and with its sign preserved,
7370 converted to an @code{INTEGER} of the default kind.
7372 @item @emph{Example}:
7379 print *, nint(x4), idnint(x8)
7380 end program test_nint
7383 @item @emph{Specific names}:
7384 @multitable @columnfractions .25 .25 .25
7385 @item Name @tab Argument @tab Standard
7386 @item @code{IDNINT(X)} @tab @code{REAL(8)} @tab F95 and later
7389 @item @emph{See also}:
7390 @ref{CEILING}, @ref{FLOOR}
7397 @section @code{NOT} --- Logical negation
7399 @cindex bits, negate
7400 @cindex bitwise logical not
7401 @cindex logical not, bitwise
7404 @item @emph{Description}:
7405 @code{NOT} returns the bitwise boolean inverse of @var{I}.
7407 @item @emph{Standard}:
7413 @item @emph{Syntax}:
7414 @code{RESULT = NOT(I)}
7416 @item @emph{Arguments}:
7417 @multitable @columnfractions .15 .70
7418 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
7421 @item @emph{Return value}:
7422 The return type is @code{INTEGER(*)}, of the same kind as the
7425 @item @emph{See also}:
7426 @ref{IAND}, @ref{IEOR}, @ref{IOR}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}
7433 @section @code{NULL} --- Function that returns an disassociated pointer
7435 @cindex pointer, status
7436 @cindex pointer, disassociated
7439 @item @emph{Description}:
7440 Returns a disassociated pointer.
7442 If @var{MOLD} is present, a dissassociated pointer of the same type is
7443 returned, otherwise the type is determined by context.
7445 In Fortran 95, @var{MOLD} is optional. Please note that F2003 includes
7446 cases where it is required.
7448 @item @emph{Standard}:
7452 Transformational function
7454 @item @emph{Syntax}:
7455 @code{PTR => NULL([MOLD])}
7457 @item @emph{Arguments}:
7458 @multitable @columnfractions .15 .70
7459 @item @var{MOLD} @tab (Optional) shall be a pointer of any association
7460 status and of any type.
7463 @item @emph{Return value}:
7464 A disassociated pointer.
7466 @item @emph{Example}:
7468 REAL, POINTER, DIMENSION(:) :: VEC => NULL ()
7471 @item @emph{See also}:
7478 @section @code{OR} --- Bitwise logical OR
7480 @cindex bitwise logical or
7481 @cindex logical or, bitwise
7484 @item @emph{Description}:
7485 Bitwise logical @code{OR}.
7487 This intrinsic routine is provided for backwards compatibility with
7488 GNU Fortran 77. For integer arguments, programmers should consider
7489 the use of the @ref{IOR} intrinsic defined by the Fortran standard.
7491 @item @emph{Standard}:
7495 Non-elemental function
7497 @item @emph{Syntax}:
7498 @code{RESULT = OR(X, Y)}
7500 @item @emph{Arguments}:
7501 @multitable @columnfractions .15 .70
7502 @item @var{X} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
7503 @item @var{Y} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
7506 @item @emph{Return value}:
7507 The return type is either @code{INTEGER(*)} or @code{LOGICAL}
7508 after cross-promotion of the arguments.
7510 @item @emph{Example}:
7513 LOGICAL :: T = .TRUE., F = .FALSE.
7515 DATA a / Z'F' /, b / Z'3' /
7517 WRITE (*,*) OR(T, T), OR(T, F), OR(F, T), OR(F, F)
7518 WRITE (*,*) OR(a, b)
7522 @item @emph{See also}:
7523 F95 elemental function: @ref{IOR}
7529 @section @code{PACK} --- Pack an array into an array of rank one
7531 @cindex array, packing
7532 @cindex array, reduce dimension
7533 @cindex array, gather elements
7536 @item @emph{Description}:
7537 Stores the elements of @var{ARRAY} in an array of rank one.
7539 The beginning of the resulting array is made up of elements whose @var{MASK}
7540 equals @code{TRUE}. Afterwards, positions are filled with elements taken from
7543 @item @emph{Standard}:
7547 Transformational function
7549 @item @emph{Syntax}:
7550 @code{RESULT = PACK(ARRAY, MASK[,VECTOR]}
7552 @item @emph{Arguments}:
7553 @multitable @columnfractions .15 .70
7554 @item @var{ARRAY} @tab Shall be an array of any type.
7555 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL} and
7556 of the same size as @var{ARRAY}. Alternatively, it may be a @code{LOGICAL}
7558 @item @var{VECTOR} @tab (Optional) shall be an array of the same type
7559 as @var{ARRAY} and of rank one. If present, the number of elements in
7560 @var{VECTOR} shall be equal to or greater than the number of true elements
7561 in @var{MASK}. If @var{MASK} is scalar, the number of elements in
7562 @var{VECTOR} shall be equal to or greater than the number of elements in
7566 @item @emph{Return value}:
7567 The result is an array of rank one and the same type as that of @var{ARRAY}.
7568 If @var{VECTOR} is present, the result size is that of @var{VECTOR}, the
7569 number of @code{TRUE} values in @var{MASK} otherwise.
7571 @item @emph{Example}:
7572 Gathering non-zero elements from an array:
7576 m = (/ 1, 0, 0, 0, 5, 0 /)
7577 WRITE(*, FMT="(6(I0, ' '))") pack(m, m /= 0) ! "1 5"
7581 Gathering non-zero elements from an array and appending elements from @var{VECTOR}:
7585 m = (/ 1, 0, 0, 2 /)
7586 WRITE(*, FMT="(4(I0, ' '))") pack(m, m /= 0, (/ 0, 0, 3, 4 /)) ! "1 2 3 4"
7590 @item @emph{See also}:
7597 @section @code{PERROR} --- Print system error message
7599 @cindex system, error handling
7602 @item @emph{Description}:
7603 Prints (on the C @code{stderr} stream) a newline-terminated error
7604 message corresponding to the last system error. This is prefixed by
7605 @var{STRING}, a colon and a space. See @code{perror(3)}.
7607 @item @emph{Standard}:
7613 @item @emph{Syntax}:
7614 @code{CALL PERROR(STRING)}
7616 @item @emph{Arguments}:
7617 @multitable @columnfractions .15 .70
7618 @item @var{STRING} @tab A scalar of default @code{CHARACTER} type.
7621 @item @emph{See also}:
7628 @section @code{PRECISION} --- Decimal precision of a real kind
7630 @cindex model representation, precision
7633 @item @emph{Description}:
7634 @code{PRECISION(X)} returns the decimal precision in the model of the
7637 @item @emph{Standard}:
7643 @item @emph{Syntax}:
7644 @code{RESULT = PRECISION(X)}
7646 @item @emph{Arguments}:
7647 @multitable @columnfractions .15 .70
7648 @item @var{X} @tab Shall be of type @code{REAL} or @code{COMPLEX}.
7651 @item @emph{Return value}:
7652 The return value is of type @code{INTEGER} and of the default integer
7655 @item @emph{Example}:
7657 program prec_and_range
7658 real(kind=4) :: x(2)
7659 complex(kind=8) :: y
7661 print *, precision(x), range(x)
7662 print *, precision(y), range(y)
7663 end program prec_and_range
7670 @section @code{PRESENT} --- Determine whether an optional dummy argument is specified
7674 @item @emph{Description}:
7675 Determines whether an optional dummy argument is present.
7677 @item @emph{Standard}:
7683 @item @emph{Syntax}:
7684 @code{RESULT = PRESENT(A)}
7686 @item @emph{Arguments}:
7687 @multitable @columnfractions .15 .70
7688 @item @var{A} @tab May be of any type and may be a pointer, scalar or array
7689 value, or a dummy procedure. It shall be the name of an optional dummy argument
7690 accessible within the current subroutine or function.
7693 @item @emph{Return value}:
7694 Returns either @code{TRUE} if the optional argument @var{A} is present, or
7695 @code{FALSE} otherwise.
7697 @item @emph{Example}:
7699 PROGRAM test_present
7700 WRITE(*,*) f(), f(42) ! "F T"
7702 LOGICAL FUNCTION f(x)
7703 INTEGER, INTENT(IN), OPTIONAL :: x
7713 @section @code{PRODUCT} --- Product of array elements
7715 @cindex array, product
7716 @cindex array, multiply elements
7717 @cindex array, conditionally multiply elements
7718 @cindex multiply array elements
7721 @item @emph{Description}:
7722 Multiplies the elements of @var{ARRAY} along dimension @var{DIM} if
7723 the corresponding element in @var{MASK} is @code{TRUE}.
7725 @item @emph{Standard}:
7729 Transformational function
7731 @item @emph{Syntax}:
7732 @code{RESULT = PRODUCT(ARRAY[, MASK])}
7733 @code{RESULT = PRODUCT(ARRAY, DIM[, MASK])}
7735 @item @emph{Arguments}:
7736 @multitable @columnfractions .15 .70
7737 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER(*)},
7738 @code{REAL(*)} or @code{COMPLEX(*)}.
7739 @item @var{DIM} @tab (Optional) shall be a scalar of type
7740 @code{INTEGER} with a value in the range from 1 to n, where n
7741 equals the rank of @var{ARRAY}.
7742 @item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL}
7743 and either be a scalar or an array of the same shape as @var{ARRAY}.
7746 @item @emph{Return value}:
7747 The result is of the same type as @var{ARRAY}.
7749 If @var{DIM} is absent, a scalar with the product of all elements in
7750 @var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals
7751 the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with
7752 dimension @var{DIM} dropped is returned.
7755 @item @emph{Example}:
7757 PROGRAM test_product
7758 INTEGER :: x(5) = (/ 1, 2, 3, 4 ,5 /)
7759 print *, PRODUCT(x) ! all elements, product = 120
7760 print *, PRODUCT(x, MASK=MOD(x, 2)==1) ! odd elements, product = 15
7764 @item @emph{See also}:
7771 @section @code{RADIX} --- Base of a model number
7773 @cindex model representation, base
7774 @cindex model representation, radix
7777 @item @emph{Description}:
7778 @code{RADIX(X)} returns the base of the model representing the entity @var{X}.
7780 @item @emph{Standard}:
7786 @item @emph{Syntax}:
7787 @code{RESULT = RADIX(X)}
7789 @item @emph{Arguments}:
7790 @multitable @columnfractions .15 .70
7791 @item @var{X} @tab Shall be of type @code{INTEGER} or @code{REAL}
7794 @item @emph{Return value}:
7795 The return value is a scalar of type @code{INTEGER} and of the default
7798 @item @emph{Example}:
7801 print *, "The radix for the default integer kind is", radix(0)
7802 print *, "The radix for the default real kind is", radix(0.0)
7803 end program test_radix
7811 @section @code{RAN} --- Real pseudo-random number
7813 @cindex random number generation
7816 @item @emph{Description}:
7817 For compatibility with HP FORTRAN 77/iX, the @code{RAN} intrinsic is
7818 provided as an alias for @code{RAND}. See @ref{RAND} for complete
7821 @item @emph{Standard}:
7825 Non-elemental function
7827 @item @emph{See also}:
7828 @ref{RAND}, @ref{RANDOM_NUMBER}
7834 @section @code{RAND} --- Real pseudo-random number
7836 @cindex random number generation
7839 @item @emph{Description}:
7840 @code{RAND(FLAG)} returns a pseudo-random number from a uniform
7841 distribution between 0 and 1. If @var{FLAG} is 0, the next number
7842 in the current sequence is returned; if @var{FLAG} is 1, the generator
7843 is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
7844 it is used as a new seed with @code{SRAND}.
7846 @item @emph{Standard}:
7850 Non-elemental function
7852 @item @emph{Syntax}:
7853 @code{RESULT = RAND(FLAG)}
7855 @item @emph{Arguments}:
7856 @multitable @columnfractions .15 .70
7857 @item @var{FLAG} @tab Shall be a scalar @code{INTEGER} of kind 4.
7860 @item @emph{Return value}:
7861 The return value is of @code{REAL} type and the default kind.
7863 @item @emph{Example}:
7866 integer,parameter :: seed = 86456
7869 print *, rand(), rand(), rand(), rand()
7870 print *, rand(seed), rand(), rand(), rand()
7871 end program test_rand
7874 @item @emph{See also}:
7875 @ref{SRAND}, @ref{RANDOM_NUMBER}
7882 @section @code{RANDOM_NUMBER} --- Pseudo-random number
7883 @fnindex RANDOM_NUMBER
7884 @cindex random number generation
7887 @item @emph{Description}:
7888 Returns a single pseudorandom number or an array of pseudorandom numbers
7889 from the uniform distribution over the range @math{ 0 \leq x < 1}.
7891 @item @emph{Standard}:
7897 @item @emph{Syntax}:
7898 @code{RANDOM_NUMBER(HARVEST)}
7900 @item @emph{Arguments}:
7901 @multitable @columnfractions .15 .70
7902 @item @var{HARVEST} @tab Shall be a scalar or an array of type @code{REAL(*)}.
7905 @item @emph{Example}:
7907 program test_random_number
7909 CALL init_random_seed() ! see example of RANDOM_SEED
7910 CALL RANDOM_NUMBER(r)
7915 The implemented random number generator is thread safe if used within
7916 OpenMP directives, i. e. its state will be consistent while called from
7917 multiple threads. Please note that the currently implemented KISS generator
7918 does not create random numbers in parallel from multiple sources, but in
7919 sequence from a single source. If your OpenMP-enabled application heavily
7920 relies on random numbers, you should consider employing a dedicated parallel
7921 random number generator instead.
7923 @item @emph{See also}:
7930 @section @code{RANDOM_SEED} --- Initialize a pseudo-random number sequence
7931 @fnindex RANDOM_SEED
7932 @cindex random number generation, seeding
7933 @cindex seeding a random number generator
7936 @item @emph{Description}:
7937 Restarts or queries the state of the pseudorandom number generator used by
7938 @code{RANDOM_NUMBER}.
7940 If @code{RANDOM_SEED} is called without arguments, it is initialized to
7941 a default state. The example below shows how to initialize the random
7942 seed based on the system's time.
7944 @item @emph{Standard}:
7950 @item @emph{Syntax}:
7951 @code{CALL RANDOM_SEED(SIZE, PUT, GET)}
7953 @item @emph{Arguments}:
7954 @multitable @columnfractions .15 .70
7955 @item @var{SIZE} @tab (Optional) Shall be a scalar and of type default
7956 @code{INTEGER}, with @code{INTENT(OUT)}. It specifies the minimum size
7957 of the arrays used with the @var{PUT} and @var{GET} arguments.
7958 @item @var{PUT} @tab (Optional) Shall be an array of type default
7959 @code{INTEGER} and rank one. It is @code{INTENT(IN)} and the size of
7960 the array must be larger than or equal to the number returned by the
7961 @var{SIZE} argument.
7962 @item @var{GET} @tab (Optional) Shall be an array of type default
7963 @code{INTEGER} and rank one. It is @code{INTENT(OUT)} and the size
7964 of the array must be larger than or equal to the number returned by
7965 the @var{SIZE} argument.
7968 @item @emph{Example}:
7970 SUBROUTINE init_random_seed()
7971 INTEGER :: i, n, clock
7972 INTEGER, DIMENSION(:), ALLOCATABLE :: seed
7974 CALL RANDOM_SEED(size = n)
7977 CALL SYSTEM_CLOCK(COUNT=clock)
7979 seed = clock + 37 * (/ (i - 1, i = 1, n) /)
7980 CALL RANDOM_SEED(PUT = seed)
7986 @item @emph{See also}:
7993 @section @code{RANGE} --- Decimal exponent range of a real kind
7995 @cindex model representation, range
7998 @item @emph{Description}:
7999 @code{RANGE(X)} returns the decimal exponent range in the model of the
8002 @item @emph{Standard}:
8008 @item @emph{Syntax}:
8009 @code{RESULT = RANGE(X)}
8011 @item @emph{Arguments}:
8012 @multitable @columnfractions .15 .70
8013 @item @var{X} @tab Shall be of type @code{REAL} or @code{COMPLEX}.
8016 @item @emph{Return value}:
8017 The return value is of type @code{INTEGER} and of the default integer
8020 @item @emph{Example}:
8021 See @code{PRECISION} for an example.
8027 @section @code{REAL} --- Convert to real type
8030 @cindex conversion, to real
8031 @cindex complex numbers, real part
8034 @item @emph{Description}:
8035 @code{REAL(X [, KIND])} converts its argument @var{X} to a real type. The
8036 @code{REALPART(X)} function is provided for compatibility with @command{g77},
8037 and its use is strongly discouraged.
8039 @item @emph{Standard}:
8045 @item @emph{Syntax}:
8046 @multitable @columnfractions .80
8047 @item @code{RESULT = REAL(X [, KIND])}
8048 @item @code{RESULT = REALPART(Z)}
8051 @item @emph{Arguments}:
8052 @multitable @columnfractions .15 .70
8053 @item @var{X} @tab Shall be @code{INTEGER(*)}, @code{REAL(*)}, or
8055 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
8056 expression indicating the kind parameter of
8060 @item @emph{Return value}:
8061 These functions return a @code{REAL(*)} variable or array under
8062 the following rules:
8066 @code{REAL(X)} is converted to a default real type if @var{X} is an
8067 integer or real variable.
8069 @code{REAL(X)} is converted to a real type with the kind type parameter
8070 of @var{X} if @var{X} is a complex variable.
8072 @code{REAL(X, KIND)} is converted to a real type with kind type
8073 parameter @var{KIND} if @var{X} is a complex, integer, or real
8077 @item @emph{Example}:
8080 complex :: x = (1.0, 2.0)
8081 print *, real(x), real(x,8), realpart(x)
8082 end program test_real
8085 @item @emph{See also}:
8086 @ref{DBLE}, @ref{DFLOAT}, @ref{FLOAT}
8093 @section @code{RENAME} --- Rename a file
8095 @cindex file system, rename file
8098 @item @emph{Description}:
8099 Renames a file from file @var{PATH1} to @var{PATH2}. A null
8100 character (@code{CHAR(0)}) can be used to mark the end of the names in
8101 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
8102 names are ignored. If the @var{STATUS} argument is supplied, it
8103 contains 0 on success or a nonzero error code upon return; see
8106 This intrinsic is provided in both subroutine and function forms;
8107 however, only one form can be used in any given program unit.
8109 @item @emph{Standard}:
8113 Subroutine, non-elemental function
8115 @item @emph{Syntax}:
8116 @multitable @columnfractions .80
8117 @item @code{CALL RENAME(PATH1, PATH2 [, STATUS])}
8118 @item @code{STATUS = RENAME(PATH1, PATH2)}
8121 @item @emph{Arguments}:
8122 @multitable @columnfractions .15 .70
8123 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
8124 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
8125 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
8128 @item @emph{See also}:
8136 @section @code{REPEAT} --- Repeated string concatenation
8138 @cindex string, repeat
8139 @cindex string, concatenate
8142 @item @emph{Description}:
8143 Concatenates @var{NCOPIES} copies of a string.
8145 @item @emph{Standard}:
8149 Transformational function
8151 @item @emph{Syntax}:
8152 @code{RESULT = REPEAT(STRING, NCOPIES)}
8154 @item @emph{Arguments}:
8155 @multitable @columnfractions .15 .70
8156 @item @var{STRING} @tab Shall be scalar and of type @code{CHARACTER(*)}.
8157 @item @var{NCOPIES} @tab Shall be scalar and of type @code{INTEGER(*)}.
8160 @item @emph{Return value}:
8161 A new scalar of type @code{CHARACTER} built up from @var{NCOPIES} copies
8164 @item @emph{Example}:
8167 write(*,*) repeat("x", 5) ! "xxxxx"
8175 @section @code{RESHAPE} --- Function to reshape an array
8177 @cindex array, change dimensions
8178 @cindex array, transmogrify
8181 @item @emph{Description}:
8182 Reshapes @var{SOURCE} to correspond to @var{SHAPE}. If necessary,
8183 the new array may be padded with elements from @var{PAD} or permuted
8184 as defined by @var{ORDER}.
8186 @item @emph{Standard}:
8190 Transformational function
8192 @item @emph{Syntax}:
8193 @code{RESULT = RESHAPE(SOURCE, SHAPE[, PAD, ORDER])}
8195 @item @emph{Arguments}:
8196 @multitable @columnfractions .15 .70
8197 @item @var{SOURCE} @tab Shall be an array of any type.
8198 @item @var{SHAPE} @tab Shall be of type @code{INTEGER} and an
8199 array of rank one. Its values must be positive or zero.
8200 @item @var{PAD} @tab (Optional) shall be an array of the same
8201 type as @var{SOURCE}.
8202 @item @var{ORDER} @tab (Optional) shall be of type @code{INTEGER}
8203 and an array of the same shape as @var{SHAPE}. Its values shall
8204 be a permutation of the numbers from 1 to n, where n is the size of
8205 @var{SHAPE}. If @var{ORDER} is absent, the natural ordering shall
8209 @item @emph{Return value}:
8210 The result is an array of shape @var{SHAPE} with the same type as
8213 @item @emph{Example}:
8215 PROGRAM test_reshape
8216 INTEGER, DIMENSION(4) :: x
8217 WRITE(*,*) SHAPE(x) ! prints "4"
8218 WRITE(*,*) SHAPE(RESHAPE(x, (/2, 2/))) ! prints "2 2"
8222 @item @emph{See also}:
8229 @section @code{RRSPACING} --- Reciprocal of the relative spacing
8231 @cindex real number, relative spacing
8232 @cindex floating point, relative spacing
8236 @item @emph{Description}:
8237 @code{RRSPACING(X)} returns the reciprocal of the relative spacing of
8238 model numbers near @var{X}.
8240 @item @emph{Standard}:
8246 @item @emph{Syntax}:
8247 @code{RESULT = RRSPACING(X)}
8249 @item @emph{Arguments}:
8250 @multitable @columnfractions .15 .70
8251 @item @var{X} @tab Shall be of type @code{REAL}.
8254 @item @emph{Return value}:
8255 The return value is of the same type and kind as @var{X}.
8256 The value returned is equal to
8257 @code{ABS(FRACTION(X)) * FLOAT(RADIX(X))**DIGITS(X)}.
8259 @item @emph{See also}:
8266 @section @code{RSHIFT} --- Right shift bits
8268 @cindex bits, shift right
8271 @item @emph{Description}:
8272 @code{RSHIFT} returns a value corresponding to @var{I} with all of the
8273 bits shifted right by @var{SHIFT} places. If the absolute value of
8274 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
8275 Bits shifted out from the left end are lost; zeros are shifted in from
8278 This function has been superseded by the @code{ISHFT} intrinsic, which
8279 is standard in Fortran 95 and later.
8281 @item @emph{Standard}:
8287 @item @emph{Syntax}:
8288 @code{RESULT = RSHIFT(I, SHIFT)}
8290 @item @emph{Arguments}:
8291 @multitable @columnfractions .15 .70
8292 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
8293 @item @var{SHIFT} @tab The type shall be @code{INTEGER(*)}.
8296 @item @emph{Return value}:
8297 The return value is of type @code{INTEGER(*)} and of the same kind as
8300 @item @emph{See also}:
8301 @ref{ISHFT}, @ref{ISHFTC}, @ref{LSHIFT}
8308 @section @code{SCALE} --- Scale a real value
8310 @cindex real number, scale
8311 @cindex floating point, scale
8314 @item @emph{Description}:
8315 @code{SCALE(X,I)} returns @code{X * RADIX(X)**I}.
8317 @item @emph{Standard}:
8323 @item @emph{Syntax}:
8324 @code{RESULT = SCALE(X, I)}
8326 @item @emph{Arguments}:
8327 @multitable @columnfractions .15 .70
8328 @item @var{X} @tab The type of the argument shall be a @code{REAL}.
8329 @item @var{I} @tab The type of the argument shall be a @code{INTEGER}.
8332 @item @emph{Return value}:
8333 The return value is of the same type and kind as @var{X}.
8334 Its value is @code{X * RADIX(X)**I}.
8336 @item @emph{Example}:
8339 real :: x = 178.1387e-4
8341 print *, scale(x,i), x*radix(x)**i
8342 end program test_scale
8350 @section @code{SCAN} --- Scan a string for the presence of a set of characters
8352 @cindex string, find subset
8355 @item @emph{Description}:
8356 Scans a @var{STRING} for any of the characters in a @var{SET}
8359 If @var{BACK} is either absent or equals @code{FALSE}, this function
8360 returns the position of the leftmost character of @var{STRING} that is
8361 in @var{SET}. If @var{BACK} equals @code{TRUE}, the rightmost position
8362 is returned. If no character of @var{SET} is found in @var{STRING}, the
8365 @item @emph{Standard}:
8371 @item @emph{Syntax}:
8372 @code{RESULT = SCAN(STRING, SET[, BACK])}
8374 @item @emph{Arguments}:
8375 @multitable @columnfractions .15 .70
8376 @item @var{STRING} @tab Shall be of type @code{CHARACTER(*)}.
8377 @item @var{SET} @tab Shall be of type @code{CHARACTER(*)}.
8378 @item @var{BACK} @tab (Optional) shall be of type @code{LOGICAL}.
8381 @item @emph{Return value}:
8382 The return value is of type @code{INTEGER} and of the default
8385 @item @emph{Example}:
8388 WRITE(*,*) SCAN("FORTRAN", "AO") ! 2, found 'O'
8389 WRITE(*,*) SCAN("FORTRAN", "AO", .TRUE.) ! 6, found 'A'
8390 WRITE(*,*) SCAN("FORTRAN", "C++") ! 0, found none
8394 @item @emph{See also}:
8395 @ref{INDEX}, @ref{VERIFY}
8401 @section @code{SECNDS} --- Time function
8403 @cindex time, elapsed
8404 @cindex elapsed time
8407 @item @emph{Description}:
8408 @code{SECNDS(X)} gets the time in seconds from the real-time system clock.
8409 @var{X} is a reference time, also in seconds. If this is zero, the time in
8410 seconds from midnight is returned. This function is non-standard and its
8413 @item @emph{Standard}:
8417 Non-elemental function
8419 @item @emph{Syntax}:
8420 @code{RESULT = SECNDS (X)}
8422 @item @emph{Arguments}:
8423 @multitable @columnfractions .15 .70
8424 @item @var{T} @tab Shall be of type @code{REAL(4)}.
8425 @item @var{X} @tab Shall be of type @code{REAL(4)}.
8428 @item @emph{Return value}:
8431 @item @emph{Example}:
8436 print *, secnds (0.0) ! seconds since midnight
8437 t1 = secnds (0.0) ! reference time
8438 do i = 1, 10000000 ! do something
8440 t2 = secnds (t1) ! elapsed time
8441 print *, "Something took ", t2, " seconds."
8442 end program test_secnds
8449 @section @code{SECOND} --- CPU time function
8451 @cindex time, elapsed
8452 @cindex elapsed time
8455 @item @emph{Description}:
8456 Returns a @code{REAL(4)} value representing the elapsed CPU time in
8457 seconds. This provides the same functionality as the standard
8458 @code{CPU_TIME} intrinsic, and is only included for backwards
8461 This intrinsic is provided in both subroutine and function forms;
8462 however, only one form can be used in any given program unit.
8464 @item @emph{Standard}:
8468 Subroutine, non-elemental function
8470 @item @emph{Syntax}:
8471 @multitable @columnfractions .80
8472 @item @code{CALL SECOND(TIME)}
8473 @item @code{TIME = SECOND()}
8476 @item @emph{Arguments}:
8477 @multitable @columnfractions .15 .70
8478 @item @var{TIME} @tab Shall be of type @code{REAL(4)}.
8481 @item @emph{Return value}:
8482 In either syntax, @var{TIME} is set to the process's current runtime in
8485 @item @emph{See also}:
8492 @node SELECTED_INT_KIND
8493 @section @code{SELECTED_INT_KIND} --- Choose integer kind
8494 @fnindex SELECTED_INT_KIND
8495 @cindex integer kind
8496 @cindex kind, integer
8499 @item @emph{Description}:
8500 @code{SELECTED_INT_KIND(I)} return the kind value of the smallest integer
8501 type that can represent all values ranging from @math{-10^I} (exclusive)
8502 to @math{10^I} (exclusive). If there is no integer kind that accommodates
8503 this range, @code{SELECTED_INT_KIND} returns @math{-1}.
8505 @item @emph{Standard}:
8509 Transformational function
8511 @item @emph{Syntax}:
8512 @code{RESULT = SELECTED_INT_KIND(I)}
8514 @item @emph{Arguments}:
8515 @multitable @columnfractions .15 .70
8516 @item @var{I} @tab Shall be a scalar and of type @code{INTEGER}.
8519 @item @emph{Example}:
8521 program large_integers
8522 integer,parameter :: k5 = selected_int_kind(5)
8523 integer,parameter :: k15 = selected_int_kind(15)
8524 integer(kind=k5) :: i5
8525 integer(kind=k15) :: i15
8527 print *, huge(i5), huge(i15)
8529 ! The following inequalities are always true
8530 print *, huge(i5) >= 10_k5**5-1
8531 print *, huge(i15) >= 10_k15**15-1
8532 end program large_integers
8538 @node SELECTED_REAL_KIND
8539 @section @code{SELECTED_REAL_KIND} --- Choose real kind
8540 @fnindex SELECTED_REAL_KIND
8545 @item @emph{Description}:
8546 @code{SELECTED_REAL_KIND(P,R)} return the kind value of a real data type
8547 with decimal precision greater of at least @code{P} digits and exponent
8548 range greater at least @code{R}.
8550 @item @emph{Standard}:
8554 Transformational function
8556 @item @emph{Syntax}:
8557 @code{RESULT = SELECTED_REAL_KIND(P, R)}
8559 @item @emph{Arguments}:
8560 @multitable @columnfractions .15 .70
8561 @item @var{P} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
8562 @item @var{R} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
8564 At least one argument shall be present.
8566 @item @emph{Return value}:
8568 @code{SELECTED_REAL_KIND} returns the value of the kind type parameter of
8569 a real data type with decimal precision of at least @code{P} digits and a
8570 decimal exponent range of at least @code{R}. If more than one real data
8571 type meet the criteria, the kind of the data type with the smallest
8572 decimal precision is returned. If no real data type matches the criteria,
8575 @item -1 if the processor does not support a real data type with a
8576 precision greater than or equal to @code{P}
8577 @item -2 if the processor does not support a real type with an exponent
8578 range greater than or equal to @code{R}
8579 @item -3 if neither is supported.
8582 @item @emph{Example}:
8585 integer,parameter :: p6 = selected_real_kind(6)
8586 integer,parameter :: p10r100 = selected_real_kind(10,100)
8587 integer,parameter :: r400 = selected_real_kind(r=400)
8589 real(kind=p10r100) :: y
8590 real(kind=r400) :: z
8592 print *, precision(x), range(x)
8593 print *, precision(y), range(y)
8594 print *, precision(z), range(z)
8595 end program real_kinds
8602 @section @code{SET_EXPONENT} --- Set the exponent of the model
8603 @fnindex SET_EXPONENT
8604 @cindex real number, set exponent
8605 @cindex floating point, set exponent
8608 @item @emph{Description}:
8609 @code{SET_EXPONENT(X, I)} returns the real number whose fractional part
8610 is that that of @var{X} and whose exponent part is @var{I}.
8612 @item @emph{Standard}:
8618 @item @emph{Syntax}:
8619 @code{RESULT = SET_EXPONENT(X, I)}
8621 @item @emph{Arguments}:
8622 @multitable @columnfractions .15 .70
8623 @item @var{X} @tab Shall be of type @code{REAL}.
8624 @item @var{I} @tab Shall be of type @code{INTEGER}.
8627 @item @emph{Return value}:
8628 The return value is of the same type and kind as @var{X}.
8629 The real number whose fractional part
8630 is that that of @var{X} and whose exponent part if @var{I} is returned;
8631 it is @code{FRACTION(X) * RADIX(X)**I}.
8633 @item @emph{Example}:
8636 REAL :: x = 178.1387e-4
8638 PRINT *, SET_EXPONENT(x, i), FRACTION(x) * RADIX(x)**i
8647 @section @code{SHAPE} --- Determine the shape of an array
8649 @cindex array, shape
8652 @item @emph{Description}:
8653 Determines the shape of an array.
8655 @item @emph{Standard}:
8661 @item @emph{Syntax}:
8662 @code{RESULT = SHAPE(SOURCE)}
8664 @item @emph{Arguments}:
8665 @multitable @columnfractions .15 .70
8666 @item @var{SOURCE} @tab Shall be an array or scalar of any type.
8667 If @var{SOURCE} is a pointer it must be associated and allocatable
8668 arrays must be allocated.
8671 @item @emph{Return value}:
8672 An @code{INTEGER} array of rank one with as many elements as @var{SOURCE}
8673 has dimensions. The elements of the resulting array correspond to the extend
8674 of @var{SOURCE} along the respective dimensions. If @var{SOURCE} is a scalar,
8675 the result is the rank one array of size zero.
8677 @item @emph{Example}:
8680 INTEGER, DIMENSION(-1:1, -1:2) :: A
8681 WRITE(*,*) SHAPE(A) ! (/ 3, 4 /)
8682 WRITE(*,*) SIZE(SHAPE(42)) ! (/ /)
8686 @item @emph{See also}:
8687 @ref{RESHAPE}, @ref{SIZE}
8693 @section @code{SIGN} --- Sign copying function
8697 @cindex sign copying
8700 @item @emph{Description}:
8701 @code{SIGN(A,B)} returns the value of @var{A} with the sign of @var{B}.
8703 @item @emph{Standard}:
8709 @item @emph{Syntax}:
8710 @code{RESULT = SIGN(A, B)}
8712 @item @emph{Arguments}:
8713 @multitable @columnfractions .15 .70
8714 @item @var{A} @tab Shall be of type @code{INTEGER} or @code{REAL}
8715 @item @var{B} @tab Shall be of the same type and kind as @var{A}
8718 @item @emph{Return value}:
8719 The kind of the return value is that of @var{A} and @var{B}.
8720 If @math{B\ge 0} then the result is @code{ABS(A)}, else
8721 it is @code{-ABS(A)}.
8723 @item @emph{Example}:
8726 print *, sign(-12,1)
8727 print *, sign(-12,0)
8728 print *, sign(-12,-1)
8730 print *, sign(-12.,1.)
8731 print *, sign(-12.,0.)
8732 print *, sign(-12.,-1.)
8733 end program test_sign
8736 @item @emph{Specific names}:
8737 @multitable @columnfractions .20 .20 .20 .25
8738 @item Name @tab Arguments @tab Return type @tab Standard
8739 @item @code{ISIGN(A,P)} @tab @code{INTEGER(4)} @tab @code{INTEGER(4)} @tab f95, gnu
8740 @item @code{DSIGN(A,P)} @tab @code{REAL(8)} @tab @code{REAL(8)} @tab f95, gnu
8747 @section @code{SIGNAL} --- Signal handling subroutine (or function)
8749 @cindex system, signal handling
8752 @item @emph{Description}:
8753 @code{SIGNAL(NUMBER, HANDLER [, STATUS])} causes external subroutine
8754 @var{HANDLER} to be executed with a single integer argument when signal
8755 @var{NUMBER} occurs. If @var{HANDLER} is an integer, it can be used to
8756 turn off handling of signal @var{NUMBER} or revert to its default
8757 action. See @code{signal(2)}.
8759 If @code{SIGNAL} is called as a subroutine and the @var{STATUS} argument
8760 is supplied, it is set to the value returned by @code{signal(2)}.
8762 @item @emph{Standard}:
8766 Subroutine, non-elemental function
8768 @item @emph{Syntax}:
8769 @multitable @columnfractions .80
8770 @item @code{CALL SIGNAL(NUMBER, HANDLER [, STATUS])}
8771 @item @code{STATUS = SIGNAL(NUMBER, HANDLER)}
8774 @item @emph{Arguments}:
8775 @multitable @columnfractions .15 .70
8776 @item @var{NUMBER} @tab Shall be a scalar integer, with @code{INTENT(IN)}
8777 @item @var{HANDLER}@tab Signal handler (@code{INTEGER FUNCTION} or
8778 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar.
8779 @code{INTEGER}. It is @code{INTENT(IN)}.
8780 @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
8781 integer. It has @code{INTENT(OUT)}.
8784 @item @emph{Return value}:
8785 The @code{SIGNAL} function returns the value returned by @code{signal(2)}.
8787 @item @emph{Example}:
8791 external handler_print
8793 call signal (12, handler_print)
8797 end program test_signal
8804 @section @code{SIN} --- Sine function
8810 @cindex trigonometric function, sine
8814 @item @emph{Description}:
8815 @code{SIN(X)} computes the sine of @var{X}.
8817 @item @emph{Standard}:
8823 @item @emph{Syntax}:
8824 @code{RESULT = SIN(X)}
8826 @item @emph{Arguments}:
8827 @multitable @columnfractions .15 .70
8828 @item @var{X} @tab The type shall be @code{REAL(*)} or
8832 @item @emph{Return value}:
8833 The return value has same type and kind as @var{X}.
8835 @item @emph{Example}:
8840 end program test_sin
8843 @item @emph{Specific names}:
8844 @multitable @columnfractions .20 .20 .20 .25
8845 @item Name @tab Argument @tab Return type @tab Standard
8846 @item @code{DSIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
8847 @item @code{CSIN(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab f95, gnu
8848 @item @code{ZSIN(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
8849 @item @code{CDSIN(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
8852 @item @emph{See also}:
8859 @section @code{SINH} --- Hyperbolic sine function
8862 @cindex hyperbolic sine
8863 @cindex hyperbolic function, sine
8864 @cindex sine, hyperbolic
8867 @item @emph{Description}:
8868 @code{SINH(X)} computes the hyperbolic sine of @var{X}.
8870 @item @emph{Standard}:
8876 @item @emph{Syntax}:
8877 @code{RESULT = SINH(X)}
8879 @item @emph{Arguments}:
8880 @multitable @columnfractions .15 .70
8881 @item @var{X} @tab The type shall be @code{REAL(*)}.
8884 @item @emph{Return value}:
8885 The return value is of type @code{REAL(*)}.
8887 @item @emph{Example}:
8890 real(8) :: x = - 1.0_8
8892 end program test_sinh
8895 @item @emph{Specific names}:
8896 @multitable @columnfractions .20 .20 .20 .25
8897 @item Name @tab Argument @tab Return type @tab Standard
8898 @item @code{DSINH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
8901 @item @emph{See also}:
8908 @section @code{SIZE} --- Determine the size of an array
8911 @cindex array, number of elements
8912 @cindex array, count elements
8915 @item @emph{Description}:
8916 Determine the extent of @var{ARRAY} along a specified dimension @var{DIM},
8917 or the total number of elements in @var{ARRAY} if @var{DIM} is absent.
8919 @item @emph{Standard}:
8925 @item @emph{Syntax}:
8926 @code{RESULT = SIZE(ARRAY[, DIM])}
8928 @item @emph{Arguments}:
8929 @multitable @columnfractions .15 .70
8930 @item @var{ARRAY} @tab Shall be an array of any type. If @var{ARRAY} is
8931 a pointer it must be associated and allocatable arrays must be allocated.
8932 @item @var{DIM} @tab (Optional) shall be a scalar of type @code{INTEGER}
8933 and its value shall be in the range from 1 to n, where n equals the rank
8937 @item @emph{Return value}:
8938 The return value is of type @code{INTEGER} and of the default
8941 @item @emph{Example}:
8944 WRITE(*,*) SIZE((/ 1, 2 /)) ! 2
8948 @item @emph{See also}:
8949 @ref{SHAPE}, @ref{RESHAPE}
8955 @section @code{SLEEP} --- Sleep for the specified number of seconds
8957 @cindex delayed execution
8960 @item @emph{Description}:
8961 Calling this subroutine causes the process to pause for @var{SECONDS} seconds.
8963 @item @emph{Standard}:
8969 @item @emph{Syntax}:
8970 @code{CALL SLEEP(SECONDS)}
8972 @item @emph{Arguments}:
8973 @multitable @columnfractions .15 .70
8974 @item @var{SECONDS} @tab The type shall be of default @code{INTEGER}.
8977 @item @emph{Example}:
8988 @section @code{SNGL} --- Convert double precision real to default real
8990 @cindex conversion, to real
8993 @item @emph{Description}:
8994 @code{SNGL(A)} converts the double precision real @var{A}
8995 to a default real value. This is an archaic form of @code{REAL}
8996 that is specific to one type for @var{A}.
8998 @item @emph{Standard}:
9004 @item @emph{Syntax}:
9005 @code{RESULT = SNGL(A)}
9007 @item @emph{Arguments}:
9008 @multitable @columnfractions .15 .70
9009 @item @var{A} @tab The type shall be a double precision @code{REAL}.
9012 @item @emph{Return value}:
9013 The return value is of type default @code{REAL}.
9015 @item @emph{See also}:
9022 @section @code{SPACING} --- Smallest distance between two numbers of a given type
9024 @cindex real number, relative spacing
9025 @cindex floating point, relative spacing
9028 @item @emph{Description}:
9029 Determines the distance between the argument @var{X} and the nearest
9030 adjacent number of the same type.
9032 @item @emph{Standard}:
9038 @item @emph{Syntax}:
9039 @code{RESULT = SPACING(X)}
9041 @item @emph{Arguments}:
9042 @multitable @columnfractions .15 .70
9043 @item @var{X} @tab Shall be of type @code{REAL(*)}.
9046 @item @emph{Return value}:
9047 The result is of the same type as the input argument @var{X}.
9049 @item @emph{Example}:
9051 PROGRAM test_spacing
9052 INTEGER, PARAMETER :: SGL = SELECTED_REAL_KIND(p=6, r=37)
9053 INTEGER, PARAMETER :: DBL = SELECTED_REAL_KIND(p=13, r=200)
9055 WRITE(*,*) spacing(1.0_SGL) ! "1.1920929E-07" on i686
9056 WRITE(*,*) spacing(1.0_DBL) ! "2.220446049250313E-016" on i686
9060 @item @emph{See also}:
9067 @section @code{SPREAD} --- Add a dimension to an array
9069 @cindex array, increase dimension
9070 @cindex array, duplicate elementes
9071 @cindex array, duplicate dimensions
9074 @item @emph{Description}:
9075 Replicates a @var{SOURCE} array @var{NCOPIES} times along a specified
9076 dimension @var{DIM}.
9078 @item @emph{Standard}:
9082 Transformational function
9084 @item @emph{Syntax}:
9085 @code{RESULT = SPREAD(SOURCE, DIM, NCOPIES)}
9087 @item @emph{Arguments}:
9088 @multitable @columnfractions .15 .70
9089 @item @var{SOURCE} @tab Shall be a scalar or an array of any type and
9090 a rank less than seven.
9091 @item @var{DIM} @tab Shall be a scalar of type @code{INTEGER} with a
9092 value in the range from 1 to n+1, where n equals the rank of @var{SOURCE}.
9093 @item @var{NCOPIES} @tab Shall be a scalar of type @code{INTEGER}.
9096 @item @emph{Return value}:
9097 The result is an array of the same type as @var{SOURCE} and has rank n+1
9098 where n equals the rank of @var{SOURCE}.
9100 @item @emph{Example}:
9103 INTEGER :: a = 1, b(2) = (/ 1, 2 /)
9104 WRITE(*,*) SPREAD(A, 1, 2) ! "1 1"
9105 WRITE(*,*) SPREAD(B, 1, 2) ! "1 1 2 2"
9109 @item @emph{See also}:
9116 @section @code{SQRT} --- Square-root function
9126 @item @emph{Description}:
9127 @code{SQRT(X)} computes the square root of @var{X}.
9129 @item @emph{Standard}:
9135 @item @emph{Syntax}:
9136 @code{RESULT = SQRT(X)}
9138 @item @emph{Arguments}:
9139 @multitable @columnfractions .15 .70
9140 @item @var{X} @tab The type shall be @code{REAL(*)} or
9144 @item @emph{Return value}:
9145 The return value is of type @code{REAL(*)} or @code{COMPLEX(*)}.
9146 The kind type parameter is the same as @var{X}.
9148 @item @emph{Example}:
9151 real(8) :: x = 2.0_8
9152 complex :: z = (1.0, 2.0)
9155 end program test_sqrt
9158 @item @emph{Specific names}:
9159 @multitable @columnfractions .20 .20 .20 .25
9160 @item Name @tab Argument @tab Return type @tab Standard
9161 @item @code{DSQRT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
9162 @item @code{CSQRT(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab F95 and later
9163 @item @code{ZSQRT(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
9164 @item @code{CDSQRT(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
9171 @section @code{SRAND} --- Reinitialize the random number generator
9173 @cindex random number generation, seeding
9174 @cindex seeding a random number generator
9177 @item @emph{Description}:
9178 @code{SRAND} reinitializes the pseudo-random number generator
9179 called by @code{RAND} and @code{IRAND}. The new seed used by the
9180 generator is specified by the required argument @var{SEED}.
9182 @item @emph{Standard}:
9186 Non-elemental subroutine
9188 @item @emph{Syntax}:
9189 @code{CALL SRAND(SEED)}
9191 @item @emph{Arguments}:
9192 @multitable @columnfractions .15 .70
9193 @item @var{SEED} @tab Shall be a scalar @code{INTEGER(kind=4)}.
9196 @item @emph{Return value}:
9199 @item @emph{Example}:
9200 See @code{RAND} and @code{IRAND} for examples.
9203 The Fortran 2003 standard specifies the intrinsic @code{RANDOM_SEED} to
9204 initialize the pseudo-random numbers generator and @code{RANDOM_NUMBER}
9205 to generate pseudo-random numbers. Please note that in
9206 GNU Fortran, these two sets of intrinsics (@code{RAND},
9207 @code{IRAND} and @code{SRAND} on the one hand, @code{RANDOM_NUMBER} and
9208 @code{RANDOM_SEED} on the other hand) access two independent
9209 pseudo-random number generators.
9211 @item @emph{See also}:
9212 @ref{RAND}, @ref{RANDOM_SEED}, @ref{RANDOM_NUMBER}
9219 @section @code{STAT} --- Get file status
9221 @cindex file system, file status
9224 @item @emph{Description}:
9225 This function returns information about a file. No permissions are required on
9226 the file itself, but execute (search) permission is required on all of the
9227 directories in path that lead to the file.
9229 The elements that are obtained and stored in the array @code{BUFF}:
9230 @multitable @columnfractions .15 .70
9231 @item @code{buff(1)} @tab Device ID
9232 @item @code{buff(2)} @tab Inode number
9233 @item @code{buff(3)} @tab File mode
9234 @item @code{buff(4)} @tab Number of links
9235 @item @code{buff(5)} @tab Owner's uid
9236 @item @code{buff(6)} @tab Owner's gid
9237 @item @code{buff(7)} @tab ID of device containing directory entry for file (0 if not available)
9238 @item @code{buff(8)} @tab File size (bytes)
9239 @item @code{buff(9)} @tab Last access time
9240 @item @code{buff(10)} @tab Last modification time
9241 @item @code{buff(11)} @tab Last file status change time
9242 @item @code{buff(12)} @tab Preferred I/O block size (-1 if not available)
9243 @item @code{buff(13)} @tab Number of blocks allocated (-1 if not available)
9246 Not all these elements are relevant on all systems.
9247 If an element is not relevant, it is returned as 0.
9250 @item @emph{Standard}:
9254 Non-elemental subroutine
9256 @item @emph{Syntax}:
9257 @code{CALL STAT(FILE,BUFF[,STATUS])}
9259 @item @emph{Arguments}:
9260 @multitable @columnfractions .15 .70
9261 @item @var{FILE} @tab The type shall be @code{CHARACTER(*)}, a valid path within the file system.
9262 @item @var{BUFF} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
9263 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0
9264 on success and a system specific error code otherwise.
9267 @item @emph{Example}:
9270 INTEGER, DIMENSION(13) :: buff
9273 CALL STAT("/etc/passwd", buff, status)
9275 IF (status == 0) THEN
9276 WRITE (*, FMT="('Device ID:', T30, I19)") buff(1)
9277 WRITE (*, FMT="('Inode number:', T30, I19)") buff(2)
9278 WRITE (*, FMT="('File mode (octal):', T30, O19)") buff(3)
9279 WRITE (*, FMT="('Number of links:', T30, I19)") buff(4)
9280 WRITE (*, FMT="('Owner''s uid:', T30, I19)") buff(5)
9281 WRITE (*, FMT="('Owner''s gid:', T30, I19)") buff(6)
9282 WRITE (*, FMT="('Device where located:', T30, I19)") buff(7)
9283 WRITE (*, FMT="('File size:', T30, I19)") buff(8)
9284 WRITE (*, FMT="('Last access time:', T30, A19)") CTIME(buff(9))
9285 WRITE (*, FMT="('Last modification time', T30, A19)") CTIME(buff(10))
9286 WRITE (*, FMT="('Last status change time:', T30, A19)") CTIME(buff(11))
9287 WRITE (*, FMT="('Preferred block size:', T30, I19)") buff(12)
9288 WRITE (*, FMT="('No. of blocks allocated:', T30, I19)") buff(13)
9293 @item @emph{See also}:
9294 To stat an open file: @ref{FSTAT}, to stat a link: @ref{LSTAT}
9300 @section @code{SUM} --- Sum of array elements
9303 @cindex array, add elements
9304 @cindex array, conditionally add elements
9305 @cindex sum array elements
9308 @item @emph{Description}:
9309 Adds the elements of @var{ARRAY} along dimension @var{DIM} if
9310 the corresponding element in @var{MASK} is @code{TRUE}.
9312 @item @emph{Standard}:
9316 Transformational function
9318 @item @emph{Syntax}:
9319 @code{RESULT = SUM(ARRAY[, MASK])}
9320 @code{RESULT = SUM(ARRAY, DIM[, MASK])}
9322 @item @emph{Arguments}:
9323 @multitable @columnfractions .15 .70
9324 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER(*)},
9325 @code{REAL(*)} or @code{COMPLEX(*)}.
9326 @item @var{DIM} @tab (Optional) shall be a scalar of type
9327 @code{INTEGER} with a value in the range from 1 to n, where n
9328 equals the rank of @var{ARRAY}.
9329 @item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL}
9330 and either be a scalar or an array of the same shape as @var{ARRAY}.
9333 @item @emph{Return value}:
9334 The result is of the same type as @var{ARRAY}.
9336 If @var{DIM} is absent, a scalar with the sum of all elements in @var{ARRAY}
9337 is returned. Otherwise, an array of rank n-1, where n equals the rank of
9338 @var{ARRAY},and a shape similar to that of @var{ARRAY} with dimension @var{DIM}
9339 dropped is returned.
9341 @item @emph{Example}:
9344 INTEGER :: x(5) = (/ 1, 2, 3, 4 ,5 /)
9345 print *, SUM(x) ! all elements, sum = 15
9346 print *, SUM(x, MASK=MOD(x, 2)==1) ! odd elements, sum = 9
9350 @item @emph{See also}:
9357 @section @code{SYMLNK} --- Create a symbolic link
9359 @cindex file system, create link
9360 @cindex file system, soft link
9363 @item @emph{Description}:
9364 Makes a symbolic link from file @var{PATH1} to @var{PATH2}. A null
9365 character (@code{CHAR(0)}) can be used to mark the end of the names in
9366 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
9367 names are ignored. If the @var{STATUS} argument is supplied, it
9368 contains 0 on success or a nonzero error code upon return; see
9369 @code{symlink(2)}. If the system does not supply @code{symlink(2)},
9370 @code{ENOSYS} is returned.
9372 This intrinsic is provided in both subroutine and function forms;
9373 however, only one form can be used in any given program unit.
9375 @item @emph{Standard}:
9379 Subroutine, non-elemental function
9381 @item @emph{Syntax}:
9382 @multitable @columnfractions .80
9383 @item @code{CALL SYMLNK(PATH1, PATH2 [, STATUS])}
9384 @item @code{STATUS = SYMLNK(PATH1, PATH2)}
9387 @item @emph{Arguments}:
9388 @multitable @columnfractions .15 .70
9389 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
9390 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
9391 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
9394 @item @emph{See also}:
9395 @ref{LINK}, @ref{UNLINK}
9402 @section @code{SYSTEM} --- Execute a shell command
9404 @cindex system, system call
9407 @item @emph{Description}:
9408 Passes the command @var{COMMAND} to a shell (see @code{system(3)}). If
9409 argument @var{STATUS} is present, it contains the value returned by
9410 @code{system(3)}, which is presumably 0 if the shell command succeeded.
9411 Note that which shell is used to invoke the command is system-dependent
9412 and environment-dependent.
9414 This intrinsic is provided in both subroutine and function forms;
9415 however, only one form can be used in any given program unit.
9417 @item @emph{Standard}:
9421 Subroutine, non-elemental function
9423 @item @emph{Syntax}:
9424 @multitable @columnfractions .80
9425 @item @code{CALL SYSTEM(COMMAND [, STATUS])}
9426 @item @code{STATUS = SYSTEM(COMMAND)}
9429 @item @emph{Arguments}:
9430 @multitable @columnfractions .15 .70
9431 @item @var{COMMAND} @tab Shall be of default @code{CHARACTER} type.
9432 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
9435 @item @emph{See also}:
9441 @section @code{SYSTEM_CLOCK} --- Time function
9442 @fnindex SYSTEM_CLOCK
9443 @cindex time, clock ticks
9447 @item @emph{Description}:
9448 Determines the @var{COUNT} of milliseconds of wall clock time since
9449 the Epoch (00:00:00 UTC, January 1, 1970) modulo @var{COUNT_MAX},
9450 @var{COUNT_RATE} determines the number of clock ticks per second.
9451 @var{COUNT_RATE} and @var{COUNT_MAX} are constant and specific to
9454 If there is no clock, @var{COUNT} is set to @code{-HUGE(COUNT)}, and
9455 @var{COUNT_RATE} and @var{COUNT_MAX} are set to zero
9457 @item @emph{Standard}:
9463 @item @emph{Syntax}:
9464 @code{CALL SYSTEM_CLOCK([COUNT, COUNT_RATE, COUNT_MAX])}
9466 @item @emph{Arguments}:
9467 @item @emph{Arguments}:
9468 @multitable @columnfractions .15 .70
9469 @item @var{COUNT} @tab (Optional) shall be a scalar of type default
9470 @code{INTEGER} with @code{INTENT(OUT)}.
9471 @item @var{COUNT_RATE} @tab (Optional) shall be a scalar of type default
9472 @code{INTEGER} with @code{INTENT(OUT)}.
9473 @item @var{COUNT_MAX} @tab (Optional) shall be a scalar of type default
9474 @code{INTEGER} with @code{INTENT(OUT)}.
9477 @item @emph{Example}:
9479 PROGRAM test_system_clock
9480 INTEGER :: count, count_rate, count_max
9481 CALL SYSTEM_CLOCK(count, count_rate, count_max)
9482 WRITE(*,*) count, count_rate, count_max
9486 @item @emph{See also}:
9487 @ref{DATE_AND_TIME}, @ref{CPU_TIME}
9493 @section @code{TAN} --- Tangent function
9496 @cindex trigonometric function, tangent
9500 @item @emph{Description}:
9501 @code{TAN(X)} computes the tangent of @var{X}.
9503 @item @emph{Standard}:
9509 @item @emph{Syntax}:
9510 @code{RESULT = TAN(X)}
9512 @item @emph{Arguments}:
9513 @multitable @columnfractions .15 .70
9514 @item @var{X} @tab The type shall be @code{REAL(*)}.
9517 @item @emph{Return value}:
9518 The return value is of type @code{REAL(*)}. The kind type parameter is
9519 the same as @var{X}.
9521 @item @emph{Example}:
9524 real(8) :: x = 0.165_8
9526 end program test_tan
9529 @item @emph{Specific names}:
9530 @multitable @columnfractions .20 .20 .20 .25
9531 @item Name @tab Argument @tab Return type @tab Standard
9532 @item @code{DTAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
9535 @item @emph{See also}:
9542 @section @code{TANH} --- Hyperbolic tangent function
9545 @cindex hyperbolic tangent
9546 @cindex hyperbolic function, tangent
9547 @cindex tangent, hyperbolic
9550 @item @emph{Description}:
9551 @code{TANH(X)} computes the hyperbolic tangent of @var{X}.
9553 @item @emph{Standard}:
9559 @item @emph{Syntax}:
9562 @item @emph{Arguments}:
9563 @multitable @columnfractions .15 .70
9564 @item @var{X} @tab The type shall be @code{REAL(*)}.
9567 @item @emph{Return value}:
9568 The return value is of type @code{REAL(*)} and lies in the range
9569 @math{ - 1 \leq tanh(x) \leq 1 }.
9571 @item @emph{Example}:
9574 real(8) :: x = 2.1_8
9576 end program test_tanh
9579 @item @emph{Specific names}:
9580 @multitable @columnfractions .20 .20 .20 .25
9581 @item Name @tab Argument @tab Return type @tab Standard
9582 @item @code{DTANH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
9585 @item @emph{See also}:
9592 @section @code{TIME} --- Time function
9594 @cindex time, current
9595 @cindex current time
9598 @item @emph{Description}:
9599 Returns the current time encoded as an integer (in the manner of the
9600 UNIX function @code{time(3)}). This value is suitable for passing to
9601 @code{CTIME()}, @code{GMTIME()}, and @code{LTIME()}.
9603 This intrinsic is not fully portable, such as to systems with 32-bit
9604 @code{INTEGER} types but supporting times wider than 32 bits. Therefore,
9605 the values returned by this intrinsic might be, or become, negative, or
9606 numerically less than previous values, during a single run of the
9609 See @ref{TIME8}, for information on a similar intrinsic that might be
9610 portable to more GNU Fortran implementations, though to fewer Fortran
9613 @item @emph{Standard}:
9617 Non-elemental function
9619 @item @emph{Syntax}:
9620 @code{RESULT = TIME()}
9622 @item @emph{Return value}:
9623 The return value is a scalar of type @code{INTEGER(4)}.
9625 @item @emph{See also}:
9626 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME8}
9633 @section @code{TIME8} --- Time function (64-bit)
9635 @cindex time, current
9636 @cindex current time
9639 @item @emph{Description}:
9640 Returns the current time encoded as an integer (in the manner of the
9641 UNIX function @code{time(3)}). This value is suitable for passing to
9642 @code{CTIME()}, @code{GMTIME()}, and @code{LTIME()}.
9644 @emph{Warning:} this intrinsic does not increase the range of the timing
9645 values over that returned by @code{time(3)}. On a system with a 32-bit
9646 @code{time(3)}, @code{TIME8()} will return a 32-bit value, even though
9647 it is converted to a 64-bit @code{INTEGER(8)} value. That means
9648 overflows of the 32-bit value can still occur. Therefore, the values
9649 returned by this intrinsic might be or become negative or numerically
9650 less than previous values during a single run of the compiled program.
9652 @item @emph{Standard}:
9656 Non-elemental function
9658 @item @emph{Syntax}:
9659 @code{RESULT = TIME8()}
9661 @item @emph{Return value}:
9662 The return value is a scalar of type @code{INTEGER(8)}.
9664 @item @emph{See also}:
9665 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK8}, @ref{TIME}
9672 @section @code{TINY} --- Smallest positive number of a real kind
9674 @cindex limits, smallest number
9675 @cindex model representation, smallest number
9678 @item @emph{Description}:
9679 @code{TINY(X)} returns the smallest positive (non zero) number
9680 in the model of the type of @code{X}.
9682 @item @emph{Standard}:
9688 @item @emph{Syntax}:
9689 @code{RESULT = TINY(X)}
9691 @item @emph{Arguments}:
9692 @multitable @columnfractions .15 .70
9693 @item @var{X} @tab Shall be of type @code{REAL}.
9696 @item @emph{Return value}:
9697 The return value is of the same type and kind as @var{X}
9699 @item @emph{Example}:
9700 See @code{HUGE} for an example.
9706 @section @code{TRANSFER} --- Transfer bit patterns
9712 @item @emph{Description}:
9713 Interprets the bitwise representation of @var{SOURCE} in memory as if it
9714 is the representation of a variable or array of the same type and type
9715 parameters as @var{MOLD}.
9717 This is approximately equivalent to the C concept of @emph{casting} one
9720 @item @emph{Standard}:
9724 Transformational function
9726 @item @emph{Syntax}:
9727 @code{RESULT = TRANSFER(SOURCE, MOLD[, SIZE])}
9729 @item @emph{Arguments}:
9730 @multitable @columnfractions .15 .70
9731 @item @var{SOURCE} @tab Shall be a scalar or an array of any type.
9732 @item @var{MOLD} @tab Shall be a scalar or an array of any type.
9733 @item @var{SIZE} @tab (Optional) shall be a scalar of type
9737 @item @emph{Return value}:
9738 The result has the same type as @var{MOLD}, with the bit level
9739 representation of @var{SOURCE}. If @var{SIZE} is present, the result is
9740 a one-dimensional array of length @var{SIZE}. If @var{SIZE} is absent
9741 but @var{MOLD} is an array (of any size or shape), the result is a one-
9742 dimensional array of the minimum length needed to contain the entirety
9743 of the bitwise representation of @var{SOURCE}. If @var{SIZE} is absent
9744 and @var{MOLD} is a scalar, the result is a scalar.
9746 If the bitwise representation of the result is longer than that of
9747 @var{SOURCE}, then the leading bits of the result correspond to those of
9748 @var{SOURCE} and any trailing bits are filled arbitrarily.
9750 When the resulting bit representation does not correspond to a valid
9751 representation of a variable of the same type as @var{MOLD}, the results
9752 are undefined, and subsequent operations on the result cannot be
9753 guaranteed to produce sensible behavior. For example, it is possible to
9754 create @code{LOGICAL} variables for which @code{@var{VAR}} and
9755 @code{.NOT.@var{VAR}} both appear to be true.
9757 @item @emph{Example}:
9759 PROGRAM test_transfer
9760 integer :: x = 2143289344
9761 print *, transfer(x, 1.0) ! prints "NaN" on i686
9769 @section @code{TRANSPOSE} --- Transpose an array of rank two
9771 @cindex array, transpose
9772 @cindex matrix, transpose
9776 @item @emph{Description}:
9777 Transpose an array of rank two. Element (i, j) of the result has the value
9778 @code{MATRIX(j, i)}, for all i, j.
9780 @item @emph{Standard}:
9784 Transformational function
9786 @item @emph{Syntax}:
9787 @code{RESULT = TRANSPOSE(MATRIX)}
9789 @item @emph{Arguments}:
9790 @multitable @columnfractions .15 .70
9791 @item @var{MATRIX} @tab Shall be an array of any type and have a rank of two.
9794 @item @emph{Return value}:
9795 The result has the the same type as @var{MATRIX}, and has shape
9796 @code{(/ m, n /)} if @var{MATRIX} has shape @code{(/ n, m /)}.
9802 @section @code{TRIM} --- Remove trailing blank characters of a string
9804 @cindex string, remove trailing whitespace
9807 @item @emph{Description}:
9808 Removes trailing blank characters of a string.
9810 @item @emph{Standard}:
9814 Transformational function
9816 @item @emph{Syntax}:
9817 @code{RESULT = TRIM(STRING)}
9819 @item @emph{Arguments}:
9820 @multitable @columnfractions .15 .70
9821 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER(*)}.
9824 @item @emph{Return value}:
9825 A scalar of type @code{CHARACTER(*)} which length is that of @var{STRING}
9826 less the number of trailing blanks.
9828 @item @emph{Example}:
9831 CHARACTER(len=10), PARAMETER :: s = "GFORTRAN "
9832 WRITE(*,*) LEN(s), LEN(TRIM(s)) ! "10 8", with/without trailing blanks
9836 @item @emph{See also}:
9837 @ref{ADJUSTL}, @ref{ADJUSTR}
9843 @section @code{TTYNAM} --- Get the name of a terminal device.
9845 @cindex system, terminal
9848 @item @emph{Description}:
9849 Get the name of a terminal device. For more information,
9850 see @code{ttyname(3)}.
9852 This intrinsic is provided in both subroutine and function forms;
9853 however, only one form can be used in any given program unit.
9855 @item @emph{Standard}:
9859 Subroutine, non-elemental function
9861 @item @emph{Syntax}:
9862 @multitable @columnfractions .80
9863 @item @code{CALL TTYNAM(UNIT, NAME)}
9864 @item @code{NAME = TTYNAM(UNIT)}
9867 @item @emph{Arguments}:
9868 @multitable @columnfractions .15 .70
9869 @item @var{UNIT} @tab Shall be a scalar @code{INTEGER(*)}.
9870 @item @var{NAME} @tab Shall be of type @code{CHARACTER(*)}.
9873 @item @emph{Example}:
9878 IF (isatty(unit=unit)) write(*,*) ttynam(unit)
9883 @item @emph{See also}:
9890 @section @code{UBOUND} --- Upper dimension bounds of an array
9892 @cindex array, upper bound
9895 @item @emph{Description}:
9896 Returns the upper bounds of an array, or a single upper bound
9897 along the @var{DIM} dimension.
9898 @item @emph{Standard}:
9904 @item @emph{Syntax}:
9905 @code{RESULT = UBOUND(ARRAY [, DIM])}
9907 @item @emph{Arguments}:
9908 @multitable @columnfractions .15 .70
9909 @item @var{ARRAY} @tab Shall be an array, of any type.
9910 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER(*)}.
9913 @item @emph{Return value}:
9914 If @var{DIM} is absent, the result is an array of the upper bounds of
9915 @var{ARRAY}. If @var{DIM} is present, the result is a scalar
9916 corresponding to the upper bound of the array along that dimension. If
9917 @var{ARRAY} is an expression rather than a whole array or array
9918 structure component, or if it has a zero extent along the relevant
9919 dimension, the upper bound is taken to be the number of elements along
9920 the relevant dimension.
9922 @item @emph{See also}:
9929 @section @code{UMASK} --- Set the file creation mask
9931 @cindex file system, file creation mask
9934 @item @emph{Description}:
9935 Sets the file creation mask to @var{MASK} and returns the old value in
9936 argument @var{OLD} if it is supplied. See @code{umask(2)}.
9938 @item @emph{Standard}:
9944 @item @emph{Syntax}:
9945 @code{CALL UMASK(MASK [, OLD])}
9947 @item @emph{Arguments}:
9948 @multitable @columnfractions .15 .70
9949 @item @var{MASK} @tab Shall be a scalar of type @code{INTEGER(*)}.
9950 @item @var{MASK} @tab (Optional) Shall be a scalar of type
9959 @section @code{UNLINK} --- Remove a file from the file system
9961 @cindex file system, remove file
9964 @item @emph{Description}:
9965 Unlinks the file @var{PATH}. A null character (@code{CHAR(0)}) can be
9966 used to mark the end of the name in @var{PATH}; otherwise, trailing
9967 blanks in the file name are ignored. If the @var{STATUS} argument is
9968 supplied, it contains 0 on success or a nonzero error code upon return;
9969 see @code{unlink(2)}.
9971 This intrinsic is provided in both subroutine and function forms;
9972 however, only one form can be used in any given program unit.
9974 @item @emph{Standard}:
9978 Subroutine, non-elemental function
9980 @item @emph{Syntax}:
9981 @multitable @columnfractions .80
9982 @item @code{CALL UNLINK(PATH [, STATUS])}
9983 @item @code{STATUS = UNLINK(PATH)}
9986 @item @emph{Arguments}:
9987 @multitable @columnfractions .15 .70
9988 @item @var{PATH} @tab Shall be of default @code{CHARACTER} type.
9989 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
9992 @item @emph{See also}:
9993 @ref{LINK}, @ref{SYMLNK}
9999 @section @code{UNPACK} --- Unpack an array of rank one into an array
10001 @cindex array, unpacking
10002 @cindex array, increase dimension
10003 @cindex array, scatter elements
10006 @item @emph{Description}:
10007 Store the elements of @var{VECTOR} in an array of higher rank.
10009 @item @emph{Standard}:
10012 @item @emph{Class}:
10013 Transformational function
10015 @item @emph{Syntax}:
10016 @code{RESULT = UNPACK(VECTOR, MASK, FIELD)}
10018 @item @emph{Arguments}:
10019 @multitable @columnfractions .15 .70
10020 @item @var{VECTOR} @tab Shall be an array of any type and rank one. It
10021 shall have at least as many elements as @var{MASK} has @code{TRUE} values.
10022 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL}.
10023 @item @var{FIELD} @tab Shall be of the sam type as @var{VECTOR} and have
10024 the same shape as @var{MASK}.
10027 @item @emph{Return value}:
10028 The resulting array corresponds to @var{FIELD} with @code{TRUE} elements
10029 of @var{MASK} replaced by values from @var{VECTOR} in array element order.
10031 @item @emph{Example}:
10033 PROGRAM test_unpack
10034 integer :: vector(2) = (/1,1/)
10035 logical :: mask(4) = (/ .TRUE., .FALSE., .FALSE., .TRUE. /)
10036 integer :: field(2,2) = 0, unity(2,2)
10038 ! result: unity matrix
10039 unity = unpack(vector, reshape(mask, (/2,2/)), field)
10043 @item @emph{See also}:
10044 @ref{PACK}, @ref{SPREAD}
10050 @section @code{VERIFY} --- Scan a string for the absence of a set of characters
10052 @cindex string, find missing set
10055 @item @emph{Description}:
10056 Verifies that all the characters in a @var{SET} are present in a @var{STRING}.
10058 If @var{BACK} is either absent or equals @code{FALSE}, this function
10059 returns the position of the leftmost character of @var{STRING} that is
10060 not in @var{SET}. If @var{BACK} equals @code{TRUE}, the rightmost position
10061 is returned. If all characters of @var{SET} are found in @var{STRING}, the
10064 @item @emph{Standard}:
10067 @item @emph{Class}:
10070 @item @emph{Syntax}:
10071 @code{RESULT = VERFIY(STRING, SET[, BACK])}
10073 @item @emph{Arguments}:
10074 @multitable @columnfractions .15 .70
10075 @item @var{STRING} @tab Shall be of type @code{CHARACTER(*)}.
10076 @item @var{SET} @tab Shall be of type @code{CHARACTER(*)}.
10077 @item @var{BACK} @tab (Optional) shall be of type @code{LOGICAL}.
10080 @item @emph{Return value}:
10081 The return value is of type @code{INTEGER} and of the default
10084 @item @emph{Example}:
10086 PROGRAM test_verify
10087 WRITE(*,*) VERIFY("FORTRAN", "AO") ! 1, found 'F'
10088 WRITE(*,*) VERIFY("FORTRAN", "FOO") ! 3, found 'R'
10089 WRITE(*,*) VERIFY("FORTRAN", "C++") ! 1, found 'F'
10090 WRITE(*,*) VERIFY("FORTRAN", "C++", .TRUE.) ! 7, found 'N'
10091 WRITE(*,*) VERIFY("FORTRAN", "FORTRAN") ! 0' found none
10095 @item @emph{See also}:
10096 @ref{SCAN}, @ref{INDEX}
10102 @section @code{XOR} --- Bitwise logical exclusive OR
10104 @cindex bitwise logical exclusive or
10105 @cindex logical exclusive or, bitwise
10108 @item @emph{Description}:
10109 Bitwise logical exclusive or.
10111 This intrinsic routine is provided for backwards compatibility with
10112 GNU Fortran 77. For integer arguments, programmers should consider
10113 the use of the @ref{IEOR} intrinsic defined by the Fortran standard.
10115 @item @emph{Standard}:
10118 @item @emph{Class}:
10119 Non-elemental function
10121 @item @emph{Syntax}:
10122 @code{RESULT = XOR(X, Y)}
10124 @item @emph{Arguments}:
10125 @multitable @columnfractions .15 .70
10126 @item @var{X} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
10127 @item @var{Y} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
10130 @item @emph{Return value}:
10131 The return type is either @code{INTEGER(*)} or @code{LOGICAL}
10132 after cross-promotion of the arguments.
10134 @item @emph{Example}:
10137 LOGICAL :: T = .TRUE., F = .FALSE.
10139 DATA a / Z'F' /, b / Z'3' /
10141 WRITE (*,*) XOR(T, T), XOR(T, F), XOR(F, T), XOR(F, F)
10142 WRITE (*,*) XOR(a, b)
10146 @item @emph{See also}:
10147 F95 elemental function: @ref{IEOR}