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{SNGL}: SNGL, Convert double precision real to default real
229 * @code{SPACING}: SPACING, Smallest distance between two numbers of a given type
230 * @code{SPREAD}: SPREAD, Add a dimension to an array
231 * @code{SQRT}: SQRT, Square-root function
232 * @code{SRAND}: SRAND, Reinitialize the random number generator
233 * @code{STAT}: STAT, Get file status
234 * @code{SUM}: SUM, Sum of array elements
235 * @code{SYMLNK}: SYMLNK, Create a symbolic link
236 * @code{SYSTEM}: SYSTEM, Execute a shell command
237 * @code{SYSTEM_CLOCK}: SYSTEM_CLOCK, Time function
238 * @code{TAN}: TAN, Tangent function
239 * @code{TANH}: TANH, Hyperbolic tangent function
240 * @code{TIME}: TIME, Time function
241 * @code{TIME8}: TIME8, Time function (64-bit)
242 * @code{TINY}: TINY, Smallest positive number of a real kind
243 * @code{TRANSFER}: TRANSFER, Transfer bit patterns
244 * @code{TRANSPOSE}: TRANSPOSE, Transpose an array of rank two
245 * @code{TRIM}: TRIM, Function to remove trailing blank characters of a string
246 * @code{UBOUND}: UBOUND, Upper dimension bounds of an array
247 * @code{UMASK}: UMASK, Set the file creation mask
248 * @code{UNLINK}: UNLINK, Remove a file from the file system
249 * @code{UNPACK}: UNPACK, Unpack an array of rank one into an array
250 * @code{VERIFY}: VERIFY, Scan a string for the absence of a set of characters
251 * @code{XOR}: XOR, Bitwise logical exclusive or
254 @node Introduction to Intrinsics
255 @section Introduction to intrinsic procedures
257 The intrinsic procedures provided by GNU Fortran include all of the
258 intrinsic procedures required by the Fortran 95 standard, a set of
259 intrinsic procedures for backwards compatibility with G77, and a small
260 selection of intrinsic procedures from the Fortran 2003 standard. Any
261 conflict between a description here and a description in either the
262 Fortran 95 standard or the Fortran 2003 standard is unintentional, and
263 the standard(s) should be considered authoritative.
265 The enumeration of the @code{KIND} type parameter is processor defined in
266 the Fortran 95 standard. GNU Fortran defines the default integer type and
267 default real type by @code{INTEGER(KIND=4)} and @code{REAL(KIND=4)},
268 respectively. The standard mandates that both data types shall have
269 another kind, which have more precision. On typical target architectures
270 supported by @command{gfortran}, this kind type parameter is @code{KIND=8}.
271 Hence, @code{REAL(KIND=8)} and @code{DOUBLE PRECISION} are equivalent.
272 In the description of generic intrinsic procedures, the kind type parameter
273 will be specified by @code{KIND=*}, and in the description of specific
274 names for an intrinsic procedure the kind type parameter will be explicitly
275 given (e.g., @code{REAL(KIND=4)} or @code{REAL(KIND=8)}). Finally, for
276 brevity the optional @code{KIND=} syntax will be omitted.
278 Many of the intrinsic procedures take one or more optional arguments.
279 This document follows the convention used in the Fortran 95 standard,
280 and denotes such arguments by square brackets.
282 GNU Fortran offers the @option{-std=f95} and @option{-std=gnu} options,
283 which can be used to restrict the set of intrinsic procedures to a
284 given standard. By default, @command{gfortran} sets the @option{-std=gnu}
285 option, and so all intrinsic procedures described here are accepted. There
286 is one caveat. For a select group of intrinsic procedures, @command{g77}
287 implemented both a function and a subroutine. Both classes
288 have been implemented in @command{gfortran} for backwards compatibility
289 with @command{g77}. It is noted here that these functions and subroutines
290 cannot be intermixed in a given subprogram. In the descriptions that follow,
291 the applicable standard for each intrinsic procedure is noted.
296 @section @code{ABORT} --- Abort the program
297 @cindex @code{ABORT} intrinsic
301 @item @emph{Description}:
302 @code{ABORT} causes immediate termination of the program. On operating
303 systems that support a core dump, @code{ABORT} will produce a core dump,
304 which is suitable for debugging purposes.
306 @item @emph{Standard}:
310 non-elemental subroutine
315 @item @emph{Return value}:
318 @item @emph{Example}:
321 integer :: i = 1, j = 2
322 if (i /= j) call abort
323 end program test_abort
326 @item @emph{See also}:
327 @ref{EXIT}, @ref{KILL}
333 @section @code{ABS} --- Absolute value
334 @cindex @code{ABS} intrinsic
335 @cindex @code{CABS} intrinsic
336 @cindex @code{DABS} intrinsic
337 @cindex @code{IABS} intrinsic
338 @cindex @code{ZABS} intrinsic
339 @cindex @code{CDABS} intrinsic
340 @cindex absolute value
343 @item @emph{Description}:
344 @code{ABS(X)} computes the absolute value of @code{X}.
346 @item @emph{Standard}:
347 F77 and later, has overloads that are GNU extensions
353 @code{RESULT = ABS(X)}
355 @item @emph{Arguments}:
356 @multitable @columnfractions .15 .80
357 @item @var{X} @tab The type of the argument shall be an @code{INTEGER(*)},
358 @code{REAL(*)}, or @code{COMPLEX(*)}.
361 @item @emph{Return value}:
362 The return value is of the same type and
363 kind as the argument except the return value is @code{REAL(*)} for a
364 @code{COMPLEX(*)} argument.
366 @item @emph{Example}:
371 complex :: z = (-1.e0,0.e0)
378 @item @emph{Specific names}:
379 @multitable @columnfractions .20 .20 .20 .40
380 @item Name @tab Argument @tab Return type @tab Standard
381 @item @code{CABS(Z)} @tab @code{COMPLEX(4) Z} @tab @code{REAL(4)} @tab F77 and later
382 @item @code{DABS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
383 @item @code{IABS(I)} @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)} @tab F77 and later
384 @item @code{ZABS(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
385 @item @code{CDABS(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
391 @section @code{ACCESS} --- Checks file access modes
392 @cindex @code{ACCESS}
393 @cindex file system operations
396 @item @emph{Description}:
397 @code{ACCESS(NAME, MODE)} checks whether the file @var{NAME}
398 exists, is readable, writable or executable. Except for the
399 executable check, @code{ACCESS} can be replaced by
400 Fortran 95's @code{INQUIRE}.
402 @item @emph{Standard}:
409 @code{RESULT = ACCESS(NAME, MODE)}
411 @item @emph{Arguments}:
412 @multitable @columnfractions .15 .80
413 @item @var{NAME} @tab Scalar @code{CHARACTER} with the file name.
414 Tailing blank are ignored unless the character @code{achar(0)} is
415 present, then all characters up to and excluding @code{achar(0)} are
417 @item @var{MODE} @tab Scalar @code{CHARACTER} with the file access mode,
418 may be any concatenation of @code{"r"} (readable), @code{"w"} (writable)
419 and @code{"x"} (executable), or @code{" "} to check for existence.
422 @item @emph{Return value}:
423 Returns a scalar @code{INTEGER}, which is @code{0} if the file is
424 accessible in the given mode; otherwise or if an invalid argument
425 has been given for @code{MODE} the value @code{1} is returned.
427 @item @emph{Example}:
431 character(len=*), parameter :: file = 'test.dat'
432 character(len=*), parameter :: file2 = 'test.dat '//achar(0)
433 if(access(file,' ') == 0) print *, trim(file),' is exists'
434 if(access(file,'r') == 0) print *, trim(file),' is readable'
435 if(access(file,'w') == 0) print *, trim(file),' is writable'
436 if(access(file,'x') == 0) print *, trim(file),' is executable'
437 if(access(file2,'rwx') == 0) &
438 print *, trim(file2),' is readable, writable and executable'
439 end program access_test
441 @item @emph{Specific names}:
442 @item @emph{See also}:
448 @section @code{ACHAR} --- Character in @acronym{ASCII} collating sequence
449 @cindex @code{ACHAR} intrinsic
450 @cindex @acronym{ASCII} collating sequence
453 @item @emph{Description}:
454 @code{ACHAR(I)} returns the character located at position @code{I}
455 in the @acronym{ASCII} collating sequence.
457 @item @emph{Standard}:
464 @code{RESULT = ACHAR(I)}
466 @item @emph{Arguments}:
467 @multitable @columnfractions .15 .80
468 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
471 @item @emph{Return value}:
472 The return value is of type @code{CHARACTER} with a length of one. The
473 kind type parameter is the same as @code{KIND('A')}.
475 @item @emph{Example}:
480 end program test_achar
483 @item @emph{See also}:
484 @ref{CHAR}, @ref{IACHAR}, @ref{ICHAR}
491 @section @code{ACOS} --- Arccosine function
492 @cindex @code{ACOS} intrinsic
493 @cindex @code{DACOS} intrinsic
494 @cindex trigonometric functions (inverse)
497 @item @emph{Description}:
498 @code{ACOS(X)} computes the arccosine of @var{X} (inverse of @code{COS(X)}).
500 @item @emph{Standard}:
507 @code{RESULT = ACOS(X)}
509 @item @emph{Arguments}:
510 @multitable @columnfractions .15 .80
511 @item @var{X} @tab The type shall be @code{REAL(*)} with a magnitude that is
515 @item @emph{Return value}:
516 The return value is of type @code{REAL(*)} and it lies in the
517 range @math{ 0 \leq \acos(x) \leq \pi}. The kind type parameter
518 is the same as @var{X}.
520 @item @emph{Example}:
523 real(8) :: x = 0.866_8
525 end program test_acos
528 @item @emph{Specific names}:
529 @multitable @columnfractions .20 .20 .20 .40
530 @item Name @tab Argument @tab Return type @tab Standard
531 @item @code{DACOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
534 @item @emph{See also}:
535 Inverse function: @ref{COS}
541 @section @code{ACOSH} --- Hyperbolic arccosine function
542 @cindex @code{ACOSH} intrinsic
543 @cindex hyperbolic arccosine
544 @cindex hyperbolic cosine (inverse)
547 @item @emph{Description}:
548 @code{ACOSH(X)} computes the area hyperbolic cosine of @var{X} (inverse of @code{COSH(X)}).
550 @item @emph{Standard}:
557 @code{RESULT = ACOSH(X)}
559 @item @emph{Arguments}:
560 @multitable @columnfractions .15 .80
561 @item @var{X} @tab The type shall be @code{REAL(*)} with a magnitude that is
562 greater or equal to one.
565 @item @emph{Return value}:
566 The return value is of type @code{REAL(*)} and it lies in the
567 range @math{0 \leq \acosh (x) \leq \infty}.
569 @item @emph{Example}:
572 REAL(8), DIMENSION(3) :: x = (/ 1.0, 2.0, 3.0 /)
577 @item @emph{See also}:
578 Inverse function: @ref{COSH}
584 @section @code{ADJUSTL} --- Left adjust a string
585 @cindex @code{ADJUSTL} intrinsic
586 @cindex adjust string
589 @item @emph{Description}:
590 @code{ADJUSTL(STR)} will left adjust a string by removing leading spaces.
591 Spaces are inserted at the end of the string as needed.
593 @item @emph{Standard}:
600 @code{RESULT = ADJUSTL(STR)}
602 @item @emph{Arguments}:
603 @multitable @columnfractions .15 .80
604 @item @var{STR} @tab The type shall be @code{CHARACTER}.
607 @item @emph{Return value}:
608 The return value is of type @code{CHARACTER} where leading spaces
609 are removed and the same number of spaces are inserted on the end
612 @item @emph{Example}:
615 character(len=20) :: str = ' gfortran'
618 end program test_adjustl
625 @section @code{ADJUSTR} --- Right adjust a string
626 @cindex @code{ADJUSTR} intrinsic
627 @cindex adjust string
630 @item @emph{Description}:
631 @code{ADJUSTR(STR)} will right adjust a string by removing trailing spaces.
632 Spaces are inserted at the start of the string as needed.
634 @item @emph{Standard}:
641 @code{RESULT = ADJUSTR(STR)}
643 @item @emph{Arguments}:
644 @multitable @columnfractions .15 .80
645 @item @var{STR} @tab The type shall be @code{CHARACTER}.
648 @item @emph{Return value}:
649 The return value is of type @code{CHARACTER} where trailing spaces
650 are removed and the same number of spaces are inserted at the start
653 @item @emph{Example}:
656 character(len=20) :: str = 'gfortran'
659 end program test_adjustr
666 @section @code{AIMAG} --- Imaginary part of complex number
667 @cindex @code{AIMAG} intrinsic
668 @cindex @code{DIMAG} intrinsic
669 @cindex @code{IMAG} intrinsic
670 @cindex @code{IMAGPART} intrinsic
671 @cindex imaginary part of a complex number
674 @item @emph{Description}:
675 @code{AIMAG(Z)} yields the imaginary part of complex argument @code{Z}.
676 The @code{IMAG(Z)} and @code{IMAGPART(Z)} intrinsic functions are provided
677 for compatibility with @command{g77}, and their use in new code is
678 strongly discouraged.
680 @item @emph{Standard}:
681 F77 and later, has overloads that are GNU extensions
687 @code{RESULT = AIMAG(Z)}
689 @item @emph{Arguments}:
690 @multitable @columnfractions .15 .80
691 @item @var{Z} @tab The type of the argument shall be @code{COMPLEX(*)}.
694 @item @emph{Return value}:
695 The return value is of type real with the
696 kind type parameter of the argument.
698 @item @emph{Example}:
703 z4 = cmplx(1.e0_4, 0.e0_4)
704 z8 = cmplx(0.e0_8, 1.e0_8)
705 print *, aimag(z4), dimag(z8)
706 end program test_aimag
709 @item @emph{Specific names}:
710 @multitable @columnfractions .20 .20 .20 .40
711 @item Name @tab Argument @tab Return type @tab Standard
712 @item @code{DIMAG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{REAL(8)} @tab GNU extension
713 @item @code{IMAG(Z)} @tab @code{COMPLEX(*) Z} @tab @code{REAL(*)} @tab GNU extension
714 @item @code{IMAGPART(Z)} @tab @code{COMPLEX(*) Z} @tab @code{REAL(*)} @tab GNU extension
721 @section @code{AINT} --- Truncate to a whole number
722 @cindex @code{AINT} intrinsic
723 @cindex @code{DINT} intrinsic
727 @item @emph{Description}:
728 @code{AINT(X [, KIND])} truncates its argument to a whole number.
730 @item @emph{Standard}:
737 @code{RESULT = AINT(X [, KIND])}
739 @item @emph{Arguments}:
740 @multitable @columnfractions .15 .80
741 @item @var{X} @tab The type of the argument shall be @code{REAL(*)}.
742 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
743 expression indicating the kind parameter of
747 @item @emph{Return value}:
748 The return value is of type real with the kind type parameter of the
749 argument if the optional @var{KIND} is absent; otherwise, the kind
750 type parameter will be given by @var{KIND}. If the magnitude of
751 @var{X} is less than one, then @code{AINT(X)} returns zero. If the
752 magnitude is equal to or greater than one, then it returns the largest
753 whole number that does not exceed its magnitude. The sign is the same
754 as the sign of @var{X}.
756 @item @emph{Example}:
763 print *, aint(x4), dint(x8)
765 end program test_aint
768 @item @emph{Specific names}:
769 @multitable @columnfractions .20 .20 .20 .40
770 @item Name @tab Argument @tab Return type @tab Standard
771 @item @code{DINT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
778 @section @code{ALARM} --- Execute a routine after a given delay
779 @cindex @code{ALARM} intrinsic
782 @item @emph{Description}:
783 @code{ALARM(SECONDS, HANDLER [, STATUS])} causes external subroutine @var{HANDLER}
784 to be executed after a delay of @var{SECONDS} by using @code{alarm(1)} to
785 set up a signal and @code{signal(2)} to catch it. If @var{STATUS} is
786 supplied, it will be returned with the number of seconds remaining until
787 any previously scheduled alarm was due to be delivered, or zero if there
788 was no previously scheduled alarm.
790 @item @emph{Standard}:
797 @code{CALL ALARM(SECONDS, HANDLER [, STATUS])}
799 @item @emph{Arguments}:
800 @multitable @columnfractions .15 .80
801 @item @var{SECONDS} @tab The type of the argument shall be a scalar
802 @code{INTEGER}. It is @code{INTENT(IN)}.
803 @item @var{HANDLER} @tab Signal handler (@code{INTEGER FUNCTION} or
804 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar.
805 @code{INTEGER}. It is @code{INTENT(IN)}.
806 @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
807 @code{INTEGER} variable. It is @code{INTENT(OUT)}.
810 @item @emph{Example}:
813 external handler_print
815 call alarm (3, handler_print, i)
818 end program test_alarm
820 This will cause the external routine @var{handler_print} to be called
827 @section @code{ALL} --- All values in @var{MASK} along @var{DIM} are true
828 @cindex @code{ALL} intrinsic
832 @item @emph{Description}:
833 @code{ALL(MASK [, DIM])} determines if all the values are true in @var{MASK}
834 in the array along dimension @var{DIM}.
836 @item @emph{Standard}:
840 transformational function
843 @code{RESULT = ALL(MASK [, DIM])}
845 @item @emph{Arguments}:
846 @multitable @columnfractions .15 .80
847 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL(*)} and
848 it shall not be scalar.
849 @item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer
850 with a value that lies between one and the rank of @var{MASK}.
853 @item @emph{Return value}:
854 @code{ALL(MASK)} returns a scalar value of type @code{LOGICAL(*)} where
855 the kind type parameter is the same as the kind type parameter of
856 @var{MASK}. If @var{DIM} is present, then @code{ALL(MASK, DIM)} returns
857 an array with the rank of @var{MASK} minus 1. The shape is determined from
858 the shape of @var{MASK} where the @var{DIM} dimension is elided.
862 @code{ALL(MASK)} is true if all elements of @var{MASK} are true.
863 It also is true if @var{MASK} has zero size; otherwise, it is false.
865 If the rank of @var{MASK} is one, then @code{ALL(MASK,DIM)} is equivalent
866 to @code{ALL(MASK)}. If the rank is greater than one, then @code{ALL(MASK,DIM)}
867 is determined by applying @code{ALL} to the array sections.
870 @item @emph{Example}:
874 l = all((/.true., .true., .true./))
879 integer a(2,3), b(2,3)
883 print *, all(a .eq. b, 1)
884 print *, all(a .eq. b, 2)
885 end subroutine section
893 @section @code{ALLOCATED} --- Status of an allocatable entity
894 @cindex @code{ALLOCATED} intrinsic
895 @cindex allocation status
898 @item @emph{Description}:
899 @code{ALLOCATED(X)} checks the status of whether @var{X} is allocated.
901 @item @emph{Standard}:
908 @code{RESULT = ALLOCATED(X)}
910 @item @emph{Arguments}:
911 @multitable @columnfractions .15 .80
912 @item @var{X} @tab The argument shall be an @code{ALLOCATABLE} array.
915 @item @emph{Return value}:
916 The return value is a scalar @code{LOGICAL} with the default logical
917 kind type parameter. If @var{X} is allocated, @code{ALLOCATED(X)}
918 is @code{.TRUE.}; otherwise, it returns the @code{.TRUE.}
920 @item @emph{Example}:
922 program test_allocated
924 real(4), allocatable :: x(:)
925 if (allocated(x) .eqv. .false.) allocate(x(i))
926 end program test_allocated
932 @section @code{AND} --- Bitwise logical AND
933 @cindex @code{AND} intrinsic
934 @cindex bit operations
937 @item @emph{Description}:
938 Bitwise logical @code{AND}.
940 This intrinsic routine is provided for backwards compatibility with
941 GNU Fortran 77. For integer arguments, programmers should consider
942 the use of the @ref{IAND} intrinsic defined by the Fortran standard.
944 @item @emph{Standard}:
948 Non-elemental function
951 @code{RESULT = AND(X, Y)}
953 @item @emph{Arguments}:
954 @multitable @columnfractions .15 .80
955 @item @var{X} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
956 @item @var{Y} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
959 @item @emph{Return value}:
960 The return type is either @code{INTEGER(*)} or @code{LOGICAL} after
961 cross-promotion of the arguments.
963 @item @emph{Example}:
966 LOGICAL :: T = .TRUE., F = ..FALSE.
968 DATA a / Z'F' /, b / Z'3' /
970 WRITE (*,*) AND(T, T), AND(T, F), AND(F, T), AND(F, F)
971 WRITE (*,*) AND(a, b)
975 @item @emph{See also}:
976 F95 elemental function: @ref{IAND}
982 @section @code{ANINT} --- Nearest whole number
983 @cindex @code{ANINT} intrinsic
984 @cindex @code{DNINT} intrinsic
988 @item @emph{Description}:
989 @code{ANINT(X [, KIND])} rounds its argument to the nearest whole number.
991 @item @emph{Standard}:
998 @code{RESULT = ANINT(X [, KIND])}
1000 @item @emph{Arguments}:
1001 @multitable @columnfractions .15 .80
1002 @item @var{X} @tab The type of the argument shall be @code{REAL(*)}.
1003 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
1004 expression indicating the kind parameter of
1008 @item @emph{Return value}:
1009 The return value is of type real with the kind type parameter of the
1010 argument if the optional @var{KIND} is absent; otherwise, the kind
1011 type parameter will be given by @var{KIND}. If @var{X} is greater than
1012 zero, then @code{ANINT(X)} returns @code{AINT(X+0.5)}. If @var{X} is
1013 less than or equal to zero, then it returns @code{AINT(X-0.5)}.
1015 @item @emph{Example}:
1022 print *, anint(x4), dnint(x8)
1024 end program test_anint
1027 @item @emph{Specific names}:
1028 @multitable @columnfractions .20 .20 .20 .40
1029 @item Name @tab Argument @tab Return type @tab Standard
1030 @item @code{DNINT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1037 @section @code{ANY} --- Any value in @var{MASK} along @var{DIM} is true
1038 @cindex @code{ANY} intrinsic
1042 @item @emph{Description}:
1043 @code{ANY(MASK [, DIM])} determines if any of the values in the logical array
1044 @var{MASK} along dimension @var{DIM} are @code{.TRUE.}.
1046 @item @emph{Standard}:
1050 transformational function
1052 @item @emph{Syntax}:
1053 @code{RESULT = ANY(MASK [, DIM])}
1055 @item @emph{Arguments}:
1056 @multitable @columnfractions .15 .80
1057 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL(*)} and
1058 it shall not be scalar.
1059 @item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer
1060 with a value that lies between one and the rank of @var{MASK}.
1063 @item @emph{Return value}:
1064 @code{ANY(MASK)} returns a scalar value of type @code{LOGICAL(*)} where
1065 the kind type parameter is the same as the kind type parameter of
1066 @var{MASK}. If @var{DIM} is present, then @code{ANY(MASK, DIM)} returns
1067 an array with the rank of @var{MASK} minus 1. The shape is determined from
1068 the shape of @var{MASK} where the @var{DIM} dimension is elided.
1072 @code{ANY(MASK)} is true if any element of @var{MASK} is true;
1073 otherwise, it is false. It also is false if @var{MASK} has zero size.
1075 If the rank of @var{MASK} is one, then @code{ANY(MASK,DIM)} is equivalent
1076 to @code{ANY(MASK)}. If the rank is greater than one, then @code{ANY(MASK,DIM)}
1077 is determined by applying @code{ANY} to the array sections.
1080 @item @emph{Example}:
1084 l = any((/.true., .true., .true./))
1089 integer a(2,3), b(2,3)
1093 print *, any(a .eq. b, 1)
1094 print *, any(a .eq. b, 2)
1095 end subroutine section
1096 end program test_any
1103 @section @code{ASIN} --- Arcsine function
1104 @cindex @code{ASIN} intrinsic
1105 @cindex @code{DASIN} intrinsic
1106 @cindex trigonometric functions (inverse)
1109 @item @emph{Description}:
1110 @code{ASIN(X)} computes the arcsine of its @var{X} (inverse of @code{SIN(X)}).
1112 @item @emph{Standard}:
1118 @item @emph{Syntax}:
1119 @code{RESULT = ASIN(X)}
1121 @item @emph{Arguments}:
1122 @multitable @columnfractions .15 .80
1123 @item @var{X} @tab The type shall be @code{REAL(*)}, and a magnitude that is
1127 @item @emph{Return value}:
1128 The return value is of type @code{REAL(*)} and it lies in the
1129 range @math{-\pi / 2 \leq \asin (x) \leq \pi / 2}. The kind type
1130 parameter is the same as @var{X}.
1132 @item @emph{Example}:
1135 real(8) :: x = 0.866_8
1137 end program test_asin
1140 @item @emph{Specific names}:
1141 @multitable @columnfractions .20 .20 .20 .40
1142 @item Name @tab Argument @tab Return type @tab Standard
1143 @item @code{DASIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1146 @item @emph{See also}:
1147 Inverse function: @ref{SIN}
1153 @section @code{ASINH} --- Hyperbolic arcsine function
1154 @cindex @code{ASINH} intrinsic
1155 @cindex hyperbolic arcsine
1156 @cindex hyperbolic sine (inverse)
1159 @item @emph{Description}:
1160 @code{ASINH(X)} computes the area hyperbolic sine of @var{X} (inverse of @code{SINH(X)}).
1162 @item @emph{Standard}:
1168 @item @emph{Syntax}:
1169 @code{RESULT = ASINH(X)}
1171 @item @emph{Arguments}:
1172 @multitable @columnfractions .15 .80
1173 @item @var{X} @tab The type shall be @code{REAL(*)}, with @var{X} a real number.
1176 @item @emph{Return value}:
1177 The return value is of type @code{REAL(*)} and it lies in the
1178 range @math{-\infty \leq \asinh (x) \leq \infty}.
1180 @item @emph{Example}:
1183 REAL(8), DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1184 WRITE (*,*) ASINH(x)
1188 @item @emph{See also}:
1189 Inverse function: @ref{SINH}
1195 @section @code{ASSOCIATED} --- Status of a pointer or pointer/target pair
1196 @cindex @code{ASSOCIATED} intrinsic
1197 @cindex pointer status
1200 @item @emph{Description}:
1201 @code{ASSOCIATED(PTR [, TGT])} determines the status of the pointer @var{PTR}
1202 or if @var{PTR} is associated with the target @var{TGT}.
1204 @item @emph{Standard}:
1210 @item @emph{Syntax}:
1211 @code{RESULT = ASSOCIATED(PTR [, TGT])}
1213 @item @emph{Arguments}:
1214 @multitable @columnfractions .15 .80
1215 @item @var{PTR} @tab @var{PTR} shall have the @code{POINTER} attribute and
1216 it can be of any type.
1217 @item @var{TGT} @tab (Optional) @var{TGT} shall be a @code{POINTER} or
1218 a @code{TARGET}. It must have the same type, kind type parameter, and
1219 array rank as @var{PTR}.
1221 The status of neither @var{PTR} nor @var{TGT} can be undefined.
1223 @item @emph{Return value}:
1224 @code{ASSOCIATED(PTR)} returns a scalar value of type @code{LOGICAL(4)}.
1225 There are several cases:
1227 @item (A) If the optional @var{TGT} is not present, then @code{ASSOCIATED(PTR)}
1228 is true if @var{PTR} is associated with a target; otherwise, it returns false.
1229 @item (B) If @var{TGT} is present and a scalar target, the result is true if
1231 is not a 0 sized storage sequence and the target associated with @var{PTR}
1232 occupies the same storage units. If @var{PTR} is disassociated, then the
1234 @item (C) If @var{TGT} is present and an array target, the result is true if
1235 @var{TGT} and @var{PTR} have the same shape, are not 0 sized arrays, are
1236 arrays whose elements are not 0 sized storage sequences, and @var{TGT} and
1237 @var{PTR} occupy the same storage units in array element order.
1238 As in case(B), the result is false, if @var{PTR} is disassociated.
1239 @item (D) If @var{TGT} is present and an scalar pointer, the result is true if
1240 target associated with @var{PTR} and the target associated with @var{TGT}
1241 are not 0 sized storage sequences and occupy the same storage units.
1242 The result is false, if either @var{TGT} or @var{PTR} is disassociated.
1243 @item (E) If @var{TGT} is present and an array pointer, the result is true if
1244 target associated with @var{PTR} and the target associated with @var{TGT}
1245 have the same shape, are not 0 sized arrays, are arrays whose elements are
1246 not 0 sized storage sequences, and @var{TGT} and @var{PTR} occupy the same
1247 storage units in array element order.
1248 The result is false, if either @var{TGT} or @var{PTR} is disassociated.
1251 @item @emph{Example}:
1253 program test_associated
1255 real, target :: tgt(2) = (/1., 2./)
1256 real, pointer :: ptr(:)
1258 if (associated(ptr) .eqv. .false.) call abort
1259 if (associated(ptr,tgt) .eqv. .false.) call abort
1260 end program test_associated
1263 @item @emph{See also}:
1270 @section @code{ATAN} --- Arctangent function
1271 @cindex @code{ATAN} intrinsic
1272 @cindex @code{DATAN} intrinsic
1273 @cindex trigonometric functions (inverse)
1276 @item @emph{Description}:
1277 @code{ATAN(X)} computes the arctangent of @var{X}.
1279 @item @emph{Standard}:
1285 @item @emph{Syntax}:
1286 @code{RESULT = ATAN(X)}
1288 @item @emph{Arguments}:
1289 @multitable @columnfractions .15 .80
1290 @item @var{X} @tab The type shall be @code{REAL(*)}.
1293 @item @emph{Return value}:
1294 The return value is of type @code{REAL(*)} and it lies in the
1295 range @math{ - \pi / 2 \leq \atan (x) \leq \pi / 2}.
1297 @item @emph{Example}:
1300 real(8) :: x = 2.866_8
1302 end program test_atan
1305 @item @emph{Specific names}:
1306 @multitable @columnfractions .20 .20 .20 .40
1307 @item Name @tab Argument @tab Return type @tab Standard
1308 @item @code{DATAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1311 @item @emph{See also}:
1312 Inverse function: @ref{TAN}
1319 @section @code{ATAN2} --- Arctangent function
1320 @cindex @code{ATAN2} intrinsic
1321 @cindex @code{DATAN2} intrinsic
1322 @cindex trigonometric functions (inverse)
1325 @item @emph{Description}:
1326 @code{ATAN2(Y,X)} computes the arctangent of the complex number @math{X + i Y}.
1328 @item @emph{Standard}:
1334 @item @emph{Syntax}:
1335 @code{RESULT = ATAN2(Y,X)}
1337 @item @emph{Arguments}:
1338 @multitable @columnfractions .15 .80
1339 @item @var{Y} @tab The type shall be @code{REAL(*)}.
1340 @item @var{X} @tab The type and kind type parameter shall be the same as @var{Y}.
1341 If @var{Y} is zero, then @var{X} must be nonzero.
1344 @item @emph{Return value}:
1345 The return value has the same type and kind type parameter as @var{Y}.
1346 It is the principal value of the complex number @math{X + i Y}. If
1347 @var{X} is nonzero, then it lies in the range @math{-\pi \le \atan (x) \leq \pi}.
1348 The sign is positive if @var{Y} is positive. If @var{Y} is zero, then
1349 the return value is zero if @var{X} is positive and @math{\pi} if @var{X}
1350 is negative. Finally, if @var{X} is zero, then the magnitude of the result
1353 @item @emph{Example}:
1356 real(4) :: x = 1.e0_4, y = 0.5e0_4
1358 end program test_atan2
1361 @item @emph{Specific names}:
1362 @multitable @columnfractions .20 .20 .20 .40
1363 @item Name @tab Argument @tab Return type @tab Standard
1364 @item @code{DATAN2(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1371 @section @code{ATANH} --- Hyperbolic arctangent function
1372 @cindex @code{ASINH} intrinsic
1373 @cindex hyperbolic arctangent
1374 @cindex hyperbolic tangent (inverse)
1377 @item @emph{Description}:
1378 @code{ATANH(X)} computes the area hyperbolic sine of @var{X} (inverse of @code{TANH(X)}).
1380 @item @emph{Standard}:
1386 @item @emph{Syntax}:
1387 @code{RESULT = ATANH(X)}
1389 @item @emph{Arguments}:
1390 @multitable @columnfractions .15 .80
1391 @item @var{X} @tab The type shall be @code{REAL(*)} with a magnitude
1392 that is less than or equal to one.
1395 @item @emph{Return value}:
1396 The return value is of type @code{REAL(*)} and it lies in the
1397 range @math{-\infty \leq \atanh(x) \leq \infty}.
1399 @item @emph{Example}:
1402 REAL, DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1403 WRITE (*,*) ATANH(x)
1407 @item @emph{See also}:
1408 Inverse function: @ref{TANH}
1415 @section @code{BESJ0} --- Bessel function of the first kind of order 0
1416 @cindex @code{BESJ0} intrinsic
1417 @cindex @code{DBESJ0} intrinsic
1421 @item @emph{Description}:
1422 @code{BESJ0(X)} computes the Bessel function of the first kind of order 0
1425 @item @emph{Standard}:
1431 @item @emph{Syntax}:
1432 @code{RESULT = BESJ0(X)}
1434 @item @emph{Arguments}:
1435 @multitable @columnfractions .15 .80
1436 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1439 @item @emph{Return value}:
1440 The return value is of type @code{REAL(*)} and it lies in the
1441 range @math{ - 0.4027... \leq Bessel (0,x) \leq 1}.
1443 @item @emph{Example}:
1446 real(8) :: x = 0.0_8
1448 end program test_besj0
1451 @item @emph{Specific names}:
1452 @multitable @columnfractions .20 .20 .20 .40
1453 @item Name @tab Argument @tab Return type @tab Standard
1454 @item @code{DBESJ0(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1461 @section @code{BESJ1} --- Bessel function of the first kind of order 1
1462 @cindex @code{BESJ1} intrinsic
1463 @cindex @code{DBESJ1} intrinsic
1467 @item @emph{Description}:
1468 @code{BESJ1(X)} computes the Bessel function of the first kind of order 1
1471 @item @emph{Standard}:
1477 @item @emph{Syntax}:
1478 @code{RESULT = BESJ1(X)}
1480 @item @emph{Arguments}:
1481 @multitable @columnfractions .15 .80
1482 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1485 @item @emph{Return value}:
1486 The return value is of type @code{REAL(*)} and it lies in the
1487 range @math{ - 0.5818... \leq Bessel (0,x) \leq 0.5818 }.
1489 @item @emph{Example}:
1492 real(8) :: x = 1.0_8
1494 end program test_besj1
1497 @item @emph{Specific names}:
1498 @multitable @columnfractions .20 .20 .20 .40
1499 @item Name @tab Argument @tab Return type @tab Standard
1500 @item @code{DBESJ1(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1507 @section @code{BESJN} --- Bessel function of the first kind
1508 @cindex @code{BESJN} intrinsic
1509 @cindex @code{DBESJN} intrinsic
1513 @item @emph{Description}:
1514 @code{BESJN(N, X)} computes the Bessel function of the first kind of order
1517 @item @emph{Standard}:
1523 @item @emph{Syntax}:
1524 @code{RESULT = BESJN(N, X)}
1526 @item @emph{Arguments}:
1527 @multitable @columnfractions .15 .80
1528 @item @var{N} @tab The type shall be @code{INTEGER(*)}, and it shall be scalar.
1529 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1532 @item @emph{Return value}:
1533 The return value is a scalar of type @code{REAL(*)}.
1535 @item @emph{Example}:
1538 real(8) :: x = 1.0_8
1540 end program test_besjn
1543 @item @emph{Specific names}:
1544 @multitable @columnfractions .20 .20 .20 .40
1545 @item Name @tab Argument @tab Return type @tab Standard
1546 @item @code{DBESJN(X)} @tab @code{INTEGER(*) N} @tab @code{REAL(8)} @tab GNU extension
1547 @item @tab @code{REAL(8) X} @tab @tab
1554 @section @code{BESY0} --- Bessel function of the second kind of order 0
1555 @cindex @code{BESY0} intrinsic
1556 @cindex @code{DBESY0} intrinsic
1560 @item @emph{Description}:
1561 @code{BESY0(X)} computes the Bessel function of the second kind of order 0
1564 @item @emph{Standard}:
1570 @item @emph{Syntax}:
1571 @code{RESULT = BESY0(X)}
1573 @item @emph{Arguments}:
1574 @multitable @columnfractions .15 .80
1575 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1578 @item @emph{Return value}:
1579 The return value is a scalar of type @code{REAL(*)}.
1581 @item @emph{Example}:
1584 real(8) :: x = 0.0_8
1586 end program test_besy0
1589 @item @emph{Specific names}:
1590 @multitable @columnfractions .20 .20 .20 .40
1591 @item Name @tab Argument @tab Return type @tab Standard
1592 @item @code{DBESY0(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1599 @section @code{BESY1} --- Bessel function of the second kind of order 1
1600 @cindex @code{BESY1} intrinsic
1601 @cindex @code{DBESY1} intrinsic
1605 @item @emph{Description}:
1606 @code{BESY1(X)} computes the Bessel function of the second kind of order 1
1609 @item @emph{Standard}:
1615 @item @emph{Syntax}:
1616 @code{RESULT = BESY1(X)}
1618 @item @emph{Arguments}:
1619 @multitable @columnfractions .15 .80
1620 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1623 @item @emph{Return value}:
1624 The return value is a scalar of type @code{REAL(*)}.
1626 @item @emph{Example}:
1629 real(8) :: x = 1.0_8
1631 end program test_besy1
1634 @item @emph{Specific names}:
1635 @multitable @columnfractions .20 .20 .20 .40
1636 @item Name @tab Argument @tab Return type @tab Standard
1637 @item @code{DBESY1(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1644 @section @code{BESYN} --- Bessel function of the second kind
1645 @cindex @code{BESYN} intrinsic
1646 @cindex @code{DBESYN} intrinsic
1650 @item @emph{Description}:
1651 @code{BESYN(N, X)} computes the Bessel function of the second kind of order
1654 @item @emph{Standard}:
1660 @item @emph{Syntax}:
1661 @code{RESULT = BESYN(N, X)}
1663 @item @emph{Arguments}:
1664 @multitable @columnfractions .15 .80
1665 @item @var{N} @tab The type shall be @code{INTEGER(*)}, and it shall be scalar.
1666 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1669 @item @emph{Return value}:
1670 The return value is a scalar of type @code{REAL(*)}.
1672 @item @emph{Example}:
1675 real(8) :: x = 1.0_8
1677 end program test_besyn
1680 @item @emph{Specific names}:
1681 @multitable @columnfractions .20 .20 .20 .40
1682 @item Name @tab Argument @tab Return type @tab Standard
1683 @item @code{DBESYN(N,X)} @tab @code{INTEGER(*) N} @tab @code{REAL(8)} @tab GNU extension
1684 @item @tab @code{REAL(8) X} @tab @tab
1691 @section @code{BIT_SIZE} --- Bit size inquiry function
1692 @cindex @code{BIT_SIZE} intrinsic
1693 @cindex bit size of a variable
1694 @cindex size of a variable, in bits
1697 @item @emph{Description}:
1698 @code{BIT_SIZE(I)} returns the number of bits (integer precision plus sign bit)
1699 represented by the type of @var{I}.
1701 @item @emph{Standard}:
1707 @item @emph{Syntax}:
1708 @code{RESULT = BIT_SIZE(I)}
1710 @item @emph{Arguments}:
1711 @multitable @columnfractions .15 .80
1712 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1715 @item @emph{Return value}:
1716 The return value is of type @code{INTEGER(*)}
1718 @item @emph{Example}:
1720 program test_bit_size
1725 end program test_bit_size
1732 @section @code{BTEST} --- Bit test function
1733 @cindex @code{BTEST} intrinsic
1734 @cindex bit operations
1737 @item @emph{Description}:
1738 @code{BTEST(I,POS)} returns logical @code{.TRUE.} if the bit at @var{POS}
1741 @item @emph{Standard}:
1747 @item @emph{Syntax}:
1748 @code{RESULT = BTEST(I, POS)}
1750 @item @emph{Arguments}:
1751 @multitable @columnfractions .15 .80
1752 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1753 @item @var{POS} @tab The type shall be @code{INTEGER(*)}.
1756 @item @emph{Return value}:
1757 The return value is of type @code{LOGICAL}
1759 @item @emph{Example}:
1762 integer :: i = 32768 + 1024 + 64
1766 bool = btest(i, pos)
1769 end program test_btest
1776 @section @code{CEILING} --- Integer ceiling function
1777 @cindex @code{CEILING} intrinsic
1781 @item @emph{Description}:
1782 @code{CEILING(X)} returns the least integer greater than or equal to @var{X}.
1784 @item @emph{Standard}:
1790 @item @emph{Syntax}:
1791 @code{RESULT = CEILING(X [, KIND])}
1793 @item @emph{Arguments}:
1794 @multitable @columnfractions .15 .80
1795 @item @var{X} @tab The type shall be @code{REAL(*)}.
1796 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
1797 expression indicating the kind parameter of
1801 @item @emph{Return value}:
1802 The return value is of type @code{INTEGER(KIND)}
1804 @item @emph{Example}:
1806 program test_ceiling
1809 print *, ceiling(x) ! returns 64
1810 print *, ceiling(y) ! returns -63
1811 end program test_ceiling
1814 @item @emph{See also}:
1815 @ref{FLOOR}, @ref{NINT}
1822 @section @code{CHAR} --- Character conversion function
1823 @cindex @code{CHAR} intrinsic
1824 @cindex conversion function (character)
1827 @item @emph{Description}:
1828 @code{CHAR(I [, KIND])} returns the character represented by the integer @var{I}.
1830 @item @emph{Standard}:
1836 @item @emph{Syntax}:
1837 @code{RESULT = CHAR(I [, KIND])}
1839 @item @emph{Arguments}:
1840 @multitable @columnfractions .15 .80
1841 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1842 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
1843 expression indicating the kind parameter of
1847 @item @emph{Return value}:
1848 The return value is of type @code{CHARACTER(1)}
1850 @item @emph{Example}:
1856 print *, i, c ! returns 'J'
1857 end program test_char
1860 @item @emph{See also}:
1861 @ref{ACHAR}, @ref{IACHAR}, @ref{ICHAR}
1867 @section @code{CHDIR} --- Change working directory
1868 @cindex @code{CHDIR} intrinsic
1869 @cindex file system operations
1872 @item @emph{Description}:
1873 Change current working directory to a specified @var{PATH}.
1875 @item @emph{Standard}:
1879 Non-elemental subroutine
1881 @item @emph{Syntax}:
1882 @code{CALL CHDIR(PATH [, STATUS])}
1884 @item @emph{Arguments}:
1885 @multitable @columnfractions .15 .80
1886 @item @var{PATH} @tab The type shall be @code{CHARACTER(*)} and shall
1887 specify a valid path within the file system.
1888 @item @var{STATUS} @tab (Optional) status flag. Returns 0 on success,
1889 a system specific and non-zero error code otherwise.
1892 @item @emph{Example}:
1895 CHARACTER(len=255) :: path
1897 WRITE(*,*) TRIM(path)
1900 WRITE(*,*) TRIM(path)
1904 @item @emph{See also}:
1911 @section @code{CHMOD} --- Change access permissions of files
1912 @cindex @code{CHMOD} intrinsic
1913 @cindex file system operations
1916 @item @emph{Description}:
1917 @code{CHMOD} changes the permissions of a file. This function invokes
1918 @code{/bin/chmod} and might therefore not work on all platforms.
1920 This intrinsic is provided in both subroutine and function forms; however,
1921 only one form can be used in any given program unit.
1923 @item @emph{Standard}:
1927 Subroutine, non-elemental function
1929 @item @emph{Syntax}:
1930 @multitable @columnfractions .80
1931 @item @code{CALL CHMOD(NAME, MODE[, STATUS])}
1932 @item @code{STATUS = CHMOD(NAME, MODE)}
1935 @item @emph{Arguments}:
1936 @multitable @columnfractions .15 .80
1937 @item @var{NAME} @tab Scalar @code{CHARACTER} with the file name.
1938 Trailing blanks are ignored unless the character @code{achar(0)} is
1939 present, then all characters up to and excluding @code{achar(0)} are
1940 used as the file name.
1942 @item @var{MODE} @tab Scalar @code{CHARACTER} giving the file permission.
1943 @var{MODE} uses the same syntax as the @var{MODE} argument of
1946 @item @var{STATUS} @tab (optional) scalar @code{INTEGER}, which is
1947 @code{0} on success and non-zero otherwise.
1950 @item @emph{Return value}:
1951 In either syntax, @var{STATUS} is set to @code{0} on success and non-zero
1954 @item @emph{Example}:
1955 @code{CHMOD} as subroutine
1960 call chmod('test.dat','u+x',status)
1961 print *, 'Status: ', status
1962 end program chmod_test
1964 @code{CHMOD} as non-elemental function:
1969 status = chmod('test.dat','u+x')
1970 print *, 'Status: ', status
1971 end program chmod_test
1973 @item @emph{Specific names}:
1974 @item @emph{See also}:
1980 @section @code{CMPLX} --- Complex conversion function
1981 @cindex @code{CMPLX} intrinsic
1982 @cindex complex numbers, conversion to
1985 @item @emph{Description}:
1986 @code{CMPLX(X [, Y [, KIND]])} returns a complex number where @var{X} is converted to
1987 the real component. If @var{Y} is present it is converted to the imaginary
1988 component. If @var{Y} is not present then the imaginary component is set to
1989 0.0. If @var{X} is complex then @var{Y} must not be present.
1991 @item @emph{Standard}:
1997 @item @emph{Syntax}:
1998 @code{RESULT = CMPLX(X [, Y [, KIND]])}
2000 @item @emph{Arguments}:
2001 @multitable @columnfractions .15 .80
2002 @item @var{X} @tab The type may be @code{INTEGER(*)}, @code{REAL(*)},
2003 or @code{COMPLEX(*)}.
2004 @item @var{Y} @tab (Optional; only allowed if @var{X} is not
2005 @code{COMPLEX(*)}.) May be @code{INTEGER(*)}
2007 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
2008 expression indicating the kind parameter of
2012 @item @emph{Return value}:
2013 The return value is of type @code{COMPLEX(*)}
2015 @item @emph{Example}:
2022 print *, z, cmplx(x)
2023 end program test_cmplx
2029 @node COMMAND_ARGUMENT_COUNT
2030 @section @code{COMMAND_ARGUMENT_COUNT} --- Get number of command line arguments
2031 @cindex @code{COMMAND_ARGUMENT_COUNT} intrinsic
2032 @cindex command-line arguments, to program
2035 @item @emph{Description}:
2036 @code{COMMAND_ARGUMENT_COUNT()} returns the number of arguments passed on the
2037 command line when the containing program was invoked.
2039 @item @emph{Standard}:
2045 @item @emph{Syntax}:
2046 @code{RESULT = COMMAND_ARGUMENT_COUNT()}
2048 @item @emph{Arguments}:
2049 @multitable @columnfractions .15 .80
2053 @item @emph{Return value}:
2054 The return value is of type @code{INTEGER(4)}
2056 @item @emph{Example}:
2058 program test_command_argument_count
2060 count = command_argument_count()
2062 end program test_command_argument_count
2065 @item @emph{See also}:
2066 @ref{GET_COMMAND}, @ref{GET_COMMAND_ARGUMENT}
2070 @section @code{CONJG} --- Complex conjugate function
2071 @cindex @code{CONJG} intrinsic
2072 @cindex @code{DCONJG} intrinsic
2073 @cindex complex conjugate
2075 @item @emph{Description}:
2076 @code{CONJG(Z)} returns the conjugate of @var{Z}. If @var{Z} is @code{(x, y)}
2077 then the result is @code{(x, -y)}
2079 @item @emph{Standard}:
2080 F77 and later, has overloads that are GNU extensions
2085 @item @emph{Syntax}:
2088 @item @emph{Arguments}:
2089 @multitable @columnfractions .15 .80
2090 @item @var{Z} @tab The type shall be @code{COMPLEX(*)}.
2093 @item @emph{Return value}:
2094 The return value is of type @code{COMPLEX(*)}.
2096 @item @emph{Example}:
2099 complex :: z = (2.0, 3.0)
2100 complex(8) :: dz = (2.71_8, -3.14_8)
2105 end program test_conjg
2108 @item @emph{Specific names}:
2109 @multitable @columnfractions .20 .20 .20 .40
2110 @item Name @tab Argument @tab Return type @tab Standard
2111 @item @code{DCONJG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
2118 @section @code{COS} --- Cosine function
2119 @cindex @code{COS} intrinsic
2120 @cindex @code{DCOS} intrinsic
2121 @cindex @code{ZCOS} intrinsic
2122 @cindex @code{CDCOS} intrinsic
2123 @cindex trigonometric functions
2126 @item @emph{Description}:
2127 @code{COS(X)} computes the cosine of @var{X}.
2129 @item @emph{Standard}:
2130 F77 and later, has overloads that are GNU extensions
2135 @item @emph{Syntax}:
2136 @code{RESULT = COS(X)}
2138 @item @emph{Arguments}:
2139 @multitable @columnfractions .15 .80
2140 @item @var{X} @tab The type shall be @code{REAL(*)} or
2144 @item @emph{Return value}:
2145 The return value is of type @code{REAL(*)} and it lies in the
2146 range @math{ -1 \leq \cos (x) \leq 1}. The kind type
2147 parameter is the same as @var{X}.
2149 @item @emph{Example}:
2154 end program test_cos
2157 @item @emph{Specific names}:
2158 @multitable @columnfractions .20 .20 .20 .40
2159 @item Name @tab Argument @tab Return type @tab Standard
2160 @item @code{DCOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
2161 @item @code{CCOS(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab F77 and later
2162 @item @code{ZCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
2163 @item @code{CDCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
2166 @item @emph{See also}:
2167 Inverse function: @ref{ACOS}
2174 @section @code{COSH} --- Hyperbolic cosine function
2175 @cindex @code{COSH} intrinsic
2176 @cindex @code{DCOSH} intrinsic
2177 @cindex hyperbolic cosine
2180 @item @emph{Description}:
2181 @code{COSH(X)} computes the hyperbolic cosine of @var{X}.
2183 @item @emph{Standard}:
2189 @item @emph{Syntax}:
2192 @item @emph{Arguments}:
2193 @multitable @columnfractions .15 .80
2194 @item @var{X} @tab The type shall be @code{REAL(*)}.
2197 @item @emph{Return value}:
2198 The return value is of type @code{REAL(*)} and it is positive
2199 (@math{ \cosh (x) \geq 0 }.
2201 @item @emph{Example}:
2204 real(8) :: x = 1.0_8
2206 end program test_cosh
2209 @item @emph{Specific names}:
2210 @multitable @columnfractions .20 .20 .20 .40
2211 @item Name @tab Argument @tab Return type @tab Standard
2212 @item @code{DCOSH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
2215 @item @emph{See also}:
2216 Inverse function: @ref{ACOSH}
2223 @section @code{COUNT} --- Count function
2224 @cindex @code{COUNT} intrinsic
2228 @item @emph{Description}:
2229 @code{COUNT(MASK [, DIM])} counts the number of @code{.TRUE.} elements of
2230 @var{MASK} along the dimension of @var{DIM}. If @var{DIM} is omitted it is
2231 taken to be @code{1}. @var{DIM} is a scaler of type @code{INTEGER} in the
2232 range of @math{1 /leq DIM /leq n)} where @math{n} is the rank of @var{MASK}.
2234 @item @emph{Standard}:
2238 transformational function
2240 @item @emph{Syntax}:
2241 @code{RESULT = COUNT(MASK [, DIM])}
2243 @item @emph{Arguments}:
2244 @multitable @columnfractions .15 .80
2245 @item @var{MASK} @tab The type shall be @code{LOGICAL}.
2246 @item @var{DIM} @tab The type shall be @code{INTEGER}.
2249 @item @emph{Return value}:
2250 The return value is of type @code{INTEGER} with rank equal to that of
2253 @item @emph{Example}:
2256 integer, dimension(2,3) :: a, b
2257 logical, dimension(2,3) :: mask
2258 a = reshape( (/ 1, 2, 3, 4, 5, 6 /), (/ 2, 3 /))
2259 b = reshape( (/ 0, 7, 3, 4, 5, 8 /), (/ 2, 3 /))
2260 print '(3i3)', a(1,:)
2261 print '(3i3)', a(2,:)
2263 print '(3i3)', b(1,:)
2264 print '(3i3)', b(2,:)
2267 print '(3l3)', mask(1,:)
2268 print '(3l3)', mask(2,:)
2270 print '(3i3)', count(mask)
2272 print '(3i3)', count(mask, 1)
2274 print '(3i3)', count(mask, 2)
2275 end program test_count
2282 @section @code{CPU_TIME} --- CPU elapsed time in seconds
2283 @cindex @code{CPU_TIME} intrinsic
2284 @cindex time, elapsed
2285 @cindex elapsed time
2288 @item @emph{Description}:
2289 Returns a @code{REAL} value representing the elapsed CPU time in seconds. This
2290 is useful for testing segments of code to determine execution time.
2292 @item @emph{Standard}:
2298 @item @emph{Syntax}:
2299 @code{CALL CPU_TIME(X)}
2301 @item @emph{Arguments}:
2302 @multitable @columnfractions .15 .80
2303 @item @var{X} @tab The type shall be @code{REAL} with @code{INTENT(OUT)}.
2306 @item @emph{Return value}:
2309 @item @emph{Example}:
2311 program test_cpu_time
2312 real :: start, finish
2313 call cpu_time(start)
2314 ! put code to test here
2315 call cpu_time(finish)
2316 print '("Time = ",f6.3," seconds.")',finish-start
2317 end program test_cpu_time
2324 @section @code{CSHIFT} --- Circular shift function
2325 @cindex @code{CSHIFT} intrinsic
2326 @cindex bit operations
2329 @item @emph{Description}:
2330 @code{CSHIFT(ARRAY, SHIFT [, DIM])} performs a circular shift on elements of
2331 @var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is omitted it is
2332 taken to be @code{1}. @var{DIM} is a scaler of type @code{INTEGER} in the
2333 range of @math{1 /leq DIM /leq n)} where @math{n} is the rank of @var{ARRAY}.
2334 If the rank of @var{ARRAY} is one, then all elements of @var{ARRAY} are shifted
2335 by @var{SHIFT} places. If rank is greater than one, then all complete rank one
2336 sections of @var{ARRAY} along the given dimension are shifted. Elements
2337 shifted out one end of each rank one section are shifted back in the other end.
2339 @item @emph{Standard}:
2343 transformational function
2345 @item @emph{Syntax}:
2346 @code{RESULT = CSHIFT(A, SHIFT [, DIM])}
2348 @item @emph{Arguments}:
2349 @multitable @columnfractions .15 .80
2350 @item @var{ARRAY} @tab May be any type, not scaler.
2351 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
2352 @item @var{DIM} @tab The type shall be @code{INTEGER}.
2355 @item @emph{Return value}:
2356 Returns an array of same type and rank as the @var{ARRAY} argument.
2358 @item @emph{Example}:
2361 integer, dimension(3,3) :: a
2362 a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
2363 print '(3i3)', a(1,:)
2364 print '(3i3)', a(2,:)
2365 print '(3i3)', a(3,:)
2366 a = cshift(a, SHIFT=(/1, 2, -1/), DIM=2)
2368 print '(3i3)', a(1,:)
2369 print '(3i3)', a(2,:)
2370 print '(3i3)', a(3,:)
2371 end program test_cshift
2377 @section @code{CTIME} --- Convert a time into a string
2378 @cindex @code{CTIME} intrinsic
2379 @cindex time, conversion function
2382 @item @emph{Description}:
2383 @code{CTIME(T,S)} converts @var{T}, a system time value, such as returned
2384 by @code{TIME8()}, to a string of the form @samp{Sat Aug 19 18:13:14
2385 1995}, and returns that string into @var{S}.
2387 If @code{CTIME} is invoked as a function, it can not be invoked as a
2388 subroutine, and vice versa.
2390 @var{T} is an @code{INTENT(IN)} @code{INTEGER(KIND=8)} variable.
2391 @var{S} is an @code{INTENT(OUT)} @code{CHARACTER} variable.
2393 @item @emph{Standard}:
2399 @item @emph{Syntax}:
2400 @multitable @columnfractions .80
2401 @item @code{CALL CTIME(T,S)}.
2402 @item @code{S = CTIME(T)}, (not recommended).
2405 @item @emph{Arguments}:
2406 @multitable @columnfractions .15 .80
2407 @item @var{S}@tab The type shall be of type @code{CHARACTER}.
2408 @item @var{T}@tab The type shall be of type @code{INTEGER(KIND=8)}.
2411 @item @emph{Return value}:
2412 The converted date and time as a string.
2414 @item @emph{Example}:
2418 character(len=30) :: date
2421 ! Do something, main part of the program
2424 print *, 'Program was started on ', date
2425 end program test_ctime
2428 @item @emph{See Also}:
2429 @ref{GMTIME}, @ref{LTIME}, @ref{TIME}, @ref{TIME8}
2436 @section @code{DATE_AND_TIME} --- Date and time subroutine
2437 @cindex @code{DATE_AND_TIME} intrinsic
2438 @cindex date, current
2439 @cindex current date
2440 @cindex time, current
2441 @cindex current time
2444 @item @emph{Description}:
2445 @code{DATE_AND_TIME(DATE, TIME, ZONE, VALUES)} gets the corresponding date and
2446 time information from the real-time system clock. @var{DATE} is
2447 @code{INTENT(OUT)} and has form ccyymmdd. @var{TIME} is @code{INTENT(OUT)} and
2448 has form hhmmss.sss. @var{ZONE} is @code{INTENT(OUT)} and has form (+-)hhmm,
2449 representing the difference with respect to Coordinated Universal Time (UTC).
2450 Unavailable time and date parameters return blanks.
2452 @var{VALUES} is @code{INTENT(OUT)} and provides the following:
2454 @multitable @columnfractions .15 .30 .60
2455 @item @tab @code{VALUE(1)}: @tab The year
2456 @item @tab @code{VALUE(2)}: @tab The month
2457 @item @tab @code{VALUE(3)}: @tab The day of the month
2458 @item @tab @code{VALUE(4)}: @tab Time difference with UTC in minutes
2459 @item @tab @code{VALUE(5)}: @tab The hour of the day
2460 @item @tab @code{VALUE(6)}: @tab The minutes of the hour
2461 @item @tab @code{VALUE(7)}: @tab The seconds of the minute
2462 @item @tab @code{VALUE(8)}: @tab The milliseconds of the second
2465 @item @emph{Standard}:
2471 @item @emph{Syntax}:
2472 @code{CALL DATE_AND_TIME([DATE, TIME, ZONE, VALUES])}
2474 @item @emph{Arguments}:
2475 @multitable @columnfractions .15 .80
2476 @item @var{DATE} @tab (Optional) The type shall be @code{CHARACTER(8)} or larger.
2477 @item @var{TIME} @tab (Optional) The type shall be @code{CHARACTER(10)} or larger.
2478 @item @var{ZONE} @tab (Optional) The type shall be @code{CHARACTER(5)} or larger.
2479 @item @var{VALUES}@tab (Optional) The type shall be @code{INTEGER(8)}.
2482 @item @emph{Return value}:
2485 @item @emph{Example}:
2487 program test_time_and_date
2488 character(8) :: date
2489 character(10) :: time
2490 character(5) :: zone
2491 integer,dimension(8) :: values
2492 ! using keyword arguments
2493 call date_and_time(date,time,zone,values)
2494 call date_and_time(DATE=date,ZONE=zone)
2495 call date_and_time(TIME=time)
2496 call date_and_time(VALUES=values)
2497 print '(a,2x,a,2x,a)', date, time, zone
2498 print '(8i5))', values
2499 end program test_time_and_date
2506 @section @code{DBLE} --- Double conversion function
2507 @cindex @code{DBLE} intrinsic
2508 @cindex double conversion
2511 @item @emph{Description}:
2512 @code{DBLE(X)} Converts @var{X} to double precision real type.
2514 @item @emph{Standard}:
2520 @item @emph{Syntax}:
2521 @code{RESULT = DBLE(X)}
2523 @item @emph{Arguments}:
2524 @multitable @columnfractions .15 .80
2525 @item @var{X} @tab The type shall be @code{INTEGER(*)}, @code{REAL(*)},
2526 or @code{COMPLEX(*)}.
2529 @item @emph{Return value}:
2530 The return value is of type double precision real.
2532 @item @emph{Example}:
2537 complex :: z = (2.3,1.14)
2538 print *, dble(x), dble(i), dble(z)
2539 end program test_dble
2542 @item @emph{See also}:
2543 @ref{DFLOAT}, @ref{FLOAT}, @ref{REAL}
2549 @section @code{DCMPLX} --- Double complex conversion function
2550 @cindex @code{DCMPLX} intrinsic
2551 @cindex complex numbers, conversion to
2554 @item @emph{Description}:
2555 @code{DCMPLX(X [,Y])} returns a double complex number where @var{X} is
2556 converted to the real component. If @var{Y} is present it is converted to the
2557 imaginary component. If @var{Y} is not present then the imaginary component is
2558 set to 0.0. If @var{X} is complex then @var{Y} must not be present.
2560 @item @emph{Standard}:
2566 @item @emph{Syntax}:
2567 @code{RESULT = DCMPLX(X [, Y])}
2569 @item @emph{Arguments}:
2570 @multitable @columnfractions .15 .80
2571 @item @var{X} @tab The type may be @code{INTEGER(*)}, @code{REAL(*)},
2572 or @code{COMPLEX(*)}.
2573 @item @var{Y} @tab (Optional if @var{X} is not @code{COMPLEX(*)}.) May be
2574 @code{INTEGER(*)} or @code{REAL(*)}.
2577 @item @emph{Return value}:
2578 The return value is of type @code{COMPLEX(8)}
2580 @item @emph{Example}:
2590 print *, dcmplx(x,i)
2591 end program test_dcmplx
2598 @section @code{DFLOAT} --- Double conversion function
2599 @cindex @code{DFLOAT} intrinsic
2600 @cindex double float conversion
2603 @item @emph{Description}:
2604 @code{DFLOAT(X)} Converts @var{X} to double precision real type.
2606 @item @emph{Standard}:
2612 @item @emph{Syntax}:
2613 @code{RESULT = DFLOAT(X)}
2615 @item @emph{Arguments}:
2616 @multitable @columnfractions .15 .80
2617 @item @var{X} @tab The type shall be @code{INTEGER(*)}.
2620 @item @emph{Return value}:
2621 The return value is of type double precision real.
2623 @item @emph{Example}:
2628 end program test_dfloat
2631 @item @emph{See also}:
2632 @ref{DBLE}, @ref{FLOAT}, @ref{REAL}
2638 @section @code{DIGITS} --- Significant digits function
2639 @cindex @code{DIGITS} intrinsic
2640 @cindex digits, significant
2643 @item @emph{Description}:
2644 @code{DIGITS(X)} returns the number of significant digits of the internal model
2645 representation of @var{X}. For example, on a system using a 32-bit
2646 floating point representation, a default real number would likely return 24.
2648 @item @emph{Standard}:
2654 @item @emph{Syntax}:
2655 @code{RESULT = DIGITS(X)}
2657 @item @emph{Arguments}:
2658 @multitable @columnfractions .15 .80
2659 @item @var{X} @tab The type may be @code{INTEGER(*)} or @code{REAL(*)}.
2662 @item @emph{Return value}:
2663 The return value is of type @code{INTEGER}.
2665 @item @emph{Example}:
2668 integer :: i = 12345
2674 end program test_digits
2681 @section @code{DIM} --- Dim function
2682 @cindex @code{DIM} intrinsic
2683 @cindex @code{IDIM} intrinsic
2684 @cindex @code{DDIM} intrinsic
2688 @item @emph{Description}:
2689 @code{DIM(X,Y)} returns the difference @code{X-Y} if the result is positive;
2690 otherwise returns zero.
2692 @item @emph{Standard}:
2698 @item @emph{Syntax}:
2699 @code{RESULT = DIM(X, Y)}
2701 @item @emph{Arguments}:
2702 @multitable @columnfractions .15 .80
2703 @item @var{X} @tab The type shall be @code{INTEGER(*)} or @code{REAL(*)}
2704 @item @var{Y} @tab The type shall be the same type and kind as @var{X}.
2707 @item @emph{Return value}:
2708 The return value is of type @code{INTEGER(*)} or @code{REAL(*)}.
2710 @item @emph{Example}:
2716 x = dim(4.345_8, 2.111_8)
2719 end program test_dim
2722 @item @emph{Specific names}:
2723 @multitable @columnfractions .20 .20 .20 .40
2724 @item Name @tab Argument @tab Return type @tab Standard
2725 @item @code{IDIM(X,Y)} @tab @code{INTEGER(4) X,Y} @tab @code{INTEGER(4)} @tab F77 and later
2726 @item @code{DDIM(X,Y)} @tab @code{REAL(8) X,Y} @tab @code{REAL(8)} @tab F77 and later
2733 @section @code{DOT_PRODUCT} --- Dot product function
2734 @cindex @code{DOT_PRODUCT} intrinsic
2738 @item @emph{Description}:
2739 @code{DOT_PRODUCT(X,Y)} computes the dot product multiplication of two vectors
2740 @var{X} and @var{Y}. The two vectors may be either numeric or logical
2741 and must be arrays of rank one and of equal size. If the vectors are
2742 @code{INTEGER(*)} or @code{REAL(*)}, the result is @code{SUM(X*Y)}. If the
2743 vectors are @code{COMPLEX(*)}, the result is @code{SUM(CONJG(X)*Y)}. If the
2744 vectors are @code{LOGICAL}, the result is @code{ANY(X.AND.Y)}.
2746 @item @emph{Standard}:
2750 transformational function
2752 @item @emph{Syntax}:
2753 @code{RESULT = DOT_PRODUCT(X, Y)}
2755 @item @emph{Arguments}:
2756 @multitable @columnfractions .15 .80
2757 @item @var{X} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
2758 @item @var{Y} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
2761 @item @emph{Return value}:
2762 If the arguments are numeric, the return value is a scaler of numeric type,
2763 @code{INTEGER(*)}, @code{REAL(*)}, or @code{COMPLEX(*)}. If the arguments are
2764 @code{LOGICAL}, the return value is @code{.TRUE.} or @code{.FALSE.}.
2766 @item @emph{Example}:
2768 program test_dot_prod
2769 integer, dimension(3) :: a, b
2776 print *, dot_product(a,b)
2777 end program test_dot_prod
2784 @section @code{DPROD} --- Double product function
2785 @cindex @code{DPROD} intrinsic
2786 @cindex double-precision product
2789 @item @emph{Description}:
2790 @code{DPROD(X,Y)} returns the product @code{X*Y}.
2792 @item @emph{Standard}:
2798 @item @emph{Syntax}:
2799 @code{RESULT = DPROD(X, Y)}
2801 @item @emph{Arguments}:
2802 @multitable @columnfractions .15 .80
2803 @item @var{X} @tab The type shall be @code{REAL}.
2804 @item @var{Y} @tab The type shall be @code{REAL}.
2807 @item @emph{Return value}:
2808 The return value is of type @code{REAL(8)}.
2810 @item @emph{Example}:
2819 end program test_dprod
2826 @section @code{DREAL} --- Double real part function
2827 @cindex @code{DREAL} intrinsic
2828 @cindex double-precision real part
2831 @item @emph{Description}:
2832 @code{DREAL(Z)} returns the real part of complex variable @var{Z}.
2834 @item @emph{Standard}:
2840 @item @emph{Syntax}:
2841 @code{RESULT = DREAL(Z)}
2843 @item @emph{Arguments}:
2844 @multitable @columnfractions .15 .80
2845 @item @var{Z} @tab The type shall be @code{COMPLEX(8)}.
2848 @item @emph{Return value}:
2849 The return value is of type @code{REAL(8)}.
2851 @item @emph{Example}:
2854 complex(8) :: z = (1.3_8,7.2_8)
2856 end program test_dreal
2859 @item @emph{See also}:
2867 @section @code{DTIME} --- Execution time subroutine (or function)
2868 @cindex @code{DTIME} intrinsic
2869 @cindex time, elapsed
2870 @cindex elapsed time
2873 @item @emph{Description}:
2874 @code{DTIME(TARRAY, RESULT)} initially returns the number of seconds of runtime
2875 since the start of the process's execution in @var{RESULT}. @var{TARRAY}
2876 returns the user and system components of this time in @code{TARRAY(1)} and
2877 @code{TARRAY(2)} respectively. @var{RESULT} is equal to @code{TARRAY(1) +
2880 Subsequent invocations of @code{DTIME} return values accumulated since the
2881 previous invocation.
2883 On some systems, the underlying timings are represented using types with
2884 sufficiently small limits that overflows (wrap around) are possible, such as
2885 32-bit types. Therefore, the values returned by this intrinsic might be, or
2886 become, negative, or numerically less than previous values, during a single
2887 run of the compiled program.
2889 If @code{DTIME} is invoked as a function, it can not be invoked as a
2890 subroutine, and vice versa.
2892 @var{TARRAY} and @var{RESULT} are @code{INTENT(OUT)} and provide the following:
2894 @multitable @columnfractions .15 .30 .60
2895 @item @tab @code{TARRAY(1)}: @tab User time in seconds.
2896 @item @tab @code{TARRAY(2)}: @tab System time in seconds.
2897 @item @tab @code{RESULT}: @tab Run time since start in seconds.
2900 @item @emph{Standard}:
2906 @item @emph{Syntax}:
2907 @multitable @columnfractions .80
2908 @item @code{CALL DTIME(TARRAY, RESULT)}.
2909 @item @code{RESULT = DTIME(TARRAY)}, (not recommended).
2912 @item @emph{Arguments}:
2913 @multitable @columnfractions .15 .80
2914 @item @var{TARRAY}@tab The type shall be @code{REAL, DIMENSION(2)}.
2915 @item @var{RESULT}@tab The type shall be @code{REAL}.
2918 @item @emph{Return value}:
2919 Elapsed time in seconds since the start of program execution.
2921 @item @emph{Example}:
2925 real, dimension(2) :: tarray
2927 call dtime(tarray, result)
2931 do i=1,100000000 ! Just a delay
2934 call dtime(tarray, result)
2938 end program test_dtime
2945 @section @code{EOSHIFT} --- End-off shift function
2946 @cindex @code{EOSHIFT} intrinsic
2947 @cindex bit operations
2950 @item @emph{Description}:
2951 @code{EOSHIFT(ARRAY, SHIFT[,BOUNDARY, DIM])} performs an end-off shift on
2952 elements of @var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is
2953 omitted it is taken to be @code{1}. @var{DIM} is a scaler of type
2954 @code{INTEGER} in the range of @math{1 /leq DIM /leq n)} where @math{n} is the
2955 rank of @var{ARRAY}. If the rank of @var{ARRAY} is one, then all elements of
2956 @var{ARRAY} are shifted by @var{SHIFT} places. If rank is greater than one,
2957 then all complete rank one sections of @var{ARRAY} along the given dimension are
2958 shifted. Elements shifted out one end of each rank one section are dropped. If
2959 @var{BOUNDARY} is present then the corresponding value of from @var{BOUNDARY}
2960 is copied back in the other end. If @var{BOUNDARY} is not present then the
2961 following are copied in depending on the type of @var{ARRAY}.
2963 @multitable @columnfractions .15 .80
2964 @item @emph{Array Type} @tab @emph{Boundary Value}
2965 @item Numeric @tab 0 of the type and kind of @var{ARRAY}.
2966 @item Logical @tab @code{.FALSE.}.
2967 @item Character(@var{len}) @tab @var{len} blanks.
2970 @item @emph{Standard}:
2974 transformational function
2976 @item @emph{Syntax}:
2977 @code{RESULT = EOSHIFT(A, SHIFT [, BOUNDARY, DIM])}
2979 @item @emph{Arguments}:
2980 @multitable @columnfractions .15 .80
2981 @item @var{ARRAY} @tab May be any type, not scaler.
2982 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
2983 @item @var{BOUNDARY} @tab Same type as @var{ARRAY}.
2984 @item @var{DIM} @tab The type shall be @code{INTEGER}.
2987 @item @emph{Return value}:
2988 Returns an array of same type and rank as the @var{ARRAY} argument.
2990 @item @emph{Example}:
2992 program test_eoshift
2993 integer, dimension(3,3) :: a
2994 a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
2995 print '(3i3)', a(1,:)
2996 print '(3i3)', a(2,:)
2997 print '(3i3)', a(3,:)
2998 a = EOSHIFT(a, SHIFT=(/1, 2, 1/), BOUNDARY=-5, DIM=2)
3000 print '(3i3)', a(1,:)
3001 print '(3i3)', a(2,:)
3002 print '(3i3)', a(3,:)
3003 end program test_eoshift
3010 @section @code{EPSILON} --- Epsilon function
3011 @cindex @code{EPSILON} intrinsic
3012 @cindex epsilon, significant
3015 @item @emph{Description}:
3016 @code{EPSILON(X)} returns a nearly negligible number relative to @code{1}.
3018 @item @emph{Standard}:
3024 @item @emph{Syntax}:
3025 @code{RESULT = EPSILON(X)}
3027 @item @emph{Arguments}:
3028 @multitable @columnfractions .15 .80
3029 @item @var{X} @tab The type shall be @code{REAL(*)}.
3032 @item @emph{Return value}:
3033 The return value is of same type as the argument.
3035 @item @emph{Example}:
3037 program test_epsilon
3042 end program test_epsilon
3049 @section @code{ERF} --- Error function
3050 @cindex @code{ERF} intrinsic
3051 @cindex error function
3054 @item @emph{Description}:
3055 @code{ERF(X)} computes the error function of @var{X}.
3057 @item @emph{Standard}:
3063 @item @emph{Syntax}:
3064 @code{RESULT = ERF(X)}
3066 @item @emph{Arguments}:
3067 @multitable @columnfractions .15 .80
3068 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
3071 @item @emph{Return value}:
3072 The return value is a scalar of type @code{REAL(*)} and it is positive
3073 (@math{ - 1 \leq erf (x) \leq 1 }.
3075 @item @emph{Example}:
3078 real(8) :: x = 0.17_8
3080 end program test_erf
3083 @item @emph{Specific names}:
3084 @multitable @columnfractions .20 .20 .20 .40
3085 @item Name @tab Argument @tab Return type @tab Standard
3086 @item @code{DERF(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
3093 @section @code{ERFC} --- Error function
3094 @cindex @code{ERFC} intrinsic
3095 @cindex error function
3098 @item @emph{Description}:
3099 @code{ERFC(X)} computes the complementary error function of @var{X}.
3101 @item @emph{Standard}:
3107 @item @emph{Syntax}:
3108 @code{RESULT = ERFC(X)}
3110 @item @emph{Arguments}:
3111 @multitable @columnfractions .15 .80
3112 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
3115 @item @emph{Return value}:
3116 The return value is a scalar of type @code{REAL(*)} and it is positive
3117 (@math{ 0 \leq erfc (x) \leq 2 }.
3119 @item @emph{Example}:
3122 real(8) :: x = 0.17_8
3124 end program test_erfc
3127 @item @emph{Specific names}:
3128 @multitable @columnfractions .20 .20 .20 .40
3129 @item Name @tab Argument @tab Return type @tab Standard
3130 @item @code{DERFC(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
3137 @section @code{ETIME} --- Execution time subroutine (or function)
3138 @cindex @code{ETIME} intrinsic
3139 @cindex time, elapsed
3142 @item @emph{Description}:
3143 @code{ETIME(TARRAY, RESULT)} returns the number of seconds of runtime
3144 since the start of the process's execution in @var{RESULT}. @var{TARRAY}
3145 returns the user and system components of this time in @code{TARRAY(1)} and
3146 @code{TARRAY(2)} respectively. @var{RESULT} is equal to @code{TARRAY(1) + TARRAY(2)}.
3148 On some systems, the underlying timings are represented using types with
3149 sufficiently small limits that overflows (wrap around) are possible, such as
3150 32-bit types. Therefore, the values returned by this intrinsic might be, or
3151 become, negative, or numerically less than previous values, during a single
3152 run of the compiled program.
3154 If @code{ETIME} is invoked as a function, it can not be invoked as a
3155 subroutine, and vice versa.
3157 @var{TARRAY} and @var{RESULT} are @code{INTENT(OUT)} and provide the following:
3159 @multitable @columnfractions .15 .30 .60
3160 @item @tab @code{TARRAY(1)}: @tab User time in seconds.
3161 @item @tab @code{TARRAY(2)}: @tab System time in seconds.
3162 @item @tab @code{RESULT}: @tab Run time since start in seconds.
3165 @item @emph{Standard}:
3171 @item @emph{Syntax}:
3172 @multitable @columnfractions .8
3173 @item @code{CALL ETIME(TARRAY, RESULT)}.
3174 @item @code{RESULT = ETIME(TARRAY)}, (not recommended).
3177 @item @emph{Arguments}:
3178 @multitable @columnfractions .15 .80
3179 @item @var{TARRAY}@tab The type shall be @code{REAL, DIMENSION(2)}.
3180 @item @var{RESULT}@tab The type shall be @code{REAL}.
3183 @item @emph{Return value}:
3184 Elapsed time in seconds since the start of program execution.
3186 @item @emph{Example}:
3190 real, dimension(2) :: tarray
3192 call ETIME(tarray, result)
3196 do i=1,100000000 ! Just a delay
3199 call ETIME(tarray, result)
3203 end program test_etime
3206 @item @emph{See also}:
3214 @section @code{EXIT} --- Exit the program with status.
3215 @cindex @code{EXIT} intrinsic
3216 @cindex exit program
3219 @item @emph{Description}:
3220 @code{EXIT} causes immediate termination of the program with status. If status
3221 is omitted it returns the canonical @emph{success} for the system. All Fortran
3222 I/O units are closed.
3224 @item @emph{Standard}:
3230 @item @emph{Syntax}:
3231 @code{CALL EXIT([STATUS])}
3233 @item @emph{Arguments}:
3234 @multitable @columnfractions .15 .80
3235 @item @var{STATUS} @tab The type of the argument shall be @code{INTEGER(*)}.
3238 @item @emph{Return value}:
3239 @code{STATUS} is passed to the parent process on exit.
3241 @item @emph{Example}:
3244 integer :: STATUS = 0
3245 print *, 'This program is going to exit.'
3247 end program test_exit
3250 @item @emph{See also}:
3251 @ref{ABORT}, @ref{KILL}
3257 @section @code{EXP} --- Exponential function
3258 @cindex @code{EXP} intrinsic
3259 @cindex @code{DEXP} intrinsic
3260 @cindex @code{ZEXP} intrinsic
3261 @cindex @code{CDEXP} intrinsic
3265 @item @emph{Description}:
3266 @code{EXP(X)} computes the base @math{e} exponential of @var{X}.
3268 @item @emph{Standard}:
3269 F77 and later, has overloads that are GNU extensions
3274 @item @emph{Syntax}:
3275 @code{RESULT = EXP(X)}
3277 @item @emph{Arguments}:
3278 @multitable @columnfractions .15 .80
3279 @item @var{X} @tab The type shall be @code{REAL(*)} or
3283 @item @emph{Return value}:
3284 The return value has same type and kind as @var{X}.
3286 @item @emph{Example}:
3291 end program test_exp
3294 @item @emph{Specific names}:
3295 @multitable @columnfractions .20 .20 .20 .40
3296 @item Name @tab Argument @tab Return type @tab Standard
3297 @item @code{DEXP(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
3298 @item @code{CEXP(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab F77 and later
3299 @item @code{ZEXP(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
3300 @item @code{CDEXP(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
3307 @section @code{EXPONENT} --- Exponent function
3308 @cindex @code{EXPONENT} intrinsic
3309 @cindex exponent part of a real number
3312 @item @emph{Description}:
3313 @code{EXPONENT(X)} returns the value of the exponent part of @var{X}. If @var{X}
3314 is zero the value returned is zero.
3316 @item @emph{Standard}:
3322 @item @emph{Syntax}:
3323 @code{RESULT = EXPONENT(X)}
3325 @item @emph{Arguments}:
3326 @multitable @columnfractions .15 .80
3327 @item @var{X} @tab The type shall be @code{REAL(*)}.
3330 @item @emph{Return value}:
3331 The return value is of type default @code{INTEGER}.
3333 @item @emph{Example}:
3335 program test_exponent
3340 print *, exponent(0.0)
3341 end program test_exponent
3347 @section @code{FDATE} --- Get the current time as a string
3348 @cindex @code{FDATE} intrinsic
3349 @cindex time, current
3350 @cindex current time
3351 @cindex date, current
3352 @cindex current date
3355 @item @emph{Description}:
3356 @code{FDATE(DATE)} returns the current date (using the same format as
3357 @code{CTIME}) in @var{DATE}. It is equivalent to @code{CALL CTIME(DATE,
3360 If @code{FDATE} is invoked as a function, it can not be invoked as a
3361 subroutine, and vice versa.
3363 @var{DATE} is an @code{INTENT(OUT)} @code{CHARACTER} variable.
3365 @item @emph{Standard}:
3371 @item @emph{Syntax}:
3372 @multitable @columnfractions .80
3373 @item @code{CALL FDATE(DATE)}.
3374 @item @code{DATE = FDATE()}, (not recommended).
3377 @item @emph{Arguments}:
3378 @multitable @columnfractions .15 .80
3379 @item @var{DATE}@tab The type shall be of type @code{CHARACTER}.
3382 @item @emph{Return value}:
3383 The current date as a string.
3385 @item @emph{Example}:
3389 character(len=30) :: date
3391 print *, 'Program started on ', date
3392 do i = 1, 100000000 ! Just a delay
3396 print *, 'Program ended on ', date
3397 end program test_fdate
3403 @section @code{FLOAT} --- Convert integer to default real
3404 @cindex @code{FLOAT} intrinsic
3405 @cindex conversion function (float)
3408 @item @emph{Description}:
3409 @code{FLOAT(I)} converts the integer @var{I} to a default real value.
3411 @item @emph{Standard}:
3417 @item @emph{Syntax}:
3418 @code{RESULT = FLOAT(I)}
3420 @item @emph{Arguments}:
3421 @multitable @columnfractions .15 .80
3422 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
3425 @item @emph{Return value}:
3426 The return value is of type default @code{REAL}.
3428 @item @emph{Example}:
3432 if (float(i) /= 1.) call abort
3433 end program test_float
3436 @item @emph{See also}:
3437 @ref{DBLE}, @ref{DFLOAT}, @ref{REAL}
3443 @section @code{FGET} --- Read a single character in stream mode from stdin
3444 @cindex @code{FGET} intrinsic
3445 @cindex file operations
3446 @cindex stream operations
3449 @item @emph{Description}:
3450 Read a single character in stream mode from stdin by bypassing normal
3451 formatted output. Stream I/O should not be mixed with normal record-oriented
3452 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
3454 This intrinsic routine is provided for backwards compatibility with
3455 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
3456 Programmers should consider the use of new stream IO feature in new code
3457 for future portability. See also @ref{Fortran 2003 status}.
3459 @item @emph{Standard}:
3463 Non-elemental subroutine
3465 @item @emph{Syntax}:
3466 @code{CALL FGET(C [, STATUS])}
3468 @item @emph{Arguments}:
3469 @multitable @columnfractions .15 .80
3470 @item @var{C} @tab The type shall be @code{CHARACTER}.
3471 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
3472 Returns 0 on success, -1 on end-of-file, and a
3473 system specific positive error code otherwise.
3476 @item @emph{Example}:
3479 INTEGER, PARAMETER :: strlen = 100
3480 INTEGER :: status, i = 1
3481 CHARACTER(len=strlen) :: str = ""
3483 WRITE (*,*) 'Enter text:'
3485 CALL fget(str(i:i), status)
3486 if (status /= 0 .OR. i > strlen) exit
3489 WRITE (*,*) TRIM(str)
3493 @item @emph{See also}:
3494 @ref{FGETC}, @ref{FPUT}, @ref{FPUTC}
3499 @section @code{FGETC} --- Read a single character in stream mode
3500 @cindex @code{FGETC} intrinsic
3501 @cindex file operations
3502 @cindex stream operations
3505 @item @emph{Description}:
3506 Read a single character in stream mode by bypassing normal formatted output.
3507 Stream I/O should not be mixed with normal record-oriented (formatted or
3508 unformatted) I/O on the same unit; the results are unpredictable.
3510 This intrinsic routine is provided for backwards compatibility with
3511 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
3512 Programmers should consider the use of new stream IO feature in new code
3513 for future portability. See also @ref{Fortran 2003 status}.
3515 @item @emph{Standard}:
3519 Non-elemental subroutine
3521 @item @emph{Syntax}:
3522 @code{CALL FGETC(UNIT, C [, STATUS])}
3524 @item @emph{Arguments}:
3525 @multitable @columnfractions .15 .80
3526 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
3527 @item @var{C} @tab The type shall be @code{CHARACTER}.
3528 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. Returns 0 on success,
3529 -1 on end-of-file and a system specific positive error code otherwise.
3532 @item @emph{Example}:
3535 INTEGER :: fd = 42, status
3538 OPEN(UNIT=fd, FILE="/etc/passwd", ACTION="READ", STATUS = "OLD")
3540 CALL fgetc(fd, c, status)
3541 IF (status /= 0) EXIT
3548 @item @emph{See also}:
3549 @ref{FGET}, @ref{FPUT}, @ref{FPUTC}
3555 @section @code{FLOOR} --- Integer floor function
3556 @cindex @code{FLOOR} intrinsic
3560 @item @emph{Description}:
3561 @code{FLOOR(X)} returns the greatest integer less than or equal to @var{X}.
3563 @item @emph{Standard}:
3569 @item @emph{Syntax}:
3570 @code{RESULT = FLOOR(X [, KIND])}
3572 @item @emph{Arguments}:
3573 @multitable @columnfractions .15 .80
3574 @item @var{X} @tab The type shall be @code{REAL(*)}.
3575 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
3576 expression indicating the kind parameter of
3580 @item @emph{Return value}:
3581 The return value is of type @code{INTEGER(KIND)}
3583 @item @emph{Example}:
3588 print *, floor(x) ! returns 63
3589 print *, floor(y) ! returns -64
3590 end program test_floor
3593 @item @emph{See also}:
3594 @ref{CEILING}, @ref{NINT}
3601 @section @code{FLUSH} --- Flush I/O unit(s)
3602 @cindex @code{FLUSH} intrinsic
3603 @cindex flush output files
3606 @item @emph{Description}:
3607 Flushes Fortran unit(s) currently open for output. Without the optional
3608 argument, all units are flushed, otherwise just the unit specified.
3610 @item @emph{Standard}:
3614 non-elemental subroutine
3616 @item @emph{Syntax}:
3617 @code{CALL FLUSH(UNIT)}
3619 @item @emph{Arguments}:
3620 @multitable @columnfractions .15 .80
3621 @item @var{UNIT} @tab (Optional) The type shall be @code{INTEGER}.
3625 Beginning with the Fortran 2003 standard, there is a @code{FLUSH}
3626 statement that should be preferred over the @code{FLUSH} intrinsic.
3633 @section @code{FNUM} --- File number function
3634 @cindex @code{FNUM} intrinsic
3638 @item @emph{Description}:
3639 @code{FNUM(UNIT)} returns the POSIX file descriptor number corresponding to the
3640 open Fortran I/O unit @code{UNIT}.
3642 @item @emph{Standard}:
3646 non-elemental function
3648 @item @emph{Syntax}:
3649 @code{RESULT = FNUM(UNIT)}
3651 @item @emph{Arguments}:
3652 @multitable @columnfractions .15 .80
3653 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
3656 @item @emph{Return value}:
3657 The return value is of type @code{INTEGER}
3659 @item @emph{Example}:
3663 open (unit=10, status = "scratch")
3667 end program test_fnum
3674 @section @code{FPUT} --- Write a single character in stream mode to stdout
3675 @cindex @code{FPUT} intrinsic
3676 @cindex file operations
3677 @cindex stream operations
3680 @item @emph{Description}:
3681 Write a single character in stream mode to stdout by bypassing normal
3682 formatted output. Stream I/O should not be mixed with normal record-oriented
3683 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
3685 This intrinsic routine is provided for backwards compatibility with
3686 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
3687 Programmers should consider the use of new stream IO feature in new code
3688 for future portability. See also @ref{Fortran 2003 status}.
3690 @item @emph{Standard}:
3694 Non-elemental subroutine
3696 @item @emph{Syntax}:
3697 @code{CALL FPUT(C [, STATUS])}
3699 @item @emph{Arguments}:
3700 @multitable @columnfractions .15 .80
3701 @item @var{C} @tab The type shall be @code{CHARACTER}.
3702 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. Returns 0 on success,
3703 -1 on end-of-file and a system specific positive error code otherwise.
3706 @item @emph{Example}:
3709 CHARACTER(len=*) :: str = "gfortran"
3711 DO i = 1, len_trim(str)
3717 @item @emph{See also}:
3718 @ref{FPUTC}, @ref{FGET}, @ref{FGETC}
3724 @section @code{FPUTC} --- Write a single character in stream mode
3725 @cindex @code{FPUTC} intrinsic
3726 @cindex file operations
3727 @cindex stream operations
3730 @item @emph{Description}:
3731 Write a single character in stream mode by bypassing normal formatted
3732 output. Stream I/O should not be mixed with normal record-oriented
3733 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
3735 This intrinsic routine is provided for backwards compatibility with
3736 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
3737 Programmers should consider the use of new stream IO feature in new code
3738 for future portability. See also @ref{Fortran 2003 status}.
3740 @item @emph{Standard}:
3744 Non-elemental subroutine
3746 @item @emph{Syntax}:
3747 @code{CALL FPUTC(UNIT, C [, STATUS])}
3749 @item @emph{Arguments}:
3750 @multitable @columnfractions .15 .80
3751 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
3752 @item @var{C} @tab The type shall be @code{CHARACTER}.
3753 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. Returns 0 on success,
3754 -1 on end-of-file and a system specific positive error code otherwise.
3757 @item @emph{Example}:
3760 CHARACTER(len=*) :: str = "gfortran"
3761 INTEGER :: fd = 42, i
3763 OPEN(UNIT = fd, FILE = "out", ACTION = "WRITE", STATUS="NEW")
3764 DO i = 1, len_trim(str)
3765 CALL fputc(fd, str(i:i))
3771 @item @emph{See also}:
3772 @ref{FPUT}, @ref{FGET}, @ref{FGETC}
3778 @section @code{FRACTION} --- Fractional part of the model representation
3779 @cindex @code{FRACTION} intrinsic
3780 @cindex fractional part
3783 @item @emph{Description}:
3784 @code{FRACTION(X)} returns the fractional part of the model
3785 representation of @code{X}.
3787 @item @emph{Standard}:
3793 @item @emph{Syntax}:
3794 @code{Y = FRACTION(X)}
3796 @item @emph{Arguments}:
3797 @multitable @columnfractions .15 .80
3798 @item @var{X} @tab The type of the argument shall be a @code{REAL}.
3801 @item @emph{Return value}:
3802 The return value is of the same type and kind as the argument.
3803 The fractional part of the model representation of @code{X} is returned;
3804 it is @code{X * RADIX(X)**(-EXPONENT(X))}.
3806 @item @emph{Example}:
3808 program test_fraction
3811 print *, fraction(x), x * radix(x)**(-exponent(x))
3812 end program test_fraction
3820 @section @code{FREE} --- Frees memory
3821 @cindex @code{FREE} intrinsic
3822 @cindex Cray pointers
3825 @item @emph{Description}:
3826 Frees memory previously allocated by @code{MALLOC()}. The @code{FREE}
3827 intrinsic is an extension intended to be used with Cray pointers, and is
3828 provided in GNU Fortran to allow user to compile legacy code. For
3829 new code using Fortran 95 pointers, the memory de-allocation intrinsic is
3832 @item @emph{Standard}:
3838 @item @emph{Syntax}:
3841 @item @emph{Arguments}:
3842 @multitable @columnfractions .15 .80
3843 @item @var{PTR} @tab The type shall be @code{INTEGER}. It represents the
3844 location of the memory that should be de-allocated.
3847 @item @emph{Return value}:
3850 @item @emph{Example}:
3851 See @code{MALLOC} for an example.
3853 @item @emph{See also}:
3861 @section @code{FSTAT} --- Get file status
3862 @cindex @code{FSTAT} intrinsic
3863 @cindex file system operations
3866 @item @emph{Description}:
3867 @code{FSTAT} is identical to @ref{STAT}, except that information about an
3868 already opened file is obtained.
3870 The elements in @code{BUFF} are the same as described by @ref{STAT}.
3872 @item @emph{Standard}:
3876 Non-elemental subroutine
3878 @item @emph{Syntax}:
3879 @code{CALL FSTAT(UNIT, BUFF [, STATUS])}
3881 @item @emph{Arguments}:
3882 @multitable @columnfractions .15 .80
3883 @item @var{UNIT} @tab An open I/O unit number of type @code{INTEGER}.
3884 @item @var{BUFF} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
3885 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0
3886 on success and a system specific error code otherwise.
3889 @item @emph{Example}:
3890 See @ref{STAT} for an example.
3892 @item @emph{See also}:
3893 To stat a link: @ref{LSTAT}, to stat a file: @ref{STAT}
3899 @section @code{FSEEK} --- Low level file positioning subroutine
3900 @cindex @code{FSEEK} intrinsic
3901 @cindex file system operations
3903 Not yet implemented in GNU Fortran.
3906 @item @emph{Description}:
3908 @item @emph{Standard}:
3914 @item @emph{Syntax}:
3915 @item @emph{Arguments}:
3916 @item @emph{Return value}:
3917 @item @emph{Example}:
3918 @item @emph{Specific names}:
3919 @item @emph{See also}:
3920 @uref{http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19292, g77 features lacking in gfortran}
3927 @section @code{FTELL} --- Current stream position
3928 @cindex @code{FTELL} intrinsic
3931 @item @emph{Description}:
3932 Retrieves the current position within an open file.
3934 This intrinsic is provided in both subroutine and function forms; however,
3935 only one form can be used in any given program unit.
3937 @item @emph{Standard}:
3941 Subroutine, function
3943 @item @emph{Syntax}:
3944 @multitable @columnfractions .80
3945 @item @code{CALL FTELL(UNIT, OFFSET)}
3946 @item @code{OFFSET = FTELL(UNIT)}
3949 @item @emph{Arguments}:
3950 @multitable @columnfractions .15 .80
3951 @item @var{OFFSET} @tab Shall of type @code{INTEGER}.
3952 @item @var{UNIT} @tab Shall of type @code{INTEGER}.
3955 @item @emph{Return value}:
3956 In either syntax, @var{OFFSET} is set to the current offset of unit
3957 number @var{UNIT}, or to @math{-1} if the unit is not currently open.
3959 @item @emph{Example}:
3963 OPEN(10, FILE="temp.dat")
3969 @item @emph{See also}:
3976 @section @code{GETARG} --- Get command line arguments
3977 @cindex @code{GETARG} intrinsic
3978 @cindex command-line arguments, to program
3981 @item @emph{Description}:
3982 Retrieve the @var{N}th argument that was passed on the
3983 command line when the containing program was invoked.
3985 This intrinsic routine is provided for backwards compatibility with
3986 GNU Fortran 77. In new code, programmers should consider the use of
3987 the @ref{GET_COMMAND_ARGUMENT} intrinsic defined by the Fortran 2003
3990 @item @emph{Standard}:
3996 @item @emph{Syntax}:
3997 @code{CALL GETARG(N, ARG)}
3999 @item @emph{Arguments}:
4000 @multitable @columnfractions .15 .80
4001 @item @var{N} @tab Shall of type @code{INTEGER(4)}, @math{@var{N} \geq 0}
4002 @item @var{ARG} @tab Shall be of type @code{CHARACTER(*)}.
4005 @item @emph{Return value}:
4006 After @code{GETARG} returns, the @var{ARG} argument holds the @var{N}th
4007 command line argument. If @var{ARG} can not hold the argument, it is
4008 truncated to fit the length of @var{ARG}. If there are less than @var{N}
4009 arguments specified at the command line, @var{ARG} will be filled with blanks.
4010 If @math{@var{N} = 0}, @var{ARG} is set to the name of the program (on systems
4011 that support this feature).
4013 @item @emph{Example}:
4017 CHARACTER(len=32) :: arg
4026 @item @emph{See also}:
4027 GNU Fortran 77 compatibility function: @ref{IARGC}
4029 F2003 functions and subroutines: @ref{GET_COMMAND}, @ref{GET_COMMAND_ARGUMENT},
4030 @ref{COMMAND_ARGUMENT_COUNT}
4036 @section @code{GET_COMMAND} --- Get the entire command line
4037 @cindex @code{GET_COMMAND} intrinsic
4038 @cindex command-line arguments, to program
4041 @item @emph{Description}:
4042 Retrieve the entire command line that was used to invoke the program.
4044 @item @emph{Standard}:
4050 @item @emph{Syntax}:
4051 @code{CALL GET_COMMAND(CMD)}
4053 @item @emph{Arguments}:
4054 @multitable @columnfractions .15 .80
4055 @item @var{CMD} @tab Shall be of type @code{CHARACTER(*)}.
4058 @item @emph{Return value}:
4059 Stores the entire command line that was used to invoke the program in @var{ARG}.
4060 If @var{ARG} is not large enough, the command will be truncated.
4062 @item @emph{Example}:
4064 PROGRAM test_get_command
4065 CHARACTER(len=255) :: cmd
4066 CALL get_command(cmd)
4067 WRITE (*,*) TRIM(cmd)
4071 @item @emph{See also}:
4072 @ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
4077 @node GET_COMMAND_ARGUMENT
4078 @section @code{GET_COMMAND_ARGUMENT} --- Get command line arguments
4079 @cindex @code{GET_COMMAND_ARGUMENT} intrinsic
4080 @cindex command-line arguments, to program
4083 @item @emph{Description}:
4084 Retrieve the @var{N}th argument that was passed on the
4085 command line when the containing program was invoked.
4087 @item @emph{Standard}:
4093 @item @emph{Syntax}:
4094 @code{CALL GET_COMMAND_ARGUMENT(N, ARG)}
4096 @item @emph{Arguments}:
4097 @multitable @columnfractions .15 .80
4098 @item @var{N} @tab Shall of type @code{INTEGER(4)}, @math{@var{N} \geq 0}
4099 @item @var{ARG} @tab Shall be of type @code{CHARACTER(*)}.
4102 @item @emph{Return value}:
4103 After @code{GET_COMMAND_ARGUMENT} returns, the @var{ARG} argument holds the
4104 @var{N}th command line argument. If @var{ARG} can not hold the argument, it is
4105 truncated to fit the length of @var{ARG}. If there are less than @var{N}
4106 arguments specified at the command line, @var{ARG} will be filled with blanks.
4107 If @math{@var{N} = 0}, @var{ARG} is set to the name of the program (on systems
4108 that support this feature).
4110 @item @emph{Example}:
4112 PROGRAM test_get_command_argument
4114 CHARACTER(len=32) :: arg
4118 CALL get_command_argument(i, arg)
4119 IF (LEN_TRIM(arg) == 0) EXIT
4121 WRITE (*,*) TRIM(arg)
4127 @item @emph{See also}:
4128 @ref{GET_COMMAND}, @ref{COMMAND_ARGUMENT_COUNT}
4134 @section @code{GETCWD} --- Get current working directory
4135 @cindex @code{GETCWD} intrinsic
4136 @cindex file system operations
4139 @item @emph{Description}:
4140 Get current working directory.
4142 @item @emph{Standard}:
4146 Non-elemental subroutine.
4148 @item @emph{Syntax}:
4149 @code{CALL GETCWD(CWD [, STATUS])}
4151 @item @emph{Arguments}:
4152 @multitable @columnfractions .15 .80
4153 @item @var{CWD} @tab The type shall be @code{CHARACTER(*)}.
4154 @item @var{STATUS} @tab (Optional) status flag. Returns 0 on success,
4155 a system specific and non-zero error code otherwise.
4158 @item @emph{Example}:
4161 CHARACTER(len=255) :: cwd
4163 WRITE(*,*) TRIM(cwd)
4167 @item @emph{See also}:
4174 @section @code{GETENV} --- Get an environmental variable
4175 @cindex @code{GETENV} intrinsic
4176 @cindex environment variable
4179 @item @emph{Description}:
4180 Get the @var{VALUE} of the environmental variable @var{ENVVAR}.
4182 This intrinsic routine is provided for backwards compatibility with
4183 GNU Fortran 77. In new code, programmers should consider the use of
4184 the @ref{GET_ENVIRONMENT_VARIABLE} intrinsic defined by the Fortran
4187 @item @emph{Standard}:
4193 @item @emph{Syntax}:
4194 @code{CALL GETENV(ENVVAR, VALUE)}
4196 @item @emph{Arguments}:
4197 @multitable @columnfractions .15 .80
4198 @item @var{ENVVAR} @tab Shall be of type @code{CHARACTER(*)}.
4199 @item @var{VALUE} @tab Shall be of type @code{CHARACTER(*)}.
4202 @item @emph{Return value}:
4203 Stores the value of @var{ENVVAR} in @var{VALUE}. If @var{VALUE} is
4204 not large enough to hold the data, it is truncated. If @var{ENVVAR}
4205 is not set, @var{VALUE} will be filled with blanks.
4207 @item @emph{Example}:
4210 CHARACTER(len=255) :: homedir
4211 CALL getenv("HOME", homedir)
4212 WRITE (*,*) TRIM(homedir)
4216 @item @emph{See also}:
4217 @ref{GET_ENVIRONMENT_VARIABLE}
4222 @node GET_ENVIRONMENT_VARIABLE
4223 @section @code{GET_ENVIRONMENT_VARIABLE} --- Get an environmental variable
4224 @cindex @code{GET_ENVIRONMENT_VARIABLE} intrinsic
4225 @cindex environment variable
4228 @item @emph{Description}:
4229 Get the @var{VALUE} of the environmental variable @var{ENVVAR}.
4231 @item @emph{Standard}:
4237 @item @emph{Syntax}:
4238 @code{CALL GET_ENVIRONMENT_VARIABLE(ENVVAR, VALUE)}
4240 @item @emph{Arguments}:
4241 @multitable @columnfractions .15 .80
4242 @item @var{ENVVAR} @tab Shall be of type @code{CHARACTER(*)}.
4243 @item @var{VALUE} @tab Shall be of type @code{CHARACTER(*)}.
4246 @item @emph{Return value}:
4247 Stores the value of @var{ENVVAR} in @var{VALUE}. If @var{VALUE} is
4248 not large enough to hold the data, it is truncated. If @var{ENVVAR}
4249 is not set, @var{VALUE} will be filled with blanks.
4251 @item @emph{Example}:
4254 CHARACTER(len=255) :: homedir
4255 CALL get_environment_variable("HOME", homedir)
4256 WRITE (*,*) TRIM(homedir)
4264 @section @code{GETGID} --- Group ID function
4265 @cindex @code{GETGID} intrinsic
4266 @cindex file system operations
4269 @item @emph{Description}:
4270 Returns the numerical group ID of the current process.
4272 @item @emph{Standard}:
4278 @item @emph{Syntax}:
4279 @code{RESULT = GETGID()}
4281 @item @emph{Return value}:
4282 The return value of @code{GETGID} is an @code{INTEGER} of the default
4286 @item @emph{Example}:
4287 See @code{GETPID} for an example.
4289 @item @emph{See also}:
4290 @ref{GETPID}, @ref{GETUID}
4296 @section @code{GETLOG} --- Get login name
4297 @cindex @code{GETLOG} intrinsic
4300 @item @emph{Description}:
4301 Gets the username under which the program is running.
4303 @item @emph{Standard}:
4309 @item @emph{Syntax}:
4310 @code{CALL GETLOG(LOGIN)}
4312 @item @emph{Arguments}:
4313 @multitable @columnfractions .15 .80
4314 @item @var{LOGIN} @tab Shall be of type @code{CHARACTER(*)}.
4317 @item @emph{Return value}:
4318 Stores the current user name in @var{LOGIN}. (On systems where
4319 the @code{getlogin(3)} function is not implemented, this will
4320 return a blank string.)
4322 @item @emph{Example}:
4325 CHARACTER(32) :: login
4331 @item @emph{See also}:
4338 @section @code{GETPID} --- Process ID function
4339 @cindex @code{GETPID} intrinsic
4340 @cindex process ID, current
4343 @item @emph{Description}:
4344 Returns the numerical process identifier of the current process.
4346 @item @emph{Standard}:
4352 @item @emph{Syntax}:
4353 @code{RESULT = GETPID()}
4355 @item @emph{Return value}:
4356 The return value of @code{GETPID} is an @code{INTEGER} of the default
4360 @item @emph{Example}:
4363 print *, "The current process ID is ", getpid()
4364 print *, "Your numerical user ID is ", getuid()
4365 print *, "Your numerical group ID is ", getgid()
4369 @item @emph{See also}:
4370 @ref{GETGID}, @ref{GETUID}
4376 @section @code{GETUID} --- User ID function
4377 @cindex @code{GETUID} intrinsic
4378 @cindex user ID, current
4381 @item @emph{Description}:
4382 Returns the numerical user ID of the current process.
4384 @item @emph{Standard}:
4390 @item @emph{Syntax}:
4391 @code{RESULT = GETUID()}
4393 @item @emph{Return value}:
4394 The return value of @code{GETUID} is an @code{INTEGER} of the default
4398 @item @emph{Example}:
4399 See @code{GETPID} for an example.
4401 @item @emph{See also}:
4402 @ref{GETPID}, @ref{GETLOG}
4408 @section @code{GMTIME} --- Convert time to GMT info
4409 @cindex @code{GMTIME} intrinsic
4410 @cindex time, conversion function
4413 @item @emph{Description}:
4414 Given a system time value @var{STIME} (as provided by the @code{TIME8()}
4415 intrinsic), fills @var{TARRAY} with values extracted from it appropriate
4416 to the UTC time zone (Universal Coordinated Time, also known in some
4417 countries as GMT, Greenwich Mean Time), using @code{gmtime(3)}.
4419 @item @emph{Standard}:
4425 @item @emph{Syntax}:
4426 @code{CALL GMTIME(STIME, TARRAY)}
4428 @item @emph{Arguments}:
4429 @multitable @columnfractions .15 .80
4430 @item @var{STIME} @tab An @code{INTEGER(*)} scalar expression
4431 corresponding to a system time, with
4433 @item @var{TARRAY} @tab A default @code{INTEGER} array with 9 elements,
4434 with @code{INTENT(OUT)}.
4437 @item @emph{Return value}:
4438 The elements of @var{TARRAY} are assigned as follows:
4440 @item Seconds after the minute, range 0--59 or 0--61 to allow for leap
4442 @item Minutes after the hour, range 0--59
4443 @item Hours past midnight, range 0--23
4444 @item Day of month, range 0--31
4445 @item Number of months since January, range 0--12
4446 @item Years since 1900
4447 @item Number of days since Sunday, range 0--6
4448 @item Days since January 1
4449 @item Daylight savings indicator: positive if daylight savings is in
4450 effect, zero if not, and negative if the information is not
4454 @item @emph{See also}:
4455 @ref{CTIME}, @ref{LTIME}, @ref{TIME}, @ref{TIME8}
4462 @section @code{HOSTNM} --- Get system host name
4463 @cindex @code{HOSTNM} intrinsic
4466 @item @emph{Description}:
4467 Retrieves the host name of the system on which the program is running.
4469 This intrinsic is provided in both subroutine and function forms; however,
4470 only one form can be used in any given program unit.
4472 @item @emph{Standard}:
4476 Subroutine, function
4478 @item @emph{Syntax}:
4479 @multitable @columnfractions .80
4480 @item @code{CALL HOSTNM(NAME, STATUS)}
4481 @item @code{STATUS = HOSTNM(NAME)}
4484 @item @emph{Arguments}:
4485 @multitable @columnfractions .15 .80
4486 @item @var{NAME} @tab Shall of type @code{CHARACTER(*)}.
4487 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
4488 Returns 0 on success, or a system specific error
4492 @item @emph{Return value}:
4493 In either syntax, @var{NAME} is set to the current hostname if it can
4494 be obtained, or to a blank string otherwise.
4501 @section @code{HUGE} --- Largest number of a kind
4502 @cindex @code{HUGE} intrinsic
4506 @item @emph{Description}:
4507 @code{HUGE(X)} returns the largest number that is not an infinity in
4508 the model of the type of @code{X}.
4510 @item @emph{Standard}:
4516 @item @emph{Syntax}:
4517 @code{RESULT = HUGE(X)}
4519 @item @emph{Arguments}:
4520 @multitable @columnfractions .15 .80
4521 @item @var{X} @tab shall be of type @code{REAL} or @code{INTEGER}.
4524 @item @emph{Return value}:
4525 The return value is of the same type and kind as @var{X}
4527 @item @emph{Example}:
4529 program test_huge_tiny
4530 print *, huge(0), huge(0.0), huge(0.0d0)
4531 print *, tiny(0.0), tiny(0.0d0)
4532 end program test_huge_tiny
4539 @section @code{IACHAR} --- Code in @acronym{ASCII} collating sequence
4540 @cindex @code{IACHAR} intrinsic
4541 @cindex @acronym{ASCII} collating sequence
4542 @cindex conversion function (character)
4545 @item @emph{Description}:
4546 @code{IACHAR(C)} returns the code for the @acronym{ASCII} character
4547 in the first character position of @code{C}.
4549 @item @emph{Standard}:
4555 @item @emph{Syntax}:
4556 @code{RESULT = IACHAR(C)}
4558 @item @emph{Arguments}:
4559 @multitable @columnfractions .15 .80
4560 @item @var{C} @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
4563 @item @emph{Return value}:
4564 The return value is of type @code{INTEGER} and of the default integer
4567 @item @emph{Example}:
4572 end program test_iachar
4575 @item @emph{See also}:
4576 @ref{ACHAR}, @ref{CHAR}, @ref{ICHAR}
4582 @section @code{IAND} --- Bitwise logical and
4583 @cindex @code{IAND} intrinsic
4584 @cindex bit operations
4587 @item @emph{Description}:
4588 Bitwise logical @code{AND}.
4590 @item @emph{Standard}:
4596 @item @emph{Syntax}:
4597 @code{RESULT = IAND(I, J)}
4599 @item @emph{Arguments}:
4600 @multitable @columnfractions .15 .80
4601 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
4602 @item @var{J} @tab The type shall be @code{INTEGER(*)}, of the same
4603 kind as @var{I}. (As a GNU extension, different kinds are also
4607 @item @emph{Return value}:
4608 The return type is @code{INTEGER(*)}, of the same kind as the
4609 arguments. (If the argument kinds differ, it is of the same kind as
4610 the larger argument.)
4612 @item @emph{Example}:
4616 DATA a / Z'F' /, b / Z'3' /
4617 WRITE (*,*) IAND(a, b)
4621 @item @emph{See also}:
4622 @ref{IOR}, @ref{IEOR}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
4629 @section @code{IARGC} --- Get the number of command line arguments
4630 @cindex @code{IARGC} intrinsic
4631 @cindex command-line arguments, to program
4634 @item @emph{Description}:
4635 @code{IARGC()} returns the number of arguments passed on the
4636 command line when the containing program was invoked.
4638 This intrinsic routine is provided for backwards compatibility with
4639 GNU Fortran 77. In new code, programmers should consider the use of
4640 the @ref{COMMAND_ARGUMENT_COUNT} intrinsic defined by the Fortran 2003
4643 @item @emph{Standard}:
4647 Non-elemental Function
4649 @item @emph{Syntax}:
4650 @code{RESULT = IARGC()}
4652 @item @emph{Arguments}:
4655 @item @emph{Return value}:
4656 The number of command line arguments, type @code{INTEGER(4)}.
4658 @item @emph{Example}:
4661 @item @emph{See also}:
4662 GNU Fortran 77 compatibility subroutine: @ref{GETARG}
4664 F2003 functions and subroutines: @ref{GET_COMMAND}, @ref{GET_COMMAND_ARGUMENT},
4665 @ref{COMMAND_ARGUMENT_COUNT}
4671 @section @code{IBCLR} --- Clear bit
4672 @cindex @code{IBCLR} intrinsic
4673 @cindex bit operations
4676 @item @emph{Description}:
4677 @code{IBCLR} returns the value of @var{I} with the bit at position
4678 @var{POS} set to zero.
4680 @item @emph{Standard}:
4686 @item @emph{Syntax}:
4687 @code{RESULT = IBCLR(I, POS)}
4689 @item @emph{Arguments}:
4690 @multitable @columnfractions .15 .80
4691 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
4692 @item @var{POS} @tab The type shall be @code{INTEGER(*)}.
4695 @item @emph{Return value}:
4696 The return value is of type @code{INTEGER(*)} and of the same kind as
4699 @item @emph{See also}:
4700 @ref{IBITS}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}, @ref{MVBITS}
4707 @section @code{IBITS} --- Bit extraction
4708 @cindex @code{IBITS} intrinsic
4709 @cindex bit operations
4712 @item @emph{Description}:
4713 @code{IBITS} extracts a field of length @var{LEN} from @var{I},
4714 starting from bit position @var{POS} and extending left for @var{LEN}
4715 bits. The result is right-justified and the remaining bits are
4716 zeroed. The value of @code{POS+LEN} must be less than or equal to the
4717 value @code{BIT_SIZE(I)}.
4719 @item @emph{Standard}:
4725 @item @emph{Syntax}:
4726 @code{RESULT = IBITS(I, POS, LEN)}
4728 @item @emph{Arguments}:
4729 @multitable @columnfractions .15 .80
4730 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
4731 @item @var{POS} @tab The type shall be @code{INTEGER(*)}.
4732 @item @var{LEN} @tab The type shall be @code{INTEGER(*)}.
4735 @item @emph{Return value}:
4736 The return value is of type @code{INTEGER(*)} and of the same kind as
4739 @item @emph{See also}:
4740 @ref{BIT_SIZE}, @ref{IBCLR}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
4746 @section @code{IBSET} --- Set bit
4747 @cindex @code{IBSET} intrinsic
4748 @cindex bit operations
4751 @item @emph{Description}:
4752 @code{IBSET} returns the value of @var{I} with the bit at position
4753 @var{POS} set to one.
4755 @item @emph{Standard}:
4761 @item @emph{Syntax}:
4762 @code{RESULT = IBSET(I, POS)}
4764 @item @emph{Arguments}:
4765 @multitable @columnfractions .15 .80
4766 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
4767 @item @var{POS} @tab The type shall be @code{INTEGER(*)}.
4770 @item @emph{Return value}:
4771 The return value is of type @code{INTEGER(*)} and of the same kind as
4774 @item @emph{See also}:
4775 @ref{IBCLR}, @ref{IBITS}, @ref{IAND}, @ref{IOR}, @ref{IEOR}, @ref{MVBITS}
4782 @section @code{ICHAR} --- Character-to-integer conversion function
4783 @cindex @code{ICHAR} intrinsic
4784 @cindex conversion function (character)
4787 @item @emph{Description}:
4788 @code{ICHAR(C)} returns the code for the character in the first character
4789 position of @code{C} in the system's native character set.
4790 The correspondence between characters and their codes is not necessarily
4791 the same across different GNU Fortran implementations.
4793 @item @emph{Standard}:
4799 @item @emph{Syntax}:
4800 @code{RESULT = ICHAR(C)}
4802 @item @emph{Arguments}:
4803 @multitable @columnfractions .15 .80
4804 @item @var{C} @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
4807 @item @emph{Return value}:
4808 The return value is of type @code{INTEGER} and of the default integer
4811 @item @emph{Example}:
4816 end program test_ichar
4820 No intrinsic exists to convert a printable character string to a numerical
4821 value. For example, there is no intrinsic that, given the @code{CHARACTER}
4822 value 154, returns an @code{INTEGER} or @code{REAL} value with the
4825 Instead, you can use internal-file I/O to do this kind of conversion. For
4830 character(len=10) string
4833 read (string,'(I10)') value
4835 end program read_val
4838 @item @emph{See also}:
4839 @ref{ACHAR}, @ref{CHAR}, @ref{IACHAR}
4846 @section @code{IDATE} --- Get current local time subroutine (day/month/year)
4847 @cindex @code{IDATE} intrinsic
4850 @item @emph{Description}:
4851 @code{IDATE(TARRAY)} Fills @var{TARRAY} with the numerical values at the
4852 current local time. The day (in the range 1-31), month (in the range 1-12),
4853 and year appear in elements 1, 2, and 3 of @var{TARRAY}, respectively.
4854 The year has four significant digits.
4856 @item @emph{Standard}:
4862 @item @emph{Syntax}:
4863 @code{CALL IDATE(TARRAY)}
4865 @item @emph{Arguments}:
4866 @multitable @columnfractions .15 .80
4867 @item @var{TARRAY} @tab The type shall be @code{INTEGER, DIMENSION(3)} and
4868 the kind shall be the default integer kind.
4871 @item @emph{Return value}:
4874 @item @emph{Example}:
4877 integer, dimension(3) :: tarray
4882 end program test_idate
4889 @section @code{IEOR} --- Bitwise logical exclusive or
4890 @cindex @code{IEOR} intrinsic
4891 @cindex bit operations
4894 @item @emph{Description}:
4895 @code{IEOR} returns the bitwise boolean exclusive-OR of @var{I} and
4898 @item @emph{Standard}:
4904 @item @emph{Syntax}:
4905 @code{RESULT = IEOR(I, J)}
4907 @item @emph{Arguments}:
4908 @multitable @columnfractions .15 .80
4909 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
4910 @item @var{J} @tab The type shall be @code{INTEGER(*)}, of the same
4911 kind as @var{I}. (As a GNU extension, different kinds are also
4915 @item @emph{Return value}:
4916 The return type is @code{INTEGER(*)}, of the same kind as the
4917 arguments. (If the argument kinds differ, it is of the same kind as
4918 the larger argument.)
4920 @item @emph{See also}:
4921 @ref{IOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
4927 @section @code{IERRNO} --- Get the last system error number
4928 @cindex @code{IERRNO} intrinsic
4931 @item @emph{Description}:
4932 Returns the last system error number, as given by the C @code{errno()}
4935 @item @emph{Standard}:
4941 @item @emph{Syntax}:
4942 @code{RESULT = IERRNO()}
4944 @item @emph{Arguments}:
4947 @item @emph{Return value}:
4948 The return value is of type @code{INTEGER} and of the default integer
4951 @item @emph{See also}:
4958 @section @code{INDEX} --- Position of a substring within a string
4959 @cindex @code{INDEX} intrinsic
4962 @item @emph{Description}:
4963 Returns the position of the start of the first occurrence of string
4964 @var{SUBSTRING} as a substring in @var{STRING}, counting from one. If
4965 @var{SUBSTRING} is not present in @var{STRING}, zero is returned. If
4966 the @var{BACK} argument is present and true, the return value is the
4967 start of the last occurrence rather than the first.
4969 @item @emph{Standard}:
4975 @item @emph{Syntax}:
4976 @code{RESULT = INDEX(STRING, SUBSTRING [, BACK])}
4978 @item @emph{Arguments}:
4979 @multitable @columnfractions .15 .80
4980 @item @var{STRING} @tab Shall be a scalar @code{CHARACTER(*)}, with
4982 @item @var{SUBSTRING} @tab Shall be a scalar @code{CHARACTER(*)}, with
4984 @item @var{BACK} @tab (Optional) Shall be a scalar @code{LOGICAL(*)}, with
4988 @item @emph{Return value}:
4989 The return value is of type @code{INTEGER} and of the default integer
4992 @item @emph{See also}:
4998 @section @code{INT} --- Convert to integer type
4999 @cindex @code{INT} intrinsic
5000 @cindex @code{IFIX} intrinsic
5001 @cindex @code{IDINT} intrinsic
5002 @cindex conversion function (integer)
5005 @item @emph{Description}:
5006 Convert to integer type
5008 @item @emph{Standard}:
5014 @item @emph{Syntax}:
5015 @item @code{RESULT = INT(X [, KIND))}
5017 @item @emph{Arguments}:
5018 @multitable @columnfractions .15 .80
5019 @item @var{X} @tab shall be of type @code{INTEGER(*)},
5020 @code{REAL(*)}, or @code{COMPLEX(*)}.
5021 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
5022 expression indicating the kind parameter of
5026 @item @emph{Return value}:
5027 These functions return a @code{INTEGER(*)} variable or array under
5028 the following rules:
5032 If @var{X} is of type @code{INTEGER(*)}, @code{INT(X) = X}
5034 If @var{X} is of type @code{REAL(*)} and @math{|X| < 1}, @code{INT(X)} equals @var{0}.
5035 If @math{|X| \geq 1}, then @code{INT(X)} equals the largest integer that does not exceed
5036 the range of @var{X} and whose sign is the same as the sign of @var{X}.
5038 If @var{X} is of type @code{COMPLEX(*)}, rule B is applied to the real part of X.
5041 @item @emph{Example}:
5045 complex :: z = (-3.7, 1.0)
5047 print *, int(z), int(z,8)
5051 @item @emph{Specific names}:
5052 @multitable @columnfractions .20 .20 .20 .40
5053 @item Name @tab Argument @tab Return type @tab Standard
5054 @item @code{IFIX(X)} @tab @code{REAL(4) X} @tab @code{INTEGER} @tab F77 and later
5055 @item @code{IDINT(X)} @tab @code{REAL(8) X} @tab @code{INTEGER} @tab F77 and later
5058 @comment @item @emph{See also}:
5064 @section @code{IOR} --- Bitwise logical or
5065 @cindex @code{IOR} intrinsic
5066 @cindex bit operations
5069 @item @emph{Description}:
5070 @code{IEOR} returns the bitwise boolean OR of @var{I} and
5073 @item @emph{Standard}:
5079 @item @emph{Syntax}:
5080 @code{RESULT = IEOR(I, J)}
5082 @item @emph{Arguments}:
5083 @multitable @columnfractions .15 .80
5084 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
5085 @item @var{J} @tab The type shall be @code{INTEGER(*)}, of the same
5086 kind as @var{I}. (As a GNU extension, different kinds are also
5090 @item @emph{Return value}:
5091 The return type is @code{INTEGER(*)}, of the same kind as the
5092 arguments. (If the argument kinds differ, it is of the same kind as
5093 the larger argument.)
5095 @item @emph{See also}:
5096 @ref{IEOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
5103 @section @code{IRAND} --- Integer pseudo-random number
5104 @cindex @code{IRAND} intrinsic
5105 @cindex random numbers
5108 @item @emph{Description}:
5109 @code{IRAND(FLAG)} returns a pseudo-random number from a uniform
5110 distribution between 0 and a system-dependent limit (which is in most
5111 cases 2147483647). If @var{FLAG} is 0, the next number
5112 in the current sequence is returned; if @var{FLAG} is 1, the generator
5113 is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
5114 it is used as a new seed with @code{SRAND}.
5116 @item @emph{Standard}:
5120 non-elemental function
5122 @item @emph{Syntax}:
5123 @code{RESULT = IRAND(FLAG)}
5125 @item @emph{Arguments}:
5126 @multitable @columnfractions .15 .80
5127 @item @var{FLAG} @tab shall be a scalar @code{INTEGER} of kind 4.
5130 @item @emph{Return value}:
5131 The return value is of @code{INTEGER(kind=4)} type.
5133 @item @emph{Example}:
5136 integer,parameter :: seed = 86456
5139 print *, irand(), irand(), irand(), irand()
5140 print *, irand(seed), irand(), irand(), irand()
5141 end program test_irand
5149 @section @code{ISHFT} --- Shift bits
5150 @cindex @code{ISHFT} intrinsic
5151 @cindex bit operations
5154 @item @emph{Description}:
5155 @code{ISHFT} returns a value corresponding to @var{I} with all of the
5156 bits shifted @var{SHIFT} places. A value of @var{SHIFT} greater than
5157 zero corresponds to a left shift, a value of zero corresponds to no
5158 shift, and a value less than zero corresponds to a right shift. If the
5159 absolute value of @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the
5160 value is undefined. Bits shifted out from the left end or right end are
5161 lost; zeros are shifted in from the opposite end.
5163 @item @emph{Standard}:
5169 @item @emph{Syntax}:
5170 @code{RESULT = ISHFT(I, SHIFT)}
5172 @item @emph{Arguments}:
5173 @multitable @columnfractions .15 .80
5174 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
5175 @item @var{SHIFT} @tab The type shall be @code{INTEGER(*)}.
5178 @item @emph{Return value}:
5179 The return value is of type @code{INTEGER(*)} and of the same kind as
5182 @item @emph{See also}:
5190 @section @code{ISHFTC} --- Shift bits circularly
5191 @cindex @code{ISHFTC} intrinsic
5192 @cindex bit operations
5195 @item @emph{Description}:
5196 @code{ISHFTC} returns a value corresponding to @var{I} with the
5197 rightmost @var{SIZE} bits shifted circularly @var{SHIFT} places; that
5198 is, bits shifted out one end are shifted into the opposite end. A value
5199 of @var{SHIFT} greater than zero corresponds to a left shift, a value of
5200 zero corresponds to no shift, and a value less than zero corresponds to
5201 a right shift. The absolute value of @var{SHIFT} must be less than
5202 @var{SIZE}. If the @var{SIZE} argument is omitted, it is taken to be
5203 equivalent to @code{BIT_SIZE(I)}.
5205 @item @emph{Standard}:
5211 @item @emph{Syntax}:
5212 @code{RESULT = ISHFTC(I, SHIFT [, SIZE])}
5214 @item @emph{Arguments}:
5215 @multitable @columnfractions .15 .80
5216 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
5217 @item @var{SHIFT} @tab The type shall be @code{INTEGER(*)}.
5218 @item @var{SIZE} @tab (Optional) The type shall be @code{INTEGER(*)};
5219 the value must be greater than zero and less than or equal to
5223 @item @emph{Return value}:
5224 The return value is of type @code{INTEGER(*)} and of the same kind as
5227 @item @emph{See also}:
5234 @section @code{ITIME} --- Get current local time subroutine (hour/minutes/seconds)
5235 @cindex @code{ITIME} intrinsic
5238 @item @emph{Description}:
5239 @code{IDATE(TARRAY)} Fills @var{TARRAY} with the numerical values at the
5240 current local time. The hour (in the range 1-24), minute (in the range 1-60),
5241 and seconds (in the range 1-60) appear in elements 1, 2, and 3 of @var{TARRAY},
5244 @item @emph{Standard}:
5250 @item @emph{Syntax}:
5251 @code{CALL ITIME(TARRAY)}
5253 @item @emph{Arguments}:
5254 @multitable @columnfractions .15 .80
5255 @item @var{TARRAY} @tab The type shall be @code{INTEGER, DIMENSION(3)}
5256 and the kind shall be the default integer kind.
5259 @item @emph{Return value}:
5263 @item @emph{Example}:
5266 integer, dimension(3) :: tarray
5271 end program test_itime
5278 @section @code{KILL} --- Send a signal to a process
5279 @cindex @code{KILL} intrinsic
5282 @item @emph{Description}:
5283 @item @emph{Standard}:
5284 Sends the signal specified by @var{SIGNAL} to the process @var{PID}.
5290 @item @emph{Syntax}:
5291 @code{CALL KILL(PID, SIGNAL [, STATUS])}
5293 @item @emph{Arguments}:
5294 @multitable @columnfractions .15 .80
5295 @item @var{PID} @tab Shall be a scalar @code{INTEGER}, with
5297 @item @var{SIGNAL} @tab Shall be a scalar @code{INTEGER}, with
5299 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)} or
5300 @code{INTEGER(8)}. Returns 0 on success, or a
5301 system-specific error code otherwise.
5304 @item @emph{See also}:
5305 @ref{ABORT}, @ref{EXIT}
5311 @section @code{KIND} --- Kind of an entity
5312 @cindex @code{KIND} intrinsic
5315 @item @emph{Description}:
5316 @code{KIND(X)} returns the kind value of the entity @var{X}.
5318 @item @emph{Standard}:
5324 @item @emph{Syntax}:
5327 @item @emph{Arguments}:
5328 @multitable @columnfractions .15 .80
5329 @item @var{X} @tab Shall be of type @code{LOGICAL}, @code{INTEGER},
5330 @code{REAL}, @code{COMPLEX} or @code{CHARACTER}.
5333 @item @emph{Return value}:
5334 The return value is a scalar of type @code{INTEGER} and of the default
5337 @item @emph{Example}:
5340 integer,parameter :: kc = kind(' ')
5341 integer,parameter :: kl = kind(.true.)
5343 print *, "The default character kind is ", kc
5344 print *, "The default logical kind is ", kl
5345 end program test_kind
5353 @section @code{LBOUND} --- Lower dimension bounds of an array
5354 @cindex @code{LBOUND} intrinsic
5357 @item @emph{Description}:
5358 Returns the lower bounds of an array, or a single lower bound
5359 along the @var{DIM} dimension.
5360 @item @emph{Standard}:
5366 @item @emph{Syntax}:
5367 @code{RESULT = LBOUND(ARRAY [, DIM])}
5369 @item @emph{Arguments}:
5370 @multitable @columnfractions .15 .80
5371 @item @var{ARRAY} @tab Shall be an array, of any type.
5372 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER(*)}.
5375 @item @emph{Return value}:
5376 If @var{DIM} is absent, the result is an array of the lower bounds of
5377 @var{ARRAY}. If @var{DIM} is present, the result is a scalar
5378 corresponding to the lower bound of the array along that dimension. If
5379 @var{ARRAY} is an expression rather than a whole array or array
5380 structure component, or if it has a zero extent along the relevant
5381 dimension, the lower bound is taken to be 1.
5383 @item @emph{See also}:
5390 @section @code{LEN} --- Length of a character entity
5391 @cindex @code{LEN} intrinsic
5394 @item @emph{Description}:
5395 Returns the length of a character string. If @var{STRING} is an array,
5396 the length of an element of @var{STRING} is returned. Note that
5397 @var{STRING} need not be defined when this intrinsic is invoked, since
5398 only the length, not the content, of @var{STRING} is needed.
5400 @item @emph{Standard}:
5406 @item @emph{Syntax}:
5407 @code{L = LEN(STRING)}
5409 @item @emph{Arguments}:
5410 @multitable @columnfractions .15 .80
5411 @item @var{STRING} @tab Shall be a scalar or array of type
5412 @code{CHARACTER(*)}, with @code{INTENT(IN)}
5415 @item @emph{Return value}:
5416 The return value is an @code{INTEGER} of the default kind.
5418 @item @emph{See also}:
5419 @ref{LEN_TRIM}, @ref{ADJUSTL}, @ref{ADJUSTR}
5425 @section @code{LEN_TRIM} --- Length of a character entity without trailing blank characters
5426 @cindex @code{LEN_TRIM} intrinsic
5429 @item @emph{Description}:
5430 Returns the length of a character string, ignoring any trailing blanks.
5432 @item @emph{Standard}:
5438 @item @emph{Syntax}:
5439 @code{RESULT = LEN_TRIM(STRING)}
5441 @item @emph{Arguments}:
5442 @multitable @columnfractions .15 .80
5443 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER(*)},
5444 with @code{INTENT(IN)}
5447 @item @emph{Return value}:
5448 The return value is an @code{INTEGER} of the default kind.
5450 @item @emph{See also}:
5451 @ref{LEN}, @ref{ADJUSTL}, @ref{ADJUSTR}
5457 @section @code{LGE} --- Lexical greater than or equal
5458 @cindex @code{LGE} intrinsic
5459 @cindex comparison (lexical)
5460 @cindex lexical comparison
5463 @item @emph{Description}:
5464 Determines whether one string is lexically greater than or equal to
5465 another string, where the two strings are interpreted as containing
5466 ASCII character codes. If the String A and String B are not the same
5467 length, the shorter is compared as if spaces were appended to it to form
5468 a value that has the same length as the longer.
5470 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
5471 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
5472 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
5473 that the latter use the processor's character ordering (which is not
5474 ASCII on some targets), whereas the former always use the ASCII
5477 @item @emph{Standard}:
5483 @item @emph{Syntax}:
5484 @code{RESULT = LGE(STRING_A, STRING_B)}
5486 @item @emph{Arguments}:
5487 @multitable @columnfractions .15 .80
5488 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
5489 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
5492 @item @emph{Return value}:
5493 Returns @code{.TRUE.} if @code{STRING_A >= STRING_B}, and @code{.FALSE.}
5494 otherwise, based on the ASCII ordering.
5496 @item @emph{See also}:
5497 @ref{LGT}, @ref{LLE}, @ref{LLT}
5503 @section @code{LGT} --- Lexical greater than
5504 @cindex @code{LGT} intrinsic
5505 @cindex comparison (lexical)
5506 @cindex lexical comparison
5509 @item @emph{Description}:
5510 Determines whether one string is lexically greater than another string,
5511 where the two strings are interpreted as containing ASCII character
5512 codes. If the String A and String B are not the same length, the
5513 shorter is compared as if spaces were appended to it to form a value
5514 that has the same length as the longer.
5516 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
5517 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
5518 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
5519 that the latter use the processor's character ordering (which is not
5520 ASCII on some targets), whereas the former always use the ASCII
5523 @item @emph{Standard}:
5529 @item @emph{Syntax}:
5530 @code{RESULT = LGT(STRING_A, STRING_B)}
5532 @item @emph{Arguments}:
5533 @multitable @columnfractions .15 .80
5534 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
5535 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
5538 @item @emph{Return value}:
5539 Returns @code{.TRUE.} if @code{STRING_A > STRING_B}, and @code{.FALSE.}
5540 otherwise, based on the ASCII ordering.
5542 @item @emph{See also}:
5543 @ref{LGE}, @ref{LLE}, @ref{LLT}
5549 @section @code{LINK} --- Create a hard link
5550 @cindex @code{LINK} intrinsic
5551 @cindex file system operations
5554 @item @emph{Description}:
5555 Makes a (hard) link from file @var{PATH1} to @var{PATH2}. A null
5556 character (@code{CHAR(0)}) can be used to mark the end of the names in
5557 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
5558 names are ignored. If the @var{STATUS} argument is supplied, it
5559 contains 0 on success or a nonzero error code upon return; see
5562 @item @emph{Standard}:
5568 @item @emph{Syntax}:
5569 @code{CALL LINK(PATH1, PATH2 [, STATUS])}
5571 @item @emph{Arguments}:
5572 @multitable @columnfractions .15 .80
5573 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
5574 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
5575 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
5578 @item @emph{See also}:
5579 @ref{SYMLNK}, @ref{UNLINK}
5585 @section @code{LLE} --- Lexical less than or equal
5586 @cindex @code{LLE} intrinsic
5587 @cindex comparison (lexical)
5588 @cindex lexical comparison
5591 @item @emph{Description}:
5592 Determines whether one string is lexically less than or equal to another
5593 string, where the two strings are interpreted as containing ASCII
5594 character codes. If the String A and String B are not the same length,
5595 the shorter is compared as if spaces were appended to it to form a value
5596 that has the same length as the longer.
5598 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
5599 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
5600 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
5601 that the latter use the processor's character ordering (which is not
5602 ASCII on some targets), whereas the former always use the ASCII
5605 @item @emph{Standard}:
5611 @item @emph{Syntax}:
5612 @code{RESULT = LLE(STRING_A, STRING_B)}
5614 @item @emph{Arguments}:
5615 @multitable @columnfractions .15 .80
5616 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
5617 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
5620 @item @emph{Return value}:
5621 Returns @code{.TRUE.} if @code{STRING_A <= STRING_B}, and @code{.FALSE.}
5622 otherwise, based on the ASCII ordering.
5624 @item @emph{See also}:
5625 @ref{LGE}, @ref{LGT}, @ref{LLT}
5631 @section @code{LLT} --- Lexical less than
5632 @cindex @code{LLT} intrinsic
5633 @cindex comparison (lexical)
5634 @cindex lexical comparison
5637 @item @emph{Description}:
5638 Determines whether one string is lexically less than another string,
5639 where the two strings are interpreted as containing ASCII character
5640 codes. If the String A and String B are not the same length, the
5641 shorter is compared as if spaces were appended to it to form a value
5642 that has the same length as the longer.
5644 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
5645 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
5646 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
5647 that the latter use the processor's character ordering (which is not
5648 ASCII on some targets), whereas the former always use the ASCII
5651 @item @emph{Standard}:
5657 @item @emph{Syntax}:
5658 @code{RESULT = LLT(STRING_A, STRING_B)}
5660 @item @emph{Arguments}:
5661 @multitable @columnfractions .15 .80
5662 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
5663 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
5666 @item @emph{Return value}:
5667 Returns @code{.TRUE.} if @code{STRING_A < STRING_B}, and @code{.FALSE.}
5668 otherwise, based on the ASCII ordering.
5670 @item @emph{See also}:
5671 @ref{LGE}, @ref{LGT}, @ref{LLE}
5677 @section @code{LNBLNK} --- Index of the last non-blank character in a string
5678 @cindex @code{LNBLNK} intrinsic
5681 @item @emph{Description}:
5682 Returns the length of a character string, ignoring any trailing blanks.
5683 This is identical to the standard @code{LEN_TRIM} intrinsic, and is only
5684 included for backwards compatibility.
5686 @item @emph{Standard}:
5692 @item @emph{Syntax}:
5693 @code{RESULT = LNBLNK(STRING)}
5695 @item @emph{Arguments}:
5696 @multitable @columnfractions .15 .80
5697 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER(*)},
5698 with @code{INTENT(IN)}
5701 @item @emph{Return value}:
5702 The return value is of @code{INTEGER(kind=4)} type.
5704 @item @emph{See also}:
5705 @ref{INDEX}, @ref{LEN_TRIM}
5711 @section @code{LOC} --- Returns the address of a variable
5712 @cindex @code{LOC} intrinsic
5713 @cindex location of a variable in memory
5716 @item @emph{Description}:
5717 @code{LOC(X)} returns the address of @var{X} as an integer.
5719 @item @emph{Standard}:
5725 @item @emph{Syntax}:
5726 @code{RESULT = LOC(X)}
5728 @item @emph{Arguments}:
5729 @multitable @columnfractions .15 .80
5730 @item @var{X} @tab Variable of any type.
5733 @item @emph{Return value}:
5734 The return value is of type @code{INTEGER}, with a @code{KIND}
5735 corresponding to the size (in bytes) of a memory address on the target
5738 @item @emph{Example}:
5745 end program test_loc
5752 @section @code{LOG} --- Logarithm function
5753 @cindex @code{LOG} intrinsic
5754 @cindex @code{ALOG} intrinsic
5755 @cindex @code{DLOG} intrinsic
5756 @cindex @code{CLOG} intrinsic
5757 @cindex @code{ZLOG} intrinsic
5758 @cindex @code{CDLOG} intrinsic
5762 @item @emph{Description}:
5763 @code{LOG(X)} computes the logarithm of @var{X}.
5765 @item @emph{Standard}:
5771 @item @emph{Syntax}:
5772 @code{RESULT = LOG(X)}
5774 @item @emph{Arguments}:
5775 @multitable @columnfractions .15 .80
5776 @item @var{X} @tab The type shall be @code{REAL(*)} or
5780 @item @emph{Return value}:
5781 The return value is of type @code{REAL(*)} or @code{COMPLEX(*)}.
5782 The kind type parameter is the same as @var{X}.
5784 @item @emph{Example}:
5787 real(8) :: x = 1.0_8
5788 complex :: z = (1.0, 2.0)
5791 end program test_log
5794 @item @emph{Specific names}:
5795 @multitable @columnfractions .20 .20 .20 .40
5796 @item Name @tab Argument @tab Return type @tab Standard
5797 @item @code{ALOG(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab f95, gnu
5798 @item @code{DLOG(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
5799 @item @code{CLOG(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab f95, gnu
5800 @item @code{ZLOG(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
5801 @item @code{CDLOG(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
5808 @section @code{LOG10} --- Base 10 logarithm function
5809 @cindex @code{LOG10} intrinsic
5810 @cindex @code{ALOG10} intrinsic
5811 @cindex @code{DLOG10} intrinsic
5815 @item @emph{Description}:
5816 @code{LOG10(X)} computes the base 10 logarithm of @var{X}.
5818 @item @emph{Standard}:
5824 @item @emph{Syntax}:
5825 @code{RESULT = LOG10(X)}
5827 @item @emph{Arguments}:
5828 @multitable @columnfractions .15 .80
5829 @item @var{X} @tab The type shall be @code{REAL(*)} or
5833 @item @emph{Return value}:
5834 The return value is of type @code{REAL(*)} or @code{COMPLEX(*)}.
5835 The kind type parameter is the same as @var{X}.
5837 @item @emph{Example}:
5840 real(8) :: x = 10.0_8
5842 end program test_log10
5845 @item @emph{Specific names}:
5846 @multitable @columnfractions .20 .20 .20 .40
5847 @item Name @tab Argument @tab Return type @tab Standard
5848 @item @code{ALOG10(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab F95 and later
5849 @item @code{DLOG10(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
5856 @section @code{LOGICAL} --- Convert to logical type
5857 @cindex @code{LOGICAL} intrinsic
5858 @cindex conversion function (logical)
5861 @item @emph{Description}:
5862 Converts one kind of @code{LOGICAL} variable to another.
5864 @item @emph{Standard}:
5870 @item @emph{Syntax}:
5871 @code{RESULT = LOGICAL(L [, KIND])}
5873 @item @emph{Arguments}:
5874 @multitable @columnfractions .15 .80
5875 @item @var{L} @tab The type shall be @code{LOGICAL(*)}.
5876 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
5877 expression indicating the kind parameter of
5881 @item @emph{Return value}:
5882 The return value is a @code{LOGICAL} value equal to @var{L}, with a
5883 kind corresponding to @var{KIND}, or of the default logical kind if
5884 @var{KIND} is not given.
5886 @item @emph{See also}:
5887 @ref{INT}, @ref{REAL}, @ref{CMPLX}
5894 @section @code{LSHIFT} --- Left shift bits
5895 @cindex @code{LSHIFT} intrinsic
5896 @cindex bit operations
5899 @item @emph{Description}:
5900 @code{LSHIFT} returns a value corresponding to @var{I} with all of the
5901 bits shifted left by @var{SHIFT} places. If the absolute value of
5902 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
5903 Bits shifted out from the left end are lost; zeros are shifted in from
5906 This function has been superseded by the @code{ISHFT} intrinsic, which
5907 is standard in Fortran 95 and later.
5909 @item @emph{Standard}:
5915 @item @emph{Syntax}:
5916 @code{RESULT = LSHIFT(I, SHIFT)}
5918 @item @emph{Arguments}:
5919 @multitable @columnfractions .15 .80
5920 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
5921 @item @var{SHIFT} @tab The type shall be @code{INTEGER(*)}.
5924 @item @emph{Return value}:
5925 The return value is of type @code{INTEGER(*)} and of the same kind as
5928 @item @emph{See also}:
5929 @ref{ISHFT}, @ref{ISHFTC}, @ref{RSHIFT}
5935 @section @code{LSTAT} --- Get file status
5936 @cindex @code{LSTAT} intrinsic
5937 @cindex file system operations
5940 @item @emph{Description}:
5941 @code{LSTAT} is identical to @ref{STAT}, except that if path is a symbolic link,
5942 then the link itself is statted, not the file that it refers to.
5944 The elements in @code{BUFF} are the same as described by @ref{STAT}.
5946 @item @emph{Standard}:
5950 Non-elemental subroutine
5952 @item @emph{Syntax}:
5953 @code{CALL LSTAT(FILE, BUFF [, STATUS])}
5955 @item @emph{Arguments}:
5956 @multitable @columnfractions .15 .80
5957 @item @var{FILE} @tab The type shall be @code{CHARACTER(*)}, a valid path within the file system.
5958 @item @var{BUFF} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
5959 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0
5960 on success and a system specific error code otherwise.
5963 @item @emph{Example}:
5964 See @ref{STAT} for an example.
5966 @item @emph{See also}:
5967 To stat an open file: @ref{FSTAT}, to stat a file: @ref{STAT}
5973 @section @code{LTIME} --- Convert time to local time info
5974 @cindex @code{LTIME} intrinsic
5975 @cindex time, conversion function
5978 @item @emph{Description}:
5979 Given a system time value @var{STIME} (as provided by the @code{TIME8()}
5980 intrinsic), fills @var{TARRAY} with values extracted from it appropriate
5981 to the local time zone using @code{localtime(3)}.
5983 @item @emph{Standard}:
5989 @item @emph{Syntax}:
5990 @code{CALL LTIME(STIME, TARRAY)}
5992 @item @emph{Arguments}:
5993 @multitable @columnfractions .15 .80
5994 @item @var{STIME} @tab An @code{INTEGER(*)} scalar expression
5995 corresponding to a system time, with
5997 @item @var{TARRAY} @tab A default @code{INTEGER} array with 9 elements,
5998 with @code{INTENT(OUT)}.
6001 @item @emph{Return value}:
6002 The elements of @var{TARRAY} are assigned as follows:
6004 @item Seconds after the minute, range 0--59 or 0--61 to allow for leap
6006 @item Minutes after the hour, range 0--59
6007 @item Hours past midnight, range 0--23
6008 @item Day of month, range 0--31
6009 @item Number of months since January, range 0--12
6010 @item Years since 1900
6011 @item Number of days since Sunday, range 0--6
6012 @item Days since January 1
6013 @item Daylight savings indicator: positive if daylight savings is in
6014 effect, zero if not, and negative if the information is not
6018 @item @emph{See also}:
6019 @ref{CTIME}, @ref{GMTIME}, @ref{TIME}, @ref{TIME8}
6026 @section @code{MALLOC} --- Allocate dynamic memory
6027 @cindex @code{MALLOC} intrinsic
6028 @cindex Cray pointers
6031 @item @emph{Description}:
6032 @code{MALLOC(SIZE)} allocates @var{SIZE} bytes of dynamic memory and
6033 returns the address of the allocated memory. The @code{MALLOC} intrinsic
6034 is an extension intended to be used with Cray pointers, and is provided
6035 in GNU Fortran to allow the user to compile legacy code. For new code
6036 using Fortran 95 pointers, the memory allocation intrinsic is
6039 @item @emph{Standard}:
6043 non-elemental function
6045 @item @emph{Syntax}:
6046 @code{PTR = MALLOC(SIZE)}
6048 @item @emph{Arguments}:
6049 @multitable @columnfractions .15 .80
6050 @item @var{SIZE} @tab The type shall be @code{INTEGER(*)}.
6053 @item @emph{Return value}:
6054 The return value is of type @code{INTEGER(K)}, with @var{K} such that
6055 variables of type @code{INTEGER(K)} have the same size as
6056 C pointers (@code{sizeof(void *)}).
6058 @item @emph{Example}:
6059 The following example demonstrates the use of @code{MALLOC} and
6060 @code{FREE} with Cray pointers. This example is intended to run on
6061 32-bit systems, where the default integer kind is suitable to store
6062 pointers; on 64-bit systems, ptr_x would need to be declared as
6063 @code{integer(kind=8)}.
6072 ptr_x = malloc(20*8)
6074 x(i) = sqrt(1.0d0 / i)
6082 end program test_malloc
6085 @item @emph{See also}:
6092 @section @code{MATMUL} --- matrix multiplication
6093 @cindex @code{MATMUL} intrinsic
6094 @cindex matrix operations
6097 @item @emph{Description}:
6098 Performs a matrix multiplication on numeric or logical arguments.
6100 @item @emph{Standard}:
6104 Transformational function
6106 @item @emph{Syntax}:
6107 @code{RESULT = MATMUL(MATRIX_A, MATRIX_B)}
6109 @item @emph{Arguments}:
6110 @multitable @columnfractions .15 .80
6111 @item @var{MATRIX_A} @tab An array of @code{INTEGER(*)},
6112 @code{REAL(*)}, @code{COMPLEX(*)}, or
6113 @code{LOGICAL(*)} type, with a rank of
6115 @item @var{MATRIX_B} @tab An array of @code{INTEGER(*)},
6116 @code{REAL(*)}, or @code{COMPLEX(*)} type if
6117 @var{MATRIX_A} is of a numeric type;
6118 otherwise, an array of @code{LOGICAL(*)}
6119 type. The rank shall be one or two, and the
6120 first (or only) dimension of @var{MATRIX_B}
6121 shall be equal to the last (or only)
6122 dimension of @var{MATRIX_A}.
6125 @item @emph{Return value}:
6126 The matrix product of @var{MATRIX_A} and @var{MATRIX_B}. The type and
6127 kind of the result follow the usual type and kind promotion rules, as
6128 for the @code{*} or @code{.AND.} operators.
6130 @item @emph{See also}:
6136 @section @code{MAX} --- Maximum value of an argument list
6137 @cindex @code{MAX} intrinsic
6140 @item @emph{Description}:
6141 Returns the argument with the largest (most positive) value.
6143 @item @emph{Standard}:
6149 @item @emph{Syntax}:
6150 @code{RESULT = MAX(A1, A2 [, A3 [, ...]])}
6152 @item @emph{Arguments}:
6153 @multitable @columnfractions .15 .80
6154 @item @var{A1} @tab The type shall be @code{INTEGER(*)} or
6156 @item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
6157 as @var{A1}. (As a GNU extension,
6158 arguments of different kinds are
6162 @item @emph{Return value}:
6163 The return value corresponds to the maximum value among the arguments,
6164 and has the same type and kind as the first argument.
6166 @item @emph{Specific names}:
6167 @multitable @columnfractions .20 .20 .20 .40
6168 @item Name @tab Argument @tab Return type @tab Standard
6169 @item @code{MAX0(I)} @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)} @tab F77 and later
6170 @item @code{AMAX0(I)} @tab @code{INTEGER(4) I} @tab @code{REAL(MAX(X))} @tab F77 and later
6171 @item @code{MAX1(X)} @tab @code{REAL(*) X} @tab @code{INT(MAX(X))} @tab F77 and later
6172 @item @code{AMAX1(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab F77 and later
6173 @item @code{DMAX1(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
6176 @item @emph{See also}:
6177 @ref{MAXLOC} @ref{MAXVAL}, @ref{MIN}
6184 @section @code{MAXEXPONENT} --- Maximum exponent of a real kind
6185 @cindex @code{MAXEXPONENT} intrinsic
6186 @cindex maximum exponent
6187 @cindex exponent, maximum
6190 @item @emph{Description}:
6191 @code{MAXEXPONENT(X)} returns the maximum exponent in the model of the
6194 @item @emph{Standard}:
6200 @item @emph{Syntax}:
6201 @code{RESULT = MAXEXPONENT(X)}
6203 @item @emph{Arguments}:
6204 @multitable @columnfractions .15 .80
6205 @item @var{X} @tab shall be of type @code{REAL}.
6208 @item @emph{Return value}:
6209 The return value is of type @code{INTEGER} and of the default integer
6212 @item @emph{Example}:
6218 print *, minexponent(x), maxexponent(x)
6219 print *, minexponent(y), maxexponent(y)
6220 end program exponents
6227 @section @code{MAXLOC} --- Location of the maximum value within an array
6228 @cindex @code{MAXLOC} intrinsic
6231 @item @emph{Description}:
6232 Determines the location of the element in the array with the maximum
6233 value, or, if the @var{DIM} argument is supplied, determines the
6234 locations of the maximum element along each row of the array in the
6235 @var{DIM} direction. If @var{MASK} is present, only the elements for
6236 which @var{MASK} is @code{.TRUE.} are considered. If more than one
6237 element in the array has the maximum value, the location returned is
6238 that of the first such element in array element order. If the array has
6239 zero size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
6240 the result is an array of zeroes. Similarly, if @var{DIM} is supplied
6241 and all of the elements of @var{MASK} along a given row are zero, the
6242 result value for that row is zero.
6244 @item @emph{Standard}:
6248 Transformational function
6250 @item @emph{Syntax}:
6251 @multitable @columnfractions .80
6252 @item @code{RESULT = MAXLOC(ARRAY, DIM [, MASK])}
6253 @item @code{RESULT = MAXLOC(ARRAY [, MASK])}
6256 @item @emph{Arguments}:
6257 @multitable @columnfractions .15 .80
6258 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER(*)},
6259 @code{REAL(*)}, or @code{CHARACTER(*)}.
6260 @item @var{DIM} @tab (Optional) Shall be a scalar of type
6261 @code{INTEGER(*)}, with a value between one
6262 and the rank of @var{ARRAY}, inclusive. It
6263 may not be an optional dummy argument.
6264 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL(*)},
6265 and conformable with @var{ARRAY}.
6268 @item @emph{Return value}:
6269 If @var{DIM} is absent, the result is a rank-one array with a length
6270 equal to the rank of @var{ARRAY}. If @var{DIM} is present, the result
6271 is an array with a rank one less than the rank of @var{ARRAY}, and a
6272 size corresponding to the size of @var{ARRAY} with the @var{DIM}
6273 dimension removed. If @var{DIM} is present and @var{ARRAY} has a rank
6274 of one, the result is a scalar. In all cases, the result is of default
6275 @code{INTEGER} type.
6277 @item @emph{See also}:
6278 @ref{MAX}, @ref{MAXVAL}
6285 @section @code{MAXVAL} --- Maximum value of an array
6286 @cindex @code{MAXVAL} intrinsic
6289 @item @emph{Description}:
6290 Determines the maximum value of the elements in an array value, or, if
6291 the @var{DIM} argument is supplied, determines the maximum value along
6292 each row of the array in the @var{DIM} direction. If @var{MASK} is
6293 present, only the elements for which @var{MASK} is @code{.TRUE.} are
6294 considered. If the array has zero size, or all of the elements of
6295 @var{MASK} are @code{.FALSE.}, then the result is the most negative
6296 number of the type and kind of @var{ARRAY} if @var{ARRAY} is numeric, or
6297 a string of nulls if @var{ARRAY} is of character type.
6299 @item @emph{Standard}:
6303 Transformational function
6305 @item @emph{Syntax}:
6306 @multitable @columnfractions .80
6307 @item @code{RESULT = MAXVAL(ARRAY, DIM [, MASK])}
6308 @item @code{RESULT = MAXVAL(ARRAY [, MASK])}
6311 @item @emph{Arguments}:
6312 @multitable @columnfractions .15 .80
6313 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER(*)},
6314 @code{REAL(*)}, or @code{CHARACTER(*)}.
6315 @item @var{DIM} @tab (Optional) Shall be a scalar of type
6316 @code{INTEGER(*)}, with a value between one
6317 and the rank of @var{ARRAY}, inclusive. It
6318 may not be an optional dummy argument.
6319 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL(*)},
6320 and conformable with @var{ARRAY}.
6323 @item @emph{Return value}:
6324 If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
6325 is a scalar. If @var{DIM} is present, the result is an array with a
6326 rank one less than the rank of @var{ARRAY}, and a size corresponding to
6327 the size of @var{ARRAY} with the @var{DIM} dimension removed. In all
6328 cases, the result is of the same type and kind as @var{ARRAY}.
6330 @item @emph{See also}:
6331 @ref{MAX}, @ref{MAXLOC}
6337 @section @code{MERGE} --- Merge variables
6338 @cindex @code{MERGE} intrinsic
6341 @item @emph{Description}:
6342 Select values from two arrays according to a logical mask. The result
6343 is equal to @var{TSOURCE} if @var{MASK} is @code{.TRUE.}, or equal to
6344 @var{FSOURCE} if it is @code{.FALSE.}.
6346 @item @emph{Standard}:
6352 @item @emph{Syntax}:
6353 @code{RESULT = MERGE(TSOURCE, FSOURCE, MASK)}
6355 @item @emph{Arguments}:
6356 @multitable @columnfractions .15 .80
6357 @item @var{TSOURCE} @tab May be of any type.
6358 @item @var{FSOURCE} @tab Shall be of the same type and type parameters
6360 @item @var{MASK} @tab Shall be of type @code{LOGICAL(*)}.
6363 @item @emph{Return value}:
6364 The result is of the same type and type parameters as @var{TSOURCE}.
6371 @section @code{MIN} --- Minimum value of an argument list
6372 @cindex @code{MIN} intrinsic
6375 @item @emph{Description}:
6376 Returns the argument with the smallest (most negative) value.
6378 @item @emph{Standard}:
6384 @item @emph{Syntax}:
6385 @code{RESULT = MIN(A1, A2 [, A3, ...])}
6387 @item @emph{Arguments}:
6388 @multitable @columnfractions .15 .80
6389 @item @var{A1} @tab The type shall be @code{INTEGER(*)} or
6391 @item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
6392 as @var{A1}. (As a GNU extension,
6393 arguments of different kinds are
6397 @item @emph{Return value}:
6398 The return value corresponds to the maximum value among the arguments,
6399 and has the same type and kind as the first argument.
6401 @item @emph{Specific names}:
6402 @multitable @columnfractions .20 .20 .20 .40
6403 @item Name @tab Argument @tab Return type @tab Standard
6404 @item @code{MIN0(I)} @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)} @tab F77 and later
6405 @item @code{AMIN0(I)} @tab @code{INTEGER(4) I} @tab @code{REAL(MIN(X))} @tab F77 and later
6406 @item @code{MIN1(X)} @tab @code{REAL(*) X} @tab @code{INT(MIN(X))} @tab F77 and later
6407 @item @code{AMIN1(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab F77 and later
6408 @item @code{DMIN1(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
6411 @item @emph{See also}:
6412 @ref{MAX}, @ref{MINLOC}, @ref{MINVAL}
6416 @section @code{MINEXPONENT} --- Minimum exponent of a real kind
6417 @cindex @code{MINEXPONENT} intrinsic
6418 @cindex minimum exponent
6419 @cindex exponent, minimum
6422 @item @emph{Description}:
6423 @code{MINEXPONENT(X)} returns the minimum exponent in the model of the
6426 @item @emph{Standard}:
6432 @item @emph{Syntax}:
6433 @code{RESULT = MINEXPONENT(X)}
6435 @item @emph{Arguments}:
6436 @multitable @columnfractions .15 .80
6437 @item @var{X} @tab shall be of type @code{REAL}.
6440 @item @emph{Return value}:
6441 The return value is of type @code{INTEGER} and of the default integer
6444 @item @emph{Example}:
6445 See @code{MAXEXPONENT} for an example.
6451 @section @code{MINLOC} --- Location of the minimum value within an array
6452 @cindex @code{MINLOC} intrinsic
6455 @item @emph{Description}:
6456 Determines the location of the element in the array with the minimum
6457 value, or, if the @var{DIM} argument is supplied, determines the
6458 locations of the minimum element along each row of the array in the
6459 @var{DIM} direction. If @var{MASK} is present, only the elements for
6460 which @var{MASK} is @code{.TRUE.} are considered. If more than one
6461 element in the array has the minimum value, the location returned is
6462 that of the first such element in array element order. If the array has
6463 zero size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
6464 the result is an array of zeroes. Similarly, if @var{DIM} is supplied
6465 and all of the elements of @var{MASK} along a given row are zero, the
6466 result value for that row is zero.
6468 @item @emph{Standard}:
6472 Transformational function
6474 @item @emph{Syntax}:
6475 @multitable @columnfractions .80
6476 @item @code{RESULT = MINLOC(ARRAY, DIM [, MASK])}
6477 @item @code{RESULT = MINLOC(ARRAY [, MASK])}
6480 @item @emph{Arguments}:
6481 @multitable @columnfractions .15 .80
6482 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER(*)},
6483 @code{REAL(*)}, or @code{CHARACTER(*)}.
6484 @item @var{DIM} @tab (Optional) Shall be a scalar of type
6485 @code{INTEGER(*)}, with a value between one
6486 and the rank of @var{ARRAY}, inclusive. It
6487 may not be an optional dummy argument.
6488 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL(*)},
6489 and conformable with @var{ARRAY}.
6492 @item @emph{Return value}:
6493 If @var{DIM} is absent, the result is a rank-one array with a length
6494 equal to the rank of @var{ARRAY}. If @var{DIM} is present, the result
6495 is an array with a rank one less than the rank of @var{ARRAY}, and a
6496 size corresponding to the size of @var{ARRAY} with the @var{DIM}
6497 dimension removed. If @var{DIM} is present and @var{ARRAY} has a rank
6498 of one, the result is a scalar. In all cases, the result is of default
6499 @code{INTEGER} type.
6501 @item @emph{See also}:
6502 @ref{MIN}, @ref{MINVAL}
6509 @section @code{MINVAL} --- Minimum value of an array
6510 @cindex @code{MINVAL} intrinsic
6513 @item @emph{Description}:
6514 Determines the minimum value of the elements in an array value, or, if
6515 the @var{DIM} argument is supplied, determines the minimum value along
6516 each row of the array in the @var{DIM} direction. If @var{MASK} is
6517 present, only the elements for which @var{MASK} is @code{.TRUE.} are
6518 considered. If the array has zero size, or all of the elements of
6519 @var{MASK} are @code{.FALSE.}, then the result is @code{HUGE(ARRAY)} if
6520 @var{ARRAY} is numeric, or a string of @code{CHAR(255)} characters if
6521 @var{ARRAY} is of character type.
6523 @item @emph{Standard}:
6527 Transformational function
6529 @item @emph{Syntax}:
6530 @multitable @columnfractions .80
6531 @item @code{RESULT = MINVAL(ARRAY, DIM [, MASK])}
6532 @item @code{RESULT = MINVAL(ARRAY [, MASK])}
6535 @item @emph{Arguments}:
6536 @multitable @columnfractions .15 .80
6537 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER(*)},
6538 @code{REAL(*)}, or @code{CHARACTER(*)}.
6539 @item @var{DIM} @tab (Optional) Shall be a scalar of type
6540 @code{INTEGER(*)}, with a value between one
6541 and the rank of @var{ARRAY}, inclusive. It
6542 may not be an optional dummy argument.
6543 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL(*)},
6544 and conformable with @var{ARRAY}.
6547 @item @emph{Return value}:
6548 If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
6549 is a scalar. If @var{DIM} is present, the result is an array with a
6550 rank one less than the rank of @var{ARRAY}, and a size corresponding to
6551 the size of @var{ARRAY} with the @var{DIM} dimension removed. In all
6552 cases, the result is of the same type and kind as @var{ARRAY}.
6554 @item @emph{See also}:
6555 @ref{MIN}, @ref{MINLOC}
6562 @section @code{MOD} --- Remainder function
6563 @cindex @code{MOD} intrinsic
6564 @cindex @code{AMOD} intrinsic
6565 @cindex @code{DMOD} intrinsic
6569 @item @emph{Description}:
6570 @code{MOD(A,P)} computes the remainder of the division of A by P. It is
6571 calculated as @code{A - (INT(A/P) * P)}.
6573 @item @emph{Standard}:
6579 @item @emph{Syntax}:
6580 @code{RESULT = MOD(A, P)}
6582 @item @emph{Arguments}:
6583 @multitable @columnfractions .15 .80
6584 @item @var{A} @tab shall be a scalar of type @code{INTEGER} or @code{REAL}
6585 @item @var{P} @tab shall be a scalar of the same type as @var{A} and not
6589 @item @emph{Return value}:
6590 The kind of the return value is the result of cross-promoting
6591 the kinds of the arguments.
6593 @item @emph{Example}:
6597 print *, mod(17.5,5.5)
6598 print *, mod(17.5d0,5.5)
6599 print *, mod(17.5,5.5d0)
6602 print *, mod(-17.5,5.5)
6603 print *, mod(-17.5d0,5.5)
6604 print *, mod(-17.5,5.5d0)
6607 print *, mod(17.5,-5.5)
6608 print *, mod(17.5d0,-5.5)
6609 print *, mod(17.5,-5.5d0)
6610 end program test_mod
6613 @item @emph{Specific names}:
6614 @multitable @columnfractions .20 .20 .20 .40
6615 @item Name @tab Arguments @tab Return type @tab Standard
6616 @item @code{AMOD(A,P)} @tab @code{REAL(4)} @tab @code{REAL(4)} @tab F95 and later
6617 @item @code{DMOD(A,P)} @tab @code{REAL(8)} @tab @code{REAL(8)} @tab F95 and later
6624 @section @code{MODULO} --- Modulo function
6625 @cindex @code{MODULO} intrinsic
6629 @item @emph{Description}:
6630 @code{MODULO(A,P)} computes the @var{A} modulo @var{P}.
6632 @item @emph{Standard}:
6638 @item @emph{Syntax}:
6639 @code{RESULT = MODULO(A, P)}
6641 @item @emph{Arguments}:
6642 @multitable @columnfractions .15 .80
6643 @item @var{A} @tab shall be a scalar of type @code{INTEGER} or @code{REAL}
6644 @item @var{P} @tab shall be a scalar of the same type and kind as @var{A}
6647 @item @emph{Return value}:
6648 The type and kind of the result are those of the arguments.
6650 @item If @var{A} and @var{P} are of type @code{INTEGER}:
6651 @code{MODULO(A,P)} has the value @var{R} such that @code{A=Q*P+R}, where
6652 @var{Q} is an integer and @var{R} is between 0 (inclusive) and @var{P}
6654 @item If @var{A} and @var{P} are of type @code{REAL}:
6655 @code{MODULO(A,P)} has the value of @code{A - FLOOR (A / P) * P}.
6657 In all cases, if @var{P} is zero the result is processor-dependent.
6659 @item @emph{Example}:
6662 print *, modulo(17,3)
6663 print *, modulo(17.5,5.5)
6665 print *, modulo(-17,3)
6666 print *, modulo(-17.5,5.5)
6668 print *, modulo(17,-3)
6669 print *, modulo(17.5,-5.5)
6670 end program test_mod
6678 @section @code{MOVE_ALLOC} --- Move allocation from one object to another
6679 @cindex @code{MOVE_ALLOC} intrinsic
6680 @cindex moving allocation
6681 @cindex allocation, moving
6684 @item @emph{Description}:
6685 @code{MOVE_ALLOC(SRC, DEST)} moves the allocation from @var{SRC} to
6686 @var{DEST}. @var{SRC} will become deallocated in the process.
6688 @item @emph{Standard}:
6694 @item @emph{Syntax}:
6695 @code{CALL MOVE_ALLOC(SRC, DEST)}
6697 @item @emph{Arguments}:
6698 @multitable @columnfractions .15 .80
6699 @item @var{SRC} @tab @code{ALLOCATABLE}, @code{INTENT(INOUT)}, may be
6700 of any type and kind.
6701 @item @var{DEST} @tab @code{ALLOCATABLE}, @code{INTENT(OUT)}, shall be
6702 of the same type, kind and rank as @var{SRC}
6705 @item @emph{Return value}:
6708 @item @emph{Example}:
6710 program test_move_alloc
6711 integer, allocatable :: a(:), b(:)
6715 call move_alloc(a, b)
6716 print *, allocated(a), allocated(b)
6718 end program test_move_alloc
6725 @section @code{MVBITS} --- Move bits from one integer to another
6726 @cindex @code{MVBITS} intrinsic
6727 @cindex bit operations
6730 @item @emph{Description}:
6731 Moves @var{LEN} bits from positions @var{FROMPOS} through
6732 @code{FROMPOS+LEN-1} of @var{FROM} to positions @var{TOPOS} through
6733 @code{TOPOS+LEN-1} of @var{TO}. The portion of argument @var{TO} not
6734 affected by the movement of bits is unchanged. The values of
6735 @code{FROMPOS+LEN-1} and @code{TOPOS+LEN-1} must be less than
6736 @code{BIT_SIZE(FROM)}.
6738 @item @emph{Standard}:
6744 @item @emph{Syntax}:
6745 @code{RESULT = MVBITS(FROM, FROMPOS, LEN, TO, TOPOS)}
6747 @item @emph{Arguments}:
6748 @multitable @columnfractions .15 .80
6749 @item @var{FROM} @tab The type shall be @code{INTEGER(*)}.
6750 @item @var{FROMPOS} @tab The type shall be @code{INTEGER(*)}.
6751 @item @var{LEN} @tab The type shall be @code{INTEGER(*)}.
6752 @item @var{TO} @tab The type shall be @code{INTEGER(*)}, of the
6753 same kind as @var{FROM}.
6754 @item @var{TOPOS} @tab The type shall be @code{INTEGER(*)}.
6757 @item @emph{Return value}:
6758 The return value is of type @code{INTEGER(*)} and of the same kind as
6761 @item @emph{See also}:
6762 @ref{IBCLR}, @ref{IBSET}, @ref{IBITS}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
6769 @section @code{NEAREST} --- Nearest representable number
6770 @cindex @code{NEAREST} intrinsic
6771 @cindex processor-representable number
6774 @item @emph{Description}:
6775 @code{NEAREST(X, S)} returns the processor-representable number nearest
6776 to @code{X} in the direction indicated by the sign of @code{S}.
6778 @item @emph{Standard}:
6784 @item @emph{Syntax}:
6785 @code{RESULT = NEAREST(X, S)}
6787 @item @emph{Arguments}:
6788 @multitable @columnfractions .15 .80
6789 @item @var{X} @tab shall be of type @code{REAL}.
6790 @item @var{S} @tab (Optional) shall be of type @code{REAL} and
6794 @item @emph{Return value}:
6795 The return value is of the same type as @code{X}. If @code{S} is
6796 positive, @code{NEAREST} returns the processor-representable number
6797 greater than @code{X} and nearest to it. If @code{S} is negative,
6798 @code{NEAREST} returns the processor-representable number smaller than
6799 @code{X} and nearest to it.
6801 @item @emph{Example}:
6803 program test_nearest
6805 x = nearest(42.0, 1.0)
6806 y = nearest(42.0, -1.0)
6807 write (*,"(3(G20.15))") x, y, x - y
6808 end program test_nearest
6815 @section @code{NEW_LINE} --- New line character
6816 @cindex @code{NEW_LINE} intrinsic
6817 @cindex @code{NEW_LINE} intrinsic
6820 @item @emph{Description}:
6821 @code{NEW_LINE(C)} returns the new-line character.
6823 @item @emph{Standard}:
6829 @item @emph{Syntax}:
6830 @code{RESULT = NEW_LINE(C)}
6832 @item @emph{Arguments}:
6833 @multitable @columnfractions .15 .80
6834 @item @var{C} @tab The argument shall be a scalar or array of the
6835 type @code{CHARACTER}.
6838 @item @emph{Return value}:
6839 Returns a @var{CHARACTER} scalar of length one with the new-line character of
6840 the same kind as parameter @var{C}.
6842 @item @emph{Example}:
6846 write(*,'(A)') 'This is record 1.'//NEW_LINE('A')//'This is record 2.'
6854 @section @code{NINT} --- Nearest whole number
6855 @cindex @code{NINT} intrinsic
6856 @cindex @code{IDNINT} intrinsic
6857 @cindex whole number
6860 @item @emph{Description}:
6861 @code{NINT(X)} rounds its argument to the nearest whole number.
6863 @item @emph{Standard}:
6869 @item @emph{Syntax}:
6870 @code{RESULT = NINT(X)}
6872 @item @emph{Arguments}:
6873 @multitable @columnfractions .15 .80
6874 @item @var{X} @tab The type of the argument shall be @code{REAL}.
6877 @item @emph{Return value}:
6878 Returns @var{A} with the fractional portion of its magnitude eliminated by
6879 rounding to the nearest whole number and with its sign preserved,
6880 converted to an @code{INTEGER} of the default kind.
6882 @item @emph{Example}:
6889 print *, nint(x4), idnint(x8)
6890 end program test_nint
6893 @item @emph{Specific names}:
6894 @multitable @columnfractions .33 .33 .33
6895 @item Name @tab Argument @tab Standard
6896 @item @code{IDNINT(X)} @tab @code{REAL(8)} @tab F95 and later
6899 @item @emph{See also}:
6900 @ref{CEILING}, @ref{FLOOR}
6906 @section @code{NOT} --- Logical negation
6907 @cindex @code{NOT} intrinsic
6908 @cindex bit operations
6911 @item @emph{Description}:
6912 @code{NOT} returns the bitwise boolean inverse of @var{I}.
6914 @item @emph{Standard}:
6920 @item @emph{Syntax}:
6921 @code{RESULT = NOT(I)}
6923 @item @emph{Arguments}:
6924 @multitable @columnfractions .15 .80
6925 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
6928 @item @emph{Return value}:
6929 The return type is @code{INTEGER(*)}, of the same kind as the
6932 @item @emph{See also}:
6933 @ref{IAND}, @ref{IEOR}, @ref{IOR}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}
6941 @section @code{NULL} --- Function that returns an disassociated pointer
6942 @cindex @code{NULL} intrinsic
6943 @cindex undocumented intrinsic
6945 Intrinsic implemented, documentation pending.
6948 @item @emph{Description}:
6949 @item @emph{Standard}:
6953 Transformational function
6955 @item @emph{Syntax}:
6956 @item @emph{Arguments}:
6957 @item @emph{Return value}:
6958 @item @emph{Example}:
6959 @item @emph{See also}:
6967 @section @code{OR} --- Bitwise logical OR
6968 @cindex @code{OR} intrinsic
6969 @cindex bit operations
6972 @item @emph{Description}:
6973 Bitwise logical @code{OR}.
6975 This intrinsic routine is provided for backwards compatibility with
6976 GNU Fortran 77. For integer arguments, programmers should consider
6977 the use of the @ref{IOR} intrinsic defined by the Fortran standard.
6979 @item @emph{Standard}:
6983 Non-elemental function
6985 @item @emph{Syntax}:
6986 @code{RESULT = OR(X, Y)}
6988 @item @emph{Arguments}:
6989 @multitable @columnfractions .15 .80
6990 @item @var{X} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
6991 @item @var{Y} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
6994 @item @emph{Return value}:
6995 The return type is either @code{INTEGER(*)} or @code{LOGICAL}
6996 after cross-promotion of the arguments.
6998 @item @emph{Example}:
7001 LOGICAL :: T = .TRUE., F = ..FALSE.
7003 DATA a / Z'F' /, b / Z'3' /
7005 WRITE (*,*) OR(T, T), OR(T, F), OR(F, T), OR(F, F)
7006 WRITE (*,*) OR(a, b)
7010 @item @emph{See also}:
7011 F95 elemental function: @ref{IOR}
7018 @section @code{PACK} --- Pack an array into an array of rank one
7019 @cindex @code{PACK} intrinsic
7020 @cindex undocumented intrinsic
7022 Intrinsic implemented, documentation pending.
7025 @item @emph{Description}:
7026 @item @emph{Standard}:
7030 Transformational function
7032 @item @emph{Syntax}:
7033 @item @emph{Arguments}:
7034 @item @emph{Return value}:
7035 @item @emph{Example}:
7036 @item @emph{Specific names}:
7037 @item @emph{See also}:
7044 @section @code{PERROR} --- Print system error message
7045 @cindex @code{PERROR} intrinsic
7048 @item @emph{Description}:
7049 Prints (on the C @code{stderr} stream) a newline-terminated error
7050 message corresponding to the last system error. This is prefixed by
7051 @var{STRING}, a colon and a space. See @code{perror(3)}.
7053 @item @emph{Standard}:
7059 @item @emph{Syntax}:
7060 @code{CALL PERROR(STRING)}
7062 @item @emph{Arguments}:
7063 @multitable @columnfractions .15 .80
7064 @item @var{STRING} @tab A scalar of default @code{CHARACTER} type.
7067 @item @emph{See also}:
7074 @section @code{PRECISION} --- Decimal precision of a real kind
7075 @cindex @code{PRECISION} intrinsic
7076 @cindex precision of a real variable
7079 @item @emph{Description}:
7080 @code{PRECISION(X)} returns the decimal precision in the model of the
7083 @item @emph{Standard}:
7089 @item @emph{Syntax}:
7090 @code{RESULT = PRECISION(X)}
7092 @item @emph{Arguments}:
7093 @multitable @columnfractions .15 .80
7094 @item @var{X} @tab shall be of type @code{REAL} or @code{COMPLEX}.
7097 @item @emph{Return value}:
7098 The return value is of type @code{INTEGER} and of the default integer
7101 @item @emph{Example}:
7103 program prec_and_range
7104 real(kind=4) :: x(2)
7105 complex(kind=8) :: y
7107 print *, precision(x), range(x)
7108 print *, precision(y), range(y)
7109 end program prec_and_range
7116 @section @code{PRESENT} --- Determine whether an optional argument is specified
7117 @cindex @code{PRESENT} intrinsic
7118 @cindex undocumented intrinsic
7120 Intrinsic implemented, documentation pending.
7123 @item @emph{Description}:
7124 @item @emph{Standard}:
7130 @item @emph{Syntax}:
7131 @item @emph{Arguments}:
7132 @item @emph{Return value}:
7133 @item @emph{Example}:
7134 @item @emph{See also}:
7140 @section @code{PRODUCT} --- Product of array elements
7141 @cindex @code{PRODUCT} intrinsic
7142 @cindex undocumented intrinsic
7144 Intrinsic implemented, documentation pending.
7147 @item @emph{Description}:
7148 @item @emph{Standard}:
7152 Transformational function
7154 @item @emph{Syntax}:
7155 @item @emph{Arguments}:
7156 @item @emph{Return value}:
7157 @item @emph{Example}:
7158 @item @emph{Specific names}:
7159 @item @emph{See also}:
7166 @section @code{RADIX} --- Base of a model number
7167 @cindex @code{RADIX} intrinsic
7171 @item @emph{Description}:
7172 @code{RADIX(X)} returns the base of the model representing the entity @var{X}.
7174 @item @emph{Standard}:
7180 @item @emph{Syntax}:
7181 @code{RESULT = RADIX(X)}
7183 @item @emph{Arguments}:
7184 @multitable @columnfractions .15 .80
7185 @item @var{X} @tab Shall be of type @code{INTEGER} or @code{REAL}
7188 @item @emph{Return value}:
7189 The return value is a scalar of type @code{INTEGER} and of the default
7192 @item @emph{Example}:
7195 print *, "The radix for the default integer kind is", radix(0)
7196 print *, "The radix for the default real kind is", radix(0.0)
7197 end program test_radix
7205 @section @code{RAN} --- Real pseudo-random number
7206 @cindex @code{RAN} intrinsic
7207 @cindex random numbers
7210 @item @emph{Description}:
7211 For compatibility with HP FORTRAN 77/iX, the @code{RAN} intrinsic is
7212 provided as an alias for @code{RAND}. See @ref{RAND} for complete
7215 @item @emph{Standard}:
7219 Non-elemental function
7221 @item @emph{See also}:
7222 @ref{RAND}, @ref{RANDOM_NUMBER}
7228 @section @code{RAND} --- Real pseudo-random number
7229 @cindex @code{RAND} intrinsic
7230 @cindex random numbers
7233 @item @emph{Description}:
7234 @code{RAND(FLAG)} returns a pseudo-random number from a uniform
7235 distribution between 0 and 1. If @var{FLAG} is 0, the next number
7236 in the current sequence is returned; if @var{FLAG} is 1, the generator
7237 is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
7238 it is used as a new seed with @code{SRAND}.
7240 @item @emph{Standard}:
7244 Non-elemental function
7246 @item @emph{Syntax}:
7247 @code{RESULT = RAND(FLAG)}
7249 @item @emph{Arguments}:
7250 @multitable @columnfractions .15 .80
7251 @item @var{FLAG} @tab shall be a scalar @code{INTEGER} of kind 4.
7254 @item @emph{Return value}:
7255 The return value is of @code{REAL} type and the default kind.
7257 @item @emph{Example}:
7260 integer,parameter :: seed = 86456
7263 print *, rand(), rand(), rand(), rand()
7264 print *, rand(seed), rand(), rand(), rand()
7265 end program test_rand
7268 @item @emph{See also}:
7269 @ref{SRAND}, @ref{RANDOM_NUMBER}
7276 @section @code{RANDOM_NUMBER} --- Pseudo-random number
7277 @cindex @code{RANDOM_NUMBER} intrinsic
7278 @cindex random numbers
7280 Intrinsic implemented, documentation pending.
7283 @item @emph{Description}:
7284 @item @emph{Standard}:
7288 Elemental subroutine
7290 @item @emph{Syntax}:
7291 @item @emph{Arguments}:
7292 @item @emph{Return value}:
7293 @item @emph{Example}:
7294 @item @emph{See also}:
7301 @section @code{RANDOM_SEED} --- Initialize a pseudo-random number sequence
7302 @cindex @code{RANDOM_SEED} intrinsic
7303 @cindex random numbers
7305 Intrinsic implemented, documentation pending.
7308 @item @emph{Description}:
7309 @item @emph{Standard}:
7315 @item @emph{Syntax}:
7316 @item @emph{Arguments}:
7317 @item @emph{Return value}:
7318 @item @emph{Example}:
7319 @item @emph{See also}:
7326 @section @code{RANGE} --- Decimal exponent range of a real kind
7327 @cindex @code{RANGE} intrinsic
7328 @cindex range of a real variable
7331 @item @emph{Description}:
7332 @code{RANGE(X)} returns the decimal exponent range in the model of the
7335 @item @emph{Standard}:
7341 @item @emph{Syntax}:
7342 @code{RESULT = RANGE(X)}
7344 @item @emph{Arguments}:
7345 @multitable @columnfractions .15 .80
7346 @item @var{X} @tab shall be of type @code{REAL} or @code{COMPLEX}.
7349 @item @emph{Return value}:
7350 The return value is of type @code{INTEGER} and of the default integer
7353 @item @emph{Example}:
7354 See @code{PRECISION} for an example.
7360 @section @code{REAL} --- Convert to real type
7361 @cindex @code{REAL} intrinsic
7362 @cindex @code{REALPART} intrinsic
7366 @item @emph{Description}:
7367 @code{REAL(X [, KIND])} converts its argument @var{X} to a real type. The
7368 @code{REALPART(X)} function is provided for compatibility with @command{g77},
7369 and its use is strongly discouraged.
7371 @item @emph{Standard}:
7377 @item @emph{Syntax}:
7378 @multitable @columnfractions .30 .80
7379 @item @code{RESULT = REAL(X [, KIND])}
7380 @item @code{RESULT = REALPART(Z)}
7383 @item @emph{Arguments}:
7384 @multitable @columnfractions .15 .80
7385 @item @var{X} @tab shall be @code{INTEGER(*)}, @code{REAL(*)}, or
7387 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
7388 expression indicating the kind parameter of
7392 @item @emph{Return value}:
7393 These functions return a @code{REAL(*)} variable or array under
7394 the following rules:
7398 @code{REAL(X)} is converted to a default real type if @var{X} is an
7399 integer or real variable.
7401 @code{REAL(X)} is converted to a real type with the kind type parameter
7402 of @var{X} if @var{X} is a complex variable.
7404 @code{REAL(X, KIND)} is converted to a real type with kind type
7405 parameter @var{KIND} if @var{X} is a complex, integer, or real
7409 @item @emph{Example}:
7412 complex :: x = (1.0, 2.0)
7413 print *, real(x), real(x,8), realpart(x)
7414 end program test_real
7417 @item @emph{See also}:
7418 @ref{DBLE}, @ref{DFLOAT}, @ref{FLOAT}
7425 @section @code{RENAME} --- Rename a file
7426 @cindex @code{RENAME} intrinsic
7427 @cindex file system operations
7430 @item @emph{Description}:
7431 Renames a file from file @var{PATH1} to @var{PATH2}. A null
7432 character (@code{CHAR(0)}) can be used to mark the end of the names in
7433 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
7434 names are ignored. If the @var{STATUS} argument is supplied, it
7435 contains 0 on success or a nonzero error code upon return; see
7438 @item @emph{Standard}:
7444 @item @emph{Syntax}:
7445 @code{CALL RENAME(PATH1, PATH2 [, STATUS])}
7447 @item @emph{Arguments}:
7448 @multitable @columnfractions .15 .80
7449 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
7450 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
7451 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
7454 @item @emph{See also}:
7462 @section @code{REPEAT} --- Repeated string concatenation
7463 @cindex @code{REPEAT} intrinsic
7464 @cindex string manipulation
7466 Intrinsic implemented, documentation pending.
7469 @item @emph{Description}:
7470 @item @emph{Standard}:
7474 Transformational function
7476 @item @emph{Syntax}:
7477 @item @emph{Arguments}:
7478 @item @emph{Return value}:
7479 @item @emph{Example}:
7480 @item @emph{See also}:
7487 @section @code{RESHAPE} --- Function to reshape an array
7488 @cindex @code{RESHAPE} intrinsic
7489 @cindex array manipulation
7491 Intrinsic implemented, documentation pending.
7494 @item @emph{Description}:
7495 @item @emph{Standard}:
7499 Transformational function
7501 @item @emph{Syntax}:
7502 @item @emph{Arguments}:
7503 @item @emph{Return value}:
7504 @item @emph{Example}:
7505 @item @emph{See also}:
7512 @section @code{RRSPACING} --- Reciprocal of the relative spacing
7513 @cindex @code{RRSPACING} intrinsic
7516 @item @emph{Description}:
7517 @code{RRSPACING(X)} returns the reciprocal of the relative spacing of
7518 model numbers near @var{X}.
7520 @item @emph{Standard}:
7526 @item @emph{Syntax}:
7527 @code{RESULT = RRSPACING(X)}
7529 @item @emph{Arguments}:
7530 @multitable @columnfractions .15 .80
7531 @item @var{X} @tab shall be of type @code{REAL}.
7534 @item @emph{Return value}:
7535 The return value is of the same type and kind as @var{X}.
7536 The value returned is equal to
7537 @code{ABS(FRACTION(X)) * FLOAT(RADIX(X))**DIGITS(X)}.
7544 @section @code{RSHIFT} --- Right shift bits
7545 @cindex @code{RSHIFT} intrinsic
7546 @cindex bit operations
7549 @item @emph{Description}:
7550 @code{RSHIFT} returns a value corresponding to @var{I} with all of the
7551 bits shifted right by @var{SHIFT} places. If the absolute value of
7552 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
7553 Bits shifted out from the left end are lost; zeros are shifted in from
7556 This function has been superseded by the @code{ISHFT} intrinsic, which
7557 is standard in Fortran 95 and later.
7559 @item @emph{Standard}:
7565 @item @emph{Syntax}:
7566 @code{RESULT = RSHIFT(I, SHIFT)}
7568 @item @emph{Arguments}:
7569 @multitable @columnfractions .15 .80
7570 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
7571 @item @var{SHIFT} @tab The type shall be @code{INTEGER(*)}.
7574 @item @emph{Return value}:
7575 The return value is of type @code{INTEGER(*)} and of the same kind as
7578 @item @emph{See also}:
7579 @ref{ISHFT}, @ref{ISHFTC}, @ref{LSHIFT}
7586 @section @code{SCALE} --- Scale a real value
7587 @cindex @code{SCALE} intrinsic
7590 @item @emph{Description}:
7591 @code{SCALE(X,I)} returns @code{X * RADIX(X)**I}.
7593 @item @emph{Standard}:
7599 @item @emph{Syntax}:
7600 @code{RESULT = SCALE(X, I)}
7602 @item @emph{Arguments}:
7603 @multitable @columnfractions .15 .80
7604 @item @var{X} @tab The type of the argument shall be a @code{REAL}.
7605 @item @var{I} @tab The type of the argument shall be a @code{INTEGER}.
7608 @item @emph{Return value}:
7609 The return value is of the same type and kind as @var{X}.
7610 Its value is @code{X * RADIX(X)**I}.
7612 @item @emph{Example}:
7615 real :: x = 178.1387e-4
7617 print *, scale(x,i), x*radix(x)**i
7618 end program test_scale
7625 @section @code{SCAN} --- Scan a string for the presence of a set of characters
7626 @cindex @code{SCAN} intrinsic
7627 @cindex string manipulation
7629 Intrinsic implemented, documentation pending.
7632 @item @emph{Description}:
7633 @item @emph{Standard}:
7639 @item @emph{Syntax}:
7640 @item @emph{Arguments}:
7641 @item @emph{Return value}:
7642 @item @emph{Example}:
7643 @item @emph{See also}:
7650 @section @code{SECNDS} --- Time function
7651 @cindex @code{SECNDS} intrinsic
7652 @cindex time, current
7653 @cindex current time
7656 @item @emph{Description}:
7657 @code{SECNDS(X)} gets the time in seconds from the real-time system clock.
7658 @var{X} is a reference time, also in seconds. If this is zero, the time in
7659 seconds from midnight is returned. This function is non-standard and its
7662 @item @emph{Standard}:
7668 @item @emph{Syntax}:
7669 @code{RESULT = SECNDS (X)}
7671 @item @emph{Arguments}:
7672 @multitable @columnfractions .15 .80
7673 @item Name @tab Type
7674 @item @var{T} @tab REAL(4)
7675 @item @var{X} @tab REAL(4)
7678 @item @emph{Return value}:
7681 @item @emph{Example}:
7685 print *, secnds (0.0) ! seconds since midnight
7686 t1 = secnds (0.0) ! reference time
7687 do i = 1, 10000000 ! do something
7689 t2 = secnds (t1) ! elapsed time
7690 print *, "Something took ", t2, " seconds."
7691 end program test_secnds
7697 @node SELECTED_INT_KIND
7698 @section @code{SELECTED_INT_KIND} --- Choose integer kind
7699 @cindex @code{SELECTED_INT_KIND} intrinsic
7700 @cindex integer kind
7703 @item @emph{Description}:
7704 @code{SELECTED_INT_KIND(I)} return the kind value of the smallest integer
7705 type that can represent all values ranging from @math{-10^I} (exclusive)
7706 to @math{10^I} (exclusive). If there is no integer kind that accommodates
7707 this range, @code{SELECTED_INT_KIND} returns @math{-1}.
7709 @item @emph{Standard}:
7713 Transformational function
7715 @item @emph{Syntax}:
7716 @code{RESULT = SELECTED_INT_KIND(I)}
7718 @item @emph{Arguments}:
7719 @multitable @columnfractions .15 .80
7720 @item @var{I} @tab shall be a scalar and of type @code{INTEGER}.
7723 @item @emph{Example}:
7725 program large_integers
7726 integer,parameter :: k5 = selected_int_kind(5)
7727 integer,parameter :: k15 = selected_int_kind(15)
7728 integer(kind=k5) :: i5
7729 integer(kind=k15) :: i15
7731 print *, huge(i5), huge(i15)
7733 ! The following inequalities are always true
7734 print *, huge(i5) >= 10_k5**5-1
7735 print *, huge(i15) >= 10_k15**15-1
7736 end program large_integers
7742 @node SELECTED_REAL_KIND
7743 @section @code{SELECTED_REAL_KIND} --- Choose real kind
7744 @cindex @code{SELECTED_REAL_KIND} intrinsic
7748 @item @emph{Description}:
7749 @code{SELECTED_REAL_KIND(P,R)} return the kind value of a real data type
7750 with decimal precision greater of at least @code{P} digits and exponent
7751 range greater at least @code{R}.
7753 @item @emph{Standard}:
7757 Transformational function
7759 @item @emph{Syntax}:
7760 @code{RESULT = SELECTED_REAL_KIND(P, R)}
7762 @item @emph{Arguments}:
7763 @multitable @columnfractions .15 .80
7764 @item @var{P} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
7765 @item @var{R} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
7767 At least one argument shall be present.
7769 @item @emph{Return value}:
7771 @code{SELECTED_REAL_KIND} returns the value of the kind type parameter of
7772 a real data type with decimal precision of at least @code{P} digits and a
7773 decimal exponent range of at least @code{R}. If more than one real data
7774 type meet the criteria, the kind of the data type with the smallest
7775 decimal precision is returned. If no real data type matches the criteria,
7778 @item -1 if the processor does not support a real data type with a
7779 precision greater than or equal to @code{P}
7780 @item -2 if the processor does not support a real type with an exponent
7781 range greater than or equal to @code{R}
7782 @item -3 if neither is supported.
7785 @item @emph{Example}:
7788 integer,parameter :: p6 = selected_real_kind(6)
7789 integer,parameter :: p10r100 = selected_real_kind(10,100)
7790 integer,parameter :: r400 = selected_real_kind(r=400)
7792 real(kind=p10r100) :: y
7793 real(kind=r400) :: z
7795 print *, precision(x), range(x)
7796 print *, precision(y), range(y)
7797 print *, precision(z), range(z)
7798 end program real_kinds
7805 @section @code{SET_EXPONENT} --- Set the exponent of the model
7806 @cindex @code{SET_EXPONENT} intrinsic
7807 @cindex exponent part of a real number
7810 @item @emph{Description}:
7811 @code{SET_EXPONENT(X, I)} returns the real number whose fractional part
7812 is that that of @var{X} and whose exponent part is @var{I}.
7814 @item @emph{Standard}:
7820 @item @emph{Syntax}:
7821 @code{RESULT = SET_EXPONENT(X, I)}
7823 @item @emph{Arguments}:
7824 @multitable @columnfractions .15 .80
7825 @item @var{X} @tab shall be of type @code{REAL}.
7826 @item @var{I} @tab shall be of type @code{INTEGER}.
7829 @item @emph{Return value}:
7830 The return value is of the same type and kind as @var{X}.
7831 The real number whose fractional part
7832 is that that of @var{X} and whose exponent part if @var{I} is returned;
7833 it is @code{FRACTION(X) * RADIX(X)**I}.
7835 @item @emph{Example}:
7838 real :: x = 178.1387e-4
7840 print *, set_exponent(x), fraction(x) * radix(x)**i
7841 end program test_setexp
7849 @section @code{SHAPE} --- Determine the shape of an array
7850 @cindex @code{SHAPE} intrinsic
7851 @cindex array manipulation
7853 Intrinsic implemented, documentation pending.
7856 @item @emph{Description}:
7857 @item @emph{Standard}:
7863 @item @emph{Syntax}:
7864 @item @emph{Arguments}:
7865 @item @emph{Return value}:
7866 @item @emph{Example}:
7867 @item @emph{See also}:
7874 @section @code{SIGN} --- Sign copying function
7875 @cindex @code{SIGN} intrinsic
7876 @cindex @code{ISIGN} intrinsic
7877 @cindex @code{DSIGN} intrinsic
7878 @cindex sign copying
7881 @item @emph{Description}:
7882 @code{SIGN(A,B)} returns the value of @var{A} with the sign of @var{B}.
7884 @item @emph{Standard}:
7890 @item @emph{Syntax}:
7891 @code{RESULT = SIGN(A, B)}
7893 @item @emph{Arguments}:
7894 @multitable @columnfractions .15 .80
7895 @item @var{A} @tab shall be a scalar of type @code{INTEGER} or @code{REAL}
7896 @item @var{B} @tab shall be a scalar of the same type and kind as @var{A}
7899 @item @emph{Return value}:
7900 The kind of the return value is that of @var{A} and @var{B}.
7901 If @math{B\ge 0} then the result is @code{ABS(A)}, else
7902 it is @code{-ABS(A)}.
7904 @item @emph{Example}:
7907 print *, sign(-12,1)
7908 print *, sign(-12,0)
7909 print *, sign(-12,-1)
7911 print *, sign(-12.,1.)
7912 print *, sign(-12.,0.)
7913 print *, sign(-12.,-1.)
7914 end program test_sign
7917 @item @emph{Specific names}:
7918 @multitable @columnfractions .20 .20 .20 .40
7919 @item Name @tab Arguments @tab Return type @tab Standard
7920 @item @code{ISIGN(A,P)} @tab @code{INTEGER(4)} @tab @code{INTEGER(4)} @tab f95, gnu
7921 @item @code{DSIGN(A,P)} @tab @code{REAL(8)} @tab @code{REAL(8)} @tab f95, gnu
7928 @section @code{SIGNAL} --- Signal handling subroutine (or function)
7929 @cindex @code{SIGNAL} intrinsic
7930 @cindex signal handling
7933 @item @emph{Description}:
7934 @code{SIGNAL(NUMBER, HANDLER [, STATUS])} causes external subroutine
7935 @var{HANDLER} to be executed with a single integer argument when signal
7936 @var{NUMBER} occurs. If @var{HANDLER} is an integer, it can be used to
7937 turn off handling of signal @var{NUMBER} or revert to its default
7938 action. See @code{signal(2)}.
7940 If @code{SIGNAL} is called as a subroutine and the @var{STATUS} argument
7941 is supplied, it is set to the value returned by @code{signal(2)}.
7943 @item @emph{Standard}:
7947 subroutine, non-elemental function
7949 @item @emph{Syntax}:
7950 @multitable @columnfractions .80
7951 @item @code{CALL SIGNAL(NUMBER, HANDLER [, STATUS])}
7952 @item @code{STATUS = SIGNAL(NUMBER, HANDLER)}
7955 @item @emph{Arguments}:
7956 @multitable @columnfractions .15 .80
7957 @item @var{NUMBER} @tab shall be a scalar integer, with @code{INTENT(IN)}
7958 @item @var{HANDLER}@tab Signal handler (@code{INTEGER FUNCTION} or
7959 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar.
7960 @code{INTEGER}. It is @code{INTENT(IN)}.
7961 @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
7962 integer. It has @code{INTENT(OUT)}.
7965 @item @emph{Return value}:
7966 The @code{SIGNAL} function returns the value returned by @code{signal(2)}.
7968 @item @emph{Example}:
7972 external handler_print
7974 call signal (12, handler_print)
7978 end program test_signal
7985 @section @code{SIN} --- Sine function
7986 @cindex @code{SIN} intrinsic
7987 @cindex @code{DSIN} intrinsic
7988 @cindex @code{ZSIN} intrinsic
7989 @cindex @code{CDSIN} intrinsic
7990 @cindex trigonometric functions
7993 @item @emph{Description}:
7994 @code{SIN(X)} computes the sine of @var{X}.
7996 @item @emph{Standard}:
8002 @item @emph{Syntax}:
8003 @code{RESULT = SIN(X)}
8005 @item @emph{Arguments}:
8006 @multitable @columnfractions .15 .80
8007 @item @var{X} @tab The type shall be @code{REAL(*)} or
8011 @item @emph{Return value}:
8012 The return value has same type and kind as @var{X}.
8014 @item @emph{Example}:
8019 end program test_sin
8022 @item @emph{Specific names}:
8023 @multitable @columnfractions .20 .20 .20 .40
8024 @item Name @tab Argument @tab Return type @tab Standard
8025 @item @code{DSIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
8026 @item @code{CSIN(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab f95, gnu
8027 @item @code{ZSIN(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
8028 @item @code{CDSIN(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
8031 @item @emph{See also}:
8038 @section @code{SINH} --- Hyperbolic sine function
8039 @cindex @code{SINH} intrinsic
8040 @cindex @code{DSINH} intrinsic
8041 @cindex hyperbolic sine
8044 @item @emph{Description}:
8045 @code{SINH(X)} computes the hyperbolic sine of @var{X}.
8047 @item @emph{Standard}:
8053 @item @emph{Syntax}:
8054 @code{RESULT = SINH(X)}
8056 @item @emph{Arguments}:
8057 @multitable @columnfractions .15 .80
8058 @item @var{X} @tab The type shall be @code{REAL(*)}.
8061 @item @emph{Return value}:
8062 The return value is of type @code{REAL(*)}.
8064 @item @emph{Example}:
8067 real(8) :: x = - 1.0_8
8069 end program test_sinh
8072 @item @emph{Specific names}:
8073 @multitable @columnfractions .20 .20 .20 .40
8074 @item Name @tab Argument @tab Return type @tab Standard
8075 @item @code{DSINH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
8078 @item @emph{See also}:
8085 @section @code{SIZE} --- Determine the size of an array
8086 @cindex @code{SIZE} intrinsic
8087 @cindex array manipulation
8089 Intrinsic implemented, documentation pending.
8092 @item @emph{Description}:
8093 @item @emph{Standard}:
8099 @item @emph{Syntax}:
8100 @item @emph{Arguments}:
8101 @item @emph{Return value}:
8102 @item @emph{Example}:
8103 @item @emph{See also}:
8109 @section @code{SNGL} --- Convert double precision real to default real
8110 @cindex @code{SNGL} intrinsic
8111 @cindex conversion function (real)
8114 @item @emph{Description}:
8115 @code{SNGL(A)} converts the double precision real @var{A}
8116 to a default real value. This is an archaic form of @code{REAL}
8117 that is specific to one type for @var{A}.
8119 @item @emph{Standard}:
8125 @item @emph{Syntax}:
8126 @code{RESULT = SNGL(A)}
8128 @item @emph{Arguments}:
8129 @multitable @columnfractions .15 .80
8130 @item @var{A} @tab The type shall be a double precision @code{REAL}.
8133 @item @emph{Return value}:
8134 The return value is of type default @code{REAL}.
8136 @item @emph{See also}:
8143 @section @code{SPACING} --- Smallest distance between two numbers of a given type
8144 @cindex @code{SPACING} intrinsic
8145 @cindex undocumented intrinsic
8147 Intrinsic implemented, documentation pending.
8150 @item @emph{Description}:
8151 @item @emph{Standard}:
8157 @item @emph{Syntax}:
8158 @item @emph{Arguments}:
8159 @item @emph{Return value}:
8160 @item @emph{Example}:
8161 @item @emph{See also}:
8168 @section @code{SPREAD} --- Add a dimension to an array
8169 @cindex @code{SPREAD} intrinsic
8170 @cindex array manipulation
8172 Intrinsic implemented, documentation pending.
8175 @item @emph{Description}:
8176 @item @emph{Standard}:
8180 Transformational function
8182 @item @emph{Syntax}:
8183 @item @emph{Arguments}:
8184 @item @emph{Return value}:
8185 @item @emph{Example}:
8186 @item @emph{See also}:
8193 @section @code{SQRT} --- Square-root function
8194 @cindex @code{SQRT} intrinsic
8195 @cindex @code{DSQRT} intrinsic
8196 @cindex @code{CSQRT} intrinsic
8197 @cindex @code{ZSQRT} intrinsic
8198 @cindex @code{CDSQRT} intrinsic
8202 @item @emph{Description}:
8203 @code{SQRT(X)} computes the square root of @var{X}.
8205 @item @emph{Standard}:
8211 @item @emph{Syntax}:
8212 @code{RESULT = SQRT(X)}
8214 @item @emph{Arguments}:
8215 @multitable @columnfractions .15 .80
8216 @item @var{X} @tab The type shall be @code{REAL(*)} or
8220 @item @emph{Return value}:
8221 The return value is of type @code{REAL(*)} or @code{COMPLEX(*)}.
8222 The kind type parameter is the same as @var{X}.
8224 @item @emph{Example}:
8227 real(8) :: x = 2.0_8
8228 complex :: z = (1.0, 2.0)
8231 end program test_sqrt
8234 @item @emph{Specific names}:
8235 @multitable @columnfractions .20 .20 .20 .40
8236 @item Name @tab Argument @tab Return type @tab Standard
8237 @item @code{DSQRT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
8238 @item @code{CSQRT(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab F95 and later
8239 @item @code{ZSQRT(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
8240 @item @code{CDSQRT(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
8247 @section @code{SRAND} --- Reinitialize the random number generator
8248 @cindex @code{SRAND} intrinsic
8249 @cindex random numbers
8252 @item @emph{Description}:
8253 @code{SRAND} reinitializes the pseudo-random number generator
8254 called by @code{RAND} and @code{IRAND}. The new seed used by the
8255 generator is specified by the required argument @var{SEED}.
8257 @item @emph{Standard}:
8261 non-elemental subroutine
8263 @item @emph{Syntax}:
8264 @code{CALL SRAND(SEED)}
8266 @item @emph{Arguments}:
8267 @multitable @columnfractions .15 .80
8268 @item @var{SEED} @tab shall be a scalar @code{INTEGER(kind=4)}.
8271 @item @emph{Return value}:
8274 @item @emph{Example}:
8275 See @code{RAND} and @code{IRAND} for examples.
8278 The Fortran 2003 standard specifies the intrinsic @code{RANDOM_SEED} to
8279 initialize the pseudo-random numbers generator and @code{RANDOM_NUMBER}
8280 to generate pseudo-random numbers. Please note that in
8281 GNU Fortran, these two sets of intrinsics (@code{RAND},
8282 @code{IRAND} and @code{SRAND} on the one hand, @code{RANDOM_NUMBER} and
8283 @code{RANDOM_SEED} on the other hand) access two independent
8284 pseudo-random number generators.
8286 @item @emph{See also}:
8287 @ref{RAND}, @ref{RANDOM_SEED}, @ref{RANDOM_NUMBER}
8294 @section @code{STAT} --- Get file status
8295 @cindex @code{STAT} intrinsic
8296 @cindex file system operations
8299 @item @emph{Description}:
8300 This function returns information about a file. No permissions are required on
8301 the file itself, but execute (search) permission is required on all of the
8302 directories in path that lead to the file.
8304 The elements that are obtained and stored in the array @code{BUFF}:
8305 @multitable @columnfractions .15 .80
8306 @item @code{buff(1)} @tab Device ID
8307 @item @code{buff(2)} @tab Inode number
8308 @item @code{buff(3)} @tab File mode
8309 @item @code{buff(4)} @tab Number of links
8310 @item @code{buff(5)} @tab Owner's uid
8311 @item @code{buff(6)} @tab Owner's gid
8312 @item @code{buff(7)} @tab ID of device containing directory entry for file (0 if not available)
8313 @item @code{buff(8)} @tab File size (bytes)
8314 @item @code{buff(9)} @tab Last access time
8315 @item @code{buff(10)} @tab Last modification time
8316 @item @code{buff(11)} @tab Last file status change time
8317 @item @code{buff(12)} @tab Preferred I/O block size (-1 if not available)
8318 @item @code{buff(13)} @tab Number of blocks allocated (-1 if not available)
8321 Not all these elements are relevant on all systems.
8322 If an element is not relevant, it is returned as 0.
8325 @item @emph{Standard}:
8329 Non-elemental subroutine
8331 @item @emph{Syntax}:
8332 @code{CALL STAT(FILE,BUFF[,STATUS])}
8334 @item @emph{Arguments}:
8335 @multitable @columnfractions .15 .80
8336 @item @var{FILE} @tab The type shall be @code{CHARACTER(*)}, a valid path within the file system.
8337 @item @var{BUFF} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
8338 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0
8339 on success and a system specific error code otherwise.
8342 @item @emph{Example}:
8345 INTEGER, DIMENSION(13) :: buff
8348 CALL STAT("/etc/passwd", buff, status)
8350 IF (status == 0) THEN
8351 WRITE (*, FMT="('Device ID:', T30, I19)") buff(1)
8352 WRITE (*, FMT="('Inode number:', T30, I19)") buff(2)
8353 WRITE (*, FMT="('File mode (octal):', T30, O19)") buff(3)
8354 WRITE (*, FMT="('Number of links:', T30, I19)") buff(4)
8355 WRITE (*, FMT="('Owner''s uid:', T30, I19)") buff(5)
8356 WRITE (*, FMT="('Owner''s gid:', T30, I19)") buff(6)
8357 WRITE (*, FMT="('Device where located:', T30, I19)") buff(7)
8358 WRITE (*, FMT="('File size:', T30, I19)") buff(8)
8359 WRITE (*, FMT="('Last access time:', T30, A19)") CTIME(buff(9))
8360 WRITE (*, FMT="('Last modification time', T30, A19)") CTIME(buff(10))
8361 WRITE (*, FMT="('Last status change time:', T30, A19)") CTIME(buff(11))
8362 WRITE (*, FMT="('Preferred block size:', T30, I19)") buff(12)
8363 WRITE (*, FMT="('No. of blocks allocated:', T30, I19)") buff(13)
8368 @item @emph{See also}:
8369 To stat an open file: @ref{FSTAT}, to stat a link: @ref{LSTAT}
8375 @section @code{SUM} --- Sum of array elements
8376 @cindex @code{SUM} intrinsic
8377 @cindex array manipulation
8379 Intrinsic implemented, documentation pending.
8382 @item @emph{Description}:
8383 @item @emph{Standard}:
8387 Transformational function
8389 @item @emph{Syntax}:
8390 @item @emph{Arguments}:
8391 @item @emph{Return value}:
8392 @item @emph{Example}:
8393 @item @emph{See also}:
8400 @section @code{SYMLNK} --- Create a symbolic link
8401 @cindex @code{SYMLNK} intrinsic
8402 @cindex file system operations
8405 @item @emph{Description}:
8406 Makes a symbolic link from file @var{PATH1} to @var{PATH2}. A null
8407 character (@code{CHAR(0)}) can be used to mark the end of the names in
8408 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
8409 names are ignored. If the @var{STATUS} argument is supplied, it
8410 contains 0 on success or a nonzero error code upon return; see
8411 @code{symlink(2)}. If the system does not supply @code{symlink(2)},
8412 @code{ENOSYS} is returned.
8414 @item @emph{Standard}:
8420 @item @emph{Syntax}:
8421 @code{CALL SYMLNK(PATH1, PATH2 [, STATUS])}
8423 @item @emph{Arguments}:
8424 @multitable @columnfractions .15 .80
8425 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
8426 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
8427 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
8430 @item @emph{See also}:
8431 @ref{LINK}, @ref{UNLINK}
8438 @section @code{SYSTEM} --- Execute a shell command
8439 @cindex @code{SYSTEM} intrinsic
8442 @item @emph{Description}:
8443 Passes the command @var{COMMAND} to a shell (see @code{system(3)}). If
8444 argument @var{STATUS} is present, it contains the value returned by
8445 @code{system(3)}, which is presumably 0 if the shell command succeeded.
8446 Note that which shell is used to invoke the command is system-dependent
8447 and environment-dependent.
8449 @item @emph{Standard}:
8455 @item @emph{Syntax}:
8456 @code{CALL SYSTEM(COMMAND [, STATUS])}
8458 @item @emph{Arguments}:
8459 @multitable @columnfractions .15 .80
8460 @item @var{COMMAND} @tab Shall be of default @code{CHARACTER} type.
8461 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
8464 @item @emph{See also}:
8470 @section @code{SYSTEM_CLOCK} --- Time function
8471 @cindex @code{SYSTEM_CLOCK} intrinsic
8472 @cindex time, current
8473 @cindex current time
8475 Intrinsic implemented, documentation pending.
8478 @item @emph{Description}:
8479 @item @emph{Standard}:
8485 @item @emph{Syntax}:
8486 @item @emph{Arguments}:
8487 @item @emph{Return value}:
8488 @item @emph{Example}:
8489 @item @emph{See also}:
8495 @section @code{TAN} --- Tangent function
8496 @cindex @code{TAN} intrinsic
8497 @cindex @code{DTAN} intrinsic
8498 @cindex trigonometric functions
8501 @item @emph{Description}:
8502 @code{TAN(X)} computes the tangent of @var{X}.
8504 @item @emph{Standard}:
8510 @item @emph{Syntax}:
8511 @code{RESULT = TAN(X)}
8513 @item @emph{Arguments}:
8514 @multitable @columnfractions .15 .80
8515 @item @var{X} @tab The type shall be @code{REAL(*)}.
8518 @item @emph{Return value}:
8519 The return value is of type @code{REAL(*)}. The kind type parameter is
8520 the same as @var{X}.
8522 @item @emph{Example}:
8525 real(8) :: x = 0.165_8
8527 end program test_tan
8530 @item @emph{Specific names}:
8531 @multitable @columnfractions .20 .20 .20 .40
8532 @item Name @tab Argument @tab Return type @tab Standard
8533 @item @code{DTAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
8536 @item @emph{See also}:
8543 @section @code{TANH} --- Hyperbolic tangent function
8544 @cindex @code{TANH} intrinsic
8545 @cindex @code{DTANH} intrinsic
8546 @cindex hyperbolic tangent
8549 @item @emph{Description}:
8550 @code{TANH(X)} computes the hyperbolic tangent of @var{X}.
8552 @item @emph{Standard}:
8558 @item @emph{Syntax}:
8561 @item @emph{Arguments}:
8562 @multitable @columnfractions .15 .80
8563 @item @var{X} @tab The type shall be @code{REAL(*)}.
8566 @item @emph{Return value}:
8567 The return value is of type @code{REAL(*)} and lies in the range
8568 @math{ - 1 \leq tanh(x) \leq 1 }.
8570 @item @emph{Example}:
8573 real(8) :: x = 2.1_8
8575 end program test_tanh
8578 @item @emph{Specific names}:
8579 @multitable @columnfractions .20 .20 .20 .40
8580 @item Name @tab Argument @tab Return type @tab Standard
8581 @item @code{DTANH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
8584 @item @emph{See also}:
8591 @section @code{TIME} --- Time function
8592 @cindex @code{TIME} intrinsic
8593 @cindex time, current
8594 @cindex current time
8597 @item @emph{Description}:
8598 Returns the current time encoded as an integer (in the manner of the
8599 UNIX function @code{time(3)}). This value is suitable for passing to
8600 @code{CTIME()}, @code{GMTIME()}, and @code{LTIME()}.
8602 This intrinsic is not fully portable, such as to systems with 32-bit
8603 @code{INTEGER} types but supporting times wider than 32 bits. Therefore,
8604 the values returned by this intrinsic might be, or become, negative, or
8605 numerically less than previous values, during a single run of the
8608 See @ref{TIME8}, for information on a similar intrinsic that might be
8609 portable to more GNU Fortran implementations, though to fewer Fortran
8612 @item @emph{Standard}:
8616 Non-elemental function
8618 @item @emph{Syntax}:
8619 @code{RESULT = TIME()}
8621 @item @emph{Return value}:
8622 The return value is a scalar of type @code{INTEGER(4)}.
8624 @item @emph{See also}:
8625 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{TIME8}
8632 @section @code{TIME8} --- Time function (64-bit)
8633 @cindex @code{TIME8} intrinsic
8634 @cindex time, current
8635 @cindex current time
8638 @item @emph{Description}:
8639 Returns the current time encoded as an integer (in the manner of the
8640 UNIX function @code{time(3)}). This value is suitable for passing to
8641 @code{CTIME()}, @code{GMTIME()}, and @code{LTIME()}.
8643 @emph{Warning:} this intrinsic does not increase the range of the timing
8644 values over that returned by @code{time(3)}. On a system with a 32-bit
8645 @code{time(3)}, @code{TIME8()} will return a 32-bit value, even though
8646 it is converted to a 64-bit @code{INTEGER(8)} value. That means
8647 overflows of the 32-bit value can still occur. Therefore, the values
8648 returned by this intrinsic might be or become negative or numerically
8649 less than previous values during a single run of the compiled program.
8651 @item @emph{Standard}:
8655 Non-elemental function
8657 @item @emph{Syntax}:
8658 @code{RESULT = TIME8()}
8660 @item @emph{Return value}:
8661 The return value is a scalar of type @code{INTEGER(8)}.
8663 @item @emph{See also}:
8664 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{TIME}
8671 @section @code{TINY} --- Smallest positive number of a real kind
8672 @cindex @code{TINY} intrinsic
8676 @item @emph{Description}:
8677 @code{TINY(X)} returns the smallest positive (non zero) number
8678 in the model of the type of @code{X}.
8680 @item @emph{Standard}:
8686 @item @emph{Syntax}:
8687 @code{RESULT = TINY(X)}
8689 @item @emph{Arguments}:
8690 @multitable @columnfractions .15 .80
8691 @item @var{X} @tab shall be of type @code{REAL}.
8694 @item @emph{Return value}:
8695 The return value is of the same type and kind as @var{X}
8697 @item @emph{Example}:
8698 See @code{HUGE} for an example.
8704 @section @code{TRANSFER} --- Transfer bit patterns
8705 @cindex @code{TRANSFER} intrinsic
8706 @cindex bit operations
8708 Intrinsic implemented, documentation pending.
8711 @item @emph{Description}:
8712 @item @emph{Standard}:
8716 Transformational function
8718 @item @emph{Syntax}:
8719 @item @emph{Arguments}:
8720 @item @emph{Return value}:
8721 @item @emph{Example}:
8722 @item @emph{See also}:
8728 @section @code{TRANSPOSE} --- Transpose an array of rank two
8729 @cindex @code{TRANSPOSE} intrinsic
8730 @cindex matrix manipulation
8732 Intrinsic implemented, documentation pending.
8735 @item @emph{Description}:
8736 @item @emph{Standard}:
8740 Transformational function
8742 @item @emph{Syntax}:
8743 @item @emph{Arguments}:
8744 @item @emph{Return value}:
8745 @item @emph{Example}:
8746 @item @emph{See also}:
8752 @section @code{TRIM} --- Function to remove trailing blank characters of a string
8753 @cindex @code{TRIM} intrinsic
8754 @cindex string manipulation
8756 Intrinsic implemented, documentation pending.
8759 @item @emph{Description}:
8760 @item @emph{Standard}:
8764 Transformational function
8766 @item @emph{Syntax}:
8767 @item @emph{Arguments}:
8768 @item @emph{Return value}:
8769 @item @emph{Example}:
8770 @item @emph{See also}:
8776 @section @code{UBOUND} --- Upper dimension bounds of an array
8777 @cindex @code{UBOUND} intrinsic
8780 @item @emph{Description}:
8781 Returns the upper bounds of an array, or a single upper bound
8782 along the @var{DIM} dimension.
8783 @item @emph{Standard}:
8789 @item @emph{Syntax}:
8790 @code{RESULT = UBOUND(ARRAY [, DIM])}
8792 @item @emph{Arguments}:
8793 @multitable @columnfractions .15 .80
8794 @item @var{ARRAY} @tab Shall be an array, of any type.
8795 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER(*)}.
8798 @item @emph{Return value}:
8799 If @var{DIM} is absent, the result is an array of the upper bounds of
8800 @var{ARRAY}. If @var{DIM} is present, the result is a scalar
8801 corresponding to the upper bound of the array along that dimension. If
8802 @var{ARRAY} is an expression rather than a whole array or array
8803 structure component, or if it has a zero extent along the relevant
8804 dimension, the upper bound is taken to be the number of elements along
8805 the relevant dimension.
8807 @item @emph{See also}:
8814 @section @code{UMASK} --- Set the file creation mask
8815 @cindex @code{UMASK} intrinsic
8816 @cindex file system operations
8819 @item @emph{Description}:
8820 Sets the file creation mask to @var{MASK} and returns the old value in
8821 argument @var{OLD} if it is supplied. See @code{umask(2)}.
8823 @item @emph{Standard}:
8829 @item @emph{Syntax}:
8830 @code{CALL UMASK(MASK [, OLD])}
8832 @item @emph{Arguments}:
8833 @multitable @columnfractions .15 .80
8834 @item @var{MASK} @tab Shall be a scalar of type @code{INTEGER(*)}.
8835 @item @var{MASK} @tab (Optional) Shall be a scalar of type
8844 @section @code{UNLINK} --- Remove a file from the file system
8845 @cindex @code{UNLINK} intrinsic
8846 @cindex file system operations
8849 @item @emph{Description}:
8850 Unlinks the file @var{PATH}. A null character (@code{CHAR(0)}) can be
8851 used to mark the end of the name in @var{PATH}; otherwise, trailing
8852 blanks in the file name are ignored. If the @var{STATUS} argument is
8853 supplied, it contains 0 on success or a nonzero error code upon return;
8854 see @code{unlink(2)}.
8856 @item @emph{Standard}:
8862 @item @emph{Syntax}:
8863 @code{CALL UNLINK(PATH [, STATUS])}
8865 @item @emph{Arguments}:
8866 @multitable @columnfractions .15 .80
8867 @item @var{PATH} @tab Shall be of default @code{CHARACTER} type.
8868 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
8871 @item @emph{See also}:
8872 @ref{LINK}, @ref{SYMLNK}
8878 @section @code{UNPACK} --- Unpack an array of rank one into an array
8879 @cindex @code{UNPACK} intrinsic
8880 @cindex array manipulation
8882 Intrinsic implemented, documentation pending.
8885 @item @emph{Description}:
8886 @item @emph{Standard}:
8890 Transformational function
8892 @item @emph{Syntax}:
8893 @item @emph{Arguments}:
8894 @item @emph{Return value}:
8895 @item @emph{Example}:
8897 @item @emph{See also}:
8904 @section @code{VERIFY} --- Scan a string for the absence of a set of characters
8905 @cindex @code{VERIFY} intrinsic
8906 @cindex string manipulation
8908 Intrinsic implemented, documentation pending.
8911 @item @emph{Description}:
8912 @item @emph{Standard}:
8918 @item @emph{Syntax}:
8919 @item @emph{Arguments}:
8920 @item @emph{Return value}:
8921 @item @emph{Example}:
8922 @item @emph{Specific names}:
8923 @item @emph{See also}:
8929 @section @code{XOR} --- Bitwise logical exclusive OR
8930 @cindex @code{XOR} intrinsic
8931 @cindex bit operations
8934 @item @emph{Description}:
8935 Bitwise logical exclusive or.
8937 This intrinsic routine is provided for backwards compatibility with
8938 GNU Fortran 77. For integer arguments, programmers should consider
8939 the use of the @ref{IEOR} intrinsic defined by the Fortran standard.
8941 @item @emph{Standard}:
8945 Non-elemental function
8947 @item @emph{Syntax}:
8948 @code{RESULT = XOR(X, Y)}
8950 @item @emph{Arguments}:
8951 @multitable @columnfractions .15 .80
8952 @item @var{X} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
8953 @item @var{Y} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
8956 @item @emph{Return value}:
8957 The return type is either @code{INTEGER(*)} or @code{LOGICAL}
8958 after cross-promotion of the arguments.
8960 @item @emph{Example}:
8963 LOGICAL :: T = .TRUE., F = .FALSE.
8965 DATA a / Z,'F' /, b / Z'3' /
8967 WRITE (*,*) XOR(T, T), XOR(T, F), XOR(F, T), XOR(F, F)
8968 WRITE (*,*) XOR(a, b)
8972 @item @emph{See also}:
8973 F95 elemental function: @ref{IEOR}