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
3969 Not yet implemented in GNU Fortran.
3972 @item @emph{Description}:
3974 @item @emph{Standard}:
3980 @item @emph{Syntax}:
3981 @item @emph{Arguments}:
3982 @item @emph{Return value}:
3983 @item @emph{Example}:
3984 @item @emph{Specific names}:
3985 @item @emph{See also}:
3986 @uref{http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19292, g77 features lacking in gfortran}
3993 @section @code{FSTAT} --- Get file status
3995 @cindex file system, file status
3998 @item @emph{Description}:
3999 @code{FSTAT} is identical to @ref{STAT}, except that information about an
4000 already opened file is obtained.
4002 The elements in @code{BUFF} are the same as described by @ref{STAT}.
4004 @item @emph{Standard}:
4008 Non-elemental subroutine
4010 @item @emph{Syntax}:
4011 @code{CALL FSTAT(UNIT, BUFF [, STATUS])}
4013 @item @emph{Arguments}:
4014 @multitable @columnfractions .15 .70
4015 @item @var{UNIT} @tab An open I/O unit number of type @code{INTEGER}.
4016 @item @var{BUFF} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
4017 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0
4018 on success and a system specific error code otherwise.
4021 @item @emph{Example}:
4022 See @ref{STAT} for an example.
4024 @item @emph{See also}:
4025 To stat a link: @ref{LSTAT}, to stat a file: @ref{STAT}
4031 @section @code{FTELL} --- Current stream position
4033 @cindex file operation, position
4036 @item @emph{Description}:
4037 Retrieves the current position within an open file.
4039 This intrinsic is provided in both subroutine and function forms; however,
4040 only one form can be used in any given program unit.
4042 @item @emph{Standard}:
4046 Subroutine, function
4048 @item @emph{Syntax}:
4049 @multitable @columnfractions .80
4050 @item @code{CALL FTELL(UNIT, OFFSET)}
4051 @item @code{OFFSET = FTELL(UNIT)}
4054 @item @emph{Arguments}:
4055 @multitable @columnfractions .15 .70
4056 @item @var{OFFSET} @tab Shall of type @code{INTEGER}.
4057 @item @var{UNIT} @tab Shall of type @code{INTEGER}.
4060 @item @emph{Return value}:
4061 In either syntax, @var{OFFSET} is set to the current offset of unit
4062 number @var{UNIT}, or to @math{-1} if the unit is not currently open.
4064 @item @emph{Example}:
4068 OPEN(10, FILE="temp.dat")
4074 @item @emph{See also}:
4081 @section @code{GERROR} --- Get last system error message
4083 @cindex system, error handling
4086 @item @emph{Description}:
4087 Returns the system error message corresponding to the last system error.
4088 This resembles the functionality of @code{strerror(3)} in C.
4090 @item @emph{Standard}:
4096 @item @emph{Syntax}:
4097 @code{CALL GERROR(RESULT)}
4099 @item @emph{Arguments}:
4100 @multitable @columnfractions .15 .70
4101 @item @var{RESULT} @tab Shall of type @code{CHARACTER(*)}.
4104 @item @emph{Example}:
4107 CHARACTER(len=100) :: msg
4113 @item @emph{See also}:
4114 @ref{IERRNO}, @ref{PERROR}
4120 @section @code{GETARG} --- Get command line arguments
4122 @cindex command-line arguments
4123 @cindex arguments, to program
4126 @item @emph{Description}:
4127 Retrieve the @var{N}th argument that was passed on the
4128 command line when the containing program was invoked.
4130 This intrinsic routine is provided for backwards compatibility with
4131 GNU Fortran 77. In new code, programmers should consider the use of
4132 the @ref{GET_COMMAND_ARGUMENT} intrinsic defined by the Fortran 2003
4135 @item @emph{Standard}:
4141 @item @emph{Syntax}:
4142 @code{CALL GETARG(N, ARG)}
4144 @item @emph{Arguments}:
4145 @multitable @columnfractions .15 .70
4146 @item @var{N} @tab Shall be of type @code{INTEGER(4)}, @math{@var{N} \geq 0}
4147 @item @var{ARG} @tab Shall be of type @code{CHARACTER(*)}.
4150 @item @emph{Return value}:
4151 After @code{GETARG} returns, the @var{ARG} argument holds the @var{N}th
4152 command line argument. If @var{ARG} can not hold the argument, it is
4153 truncated to fit the length of @var{ARG}. If there are less than @var{N}
4154 arguments specified at the command line, @var{ARG} will be filled with blanks.
4155 If @math{@var{N} = 0}, @var{ARG} is set to the name of the program (on systems
4156 that support this feature).
4158 @item @emph{Example}:
4162 CHARACTER(len=32) :: arg
4171 @item @emph{See also}:
4172 GNU Fortran 77 compatibility function: @ref{IARGC}
4174 F2003 functions and subroutines: @ref{GET_COMMAND}, @ref{GET_COMMAND_ARGUMENT},
4175 @ref{COMMAND_ARGUMENT_COUNT}
4181 @section @code{GET_COMMAND} --- Get the entire command line
4182 @fnindex GET_COMMAND
4183 @cindex command-line arguments
4184 @cindex arguments, to program
4187 @item @emph{Description}:
4188 Retrieve the entire command line that was used to invoke the program.
4190 @item @emph{Standard}:
4196 @item @emph{Syntax}:
4197 @code{CALL GET_COMMAND(CMD)}
4199 @item @emph{Arguments}:
4200 @multitable @columnfractions .15 .70
4201 @item @var{CMD} @tab Shall be of type @code{CHARACTER(*)}.
4204 @item @emph{Return value}:
4205 Stores the entire command line that was used to invoke the program in @var{ARG}.
4206 If @var{ARG} is not large enough, the command will be truncated.
4208 @item @emph{Example}:
4210 PROGRAM test_get_command
4211 CHARACTER(len=255) :: cmd
4212 CALL get_command(cmd)
4213 WRITE (*,*) TRIM(cmd)
4217 @item @emph{See also}:
4218 @ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
4223 @node GET_COMMAND_ARGUMENT
4224 @section @code{GET_COMMAND_ARGUMENT} --- Get command line arguments
4225 @fnindex GET_COMMAND_ARGUMENT
4226 @cindex command-line arguments
4227 @cindex arguments, to program
4230 @item @emph{Description}:
4231 Retrieve the @var{N}th argument that was passed on the
4232 command line when the containing program was invoked.
4234 @item @emph{Standard}:
4240 @item @emph{Syntax}:
4241 @code{CALL GET_COMMAND_ARGUMENT(N, ARG)}
4243 @item @emph{Arguments}:
4244 @multitable @columnfractions .15 .70
4245 @item @var{N} @tab Shall be of type @code{INTEGER(4)}, @math{@var{N} \geq 0}
4246 @item @var{ARG} @tab Shall be of type @code{CHARACTER(*)}.
4249 @item @emph{Return value}:
4250 After @code{GET_COMMAND_ARGUMENT} returns, the @var{ARG} argument holds the
4251 @var{N}th command line argument. If @var{ARG} can not hold the argument, it is
4252 truncated to fit the length of @var{ARG}. If there are less than @var{N}
4253 arguments specified at the command line, @var{ARG} will be filled with blanks.
4254 If @math{@var{N} = 0}, @var{ARG} is set to the name of the program (on systems
4255 that support this feature).
4257 @item @emph{Example}:
4259 PROGRAM test_get_command_argument
4261 CHARACTER(len=32) :: arg
4265 CALL get_command_argument(i, arg)
4266 IF (LEN_TRIM(arg) == 0) EXIT
4268 WRITE (*,*) TRIM(arg)
4274 @item @emph{See also}:
4275 @ref{GET_COMMAND}, @ref{COMMAND_ARGUMENT_COUNT}
4281 @section @code{GETCWD} --- Get current working directory
4283 @cindex system, working directory
4286 @item @emph{Description}:
4287 Get current working directory.
4289 @item @emph{Standard}:
4293 Non-elemental subroutine.
4295 @item @emph{Syntax}:
4296 @code{CALL GETCWD(CWD [, STATUS])}
4298 @item @emph{Arguments}:
4299 @multitable @columnfractions .15 .70
4300 @item @var{CWD} @tab The type shall be @code{CHARACTER(*)}.
4301 @item @var{STATUS} @tab (Optional) status flag. Returns 0 on success,
4302 a system specific and non-zero error code otherwise.
4305 @item @emph{Example}:
4308 CHARACTER(len=255) :: cwd
4310 WRITE(*,*) TRIM(cwd)
4314 @item @emph{See also}:
4321 @section @code{GETENV} --- Get an environmental variable
4323 @cindex environment variable
4326 @item @emph{Description}:
4327 Get the @var{VALUE} of the environmental variable @var{ENVVAR}.
4329 This intrinsic routine is provided for backwards compatibility with
4330 GNU Fortran 77. In new code, programmers should consider the use of
4331 the @ref{GET_ENVIRONMENT_VARIABLE} intrinsic defined by the Fortran
4334 @item @emph{Standard}:
4340 @item @emph{Syntax}:
4341 @code{CALL GETENV(ENVVAR, VALUE)}
4343 @item @emph{Arguments}:
4344 @multitable @columnfractions .15 .70
4345 @item @var{ENVVAR} @tab Shall be of type @code{CHARACTER(*)}.
4346 @item @var{VALUE} @tab Shall be of type @code{CHARACTER(*)}.
4349 @item @emph{Return value}:
4350 Stores the value of @var{ENVVAR} in @var{VALUE}. If @var{VALUE} is
4351 not large enough to hold the data, it is truncated. If @var{ENVVAR}
4352 is not set, @var{VALUE} will be filled with blanks.
4354 @item @emph{Example}:
4357 CHARACTER(len=255) :: homedir
4358 CALL getenv("HOME", homedir)
4359 WRITE (*,*) TRIM(homedir)
4363 @item @emph{See also}:
4364 @ref{GET_ENVIRONMENT_VARIABLE}
4369 @node GET_ENVIRONMENT_VARIABLE
4370 @section @code{GET_ENVIRONMENT_VARIABLE} --- Get an environmental variable
4371 @fnindex GET_ENVIRONMENT_VARIABLE
4372 @cindex environment variable
4375 @item @emph{Description}:
4376 Get the @var{VALUE} of the environmental variable @var{ENVVAR}.
4378 @item @emph{Standard}:
4384 @item @emph{Syntax}:
4385 @code{CALL GET_ENVIRONMENT_VARIABLE(ENVVAR, VALUE)}
4387 @item @emph{Arguments}:
4388 @multitable @columnfractions .15 .70
4389 @item @var{ENVVAR} @tab Shall be of type @code{CHARACTER(*)}.
4390 @item @var{VALUE} @tab Shall be of type @code{CHARACTER(*)}.
4393 @item @emph{Return value}:
4394 Stores the value of @var{ENVVAR} in @var{VALUE}. If @var{VALUE} is
4395 not large enough to hold the data, it is truncated. If @var{ENVVAR}
4396 is not set, @var{VALUE} will be filled with blanks.
4398 @item @emph{Example}:
4401 CHARACTER(len=255) :: homedir
4402 CALL get_environment_variable("HOME", homedir)
4403 WRITE (*,*) TRIM(homedir)
4411 @section @code{GETGID} --- Group ID function
4413 @cindex system, group id
4416 @item @emph{Description}:
4417 Returns the numerical group ID of the current process.
4419 @item @emph{Standard}:
4425 @item @emph{Syntax}:
4426 @code{RESULT = GETGID()}
4428 @item @emph{Return value}:
4429 The return value of @code{GETGID} is an @code{INTEGER} of the default
4433 @item @emph{Example}:
4434 See @code{GETPID} for an example.
4436 @item @emph{See also}:
4437 @ref{GETPID}, @ref{GETUID}
4443 @section @code{GETLOG} --- Get login name
4445 @cindex system, login name
4449 @item @emph{Description}:
4450 Gets the username under which the program is running.
4452 @item @emph{Standard}:
4458 @item @emph{Syntax}:
4459 @code{CALL GETLOG(LOGIN)}
4461 @item @emph{Arguments}:
4462 @multitable @columnfractions .15 .70
4463 @item @var{LOGIN} @tab Shall be of type @code{CHARACTER(*)}.
4466 @item @emph{Return value}:
4467 Stores the current user name in @var{LOGIN}. (On systems where POSIX
4468 functions @code{geteuid} and @code{getpwuid} are not available, and
4469 the @code{getlogin} function is not implemented either, this will
4470 return a blank string.)
4472 @item @emph{Example}:
4475 CHARACTER(32) :: login
4481 @item @emph{See also}:
4488 @section @code{GETPID} --- Process ID function
4490 @cindex system, process id
4494 @item @emph{Description}:
4495 Returns the numerical process identifier of the current process.
4497 @item @emph{Standard}:
4503 @item @emph{Syntax}:
4504 @code{RESULT = GETPID()}
4506 @item @emph{Return value}:
4507 The return value of @code{GETPID} is an @code{INTEGER} of the default
4511 @item @emph{Example}:
4514 print *, "The current process ID is ", getpid()
4515 print *, "Your numerical user ID is ", getuid()
4516 print *, "Your numerical group ID is ", getgid()
4520 @item @emph{See also}:
4521 @ref{GETGID}, @ref{GETUID}
4527 @section @code{GETUID} --- User ID function
4529 @cindex system, user id
4533 @item @emph{Description}:
4534 Returns the numerical user ID of the current process.
4536 @item @emph{Standard}:
4542 @item @emph{Syntax}:
4543 @code{RESULT = GETUID()}
4545 @item @emph{Return value}:
4546 The return value of @code{GETUID} is an @code{INTEGER} of the default
4550 @item @emph{Example}:
4551 See @code{GETPID} for an example.
4553 @item @emph{See also}:
4554 @ref{GETPID}, @ref{GETLOG}
4560 @section @code{GMTIME} --- Convert time to GMT info
4562 @cindex time, conversion to GMT info
4565 @item @emph{Description}:
4566 Given a system time value @var{STIME} (as provided by the @code{TIME8()}
4567 intrinsic), fills @var{TARRAY} with values extracted from it appropriate
4568 to the UTC time zone (Universal Coordinated Time, also known in some
4569 countries as GMT, Greenwich Mean Time), using @code{gmtime(3)}.
4571 @item @emph{Standard}:
4577 @item @emph{Syntax}:
4578 @code{CALL GMTIME(STIME, TARRAY)}
4580 @item @emph{Arguments}:
4581 @multitable @columnfractions .15 .70
4582 @item @var{STIME} @tab An @code{INTEGER(*)} scalar expression
4583 corresponding to a system time, with
4585 @item @var{TARRAY} @tab A default @code{INTEGER} array with 9 elements,
4586 with @code{INTENT(OUT)}.
4589 @item @emph{Return value}:
4590 The elements of @var{TARRAY} are assigned as follows:
4592 @item Seconds after the minute, range 0--59 or 0--61 to allow for leap
4594 @item Minutes after the hour, range 0--59
4595 @item Hours past midnight, range 0--23
4596 @item Day of month, range 0--31
4597 @item Number of months since January, range 0--12
4598 @item Years since 1900
4599 @item Number of days since Sunday, range 0--6
4600 @item Days since January 1
4601 @item Daylight savings indicator: positive if daylight savings is in
4602 effect, zero if not, and negative if the information is not
4606 @item @emph{See also}:
4607 @ref{CTIME}, @ref{LTIME}, @ref{TIME}, @ref{TIME8}
4614 @section @code{HOSTNM} --- Get system host name
4616 @cindex system, host name
4619 @item @emph{Description}:
4620 Retrieves the host name of the system on which the program is running.
4622 This intrinsic is provided in both subroutine and function forms; however,
4623 only one form can be used in any given program unit.
4625 @item @emph{Standard}:
4629 Subroutine, function
4631 @item @emph{Syntax}:
4632 @multitable @columnfractions .80
4633 @item @code{CALL HOSTNM(NAME[, STATUS])}
4634 @item @code{STATUS = HOSTNM(NAME)}
4637 @item @emph{Arguments}:
4638 @multitable @columnfractions .15 .70
4639 @item @var{NAME} @tab Shall of type @code{CHARACTER(*)}.
4640 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
4641 Returns 0 on success, or a system specific error
4645 @item @emph{Return value}:
4646 In either syntax, @var{NAME} is set to the current hostname if it can
4647 be obtained, or to a blank string otherwise.
4654 @section @code{HUGE} --- Largest number of a kind
4656 @cindex limits, largest number
4657 @cindex model representation, largest number
4660 @item @emph{Description}:
4661 @code{HUGE(X)} returns the largest number that is not an infinity in
4662 the model of the type of @code{X}.
4664 @item @emph{Standard}:
4670 @item @emph{Syntax}:
4671 @code{RESULT = HUGE(X)}
4673 @item @emph{Arguments}:
4674 @multitable @columnfractions .15 .70
4675 @item @var{X} @tab Shall be of type @code{REAL} or @code{INTEGER}.
4678 @item @emph{Return value}:
4679 The return value is of the same type and kind as @var{X}
4681 @item @emph{Example}:
4683 program test_huge_tiny
4684 print *, huge(0), huge(0.0), huge(0.0d0)
4685 print *, tiny(0.0), tiny(0.0d0)
4686 end program test_huge_tiny
4693 @section @code{IACHAR} --- Code in @acronym{ASCII} collating sequence
4695 @cindex @acronym{ASCII} collating sequence
4696 @cindex collating sequence, @acronym{ASCII}
4697 @cindex conversion, to integer
4700 @item @emph{Description}:
4701 @code{IACHAR(C)} returns the code for the @acronym{ASCII} character
4702 in the first character position of @code{C}.
4704 @item @emph{Standard}:
4710 @item @emph{Syntax}:
4711 @code{RESULT = IACHAR(C)}
4713 @item @emph{Arguments}:
4714 @multitable @columnfractions .15 .70
4715 @item @var{C} @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
4718 @item @emph{Return value}:
4719 The return value is of type @code{INTEGER} and of the default integer
4722 @item @emph{Example}:
4727 end program test_iachar
4731 See @ref{ICHAR} for a discussion of converting between numerical values
4732 and formatted string representations.
4734 @item @emph{See also}:
4735 @ref{ACHAR}, @ref{CHAR}, @ref{ICHAR}
4742 @section @code{IAND} --- Bitwise logical and
4744 @cindex bitwise logical and
4745 @cindex logical and, bitwise
4748 @item @emph{Description}:
4749 Bitwise logical @code{AND}.
4751 @item @emph{Standard}:
4757 @item @emph{Syntax}:
4758 @code{RESULT = IAND(I, J)}
4760 @item @emph{Arguments}:
4761 @multitable @columnfractions .15 .70
4762 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
4763 @item @var{J} @tab The type shall be @code{INTEGER(*)}, of the same
4764 kind as @var{I}. (As a GNU extension, different kinds are also
4768 @item @emph{Return value}:
4769 The return type is @code{INTEGER(*)}, of the same kind as the
4770 arguments. (If the argument kinds differ, it is of the same kind as
4771 the larger argument.)
4773 @item @emph{Example}:
4777 DATA a / Z'F' /, b / Z'3' /
4778 WRITE (*,*) IAND(a, b)
4782 @item @emph{See also}:
4783 @ref{IOR}, @ref{IEOR}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
4790 @section @code{IARGC} --- Get the number of command line arguments
4792 @cindex command-line arguments
4793 @cindex command-line arguments, number of
4794 @cindex arguments, to program
4797 @item @emph{Description}:
4798 @code{IARGC()} returns the number of arguments passed on the
4799 command line when the containing program was invoked.
4801 This intrinsic routine is provided for backwards compatibility with
4802 GNU Fortran 77. In new code, programmers should consider the use of
4803 the @ref{COMMAND_ARGUMENT_COUNT} intrinsic defined by the Fortran 2003
4806 @item @emph{Standard}:
4810 Non-elemental Function
4812 @item @emph{Syntax}:
4813 @code{RESULT = IARGC()}
4815 @item @emph{Arguments}:
4818 @item @emph{Return value}:
4819 The number of command line arguments, type @code{INTEGER(4)}.
4821 @item @emph{Example}:
4824 @item @emph{See also}:
4825 GNU Fortran 77 compatibility subroutine: @ref{GETARG}
4827 F2003 functions and subroutines: @ref{GET_COMMAND}, @ref{GET_COMMAND_ARGUMENT},
4828 @ref{COMMAND_ARGUMENT_COUNT}
4834 @section @code{IBCLR} --- Clear bit
4840 @item @emph{Description}:
4841 @code{IBCLR} returns the value of @var{I} with the bit at position
4842 @var{POS} set to zero.
4844 @item @emph{Standard}:
4850 @item @emph{Syntax}:
4851 @code{RESULT = IBCLR(I, POS)}
4853 @item @emph{Arguments}:
4854 @multitable @columnfractions .15 .70
4855 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
4856 @item @var{POS} @tab The type shall be @code{INTEGER(*)}.
4859 @item @emph{Return value}:
4860 The return value is of type @code{INTEGER(*)} and of the same kind as
4863 @item @emph{See also}:
4864 @ref{IBITS}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}, @ref{MVBITS}
4871 @section @code{IBITS} --- Bit extraction
4874 @cindex bits, extract
4877 @item @emph{Description}:
4878 @code{IBITS} extracts a field of length @var{LEN} from @var{I},
4879 starting from bit position @var{POS} and extending left for @var{LEN}
4880 bits. The result is right-justified and the remaining bits are
4881 zeroed. The value of @code{POS+LEN} must be less than or equal to the
4882 value @code{BIT_SIZE(I)}.
4884 @item @emph{Standard}:
4890 @item @emph{Syntax}:
4891 @code{RESULT = IBITS(I, POS, LEN)}
4893 @item @emph{Arguments}:
4894 @multitable @columnfractions .15 .70
4895 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
4896 @item @var{POS} @tab The type shall be @code{INTEGER(*)}.
4897 @item @var{LEN} @tab The type shall be @code{INTEGER(*)}.
4900 @item @emph{Return value}:
4901 The return value is of type @code{INTEGER(*)} and of the same kind as
4904 @item @emph{See also}:
4905 @ref{BIT_SIZE}, @ref{IBCLR}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
4911 @section @code{IBSET} --- Set bit
4916 @item @emph{Description}:
4917 @code{IBSET} returns the value of @var{I} with the bit at position
4918 @var{POS} set to one.
4920 @item @emph{Standard}:
4926 @item @emph{Syntax}:
4927 @code{RESULT = IBSET(I, POS)}
4929 @item @emph{Arguments}:
4930 @multitable @columnfractions .15 .70
4931 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
4932 @item @var{POS} @tab The type shall be @code{INTEGER(*)}.
4935 @item @emph{Return value}:
4936 The return value is of type @code{INTEGER(*)} and of the same kind as
4939 @item @emph{See also}:
4940 @ref{IBCLR}, @ref{IBITS}, @ref{IAND}, @ref{IOR}, @ref{IEOR}, @ref{MVBITS}
4947 @section @code{ICHAR} --- Character-to-integer conversion function
4949 @cindex conversion, to integer
4952 @item @emph{Description}:
4953 @code{ICHAR(C)} returns the code for the character in the first character
4954 position of @code{C} in the system's native character set.
4955 The correspondence between characters and their codes is not necessarily
4956 the same across different GNU Fortran implementations.
4958 @item @emph{Standard}:
4964 @item @emph{Syntax}:
4965 @code{RESULT = ICHAR(C)}
4967 @item @emph{Arguments}:
4968 @multitable @columnfractions .15 .70
4969 @item @var{C} @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
4972 @item @emph{Return value}:
4973 The return value is of type @code{INTEGER} and of the default integer
4976 @item @emph{Example}:
4981 end program test_ichar
4985 No intrinsic exists to convert between a numeric value and a formatted
4986 character string representation -- for instance, given the
4987 @code{CHARACTER} value @code{'154'}, obtaining an @code{INTEGER} or
4988 @code{REAL} value with the value 154, or vice versa. Instead, this
4989 functionality is provided by internal-file I/O, as in the following
4994 character(len=10) string, string2
4997 ! Convert a string to a numeric value
4998 read (string,'(I10)') value
5001 ! Convert a value to a formatted string
5002 write (string2,'(I10)') value
5004 end program read_val
5007 @item @emph{See also}:
5008 @ref{ACHAR}, @ref{CHAR}, @ref{IACHAR}
5015 @section @code{IDATE} --- Get current local time subroutine (day/month/year)
5017 @cindex date, current
5018 @cindex current date
5021 @item @emph{Description}:
5022 @code{IDATE(TARRAY)} Fills @var{TARRAY} with the numerical values at the
5023 current local time. The day (in the range 1-31), month (in the range 1-12),
5024 and year appear in elements 1, 2, and 3 of @var{TARRAY}, respectively.
5025 The year has four significant digits.
5027 @item @emph{Standard}:
5033 @item @emph{Syntax}:
5034 @code{CALL IDATE(TARRAY)}
5036 @item @emph{Arguments}:
5037 @multitable @columnfractions .15 .70
5038 @item @var{TARRAY} @tab The type shall be @code{INTEGER, DIMENSION(3)} and
5039 the kind shall be the default integer kind.
5042 @item @emph{Return value}:
5045 @item @emph{Example}:
5048 integer, dimension(3) :: tarray
5053 end program test_idate
5060 @section @code{IEOR} --- Bitwise logical exclusive or
5062 @cindex bitwise logical exclusive or
5063 @cindex logical exclusive or, bitwise
5066 @item @emph{Description}:
5067 @code{IEOR} returns the bitwise boolean exclusive-OR of @var{I} and
5070 @item @emph{Standard}:
5076 @item @emph{Syntax}:
5077 @code{RESULT = IEOR(I, J)}
5079 @item @emph{Arguments}:
5080 @multitable @columnfractions .15 .70
5081 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
5082 @item @var{J} @tab The type shall be @code{INTEGER(*)}, of the same
5083 kind as @var{I}. (As a GNU extension, different kinds are also
5087 @item @emph{Return value}:
5088 The return type is @code{INTEGER(*)}, of the same kind as the
5089 arguments. (If the argument kinds differ, it is of the same kind as
5090 the larger argument.)
5092 @item @emph{See also}:
5093 @ref{IOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
5099 @section @code{IERRNO} --- Get the last system error number
5101 @cindex system, error handling
5104 @item @emph{Description}:
5105 Returns the last system error number, as given by the C @code{errno()}
5108 @item @emph{Standard}:
5112 Non-elemental function
5114 @item @emph{Syntax}:
5115 @code{RESULT = IERRNO()}
5117 @item @emph{Arguments}:
5120 @item @emph{Return value}:
5121 The return value is of type @code{INTEGER} and of the default integer
5124 @item @emph{See also}:
5131 @section @code{INDEX} --- Position of a substring within a string
5133 @cindex substring position
5134 @cindex string, find substring
5137 @item @emph{Description}:
5138 Returns the position of the start of the first occurrence of string
5139 @var{SUBSTRING} as a substring in @var{STRING}, counting from one. If
5140 @var{SUBSTRING} is not present in @var{STRING}, zero is returned. If
5141 the @var{BACK} argument is present and true, the return value is the
5142 start of the last occurrence rather than the first.
5144 @item @emph{Standard}:
5150 @item @emph{Syntax}:
5151 @code{RESULT = INDEX(STRING, SUBSTRING [, BACK])}
5153 @item @emph{Arguments}:
5154 @multitable @columnfractions .15 .70
5155 @item @var{STRING} @tab Shall be a scalar @code{CHARACTER(*)}, with
5157 @item @var{SUBSTRING} @tab Shall be a scalar @code{CHARACTER(*)}, with
5159 @item @var{BACK} @tab (Optional) Shall be a scalar @code{LOGICAL(*)}, with
5163 @item @emph{Return value}:
5164 The return value is of type @code{INTEGER} and of the default integer
5167 @item @emph{See also}:
5168 @ref{SCAN}, @ref{VERIFY}
5174 @section @code{INT} --- Convert to integer type
5178 @cindex conversion, to integer
5181 @item @emph{Description}:
5182 Convert to integer type
5184 @item @emph{Standard}:
5190 @item @emph{Syntax}:
5191 @code{RESULT = INT(A [, KIND))}
5193 @item @emph{Arguments}:
5194 @multitable @columnfractions .15 .70
5195 @item @var{A} @tab Shall be of type @code{INTEGER(*)},
5196 @code{REAL(*)}, or @code{COMPLEX(*)}.
5197 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
5198 expression indicating the kind parameter of
5202 @item @emph{Return value}:
5203 These functions return a @code{INTEGER(*)} variable or array under
5204 the following rules:
5208 If @var{A} is of type @code{INTEGER(*)}, @code{INT(A) = A}
5210 If @var{A} is of type @code{REAL(*)} and @math{|A| < 1}, @code{INT(A)} equals @code{0}.
5211 If @math{|A| \geq 1}, then @code{INT(A)} equals the largest integer that does not exceed
5212 the range of @var{A} and whose sign is the same as the sign of @var{A}.
5214 If @var{A} is of type @code{COMPLEX(*)}, rule B is applied to the real part of @var{A}.
5217 @item @emph{Example}:
5221 complex :: z = (-3.7, 1.0)
5223 print *, int(z), int(z,8)
5227 @item @emph{Specific names}:
5228 @multitable @columnfractions .20 .20 .20 .25
5229 @item Name @tab Argument @tab Return type @tab Standard
5230 @item @code{IFIX(A)} @tab @code{REAL(4) A} @tab @code{INTEGER} @tab F77 and later
5231 @item @code{IDINT(A)} @tab @code{REAL(8) A} @tab @code{INTEGER} @tab F77 and later
5239 @section @code{INT2} --- Convert to 16-bit integer type
5242 @cindex conversion, to integer
5245 @item @emph{Description}:
5246 Convert to a @code{KIND=2} integer type. This is equivalent to the
5247 standard @code{INT} intrinsic with an optional argument of
5248 @code{KIND=2}, and is only included for backwards compatibility.
5250 The @code{SHORT} intrinsic is equivalent to @code{INT2}.
5252 @item @emph{Standard}:
5258 @item @emph{Syntax}:
5259 @code{RESULT = INT2(A)}
5261 @item @emph{Arguments}:
5262 @multitable @columnfractions .15 .70
5263 @item @var{A} @tab Shall be of type @code{INTEGER(*)},
5264 @code{REAL(*)}, or @code{COMPLEX(*)}.
5267 @item @emph{Return value}:
5268 The return value is a @code{INTEGER(2)} variable.
5270 @item @emph{See also}:
5271 @ref{INT}, @ref{INT8}, @ref{LONG}
5277 @section @code{INT8} --- Convert to 64-bit integer type
5279 @cindex conversion, to integer
5282 @item @emph{Description}:
5283 Convert to a @code{KIND=8} integer type. This is equivalent to the
5284 standard @code{INT} intrinsic with an optional argument of
5285 @code{KIND=8}, and is only included for backwards compatibility.
5287 @item @emph{Standard}:
5293 @item @emph{Syntax}:
5294 @code{RESULT = INT8(A)}
5296 @item @emph{Arguments}:
5297 @multitable @columnfractions .15 .70
5298 @item @var{A} @tab Shall be of type @code{INTEGER(*)},
5299 @code{REAL(*)}, or @code{COMPLEX(*)}.
5302 @item @emph{Return value}:
5303 The return value is a @code{INTEGER(8)} variable.
5305 @item @emph{See also}:
5306 @ref{INT}, @ref{INT2}, @ref{LONG}
5312 @section @code{IOR} --- Bitwise logical or
5314 @cindex bitwise logical or
5315 @cindex logical or, bitwise
5318 @item @emph{Description}:
5319 @code{IEOR} returns the bitwise boolean OR of @var{I} and
5322 @item @emph{Standard}:
5328 @item @emph{Syntax}:
5329 @code{RESULT = IEOR(I, J)}
5331 @item @emph{Arguments}:
5332 @multitable @columnfractions .15 .70
5333 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
5334 @item @var{J} @tab The type shall be @code{INTEGER(*)}, of the same
5335 kind as @var{I}. (As a GNU extension, different kinds are also
5339 @item @emph{Return value}:
5340 The return type is @code{INTEGER(*)}, of the same kind as the
5341 arguments. (If the argument kinds differ, it is of the same kind as
5342 the larger argument.)
5344 @item @emph{See also}:
5345 @ref{IEOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
5351 @section @code{IRAND} --- Integer pseudo-random number
5353 @cindex random number generation
5356 @item @emph{Description}:
5357 @code{IRAND(FLAG)} returns a pseudo-random number from a uniform
5358 distribution between 0 and a system-dependent limit (which is in most
5359 cases 2147483647). If @var{FLAG} is 0, the next number
5360 in the current sequence is returned; if @var{FLAG} is 1, the generator
5361 is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
5362 it is used as a new seed with @code{SRAND}.
5364 @item @emph{Standard}:
5368 Non-elemental function
5370 @item @emph{Syntax}:
5371 @code{RESULT = IRAND(FLAG)}
5373 @item @emph{Arguments}:
5374 @multitable @columnfractions .15 .70
5375 @item @var{FLAG} @tab Shall be a scalar @code{INTEGER} of kind 4.
5378 @item @emph{Return value}:
5379 The return value is of @code{INTEGER(kind=4)} type.
5381 @item @emph{Example}:
5384 integer,parameter :: seed = 86456
5387 print *, irand(), irand(), irand(), irand()
5388 print *, irand(seed), irand(), irand(), irand()
5389 end program test_irand
5397 @section @code{ISATTY} --- Whether a unit is a terminal device.
5399 @cindex system, terminal
5402 @item @emph{Description}:
5403 Determine whether a unit is connected to a terminal device.
5405 @item @emph{Standard}:
5409 Non-elemental function.
5411 @item @emph{Syntax}:
5412 @code{RESULT = ISATTY(UNIT)}
5414 @item @emph{Arguments}:
5415 @multitable @columnfractions .15 .70
5416 @item @var{UNIT} @tab Shall be a scalar @code{INTEGER(*)}.
5419 @item @emph{Return value}:
5420 Returns @code{.TRUE.} if the @var{UNIT} is connected to a terminal
5421 device, @code{.FALSE.} otherwise.
5423 @item @emph{Example}:
5426 INTEGER(kind=1) :: unit
5428 write(*,*) isatty(unit=unit)
5432 @item @emph{See also}:
5439 @section @code{ISHFT} --- Shift bits
5444 @item @emph{Description}:
5445 @code{ISHFT} returns a value corresponding to @var{I} with all of the
5446 bits shifted @var{SHIFT} places. A value of @var{SHIFT} greater than
5447 zero corresponds to a left shift, a value of zero corresponds to no
5448 shift, and a value less than zero corresponds to a right shift. If the
5449 absolute value of @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the
5450 value is undefined. Bits shifted out from the left end or right end are
5451 lost; zeros are shifted in from the opposite end.
5453 @item @emph{Standard}:
5459 @item @emph{Syntax}:
5460 @code{RESULT = ISHFT(I, SHIFT)}
5462 @item @emph{Arguments}:
5463 @multitable @columnfractions .15 .70
5464 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
5465 @item @var{SHIFT} @tab The type shall be @code{INTEGER(*)}.
5468 @item @emph{Return value}:
5469 The return value is of type @code{INTEGER(*)} and of the same kind as
5472 @item @emph{See also}:
5479 @section @code{ISHFTC} --- Shift bits circularly
5481 @cindex bits, shift circular
5484 @item @emph{Description}:
5485 @code{ISHFTC} returns a value corresponding to @var{I} with the
5486 rightmost @var{SIZE} bits shifted circularly @var{SHIFT} places; that
5487 is, bits shifted out one end are shifted into the opposite end. A value
5488 of @var{SHIFT} greater than zero corresponds to a left shift, a value of
5489 zero corresponds to no shift, and a value less than zero corresponds to
5490 a right shift. The absolute value of @var{SHIFT} must be less than
5491 @var{SIZE}. If the @var{SIZE} argument is omitted, it is taken to be
5492 equivalent to @code{BIT_SIZE(I)}.
5494 @item @emph{Standard}:
5500 @item @emph{Syntax}:
5501 @code{RESULT = ISHFTC(I, SHIFT [, SIZE])}
5503 @item @emph{Arguments}:
5504 @multitable @columnfractions .15 .70
5505 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
5506 @item @var{SHIFT} @tab The type shall be @code{INTEGER(*)}.
5507 @item @var{SIZE} @tab (Optional) The type shall be @code{INTEGER(*)};
5508 the value must be greater than zero and less than or equal to
5512 @item @emph{Return value}:
5513 The return value is of type @code{INTEGER(*)} and of the same kind as
5516 @item @emph{See also}:
5523 @section @code{ITIME} --- Get current local time subroutine (hour/minutes/seconds)
5525 @cindex time, current
5526 @cindex current time
5529 @item @emph{Description}:
5530 @code{IDATE(TARRAY)} Fills @var{TARRAY} with the numerical values at the
5531 current local time. The hour (in the range 1-24), minute (in the range 1-60),
5532 and seconds (in the range 1-60) appear in elements 1, 2, and 3 of @var{TARRAY},
5535 @item @emph{Standard}:
5541 @item @emph{Syntax}:
5542 @code{CALL ITIME(TARRAY)}
5544 @item @emph{Arguments}:
5545 @multitable @columnfractions .15 .70
5546 @item @var{TARRAY} @tab The type shall be @code{INTEGER, DIMENSION(3)}
5547 and the kind shall be the default integer kind.
5550 @item @emph{Return value}:
5554 @item @emph{Example}:
5557 integer, dimension(3) :: tarray
5562 end program test_itime
5569 @section @code{KILL} --- Send a signal to a process
5573 @item @emph{Description}:
5574 @item @emph{Standard}:
5575 Sends the signal specified by @var{SIGNAL} to the process @var{PID}.
5581 @item @emph{Syntax}:
5582 @code{CALL KILL(PID, SIGNAL [, STATUS])}
5584 @item @emph{Arguments}:
5585 @multitable @columnfractions .15 .70
5586 @item @var{PID} @tab Shall be a scalar @code{INTEGER}, with
5588 @item @var{SIGNAL} @tab Shall be a scalar @code{INTEGER}, with
5590 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)} or
5591 @code{INTEGER(8)}. Returns 0 on success, or a
5592 system-specific error code otherwise.
5595 @item @emph{See also}:
5596 @ref{ABORT}, @ref{EXIT}
5602 @section @code{KIND} --- Kind of an entity
5607 @item @emph{Description}:
5608 @code{KIND(X)} returns the kind value of the entity @var{X}.
5610 @item @emph{Standard}:
5616 @item @emph{Syntax}:
5619 @item @emph{Arguments}:
5620 @multitable @columnfractions .15 .70
5621 @item @var{X} @tab Shall be of type @code{LOGICAL}, @code{INTEGER},
5622 @code{REAL}, @code{COMPLEX} or @code{CHARACTER}.
5625 @item @emph{Return value}:
5626 The return value is a scalar of type @code{INTEGER} and of the default
5629 @item @emph{Example}:
5632 integer,parameter :: kc = kind(' ')
5633 integer,parameter :: kl = kind(.true.)
5635 print *, "The default character kind is ", kc
5636 print *, "The default logical kind is ", kl
5637 end program test_kind
5645 @section @code{LBOUND} --- Lower dimension bounds of an array
5647 @cindex array, lower bound
5650 @item @emph{Description}:
5651 Returns the lower bounds of an array, or a single lower bound
5652 along the @var{DIM} dimension.
5653 @item @emph{Standard}:
5659 @item @emph{Syntax}:
5660 @code{RESULT = LBOUND(ARRAY [, DIM])}
5662 @item @emph{Arguments}:
5663 @multitable @columnfractions .15 .70
5664 @item @var{ARRAY} @tab Shall be an array, of any type.
5665 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER(*)}.
5668 @item @emph{Return value}:
5669 If @var{DIM} is absent, the result is an array of the lower bounds of
5670 @var{ARRAY}. If @var{DIM} is present, the result is a scalar
5671 corresponding to the lower bound of the array along that dimension. If
5672 @var{ARRAY} is an expression rather than a whole array or array
5673 structure component, or if it has a zero extent along the relevant
5674 dimension, the lower bound is taken to be 1.
5676 @item @emph{See also}:
5683 @section @code{LEN} --- Length of a character entity
5685 @cindex string, length
5688 @item @emph{Description}:
5689 Returns the length of a character string. If @var{STRING} is an array,
5690 the length of an element of @var{STRING} is returned. Note that
5691 @var{STRING} need not be defined when this intrinsic is invoked, since
5692 only the length, not the content, of @var{STRING} is needed.
5694 @item @emph{Standard}:
5700 @item @emph{Syntax}:
5701 @code{L = LEN(STRING)}
5703 @item @emph{Arguments}:
5704 @multitable @columnfractions .15 .70
5705 @item @var{STRING} @tab Shall be a scalar or array of type
5706 @code{CHARACTER(*)}, with @code{INTENT(IN)}
5709 @item @emph{Return value}:
5710 The return value is an @code{INTEGER} of the default kind.
5712 @item @emph{See also}:
5713 @ref{LEN_TRIM}, @ref{ADJUSTL}, @ref{ADJUSTR}
5719 @section @code{LEN_TRIM} --- Length of a character entity without trailing blank characters
5721 @cindex string, length, without trailing whitespace
5724 @item @emph{Description}:
5725 Returns the length of a character string, ignoring any trailing blanks.
5727 @item @emph{Standard}:
5733 @item @emph{Syntax}:
5734 @code{RESULT = LEN_TRIM(STRING)}
5736 @item @emph{Arguments}:
5737 @multitable @columnfractions .15 .70
5738 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER(*)},
5739 with @code{INTENT(IN)}
5742 @item @emph{Return value}:
5743 The return value is an @code{INTEGER} of the default kind.
5745 @item @emph{See also}:
5746 @ref{LEN}, @ref{ADJUSTL}, @ref{ADJUSTR}
5752 @section @code{LGE} --- Lexical greater than or equal
5754 @cindex lexical comparison of strings
5755 @cindex string, comparison
5758 @item @emph{Description}:
5759 Determines whether one string is lexically greater than or equal to
5760 another string, where the two strings are interpreted as containing
5761 ASCII character codes. If the String A and String B are not the same
5762 length, the shorter is compared as if spaces were appended to it to form
5763 a value that has the same length as the longer.
5765 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
5766 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
5767 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
5768 that the latter use the processor's character ordering (which is not
5769 ASCII on some targets), whereas the former always use the ASCII
5772 @item @emph{Standard}:
5778 @item @emph{Syntax}:
5779 @code{RESULT = LGE(STRING_A, STRING_B)}
5781 @item @emph{Arguments}:
5782 @multitable @columnfractions .15 .70
5783 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
5784 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
5787 @item @emph{Return value}:
5788 Returns @code{.TRUE.} if @code{STRING_A >= STRING_B}, and @code{.FALSE.}
5789 otherwise, based on the ASCII ordering.
5791 @item @emph{See also}:
5792 @ref{LGT}, @ref{LLE}, @ref{LLT}
5798 @section @code{LGT} --- Lexical greater than
5800 @cindex lexical comparison of strings
5801 @cindex string, comparison
5804 @item @emph{Description}:
5805 Determines whether one string is lexically greater than another string,
5806 where the two strings are interpreted as containing ASCII character
5807 codes. If the String A and String B are not the same length, the
5808 shorter is compared as if spaces were appended to it to form a value
5809 that has the same length as the longer.
5811 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
5812 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
5813 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
5814 that the latter use the processor's character ordering (which is not
5815 ASCII on some targets), whereas the former always use the ASCII
5818 @item @emph{Standard}:
5824 @item @emph{Syntax}:
5825 @code{RESULT = LGT(STRING_A, STRING_B)}
5827 @item @emph{Arguments}:
5828 @multitable @columnfractions .15 .70
5829 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
5830 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
5833 @item @emph{Return value}:
5834 Returns @code{.TRUE.} if @code{STRING_A > STRING_B}, and @code{.FALSE.}
5835 otherwise, based on the ASCII ordering.
5837 @item @emph{See also}:
5838 @ref{LGE}, @ref{LLE}, @ref{LLT}
5844 @section @code{LINK} --- Create a hard link
5846 @cindex file system, create link
5847 @cindex file system, hard link
5850 @item @emph{Description}:
5851 Makes a (hard) link from file @var{PATH1} to @var{PATH2}. A null
5852 character (@code{CHAR(0)}) can be used to mark the end of the names in
5853 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
5854 names are ignored. If the @var{STATUS} argument is supplied, it
5855 contains 0 on success or a nonzero error code upon return; see
5858 This intrinsic is provided in both subroutine and function forms;
5859 however, only one form can be used in any given program unit.
5861 @item @emph{Standard}:
5865 Subroutine, non-elemental function
5867 @item @emph{Syntax}:
5868 @multitable @columnfractions .80
5869 @item @code{CALL LINK(PATH1, PATH2 [, STATUS])}
5870 @item @code{STATUS = LINK(PATH1, PATH2)}
5873 @item @emph{Arguments}:
5874 @multitable @columnfractions .15 .70
5875 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
5876 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
5877 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
5880 @item @emph{See also}:
5881 @ref{SYMLNK}, @ref{UNLINK}
5887 @section @code{LLE} --- Lexical less than or equal
5889 @cindex lexical comparison of strings
5890 @cindex string, comparison
5893 @item @emph{Description}:
5894 Determines whether one string is lexically less than or equal to another
5895 string, where the two strings are interpreted as containing ASCII
5896 character codes. If the String A and String B are not the same length,
5897 the shorter is compared as if spaces were appended to it to form a value
5898 that has the same length as the longer.
5900 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
5901 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
5902 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
5903 that the latter use the processor's character ordering (which is not
5904 ASCII on some targets), whereas the former always use the ASCII
5907 @item @emph{Standard}:
5913 @item @emph{Syntax}:
5914 @code{RESULT = LLE(STRING_A, STRING_B)}
5916 @item @emph{Arguments}:
5917 @multitable @columnfractions .15 .70
5918 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
5919 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
5922 @item @emph{Return value}:
5923 Returns @code{.TRUE.} if @code{STRING_A <= STRING_B}, and @code{.FALSE.}
5924 otherwise, based on the ASCII ordering.
5926 @item @emph{See also}:
5927 @ref{LGE}, @ref{LGT}, @ref{LLT}
5933 @section @code{LLT} --- Lexical less than
5935 @cindex lexical comparison of strings
5936 @cindex string, comparison
5939 @item @emph{Description}:
5940 Determines whether one string is lexically less than another string,
5941 where the two strings are interpreted as containing ASCII character
5942 codes. If the String A and String B are not the same length, the
5943 shorter is compared as if spaces were appended to it to form a value
5944 that has the same length as the longer.
5946 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
5947 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
5948 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
5949 that the latter use the processor's character ordering (which is not
5950 ASCII on some targets), whereas the former always use the ASCII
5953 @item @emph{Standard}:
5959 @item @emph{Syntax}:
5960 @code{RESULT = LLT(STRING_A, STRING_B)}
5962 @item @emph{Arguments}:
5963 @multitable @columnfractions .15 .70
5964 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
5965 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
5968 @item @emph{Return value}:
5969 Returns @code{.TRUE.} if @code{STRING_A < STRING_B}, and @code{.FALSE.}
5970 otherwise, based on the ASCII ordering.
5972 @item @emph{See also}:
5973 @ref{LGE}, @ref{LGT}, @ref{LLE}
5979 @section @code{LNBLNK} --- Index of the last non-blank character in a string
5981 @cindex string, find non-blank character
5984 @item @emph{Description}:
5985 Returns the length of a character string, ignoring any trailing blanks.
5986 This is identical to the standard @code{LEN_TRIM} intrinsic, and is only
5987 included for backwards compatibility.
5989 @item @emph{Standard}:
5995 @item @emph{Syntax}:
5996 @code{RESULT = LNBLNK(STRING)}
5998 @item @emph{Arguments}:
5999 @multitable @columnfractions .15 .70
6000 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER(*)},
6001 with @code{INTENT(IN)}
6004 @item @emph{Return value}:
6005 The return value is of @code{INTEGER(kind=4)} type.
6007 @item @emph{See also}:
6008 @ref{INDEX}, @ref{LEN_TRIM}
6014 @section @code{LOC} --- Returns the address of a variable
6016 @cindex location of a variable in memory
6019 @item @emph{Description}:
6020 @code{LOC(X)} returns the address of @var{X} as an integer.
6022 @item @emph{Standard}:
6028 @item @emph{Syntax}:
6029 @code{RESULT = LOC(X)}
6031 @item @emph{Arguments}:
6032 @multitable @columnfractions .15 .70
6033 @item @var{X} @tab Variable of any type.
6036 @item @emph{Return value}:
6037 The return value is of type @code{INTEGER}, with a @code{KIND}
6038 corresponding to the size (in bytes) of a memory address on the target
6041 @item @emph{Example}:
6048 end program test_loc
6055 @section @code{LOG} --- Logarithm function
6062 @cindex exponential function, inverse
6063 @cindex logarithmic function
6066 @item @emph{Description}:
6067 @code{LOG(X)} computes the logarithm of @var{X}.
6069 @item @emph{Standard}:
6075 @item @emph{Syntax}:
6076 @code{RESULT = LOG(X)}
6078 @item @emph{Arguments}:
6079 @multitable @columnfractions .15 .70
6080 @item @var{X} @tab The type shall be @code{REAL(*)} or
6084 @item @emph{Return value}:
6085 The return value is of type @code{REAL(*)} or @code{COMPLEX(*)}.
6086 The kind type parameter is the same as @var{X}.
6088 @item @emph{Example}:
6091 real(8) :: x = 1.0_8
6092 complex :: z = (1.0, 2.0)
6095 end program test_log
6098 @item @emph{Specific names}:
6099 @multitable @columnfractions .20 .20 .20 .25
6100 @item Name @tab Argument @tab Return type @tab Standard
6101 @item @code{ALOG(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab f95, gnu
6102 @item @code{DLOG(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
6103 @item @code{CLOG(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab f95, gnu
6104 @item @code{ZLOG(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
6105 @item @code{CDLOG(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
6112 @section @code{LOG10} --- Base 10 logarithm function
6116 @cindex exponential function, inverse
6117 @cindex logarithmic function
6120 @item @emph{Description}:
6121 @code{LOG10(X)} computes the base 10 logarithm of @var{X}.
6123 @item @emph{Standard}:
6129 @item @emph{Syntax}:
6130 @code{RESULT = LOG10(X)}
6132 @item @emph{Arguments}:
6133 @multitable @columnfractions .15 .70
6134 @item @var{X} @tab The type shall be @code{REAL(*)}.
6137 @item @emph{Return value}:
6138 The return value is of type @code{REAL(*)} or @code{COMPLEX(*)}.
6139 The kind type parameter is the same as @var{X}.
6141 @item @emph{Example}:
6144 real(8) :: x = 10.0_8
6146 end program test_log10
6149 @item @emph{Specific names}:
6150 @multitable @columnfractions .20 .20 .20 .25
6151 @item Name @tab Argument @tab Return type @tab Standard
6152 @item @code{ALOG10(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab F95 and later
6153 @item @code{DLOG10(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
6160 @section @code{LOGICAL} --- Convert to logical type
6162 @cindex conversion, to logical
6165 @item @emph{Description}:
6166 Converts one kind of @code{LOGICAL} variable to another.
6168 @item @emph{Standard}:
6174 @item @emph{Syntax}:
6175 @code{RESULT = LOGICAL(L [, KIND])}
6177 @item @emph{Arguments}:
6178 @multitable @columnfractions .15 .70
6179 @item @var{L} @tab The type shall be @code{LOGICAL(*)}.
6180 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
6181 expression indicating the kind parameter of
6185 @item @emph{Return value}:
6186 The return value is a @code{LOGICAL} value equal to @var{L}, with a
6187 kind corresponding to @var{KIND}, or of the default logical kind if
6188 @var{KIND} is not given.
6190 @item @emph{See also}:
6191 @ref{INT}, @ref{REAL}, @ref{CMPLX}
6197 @section @code{LONG} --- Convert to integer type
6199 @cindex conversion, to integer
6202 @item @emph{Description}:
6203 Convert to a @code{KIND=4} integer type, which is the same size as a C
6204 @code{long} integer. This is equivalent to the standard @code{INT}
6205 intrinsic with an optional argument of @code{KIND=4}, and is only
6206 included for backwards compatibility.
6208 @item @emph{Standard}:
6214 @item @emph{Syntax}:
6215 @code{RESULT = LONG(A)}
6217 @item @emph{Arguments}:
6218 @multitable @columnfractions .15 .70
6219 @item @var{A} @tab Shall be of type @code{INTEGER(*)},
6220 @code{REAL(*)}, or @code{COMPLEX(*)}.
6223 @item @emph{Return value}:
6224 The return value is a @code{INTEGER(4)} variable.
6226 @item @emph{See also}:
6227 @ref{INT}, @ref{INT2}, @ref{INT8}
6233 @section @code{LSHIFT} --- Left shift bits
6235 @cindex bits, shift left
6238 @item @emph{Description}:
6239 @code{LSHIFT} returns a value corresponding to @var{I} with all of the
6240 bits shifted left by @var{SHIFT} places. If the absolute value of
6241 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
6242 Bits shifted out from the left end are lost; zeros are shifted in from
6245 This function has been superseded by the @code{ISHFT} intrinsic, which
6246 is standard in Fortran 95 and later.
6248 @item @emph{Standard}:
6254 @item @emph{Syntax}:
6255 @code{RESULT = LSHIFT(I, SHIFT)}
6257 @item @emph{Arguments}:
6258 @multitable @columnfractions .15 .70
6259 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
6260 @item @var{SHIFT} @tab The type shall be @code{INTEGER(*)}.
6263 @item @emph{Return value}:
6264 The return value is of type @code{INTEGER(*)} and of the same kind as
6267 @item @emph{See also}:
6268 @ref{ISHFT}, @ref{ISHFTC}, @ref{RSHIFT}
6275 @section @code{LSTAT} --- Get file status
6277 @cindex file system, file status
6280 @item @emph{Description}:
6281 @code{LSTAT} is identical to @ref{STAT}, except that if path is a symbolic link,
6282 then the link itself is statted, not the file that it refers to.
6284 The elements in @code{BUFF} are the same as described by @ref{STAT}.
6286 @item @emph{Standard}:
6290 Non-elemental subroutine
6292 @item @emph{Syntax}:
6293 @code{CALL LSTAT(FILE, BUFF [, STATUS])}
6295 @item @emph{Arguments}:
6296 @multitable @columnfractions .15 .70
6297 @item @var{FILE} @tab The type shall be @code{CHARACTER(*)}, a valid path within the file system.
6298 @item @var{BUFF} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
6299 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0
6300 on success and a system specific error code otherwise.
6303 @item @emph{Example}:
6304 See @ref{STAT} for an example.
6306 @item @emph{See also}:
6307 To stat an open file: @ref{FSTAT}, to stat a file: @ref{STAT}
6313 @section @code{LTIME} --- Convert time to local time info
6315 @cindex time, converstion to local time info
6318 @item @emph{Description}:
6319 Given a system time value @var{STIME} (as provided by the @code{TIME8()}
6320 intrinsic), fills @var{TARRAY} with values extracted from it appropriate
6321 to the local time zone using @code{localtime(3)}.
6323 @item @emph{Standard}:
6329 @item @emph{Syntax}:
6330 @code{CALL LTIME(STIME, TARRAY)}
6332 @item @emph{Arguments}:
6333 @multitable @columnfractions .15 .70
6334 @item @var{STIME} @tab An @code{INTEGER(*)} scalar expression
6335 corresponding to a system time, with
6337 @item @var{TARRAY} @tab A default @code{INTEGER} array with 9 elements,
6338 with @code{INTENT(OUT)}.
6341 @item @emph{Return value}:
6342 The elements of @var{TARRAY} are assigned as follows:
6344 @item Seconds after the minute, range 0--59 or 0--61 to allow for leap
6346 @item Minutes after the hour, range 0--59
6347 @item Hours past midnight, range 0--23
6348 @item Day of month, range 0--31
6349 @item Number of months since January, range 0--12
6350 @item Years since 1900
6351 @item Number of days since Sunday, range 0--6
6352 @item Days since January 1
6353 @item Daylight savings indicator: positive if daylight savings is in
6354 effect, zero if not, and negative if the information is not
6358 @item @emph{See also}:
6359 @ref{CTIME}, @ref{GMTIME}, @ref{TIME}, @ref{TIME8}
6366 @section @code{MALLOC} --- Allocate dynamic memory
6368 @cindex pointer, cray
6371 @item @emph{Description}:
6372 @code{MALLOC(SIZE)} allocates @var{SIZE} bytes of dynamic memory and
6373 returns the address of the allocated memory. The @code{MALLOC} intrinsic
6374 is an extension intended to be used with Cray pointers, and is provided
6375 in GNU Fortran to allow the user to compile legacy code. For new code
6376 using Fortran 95 pointers, the memory allocation intrinsic is
6379 @item @emph{Standard}:
6383 Non-elemental function
6385 @item @emph{Syntax}:
6386 @code{PTR = MALLOC(SIZE)}
6388 @item @emph{Arguments}:
6389 @multitable @columnfractions .15 .70
6390 @item @var{SIZE} @tab The type shall be @code{INTEGER(*)}.
6393 @item @emph{Return value}:
6394 The return value is of type @code{INTEGER(K)}, with @var{K} such that
6395 variables of type @code{INTEGER(K)} have the same size as
6396 C pointers (@code{sizeof(void *)}).
6398 @item @emph{Example}:
6399 The following example demonstrates the use of @code{MALLOC} and
6400 @code{FREE} with Cray pointers. This example is intended to run on
6401 32-bit systems, where the default integer kind is suitable to store
6402 pointers; on 64-bit systems, ptr_x would need to be declared as
6403 @code{integer(kind=8)}.
6412 ptr_x = malloc(20*8)
6414 x(i) = sqrt(1.0d0 / i)
6422 end program test_malloc
6425 @item @emph{See also}:
6432 @section @code{MATMUL} --- matrix multiplication
6434 @cindex matrix multiplication
6435 @cindex product, matrix
6438 @item @emph{Description}:
6439 Performs a matrix multiplication on numeric or logical arguments.
6441 @item @emph{Standard}:
6445 Transformational function
6447 @item @emph{Syntax}:
6448 @code{RESULT = MATMUL(MATRIX_A, MATRIX_B)}
6450 @item @emph{Arguments}:
6451 @multitable @columnfractions .15 .70
6452 @item @var{MATRIX_A} @tab An array of @code{INTEGER(*)},
6453 @code{REAL(*)}, @code{COMPLEX(*)}, or
6454 @code{LOGICAL(*)} type, with a rank of
6456 @item @var{MATRIX_B} @tab An array of @code{INTEGER(*)},
6457 @code{REAL(*)}, or @code{COMPLEX(*)} type if
6458 @var{MATRIX_A} is of a numeric type;
6459 otherwise, an array of @code{LOGICAL(*)}
6460 type. The rank shall be one or two, and the
6461 first (or only) dimension of @var{MATRIX_B}
6462 shall be equal to the last (or only)
6463 dimension of @var{MATRIX_A}.
6466 @item @emph{Return value}:
6467 The matrix product of @var{MATRIX_A} and @var{MATRIX_B}. The type and
6468 kind of the result follow the usual type and kind promotion rules, as
6469 for the @code{*} or @code{.AND.} operators.
6471 @item @emph{See also}:
6477 @section @code{MAX} --- Maximum value of an argument list
6484 @cindex maximum value
6487 @item @emph{Description}:
6488 Returns the argument with the largest (most positive) value.
6490 @item @emph{Standard}:
6496 @item @emph{Syntax}:
6497 @code{RESULT = MAX(A1, A2 [, A3 [, ...]])}
6499 @item @emph{Arguments}:
6500 @multitable @columnfractions .15 .70
6501 @item @var{A1} @tab The type shall be @code{INTEGER(*)} or
6503 @item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
6504 as @var{A1}. (As a GNU extension,
6505 arguments of different kinds are
6509 @item @emph{Return value}:
6510 The return value corresponds to the maximum value among the arguments,
6511 and has the same type and kind as the first argument.
6513 @item @emph{Specific names}:
6514 @multitable @columnfractions .20 .20 .20 .25
6515 @item Name @tab Argument @tab Return type @tab Standard
6516 @item @code{MAX0(I)} @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)} @tab F77 and later
6517 @item @code{AMAX0(I)} @tab @code{INTEGER(4) I} @tab @code{REAL(MAX(X))} @tab F77 and later
6518 @item @code{MAX1(X)} @tab @code{REAL(*) X} @tab @code{INT(MAX(X))} @tab F77 and later
6519 @item @code{AMAX1(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab F77 and later
6520 @item @code{DMAX1(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
6523 @item @emph{See also}:
6524 @ref{MAXLOC} @ref{MAXVAL}, @ref{MIN}
6531 @section @code{MAXEXPONENT} --- Maximum exponent of a real kind
6532 @fnindex MAXEXPONENT
6533 @cindex model representation, maximum exponent
6536 @item @emph{Description}:
6537 @code{MAXEXPONENT(X)} returns the maximum exponent in the model of the
6540 @item @emph{Standard}:
6546 @item @emph{Syntax}:
6547 @code{RESULT = MAXEXPONENT(X)}
6549 @item @emph{Arguments}:
6550 @multitable @columnfractions .15 .70
6551 @item @var{X} @tab Shall be of type @code{REAL}.
6554 @item @emph{Return value}:
6555 The return value is of type @code{INTEGER} and of the default integer
6558 @item @emph{Example}:
6564 print *, minexponent(x), maxexponent(x)
6565 print *, minexponent(y), maxexponent(y)
6566 end program exponents
6573 @section @code{MAXLOC} --- Location of the maximum value within an array
6575 @cindex array, location of maximum element
6578 @item @emph{Description}:
6579 Determines the location of the element in the array with the maximum
6580 value, or, if the @var{DIM} argument is supplied, determines the
6581 locations of the maximum element along each row of the array in the
6582 @var{DIM} direction. If @var{MASK} is present, only the elements for
6583 which @var{MASK} is @code{.TRUE.} are considered. If more than one
6584 element in the array has the maximum value, the location returned is
6585 that of the first such element in array element order. If the array has
6586 zero size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
6587 the result is an array of zeroes. Similarly, if @var{DIM} is supplied
6588 and all of the elements of @var{MASK} along a given row are zero, the
6589 result value for that row is zero.
6591 @item @emph{Standard}:
6595 Transformational function
6597 @item @emph{Syntax}:
6598 @multitable @columnfractions .80
6599 @item @code{RESULT = MAXLOC(ARRAY, DIM [, MASK])}
6600 @item @code{RESULT = MAXLOC(ARRAY [, MASK])}
6603 @item @emph{Arguments}:
6604 @multitable @columnfractions .15 .70
6605 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER(*)},
6606 @code{REAL(*)}, or @code{CHARACTER(*)}.
6607 @item @var{DIM} @tab (Optional) Shall be a scalar of type
6608 @code{INTEGER(*)}, with a value between one
6609 and the rank of @var{ARRAY}, inclusive. It
6610 may not be an optional dummy argument.
6611 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL(*)},
6612 and conformable with @var{ARRAY}.
6615 @item @emph{Return value}:
6616 If @var{DIM} is absent, the result is a rank-one array with a length
6617 equal to the rank of @var{ARRAY}. If @var{DIM} is present, the result
6618 is an array with a rank one less than the rank of @var{ARRAY}, and a
6619 size corresponding to the size of @var{ARRAY} with the @var{DIM}
6620 dimension removed. If @var{DIM} is present and @var{ARRAY} has a rank
6621 of one, the result is a scalar. In all cases, the result is of default
6622 @code{INTEGER} type.
6624 @item @emph{See also}:
6625 @ref{MAX}, @ref{MAXVAL}
6632 @section @code{MAXVAL} --- Maximum value of an array
6634 @cindex array, maximum value
6635 @cindex maximum value
6638 @item @emph{Description}:
6639 Determines the maximum value of the elements in an array value, or, if
6640 the @var{DIM} argument is supplied, determines the maximum value along
6641 each row of the array in the @var{DIM} direction. If @var{MASK} is
6642 present, only the elements for which @var{MASK} is @code{.TRUE.} are
6643 considered. If the array has zero size, or all of the elements of
6644 @var{MASK} are @code{.FALSE.}, then the result is the most negative
6645 number of the type and kind of @var{ARRAY} if @var{ARRAY} is numeric, or
6646 a string of nulls if @var{ARRAY} is of character type.
6648 @item @emph{Standard}:
6652 Transformational function
6654 @item @emph{Syntax}:
6655 @multitable @columnfractions .80
6656 @item @code{RESULT = MAXVAL(ARRAY, DIM [, MASK])}
6657 @item @code{RESULT = MAXVAL(ARRAY [, MASK])}
6660 @item @emph{Arguments}:
6661 @multitable @columnfractions .15 .70
6662 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER(*)},
6663 @code{REAL(*)}, or @code{CHARACTER(*)}.
6664 @item @var{DIM} @tab (Optional) Shall be a scalar of type
6665 @code{INTEGER(*)}, with a value between one
6666 and the rank of @var{ARRAY}, inclusive. It
6667 may not be an optional dummy argument.
6668 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL(*)},
6669 and conformable with @var{ARRAY}.
6672 @item @emph{Return value}:
6673 If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
6674 is a scalar. If @var{DIM} is present, the result is an array with a
6675 rank one less than the rank of @var{ARRAY}, and a size corresponding to
6676 the size of @var{ARRAY} with the @var{DIM} dimension removed. In all
6677 cases, the result is of the same type and kind as @var{ARRAY}.
6679 @item @emph{See also}:
6680 @ref{MAX}, @ref{MAXLOC}
6686 @section @code{MCLOCK} --- Time function
6688 @cindex time, clock ticks
6692 @item @emph{Description}:
6693 Returns the number of clock ticks since the start of the process, based
6694 on the UNIX function @code{clock(3)}.
6696 This intrinsic is not fully portable, such as to systems with 32-bit
6697 @code{INTEGER} types but supporting times wider than 32 bits. Therefore,
6698 the values returned by this intrinsic might be, or become, negative, or
6699 numerically less than previous values, during a single run of the
6702 @item @emph{Standard}:
6706 Non-elemental function
6708 @item @emph{Syntax}:
6709 @code{RESULT = MCLOCK()}
6711 @item @emph{Return value}:
6712 The return value is a scalar of type @code{INTEGER(4)}, equal to the
6713 number of clock ticks since the start of the process, or @code{-1} if
6714 the system does not support @code{clock(3)}.
6716 @item @emph{See also}:
6717 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME}
6724 @section @code{MCLOCK8} --- Time function (64-bit)
6726 @cindex time, clock ticks
6730 @item @emph{Description}:
6731 Returns the number of clock ticks since the start of the process, based
6732 on the UNIX function @code{clock(3)}.
6734 @emph{Warning:} this intrinsic does not increase the range of the timing
6735 values over that returned by @code{clock(3)}. On a system with a 32-bit
6736 @code{clock(3)}, @code{MCLOCK8()} will return a 32-bit value, even though
6737 it is converted to a 64-bit @code{INTEGER(8)} value. That means
6738 overflows of the 32-bit value can still occur. Therefore, the values
6739 returned by this intrinsic might be or become negative or numerically
6740 less than previous values during a single run of the compiled program.
6742 @item @emph{Standard}:
6746 Non-elemental function
6748 @item @emph{Syntax}:
6749 @code{RESULT = MCLOCK8()}
6751 @item @emph{Return value}:
6752 The return value is a scalar of type @code{INTEGER(8)}, equal to the
6753 number of clock ticks since the start of the process, or @code{-1} if
6754 the system does not support @code{clock(3)}.
6756 @item @emph{See also}:
6757 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME8}
6764 @section @code{MERGE} --- Merge variables
6766 @cindex array, merge arrays
6767 @cindex array, combine arrays
6770 @item @emph{Description}:
6771 Select values from two arrays according to a logical mask. The result
6772 is equal to @var{TSOURCE} if @var{MASK} is @code{.TRUE.}, or equal to
6773 @var{FSOURCE} if it is @code{.FALSE.}.
6775 @item @emph{Standard}:
6781 @item @emph{Syntax}:
6782 @code{RESULT = MERGE(TSOURCE, FSOURCE, MASK)}
6784 @item @emph{Arguments}:
6785 @multitable @columnfractions .15 .70
6786 @item @var{TSOURCE} @tab May be of any type.
6787 @item @var{FSOURCE} @tab Shall be of the same type and type parameters
6789 @item @var{MASK} @tab Shall be of type @code{LOGICAL(*)}.
6792 @item @emph{Return value}:
6793 The result is of the same type and type parameters as @var{TSOURCE}.
6800 @section @code{MIN} --- Minimum value of an argument list
6807 @cindex minimum value
6810 @item @emph{Description}:
6811 Returns the argument with the smallest (most negative) value.
6813 @item @emph{Standard}:
6819 @item @emph{Syntax}:
6820 @code{RESULT = MIN(A1, A2 [, A3, ...])}
6822 @item @emph{Arguments}:
6823 @multitable @columnfractions .15 .70
6824 @item @var{A1} @tab The type shall be @code{INTEGER(*)} or
6826 @item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
6827 as @var{A1}. (As a GNU extension,
6828 arguments of different kinds are
6832 @item @emph{Return value}:
6833 The return value corresponds to the maximum value among the arguments,
6834 and has the same type and kind as the first argument.
6836 @item @emph{Specific names}:
6837 @multitable @columnfractions .20 .20 .20 .25
6838 @item Name @tab Argument @tab Return type @tab Standard
6839 @item @code{MIN0(I)} @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)} @tab F77 and later
6840 @item @code{AMIN0(I)} @tab @code{INTEGER(4) I} @tab @code{REAL(MIN(X))} @tab F77 and later
6841 @item @code{MIN1(X)} @tab @code{REAL(*) X} @tab @code{INT(MIN(X))} @tab F77 and later
6842 @item @code{AMIN1(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab F77 and later
6843 @item @code{DMIN1(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
6846 @item @emph{See also}:
6847 @ref{MAX}, @ref{MINLOC}, @ref{MINVAL}
6853 @section @code{MINEXPONENT} --- Minimum exponent of a real kind
6854 @fnindex MINEXPONENT
6855 @cindex model representation, minimum exponent
6858 @item @emph{Description}:
6859 @code{MINEXPONENT(X)} returns the minimum exponent in the model of the
6862 @item @emph{Standard}:
6868 @item @emph{Syntax}:
6869 @code{RESULT = MINEXPONENT(X)}
6871 @item @emph{Arguments}:
6872 @multitable @columnfractions .15 .70
6873 @item @var{X} @tab Shall be of type @code{REAL}.
6876 @item @emph{Return value}:
6877 The return value is of type @code{INTEGER} and of the default integer
6880 @item @emph{Example}:
6881 See @code{MAXEXPONENT} for an example.
6887 @section @code{MINLOC} --- Location of the minimum value within an array
6889 @cindex array, location of minimum element
6892 @item @emph{Description}:
6893 Determines the location of the element in the array with the minimum
6894 value, or, if the @var{DIM} argument is supplied, determines the
6895 locations of the minimum element along each row of the array in the
6896 @var{DIM} direction. If @var{MASK} is present, only the elements for
6897 which @var{MASK} is @code{.TRUE.} are considered. If more than one
6898 element in the array has the minimum value, the location returned is
6899 that of the first such element in array element order. If the array has
6900 zero size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
6901 the result is an array of zeroes. Similarly, if @var{DIM} is supplied
6902 and all of the elements of @var{MASK} along a given row are zero, the
6903 result value for that row is zero.
6905 @item @emph{Standard}:
6909 Transformational function
6911 @item @emph{Syntax}:
6912 @multitable @columnfractions .80
6913 @item @code{RESULT = MINLOC(ARRAY, DIM [, MASK])}
6914 @item @code{RESULT = MINLOC(ARRAY [, MASK])}
6917 @item @emph{Arguments}:
6918 @multitable @columnfractions .15 .70
6919 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER(*)},
6920 @code{REAL(*)}, or @code{CHARACTER(*)}.
6921 @item @var{DIM} @tab (Optional) Shall be a scalar of type
6922 @code{INTEGER(*)}, with a value between one
6923 and the rank of @var{ARRAY}, inclusive. It
6924 may not be an optional dummy argument.
6925 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL(*)},
6926 and conformable with @var{ARRAY}.
6929 @item @emph{Return value}:
6930 If @var{DIM} is absent, the result is a rank-one array with a length
6931 equal to the rank of @var{ARRAY}. If @var{DIM} is present, the result
6932 is an array with a rank one less than the rank of @var{ARRAY}, and a
6933 size corresponding to the size of @var{ARRAY} with the @var{DIM}
6934 dimension removed. If @var{DIM} is present and @var{ARRAY} has a rank
6935 of one, the result is a scalar. In all cases, the result is of default
6936 @code{INTEGER} type.
6938 @item @emph{See also}:
6939 @ref{MIN}, @ref{MINVAL}
6946 @section @code{MINVAL} --- Minimum value of an array
6948 @cindex array, minmum value
6949 @cindex minimum value
6952 @item @emph{Description}:
6953 Determines the minimum value of the elements in an array value, or, if
6954 the @var{DIM} argument is supplied, determines the minimum value along
6955 each row of the array in the @var{DIM} direction. If @var{MASK} is
6956 present, only the elements for which @var{MASK} is @code{.TRUE.} are
6957 considered. If the array has zero size, or all of the elements of
6958 @var{MASK} are @code{.FALSE.}, then the result is @code{HUGE(ARRAY)} if
6959 @var{ARRAY} is numeric, or a string of @code{CHAR(255)} characters if
6960 @var{ARRAY} is of character type.
6962 @item @emph{Standard}:
6966 Transformational function
6968 @item @emph{Syntax}:
6969 @multitable @columnfractions .80
6970 @item @code{RESULT = MINVAL(ARRAY, DIM [, MASK])}
6971 @item @code{RESULT = MINVAL(ARRAY [, MASK])}
6974 @item @emph{Arguments}:
6975 @multitable @columnfractions .15 .70
6976 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER(*)},
6977 @code{REAL(*)}, or @code{CHARACTER(*)}.
6978 @item @var{DIM} @tab (Optional) Shall be a scalar of type
6979 @code{INTEGER(*)}, with a value between one
6980 and the rank of @var{ARRAY}, inclusive. It
6981 may not be an optional dummy argument.
6982 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL(*)},
6983 and conformable with @var{ARRAY}.
6986 @item @emph{Return value}:
6987 If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
6988 is a scalar. If @var{DIM} is present, the result is an array with a
6989 rank one less than the rank of @var{ARRAY}, and a size corresponding to
6990 the size of @var{ARRAY} with the @var{DIM} dimension removed. In all
6991 cases, the result is of the same type and kind as @var{ARRAY}.
6993 @item @emph{See also}:
6994 @ref{MIN}, @ref{MINLOC}
7001 @section @code{MOD} --- Remainder function
7006 @cindex division, remainder
7009 @item @emph{Description}:
7010 @code{MOD(A,P)} computes the remainder of the division of A by P. It is
7011 calculated as @code{A - (INT(A/P) * P)}.
7013 @item @emph{Standard}:
7019 @item @emph{Syntax}:
7020 @code{RESULT = MOD(A, P)}
7022 @item @emph{Arguments}:
7023 @multitable @columnfractions .15 .70
7024 @item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL}
7025 @item @var{P} @tab Shall be a scalar of the same type as @var{A} and not
7029 @item @emph{Return value}:
7030 The kind of the return value is the result of cross-promoting
7031 the kinds of the arguments.
7033 @item @emph{Example}:
7037 print *, mod(17.5,5.5)
7038 print *, mod(17.5d0,5.5)
7039 print *, mod(17.5,5.5d0)
7042 print *, mod(-17.5,5.5)
7043 print *, mod(-17.5d0,5.5)
7044 print *, mod(-17.5,5.5d0)
7047 print *, mod(17.5,-5.5)
7048 print *, mod(17.5d0,-5.5)
7049 print *, mod(17.5,-5.5d0)
7050 end program test_mod
7053 @item @emph{Specific names}:
7054 @multitable @columnfractions .20 .20 .20 .25
7055 @item Name @tab Arguments @tab Return type @tab Standard
7056 @item @code{AMOD(A,P)} @tab @code{REAL(4)} @tab @code{REAL(4)} @tab F95 and later
7057 @item @code{DMOD(A,P)} @tab @code{REAL(8)} @tab @code{REAL(8)} @tab F95 and later
7064 @section @code{MODULO} --- Modulo function
7067 @cindex division, modulo
7070 @item @emph{Description}:
7071 @code{MODULO(A,P)} computes the @var{A} modulo @var{P}.
7073 @item @emph{Standard}:
7079 @item @emph{Syntax}:
7080 @code{RESULT = MODULO(A, P)}
7082 @item @emph{Arguments}:
7083 @multitable @columnfractions .15 .70
7084 @item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL}
7085 @item @var{P} @tab Shall be a scalar of the same type and kind as @var{A}
7088 @item @emph{Return value}:
7089 The type and kind of the result are those of the arguments.
7091 @item If @var{A} and @var{P} are of type @code{INTEGER}:
7092 @code{MODULO(A,P)} has the value @var{R} such that @code{A=Q*P+R}, where
7093 @var{Q} is an integer and @var{R} is between 0 (inclusive) and @var{P}
7095 @item If @var{A} and @var{P} are of type @code{REAL}:
7096 @code{MODULO(A,P)} has the value of @code{A - FLOOR (A / P) * P}.
7098 In all cases, if @var{P} is zero the result is processor-dependent.
7100 @item @emph{Example}:
7103 print *, modulo(17,3)
7104 print *, modulo(17.5,5.5)
7106 print *, modulo(-17,3)
7107 print *, modulo(-17.5,5.5)
7109 print *, modulo(17,-3)
7110 print *, modulo(17.5,-5.5)
7119 @section @code{MOVE_ALLOC} --- Move allocation from one object to another
7121 @cindex moving allocation
7122 @cindex allocation, moving
7125 @item @emph{Description}:
7126 @code{MOVE_ALLOC(SRC, DEST)} moves the allocation from @var{SRC} to
7127 @var{DEST}. @var{SRC} will become deallocated in the process.
7129 @item @emph{Standard}:
7135 @item @emph{Syntax}:
7136 @code{CALL MOVE_ALLOC(SRC, DEST)}
7138 @item @emph{Arguments}:
7139 @multitable @columnfractions .15 .70
7140 @item @var{SRC} @tab @code{ALLOCATABLE}, @code{INTENT(INOUT)}, may be
7141 of any type and kind.
7142 @item @var{DEST} @tab @code{ALLOCATABLE}, @code{INTENT(OUT)}, shall be
7143 of the same type, kind and rank as @var{SRC}
7146 @item @emph{Return value}:
7149 @item @emph{Example}:
7151 program test_move_alloc
7152 integer, allocatable :: a(:), b(:)
7156 call move_alloc(a, b)
7157 print *, allocated(a), allocated(b)
7159 end program test_move_alloc
7166 @section @code{MVBITS} --- Move bits from one integer to another
7171 @item @emph{Description}:
7172 Moves @var{LEN} bits from positions @var{FROMPOS} through
7173 @code{FROMPOS+LEN-1} of @var{FROM} to positions @var{TOPOS} through
7174 @code{TOPOS+LEN-1} of @var{TO}. The portion of argument @var{TO} not
7175 affected by the movement of bits is unchanged. The values of
7176 @code{FROMPOS+LEN-1} and @code{TOPOS+LEN-1} must be less than
7177 @code{BIT_SIZE(FROM)}.
7179 @item @emph{Standard}:
7185 @item @emph{Syntax}:
7186 @code{RESULT = MVBITS(FROM, FROMPOS, LEN, TO, TOPOS)}
7188 @item @emph{Arguments}:
7189 @multitable @columnfractions .15 .70
7190 @item @var{FROM} @tab The type shall be @code{INTEGER(*)}.
7191 @item @var{FROMPOS} @tab The type shall be @code{INTEGER(*)}.
7192 @item @var{LEN} @tab The type shall be @code{INTEGER(*)}.
7193 @item @var{TO} @tab The type shall be @code{INTEGER(*)}, of the
7194 same kind as @var{FROM}.
7195 @item @var{TOPOS} @tab The type shall be @code{INTEGER(*)}.
7198 @item @emph{Return value}:
7199 The return value is of type @code{INTEGER(*)} and of the same kind as
7202 @item @emph{See also}:
7203 @ref{IBCLR}, @ref{IBSET}, @ref{IBITS}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
7210 @section @code{NEAREST} --- Nearest representable number
7212 @cindex real number, nearest different
7213 @cindex floating point, nearest different
7216 @item @emph{Description}:
7217 @code{NEAREST(X, S)} returns the processor-representable number nearest
7218 to @code{X} in the direction indicated by the sign of @code{S}.
7220 @item @emph{Standard}:
7226 @item @emph{Syntax}:
7227 @code{RESULT = NEAREST(X, S)}
7229 @item @emph{Arguments}:
7230 @multitable @columnfractions .15 .70
7231 @item @var{X} @tab Shall be of type @code{REAL}.
7232 @item @var{S} @tab (Optional) shall be of type @code{REAL} and
7236 @item @emph{Return value}:
7237 The return value is of the same type as @code{X}. If @code{S} is
7238 positive, @code{NEAREST} returns the processor-representable number
7239 greater than @code{X} and nearest to it. If @code{S} is negative,
7240 @code{NEAREST} returns the processor-representable number smaller than
7241 @code{X} and nearest to it.
7243 @item @emph{Example}:
7245 program test_nearest
7247 x = nearest(42.0, 1.0)
7248 y = nearest(42.0, -1.0)
7249 write (*,"(3(G20.15))") x, y, x - y
7250 end program test_nearest
7257 @section @code{NEW_LINE} --- New line character
7260 @cindex output, newline
7263 @item @emph{Description}:
7264 @code{NEW_LINE(C)} returns the new-line character.
7266 @item @emph{Standard}:
7272 @item @emph{Syntax}:
7273 @code{RESULT = NEW_LINE(C)}
7275 @item @emph{Arguments}:
7276 @multitable @columnfractions .15 .70
7277 @item @var{C} @tab The argument shall be a scalar or array of the
7278 type @code{CHARACTER}.
7281 @item @emph{Return value}:
7282 Returns a @var{CHARACTER} scalar of length one with the new-line character of
7283 the same kind as parameter @var{C}.
7285 @item @emph{Example}:
7289 write(*,'(A)') 'This is record 1.'//NEW_LINE('A')//'This is record 2.'
7297 @section @code{NINT} --- Nearest whole number
7300 @cindex rounding, nearest whole number
7303 @item @emph{Description}:
7304 @code{NINT(X)} rounds its argument to the nearest whole number.
7306 @item @emph{Standard}:
7312 @item @emph{Syntax}:
7313 @code{RESULT = NINT(X)}
7315 @item @emph{Arguments}:
7316 @multitable @columnfractions .15 .70
7317 @item @var{X} @tab The type of the argument shall be @code{REAL}.
7320 @item @emph{Return value}:
7321 Returns @var{A} with the fractional portion of its magnitude eliminated by
7322 rounding to the nearest whole number and with its sign preserved,
7323 converted to an @code{INTEGER} of the default kind.
7325 @item @emph{Example}:
7332 print *, nint(x4), idnint(x8)
7333 end program test_nint
7336 @item @emph{Specific names}:
7337 @multitable @columnfractions .25 .25 .25
7338 @item Name @tab Argument @tab Standard
7339 @item @code{IDNINT(X)} @tab @code{REAL(8)} @tab F95 and later
7342 @item @emph{See also}:
7343 @ref{CEILING}, @ref{FLOOR}
7350 @section @code{NOT} --- Logical negation
7352 @cindex bits, negate
7353 @cindex bitwise logical not
7354 @cindex logical not, bitwise
7357 @item @emph{Description}:
7358 @code{NOT} returns the bitwise boolean inverse of @var{I}.
7360 @item @emph{Standard}:
7366 @item @emph{Syntax}:
7367 @code{RESULT = NOT(I)}
7369 @item @emph{Arguments}:
7370 @multitable @columnfractions .15 .70
7371 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
7374 @item @emph{Return value}:
7375 The return type is @code{INTEGER(*)}, of the same kind as the
7378 @item @emph{See also}:
7379 @ref{IAND}, @ref{IEOR}, @ref{IOR}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}
7386 @section @code{NULL} --- Function that returns an disassociated pointer
7388 @cindex pointer, status
7389 @cindex pointer, disassociated
7392 @item @emph{Description}:
7393 Returns a disassociated pointer.
7395 If @var{MOLD} is present, a dissassociated pointer of the same type is
7396 returned, otherwise the type is determined by context.
7398 In Fortran 95, @var{MOLD} is optional. Please note that F2003 includes
7399 cases where it is required.
7401 @item @emph{Standard}:
7405 Transformational function
7407 @item @emph{Syntax}:
7408 @code{PTR => NULL([MOLD])}
7410 @item @emph{Arguments}:
7411 @multitable @columnfractions .15 .70
7412 @item @var{MOLD} @tab (Optional) shall be a pointer of any association
7413 status and of any type.
7416 @item @emph{Return value}:
7417 A disassociated pointer.
7419 @item @emph{Example}:
7421 REAL, POINTER, DIMENSION(:) :: VEC => NULL ()
7424 @item @emph{See also}:
7431 @section @code{OR} --- Bitwise logical OR
7433 @cindex bitwise logical or
7434 @cindex logical or, bitwise
7437 @item @emph{Description}:
7438 Bitwise logical @code{OR}.
7440 This intrinsic routine is provided for backwards compatibility with
7441 GNU Fortran 77. For integer arguments, programmers should consider
7442 the use of the @ref{IOR} intrinsic defined by the Fortran standard.
7444 @item @emph{Standard}:
7448 Non-elemental function
7450 @item @emph{Syntax}:
7451 @code{RESULT = OR(X, Y)}
7453 @item @emph{Arguments}:
7454 @multitable @columnfractions .15 .70
7455 @item @var{X} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
7456 @item @var{Y} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
7459 @item @emph{Return value}:
7460 The return type is either @code{INTEGER(*)} or @code{LOGICAL}
7461 after cross-promotion of the arguments.
7463 @item @emph{Example}:
7466 LOGICAL :: T = .TRUE., F = .FALSE.
7468 DATA a / Z'F' /, b / Z'3' /
7470 WRITE (*,*) OR(T, T), OR(T, F), OR(F, T), OR(F, F)
7471 WRITE (*,*) OR(a, b)
7475 @item @emph{See also}:
7476 F95 elemental function: @ref{IOR}
7482 @section @code{PACK} --- Pack an array into an array of rank one
7484 @cindex array, packing
7485 @cindex array, reduce dimension
7486 @cindex array, gather elements
7489 @item @emph{Description}:
7490 Stores the elements of @var{ARRAY} in an array of rank one.
7492 The beginning of the resulting array is made up of elements whose @var{MASK}
7493 equals @code{TRUE}. Afterwards, positions are filled with elements taken from
7496 @item @emph{Standard}:
7500 Transformational function
7502 @item @emph{Syntax}:
7503 @code{RESULT = PACK(ARRAY, MASK[,VECTOR]}
7505 @item @emph{Arguments}:
7506 @multitable @columnfractions .15 .70
7507 @item @var{ARRAY} @tab Shall be an array of any type.
7508 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL} and
7509 of the same size as @var{ARRAY}. Alternatively, it may be a @code{LOGICAL}
7511 @item @var{VECTOR} @tab (Optional) shall be an array of the same type
7512 as @var{ARRAY} and of rank one. If present, the number of elements in
7513 @var{VECTOR} shall be equal to or greater than the number of true elements
7514 in @var{MASK}. If @var{MASK} is scalar, the number of elements in
7515 @var{VECTOR} shall be equal to or greater than the number of elements in
7519 @item @emph{Return value}:
7520 The result is an array of rank one and the same type as that of @var{ARRAY}.
7521 If @var{VECTOR} is present, the result size is that of @var{VECTOR}, the
7522 number of @code{TRUE} values in @var{MASK} otherwise.
7524 @item @emph{Example}:
7525 Gathering non-zero elements from an array:
7529 m = (/ 1, 0, 0, 0, 5, 0 /)
7530 WRITE(*, FMT="(6(I0, ' '))") pack(m, m /= 0) ! "1 5"
7534 Gathering non-zero elements from an array and appending elements from @var{VECTOR}:
7538 m = (/ 1, 0, 0, 2 /)
7539 WRITE(*, FMT="(4(I0, ' '))") pack(m, m /= 0, (/ 0, 0, 3, 4 /)) ! "1 2 3 4"
7543 @item @emph{See also}:
7550 @section @code{PERROR} --- Print system error message
7552 @cindex system, error handling
7555 @item @emph{Description}:
7556 Prints (on the C @code{stderr} stream) a newline-terminated error
7557 message corresponding to the last system error. This is prefixed by
7558 @var{STRING}, a colon and a space. See @code{perror(3)}.
7560 @item @emph{Standard}:
7566 @item @emph{Syntax}:
7567 @code{CALL PERROR(STRING)}
7569 @item @emph{Arguments}:
7570 @multitable @columnfractions .15 .70
7571 @item @var{STRING} @tab A scalar of default @code{CHARACTER} type.
7574 @item @emph{See also}:
7581 @section @code{PRECISION} --- Decimal precision of a real kind
7583 @cindex model representation, precision
7586 @item @emph{Description}:
7587 @code{PRECISION(X)} returns the decimal precision in the model of the
7590 @item @emph{Standard}:
7596 @item @emph{Syntax}:
7597 @code{RESULT = PRECISION(X)}
7599 @item @emph{Arguments}:
7600 @multitable @columnfractions .15 .70
7601 @item @var{X} @tab Shall be of type @code{REAL} or @code{COMPLEX}.
7604 @item @emph{Return value}:
7605 The return value is of type @code{INTEGER} and of the default integer
7608 @item @emph{Example}:
7610 program prec_and_range
7611 real(kind=4) :: x(2)
7612 complex(kind=8) :: y
7614 print *, precision(x), range(x)
7615 print *, precision(y), range(y)
7616 end program prec_and_range
7623 @section @code{PRESENT} --- Determine whether an optional dummy argument is specified
7627 @item @emph{Description}:
7628 Determines whether an optional dummy argument is present.
7630 @item @emph{Standard}:
7636 @item @emph{Syntax}:
7637 @code{RESULT = PRESENT(A)}
7639 @item @emph{Arguments}:
7640 @multitable @columnfractions .15 .70
7641 @item @var{A} @tab May be of any type and may be a pointer, scalar or array
7642 value, or a dummy procedure. It shall be the name of an optional dummy argument
7643 accessible within the current subroutine or function.
7646 @item @emph{Return value}:
7647 Returns either @code{TRUE} if the optional argument @var{A} is present, or
7648 @code{FALSE} otherwise.
7650 @item @emph{Example}:
7652 PROGRAM test_present
7653 WRITE(*,*) f(), f(42) ! "F T"
7655 LOGICAL FUNCTION f(x)
7656 INTEGER, INTENT(IN), OPTIONAL :: x
7666 @section @code{PRODUCT} --- Product of array elements
7668 @cindex array, product
7669 @cindex array, multiply elements
7670 @cindex array, conditionally multiply elements
7671 @cindex multiply array elements
7674 @item @emph{Description}:
7675 Multiplies the elements of @var{ARRAY} along dimension @var{DIM} if
7676 the corresponding element in @var{MASK} is @code{TRUE}.
7678 @item @emph{Standard}:
7682 Transformational function
7684 @item @emph{Syntax}:
7685 @code{RESULT = PRODUCT(ARRAY[, MASK])}
7686 @code{RESULT = PRODUCT(ARRAY, DIM[, MASK])}
7688 @item @emph{Arguments}:
7689 @multitable @columnfractions .15 .70
7690 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER(*)},
7691 @code{REAL(*)} or @code{COMPLEX(*)}.
7692 @item @var{DIM} @tab (Optional) shall be a scalar of type
7693 @code{INTEGER} with a value in the range from 1 to n, where n
7694 equals the rank of @var{ARRAY}.
7695 @item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL}
7696 and either be a scalar or an array of the same shape as @var{ARRAY}.
7699 @item @emph{Return value}:
7700 The result is of the same type as @var{ARRAY}.
7702 If @var{DIM} is absent, a scalar with the product of all elements in
7703 @var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals
7704 the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with
7705 dimension @var{DIM} dropped is returned.
7708 @item @emph{Example}:
7710 PROGRAM test_product
7711 INTEGER :: x(5) = (/ 1, 2, 3, 4 ,5 /)
7712 print *, PRODUCT(x) ! all elements, product = 120
7713 print *, PRODUCT(x, MASK=MOD(x, 2)==1) ! odd elements, product = 15
7717 @item @emph{See also}:
7724 @section @code{RADIX} --- Base of a model number
7726 @cindex model representation, base
7727 @cindex model representation, radix
7730 @item @emph{Description}:
7731 @code{RADIX(X)} returns the base of the model representing the entity @var{X}.
7733 @item @emph{Standard}:
7739 @item @emph{Syntax}:
7740 @code{RESULT = RADIX(X)}
7742 @item @emph{Arguments}:
7743 @multitable @columnfractions .15 .70
7744 @item @var{X} @tab Shall be of type @code{INTEGER} or @code{REAL}
7747 @item @emph{Return value}:
7748 The return value is a scalar of type @code{INTEGER} and of the default
7751 @item @emph{Example}:
7754 print *, "The radix for the default integer kind is", radix(0)
7755 print *, "The radix for the default real kind is", radix(0.0)
7756 end program test_radix
7764 @section @code{RAN} --- Real pseudo-random number
7766 @cindex random number generation
7769 @item @emph{Description}:
7770 For compatibility with HP FORTRAN 77/iX, the @code{RAN} intrinsic is
7771 provided as an alias for @code{RAND}. See @ref{RAND} for complete
7774 @item @emph{Standard}:
7778 Non-elemental function
7780 @item @emph{See also}:
7781 @ref{RAND}, @ref{RANDOM_NUMBER}
7787 @section @code{RAND} --- Real pseudo-random number
7789 @cindex random number generation
7792 @item @emph{Description}:
7793 @code{RAND(FLAG)} returns a pseudo-random number from a uniform
7794 distribution between 0 and 1. If @var{FLAG} is 0, the next number
7795 in the current sequence is returned; if @var{FLAG} is 1, the generator
7796 is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
7797 it is used as a new seed with @code{SRAND}.
7799 @item @emph{Standard}:
7803 Non-elemental function
7805 @item @emph{Syntax}:
7806 @code{RESULT = RAND(FLAG)}
7808 @item @emph{Arguments}:
7809 @multitable @columnfractions .15 .70
7810 @item @var{FLAG} @tab Shall be a scalar @code{INTEGER} of kind 4.
7813 @item @emph{Return value}:
7814 The return value is of @code{REAL} type and the default kind.
7816 @item @emph{Example}:
7819 integer,parameter :: seed = 86456
7822 print *, rand(), rand(), rand(), rand()
7823 print *, rand(seed), rand(), rand(), rand()
7824 end program test_rand
7827 @item @emph{See also}:
7828 @ref{SRAND}, @ref{RANDOM_NUMBER}
7835 @section @code{RANDOM_NUMBER} --- Pseudo-random number
7836 @fnindex RANDOM_NUMBER
7837 @cindex random number generation
7840 @item @emph{Description}:
7841 Returns a single pseudorandom number or an array of pseudorandom numbers
7842 from the uniform distribution over the range @math{ 0 \leq x < 1}.
7844 @item @emph{Standard}:
7848 Elemental subroutine
7850 @item @emph{Syntax}:
7851 @code{RANDOM_NUMBER(HARVEST)}
7853 @item @emph{Arguments}:
7854 @multitable @columnfractions .15 .70
7855 @item @var{HARVEST} @tab Shall be a scalar or an array of type @code{REAL(*)}.
7858 @item @emph{Example}:
7860 program test_random_number
7862 CALL init_random_seed() ! see example of RANDOM_SEED
7863 CALL RANDOM_NUMBER(r)
7868 The implemented random number generator is thread safe if used within
7869 OpenMP directives, i. e. its state will be consistent while called from
7870 multiple threads. Please note that the currently implemented KISS generator
7871 does not create random numbers in parallel from multiple sources, but in
7872 sequence from a single source. If your OpenMP-enabled application heavily
7873 relies on random numbers, you should consider employing a dedicated parallel
7874 random number generator instead.
7876 @item @emph{See also}:
7883 @section @code{RANDOM_SEED} --- Initialize a pseudo-random number sequence
7884 @fnindex RANDOM_SEED
7885 @cindex random number generation, seeding
7886 @cindex seeding a random number generator
7889 @item @emph{Description}:
7890 Restarts or queries the state of the pseudorandom number generator used by
7891 @code{RANDOM_NUMBER}.
7893 If @code{RANDOM_SEED} is called without arguments, it is initialized to
7894 a default state. The example below shows how to initialize the random
7895 seed based on the system's time.
7897 @item @emph{Standard}:
7903 @item @emph{Syntax}:
7904 @code{CALL RANDOM_SEED(SIZE, PUT, GET)}
7906 @item @emph{Arguments}:
7907 @multitable @columnfractions .15 .70
7908 @item @var{SIZE} @tab (Optional) Shall be a scalar and of type default
7909 @code{INTEGER}, with @code{INTENT(OUT)}. It specifies the minimum size
7910 of the arrays used with the @var{PUT} and @var{GET} arguments.
7911 @item @var{PUT} @tab (Optional) Shall be an array of type default
7912 @code{INTEGER} and rank one. It is @code{INTENT(IN)} and the size of
7913 the array must be larger than or equal to the number returned by the
7914 @var{SIZE} argument.
7915 @item @var{GET} @tab (Optional) Shall be an array of type default
7916 @code{INTEGER} and rank one. It is @code{INTENT(OUT)} and the size
7917 of the array must be larger than or equal to the number returned by
7918 the @var{SIZE} argument.
7921 @item @emph{Example}:
7923 SUBROUTINE init_random_seed()
7924 INTEGER :: i, n, clock
7925 INTEGER, DIMENSION(:), ALLOCATABLE :: seed
7927 CALL RANDOM_SEED(size = n)
7930 CALL SYSTEM_CLOCK(COUNT=clock)
7932 seed = clock + 37 * (/ (i - 1, i = 1, n) /)
7933 CALL RANDOM_SEED(PUT = seed)
7939 @item @emph{See also}:
7946 @section @code{RANGE} --- Decimal exponent range of a real kind
7948 @cindex model representation, range
7951 @item @emph{Description}:
7952 @code{RANGE(X)} returns the decimal exponent range in the model of the
7955 @item @emph{Standard}:
7961 @item @emph{Syntax}:
7962 @code{RESULT = RANGE(X)}
7964 @item @emph{Arguments}:
7965 @multitable @columnfractions .15 .70
7966 @item @var{X} @tab Shall be of type @code{REAL} or @code{COMPLEX}.
7969 @item @emph{Return value}:
7970 The return value is of type @code{INTEGER} and of the default integer
7973 @item @emph{Example}:
7974 See @code{PRECISION} for an example.
7980 @section @code{REAL} --- Convert to real type
7983 @cindex conversion, to real
7984 @cindex complex numbers, real part
7987 @item @emph{Description}:
7988 @code{REAL(X [, KIND])} converts its argument @var{X} to a real type. The
7989 @code{REALPART(X)} function is provided for compatibility with @command{g77},
7990 and its use is strongly discouraged.
7992 @item @emph{Standard}:
7998 @item @emph{Syntax}:
7999 @multitable @columnfractions .80
8000 @item @code{RESULT = REAL(X [, KIND])}
8001 @item @code{RESULT = REALPART(Z)}
8004 @item @emph{Arguments}:
8005 @multitable @columnfractions .15 .70
8006 @item @var{X} @tab Shall be @code{INTEGER(*)}, @code{REAL(*)}, or
8008 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
8009 expression indicating the kind parameter of
8013 @item @emph{Return value}:
8014 These functions return a @code{REAL(*)} variable or array under
8015 the following rules:
8019 @code{REAL(X)} is converted to a default real type if @var{X} is an
8020 integer or real variable.
8022 @code{REAL(X)} is converted to a real type with the kind type parameter
8023 of @var{X} if @var{X} is a complex variable.
8025 @code{REAL(X, KIND)} is converted to a real type with kind type
8026 parameter @var{KIND} if @var{X} is a complex, integer, or real
8030 @item @emph{Example}:
8033 complex :: x = (1.0, 2.0)
8034 print *, real(x), real(x,8), realpart(x)
8035 end program test_real
8038 @item @emph{See also}:
8039 @ref{DBLE}, @ref{DFLOAT}, @ref{FLOAT}
8046 @section @code{RENAME} --- Rename a file
8048 @cindex file system, rename file
8051 @item @emph{Description}:
8052 Renames a file from file @var{PATH1} to @var{PATH2}. A null
8053 character (@code{CHAR(0)}) can be used to mark the end of the names in
8054 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
8055 names are ignored. If the @var{STATUS} argument is supplied, it
8056 contains 0 on success or a nonzero error code upon return; see
8059 This intrinsic is provided in both subroutine and function forms;
8060 however, only one form can be used in any given program unit.
8062 @item @emph{Standard}:
8066 Subroutine, non-elemental function
8068 @item @emph{Syntax}:
8069 @multitable @columnfractions .80
8070 @item @code{CALL RENAME(PATH1, PATH2 [, STATUS])}
8071 @item @code{STATUS = RENAME(PATH1, PATH2)}
8074 @item @emph{Arguments}:
8075 @multitable @columnfractions .15 .70
8076 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
8077 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
8078 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
8081 @item @emph{See also}:
8089 @section @code{REPEAT} --- Repeated string concatenation
8091 @cindex string, repeat
8092 @cindex string, concatenate
8095 @item @emph{Description}:
8096 Concatenates @var{NCOPIES} copies of a string.
8098 @item @emph{Standard}:
8102 Transformational function
8104 @item @emph{Syntax}:
8105 @code{RESULT = REPEAT(STRING, NCOPIES)}
8107 @item @emph{Arguments}:
8108 @multitable @columnfractions .15 .70
8109 @item @var{STRING} @tab Shall be scalar and of type @code{CHARACTER(*)}.
8110 @item @var{NCOPIES} @tab Shall be scalar and of type @code{INTEGER(*)}.
8113 @item @emph{Return value}:
8114 A new scalar of type @code{CHARACTER} built up from @var{NCOPIES} copies
8117 @item @emph{Example}:
8120 write(*,*) repeat("x", 5) ! "xxxxx"
8128 @section @code{RESHAPE} --- Function to reshape an array
8130 @cindex array, change dimensions
8131 @cindex array, transmogrify
8134 @item @emph{Description}:
8135 Reshapes @var{SOURCE} to correspond to @var{SHAPE}. If necessary,
8136 the new array may be padded with elements from @var{PAD} or permuted
8137 as defined by @var{ORDER}.
8139 @item @emph{Standard}:
8143 Transformational function
8145 @item @emph{Syntax}:
8146 @code{RESULT = RESHAPE(SOURCE, SHAPE[, PAD, ORDER])}
8148 @item @emph{Arguments}:
8149 @multitable @columnfractions .15 .70
8150 @item @var{SOURCE} @tab Shall be an array of any type.
8151 @item @var{SHAPE} @tab Shall be of type @code{INTEGER} and an
8152 array of rank one. Its values must be positive or zero.
8153 @item @var{PAD} @tab (Optional) shall be an array of the same
8154 type as @var{SOURCE}.
8155 @item @var{ORDER} @tab (Optional) shall be of type @code{INTEGER}
8156 and an array of the same shape as @var{SHAPE}. Its values shall
8157 be a permutation of the numbers from 1 to n, where n is the size of
8158 @var{SHAPE}. If @var{ORDER} is absent, the natural ordering shall
8162 @item @emph{Return value}:
8163 The result is an array of shape @var{SHAPE} with the same type as
8166 @item @emph{Example}:
8168 PROGRAM test_reshape
8169 INTEGER, DIMENSION(4) :: x
8170 WRITE(*,*) SHAPE(x) ! prints "4"
8171 WRITE(*,*) SHAPE(RESHAPE(x, (/2, 2/))) ! prints "2 2"
8175 @item @emph{See also}:
8182 @section @code{RRSPACING} --- Reciprocal of the relative spacing
8184 @cindex real number, relative spacing
8185 @cindex floating point, relative spacing
8189 @item @emph{Description}:
8190 @code{RRSPACING(X)} returns the reciprocal of the relative spacing of
8191 model numbers near @var{X}.
8193 @item @emph{Standard}:
8199 @item @emph{Syntax}:
8200 @code{RESULT = RRSPACING(X)}
8202 @item @emph{Arguments}:
8203 @multitable @columnfractions .15 .70
8204 @item @var{X} @tab Shall be of type @code{REAL}.
8207 @item @emph{Return value}:
8208 The return value is of the same type and kind as @var{X}.
8209 The value returned is equal to
8210 @code{ABS(FRACTION(X)) * FLOAT(RADIX(X))**DIGITS(X)}.
8212 @item @emph{See also}:
8219 @section @code{RSHIFT} --- Right shift bits
8221 @cindex bits, shift right
8224 @item @emph{Description}:
8225 @code{RSHIFT} returns a value corresponding to @var{I} with all of the
8226 bits shifted right by @var{SHIFT} places. If the absolute value of
8227 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
8228 Bits shifted out from the left end are lost; zeros are shifted in from
8231 This function has been superseded by the @code{ISHFT} intrinsic, which
8232 is standard in Fortran 95 and later.
8234 @item @emph{Standard}:
8240 @item @emph{Syntax}:
8241 @code{RESULT = RSHIFT(I, SHIFT)}
8243 @item @emph{Arguments}:
8244 @multitable @columnfractions .15 .70
8245 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
8246 @item @var{SHIFT} @tab The type shall be @code{INTEGER(*)}.
8249 @item @emph{Return value}:
8250 The return value is of type @code{INTEGER(*)} and of the same kind as
8253 @item @emph{See also}:
8254 @ref{ISHFT}, @ref{ISHFTC}, @ref{LSHIFT}
8261 @section @code{SCALE} --- Scale a real value
8263 @cindex real number, scale
8264 @cindex floating point, scale
8267 @item @emph{Description}:
8268 @code{SCALE(X,I)} returns @code{X * RADIX(X)**I}.
8270 @item @emph{Standard}:
8276 @item @emph{Syntax}:
8277 @code{RESULT = SCALE(X, I)}
8279 @item @emph{Arguments}:
8280 @multitable @columnfractions .15 .70
8281 @item @var{X} @tab The type of the argument shall be a @code{REAL}.
8282 @item @var{I} @tab The type of the argument shall be a @code{INTEGER}.
8285 @item @emph{Return value}:
8286 The return value is of the same type and kind as @var{X}.
8287 Its value is @code{X * RADIX(X)**I}.
8289 @item @emph{Example}:
8292 real :: x = 178.1387e-4
8294 print *, scale(x,i), x*radix(x)**i
8295 end program test_scale
8303 @section @code{SCAN} --- Scan a string for the presence of a set of characters
8305 @cindex string, find subset
8308 @item @emph{Description}:
8309 Scans a @var{STRING} for any of the characters in a @var{SET}
8312 If @var{BACK} is either absent or equals @code{FALSE}, this function
8313 returns the position of the leftmost character of @var{STRING} that is
8314 in @var{SET}. If @var{BACK} equals @code{TRUE}, the rightmost position
8315 is returned. If no character of @var{SET} is found in @var{STRING}, the
8318 @item @emph{Standard}:
8324 @item @emph{Syntax}:
8325 @code{RESULT = SCAN(STRING, SET[, BACK])}
8327 @item @emph{Arguments}:
8328 @multitable @columnfractions .15 .70
8329 @item @var{STRING} @tab Shall be of type @code{CHARACTER(*)}.
8330 @item @var{SET} @tab Shall be of type @code{CHARACTER(*)}.
8331 @item @var{BACK} @tab (Optional) shall be of type @code{LOGICAL}.
8334 @item @emph{Return value}:
8335 The return value is of type @code{INTEGER} and of the default
8338 @item @emph{Example}:
8341 WRITE(*,*) SCAN("FORTRAN", "AO") ! 2, found 'O'
8342 WRITE(*,*) SCAN("FORTRAN", "AO", .TRUE.) ! 6, found 'A'
8343 WRITE(*,*) SCAN("FORTRAN", "C++") ! 0, found none
8347 @item @emph{See also}:
8348 @ref{INDEX}, @ref{VERIFY}
8354 @section @code{SECNDS} --- Time function
8356 @cindex time, elapsed
8357 @cindex elapsed time
8360 @item @emph{Description}:
8361 @code{SECNDS(X)} gets the time in seconds from the real-time system clock.
8362 @var{X} is a reference time, also in seconds. If this is zero, the time in
8363 seconds from midnight is returned. This function is non-standard and its
8366 @item @emph{Standard}:
8370 Non-elemental function
8372 @item @emph{Syntax}:
8373 @code{RESULT = SECNDS (X)}
8375 @item @emph{Arguments}:
8376 @multitable @columnfractions .15 .70
8377 @item @var{T} @tab Shall be of type @code{REAL(4)}.
8378 @item @var{X} @tab Shall be of type @code{REAL(4)}.
8381 @item @emph{Return value}:
8384 @item @emph{Example}:
8389 print *, secnds (0.0) ! seconds since midnight
8390 t1 = secnds (0.0) ! reference time
8391 do i = 1, 10000000 ! do something
8393 t2 = secnds (t1) ! elapsed time
8394 print *, "Something took ", t2, " seconds."
8395 end program test_secnds
8402 @section @code{SECOND} --- CPU time function
8404 @cindex time, elapsed
8405 @cindex elapsed time
8408 @item @emph{Description}:
8409 Returns a @code{REAL(4)} value representing the elapsed CPU time in
8410 seconds. This provides the same functionality as the standard
8411 @code{CPU_TIME} intrinsic, and is only included for backwards
8414 This intrinsic is provided in both subroutine and function forms;
8415 however, only one form can be used in any given program unit.
8417 @item @emph{Standard}:
8421 Subroutine, non-elemental function
8423 @item @emph{Syntax}:
8424 @multitable @columnfractions .80
8425 @item @code{CALL SECOND(TIME)}
8426 @item @code{TIME = SECOND()}
8429 @item @emph{Arguments}:
8430 @multitable @columnfractions .15 .70
8431 @item @var{TIME} @tab Shall be of type @code{REAL(4)}.
8434 @item @emph{Return value}:
8435 In either syntax, @var{TIME} is set to the process's current runtime in
8438 @item @emph{See also}:
8445 @node SELECTED_INT_KIND
8446 @section @code{SELECTED_INT_KIND} --- Choose integer kind
8447 @fnindex SELECTED_INT_KIND
8448 @cindex integer kind
8449 @cindex kind, integer
8452 @item @emph{Description}:
8453 @code{SELECTED_INT_KIND(I)} return the kind value of the smallest integer
8454 type that can represent all values ranging from @math{-10^I} (exclusive)
8455 to @math{10^I} (exclusive). If there is no integer kind that accommodates
8456 this range, @code{SELECTED_INT_KIND} returns @math{-1}.
8458 @item @emph{Standard}:
8462 Transformational function
8464 @item @emph{Syntax}:
8465 @code{RESULT = SELECTED_INT_KIND(I)}
8467 @item @emph{Arguments}:
8468 @multitable @columnfractions .15 .70
8469 @item @var{I} @tab Shall be a scalar and of type @code{INTEGER}.
8472 @item @emph{Example}:
8474 program large_integers
8475 integer,parameter :: k5 = selected_int_kind(5)
8476 integer,parameter :: k15 = selected_int_kind(15)
8477 integer(kind=k5) :: i5
8478 integer(kind=k15) :: i15
8480 print *, huge(i5), huge(i15)
8482 ! The following inequalities are always true
8483 print *, huge(i5) >= 10_k5**5-1
8484 print *, huge(i15) >= 10_k15**15-1
8485 end program large_integers
8491 @node SELECTED_REAL_KIND
8492 @section @code{SELECTED_REAL_KIND} --- Choose real kind
8493 @fnindex SELECTED_REAL_KIND
8498 @item @emph{Description}:
8499 @code{SELECTED_REAL_KIND(P,R)} return the kind value of a real data type
8500 with decimal precision greater of at least @code{P} digits and exponent
8501 range greater at least @code{R}.
8503 @item @emph{Standard}:
8507 Transformational function
8509 @item @emph{Syntax}:
8510 @code{RESULT = SELECTED_REAL_KIND(P, R)}
8512 @item @emph{Arguments}:
8513 @multitable @columnfractions .15 .70
8514 @item @var{P} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
8515 @item @var{R} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
8517 At least one argument shall be present.
8519 @item @emph{Return value}:
8521 @code{SELECTED_REAL_KIND} returns the value of the kind type parameter of
8522 a real data type with decimal precision of at least @code{P} digits and a
8523 decimal exponent range of at least @code{R}. If more than one real data
8524 type meet the criteria, the kind of the data type with the smallest
8525 decimal precision is returned. If no real data type matches the criteria,
8528 @item -1 if the processor does not support a real data type with a
8529 precision greater than or equal to @code{P}
8530 @item -2 if the processor does not support a real type with an exponent
8531 range greater than or equal to @code{R}
8532 @item -3 if neither is supported.
8535 @item @emph{Example}:
8538 integer,parameter :: p6 = selected_real_kind(6)
8539 integer,parameter :: p10r100 = selected_real_kind(10,100)
8540 integer,parameter :: r400 = selected_real_kind(r=400)
8542 real(kind=p10r100) :: y
8543 real(kind=r400) :: z
8545 print *, precision(x), range(x)
8546 print *, precision(y), range(y)
8547 print *, precision(z), range(z)
8548 end program real_kinds
8555 @section @code{SET_EXPONENT} --- Set the exponent of the model
8556 @fnindex SET_EXPONENT
8557 @cindex real number, set exponent
8558 @cindex floating point, set exponent
8561 @item @emph{Description}:
8562 @code{SET_EXPONENT(X, I)} returns the real number whose fractional part
8563 is that that of @var{X} and whose exponent part is @var{I}.
8565 @item @emph{Standard}:
8571 @item @emph{Syntax}:
8572 @code{RESULT = SET_EXPONENT(X, I)}
8574 @item @emph{Arguments}:
8575 @multitable @columnfractions .15 .70
8576 @item @var{X} @tab Shall be of type @code{REAL}.
8577 @item @var{I} @tab Shall be of type @code{INTEGER}.
8580 @item @emph{Return value}:
8581 The return value is of the same type and kind as @var{X}.
8582 The real number whose fractional part
8583 is that that of @var{X} and whose exponent part if @var{I} is returned;
8584 it is @code{FRACTION(X) * RADIX(X)**I}.
8586 @item @emph{Example}:
8589 REAL :: x = 178.1387e-4
8591 PRINT *, SET_EXPONENT(x, i), FRACTION(x) * RADIX(x)**i
8600 @section @code{SHAPE} --- Determine the shape of an array
8602 @cindex array, shape
8605 @item @emph{Description}:
8606 Determines the shape of an array.
8608 @item @emph{Standard}:
8614 @item @emph{Syntax}:
8615 @code{RESULT = SHAPE(SOURCE)}
8617 @item @emph{Arguments}:
8618 @multitable @columnfractions .15 .70
8619 @item @var{SOURCE} @tab Shall be an array or scalar of any type.
8620 If @var{SOURCE} is a pointer it must be associated and allocatable
8621 arrays must be allocated.
8624 @item @emph{Return value}:
8625 An @code{INTEGER} array of rank one with as many elements as @var{SOURCE}
8626 has dimensions. The elements of the resulting array correspond to the extend
8627 of @var{SOURCE} along the respective dimensions. If @var{SOURCE} is a scalar,
8628 the result is the rank one array of size zero.
8630 @item @emph{Example}:
8633 INTEGER, DIMENSION(-1:1, -1:2) :: A
8634 WRITE(*,*) SHAPE(A) ! (/ 3, 4 /)
8635 WRITE(*,*) SIZE(SHAPE(42)) ! (/ /)
8639 @item @emph{See also}:
8640 @ref{RESHAPE}, @ref{SIZE}
8646 @section @code{SIGN} --- Sign copying function
8650 @cindex sign copying
8653 @item @emph{Description}:
8654 @code{SIGN(A,B)} returns the value of @var{A} with the sign of @var{B}.
8656 @item @emph{Standard}:
8662 @item @emph{Syntax}:
8663 @code{RESULT = SIGN(A, B)}
8665 @item @emph{Arguments}:
8666 @multitable @columnfractions .15 .70
8667 @item @var{A} @tab Shall be of type @code{INTEGER} or @code{REAL}
8668 @item @var{B} @tab Shall be of the same type and kind as @var{A}
8671 @item @emph{Return value}:
8672 The kind of the return value is that of @var{A} and @var{B}.
8673 If @math{B\ge 0} then the result is @code{ABS(A)}, else
8674 it is @code{-ABS(A)}.
8676 @item @emph{Example}:
8679 print *, sign(-12,1)
8680 print *, sign(-12,0)
8681 print *, sign(-12,-1)
8683 print *, sign(-12.,1.)
8684 print *, sign(-12.,0.)
8685 print *, sign(-12.,-1.)
8686 end program test_sign
8689 @item @emph{Specific names}:
8690 @multitable @columnfractions .20 .20 .20 .25
8691 @item Name @tab Arguments @tab Return type @tab Standard
8692 @item @code{ISIGN(A,P)} @tab @code{INTEGER(4)} @tab @code{INTEGER(4)} @tab f95, gnu
8693 @item @code{DSIGN(A,P)} @tab @code{REAL(8)} @tab @code{REAL(8)} @tab f95, gnu
8700 @section @code{SIGNAL} --- Signal handling subroutine (or function)
8702 @cindex system, signal handling
8705 @item @emph{Description}:
8706 @code{SIGNAL(NUMBER, HANDLER [, STATUS])} causes external subroutine
8707 @var{HANDLER} to be executed with a single integer argument when signal
8708 @var{NUMBER} occurs. If @var{HANDLER} is an integer, it can be used to
8709 turn off handling of signal @var{NUMBER} or revert to its default
8710 action. See @code{signal(2)}.
8712 If @code{SIGNAL} is called as a subroutine and the @var{STATUS} argument
8713 is supplied, it is set to the value returned by @code{signal(2)}.
8715 @item @emph{Standard}:
8719 Subroutine, non-elemental function
8721 @item @emph{Syntax}:
8722 @multitable @columnfractions .80
8723 @item @code{CALL SIGNAL(NUMBER, HANDLER [, STATUS])}
8724 @item @code{STATUS = SIGNAL(NUMBER, HANDLER)}
8727 @item @emph{Arguments}:
8728 @multitable @columnfractions .15 .70
8729 @item @var{NUMBER} @tab Shall be a scalar integer, with @code{INTENT(IN)}
8730 @item @var{HANDLER}@tab Signal handler (@code{INTEGER FUNCTION} or
8731 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar.
8732 @code{INTEGER}. It is @code{INTENT(IN)}.
8733 @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
8734 integer. It has @code{INTENT(OUT)}.
8737 @item @emph{Return value}:
8738 The @code{SIGNAL} function returns the value returned by @code{signal(2)}.
8740 @item @emph{Example}:
8744 external handler_print
8746 call signal (12, handler_print)
8750 end program test_signal
8757 @section @code{SIN} --- Sine function
8763 @cindex trigonometric function, sine
8767 @item @emph{Description}:
8768 @code{SIN(X)} computes the sine of @var{X}.
8770 @item @emph{Standard}:
8776 @item @emph{Syntax}:
8777 @code{RESULT = SIN(X)}
8779 @item @emph{Arguments}:
8780 @multitable @columnfractions .15 .70
8781 @item @var{X} @tab The type shall be @code{REAL(*)} or
8785 @item @emph{Return value}:
8786 The return value has same type and kind as @var{X}.
8788 @item @emph{Example}:
8793 end program test_sin
8796 @item @emph{Specific names}:
8797 @multitable @columnfractions .20 .20 .20 .25
8798 @item Name @tab Argument @tab Return type @tab Standard
8799 @item @code{DSIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
8800 @item @code{CSIN(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab f95, gnu
8801 @item @code{ZSIN(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
8802 @item @code{CDSIN(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
8805 @item @emph{See also}:
8812 @section @code{SINH} --- Hyperbolic sine function
8815 @cindex hyperbolic sine
8816 @cindex hyperbolic function, sine
8817 @cindex sine, hyperbolic
8820 @item @emph{Description}:
8821 @code{SINH(X)} computes the hyperbolic sine of @var{X}.
8823 @item @emph{Standard}:
8829 @item @emph{Syntax}:
8830 @code{RESULT = SINH(X)}
8832 @item @emph{Arguments}:
8833 @multitable @columnfractions .15 .70
8834 @item @var{X} @tab The type shall be @code{REAL(*)}.
8837 @item @emph{Return value}:
8838 The return value is of type @code{REAL(*)}.
8840 @item @emph{Example}:
8843 real(8) :: x = - 1.0_8
8845 end program test_sinh
8848 @item @emph{Specific names}:
8849 @multitable @columnfractions .20 .20 .20 .25
8850 @item Name @tab Argument @tab Return type @tab Standard
8851 @item @code{DSINH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
8854 @item @emph{See also}:
8861 @section @code{SIZE} --- Determine the size of an array
8864 @cindex array, number of elements
8865 @cindex array, count elements
8868 @item @emph{Description}:
8869 Determine the extent of @var{ARRAY} along a specified dimension @var{DIM},
8870 or the total number of elements in @var{ARRAY} if @var{DIM} is absent.
8872 @item @emph{Standard}:
8878 @item @emph{Syntax}:
8879 @code{RESULT = SIZE(ARRAY[, DIM])}
8881 @item @emph{Arguments}:
8882 @multitable @columnfractions .15 .70
8883 @item @var{ARRAY} @tab Shall be an array of any type. If @var{ARRAY} is
8884 a pointer it must be associated and allocatable arrays must be allocated.
8885 @item @var{DIM} @tab (Optional) shall be a scalar of type @code{INTEGER}
8886 and its value shall be in the range from 1 to n, where n equals the rank
8890 @item @emph{Return value}:
8891 The return value is of type @code{INTEGER} and of the default
8894 @item @emph{Example}:
8897 WRITE(*,*) SIZE((/ 1, 2 /)) ! 2
8901 @item @emph{See also}:
8902 @ref{SHAPE}, @ref{RESHAPE}
8908 @section @code{SLEEP} --- Sleep for the specified number of seconds
8910 @cindex delayed execution
8913 @item @emph{Description}:
8914 Calling this subroutine causes the process to pause for @var{SECONDS} seconds.
8916 @item @emph{Standard}:
8922 @item @emph{Syntax}:
8923 @code{CALL SLEEP(SECONDS)}
8925 @item @emph{Arguments}:
8926 @multitable @columnfractions .15 .70
8927 @item @var{SECONDS} @tab The type shall be of default @code{INTEGER}.
8930 @item @emph{Example}:
8941 @section @code{SNGL} --- Convert double precision real to default real
8943 @cindex conversion, to real
8946 @item @emph{Description}:
8947 @code{SNGL(A)} converts the double precision real @var{A}
8948 to a default real value. This is an archaic form of @code{REAL}
8949 that is specific to one type for @var{A}.
8951 @item @emph{Standard}:
8957 @item @emph{Syntax}:
8958 @code{RESULT = SNGL(A)}
8960 @item @emph{Arguments}:
8961 @multitable @columnfractions .15 .70
8962 @item @var{A} @tab The type shall be a double precision @code{REAL}.
8965 @item @emph{Return value}:
8966 The return value is of type default @code{REAL}.
8968 @item @emph{See also}:
8975 @section @code{SPACING} --- Smallest distance between two numbers of a given type
8977 @cindex real number, relative spacing
8978 @cindex floating point, relative spacing
8981 @item @emph{Description}:
8982 Determines the distance between the argument @var{X} and the nearest
8983 adjacent number of the same type.
8985 @item @emph{Standard}:
8991 @item @emph{Syntax}:
8992 @code{RESULT = SPACING(X)}
8994 @item @emph{Arguments}:
8995 @multitable @columnfractions .15 .70
8996 @item @var{X} @tab Shall be of type @code{REAL(*)}.
8999 @item @emph{Return value}:
9000 The result is of the same type as the input argument @var{X}.
9002 @item @emph{Example}:
9004 PROGRAM test_spacing
9005 INTEGER, PARAMETER :: SGL = SELECTED_REAL_KIND(p=6, r=37)
9006 INTEGER, PARAMETER :: DBL = SELECTED_REAL_KIND(p=13, r=200)
9008 WRITE(*,*) spacing(1.0_SGL) ! "1.1920929E-07" on i686
9009 WRITE(*,*) spacing(1.0_DBL) ! "2.220446049250313E-016" on i686
9013 @item @emph{See also}:
9020 @section @code{SPREAD} --- Add a dimension to an array
9022 @cindex array, increase dimension
9023 @cindex array, duplicate elementes
9024 @cindex array, duplicate dimensions
9027 @item @emph{Description}:
9028 Replicates a @var{SOURCE} array @var{NCOPIES} times along a specified
9029 dimension @var{DIM}.
9031 @item @emph{Standard}:
9035 Transformational function
9037 @item @emph{Syntax}:
9038 @code{RESULT = SPREAD(SOURCE, DIM, NCOPIES)}
9040 @item @emph{Arguments}:
9041 @multitable @columnfractions .15 .70
9042 @item @var{SOURCE} @tab Shall be a scalar or an array of any type and
9043 a rank less than seven.
9044 @item @var{DIM} @tab Shall be a scalar of type @code{INTEGER} with a
9045 value in the range from 1 to n+1, where n equals the rank of @var{SOURCE}.
9046 @item @var{NCOPIES} @tab Shall be a scalar of type @code{INTEGER}.
9049 @item @emph{Return value}:
9050 The result is an array of the same type as @var{SOURCE} and has rank n+1
9051 where n equals the rank of @var{SOURCE}.
9053 @item @emph{Example}:
9056 INTEGER :: a = 1, b(2) = (/ 1, 2 /)
9057 WRITE(*,*) SPREAD(A, 1, 2) ! "1 1"
9058 WRITE(*,*) SPREAD(B, 1, 2) ! "1 1 2 2"
9062 @item @emph{See also}:
9069 @section @code{SQRT} --- Square-root function
9079 @item @emph{Description}:
9080 @code{SQRT(X)} computes the square root of @var{X}.
9082 @item @emph{Standard}:
9088 @item @emph{Syntax}:
9089 @code{RESULT = SQRT(X)}
9091 @item @emph{Arguments}:
9092 @multitable @columnfractions .15 .70
9093 @item @var{X} @tab The type shall be @code{REAL(*)} or
9097 @item @emph{Return value}:
9098 The return value is of type @code{REAL(*)} or @code{COMPLEX(*)}.
9099 The kind type parameter is the same as @var{X}.
9101 @item @emph{Example}:
9104 real(8) :: x = 2.0_8
9105 complex :: z = (1.0, 2.0)
9108 end program test_sqrt
9111 @item @emph{Specific names}:
9112 @multitable @columnfractions .20 .20 .20 .25
9113 @item Name @tab Argument @tab Return type @tab Standard
9114 @item @code{DSQRT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
9115 @item @code{CSQRT(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab F95 and later
9116 @item @code{ZSQRT(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
9117 @item @code{CDSQRT(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
9124 @section @code{SRAND} --- Reinitialize the random number generator
9126 @cindex random number generation, seeding
9127 @cindex seeding a random number generator
9130 @item @emph{Description}:
9131 @code{SRAND} reinitializes the pseudo-random number generator
9132 called by @code{RAND} and @code{IRAND}. The new seed used by the
9133 generator is specified by the required argument @var{SEED}.
9135 @item @emph{Standard}:
9139 Non-elemental subroutine
9141 @item @emph{Syntax}:
9142 @code{CALL SRAND(SEED)}
9144 @item @emph{Arguments}:
9145 @multitable @columnfractions .15 .70
9146 @item @var{SEED} @tab Shall be a scalar @code{INTEGER(kind=4)}.
9149 @item @emph{Return value}:
9152 @item @emph{Example}:
9153 See @code{RAND} and @code{IRAND} for examples.
9156 The Fortran 2003 standard specifies the intrinsic @code{RANDOM_SEED} to
9157 initialize the pseudo-random numbers generator and @code{RANDOM_NUMBER}
9158 to generate pseudo-random numbers. Please note that in
9159 GNU Fortran, these two sets of intrinsics (@code{RAND},
9160 @code{IRAND} and @code{SRAND} on the one hand, @code{RANDOM_NUMBER} and
9161 @code{RANDOM_SEED} on the other hand) access two independent
9162 pseudo-random number generators.
9164 @item @emph{See also}:
9165 @ref{RAND}, @ref{RANDOM_SEED}, @ref{RANDOM_NUMBER}
9172 @section @code{STAT} --- Get file status
9174 @cindex file system, file status
9177 @item @emph{Description}:
9178 This function returns information about a file. No permissions are required on
9179 the file itself, but execute (search) permission is required on all of the
9180 directories in path that lead to the file.
9182 The elements that are obtained and stored in the array @code{BUFF}:
9183 @multitable @columnfractions .15 .70
9184 @item @code{buff(1)} @tab Device ID
9185 @item @code{buff(2)} @tab Inode number
9186 @item @code{buff(3)} @tab File mode
9187 @item @code{buff(4)} @tab Number of links
9188 @item @code{buff(5)} @tab Owner's uid
9189 @item @code{buff(6)} @tab Owner's gid
9190 @item @code{buff(7)} @tab ID of device containing directory entry for file (0 if not available)
9191 @item @code{buff(8)} @tab File size (bytes)
9192 @item @code{buff(9)} @tab Last access time
9193 @item @code{buff(10)} @tab Last modification time
9194 @item @code{buff(11)} @tab Last file status change time
9195 @item @code{buff(12)} @tab Preferred I/O block size (-1 if not available)
9196 @item @code{buff(13)} @tab Number of blocks allocated (-1 if not available)
9199 Not all these elements are relevant on all systems.
9200 If an element is not relevant, it is returned as 0.
9203 @item @emph{Standard}:
9207 Non-elemental subroutine
9209 @item @emph{Syntax}:
9210 @code{CALL STAT(FILE,BUFF[,STATUS])}
9212 @item @emph{Arguments}:
9213 @multitable @columnfractions .15 .70
9214 @item @var{FILE} @tab The type shall be @code{CHARACTER(*)}, a valid path within the file system.
9215 @item @var{BUFF} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
9216 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0
9217 on success and a system specific error code otherwise.
9220 @item @emph{Example}:
9223 INTEGER, DIMENSION(13) :: buff
9226 CALL STAT("/etc/passwd", buff, status)
9228 IF (status == 0) THEN
9229 WRITE (*, FMT="('Device ID:', T30, I19)") buff(1)
9230 WRITE (*, FMT="('Inode number:', T30, I19)") buff(2)
9231 WRITE (*, FMT="('File mode (octal):', T30, O19)") buff(3)
9232 WRITE (*, FMT="('Number of links:', T30, I19)") buff(4)
9233 WRITE (*, FMT="('Owner''s uid:', T30, I19)") buff(5)
9234 WRITE (*, FMT="('Owner''s gid:', T30, I19)") buff(6)
9235 WRITE (*, FMT="('Device where located:', T30, I19)") buff(7)
9236 WRITE (*, FMT="('File size:', T30, I19)") buff(8)
9237 WRITE (*, FMT="('Last access time:', T30, A19)") CTIME(buff(9))
9238 WRITE (*, FMT="('Last modification time', T30, A19)") CTIME(buff(10))
9239 WRITE (*, FMT="('Last status change time:', T30, A19)") CTIME(buff(11))
9240 WRITE (*, FMT="('Preferred block size:', T30, I19)") buff(12)
9241 WRITE (*, FMT="('No. of blocks allocated:', T30, I19)") buff(13)
9246 @item @emph{See also}:
9247 To stat an open file: @ref{FSTAT}, to stat a link: @ref{LSTAT}
9253 @section @code{SUM} --- Sum of array elements
9256 @cindex array, add elements
9257 @cindex array, conditionally add elements
9258 @cindex sum array elements
9261 @item @emph{Description}:
9262 Adds the elements of @var{ARRAY} along dimension @var{DIM} if
9263 the corresponding element in @var{MASK} is @code{TRUE}.
9265 @item @emph{Standard}:
9269 Transformational function
9271 @item @emph{Syntax}:
9272 @code{RESULT = SUM(ARRAY[, MASK])}
9273 @code{RESULT = SUM(ARRAY, DIM[, MASK])}
9275 @item @emph{Arguments}:
9276 @multitable @columnfractions .15 .70
9277 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER(*)},
9278 @code{REAL(*)} or @code{COMPLEX(*)}.
9279 @item @var{DIM} @tab (Optional) shall be a scalar of type
9280 @code{INTEGER} with a value in the range from 1 to n, where n
9281 equals the rank of @var{ARRAY}.
9282 @item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL}
9283 and either be a scalar or an array of the same shape as @var{ARRAY}.
9286 @item @emph{Return value}:
9287 The result is of the same type as @var{ARRAY}.
9289 If @var{DIM} is absent, a scalar with the sum of all elements in @var{ARRAY}
9290 is returned. Otherwise, an array of rank n-1, where n equals the rank of
9291 @var{ARRAY},and a shape similar to that of @var{ARRAY} with dimension @var{DIM}
9292 dropped is returned.
9294 @item @emph{Example}:
9297 INTEGER :: x(5) = (/ 1, 2, 3, 4 ,5 /)
9298 print *, SUM(x) ! all elements, sum = 15
9299 print *, SUM(x, MASK=MOD(x, 2)==1) ! odd elements, sum = 9
9303 @item @emph{See also}:
9310 @section @code{SYMLNK} --- Create a symbolic link
9312 @cindex file system, create link
9313 @cindex file system, soft link
9316 @item @emph{Description}:
9317 Makes a symbolic link from file @var{PATH1} to @var{PATH2}. A null
9318 character (@code{CHAR(0)}) can be used to mark the end of the names in
9319 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
9320 names are ignored. If the @var{STATUS} argument is supplied, it
9321 contains 0 on success or a nonzero error code upon return; see
9322 @code{symlink(2)}. If the system does not supply @code{symlink(2)},
9323 @code{ENOSYS} is returned.
9325 This intrinsic is provided in both subroutine and function forms;
9326 however, only one form can be used in any given program unit.
9328 @item @emph{Standard}:
9332 Subroutine, non-elemental function
9334 @item @emph{Syntax}:
9335 @multitable @columnfractions .80
9336 @item @code{CALL SYMLNK(PATH1, PATH2 [, STATUS])}
9337 @item @code{STATUS = SYMLNK(PATH1, PATH2)}
9340 @item @emph{Arguments}:
9341 @multitable @columnfractions .15 .70
9342 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
9343 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
9344 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
9347 @item @emph{See also}:
9348 @ref{LINK}, @ref{UNLINK}
9355 @section @code{SYSTEM} --- Execute a shell command
9357 @cindex system, system call
9360 @item @emph{Description}:
9361 Passes the command @var{COMMAND} to a shell (see @code{system(3)}). If
9362 argument @var{STATUS} is present, it contains the value returned by
9363 @code{system(3)}, which is presumably 0 if the shell command succeeded.
9364 Note that which shell is used to invoke the command is system-dependent
9365 and environment-dependent.
9367 This intrinsic is provided in both subroutine and function forms;
9368 however, only one form can be used in any given program unit.
9370 @item @emph{Standard}:
9374 Subroutine, non-elemental function
9376 @item @emph{Syntax}:
9377 @multitable @columnfractions .80
9378 @item @code{CALL SYSTEM(COMMAND [, STATUS])}
9379 @item @code{STATUS = SYSTEM(COMMAND)}
9382 @item @emph{Arguments}:
9383 @multitable @columnfractions .15 .70
9384 @item @var{COMMAND} @tab Shall be of default @code{CHARACTER} type.
9385 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
9388 @item @emph{See also}:
9394 @section @code{SYSTEM_CLOCK} --- Time function
9395 @fnindex SYSTEM_CLOCK
9396 @cindex time, clock ticks
9400 @item @emph{Description}:
9401 Determines the @var{COUNT} of milliseconds of wall clock time since
9402 the Epoch (00:00:00 UTC, January 1, 1970) modulo @var{COUNT_MAX},
9403 @var{COUNT_RATE} determines the number of clock ticks per second.
9404 @var{COUNT_RATE} and @var{COUNT_MAX} are constant and specific to
9407 If there is no clock, @var{COUNT} is set to @code{-HUGE(COUNT)}, and
9408 @var{COUNT_RATE} and @var{COUNT_MAX} are set to zero
9410 @item @emph{Standard}:
9416 @item @emph{Syntax}:
9417 @code{CALL SYSTEM_CLOCK([COUNT, COUNT_RATE, COUNT_MAX])}
9419 @item @emph{Arguments}:
9420 @item @emph{Arguments}:
9421 @multitable @columnfractions .15 .70
9422 @item @var{COUNT} @tab (Optional) shall be a scalar of type default
9423 @code{INTEGER} with @code{INTENT(OUT)}.
9424 @item @var{COUNT_RATE} @tab (Optional) shall be a scalar of type default
9425 @code{INTEGER} with @code{INTENT(OUT)}.
9426 @item @var{COUNT_MAX} @tab (Optional) shall be a scalar of type default
9427 @code{INTEGER} with @code{INTENT(OUT)}.
9430 @item @emph{Example}:
9432 PROGRAM test_system_clock
9433 INTEGER :: count, count_rate, count_max
9434 CALL SYSTEM_CLOCK(count, count_rate, count_max)
9435 WRITE(*,*) count, count_rate, count_max
9439 @item @emph{See also}:
9440 @ref{DATE_AND_TIME}, @ref{CPU_TIME}
9446 @section @code{TAN} --- Tangent function
9449 @cindex trigonometric function, tangent
9453 @item @emph{Description}:
9454 @code{TAN(X)} computes the tangent of @var{X}.
9456 @item @emph{Standard}:
9462 @item @emph{Syntax}:
9463 @code{RESULT = TAN(X)}
9465 @item @emph{Arguments}:
9466 @multitable @columnfractions .15 .70
9467 @item @var{X} @tab The type shall be @code{REAL(*)}.
9470 @item @emph{Return value}:
9471 The return value is of type @code{REAL(*)}. The kind type parameter is
9472 the same as @var{X}.
9474 @item @emph{Example}:
9477 real(8) :: x = 0.165_8
9479 end program test_tan
9482 @item @emph{Specific names}:
9483 @multitable @columnfractions .20 .20 .20 .25
9484 @item Name @tab Argument @tab Return type @tab Standard
9485 @item @code{DTAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
9488 @item @emph{See also}:
9495 @section @code{TANH} --- Hyperbolic tangent function
9498 @cindex hyperbolic tangent
9499 @cindex hyperbolic function, tangent
9500 @cindex tangent, hyperbolic
9503 @item @emph{Description}:
9504 @code{TANH(X)} computes the hyperbolic tangent of @var{X}.
9506 @item @emph{Standard}:
9512 @item @emph{Syntax}:
9515 @item @emph{Arguments}:
9516 @multitable @columnfractions .15 .70
9517 @item @var{X} @tab The type shall be @code{REAL(*)}.
9520 @item @emph{Return value}:
9521 The return value is of type @code{REAL(*)} and lies in the range
9522 @math{ - 1 \leq tanh(x) \leq 1 }.
9524 @item @emph{Example}:
9527 real(8) :: x = 2.1_8
9529 end program test_tanh
9532 @item @emph{Specific names}:
9533 @multitable @columnfractions .20 .20 .20 .25
9534 @item Name @tab Argument @tab Return type @tab Standard
9535 @item @code{DTANH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
9538 @item @emph{See also}:
9545 @section @code{TIME} --- Time function
9547 @cindex time, current
9548 @cindex current time
9551 @item @emph{Description}:
9552 Returns the current time encoded as an integer (in the manner of the
9553 UNIX function @code{time(3)}). This value is suitable for passing to
9554 @code{CTIME()}, @code{GMTIME()}, and @code{LTIME()}.
9556 This intrinsic is not fully portable, such as to systems with 32-bit
9557 @code{INTEGER} types but supporting times wider than 32 bits. Therefore,
9558 the values returned by this intrinsic might be, or become, negative, or
9559 numerically less than previous values, during a single run of the
9562 See @ref{TIME8}, for information on a similar intrinsic that might be
9563 portable to more GNU Fortran implementations, though to fewer Fortran
9566 @item @emph{Standard}:
9570 Non-elemental function
9572 @item @emph{Syntax}:
9573 @code{RESULT = TIME()}
9575 @item @emph{Return value}:
9576 The return value is a scalar of type @code{INTEGER(4)}.
9578 @item @emph{See also}:
9579 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME8}
9586 @section @code{TIME8} --- Time function (64-bit)
9588 @cindex time, current
9589 @cindex current time
9592 @item @emph{Description}:
9593 Returns the current time encoded as an integer (in the manner of the
9594 UNIX function @code{time(3)}). This value is suitable for passing to
9595 @code{CTIME()}, @code{GMTIME()}, and @code{LTIME()}.
9597 @emph{Warning:} this intrinsic does not increase the range of the timing
9598 values over that returned by @code{time(3)}. On a system with a 32-bit
9599 @code{time(3)}, @code{TIME8()} will return a 32-bit value, even though
9600 it is converted to a 64-bit @code{INTEGER(8)} value. That means
9601 overflows of the 32-bit value can still occur. Therefore, the values
9602 returned by this intrinsic might be or become negative or numerically
9603 less than previous values during a single run of the compiled program.
9605 @item @emph{Standard}:
9609 Non-elemental function
9611 @item @emph{Syntax}:
9612 @code{RESULT = TIME8()}
9614 @item @emph{Return value}:
9615 The return value is a scalar of type @code{INTEGER(8)}.
9617 @item @emph{See also}:
9618 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK8}, @ref{TIME}
9625 @section @code{TINY} --- Smallest positive number of a real kind
9627 @cindex limits, smallest number
9628 @cindex model representation, smallest number
9631 @item @emph{Description}:
9632 @code{TINY(X)} returns the smallest positive (non zero) number
9633 in the model of the type of @code{X}.
9635 @item @emph{Standard}:
9641 @item @emph{Syntax}:
9642 @code{RESULT = TINY(X)}
9644 @item @emph{Arguments}:
9645 @multitable @columnfractions .15 .70
9646 @item @var{X} @tab Shall be of type @code{REAL}.
9649 @item @emph{Return value}:
9650 The return value is of the same type and kind as @var{X}
9652 @item @emph{Example}:
9653 See @code{HUGE} for an example.
9659 @section @code{TRANSFER} --- Transfer bit patterns
9665 @item @emph{Description}:
9666 Interprets the bitwise representation of @var{SOURCE} in memory as if it
9667 is the representation of a variable or array of the same type and type
9668 parameters as @var{MOLD}.
9670 This is approximately equivalent to the C concept of @emph{casting} one
9673 @item @emph{Standard}:
9677 Transformational function
9679 @item @emph{Syntax}:
9680 @code{RESULT = TRANSFER(SOURCE, MOLD[, SIZE])}
9682 @item @emph{Arguments}:
9683 @multitable @columnfractions .15 .70
9684 @item @var{SOURCE} @tab Shall be a scalar or an array of any type.
9685 @item @var{MOLD} @tab Shall be a scalar or an array of any type.
9686 @item @var{SIZE} @tab (Optional) shall be a scalar of type
9690 @item @emph{Return value}:
9691 The result has the same type as @var{MOLD}, with the bit level
9692 representation of @var{SOURCE}. If @var{SIZE} is present, the result is
9693 a one-dimensional array of length @var{SIZE}. If @var{SIZE} is absent
9694 but @var{MOLD} is an array (of any size or shape), the result is a one-
9695 dimensional array of the minimum length needed to contain the entirety
9696 of the bitwise representation of @var{SOURCE}. If @var{SIZE} is absent
9697 and @var{MOLD} is a scalar, the result is a scalar.
9699 If the bitwise representation of the result is longer than that of
9700 @var{SOURCE}, then the leading bits of the result correspond to those of
9701 @var{SOURCE} and any trailing bits are filled arbitrarily.
9703 When the resulting bit representation does not correspond to a valid
9704 representation of a variable of the same type as @var{MOLD}, the results
9705 are undefined, and subsequent operations on the result cannot be
9706 guaranteed to produce sensible behavior. For example, it is possible to
9707 create @code{LOGICAL} variables for which @code{@var{VAR}} and
9708 @code{.NOT.@var{VAR}} both appear to be true.
9710 @item @emph{Example}:
9712 PROGRAM test_transfer
9713 integer :: x = 2143289344
9714 print *, transfer(x, 1.0) ! prints "NaN" on i686
9722 @section @code{TRANSPOSE} --- Transpose an array of rank two
9724 @cindex array, transpose
9725 @cindex matrix, transpose
9729 @item @emph{Description}:
9730 Transpose an array of rank two. Element (i, j) of the result has the value
9731 @code{MATRIX(j, i)}, for all i, j.
9733 @item @emph{Standard}:
9737 Transformational function
9739 @item @emph{Syntax}:
9740 @code{RESULT = TRANSPOSE(MATRIX)}
9742 @item @emph{Arguments}:
9743 @multitable @columnfractions .15 .70
9744 @item @var{MATRIX} @tab Shall be an array of any type and have a rank of two.
9747 @item @emph{Return value}:
9748 The result has the the same type as @var{MATRIX}, and has shape
9749 @code{(/ m, n /)} if @var{MATRIX} has shape @code{(/ n, m /)}.
9755 @section @code{TRIM} --- Remove trailing blank characters of a string
9757 @cindex string, remove trailing whitespace
9760 @item @emph{Description}:
9761 Removes trailing blank characters of a string.
9763 @item @emph{Standard}:
9767 Transformational function
9769 @item @emph{Syntax}:
9770 @code{RESULT = TRIM(STRING)}
9772 @item @emph{Arguments}:
9773 @multitable @columnfractions .15 .70
9774 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER(*)}.
9777 @item @emph{Return value}:
9778 A scalar of type @code{CHARACTER(*)} which length is that of @var{STRING}
9779 less the number of trailing blanks.
9781 @item @emph{Example}:
9784 CHARACTER(len=10), PARAMETER :: s = "GFORTRAN "
9785 WRITE(*,*) LEN(s), LEN(TRIM(s)) ! "10 8", with/without trailing blanks
9789 @item @emph{See also}:
9790 @ref{ADJUSTL}, @ref{ADJUSTR}
9796 @section @code{TTYNAM} --- Get the name of a terminal device.
9798 @cindex system, terminal
9801 @item @emph{Description}:
9802 Get the name of a terminal device. For more information,
9803 see @code{ttyname(3)}.
9805 This intrinsic is provided in both subroutine and function forms;
9806 however, only one form can be used in any given program unit.
9808 @item @emph{Standard}:
9812 Subroutine, non-elemental function
9814 @item @emph{Syntax}:
9815 @multitable @columnfractions .80
9816 @item @code{CALL TTYNAM(UNIT, NAME)}
9817 @item @code{NAME = TTYNAM(UNIT)}
9820 @item @emph{Arguments}:
9821 @multitable @columnfractions .15 .70
9822 @item @var{UNIT} @tab Shall be a scalar @code{INTEGER(*)}.
9823 @item @var{NAME} @tab Shall be of type @code{CHARACTER(*)}.
9826 @item @emph{Example}:
9831 IF (isatty(unit=unit)) write(*,*) ttynam(unit)
9836 @item @emph{See also}:
9843 @section @code{UBOUND} --- Upper dimension bounds of an array
9845 @cindex array, upper bound
9848 @item @emph{Description}:
9849 Returns the upper bounds of an array, or a single upper bound
9850 along the @var{DIM} dimension.
9851 @item @emph{Standard}:
9857 @item @emph{Syntax}:
9858 @code{RESULT = UBOUND(ARRAY [, DIM])}
9860 @item @emph{Arguments}:
9861 @multitable @columnfractions .15 .70
9862 @item @var{ARRAY} @tab Shall be an array, of any type.
9863 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER(*)}.
9866 @item @emph{Return value}:
9867 If @var{DIM} is absent, the result is an array of the upper bounds of
9868 @var{ARRAY}. If @var{DIM} is present, the result is a scalar
9869 corresponding to the upper bound of the array along that dimension. If
9870 @var{ARRAY} is an expression rather than a whole array or array
9871 structure component, or if it has a zero extent along the relevant
9872 dimension, the upper bound is taken to be the number of elements along
9873 the relevant dimension.
9875 @item @emph{See also}:
9882 @section @code{UMASK} --- Set the file creation mask
9884 @cindex file system, file creation mask
9887 @item @emph{Description}:
9888 Sets the file creation mask to @var{MASK} and returns the old value in
9889 argument @var{OLD} if it is supplied. See @code{umask(2)}.
9891 @item @emph{Standard}:
9897 @item @emph{Syntax}:
9898 @code{CALL UMASK(MASK [, OLD])}
9900 @item @emph{Arguments}:
9901 @multitable @columnfractions .15 .70
9902 @item @var{MASK} @tab Shall be a scalar of type @code{INTEGER(*)}.
9903 @item @var{MASK} @tab (Optional) Shall be a scalar of type
9912 @section @code{UNLINK} --- Remove a file from the file system
9914 @cindex file system, remove file
9917 @item @emph{Description}:
9918 Unlinks the file @var{PATH}. A null character (@code{CHAR(0)}) can be
9919 used to mark the end of the name in @var{PATH}; otherwise, trailing
9920 blanks in the file name are ignored. If the @var{STATUS} argument is
9921 supplied, it contains 0 on success or a nonzero error code upon return;
9922 see @code{unlink(2)}.
9924 This intrinsic is provided in both subroutine and function forms;
9925 however, only one form can be used in any given program unit.
9927 @item @emph{Standard}:
9931 Subroutine, non-elemental function
9933 @item @emph{Syntax}:
9934 @multitable @columnfractions .80
9935 @item @code{CALL UNLINK(PATH [, STATUS])}
9936 @item @code{STATUS = UNLINK(PATH)}
9939 @item @emph{Arguments}:
9940 @multitable @columnfractions .15 .70
9941 @item @var{PATH} @tab Shall be of default @code{CHARACTER} type.
9942 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
9945 @item @emph{See also}:
9946 @ref{LINK}, @ref{SYMLNK}
9952 @section @code{UNPACK} --- Unpack an array of rank one into an array
9954 @cindex array, unpacking
9955 @cindex array, increase dimension
9956 @cindex array, scatter elements
9959 @item @emph{Description}:
9960 Store the elements of @var{VECTOR} in an array of higher rank.
9962 @item @emph{Standard}:
9966 Transformational function
9968 @item @emph{Syntax}:
9969 @code{RESULT = UNPACK(VECTOR, MASK, FIELD)}
9971 @item @emph{Arguments}:
9972 @multitable @columnfractions .15 .70
9973 @item @var{VECTOR} @tab Shall be an array of any type and rank one. It
9974 shall have at least as many elements as @var{MASK} has @code{TRUE} values.
9975 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL}.
9976 @item @var{FIELD} @tab Shall be of the sam type as @var{VECTOR} and have
9977 the same shape as @var{MASK}.
9980 @item @emph{Return value}:
9981 The resulting array corresponds to @var{FIELD} with @code{TRUE} elements
9982 of @var{MASK} replaced by values from @var{VECTOR} in array element order.
9984 @item @emph{Example}:
9987 integer :: vector(2) = (/1,1/)
9988 logical :: mask(4) = (/ .TRUE., .FALSE., .FALSE., .TRUE. /)
9989 integer :: field(2,2) = 0, unity(2,2)
9991 ! result: unity matrix
9992 unity = unpack(vector, reshape(mask, (/2,2/)), field)
9996 @item @emph{See also}:
9997 @ref{PACK}, @ref{SPREAD}
10003 @section @code{VERIFY} --- Scan a string for the absence of a set of characters
10005 @cindex string, find missing set
10008 @item @emph{Description}:
10009 Verifies that all the characters in a @var{SET} are present in a @var{STRING}.
10011 If @var{BACK} is either absent or equals @code{FALSE}, this function
10012 returns the position of the leftmost character of @var{STRING} that is
10013 not in @var{SET}. If @var{BACK} equals @code{TRUE}, the rightmost position
10014 is returned. If all characters of @var{SET} are found in @var{STRING}, the
10017 @item @emph{Standard}:
10020 @item @emph{Class}:
10023 @item @emph{Syntax}:
10024 @code{RESULT = VERFIY(STRING, SET[, BACK])}
10026 @item @emph{Arguments}:
10027 @multitable @columnfractions .15 .70
10028 @item @var{STRING} @tab Shall be of type @code{CHARACTER(*)}.
10029 @item @var{SET} @tab Shall be of type @code{CHARACTER(*)}.
10030 @item @var{BACK} @tab (Optional) shall be of type @code{LOGICAL}.
10033 @item @emph{Return value}:
10034 The return value is of type @code{INTEGER} and of the default
10037 @item @emph{Example}:
10039 PROGRAM test_verify
10040 WRITE(*,*) VERIFY("FORTRAN", "AO") ! 1, found 'F'
10041 WRITE(*,*) VERIFY("FORTRAN", "FOO") ! 3, found 'R'
10042 WRITE(*,*) VERIFY("FORTRAN", "C++") ! 1, found 'F'
10043 WRITE(*,*) VERIFY("FORTRAN", "C++", .TRUE.) ! 7, found 'N'
10044 WRITE(*,*) VERIFY("FORTRAN", "FORTRAN") ! 0' found none
10048 @item @emph{See also}:
10049 @ref{SCAN}, @ref{INDEX}
10055 @section @code{XOR} --- Bitwise logical exclusive OR
10057 @cindex bitwise logical exclusive or
10058 @cindex logical exclusive or, bitwise
10061 @item @emph{Description}:
10062 Bitwise logical exclusive or.
10064 This intrinsic routine is provided for backwards compatibility with
10065 GNU Fortran 77. For integer arguments, programmers should consider
10066 the use of the @ref{IEOR} intrinsic defined by the Fortran standard.
10068 @item @emph{Standard}:
10071 @item @emph{Class}:
10072 Non-elemental function
10074 @item @emph{Syntax}:
10075 @code{RESULT = XOR(X, Y)}
10077 @item @emph{Arguments}:
10078 @multitable @columnfractions .15 .70
10079 @item @var{X} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
10080 @item @var{Y} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
10083 @item @emph{Return value}:
10084 The return type is either @code{INTEGER(*)} or @code{LOGICAL}
10085 after cross-promotion of the arguments.
10087 @item @emph{Example}:
10090 LOGICAL :: T = .TRUE., F = .FALSE.
10092 DATA a / Z'F' /, b / Z'3' /
10094 WRITE (*,*) XOR(T, T), XOR(T, F), XOR(F, T), XOR(F, F)
10095 WRITE (*,*) XOR(a, b)
10099 @item @emph{See also}:
10100 F95 elemental function: @ref{IEOR}