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{GETARG}: GETARG, Get command line arguments
129 * @code{GET_COMMAND}: GET_COMMAND, Get the entire command line
130 * @code{GET_COMMAND_ARGUMENT}: GET_COMMAND_ARGUMENT, Get command line arguments
131 * @code{GETCWD}: GETCWD, Get current working directory
132 * @code{GETENV}: GETENV, Get an environmental variable
133 * @code{GET_ENVIRONMENT_VARIABLE}: GET_ENVIRONMENT_VARIABLE, Get an environmental variable
134 * @code{GETGID}: GETGID, Group ID function
135 * @code{GETLOG}: GETLOG, Get login name
136 * @code{GETPID}: GETPID, Process ID function
137 * @code{GETUID}: GETUID, User ID function
138 * @code{GMTIME}: GMTIME, Convert time to GMT info
139 * @code{HOSTNM}: HOSTNM, Get system host name
140 * @code{HUGE}: HUGE, Largest number of a kind
141 * @code{IACHAR}: IACHAR, Code in @acronym{ASCII} collating sequence
142 * @code{IAND}: IAND, Bitwise logical and
143 * @code{IARGC}: IARGC, Get the number of command line arguments
144 * @code{IBCLR}: IBCLR, Clear bit
145 * @code{IBITS}: IBITS, Bit extraction
146 * @code{IBSET}: IBSET, Set bit
147 * @code{ICHAR}: ICHAR, Character-to-integer conversion function
148 * @code{IDATE}: IDATE, Current local time (day/month/year)
149 * @code{IEOR}: IEOR, Bitwise logical exclusive or
150 * @code{IERRNO}: IERRNO, Function to get the last system error number
151 * @code{INDEX}: INDEX, Position of a substring within a string
152 * @code{INT}: INT, Convert to integer type
153 * @code{IOR}: IOR, Bitwise logical or
154 * @code{IRAND}: IRAND, Integer pseudo-random number
155 * @code{ISHFT}: ISHFT, Shift bits
156 * @code{ISHFTC}: ISHFTC, Shift bits circularly
157 * @code{ITIME}: ITIME, Current local time (hour/minutes/seconds)
158 * @code{KILL}: KILL, Send a signal to a process
159 * @code{KIND}: KIND, Kind of an entity
160 * @code{LBOUND}: LBOUND, Lower dimension bounds of an array
161 * @code{LEN}: LEN, Length of a character entity
162 * @code{LEN_TRIM}: LEN_TRIM, Length of a character entity without trailing blank characters
163 * @code{LGE}: LGE, Lexical greater than or equal
164 * @code{LGT}: LGT, Lexical greater than
165 * @code{LINK}: LINK, Create a hard link
166 * @code{LLE}: LLE, Lexical less than or equal
167 * @code{LLT}: LLT, Lexical less than
168 * @code{LNBLNK}: LNBLNK, Index of the last non-blank character in a string
169 * @code{LOC}: LOC, Returns the address of a variable
170 * @code{LOG}: LOG, Logarithm function
171 * @code{LOG10}: LOG10, Base 10 logarithm function
172 * @code{LOGICAL}: LOGICAL, Convert to logical type
173 * @code{LSHIFT}: LSHIFT, Left shift bits
174 * @code{LSTAT}: LSTAT, Get file status
175 * @code{LTIME}: LTIME, Convert time to local time info
176 * @code{MALLOC}: MALLOC, Dynamic memory allocation function
177 * @code{MATMUL}: MATMUL, matrix multiplication
178 * @code{MAX}: MAX, Maximum value of an argument list
179 * @code{MAXEXPONENT}: MAXEXPONENT, Maximum exponent of a real kind
180 * @code{MAXLOC}: MAXLOC, Location of the maximum value within an array
181 * @code{MAXVAL}: MAXVAL, Maximum value of an array
182 * @code{MERGE}: MERGE, Merge arrays
183 * @code{MIN}: MIN, Minimum value of an argument list
184 * @code{MINEXPONENT}: MINEXPONENT, Minimum exponent of a real kind
185 * @code{MINLOC}: MINLOC, Location of the minimum value within an array
186 * @code{MINVAL}: MINVAL, Minimum value of an array
187 * @code{MOD}: MOD, Remainder function
188 * @code{MODULO}: MODULO, Modulo function
189 * @code{MOVE_ALLOC}: MOVE_ALLOC, Move allocation from one object to another
190 * @code{MVBITS}: MVBITS, Move bits from one integer to another
191 * @code{NEAREST}: NEAREST, Nearest representable number
192 * @code{NEW_LINE}: NEW_LINE, New line character
193 * @code{NINT}: NINT, Nearest whole number
194 * @code{NOT}: NOT, Logical negation
195 * @code{NULL}: NULL, Function that returns an disassociated pointer
196 * @code{OR}: OR, Bitwise logical OR
197 * @code{PACK}: PACK, Pack an array into an array of rank one
198 * @code{PERROR}: PERROR, Print system error message
199 * @code{PRECISION}: PRECISION, Decimal precision of a real kind
200 * @code{PRESENT}: PRESENT, Determine whether an optional argument is specified
201 * @code{PRODUCT}: PRODUCT, Product of array elements
202 * @code{RADIX}: RADIX, Base of a data model
203 * @code{RANDOM_NUMBER}: RANDOM_NUMBER, Pseudo-random number
204 * @code{RANDOM_SEED}: RANDOM_SEED, Initialize a pseudo-random number sequence
205 * @code{RAND}: RAND, Real pseudo-random number
206 * @code{RANGE}: RANGE, Decimal exponent range of a real kind
207 * @code{RAN}: RAN, Real pseudo-random number
208 * @code{REAL}: REAL, Convert to real type
209 * @code{RENAME}: RENAME, Rename a file
210 * @code{REPEAT}: REPEAT, Repeated string concatenation
211 * @code{RESHAPE}: RESHAPE, Function to reshape an array
212 * @code{RRSPACING}: RRSPACING, Reciprocal of the relative spacing
213 * @code{RSHIFT}: RSHIFT, Right shift bits
214 * @code{SCALE}: SCALE, Scale a real value
215 * @code{SCAN}: SCAN, Scan a string for the presence of a set of characters
216 * @code{SECNDS}: SECNDS, Time function
217 @comment * @code{SECOND}: SECOND, (?)
218 @comment * @code{SECONDS}: SECONDS, (?)
219 * @code{SELECTED_INT_KIND}: SELECTED_INT_KIND, Choose integer kind
220 * @code{SELECTED_REAL_KIND}: SELECTED_REAL_KIND, Choose real kind
221 * @code{SET_EXPONENT}: SET_EXPONENT, Set the exponent of the model
222 * @code{SHAPE}: SHAPE, Determine the shape of an array
223 * @code{SIGN}: SIGN, Sign copying function
224 * @code{SIGNAL}: SIGNAL, Signal handling subroutine (or function)
225 * @code{SIN}: SIN, Sine function
226 * @code{SINH}: SINH, Hyperbolic sine function
227 * @code{SIZE}: SIZE, Function to determine the size of an array
228 * @code{SLEEP}: SLEEP, Sleep for the specified number of seconds
229 * @code{SNGL}: SNGL, Convert double precision real to default real
230 * @code{SPACING}: SPACING, Smallest distance between two numbers of a given type
231 * @code{SPREAD}: SPREAD, Add a dimension to an array
232 * @code{SQRT}: SQRT, Square-root function
233 * @code{SRAND}: SRAND, Reinitialize the random number generator
234 * @code{STAT}: STAT, Get file status
235 * @code{SUM}: SUM, Sum of array elements
236 * @code{SYMLNK}: SYMLNK, Create a symbolic link
237 * @code{SYSTEM}: SYSTEM, Execute a shell command
238 * @code{SYSTEM_CLOCK}: SYSTEM_CLOCK, Time function
239 * @code{TAN}: TAN, Tangent function
240 * @code{TANH}: TANH, Hyperbolic tangent function
241 * @code{TIME}: TIME, Time function
242 * @code{TIME8}: TIME8, Time function (64-bit)
243 * @code{TINY}: TINY, Smallest positive number of a real kind
244 * @code{TRANSFER}: TRANSFER, Transfer bit patterns
245 * @code{TRANSPOSE}: TRANSPOSE, Transpose an array of rank two
246 * @code{TRIM}: TRIM, Function to remove trailing blank characters of a string
247 * @code{UBOUND}: UBOUND, Upper dimension bounds of an array
248 * @code{UMASK}: UMASK, Set the file creation mask
249 * @code{UNLINK}: UNLINK, Remove a file from the file system
250 * @code{UNPACK}: UNPACK, Unpack an array of rank one into an array
251 * @code{VERIFY}: VERIFY, Scan a string for the absence of a set of characters
252 * @code{XOR}: XOR, Bitwise logical exclusive or
255 @node Introduction to Intrinsics
256 @section Introduction to intrinsic procedures
258 The intrinsic procedures provided by GNU Fortran include all of the
259 intrinsic procedures required by the Fortran 95 standard, a set of
260 intrinsic procedures for backwards compatibility with G77, and a small
261 selection of intrinsic procedures from the Fortran 2003 standard. Any
262 conflict between a description here and a description in either the
263 Fortran 95 standard or the Fortran 2003 standard is unintentional, and
264 the standard(s) should be considered authoritative.
266 The enumeration of the @code{KIND} type parameter is processor defined in
267 the Fortran 95 standard. GNU Fortran defines the default integer type and
268 default real type by @code{INTEGER(KIND=4)} and @code{REAL(KIND=4)},
269 respectively. The standard mandates that both data types shall have
270 another kind, which have more precision. On typical target architectures
271 supported by @command{gfortran}, this kind type parameter is @code{KIND=8}.
272 Hence, @code{REAL(KIND=8)} and @code{DOUBLE PRECISION} are equivalent.
273 In the description of generic intrinsic procedures, the kind type parameter
274 will be specified by @code{KIND=*}, and in the description of specific
275 names for an intrinsic procedure the kind type parameter will be explicitly
276 given (e.g., @code{REAL(KIND=4)} or @code{REAL(KIND=8)}). Finally, for
277 brevity the optional @code{KIND=} syntax will be omitted.
279 Many of the intrinsic procedures take one or more optional arguments.
280 This document follows the convention used in the Fortran 95 standard,
281 and denotes such arguments by square brackets.
283 GNU Fortran offers the @option{-std=f95} and @option{-std=gnu} options,
284 which can be used to restrict the set of intrinsic procedures to a
285 given standard. By default, @command{gfortran} sets the @option{-std=gnu}
286 option, and so all intrinsic procedures described here are accepted. There
287 is one caveat. For a select group of intrinsic procedures, @command{g77}
288 implemented both a function and a subroutine. Both classes
289 have been implemented in @command{gfortran} for backwards compatibility
290 with @command{g77}. It is noted here that these functions and subroutines
291 cannot be intermixed in a given subprogram. In the descriptions that follow,
292 the applicable standard for each intrinsic procedure is noted.
297 @section @code{ABORT} --- Abort the program
298 @cindex @code{ABORT} intrinsic
302 @item @emph{Description}:
303 @code{ABORT} causes immediate termination of the program. On operating
304 systems that support a core dump, @code{ABORT} will produce a core dump,
305 which is suitable for debugging purposes.
307 @item @emph{Standard}:
311 non-elemental subroutine
316 @item @emph{Return value}:
319 @item @emph{Example}:
322 integer :: i = 1, j = 2
323 if (i /= j) call abort
324 end program test_abort
327 @item @emph{See also}:
328 @ref{EXIT}, @ref{KILL}
334 @section @code{ABS} --- Absolute value
335 @cindex @code{ABS} intrinsic
336 @cindex @code{CABS} intrinsic
337 @cindex @code{DABS} intrinsic
338 @cindex @code{IABS} intrinsic
339 @cindex @code{ZABS} intrinsic
340 @cindex @code{CDABS} intrinsic
341 @cindex absolute value
344 @item @emph{Description}:
345 @code{ABS(X)} computes the absolute value of @code{X}.
347 @item @emph{Standard}:
348 F77 and later, has overloads that are GNU extensions
354 @code{RESULT = ABS(X)}
356 @item @emph{Arguments}:
357 @multitable @columnfractions .15 .80
358 @item @var{X} @tab The type of the argument shall be an @code{INTEGER(*)},
359 @code{REAL(*)}, or @code{COMPLEX(*)}.
362 @item @emph{Return value}:
363 The return value is of the same type and
364 kind as the argument except the return value is @code{REAL(*)} for a
365 @code{COMPLEX(*)} argument.
367 @item @emph{Example}:
372 complex :: z = (-1.e0,0.e0)
379 @item @emph{Specific names}:
380 @multitable @columnfractions .20 .20 .20 .40
381 @item Name @tab Argument @tab Return type @tab Standard
382 @item @code{CABS(Z)} @tab @code{COMPLEX(4) Z} @tab @code{REAL(4)} @tab F77 and later
383 @item @code{DABS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
384 @item @code{IABS(I)} @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)} @tab F77 and later
385 @item @code{ZABS(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
386 @item @code{CDABS(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
392 @section @code{ACCESS} --- Checks file access modes
393 @cindex @code{ACCESS}
394 @cindex file system operations
397 @item @emph{Description}:
398 @code{ACCESS(NAME, MODE)} checks whether the file @var{NAME}
399 exists, is readable, writable or executable. Except for the
400 executable check, @code{ACCESS} can be replaced by
401 Fortran 95's @code{INQUIRE}.
403 @item @emph{Standard}:
410 @code{RESULT = ACCESS(NAME, MODE)}
412 @item @emph{Arguments}:
413 @multitable @columnfractions .15 .80
414 @item @var{NAME} @tab Scalar @code{CHARACTER} with the file name.
415 Tailing blank are ignored unless the character @code{achar(0)} is
416 present, then all characters up to and excluding @code{achar(0)} are
418 @item @var{MODE} @tab Scalar @code{CHARACTER} with the file access mode,
419 may be any concatenation of @code{"r"} (readable), @code{"w"} (writable)
420 and @code{"x"} (executable), or @code{" "} to check for existence.
423 @item @emph{Return value}:
424 Returns a scalar @code{INTEGER}, which is @code{0} if the file is
425 accessible in the given mode; otherwise or if an invalid argument
426 has been given for @code{MODE} the value @code{1} is returned.
428 @item @emph{Example}:
432 character(len=*), parameter :: file = 'test.dat'
433 character(len=*), parameter :: file2 = 'test.dat '//achar(0)
434 if(access(file,' ') == 0) print *, trim(file),' is exists'
435 if(access(file,'r') == 0) print *, trim(file),' is readable'
436 if(access(file,'w') == 0) print *, trim(file),' is writable'
437 if(access(file,'x') == 0) print *, trim(file),' is executable'
438 if(access(file2,'rwx') == 0) &
439 print *, trim(file2),' is readable, writable and executable'
440 end program access_test
442 @item @emph{Specific names}:
443 @item @emph{See also}:
449 @section @code{ACHAR} --- Character in @acronym{ASCII} collating sequence
450 @cindex @code{ACHAR} intrinsic
451 @cindex @acronym{ASCII} collating sequence
454 @item @emph{Description}:
455 @code{ACHAR(I)} returns the character located at position @code{I}
456 in the @acronym{ASCII} collating sequence.
458 @item @emph{Standard}:
465 @code{RESULT = ACHAR(I)}
467 @item @emph{Arguments}:
468 @multitable @columnfractions .15 .80
469 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
472 @item @emph{Return value}:
473 The return value is of type @code{CHARACTER} with a length of one. The
474 kind type parameter is the same as @code{KIND('A')}.
476 @item @emph{Example}:
481 end program test_achar
484 @item @emph{See also}:
485 @ref{CHAR}, @ref{IACHAR}, @ref{ICHAR}
492 @section @code{ACOS} --- Arccosine function
493 @cindex @code{ACOS} intrinsic
494 @cindex @code{DACOS} intrinsic
495 @cindex trigonometric functions (inverse)
498 @item @emph{Description}:
499 @code{ACOS(X)} computes the arccosine of @var{X} (inverse of @code{COS(X)}).
501 @item @emph{Standard}:
508 @code{RESULT = ACOS(X)}
510 @item @emph{Arguments}:
511 @multitable @columnfractions .15 .80
512 @item @var{X} @tab The type shall be @code{REAL(*)} with a magnitude that is
516 @item @emph{Return value}:
517 The return value is of type @code{REAL(*)} and it lies in the
518 range @math{ 0 \leq \acos(x) \leq \pi}. The kind type parameter
519 is the same as @var{X}.
521 @item @emph{Example}:
524 real(8) :: x = 0.866_8
526 end program test_acos
529 @item @emph{Specific names}:
530 @multitable @columnfractions .20 .20 .20 .40
531 @item Name @tab Argument @tab Return type @tab Standard
532 @item @code{DACOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
535 @item @emph{See also}:
536 Inverse function: @ref{COS}
542 @section @code{ACOSH} --- Hyperbolic arccosine function
543 @cindex @code{ACOSH} intrinsic
544 @cindex hyperbolic arccosine
545 @cindex hyperbolic cosine (inverse)
548 @item @emph{Description}:
549 @code{ACOSH(X)} computes the area hyperbolic cosine of @var{X} (inverse of @code{COSH(X)}).
551 @item @emph{Standard}:
558 @code{RESULT = ACOSH(X)}
560 @item @emph{Arguments}:
561 @multitable @columnfractions .15 .80
562 @item @var{X} @tab The type shall be @code{REAL(*)} with a magnitude that is
563 greater or equal to one.
566 @item @emph{Return value}:
567 The return value is of type @code{REAL(*)} and it lies in the
568 range @math{0 \leq \acosh (x) \leq \infty}.
570 @item @emph{Example}:
573 REAL(8), DIMENSION(3) :: x = (/ 1.0, 2.0, 3.0 /)
578 @item @emph{See also}:
579 Inverse function: @ref{COSH}
585 @section @code{ADJUSTL} --- Left adjust a string
586 @cindex @code{ADJUSTL} intrinsic
587 @cindex adjust string
590 @item @emph{Description}:
591 @code{ADJUSTL(STR)} will left adjust a string by removing leading spaces.
592 Spaces are inserted at the end of the string as needed.
594 @item @emph{Standard}:
601 @code{RESULT = ADJUSTL(STR)}
603 @item @emph{Arguments}:
604 @multitable @columnfractions .15 .80
605 @item @var{STR} @tab The type shall be @code{CHARACTER}.
608 @item @emph{Return value}:
609 The return value is of type @code{CHARACTER} where leading spaces
610 are removed and the same number of spaces are inserted on the end
613 @item @emph{Example}:
616 character(len=20) :: str = ' gfortran'
619 end program test_adjustl
626 @section @code{ADJUSTR} --- Right adjust a string
627 @cindex @code{ADJUSTR} intrinsic
628 @cindex adjust string
631 @item @emph{Description}:
632 @code{ADJUSTR(STR)} will right adjust a string by removing trailing spaces.
633 Spaces are inserted at the start of the string as needed.
635 @item @emph{Standard}:
642 @code{RESULT = ADJUSTR(STR)}
644 @item @emph{Arguments}:
645 @multitable @columnfractions .15 .80
646 @item @var{STR} @tab The type shall be @code{CHARACTER}.
649 @item @emph{Return value}:
650 The return value is of type @code{CHARACTER} where trailing spaces
651 are removed and the same number of spaces are inserted at the start
654 @item @emph{Example}:
657 character(len=20) :: str = 'gfortran'
660 end program test_adjustr
667 @section @code{AIMAG} --- Imaginary part of complex number
668 @cindex @code{AIMAG} intrinsic
669 @cindex @code{DIMAG} intrinsic
670 @cindex @code{IMAG} intrinsic
671 @cindex @code{IMAGPART} intrinsic
672 @cindex imaginary part of a complex number
675 @item @emph{Description}:
676 @code{AIMAG(Z)} yields the imaginary part of complex argument @code{Z}.
677 The @code{IMAG(Z)} and @code{IMAGPART(Z)} intrinsic functions are provided
678 for compatibility with @command{g77}, and their use in new code is
679 strongly discouraged.
681 @item @emph{Standard}:
682 F77 and later, has overloads that are GNU extensions
688 @code{RESULT = AIMAG(Z)}
690 @item @emph{Arguments}:
691 @multitable @columnfractions .15 .80
692 @item @var{Z} @tab The type of the argument shall be @code{COMPLEX(*)}.
695 @item @emph{Return value}:
696 The return value is of type real with the
697 kind type parameter of the argument.
699 @item @emph{Example}:
704 z4 = cmplx(1.e0_4, 0.e0_4)
705 z8 = cmplx(0.e0_8, 1.e0_8)
706 print *, aimag(z4), dimag(z8)
707 end program test_aimag
710 @item @emph{Specific names}:
711 @multitable @columnfractions .20 .20 .20 .40
712 @item Name @tab Argument @tab Return type @tab Standard
713 @item @code{DIMAG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{REAL(8)} @tab GNU extension
714 @item @code{IMAG(Z)} @tab @code{COMPLEX(*) Z} @tab @code{REAL(*)} @tab GNU extension
715 @item @code{IMAGPART(Z)} @tab @code{COMPLEX(*) Z} @tab @code{REAL(*)} @tab GNU extension
722 @section @code{AINT} --- Truncate to a whole number
723 @cindex @code{AINT} intrinsic
724 @cindex @code{DINT} intrinsic
728 @item @emph{Description}:
729 @code{AINT(X [, KIND])} truncates its argument to a whole number.
731 @item @emph{Standard}:
738 @code{RESULT = AINT(X [, KIND])}
740 @item @emph{Arguments}:
741 @multitable @columnfractions .15 .80
742 @item @var{X} @tab The type of the argument shall be @code{REAL(*)}.
743 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
744 expression indicating the kind parameter of
748 @item @emph{Return value}:
749 The return value is of type real with the kind type parameter of the
750 argument if the optional @var{KIND} is absent; otherwise, the kind
751 type parameter will be given by @var{KIND}. If the magnitude of
752 @var{X} is less than one, then @code{AINT(X)} returns zero. If the
753 magnitude is equal to or greater than one, then it returns the largest
754 whole number that does not exceed its magnitude. The sign is the same
755 as the sign of @var{X}.
757 @item @emph{Example}:
764 print *, aint(x4), dint(x8)
766 end program test_aint
769 @item @emph{Specific names}:
770 @multitable @columnfractions .20 .20 .20 .40
771 @item Name @tab Argument @tab Return type @tab Standard
772 @item @code{DINT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
779 @section @code{ALARM} --- Execute a routine after a given delay
780 @cindex @code{ALARM} intrinsic
783 @item @emph{Description}:
784 @code{ALARM(SECONDS, HANDLER [, STATUS])} causes external subroutine @var{HANDLER}
785 to be executed after a delay of @var{SECONDS} by using @code{alarm(1)} to
786 set up a signal and @code{signal(2)} to catch it. If @var{STATUS} is
787 supplied, it will be returned with the number of seconds remaining until
788 any previously scheduled alarm was due to be delivered, or zero if there
789 was no previously scheduled alarm.
791 @item @emph{Standard}:
798 @code{CALL ALARM(SECONDS, HANDLER [, STATUS])}
800 @item @emph{Arguments}:
801 @multitable @columnfractions .15 .80
802 @item @var{SECONDS} @tab The type of the argument shall be a scalar
803 @code{INTEGER}. It is @code{INTENT(IN)}.
804 @item @var{HANDLER} @tab Signal handler (@code{INTEGER FUNCTION} or
805 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar.
806 @code{INTEGER}. It is @code{INTENT(IN)}.
807 @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
808 @code{INTEGER} variable. It is @code{INTENT(OUT)}.
811 @item @emph{Example}:
814 external handler_print
816 call alarm (3, handler_print, i)
819 end program test_alarm
821 This will cause the external routine @var{handler_print} to be called
828 @section @code{ALL} --- All values in @var{MASK} along @var{DIM} are true
829 @cindex @code{ALL} intrinsic
833 @item @emph{Description}:
834 @code{ALL(MASK [, DIM])} determines if all the values are true in @var{MASK}
835 in the array along dimension @var{DIM}.
837 @item @emph{Standard}:
841 transformational function
844 @code{RESULT = ALL(MASK [, DIM])}
846 @item @emph{Arguments}:
847 @multitable @columnfractions .15 .80
848 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL(*)} and
849 it shall not be scalar.
850 @item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer
851 with a value that lies between one and the rank of @var{MASK}.
854 @item @emph{Return value}:
855 @code{ALL(MASK)} returns a scalar value of type @code{LOGICAL(*)} where
856 the kind type parameter is the same as the kind type parameter of
857 @var{MASK}. If @var{DIM} is present, then @code{ALL(MASK, DIM)} returns
858 an array with the rank of @var{MASK} minus 1. The shape is determined from
859 the shape of @var{MASK} where the @var{DIM} dimension is elided.
863 @code{ALL(MASK)} is true if all elements of @var{MASK} are true.
864 It also is true if @var{MASK} has zero size; otherwise, it is false.
866 If the rank of @var{MASK} is one, then @code{ALL(MASK,DIM)} is equivalent
867 to @code{ALL(MASK)}. If the rank is greater than one, then @code{ALL(MASK,DIM)}
868 is determined by applying @code{ALL} to the array sections.
871 @item @emph{Example}:
875 l = all((/.true., .true., .true./))
880 integer a(2,3), b(2,3)
884 print *, all(a .eq. b, 1)
885 print *, all(a .eq. b, 2)
886 end subroutine section
894 @section @code{ALLOCATED} --- Status of an allocatable entity
895 @cindex @code{ALLOCATED} intrinsic
896 @cindex allocation status
899 @item @emph{Description}:
900 @code{ALLOCATED(X)} checks the status of whether @var{X} is allocated.
902 @item @emph{Standard}:
909 @code{RESULT = ALLOCATED(X)}
911 @item @emph{Arguments}:
912 @multitable @columnfractions .15 .80
913 @item @var{X} @tab The argument shall be an @code{ALLOCATABLE} array.
916 @item @emph{Return value}:
917 The return value is a scalar @code{LOGICAL} with the default logical
918 kind type parameter. If @var{X} is allocated, @code{ALLOCATED(X)}
919 is @code{.TRUE.}; otherwise, it returns the @code{.TRUE.}
921 @item @emph{Example}:
923 program test_allocated
925 real(4), allocatable :: x(:)
926 if (allocated(x) .eqv. .false.) allocate(x(i))
927 end program test_allocated
933 @section @code{AND} --- Bitwise logical AND
934 @cindex @code{AND} intrinsic
935 @cindex bit operations
938 @item @emph{Description}:
939 Bitwise logical @code{AND}.
941 This intrinsic routine is provided for backwards compatibility with
942 GNU Fortran 77. For integer arguments, programmers should consider
943 the use of the @ref{IAND} intrinsic defined by the Fortran standard.
945 @item @emph{Standard}:
949 Non-elemental function
952 @code{RESULT = AND(X, Y)}
954 @item @emph{Arguments}:
955 @multitable @columnfractions .15 .80
956 @item @var{X} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
957 @item @var{Y} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
960 @item @emph{Return value}:
961 The return type is either @code{INTEGER(*)} or @code{LOGICAL} after
962 cross-promotion of the arguments.
964 @item @emph{Example}:
967 LOGICAL :: T = .TRUE., F = ..FALSE.
969 DATA a / Z'F' /, b / Z'3' /
971 WRITE (*,*) AND(T, T), AND(T, F), AND(F, T), AND(F, F)
972 WRITE (*,*) AND(a, b)
976 @item @emph{See also}:
977 F95 elemental function: @ref{IAND}
983 @section @code{ANINT} --- Nearest whole number
984 @cindex @code{ANINT} intrinsic
985 @cindex @code{DNINT} intrinsic
989 @item @emph{Description}:
990 @code{ANINT(X [, KIND])} rounds its argument to the nearest whole number.
992 @item @emph{Standard}:
999 @code{RESULT = ANINT(X [, KIND])}
1001 @item @emph{Arguments}:
1002 @multitable @columnfractions .15 .80
1003 @item @var{X} @tab The type of the argument shall be @code{REAL(*)}.
1004 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
1005 expression indicating the kind parameter of
1009 @item @emph{Return value}:
1010 The return value is of type real with the kind type parameter of the
1011 argument if the optional @var{KIND} is absent; otherwise, the kind
1012 type parameter will be given by @var{KIND}. If @var{X} is greater than
1013 zero, then @code{ANINT(X)} returns @code{AINT(X+0.5)}. If @var{X} is
1014 less than or equal to zero, then it returns @code{AINT(X-0.5)}.
1016 @item @emph{Example}:
1023 print *, anint(x4), dnint(x8)
1025 end program test_anint
1028 @item @emph{Specific names}:
1029 @multitable @columnfractions .20 .20 .20 .40
1030 @item Name @tab Argument @tab Return type @tab Standard
1031 @item @code{DNINT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1038 @section @code{ANY} --- Any value in @var{MASK} along @var{DIM} is true
1039 @cindex @code{ANY} intrinsic
1043 @item @emph{Description}:
1044 @code{ANY(MASK [, DIM])} determines if any of the values in the logical array
1045 @var{MASK} along dimension @var{DIM} are @code{.TRUE.}.
1047 @item @emph{Standard}:
1051 transformational function
1053 @item @emph{Syntax}:
1054 @code{RESULT = ANY(MASK [, DIM])}
1056 @item @emph{Arguments}:
1057 @multitable @columnfractions .15 .80
1058 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL(*)} and
1059 it shall not be scalar.
1060 @item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer
1061 with a value that lies between one and the rank of @var{MASK}.
1064 @item @emph{Return value}:
1065 @code{ANY(MASK)} returns a scalar value of type @code{LOGICAL(*)} where
1066 the kind type parameter is the same as the kind type parameter of
1067 @var{MASK}. If @var{DIM} is present, then @code{ANY(MASK, DIM)} returns
1068 an array with the rank of @var{MASK} minus 1. The shape is determined from
1069 the shape of @var{MASK} where the @var{DIM} dimension is elided.
1073 @code{ANY(MASK)} is true if any element of @var{MASK} is true;
1074 otherwise, it is false. It also is false if @var{MASK} has zero size.
1076 If the rank of @var{MASK} is one, then @code{ANY(MASK,DIM)} is equivalent
1077 to @code{ANY(MASK)}. If the rank is greater than one, then @code{ANY(MASK,DIM)}
1078 is determined by applying @code{ANY} to the array sections.
1081 @item @emph{Example}:
1085 l = any((/.true., .true., .true./))
1090 integer a(2,3), b(2,3)
1094 print *, any(a .eq. b, 1)
1095 print *, any(a .eq. b, 2)
1096 end subroutine section
1097 end program test_any
1104 @section @code{ASIN} --- Arcsine function
1105 @cindex @code{ASIN} intrinsic
1106 @cindex @code{DASIN} intrinsic
1107 @cindex trigonometric functions (inverse)
1110 @item @emph{Description}:
1111 @code{ASIN(X)} computes the arcsine of its @var{X} (inverse of @code{SIN(X)}).
1113 @item @emph{Standard}:
1119 @item @emph{Syntax}:
1120 @code{RESULT = ASIN(X)}
1122 @item @emph{Arguments}:
1123 @multitable @columnfractions .15 .80
1124 @item @var{X} @tab The type shall be @code{REAL(*)}, and a magnitude that is
1128 @item @emph{Return value}:
1129 The return value is of type @code{REAL(*)} and it lies in the
1130 range @math{-\pi / 2 \leq \asin (x) \leq \pi / 2}. The kind type
1131 parameter is the same as @var{X}.
1133 @item @emph{Example}:
1136 real(8) :: x = 0.866_8
1138 end program test_asin
1141 @item @emph{Specific names}:
1142 @multitable @columnfractions .20 .20 .20 .40
1143 @item Name @tab Argument @tab Return type @tab Standard
1144 @item @code{DASIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1147 @item @emph{See also}:
1148 Inverse function: @ref{SIN}
1154 @section @code{ASINH} --- Hyperbolic arcsine function
1155 @cindex @code{ASINH} intrinsic
1156 @cindex hyperbolic arcsine
1157 @cindex hyperbolic sine (inverse)
1160 @item @emph{Description}:
1161 @code{ASINH(X)} computes the area hyperbolic sine of @var{X} (inverse of @code{SINH(X)}).
1163 @item @emph{Standard}:
1169 @item @emph{Syntax}:
1170 @code{RESULT = ASINH(X)}
1172 @item @emph{Arguments}:
1173 @multitable @columnfractions .15 .80
1174 @item @var{X} @tab The type shall be @code{REAL(*)}, with @var{X} a real number.
1177 @item @emph{Return value}:
1178 The return value is of type @code{REAL(*)} and it lies in the
1179 range @math{-\infty \leq \asinh (x) \leq \infty}.
1181 @item @emph{Example}:
1184 REAL(8), DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1185 WRITE (*,*) ASINH(x)
1189 @item @emph{See also}:
1190 Inverse function: @ref{SINH}
1196 @section @code{ASSOCIATED} --- Status of a pointer or pointer/target pair
1197 @cindex @code{ASSOCIATED} intrinsic
1198 @cindex pointer status
1201 @item @emph{Description}:
1202 @code{ASSOCIATED(PTR [, TGT])} determines the status of the pointer @var{PTR}
1203 or if @var{PTR} is associated with the target @var{TGT}.
1205 @item @emph{Standard}:
1211 @item @emph{Syntax}:
1212 @code{RESULT = ASSOCIATED(PTR [, TGT])}
1214 @item @emph{Arguments}:
1215 @multitable @columnfractions .15 .80
1216 @item @var{PTR} @tab @var{PTR} shall have the @code{POINTER} attribute and
1217 it can be of any type.
1218 @item @var{TGT} @tab (Optional) @var{TGT} shall be a @code{POINTER} or
1219 a @code{TARGET}. It must have the same type, kind type parameter, and
1220 array rank as @var{PTR}.
1222 The status of neither @var{PTR} nor @var{TGT} can be undefined.
1224 @item @emph{Return value}:
1225 @code{ASSOCIATED(PTR)} returns a scalar value of type @code{LOGICAL(4)}.
1226 There are several cases:
1228 @item (A) If the optional @var{TGT} is not present, then @code{ASSOCIATED(PTR)}
1229 is true if @var{PTR} is associated with a target; otherwise, it returns false.
1230 @item (B) If @var{TGT} is present and a scalar target, the result is true if
1232 is not a 0 sized storage sequence and the target associated with @var{PTR}
1233 occupies the same storage units. If @var{PTR} is disassociated, then the
1235 @item (C) If @var{TGT} is present and an array target, the result is true if
1236 @var{TGT} and @var{PTR} have the same shape, are not 0 sized arrays, are
1237 arrays whose elements are not 0 sized storage sequences, and @var{TGT} and
1238 @var{PTR} occupy the same storage units in array element order.
1239 As in case(B), the result is false, if @var{PTR} is disassociated.
1240 @item (D) If @var{TGT} is present and an scalar pointer, the result is true if
1241 target associated with @var{PTR} and the target associated with @var{TGT}
1242 are not 0 sized storage sequences and occupy the same storage units.
1243 The result is false, if either @var{TGT} or @var{PTR} is disassociated.
1244 @item (E) If @var{TGT} is present and an array pointer, the result is true if
1245 target associated with @var{PTR} and the target associated with @var{TGT}
1246 have the same shape, are not 0 sized arrays, are arrays whose elements are
1247 not 0 sized storage sequences, and @var{TGT} and @var{PTR} occupy the same
1248 storage units in array element order.
1249 The result is false, if either @var{TGT} or @var{PTR} is disassociated.
1252 @item @emph{Example}:
1254 program test_associated
1256 real, target :: tgt(2) = (/1., 2./)
1257 real, pointer :: ptr(:)
1259 if (associated(ptr) .eqv. .false.) call abort
1260 if (associated(ptr,tgt) .eqv. .false.) call abort
1261 end program test_associated
1264 @item @emph{See also}:
1271 @section @code{ATAN} --- Arctangent function
1272 @cindex @code{ATAN} intrinsic
1273 @cindex @code{DATAN} intrinsic
1274 @cindex trigonometric functions (inverse)
1277 @item @emph{Description}:
1278 @code{ATAN(X)} computes the arctangent of @var{X}.
1280 @item @emph{Standard}:
1286 @item @emph{Syntax}:
1287 @code{RESULT = ATAN(X)}
1289 @item @emph{Arguments}:
1290 @multitable @columnfractions .15 .80
1291 @item @var{X} @tab The type shall be @code{REAL(*)}.
1294 @item @emph{Return value}:
1295 The return value is of type @code{REAL(*)} and it lies in the
1296 range @math{ - \pi / 2 \leq \atan (x) \leq \pi / 2}.
1298 @item @emph{Example}:
1301 real(8) :: x = 2.866_8
1303 end program test_atan
1306 @item @emph{Specific names}:
1307 @multitable @columnfractions .20 .20 .20 .40
1308 @item Name @tab Argument @tab Return type @tab Standard
1309 @item @code{DATAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1312 @item @emph{See also}:
1313 Inverse function: @ref{TAN}
1320 @section @code{ATAN2} --- Arctangent function
1321 @cindex @code{ATAN2} intrinsic
1322 @cindex @code{DATAN2} intrinsic
1323 @cindex trigonometric functions (inverse)
1326 @item @emph{Description}:
1327 @code{ATAN2(Y,X)} computes the arctangent of the complex number @math{X + i Y}.
1329 @item @emph{Standard}:
1335 @item @emph{Syntax}:
1336 @code{RESULT = ATAN2(Y,X)}
1338 @item @emph{Arguments}:
1339 @multitable @columnfractions .15 .80
1340 @item @var{Y} @tab The type shall be @code{REAL(*)}.
1341 @item @var{X} @tab The type and kind type parameter shall be the same as @var{Y}.
1342 If @var{Y} is zero, then @var{X} must be nonzero.
1345 @item @emph{Return value}:
1346 The return value has the same type and kind type parameter as @var{Y}.
1347 It is the principal value of the complex number @math{X + i Y}. If
1348 @var{X} is nonzero, then it lies in the range @math{-\pi \le \atan (x) \leq \pi}.
1349 The sign is positive if @var{Y} is positive. If @var{Y} is zero, then
1350 the return value is zero if @var{X} is positive and @math{\pi} if @var{X}
1351 is negative. Finally, if @var{X} is zero, then the magnitude of the result
1354 @item @emph{Example}:
1357 real(4) :: x = 1.e0_4, y = 0.5e0_4
1359 end program test_atan2
1362 @item @emph{Specific names}:
1363 @multitable @columnfractions .20 .20 .20 .40
1364 @item Name @tab Argument @tab Return type @tab Standard
1365 @item @code{DATAN2(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1372 @section @code{ATANH} --- Hyperbolic arctangent function
1373 @cindex @code{ASINH} intrinsic
1374 @cindex hyperbolic arctangent
1375 @cindex hyperbolic tangent (inverse)
1378 @item @emph{Description}:
1379 @code{ATANH(X)} computes the area hyperbolic sine of @var{X} (inverse of @code{TANH(X)}).
1381 @item @emph{Standard}:
1387 @item @emph{Syntax}:
1388 @code{RESULT = ATANH(X)}
1390 @item @emph{Arguments}:
1391 @multitable @columnfractions .15 .80
1392 @item @var{X} @tab The type shall be @code{REAL(*)} with a magnitude
1393 that is less than or equal to one.
1396 @item @emph{Return value}:
1397 The return value is of type @code{REAL(*)} and it lies in the
1398 range @math{-\infty \leq \atanh(x) \leq \infty}.
1400 @item @emph{Example}:
1403 REAL, DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1404 WRITE (*,*) ATANH(x)
1408 @item @emph{See also}:
1409 Inverse function: @ref{TANH}
1416 @section @code{BESJ0} --- Bessel function of the first kind of order 0
1417 @cindex @code{BESJ0} intrinsic
1418 @cindex @code{DBESJ0} intrinsic
1422 @item @emph{Description}:
1423 @code{BESJ0(X)} computes the Bessel function of the first kind of order 0
1426 @item @emph{Standard}:
1432 @item @emph{Syntax}:
1433 @code{RESULT = BESJ0(X)}
1435 @item @emph{Arguments}:
1436 @multitable @columnfractions .15 .80
1437 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1440 @item @emph{Return value}:
1441 The return value is of type @code{REAL(*)} and it lies in the
1442 range @math{ - 0.4027... \leq Bessel (0,x) \leq 1}.
1444 @item @emph{Example}:
1447 real(8) :: x = 0.0_8
1449 end program test_besj0
1452 @item @emph{Specific names}:
1453 @multitable @columnfractions .20 .20 .20 .40
1454 @item Name @tab Argument @tab Return type @tab Standard
1455 @item @code{DBESJ0(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1462 @section @code{BESJ1} --- Bessel function of the first kind of order 1
1463 @cindex @code{BESJ1} intrinsic
1464 @cindex @code{DBESJ1} intrinsic
1468 @item @emph{Description}:
1469 @code{BESJ1(X)} computes the Bessel function of the first kind of order 1
1472 @item @emph{Standard}:
1478 @item @emph{Syntax}:
1479 @code{RESULT = BESJ1(X)}
1481 @item @emph{Arguments}:
1482 @multitable @columnfractions .15 .80
1483 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1486 @item @emph{Return value}:
1487 The return value is of type @code{REAL(*)} and it lies in the
1488 range @math{ - 0.5818... \leq Bessel (0,x) \leq 0.5818 }.
1490 @item @emph{Example}:
1493 real(8) :: x = 1.0_8
1495 end program test_besj1
1498 @item @emph{Specific names}:
1499 @multitable @columnfractions .20 .20 .20 .40
1500 @item Name @tab Argument @tab Return type @tab Standard
1501 @item @code{DBESJ1(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1508 @section @code{BESJN} --- Bessel function of the first kind
1509 @cindex @code{BESJN} intrinsic
1510 @cindex @code{DBESJN} intrinsic
1514 @item @emph{Description}:
1515 @code{BESJN(N, X)} computes the Bessel function of the first kind of order
1518 @item @emph{Standard}:
1524 @item @emph{Syntax}:
1525 @code{RESULT = BESJN(N, X)}
1527 @item @emph{Arguments}:
1528 @multitable @columnfractions .15 .80
1529 @item @var{N} @tab The type shall be @code{INTEGER(*)}, and it shall be scalar.
1530 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1533 @item @emph{Return value}:
1534 The return value is a scalar of type @code{REAL(*)}.
1536 @item @emph{Example}:
1539 real(8) :: x = 1.0_8
1541 end program test_besjn
1544 @item @emph{Specific names}:
1545 @multitable @columnfractions .20 .20 .20 .40
1546 @item Name @tab Argument @tab Return type @tab Standard
1547 @item @code{DBESJN(X)} @tab @code{INTEGER(*) N} @tab @code{REAL(8)} @tab GNU extension
1548 @item @tab @code{REAL(8) X} @tab @tab
1555 @section @code{BESY0} --- Bessel function of the second kind of order 0
1556 @cindex @code{BESY0} intrinsic
1557 @cindex @code{DBESY0} intrinsic
1561 @item @emph{Description}:
1562 @code{BESY0(X)} computes the Bessel function of the second kind of order 0
1565 @item @emph{Standard}:
1571 @item @emph{Syntax}:
1572 @code{RESULT = BESY0(X)}
1574 @item @emph{Arguments}:
1575 @multitable @columnfractions .15 .80
1576 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1579 @item @emph{Return value}:
1580 The return value is a scalar of type @code{REAL(*)}.
1582 @item @emph{Example}:
1585 real(8) :: x = 0.0_8
1587 end program test_besy0
1590 @item @emph{Specific names}:
1591 @multitable @columnfractions .20 .20 .20 .40
1592 @item Name @tab Argument @tab Return type @tab Standard
1593 @item @code{DBESY0(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1600 @section @code{BESY1} --- Bessel function of the second kind of order 1
1601 @cindex @code{BESY1} intrinsic
1602 @cindex @code{DBESY1} intrinsic
1606 @item @emph{Description}:
1607 @code{BESY1(X)} computes the Bessel function of the second kind of order 1
1610 @item @emph{Standard}:
1616 @item @emph{Syntax}:
1617 @code{RESULT = BESY1(X)}
1619 @item @emph{Arguments}:
1620 @multitable @columnfractions .15 .80
1621 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1624 @item @emph{Return value}:
1625 The return value is a scalar of type @code{REAL(*)}.
1627 @item @emph{Example}:
1630 real(8) :: x = 1.0_8
1632 end program test_besy1
1635 @item @emph{Specific names}:
1636 @multitable @columnfractions .20 .20 .20 .40
1637 @item Name @tab Argument @tab Return type @tab Standard
1638 @item @code{DBESY1(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1645 @section @code{BESYN} --- Bessel function of the second kind
1646 @cindex @code{BESYN} intrinsic
1647 @cindex @code{DBESYN} intrinsic
1651 @item @emph{Description}:
1652 @code{BESYN(N, X)} computes the Bessel function of the second kind of order
1655 @item @emph{Standard}:
1661 @item @emph{Syntax}:
1662 @code{RESULT = BESYN(N, X)}
1664 @item @emph{Arguments}:
1665 @multitable @columnfractions .15 .80
1666 @item @var{N} @tab The type shall be @code{INTEGER(*)}, and it shall be scalar.
1667 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1670 @item @emph{Return value}:
1671 The return value is a scalar of type @code{REAL(*)}.
1673 @item @emph{Example}:
1676 real(8) :: x = 1.0_8
1678 end program test_besyn
1681 @item @emph{Specific names}:
1682 @multitable @columnfractions .20 .20 .20 .40
1683 @item Name @tab Argument @tab Return type @tab Standard
1684 @item @code{DBESYN(N,X)} @tab @code{INTEGER(*) N} @tab @code{REAL(8)} @tab GNU extension
1685 @item @tab @code{REAL(8) X} @tab @tab
1692 @section @code{BIT_SIZE} --- Bit size inquiry function
1693 @cindex @code{BIT_SIZE} intrinsic
1694 @cindex bit size of a variable
1695 @cindex size of a variable, in bits
1698 @item @emph{Description}:
1699 @code{BIT_SIZE(I)} returns the number of bits (integer precision plus sign bit)
1700 represented by the type of @var{I}.
1702 @item @emph{Standard}:
1708 @item @emph{Syntax}:
1709 @code{RESULT = BIT_SIZE(I)}
1711 @item @emph{Arguments}:
1712 @multitable @columnfractions .15 .80
1713 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1716 @item @emph{Return value}:
1717 The return value is of type @code{INTEGER(*)}
1719 @item @emph{Example}:
1721 program test_bit_size
1726 end program test_bit_size
1733 @section @code{BTEST} --- Bit test function
1734 @cindex @code{BTEST} intrinsic
1735 @cindex bit operations
1738 @item @emph{Description}:
1739 @code{BTEST(I,POS)} returns logical @code{.TRUE.} if the bit at @var{POS}
1742 @item @emph{Standard}:
1748 @item @emph{Syntax}:
1749 @code{RESULT = BTEST(I, POS)}
1751 @item @emph{Arguments}:
1752 @multitable @columnfractions .15 .80
1753 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1754 @item @var{POS} @tab The type shall be @code{INTEGER(*)}.
1757 @item @emph{Return value}:
1758 The return value is of type @code{LOGICAL}
1760 @item @emph{Example}:
1763 integer :: i = 32768 + 1024 + 64
1767 bool = btest(i, pos)
1770 end program test_btest
1777 @section @code{CEILING} --- Integer ceiling function
1778 @cindex @code{CEILING} intrinsic
1782 @item @emph{Description}:
1783 @code{CEILING(X)} returns the least integer greater than or equal to @var{X}.
1785 @item @emph{Standard}:
1791 @item @emph{Syntax}:
1792 @code{RESULT = CEILING(X [, KIND])}
1794 @item @emph{Arguments}:
1795 @multitable @columnfractions .15 .80
1796 @item @var{X} @tab The type shall be @code{REAL(*)}.
1797 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
1798 expression indicating the kind parameter of
1802 @item @emph{Return value}:
1803 The return value is of type @code{INTEGER(KIND)}
1805 @item @emph{Example}:
1807 program test_ceiling
1810 print *, ceiling(x) ! returns 64
1811 print *, ceiling(y) ! returns -63
1812 end program test_ceiling
1815 @item @emph{See also}:
1816 @ref{FLOOR}, @ref{NINT}
1823 @section @code{CHAR} --- Character conversion function
1824 @cindex @code{CHAR} intrinsic
1825 @cindex conversion function (character)
1828 @item @emph{Description}:
1829 @code{CHAR(I [, KIND])} returns the character represented by the integer @var{I}.
1831 @item @emph{Standard}:
1837 @item @emph{Syntax}:
1838 @code{RESULT = CHAR(I [, KIND])}
1840 @item @emph{Arguments}:
1841 @multitable @columnfractions .15 .80
1842 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1843 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
1844 expression indicating the kind parameter of
1848 @item @emph{Return value}:
1849 The return value is of type @code{CHARACTER(1)}
1851 @item @emph{Example}:
1857 print *, i, c ! returns 'J'
1858 end program test_char
1861 @item @emph{See also}:
1862 @ref{ACHAR}, @ref{IACHAR}, @ref{ICHAR}
1868 @section @code{CHDIR} --- Change working directory
1869 @cindex @code{CHDIR} intrinsic
1870 @cindex file system operations
1873 @item @emph{Description}:
1874 Change current working directory to a specified @var{PATH}.
1876 @item @emph{Standard}:
1880 Non-elemental subroutine
1882 @item @emph{Syntax}:
1883 @code{CALL CHDIR(PATH [, STATUS])}
1885 @item @emph{Arguments}:
1886 @multitable @columnfractions .15 .80
1887 @item @var{PATH} @tab The type shall be @code{CHARACTER(*)} and shall
1888 specify a valid path within the file system.
1889 @item @var{STATUS} @tab (Optional) status flag. Returns 0 on success,
1890 a system specific and non-zero error code otherwise.
1893 @item @emph{Example}:
1896 CHARACTER(len=255) :: path
1898 WRITE(*,*) TRIM(path)
1901 WRITE(*,*) TRIM(path)
1905 @item @emph{See also}:
1912 @section @code{CHMOD} --- Change access permissions of files
1913 @cindex @code{CHMOD} intrinsic
1914 @cindex file system operations
1917 @item @emph{Description}:
1918 @code{CHMOD} changes the permissions of a file. This function invokes
1919 @code{/bin/chmod} and might therefore not work on all platforms.
1921 This intrinsic is provided in both subroutine and function forms; however,
1922 only one form can be used in any given program unit.
1924 @item @emph{Standard}:
1928 Subroutine, non-elemental function
1930 @item @emph{Syntax}:
1931 @multitable @columnfractions .80
1932 @item @code{CALL CHMOD(NAME, MODE[, STATUS])}
1933 @item @code{STATUS = CHMOD(NAME, MODE)}
1936 @item @emph{Arguments}:
1937 @multitable @columnfractions .15 .80
1938 @item @var{NAME} @tab Scalar @code{CHARACTER} with the file name.
1939 Trailing blanks are ignored unless the character @code{achar(0)} is
1940 present, then all characters up to and excluding @code{achar(0)} are
1941 used as the file name.
1943 @item @var{MODE} @tab Scalar @code{CHARACTER} giving the file permission.
1944 @var{MODE} uses the same syntax as the @var{MODE} argument of
1947 @item @var{STATUS} @tab (optional) scalar @code{INTEGER}, which is
1948 @code{0} on success and non-zero otherwise.
1951 @item @emph{Return value}:
1952 In either syntax, @var{STATUS} is set to @code{0} on success and non-zero
1955 @item @emph{Example}:
1956 @code{CHMOD} as subroutine
1961 call chmod('test.dat','u+x',status)
1962 print *, 'Status: ', status
1963 end program chmod_test
1965 @code{CHMOD} as non-elemental function:
1970 status = chmod('test.dat','u+x')
1971 print *, 'Status: ', status
1972 end program chmod_test
1974 @item @emph{Specific names}:
1975 @item @emph{See also}:
1981 @section @code{CMPLX} --- Complex conversion function
1982 @cindex @code{CMPLX} intrinsic
1983 @cindex complex numbers, conversion to
1986 @item @emph{Description}:
1987 @code{CMPLX(X [, Y [, KIND]])} returns a complex number where @var{X} is converted to
1988 the real component. If @var{Y} is present it is converted to the imaginary
1989 component. If @var{Y} is not present then the imaginary component is set to
1990 0.0. If @var{X} is complex then @var{Y} must not be present.
1992 @item @emph{Standard}:
1998 @item @emph{Syntax}:
1999 @code{RESULT = CMPLX(X [, Y [, KIND]])}
2001 @item @emph{Arguments}:
2002 @multitable @columnfractions .15 .80
2003 @item @var{X} @tab The type may be @code{INTEGER(*)}, @code{REAL(*)},
2004 or @code{COMPLEX(*)}.
2005 @item @var{Y} @tab (Optional; only allowed if @var{X} is not
2006 @code{COMPLEX(*)}.) May be @code{INTEGER(*)}
2008 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
2009 expression indicating the kind parameter of
2013 @item @emph{Return value}:
2014 The return value is of type @code{COMPLEX(*)}
2016 @item @emph{Example}:
2023 print *, z, cmplx(x)
2024 end program test_cmplx
2030 @node COMMAND_ARGUMENT_COUNT
2031 @section @code{COMMAND_ARGUMENT_COUNT} --- Get number of command line arguments
2032 @cindex @code{COMMAND_ARGUMENT_COUNT} intrinsic
2033 @cindex command-line arguments, to program
2036 @item @emph{Description}:
2037 @code{COMMAND_ARGUMENT_COUNT()} returns the number of arguments passed on the
2038 command line when the containing program was invoked.
2040 @item @emph{Standard}:
2046 @item @emph{Syntax}:
2047 @code{RESULT = COMMAND_ARGUMENT_COUNT()}
2049 @item @emph{Arguments}:
2050 @multitable @columnfractions .15 .80
2054 @item @emph{Return value}:
2055 The return value is of type @code{INTEGER(4)}
2057 @item @emph{Example}:
2059 program test_command_argument_count
2061 count = command_argument_count()
2063 end program test_command_argument_count
2066 @item @emph{See also}:
2067 @ref{GET_COMMAND}, @ref{GET_COMMAND_ARGUMENT}
2071 @section @code{CONJG} --- Complex conjugate function
2072 @cindex @code{CONJG} intrinsic
2073 @cindex @code{DCONJG} intrinsic
2074 @cindex complex conjugate
2076 @item @emph{Description}:
2077 @code{CONJG(Z)} returns the conjugate of @var{Z}. If @var{Z} is @code{(x, y)}
2078 then the result is @code{(x, -y)}
2080 @item @emph{Standard}:
2081 F77 and later, has overloads that are GNU extensions
2086 @item @emph{Syntax}:
2089 @item @emph{Arguments}:
2090 @multitable @columnfractions .15 .80
2091 @item @var{Z} @tab The type shall be @code{COMPLEX(*)}.
2094 @item @emph{Return value}:
2095 The return value is of type @code{COMPLEX(*)}.
2097 @item @emph{Example}:
2100 complex :: z = (2.0, 3.0)
2101 complex(8) :: dz = (2.71_8, -3.14_8)
2106 end program test_conjg
2109 @item @emph{Specific names}:
2110 @multitable @columnfractions .20 .20 .20 .40
2111 @item Name @tab Argument @tab Return type @tab Standard
2112 @item @code{DCONJG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
2119 @section @code{COS} --- Cosine function
2120 @cindex @code{COS} intrinsic
2121 @cindex @code{DCOS} intrinsic
2122 @cindex @code{ZCOS} intrinsic
2123 @cindex @code{CDCOS} intrinsic
2124 @cindex trigonometric functions
2127 @item @emph{Description}:
2128 @code{COS(X)} computes the cosine of @var{X}.
2130 @item @emph{Standard}:
2131 F77 and later, has overloads that are GNU extensions
2136 @item @emph{Syntax}:
2137 @code{RESULT = COS(X)}
2139 @item @emph{Arguments}:
2140 @multitable @columnfractions .15 .80
2141 @item @var{X} @tab The type shall be @code{REAL(*)} or
2145 @item @emph{Return value}:
2146 The return value is of type @code{REAL(*)} and it lies in the
2147 range @math{ -1 \leq \cos (x) \leq 1}. The kind type
2148 parameter is the same as @var{X}.
2150 @item @emph{Example}:
2155 end program test_cos
2158 @item @emph{Specific names}:
2159 @multitable @columnfractions .20 .20 .20 .40
2160 @item Name @tab Argument @tab Return type @tab Standard
2161 @item @code{DCOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
2162 @item @code{CCOS(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab F77 and later
2163 @item @code{ZCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
2164 @item @code{CDCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
2167 @item @emph{See also}:
2168 Inverse function: @ref{ACOS}
2175 @section @code{COSH} --- Hyperbolic cosine function
2176 @cindex @code{COSH} intrinsic
2177 @cindex @code{DCOSH} intrinsic
2178 @cindex hyperbolic cosine
2181 @item @emph{Description}:
2182 @code{COSH(X)} computes the hyperbolic cosine of @var{X}.
2184 @item @emph{Standard}:
2190 @item @emph{Syntax}:
2193 @item @emph{Arguments}:
2194 @multitable @columnfractions .15 .80
2195 @item @var{X} @tab The type shall be @code{REAL(*)}.
2198 @item @emph{Return value}:
2199 The return value is of type @code{REAL(*)} and it is positive
2200 (@math{ \cosh (x) \geq 0 }.
2202 @item @emph{Example}:
2205 real(8) :: x = 1.0_8
2207 end program test_cosh
2210 @item @emph{Specific names}:
2211 @multitable @columnfractions .20 .20 .20 .40
2212 @item Name @tab Argument @tab Return type @tab Standard
2213 @item @code{DCOSH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
2216 @item @emph{See also}:
2217 Inverse function: @ref{ACOSH}
2224 @section @code{COUNT} --- Count function
2225 @cindex @code{COUNT} intrinsic
2229 @item @emph{Description}:
2230 @code{COUNT(MASK [, DIM])} counts the number of @code{.TRUE.} elements of
2231 @var{MASK} along the dimension of @var{DIM}. If @var{DIM} is omitted it is
2232 taken to be @code{1}. @var{DIM} is a scaler of type @code{INTEGER} in the
2233 range of @math{1 /leq DIM /leq n)} where @math{n} is the rank of @var{MASK}.
2235 @item @emph{Standard}:
2239 transformational function
2241 @item @emph{Syntax}:
2242 @code{RESULT = COUNT(MASK [, DIM])}
2244 @item @emph{Arguments}:
2245 @multitable @columnfractions .15 .80
2246 @item @var{MASK} @tab The type shall be @code{LOGICAL}.
2247 @item @var{DIM} @tab The type shall be @code{INTEGER}.
2250 @item @emph{Return value}:
2251 The return value is of type @code{INTEGER} with rank equal to that of
2254 @item @emph{Example}:
2257 integer, dimension(2,3) :: a, b
2258 logical, dimension(2,3) :: mask
2259 a = reshape( (/ 1, 2, 3, 4, 5, 6 /), (/ 2, 3 /))
2260 b = reshape( (/ 0, 7, 3, 4, 5, 8 /), (/ 2, 3 /))
2261 print '(3i3)', a(1,:)
2262 print '(3i3)', a(2,:)
2264 print '(3i3)', b(1,:)
2265 print '(3i3)', b(2,:)
2268 print '(3l3)', mask(1,:)
2269 print '(3l3)', mask(2,:)
2271 print '(3i3)', count(mask)
2273 print '(3i3)', count(mask, 1)
2275 print '(3i3)', count(mask, 2)
2276 end program test_count
2283 @section @code{CPU_TIME} --- CPU elapsed time in seconds
2284 @cindex @code{CPU_TIME} intrinsic
2285 @cindex time, elapsed
2286 @cindex elapsed time
2289 @item @emph{Description}:
2290 Returns a @code{REAL} value representing the elapsed CPU time in seconds. This
2291 is useful for testing segments of code to determine execution time.
2293 @item @emph{Standard}:
2299 @item @emph{Syntax}:
2300 @code{CALL CPU_TIME(X)}
2302 @item @emph{Arguments}:
2303 @multitable @columnfractions .15 .80
2304 @item @var{X} @tab The type shall be @code{REAL} with @code{INTENT(OUT)}.
2307 @item @emph{Return value}:
2310 @item @emph{Example}:
2312 program test_cpu_time
2313 real :: start, finish
2314 call cpu_time(start)
2315 ! put code to test here
2316 call cpu_time(finish)
2317 print '("Time = ",f6.3," seconds.")',finish-start
2318 end program test_cpu_time
2325 @section @code{CSHIFT} --- Circular shift function
2326 @cindex @code{CSHIFT} intrinsic
2327 @cindex bit operations
2330 @item @emph{Description}:
2331 @code{CSHIFT(ARRAY, SHIFT [, DIM])} performs a circular shift on elements of
2332 @var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is omitted it is
2333 taken to be @code{1}. @var{DIM} is a scaler of type @code{INTEGER} in the
2334 range of @math{1 /leq DIM /leq n)} where @math{n} is the rank of @var{ARRAY}.
2335 If the rank of @var{ARRAY} is one, then all elements of @var{ARRAY} are shifted
2336 by @var{SHIFT} places. If rank is greater than one, then all complete rank one
2337 sections of @var{ARRAY} along the given dimension are shifted. Elements
2338 shifted out one end of each rank one section are shifted back in the other end.
2340 @item @emph{Standard}:
2344 transformational function
2346 @item @emph{Syntax}:
2347 @code{RESULT = CSHIFT(A, SHIFT [, DIM])}
2349 @item @emph{Arguments}:
2350 @multitable @columnfractions .15 .80
2351 @item @var{ARRAY} @tab May be any type, not scaler.
2352 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
2353 @item @var{DIM} @tab The type shall be @code{INTEGER}.
2356 @item @emph{Return value}:
2357 Returns an array of same type and rank as the @var{ARRAY} argument.
2359 @item @emph{Example}:
2362 integer, dimension(3,3) :: a
2363 a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
2364 print '(3i3)', a(1,:)
2365 print '(3i3)', a(2,:)
2366 print '(3i3)', a(3,:)
2367 a = cshift(a, SHIFT=(/1, 2, -1/), DIM=2)
2369 print '(3i3)', a(1,:)
2370 print '(3i3)', a(2,:)
2371 print '(3i3)', a(3,:)
2372 end program test_cshift
2378 @section @code{CTIME} --- Convert a time into a string
2379 @cindex @code{CTIME} intrinsic
2380 @cindex time, conversion function
2383 @item @emph{Description}:
2384 @code{CTIME(T,S)} converts @var{T}, a system time value, such as returned
2385 by @code{TIME8()}, to a string of the form @samp{Sat Aug 19 18:13:14
2386 1995}, and returns that string into @var{S}.
2388 If @code{CTIME} is invoked as a function, it can not be invoked as a
2389 subroutine, and vice versa.
2391 @var{T} is an @code{INTENT(IN)} @code{INTEGER(KIND=8)} variable.
2392 @var{S} is an @code{INTENT(OUT)} @code{CHARACTER} variable.
2394 @item @emph{Standard}:
2400 @item @emph{Syntax}:
2401 @multitable @columnfractions .80
2402 @item @code{CALL CTIME(T,S)}.
2403 @item @code{S = CTIME(T)}, (not recommended).
2406 @item @emph{Arguments}:
2407 @multitable @columnfractions .15 .80
2408 @item @var{S}@tab The type shall be of type @code{CHARACTER}.
2409 @item @var{T}@tab The type shall be of type @code{INTEGER(KIND=8)}.
2412 @item @emph{Return value}:
2413 The converted date and time as a string.
2415 @item @emph{Example}:
2419 character(len=30) :: date
2422 ! Do something, main part of the program
2425 print *, 'Program was started on ', date
2426 end program test_ctime
2429 @item @emph{See Also}:
2430 @ref{GMTIME}, @ref{LTIME}, @ref{TIME}, @ref{TIME8}
2437 @section @code{DATE_AND_TIME} --- Date and time subroutine
2438 @cindex @code{DATE_AND_TIME} intrinsic
2439 @cindex date, current
2440 @cindex current date
2441 @cindex time, current
2442 @cindex current time
2445 @item @emph{Description}:
2446 @code{DATE_AND_TIME(DATE, TIME, ZONE, VALUES)} gets the corresponding date and
2447 time information from the real-time system clock. @var{DATE} is
2448 @code{INTENT(OUT)} and has form ccyymmdd. @var{TIME} is @code{INTENT(OUT)} and
2449 has form hhmmss.sss. @var{ZONE} is @code{INTENT(OUT)} and has form (+-)hhmm,
2450 representing the difference with respect to Coordinated Universal Time (UTC).
2451 Unavailable time and date parameters return blanks.
2453 @var{VALUES} is @code{INTENT(OUT)} and provides the following:
2455 @multitable @columnfractions .15 .30 .60
2456 @item @tab @code{VALUE(1)}: @tab The year
2457 @item @tab @code{VALUE(2)}: @tab The month
2458 @item @tab @code{VALUE(3)}: @tab The day of the month
2459 @item @tab @code{VALUE(4)}: @tab Time difference with UTC in minutes
2460 @item @tab @code{VALUE(5)}: @tab The hour of the day
2461 @item @tab @code{VALUE(6)}: @tab The minutes of the hour
2462 @item @tab @code{VALUE(7)}: @tab The seconds of the minute
2463 @item @tab @code{VALUE(8)}: @tab The milliseconds of the second
2466 @item @emph{Standard}:
2472 @item @emph{Syntax}:
2473 @code{CALL DATE_AND_TIME([DATE, TIME, ZONE, VALUES])}
2475 @item @emph{Arguments}:
2476 @multitable @columnfractions .15 .80
2477 @item @var{DATE} @tab (Optional) The type shall be @code{CHARACTER(8)} or larger.
2478 @item @var{TIME} @tab (Optional) The type shall be @code{CHARACTER(10)} or larger.
2479 @item @var{ZONE} @tab (Optional) The type shall be @code{CHARACTER(5)} or larger.
2480 @item @var{VALUES}@tab (Optional) The type shall be @code{INTEGER(8)}.
2483 @item @emph{Return value}:
2486 @item @emph{Example}:
2488 program test_time_and_date
2489 character(8) :: date
2490 character(10) :: time
2491 character(5) :: zone
2492 integer,dimension(8) :: values
2493 ! using keyword arguments
2494 call date_and_time(date,time,zone,values)
2495 call date_and_time(DATE=date,ZONE=zone)
2496 call date_and_time(TIME=time)
2497 call date_and_time(VALUES=values)
2498 print '(a,2x,a,2x,a)', date, time, zone
2499 print '(8i5))', values
2500 end program test_time_and_date
2507 @section @code{DBLE} --- Double conversion function
2508 @cindex @code{DBLE} intrinsic
2509 @cindex double conversion
2512 @item @emph{Description}:
2513 @code{DBLE(X)} Converts @var{X} to double precision real type.
2515 @item @emph{Standard}:
2521 @item @emph{Syntax}:
2522 @code{RESULT = DBLE(X)}
2524 @item @emph{Arguments}:
2525 @multitable @columnfractions .15 .80
2526 @item @var{X} @tab The type shall be @code{INTEGER(*)}, @code{REAL(*)},
2527 or @code{COMPLEX(*)}.
2530 @item @emph{Return value}:
2531 The return value is of type double precision real.
2533 @item @emph{Example}:
2538 complex :: z = (2.3,1.14)
2539 print *, dble(x), dble(i), dble(z)
2540 end program test_dble
2543 @item @emph{See also}:
2544 @ref{DFLOAT}, @ref{FLOAT}, @ref{REAL}
2550 @section @code{DCMPLX} --- Double complex conversion function
2551 @cindex @code{DCMPLX} intrinsic
2552 @cindex complex numbers, conversion to
2555 @item @emph{Description}:
2556 @code{DCMPLX(X [,Y])} returns a double complex number where @var{X} is
2557 converted to the real component. If @var{Y} is present it is converted to the
2558 imaginary component. If @var{Y} is not present then the imaginary component is
2559 set to 0.0. If @var{X} is complex then @var{Y} must not be present.
2561 @item @emph{Standard}:
2567 @item @emph{Syntax}:
2568 @code{RESULT = DCMPLX(X [, Y])}
2570 @item @emph{Arguments}:
2571 @multitable @columnfractions .15 .80
2572 @item @var{X} @tab The type may be @code{INTEGER(*)}, @code{REAL(*)},
2573 or @code{COMPLEX(*)}.
2574 @item @var{Y} @tab (Optional if @var{X} is not @code{COMPLEX(*)}.) May be
2575 @code{INTEGER(*)} or @code{REAL(*)}.
2578 @item @emph{Return value}:
2579 The return value is of type @code{COMPLEX(8)}
2581 @item @emph{Example}:
2591 print *, dcmplx(x,i)
2592 end program test_dcmplx
2599 @section @code{DFLOAT} --- Double conversion function
2600 @cindex @code{DFLOAT} intrinsic
2601 @cindex double float conversion
2604 @item @emph{Description}:
2605 @code{DFLOAT(X)} Converts @var{X} to double precision real type.
2607 @item @emph{Standard}:
2613 @item @emph{Syntax}:
2614 @code{RESULT = DFLOAT(X)}
2616 @item @emph{Arguments}:
2617 @multitable @columnfractions .15 .80
2618 @item @var{X} @tab The type shall be @code{INTEGER(*)}.
2621 @item @emph{Return value}:
2622 The return value is of type double precision real.
2624 @item @emph{Example}:
2629 end program test_dfloat
2632 @item @emph{See also}:
2633 @ref{DBLE}, @ref{FLOAT}, @ref{REAL}
2639 @section @code{DIGITS} --- Significant digits function
2640 @cindex @code{DIGITS} intrinsic
2641 @cindex digits, significant
2644 @item @emph{Description}:
2645 @code{DIGITS(X)} returns the number of significant digits of the internal model
2646 representation of @var{X}. For example, on a system using a 32-bit
2647 floating point representation, a default real number would likely return 24.
2649 @item @emph{Standard}:
2655 @item @emph{Syntax}:
2656 @code{RESULT = DIGITS(X)}
2658 @item @emph{Arguments}:
2659 @multitable @columnfractions .15 .80
2660 @item @var{X} @tab The type may be @code{INTEGER(*)} or @code{REAL(*)}.
2663 @item @emph{Return value}:
2664 The return value is of type @code{INTEGER}.
2666 @item @emph{Example}:
2669 integer :: i = 12345
2675 end program test_digits
2682 @section @code{DIM} --- Dim function
2683 @cindex @code{DIM} intrinsic
2684 @cindex @code{IDIM} intrinsic
2685 @cindex @code{DDIM} intrinsic
2689 @item @emph{Description}:
2690 @code{DIM(X,Y)} returns the difference @code{X-Y} if the result is positive;
2691 otherwise returns zero.
2693 @item @emph{Standard}:
2699 @item @emph{Syntax}:
2700 @code{RESULT = DIM(X, Y)}
2702 @item @emph{Arguments}:
2703 @multitable @columnfractions .15 .80
2704 @item @var{X} @tab The type shall be @code{INTEGER(*)} or @code{REAL(*)}
2705 @item @var{Y} @tab The type shall be the same type and kind as @var{X}.
2708 @item @emph{Return value}:
2709 The return value is of type @code{INTEGER(*)} or @code{REAL(*)}.
2711 @item @emph{Example}:
2717 x = dim(4.345_8, 2.111_8)
2720 end program test_dim
2723 @item @emph{Specific names}:
2724 @multitable @columnfractions .20 .20 .20 .40
2725 @item Name @tab Argument @tab Return type @tab Standard
2726 @item @code{IDIM(X,Y)} @tab @code{INTEGER(4) X,Y} @tab @code{INTEGER(4)} @tab F77 and later
2727 @item @code{DDIM(X,Y)} @tab @code{REAL(8) X,Y} @tab @code{REAL(8)} @tab F77 and later
2734 @section @code{DOT_PRODUCT} --- Dot product function
2735 @cindex @code{DOT_PRODUCT} intrinsic
2739 @item @emph{Description}:
2740 @code{DOT_PRODUCT(X,Y)} computes the dot product multiplication of two vectors
2741 @var{X} and @var{Y}. The two vectors may be either numeric or logical
2742 and must be arrays of rank one and of equal size. If the vectors are
2743 @code{INTEGER(*)} or @code{REAL(*)}, the result is @code{SUM(X*Y)}. If the
2744 vectors are @code{COMPLEX(*)}, the result is @code{SUM(CONJG(X)*Y)}. If the
2745 vectors are @code{LOGICAL}, the result is @code{ANY(X.AND.Y)}.
2747 @item @emph{Standard}:
2751 transformational function
2753 @item @emph{Syntax}:
2754 @code{RESULT = DOT_PRODUCT(X, Y)}
2756 @item @emph{Arguments}:
2757 @multitable @columnfractions .15 .80
2758 @item @var{X} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
2759 @item @var{Y} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
2762 @item @emph{Return value}:
2763 If the arguments are numeric, the return value is a scaler of numeric type,
2764 @code{INTEGER(*)}, @code{REAL(*)}, or @code{COMPLEX(*)}. If the arguments are
2765 @code{LOGICAL}, the return value is @code{.TRUE.} or @code{.FALSE.}.
2767 @item @emph{Example}:
2769 program test_dot_prod
2770 integer, dimension(3) :: a, b
2777 print *, dot_product(a,b)
2778 end program test_dot_prod
2785 @section @code{DPROD} --- Double product function
2786 @cindex @code{DPROD} intrinsic
2787 @cindex double-precision product
2790 @item @emph{Description}:
2791 @code{DPROD(X,Y)} returns the product @code{X*Y}.
2793 @item @emph{Standard}:
2799 @item @emph{Syntax}:
2800 @code{RESULT = DPROD(X, Y)}
2802 @item @emph{Arguments}:
2803 @multitable @columnfractions .15 .80
2804 @item @var{X} @tab The type shall be @code{REAL}.
2805 @item @var{Y} @tab The type shall be @code{REAL}.
2808 @item @emph{Return value}:
2809 The return value is of type @code{REAL(8)}.
2811 @item @emph{Example}:
2820 end program test_dprod
2827 @section @code{DREAL} --- Double real part function
2828 @cindex @code{DREAL} intrinsic
2829 @cindex double-precision real part
2832 @item @emph{Description}:
2833 @code{DREAL(Z)} returns the real part of complex variable @var{Z}.
2835 @item @emph{Standard}:
2841 @item @emph{Syntax}:
2842 @code{RESULT = DREAL(Z)}
2844 @item @emph{Arguments}:
2845 @multitable @columnfractions .15 .80
2846 @item @var{Z} @tab The type shall be @code{COMPLEX(8)}.
2849 @item @emph{Return value}:
2850 The return value is of type @code{REAL(8)}.
2852 @item @emph{Example}:
2855 complex(8) :: z = (1.3_8,7.2_8)
2857 end program test_dreal
2860 @item @emph{See also}:
2868 @section @code{DTIME} --- Execution time subroutine (or function)
2869 @cindex @code{DTIME} intrinsic
2870 @cindex time, elapsed
2871 @cindex elapsed time
2874 @item @emph{Description}:
2875 @code{DTIME(TARRAY, RESULT)} initially returns the number of seconds of runtime
2876 since the start of the process's execution in @var{RESULT}. @var{TARRAY}
2877 returns the user and system components of this time in @code{TARRAY(1)} and
2878 @code{TARRAY(2)} respectively. @var{RESULT} is equal to @code{TARRAY(1) +
2881 Subsequent invocations of @code{DTIME} return values accumulated since the
2882 previous invocation.
2884 On some systems, the underlying timings are represented using types with
2885 sufficiently small limits that overflows (wrap around) are possible, such as
2886 32-bit types. Therefore, the values returned by this intrinsic might be, or
2887 become, negative, or numerically less than previous values, during a single
2888 run of the compiled program.
2890 If @code{DTIME} is invoked as a function, it can not be invoked as a
2891 subroutine, and vice versa.
2893 @var{TARRAY} and @var{RESULT} are @code{INTENT(OUT)} and provide the following:
2895 @multitable @columnfractions .15 .30 .60
2896 @item @tab @code{TARRAY(1)}: @tab User time in seconds.
2897 @item @tab @code{TARRAY(2)}: @tab System time in seconds.
2898 @item @tab @code{RESULT}: @tab Run time since start in seconds.
2901 @item @emph{Standard}:
2907 @item @emph{Syntax}:
2908 @multitable @columnfractions .80
2909 @item @code{CALL DTIME(TARRAY, RESULT)}.
2910 @item @code{RESULT = DTIME(TARRAY)}, (not recommended).
2913 @item @emph{Arguments}:
2914 @multitable @columnfractions .15 .80
2915 @item @var{TARRAY}@tab The type shall be @code{REAL, DIMENSION(2)}.
2916 @item @var{RESULT}@tab The type shall be @code{REAL}.
2919 @item @emph{Return value}:
2920 Elapsed time in seconds since the start of program execution.
2922 @item @emph{Example}:
2926 real, dimension(2) :: tarray
2928 call dtime(tarray, result)
2932 do i=1,100000000 ! Just a delay
2935 call dtime(tarray, result)
2939 end program test_dtime
2946 @section @code{EOSHIFT} --- End-off shift function
2947 @cindex @code{EOSHIFT} intrinsic
2948 @cindex bit operations
2951 @item @emph{Description}:
2952 @code{EOSHIFT(ARRAY, SHIFT[,BOUNDARY, DIM])} performs an end-off shift on
2953 elements of @var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is
2954 omitted it is taken to be @code{1}. @var{DIM} is a scaler of type
2955 @code{INTEGER} in the range of @math{1 /leq DIM /leq n)} where @math{n} is the
2956 rank of @var{ARRAY}. If the rank of @var{ARRAY} is one, then all elements of
2957 @var{ARRAY} are shifted by @var{SHIFT} places. If rank is greater than one,
2958 then all complete rank one sections of @var{ARRAY} along the given dimension are
2959 shifted. Elements shifted out one end of each rank one section are dropped. If
2960 @var{BOUNDARY} is present then the corresponding value of from @var{BOUNDARY}
2961 is copied back in the other end. If @var{BOUNDARY} is not present then the
2962 following are copied in depending on the type of @var{ARRAY}.
2964 @multitable @columnfractions .15 .80
2965 @item @emph{Array Type} @tab @emph{Boundary Value}
2966 @item Numeric @tab 0 of the type and kind of @var{ARRAY}.
2967 @item Logical @tab @code{.FALSE.}.
2968 @item Character(@var{len}) @tab @var{len} blanks.
2971 @item @emph{Standard}:
2975 transformational function
2977 @item @emph{Syntax}:
2978 @code{RESULT = EOSHIFT(A, SHIFT [, BOUNDARY, DIM])}
2980 @item @emph{Arguments}:
2981 @multitable @columnfractions .15 .80
2982 @item @var{ARRAY} @tab May be any type, not scaler.
2983 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
2984 @item @var{BOUNDARY} @tab Same type as @var{ARRAY}.
2985 @item @var{DIM} @tab The type shall be @code{INTEGER}.
2988 @item @emph{Return value}:
2989 Returns an array of same type and rank as the @var{ARRAY} argument.
2991 @item @emph{Example}:
2993 program test_eoshift
2994 integer, dimension(3,3) :: a
2995 a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
2996 print '(3i3)', a(1,:)
2997 print '(3i3)', a(2,:)
2998 print '(3i3)', a(3,:)
2999 a = EOSHIFT(a, SHIFT=(/1, 2, 1/), BOUNDARY=-5, DIM=2)
3001 print '(3i3)', a(1,:)
3002 print '(3i3)', a(2,:)
3003 print '(3i3)', a(3,:)
3004 end program test_eoshift
3011 @section @code{EPSILON} --- Epsilon function
3012 @cindex @code{EPSILON} intrinsic
3013 @cindex epsilon, significant
3016 @item @emph{Description}:
3017 @code{EPSILON(X)} returns a nearly negligible number relative to @code{1}.
3019 @item @emph{Standard}:
3025 @item @emph{Syntax}:
3026 @code{RESULT = EPSILON(X)}
3028 @item @emph{Arguments}:
3029 @multitable @columnfractions .15 .80
3030 @item @var{X} @tab The type shall be @code{REAL(*)}.
3033 @item @emph{Return value}:
3034 The return value is of same type as the argument.
3036 @item @emph{Example}:
3038 program test_epsilon
3043 end program test_epsilon
3050 @section @code{ERF} --- Error function
3051 @cindex @code{ERF} intrinsic
3052 @cindex error function
3055 @item @emph{Description}:
3056 @code{ERF(X)} computes the error function of @var{X}.
3058 @item @emph{Standard}:
3064 @item @emph{Syntax}:
3065 @code{RESULT = ERF(X)}
3067 @item @emph{Arguments}:
3068 @multitable @columnfractions .15 .80
3069 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
3072 @item @emph{Return value}:
3073 The return value is a scalar of type @code{REAL(*)} and it is positive
3074 (@math{ - 1 \leq erf (x) \leq 1 }.
3076 @item @emph{Example}:
3079 real(8) :: x = 0.17_8
3081 end program test_erf
3084 @item @emph{Specific names}:
3085 @multitable @columnfractions .20 .20 .20 .40
3086 @item Name @tab Argument @tab Return type @tab Standard
3087 @item @code{DERF(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
3094 @section @code{ERFC} --- Error function
3095 @cindex @code{ERFC} intrinsic
3096 @cindex error function
3099 @item @emph{Description}:
3100 @code{ERFC(X)} computes the complementary error function of @var{X}.
3102 @item @emph{Standard}:
3108 @item @emph{Syntax}:
3109 @code{RESULT = ERFC(X)}
3111 @item @emph{Arguments}:
3112 @multitable @columnfractions .15 .80
3113 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
3116 @item @emph{Return value}:
3117 The return value is a scalar of type @code{REAL(*)} and it is positive
3118 (@math{ 0 \leq erfc (x) \leq 2 }.
3120 @item @emph{Example}:
3123 real(8) :: x = 0.17_8
3125 end program test_erfc
3128 @item @emph{Specific names}:
3129 @multitable @columnfractions .20 .20 .20 .40
3130 @item Name @tab Argument @tab Return type @tab Standard
3131 @item @code{DERFC(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
3138 @section @code{ETIME} --- Execution time subroutine (or function)
3139 @cindex @code{ETIME} intrinsic
3140 @cindex time, elapsed
3143 @item @emph{Description}:
3144 @code{ETIME(TARRAY, RESULT)} returns the number of seconds of runtime
3145 since the start of the process's execution in @var{RESULT}. @var{TARRAY}
3146 returns the user and system components of this time in @code{TARRAY(1)} and
3147 @code{TARRAY(2)} respectively. @var{RESULT} is equal to @code{TARRAY(1) + TARRAY(2)}.
3149 On some systems, the underlying timings are represented using types with
3150 sufficiently small limits that overflows (wrap around) are possible, such as
3151 32-bit types. Therefore, the values returned by this intrinsic might be, or
3152 become, negative, or numerically less than previous values, during a single
3153 run of the compiled program.
3155 If @code{ETIME} is invoked as a function, it can not be invoked as a
3156 subroutine, and vice versa.
3158 @var{TARRAY} and @var{RESULT} are @code{INTENT(OUT)} and provide the following:
3160 @multitable @columnfractions .15 .30 .60
3161 @item @tab @code{TARRAY(1)}: @tab User time in seconds.
3162 @item @tab @code{TARRAY(2)}: @tab System time in seconds.
3163 @item @tab @code{RESULT}: @tab Run time since start in seconds.
3166 @item @emph{Standard}:
3172 @item @emph{Syntax}:
3173 @multitable @columnfractions .8
3174 @item @code{CALL ETIME(TARRAY, RESULT)}.
3175 @item @code{RESULT = ETIME(TARRAY)}, (not recommended).
3178 @item @emph{Arguments}:
3179 @multitable @columnfractions .15 .80
3180 @item @var{TARRAY}@tab The type shall be @code{REAL, DIMENSION(2)}.
3181 @item @var{RESULT}@tab The type shall be @code{REAL}.
3184 @item @emph{Return value}:
3185 Elapsed time in seconds since the start of program execution.
3187 @item @emph{Example}:
3191 real, dimension(2) :: tarray
3193 call ETIME(tarray, result)
3197 do i=1,100000000 ! Just a delay
3200 call ETIME(tarray, result)
3204 end program test_etime
3207 @item @emph{See also}:
3215 @section @code{EXIT} --- Exit the program with status.
3216 @cindex @code{EXIT} intrinsic
3217 @cindex exit program
3220 @item @emph{Description}:
3221 @code{EXIT} causes immediate termination of the program with status. If status
3222 is omitted it returns the canonical @emph{success} for the system. All Fortran
3223 I/O units are closed.
3225 @item @emph{Standard}:
3231 @item @emph{Syntax}:
3232 @code{CALL EXIT([STATUS])}
3234 @item @emph{Arguments}:
3235 @multitable @columnfractions .15 .80
3236 @item @var{STATUS} @tab The type of the argument shall be @code{INTEGER(*)}.
3239 @item @emph{Return value}:
3240 @code{STATUS} is passed to the parent process on exit.
3242 @item @emph{Example}:
3245 integer :: STATUS = 0
3246 print *, 'This program is going to exit.'
3248 end program test_exit
3251 @item @emph{See also}:
3252 @ref{ABORT}, @ref{KILL}
3258 @section @code{EXP} --- Exponential function
3259 @cindex @code{EXP} intrinsic
3260 @cindex @code{DEXP} intrinsic
3261 @cindex @code{ZEXP} intrinsic
3262 @cindex @code{CDEXP} intrinsic
3266 @item @emph{Description}:
3267 @code{EXP(X)} computes the base @math{e} exponential of @var{X}.
3269 @item @emph{Standard}:
3270 F77 and later, has overloads that are GNU extensions
3275 @item @emph{Syntax}:
3276 @code{RESULT = EXP(X)}
3278 @item @emph{Arguments}:
3279 @multitable @columnfractions .15 .80
3280 @item @var{X} @tab The type shall be @code{REAL(*)} or
3284 @item @emph{Return value}:
3285 The return value has same type and kind as @var{X}.
3287 @item @emph{Example}:
3292 end program test_exp
3295 @item @emph{Specific names}:
3296 @multitable @columnfractions .20 .20 .20 .40
3297 @item Name @tab Argument @tab Return type @tab Standard
3298 @item @code{DEXP(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
3299 @item @code{CEXP(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab F77 and later
3300 @item @code{ZEXP(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
3301 @item @code{CDEXP(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
3308 @section @code{EXPONENT} --- Exponent function
3309 @cindex @code{EXPONENT} intrinsic
3310 @cindex exponent part of a real number
3313 @item @emph{Description}:
3314 @code{EXPONENT(X)} returns the value of the exponent part of @var{X}. If @var{X}
3315 is zero the value returned is zero.
3317 @item @emph{Standard}:
3323 @item @emph{Syntax}:
3324 @code{RESULT = EXPONENT(X)}
3326 @item @emph{Arguments}:
3327 @multitable @columnfractions .15 .80
3328 @item @var{X} @tab The type shall be @code{REAL(*)}.
3331 @item @emph{Return value}:
3332 The return value is of type default @code{INTEGER}.
3334 @item @emph{Example}:
3336 program test_exponent
3341 print *, exponent(0.0)
3342 end program test_exponent
3348 @section @code{FDATE} --- Get the current time as a string
3349 @cindex @code{FDATE} intrinsic
3350 @cindex time, current
3351 @cindex current time
3352 @cindex date, current
3353 @cindex current date
3356 @item @emph{Description}:
3357 @code{FDATE(DATE)} returns the current date (using the same format as
3358 @code{CTIME}) in @var{DATE}. It is equivalent to @code{CALL CTIME(DATE,
3361 If @code{FDATE} is invoked as a function, it can not be invoked as a
3362 subroutine, and vice versa.
3364 @var{DATE} is an @code{INTENT(OUT)} @code{CHARACTER} variable.
3366 @item @emph{Standard}:
3372 @item @emph{Syntax}:
3373 @multitable @columnfractions .80
3374 @item @code{CALL FDATE(DATE)}.
3375 @item @code{DATE = FDATE()}, (not recommended).
3378 @item @emph{Arguments}:
3379 @multitable @columnfractions .15 .80
3380 @item @var{DATE}@tab The type shall be of type @code{CHARACTER}.
3383 @item @emph{Return value}:
3384 The current date as a string.
3386 @item @emph{Example}:
3390 character(len=30) :: date
3392 print *, 'Program started on ', date
3393 do i = 1, 100000000 ! Just a delay
3397 print *, 'Program ended on ', date
3398 end program test_fdate
3404 @section @code{FLOAT} --- Convert integer to default real
3405 @cindex @code{FLOAT} intrinsic
3406 @cindex conversion function (float)
3409 @item @emph{Description}:
3410 @code{FLOAT(I)} converts the integer @var{I} to a default real value.
3412 @item @emph{Standard}:
3418 @item @emph{Syntax}:
3419 @code{RESULT = FLOAT(I)}
3421 @item @emph{Arguments}:
3422 @multitable @columnfractions .15 .80
3423 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
3426 @item @emph{Return value}:
3427 The return value is of type default @code{REAL}.
3429 @item @emph{Example}:
3433 if (float(i) /= 1.) call abort
3434 end program test_float
3437 @item @emph{See also}:
3438 @ref{DBLE}, @ref{DFLOAT}, @ref{REAL}
3444 @section @code{FGET} --- Read a single character in stream mode from stdin
3445 @cindex @code{FGET} intrinsic
3446 @cindex file operations
3447 @cindex stream operations
3450 @item @emph{Description}:
3451 Read a single character in stream mode from stdin by bypassing normal
3452 formatted output. Stream I/O should not be mixed with normal record-oriented
3453 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
3455 This intrinsic routine is provided for backwards compatibility with
3456 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
3457 Programmers should consider the use of new stream IO feature in new code
3458 for future portability. See also @ref{Fortran 2003 status}.
3460 @item @emph{Standard}:
3464 Non-elemental subroutine
3466 @item @emph{Syntax}:
3467 @code{CALL FGET(C [, STATUS])}
3469 @item @emph{Arguments}:
3470 @multitable @columnfractions .15 .80
3471 @item @var{C} @tab The type shall be @code{CHARACTER}.
3472 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
3473 Returns 0 on success, -1 on end-of-file, and a
3474 system specific positive error code otherwise.
3477 @item @emph{Example}:
3480 INTEGER, PARAMETER :: strlen = 100
3481 INTEGER :: status, i = 1
3482 CHARACTER(len=strlen) :: str = ""
3484 WRITE (*,*) 'Enter text:'
3486 CALL fget(str(i:i), status)
3487 if (status /= 0 .OR. i > strlen) exit
3490 WRITE (*,*) TRIM(str)
3494 @item @emph{See also}:
3495 @ref{FGETC}, @ref{FPUT}, @ref{FPUTC}
3500 @section @code{FGETC} --- Read a single character in stream mode
3501 @cindex @code{FGETC} intrinsic
3502 @cindex file operations
3503 @cindex stream operations
3506 @item @emph{Description}:
3507 Read a single character in stream mode by bypassing normal formatted output.
3508 Stream I/O should not be mixed with normal record-oriented (formatted or
3509 unformatted) I/O on the same unit; the results are unpredictable.
3511 This intrinsic routine is provided for backwards compatibility with
3512 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
3513 Programmers should consider the use of new stream IO feature in new code
3514 for future portability. See also @ref{Fortran 2003 status}.
3516 @item @emph{Standard}:
3520 Non-elemental subroutine
3522 @item @emph{Syntax}:
3523 @code{CALL FGETC(UNIT, C [, STATUS])}
3525 @item @emph{Arguments}:
3526 @multitable @columnfractions .15 .80
3527 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
3528 @item @var{C} @tab The type shall be @code{CHARACTER}.
3529 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. Returns 0 on success,
3530 -1 on end-of-file and a system specific positive error code otherwise.
3533 @item @emph{Example}:
3536 INTEGER :: fd = 42, status
3539 OPEN(UNIT=fd, FILE="/etc/passwd", ACTION="READ", STATUS = "OLD")
3541 CALL fgetc(fd, c, status)
3542 IF (status /= 0) EXIT
3549 @item @emph{See also}:
3550 @ref{FGET}, @ref{FPUT}, @ref{FPUTC}
3556 @section @code{FLOOR} --- Integer floor function
3557 @cindex @code{FLOOR} intrinsic
3561 @item @emph{Description}:
3562 @code{FLOOR(X)} returns the greatest integer less than or equal to @var{X}.
3564 @item @emph{Standard}:
3570 @item @emph{Syntax}:
3571 @code{RESULT = FLOOR(X [, KIND])}
3573 @item @emph{Arguments}:
3574 @multitable @columnfractions .15 .80
3575 @item @var{X} @tab The type shall be @code{REAL(*)}.
3576 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
3577 expression indicating the kind parameter of
3581 @item @emph{Return value}:
3582 The return value is of type @code{INTEGER(KIND)}
3584 @item @emph{Example}:
3589 print *, floor(x) ! returns 63
3590 print *, floor(y) ! returns -64
3591 end program test_floor
3594 @item @emph{See also}:
3595 @ref{CEILING}, @ref{NINT}
3602 @section @code{FLUSH} --- Flush I/O unit(s)
3603 @cindex @code{FLUSH} intrinsic
3604 @cindex flush output files
3607 @item @emph{Description}:
3608 Flushes Fortran unit(s) currently open for output. Without the optional
3609 argument, all units are flushed, otherwise just the unit specified.
3611 @item @emph{Standard}:
3615 non-elemental subroutine
3617 @item @emph{Syntax}:
3618 @code{CALL FLUSH(UNIT)}
3620 @item @emph{Arguments}:
3621 @multitable @columnfractions .15 .80
3622 @item @var{UNIT} @tab (Optional) The type shall be @code{INTEGER}.
3626 Beginning with the Fortran 2003 standard, there is a @code{FLUSH}
3627 statement that should be preferred over the @code{FLUSH} intrinsic.
3634 @section @code{FNUM} --- File number function
3635 @cindex @code{FNUM} intrinsic
3639 @item @emph{Description}:
3640 @code{FNUM(UNIT)} returns the POSIX file descriptor number corresponding to the
3641 open Fortran I/O unit @code{UNIT}.
3643 @item @emph{Standard}:
3647 non-elemental function
3649 @item @emph{Syntax}:
3650 @code{RESULT = FNUM(UNIT)}
3652 @item @emph{Arguments}:
3653 @multitable @columnfractions .15 .80
3654 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
3657 @item @emph{Return value}:
3658 The return value is of type @code{INTEGER}
3660 @item @emph{Example}:
3664 open (unit=10, status = "scratch")
3668 end program test_fnum
3675 @section @code{FPUT} --- Write a single character in stream mode to stdout
3676 @cindex @code{FPUT} intrinsic
3677 @cindex file operations
3678 @cindex stream operations
3681 @item @emph{Description}:
3682 Write a single character in stream mode to stdout by bypassing normal
3683 formatted output. Stream I/O should not be mixed with normal record-oriented
3684 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
3686 This intrinsic routine is provided for backwards compatibility with
3687 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
3688 Programmers should consider the use of new stream IO feature in new code
3689 for future portability. See also @ref{Fortran 2003 status}.
3691 @item @emph{Standard}:
3695 Non-elemental subroutine
3697 @item @emph{Syntax}:
3698 @code{CALL FPUT(C [, STATUS])}
3700 @item @emph{Arguments}:
3701 @multitable @columnfractions .15 .80
3702 @item @var{C} @tab The type shall be @code{CHARACTER}.
3703 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. Returns 0 on success,
3704 -1 on end-of-file and a system specific positive error code otherwise.
3707 @item @emph{Example}:
3710 CHARACTER(len=*) :: str = "gfortran"
3712 DO i = 1, len_trim(str)
3718 @item @emph{See also}:
3719 @ref{FPUTC}, @ref{FGET}, @ref{FGETC}
3725 @section @code{FPUTC} --- Write a single character in stream mode
3726 @cindex @code{FPUTC} intrinsic
3727 @cindex file operations
3728 @cindex stream operations
3731 @item @emph{Description}:
3732 Write a single character in stream mode by bypassing normal formatted
3733 output. Stream I/O should not be mixed with normal record-oriented
3734 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
3736 This intrinsic routine is provided for backwards compatibility with
3737 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
3738 Programmers should consider the use of new stream IO feature in new code
3739 for future portability. See also @ref{Fortran 2003 status}.
3741 @item @emph{Standard}:
3745 Non-elemental subroutine
3747 @item @emph{Syntax}:
3748 @code{CALL FPUTC(UNIT, C [, STATUS])}
3750 @item @emph{Arguments}:
3751 @multitable @columnfractions .15 .80
3752 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
3753 @item @var{C} @tab The type shall be @code{CHARACTER}.
3754 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. Returns 0 on success,
3755 -1 on end-of-file and a system specific positive error code otherwise.
3758 @item @emph{Example}:
3761 CHARACTER(len=*) :: str = "gfortran"
3762 INTEGER :: fd = 42, i
3764 OPEN(UNIT = fd, FILE = "out", ACTION = "WRITE", STATUS="NEW")
3765 DO i = 1, len_trim(str)
3766 CALL fputc(fd, str(i:i))
3772 @item @emph{See also}:
3773 @ref{FPUT}, @ref{FGET}, @ref{FGETC}
3779 @section @code{FRACTION} --- Fractional part of the model representation
3780 @cindex @code{FRACTION} intrinsic
3781 @cindex fractional part
3784 @item @emph{Description}:
3785 @code{FRACTION(X)} returns the fractional part of the model
3786 representation of @code{X}.
3788 @item @emph{Standard}:
3794 @item @emph{Syntax}:
3795 @code{Y = FRACTION(X)}
3797 @item @emph{Arguments}:
3798 @multitable @columnfractions .15 .80
3799 @item @var{X} @tab The type of the argument shall be a @code{REAL}.
3802 @item @emph{Return value}:
3803 The return value is of the same type and kind as the argument.
3804 The fractional part of the model representation of @code{X} is returned;
3805 it is @code{X * RADIX(X)**(-EXPONENT(X))}.
3807 @item @emph{Example}:
3809 program test_fraction
3812 print *, fraction(x), x * radix(x)**(-exponent(x))
3813 end program test_fraction
3821 @section @code{FREE} --- Frees memory
3822 @cindex @code{FREE} intrinsic
3823 @cindex Cray pointers
3826 @item @emph{Description}:
3827 Frees memory previously allocated by @code{MALLOC()}. The @code{FREE}
3828 intrinsic is an extension intended to be used with Cray pointers, and is
3829 provided in GNU Fortran to allow user to compile legacy code. For
3830 new code using Fortran 95 pointers, the memory de-allocation intrinsic is
3833 @item @emph{Standard}:
3839 @item @emph{Syntax}:
3842 @item @emph{Arguments}:
3843 @multitable @columnfractions .15 .80
3844 @item @var{PTR} @tab The type shall be @code{INTEGER}. It represents the
3845 location of the memory that should be de-allocated.
3848 @item @emph{Return value}:
3851 @item @emph{Example}:
3852 See @code{MALLOC} for an example.
3854 @item @emph{See also}:
3862 @section @code{FSTAT} --- Get file status
3863 @cindex @code{FSTAT} intrinsic
3864 @cindex file system operations
3867 @item @emph{Description}:
3868 @code{FSTAT} is identical to @ref{STAT}, except that information about an
3869 already opened file is obtained.
3871 The elements in @code{BUFF} are the same as described by @ref{STAT}.
3873 @item @emph{Standard}:
3877 Non-elemental subroutine
3879 @item @emph{Syntax}:
3880 @code{CALL FSTAT(UNIT, BUFF [, STATUS])}
3882 @item @emph{Arguments}:
3883 @multitable @columnfractions .15 .80
3884 @item @var{UNIT} @tab An open I/O unit number of type @code{INTEGER}.
3885 @item @var{BUFF} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
3886 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0
3887 on success and a system specific error code otherwise.
3890 @item @emph{Example}:
3891 See @ref{STAT} for an example.
3893 @item @emph{See also}:
3894 To stat a link: @ref{LSTAT}, to stat a file: @ref{STAT}
3900 @section @code{FSEEK} --- Low level file positioning subroutine
3901 @cindex @code{FSEEK} intrinsic
3902 @cindex file system operations
3904 Not yet implemented in GNU Fortran.
3907 @item @emph{Description}:
3909 @item @emph{Standard}:
3915 @item @emph{Syntax}:
3916 @item @emph{Arguments}:
3917 @item @emph{Return value}:
3918 @item @emph{Example}:
3919 @item @emph{Specific names}:
3920 @item @emph{See also}:
3921 @uref{http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19292, g77 features lacking in gfortran}
3928 @section @code{FTELL} --- Current stream position
3929 @cindex @code{FTELL} intrinsic
3932 @item @emph{Description}:
3933 Retrieves the current position within an open file.
3935 This intrinsic is provided in both subroutine and function forms; however,
3936 only one form can be used in any given program unit.
3938 @item @emph{Standard}:
3942 Subroutine, function
3944 @item @emph{Syntax}:
3945 @multitable @columnfractions .80
3946 @item @code{CALL FTELL(UNIT, OFFSET)}
3947 @item @code{OFFSET = FTELL(UNIT)}
3950 @item @emph{Arguments}:
3951 @multitable @columnfractions .15 .80
3952 @item @var{OFFSET} @tab Shall of type @code{INTEGER}.
3953 @item @var{UNIT} @tab Shall of type @code{INTEGER}.
3956 @item @emph{Return value}:
3957 In either syntax, @var{OFFSET} is set to the current offset of unit
3958 number @var{UNIT}, or to @math{-1} if the unit is not currently open.
3960 @item @emph{Example}:
3964 OPEN(10, FILE="temp.dat")
3970 @item @emph{See also}:
3977 @section @code{GETARG} --- Get command line arguments
3978 @cindex @code{GETARG} intrinsic
3979 @cindex command-line arguments, to program
3982 @item @emph{Description}:
3983 Retrieve the @var{N}th argument that was passed on the
3984 command line when the containing program was invoked.
3986 This intrinsic routine is provided for backwards compatibility with
3987 GNU Fortran 77. In new code, programmers should consider the use of
3988 the @ref{GET_COMMAND_ARGUMENT} intrinsic defined by the Fortran 2003
3991 @item @emph{Standard}:
3997 @item @emph{Syntax}:
3998 @code{CALL GETARG(N, ARG)}
4000 @item @emph{Arguments}:
4001 @multitable @columnfractions .15 .80
4002 @item @var{N} @tab Shall of type @code{INTEGER(4)}, @math{@var{N} \geq 0}
4003 @item @var{ARG} @tab Shall be of type @code{CHARACTER(*)}.
4006 @item @emph{Return value}:
4007 After @code{GETARG} returns, the @var{ARG} argument holds the @var{N}th
4008 command line argument. If @var{ARG} can not hold the argument, it is
4009 truncated to fit the length of @var{ARG}. If there are less than @var{N}
4010 arguments specified at the command line, @var{ARG} will be filled with blanks.
4011 If @math{@var{N} = 0}, @var{ARG} is set to the name of the program (on systems
4012 that support this feature).
4014 @item @emph{Example}:
4018 CHARACTER(len=32) :: arg
4027 @item @emph{See also}:
4028 GNU Fortran 77 compatibility function: @ref{IARGC}
4030 F2003 functions and subroutines: @ref{GET_COMMAND}, @ref{GET_COMMAND_ARGUMENT},
4031 @ref{COMMAND_ARGUMENT_COUNT}
4037 @section @code{GET_COMMAND} --- Get the entire command line
4038 @cindex @code{GET_COMMAND} intrinsic
4039 @cindex command-line arguments, to program
4042 @item @emph{Description}:
4043 Retrieve the entire command line that was used to invoke the program.
4045 @item @emph{Standard}:
4051 @item @emph{Syntax}:
4052 @code{CALL GET_COMMAND(CMD)}
4054 @item @emph{Arguments}:
4055 @multitable @columnfractions .15 .80
4056 @item @var{CMD} @tab Shall be of type @code{CHARACTER(*)}.
4059 @item @emph{Return value}:
4060 Stores the entire command line that was used to invoke the program in @var{ARG}.
4061 If @var{ARG} is not large enough, the command will be truncated.
4063 @item @emph{Example}:
4065 PROGRAM test_get_command
4066 CHARACTER(len=255) :: cmd
4067 CALL get_command(cmd)
4068 WRITE (*,*) TRIM(cmd)
4072 @item @emph{See also}:
4073 @ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
4078 @node GET_COMMAND_ARGUMENT
4079 @section @code{GET_COMMAND_ARGUMENT} --- Get command line arguments
4080 @cindex @code{GET_COMMAND_ARGUMENT} intrinsic
4081 @cindex command-line arguments, to program
4084 @item @emph{Description}:
4085 Retrieve the @var{N}th argument that was passed on the
4086 command line when the containing program was invoked.
4088 @item @emph{Standard}:
4094 @item @emph{Syntax}:
4095 @code{CALL GET_COMMAND_ARGUMENT(N, ARG)}
4097 @item @emph{Arguments}:
4098 @multitable @columnfractions .15 .80
4099 @item @var{N} @tab Shall of type @code{INTEGER(4)}, @math{@var{N} \geq 0}
4100 @item @var{ARG} @tab Shall be of type @code{CHARACTER(*)}.
4103 @item @emph{Return value}:
4104 After @code{GET_COMMAND_ARGUMENT} returns, the @var{ARG} argument holds the
4105 @var{N}th command line argument. If @var{ARG} can not hold the argument, it is
4106 truncated to fit the length of @var{ARG}. If there are less than @var{N}
4107 arguments specified at the command line, @var{ARG} will be filled with blanks.
4108 If @math{@var{N} = 0}, @var{ARG} is set to the name of the program (on systems
4109 that support this feature).
4111 @item @emph{Example}:
4113 PROGRAM test_get_command_argument
4115 CHARACTER(len=32) :: arg
4119 CALL get_command_argument(i, arg)
4120 IF (LEN_TRIM(arg) == 0) EXIT
4122 WRITE (*,*) TRIM(arg)
4128 @item @emph{See also}:
4129 @ref{GET_COMMAND}, @ref{COMMAND_ARGUMENT_COUNT}
4135 @section @code{GETCWD} --- Get current working directory
4136 @cindex @code{GETCWD} intrinsic
4137 @cindex file system operations
4140 @item @emph{Description}:
4141 Get current working directory.
4143 @item @emph{Standard}:
4147 Non-elemental subroutine.
4149 @item @emph{Syntax}:
4150 @code{CALL GETCWD(CWD [, STATUS])}
4152 @item @emph{Arguments}:
4153 @multitable @columnfractions .15 .80
4154 @item @var{CWD} @tab The type shall be @code{CHARACTER(*)}.
4155 @item @var{STATUS} @tab (Optional) status flag. Returns 0 on success,
4156 a system specific and non-zero error code otherwise.
4159 @item @emph{Example}:
4162 CHARACTER(len=255) :: cwd
4164 WRITE(*,*) TRIM(cwd)
4168 @item @emph{See also}:
4175 @section @code{GETENV} --- Get an environmental variable
4176 @cindex @code{GETENV} intrinsic
4177 @cindex environment variable
4180 @item @emph{Description}:
4181 Get the @var{VALUE} of the environmental variable @var{ENVVAR}.
4183 This intrinsic routine is provided for backwards compatibility with
4184 GNU Fortran 77. In new code, programmers should consider the use of
4185 the @ref{GET_ENVIRONMENT_VARIABLE} intrinsic defined by the Fortran
4188 @item @emph{Standard}:
4194 @item @emph{Syntax}:
4195 @code{CALL GETENV(ENVVAR, VALUE)}
4197 @item @emph{Arguments}:
4198 @multitable @columnfractions .15 .80
4199 @item @var{ENVVAR} @tab Shall be of type @code{CHARACTER(*)}.
4200 @item @var{VALUE} @tab Shall be of type @code{CHARACTER(*)}.
4203 @item @emph{Return value}:
4204 Stores the value of @var{ENVVAR} in @var{VALUE}. If @var{VALUE} is
4205 not large enough to hold the data, it is truncated. If @var{ENVVAR}
4206 is not set, @var{VALUE} will be filled with blanks.
4208 @item @emph{Example}:
4211 CHARACTER(len=255) :: homedir
4212 CALL getenv("HOME", homedir)
4213 WRITE (*,*) TRIM(homedir)
4217 @item @emph{See also}:
4218 @ref{GET_ENVIRONMENT_VARIABLE}
4223 @node GET_ENVIRONMENT_VARIABLE
4224 @section @code{GET_ENVIRONMENT_VARIABLE} --- Get an environmental variable
4225 @cindex @code{GET_ENVIRONMENT_VARIABLE} intrinsic
4226 @cindex environment variable
4229 @item @emph{Description}:
4230 Get the @var{VALUE} of the environmental variable @var{ENVVAR}.
4232 @item @emph{Standard}:
4238 @item @emph{Syntax}:
4239 @code{CALL GET_ENVIRONMENT_VARIABLE(ENVVAR, VALUE)}
4241 @item @emph{Arguments}:
4242 @multitable @columnfractions .15 .80
4243 @item @var{ENVVAR} @tab Shall be of type @code{CHARACTER(*)}.
4244 @item @var{VALUE} @tab Shall be of type @code{CHARACTER(*)}.
4247 @item @emph{Return value}:
4248 Stores the value of @var{ENVVAR} in @var{VALUE}. If @var{VALUE} is
4249 not large enough to hold the data, it is truncated. If @var{ENVVAR}
4250 is not set, @var{VALUE} will be filled with blanks.
4252 @item @emph{Example}:
4255 CHARACTER(len=255) :: homedir
4256 CALL get_environment_variable("HOME", homedir)
4257 WRITE (*,*) TRIM(homedir)
4265 @section @code{GETGID} --- Group ID function
4266 @cindex @code{GETGID} intrinsic
4267 @cindex file system operations
4270 @item @emph{Description}:
4271 Returns the numerical group ID of the current process.
4273 @item @emph{Standard}:
4279 @item @emph{Syntax}:
4280 @code{RESULT = GETGID()}
4282 @item @emph{Return value}:
4283 The return value of @code{GETGID} is an @code{INTEGER} of the default
4287 @item @emph{Example}:
4288 See @code{GETPID} for an example.
4290 @item @emph{See also}:
4291 @ref{GETPID}, @ref{GETUID}
4297 @section @code{GETLOG} --- Get login name
4298 @cindex @code{GETLOG} intrinsic
4301 @item @emph{Description}:
4302 Gets the username under which the program is running.
4304 @item @emph{Standard}:
4310 @item @emph{Syntax}:
4311 @code{CALL GETLOG(LOGIN)}
4313 @item @emph{Arguments}:
4314 @multitable @columnfractions .15 .80
4315 @item @var{LOGIN} @tab Shall be of type @code{CHARACTER(*)}.
4318 @item @emph{Return value}:
4319 Stores the current user name in @var{LOGIN}. (On systems where
4320 the @code{getlogin(3)} function is not implemented, this will
4321 return a blank string.)
4323 @item @emph{Example}:
4326 CHARACTER(32) :: login
4332 @item @emph{See also}:
4339 @section @code{GETPID} --- Process ID function
4340 @cindex @code{GETPID} intrinsic
4341 @cindex process ID, current
4344 @item @emph{Description}:
4345 Returns the numerical process identifier of the current process.
4347 @item @emph{Standard}:
4353 @item @emph{Syntax}:
4354 @code{RESULT = GETPID()}
4356 @item @emph{Return value}:
4357 The return value of @code{GETPID} is an @code{INTEGER} of the default
4361 @item @emph{Example}:
4364 print *, "The current process ID is ", getpid()
4365 print *, "Your numerical user ID is ", getuid()
4366 print *, "Your numerical group ID is ", getgid()
4370 @item @emph{See also}:
4371 @ref{GETGID}, @ref{GETUID}
4377 @section @code{GETUID} --- User ID function
4378 @cindex @code{GETUID} intrinsic
4379 @cindex user ID, current
4382 @item @emph{Description}:
4383 Returns the numerical user ID of the current process.
4385 @item @emph{Standard}:
4391 @item @emph{Syntax}:
4392 @code{RESULT = GETUID()}
4394 @item @emph{Return value}:
4395 The return value of @code{GETUID} is an @code{INTEGER} of the default
4399 @item @emph{Example}:
4400 See @code{GETPID} for an example.
4402 @item @emph{See also}:
4403 @ref{GETPID}, @ref{GETLOG}
4409 @section @code{GMTIME} --- Convert time to GMT info
4410 @cindex @code{GMTIME} intrinsic
4411 @cindex time, conversion function
4414 @item @emph{Description}:
4415 Given a system time value @var{STIME} (as provided by the @code{TIME8()}
4416 intrinsic), fills @var{TARRAY} with values extracted from it appropriate
4417 to the UTC time zone (Universal Coordinated Time, also known in some
4418 countries as GMT, Greenwich Mean Time), using @code{gmtime(3)}.
4420 @item @emph{Standard}:
4426 @item @emph{Syntax}:
4427 @code{CALL GMTIME(STIME, TARRAY)}
4429 @item @emph{Arguments}:
4430 @multitable @columnfractions .15 .80
4431 @item @var{STIME} @tab An @code{INTEGER(*)} scalar expression
4432 corresponding to a system time, with
4434 @item @var{TARRAY} @tab A default @code{INTEGER} array with 9 elements,
4435 with @code{INTENT(OUT)}.
4438 @item @emph{Return value}:
4439 The elements of @var{TARRAY} are assigned as follows:
4441 @item Seconds after the minute, range 0--59 or 0--61 to allow for leap
4443 @item Minutes after the hour, range 0--59
4444 @item Hours past midnight, range 0--23
4445 @item Day of month, range 0--31
4446 @item Number of months since January, range 0--12
4447 @item Years since 1900
4448 @item Number of days since Sunday, range 0--6
4449 @item Days since January 1
4450 @item Daylight savings indicator: positive if daylight savings is in
4451 effect, zero if not, and negative if the information is not
4455 @item @emph{See also}:
4456 @ref{CTIME}, @ref{LTIME}, @ref{TIME}, @ref{TIME8}
4463 @section @code{HOSTNM} --- Get system host name
4464 @cindex @code{HOSTNM} intrinsic
4467 @item @emph{Description}:
4468 Retrieves the host name of the system on which the program is running.
4470 This intrinsic is provided in both subroutine and function forms; however,
4471 only one form can be used in any given program unit.
4473 @item @emph{Standard}:
4477 Subroutine, function
4479 @item @emph{Syntax}:
4480 @multitable @columnfractions .80
4481 @item @code{CALL HOSTNM(NAME[, STATUS])}
4482 @item @code{STATUS = HOSTNM(NAME)}
4485 @item @emph{Arguments}:
4486 @multitable @columnfractions .15 .80
4487 @item @var{NAME} @tab Shall of type @code{CHARACTER(*)}.
4488 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
4489 Returns 0 on success, or a system specific error
4493 @item @emph{Return value}:
4494 In either syntax, @var{NAME} is set to the current hostname if it can
4495 be obtained, or to a blank string otherwise.
4502 @section @code{HUGE} --- Largest number of a kind
4503 @cindex @code{HUGE} intrinsic
4507 @item @emph{Description}:
4508 @code{HUGE(X)} returns the largest number that is not an infinity in
4509 the model of the type of @code{X}.
4511 @item @emph{Standard}:
4517 @item @emph{Syntax}:
4518 @code{RESULT = HUGE(X)}
4520 @item @emph{Arguments}:
4521 @multitable @columnfractions .15 .80
4522 @item @var{X} @tab shall be of type @code{REAL} or @code{INTEGER}.
4525 @item @emph{Return value}:
4526 The return value is of the same type and kind as @var{X}
4528 @item @emph{Example}:
4530 program test_huge_tiny
4531 print *, huge(0), huge(0.0), huge(0.0d0)
4532 print *, tiny(0.0), tiny(0.0d0)
4533 end program test_huge_tiny
4540 @section @code{IACHAR} --- Code in @acronym{ASCII} collating sequence
4541 @cindex @code{IACHAR} intrinsic
4542 @cindex @acronym{ASCII} collating sequence
4543 @cindex conversion function (character)
4546 @item @emph{Description}:
4547 @code{IACHAR(C)} returns the code for the @acronym{ASCII} character
4548 in the first character position of @code{C}.
4550 @item @emph{Standard}:
4556 @item @emph{Syntax}:
4557 @code{RESULT = IACHAR(C)}
4559 @item @emph{Arguments}:
4560 @multitable @columnfractions .15 .80
4561 @item @var{C} @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
4564 @item @emph{Return value}:
4565 The return value is of type @code{INTEGER} and of the default integer
4568 @item @emph{Example}:
4573 end program test_iachar
4576 @item @emph{See also}:
4577 @ref{ACHAR}, @ref{CHAR}, @ref{ICHAR}
4583 @section @code{IAND} --- Bitwise logical and
4584 @cindex @code{IAND} intrinsic
4585 @cindex bit operations
4588 @item @emph{Description}:
4589 Bitwise logical @code{AND}.
4591 @item @emph{Standard}:
4597 @item @emph{Syntax}:
4598 @code{RESULT = IAND(I, J)}
4600 @item @emph{Arguments}:
4601 @multitable @columnfractions .15 .80
4602 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
4603 @item @var{J} @tab The type shall be @code{INTEGER(*)}, of the same
4604 kind as @var{I}. (As a GNU extension, different kinds are also
4608 @item @emph{Return value}:
4609 The return type is @code{INTEGER(*)}, of the same kind as the
4610 arguments. (If the argument kinds differ, it is of the same kind as
4611 the larger argument.)
4613 @item @emph{Example}:
4617 DATA a / Z'F' /, b / Z'3' /
4618 WRITE (*,*) IAND(a, b)
4622 @item @emph{See also}:
4623 @ref{IOR}, @ref{IEOR}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
4630 @section @code{IARGC} --- Get the number of command line arguments
4631 @cindex @code{IARGC} intrinsic
4632 @cindex command-line arguments, to program
4635 @item @emph{Description}:
4636 @code{IARGC()} returns the number of arguments passed on the
4637 command line when the containing program was invoked.
4639 This intrinsic routine is provided for backwards compatibility with
4640 GNU Fortran 77. In new code, programmers should consider the use of
4641 the @ref{COMMAND_ARGUMENT_COUNT} intrinsic defined by the Fortran 2003
4644 @item @emph{Standard}:
4648 Non-elemental Function
4650 @item @emph{Syntax}:
4651 @code{RESULT = IARGC()}
4653 @item @emph{Arguments}:
4656 @item @emph{Return value}:
4657 The number of command line arguments, type @code{INTEGER(4)}.
4659 @item @emph{Example}:
4662 @item @emph{See also}:
4663 GNU Fortran 77 compatibility subroutine: @ref{GETARG}
4665 F2003 functions and subroutines: @ref{GET_COMMAND}, @ref{GET_COMMAND_ARGUMENT},
4666 @ref{COMMAND_ARGUMENT_COUNT}
4672 @section @code{IBCLR} --- Clear bit
4673 @cindex @code{IBCLR} intrinsic
4674 @cindex bit operations
4677 @item @emph{Description}:
4678 @code{IBCLR} returns the value of @var{I} with the bit at position
4679 @var{POS} set to zero.
4681 @item @emph{Standard}:
4687 @item @emph{Syntax}:
4688 @code{RESULT = IBCLR(I, POS)}
4690 @item @emph{Arguments}:
4691 @multitable @columnfractions .15 .80
4692 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
4693 @item @var{POS} @tab The type shall be @code{INTEGER(*)}.
4696 @item @emph{Return value}:
4697 The return value is of type @code{INTEGER(*)} and of the same kind as
4700 @item @emph{See also}:
4701 @ref{IBITS}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}, @ref{MVBITS}
4708 @section @code{IBITS} --- Bit extraction
4709 @cindex @code{IBITS} intrinsic
4710 @cindex bit operations
4713 @item @emph{Description}:
4714 @code{IBITS} extracts a field of length @var{LEN} from @var{I},
4715 starting from bit position @var{POS} and extending left for @var{LEN}
4716 bits. The result is right-justified and the remaining bits are
4717 zeroed. The value of @code{POS+LEN} must be less than or equal to the
4718 value @code{BIT_SIZE(I)}.
4720 @item @emph{Standard}:
4726 @item @emph{Syntax}:
4727 @code{RESULT = IBITS(I, POS, LEN)}
4729 @item @emph{Arguments}:
4730 @multitable @columnfractions .15 .80
4731 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
4732 @item @var{POS} @tab The type shall be @code{INTEGER(*)}.
4733 @item @var{LEN} @tab The type shall be @code{INTEGER(*)}.
4736 @item @emph{Return value}:
4737 The return value is of type @code{INTEGER(*)} and of the same kind as
4740 @item @emph{See also}:
4741 @ref{BIT_SIZE}, @ref{IBCLR}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
4747 @section @code{IBSET} --- Set bit
4748 @cindex @code{IBSET} intrinsic
4749 @cindex bit operations
4752 @item @emph{Description}:
4753 @code{IBSET} returns the value of @var{I} with the bit at position
4754 @var{POS} set to one.
4756 @item @emph{Standard}:
4762 @item @emph{Syntax}:
4763 @code{RESULT = IBSET(I, POS)}
4765 @item @emph{Arguments}:
4766 @multitable @columnfractions .15 .80
4767 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
4768 @item @var{POS} @tab The type shall be @code{INTEGER(*)}.
4771 @item @emph{Return value}:
4772 The return value is of type @code{INTEGER(*)} and of the same kind as
4775 @item @emph{See also}:
4776 @ref{IBCLR}, @ref{IBITS}, @ref{IAND}, @ref{IOR}, @ref{IEOR}, @ref{MVBITS}
4783 @section @code{ICHAR} --- Character-to-integer conversion function
4784 @cindex @code{ICHAR} intrinsic
4785 @cindex conversion function (character)
4788 @item @emph{Description}:
4789 @code{ICHAR(C)} returns the code for the character in the first character
4790 position of @code{C} in the system's native character set.
4791 The correspondence between characters and their codes is not necessarily
4792 the same across different GNU Fortran implementations.
4794 @item @emph{Standard}:
4800 @item @emph{Syntax}:
4801 @code{RESULT = ICHAR(C)}
4803 @item @emph{Arguments}:
4804 @multitable @columnfractions .15 .80
4805 @item @var{C} @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
4808 @item @emph{Return value}:
4809 The return value is of type @code{INTEGER} and of the default integer
4812 @item @emph{Example}:
4817 end program test_ichar
4821 No intrinsic exists to convert a printable character string to a numerical
4822 value. For example, there is no intrinsic that, given the @code{CHARACTER}
4823 value 154, returns an @code{INTEGER} or @code{REAL} value with the
4826 Instead, you can use internal-file I/O to do this kind of conversion. For
4831 character(len=10) string
4834 read (string,'(I10)') value
4836 end program read_val
4839 @item @emph{See also}:
4840 @ref{ACHAR}, @ref{CHAR}, @ref{IACHAR}
4847 @section @code{IDATE} --- Get current local time subroutine (day/month/year)
4848 @cindex @code{IDATE} intrinsic
4851 @item @emph{Description}:
4852 @code{IDATE(TARRAY)} Fills @var{TARRAY} with the numerical values at the
4853 current local time. The day (in the range 1-31), month (in the range 1-12),
4854 and year appear in elements 1, 2, and 3 of @var{TARRAY}, respectively.
4855 The year has four significant digits.
4857 @item @emph{Standard}:
4863 @item @emph{Syntax}:
4864 @code{CALL IDATE(TARRAY)}
4866 @item @emph{Arguments}:
4867 @multitable @columnfractions .15 .80
4868 @item @var{TARRAY} @tab The type shall be @code{INTEGER, DIMENSION(3)} and
4869 the kind shall be the default integer kind.
4872 @item @emph{Return value}:
4875 @item @emph{Example}:
4878 integer, dimension(3) :: tarray
4883 end program test_idate
4890 @section @code{IEOR} --- Bitwise logical exclusive or
4891 @cindex @code{IEOR} intrinsic
4892 @cindex bit operations
4895 @item @emph{Description}:
4896 @code{IEOR} returns the bitwise boolean exclusive-OR of @var{I} and
4899 @item @emph{Standard}:
4905 @item @emph{Syntax}:
4906 @code{RESULT = IEOR(I, J)}
4908 @item @emph{Arguments}:
4909 @multitable @columnfractions .15 .80
4910 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
4911 @item @var{J} @tab The type shall be @code{INTEGER(*)}, of the same
4912 kind as @var{I}. (As a GNU extension, different kinds are also
4916 @item @emph{Return value}:
4917 The return type is @code{INTEGER(*)}, of the same kind as the
4918 arguments. (If the argument kinds differ, it is of the same kind as
4919 the larger argument.)
4921 @item @emph{See also}:
4922 @ref{IOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
4928 @section @code{IERRNO} --- Get the last system error number
4929 @cindex @code{IERRNO} intrinsic
4932 @item @emph{Description}:
4933 Returns the last system error number, as given by the C @code{errno()}
4936 @item @emph{Standard}:
4942 @item @emph{Syntax}:
4943 @code{RESULT = IERRNO()}
4945 @item @emph{Arguments}:
4948 @item @emph{Return value}:
4949 The return value is of type @code{INTEGER} and of the default integer
4952 @item @emph{See also}:
4959 @section @code{INDEX} --- Position of a substring within a string
4960 @cindex @code{INDEX} intrinsic
4963 @item @emph{Description}:
4964 Returns the position of the start of the first occurrence of string
4965 @var{SUBSTRING} as a substring in @var{STRING}, counting from one. If
4966 @var{SUBSTRING} is not present in @var{STRING}, zero is returned. If
4967 the @var{BACK} argument is present and true, the return value is the
4968 start of the last occurrence rather than the first.
4970 @item @emph{Standard}:
4976 @item @emph{Syntax}:
4977 @code{RESULT = INDEX(STRING, SUBSTRING [, BACK])}
4979 @item @emph{Arguments}:
4980 @multitable @columnfractions .15 .80
4981 @item @var{STRING} @tab Shall be a scalar @code{CHARACTER(*)}, with
4983 @item @var{SUBSTRING} @tab Shall be a scalar @code{CHARACTER(*)}, with
4985 @item @var{BACK} @tab (Optional) Shall be a scalar @code{LOGICAL(*)}, with
4989 @item @emph{Return value}:
4990 The return value is of type @code{INTEGER} and of the default integer
4993 @item @emph{See also}:
4999 @section @code{INT} --- Convert to integer type
5000 @cindex @code{INT} intrinsic
5001 @cindex @code{IFIX} intrinsic
5002 @cindex @code{IDINT} intrinsic
5003 @cindex conversion function (integer)
5006 @item @emph{Description}:
5007 Convert to integer type
5009 @item @emph{Standard}:
5015 @item @emph{Syntax}:
5016 @item @code{RESULT = INT(X [, KIND))}
5018 @item @emph{Arguments}:
5019 @multitable @columnfractions .15 .80
5020 @item @var{X} @tab shall be of type @code{INTEGER(*)},
5021 @code{REAL(*)}, or @code{COMPLEX(*)}.
5022 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
5023 expression indicating the kind parameter of
5027 @item @emph{Return value}:
5028 These functions return a @code{INTEGER(*)} variable or array under
5029 the following rules:
5033 If @var{X} is of type @code{INTEGER(*)}, @code{INT(X) = X}
5035 If @var{X} is of type @code{REAL(*)} and @math{|X| < 1}, @code{INT(X)} equals @var{0}.
5036 If @math{|X| \geq 1}, then @code{INT(X)} equals the largest integer that does not exceed
5037 the range of @var{X} and whose sign is the same as the sign of @var{X}.
5039 If @var{X} is of type @code{COMPLEX(*)}, rule B is applied to the real part of X.
5042 @item @emph{Example}:
5046 complex :: z = (-3.7, 1.0)
5048 print *, int(z), int(z,8)
5052 @item @emph{Specific names}:
5053 @multitable @columnfractions .20 .20 .20 .40
5054 @item Name @tab Argument @tab Return type @tab Standard
5055 @item @code{IFIX(X)} @tab @code{REAL(4) X} @tab @code{INTEGER} @tab F77 and later
5056 @item @code{IDINT(X)} @tab @code{REAL(8) X} @tab @code{INTEGER} @tab F77 and later
5059 @comment @item @emph{See also}:
5065 @section @code{IOR} --- Bitwise logical or
5066 @cindex @code{IOR} intrinsic
5067 @cindex bit operations
5070 @item @emph{Description}:
5071 @code{IEOR} returns the bitwise boolean OR of @var{I} and
5074 @item @emph{Standard}:
5080 @item @emph{Syntax}:
5081 @code{RESULT = IEOR(I, J)}
5083 @item @emph{Arguments}:
5084 @multitable @columnfractions .15 .80
5085 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
5086 @item @var{J} @tab The type shall be @code{INTEGER(*)}, of the same
5087 kind as @var{I}. (As a GNU extension, different kinds are also
5091 @item @emph{Return value}:
5092 The return type is @code{INTEGER(*)}, of the same kind as the
5093 arguments. (If the argument kinds differ, it is of the same kind as
5094 the larger argument.)
5096 @item @emph{See also}:
5097 @ref{IEOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
5104 @section @code{IRAND} --- Integer pseudo-random number
5105 @cindex @code{IRAND} intrinsic
5106 @cindex random numbers
5109 @item @emph{Description}:
5110 @code{IRAND(FLAG)} returns a pseudo-random number from a uniform
5111 distribution between 0 and a system-dependent limit (which is in most
5112 cases 2147483647). If @var{FLAG} is 0, the next number
5113 in the current sequence is returned; if @var{FLAG} is 1, the generator
5114 is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
5115 it is used as a new seed with @code{SRAND}.
5117 @item @emph{Standard}:
5121 non-elemental function
5123 @item @emph{Syntax}:
5124 @code{RESULT = IRAND(FLAG)}
5126 @item @emph{Arguments}:
5127 @multitable @columnfractions .15 .80
5128 @item @var{FLAG} @tab shall be a scalar @code{INTEGER} of kind 4.
5131 @item @emph{Return value}:
5132 The return value is of @code{INTEGER(kind=4)} type.
5134 @item @emph{Example}:
5137 integer,parameter :: seed = 86456
5140 print *, irand(), irand(), irand(), irand()
5141 print *, irand(seed), irand(), irand(), irand()
5142 end program test_irand
5150 @section @code{ISHFT} --- Shift bits
5151 @cindex @code{ISHFT} intrinsic
5152 @cindex bit operations
5155 @item @emph{Description}:
5156 @code{ISHFT} returns a value corresponding to @var{I} with all of the
5157 bits shifted @var{SHIFT} places. A value of @var{SHIFT} greater than
5158 zero corresponds to a left shift, a value of zero corresponds to no
5159 shift, and a value less than zero corresponds to a right shift. If the
5160 absolute value of @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the
5161 value is undefined. Bits shifted out from the left end or right end are
5162 lost; zeros are shifted in from the opposite end.
5164 @item @emph{Standard}:
5170 @item @emph{Syntax}:
5171 @code{RESULT = ISHFT(I, SHIFT)}
5173 @item @emph{Arguments}:
5174 @multitable @columnfractions .15 .80
5175 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
5176 @item @var{SHIFT} @tab The type shall be @code{INTEGER(*)}.
5179 @item @emph{Return value}:
5180 The return value is of type @code{INTEGER(*)} and of the same kind as
5183 @item @emph{See also}:
5191 @section @code{ISHFTC} --- Shift bits circularly
5192 @cindex @code{ISHFTC} intrinsic
5193 @cindex bit operations
5196 @item @emph{Description}:
5197 @code{ISHFTC} returns a value corresponding to @var{I} with the
5198 rightmost @var{SIZE} bits shifted circularly @var{SHIFT} places; that
5199 is, bits shifted out one end are shifted into the opposite end. A value
5200 of @var{SHIFT} greater than zero corresponds to a left shift, a value of
5201 zero corresponds to no shift, and a value less than zero corresponds to
5202 a right shift. The absolute value of @var{SHIFT} must be less than
5203 @var{SIZE}. If the @var{SIZE} argument is omitted, it is taken to be
5204 equivalent to @code{BIT_SIZE(I)}.
5206 @item @emph{Standard}:
5212 @item @emph{Syntax}:
5213 @code{RESULT = ISHFTC(I, SHIFT [, SIZE])}
5215 @item @emph{Arguments}:
5216 @multitable @columnfractions .15 .80
5217 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
5218 @item @var{SHIFT} @tab The type shall be @code{INTEGER(*)}.
5219 @item @var{SIZE} @tab (Optional) The type shall be @code{INTEGER(*)};
5220 the value must be greater than zero and less than or equal to
5224 @item @emph{Return value}:
5225 The return value is of type @code{INTEGER(*)} and of the same kind as
5228 @item @emph{See also}:
5235 @section @code{ITIME} --- Get current local time subroutine (hour/minutes/seconds)
5236 @cindex @code{ITIME} intrinsic
5239 @item @emph{Description}:
5240 @code{IDATE(TARRAY)} Fills @var{TARRAY} with the numerical values at the
5241 current local time. The hour (in the range 1-24), minute (in the range 1-60),
5242 and seconds (in the range 1-60) appear in elements 1, 2, and 3 of @var{TARRAY},
5245 @item @emph{Standard}:
5251 @item @emph{Syntax}:
5252 @code{CALL ITIME(TARRAY)}
5254 @item @emph{Arguments}:
5255 @multitable @columnfractions .15 .80
5256 @item @var{TARRAY} @tab The type shall be @code{INTEGER, DIMENSION(3)}
5257 and the kind shall be the default integer kind.
5260 @item @emph{Return value}:
5264 @item @emph{Example}:
5267 integer, dimension(3) :: tarray
5272 end program test_itime
5279 @section @code{KILL} --- Send a signal to a process
5280 @cindex @code{KILL} intrinsic
5283 @item @emph{Description}:
5284 @item @emph{Standard}:
5285 Sends the signal specified by @var{SIGNAL} to the process @var{PID}.
5291 @item @emph{Syntax}:
5292 @code{CALL KILL(PID, SIGNAL [, STATUS])}
5294 @item @emph{Arguments}:
5295 @multitable @columnfractions .15 .80
5296 @item @var{PID} @tab Shall be a scalar @code{INTEGER}, with
5298 @item @var{SIGNAL} @tab Shall be a scalar @code{INTEGER}, with
5300 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)} or
5301 @code{INTEGER(8)}. Returns 0 on success, or a
5302 system-specific error code otherwise.
5305 @item @emph{See also}:
5306 @ref{ABORT}, @ref{EXIT}
5312 @section @code{KIND} --- Kind of an entity
5313 @cindex @code{KIND} intrinsic
5316 @item @emph{Description}:
5317 @code{KIND(X)} returns the kind value of the entity @var{X}.
5319 @item @emph{Standard}:
5325 @item @emph{Syntax}:
5328 @item @emph{Arguments}:
5329 @multitable @columnfractions .15 .80
5330 @item @var{X} @tab Shall be of type @code{LOGICAL}, @code{INTEGER},
5331 @code{REAL}, @code{COMPLEX} or @code{CHARACTER}.
5334 @item @emph{Return value}:
5335 The return value is a scalar of type @code{INTEGER} and of the default
5338 @item @emph{Example}:
5341 integer,parameter :: kc = kind(' ')
5342 integer,parameter :: kl = kind(.true.)
5344 print *, "The default character kind is ", kc
5345 print *, "The default logical kind is ", kl
5346 end program test_kind
5354 @section @code{LBOUND} --- Lower dimension bounds of an array
5355 @cindex @code{LBOUND} intrinsic
5358 @item @emph{Description}:
5359 Returns the lower bounds of an array, or a single lower bound
5360 along the @var{DIM} dimension.
5361 @item @emph{Standard}:
5367 @item @emph{Syntax}:
5368 @code{RESULT = LBOUND(ARRAY [, DIM])}
5370 @item @emph{Arguments}:
5371 @multitable @columnfractions .15 .80
5372 @item @var{ARRAY} @tab Shall be an array, of any type.
5373 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER(*)}.
5376 @item @emph{Return value}:
5377 If @var{DIM} is absent, the result is an array of the lower bounds of
5378 @var{ARRAY}. If @var{DIM} is present, the result is a scalar
5379 corresponding to the lower bound of the array along that dimension. If
5380 @var{ARRAY} is an expression rather than a whole array or array
5381 structure component, or if it has a zero extent along the relevant
5382 dimension, the lower bound is taken to be 1.
5384 @item @emph{See also}:
5391 @section @code{LEN} --- Length of a character entity
5392 @cindex @code{LEN} intrinsic
5395 @item @emph{Description}:
5396 Returns the length of a character string. If @var{STRING} is an array,
5397 the length of an element of @var{STRING} is returned. Note that
5398 @var{STRING} need not be defined when this intrinsic is invoked, since
5399 only the length, not the content, of @var{STRING} is needed.
5401 @item @emph{Standard}:
5407 @item @emph{Syntax}:
5408 @code{L = LEN(STRING)}
5410 @item @emph{Arguments}:
5411 @multitable @columnfractions .15 .80
5412 @item @var{STRING} @tab Shall be a scalar or array of type
5413 @code{CHARACTER(*)}, with @code{INTENT(IN)}
5416 @item @emph{Return value}:
5417 The return value is an @code{INTEGER} of the default kind.
5419 @item @emph{See also}:
5420 @ref{LEN_TRIM}, @ref{ADJUSTL}, @ref{ADJUSTR}
5426 @section @code{LEN_TRIM} --- Length of a character entity without trailing blank characters
5427 @cindex @code{LEN_TRIM} intrinsic
5430 @item @emph{Description}:
5431 Returns the length of a character string, ignoring any trailing blanks.
5433 @item @emph{Standard}:
5439 @item @emph{Syntax}:
5440 @code{RESULT = LEN_TRIM(STRING)}
5442 @item @emph{Arguments}:
5443 @multitable @columnfractions .15 .80
5444 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER(*)},
5445 with @code{INTENT(IN)}
5448 @item @emph{Return value}:
5449 The return value is an @code{INTEGER} of the default kind.
5451 @item @emph{See also}:
5452 @ref{LEN}, @ref{ADJUSTL}, @ref{ADJUSTR}
5458 @section @code{LGE} --- Lexical greater than or equal
5459 @cindex @code{LGE} intrinsic
5460 @cindex comparison (lexical)
5461 @cindex lexical comparison
5464 @item @emph{Description}:
5465 Determines whether one string is lexically greater than or equal to
5466 another string, where the two strings are interpreted as containing
5467 ASCII character codes. If the String A and String B are not the same
5468 length, the shorter is compared as if spaces were appended to it to form
5469 a value that has the same length as the longer.
5471 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
5472 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
5473 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
5474 that the latter use the processor's character ordering (which is not
5475 ASCII on some targets), whereas the former always use the ASCII
5478 @item @emph{Standard}:
5484 @item @emph{Syntax}:
5485 @code{RESULT = LGE(STRING_A, STRING_B)}
5487 @item @emph{Arguments}:
5488 @multitable @columnfractions .15 .80
5489 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
5490 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
5493 @item @emph{Return value}:
5494 Returns @code{.TRUE.} if @code{STRING_A >= STRING_B}, and @code{.FALSE.}
5495 otherwise, based on the ASCII ordering.
5497 @item @emph{See also}:
5498 @ref{LGT}, @ref{LLE}, @ref{LLT}
5504 @section @code{LGT} --- Lexical greater than
5505 @cindex @code{LGT} intrinsic
5506 @cindex comparison (lexical)
5507 @cindex lexical comparison
5510 @item @emph{Description}:
5511 Determines whether one string is lexically greater than another string,
5512 where the two strings are interpreted as containing ASCII character
5513 codes. If the String A and String B are not the same length, the
5514 shorter is compared as if spaces were appended to it to form a value
5515 that has the same length as the longer.
5517 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
5518 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
5519 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
5520 that the latter use the processor's character ordering (which is not
5521 ASCII on some targets), whereas the former always use the ASCII
5524 @item @emph{Standard}:
5530 @item @emph{Syntax}:
5531 @code{RESULT = LGT(STRING_A, STRING_B)}
5533 @item @emph{Arguments}:
5534 @multitable @columnfractions .15 .80
5535 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
5536 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
5539 @item @emph{Return value}:
5540 Returns @code{.TRUE.} if @code{STRING_A > STRING_B}, and @code{.FALSE.}
5541 otherwise, based on the ASCII ordering.
5543 @item @emph{See also}:
5544 @ref{LGE}, @ref{LLE}, @ref{LLT}
5550 @section @code{LINK} --- Create a hard link
5551 @cindex @code{LINK} intrinsic
5552 @cindex file system operations
5555 @item @emph{Description}:
5556 Makes a (hard) link from file @var{PATH1} to @var{PATH2}. A null
5557 character (@code{CHAR(0)}) can be used to mark the end of the names in
5558 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
5559 names are ignored. If the @var{STATUS} argument is supplied, it
5560 contains 0 on success or a nonzero error code upon return; see
5563 @item @emph{Standard}:
5569 @item @emph{Syntax}:
5570 @code{CALL LINK(PATH1, PATH2 [, STATUS])}
5572 @item @emph{Arguments}:
5573 @multitable @columnfractions .15 .80
5574 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
5575 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
5576 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
5579 @item @emph{See also}:
5580 @ref{SYMLNK}, @ref{UNLINK}
5586 @section @code{LLE} --- Lexical less than or equal
5587 @cindex @code{LLE} intrinsic
5588 @cindex comparison (lexical)
5589 @cindex lexical comparison
5592 @item @emph{Description}:
5593 Determines whether one string is lexically less than or equal to another
5594 string, where the two strings are interpreted as containing ASCII
5595 character codes. If the String A and String B are not the same length,
5596 the shorter is compared as if spaces were appended to it to form a value
5597 that has the same length as the longer.
5599 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
5600 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
5601 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
5602 that the latter use the processor's character ordering (which is not
5603 ASCII on some targets), whereas the former always use the ASCII
5606 @item @emph{Standard}:
5612 @item @emph{Syntax}:
5613 @code{RESULT = LLE(STRING_A, STRING_B)}
5615 @item @emph{Arguments}:
5616 @multitable @columnfractions .15 .80
5617 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
5618 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
5621 @item @emph{Return value}:
5622 Returns @code{.TRUE.} if @code{STRING_A <= STRING_B}, and @code{.FALSE.}
5623 otherwise, based on the ASCII ordering.
5625 @item @emph{See also}:
5626 @ref{LGE}, @ref{LGT}, @ref{LLT}
5632 @section @code{LLT} --- Lexical less than
5633 @cindex @code{LLT} intrinsic
5634 @cindex comparison (lexical)
5635 @cindex lexical comparison
5638 @item @emph{Description}:
5639 Determines whether one string is lexically less than another string,
5640 where the two strings are interpreted as containing ASCII character
5641 codes. If the String A and String B are not the same length, the
5642 shorter is compared as if spaces were appended to it to form a value
5643 that has the same length as the longer.
5645 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
5646 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
5647 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
5648 that the latter use the processor's character ordering (which is not
5649 ASCII on some targets), whereas the former always use the ASCII
5652 @item @emph{Standard}:
5658 @item @emph{Syntax}:
5659 @code{RESULT = LLT(STRING_A, STRING_B)}
5661 @item @emph{Arguments}:
5662 @multitable @columnfractions .15 .80
5663 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
5664 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
5667 @item @emph{Return value}:
5668 Returns @code{.TRUE.} if @code{STRING_A < STRING_B}, and @code{.FALSE.}
5669 otherwise, based on the ASCII ordering.
5671 @item @emph{See also}:
5672 @ref{LGE}, @ref{LGT}, @ref{LLE}
5678 @section @code{LNBLNK} --- Index of the last non-blank character in a string
5679 @cindex @code{LNBLNK} intrinsic
5682 @item @emph{Description}:
5683 Returns the length of a character string, ignoring any trailing blanks.
5684 This is identical to the standard @code{LEN_TRIM} intrinsic, and is only
5685 included for backwards compatibility.
5687 @item @emph{Standard}:
5693 @item @emph{Syntax}:
5694 @code{RESULT = LNBLNK(STRING)}
5696 @item @emph{Arguments}:
5697 @multitable @columnfractions .15 .80
5698 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER(*)},
5699 with @code{INTENT(IN)}
5702 @item @emph{Return value}:
5703 The return value is of @code{INTEGER(kind=4)} type.
5705 @item @emph{See also}:
5706 @ref{INDEX}, @ref{LEN_TRIM}
5712 @section @code{LOC} --- Returns the address of a variable
5713 @cindex @code{LOC} intrinsic
5714 @cindex location of a variable in memory
5717 @item @emph{Description}:
5718 @code{LOC(X)} returns the address of @var{X} as an integer.
5720 @item @emph{Standard}:
5726 @item @emph{Syntax}:
5727 @code{RESULT = LOC(X)}
5729 @item @emph{Arguments}:
5730 @multitable @columnfractions .15 .80
5731 @item @var{X} @tab Variable of any type.
5734 @item @emph{Return value}:
5735 The return value is of type @code{INTEGER}, with a @code{KIND}
5736 corresponding to the size (in bytes) of a memory address on the target
5739 @item @emph{Example}:
5746 end program test_loc
5753 @section @code{LOG} --- Logarithm function
5754 @cindex @code{LOG} intrinsic
5755 @cindex @code{ALOG} intrinsic
5756 @cindex @code{DLOG} intrinsic
5757 @cindex @code{CLOG} intrinsic
5758 @cindex @code{ZLOG} intrinsic
5759 @cindex @code{CDLOG} intrinsic
5763 @item @emph{Description}:
5764 @code{LOG(X)} computes the logarithm of @var{X}.
5766 @item @emph{Standard}:
5772 @item @emph{Syntax}:
5773 @code{RESULT = LOG(X)}
5775 @item @emph{Arguments}:
5776 @multitable @columnfractions .15 .80
5777 @item @var{X} @tab The type shall be @code{REAL(*)} or
5781 @item @emph{Return value}:
5782 The return value is of type @code{REAL(*)} or @code{COMPLEX(*)}.
5783 The kind type parameter is the same as @var{X}.
5785 @item @emph{Example}:
5788 real(8) :: x = 1.0_8
5789 complex :: z = (1.0, 2.0)
5792 end program test_log
5795 @item @emph{Specific names}:
5796 @multitable @columnfractions .20 .20 .20 .40
5797 @item Name @tab Argument @tab Return type @tab Standard
5798 @item @code{ALOG(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab f95, gnu
5799 @item @code{DLOG(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
5800 @item @code{CLOG(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab f95, gnu
5801 @item @code{ZLOG(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
5802 @item @code{CDLOG(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
5809 @section @code{LOG10} --- Base 10 logarithm function
5810 @cindex @code{LOG10} intrinsic
5811 @cindex @code{ALOG10} intrinsic
5812 @cindex @code{DLOG10} intrinsic
5816 @item @emph{Description}:
5817 @code{LOG10(X)} computes the base 10 logarithm of @var{X}.
5819 @item @emph{Standard}:
5825 @item @emph{Syntax}:
5826 @code{RESULT = LOG10(X)}
5828 @item @emph{Arguments}:
5829 @multitable @columnfractions .15 .80
5830 @item @var{X} @tab The type shall be @code{REAL(*)} or
5834 @item @emph{Return value}:
5835 The return value is of type @code{REAL(*)} or @code{COMPLEX(*)}.
5836 The kind type parameter is the same as @var{X}.
5838 @item @emph{Example}:
5841 real(8) :: x = 10.0_8
5843 end program test_log10
5846 @item @emph{Specific names}:
5847 @multitable @columnfractions .20 .20 .20 .40
5848 @item Name @tab Argument @tab Return type @tab Standard
5849 @item @code{ALOG10(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab F95 and later
5850 @item @code{DLOG10(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
5857 @section @code{LOGICAL} --- Convert to logical type
5858 @cindex @code{LOGICAL} intrinsic
5859 @cindex conversion function (logical)
5862 @item @emph{Description}:
5863 Converts one kind of @code{LOGICAL} variable to another.
5865 @item @emph{Standard}:
5871 @item @emph{Syntax}:
5872 @code{RESULT = LOGICAL(L [, KIND])}
5874 @item @emph{Arguments}:
5875 @multitable @columnfractions .15 .80
5876 @item @var{L} @tab The type shall be @code{LOGICAL(*)}.
5877 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
5878 expression indicating the kind parameter of
5882 @item @emph{Return value}:
5883 The return value is a @code{LOGICAL} value equal to @var{L}, with a
5884 kind corresponding to @var{KIND}, or of the default logical kind if
5885 @var{KIND} is not given.
5887 @item @emph{See also}:
5888 @ref{INT}, @ref{REAL}, @ref{CMPLX}
5895 @section @code{LSHIFT} --- Left shift bits
5896 @cindex @code{LSHIFT} intrinsic
5897 @cindex bit operations
5900 @item @emph{Description}:
5901 @code{LSHIFT} returns a value corresponding to @var{I} with all of the
5902 bits shifted left by @var{SHIFT} places. If the absolute value of
5903 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
5904 Bits shifted out from the left end are lost; zeros are shifted in from
5907 This function has been superseded by the @code{ISHFT} intrinsic, which
5908 is standard in Fortran 95 and later.
5910 @item @emph{Standard}:
5916 @item @emph{Syntax}:
5917 @code{RESULT = LSHIFT(I, SHIFT)}
5919 @item @emph{Arguments}:
5920 @multitable @columnfractions .15 .80
5921 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
5922 @item @var{SHIFT} @tab The type shall be @code{INTEGER(*)}.
5925 @item @emph{Return value}:
5926 The return value is of type @code{INTEGER(*)} and of the same kind as
5929 @item @emph{See also}:
5930 @ref{ISHFT}, @ref{ISHFTC}, @ref{RSHIFT}
5936 @section @code{LSTAT} --- Get file status
5937 @cindex @code{LSTAT} intrinsic
5938 @cindex file system operations
5941 @item @emph{Description}:
5942 @code{LSTAT} is identical to @ref{STAT}, except that if path is a symbolic link,
5943 then the link itself is statted, not the file that it refers to.
5945 The elements in @code{BUFF} are the same as described by @ref{STAT}.
5947 @item @emph{Standard}:
5951 Non-elemental subroutine
5953 @item @emph{Syntax}:
5954 @code{CALL LSTAT(FILE, BUFF [, STATUS])}
5956 @item @emph{Arguments}:
5957 @multitable @columnfractions .15 .80
5958 @item @var{FILE} @tab The type shall be @code{CHARACTER(*)}, a valid path within the file system.
5959 @item @var{BUFF} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
5960 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0
5961 on success and a system specific error code otherwise.
5964 @item @emph{Example}:
5965 See @ref{STAT} for an example.
5967 @item @emph{See also}:
5968 To stat an open file: @ref{FSTAT}, to stat a file: @ref{STAT}
5974 @section @code{LTIME} --- Convert time to local time info
5975 @cindex @code{LTIME} intrinsic
5976 @cindex time, conversion function
5979 @item @emph{Description}:
5980 Given a system time value @var{STIME} (as provided by the @code{TIME8()}
5981 intrinsic), fills @var{TARRAY} with values extracted from it appropriate
5982 to the local time zone using @code{localtime(3)}.
5984 @item @emph{Standard}:
5990 @item @emph{Syntax}:
5991 @code{CALL LTIME(STIME, TARRAY)}
5993 @item @emph{Arguments}:
5994 @multitable @columnfractions .15 .80
5995 @item @var{STIME} @tab An @code{INTEGER(*)} scalar expression
5996 corresponding to a system time, with
5998 @item @var{TARRAY} @tab A default @code{INTEGER} array with 9 elements,
5999 with @code{INTENT(OUT)}.
6002 @item @emph{Return value}:
6003 The elements of @var{TARRAY} are assigned as follows:
6005 @item Seconds after the minute, range 0--59 or 0--61 to allow for leap
6007 @item Minutes after the hour, range 0--59
6008 @item Hours past midnight, range 0--23
6009 @item Day of month, range 0--31
6010 @item Number of months since January, range 0--12
6011 @item Years since 1900
6012 @item Number of days since Sunday, range 0--6
6013 @item Days since January 1
6014 @item Daylight savings indicator: positive if daylight savings is in
6015 effect, zero if not, and negative if the information is not
6019 @item @emph{See also}:
6020 @ref{CTIME}, @ref{GMTIME}, @ref{TIME}, @ref{TIME8}
6027 @section @code{MALLOC} --- Allocate dynamic memory
6028 @cindex @code{MALLOC} intrinsic
6029 @cindex Cray pointers
6032 @item @emph{Description}:
6033 @code{MALLOC(SIZE)} allocates @var{SIZE} bytes of dynamic memory and
6034 returns the address of the allocated memory. The @code{MALLOC} intrinsic
6035 is an extension intended to be used with Cray pointers, and is provided
6036 in GNU Fortran to allow the user to compile legacy code. For new code
6037 using Fortran 95 pointers, the memory allocation intrinsic is
6040 @item @emph{Standard}:
6044 non-elemental function
6046 @item @emph{Syntax}:
6047 @code{PTR = MALLOC(SIZE)}
6049 @item @emph{Arguments}:
6050 @multitable @columnfractions .15 .80
6051 @item @var{SIZE} @tab The type shall be @code{INTEGER(*)}.
6054 @item @emph{Return value}:
6055 The return value is of type @code{INTEGER(K)}, with @var{K} such that
6056 variables of type @code{INTEGER(K)} have the same size as
6057 C pointers (@code{sizeof(void *)}).
6059 @item @emph{Example}:
6060 The following example demonstrates the use of @code{MALLOC} and
6061 @code{FREE} with Cray pointers. This example is intended to run on
6062 32-bit systems, where the default integer kind is suitable to store
6063 pointers; on 64-bit systems, ptr_x would need to be declared as
6064 @code{integer(kind=8)}.
6073 ptr_x = malloc(20*8)
6075 x(i) = sqrt(1.0d0 / i)
6083 end program test_malloc
6086 @item @emph{See also}:
6093 @section @code{MATMUL} --- matrix multiplication
6094 @cindex @code{MATMUL} intrinsic
6095 @cindex matrix operations
6098 @item @emph{Description}:
6099 Performs a matrix multiplication on numeric or logical arguments.
6101 @item @emph{Standard}:
6105 Transformational function
6107 @item @emph{Syntax}:
6108 @code{RESULT = MATMUL(MATRIX_A, MATRIX_B)}
6110 @item @emph{Arguments}:
6111 @multitable @columnfractions .15 .80
6112 @item @var{MATRIX_A} @tab An array of @code{INTEGER(*)},
6113 @code{REAL(*)}, @code{COMPLEX(*)}, or
6114 @code{LOGICAL(*)} type, with a rank of
6116 @item @var{MATRIX_B} @tab An array of @code{INTEGER(*)},
6117 @code{REAL(*)}, or @code{COMPLEX(*)} type if
6118 @var{MATRIX_A} is of a numeric type;
6119 otherwise, an array of @code{LOGICAL(*)}
6120 type. The rank shall be one or two, and the
6121 first (or only) dimension of @var{MATRIX_B}
6122 shall be equal to the last (or only)
6123 dimension of @var{MATRIX_A}.
6126 @item @emph{Return value}:
6127 The matrix product of @var{MATRIX_A} and @var{MATRIX_B}. The type and
6128 kind of the result follow the usual type and kind promotion rules, as
6129 for the @code{*} or @code{.AND.} operators.
6131 @item @emph{See also}:
6137 @section @code{MAX} --- Maximum value of an argument list
6138 @cindex @code{MAX} intrinsic
6141 @item @emph{Description}:
6142 Returns the argument with the largest (most positive) value.
6144 @item @emph{Standard}:
6150 @item @emph{Syntax}:
6151 @code{RESULT = MAX(A1, A2 [, A3 [, ...]])}
6153 @item @emph{Arguments}:
6154 @multitable @columnfractions .15 .80
6155 @item @var{A1} @tab The type shall be @code{INTEGER(*)} or
6157 @item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
6158 as @var{A1}. (As a GNU extension,
6159 arguments of different kinds are
6163 @item @emph{Return value}:
6164 The return value corresponds to the maximum value among the arguments,
6165 and has the same type and kind as the first argument.
6167 @item @emph{Specific names}:
6168 @multitable @columnfractions .20 .20 .20 .40
6169 @item Name @tab Argument @tab Return type @tab Standard
6170 @item @code{MAX0(I)} @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)} @tab F77 and later
6171 @item @code{AMAX0(I)} @tab @code{INTEGER(4) I} @tab @code{REAL(MAX(X))} @tab F77 and later
6172 @item @code{MAX1(X)} @tab @code{REAL(*) X} @tab @code{INT(MAX(X))} @tab F77 and later
6173 @item @code{AMAX1(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab F77 and later
6174 @item @code{DMAX1(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
6177 @item @emph{See also}:
6178 @ref{MAXLOC} @ref{MAXVAL}, @ref{MIN}
6185 @section @code{MAXEXPONENT} --- Maximum exponent of a real kind
6186 @cindex @code{MAXEXPONENT} intrinsic
6187 @cindex maximum exponent
6188 @cindex exponent, maximum
6191 @item @emph{Description}:
6192 @code{MAXEXPONENT(X)} returns the maximum exponent in the model of the
6195 @item @emph{Standard}:
6201 @item @emph{Syntax}:
6202 @code{RESULT = MAXEXPONENT(X)}
6204 @item @emph{Arguments}:
6205 @multitable @columnfractions .15 .80
6206 @item @var{X} @tab shall be of type @code{REAL}.
6209 @item @emph{Return value}:
6210 The return value is of type @code{INTEGER} and of the default integer
6213 @item @emph{Example}:
6219 print *, minexponent(x), maxexponent(x)
6220 print *, minexponent(y), maxexponent(y)
6221 end program exponents
6228 @section @code{MAXLOC} --- Location of the maximum value within an array
6229 @cindex @code{MAXLOC} intrinsic
6232 @item @emph{Description}:
6233 Determines the location of the element in the array with the maximum
6234 value, or, if the @var{DIM} argument is supplied, determines the
6235 locations of the maximum element along each row of the array in the
6236 @var{DIM} direction. If @var{MASK} is present, only the elements for
6237 which @var{MASK} is @code{.TRUE.} are considered. If more than one
6238 element in the array has the maximum value, the location returned is
6239 that of the first such element in array element order. If the array has
6240 zero size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
6241 the result is an array of zeroes. Similarly, if @var{DIM} is supplied
6242 and all of the elements of @var{MASK} along a given row are zero, the
6243 result value for that row is zero.
6245 @item @emph{Standard}:
6249 Transformational function
6251 @item @emph{Syntax}:
6252 @multitable @columnfractions .80
6253 @item @code{RESULT = MAXLOC(ARRAY, DIM [, MASK])}
6254 @item @code{RESULT = MAXLOC(ARRAY [, MASK])}
6257 @item @emph{Arguments}:
6258 @multitable @columnfractions .15 .80
6259 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER(*)},
6260 @code{REAL(*)}, or @code{CHARACTER(*)}.
6261 @item @var{DIM} @tab (Optional) Shall be a scalar of type
6262 @code{INTEGER(*)}, with a value between one
6263 and the rank of @var{ARRAY}, inclusive. It
6264 may not be an optional dummy argument.
6265 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL(*)},
6266 and conformable with @var{ARRAY}.
6269 @item @emph{Return value}:
6270 If @var{DIM} is absent, the result is a rank-one array with a length
6271 equal to the rank of @var{ARRAY}. If @var{DIM} is present, the result
6272 is an array with a rank one less than the rank of @var{ARRAY}, and a
6273 size corresponding to the size of @var{ARRAY} with the @var{DIM}
6274 dimension removed. If @var{DIM} is present and @var{ARRAY} has a rank
6275 of one, the result is a scalar. In all cases, the result is of default
6276 @code{INTEGER} type.
6278 @item @emph{See also}:
6279 @ref{MAX}, @ref{MAXVAL}
6286 @section @code{MAXVAL} --- Maximum value of an array
6287 @cindex @code{MAXVAL} intrinsic
6290 @item @emph{Description}:
6291 Determines the maximum value of the elements in an array value, or, if
6292 the @var{DIM} argument is supplied, determines the maximum value along
6293 each row of the array in the @var{DIM} direction. If @var{MASK} is
6294 present, only the elements for which @var{MASK} is @code{.TRUE.} are
6295 considered. If the array has zero size, or all of the elements of
6296 @var{MASK} are @code{.FALSE.}, then the result is the most negative
6297 number of the type and kind of @var{ARRAY} if @var{ARRAY} is numeric, or
6298 a string of nulls if @var{ARRAY} is of character type.
6300 @item @emph{Standard}:
6304 Transformational function
6306 @item @emph{Syntax}:
6307 @multitable @columnfractions .80
6308 @item @code{RESULT = MAXVAL(ARRAY, DIM [, MASK])}
6309 @item @code{RESULT = MAXVAL(ARRAY [, MASK])}
6312 @item @emph{Arguments}:
6313 @multitable @columnfractions .15 .80
6314 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER(*)},
6315 @code{REAL(*)}, or @code{CHARACTER(*)}.
6316 @item @var{DIM} @tab (Optional) Shall be a scalar of type
6317 @code{INTEGER(*)}, with a value between one
6318 and the rank of @var{ARRAY}, inclusive. It
6319 may not be an optional dummy argument.
6320 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL(*)},
6321 and conformable with @var{ARRAY}.
6324 @item @emph{Return value}:
6325 If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
6326 is a scalar. If @var{DIM} is present, the result is an array with a
6327 rank one less than the rank of @var{ARRAY}, and a size corresponding to
6328 the size of @var{ARRAY} with the @var{DIM} dimension removed. In all
6329 cases, the result is of the same type and kind as @var{ARRAY}.
6331 @item @emph{See also}:
6332 @ref{MAX}, @ref{MAXLOC}
6338 @section @code{MERGE} --- Merge variables
6339 @cindex @code{MERGE} intrinsic
6342 @item @emph{Description}:
6343 Select values from two arrays according to a logical mask. The result
6344 is equal to @var{TSOURCE} if @var{MASK} is @code{.TRUE.}, or equal to
6345 @var{FSOURCE} if it is @code{.FALSE.}.
6347 @item @emph{Standard}:
6353 @item @emph{Syntax}:
6354 @code{RESULT = MERGE(TSOURCE, FSOURCE, MASK)}
6356 @item @emph{Arguments}:
6357 @multitable @columnfractions .15 .80
6358 @item @var{TSOURCE} @tab May be of any type.
6359 @item @var{FSOURCE} @tab Shall be of the same type and type parameters
6361 @item @var{MASK} @tab Shall be of type @code{LOGICAL(*)}.
6364 @item @emph{Return value}:
6365 The result is of the same type and type parameters as @var{TSOURCE}.
6372 @section @code{MIN} --- Minimum value of an argument list
6373 @cindex @code{MIN} intrinsic
6376 @item @emph{Description}:
6377 Returns the argument with the smallest (most negative) value.
6379 @item @emph{Standard}:
6385 @item @emph{Syntax}:
6386 @code{RESULT = MIN(A1, A2 [, A3, ...])}
6388 @item @emph{Arguments}:
6389 @multitable @columnfractions .15 .80
6390 @item @var{A1} @tab The type shall be @code{INTEGER(*)} or
6392 @item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
6393 as @var{A1}. (As a GNU extension,
6394 arguments of different kinds are
6398 @item @emph{Return value}:
6399 The return value corresponds to the maximum value among the arguments,
6400 and has the same type and kind as the first argument.
6402 @item @emph{Specific names}:
6403 @multitable @columnfractions .20 .20 .20 .40
6404 @item Name @tab Argument @tab Return type @tab Standard
6405 @item @code{MIN0(I)} @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)} @tab F77 and later
6406 @item @code{AMIN0(I)} @tab @code{INTEGER(4) I} @tab @code{REAL(MIN(X))} @tab F77 and later
6407 @item @code{MIN1(X)} @tab @code{REAL(*) X} @tab @code{INT(MIN(X))} @tab F77 and later
6408 @item @code{AMIN1(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab F77 and later
6409 @item @code{DMIN1(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
6412 @item @emph{See also}:
6413 @ref{MAX}, @ref{MINLOC}, @ref{MINVAL}
6417 @section @code{MINEXPONENT} --- Minimum exponent of a real kind
6418 @cindex @code{MINEXPONENT} intrinsic
6419 @cindex minimum exponent
6420 @cindex exponent, minimum
6423 @item @emph{Description}:
6424 @code{MINEXPONENT(X)} returns the minimum exponent in the model of the
6427 @item @emph{Standard}:
6433 @item @emph{Syntax}:
6434 @code{RESULT = MINEXPONENT(X)}
6436 @item @emph{Arguments}:
6437 @multitable @columnfractions .15 .80
6438 @item @var{X} @tab shall be of type @code{REAL}.
6441 @item @emph{Return value}:
6442 The return value is of type @code{INTEGER} and of the default integer
6445 @item @emph{Example}:
6446 See @code{MAXEXPONENT} for an example.
6452 @section @code{MINLOC} --- Location of the minimum value within an array
6453 @cindex @code{MINLOC} intrinsic
6456 @item @emph{Description}:
6457 Determines the location of the element in the array with the minimum
6458 value, or, if the @var{DIM} argument is supplied, determines the
6459 locations of the minimum element along each row of the array in the
6460 @var{DIM} direction. If @var{MASK} is present, only the elements for
6461 which @var{MASK} is @code{.TRUE.} are considered. If more than one
6462 element in the array has the minimum value, the location returned is
6463 that of the first such element in array element order. If the array has
6464 zero size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
6465 the result is an array of zeroes. Similarly, if @var{DIM} is supplied
6466 and all of the elements of @var{MASK} along a given row are zero, the
6467 result value for that row is zero.
6469 @item @emph{Standard}:
6473 Transformational function
6475 @item @emph{Syntax}:
6476 @multitable @columnfractions .80
6477 @item @code{RESULT = MINLOC(ARRAY, DIM [, MASK])}
6478 @item @code{RESULT = MINLOC(ARRAY [, MASK])}
6481 @item @emph{Arguments}:
6482 @multitable @columnfractions .15 .80
6483 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER(*)},
6484 @code{REAL(*)}, or @code{CHARACTER(*)}.
6485 @item @var{DIM} @tab (Optional) Shall be a scalar of type
6486 @code{INTEGER(*)}, with a value between one
6487 and the rank of @var{ARRAY}, inclusive. It
6488 may not be an optional dummy argument.
6489 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL(*)},
6490 and conformable with @var{ARRAY}.
6493 @item @emph{Return value}:
6494 If @var{DIM} is absent, the result is a rank-one array with a length
6495 equal to the rank of @var{ARRAY}. If @var{DIM} is present, the result
6496 is an array with a rank one less than the rank of @var{ARRAY}, and a
6497 size corresponding to the size of @var{ARRAY} with the @var{DIM}
6498 dimension removed. If @var{DIM} is present and @var{ARRAY} has a rank
6499 of one, the result is a scalar. In all cases, the result is of default
6500 @code{INTEGER} type.
6502 @item @emph{See also}:
6503 @ref{MIN}, @ref{MINVAL}
6510 @section @code{MINVAL} --- Minimum value of an array
6511 @cindex @code{MINVAL} intrinsic
6514 @item @emph{Description}:
6515 Determines the minimum value of the elements in an array value, or, if
6516 the @var{DIM} argument is supplied, determines the minimum value along
6517 each row of the array in the @var{DIM} direction. If @var{MASK} is
6518 present, only the elements for which @var{MASK} is @code{.TRUE.} are
6519 considered. If the array has zero size, or all of the elements of
6520 @var{MASK} are @code{.FALSE.}, then the result is @code{HUGE(ARRAY)} if
6521 @var{ARRAY} is numeric, or a string of @code{CHAR(255)} characters if
6522 @var{ARRAY} is of character type.
6524 @item @emph{Standard}:
6528 Transformational function
6530 @item @emph{Syntax}:
6531 @multitable @columnfractions .80
6532 @item @code{RESULT = MINVAL(ARRAY, DIM [, MASK])}
6533 @item @code{RESULT = MINVAL(ARRAY [, MASK])}
6536 @item @emph{Arguments}:
6537 @multitable @columnfractions .15 .80
6538 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER(*)},
6539 @code{REAL(*)}, or @code{CHARACTER(*)}.
6540 @item @var{DIM} @tab (Optional) Shall be a scalar of type
6541 @code{INTEGER(*)}, with a value between one
6542 and the rank of @var{ARRAY}, inclusive. It
6543 may not be an optional dummy argument.
6544 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL(*)},
6545 and conformable with @var{ARRAY}.
6548 @item @emph{Return value}:
6549 If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
6550 is a scalar. If @var{DIM} is present, the result is an array with a
6551 rank one less than the rank of @var{ARRAY}, and a size corresponding to
6552 the size of @var{ARRAY} with the @var{DIM} dimension removed. In all
6553 cases, the result is of the same type and kind as @var{ARRAY}.
6555 @item @emph{See also}:
6556 @ref{MIN}, @ref{MINLOC}
6563 @section @code{MOD} --- Remainder function
6564 @cindex @code{MOD} intrinsic
6565 @cindex @code{AMOD} intrinsic
6566 @cindex @code{DMOD} intrinsic
6570 @item @emph{Description}:
6571 @code{MOD(A,P)} computes the remainder of the division of A by P. It is
6572 calculated as @code{A - (INT(A/P) * P)}.
6574 @item @emph{Standard}:
6580 @item @emph{Syntax}:
6581 @code{RESULT = MOD(A, P)}
6583 @item @emph{Arguments}:
6584 @multitable @columnfractions .15 .80
6585 @item @var{A} @tab shall be a scalar of type @code{INTEGER} or @code{REAL}
6586 @item @var{P} @tab shall be a scalar of the same type as @var{A} and not
6590 @item @emph{Return value}:
6591 The kind of the return value is the result of cross-promoting
6592 the kinds of the arguments.
6594 @item @emph{Example}:
6598 print *, mod(17.5,5.5)
6599 print *, mod(17.5d0,5.5)
6600 print *, mod(17.5,5.5d0)
6603 print *, mod(-17.5,5.5)
6604 print *, mod(-17.5d0,5.5)
6605 print *, mod(-17.5,5.5d0)
6608 print *, mod(17.5,-5.5)
6609 print *, mod(17.5d0,-5.5)
6610 print *, mod(17.5,-5.5d0)
6611 end program test_mod
6614 @item @emph{Specific names}:
6615 @multitable @columnfractions .20 .20 .20 .40
6616 @item Name @tab Arguments @tab Return type @tab Standard
6617 @item @code{AMOD(A,P)} @tab @code{REAL(4)} @tab @code{REAL(4)} @tab F95 and later
6618 @item @code{DMOD(A,P)} @tab @code{REAL(8)} @tab @code{REAL(8)} @tab F95 and later
6625 @section @code{MODULO} --- Modulo function
6626 @cindex @code{MODULO} intrinsic
6630 @item @emph{Description}:
6631 @code{MODULO(A,P)} computes the @var{A} modulo @var{P}.
6633 @item @emph{Standard}:
6639 @item @emph{Syntax}:
6640 @code{RESULT = MODULO(A, P)}
6642 @item @emph{Arguments}:
6643 @multitable @columnfractions .15 .80
6644 @item @var{A} @tab shall be a scalar of type @code{INTEGER} or @code{REAL}
6645 @item @var{P} @tab shall be a scalar of the same type and kind as @var{A}
6648 @item @emph{Return value}:
6649 The type and kind of the result are those of the arguments.
6651 @item If @var{A} and @var{P} are of type @code{INTEGER}:
6652 @code{MODULO(A,P)} has the value @var{R} such that @code{A=Q*P+R}, where
6653 @var{Q} is an integer and @var{R} is between 0 (inclusive) and @var{P}
6655 @item If @var{A} and @var{P} are of type @code{REAL}:
6656 @code{MODULO(A,P)} has the value of @code{A - FLOOR (A / P) * P}.
6658 In all cases, if @var{P} is zero the result is processor-dependent.
6660 @item @emph{Example}:
6663 print *, modulo(17,3)
6664 print *, modulo(17.5,5.5)
6666 print *, modulo(-17,3)
6667 print *, modulo(-17.5,5.5)
6669 print *, modulo(17,-3)
6670 print *, modulo(17.5,-5.5)
6671 end program test_mod
6679 @section @code{MOVE_ALLOC} --- Move allocation from one object to another
6680 @cindex @code{MOVE_ALLOC} intrinsic
6681 @cindex moving allocation
6682 @cindex allocation, moving
6685 @item @emph{Description}:
6686 @code{MOVE_ALLOC(SRC, DEST)} moves the allocation from @var{SRC} to
6687 @var{DEST}. @var{SRC} will become deallocated in the process.
6689 @item @emph{Standard}:
6695 @item @emph{Syntax}:
6696 @code{CALL MOVE_ALLOC(SRC, DEST)}
6698 @item @emph{Arguments}:
6699 @multitable @columnfractions .15 .80
6700 @item @var{SRC} @tab @code{ALLOCATABLE}, @code{INTENT(INOUT)}, may be
6701 of any type and kind.
6702 @item @var{DEST} @tab @code{ALLOCATABLE}, @code{INTENT(OUT)}, shall be
6703 of the same type, kind and rank as @var{SRC}
6706 @item @emph{Return value}:
6709 @item @emph{Example}:
6711 program test_move_alloc
6712 integer, allocatable :: a(:), b(:)
6716 call move_alloc(a, b)
6717 print *, allocated(a), allocated(b)
6719 end program test_move_alloc
6726 @section @code{MVBITS} --- Move bits from one integer to another
6727 @cindex @code{MVBITS} intrinsic
6728 @cindex bit operations
6731 @item @emph{Description}:
6732 Moves @var{LEN} bits from positions @var{FROMPOS} through
6733 @code{FROMPOS+LEN-1} of @var{FROM} to positions @var{TOPOS} through
6734 @code{TOPOS+LEN-1} of @var{TO}. The portion of argument @var{TO} not
6735 affected by the movement of bits is unchanged. The values of
6736 @code{FROMPOS+LEN-1} and @code{TOPOS+LEN-1} must be less than
6737 @code{BIT_SIZE(FROM)}.
6739 @item @emph{Standard}:
6745 @item @emph{Syntax}:
6746 @code{RESULT = MVBITS(FROM, FROMPOS, LEN, TO, TOPOS)}
6748 @item @emph{Arguments}:
6749 @multitable @columnfractions .15 .80
6750 @item @var{FROM} @tab The type shall be @code{INTEGER(*)}.
6751 @item @var{FROMPOS} @tab The type shall be @code{INTEGER(*)}.
6752 @item @var{LEN} @tab The type shall be @code{INTEGER(*)}.
6753 @item @var{TO} @tab The type shall be @code{INTEGER(*)}, of the
6754 same kind as @var{FROM}.
6755 @item @var{TOPOS} @tab The type shall be @code{INTEGER(*)}.
6758 @item @emph{Return value}:
6759 The return value is of type @code{INTEGER(*)} and of the same kind as
6762 @item @emph{See also}:
6763 @ref{IBCLR}, @ref{IBSET}, @ref{IBITS}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
6770 @section @code{NEAREST} --- Nearest representable number
6771 @cindex @code{NEAREST} intrinsic
6772 @cindex processor-representable number
6775 @item @emph{Description}:
6776 @code{NEAREST(X, S)} returns the processor-representable number nearest
6777 to @code{X} in the direction indicated by the sign of @code{S}.
6779 @item @emph{Standard}:
6785 @item @emph{Syntax}:
6786 @code{RESULT = NEAREST(X, S)}
6788 @item @emph{Arguments}:
6789 @multitable @columnfractions .15 .80
6790 @item @var{X} @tab shall be of type @code{REAL}.
6791 @item @var{S} @tab (Optional) shall be of type @code{REAL} and
6795 @item @emph{Return value}:
6796 The return value is of the same type as @code{X}. If @code{S} is
6797 positive, @code{NEAREST} returns the processor-representable number
6798 greater than @code{X} and nearest to it. If @code{S} is negative,
6799 @code{NEAREST} returns the processor-representable number smaller than
6800 @code{X} and nearest to it.
6802 @item @emph{Example}:
6804 program test_nearest
6806 x = nearest(42.0, 1.0)
6807 y = nearest(42.0, -1.0)
6808 write (*,"(3(G20.15))") x, y, x - y
6809 end program test_nearest
6816 @section @code{NEW_LINE} --- New line character
6817 @cindex @code{NEW_LINE} intrinsic
6818 @cindex @code{NEW_LINE} intrinsic
6821 @item @emph{Description}:
6822 @code{NEW_LINE(C)} returns the new-line character.
6824 @item @emph{Standard}:
6830 @item @emph{Syntax}:
6831 @code{RESULT = NEW_LINE(C)}
6833 @item @emph{Arguments}:
6834 @multitable @columnfractions .15 .80
6835 @item @var{C} @tab The argument shall be a scalar or array of the
6836 type @code{CHARACTER}.
6839 @item @emph{Return value}:
6840 Returns a @var{CHARACTER} scalar of length one with the new-line character of
6841 the same kind as parameter @var{C}.
6843 @item @emph{Example}:
6847 write(*,'(A)') 'This is record 1.'//NEW_LINE('A')//'This is record 2.'
6855 @section @code{NINT} --- Nearest whole number
6856 @cindex @code{NINT} intrinsic
6857 @cindex @code{IDNINT} intrinsic
6858 @cindex whole number
6861 @item @emph{Description}:
6862 @code{NINT(X)} rounds its argument to the nearest whole number.
6864 @item @emph{Standard}:
6870 @item @emph{Syntax}:
6871 @code{RESULT = NINT(X)}
6873 @item @emph{Arguments}:
6874 @multitable @columnfractions .15 .80
6875 @item @var{X} @tab The type of the argument shall be @code{REAL}.
6878 @item @emph{Return value}:
6879 Returns @var{A} with the fractional portion of its magnitude eliminated by
6880 rounding to the nearest whole number and with its sign preserved,
6881 converted to an @code{INTEGER} of the default kind.
6883 @item @emph{Example}:
6890 print *, nint(x4), idnint(x8)
6891 end program test_nint
6894 @item @emph{Specific names}:
6895 @multitable @columnfractions .33 .33 .33
6896 @item Name @tab Argument @tab Standard
6897 @item @code{IDNINT(X)} @tab @code{REAL(8)} @tab F95 and later
6900 @item @emph{See also}:
6901 @ref{CEILING}, @ref{FLOOR}
6907 @section @code{NOT} --- Logical negation
6908 @cindex @code{NOT} intrinsic
6909 @cindex bit operations
6912 @item @emph{Description}:
6913 @code{NOT} returns the bitwise boolean inverse of @var{I}.
6915 @item @emph{Standard}:
6921 @item @emph{Syntax}:
6922 @code{RESULT = NOT(I)}
6924 @item @emph{Arguments}:
6925 @multitable @columnfractions .15 .80
6926 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
6929 @item @emph{Return value}:
6930 The return type is @code{INTEGER(*)}, of the same kind as the
6933 @item @emph{See also}:
6934 @ref{IAND}, @ref{IEOR}, @ref{IOR}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}
6942 @section @code{NULL} --- Function that returns an disassociated pointer
6943 @cindex @code{NULL} intrinsic
6944 @cindex undocumented intrinsic
6946 Intrinsic implemented, documentation pending.
6949 @item @emph{Description}:
6950 @item @emph{Standard}:
6954 Transformational function
6956 @item @emph{Syntax}:
6957 @item @emph{Arguments}:
6958 @item @emph{Return value}:
6959 @item @emph{Example}:
6960 @item @emph{See also}:
6968 @section @code{OR} --- Bitwise logical OR
6969 @cindex @code{OR} intrinsic
6970 @cindex bit operations
6973 @item @emph{Description}:
6974 Bitwise logical @code{OR}.
6976 This intrinsic routine is provided for backwards compatibility with
6977 GNU Fortran 77. For integer arguments, programmers should consider
6978 the use of the @ref{IOR} intrinsic defined by the Fortran standard.
6980 @item @emph{Standard}:
6984 Non-elemental function
6986 @item @emph{Syntax}:
6987 @code{RESULT = OR(X, Y)}
6989 @item @emph{Arguments}:
6990 @multitable @columnfractions .15 .80
6991 @item @var{X} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
6992 @item @var{Y} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
6995 @item @emph{Return value}:
6996 The return type is either @code{INTEGER(*)} or @code{LOGICAL}
6997 after cross-promotion of the arguments.
6999 @item @emph{Example}:
7002 LOGICAL :: T = .TRUE., F = ..FALSE.
7004 DATA a / Z'F' /, b / Z'3' /
7006 WRITE (*,*) OR(T, T), OR(T, F), OR(F, T), OR(F, F)
7007 WRITE (*,*) OR(a, b)
7011 @item @emph{See also}:
7012 F95 elemental function: @ref{IOR}
7019 @section @code{PACK} --- Pack an array into an array of rank one
7020 @cindex @code{PACK} intrinsic
7021 @cindex undocumented intrinsic
7023 Intrinsic implemented, documentation pending.
7026 @item @emph{Description}:
7027 @item @emph{Standard}:
7031 Transformational function
7033 @item @emph{Syntax}:
7034 @item @emph{Arguments}:
7035 @item @emph{Return value}:
7036 @item @emph{Example}:
7037 @item @emph{Specific names}:
7038 @item @emph{See also}:
7045 @section @code{PERROR} --- Print system error message
7046 @cindex @code{PERROR} intrinsic
7049 @item @emph{Description}:
7050 Prints (on the C @code{stderr} stream) a newline-terminated error
7051 message corresponding to the last system error. This is prefixed by
7052 @var{STRING}, a colon and a space. See @code{perror(3)}.
7054 @item @emph{Standard}:
7060 @item @emph{Syntax}:
7061 @code{CALL PERROR(STRING)}
7063 @item @emph{Arguments}:
7064 @multitable @columnfractions .15 .80
7065 @item @var{STRING} @tab A scalar of default @code{CHARACTER} type.
7068 @item @emph{See also}:
7075 @section @code{PRECISION} --- Decimal precision of a real kind
7076 @cindex @code{PRECISION} intrinsic
7077 @cindex precision of a real variable
7080 @item @emph{Description}:
7081 @code{PRECISION(X)} returns the decimal precision in the model of the
7084 @item @emph{Standard}:
7090 @item @emph{Syntax}:
7091 @code{RESULT = PRECISION(X)}
7093 @item @emph{Arguments}:
7094 @multitable @columnfractions .15 .80
7095 @item @var{X} @tab shall be of type @code{REAL} or @code{COMPLEX}.
7098 @item @emph{Return value}:
7099 The return value is of type @code{INTEGER} and of the default integer
7102 @item @emph{Example}:
7104 program prec_and_range
7105 real(kind=4) :: x(2)
7106 complex(kind=8) :: y
7108 print *, precision(x), range(x)
7109 print *, precision(y), range(y)
7110 end program prec_and_range
7117 @section @code{PRESENT} --- Determine whether an optional argument is specified
7118 @cindex @code{PRESENT} intrinsic
7119 @cindex undocumented intrinsic
7121 Intrinsic implemented, documentation pending.
7124 @item @emph{Description}:
7125 @item @emph{Standard}:
7131 @item @emph{Syntax}:
7132 @item @emph{Arguments}:
7133 @item @emph{Return value}:
7134 @item @emph{Example}:
7135 @item @emph{See also}:
7141 @section @code{PRODUCT} --- Product of array elements
7142 @cindex @code{PRODUCT} intrinsic
7143 @cindex undocumented intrinsic
7145 Intrinsic implemented, documentation pending.
7148 @item @emph{Description}:
7149 @item @emph{Standard}:
7153 Transformational function
7155 @item @emph{Syntax}:
7156 @item @emph{Arguments}:
7157 @item @emph{Return value}:
7158 @item @emph{Example}:
7159 @item @emph{Specific names}:
7160 @item @emph{See also}:
7167 @section @code{RADIX} --- Base of a model number
7168 @cindex @code{RADIX} intrinsic
7172 @item @emph{Description}:
7173 @code{RADIX(X)} returns the base of the model representing the entity @var{X}.
7175 @item @emph{Standard}:
7181 @item @emph{Syntax}:
7182 @code{RESULT = RADIX(X)}
7184 @item @emph{Arguments}:
7185 @multitable @columnfractions .15 .80
7186 @item @var{X} @tab Shall be of type @code{INTEGER} or @code{REAL}
7189 @item @emph{Return value}:
7190 The return value is a scalar of type @code{INTEGER} and of the default
7193 @item @emph{Example}:
7196 print *, "The radix for the default integer kind is", radix(0)
7197 print *, "The radix for the default real kind is", radix(0.0)
7198 end program test_radix
7206 @section @code{RAN} --- Real pseudo-random number
7207 @cindex @code{RAN} intrinsic
7208 @cindex random numbers
7211 @item @emph{Description}:
7212 For compatibility with HP FORTRAN 77/iX, the @code{RAN} intrinsic is
7213 provided as an alias for @code{RAND}. See @ref{RAND} for complete
7216 @item @emph{Standard}:
7220 Non-elemental function
7222 @item @emph{See also}:
7223 @ref{RAND}, @ref{RANDOM_NUMBER}
7229 @section @code{RAND} --- Real pseudo-random number
7230 @cindex @code{RAND} intrinsic
7231 @cindex random numbers
7234 @item @emph{Description}:
7235 @code{RAND(FLAG)} returns a pseudo-random number from a uniform
7236 distribution between 0 and 1. If @var{FLAG} is 0, the next number
7237 in the current sequence is returned; if @var{FLAG} is 1, the generator
7238 is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
7239 it is used as a new seed with @code{SRAND}.
7241 @item @emph{Standard}:
7245 Non-elemental function
7247 @item @emph{Syntax}:
7248 @code{RESULT = RAND(FLAG)}
7250 @item @emph{Arguments}:
7251 @multitable @columnfractions .15 .80
7252 @item @var{FLAG} @tab shall be a scalar @code{INTEGER} of kind 4.
7255 @item @emph{Return value}:
7256 The return value is of @code{REAL} type and the default kind.
7258 @item @emph{Example}:
7261 integer,parameter :: seed = 86456
7264 print *, rand(), rand(), rand(), rand()
7265 print *, rand(seed), rand(), rand(), rand()
7266 end program test_rand
7269 @item @emph{See also}:
7270 @ref{SRAND}, @ref{RANDOM_NUMBER}
7277 @section @code{RANDOM_NUMBER} --- Pseudo-random number
7278 @cindex @code{RANDOM_NUMBER} intrinsic
7279 @cindex random numbers
7281 Intrinsic implemented, documentation pending.
7284 @item @emph{Description}:
7285 @item @emph{Standard}:
7289 Elemental subroutine
7291 @item @emph{Syntax}:
7292 @item @emph{Arguments}:
7293 @item @emph{Return value}:
7294 @item @emph{Example}:
7295 @item @emph{See also}:
7302 @section @code{RANDOM_SEED} --- Initialize a pseudo-random number sequence
7303 @cindex @code{RANDOM_SEED} intrinsic
7304 @cindex random numbers
7306 Intrinsic implemented, documentation pending.
7309 @item @emph{Description}:
7310 @item @emph{Standard}:
7316 @item @emph{Syntax}:
7317 @item @emph{Arguments}:
7318 @item @emph{Return value}:
7319 @item @emph{Example}:
7320 @item @emph{See also}:
7327 @section @code{RANGE} --- Decimal exponent range of a real kind
7328 @cindex @code{RANGE} intrinsic
7329 @cindex range of a real variable
7332 @item @emph{Description}:
7333 @code{RANGE(X)} returns the decimal exponent range in the model of the
7336 @item @emph{Standard}:
7342 @item @emph{Syntax}:
7343 @code{RESULT = RANGE(X)}
7345 @item @emph{Arguments}:
7346 @multitable @columnfractions .15 .80
7347 @item @var{X} @tab shall be of type @code{REAL} or @code{COMPLEX}.
7350 @item @emph{Return value}:
7351 The return value is of type @code{INTEGER} and of the default integer
7354 @item @emph{Example}:
7355 See @code{PRECISION} for an example.
7361 @section @code{REAL} --- Convert to real type
7362 @cindex @code{REAL} intrinsic
7363 @cindex @code{REALPART} intrinsic
7367 @item @emph{Description}:
7368 @code{REAL(X [, KIND])} converts its argument @var{X} to a real type. The
7369 @code{REALPART(X)} function is provided for compatibility with @command{g77},
7370 and its use is strongly discouraged.
7372 @item @emph{Standard}:
7378 @item @emph{Syntax}:
7379 @multitable @columnfractions .30 .80
7380 @item @code{RESULT = REAL(X [, KIND])}
7381 @item @code{RESULT = REALPART(Z)}
7384 @item @emph{Arguments}:
7385 @multitable @columnfractions .15 .80
7386 @item @var{X} @tab shall be @code{INTEGER(*)}, @code{REAL(*)}, or
7388 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
7389 expression indicating the kind parameter of
7393 @item @emph{Return value}:
7394 These functions return a @code{REAL(*)} variable or array under
7395 the following rules:
7399 @code{REAL(X)} is converted to a default real type if @var{X} is an
7400 integer or real variable.
7402 @code{REAL(X)} is converted to a real type with the kind type parameter
7403 of @var{X} if @var{X} is a complex variable.
7405 @code{REAL(X, KIND)} is converted to a real type with kind type
7406 parameter @var{KIND} if @var{X} is a complex, integer, or real
7410 @item @emph{Example}:
7413 complex :: x = (1.0, 2.0)
7414 print *, real(x), real(x,8), realpart(x)
7415 end program test_real
7418 @item @emph{See also}:
7419 @ref{DBLE}, @ref{DFLOAT}, @ref{FLOAT}
7426 @section @code{RENAME} --- Rename a file
7427 @cindex @code{RENAME} intrinsic
7428 @cindex file system operations
7431 @item @emph{Description}:
7432 Renames a file from file @var{PATH1} to @var{PATH2}. A null
7433 character (@code{CHAR(0)}) can be used to mark the end of the names in
7434 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
7435 names are ignored. If the @var{STATUS} argument is supplied, it
7436 contains 0 on success or a nonzero error code upon return; see
7439 @item @emph{Standard}:
7445 @item @emph{Syntax}:
7446 @code{CALL RENAME(PATH1, PATH2 [, STATUS])}
7448 @item @emph{Arguments}:
7449 @multitable @columnfractions .15 .80
7450 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
7451 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
7452 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
7455 @item @emph{See also}:
7463 @section @code{REPEAT} --- Repeated string concatenation
7464 @cindex @code{REPEAT} intrinsic
7465 @cindex string manipulation
7467 Intrinsic implemented, documentation pending.
7470 @item @emph{Description}:
7471 @item @emph{Standard}:
7475 Transformational function
7477 @item @emph{Syntax}:
7478 @item @emph{Arguments}:
7479 @item @emph{Return value}:
7480 @item @emph{Example}:
7481 @item @emph{See also}:
7488 @section @code{RESHAPE} --- Function to reshape an array
7489 @cindex @code{RESHAPE} intrinsic
7490 @cindex array manipulation
7492 Intrinsic implemented, documentation pending.
7495 @item @emph{Description}:
7496 @item @emph{Standard}:
7500 Transformational function
7502 @item @emph{Syntax}:
7503 @item @emph{Arguments}:
7504 @item @emph{Return value}:
7505 @item @emph{Example}:
7506 @item @emph{See also}:
7513 @section @code{RRSPACING} --- Reciprocal of the relative spacing
7514 @cindex @code{RRSPACING} intrinsic
7517 @item @emph{Description}:
7518 @code{RRSPACING(X)} returns the reciprocal of the relative spacing of
7519 model numbers near @var{X}.
7521 @item @emph{Standard}:
7527 @item @emph{Syntax}:
7528 @code{RESULT = RRSPACING(X)}
7530 @item @emph{Arguments}:
7531 @multitable @columnfractions .15 .80
7532 @item @var{X} @tab shall be of type @code{REAL}.
7535 @item @emph{Return value}:
7536 The return value is of the same type and kind as @var{X}.
7537 The value returned is equal to
7538 @code{ABS(FRACTION(X)) * FLOAT(RADIX(X))**DIGITS(X)}.
7545 @section @code{RSHIFT} --- Right shift bits
7546 @cindex @code{RSHIFT} intrinsic
7547 @cindex bit operations
7550 @item @emph{Description}:
7551 @code{RSHIFT} returns a value corresponding to @var{I} with all of the
7552 bits shifted right by @var{SHIFT} places. If the absolute value of
7553 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
7554 Bits shifted out from the left end are lost; zeros are shifted in from
7557 This function has been superseded by the @code{ISHFT} intrinsic, which
7558 is standard in Fortran 95 and later.
7560 @item @emph{Standard}:
7566 @item @emph{Syntax}:
7567 @code{RESULT = RSHIFT(I, SHIFT)}
7569 @item @emph{Arguments}:
7570 @multitable @columnfractions .15 .80
7571 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
7572 @item @var{SHIFT} @tab The type shall be @code{INTEGER(*)}.
7575 @item @emph{Return value}:
7576 The return value is of type @code{INTEGER(*)} and of the same kind as
7579 @item @emph{See also}:
7580 @ref{ISHFT}, @ref{ISHFTC}, @ref{LSHIFT}
7587 @section @code{SCALE} --- Scale a real value
7588 @cindex @code{SCALE} intrinsic
7591 @item @emph{Description}:
7592 @code{SCALE(X,I)} returns @code{X * RADIX(X)**I}.
7594 @item @emph{Standard}:
7600 @item @emph{Syntax}:
7601 @code{RESULT = SCALE(X, I)}
7603 @item @emph{Arguments}:
7604 @multitable @columnfractions .15 .80
7605 @item @var{X} @tab The type of the argument shall be a @code{REAL}.
7606 @item @var{I} @tab The type of the argument shall be a @code{INTEGER}.
7609 @item @emph{Return value}:
7610 The return value is of the same type and kind as @var{X}.
7611 Its value is @code{X * RADIX(X)**I}.
7613 @item @emph{Example}:
7616 real :: x = 178.1387e-4
7618 print *, scale(x,i), x*radix(x)**i
7619 end program test_scale
7626 @section @code{SCAN} --- Scan a string for the presence of a set of characters
7627 @cindex @code{SCAN} intrinsic
7628 @cindex string manipulation
7630 Intrinsic implemented, documentation pending.
7633 @item @emph{Description}:
7634 @item @emph{Standard}:
7640 @item @emph{Syntax}:
7641 @item @emph{Arguments}:
7642 @item @emph{Return value}:
7643 @item @emph{Example}:
7644 @item @emph{See also}:
7651 @section @code{SECNDS} --- Time function
7652 @cindex @code{SECNDS} intrinsic
7653 @cindex time, current
7654 @cindex current time
7657 @item @emph{Description}:
7658 @code{SECNDS(X)} gets the time in seconds from the real-time system clock.
7659 @var{X} is a reference time, also in seconds. If this is zero, the time in
7660 seconds from midnight is returned. This function is non-standard and its
7663 @item @emph{Standard}:
7669 @item @emph{Syntax}:
7670 @code{RESULT = SECNDS (X)}
7672 @item @emph{Arguments}:
7673 @multitable @columnfractions .15 .80
7674 @item Name @tab Type
7675 @item @var{T} @tab REAL(4)
7676 @item @var{X} @tab REAL(4)
7679 @item @emph{Return value}:
7682 @item @emph{Example}:
7686 print *, secnds (0.0) ! seconds since midnight
7687 t1 = secnds (0.0) ! reference time
7688 do i = 1, 10000000 ! do something
7690 t2 = secnds (t1) ! elapsed time
7691 print *, "Something took ", t2, " seconds."
7692 end program test_secnds
7698 @node SELECTED_INT_KIND
7699 @section @code{SELECTED_INT_KIND} --- Choose integer kind
7700 @cindex @code{SELECTED_INT_KIND} intrinsic
7701 @cindex integer kind
7704 @item @emph{Description}:
7705 @code{SELECTED_INT_KIND(I)} return the kind value of the smallest integer
7706 type that can represent all values ranging from @math{-10^I} (exclusive)
7707 to @math{10^I} (exclusive). If there is no integer kind that accommodates
7708 this range, @code{SELECTED_INT_KIND} returns @math{-1}.
7710 @item @emph{Standard}:
7714 Transformational function
7716 @item @emph{Syntax}:
7717 @code{RESULT = SELECTED_INT_KIND(I)}
7719 @item @emph{Arguments}:
7720 @multitable @columnfractions .15 .80
7721 @item @var{I} @tab shall be a scalar and of type @code{INTEGER}.
7724 @item @emph{Example}:
7726 program large_integers
7727 integer,parameter :: k5 = selected_int_kind(5)
7728 integer,parameter :: k15 = selected_int_kind(15)
7729 integer(kind=k5) :: i5
7730 integer(kind=k15) :: i15
7732 print *, huge(i5), huge(i15)
7734 ! The following inequalities are always true
7735 print *, huge(i5) >= 10_k5**5-1
7736 print *, huge(i15) >= 10_k15**15-1
7737 end program large_integers
7743 @node SELECTED_REAL_KIND
7744 @section @code{SELECTED_REAL_KIND} --- Choose real kind
7745 @cindex @code{SELECTED_REAL_KIND} intrinsic
7749 @item @emph{Description}:
7750 @code{SELECTED_REAL_KIND(P,R)} return the kind value of a real data type
7751 with decimal precision greater of at least @code{P} digits and exponent
7752 range greater at least @code{R}.
7754 @item @emph{Standard}:
7758 Transformational function
7760 @item @emph{Syntax}:
7761 @code{RESULT = SELECTED_REAL_KIND(P, R)}
7763 @item @emph{Arguments}:
7764 @multitable @columnfractions .15 .80
7765 @item @var{P} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
7766 @item @var{R} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
7768 At least one argument shall be present.
7770 @item @emph{Return value}:
7772 @code{SELECTED_REAL_KIND} returns the value of the kind type parameter of
7773 a real data type with decimal precision of at least @code{P} digits and a
7774 decimal exponent range of at least @code{R}. If more than one real data
7775 type meet the criteria, the kind of the data type with the smallest
7776 decimal precision is returned. If no real data type matches the criteria,
7779 @item -1 if the processor does not support a real data type with a
7780 precision greater than or equal to @code{P}
7781 @item -2 if the processor does not support a real type with an exponent
7782 range greater than or equal to @code{R}
7783 @item -3 if neither is supported.
7786 @item @emph{Example}:
7789 integer,parameter :: p6 = selected_real_kind(6)
7790 integer,parameter :: p10r100 = selected_real_kind(10,100)
7791 integer,parameter :: r400 = selected_real_kind(r=400)
7793 real(kind=p10r100) :: y
7794 real(kind=r400) :: z
7796 print *, precision(x), range(x)
7797 print *, precision(y), range(y)
7798 print *, precision(z), range(z)
7799 end program real_kinds
7806 @section @code{SET_EXPONENT} --- Set the exponent of the model
7807 @cindex @code{SET_EXPONENT} intrinsic
7808 @cindex exponent part of a real number
7811 @item @emph{Description}:
7812 @code{SET_EXPONENT(X, I)} returns the real number whose fractional part
7813 is that that of @var{X} and whose exponent part is @var{I}.
7815 @item @emph{Standard}:
7821 @item @emph{Syntax}:
7822 @code{RESULT = SET_EXPONENT(X, I)}
7824 @item @emph{Arguments}:
7825 @multitable @columnfractions .15 .80
7826 @item @var{X} @tab shall be of type @code{REAL}.
7827 @item @var{I} @tab shall be of type @code{INTEGER}.
7830 @item @emph{Return value}:
7831 The return value is of the same type and kind as @var{X}.
7832 The real number whose fractional part
7833 is that that of @var{X} and whose exponent part if @var{I} is returned;
7834 it is @code{FRACTION(X) * RADIX(X)**I}.
7836 @item @emph{Example}:
7839 real :: x = 178.1387e-4
7841 print *, set_exponent(x), fraction(x) * radix(x)**i
7842 end program test_setexp
7850 @section @code{SHAPE} --- Determine the shape of an array
7851 @cindex @code{SHAPE} intrinsic
7852 @cindex array manipulation
7854 Intrinsic implemented, documentation pending.
7857 @item @emph{Description}:
7858 @item @emph{Standard}:
7864 @item @emph{Syntax}:
7865 @item @emph{Arguments}:
7866 @item @emph{Return value}:
7867 @item @emph{Example}:
7868 @item @emph{See also}:
7875 @section @code{SIGN} --- Sign copying function
7876 @cindex @code{SIGN} intrinsic
7877 @cindex @code{ISIGN} intrinsic
7878 @cindex @code{DSIGN} intrinsic
7879 @cindex sign copying
7882 @item @emph{Description}:
7883 @code{SIGN(A,B)} returns the value of @var{A} with the sign of @var{B}.
7885 @item @emph{Standard}:
7891 @item @emph{Syntax}:
7892 @code{RESULT = SIGN(A, B)}
7894 @item @emph{Arguments}:
7895 @multitable @columnfractions .15 .80
7896 @item @var{A} @tab shall be a scalar of type @code{INTEGER} or @code{REAL}
7897 @item @var{B} @tab shall be a scalar of the same type and kind as @var{A}
7900 @item @emph{Return value}:
7901 The kind of the return value is that of @var{A} and @var{B}.
7902 If @math{B\ge 0} then the result is @code{ABS(A)}, else
7903 it is @code{-ABS(A)}.
7905 @item @emph{Example}:
7908 print *, sign(-12,1)
7909 print *, sign(-12,0)
7910 print *, sign(-12,-1)
7912 print *, sign(-12.,1.)
7913 print *, sign(-12.,0.)
7914 print *, sign(-12.,-1.)
7915 end program test_sign
7918 @item @emph{Specific names}:
7919 @multitable @columnfractions .20 .20 .20 .40
7920 @item Name @tab Arguments @tab Return type @tab Standard
7921 @item @code{ISIGN(A,P)} @tab @code{INTEGER(4)} @tab @code{INTEGER(4)} @tab f95, gnu
7922 @item @code{DSIGN(A,P)} @tab @code{REAL(8)} @tab @code{REAL(8)} @tab f95, gnu
7929 @section @code{SIGNAL} --- Signal handling subroutine (or function)
7930 @cindex @code{SIGNAL} intrinsic
7931 @cindex signal handling
7934 @item @emph{Description}:
7935 @code{SIGNAL(NUMBER, HANDLER [, STATUS])} causes external subroutine
7936 @var{HANDLER} to be executed with a single integer argument when signal
7937 @var{NUMBER} occurs. If @var{HANDLER} is an integer, it can be used to
7938 turn off handling of signal @var{NUMBER} or revert to its default
7939 action. See @code{signal(2)}.
7941 If @code{SIGNAL} is called as a subroutine and the @var{STATUS} argument
7942 is supplied, it is set to the value returned by @code{signal(2)}.
7944 @item @emph{Standard}:
7948 subroutine, non-elemental function
7950 @item @emph{Syntax}:
7951 @multitable @columnfractions .80
7952 @item @code{CALL SIGNAL(NUMBER, HANDLER [, STATUS])}
7953 @item @code{STATUS = SIGNAL(NUMBER, HANDLER)}
7956 @item @emph{Arguments}:
7957 @multitable @columnfractions .15 .80
7958 @item @var{NUMBER} @tab shall be a scalar integer, with @code{INTENT(IN)}
7959 @item @var{HANDLER}@tab Signal handler (@code{INTEGER FUNCTION} or
7960 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar.
7961 @code{INTEGER}. It is @code{INTENT(IN)}.
7962 @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
7963 integer. It has @code{INTENT(OUT)}.
7966 @item @emph{Return value}:
7967 The @code{SIGNAL} function returns the value returned by @code{signal(2)}.
7969 @item @emph{Example}:
7973 external handler_print
7975 call signal (12, handler_print)
7979 end program test_signal
7986 @section @code{SIN} --- Sine function
7987 @cindex @code{SIN} intrinsic
7988 @cindex @code{DSIN} intrinsic
7989 @cindex @code{ZSIN} intrinsic
7990 @cindex @code{CDSIN} intrinsic
7991 @cindex trigonometric functions
7994 @item @emph{Description}:
7995 @code{SIN(X)} computes the sine of @var{X}.
7997 @item @emph{Standard}:
8003 @item @emph{Syntax}:
8004 @code{RESULT = SIN(X)}
8006 @item @emph{Arguments}:
8007 @multitable @columnfractions .15 .80
8008 @item @var{X} @tab The type shall be @code{REAL(*)} or
8012 @item @emph{Return value}:
8013 The return value has same type and kind as @var{X}.
8015 @item @emph{Example}:
8020 end program test_sin
8023 @item @emph{Specific names}:
8024 @multitable @columnfractions .20 .20 .20 .40
8025 @item Name @tab Argument @tab Return type @tab Standard
8026 @item @code{DSIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
8027 @item @code{CSIN(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab f95, gnu
8028 @item @code{ZSIN(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
8029 @item @code{CDSIN(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
8032 @item @emph{See also}:
8039 @section @code{SINH} --- Hyperbolic sine function
8040 @cindex @code{SINH} intrinsic
8041 @cindex @code{DSINH} intrinsic
8042 @cindex hyperbolic sine
8045 @item @emph{Description}:
8046 @code{SINH(X)} computes the hyperbolic sine of @var{X}.
8048 @item @emph{Standard}:
8054 @item @emph{Syntax}:
8055 @code{RESULT = SINH(X)}
8057 @item @emph{Arguments}:
8058 @multitable @columnfractions .15 .80
8059 @item @var{X} @tab The type shall be @code{REAL(*)}.
8062 @item @emph{Return value}:
8063 The return value is of type @code{REAL(*)}.
8065 @item @emph{Example}:
8068 real(8) :: x = - 1.0_8
8070 end program test_sinh
8073 @item @emph{Specific names}:
8074 @multitable @columnfractions .20 .20 .20 .40
8075 @item Name @tab Argument @tab Return type @tab Standard
8076 @item @code{DSINH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
8079 @item @emph{See also}:
8086 @section @code{SIZE} --- Determine the size of an array
8087 @cindex @code{SIZE} intrinsic
8088 @cindex array manipulation
8090 Intrinsic implemented, documentation pending.
8093 @item @emph{Description}:
8094 @item @emph{Standard}:
8100 @item @emph{Syntax}:
8101 @item @emph{Arguments}:
8102 @item @emph{Return value}:
8103 @item @emph{Example}:
8104 @item @emph{See also}:
8110 @section @code{SLEEP} --- Sleep for the specified number of seconds
8111 @cindex @code{SLEEP} intrinsic
8114 @item @emph{Description}:
8115 Calling this subroutine causes the process to pause for @var{SECONDS} seconds.
8117 @item @emph{Standard}:
8123 @item @emph{Syntax}:
8124 @code{CALL SLEEP(SECONDS)}
8126 @item @emph{Arguments}:
8127 @multitable @columnfractions .15 .80
8128 @item @var{SECONDS} @tab The type shall be of default @code{INTEGER}.
8131 @item @emph{Example}:
8142 @section @code{SNGL} --- Convert double precision real to default real
8143 @cindex @code{SNGL} intrinsic
8144 @cindex conversion function (real)
8147 @item @emph{Description}:
8148 @code{SNGL(A)} converts the double precision real @var{A}
8149 to a default real value. This is an archaic form of @code{REAL}
8150 that is specific to one type for @var{A}.
8152 @item @emph{Standard}:
8158 @item @emph{Syntax}:
8159 @code{RESULT = SNGL(A)}
8161 @item @emph{Arguments}:
8162 @multitable @columnfractions .15 .80
8163 @item @var{A} @tab The type shall be a double precision @code{REAL}.
8166 @item @emph{Return value}:
8167 The return value is of type default @code{REAL}.
8169 @item @emph{See also}:
8176 @section @code{SPACING} --- Smallest distance between two numbers of a given type
8177 @cindex @code{SPACING} intrinsic
8178 @cindex undocumented intrinsic
8180 Intrinsic implemented, documentation pending.
8183 @item @emph{Description}:
8184 @item @emph{Standard}:
8190 @item @emph{Syntax}:
8191 @item @emph{Arguments}:
8192 @item @emph{Return value}:
8193 @item @emph{Example}:
8194 @item @emph{See also}:
8201 @section @code{SPREAD} --- Add a dimension to an array
8202 @cindex @code{SPREAD} intrinsic
8203 @cindex array manipulation
8205 Intrinsic implemented, documentation pending.
8208 @item @emph{Description}:
8209 @item @emph{Standard}:
8213 Transformational function
8215 @item @emph{Syntax}:
8216 @item @emph{Arguments}:
8217 @item @emph{Return value}:
8218 @item @emph{Example}:
8219 @item @emph{See also}:
8226 @section @code{SQRT} --- Square-root function
8227 @cindex @code{SQRT} intrinsic
8228 @cindex @code{DSQRT} intrinsic
8229 @cindex @code{CSQRT} intrinsic
8230 @cindex @code{ZSQRT} intrinsic
8231 @cindex @code{CDSQRT} intrinsic
8235 @item @emph{Description}:
8236 @code{SQRT(X)} computes the square root of @var{X}.
8238 @item @emph{Standard}:
8244 @item @emph{Syntax}:
8245 @code{RESULT = SQRT(X)}
8247 @item @emph{Arguments}:
8248 @multitable @columnfractions .15 .80
8249 @item @var{X} @tab The type shall be @code{REAL(*)} or
8253 @item @emph{Return value}:
8254 The return value is of type @code{REAL(*)} or @code{COMPLEX(*)}.
8255 The kind type parameter is the same as @var{X}.
8257 @item @emph{Example}:
8260 real(8) :: x = 2.0_8
8261 complex :: z = (1.0, 2.0)
8264 end program test_sqrt
8267 @item @emph{Specific names}:
8268 @multitable @columnfractions .20 .20 .20 .40
8269 @item Name @tab Argument @tab Return type @tab Standard
8270 @item @code{DSQRT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
8271 @item @code{CSQRT(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab F95 and later
8272 @item @code{ZSQRT(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
8273 @item @code{CDSQRT(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
8280 @section @code{SRAND} --- Reinitialize the random number generator
8281 @cindex @code{SRAND} intrinsic
8282 @cindex random numbers
8285 @item @emph{Description}:
8286 @code{SRAND} reinitializes the pseudo-random number generator
8287 called by @code{RAND} and @code{IRAND}. The new seed used by the
8288 generator is specified by the required argument @var{SEED}.
8290 @item @emph{Standard}:
8294 non-elemental subroutine
8296 @item @emph{Syntax}:
8297 @code{CALL SRAND(SEED)}
8299 @item @emph{Arguments}:
8300 @multitable @columnfractions .15 .80
8301 @item @var{SEED} @tab shall be a scalar @code{INTEGER(kind=4)}.
8304 @item @emph{Return value}:
8307 @item @emph{Example}:
8308 See @code{RAND} and @code{IRAND} for examples.
8311 The Fortran 2003 standard specifies the intrinsic @code{RANDOM_SEED} to
8312 initialize the pseudo-random numbers generator and @code{RANDOM_NUMBER}
8313 to generate pseudo-random numbers. Please note that in
8314 GNU Fortran, these two sets of intrinsics (@code{RAND},
8315 @code{IRAND} and @code{SRAND} on the one hand, @code{RANDOM_NUMBER} and
8316 @code{RANDOM_SEED} on the other hand) access two independent
8317 pseudo-random number generators.
8319 @item @emph{See also}:
8320 @ref{RAND}, @ref{RANDOM_SEED}, @ref{RANDOM_NUMBER}
8327 @section @code{STAT} --- Get file status
8328 @cindex @code{STAT} intrinsic
8329 @cindex file system operations
8332 @item @emph{Description}:
8333 This function returns information about a file. No permissions are required on
8334 the file itself, but execute (search) permission is required on all of the
8335 directories in path that lead to the file.
8337 The elements that are obtained and stored in the array @code{BUFF}:
8338 @multitable @columnfractions .15 .80
8339 @item @code{buff(1)} @tab Device ID
8340 @item @code{buff(2)} @tab Inode number
8341 @item @code{buff(3)} @tab File mode
8342 @item @code{buff(4)} @tab Number of links
8343 @item @code{buff(5)} @tab Owner's uid
8344 @item @code{buff(6)} @tab Owner's gid
8345 @item @code{buff(7)} @tab ID of device containing directory entry for file (0 if not available)
8346 @item @code{buff(8)} @tab File size (bytes)
8347 @item @code{buff(9)} @tab Last access time
8348 @item @code{buff(10)} @tab Last modification time
8349 @item @code{buff(11)} @tab Last file status change time
8350 @item @code{buff(12)} @tab Preferred I/O block size (-1 if not available)
8351 @item @code{buff(13)} @tab Number of blocks allocated (-1 if not available)
8354 Not all these elements are relevant on all systems.
8355 If an element is not relevant, it is returned as 0.
8358 @item @emph{Standard}:
8362 Non-elemental subroutine
8364 @item @emph{Syntax}:
8365 @code{CALL STAT(FILE,BUFF[,STATUS])}
8367 @item @emph{Arguments}:
8368 @multitable @columnfractions .15 .80
8369 @item @var{FILE} @tab The type shall be @code{CHARACTER(*)}, a valid path within the file system.
8370 @item @var{BUFF} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
8371 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0
8372 on success and a system specific error code otherwise.
8375 @item @emph{Example}:
8378 INTEGER, DIMENSION(13) :: buff
8381 CALL STAT("/etc/passwd", buff, status)
8383 IF (status == 0) THEN
8384 WRITE (*, FMT="('Device ID:', T30, I19)") buff(1)
8385 WRITE (*, FMT="('Inode number:', T30, I19)") buff(2)
8386 WRITE (*, FMT="('File mode (octal):', T30, O19)") buff(3)
8387 WRITE (*, FMT="('Number of links:', T30, I19)") buff(4)
8388 WRITE (*, FMT="('Owner''s uid:', T30, I19)") buff(5)
8389 WRITE (*, FMT="('Owner''s gid:', T30, I19)") buff(6)
8390 WRITE (*, FMT="('Device where located:', T30, I19)") buff(7)
8391 WRITE (*, FMT="('File size:', T30, I19)") buff(8)
8392 WRITE (*, FMT="('Last access time:', T30, A19)") CTIME(buff(9))
8393 WRITE (*, FMT="('Last modification time', T30, A19)") CTIME(buff(10))
8394 WRITE (*, FMT="('Last status change time:', T30, A19)") CTIME(buff(11))
8395 WRITE (*, FMT="('Preferred block size:', T30, I19)") buff(12)
8396 WRITE (*, FMT="('No. of blocks allocated:', T30, I19)") buff(13)
8401 @item @emph{See also}:
8402 To stat an open file: @ref{FSTAT}, to stat a link: @ref{LSTAT}
8408 @section @code{SUM} --- Sum of array elements
8409 @cindex @code{SUM} intrinsic
8410 @cindex array manipulation
8412 Intrinsic implemented, documentation pending.
8415 @item @emph{Description}:
8416 @item @emph{Standard}:
8420 Transformational function
8422 @item @emph{Syntax}:
8423 @item @emph{Arguments}:
8424 @item @emph{Return value}:
8425 @item @emph{Example}:
8426 @item @emph{See also}:
8433 @section @code{SYMLNK} --- Create a symbolic link
8434 @cindex @code{SYMLNK} intrinsic
8435 @cindex file system operations
8438 @item @emph{Description}:
8439 Makes a symbolic link from file @var{PATH1} to @var{PATH2}. A null
8440 character (@code{CHAR(0)}) can be used to mark the end of the names in
8441 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
8442 names are ignored. If the @var{STATUS} argument is supplied, it
8443 contains 0 on success or a nonzero error code upon return; see
8444 @code{symlink(2)}. If the system does not supply @code{symlink(2)},
8445 @code{ENOSYS} is returned.
8447 @item @emph{Standard}:
8453 @item @emph{Syntax}:
8454 @code{CALL SYMLNK(PATH1, PATH2 [, STATUS])}
8456 @item @emph{Arguments}:
8457 @multitable @columnfractions .15 .80
8458 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
8459 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
8460 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
8463 @item @emph{See also}:
8464 @ref{LINK}, @ref{UNLINK}
8471 @section @code{SYSTEM} --- Execute a shell command
8472 @cindex @code{SYSTEM} intrinsic
8475 @item @emph{Description}:
8476 Passes the command @var{COMMAND} to a shell (see @code{system(3)}). If
8477 argument @var{STATUS} is present, it contains the value returned by
8478 @code{system(3)}, which is presumably 0 if the shell command succeeded.
8479 Note that which shell is used to invoke the command is system-dependent
8480 and environment-dependent.
8482 @item @emph{Standard}:
8488 @item @emph{Syntax}:
8489 @code{CALL SYSTEM(COMMAND [, STATUS])}
8491 @item @emph{Arguments}:
8492 @multitable @columnfractions .15 .80
8493 @item @var{COMMAND} @tab Shall be of default @code{CHARACTER} type.
8494 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
8497 @item @emph{See also}:
8503 @section @code{SYSTEM_CLOCK} --- Time function
8504 @cindex @code{SYSTEM_CLOCK} intrinsic
8505 @cindex time, current
8506 @cindex current time
8508 Intrinsic implemented, documentation pending.
8511 @item @emph{Description}:
8512 @item @emph{Standard}:
8518 @item @emph{Syntax}:
8519 @item @emph{Arguments}:
8520 @item @emph{Return value}:
8521 @item @emph{Example}:
8522 @item @emph{See also}:
8528 @section @code{TAN} --- Tangent function
8529 @cindex @code{TAN} intrinsic
8530 @cindex @code{DTAN} intrinsic
8531 @cindex trigonometric functions
8534 @item @emph{Description}:
8535 @code{TAN(X)} computes the tangent of @var{X}.
8537 @item @emph{Standard}:
8543 @item @emph{Syntax}:
8544 @code{RESULT = TAN(X)}
8546 @item @emph{Arguments}:
8547 @multitable @columnfractions .15 .80
8548 @item @var{X} @tab The type shall be @code{REAL(*)}.
8551 @item @emph{Return value}:
8552 The return value is of type @code{REAL(*)}. The kind type parameter is
8553 the same as @var{X}.
8555 @item @emph{Example}:
8558 real(8) :: x = 0.165_8
8560 end program test_tan
8563 @item @emph{Specific names}:
8564 @multitable @columnfractions .20 .20 .20 .40
8565 @item Name @tab Argument @tab Return type @tab Standard
8566 @item @code{DTAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
8569 @item @emph{See also}:
8576 @section @code{TANH} --- Hyperbolic tangent function
8577 @cindex @code{TANH} intrinsic
8578 @cindex @code{DTANH} intrinsic
8579 @cindex hyperbolic tangent
8582 @item @emph{Description}:
8583 @code{TANH(X)} computes the hyperbolic tangent of @var{X}.
8585 @item @emph{Standard}:
8591 @item @emph{Syntax}:
8594 @item @emph{Arguments}:
8595 @multitable @columnfractions .15 .80
8596 @item @var{X} @tab The type shall be @code{REAL(*)}.
8599 @item @emph{Return value}:
8600 The return value is of type @code{REAL(*)} and lies in the range
8601 @math{ - 1 \leq tanh(x) \leq 1 }.
8603 @item @emph{Example}:
8606 real(8) :: x = 2.1_8
8608 end program test_tanh
8611 @item @emph{Specific names}:
8612 @multitable @columnfractions .20 .20 .20 .40
8613 @item Name @tab Argument @tab Return type @tab Standard
8614 @item @code{DTANH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
8617 @item @emph{See also}:
8624 @section @code{TIME} --- Time function
8625 @cindex @code{TIME} intrinsic
8626 @cindex time, current
8627 @cindex current time
8630 @item @emph{Description}:
8631 Returns the current time encoded as an integer (in the manner of the
8632 UNIX function @code{time(3)}). This value is suitable for passing to
8633 @code{CTIME()}, @code{GMTIME()}, and @code{LTIME()}.
8635 This intrinsic is not fully portable, such as to systems with 32-bit
8636 @code{INTEGER} types but supporting times wider than 32 bits. Therefore,
8637 the values returned by this intrinsic might be, or become, negative, or
8638 numerically less than previous values, during a single run of the
8641 See @ref{TIME8}, for information on a similar intrinsic that might be
8642 portable to more GNU Fortran implementations, though to fewer Fortran
8645 @item @emph{Standard}:
8649 Non-elemental function
8651 @item @emph{Syntax}:
8652 @code{RESULT = TIME()}
8654 @item @emph{Return value}:
8655 The return value is a scalar of type @code{INTEGER(4)}.
8657 @item @emph{See also}:
8658 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{TIME8}
8665 @section @code{TIME8} --- Time function (64-bit)
8666 @cindex @code{TIME8} intrinsic
8667 @cindex time, current
8668 @cindex current time
8671 @item @emph{Description}:
8672 Returns the current time encoded as an integer (in the manner of the
8673 UNIX function @code{time(3)}). This value is suitable for passing to
8674 @code{CTIME()}, @code{GMTIME()}, and @code{LTIME()}.
8676 @emph{Warning:} this intrinsic does not increase the range of the timing
8677 values over that returned by @code{time(3)}. On a system with a 32-bit
8678 @code{time(3)}, @code{TIME8()} will return a 32-bit value, even though
8679 it is converted to a 64-bit @code{INTEGER(8)} value. That means
8680 overflows of the 32-bit value can still occur. Therefore, the values
8681 returned by this intrinsic might be or become negative or numerically
8682 less than previous values during a single run of the compiled program.
8684 @item @emph{Standard}:
8688 Non-elemental function
8690 @item @emph{Syntax}:
8691 @code{RESULT = TIME8()}
8693 @item @emph{Return value}:
8694 The return value is a scalar of type @code{INTEGER(8)}.
8696 @item @emph{See also}:
8697 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{TIME}
8704 @section @code{TINY} --- Smallest positive number of a real kind
8705 @cindex @code{TINY} intrinsic
8709 @item @emph{Description}:
8710 @code{TINY(X)} returns the smallest positive (non zero) number
8711 in the model of the type of @code{X}.
8713 @item @emph{Standard}:
8719 @item @emph{Syntax}:
8720 @code{RESULT = TINY(X)}
8722 @item @emph{Arguments}:
8723 @multitable @columnfractions .15 .80
8724 @item @var{X} @tab shall be of type @code{REAL}.
8727 @item @emph{Return value}:
8728 The return value is of the same type and kind as @var{X}
8730 @item @emph{Example}:
8731 See @code{HUGE} for an example.
8737 @section @code{TRANSFER} --- Transfer bit patterns
8738 @cindex @code{TRANSFER} intrinsic
8739 @cindex bit operations
8741 Intrinsic implemented, documentation pending.
8744 @item @emph{Description}:
8745 @item @emph{Standard}:
8749 Transformational function
8751 @item @emph{Syntax}:
8752 @item @emph{Arguments}:
8753 @item @emph{Return value}:
8754 @item @emph{Example}:
8755 @item @emph{See also}:
8761 @section @code{TRANSPOSE} --- Transpose an array of rank two
8762 @cindex @code{TRANSPOSE} intrinsic
8763 @cindex matrix manipulation
8765 Intrinsic implemented, documentation pending.
8768 @item @emph{Description}:
8769 @item @emph{Standard}:
8773 Transformational function
8775 @item @emph{Syntax}:
8776 @item @emph{Arguments}:
8777 @item @emph{Return value}:
8778 @item @emph{Example}:
8779 @item @emph{See also}:
8785 @section @code{TRIM} --- Function to remove trailing blank characters of a string
8786 @cindex @code{TRIM} intrinsic
8787 @cindex string manipulation
8789 Intrinsic implemented, documentation pending.
8792 @item @emph{Description}:
8793 @item @emph{Standard}:
8797 Transformational function
8799 @item @emph{Syntax}:
8800 @item @emph{Arguments}:
8801 @item @emph{Return value}:
8802 @item @emph{Example}:
8803 @item @emph{See also}:
8809 @section @code{UBOUND} --- Upper dimension bounds of an array
8810 @cindex @code{UBOUND} intrinsic
8813 @item @emph{Description}:
8814 Returns the upper bounds of an array, or a single upper bound
8815 along the @var{DIM} dimension.
8816 @item @emph{Standard}:
8822 @item @emph{Syntax}:
8823 @code{RESULT = UBOUND(ARRAY [, DIM])}
8825 @item @emph{Arguments}:
8826 @multitable @columnfractions .15 .80
8827 @item @var{ARRAY} @tab Shall be an array, of any type.
8828 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER(*)}.
8831 @item @emph{Return value}:
8832 If @var{DIM} is absent, the result is an array of the upper bounds of
8833 @var{ARRAY}. If @var{DIM} is present, the result is a scalar
8834 corresponding to the upper bound of the array along that dimension. If
8835 @var{ARRAY} is an expression rather than a whole array or array
8836 structure component, or if it has a zero extent along the relevant
8837 dimension, the upper bound is taken to be the number of elements along
8838 the relevant dimension.
8840 @item @emph{See also}:
8847 @section @code{UMASK} --- Set the file creation mask
8848 @cindex @code{UMASK} intrinsic
8849 @cindex file system operations
8852 @item @emph{Description}:
8853 Sets the file creation mask to @var{MASK} and returns the old value in
8854 argument @var{OLD} if it is supplied. See @code{umask(2)}.
8856 @item @emph{Standard}:
8862 @item @emph{Syntax}:
8863 @code{CALL UMASK(MASK [, OLD])}
8865 @item @emph{Arguments}:
8866 @multitable @columnfractions .15 .80
8867 @item @var{MASK} @tab Shall be a scalar of type @code{INTEGER(*)}.
8868 @item @var{MASK} @tab (Optional) Shall be a scalar of type
8877 @section @code{UNLINK} --- Remove a file from the file system
8878 @cindex @code{UNLINK} intrinsic
8879 @cindex file system operations
8882 @item @emph{Description}:
8883 Unlinks the file @var{PATH}. A null character (@code{CHAR(0)}) can be
8884 used to mark the end of the name in @var{PATH}; otherwise, trailing
8885 blanks in the file name are ignored. If the @var{STATUS} argument is
8886 supplied, it contains 0 on success or a nonzero error code upon return;
8887 see @code{unlink(2)}.
8889 @item @emph{Standard}:
8895 @item @emph{Syntax}:
8896 @code{CALL UNLINK(PATH [, STATUS])}
8898 @item @emph{Arguments}:
8899 @multitable @columnfractions .15 .80
8900 @item @var{PATH} @tab Shall be of default @code{CHARACTER} type.
8901 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
8904 @item @emph{See also}:
8905 @ref{LINK}, @ref{SYMLNK}
8911 @section @code{UNPACK} --- Unpack an array of rank one into an array
8912 @cindex @code{UNPACK} intrinsic
8913 @cindex array manipulation
8915 Intrinsic implemented, documentation pending.
8918 @item @emph{Description}:
8919 @item @emph{Standard}:
8923 Transformational function
8925 @item @emph{Syntax}:
8926 @item @emph{Arguments}:
8927 @item @emph{Return value}:
8928 @item @emph{Example}:
8930 @item @emph{See also}:
8937 @section @code{VERIFY} --- Scan a string for the absence of a set of characters
8938 @cindex @code{VERIFY} intrinsic
8939 @cindex string manipulation
8941 Intrinsic implemented, documentation pending.
8944 @item @emph{Description}:
8945 @item @emph{Standard}:
8951 @item @emph{Syntax}:
8952 @item @emph{Arguments}:
8953 @item @emph{Return value}:
8954 @item @emph{Example}:
8955 @item @emph{Specific names}:
8956 @item @emph{See also}:
8962 @section @code{XOR} --- Bitwise logical exclusive OR
8963 @cindex @code{XOR} intrinsic
8964 @cindex bit operations
8967 @item @emph{Description}:
8968 Bitwise logical exclusive or.
8970 This intrinsic routine is provided for backwards compatibility with
8971 GNU Fortran 77. For integer arguments, programmers should consider
8972 the use of the @ref{IEOR} intrinsic defined by the Fortran standard.
8974 @item @emph{Standard}:
8978 Non-elemental function
8980 @item @emph{Syntax}:
8981 @code{RESULT = XOR(X, Y)}
8983 @item @emph{Arguments}:
8984 @multitable @columnfractions .15 .80
8985 @item @var{X} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
8986 @item @var{Y} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
8989 @item @emph{Return value}:
8990 The return type is either @code{INTEGER(*)} or @code{LOGICAL}
8991 after cross-promotion of the arguments.
8993 @item @emph{Example}:
8996 LOGICAL :: T = .TRUE., F = .FALSE.
8998 DATA a / Z,'F' /, b / Z'3' /
9000 WRITE (*,*) XOR(T, T), XOR(T, F), XOR(F, T), XOR(F, F)
9001 WRITE (*,*) XOR(a, b)
9005 @item @emph{See also}:
9006 F95 elemental function: @ref{IEOR}