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 This portion of the document is incomplete and undergoing massive expansion
42 and editing. All contributions and corrections are strongly encouraged.
44 Implemented intrinsics are fully functional and available to the user to apply.
45 Some intrinsics have documentation yet to be completed as indicated by 'documentation pending'.
47 @comment Missing intrinsics (double check with #19292)
52 * Introduction: Introduction to Intrinsics
53 * @code{ABORT}: ABORT, Abort the program
54 * @code{ABS}: ABS, Absolute value
55 * @code{ACCESS}: ACCESS, Checks file access modes
56 * @code{ACHAR}: ACHAR, Character in @acronym{ASCII} collating sequence
57 * @code{ACOS}: ACOS, Arccosine function
58 * @code{ACOSH}: ACOSH, Hyperbolic arccosine function
59 * @code{ADJUSTL}: ADJUSTL, Left adjust a string
60 * @code{ADJUSTR}: ADJUSTR, Right adjust a string
61 * @code{AIMAG}: AIMAG, Imaginary part of complex number
62 * @code{AINT}: AINT, Truncate to a whole number
63 * @code{ALARM}: ALARM, Set an alarm clock
64 * @code{ALL}: ALL, Determine if all values are true
65 * @code{ALLOCATED}: ALLOCATED, Status of allocatable entity
66 * @code{AND}: AND, Bitwise logical AND
67 * @code{ANINT}: ANINT, Nearest whole number
68 * @code{ANY}: ANY, Determine if any values are true
69 * @code{ASIN}: ASIN, Arcsine function
70 * @code{ASINH}: ASINH, Hyperbolic arcsine function
71 * @code{ASSOCIATED}: ASSOCIATED, Status of a pointer or pointer/target pair
72 * @code{ATAN}: ATAN, Arctangent function
73 * @code{ATAN2}: ATAN2, Arctangent function
74 * @code{ATANH}: ATANH, Hyperbolic arctangent function
75 * @code{BESJ0}: BESJ0, Bessel function of the first kind of order 0
76 * @code{BESJ1}: BESJ1, Bessel function of the first kind of order 1
77 * @code{BESJN}: BESJN, Bessel function of the first kind
78 * @code{BESY0}: BESY0, Bessel function of the second kind of order 0
79 * @code{BESY1}: BESY1, Bessel function of the second kind of order 1
80 * @code{BESYN}: BESYN, Bessel function of the second kind
81 * @code{BIT_SIZE}: BIT_SIZE, Bit size inquiry function
82 * @code{BTEST}: BTEST, Bit test function
83 * @code{CEILING}: CEILING, Integer ceiling function
84 * @code{CHAR}: CHAR, Integer-to-character conversion function
85 * @code{CHDIR}: CHDIR, Change working directory
86 * @code{CHMOD}: CHMOD, Change access permissions of files
87 * @code{CMPLX}: CMPLX, Complex conversion function
88 * @code{COMMAND_ARGUMENT_COUNT}: COMMAND_ARGUMENT_COUNT, Get number of command line arguments
89 * @code{CONJG}: CONJG, Complex conjugate function
90 * @code{COS}: COS, Cosine function
91 * @code{COSH}: COSH, Hyperbolic cosine function
92 * @code{COUNT}: COUNT, Count occurrences of TRUE in an array
93 * @code{CPU_TIME}: CPU_TIME, CPU time subroutine
94 * @code{CSHIFT}: CSHIFT, Circular array shift function
95 * @code{CTIME}: CTIME, Subroutine (or function) to convert a time into a string
96 * @code{DATE_AND_TIME}: DATE_AND_TIME, Date and time subroutine
97 * @code{DBLE}: DBLE, Double precision conversion function
98 * @code{DCMPLX}: DCMPLX, Double complex conversion function
99 * @code{DFLOAT}: DFLOAT, Double precision conversion function
100 * @code{DIGITS}: DIGITS, Significant digits function
101 * @code{DIM}: DIM, Dim function
102 * @code{DOT_PRODUCT}: DOT_PRODUCT, Dot product function
103 * @code{DPROD}: DPROD, Double product function
104 * @code{DREAL}: DREAL, Double real part function
105 * @code{DTIME}: DTIME, Execution time subroutine (or function)
106 * @code{EOSHIFT}: EOSHIFT, End-off shift function
107 * @code{EPSILON}: EPSILON, Epsilon function
108 * @code{ERF}: ERF, Error function
109 * @code{ERFC}: ERFC, Complementary error function
110 * @code{ETIME}: ETIME, Execution time subroutine (or function)
111 * @code{EXIT}: EXIT, Exit the program with status.
112 * @code{EXP}: EXP, Exponential function
113 * @code{EXPONENT}: EXPONENT, Exponent function
114 * @code{FDATE}: FDATE, Subroutine (or function) to get the current time as a string
115 * @code{FGET}: FGET, Read a single character in stream mode from stdin
116 * @code{FGETC}: FGETC, Read a single character in stream mode
117 * @code{FLOAT}: FLOAT, Convert integer to default real
118 * @code{FLOOR}: FLOOR, Integer floor function
119 * @code{FLUSH}: FLUSH, Flush I/O unit(s)
120 * @code{FNUM}: FNUM, File number function
121 * @code{FPUT}: FPUT, Write a single character in stream mode to stdout
122 * @code{FPUTC}: FPUTC, Write a single character in stream mode
123 * @code{FRACTION}: FRACTION, Fractional part of the model representation
124 * @code{FREE}: FREE, Memory de-allocation subroutine
125 * @code{FSEEK}: FSEEK, Low level file positioning subroutine
126 * @code{FSTAT}: FSTAT, Get file status
127 * @code{FTELL}: FTELL, Current stream position
128 * @code{GERROR}: GERROR, Get last system error message
129 * @code{GETARG}: GETARG, Get command line arguments
130 * @code{GET_COMMAND}: GET_COMMAND, Get the entire command line
131 * @code{GET_COMMAND_ARGUMENT}: GET_COMMAND_ARGUMENT, Get command line arguments
132 * @code{GETCWD}: GETCWD, Get current working directory
133 * @code{GETENV}: GETENV, Get an environmental variable
134 * @code{GET_ENVIRONMENT_VARIABLE}: GET_ENVIRONMENT_VARIABLE, Get an environmental variable
135 * @code{GETGID}: GETGID, Group ID function
136 * @code{GETLOG}: GETLOG, Get login name
137 * @code{GETPID}: GETPID, Process ID function
138 * @code{GETUID}: GETUID, User ID function
139 * @code{GMTIME}: GMTIME, Convert time to GMT info
140 * @code{HOSTNM}: HOSTNM, Get system host name
141 * @code{HUGE}: HUGE, Largest number of a kind
142 * @code{IACHAR}: IACHAR, Code in @acronym{ASCII} collating sequence
143 * @code{IAND}: IAND, Bitwise logical and
144 * @code{IARGC}: IARGC, Get the number of command line arguments
145 * @code{IBCLR}: IBCLR, Clear bit
146 * @code{IBITS}: IBITS, Bit extraction
147 * @code{IBSET}: IBSET, Set bit
148 * @code{ICHAR}: ICHAR, Character-to-integer conversion function
149 * @code{IDATE}: IDATE, Current local time (day/month/year)
150 * @code{IEOR}: IEOR, Bitwise logical exclusive or
151 * @code{IERRNO}: IERRNO, Function to get the last system error number
152 * @code{INDEX}: INDEX, Position of a substring within a string
153 * @code{INT}: INT, Convert to integer type
154 * @code{IOR}: IOR, Bitwise logical or
155 * @code{IRAND}: IRAND, Integer pseudo-random number
156 * @code{ISATTY}: ISATTY, Whether a unit is a terminal device
157 * @code{ISHFT}: ISHFT, Shift bits
158 * @code{ISHFTC}: ISHFTC, Shift bits circularly
159 * @code{ITIME}: ITIME, Current local time (hour/minutes/seconds)
160 * @code{KILL}: KILL, Send a signal to a process
161 * @code{KIND}: KIND, Kind of an entity
162 * @code{LBOUND}: LBOUND, Lower dimension bounds of an array
163 * @code{LEN}: LEN, Length of a character entity
164 * @code{LEN_TRIM}: LEN_TRIM, Length of a character entity without trailing blank characters
165 * @code{LGE}: LGE, Lexical greater than or equal
166 * @code{LGT}: LGT, Lexical greater than
167 * @code{LINK}: LINK, Create a hard link
168 * @code{LLE}: LLE, Lexical less than or equal
169 * @code{LLT}: LLT, Lexical less than
170 * @code{LNBLNK}: LNBLNK, Index of the last non-blank character in a string
171 * @code{LOC}: LOC, Returns the address of a variable
172 * @code{LOG}: LOG, Logarithm function
173 * @code{LOG10}: LOG10, Base 10 logarithm function
174 * @code{LOGICAL}: LOGICAL, Convert to logical type
175 * @code{LSHIFT}: LSHIFT, Left shift bits
176 * @code{LSTAT}: LSTAT, Get file status
177 * @code{LTIME}: LTIME, Convert time to local time info
178 * @code{MALLOC}: MALLOC, Dynamic memory allocation function
179 * @code{MATMUL}: MATMUL, matrix multiplication
180 * @code{MAX}: MAX, Maximum value of an argument list
181 * @code{MAXEXPONENT}: MAXEXPONENT, Maximum exponent of a real kind
182 * @code{MAXLOC}: MAXLOC, Location of the maximum value within an array
183 * @code{MAXVAL}: MAXVAL, Maximum value of an array
184 * @code{MERGE}: MERGE, Merge arrays
185 * @code{MIN}: MIN, Minimum value of an argument list
186 * @code{MINEXPONENT}: MINEXPONENT, Minimum exponent of a real kind
187 * @code{MINLOC}: MINLOC, Location of the minimum value within an array
188 * @code{MINVAL}: MINVAL, Minimum value of an array
189 * @code{MOD}: MOD, Remainder function
190 * @code{MODULO}: MODULO, Modulo function
191 * @code{MOVE_ALLOC}: MOVE_ALLOC, Move allocation from one object to another
192 * @code{MVBITS}: MVBITS, Move bits from one integer to another
193 * @code{NEAREST}: NEAREST, Nearest representable number
194 * @code{NEW_LINE}: NEW_LINE, New line character
195 * @code{NINT}: NINT, Nearest whole number
196 * @code{NOT}: NOT, Logical negation
197 * @code{NULL}: NULL, Function that returns an disassociated pointer
198 * @code{OR}: OR, Bitwise logical OR
199 * @code{PACK}: PACK, Pack an array into an array of rank one
200 * @code{PERROR}: PERROR, Print system error message
201 * @code{PRECISION}: PRECISION, Decimal precision of a real kind
202 * @code{PRESENT}: PRESENT, Determine whether an optional argument is specified
203 * @code{PRODUCT}: PRODUCT, Product of array elements
204 * @code{RADIX}: RADIX, Base of a data model
205 * @code{RANDOM_NUMBER}: RANDOM_NUMBER, Pseudo-random number
206 * @code{RANDOM_SEED}: RANDOM_SEED, Initialize a pseudo-random number sequence
207 * @code{RAND}: RAND, Real pseudo-random number
208 * @code{RANGE}: RANGE, Decimal exponent range of a real kind
209 * @code{RAN}: RAN, Real pseudo-random number
210 * @code{REAL}: REAL, Convert to real type
211 * @code{RENAME}: RENAME, Rename a file
212 * @code{REPEAT}: REPEAT, Repeated string concatenation
213 * @code{RESHAPE}: RESHAPE, Function to reshape an array
214 * @code{RRSPACING}: RRSPACING, Reciprocal of the relative spacing
215 * @code{RSHIFT}: RSHIFT, Right shift bits
216 * @code{SCALE}: SCALE, Scale a real value
217 * @code{SCAN}: SCAN, Scan a string for the presence of a set of characters
218 * @code{SECNDS}: SECNDS, Time function
219 @comment * @code{SECOND}: SECOND, (?)
220 @comment * @code{SECONDS}: SECONDS, (?)
221 * @code{SELECTED_INT_KIND}: SELECTED_INT_KIND, Choose integer kind
222 * @code{SELECTED_REAL_KIND}: SELECTED_REAL_KIND, Choose real kind
223 * @code{SET_EXPONENT}: SET_EXPONENT, Set the exponent of the model
224 * @code{SHAPE}: SHAPE, Determine the shape of an array
225 * @code{SIGN}: SIGN, Sign copying function
226 * @code{SIGNAL}: SIGNAL, Signal handling subroutine (or function)
227 * @code{SIN}: SIN, Sine function
228 * @code{SINH}: SINH, Hyperbolic sine function
229 * @code{SIZE}: SIZE, Function to determine the size of an array
230 * @code{SLEEP}: SLEEP, Sleep for the specified number of seconds
231 * @code{SNGL}: SNGL, Convert double precision real to default real
232 * @code{SPACING}: SPACING, Smallest distance between two numbers of a given type
233 * @code{SPREAD}: SPREAD, Add a dimension to an array
234 * @code{SQRT}: SQRT, Square-root function
235 * @code{SRAND}: SRAND, Reinitialize the random number generator
236 * @code{STAT}: STAT, Get file status
237 * @code{SUM}: SUM, Sum of array elements
238 * @code{SYMLNK}: SYMLNK, Create a symbolic link
239 * @code{SYSTEM}: SYSTEM, Execute a shell command
240 * @code{SYSTEM_CLOCK}: SYSTEM_CLOCK, Time function
241 * @code{TAN}: TAN, Tangent function
242 * @code{TANH}: TANH, Hyperbolic tangent function
243 * @code{TIME}: TIME, Time function
244 * @code{TIME8}: TIME8, Time function (64-bit)
245 * @code{TINY}: TINY, Smallest positive number of a real kind
246 * @code{TRANSFER}: TRANSFER, Transfer bit patterns
247 * @code{TRANSPOSE}: TRANSPOSE, Transpose an array of rank two
248 * @code{TRIM}: TRIM, Function to remove trailing blank characters of a string
249 * @code{TTYNAM}: TTYNAM, Get the name of a terminal device.
250 * @code{UBOUND}: UBOUND, Upper dimension bounds of an array
251 * @code{UMASK}: UMASK, Set the file creation mask
252 * @code{UNLINK}: UNLINK, Remove a file from the file system
253 * @code{UNPACK}: UNPACK, Unpack an array of rank one into an array
254 * @code{VERIFY}: VERIFY, Scan a string for the absence of a set of characters
255 * @code{XOR}: XOR, Bitwise logical exclusive or
258 @node Introduction to Intrinsics
259 @section Introduction to intrinsic procedures
261 The intrinsic procedures provided by GNU Fortran include all of the
262 intrinsic procedures required by the Fortran 95 standard, a set of
263 intrinsic procedures for backwards compatibility with G77, and a small
264 selection of intrinsic procedures from the Fortran 2003 standard. Any
265 conflict between a description here and a description in either the
266 Fortran 95 standard or the Fortran 2003 standard is unintentional, and
267 the standard(s) should be considered authoritative.
269 The enumeration of the @code{KIND} type parameter is processor defined in
270 the Fortran 95 standard. GNU Fortran defines the default integer type and
271 default real type by @code{INTEGER(KIND=4)} and @code{REAL(KIND=4)},
272 respectively. The standard mandates that both data types shall have
273 another kind, which have more precision. On typical target architectures
274 supported by @command{gfortran}, this kind type parameter is @code{KIND=8}.
275 Hence, @code{REAL(KIND=8)} and @code{DOUBLE PRECISION} are equivalent.
276 In the description of generic intrinsic procedures, the kind type parameter
277 will be specified by @code{KIND=*}, and in the description of specific
278 names for an intrinsic procedure the kind type parameter will be explicitly
279 given (e.g., @code{REAL(KIND=4)} or @code{REAL(KIND=8)}). Finally, for
280 brevity the optional @code{KIND=} syntax will be omitted.
282 Many of the intrinsic procedures take one or more optional arguments.
283 This document follows the convention used in the Fortran 95 standard,
284 and denotes such arguments by square brackets.
286 GNU Fortran offers the @option{-std=f95} and @option{-std=gnu} options,
287 which can be used to restrict the set of intrinsic procedures to a
288 given standard. By default, @command{gfortran} sets the @option{-std=gnu}
289 option, and so all intrinsic procedures described here are accepted. There
290 is one caveat. For a select group of intrinsic procedures, @command{g77}
291 implemented both a function and a subroutine. Both classes
292 have been implemented in @command{gfortran} for backwards compatibility
293 with @command{g77}. It is noted here that these functions and subroutines
294 cannot be intermixed in a given subprogram. In the descriptions that follow,
295 the applicable standard for each intrinsic procedure is noted.
300 @section @code{ABORT} --- Abort the program
301 @cindex @code{ABORT} intrinsic
305 @item @emph{Description}:
306 @code{ABORT} causes immediate termination of the program. On operating
307 systems that support a core dump, @code{ABORT} will produce a core dump,
308 which is suitable for debugging purposes.
310 @item @emph{Standard}:
314 Non-elemental subroutine
319 @item @emph{Return value}:
322 @item @emph{Example}:
325 integer :: i = 1, j = 2
326 if (i /= j) call abort
327 end program test_abort
330 @item @emph{See also}:
331 @ref{EXIT}, @ref{KILL}
337 @section @code{ABS} --- Absolute value
338 @cindex @code{ABS} intrinsic
339 @cindex @code{CABS} intrinsic
340 @cindex @code{DABS} intrinsic
341 @cindex @code{IABS} intrinsic
342 @cindex @code{ZABS} intrinsic
343 @cindex @code{CDABS} intrinsic
344 @cindex absolute value
347 @item @emph{Description}:
348 @code{ABS(X)} computes the absolute value of @code{X}.
350 @item @emph{Standard}:
351 F77 and later, has overloads that are GNU extensions
357 @code{RESULT = ABS(X)}
359 @item @emph{Arguments}:
360 @multitable @columnfractions .15 .70
361 @item @var{X} @tab The type of the argument shall be an @code{INTEGER(*)},
362 @code{REAL(*)}, or @code{COMPLEX(*)}.
365 @item @emph{Return value}:
366 The return value is of the same type and
367 kind as the argument except the return value is @code{REAL(*)} for a
368 @code{COMPLEX(*)} argument.
370 @item @emph{Example}:
375 complex :: z = (-1.e0,0.e0)
382 @item @emph{Specific names}:
383 @multitable @columnfractions .20 .20 .20 .25
384 @item Name @tab Argument @tab Return type @tab Standard
385 @item @code{CABS(Z)} @tab @code{COMPLEX(4) Z} @tab @code{REAL(4)} @tab F77 and later
386 @item @code{DABS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
387 @item @code{IABS(I)} @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)} @tab F77 and later
388 @item @code{ZABS(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
389 @item @code{CDABS(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
395 @section @code{ACCESS} --- Checks file access modes
396 @cindex @code{ACCESS}
397 @cindex file system operations
400 @item @emph{Description}:
401 @code{ACCESS(NAME, MODE)} checks whether the file @var{NAME}
402 exists, is readable, writable or executable. Except for the
403 executable check, @code{ACCESS} can be replaced by
404 Fortran 95's @code{INQUIRE}.
406 @item @emph{Standard}:
413 @code{RESULT = ACCESS(NAME, MODE)}
415 @item @emph{Arguments}:
416 @multitable @columnfractions .15 .70
417 @item @var{NAME} @tab Scalar @code{CHARACTER} with the file name.
418 Tailing blank are ignored unless the character @code{achar(0)} is
419 present, then all characters up to and excluding @code{achar(0)} are
421 @item @var{MODE} @tab Scalar @code{CHARACTER} with the file access mode,
422 may be any concatenation of @code{"r"} (readable), @code{"w"} (writable)
423 and @code{"x"} (executable), or @code{" "} to check for existence.
426 @item @emph{Return value}:
427 Returns a scalar @code{INTEGER}, which is @code{0} if the file is
428 accessible in the given mode; otherwise or if an invalid argument
429 has been given for @code{MODE} the value @code{1} is returned.
431 @item @emph{Example}:
435 character(len=*), parameter :: file = 'test.dat'
436 character(len=*), parameter :: file2 = 'test.dat '//achar(0)
437 if(access(file,' ') == 0) print *, trim(file),' is exists'
438 if(access(file,'r') == 0) print *, trim(file),' is readable'
439 if(access(file,'w') == 0) print *, trim(file),' is writable'
440 if(access(file,'x') == 0) print *, trim(file),' is executable'
441 if(access(file2,'rwx') == 0) &
442 print *, trim(file2),' is readable, writable and executable'
443 end program access_test
445 @item @emph{Specific names}:
446 @item @emph{See also}:
452 @section @code{ACHAR} --- Character in @acronym{ASCII} collating sequence
453 @cindex @code{ACHAR} intrinsic
454 @cindex @acronym{ASCII} collating sequence
457 @item @emph{Description}:
458 @code{ACHAR(I)} returns the character located at position @code{I}
459 in the @acronym{ASCII} collating sequence.
461 @item @emph{Standard}:
468 @code{RESULT = ACHAR(I)}
470 @item @emph{Arguments}:
471 @multitable @columnfractions .15 .70
472 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
475 @item @emph{Return value}:
476 The return value is of type @code{CHARACTER} with a length of one. The
477 kind type parameter is the same as @code{KIND('A')}.
479 @item @emph{Example}:
484 end program test_achar
487 @item @emph{See also}:
488 @ref{CHAR}, @ref{IACHAR}, @ref{ICHAR}
495 @section @code{ACOS} --- Arccosine function
496 @cindex @code{ACOS} intrinsic
497 @cindex @code{DACOS} intrinsic
498 @cindex trigonometric functions (inverse)
501 @item @emph{Description}:
502 @code{ACOS(X)} computes the arccosine of @var{X} (inverse of @code{COS(X)}).
504 @item @emph{Standard}:
511 @code{RESULT = ACOS(X)}
513 @item @emph{Arguments}:
514 @multitable @columnfractions .15 .70
515 @item @var{X} @tab The type shall be @code{REAL(*)} with a magnitude that is
519 @item @emph{Return value}:
520 The return value is of type @code{REAL(*)} and it lies in the
521 range @math{ 0 \leq \acos(x) \leq \pi}. The kind type parameter
522 is the same as @var{X}.
524 @item @emph{Example}:
527 real(8) :: x = 0.866_8
529 end program test_acos
532 @item @emph{Specific names}:
533 @multitable @columnfractions .20 .20 .20 .25
534 @item Name @tab Argument @tab Return type @tab Standard
535 @item @code{DACOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
538 @item @emph{See also}:
539 Inverse function: @ref{COS}
545 @section @code{ACOSH} --- Hyperbolic arccosine function
546 @cindex @code{ACOSH} intrinsic
547 @cindex hyperbolic arccosine
548 @cindex hyperbolic cosine (inverse)
551 @item @emph{Description}:
552 @code{ACOSH(X)} computes the area hyperbolic cosine of @var{X} (inverse of @code{COSH(X)}).
554 @item @emph{Standard}:
561 @code{RESULT = ACOSH(X)}
563 @item @emph{Arguments}:
564 @multitable @columnfractions .15 .70
565 @item @var{X} @tab The type shall be @code{REAL(*)} with a magnitude that is
566 greater or equal to one.
569 @item @emph{Return value}:
570 The return value is of type @code{REAL(*)} and it lies in the
571 range @math{0 \leq \acosh (x) \leq \infty}.
573 @item @emph{Example}:
576 REAL(8), DIMENSION(3) :: x = (/ 1.0, 2.0, 3.0 /)
581 @item @emph{See also}:
582 Inverse function: @ref{COSH}
588 @section @code{ADJUSTL} --- Left adjust a string
589 @cindex @code{ADJUSTL} intrinsic
590 @cindex adjust string
593 @item @emph{Description}:
594 @code{ADJUSTL(STR)} will left adjust a string by removing leading spaces.
595 Spaces are inserted at the end of the string as needed.
597 @item @emph{Standard}:
604 @code{RESULT = ADJUSTL(STR)}
606 @item @emph{Arguments}:
607 @multitable @columnfractions .15 .70
608 @item @var{STR} @tab The type shall be @code{CHARACTER}.
611 @item @emph{Return value}:
612 The return value is of type @code{CHARACTER} where leading spaces
613 are removed and the same number of spaces are inserted on the end
616 @item @emph{Example}:
619 character(len=20) :: str = ' gfortran'
622 end program test_adjustl
629 @section @code{ADJUSTR} --- Right adjust a string
630 @cindex @code{ADJUSTR} intrinsic
631 @cindex adjust string
634 @item @emph{Description}:
635 @code{ADJUSTR(STR)} will right adjust a string by removing trailing spaces.
636 Spaces are inserted at the start of the string as needed.
638 @item @emph{Standard}:
645 @code{RESULT = ADJUSTR(STR)}
647 @item @emph{Arguments}:
648 @multitable @columnfractions .15 .70
649 @item @var{STR} @tab The type shall be @code{CHARACTER}.
652 @item @emph{Return value}:
653 The return value is of type @code{CHARACTER} where trailing spaces
654 are removed and the same number of spaces are inserted at the start
657 @item @emph{Example}:
660 character(len=20) :: str = 'gfortran'
663 end program test_adjustr
670 @section @code{AIMAG} --- Imaginary part of complex number
671 @cindex @code{AIMAG} intrinsic
672 @cindex @code{DIMAG} intrinsic
673 @cindex @code{IMAG} intrinsic
674 @cindex @code{IMAGPART} intrinsic
675 @cindex imaginary part of a complex number
678 @item @emph{Description}:
679 @code{AIMAG(Z)} yields the imaginary part of complex argument @code{Z}.
680 The @code{IMAG(Z)} and @code{IMAGPART(Z)} intrinsic functions are provided
681 for compatibility with @command{g77}, and their use in new code is
682 strongly discouraged.
684 @item @emph{Standard}:
685 F77 and later, has overloads that are GNU extensions
691 @code{RESULT = AIMAG(Z)}
693 @item @emph{Arguments}:
694 @multitable @columnfractions .15 .70
695 @item @var{Z} @tab The type of the argument shall be @code{COMPLEX(*)}.
698 @item @emph{Return value}:
699 The return value is of type real with the
700 kind type parameter of the argument.
702 @item @emph{Example}:
707 z4 = cmplx(1.e0_4, 0.e0_4)
708 z8 = cmplx(0.e0_8, 1.e0_8)
709 print *, aimag(z4), dimag(z8)
710 end program test_aimag
713 @item @emph{Specific names}:
714 @multitable @columnfractions .20 .20 .20 .25
715 @item Name @tab Argument @tab Return type @tab Standard
716 @item @code{DIMAG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{REAL(8)} @tab GNU extension
717 @item @code{IMAG(Z)} @tab @code{COMPLEX(*) Z} @tab @code{REAL(*)} @tab GNU extension
718 @item @code{IMAGPART(Z)} @tab @code{COMPLEX(*) Z} @tab @code{REAL(*)} @tab GNU extension
725 @section @code{AINT} --- Truncate to a whole number
726 @cindex @code{AINT} intrinsic
727 @cindex @code{DINT} intrinsic
731 @item @emph{Description}:
732 @code{AINT(X [, KIND])} truncates its argument to a whole number.
734 @item @emph{Standard}:
741 @code{RESULT = AINT(X [, KIND])}
743 @item @emph{Arguments}:
744 @multitable @columnfractions .15 .70
745 @item @var{X} @tab The type of the argument shall be @code{REAL(*)}.
746 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
747 expression indicating the kind parameter of
751 @item @emph{Return value}:
752 The return value is of type real with the kind type parameter of the
753 argument if the optional @var{KIND} is absent; otherwise, the kind
754 type parameter will be given by @var{KIND}. If the magnitude of
755 @var{X} is less than one, then @code{AINT(X)} returns zero. If the
756 magnitude is equal to or greater than one, then it returns the largest
757 whole number that does not exceed its magnitude. The sign is the same
758 as the sign of @var{X}.
760 @item @emph{Example}:
767 print *, aint(x4), dint(x8)
769 end program test_aint
772 @item @emph{Specific names}:
773 @multitable @columnfractions .20 .20 .20 .25
774 @item Name @tab Argument @tab Return type @tab Standard
775 @item @code{DINT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
782 @section @code{ALARM} --- Execute a routine after a given delay
783 @cindex @code{ALARM} intrinsic
786 @item @emph{Description}:
787 @code{ALARM(SECONDS, HANDLER [, STATUS])} causes external subroutine @var{HANDLER}
788 to be executed after a delay of @var{SECONDS} by using @code{alarm(1)} to
789 set up a signal and @code{signal(2)} to catch it. If @var{STATUS} is
790 supplied, it will be returned with the number of seconds remaining until
791 any previously scheduled alarm was due to be delivered, or zero if there
792 was no previously scheduled alarm.
794 @item @emph{Standard}:
801 @code{CALL ALARM(SECONDS, HANDLER [, STATUS])}
803 @item @emph{Arguments}:
804 @multitable @columnfractions .15 .70
805 @item @var{SECONDS} @tab The type of the argument shall be a scalar
806 @code{INTEGER}. It is @code{INTENT(IN)}.
807 @item @var{HANDLER} @tab Signal handler (@code{INTEGER FUNCTION} or
808 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar.
809 @code{INTEGER}. It is @code{INTENT(IN)}.
810 @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
811 @code{INTEGER} variable. It is @code{INTENT(OUT)}.
814 @item @emph{Example}:
817 external handler_print
819 call alarm (3, handler_print, i)
822 end program test_alarm
824 This will cause the external routine @var{handler_print} to be called
831 @section @code{ALL} --- All values in @var{MASK} along @var{DIM} are true
832 @cindex @code{ALL} intrinsic
836 @item @emph{Description}:
837 @code{ALL(MASK [, DIM])} determines if all the values are true in @var{MASK}
838 in the array along dimension @var{DIM}.
840 @item @emph{Standard}:
844 transformational function
847 @code{RESULT = ALL(MASK [, DIM])}
849 @item @emph{Arguments}:
850 @multitable @columnfractions .15 .70
851 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL(*)} and
852 it shall not be scalar.
853 @item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer
854 with a value that lies between one and the rank of @var{MASK}.
857 @item @emph{Return value}:
858 @code{ALL(MASK)} returns a scalar value of type @code{LOGICAL(*)} where
859 the kind type parameter is the same as the kind type parameter of
860 @var{MASK}. If @var{DIM} is present, then @code{ALL(MASK, DIM)} returns
861 an array with the rank of @var{MASK} minus 1. The shape is determined from
862 the shape of @var{MASK} where the @var{DIM} dimension is elided.
866 @code{ALL(MASK)} is true if all elements of @var{MASK} are true.
867 It also is true if @var{MASK} has zero size; otherwise, it is false.
869 If the rank of @var{MASK} is one, then @code{ALL(MASK,DIM)} is equivalent
870 to @code{ALL(MASK)}. If the rank is greater than one, then @code{ALL(MASK,DIM)}
871 is determined by applying @code{ALL} to the array sections.
874 @item @emph{Example}:
878 l = all((/.true., .true., .true./))
883 integer a(2,3), b(2,3)
887 print *, all(a .eq. b, 1)
888 print *, all(a .eq. b, 2)
889 end subroutine section
897 @section @code{ALLOCATED} --- Status of an allocatable entity
898 @cindex @code{ALLOCATED} intrinsic
899 @cindex allocation status
902 @item @emph{Description}:
903 @code{ALLOCATED(X)} checks the status of whether @var{X} is allocated.
905 @item @emph{Standard}:
912 @code{RESULT = ALLOCATED(X)}
914 @item @emph{Arguments}:
915 @multitable @columnfractions .15 .70
916 @item @var{X} @tab The argument shall be an @code{ALLOCATABLE} array.
919 @item @emph{Return value}:
920 The return value is a scalar @code{LOGICAL} with the default logical
921 kind type parameter. If @var{X} is allocated, @code{ALLOCATED(X)}
922 is @code{.TRUE.}; otherwise, it returns the @code{.TRUE.}
924 @item @emph{Example}:
926 program test_allocated
928 real(4), allocatable :: x(:)
929 if (allocated(x) .eqv. .false.) allocate(x(i))
930 end program test_allocated
936 @section @code{AND} --- Bitwise logical AND
937 @cindex @code{AND} intrinsic
938 @cindex bit operations
941 @item @emph{Description}:
942 Bitwise logical @code{AND}.
944 This intrinsic routine is provided for backwards compatibility with
945 GNU Fortran 77. For integer arguments, programmers should consider
946 the use of the @ref{IAND} intrinsic defined by the Fortran standard.
948 @item @emph{Standard}:
952 Non-elemental function
955 @code{RESULT = AND(I, J)}
957 @item @emph{Arguments}:
958 @multitable @columnfractions .15 .70
959 @item @var{I} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
960 @item @var{J} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
963 @item @emph{Return value}:
964 The return type is either @code{INTEGER(*)} or @code{LOGICAL} after
965 cross-promotion of the arguments.
967 @item @emph{Example}:
970 LOGICAL :: T = .TRUE., F = ..FALSE.
972 DATA a / Z'F' /, b / Z'3' /
974 WRITE (*,*) AND(T, T), AND(T, F), AND(F, T), AND(F, F)
975 WRITE (*,*) AND(a, b)
979 @item @emph{See also}:
980 F95 elemental function: @ref{IAND}
986 @section @code{ANINT} --- Nearest whole number
987 @cindex @code{ANINT} intrinsic
988 @cindex @code{DNINT} intrinsic
992 @item @emph{Description}:
993 @code{ANINT(X [, KIND])} rounds its argument to the nearest whole number.
995 @item @emph{Standard}:
1001 @item @emph{Syntax}:
1002 @code{RESULT = ANINT(X [, KIND])}
1004 @item @emph{Arguments}:
1005 @multitable @columnfractions .15 .70
1006 @item @var{X} @tab The type of the argument shall be @code{REAL(*)}.
1007 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
1008 expression indicating the kind parameter of
1012 @item @emph{Return value}:
1013 The return value is of type real with the kind type parameter of the
1014 argument if the optional @var{KIND} is absent; otherwise, the kind
1015 type parameter will be given by @var{KIND}. If @var{X} is greater than
1016 zero, then @code{ANINT(X)} returns @code{AINT(X+0.5)}. If @var{X} is
1017 less than or equal to zero, then it returns @code{AINT(X-0.5)}.
1019 @item @emph{Example}:
1026 print *, anint(x4), dnint(x8)
1028 end program test_anint
1031 @item @emph{Specific names}:
1032 @multitable @columnfractions .20 .20 .20 .25
1033 @item Name @tab Argument @tab Return type @tab Standard
1034 @item @code{DNINT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1041 @section @code{ANY} --- Any value in @var{MASK} along @var{DIM} is true
1042 @cindex @code{ANY} intrinsic
1046 @item @emph{Description}:
1047 @code{ANY(MASK [, DIM])} determines if any of the values in the logical array
1048 @var{MASK} along dimension @var{DIM} are @code{.TRUE.}.
1050 @item @emph{Standard}:
1054 transformational function
1056 @item @emph{Syntax}:
1057 @code{RESULT = ANY(MASK [, DIM])}
1059 @item @emph{Arguments}:
1060 @multitable @columnfractions .15 .70
1061 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL(*)} and
1062 it shall not be scalar.
1063 @item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer
1064 with a value that lies between one and the rank of @var{MASK}.
1067 @item @emph{Return value}:
1068 @code{ANY(MASK)} returns a scalar value of type @code{LOGICAL(*)} where
1069 the kind type parameter is the same as the kind type parameter of
1070 @var{MASK}. If @var{DIM} is present, then @code{ANY(MASK, DIM)} returns
1071 an array with the rank of @var{MASK} minus 1. The shape is determined from
1072 the shape of @var{MASK} where the @var{DIM} dimension is elided.
1076 @code{ANY(MASK)} is true if any element of @var{MASK} is true;
1077 otherwise, it is false. It also is false if @var{MASK} has zero size.
1079 If the rank of @var{MASK} is one, then @code{ANY(MASK,DIM)} is equivalent
1080 to @code{ANY(MASK)}. If the rank is greater than one, then @code{ANY(MASK,DIM)}
1081 is determined by applying @code{ANY} to the array sections.
1084 @item @emph{Example}:
1088 l = any((/.true., .true., .true./))
1093 integer a(2,3), b(2,3)
1097 print *, any(a .eq. b, 1)
1098 print *, any(a .eq. b, 2)
1099 end subroutine section
1100 end program test_any
1107 @section @code{ASIN} --- Arcsine function
1108 @cindex @code{ASIN} intrinsic
1109 @cindex @code{DASIN} intrinsic
1110 @cindex trigonometric functions (inverse)
1113 @item @emph{Description}:
1114 @code{ASIN(X)} computes the arcsine of its @var{X} (inverse of @code{SIN(X)}).
1116 @item @emph{Standard}:
1122 @item @emph{Syntax}:
1123 @code{RESULT = ASIN(X)}
1125 @item @emph{Arguments}:
1126 @multitable @columnfractions .15 .70
1127 @item @var{X} @tab The type shall be @code{REAL(*)}, and a magnitude that is
1131 @item @emph{Return value}:
1132 The return value is of type @code{REAL(*)} and it lies in the
1133 range @math{-\pi / 2 \leq \asin (x) \leq \pi / 2}. The kind type
1134 parameter is the same as @var{X}.
1136 @item @emph{Example}:
1139 real(8) :: x = 0.866_8
1141 end program test_asin
1144 @item @emph{Specific names}:
1145 @multitable @columnfractions .20 .20 .20 .25
1146 @item Name @tab Argument @tab Return type @tab Standard
1147 @item @code{DASIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1150 @item @emph{See also}:
1151 Inverse function: @ref{SIN}
1157 @section @code{ASINH} --- Hyperbolic arcsine function
1158 @cindex @code{ASINH} intrinsic
1159 @cindex hyperbolic arcsine
1160 @cindex hyperbolic sine (inverse)
1163 @item @emph{Description}:
1164 @code{ASINH(X)} computes the area hyperbolic sine of @var{X} (inverse of @code{SINH(X)}).
1166 @item @emph{Standard}:
1172 @item @emph{Syntax}:
1173 @code{RESULT = ASINH(X)}
1175 @item @emph{Arguments}:
1176 @multitable @columnfractions .15 .70
1177 @item @var{X} @tab The type shall be @code{REAL(*)}, with @var{X} a real number.
1180 @item @emph{Return value}:
1181 The return value is of type @code{REAL(*)} and it lies in the
1182 range @math{-\infty \leq \asinh (x) \leq \infty}.
1184 @item @emph{Example}:
1187 REAL(8), DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1188 WRITE (*,*) ASINH(x)
1192 @item @emph{See also}:
1193 Inverse function: @ref{SINH}
1199 @section @code{ASSOCIATED} --- Status of a pointer or pointer/target pair
1200 @cindex @code{ASSOCIATED} intrinsic
1201 @cindex pointer status
1204 @item @emph{Description}:
1205 @code{ASSOCIATED(PTR [, TGT])} determines the status of the pointer @var{PTR}
1206 or if @var{PTR} is associated with the target @var{TGT}.
1208 @item @emph{Standard}:
1214 @item @emph{Syntax}:
1215 @code{RESULT = ASSOCIATED(PTR [, TGT])}
1217 @item @emph{Arguments}:
1218 @multitable @columnfractions .15 .70
1219 @item @var{PTR} @tab @var{PTR} shall have the @code{POINTER} attribute and
1220 it can be of any type.
1221 @item @var{TGT} @tab (Optional) @var{TGT} shall be a @code{POINTER} or
1222 a @code{TARGET}. It must have the same type, kind type parameter, and
1223 array rank as @var{PTR}.
1225 The status of neither @var{PTR} nor @var{TGT} can be undefined.
1227 @item @emph{Return value}:
1228 @code{ASSOCIATED(PTR)} returns a scalar value of type @code{LOGICAL(4)}.
1229 There are several cases:
1231 @item (A) If the optional @var{TGT} is not present, then @code{ASSOCIATED(PTR)}
1232 is true if @var{PTR} is associated with a target; otherwise, it returns false.
1233 @item (B) If @var{TGT} is present and a scalar target, the result is true if
1235 is not a 0 sized storage sequence and the target associated with @var{PTR}
1236 occupies the same storage units. If @var{PTR} is disassociated, then the
1238 @item (C) If @var{TGT} is present and an array target, the result is true if
1239 @var{TGT} and @var{PTR} have the same shape, are not 0 sized arrays, are
1240 arrays whose elements are not 0 sized storage sequences, and @var{TGT} and
1241 @var{PTR} occupy the same storage units in array element order.
1242 As in case(B), the result is false, if @var{PTR} is disassociated.
1243 @item (D) If @var{TGT} is present and an scalar pointer, the result is true if
1244 target associated with @var{PTR} and the target associated with @var{TGT}
1245 are not 0 sized storage sequences and occupy the same storage units.
1246 The result is false, if either @var{TGT} or @var{PTR} is disassociated.
1247 @item (E) If @var{TGT} is present and an array pointer, the result is true if
1248 target associated with @var{PTR} and the target associated with @var{TGT}
1249 have the same shape, are not 0 sized arrays, are arrays whose elements are
1250 not 0 sized storage sequences, and @var{TGT} and @var{PTR} occupy the same
1251 storage units in array element order.
1252 The result is false, if either @var{TGT} or @var{PTR} is disassociated.
1255 @item @emph{Example}:
1257 program test_associated
1259 real, target :: tgt(2) = (/1., 2./)
1260 real, pointer :: ptr(:)
1262 if (associated(ptr) .eqv. .false.) call abort
1263 if (associated(ptr,tgt) .eqv. .false.) call abort
1264 end program test_associated
1267 @item @emph{See also}:
1274 @section @code{ATAN} --- Arctangent function
1275 @cindex @code{ATAN} intrinsic
1276 @cindex @code{DATAN} intrinsic
1277 @cindex trigonometric functions (inverse)
1280 @item @emph{Description}:
1281 @code{ATAN(X)} computes the arctangent of @var{X}.
1283 @item @emph{Standard}:
1289 @item @emph{Syntax}:
1290 @code{RESULT = ATAN(X)}
1292 @item @emph{Arguments}:
1293 @multitable @columnfractions .15 .70
1294 @item @var{X} @tab The type shall be @code{REAL(*)}.
1297 @item @emph{Return value}:
1298 The return value is of type @code{REAL(*)} and it lies in the
1299 range @math{ - \pi / 2 \leq \atan (x) \leq \pi / 2}.
1301 @item @emph{Example}:
1304 real(8) :: x = 2.866_8
1306 end program test_atan
1309 @item @emph{Specific names}:
1310 @multitable @columnfractions .20 .20 .20 .25
1311 @item Name @tab Argument @tab Return type @tab Standard
1312 @item @code{DATAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1315 @item @emph{See also}:
1316 Inverse function: @ref{TAN}
1323 @section @code{ATAN2} --- Arctangent function
1324 @cindex @code{ATAN2} intrinsic
1325 @cindex @code{DATAN2} intrinsic
1326 @cindex trigonometric functions (inverse)
1329 @item @emph{Description}:
1330 @code{ATAN2(Y,X)} computes the arctangent of the complex number @math{X + i Y}.
1332 @item @emph{Standard}:
1338 @item @emph{Syntax}:
1339 @code{RESULT = ATAN2(Y,X)}
1341 @item @emph{Arguments}:
1342 @multitable @columnfractions .15 .70
1343 @item @var{Y} @tab The type shall be @code{REAL(*)}.
1344 @item @var{X} @tab The type and kind type parameter shall be the same as @var{Y}.
1345 If @var{Y} is zero, then @var{X} must be nonzero.
1348 @item @emph{Return value}:
1349 The return value has the same type and kind type parameter as @var{Y}.
1350 It is the principal value of the complex number @math{X + i Y}. If
1351 @var{X} is nonzero, then it lies in the range @math{-\pi \le \atan (x) \leq \pi}.
1352 The sign is positive if @var{Y} is positive. If @var{Y} is zero, then
1353 the return value is zero if @var{X} is positive and @math{\pi} if @var{X}
1354 is negative. Finally, if @var{X} is zero, then the magnitude of the result
1357 @item @emph{Example}:
1360 real(4) :: x = 1.e0_4, y = 0.5e0_4
1362 end program test_atan2
1365 @item @emph{Specific names}:
1366 @multitable @columnfractions .20 .20 .20 .25
1367 @item Name @tab Argument @tab Return type @tab Standard
1368 @item @code{DATAN2(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1375 @section @code{ATANH} --- Hyperbolic arctangent function
1376 @cindex @code{ASINH} intrinsic
1377 @cindex hyperbolic arctangent
1378 @cindex hyperbolic tangent (inverse)
1381 @item @emph{Description}:
1382 @code{ATANH(X)} computes the area hyperbolic sine of @var{X} (inverse of @code{TANH(X)}).
1384 @item @emph{Standard}:
1390 @item @emph{Syntax}:
1391 @code{RESULT = ATANH(X)}
1393 @item @emph{Arguments}:
1394 @multitable @columnfractions .15 .70
1395 @item @var{X} @tab The type shall be @code{REAL(*)} with a magnitude
1396 that is less than or equal to one.
1399 @item @emph{Return value}:
1400 The return value is of type @code{REAL(*)} and it lies in the
1401 range @math{-\infty \leq \atanh(x) \leq \infty}.
1403 @item @emph{Example}:
1406 REAL, DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1407 WRITE (*,*) ATANH(x)
1411 @item @emph{See also}:
1412 Inverse function: @ref{TANH}
1419 @section @code{BESJ0} --- Bessel function of the first kind of order 0
1420 @cindex @code{BESJ0} intrinsic
1421 @cindex @code{DBESJ0} intrinsic
1425 @item @emph{Description}:
1426 @code{BESJ0(X)} computes the Bessel function of the first kind of order 0
1429 @item @emph{Standard}:
1435 @item @emph{Syntax}:
1436 @code{RESULT = BESJ0(X)}
1438 @item @emph{Arguments}:
1439 @multitable @columnfractions .15 .70
1440 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1443 @item @emph{Return value}:
1444 The return value is of type @code{REAL(*)} and it lies in the
1445 range @math{ - 0.4027... \leq Bessel (0,x) \leq 1}.
1447 @item @emph{Example}:
1450 real(8) :: x = 0.0_8
1452 end program test_besj0
1455 @item @emph{Specific names}:
1456 @multitable @columnfractions .20 .20 .20 .25
1457 @item Name @tab Argument @tab Return type @tab Standard
1458 @item @code{DBESJ0(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1465 @section @code{BESJ1} --- Bessel function of the first kind of order 1
1466 @cindex @code{BESJ1} intrinsic
1467 @cindex @code{DBESJ1} intrinsic
1471 @item @emph{Description}:
1472 @code{BESJ1(X)} computes the Bessel function of the first kind of order 1
1475 @item @emph{Standard}:
1481 @item @emph{Syntax}:
1482 @code{RESULT = BESJ1(X)}
1484 @item @emph{Arguments}:
1485 @multitable @columnfractions .15 .70
1486 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1489 @item @emph{Return value}:
1490 The return value is of type @code{REAL(*)} and it lies in the
1491 range @math{ - 0.5818... \leq Bessel (0,x) \leq 0.5818 }.
1493 @item @emph{Example}:
1496 real(8) :: x = 1.0_8
1498 end program test_besj1
1501 @item @emph{Specific names}:
1502 @multitable @columnfractions .20 .20 .20 .25
1503 @item Name @tab Argument @tab Return type @tab Standard
1504 @item @code{DBESJ1(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1511 @section @code{BESJN} --- Bessel function of the first kind
1512 @cindex @code{BESJN} intrinsic
1513 @cindex @code{DBESJN} intrinsic
1517 @item @emph{Description}:
1518 @code{BESJN(N, X)} computes the Bessel function of the first kind of order
1521 @item @emph{Standard}:
1527 @item @emph{Syntax}:
1528 @code{RESULT = BESJN(N, X)}
1530 @item @emph{Arguments}:
1531 @multitable @columnfractions .15 .70
1532 @item @var{N} @tab The type shall be @code{INTEGER(*)}, and it shall be scalar.
1533 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1536 @item @emph{Return value}:
1537 The return value is a scalar of type @code{REAL(*)}.
1539 @item @emph{Example}:
1542 real(8) :: x = 1.0_8
1544 end program test_besjn
1547 @item @emph{Specific names}:
1548 @multitable @columnfractions .20 .20 .20 .25
1549 @item Name @tab Argument @tab Return type @tab Standard
1550 @item @code{DBESJN(X)} @tab @code{INTEGER(*) N} @tab @code{REAL(8)} @tab GNU extension
1551 @item @tab @code{REAL(8) X} @tab @tab
1558 @section @code{BESY0} --- Bessel function of the second kind of order 0
1559 @cindex @code{BESY0} intrinsic
1560 @cindex @code{DBESY0} intrinsic
1564 @item @emph{Description}:
1565 @code{BESY0(X)} computes the Bessel function of the second kind of order 0
1568 @item @emph{Standard}:
1574 @item @emph{Syntax}:
1575 @code{RESULT = BESY0(X)}
1577 @item @emph{Arguments}:
1578 @multitable @columnfractions .15 .70
1579 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1582 @item @emph{Return value}:
1583 The return value is a scalar of type @code{REAL(*)}.
1585 @item @emph{Example}:
1588 real(8) :: x = 0.0_8
1590 end program test_besy0
1593 @item @emph{Specific names}:
1594 @multitable @columnfractions .20 .20 .20 .25
1595 @item Name @tab Argument @tab Return type @tab Standard
1596 @item @code{DBESY0(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1603 @section @code{BESY1} --- Bessel function of the second kind of order 1
1604 @cindex @code{BESY1} intrinsic
1605 @cindex @code{DBESY1} intrinsic
1609 @item @emph{Description}:
1610 @code{BESY1(X)} computes the Bessel function of the second kind of order 1
1613 @item @emph{Standard}:
1619 @item @emph{Syntax}:
1620 @code{RESULT = BESY1(X)}
1622 @item @emph{Arguments}:
1623 @multitable @columnfractions .15 .70
1624 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1627 @item @emph{Return value}:
1628 The return value is a scalar of type @code{REAL(*)}.
1630 @item @emph{Example}:
1633 real(8) :: x = 1.0_8
1635 end program test_besy1
1638 @item @emph{Specific names}:
1639 @multitable @columnfractions .20 .20 .20 .25
1640 @item Name @tab Argument @tab Return type @tab Standard
1641 @item @code{DBESY1(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1648 @section @code{BESYN} --- Bessel function of the second kind
1649 @cindex @code{BESYN} intrinsic
1650 @cindex @code{DBESYN} intrinsic
1654 @item @emph{Description}:
1655 @code{BESYN(N, X)} computes the Bessel function of the second kind of order
1658 @item @emph{Standard}:
1664 @item @emph{Syntax}:
1665 @code{RESULT = BESYN(N, X)}
1667 @item @emph{Arguments}:
1668 @multitable @columnfractions .15 .70
1669 @item @var{N} @tab The type shall be @code{INTEGER(*)}, and it shall be scalar.
1670 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1673 @item @emph{Return value}:
1674 The return value is a scalar of type @code{REAL(*)}.
1676 @item @emph{Example}:
1679 real(8) :: x = 1.0_8
1681 end program test_besyn
1684 @item @emph{Specific names}:
1685 @multitable @columnfractions .20 .20 .20 .25
1686 @item Name @tab Argument @tab Return type @tab Standard
1687 @item @code{DBESYN(N,X)} @tab @code{INTEGER(*) N} @tab @code{REAL(8)} @tab GNU extension
1688 @item @tab @code{REAL(8) X} @tab @tab
1695 @section @code{BIT_SIZE} --- Bit size inquiry function
1696 @cindex @code{BIT_SIZE} intrinsic
1697 @cindex bit size of a variable
1698 @cindex size of a variable, in bits
1701 @item @emph{Description}:
1702 @code{BIT_SIZE(I)} returns the number of bits (integer precision plus sign bit)
1703 represented by the type of @var{I}.
1705 @item @emph{Standard}:
1711 @item @emph{Syntax}:
1712 @code{RESULT = BIT_SIZE(I)}
1714 @item @emph{Arguments}:
1715 @multitable @columnfractions .15 .70
1716 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1719 @item @emph{Return value}:
1720 The return value is of type @code{INTEGER(*)}
1722 @item @emph{Example}:
1724 program test_bit_size
1729 end program test_bit_size
1736 @section @code{BTEST} --- Bit test function
1737 @cindex @code{BTEST} intrinsic
1738 @cindex bit operations
1741 @item @emph{Description}:
1742 @code{BTEST(I,POS)} returns logical @code{.TRUE.} if the bit at @var{POS}
1745 @item @emph{Standard}:
1751 @item @emph{Syntax}:
1752 @code{RESULT = BTEST(I, POS)}
1754 @item @emph{Arguments}:
1755 @multitable @columnfractions .15 .70
1756 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1757 @item @var{POS} @tab The type shall be @code{INTEGER(*)}.
1760 @item @emph{Return value}:
1761 The return value is of type @code{LOGICAL}
1763 @item @emph{Example}:
1766 integer :: i = 32768 + 1024 + 64
1770 bool = btest(i, pos)
1773 end program test_btest
1780 @section @code{CEILING} --- Integer ceiling function
1781 @cindex @code{CEILING} intrinsic
1785 @item @emph{Description}:
1786 @code{CEILING(X)} returns the least integer greater than or equal to @var{X}.
1788 @item @emph{Standard}:
1794 @item @emph{Syntax}:
1795 @code{RESULT = CEILING(X [, KIND])}
1797 @item @emph{Arguments}:
1798 @multitable @columnfractions .15 .70
1799 @item @var{X} @tab The type shall be @code{REAL(*)}.
1800 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
1801 expression indicating the kind parameter of
1805 @item @emph{Return value}:
1806 The return value is of type @code{INTEGER(KIND)}
1808 @item @emph{Example}:
1810 program test_ceiling
1813 print *, ceiling(x) ! returns 64
1814 print *, ceiling(y) ! returns -63
1815 end program test_ceiling
1818 @item @emph{See also}:
1819 @ref{FLOOR}, @ref{NINT}
1826 @section @code{CHAR} --- Character conversion function
1827 @cindex @code{CHAR} intrinsic
1828 @cindex conversion function (character)
1831 @item @emph{Description}:
1832 @code{CHAR(I [, KIND])} returns the character represented by the integer @var{I}.
1834 @item @emph{Standard}:
1840 @item @emph{Syntax}:
1841 @code{RESULT = CHAR(I [, KIND])}
1843 @item @emph{Arguments}:
1844 @multitable @columnfractions .15 .70
1845 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1846 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
1847 expression indicating the kind parameter of
1851 @item @emph{Return value}:
1852 The return value is of type @code{CHARACTER(1)}
1854 @item @emph{Example}:
1860 print *, i, c ! returns 'J'
1861 end program test_char
1864 @item @emph{See also}:
1865 @ref{ACHAR}, @ref{IACHAR}, @ref{ICHAR}
1871 @section @code{CHDIR} --- Change working directory
1872 @cindex @code{CHDIR} intrinsic
1873 @cindex file system operations
1876 @item @emph{Description}:
1877 Change current working directory to a specified @var{PATH}.
1879 @item @emph{Standard}:
1883 Non-elemental subroutine
1885 @item @emph{Syntax}:
1886 @code{CALL CHDIR(PATH [, STATUS])}
1888 @item @emph{Arguments}:
1889 @multitable @columnfractions .15 .70
1890 @item @var{PATH} @tab The type shall be @code{CHARACTER(*)} and shall
1891 specify a valid path within the file system.
1892 @item @var{STATUS} @tab (Optional) status flag. Returns 0 on success,
1893 a system specific and non-zero error code otherwise.
1896 @item @emph{Example}:
1899 CHARACTER(len=255) :: path
1901 WRITE(*,*) TRIM(path)
1904 WRITE(*,*) TRIM(path)
1908 @item @emph{See also}:
1915 @section @code{CHMOD} --- Change access permissions of files
1916 @cindex @code{CHMOD} intrinsic
1917 @cindex file system operations
1920 @item @emph{Description}:
1921 @code{CHMOD} changes the permissions of a file. This function invokes
1922 @code{/bin/chmod} and might therefore not work on all platforms.
1924 This intrinsic is provided in both subroutine and function forms; however,
1925 only one form can be used in any given program unit.
1927 @item @emph{Standard}:
1931 Subroutine, non-elemental function
1933 @item @emph{Syntax}:
1934 @multitable @columnfractions .80
1935 @item @code{CALL CHMOD(NAME, MODE[, STATUS])}
1936 @item @code{STATUS = CHMOD(NAME, MODE)}
1939 @item @emph{Arguments}:
1940 @multitable @columnfractions .15 .70
1941 @item @var{NAME} @tab Scalar @code{CHARACTER} with the file name.
1942 Trailing blanks are ignored unless the character @code{achar(0)} is
1943 present, then all characters up to and excluding @code{achar(0)} are
1944 used as the file name.
1946 @item @var{MODE} @tab Scalar @code{CHARACTER} giving the file permission.
1947 @var{MODE} uses the same syntax as the @var{MODE} argument of
1950 @item @var{STATUS} @tab (optional) scalar @code{INTEGER}, which is
1951 @code{0} on success and non-zero otherwise.
1954 @item @emph{Return value}:
1955 In either syntax, @var{STATUS} is set to @code{0} on success and non-zero
1958 @item @emph{Example}:
1959 @code{CHMOD} as subroutine
1964 call chmod('test.dat','u+x',status)
1965 print *, 'Status: ', status
1966 end program chmod_test
1968 @code{CHMOD} as non-elemental function:
1973 status = chmod('test.dat','u+x')
1974 print *, 'Status: ', status
1975 end program chmod_test
1977 @item @emph{Specific names}:
1978 @item @emph{See also}:
1984 @section @code{CMPLX} --- Complex conversion function
1985 @cindex @code{CMPLX} intrinsic
1986 @cindex complex numbers, conversion to
1989 @item @emph{Description}:
1990 @code{CMPLX(X [, Y [, KIND]])} returns a complex number where @var{X} is converted to
1991 the real component. If @var{Y} is present it is converted to the imaginary
1992 component. If @var{Y} is not present then the imaginary component is set to
1993 0.0. If @var{X} is complex then @var{Y} must not be present.
1995 @item @emph{Standard}:
2001 @item @emph{Syntax}:
2002 @code{RESULT = CMPLX(X [, Y [, KIND]])}
2004 @item @emph{Arguments}:
2005 @multitable @columnfractions .15 .70
2006 @item @var{X} @tab The type may be @code{INTEGER(*)}, @code{REAL(*)},
2007 or @code{COMPLEX(*)}.
2008 @item @var{Y} @tab (Optional; only allowed if @var{X} is not
2009 @code{COMPLEX(*)}.) May be @code{INTEGER(*)}
2011 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
2012 expression indicating the kind parameter of
2016 @item @emph{Return value}:
2017 The return value is of type @code{COMPLEX(*)}
2019 @item @emph{Example}:
2026 print *, z, cmplx(x)
2027 end program test_cmplx
2033 @node COMMAND_ARGUMENT_COUNT
2034 @section @code{COMMAND_ARGUMENT_COUNT} --- Get number of command line arguments
2035 @cindex @code{COMMAND_ARGUMENT_COUNT} intrinsic
2036 @cindex command-line arguments, to program
2039 @item @emph{Description}:
2040 @code{COMMAND_ARGUMENT_COUNT()} returns the number of arguments passed on the
2041 command line when the containing program was invoked.
2043 @item @emph{Standard}:
2049 @item @emph{Syntax}:
2050 @code{RESULT = COMMAND_ARGUMENT_COUNT()}
2052 @item @emph{Arguments}:
2053 @multitable @columnfractions .15 .70
2057 @item @emph{Return value}:
2058 The return value is of type @code{INTEGER(4)}
2060 @item @emph{Example}:
2062 program test_command_argument_count
2064 count = command_argument_count()
2066 end program test_command_argument_count
2069 @item @emph{See also}:
2070 @ref{GET_COMMAND}, @ref{GET_COMMAND_ARGUMENT}
2074 @section @code{CONJG} --- Complex conjugate function
2075 @cindex @code{CONJG} intrinsic
2076 @cindex @code{DCONJG} intrinsic
2077 @cindex complex conjugate
2079 @item @emph{Description}:
2080 @code{CONJG(Z)} returns the conjugate of @var{Z}. If @var{Z} is @code{(x, y)}
2081 then the result is @code{(x, -y)}
2083 @item @emph{Standard}:
2084 F77 and later, has overloads that are GNU extensions
2089 @item @emph{Syntax}:
2092 @item @emph{Arguments}:
2093 @multitable @columnfractions .15 .70
2094 @item @var{Z} @tab The type shall be @code{COMPLEX(*)}.
2097 @item @emph{Return value}:
2098 The return value is of type @code{COMPLEX(*)}.
2100 @item @emph{Example}:
2103 complex :: z = (2.0, 3.0)
2104 complex(8) :: dz = (2.71_8, -3.14_8)
2109 end program test_conjg
2112 @item @emph{Specific names}:
2113 @multitable @columnfractions .20 .20 .20 .25
2114 @item Name @tab Argument @tab Return type @tab Standard
2115 @item @code{DCONJG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
2122 @section @code{COS} --- Cosine function
2123 @cindex @code{COS} intrinsic
2124 @cindex @code{DCOS} intrinsic
2125 @cindex @code{ZCOS} intrinsic
2126 @cindex @code{CDCOS} intrinsic
2127 @cindex trigonometric functions
2130 @item @emph{Description}:
2131 @code{COS(X)} computes the cosine of @var{X}.
2133 @item @emph{Standard}:
2134 F77 and later, has overloads that are GNU extensions
2139 @item @emph{Syntax}:
2140 @code{RESULT = COS(X)}
2142 @item @emph{Arguments}:
2143 @multitable @columnfractions .15 .70
2144 @item @var{X} @tab The type shall be @code{REAL(*)} or
2148 @item @emph{Return value}:
2149 The return value is of type @code{REAL(*)} and it lies in the
2150 range @math{ -1 \leq \cos (x) \leq 1}. The kind type
2151 parameter is the same as @var{X}.
2153 @item @emph{Example}:
2158 end program test_cos
2161 @item @emph{Specific names}:
2162 @multitable @columnfractions .20 .20 .20 .25
2163 @item Name @tab Argument @tab Return type @tab Standard
2164 @item @code{DCOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
2165 @item @code{CCOS(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab F77 and later
2166 @item @code{ZCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
2167 @item @code{CDCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
2170 @item @emph{See also}:
2171 Inverse function: @ref{ACOS}
2178 @section @code{COSH} --- Hyperbolic cosine function
2179 @cindex @code{COSH} intrinsic
2180 @cindex @code{DCOSH} intrinsic
2181 @cindex hyperbolic cosine
2184 @item @emph{Description}:
2185 @code{COSH(X)} computes the hyperbolic cosine of @var{X}.
2187 @item @emph{Standard}:
2193 @item @emph{Syntax}:
2196 @item @emph{Arguments}:
2197 @multitable @columnfractions .15 .70
2198 @item @var{X} @tab The type shall be @code{REAL(*)}.
2201 @item @emph{Return value}:
2202 The return value is of type @code{REAL(*)} and it is positive
2203 (@math{ \cosh (x) \geq 0 }.
2205 @item @emph{Example}:
2208 real(8) :: x = 1.0_8
2210 end program test_cosh
2213 @item @emph{Specific names}:
2214 @multitable @columnfractions .20 .20 .20 .25
2215 @item Name @tab Argument @tab Return type @tab Standard
2216 @item @code{DCOSH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
2219 @item @emph{See also}:
2220 Inverse function: @ref{ACOSH}
2227 @section @code{COUNT} --- Count function
2228 @cindex @code{COUNT} intrinsic
2232 @item @emph{Description}:
2233 @code{COUNT(MASK [, DIM])} counts the number of @code{.TRUE.} elements of
2234 @var{MASK} along the dimension of @var{DIM}. If @var{DIM} is omitted it is
2235 taken to be @code{1}. @var{DIM} is a scaler of type @code{INTEGER} in the
2236 range of @math{1 /leq DIM /leq n)} where @math{n} is the rank of @var{MASK}.
2238 @item @emph{Standard}:
2242 transformational function
2244 @item @emph{Syntax}:
2245 @code{RESULT = COUNT(MASK [, DIM])}
2247 @item @emph{Arguments}:
2248 @multitable @columnfractions .15 .70
2249 @item @var{MASK} @tab The type shall be @code{LOGICAL}.
2250 @item @var{DIM} @tab The type shall be @code{INTEGER}.
2253 @item @emph{Return value}:
2254 The return value is of type @code{INTEGER} with rank equal to that of
2257 @item @emph{Example}:
2260 integer, dimension(2,3) :: a, b
2261 logical, dimension(2,3) :: mask
2262 a = reshape( (/ 1, 2, 3, 4, 5, 6 /), (/ 2, 3 /))
2263 b = reshape( (/ 0, 7, 3, 4, 5, 8 /), (/ 2, 3 /))
2264 print '(3i3)', a(1,:)
2265 print '(3i3)', a(2,:)
2267 print '(3i3)', b(1,:)
2268 print '(3i3)', b(2,:)
2271 print '(3l3)', mask(1,:)
2272 print '(3l3)', mask(2,:)
2274 print '(3i3)', count(mask)
2276 print '(3i3)', count(mask, 1)
2278 print '(3i3)', count(mask, 2)
2279 end program test_count
2286 @section @code{CPU_TIME} --- CPU elapsed time in seconds
2287 @cindex @code{CPU_TIME} intrinsic
2288 @cindex time, elapsed
2289 @cindex elapsed time
2292 @item @emph{Description}:
2293 Returns a @code{REAL} value representing the elapsed CPU time in seconds. This
2294 is useful for testing segments of code to determine execution time.
2296 @item @emph{Standard}:
2302 @item @emph{Syntax}:
2303 @code{CALL CPU_TIME(TIME)}
2305 @item @emph{Arguments}:
2306 @multitable @columnfractions .15 .70
2307 @item @var{TIME} @tab The type shall be @code{REAL} with @code{INTENT(OUT)}.
2310 @item @emph{Return value}:
2313 @item @emph{Example}:
2315 program test_cpu_time
2316 real :: start, finish
2317 call cpu_time(start)
2318 ! put code to test here
2319 call cpu_time(finish)
2320 print '("Time = ",f6.3," seconds.")',finish-start
2321 end program test_cpu_time
2328 @section @code{CSHIFT} --- Circular shift function
2329 @cindex @code{CSHIFT} intrinsic
2330 @cindex bit operations
2333 @item @emph{Description}:
2334 @code{CSHIFT(ARRAY, SHIFT [, DIM])} performs a circular shift on elements of
2335 @var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is omitted it is
2336 taken to be @code{1}. @var{DIM} is a scaler of type @code{INTEGER} in the
2337 range of @math{1 /leq DIM /leq n)} where @math{n} is the rank of @var{ARRAY}.
2338 If the rank of @var{ARRAY} is one, then all elements of @var{ARRAY} are shifted
2339 by @var{SHIFT} places. If rank is greater than one, then all complete rank one
2340 sections of @var{ARRAY} along the given dimension are shifted. Elements
2341 shifted out one end of each rank one section are shifted back in the other end.
2343 @item @emph{Standard}:
2347 transformational function
2349 @item @emph{Syntax}:
2350 @code{RESULT = CSHIFT(A, SHIFT [, DIM])}
2352 @item @emph{Arguments}:
2353 @multitable @columnfractions .15 .70
2354 @item @var{ARRAY} @tab May be any type, not scaler.
2355 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
2356 @item @var{DIM} @tab The type shall be @code{INTEGER}.
2359 @item @emph{Return value}:
2360 Returns an array of same type and rank as the @var{ARRAY} argument.
2362 @item @emph{Example}:
2365 integer, dimension(3,3) :: a
2366 a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
2367 print '(3i3)', a(1,:)
2368 print '(3i3)', a(2,:)
2369 print '(3i3)', a(3,:)
2370 a = cshift(a, SHIFT=(/1, 2, -1/), DIM=2)
2372 print '(3i3)', a(1,:)
2373 print '(3i3)', a(2,:)
2374 print '(3i3)', a(3,:)
2375 end program test_cshift
2381 @section @code{CTIME} --- Convert a time into a string
2382 @cindex @code{CTIME} intrinsic
2383 @cindex time, conversion function
2386 @item @emph{Description}:
2387 @code{CTIME(T,S)} converts @var{T}, a system time value, such as returned
2388 by @code{TIME8()}, to a string of the form @samp{Sat Aug 19 18:13:14
2389 1995}, and returns that string into @var{S}.
2391 If @code{CTIME} is invoked as a function, it can not be invoked as a
2392 subroutine, and vice versa.
2394 @var{T} is an @code{INTENT(IN)} @code{INTEGER(KIND=8)} variable.
2395 @var{S} is an @code{INTENT(OUT)} @code{CHARACTER} variable.
2397 @item @emph{Standard}:
2403 @item @emph{Syntax}:
2404 @multitable @columnfractions .80
2405 @item @code{CALL CTIME(T,S)}.
2406 @item @code{S = CTIME(T)}, (not recommended).
2409 @item @emph{Arguments}:
2410 @multitable @columnfractions .15 .70
2411 @item @var{S}@tab The type shall be of type @code{CHARACTER}.
2412 @item @var{T}@tab The type shall be of type @code{INTEGER(KIND=8)}.
2415 @item @emph{Return value}:
2416 The converted date and time as a string.
2418 @item @emph{Example}:
2422 character(len=30) :: date
2425 ! Do something, main part of the program
2428 print *, 'Program was started on ', date
2429 end program test_ctime
2432 @item @emph{See Also}:
2433 @ref{GMTIME}, @ref{LTIME}, @ref{TIME}, @ref{TIME8}
2440 @section @code{DATE_AND_TIME} --- Date and time subroutine
2441 @cindex @code{DATE_AND_TIME} intrinsic
2442 @cindex date, current
2443 @cindex current date
2444 @cindex time, current
2445 @cindex current time
2448 @item @emph{Description}:
2449 @code{DATE_AND_TIME(DATE, TIME, ZONE, VALUES)} gets the corresponding date and
2450 time information from the real-time system clock. @var{DATE} is
2451 @code{INTENT(OUT)} and has form ccyymmdd. @var{TIME} is @code{INTENT(OUT)} and
2452 has form hhmmss.sss. @var{ZONE} is @code{INTENT(OUT)} and has form (+-)hhmm,
2453 representing the difference with respect to Coordinated Universal Time (UTC).
2454 Unavailable time and date parameters return blanks.
2456 @var{VALUES} is @code{INTENT(OUT)} and provides the following:
2458 @multitable @columnfractions .15 .30 .40
2459 @item @tab @code{VALUE(1)}: @tab The year
2460 @item @tab @code{VALUE(2)}: @tab The month
2461 @item @tab @code{VALUE(3)}: @tab The day of the month
2462 @item @tab @code{VALUE(4)}: @tab Time difference with UTC in minutes
2463 @item @tab @code{VALUE(5)}: @tab The hour of the day
2464 @item @tab @code{VALUE(6)}: @tab The minutes of the hour
2465 @item @tab @code{VALUE(7)}: @tab The seconds of the minute
2466 @item @tab @code{VALUE(8)}: @tab The milliseconds of the second
2469 @item @emph{Standard}:
2475 @item @emph{Syntax}:
2476 @code{CALL DATE_AND_TIME([DATE, TIME, ZONE, VALUES])}
2478 @item @emph{Arguments}:
2479 @multitable @columnfractions .15 .70
2480 @item @var{DATE} @tab (Optional) The type shall be @code{CHARACTER(8)} or larger.
2481 @item @var{TIME} @tab (Optional) The type shall be @code{CHARACTER(10)} or larger.
2482 @item @var{ZONE} @tab (Optional) The type shall be @code{CHARACTER(5)} or larger.
2483 @item @var{VALUES}@tab (Optional) The type shall be @code{INTEGER(8)}.
2486 @item @emph{Return value}:
2489 @item @emph{Example}:
2491 program test_time_and_date
2492 character(8) :: date
2493 character(10) :: time
2494 character(5) :: zone
2495 integer,dimension(8) :: values
2496 ! using keyword arguments
2497 call date_and_time(date,time,zone,values)
2498 call date_and_time(DATE=date,ZONE=zone)
2499 call date_and_time(TIME=time)
2500 call date_and_time(VALUES=values)
2501 print '(a,2x,a,2x,a)', date, time, zone
2502 print '(8i5))', values
2503 end program test_time_and_date
2510 @section @code{DBLE} --- Double conversion function
2511 @cindex @code{DBLE} intrinsic
2512 @cindex double conversion
2515 @item @emph{Description}:
2516 @code{DBLE(X)} Converts @var{X} to double precision real type.
2518 @item @emph{Standard}:
2524 @item @emph{Syntax}:
2525 @code{RESULT = DBLE(X)}
2527 @item @emph{Arguments}:
2528 @multitable @columnfractions .15 .70
2529 @item @var{X} @tab The type shall be @code{INTEGER(*)}, @code{REAL(*)},
2530 or @code{COMPLEX(*)}.
2533 @item @emph{Return value}:
2534 The return value is of type double precision real.
2536 @item @emph{Example}:
2541 complex :: z = (2.3,1.14)
2542 print *, dble(x), dble(i), dble(z)
2543 end program test_dble
2546 @item @emph{See also}:
2547 @ref{DFLOAT}, @ref{FLOAT}, @ref{REAL}
2553 @section @code{DCMPLX} --- Double complex conversion function
2554 @cindex @code{DCMPLX} intrinsic
2555 @cindex complex numbers, conversion to
2558 @item @emph{Description}:
2559 @code{DCMPLX(X [,Y])} returns a double complex number where @var{X} is
2560 converted to the real component. If @var{Y} is present it is converted to the
2561 imaginary component. If @var{Y} is not present then the imaginary component is
2562 set to 0.0. If @var{X} is complex then @var{Y} must not be present.
2564 @item @emph{Standard}:
2570 @item @emph{Syntax}:
2571 @code{RESULT = DCMPLX(X [, Y])}
2573 @item @emph{Arguments}:
2574 @multitable @columnfractions .15 .70
2575 @item @var{X} @tab The type may be @code{INTEGER(*)}, @code{REAL(*)},
2576 or @code{COMPLEX(*)}.
2577 @item @var{Y} @tab (Optional if @var{X} is not @code{COMPLEX(*)}.) May be
2578 @code{INTEGER(*)} or @code{REAL(*)}.
2581 @item @emph{Return value}:
2582 The return value is of type @code{COMPLEX(8)}
2584 @item @emph{Example}:
2594 print *, dcmplx(x,i)
2595 end program test_dcmplx
2602 @section @code{DFLOAT} --- Double conversion function
2603 @cindex @code{DFLOAT} intrinsic
2604 @cindex double float conversion
2607 @item @emph{Description}:
2608 @code{DFLOAT(X)} Converts @var{X} to double precision real type.
2610 @item @emph{Standard}:
2616 @item @emph{Syntax}:
2617 @code{RESULT = DFLOAT(X)}
2619 @item @emph{Arguments}:
2620 @multitable @columnfractions .15 .70
2621 @item @var{X} @tab The type shall be @code{INTEGER(*)}.
2624 @item @emph{Return value}:
2625 The return value is of type double precision real.
2627 @item @emph{Example}:
2632 end program test_dfloat
2635 @item @emph{See also}:
2636 @ref{DBLE}, @ref{FLOAT}, @ref{REAL}
2642 @section @code{DIGITS} --- Significant digits function
2643 @cindex @code{DIGITS} intrinsic
2644 @cindex digits, significant
2647 @item @emph{Description}:
2648 @code{DIGITS(X)} returns the number of significant digits of the internal model
2649 representation of @var{X}. For example, on a system using a 32-bit
2650 floating point representation, a default real number would likely return 24.
2652 @item @emph{Standard}:
2658 @item @emph{Syntax}:
2659 @code{RESULT = DIGITS(X)}
2661 @item @emph{Arguments}:
2662 @multitable @columnfractions .15 .70
2663 @item @var{X} @tab The type may be @code{INTEGER(*)} or @code{REAL(*)}.
2666 @item @emph{Return value}:
2667 The return value is of type @code{INTEGER}.
2669 @item @emph{Example}:
2672 integer :: i = 12345
2678 end program test_digits
2685 @section @code{DIM} --- Dim function
2686 @cindex @code{DIM} intrinsic
2687 @cindex @code{IDIM} intrinsic
2688 @cindex @code{DDIM} intrinsic
2692 @item @emph{Description}:
2693 @code{DIM(X,Y)} returns the difference @code{X-Y} if the result is positive;
2694 otherwise returns zero.
2696 @item @emph{Standard}:
2702 @item @emph{Syntax}:
2703 @code{RESULT = DIM(X, Y)}
2705 @item @emph{Arguments}:
2706 @multitable @columnfractions .15 .70
2707 @item @var{X} @tab The type shall be @code{INTEGER(*)} or @code{REAL(*)}
2708 @item @var{Y} @tab The type shall be the same type and kind as @var{X}.
2711 @item @emph{Return value}:
2712 The return value is of type @code{INTEGER(*)} or @code{REAL(*)}.
2714 @item @emph{Example}:
2720 x = dim(4.345_8, 2.111_8)
2723 end program test_dim
2726 @item @emph{Specific names}:
2727 @multitable @columnfractions .20 .20 .20 .25
2728 @item Name @tab Argument @tab Return type @tab Standard
2729 @item @code{IDIM(X,Y)} @tab @code{INTEGER(4) X,Y} @tab @code{INTEGER(4)} @tab F77 and later
2730 @item @code{DDIM(X,Y)} @tab @code{REAL(8) X,Y} @tab @code{REAL(8)} @tab F77 and later
2737 @section @code{DOT_PRODUCT} --- Dot product function
2738 @cindex @code{DOT_PRODUCT} intrinsic
2742 @item @emph{Description}:
2743 @code{DOT_PRODUCT(X,Y)} computes the dot product multiplication of two vectors
2744 @var{X} and @var{Y}. The two vectors may be either numeric or logical
2745 and must be arrays of rank one and of equal size. If the vectors are
2746 @code{INTEGER(*)} or @code{REAL(*)}, the result is @code{SUM(X*Y)}. If the
2747 vectors are @code{COMPLEX(*)}, the result is @code{SUM(CONJG(X)*Y)}. If the
2748 vectors are @code{LOGICAL}, the result is @code{ANY(X.AND.Y)}.
2750 @item @emph{Standard}:
2754 transformational function
2756 @item @emph{Syntax}:
2757 @code{RESULT = DOT_PRODUCT(X, Y)}
2759 @item @emph{Arguments}:
2760 @multitable @columnfractions .15 .70
2761 @item @var{X} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
2762 @item @var{Y} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
2765 @item @emph{Return value}:
2766 If the arguments are numeric, the return value is a scaler of numeric type,
2767 @code{INTEGER(*)}, @code{REAL(*)}, or @code{COMPLEX(*)}. If the arguments are
2768 @code{LOGICAL}, the return value is @code{.TRUE.} or @code{.FALSE.}.
2770 @item @emph{Example}:
2772 program test_dot_prod
2773 integer, dimension(3) :: a, b
2780 print *, dot_product(a,b)
2781 end program test_dot_prod
2788 @section @code{DPROD} --- Double product function
2789 @cindex @code{DPROD} intrinsic
2790 @cindex double-precision product
2793 @item @emph{Description}:
2794 @code{DPROD(X,Y)} returns the product @code{X*Y}.
2796 @item @emph{Standard}:
2802 @item @emph{Syntax}:
2803 @code{RESULT = DPROD(X, Y)}
2805 @item @emph{Arguments}:
2806 @multitable @columnfractions .15 .70
2807 @item @var{X} @tab The type shall be @code{REAL}.
2808 @item @var{Y} @tab The type shall be @code{REAL}.
2811 @item @emph{Return value}:
2812 The return value is of type @code{REAL(8)}.
2814 @item @emph{Example}:
2823 end program test_dprod
2830 @section @code{DREAL} --- Double real part function
2831 @cindex @code{DREAL} intrinsic
2832 @cindex double-precision real part
2835 @item @emph{Description}:
2836 @code{DREAL(Z)} returns the real part of complex variable @var{Z}.
2838 @item @emph{Standard}:
2844 @item @emph{Syntax}:
2845 @code{RESULT = DREAL(Z)}
2847 @item @emph{Arguments}:
2848 @multitable @columnfractions .15 .70
2849 @item @var{Z} @tab The type shall be @code{COMPLEX(8)}.
2852 @item @emph{Return value}:
2853 The return value is of type @code{REAL(8)}.
2855 @item @emph{Example}:
2858 complex(8) :: z = (1.3_8,7.2_8)
2860 end program test_dreal
2863 @item @emph{See also}:
2871 @section @code{DTIME} --- Execution time subroutine (or function)
2872 @cindex @code{DTIME} intrinsic
2873 @cindex time, elapsed
2874 @cindex elapsed time
2877 @item @emph{Description}:
2878 @code{DTIME(TARRAY, RESULT)} initially returns the number of seconds of runtime
2879 since the start of the process's execution in @var{RESULT}. @var{TARRAY}
2880 returns the user and system components of this time in @code{TARRAY(1)} and
2881 @code{TARRAY(2)} respectively. @var{RESULT} is equal to @code{TARRAY(1) +
2884 Subsequent invocations of @code{DTIME} return values accumulated since the
2885 previous invocation.
2887 On some systems, the underlying timings are represented using types with
2888 sufficiently small limits that overflows (wrap around) are possible, such as
2889 32-bit types. Therefore, the values returned by this intrinsic might be, or
2890 become, negative, or numerically less than previous values, during a single
2891 run of the compiled program.
2893 If @code{DTIME} is invoked as a function, it can not be invoked as a
2894 subroutine, and vice versa.
2896 @var{TARRAY} and @var{RESULT} are @code{INTENT(OUT)} and provide the following:
2898 @multitable @columnfractions .15 .30 .40
2899 @item @tab @code{TARRAY(1)}: @tab User time in seconds.
2900 @item @tab @code{TARRAY(2)}: @tab System time in seconds.
2901 @item @tab @code{RESULT}: @tab Run time since start in seconds.
2904 @item @emph{Standard}:
2910 @item @emph{Syntax}:
2911 @multitable @columnfractions .80
2912 @item @code{CALL DTIME(TARRAY, RESULT)}.
2913 @item @code{RESULT = DTIME(TARRAY)}, (not recommended).
2916 @item @emph{Arguments}:
2917 @multitable @columnfractions .15 .70
2918 @item @var{TARRAY}@tab The type shall be @code{REAL, DIMENSION(2)}.
2919 @item @var{RESULT}@tab The type shall be @code{REAL}.
2922 @item @emph{Return value}:
2923 Elapsed time in seconds since the start of program execution.
2925 @item @emph{Example}:
2929 real, dimension(2) :: tarray
2931 call dtime(tarray, result)
2935 do i=1,100000000 ! Just a delay
2938 call dtime(tarray, result)
2942 end program test_dtime
2949 @section @code{EOSHIFT} --- End-off shift function
2950 @cindex @code{EOSHIFT} intrinsic
2951 @cindex bit operations
2954 @item @emph{Description}:
2955 @code{EOSHIFT(ARRAY, SHIFT[,BOUNDARY, DIM])} performs an end-off shift on
2956 elements of @var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is
2957 omitted it is taken to be @code{1}. @var{DIM} is a scaler of type
2958 @code{INTEGER} in the range of @math{1 /leq DIM /leq n)} where @math{n} is the
2959 rank of @var{ARRAY}. If the rank of @var{ARRAY} is one, then all elements of
2960 @var{ARRAY} are shifted by @var{SHIFT} places. If rank is greater than one,
2961 then all complete rank one sections of @var{ARRAY} along the given dimension are
2962 shifted. Elements shifted out one end of each rank one section are dropped. If
2963 @var{BOUNDARY} is present then the corresponding value of from @var{BOUNDARY}
2964 is copied back in the other end. If @var{BOUNDARY} is not present then the
2965 following are copied in depending on the type of @var{ARRAY}.
2967 @multitable @columnfractions .15 .80
2968 @item @emph{Array Type} @tab @emph{Boundary Value}
2969 @item Numeric @tab 0 of the type and kind of @var{ARRAY}.
2970 @item Logical @tab @code{.FALSE.}.
2971 @item Character(@var{len}) @tab @var{len} blanks.
2974 @item @emph{Standard}:
2978 transformational function
2980 @item @emph{Syntax}:
2981 @code{RESULT = EOSHIFT(A, SHIFT [, BOUNDARY, DIM])}
2983 @item @emph{Arguments}:
2984 @multitable @columnfractions .15 .70
2985 @item @var{ARRAY} @tab May be any type, not scaler.
2986 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
2987 @item @var{BOUNDARY} @tab Same type as @var{ARRAY}.
2988 @item @var{DIM} @tab The type shall be @code{INTEGER}.
2991 @item @emph{Return value}:
2992 Returns an array of same type and rank as the @var{ARRAY} argument.
2994 @item @emph{Example}:
2996 program test_eoshift
2997 integer, dimension(3,3) :: a
2998 a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
2999 print '(3i3)', a(1,:)
3000 print '(3i3)', a(2,:)
3001 print '(3i3)', a(3,:)
3002 a = EOSHIFT(a, SHIFT=(/1, 2, 1/), BOUNDARY=-5, DIM=2)
3004 print '(3i3)', a(1,:)
3005 print '(3i3)', a(2,:)
3006 print '(3i3)', a(3,:)
3007 end program test_eoshift
3014 @section @code{EPSILON} --- Epsilon function
3015 @cindex @code{EPSILON} intrinsic
3016 @cindex epsilon, significant
3019 @item @emph{Description}:
3020 @code{EPSILON(X)} returns a nearly negligible number relative to @code{1}.
3022 @item @emph{Standard}:
3028 @item @emph{Syntax}:
3029 @code{RESULT = EPSILON(X)}
3031 @item @emph{Arguments}:
3032 @multitable @columnfractions .15 .70
3033 @item @var{X} @tab The type shall be @code{REAL(*)}.
3036 @item @emph{Return value}:
3037 The return value is of same type as the argument.
3039 @item @emph{Example}:
3041 program test_epsilon
3046 end program test_epsilon
3053 @section @code{ERF} --- Error function
3054 @cindex @code{ERF} intrinsic
3055 @cindex error function
3058 @item @emph{Description}:
3059 @code{ERF(X)} computes the error function of @var{X}.
3061 @item @emph{Standard}:
3067 @item @emph{Syntax}:
3068 @code{RESULT = ERF(X)}
3070 @item @emph{Arguments}:
3071 @multitable @columnfractions .15 .70
3072 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
3075 @item @emph{Return value}:
3076 The return value is a scalar of type @code{REAL(*)} and it is positive
3077 (@math{ - 1 \leq erf (x) \leq 1 }.
3079 @item @emph{Example}:
3082 real(8) :: x = 0.17_8
3084 end program test_erf
3087 @item @emph{Specific names}:
3088 @multitable @columnfractions .20 .20 .20 .25
3089 @item Name @tab Argument @tab Return type @tab Standard
3090 @item @code{DERF(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
3097 @section @code{ERFC} --- Error function
3098 @cindex @code{ERFC} intrinsic
3099 @cindex error function
3102 @item @emph{Description}:
3103 @code{ERFC(X)} computes the complementary error function of @var{X}.
3105 @item @emph{Standard}:
3111 @item @emph{Syntax}:
3112 @code{RESULT = ERFC(X)}
3114 @item @emph{Arguments}:
3115 @multitable @columnfractions .15 .70
3116 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
3119 @item @emph{Return value}:
3120 The return value is a scalar of type @code{REAL(*)} and it is positive
3121 (@math{ 0 \leq erfc (x) \leq 2 }.
3123 @item @emph{Example}:
3126 real(8) :: x = 0.17_8
3128 end program test_erfc
3131 @item @emph{Specific names}:
3132 @multitable @columnfractions .20 .20 .20 .25
3133 @item Name @tab Argument @tab Return type @tab Standard
3134 @item @code{DERFC(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
3141 @section @code{ETIME} --- Execution time subroutine (or function)
3142 @cindex @code{ETIME} intrinsic
3143 @cindex time, elapsed
3146 @item @emph{Description}:
3147 @code{ETIME(TARRAY, RESULT)} returns the number of seconds of runtime
3148 since the start of the process's execution in @var{RESULT}. @var{TARRAY}
3149 returns the user and system components of this time in @code{TARRAY(1)} and
3150 @code{TARRAY(2)} respectively. @var{RESULT} is equal to @code{TARRAY(1) + TARRAY(2)}.
3152 On some systems, the underlying timings are represented using types with
3153 sufficiently small limits that overflows (wrap around) are possible, such as
3154 32-bit types. Therefore, the values returned by this intrinsic might be, or
3155 become, negative, or numerically less than previous values, during a single
3156 run of the compiled program.
3158 If @code{ETIME} is invoked as a function, it can not be invoked as a
3159 subroutine, and vice versa.
3161 @var{TARRAY} and @var{RESULT} are @code{INTENT(OUT)} and provide the following:
3163 @multitable @columnfractions .15 .30 .60
3164 @item @tab @code{TARRAY(1)}: @tab User time in seconds.
3165 @item @tab @code{TARRAY(2)}: @tab System time in seconds.
3166 @item @tab @code{RESULT}: @tab Run time since start in seconds.
3169 @item @emph{Standard}:
3175 @item @emph{Syntax}:
3176 @multitable @columnfractions .80
3177 @item @code{CALL ETIME(TARRAY, RESULT)}.
3178 @item @code{RESULT = ETIME(TARRAY)}, (not recommended).
3181 @item @emph{Arguments}:
3182 @multitable @columnfractions .15 .70
3183 @item @var{TARRAY}@tab The type shall be @code{REAL, DIMENSION(2)}.
3184 @item @var{RESULT}@tab The type shall be @code{REAL}.
3187 @item @emph{Return value}:
3188 Elapsed time in seconds since the start of program execution.
3190 @item @emph{Example}:
3194 real, dimension(2) :: tarray
3196 call ETIME(tarray, result)
3200 do i=1,100000000 ! Just a delay
3203 call ETIME(tarray, result)
3207 end program test_etime
3210 @item @emph{See also}:
3218 @section @code{EXIT} --- Exit the program with status.
3219 @cindex @code{EXIT} intrinsic
3220 @cindex exit program
3223 @item @emph{Description}:
3224 @code{EXIT} causes immediate termination of the program with status. If status
3225 is omitted it returns the canonical @emph{success} for the system. All Fortran
3226 I/O units are closed.
3228 @item @emph{Standard}:
3234 @item @emph{Syntax}:
3235 @code{CALL EXIT([STATUS])}
3237 @item @emph{Arguments}:
3238 @multitable @columnfractions .15 .70
3239 @item @var{STATUS} @tab The type of the argument shall be @code{INTEGER(*)}.
3242 @item @emph{Return value}:
3243 @code{STATUS} is passed to the parent process on exit.
3245 @item @emph{Example}:
3248 integer :: STATUS = 0
3249 print *, 'This program is going to exit.'
3251 end program test_exit
3254 @item @emph{See also}:
3255 @ref{ABORT}, @ref{KILL}
3261 @section @code{EXP} --- Exponential function
3262 @cindex @code{EXP} intrinsic
3263 @cindex @code{DEXP} intrinsic
3264 @cindex @code{ZEXP} intrinsic
3265 @cindex @code{CDEXP} intrinsic
3269 @item @emph{Description}:
3270 @code{EXP(X)} computes the base @math{e} exponential of @var{X}.
3272 @item @emph{Standard}:
3273 F77 and later, has overloads that are GNU extensions
3278 @item @emph{Syntax}:
3279 @code{RESULT = EXP(X)}
3281 @item @emph{Arguments}:
3282 @multitable @columnfractions .15 .70
3283 @item @var{X} @tab The type shall be @code{REAL(*)} or
3287 @item @emph{Return value}:
3288 The return value has same type and kind as @var{X}.
3290 @item @emph{Example}:
3295 end program test_exp
3298 @item @emph{Specific names}:
3299 @multitable @columnfractions .20 .20 .20 .25
3300 @item Name @tab Argument @tab Return type @tab Standard
3301 @item @code{DEXP(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
3302 @item @code{CEXP(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab F77 and later
3303 @item @code{ZEXP(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
3304 @item @code{CDEXP(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
3311 @section @code{EXPONENT} --- Exponent function
3312 @cindex @code{EXPONENT} intrinsic
3313 @cindex exponent part of a real number
3316 @item @emph{Description}:
3317 @code{EXPONENT(X)} returns the value of the exponent part of @var{X}. If @var{X}
3318 is zero the value returned is zero.
3320 @item @emph{Standard}:
3326 @item @emph{Syntax}:
3327 @code{RESULT = EXPONENT(X)}
3329 @item @emph{Arguments}:
3330 @multitable @columnfractions .15 .70
3331 @item @var{X} @tab The type shall be @code{REAL(*)}.
3334 @item @emph{Return value}:
3335 The return value is of type default @code{INTEGER}.
3337 @item @emph{Example}:
3339 program test_exponent
3344 print *, exponent(0.0)
3345 end program test_exponent
3351 @section @code{FDATE} --- Get the current time as a string
3352 @cindex @code{FDATE} intrinsic
3353 @cindex time, current
3354 @cindex current time
3355 @cindex date, current
3356 @cindex current date
3359 @item @emph{Description}:
3360 @code{FDATE(DATE)} returns the current date (using the same format as
3361 @code{CTIME}) in @var{DATE}. It is equivalent to @code{CALL CTIME(DATE,
3364 If @code{FDATE} is invoked as a function, it can not be invoked as a
3365 subroutine, and vice versa.
3367 @var{DATE} is an @code{INTENT(OUT)} @code{CHARACTER} variable.
3369 @item @emph{Standard}:
3375 @item @emph{Syntax}:
3376 @multitable @columnfractions .80
3377 @item @code{CALL FDATE(DATE)}.
3378 @item @code{DATE = FDATE()}, (not recommended).
3381 @item @emph{Arguments}:
3382 @multitable @columnfractions .15 .70
3383 @item @var{DATE}@tab The type shall be of type @code{CHARACTER}.
3386 @item @emph{Return value}:
3387 The current date as a string.
3389 @item @emph{Example}:
3393 character(len=30) :: date
3395 print *, 'Program started on ', date
3396 do i = 1, 100000000 ! Just a delay
3400 print *, 'Program ended on ', date
3401 end program test_fdate
3407 @section @code{FLOAT} --- Convert integer to default real
3408 @cindex @code{FLOAT} intrinsic
3409 @cindex conversion function (float)
3412 @item @emph{Description}:
3413 @code{FLOAT(I)} converts the integer @var{I} to a default real value.
3415 @item @emph{Standard}:
3421 @item @emph{Syntax}:
3422 @code{RESULT = FLOAT(I)}
3424 @item @emph{Arguments}:
3425 @multitable @columnfractions .15 .70
3426 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
3429 @item @emph{Return value}:
3430 The return value is of type default @code{REAL}.
3432 @item @emph{Example}:
3436 if (float(i) /= 1.) call abort
3437 end program test_float
3440 @item @emph{See also}:
3441 @ref{DBLE}, @ref{DFLOAT}, @ref{REAL}
3447 @section @code{FGET} --- Read a single character in stream mode from stdin
3448 @cindex @code{FGET} intrinsic
3449 @cindex file operations
3450 @cindex stream operations
3453 @item @emph{Description}:
3454 Read a single character in stream mode from stdin by bypassing normal
3455 formatted output. Stream I/O should not be mixed with normal record-oriented
3456 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
3458 This intrinsic routine is provided for backwards compatibility with
3459 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
3460 Programmers should consider the use of new stream IO feature in new code
3461 for future portability. See also @ref{Fortran 2003 status}.
3463 @item @emph{Standard}:
3467 Non-elemental subroutine
3469 @item @emph{Syntax}:
3470 @code{CALL FGET(C [, STATUS])}
3472 @item @emph{Arguments}:
3473 @multitable @columnfractions .15 .70
3474 @item @var{C} @tab The type shall be @code{CHARACTER}.
3475 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
3476 Returns 0 on success, -1 on end-of-file, and a
3477 system specific positive error code otherwise.
3480 @item @emph{Example}:
3483 INTEGER, PARAMETER :: strlen = 100
3484 INTEGER :: status, i = 1
3485 CHARACTER(len=strlen) :: str = ""
3487 WRITE (*,*) 'Enter text:'
3489 CALL fget(str(i:i), status)
3490 if (status /= 0 .OR. i > strlen) exit
3493 WRITE (*,*) TRIM(str)
3497 @item @emph{See also}:
3498 @ref{FGETC}, @ref{FPUT}, @ref{FPUTC}
3503 @section @code{FGETC} --- Read a single character in stream mode
3504 @cindex @code{FGETC} intrinsic
3505 @cindex file operations
3506 @cindex stream operations
3509 @item @emph{Description}:
3510 Read a single character in stream mode by bypassing normal formatted output.
3511 Stream I/O should not be mixed with normal record-oriented (formatted or
3512 unformatted) I/O on the same unit; the results are unpredictable.
3514 This intrinsic routine is provided for backwards compatibility with
3515 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
3516 Programmers should consider the use of new stream IO feature in new code
3517 for future portability. See also @ref{Fortran 2003 status}.
3519 @item @emph{Standard}:
3523 Non-elemental subroutine
3525 @item @emph{Syntax}:
3526 @code{CALL FGETC(UNIT, C [, STATUS])}
3528 @item @emph{Arguments}:
3529 @multitable @columnfractions .15 .70
3530 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
3531 @item @var{C} @tab The type shall be @code{CHARACTER}.
3532 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. Returns 0 on success,
3533 -1 on end-of-file and a system specific positive error code otherwise.
3536 @item @emph{Example}:
3539 INTEGER :: fd = 42, status
3542 OPEN(UNIT=fd, FILE="/etc/passwd", ACTION="READ", STATUS = "OLD")
3544 CALL fgetc(fd, c, status)
3545 IF (status /= 0) EXIT
3552 @item @emph{See also}:
3553 @ref{FGET}, @ref{FPUT}, @ref{FPUTC}
3559 @section @code{FLOOR} --- Integer floor function
3560 @cindex @code{FLOOR} intrinsic
3564 @item @emph{Description}:
3565 @code{FLOOR(X)} returns the greatest integer less than or equal to @var{X}.
3567 @item @emph{Standard}:
3573 @item @emph{Syntax}:
3574 @code{RESULT = FLOOR(X [, KIND])}
3576 @item @emph{Arguments}:
3577 @multitable @columnfractions .15 .70
3578 @item @var{X} @tab The type shall be @code{REAL(*)}.
3579 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
3580 expression indicating the kind parameter of
3584 @item @emph{Return value}:
3585 The return value is of type @code{INTEGER(KIND)}
3587 @item @emph{Example}:
3592 print *, floor(x) ! returns 63
3593 print *, floor(y) ! returns -64
3594 end program test_floor
3597 @item @emph{See also}:
3598 @ref{CEILING}, @ref{NINT}
3605 @section @code{FLUSH} --- Flush I/O unit(s)
3606 @cindex @code{FLUSH} intrinsic
3607 @cindex flush output files
3610 @item @emph{Description}:
3611 Flushes Fortran unit(s) currently open for output. Without the optional
3612 argument, all units are flushed, otherwise just the unit specified.
3614 @item @emph{Standard}:
3618 Non-elemental subroutine
3620 @item @emph{Syntax}:
3621 @code{CALL FLUSH(UNIT)}
3623 @item @emph{Arguments}:
3624 @multitable @columnfractions .15 .70
3625 @item @var{UNIT} @tab (Optional) The type shall be @code{INTEGER}.
3629 Beginning with the Fortran 2003 standard, there is a @code{FLUSH}
3630 statement that should be preferred over the @code{FLUSH} intrinsic.
3637 @section @code{FNUM} --- File number function
3638 @cindex @code{FNUM} intrinsic
3642 @item @emph{Description}:
3643 @code{FNUM(UNIT)} returns the POSIX file descriptor number corresponding to the
3644 open Fortran I/O unit @code{UNIT}.
3646 @item @emph{Standard}:
3650 Non-elemental function
3652 @item @emph{Syntax}:
3653 @code{RESULT = FNUM(UNIT)}
3655 @item @emph{Arguments}:
3656 @multitable @columnfractions .15 .70
3657 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
3660 @item @emph{Return value}:
3661 The return value is of type @code{INTEGER}
3663 @item @emph{Example}:
3667 open (unit=10, status = "scratch")
3671 end program test_fnum
3678 @section @code{FPUT} --- Write a single character in stream mode to stdout
3679 @cindex @code{FPUT} intrinsic
3680 @cindex file operations
3681 @cindex stream operations
3684 @item @emph{Description}:
3685 Write a single character in stream mode to stdout by bypassing normal
3686 formatted output. Stream I/O should not be mixed with normal record-oriented
3687 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
3689 This intrinsic routine is provided for backwards compatibility with
3690 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
3691 Programmers should consider the use of new stream IO feature in new code
3692 for future portability. See also @ref{Fortran 2003 status}.
3694 @item @emph{Standard}:
3698 Non-elemental subroutine
3700 @item @emph{Syntax}:
3701 @code{CALL FPUT(C [, STATUS])}
3703 @item @emph{Arguments}:
3704 @multitable @columnfractions .15 .70
3705 @item @var{C} @tab The type shall be @code{CHARACTER}.
3706 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. Returns 0 on success,
3707 -1 on end-of-file and a system specific positive error code otherwise.
3710 @item @emph{Example}:
3713 CHARACTER(len=*) :: str = "gfortran"
3715 DO i = 1, len_trim(str)
3721 @item @emph{See also}:
3722 @ref{FPUTC}, @ref{FGET}, @ref{FGETC}
3728 @section @code{FPUTC} --- Write a single character in stream mode
3729 @cindex @code{FPUTC} intrinsic
3730 @cindex file operations
3731 @cindex stream operations
3734 @item @emph{Description}:
3735 Write a single character in stream mode by bypassing normal formatted
3736 output. Stream I/O should not be mixed with normal record-oriented
3737 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
3739 This intrinsic routine is provided for backwards compatibility with
3740 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
3741 Programmers should consider the use of new stream IO feature in new code
3742 for future portability. See also @ref{Fortran 2003 status}.
3744 @item @emph{Standard}:
3748 Non-elemental subroutine
3750 @item @emph{Syntax}:
3751 @code{CALL FPUTC(UNIT, C [, STATUS])}
3753 @item @emph{Arguments}:
3754 @multitable @columnfractions .15 .70
3755 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
3756 @item @var{C} @tab The type shall be @code{CHARACTER}.
3757 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. Returns 0 on success,
3758 -1 on end-of-file and a system specific positive error code otherwise.
3761 @item @emph{Example}:
3764 CHARACTER(len=*) :: str = "gfortran"
3765 INTEGER :: fd = 42, i
3767 OPEN(UNIT = fd, FILE = "out", ACTION = "WRITE", STATUS="NEW")
3768 DO i = 1, len_trim(str)
3769 CALL fputc(fd, str(i:i))
3775 @item @emph{See also}:
3776 @ref{FPUT}, @ref{FGET}, @ref{FGETC}
3782 @section @code{FRACTION} --- Fractional part of the model representation
3783 @cindex @code{FRACTION} intrinsic
3784 @cindex fractional part
3787 @item @emph{Description}:
3788 @code{FRACTION(X)} returns the fractional part of the model
3789 representation of @code{X}.
3791 @item @emph{Standard}:
3797 @item @emph{Syntax}:
3798 @code{Y = FRACTION(X)}
3800 @item @emph{Arguments}:
3801 @multitable @columnfractions .15 .70
3802 @item @var{X} @tab The type of the argument shall be a @code{REAL}.
3805 @item @emph{Return value}:
3806 The return value is of the same type and kind as the argument.
3807 The fractional part of the model representation of @code{X} is returned;
3808 it is @code{X * RADIX(X)**(-EXPONENT(X))}.
3810 @item @emph{Example}:
3812 program test_fraction
3815 print *, fraction(x), x * radix(x)**(-exponent(x))
3816 end program test_fraction
3824 @section @code{FREE} --- Frees memory
3825 @cindex @code{FREE} intrinsic
3826 @cindex Cray pointers
3829 @item @emph{Description}:
3830 Frees memory previously allocated by @code{MALLOC()}. The @code{FREE}
3831 intrinsic is an extension intended to be used with Cray pointers, and is
3832 provided in GNU Fortran to allow user to compile legacy code. For
3833 new code using Fortran 95 pointers, the memory de-allocation intrinsic is
3836 @item @emph{Standard}:
3842 @item @emph{Syntax}:
3843 @code{CALL FREE(PTR)}
3845 @item @emph{Arguments}:
3846 @multitable @columnfractions .15 .70
3847 @item @var{PTR} @tab The type shall be @code{INTEGER}. It represents the
3848 location of the memory that should be de-allocated.
3851 @item @emph{Return value}:
3854 @item @emph{Example}:
3855 See @code{MALLOC} for an example.
3857 @item @emph{See also}:
3865 @section @code{FSTAT} --- Get file status
3866 @cindex @code{FSTAT} intrinsic
3867 @cindex file system operations
3870 @item @emph{Description}:
3871 @code{FSTAT} is identical to @ref{STAT}, except that information about an
3872 already opened file is obtained.
3874 The elements in @code{BUFF} are the same as described by @ref{STAT}.
3876 @item @emph{Standard}:
3880 Non-elemental subroutine
3882 @item @emph{Syntax}:
3883 @code{CALL FSTAT(UNIT, BUFF [, STATUS])}
3885 @item @emph{Arguments}:
3886 @multitable @columnfractions .15 .70
3887 @item @var{UNIT} @tab An open I/O unit number of type @code{INTEGER}.
3888 @item @var{BUFF} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
3889 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0
3890 on success and a system specific error code otherwise.
3893 @item @emph{Example}:
3894 See @ref{STAT} for an example.
3896 @item @emph{See also}:
3897 To stat a link: @ref{LSTAT}, to stat a file: @ref{STAT}
3903 @section @code{FSEEK} --- Low level file positioning subroutine
3904 @cindex @code{FSEEK} intrinsic
3905 @cindex file system operations
3907 Not yet implemented in GNU Fortran.
3910 @item @emph{Description}:
3912 @item @emph{Standard}:
3918 @item @emph{Syntax}:
3919 @item @emph{Arguments}:
3920 @item @emph{Return value}:
3921 @item @emph{Example}:
3922 @item @emph{Specific names}:
3923 @item @emph{See also}:
3924 @uref{http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19292, g77 features lacking in gfortran}
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 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 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
4617 @item @emph{See also}:
4618 @ref{ACHAR}, @ref{CHAR}, @ref{ICHAR}
4624 @section @code{IAND} --- Bitwise logical and
4625 @cindex @code{IAND} intrinsic
4626 @cindex bit operations
4629 @item @emph{Description}:
4630 Bitwise logical @code{AND}.
4632 @item @emph{Standard}:
4638 @item @emph{Syntax}:
4639 @code{RESULT = IAND(I, J)}
4641 @item @emph{Arguments}:
4642 @multitable @columnfractions .15 .70
4643 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
4644 @item @var{J} @tab The type shall be @code{INTEGER(*)}, of the same
4645 kind as @var{I}. (As a GNU extension, different kinds are also
4649 @item @emph{Return value}:
4650 The return type is @code{INTEGER(*)}, of the same kind as the
4651 arguments. (If the argument kinds differ, it is of the same kind as
4652 the larger argument.)
4654 @item @emph{Example}:
4658 DATA a / Z'F' /, b / Z'3' /
4659 WRITE (*,*) IAND(a, b)
4663 @item @emph{See also}:
4664 @ref{IOR}, @ref{IEOR}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
4671 @section @code{IARGC} --- Get the number of command line arguments
4672 @cindex @code{IARGC} intrinsic
4673 @cindex command-line arguments, to program
4676 @item @emph{Description}:
4677 @code{IARGC()} returns the number of arguments passed on the
4678 command line when the containing program was invoked.
4680 This intrinsic routine is provided for backwards compatibility with
4681 GNU Fortran 77. In new code, programmers should consider the use of
4682 the @ref{COMMAND_ARGUMENT_COUNT} intrinsic defined by the Fortran 2003
4685 @item @emph{Standard}:
4689 Non-elemental Function
4691 @item @emph{Syntax}:
4692 @code{RESULT = IARGC()}
4694 @item @emph{Arguments}:
4697 @item @emph{Return value}:
4698 The number of command line arguments, type @code{INTEGER(4)}.
4700 @item @emph{Example}:
4703 @item @emph{See also}:
4704 GNU Fortran 77 compatibility subroutine: @ref{GETARG}
4706 F2003 functions and subroutines: @ref{GET_COMMAND}, @ref{GET_COMMAND_ARGUMENT},
4707 @ref{COMMAND_ARGUMENT_COUNT}
4713 @section @code{IBCLR} --- Clear bit
4714 @cindex @code{IBCLR} intrinsic
4715 @cindex bit operations
4718 @item @emph{Description}:
4719 @code{IBCLR} returns the value of @var{I} with the bit at position
4720 @var{POS} set to zero.
4722 @item @emph{Standard}:
4728 @item @emph{Syntax}:
4729 @code{RESULT = IBCLR(I, POS)}
4731 @item @emph{Arguments}:
4732 @multitable @columnfractions .15 .70
4733 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
4734 @item @var{POS} @tab The type shall be @code{INTEGER(*)}.
4737 @item @emph{Return value}:
4738 The return value is of type @code{INTEGER(*)} and of the same kind as
4741 @item @emph{See also}:
4742 @ref{IBITS}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}, @ref{MVBITS}
4749 @section @code{IBITS} --- Bit extraction
4750 @cindex @code{IBITS} intrinsic
4751 @cindex bit operations
4754 @item @emph{Description}:
4755 @code{IBITS} extracts a field of length @var{LEN} from @var{I},
4756 starting from bit position @var{POS} and extending left for @var{LEN}
4757 bits. The result is right-justified and the remaining bits are
4758 zeroed. The value of @code{POS+LEN} must be less than or equal to the
4759 value @code{BIT_SIZE(I)}.
4761 @item @emph{Standard}:
4767 @item @emph{Syntax}:
4768 @code{RESULT = IBITS(I, POS, LEN)}
4770 @item @emph{Arguments}:
4771 @multitable @columnfractions .15 .70
4772 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
4773 @item @var{POS} @tab The type shall be @code{INTEGER(*)}.
4774 @item @var{LEN} @tab The type shall be @code{INTEGER(*)}.
4777 @item @emph{Return value}:
4778 The return value is of type @code{INTEGER(*)} and of the same kind as
4781 @item @emph{See also}:
4782 @ref{BIT_SIZE}, @ref{IBCLR}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
4788 @section @code{IBSET} --- Set bit
4789 @cindex @code{IBSET} intrinsic
4790 @cindex bit operations
4793 @item @emph{Description}:
4794 @code{IBSET} returns the value of @var{I} with the bit at position
4795 @var{POS} set to one.
4797 @item @emph{Standard}:
4803 @item @emph{Syntax}:
4804 @code{RESULT = IBSET(I, POS)}
4806 @item @emph{Arguments}:
4807 @multitable @columnfractions .15 .70
4808 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
4809 @item @var{POS} @tab The type shall be @code{INTEGER(*)}.
4812 @item @emph{Return value}:
4813 The return value is of type @code{INTEGER(*)} and of the same kind as
4816 @item @emph{See also}:
4817 @ref{IBCLR}, @ref{IBITS}, @ref{IAND}, @ref{IOR}, @ref{IEOR}, @ref{MVBITS}
4824 @section @code{ICHAR} --- Character-to-integer conversion function
4825 @cindex @code{ICHAR} intrinsic
4826 @cindex conversion function (character)
4829 @item @emph{Description}:
4830 @code{ICHAR(C)} returns the code for the character in the first character
4831 position of @code{C} in the system's native character set.
4832 The correspondence between characters and their codes is not necessarily
4833 the same across different GNU Fortran implementations.
4835 @item @emph{Standard}:
4841 @item @emph{Syntax}:
4842 @code{RESULT = ICHAR(C)}
4844 @item @emph{Arguments}:
4845 @multitable @columnfractions .15 .70
4846 @item @var{C} @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
4849 @item @emph{Return value}:
4850 The return value is of type @code{INTEGER} and of the default integer
4853 @item @emph{Example}:
4858 end program test_ichar
4862 No intrinsic exists to convert a printable character string to a numerical
4863 value. For example, there is no intrinsic that, given the @code{CHARACTER}
4864 value 154, returns an @code{INTEGER} or @code{REAL} value with the
4867 Instead, you can use internal-file I/O to do this kind of conversion. For
4872 character(len=10) string
4875 read (string,'(I10)') value
4877 end program read_val
4880 @item @emph{See also}:
4881 @ref{ACHAR}, @ref{CHAR}, @ref{IACHAR}
4888 @section @code{IDATE} --- Get current local time subroutine (day/month/year)
4889 @cindex @code{IDATE} intrinsic
4892 @item @emph{Description}:
4893 @code{IDATE(TARRAY)} Fills @var{TARRAY} with the numerical values at the
4894 current local time. The day (in the range 1-31), month (in the range 1-12),
4895 and year appear in elements 1, 2, and 3 of @var{TARRAY}, respectively.
4896 The year has four significant digits.
4898 @item @emph{Standard}:
4904 @item @emph{Syntax}:
4905 @code{CALL IDATE(TARRAY)}
4907 @item @emph{Arguments}:
4908 @multitable @columnfractions .15 .70
4909 @item @var{TARRAY} @tab The type shall be @code{INTEGER, DIMENSION(3)} and
4910 the kind shall be the default integer kind.
4913 @item @emph{Return value}:
4916 @item @emph{Example}:
4919 integer, dimension(3) :: tarray
4924 end program test_idate
4931 @section @code{IEOR} --- Bitwise logical exclusive or
4932 @cindex @code{IEOR} intrinsic
4933 @cindex bit operations
4936 @item @emph{Description}:
4937 @code{IEOR} returns the bitwise boolean exclusive-OR of @var{I} and
4940 @item @emph{Standard}:
4946 @item @emph{Syntax}:
4947 @code{RESULT = IEOR(I, J)}
4949 @item @emph{Arguments}:
4950 @multitable @columnfractions .15 .70
4951 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
4952 @item @var{J} @tab The type shall be @code{INTEGER(*)}, of the same
4953 kind as @var{I}. (As a GNU extension, different kinds are also
4957 @item @emph{Return value}:
4958 The return type is @code{INTEGER(*)}, of the same kind as the
4959 arguments. (If the argument kinds differ, it is of the same kind as
4960 the larger argument.)
4962 @item @emph{See also}:
4963 @ref{IOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
4969 @section @code{IERRNO} --- Get the last system error number
4970 @cindex @code{IERRNO} intrinsic
4973 @item @emph{Description}:
4974 Returns the last system error number, as given by the C @code{errno()}
4977 @item @emph{Standard}:
4983 @item @emph{Syntax}:
4984 @code{RESULT = IERRNO()}
4986 @item @emph{Arguments}:
4989 @item @emph{Return value}:
4990 The return value is of type @code{INTEGER} and of the default integer
4993 @item @emph{See also}:
5000 @section @code{INDEX} --- Position of a substring within a string
5001 @cindex @code{INDEX} intrinsic
5004 @item @emph{Description}:
5005 Returns the position of the start of the first occurrence of string
5006 @var{SUBSTRING} as a substring in @var{STRING}, counting from one. If
5007 @var{SUBSTRING} is not present in @var{STRING}, zero is returned. If
5008 the @var{BACK} argument is present and true, the return value is the
5009 start of the last occurrence rather than the first.
5011 @item @emph{Standard}:
5017 @item @emph{Syntax}:
5018 @code{RESULT = INDEX(STRING, SUBSTRING [, BACK])}
5020 @item @emph{Arguments}:
5021 @multitable @columnfractions .15 .70
5022 @item @var{STRING} @tab Shall be a scalar @code{CHARACTER(*)}, with
5024 @item @var{SUBSTRING} @tab Shall be a scalar @code{CHARACTER(*)}, with
5026 @item @var{BACK} @tab (Optional) Shall be a scalar @code{LOGICAL(*)}, with
5030 @item @emph{Return value}:
5031 The return value is of type @code{INTEGER} and of the default integer
5034 @item @emph{See also}:
5040 @section @code{INT} --- Convert to integer type
5041 @cindex @code{INT} intrinsic
5042 @cindex @code{IFIX} intrinsic
5043 @cindex @code{IDINT} intrinsic
5044 @cindex conversion function (integer)
5047 @item @emph{Description}:
5048 Convert to integer type
5050 @item @emph{Standard}:
5056 @item @emph{Syntax}:
5057 @item @code{RESULT = INT(X [, KIND))}
5059 @item @emph{Arguments}:
5060 @multitable @columnfractions .15 .70
5061 @item @var{X} @tab shall be of type @code{INTEGER(*)},
5062 @code{REAL(*)}, or @code{COMPLEX(*)}.
5063 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
5064 expression indicating the kind parameter of
5068 @item @emph{Return value}:
5069 These functions return a @code{INTEGER(*)} variable or array under
5070 the following rules:
5074 If @var{X} is of type @code{INTEGER(*)}, @code{INT(X) = X}
5076 If @var{X} is of type @code{REAL(*)} and @math{|X| < 1}, @code{INT(X)} equals @var{0}.
5077 If @math{|X| \geq 1}, then @code{INT(X)} equals the largest integer that does not exceed
5078 the range of @var{X} and whose sign is the same as the sign of @var{X}.
5080 If @var{X} is of type @code{COMPLEX(*)}, rule B is applied to the real part of X.
5083 @item @emph{Example}:
5087 complex :: z = (-3.7, 1.0)
5089 print *, int(z), int(z,8)
5093 @item @emph{Specific names}:
5094 @multitable @columnfractions .20 .20 .20 .25
5095 @item Name @tab Argument @tab Return type @tab Standard
5096 @item @code{IFIX(X)} @tab @code{REAL(4) X} @tab @code{INTEGER} @tab F77 and later
5097 @item @code{IDINT(X)} @tab @code{REAL(8) X} @tab @code{INTEGER} @tab F77 and later
5100 @comment @item @emph{See also}:
5106 @section @code{IOR} --- Bitwise logical or
5107 @cindex @code{IOR} intrinsic
5108 @cindex bit operations
5111 @item @emph{Description}:
5112 @code{IEOR} returns the bitwise boolean OR of @var{I} and
5115 @item @emph{Standard}:
5121 @item @emph{Syntax}:
5122 @code{RESULT = IEOR(I, J)}
5124 @item @emph{Arguments}:
5125 @multitable @columnfractions .15 .70
5126 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
5127 @item @var{J} @tab The type shall be @code{INTEGER(*)}, of the same
5128 kind as @var{I}. (As a GNU extension, different kinds are also
5132 @item @emph{Return value}:
5133 The return type is @code{INTEGER(*)}, of the same kind as the
5134 arguments. (If the argument kinds differ, it is of the same kind as
5135 the larger argument.)
5137 @item @emph{See also}:
5138 @ref{IEOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
5145 @section @code{IRAND} --- Integer pseudo-random number
5146 @cindex @code{IRAND} intrinsic
5147 @cindex random numbers
5150 @item @emph{Description}:
5151 @code{IRAND(FLAG)} returns a pseudo-random number from a uniform
5152 distribution between 0 and a system-dependent limit (which is in most
5153 cases 2147483647). If @var{FLAG} is 0, the next number
5154 in the current sequence is returned; if @var{FLAG} is 1, the generator
5155 is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
5156 it is used as a new seed with @code{SRAND}.
5158 @item @emph{Standard}:
5162 Non-elemental function
5164 @item @emph{Syntax}:
5165 @code{RESULT = IRAND(FLAG)}
5167 @item @emph{Arguments}:
5168 @multitable @columnfractions .15 .70
5169 @item @var{FLAG} @tab shall be a scalar @code{INTEGER} of kind 4.
5172 @item @emph{Return value}:
5173 The return value is of @code{INTEGER(kind=4)} type.
5175 @item @emph{Example}:
5178 integer,parameter :: seed = 86456
5181 print *, irand(), irand(), irand(), irand()
5182 print *, irand(seed), irand(), irand(), irand()
5183 end program test_irand
5191 @section @code{ISATTY} --- Whether a unit is a terminal device.
5192 @cindex @code{ISATTY} intrinsic
5195 @item @emph{Description}:
5196 Determine whether a unit is connected to a terminal device.
5198 @item @emph{Standard}:
5202 Non-elemental function.
5204 @item @emph{Syntax}:
5205 @code{RESULT = ISATTY(UNIT)}
5207 @item @emph{Arguments}:
5208 @multitable @columnfractions .15 .70
5209 @item @var{UNIT} @tab Shall be a scalar @code{INTEGER(*)}.
5212 @item @emph{Return value}:
5213 Returns @code{.TRUE.} if the @var{UNIT} is connected to a terminal
5214 device, @code{.FALSE.} otherwise.
5216 @item @emph{Example}:
5219 INTEGER(kind=1) :: unit
5221 write(*,*) isatty(unit=unit)
5225 @item @emph{See also}:
5233 @section @code{ISHFT} --- Shift bits
5234 @cindex @code{ISHFT} intrinsic
5235 @cindex bit operations
5238 @item @emph{Description}:
5239 @code{ISHFT} returns a value corresponding to @var{I} with all of the
5240 bits shifted @var{SHIFT} places. A value of @var{SHIFT} greater than
5241 zero corresponds to a left shift, a value of zero corresponds to no
5242 shift, and a value less than zero corresponds to a right shift. If the
5243 absolute value of @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the
5244 value is undefined. Bits shifted out from the left end or right end are
5245 lost; zeros are shifted in from the opposite end.
5247 @item @emph{Standard}:
5253 @item @emph{Syntax}:
5254 @code{RESULT = ISHFT(I, SHIFT)}
5256 @item @emph{Arguments}:
5257 @multitable @columnfractions .15 .70
5258 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
5259 @item @var{SHIFT} @tab The type shall be @code{INTEGER(*)}.
5262 @item @emph{Return value}:
5263 The return value is of type @code{INTEGER(*)} and of the same kind as
5266 @item @emph{See also}:
5274 @section @code{ISHFTC} --- Shift bits circularly
5275 @cindex @code{ISHFTC} intrinsic
5276 @cindex bit operations
5279 @item @emph{Description}:
5280 @code{ISHFTC} returns a value corresponding to @var{I} with the
5281 rightmost @var{SIZE} bits shifted circularly @var{SHIFT} places; that
5282 is, bits shifted out one end are shifted into the opposite end. A value
5283 of @var{SHIFT} greater than zero corresponds to a left shift, a value of
5284 zero corresponds to no shift, and a value less than zero corresponds to
5285 a right shift. The absolute value of @var{SHIFT} must be less than
5286 @var{SIZE}. If the @var{SIZE} argument is omitted, it is taken to be
5287 equivalent to @code{BIT_SIZE(I)}.
5289 @item @emph{Standard}:
5295 @item @emph{Syntax}:
5296 @code{RESULT = ISHFTC(I, SHIFT [, SIZE])}
5298 @item @emph{Arguments}:
5299 @multitable @columnfractions .15 .70
5300 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
5301 @item @var{SHIFT} @tab The type shall be @code{INTEGER(*)}.
5302 @item @var{SIZE} @tab (Optional) The type shall be @code{INTEGER(*)};
5303 the value must be greater than zero and less than or equal to
5307 @item @emph{Return value}:
5308 The return value is of type @code{INTEGER(*)} and of the same kind as
5311 @item @emph{See also}:
5318 @section @code{ITIME} --- Get current local time subroutine (hour/minutes/seconds)
5319 @cindex @code{ITIME} intrinsic
5322 @item @emph{Description}:
5323 @code{IDATE(TARRAY)} Fills @var{TARRAY} with the numerical values at the
5324 current local time. The hour (in the range 1-24), minute (in the range 1-60),
5325 and seconds (in the range 1-60) appear in elements 1, 2, and 3 of @var{TARRAY},
5328 @item @emph{Standard}:
5334 @item @emph{Syntax}:
5335 @code{CALL ITIME(TARRAY)}
5337 @item @emph{Arguments}:
5338 @multitable @columnfractions .15 .70
5339 @item @var{TARRAY} @tab The type shall be @code{INTEGER, DIMENSION(3)}
5340 and the kind shall be the default integer kind.
5343 @item @emph{Return value}:
5347 @item @emph{Example}:
5350 integer, dimension(3) :: tarray
5355 end program test_itime
5362 @section @code{KILL} --- Send a signal to a process
5363 @cindex @code{KILL} intrinsic
5366 @item @emph{Description}:
5367 @item @emph{Standard}:
5368 Sends the signal specified by @var{SIGNAL} to the process @var{PID}.
5374 @item @emph{Syntax}:
5375 @code{CALL KILL(PID, SIGNAL [, STATUS])}
5377 @item @emph{Arguments}:
5378 @multitable @columnfractions .15 .70
5379 @item @var{PID} @tab Shall be a scalar @code{INTEGER}, with
5381 @item @var{SIGNAL} @tab Shall be a scalar @code{INTEGER}, with
5383 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)} or
5384 @code{INTEGER(8)}. Returns 0 on success, or a
5385 system-specific error code otherwise.
5388 @item @emph{See also}:
5389 @ref{ABORT}, @ref{EXIT}
5395 @section @code{KIND} --- Kind of an entity
5396 @cindex @code{KIND} intrinsic
5399 @item @emph{Description}:
5400 @code{KIND(X)} returns the kind value of the entity @var{X}.
5402 @item @emph{Standard}:
5408 @item @emph{Syntax}:
5411 @item @emph{Arguments}:
5412 @multitable @columnfractions .15 .70
5413 @item @var{X} @tab Shall be of type @code{LOGICAL}, @code{INTEGER},
5414 @code{REAL}, @code{COMPLEX} or @code{CHARACTER}.
5417 @item @emph{Return value}:
5418 The return value is a scalar of type @code{INTEGER} and of the default
5421 @item @emph{Example}:
5424 integer,parameter :: kc = kind(' ')
5425 integer,parameter :: kl = kind(.true.)
5427 print *, "The default character kind is ", kc
5428 print *, "The default logical kind is ", kl
5429 end program test_kind
5437 @section @code{LBOUND} --- Lower dimension bounds of an array
5438 @cindex @code{LBOUND} intrinsic
5441 @item @emph{Description}:
5442 Returns the lower bounds of an array, or a single lower bound
5443 along the @var{DIM} dimension.
5444 @item @emph{Standard}:
5450 @item @emph{Syntax}:
5451 @code{RESULT = LBOUND(ARRAY [, DIM])}
5453 @item @emph{Arguments}:
5454 @multitable @columnfractions .15 .70
5455 @item @var{ARRAY} @tab Shall be an array, of any type.
5456 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER(*)}.
5459 @item @emph{Return value}:
5460 If @var{DIM} is absent, the result is an array of the lower bounds of
5461 @var{ARRAY}. If @var{DIM} is present, the result is a scalar
5462 corresponding to the lower bound of the array along that dimension. If
5463 @var{ARRAY} is an expression rather than a whole array or array
5464 structure component, or if it has a zero extent along the relevant
5465 dimension, the lower bound is taken to be 1.
5467 @item @emph{See also}:
5474 @section @code{LEN} --- Length of a character entity
5475 @cindex @code{LEN} intrinsic
5478 @item @emph{Description}:
5479 Returns the length of a character string. If @var{STRING} is an array,
5480 the length of an element of @var{STRING} is returned. Note that
5481 @var{STRING} need not be defined when this intrinsic is invoked, since
5482 only the length, not the content, of @var{STRING} is needed.
5484 @item @emph{Standard}:
5490 @item @emph{Syntax}:
5491 @code{L = LEN(STRING)}
5493 @item @emph{Arguments}:
5494 @multitable @columnfractions .15 .70
5495 @item @var{STRING} @tab Shall be a scalar or array of type
5496 @code{CHARACTER(*)}, with @code{INTENT(IN)}
5499 @item @emph{Return value}:
5500 The return value is an @code{INTEGER} of the default kind.
5502 @item @emph{See also}:
5503 @ref{LEN_TRIM}, @ref{ADJUSTL}, @ref{ADJUSTR}
5509 @section @code{LEN_TRIM} --- Length of a character entity without trailing blank characters
5510 @cindex @code{LEN_TRIM} intrinsic
5513 @item @emph{Description}:
5514 Returns the length of a character string, ignoring any trailing blanks.
5516 @item @emph{Standard}:
5522 @item @emph{Syntax}:
5523 @code{RESULT = LEN_TRIM(STRING)}
5525 @item @emph{Arguments}:
5526 @multitable @columnfractions .15 .70
5527 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER(*)},
5528 with @code{INTENT(IN)}
5531 @item @emph{Return value}:
5532 The return value is an @code{INTEGER} of the default kind.
5534 @item @emph{See also}:
5535 @ref{LEN}, @ref{ADJUSTL}, @ref{ADJUSTR}
5541 @section @code{LGE} --- Lexical greater than or equal
5542 @cindex @code{LGE} intrinsic
5543 @cindex comparison (lexical)
5544 @cindex lexical comparison
5547 @item @emph{Description}:
5548 Determines whether one string is lexically greater than or equal to
5549 another string, where the two strings are interpreted as containing
5550 ASCII character codes. If the String A and String B are not the same
5551 length, the shorter is compared as if spaces were appended to it to form
5552 a value that has the same length as the longer.
5554 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
5555 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
5556 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
5557 that the latter use the processor's character ordering (which is not
5558 ASCII on some targets), whereas the former always use the ASCII
5561 @item @emph{Standard}:
5567 @item @emph{Syntax}:
5568 @code{RESULT = LGE(STRING_A, STRING_B)}
5570 @item @emph{Arguments}:
5571 @multitable @columnfractions .15 .70
5572 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
5573 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
5576 @item @emph{Return value}:
5577 Returns @code{.TRUE.} if @code{STRING_A >= STRING_B}, and @code{.FALSE.}
5578 otherwise, based on the ASCII ordering.
5580 @item @emph{See also}:
5581 @ref{LGT}, @ref{LLE}, @ref{LLT}
5587 @section @code{LGT} --- Lexical greater than
5588 @cindex @code{LGT} intrinsic
5589 @cindex comparison (lexical)
5590 @cindex lexical comparison
5593 @item @emph{Description}:
5594 Determines whether one string is lexically greater than another string,
5595 where the two strings are interpreted as containing ASCII character
5596 codes. If the String A and String B are not the same length, the
5597 shorter is compared as if spaces were appended to it to form a value
5598 that has the same length as the longer.
5600 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
5601 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
5602 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
5603 that the latter use the processor's character ordering (which is not
5604 ASCII on some targets), whereas the former always use the ASCII
5607 @item @emph{Standard}:
5613 @item @emph{Syntax}:
5614 @code{RESULT = LGT(STRING_A, STRING_B)}
5616 @item @emph{Arguments}:
5617 @multitable @columnfractions .15 .70
5618 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
5619 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
5622 @item @emph{Return value}:
5623 Returns @code{.TRUE.} if @code{STRING_A > STRING_B}, and @code{.FALSE.}
5624 otherwise, based on the ASCII ordering.
5626 @item @emph{See also}:
5627 @ref{LGE}, @ref{LLE}, @ref{LLT}
5633 @section @code{LINK} --- Create a hard link
5634 @cindex @code{LINK} intrinsic
5635 @cindex file system operations
5638 @item @emph{Description}:
5639 Makes a (hard) link from file @var{PATH1} to @var{PATH2}. A null
5640 character (@code{CHAR(0)}) can be used to mark the end of the names in
5641 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
5642 names are ignored. If the @var{STATUS} argument is supplied, it
5643 contains 0 on success or a nonzero error code upon return; see
5646 @item @emph{Standard}:
5652 @item @emph{Syntax}:
5653 @code{CALL LINK(PATH1, PATH2 [, STATUS])}
5655 @item @emph{Arguments}:
5656 @multitable @columnfractions .15 .70
5657 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
5658 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
5659 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
5662 @item @emph{See also}:
5663 @ref{SYMLNK}, @ref{UNLINK}
5669 @section @code{LLE} --- Lexical less than or equal
5670 @cindex @code{LLE} intrinsic
5671 @cindex comparison (lexical)
5672 @cindex lexical comparison
5675 @item @emph{Description}:
5676 Determines whether one string is lexically less than or equal to another
5677 string, where the two strings are interpreted as containing ASCII
5678 character codes. If the String A and String B are not the same length,
5679 the shorter is compared as if spaces were appended to it to form a value
5680 that has the same length as the longer.
5682 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
5683 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
5684 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
5685 that the latter use the processor's character ordering (which is not
5686 ASCII on some targets), whereas the former always use the ASCII
5689 @item @emph{Standard}:
5695 @item @emph{Syntax}:
5696 @code{RESULT = LLE(STRING_A, STRING_B)}
5698 @item @emph{Arguments}:
5699 @multitable @columnfractions .15 .70
5700 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
5701 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
5704 @item @emph{Return value}:
5705 Returns @code{.TRUE.} if @code{STRING_A <= STRING_B}, and @code{.FALSE.}
5706 otherwise, based on the ASCII ordering.
5708 @item @emph{See also}:
5709 @ref{LGE}, @ref{LGT}, @ref{LLT}
5715 @section @code{LLT} --- Lexical less than
5716 @cindex @code{LLT} intrinsic
5717 @cindex comparison (lexical)
5718 @cindex lexical comparison
5721 @item @emph{Description}:
5722 Determines whether one string is lexically less than another string,
5723 where the two strings are interpreted as containing ASCII character
5724 codes. If the String A and String B are not the same length, the
5725 shorter is compared as if spaces were appended to it to form a value
5726 that has the same length as the longer.
5728 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
5729 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
5730 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
5731 that the latter use the processor's character ordering (which is not
5732 ASCII on some targets), whereas the former always use the ASCII
5735 @item @emph{Standard}:
5741 @item @emph{Syntax}:
5742 @code{RESULT = LLT(STRING_A, STRING_B)}
5744 @item @emph{Arguments}:
5745 @multitable @columnfractions .15 .70
5746 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
5747 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
5750 @item @emph{Return value}:
5751 Returns @code{.TRUE.} if @code{STRING_A < STRING_B}, and @code{.FALSE.}
5752 otherwise, based on the ASCII ordering.
5754 @item @emph{See also}:
5755 @ref{LGE}, @ref{LGT}, @ref{LLE}
5761 @section @code{LNBLNK} --- Index of the last non-blank character in a string
5762 @cindex @code{LNBLNK} intrinsic
5765 @item @emph{Description}:
5766 Returns the length of a character string, ignoring any trailing blanks.
5767 This is identical to the standard @code{LEN_TRIM} intrinsic, and is only
5768 included for backwards compatibility.
5770 @item @emph{Standard}:
5776 @item @emph{Syntax}:
5777 @code{RESULT = LNBLNK(STRING)}
5779 @item @emph{Arguments}:
5780 @multitable @columnfractions .15 .70
5781 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER(*)},
5782 with @code{INTENT(IN)}
5785 @item @emph{Return value}:
5786 The return value is of @code{INTEGER(kind=4)} type.
5788 @item @emph{See also}:
5789 @ref{INDEX}, @ref{LEN_TRIM}
5795 @section @code{LOC} --- Returns the address of a variable
5796 @cindex @code{LOC} intrinsic
5797 @cindex location of a variable in memory
5800 @item @emph{Description}:
5801 @code{LOC(X)} returns the address of @var{X} as an integer.
5803 @item @emph{Standard}:
5809 @item @emph{Syntax}:
5810 @code{RESULT = LOC(X)}
5812 @item @emph{Arguments}:
5813 @multitable @columnfractions .15 .70
5814 @item @var{X} @tab Variable of any type.
5817 @item @emph{Return value}:
5818 The return value is of type @code{INTEGER}, with a @code{KIND}
5819 corresponding to the size (in bytes) of a memory address on the target
5822 @item @emph{Example}:
5829 end program test_loc
5836 @section @code{LOG} --- Logarithm function
5837 @cindex @code{LOG} intrinsic
5838 @cindex @code{ALOG} intrinsic
5839 @cindex @code{DLOG} intrinsic
5840 @cindex @code{CLOG} intrinsic
5841 @cindex @code{ZLOG} intrinsic
5842 @cindex @code{CDLOG} intrinsic
5846 @item @emph{Description}:
5847 @code{LOG(X)} computes the logarithm of @var{X}.
5849 @item @emph{Standard}:
5855 @item @emph{Syntax}:
5856 @code{RESULT = LOG(X)}
5858 @item @emph{Arguments}:
5859 @multitable @columnfractions .15 .70
5860 @item @var{X} @tab The type shall be @code{REAL(*)} or
5864 @item @emph{Return value}:
5865 The return value is of type @code{REAL(*)} or @code{COMPLEX(*)}.
5866 The kind type parameter is the same as @var{X}.
5868 @item @emph{Example}:
5871 real(8) :: x = 1.0_8
5872 complex :: z = (1.0, 2.0)
5875 end program test_log
5878 @item @emph{Specific names}:
5879 @multitable @columnfractions .20 .20 .20 .25
5880 @item Name @tab Argument @tab Return type @tab Standard
5881 @item @code{ALOG(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab f95, gnu
5882 @item @code{DLOG(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
5883 @item @code{CLOG(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab f95, gnu
5884 @item @code{ZLOG(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
5885 @item @code{CDLOG(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
5892 @section @code{LOG10} --- Base 10 logarithm function
5893 @cindex @code{LOG10} intrinsic
5894 @cindex @code{ALOG10} intrinsic
5895 @cindex @code{DLOG10} intrinsic
5899 @item @emph{Description}:
5900 @code{LOG10(X)} computes the base 10 logarithm of @var{X}.
5902 @item @emph{Standard}:
5908 @item @emph{Syntax}:
5909 @code{RESULT = LOG10(X)}
5911 @item @emph{Arguments}:
5912 @multitable @columnfractions .15 .70
5913 @item @var{X} @tab The type shall be @code{REAL(*)} or
5917 @item @emph{Return value}:
5918 The return value is of type @code{REAL(*)} or @code{COMPLEX(*)}.
5919 The kind type parameter is the same as @var{X}.
5921 @item @emph{Example}:
5924 real(8) :: x = 10.0_8
5926 end program test_log10
5929 @item @emph{Specific names}:
5930 @multitable @columnfractions .20 .20 .20 .25
5931 @item Name @tab Argument @tab Return type @tab Standard
5932 @item @code{ALOG10(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab F95 and later
5933 @item @code{DLOG10(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
5940 @section @code{LOGICAL} --- Convert to logical type
5941 @cindex @code{LOGICAL} intrinsic
5942 @cindex conversion function (logical)
5945 @item @emph{Description}:
5946 Converts one kind of @code{LOGICAL} variable to another.
5948 @item @emph{Standard}:
5954 @item @emph{Syntax}:
5955 @code{RESULT = LOGICAL(L [, KIND])}
5957 @item @emph{Arguments}:
5958 @multitable @columnfractions .15 .70
5959 @item @var{L} @tab The type shall be @code{LOGICAL(*)}.
5960 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
5961 expression indicating the kind parameter of
5965 @item @emph{Return value}:
5966 The return value is a @code{LOGICAL} value equal to @var{L}, with a
5967 kind corresponding to @var{KIND}, or of the default logical kind if
5968 @var{KIND} is not given.
5970 @item @emph{See also}:
5971 @ref{INT}, @ref{REAL}, @ref{CMPLX}
5978 @section @code{LSHIFT} --- Left shift bits
5979 @cindex @code{LSHIFT} intrinsic
5980 @cindex bit operations
5983 @item @emph{Description}:
5984 @code{LSHIFT} returns a value corresponding to @var{I} with all of the
5985 bits shifted left by @var{SHIFT} places. If the absolute value of
5986 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
5987 Bits shifted out from the left end are lost; zeros are shifted in from
5990 This function has been superseded by the @code{ISHFT} intrinsic, which
5991 is standard in Fortran 95 and later.
5993 @item @emph{Standard}:
5999 @item @emph{Syntax}:
6000 @code{RESULT = LSHIFT(I, SHIFT)}
6002 @item @emph{Arguments}:
6003 @multitable @columnfractions .15 .70
6004 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
6005 @item @var{SHIFT} @tab The type shall be @code{INTEGER(*)}.
6008 @item @emph{Return value}:
6009 The return value is of type @code{INTEGER(*)} and of the same kind as
6012 @item @emph{See also}:
6013 @ref{ISHFT}, @ref{ISHFTC}, @ref{RSHIFT}
6019 @section @code{LSTAT} --- Get file status
6020 @cindex @code{LSTAT} intrinsic
6021 @cindex file system operations
6024 @item @emph{Description}:
6025 @code{LSTAT} is identical to @ref{STAT}, except that if path is a symbolic link,
6026 then the link itself is statted, not the file that it refers to.
6028 The elements in @code{BUFF} are the same as described by @ref{STAT}.
6030 @item @emph{Standard}:
6034 Non-elemental subroutine
6036 @item @emph{Syntax}:
6037 @code{CALL LSTAT(FILE, BUFF [, STATUS])}
6039 @item @emph{Arguments}:
6040 @multitable @columnfractions .15 .70
6041 @item @var{FILE} @tab The type shall be @code{CHARACTER(*)}, a valid path within the file system.
6042 @item @var{BUFF} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
6043 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0
6044 on success and a system specific error code otherwise.
6047 @item @emph{Example}:
6048 See @ref{STAT} for an example.
6050 @item @emph{See also}:
6051 To stat an open file: @ref{FSTAT}, to stat a file: @ref{STAT}
6057 @section @code{LTIME} --- Convert time to local time info
6058 @cindex @code{LTIME} intrinsic
6059 @cindex time, conversion function
6062 @item @emph{Description}:
6063 Given a system time value @var{STIME} (as provided by the @code{TIME8()}
6064 intrinsic), fills @var{TARRAY} with values extracted from it appropriate
6065 to the local time zone using @code{localtime(3)}.
6067 @item @emph{Standard}:
6073 @item @emph{Syntax}:
6074 @code{CALL LTIME(STIME, TARRAY)}
6076 @item @emph{Arguments}:
6077 @multitable @columnfractions .15 .70
6078 @item @var{STIME} @tab An @code{INTEGER(*)} scalar expression
6079 corresponding to a system time, with
6081 @item @var{TARRAY} @tab A default @code{INTEGER} array with 9 elements,
6082 with @code{INTENT(OUT)}.
6085 @item @emph{Return value}:
6086 The elements of @var{TARRAY} are assigned as follows:
6088 @item Seconds after the minute, range 0--59 or 0--61 to allow for leap
6090 @item Minutes after the hour, range 0--59
6091 @item Hours past midnight, range 0--23
6092 @item Day of month, range 0--31
6093 @item Number of months since January, range 0--12
6094 @item Years since 1900
6095 @item Number of days since Sunday, range 0--6
6096 @item Days since January 1
6097 @item Daylight savings indicator: positive if daylight savings is in
6098 effect, zero if not, and negative if the information is not
6102 @item @emph{See also}:
6103 @ref{CTIME}, @ref{GMTIME}, @ref{TIME}, @ref{TIME8}
6110 @section @code{MALLOC} --- Allocate dynamic memory
6111 @cindex @code{MALLOC} intrinsic
6112 @cindex Cray pointers
6115 @item @emph{Description}:
6116 @code{MALLOC(SIZE)} allocates @var{SIZE} bytes of dynamic memory and
6117 returns the address of the allocated memory. The @code{MALLOC} intrinsic
6118 is an extension intended to be used with Cray pointers, and is provided
6119 in GNU Fortran to allow the user to compile legacy code. For new code
6120 using Fortran 95 pointers, the memory allocation intrinsic is
6123 @item @emph{Standard}:
6127 Non-elemental function
6129 @item @emph{Syntax}:
6130 @code{PTR = MALLOC(SIZE)}
6132 @item @emph{Arguments}:
6133 @multitable @columnfractions .15 .70
6134 @item @var{SIZE} @tab The type shall be @code{INTEGER(*)}.
6137 @item @emph{Return value}:
6138 The return value is of type @code{INTEGER(K)}, with @var{K} such that
6139 variables of type @code{INTEGER(K)} have the same size as
6140 C pointers (@code{sizeof(void *)}).
6142 @item @emph{Example}:
6143 The following example demonstrates the use of @code{MALLOC} and
6144 @code{FREE} with Cray pointers. This example is intended to run on
6145 32-bit systems, where the default integer kind is suitable to store
6146 pointers; on 64-bit systems, ptr_x would need to be declared as
6147 @code{integer(kind=8)}.
6156 ptr_x = malloc(20*8)
6158 x(i) = sqrt(1.0d0 / i)
6166 end program test_malloc
6169 @item @emph{See also}:
6176 @section @code{MATMUL} --- matrix multiplication
6177 @cindex @code{MATMUL} intrinsic
6178 @cindex matrix operations
6181 @item @emph{Description}:
6182 Performs a matrix multiplication on numeric or logical arguments.
6184 @item @emph{Standard}:
6188 Transformational function
6190 @item @emph{Syntax}:
6191 @code{RESULT = MATMUL(MATRIX_A, MATRIX_B)}
6193 @item @emph{Arguments}:
6194 @multitable @columnfractions .15 .70
6195 @item @var{MATRIX_A} @tab An array of @code{INTEGER(*)},
6196 @code{REAL(*)}, @code{COMPLEX(*)}, or
6197 @code{LOGICAL(*)} type, with a rank of
6199 @item @var{MATRIX_B} @tab An array of @code{INTEGER(*)},
6200 @code{REAL(*)}, or @code{COMPLEX(*)} type if
6201 @var{MATRIX_A} is of a numeric type;
6202 otherwise, an array of @code{LOGICAL(*)}
6203 type. The rank shall be one or two, and the
6204 first (or only) dimension of @var{MATRIX_B}
6205 shall be equal to the last (or only)
6206 dimension of @var{MATRIX_A}.
6209 @item @emph{Return value}:
6210 The matrix product of @var{MATRIX_A} and @var{MATRIX_B}. The type and
6211 kind of the result follow the usual type and kind promotion rules, as
6212 for the @code{*} or @code{.AND.} operators.
6214 @item @emph{See also}:
6220 @section @code{MAX} --- Maximum value of an argument list
6221 @cindex @code{MAX} intrinsic
6224 @item @emph{Description}:
6225 Returns the argument with the largest (most positive) value.
6227 @item @emph{Standard}:
6233 @item @emph{Syntax}:
6234 @code{RESULT = MAX(A1, A2 [, A3 [, ...]])}
6236 @item @emph{Arguments}:
6237 @multitable @columnfractions .15 .70
6238 @item @var{A1} @tab The type shall be @code{INTEGER(*)} or
6240 @item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
6241 as @var{A1}. (As a GNU extension,
6242 arguments of different kinds are
6246 @item @emph{Return value}:
6247 The return value corresponds to the maximum value among the arguments,
6248 and has the same type and kind as the first argument.
6250 @item @emph{Specific names}:
6251 @multitable @columnfractions .20 .20 .20 .25
6252 @item Name @tab Argument @tab Return type @tab Standard
6253 @item @code{MAX0(I)} @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)} @tab F77 and later
6254 @item @code{AMAX0(I)} @tab @code{INTEGER(4) I} @tab @code{REAL(MAX(X))} @tab F77 and later
6255 @item @code{MAX1(X)} @tab @code{REAL(*) X} @tab @code{INT(MAX(X))} @tab F77 and later
6256 @item @code{AMAX1(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab F77 and later
6257 @item @code{DMAX1(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
6260 @item @emph{See also}:
6261 @ref{MAXLOC} @ref{MAXVAL}, @ref{MIN}
6268 @section @code{MAXEXPONENT} --- Maximum exponent of a real kind
6269 @cindex @code{MAXEXPONENT} intrinsic
6270 @cindex maximum exponent
6271 @cindex exponent, maximum
6274 @item @emph{Description}:
6275 @code{MAXEXPONENT(X)} returns the maximum exponent in the model of the
6278 @item @emph{Standard}:
6284 @item @emph{Syntax}:
6285 @code{RESULT = MAXEXPONENT(X)}
6287 @item @emph{Arguments}:
6288 @multitable @columnfractions .15 .70
6289 @item @var{X} @tab shall be of type @code{REAL}.
6292 @item @emph{Return value}:
6293 The return value is of type @code{INTEGER} and of the default integer
6296 @item @emph{Example}:
6302 print *, minexponent(x), maxexponent(x)
6303 print *, minexponent(y), maxexponent(y)
6304 end program exponents
6311 @section @code{MAXLOC} --- Location of the maximum value within an array
6312 @cindex @code{MAXLOC} intrinsic
6315 @item @emph{Description}:
6316 Determines the location of the element in the array with the maximum
6317 value, or, if the @var{DIM} argument is supplied, determines the
6318 locations of the maximum element along each row of the array in the
6319 @var{DIM} direction. If @var{MASK} is present, only the elements for
6320 which @var{MASK} is @code{.TRUE.} are considered. If more than one
6321 element in the array has the maximum value, the location returned is
6322 that of the first such element in array element order. If the array has
6323 zero size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
6324 the result is an array of zeroes. Similarly, if @var{DIM} is supplied
6325 and all of the elements of @var{MASK} along a given row are zero, the
6326 result value for that row is zero.
6328 @item @emph{Standard}:
6332 Transformational function
6334 @item @emph{Syntax}:
6335 @multitable @columnfractions .80
6336 @item @code{RESULT = MAXLOC(ARRAY, DIM [, MASK])}
6337 @item @code{RESULT = MAXLOC(ARRAY [, MASK])}
6340 @item @emph{Arguments}:
6341 @multitable @columnfractions .15 .70
6342 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER(*)},
6343 @code{REAL(*)}, or @code{CHARACTER(*)}.
6344 @item @var{DIM} @tab (Optional) Shall be a scalar of type
6345 @code{INTEGER(*)}, with a value between one
6346 and the rank of @var{ARRAY}, inclusive. It
6347 may not be an optional dummy argument.
6348 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL(*)},
6349 and conformable with @var{ARRAY}.
6352 @item @emph{Return value}:
6353 If @var{DIM} is absent, the result is a rank-one array with a length
6354 equal to the rank of @var{ARRAY}. If @var{DIM} is present, the result
6355 is an array with a rank one less than the rank of @var{ARRAY}, and a
6356 size corresponding to the size of @var{ARRAY} with the @var{DIM}
6357 dimension removed. If @var{DIM} is present and @var{ARRAY} has a rank
6358 of one, the result is a scalar. In all cases, the result is of default
6359 @code{INTEGER} type.
6361 @item @emph{See also}:
6362 @ref{MAX}, @ref{MAXVAL}
6369 @section @code{MAXVAL} --- Maximum value of an array
6370 @cindex @code{MAXVAL} intrinsic
6373 @item @emph{Description}:
6374 Determines the maximum value of the elements in an array value, or, if
6375 the @var{DIM} argument is supplied, determines the maximum value along
6376 each row of the array in the @var{DIM} direction. If @var{MASK} is
6377 present, only the elements for which @var{MASK} is @code{.TRUE.} are
6378 considered. If the array has zero size, or all of the elements of
6379 @var{MASK} are @code{.FALSE.}, then the result is the most negative
6380 number of the type and kind of @var{ARRAY} if @var{ARRAY} is numeric, or
6381 a string of nulls if @var{ARRAY} is of character type.
6383 @item @emph{Standard}:
6387 Transformational function
6389 @item @emph{Syntax}:
6390 @multitable @columnfractions .80
6391 @item @code{RESULT = MAXVAL(ARRAY, DIM [, MASK])}
6392 @item @code{RESULT = MAXVAL(ARRAY [, MASK])}
6395 @item @emph{Arguments}:
6396 @multitable @columnfractions .15 .70
6397 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER(*)},
6398 @code{REAL(*)}, or @code{CHARACTER(*)}.
6399 @item @var{DIM} @tab (Optional) Shall be a scalar of type
6400 @code{INTEGER(*)}, with a value between one
6401 and the rank of @var{ARRAY}, inclusive. It
6402 may not be an optional dummy argument.
6403 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL(*)},
6404 and conformable with @var{ARRAY}.
6407 @item @emph{Return value}:
6408 If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
6409 is a scalar. If @var{DIM} is present, the result is an array with a
6410 rank one less than the rank of @var{ARRAY}, and a size corresponding to
6411 the size of @var{ARRAY} with the @var{DIM} dimension removed. In all
6412 cases, the result is of the same type and kind as @var{ARRAY}.
6414 @item @emph{See also}:
6415 @ref{MAX}, @ref{MAXLOC}
6421 @section @code{MERGE} --- Merge variables
6422 @cindex @code{MERGE} intrinsic
6425 @item @emph{Description}:
6426 Select values from two arrays according to a logical mask. The result
6427 is equal to @var{TSOURCE} if @var{MASK} is @code{.TRUE.}, or equal to
6428 @var{FSOURCE} if it is @code{.FALSE.}.
6430 @item @emph{Standard}:
6436 @item @emph{Syntax}:
6437 @code{RESULT = MERGE(TSOURCE, FSOURCE, MASK)}
6439 @item @emph{Arguments}:
6440 @multitable @columnfractions .15 .70
6441 @item @var{TSOURCE} @tab May be of any type.
6442 @item @var{FSOURCE} @tab Shall be of the same type and type parameters
6444 @item @var{MASK} @tab Shall be of type @code{LOGICAL(*)}.
6447 @item @emph{Return value}:
6448 The result is of the same type and type parameters as @var{TSOURCE}.
6455 @section @code{MIN} --- Minimum value of an argument list
6456 @cindex @code{MIN} intrinsic
6459 @item @emph{Description}:
6460 Returns the argument with the smallest (most negative) value.
6462 @item @emph{Standard}:
6468 @item @emph{Syntax}:
6469 @code{RESULT = MIN(A1, A2 [, A3, ...])}
6471 @item @emph{Arguments}:
6472 @multitable @columnfractions .15 .70
6473 @item @var{A1} @tab The type shall be @code{INTEGER(*)} or
6475 @item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
6476 as @var{A1}. (As a GNU extension,
6477 arguments of different kinds are
6481 @item @emph{Return value}:
6482 The return value corresponds to the maximum value among the arguments,
6483 and has the same type and kind as the first argument.
6485 @item @emph{Specific names}:
6486 @multitable @columnfractions .20 .20 .20 .25
6487 @item Name @tab Argument @tab Return type @tab Standard
6488 @item @code{MIN0(I)} @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)} @tab F77 and later
6489 @item @code{AMIN0(I)} @tab @code{INTEGER(4) I} @tab @code{REAL(MIN(X))} @tab F77 and later
6490 @item @code{MIN1(X)} @tab @code{REAL(*) X} @tab @code{INT(MIN(X))} @tab F77 and later
6491 @item @code{AMIN1(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab F77 and later
6492 @item @code{DMIN1(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
6495 @item @emph{See also}:
6496 @ref{MAX}, @ref{MINLOC}, @ref{MINVAL}
6500 @section @code{MINEXPONENT} --- Minimum exponent of a real kind
6501 @cindex @code{MINEXPONENT} intrinsic
6502 @cindex minimum exponent
6503 @cindex exponent, minimum
6506 @item @emph{Description}:
6507 @code{MINEXPONENT(X)} returns the minimum exponent in the model of the
6510 @item @emph{Standard}:
6516 @item @emph{Syntax}:
6517 @code{RESULT = MINEXPONENT(X)}
6519 @item @emph{Arguments}:
6520 @multitable @columnfractions .15 .70
6521 @item @var{X} @tab shall be of type @code{REAL}.
6524 @item @emph{Return value}:
6525 The return value is of type @code{INTEGER} and of the default integer
6528 @item @emph{Example}:
6529 See @code{MAXEXPONENT} for an example.
6535 @section @code{MINLOC} --- Location of the minimum value within an array
6536 @cindex @code{MINLOC} intrinsic
6539 @item @emph{Description}:
6540 Determines the location of the element in the array with the minimum
6541 value, or, if the @var{DIM} argument is supplied, determines the
6542 locations of the minimum element along each row of the array in the
6543 @var{DIM} direction. If @var{MASK} is present, only the elements for
6544 which @var{MASK} is @code{.TRUE.} are considered. If more than one
6545 element in the array has the minimum value, the location returned is
6546 that of the first such element in array element order. If the array has
6547 zero size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
6548 the result is an array of zeroes. Similarly, if @var{DIM} is supplied
6549 and all of the elements of @var{MASK} along a given row are zero, the
6550 result value for that row is zero.
6552 @item @emph{Standard}:
6556 Transformational function
6558 @item @emph{Syntax}:
6559 @multitable @columnfractions .80
6560 @item @code{RESULT = MINLOC(ARRAY, DIM [, MASK])}
6561 @item @code{RESULT = MINLOC(ARRAY [, MASK])}
6564 @item @emph{Arguments}:
6565 @multitable @columnfractions .15 .70
6566 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER(*)},
6567 @code{REAL(*)}, or @code{CHARACTER(*)}.
6568 @item @var{DIM} @tab (Optional) Shall be a scalar of type
6569 @code{INTEGER(*)}, with a value between one
6570 and the rank of @var{ARRAY}, inclusive. It
6571 may not be an optional dummy argument.
6572 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL(*)},
6573 and conformable with @var{ARRAY}.
6576 @item @emph{Return value}:
6577 If @var{DIM} is absent, the result is a rank-one array with a length
6578 equal to the rank of @var{ARRAY}. If @var{DIM} is present, the result
6579 is an array with a rank one less than the rank of @var{ARRAY}, and a
6580 size corresponding to the size of @var{ARRAY} with the @var{DIM}
6581 dimension removed. If @var{DIM} is present and @var{ARRAY} has a rank
6582 of one, the result is a scalar. In all cases, the result is of default
6583 @code{INTEGER} type.
6585 @item @emph{See also}:
6586 @ref{MIN}, @ref{MINVAL}
6593 @section @code{MINVAL} --- Minimum value of an array
6594 @cindex @code{MINVAL} intrinsic
6597 @item @emph{Description}:
6598 Determines the minimum value of the elements in an array value, or, if
6599 the @var{DIM} argument is supplied, determines the minimum value along
6600 each row of the array in the @var{DIM} direction. If @var{MASK} is
6601 present, only the elements for which @var{MASK} is @code{.TRUE.} are
6602 considered. If the array has zero size, or all of the elements of
6603 @var{MASK} are @code{.FALSE.}, then the result is @code{HUGE(ARRAY)} if
6604 @var{ARRAY} is numeric, or a string of @code{CHAR(255)} characters if
6605 @var{ARRAY} is of character type.
6607 @item @emph{Standard}:
6611 Transformational function
6613 @item @emph{Syntax}:
6614 @multitable @columnfractions .80
6615 @item @code{RESULT = MINVAL(ARRAY, DIM [, MASK])}
6616 @item @code{RESULT = MINVAL(ARRAY [, MASK])}
6619 @item @emph{Arguments}:
6620 @multitable @columnfractions .15 .70
6621 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER(*)},
6622 @code{REAL(*)}, or @code{CHARACTER(*)}.
6623 @item @var{DIM} @tab (Optional) Shall be a scalar of type
6624 @code{INTEGER(*)}, with a value between one
6625 and the rank of @var{ARRAY}, inclusive. It
6626 may not be an optional dummy argument.
6627 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL(*)},
6628 and conformable with @var{ARRAY}.
6631 @item @emph{Return value}:
6632 If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
6633 is a scalar. If @var{DIM} is present, the result is an array with a
6634 rank one less than the rank of @var{ARRAY}, and a size corresponding to
6635 the size of @var{ARRAY} with the @var{DIM} dimension removed. In all
6636 cases, the result is of the same type and kind as @var{ARRAY}.
6638 @item @emph{See also}:
6639 @ref{MIN}, @ref{MINLOC}
6646 @section @code{MOD} --- Remainder function
6647 @cindex @code{MOD} intrinsic
6648 @cindex @code{AMOD} intrinsic
6649 @cindex @code{DMOD} intrinsic
6653 @item @emph{Description}:
6654 @code{MOD(A,P)} computes the remainder of the division of A by P. It is
6655 calculated as @code{A - (INT(A/P) * P)}.
6657 @item @emph{Standard}:
6663 @item @emph{Syntax}:
6664 @code{RESULT = MOD(A, P)}
6666 @item @emph{Arguments}:
6667 @multitable @columnfractions .15 .70
6668 @item @var{A} @tab shall be a scalar of type @code{INTEGER} or @code{REAL}
6669 @item @var{P} @tab shall be a scalar of the same type as @var{A} and not
6673 @item @emph{Return value}:
6674 The kind of the return value is the result of cross-promoting
6675 the kinds of the arguments.
6677 @item @emph{Example}:
6681 print *, mod(17.5,5.5)
6682 print *, mod(17.5d0,5.5)
6683 print *, mod(17.5,5.5d0)
6686 print *, mod(-17.5,5.5)
6687 print *, mod(-17.5d0,5.5)
6688 print *, mod(-17.5,5.5d0)
6691 print *, mod(17.5,-5.5)
6692 print *, mod(17.5d0,-5.5)
6693 print *, mod(17.5,-5.5d0)
6694 end program test_mod
6697 @item @emph{Specific names}:
6698 @multitable @columnfractions .20 .20 .20 .25
6699 @item Name @tab Arguments @tab Return type @tab Standard
6700 @item @code{AMOD(A,P)} @tab @code{REAL(4)} @tab @code{REAL(4)} @tab F95 and later
6701 @item @code{DMOD(A,P)} @tab @code{REAL(8)} @tab @code{REAL(8)} @tab F95 and later
6708 @section @code{MODULO} --- Modulo function
6709 @cindex @code{MODULO} intrinsic
6713 @item @emph{Description}:
6714 @code{MODULO(A,P)} computes the @var{A} modulo @var{P}.
6716 @item @emph{Standard}:
6722 @item @emph{Syntax}:
6723 @code{RESULT = MODULO(A, P)}
6725 @item @emph{Arguments}:
6726 @multitable @columnfractions .15 .70
6727 @item @var{A} @tab shall be a scalar of type @code{INTEGER} or @code{REAL}
6728 @item @var{P} @tab shall be a scalar of the same type and kind as @var{A}
6731 @item @emph{Return value}:
6732 The type and kind of the result are those of the arguments.
6734 @item If @var{A} and @var{P} are of type @code{INTEGER}:
6735 @code{MODULO(A,P)} has the value @var{R} such that @code{A=Q*P+R}, where
6736 @var{Q} is an integer and @var{R} is between 0 (inclusive) and @var{P}
6738 @item If @var{A} and @var{P} are of type @code{REAL}:
6739 @code{MODULO(A,P)} has the value of @code{A - FLOOR (A / P) * P}.
6741 In all cases, if @var{P} is zero the result is processor-dependent.
6743 @item @emph{Example}:
6746 print *, modulo(17,3)
6747 print *, modulo(17.5,5.5)
6749 print *, modulo(-17,3)
6750 print *, modulo(-17.5,5.5)
6752 print *, modulo(17,-3)
6753 print *, modulo(17.5,-5.5)
6754 end program test_mod
6762 @section @code{MOVE_ALLOC} --- Move allocation from one object to another
6763 @cindex @code{MOVE_ALLOC} intrinsic
6764 @cindex moving allocation
6765 @cindex allocation, moving
6768 @item @emph{Description}:
6769 @code{MOVE_ALLOC(SRC, DEST)} moves the allocation from @var{SRC} to
6770 @var{DEST}. @var{SRC} will become deallocated in the process.
6772 @item @emph{Standard}:
6778 @item @emph{Syntax}:
6779 @code{CALL MOVE_ALLOC(SRC, DEST)}
6781 @item @emph{Arguments}:
6782 @multitable @columnfractions .15 .70
6783 @item @var{SRC} @tab @code{ALLOCATABLE}, @code{INTENT(INOUT)}, may be
6784 of any type and kind.
6785 @item @var{DEST} @tab @code{ALLOCATABLE}, @code{INTENT(OUT)}, shall be
6786 of the same type, kind and rank as @var{SRC}
6789 @item @emph{Return value}:
6792 @item @emph{Example}:
6794 program test_move_alloc
6795 integer, allocatable :: a(:), b(:)
6799 call move_alloc(a, b)
6800 print *, allocated(a), allocated(b)
6802 end program test_move_alloc
6809 @section @code{MVBITS} --- Move bits from one integer to another
6810 @cindex @code{MVBITS} intrinsic
6811 @cindex bit operations
6814 @item @emph{Description}:
6815 Moves @var{LEN} bits from positions @var{FROMPOS} through
6816 @code{FROMPOS+LEN-1} of @var{FROM} to positions @var{TOPOS} through
6817 @code{TOPOS+LEN-1} of @var{TO}. The portion of argument @var{TO} not
6818 affected by the movement of bits is unchanged. The values of
6819 @code{FROMPOS+LEN-1} and @code{TOPOS+LEN-1} must be less than
6820 @code{BIT_SIZE(FROM)}.
6822 @item @emph{Standard}:
6828 @item @emph{Syntax}:
6829 @code{RESULT = MVBITS(FROM, FROMPOS, LEN, TO, TOPOS)}
6831 @item @emph{Arguments}:
6832 @multitable @columnfractions .15 .70
6833 @item @var{FROM} @tab The type shall be @code{INTEGER(*)}.
6834 @item @var{FROMPOS} @tab The type shall be @code{INTEGER(*)}.
6835 @item @var{LEN} @tab The type shall be @code{INTEGER(*)}.
6836 @item @var{TO} @tab The type shall be @code{INTEGER(*)}, of the
6837 same kind as @var{FROM}.
6838 @item @var{TOPOS} @tab The type shall be @code{INTEGER(*)}.
6841 @item @emph{Return value}:
6842 The return value is of type @code{INTEGER(*)} and of the same kind as
6845 @item @emph{See also}:
6846 @ref{IBCLR}, @ref{IBSET}, @ref{IBITS}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
6853 @section @code{NEAREST} --- Nearest representable number
6854 @cindex @code{NEAREST} intrinsic
6855 @cindex processor-representable number
6858 @item @emph{Description}:
6859 @code{NEAREST(X, S)} returns the processor-representable number nearest
6860 to @code{X} in the direction indicated by the sign of @code{S}.
6862 @item @emph{Standard}:
6868 @item @emph{Syntax}:
6869 @code{RESULT = NEAREST(X, S)}
6871 @item @emph{Arguments}:
6872 @multitable @columnfractions .15 .70
6873 @item @var{X} @tab shall be of type @code{REAL}.
6874 @item @var{S} @tab (Optional) shall be of type @code{REAL} and
6878 @item @emph{Return value}:
6879 The return value is of the same type as @code{X}. If @code{S} is
6880 positive, @code{NEAREST} returns the processor-representable number
6881 greater than @code{X} and nearest to it. If @code{S} is negative,
6882 @code{NEAREST} returns the processor-representable number smaller than
6883 @code{X} and nearest to it.
6885 @item @emph{Example}:
6887 program test_nearest
6889 x = nearest(42.0, 1.0)
6890 y = nearest(42.0, -1.0)
6891 write (*,"(3(G20.15))") x, y, x - y
6892 end program test_nearest
6899 @section @code{NEW_LINE} --- New line character
6900 @cindex @code{NEW_LINE} intrinsic
6901 @cindex @code{NEW_LINE} intrinsic
6904 @item @emph{Description}:
6905 @code{NEW_LINE(C)} returns the new-line character.
6907 @item @emph{Standard}:
6913 @item @emph{Syntax}:
6914 @code{RESULT = NEW_LINE(C)}
6916 @item @emph{Arguments}:
6917 @multitable @columnfractions .15 .70
6918 @item @var{C} @tab The argument shall be a scalar or array of the
6919 type @code{CHARACTER}.
6922 @item @emph{Return value}:
6923 Returns a @var{CHARACTER} scalar of length one with the new-line character of
6924 the same kind as parameter @var{C}.
6926 @item @emph{Example}:
6930 write(*,'(A)') 'This is record 1.'//NEW_LINE('A')//'This is record 2.'
6938 @section @code{NINT} --- Nearest whole number
6939 @cindex @code{NINT} intrinsic
6940 @cindex @code{IDNINT} intrinsic
6941 @cindex whole number
6944 @item @emph{Description}:
6945 @code{NINT(X)} rounds its argument to the nearest whole number.
6947 @item @emph{Standard}:
6953 @item @emph{Syntax}:
6954 @code{RESULT = NINT(X)}
6956 @item @emph{Arguments}:
6957 @multitable @columnfractions .15 .70
6958 @item @var{X} @tab The type of the argument shall be @code{REAL}.
6961 @item @emph{Return value}:
6962 Returns @var{A} with the fractional portion of its magnitude eliminated by
6963 rounding to the nearest whole number and with its sign preserved,
6964 converted to an @code{INTEGER} of the default kind.
6966 @item @emph{Example}:
6973 print *, nint(x4), idnint(x8)
6974 end program test_nint
6977 @item @emph{Specific names}:
6978 @multitable @columnfractions .25 .25 .25
6979 @item Name @tab Argument @tab Standard
6980 @item @code{IDNINT(X)} @tab @code{REAL(8)} @tab F95 and later
6983 @item @emph{See also}:
6984 @ref{CEILING}, @ref{FLOOR}
6990 @section @code{NOT} --- Logical negation
6991 @cindex @code{NOT} intrinsic
6992 @cindex bit operations
6995 @item @emph{Description}:
6996 @code{NOT} returns the bitwise boolean inverse of @var{I}.
6998 @item @emph{Standard}:
7004 @item @emph{Syntax}:
7005 @code{RESULT = NOT(I)}
7007 @item @emph{Arguments}:
7008 @multitable @columnfractions .15 .70
7009 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
7012 @item @emph{Return value}:
7013 The return type is @code{INTEGER(*)}, of the same kind as the
7016 @item @emph{See also}:
7017 @ref{IAND}, @ref{IEOR}, @ref{IOR}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}
7025 @section @code{NULL} --- Function that returns an disassociated pointer
7026 @cindex @code{NULL} intrinsic
7027 @cindex undocumented intrinsic
7029 Intrinsic implemented, documentation pending.
7032 @item @emph{Description}:
7033 @item @emph{Standard}:
7037 Transformational function
7039 @item @emph{Syntax}:
7040 @item @emph{Arguments}:
7041 @item @emph{Return value}:
7042 @item @emph{Example}:
7043 @item @emph{See also}:
7051 @section @code{OR} --- Bitwise logical OR
7052 @cindex @code{OR} intrinsic
7053 @cindex bit operations
7056 @item @emph{Description}:
7057 Bitwise logical @code{OR}.
7059 This intrinsic routine is provided for backwards compatibility with
7060 GNU Fortran 77. For integer arguments, programmers should consider
7061 the use of the @ref{IOR} intrinsic defined by the Fortran standard.
7063 @item @emph{Standard}:
7067 Non-elemental function
7069 @item @emph{Syntax}:
7070 @code{RESULT = OR(X, Y)}
7072 @item @emph{Arguments}:
7073 @multitable @columnfractions .15 .70
7074 @item @var{X} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
7075 @item @var{Y} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
7078 @item @emph{Return value}:
7079 The return type is either @code{INTEGER(*)} or @code{LOGICAL}
7080 after cross-promotion of the arguments.
7082 @item @emph{Example}:
7085 LOGICAL :: T = .TRUE., F = ..FALSE.
7087 DATA a / Z'F' /, b / Z'3' /
7089 WRITE (*,*) OR(T, T), OR(T, F), OR(F, T), OR(F, F)
7090 WRITE (*,*) OR(a, b)
7094 @item @emph{See also}:
7095 F95 elemental function: @ref{IOR}
7102 @section @code{PACK} --- Pack an array into an array of rank one
7103 @cindex @code{PACK} intrinsic
7104 @cindex undocumented intrinsic
7106 Intrinsic implemented, documentation pending.
7109 @item @emph{Description}:
7110 @item @emph{Standard}:
7114 Transformational function
7116 @item @emph{Syntax}:
7117 @item @emph{Arguments}:
7118 @item @emph{Return value}:
7119 @item @emph{Example}:
7120 @item @emph{Specific names}:
7121 @item @emph{See also}:
7128 @section @code{PERROR} --- Print system error message
7129 @cindex @code{PERROR} intrinsic
7132 @item @emph{Description}:
7133 Prints (on the C @code{stderr} stream) a newline-terminated error
7134 message corresponding to the last system error. This is prefixed by
7135 @var{STRING}, a colon and a space. See @code{perror(3)}.
7137 @item @emph{Standard}:
7143 @item @emph{Syntax}:
7144 @code{CALL PERROR(STRING)}
7146 @item @emph{Arguments}:
7147 @multitable @columnfractions .15 .70
7148 @item @var{STRING} @tab A scalar of default @code{CHARACTER} type.
7151 @item @emph{See also}:
7158 @section @code{PRECISION} --- Decimal precision of a real kind
7159 @cindex @code{PRECISION} intrinsic
7160 @cindex precision of a real variable
7163 @item @emph{Description}:
7164 @code{PRECISION(X)} returns the decimal precision in the model of the
7167 @item @emph{Standard}:
7173 @item @emph{Syntax}:
7174 @code{RESULT = PRECISION(X)}
7176 @item @emph{Arguments}:
7177 @multitable @columnfractions .15 .70
7178 @item @var{X} @tab shall be of type @code{REAL} or @code{COMPLEX}.
7181 @item @emph{Return value}:
7182 The return value is of type @code{INTEGER} and of the default integer
7185 @item @emph{Example}:
7187 program prec_and_range
7188 real(kind=4) :: x(2)
7189 complex(kind=8) :: y
7191 print *, precision(x), range(x)
7192 print *, precision(y), range(y)
7193 end program prec_and_range
7200 @section @code{PRESENT} --- Determine whether an optional argument is specified
7201 @cindex @code{PRESENT} intrinsic
7202 @cindex undocumented intrinsic
7204 Intrinsic implemented, documentation pending.
7207 @item @emph{Description}:
7208 @item @emph{Standard}:
7214 @item @emph{Syntax}:
7215 @item @emph{Arguments}:
7216 @item @emph{Return value}:
7217 @item @emph{Example}:
7218 @item @emph{See also}:
7224 @section @code{PRODUCT} --- Product of array elements
7225 @cindex @code{PRODUCT} intrinsic
7226 @cindex undocumented intrinsic
7228 Intrinsic implemented, documentation pending.
7231 @item @emph{Description}:
7232 @item @emph{Standard}:
7236 Transformational function
7238 @item @emph{Syntax}:
7239 @item @emph{Arguments}:
7240 @item @emph{Return value}:
7241 @item @emph{Example}:
7242 @item @emph{Specific names}:
7243 @item @emph{See also}:
7250 @section @code{RADIX} --- Base of a model number
7251 @cindex @code{RADIX} intrinsic
7255 @item @emph{Description}:
7256 @code{RADIX(X)} returns the base of the model representing the entity @var{X}.
7258 @item @emph{Standard}:
7264 @item @emph{Syntax}:
7265 @code{RESULT = RADIX(X)}
7267 @item @emph{Arguments}:
7268 @multitable @columnfractions .15 .70
7269 @item @var{X} @tab Shall be of type @code{INTEGER} or @code{REAL}
7272 @item @emph{Return value}:
7273 The return value is a scalar of type @code{INTEGER} and of the default
7276 @item @emph{Example}:
7279 print *, "The radix for the default integer kind is", radix(0)
7280 print *, "The radix for the default real kind is", radix(0.0)
7281 end program test_radix
7289 @section @code{RAN} --- Real pseudo-random number
7290 @cindex @code{RAN} intrinsic
7291 @cindex random numbers
7294 @item @emph{Description}:
7295 For compatibility with HP FORTRAN 77/iX, the @code{RAN} intrinsic is
7296 provided as an alias for @code{RAND}. See @ref{RAND} for complete
7299 @item @emph{Standard}:
7303 Non-elemental function
7305 @item @emph{See also}:
7306 @ref{RAND}, @ref{RANDOM_NUMBER}
7312 @section @code{RAND} --- Real pseudo-random number
7313 @cindex @code{RAND} intrinsic
7314 @cindex random numbers
7317 @item @emph{Description}:
7318 @code{RAND(FLAG)} returns a pseudo-random number from a uniform
7319 distribution between 0 and 1. If @var{FLAG} is 0, the next number
7320 in the current sequence is returned; if @var{FLAG} is 1, the generator
7321 is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
7322 it is used as a new seed with @code{SRAND}.
7324 @item @emph{Standard}:
7328 Non-elemental function
7330 @item @emph{Syntax}:
7331 @code{RESULT = RAND(FLAG)}
7333 @item @emph{Arguments}:
7334 @multitable @columnfractions .15 .70
7335 @item @var{FLAG} @tab shall be a scalar @code{INTEGER} of kind 4.
7338 @item @emph{Return value}:
7339 The return value is of @code{REAL} type and the default kind.
7341 @item @emph{Example}:
7344 integer,parameter :: seed = 86456
7347 print *, rand(), rand(), rand(), rand()
7348 print *, rand(seed), rand(), rand(), rand()
7349 end program test_rand
7352 @item @emph{See also}:
7353 @ref{SRAND}, @ref{RANDOM_NUMBER}
7360 @section @code{RANDOM_NUMBER} --- Pseudo-random number
7361 @cindex @code{RANDOM_NUMBER} intrinsic
7362 @cindex random numbers
7364 Intrinsic implemented, documentation pending.
7367 @item @emph{Description}:
7368 @item @emph{Standard}:
7372 Elemental subroutine
7374 @item @emph{Syntax}:
7375 @item @emph{Arguments}:
7376 @item @emph{Return value}:
7377 @item @emph{Example}:
7378 @item @emph{See also}:
7385 @section @code{RANDOM_SEED} --- Initialize a pseudo-random number sequence
7386 @cindex @code{RANDOM_SEED} intrinsic
7387 @cindex random numbers
7389 Intrinsic implemented, documentation pending.
7392 @item @emph{Description}:
7393 @item @emph{Standard}:
7399 @item @emph{Syntax}:
7400 @item @emph{Arguments}:
7401 @item @emph{Return value}:
7402 @item @emph{Example}:
7403 @item @emph{See also}:
7410 @section @code{RANGE} --- Decimal exponent range of a real kind
7411 @cindex @code{RANGE} intrinsic
7412 @cindex range of a real variable
7415 @item @emph{Description}:
7416 @code{RANGE(X)} returns the decimal exponent range in the model of the
7419 @item @emph{Standard}:
7425 @item @emph{Syntax}:
7426 @code{RESULT = RANGE(X)}
7428 @item @emph{Arguments}:
7429 @multitable @columnfractions .15 .70
7430 @item @var{X} @tab shall be of type @code{REAL} or @code{COMPLEX}.
7433 @item @emph{Return value}:
7434 The return value is of type @code{INTEGER} and of the default integer
7437 @item @emph{Example}:
7438 See @code{PRECISION} for an example.
7444 @section @code{REAL} --- Convert to real type
7445 @cindex @code{REAL} intrinsic
7446 @cindex @code{REALPART} intrinsic
7450 @item @emph{Description}:
7451 @code{REAL(X [, KIND])} converts its argument @var{X} to a real type. The
7452 @code{REALPART(X)} function is provided for compatibility with @command{g77},
7453 and its use is strongly discouraged.
7455 @item @emph{Standard}:
7461 @item @emph{Syntax}:
7462 @multitable @columnfractions .80
7463 @item @code{RESULT = REAL(X [, KIND])}
7464 @item @code{RESULT = REALPART(Z)}
7467 @item @emph{Arguments}:
7468 @multitable @columnfractions .15 .70
7469 @item @var{X} @tab shall be @code{INTEGER(*)}, @code{REAL(*)}, or
7471 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
7472 expression indicating the kind parameter of
7476 @item @emph{Return value}:
7477 These functions return a @code{REAL(*)} variable or array under
7478 the following rules:
7482 @code{REAL(X)} is converted to a default real type if @var{X} is an
7483 integer or real variable.
7485 @code{REAL(X)} is converted to a real type with the kind type parameter
7486 of @var{X} if @var{X} is a complex variable.
7488 @code{REAL(X, KIND)} is converted to a real type with kind type
7489 parameter @var{KIND} if @var{X} is a complex, integer, or real
7493 @item @emph{Example}:
7496 complex :: x = (1.0, 2.0)
7497 print *, real(x), real(x,8), realpart(x)
7498 end program test_real
7501 @item @emph{See also}:
7502 @ref{DBLE}, @ref{DFLOAT}, @ref{FLOAT}
7509 @section @code{RENAME} --- Rename a file
7510 @cindex @code{RENAME} intrinsic
7511 @cindex file system operations
7514 @item @emph{Description}:
7515 Renames a file from file @var{PATH1} to @var{PATH2}. A null
7516 character (@code{CHAR(0)}) can be used to mark the end of the names in
7517 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
7518 names are ignored. If the @var{STATUS} argument is supplied, it
7519 contains 0 on success or a nonzero error code upon return; see
7522 @item @emph{Standard}:
7528 @item @emph{Syntax}:
7529 @code{CALL RENAME(PATH1, PATH2 [, STATUS])}
7531 @item @emph{Arguments}:
7532 @multitable @columnfractions .15 .70
7533 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
7534 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
7535 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
7538 @item @emph{See also}:
7546 @section @code{REPEAT} --- Repeated string concatenation
7547 @cindex @code{REPEAT} intrinsic
7548 @cindex string manipulation
7550 Intrinsic implemented, documentation pending.
7553 @item @emph{Description}:
7554 @item @emph{Standard}:
7558 Transformational function
7560 @item @emph{Syntax}:
7561 @item @emph{Arguments}:
7562 @item @emph{Return value}:
7563 @item @emph{Example}:
7564 @item @emph{See also}:
7571 @section @code{RESHAPE} --- Function to reshape an array
7572 @cindex @code{RESHAPE} intrinsic
7573 @cindex array manipulation
7575 Intrinsic implemented, documentation pending.
7578 @item @emph{Description}:
7579 @item @emph{Standard}:
7583 Transformational function
7585 @item @emph{Syntax}:
7586 @item @emph{Arguments}:
7587 @item @emph{Return value}:
7588 @item @emph{Example}:
7589 @item @emph{See also}:
7596 @section @code{RRSPACING} --- Reciprocal of the relative spacing
7597 @cindex @code{RRSPACING} intrinsic
7600 @item @emph{Description}:
7601 @code{RRSPACING(X)} returns the reciprocal of the relative spacing of
7602 model numbers near @var{X}.
7604 @item @emph{Standard}:
7610 @item @emph{Syntax}:
7611 @code{RESULT = RRSPACING(X)}
7613 @item @emph{Arguments}:
7614 @multitable @columnfractions .15 .70
7615 @item @var{X} @tab shall be of type @code{REAL}.
7618 @item @emph{Return value}:
7619 The return value is of the same type and kind as @var{X}.
7620 The value returned is equal to
7621 @code{ABS(FRACTION(X)) * FLOAT(RADIX(X))**DIGITS(X)}.
7628 @section @code{RSHIFT} --- Right shift bits
7629 @cindex @code{RSHIFT} intrinsic
7630 @cindex bit operations
7633 @item @emph{Description}:
7634 @code{RSHIFT} returns a value corresponding to @var{I} with all of the
7635 bits shifted right by @var{SHIFT} places. If the absolute value of
7636 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
7637 Bits shifted out from the left end are lost; zeros are shifted in from
7640 This function has been superseded by the @code{ISHFT} intrinsic, which
7641 is standard in Fortran 95 and later.
7643 @item @emph{Standard}:
7649 @item @emph{Syntax}:
7650 @code{RESULT = RSHIFT(I, SHIFT)}
7652 @item @emph{Arguments}:
7653 @multitable @columnfractions .15 .70
7654 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
7655 @item @var{SHIFT} @tab The type shall be @code{INTEGER(*)}.
7658 @item @emph{Return value}:
7659 The return value is of type @code{INTEGER(*)} and of the same kind as
7662 @item @emph{See also}:
7663 @ref{ISHFT}, @ref{ISHFTC}, @ref{LSHIFT}
7670 @section @code{SCALE} --- Scale a real value
7671 @cindex @code{SCALE} intrinsic
7674 @item @emph{Description}:
7675 @code{SCALE(X,I)} returns @code{X * RADIX(X)**I}.
7677 @item @emph{Standard}:
7683 @item @emph{Syntax}:
7684 @code{RESULT = SCALE(X, I)}
7686 @item @emph{Arguments}:
7687 @multitable @columnfractions .15 .70
7688 @item @var{X} @tab The type of the argument shall be a @code{REAL}.
7689 @item @var{I} @tab The type of the argument shall be a @code{INTEGER}.
7692 @item @emph{Return value}:
7693 The return value is of the same type and kind as @var{X}.
7694 Its value is @code{X * RADIX(X)**I}.
7696 @item @emph{Example}:
7699 real :: x = 178.1387e-4
7701 print *, scale(x,i), x*radix(x)**i
7702 end program test_scale
7709 @section @code{SCAN} --- Scan a string for the presence of a set of characters
7710 @cindex @code{SCAN} intrinsic
7711 @cindex string manipulation
7713 Intrinsic implemented, documentation pending.
7716 @item @emph{Description}:
7717 @item @emph{Standard}:
7723 @item @emph{Syntax}:
7724 @item @emph{Arguments}:
7725 @item @emph{Return value}:
7726 @item @emph{Example}:
7727 @item @emph{See also}:
7734 @section @code{SECNDS} --- Time function
7735 @cindex @code{SECNDS} intrinsic
7736 @cindex time, current
7737 @cindex current time
7740 @item @emph{Description}:
7741 @code{SECNDS(X)} gets the time in seconds from the real-time system clock.
7742 @var{X} is a reference time, also in seconds. If this is zero, the time in
7743 seconds from midnight is returned. This function is non-standard and its
7746 @item @emph{Standard}:
7752 @item @emph{Syntax}:
7753 @code{RESULT = SECNDS (X)}
7755 @item @emph{Arguments}:
7756 @multitable @columnfractions .15 .70
7757 @item Name @tab Type
7758 @item @var{T} @tab REAL(4)
7759 @item @var{X} @tab REAL(4)
7762 @item @emph{Return value}:
7765 @item @emph{Example}:
7769 print *, secnds (0.0) ! seconds since midnight
7770 t1 = secnds (0.0) ! reference time
7771 do i = 1, 10000000 ! do something
7773 t2 = secnds (t1) ! elapsed time
7774 print *, "Something took ", t2, " seconds."
7775 end program test_secnds
7781 @node SELECTED_INT_KIND
7782 @section @code{SELECTED_INT_KIND} --- Choose integer kind
7783 @cindex @code{SELECTED_INT_KIND} intrinsic
7784 @cindex integer kind
7787 @item @emph{Description}:
7788 @code{SELECTED_INT_KIND(I)} return the kind value of the smallest integer
7789 type that can represent all values ranging from @math{-10^I} (exclusive)
7790 to @math{10^I} (exclusive). If there is no integer kind that accommodates
7791 this range, @code{SELECTED_INT_KIND} returns @math{-1}.
7793 @item @emph{Standard}:
7797 Transformational function
7799 @item @emph{Syntax}:
7800 @code{RESULT = SELECTED_INT_KIND(I)}
7802 @item @emph{Arguments}:
7803 @multitable @columnfractions .15 .70
7804 @item @var{I} @tab shall be a scalar and of type @code{INTEGER}.
7807 @item @emph{Example}:
7809 program large_integers
7810 integer,parameter :: k5 = selected_int_kind(5)
7811 integer,parameter :: k15 = selected_int_kind(15)
7812 integer(kind=k5) :: i5
7813 integer(kind=k15) :: i15
7815 print *, huge(i5), huge(i15)
7817 ! The following inequalities are always true
7818 print *, huge(i5) >= 10_k5**5-1
7819 print *, huge(i15) >= 10_k15**15-1
7820 end program large_integers
7826 @node SELECTED_REAL_KIND
7827 @section @code{SELECTED_REAL_KIND} --- Choose real kind
7828 @cindex @code{SELECTED_REAL_KIND} intrinsic
7832 @item @emph{Description}:
7833 @code{SELECTED_REAL_KIND(P,R)} return the kind value of a real data type
7834 with decimal precision greater of at least @code{P} digits and exponent
7835 range greater at least @code{R}.
7837 @item @emph{Standard}:
7841 Transformational function
7843 @item @emph{Syntax}:
7844 @code{RESULT = SELECTED_REAL_KIND(P, R)}
7846 @item @emph{Arguments}:
7847 @multitable @columnfractions .15 .70
7848 @item @var{P} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
7849 @item @var{R} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
7851 At least one argument shall be present.
7853 @item @emph{Return value}:
7855 @code{SELECTED_REAL_KIND} returns the value of the kind type parameter of
7856 a real data type with decimal precision of at least @code{P} digits and a
7857 decimal exponent range of at least @code{R}. If more than one real data
7858 type meet the criteria, the kind of the data type with the smallest
7859 decimal precision is returned. If no real data type matches the criteria,
7862 @item -1 if the processor does not support a real data type with a
7863 precision greater than or equal to @code{P}
7864 @item -2 if the processor does not support a real type with an exponent
7865 range greater than or equal to @code{R}
7866 @item -3 if neither is supported.
7869 @item @emph{Example}:
7872 integer,parameter :: p6 = selected_real_kind(6)
7873 integer,parameter :: p10r100 = selected_real_kind(10,100)
7874 integer,parameter :: r400 = selected_real_kind(r=400)
7876 real(kind=p10r100) :: y
7877 real(kind=r400) :: z
7879 print *, precision(x), range(x)
7880 print *, precision(y), range(y)
7881 print *, precision(z), range(z)
7882 end program real_kinds
7889 @section @code{SET_EXPONENT} --- Set the exponent of the model
7890 @cindex @code{SET_EXPONENT} intrinsic
7891 @cindex exponent part of a real number
7894 @item @emph{Description}:
7895 @code{SET_EXPONENT(X, I)} returns the real number whose fractional part
7896 is that that of @var{X} and whose exponent part is @var{I}.
7898 @item @emph{Standard}:
7904 @item @emph{Syntax}:
7905 @code{RESULT = SET_EXPONENT(X, I)}
7907 @item @emph{Arguments}:
7908 @multitable @columnfractions .15 .70
7909 @item @var{X} @tab shall be of type @code{REAL}.
7910 @item @var{I} @tab shall be of type @code{INTEGER}.
7913 @item @emph{Return value}:
7914 The return value is of the same type and kind as @var{X}.
7915 The real number whose fractional part
7916 is that that of @var{X} and whose exponent part if @var{I} is returned;
7917 it is @code{FRACTION(X) * RADIX(X)**I}.
7919 @item @emph{Example}:
7922 real :: x = 178.1387e-4
7924 print *, set_exponent(x), fraction(x) * radix(x)**i
7925 end program test_setexp
7933 @section @code{SHAPE} --- Determine the shape of an array
7934 @cindex @code{SHAPE} intrinsic
7935 @cindex array manipulation
7937 Intrinsic implemented, documentation pending.
7940 @item @emph{Description}:
7941 @item @emph{Standard}:
7947 @item @emph{Syntax}:
7948 @item @emph{Arguments}:
7949 @item @emph{Return value}:
7950 @item @emph{Example}:
7951 @item @emph{See also}:
7958 @section @code{SIGN} --- Sign copying function
7959 @cindex @code{SIGN} intrinsic
7960 @cindex @code{ISIGN} intrinsic
7961 @cindex @code{DSIGN} intrinsic
7962 @cindex sign copying
7965 @item @emph{Description}:
7966 @code{SIGN(A,B)} returns the value of @var{A} with the sign of @var{B}.
7968 @item @emph{Standard}:
7974 @item @emph{Syntax}:
7975 @code{RESULT = SIGN(A, B)}
7977 @item @emph{Arguments}:
7978 @multitable @columnfractions .15 .70
7979 @item @var{A} @tab shall be a scalar of type @code{INTEGER} or @code{REAL}
7980 @item @var{B} @tab shall be a scalar of the same type and kind as @var{A}
7983 @item @emph{Return value}:
7984 The kind of the return value is that of @var{A} and @var{B}.
7985 If @math{B\ge 0} then the result is @code{ABS(A)}, else
7986 it is @code{-ABS(A)}.
7988 @item @emph{Example}:
7991 print *, sign(-12,1)
7992 print *, sign(-12,0)
7993 print *, sign(-12,-1)
7995 print *, sign(-12.,1.)
7996 print *, sign(-12.,0.)
7997 print *, sign(-12.,-1.)
7998 end program test_sign
8001 @item @emph{Specific names}:
8002 @multitable @columnfractions .20 .20 .20 .25
8003 @item Name @tab Arguments @tab Return type @tab Standard
8004 @item @code{ISIGN(A,P)} @tab @code{INTEGER(4)} @tab @code{INTEGER(4)} @tab f95, gnu
8005 @item @code{DSIGN(A,P)} @tab @code{REAL(8)} @tab @code{REAL(8)} @tab f95, gnu
8012 @section @code{SIGNAL} --- Signal handling subroutine (or function)
8013 @cindex @code{SIGNAL} intrinsic
8014 @cindex signal handling
8017 @item @emph{Description}:
8018 @code{SIGNAL(NUMBER, HANDLER [, STATUS])} causes external subroutine
8019 @var{HANDLER} to be executed with a single integer argument when signal
8020 @var{NUMBER} occurs. If @var{HANDLER} is an integer, it can be used to
8021 turn off handling of signal @var{NUMBER} or revert to its default
8022 action. See @code{signal(2)}.
8024 If @code{SIGNAL} is called as a subroutine and the @var{STATUS} argument
8025 is supplied, it is set to the value returned by @code{signal(2)}.
8027 @item @emph{Standard}:
8031 Subroutine, non-elemental function
8033 @item @emph{Syntax}:
8034 @multitable @columnfractions .80
8035 @item @code{CALL SIGNAL(NUMBER, HANDLER [, STATUS])}
8036 @item @code{STATUS = SIGNAL(NUMBER, HANDLER)}
8039 @item @emph{Arguments}:
8040 @multitable @columnfractions .15 .70
8041 @item @var{NUMBER} @tab shall be a scalar integer, with @code{INTENT(IN)}
8042 @item @var{HANDLER}@tab Signal handler (@code{INTEGER FUNCTION} or
8043 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar.
8044 @code{INTEGER}. It is @code{INTENT(IN)}.
8045 @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
8046 integer. It has @code{INTENT(OUT)}.
8049 @item @emph{Return value}:
8050 The @code{SIGNAL} function returns the value returned by @code{signal(2)}.
8052 @item @emph{Example}:
8056 external handler_print
8058 call signal (12, handler_print)
8062 end program test_signal
8069 @section @code{SIN} --- Sine function
8070 @cindex @code{SIN} intrinsic
8071 @cindex @code{DSIN} intrinsic
8072 @cindex @code{ZSIN} intrinsic
8073 @cindex @code{CDSIN} intrinsic
8074 @cindex trigonometric functions
8077 @item @emph{Description}:
8078 @code{SIN(X)} computes the sine of @var{X}.
8080 @item @emph{Standard}:
8086 @item @emph{Syntax}:
8087 @code{RESULT = SIN(X)}
8089 @item @emph{Arguments}:
8090 @multitable @columnfractions .15 .70
8091 @item @var{X} @tab The type shall be @code{REAL(*)} or
8095 @item @emph{Return value}:
8096 The return value has same type and kind as @var{X}.
8098 @item @emph{Example}:
8103 end program test_sin
8106 @item @emph{Specific names}:
8107 @multitable @columnfractions .20 .20 .20 .25
8108 @item Name @tab Argument @tab Return type @tab Standard
8109 @item @code{DSIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
8110 @item @code{CSIN(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab f95, gnu
8111 @item @code{ZSIN(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
8112 @item @code{CDSIN(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
8115 @item @emph{See also}:
8122 @section @code{SINH} --- Hyperbolic sine function
8123 @cindex @code{SINH} intrinsic
8124 @cindex @code{DSINH} intrinsic
8125 @cindex hyperbolic sine
8128 @item @emph{Description}:
8129 @code{SINH(X)} computes the hyperbolic sine of @var{X}.
8131 @item @emph{Standard}:
8137 @item @emph{Syntax}:
8138 @code{RESULT = SINH(X)}
8140 @item @emph{Arguments}:
8141 @multitable @columnfractions .15 .70
8142 @item @var{X} @tab The type shall be @code{REAL(*)}.
8145 @item @emph{Return value}:
8146 The return value is of type @code{REAL(*)}.
8148 @item @emph{Example}:
8151 real(8) :: x = - 1.0_8
8153 end program test_sinh
8156 @item @emph{Specific names}:
8157 @multitable @columnfractions .20 .20 .20 .25
8158 @item Name @tab Argument @tab Return type @tab Standard
8159 @item @code{DSINH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
8162 @item @emph{See also}:
8169 @section @code{SIZE} --- Determine the size of an array
8170 @cindex @code{SIZE} intrinsic
8171 @cindex array manipulation
8173 Intrinsic implemented, documentation pending.
8176 @item @emph{Description}:
8177 @item @emph{Standard}:
8183 @item @emph{Syntax}:
8184 @item @emph{Arguments}:
8185 @item @emph{Return value}:
8186 @item @emph{Example}:
8187 @item @emph{See also}:
8193 @section @code{SLEEP} --- Sleep for the specified number of seconds
8194 @cindex @code{SLEEP} intrinsic
8197 @item @emph{Description}:
8198 Calling this subroutine causes the process to pause for @var{SECONDS} seconds.
8200 @item @emph{Standard}:
8206 @item @emph{Syntax}:
8207 @code{CALL SLEEP(SECONDS)}
8209 @item @emph{Arguments}:
8210 @multitable @columnfractions .15 .70
8211 @item @var{SECONDS} @tab The type shall be of default @code{INTEGER}.
8214 @item @emph{Example}:
8225 @section @code{SNGL} --- Convert double precision real to default real
8226 @cindex @code{SNGL} intrinsic
8227 @cindex conversion function (real)
8230 @item @emph{Description}:
8231 @code{SNGL(A)} converts the double precision real @var{A}
8232 to a default real value. This is an archaic form of @code{REAL}
8233 that is specific to one type for @var{A}.
8235 @item @emph{Standard}:
8241 @item @emph{Syntax}:
8242 @code{RESULT = SNGL(A)}
8244 @item @emph{Arguments}:
8245 @multitable @columnfractions .15 .70
8246 @item @var{A} @tab The type shall be a double precision @code{REAL}.
8249 @item @emph{Return value}:
8250 The return value is of type default @code{REAL}.
8252 @item @emph{See also}:
8259 @section @code{SPACING} --- Smallest distance between two numbers of a given type
8260 @cindex @code{SPACING} intrinsic
8261 @cindex undocumented intrinsic
8263 Intrinsic implemented, documentation pending.
8266 @item @emph{Description}:
8267 @item @emph{Standard}:
8273 @item @emph{Syntax}:
8274 @item @emph{Arguments}:
8275 @item @emph{Return value}:
8276 @item @emph{Example}:
8277 @item @emph{See also}:
8284 @section @code{SPREAD} --- Add a dimension to an array
8285 @cindex @code{SPREAD} intrinsic
8286 @cindex array manipulation
8288 Intrinsic implemented, documentation pending.
8291 @item @emph{Description}:
8292 @item @emph{Standard}:
8296 Transformational function
8298 @item @emph{Syntax}:
8299 @item @emph{Arguments}:
8300 @item @emph{Return value}:
8301 @item @emph{Example}:
8302 @item @emph{See also}:
8309 @section @code{SQRT} --- Square-root function
8310 @cindex @code{SQRT} intrinsic
8311 @cindex @code{DSQRT} intrinsic
8312 @cindex @code{CSQRT} intrinsic
8313 @cindex @code{ZSQRT} intrinsic
8314 @cindex @code{CDSQRT} intrinsic
8318 @item @emph{Description}:
8319 @code{SQRT(X)} computes the square root of @var{X}.
8321 @item @emph{Standard}:
8327 @item @emph{Syntax}:
8328 @code{RESULT = SQRT(X)}
8330 @item @emph{Arguments}:
8331 @multitable @columnfractions .15 .70
8332 @item @var{X} @tab The type shall be @code{REAL(*)} or
8336 @item @emph{Return value}:
8337 The return value is of type @code{REAL(*)} or @code{COMPLEX(*)}.
8338 The kind type parameter is the same as @var{X}.
8340 @item @emph{Example}:
8343 real(8) :: x = 2.0_8
8344 complex :: z = (1.0, 2.0)
8347 end program test_sqrt
8350 @item @emph{Specific names}:
8351 @multitable @columnfractions .20 .20 .20 .25
8352 @item Name @tab Argument @tab Return type @tab Standard
8353 @item @code{DSQRT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
8354 @item @code{CSQRT(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab F95 and later
8355 @item @code{ZSQRT(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
8356 @item @code{CDSQRT(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
8363 @section @code{SRAND} --- Reinitialize the random number generator
8364 @cindex @code{SRAND} intrinsic
8365 @cindex random numbers
8368 @item @emph{Description}:
8369 @code{SRAND} reinitializes the pseudo-random number generator
8370 called by @code{RAND} and @code{IRAND}. The new seed used by the
8371 generator is specified by the required argument @var{SEED}.
8373 @item @emph{Standard}:
8377 Non-elemental subroutine
8379 @item @emph{Syntax}:
8380 @code{CALL SRAND(SEED)}
8382 @item @emph{Arguments}:
8383 @multitable @columnfractions .15 .70
8384 @item @var{SEED} @tab shall be a scalar @code{INTEGER(kind=4)}.
8387 @item @emph{Return value}:
8390 @item @emph{Example}:
8391 See @code{RAND} and @code{IRAND} for examples.
8394 The Fortran 2003 standard specifies the intrinsic @code{RANDOM_SEED} to
8395 initialize the pseudo-random numbers generator and @code{RANDOM_NUMBER}
8396 to generate pseudo-random numbers. Please note that in
8397 GNU Fortran, these two sets of intrinsics (@code{RAND},
8398 @code{IRAND} and @code{SRAND} on the one hand, @code{RANDOM_NUMBER} and
8399 @code{RANDOM_SEED} on the other hand) access two independent
8400 pseudo-random number generators.
8402 @item @emph{See also}:
8403 @ref{RAND}, @ref{RANDOM_SEED}, @ref{RANDOM_NUMBER}
8410 @section @code{STAT} --- Get file status
8411 @cindex @code{STAT} intrinsic
8412 @cindex file system operations
8415 @item @emph{Description}:
8416 This function returns information about a file. No permissions are required on
8417 the file itself, but execute (search) permission is required on all of the
8418 directories in path that lead to the file.
8420 The elements that are obtained and stored in the array @code{BUFF}:
8421 @multitable @columnfractions .15 .70
8422 @item @code{buff(1)} @tab Device ID
8423 @item @code{buff(2)} @tab Inode number
8424 @item @code{buff(3)} @tab File mode
8425 @item @code{buff(4)} @tab Number of links
8426 @item @code{buff(5)} @tab Owner's uid
8427 @item @code{buff(6)} @tab Owner's gid
8428 @item @code{buff(7)} @tab ID of device containing directory entry for file (0 if not available)
8429 @item @code{buff(8)} @tab File size (bytes)
8430 @item @code{buff(9)} @tab Last access time
8431 @item @code{buff(10)} @tab Last modification time
8432 @item @code{buff(11)} @tab Last file status change time
8433 @item @code{buff(12)} @tab Preferred I/O block size (-1 if not available)
8434 @item @code{buff(13)} @tab Number of blocks allocated (-1 if not available)
8437 Not all these elements are relevant on all systems.
8438 If an element is not relevant, it is returned as 0.
8441 @item @emph{Standard}:
8445 Non-elemental subroutine
8447 @item @emph{Syntax}:
8448 @code{CALL STAT(FILE,BUFF[,STATUS])}
8450 @item @emph{Arguments}:
8451 @multitable @columnfractions .15 .70
8452 @item @var{FILE} @tab The type shall be @code{CHARACTER(*)}, a valid path within the file system.
8453 @item @var{BUFF} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
8454 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0
8455 on success and a system specific error code otherwise.
8458 @item @emph{Example}:
8461 INTEGER, DIMENSION(13) :: buff
8464 CALL STAT("/etc/passwd", buff, status)
8466 IF (status == 0) THEN
8467 WRITE (*, FMT="('Device ID:', T30, I19)") buff(1)
8468 WRITE (*, FMT="('Inode number:', T30, I19)") buff(2)
8469 WRITE (*, FMT="('File mode (octal):', T30, O19)") buff(3)
8470 WRITE (*, FMT="('Number of links:', T30, I19)") buff(4)
8471 WRITE (*, FMT="('Owner''s uid:', T30, I19)") buff(5)
8472 WRITE (*, FMT="('Owner''s gid:', T30, I19)") buff(6)
8473 WRITE (*, FMT="('Device where located:', T30, I19)") buff(7)
8474 WRITE (*, FMT="('File size:', T30, I19)") buff(8)
8475 WRITE (*, FMT="('Last access time:', T30, A19)") CTIME(buff(9))
8476 WRITE (*, FMT="('Last modification time', T30, A19)") CTIME(buff(10))
8477 WRITE (*, FMT="('Last status change time:', T30, A19)") CTIME(buff(11))
8478 WRITE (*, FMT="('Preferred block size:', T30, I19)") buff(12)
8479 WRITE (*, FMT="('No. of blocks allocated:', T30, I19)") buff(13)
8484 @item @emph{See also}:
8485 To stat an open file: @ref{FSTAT}, to stat a link: @ref{LSTAT}
8491 @section @code{SUM} --- Sum of array elements
8492 @cindex @code{SUM} intrinsic
8493 @cindex array manipulation
8495 Intrinsic implemented, documentation pending.
8498 @item @emph{Description}:
8499 @item @emph{Standard}:
8503 Transformational function
8505 @item @emph{Syntax}:
8506 @item @emph{Arguments}:
8507 @item @emph{Return value}:
8508 @item @emph{Example}:
8509 @item @emph{See also}:
8516 @section @code{SYMLNK} --- Create a symbolic link
8517 @cindex @code{SYMLNK} intrinsic
8518 @cindex file system operations
8521 @item @emph{Description}:
8522 Makes a symbolic link from file @var{PATH1} to @var{PATH2}. A null
8523 character (@code{CHAR(0)}) can be used to mark the end of the names in
8524 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
8525 names are ignored. If the @var{STATUS} argument is supplied, it
8526 contains 0 on success or a nonzero error code upon return; see
8527 @code{symlink(2)}. If the system does not supply @code{symlink(2)},
8528 @code{ENOSYS} is returned.
8530 @item @emph{Standard}:
8536 @item @emph{Syntax}:
8537 @code{CALL SYMLNK(PATH1, PATH2 [, STATUS])}
8539 @item @emph{Arguments}:
8540 @multitable @columnfractions .15 .70
8541 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
8542 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
8543 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
8546 @item @emph{See also}:
8547 @ref{LINK}, @ref{UNLINK}
8554 @section @code{SYSTEM} --- Execute a shell command
8555 @cindex @code{SYSTEM} intrinsic
8558 @item @emph{Description}:
8559 Passes the command @var{COMMAND} to a shell (see @code{system(3)}). If
8560 argument @var{STATUS} is present, it contains the value returned by
8561 @code{system(3)}, which is presumably 0 if the shell command succeeded.
8562 Note that which shell is used to invoke the command is system-dependent
8563 and environment-dependent.
8565 @item @emph{Standard}:
8571 @item @emph{Syntax}:
8572 @code{CALL SYSTEM(COMMAND [, STATUS])}
8574 @item @emph{Arguments}:
8575 @multitable @columnfractions .15 .70
8576 @item @var{COMMAND} @tab Shall be of default @code{CHARACTER} type.
8577 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
8580 @item @emph{See also}:
8586 @section @code{SYSTEM_CLOCK} --- Time function
8587 @cindex @code{SYSTEM_CLOCK} intrinsic
8588 @cindex time, current
8589 @cindex current time
8591 Intrinsic implemented, documentation pending.
8594 @item @emph{Description}:
8595 @item @emph{Standard}:
8601 @item @emph{Syntax}:
8602 @item @emph{Arguments}:
8603 @item @emph{Return value}:
8604 @item @emph{Example}:
8605 @item @emph{See also}:
8611 @section @code{TAN} --- Tangent function
8612 @cindex @code{TAN} intrinsic
8613 @cindex @code{DTAN} intrinsic
8614 @cindex trigonometric functions
8617 @item @emph{Description}:
8618 @code{TAN(X)} computes the tangent of @var{X}.
8620 @item @emph{Standard}:
8626 @item @emph{Syntax}:
8627 @code{RESULT = TAN(X)}
8629 @item @emph{Arguments}:
8630 @multitable @columnfractions .15 .70
8631 @item @var{X} @tab The type shall be @code{REAL(*)}.
8634 @item @emph{Return value}:
8635 The return value is of type @code{REAL(*)}. The kind type parameter is
8636 the same as @var{X}.
8638 @item @emph{Example}:
8641 real(8) :: x = 0.165_8
8643 end program test_tan
8646 @item @emph{Specific names}:
8647 @multitable @columnfractions .20 .20 .20 .25
8648 @item Name @tab Argument @tab Return type @tab Standard
8649 @item @code{DTAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
8652 @item @emph{See also}:
8659 @section @code{TANH} --- Hyperbolic tangent function
8660 @cindex @code{TANH} intrinsic
8661 @cindex @code{DTANH} intrinsic
8662 @cindex hyperbolic tangent
8665 @item @emph{Description}:
8666 @code{TANH(X)} computes the hyperbolic tangent of @var{X}.
8668 @item @emph{Standard}:
8674 @item @emph{Syntax}:
8677 @item @emph{Arguments}:
8678 @multitable @columnfractions .15 .70
8679 @item @var{X} @tab The type shall be @code{REAL(*)}.
8682 @item @emph{Return value}:
8683 The return value is of type @code{REAL(*)} and lies in the range
8684 @math{ - 1 \leq tanh(x) \leq 1 }.
8686 @item @emph{Example}:
8689 real(8) :: x = 2.1_8
8691 end program test_tanh
8694 @item @emph{Specific names}:
8695 @multitable @columnfractions .20 .20 .20 .25
8696 @item Name @tab Argument @tab Return type @tab Standard
8697 @item @code{DTANH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
8700 @item @emph{See also}:
8707 @section @code{TIME} --- Time function
8708 @cindex @code{TIME} intrinsic
8709 @cindex time, current
8710 @cindex current time
8713 @item @emph{Description}:
8714 Returns the current time encoded as an integer (in the manner of the
8715 UNIX function @code{time(3)}). This value is suitable for passing to
8716 @code{CTIME()}, @code{GMTIME()}, and @code{LTIME()}.
8718 This intrinsic is not fully portable, such as to systems with 32-bit
8719 @code{INTEGER} types but supporting times wider than 32 bits. Therefore,
8720 the values returned by this intrinsic might be, or become, negative, or
8721 numerically less than previous values, during a single run of the
8724 See @ref{TIME8}, for information on a similar intrinsic that might be
8725 portable to more GNU Fortran implementations, though to fewer Fortran
8728 @item @emph{Standard}:
8732 Non-elemental function
8734 @item @emph{Syntax}:
8735 @code{RESULT = TIME()}
8737 @item @emph{Return value}:
8738 The return value is a scalar of type @code{INTEGER(4)}.
8740 @item @emph{See also}:
8741 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{TIME8}
8748 @section @code{TIME8} --- Time function (64-bit)
8749 @cindex @code{TIME8} intrinsic
8750 @cindex time, current
8751 @cindex current time
8754 @item @emph{Description}:
8755 Returns the current time encoded as an integer (in the manner of the
8756 UNIX function @code{time(3)}). This value is suitable for passing to
8757 @code{CTIME()}, @code{GMTIME()}, and @code{LTIME()}.
8759 @emph{Warning:} this intrinsic does not increase the range of the timing
8760 values over that returned by @code{time(3)}. On a system with a 32-bit
8761 @code{time(3)}, @code{TIME8()} will return a 32-bit value, even though
8762 it is converted to a 64-bit @code{INTEGER(8)} value. That means
8763 overflows of the 32-bit value can still occur. Therefore, the values
8764 returned by this intrinsic might be or become negative or numerically
8765 less than previous values during a single run of the compiled program.
8767 @item @emph{Standard}:
8771 Non-elemental function
8773 @item @emph{Syntax}:
8774 @code{RESULT = TIME8()}
8776 @item @emph{Return value}:
8777 The return value is a scalar of type @code{INTEGER(8)}.
8779 @item @emph{See also}:
8780 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{TIME}
8787 @section @code{TINY} --- Smallest positive number of a real kind
8788 @cindex @code{TINY} intrinsic
8792 @item @emph{Description}:
8793 @code{TINY(X)} returns the smallest positive (non zero) number
8794 in the model of the type of @code{X}.
8796 @item @emph{Standard}:
8802 @item @emph{Syntax}:
8803 @code{RESULT = TINY(X)}
8805 @item @emph{Arguments}:
8806 @multitable @columnfractions .15 .70
8807 @item @var{X} @tab shall be of type @code{REAL}.
8810 @item @emph{Return value}:
8811 The return value is of the same type and kind as @var{X}
8813 @item @emph{Example}:
8814 See @code{HUGE} for an example.
8820 @section @code{TRANSFER} --- Transfer bit patterns
8821 @cindex @code{TRANSFER} intrinsic
8822 @cindex bit operations
8824 Intrinsic implemented, documentation pending.
8827 @item @emph{Description}:
8828 @item @emph{Standard}:
8832 Transformational function
8834 @item @emph{Syntax}:
8835 @item @emph{Arguments}:
8836 @item @emph{Return value}:
8837 @item @emph{Example}:
8838 @item @emph{See also}:
8844 @section @code{TRANSPOSE} --- Transpose an array of rank two
8845 @cindex @code{TRANSPOSE} intrinsic
8846 @cindex matrix manipulation
8848 Intrinsic implemented, documentation pending.
8851 @item @emph{Description}:
8852 @item @emph{Standard}:
8856 Transformational function
8858 @item @emph{Syntax}:
8859 @item @emph{Arguments}:
8860 @item @emph{Return value}:
8861 @item @emph{Example}:
8862 @item @emph{See also}:
8868 @section @code{TRIM} --- Function to remove trailing blank characters of a string
8869 @cindex @code{TRIM} intrinsic
8870 @cindex string manipulation
8872 Intrinsic implemented, documentation pending.
8875 @item @emph{Description}:
8876 @item @emph{Standard}:
8880 Transformational function
8882 @item @emph{Syntax}:
8883 @item @emph{Arguments}:
8884 @item @emph{Return value}:
8885 @item @emph{Example}:
8886 @item @emph{See also}:
8892 @section @code{TTYNAM} --- Get the name of a terminal device.
8893 @cindex @code{TTYNAM} intrinsic
8896 @item @emph{Description}:
8897 Get the name of a terminal device. For more information,
8898 see @code{ttyname(3)}.
8900 This intrinsic is provided in both subroutine and function forms;
8901 however, only one form can be used in any given program unit.
8903 @item @emph{Standard}:
8907 Subroutine, non-elemental function
8909 @item @emph{Syntax}:
8910 @multitable @columnfractions .80
8911 @item @code{CALL TTYNAM(UNIT, NAME)}
8912 @item @code{NAME = TTYNAM(UNIT)}
8915 @item @emph{Arguments}:
8916 @multitable @columnfractions .15 .70
8917 @item @var{UNIT} @tab Shall be a scalar @code{INTEGER(*)}.
8918 @item @var{NAME} @tab Shall be of type @code{CHARACTER(*)}.
8921 @item @emph{Example}:
8926 IF (isatty(unit=unit)) write(*,*) ttynam(unit)
8931 @item @emph{See also}:
8938 @section @code{UBOUND} --- Upper dimension bounds of an array
8939 @cindex @code{UBOUND} intrinsic
8942 @item @emph{Description}:
8943 Returns the upper bounds of an array, or a single upper bound
8944 along the @var{DIM} dimension.
8945 @item @emph{Standard}:
8951 @item @emph{Syntax}:
8952 @code{RESULT = UBOUND(ARRAY [, DIM])}
8954 @item @emph{Arguments}:
8955 @multitable @columnfractions .15 .70
8956 @item @var{ARRAY} @tab Shall be an array, of any type.
8957 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER(*)}.
8960 @item @emph{Return value}:
8961 If @var{DIM} is absent, the result is an array of the upper bounds of
8962 @var{ARRAY}. If @var{DIM} is present, the result is a scalar
8963 corresponding to the upper bound of the array along that dimension. If
8964 @var{ARRAY} is an expression rather than a whole array or array
8965 structure component, or if it has a zero extent along the relevant
8966 dimension, the upper bound is taken to be the number of elements along
8967 the relevant dimension.
8969 @item @emph{See also}:
8976 @section @code{UMASK} --- Set the file creation mask
8977 @cindex @code{UMASK} intrinsic
8978 @cindex file system operations
8981 @item @emph{Description}:
8982 Sets the file creation mask to @var{MASK} and returns the old value in
8983 argument @var{OLD} if it is supplied. See @code{umask(2)}.
8985 @item @emph{Standard}:
8991 @item @emph{Syntax}:
8992 @code{CALL UMASK(MASK [, OLD])}
8994 @item @emph{Arguments}:
8995 @multitable @columnfractions .15 .70
8996 @item @var{MASK} @tab Shall be a scalar of type @code{INTEGER(*)}.
8997 @item @var{MASK} @tab (Optional) Shall be a scalar of type
9006 @section @code{UNLINK} --- Remove a file from the file system
9007 @cindex @code{UNLINK} intrinsic
9008 @cindex file system operations
9011 @item @emph{Description}:
9012 Unlinks the file @var{PATH}. A null character (@code{CHAR(0)}) can be
9013 used to mark the end of the name in @var{PATH}; otherwise, trailing
9014 blanks in the file name are ignored. If the @var{STATUS} argument is
9015 supplied, it contains 0 on success or a nonzero error code upon return;
9016 see @code{unlink(2)}.
9018 @item @emph{Standard}:
9024 @item @emph{Syntax}:
9025 @code{CALL UNLINK(PATH [, STATUS])}
9027 @item @emph{Arguments}:
9028 @multitable @columnfractions .15 .70
9029 @item @var{PATH} @tab Shall be of default @code{CHARACTER} type.
9030 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
9033 @item @emph{See also}:
9034 @ref{LINK}, @ref{SYMLNK}
9040 @section @code{UNPACK} --- Unpack an array of rank one into an array
9041 @cindex @code{UNPACK} intrinsic
9042 @cindex array manipulation
9044 Intrinsic implemented, documentation pending.
9047 @item @emph{Description}:
9048 @item @emph{Standard}:
9052 Transformational function
9054 @item @emph{Syntax}:
9055 @item @emph{Arguments}:
9056 @item @emph{Return value}:
9057 @item @emph{Example}:
9059 @item @emph{See also}:
9066 @section @code{VERIFY} --- Scan a string for the absence of a set of characters
9067 @cindex @code{VERIFY} intrinsic
9068 @cindex string manipulation
9070 Intrinsic implemented, documentation pending.
9073 @item @emph{Description}:
9074 @item @emph{Standard}:
9080 @item @emph{Syntax}:
9081 @item @emph{Arguments}:
9082 @item @emph{Return value}:
9083 @item @emph{Example}:
9084 @item @emph{Specific names}:
9085 @item @emph{See also}:
9091 @section @code{XOR} --- Bitwise logical exclusive OR
9092 @cindex @code{XOR} intrinsic
9093 @cindex bit operations
9096 @item @emph{Description}:
9097 Bitwise logical exclusive or.
9099 This intrinsic routine is provided for backwards compatibility with
9100 GNU Fortran 77. For integer arguments, programmers should consider
9101 the use of the @ref{IEOR} intrinsic defined by the Fortran standard.
9103 @item @emph{Standard}:
9107 Non-elemental function
9109 @item @emph{Syntax}:
9110 @code{RESULT = XOR(X, Y)}
9112 @item @emph{Arguments}:
9113 @multitable @columnfractions .15 .70
9114 @item @var{X} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
9115 @item @var{Y} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
9118 @item @emph{Return value}:
9119 The return type is either @code{INTEGER(*)} or @code{LOGICAL}
9120 after cross-promotion of the arguments.
9122 @item @emph{Example}:
9125 LOGICAL :: T = .TRUE., F = .FALSE.
9127 DATA a / Z,'F' /, b / Z'3' /
9129 WRITE (*,*) XOR(T, T), XOR(T, F), XOR(F, T), XOR(F, F)
9130 WRITE (*,*) XOR(a, b)
9134 @item @emph{See also}:
9135 F95 elemental function: @ref{IEOR}