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{COMPLEX}: COMPLEX, Complex conversion function
80 * @code{CONJG}: CONJG, Complex conjugate function
81 * @code{COS}: COS, Cosine function
82 * @code{COSH}: COSH, Hyperbolic cosine function
83 * @code{COUNT}: COUNT, Count occurrences of TRUE in an array
84 * @code{CPU_TIME}: CPU_TIME, CPU time subroutine
85 * @code{CSHIFT}: CSHIFT, Circular shift elements of an array
86 * @code{CTIME}: CTIME, Subroutine (or function) to convert a time into a string
87 * @code{DATE_AND_TIME}: DATE_AND_TIME, Date and time subroutine
88 * @code{DBLE}: DBLE, Double precision conversion function
89 * @code{DCMPLX}: DCMPLX, Double complex conversion function
90 * @code{DFLOAT}: DFLOAT, Double precision conversion function
91 * @code{DIGITS}: DIGITS, Significant digits function
92 * @code{DIM}: DIM, Positive difference
93 * @code{DOT_PRODUCT}: DOT_PRODUCT, Dot product function
94 * @code{DPROD}: DPROD, Double product function
95 * @code{DREAL}: DREAL, Double real part function
96 * @code{DTIME}: DTIME, Execution time subroutine (or function)
97 * @code{EOSHIFT}: EOSHIFT, End-off shift elements of an array
98 * @code{EPSILON}: EPSILON, Epsilon function
99 * @code{ERF}: ERF, Error function
100 * @code{ERFC}: ERFC, Complementary error function
101 * @code{ETIME}: ETIME, Execution time subroutine (or function)
102 * @code{EXIT}: EXIT, Exit the program with status.
103 * @code{EXP}: EXP, Exponential function
104 * @code{EXPONENT}: EXPONENT, Exponent function
105 * @code{FDATE}: FDATE, Subroutine (or function) to get the current time as a string
106 * @code{FGET}: FGET, Read a single character in stream mode from stdin
107 * @code{FGETC}: FGETC, Read a single character in stream mode
108 * @code{FLOAT}: FLOAT, Convert integer to default real
109 * @code{FLOOR}: FLOOR, Integer floor function
110 * @code{FLUSH}: FLUSH, Flush I/O unit(s)
111 * @code{FNUM}: FNUM, File number function
112 * @code{FPUT}: FPUT, Write a single character in stream mode to stdout
113 * @code{FPUTC}: FPUTC, Write a single character in stream mode
114 * @code{FRACTION}: FRACTION, Fractional part of the model representation
115 * @code{FREE}: FREE, Memory de-allocation subroutine
116 * @code{FSEEK}: FSEEK, Low level file positioning subroutine
117 * @code{FSTAT}: FSTAT, Get file status
118 * @code{FTELL}: FTELL, Current stream position
119 * @code{GERROR}: GERROR, Get last system error message
120 * @code{GETARG}: GETARG, Get command line arguments
121 * @code{GET_COMMAND}: GET_COMMAND, Get the entire command line
122 * @code{GET_COMMAND_ARGUMENT}: GET_COMMAND_ARGUMENT, Get command line arguments
123 * @code{GETCWD}: GETCWD, Get current working directory
124 * @code{GETENV}: GETENV, Get an environmental variable
125 * @code{GET_ENVIRONMENT_VARIABLE}: GET_ENVIRONMENT_VARIABLE, Get an environmental variable
126 * @code{GETGID}: GETGID, Group ID function
127 * @code{GETLOG}: GETLOG, Get login name
128 * @code{GETPID}: GETPID, Process ID function
129 * @code{GETUID}: GETUID, User ID function
130 * @code{GMTIME}: GMTIME, Convert time to GMT info
131 * @code{HOSTNM}: HOSTNM, Get system host name
132 * @code{HUGE}: HUGE, Largest number of a kind
133 * @code{IACHAR}: IACHAR, Code in @acronym{ASCII} collating sequence
134 * @code{IAND}: IAND, Bitwise logical and
135 * @code{IARGC}: IARGC, Get the number of command line arguments
136 * @code{IBCLR}: IBCLR, Clear bit
137 * @code{IBITS}: IBITS, Bit extraction
138 * @code{IBSET}: IBSET, Set bit
139 * @code{ICHAR}: ICHAR, Character-to-integer conversion function
140 * @code{IDATE}: IDATE, Current local time (day/month/year)
141 * @code{IEOR}: IEOR, Bitwise logical exclusive or
142 * @code{IERRNO}: IERRNO, Function to get the last system error number
143 * @code{INDEX}: INDEX, Position of a substring within a string
144 * @code{INT}: INT, Convert to integer type
145 * @code{INT2}: INT2, Convert to 16-bit integer type
146 * @code{INT8}: INT8, Convert to 64-bit integer type
147 * @code{IOR}: IOR, Bitwise logical or
148 * @code{IRAND}: IRAND, Integer pseudo-random number
149 * @code{ISATTY}: ISATTY, Whether a unit is a terminal device
150 * @code{ISHFT}: ISHFT, Shift bits
151 * @code{ISHFTC}: ISHFTC, Shift bits circularly
152 * @code{ITIME}: ITIME, Current local time (hour/minutes/seconds)
153 * @code{KILL}: KILL, Send a signal to a process
154 * @code{KIND}: KIND, Kind of an entity
155 * @code{LBOUND}: LBOUND, Lower dimension bounds of an array
156 * @code{LEN}: LEN, Length of a character entity
157 * @code{LEN_TRIM}: LEN_TRIM, Length of a character entity without trailing blank characters
158 * @code{LGE}: LGE, Lexical greater than or equal
159 * @code{LGT}: LGT, Lexical greater than
160 * @code{LINK}: LINK, Create a hard link
161 * @code{LLE}: LLE, Lexical less than or equal
162 * @code{LLT}: LLT, Lexical less than
163 * @code{LNBLNK}: LNBLNK, Index of the last non-blank character in a string
164 * @code{LOC}: LOC, Returns the address of a variable
165 * @code{LOG}: LOG, Logarithm function
166 * @code{LOG10}: LOG10, Base 10 logarithm function
167 * @code{LOGICAL}: LOGICAL, Convert to logical type
168 * @code{LONG}: LONG, Convert to integer type
169 * @code{LSHIFT}: LSHIFT, Left shift bits
170 * @code{LSTAT}: LSTAT, Get file status
171 * @code{LTIME}: LTIME, Convert time to local time info
172 * @code{MALLOC}: MALLOC, Dynamic memory allocation function
173 * @code{MATMUL}: MATMUL, matrix multiplication
174 * @code{MAX}: MAX, Maximum value of an argument list
175 * @code{MAXEXPONENT}: MAXEXPONENT, Maximum exponent of a real kind
176 * @code{MAXLOC}: MAXLOC, Location of the maximum value within an array
177 * @code{MAXVAL}: MAXVAL, Maximum value of an array
178 * @code{MCLOCK}: MCLOCK, Time function
179 * @code{MCLOCK8}: MCLOCK8, Time function (64-bit)
180 * @code{MERGE}: MERGE, Merge arrays
181 * @code{MIN}: MIN, Minimum value of an argument list
182 * @code{MINEXPONENT}: MINEXPONENT, Minimum exponent of a real kind
183 * @code{MINLOC}: MINLOC, Location of the minimum value within an array
184 * @code{MINVAL}: MINVAL, Minimum value of an array
185 * @code{MOD}: MOD, Remainder function
186 * @code{MODULO}: MODULO, Modulo function
187 * @code{MOVE_ALLOC}: MOVE_ALLOC, Move allocation from one object to another
188 * @code{MVBITS}: MVBITS, Move bits from one integer to another
189 * @code{NEAREST}: NEAREST, Nearest representable number
190 * @code{NEW_LINE}: NEW_LINE, New line character
191 * @code{NINT}: NINT, Nearest whole number
192 * @code{NOT}: NOT, Logical negation
193 * @code{NULL}: NULL, Function that returns an disassociated pointer
194 * @code{OR}: OR, Bitwise logical OR
195 * @code{PACK}: PACK, Pack an array into an array of rank one
196 * @code{PERROR}: PERROR, Print system error message
197 * @code{PRECISION}: PRECISION, Decimal precision of a real kind
198 * @code{PRESENT}: PRESENT, Determine whether an optional dummy argument is specified
199 * @code{PRODUCT}: PRODUCT, Product of array elements
200 * @code{RADIX}: RADIX, Base of a data model
201 * @code{RANDOM_NUMBER}: RANDOM_NUMBER, Pseudo-random number
202 * @code{RANDOM_SEED}: RANDOM_SEED, Initialize a pseudo-random number sequence
203 * @code{RAND}: RAND, Real pseudo-random number
204 * @code{RANGE}: RANGE, Decimal exponent range of a real kind
205 * @code{RAN}: RAN, Real pseudo-random number
206 * @code{REAL}: REAL, Convert to real type
207 * @code{RENAME}: RENAME, Rename a file
208 * @code{REPEAT}: REPEAT, Repeated string concatenation
209 * @code{RESHAPE}: RESHAPE, Function to reshape an array
210 * @code{RRSPACING}: RRSPACING, Reciprocal of the relative spacing
211 * @code{RSHIFT}: RSHIFT, Right shift bits
212 * @code{SCALE}: SCALE, Scale a real value
213 * @code{SCAN}: SCAN, Scan a string for the presence of a set of characters
214 * @code{SECNDS}: SECNDS, Time function
215 * @code{SECOND}: SECOND, CPU time function
216 * @code{SELECTED_INT_KIND}: SELECTED_INT_KIND, Choose integer kind
217 * @code{SELECTED_REAL_KIND}: SELECTED_REAL_KIND, Choose real kind
218 * @code{SET_EXPONENT}: SET_EXPONENT, Set the exponent of the model
219 * @code{SHAPE}: SHAPE, Determine the shape of an array
220 * @code{SIGN}: SIGN, Sign copying function
221 * @code{SIGNAL}: SIGNAL, Signal handling subroutine (or function)
222 * @code{SIN}: SIN, Sine function
223 * @code{SINH}: SINH, Hyperbolic sine function
224 * @code{SIZE}: SIZE, Function to determine the size of an array
225 * @code{SLEEP}: SLEEP, Sleep for the specified number of seconds
226 * @code{SNGL}: SNGL, Convert double precision real to default real
227 * @code{SPACING}: SPACING, Smallest distance between two numbers of a given type
228 * @code{SPREAD}: SPREAD, Add a dimension to an array
229 * @code{SQRT}: SQRT, Square-root function
230 * @code{SRAND}: SRAND, Reinitialize the random number generator
231 * @code{STAT}: STAT, Get file status
232 * @code{SUM}: SUM, Sum of array elements
233 * @code{SYMLNK}: SYMLNK, Create a symbolic link
234 * @code{SYSTEM}: SYSTEM, Execute a shell command
235 * @code{SYSTEM_CLOCK}: SYSTEM_CLOCK, Time function
236 * @code{TAN}: TAN, Tangent function
237 * @code{TANH}: TANH, Hyperbolic tangent function
238 * @code{TIME}: TIME, Time function
239 * @code{TIME8}: TIME8, Time function (64-bit)
240 * @code{TINY}: TINY, Smallest positive number of a real kind
241 * @code{TRANSFER}: TRANSFER, Transfer bit patterns
242 * @code{TRANSPOSE}: TRANSPOSE, Transpose an array of rank two
243 * @code{TRIM}: TRIM, Remove trailing blank characters of a string
244 * @code{TTYNAM}: TTYNAM, Get the name of a terminal device.
245 * @code{UBOUND}: UBOUND, Upper dimension bounds of an array
246 * @code{UMASK}: UMASK, Set the file creation mask
247 * @code{UNLINK}: UNLINK, Remove a file from the file system
248 * @code{UNPACK}: UNPACK, Unpack an array of rank one into an array
249 * @code{VERIFY}: VERIFY, Scan a string for the absence of a set of characters
250 * @code{XOR}: XOR, Bitwise logical exclusive or
253 @node Introduction to Intrinsics
254 @section Introduction to intrinsic procedures
256 The intrinsic procedures provided by GNU Fortran include all of the
257 intrinsic procedures required by the Fortran 95 standard, a set of
258 intrinsic procedures for backwards compatibility with G77, and a small
259 selection of intrinsic procedures from the Fortran 2003 standard. Any
260 conflict between a description here and a description in either the
261 Fortran 95 standard or the Fortran 2003 standard is unintentional, and
262 the standard(s) should be considered authoritative.
264 The enumeration of the @code{KIND} type parameter is processor defined in
265 the Fortran 95 standard. GNU Fortran defines the default integer type and
266 default real type by @code{INTEGER(KIND=4)} and @code{REAL(KIND=4)},
267 respectively. The standard mandates that both data types shall have
268 another kind, which have more precision. On typical target architectures
269 supported by @command{gfortran}, this kind type parameter is @code{KIND=8}.
270 Hence, @code{REAL(KIND=8)} and @code{DOUBLE PRECISION} are equivalent.
271 In the description of generic intrinsic procedures, the kind type parameter
272 will be specified by @code{KIND=*}, and in the description of specific
273 names for an intrinsic procedure the kind type parameter will be explicitly
274 given (e.g., @code{REAL(KIND=4)} or @code{REAL(KIND=8)}). Finally, for
275 brevity the optional @code{KIND=} syntax will be omitted.
277 Many of the intrinsic procedures take one or more optional arguments.
278 This document follows the convention used in the Fortran 95 standard,
279 and denotes such arguments by square brackets.
281 GNU Fortran offers the @option{-std=f95} and @option{-std=gnu} options,
282 which can be used to restrict the set of intrinsic procedures to a
283 given standard. By default, @command{gfortran} sets the @option{-std=gnu}
284 option, and so all intrinsic procedures described here are accepted. There
285 is one caveat. For a select group of intrinsic procedures, @command{g77}
286 implemented both a function and a subroutine. Both classes
287 have been implemented in @command{gfortran} for backwards compatibility
288 with @command{g77}. It is noted here that these functions and subroutines
289 cannot be intermixed in a given subprogram. In the descriptions that follow,
290 the applicable standard for each intrinsic procedure is noted.
295 @section @code{ABORT} --- Abort the program
297 @cindex program termination, with core dump
298 @cindex terminate program, with core dump
302 @item @emph{Description}:
303 @code{ABORT} causes immediate termination of the program. On operating
304 systems that support a core dump, @code{ABORT} will produce a core dump,
305 which is suitable for debugging purposes.
307 @item @emph{Standard}:
311 Non-elemental subroutine
316 @item @emph{Return value}:
319 @item @emph{Example}:
322 integer :: i = 1, j = 2
323 if (i /= j) call abort
324 end program test_abort
327 @item @emph{See also}:
328 @ref{EXIT}, @ref{KILL}
335 @section @code{ABS} --- Absolute value
342 @cindex absolute value
345 @item @emph{Description}:
346 @code{ABS(X)} computes the absolute value of @code{X}.
348 @item @emph{Standard}:
349 F77 and later, has overloads that are GNU extensions
355 @code{RESULT = ABS(X)}
357 @item @emph{Arguments}:
358 @multitable @columnfractions .15 .70
359 @item @var{X} @tab The type of the argument shall be an @code{INTEGER(*)},
360 @code{REAL(*)}, or @code{COMPLEX(*)}.
363 @item @emph{Return value}:
364 The return value is of the same type and
365 kind as the argument except the return value is @code{REAL(*)} for a
366 @code{COMPLEX(*)} argument.
368 @item @emph{Example}:
373 complex :: z = (-1.e0,0.e0)
380 @item @emph{Specific names}:
381 @multitable @columnfractions .20 .20 .20 .25
382 @item Name @tab Argument @tab Return type @tab Standard
383 @item @code{CABS(Z)} @tab @code{COMPLEX(4) Z} @tab @code{REAL(4)} @tab F77 and later
384 @item @code{DABS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
385 @item @code{IABS(I)} @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)} @tab F77 and later
386 @item @code{ZABS(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
387 @item @code{CDABS(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
394 @section @code{ACCESS} --- Checks file access modes
396 @cindex file system, access mode
399 @item @emph{Description}:
400 @code{ACCESS(NAME, MODE)} checks whether the file @var{NAME}
401 exists, is readable, writable or executable. Except for the
402 executable check, @code{ACCESS} can be replaced by
403 Fortran 95's @code{INQUIRE}.
405 @item @emph{Standard}:
412 @code{RESULT = ACCESS(NAME, MODE)}
414 @item @emph{Arguments}:
415 @multitable @columnfractions .15 .70
416 @item @var{NAME} @tab Scalar @code{CHARACTER} with the file name.
417 Tailing blank are ignored unless the character @code{achar(0)} is
418 present, then all characters up to and excluding @code{achar(0)} are
420 @item @var{MODE} @tab Scalar @code{CHARACTER} with the file access mode,
421 may be any concatenation of @code{"r"} (readable), @code{"w"} (writable)
422 and @code{"x"} (executable), or @code{" "} to check for existence.
425 @item @emph{Return value}:
426 Returns a scalar @code{INTEGER}, which is @code{0} if the file is
427 accessible in the given mode; otherwise or if an invalid argument
428 has been given for @code{MODE} the value @code{1} is returned.
430 @item @emph{Example}:
434 character(len=*), parameter :: file = 'test.dat'
435 character(len=*), parameter :: file2 = 'test.dat '//achar(0)
436 if(access(file,' ') == 0) print *, trim(file),' is exists'
437 if(access(file,'r') == 0) print *, trim(file),' is readable'
438 if(access(file,'w') == 0) print *, trim(file),' is writable'
439 if(access(file,'x') == 0) print *, trim(file),' is executable'
440 if(access(file2,'rwx') == 0) &
441 print *, trim(file2),' is readable, writable and executable'
442 end program access_test
444 @item @emph{Specific names}:
445 @item @emph{See also}:
452 @section @code{ACHAR} --- Character in @acronym{ASCII} collating sequence
454 @cindex @acronym{ASCII} collating sequence
455 @cindex collating sequence, @acronym{ASCII}
458 @item @emph{Description}:
459 @code{ACHAR(I)} returns the character located at position @code{I}
460 in the @acronym{ASCII} collating sequence.
462 @item @emph{Standard}:
469 @code{RESULT = ACHAR(I)}
471 @item @emph{Arguments}:
472 @multitable @columnfractions .15 .70
473 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
476 @item @emph{Return value}:
477 The return value is of type @code{CHARACTER} with a length of one. The
478 kind type parameter is the same as @code{KIND('A')}.
480 @item @emph{Example}:
485 end program test_achar
489 See @ref{ICHAR} for a discussion of converting between numerical values
490 and formatted string representations.
492 @item @emph{See also}:
493 @ref{CHAR}, @ref{IACHAR}, @ref{ICHAR}
500 @section @code{ACOS} --- Arccosine function
503 @cindex trigonometric function, cosine, inverse
504 @cindex cosine, inverse
507 @item @emph{Description}:
508 @code{ACOS(X)} computes the arccosine of @var{X} (inverse of @code{COS(X)}).
510 @item @emph{Standard}:
517 @code{RESULT = ACOS(X)}
519 @item @emph{Arguments}:
520 @multitable @columnfractions .15 .70
521 @item @var{X} @tab The type shall be @code{REAL(*)} with a magnitude that is
525 @item @emph{Return value}:
526 The return value is of type @code{REAL(*)} and it lies in the
527 range @math{ 0 \leq \acos(x) \leq \pi}. The kind type parameter
528 is the same as @var{X}.
530 @item @emph{Example}:
533 real(8) :: x = 0.866_8
535 end program test_acos
538 @item @emph{Specific names}:
539 @multitable @columnfractions .20 .20 .20 .25
540 @item Name @tab Argument @tab Return type @tab Standard
541 @item @code{DACOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
544 @item @emph{See also}:
545 Inverse function: @ref{COS}
552 @section @code{ACOSH} --- Hyperbolic arccosine function
555 @cindex area hyperbolic cosine
556 @cindex hyperbolic arccosine
557 @cindex hyperbolic function, cosine, inverse
558 @cindex cosine, hyperbolic, inverse
561 @item @emph{Description}:
562 @code{ACOSH(X)} computes the hyperbolic arccosine of @var{X} (inverse of
565 @item @emph{Standard}:
572 @code{RESULT = ACOSH(X)}
574 @item @emph{Arguments}:
575 @multitable @columnfractions .15 .70
576 @item @var{X} @tab The type shall be @code{REAL(*)} with a magnitude that is
577 greater or equal to one.
580 @item @emph{Return value}:
581 The return value is of type @code{REAL(*)} and it lies in the
582 range @math{0 \leq \acosh (x) \leq \infty}.
584 @item @emph{Example}:
587 REAL(8), DIMENSION(3) :: x = (/ 1.0, 2.0, 3.0 /)
592 @item @emph{Specific names}:
593 @multitable @columnfractions .20 .20 .20 .25
594 @item Name @tab Argument @tab Return type @tab Standard
595 @item @code{DACOSH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
598 @item @emph{See also}:
599 Inverse function: @ref{COSH}
605 @section @code{ADJUSTL} --- Left adjust a string
607 @cindex string, adjust left
608 @cindex adjust string
611 @item @emph{Description}:
612 @code{ADJUSTL(STR)} will left adjust a string by removing leading spaces.
613 Spaces are inserted at the end of the string as needed.
615 @item @emph{Standard}:
622 @code{RESULT = ADJUSTL(STR)}
624 @item @emph{Arguments}:
625 @multitable @columnfractions .15 .70
626 @item @var{STR} @tab The type shall be @code{CHARACTER}.
629 @item @emph{Return value}:
630 The return value is of type @code{CHARACTER} where leading spaces
631 are removed and the same number of spaces are inserted on the end
634 @item @emph{Example}:
637 character(len=20) :: str = ' gfortran'
640 end program test_adjustl
643 @item @emph{See also}:
644 @ref{ADJUSTR}, @ref{TRIM}
650 @section @code{ADJUSTR} --- Right adjust a string
652 @cindex string, adjust right
653 @cindex adjust string
656 @item @emph{Description}:
657 @code{ADJUSTR(STR)} will right adjust a string by removing trailing spaces.
658 Spaces are inserted at the start of the string as needed.
660 @item @emph{Standard}:
667 @code{RESULT = ADJUSTR(STR)}
669 @item @emph{Arguments}:
670 @multitable @columnfractions .15 .70
671 @item @var{STR} @tab The type shall be @code{CHARACTER}.
674 @item @emph{Return value}:
675 The return value is of type @code{CHARACTER} where trailing spaces
676 are removed and the same number of spaces are inserted at the start
679 @item @emph{Example}:
682 character(len=20) :: str = 'gfortran'
685 end program test_adjustr
688 @item @emph{See also}:
689 @ref{ADJUSTL}, @ref{TRIM}
695 @section @code{AIMAG} --- Imaginary part of complex number
700 @cindex complex numbers, imaginary part
703 @item @emph{Description}:
704 @code{AIMAG(Z)} yields the imaginary part of complex argument @code{Z}.
705 The @code{IMAG(Z)} and @code{IMAGPART(Z)} intrinsic functions are provided
706 for compatibility with @command{g77}, and their use in new code is
707 strongly discouraged.
709 @item @emph{Standard}:
710 F77 and later, has overloads that are GNU extensions
716 @code{RESULT = AIMAG(Z)}
718 @item @emph{Arguments}:
719 @multitable @columnfractions .15 .70
720 @item @var{Z} @tab The type of the argument shall be @code{COMPLEX(*)}.
723 @item @emph{Return value}:
724 The return value is of type real with the
725 kind type parameter of the argument.
727 @item @emph{Example}:
732 z4 = cmplx(1.e0_4, 0.e0_4)
733 z8 = cmplx(0.e0_8, 1.e0_8)
734 print *, aimag(z4), dimag(z8)
735 end program test_aimag
738 @item @emph{Specific names}:
739 @multitable @columnfractions .20 .20 .20 .25
740 @item Name @tab Argument @tab Return type @tab Standard
741 @item @code{DIMAG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{REAL(8)} @tab GNU extension
742 @item @code{IMAG(Z)} @tab @code{COMPLEX(*) Z} @tab @code{REAL(*)} @tab GNU extension
743 @item @code{IMAGPART(Z)} @tab @code{COMPLEX(*) Z} @tab @code{REAL(*)} @tab GNU extension
750 @section @code{AINT} --- Truncate to a whole number
754 @cindex rounding, floor
757 @item @emph{Description}:
758 @code{AINT(X [, KIND])} truncates its argument to a whole number.
760 @item @emph{Standard}:
767 @code{RESULT = AINT(X [, KIND])}
769 @item @emph{Arguments}:
770 @multitable @columnfractions .15 .70
771 @item @var{X} @tab The type of the argument shall be @code{REAL(*)}.
772 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
773 expression indicating the kind parameter of
777 @item @emph{Return value}:
778 The return value is of type real with the kind type parameter of the
779 argument if the optional @var{KIND} is absent; otherwise, the kind
780 type parameter will be given by @var{KIND}. If the magnitude of
781 @var{X} is less than one, then @code{AINT(X)} returns zero. If the
782 magnitude is equal to or greater than one, then it returns the largest
783 whole number that does not exceed its magnitude. The sign is the same
784 as the sign of @var{X}.
786 @item @emph{Example}:
793 print *, aint(x4), dint(x8)
795 end program test_aint
798 @item @emph{Specific names}:
799 @multitable @columnfractions .20 .20 .20 .25
800 @item Name @tab Argument @tab Return type @tab Standard
801 @item @code{DINT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
808 @section @code{ALARM} --- Execute a routine after a given delay
810 @cindex delayed execution
813 @item @emph{Description}:
814 @code{ALARM(SECONDS, HANDLER [, STATUS])} causes external subroutine @var{HANDLER}
815 to be executed after a delay of @var{SECONDS} by using @code{alarm(2)} to
816 set up a signal and @code{signal(2)} to catch it. If @var{STATUS} is
817 supplied, it will be returned with the number of seconds remaining until
818 any previously scheduled alarm was due to be delivered, or zero if there
819 was no previously scheduled alarm.
821 @item @emph{Standard}:
828 @code{CALL ALARM(SECONDS, HANDLER [, STATUS])}
830 @item @emph{Arguments}:
831 @multitable @columnfractions .15 .70
832 @item @var{SECONDS} @tab The type of the argument shall be a scalar
833 @code{INTEGER}. It is @code{INTENT(IN)}.
834 @item @var{HANDLER} @tab Signal handler (@code{INTEGER FUNCTION} or
835 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar. The scalar
836 values may be either @code{SIG_IGN=1} to ignore the alarm generated
837 or @code{SIG_DFL=0} to set the default action. It is @code{INTENT(IN)}.
838 @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
839 variable of the default @code{INTEGER} kind. It is @code{INTENT(OUT)}.
842 @item @emph{Example}:
845 external handler_print
847 call alarm (3, handler_print, i)
850 end program test_alarm
852 This will cause the external routine @var{handler_print} to be called
859 @section @code{ALL} --- All values in @var{MASK} along @var{DIM} are true
861 @cindex array, apply condition
862 @cindex array, condition testing
865 @item @emph{Description}:
866 @code{ALL(MASK [, DIM])} determines if all the values are true in @var{MASK}
867 in the array along dimension @var{DIM}.
869 @item @emph{Standard}:
873 transformational function
876 @code{RESULT = ALL(MASK [, DIM])}
878 @item @emph{Arguments}:
879 @multitable @columnfractions .15 .70
880 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL(*)} and
881 it shall not be scalar.
882 @item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer
883 with a value that lies between one and the rank of @var{MASK}.
886 @item @emph{Return value}:
887 @code{ALL(MASK)} returns a scalar value of type @code{LOGICAL(*)} where
888 the kind type parameter is the same as the kind type parameter of
889 @var{MASK}. If @var{DIM} is present, then @code{ALL(MASK, DIM)} returns
890 an array with the rank of @var{MASK} minus 1. The shape is determined from
891 the shape of @var{MASK} where the @var{DIM} dimension is elided.
895 @code{ALL(MASK)} is true if all elements of @var{MASK} are true.
896 It also is true if @var{MASK} has zero size; otherwise, it is false.
898 If the rank of @var{MASK} is one, then @code{ALL(MASK,DIM)} is equivalent
899 to @code{ALL(MASK)}. If the rank is greater than one, then @code{ALL(MASK,DIM)}
900 is determined by applying @code{ALL} to the array sections.
903 @item @emph{Example}:
907 l = all((/.true., .true., .true./))
912 integer a(2,3), b(2,3)
916 print *, all(a .eq. b, 1)
917 print *, all(a .eq. b, 2)
918 end subroutine section
926 @section @code{ALLOCATED} --- Status of an allocatable entity
928 @cindex allocation, status
931 @item @emph{Description}:
932 @code{ALLOCATED(X)} checks the status of whether @var{X} is allocated.
934 @item @emph{Standard}:
941 @code{RESULT = ALLOCATED(X)}
943 @item @emph{Arguments}:
944 @multitable @columnfractions .15 .70
945 @item @var{X} @tab The argument shall be an @code{ALLOCATABLE} array.
948 @item @emph{Return value}:
949 The return value is a scalar @code{LOGICAL} with the default logical
950 kind type parameter. If @var{X} is allocated, @code{ALLOCATED(X)}
951 is @code{.TRUE.}; otherwise, it returns the @code{.TRUE.}
953 @item @emph{Example}:
955 program test_allocated
957 real(4), allocatable :: x(:)
958 if (allocated(x) .eqv. .false.) allocate(x(i))
959 end program test_allocated
966 @section @code{AND} --- Bitwise logical AND
968 @cindex bitwise logical and
969 @cindex logical and, bitwise
972 @item @emph{Description}:
973 Bitwise logical @code{AND}.
975 This intrinsic routine is provided for backwards compatibility with
976 GNU Fortran 77. For integer arguments, programmers should consider
977 the use of the @ref{IAND} intrinsic defined by the Fortran standard.
979 @item @emph{Standard}:
983 Non-elemental function
986 @code{RESULT = AND(I, J)}
988 @item @emph{Arguments}:
989 @multitable @columnfractions .15 .70
990 @item @var{I} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
991 @item @var{J} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
994 @item @emph{Return value}:
995 The return type is either @code{INTEGER(*)} or @code{LOGICAL} after
996 cross-promotion of the arguments.
998 @item @emph{Example}:
1001 LOGICAL :: T = .TRUE., F = .FALSE.
1003 DATA a / Z'F' /, b / Z'3' /
1005 WRITE (*,*) AND(T, T), AND(T, F), AND(F, T), AND(F, F)
1006 WRITE (*,*) AND(a, b)
1010 @item @emph{See also}:
1011 F95 elemental function: @ref{IAND}
1017 @section @code{ANINT} --- Nearest whole number
1021 @cindex rounding, ceiling
1024 @item @emph{Description}:
1025 @code{ANINT(X [, KIND])} rounds its argument to the nearest whole number.
1027 @item @emph{Standard}:
1033 @item @emph{Syntax}:
1034 @code{RESULT = ANINT(X [, KIND])}
1036 @item @emph{Arguments}:
1037 @multitable @columnfractions .15 .70
1038 @item @var{X} @tab The type of the argument shall be @code{REAL(*)}.
1039 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
1040 expression indicating the kind parameter of
1044 @item @emph{Return value}:
1045 The return value is of type real with the kind type parameter of the
1046 argument if the optional @var{KIND} is absent; otherwise, the kind
1047 type parameter will be given by @var{KIND}. If @var{X} is greater than
1048 zero, then @code{ANINT(X)} returns @code{AINT(X+0.5)}. If @var{X} is
1049 less than or equal to zero, then it returns @code{AINT(X-0.5)}.
1051 @item @emph{Example}:
1058 print *, anint(x4), dnint(x8)
1060 end program test_anint
1063 @item @emph{Specific names}:
1064 @multitable @columnfractions .20 .20 .20 .25
1065 @item Name @tab Argument @tab Return type @tab Standard
1066 @item @code{DNINT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1073 @section @code{ANY} --- Any value in @var{MASK} along @var{DIM} is true
1075 @cindex array, apply condition
1076 @cindex array, condition testing
1079 @item @emph{Description}:
1080 @code{ANY(MASK [, DIM])} determines if any of the values in the logical array
1081 @var{MASK} along dimension @var{DIM} are @code{.TRUE.}.
1083 @item @emph{Standard}:
1087 transformational function
1089 @item @emph{Syntax}:
1090 @code{RESULT = ANY(MASK [, DIM])}
1092 @item @emph{Arguments}:
1093 @multitable @columnfractions .15 .70
1094 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL(*)} and
1095 it shall not be scalar.
1096 @item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer
1097 with a value that lies between one and the rank of @var{MASK}.
1100 @item @emph{Return value}:
1101 @code{ANY(MASK)} returns a scalar value of type @code{LOGICAL(*)} where
1102 the kind type parameter is the same as the kind type parameter of
1103 @var{MASK}. If @var{DIM} is present, then @code{ANY(MASK, DIM)} returns
1104 an array with the rank of @var{MASK} minus 1. The shape is determined from
1105 the shape of @var{MASK} where the @var{DIM} dimension is elided.
1109 @code{ANY(MASK)} is true if any element of @var{MASK} is true;
1110 otherwise, it is false. It also is false if @var{MASK} has zero size.
1112 If the rank of @var{MASK} is one, then @code{ANY(MASK,DIM)} is equivalent
1113 to @code{ANY(MASK)}. If the rank is greater than one, then @code{ANY(MASK,DIM)}
1114 is determined by applying @code{ANY} to the array sections.
1117 @item @emph{Example}:
1121 l = any((/.true., .true., .true./))
1126 integer a(2,3), b(2,3)
1130 print *, any(a .eq. b, 1)
1131 print *, any(a .eq. b, 2)
1132 end subroutine section
1133 end program test_any
1140 @section @code{ASIN} --- Arcsine function
1143 @cindex trigonometric function, sine, inverse
1144 @cindex sine, inverse
1147 @item @emph{Description}:
1148 @code{ASIN(X)} computes the arcsine of its @var{X} (inverse of @code{SIN(X)}).
1150 @item @emph{Standard}:
1156 @item @emph{Syntax}:
1157 @code{RESULT = ASIN(X)}
1159 @item @emph{Arguments}:
1160 @multitable @columnfractions .15 .70
1161 @item @var{X} @tab The type shall be @code{REAL(*)}, and a magnitude that is
1165 @item @emph{Return value}:
1166 The return value is of type @code{REAL(*)} and it lies in the
1167 range @math{-\pi / 2 \leq \asin (x) \leq \pi / 2}. The kind type
1168 parameter is the same as @var{X}.
1170 @item @emph{Example}:
1173 real(8) :: x = 0.866_8
1175 end program test_asin
1178 @item @emph{Specific names}:
1179 @multitable @columnfractions .20 .20 .20 .25
1180 @item Name @tab Argument @tab Return type @tab Standard
1181 @item @code{DASIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1184 @item @emph{See also}:
1185 Inverse function: @ref{SIN}
1192 @section @code{ASINH} --- Hyperbolic arcsine function
1195 @cindex area hyperbolic sine
1196 @cindex hyperbolic arcsine
1197 @cindex hyperbolic function, sine, inverse
1198 @cindex sine, hyperbolic, inverse
1201 @item @emph{Description}:
1202 @code{ASINH(X)} computes the hyperbolic arcsine of @var{X} (inverse of @code{SINH(X)}).
1204 @item @emph{Standard}:
1210 @item @emph{Syntax}:
1211 @code{RESULT = ASINH(X)}
1213 @item @emph{Arguments}:
1214 @multitable @columnfractions .15 .70
1215 @item @var{X} @tab The type shall be @code{REAL(*)}, with @var{X} a real number.
1218 @item @emph{Return value}:
1219 The return value is of type @code{REAL(*)} and it lies in the
1220 range @math{-\infty \leq \asinh (x) \leq \infty}.
1222 @item @emph{Example}:
1225 REAL(8), DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1226 WRITE (*,*) ASINH(x)
1230 @item @emph{Specific names}:
1231 @multitable @columnfractions .20 .20 .20 .25
1232 @item Name @tab Argument @tab Return type @tab Standard
1233 @item @code{DASINH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension.
1236 @item @emph{See also}:
1237 Inverse function: @ref{SINH}
1243 @section @code{ASSOCIATED} --- Status of a pointer or pointer/target pair
1245 @cindex pointer, status
1246 @cindex association status
1249 @item @emph{Description}:
1250 @code{ASSOCIATED(PTR [, TGT])} determines the status of the pointer @var{PTR}
1251 or if @var{PTR} is associated with the target @var{TGT}.
1253 @item @emph{Standard}:
1259 @item @emph{Syntax}:
1260 @code{RESULT = ASSOCIATED(PTR [, TGT])}
1262 @item @emph{Arguments}:
1263 @multitable @columnfractions .15 .70
1264 @item @var{PTR} @tab @var{PTR} shall have the @code{POINTER} attribute and
1265 it can be of any type.
1266 @item @var{TGT} @tab (Optional) @var{TGT} shall be a @code{POINTER} or
1267 a @code{TARGET}. It must have the same type, kind type parameter, and
1268 array rank as @var{PTR}.
1270 The status of neither @var{PTR} nor @var{TGT} can be undefined.
1272 @item @emph{Return value}:
1273 @code{ASSOCIATED(PTR)} returns a scalar value of type @code{LOGICAL(4)}.
1274 There are several cases:
1276 @item (A) If the optional @var{TGT} is not present, then @code{ASSOCIATED(PTR)}
1277 is true if @var{PTR} is associated with a target; otherwise, it returns false.
1278 @item (B) If @var{TGT} is present and a scalar target, the result is true if
1280 is not a 0 sized storage sequence and the target associated with @var{PTR}
1281 occupies the same storage units. If @var{PTR} is disassociated, then the
1283 @item (C) If @var{TGT} is present and an array target, the result is true if
1284 @var{TGT} and @var{PTR} have the same shape, are not 0 sized arrays, are
1285 arrays whose elements are not 0 sized storage sequences, and @var{TGT} and
1286 @var{PTR} occupy the same storage units in array element order.
1287 As in case(B), the result is false, if @var{PTR} is disassociated.
1288 @item (D) If @var{TGT} is present and an scalar pointer, the result is true if
1289 target associated with @var{PTR} and the target associated with @var{TGT}
1290 are not 0 sized storage sequences and occupy the same storage units.
1291 The result is false, if either @var{TGT} or @var{PTR} is disassociated.
1292 @item (E) If @var{TGT} is present and an array pointer, the result is true if
1293 target associated with @var{PTR} and the target associated with @var{TGT}
1294 have the same shape, are not 0 sized arrays, are arrays whose elements are
1295 not 0 sized storage sequences, and @var{TGT} and @var{PTR} occupy the same
1296 storage units in array element order.
1297 The result is false, if either @var{TGT} or @var{PTR} is disassociated.
1300 @item @emph{Example}:
1302 program test_associated
1304 real, target :: tgt(2) = (/1., 2./)
1305 real, pointer :: ptr(:)
1307 if (associated(ptr) .eqv. .false.) call abort
1308 if (associated(ptr,tgt) .eqv. .false.) call abort
1309 end program test_associated
1312 @item @emph{See also}:
1319 @section @code{ATAN} --- Arctangent function
1322 @cindex trigonometric function, tangent, inverse
1323 @cindex tangent, inverse
1326 @item @emph{Description}:
1327 @code{ATAN(X)} computes the arctangent of @var{X}.
1329 @item @emph{Standard}:
1335 @item @emph{Syntax}:
1336 @code{RESULT = ATAN(X)}
1338 @item @emph{Arguments}:
1339 @multitable @columnfractions .15 .70
1340 @item @var{X} @tab The type shall be @code{REAL(*)}.
1343 @item @emph{Return value}:
1344 The return value is of type @code{REAL(*)} and it lies in the
1345 range @math{ - \pi / 2 \leq \atan (x) \leq \pi / 2}.
1347 @item @emph{Example}:
1350 real(8) :: x = 2.866_8
1352 end program test_atan
1355 @item @emph{Specific names}:
1356 @multitable @columnfractions .20 .20 .20 .25
1357 @item Name @tab Argument @tab Return type @tab Standard
1358 @item @code{DATAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1361 @item @emph{See also}:
1362 Inverse function: @ref{TAN}
1369 @section @code{ATAN2} --- Arctangent function
1372 @cindex trigonometric function, tangent, inverse
1373 @cindex tangent, inverse
1376 @item @emph{Description}:
1377 @code{ATAN2(Y,X)} computes the arctangent of the complex number
1380 @item @emph{Standard}:
1386 @item @emph{Syntax}:
1387 @code{RESULT = ATAN2(Y,X)}
1389 @item @emph{Arguments}:
1390 @multitable @columnfractions .15 .70
1391 @item @var{Y} @tab The type shall be @code{REAL(*)}.
1392 @item @var{X} @tab The type and kind type parameter shall be the same as @var{Y}.
1393 If @var{Y} is zero, then @var{X} must be nonzero.
1396 @item @emph{Return value}:
1397 The return value has the same type and kind type parameter as @var{Y}.
1398 It is the principal value of the complex number @math{X + i Y}. If
1399 @var{X} is nonzero, then it lies in the range @math{-\pi \le \atan (x) \leq \pi}.
1400 The sign is positive if @var{Y} is positive. If @var{Y} is zero, then
1401 the return value is zero if @var{X} is positive and @math{\pi} if @var{X}
1402 is negative. Finally, if @var{X} is zero, then the magnitude of the result
1405 @item @emph{Example}:
1408 real(4) :: x = 1.e0_4, y = 0.5e0_4
1410 end program test_atan2
1413 @item @emph{Specific names}:
1414 @multitable @columnfractions .20 .20 .20 .25
1415 @item Name @tab Argument @tab Return type @tab Standard
1416 @item @code{DATAN2(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1423 @section @code{ATANH} --- Hyperbolic arctangent function
1426 @cindex area hyperbolic tangent
1427 @cindex hyperbolic arctangent
1428 @cindex hyperbolic function, tangent, inverse
1429 @cindex tangent, hyperbolic, inverse
1432 @item @emph{Description}:
1433 @code{ATANH(X)} computes the hyperbolic arctangent of @var{X} (inverse
1436 @item @emph{Standard}:
1442 @item @emph{Syntax}:
1443 @code{RESULT = ATANH(X)}
1445 @item @emph{Arguments}:
1446 @multitable @columnfractions .15 .70
1447 @item @var{X} @tab The type shall be @code{REAL(*)} with a magnitude
1448 that is less than or equal to one.
1451 @item @emph{Return value}:
1452 The return value is of type @code{REAL(*)} and it lies in the
1453 range @math{-\infty \leq \atanh(x) \leq \infty}.
1455 @item @emph{Example}:
1458 REAL, DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1459 WRITE (*,*) ATANH(x)
1463 @item @emph{Specific names}:
1464 @multitable @columnfractions .20 .20 .20 .25
1465 @item Name @tab Argument @tab Return type @tab Standard
1466 @item @code{DATANH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1469 @item @emph{See also}:
1470 Inverse function: @ref{TANH}
1476 @section @code{BESJ0} --- Bessel function of the first kind of order 0
1479 @cindex Bessel function, first kind
1482 @item @emph{Description}:
1483 @code{BESJ0(X)} computes the Bessel function of the first kind of order 0
1486 @item @emph{Standard}:
1492 @item @emph{Syntax}:
1493 @code{RESULT = BESJ0(X)}
1495 @item @emph{Arguments}:
1496 @multitable @columnfractions .15 .70
1497 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1500 @item @emph{Return value}:
1501 The return value is of type @code{REAL(*)} and it lies in the
1502 range @math{ - 0.4027... \leq Bessel (0,x) \leq 1}.
1504 @item @emph{Example}:
1507 real(8) :: x = 0.0_8
1509 end program test_besj0
1512 @item @emph{Specific names}:
1513 @multitable @columnfractions .20 .20 .20 .25
1514 @item Name @tab Argument @tab Return type @tab Standard
1515 @item @code{DBESJ0(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1522 @section @code{BESJ1} --- Bessel function of the first kind of order 1
1525 @cindex Bessel function, first kind
1528 @item @emph{Description}:
1529 @code{BESJ1(X)} computes the Bessel function of the first kind of order 1
1532 @item @emph{Standard}:
1538 @item @emph{Syntax}:
1539 @code{RESULT = BESJ1(X)}
1541 @item @emph{Arguments}:
1542 @multitable @columnfractions .15 .70
1543 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1546 @item @emph{Return value}:
1547 The return value is of type @code{REAL(*)} and it lies in the
1548 range @math{ - 0.5818... \leq Bessel (0,x) \leq 0.5818 }.
1550 @item @emph{Example}:
1553 real(8) :: x = 1.0_8
1555 end program test_besj1
1558 @item @emph{Specific names}:
1559 @multitable @columnfractions .20 .20 .20 .25
1560 @item Name @tab Argument @tab Return type @tab Standard
1561 @item @code{DBESJ1(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1568 @section @code{BESJN} --- Bessel function of the first kind
1571 @cindex Bessel function, first kind
1574 @item @emph{Description}:
1575 @code{BESJN(N, X)} computes the Bessel function of the first kind of order
1578 If both arguments are arrays, their ranks and shapes shall conform.
1580 @item @emph{Standard}:
1586 @item @emph{Syntax}:
1587 @code{RESULT = BESJN(N, X)}
1589 @item @emph{Arguments}:
1590 @multitable @columnfractions .15 .70
1591 @item @var{N} @tab Shall be a scalar or an array of type @code{INTEGER(*)}.
1592 @item @var{X} @tab Shall be a scalar or an array of type @code{REAL(*)}.
1595 @item @emph{Return value}:
1596 The return value is a scalar of type @code{REAL(*)}.
1598 @item @emph{Example}:
1601 real(8) :: x = 1.0_8
1603 end program test_besjn
1606 @item @emph{Specific names}:
1607 @multitable @columnfractions .20 .20 .20 .25
1608 @item Name @tab Argument @tab Return type @tab Standard
1609 @item @code{DBESJN(X)} @tab @code{INTEGER(*) N} @tab @code{REAL(8)} @tab GNU extension
1610 @item @tab @code{REAL(8) X} @tab @tab
1617 @section @code{BESY0} --- Bessel function of the second kind of order 0
1620 @cindex Bessel function, second kind
1623 @item @emph{Description}:
1624 @code{BESY0(X)} computes the Bessel function of the second kind of order 0
1627 @item @emph{Standard}:
1633 @item @emph{Syntax}:
1634 @code{RESULT = BESY0(X)}
1636 @item @emph{Arguments}:
1637 @multitable @columnfractions .15 .70
1638 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1641 @item @emph{Return value}:
1642 The return value is a scalar of type @code{REAL(*)}.
1644 @item @emph{Example}:
1647 real(8) :: x = 0.0_8
1649 end program test_besy0
1652 @item @emph{Specific names}:
1653 @multitable @columnfractions .20 .20 .20 .25
1654 @item Name @tab Argument @tab Return type @tab Standard
1655 @item @code{DBESY0(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1662 @section @code{BESY1} --- Bessel function of the second kind of order 1
1665 @cindex Bessel function, second kind
1668 @item @emph{Description}:
1669 @code{BESY1(X)} computes the Bessel function of the second kind of order 1
1672 @item @emph{Standard}:
1678 @item @emph{Syntax}:
1679 @code{RESULT = BESY1(X)}
1681 @item @emph{Arguments}:
1682 @multitable @columnfractions .15 .70
1683 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1686 @item @emph{Return value}:
1687 The return value is a scalar of type @code{REAL(*)}.
1689 @item @emph{Example}:
1692 real(8) :: x = 1.0_8
1694 end program test_besy1
1697 @item @emph{Specific names}:
1698 @multitable @columnfractions .20 .20 .20 .25
1699 @item Name @tab Argument @tab Return type @tab Standard
1700 @item @code{DBESY1(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1707 @section @code{BESYN} --- Bessel function of the second kind
1710 @cindex Bessel function, second kind
1713 @item @emph{Description}:
1714 @code{BESYN(N, X)} computes the Bessel function of the second kind of order
1717 If both arguments are arrays, their ranks and shapes shall conform.
1719 @item @emph{Standard}:
1725 @item @emph{Syntax}:
1726 @code{RESULT = BESYN(N, X)}
1728 @item @emph{Arguments}:
1729 @multitable @columnfractions .15 .70
1730 @item @var{N} @tab Shall be a scalar or an array of type @code{INTEGER(*)}.
1731 @item @var{X} @tab Shall be a scalar or an array of type @code{REAL(*)}.
1734 @item @emph{Return value}:
1735 The return value is a scalar of type @code{REAL(*)}.
1737 @item @emph{Example}:
1740 real(8) :: x = 1.0_8
1742 end program test_besyn
1745 @item @emph{Specific names}:
1746 @multitable @columnfractions .20 .20 .20 .25
1747 @item Name @tab Argument @tab Return type @tab Standard
1748 @item @code{DBESYN(N,X)} @tab @code{INTEGER(*) N} @tab @code{REAL(8)} @tab GNU extension
1749 @item @tab @code{REAL(8) X} @tab @tab
1756 @section @code{BIT_SIZE} --- Bit size inquiry function
1758 @cindex bits, number of
1759 @cindex size of a variable, in bits
1762 @item @emph{Description}:
1763 @code{BIT_SIZE(I)} returns the number of bits (integer precision plus sign bit)
1764 represented by the type of @var{I}.
1766 @item @emph{Standard}:
1772 @item @emph{Syntax}:
1773 @code{RESULT = BIT_SIZE(I)}
1775 @item @emph{Arguments}:
1776 @multitable @columnfractions .15 .70
1777 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1780 @item @emph{Return value}:
1781 The return value is of type @code{INTEGER(*)}
1783 @item @emph{Example}:
1785 program test_bit_size
1790 end program test_bit_size
1797 @section @code{BTEST} --- Bit test function
1799 @cindex bits, testing
1802 @item @emph{Description}:
1803 @code{BTEST(I,POS)} returns logical @code{.TRUE.} if the bit at @var{POS}
1806 @item @emph{Standard}:
1812 @item @emph{Syntax}:
1813 @code{RESULT = BTEST(I, POS)}
1815 @item @emph{Arguments}:
1816 @multitable @columnfractions .15 .70
1817 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1818 @item @var{POS} @tab The type shall be @code{INTEGER(*)}.
1821 @item @emph{Return value}:
1822 The return value is of type @code{LOGICAL}
1824 @item @emph{Example}:
1827 integer :: i = 32768 + 1024 + 64
1831 bool = btest(i, pos)
1834 end program test_btest
1841 @section @code{CEILING} --- Integer ceiling function
1844 @cindex rounding, ceiling
1847 @item @emph{Description}:
1848 @code{CEILING(X)} returns the least integer greater than or equal to @var{X}.
1850 @item @emph{Standard}:
1856 @item @emph{Syntax}:
1857 @code{RESULT = CEILING(X [, KIND])}
1859 @item @emph{Arguments}:
1860 @multitable @columnfractions .15 .70
1861 @item @var{X} @tab The type shall be @code{REAL(*)}.
1862 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
1863 expression indicating the kind parameter of
1867 @item @emph{Return value}:
1868 The return value is of type @code{INTEGER(KIND)}
1870 @item @emph{Example}:
1872 program test_ceiling
1875 print *, ceiling(x) ! returns 64
1876 print *, ceiling(y) ! returns -63
1877 end program test_ceiling
1880 @item @emph{See also}:
1881 @ref{FLOOR}, @ref{NINT}
1888 @section @code{CHAR} --- Character conversion function
1890 @cindex conversion, to character
1893 @item @emph{Description}:
1894 @code{CHAR(I [, KIND])} returns the character represented by the integer @var{I}.
1896 @item @emph{Standard}:
1902 @item @emph{Syntax}:
1903 @code{RESULT = CHAR(I [, KIND])}
1905 @item @emph{Arguments}:
1906 @multitable @columnfractions .15 .70
1907 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1908 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
1909 expression indicating the kind parameter of
1913 @item @emph{Return value}:
1914 The return value is of type @code{CHARACTER(1)}
1916 @item @emph{Example}:
1922 print *, i, c ! returns 'J'
1923 end program test_char
1927 See @ref{ICHAR} for a discussion of converting between numerical values
1928 and formatted string representations.
1930 @item @emph{See also}:
1931 @ref{ACHAR}, @ref{IACHAR}, @ref{ICHAR}
1938 @section @code{CHDIR} --- Change working directory
1940 @cindex system, working directory
1943 @item @emph{Description}:
1944 Change current working directory to a specified path.
1946 This intrinsic is provided in both subroutine and function forms; however,
1947 only one form can be used in any given program unit.
1949 @item @emph{Standard}:
1953 Subroutine, non-elemental function
1955 @item @emph{Syntax}:
1956 @multitable @columnfractions .80
1957 @item @code{CALL CHDIR(NAME [, STATUS])}
1958 @item @code{STATUS = CHDIR(NAME)}
1961 @item @emph{Arguments}:
1962 @multitable @columnfractions .15 .70
1963 @item @var{NAME} @tab The type shall be @code{CHARACTER(*)} and shall
1964 specify a valid path within the file system.
1965 @item @var{STATUS} @tab (Optional) @code{INTEGER} status flag of the default
1966 kind. Returns 0 on success, and a system specific
1967 and non-zero error code otherwise.
1970 @item @emph{Example}:
1973 CHARACTER(len=255) :: path
1975 WRITE(*,*) TRIM(path)
1978 WRITE(*,*) TRIM(path)
1982 @item @emph{See also}:
1989 @section @code{CHMOD} --- Change access permissions of files
1991 @cindex file system, change access mode
1994 @item @emph{Description}:
1995 @code{CHMOD} changes the permissions of a file. This function invokes
1996 @code{/bin/chmod} and might therefore not work on all platforms.
1998 This intrinsic is provided in both subroutine and function forms; however,
1999 only one form can be used in any given program unit.
2001 @item @emph{Standard}:
2005 Subroutine, non-elemental function
2007 @item @emph{Syntax}:
2008 @multitable @columnfractions .80
2009 @item @code{CALL CHMOD(NAME, MODE[, STATUS])}
2010 @item @code{STATUS = CHMOD(NAME, MODE)}
2013 @item @emph{Arguments}:
2014 @multitable @columnfractions .15 .70
2015 @item @var{NAME} @tab Scalar @code{CHARACTER} with the file name.
2016 Trailing blanks are ignored unless the character @code{achar(0)} is
2017 present, then all characters up to and excluding @code{achar(0)} are
2018 used as the file name.
2020 @item @var{MODE} @tab Scalar @code{CHARACTER} giving the file permission.
2021 @var{MODE} uses the same syntax as the @var{MODE} argument of
2024 @item @var{STATUS} @tab (optional) scalar @code{INTEGER}, which is
2025 @code{0} on success and non-zero otherwise.
2028 @item @emph{Return value}:
2029 In either syntax, @var{STATUS} is set to @code{0} on success and non-zero
2032 @item @emph{Example}:
2033 @code{CHMOD} as subroutine
2038 call chmod('test.dat','u+x',status)
2039 print *, 'Status: ', status
2040 end program chmod_test
2042 @code{CHMOD} as non-elemental function:
2047 status = chmod('test.dat','u+x')
2048 print *, 'Status: ', status
2049 end program chmod_test
2057 @section @code{CMPLX} --- Complex conversion function
2059 @cindex complex numbers, conversion to
2060 @cindex conversion, to complex
2063 @item @emph{Description}:
2064 @code{CMPLX(X [, Y [, KIND]])} returns a complex number where @var{X} is converted to
2065 the real component. If @var{Y} is present it is converted to the imaginary
2066 component. If @var{Y} is not present then the imaginary component is set to
2067 0.0. If @var{X} is complex then @var{Y} must not be present.
2069 @item @emph{Standard}:
2075 @item @emph{Syntax}:
2076 @code{RESULT = CMPLX(X [, Y [, KIND]])}
2078 @item @emph{Arguments}:
2079 @multitable @columnfractions .15 .70
2080 @item @var{X} @tab The type may be @code{INTEGER(*)}, @code{REAL(*)},
2081 or @code{COMPLEX(*)}.
2082 @item @var{Y} @tab (Optional; only allowed if @var{X} is not
2083 @code{COMPLEX(*)}.) May be @code{INTEGER(*)}
2085 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
2086 expression indicating the kind parameter of
2090 @item @emph{Return value}:
2091 The return value is of @code{COMPLEX} type, with a kind equal to
2092 @var{KIND} if it is specified. If @var{KIND} is not specified, the
2093 result is of the default @code{COMPLEX} kind, regardless of the kinds of
2094 @var{X} and @var{Y}.
2096 @item @emph{Example}:
2103 print *, z, cmplx(x)
2104 end program test_cmplx
2107 @item @emph{See also}:
2113 @node COMMAND_ARGUMENT_COUNT
2114 @section @code{COMMAND_ARGUMENT_COUNT} --- Get number of command line arguments
2115 @fnindex COMMAND_ARGUMENT_COUNT
2116 @cindex command-line arguments
2117 @cindex command-line arguments, number of
2118 @cindex arguments, to program
2121 @item @emph{Description}:
2122 @code{COMMAND_ARGUMENT_COUNT()} returns the number of arguments passed on the
2123 command line when the containing program was invoked.
2125 @item @emph{Standard}:
2131 @item @emph{Syntax}:
2132 @code{RESULT = COMMAND_ARGUMENT_COUNT()}
2134 @item @emph{Arguments}:
2135 @multitable @columnfractions .15 .70
2139 @item @emph{Return value}:
2140 The return value is of type @code{INTEGER(4)}
2142 @item @emph{Example}:
2144 program test_command_argument_count
2146 count = command_argument_count()
2148 end program test_command_argument_count
2151 @item @emph{See also}:
2152 @ref{GET_COMMAND}, @ref{GET_COMMAND_ARGUMENT}
2158 @section @code{COMPLEX} --- Complex conversion function
2160 @cindex complex numbers, conversion to
2161 @cindex conversion, to complex
2164 @item @emph{Description}:
2165 @code{COMPLEX(X, Y)} returns a complex number where @var{X} is converted
2166 to the real component and @var{Y} is converted to the imaginary
2169 @item @emph{Standard}:
2175 @item @emph{Syntax}:
2176 @code{RESULT = COMPLEX(X, Y)}
2178 @item @emph{Arguments}:
2179 @multitable @columnfractions .15 .70
2180 @item @var{X} @tab The type may be @code{INTEGER(*)} or @code{REAL(*)}.
2181 @item @var{Y} @tab The type may be @code{INTEGER(*)} or @code{REAL(*)}.
2184 @item @emph{Return value}:
2185 If @var{X} and @var{Y} are both of @code{INTEGER} type, then the return
2186 value is of default @code{COMPLEX} type.
2188 If @var{X} and @var{Y} are of @code{REAL} type, or one is of @code{REAL}
2189 type and one is of @code{INTEGER} type, then the return value is of
2190 @code{COMPLEX} type with a kind equal to that of the @code{REAL}
2191 argument with the highest precision.
2193 @item @emph{Example}:
2195 program test_complex
2198 print *, complex(i, x)
2199 end program test_complex
2202 @item @emph{See also}:
2209 @section @code{CONJG} --- Complex conjugate function
2212 @cindex complex conjugate
2215 @item @emph{Description}:
2216 @code{CONJG(Z)} returns the conjugate of @var{Z}. If @var{Z} is @code{(x, y)}
2217 then the result is @code{(x, -y)}
2219 @item @emph{Standard}:
2220 F77 and later, has overloads that are GNU extensions
2225 @item @emph{Syntax}:
2228 @item @emph{Arguments}:
2229 @multitable @columnfractions .15 .70
2230 @item @var{Z} @tab The type shall be @code{COMPLEX(*)}.
2233 @item @emph{Return value}:
2234 The return value is of type @code{COMPLEX(*)}.
2236 @item @emph{Example}:
2239 complex :: z = (2.0, 3.0)
2240 complex(8) :: dz = (2.71_8, -3.14_8)
2245 end program test_conjg
2248 @item @emph{Specific names}:
2249 @multitable @columnfractions .20 .20 .20 .25
2250 @item Name @tab Argument @tab Return type @tab Standard
2251 @item @code{DCONJG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
2258 @section @code{COS} --- Cosine function
2264 @cindex trigonometric function, cosine
2268 @item @emph{Description}:
2269 @code{COS(X)} computes the cosine of @var{X}.
2271 @item @emph{Standard}:
2272 F77 and later, has overloads that are GNU extensions
2277 @item @emph{Syntax}:
2278 @code{RESULT = COS(X)}
2280 @item @emph{Arguments}:
2281 @multitable @columnfractions .15 .70
2282 @item @var{X} @tab The type shall be @code{REAL(*)} or
2286 @item @emph{Return value}:
2287 The return value is of type @code{REAL(*)} and it lies in the
2288 range @math{ -1 \leq \cos (x) \leq 1}. The kind type
2289 parameter is the same as @var{X}.
2291 @item @emph{Example}:
2296 end program test_cos
2299 @item @emph{Specific names}:
2300 @multitable @columnfractions .20 .20 .20 .25
2301 @item Name @tab Argument @tab Return type @tab Standard
2302 @item @code{DCOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
2303 @item @code{CCOS(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab F77 and later
2304 @item @code{ZCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
2305 @item @code{CDCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
2308 @item @emph{See also}:
2309 Inverse function: @ref{ACOS}
2316 @section @code{COSH} --- Hyperbolic cosine function
2319 @cindex hyperbolic cosine
2320 @cindex hyperbolic function, cosine
2321 @cindex cosine, hyperbolic
2324 @item @emph{Description}:
2325 @code{COSH(X)} computes the hyperbolic cosine of @var{X}.
2327 @item @emph{Standard}:
2333 @item @emph{Syntax}:
2336 @item @emph{Arguments}:
2337 @multitable @columnfractions .15 .70
2338 @item @var{X} @tab The type shall be @code{REAL(*)}.
2341 @item @emph{Return value}:
2342 The return value is of type @code{REAL(*)} and it is positive
2343 (@math{ \cosh (x) \geq 0 }.
2345 @item @emph{Example}:
2348 real(8) :: x = 1.0_8
2350 end program test_cosh
2353 @item @emph{Specific names}:
2354 @multitable @columnfractions .20 .20 .20 .25
2355 @item Name @tab Argument @tab Return type @tab Standard
2356 @item @code{DCOSH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
2359 @item @emph{See also}:
2360 Inverse function: @ref{ACOSH}
2367 @section @code{COUNT} --- Count function
2369 @cindex array, conditionally count elements
2370 @cindex array, element counting
2371 @cindex array, number of elements
2374 @item @emph{Description}:
2375 @code{COUNT(MASK [, DIM])} counts the number of @code{.TRUE.} elements of
2376 @var{MASK} along the dimension of @var{DIM}. If @var{DIM} is omitted it is
2377 taken to be @code{1}. @var{DIM} is a scaler of type @code{INTEGER} in the
2378 range of @math{1 /leq DIM /leq n)} where @math{n} is the rank of @var{MASK}.
2380 @item @emph{Standard}:
2384 transformational function
2386 @item @emph{Syntax}:
2387 @code{RESULT = COUNT(MASK [, DIM])}
2389 @item @emph{Arguments}:
2390 @multitable @columnfractions .15 .70
2391 @item @var{MASK} @tab The type shall be @code{LOGICAL}.
2392 @item @var{DIM} @tab The type shall be @code{INTEGER}.
2395 @item @emph{Return value}:
2396 The return value is of type @code{INTEGER} with rank equal to that of
2399 @item @emph{Example}:
2402 integer, dimension(2,3) :: a, b
2403 logical, dimension(2,3) :: mask
2404 a = reshape( (/ 1, 2, 3, 4, 5, 6 /), (/ 2, 3 /))
2405 b = reshape( (/ 0, 7, 3, 4, 5, 8 /), (/ 2, 3 /))
2406 print '(3i3)', a(1,:)
2407 print '(3i3)', a(2,:)
2409 print '(3i3)', b(1,:)
2410 print '(3i3)', b(2,:)
2413 print '(3l3)', mask(1,:)
2414 print '(3l3)', mask(2,:)
2416 print '(3i3)', count(mask)
2418 print '(3i3)', count(mask, 1)
2420 print '(3i3)', count(mask, 2)
2421 end program test_count
2428 @section @code{CPU_TIME} --- CPU elapsed time in seconds
2430 @cindex time, elapsed
2433 @item @emph{Description}:
2434 Returns a @code{REAL(*)} value representing the elapsed CPU time in
2435 seconds. This is useful for testing segments of code to determine
2438 @item @emph{Standard}:
2444 @item @emph{Syntax}:
2445 @code{CALL CPU_TIME(TIME)}
2447 @item @emph{Arguments}:
2448 @multitable @columnfractions .15 .70
2449 @item @var{TIME} @tab The type shall be @code{REAL(*)} with @code{INTENT(OUT)}.
2452 @item @emph{Return value}:
2455 @item @emph{Example}:
2457 program test_cpu_time
2458 real :: start, finish
2459 call cpu_time(start)
2460 ! put code to test here
2461 call cpu_time(finish)
2462 print '("Time = ",f6.3," seconds.")',finish-start
2463 end program test_cpu_time
2466 @item @emph{See also}:
2467 @ref{SYSTEM_CLOCK}, @ref{DATE_AND_TIME}
2473 @section @code{CSHIFT} --- Circular shift elements of an array
2475 @cindex array, shift circularly
2476 @cindex array, permutation
2477 @cindex array, rotate
2480 @item @emph{Description}:
2481 @code{CSHIFT(ARRAY, SHIFT [, DIM])} performs a circular shift on elements of
2482 @var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is omitted it is
2483 taken to be @code{1}. @var{DIM} is a scaler of type @code{INTEGER} in the
2484 range of @math{1 /leq DIM /leq n)} where @math{n} is the rank of @var{ARRAY}.
2485 If the rank of @var{ARRAY} is one, then all elements of @var{ARRAY} are shifted
2486 by @var{SHIFT} places. If rank is greater than one, then all complete rank one
2487 sections of @var{ARRAY} along the given dimension are shifted. Elements
2488 shifted out one end of each rank one section are shifted back in the other end.
2490 @item @emph{Standard}:
2494 Transformational function
2496 @item @emph{Syntax}:
2497 @code{RESULT = CSHIFT(ARRAY, SHIFT [, DIM])}
2499 @item @emph{Arguments}:
2500 @multitable @columnfractions .15 .70
2501 @item @var{ARRAY} @tab Shall be an array of any type.
2502 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
2503 @item @var{DIM} @tab The type shall be @code{INTEGER}.
2506 @item @emph{Return value}:
2507 Returns an array of same type and rank as the @var{ARRAY} argument.
2509 @item @emph{Example}:
2512 integer, dimension(3,3) :: a
2513 a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
2514 print '(3i3)', a(1,:)
2515 print '(3i3)', a(2,:)
2516 print '(3i3)', a(3,:)
2517 a = cshift(a, SHIFT=(/1, 2, -1/), DIM=2)
2519 print '(3i3)', a(1,:)
2520 print '(3i3)', a(2,:)
2521 print '(3i3)', a(3,:)
2522 end program test_cshift
2529 @section @code{CTIME} --- Convert a time into a string
2531 @cindex time, conversion to string
2532 @cindex conversion, to string
2535 @item @emph{Description}:
2536 @code{CTIME} converts a system time value, such as returned by
2537 @code{TIME8()}, to a string of the form @samp{Sat Aug 19 18:13:14 1995}.
2539 This intrinsic is provided in both subroutine and function forms; however,
2540 only one form can be used in any given program unit.
2542 @item @emph{Standard}:
2548 @item @emph{Syntax}:
2549 @multitable @columnfractions .80
2550 @item @code{CALL CTIME(TIME, RESULT)}.
2551 @item @code{RESULT = CTIME(TIME)}, (not recommended).
2554 @item @emph{Arguments}:
2555 @multitable @columnfractions .15 .70
2556 @item @var{TIME} @tab The type shall be of type @code{INTEGER(KIND=8)}.
2557 @item @var{RESULT} @tab The type shall be of type @code{CHARACTER}.
2560 @item @emph{Return value}:
2561 The converted date and time as a string.
2563 @item @emph{Example}:
2567 character(len=30) :: date
2570 ! Do something, main part of the program
2573 print *, 'Program was started on ', date
2574 end program test_ctime
2577 @item @emph{See Also}:
2578 @ref{GMTIME}, @ref{LTIME}, @ref{TIME}, @ref{TIME8}
2584 @section @code{DATE_AND_TIME} --- Date and time subroutine
2585 @fnindex DATE_AND_TIME
2586 @cindex date, current
2587 @cindex current date
2588 @cindex time, current
2589 @cindex current time
2592 @item @emph{Description}:
2593 @code{DATE_AND_TIME(DATE, TIME, ZONE, VALUES)} gets the corresponding date and
2594 time information from the real-time system clock. @var{DATE} is
2595 @code{INTENT(OUT)} and has form ccyymmdd. @var{TIME} is @code{INTENT(OUT)} and
2596 has form hhmmss.sss. @var{ZONE} is @code{INTENT(OUT)} and has form (+-)hhmm,
2597 representing the difference with respect to Coordinated Universal Time (UTC).
2598 Unavailable time and date parameters return blanks.
2600 @var{VALUES} is @code{INTENT(OUT)} and provides the following:
2602 @multitable @columnfractions .15 .30 .40
2603 @item @tab @code{VALUE(1)}: @tab The year
2604 @item @tab @code{VALUE(2)}: @tab The month
2605 @item @tab @code{VALUE(3)}: @tab The day of the month
2606 @item @tab @code{VALUE(4)}: @tab Time difference with UTC in minutes
2607 @item @tab @code{VALUE(5)}: @tab The hour of the day
2608 @item @tab @code{VALUE(6)}: @tab The minutes of the hour
2609 @item @tab @code{VALUE(7)}: @tab The seconds of the minute
2610 @item @tab @code{VALUE(8)}: @tab The milliseconds of the second
2613 @item @emph{Standard}:
2619 @item @emph{Syntax}:
2620 @code{CALL DATE_AND_TIME([DATE, TIME, ZONE, VALUES])}
2622 @item @emph{Arguments}:
2623 @multitable @columnfractions .15 .70
2624 @item @var{DATE} @tab (Optional) The type shall be @code{CHARACTER(8)} or larger.
2625 @item @var{TIME} @tab (Optional) The type shall be @code{CHARACTER(10)} or larger.
2626 @item @var{ZONE} @tab (Optional) The type shall be @code{CHARACTER(5)} or larger.
2627 @item @var{VALUES}@tab (Optional) The type shall be @code{INTEGER(8)}.
2630 @item @emph{Return value}:
2633 @item @emph{Example}:
2635 program test_time_and_date
2636 character(8) :: date
2637 character(10) :: time
2638 character(5) :: zone
2639 integer,dimension(8) :: values
2640 ! using keyword arguments
2641 call date_and_time(date,time,zone,values)
2642 call date_and_time(DATE=date,ZONE=zone)
2643 call date_and_time(TIME=time)
2644 call date_and_time(VALUES=values)
2645 print '(a,2x,a,2x,a)', date, time, zone
2646 print '(8i5))', values
2647 end program test_time_and_date
2650 @item @emph{See also}:
2651 @ref{CPU_TIME}, @ref{SYSTEM_CLOCK}
2657 @section @code{DBLE} --- Double conversion function
2659 @cindex conversion, to real
2662 @item @emph{Description}:
2663 @code{DBLE(X)} Converts @var{X} to double precision real type.
2665 @item @emph{Standard}:
2671 @item @emph{Syntax}:
2672 @code{RESULT = DBLE(X)}
2674 @item @emph{Arguments}:
2675 @multitable @columnfractions .15 .70
2676 @item @var{X} @tab The type shall be @code{INTEGER(*)}, @code{REAL(*)},
2677 or @code{COMPLEX(*)}.
2680 @item @emph{Return value}:
2681 The return value is of type double precision real.
2683 @item @emph{Example}:
2688 complex :: z = (2.3,1.14)
2689 print *, dble(x), dble(i), dble(z)
2690 end program test_dble
2693 @item @emph{See also}:
2694 @ref{DFLOAT}, @ref{FLOAT}, @ref{REAL}
2700 @section @code{DCMPLX} --- Double complex conversion function
2702 @cindex complex numbers, conversion to
2703 @cindex conversion, to complex
2706 @item @emph{Description}:
2707 @code{DCMPLX(X [,Y])} returns a double complex number where @var{X} is
2708 converted to the real component. If @var{Y} is present it is converted to the
2709 imaginary component. If @var{Y} is not present then the imaginary component is
2710 set to 0.0. If @var{X} is complex then @var{Y} must not be present.
2712 @item @emph{Standard}:
2718 @item @emph{Syntax}:
2719 @code{RESULT = DCMPLX(X [, Y])}
2721 @item @emph{Arguments}:
2722 @multitable @columnfractions .15 .70
2723 @item @var{X} @tab The type may be @code{INTEGER(*)}, @code{REAL(*)},
2724 or @code{COMPLEX(*)}.
2725 @item @var{Y} @tab (Optional if @var{X} is not @code{COMPLEX(*)}.) May be
2726 @code{INTEGER(*)} or @code{REAL(*)}.
2729 @item @emph{Return value}:
2730 The return value is of type @code{COMPLEX(8)}
2732 @item @emph{Example}:
2742 print *, dcmplx(x,i)
2743 end program test_dcmplx
2750 @section @code{DFLOAT} --- Double conversion function
2752 @cindex conversion, to real
2755 @item @emph{Description}:
2756 @code{DFLOAT(X)} Converts @var{X} to double precision real type.
2758 @item @emph{Standard}:
2764 @item @emph{Syntax}:
2765 @code{RESULT = DFLOAT(X)}
2767 @item @emph{Arguments}:
2768 @multitable @columnfractions .15 .70
2769 @item @var{X} @tab The type shall be @code{INTEGER(*)}.
2772 @item @emph{Return value}:
2773 The return value is of type double precision real.
2775 @item @emph{Example}:
2780 end program test_dfloat
2783 @item @emph{See also}:
2784 @ref{DBLE}, @ref{FLOAT}, @ref{REAL}
2790 @section @code{DIGITS} --- Significant digits function
2792 @cindex model representation, significant digits
2795 @item @emph{Description}:
2796 @code{DIGITS(X)} returns the number of significant digits of the internal model
2797 representation of @var{X}. For example, on a system using a 32-bit
2798 floating point representation, a default real number would likely return 24.
2800 @item @emph{Standard}:
2806 @item @emph{Syntax}:
2807 @code{RESULT = DIGITS(X)}
2809 @item @emph{Arguments}:
2810 @multitable @columnfractions .15 .70
2811 @item @var{X} @tab The type may be @code{INTEGER(*)} or @code{REAL(*)}.
2814 @item @emph{Return value}:
2815 The return value is of type @code{INTEGER}.
2817 @item @emph{Example}:
2820 integer :: i = 12345
2826 end program test_digits
2833 @section @code{DIM} --- Positive difference
2837 @cindex positive difference
2840 @item @emph{Description}:
2841 @code{DIM(X,Y)} returns the difference @code{X-Y} if the result is positive;
2842 otherwise returns zero.
2844 @item @emph{Standard}:
2850 @item @emph{Syntax}:
2851 @code{RESULT = DIM(X, Y)}
2853 @item @emph{Arguments}:
2854 @multitable @columnfractions .15 .70
2855 @item @var{X} @tab The type shall be @code{INTEGER(*)} or @code{REAL(*)}
2856 @item @var{Y} @tab The type shall be the same type and kind as @var{X}.
2859 @item @emph{Return value}:
2860 The return value is of type @code{INTEGER(*)} or @code{REAL(*)}.
2862 @item @emph{Example}:
2868 x = dim(4.345_8, 2.111_8)
2871 end program test_dim
2874 @item @emph{Specific names}:
2875 @multitable @columnfractions .20 .20 .20 .25
2876 @item Name @tab Argument @tab Return type @tab Standard
2877 @item @code{IDIM(X,Y)} @tab @code{INTEGER(4) X,Y} @tab @code{INTEGER(4)} @tab F77 and later
2878 @item @code{DDIM(X,Y)} @tab @code{REAL(8) X,Y} @tab @code{REAL(8)} @tab F77 and later
2885 @section @code{DOT_PRODUCT} --- Dot product function
2886 @fnindex DOT_PRODUCT
2888 @cindex vector product
2889 @cindex product, vector
2892 @item @emph{Description}:
2893 @code{DOT_PRODUCT(X,Y)} computes the dot product multiplication of two vectors
2894 @var{X} and @var{Y}. The two vectors may be either numeric or logical
2895 and must be arrays of rank one and of equal size. If the vectors are
2896 @code{INTEGER(*)} or @code{REAL(*)}, the result is @code{SUM(X*Y)}. If the
2897 vectors are @code{COMPLEX(*)}, the result is @code{SUM(CONJG(X)*Y)}. If the
2898 vectors are @code{LOGICAL}, the result is @code{ANY(X.AND.Y)}.
2900 @item @emph{Standard}:
2904 transformational function
2906 @item @emph{Syntax}:
2907 @code{RESULT = DOT_PRODUCT(X, Y)}
2909 @item @emph{Arguments}:
2910 @multitable @columnfractions .15 .70
2911 @item @var{X} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
2912 @item @var{Y} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
2915 @item @emph{Return value}:
2916 If the arguments are numeric, the return value is a scaler of numeric type,
2917 @code{INTEGER(*)}, @code{REAL(*)}, or @code{COMPLEX(*)}. If the arguments are
2918 @code{LOGICAL}, the return value is @code{.TRUE.} or @code{.FALSE.}.
2920 @item @emph{Example}:
2922 program test_dot_prod
2923 integer, dimension(3) :: a, b
2930 print *, dot_product(a,b)
2931 end program test_dot_prod
2938 @section @code{DPROD} --- Double product function
2940 @cindex product, double-precision
2943 @item @emph{Description}:
2944 @code{DPROD(X,Y)} returns the product @code{X*Y}.
2946 @item @emph{Standard}:
2952 @item @emph{Syntax}:
2953 @code{RESULT = DPROD(X, Y)}
2955 @item @emph{Arguments}:
2956 @multitable @columnfractions .15 .70
2957 @item @var{X} @tab The type shall be @code{REAL}.
2958 @item @var{Y} @tab The type shall be @code{REAL}.
2961 @item @emph{Return value}:
2962 The return value is of type @code{REAL(8)}.
2964 @item @emph{Example}:
2972 end program test_dprod
2979 @section @code{DREAL} --- Double real part function
2981 @cindex complex numbers, real part
2984 @item @emph{Description}:
2985 @code{DREAL(Z)} returns the real part of complex variable @var{Z}.
2987 @item @emph{Standard}:
2993 @item @emph{Syntax}:
2994 @code{RESULT = DREAL(Z)}
2996 @item @emph{Arguments}:
2997 @multitable @columnfractions .15 .70
2998 @item @var{Z} @tab The type shall be @code{COMPLEX(8)}.
3001 @item @emph{Return value}:
3002 The return value is of type @code{REAL(8)}.
3004 @item @emph{Example}:
3007 complex(8) :: z = (1.3_8,7.2_8)
3009 end program test_dreal
3012 @item @emph{See also}:
3020 @section @code{DTIME} --- Execution time subroutine (or function)
3022 @cindex time, elapsed
3023 @cindex elapsed time
3026 @item @emph{Description}:
3027 @code{DTIME(TARRAY, RESULT)} initially returns the number of seconds of runtime
3028 since the start of the process's execution in @var{RESULT}. @var{TARRAY}
3029 returns the user and system components of this time in @code{TARRAY(1)} and
3030 @code{TARRAY(2)} respectively. @var{RESULT} is equal to @code{TARRAY(1) +
3033 Subsequent invocations of @code{DTIME} return values accumulated since the
3034 previous invocation.
3036 On some systems, the underlying timings are represented using types with
3037 sufficiently small limits that overflows (wrap around) are possible, such as
3038 32-bit types. Therefore, the values returned by this intrinsic might be, or
3039 become, negative, or numerically less than previous values, during a single
3040 run of the compiled program.
3042 If @code{DTIME} is invoked as a function, it can not be invoked as a
3043 subroutine, and vice versa.
3045 @var{TARRAY} and @var{RESULT} are @code{INTENT(OUT)} and provide the following:
3047 @multitable @columnfractions .15 .30 .40
3048 @item @tab @code{TARRAY(1)}: @tab User time in seconds.
3049 @item @tab @code{TARRAY(2)}: @tab System time in seconds.
3050 @item @tab @code{RESULT}: @tab Run time since start in seconds.
3053 @item @emph{Standard}:
3059 @item @emph{Syntax}:
3060 @multitable @columnfractions .80
3061 @item @code{CALL DTIME(TARRAY, RESULT)}.
3062 @item @code{RESULT = DTIME(TARRAY)}, (not recommended).
3065 @item @emph{Arguments}:
3066 @multitable @columnfractions .15 .70
3067 @item @var{TARRAY}@tab The type shall be @code{REAL, DIMENSION(2)}.
3068 @item @var{RESULT}@tab The type shall be @code{REAL}.
3071 @item @emph{Return value}:
3072 Elapsed time in seconds since the start of program execution.
3074 @item @emph{Example}:
3078 real, dimension(2) :: tarray
3080 call dtime(tarray, result)
3084 do i=1,100000000 ! Just a delay
3087 call dtime(tarray, result)
3091 end program test_dtime
3098 @section @code{EOSHIFT} --- End-off shift elements of an array
3100 @cindex array, shift
3103 @item @emph{Description}:
3104 @code{EOSHIFT(ARRAY, SHIFT[,BOUNDARY, DIM])} performs an end-off shift on
3105 elements of @var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is
3106 omitted it is taken to be @code{1}. @var{DIM} is a scaler of type
3107 @code{INTEGER} in the range of @math{1 /leq DIM /leq n)} where @math{n} is the
3108 rank of @var{ARRAY}. If the rank of @var{ARRAY} is one, then all elements of
3109 @var{ARRAY} are shifted by @var{SHIFT} places. If rank is greater than one,
3110 then all complete rank one sections of @var{ARRAY} along the given dimension are
3111 shifted. Elements shifted out one end of each rank one section are dropped. If
3112 @var{BOUNDARY} is present then the corresponding value of from @var{BOUNDARY}
3113 is copied back in the other end. If @var{BOUNDARY} is not present then the
3114 following are copied in depending on the type of @var{ARRAY}.
3116 @multitable @columnfractions .15 .80
3117 @item @emph{Array Type} @tab @emph{Boundary Value}
3118 @item Numeric @tab 0 of the type and kind of @var{ARRAY}.
3119 @item Logical @tab @code{.FALSE.}.
3120 @item Character(@var{len}) @tab @var{len} blanks.
3123 @item @emph{Standard}:
3127 Transformational function
3129 @item @emph{Syntax}:
3130 @code{RESULT = EOSHIFT(ARRAY, SHIFT [, BOUNDARY, DIM])}
3132 @item @emph{Arguments}:
3133 @multitable @columnfractions .15 .70
3134 @item @var{ARRAY} @tab May be any type, not scaler.
3135 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
3136 @item @var{BOUNDARY} @tab Same type as @var{ARRAY}.
3137 @item @var{DIM} @tab The type shall be @code{INTEGER}.
3140 @item @emph{Return value}:
3141 Returns an array of same type and rank as the @var{ARRAY} argument.
3143 @item @emph{Example}:
3145 program test_eoshift
3146 integer, dimension(3,3) :: a
3147 a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
3148 print '(3i3)', a(1,:)
3149 print '(3i3)', a(2,:)
3150 print '(3i3)', a(3,:)
3151 a = EOSHIFT(a, SHIFT=(/1, 2, 1/), BOUNDARY=-5, DIM=2)
3153 print '(3i3)', a(1,:)
3154 print '(3i3)', a(2,:)
3155 print '(3i3)', a(3,:)
3156 end program test_eoshift
3163 @section @code{EPSILON} --- Epsilon function
3165 @cindex model representation, epsilon
3168 @item @emph{Description}:
3169 @code{EPSILON(X)} returns a nearly negligible number relative to @code{1}.
3171 @item @emph{Standard}:
3177 @item @emph{Syntax}:
3178 @code{RESULT = EPSILON(X)}
3180 @item @emph{Arguments}:
3181 @multitable @columnfractions .15 .70
3182 @item @var{X} @tab The type shall be @code{REAL(*)}.
3185 @item @emph{Return value}:
3186 The return value is of same type as the argument.
3188 @item @emph{Example}:
3190 program test_epsilon
3195 end program test_epsilon
3202 @section @code{ERF} --- Error function
3204 @cindex error function
3207 @item @emph{Description}:
3208 @code{ERF(X)} computes the error function of @var{X}.
3210 @item @emph{Standard}:
3216 @item @emph{Syntax}:
3217 @code{RESULT = ERF(X)}
3219 @item @emph{Arguments}:
3220 @multitable @columnfractions .15 .70
3221 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
3224 @item @emph{Return value}:
3225 The return value is a scalar of type @code{REAL(*)} and it is positive
3226 (@math{ - 1 \leq erf (x) \leq 1 }.
3228 @item @emph{Example}:
3231 real(8) :: x = 0.17_8
3233 end program test_erf
3236 @item @emph{Specific names}:
3237 @multitable @columnfractions .20 .20 .20 .25
3238 @item Name @tab Argument @tab Return type @tab Standard
3239 @item @code{DERF(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
3246 @section @code{ERFC} --- Error function
3248 @cindex error function, complementary
3251 @item @emph{Description}:
3252 @code{ERFC(X)} computes the complementary error function of @var{X}.
3254 @item @emph{Standard}:
3260 @item @emph{Syntax}:
3261 @code{RESULT = ERFC(X)}
3263 @item @emph{Arguments}:
3264 @multitable @columnfractions .15 .70
3265 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
3268 @item @emph{Return value}:
3269 The return value is a scalar of type @code{REAL(*)} and it is positive
3270 (@math{ 0 \leq erfc (x) \leq 2 }.
3272 @item @emph{Example}:
3275 real(8) :: x = 0.17_8
3277 end program test_erfc
3280 @item @emph{Specific names}:
3281 @multitable @columnfractions .20 .20 .20 .25
3282 @item Name @tab Argument @tab Return type @tab Standard
3283 @item @code{DERFC(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
3290 @section @code{ETIME} --- Execution time subroutine (or function)
3292 @cindex time, elapsed
3295 @item @emph{Description}:
3296 @code{ETIME(TARRAY, RESULT)} returns the number of seconds of runtime
3297 since the start of the process's execution in @var{RESULT}. @var{TARRAY}
3298 returns the user and system components of this time in @code{TARRAY(1)} and
3299 @code{TARRAY(2)} respectively. @var{RESULT} is equal to @code{TARRAY(1) + TARRAY(2)}.
3301 On some systems, the underlying timings are represented using types with
3302 sufficiently small limits that overflows (wrap around) are possible, such as
3303 32-bit types. Therefore, the values returned by this intrinsic might be, or
3304 become, negative, or numerically less than previous values, during a single
3305 run of the compiled program.
3307 If @code{ETIME} is invoked as a function, it can not be invoked as a
3308 subroutine, and vice versa.
3310 @var{TARRAY} and @var{RESULT} are @code{INTENT(OUT)} and provide the following:
3312 @multitable @columnfractions .15 .30 .60
3313 @item @tab @code{TARRAY(1)}: @tab User time in seconds.
3314 @item @tab @code{TARRAY(2)}: @tab System time in seconds.
3315 @item @tab @code{RESULT}: @tab Run time since start in seconds.
3318 @item @emph{Standard}:
3324 @item @emph{Syntax}:
3325 @multitable @columnfractions .80
3326 @item @code{CALL ETIME(TARRAY, RESULT)}.
3327 @item @code{RESULT = ETIME(TARRAY)}, (not recommended).
3330 @item @emph{Arguments}:
3331 @multitable @columnfractions .15 .70
3332 @item @var{TARRAY}@tab The type shall be @code{REAL, DIMENSION(2)}.
3333 @item @var{RESULT}@tab The type shall be @code{REAL}.
3336 @item @emph{Return value}:
3337 Elapsed time in seconds since the start of program execution.
3339 @item @emph{Example}:
3343 real, dimension(2) :: tarray
3345 call ETIME(tarray, result)
3349 do i=1,100000000 ! Just a delay
3352 call ETIME(tarray, result)
3356 end program test_etime
3359 @item @emph{See also}:
3367 @section @code{EXIT} --- Exit the program with status.
3369 @cindex program termination
3370 @cindex terminate program
3373 @item @emph{Description}:
3374 @code{EXIT} causes immediate termination of the program with status. If status
3375 is omitted it returns the canonical @emph{success} for the system. All Fortran
3376 I/O units are closed.
3378 @item @emph{Standard}:
3384 @item @emph{Syntax}:
3385 @code{CALL EXIT([STATUS])}
3387 @item @emph{Arguments}:
3388 @multitable @columnfractions .15 .70
3389 @item @var{STATUS} @tab Shall be an @code{INTEGER} of the default kind.
3392 @item @emph{Return value}:
3393 @code{STATUS} is passed to the parent process on exit.
3395 @item @emph{Example}:
3398 integer :: STATUS = 0
3399 print *, 'This program is going to exit.'
3401 end program test_exit
3404 @item @emph{See also}:
3405 @ref{ABORT}, @ref{KILL}
3411 @section @code{EXP} --- Exponential function
3417 @cindex exponential function
3418 @cindex logarithmic function, inverse
3421 @item @emph{Description}:
3422 @code{EXP(X)} computes the base @math{e} exponential of @var{X}.
3424 @item @emph{Standard}:
3425 F77 and later, has overloads that are GNU extensions
3430 @item @emph{Syntax}:
3431 @code{RESULT = EXP(X)}
3433 @item @emph{Arguments}:
3434 @multitable @columnfractions .15 .70
3435 @item @var{X} @tab The type shall be @code{REAL(*)} or
3439 @item @emph{Return value}:
3440 The return value has same type and kind as @var{X}.
3442 @item @emph{Example}:
3447 end program test_exp
3450 @item @emph{Specific names}:
3451 @multitable @columnfractions .20 .20 .20 .25
3452 @item Name @tab Argument @tab Return type @tab Standard
3453 @item @code{DEXP(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
3454 @item @code{CEXP(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab F77 and later
3455 @item @code{ZEXP(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
3456 @item @code{CDEXP(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
3463 @section @code{EXPONENT} --- Exponent function
3465 @cindex real number, exponent
3466 @cindex floating point, exponent
3469 @item @emph{Description}:
3470 @code{EXPONENT(X)} returns the value of the exponent part of @var{X}. If @var{X}
3471 is zero the value returned is zero.
3473 @item @emph{Standard}:
3479 @item @emph{Syntax}:
3480 @code{RESULT = EXPONENT(X)}
3482 @item @emph{Arguments}:
3483 @multitable @columnfractions .15 .70
3484 @item @var{X} @tab The type shall be @code{REAL(*)}.
3487 @item @emph{Return value}:
3488 The return value is of type default @code{INTEGER}.
3490 @item @emph{Example}:
3492 program test_exponent
3497 print *, exponent(0.0)
3498 end program test_exponent
3505 @section @code{FDATE} --- Get the current time as a string
3507 @cindex time, current
3508 @cindex current time
3509 @cindex date, current
3510 @cindex current date
3513 @item @emph{Description}:
3514 @code{FDATE(DATE)} returns the current date (using the same format as
3515 @code{CTIME}) in @var{DATE}. It is equivalent to @code{CALL CTIME(DATE,
3518 If @code{FDATE} is invoked as a function, it can not be invoked as a
3519 subroutine, and vice versa.
3521 @var{DATE} is an @code{INTENT(OUT)} @code{CHARACTER} variable.
3523 @item @emph{Standard}:
3529 @item @emph{Syntax}:
3530 @multitable @columnfractions .80
3531 @item @code{CALL FDATE(DATE)}.
3532 @item @code{DATE = FDATE()}, (not recommended).
3535 @item @emph{Arguments}:
3536 @multitable @columnfractions .15 .70
3537 @item @var{DATE}@tab The type shall be of type @code{CHARACTER}.
3540 @item @emph{Return value}:
3541 The current date as a string.
3543 @item @emph{Example}:
3547 character(len=30) :: date
3549 print *, 'Program started on ', date
3550 do i = 1, 100000000 ! Just a delay
3554 print *, 'Program ended on ', date
3555 end program test_fdate
3562 @section @code{FLOAT} --- Convert integer to default real
3564 @cindex conversion, to real
3567 @item @emph{Description}:
3568 @code{FLOAT(I)} converts the integer @var{I} to a default real value.
3570 @item @emph{Standard}:
3576 @item @emph{Syntax}:
3577 @code{RESULT = FLOAT(I)}
3579 @item @emph{Arguments}:
3580 @multitable @columnfractions .15 .70
3581 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
3584 @item @emph{Return value}:
3585 The return value is of type default @code{REAL}.
3587 @item @emph{Example}:
3591 if (float(i) /= 1.) call abort
3592 end program test_float
3595 @item @emph{See also}:
3596 @ref{DBLE}, @ref{DFLOAT}, @ref{REAL}
3602 @section @code{FGET} --- Read a single character in stream mode from stdin
3604 @cindex read character, stream mode
3605 @cindex stream mode, read character
3606 @cindex file operation, read character
3609 @item @emph{Description}:
3610 Read a single character in stream mode from stdin by bypassing normal
3611 formatted output. Stream I/O should not be mixed with normal record-oriented
3612 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
3614 This intrinsic routine is provided for backwards compatibility with
3615 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
3616 Programmers should consider the use of new stream IO feature in new code
3617 for future portability. See also @ref{Fortran 2003 status}.
3619 @item @emph{Standard}:
3623 Non-elemental subroutine
3625 @item @emph{Syntax}:
3626 @code{CALL FGET(C [, STATUS])}
3628 @item @emph{Arguments}:
3629 @multitable @columnfractions .15 .70
3630 @item @var{C} @tab The type shall be @code{CHARACTER}.
3631 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
3632 Returns 0 on success, -1 on end-of-file, and a
3633 system specific positive error code otherwise.
3636 @item @emph{Example}:
3639 INTEGER, PARAMETER :: strlen = 100
3640 INTEGER :: status, i = 1
3641 CHARACTER(len=strlen) :: str = ""
3643 WRITE (*,*) 'Enter text:'
3645 CALL fget(str(i:i), status)
3646 if (status /= 0 .OR. i > strlen) exit
3649 WRITE (*,*) TRIM(str)
3653 @item @emph{See also}:
3654 @ref{FGETC}, @ref{FPUT}, @ref{FPUTC}
3660 @section @code{FGETC} --- Read a single character in stream mode
3662 @cindex read character, stream mode
3663 @cindex stream mode, read character
3664 @cindex file operation, read character
3667 @item @emph{Description}:
3668 Read a single character in stream mode by bypassing normal formatted output.
3669 Stream I/O should not be mixed with normal record-oriented (formatted or
3670 unformatted) I/O on the same unit; the results are unpredictable.
3672 This intrinsic routine is provided for backwards compatibility with
3673 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
3674 Programmers should consider the use of new stream IO feature in new code
3675 for future portability. See also @ref{Fortran 2003 status}.
3677 @item @emph{Standard}:
3681 Non-elemental subroutine
3683 @item @emph{Syntax}:
3684 @code{CALL FGETC(UNIT, C [, STATUS])}
3686 @item @emph{Arguments}:
3687 @multitable @columnfractions .15 .70
3688 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
3689 @item @var{C} @tab The type shall be @code{CHARACTER}.
3690 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. Returns 0 on success,
3691 -1 on end-of-file and a system specific positive error code otherwise.
3694 @item @emph{Example}:
3697 INTEGER :: fd = 42, status
3700 OPEN(UNIT=fd, FILE="/etc/passwd", ACTION="READ", STATUS = "OLD")
3702 CALL fgetc(fd, c, status)
3703 IF (status /= 0) EXIT
3710 @item @emph{See also}:
3711 @ref{FGET}, @ref{FPUT}, @ref{FPUTC}
3717 @section @code{FLOOR} --- Integer floor function
3720 @cindex rounding, floor
3723 @item @emph{Description}:
3724 @code{FLOOR(X)} returns the greatest integer less than or equal to @var{X}.
3726 @item @emph{Standard}:
3732 @item @emph{Syntax}:
3733 @code{RESULT = FLOOR(X [, KIND])}
3735 @item @emph{Arguments}:
3736 @multitable @columnfractions .15 .70
3737 @item @var{X} @tab The type shall be @code{REAL(*)}.
3738 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
3739 expression indicating the kind parameter of
3743 @item @emph{Return value}:
3744 The return value is of type @code{INTEGER(KIND)}
3746 @item @emph{Example}:
3751 print *, floor(x) ! returns 63
3752 print *, floor(y) ! returns -64
3753 end program test_floor
3756 @item @emph{See also}:
3757 @ref{CEILING}, @ref{NINT}
3764 @section @code{FLUSH} --- Flush I/O unit(s)
3766 @cindex file operation, flush
3769 @item @emph{Description}:
3770 Flushes Fortran unit(s) currently open for output. Without the optional
3771 argument, all units are flushed, otherwise just the unit specified.
3773 @item @emph{Standard}:
3777 Non-elemental subroutine
3779 @item @emph{Syntax}:
3780 @code{CALL FLUSH(UNIT)}
3782 @item @emph{Arguments}:
3783 @multitable @columnfractions .15 .70
3784 @item @var{UNIT} @tab (Optional) The type shall be @code{INTEGER}.
3788 Beginning with the Fortran 2003 standard, there is a @code{FLUSH}
3789 statement that should be preferred over the @code{FLUSH} intrinsic.
3796 @section @code{FNUM} --- File number function
3798 @cindex file operation, file number
3801 @item @emph{Description}:
3802 @code{FNUM(UNIT)} returns the POSIX file descriptor number corresponding to the
3803 open Fortran I/O unit @code{UNIT}.
3805 @item @emph{Standard}:
3809 Non-elemental function
3811 @item @emph{Syntax}:
3812 @code{RESULT = FNUM(UNIT)}
3814 @item @emph{Arguments}:
3815 @multitable @columnfractions .15 .70
3816 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
3819 @item @emph{Return value}:
3820 The return value is of type @code{INTEGER}
3822 @item @emph{Example}:
3826 open (unit=10, status = "scratch")
3830 end program test_fnum
3837 @section @code{FPUT} --- Write a single character in stream mode to stdout
3839 @cindex write character, stream mode
3840 @cindex stream mode, write character
3841 @cindex file operation, write character
3844 @item @emph{Description}:
3845 Write a single character in stream mode to stdout by bypassing normal
3846 formatted output. Stream I/O should not be mixed with normal record-oriented
3847 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
3849 This intrinsic routine is provided for backwards compatibility with
3850 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
3851 Programmers should consider the use of new stream IO feature in new code
3852 for future portability. See also @ref{Fortran 2003 status}.
3854 @item @emph{Standard}:
3858 Non-elemental subroutine
3860 @item @emph{Syntax}:
3861 @code{CALL FPUT(C [, STATUS])}
3863 @item @emph{Arguments}:
3864 @multitable @columnfractions .15 .70
3865 @item @var{C} @tab The type shall be @code{CHARACTER}.
3866 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. Returns 0 on success,
3867 -1 on end-of-file and a system specific positive error code otherwise.
3870 @item @emph{Example}:
3873 CHARACTER(len=10) :: str = "gfortran"
3875 DO i = 1, len_trim(str)
3881 @item @emph{See also}:
3882 @ref{FPUTC}, @ref{FGET}, @ref{FGETC}
3888 @section @code{FPUTC} --- Write a single character in stream mode
3890 @cindex write character, stream mode
3891 @cindex stream mode, write character
3892 @cindex file operation, write character
3895 @item @emph{Description}:
3896 Write a single character in stream mode by bypassing normal formatted
3897 output. Stream I/O should not be mixed with normal record-oriented
3898 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
3900 This intrinsic routine is provided for backwards compatibility with
3901 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
3902 Programmers should consider the use of new stream IO feature in new code
3903 for future portability. See also @ref{Fortran 2003 status}.
3905 @item @emph{Standard}:
3909 Non-elemental subroutine
3911 @item @emph{Syntax}:
3912 @code{CALL FPUTC(UNIT, C [, STATUS])}
3914 @item @emph{Arguments}:
3915 @multitable @columnfractions .15 .70
3916 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
3917 @item @var{C} @tab The type shall be @code{CHARACTER}.
3918 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. Returns 0 on success,
3919 -1 on end-of-file and a system specific positive error code otherwise.
3922 @item @emph{Example}:
3925 CHARACTER(len=10) :: str = "gfortran"
3926 INTEGER :: fd = 42, i
3928 OPEN(UNIT = fd, FILE = "out", ACTION = "WRITE", STATUS="NEW")
3929 DO i = 1, len_trim(str)
3930 CALL fputc(fd, str(i:i))
3936 @item @emph{See also}:
3937 @ref{FPUT}, @ref{FGET}, @ref{FGETC}
3943 @section @code{FRACTION} --- Fractional part of the model representation
3945 @cindex real number, fraction
3946 @cindex floating point, fraction
3949 @item @emph{Description}:
3950 @code{FRACTION(X)} returns the fractional part of the model
3951 representation of @code{X}.
3953 @item @emph{Standard}:
3959 @item @emph{Syntax}:
3960 @code{Y = FRACTION(X)}
3962 @item @emph{Arguments}:
3963 @multitable @columnfractions .15 .70
3964 @item @var{X} @tab The type of the argument shall be a @code{REAL}.
3967 @item @emph{Return value}:
3968 The return value is of the same type and kind as the argument.
3969 The fractional part of the model representation of @code{X} is returned;
3970 it is @code{X * RADIX(X)**(-EXPONENT(X))}.
3972 @item @emph{Example}:
3974 program test_fraction
3977 print *, fraction(x), x * radix(x)**(-exponent(x))
3978 end program test_fraction
3986 @section @code{FREE} --- Frees memory
3988 @cindex pointer, cray
3991 @item @emph{Description}:
3992 Frees memory previously allocated by @code{MALLOC()}. The @code{FREE}
3993 intrinsic is an extension intended to be used with Cray pointers, and is
3994 provided in GNU Fortran to allow user to compile legacy code. For
3995 new code using Fortran 95 pointers, the memory de-allocation intrinsic is
3998 @item @emph{Standard}:
4004 @item @emph{Syntax}:
4005 @code{CALL FREE(PTR)}
4007 @item @emph{Arguments}:
4008 @multitable @columnfractions .15 .70
4009 @item @var{PTR} @tab The type shall be @code{INTEGER}. It represents the
4010 location of the memory that should be de-allocated.
4013 @item @emph{Return value}:
4016 @item @emph{Example}:
4017 See @code{MALLOC} for an example.
4019 @item @emph{See also}:
4026 @section @code{FSEEK} --- Low level file positioning subroutine
4028 @cindex file operation, seek
4029 @cindex file operation, position
4032 @item @emph{Description}:
4033 Moves @var{UNIT} to the specified @var{OFFSET}. If @var{WHENCE}
4034 is set to 0, the @var{OFFSET} is taken as an absolute value @code{SEEK_SET},
4035 if set to 1, @var{OFFSET} is taken to be relative to the current position
4036 @code{SEEK_CUR}, and if set to 2 relative to the end of the file @code{SEEK_END}.
4037 On error, @var{STATUS} is set to a non-zero value. If @var{STATUS} the seek
4040 This intrinsic routine is not fully backwards compatible with @command{g77}.
4041 In @command{g77}, the @code{FSEEK} takes a statement label instead of a
4042 @var{STATUS} variable. If FSEEK is used in old code, change
4044 CALL FSEEK(UNIT, OFFSET, WHENCE, *label)
4049 CALL FSEEK(UNIT, OFFSET, WHENCE, status)
4050 IF (status /= 0) GOTO label
4053 Please note that GNU Fortran provides the Fortran 2003 Stream facility.
4054 Programmers should consider the use of new stream IO feature in new code
4055 for future portability. See also @ref{Fortran 2003 status}.
4057 @item @emph{Standard}:
4063 @item @emph{Syntax}:
4064 @code{CALL FSEEK(UNIT, OFFSET, WHENCE[, STATUS])}
4066 @item @emph{Arguments}:
4067 @multitable @columnfractions .15 .70
4068 @item @var{UNIT} @tab Shall be a scalar of type @code{INTEGER}.
4069 @item @var{OFFSET} @tab Shall be a scalar of type @code{INTEGER}.
4070 @item @var{WHENCE} @tab Shall be a scalar of type @code{INTEGER}.
4071 Its value shall be either 0, 1 or 2.
4072 @item @var{STATUS} @tab (Optional) shall be a scalar of type
4076 @item @emph{Example}:
4079 INTEGER, PARAMETER :: SEEK_SET = 0, SEEK_CUR = 1, SEEK_END = 2
4080 INTEGER :: fd, offset, ierr
4086 OPEN(UNIT=fd, FILE="fseek.test")
4087 CALL FSEEK(fd, offset, SEEK_SET, ierr) ! move to OFFSET
4088 print *, FTELL(fd), ierr
4090 CALL FSEEK(fd, 0, SEEK_END, ierr) ! move to end
4091 print *, FTELL(fd), ierr
4093 CALL FSEEK(fd, 0, SEEK_SET, ierr) ! move to beginning
4094 print *, FTELL(fd), ierr
4100 @item @emph{See also}:
4107 @section @code{FSTAT} --- Get file status
4109 @cindex file system, file status
4112 @item @emph{Description}:
4113 @code{FSTAT} is identical to @ref{STAT}, except that information about an
4114 already opened file is obtained.
4116 The elements in @code{BUFF} are the same as described by @ref{STAT}.
4118 @item @emph{Standard}:
4122 Non-elemental subroutine
4124 @item @emph{Syntax}:
4125 @code{CALL FSTAT(UNIT, BUFF [, STATUS])}
4127 @item @emph{Arguments}:
4128 @multitable @columnfractions .15 .70
4129 @item @var{UNIT} @tab An open I/O unit number of type @code{INTEGER}.
4130 @item @var{BUFF} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
4131 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0
4132 on success and a system specific error code otherwise.
4135 @item @emph{Example}:
4136 See @ref{STAT} for an example.
4138 @item @emph{See also}:
4139 To stat a link: @ref{LSTAT}, to stat a file: @ref{STAT}
4145 @section @code{FTELL} --- Current stream position
4147 @cindex file operation, position
4150 @item @emph{Description}:
4151 Retrieves the current position within an open file.
4153 This intrinsic is provided in both subroutine and function forms; however,
4154 only one form can be used in any given program unit.
4156 @item @emph{Standard}:
4160 Subroutine, function
4162 @item @emph{Syntax}:
4163 @multitable @columnfractions .80
4164 @item @code{CALL FTELL(UNIT, OFFSET)}
4165 @item @code{OFFSET = FTELL(UNIT)}
4168 @item @emph{Arguments}:
4169 @multitable @columnfractions .15 .70
4170 @item @var{OFFSET} @tab Shall of type @code{INTEGER}.
4171 @item @var{UNIT} @tab Shall of type @code{INTEGER}.
4174 @item @emph{Return value}:
4175 In either syntax, @var{OFFSET} is set to the current offset of unit
4176 number @var{UNIT}, or to @math{-1} if the unit is not currently open.
4178 @item @emph{Example}:
4182 OPEN(10, FILE="temp.dat")
4188 @item @emph{See also}:
4195 @section @code{GERROR} --- Get last system error message
4197 @cindex system, error handling
4200 @item @emph{Description}:
4201 Returns the system error message corresponding to the last system error.
4202 This resembles the functionality of @code{strerror(3)} in C.
4204 @item @emph{Standard}:
4210 @item @emph{Syntax}:
4211 @code{CALL GERROR(RESULT)}
4213 @item @emph{Arguments}:
4214 @multitable @columnfractions .15 .70
4215 @item @var{RESULT} @tab Shall of type @code{CHARACTER(*)}.
4218 @item @emph{Example}:
4221 CHARACTER(len=100) :: msg
4227 @item @emph{See also}:
4228 @ref{IERRNO}, @ref{PERROR}
4234 @section @code{GETARG} --- Get command line arguments
4236 @cindex command-line arguments
4237 @cindex arguments, to program
4240 @item @emph{Description}:
4241 Retrieve the @var{N}th argument that was passed on the
4242 command line when the containing program was invoked.
4244 This intrinsic routine is provided for backwards compatibility with
4245 GNU Fortran 77. In new code, programmers should consider the use of
4246 the @ref{GET_COMMAND_ARGUMENT} intrinsic defined by the Fortran 2003
4249 @item @emph{Standard}:
4255 @item @emph{Syntax}:
4256 @code{CALL GETARG(N, ARG)}
4258 @item @emph{Arguments}:
4259 @multitable @columnfractions .15 .70
4260 @item @var{N} @tab Shall be of type @code{INTEGER(4)}, @math{@var{N} \geq 0}
4261 @item @var{ARG} @tab Shall be of type @code{CHARACTER(*)}.
4264 @item @emph{Return value}:
4265 After @code{GETARG} returns, the @var{ARG} argument holds the @var{N}th
4266 command line argument. If @var{ARG} can not hold the argument, it is
4267 truncated to fit the length of @var{ARG}. If there are less than @var{N}
4268 arguments specified at the command line, @var{ARG} will be filled with blanks.
4269 If @math{@var{N} = 0}, @var{ARG} is set to the name of the program (on systems
4270 that support this feature).
4272 @item @emph{Example}:
4276 CHARACTER(len=32) :: arg
4285 @item @emph{See also}:
4286 GNU Fortran 77 compatibility function: @ref{IARGC}
4288 F2003 functions and subroutines: @ref{GET_COMMAND}, @ref{GET_COMMAND_ARGUMENT},
4289 @ref{COMMAND_ARGUMENT_COUNT}
4295 @section @code{GET_COMMAND} --- Get the entire command line
4296 @fnindex GET_COMMAND
4297 @cindex command-line arguments
4298 @cindex arguments, to program
4301 @item @emph{Description}:
4302 Retrieve the entire command line that was used to invoke the program.
4304 @item @emph{Standard}:
4310 @item @emph{Syntax}:
4311 @code{CALL GET_COMMAND(CMD)}
4313 @item @emph{Arguments}:
4314 @multitable @columnfractions .15 .70
4315 @item @var{CMD} @tab Shall be of type @code{CHARACTER(*)}.
4318 @item @emph{Return value}:
4319 Stores the entire command line that was used to invoke the program in @var{ARG}.
4320 If @var{ARG} is not large enough, the command will be truncated.
4322 @item @emph{Example}:
4324 PROGRAM test_get_command
4325 CHARACTER(len=255) :: cmd
4326 CALL get_command(cmd)
4327 WRITE (*,*) TRIM(cmd)
4331 @item @emph{See also}:
4332 @ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
4337 @node GET_COMMAND_ARGUMENT
4338 @section @code{GET_COMMAND_ARGUMENT} --- Get command line arguments
4339 @fnindex GET_COMMAND_ARGUMENT
4340 @cindex command-line arguments
4341 @cindex arguments, to program
4344 @item @emph{Description}:
4345 Retrieve the @var{N}th argument that was passed on the
4346 command line when the containing program was invoked.
4348 @item @emph{Standard}:
4354 @item @emph{Syntax}:
4355 @code{CALL GET_COMMAND_ARGUMENT(N, ARG)}
4357 @item @emph{Arguments}:
4358 @multitable @columnfractions .15 .70
4359 @item @var{N} @tab Shall be of type @code{INTEGER(4)}, @math{@var{N} \geq 0}
4360 @item @var{ARG} @tab Shall be of type @code{CHARACTER(*)}.
4363 @item @emph{Return value}:
4364 After @code{GET_COMMAND_ARGUMENT} returns, the @var{ARG} argument holds the
4365 @var{N}th command line argument. If @var{ARG} can not hold the argument, it is
4366 truncated to fit the length of @var{ARG}. If there are less than @var{N}
4367 arguments specified at the command line, @var{ARG} will be filled with blanks.
4368 If @math{@var{N} = 0}, @var{ARG} is set to the name of the program (on systems
4369 that support this feature).
4371 @item @emph{Example}:
4373 PROGRAM test_get_command_argument
4375 CHARACTER(len=32) :: arg
4379 CALL get_command_argument(i, arg)
4380 IF (LEN_TRIM(arg) == 0) EXIT
4382 WRITE (*,*) TRIM(arg)
4388 @item @emph{See also}:
4389 @ref{GET_COMMAND}, @ref{COMMAND_ARGUMENT_COUNT}
4395 @section @code{GETCWD} --- Get current working directory
4397 @cindex system, working directory
4400 @item @emph{Description}:
4401 Get current working directory.
4403 @item @emph{Standard}:
4407 Non-elemental subroutine.
4409 @item @emph{Syntax}:
4410 @code{CALL GETCWD(CWD [, STATUS])}
4412 @item @emph{Arguments}:
4413 @multitable @columnfractions .15 .70
4414 @item @var{CWD} @tab The type shall be @code{CHARACTER(*)}.
4415 @item @var{STATUS} @tab (Optional) status flag. Returns 0 on success,
4416 a system specific and non-zero error code otherwise.
4419 @item @emph{Example}:
4422 CHARACTER(len=255) :: cwd
4424 WRITE(*,*) TRIM(cwd)
4428 @item @emph{See also}:
4435 @section @code{GETENV} --- Get an environmental variable
4437 @cindex environment variable
4440 @item @emph{Description}:
4441 Get the @var{VALUE} of the environmental variable @var{ENVVAR}.
4443 This intrinsic routine is provided for backwards compatibility with
4444 GNU Fortran 77. In new code, programmers should consider the use of
4445 the @ref{GET_ENVIRONMENT_VARIABLE} intrinsic defined by the Fortran
4448 @item @emph{Standard}:
4454 @item @emph{Syntax}:
4455 @code{CALL GETENV(ENVVAR, VALUE)}
4457 @item @emph{Arguments}:
4458 @multitable @columnfractions .15 .70
4459 @item @var{ENVVAR} @tab Shall be of type @code{CHARACTER(*)}.
4460 @item @var{VALUE} @tab Shall be of type @code{CHARACTER(*)}.
4463 @item @emph{Return value}:
4464 Stores the value of @var{ENVVAR} in @var{VALUE}. If @var{VALUE} is
4465 not large enough to hold the data, it is truncated. If @var{ENVVAR}
4466 is not set, @var{VALUE} will be filled with blanks.
4468 @item @emph{Example}:
4471 CHARACTER(len=255) :: homedir
4472 CALL getenv("HOME", homedir)
4473 WRITE (*,*) TRIM(homedir)
4477 @item @emph{See also}:
4478 @ref{GET_ENVIRONMENT_VARIABLE}
4483 @node GET_ENVIRONMENT_VARIABLE
4484 @section @code{GET_ENVIRONMENT_VARIABLE} --- Get an environmental variable
4485 @fnindex GET_ENVIRONMENT_VARIABLE
4486 @cindex environment variable
4489 @item @emph{Description}:
4490 Get the @var{VALUE} of the environmental variable @var{ENVVAR}.
4492 @item @emph{Standard}:
4498 @item @emph{Syntax}:
4499 @code{CALL GET_ENVIRONMENT_VARIABLE(ENVVAR, VALUE)}
4501 @item @emph{Arguments}:
4502 @multitable @columnfractions .15 .70
4503 @item @var{ENVVAR} @tab Shall be of type @code{CHARACTER(*)}.
4504 @item @var{VALUE} @tab Shall be of type @code{CHARACTER(*)}.
4507 @item @emph{Return value}:
4508 Stores the value of @var{ENVVAR} in @var{VALUE}. If @var{VALUE} is
4509 not large enough to hold the data, it is truncated. If @var{ENVVAR}
4510 is not set, @var{VALUE} will be filled with blanks.
4512 @item @emph{Example}:
4515 CHARACTER(len=255) :: homedir
4516 CALL get_environment_variable("HOME", homedir)
4517 WRITE (*,*) TRIM(homedir)
4525 @section @code{GETGID} --- Group ID function
4527 @cindex system, group id
4530 @item @emph{Description}:
4531 Returns the numerical group ID of the current process.
4533 @item @emph{Standard}:
4539 @item @emph{Syntax}:
4540 @code{RESULT = GETGID()}
4542 @item @emph{Return value}:
4543 The return value of @code{GETGID} is an @code{INTEGER} of the default
4547 @item @emph{Example}:
4548 See @code{GETPID} for an example.
4550 @item @emph{See also}:
4551 @ref{GETPID}, @ref{GETUID}
4557 @section @code{GETLOG} --- Get login name
4559 @cindex system, login name
4563 @item @emph{Description}:
4564 Gets the username under which the program is running.
4566 @item @emph{Standard}:
4572 @item @emph{Syntax}:
4573 @code{CALL GETLOG(LOGIN)}
4575 @item @emph{Arguments}:
4576 @multitable @columnfractions .15 .70
4577 @item @var{LOGIN} @tab Shall be of type @code{CHARACTER(*)}.
4580 @item @emph{Return value}:
4581 Stores the current user name in @var{LOGIN}. (On systems where POSIX
4582 functions @code{geteuid} and @code{getpwuid} are not available, and
4583 the @code{getlogin} function is not implemented either, this will
4584 return a blank string.)
4586 @item @emph{Example}:
4589 CHARACTER(32) :: login
4595 @item @emph{See also}:
4602 @section @code{GETPID} --- Process ID function
4604 @cindex system, process id
4608 @item @emph{Description}:
4609 Returns the numerical process identifier of the current process.
4611 @item @emph{Standard}:
4617 @item @emph{Syntax}:
4618 @code{RESULT = GETPID()}
4620 @item @emph{Return value}:
4621 The return value of @code{GETPID} is an @code{INTEGER} of the default
4625 @item @emph{Example}:
4628 print *, "The current process ID is ", getpid()
4629 print *, "Your numerical user ID is ", getuid()
4630 print *, "Your numerical group ID is ", getgid()
4634 @item @emph{See also}:
4635 @ref{GETGID}, @ref{GETUID}
4641 @section @code{GETUID} --- User ID function
4643 @cindex system, user id
4647 @item @emph{Description}:
4648 Returns the numerical user ID of the current process.
4650 @item @emph{Standard}:
4656 @item @emph{Syntax}:
4657 @code{RESULT = GETUID()}
4659 @item @emph{Return value}:
4660 The return value of @code{GETUID} is an @code{INTEGER} of the default
4664 @item @emph{Example}:
4665 See @code{GETPID} for an example.
4667 @item @emph{See also}:
4668 @ref{GETPID}, @ref{GETLOG}
4674 @section @code{GMTIME} --- Convert time to GMT info
4676 @cindex time, conversion to GMT info
4679 @item @emph{Description}:
4680 Given a system time value @var{STIME} (as provided by the @code{TIME8()}
4681 intrinsic), fills @var{TARRAY} with values extracted from it appropriate
4682 to the UTC time zone (Universal Coordinated Time, also known in some
4683 countries as GMT, Greenwich Mean Time), using @code{gmtime(3)}.
4685 @item @emph{Standard}:
4691 @item @emph{Syntax}:
4692 @code{CALL GMTIME(STIME, TARRAY)}
4694 @item @emph{Arguments}:
4695 @multitable @columnfractions .15 .70
4696 @item @var{STIME} @tab An @code{INTEGER(*)} scalar expression
4697 corresponding to a system time, with
4699 @item @var{TARRAY} @tab A default @code{INTEGER} array with 9 elements,
4700 with @code{INTENT(OUT)}.
4703 @item @emph{Return value}:
4704 The elements of @var{TARRAY} are assigned as follows:
4706 @item Seconds after the minute, range 0--59 or 0--61 to allow for leap
4708 @item Minutes after the hour, range 0--59
4709 @item Hours past midnight, range 0--23
4710 @item Day of month, range 0--31
4711 @item Number of months since January, range 0--12
4712 @item Years since 1900
4713 @item Number of days since Sunday, range 0--6
4714 @item Days since January 1
4715 @item Daylight savings indicator: positive if daylight savings is in
4716 effect, zero if not, and negative if the information is not
4720 @item @emph{See also}:
4721 @ref{CTIME}, @ref{LTIME}, @ref{TIME}, @ref{TIME8}
4728 @section @code{HOSTNM} --- Get system host name
4730 @cindex system, host name
4733 @item @emph{Description}:
4734 Retrieves the host name of the system on which the program is running.
4736 This intrinsic is provided in both subroutine and function forms; however,
4737 only one form can be used in any given program unit.
4739 @item @emph{Standard}:
4743 Subroutine, function
4745 @item @emph{Syntax}:
4746 @multitable @columnfractions .80
4747 @item @code{CALL HOSTNM(NAME[, STATUS])}
4748 @item @code{STATUS = HOSTNM(NAME)}
4751 @item @emph{Arguments}:
4752 @multitable @columnfractions .15 .70
4753 @item @var{NAME} @tab Shall of type @code{CHARACTER(*)}.
4754 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
4755 Returns 0 on success, or a system specific error
4759 @item @emph{Return value}:
4760 In either syntax, @var{NAME} is set to the current hostname if it can
4761 be obtained, or to a blank string otherwise.
4768 @section @code{HUGE} --- Largest number of a kind
4770 @cindex limits, largest number
4771 @cindex model representation, largest number
4774 @item @emph{Description}:
4775 @code{HUGE(X)} returns the largest number that is not an infinity in
4776 the model of the type of @code{X}.
4778 @item @emph{Standard}:
4784 @item @emph{Syntax}:
4785 @code{RESULT = HUGE(X)}
4787 @item @emph{Arguments}:
4788 @multitable @columnfractions .15 .70
4789 @item @var{X} @tab Shall be of type @code{REAL} or @code{INTEGER}.
4792 @item @emph{Return value}:
4793 The return value is of the same type and kind as @var{X}
4795 @item @emph{Example}:
4797 program test_huge_tiny
4798 print *, huge(0), huge(0.0), huge(0.0d0)
4799 print *, tiny(0.0), tiny(0.0d0)
4800 end program test_huge_tiny
4807 @section @code{IACHAR} --- Code in @acronym{ASCII} collating sequence
4809 @cindex @acronym{ASCII} collating sequence
4810 @cindex collating sequence, @acronym{ASCII}
4811 @cindex conversion, to integer
4814 @item @emph{Description}:
4815 @code{IACHAR(C)} returns the code for the @acronym{ASCII} character
4816 in the first character position of @code{C}.
4818 @item @emph{Standard}:
4824 @item @emph{Syntax}:
4825 @code{RESULT = IACHAR(C)}
4827 @item @emph{Arguments}:
4828 @multitable @columnfractions .15 .70
4829 @item @var{C} @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
4832 @item @emph{Return value}:
4833 The return value is of type @code{INTEGER} and of the default integer
4836 @item @emph{Example}:
4841 end program test_iachar
4845 See @ref{ICHAR} for a discussion of converting between numerical values
4846 and formatted string representations.
4848 @item @emph{See also}:
4849 @ref{ACHAR}, @ref{CHAR}, @ref{ICHAR}
4856 @section @code{IAND} --- Bitwise logical and
4858 @cindex bitwise logical and
4859 @cindex logical and, bitwise
4862 @item @emph{Description}:
4863 Bitwise logical @code{AND}.
4865 @item @emph{Standard}:
4871 @item @emph{Syntax}:
4872 @code{RESULT = IAND(I, J)}
4874 @item @emph{Arguments}:
4875 @multitable @columnfractions .15 .70
4876 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
4877 @item @var{J} @tab The type shall be @code{INTEGER(*)}, of the same
4878 kind as @var{I}. (As a GNU extension, different kinds are also
4882 @item @emph{Return value}:
4883 The return type is @code{INTEGER(*)}, of the same kind as the
4884 arguments. (If the argument kinds differ, it is of the same kind as
4885 the larger argument.)
4887 @item @emph{Example}:
4891 DATA a / Z'F' /, b / Z'3' /
4892 WRITE (*,*) IAND(a, b)
4896 @item @emph{See also}:
4897 @ref{IOR}, @ref{IEOR}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
4904 @section @code{IARGC} --- Get the number of command line arguments
4906 @cindex command-line arguments
4907 @cindex command-line arguments, number of
4908 @cindex arguments, to program
4911 @item @emph{Description}:
4912 @code{IARGC()} returns the number of arguments passed on the
4913 command line when the containing program was invoked.
4915 This intrinsic routine is provided for backwards compatibility with
4916 GNU Fortran 77. In new code, programmers should consider the use of
4917 the @ref{COMMAND_ARGUMENT_COUNT} intrinsic defined by the Fortran 2003
4920 @item @emph{Standard}:
4924 Non-elemental Function
4926 @item @emph{Syntax}:
4927 @code{RESULT = IARGC()}
4929 @item @emph{Arguments}:
4932 @item @emph{Return value}:
4933 The number of command line arguments, type @code{INTEGER(4)}.
4935 @item @emph{Example}:
4938 @item @emph{See also}:
4939 GNU Fortran 77 compatibility subroutine: @ref{GETARG}
4941 F2003 functions and subroutines: @ref{GET_COMMAND}, @ref{GET_COMMAND_ARGUMENT},
4942 @ref{COMMAND_ARGUMENT_COUNT}
4948 @section @code{IBCLR} --- Clear bit
4954 @item @emph{Description}:
4955 @code{IBCLR} returns the value of @var{I} with the bit at position
4956 @var{POS} set to zero.
4958 @item @emph{Standard}:
4964 @item @emph{Syntax}:
4965 @code{RESULT = IBCLR(I, POS)}
4967 @item @emph{Arguments}:
4968 @multitable @columnfractions .15 .70
4969 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
4970 @item @var{POS} @tab The type shall be @code{INTEGER(*)}.
4973 @item @emph{Return value}:
4974 The return value is of type @code{INTEGER(*)} and of the same kind as
4977 @item @emph{See also}:
4978 @ref{IBITS}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}, @ref{MVBITS}
4985 @section @code{IBITS} --- Bit extraction
4988 @cindex bits, extract
4991 @item @emph{Description}:
4992 @code{IBITS} extracts a field of length @var{LEN} from @var{I},
4993 starting from bit position @var{POS} and extending left for @var{LEN}
4994 bits. The result is right-justified and the remaining bits are
4995 zeroed. The value of @code{POS+LEN} must be less than or equal to the
4996 value @code{BIT_SIZE(I)}.
4998 @item @emph{Standard}:
5004 @item @emph{Syntax}:
5005 @code{RESULT = IBITS(I, POS, LEN)}
5007 @item @emph{Arguments}:
5008 @multitable @columnfractions .15 .70
5009 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
5010 @item @var{POS} @tab The type shall be @code{INTEGER(*)}.
5011 @item @var{LEN} @tab The type shall be @code{INTEGER(*)}.
5014 @item @emph{Return value}:
5015 The return value is of type @code{INTEGER(*)} and of the same kind as
5018 @item @emph{See also}:
5019 @ref{BIT_SIZE}, @ref{IBCLR}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
5025 @section @code{IBSET} --- Set bit
5030 @item @emph{Description}:
5031 @code{IBSET} returns the value of @var{I} with the bit at position
5032 @var{POS} set to one.
5034 @item @emph{Standard}:
5040 @item @emph{Syntax}:
5041 @code{RESULT = IBSET(I, POS)}
5043 @item @emph{Arguments}:
5044 @multitable @columnfractions .15 .70
5045 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
5046 @item @var{POS} @tab The type shall be @code{INTEGER(*)}.
5049 @item @emph{Return value}:
5050 The return value is of type @code{INTEGER(*)} and of the same kind as
5053 @item @emph{See also}:
5054 @ref{IBCLR}, @ref{IBITS}, @ref{IAND}, @ref{IOR}, @ref{IEOR}, @ref{MVBITS}
5061 @section @code{ICHAR} --- Character-to-integer conversion function
5063 @cindex conversion, to integer
5066 @item @emph{Description}:
5067 @code{ICHAR(C)} returns the code for the character in the first character
5068 position of @code{C} in the system's native character set.
5069 The correspondence between characters and their codes is not necessarily
5070 the same across different GNU Fortran implementations.
5072 @item @emph{Standard}:
5078 @item @emph{Syntax}:
5079 @code{RESULT = ICHAR(C)}
5081 @item @emph{Arguments}:
5082 @multitable @columnfractions .15 .70
5083 @item @var{C} @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
5086 @item @emph{Return value}:
5087 The return value is of type @code{INTEGER} and of the default integer
5090 @item @emph{Example}:
5095 end program test_ichar
5099 No intrinsic exists to convert between a numeric value and a formatted
5100 character string representation -- for instance, given the
5101 @code{CHARACTER} value @code{'154'}, obtaining an @code{INTEGER} or
5102 @code{REAL} value with the value 154, or vice versa. Instead, this
5103 functionality is provided by internal-file I/O, as in the following
5108 character(len=10) string, string2
5111 ! Convert a string to a numeric value
5112 read (string,'(I10)') value
5115 ! Convert a value to a formatted string
5116 write (string2,'(I10)') value
5118 end program read_val
5121 @item @emph{See also}:
5122 @ref{ACHAR}, @ref{CHAR}, @ref{IACHAR}
5129 @section @code{IDATE} --- Get current local time subroutine (day/month/year)
5131 @cindex date, current
5132 @cindex current date
5135 @item @emph{Description}:
5136 @code{IDATE(TARRAY)} Fills @var{TARRAY} with the numerical values at the
5137 current local time. The day (in the range 1-31), month (in the range 1-12),
5138 and year appear in elements 1, 2, and 3 of @var{TARRAY}, respectively.
5139 The year has four significant digits.
5141 @item @emph{Standard}:
5147 @item @emph{Syntax}:
5148 @code{CALL IDATE(TARRAY)}
5150 @item @emph{Arguments}:
5151 @multitable @columnfractions .15 .70
5152 @item @var{TARRAY} @tab The type shall be @code{INTEGER, DIMENSION(3)} and
5153 the kind shall be the default integer kind.
5156 @item @emph{Return value}:
5159 @item @emph{Example}:
5162 integer, dimension(3) :: tarray
5167 end program test_idate
5174 @section @code{IEOR} --- Bitwise logical exclusive or
5176 @cindex bitwise logical exclusive or
5177 @cindex logical exclusive or, bitwise
5180 @item @emph{Description}:
5181 @code{IEOR} returns the bitwise boolean exclusive-OR of @var{I} and
5184 @item @emph{Standard}:
5190 @item @emph{Syntax}:
5191 @code{RESULT = IEOR(I, J)}
5193 @item @emph{Arguments}:
5194 @multitable @columnfractions .15 .70
5195 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
5196 @item @var{J} @tab The type shall be @code{INTEGER(*)}, of the same
5197 kind as @var{I}. (As a GNU extension, different kinds are also
5201 @item @emph{Return value}:
5202 The return type is @code{INTEGER(*)}, of the same kind as the
5203 arguments. (If the argument kinds differ, it is of the same kind as
5204 the larger argument.)
5206 @item @emph{See also}:
5207 @ref{IOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
5213 @section @code{IERRNO} --- Get the last system error number
5215 @cindex system, error handling
5218 @item @emph{Description}:
5219 Returns the last system error number, as given by the C @code{errno()}
5222 @item @emph{Standard}:
5226 Non-elemental function
5228 @item @emph{Syntax}:
5229 @code{RESULT = IERRNO()}
5231 @item @emph{Arguments}:
5234 @item @emph{Return value}:
5235 The return value is of type @code{INTEGER} and of the default integer
5238 @item @emph{See also}:
5245 @section @code{INDEX} --- Position of a substring within a string
5247 @cindex substring position
5248 @cindex string, find substring
5251 @item @emph{Description}:
5252 Returns the position of the start of the first occurrence of string
5253 @var{SUBSTRING} as a substring in @var{STRING}, counting from one. If
5254 @var{SUBSTRING} is not present in @var{STRING}, zero is returned. If
5255 the @var{BACK} argument is present and true, the return value is the
5256 start of the last occurrence rather than the first.
5258 @item @emph{Standard}:
5264 @item @emph{Syntax}:
5265 @code{RESULT = INDEX(STRING, SUBSTRING [, BACK])}
5267 @item @emph{Arguments}:
5268 @multitable @columnfractions .15 .70
5269 @item @var{STRING} @tab Shall be a scalar @code{CHARACTER(*)}, with
5271 @item @var{SUBSTRING} @tab Shall be a scalar @code{CHARACTER(*)}, with
5273 @item @var{BACK} @tab (Optional) Shall be a scalar @code{LOGICAL(*)}, with
5277 @item @emph{Return value}:
5278 The return value is of type @code{INTEGER} and of the default integer
5281 @item @emph{See also}:
5282 @ref{SCAN}, @ref{VERIFY}
5288 @section @code{INT} --- Convert to integer type
5292 @cindex conversion, to integer
5295 @item @emph{Description}:
5296 Convert to integer type
5298 @item @emph{Standard}:
5304 @item @emph{Syntax}:
5305 @code{RESULT = INT(A [, KIND))}
5307 @item @emph{Arguments}:
5308 @multitable @columnfractions .15 .70
5309 @item @var{A} @tab Shall be of type @code{INTEGER(*)},
5310 @code{REAL(*)}, or @code{COMPLEX(*)}.
5311 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
5312 expression indicating the kind parameter of
5316 @item @emph{Return value}:
5317 These functions return a @code{INTEGER(*)} variable or array under
5318 the following rules:
5322 If @var{A} is of type @code{INTEGER(*)}, @code{INT(A) = A}
5324 If @var{A} is of type @code{REAL(*)} and @math{|A| < 1}, @code{INT(A)} equals @code{0}.
5325 If @math{|A| \geq 1}, then @code{INT(A)} equals the largest integer that does not exceed
5326 the range of @var{A} and whose sign is the same as the sign of @var{A}.
5328 If @var{A} is of type @code{COMPLEX(*)}, rule B is applied to the real part of @var{A}.
5331 @item @emph{Example}:
5335 complex :: z = (-3.7, 1.0)
5337 print *, int(z), int(z,8)
5341 @item @emph{Specific names}:
5342 @multitable @columnfractions .20 .20 .20 .25
5343 @item Name @tab Argument @tab Return type @tab Standard
5344 @item @code{IFIX(A)} @tab @code{REAL(4) A} @tab @code{INTEGER} @tab F77 and later
5345 @item @code{IDINT(A)} @tab @code{REAL(8) A} @tab @code{INTEGER} @tab F77 and later
5353 @section @code{INT2} --- Convert to 16-bit integer type
5356 @cindex conversion, to integer
5359 @item @emph{Description}:
5360 Convert to a @code{KIND=2} integer type. This is equivalent to the
5361 standard @code{INT} intrinsic with an optional argument of
5362 @code{KIND=2}, and is only included for backwards compatibility.
5364 The @code{SHORT} intrinsic is equivalent to @code{INT2}.
5366 @item @emph{Standard}:
5372 @item @emph{Syntax}:
5373 @code{RESULT = INT2(A)}
5375 @item @emph{Arguments}:
5376 @multitable @columnfractions .15 .70
5377 @item @var{A} @tab Shall be of type @code{INTEGER(*)},
5378 @code{REAL(*)}, or @code{COMPLEX(*)}.
5381 @item @emph{Return value}:
5382 The return value is a @code{INTEGER(2)} variable.
5384 @item @emph{See also}:
5385 @ref{INT}, @ref{INT8}, @ref{LONG}
5391 @section @code{INT8} --- Convert to 64-bit integer type
5393 @cindex conversion, to integer
5396 @item @emph{Description}:
5397 Convert to a @code{KIND=8} integer type. This is equivalent to the
5398 standard @code{INT} intrinsic with an optional argument of
5399 @code{KIND=8}, and is only included for backwards compatibility.
5401 @item @emph{Standard}:
5407 @item @emph{Syntax}:
5408 @code{RESULT = INT8(A)}
5410 @item @emph{Arguments}:
5411 @multitable @columnfractions .15 .70
5412 @item @var{A} @tab Shall be of type @code{INTEGER(*)},
5413 @code{REAL(*)}, or @code{COMPLEX(*)}.
5416 @item @emph{Return value}:
5417 The return value is a @code{INTEGER(8)} variable.
5419 @item @emph{See also}:
5420 @ref{INT}, @ref{INT2}, @ref{LONG}
5426 @section @code{IOR} --- Bitwise logical or
5428 @cindex bitwise logical or
5429 @cindex logical or, bitwise
5432 @item @emph{Description}:
5433 @code{IEOR} returns the bitwise boolean OR of @var{I} and
5436 @item @emph{Standard}:
5442 @item @emph{Syntax}:
5443 @code{RESULT = IEOR(I, J)}
5445 @item @emph{Arguments}:
5446 @multitable @columnfractions .15 .70
5447 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
5448 @item @var{J} @tab The type shall be @code{INTEGER(*)}, of the same
5449 kind as @var{I}. (As a GNU extension, different kinds are also
5453 @item @emph{Return value}:
5454 The return type is @code{INTEGER(*)}, of the same kind as the
5455 arguments. (If the argument kinds differ, it is of the same kind as
5456 the larger argument.)
5458 @item @emph{See also}:
5459 @ref{IEOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
5465 @section @code{IRAND} --- Integer pseudo-random number
5467 @cindex random number generation
5470 @item @emph{Description}:
5471 @code{IRAND(FLAG)} returns a pseudo-random number from a uniform
5472 distribution between 0 and a system-dependent limit (which is in most
5473 cases 2147483647). If @var{FLAG} is 0, the next number
5474 in the current sequence is returned; if @var{FLAG} is 1, the generator
5475 is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
5476 it is used as a new seed with @code{SRAND}.
5478 @item @emph{Standard}:
5482 Non-elemental function
5484 @item @emph{Syntax}:
5485 @code{RESULT = IRAND(FLAG)}
5487 @item @emph{Arguments}:
5488 @multitable @columnfractions .15 .70
5489 @item @var{FLAG} @tab Shall be a scalar @code{INTEGER} of kind 4.
5492 @item @emph{Return value}:
5493 The return value is of @code{INTEGER(kind=4)} type.
5495 @item @emph{Example}:
5498 integer,parameter :: seed = 86456
5501 print *, irand(), irand(), irand(), irand()
5502 print *, irand(seed), irand(), irand(), irand()
5503 end program test_irand
5511 @section @code{ISATTY} --- Whether a unit is a terminal device.
5513 @cindex system, terminal
5516 @item @emph{Description}:
5517 Determine whether a unit is connected to a terminal device.
5519 @item @emph{Standard}:
5523 Non-elemental function.
5525 @item @emph{Syntax}:
5526 @code{RESULT = ISATTY(UNIT)}
5528 @item @emph{Arguments}:
5529 @multitable @columnfractions .15 .70
5530 @item @var{UNIT} @tab Shall be a scalar @code{INTEGER(*)}.
5533 @item @emph{Return value}:
5534 Returns @code{.TRUE.} if the @var{UNIT} is connected to a terminal
5535 device, @code{.FALSE.} otherwise.
5537 @item @emph{Example}:
5540 INTEGER(kind=1) :: unit
5542 write(*,*) isatty(unit=unit)
5546 @item @emph{See also}:
5553 @section @code{ISHFT} --- Shift bits
5558 @item @emph{Description}:
5559 @code{ISHFT} returns a value corresponding to @var{I} with all of the
5560 bits shifted @var{SHIFT} places. A value of @var{SHIFT} greater than
5561 zero corresponds to a left shift, a value of zero corresponds to no
5562 shift, and a value less than zero corresponds to a right shift. If the
5563 absolute value of @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the
5564 value is undefined. Bits shifted out from the left end or right end are
5565 lost; zeros are shifted in from the opposite end.
5567 @item @emph{Standard}:
5573 @item @emph{Syntax}:
5574 @code{RESULT = ISHFT(I, SHIFT)}
5576 @item @emph{Arguments}:
5577 @multitable @columnfractions .15 .70
5578 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
5579 @item @var{SHIFT} @tab The type shall be @code{INTEGER(*)}.
5582 @item @emph{Return value}:
5583 The return value is of type @code{INTEGER(*)} and of the same kind as
5586 @item @emph{See also}:
5593 @section @code{ISHFTC} --- Shift bits circularly
5595 @cindex bits, shift circular
5598 @item @emph{Description}:
5599 @code{ISHFTC} returns a value corresponding to @var{I} with the
5600 rightmost @var{SIZE} bits shifted circularly @var{SHIFT} places; that
5601 is, bits shifted out one end are shifted into the opposite end. A value
5602 of @var{SHIFT} greater than zero corresponds to a left shift, a value of
5603 zero corresponds to no shift, and a value less than zero corresponds to
5604 a right shift. The absolute value of @var{SHIFT} must be less than
5605 @var{SIZE}. If the @var{SIZE} argument is omitted, it is taken to be
5606 equivalent to @code{BIT_SIZE(I)}.
5608 @item @emph{Standard}:
5614 @item @emph{Syntax}:
5615 @code{RESULT = ISHFTC(I, SHIFT [, SIZE])}
5617 @item @emph{Arguments}:
5618 @multitable @columnfractions .15 .70
5619 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
5620 @item @var{SHIFT} @tab The type shall be @code{INTEGER(*)}.
5621 @item @var{SIZE} @tab (Optional) The type shall be @code{INTEGER(*)};
5622 the value must be greater than zero and less than or equal to
5626 @item @emph{Return value}:
5627 The return value is of type @code{INTEGER(*)} and of the same kind as
5630 @item @emph{See also}:
5637 @section @code{ITIME} --- Get current local time subroutine (hour/minutes/seconds)
5639 @cindex time, current
5640 @cindex current time
5643 @item @emph{Description}:
5644 @code{IDATE(TARRAY)} Fills @var{TARRAY} with the numerical values at the
5645 current local time. The hour (in the range 1-24), minute (in the range 1-60),
5646 and seconds (in the range 1-60) appear in elements 1, 2, and 3 of @var{TARRAY},
5649 @item @emph{Standard}:
5655 @item @emph{Syntax}:
5656 @code{CALL ITIME(TARRAY)}
5658 @item @emph{Arguments}:
5659 @multitable @columnfractions .15 .70
5660 @item @var{TARRAY} @tab The type shall be @code{INTEGER, DIMENSION(3)}
5661 and the kind shall be the default integer kind.
5664 @item @emph{Return value}:
5668 @item @emph{Example}:
5671 integer, dimension(3) :: tarray
5676 end program test_itime
5683 @section @code{KILL} --- Send a signal to a process
5687 @item @emph{Description}:
5688 @item @emph{Standard}:
5689 Sends the signal specified by @var{SIGNAL} to the process @var{PID}.
5695 @item @emph{Syntax}:
5696 @code{CALL KILL(PID, SIGNAL [, STATUS])}
5698 @item @emph{Arguments}:
5699 @multitable @columnfractions .15 .70
5700 @item @var{PID} @tab Shall be a scalar @code{INTEGER}, with
5702 @item @var{SIGNAL} @tab Shall be a scalar @code{INTEGER}, with
5704 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)} or
5705 @code{INTEGER(8)}. Returns 0 on success, or a
5706 system-specific error code otherwise.
5709 @item @emph{See also}:
5710 @ref{ABORT}, @ref{EXIT}
5716 @section @code{KIND} --- Kind of an entity
5721 @item @emph{Description}:
5722 @code{KIND(X)} returns the kind value of the entity @var{X}.
5724 @item @emph{Standard}:
5730 @item @emph{Syntax}:
5733 @item @emph{Arguments}:
5734 @multitable @columnfractions .15 .70
5735 @item @var{X} @tab Shall be of type @code{LOGICAL}, @code{INTEGER},
5736 @code{REAL}, @code{COMPLEX} or @code{CHARACTER}.
5739 @item @emph{Return value}:
5740 The return value is a scalar of type @code{INTEGER} and of the default
5743 @item @emph{Example}:
5746 integer,parameter :: kc = kind(' ')
5747 integer,parameter :: kl = kind(.true.)
5749 print *, "The default character kind is ", kc
5750 print *, "The default logical kind is ", kl
5751 end program test_kind
5759 @section @code{LBOUND} --- Lower dimension bounds of an array
5761 @cindex array, lower bound
5764 @item @emph{Description}:
5765 Returns the lower bounds of an array, or a single lower bound
5766 along the @var{DIM} dimension.
5767 @item @emph{Standard}:
5773 @item @emph{Syntax}:
5774 @code{RESULT = LBOUND(ARRAY [, DIM])}
5776 @item @emph{Arguments}:
5777 @multitable @columnfractions .15 .70
5778 @item @var{ARRAY} @tab Shall be an array, of any type.
5779 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER(*)}.
5782 @item @emph{Return value}:
5783 If @var{DIM} is absent, the result is an array of the lower bounds of
5784 @var{ARRAY}. If @var{DIM} is present, the result is a scalar
5785 corresponding to the lower bound of the array along that dimension. If
5786 @var{ARRAY} is an expression rather than a whole array or array
5787 structure component, or if it has a zero extent along the relevant
5788 dimension, the lower bound is taken to be 1.
5790 @item @emph{See also}:
5797 @section @code{LEN} --- Length of a character entity
5799 @cindex string, length
5802 @item @emph{Description}:
5803 Returns the length of a character string. If @var{STRING} is an array,
5804 the length of an element of @var{STRING} is returned. Note that
5805 @var{STRING} need not be defined when this intrinsic is invoked, since
5806 only the length, not the content, of @var{STRING} is needed.
5808 @item @emph{Standard}:
5814 @item @emph{Syntax}:
5815 @code{L = LEN(STRING)}
5817 @item @emph{Arguments}:
5818 @multitable @columnfractions .15 .70
5819 @item @var{STRING} @tab Shall be a scalar or array of type
5820 @code{CHARACTER(*)}, with @code{INTENT(IN)}
5823 @item @emph{Return value}:
5824 The return value is an @code{INTEGER} of the default kind.
5826 @item @emph{See also}:
5827 @ref{LEN_TRIM}, @ref{ADJUSTL}, @ref{ADJUSTR}
5833 @section @code{LEN_TRIM} --- Length of a character entity without trailing blank characters
5835 @cindex string, length, without trailing whitespace
5838 @item @emph{Description}:
5839 Returns the length of a character string, ignoring any trailing blanks.
5841 @item @emph{Standard}:
5847 @item @emph{Syntax}:
5848 @code{RESULT = LEN_TRIM(STRING)}
5850 @item @emph{Arguments}:
5851 @multitable @columnfractions .15 .70
5852 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER(*)},
5853 with @code{INTENT(IN)}
5856 @item @emph{Return value}:
5857 The return value is an @code{INTEGER} of the default kind.
5859 @item @emph{See also}:
5860 @ref{LEN}, @ref{ADJUSTL}, @ref{ADJUSTR}
5866 @section @code{LGE} --- Lexical greater than or equal
5868 @cindex lexical comparison of strings
5869 @cindex string, comparison
5872 @item @emph{Description}:
5873 Determines whether one string is lexically greater than or equal to
5874 another string, where the two strings are interpreted as containing
5875 ASCII character codes. If the String A and String B are not the same
5876 length, the shorter is compared as if spaces were appended to it to form
5877 a value that has the same length as the longer.
5879 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
5880 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
5881 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
5882 that the latter use the processor's character ordering (which is not
5883 ASCII on some targets), whereas the former always use the ASCII
5886 @item @emph{Standard}:
5892 @item @emph{Syntax}:
5893 @code{RESULT = LGE(STRING_A, STRING_B)}
5895 @item @emph{Arguments}:
5896 @multitable @columnfractions .15 .70
5897 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
5898 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
5901 @item @emph{Return value}:
5902 Returns @code{.TRUE.} if @code{STRING_A >= STRING_B}, and @code{.FALSE.}
5903 otherwise, based on the ASCII ordering.
5905 @item @emph{See also}:
5906 @ref{LGT}, @ref{LLE}, @ref{LLT}
5912 @section @code{LGT} --- Lexical greater than
5914 @cindex lexical comparison of strings
5915 @cindex string, comparison
5918 @item @emph{Description}:
5919 Determines whether one string is lexically greater than another string,
5920 where the two strings are interpreted as containing ASCII character
5921 codes. If the String A and String B are not the same length, the
5922 shorter is compared as if spaces were appended to it to form a value
5923 that has the same length as the longer.
5925 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
5926 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
5927 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
5928 that the latter use the processor's character ordering (which is not
5929 ASCII on some targets), whereas the former always use the ASCII
5932 @item @emph{Standard}:
5938 @item @emph{Syntax}:
5939 @code{RESULT = LGT(STRING_A, STRING_B)}
5941 @item @emph{Arguments}:
5942 @multitable @columnfractions .15 .70
5943 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
5944 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
5947 @item @emph{Return value}:
5948 Returns @code{.TRUE.} if @code{STRING_A > STRING_B}, and @code{.FALSE.}
5949 otherwise, based on the ASCII ordering.
5951 @item @emph{See also}:
5952 @ref{LGE}, @ref{LLE}, @ref{LLT}
5958 @section @code{LINK} --- Create a hard link
5960 @cindex file system, create link
5961 @cindex file system, hard link
5964 @item @emph{Description}:
5965 Makes a (hard) link from file @var{PATH1} to @var{PATH2}. A null
5966 character (@code{CHAR(0)}) can be used to mark the end of the names in
5967 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
5968 names are ignored. If the @var{STATUS} argument is supplied, it
5969 contains 0 on success or a nonzero error code upon return; see
5972 This intrinsic is provided in both subroutine and function forms;
5973 however, only one form can be used in any given program unit.
5975 @item @emph{Standard}:
5979 Subroutine, non-elemental function
5981 @item @emph{Syntax}:
5982 @multitable @columnfractions .80
5983 @item @code{CALL LINK(PATH1, PATH2 [, STATUS])}
5984 @item @code{STATUS = LINK(PATH1, PATH2)}
5987 @item @emph{Arguments}:
5988 @multitable @columnfractions .15 .70
5989 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
5990 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
5991 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
5994 @item @emph{See also}:
5995 @ref{SYMLNK}, @ref{UNLINK}
6001 @section @code{LLE} --- Lexical less than or equal
6003 @cindex lexical comparison of strings
6004 @cindex string, comparison
6007 @item @emph{Description}:
6008 Determines whether one string is lexically less than or equal to another
6009 string, where the two strings are interpreted as containing ASCII
6010 character codes. If the String A and String B are not the same length,
6011 the shorter is compared as if spaces were appended to it to form a value
6012 that has the same length as the longer.
6014 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
6015 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
6016 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
6017 that the latter use the processor's character ordering (which is not
6018 ASCII on some targets), whereas the former always use the ASCII
6021 @item @emph{Standard}:
6027 @item @emph{Syntax}:
6028 @code{RESULT = LLE(STRING_A, STRING_B)}
6030 @item @emph{Arguments}:
6031 @multitable @columnfractions .15 .70
6032 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
6033 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
6036 @item @emph{Return value}:
6037 Returns @code{.TRUE.} if @code{STRING_A <= STRING_B}, and @code{.FALSE.}
6038 otherwise, based on the ASCII ordering.
6040 @item @emph{See also}:
6041 @ref{LGE}, @ref{LGT}, @ref{LLT}
6047 @section @code{LLT} --- Lexical less than
6049 @cindex lexical comparison of strings
6050 @cindex string, comparison
6053 @item @emph{Description}:
6054 Determines whether one string is lexically less than another string,
6055 where the two strings are interpreted as containing ASCII character
6056 codes. If the String A and String B are not the same length, the
6057 shorter is compared as if spaces were appended to it to form a value
6058 that has the same length as the longer.
6060 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
6061 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
6062 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
6063 that the latter use the processor's character ordering (which is not
6064 ASCII on some targets), whereas the former always use the ASCII
6067 @item @emph{Standard}:
6073 @item @emph{Syntax}:
6074 @code{RESULT = LLT(STRING_A, STRING_B)}
6076 @item @emph{Arguments}:
6077 @multitable @columnfractions .15 .70
6078 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
6079 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
6082 @item @emph{Return value}:
6083 Returns @code{.TRUE.} if @code{STRING_A < STRING_B}, and @code{.FALSE.}
6084 otherwise, based on the ASCII ordering.
6086 @item @emph{See also}:
6087 @ref{LGE}, @ref{LGT}, @ref{LLE}
6093 @section @code{LNBLNK} --- Index of the last non-blank character in a string
6095 @cindex string, find non-blank character
6098 @item @emph{Description}:
6099 Returns the length of a character string, ignoring any trailing blanks.
6100 This is identical to the standard @code{LEN_TRIM} intrinsic, and is only
6101 included for backwards compatibility.
6103 @item @emph{Standard}:
6109 @item @emph{Syntax}:
6110 @code{RESULT = LNBLNK(STRING)}
6112 @item @emph{Arguments}:
6113 @multitable @columnfractions .15 .70
6114 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER(*)},
6115 with @code{INTENT(IN)}
6118 @item @emph{Return value}:
6119 The return value is of @code{INTEGER(kind=4)} type.
6121 @item @emph{See also}:
6122 @ref{INDEX}, @ref{LEN_TRIM}
6128 @section @code{LOC} --- Returns the address of a variable
6130 @cindex location of a variable in memory
6133 @item @emph{Description}:
6134 @code{LOC(X)} returns the address of @var{X} as an integer.
6136 @item @emph{Standard}:
6142 @item @emph{Syntax}:
6143 @code{RESULT = LOC(X)}
6145 @item @emph{Arguments}:
6146 @multitable @columnfractions .15 .70
6147 @item @var{X} @tab Variable of any type.
6150 @item @emph{Return value}:
6151 The return value is of type @code{INTEGER}, with a @code{KIND}
6152 corresponding to the size (in bytes) of a memory address on the target
6155 @item @emph{Example}:
6162 end program test_loc
6169 @section @code{LOG} --- Logarithm function
6176 @cindex exponential function, inverse
6177 @cindex logarithmic function
6180 @item @emph{Description}:
6181 @code{LOG(X)} computes the logarithm of @var{X}.
6183 @item @emph{Standard}:
6189 @item @emph{Syntax}:
6190 @code{RESULT = LOG(X)}
6192 @item @emph{Arguments}:
6193 @multitable @columnfractions .15 .70
6194 @item @var{X} @tab The type shall be @code{REAL(*)} or
6198 @item @emph{Return value}:
6199 The return value is of type @code{REAL(*)} or @code{COMPLEX(*)}.
6200 The kind type parameter is the same as @var{X}.
6202 @item @emph{Example}:
6205 real(8) :: x = 1.0_8
6206 complex :: z = (1.0, 2.0)
6209 end program test_log
6212 @item @emph{Specific names}:
6213 @multitable @columnfractions .20 .20 .20 .25
6214 @item Name @tab Argument @tab Return type @tab Standard
6215 @item @code{ALOG(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab f95, gnu
6216 @item @code{DLOG(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
6217 @item @code{CLOG(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab f95, gnu
6218 @item @code{ZLOG(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
6219 @item @code{CDLOG(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
6226 @section @code{LOG10} --- Base 10 logarithm function
6230 @cindex exponential function, inverse
6231 @cindex logarithmic function
6234 @item @emph{Description}:
6235 @code{LOG10(X)} computes the base 10 logarithm of @var{X}.
6237 @item @emph{Standard}:
6243 @item @emph{Syntax}:
6244 @code{RESULT = LOG10(X)}
6246 @item @emph{Arguments}:
6247 @multitable @columnfractions .15 .70
6248 @item @var{X} @tab The type shall be @code{REAL(*)}.
6251 @item @emph{Return value}:
6252 The return value is of type @code{REAL(*)} or @code{COMPLEX(*)}.
6253 The kind type parameter is the same as @var{X}.
6255 @item @emph{Example}:
6258 real(8) :: x = 10.0_8
6260 end program test_log10
6263 @item @emph{Specific names}:
6264 @multitable @columnfractions .20 .20 .20 .25
6265 @item Name @tab Argument @tab Return type @tab Standard
6266 @item @code{ALOG10(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab F95 and later
6267 @item @code{DLOG10(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
6274 @section @code{LOGICAL} --- Convert to logical type
6276 @cindex conversion, to logical
6279 @item @emph{Description}:
6280 Converts one kind of @code{LOGICAL} variable to another.
6282 @item @emph{Standard}:
6288 @item @emph{Syntax}:
6289 @code{RESULT = LOGICAL(L [, KIND])}
6291 @item @emph{Arguments}:
6292 @multitable @columnfractions .15 .70
6293 @item @var{L} @tab The type shall be @code{LOGICAL(*)}.
6294 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
6295 expression indicating the kind parameter of
6299 @item @emph{Return value}:
6300 The return value is a @code{LOGICAL} value equal to @var{L}, with a
6301 kind corresponding to @var{KIND}, or of the default logical kind if
6302 @var{KIND} is not given.
6304 @item @emph{See also}:
6305 @ref{INT}, @ref{REAL}, @ref{CMPLX}
6311 @section @code{LONG} --- Convert to integer type
6313 @cindex conversion, to integer
6316 @item @emph{Description}:
6317 Convert to a @code{KIND=4} integer type, which is the same size as a C
6318 @code{long} integer. This is equivalent to the standard @code{INT}
6319 intrinsic with an optional argument of @code{KIND=4}, and is only
6320 included for backwards compatibility.
6322 @item @emph{Standard}:
6328 @item @emph{Syntax}:
6329 @code{RESULT = LONG(A)}
6331 @item @emph{Arguments}:
6332 @multitable @columnfractions .15 .70
6333 @item @var{A} @tab Shall be of type @code{INTEGER(*)},
6334 @code{REAL(*)}, or @code{COMPLEX(*)}.
6337 @item @emph{Return value}:
6338 The return value is a @code{INTEGER(4)} variable.
6340 @item @emph{See also}:
6341 @ref{INT}, @ref{INT2}, @ref{INT8}
6347 @section @code{LSHIFT} --- Left shift bits
6349 @cindex bits, shift left
6352 @item @emph{Description}:
6353 @code{LSHIFT} returns a value corresponding to @var{I} with all of the
6354 bits shifted left by @var{SHIFT} places. If the absolute value of
6355 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
6356 Bits shifted out from the left end are lost; zeros are shifted in from
6359 This function has been superseded by the @code{ISHFT} intrinsic, which
6360 is standard in Fortran 95 and later.
6362 @item @emph{Standard}:
6368 @item @emph{Syntax}:
6369 @code{RESULT = LSHIFT(I, SHIFT)}
6371 @item @emph{Arguments}:
6372 @multitable @columnfractions .15 .70
6373 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
6374 @item @var{SHIFT} @tab The type shall be @code{INTEGER(*)}.
6377 @item @emph{Return value}:
6378 The return value is of type @code{INTEGER(*)} and of the same kind as
6381 @item @emph{See also}:
6382 @ref{ISHFT}, @ref{ISHFTC}, @ref{RSHIFT}
6389 @section @code{LSTAT} --- Get file status
6391 @cindex file system, file status
6394 @item @emph{Description}:
6395 @code{LSTAT} is identical to @ref{STAT}, except that if path is a symbolic link,
6396 then the link itself is statted, not the file that it refers to.
6398 The elements in @code{BUFF} are the same as described by @ref{STAT}.
6400 @item @emph{Standard}:
6404 Non-elemental subroutine
6406 @item @emph{Syntax}:
6407 @code{CALL LSTAT(FILE, BUFF [, STATUS])}
6409 @item @emph{Arguments}:
6410 @multitable @columnfractions .15 .70
6411 @item @var{FILE} @tab The type shall be @code{CHARACTER(*)}, a valid path within the file system.
6412 @item @var{BUFF} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
6413 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0
6414 on success and a system specific error code otherwise.
6417 @item @emph{Example}:
6418 See @ref{STAT} for an example.
6420 @item @emph{See also}:
6421 To stat an open file: @ref{FSTAT}, to stat a file: @ref{STAT}
6427 @section @code{LTIME} --- Convert time to local time info
6429 @cindex time, converstion to local time info
6432 @item @emph{Description}:
6433 Given a system time value @var{STIME} (as provided by the @code{TIME8()}
6434 intrinsic), fills @var{TARRAY} with values extracted from it appropriate
6435 to the local time zone using @code{localtime(3)}.
6437 @item @emph{Standard}:
6443 @item @emph{Syntax}:
6444 @code{CALL LTIME(STIME, TARRAY)}
6446 @item @emph{Arguments}:
6447 @multitable @columnfractions .15 .70
6448 @item @var{STIME} @tab An @code{INTEGER(*)} scalar expression
6449 corresponding to a system time, with
6451 @item @var{TARRAY} @tab A default @code{INTEGER} array with 9 elements,
6452 with @code{INTENT(OUT)}.
6455 @item @emph{Return value}:
6456 The elements of @var{TARRAY} are assigned as follows:
6458 @item Seconds after the minute, range 0--59 or 0--61 to allow for leap
6460 @item Minutes after the hour, range 0--59
6461 @item Hours past midnight, range 0--23
6462 @item Day of month, range 0--31
6463 @item Number of months since January, range 0--12
6464 @item Years since 1900
6465 @item Number of days since Sunday, range 0--6
6466 @item Days since January 1
6467 @item Daylight savings indicator: positive if daylight savings is in
6468 effect, zero if not, and negative if the information is not
6472 @item @emph{See also}:
6473 @ref{CTIME}, @ref{GMTIME}, @ref{TIME}, @ref{TIME8}
6480 @section @code{MALLOC} --- Allocate dynamic memory
6482 @cindex pointer, cray
6485 @item @emph{Description}:
6486 @code{MALLOC(SIZE)} allocates @var{SIZE} bytes of dynamic memory and
6487 returns the address of the allocated memory. The @code{MALLOC} intrinsic
6488 is an extension intended to be used with Cray pointers, and is provided
6489 in GNU Fortran to allow the user to compile legacy code. For new code
6490 using Fortran 95 pointers, the memory allocation intrinsic is
6493 @item @emph{Standard}:
6497 Non-elemental function
6499 @item @emph{Syntax}:
6500 @code{PTR = MALLOC(SIZE)}
6502 @item @emph{Arguments}:
6503 @multitable @columnfractions .15 .70
6504 @item @var{SIZE} @tab The type shall be @code{INTEGER(*)}.
6507 @item @emph{Return value}:
6508 The return value is of type @code{INTEGER(K)}, with @var{K} such that
6509 variables of type @code{INTEGER(K)} have the same size as
6510 C pointers (@code{sizeof(void *)}).
6512 @item @emph{Example}:
6513 The following example demonstrates the use of @code{MALLOC} and
6514 @code{FREE} with Cray pointers. This example is intended to run on
6515 32-bit systems, where the default integer kind is suitable to store
6516 pointers; on 64-bit systems, ptr_x would need to be declared as
6517 @code{integer(kind=8)}.
6526 ptr_x = malloc(20*8)
6528 x(i) = sqrt(1.0d0 / i)
6536 end program test_malloc
6539 @item @emph{See also}:
6546 @section @code{MATMUL} --- matrix multiplication
6548 @cindex matrix multiplication
6549 @cindex product, matrix
6552 @item @emph{Description}:
6553 Performs a matrix multiplication on numeric or logical arguments.
6555 @item @emph{Standard}:
6559 Transformational function
6561 @item @emph{Syntax}:
6562 @code{RESULT = MATMUL(MATRIX_A, MATRIX_B)}
6564 @item @emph{Arguments}:
6565 @multitable @columnfractions .15 .70
6566 @item @var{MATRIX_A} @tab An array of @code{INTEGER(*)},
6567 @code{REAL(*)}, @code{COMPLEX(*)}, or
6568 @code{LOGICAL(*)} type, with a rank of
6570 @item @var{MATRIX_B} @tab An array of @code{INTEGER(*)},
6571 @code{REAL(*)}, or @code{COMPLEX(*)} type if
6572 @var{MATRIX_A} is of a numeric type;
6573 otherwise, an array of @code{LOGICAL(*)}
6574 type. The rank shall be one or two, and the
6575 first (or only) dimension of @var{MATRIX_B}
6576 shall be equal to the last (or only)
6577 dimension of @var{MATRIX_A}.
6580 @item @emph{Return value}:
6581 The matrix product of @var{MATRIX_A} and @var{MATRIX_B}. The type and
6582 kind of the result follow the usual type and kind promotion rules, as
6583 for the @code{*} or @code{.AND.} operators.
6585 @item @emph{See also}:
6591 @section @code{MAX} --- Maximum value of an argument list
6598 @cindex maximum value
6601 @item @emph{Description}:
6602 Returns the argument with the largest (most positive) value.
6604 @item @emph{Standard}:
6610 @item @emph{Syntax}:
6611 @code{RESULT = MAX(A1, A2 [, A3 [, ...]])}
6613 @item @emph{Arguments}:
6614 @multitable @columnfractions .15 .70
6615 @item @var{A1} @tab The type shall be @code{INTEGER(*)} or
6617 @item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
6618 as @var{A1}. (As a GNU extension,
6619 arguments of different kinds are
6623 @item @emph{Return value}:
6624 The return value corresponds to the maximum value among the arguments,
6625 and has the same type and kind as the first argument.
6627 @item @emph{Specific names}:
6628 @multitable @columnfractions .20 .20 .20 .25
6629 @item Name @tab Argument @tab Return type @tab Standard
6630 @item @code{MAX0(I)} @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)} @tab F77 and later
6631 @item @code{AMAX0(I)} @tab @code{INTEGER(4) I} @tab @code{REAL(MAX(X))} @tab F77 and later
6632 @item @code{MAX1(X)} @tab @code{REAL(*) X} @tab @code{INT(MAX(X))} @tab F77 and later
6633 @item @code{AMAX1(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab F77 and later
6634 @item @code{DMAX1(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
6637 @item @emph{See also}:
6638 @ref{MAXLOC} @ref{MAXVAL}, @ref{MIN}
6645 @section @code{MAXEXPONENT} --- Maximum exponent of a real kind
6646 @fnindex MAXEXPONENT
6647 @cindex model representation, maximum exponent
6650 @item @emph{Description}:
6651 @code{MAXEXPONENT(X)} returns the maximum exponent in the model of the
6654 @item @emph{Standard}:
6660 @item @emph{Syntax}:
6661 @code{RESULT = MAXEXPONENT(X)}
6663 @item @emph{Arguments}:
6664 @multitable @columnfractions .15 .70
6665 @item @var{X} @tab Shall be of type @code{REAL}.
6668 @item @emph{Return value}:
6669 The return value is of type @code{INTEGER} and of the default integer
6672 @item @emph{Example}:
6678 print *, minexponent(x), maxexponent(x)
6679 print *, minexponent(y), maxexponent(y)
6680 end program exponents
6687 @section @code{MAXLOC} --- Location of the maximum value within an array
6689 @cindex array, location of maximum element
6692 @item @emph{Description}:
6693 Determines the location of the element in the array with the maximum
6694 value, or, if the @var{DIM} argument is supplied, determines the
6695 locations of the maximum element along each row of the array in the
6696 @var{DIM} direction. If @var{MASK} is present, only the elements for
6697 which @var{MASK} is @code{.TRUE.} are considered. If more than one
6698 element in the array has the maximum value, the location returned is
6699 that of the first such element in array element order. If the array has
6700 zero size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
6701 the result is an array of zeroes. Similarly, if @var{DIM} is supplied
6702 and all of the elements of @var{MASK} along a given row are zero, the
6703 result value for that row is zero.
6705 @item @emph{Standard}:
6709 Transformational function
6711 @item @emph{Syntax}:
6712 @multitable @columnfractions .80
6713 @item @code{RESULT = MAXLOC(ARRAY, DIM [, MASK])}
6714 @item @code{RESULT = MAXLOC(ARRAY [, MASK])}
6717 @item @emph{Arguments}:
6718 @multitable @columnfractions .15 .70
6719 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER(*)},
6720 @code{REAL(*)}, or @code{CHARACTER(*)}.
6721 @item @var{DIM} @tab (Optional) Shall be a scalar of type
6722 @code{INTEGER(*)}, with a value between one
6723 and the rank of @var{ARRAY}, inclusive. It
6724 may not be an optional dummy argument.
6725 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL(*)},
6726 and conformable with @var{ARRAY}.
6729 @item @emph{Return value}:
6730 If @var{DIM} is absent, the result is a rank-one array with a length
6731 equal to the rank of @var{ARRAY}. If @var{DIM} is present, the result
6732 is an array with a rank one less than the rank of @var{ARRAY}, and a
6733 size corresponding to the size of @var{ARRAY} with the @var{DIM}
6734 dimension removed. If @var{DIM} is present and @var{ARRAY} has a rank
6735 of one, the result is a scalar. In all cases, the result is of default
6736 @code{INTEGER} type.
6738 @item @emph{See also}:
6739 @ref{MAX}, @ref{MAXVAL}
6746 @section @code{MAXVAL} --- Maximum value of an array
6748 @cindex array, maximum value
6749 @cindex maximum value
6752 @item @emph{Description}:
6753 Determines the maximum value of the elements in an array value, or, if
6754 the @var{DIM} argument is supplied, determines the maximum value along
6755 each row of the array in the @var{DIM} direction. If @var{MASK} is
6756 present, only the elements for which @var{MASK} is @code{.TRUE.} are
6757 considered. If the array has zero size, or all of the elements of
6758 @var{MASK} are @code{.FALSE.}, then the result is the most negative
6759 number of the type and kind of @var{ARRAY} if @var{ARRAY} is numeric, or
6760 a string of nulls if @var{ARRAY} is of character type.
6762 @item @emph{Standard}:
6766 Transformational function
6768 @item @emph{Syntax}:
6769 @multitable @columnfractions .80
6770 @item @code{RESULT = MAXVAL(ARRAY, DIM [, MASK])}
6771 @item @code{RESULT = MAXVAL(ARRAY [, MASK])}
6774 @item @emph{Arguments}:
6775 @multitable @columnfractions .15 .70
6776 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER(*)},
6777 @code{REAL(*)}, or @code{CHARACTER(*)}.
6778 @item @var{DIM} @tab (Optional) Shall be a scalar of type
6779 @code{INTEGER(*)}, with a value between one
6780 and the rank of @var{ARRAY}, inclusive. It
6781 may not be an optional dummy argument.
6782 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL(*)},
6783 and conformable with @var{ARRAY}.
6786 @item @emph{Return value}:
6787 If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
6788 is a scalar. If @var{DIM} is present, the result is an array with a
6789 rank one less than the rank of @var{ARRAY}, and a size corresponding to
6790 the size of @var{ARRAY} with the @var{DIM} dimension removed. In all
6791 cases, the result is of the same type and kind as @var{ARRAY}.
6793 @item @emph{See also}:
6794 @ref{MAX}, @ref{MAXLOC}
6800 @section @code{MCLOCK} --- Time function
6802 @cindex time, clock ticks
6806 @item @emph{Description}:
6807 Returns the number of clock ticks since the start of the process, based
6808 on the UNIX function @code{clock(3)}.
6810 This intrinsic is not fully portable, such as to systems with 32-bit
6811 @code{INTEGER} types but supporting times wider than 32 bits. Therefore,
6812 the values returned by this intrinsic might be, or become, negative, or
6813 numerically less than previous values, during a single run of the
6816 @item @emph{Standard}:
6820 Non-elemental function
6822 @item @emph{Syntax}:
6823 @code{RESULT = MCLOCK()}
6825 @item @emph{Return value}:
6826 The return value is a scalar of type @code{INTEGER(4)}, equal to the
6827 number of clock ticks since the start of the process, or @code{-1} if
6828 the system does not support @code{clock(3)}.
6830 @item @emph{See also}:
6831 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME}
6838 @section @code{MCLOCK8} --- Time function (64-bit)
6840 @cindex time, clock ticks
6844 @item @emph{Description}:
6845 Returns the number of clock ticks since the start of the process, based
6846 on the UNIX function @code{clock(3)}.
6848 @emph{Warning:} this intrinsic does not increase the range of the timing
6849 values over that returned by @code{clock(3)}. On a system with a 32-bit
6850 @code{clock(3)}, @code{MCLOCK8()} will return a 32-bit value, even though
6851 it is converted to a 64-bit @code{INTEGER(8)} value. That means
6852 overflows of the 32-bit value can still occur. Therefore, the values
6853 returned by this intrinsic might be or become negative or numerically
6854 less than previous values during a single run of the compiled program.
6856 @item @emph{Standard}:
6860 Non-elemental function
6862 @item @emph{Syntax}:
6863 @code{RESULT = MCLOCK8()}
6865 @item @emph{Return value}:
6866 The return value is a scalar of type @code{INTEGER(8)}, equal to the
6867 number of clock ticks since the start of the process, or @code{-1} if
6868 the system does not support @code{clock(3)}.
6870 @item @emph{See also}:
6871 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME8}
6878 @section @code{MERGE} --- Merge variables
6880 @cindex array, merge arrays
6881 @cindex array, combine arrays
6884 @item @emph{Description}:
6885 Select values from two arrays according to a logical mask. The result
6886 is equal to @var{TSOURCE} if @var{MASK} is @code{.TRUE.}, or equal to
6887 @var{FSOURCE} if it is @code{.FALSE.}.
6889 @item @emph{Standard}:
6895 @item @emph{Syntax}:
6896 @code{RESULT = MERGE(TSOURCE, FSOURCE, MASK)}
6898 @item @emph{Arguments}:
6899 @multitable @columnfractions .15 .70
6900 @item @var{TSOURCE} @tab May be of any type.
6901 @item @var{FSOURCE} @tab Shall be of the same type and type parameters
6903 @item @var{MASK} @tab Shall be of type @code{LOGICAL(*)}.
6906 @item @emph{Return value}:
6907 The result is of the same type and type parameters as @var{TSOURCE}.
6914 @section @code{MIN} --- Minimum value of an argument list
6921 @cindex minimum value
6924 @item @emph{Description}:
6925 Returns the argument with the smallest (most negative) value.
6927 @item @emph{Standard}:
6933 @item @emph{Syntax}:
6934 @code{RESULT = MIN(A1, A2 [, A3, ...])}
6936 @item @emph{Arguments}:
6937 @multitable @columnfractions .15 .70
6938 @item @var{A1} @tab The type shall be @code{INTEGER(*)} or
6940 @item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
6941 as @var{A1}. (As a GNU extension,
6942 arguments of different kinds are
6946 @item @emph{Return value}:
6947 The return value corresponds to the maximum value among the arguments,
6948 and has the same type and kind as the first argument.
6950 @item @emph{Specific names}:
6951 @multitable @columnfractions .20 .20 .20 .25
6952 @item Name @tab Argument @tab Return type @tab Standard
6953 @item @code{MIN0(I)} @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)} @tab F77 and later
6954 @item @code{AMIN0(I)} @tab @code{INTEGER(4) I} @tab @code{REAL(MIN(X))} @tab F77 and later
6955 @item @code{MIN1(X)} @tab @code{REAL(*) X} @tab @code{INT(MIN(X))} @tab F77 and later
6956 @item @code{AMIN1(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab F77 and later
6957 @item @code{DMIN1(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
6960 @item @emph{See also}:
6961 @ref{MAX}, @ref{MINLOC}, @ref{MINVAL}
6967 @section @code{MINEXPONENT} --- Minimum exponent of a real kind
6968 @fnindex MINEXPONENT
6969 @cindex model representation, minimum exponent
6972 @item @emph{Description}:
6973 @code{MINEXPONENT(X)} returns the minimum exponent in the model of the
6976 @item @emph{Standard}:
6982 @item @emph{Syntax}:
6983 @code{RESULT = MINEXPONENT(X)}
6985 @item @emph{Arguments}:
6986 @multitable @columnfractions .15 .70
6987 @item @var{X} @tab Shall be of type @code{REAL}.
6990 @item @emph{Return value}:
6991 The return value is of type @code{INTEGER} and of the default integer
6994 @item @emph{Example}:
6995 See @code{MAXEXPONENT} for an example.
7001 @section @code{MINLOC} --- Location of the minimum value within an array
7003 @cindex array, location of minimum element
7006 @item @emph{Description}:
7007 Determines the location of the element in the array with the minimum
7008 value, or, if the @var{DIM} argument is supplied, determines the
7009 locations of the minimum element along each row of the array in the
7010 @var{DIM} direction. If @var{MASK} is present, only the elements for
7011 which @var{MASK} is @code{.TRUE.} are considered. If more than one
7012 element in the array has the minimum value, the location returned is
7013 that of the first such element in array element order. If the array has
7014 zero size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
7015 the result is an array of zeroes. Similarly, if @var{DIM} is supplied
7016 and all of the elements of @var{MASK} along a given row are zero, the
7017 result value for that row is zero.
7019 @item @emph{Standard}:
7023 Transformational function
7025 @item @emph{Syntax}:
7026 @multitable @columnfractions .80
7027 @item @code{RESULT = MINLOC(ARRAY, DIM [, MASK])}
7028 @item @code{RESULT = MINLOC(ARRAY [, MASK])}
7031 @item @emph{Arguments}:
7032 @multitable @columnfractions .15 .70
7033 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER(*)},
7034 @code{REAL(*)}, or @code{CHARACTER(*)}.
7035 @item @var{DIM} @tab (Optional) Shall be a scalar of type
7036 @code{INTEGER(*)}, with a value between one
7037 and the rank of @var{ARRAY}, inclusive. It
7038 may not be an optional dummy argument.
7039 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL(*)},
7040 and conformable with @var{ARRAY}.
7043 @item @emph{Return value}:
7044 If @var{DIM} is absent, the result is a rank-one array with a length
7045 equal to the rank of @var{ARRAY}. If @var{DIM} is present, the result
7046 is an array with a rank one less than the rank of @var{ARRAY}, and a
7047 size corresponding to the size of @var{ARRAY} with the @var{DIM}
7048 dimension removed. If @var{DIM} is present and @var{ARRAY} has a rank
7049 of one, the result is a scalar. In all cases, the result is of default
7050 @code{INTEGER} type.
7052 @item @emph{See also}:
7053 @ref{MIN}, @ref{MINVAL}
7060 @section @code{MINVAL} --- Minimum value of an array
7062 @cindex array, minmum value
7063 @cindex minimum value
7066 @item @emph{Description}:
7067 Determines the minimum value of the elements in an array value, or, if
7068 the @var{DIM} argument is supplied, determines the minimum value along
7069 each row of the array in the @var{DIM} direction. If @var{MASK} is
7070 present, only the elements for which @var{MASK} is @code{.TRUE.} are
7071 considered. If the array has zero size, or all of the elements of
7072 @var{MASK} are @code{.FALSE.}, then the result is @code{HUGE(ARRAY)} if
7073 @var{ARRAY} is numeric, or a string of @code{CHAR(255)} characters if
7074 @var{ARRAY} is of character type.
7076 @item @emph{Standard}:
7080 Transformational function
7082 @item @emph{Syntax}:
7083 @multitable @columnfractions .80
7084 @item @code{RESULT = MINVAL(ARRAY, DIM [, MASK])}
7085 @item @code{RESULT = MINVAL(ARRAY [, MASK])}
7088 @item @emph{Arguments}:
7089 @multitable @columnfractions .15 .70
7090 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER(*)},
7091 @code{REAL(*)}, or @code{CHARACTER(*)}.
7092 @item @var{DIM} @tab (Optional) Shall be a scalar of type
7093 @code{INTEGER(*)}, with a value between one
7094 and the rank of @var{ARRAY}, inclusive. It
7095 may not be an optional dummy argument.
7096 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL(*)},
7097 and conformable with @var{ARRAY}.
7100 @item @emph{Return value}:
7101 If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
7102 is a scalar. If @var{DIM} is present, the result is an array with a
7103 rank one less than the rank of @var{ARRAY}, and a size corresponding to
7104 the size of @var{ARRAY} with the @var{DIM} dimension removed. In all
7105 cases, the result is of the same type and kind as @var{ARRAY}.
7107 @item @emph{See also}:
7108 @ref{MIN}, @ref{MINLOC}
7115 @section @code{MOD} --- Remainder function
7120 @cindex division, remainder
7123 @item @emph{Description}:
7124 @code{MOD(A,P)} computes the remainder of the division of A by P. It is
7125 calculated as @code{A - (INT(A/P) * P)}.
7127 @item @emph{Standard}:
7133 @item @emph{Syntax}:
7134 @code{RESULT = MOD(A, P)}
7136 @item @emph{Arguments}:
7137 @multitable @columnfractions .15 .70
7138 @item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL}
7139 @item @var{P} @tab Shall be a scalar of the same type as @var{A} and not
7143 @item @emph{Return value}:
7144 The kind of the return value is the result of cross-promoting
7145 the kinds of the arguments.
7147 @item @emph{Example}:
7151 print *, mod(17.5,5.5)
7152 print *, mod(17.5d0,5.5)
7153 print *, mod(17.5,5.5d0)
7156 print *, mod(-17.5,5.5)
7157 print *, mod(-17.5d0,5.5)
7158 print *, mod(-17.5,5.5d0)
7161 print *, mod(17.5,-5.5)
7162 print *, mod(17.5d0,-5.5)
7163 print *, mod(17.5,-5.5d0)
7164 end program test_mod
7167 @item @emph{Specific names}:
7168 @multitable @columnfractions .20 .20 .20 .25
7169 @item Name @tab Arguments @tab Return type @tab Standard
7170 @item @code{AMOD(A,P)} @tab @code{REAL(4)} @tab @code{REAL(4)} @tab F95 and later
7171 @item @code{DMOD(A,P)} @tab @code{REAL(8)} @tab @code{REAL(8)} @tab F95 and later
7178 @section @code{MODULO} --- Modulo function
7181 @cindex division, modulo
7184 @item @emph{Description}:
7185 @code{MODULO(A,P)} computes the @var{A} modulo @var{P}.
7187 @item @emph{Standard}:
7193 @item @emph{Syntax}:
7194 @code{RESULT = MODULO(A, P)}
7196 @item @emph{Arguments}:
7197 @multitable @columnfractions .15 .70
7198 @item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL}
7199 @item @var{P} @tab Shall be a scalar of the same type and kind as @var{A}
7202 @item @emph{Return value}:
7203 The type and kind of the result are those of the arguments.
7205 @item If @var{A} and @var{P} are of type @code{INTEGER}:
7206 @code{MODULO(A,P)} has the value @var{R} such that @code{A=Q*P+R}, where
7207 @var{Q} is an integer and @var{R} is between 0 (inclusive) and @var{P}
7209 @item If @var{A} and @var{P} are of type @code{REAL}:
7210 @code{MODULO(A,P)} has the value of @code{A - FLOOR (A / P) * P}.
7212 In all cases, if @var{P} is zero the result is processor-dependent.
7214 @item @emph{Example}:
7217 print *, modulo(17,3)
7218 print *, modulo(17.5,5.5)
7220 print *, modulo(-17,3)
7221 print *, modulo(-17.5,5.5)
7223 print *, modulo(17,-3)
7224 print *, modulo(17.5,-5.5)
7233 @section @code{MOVE_ALLOC} --- Move allocation from one object to another
7235 @cindex moving allocation
7236 @cindex allocation, moving
7239 @item @emph{Description}:
7240 @code{MOVE_ALLOC(SRC, DEST)} moves the allocation from @var{SRC} to
7241 @var{DEST}. @var{SRC} will become deallocated in the process.
7243 @item @emph{Standard}:
7249 @item @emph{Syntax}:
7250 @code{CALL MOVE_ALLOC(SRC, DEST)}
7252 @item @emph{Arguments}:
7253 @multitable @columnfractions .15 .70
7254 @item @var{SRC} @tab @code{ALLOCATABLE}, @code{INTENT(INOUT)}, may be
7255 of any type and kind.
7256 @item @var{DEST} @tab @code{ALLOCATABLE}, @code{INTENT(OUT)}, shall be
7257 of the same type, kind and rank as @var{SRC}
7260 @item @emph{Return value}:
7263 @item @emph{Example}:
7265 program test_move_alloc
7266 integer, allocatable :: a(:), b(:)
7270 call move_alloc(a, b)
7271 print *, allocated(a), allocated(b)
7273 end program test_move_alloc
7280 @section @code{MVBITS} --- Move bits from one integer to another
7285 @item @emph{Description}:
7286 Moves @var{LEN} bits from positions @var{FROMPOS} through
7287 @code{FROMPOS+LEN-1} of @var{FROM} to positions @var{TOPOS} through
7288 @code{TOPOS+LEN-1} of @var{TO}. The portion of argument @var{TO} not
7289 affected by the movement of bits is unchanged. The values of
7290 @code{FROMPOS+LEN-1} and @code{TOPOS+LEN-1} must be less than
7291 @code{BIT_SIZE(FROM)}.
7293 @item @emph{Standard}:
7297 Elemental subroutine
7299 @item @emph{Syntax}:
7300 @code{CALL MVBITS(FROM, FROMPOS, LEN, TO, TOPOS)}
7302 @item @emph{Arguments}:
7303 @multitable @columnfractions .15 .70
7304 @item @var{FROM} @tab The type shall be @code{INTEGER(*)}.
7305 @item @var{FROMPOS} @tab The type shall be @code{INTEGER(*)}.
7306 @item @var{LEN} @tab The type shall be @code{INTEGER(*)}.
7307 @item @var{TO} @tab The type shall be @code{INTEGER(*)}, of the
7308 same kind as @var{FROM}.
7309 @item @var{TOPOS} @tab The type shall be @code{INTEGER(*)}.
7312 @item @emph{See also}:
7313 @ref{IBCLR}, @ref{IBSET}, @ref{IBITS}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
7319 @section @code{NEAREST} --- Nearest representable number
7321 @cindex real number, nearest different
7322 @cindex floating point, nearest different
7325 @item @emph{Description}:
7326 @code{NEAREST(X, S)} returns the processor-representable number nearest
7327 to @code{X} in the direction indicated by the sign of @code{S}.
7329 @item @emph{Standard}:
7335 @item @emph{Syntax}:
7336 @code{RESULT = NEAREST(X, S)}
7338 @item @emph{Arguments}:
7339 @multitable @columnfractions .15 .70
7340 @item @var{X} @tab Shall be of type @code{REAL}.
7341 @item @var{S} @tab (Optional) shall be of type @code{REAL} and
7345 @item @emph{Return value}:
7346 The return value is of the same type as @code{X}. If @code{S} is
7347 positive, @code{NEAREST} returns the processor-representable number
7348 greater than @code{X} and nearest to it. If @code{S} is negative,
7349 @code{NEAREST} returns the processor-representable number smaller than
7350 @code{X} and nearest to it.
7352 @item @emph{Example}:
7354 program test_nearest
7356 x = nearest(42.0, 1.0)
7357 y = nearest(42.0, -1.0)
7358 write (*,"(3(G20.15))") x, y, x - y
7359 end program test_nearest
7366 @section @code{NEW_LINE} --- New line character
7369 @cindex output, newline
7372 @item @emph{Description}:
7373 @code{NEW_LINE(C)} returns the new-line character.
7375 @item @emph{Standard}:
7381 @item @emph{Syntax}:
7382 @code{RESULT = NEW_LINE(C)}
7384 @item @emph{Arguments}:
7385 @multitable @columnfractions .15 .70
7386 @item @var{C} @tab The argument shall be a scalar or array of the
7387 type @code{CHARACTER}.
7390 @item @emph{Return value}:
7391 Returns a @var{CHARACTER} scalar of length one with the new-line character of
7392 the same kind as parameter @var{C}.
7394 @item @emph{Example}:
7398 write(*,'(A)') 'This is record 1.'//NEW_LINE('A')//'This is record 2.'
7406 @section @code{NINT} --- Nearest whole number
7409 @cindex rounding, nearest whole number
7412 @item @emph{Description}:
7413 @code{NINT(X)} rounds its argument to the nearest whole number.
7415 @item @emph{Standard}:
7421 @item @emph{Syntax}:
7422 @code{RESULT = NINT(X)}
7424 @item @emph{Arguments}:
7425 @multitable @columnfractions .15 .70
7426 @item @var{X} @tab The type of the argument shall be @code{REAL}.
7429 @item @emph{Return value}:
7430 Returns @var{A} with the fractional portion of its magnitude eliminated by
7431 rounding to the nearest whole number and with its sign preserved,
7432 converted to an @code{INTEGER} of the default kind.
7434 @item @emph{Example}:
7441 print *, nint(x4), idnint(x8)
7442 end program test_nint
7445 @item @emph{Specific names}:
7446 @multitable @columnfractions .25 .25 .25
7447 @item Name @tab Argument @tab Standard
7448 @item @code{IDNINT(X)} @tab @code{REAL(8)} @tab F95 and later
7451 @item @emph{See also}:
7452 @ref{CEILING}, @ref{FLOOR}
7459 @section @code{NOT} --- Logical negation
7461 @cindex bits, negate
7462 @cindex bitwise logical not
7463 @cindex logical not, bitwise
7466 @item @emph{Description}:
7467 @code{NOT} returns the bitwise boolean inverse of @var{I}.
7469 @item @emph{Standard}:
7475 @item @emph{Syntax}:
7476 @code{RESULT = NOT(I)}
7478 @item @emph{Arguments}:
7479 @multitable @columnfractions .15 .70
7480 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
7483 @item @emph{Return value}:
7484 The return type is @code{INTEGER(*)}, of the same kind as the
7487 @item @emph{See also}:
7488 @ref{IAND}, @ref{IEOR}, @ref{IOR}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}
7495 @section @code{NULL} --- Function that returns an disassociated pointer
7497 @cindex pointer, status
7498 @cindex pointer, disassociated
7501 @item @emph{Description}:
7502 Returns a disassociated pointer.
7504 If @var{MOLD} is present, a dissassociated pointer of the same type is
7505 returned, otherwise the type is determined by context.
7507 In Fortran 95, @var{MOLD} is optional. Please note that F2003 includes
7508 cases where it is required.
7510 @item @emph{Standard}:
7514 Transformational function
7516 @item @emph{Syntax}:
7517 @code{PTR => NULL([MOLD])}
7519 @item @emph{Arguments}:
7520 @multitable @columnfractions .15 .70
7521 @item @var{MOLD} @tab (Optional) shall be a pointer of any association
7522 status and of any type.
7525 @item @emph{Return value}:
7526 A disassociated pointer.
7528 @item @emph{Example}:
7530 REAL, POINTER, DIMENSION(:) :: VEC => NULL ()
7533 @item @emph{See also}:
7540 @section @code{OR} --- Bitwise logical OR
7542 @cindex bitwise logical or
7543 @cindex logical or, bitwise
7546 @item @emph{Description}:
7547 Bitwise logical @code{OR}.
7549 This intrinsic routine is provided for backwards compatibility with
7550 GNU Fortran 77. For integer arguments, programmers should consider
7551 the use of the @ref{IOR} intrinsic defined by the Fortran standard.
7553 @item @emph{Standard}:
7557 Non-elemental function
7559 @item @emph{Syntax}:
7560 @code{RESULT = OR(X, Y)}
7562 @item @emph{Arguments}:
7563 @multitable @columnfractions .15 .70
7564 @item @var{X} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
7565 @item @var{Y} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
7568 @item @emph{Return value}:
7569 The return type is either @code{INTEGER(*)} or @code{LOGICAL}
7570 after cross-promotion of the arguments.
7572 @item @emph{Example}:
7575 LOGICAL :: T = .TRUE., F = .FALSE.
7577 DATA a / Z'F' /, b / Z'3' /
7579 WRITE (*,*) OR(T, T), OR(T, F), OR(F, T), OR(F, F)
7580 WRITE (*,*) OR(a, b)
7584 @item @emph{See also}:
7585 F95 elemental function: @ref{IOR}
7591 @section @code{PACK} --- Pack an array into an array of rank one
7593 @cindex array, packing
7594 @cindex array, reduce dimension
7595 @cindex array, gather elements
7598 @item @emph{Description}:
7599 Stores the elements of @var{ARRAY} in an array of rank one.
7601 The beginning of the resulting array is made up of elements whose @var{MASK}
7602 equals @code{TRUE}. Afterwards, positions are filled with elements taken from
7605 @item @emph{Standard}:
7609 Transformational function
7611 @item @emph{Syntax}:
7612 @code{RESULT = PACK(ARRAY, MASK[,VECTOR]}
7614 @item @emph{Arguments}:
7615 @multitable @columnfractions .15 .70
7616 @item @var{ARRAY} @tab Shall be an array of any type.
7617 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL} and
7618 of the same size as @var{ARRAY}. Alternatively, it may be a @code{LOGICAL}
7620 @item @var{VECTOR} @tab (Optional) shall be an array of the same type
7621 as @var{ARRAY} and of rank one. If present, the number of elements in
7622 @var{VECTOR} shall be equal to or greater than the number of true elements
7623 in @var{MASK}. If @var{MASK} is scalar, the number of elements in
7624 @var{VECTOR} shall be equal to or greater than the number of elements in
7628 @item @emph{Return value}:
7629 The result is an array of rank one and the same type as that of @var{ARRAY}.
7630 If @var{VECTOR} is present, the result size is that of @var{VECTOR}, the
7631 number of @code{TRUE} values in @var{MASK} otherwise.
7633 @item @emph{Example}:
7634 Gathering non-zero elements from an array:
7638 m = (/ 1, 0, 0, 0, 5, 0 /)
7639 WRITE(*, FMT="(6(I0, ' '))") pack(m, m /= 0) ! "1 5"
7643 Gathering non-zero elements from an array and appending elements from @var{VECTOR}:
7647 m = (/ 1, 0, 0, 2 /)
7648 WRITE(*, FMT="(4(I0, ' '))") pack(m, m /= 0, (/ 0, 0, 3, 4 /)) ! "1 2 3 4"
7652 @item @emph{See also}:
7659 @section @code{PERROR} --- Print system error message
7661 @cindex system, error handling
7664 @item @emph{Description}:
7665 Prints (on the C @code{stderr} stream) a newline-terminated error
7666 message corresponding to the last system error. This is prefixed by
7667 @var{STRING}, a colon and a space. See @code{perror(3)}.
7669 @item @emph{Standard}:
7675 @item @emph{Syntax}:
7676 @code{CALL PERROR(STRING)}
7678 @item @emph{Arguments}:
7679 @multitable @columnfractions .15 .70
7680 @item @var{STRING} @tab A scalar of default @code{CHARACTER} type.
7683 @item @emph{See also}:
7690 @section @code{PRECISION} --- Decimal precision of a real kind
7692 @cindex model representation, precision
7695 @item @emph{Description}:
7696 @code{PRECISION(X)} returns the decimal precision in the model of the
7699 @item @emph{Standard}:
7705 @item @emph{Syntax}:
7706 @code{RESULT = PRECISION(X)}
7708 @item @emph{Arguments}:
7709 @multitable @columnfractions .15 .70
7710 @item @var{X} @tab Shall be of type @code{REAL} or @code{COMPLEX}.
7713 @item @emph{Return value}:
7714 The return value is of type @code{INTEGER} and of the default integer
7717 @item @emph{Example}:
7719 program prec_and_range
7720 real(kind=4) :: x(2)
7721 complex(kind=8) :: y
7723 print *, precision(x), range(x)
7724 print *, precision(y), range(y)
7725 end program prec_and_range
7732 @section @code{PRESENT} --- Determine whether an optional dummy argument is specified
7736 @item @emph{Description}:
7737 Determines whether an optional dummy argument is present.
7739 @item @emph{Standard}:
7745 @item @emph{Syntax}:
7746 @code{RESULT = PRESENT(A)}
7748 @item @emph{Arguments}:
7749 @multitable @columnfractions .15 .70
7750 @item @var{A} @tab May be of any type and may be a pointer, scalar or array
7751 value, or a dummy procedure. It shall be the name of an optional dummy argument
7752 accessible within the current subroutine or function.
7755 @item @emph{Return value}:
7756 Returns either @code{TRUE} if the optional argument @var{A} is present, or
7757 @code{FALSE} otherwise.
7759 @item @emph{Example}:
7761 PROGRAM test_present
7762 WRITE(*,*) f(), f(42) ! "F T"
7764 LOGICAL FUNCTION f(x)
7765 INTEGER, INTENT(IN), OPTIONAL :: x
7775 @section @code{PRODUCT} --- Product of array elements
7777 @cindex array, product
7778 @cindex array, multiply elements
7779 @cindex array, conditionally multiply elements
7780 @cindex multiply array elements
7783 @item @emph{Description}:
7784 Multiplies the elements of @var{ARRAY} along dimension @var{DIM} if
7785 the corresponding element in @var{MASK} is @code{TRUE}.
7787 @item @emph{Standard}:
7791 Transformational function
7793 @item @emph{Syntax}:
7794 @code{RESULT = PRODUCT(ARRAY[, MASK])}
7795 @code{RESULT = PRODUCT(ARRAY, DIM[, MASK])}
7797 @item @emph{Arguments}:
7798 @multitable @columnfractions .15 .70
7799 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER(*)},
7800 @code{REAL(*)} or @code{COMPLEX(*)}.
7801 @item @var{DIM} @tab (Optional) shall be a scalar of type
7802 @code{INTEGER} with a value in the range from 1 to n, where n
7803 equals the rank of @var{ARRAY}.
7804 @item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL}
7805 and either be a scalar or an array of the same shape as @var{ARRAY}.
7808 @item @emph{Return value}:
7809 The result is of the same type as @var{ARRAY}.
7811 If @var{DIM} is absent, a scalar with the product of all elements in
7812 @var{ARRAY} is returned. Otherwise, an array of rank n-1, where n equals
7813 the rank of @var{ARRAY}, and a shape similar to that of @var{ARRAY} with
7814 dimension @var{DIM} dropped is returned.
7817 @item @emph{Example}:
7819 PROGRAM test_product
7820 INTEGER :: x(5) = (/ 1, 2, 3, 4 ,5 /)
7821 print *, PRODUCT(x) ! all elements, product = 120
7822 print *, PRODUCT(x, MASK=MOD(x, 2)==1) ! odd elements, product = 15
7826 @item @emph{See also}:
7833 @section @code{RADIX} --- Base of a model number
7835 @cindex model representation, base
7836 @cindex model representation, radix
7839 @item @emph{Description}:
7840 @code{RADIX(X)} returns the base of the model representing the entity @var{X}.
7842 @item @emph{Standard}:
7848 @item @emph{Syntax}:
7849 @code{RESULT = RADIX(X)}
7851 @item @emph{Arguments}:
7852 @multitable @columnfractions .15 .70
7853 @item @var{X} @tab Shall be of type @code{INTEGER} or @code{REAL}
7856 @item @emph{Return value}:
7857 The return value is a scalar of type @code{INTEGER} and of the default
7860 @item @emph{Example}:
7863 print *, "The radix for the default integer kind is", radix(0)
7864 print *, "The radix for the default real kind is", radix(0.0)
7865 end program test_radix
7873 @section @code{RAN} --- Real pseudo-random number
7875 @cindex random number generation
7878 @item @emph{Description}:
7879 For compatibility with HP FORTRAN 77/iX, the @code{RAN} intrinsic is
7880 provided as an alias for @code{RAND}. See @ref{RAND} for complete
7883 @item @emph{Standard}:
7887 Non-elemental function
7889 @item @emph{See also}:
7890 @ref{RAND}, @ref{RANDOM_NUMBER}
7896 @section @code{RAND} --- Real pseudo-random number
7898 @cindex random number generation
7901 @item @emph{Description}:
7902 @code{RAND(FLAG)} returns a pseudo-random number from a uniform
7903 distribution between 0 and 1. If @var{FLAG} is 0, the next number
7904 in the current sequence is returned; if @var{FLAG} is 1, the generator
7905 is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
7906 it is used as a new seed with @code{SRAND}.
7908 @item @emph{Standard}:
7912 Non-elemental function
7914 @item @emph{Syntax}:
7915 @code{RESULT = RAND(FLAG)}
7917 @item @emph{Arguments}:
7918 @multitable @columnfractions .15 .70
7919 @item @var{FLAG} @tab Shall be a scalar @code{INTEGER} of kind 4.
7922 @item @emph{Return value}:
7923 The return value is of @code{REAL} type and the default kind.
7925 @item @emph{Example}:
7928 integer,parameter :: seed = 86456
7931 print *, rand(), rand(), rand(), rand()
7932 print *, rand(seed), rand(), rand(), rand()
7933 end program test_rand
7936 @item @emph{See also}:
7937 @ref{SRAND}, @ref{RANDOM_NUMBER}
7944 @section @code{RANDOM_NUMBER} --- Pseudo-random number
7945 @fnindex RANDOM_NUMBER
7946 @cindex random number generation
7949 @item @emph{Description}:
7950 Returns a single pseudorandom number or an array of pseudorandom numbers
7951 from the uniform distribution over the range @math{ 0 \leq x < 1}.
7953 @item @emph{Standard}:
7959 @item @emph{Syntax}:
7960 @code{RANDOM_NUMBER(HARVEST)}
7962 @item @emph{Arguments}:
7963 @multitable @columnfractions .15 .70
7964 @item @var{HARVEST} @tab Shall be a scalar or an array of type @code{REAL(*)}.
7967 @item @emph{Example}:
7969 program test_random_number
7971 CALL init_random_seed() ! see example of RANDOM_SEED
7972 CALL RANDOM_NUMBER(r)
7977 The implemented random number generator is thread safe if used within
7978 OpenMP directives, i. e. its state will be consistent while called from
7979 multiple threads. Please note that the currently implemented KISS generator
7980 does not create random numbers in parallel from multiple sources, but in
7981 sequence from a single source. If your OpenMP-enabled application heavily
7982 relies on random numbers, you should consider employing a dedicated parallel
7983 random number generator instead.
7985 @item @emph{See also}:
7992 @section @code{RANDOM_SEED} --- Initialize a pseudo-random number sequence
7993 @fnindex RANDOM_SEED
7994 @cindex random number generation, seeding
7995 @cindex seeding a random number generator
7998 @item @emph{Description}:
7999 Restarts or queries the state of the pseudorandom number generator used by
8000 @code{RANDOM_NUMBER}.
8002 If @code{RANDOM_SEED} is called without arguments, it is initialized to
8003 a default state. The example below shows how to initialize the random
8004 seed based on the system's time.
8006 @item @emph{Standard}:
8012 @item @emph{Syntax}:
8013 @code{CALL RANDOM_SEED(SIZE, PUT, GET)}
8015 @item @emph{Arguments}:
8016 @multitable @columnfractions .15 .70
8017 @item @var{SIZE} @tab (Optional) Shall be a scalar and of type default
8018 @code{INTEGER}, with @code{INTENT(OUT)}. It specifies the minimum size
8019 of the arrays used with the @var{PUT} and @var{GET} arguments.
8020 @item @var{PUT} @tab (Optional) Shall be an array of type default
8021 @code{INTEGER} and rank one. It is @code{INTENT(IN)} and the size of
8022 the array must be larger than or equal to the number returned by the
8023 @var{SIZE} argument.
8024 @item @var{GET} @tab (Optional) Shall be an array of type default
8025 @code{INTEGER} and rank one. It is @code{INTENT(OUT)} and the size
8026 of the array must be larger than or equal to the number returned by
8027 the @var{SIZE} argument.
8030 @item @emph{Example}:
8032 SUBROUTINE init_random_seed()
8033 INTEGER :: i, n, clock
8034 INTEGER, DIMENSION(:), ALLOCATABLE :: seed
8036 CALL RANDOM_SEED(size = n)
8039 CALL SYSTEM_CLOCK(COUNT=clock)
8041 seed = clock + 37 * (/ (i - 1, i = 1, n) /)
8042 CALL RANDOM_SEED(PUT = seed)
8048 @item @emph{See also}:
8055 @section @code{RANGE} --- Decimal exponent range of a real kind
8057 @cindex model representation, range
8060 @item @emph{Description}:
8061 @code{RANGE(X)} returns the decimal exponent range in the model of the
8064 @item @emph{Standard}:
8070 @item @emph{Syntax}:
8071 @code{RESULT = RANGE(X)}
8073 @item @emph{Arguments}:
8074 @multitable @columnfractions .15 .70
8075 @item @var{X} @tab Shall be of type @code{REAL} or @code{COMPLEX}.
8078 @item @emph{Return value}:
8079 The return value is of type @code{INTEGER} and of the default integer
8082 @item @emph{Example}:
8083 See @code{PRECISION} for an example.
8089 @section @code{REAL} --- Convert to real type
8092 @cindex conversion, to real
8093 @cindex complex numbers, real part
8096 @item @emph{Description}:
8097 @code{REAL(X [, KIND])} converts its argument @var{X} to a real type. The
8098 @code{REALPART(X)} function is provided for compatibility with @command{g77},
8099 and its use is strongly discouraged.
8101 @item @emph{Standard}:
8107 @item @emph{Syntax}:
8108 @multitable @columnfractions .80
8109 @item @code{RESULT = REAL(X [, KIND])}
8110 @item @code{RESULT = REALPART(Z)}
8113 @item @emph{Arguments}:
8114 @multitable @columnfractions .15 .70
8115 @item @var{X} @tab Shall be @code{INTEGER(*)}, @code{REAL(*)}, or
8117 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
8118 expression indicating the kind parameter of
8122 @item @emph{Return value}:
8123 These functions return a @code{REAL(*)} variable or array under
8124 the following rules:
8128 @code{REAL(X)} is converted to a default real type if @var{X} is an
8129 integer or real variable.
8131 @code{REAL(X)} is converted to a real type with the kind type parameter
8132 of @var{X} if @var{X} is a complex variable.
8134 @code{REAL(X, KIND)} is converted to a real type with kind type
8135 parameter @var{KIND} if @var{X} is a complex, integer, or real
8139 @item @emph{Example}:
8142 complex :: x = (1.0, 2.0)
8143 print *, real(x), real(x,8), realpart(x)
8144 end program test_real
8147 @item @emph{See also}:
8148 @ref{DBLE}, @ref{DFLOAT}, @ref{FLOAT}
8155 @section @code{RENAME} --- Rename a file
8157 @cindex file system, rename file
8160 @item @emph{Description}:
8161 Renames a file from file @var{PATH1} to @var{PATH2}. A null
8162 character (@code{CHAR(0)}) can be used to mark the end of the names in
8163 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
8164 names are ignored. If the @var{STATUS} argument is supplied, it
8165 contains 0 on success or a nonzero error code upon return; see
8168 This intrinsic is provided in both subroutine and function forms;
8169 however, only one form can be used in any given program unit.
8171 @item @emph{Standard}:
8175 Subroutine, non-elemental function
8177 @item @emph{Syntax}:
8178 @multitable @columnfractions .80
8179 @item @code{CALL RENAME(PATH1, PATH2 [, STATUS])}
8180 @item @code{STATUS = RENAME(PATH1, PATH2)}
8183 @item @emph{Arguments}:
8184 @multitable @columnfractions .15 .70
8185 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
8186 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
8187 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
8190 @item @emph{See also}:
8198 @section @code{REPEAT} --- Repeated string concatenation
8200 @cindex string, repeat
8201 @cindex string, concatenate
8204 @item @emph{Description}:
8205 Concatenates @var{NCOPIES} copies of a string.
8207 @item @emph{Standard}:
8211 Transformational function
8213 @item @emph{Syntax}:
8214 @code{RESULT = REPEAT(STRING, NCOPIES)}
8216 @item @emph{Arguments}:
8217 @multitable @columnfractions .15 .70
8218 @item @var{STRING} @tab Shall be scalar and of type @code{CHARACTER(*)}.
8219 @item @var{NCOPIES} @tab Shall be scalar and of type @code{INTEGER(*)}.
8222 @item @emph{Return value}:
8223 A new scalar of type @code{CHARACTER} built up from @var{NCOPIES} copies
8226 @item @emph{Example}:
8229 write(*,*) repeat("x", 5) ! "xxxxx"
8237 @section @code{RESHAPE} --- Function to reshape an array
8239 @cindex array, change dimensions
8240 @cindex array, transmogrify
8243 @item @emph{Description}:
8244 Reshapes @var{SOURCE} to correspond to @var{SHAPE}. If necessary,
8245 the new array may be padded with elements from @var{PAD} or permuted
8246 as defined by @var{ORDER}.
8248 @item @emph{Standard}:
8252 Transformational function
8254 @item @emph{Syntax}:
8255 @code{RESULT = RESHAPE(SOURCE, SHAPE[, PAD, ORDER])}
8257 @item @emph{Arguments}:
8258 @multitable @columnfractions .15 .70
8259 @item @var{SOURCE} @tab Shall be an array of any type.
8260 @item @var{SHAPE} @tab Shall be of type @code{INTEGER} and an
8261 array of rank one. Its values must be positive or zero.
8262 @item @var{PAD} @tab (Optional) shall be an array of the same
8263 type as @var{SOURCE}.
8264 @item @var{ORDER} @tab (Optional) shall be of type @code{INTEGER}
8265 and an array of the same shape as @var{SHAPE}. Its values shall
8266 be a permutation of the numbers from 1 to n, where n is the size of
8267 @var{SHAPE}. If @var{ORDER} is absent, the natural ordering shall
8271 @item @emph{Return value}:
8272 The result is an array of shape @var{SHAPE} with the same type as
8275 @item @emph{Example}:
8277 PROGRAM test_reshape
8278 INTEGER, DIMENSION(4) :: x
8279 WRITE(*,*) SHAPE(x) ! prints "4"
8280 WRITE(*,*) SHAPE(RESHAPE(x, (/2, 2/))) ! prints "2 2"
8284 @item @emph{See also}:
8291 @section @code{RRSPACING} --- Reciprocal of the relative spacing
8293 @cindex real number, relative spacing
8294 @cindex floating point, relative spacing
8298 @item @emph{Description}:
8299 @code{RRSPACING(X)} returns the reciprocal of the relative spacing of
8300 model numbers near @var{X}.
8302 @item @emph{Standard}:
8308 @item @emph{Syntax}:
8309 @code{RESULT = RRSPACING(X)}
8311 @item @emph{Arguments}:
8312 @multitable @columnfractions .15 .70
8313 @item @var{X} @tab Shall be of type @code{REAL}.
8316 @item @emph{Return value}:
8317 The return value is of the same type and kind as @var{X}.
8318 The value returned is equal to
8319 @code{ABS(FRACTION(X)) * FLOAT(RADIX(X))**DIGITS(X)}.
8321 @item @emph{See also}:
8328 @section @code{RSHIFT} --- Right shift bits
8330 @cindex bits, shift right
8333 @item @emph{Description}:
8334 @code{RSHIFT} returns a value corresponding to @var{I} with all of the
8335 bits shifted right by @var{SHIFT} places. If the absolute value of
8336 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
8337 Bits shifted out from the left end are lost; zeros are shifted in from
8340 This function has been superseded by the @code{ISHFT} intrinsic, which
8341 is standard in Fortran 95 and later.
8343 @item @emph{Standard}:
8349 @item @emph{Syntax}:
8350 @code{RESULT = RSHIFT(I, SHIFT)}
8352 @item @emph{Arguments}:
8353 @multitable @columnfractions .15 .70
8354 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
8355 @item @var{SHIFT} @tab The type shall be @code{INTEGER(*)}.
8358 @item @emph{Return value}:
8359 The return value is of type @code{INTEGER(*)} and of the same kind as
8362 @item @emph{See also}:
8363 @ref{ISHFT}, @ref{ISHFTC}, @ref{LSHIFT}
8370 @section @code{SCALE} --- Scale a real value
8372 @cindex real number, scale
8373 @cindex floating point, scale
8376 @item @emph{Description}:
8377 @code{SCALE(X,I)} returns @code{X * RADIX(X)**I}.
8379 @item @emph{Standard}:
8385 @item @emph{Syntax}:
8386 @code{RESULT = SCALE(X, I)}
8388 @item @emph{Arguments}:
8389 @multitable @columnfractions .15 .70
8390 @item @var{X} @tab The type of the argument shall be a @code{REAL}.
8391 @item @var{I} @tab The type of the argument shall be a @code{INTEGER}.
8394 @item @emph{Return value}:
8395 The return value is of the same type and kind as @var{X}.
8396 Its value is @code{X * RADIX(X)**I}.
8398 @item @emph{Example}:
8401 real :: x = 178.1387e-4
8403 print *, scale(x,i), x*radix(x)**i
8404 end program test_scale
8412 @section @code{SCAN} --- Scan a string for the presence of a set of characters
8414 @cindex string, find subset
8417 @item @emph{Description}:
8418 Scans a @var{STRING} for any of the characters in a @var{SET}
8421 If @var{BACK} is either absent or equals @code{FALSE}, this function
8422 returns the position of the leftmost character of @var{STRING} that is
8423 in @var{SET}. If @var{BACK} equals @code{TRUE}, the rightmost position
8424 is returned. If no character of @var{SET} is found in @var{STRING}, the
8427 @item @emph{Standard}:
8433 @item @emph{Syntax}:
8434 @code{RESULT = SCAN(STRING, SET[, BACK])}
8436 @item @emph{Arguments}:
8437 @multitable @columnfractions .15 .70
8438 @item @var{STRING} @tab Shall be of type @code{CHARACTER(*)}.
8439 @item @var{SET} @tab Shall be of type @code{CHARACTER(*)}.
8440 @item @var{BACK} @tab (Optional) shall be of type @code{LOGICAL}.
8443 @item @emph{Return value}:
8444 The return value is of type @code{INTEGER} and of the default
8447 @item @emph{Example}:
8450 WRITE(*,*) SCAN("FORTRAN", "AO") ! 2, found 'O'
8451 WRITE(*,*) SCAN("FORTRAN", "AO", .TRUE.) ! 6, found 'A'
8452 WRITE(*,*) SCAN("FORTRAN", "C++") ! 0, found none
8456 @item @emph{See also}:
8457 @ref{INDEX}, @ref{VERIFY}
8463 @section @code{SECNDS} --- Time function
8465 @cindex time, elapsed
8466 @cindex elapsed time
8469 @item @emph{Description}:
8470 @code{SECNDS(X)} gets the time in seconds from the real-time system clock.
8471 @var{X} is a reference time, also in seconds. If this is zero, the time in
8472 seconds from midnight is returned. This function is non-standard and its
8475 @item @emph{Standard}:
8479 Non-elemental function
8481 @item @emph{Syntax}:
8482 @code{RESULT = SECNDS (X)}
8484 @item @emph{Arguments}:
8485 @multitable @columnfractions .15 .70
8486 @item @var{T} @tab Shall be of type @code{REAL(4)}.
8487 @item @var{X} @tab Shall be of type @code{REAL(4)}.
8490 @item @emph{Return value}:
8493 @item @emph{Example}:
8498 print *, secnds (0.0) ! seconds since midnight
8499 t1 = secnds (0.0) ! reference time
8500 do i = 1, 10000000 ! do something
8502 t2 = secnds (t1) ! elapsed time
8503 print *, "Something took ", t2, " seconds."
8504 end program test_secnds
8511 @section @code{SECOND} --- CPU time function
8513 @cindex time, elapsed
8514 @cindex elapsed time
8517 @item @emph{Description}:
8518 Returns a @code{REAL(4)} value representing the elapsed CPU time in
8519 seconds. This provides the same functionality as the standard
8520 @code{CPU_TIME} intrinsic, and is only included for backwards
8523 This intrinsic is provided in both subroutine and function forms;
8524 however, only one form can be used in any given program unit.
8526 @item @emph{Standard}:
8530 Subroutine, non-elemental function
8532 @item @emph{Syntax}:
8533 @multitable @columnfractions .80
8534 @item @code{CALL SECOND(TIME)}
8535 @item @code{TIME = SECOND()}
8538 @item @emph{Arguments}:
8539 @multitable @columnfractions .15 .70
8540 @item @var{TIME} @tab Shall be of type @code{REAL(4)}.
8543 @item @emph{Return value}:
8544 In either syntax, @var{TIME} is set to the process's current runtime in
8547 @item @emph{See also}:
8554 @node SELECTED_INT_KIND
8555 @section @code{SELECTED_INT_KIND} --- Choose integer kind
8556 @fnindex SELECTED_INT_KIND
8557 @cindex integer kind
8558 @cindex kind, integer
8561 @item @emph{Description}:
8562 @code{SELECTED_INT_KIND(I)} return the kind value of the smallest integer
8563 type that can represent all values ranging from @math{-10^I} (exclusive)
8564 to @math{10^I} (exclusive). If there is no integer kind that accommodates
8565 this range, @code{SELECTED_INT_KIND} returns @math{-1}.
8567 @item @emph{Standard}:
8571 Transformational function
8573 @item @emph{Syntax}:
8574 @code{RESULT = SELECTED_INT_KIND(I)}
8576 @item @emph{Arguments}:
8577 @multitable @columnfractions .15 .70
8578 @item @var{I} @tab Shall be a scalar and of type @code{INTEGER}.
8581 @item @emph{Example}:
8583 program large_integers
8584 integer,parameter :: k5 = selected_int_kind(5)
8585 integer,parameter :: k15 = selected_int_kind(15)
8586 integer(kind=k5) :: i5
8587 integer(kind=k15) :: i15
8589 print *, huge(i5), huge(i15)
8591 ! The following inequalities are always true
8592 print *, huge(i5) >= 10_k5**5-1
8593 print *, huge(i15) >= 10_k15**15-1
8594 end program large_integers
8600 @node SELECTED_REAL_KIND
8601 @section @code{SELECTED_REAL_KIND} --- Choose real kind
8602 @fnindex SELECTED_REAL_KIND
8607 @item @emph{Description}:
8608 @code{SELECTED_REAL_KIND(P,R)} return the kind value of a real data type
8609 with decimal precision greater of at least @code{P} digits and exponent
8610 range greater at least @code{R}.
8612 @item @emph{Standard}:
8616 Transformational function
8618 @item @emph{Syntax}:
8619 @code{RESULT = SELECTED_REAL_KIND(P, R)}
8621 @item @emph{Arguments}:
8622 @multitable @columnfractions .15 .70
8623 @item @var{P} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
8624 @item @var{R} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
8626 At least one argument shall be present.
8628 @item @emph{Return value}:
8630 @code{SELECTED_REAL_KIND} returns the value of the kind type parameter of
8631 a real data type with decimal precision of at least @code{P} digits and a
8632 decimal exponent range of at least @code{R}. If more than one real data
8633 type meet the criteria, the kind of the data type with the smallest
8634 decimal precision is returned. If no real data type matches the criteria,
8637 @item -1 if the processor does not support a real data type with a
8638 precision greater than or equal to @code{P}
8639 @item -2 if the processor does not support a real type with an exponent
8640 range greater than or equal to @code{R}
8641 @item -3 if neither is supported.
8644 @item @emph{Example}:
8647 integer,parameter :: p6 = selected_real_kind(6)
8648 integer,parameter :: p10r100 = selected_real_kind(10,100)
8649 integer,parameter :: r400 = selected_real_kind(r=400)
8651 real(kind=p10r100) :: y
8652 real(kind=r400) :: z
8654 print *, precision(x), range(x)
8655 print *, precision(y), range(y)
8656 print *, precision(z), range(z)
8657 end program real_kinds
8664 @section @code{SET_EXPONENT} --- Set the exponent of the model
8665 @fnindex SET_EXPONENT
8666 @cindex real number, set exponent
8667 @cindex floating point, set exponent
8670 @item @emph{Description}:
8671 @code{SET_EXPONENT(X, I)} returns the real number whose fractional part
8672 is that that of @var{X} and whose exponent part is @var{I}.
8674 @item @emph{Standard}:
8680 @item @emph{Syntax}:
8681 @code{RESULT = SET_EXPONENT(X, I)}
8683 @item @emph{Arguments}:
8684 @multitable @columnfractions .15 .70
8685 @item @var{X} @tab Shall be of type @code{REAL}.
8686 @item @var{I} @tab Shall be of type @code{INTEGER}.
8689 @item @emph{Return value}:
8690 The return value is of the same type and kind as @var{X}.
8691 The real number whose fractional part
8692 is that that of @var{X} and whose exponent part if @var{I} is returned;
8693 it is @code{FRACTION(X) * RADIX(X)**I}.
8695 @item @emph{Example}:
8698 REAL :: x = 178.1387e-4
8700 PRINT *, SET_EXPONENT(x, i), FRACTION(x) * RADIX(x)**i
8709 @section @code{SHAPE} --- Determine the shape of an array
8711 @cindex array, shape
8714 @item @emph{Description}:
8715 Determines the shape of an array.
8717 @item @emph{Standard}:
8723 @item @emph{Syntax}:
8724 @code{RESULT = SHAPE(SOURCE)}
8726 @item @emph{Arguments}:
8727 @multitable @columnfractions .15 .70
8728 @item @var{SOURCE} @tab Shall be an array or scalar of any type.
8729 If @var{SOURCE} is a pointer it must be associated and allocatable
8730 arrays must be allocated.
8733 @item @emph{Return value}:
8734 An @code{INTEGER} array of rank one with as many elements as @var{SOURCE}
8735 has dimensions. The elements of the resulting array correspond to the extend
8736 of @var{SOURCE} along the respective dimensions. If @var{SOURCE} is a scalar,
8737 the result is the rank one array of size zero.
8739 @item @emph{Example}:
8742 INTEGER, DIMENSION(-1:1, -1:2) :: A
8743 WRITE(*,*) SHAPE(A) ! (/ 3, 4 /)
8744 WRITE(*,*) SIZE(SHAPE(42)) ! (/ /)
8748 @item @emph{See also}:
8749 @ref{RESHAPE}, @ref{SIZE}
8755 @section @code{SIGN} --- Sign copying function
8759 @cindex sign copying
8762 @item @emph{Description}:
8763 @code{SIGN(A,B)} returns the value of @var{A} with the sign of @var{B}.
8765 @item @emph{Standard}:
8771 @item @emph{Syntax}:
8772 @code{RESULT = SIGN(A, B)}
8774 @item @emph{Arguments}:
8775 @multitable @columnfractions .15 .70
8776 @item @var{A} @tab Shall be of type @code{INTEGER} or @code{REAL}
8777 @item @var{B} @tab Shall be of the same type and kind as @var{A}
8780 @item @emph{Return value}:
8781 The kind of the return value is that of @var{A} and @var{B}.
8782 If @math{B\ge 0} then the result is @code{ABS(A)}, else
8783 it is @code{-ABS(A)}.
8785 @item @emph{Example}:
8788 print *, sign(-12,1)
8789 print *, sign(-12,0)
8790 print *, sign(-12,-1)
8792 print *, sign(-12.,1.)
8793 print *, sign(-12.,0.)
8794 print *, sign(-12.,-1.)
8795 end program test_sign
8798 @item @emph{Specific names}:
8799 @multitable @columnfractions .20 .20 .20 .25
8800 @item Name @tab Arguments @tab Return type @tab Standard
8801 @item @code{ISIGN(A,P)} @tab @code{INTEGER(4)} @tab @code{INTEGER(4)} @tab f95, gnu
8802 @item @code{DSIGN(A,P)} @tab @code{REAL(8)} @tab @code{REAL(8)} @tab f95, gnu
8809 @section @code{SIGNAL} --- Signal handling subroutine (or function)
8811 @cindex system, signal handling
8814 @item @emph{Description}:
8815 @code{SIGNAL(NUMBER, HANDLER [, STATUS])} causes external subroutine
8816 @var{HANDLER} to be executed with a single integer argument when signal
8817 @var{NUMBER} occurs. If @var{HANDLER} is an integer, it can be used to
8818 turn off handling of signal @var{NUMBER} or revert to its default
8819 action. See @code{signal(2)}.
8821 If @code{SIGNAL} is called as a subroutine and the @var{STATUS} argument
8822 is supplied, it is set to the value returned by @code{signal(2)}.
8824 @item @emph{Standard}:
8828 Subroutine, non-elemental function
8830 @item @emph{Syntax}:
8831 @multitable @columnfractions .80
8832 @item @code{CALL SIGNAL(NUMBER, HANDLER [, STATUS])}
8833 @item @code{STATUS = SIGNAL(NUMBER, HANDLER)}
8836 @item @emph{Arguments}:
8837 @multitable @columnfractions .15 .70
8838 @item @var{NUMBER} @tab Shall be a scalar integer, with @code{INTENT(IN)}
8839 @item @var{HANDLER}@tab Signal handler (@code{INTEGER FUNCTION} or
8840 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar.
8841 @code{INTEGER}. It is @code{INTENT(IN)}.
8842 @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
8843 integer. It has @code{INTENT(OUT)}.
8846 @item @emph{Return value}:
8847 The @code{SIGNAL} function returns the value returned by @code{signal(2)}.
8849 @item @emph{Example}:
8853 external handler_print
8855 call signal (12, handler_print)
8859 end program test_signal
8866 @section @code{SIN} --- Sine function
8872 @cindex trigonometric function, sine
8876 @item @emph{Description}:
8877 @code{SIN(X)} computes the sine of @var{X}.
8879 @item @emph{Standard}:
8885 @item @emph{Syntax}:
8886 @code{RESULT = SIN(X)}
8888 @item @emph{Arguments}:
8889 @multitable @columnfractions .15 .70
8890 @item @var{X} @tab The type shall be @code{REAL(*)} or
8894 @item @emph{Return value}:
8895 The return value has same type and kind as @var{X}.
8897 @item @emph{Example}:
8902 end program test_sin
8905 @item @emph{Specific names}:
8906 @multitable @columnfractions .20 .20 .20 .25
8907 @item Name @tab Argument @tab Return type @tab Standard
8908 @item @code{DSIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
8909 @item @code{CSIN(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab f95, gnu
8910 @item @code{ZSIN(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
8911 @item @code{CDSIN(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
8914 @item @emph{See also}:
8921 @section @code{SINH} --- Hyperbolic sine function
8924 @cindex hyperbolic sine
8925 @cindex hyperbolic function, sine
8926 @cindex sine, hyperbolic
8929 @item @emph{Description}:
8930 @code{SINH(X)} computes the hyperbolic sine of @var{X}.
8932 @item @emph{Standard}:
8938 @item @emph{Syntax}:
8939 @code{RESULT = SINH(X)}
8941 @item @emph{Arguments}:
8942 @multitable @columnfractions .15 .70
8943 @item @var{X} @tab The type shall be @code{REAL(*)}.
8946 @item @emph{Return value}:
8947 The return value is of type @code{REAL(*)}.
8949 @item @emph{Example}:
8952 real(8) :: x = - 1.0_8
8954 end program test_sinh
8957 @item @emph{Specific names}:
8958 @multitable @columnfractions .20 .20 .20 .25
8959 @item Name @tab Argument @tab Return type @tab Standard
8960 @item @code{DSINH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
8963 @item @emph{See also}:
8970 @section @code{SIZE} --- Determine the size of an array
8973 @cindex array, number of elements
8974 @cindex array, count elements
8977 @item @emph{Description}:
8978 Determine the extent of @var{ARRAY} along a specified dimension @var{DIM},
8979 or the total number of elements in @var{ARRAY} if @var{DIM} is absent.
8981 @item @emph{Standard}:
8987 @item @emph{Syntax}:
8988 @code{RESULT = SIZE(ARRAY[, DIM])}
8990 @item @emph{Arguments}:
8991 @multitable @columnfractions .15 .70
8992 @item @var{ARRAY} @tab Shall be an array of any type. If @var{ARRAY} is
8993 a pointer it must be associated and allocatable arrays must be allocated.
8994 @item @var{DIM} @tab (Optional) shall be a scalar of type @code{INTEGER}
8995 and its value shall be in the range from 1 to n, where n equals the rank
8999 @item @emph{Return value}:
9000 The return value is of type @code{INTEGER} and of the default
9003 @item @emph{Example}:
9006 WRITE(*,*) SIZE((/ 1, 2 /)) ! 2
9010 @item @emph{See also}:
9011 @ref{SHAPE}, @ref{RESHAPE}
9017 @section @code{SLEEP} --- Sleep for the specified number of seconds
9019 @cindex delayed execution
9022 @item @emph{Description}:
9023 Calling this subroutine causes the process to pause for @var{SECONDS} seconds.
9025 @item @emph{Standard}:
9031 @item @emph{Syntax}:
9032 @code{CALL SLEEP(SECONDS)}
9034 @item @emph{Arguments}:
9035 @multitable @columnfractions .15 .70
9036 @item @var{SECONDS} @tab The type shall be of default @code{INTEGER}.
9039 @item @emph{Example}:
9050 @section @code{SNGL} --- Convert double precision real to default real
9052 @cindex conversion, to real
9055 @item @emph{Description}:
9056 @code{SNGL(A)} converts the double precision real @var{A}
9057 to a default real value. This is an archaic form of @code{REAL}
9058 that is specific to one type for @var{A}.
9060 @item @emph{Standard}:
9066 @item @emph{Syntax}:
9067 @code{RESULT = SNGL(A)}
9069 @item @emph{Arguments}:
9070 @multitable @columnfractions .15 .70
9071 @item @var{A} @tab The type shall be a double precision @code{REAL}.
9074 @item @emph{Return value}:
9075 The return value is of type default @code{REAL}.
9077 @item @emph{See also}:
9084 @section @code{SPACING} --- Smallest distance between two numbers of a given type
9086 @cindex real number, relative spacing
9087 @cindex floating point, relative spacing
9090 @item @emph{Description}:
9091 Determines the distance between the argument @var{X} and the nearest
9092 adjacent number of the same type.
9094 @item @emph{Standard}:
9100 @item @emph{Syntax}:
9101 @code{RESULT = SPACING(X)}
9103 @item @emph{Arguments}:
9104 @multitable @columnfractions .15 .70
9105 @item @var{X} @tab Shall be of type @code{REAL(*)}.
9108 @item @emph{Return value}:
9109 The result is of the same type as the input argument @var{X}.
9111 @item @emph{Example}:
9113 PROGRAM test_spacing
9114 INTEGER, PARAMETER :: SGL = SELECTED_REAL_KIND(p=6, r=37)
9115 INTEGER, PARAMETER :: DBL = SELECTED_REAL_KIND(p=13, r=200)
9117 WRITE(*,*) spacing(1.0_SGL) ! "1.1920929E-07" on i686
9118 WRITE(*,*) spacing(1.0_DBL) ! "2.220446049250313E-016" on i686
9122 @item @emph{See also}:
9129 @section @code{SPREAD} --- Add a dimension to an array
9131 @cindex array, increase dimension
9132 @cindex array, duplicate elementes
9133 @cindex array, duplicate dimensions
9136 @item @emph{Description}:
9137 Replicates a @var{SOURCE} array @var{NCOPIES} times along a specified
9138 dimension @var{DIM}.
9140 @item @emph{Standard}:
9144 Transformational function
9146 @item @emph{Syntax}:
9147 @code{RESULT = SPREAD(SOURCE, DIM, NCOPIES)}
9149 @item @emph{Arguments}:
9150 @multitable @columnfractions .15 .70
9151 @item @var{SOURCE} @tab Shall be a scalar or an array of any type and
9152 a rank less than seven.
9153 @item @var{DIM} @tab Shall be a scalar of type @code{INTEGER} with a
9154 value in the range from 1 to n+1, where n equals the rank of @var{SOURCE}.
9155 @item @var{NCOPIES} @tab Shall be a scalar of type @code{INTEGER}.
9158 @item @emph{Return value}:
9159 The result is an array of the same type as @var{SOURCE} and has rank n+1
9160 where n equals the rank of @var{SOURCE}.
9162 @item @emph{Example}:
9165 INTEGER :: a = 1, b(2) = (/ 1, 2 /)
9166 WRITE(*,*) SPREAD(A, 1, 2) ! "1 1"
9167 WRITE(*,*) SPREAD(B, 1, 2) ! "1 1 2 2"
9171 @item @emph{See also}:
9178 @section @code{SQRT} --- Square-root function
9188 @item @emph{Description}:
9189 @code{SQRT(X)} computes the square root of @var{X}.
9191 @item @emph{Standard}:
9197 @item @emph{Syntax}:
9198 @code{RESULT = SQRT(X)}
9200 @item @emph{Arguments}:
9201 @multitable @columnfractions .15 .70
9202 @item @var{X} @tab The type shall be @code{REAL(*)} or
9206 @item @emph{Return value}:
9207 The return value is of type @code{REAL(*)} or @code{COMPLEX(*)}.
9208 The kind type parameter is the same as @var{X}.
9210 @item @emph{Example}:
9213 real(8) :: x = 2.0_8
9214 complex :: z = (1.0, 2.0)
9217 end program test_sqrt
9220 @item @emph{Specific names}:
9221 @multitable @columnfractions .20 .20 .20 .25
9222 @item Name @tab Argument @tab Return type @tab Standard
9223 @item @code{DSQRT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
9224 @item @code{CSQRT(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab F95 and later
9225 @item @code{ZSQRT(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
9226 @item @code{CDSQRT(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
9233 @section @code{SRAND} --- Reinitialize the random number generator
9235 @cindex random number generation, seeding
9236 @cindex seeding a random number generator
9239 @item @emph{Description}:
9240 @code{SRAND} reinitializes the pseudo-random number generator
9241 called by @code{RAND} and @code{IRAND}. The new seed used by the
9242 generator is specified by the required argument @var{SEED}.
9244 @item @emph{Standard}:
9248 Non-elemental subroutine
9250 @item @emph{Syntax}:
9251 @code{CALL SRAND(SEED)}
9253 @item @emph{Arguments}:
9254 @multitable @columnfractions .15 .70
9255 @item @var{SEED} @tab Shall be a scalar @code{INTEGER(kind=4)}.
9258 @item @emph{Return value}:
9261 @item @emph{Example}:
9262 See @code{RAND} and @code{IRAND} for examples.
9265 The Fortran 2003 standard specifies the intrinsic @code{RANDOM_SEED} to
9266 initialize the pseudo-random numbers generator and @code{RANDOM_NUMBER}
9267 to generate pseudo-random numbers. Please note that in
9268 GNU Fortran, these two sets of intrinsics (@code{RAND},
9269 @code{IRAND} and @code{SRAND} on the one hand, @code{RANDOM_NUMBER} and
9270 @code{RANDOM_SEED} on the other hand) access two independent
9271 pseudo-random number generators.
9273 @item @emph{See also}:
9274 @ref{RAND}, @ref{RANDOM_SEED}, @ref{RANDOM_NUMBER}
9281 @section @code{STAT} --- Get file status
9283 @cindex file system, file status
9286 @item @emph{Description}:
9287 This function returns information about a file. No permissions are required on
9288 the file itself, but execute (search) permission is required on all of the
9289 directories in path that lead to the file.
9291 The elements that are obtained and stored in the array @code{BUFF}:
9292 @multitable @columnfractions .15 .70
9293 @item @code{buff(1)} @tab Device ID
9294 @item @code{buff(2)} @tab Inode number
9295 @item @code{buff(3)} @tab File mode
9296 @item @code{buff(4)} @tab Number of links
9297 @item @code{buff(5)} @tab Owner's uid
9298 @item @code{buff(6)} @tab Owner's gid
9299 @item @code{buff(7)} @tab ID of device containing directory entry for file (0 if not available)
9300 @item @code{buff(8)} @tab File size (bytes)
9301 @item @code{buff(9)} @tab Last access time
9302 @item @code{buff(10)} @tab Last modification time
9303 @item @code{buff(11)} @tab Last file status change time
9304 @item @code{buff(12)} @tab Preferred I/O block size (-1 if not available)
9305 @item @code{buff(13)} @tab Number of blocks allocated (-1 if not available)
9308 Not all these elements are relevant on all systems.
9309 If an element is not relevant, it is returned as 0.
9312 @item @emph{Standard}:
9316 Non-elemental subroutine
9318 @item @emph{Syntax}:
9319 @code{CALL STAT(FILE,BUFF[,STATUS])}
9321 @item @emph{Arguments}:
9322 @multitable @columnfractions .15 .70
9323 @item @var{FILE} @tab The type shall be @code{CHARACTER(*)}, a valid path within the file system.
9324 @item @var{BUFF} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
9325 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0
9326 on success and a system specific error code otherwise.
9329 @item @emph{Example}:
9332 INTEGER, DIMENSION(13) :: buff
9335 CALL STAT("/etc/passwd", buff, status)
9337 IF (status == 0) THEN
9338 WRITE (*, FMT="('Device ID:', T30, I19)") buff(1)
9339 WRITE (*, FMT="('Inode number:', T30, I19)") buff(2)
9340 WRITE (*, FMT="('File mode (octal):', T30, O19)") buff(3)
9341 WRITE (*, FMT="('Number of links:', T30, I19)") buff(4)
9342 WRITE (*, FMT="('Owner''s uid:', T30, I19)") buff(5)
9343 WRITE (*, FMT="('Owner''s gid:', T30, I19)") buff(6)
9344 WRITE (*, FMT="('Device where located:', T30, I19)") buff(7)
9345 WRITE (*, FMT="('File size:', T30, I19)") buff(8)
9346 WRITE (*, FMT="('Last access time:', T30, A19)") CTIME(buff(9))
9347 WRITE (*, FMT="('Last modification time', T30, A19)") CTIME(buff(10))
9348 WRITE (*, FMT="('Last status change time:', T30, A19)") CTIME(buff(11))
9349 WRITE (*, FMT="('Preferred block size:', T30, I19)") buff(12)
9350 WRITE (*, FMT="('No. of blocks allocated:', T30, I19)") buff(13)
9355 @item @emph{See also}:
9356 To stat an open file: @ref{FSTAT}, to stat a link: @ref{LSTAT}
9362 @section @code{SUM} --- Sum of array elements
9365 @cindex array, add elements
9366 @cindex array, conditionally add elements
9367 @cindex sum array elements
9370 @item @emph{Description}:
9371 Adds the elements of @var{ARRAY} along dimension @var{DIM} if
9372 the corresponding element in @var{MASK} is @code{TRUE}.
9374 @item @emph{Standard}:
9378 Transformational function
9380 @item @emph{Syntax}:
9381 @code{RESULT = SUM(ARRAY[, MASK])}
9382 @code{RESULT = SUM(ARRAY, DIM[, MASK])}
9384 @item @emph{Arguments}:
9385 @multitable @columnfractions .15 .70
9386 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER(*)},
9387 @code{REAL(*)} or @code{COMPLEX(*)}.
9388 @item @var{DIM} @tab (Optional) shall be a scalar of type
9389 @code{INTEGER} with a value in the range from 1 to n, where n
9390 equals the rank of @var{ARRAY}.
9391 @item @var{MASK} @tab (Optional) shall be of type @code{LOGICAL}
9392 and either be a scalar or an array of the same shape as @var{ARRAY}.
9395 @item @emph{Return value}:
9396 The result is of the same type as @var{ARRAY}.
9398 If @var{DIM} is absent, a scalar with the sum of all elements in @var{ARRAY}
9399 is returned. Otherwise, an array of rank n-1, where n equals the rank of
9400 @var{ARRAY},and a shape similar to that of @var{ARRAY} with dimension @var{DIM}
9401 dropped is returned.
9403 @item @emph{Example}:
9406 INTEGER :: x(5) = (/ 1, 2, 3, 4 ,5 /)
9407 print *, SUM(x) ! all elements, sum = 15
9408 print *, SUM(x, MASK=MOD(x, 2)==1) ! odd elements, sum = 9
9412 @item @emph{See also}:
9419 @section @code{SYMLNK} --- Create a symbolic link
9421 @cindex file system, create link
9422 @cindex file system, soft link
9425 @item @emph{Description}:
9426 Makes a symbolic link from file @var{PATH1} to @var{PATH2}. A null
9427 character (@code{CHAR(0)}) can be used to mark the end of the names in
9428 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
9429 names are ignored. If the @var{STATUS} argument is supplied, it
9430 contains 0 on success or a nonzero error code upon return; see
9431 @code{symlink(2)}. If the system does not supply @code{symlink(2)},
9432 @code{ENOSYS} is returned.
9434 This intrinsic is provided in both subroutine and function forms;
9435 however, only one form can be used in any given program unit.
9437 @item @emph{Standard}:
9441 Subroutine, non-elemental function
9443 @item @emph{Syntax}:
9444 @multitable @columnfractions .80
9445 @item @code{CALL SYMLNK(PATH1, PATH2 [, STATUS])}
9446 @item @code{STATUS = SYMLNK(PATH1, PATH2)}
9449 @item @emph{Arguments}:
9450 @multitable @columnfractions .15 .70
9451 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
9452 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
9453 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
9456 @item @emph{See also}:
9457 @ref{LINK}, @ref{UNLINK}
9464 @section @code{SYSTEM} --- Execute a shell command
9466 @cindex system, system call
9469 @item @emph{Description}:
9470 Passes the command @var{COMMAND} to a shell (see @code{system(3)}). If
9471 argument @var{STATUS} is present, it contains the value returned by
9472 @code{system(3)}, which is presumably 0 if the shell command succeeded.
9473 Note that which shell is used to invoke the command is system-dependent
9474 and environment-dependent.
9476 This intrinsic is provided in both subroutine and function forms;
9477 however, only one form can be used in any given program unit.
9479 @item @emph{Standard}:
9483 Subroutine, non-elemental function
9485 @item @emph{Syntax}:
9486 @multitable @columnfractions .80
9487 @item @code{CALL SYSTEM(COMMAND [, STATUS])}
9488 @item @code{STATUS = SYSTEM(COMMAND)}
9491 @item @emph{Arguments}:
9492 @multitable @columnfractions .15 .70
9493 @item @var{COMMAND} @tab Shall be of default @code{CHARACTER} type.
9494 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
9497 @item @emph{See also}:
9503 @section @code{SYSTEM_CLOCK} --- Time function
9504 @fnindex SYSTEM_CLOCK
9505 @cindex time, clock ticks
9509 @item @emph{Description}:
9510 Determines the @var{COUNT} of milliseconds of wall clock time since
9511 the Epoch (00:00:00 UTC, January 1, 1970) modulo @var{COUNT_MAX},
9512 @var{COUNT_RATE} determines the number of clock ticks per second.
9513 @var{COUNT_RATE} and @var{COUNT_MAX} are constant and specific to
9516 If there is no clock, @var{COUNT} is set to @code{-HUGE(COUNT)}, and
9517 @var{COUNT_RATE} and @var{COUNT_MAX} are set to zero
9519 @item @emph{Standard}:
9525 @item @emph{Syntax}:
9526 @code{CALL SYSTEM_CLOCK([COUNT, COUNT_RATE, COUNT_MAX])}
9528 @item @emph{Arguments}:
9529 @item @emph{Arguments}:
9530 @multitable @columnfractions .15 .70
9531 @item @var{COUNT} @tab (Optional) shall be a scalar of type default
9532 @code{INTEGER} with @code{INTENT(OUT)}.
9533 @item @var{COUNT_RATE} @tab (Optional) shall be a scalar of type default
9534 @code{INTEGER} with @code{INTENT(OUT)}.
9535 @item @var{COUNT_MAX} @tab (Optional) shall be a scalar of type default
9536 @code{INTEGER} with @code{INTENT(OUT)}.
9539 @item @emph{Example}:
9541 PROGRAM test_system_clock
9542 INTEGER :: count, count_rate, count_max
9543 CALL SYSTEM_CLOCK(count, count_rate, count_max)
9544 WRITE(*,*) count, count_rate, count_max
9548 @item @emph{See also}:
9549 @ref{DATE_AND_TIME}, @ref{CPU_TIME}
9555 @section @code{TAN} --- Tangent function
9558 @cindex trigonometric function, tangent
9562 @item @emph{Description}:
9563 @code{TAN(X)} computes the tangent of @var{X}.
9565 @item @emph{Standard}:
9571 @item @emph{Syntax}:
9572 @code{RESULT = TAN(X)}
9574 @item @emph{Arguments}:
9575 @multitable @columnfractions .15 .70
9576 @item @var{X} @tab The type shall be @code{REAL(*)}.
9579 @item @emph{Return value}:
9580 The return value is of type @code{REAL(*)}. The kind type parameter is
9581 the same as @var{X}.
9583 @item @emph{Example}:
9586 real(8) :: x = 0.165_8
9588 end program test_tan
9591 @item @emph{Specific names}:
9592 @multitable @columnfractions .20 .20 .20 .25
9593 @item Name @tab Argument @tab Return type @tab Standard
9594 @item @code{DTAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
9597 @item @emph{See also}:
9604 @section @code{TANH} --- Hyperbolic tangent function
9607 @cindex hyperbolic tangent
9608 @cindex hyperbolic function, tangent
9609 @cindex tangent, hyperbolic
9612 @item @emph{Description}:
9613 @code{TANH(X)} computes the hyperbolic tangent of @var{X}.
9615 @item @emph{Standard}:
9621 @item @emph{Syntax}:
9624 @item @emph{Arguments}:
9625 @multitable @columnfractions .15 .70
9626 @item @var{X} @tab The type shall be @code{REAL(*)}.
9629 @item @emph{Return value}:
9630 The return value is of type @code{REAL(*)} and lies in the range
9631 @math{ - 1 \leq tanh(x) \leq 1 }.
9633 @item @emph{Example}:
9636 real(8) :: x = 2.1_8
9638 end program test_tanh
9641 @item @emph{Specific names}:
9642 @multitable @columnfractions .20 .20 .20 .25
9643 @item Name @tab Argument @tab Return type @tab Standard
9644 @item @code{DTANH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
9647 @item @emph{See also}:
9654 @section @code{TIME} --- Time function
9656 @cindex time, current
9657 @cindex current time
9660 @item @emph{Description}:
9661 Returns the current time encoded as an integer (in the manner of the
9662 UNIX function @code{time(3)}). This value is suitable for passing to
9663 @code{CTIME()}, @code{GMTIME()}, and @code{LTIME()}.
9665 This intrinsic is not fully portable, such as to systems with 32-bit
9666 @code{INTEGER} types but supporting times wider than 32 bits. Therefore,
9667 the values returned by this intrinsic might be, or become, negative, or
9668 numerically less than previous values, during a single run of the
9671 See @ref{TIME8}, for information on a similar intrinsic that might be
9672 portable to more GNU Fortran implementations, though to fewer Fortran
9675 @item @emph{Standard}:
9679 Non-elemental function
9681 @item @emph{Syntax}:
9682 @code{RESULT = TIME()}
9684 @item @emph{Return value}:
9685 The return value is a scalar of type @code{INTEGER(4)}.
9687 @item @emph{See also}:
9688 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK}, @ref{TIME8}
9695 @section @code{TIME8} --- Time function (64-bit)
9697 @cindex time, current
9698 @cindex current time
9701 @item @emph{Description}:
9702 Returns the current time encoded as an integer (in the manner of the
9703 UNIX function @code{time(3)}). This value is suitable for passing to
9704 @code{CTIME()}, @code{GMTIME()}, and @code{LTIME()}.
9706 @emph{Warning:} this intrinsic does not increase the range of the timing
9707 values over that returned by @code{time(3)}. On a system with a 32-bit
9708 @code{time(3)}, @code{TIME8()} will return a 32-bit value, even though
9709 it is converted to a 64-bit @code{INTEGER(8)} value. That means
9710 overflows of the 32-bit value can still occur. Therefore, the values
9711 returned by this intrinsic might be or become negative or numerically
9712 less than previous values during a single run of the compiled program.
9714 @item @emph{Standard}:
9718 Non-elemental function
9720 @item @emph{Syntax}:
9721 @code{RESULT = TIME8()}
9723 @item @emph{Return value}:
9724 The return value is a scalar of type @code{INTEGER(8)}.
9726 @item @emph{See also}:
9727 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{MCLOCK8}, @ref{TIME}
9734 @section @code{TINY} --- Smallest positive number of a real kind
9736 @cindex limits, smallest number
9737 @cindex model representation, smallest number
9740 @item @emph{Description}:
9741 @code{TINY(X)} returns the smallest positive (non zero) number
9742 in the model of the type of @code{X}.
9744 @item @emph{Standard}:
9750 @item @emph{Syntax}:
9751 @code{RESULT = TINY(X)}
9753 @item @emph{Arguments}:
9754 @multitable @columnfractions .15 .70
9755 @item @var{X} @tab Shall be of type @code{REAL}.
9758 @item @emph{Return value}:
9759 The return value is of the same type and kind as @var{X}
9761 @item @emph{Example}:
9762 See @code{HUGE} for an example.
9768 @section @code{TRANSFER} --- Transfer bit patterns
9774 @item @emph{Description}:
9775 Interprets the bitwise representation of @var{SOURCE} in memory as if it
9776 is the representation of a variable or array of the same type and type
9777 parameters as @var{MOLD}.
9779 This is approximately equivalent to the C concept of @emph{casting} one
9782 @item @emph{Standard}:
9786 Transformational function
9788 @item @emph{Syntax}:
9789 @code{RESULT = TRANSFER(SOURCE, MOLD[, SIZE])}
9791 @item @emph{Arguments}:
9792 @multitable @columnfractions .15 .70
9793 @item @var{SOURCE} @tab Shall be a scalar or an array of any type.
9794 @item @var{MOLD} @tab Shall be a scalar or an array of any type.
9795 @item @var{SIZE} @tab (Optional) shall be a scalar of type
9799 @item @emph{Return value}:
9800 The result has the same type as @var{MOLD}, with the bit level
9801 representation of @var{SOURCE}. If @var{SIZE} is present, the result is
9802 a one-dimensional array of length @var{SIZE}. If @var{SIZE} is absent
9803 but @var{MOLD} is an array (of any size or shape), the result is a one-
9804 dimensional array of the minimum length needed to contain the entirety
9805 of the bitwise representation of @var{SOURCE}. If @var{SIZE} is absent
9806 and @var{MOLD} is a scalar, the result is a scalar.
9808 If the bitwise representation of the result is longer than that of
9809 @var{SOURCE}, then the leading bits of the result correspond to those of
9810 @var{SOURCE} and any trailing bits are filled arbitrarily.
9812 When the resulting bit representation does not correspond to a valid
9813 representation of a variable of the same type as @var{MOLD}, the results
9814 are undefined, and subsequent operations on the result cannot be
9815 guaranteed to produce sensible behavior. For example, it is possible to
9816 create @code{LOGICAL} variables for which @code{@var{VAR}} and
9817 @code{.NOT.@var{VAR}} both appear to be true.
9819 @item @emph{Example}:
9821 PROGRAM test_transfer
9822 integer :: x = 2143289344
9823 print *, transfer(x, 1.0) ! prints "NaN" on i686
9831 @section @code{TRANSPOSE} --- Transpose an array of rank two
9833 @cindex array, transpose
9834 @cindex matrix, transpose
9838 @item @emph{Description}:
9839 Transpose an array of rank two. Element (i, j) of the result has the value
9840 @code{MATRIX(j, i)}, for all i, j.
9842 @item @emph{Standard}:
9846 Transformational function
9848 @item @emph{Syntax}:
9849 @code{RESULT = TRANSPOSE(MATRIX)}
9851 @item @emph{Arguments}:
9852 @multitable @columnfractions .15 .70
9853 @item @var{MATRIX} @tab Shall be an array of any type and have a rank of two.
9856 @item @emph{Return value}:
9857 The result has the the same type as @var{MATRIX}, and has shape
9858 @code{(/ m, n /)} if @var{MATRIX} has shape @code{(/ n, m /)}.
9864 @section @code{TRIM} --- Remove trailing blank characters of a string
9866 @cindex string, remove trailing whitespace
9869 @item @emph{Description}:
9870 Removes trailing blank characters of a string.
9872 @item @emph{Standard}:
9876 Transformational function
9878 @item @emph{Syntax}:
9879 @code{RESULT = TRIM(STRING)}
9881 @item @emph{Arguments}:
9882 @multitable @columnfractions .15 .70
9883 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER(*)}.
9886 @item @emph{Return value}:
9887 A scalar of type @code{CHARACTER(*)} which length is that of @var{STRING}
9888 less the number of trailing blanks.
9890 @item @emph{Example}:
9893 CHARACTER(len=10), PARAMETER :: s = "GFORTRAN "
9894 WRITE(*,*) LEN(s), LEN(TRIM(s)) ! "10 8", with/without trailing blanks
9898 @item @emph{See also}:
9899 @ref{ADJUSTL}, @ref{ADJUSTR}
9905 @section @code{TTYNAM} --- Get the name of a terminal device.
9907 @cindex system, terminal
9910 @item @emph{Description}:
9911 Get the name of a terminal device. For more information,
9912 see @code{ttyname(3)}.
9914 This intrinsic is provided in both subroutine and function forms;
9915 however, only one form can be used in any given program unit.
9917 @item @emph{Standard}:
9921 Subroutine, non-elemental function
9923 @item @emph{Syntax}:
9924 @multitable @columnfractions .80
9925 @item @code{CALL TTYNAM(UNIT, NAME)}
9926 @item @code{NAME = TTYNAM(UNIT)}
9929 @item @emph{Arguments}:
9930 @multitable @columnfractions .15 .70
9931 @item @var{UNIT} @tab Shall be a scalar @code{INTEGER(*)}.
9932 @item @var{NAME} @tab Shall be of type @code{CHARACTER(*)}.
9935 @item @emph{Example}:
9940 IF (isatty(unit=unit)) write(*,*) ttynam(unit)
9945 @item @emph{See also}:
9952 @section @code{UBOUND} --- Upper dimension bounds of an array
9954 @cindex array, upper bound
9957 @item @emph{Description}:
9958 Returns the upper bounds of an array, or a single upper bound
9959 along the @var{DIM} dimension.
9960 @item @emph{Standard}:
9966 @item @emph{Syntax}:
9967 @code{RESULT = UBOUND(ARRAY [, DIM])}
9969 @item @emph{Arguments}:
9970 @multitable @columnfractions .15 .70
9971 @item @var{ARRAY} @tab Shall be an array, of any type.
9972 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER(*)}.
9975 @item @emph{Return value}:
9976 If @var{DIM} is absent, the result is an array of the upper bounds of
9977 @var{ARRAY}. If @var{DIM} is present, the result is a scalar
9978 corresponding to the upper bound of the array along that dimension. If
9979 @var{ARRAY} is an expression rather than a whole array or array
9980 structure component, or if it has a zero extent along the relevant
9981 dimension, the upper bound is taken to be the number of elements along
9982 the relevant dimension.
9984 @item @emph{See also}:
9991 @section @code{UMASK} --- Set the file creation mask
9993 @cindex file system, file creation mask
9996 @item @emph{Description}:
9997 Sets the file creation mask to @var{MASK} and returns the old value in
9998 argument @var{OLD} if it is supplied. See @code{umask(2)}.
10000 @item @emph{Standard}:
10003 @item @emph{Class}:
10006 @item @emph{Syntax}:
10007 @code{CALL UMASK(MASK [, OLD])}
10009 @item @emph{Arguments}:
10010 @multitable @columnfractions .15 .70
10011 @item @var{MASK} @tab Shall be a scalar of type @code{INTEGER(*)}.
10012 @item @var{MASK} @tab (Optional) Shall be a scalar of type
10021 @section @code{UNLINK} --- Remove a file from the file system
10023 @cindex file system, remove file
10026 @item @emph{Description}:
10027 Unlinks the file @var{PATH}. A null character (@code{CHAR(0)}) can be
10028 used to mark the end of the name in @var{PATH}; otherwise, trailing
10029 blanks in the file name are ignored. If the @var{STATUS} argument is
10030 supplied, it contains 0 on success or a nonzero error code upon return;
10031 see @code{unlink(2)}.
10033 This intrinsic is provided in both subroutine and function forms;
10034 however, only one form can be used in any given program unit.
10036 @item @emph{Standard}:
10039 @item @emph{Class}:
10040 Subroutine, non-elemental function
10042 @item @emph{Syntax}:
10043 @multitable @columnfractions .80
10044 @item @code{CALL UNLINK(PATH [, STATUS])}
10045 @item @code{STATUS = UNLINK(PATH)}
10048 @item @emph{Arguments}:
10049 @multitable @columnfractions .15 .70
10050 @item @var{PATH} @tab Shall be of default @code{CHARACTER} type.
10051 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
10054 @item @emph{See also}:
10055 @ref{LINK}, @ref{SYMLNK}
10061 @section @code{UNPACK} --- Unpack an array of rank one into an array
10063 @cindex array, unpacking
10064 @cindex array, increase dimension
10065 @cindex array, scatter elements
10068 @item @emph{Description}:
10069 Store the elements of @var{VECTOR} in an array of higher rank.
10071 @item @emph{Standard}:
10074 @item @emph{Class}:
10075 Transformational function
10077 @item @emph{Syntax}:
10078 @code{RESULT = UNPACK(VECTOR, MASK, FIELD)}
10080 @item @emph{Arguments}:
10081 @multitable @columnfractions .15 .70
10082 @item @var{VECTOR} @tab Shall be an array of any type and rank one. It
10083 shall have at least as many elements as @var{MASK} has @code{TRUE} values.
10084 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL}.
10085 @item @var{FIELD} @tab Shall be of the sam type as @var{VECTOR} and have
10086 the same shape as @var{MASK}.
10089 @item @emph{Return value}:
10090 The resulting array corresponds to @var{FIELD} with @code{TRUE} elements
10091 of @var{MASK} replaced by values from @var{VECTOR} in array element order.
10093 @item @emph{Example}:
10095 PROGRAM test_unpack
10096 integer :: vector(2) = (/1,1/)
10097 logical :: mask(4) = (/ .TRUE., .FALSE., .FALSE., .TRUE. /)
10098 integer :: field(2,2) = 0, unity(2,2)
10100 ! result: unity matrix
10101 unity = unpack(vector, reshape(mask, (/2,2/)), field)
10105 @item @emph{See also}:
10106 @ref{PACK}, @ref{SPREAD}
10112 @section @code{VERIFY} --- Scan a string for the absence of a set of characters
10114 @cindex string, find missing set
10117 @item @emph{Description}:
10118 Verifies that all the characters in a @var{SET} are present in a @var{STRING}.
10120 If @var{BACK} is either absent or equals @code{FALSE}, this function
10121 returns the position of the leftmost character of @var{STRING} that is
10122 not in @var{SET}. If @var{BACK} equals @code{TRUE}, the rightmost position
10123 is returned. If all characters of @var{SET} are found in @var{STRING}, the
10126 @item @emph{Standard}:
10129 @item @emph{Class}:
10132 @item @emph{Syntax}:
10133 @code{RESULT = VERFIY(STRING, SET[, BACK])}
10135 @item @emph{Arguments}:
10136 @multitable @columnfractions .15 .70
10137 @item @var{STRING} @tab Shall be of type @code{CHARACTER(*)}.
10138 @item @var{SET} @tab Shall be of type @code{CHARACTER(*)}.
10139 @item @var{BACK} @tab (Optional) shall be of type @code{LOGICAL}.
10142 @item @emph{Return value}:
10143 The return value is of type @code{INTEGER} and of the default
10146 @item @emph{Example}:
10148 PROGRAM test_verify
10149 WRITE(*,*) VERIFY("FORTRAN", "AO") ! 1, found 'F'
10150 WRITE(*,*) VERIFY("FORTRAN", "FOO") ! 3, found 'R'
10151 WRITE(*,*) VERIFY("FORTRAN", "C++") ! 1, found 'F'
10152 WRITE(*,*) VERIFY("FORTRAN", "C++", .TRUE.) ! 7, found 'N'
10153 WRITE(*,*) VERIFY("FORTRAN", "FORTRAN") ! 0' found none
10157 @item @emph{See also}:
10158 @ref{SCAN}, @ref{INDEX}
10164 @section @code{XOR} --- Bitwise logical exclusive OR
10166 @cindex bitwise logical exclusive or
10167 @cindex logical exclusive or, bitwise
10170 @item @emph{Description}:
10171 Bitwise logical exclusive or.
10173 This intrinsic routine is provided for backwards compatibility with
10174 GNU Fortran 77. For integer arguments, programmers should consider
10175 the use of the @ref{IEOR} intrinsic defined by the Fortran standard.
10177 @item @emph{Standard}:
10180 @item @emph{Class}:
10181 Non-elemental function
10183 @item @emph{Syntax}:
10184 @code{RESULT = XOR(X, Y)}
10186 @item @emph{Arguments}:
10187 @multitable @columnfractions .15 .70
10188 @item @var{X} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
10189 @item @var{Y} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
10192 @item @emph{Return value}:
10193 The return type is either @code{INTEGER(*)} or @code{LOGICAL}
10194 after cross-promotion of the arguments.
10196 @item @emph{Example}:
10199 LOGICAL :: T = .TRUE., F = .FALSE.
10201 DATA a / Z'F' /, b / Z'3' /
10203 WRITE (*,*) XOR(T, T), XOR(T, F), XOR(F, T), XOR(F, F)
10204 WRITE (*,*) XOR(a, b)
10208 @item @emph{See also}:
10209 F95 elemental function: @ref{IEOR}