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
41 @comment Missing intrinsics (double check with #19292)
46 * Introduction: Introduction to Intrinsics
47 * @code{ABORT}: ABORT, Abort the program
48 * @code{ABS}: ABS, Absolute value
49 * @code{ACCESS}: ACCESS, Checks file access modes
50 * @code{ACHAR}: ACHAR, Character in @acronym{ASCII} collating sequence
51 * @code{ACOS}: ACOS, Arccosine function
52 * @code{ACOSH}: ACOSH, Hyperbolic arccosine function
53 * @code{ADJUSTL}: ADJUSTL, Left adjust a string
54 * @code{ADJUSTR}: ADJUSTR, Right adjust a string
55 * @code{AIMAG}: AIMAG, Imaginary part of complex number
56 * @code{AINT}: AINT, Truncate to a whole number
57 * @code{ALARM}: ALARM, Set an alarm clock
58 * @code{ALL}: ALL, Determine if all values are true
59 * @code{ALLOCATED}: ALLOCATED, Status of allocatable entity
60 * @code{AND}: AND, Bitwise logical AND
61 * @code{ANINT}: ANINT, Nearest whole number
62 * @code{ANY}: ANY, Determine if any values are true
63 * @code{ASIN}: ASIN, Arcsine function
64 * @code{ASINH}: ASINH, Hyperbolic arcsine function
65 * @code{ASSOCIATED}: ASSOCIATED, Status of a pointer or pointer/target pair
66 * @code{ATAN}: ATAN, Arctangent function
67 * @code{ATAN2}: ATAN2, Arctangent function
68 * @code{ATANH}: ATANH, Hyperbolic arctangent function
69 * @code{BESJ0}: BESJ0, Bessel function of the first kind of order 0
70 * @code{BESJ1}: BESJ1, Bessel function of the first kind of order 1
71 * @code{BESJN}: BESJN, Bessel function of the first kind
72 * @code{BESY0}: BESY0, Bessel function of the second kind of order 0
73 * @code{BESY1}: BESY1, Bessel function of the second kind of order 1
74 * @code{BESYN}: BESYN, Bessel function of the second kind
75 * @code{BIT_SIZE}: BIT_SIZE, Bit size inquiry function
76 * @code{BTEST}: BTEST, Bit test function
77 * @code{CEILING}: CEILING, Integer ceiling function
78 * @code{CHAR}: CHAR, Integer-to-character conversion function
79 * @code{CHDIR}: CHDIR, Change working directory
80 * @code{CHMOD}: CHMOD, Change access permissions of files
81 * @code{CMPLX}: CMPLX, Complex conversion function
82 * @code{COMMAND_ARGUMENT_COUNT}: COMMAND_ARGUMENT_COUNT, Get number of command line arguments
83 * @code{CONJG}: CONJG, Complex conjugate function
84 * @code{COS}: COS, Cosine function
85 * @code{COSH}: COSH, Hyperbolic cosine function
86 * @code{COUNT}: COUNT, Count occurrences of TRUE in an array
87 * @code{CPU_TIME}: CPU_TIME, CPU time subroutine
88 * @code{CSHIFT}: CSHIFT, Circular array shift function
89 * @code{CTIME}: CTIME, Subroutine (or function) to convert a time into a string
90 * @code{DATE_AND_TIME}: DATE_AND_TIME, Date and time subroutine
91 * @code{DBLE}: DBLE, Double precision conversion function
92 * @code{DCMPLX}: DCMPLX, Double complex conversion function
93 * @code{DFLOAT}: DFLOAT, Double precision conversion function
94 * @code{DIGITS}: DIGITS, Significant digits function
95 * @code{DIM}: DIM, Dim function
96 * @code{DOT_PRODUCT}: DOT_PRODUCT, Dot product function
97 * @code{DPROD}: DPROD, Double product function
98 * @code{DREAL}: DREAL, Double real part function
99 * @code{DTIME}: DTIME, Execution time subroutine (or function)
100 * @code{EOSHIFT}: EOSHIFT, End-off shift function
101 * @code{EPSILON}: EPSILON, Epsilon function
102 * @code{ERF}: ERF, Error function
103 * @code{ERFC}: ERFC, Complementary error function
104 * @code{ETIME}: ETIME, Execution time subroutine (or function)
105 * @code{EXIT}: EXIT, Exit the program with status.
106 * @code{EXP}: EXP, Exponential function
107 * @code{EXPONENT}: EXPONENT, Exponent function
108 * @code{FDATE}: FDATE, Subroutine (or function) to get the current time as a string
109 * @code{FGET}: FGET, Read a single character in stream mode from stdin
110 * @code{FGETC}: FGETC, Read a single character in stream mode
111 * @code{FLOAT}: FLOAT, Convert integer to default real
112 * @code{FLOOR}: FLOOR, Integer floor function
113 * @code{FLUSH}: FLUSH, Flush I/O unit(s)
114 * @code{FNUM}: FNUM, File number function
115 * @code{FPUT}: FPUT, Write a single character in stream mode to stdout
116 * @code{FPUTC}: FPUTC, Write a single character in stream mode
117 * @code{FRACTION}: FRACTION, Fractional part of the model representation
118 * @code{FREE}: FREE, Memory de-allocation subroutine
119 * @code{FSEEK}: FSEEK, Low level file positioning subroutine
120 * @code{FSTAT}: FSTAT, Get file status
121 * @code{FTELL}: FTELL, Current stream position
122 * @code{GERROR}: GERROR, Get last system error message
123 * @code{GETARG}: GETARG, Get command line arguments
124 * @code{GET_COMMAND}: GET_COMMAND, Get the entire command line
125 * @code{GET_COMMAND_ARGUMENT}: GET_COMMAND_ARGUMENT, Get command line arguments
126 * @code{GETCWD}: GETCWD, Get current working directory
127 * @code{GETENV}: GETENV, Get an environmental variable
128 * @code{GET_ENVIRONMENT_VARIABLE}: GET_ENVIRONMENT_VARIABLE, Get an environmental variable
129 * @code{GETGID}: GETGID, Group ID function
130 * @code{GETLOG}: GETLOG, Get login name
131 * @code{GETPID}: GETPID, Process ID function
132 * @code{GETUID}: GETUID, User ID function
133 * @code{GMTIME}: GMTIME, Convert time to GMT info
134 * @code{HOSTNM}: HOSTNM, Get system host name
135 * @code{HUGE}: HUGE, Largest number of a kind
136 * @code{IACHAR}: IACHAR, Code in @acronym{ASCII} collating sequence
137 * @code{IAND}: IAND, Bitwise logical and
138 * @code{IARGC}: IARGC, Get the number of command line arguments
139 * @code{IBCLR}: IBCLR, Clear bit
140 * @code{IBITS}: IBITS, Bit extraction
141 * @code{IBSET}: IBSET, Set bit
142 * @code{ICHAR}: ICHAR, Character-to-integer conversion function
143 * @code{IDATE}: IDATE, Current local time (day/month/year)
144 * @code{IEOR}: IEOR, Bitwise logical exclusive or
145 * @code{IERRNO}: IERRNO, Function to get the last system error number
146 * @code{INDEX}: INDEX, Position of a substring within a string
147 * @code{INT}: INT, Convert to integer type
148 * @code{IOR}: IOR, Bitwise logical or
149 * @code{IRAND}: IRAND, Integer pseudo-random number
150 * @code{ISATTY}: ISATTY, Whether a unit is a terminal device
151 * @code{ISHFT}: ISHFT, Shift bits
152 * @code{ISHFTC}: ISHFTC, Shift bits circularly
153 * @code{ITIME}: ITIME, Current local time (hour/minutes/seconds)
154 * @code{KILL}: KILL, Send a signal to a process
155 * @code{KIND}: KIND, Kind of an entity
156 * @code{LBOUND}: LBOUND, Lower dimension bounds of an array
157 * @code{LEN}: LEN, Length of a character entity
158 * @code{LEN_TRIM}: LEN_TRIM, Length of a character entity without trailing blank characters
159 * @code{LGE}: LGE, Lexical greater than or equal
160 * @code{LGT}: LGT, Lexical greater than
161 * @code{LINK}: LINK, Create a hard link
162 * @code{LLE}: LLE, Lexical less than or equal
163 * @code{LLT}: LLT, Lexical less than
164 * @code{LNBLNK}: LNBLNK, Index of the last non-blank character in a string
165 * @code{LOC}: LOC, Returns the address of a variable
166 * @code{LOG}: LOG, Logarithm function
167 * @code{LOG10}: LOG10, Base 10 logarithm function
168 * @code{LOGICAL}: LOGICAL, Convert to logical 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{MERGE}: MERGE, Merge arrays
179 * @code{MIN}: MIN, Minimum value of an argument list
180 * @code{MINEXPONENT}: MINEXPONENT, Minimum exponent of a real kind
181 * @code{MINLOC}: MINLOC, Location of the minimum value within an array
182 * @code{MINVAL}: MINVAL, Minimum value of an array
183 * @code{MOD}: MOD, Remainder function
184 * @code{MODULO}: MODULO, Modulo function
185 * @code{MOVE_ALLOC}: MOVE_ALLOC, Move allocation from one object to another
186 * @code{MVBITS}: MVBITS, Move bits from one integer to another
187 * @code{NEAREST}: NEAREST, Nearest representable number
188 * @code{NEW_LINE}: NEW_LINE, New line character
189 * @code{NINT}: NINT, Nearest whole number
190 * @code{NOT}: NOT, Logical negation
191 * @code{NULL}: NULL, Function that returns an disassociated pointer
192 * @code{OR}: OR, Bitwise logical OR
193 * @code{PACK}: PACK, Pack an array into an array of rank one
194 * @code{PERROR}: PERROR, Print system error message
195 * @code{PRECISION}: PRECISION, Decimal precision of a real kind
196 * @code{PRESENT}: PRESENT, Determine whether an optional argument is specified
197 * @code{PRODUCT}: PRODUCT, Product of array elements
198 * @code{RADIX}: RADIX, Base of a data model
199 * @code{RANDOM_NUMBER}: RANDOM_NUMBER, Pseudo-random number
200 * @code{RANDOM_SEED}: RANDOM_SEED, Initialize a pseudo-random number sequence
201 * @code{RAND}: RAND, Real pseudo-random number
202 * @code{RANGE}: RANGE, Decimal exponent range of a real kind
203 * @code{RAN}: RAN, Real pseudo-random number
204 * @code{REAL}: REAL, Convert to real type
205 * @code{RENAME}: RENAME, Rename a file
206 * @code{REPEAT}: REPEAT, Repeated string concatenation
207 * @code{RESHAPE}: RESHAPE, Function to reshape an array
208 * @code{RRSPACING}: RRSPACING, Reciprocal of the relative spacing
209 * @code{RSHIFT}: RSHIFT, Right shift bits
210 * @code{SCALE}: SCALE, Scale a real value
211 * @code{SCAN}: SCAN, Scan a string for the presence of a set of characters
212 * @code{SECNDS}: SECNDS, Time function
213 @comment * @code{SECOND}: SECOND, (?)
214 @comment * @code{SECONDS}: SECONDS, (?)
215 * @code{SELECTED_INT_KIND}: SELECTED_INT_KIND, Choose integer kind
216 * @code{SELECTED_REAL_KIND}: SELECTED_REAL_KIND, Choose real kind
217 * @code{SET_EXPONENT}: SET_EXPONENT, Set the exponent of the model
218 * @code{SHAPE}: SHAPE, Determine the shape of an array
219 * @code{SIGN}: SIGN, Sign copying function
220 * @code{SIGNAL}: SIGNAL, Signal handling subroutine (or function)
221 * @code{SIN}: SIN, Sine function
222 * @code{SINH}: SINH, Hyperbolic sine function
223 * @code{SIZE}: SIZE, Function to determine the size of an array
224 * @code{SLEEP}: SLEEP, Sleep for the specified number of seconds
225 * @code{SNGL}: SNGL, Convert double precision real to default real
226 * @code{SPACING}: SPACING, Smallest distance between two numbers of a given type
227 * @code{SPREAD}: SPREAD, Add a dimension to an array
228 * @code{SQRT}: SQRT, Square-root function
229 * @code{SRAND}: SRAND, Reinitialize the random number generator
230 * @code{STAT}: STAT, Get file status
231 * @code{SUM}: SUM, Sum of array elements
232 * @code{SYMLNK}: SYMLNK, Create a symbolic link
233 * @code{SYSTEM}: SYSTEM, Execute a shell command
234 * @code{SYSTEM_CLOCK}: SYSTEM_CLOCK, Time function
235 * @code{TAN}: TAN, Tangent function
236 * @code{TANH}: TANH, Hyperbolic tangent function
237 * @code{TIME}: TIME, Time function
238 * @code{TIME8}: TIME8, Time function (64-bit)
239 * @code{TINY}: TINY, Smallest positive number of a real kind
240 * @code{TRANSFER}: TRANSFER, Transfer bit patterns
241 * @code{TRANSPOSE}: TRANSPOSE, Transpose an array of rank two
242 * @code{TRIM}: TRIM, Function to remove trailing blank characters of a string
243 * @code{TTYNAM}: TTYNAM, Get the name of a terminal device.
244 * @code{UBOUND}: UBOUND, Upper dimension bounds of an array
245 * @code{UMASK}: UMASK, Set the file creation mask
246 * @code{UNLINK}: UNLINK, Remove a file from the file system
247 * @code{UNPACK}: UNPACK, Unpack an array of rank one into an array
248 * @code{VERIFY}: VERIFY, Scan a string for the absence of a set of characters
249 * @code{XOR}: XOR, Bitwise logical exclusive or
252 @node Introduction to Intrinsics
253 @section Introduction to intrinsic procedures
255 The intrinsic procedures provided by GNU Fortran include all of the
256 intrinsic procedures required by the Fortran 95 standard, a set of
257 intrinsic procedures for backwards compatibility with G77, and a small
258 selection of intrinsic procedures from the Fortran 2003 standard. Any
259 conflict between a description here and a description in either the
260 Fortran 95 standard or the Fortran 2003 standard is unintentional, and
261 the standard(s) should be considered authoritative.
263 The enumeration of the @code{KIND} type parameter is processor defined in
264 the Fortran 95 standard. GNU Fortran defines the default integer type and
265 default real type by @code{INTEGER(KIND=4)} and @code{REAL(KIND=4)},
266 respectively. The standard mandates that both data types shall have
267 another kind, which have more precision. On typical target architectures
268 supported by @command{gfortran}, this kind type parameter is @code{KIND=8}.
269 Hence, @code{REAL(KIND=8)} and @code{DOUBLE PRECISION} are equivalent.
270 In the description of generic intrinsic procedures, the kind type parameter
271 will be specified by @code{KIND=*}, and in the description of specific
272 names for an intrinsic procedure the kind type parameter will be explicitly
273 given (e.g., @code{REAL(KIND=4)} or @code{REAL(KIND=8)}). Finally, for
274 brevity the optional @code{KIND=} syntax will be omitted.
276 Many of the intrinsic procedures take one or more optional arguments.
277 This document follows the convention used in the Fortran 95 standard,
278 and denotes such arguments by square brackets.
280 GNU Fortran offers the @option{-std=f95} and @option{-std=gnu} options,
281 which can be used to restrict the set of intrinsic procedures to a
282 given standard. By default, @command{gfortran} sets the @option{-std=gnu}
283 option, and so all intrinsic procedures described here are accepted. There
284 is one caveat. For a select group of intrinsic procedures, @command{g77}
285 implemented both a function and a subroutine. Both classes
286 have been implemented in @command{gfortran} for backwards compatibility
287 with @command{g77}. It is noted here that these functions and subroutines
288 cannot be intermixed in a given subprogram. In the descriptions that follow,
289 the applicable standard for each intrinsic procedure is noted.
294 @section @code{ABORT} --- Abort the program
295 @cindex @code{ABORT} intrinsic
299 @item @emph{Description}:
300 @code{ABORT} causes immediate termination of the program. On operating
301 systems that support a core dump, @code{ABORT} will produce a core dump,
302 which is suitable for debugging purposes.
304 @item @emph{Standard}:
308 Non-elemental subroutine
313 @item @emph{Return value}:
316 @item @emph{Example}:
319 integer :: i = 1, j = 2
320 if (i /= j) call abort
321 end program test_abort
324 @item @emph{See also}:
325 @ref{EXIT}, @ref{KILL}
331 @section @code{ABS} --- Absolute value
332 @cindex @code{ABS} intrinsic
333 @cindex @code{CABS} intrinsic
334 @cindex @code{DABS} intrinsic
335 @cindex @code{IABS} intrinsic
336 @cindex @code{ZABS} intrinsic
337 @cindex @code{CDABS} intrinsic
338 @cindex absolute value
341 @item @emph{Description}:
342 @code{ABS(X)} computes the absolute value of @code{X}.
344 @item @emph{Standard}:
345 F77 and later, has overloads that are GNU extensions
351 @code{RESULT = ABS(X)}
353 @item @emph{Arguments}:
354 @multitable @columnfractions .15 .70
355 @item @var{X} @tab The type of the argument shall be an @code{INTEGER(*)},
356 @code{REAL(*)}, or @code{COMPLEX(*)}.
359 @item @emph{Return value}:
360 The return value is of the same type and
361 kind as the argument except the return value is @code{REAL(*)} for a
362 @code{COMPLEX(*)} argument.
364 @item @emph{Example}:
369 complex :: z = (-1.e0,0.e0)
376 @item @emph{Specific names}:
377 @multitable @columnfractions .20 .20 .20 .25
378 @item Name @tab Argument @tab Return type @tab Standard
379 @item @code{CABS(Z)} @tab @code{COMPLEX(4) Z} @tab @code{REAL(4)} @tab F77 and later
380 @item @code{DABS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
381 @item @code{IABS(I)} @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)} @tab F77 and later
382 @item @code{ZABS(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
383 @item @code{CDABS(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
389 @section @code{ACCESS} --- Checks file access modes
390 @cindex @code{ACCESS}
391 @cindex file system operations
394 @item @emph{Description}:
395 @code{ACCESS(NAME, MODE)} checks whether the file @var{NAME}
396 exists, is readable, writable or executable. Except for the
397 executable check, @code{ACCESS} can be replaced by
398 Fortran 95's @code{INQUIRE}.
400 @item @emph{Standard}:
407 @code{RESULT = ACCESS(NAME, MODE)}
409 @item @emph{Arguments}:
410 @multitable @columnfractions .15 .70
411 @item @var{NAME} @tab Scalar @code{CHARACTER} with the file name.
412 Tailing blank are ignored unless the character @code{achar(0)} is
413 present, then all characters up to and excluding @code{achar(0)} are
415 @item @var{MODE} @tab Scalar @code{CHARACTER} with the file access mode,
416 may be any concatenation of @code{"r"} (readable), @code{"w"} (writable)
417 and @code{"x"} (executable), or @code{" "} to check for existence.
420 @item @emph{Return value}:
421 Returns a scalar @code{INTEGER}, which is @code{0} if the file is
422 accessible in the given mode; otherwise or if an invalid argument
423 has been given for @code{MODE} the value @code{1} is returned.
425 @item @emph{Example}:
429 character(len=*), parameter :: file = 'test.dat'
430 character(len=*), parameter :: file2 = 'test.dat '//achar(0)
431 if(access(file,' ') == 0) print *, trim(file),' is exists'
432 if(access(file,'r') == 0) print *, trim(file),' is readable'
433 if(access(file,'w') == 0) print *, trim(file),' is writable'
434 if(access(file,'x') == 0) print *, trim(file),' is executable'
435 if(access(file2,'rwx') == 0) &
436 print *, trim(file2),' is readable, writable and executable'
437 end program access_test
439 @item @emph{Specific names}:
440 @item @emph{See also}:
446 @section @code{ACHAR} --- Character in @acronym{ASCII} collating sequence
447 @cindex @code{ACHAR} intrinsic
448 @cindex @acronym{ASCII} collating sequence
451 @item @emph{Description}:
452 @code{ACHAR(I)} returns the character located at position @code{I}
453 in the @acronym{ASCII} collating sequence.
455 @item @emph{Standard}:
462 @code{RESULT = ACHAR(I)}
464 @item @emph{Arguments}:
465 @multitable @columnfractions .15 .70
466 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
469 @item @emph{Return value}:
470 The return value is of type @code{CHARACTER} with a length of one. The
471 kind type parameter is the same as @code{KIND('A')}.
473 @item @emph{Example}:
478 end program test_achar
482 See @ref{ICHAR} for a discussion of converting between numerical values
483 and formatted string representations.
485 @item @emph{See also}:
486 @ref{CHAR}, @ref{IACHAR}, @ref{ICHAR}
493 @section @code{ACOS} --- Arccosine function
494 @cindex @code{ACOS} intrinsic
495 @cindex @code{DACOS} intrinsic
496 @cindex trigonometric functions (inverse)
499 @item @emph{Description}:
500 @code{ACOS(X)} computes the arccosine of @var{X} (inverse of @code{COS(X)}).
502 @item @emph{Standard}:
509 @code{RESULT = ACOS(X)}
511 @item @emph{Arguments}:
512 @multitable @columnfractions .15 .70
513 @item @var{X} @tab The type shall be @code{REAL(*)} with a magnitude that is
517 @item @emph{Return value}:
518 The return value is of type @code{REAL(*)} and it lies in the
519 range @math{ 0 \leq \acos(x) \leq \pi}. The kind type parameter
520 is the same as @var{X}.
522 @item @emph{Example}:
525 real(8) :: x = 0.866_8
527 end program test_acos
530 @item @emph{Specific names}:
531 @multitable @columnfractions .20 .20 .20 .25
532 @item Name @tab Argument @tab Return type @tab Standard
533 @item @code{DACOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
536 @item @emph{See also}:
537 Inverse function: @ref{COS}
543 @section @code{ACOSH} --- Hyperbolic arccosine function
544 @cindex @code{ACOSH} intrinsic
545 @cindex hyperbolic arccosine
546 @cindex hyperbolic cosine (inverse)
549 @item @emph{Description}:
550 @code{ACOSH(X)} computes the area hyperbolic cosine of @var{X} (inverse of @code{COSH(X)}).
552 @item @emph{Standard}:
559 @code{RESULT = ACOSH(X)}
561 @item @emph{Arguments}:
562 @multitable @columnfractions .15 .70
563 @item @var{X} @tab The type shall be @code{REAL(*)} with a magnitude that is
564 greater or equal to one.
567 @item @emph{Return value}:
568 The return value is of type @code{REAL(*)} and it lies in the
569 range @math{0 \leq \acosh (x) \leq \infty}.
571 @item @emph{Example}:
574 REAL(8), DIMENSION(3) :: x = (/ 1.0, 2.0, 3.0 /)
579 @item @emph{See also}:
580 Inverse function: @ref{COSH}
586 @section @code{ADJUSTL} --- Left adjust a string
587 @cindex @code{ADJUSTL} intrinsic
588 @cindex adjust string
591 @item @emph{Description}:
592 @code{ADJUSTL(STR)} will left adjust a string by removing leading spaces.
593 Spaces are inserted at the end of the string as needed.
595 @item @emph{Standard}:
602 @code{RESULT = ADJUSTL(STR)}
604 @item @emph{Arguments}:
605 @multitable @columnfractions .15 .70
606 @item @var{STR} @tab The type shall be @code{CHARACTER}.
609 @item @emph{Return value}:
610 The return value is of type @code{CHARACTER} where leading spaces
611 are removed and the same number of spaces are inserted on the end
614 @item @emph{Example}:
617 character(len=20) :: str = ' gfortran'
620 end program test_adjustl
627 @section @code{ADJUSTR} --- Right adjust a string
628 @cindex @code{ADJUSTR} intrinsic
629 @cindex adjust string
632 @item @emph{Description}:
633 @code{ADJUSTR(STR)} will right adjust a string by removing trailing spaces.
634 Spaces are inserted at the start of the string as needed.
636 @item @emph{Standard}:
643 @code{RESULT = ADJUSTR(STR)}
645 @item @emph{Arguments}:
646 @multitable @columnfractions .15 .70
647 @item @var{STR} @tab The type shall be @code{CHARACTER}.
650 @item @emph{Return value}:
651 The return value is of type @code{CHARACTER} where trailing spaces
652 are removed and the same number of spaces are inserted at the start
655 @item @emph{Example}:
658 character(len=20) :: str = 'gfortran'
661 end program test_adjustr
668 @section @code{AIMAG} --- Imaginary part of complex number
669 @cindex @code{AIMAG} intrinsic
670 @cindex @code{DIMAG} intrinsic
671 @cindex @code{IMAG} intrinsic
672 @cindex @code{IMAGPART} intrinsic
673 @cindex imaginary part of a complex number
676 @item @emph{Description}:
677 @code{AIMAG(Z)} yields the imaginary part of complex argument @code{Z}.
678 The @code{IMAG(Z)} and @code{IMAGPART(Z)} intrinsic functions are provided
679 for compatibility with @command{g77}, and their use in new code is
680 strongly discouraged.
682 @item @emph{Standard}:
683 F77 and later, has overloads that are GNU extensions
689 @code{RESULT = AIMAG(Z)}
691 @item @emph{Arguments}:
692 @multitable @columnfractions .15 .70
693 @item @var{Z} @tab The type of the argument shall be @code{COMPLEX(*)}.
696 @item @emph{Return value}:
697 The return value is of type real with the
698 kind type parameter of the argument.
700 @item @emph{Example}:
705 z4 = cmplx(1.e0_4, 0.e0_4)
706 z8 = cmplx(0.e0_8, 1.e0_8)
707 print *, aimag(z4), dimag(z8)
708 end program test_aimag
711 @item @emph{Specific names}:
712 @multitable @columnfractions .20 .20 .20 .25
713 @item Name @tab Argument @tab Return type @tab Standard
714 @item @code{DIMAG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{REAL(8)} @tab GNU extension
715 @item @code{IMAG(Z)} @tab @code{COMPLEX(*) Z} @tab @code{REAL(*)} @tab GNU extension
716 @item @code{IMAGPART(Z)} @tab @code{COMPLEX(*) Z} @tab @code{REAL(*)} @tab GNU extension
723 @section @code{AINT} --- Truncate to a whole number
724 @cindex @code{AINT} intrinsic
725 @cindex @code{DINT} intrinsic
729 @item @emph{Description}:
730 @code{AINT(X [, KIND])} truncates its argument to a whole number.
732 @item @emph{Standard}:
739 @code{RESULT = AINT(X [, KIND])}
741 @item @emph{Arguments}:
742 @multitable @columnfractions .15 .70
743 @item @var{X} @tab The type of the argument shall be @code{REAL(*)}.
744 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
745 expression indicating the kind parameter of
749 @item @emph{Return value}:
750 The return value is of type real with the kind type parameter of the
751 argument if the optional @var{KIND} is absent; otherwise, the kind
752 type parameter will be given by @var{KIND}. If the magnitude of
753 @var{X} is less than one, then @code{AINT(X)} returns zero. If the
754 magnitude is equal to or greater than one, then it returns the largest
755 whole number that does not exceed its magnitude. The sign is the same
756 as the sign of @var{X}.
758 @item @emph{Example}:
765 print *, aint(x4), dint(x8)
767 end program test_aint
770 @item @emph{Specific names}:
771 @multitable @columnfractions .20 .20 .20 .25
772 @item Name @tab Argument @tab Return type @tab Standard
773 @item @code{DINT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
780 @section @code{ALARM} --- Execute a routine after a given delay
781 @cindex @code{ALARM} intrinsic
784 @item @emph{Description}:
785 @code{ALARM(SECONDS, HANDLER [, STATUS])} causes external subroutine @var{HANDLER}
786 to be executed after a delay of @var{SECONDS} by using @code{alarm(2)} to
787 set up a signal and @code{signal(2)} to catch it. If @var{STATUS} is
788 supplied, it will be returned with the number of seconds remaining until
789 any previously scheduled alarm was due to be delivered, or zero if there
790 was no previously scheduled alarm.
792 @item @emph{Standard}:
799 @code{CALL ALARM(SECONDS, HANDLER [, STATUS])}
801 @item @emph{Arguments}:
802 @multitable @columnfractions .15 .70
803 @item @var{SECONDS} @tab The type of the argument shall be a scalar
804 @code{INTEGER}. It is @code{INTENT(IN)}.
805 @item @var{HANDLER} @tab Signal handler (@code{INTEGER FUNCTION} or
806 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar. The scalar
807 values may be either @code{SIG_IGN=1} to ignore the alarm generated
808 or @code{SIG_DFL=0} to set the default action. It is @code{INTENT(IN)}.
809 @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
810 variable of the default @code{INTEGER} kind. It is @code{INTENT(OUT)}.
813 @item @emph{Example}:
816 external handler_print
818 call alarm (3, handler_print, i)
821 end program test_alarm
823 This will cause the external routine @var{handler_print} to be called
830 @section @code{ALL} --- All values in @var{MASK} along @var{DIM} are true
831 @cindex @code{ALL} intrinsic
835 @item @emph{Description}:
836 @code{ALL(MASK [, DIM])} determines if all the values are true in @var{MASK}
837 in the array along dimension @var{DIM}.
839 @item @emph{Standard}:
843 transformational function
846 @code{RESULT = ALL(MASK [, DIM])}
848 @item @emph{Arguments}:
849 @multitable @columnfractions .15 .70
850 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL(*)} and
851 it shall not be scalar.
852 @item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer
853 with a value that lies between one and the rank of @var{MASK}.
856 @item @emph{Return value}:
857 @code{ALL(MASK)} returns a scalar value of type @code{LOGICAL(*)} where
858 the kind type parameter is the same as the kind type parameter of
859 @var{MASK}. If @var{DIM} is present, then @code{ALL(MASK, DIM)} returns
860 an array with the rank of @var{MASK} minus 1. The shape is determined from
861 the shape of @var{MASK} where the @var{DIM} dimension is elided.
865 @code{ALL(MASK)} is true if all elements of @var{MASK} are true.
866 It also is true if @var{MASK} has zero size; otherwise, it is false.
868 If the rank of @var{MASK} is one, then @code{ALL(MASK,DIM)} is equivalent
869 to @code{ALL(MASK)}. If the rank is greater than one, then @code{ALL(MASK,DIM)}
870 is determined by applying @code{ALL} to the array sections.
873 @item @emph{Example}:
877 l = all((/.true., .true., .true./))
882 integer a(2,3), b(2,3)
886 print *, all(a .eq. b, 1)
887 print *, all(a .eq. b, 2)
888 end subroutine section
896 @section @code{ALLOCATED} --- Status of an allocatable entity
897 @cindex @code{ALLOCATED} intrinsic
898 @cindex allocation status
901 @item @emph{Description}:
902 @code{ALLOCATED(X)} checks the status of whether @var{X} is allocated.
904 @item @emph{Standard}:
911 @code{RESULT = ALLOCATED(X)}
913 @item @emph{Arguments}:
914 @multitable @columnfractions .15 .70
915 @item @var{X} @tab The argument shall be an @code{ALLOCATABLE} array.
918 @item @emph{Return value}:
919 The return value is a scalar @code{LOGICAL} with the default logical
920 kind type parameter. If @var{X} is allocated, @code{ALLOCATED(X)}
921 is @code{.TRUE.}; otherwise, it returns the @code{.TRUE.}
923 @item @emph{Example}:
925 program test_allocated
927 real(4), allocatable :: x(:)
928 if (allocated(x) .eqv. .false.) allocate(x(i))
929 end program test_allocated
935 @section @code{AND} --- Bitwise logical AND
936 @cindex @code{AND} intrinsic
937 @cindex bit operations
940 @item @emph{Description}:
941 Bitwise logical @code{AND}.
943 This intrinsic routine is provided for backwards compatibility with
944 GNU Fortran 77. For integer arguments, programmers should consider
945 the use of the @ref{IAND} intrinsic defined by the Fortran standard.
947 @item @emph{Standard}:
951 Non-elemental function
954 @code{RESULT = AND(I, J)}
956 @item @emph{Arguments}:
957 @multitable @columnfractions .15 .70
958 @item @var{I} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
959 @item @var{J} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
962 @item @emph{Return value}:
963 The return type is either @code{INTEGER(*)} or @code{LOGICAL} after
964 cross-promotion of the arguments.
966 @item @emph{Example}:
969 LOGICAL :: T = .TRUE., F = ..FALSE.
971 DATA a / Z'F' /, b / Z'3' /
973 WRITE (*,*) AND(T, T), AND(T, F), AND(F, T), AND(F, F)
974 WRITE (*,*) AND(a, b)
978 @item @emph{See also}:
979 F95 elemental function: @ref{IAND}
985 @section @code{ANINT} --- Nearest whole number
986 @cindex @code{ANINT} intrinsic
987 @cindex @code{DNINT} intrinsic
991 @item @emph{Description}:
992 @code{ANINT(X [, KIND])} rounds its argument to the nearest whole number.
994 @item @emph{Standard}:
1000 @item @emph{Syntax}:
1001 @code{RESULT = ANINT(X [, KIND])}
1003 @item @emph{Arguments}:
1004 @multitable @columnfractions .15 .70
1005 @item @var{X} @tab The type of the argument shall be @code{REAL(*)}.
1006 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
1007 expression indicating the kind parameter of
1011 @item @emph{Return value}:
1012 The return value is of type real with the kind type parameter of the
1013 argument if the optional @var{KIND} is absent; otherwise, the kind
1014 type parameter will be given by @var{KIND}. If @var{X} is greater than
1015 zero, then @code{ANINT(X)} returns @code{AINT(X+0.5)}. If @var{X} is
1016 less than or equal to zero, then it returns @code{AINT(X-0.5)}.
1018 @item @emph{Example}:
1025 print *, anint(x4), dnint(x8)
1027 end program test_anint
1030 @item @emph{Specific names}:
1031 @multitable @columnfractions .20 .20 .20 .25
1032 @item Name @tab Argument @tab Return type @tab Standard
1033 @item @code{DNINT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1040 @section @code{ANY} --- Any value in @var{MASK} along @var{DIM} is true
1041 @cindex @code{ANY} intrinsic
1045 @item @emph{Description}:
1046 @code{ANY(MASK [, DIM])} determines if any of the values in the logical array
1047 @var{MASK} along dimension @var{DIM} are @code{.TRUE.}.
1049 @item @emph{Standard}:
1053 transformational function
1055 @item @emph{Syntax}:
1056 @code{RESULT = ANY(MASK [, DIM])}
1058 @item @emph{Arguments}:
1059 @multitable @columnfractions .15 .70
1060 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL(*)} and
1061 it shall not be scalar.
1062 @item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer
1063 with a value that lies between one and the rank of @var{MASK}.
1066 @item @emph{Return value}:
1067 @code{ANY(MASK)} returns a scalar value of type @code{LOGICAL(*)} where
1068 the kind type parameter is the same as the kind type parameter of
1069 @var{MASK}. If @var{DIM} is present, then @code{ANY(MASK, DIM)} returns
1070 an array with the rank of @var{MASK} minus 1. The shape is determined from
1071 the shape of @var{MASK} where the @var{DIM} dimension is elided.
1075 @code{ANY(MASK)} is true if any element of @var{MASK} is true;
1076 otherwise, it is false. It also is false if @var{MASK} has zero size.
1078 If the rank of @var{MASK} is one, then @code{ANY(MASK,DIM)} is equivalent
1079 to @code{ANY(MASK)}. If the rank is greater than one, then @code{ANY(MASK,DIM)}
1080 is determined by applying @code{ANY} to the array sections.
1083 @item @emph{Example}:
1087 l = any((/.true., .true., .true./))
1092 integer a(2,3), b(2,3)
1096 print *, any(a .eq. b, 1)
1097 print *, any(a .eq. b, 2)
1098 end subroutine section
1099 end program test_any
1106 @section @code{ASIN} --- Arcsine function
1107 @cindex @code{ASIN} intrinsic
1108 @cindex @code{DASIN} intrinsic
1109 @cindex trigonometric functions (inverse)
1112 @item @emph{Description}:
1113 @code{ASIN(X)} computes the arcsine of its @var{X} (inverse of @code{SIN(X)}).
1115 @item @emph{Standard}:
1121 @item @emph{Syntax}:
1122 @code{RESULT = ASIN(X)}
1124 @item @emph{Arguments}:
1125 @multitable @columnfractions .15 .70
1126 @item @var{X} @tab The type shall be @code{REAL(*)}, and a magnitude that is
1130 @item @emph{Return value}:
1131 The return value is of type @code{REAL(*)} and it lies in the
1132 range @math{-\pi / 2 \leq \asin (x) \leq \pi / 2}. The kind type
1133 parameter is the same as @var{X}.
1135 @item @emph{Example}:
1138 real(8) :: x = 0.866_8
1140 end program test_asin
1143 @item @emph{Specific names}:
1144 @multitable @columnfractions .20 .20 .20 .25
1145 @item Name @tab Argument @tab Return type @tab Standard
1146 @item @code{DASIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1149 @item @emph{See also}:
1150 Inverse function: @ref{SIN}
1156 @section @code{ASINH} --- Hyperbolic arcsine function
1157 @cindex @code{ASINH} intrinsic
1158 @cindex hyperbolic arcsine
1159 @cindex hyperbolic sine (inverse)
1162 @item @emph{Description}:
1163 @code{ASINH(X)} computes the area hyperbolic sine of @var{X} (inverse of @code{SINH(X)}).
1165 @item @emph{Standard}:
1171 @item @emph{Syntax}:
1172 @code{RESULT = ASINH(X)}
1174 @item @emph{Arguments}:
1175 @multitable @columnfractions .15 .70
1176 @item @var{X} @tab The type shall be @code{REAL(*)}, with @var{X} a real number.
1179 @item @emph{Return value}:
1180 The return value is of type @code{REAL(*)} and it lies in the
1181 range @math{-\infty \leq \asinh (x) \leq \infty}.
1183 @item @emph{Example}:
1186 REAL(8), DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1187 WRITE (*,*) ASINH(x)
1191 @item @emph{See also}:
1192 Inverse function: @ref{SINH}
1198 @section @code{ASSOCIATED} --- Status of a pointer or pointer/target pair
1199 @cindex @code{ASSOCIATED} intrinsic
1200 @cindex pointer status
1203 @item @emph{Description}:
1204 @code{ASSOCIATED(PTR [, TGT])} determines the status of the pointer @var{PTR}
1205 or if @var{PTR} is associated with the target @var{TGT}.
1207 @item @emph{Standard}:
1213 @item @emph{Syntax}:
1214 @code{RESULT = ASSOCIATED(PTR [, TGT])}
1216 @item @emph{Arguments}:
1217 @multitable @columnfractions .15 .70
1218 @item @var{PTR} @tab @var{PTR} shall have the @code{POINTER} attribute and
1219 it can be of any type.
1220 @item @var{TGT} @tab (Optional) @var{TGT} shall be a @code{POINTER} or
1221 a @code{TARGET}. It must have the same type, kind type parameter, and
1222 array rank as @var{PTR}.
1224 The status of neither @var{PTR} nor @var{TGT} can be undefined.
1226 @item @emph{Return value}:
1227 @code{ASSOCIATED(PTR)} returns a scalar value of type @code{LOGICAL(4)}.
1228 There are several cases:
1230 @item (A) If the optional @var{TGT} is not present, then @code{ASSOCIATED(PTR)}
1231 is true if @var{PTR} is associated with a target; otherwise, it returns false.
1232 @item (B) If @var{TGT} is present and a scalar target, the result is true if
1234 is not a 0 sized storage sequence and the target associated with @var{PTR}
1235 occupies the same storage units. If @var{PTR} is disassociated, then the
1237 @item (C) If @var{TGT} is present and an array target, the result is true if
1238 @var{TGT} and @var{PTR} have the same shape, are not 0 sized arrays, are
1239 arrays whose elements are not 0 sized storage sequences, and @var{TGT} and
1240 @var{PTR} occupy the same storage units in array element order.
1241 As in case(B), the result is false, if @var{PTR} is disassociated.
1242 @item (D) If @var{TGT} is present and an scalar pointer, the result is true if
1243 target associated with @var{PTR} and the target associated with @var{TGT}
1244 are not 0 sized storage sequences and occupy the same storage units.
1245 The result is false, if either @var{TGT} or @var{PTR} is disassociated.
1246 @item (E) If @var{TGT} is present and an array pointer, the result is true if
1247 target associated with @var{PTR} and the target associated with @var{TGT}
1248 have the same shape, are not 0 sized arrays, are arrays whose elements are
1249 not 0 sized storage sequences, and @var{TGT} and @var{PTR} occupy the same
1250 storage units in array element order.
1251 The result is false, if either @var{TGT} or @var{PTR} is disassociated.
1254 @item @emph{Example}:
1256 program test_associated
1258 real, target :: tgt(2) = (/1., 2./)
1259 real, pointer :: ptr(:)
1261 if (associated(ptr) .eqv. .false.) call abort
1262 if (associated(ptr,tgt) .eqv. .false.) call abort
1263 end program test_associated
1266 @item @emph{See also}:
1273 @section @code{ATAN} --- Arctangent function
1274 @cindex @code{ATAN} intrinsic
1275 @cindex @code{DATAN} intrinsic
1276 @cindex trigonometric functions (inverse)
1279 @item @emph{Description}:
1280 @code{ATAN(X)} computes the arctangent of @var{X}.
1282 @item @emph{Standard}:
1288 @item @emph{Syntax}:
1289 @code{RESULT = ATAN(X)}
1291 @item @emph{Arguments}:
1292 @multitable @columnfractions .15 .70
1293 @item @var{X} @tab The type shall be @code{REAL(*)}.
1296 @item @emph{Return value}:
1297 The return value is of type @code{REAL(*)} and it lies in the
1298 range @math{ - \pi / 2 \leq \atan (x) \leq \pi / 2}.
1300 @item @emph{Example}:
1303 real(8) :: x = 2.866_8
1305 end program test_atan
1308 @item @emph{Specific names}:
1309 @multitable @columnfractions .20 .20 .20 .25
1310 @item Name @tab Argument @tab Return type @tab Standard
1311 @item @code{DATAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1314 @item @emph{See also}:
1315 Inverse function: @ref{TAN}
1322 @section @code{ATAN2} --- Arctangent function
1323 @cindex @code{ATAN2} intrinsic
1324 @cindex @code{DATAN2} intrinsic
1325 @cindex trigonometric functions (inverse)
1328 @item @emph{Description}:
1329 @code{ATAN2(Y,X)} computes the arctangent of the complex number @math{X + i Y}.
1331 @item @emph{Standard}:
1337 @item @emph{Syntax}:
1338 @code{RESULT = ATAN2(Y,X)}
1340 @item @emph{Arguments}:
1341 @multitable @columnfractions .15 .70
1342 @item @var{Y} @tab The type shall be @code{REAL(*)}.
1343 @item @var{X} @tab The type and kind type parameter shall be the same as @var{Y}.
1344 If @var{Y} is zero, then @var{X} must be nonzero.
1347 @item @emph{Return value}:
1348 The return value has the same type and kind type parameter as @var{Y}.
1349 It is the principal value of the complex number @math{X + i Y}. If
1350 @var{X} is nonzero, then it lies in the range @math{-\pi \le \atan (x) \leq \pi}.
1351 The sign is positive if @var{Y} is positive. If @var{Y} is zero, then
1352 the return value is zero if @var{X} is positive and @math{\pi} if @var{X}
1353 is negative. Finally, if @var{X} is zero, then the magnitude of the result
1356 @item @emph{Example}:
1359 real(4) :: x = 1.e0_4, y = 0.5e0_4
1361 end program test_atan2
1364 @item @emph{Specific names}:
1365 @multitable @columnfractions .20 .20 .20 .25
1366 @item Name @tab Argument @tab Return type @tab Standard
1367 @item @code{DATAN2(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1374 @section @code{ATANH} --- Hyperbolic arctangent function
1375 @cindex @code{ASINH} intrinsic
1376 @cindex hyperbolic arctangent
1377 @cindex hyperbolic tangent (inverse)
1380 @item @emph{Description}:
1381 @code{ATANH(X)} computes the area hyperbolic sine of @var{X} (inverse of @code{TANH(X)}).
1383 @item @emph{Standard}:
1389 @item @emph{Syntax}:
1390 @code{RESULT = ATANH(X)}
1392 @item @emph{Arguments}:
1393 @multitable @columnfractions .15 .70
1394 @item @var{X} @tab The type shall be @code{REAL(*)} with a magnitude
1395 that is less than or equal to one.
1398 @item @emph{Return value}:
1399 The return value is of type @code{REAL(*)} and it lies in the
1400 range @math{-\infty \leq \atanh(x) \leq \infty}.
1402 @item @emph{Example}:
1405 REAL, DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1406 WRITE (*,*) ATANH(x)
1410 @item @emph{See also}:
1411 Inverse function: @ref{TANH}
1418 @section @code{BESJ0} --- Bessel function of the first kind of order 0
1419 @cindex @code{BESJ0} intrinsic
1420 @cindex @code{DBESJ0} intrinsic
1424 @item @emph{Description}:
1425 @code{BESJ0(X)} computes the Bessel function of the first kind of order 0
1428 @item @emph{Standard}:
1434 @item @emph{Syntax}:
1435 @code{RESULT = BESJ0(X)}
1437 @item @emph{Arguments}:
1438 @multitable @columnfractions .15 .70
1439 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1442 @item @emph{Return value}:
1443 The return value is of type @code{REAL(*)} and it lies in the
1444 range @math{ - 0.4027... \leq Bessel (0,x) \leq 1}.
1446 @item @emph{Example}:
1449 real(8) :: x = 0.0_8
1451 end program test_besj0
1454 @item @emph{Specific names}:
1455 @multitable @columnfractions .20 .20 .20 .25
1456 @item Name @tab Argument @tab Return type @tab Standard
1457 @item @code{DBESJ0(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1464 @section @code{BESJ1} --- Bessel function of the first kind of order 1
1465 @cindex @code{BESJ1} intrinsic
1466 @cindex @code{DBESJ1} intrinsic
1470 @item @emph{Description}:
1471 @code{BESJ1(X)} computes the Bessel function of the first kind of order 1
1474 @item @emph{Standard}:
1480 @item @emph{Syntax}:
1481 @code{RESULT = BESJ1(X)}
1483 @item @emph{Arguments}:
1484 @multitable @columnfractions .15 .70
1485 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1488 @item @emph{Return value}:
1489 The return value is of type @code{REAL(*)} and it lies in the
1490 range @math{ - 0.5818... \leq Bessel (0,x) \leq 0.5818 }.
1492 @item @emph{Example}:
1495 real(8) :: x = 1.0_8
1497 end program test_besj1
1500 @item @emph{Specific names}:
1501 @multitable @columnfractions .20 .20 .20 .25
1502 @item Name @tab Argument @tab Return type @tab Standard
1503 @item @code{DBESJ1(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1510 @section @code{BESJN} --- Bessel function of the first kind
1511 @cindex @code{BESJN} intrinsic
1512 @cindex @code{DBESJN} intrinsic
1516 @item @emph{Description}:
1517 @code{BESJN(N, X)} computes the Bessel function of the first kind of order
1520 @item @emph{Standard}:
1526 @item @emph{Syntax}:
1527 @code{RESULT = BESJN(N, X)}
1529 @item @emph{Arguments}:
1530 @multitable @columnfractions .15 .70
1531 @item @var{N} @tab The type shall be @code{INTEGER(*)}, and it shall be scalar.
1532 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1535 @item @emph{Return value}:
1536 The return value is a scalar of type @code{REAL(*)}.
1538 @item @emph{Example}:
1541 real(8) :: x = 1.0_8
1543 end program test_besjn
1546 @item @emph{Specific names}:
1547 @multitable @columnfractions .20 .20 .20 .25
1548 @item Name @tab Argument @tab Return type @tab Standard
1549 @item @code{DBESJN(X)} @tab @code{INTEGER(*) N} @tab @code{REAL(8)} @tab GNU extension
1550 @item @tab @code{REAL(8) X} @tab @tab
1557 @section @code{BESY0} --- Bessel function of the second kind of order 0
1558 @cindex @code{BESY0} intrinsic
1559 @cindex @code{DBESY0} intrinsic
1563 @item @emph{Description}:
1564 @code{BESY0(X)} computes the Bessel function of the second kind of order 0
1567 @item @emph{Standard}:
1573 @item @emph{Syntax}:
1574 @code{RESULT = BESY0(X)}
1576 @item @emph{Arguments}:
1577 @multitable @columnfractions .15 .70
1578 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1581 @item @emph{Return value}:
1582 The return value is a scalar of type @code{REAL(*)}.
1584 @item @emph{Example}:
1587 real(8) :: x = 0.0_8
1589 end program test_besy0
1592 @item @emph{Specific names}:
1593 @multitable @columnfractions .20 .20 .20 .25
1594 @item Name @tab Argument @tab Return type @tab Standard
1595 @item @code{DBESY0(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1602 @section @code{BESY1} --- Bessel function of the second kind of order 1
1603 @cindex @code{BESY1} intrinsic
1604 @cindex @code{DBESY1} intrinsic
1608 @item @emph{Description}:
1609 @code{BESY1(X)} computes the Bessel function of the second kind of order 1
1612 @item @emph{Standard}:
1618 @item @emph{Syntax}:
1619 @code{RESULT = BESY1(X)}
1621 @item @emph{Arguments}:
1622 @multitable @columnfractions .15 .70
1623 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1626 @item @emph{Return value}:
1627 The return value is a scalar of type @code{REAL(*)}.
1629 @item @emph{Example}:
1632 real(8) :: x = 1.0_8
1634 end program test_besy1
1637 @item @emph{Specific names}:
1638 @multitable @columnfractions .20 .20 .20 .25
1639 @item Name @tab Argument @tab Return type @tab Standard
1640 @item @code{DBESY1(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1647 @section @code{BESYN} --- Bessel function of the second kind
1648 @cindex @code{BESYN} intrinsic
1649 @cindex @code{DBESYN} intrinsic
1653 @item @emph{Description}:
1654 @code{BESYN(N, X)} computes the Bessel function of the second kind of order
1657 @item @emph{Standard}:
1663 @item @emph{Syntax}:
1664 @code{RESULT = BESYN(N, X)}
1666 @item @emph{Arguments}:
1667 @multitable @columnfractions .15 .70
1668 @item @var{N} @tab The type shall be @code{INTEGER(*)}, and it shall be scalar.
1669 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1672 @item @emph{Return value}:
1673 The return value is a scalar of type @code{REAL(*)}.
1675 @item @emph{Example}:
1678 real(8) :: x = 1.0_8
1680 end program test_besyn
1683 @item @emph{Specific names}:
1684 @multitable @columnfractions .20 .20 .20 .25
1685 @item Name @tab Argument @tab Return type @tab Standard
1686 @item @code{DBESYN(N,X)} @tab @code{INTEGER(*) N} @tab @code{REAL(8)} @tab GNU extension
1687 @item @tab @code{REAL(8) X} @tab @tab
1694 @section @code{BIT_SIZE} --- Bit size inquiry function
1695 @cindex @code{BIT_SIZE} intrinsic
1696 @cindex bit size of a variable
1697 @cindex size of a variable, in bits
1700 @item @emph{Description}:
1701 @code{BIT_SIZE(I)} returns the number of bits (integer precision plus sign bit)
1702 represented by the type of @var{I}.
1704 @item @emph{Standard}:
1710 @item @emph{Syntax}:
1711 @code{RESULT = BIT_SIZE(I)}
1713 @item @emph{Arguments}:
1714 @multitable @columnfractions .15 .70
1715 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1718 @item @emph{Return value}:
1719 The return value is of type @code{INTEGER(*)}
1721 @item @emph{Example}:
1723 program test_bit_size
1728 end program test_bit_size
1735 @section @code{BTEST} --- Bit test function
1736 @cindex @code{BTEST} intrinsic
1737 @cindex bit operations
1740 @item @emph{Description}:
1741 @code{BTEST(I,POS)} returns logical @code{.TRUE.} if the bit at @var{POS}
1744 @item @emph{Standard}:
1750 @item @emph{Syntax}:
1751 @code{RESULT = BTEST(I, POS)}
1753 @item @emph{Arguments}:
1754 @multitable @columnfractions .15 .70
1755 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1756 @item @var{POS} @tab The type shall be @code{INTEGER(*)}.
1759 @item @emph{Return value}:
1760 The return value is of type @code{LOGICAL}
1762 @item @emph{Example}:
1765 integer :: i = 32768 + 1024 + 64
1769 bool = btest(i, pos)
1772 end program test_btest
1779 @section @code{CEILING} --- Integer ceiling function
1780 @cindex @code{CEILING} intrinsic
1784 @item @emph{Description}:
1785 @code{CEILING(X)} returns the least integer greater than or equal to @var{X}.
1787 @item @emph{Standard}:
1793 @item @emph{Syntax}:
1794 @code{RESULT = CEILING(X [, KIND])}
1796 @item @emph{Arguments}:
1797 @multitable @columnfractions .15 .70
1798 @item @var{X} @tab The type shall be @code{REAL(*)}.
1799 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
1800 expression indicating the kind parameter of
1804 @item @emph{Return value}:
1805 The return value is of type @code{INTEGER(KIND)}
1807 @item @emph{Example}:
1809 program test_ceiling
1812 print *, ceiling(x) ! returns 64
1813 print *, ceiling(y) ! returns -63
1814 end program test_ceiling
1817 @item @emph{See also}:
1818 @ref{FLOOR}, @ref{NINT}
1825 @section @code{CHAR} --- Character conversion function
1826 @cindex @code{CHAR} intrinsic
1827 @cindex conversion function (character)
1830 @item @emph{Description}:
1831 @code{CHAR(I [, KIND])} returns the character represented by the integer @var{I}.
1833 @item @emph{Standard}:
1839 @item @emph{Syntax}:
1840 @code{RESULT = CHAR(I [, KIND])}
1842 @item @emph{Arguments}:
1843 @multitable @columnfractions .15 .70
1844 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1845 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
1846 expression indicating the kind parameter of
1850 @item @emph{Return value}:
1851 The return value is of type @code{CHARACTER(1)}
1853 @item @emph{Example}:
1859 print *, i, c ! returns 'J'
1860 end program test_char
1864 See @ref{ICHAR} for a discussion of converting between numerical values
1865 and formatted string representations.
1867 @item @emph{See also}:
1868 @ref{ACHAR}, @ref{IACHAR}, @ref{ICHAR}
1874 @section @code{CHDIR} --- Change working directory
1875 @cindex @code{CHDIR} intrinsic
1876 @cindex file system operations
1879 @item @emph{Description}:
1880 Change current working directory to a specified @var{PATH}.
1882 @item @emph{Standard}:
1886 Non-elemental subroutine
1888 @item @emph{Syntax}:
1889 @code{CALL CHDIR(PATH [, STATUS])}
1891 @item @emph{Arguments}:
1892 @multitable @columnfractions .15 .70
1893 @item @var{PATH} @tab The type shall be @code{CHARACTER(*)} and shall
1894 specify a valid path within the file system.
1895 @item @var{STATUS} @tab (Optional) status flag. Returns 0 on success,
1896 a system specific and non-zero error code otherwise.
1899 @item @emph{Example}:
1902 CHARACTER(len=255) :: path
1904 WRITE(*,*) TRIM(path)
1907 WRITE(*,*) TRIM(path)
1911 @item @emph{See also}:
1918 @section @code{CHMOD} --- Change access permissions of files
1919 @cindex @code{CHMOD} intrinsic
1920 @cindex file system operations
1923 @item @emph{Description}:
1924 @code{CHMOD} changes the permissions of a file. This function invokes
1925 @code{/bin/chmod} and might therefore not work on all platforms.
1927 This intrinsic is provided in both subroutine and function forms; however,
1928 only one form can be used in any given program unit.
1930 @item @emph{Standard}:
1934 Subroutine, non-elemental function
1936 @item @emph{Syntax}:
1937 @multitable @columnfractions .80
1938 @item @code{CALL CHMOD(NAME, MODE[, STATUS])}
1939 @item @code{STATUS = CHMOD(NAME, MODE)}
1942 @item @emph{Arguments}:
1943 @multitable @columnfractions .15 .70
1944 @item @var{NAME} @tab Scalar @code{CHARACTER} with the file name.
1945 Trailing blanks are ignored unless the character @code{achar(0)} is
1946 present, then all characters up to and excluding @code{achar(0)} are
1947 used as the file name.
1949 @item @var{MODE} @tab Scalar @code{CHARACTER} giving the file permission.
1950 @var{MODE} uses the same syntax as the @var{MODE} argument of
1953 @item @var{STATUS} @tab (optional) scalar @code{INTEGER}, which is
1954 @code{0} on success and non-zero otherwise.
1957 @item @emph{Return value}:
1958 In either syntax, @var{STATUS} is set to @code{0} on success and non-zero
1961 @item @emph{Example}:
1962 @code{CHMOD} as subroutine
1967 call chmod('test.dat','u+x',status)
1968 print *, 'Status: ', status
1969 end program chmod_test
1971 @code{CHMOD} as non-elemental function:
1976 status = chmod('test.dat','u+x')
1977 print *, 'Status: ', status
1978 end program chmod_test
1985 @section @code{CMPLX} --- Complex conversion function
1986 @cindex @code{CMPLX} intrinsic
1987 @cindex complex numbers, conversion to
1990 @item @emph{Description}:
1991 @code{CMPLX(X [, Y [, KIND]])} returns a complex number where @var{X} is converted to
1992 the real component. If @var{Y} is present it is converted to the imaginary
1993 component. If @var{Y} is not present then the imaginary component is set to
1994 0.0. If @var{X} is complex then @var{Y} must not be present.
1996 @item @emph{Standard}:
2002 @item @emph{Syntax}:
2003 @code{RESULT = CMPLX(X [, Y [, KIND]])}
2005 @item @emph{Arguments}:
2006 @multitable @columnfractions .15 .70
2007 @item @var{X} @tab The type may be @code{INTEGER(*)}, @code{REAL(*)},
2008 or @code{COMPLEX(*)}.
2009 @item @var{Y} @tab (Optional; only allowed if @var{X} is not
2010 @code{COMPLEX(*)}.) May be @code{INTEGER(*)}
2012 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
2013 expression indicating the kind parameter of
2017 @item @emph{Return value}:
2018 The return value is of type @code{COMPLEX(*)}
2020 @item @emph{Example}:
2027 print *, z, cmplx(x)
2028 end program test_cmplx
2034 @node COMMAND_ARGUMENT_COUNT
2035 @section @code{COMMAND_ARGUMENT_COUNT} --- Get number of command line arguments
2036 @cindex @code{COMMAND_ARGUMENT_COUNT} intrinsic
2037 @cindex command-line arguments, to program
2040 @item @emph{Description}:
2041 @code{COMMAND_ARGUMENT_COUNT()} returns the number of arguments passed on the
2042 command line when the containing program was invoked.
2044 @item @emph{Standard}:
2050 @item @emph{Syntax}:
2051 @code{RESULT = COMMAND_ARGUMENT_COUNT()}
2053 @item @emph{Arguments}:
2054 @multitable @columnfractions .15 .70
2058 @item @emph{Return value}:
2059 The return value is of type @code{INTEGER(4)}
2061 @item @emph{Example}:
2063 program test_command_argument_count
2065 count = command_argument_count()
2067 end program test_command_argument_count
2070 @item @emph{See also}:
2071 @ref{GET_COMMAND}, @ref{GET_COMMAND_ARGUMENT}
2075 @section @code{CONJG} --- Complex conjugate function
2076 @cindex @code{CONJG} intrinsic
2077 @cindex @code{DCONJG} intrinsic
2078 @cindex complex conjugate
2080 @item @emph{Description}:
2081 @code{CONJG(Z)} returns the conjugate of @var{Z}. If @var{Z} is @code{(x, y)}
2082 then the result is @code{(x, -y)}
2084 @item @emph{Standard}:
2085 F77 and later, has overloads that are GNU extensions
2090 @item @emph{Syntax}:
2093 @item @emph{Arguments}:
2094 @multitable @columnfractions .15 .70
2095 @item @var{Z} @tab The type shall be @code{COMPLEX(*)}.
2098 @item @emph{Return value}:
2099 The return value is of type @code{COMPLEX(*)}.
2101 @item @emph{Example}:
2104 complex :: z = (2.0, 3.0)
2105 complex(8) :: dz = (2.71_8, -3.14_8)
2110 end program test_conjg
2113 @item @emph{Specific names}:
2114 @multitable @columnfractions .20 .20 .20 .25
2115 @item Name @tab Argument @tab Return type @tab Standard
2116 @item @code{DCONJG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
2123 @section @code{COS} --- Cosine function
2124 @cindex @code{COS} intrinsic
2125 @cindex @code{DCOS} intrinsic
2126 @cindex @code{ZCOS} intrinsic
2127 @cindex @code{CDCOS} intrinsic
2128 @cindex trigonometric functions
2131 @item @emph{Description}:
2132 @code{COS(X)} computes the cosine of @var{X}.
2134 @item @emph{Standard}:
2135 F77 and later, has overloads that are GNU extensions
2140 @item @emph{Syntax}:
2141 @code{RESULT = COS(X)}
2143 @item @emph{Arguments}:
2144 @multitable @columnfractions .15 .70
2145 @item @var{X} @tab The type shall be @code{REAL(*)} or
2149 @item @emph{Return value}:
2150 The return value is of type @code{REAL(*)} and it lies in the
2151 range @math{ -1 \leq \cos (x) \leq 1}. The kind type
2152 parameter is the same as @var{X}.
2154 @item @emph{Example}:
2159 end program test_cos
2162 @item @emph{Specific names}:
2163 @multitable @columnfractions .20 .20 .20 .25
2164 @item Name @tab Argument @tab Return type @tab Standard
2165 @item @code{DCOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
2166 @item @code{CCOS(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab F77 and later
2167 @item @code{ZCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
2168 @item @code{CDCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
2171 @item @emph{See also}:
2172 Inverse function: @ref{ACOS}
2179 @section @code{COSH} --- Hyperbolic cosine function
2180 @cindex @code{COSH} intrinsic
2181 @cindex @code{DCOSH} intrinsic
2182 @cindex hyperbolic cosine
2185 @item @emph{Description}:
2186 @code{COSH(X)} computes the hyperbolic cosine of @var{X}.
2188 @item @emph{Standard}:
2194 @item @emph{Syntax}:
2197 @item @emph{Arguments}:
2198 @multitable @columnfractions .15 .70
2199 @item @var{X} @tab The type shall be @code{REAL(*)}.
2202 @item @emph{Return value}:
2203 The return value is of type @code{REAL(*)} and it is positive
2204 (@math{ \cosh (x) \geq 0 }.
2206 @item @emph{Example}:
2209 real(8) :: x = 1.0_8
2211 end program test_cosh
2214 @item @emph{Specific names}:
2215 @multitable @columnfractions .20 .20 .20 .25
2216 @item Name @tab Argument @tab Return type @tab Standard
2217 @item @code{DCOSH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
2220 @item @emph{See also}:
2221 Inverse function: @ref{ACOSH}
2228 @section @code{COUNT} --- Count function
2229 @cindex @code{COUNT} intrinsic
2233 @item @emph{Description}:
2234 @code{COUNT(MASK [, DIM])} counts the number of @code{.TRUE.} elements of
2235 @var{MASK} along the dimension of @var{DIM}. If @var{DIM} is omitted it is
2236 taken to be @code{1}. @var{DIM} is a scaler of type @code{INTEGER} in the
2237 range of @math{1 /leq DIM /leq n)} where @math{n} is the rank of @var{MASK}.
2239 @item @emph{Standard}:
2243 transformational function
2245 @item @emph{Syntax}:
2246 @code{RESULT = COUNT(MASK [, DIM])}
2248 @item @emph{Arguments}:
2249 @multitable @columnfractions .15 .70
2250 @item @var{MASK} @tab The type shall be @code{LOGICAL}.
2251 @item @var{DIM} @tab The type shall be @code{INTEGER}.
2254 @item @emph{Return value}:
2255 The return value is of type @code{INTEGER} with rank equal to that of
2258 @item @emph{Example}:
2261 integer, dimension(2,3) :: a, b
2262 logical, dimension(2,3) :: mask
2263 a = reshape( (/ 1, 2, 3, 4, 5, 6 /), (/ 2, 3 /))
2264 b = reshape( (/ 0, 7, 3, 4, 5, 8 /), (/ 2, 3 /))
2265 print '(3i3)', a(1,:)
2266 print '(3i3)', a(2,:)
2268 print '(3i3)', b(1,:)
2269 print '(3i3)', b(2,:)
2272 print '(3l3)', mask(1,:)
2273 print '(3l3)', mask(2,:)
2275 print '(3i3)', count(mask)
2277 print '(3i3)', count(mask, 1)
2279 print '(3i3)', count(mask, 2)
2280 end program test_count
2287 @section @code{CPU_TIME} --- CPU elapsed time in seconds
2288 @cindex @code{CPU_TIME} intrinsic
2289 @cindex time, elapsed
2290 @cindex elapsed time
2293 @item @emph{Description}:
2294 Returns a @code{REAL} value representing the elapsed CPU time in seconds. This
2295 is useful for testing segments of code to determine execution time.
2297 @item @emph{Standard}:
2303 @item @emph{Syntax}:
2304 @code{CALL CPU_TIME(TIME)}
2306 @item @emph{Arguments}:
2307 @multitable @columnfractions .15 .70
2308 @item @var{TIME} @tab The type shall be @code{REAL} with @code{INTENT(OUT)}.
2311 @item @emph{Return value}:
2314 @item @emph{Example}:
2316 program test_cpu_time
2317 real :: start, finish
2318 call cpu_time(start)
2319 ! put code to test here
2320 call cpu_time(finish)
2321 print '("Time = ",f6.3," seconds.")',finish-start
2322 end program test_cpu_time
2329 @section @code{CSHIFT} --- Circular shift function
2330 @cindex @code{CSHIFT} intrinsic
2331 @cindex bit operations
2334 @item @emph{Description}:
2335 @code{CSHIFT(ARRAY, SHIFT [, DIM])} performs a circular shift on elements of
2336 @var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is omitted it is
2337 taken to be @code{1}. @var{DIM} is a scaler of type @code{INTEGER} in the
2338 range of @math{1 /leq DIM /leq n)} where @math{n} is the rank of @var{ARRAY}.
2339 If the rank of @var{ARRAY} is one, then all elements of @var{ARRAY} are shifted
2340 by @var{SHIFT} places. If rank is greater than one, then all complete rank one
2341 sections of @var{ARRAY} along the given dimension are shifted. Elements
2342 shifted out one end of each rank one section are shifted back in the other end.
2344 @item @emph{Standard}:
2348 transformational function
2350 @item @emph{Syntax}:
2351 @code{RESULT = CSHIFT(A, SHIFT [, DIM])}
2353 @item @emph{Arguments}:
2354 @multitable @columnfractions .15 .70
2355 @item @var{ARRAY} @tab May be any type, not scaler.
2356 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
2357 @item @var{DIM} @tab The type shall be @code{INTEGER}.
2360 @item @emph{Return value}:
2361 Returns an array of same type and rank as the @var{ARRAY} argument.
2363 @item @emph{Example}:
2366 integer, dimension(3,3) :: a
2367 a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
2368 print '(3i3)', a(1,:)
2369 print '(3i3)', a(2,:)
2370 print '(3i3)', a(3,:)
2371 a = cshift(a, SHIFT=(/1, 2, -1/), DIM=2)
2373 print '(3i3)', a(1,:)
2374 print '(3i3)', a(2,:)
2375 print '(3i3)', a(3,:)
2376 end program test_cshift
2382 @section @code{CTIME} --- Convert a time into a string
2383 @cindex @code{CTIME} intrinsic
2384 @cindex time, conversion function
2387 @item @emph{Description}:
2388 @code{CTIME(T,S)} converts @var{T}, a system time value, such as returned
2389 by @code{TIME8()}, to a string of the form @samp{Sat Aug 19 18:13:14
2390 1995}, and returns that string into @var{S}.
2392 If @code{CTIME} is invoked as a function, it can not be invoked as a
2393 subroutine, and vice versa.
2395 @var{T} is an @code{INTENT(IN)} @code{INTEGER(KIND=8)} variable.
2396 @var{S} is an @code{INTENT(OUT)} @code{CHARACTER} variable.
2398 @item @emph{Standard}:
2404 @item @emph{Syntax}:
2405 @multitable @columnfractions .80
2406 @item @code{CALL CTIME(T,S)}.
2407 @item @code{S = CTIME(T)}, (not recommended).
2410 @item @emph{Arguments}:
2411 @multitable @columnfractions .15 .70
2412 @item @var{S}@tab The type shall be of type @code{CHARACTER}.
2413 @item @var{T}@tab The type shall be of type @code{INTEGER(KIND=8)}.
2416 @item @emph{Return value}:
2417 The converted date and time as a string.
2419 @item @emph{Example}:
2423 character(len=30) :: date
2426 ! Do something, main part of the program
2429 print *, 'Program was started on ', date
2430 end program test_ctime
2433 @item @emph{See Also}:
2434 @ref{GMTIME}, @ref{LTIME}, @ref{TIME}, @ref{TIME8}
2441 @section @code{DATE_AND_TIME} --- Date and time subroutine
2442 @cindex @code{DATE_AND_TIME} intrinsic
2443 @cindex date, current
2444 @cindex current date
2445 @cindex time, current
2446 @cindex current time
2449 @item @emph{Description}:
2450 @code{DATE_AND_TIME(DATE, TIME, ZONE, VALUES)} gets the corresponding date and
2451 time information from the real-time system clock. @var{DATE} is
2452 @code{INTENT(OUT)} and has form ccyymmdd. @var{TIME} is @code{INTENT(OUT)} and
2453 has form hhmmss.sss. @var{ZONE} is @code{INTENT(OUT)} and has form (+-)hhmm,
2454 representing the difference with respect to Coordinated Universal Time (UTC).
2455 Unavailable time and date parameters return blanks.
2457 @var{VALUES} is @code{INTENT(OUT)} and provides the following:
2459 @multitable @columnfractions .15 .30 .40
2460 @item @tab @code{VALUE(1)}: @tab The year
2461 @item @tab @code{VALUE(2)}: @tab The month
2462 @item @tab @code{VALUE(3)}: @tab The day of the month
2463 @item @tab @code{VALUE(4)}: @tab Time difference with UTC in minutes
2464 @item @tab @code{VALUE(5)}: @tab The hour of the day
2465 @item @tab @code{VALUE(6)}: @tab The minutes of the hour
2466 @item @tab @code{VALUE(7)}: @tab The seconds of the minute
2467 @item @tab @code{VALUE(8)}: @tab The milliseconds of the second
2470 @item @emph{Standard}:
2476 @item @emph{Syntax}:
2477 @code{CALL DATE_AND_TIME([DATE, TIME, ZONE, VALUES])}
2479 @item @emph{Arguments}:
2480 @multitable @columnfractions .15 .70
2481 @item @var{DATE} @tab (Optional) The type shall be @code{CHARACTER(8)} or larger.
2482 @item @var{TIME} @tab (Optional) The type shall be @code{CHARACTER(10)} or larger.
2483 @item @var{ZONE} @tab (Optional) The type shall be @code{CHARACTER(5)} or larger.
2484 @item @var{VALUES}@tab (Optional) The type shall be @code{INTEGER(8)}.
2487 @item @emph{Return value}:
2490 @item @emph{Example}:
2492 program test_time_and_date
2493 character(8) :: date
2494 character(10) :: time
2495 character(5) :: zone
2496 integer,dimension(8) :: values
2497 ! using keyword arguments
2498 call date_and_time(date,time,zone,values)
2499 call date_and_time(DATE=date,ZONE=zone)
2500 call date_and_time(TIME=time)
2501 call date_and_time(VALUES=values)
2502 print '(a,2x,a,2x,a)', date, time, zone
2503 print '(8i5))', values
2504 end program test_time_and_date
2511 @section @code{DBLE} --- Double conversion function
2512 @cindex @code{DBLE} intrinsic
2513 @cindex double conversion
2516 @item @emph{Description}:
2517 @code{DBLE(X)} Converts @var{X} to double precision real type.
2519 @item @emph{Standard}:
2525 @item @emph{Syntax}:
2526 @code{RESULT = DBLE(X)}
2528 @item @emph{Arguments}:
2529 @multitable @columnfractions .15 .70
2530 @item @var{X} @tab The type shall be @code{INTEGER(*)}, @code{REAL(*)},
2531 or @code{COMPLEX(*)}.
2534 @item @emph{Return value}:
2535 The return value is of type double precision real.
2537 @item @emph{Example}:
2542 complex :: z = (2.3,1.14)
2543 print *, dble(x), dble(i), dble(z)
2544 end program test_dble
2547 @item @emph{See also}:
2548 @ref{DFLOAT}, @ref{FLOAT}, @ref{REAL}
2554 @section @code{DCMPLX} --- Double complex conversion function
2555 @cindex @code{DCMPLX} intrinsic
2556 @cindex complex numbers, conversion to
2559 @item @emph{Description}:
2560 @code{DCMPLX(X [,Y])} returns a double complex number where @var{X} is
2561 converted to the real component. If @var{Y} is present it is converted to the
2562 imaginary component. If @var{Y} is not present then the imaginary component is
2563 set to 0.0. If @var{X} is complex then @var{Y} must not be present.
2565 @item @emph{Standard}:
2571 @item @emph{Syntax}:
2572 @code{RESULT = DCMPLX(X [, Y])}
2574 @item @emph{Arguments}:
2575 @multitable @columnfractions .15 .70
2576 @item @var{X} @tab The type may be @code{INTEGER(*)}, @code{REAL(*)},
2577 or @code{COMPLEX(*)}.
2578 @item @var{Y} @tab (Optional if @var{X} is not @code{COMPLEX(*)}.) May be
2579 @code{INTEGER(*)} or @code{REAL(*)}.
2582 @item @emph{Return value}:
2583 The return value is of type @code{COMPLEX(8)}
2585 @item @emph{Example}:
2595 print *, dcmplx(x,i)
2596 end program test_dcmplx
2603 @section @code{DFLOAT} --- Double conversion function
2604 @cindex @code{DFLOAT} intrinsic
2605 @cindex double float conversion
2608 @item @emph{Description}:
2609 @code{DFLOAT(X)} Converts @var{X} to double precision real type.
2611 @item @emph{Standard}:
2617 @item @emph{Syntax}:
2618 @code{RESULT = DFLOAT(X)}
2620 @item @emph{Arguments}:
2621 @multitable @columnfractions .15 .70
2622 @item @var{X} @tab The type shall be @code{INTEGER(*)}.
2625 @item @emph{Return value}:
2626 The return value is of type double precision real.
2628 @item @emph{Example}:
2633 end program test_dfloat
2636 @item @emph{See also}:
2637 @ref{DBLE}, @ref{FLOAT}, @ref{REAL}
2643 @section @code{DIGITS} --- Significant digits function
2644 @cindex @code{DIGITS} intrinsic
2645 @cindex digits, significant
2648 @item @emph{Description}:
2649 @code{DIGITS(X)} returns the number of significant digits of the internal model
2650 representation of @var{X}. For example, on a system using a 32-bit
2651 floating point representation, a default real number would likely return 24.
2653 @item @emph{Standard}:
2659 @item @emph{Syntax}:
2660 @code{RESULT = DIGITS(X)}
2662 @item @emph{Arguments}:
2663 @multitable @columnfractions .15 .70
2664 @item @var{X} @tab The type may be @code{INTEGER(*)} or @code{REAL(*)}.
2667 @item @emph{Return value}:
2668 The return value is of type @code{INTEGER}.
2670 @item @emph{Example}:
2673 integer :: i = 12345
2679 end program test_digits
2686 @section @code{DIM} --- Dim function
2687 @cindex @code{DIM} intrinsic
2688 @cindex @code{IDIM} intrinsic
2689 @cindex @code{DDIM} intrinsic
2693 @item @emph{Description}:
2694 @code{DIM(X,Y)} returns the difference @code{X-Y} if the result is positive;
2695 otherwise returns zero.
2697 @item @emph{Standard}:
2703 @item @emph{Syntax}:
2704 @code{RESULT = DIM(X, Y)}
2706 @item @emph{Arguments}:
2707 @multitable @columnfractions .15 .70
2708 @item @var{X} @tab The type shall be @code{INTEGER(*)} or @code{REAL(*)}
2709 @item @var{Y} @tab The type shall be the same type and kind as @var{X}.
2712 @item @emph{Return value}:
2713 The return value is of type @code{INTEGER(*)} or @code{REAL(*)}.
2715 @item @emph{Example}:
2721 x = dim(4.345_8, 2.111_8)
2724 end program test_dim
2727 @item @emph{Specific names}:
2728 @multitable @columnfractions .20 .20 .20 .25
2729 @item Name @tab Argument @tab Return type @tab Standard
2730 @item @code{IDIM(X,Y)} @tab @code{INTEGER(4) X,Y} @tab @code{INTEGER(4)} @tab F77 and later
2731 @item @code{DDIM(X,Y)} @tab @code{REAL(8) X,Y} @tab @code{REAL(8)} @tab F77 and later
2738 @section @code{DOT_PRODUCT} --- Dot product function
2739 @cindex @code{DOT_PRODUCT} intrinsic
2743 @item @emph{Description}:
2744 @code{DOT_PRODUCT(X,Y)} computes the dot product multiplication of two vectors
2745 @var{X} and @var{Y}. The two vectors may be either numeric or logical
2746 and must be arrays of rank one and of equal size. If the vectors are
2747 @code{INTEGER(*)} or @code{REAL(*)}, the result is @code{SUM(X*Y)}. If the
2748 vectors are @code{COMPLEX(*)}, the result is @code{SUM(CONJG(X)*Y)}. If the
2749 vectors are @code{LOGICAL}, the result is @code{ANY(X.AND.Y)}.
2751 @item @emph{Standard}:
2755 transformational function
2757 @item @emph{Syntax}:
2758 @code{RESULT = DOT_PRODUCT(X, Y)}
2760 @item @emph{Arguments}:
2761 @multitable @columnfractions .15 .70
2762 @item @var{X} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
2763 @item @var{Y} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
2766 @item @emph{Return value}:
2767 If the arguments are numeric, the return value is a scaler of numeric type,
2768 @code{INTEGER(*)}, @code{REAL(*)}, or @code{COMPLEX(*)}. If the arguments are
2769 @code{LOGICAL}, the return value is @code{.TRUE.} or @code{.FALSE.}.
2771 @item @emph{Example}:
2773 program test_dot_prod
2774 integer, dimension(3) :: a, b
2781 print *, dot_product(a,b)
2782 end program test_dot_prod
2789 @section @code{DPROD} --- Double product function
2790 @cindex @code{DPROD} intrinsic
2791 @cindex double-precision product
2794 @item @emph{Description}:
2795 @code{DPROD(X,Y)} returns the product @code{X*Y}.
2797 @item @emph{Standard}:
2803 @item @emph{Syntax}:
2804 @code{RESULT = DPROD(X, Y)}
2806 @item @emph{Arguments}:
2807 @multitable @columnfractions .15 .70
2808 @item @var{X} @tab The type shall be @code{REAL}.
2809 @item @var{Y} @tab The type shall be @code{REAL}.
2812 @item @emph{Return value}:
2813 The return value is of type @code{REAL(8)}.
2815 @item @emph{Example}:
2824 end program test_dprod
2831 @section @code{DREAL} --- Double real part function
2832 @cindex @code{DREAL} intrinsic
2833 @cindex double-precision real part
2836 @item @emph{Description}:
2837 @code{DREAL(Z)} returns the real part of complex variable @var{Z}.
2839 @item @emph{Standard}:
2845 @item @emph{Syntax}:
2846 @code{RESULT = DREAL(Z)}
2848 @item @emph{Arguments}:
2849 @multitable @columnfractions .15 .70
2850 @item @var{Z} @tab The type shall be @code{COMPLEX(8)}.
2853 @item @emph{Return value}:
2854 The return value is of type @code{REAL(8)}.
2856 @item @emph{Example}:
2859 complex(8) :: z = (1.3_8,7.2_8)
2861 end program test_dreal
2864 @item @emph{See also}:
2872 @section @code{DTIME} --- Execution time subroutine (or function)
2873 @cindex @code{DTIME} intrinsic
2874 @cindex time, elapsed
2875 @cindex elapsed time
2878 @item @emph{Description}:
2879 @code{DTIME(TARRAY, RESULT)} initially returns the number of seconds of runtime
2880 since the start of the process's execution in @var{RESULT}. @var{TARRAY}
2881 returns the user and system components of this time in @code{TARRAY(1)} and
2882 @code{TARRAY(2)} respectively. @var{RESULT} is equal to @code{TARRAY(1) +
2885 Subsequent invocations of @code{DTIME} return values accumulated since the
2886 previous invocation.
2888 On some systems, the underlying timings are represented using types with
2889 sufficiently small limits that overflows (wrap around) are possible, such as
2890 32-bit types. Therefore, the values returned by this intrinsic might be, or
2891 become, negative, or numerically less than previous values, during a single
2892 run of the compiled program.
2894 If @code{DTIME} is invoked as a function, it can not be invoked as a
2895 subroutine, and vice versa.
2897 @var{TARRAY} and @var{RESULT} are @code{INTENT(OUT)} and provide the following:
2899 @multitable @columnfractions .15 .30 .40
2900 @item @tab @code{TARRAY(1)}: @tab User time in seconds.
2901 @item @tab @code{TARRAY(2)}: @tab System time in seconds.
2902 @item @tab @code{RESULT}: @tab Run time since start in seconds.
2905 @item @emph{Standard}:
2911 @item @emph{Syntax}:
2912 @multitable @columnfractions .80
2913 @item @code{CALL DTIME(TARRAY, RESULT)}.
2914 @item @code{RESULT = DTIME(TARRAY)}, (not recommended).
2917 @item @emph{Arguments}:
2918 @multitable @columnfractions .15 .70
2919 @item @var{TARRAY}@tab The type shall be @code{REAL, DIMENSION(2)}.
2920 @item @var{RESULT}@tab The type shall be @code{REAL}.
2923 @item @emph{Return value}:
2924 Elapsed time in seconds since the start of program execution.
2926 @item @emph{Example}:
2930 real, dimension(2) :: tarray
2932 call dtime(tarray, result)
2936 do i=1,100000000 ! Just a delay
2939 call dtime(tarray, result)
2943 end program test_dtime
2950 @section @code{EOSHIFT} --- End-off shift function
2951 @cindex @code{EOSHIFT} intrinsic
2952 @cindex bit operations
2955 @item @emph{Description}:
2956 @code{EOSHIFT(ARRAY, SHIFT[,BOUNDARY, DIM])} performs an end-off shift on
2957 elements of @var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is
2958 omitted it is taken to be @code{1}. @var{DIM} is a scaler of type
2959 @code{INTEGER} in the range of @math{1 /leq DIM /leq n)} where @math{n} is the
2960 rank of @var{ARRAY}. If the rank of @var{ARRAY} is one, then all elements of
2961 @var{ARRAY} are shifted by @var{SHIFT} places. If rank is greater than one,
2962 then all complete rank one sections of @var{ARRAY} along the given dimension are
2963 shifted. Elements shifted out one end of each rank one section are dropped. If
2964 @var{BOUNDARY} is present then the corresponding value of from @var{BOUNDARY}
2965 is copied back in the other end. If @var{BOUNDARY} is not present then the
2966 following are copied in depending on the type of @var{ARRAY}.
2968 @multitable @columnfractions .15 .80
2969 @item @emph{Array Type} @tab @emph{Boundary Value}
2970 @item Numeric @tab 0 of the type and kind of @var{ARRAY}.
2971 @item Logical @tab @code{.FALSE.}.
2972 @item Character(@var{len}) @tab @var{len} blanks.
2975 @item @emph{Standard}:
2979 transformational function
2981 @item @emph{Syntax}:
2982 @code{RESULT = EOSHIFT(A, SHIFT [, BOUNDARY, DIM])}
2984 @item @emph{Arguments}:
2985 @multitable @columnfractions .15 .70
2986 @item @var{ARRAY} @tab May be any type, not scaler.
2987 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
2988 @item @var{BOUNDARY} @tab Same type as @var{ARRAY}.
2989 @item @var{DIM} @tab The type shall be @code{INTEGER}.
2992 @item @emph{Return value}:
2993 Returns an array of same type and rank as the @var{ARRAY} argument.
2995 @item @emph{Example}:
2997 program test_eoshift
2998 integer, dimension(3,3) :: a
2999 a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
3000 print '(3i3)', a(1,:)
3001 print '(3i3)', a(2,:)
3002 print '(3i3)', a(3,:)
3003 a = EOSHIFT(a, SHIFT=(/1, 2, 1/), BOUNDARY=-5, DIM=2)
3005 print '(3i3)', a(1,:)
3006 print '(3i3)', a(2,:)
3007 print '(3i3)', a(3,:)
3008 end program test_eoshift
3015 @section @code{EPSILON} --- Epsilon function
3016 @cindex @code{EPSILON} intrinsic
3017 @cindex epsilon, significant
3020 @item @emph{Description}:
3021 @code{EPSILON(X)} returns a nearly negligible number relative to @code{1}.
3023 @item @emph{Standard}:
3029 @item @emph{Syntax}:
3030 @code{RESULT = EPSILON(X)}
3032 @item @emph{Arguments}:
3033 @multitable @columnfractions .15 .70
3034 @item @var{X} @tab The type shall be @code{REAL(*)}.
3037 @item @emph{Return value}:
3038 The return value is of same type as the argument.
3040 @item @emph{Example}:
3042 program test_epsilon
3047 end program test_epsilon
3054 @section @code{ERF} --- Error function
3055 @cindex @code{ERF} intrinsic
3056 @cindex error function
3059 @item @emph{Description}:
3060 @code{ERF(X)} computes the error function of @var{X}.
3062 @item @emph{Standard}:
3068 @item @emph{Syntax}:
3069 @code{RESULT = ERF(X)}
3071 @item @emph{Arguments}:
3072 @multitable @columnfractions .15 .70
3073 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
3076 @item @emph{Return value}:
3077 The return value is a scalar of type @code{REAL(*)} and it is positive
3078 (@math{ - 1 \leq erf (x) \leq 1 }.
3080 @item @emph{Example}:
3083 real(8) :: x = 0.17_8
3085 end program test_erf
3088 @item @emph{Specific names}:
3089 @multitable @columnfractions .20 .20 .20 .25
3090 @item Name @tab Argument @tab Return type @tab Standard
3091 @item @code{DERF(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
3098 @section @code{ERFC} --- Error function
3099 @cindex @code{ERFC} intrinsic
3100 @cindex error function
3103 @item @emph{Description}:
3104 @code{ERFC(X)} computes the complementary error function of @var{X}.
3106 @item @emph{Standard}:
3112 @item @emph{Syntax}:
3113 @code{RESULT = ERFC(X)}
3115 @item @emph{Arguments}:
3116 @multitable @columnfractions .15 .70
3117 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
3120 @item @emph{Return value}:
3121 The return value is a scalar of type @code{REAL(*)} and it is positive
3122 (@math{ 0 \leq erfc (x) \leq 2 }.
3124 @item @emph{Example}:
3127 real(8) :: x = 0.17_8
3129 end program test_erfc
3132 @item @emph{Specific names}:
3133 @multitable @columnfractions .20 .20 .20 .25
3134 @item Name @tab Argument @tab Return type @tab Standard
3135 @item @code{DERFC(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
3142 @section @code{ETIME} --- Execution time subroutine (or function)
3143 @cindex @code{ETIME} intrinsic
3144 @cindex time, elapsed
3147 @item @emph{Description}:
3148 @code{ETIME(TARRAY, RESULT)} returns the number of seconds of runtime
3149 since the start of the process's execution in @var{RESULT}. @var{TARRAY}
3150 returns the user and system components of this time in @code{TARRAY(1)} and
3151 @code{TARRAY(2)} respectively. @var{RESULT} is equal to @code{TARRAY(1) + TARRAY(2)}.
3153 On some systems, the underlying timings are represented using types with
3154 sufficiently small limits that overflows (wrap around) are possible, such as
3155 32-bit types. Therefore, the values returned by this intrinsic might be, or
3156 become, negative, or numerically less than previous values, during a single
3157 run of the compiled program.
3159 If @code{ETIME} is invoked as a function, it can not be invoked as a
3160 subroutine, and vice versa.
3162 @var{TARRAY} and @var{RESULT} are @code{INTENT(OUT)} and provide the following:
3164 @multitable @columnfractions .15 .30 .60
3165 @item @tab @code{TARRAY(1)}: @tab User time in seconds.
3166 @item @tab @code{TARRAY(2)}: @tab System time in seconds.
3167 @item @tab @code{RESULT}: @tab Run time since start in seconds.
3170 @item @emph{Standard}:
3176 @item @emph{Syntax}:
3177 @multitable @columnfractions .80
3178 @item @code{CALL ETIME(TARRAY, RESULT)}.
3179 @item @code{RESULT = ETIME(TARRAY)}, (not recommended).
3182 @item @emph{Arguments}:
3183 @multitable @columnfractions .15 .70
3184 @item @var{TARRAY}@tab The type shall be @code{REAL, DIMENSION(2)}.
3185 @item @var{RESULT}@tab The type shall be @code{REAL}.
3188 @item @emph{Return value}:
3189 Elapsed time in seconds since the start of program execution.
3191 @item @emph{Example}:
3195 real, dimension(2) :: tarray
3197 call ETIME(tarray, result)
3201 do i=1,100000000 ! Just a delay
3204 call ETIME(tarray, result)
3208 end program test_etime
3211 @item @emph{See also}:
3219 @section @code{EXIT} --- Exit the program with status.
3220 @cindex @code{EXIT} intrinsic
3221 @cindex exit program
3224 @item @emph{Description}:
3225 @code{EXIT} causes immediate termination of the program with status. If status
3226 is omitted it returns the canonical @emph{success} for the system. All Fortran
3227 I/O units are closed.
3229 @item @emph{Standard}:
3235 @item @emph{Syntax}:
3236 @code{CALL EXIT([STATUS])}
3238 @item @emph{Arguments}:
3239 @multitable @columnfractions .15 .70
3240 @item @var{STATUS} @tab The type of the argument shall be @code{INTEGER(*)}.
3243 @item @emph{Return value}:
3244 @code{STATUS} is passed to the parent process on exit.
3246 @item @emph{Example}:
3249 integer :: STATUS = 0
3250 print *, 'This program is going to exit.'
3252 end program test_exit
3255 @item @emph{See also}:
3256 @ref{ABORT}, @ref{KILL}
3262 @section @code{EXP} --- Exponential function
3263 @cindex @code{EXP} intrinsic
3264 @cindex @code{DEXP} intrinsic
3265 @cindex @code{ZEXP} intrinsic
3266 @cindex @code{CDEXP} intrinsic
3270 @item @emph{Description}:
3271 @code{EXP(X)} computes the base @math{e} exponential of @var{X}.
3273 @item @emph{Standard}:
3274 F77 and later, has overloads that are GNU extensions
3279 @item @emph{Syntax}:
3280 @code{RESULT = EXP(X)}
3282 @item @emph{Arguments}:
3283 @multitable @columnfractions .15 .70
3284 @item @var{X} @tab The type shall be @code{REAL(*)} or
3288 @item @emph{Return value}:
3289 The return value has same type and kind as @var{X}.
3291 @item @emph{Example}:
3296 end program test_exp
3299 @item @emph{Specific names}:
3300 @multitable @columnfractions .20 .20 .20 .25
3301 @item Name @tab Argument @tab Return type @tab Standard
3302 @item @code{DEXP(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
3303 @item @code{CEXP(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab F77 and later
3304 @item @code{ZEXP(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
3305 @item @code{CDEXP(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
3312 @section @code{EXPONENT} --- Exponent function
3313 @cindex @code{EXPONENT} intrinsic
3314 @cindex exponent part of a real number
3317 @item @emph{Description}:
3318 @code{EXPONENT(X)} returns the value of the exponent part of @var{X}. If @var{X}
3319 is zero the value returned is zero.
3321 @item @emph{Standard}:
3327 @item @emph{Syntax}:
3328 @code{RESULT = EXPONENT(X)}
3330 @item @emph{Arguments}:
3331 @multitable @columnfractions .15 .70
3332 @item @var{X} @tab The type shall be @code{REAL(*)}.
3335 @item @emph{Return value}:
3336 The return value is of type default @code{INTEGER}.
3338 @item @emph{Example}:
3340 program test_exponent
3345 print *, exponent(0.0)
3346 end program test_exponent
3352 @section @code{FDATE} --- Get the current time as a string
3353 @cindex @code{FDATE} intrinsic
3354 @cindex time, current
3355 @cindex current time
3356 @cindex date, current
3357 @cindex current date
3360 @item @emph{Description}:
3361 @code{FDATE(DATE)} returns the current date (using the same format as
3362 @code{CTIME}) in @var{DATE}. It is equivalent to @code{CALL CTIME(DATE,
3365 If @code{FDATE} is invoked as a function, it can not be invoked as a
3366 subroutine, and vice versa.
3368 @var{DATE} is an @code{INTENT(OUT)} @code{CHARACTER} variable.
3370 @item @emph{Standard}:
3376 @item @emph{Syntax}:
3377 @multitable @columnfractions .80
3378 @item @code{CALL FDATE(DATE)}.
3379 @item @code{DATE = FDATE()}, (not recommended).
3382 @item @emph{Arguments}:
3383 @multitable @columnfractions .15 .70
3384 @item @var{DATE}@tab The type shall be of type @code{CHARACTER}.
3387 @item @emph{Return value}:
3388 The current date as a string.
3390 @item @emph{Example}:
3394 character(len=30) :: date
3396 print *, 'Program started on ', date
3397 do i = 1, 100000000 ! Just a delay
3401 print *, 'Program ended on ', date
3402 end program test_fdate
3408 @section @code{FLOAT} --- Convert integer to default real
3409 @cindex @code{FLOAT} intrinsic
3410 @cindex conversion function (float)
3413 @item @emph{Description}:
3414 @code{FLOAT(I)} converts the integer @var{I} to a default real value.
3416 @item @emph{Standard}:
3422 @item @emph{Syntax}:
3423 @code{RESULT = FLOAT(I)}
3425 @item @emph{Arguments}:
3426 @multitable @columnfractions .15 .70
3427 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
3430 @item @emph{Return value}:
3431 The return value is of type default @code{REAL}.
3433 @item @emph{Example}:
3437 if (float(i) /= 1.) call abort
3438 end program test_float
3441 @item @emph{See also}:
3442 @ref{DBLE}, @ref{DFLOAT}, @ref{REAL}
3448 @section @code{FGET} --- Read a single character in stream mode from stdin
3449 @cindex @code{FGET} intrinsic
3450 @cindex file operations
3451 @cindex stream operations
3454 @item @emph{Description}:
3455 Read a single character in stream mode from stdin by bypassing normal
3456 formatted output. Stream I/O should not be mixed with normal record-oriented
3457 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
3459 This intrinsic routine is provided for backwards compatibility with
3460 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
3461 Programmers should consider the use of new stream IO feature in new code
3462 for future portability. See also @ref{Fortran 2003 status}.
3464 @item @emph{Standard}:
3468 Non-elemental subroutine
3470 @item @emph{Syntax}:
3471 @code{CALL FGET(C [, STATUS])}
3473 @item @emph{Arguments}:
3474 @multitable @columnfractions .15 .70
3475 @item @var{C} @tab The type shall be @code{CHARACTER}.
3476 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
3477 Returns 0 on success, -1 on end-of-file, and a
3478 system specific positive error code otherwise.
3481 @item @emph{Example}:
3484 INTEGER, PARAMETER :: strlen = 100
3485 INTEGER :: status, i = 1
3486 CHARACTER(len=strlen) :: str = ""
3488 WRITE (*,*) 'Enter text:'
3490 CALL fget(str(i:i), status)
3491 if (status /= 0 .OR. i > strlen) exit
3494 WRITE (*,*) TRIM(str)
3498 @item @emph{See also}:
3499 @ref{FGETC}, @ref{FPUT}, @ref{FPUTC}
3504 @section @code{FGETC} --- Read a single character in stream mode
3505 @cindex @code{FGETC} intrinsic
3506 @cindex file operations
3507 @cindex stream operations
3510 @item @emph{Description}:
3511 Read a single character in stream mode by bypassing normal formatted output.
3512 Stream I/O should not be mixed with normal record-oriented (formatted or
3513 unformatted) I/O on the same unit; the results are unpredictable.
3515 This intrinsic routine is provided for backwards compatibility with
3516 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
3517 Programmers should consider the use of new stream IO feature in new code
3518 for future portability. See also @ref{Fortran 2003 status}.
3520 @item @emph{Standard}:
3524 Non-elemental subroutine
3526 @item @emph{Syntax}:
3527 @code{CALL FGETC(UNIT, C [, STATUS])}
3529 @item @emph{Arguments}:
3530 @multitable @columnfractions .15 .70
3531 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
3532 @item @var{C} @tab The type shall be @code{CHARACTER}.
3533 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. Returns 0 on success,
3534 -1 on end-of-file and a system specific positive error code otherwise.
3537 @item @emph{Example}:
3540 INTEGER :: fd = 42, status
3543 OPEN(UNIT=fd, FILE="/etc/passwd", ACTION="READ", STATUS = "OLD")
3545 CALL fgetc(fd, c, status)
3546 IF (status /= 0) EXIT
3553 @item @emph{See also}:
3554 @ref{FGET}, @ref{FPUT}, @ref{FPUTC}
3560 @section @code{FLOOR} --- Integer floor function
3561 @cindex @code{FLOOR} intrinsic
3565 @item @emph{Description}:
3566 @code{FLOOR(X)} returns the greatest integer less than or equal to @var{X}.
3568 @item @emph{Standard}:
3574 @item @emph{Syntax}:
3575 @code{RESULT = FLOOR(X [, KIND])}
3577 @item @emph{Arguments}:
3578 @multitable @columnfractions .15 .70
3579 @item @var{X} @tab The type shall be @code{REAL(*)}.
3580 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
3581 expression indicating the kind parameter of
3585 @item @emph{Return value}:
3586 The return value is of type @code{INTEGER(KIND)}
3588 @item @emph{Example}:
3593 print *, floor(x) ! returns 63
3594 print *, floor(y) ! returns -64
3595 end program test_floor
3598 @item @emph{See also}:
3599 @ref{CEILING}, @ref{NINT}
3606 @section @code{FLUSH} --- Flush I/O unit(s)
3607 @cindex @code{FLUSH} intrinsic
3608 @cindex flush output files
3611 @item @emph{Description}:
3612 Flushes Fortran unit(s) currently open for output. Without the optional
3613 argument, all units are flushed, otherwise just the unit specified.
3615 @item @emph{Standard}:
3619 Non-elemental subroutine
3621 @item @emph{Syntax}:
3622 @code{CALL FLUSH(UNIT)}
3624 @item @emph{Arguments}:
3625 @multitable @columnfractions .15 .70
3626 @item @var{UNIT} @tab (Optional) The type shall be @code{INTEGER}.
3630 Beginning with the Fortran 2003 standard, there is a @code{FLUSH}
3631 statement that should be preferred over the @code{FLUSH} intrinsic.
3638 @section @code{FNUM} --- File number function
3639 @cindex @code{FNUM} intrinsic
3643 @item @emph{Description}:
3644 @code{FNUM(UNIT)} returns the POSIX file descriptor number corresponding to the
3645 open Fortran I/O unit @code{UNIT}.
3647 @item @emph{Standard}:
3651 Non-elemental function
3653 @item @emph{Syntax}:
3654 @code{RESULT = FNUM(UNIT)}
3656 @item @emph{Arguments}:
3657 @multitable @columnfractions .15 .70
3658 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
3661 @item @emph{Return value}:
3662 The return value is of type @code{INTEGER}
3664 @item @emph{Example}:
3668 open (unit=10, status = "scratch")
3672 end program test_fnum
3679 @section @code{FPUT} --- Write a single character in stream mode to stdout
3680 @cindex @code{FPUT} intrinsic
3681 @cindex file operations
3682 @cindex stream operations
3685 @item @emph{Description}:
3686 Write a single character in stream mode to stdout by bypassing normal
3687 formatted output. Stream I/O should not be mixed with normal record-oriented
3688 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
3690 This intrinsic routine is provided for backwards compatibility with
3691 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
3692 Programmers should consider the use of new stream IO feature in new code
3693 for future portability. See also @ref{Fortran 2003 status}.
3695 @item @emph{Standard}:
3699 Non-elemental subroutine
3701 @item @emph{Syntax}:
3702 @code{CALL FPUT(C [, STATUS])}
3704 @item @emph{Arguments}:
3705 @multitable @columnfractions .15 .70
3706 @item @var{C} @tab The type shall be @code{CHARACTER}.
3707 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. Returns 0 on success,
3708 -1 on end-of-file and a system specific positive error code otherwise.
3711 @item @emph{Example}:
3714 CHARACTER(len=*) :: str = "gfortran"
3716 DO i = 1, len_trim(str)
3722 @item @emph{See also}:
3723 @ref{FPUTC}, @ref{FGET}, @ref{FGETC}
3729 @section @code{FPUTC} --- Write a single character in stream mode
3730 @cindex @code{FPUTC} intrinsic
3731 @cindex file operations
3732 @cindex stream operations
3735 @item @emph{Description}:
3736 Write a single character in stream mode by bypassing normal formatted
3737 output. Stream I/O should not be mixed with normal record-oriented
3738 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
3740 This intrinsic routine is provided for backwards compatibility with
3741 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
3742 Programmers should consider the use of new stream IO feature in new code
3743 for future portability. See also @ref{Fortran 2003 status}.
3745 @item @emph{Standard}:
3749 Non-elemental subroutine
3751 @item @emph{Syntax}:
3752 @code{CALL FPUTC(UNIT, C [, STATUS])}
3754 @item @emph{Arguments}:
3755 @multitable @columnfractions .15 .70
3756 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
3757 @item @var{C} @tab The type shall be @code{CHARACTER}.
3758 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. Returns 0 on success,
3759 -1 on end-of-file and a system specific positive error code otherwise.
3762 @item @emph{Example}:
3765 CHARACTER(len=*) :: str = "gfortran"
3766 INTEGER :: fd = 42, i
3768 OPEN(UNIT = fd, FILE = "out", ACTION = "WRITE", STATUS="NEW")
3769 DO i = 1, len_trim(str)
3770 CALL fputc(fd, str(i:i))
3776 @item @emph{See also}:
3777 @ref{FPUT}, @ref{FGET}, @ref{FGETC}
3783 @section @code{FRACTION} --- Fractional part of the model representation
3784 @cindex @code{FRACTION} intrinsic
3785 @cindex fractional part
3788 @item @emph{Description}:
3789 @code{FRACTION(X)} returns the fractional part of the model
3790 representation of @code{X}.
3792 @item @emph{Standard}:
3798 @item @emph{Syntax}:
3799 @code{Y = FRACTION(X)}
3801 @item @emph{Arguments}:
3802 @multitable @columnfractions .15 .70
3803 @item @var{X} @tab The type of the argument shall be a @code{REAL}.
3806 @item @emph{Return value}:
3807 The return value is of the same type and kind as the argument.
3808 The fractional part of the model representation of @code{X} is returned;
3809 it is @code{X * RADIX(X)**(-EXPONENT(X))}.
3811 @item @emph{Example}:
3813 program test_fraction
3816 print *, fraction(x), x * radix(x)**(-exponent(x))
3817 end program test_fraction
3825 @section @code{FREE} --- Frees memory
3826 @cindex @code{FREE} intrinsic
3827 @cindex Cray pointers
3830 @item @emph{Description}:
3831 Frees memory previously allocated by @code{MALLOC()}. The @code{FREE}
3832 intrinsic is an extension intended to be used with Cray pointers, and is
3833 provided in GNU Fortran to allow user to compile legacy code. For
3834 new code using Fortran 95 pointers, the memory de-allocation intrinsic is
3837 @item @emph{Standard}:
3843 @item @emph{Syntax}:
3844 @code{CALL FREE(PTR)}
3846 @item @emph{Arguments}:
3847 @multitable @columnfractions .15 .70
3848 @item @var{PTR} @tab The type shall be @code{INTEGER}. It represents the
3849 location of the memory that should be de-allocated.
3852 @item @emph{Return value}:
3855 @item @emph{Example}:
3856 See @code{MALLOC} for an example.
3858 @item @emph{See also}:
3865 @section @code{FSEEK} --- Low level file positioning subroutine
3866 @cindex @code{FSEEK} intrinsic
3867 @cindex file system operations
3869 Not yet implemented in GNU Fortran.
3872 @item @emph{Description}:
3874 @item @emph{Standard}:
3880 @item @emph{Syntax}:
3881 @item @emph{Arguments}:
3882 @item @emph{Return value}:
3883 @item @emph{Example}:
3884 @item @emph{Specific names}:
3885 @item @emph{See also}:
3886 @uref{http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19292, g77 features lacking in gfortran}
3893 @section @code{FSTAT} --- Get file status
3894 @cindex @code{FSTAT} intrinsic
3895 @cindex file system operations
3898 @item @emph{Description}:
3899 @code{FSTAT} is identical to @ref{STAT}, except that information about an
3900 already opened file is obtained.
3902 The elements in @code{BUFF} are the same as described by @ref{STAT}.
3904 @item @emph{Standard}:
3908 Non-elemental subroutine
3910 @item @emph{Syntax}:
3911 @code{CALL FSTAT(UNIT, BUFF [, STATUS])}
3913 @item @emph{Arguments}:
3914 @multitable @columnfractions .15 .70
3915 @item @var{UNIT} @tab An open I/O unit number of type @code{INTEGER}.
3916 @item @var{BUFF} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
3917 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0
3918 on success and a system specific error code otherwise.
3921 @item @emph{Example}:
3922 See @ref{STAT} for an example.
3924 @item @emph{See also}:
3925 To stat a link: @ref{LSTAT}, to stat a file: @ref{STAT}
3931 @section @code{FTELL} --- Current stream position
3932 @cindex @code{FTELL} intrinsic
3935 @item @emph{Description}:
3936 Retrieves the current position within an open file.
3938 This intrinsic is provided in both subroutine and function forms; however,
3939 only one form can be used in any given program unit.
3941 @item @emph{Standard}:
3945 Subroutine, function
3947 @item @emph{Syntax}:
3948 @multitable @columnfractions .80
3949 @item @code{CALL FTELL(UNIT, OFFSET)}
3950 @item @code{OFFSET = FTELL(UNIT)}
3953 @item @emph{Arguments}:
3954 @multitable @columnfractions .15 .70
3955 @item @var{OFFSET} @tab Shall of type @code{INTEGER}.
3956 @item @var{UNIT} @tab Shall of type @code{INTEGER}.
3959 @item @emph{Return value}:
3960 In either syntax, @var{OFFSET} is set to the current offset of unit
3961 number @var{UNIT}, or to @math{-1} if the unit is not currently open.
3963 @item @emph{Example}:
3967 OPEN(10, FILE="temp.dat")
3973 @item @emph{See also}:
3980 @section @code{GERROR} --- Get last system error message
3981 @cindex @code{GERROR} intrinsic
3984 @item @emph{Description}:
3985 Returns the system error message corresponding to the last system error.
3986 This resembles the functionality of @code{strerror(3)} in C.
3988 @item @emph{Standard}:
3994 @item @emph{Syntax}:
3995 @code{CALL GERROR(RESULT)}
3997 @item @emph{Arguments}:
3998 @multitable @columnfractions .15 .70
3999 @item @var{RESULT} @tab Shall of type @code{CHARACTER(*)}.
4002 @item @emph{Example}:
4005 CHARACTER(len=100) :: msg
4011 @item @emph{See also}:
4012 @ref{IERRNO}, @ref{PERROR}
4018 @section @code{GETARG} --- Get command line arguments
4019 @cindex @code{GETARG} intrinsic
4020 @cindex command-line arguments, to program
4023 @item @emph{Description}:
4024 Retrieve the @var{N}th argument that was passed on the
4025 command line when the containing program was invoked.
4027 This intrinsic routine is provided for backwards compatibility with
4028 GNU Fortran 77. In new code, programmers should consider the use of
4029 the @ref{GET_COMMAND_ARGUMENT} intrinsic defined by the Fortran 2003
4032 @item @emph{Standard}:
4038 @item @emph{Syntax}:
4039 @code{CALL GETARG(N, ARG)}
4041 @item @emph{Arguments}:
4042 @multitable @columnfractions .15 .70
4043 @item @var{N} @tab Shall be of type @code{INTEGER(4)}, @math{@var{N} \geq 0}
4044 @item @var{ARG} @tab Shall be of type @code{CHARACTER(*)}.
4047 @item @emph{Return value}:
4048 After @code{GETARG} returns, the @var{ARG} argument holds the @var{N}th
4049 command line argument. If @var{ARG} can not hold the argument, it is
4050 truncated to fit the length of @var{ARG}. If there are less than @var{N}
4051 arguments specified at the command line, @var{ARG} will be filled with blanks.
4052 If @math{@var{N} = 0}, @var{ARG} is set to the name of the program (on systems
4053 that support this feature).
4055 @item @emph{Example}:
4059 CHARACTER(len=32) :: arg
4068 @item @emph{See also}:
4069 GNU Fortran 77 compatibility function: @ref{IARGC}
4071 F2003 functions and subroutines: @ref{GET_COMMAND}, @ref{GET_COMMAND_ARGUMENT},
4072 @ref{COMMAND_ARGUMENT_COUNT}
4078 @section @code{GET_COMMAND} --- Get the entire command line
4079 @cindex @code{GET_COMMAND} intrinsic
4080 @cindex command-line arguments, to program
4083 @item @emph{Description}:
4084 Retrieve the entire command line that was used to invoke the program.
4086 @item @emph{Standard}:
4092 @item @emph{Syntax}:
4093 @code{CALL GET_COMMAND(CMD)}
4095 @item @emph{Arguments}:
4096 @multitable @columnfractions .15 .70
4097 @item @var{CMD} @tab Shall be of type @code{CHARACTER(*)}.
4100 @item @emph{Return value}:
4101 Stores the entire command line that was used to invoke the program in @var{ARG}.
4102 If @var{ARG} is not large enough, the command will be truncated.
4104 @item @emph{Example}:
4106 PROGRAM test_get_command
4107 CHARACTER(len=255) :: cmd
4108 CALL get_command(cmd)
4109 WRITE (*,*) TRIM(cmd)
4113 @item @emph{See also}:
4114 @ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
4119 @node GET_COMMAND_ARGUMENT
4120 @section @code{GET_COMMAND_ARGUMENT} --- Get command line arguments
4121 @cindex @code{GET_COMMAND_ARGUMENT} intrinsic
4122 @cindex command-line arguments, to program
4125 @item @emph{Description}:
4126 Retrieve the @var{N}th argument that was passed on the
4127 command line when the containing program was invoked.
4129 @item @emph{Standard}:
4135 @item @emph{Syntax}:
4136 @code{CALL GET_COMMAND_ARGUMENT(N, ARG)}
4138 @item @emph{Arguments}:
4139 @multitable @columnfractions .15 .70
4140 @item @var{N} @tab Shall be of type @code{INTEGER(4)}, @math{@var{N} \geq 0}
4141 @item @var{ARG} @tab Shall be of type @code{CHARACTER(*)}.
4144 @item @emph{Return value}:
4145 After @code{GET_COMMAND_ARGUMENT} returns, the @var{ARG} argument holds the
4146 @var{N}th command line argument. If @var{ARG} can not hold the argument, it is
4147 truncated to fit the length of @var{ARG}. If there are less than @var{N}
4148 arguments specified at the command line, @var{ARG} will be filled with blanks.
4149 If @math{@var{N} = 0}, @var{ARG} is set to the name of the program (on systems
4150 that support this feature).
4152 @item @emph{Example}:
4154 PROGRAM test_get_command_argument
4156 CHARACTER(len=32) :: arg
4160 CALL get_command_argument(i, arg)
4161 IF (LEN_TRIM(arg) == 0) EXIT
4163 WRITE (*,*) TRIM(arg)
4169 @item @emph{See also}:
4170 @ref{GET_COMMAND}, @ref{COMMAND_ARGUMENT_COUNT}
4176 @section @code{GETCWD} --- Get current working directory
4177 @cindex @code{GETCWD} intrinsic
4178 @cindex file system operations
4181 @item @emph{Description}:
4182 Get current working directory.
4184 @item @emph{Standard}:
4188 Non-elemental subroutine.
4190 @item @emph{Syntax}:
4191 @code{CALL GETCWD(CWD [, STATUS])}
4193 @item @emph{Arguments}:
4194 @multitable @columnfractions .15 .70
4195 @item @var{CWD} @tab The type shall be @code{CHARACTER(*)}.
4196 @item @var{STATUS} @tab (Optional) status flag. Returns 0 on success,
4197 a system specific and non-zero error code otherwise.
4200 @item @emph{Example}:
4203 CHARACTER(len=255) :: cwd
4205 WRITE(*,*) TRIM(cwd)
4209 @item @emph{See also}:
4216 @section @code{GETENV} --- Get an environmental variable
4217 @cindex @code{GETENV} intrinsic
4218 @cindex environment variable
4221 @item @emph{Description}:
4222 Get the @var{VALUE} of the environmental variable @var{ENVVAR}.
4224 This intrinsic routine is provided for backwards compatibility with
4225 GNU Fortran 77. In new code, programmers should consider the use of
4226 the @ref{GET_ENVIRONMENT_VARIABLE} intrinsic defined by the Fortran
4229 @item @emph{Standard}:
4235 @item @emph{Syntax}:
4236 @code{CALL GETENV(ENVVAR, VALUE)}
4238 @item @emph{Arguments}:
4239 @multitable @columnfractions .15 .70
4240 @item @var{ENVVAR} @tab Shall be of type @code{CHARACTER(*)}.
4241 @item @var{VALUE} @tab Shall be of type @code{CHARACTER(*)}.
4244 @item @emph{Return value}:
4245 Stores the value of @var{ENVVAR} in @var{VALUE}. If @var{VALUE} is
4246 not large enough to hold the data, it is truncated. If @var{ENVVAR}
4247 is not set, @var{VALUE} will be filled with blanks.
4249 @item @emph{Example}:
4252 CHARACTER(len=255) :: homedir
4253 CALL getenv("HOME", homedir)
4254 WRITE (*,*) TRIM(homedir)
4258 @item @emph{See also}:
4259 @ref{GET_ENVIRONMENT_VARIABLE}
4264 @node GET_ENVIRONMENT_VARIABLE
4265 @section @code{GET_ENVIRONMENT_VARIABLE} --- Get an environmental variable
4266 @cindex @code{GET_ENVIRONMENT_VARIABLE} intrinsic
4267 @cindex environment variable
4270 @item @emph{Description}:
4271 Get the @var{VALUE} of the environmental variable @var{ENVVAR}.
4273 @item @emph{Standard}:
4279 @item @emph{Syntax}:
4280 @code{CALL GET_ENVIRONMENT_VARIABLE(ENVVAR, VALUE)}
4282 @item @emph{Arguments}:
4283 @multitable @columnfractions .15 .70
4284 @item @var{ENVVAR} @tab Shall be of type @code{CHARACTER(*)}.
4285 @item @var{VALUE} @tab Shall be of type @code{CHARACTER(*)}.
4288 @item @emph{Return value}:
4289 Stores the value of @var{ENVVAR} in @var{VALUE}. If @var{VALUE} is
4290 not large enough to hold the data, it is truncated. If @var{ENVVAR}
4291 is not set, @var{VALUE} will be filled with blanks.
4293 @item @emph{Example}:
4296 CHARACTER(len=255) :: homedir
4297 CALL get_environment_variable("HOME", homedir)
4298 WRITE (*,*) TRIM(homedir)
4306 @section @code{GETGID} --- Group ID function
4307 @cindex @code{GETGID} intrinsic
4308 @cindex file system operations
4311 @item @emph{Description}:
4312 Returns the numerical group ID of the current process.
4314 @item @emph{Standard}:
4320 @item @emph{Syntax}:
4321 @code{RESULT = GETGID()}
4323 @item @emph{Return value}:
4324 The return value of @code{GETGID} is an @code{INTEGER} of the default
4328 @item @emph{Example}:
4329 See @code{GETPID} for an example.
4331 @item @emph{See also}:
4332 @ref{GETPID}, @ref{GETUID}
4338 @section @code{GETLOG} --- Get login name
4339 @cindex @code{GETLOG} intrinsic
4342 @item @emph{Description}:
4343 Gets the username under which the program is running.
4345 @item @emph{Standard}:
4351 @item @emph{Syntax}:
4352 @code{CALL GETLOG(LOGIN)}
4354 @item @emph{Arguments}:
4355 @multitable @columnfractions .15 .70
4356 @item @var{LOGIN} @tab Shall be of type @code{CHARACTER(*)}.
4359 @item @emph{Return value}:
4360 Stores the current user name in @var{LOGIN}. (On systems where
4361 the @code{getlogin(3)} function is not implemented, this will
4362 return a blank string.)
4364 @item @emph{Example}:
4367 CHARACTER(32) :: login
4373 @item @emph{See also}:
4380 @section @code{GETPID} --- Process ID function
4381 @cindex @code{GETPID} intrinsic
4382 @cindex process ID, current
4385 @item @emph{Description}:
4386 Returns the numerical process identifier of the current process.
4388 @item @emph{Standard}:
4394 @item @emph{Syntax}:
4395 @code{RESULT = GETPID()}
4397 @item @emph{Return value}:
4398 The return value of @code{GETPID} is an @code{INTEGER} of the default
4402 @item @emph{Example}:
4405 print *, "The current process ID is ", getpid()
4406 print *, "Your numerical user ID is ", getuid()
4407 print *, "Your numerical group ID is ", getgid()
4411 @item @emph{See also}:
4412 @ref{GETGID}, @ref{GETUID}
4418 @section @code{GETUID} --- User ID function
4419 @cindex @code{GETUID} intrinsic
4420 @cindex user ID, current
4423 @item @emph{Description}:
4424 Returns the numerical user ID of the current process.
4426 @item @emph{Standard}:
4432 @item @emph{Syntax}:
4433 @code{RESULT = GETUID()}
4435 @item @emph{Return value}:
4436 The return value of @code{GETUID} is an @code{INTEGER} of the default
4440 @item @emph{Example}:
4441 See @code{GETPID} for an example.
4443 @item @emph{See also}:
4444 @ref{GETPID}, @ref{GETLOG}
4450 @section @code{GMTIME} --- Convert time to GMT info
4451 @cindex @code{GMTIME} intrinsic
4452 @cindex time, conversion function
4455 @item @emph{Description}:
4456 Given a system time value @var{STIME} (as provided by the @code{TIME8()}
4457 intrinsic), fills @var{TARRAY} with values extracted from it appropriate
4458 to the UTC time zone (Universal Coordinated Time, also known in some
4459 countries as GMT, Greenwich Mean Time), using @code{gmtime(3)}.
4461 @item @emph{Standard}:
4467 @item @emph{Syntax}:
4468 @code{CALL GMTIME(STIME, TARRAY)}
4470 @item @emph{Arguments}:
4471 @multitable @columnfractions .15 .70
4472 @item @var{STIME} @tab An @code{INTEGER(*)} scalar expression
4473 corresponding to a system time, with
4475 @item @var{TARRAY} @tab A default @code{INTEGER} array with 9 elements,
4476 with @code{INTENT(OUT)}.
4479 @item @emph{Return value}:
4480 The elements of @var{TARRAY} are assigned as follows:
4482 @item Seconds after the minute, range 0--59 or 0--61 to allow for leap
4484 @item Minutes after the hour, range 0--59
4485 @item Hours past midnight, range 0--23
4486 @item Day of month, range 0--31
4487 @item Number of months since January, range 0--12
4488 @item Years since 1900
4489 @item Number of days since Sunday, range 0--6
4490 @item Days since January 1
4491 @item Daylight savings indicator: positive if daylight savings is in
4492 effect, zero if not, and negative if the information is not
4496 @item @emph{See also}:
4497 @ref{CTIME}, @ref{LTIME}, @ref{TIME}, @ref{TIME8}
4504 @section @code{HOSTNM} --- Get system host name
4505 @cindex @code{HOSTNM} intrinsic
4508 @item @emph{Description}:
4509 Retrieves the host name of the system on which the program is running.
4511 This intrinsic is provided in both subroutine and function forms; however,
4512 only one form can be used in any given program unit.
4514 @item @emph{Standard}:
4518 Subroutine, function
4520 @item @emph{Syntax}:
4521 @multitable @columnfractions .80
4522 @item @code{CALL HOSTNM(NAME[, STATUS])}
4523 @item @code{STATUS = HOSTNM(NAME)}
4526 @item @emph{Arguments}:
4527 @multitable @columnfractions .15 .70
4528 @item @var{NAME} @tab Shall of type @code{CHARACTER(*)}.
4529 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
4530 Returns 0 on success, or a system specific error
4534 @item @emph{Return value}:
4535 In either syntax, @var{NAME} is set to the current hostname if it can
4536 be obtained, or to a blank string otherwise.
4543 @section @code{HUGE} --- Largest number of a kind
4544 @cindex @code{HUGE} intrinsic
4548 @item @emph{Description}:
4549 @code{HUGE(X)} returns the largest number that is not an infinity in
4550 the model of the type of @code{X}.
4552 @item @emph{Standard}:
4558 @item @emph{Syntax}:
4559 @code{RESULT = HUGE(X)}
4561 @item @emph{Arguments}:
4562 @multitable @columnfractions .15 .70
4563 @item @var{X} @tab Shall be of type @code{REAL} or @code{INTEGER}.
4566 @item @emph{Return value}:
4567 The return value is of the same type and kind as @var{X}
4569 @item @emph{Example}:
4571 program test_huge_tiny
4572 print *, huge(0), huge(0.0), huge(0.0d0)
4573 print *, tiny(0.0), tiny(0.0d0)
4574 end program test_huge_tiny
4581 @section @code{IACHAR} --- Code in @acronym{ASCII} collating sequence
4582 @cindex @code{IACHAR} intrinsic
4583 @cindex @acronym{ASCII} collating sequence
4584 @cindex conversion function (character)
4587 @item @emph{Description}:
4588 @code{IACHAR(C)} returns the code for the @acronym{ASCII} character
4589 in the first character position of @code{C}.
4591 @item @emph{Standard}:
4597 @item @emph{Syntax}:
4598 @code{RESULT = IACHAR(C)}
4600 @item @emph{Arguments}:
4601 @multitable @columnfractions .15 .70
4602 @item @var{C} @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
4605 @item @emph{Return value}:
4606 The return value is of type @code{INTEGER} and of the default integer
4609 @item @emph{Example}:
4614 end program test_iachar
4618 See @ref{ICHAR} for a discussion of converting between numerical values
4619 and formatted string representations.
4621 @item @emph{See also}:
4622 @ref{ACHAR}, @ref{CHAR}, @ref{ICHAR}
4628 @section @code{IAND} --- Bitwise logical and
4629 @cindex @code{IAND} intrinsic
4630 @cindex bit operations
4633 @item @emph{Description}:
4634 Bitwise logical @code{AND}.
4636 @item @emph{Standard}:
4642 @item @emph{Syntax}:
4643 @code{RESULT = IAND(I, J)}
4645 @item @emph{Arguments}:
4646 @multitable @columnfractions .15 .70
4647 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
4648 @item @var{J} @tab The type shall be @code{INTEGER(*)}, of the same
4649 kind as @var{I}. (As a GNU extension, different kinds are also
4653 @item @emph{Return value}:
4654 The return type is @code{INTEGER(*)}, of the same kind as the
4655 arguments. (If the argument kinds differ, it is of the same kind as
4656 the larger argument.)
4658 @item @emph{Example}:
4662 DATA a / Z'F' /, b / Z'3' /
4663 WRITE (*,*) IAND(a, b)
4667 @item @emph{See also}:
4668 @ref{IOR}, @ref{IEOR}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
4675 @section @code{IARGC} --- Get the number of command line arguments
4676 @cindex @code{IARGC} intrinsic
4677 @cindex command-line arguments, to program
4680 @item @emph{Description}:
4681 @code{IARGC()} returns the number of arguments passed on the
4682 command line when the containing program was invoked.
4684 This intrinsic routine is provided for backwards compatibility with
4685 GNU Fortran 77. In new code, programmers should consider the use of
4686 the @ref{COMMAND_ARGUMENT_COUNT} intrinsic defined by the Fortran 2003
4689 @item @emph{Standard}:
4693 Non-elemental Function
4695 @item @emph{Syntax}:
4696 @code{RESULT = IARGC()}
4698 @item @emph{Arguments}:
4701 @item @emph{Return value}:
4702 The number of command line arguments, type @code{INTEGER(4)}.
4704 @item @emph{Example}:
4707 @item @emph{See also}:
4708 GNU Fortran 77 compatibility subroutine: @ref{GETARG}
4710 F2003 functions and subroutines: @ref{GET_COMMAND}, @ref{GET_COMMAND_ARGUMENT},
4711 @ref{COMMAND_ARGUMENT_COUNT}
4717 @section @code{IBCLR} --- Clear bit
4718 @cindex @code{IBCLR} intrinsic
4719 @cindex bit operations
4722 @item @emph{Description}:
4723 @code{IBCLR} returns the value of @var{I} with the bit at position
4724 @var{POS} set to zero.
4726 @item @emph{Standard}:
4732 @item @emph{Syntax}:
4733 @code{RESULT = IBCLR(I, POS)}
4735 @item @emph{Arguments}:
4736 @multitable @columnfractions .15 .70
4737 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
4738 @item @var{POS} @tab The type shall be @code{INTEGER(*)}.
4741 @item @emph{Return value}:
4742 The return value is of type @code{INTEGER(*)} and of the same kind as
4745 @item @emph{See also}:
4746 @ref{IBITS}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}, @ref{MVBITS}
4753 @section @code{IBITS} --- Bit extraction
4754 @cindex @code{IBITS} intrinsic
4755 @cindex bit operations
4758 @item @emph{Description}:
4759 @code{IBITS} extracts a field of length @var{LEN} from @var{I},
4760 starting from bit position @var{POS} and extending left for @var{LEN}
4761 bits. The result is right-justified and the remaining bits are
4762 zeroed. The value of @code{POS+LEN} must be less than or equal to the
4763 value @code{BIT_SIZE(I)}.
4765 @item @emph{Standard}:
4771 @item @emph{Syntax}:
4772 @code{RESULT = IBITS(I, POS, LEN)}
4774 @item @emph{Arguments}:
4775 @multitable @columnfractions .15 .70
4776 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
4777 @item @var{POS} @tab The type shall be @code{INTEGER(*)}.
4778 @item @var{LEN} @tab The type shall be @code{INTEGER(*)}.
4781 @item @emph{Return value}:
4782 The return value is of type @code{INTEGER(*)} and of the same kind as
4785 @item @emph{See also}:
4786 @ref{BIT_SIZE}, @ref{IBCLR}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
4792 @section @code{IBSET} --- Set bit
4793 @cindex @code{IBSET} intrinsic
4794 @cindex bit operations
4797 @item @emph{Description}:
4798 @code{IBSET} returns the value of @var{I} with the bit at position
4799 @var{POS} set to one.
4801 @item @emph{Standard}:
4807 @item @emph{Syntax}:
4808 @code{RESULT = IBSET(I, POS)}
4810 @item @emph{Arguments}:
4811 @multitable @columnfractions .15 .70
4812 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
4813 @item @var{POS} @tab The type shall be @code{INTEGER(*)}.
4816 @item @emph{Return value}:
4817 The return value is of type @code{INTEGER(*)} and of the same kind as
4820 @item @emph{See also}:
4821 @ref{IBCLR}, @ref{IBITS}, @ref{IAND}, @ref{IOR}, @ref{IEOR}, @ref{MVBITS}
4828 @section @code{ICHAR} --- Character-to-integer conversion function
4829 @cindex @code{ICHAR} intrinsic
4830 @cindex conversion function (character)
4833 @item @emph{Description}:
4834 @code{ICHAR(C)} returns the code for the character in the first character
4835 position of @code{C} in the system's native character set.
4836 The correspondence between characters and their codes is not necessarily
4837 the same across different GNU Fortran implementations.
4839 @item @emph{Standard}:
4845 @item @emph{Syntax}:
4846 @code{RESULT = ICHAR(C)}
4848 @item @emph{Arguments}:
4849 @multitable @columnfractions .15 .70
4850 @item @var{C} @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
4853 @item @emph{Return value}:
4854 The return value is of type @code{INTEGER} and of the default integer
4857 @item @emph{Example}:
4862 end program test_ichar
4866 No intrinsic exists to convert between a numeric value and a formatted
4867 character string representation -- for instance, given the
4868 @code{CHARACTER} value @code{'154'}, obtaining an @code{INTEGER} or
4869 @code{REAL} value with the value 154, or vice versa. Instead, this
4870 functionality is provided by internal-file I/O, as in the following
4875 character(len=10) string, string2
4878 ! Convert a string to a numeric value
4879 read (string,'(I10)') value
4882 ! Convert a value to a formatted string
4883 write (string2,'(I10)') value
4885 end program read_val
4888 @item @emph{See also}:
4889 @ref{ACHAR}, @ref{CHAR}, @ref{IACHAR}
4896 @section @code{IDATE} --- Get current local time subroutine (day/month/year)
4897 @cindex @code{IDATE} intrinsic
4900 @item @emph{Description}:
4901 @code{IDATE(TARRAY)} Fills @var{TARRAY} with the numerical values at the
4902 current local time. The day (in the range 1-31), month (in the range 1-12),
4903 and year appear in elements 1, 2, and 3 of @var{TARRAY}, respectively.
4904 The year has four significant digits.
4906 @item @emph{Standard}:
4912 @item @emph{Syntax}:
4913 @code{CALL IDATE(TARRAY)}
4915 @item @emph{Arguments}:
4916 @multitable @columnfractions .15 .70
4917 @item @var{TARRAY} @tab The type shall be @code{INTEGER, DIMENSION(3)} and
4918 the kind shall be the default integer kind.
4921 @item @emph{Return value}:
4924 @item @emph{Example}:
4927 integer, dimension(3) :: tarray
4932 end program test_idate
4939 @section @code{IEOR} --- Bitwise logical exclusive or
4940 @cindex @code{IEOR} intrinsic
4941 @cindex bit operations
4944 @item @emph{Description}:
4945 @code{IEOR} returns the bitwise boolean exclusive-OR of @var{I} and
4948 @item @emph{Standard}:
4954 @item @emph{Syntax}:
4955 @code{RESULT = IEOR(I, J)}
4957 @item @emph{Arguments}:
4958 @multitable @columnfractions .15 .70
4959 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
4960 @item @var{J} @tab The type shall be @code{INTEGER(*)}, of the same
4961 kind as @var{I}. (As a GNU extension, different kinds are also
4965 @item @emph{Return value}:
4966 The return type is @code{INTEGER(*)}, of the same kind as the
4967 arguments. (If the argument kinds differ, it is of the same kind as
4968 the larger argument.)
4970 @item @emph{See also}:
4971 @ref{IOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
4977 @section @code{IERRNO} --- Get the last system error number
4978 @cindex @code{IERRNO} intrinsic
4981 @item @emph{Description}:
4982 Returns the last system error number, as given by the C @code{errno()}
4985 @item @emph{Standard}:
4991 @item @emph{Syntax}:
4992 @code{RESULT = IERRNO()}
4994 @item @emph{Arguments}:
4997 @item @emph{Return value}:
4998 The return value is of type @code{INTEGER} and of the default integer
5001 @item @emph{See also}:
5008 @section @code{INDEX} --- Position of a substring within a string
5009 @cindex @code{INDEX} intrinsic
5012 @item @emph{Description}:
5013 Returns the position of the start of the first occurrence of string
5014 @var{SUBSTRING} as a substring in @var{STRING}, counting from one. If
5015 @var{SUBSTRING} is not present in @var{STRING}, zero is returned. If
5016 the @var{BACK} argument is present and true, the return value is the
5017 start of the last occurrence rather than the first.
5019 @item @emph{Standard}:
5025 @item @emph{Syntax}:
5026 @code{RESULT = INDEX(STRING, SUBSTRING [, BACK])}
5028 @item @emph{Arguments}:
5029 @multitable @columnfractions .15 .70
5030 @item @var{STRING} @tab Shall be a scalar @code{CHARACTER(*)}, with
5032 @item @var{SUBSTRING} @tab Shall be a scalar @code{CHARACTER(*)}, with
5034 @item @var{BACK} @tab (Optional) Shall be a scalar @code{LOGICAL(*)}, with
5038 @item @emph{Return value}:
5039 The return value is of type @code{INTEGER} and of the default integer
5042 @item @emph{See also}:
5048 @section @code{INT} --- Convert to integer type
5049 @cindex @code{INT} intrinsic
5050 @cindex @code{IFIX} intrinsic
5051 @cindex @code{IDINT} intrinsic
5052 @cindex conversion function (integer)
5055 @item @emph{Description}:
5056 Convert to integer type
5058 @item @emph{Standard}:
5064 @item @emph{Syntax}:
5065 @item @code{RESULT = INT(X [, KIND))}
5067 @item @emph{Arguments}:
5068 @multitable @columnfractions .15 .70
5069 @item @var{X} @tab Shall be of type @code{INTEGER(*)},
5070 @code{REAL(*)}, or @code{COMPLEX(*)}.
5071 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
5072 expression indicating the kind parameter of
5076 @item @emph{Return value}:
5077 These functions return a @code{INTEGER(*)} variable or array under
5078 the following rules:
5082 If @var{X} is of type @code{INTEGER(*)}, @code{INT(X) = X}
5084 If @var{X} is of type @code{REAL(*)} and @math{|X| < 1}, @code{INT(X)} equals @var{0}.
5085 If @math{|X| \geq 1}, then @code{INT(X)} equals the largest integer that does not exceed
5086 the range of @var{X} and whose sign is the same as the sign of @var{X}.
5088 If @var{X} is of type @code{COMPLEX(*)}, rule B is applied to the real part of X.
5091 @item @emph{Example}:
5095 complex :: z = (-3.7, 1.0)
5097 print *, int(z), int(z,8)
5101 @item @emph{Specific names}:
5102 @multitable @columnfractions .20 .20 .20 .25
5103 @item Name @tab Argument @tab Return type @tab Standard
5104 @item @code{IFIX(X)} @tab @code{REAL(4) X} @tab @code{INTEGER} @tab F77 and later
5105 @item @code{IDINT(X)} @tab @code{REAL(8) X} @tab @code{INTEGER} @tab F77 and later
5108 @comment @item @emph{See also}:
5114 @section @code{IOR} --- Bitwise logical or
5115 @cindex @code{IOR} intrinsic
5116 @cindex bit operations
5119 @item @emph{Description}:
5120 @code{IEOR} returns the bitwise boolean OR of @var{I} and
5123 @item @emph{Standard}:
5129 @item @emph{Syntax}:
5130 @code{RESULT = IEOR(I, J)}
5132 @item @emph{Arguments}:
5133 @multitable @columnfractions .15 .70
5134 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
5135 @item @var{J} @tab The type shall be @code{INTEGER(*)}, of the same
5136 kind as @var{I}. (As a GNU extension, different kinds are also
5140 @item @emph{Return value}:
5141 The return type is @code{INTEGER(*)}, of the same kind as the
5142 arguments. (If the argument kinds differ, it is of the same kind as
5143 the larger argument.)
5145 @item @emph{See also}:
5146 @ref{IEOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
5153 @section @code{IRAND} --- Integer pseudo-random number
5154 @cindex @code{IRAND} intrinsic
5155 @cindex random numbers
5158 @item @emph{Description}:
5159 @code{IRAND(FLAG)} returns a pseudo-random number from a uniform
5160 distribution between 0 and a system-dependent limit (which is in most
5161 cases 2147483647). If @var{FLAG} is 0, the next number
5162 in the current sequence is returned; if @var{FLAG} is 1, the generator
5163 is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
5164 it is used as a new seed with @code{SRAND}.
5166 @item @emph{Standard}:
5170 Non-elemental function
5172 @item @emph{Syntax}:
5173 @code{RESULT = IRAND(FLAG)}
5175 @item @emph{Arguments}:
5176 @multitable @columnfractions .15 .70
5177 @item @var{FLAG} @tab Shall be a scalar @code{INTEGER} of kind 4.
5180 @item @emph{Return value}:
5181 The return value is of @code{INTEGER(kind=4)} type.
5183 @item @emph{Example}:
5186 integer,parameter :: seed = 86456
5189 print *, irand(), irand(), irand(), irand()
5190 print *, irand(seed), irand(), irand(), irand()
5191 end program test_irand
5199 @section @code{ISATTY} --- Whether a unit is a terminal device.
5200 @cindex @code{ISATTY} intrinsic
5203 @item @emph{Description}:
5204 Determine whether a unit is connected to a terminal device.
5206 @item @emph{Standard}:
5210 Non-elemental function.
5212 @item @emph{Syntax}:
5213 @code{RESULT = ISATTY(UNIT)}
5215 @item @emph{Arguments}:
5216 @multitable @columnfractions .15 .70
5217 @item @var{UNIT} @tab Shall be a scalar @code{INTEGER(*)}.
5220 @item @emph{Return value}:
5221 Returns @code{.TRUE.} if the @var{UNIT} is connected to a terminal
5222 device, @code{.FALSE.} otherwise.
5224 @item @emph{Example}:
5227 INTEGER(kind=1) :: unit
5229 write(*,*) isatty(unit=unit)
5233 @item @emph{See also}:
5241 @section @code{ISHFT} --- Shift bits
5242 @cindex @code{ISHFT} intrinsic
5243 @cindex bit operations
5246 @item @emph{Description}:
5247 @code{ISHFT} returns a value corresponding to @var{I} with all of the
5248 bits shifted @var{SHIFT} places. A value of @var{SHIFT} greater than
5249 zero corresponds to a left shift, a value of zero corresponds to no
5250 shift, and a value less than zero corresponds to a right shift. If the
5251 absolute value of @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the
5252 value is undefined. Bits shifted out from the left end or right end are
5253 lost; zeros are shifted in from the opposite end.
5255 @item @emph{Standard}:
5261 @item @emph{Syntax}:
5262 @code{RESULT = ISHFT(I, SHIFT)}
5264 @item @emph{Arguments}:
5265 @multitable @columnfractions .15 .70
5266 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
5267 @item @var{SHIFT} @tab The type shall be @code{INTEGER(*)}.
5270 @item @emph{Return value}:
5271 The return value is of type @code{INTEGER(*)} and of the same kind as
5274 @item @emph{See also}:
5282 @section @code{ISHFTC} --- Shift bits circularly
5283 @cindex @code{ISHFTC} intrinsic
5284 @cindex bit operations
5287 @item @emph{Description}:
5288 @code{ISHFTC} returns a value corresponding to @var{I} with the
5289 rightmost @var{SIZE} bits shifted circularly @var{SHIFT} places; that
5290 is, bits shifted out one end are shifted into the opposite end. A value
5291 of @var{SHIFT} greater than zero corresponds to a left shift, a value of
5292 zero corresponds to no shift, and a value less than zero corresponds to
5293 a right shift. The absolute value of @var{SHIFT} must be less than
5294 @var{SIZE}. If the @var{SIZE} argument is omitted, it is taken to be
5295 equivalent to @code{BIT_SIZE(I)}.
5297 @item @emph{Standard}:
5303 @item @emph{Syntax}:
5304 @code{RESULT = ISHFTC(I, SHIFT [, SIZE])}
5306 @item @emph{Arguments}:
5307 @multitable @columnfractions .15 .70
5308 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
5309 @item @var{SHIFT} @tab The type shall be @code{INTEGER(*)}.
5310 @item @var{SIZE} @tab (Optional) The type shall be @code{INTEGER(*)};
5311 the value must be greater than zero and less than or equal to
5315 @item @emph{Return value}:
5316 The return value is of type @code{INTEGER(*)} and of the same kind as
5319 @item @emph{See also}:
5326 @section @code{ITIME} --- Get current local time subroutine (hour/minutes/seconds)
5327 @cindex @code{ITIME} intrinsic
5330 @item @emph{Description}:
5331 @code{IDATE(TARRAY)} Fills @var{TARRAY} with the numerical values at the
5332 current local time. The hour (in the range 1-24), minute (in the range 1-60),
5333 and seconds (in the range 1-60) appear in elements 1, 2, and 3 of @var{TARRAY},
5336 @item @emph{Standard}:
5342 @item @emph{Syntax}:
5343 @code{CALL ITIME(TARRAY)}
5345 @item @emph{Arguments}:
5346 @multitable @columnfractions .15 .70
5347 @item @var{TARRAY} @tab The type shall be @code{INTEGER, DIMENSION(3)}
5348 and the kind shall be the default integer kind.
5351 @item @emph{Return value}:
5355 @item @emph{Example}:
5358 integer, dimension(3) :: tarray
5363 end program test_itime
5370 @section @code{KILL} --- Send a signal to a process
5371 @cindex @code{KILL} intrinsic
5374 @item @emph{Description}:
5375 @item @emph{Standard}:
5376 Sends the signal specified by @var{SIGNAL} to the process @var{PID}.
5382 @item @emph{Syntax}:
5383 @code{CALL KILL(PID, SIGNAL [, STATUS])}
5385 @item @emph{Arguments}:
5386 @multitable @columnfractions .15 .70
5387 @item @var{PID} @tab Shall be a scalar @code{INTEGER}, with
5389 @item @var{SIGNAL} @tab Shall be a scalar @code{INTEGER}, with
5391 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)} or
5392 @code{INTEGER(8)}. Returns 0 on success, or a
5393 system-specific error code otherwise.
5396 @item @emph{See also}:
5397 @ref{ABORT}, @ref{EXIT}
5403 @section @code{KIND} --- Kind of an entity
5404 @cindex @code{KIND} intrinsic
5407 @item @emph{Description}:
5408 @code{KIND(X)} returns the kind value of the entity @var{X}.
5410 @item @emph{Standard}:
5416 @item @emph{Syntax}:
5419 @item @emph{Arguments}:
5420 @multitable @columnfractions .15 .70
5421 @item @var{X} @tab Shall be of type @code{LOGICAL}, @code{INTEGER},
5422 @code{REAL}, @code{COMPLEX} or @code{CHARACTER}.
5425 @item @emph{Return value}:
5426 The return value is a scalar of type @code{INTEGER} and of the default
5429 @item @emph{Example}:
5432 integer,parameter :: kc = kind(' ')
5433 integer,parameter :: kl = kind(.true.)
5435 print *, "The default character kind is ", kc
5436 print *, "The default logical kind is ", kl
5437 end program test_kind
5445 @section @code{LBOUND} --- Lower dimension bounds of an array
5446 @cindex @code{LBOUND} intrinsic
5449 @item @emph{Description}:
5450 Returns the lower bounds of an array, or a single lower bound
5451 along the @var{DIM} dimension.
5452 @item @emph{Standard}:
5458 @item @emph{Syntax}:
5459 @code{RESULT = LBOUND(ARRAY [, DIM])}
5461 @item @emph{Arguments}:
5462 @multitable @columnfractions .15 .70
5463 @item @var{ARRAY} @tab Shall be an array, of any type.
5464 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER(*)}.
5467 @item @emph{Return value}:
5468 If @var{DIM} is absent, the result is an array of the lower bounds of
5469 @var{ARRAY}. If @var{DIM} is present, the result is a scalar
5470 corresponding to the lower bound of the array along that dimension. If
5471 @var{ARRAY} is an expression rather than a whole array or array
5472 structure component, or if it has a zero extent along the relevant
5473 dimension, the lower bound is taken to be 1.
5475 @item @emph{See also}:
5482 @section @code{LEN} --- Length of a character entity
5483 @cindex @code{LEN} intrinsic
5486 @item @emph{Description}:
5487 Returns the length of a character string. If @var{STRING} is an array,
5488 the length of an element of @var{STRING} is returned. Note that
5489 @var{STRING} need not be defined when this intrinsic is invoked, since
5490 only the length, not the content, of @var{STRING} is needed.
5492 @item @emph{Standard}:
5498 @item @emph{Syntax}:
5499 @code{L = LEN(STRING)}
5501 @item @emph{Arguments}:
5502 @multitable @columnfractions .15 .70
5503 @item @var{STRING} @tab Shall be a scalar or array of type
5504 @code{CHARACTER(*)}, with @code{INTENT(IN)}
5507 @item @emph{Return value}:
5508 The return value is an @code{INTEGER} of the default kind.
5510 @item @emph{See also}:
5511 @ref{LEN_TRIM}, @ref{ADJUSTL}, @ref{ADJUSTR}
5517 @section @code{LEN_TRIM} --- Length of a character entity without trailing blank characters
5518 @cindex @code{LEN_TRIM} intrinsic
5521 @item @emph{Description}:
5522 Returns the length of a character string, ignoring any trailing blanks.
5524 @item @emph{Standard}:
5530 @item @emph{Syntax}:
5531 @code{RESULT = LEN_TRIM(STRING)}
5533 @item @emph{Arguments}:
5534 @multitable @columnfractions .15 .70
5535 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER(*)},
5536 with @code{INTENT(IN)}
5539 @item @emph{Return value}:
5540 The return value is an @code{INTEGER} of the default kind.
5542 @item @emph{See also}:
5543 @ref{LEN}, @ref{ADJUSTL}, @ref{ADJUSTR}
5549 @section @code{LGE} --- Lexical greater than or equal
5550 @cindex @code{LGE} intrinsic
5551 @cindex comparison (lexical)
5552 @cindex lexical comparison
5555 @item @emph{Description}:
5556 Determines whether one string is lexically greater than or equal to
5557 another string, where the two strings are interpreted as containing
5558 ASCII character codes. If the String A and String B are not the same
5559 length, the shorter is compared as if spaces were appended to it to form
5560 a value that has the same length as the longer.
5562 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
5563 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
5564 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
5565 that the latter use the processor's character ordering (which is not
5566 ASCII on some targets), whereas the former always use the ASCII
5569 @item @emph{Standard}:
5575 @item @emph{Syntax}:
5576 @code{RESULT = LGE(STRING_A, STRING_B)}
5578 @item @emph{Arguments}:
5579 @multitable @columnfractions .15 .70
5580 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
5581 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
5584 @item @emph{Return value}:
5585 Returns @code{.TRUE.} if @code{STRING_A >= STRING_B}, and @code{.FALSE.}
5586 otherwise, based on the ASCII ordering.
5588 @item @emph{See also}:
5589 @ref{LGT}, @ref{LLE}, @ref{LLT}
5595 @section @code{LGT} --- Lexical greater than
5596 @cindex @code{LGT} intrinsic
5597 @cindex comparison (lexical)
5598 @cindex lexical comparison
5601 @item @emph{Description}:
5602 Determines whether one string is lexically greater than another string,
5603 where the two strings are interpreted as containing ASCII character
5604 codes. If the String A and String B are not the same length, the
5605 shorter is compared as if spaces were appended to it to form a value
5606 that has the same length as the longer.
5608 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
5609 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
5610 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
5611 that the latter use the processor's character ordering (which is not
5612 ASCII on some targets), whereas the former always use the ASCII
5615 @item @emph{Standard}:
5621 @item @emph{Syntax}:
5622 @code{RESULT = LGT(STRING_A, STRING_B)}
5624 @item @emph{Arguments}:
5625 @multitable @columnfractions .15 .70
5626 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
5627 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
5630 @item @emph{Return value}:
5631 Returns @code{.TRUE.} if @code{STRING_A > STRING_B}, and @code{.FALSE.}
5632 otherwise, based on the ASCII ordering.
5634 @item @emph{See also}:
5635 @ref{LGE}, @ref{LLE}, @ref{LLT}
5641 @section @code{LINK} --- Create a hard link
5642 @cindex @code{LINK} intrinsic
5643 @cindex file system operations
5646 @item @emph{Description}:
5647 Makes a (hard) link from file @var{PATH1} to @var{PATH2}. A null
5648 character (@code{CHAR(0)}) can be used to mark the end of the names in
5649 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
5650 names are ignored. If the @var{STATUS} argument is supplied, it
5651 contains 0 on success or a nonzero error code upon return; see
5654 This intrinsic is provided in both subroutine and function forms;
5655 however, only one form can be used in any given program unit.
5657 @item @emph{Standard}:
5661 Subroutine, non-elemental function
5663 @item @emph{Syntax}:
5664 @multitable @columnfractions .80
5665 @item @code{CALL LINK(PATH1, PATH2 [, STATUS])}
5666 @item @code{STATUS = LINK(PATH1, PATH2)}
5669 @item @emph{Arguments}:
5670 @multitable @columnfractions .15 .70
5671 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
5672 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
5673 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
5676 @item @emph{See also}:
5677 @ref{SYMLNK}, @ref{UNLINK}
5683 @section @code{LLE} --- Lexical less than or equal
5684 @cindex @code{LLE} intrinsic
5685 @cindex comparison (lexical)
5686 @cindex lexical comparison
5689 @item @emph{Description}:
5690 Determines whether one string is lexically less than or equal to another
5691 string, where the two strings are interpreted as containing ASCII
5692 character codes. If the String A and String B are not the same length,
5693 the shorter is compared as if spaces were appended to it to form a value
5694 that has the same length as the longer.
5696 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
5697 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
5698 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
5699 that the latter use the processor's character ordering (which is not
5700 ASCII on some targets), whereas the former always use the ASCII
5703 @item @emph{Standard}:
5709 @item @emph{Syntax}:
5710 @code{RESULT = LLE(STRING_A, STRING_B)}
5712 @item @emph{Arguments}:
5713 @multitable @columnfractions .15 .70
5714 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
5715 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
5718 @item @emph{Return value}:
5719 Returns @code{.TRUE.} if @code{STRING_A <= STRING_B}, and @code{.FALSE.}
5720 otherwise, based on the ASCII ordering.
5722 @item @emph{See also}:
5723 @ref{LGE}, @ref{LGT}, @ref{LLT}
5729 @section @code{LLT} --- Lexical less than
5730 @cindex @code{LLT} intrinsic
5731 @cindex comparison (lexical)
5732 @cindex lexical comparison
5735 @item @emph{Description}:
5736 Determines whether one string is lexically less than another string,
5737 where the two strings are interpreted as containing ASCII character
5738 codes. If the String A and String B are not the same length, the
5739 shorter is compared as if spaces were appended to it to form a value
5740 that has the same length as the longer.
5742 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
5743 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
5744 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
5745 that the latter use the processor's character ordering (which is not
5746 ASCII on some targets), whereas the former always use the ASCII
5749 @item @emph{Standard}:
5755 @item @emph{Syntax}:
5756 @code{RESULT = LLT(STRING_A, STRING_B)}
5758 @item @emph{Arguments}:
5759 @multitable @columnfractions .15 .70
5760 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
5761 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
5764 @item @emph{Return value}:
5765 Returns @code{.TRUE.} if @code{STRING_A < STRING_B}, and @code{.FALSE.}
5766 otherwise, based on the ASCII ordering.
5768 @item @emph{See also}:
5769 @ref{LGE}, @ref{LGT}, @ref{LLE}
5775 @section @code{LNBLNK} --- Index of the last non-blank character in a string
5776 @cindex @code{LNBLNK} intrinsic
5779 @item @emph{Description}:
5780 Returns the length of a character string, ignoring any trailing blanks.
5781 This is identical to the standard @code{LEN_TRIM} intrinsic, and is only
5782 included for backwards compatibility.
5784 @item @emph{Standard}:
5790 @item @emph{Syntax}:
5791 @code{RESULT = LNBLNK(STRING)}
5793 @item @emph{Arguments}:
5794 @multitable @columnfractions .15 .70
5795 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER(*)},
5796 with @code{INTENT(IN)}
5799 @item @emph{Return value}:
5800 The return value is of @code{INTEGER(kind=4)} type.
5802 @item @emph{See also}:
5803 @ref{INDEX}, @ref{LEN_TRIM}
5809 @section @code{LOC} --- Returns the address of a variable
5810 @cindex @code{LOC} intrinsic
5811 @cindex location of a variable in memory
5814 @item @emph{Description}:
5815 @code{LOC(X)} returns the address of @var{X} as an integer.
5817 @item @emph{Standard}:
5823 @item @emph{Syntax}:
5824 @code{RESULT = LOC(X)}
5826 @item @emph{Arguments}:
5827 @multitable @columnfractions .15 .70
5828 @item @var{X} @tab Variable of any type.
5831 @item @emph{Return value}:
5832 The return value is of type @code{INTEGER}, with a @code{KIND}
5833 corresponding to the size (in bytes) of a memory address on the target
5836 @item @emph{Example}:
5843 end program test_loc
5850 @section @code{LOG} --- Logarithm function
5851 @cindex @code{LOG} intrinsic
5852 @cindex @code{ALOG} intrinsic
5853 @cindex @code{DLOG} intrinsic
5854 @cindex @code{CLOG} intrinsic
5855 @cindex @code{ZLOG} intrinsic
5856 @cindex @code{CDLOG} intrinsic
5860 @item @emph{Description}:
5861 @code{LOG(X)} computes the logarithm of @var{X}.
5863 @item @emph{Standard}:
5869 @item @emph{Syntax}:
5870 @code{RESULT = LOG(X)}
5872 @item @emph{Arguments}:
5873 @multitable @columnfractions .15 .70
5874 @item @var{X} @tab The type shall be @code{REAL(*)} or
5878 @item @emph{Return value}:
5879 The return value is of type @code{REAL(*)} or @code{COMPLEX(*)}.
5880 The kind type parameter is the same as @var{X}.
5882 @item @emph{Example}:
5885 real(8) :: x = 1.0_8
5886 complex :: z = (1.0, 2.0)
5889 end program test_log
5892 @item @emph{Specific names}:
5893 @multitable @columnfractions .20 .20 .20 .25
5894 @item Name @tab Argument @tab Return type @tab Standard
5895 @item @code{ALOG(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab f95, gnu
5896 @item @code{DLOG(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
5897 @item @code{CLOG(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab f95, gnu
5898 @item @code{ZLOG(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
5899 @item @code{CDLOG(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
5906 @section @code{LOG10} --- Base 10 logarithm function
5907 @cindex @code{LOG10} intrinsic
5908 @cindex @code{ALOG10} intrinsic
5909 @cindex @code{DLOG10} intrinsic
5913 @item @emph{Description}:
5914 @code{LOG10(X)} computes the base 10 logarithm of @var{X}.
5916 @item @emph{Standard}:
5922 @item @emph{Syntax}:
5923 @code{RESULT = LOG10(X)}
5925 @item @emph{Arguments}:
5926 @multitable @columnfractions .15 .70
5927 @item @var{X} @tab The type shall be @code{REAL(*)} or
5931 @item @emph{Return value}:
5932 The return value is of type @code{REAL(*)} or @code{COMPLEX(*)}.
5933 The kind type parameter is the same as @var{X}.
5935 @item @emph{Example}:
5938 real(8) :: x = 10.0_8
5940 end program test_log10
5943 @item @emph{Specific names}:
5944 @multitable @columnfractions .20 .20 .20 .25
5945 @item Name @tab Argument @tab Return type @tab Standard
5946 @item @code{ALOG10(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab F95 and later
5947 @item @code{DLOG10(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
5954 @section @code{LOGICAL} --- Convert to logical type
5955 @cindex @code{LOGICAL} intrinsic
5956 @cindex conversion function (logical)
5959 @item @emph{Description}:
5960 Converts one kind of @code{LOGICAL} variable to another.
5962 @item @emph{Standard}:
5968 @item @emph{Syntax}:
5969 @code{RESULT = LOGICAL(L [, KIND])}
5971 @item @emph{Arguments}:
5972 @multitable @columnfractions .15 .70
5973 @item @var{L} @tab The type shall be @code{LOGICAL(*)}.
5974 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
5975 expression indicating the kind parameter of
5979 @item @emph{Return value}:
5980 The return value is a @code{LOGICAL} value equal to @var{L}, with a
5981 kind corresponding to @var{KIND}, or of the default logical kind if
5982 @var{KIND} is not given.
5984 @item @emph{See also}:
5985 @ref{INT}, @ref{REAL}, @ref{CMPLX}
5992 @section @code{LSHIFT} --- Left shift bits
5993 @cindex @code{LSHIFT} intrinsic
5994 @cindex bit operations
5997 @item @emph{Description}:
5998 @code{LSHIFT} returns a value corresponding to @var{I} with all of the
5999 bits shifted left by @var{SHIFT} places. If the absolute value of
6000 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
6001 Bits shifted out from the left end are lost; zeros are shifted in from
6004 This function has been superseded by the @code{ISHFT} intrinsic, which
6005 is standard in Fortran 95 and later.
6007 @item @emph{Standard}:
6013 @item @emph{Syntax}:
6014 @code{RESULT = LSHIFT(I, SHIFT)}
6016 @item @emph{Arguments}:
6017 @multitable @columnfractions .15 .70
6018 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
6019 @item @var{SHIFT} @tab The type shall be @code{INTEGER(*)}.
6022 @item @emph{Return value}:
6023 The return value is of type @code{INTEGER(*)} and of the same kind as
6026 @item @emph{See also}:
6027 @ref{ISHFT}, @ref{ISHFTC}, @ref{RSHIFT}
6033 @section @code{LSTAT} --- Get file status
6034 @cindex @code{LSTAT} intrinsic
6035 @cindex file system operations
6038 @item @emph{Description}:
6039 @code{LSTAT} is identical to @ref{STAT}, except that if path is a symbolic link,
6040 then the link itself is statted, not the file that it refers to.
6042 The elements in @code{BUFF} are the same as described by @ref{STAT}.
6044 @item @emph{Standard}:
6048 Non-elemental subroutine
6050 @item @emph{Syntax}:
6051 @code{CALL LSTAT(FILE, BUFF [, STATUS])}
6053 @item @emph{Arguments}:
6054 @multitable @columnfractions .15 .70
6055 @item @var{FILE} @tab The type shall be @code{CHARACTER(*)}, a valid path within the file system.
6056 @item @var{BUFF} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
6057 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0
6058 on success and a system specific error code otherwise.
6061 @item @emph{Example}:
6062 See @ref{STAT} for an example.
6064 @item @emph{See also}:
6065 To stat an open file: @ref{FSTAT}, to stat a file: @ref{STAT}
6071 @section @code{LTIME} --- Convert time to local time info
6072 @cindex @code{LTIME} intrinsic
6073 @cindex time, conversion function
6076 @item @emph{Description}:
6077 Given a system time value @var{STIME} (as provided by the @code{TIME8()}
6078 intrinsic), fills @var{TARRAY} with values extracted from it appropriate
6079 to the local time zone using @code{localtime(3)}.
6081 @item @emph{Standard}:
6087 @item @emph{Syntax}:
6088 @code{CALL LTIME(STIME, TARRAY)}
6090 @item @emph{Arguments}:
6091 @multitable @columnfractions .15 .70
6092 @item @var{STIME} @tab An @code{INTEGER(*)} scalar expression
6093 corresponding to a system time, with
6095 @item @var{TARRAY} @tab A default @code{INTEGER} array with 9 elements,
6096 with @code{INTENT(OUT)}.
6099 @item @emph{Return value}:
6100 The elements of @var{TARRAY} are assigned as follows:
6102 @item Seconds after the minute, range 0--59 or 0--61 to allow for leap
6104 @item Minutes after the hour, range 0--59
6105 @item Hours past midnight, range 0--23
6106 @item Day of month, range 0--31
6107 @item Number of months since January, range 0--12
6108 @item Years since 1900
6109 @item Number of days since Sunday, range 0--6
6110 @item Days since January 1
6111 @item Daylight savings indicator: positive if daylight savings is in
6112 effect, zero if not, and negative if the information is not
6116 @item @emph{See also}:
6117 @ref{CTIME}, @ref{GMTIME}, @ref{TIME}, @ref{TIME8}
6124 @section @code{MALLOC} --- Allocate dynamic memory
6125 @cindex @code{MALLOC} intrinsic
6126 @cindex Cray pointers
6129 @item @emph{Description}:
6130 @code{MALLOC(SIZE)} allocates @var{SIZE} bytes of dynamic memory and
6131 returns the address of the allocated memory. The @code{MALLOC} intrinsic
6132 is an extension intended to be used with Cray pointers, and is provided
6133 in GNU Fortran to allow the user to compile legacy code. For new code
6134 using Fortran 95 pointers, the memory allocation intrinsic is
6137 @item @emph{Standard}:
6141 Non-elemental function
6143 @item @emph{Syntax}:
6144 @code{PTR = MALLOC(SIZE)}
6146 @item @emph{Arguments}:
6147 @multitable @columnfractions .15 .70
6148 @item @var{SIZE} @tab The type shall be @code{INTEGER(*)}.
6151 @item @emph{Return value}:
6152 The return value is of type @code{INTEGER(K)}, with @var{K} such that
6153 variables of type @code{INTEGER(K)} have the same size as
6154 C pointers (@code{sizeof(void *)}).
6156 @item @emph{Example}:
6157 The following example demonstrates the use of @code{MALLOC} and
6158 @code{FREE} with Cray pointers. This example is intended to run on
6159 32-bit systems, where the default integer kind is suitable to store
6160 pointers; on 64-bit systems, ptr_x would need to be declared as
6161 @code{integer(kind=8)}.
6170 ptr_x = malloc(20*8)
6172 x(i) = sqrt(1.0d0 / i)
6180 end program test_malloc
6183 @item @emph{See also}:
6190 @section @code{MATMUL} --- matrix multiplication
6191 @cindex @code{MATMUL} intrinsic
6192 @cindex matrix operations
6195 @item @emph{Description}:
6196 Performs a matrix multiplication on numeric or logical arguments.
6198 @item @emph{Standard}:
6202 Transformational function
6204 @item @emph{Syntax}:
6205 @code{RESULT = MATMUL(MATRIX_A, MATRIX_B)}
6207 @item @emph{Arguments}:
6208 @multitable @columnfractions .15 .70
6209 @item @var{MATRIX_A} @tab An array of @code{INTEGER(*)},
6210 @code{REAL(*)}, @code{COMPLEX(*)}, or
6211 @code{LOGICAL(*)} type, with a rank of
6213 @item @var{MATRIX_B} @tab An array of @code{INTEGER(*)},
6214 @code{REAL(*)}, or @code{COMPLEX(*)} type if
6215 @var{MATRIX_A} is of a numeric type;
6216 otherwise, an array of @code{LOGICAL(*)}
6217 type. The rank shall be one or two, and the
6218 first (or only) dimension of @var{MATRIX_B}
6219 shall be equal to the last (or only)
6220 dimension of @var{MATRIX_A}.
6223 @item @emph{Return value}:
6224 The matrix product of @var{MATRIX_A} and @var{MATRIX_B}. The type and
6225 kind of the result follow the usual type and kind promotion rules, as
6226 for the @code{*} or @code{.AND.} operators.
6228 @item @emph{See also}:
6234 @section @code{MAX} --- Maximum value of an argument list
6235 @cindex @code{MAX} intrinsic
6238 @item @emph{Description}:
6239 Returns the argument with the largest (most positive) value.
6241 @item @emph{Standard}:
6247 @item @emph{Syntax}:
6248 @code{RESULT = MAX(A1, A2 [, A3 [, ...]])}
6250 @item @emph{Arguments}:
6251 @multitable @columnfractions .15 .70
6252 @item @var{A1} @tab The type shall be @code{INTEGER(*)} or
6254 @item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
6255 as @var{A1}. (As a GNU extension,
6256 arguments of different kinds are
6260 @item @emph{Return value}:
6261 The return value corresponds to the maximum value among the arguments,
6262 and has the same type and kind as the first argument.
6264 @item @emph{Specific names}:
6265 @multitable @columnfractions .20 .20 .20 .25
6266 @item Name @tab Argument @tab Return type @tab Standard
6267 @item @code{MAX0(I)} @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)} @tab F77 and later
6268 @item @code{AMAX0(I)} @tab @code{INTEGER(4) I} @tab @code{REAL(MAX(X))} @tab F77 and later
6269 @item @code{MAX1(X)} @tab @code{REAL(*) X} @tab @code{INT(MAX(X))} @tab F77 and later
6270 @item @code{AMAX1(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab F77 and later
6271 @item @code{DMAX1(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
6274 @item @emph{See also}:
6275 @ref{MAXLOC} @ref{MAXVAL}, @ref{MIN}
6282 @section @code{MAXEXPONENT} --- Maximum exponent of a real kind
6283 @cindex @code{MAXEXPONENT} intrinsic
6284 @cindex maximum exponent
6285 @cindex exponent, maximum
6288 @item @emph{Description}:
6289 @code{MAXEXPONENT(X)} returns the maximum exponent in the model of the
6292 @item @emph{Standard}:
6298 @item @emph{Syntax}:
6299 @code{RESULT = MAXEXPONENT(X)}
6301 @item @emph{Arguments}:
6302 @multitable @columnfractions .15 .70
6303 @item @var{X} @tab Shall be of type @code{REAL}.
6306 @item @emph{Return value}:
6307 The return value is of type @code{INTEGER} and of the default integer
6310 @item @emph{Example}:
6316 print *, minexponent(x), maxexponent(x)
6317 print *, minexponent(y), maxexponent(y)
6318 end program exponents
6325 @section @code{MAXLOC} --- Location of the maximum value within an array
6326 @cindex @code{MAXLOC} intrinsic
6329 @item @emph{Description}:
6330 Determines the location of the element in the array with the maximum
6331 value, or, if the @var{DIM} argument is supplied, determines the
6332 locations of the maximum element along each row of the array in the
6333 @var{DIM} direction. If @var{MASK} is present, only the elements for
6334 which @var{MASK} is @code{.TRUE.} are considered. If more than one
6335 element in the array has the maximum value, the location returned is
6336 that of the first such element in array element order. If the array has
6337 zero size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
6338 the result is an array of zeroes. Similarly, if @var{DIM} is supplied
6339 and all of the elements of @var{MASK} along a given row are zero, the
6340 result value for that row is zero.
6342 @item @emph{Standard}:
6346 Transformational function
6348 @item @emph{Syntax}:
6349 @multitable @columnfractions .80
6350 @item @code{RESULT = MAXLOC(ARRAY, DIM [, MASK])}
6351 @item @code{RESULT = MAXLOC(ARRAY [, MASK])}
6354 @item @emph{Arguments}:
6355 @multitable @columnfractions .15 .70
6356 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER(*)},
6357 @code{REAL(*)}, or @code{CHARACTER(*)}.
6358 @item @var{DIM} @tab (Optional) Shall be a scalar of type
6359 @code{INTEGER(*)}, with a value between one
6360 and the rank of @var{ARRAY}, inclusive. It
6361 may not be an optional dummy argument.
6362 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL(*)},
6363 and conformable with @var{ARRAY}.
6366 @item @emph{Return value}:
6367 If @var{DIM} is absent, the result is a rank-one array with a length
6368 equal to the rank of @var{ARRAY}. If @var{DIM} is present, the result
6369 is an array with a rank one less than the rank of @var{ARRAY}, and a
6370 size corresponding to the size of @var{ARRAY} with the @var{DIM}
6371 dimension removed. If @var{DIM} is present and @var{ARRAY} has a rank
6372 of one, the result is a scalar. In all cases, the result is of default
6373 @code{INTEGER} type.
6375 @item @emph{See also}:
6376 @ref{MAX}, @ref{MAXVAL}
6383 @section @code{MAXVAL} --- Maximum value of an array
6384 @cindex @code{MAXVAL} intrinsic
6387 @item @emph{Description}:
6388 Determines the maximum value of the elements in an array value, or, if
6389 the @var{DIM} argument is supplied, determines the maximum value along
6390 each row of the array in the @var{DIM} direction. If @var{MASK} is
6391 present, only the elements for which @var{MASK} is @code{.TRUE.} are
6392 considered. If the array has zero size, or all of the elements of
6393 @var{MASK} are @code{.FALSE.}, then the result is the most negative
6394 number of the type and kind of @var{ARRAY} if @var{ARRAY} is numeric, or
6395 a string of nulls if @var{ARRAY} is of character type.
6397 @item @emph{Standard}:
6401 Transformational function
6403 @item @emph{Syntax}:
6404 @multitable @columnfractions .80
6405 @item @code{RESULT = MAXVAL(ARRAY, DIM [, MASK])}
6406 @item @code{RESULT = MAXVAL(ARRAY [, MASK])}
6409 @item @emph{Arguments}:
6410 @multitable @columnfractions .15 .70
6411 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER(*)},
6412 @code{REAL(*)}, or @code{CHARACTER(*)}.
6413 @item @var{DIM} @tab (Optional) Shall be a scalar of type
6414 @code{INTEGER(*)}, with a value between one
6415 and the rank of @var{ARRAY}, inclusive. It
6416 may not be an optional dummy argument.
6417 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL(*)},
6418 and conformable with @var{ARRAY}.
6421 @item @emph{Return value}:
6422 If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
6423 is a scalar. If @var{DIM} is present, the result is an array with a
6424 rank one less than the rank of @var{ARRAY}, and a size corresponding to
6425 the size of @var{ARRAY} with the @var{DIM} dimension removed. In all
6426 cases, the result is of the same type and kind as @var{ARRAY}.
6428 @item @emph{See also}:
6429 @ref{MAX}, @ref{MAXLOC}
6435 @section @code{MERGE} --- Merge variables
6436 @cindex @code{MERGE} intrinsic
6439 @item @emph{Description}:
6440 Select values from two arrays according to a logical mask. The result
6441 is equal to @var{TSOURCE} if @var{MASK} is @code{.TRUE.}, or equal to
6442 @var{FSOURCE} if it is @code{.FALSE.}.
6444 @item @emph{Standard}:
6450 @item @emph{Syntax}:
6451 @code{RESULT = MERGE(TSOURCE, FSOURCE, MASK)}
6453 @item @emph{Arguments}:
6454 @multitable @columnfractions .15 .70
6455 @item @var{TSOURCE} @tab May be of any type.
6456 @item @var{FSOURCE} @tab Shall be of the same type and type parameters
6458 @item @var{MASK} @tab Shall be of type @code{LOGICAL(*)}.
6461 @item @emph{Return value}:
6462 The result is of the same type and type parameters as @var{TSOURCE}.
6469 @section @code{MIN} --- Minimum value of an argument list
6470 @cindex @code{MIN} intrinsic
6473 @item @emph{Description}:
6474 Returns the argument with the smallest (most negative) value.
6476 @item @emph{Standard}:
6482 @item @emph{Syntax}:
6483 @code{RESULT = MIN(A1, A2 [, A3, ...])}
6485 @item @emph{Arguments}:
6486 @multitable @columnfractions .15 .70
6487 @item @var{A1} @tab The type shall be @code{INTEGER(*)} or
6489 @item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
6490 as @var{A1}. (As a GNU extension,
6491 arguments of different kinds are
6495 @item @emph{Return value}:
6496 The return value corresponds to the maximum value among the arguments,
6497 and has the same type and kind as the first argument.
6499 @item @emph{Specific names}:
6500 @multitable @columnfractions .20 .20 .20 .25
6501 @item Name @tab Argument @tab Return type @tab Standard
6502 @item @code{MIN0(I)} @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)} @tab F77 and later
6503 @item @code{AMIN0(I)} @tab @code{INTEGER(4) I} @tab @code{REAL(MIN(X))} @tab F77 and later
6504 @item @code{MIN1(X)} @tab @code{REAL(*) X} @tab @code{INT(MIN(X))} @tab F77 and later
6505 @item @code{AMIN1(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab F77 and later
6506 @item @code{DMIN1(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
6509 @item @emph{See also}:
6510 @ref{MAX}, @ref{MINLOC}, @ref{MINVAL}
6514 @section @code{MINEXPONENT} --- Minimum exponent of a real kind
6515 @cindex @code{MINEXPONENT} intrinsic
6516 @cindex minimum exponent
6517 @cindex exponent, minimum
6520 @item @emph{Description}:
6521 @code{MINEXPONENT(X)} returns the minimum exponent in the model of the
6524 @item @emph{Standard}:
6530 @item @emph{Syntax}:
6531 @code{RESULT = MINEXPONENT(X)}
6533 @item @emph{Arguments}:
6534 @multitable @columnfractions .15 .70
6535 @item @var{X} @tab Shall be of type @code{REAL}.
6538 @item @emph{Return value}:
6539 The return value is of type @code{INTEGER} and of the default integer
6542 @item @emph{Example}:
6543 See @code{MAXEXPONENT} for an example.
6549 @section @code{MINLOC} --- Location of the minimum value within an array
6550 @cindex @code{MINLOC} intrinsic
6553 @item @emph{Description}:
6554 Determines the location of the element in the array with the minimum
6555 value, or, if the @var{DIM} argument is supplied, determines the
6556 locations of the minimum element along each row of the array in the
6557 @var{DIM} direction. If @var{MASK} is present, only the elements for
6558 which @var{MASK} is @code{.TRUE.} are considered. If more than one
6559 element in the array has the minimum value, the location returned is
6560 that of the first such element in array element order. If the array has
6561 zero size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
6562 the result is an array of zeroes. Similarly, if @var{DIM} is supplied
6563 and all of the elements of @var{MASK} along a given row are zero, the
6564 result value for that row is zero.
6566 @item @emph{Standard}:
6570 Transformational function
6572 @item @emph{Syntax}:
6573 @multitable @columnfractions .80
6574 @item @code{RESULT = MINLOC(ARRAY, DIM [, MASK])}
6575 @item @code{RESULT = MINLOC(ARRAY [, MASK])}
6578 @item @emph{Arguments}:
6579 @multitable @columnfractions .15 .70
6580 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER(*)},
6581 @code{REAL(*)}, or @code{CHARACTER(*)}.
6582 @item @var{DIM} @tab (Optional) Shall be a scalar of type
6583 @code{INTEGER(*)}, with a value between one
6584 and the rank of @var{ARRAY}, inclusive. It
6585 may not be an optional dummy argument.
6586 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL(*)},
6587 and conformable with @var{ARRAY}.
6590 @item @emph{Return value}:
6591 If @var{DIM} is absent, the result is a rank-one array with a length
6592 equal to the rank of @var{ARRAY}. If @var{DIM} is present, the result
6593 is an array with a rank one less than the rank of @var{ARRAY}, and a
6594 size corresponding to the size of @var{ARRAY} with the @var{DIM}
6595 dimension removed. If @var{DIM} is present and @var{ARRAY} has a rank
6596 of one, the result is a scalar. In all cases, the result is of default
6597 @code{INTEGER} type.
6599 @item @emph{See also}:
6600 @ref{MIN}, @ref{MINVAL}
6607 @section @code{MINVAL} --- Minimum value of an array
6608 @cindex @code{MINVAL} intrinsic
6611 @item @emph{Description}:
6612 Determines the minimum value of the elements in an array value, or, if
6613 the @var{DIM} argument is supplied, determines the minimum value along
6614 each row of the array in the @var{DIM} direction. If @var{MASK} is
6615 present, only the elements for which @var{MASK} is @code{.TRUE.} are
6616 considered. If the array has zero size, or all of the elements of
6617 @var{MASK} are @code{.FALSE.}, then the result is @code{HUGE(ARRAY)} if
6618 @var{ARRAY} is numeric, or a string of @code{CHAR(255)} characters if
6619 @var{ARRAY} is of character type.
6621 @item @emph{Standard}:
6625 Transformational function
6627 @item @emph{Syntax}:
6628 @multitable @columnfractions .80
6629 @item @code{RESULT = MINVAL(ARRAY, DIM [, MASK])}
6630 @item @code{RESULT = MINVAL(ARRAY [, MASK])}
6633 @item @emph{Arguments}:
6634 @multitable @columnfractions .15 .70
6635 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER(*)},
6636 @code{REAL(*)}, or @code{CHARACTER(*)}.
6637 @item @var{DIM} @tab (Optional) Shall be a scalar of type
6638 @code{INTEGER(*)}, with a value between one
6639 and the rank of @var{ARRAY}, inclusive. It
6640 may not be an optional dummy argument.
6641 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL(*)},
6642 and conformable with @var{ARRAY}.
6645 @item @emph{Return value}:
6646 If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
6647 is a scalar. If @var{DIM} is present, the result is an array with a
6648 rank one less than the rank of @var{ARRAY}, and a size corresponding to
6649 the size of @var{ARRAY} with the @var{DIM} dimension removed. In all
6650 cases, the result is of the same type and kind as @var{ARRAY}.
6652 @item @emph{See also}:
6653 @ref{MIN}, @ref{MINLOC}
6660 @section @code{MOD} --- Remainder function
6661 @cindex @code{MOD} intrinsic
6662 @cindex @code{AMOD} intrinsic
6663 @cindex @code{DMOD} intrinsic
6667 @item @emph{Description}:
6668 @code{MOD(A,P)} computes the remainder of the division of A by P. It is
6669 calculated as @code{A - (INT(A/P) * P)}.
6671 @item @emph{Standard}:
6677 @item @emph{Syntax}:
6678 @code{RESULT = MOD(A, P)}
6680 @item @emph{Arguments}:
6681 @multitable @columnfractions .15 .70
6682 @item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL}
6683 @item @var{P} @tab Shall be a scalar of the same type as @var{A} and not
6687 @item @emph{Return value}:
6688 The kind of the return value is the result of cross-promoting
6689 the kinds of the arguments.
6691 @item @emph{Example}:
6695 print *, mod(17.5,5.5)
6696 print *, mod(17.5d0,5.5)
6697 print *, mod(17.5,5.5d0)
6700 print *, mod(-17.5,5.5)
6701 print *, mod(-17.5d0,5.5)
6702 print *, mod(-17.5,5.5d0)
6705 print *, mod(17.5,-5.5)
6706 print *, mod(17.5d0,-5.5)
6707 print *, mod(17.5,-5.5d0)
6708 end program test_mod
6711 @item @emph{Specific names}:
6712 @multitable @columnfractions .20 .20 .20 .25
6713 @item Name @tab Arguments @tab Return type @tab Standard
6714 @item @code{AMOD(A,P)} @tab @code{REAL(4)} @tab @code{REAL(4)} @tab F95 and later
6715 @item @code{DMOD(A,P)} @tab @code{REAL(8)} @tab @code{REAL(8)} @tab F95 and later
6722 @section @code{MODULO} --- Modulo function
6723 @cindex @code{MODULO} intrinsic
6727 @item @emph{Description}:
6728 @code{MODULO(A,P)} computes the @var{A} modulo @var{P}.
6730 @item @emph{Standard}:
6736 @item @emph{Syntax}:
6737 @code{RESULT = MODULO(A, P)}
6739 @item @emph{Arguments}:
6740 @multitable @columnfractions .15 .70
6741 @item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL}
6742 @item @var{P} @tab Shall be a scalar of the same type and kind as @var{A}
6745 @item @emph{Return value}:
6746 The type and kind of the result are those of the arguments.
6748 @item If @var{A} and @var{P} are of type @code{INTEGER}:
6749 @code{MODULO(A,P)} has the value @var{R} such that @code{A=Q*P+R}, where
6750 @var{Q} is an integer and @var{R} is between 0 (inclusive) and @var{P}
6752 @item If @var{A} and @var{P} are of type @code{REAL}:
6753 @code{MODULO(A,P)} has the value of @code{A - FLOOR (A / P) * P}.
6755 In all cases, if @var{P} is zero the result is processor-dependent.
6757 @item @emph{Example}:
6760 print *, modulo(17,3)
6761 print *, modulo(17.5,5.5)
6763 print *, modulo(-17,3)
6764 print *, modulo(-17.5,5.5)
6766 print *, modulo(17,-3)
6767 print *, modulo(17.5,-5.5)
6768 end program test_mod
6776 @section @code{MOVE_ALLOC} --- Move allocation from one object to another
6777 @cindex @code{MOVE_ALLOC} intrinsic
6778 @cindex moving allocation
6779 @cindex allocation, moving
6782 @item @emph{Description}:
6783 @code{MOVE_ALLOC(SRC, DEST)} moves the allocation from @var{SRC} to
6784 @var{DEST}. @var{SRC} will become deallocated in the process.
6786 @item @emph{Standard}:
6792 @item @emph{Syntax}:
6793 @code{CALL MOVE_ALLOC(SRC, DEST)}
6795 @item @emph{Arguments}:
6796 @multitable @columnfractions .15 .70
6797 @item @var{SRC} @tab @code{ALLOCATABLE}, @code{INTENT(INOUT)}, may be
6798 of any type and kind.
6799 @item @var{DEST} @tab @code{ALLOCATABLE}, @code{INTENT(OUT)}, shall be
6800 of the same type, kind and rank as @var{SRC}
6803 @item @emph{Return value}:
6806 @item @emph{Example}:
6808 program test_move_alloc
6809 integer, allocatable :: a(:), b(:)
6813 call move_alloc(a, b)
6814 print *, allocated(a), allocated(b)
6816 end program test_move_alloc
6823 @section @code{MVBITS} --- Move bits from one integer to another
6824 @cindex @code{MVBITS} intrinsic
6825 @cindex bit operations
6828 @item @emph{Description}:
6829 Moves @var{LEN} bits from positions @var{FROMPOS} through
6830 @code{FROMPOS+LEN-1} of @var{FROM} to positions @var{TOPOS} through
6831 @code{TOPOS+LEN-1} of @var{TO}. The portion of argument @var{TO} not
6832 affected by the movement of bits is unchanged. The values of
6833 @code{FROMPOS+LEN-1} and @code{TOPOS+LEN-1} must be less than
6834 @code{BIT_SIZE(FROM)}.
6836 @item @emph{Standard}:
6842 @item @emph{Syntax}:
6843 @code{RESULT = MVBITS(FROM, FROMPOS, LEN, TO, TOPOS)}
6845 @item @emph{Arguments}:
6846 @multitable @columnfractions .15 .70
6847 @item @var{FROM} @tab The type shall be @code{INTEGER(*)}.
6848 @item @var{FROMPOS} @tab The type shall be @code{INTEGER(*)}.
6849 @item @var{LEN} @tab The type shall be @code{INTEGER(*)}.
6850 @item @var{TO} @tab The type shall be @code{INTEGER(*)}, of the
6851 same kind as @var{FROM}.
6852 @item @var{TOPOS} @tab The type shall be @code{INTEGER(*)}.
6855 @item @emph{Return value}:
6856 The return value is of type @code{INTEGER(*)} and of the same kind as
6859 @item @emph{See also}:
6860 @ref{IBCLR}, @ref{IBSET}, @ref{IBITS}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
6867 @section @code{NEAREST} --- Nearest representable number
6868 @cindex @code{NEAREST} intrinsic
6869 @cindex processor-representable number
6872 @item @emph{Description}:
6873 @code{NEAREST(X, S)} returns the processor-representable number nearest
6874 to @code{X} in the direction indicated by the sign of @code{S}.
6876 @item @emph{Standard}:
6882 @item @emph{Syntax}:
6883 @code{RESULT = NEAREST(X, S)}
6885 @item @emph{Arguments}:
6886 @multitable @columnfractions .15 .70
6887 @item @var{X} @tab Shall be of type @code{REAL}.
6888 @item @var{S} @tab (Optional) shall be of type @code{REAL} and
6892 @item @emph{Return value}:
6893 The return value is of the same type as @code{X}. If @code{S} is
6894 positive, @code{NEAREST} returns the processor-representable number
6895 greater than @code{X} and nearest to it. If @code{S} is negative,
6896 @code{NEAREST} returns the processor-representable number smaller than
6897 @code{X} and nearest to it.
6899 @item @emph{Example}:
6901 program test_nearest
6903 x = nearest(42.0, 1.0)
6904 y = nearest(42.0, -1.0)
6905 write (*,"(3(G20.15))") x, y, x - y
6906 end program test_nearest
6913 @section @code{NEW_LINE} --- New line character
6914 @cindex @code{NEW_LINE} intrinsic
6915 @cindex @code{NEW_LINE} intrinsic
6918 @item @emph{Description}:
6919 @code{NEW_LINE(C)} returns the new-line character.
6921 @item @emph{Standard}:
6927 @item @emph{Syntax}:
6928 @code{RESULT = NEW_LINE(C)}
6930 @item @emph{Arguments}:
6931 @multitable @columnfractions .15 .70
6932 @item @var{C} @tab The argument shall be a scalar or array of the
6933 type @code{CHARACTER}.
6936 @item @emph{Return value}:
6937 Returns a @var{CHARACTER} scalar of length one with the new-line character of
6938 the same kind as parameter @var{C}.
6940 @item @emph{Example}:
6944 write(*,'(A)') 'This is record 1.'//NEW_LINE('A')//'This is record 2.'
6952 @section @code{NINT} --- Nearest whole number
6953 @cindex @code{NINT} intrinsic
6954 @cindex @code{IDNINT} intrinsic
6955 @cindex whole number
6958 @item @emph{Description}:
6959 @code{NINT(X)} rounds its argument to the nearest whole number.
6961 @item @emph{Standard}:
6967 @item @emph{Syntax}:
6968 @code{RESULT = NINT(X)}
6970 @item @emph{Arguments}:
6971 @multitable @columnfractions .15 .70
6972 @item @var{X} @tab The type of the argument shall be @code{REAL}.
6975 @item @emph{Return value}:
6976 Returns @var{A} with the fractional portion of its magnitude eliminated by
6977 rounding to the nearest whole number and with its sign preserved,
6978 converted to an @code{INTEGER} of the default kind.
6980 @item @emph{Example}:
6987 print *, nint(x4), idnint(x8)
6988 end program test_nint
6991 @item @emph{Specific names}:
6992 @multitable @columnfractions .25 .25 .25
6993 @item Name @tab Argument @tab Standard
6994 @item @code{IDNINT(X)} @tab @code{REAL(8)} @tab F95 and later
6997 @item @emph{See also}:
6998 @ref{CEILING}, @ref{FLOOR}
7004 @section @code{NOT} --- Logical negation
7005 @cindex @code{NOT} intrinsic
7006 @cindex bit operations
7009 @item @emph{Description}:
7010 @code{NOT} returns the bitwise boolean inverse of @var{I}.
7012 @item @emph{Standard}:
7018 @item @emph{Syntax}:
7019 @code{RESULT = NOT(I)}
7021 @item @emph{Arguments}:
7022 @multitable @columnfractions .15 .70
7023 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
7026 @item @emph{Return value}:
7027 The return type is @code{INTEGER(*)}, of the same kind as the
7030 @item @emph{See also}:
7031 @ref{IAND}, @ref{IEOR}, @ref{IOR}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}
7039 @section @code{NULL} --- Function that returns an disassociated pointer
7040 @cindex @code{NULL} intrinsic
7041 @cindex undocumented intrinsic
7043 Intrinsic implemented, documentation pending.
7046 @item @emph{Description}:
7047 @item @emph{Standard}:
7051 Transformational function
7053 @item @emph{Syntax}:
7054 @item @emph{Arguments}:
7055 @item @emph{Return value}:
7056 @item @emph{Example}:
7057 @item @emph{See also}:
7065 @section @code{OR} --- Bitwise logical OR
7066 @cindex @code{OR} intrinsic
7067 @cindex bit operations
7070 @item @emph{Description}:
7071 Bitwise logical @code{OR}.
7073 This intrinsic routine is provided for backwards compatibility with
7074 GNU Fortran 77. For integer arguments, programmers should consider
7075 the use of the @ref{IOR} intrinsic defined by the Fortran standard.
7077 @item @emph{Standard}:
7081 Non-elemental function
7083 @item @emph{Syntax}:
7084 @code{RESULT = OR(X, Y)}
7086 @item @emph{Arguments}:
7087 @multitable @columnfractions .15 .70
7088 @item @var{X} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
7089 @item @var{Y} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
7092 @item @emph{Return value}:
7093 The return type is either @code{INTEGER(*)} or @code{LOGICAL}
7094 after cross-promotion of the arguments.
7096 @item @emph{Example}:
7099 LOGICAL :: T = .TRUE., F = ..FALSE.
7101 DATA a / Z'F' /, b / Z'3' /
7103 WRITE (*,*) OR(T, T), OR(T, F), OR(F, T), OR(F, F)
7104 WRITE (*,*) OR(a, b)
7108 @item @emph{See also}:
7109 F95 elemental function: @ref{IOR}
7116 @section @code{PACK} --- Pack an array into an array of rank one
7117 @cindex @code{PACK} intrinsic
7118 @cindex undocumented intrinsic
7120 Intrinsic implemented, documentation pending.
7123 @item @emph{Description}:
7124 @item @emph{Standard}:
7128 Transformational function
7130 @item @emph{Syntax}:
7131 @item @emph{Arguments}:
7132 @item @emph{Return value}:
7133 @item @emph{Example}:
7134 @item @emph{Specific names}:
7135 @item @emph{See also}:
7142 @section @code{PERROR} --- Print system error message
7143 @cindex @code{PERROR} intrinsic
7146 @item @emph{Description}:
7147 Prints (on the C @code{stderr} stream) a newline-terminated error
7148 message corresponding to the last system error. This is prefixed by
7149 @var{STRING}, a colon and a space. See @code{perror(3)}.
7151 @item @emph{Standard}:
7157 @item @emph{Syntax}:
7158 @code{CALL PERROR(STRING)}
7160 @item @emph{Arguments}:
7161 @multitable @columnfractions .15 .70
7162 @item @var{STRING} @tab A scalar of default @code{CHARACTER} type.
7165 @item @emph{See also}:
7172 @section @code{PRECISION} --- Decimal precision of a real kind
7173 @cindex @code{PRECISION} intrinsic
7174 @cindex precision of a real variable
7177 @item @emph{Description}:
7178 @code{PRECISION(X)} returns the decimal precision in the model of the
7181 @item @emph{Standard}:
7187 @item @emph{Syntax}:
7188 @code{RESULT = PRECISION(X)}
7190 @item @emph{Arguments}:
7191 @multitable @columnfractions .15 .70
7192 @item @var{X} @tab Shall be of type @code{REAL} or @code{COMPLEX}.
7195 @item @emph{Return value}:
7196 The return value is of type @code{INTEGER} and of the default integer
7199 @item @emph{Example}:
7201 program prec_and_range
7202 real(kind=4) :: x(2)
7203 complex(kind=8) :: y
7205 print *, precision(x), range(x)
7206 print *, precision(y), range(y)
7207 end program prec_and_range
7214 @section @code{PRESENT} --- Determine whether an optional argument is specified
7215 @cindex @code{PRESENT} intrinsic
7216 @cindex undocumented intrinsic
7218 Intrinsic implemented, documentation pending.
7221 @item @emph{Description}:
7222 @item @emph{Standard}:
7228 @item @emph{Syntax}:
7229 @item @emph{Arguments}:
7230 @item @emph{Return value}:
7231 @item @emph{Example}:
7232 @item @emph{See also}:
7238 @section @code{PRODUCT} --- Product of array elements
7239 @cindex @code{PRODUCT} intrinsic
7240 @cindex undocumented intrinsic
7242 Intrinsic implemented, documentation pending.
7245 @item @emph{Description}:
7246 @item @emph{Standard}:
7250 Transformational function
7252 @item @emph{Syntax}:
7253 @item @emph{Arguments}:
7254 @item @emph{Return value}:
7255 @item @emph{Example}:
7256 @item @emph{Specific names}:
7257 @item @emph{See also}:
7264 @section @code{RADIX} --- Base of a model number
7265 @cindex @code{RADIX} intrinsic
7269 @item @emph{Description}:
7270 @code{RADIX(X)} returns the base of the model representing the entity @var{X}.
7272 @item @emph{Standard}:
7278 @item @emph{Syntax}:
7279 @code{RESULT = RADIX(X)}
7281 @item @emph{Arguments}:
7282 @multitable @columnfractions .15 .70
7283 @item @var{X} @tab Shall be of type @code{INTEGER} or @code{REAL}
7286 @item @emph{Return value}:
7287 The return value is a scalar of type @code{INTEGER} and of the default
7290 @item @emph{Example}:
7293 print *, "The radix for the default integer kind is", radix(0)
7294 print *, "The radix for the default real kind is", radix(0.0)
7295 end program test_radix
7303 @section @code{RAN} --- Real pseudo-random number
7304 @cindex @code{RAN} intrinsic
7305 @cindex random numbers
7308 @item @emph{Description}:
7309 For compatibility with HP FORTRAN 77/iX, the @code{RAN} intrinsic is
7310 provided as an alias for @code{RAND}. See @ref{RAND} for complete
7313 @item @emph{Standard}:
7317 Non-elemental function
7319 @item @emph{See also}:
7320 @ref{RAND}, @ref{RANDOM_NUMBER}
7326 @section @code{RAND} --- Real pseudo-random number
7327 @cindex @code{RAND} intrinsic
7328 @cindex random numbers
7331 @item @emph{Description}:
7332 @code{RAND(FLAG)} returns a pseudo-random number from a uniform
7333 distribution between 0 and 1. If @var{FLAG} is 0, the next number
7334 in the current sequence is returned; if @var{FLAG} is 1, the generator
7335 is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
7336 it is used as a new seed with @code{SRAND}.
7338 @item @emph{Standard}:
7342 Non-elemental function
7344 @item @emph{Syntax}:
7345 @code{RESULT = RAND(FLAG)}
7347 @item @emph{Arguments}:
7348 @multitable @columnfractions .15 .70
7349 @item @var{FLAG} @tab Shall be a scalar @code{INTEGER} of kind 4.
7352 @item @emph{Return value}:
7353 The return value is of @code{REAL} type and the default kind.
7355 @item @emph{Example}:
7358 integer,parameter :: seed = 86456
7361 print *, rand(), rand(), rand(), rand()
7362 print *, rand(seed), rand(), rand(), rand()
7363 end program test_rand
7366 @item @emph{See also}:
7367 @ref{SRAND}, @ref{RANDOM_NUMBER}
7374 @section @code{RANDOM_NUMBER} --- Pseudo-random number
7375 @cindex @code{RANDOM_NUMBER} intrinsic
7376 @cindex random numbers
7378 Intrinsic implemented, documentation pending.
7381 @item @emph{Description}:
7382 @item @emph{Standard}:
7386 Elemental subroutine
7388 @item @emph{Syntax}:
7389 @item @emph{Arguments}:
7390 @item @emph{Return value}:
7391 @item @emph{Example}:
7392 @item @emph{See also}:
7399 @section @code{RANDOM_SEED} --- Initialize a pseudo-random number sequence
7400 @cindex @code{RANDOM_SEED} intrinsic
7401 @cindex random numbers
7403 Intrinsic implemented, documentation pending.
7406 @item @emph{Description}:
7407 @item @emph{Standard}:
7413 @item @emph{Syntax}:
7414 @item @emph{Arguments}:
7415 @item @emph{Return value}:
7416 @item @emph{Example}:
7417 @item @emph{See also}:
7424 @section @code{RANGE} --- Decimal exponent range of a real kind
7425 @cindex @code{RANGE} intrinsic
7426 @cindex range of a real variable
7429 @item @emph{Description}:
7430 @code{RANGE(X)} returns the decimal exponent range in the model of the
7433 @item @emph{Standard}:
7439 @item @emph{Syntax}:
7440 @code{RESULT = RANGE(X)}
7442 @item @emph{Arguments}:
7443 @multitable @columnfractions .15 .70
7444 @item @var{X} @tab Shall be of type @code{REAL} or @code{COMPLEX}.
7447 @item @emph{Return value}:
7448 The return value is of type @code{INTEGER} and of the default integer
7451 @item @emph{Example}:
7452 See @code{PRECISION} for an example.
7458 @section @code{REAL} --- Convert to real type
7459 @cindex @code{REAL} intrinsic
7460 @cindex @code{REALPART} intrinsic
7464 @item @emph{Description}:
7465 @code{REAL(X [, KIND])} converts its argument @var{X} to a real type. The
7466 @code{REALPART(X)} function is provided for compatibility with @command{g77},
7467 and its use is strongly discouraged.
7469 @item @emph{Standard}:
7475 @item @emph{Syntax}:
7476 @multitable @columnfractions .80
7477 @item @code{RESULT = REAL(X [, KIND])}
7478 @item @code{RESULT = REALPART(Z)}
7481 @item @emph{Arguments}:
7482 @multitable @columnfractions .15 .70
7483 @item @var{X} @tab Shall be @code{INTEGER(*)}, @code{REAL(*)}, or
7485 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
7486 expression indicating the kind parameter of
7490 @item @emph{Return value}:
7491 These functions return a @code{REAL(*)} variable or array under
7492 the following rules:
7496 @code{REAL(X)} is converted to a default real type if @var{X} is an
7497 integer or real variable.
7499 @code{REAL(X)} is converted to a real type with the kind type parameter
7500 of @var{X} if @var{X} is a complex variable.
7502 @code{REAL(X, KIND)} is converted to a real type with kind type
7503 parameter @var{KIND} if @var{X} is a complex, integer, or real
7507 @item @emph{Example}:
7510 complex :: x = (1.0, 2.0)
7511 print *, real(x), real(x,8), realpart(x)
7512 end program test_real
7515 @item @emph{See also}:
7516 @ref{DBLE}, @ref{DFLOAT}, @ref{FLOAT}
7523 @section @code{RENAME} --- Rename a file
7524 @cindex @code{RENAME} intrinsic
7525 @cindex file system operations
7528 @item @emph{Description}:
7529 Renames a file from file @var{PATH1} to @var{PATH2}. A null
7530 character (@code{CHAR(0)}) can be used to mark the end of the names in
7531 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
7532 names are ignored. If the @var{STATUS} argument is supplied, it
7533 contains 0 on success or a nonzero error code upon return; see
7536 This intrinsic is provided in both subroutine and function forms;
7537 however, only one form can be used in any given program unit.
7539 @item @emph{Standard}:
7543 Subroutine, non-elemental function
7545 @item @emph{Syntax}:
7546 @multitable @columnfractions .80
7547 @item @code{CALL RENAME(PATH1, PATH2 [, STATUS])}
7548 @item @code{STATUS = RENAME(PATH1, PATH2)}
7551 @item @emph{Arguments}:
7552 @multitable @columnfractions .15 .70
7553 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
7554 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
7555 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
7558 @item @emph{See also}:
7566 @section @code{REPEAT} --- Repeated string concatenation
7567 @cindex @code{REPEAT} intrinsic
7568 @cindex string manipulation
7570 Intrinsic implemented, documentation pending.
7573 @item @emph{Description}:
7574 @item @emph{Standard}:
7578 Transformational function
7580 @item @emph{Syntax}:
7581 @item @emph{Arguments}:
7582 @item @emph{Return value}:
7583 @item @emph{Example}:
7584 @item @emph{See also}:
7591 @section @code{RESHAPE} --- Function to reshape an array
7592 @cindex @code{RESHAPE} intrinsic
7593 @cindex array manipulation
7595 Intrinsic implemented, documentation pending.
7598 @item @emph{Description}:
7599 @item @emph{Standard}:
7603 Transformational function
7605 @item @emph{Syntax}:
7606 @item @emph{Arguments}:
7607 @item @emph{Return value}:
7608 @item @emph{Example}:
7609 @item @emph{See also}:
7616 @section @code{RRSPACING} --- Reciprocal of the relative spacing
7617 @cindex @code{RRSPACING} intrinsic
7620 @item @emph{Description}:
7621 @code{RRSPACING(X)} returns the reciprocal of the relative spacing of
7622 model numbers near @var{X}.
7624 @item @emph{Standard}:
7630 @item @emph{Syntax}:
7631 @code{RESULT = RRSPACING(X)}
7633 @item @emph{Arguments}:
7634 @multitable @columnfractions .15 .70
7635 @item @var{X} @tab Shall be of type @code{REAL}.
7638 @item @emph{Return value}:
7639 The return value is of the same type and kind as @var{X}.
7640 The value returned is equal to
7641 @code{ABS(FRACTION(X)) * FLOAT(RADIX(X))**DIGITS(X)}.
7648 @section @code{RSHIFT} --- Right shift bits
7649 @cindex @code{RSHIFT} intrinsic
7650 @cindex bit operations
7653 @item @emph{Description}:
7654 @code{RSHIFT} returns a value corresponding to @var{I} with all of the
7655 bits shifted right by @var{SHIFT} places. If the absolute value of
7656 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
7657 Bits shifted out from the left end are lost; zeros are shifted in from
7660 This function has been superseded by the @code{ISHFT} intrinsic, which
7661 is standard in Fortran 95 and later.
7663 @item @emph{Standard}:
7669 @item @emph{Syntax}:
7670 @code{RESULT = RSHIFT(I, SHIFT)}
7672 @item @emph{Arguments}:
7673 @multitable @columnfractions .15 .70
7674 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
7675 @item @var{SHIFT} @tab The type shall be @code{INTEGER(*)}.
7678 @item @emph{Return value}:
7679 The return value is of type @code{INTEGER(*)} and of the same kind as
7682 @item @emph{See also}:
7683 @ref{ISHFT}, @ref{ISHFTC}, @ref{LSHIFT}
7690 @section @code{SCALE} --- Scale a real value
7691 @cindex @code{SCALE} intrinsic
7694 @item @emph{Description}:
7695 @code{SCALE(X,I)} returns @code{X * RADIX(X)**I}.
7697 @item @emph{Standard}:
7703 @item @emph{Syntax}:
7704 @code{RESULT = SCALE(X, I)}
7706 @item @emph{Arguments}:
7707 @multitable @columnfractions .15 .70
7708 @item @var{X} @tab The type of the argument shall be a @code{REAL}.
7709 @item @var{I} @tab The type of the argument shall be a @code{INTEGER}.
7712 @item @emph{Return value}:
7713 The return value is of the same type and kind as @var{X}.
7714 Its value is @code{X * RADIX(X)**I}.
7716 @item @emph{Example}:
7719 real :: x = 178.1387e-4
7721 print *, scale(x,i), x*radix(x)**i
7722 end program test_scale
7729 @section @code{SCAN} --- Scan a string for the presence of a set of characters
7730 @cindex @code{SCAN} intrinsic
7731 @cindex string manipulation
7733 Intrinsic implemented, documentation pending.
7736 @item @emph{Description}:
7737 @item @emph{Standard}:
7743 @item @emph{Syntax}:
7744 @item @emph{Arguments}:
7745 @item @emph{Return value}:
7746 @item @emph{Example}:
7747 @item @emph{See also}:
7754 @section @code{SECNDS} --- Time function
7755 @cindex @code{SECNDS} intrinsic
7756 @cindex time, current
7757 @cindex current time
7760 @item @emph{Description}:
7761 @code{SECNDS(X)} gets the time in seconds from the real-time system clock.
7762 @var{X} is a reference time, also in seconds. If this is zero, the time in
7763 seconds from midnight is returned. This function is non-standard and its
7766 @item @emph{Standard}:
7772 @item @emph{Syntax}:
7773 @code{RESULT = SECNDS (X)}
7775 @item @emph{Arguments}:
7776 @multitable @columnfractions .15 .70
7777 @item Name @tab Type
7778 @item @var{T} @tab REAL(4)
7779 @item @var{X} @tab REAL(4)
7782 @item @emph{Return value}:
7785 @item @emph{Example}:
7789 print *, secnds (0.0) ! seconds since midnight
7790 t1 = secnds (0.0) ! reference time
7791 do i = 1, 10000000 ! do something
7793 t2 = secnds (t1) ! elapsed time
7794 print *, "Something took ", t2, " seconds."
7795 end program test_secnds
7801 @node SELECTED_INT_KIND
7802 @section @code{SELECTED_INT_KIND} --- Choose integer kind
7803 @cindex @code{SELECTED_INT_KIND} intrinsic
7804 @cindex integer kind
7807 @item @emph{Description}:
7808 @code{SELECTED_INT_KIND(I)} return the kind value of the smallest integer
7809 type that can represent all values ranging from @math{-10^I} (exclusive)
7810 to @math{10^I} (exclusive). If there is no integer kind that accommodates
7811 this range, @code{SELECTED_INT_KIND} returns @math{-1}.
7813 @item @emph{Standard}:
7817 Transformational function
7819 @item @emph{Syntax}:
7820 @code{RESULT = SELECTED_INT_KIND(I)}
7822 @item @emph{Arguments}:
7823 @multitable @columnfractions .15 .70
7824 @item @var{I} @tab Shall be a scalar and of type @code{INTEGER}.
7827 @item @emph{Example}:
7829 program large_integers
7830 integer,parameter :: k5 = selected_int_kind(5)
7831 integer,parameter :: k15 = selected_int_kind(15)
7832 integer(kind=k5) :: i5
7833 integer(kind=k15) :: i15
7835 print *, huge(i5), huge(i15)
7837 ! The following inequalities are always true
7838 print *, huge(i5) >= 10_k5**5-1
7839 print *, huge(i15) >= 10_k15**15-1
7840 end program large_integers
7846 @node SELECTED_REAL_KIND
7847 @section @code{SELECTED_REAL_KIND} --- Choose real kind
7848 @cindex @code{SELECTED_REAL_KIND} intrinsic
7852 @item @emph{Description}:
7853 @code{SELECTED_REAL_KIND(P,R)} return the kind value of a real data type
7854 with decimal precision greater of at least @code{P} digits and exponent
7855 range greater at least @code{R}.
7857 @item @emph{Standard}:
7861 Transformational function
7863 @item @emph{Syntax}:
7864 @code{RESULT = SELECTED_REAL_KIND(P, R)}
7866 @item @emph{Arguments}:
7867 @multitable @columnfractions .15 .70
7868 @item @var{P} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
7869 @item @var{R} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
7871 At least one argument shall be present.
7873 @item @emph{Return value}:
7875 @code{SELECTED_REAL_KIND} returns the value of the kind type parameter of
7876 a real data type with decimal precision of at least @code{P} digits and a
7877 decimal exponent range of at least @code{R}. If more than one real data
7878 type meet the criteria, the kind of the data type with the smallest
7879 decimal precision is returned. If no real data type matches the criteria,
7882 @item -1 if the processor does not support a real data type with a
7883 precision greater than or equal to @code{P}
7884 @item -2 if the processor does not support a real type with an exponent
7885 range greater than or equal to @code{R}
7886 @item -3 if neither is supported.
7889 @item @emph{Example}:
7892 integer,parameter :: p6 = selected_real_kind(6)
7893 integer,parameter :: p10r100 = selected_real_kind(10,100)
7894 integer,parameter :: r400 = selected_real_kind(r=400)
7896 real(kind=p10r100) :: y
7897 real(kind=r400) :: z
7899 print *, precision(x), range(x)
7900 print *, precision(y), range(y)
7901 print *, precision(z), range(z)
7902 end program real_kinds
7909 @section @code{SET_EXPONENT} --- Set the exponent of the model
7910 @cindex @code{SET_EXPONENT} intrinsic
7911 @cindex exponent part of a real number
7914 @item @emph{Description}:
7915 @code{SET_EXPONENT(X, I)} returns the real number whose fractional part
7916 is that that of @var{X} and whose exponent part is @var{I}.
7918 @item @emph{Standard}:
7924 @item @emph{Syntax}:
7925 @code{RESULT = SET_EXPONENT(X, I)}
7927 @item @emph{Arguments}:
7928 @multitable @columnfractions .15 .70
7929 @item @var{X} @tab Shall be of type @code{REAL}.
7930 @item @var{I} @tab Shall be of type @code{INTEGER}.
7933 @item @emph{Return value}:
7934 The return value is of the same type and kind as @var{X}.
7935 The real number whose fractional part
7936 is that that of @var{X} and whose exponent part if @var{I} is returned;
7937 it is @code{FRACTION(X) * RADIX(X)**I}.
7939 @item @emph{Example}:
7942 real :: x = 178.1387e-4
7944 print *, set_exponent(x), fraction(x) * radix(x)**i
7945 end program test_setexp
7953 @section @code{SHAPE} --- Determine the shape of an array
7954 @cindex @code{SHAPE} intrinsic
7955 @cindex array manipulation
7957 Intrinsic implemented, documentation pending.
7960 @item @emph{Description}:
7961 @item @emph{Standard}:
7967 @item @emph{Syntax}:
7968 @item @emph{Arguments}:
7969 @item @emph{Return value}:
7970 @item @emph{Example}:
7971 @item @emph{See also}:
7978 @section @code{SIGN} --- Sign copying function
7979 @cindex @code{SIGN} intrinsic
7980 @cindex @code{ISIGN} intrinsic
7981 @cindex @code{DSIGN} intrinsic
7982 @cindex sign copying
7985 @item @emph{Description}:
7986 @code{SIGN(A,B)} returns the value of @var{A} with the sign of @var{B}.
7988 @item @emph{Standard}:
7994 @item @emph{Syntax}:
7995 @code{RESULT = SIGN(A, B)}
7997 @item @emph{Arguments}:
7998 @multitable @columnfractions .15 .70
7999 @item @var{A} @tab Shall be a scalar of type @code{INTEGER} or @code{REAL}
8000 @item @var{B} @tab Shall be a scalar of the same type and kind as @var{A}
8003 @item @emph{Return value}:
8004 The kind of the return value is that of @var{A} and @var{B}.
8005 If @math{B\ge 0} then the result is @code{ABS(A)}, else
8006 it is @code{-ABS(A)}.
8008 @item @emph{Example}:
8011 print *, sign(-12,1)
8012 print *, sign(-12,0)
8013 print *, sign(-12,-1)
8015 print *, sign(-12.,1.)
8016 print *, sign(-12.,0.)
8017 print *, sign(-12.,-1.)
8018 end program test_sign
8021 @item @emph{Specific names}:
8022 @multitable @columnfractions .20 .20 .20 .25
8023 @item Name @tab Arguments @tab Return type @tab Standard
8024 @item @code{ISIGN(A,P)} @tab @code{INTEGER(4)} @tab @code{INTEGER(4)} @tab f95, gnu
8025 @item @code{DSIGN(A,P)} @tab @code{REAL(8)} @tab @code{REAL(8)} @tab f95, gnu
8032 @section @code{SIGNAL} --- Signal handling subroutine (or function)
8033 @cindex @code{SIGNAL} intrinsic
8034 @cindex signal handling
8037 @item @emph{Description}:
8038 @code{SIGNAL(NUMBER, HANDLER [, STATUS])} causes external subroutine
8039 @var{HANDLER} to be executed with a single integer argument when signal
8040 @var{NUMBER} occurs. If @var{HANDLER} is an integer, it can be used to
8041 turn off handling of signal @var{NUMBER} or revert to its default
8042 action. See @code{signal(2)}.
8044 If @code{SIGNAL} is called as a subroutine and the @var{STATUS} argument
8045 is supplied, it is set to the value returned by @code{signal(2)}.
8047 @item @emph{Standard}:
8051 Subroutine, non-elemental function
8053 @item @emph{Syntax}:
8054 @multitable @columnfractions .80
8055 @item @code{CALL SIGNAL(NUMBER, HANDLER [, STATUS])}
8056 @item @code{STATUS = SIGNAL(NUMBER, HANDLER)}
8059 @item @emph{Arguments}:
8060 @multitable @columnfractions .15 .70
8061 @item @var{NUMBER} @tab Shall be a scalar integer, with @code{INTENT(IN)}
8062 @item @var{HANDLER}@tab Signal handler (@code{INTEGER FUNCTION} or
8063 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar.
8064 @code{INTEGER}. It is @code{INTENT(IN)}.
8065 @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
8066 integer. It has @code{INTENT(OUT)}.
8069 @item @emph{Return value}:
8070 The @code{SIGNAL} function returns the value returned by @code{signal(2)}.
8072 @item @emph{Example}:
8076 external handler_print
8078 call signal (12, handler_print)
8082 end program test_signal
8089 @section @code{SIN} --- Sine function
8090 @cindex @code{SIN} intrinsic
8091 @cindex @code{DSIN} intrinsic
8092 @cindex @code{ZSIN} intrinsic
8093 @cindex @code{CDSIN} intrinsic
8094 @cindex trigonometric functions
8097 @item @emph{Description}:
8098 @code{SIN(X)} computes the sine of @var{X}.
8100 @item @emph{Standard}:
8106 @item @emph{Syntax}:
8107 @code{RESULT = SIN(X)}
8109 @item @emph{Arguments}:
8110 @multitable @columnfractions .15 .70
8111 @item @var{X} @tab The type shall be @code{REAL(*)} or
8115 @item @emph{Return value}:
8116 The return value has same type and kind as @var{X}.
8118 @item @emph{Example}:
8123 end program test_sin
8126 @item @emph{Specific names}:
8127 @multitable @columnfractions .20 .20 .20 .25
8128 @item Name @tab Argument @tab Return type @tab Standard
8129 @item @code{DSIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
8130 @item @code{CSIN(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab f95, gnu
8131 @item @code{ZSIN(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
8132 @item @code{CDSIN(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
8135 @item @emph{See also}:
8142 @section @code{SINH} --- Hyperbolic sine function
8143 @cindex @code{SINH} intrinsic
8144 @cindex @code{DSINH} intrinsic
8145 @cindex hyperbolic sine
8148 @item @emph{Description}:
8149 @code{SINH(X)} computes the hyperbolic sine of @var{X}.
8151 @item @emph{Standard}:
8157 @item @emph{Syntax}:
8158 @code{RESULT = SINH(X)}
8160 @item @emph{Arguments}:
8161 @multitable @columnfractions .15 .70
8162 @item @var{X} @tab The type shall be @code{REAL(*)}.
8165 @item @emph{Return value}:
8166 The return value is of type @code{REAL(*)}.
8168 @item @emph{Example}:
8171 real(8) :: x = - 1.0_8
8173 end program test_sinh
8176 @item @emph{Specific names}:
8177 @multitable @columnfractions .20 .20 .20 .25
8178 @item Name @tab Argument @tab Return type @tab Standard
8179 @item @code{DSINH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
8182 @item @emph{See also}:
8189 @section @code{SIZE} --- Determine the size of an array
8190 @cindex @code{SIZE} intrinsic
8191 @cindex array manipulation
8193 Intrinsic implemented, documentation pending.
8196 @item @emph{Description}:
8197 @item @emph{Standard}:
8203 @item @emph{Syntax}:
8204 @item @emph{Arguments}:
8205 @item @emph{Return value}:
8206 @item @emph{Example}:
8207 @item @emph{See also}:
8213 @section @code{SLEEP} --- Sleep for the specified number of seconds
8214 @cindex @code{SLEEP} intrinsic
8217 @item @emph{Description}:
8218 Calling this subroutine causes the process to pause for @var{SECONDS} seconds.
8220 @item @emph{Standard}:
8226 @item @emph{Syntax}:
8227 @code{CALL SLEEP(SECONDS)}
8229 @item @emph{Arguments}:
8230 @multitable @columnfractions .15 .70
8231 @item @var{SECONDS} @tab The type shall be of default @code{INTEGER}.
8234 @item @emph{Example}:
8245 @section @code{SNGL} --- Convert double precision real to default real
8246 @cindex @code{SNGL} intrinsic
8247 @cindex conversion function (real)
8250 @item @emph{Description}:
8251 @code{SNGL(A)} converts the double precision real @var{A}
8252 to a default real value. This is an archaic form of @code{REAL}
8253 that is specific to one type for @var{A}.
8255 @item @emph{Standard}:
8261 @item @emph{Syntax}:
8262 @code{RESULT = SNGL(A)}
8264 @item @emph{Arguments}:
8265 @multitable @columnfractions .15 .70
8266 @item @var{A} @tab The type shall be a double precision @code{REAL}.
8269 @item @emph{Return value}:
8270 The return value is of type default @code{REAL}.
8272 @item @emph{See also}:
8279 @section @code{SPACING} --- Smallest distance between two numbers of a given type
8280 @cindex @code{SPACING} intrinsic
8281 @cindex undocumented intrinsic
8283 Intrinsic implemented, documentation pending.
8286 @item @emph{Description}:
8287 @item @emph{Standard}:
8293 @item @emph{Syntax}:
8294 @item @emph{Arguments}:
8295 @item @emph{Return value}:
8296 @item @emph{Example}:
8297 @item @emph{See also}:
8304 @section @code{SPREAD} --- Add a dimension to an array
8305 @cindex @code{SPREAD} intrinsic
8306 @cindex array manipulation
8308 Intrinsic implemented, documentation pending.
8311 @item @emph{Description}:
8312 @item @emph{Standard}:
8316 Transformational function
8318 @item @emph{Syntax}:
8319 @item @emph{Arguments}:
8320 @item @emph{Return value}:
8321 @item @emph{Example}:
8322 @item @emph{See also}:
8329 @section @code{SQRT} --- Square-root function
8330 @cindex @code{SQRT} intrinsic
8331 @cindex @code{DSQRT} intrinsic
8332 @cindex @code{CSQRT} intrinsic
8333 @cindex @code{ZSQRT} intrinsic
8334 @cindex @code{CDSQRT} intrinsic
8338 @item @emph{Description}:
8339 @code{SQRT(X)} computes the square root of @var{X}.
8341 @item @emph{Standard}:
8347 @item @emph{Syntax}:
8348 @code{RESULT = SQRT(X)}
8350 @item @emph{Arguments}:
8351 @multitable @columnfractions .15 .70
8352 @item @var{X} @tab The type shall be @code{REAL(*)} or
8356 @item @emph{Return value}:
8357 The return value is of type @code{REAL(*)} or @code{COMPLEX(*)}.
8358 The kind type parameter is the same as @var{X}.
8360 @item @emph{Example}:
8363 real(8) :: x = 2.0_8
8364 complex :: z = (1.0, 2.0)
8367 end program test_sqrt
8370 @item @emph{Specific names}:
8371 @multitable @columnfractions .20 .20 .20 .25
8372 @item Name @tab Argument @tab Return type @tab Standard
8373 @item @code{DSQRT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
8374 @item @code{CSQRT(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab F95 and later
8375 @item @code{ZSQRT(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
8376 @item @code{CDSQRT(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
8383 @section @code{SRAND} --- Reinitialize the random number generator
8384 @cindex @code{SRAND} intrinsic
8385 @cindex random numbers
8388 @item @emph{Description}:
8389 @code{SRAND} reinitializes the pseudo-random number generator
8390 called by @code{RAND} and @code{IRAND}. The new seed used by the
8391 generator is specified by the required argument @var{SEED}.
8393 @item @emph{Standard}:
8397 Non-elemental subroutine
8399 @item @emph{Syntax}:
8400 @code{CALL SRAND(SEED)}
8402 @item @emph{Arguments}:
8403 @multitable @columnfractions .15 .70
8404 @item @var{SEED} @tab Shall be a scalar @code{INTEGER(kind=4)}.
8407 @item @emph{Return value}:
8410 @item @emph{Example}:
8411 See @code{RAND} and @code{IRAND} for examples.
8414 The Fortran 2003 standard specifies the intrinsic @code{RANDOM_SEED} to
8415 initialize the pseudo-random numbers generator and @code{RANDOM_NUMBER}
8416 to generate pseudo-random numbers. Please note that in
8417 GNU Fortran, these two sets of intrinsics (@code{RAND},
8418 @code{IRAND} and @code{SRAND} on the one hand, @code{RANDOM_NUMBER} and
8419 @code{RANDOM_SEED} on the other hand) access two independent
8420 pseudo-random number generators.
8422 @item @emph{See also}:
8423 @ref{RAND}, @ref{RANDOM_SEED}, @ref{RANDOM_NUMBER}
8430 @section @code{STAT} --- Get file status
8431 @cindex @code{STAT} intrinsic
8432 @cindex file system operations
8435 @item @emph{Description}:
8436 This function returns information about a file. No permissions are required on
8437 the file itself, but execute (search) permission is required on all of the
8438 directories in path that lead to the file.
8440 The elements that are obtained and stored in the array @code{BUFF}:
8441 @multitable @columnfractions .15 .70
8442 @item @code{buff(1)} @tab Device ID
8443 @item @code{buff(2)} @tab Inode number
8444 @item @code{buff(3)} @tab File mode
8445 @item @code{buff(4)} @tab Number of links
8446 @item @code{buff(5)} @tab Owner's uid
8447 @item @code{buff(6)} @tab Owner's gid
8448 @item @code{buff(7)} @tab ID of device containing directory entry for file (0 if not available)
8449 @item @code{buff(8)} @tab File size (bytes)
8450 @item @code{buff(9)} @tab Last access time
8451 @item @code{buff(10)} @tab Last modification time
8452 @item @code{buff(11)} @tab Last file status change time
8453 @item @code{buff(12)} @tab Preferred I/O block size (-1 if not available)
8454 @item @code{buff(13)} @tab Number of blocks allocated (-1 if not available)
8457 Not all these elements are relevant on all systems.
8458 If an element is not relevant, it is returned as 0.
8461 @item @emph{Standard}:
8465 Non-elemental subroutine
8467 @item @emph{Syntax}:
8468 @code{CALL STAT(FILE,BUFF[,STATUS])}
8470 @item @emph{Arguments}:
8471 @multitable @columnfractions .15 .70
8472 @item @var{FILE} @tab The type shall be @code{CHARACTER(*)}, a valid path within the file system.
8473 @item @var{BUFF} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
8474 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0
8475 on success and a system specific error code otherwise.
8478 @item @emph{Example}:
8481 INTEGER, DIMENSION(13) :: buff
8484 CALL STAT("/etc/passwd", buff, status)
8486 IF (status == 0) THEN
8487 WRITE (*, FMT="('Device ID:', T30, I19)") buff(1)
8488 WRITE (*, FMT="('Inode number:', T30, I19)") buff(2)
8489 WRITE (*, FMT="('File mode (octal):', T30, O19)") buff(3)
8490 WRITE (*, FMT="('Number of links:', T30, I19)") buff(4)
8491 WRITE (*, FMT="('Owner''s uid:', T30, I19)") buff(5)
8492 WRITE (*, FMT="('Owner''s gid:', T30, I19)") buff(6)
8493 WRITE (*, FMT="('Device where located:', T30, I19)") buff(7)
8494 WRITE (*, FMT="('File size:', T30, I19)") buff(8)
8495 WRITE (*, FMT="('Last access time:', T30, A19)") CTIME(buff(9))
8496 WRITE (*, FMT="('Last modification time', T30, A19)") CTIME(buff(10))
8497 WRITE (*, FMT="('Last status change time:', T30, A19)") CTIME(buff(11))
8498 WRITE (*, FMT="('Preferred block size:', T30, I19)") buff(12)
8499 WRITE (*, FMT="('No. of blocks allocated:', T30, I19)") buff(13)
8504 @item @emph{See also}:
8505 To stat an open file: @ref{FSTAT}, to stat a link: @ref{LSTAT}
8511 @section @code{SUM} --- Sum of array elements
8512 @cindex @code{SUM} intrinsic
8513 @cindex array manipulation
8515 Intrinsic implemented, documentation pending.
8518 @item @emph{Description}:
8519 @item @emph{Standard}:
8523 Transformational function
8525 @item @emph{Syntax}:
8526 @item @emph{Arguments}:
8527 @item @emph{Return value}:
8528 @item @emph{Example}:
8529 @item @emph{See also}:
8536 @section @code{SYMLNK} --- Create a symbolic link
8537 @cindex @code{SYMLNK} intrinsic
8538 @cindex file system operations
8541 @item @emph{Description}:
8542 Makes a symbolic link from file @var{PATH1} to @var{PATH2}. A null
8543 character (@code{CHAR(0)}) can be used to mark the end of the names in
8544 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
8545 names are ignored. If the @var{STATUS} argument is supplied, it
8546 contains 0 on success or a nonzero error code upon return; see
8547 @code{symlink(2)}. If the system does not supply @code{symlink(2)},
8548 @code{ENOSYS} is returned.
8550 This intrinsic is provided in both subroutine and function forms;
8551 however, only one form can be used in any given program unit.
8553 @item @emph{Standard}:
8557 Subroutine, non-elemental function
8559 @item @emph{Syntax}:
8560 @multitable @columnfractions .80
8561 @item @code{CALL SYMLNK(PATH1, PATH2 [, STATUS])}
8562 @item @code{STATUS = SYMLNK(PATH1, PATH2)}
8565 @item @emph{Arguments}:
8566 @multitable @columnfractions .15 .70
8567 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
8568 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
8569 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
8572 @item @emph{See also}:
8573 @ref{LINK}, @ref{UNLINK}
8580 @section @code{SYSTEM} --- Execute a shell command
8581 @cindex @code{SYSTEM} intrinsic
8584 @item @emph{Description}:
8585 Passes the command @var{COMMAND} to a shell (see @code{system(3)}). If
8586 argument @var{STATUS} is present, it contains the value returned by
8587 @code{system(3)}, which is presumably 0 if the shell command succeeded.
8588 Note that which shell is used to invoke the command is system-dependent
8589 and environment-dependent.
8591 This intrinsic is provided in both subroutine and function forms;
8592 however, only one form can be used in any given program unit.
8594 @item @emph{Standard}:
8598 Subroutine, non-elemental function
8600 @item @emph{Syntax}:
8601 @multitable @columnfractions .80
8602 @item @code{CALL SYSTEM(COMMAND [, STATUS])}
8603 @item @code{STATUS = SYSTEM(COMMAND)}
8606 @item @emph{Arguments}:
8607 @multitable @columnfractions .15 .70
8608 @item @var{COMMAND} @tab Shall be of default @code{CHARACTER} type.
8609 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
8612 @item @emph{See also}:
8618 @section @code{SYSTEM_CLOCK} --- Time function
8619 @cindex @code{SYSTEM_CLOCK} intrinsic
8620 @cindex time, current
8621 @cindex current time
8623 Intrinsic implemented, documentation pending.
8626 @item @emph{Description}:
8627 @item @emph{Standard}:
8633 @item @emph{Syntax}:
8634 @item @emph{Arguments}:
8635 @item @emph{Return value}:
8636 @item @emph{Example}:
8637 @item @emph{See also}:
8643 @section @code{TAN} --- Tangent function
8644 @cindex @code{TAN} intrinsic
8645 @cindex @code{DTAN} intrinsic
8646 @cindex trigonometric functions
8649 @item @emph{Description}:
8650 @code{TAN(X)} computes the tangent of @var{X}.
8652 @item @emph{Standard}:
8658 @item @emph{Syntax}:
8659 @code{RESULT = TAN(X)}
8661 @item @emph{Arguments}:
8662 @multitable @columnfractions .15 .70
8663 @item @var{X} @tab The type shall be @code{REAL(*)}.
8666 @item @emph{Return value}:
8667 The return value is of type @code{REAL(*)}. The kind type parameter is
8668 the same as @var{X}.
8670 @item @emph{Example}:
8673 real(8) :: x = 0.165_8
8675 end program test_tan
8678 @item @emph{Specific names}:
8679 @multitable @columnfractions .20 .20 .20 .25
8680 @item Name @tab Argument @tab Return type @tab Standard
8681 @item @code{DTAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
8684 @item @emph{See also}:
8691 @section @code{TANH} --- Hyperbolic tangent function
8692 @cindex @code{TANH} intrinsic
8693 @cindex @code{DTANH} intrinsic
8694 @cindex hyperbolic tangent
8697 @item @emph{Description}:
8698 @code{TANH(X)} computes the hyperbolic tangent of @var{X}.
8700 @item @emph{Standard}:
8706 @item @emph{Syntax}:
8709 @item @emph{Arguments}:
8710 @multitable @columnfractions .15 .70
8711 @item @var{X} @tab The type shall be @code{REAL(*)}.
8714 @item @emph{Return value}:
8715 The return value is of type @code{REAL(*)} and lies in the range
8716 @math{ - 1 \leq tanh(x) \leq 1 }.
8718 @item @emph{Example}:
8721 real(8) :: x = 2.1_8
8723 end program test_tanh
8726 @item @emph{Specific names}:
8727 @multitable @columnfractions .20 .20 .20 .25
8728 @item Name @tab Argument @tab Return type @tab Standard
8729 @item @code{DTANH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
8732 @item @emph{See also}:
8739 @section @code{TIME} --- Time function
8740 @cindex @code{TIME} intrinsic
8741 @cindex time, current
8742 @cindex current time
8745 @item @emph{Description}:
8746 Returns the current time encoded as an integer (in the manner of the
8747 UNIX function @code{time(3)}). This value is suitable for passing to
8748 @code{CTIME()}, @code{GMTIME()}, and @code{LTIME()}.
8750 This intrinsic is not fully portable, such as to systems with 32-bit
8751 @code{INTEGER} types but supporting times wider than 32 bits. Therefore,
8752 the values returned by this intrinsic might be, or become, negative, or
8753 numerically less than previous values, during a single run of the
8756 See @ref{TIME8}, for information on a similar intrinsic that might be
8757 portable to more GNU Fortran implementations, though to fewer Fortran
8760 @item @emph{Standard}:
8764 Non-elemental function
8766 @item @emph{Syntax}:
8767 @code{RESULT = TIME()}
8769 @item @emph{Return value}:
8770 The return value is a scalar of type @code{INTEGER(4)}.
8772 @item @emph{See also}:
8773 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{TIME8}
8780 @section @code{TIME8} --- Time function (64-bit)
8781 @cindex @code{TIME8} intrinsic
8782 @cindex time, current
8783 @cindex current time
8786 @item @emph{Description}:
8787 Returns the current time encoded as an integer (in the manner of the
8788 UNIX function @code{time(3)}). This value is suitable for passing to
8789 @code{CTIME()}, @code{GMTIME()}, and @code{LTIME()}.
8791 @emph{Warning:} this intrinsic does not increase the range of the timing
8792 values over that returned by @code{time(3)}. On a system with a 32-bit
8793 @code{time(3)}, @code{TIME8()} will return a 32-bit value, even though
8794 it is converted to a 64-bit @code{INTEGER(8)} value. That means
8795 overflows of the 32-bit value can still occur. Therefore, the values
8796 returned by this intrinsic might be or become negative or numerically
8797 less than previous values during a single run of the compiled program.
8799 @item @emph{Standard}:
8803 Non-elemental function
8805 @item @emph{Syntax}:
8806 @code{RESULT = TIME8()}
8808 @item @emph{Return value}:
8809 The return value is a scalar of type @code{INTEGER(8)}.
8811 @item @emph{See also}:
8812 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{TIME}
8819 @section @code{TINY} --- Smallest positive number of a real kind
8820 @cindex @code{TINY} intrinsic
8824 @item @emph{Description}:
8825 @code{TINY(X)} returns the smallest positive (non zero) number
8826 in the model of the type of @code{X}.
8828 @item @emph{Standard}:
8834 @item @emph{Syntax}:
8835 @code{RESULT = TINY(X)}
8837 @item @emph{Arguments}:
8838 @multitable @columnfractions .15 .70
8839 @item @var{X} @tab Shall be of type @code{REAL}.
8842 @item @emph{Return value}:
8843 The return value is of the same type and kind as @var{X}
8845 @item @emph{Example}:
8846 See @code{HUGE} for an example.
8852 @section @code{TRANSFER} --- Transfer bit patterns
8853 @cindex @code{TRANSFER} intrinsic
8854 @cindex bit operations
8856 Intrinsic implemented, documentation pending.
8859 @item @emph{Description}:
8860 @item @emph{Standard}:
8864 Transformational function
8866 @item @emph{Syntax}:
8867 @item @emph{Arguments}:
8868 @item @emph{Return value}:
8869 @item @emph{Example}:
8870 @item @emph{See also}:
8876 @section @code{TRANSPOSE} --- Transpose an array of rank two
8877 @cindex @code{TRANSPOSE} intrinsic
8878 @cindex matrix manipulation
8880 Intrinsic implemented, documentation pending.
8883 @item @emph{Description}:
8884 @item @emph{Standard}:
8888 Transformational function
8890 @item @emph{Syntax}:
8891 @item @emph{Arguments}:
8892 @item @emph{Return value}:
8893 @item @emph{Example}:
8894 @item @emph{See also}:
8900 @section @code{TRIM} --- Function to remove trailing blank characters of a string
8901 @cindex @code{TRIM} intrinsic
8902 @cindex string manipulation
8904 Intrinsic implemented, documentation pending.
8907 @item @emph{Description}:
8908 @item @emph{Standard}:
8912 Transformational function
8914 @item @emph{Syntax}:
8915 @item @emph{Arguments}:
8916 @item @emph{Return value}:
8917 @item @emph{Example}:
8918 @item @emph{See also}:
8924 @section @code{TTYNAM} --- Get the name of a terminal device.
8925 @cindex @code{TTYNAM} intrinsic
8928 @item @emph{Description}:
8929 Get the name of a terminal device. For more information,
8930 see @code{ttyname(3)}.
8932 This intrinsic is provided in both subroutine and function forms;
8933 however, only one form can be used in any given program unit.
8935 @item @emph{Standard}:
8939 Subroutine, non-elemental function
8941 @item @emph{Syntax}:
8942 @multitable @columnfractions .80
8943 @item @code{CALL TTYNAM(UNIT, NAME)}
8944 @item @code{NAME = TTYNAM(UNIT)}
8947 @item @emph{Arguments}:
8948 @multitable @columnfractions .15 .70
8949 @item @var{UNIT} @tab Shall be a scalar @code{INTEGER(*)}.
8950 @item @var{NAME} @tab Shall be of type @code{CHARACTER(*)}.
8953 @item @emph{Example}:
8958 IF (isatty(unit=unit)) write(*,*) ttynam(unit)
8963 @item @emph{See also}:
8970 @section @code{UBOUND} --- Upper dimension bounds of an array
8971 @cindex @code{UBOUND} intrinsic
8974 @item @emph{Description}:
8975 Returns the upper bounds of an array, or a single upper bound
8976 along the @var{DIM} dimension.
8977 @item @emph{Standard}:
8983 @item @emph{Syntax}:
8984 @code{RESULT = UBOUND(ARRAY [, DIM])}
8986 @item @emph{Arguments}:
8987 @multitable @columnfractions .15 .70
8988 @item @var{ARRAY} @tab Shall be an array, of any type.
8989 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER(*)}.
8992 @item @emph{Return value}:
8993 If @var{DIM} is absent, the result is an array of the upper bounds of
8994 @var{ARRAY}. If @var{DIM} is present, the result is a scalar
8995 corresponding to the upper bound of the array along that dimension. If
8996 @var{ARRAY} is an expression rather than a whole array or array
8997 structure component, or if it has a zero extent along the relevant
8998 dimension, the upper bound is taken to be the number of elements along
8999 the relevant dimension.
9001 @item @emph{See also}:
9008 @section @code{UMASK} --- Set the file creation mask
9009 @cindex @code{UMASK} intrinsic
9010 @cindex file system operations
9013 @item @emph{Description}:
9014 Sets the file creation mask to @var{MASK} and returns the old value in
9015 argument @var{OLD} if it is supplied. See @code{umask(2)}.
9017 @item @emph{Standard}:
9023 @item @emph{Syntax}:
9024 @code{CALL UMASK(MASK [, OLD])}
9026 @item @emph{Arguments}:
9027 @multitable @columnfractions .15 .70
9028 @item @var{MASK} @tab Shall be a scalar of type @code{INTEGER(*)}.
9029 @item @var{MASK} @tab (Optional) Shall be a scalar of type
9038 @section @code{UNLINK} --- Remove a file from the file system
9039 @cindex @code{UNLINK} intrinsic
9040 @cindex file system operations
9043 @item @emph{Description}:
9044 Unlinks the file @var{PATH}. A null character (@code{CHAR(0)}) can be
9045 used to mark the end of the name in @var{PATH}; otherwise, trailing
9046 blanks in the file name are ignored. If the @var{STATUS} argument is
9047 supplied, it contains 0 on success or a nonzero error code upon return;
9048 see @code{unlink(2)}.
9050 This intrinsic is provided in both subroutine and function forms;
9051 however, only one form can be used in any given program unit.
9053 @item @emph{Standard}:
9057 Subroutine, non-elemental function
9059 @item @emph{Syntax}:
9060 @multitable @columnfractions .80
9061 @item @code{CALL UNLINK(PATH [, STATUS])}
9062 @item @code{STATUS = UNLINK(PATH)}
9065 @item @emph{Arguments}:
9066 @multitable @columnfractions .15 .70
9067 @item @var{PATH} @tab Shall be of default @code{CHARACTER} type.
9068 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
9071 @item @emph{See also}:
9072 @ref{LINK}, @ref{SYMLNK}
9078 @section @code{UNPACK} --- Unpack an array of rank one into an array
9079 @cindex @code{UNPACK} intrinsic
9080 @cindex array manipulation
9082 Intrinsic implemented, documentation pending.
9085 @item @emph{Description}:
9086 @item @emph{Standard}:
9090 Transformational function
9092 @item @emph{Syntax}:
9093 @item @emph{Arguments}:
9094 @item @emph{Return value}:
9095 @item @emph{Example}:
9097 @item @emph{See also}:
9104 @section @code{VERIFY} --- Scan a string for the absence of a set of characters
9105 @cindex @code{VERIFY} intrinsic
9106 @cindex string manipulation
9108 Intrinsic implemented, documentation pending.
9111 @item @emph{Description}:
9112 @item @emph{Standard}:
9118 @item @emph{Syntax}:
9119 @item @emph{Arguments}:
9120 @item @emph{Return value}:
9121 @item @emph{Example}:
9122 @item @emph{Specific names}:
9123 @item @emph{See also}:
9129 @section @code{XOR} --- Bitwise logical exclusive OR
9130 @cindex @code{XOR} intrinsic
9131 @cindex bit operations
9134 @item @emph{Description}:
9135 Bitwise logical exclusive or.
9137 This intrinsic routine is provided for backwards compatibility with
9138 GNU Fortran 77. For integer arguments, programmers should consider
9139 the use of the @ref{IEOR} intrinsic defined by the Fortran standard.
9141 @item @emph{Standard}:
9145 Non-elemental function
9147 @item @emph{Syntax}:
9148 @code{RESULT = XOR(X, Y)}
9150 @item @emph{Arguments}:
9151 @multitable @columnfractions .15 .70
9152 @item @var{X} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
9153 @item @var{Y} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
9156 @item @emph{Return value}:
9157 The return type is either @code{INTEGER(*)} or @code{LOGICAL}
9158 after cross-promotion of the arguments.
9160 @item @emph{Example}:
9163 LOGICAL :: T = .TRUE., F = .FALSE.
9165 DATA a / Z,'F' /, b / Z'3' /
9167 WRITE (*,*) XOR(T, T), XOR(T, F), XOR(F, T), XOR(F, F)
9168 WRITE (*,*) XOR(a, b)
9172 @item @emph{See also}:
9173 F95 elemental function: @ref{IEOR}