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 accessable 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
487 @section @code{ACOS} --- Arccosine function
488 @cindex @code{ACOS} intrinsic
489 @cindex @code{DACOS} intrinsic
490 @cindex trigonometric functions (inverse)
493 @item @emph{Description}:
494 @code{ACOS(X)} computes the arccosine of @var{X} (inverse of @code{COS(X)}).
496 @item @emph{Standard}:
503 @code{RESULT = ACOS(X)}
505 @item @emph{Arguments}:
506 @multitable @columnfractions .15 .80
507 @item @var{X} @tab The type shall be @code{REAL(*)} with a magnitude that is
511 @item @emph{Return value}:
512 The return value is of type @code{REAL(*)} and it lies in the
513 range @math{ 0 \leq \acos(x) \leq \pi}. The kind type parameter
514 is the same as @var{X}.
516 @item @emph{Example}:
519 real(8) :: x = 0.866_8
521 end program test_acos
524 @item @emph{Specific names}:
525 @multitable @columnfractions .20 .20 .20 .40
526 @item Name @tab Argument @tab Return type @tab Standard
527 @item @code{DACOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
530 @item @emph{See also}:
531 Inverse function: @ref{COS}
537 @section @code{ACOSH} --- Hyperbolic arccosine function
538 @cindex @code{ACOSH} intrinsic
539 @cindex hyperbolic arccosine
540 @cindex hyperbolic cosine (inverse)
543 @item @emph{Description}:
544 @code{ACOSH(X)} computes the area hyperbolic cosine of @var{X} (inverse of @code{COSH(X)}).
546 @item @emph{Standard}:
553 @code{RESULT = ACOSH(X)}
555 @item @emph{Arguments}:
556 @multitable @columnfractions .15 .80
557 @item @var{X} @tab The type shall be @code{REAL(*)} with a magnitude that is
558 greater or equal to one.
561 @item @emph{Return value}:
562 The return value is of type @code{REAL(*)} and it lies in the
563 range @math{0 \leq \acosh (x) \leq \infty}.
565 @item @emph{Example}:
568 REAL(8), DIMENSION(3) :: x = (/ 1.0, 2.0, 3.0 /)
573 @item @emph{See also}:
574 Inverse function: @ref{COSH}
580 @section @code{ADJUSTL} --- Left adjust a string
581 @cindex @code{ADJUSTL} intrinsic
582 @cindex adjust string
585 @item @emph{Description}:
586 @code{ADJUSTL(STR)} will left adjust a string by removing leading spaces.
587 Spaces are inserted at the end of the string as needed.
589 @item @emph{Standard}:
596 @code{RESULT = ADJUSTL(STR)}
598 @item @emph{Arguments}:
599 @multitable @columnfractions .15 .80
600 @item @var{STR} @tab The type shall be @code{CHARACTER}.
603 @item @emph{Return value}:
604 The return value is of type @code{CHARACTER} where leading spaces
605 are removed and the same number of spaces are inserted on the end
608 @item @emph{Example}:
611 character(len=20) :: str = ' gfortran'
614 end program test_adjustl
621 @section @code{ADJUSTR} --- Right adjust a string
622 @cindex @code{ADJUSTR} intrinsic
623 @cindex adjust string
626 @item @emph{Description}:
627 @code{ADJUSTR(STR)} will right adjust a string by removing trailing spaces.
628 Spaces are inserted at the start of the string as needed.
630 @item @emph{Standard}:
637 @code{RESULT = ADJUSTR(STR)}
639 @item @emph{Arguments}:
640 @multitable @columnfractions .15 .80
641 @item @var{STR} @tab The type shall be @code{CHARACTER}.
644 @item @emph{Return value}:
645 The return value is of type @code{CHARACTER} where trailing spaces
646 are removed and the same number of spaces are inserted at the start
649 @item @emph{Example}:
652 character(len=20) :: str = 'gfortran'
655 end program test_adjustr
662 @section @code{AIMAG} --- Imaginary part of complex number
663 @cindex @code{AIMAG} intrinsic
664 @cindex @code{DIMAG} intrinsic
665 @cindex @code{IMAG} intrinsic
666 @cindex @code{IMAGPART} intrinsic
667 @cindex imaginary part of a complex number
670 @item @emph{Description}:
671 @code{AIMAG(Z)} yields the imaginary part of complex argument @code{Z}.
672 The @code{IMAG(Z)} and @code{IMAGPART(Z)} intrinsic functions are provided
673 for compatibility with @command{g77}, and their use in new code is
674 strongly discouraged.
676 @item @emph{Standard}:
677 F77 and later, has overloads that are GNU extensions
683 @code{RESULT = AIMAG(Z)}
685 @item @emph{Arguments}:
686 @multitable @columnfractions .15 .80
687 @item @var{Z} @tab The type of the argument shall be @code{COMPLEX(*)}.
690 @item @emph{Return value}:
691 The return value is of type real with the
692 kind type parameter of the argument.
694 @item @emph{Example}:
699 z4 = cmplx(1.e0_4, 0.e0_4)
700 z8 = cmplx(0.e0_8, 1.e0_8)
701 print *, aimag(z4), dimag(z8)
702 end program test_aimag
705 @item @emph{Specific names}:
706 @multitable @columnfractions .20 .20 .20 .40
707 @item Name @tab Argument @tab Return type @tab Standard
708 @item @code{DIMAG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{REAL(8)} @tab GNU extension
709 @item @code{IMAG(Z)} @tab @code{COMPLEX(*) Z} @tab @code{REAL(*)} @tab GNU extension
710 @item @code{IMAGPART(Z)} @tab @code{COMPLEX(*) Z} @tab @code{REAL(*)} @tab GNU extension
717 @section @code{AINT} --- Truncate to a whole number
718 @cindex @code{AINT} intrinsic
719 @cindex @code{DINT} intrinsic
723 @item @emph{Description}:
724 @code{AINT(X [, KIND])} truncates its argument to a whole number.
726 @item @emph{Standard}:
733 @code{RESULT = AINT(X [, KIND])}
735 @item @emph{Arguments}:
736 @multitable @columnfractions .15 .80
737 @item @var{X} @tab The type of the argument shall be @code{REAL(*)}.
738 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
739 expression indicating the kind parameter of
743 @item @emph{Return value}:
744 The return value is of type real with the kind type parameter of the
745 argument if the optional @var{KIND} is absent; otherwise, the kind
746 type parameter will be given by @var{KIND}. If the magnitude of
747 @var{X} is less than one, then @code{AINT(X)} returns zero. If the
748 magnitude is equal to or greater than one, then it returns the largest
749 whole number that does not exceed its magnitude. The sign is the same
750 as the sign of @var{X}.
752 @item @emph{Example}:
759 print *, aint(x4), dint(x8)
761 end program test_aint
764 @item @emph{Specific names}:
765 @multitable @columnfractions .20 .20 .20 .40
766 @item Name @tab Argument @tab Return type @tab Standard
767 @item @code{DINT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
774 @section @code{ALARM} --- Execute a routine after a given delay
775 @cindex @code{ALARM} intrinsic
778 @item @emph{Description}:
779 @code{ALARM(SECONDS, HANDLER [, STATUS])} causes external subroutine @var{HANDLER}
780 to be executed after a delay of @var{SECONDS} by using @code{alarm(1)} to
781 set up a signal and @code{signal(2)} to catch it. If @var{STATUS} is
782 supplied, it will be returned with the number of seconds remaining until
783 any previously scheduled alarm was due to be delivered, or zero if there
784 was no previously scheduled alarm.
786 @item @emph{Standard}:
793 @code{CALL ALARM(SECONDS, HANDLER [, STATUS])}
795 @item @emph{Arguments}:
796 @multitable @columnfractions .15 .80
797 @item @var{SECONDS} @tab The type of the argument shall be a scalar
798 @code{INTEGER}. It is @code{INTENT(IN)}.
799 @item @var{HANDLER} @tab Signal handler (@code{INTEGER FUNCTION} or
800 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar.
801 @code{INTEGER}. It is @code{INTENT(IN)}.
802 @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
803 @code{INTEGER} variable. It is @code{INTENT(OUT)}.
806 @item @emph{Example}:
809 external handler_print
811 call alarm (3, handler_print, i)
814 end program test_alarm
816 This will cause the external routine @var{handler_print} to be called
823 @section @code{ALL} --- All values in @var{MASK} along @var{DIM} are true
824 @cindex @code{ALL} intrinsic
828 @item @emph{Description}:
829 @code{ALL(MASK [, DIM])} determines if all the values are true in @var{MASK}
830 in the array along dimension @var{DIM}.
832 @item @emph{Standard}:
836 transformational function
839 @code{RESULT = ALL(MASK [, DIM])}
841 @item @emph{Arguments}:
842 @multitable @columnfractions .15 .80
843 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL(*)} and
844 it shall not be scalar.
845 @item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer
846 with a value that lies between one and the rank of @var{MASK}.
849 @item @emph{Return value}:
850 @code{ALL(MASK)} returns a scalar value of type @code{LOGICAL(*)} where
851 the kind type parameter is the same as the kind type parameter of
852 @var{MASK}. If @var{DIM} is present, then @code{ALL(MASK, DIM)} returns
853 an array with the rank of @var{MASK} minus 1. The shape is determined from
854 the shape of @var{MASK} where the @var{DIM} dimension is elided.
858 @code{ALL(MASK)} is true if all elements of @var{MASK} are true.
859 It also is true if @var{MASK} has zero size; otherwise, it is false.
861 If the rank of @var{MASK} is one, then @code{ALL(MASK,DIM)} is equivalent
862 to @code{ALL(MASK)}. If the rank is greater than one, then @code{ALL(MASK,DIM)}
863 is determined by applying @code{ALL} to the array sections.
866 @item @emph{Example}:
870 l = all((/.true., .true., .true./))
875 integer a(2,3), b(2,3)
879 print *, all(a .eq. b, 1)
880 print *, all(a .eq. b, 2)
881 end subroutine section
889 @section @code{ALLOCATED} --- Status of an allocatable entity
890 @cindex @code{ALLOCATED} intrinsic
891 @cindex allocation status
894 @item @emph{Description}:
895 @code{ALLOCATED(X)} checks the status of whether @var{X} is allocated.
897 @item @emph{Standard}:
904 @code{RESULT = ALLOCATED(X)}
906 @item @emph{Arguments}:
907 @multitable @columnfractions .15 .80
908 @item @var{X} @tab The argument shall be an @code{ALLOCATABLE} array.
911 @item @emph{Return value}:
912 The return value is a scalar @code{LOGICAL} with the default logical
913 kind type parameter. If @var{X} is allocated, @code{ALLOCATED(X)}
914 is @code{.TRUE.}; otherwise, it returns the @code{.TRUE.}
916 @item @emph{Example}:
918 program test_allocated
920 real(4), allocatable :: x(:)
921 if (allocated(x) .eqv. .false.) allocate(x(i))
922 end program test_allocated
928 @section @code{AND} --- Bitwise logical AND
929 @cindex @code{AND} intrinsic
930 @cindex bit operations
933 @item @emph{Description}:
934 Bitwise logical @code{AND}.
936 This intrinsic routine is provided for backwards compatibility with
937 GNU Fortran 77. For integer arguments, programmers should consider
938 the use of the @ref{IAND} intrinsic defined by the Fortran standard.
940 @item @emph{Standard}:
944 Non-elemental function
947 @code{RESULT = AND(X, Y)}
949 @item @emph{Arguments}:
950 @multitable @columnfractions .15 .80
951 @item @var{X} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
952 @item @var{Y} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
955 @item @emph{Return value}:
956 The return type is either @code{INTEGER(*)} or @code{LOGICAL} after
957 cross-promotion of the arguments.
959 @item @emph{Example}:
962 LOGICAL :: T = .TRUE., F = ..FALSE.
964 DATA a / Z'F' /, b / Z'3' /
966 WRITE (*,*) AND(T, T), AND(T, F), AND(F, T), AND(F, F)
967 WRITE (*,*) AND(a, b)
971 @item @emph{See also}:
972 F95 elemental function: @ref{IAND}
978 @section @code{ANINT} --- Nearest whole number
979 @cindex @code{ANINT} intrinsic
980 @cindex @code{DNINT} intrinsic
984 @item @emph{Description}:
985 @code{ANINT(X [, KIND])} rounds its argument to the nearest whole number.
987 @item @emph{Standard}:
994 @code{RESULT = ANINT(X [, KIND])}
996 @item @emph{Arguments}:
997 @multitable @columnfractions .15 .80
998 @item @var{X} @tab The type of the argument shall be @code{REAL(*)}.
999 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
1000 expression indicating the kind parameter of
1004 @item @emph{Return value}:
1005 The return value is of type real with the kind type parameter of the
1006 argument if the optional @var{KIND} is absent; otherwise, the kind
1007 type parameter will be given by @var{KIND}. If @var{X} is greater than
1008 zero, then @code{ANINT(X)} returns @code{AINT(X+0.5)}. If @var{X} is
1009 less than or equal to zero, then it returns @code{AINT(X-0.5)}.
1011 @item @emph{Example}:
1018 print *, anint(x4), dnint(x8)
1020 end program test_anint
1023 @item @emph{Specific names}:
1024 @multitable @columnfractions .20 .20 .20 .40
1025 @item Name @tab Argument @tab Return type @tab Standard
1026 @item @code{DNINT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1033 @section @code{ANY} --- Any value in @var{MASK} along @var{DIM} is true
1034 @cindex @code{ANY} intrinsic
1038 @item @emph{Description}:
1039 @code{ANY(MASK [, DIM])} determines if any of the values in the logical array
1040 @var{MASK} along dimension @var{DIM} are @code{.TRUE.}.
1042 @item @emph{Standard}:
1046 transformational function
1048 @item @emph{Syntax}:
1049 @code{RESULT = ANY(MASK [, DIM])}
1051 @item @emph{Arguments}:
1052 @multitable @columnfractions .15 .80
1053 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL(*)} and
1054 it shall not be scalar.
1055 @item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer
1056 with a value that lies between one and the rank of @var{MASK}.
1059 @item @emph{Return value}:
1060 @code{ANY(MASK)} returns a scalar value of type @code{LOGICAL(*)} where
1061 the kind type parameter is the same as the kind type parameter of
1062 @var{MASK}. If @var{DIM} is present, then @code{ANY(MASK, DIM)} returns
1063 an array with the rank of @var{MASK} minus 1. The shape is determined from
1064 the shape of @var{MASK} where the @var{DIM} dimension is elided.
1068 @code{ANY(MASK)} is true if any element of @var{MASK} is true;
1069 otherwise, it is false. It also is false if @var{MASK} has zero size.
1071 If the rank of @var{MASK} is one, then @code{ANY(MASK,DIM)} is equivalent
1072 to @code{ANY(MASK)}. If the rank is greater than one, then @code{ANY(MASK,DIM)}
1073 is determined by applying @code{ANY} to the array sections.
1076 @item @emph{Example}:
1080 l = any((/.true., .true., .true./))
1085 integer a(2,3), b(2,3)
1089 print *, any(a .eq. b, 1)
1090 print *, any(a .eq. b, 2)
1091 end subroutine section
1092 end program test_any
1099 @section @code{ASIN} --- Arcsine function
1100 @cindex @code{ASIN} intrinsic
1101 @cindex @code{DASIN} intrinsic
1102 @cindex trigonometric functions (inverse)
1105 @item @emph{Description}:
1106 @code{ASIN(X)} computes the arcsine of its @var{X} (inverse of @code{SIN(X)}).
1108 @item @emph{Standard}:
1114 @item @emph{Syntax}:
1115 @code{RESULT = ASIN(X)}
1117 @item @emph{Arguments}:
1118 @multitable @columnfractions .15 .80
1119 @item @var{X} @tab The type shall be @code{REAL(*)}, and a magnitude that is
1123 @item @emph{Return value}:
1124 The return value is of type @code{REAL(*)} and it lies in the
1125 range @math{-\pi / 2 \leq \asin (x) \leq \pi / 2}. The kind type
1126 parameter is the same as @var{X}.
1128 @item @emph{Example}:
1131 real(8) :: x = 0.866_8
1133 end program test_asin
1136 @item @emph{Specific names}:
1137 @multitable @columnfractions .20 .20 .20 .40
1138 @item Name @tab Argument @tab Return type @tab Standard
1139 @item @code{DASIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1142 @item @emph{See also}:
1143 Inverse function: @ref{SIN}
1149 @section @code{ASINH} --- Hyperbolic arcsine function
1150 @cindex @code{ASINH} intrinsic
1151 @cindex hyperbolic arcsine
1152 @cindex hyperbolic sine (inverse)
1155 @item @emph{Description}:
1156 @code{ASINH(X)} computes the area hyperbolic sine of @var{X} (inverse of @code{SINH(X)}).
1158 @item @emph{Standard}:
1164 @item @emph{Syntax}:
1165 @code{RESULT = ASINH(X)}
1167 @item @emph{Arguments}:
1168 @multitable @columnfractions .15 .80
1169 @item @var{X} @tab The type shall be @code{REAL(*)}, with @var{X} a real number.
1172 @item @emph{Return value}:
1173 The return value is of type @code{REAL(*)} and it lies in the
1174 range @math{-\infty \leq \asinh (x) \leq \infty}.
1176 @item @emph{Example}:
1179 REAL(8), DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1180 WRITE (*,*) ASINH(x)
1184 @item @emph{See also}:
1185 Inverse function: @ref{SINH}
1191 @section @code{ASSOCIATED} --- Status of a pointer or pointer/target pair
1192 @cindex @code{ASSOCIATED} intrinsic
1193 @cindex pointer status
1196 @item @emph{Description}:
1197 @code{ASSOCIATED(PTR [, TGT])} determines the status of the pointer @var{PTR}
1198 or if @var{PTR} is associated with the target @var{TGT}.
1200 @item @emph{Standard}:
1206 @item @emph{Syntax}:
1207 @code{RESULT = ASSOCIATED(PTR [, TGT])}
1209 @item @emph{Arguments}:
1210 @multitable @columnfractions .15 .80
1211 @item @var{PTR} @tab @var{PTR} shall have the @code{POINTER} attribute and
1212 it can be of any type.
1213 @item @var{TGT} @tab (Optional) @var{TGT} shall be a @code{POINTER} or
1214 a @code{TARGET}. It must have the same type, kind type parameter, and
1215 array rank as @var{PTR}.
1217 The status of neither @var{PTR} nor @var{TGT} can be undefined.
1219 @item @emph{Return value}:
1220 @code{ASSOCIATED(PTR)} returns a scalar value of type @code{LOGICAL(4)}.
1221 There are several cases:
1223 @item (A) If the optional @var{TGT} is not present, then @code{ASSOCIATED(PTR)}
1224 is true if @var{PTR} is associated with a target; otherwise, it returns false.
1225 @item (B) If @var{TGT} is present and a scalar target, the result is true if
1227 is not a 0 sized storage sequence and the target associated with @var{PTR}
1228 occupies the same storage units. If @var{PTR} is disassociated, then the
1230 @item (C) If @var{TGT} is present and an array target, the result is true if
1231 @var{TGT} and @var{PTR} have the same shape, are not 0 sized arrays, are
1232 arrays whose elements are not 0 sized storage sequences, and @var{TGT} and
1233 @var{PTR} occupy the same storage units in array element order.
1234 As in case(B), the result is false, if @var{PTR} is disassociated.
1235 @item (D) If @var{TGT} is present and an scalar pointer, the result is true if
1236 target associated with @var{PTR} and the target associated with @var{TGT}
1237 are not 0 sized storage sequences and occupy the same storage units.
1238 The result is false, if either @var{TGT} or @var{PTR} is disassociated.
1239 @item (E) If @var{TGT} is present and an array pointer, the result is true if
1240 target associated with @var{PTR} and the target associated with @var{TGT}
1241 have the same shape, are not 0 sized arrays, are arrays whose elements are
1242 not 0 sized storage sequences, and @var{TGT} and @var{PTR} occupy the same
1243 storage units in array element order.
1244 The result is false, if either @var{TGT} or @var{PTR} is disassociated.
1247 @item @emph{Example}:
1249 program test_associated
1251 real, target :: tgt(2) = (/1., 2./)
1252 real, pointer :: ptr(:)
1254 if (associated(ptr) .eqv. .false.) call abort
1255 if (associated(ptr,tgt) .eqv. .false.) call abort
1256 end program test_associated
1259 @item @emph{See also}:
1266 @section @code{ATAN} --- Arctangent function
1267 @cindex @code{ATAN} intrinsic
1268 @cindex @code{DATAN} intrinsic
1269 @cindex trigonometric functions (inverse)
1272 @item @emph{Description}:
1273 @code{ATAN(X)} computes the arctangent of @var{X}.
1275 @item @emph{Standard}:
1281 @item @emph{Syntax}:
1282 @code{RESULT = ATAN(X)}
1284 @item @emph{Arguments}:
1285 @multitable @columnfractions .15 .80
1286 @item @var{X} @tab The type shall be @code{REAL(*)}.
1289 @item @emph{Return value}:
1290 The return value is of type @code{REAL(*)} and it lies in the
1291 range @math{ - \pi / 2 \leq \atan (x) \leq \pi / 2}.
1293 @item @emph{Example}:
1296 real(8) :: x = 2.866_8
1298 end program test_atan
1301 @item @emph{Specific names}:
1302 @multitable @columnfractions .20 .20 .20 .40
1303 @item Name @tab Argument @tab Return type @tab Standard
1304 @item @code{DATAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1307 @item @emph{See also}:
1308 Inverse function: @ref{TAN}
1315 @section @code{ATAN2} --- Arctangent function
1316 @cindex @code{ATAN2} intrinsic
1317 @cindex @code{DATAN2} intrinsic
1318 @cindex trigonometric functions (inverse)
1321 @item @emph{Description}:
1322 @code{ATAN2(Y,X)} computes the arctangent of the complex number @math{X + i Y}.
1324 @item @emph{Standard}:
1330 @item @emph{Syntax}:
1331 @code{RESULT = ATAN2(Y,X)}
1333 @item @emph{Arguments}:
1334 @multitable @columnfractions .15 .80
1335 @item @var{Y} @tab The type shall be @code{REAL(*)}.
1336 @item @var{X} @tab The type and kind type parameter shall be the same as @var{Y}.
1337 If @var{Y} is zero, then @var{X} must be nonzero.
1340 @item @emph{Return value}:
1341 The return value has the same type and kind type parameter as @var{Y}.
1342 It is the principal value of the complex number @math{X + i Y}. If
1343 @var{X} is nonzero, then it lies in the range @math{-\pi \le \atan (x) \leq \pi}.
1344 The sign is positive if @var{Y} is positive. If @var{Y} is zero, then
1345 the return value is zero if @var{X} is positive and @math{\pi} if @var{X}
1346 is negative. Finally, if @var{X} is zero, then the magnitude of the result
1349 @item @emph{Example}:
1352 real(4) :: x = 1.e0_4, y = 0.5e0_4
1354 end program test_atan2
1357 @item @emph{Specific names}:
1358 @multitable @columnfractions .20 .20 .20 .40
1359 @item Name @tab Argument @tab Return type @tab Standard
1360 @item @code{DATAN2(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1367 @section @code{ATANH} --- Hyperbolic arctangent function
1368 @cindex @code{ASINH} intrinsic
1369 @cindex hyperbolic arctangent
1370 @cindex hyperbolic tangent (inverse)
1373 @item @emph{Description}:
1374 @code{ATANH(X)} computes the area hyperbolic sine of @var{X} (inverse of @code{TANH(X)}).
1376 @item @emph{Standard}:
1382 @item @emph{Syntax}:
1383 @code{RESULT = ATANH(X)}
1385 @item @emph{Arguments}:
1386 @multitable @columnfractions .15 .80
1387 @item @var{X} @tab The type shall be @code{REAL(*)} with a magnitude
1388 that is less than or equal to one.
1391 @item @emph{Return value}:
1392 The return value is of type @code{REAL(*)} and it lies in the
1393 range @math{-\infty \leq \atanh(x) \leq \infty}.
1395 @item @emph{Example}:
1398 REAL, DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1399 WRITE (*,*) ATANH(x)
1403 @item @emph{See also}:
1404 Inverse function: @ref{TANH}
1411 @section @code{BESJ0} --- Bessel function of the first kind of order 0
1412 @cindex @code{BESJ0} intrinsic
1413 @cindex @code{DBESJ0} intrinsic
1417 @item @emph{Description}:
1418 @code{BESJ0(X)} computes the Bessel function of the first kind of order 0
1421 @item @emph{Standard}:
1427 @item @emph{Syntax}:
1428 @code{RESULT = BESJ0(X)}
1430 @item @emph{Arguments}:
1431 @multitable @columnfractions .15 .80
1432 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1435 @item @emph{Return value}:
1436 The return value is of type @code{REAL(*)} and it lies in the
1437 range @math{ - 0.4027... \leq Bessel (0,x) \leq 1}.
1439 @item @emph{Example}:
1442 real(8) :: x = 0.0_8
1444 end program test_besj0
1447 @item @emph{Specific names}:
1448 @multitable @columnfractions .20 .20 .20 .40
1449 @item Name @tab Argument @tab Return type @tab Standard
1450 @item @code{DBESJ0(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1457 @section @code{BESJ1} --- Bessel function of the first kind of order 1
1458 @cindex @code{BESJ1} intrinsic
1459 @cindex @code{DBESJ1} intrinsic
1463 @item @emph{Description}:
1464 @code{BESJ1(X)} computes the Bessel function of the first kind of order 1
1467 @item @emph{Standard}:
1473 @item @emph{Syntax}:
1474 @code{RESULT = BESJ1(X)}
1476 @item @emph{Arguments}:
1477 @multitable @columnfractions .15 .80
1478 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1481 @item @emph{Return value}:
1482 The return value is of type @code{REAL(*)} and it lies in the
1483 range @math{ - 0.5818... \leq Bessel (0,x) \leq 0.5818 }.
1485 @item @emph{Example}:
1488 real(8) :: x = 1.0_8
1490 end program test_besj1
1493 @item @emph{Specific names}:
1494 @multitable @columnfractions .20 .20 .20 .40
1495 @item Name @tab Argument @tab Return type @tab Standard
1496 @item @code{DBESJ1(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1503 @section @code{BESJN} --- Bessel function of the first kind
1504 @cindex @code{BESJN} intrinsic
1505 @cindex @code{DBESJN} intrinsic
1509 @item @emph{Description}:
1510 @code{BESJN(N, X)} computes the Bessel function of the first kind of order
1513 @item @emph{Standard}:
1519 @item @emph{Syntax}:
1520 @code{RESULT = BESJN(N, X)}
1522 @item @emph{Arguments}:
1523 @multitable @columnfractions .15 .80
1524 @item @var{N} @tab The type shall be @code{INTEGER(*)}, and it shall be scalar.
1525 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1528 @item @emph{Return value}:
1529 The return value is a scalar of type @code{REAL(*)}.
1531 @item @emph{Example}:
1534 real(8) :: x = 1.0_8
1536 end program test_besjn
1539 @item @emph{Specific names}:
1540 @multitable @columnfractions .20 .20 .20 .40
1541 @item Name @tab Argument @tab Return type @tab Standard
1542 @item @code{DBESJN(X)} @tab @code{INTEGER(*) N} @tab @code{REAL(8)} @tab GNU extension
1543 @item @tab @code{REAL(8) X} @tab @tab
1550 @section @code{BESY0} --- Bessel function of the second kind of order 0
1551 @cindex @code{BESY0} intrinsic
1552 @cindex @code{DBESY0} intrinsic
1556 @item @emph{Description}:
1557 @code{BESY0(X)} computes the Bessel function of the second kind of order 0
1560 @item @emph{Standard}:
1566 @item @emph{Syntax}:
1567 @code{RESULT = BESY0(X)}
1569 @item @emph{Arguments}:
1570 @multitable @columnfractions .15 .80
1571 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1574 @item @emph{Return value}:
1575 The return value is a scalar of type @code{REAL(*)}.
1577 @item @emph{Example}:
1580 real(8) :: x = 0.0_8
1582 end program test_besy0
1585 @item @emph{Specific names}:
1586 @multitable @columnfractions .20 .20 .20 .40
1587 @item Name @tab Argument @tab Return type @tab Standard
1588 @item @code{DBESY0(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1595 @section @code{BESY1} --- Bessel function of the second kind of order 1
1596 @cindex @code{BESY1} intrinsic
1597 @cindex @code{DBESY1} intrinsic
1601 @item @emph{Description}:
1602 @code{BESY1(X)} computes the Bessel function of the second kind of order 1
1605 @item @emph{Standard}:
1611 @item @emph{Syntax}:
1612 @code{RESULT = BESY1(X)}
1614 @item @emph{Arguments}:
1615 @multitable @columnfractions .15 .80
1616 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1619 @item @emph{Return value}:
1620 The return value is a scalar of type @code{REAL(*)}.
1622 @item @emph{Example}:
1625 real(8) :: x = 1.0_8
1627 end program test_besy1
1630 @item @emph{Specific names}:
1631 @multitable @columnfractions .20 .20 .20 .40
1632 @item Name @tab Argument @tab Return type @tab Standard
1633 @item @code{DBESY1(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1640 @section @code{BESYN} --- Bessel function of the second kind
1641 @cindex @code{BESYN} intrinsic
1642 @cindex @code{DBESYN} intrinsic
1646 @item @emph{Description}:
1647 @code{BESYN(N, X)} computes the Bessel function of the second kind of order
1650 @item @emph{Standard}:
1656 @item @emph{Syntax}:
1657 @code{RESULT = BESYN(N, X)}
1659 @item @emph{Arguments}:
1660 @multitable @columnfractions .15 .80
1661 @item @var{N} @tab The type shall be @code{INTEGER(*)}, and it shall be scalar.
1662 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1665 @item @emph{Return value}:
1666 The return value is a scalar of type @code{REAL(*)}.
1668 @item @emph{Example}:
1671 real(8) :: x = 1.0_8
1673 end program test_besyn
1676 @item @emph{Specific names}:
1677 @multitable @columnfractions .20 .20 .20 .40
1678 @item Name @tab Argument @tab Return type @tab Standard
1679 @item @code{DBESYN(N,X)} @tab @code{INTEGER(*) N} @tab @code{REAL(8)} @tab GNU extension
1680 @item @tab @code{REAL(8) X} @tab @tab
1687 @section @code{BIT_SIZE} --- Bit size inquiry function
1688 @cindex @code{BIT_SIZE} intrinsic
1689 @cindex bit size of a variable
1690 @cindex size of a variable, in bits
1693 @item @emph{Description}:
1694 @code{BIT_SIZE(I)} returns the number of bits (integer precision plus sign bit)
1695 represented by the type of @var{I}.
1697 @item @emph{Standard}:
1703 @item @emph{Syntax}:
1704 @code{RESULT = BIT_SIZE(I)}
1706 @item @emph{Arguments}:
1707 @multitable @columnfractions .15 .80
1708 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1711 @item @emph{Return value}:
1712 The return value is of type @code{INTEGER(*)}
1714 @item @emph{Example}:
1716 program test_bit_size
1721 end program test_bit_size
1728 @section @code{BTEST} --- Bit test function
1729 @cindex @code{BTEST} intrinsic
1730 @cindex bit operations
1733 @item @emph{Description}:
1734 @code{BTEST(I,POS)} returns logical @code{.TRUE.} if the bit at @var{POS}
1737 @item @emph{Standard}:
1743 @item @emph{Syntax}:
1744 @code{RESULT = BTEST(I, POS)}
1746 @item @emph{Arguments}:
1747 @multitable @columnfractions .15 .80
1748 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1749 @item @var{POS} @tab The type shall be @code{INTEGER(*)}.
1752 @item @emph{Return value}:
1753 The return value is of type @code{LOGICAL}
1755 @item @emph{Example}:
1758 integer :: i = 32768 + 1024 + 64
1762 bool = btest(i, pos)
1765 end program test_btest
1772 @section @code{CEILING} --- Integer ceiling function
1773 @cindex @code{CEILING} intrinsic
1777 @item @emph{Description}:
1778 @code{CEILING(X)} returns the least integer greater than or equal to @var{X}.
1780 @item @emph{Standard}:
1786 @item @emph{Syntax}:
1787 @code{RESULT = CEILING(X [, KIND])}
1789 @item @emph{Arguments}:
1790 @multitable @columnfractions .15 .80
1791 @item @var{X} @tab The type shall be @code{REAL(*)}.
1792 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
1793 expression indicating the kind parameter of
1797 @item @emph{Return value}:
1798 The return value is of type @code{INTEGER(KIND)}
1800 @item @emph{Example}:
1802 program test_ceiling
1805 print *, ceiling(x) ! returns 64
1806 print *, ceiling(y) ! returns -63
1807 end program test_ceiling
1810 @item @emph{See also}:
1811 @ref{FLOOR}, @ref{NINT}
1818 @section @code{CHAR} --- Character conversion function
1819 @cindex @code{CHAR} intrinsic
1820 @cindex conversion function (character)
1823 @item @emph{Description}:
1824 @code{CHAR(I [, KIND])} returns the character represented by the integer @var{I}.
1826 @item @emph{Standard}:
1832 @item @emph{Syntax}:
1833 @code{RESULT = CHAR(I [, KIND])}
1835 @item @emph{Arguments}:
1836 @multitable @columnfractions .15 .80
1837 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1838 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
1839 expression indicating the kind parameter of
1843 @item @emph{Return value}:
1844 The return value is of type @code{CHARACTER(1)}
1846 @item @emph{Example}:
1852 print *, i, c ! returns 'J'
1853 end program test_char
1856 @item @emph{See also}:
1857 @ref{ACHAR}, @ref{ICHAR}, @ref{IACHAR}
1863 @section @code{CHDIR} --- Change working directory
1864 @cindex @code{CHDIR} intrinsic
1865 @cindex file system operations
1868 @item @emph{Description}:
1869 Change current working directory to a specified @var{PATH}.
1871 @item @emph{Standard}:
1875 Non-elemental subroutine
1877 @item @emph{Syntax}:
1878 @code{CALL CHDIR(PATH [, STATUS])}
1880 @item @emph{Arguments}:
1881 @multitable @columnfractions .15 .80
1882 @item @var{PATH} @tab The type shall be @code{CHARACTER(*)} and shall
1883 specify a valid path within the file system.
1884 @item @var{STATUS} @tab (Optional) status flag. Returns 0 on success,
1885 a system specific and non-zero error code otherwise.
1888 @item @emph{Example}:
1891 CHARACTER(len=255) :: path
1893 WRITE(*,*) TRIM(path)
1896 WRITE(*,*) TRIM(path)
1900 @item @emph{See also}:
1907 @section @code{CHMOD} --- Change access permissions of files
1908 @cindex @code{CHMOD} intrinsic
1909 @cindex file system operations
1912 @item @emph{Description}:
1913 @code{CHMOD} changes the permissions of a file. This function invokes
1914 @code{/bin/chmod} and might therefore not work on all platforms.
1916 This intrinsic is provided in both subroutine and function forms; however,
1917 only one form can be used in any given program unit.
1919 @item @emph{Standard}:
1923 Subroutine, non-elemental function
1925 @item @emph{Syntax}:
1926 @multitable @columnfractions .80
1927 @item @code{CALL CHMOD(NAME, MODE[, STATUS])}
1928 @item @code{STATUS = CHMOD(NAME, MODE)}
1931 @item @emph{Arguments}:
1932 @multitable @columnfractions .15 .80
1933 @item @var{NAME} @tab Scalar @code{CHARACTER} with the file name.
1934 Trailing blanks are ignored unless the character @code{achar(0)} is
1935 present, then all characters up to and excluding @code{achar(0)} are
1936 used as the file name.
1938 @item @var{MODE} @tab Scalar @code{CHARACTER} giving the file permission.
1939 @var{MODE} uses the same syntax as the @var{MODE} argument of
1942 @item @var{STATUS} @tab (optional) scalar @code{INTEGER}, which is
1943 @code{0} on success and non-zero otherwise.
1946 @item @emph{Return value}:
1947 In either syntax, @var{STATUS} is set to @code{0} on success and non-zero
1950 @item @emph{Example}:
1951 @code{CHMOD} as subroutine
1956 call chmod('test.dat','u+x',status)
1957 print *, 'Status: ', status
1958 end program chmod_test
1960 @code{CHMOD} as non-elemental function:
1965 status = chmod('test.dat','u+x')
1966 print *, 'Status: ', status
1967 end program chmod_test
1969 @item @emph{Specific names}:
1970 @item @emph{See also}:
1976 @section @code{CMPLX} --- Complex conversion function
1977 @cindex @code{CMPLX} intrinsic
1978 @cindex complex numbers, conversion to
1981 @item @emph{Description}:
1982 @code{CMPLX(X [, Y [, KIND]])} returns a complex number where @var{X} is converted to
1983 the real component. If @var{Y} is present it is converted to the imaginary
1984 component. If @var{Y} is not present then the imaginary component is set to
1985 0.0. If @var{X} is complex then @var{Y} must not be present.
1987 @item @emph{Standard}:
1993 @item @emph{Syntax}:
1994 @code{RESULT = CMPLX(X [, Y [, KIND]])}
1996 @item @emph{Arguments}:
1997 @multitable @columnfractions .15 .80
1998 @item @var{X} @tab The type may be @code{INTEGER(*)}, @code{REAL(*)},
1999 or @code{COMPLEX(*)}.
2000 @item @var{Y} @tab (Optional; only allowed if @var{X} is not
2001 @code{COMPLEX(*)}.) May be @code{INTEGER(*)}
2003 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
2004 expression indicating the kind parameter of
2008 @item @emph{Return value}:
2009 The return value is of type @code{COMPLEX(*)}
2011 @item @emph{Example}:
2018 print *, z, cmplx(x)
2019 end program test_cmplx
2025 @node COMMAND_ARGUMENT_COUNT
2026 @section @code{COMMAND_ARGUMENT_COUNT} --- Get number of command line arguments
2027 @cindex @code{COMMAND_ARGUMENT_COUNT} intrinsic
2028 @cindex command-line arguments, to program
2031 @item @emph{Description}:
2032 @code{COMMAND_ARGUMENT_COUNT()} returns the number of arguments passed on the
2033 command line when the containing program was invoked.
2035 @item @emph{Standard}:
2041 @item @emph{Syntax}:
2042 @code{RESULT = COMMAND_ARGUMENT_COUNT()}
2044 @item @emph{Arguments}:
2045 @multitable @columnfractions .15 .80
2049 @item @emph{Return value}:
2050 The return value is of type @code{INTEGER(4)}
2052 @item @emph{Example}:
2054 program test_command_argument_count
2056 count = command_argument_count()
2058 end program test_command_argument_count
2061 @item @emph{See also}:
2062 @ref{GET_COMMAND}, @ref{GET_COMMAND_ARGUMENT}
2066 @section @code{CONJG} --- Complex conjugate function
2067 @cindex @code{CONJG} intrinsic
2068 @cindex @code{DCONJG} intrinsic
2069 @cindex complex conjugate
2071 @item @emph{Description}:
2072 @code{CONJG(Z)} returns the conjugate of @var{Z}. If @var{Z} is @code{(x, y)}
2073 then the result is @code{(x, -y)}
2075 @item @emph{Standard}:
2076 F77 and later, has overloads that are GNU extensions
2081 @item @emph{Syntax}:
2084 @item @emph{Arguments}:
2085 @multitable @columnfractions .15 .80
2086 @item @var{Z} @tab The type shall be @code{COMPLEX(*)}.
2089 @item @emph{Return value}:
2090 The return value is of type @code{COMPLEX(*)}.
2092 @item @emph{Example}:
2095 complex :: z = (2.0, 3.0)
2096 complex(8) :: dz = (2.71_8, -3.14_8)
2101 end program test_conjg
2104 @item @emph{Specific names}:
2105 @multitable @columnfractions .20 .20 .20 .40
2106 @item Name @tab Argument @tab Return type @tab Standard
2107 @item @code{DCONJG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
2114 @section @code{COS} --- Cosine function
2115 @cindex @code{COS} intrinsic
2116 @cindex @code{DCOS} intrinsic
2117 @cindex @code{ZCOS} intrinsic
2118 @cindex @code{CDCOS} intrinsic
2119 @cindex trigonometric functions
2122 @item @emph{Description}:
2123 @code{COS(X)} computes the cosine of @var{X}.
2125 @item @emph{Standard}:
2126 F77 and later, has overloads that are GNU extensions
2131 @item @emph{Syntax}:
2132 @code{RESULT = COS(X)}
2134 @item @emph{Arguments}:
2135 @multitable @columnfractions .15 .80
2136 @item @var{X} @tab The type shall be @code{REAL(*)} or
2140 @item @emph{Return value}:
2141 The return value is of type @code{REAL(*)} and it lies in the
2142 range @math{ -1 \leq \cos (x) \leq 1}. The kind type
2143 parameter is the same as @var{X}.
2145 @item @emph{Example}:
2150 end program test_cos
2153 @item @emph{Specific names}:
2154 @multitable @columnfractions .20 .20 .20 .40
2155 @item Name @tab Argument @tab Return type @tab Standard
2156 @item @code{DCOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
2157 @item @code{CCOS(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab F77 and later
2158 @item @code{ZCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
2159 @item @code{CDCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
2162 @item @emph{See also}:
2163 Inverse function: @ref{ACOS}
2170 @section @code{COSH} --- Hyperbolic cosine function
2171 @cindex @code{COSH} intrinsic
2172 @cindex @code{DCOSH} intrinsic
2173 @cindex hyperbolic cosine
2176 @item @emph{Description}:
2177 @code{COSH(X)} computes the hyperbolic cosine of @var{X}.
2179 @item @emph{Standard}:
2185 @item @emph{Syntax}:
2188 @item @emph{Arguments}:
2189 @multitable @columnfractions .15 .80
2190 @item @var{X} @tab The type shall be @code{REAL(*)}.
2193 @item @emph{Return value}:
2194 The return value is of type @code{REAL(*)} and it is positive
2195 (@math{ \cosh (x) \geq 0 }.
2197 @item @emph{Example}:
2200 real(8) :: x = 1.0_8
2202 end program test_cosh
2205 @item @emph{Specific names}:
2206 @multitable @columnfractions .20 .20 .20 .40
2207 @item Name @tab Argument @tab Return type @tab Standard
2208 @item @code{DCOSH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
2211 @item @emph{See also}:
2212 Inverse function: @ref{ACOSH}
2219 @section @code{COUNT} --- Count function
2220 @cindex @code{COUNT} intrinsic
2224 @item @emph{Description}:
2225 @code{COUNT(MASK [, DIM])} counts the number of @code{.TRUE.} elements of
2226 @var{MASK} along the dimension of @var{DIM}. If @var{DIM} is omitted it is
2227 taken to be @code{1}. @var{DIM} is a scaler of type @code{INTEGER} in the
2228 range of @math{1 /leq DIM /leq n)} where @math{n} is the rank of @var{MASK}.
2230 @item @emph{Standard}:
2234 transformational function
2236 @item @emph{Syntax}:
2237 @code{RESULT = COUNT(MASK [, DIM])}
2239 @item @emph{Arguments}:
2240 @multitable @columnfractions .15 .80
2241 @item @var{MASK} @tab The type shall be @code{LOGICAL}.
2242 @item @var{DIM} @tab The type shall be @code{INTEGER}.
2245 @item @emph{Return value}:
2246 The return value is of type @code{INTEGER} with rank equal to that of
2249 @item @emph{Example}:
2252 integer, dimension(2,3) :: a, b
2253 logical, dimension(2,3) :: mask
2254 a = reshape( (/ 1, 2, 3, 4, 5, 6 /), (/ 2, 3 /))
2255 b = reshape( (/ 0, 7, 3, 4, 5, 8 /), (/ 2, 3 /))
2256 print '(3i3)', a(1,:)
2257 print '(3i3)', a(2,:)
2259 print '(3i3)', b(1,:)
2260 print '(3i3)', b(2,:)
2263 print '(3l3)', mask(1,:)
2264 print '(3l3)', mask(2,:)
2266 print '(3i3)', count(mask)
2268 print '(3i3)', count(mask, 1)
2270 print '(3i3)', count(mask, 2)
2271 end program test_count
2278 @section @code{CPU_TIME} --- CPU elapsed time in seconds
2279 @cindex @code{CPU_TIME} intrinsic
2280 @cindex time, elapsed
2281 @cindex elapsed time
2284 @item @emph{Description}:
2285 Returns a @code{REAL} value representing the elapsed CPU time in seconds. This
2286 is useful for testing segments of code to determine execution time.
2288 @item @emph{Standard}:
2294 @item @emph{Syntax}:
2295 @code{CALL CPU_TIME(X)}
2297 @item @emph{Arguments}:
2298 @multitable @columnfractions .15 .80
2299 @item @var{X} @tab The type shall be @code{REAL} with @code{INTENT(OUT)}.
2302 @item @emph{Return value}:
2305 @item @emph{Example}:
2307 program test_cpu_time
2308 real :: start, finish
2309 call cpu_time(start)
2310 ! put code to test here
2311 call cpu_time(finish)
2312 print '("Time = ",f6.3," seconds.")',finish-start
2313 end program test_cpu_time
2320 @section @code{CSHIFT} --- Circular shift function
2321 @cindex @code{CSHIFT} intrinsic
2322 @cindex bit operations
2325 @item @emph{Description}:
2326 @code{CSHIFT(ARRAY, SHIFT [, DIM])} performs a circular shift on elements of
2327 @var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is omitted it is
2328 taken to be @code{1}. @var{DIM} is a scaler of type @code{INTEGER} in the
2329 range of @math{1 /leq DIM /leq n)} where @math{n} is the rank of @var{ARRAY}.
2330 If the rank of @var{ARRAY} is one, then all elements of @var{ARRAY} are shifted
2331 by @var{SHIFT} places. If rank is greater than one, then all complete rank one
2332 sections of @var{ARRAY} along the given dimension are shifted. Elements
2333 shifted out one end of each rank one section are shifted back in the other end.
2335 @item @emph{Standard}:
2339 transformational function
2341 @item @emph{Syntax}:
2342 @code{RESULT = CSHIFT(A, SHIFT [, DIM])}
2344 @item @emph{Arguments}:
2345 @multitable @columnfractions .15 .80
2346 @item @var{ARRAY} @tab May be any type, not scaler.
2347 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
2348 @item @var{DIM} @tab The type shall be @code{INTEGER}.
2351 @item @emph{Return value}:
2352 Returns an array of same type and rank as the @var{ARRAY} argument.
2354 @item @emph{Example}:
2357 integer, dimension(3,3) :: a
2358 a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
2359 print '(3i3)', a(1,:)
2360 print '(3i3)', a(2,:)
2361 print '(3i3)', a(3,:)
2362 a = cshift(a, SHIFT=(/1, 2, -1/), DIM=2)
2364 print '(3i3)', a(1,:)
2365 print '(3i3)', a(2,:)
2366 print '(3i3)', a(3,:)
2367 end program test_cshift
2373 @section @code{CTIME} --- Convert a time into a string
2374 @cindex @code{CTIME} intrinsic
2375 @cindex time, conversion function
2378 @item @emph{Description}:
2379 @code{CTIME(T,S)} converts @var{T}, a system time value, such as returned
2380 by @code{TIME8()}, to a string of the form @samp{Sat Aug 19 18:13:14
2381 1995}, and returns that string into @var{S}.
2383 If @code{CTIME} is invoked as a function, it can not be invoked as a
2384 subroutine, and vice versa.
2386 @var{T} is an @code{INTENT(IN)} @code{INTEGER(KIND=8)} variable.
2387 @var{S} is an @code{INTENT(OUT)} @code{CHARACTER} variable.
2389 @item @emph{Standard}:
2395 @item @emph{Syntax}:
2396 @multitable @columnfractions .80
2397 @item @code{CALL CTIME(T,S)}.
2398 @item @code{S = CTIME(T)}, (not recommended).
2401 @item @emph{Arguments}:
2402 @multitable @columnfractions .15 .80
2403 @item @var{S}@tab The type shall be of type @code{CHARACTER}.
2404 @item @var{T}@tab The type shall be of type @code{INTEGER(KIND=8)}.
2407 @item @emph{Return value}:
2408 The converted date and time as a string.
2410 @item @emph{Example}:
2414 character(len=30) :: date
2417 ! Do something, main part of the program
2420 print *, 'Program was started on ', date
2421 end program test_ctime
2424 @item @emph{See Also}:
2425 @ref{GMTIME}, @ref{LTIME}, @ref{TIME}, @ref{TIME8}
2432 @section @code{DATE_AND_TIME} --- Date and time subroutine
2433 @cindex @code{DATE_AND_TIME} intrinsic
2434 @cindex date, current
2435 @cindex current date
2436 @cindex time, current
2437 @cindex current time
2440 @item @emph{Description}:
2441 @code{DATE_AND_TIME(DATE, TIME, ZONE, VALUES)} gets the corresponding date and
2442 time information from the real-time system clock. @var{DATE} is
2443 @code{INTENT(OUT)} and has form ccyymmdd. @var{TIME} is @code{INTENT(OUT)} and
2444 has form hhmmss.sss. @var{ZONE} is @code{INTENT(OUT)} and has form (+-)hhmm,
2445 representing the difference with respect to Coordinated Universal Time (UTC).
2446 Unavailable time and date parameters return blanks.
2448 @var{VALUES} is @code{INTENT(OUT)} and provides the following:
2450 @multitable @columnfractions .15 .30 .60
2451 @item @tab @code{VALUE(1)}: @tab The year
2452 @item @tab @code{VALUE(2)}: @tab The month
2453 @item @tab @code{VALUE(3)}: @tab The day of the month
2454 @item @tab @code{VALUE(4)}: @tab Time difference with UTC in minutes
2455 @item @tab @code{VALUE(5)}: @tab The hour of the day
2456 @item @tab @code{VALUE(6)}: @tab The minutes of the hour
2457 @item @tab @code{VALUE(7)}: @tab The seconds of the minute
2458 @item @tab @code{VALUE(8)}: @tab The milliseconds of the second
2461 @item @emph{Standard}:
2467 @item @emph{Syntax}:
2468 @code{CALL DATE_AND_TIME([DATE, TIME, ZONE, VALUES])}
2470 @item @emph{Arguments}:
2471 @multitable @columnfractions .15 .80
2472 @item @var{DATE} @tab (Optional) The type shall be @code{CHARACTER(8)} or larger.
2473 @item @var{TIME} @tab (Optional) The type shall be @code{CHARACTER(10)} or larger.
2474 @item @var{ZONE} @tab (Optional) The type shall be @code{CHARACTER(5)} or larger.
2475 @item @var{VALUES}@tab (Optional) The type shall be @code{INTEGER(8)}.
2478 @item @emph{Return value}:
2481 @item @emph{Example}:
2483 program test_time_and_date
2484 character(8) :: date
2485 character(10) :: time
2486 character(5) :: zone
2487 integer,dimension(8) :: values
2488 ! using keyword arguments
2489 call date_and_time(date,time,zone,values)
2490 call date_and_time(DATE=date,ZONE=zone)
2491 call date_and_time(TIME=time)
2492 call date_and_time(VALUES=values)
2493 print '(a,2x,a,2x,a)', date, time, zone
2494 print '(8i5))', values
2495 end program test_time_and_date
2502 @section @code{DBLE} --- Double conversion function
2503 @cindex @code{DBLE} intrinsic
2504 @cindex double conversion
2507 @item @emph{Description}:
2508 @code{DBLE(X)} Converts @var{X} to double precision real type.
2510 @item @emph{Standard}:
2516 @item @emph{Syntax}:
2517 @code{RESULT = DBLE(X)}
2519 @item @emph{Arguments}:
2520 @multitable @columnfractions .15 .80
2521 @item @var{X} @tab The type shall be @code{INTEGER(*)}, @code{REAL(*)},
2522 or @code{COMPLEX(*)}.
2525 @item @emph{Return value}:
2526 The return value is of type double precision real.
2528 @item @emph{Example}:
2533 complex :: z = (2.3,1.14)
2534 print *, dble(x), dble(i), dble(z)
2535 end program test_dble
2538 @item @emph{See also}:
2539 @ref{DFLOAT}, @ref{FLOAT}, @ref{REAL}
2545 @section @code{DCMPLX} --- Double complex conversion function
2546 @cindex @code{DCMPLX} intrinsic
2547 @cindex complex numbers, conversion to
2550 @item @emph{Description}:
2551 @code{DCMPLX(X [,Y])} returns a double complex number where @var{X} is
2552 converted to the real component. If @var{Y} is present it is converted to the
2553 imaginary component. If @var{Y} is not present then the imaginary component is
2554 set to 0.0. If @var{X} is complex then @var{Y} must not be present.
2556 @item @emph{Standard}:
2562 @item @emph{Syntax}:
2563 @code{RESULT = DCMPLX(X [, Y])}
2565 @item @emph{Arguments}:
2566 @multitable @columnfractions .15 .80
2567 @item @var{X} @tab The type may be @code{INTEGER(*)}, @code{REAL(*)},
2568 or @code{COMPLEX(*)}.
2569 @item @var{Y} @tab (Optional if @var{X} is not @code{COMPLEX(*)}.) May be
2570 @code{INTEGER(*)} or @code{REAL(*)}.
2573 @item @emph{Return value}:
2574 The return value is of type @code{COMPLEX(8)}
2576 @item @emph{Example}:
2586 print *, dcmplx(x,i)
2587 end program test_dcmplx
2594 @section @code{DFLOAT} --- Double conversion function
2595 @cindex @code{DFLOAT} intrinsic
2596 @cindex double float conversion
2599 @item @emph{Description}:
2600 @code{DFLOAT(X)} Converts @var{X} to double precision real type.
2602 @item @emph{Standard}:
2608 @item @emph{Syntax}:
2609 @code{RESULT = DFLOAT(X)}
2611 @item @emph{Arguments}:
2612 @multitable @columnfractions .15 .80
2613 @item @var{X} @tab The type shall be @code{INTEGER(*)}.
2616 @item @emph{Return value}:
2617 The return value is of type double precision real.
2619 @item @emph{Example}:
2624 end program test_dfloat
2627 @item @emph{See also}:
2628 @ref{DBLE}, @ref{FLOAT}, @ref{REAL}
2634 @section @code{DIGITS} --- Significant digits function
2635 @cindex @code{DIGITS} intrinsic
2636 @cindex digits, significant
2639 @item @emph{Description}:
2640 @code{DIGITS(X)} returns the number of significant digits of the internal model
2641 representation of @var{X}. For example, on a system using a 32-bit
2642 floating point representation, a default real number would likely return 24.
2644 @item @emph{Standard}:
2650 @item @emph{Syntax}:
2651 @code{RESULT = DIGITS(X)}
2653 @item @emph{Arguments}:
2654 @multitable @columnfractions .15 .80
2655 @item @var{X} @tab The type may be @code{INTEGER(*)} or @code{REAL(*)}.
2658 @item @emph{Return value}:
2659 The return value is of type @code{INTEGER}.
2661 @item @emph{Example}:
2664 integer :: i = 12345
2670 end program test_digits
2677 @section @code{DIM} --- Dim function
2678 @cindex @code{DIM} intrinsic
2679 @cindex @code{IDIM} intrinsic
2680 @cindex @code{DDIM} intrinsic
2684 @item @emph{Description}:
2685 @code{DIM(X,Y)} returns the difference @code{X-Y} if the result is positive;
2686 otherwise returns zero.
2688 @item @emph{Standard}:
2694 @item @emph{Syntax}:
2695 @code{RESULT = DIM(X, Y)}
2697 @item @emph{Arguments}:
2698 @multitable @columnfractions .15 .80
2699 @item @var{X} @tab The type shall be @code{INTEGER(*)} or @code{REAL(*)}
2700 @item @var{Y} @tab The type shall be the same type and kind as @var{X}.
2703 @item @emph{Return value}:
2704 The return value is of type @code{INTEGER(*)} or @code{REAL(*)}.
2706 @item @emph{Example}:
2712 x = dim(4.345_8, 2.111_8)
2715 end program test_dim
2718 @item @emph{Specific names}:
2719 @multitable @columnfractions .20 .20 .20 .40
2720 @item Name @tab Argument @tab Return type @tab Standard
2721 @item @code{IDIM(X,Y)} @tab @code{INTEGER(4) X,Y} @tab @code{INTEGER(4)} @tab F77 and later
2722 @item @code{DDIM(X,Y)} @tab @code{REAL(8) X,Y} @tab @code{REAL(8)} @tab F77 and later
2729 @section @code{DOT_PRODUCT} --- Dot product function
2730 @cindex @code{DOT_PRODUCT} intrinsic
2734 @item @emph{Description}:
2735 @code{DOT_PRODUCT(X,Y)} computes the dot product multiplication of two vectors
2736 @var{X} and @var{Y}. The two vectors may be either numeric or logical
2737 and must be arrays of rank one and of equal size. If the vectors are
2738 @code{INTEGER(*)} or @code{REAL(*)}, the result is @code{SUM(X*Y)}. If the
2739 vectors are @code{COMPLEX(*)}, the result is @code{SUM(CONJG(X)*Y)}. If the
2740 vectors are @code{LOGICAL}, the result is @code{ANY(X.AND.Y)}.
2742 @item @emph{Standard}:
2746 transformational function
2748 @item @emph{Syntax}:
2749 @code{RESULT = DOT_PRODUCT(X, Y)}
2751 @item @emph{Arguments}:
2752 @multitable @columnfractions .15 .80
2753 @item @var{X} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
2754 @item @var{Y} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
2757 @item @emph{Return value}:
2758 If the arguments are numeric, the return value is a scaler of numeric type,
2759 @code{INTEGER(*)}, @code{REAL(*)}, or @code{COMPLEX(*)}. If the arguments are
2760 @code{LOGICAL}, the return value is @code{.TRUE.} or @code{.FALSE.}.
2762 @item @emph{Example}:
2764 program test_dot_prod
2765 integer, dimension(3) :: a, b
2772 print *, dot_product(a,b)
2773 end program test_dot_prod
2780 @section @code{DPROD} --- Double product function
2781 @cindex @code{DPROD} intrinsic
2782 @cindex double-precision product
2785 @item @emph{Description}:
2786 @code{DPROD(X,Y)} returns the product @code{X*Y}.
2788 @item @emph{Standard}:
2794 @item @emph{Syntax}:
2795 @code{RESULT = DPROD(X, Y)}
2797 @item @emph{Arguments}:
2798 @multitable @columnfractions .15 .80
2799 @item @var{X} @tab The type shall be @code{REAL}.
2800 @item @var{Y} @tab The type shall be @code{REAL}.
2803 @item @emph{Return value}:
2804 The return value is of type @code{REAL(8)}.
2806 @item @emph{Example}:
2815 end program test_dprod
2822 @section @code{DREAL} --- Double real part function
2823 @cindex @code{DREAL} intrinsic
2824 @cindex double-precision real part
2827 @item @emph{Description}:
2828 @code{DREAL(Z)} returns the real part of complex variable @var{Z}.
2830 @item @emph{Standard}:
2836 @item @emph{Syntax}:
2837 @code{RESULT = DREAL(Z)}
2839 @item @emph{Arguments}:
2840 @multitable @columnfractions .15 .80
2841 @item @var{Z} @tab The type shall be @code{COMPLEX(8)}.
2844 @item @emph{Return value}:
2845 The return value is of type @code{REAL(8)}.
2847 @item @emph{Example}:
2850 complex(8) :: z = (1.3_8,7.2_8)
2852 end program test_dreal
2855 @item @emph{See also}:
2863 @section @code{DTIME} --- Execution time subroutine (or function)
2864 @cindex @code{DTIME} intrinsic
2865 @cindex time, elapsed
2866 @cindex elapsed time
2869 @item @emph{Description}:
2870 @code{DTIME(TARRAY, RESULT)} initially returns the number of seconds of runtime
2871 since the start of the process's execution in @var{RESULT}. @var{TARRAY}
2872 returns the user and system components of this time in @code{TARRAY(1)} and
2873 @code{TARRAY(2)} respectively. @var{RESULT} is equal to @code{TARRAY(1) +
2876 Subsequent invocations of @code{DTIME} return values accumulated since the
2877 previous invocation.
2879 On some systems, the underlying timings are represented using types with
2880 sufficiently small limits that overflows (wrap around) are possible, such as
2881 32-bit types. Therefore, the values returned by this intrinsic might be, or
2882 become, negative, or numerically less than previous values, during a single
2883 run of the compiled program.
2885 If @code{DTIME} is invoked as a function, it can not be invoked as a
2886 subroutine, and vice versa.
2888 @var{TARRAY} and @var{RESULT} are @code{INTENT(OUT)} and provide the following:
2890 @multitable @columnfractions .15 .30 .60
2891 @item @tab @code{TARRAY(1)}: @tab User time in seconds.
2892 @item @tab @code{TARRAY(2)}: @tab System time in seconds.
2893 @item @tab @code{RESULT}: @tab Run time since start in seconds.
2896 @item @emph{Standard}:
2902 @item @emph{Syntax}:
2903 @multitable @columnfractions .80
2904 @item @code{CALL DTIME(TARRAY, RESULT)}.
2905 @item @code{RESULT = DTIME(TARRAY)}, (not recommended).
2908 @item @emph{Arguments}:
2909 @multitable @columnfractions .15 .80
2910 @item @var{TARRAY}@tab The type shall be @code{REAL, DIMENSION(2)}.
2911 @item @var{RESULT}@tab The type shall be @code{REAL}.
2914 @item @emph{Return value}:
2915 Elapsed time in seconds since the start of program execution.
2917 @item @emph{Example}:
2921 real, dimension(2) :: tarray
2923 call dtime(tarray, result)
2927 do i=1,100000000 ! Just a delay
2930 call dtime(tarray, result)
2934 end program test_dtime
2941 @section @code{EOSHIFT} --- End-off shift function
2942 @cindex @code{EOSHIFT} intrinsic
2943 @cindex bit operations
2946 @item @emph{Description}:
2947 @code{EOSHIFT(ARRAY, SHIFT[,BOUNDARY, DIM])} performs an end-off shift on
2948 elements of @var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is
2949 omitted it is taken to be @code{1}. @var{DIM} is a scaler of type
2950 @code{INTEGER} in the range of @math{1 /leq DIM /leq n)} where @math{n} is the
2951 rank of @var{ARRAY}. If the rank of @var{ARRAY} is one, then all elements of
2952 @var{ARRAY} are shifted by @var{SHIFT} places. If rank is greater than one,
2953 then all complete rank one sections of @var{ARRAY} along the given dimension are
2954 shifted. Elements shifted out one end of each rank one section are dropped. If
2955 @var{BOUNDARY} is present then the corresponding value of from @var{BOUNDARY}
2956 is copied back in the other end. If @var{BOUNDARY} is not present then the
2957 following are copied in depending on the type of @var{ARRAY}.
2959 @multitable @columnfractions .15 .80
2960 @item @emph{Array Type} @tab @emph{Boundary Value}
2961 @item Numeric @tab 0 of the type and kind of @var{ARRAY}.
2962 @item Logical @tab @code{.FALSE.}.
2963 @item Character(@var{len}) @tab @var{len} blanks.
2966 @item @emph{Standard}:
2970 transformational function
2972 @item @emph{Syntax}:
2973 @code{RESULT = EOSHIFT(A, SHIFT [, BOUNDARY, DIM])}
2975 @item @emph{Arguments}:
2976 @multitable @columnfractions .15 .80
2977 @item @var{ARRAY} @tab May be any type, not scaler.
2978 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
2979 @item @var{BOUNDARY} @tab Same type as @var{ARRAY}.
2980 @item @var{DIM} @tab The type shall be @code{INTEGER}.
2983 @item @emph{Return value}:
2984 Returns an array of same type and rank as the @var{ARRAY} argument.
2986 @item @emph{Example}:
2988 program test_eoshift
2989 integer, dimension(3,3) :: a
2990 a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
2991 print '(3i3)', a(1,:)
2992 print '(3i3)', a(2,:)
2993 print '(3i3)', a(3,:)
2994 a = EOSHIFT(a, SHIFT=(/1, 2, 1/), BOUNDARY=-5, DIM=2)
2996 print '(3i3)', a(1,:)
2997 print '(3i3)', a(2,:)
2998 print '(3i3)', a(3,:)
2999 end program test_eoshift
3006 @section @code{EPSILON} --- Epsilon function
3007 @cindex @code{EPSILON} intrinsic
3008 @cindex epsilon, significant
3011 @item @emph{Description}:
3012 @code{EPSILON(X)} returns a nearly negligible number relative to @code{1}.
3014 @item @emph{Standard}:
3020 @item @emph{Syntax}:
3021 @code{RESULT = EPSILON(X)}
3023 @item @emph{Arguments}:
3024 @multitable @columnfractions .15 .80
3025 @item @var{X} @tab The type shall be @code{REAL(*)}.
3028 @item @emph{Return value}:
3029 The return value is of same type as the argument.
3031 @item @emph{Example}:
3033 program test_epsilon
3038 end program test_epsilon
3045 @section @code{ERF} --- Error function
3046 @cindex @code{ERF} intrinsic
3047 @cindex error function
3050 @item @emph{Description}:
3051 @code{ERF(X)} computes the error function of @var{X}.
3053 @item @emph{Standard}:
3059 @item @emph{Syntax}:
3060 @code{RESULT = ERF(X)}
3062 @item @emph{Arguments}:
3063 @multitable @columnfractions .15 .80
3064 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
3067 @item @emph{Return value}:
3068 The return value is a scalar of type @code{REAL(*)} and it is positive
3069 (@math{ - 1 \leq erf (x) \leq 1 }.
3071 @item @emph{Example}:
3074 real(8) :: x = 0.17_8
3076 end program test_erf
3079 @item @emph{Specific names}:
3080 @multitable @columnfractions .20 .20 .20 .40
3081 @item Name @tab Argument @tab Return type @tab Standard
3082 @item @code{DERF(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
3089 @section @code{ERFC} --- Error function
3090 @cindex @code{ERFC} intrinsic
3091 @cindex error function
3094 @item @emph{Description}:
3095 @code{ERFC(X)} computes the complementary error function of @var{X}.
3097 @item @emph{Standard}:
3103 @item @emph{Syntax}:
3104 @code{RESULT = ERFC(X)}
3106 @item @emph{Arguments}:
3107 @multitable @columnfractions .15 .80
3108 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
3111 @item @emph{Return value}:
3112 The return value is a scalar of type @code{REAL(*)} and it is positive
3113 (@math{ 0 \leq erfc (x) \leq 2 }.
3115 @item @emph{Example}:
3118 real(8) :: x = 0.17_8
3120 end program test_erfc
3123 @item @emph{Specific names}:
3124 @multitable @columnfractions .20 .20 .20 .40
3125 @item Name @tab Argument @tab Return type @tab Standard
3126 @item @code{DERFC(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
3133 @section @code{ETIME} --- Execution time subroutine (or function)
3134 @cindex @code{ETIME} intrinsic
3135 @cindex time, elapsed
3138 @item @emph{Description}:
3139 @code{ETIME(TARRAY, RESULT)} returns the number of seconds of runtime
3140 since the start of the process's execution in @var{RESULT}. @var{TARRAY}
3141 returns the user and system components of this time in @code{TARRAY(1)} and
3142 @code{TARRAY(2)} respectively. @var{RESULT} is equal to @code{TARRAY(1) + TARRAY(2)}.
3144 On some systems, the underlying timings are represented using types with
3145 sufficiently small limits that overflows (wrap around) are possible, such as
3146 32-bit types. Therefore, the values returned by this intrinsic might be, or
3147 become, negative, or numerically less than previous values, during a single
3148 run of the compiled program.
3150 If @code{ETIME} is invoked as a function, it can not be invoked as a
3151 subroutine, and vice versa.
3153 @var{TARRAY} and @var{RESULT} are @code{INTENT(OUT)} and provide the following:
3155 @multitable @columnfractions .15 .30 .60
3156 @item @tab @code{TARRAY(1)}: @tab User time in seconds.
3157 @item @tab @code{TARRAY(2)}: @tab System time in seconds.
3158 @item @tab @code{RESULT}: @tab Run time since start in seconds.
3161 @item @emph{Standard}:
3167 @item @emph{Syntax}:
3168 @multitable @columnfractions .8
3169 @item @code{CALL ETIME(TARRAY, RESULT)}.
3170 @item @code{RESULT = ETIME(TARRAY)}, (not recommended).
3173 @item @emph{Arguments}:
3174 @multitable @columnfractions .15 .80
3175 @item @var{TARRAY}@tab The type shall be @code{REAL, DIMENSION(2)}.
3176 @item @var{RESULT}@tab The type shall be @code{REAL}.
3179 @item @emph{Return value}:
3180 Elapsed time in seconds since the start of program execution.
3182 @item @emph{Example}:
3186 real, dimension(2) :: tarray
3188 call ETIME(tarray, result)
3192 do i=1,100000000 ! Just a delay
3195 call ETIME(tarray, result)
3199 end program test_etime
3202 @item @emph{See also}:
3210 @section @code{EXIT} --- Exit the program with status.
3211 @cindex @code{EXIT} intrinsic
3212 @cindex exit program
3215 @item @emph{Description}:
3216 @code{EXIT} causes immediate termination of the program with status. If status
3217 is omitted it returns the canonical @emph{success} for the system. All Fortran
3218 I/O units are closed.
3220 @item @emph{Standard}:
3226 @item @emph{Syntax}:
3227 @code{CALL EXIT([STATUS])}
3229 @item @emph{Arguments}:
3230 @multitable @columnfractions .15 .80
3231 @item @var{STATUS} @tab The type of the argument shall be @code{INTEGER(*)}.
3234 @item @emph{Return value}:
3235 @code{STATUS} is passed to the parent process on exit.
3237 @item @emph{Example}:
3240 integer :: STATUS = 0
3241 print *, 'This program is going to exit.'
3243 end program test_exit
3246 @item @emph{See also}:
3247 @ref{ABORT}, @ref{KILL}
3253 @section @code{EXP} --- Exponential function
3254 @cindex @code{EXP} intrinsic
3255 @cindex @code{DEXP} intrinsic
3256 @cindex @code{ZEXP} intrinsic
3257 @cindex @code{CDEXP} intrinsic
3261 @item @emph{Description}:
3262 @code{EXP(X)} computes the base @math{e} exponential of @var{X}.
3264 @item @emph{Standard}:
3265 F77 and later, has overloads that are GNU extensions
3270 @item @emph{Syntax}:
3271 @code{RESULT = EXP(X)}
3273 @item @emph{Arguments}:
3274 @multitable @columnfractions .15 .80
3275 @item @var{X} @tab The type shall be @code{REAL(*)} or
3279 @item @emph{Return value}:
3280 The return value has same type and kind as @var{X}.
3282 @item @emph{Example}:
3287 end program test_exp
3290 @item @emph{Specific names}:
3291 @multitable @columnfractions .20 .20 .20 .40
3292 @item Name @tab Argument @tab Return type @tab Standard
3293 @item @code{DEXP(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
3294 @item @code{CEXP(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab F77 and later
3295 @item @code{ZEXP(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
3296 @item @code{CDEXP(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
3303 @section @code{EXPONENT} --- Exponent function
3304 @cindex @code{EXPONENT} intrinsic
3305 @cindex exponent part of a real number
3308 @item @emph{Description}:
3309 @code{EXPONENT(X)} returns the value of the exponent part of @var{X}. If @var{X}
3310 is zero the value returned is zero.
3312 @item @emph{Standard}:
3318 @item @emph{Syntax}:
3319 @code{RESULT = EXPONENT(X)}
3321 @item @emph{Arguments}:
3322 @multitable @columnfractions .15 .80
3323 @item @var{X} @tab The type shall be @code{REAL(*)}.
3326 @item @emph{Return value}:
3327 The return value is of type default @code{INTEGER}.
3329 @item @emph{Example}:
3331 program test_exponent
3336 print *, exponent(0.0)
3337 end program test_exponent
3343 @section @code{FDATE} --- Get the current time as a string
3344 @cindex @code{FDATE} intrinsic
3345 @cindex time, current
3346 @cindex current time
3347 @cindex date, current
3348 @cindex current date
3351 @item @emph{Description}:
3352 @code{FDATE(DATE)} returns the current date (using the same format as
3353 @code{CTIME}) in @var{DATE}. It is equivalent to @code{CALL CTIME(DATE,
3356 If @code{FDATE} is invoked as a function, it can not be invoked as a
3357 subroutine, and vice versa.
3359 @var{DATE} is an @code{INTENT(OUT)} @code{CHARACTER} variable.
3361 @item @emph{Standard}:
3367 @item @emph{Syntax}:
3368 @multitable @columnfractions .80
3369 @item @code{CALL FDATE(DATE)}.
3370 @item @code{DATE = FDATE()}, (not recommended).
3373 @item @emph{Arguments}:
3374 @multitable @columnfractions .15 .80
3375 @item @var{DATE}@tab The type shall be of type @code{CHARACTER}.
3378 @item @emph{Return value}:
3379 The current date as a string.
3381 @item @emph{Example}:
3385 character(len=30) :: date
3387 print *, 'Program started on ', date
3388 do i = 1, 100000000 ! Just a delay
3392 print *, 'Program ended on ', date
3393 end program test_fdate
3399 @section @code{FLOAT} --- Convert integer to default real
3400 @cindex @code{FLOAT} intrinsic
3401 @cindex conversion function (float)
3404 @item @emph{Description}:
3405 @code{FLOAT(I)} converts the integer @var{I} to a default real value.
3407 @item @emph{Standard}:
3413 @item @emph{Syntax}:
3414 @code{RESULT = FLOAT(I)}
3416 @item @emph{Arguments}:
3417 @multitable @columnfractions .15 .80
3418 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
3421 @item @emph{Return value}:
3422 The return value is of type default @code{REAL}.
3424 @item @emph{Example}:
3428 if (float(i) /= 1.) call abort
3429 end program test_float
3432 @item @emph{See also}:
3433 @ref{DBLE}, @ref{DFLOAT}, @ref{REAL}
3439 @section @code{FGET} --- Read a single character in stream mode from stdin
3440 @cindex @code{FGET} intrinsic
3441 @cindex file operations
3442 @cindex stream operations
3445 @item @emph{Description}:
3446 Read a single character in stream mode from stdin by bypassing normal
3447 formatted output. Stream I/O should not be mixed with normal record-oriented
3448 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
3450 This intrinsic routine is provided for backwards compatibility with
3451 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
3452 Programmers should consider the use of new stream IO feature in new code
3453 for future portability. See also @ref{Fortran 2003 status}.
3455 @item @emph{Standard}:
3459 Non-elemental subroutine
3461 @item @emph{Syntax}:
3462 @code{CALL FGET(C [, STATUS])}
3464 @item @emph{Arguments}:
3465 @multitable @columnfractions .15 .80
3466 @item @var{C} @tab The type shall be @code{CHARACTER}.
3467 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
3468 Returns 0 on success, -1 on end-of-file, and a
3469 system specific positive error code otherwise.
3472 @item @emph{Example}:
3475 INTEGER, PARAMETER :: strlen = 100
3476 INTEGER :: status, i = 1
3477 CHARACTER(len=strlen) :: str = ""
3479 WRITE (*,*) 'Enter text:'
3481 CALL fget(str(i:i), status)
3482 if (status /= 0 .OR. i > strlen) exit
3485 WRITE (*,*) TRIM(str)
3489 @item @emph{See also}:
3490 @ref{FGETC}, @ref{FPUT}, @ref{FPUTC}
3495 @section @code{FGETC} --- Read a single character in stream mode
3496 @cindex @code{FGETC} intrinsic
3497 @cindex file operations
3498 @cindex stream operations
3501 @item @emph{Description}:
3502 Read a single character in stream mode by bypassing normal formatted output.
3503 Stream I/O should not be mixed with normal record-oriented (formatted or
3504 unformatted) I/O on the same unit; the results are unpredictable.
3506 This intrinsic routine is provided for backwards compatibility with
3507 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
3508 Programmers should consider the use of new stream IO feature in new code
3509 for future portability. See also @ref{Fortran 2003 status}.
3511 @item @emph{Standard}:
3515 Non-elemental subroutine
3517 @item @emph{Syntax}:
3518 @code{CALL FGETC(UNIT, C [, STATUS])}
3520 @item @emph{Arguments}:
3521 @multitable @columnfractions .15 .80
3522 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
3523 @item @var{C} @tab The type shall be @code{CHARACTER}.
3524 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. Returns 0 on success,
3525 -1 on end-of-file and a system specific positive error code otherwise.
3528 @item @emph{Example}:
3531 INTEGER :: fd = 42, status
3534 OPEN(UNIT=fd, FILE="/etc/passwd", ACTION="READ", STATUS = "OLD")
3536 CALL fgetc(fd, c, status)
3537 IF (status /= 0) EXIT
3544 @item @emph{See also}:
3545 @ref{FGET}, @ref{FPUT}, @ref{FPUTC}
3551 @section @code{FLOOR} --- Integer floor function
3552 @cindex @code{FLOOR} intrinsic
3556 @item @emph{Description}:
3557 @code{FLOOR(X)} returns the greatest integer less than or equal to @var{X}.
3559 @item @emph{Standard}:
3565 @item @emph{Syntax}:
3566 @code{RESULT = FLOOR(X [, KIND])}
3568 @item @emph{Arguments}:
3569 @multitable @columnfractions .15 .80
3570 @item @var{X} @tab The type shall be @code{REAL(*)}.
3571 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
3572 expression indicating the kind parameter of
3576 @item @emph{Return value}:
3577 The return value is of type @code{INTEGER(KIND)}
3579 @item @emph{Example}:
3584 print *, floor(x) ! returns 63
3585 print *, floor(y) ! returns -64
3586 end program test_floor
3589 @item @emph{See also}:
3590 @ref{CEILING}, @ref{NINT}
3597 @section @code{FLUSH} --- Flush I/O unit(s)
3598 @cindex @code{FLUSH} intrinsic
3599 @cindex flush output files
3602 @item @emph{Description}:
3603 Flushes Fortran unit(s) currently open for output. Without the optional
3604 argument, all units are flushed, otherwise just the unit specified.
3606 @item @emph{Standard}:
3610 non-elemental subroutine
3612 @item @emph{Syntax}:
3613 @code{CALL FLUSH(UNIT)}
3615 @item @emph{Arguments}:
3616 @multitable @columnfractions .15 .80
3617 @item @var{UNIT} @tab (Optional) The type shall be @code{INTEGER}.
3621 Beginning with the Fortran 2003 standard, there is a @code{FLUSH}
3622 statement that should be preferred over the @code{FLUSH} intrinsic.
3629 @section @code{FNUM} --- File number function
3630 @cindex @code{FNUM} intrinsic
3634 @item @emph{Description}:
3635 @code{FNUM(UNIT)} returns the POSIX file descriptor number corresponding to the
3636 open Fortran I/O unit @code{UNIT}.
3638 @item @emph{Standard}:
3642 non-elemental function
3644 @item @emph{Syntax}:
3645 @code{RESULT = FNUM(UNIT)}
3647 @item @emph{Arguments}:
3648 @multitable @columnfractions .15 .80
3649 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
3652 @item @emph{Return value}:
3653 The return value is of type @code{INTEGER}
3655 @item @emph{Example}:
3659 open (unit=10, status = "scratch")
3663 end program test_fnum
3670 @section @code{FPUT} --- Write a single character in stream mode to stdout
3671 @cindex @code{FPUT} intrinsic
3672 @cindex file operations
3673 @cindex stream operations
3676 @item @emph{Description}:
3677 Write a single character in stream mode to stdout by bypassing normal
3678 formatted output. Stream I/O should not be mixed with normal record-oriented
3679 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
3681 This intrinsic routine is provided for backwards compatibility with
3682 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
3683 Programmers should consider the use of new stream IO feature in new code
3684 for future portability. See also @ref{Fortran 2003 status}.
3686 @item @emph{Standard}:
3690 Non-elemental subroutine
3692 @item @emph{Syntax}:
3693 @code{CALL FPUT(C [, STATUS])}
3695 @item @emph{Arguments}:
3696 @multitable @columnfractions .15 .80
3697 @item @var{C} @tab The type shall be @code{CHARACTER}.
3698 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. Returns 0 on success,
3699 -1 on end-of-file and a system specific positive error code otherwise.
3702 @item @emph{Example}:
3705 CHARACTER(len=*) :: str = "gfortran"
3707 DO i = 1, len_trim(str)
3713 @item @emph{See also}:
3714 @ref{FPUTC}, @ref{FGET}, @ref{FGETC}
3720 @section @code{FPUTC} --- Write a single character in stream mode
3721 @cindex @code{FPUTC} intrinsic
3722 @cindex file operations
3723 @cindex stream operations
3726 @item @emph{Description}:
3727 Write a single character in stream mode by bypassing normal formatted
3728 output. Stream I/O should not be mixed with normal record-oriented
3729 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
3731 This intrinsic routine is provided for backwards compatibility with
3732 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
3733 Programmers should consider the use of new stream IO feature in new code
3734 for future portability. See also @ref{Fortran 2003 status}.
3736 @item @emph{Standard}:
3740 Non-elemental subroutine
3742 @item @emph{Syntax}:
3743 @code{CALL FPUTC(UNIT, C [, STATUS])}
3745 @item @emph{Arguments}:
3746 @multitable @columnfractions .15 .80
3747 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
3748 @item @var{C} @tab The type shall be @code{CHARACTER}.
3749 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. Returns 0 on success,
3750 -1 on end-of-file and a system specific positive error code otherwise.
3753 @item @emph{Example}:
3756 CHARACTER(len=*) :: str = "gfortran"
3757 INTEGER :: fd = 42, i
3759 OPEN(UNIT = fd, FILE = "out", ACTION = "WRITE", STATUS="NEW")
3760 DO i = 1, len_trim(str)
3761 CALL fputc(fd, str(i:i))
3767 @item @emph{See also}:
3768 @ref{FPUT}, @ref{FGET}, @ref{FGETC}
3774 @section @code{FRACTION} --- Fractional part of the model representation
3775 @cindex @code{FRACTION} intrinsic
3776 @cindex fractional part
3779 @item @emph{Description}:
3780 @code{FRACTION(X)} returns the fractional part of the model
3781 representation of @code{X}.
3783 @item @emph{Standard}:
3789 @item @emph{Syntax}:
3790 @code{Y = FRACTION(X)}
3792 @item @emph{Arguments}:
3793 @multitable @columnfractions .15 .80
3794 @item @var{X} @tab The type of the argument shall be a @code{REAL}.
3797 @item @emph{Return value}:
3798 The return value is of the same type and kind as the argument.
3799 The fractional part of the model representation of @code{X} is returned;
3800 it is @code{X * RADIX(X)**(-EXPONENT(X))}.
3802 @item @emph{Example}:
3804 program test_fraction
3807 print *, fraction(x), x * radix(x)**(-exponent(x))
3808 end program test_fraction
3816 @section @code{FREE} --- Frees memory
3817 @cindex @code{FREE} intrinsic
3818 @cindex Cray pointers
3821 @item @emph{Description}:
3822 Frees memory previously allocated by @code{MALLOC()}. The @code{FREE}
3823 intrinsic is an extension intended to be used with Cray pointers, and is
3824 provided in GNU Fortran to allow user to compile legacy code. For
3825 new code using Fortran 95 pointers, the memory de-allocation intrinsic is
3828 @item @emph{Standard}:
3834 @item @emph{Syntax}:
3837 @item @emph{Arguments}:
3838 @multitable @columnfractions .15 .80
3839 @item @var{PTR} @tab The type shall be @code{INTEGER}. It represents the
3840 location of the memory that should be de-allocated.
3843 @item @emph{Return value}:
3846 @item @emph{Example}:
3847 See @code{MALLOC} for an example.
3849 @item @emph{See also}:
3857 @section @code{FSTAT} --- Get file status
3858 @cindex @code{FSTAT} intrinsic
3859 @cindex file system operations
3862 @item @emph{Description}:
3863 @code{FSTAT} is identical to @ref{STAT}, except that information about an
3864 already opened file is obtained.
3866 The elements in @code{BUFF} are the same as described by @ref{STAT}.
3868 @item @emph{Standard}:
3872 Non-elemental subroutine
3874 @item @emph{Syntax}:
3875 @code{CALL FSTAT(UNIT, BUFF [, STATUS])}
3877 @item @emph{Arguments}:
3878 @multitable @columnfractions .15 .80
3879 @item @var{UNIT} @tab An open I/O unit number of type @code{INTEGER}.
3880 @item @var{BUFF} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
3881 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0
3882 on success and a system specific error code otherwise.
3885 @item @emph{Example}:
3886 See @ref{STAT} for an example.
3888 @item @emph{See also}:
3889 To stat a link: @ref{LSTAT}, to stat a file: @ref{STAT}
3895 @section @code{FSEEK} --- Low level file positioning subroutine
3896 @cindex @code{FSEEK} intrinsic
3897 @cindex file system operations
3899 Not yet implemented in GNU Fortran.
3902 @item @emph{Description}:
3904 @item @emph{Standard}:
3910 @item @emph{Syntax}:
3911 @item @emph{Arguments}:
3912 @item @emph{Return value}:
3913 @item @emph{Example}:
3914 @item @emph{Specific names}:
3915 @item @emph{See also}:
3916 @uref{http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19292, g77 features lacking in gfortran}
3923 @section @code{FTELL} --- Current stream position
3924 @cindex @code{FTELL} intrinsic
3927 @item @emph{Description}:
3928 Retrieves the current position within an open file.
3930 This intrinsic is provided in both subroutine and function forms; however,
3931 only one form can be used in any given program unit.
3933 @item @emph{Standard}:
3937 Subroutine, function
3939 @item @emph{Syntax}:
3940 @multitable @columnfractions .80
3941 @item @code{CALL FTELL(UNIT, OFFSET)}
3942 @item @code{OFFSET = FTELL(UNIT)}
3945 @item @emph{Arguments}:
3946 @multitable @columnfractions .15 .80
3947 @item @var{OFFSET} @tab Shall of type @code{INTEGER}.
3948 @item @var{UNIT} @tab Shall of type @code{INTEGER}.
3951 @item @emph{Return value}:
3952 In either syntax, @var{OFFSET} is set to the current offset of unit
3953 number @var{UNIT}, or to @math{-1} if the unit is not currently open.
3955 @item @emph{Example}:
3959 OPEN(10, FILE="temp.dat")
3965 @item @emph{See also}:
3972 @section @code{GETARG} --- Get command line arguments
3973 @cindex @code{GETARG} intrinsic
3974 @cindex command-line arguments, to program
3977 @item @emph{Description}:
3978 Retrieve the @var{N}th argument that was passed on the
3979 command line when the containing program was invoked.
3981 This intrinsic routine is provided for backwards compatibility with
3982 GNU Fortran 77. In new code, programmers should consider the use of
3983 the @ref{GET_COMMAND_ARGUMENT} intrinsic defined by the Fortran 2003
3986 @item @emph{Standard}:
3992 @item @emph{Syntax}:
3993 @code{CALL GETARG(N, ARG)}
3995 @item @emph{Arguments}:
3996 @multitable @columnfractions .15 .80
3997 @item @var{N} @tab Shall of type @code{INTEGER(4)}, @math{@var{N} \geq 0}
3998 @item @var{ARG} @tab Shall be of type @code{CHARACTER(*)}.
4001 @item @emph{Return value}:
4002 After @code{GETARG} returns, the @var{ARG} argument holds the @var{N}th
4003 command line argument. If @var{ARG} can not hold the argument, it is
4004 truncated to fit the length of @var{ARG}. If there are less than @var{N}
4005 arguments specified at the command line, @var{ARG} will be filled with blanks.
4006 If @math{@var{N} = 0}, @var{ARG} is set to the name of the program (on systems
4007 that support this feature).
4009 @item @emph{Example}:
4013 CHARACTER(len=32) :: arg
4022 @item @emph{See also}:
4023 GNU Fortran 77 compatibility function: @ref{IARGC}
4025 F2003 functions and subroutines: @ref{GET_COMMAND}, @ref{GET_COMMAND_ARGUMENT},
4026 @ref{COMMAND_ARGUMENT_COUNT}
4032 @section @code{GET_COMMAND} --- Get the entire command line
4033 @cindex @code{GET_COMMAND} intrinsic
4034 @cindex command-line arguments, to program
4037 @item @emph{Description}:
4038 Retrieve the entire command line that was used to invoke the program.
4040 @item @emph{Standard}:
4046 @item @emph{Syntax}:
4047 @code{CALL GET_COMMAND(CMD)}
4049 @item @emph{Arguments}:
4050 @multitable @columnfractions .15 .80
4051 @item @var{CMD} @tab Shall be of type @code{CHARACTER(*)}.
4054 @item @emph{Return value}:
4055 Stores the entire command line that was used to invoke the program in @var{ARG}.
4056 If @var{ARG} is not large enough, the command will be truncated.
4058 @item @emph{Example}:
4060 PROGRAM test_get_command
4061 CHARACTER(len=255) :: cmd
4062 CALL get_command(cmd)
4063 WRITE (*,*) TRIM(cmd)
4067 @item @emph{See also}:
4068 @ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
4073 @node GET_COMMAND_ARGUMENT
4074 @section @code{GET_COMMAND_ARGUMENT} --- Get command line arguments
4075 @cindex @code{GET_COMMAND_ARGUMENT} intrinsic
4076 @cindex command-line arguments, to program
4079 @item @emph{Description}:
4080 Retrieve the @var{N}th argument that was passed on the
4081 command line when the containing program was invoked.
4083 @item @emph{Standard}:
4089 @item @emph{Syntax}:
4090 @code{CALL GET_COMMAND_ARGUMENT(N, ARG)}
4092 @item @emph{Arguments}:
4093 @multitable @columnfractions .15 .80
4094 @item @var{N} @tab Shall of type @code{INTEGER(4)}, @math{@var{N} \geq 0}
4095 @item @var{ARG} @tab Shall be of type @code{CHARACTER(*)}.
4098 @item @emph{Return value}:
4099 After @code{GET_COMMAND_ARGUMENT} returns, the @var{ARG} argument holds the
4100 @var{N}th command line argument. If @var{ARG} can not hold the argument, it is
4101 truncated to fit the length of @var{ARG}. If there are less than @var{N}
4102 arguments specified at the command line, @var{ARG} will be filled with blanks.
4103 If @math{@var{N} = 0}, @var{ARG} is set to the name of the program (on systems
4104 that support this feature).
4106 @item @emph{Example}:
4108 PROGRAM test_get_command_argument
4110 CHARACTER(len=32) :: arg
4114 CALL get_command_argument(i, arg)
4115 IF (LEN_TRIM(arg) == 0) EXIT
4117 WRITE (*,*) TRIM(arg)
4123 @item @emph{See also}:
4124 @ref{GET_COMMAND}, @ref{COMMAND_ARGUMENT_COUNT}
4130 @section @code{GETCWD} --- Get current working directory
4131 @cindex @code{GETCWD} intrinsic
4132 @cindex file system operations
4135 @item @emph{Description}:
4136 Get current working directory.
4138 @item @emph{Standard}:
4142 Non-elemental subroutine.
4144 @item @emph{Syntax}:
4145 @code{CALL GETCWD(CWD [, STATUS])}
4147 @item @emph{Arguments}:
4148 @multitable @columnfractions .15 .80
4149 @item @var{CWD} @tab The type shall be @code{CHARACTER(*)}.
4150 @item @var{STATUS} @tab (Optional) status flag. Returns 0 on success,
4151 a system specific and non-zero error code otherwise.
4154 @item @emph{Example}:
4157 CHARACTER(len=255) :: cwd
4159 WRITE(*,*) TRIM(cwd)
4163 @item @emph{See also}:
4170 @section @code{GETENV} --- Get an environmental variable
4171 @cindex @code{GETENV} intrinsic
4172 @cindex environment variable
4175 @item @emph{Description}:
4176 Get the @var{VALUE} of the environmental variable @var{ENVVAR}.
4178 This intrinsic routine is provided for backwards compatibility with
4179 GNU Fortran 77. In new code, programmers should consider the use of
4180 the @ref{GET_ENVIRONMENT_VARIABLE} intrinsic defined by the Fortran
4183 @item @emph{Standard}:
4189 @item @emph{Syntax}:
4190 @code{CALL GETENV(ENVVAR, VALUE)}
4192 @item @emph{Arguments}:
4193 @multitable @columnfractions .15 .80
4194 @item @var{ENVVAR} @tab Shall be of type @code{CHARACTER(*)}.
4195 @item @var{VALUE} @tab Shall be of type @code{CHARACTER(*)}.
4198 @item @emph{Return value}:
4199 Stores the value of @var{ENVVAR} in @var{VALUE}. If @var{VALUE} is
4200 not large enough to hold the data, it is truncated. If @var{ENVVAR}
4201 is not set, @var{VALUE} will be filled with blanks.
4203 @item @emph{Example}:
4206 CHARACTER(len=255) :: homedir
4207 CALL getenv("HOME", homedir)
4208 WRITE (*,*) TRIM(homedir)
4212 @item @emph{See also}:
4213 @ref{GET_ENVIRONMENT_VARIABLE}
4218 @node GET_ENVIRONMENT_VARIABLE
4219 @section @code{GET_ENVIRONMENT_VARIABLE} --- Get an environmental variable
4220 @cindex @code{GET_ENVIRONMENT_VARIABLE} intrinsic
4221 @cindex environment variable
4224 @item @emph{Description}:
4225 Get the @var{VALUE} of the environmental variable @var{ENVVAR}.
4227 @item @emph{Standard}:
4233 @item @emph{Syntax}:
4234 @code{CALL GET_ENVIRONMENT_VARIABLE(ENVVAR, VALUE)}
4236 @item @emph{Arguments}:
4237 @multitable @columnfractions .15 .80
4238 @item @var{ENVVAR} @tab Shall be of type @code{CHARACTER(*)}.
4239 @item @var{VALUE} @tab Shall be of type @code{CHARACTER(*)}.
4242 @item @emph{Return value}:
4243 Stores the value of @var{ENVVAR} in @var{VALUE}. If @var{VALUE} is
4244 not large enough to hold the data, it is truncated. If @var{ENVVAR}
4245 is not set, @var{VALUE} will be filled with blanks.
4247 @item @emph{Example}:
4250 CHARACTER(len=255) :: homedir
4251 CALL get_environment_variable("HOME", homedir)
4252 WRITE (*,*) TRIM(homedir)
4260 @section @code{GETGID} --- Group ID function
4261 @cindex @code{GETGID} intrinsic
4262 @cindex file system operations
4265 @item @emph{Description}:
4266 Returns the numerical group ID of the current process.
4268 @item @emph{Standard}:
4274 @item @emph{Syntax}:
4275 @code{RESULT = GETGID()}
4277 @item @emph{Return value}:
4278 The return value of @code{GETGID} is an @code{INTEGER} of the default
4282 @item @emph{Example}:
4283 See @code{GETPID} for an example.
4285 @item @emph{See also}:
4286 @ref{GETPID}, @ref{GETUID}
4292 @section @code{GETLOG} --- Get login name
4293 @cindex @code{GETLOG} intrinsic
4296 @item @emph{Description}:
4297 Gets the username under which the program is running.
4299 @item @emph{Standard}:
4305 @item @emph{Syntax}:
4306 @code{CALL GETLOG(LOGIN)}
4308 @item @emph{Arguments}:
4309 @multitable @columnfractions .15 .80
4310 @item @var{LOGIN} @tab Shall be of type @code{CHARACTER(*)}.
4313 @item @emph{Return value}:
4314 Stores the current user name in @var{LOGIN}. (On systems where
4315 the @code{getlogin(3)} function is not implemented, this will
4316 return a blank string.)
4318 @item @emph{Example}:
4321 CHARACTER(32) :: login
4327 @item @emph{See also}:
4334 @section @code{GETPID} --- Process ID function
4335 @cindex @code{GETPID} intrinsic
4336 @cindex process ID, current
4339 @item @emph{Description}:
4340 Returns the numerical process identifier of the current process.
4342 @item @emph{Standard}:
4348 @item @emph{Syntax}:
4349 @code{RESULT = GETPID()}
4351 @item @emph{Return value}:
4352 The return value of @code{GETPID} is an @code{INTEGER} of the default
4356 @item @emph{Example}:
4359 print *, "The current process ID is ", getpid()
4360 print *, "Your numerical user ID is ", getuid()
4361 print *, "Your numerical group ID is ", getgid()
4365 @item @emph{See also}:
4366 @ref{GETGID}, @ref{GETUID}
4372 @section @code{GETUID} --- User ID function
4373 @cindex @code{GETUID} intrinsic
4374 @cindex user ID, current
4377 @item @emph{Description}:
4378 Returns the numerical user ID of the current process.
4380 @item @emph{Standard}:
4386 @item @emph{Syntax}:
4387 @code{RESULT = GETUID()}
4389 @item @emph{Return value}:
4390 The return value of @code{GETUID} is an @code{INTEGER} of the default
4394 @item @emph{Example}:
4395 See @code{GETPID} for an example.
4397 @item @emph{See also}:
4398 @ref{GETPID}, @ref{GETLOG}
4404 @section @code{GMTIME} --- Convert time to GMT info
4405 @cindex @code{GMTIME} intrinsic
4406 @cindex time, conversion function
4409 @item @emph{Description}:
4410 Given a system time value @var{STIME} (as provided by the @code{TIME8()}
4411 intrinsic), fills @var{TARRAY} with values extracted from it appropriate
4412 to the UTC time zone (Universal Coordinated Time, also known in some
4413 countries as GMT, Greenwich Mean Time), using @code{gmtime(3)}.
4415 @item @emph{Standard}:
4421 @item @emph{Syntax}:
4422 @code{CALL GMTIME(STIME, TARRAY)}
4424 @item @emph{Arguments}:
4425 @multitable @columnfractions .15 .80
4426 @item @var{STIME} @tab An @code{INTEGER(*)} scalar expression
4427 corresponding to a system time, with
4429 @item @var{TARRAY} @tab A default @code{INTEGER} array with 9 elements,
4430 with @code{INTENT(OUT)}.
4433 @item @emph{Return value}:
4434 The elements of @var{TARRAY} are assigned as follows:
4436 @item Seconds after the minute, range 0--59 or 0--61 to allow for leap
4438 @item Minutes after the hour, range 0--59
4439 @item Hours past midnight, range 0--23
4440 @item Day of month, range 0--31
4441 @item Number of months since January, range 0--12
4442 @item Years since 1900
4443 @item Number of days since Sunday, range 0--6
4444 @item Days since January 1
4445 @item Daylight savings indicator: positive if daylight savings is in
4446 effect, zero if not, and negative if the information is not
4450 @item @emph{See also}:
4451 @ref{CTIME}, @ref{LTIME}, @ref{TIME}, @ref{TIME8}
4458 @section @code{HOSTNM} --- Get system host name
4459 @cindex @code{HOSTNM} intrinsic
4462 @item @emph{Description}:
4463 Retrieves the host name of the system on which the program is running.
4465 This intrinsic is provided in both subroutine and function forms; however,
4466 only one form can be used in any given program unit.
4468 @item @emph{Standard}:
4472 Subroutine, function
4474 @item @emph{Syntax}:
4475 @multitable @columnfractions .80
4476 @item @code{CALL HOSTNM(NAME, STATUS)}
4477 @item @code{STATUS = HOSTNM(NAME)}
4480 @item @emph{Arguments}:
4481 @multitable @columnfractions .15 .80
4482 @item @var{NAME} @tab Shall of type @code{CHARACTER(*)}.
4483 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
4484 Returns 0 on success, or a system specific error
4488 @item @emph{Return value}:
4489 In either syntax, @var{NAME} is set to the current hostname if it can
4490 be obtained, or to a blank string otherwise.
4497 @section @code{HUGE} --- Largest number of a kind
4498 @cindex @code{HUGE} intrinsic
4502 @item @emph{Description}:
4503 @code{HUGE(X)} returns the largest number that is not an infinity in
4504 the model of the type of @code{X}.
4506 @item @emph{Standard}:
4512 @item @emph{Syntax}:
4513 @code{RESULT = HUGE(X)}
4515 @item @emph{Arguments}:
4516 @multitable @columnfractions .15 .80
4517 @item @var{X} @tab shall be of type @code{REAL} or @code{INTEGER}.
4520 @item @emph{Return value}:
4521 The return value is of the same type and kind as @var{X}
4523 @item @emph{Example}:
4525 program test_huge_tiny
4526 print *, huge(0), huge(0.0), huge(0.0d0)
4527 print *, tiny(0.0), tiny(0.0d0)
4528 end program test_huge_tiny
4535 @section @code{IACHAR} --- Code in @acronym{ASCII} collating sequence
4536 @cindex @code{IACHAR} intrinsic
4537 @cindex @acronym{ASCII} collating sequence
4538 @cindex conversion function (character)
4541 @item @emph{Description}:
4542 @code{IACHAR(C)} returns the code for the @acronym{ASCII} character
4543 in the first character position of @code{C}.
4545 @item @emph{Standard}:
4551 @item @emph{Syntax}:
4552 @code{RESULT = IACHAR(C)}
4554 @item @emph{Arguments}:
4555 @multitable @columnfractions .15 .80
4556 @item @var{C} @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
4559 @item @emph{Return value}:
4560 The return value is of type @code{INTEGER} and of the default integer
4563 @item @emph{Example}:
4568 end program test_iachar
4571 @item @emph{See also}:
4572 @ref{CHAR},@ref{ICHAR}
4578 @section @code{IAND} --- Bitwise logical and
4579 @cindex @code{IAND} intrinsic
4580 @cindex bit operations
4583 @item @emph{Description}:
4584 Bitwise logical @code{AND}.
4586 @item @emph{Standard}:
4592 @item @emph{Syntax}:
4593 @code{RESULT = IAND(I, J)}
4595 @item @emph{Arguments}:
4596 @multitable @columnfractions .15 .80
4597 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
4598 @item @var{J} @tab The type shall be @code{INTEGER(*)}, of the same
4599 kind as @var{I}. (As a GNU extension, different kinds are also
4603 @item @emph{Return value}:
4604 The return type is @code{INTEGER(*)}, of the same kind as the
4605 arguments. (If the argument kinds differ, it is of the same kind as
4606 the larger argument.)
4608 @item @emph{Example}:
4612 DATA a / Z'F' /, b / Z'3' /
4613 WRITE (*,*) IAND(a, b)
4617 @item @emph{See also}:
4618 @ref{IOR}, @ref{IEOR}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
4625 @section @code{IARGC} --- Get the number of command line arguments
4626 @cindex @code{IARGC} intrinsic
4627 @cindex command-line arguments, to program
4630 @item @emph{Description}:
4631 @code{IARGC()} returns the number of arguments passed on the
4632 command line when the containing program was invoked.
4634 This intrinsic routine is provided for backwards compatibility with
4635 GNU Fortran 77. In new code, programmers should consider the use of
4636 the @ref{COMMAND_ARGUMENT_COUNT} intrinsic defined by the Fortran 2003
4639 @item @emph{Standard}:
4643 Non-elemental Function
4645 @item @emph{Syntax}:
4646 @code{RESULT = IARGC()}
4648 @item @emph{Arguments}:
4651 @item @emph{Return value}:
4652 The number of command line arguments, type @code{INTEGER(4)}.
4654 @item @emph{Example}:
4657 @item @emph{See also}:
4658 GNU Fortran 77 compatibility subroutine: @ref{GETARG}
4660 F2003 functions and subroutines: @ref{GET_COMMAND}, @ref{GET_COMMAND_ARGUMENT},
4661 @ref{COMMAND_ARGUMENT_COUNT}
4667 @section @code{IBCLR} --- Clear bit
4668 @cindex @code{IBCLR} intrinsic
4669 @cindex bit operations
4672 @item @emph{Description}:
4673 @code{IBCLR} returns the value of @var{I} with the bit at position
4674 @var{POS} set to zero.
4676 @item @emph{Standard}:
4682 @item @emph{Syntax}:
4683 @code{RESULT = IBCLR(I, POS)}
4685 @item @emph{Arguments}:
4686 @multitable @columnfractions .15 .80
4687 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
4688 @item @var{POS} @tab The type shall be @code{INTEGER(*)}.
4691 @item @emph{Return value}:
4692 The return value is of type @code{INTEGER(*)} and of the same kind as
4695 @item @emph{See also}:
4696 @ref{IBITS}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}, @ref{MVBITS}
4703 @section @code{IBITS} --- Bit extraction
4704 @cindex @code{IBITS} intrinsic
4705 @cindex bit operations
4708 @item @emph{Description}:
4709 @code{IBITS} extracts a field of length @var{LEN} from @var{I},
4710 starting from bit position @var{POS} and extending left for @var{LEN}
4711 bits. The result is right-justified and the remaining bits are
4712 zeroed. The value of @code{POS+LEN} must be less than or equal to the
4713 value @code{BIT_SIZE(I)}.
4715 @item @emph{Standard}:
4721 @item @emph{Syntax}:
4722 @code{RESULT = IBITS(I, POS, LEN)}
4724 @item @emph{Arguments}:
4725 @multitable @columnfractions .15 .80
4726 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
4727 @item @var{POS} @tab The type shall be @code{INTEGER(*)}.
4728 @item @var{LEN} @tab The type shall be @code{INTEGER(*)}.
4731 @item @emph{Return value}:
4732 The return value is of type @code{INTEGER(*)} and of the same kind as
4735 @item @emph{See also}:
4736 @ref{BIT_SIZE}, @ref{IBCLR}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
4742 @section @code{IBSET} --- Set bit
4743 @cindex @code{IBSET} intrinsic
4744 @cindex bit operations
4747 @item @emph{Description}:
4748 @code{IBSET} returns the value of @var{I} with the bit at position
4749 @var{POS} set to one.
4751 @item @emph{Standard}:
4757 @item @emph{Syntax}:
4758 @code{RESULT = IBSET(I, POS)}
4760 @item @emph{Arguments}:
4761 @multitable @columnfractions .15 .80
4762 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
4763 @item @var{POS} @tab The type shall be @code{INTEGER(*)}.
4766 @item @emph{Return value}:
4767 The return value is of type @code{INTEGER(*)} and of the same kind as
4770 @item @emph{See also}:
4771 @ref{IBCLR}, @ref{IBITS}, @ref{IAND}, @ref{IOR}, @ref{IEOR}, @ref{MVBITS}
4778 @section @code{ICHAR} --- Character-to-integer conversion function
4779 @cindex @code{ICHAR} intrinsic
4780 @cindex conversion function (character)
4783 @item @emph{Description}:
4784 @code{ICHAR(C)} returns the code for the character in the first character
4785 position of @code{C} in the system's native character set.
4786 The correspondence between characters and their codes is not necessarily
4787 the same across different GNU Fortran implementations.
4789 @item @emph{Standard}:
4795 @item @emph{Syntax}:
4796 @code{RESULT = ICHAR(C)}
4798 @item @emph{Arguments}:
4799 @multitable @columnfractions .15 .80
4800 @item @var{C} @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
4803 @item @emph{Return value}:
4804 The return value is of type @code{INTEGER} and of the default integer
4807 @item @emph{Example}:
4812 end program test_ichar
4816 No intrinsic exists to convert a printable character string to a numerical
4817 value. For example, there is no intrinsic that, given the @code{CHARACTER}
4818 value 154, returns an @code{INTEGER} or @code{REAL} value with the
4821 Instead, you can use internal-file I/O to do this kind of conversion. For
4826 character(len=10) string
4829 read (string,'(I10)') value
4831 end program read_val
4836 @section @code{IDATE} --- Get current local time subroutine (day/month/year)
4837 @cindex @code{IDATE} intrinsic
4840 @item @emph{Description}:
4841 @code{IDATE(TARRAY)} Fills @var{TARRAY} with the numerical values at the
4842 current local time. The day (in the range 1-31), month (in the range 1-12),
4843 and year appear in elements 1, 2, and 3 of @var{TARRAY}, respectively.
4844 The year has four significant digits.
4846 @item @emph{Standard}:
4852 @item @emph{Syntax}:
4853 @code{CALL IDATE(TARRAY)}
4855 @item @emph{Arguments}:
4856 @multitable @columnfractions .15 .80
4857 @item @var{TARRAY} @tab The type shall be @code{INTEGER, DIMENSION(3)} and
4858 the kind shall be the default integer kind.
4861 @item @emph{Return value}:
4864 @item @emph{Example}:
4867 integer, dimension(3) :: tarray
4872 end program test_idate
4879 @section @code{IEOR} --- Bitwise logical exclusive or
4880 @cindex @code{IEOR} intrinsic
4881 @cindex bit operations
4884 @item @emph{Description}:
4885 @code{IEOR} returns the bitwise boolean exclusive-OR of @var{I} and
4888 @item @emph{Standard}:
4894 @item @emph{Syntax}:
4895 @code{RESULT = IEOR(I, J)}
4897 @item @emph{Arguments}:
4898 @multitable @columnfractions .15 .80
4899 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
4900 @item @var{J} @tab The type shall be @code{INTEGER(*)}, of the same
4901 kind as @var{I}. (As a GNU extension, different kinds are also
4905 @item @emph{Return value}:
4906 The return type is @code{INTEGER(*)}, of the same kind as the
4907 arguments. (If the argument kinds differ, it is of the same kind as
4908 the larger argument.)
4910 @item @emph{See also}:
4911 @ref{IOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
4917 @section @code{IERRNO} --- Get the last system error number
4918 @cindex @code{IERRNO} intrinsic
4921 @item @emph{Description}:
4922 Returns the last system error number, as given by the C @code{errno()}
4925 @item @emph{Standard}:
4931 @item @emph{Syntax}:
4932 @code{RESULT = IERRNO()}
4934 @item @emph{Arguments}:
4937 @item @emph{Return value}:
4938 The return value is of type @code{INTEGER} and of the default integer
4941 @item @emph{See also}:
4948 @section @code{INDEX} --- Position of a substring within a string
4949 @cindex @code{INDEX} intrinsic
4952 @item @emph{Description}:
4953 Returns the position of the start of the first occurrence of string
4954 @var{SUBSTRING} as a substring in @var{STRING}, counting from one. If
4955 @var{SUBSTRING} is not present in @var{STRING}, zero is returned. If
4956 the @var{BACK} argument is present and true, the return value is the
4957 start of the last occurrence rather than the first.
4959 @item @emph{Standard}:
4965 @item @emph{Syntax}:
4966 @code{RESULT = INDEX(STRING, SUBSTRING [, BACK])}
4968 @item @emph{Arguments}:
4969 @multitable @columnfractions .15 .80
4970 @item @var{STRING} @tab Shall be a scalar @code{CHARACTER(*)}, with
4972 @item @var{SUBSTRING} @tab Shall be a scalar @code{CHARACTER(*)}, with
4974 @item @var{BACK} @tab (Optional) Shall be a scalar @code{LOGICAL(*)}, with
4978 @item @emph{Return value}:
4979 The return value is of type @code{INTEGER} and of the default integer
4982 @item @emph{See also}:
4988 @section @code{INT} --- Convert to integer type
4989 @cindex @code{INT} intrinsic
4990 @cindex @code{IFIX} intrinsic
4991 @cindex @code{IDINT} intrinsic
4992 @cindex conversion function (integer)
4995 @item @emph{Description}:
4996 Convert to integer type
4998 @item @emph{Standard}:
5004 @item @emph{Syntax}:
5005 @item @code{RESULT = INT(X [, KIND))}
5007 @item @emph{Arguments}:
5008 @multitable @columnfractions .15 .80
5009 @item @var{X} @tab shall be of type @code{INTEGER(*)},
5010 @code{REAL(*)}, or @code{COMPLEX(*)}.
5011 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
5012 expression indicating the kind parameter of
5016 @item @emph{Return value}:
5017 These functions return a @code{INTEGER(*)} variable or array under
5018 the following rules:
5022 If @var{X} is of type @code{INTEGER(*)}, @code{INT(X) = X}
5024 If @var{X} is of type @code{REAL(*)} and @math{|X| < 1}, @code{INT(X)} equals @var{0}.
5025 If @math{|X| \geq 1}, then @code{INT(X)} equals the largest integer that does not exceed
5026 the range of @var{X} and whose sign is the same as the sign of @var{X}.
5028 If @var{X} is of type @code{COMPLEX(*)}, rule B is applied to the real part of X.
5031 @item @emph{Example}:
5035 complex :: z = (-3.7, 1.0)
5037 print *, int(z), int(z,8)
5041 @item @emph{Specific names}:
5042 @multitable @columnfractions .20 .20 .20 .40
5043 @item Name @tab Argument @tab Return type @tab Standard
5044 @item @code{IFIX(X)} @tab @code{REAL(4) X} @tab @code{INTEGER} @tab F77 and later
5045 @item @code{IDINT(X)} @tab @code{REAL(8) X} @tab @code{INTEGER} @tab F77 and later
5048 @comment @item @emph{See also}:
5054 @section @code{IOR} --- Bitwise logical or
5055 @cindex @code{IOR} intrinsic
5056 @cindex bit operations
5059 @item @emph{Description}:
5060 @code{IEOR} returns the bitwise boolean OR of @var{I} and
5063 @item @emph{Standard}:
5069 @item @emph{Syntax}:
5070 @code{RESULT = IEOR(I, J)}
5072 @item @emph{Arguments}:
5073 @multitable @columnfractions .15 .80
5074 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
5075 @item @var{J} @tab The type shall be @code{INTEGER(*)}, of the same
5076 kind as @var{I}. (As a GNU extension, different kinds are also
5080 @item @emph{Return value}:
5081 The return type is @code{INTEGER(*)}, of the same kind as the
5082 arguments. (If the argument kinds differ, it is of the same kind as
5083 the larger argument.)
5085 @item @emph{See also}:
5086 @ref{IEOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}, @ref{NOT}
5093 @section @code{IRAND} --- Integer pseudo-random number
5094 @cindex @code{IRAND} intrinsic
5095 @cindex random numbers
5098 @item @emph{Description}:
5099 @code{IRAND(FLAG)} returns a pseudo-random number from a uniform
5100 distribution between 0 and a system-dependent limit (which is in most
5101 cases 2147483647). If @var{FLAG} is 0, the next number
5102 in the current sequence is returned; if @var{FLAG} is 1, the generator
5103 is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
5104 it is used as a new seed with @code{SRAND}.
5106 @item @emph{Standard}:
5110 non-elemental function
5112 @item @emph{Syntax}:
5113 @code{RESULT = IRAND(FLAG)}
5115 @item @emph{Arguments}:
5116 @multitable @columnfractions .15 .80
5117 @item @var{FLAG} @tab shall be a scalar @code{INTEGER} of kind 4.
5120 @item @emph{Return value}:
5121 The return value is of @code{INTEGER(kind=4)} type.
5123 @item @emph{Example}:
5126 integer,parameter :: seed = 86456
5129 print *, irand(), irand(), irand(), irand()
5130 print *, irand(seed), irand(), irand(), irand()
5131 end program test_irand
5139 @section @code{ISHFT} --- Shift bits
5140 @cindex @code{ISHFT} intrinsic
5141 @cindex bit operations
5144 @item @emph{Description}:
5145 @code{ISHFT} returns a value corresponding to @var{I} with all of the
5146 bits shifted @var{SHIFT} places. A value of @var{SHIFT} greater than
5147 zero corresponds to a left shift, a value of zero corresponds to no
5148 shift, and a value less than zero corresponds to a right shift. If the
5149 absolute value of @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the
5150 value is undefined. Bits shifted out from the left end or right end are
5151 lost; zeros are shifted in from the opposite end.
5153 @item @emph{Standard}:
5159 @item @emph{Syntax}:
5160 @code{RESULT = ISHFT(I, SHIFT)}
5162 @item @emph{Arguments}:
5163 @multitable @columnfractions .15 .80
5164 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
5165 @item @var{SHIFT} @tab The type shall be @code{INTEGER(*)}.
5168 @item @emph{Return value}:
5169 The return value is of type @code{INTEGER(*)} and of the same kind as
5172 @item @emph{See also}:
5180 @section @code{ISHFTC} --- Shift bits circularly
5181 @cindex @code{ISHFTC} intrinsic
5182 @cindex bit operations
5185 @item @emph{Description}:
5186 @code{ISHFTC} returns a value corresponding to @var{I} with the
5187 rightmost @var{SIZE} bits shifted circularly @var{SHIFT} places; that
5188 is, bits shifted out one end are shifted into the opposite end. A value
5189 of @var{SHIFT} greater than zero corresponds to a left shift, a value of
5190 zero corresponds to no shift, and a value less than zero corresponds to
5191 a right shift. The absolute value of @var{SHIFT} must be less than
5192 @var{SIZE}. If the @var{SIZE} argument is omitted, it is taken to be
5193 equivalent to @code{BIT_SIZE(I)}.
5195 @item @emph{Standard}:
5201 @item @emph{Syntax}:
5202 @code{RESULT = ISHFTC(I, SHIFT [, SIZE])}
5204 @item @emph{Arguments}:
5205 @multitable @columnfractions .15 .80
5206 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
5207 @item @var{SHIFT} @tab The type shall be @code{INTEGER(*)}.
5208 @item @var{SIZE} @tab (Optional) The type shall be @code{INTEGER(*)};
5209 the value must be greater than zero and less than or equal to
5213 @item @emph{Return value}:
5214 The return value is of type @code{INTEGER(*)} and of the same kind as
5217 @item @emph{See also}:
5224 @section @code{ITIME} --- Get current local time subroutine (hour/minutes/seconds)
5225 @cindex @code{ITIME} intrinsic
5228 @item @emph{Description}:
5229 @code{IDATE(TARRAY)} Fills @var{TARRAY} with the numerical values at the
5230 current local time. The hour (in the range 1-24), minute (in the range 1-60),
5231 and seconds (in the range 1-60) appear in elements 1, 2, and 3 of @var{TARRAY},
5234 @item @emph{Standard}:
5240 @item @emph{Syntax}:
5241 @code{CALL ITIME(TARRAY)}
5243 @item @emph{Arguments}:
5244 @multitable @columnfractions .15 .80
5245 @item @var{TARRAY} @tab The type shall be @code{INTEGER, DIMENSION(3)}
5246 and the kind shall be the default integer kind.
5249 @item @emph{Return value}:
5253 @item @emph{Example}:
5256 integer, dimension(3) :: tarray
5261 end program test_itime
5268 @section @code{KILL} --- Send a signal to a process
5269 @cindex @code{KILL} intrinsic
5272 @item @emph{Description}:
5273 @item @emph{Standard}:
5274 Sends the signal specified by @var{SIGNAL} to the process @var{PID}.
5280 @item @emph{Syntax}:
5281 @code{CALL KILL(PID, SIGNAL [, STATUS])}
5283 @item @emph{Arguments}:
5284 @multitable @columnfractions .15 .80
5285 @item @var{PID} @tab Shall be a scalar @code{INTEGER}, with
5287 @item @var{SIGNAL} @tab Shall be a scalar @code{INTEGER}, with
5289 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)} or
5290 @code{INTEGER(8)}. Returns 0 on success, or a
5291 system-specific error code otherwise.
5294 @item @emph{See also}:
5295 @ref{ABORT}, @ref{EXIT}
5301 @section @code{KIND} --- Kind of an entity
5302 @cindex @code{KIND} intrinsic
5305 @item @emph{Description}:
5306 @code{KIND(X)} returns the kind value of the entity @var{X}.
5308 @item @emph{Standard}:
5314 @item @emph{Syntax}:
5317 @item @emph{Arguments}:
5318 @multitable @columnfractions .15 .80
5319 @item @var{X} @tab Shall be of type @code{LOGICAL}, @code{INTEGER},
5320 @code{REAL}, @code{COMPLEX} or @code{CHARACTER}.
5323 @item @emph{Return value}:
5324 The return value is a scalar of type @code{INTEGER} and of the default
5327 @item @emph{Example}:
5330 integer,parameter :: kc = kind(' ')
5331 integer,parameter :: kl = kind(.true.)
5333 print *, "The default character kind is ", kc
5334 print *, "The default logical kind is ", kl
5335 end program test_kind
5343 @section @code{LBOUND} --- Lower dimension bounds of an array
5344 @cindex @code{LBOUND} intrinsic
5347 @item @emph{Description}:
5348 Returns the lower bounds of an array, or a single lower bound
5349 along the @var{DIM} dimension.
5350 @item @emph{Standard}:
5356 @item @emph{Syntax}:
5357 @code{RESULT = LBOUND(ARRAY [, DIM])}
5359 @item @emph{Arguments}:
5360 @multitable @columnfractions .15 .80
5361 @item @var{ARRAY} @tab Shall be an array, of any type.
5362 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER(*)}.
5365 @item @emph{Return value}:
5366 If @var{DIM} is absent, the result is an array of the lower bounds of
5367 @var{ARRAY}. If @var{DIM} is present, the result is a scalar
5368 corresponding to the lower bound of the array along that dimension. If
5369 @var{ARRAY} is an expression rather than a whole array or array
5370 structure component, or if it has a zero extent along the relevant
5371 dimension, the lower bound is taken to be 1.
5373 @item @emph{See also}:
5380 @section @code{LEN} --- Length of a character entity
5381 @cindex @code{LEN} intrinsic
5384 @item @emph{Description}:
5385 Returns the length of a character string. If @var{STRING} is an array,
5386 the length of an element of @var{STRING} is returned. Note that
5387 @var{STRING} need not be defined when this intrinsic is invoked, since
5388 only the length, not the content, of @var{STRING} is needed.
5390 @item @emph{Standard}:
5396 @item @emph{Syntax}:
5397 @code{L = LEN(STRING)}
5399 @item @emph{Arguments}:
5400 @multitable @columnfractions .15 .80
5401 @item @var{STRING} @tab Shall be a scalar or array of type
5402 @code{CHARACTER(*)}, with @code{INTENT(IN)}
5405 @item @emph{Return value}:
5406 The return value is an @code{INTEGER} of the default kind.
5408 @item @emph{See also}:
5409 @ref{LEN_TRIM}, @ref{ADJUSTL}, @ref{ADJUSTR}
5415 @section @code{LEN_TRIM} --- Length of a character entity without trailing blank characters
5416 @cindex @code{LEN_TRIM} intrinsic
5419 @item @emph{Description}:
5420 Returns the length of a character string, ignoring any trailing blanks.
5422 @item @emph{Standard}:
5428 @item @emph{Syntax}:
5429 @code{RESULT = LEN_TRIM(STRING)}
5431 @item @emph{Arguments}:
5432 @multitable @columnfractions .15 .80
5433 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER(*)},
5434 with @code{INTENT(IN)}
5437 @item @emph{Return value}:
5438 The return value is an @code{INTEGER} of the default kind.
5440 @item @emph{See also}:
5441 @ref{LEN}, @ref{ADJUSTL}, @ref{ADJUSTR}
5447 @section @code{LGE} --- Lexical greater than or equal
5448 @cindex @code{LGE} intrinsic
5449 @cindex comparison (lexical)
5450 @cindex lexical comparison
5453 @item @emph{Description}:
5454 Determines whether one string is lexically greater than or equal to
5455 another string, where the two strings are interpreted as containing
5456 ASCII character codes. If the String A and String B are not the same
5457 length, the shorter is compared as if spaces were appended to it to form
5458 a value that has the same length as the longer.
5460 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
5461 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
5462 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
5463 that the latter use the processor's character ordering (which is not
5464 ASCII on some targets), whereas the former always use the ASCII
5467 @item @emph{Standard}:
5473 @item @emph{Syntax}:
5474 @code{RESULT = LGE(STRING_A, STRING_B)}
5476 @item @emph{Arguments}:
5477 @multitable @columnfractions .15 .80
5478 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
5479 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
5482 @item @emph{Return value}:
5483 Returns @code{.TRUE.} if @code{STRING_A >= STRING_B}, and @code{.FALSE.}
5484 otherwise, based on the ASCII ordering.
5486 @item @emph{See also}:
5487 @ref{LGT}, @ref{LLE}, @ref{LLT}
5493 @section @code{LGT} --- Lexical greater than
5494 @cindex @code{LGT} intrinsic
5495 @cindex comparison (lexical)
5496 @cindex lexical comparison
5499 @item @emph{Description}:
5500 Determines whether one string is lexically greater than another string,
5501 where the two strings are interpreted as containing ASCII character
5502 codes. If the String A and String B are not the same length, the
5503 shorter is compared as if spaces were appended to it to form a value
5504 that has the same length as the longer.
5506 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
5507 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
5508 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
5509 that the latter use the processor's character ordering (which is not
5510 ASCII on some targets), whereas the former always use the ASCII
5513 @item @emph{Standard}:
5519 @item @emph{Syntax}:
5520 @code{RESULT = LGT(STRING_A, STRING_B)}
5522 @item @emph{Arguments}:
5523 @multitable @columnfractions .15 .80
5524 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
5525 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
5528 @item @emph{Return value}:
5529 Returns @code{.TRUE.} if @code{STRING_A > STRING_B}, and @code{.FALSE.}
5530 otherwise, based on the ASCII ordering.
5532 @item @emph{See also}:
5533 @ref{LGE}, @ref{LLE}, @ref{LLT}
5539 @section @code{LINK} --- Create a hard link
5540 @cindex @code{LINK} intrinsic
5541 @cindex file system operations
5544 @item @emph{Description}:
5545 Makes a (hard) link from file @var{PATH1} to @var{PATH2}. A null
5546 character (@code{CHAR(0)}) can be used to mark the end of the names in
5547 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
5548 names are ignored. If the @var{STATUS} argument is supplied, it
5549 contains 0 on success or a nonzero error code upon return; see
5552 @item @emph{Standard}:
5558 @item @emph{Syntax}:
5559 @code{CALL LINK(PATH1, PATH2 [, STATUS])}
5561 @item @emph{Arguments}:
5562 @multitable @columnfractions .15 .80
5563 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
5564 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
5565 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
5568 @item @emph{See also}:
5569 @ref{SYMLNK}, @ref{UNLINK}
5575 @section @code{LLE} --- Lexical less than or equal
5576 @cindex @code{LLE} intrinsic
5577 @cindex comparison (lexical)
5578 @cindex lexical comparison
5581 @item @emph{Description}:
5582 Determines whether one string is lexically less than or equal to another
5583 string, where the two strings are interpreted as containing ASCII
5584 character codes. If the String A and String B are not the same length,
5585 the shorter is compared as if spaces were appended to it to form a value
5586 that has the same length as the longer.
5588 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
5589 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
5590 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
5591 that the latter use the processor's character ordering (which is not
5592 ASCII on some targets), whereas the former always use the ASCII
5595 @item @emph{Standard}:
5601 @item @emph{Syntax}:
5602 @code{RESULT = LLE(STRING_A, STRING_B)}
5604 @item @emph{Arguments}:
5605 @multitable @columnfractions .15 .80
5606 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
5607 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
5610 @item @emph{Return value}:
5611 Returns @code{.TRUE.} if @code{STRING_A <= STRING_B}, and @code{.FALSE.}
5612 otherwise, based on the ASCII ordering.
5614 @item @emph{See also}:
5615 @ref{LGE}, @ref{LGT}, @ref{LLT}
5621 @section @code{LLT} --- Lexical less than
5622 @cindex @code{LLT} intrinsic
5623 @cindex comparison (lexical)
5624 @cindex lexical comparison
5627 @item @emph{Description}:
5628 Determines whether one string is lexically less than another string,
5629 where the two strings are interpreted as containing ASCII character
5630 codes. If the String A and String B are not the same length, the
5631 shorter is compared as if spaces were appended to it to form a value
5632 that has the same length as the longer.
5634 In general, the lexical comparison intrinsics @code{LGE}, @code{LGT},
5635 @code{LLE}, and @code{LLT} differ from the corresponding intrinsic
5636 operators @code{.GE.}, @code{.GT.}, @code{.LE.}, and @code{.LT.}, in
5637 that the latter use the processor's character ordering (which is not
5638 ASCII on some targets), whereas the former always use the ASCII
5641 @item @emph{Standard}:
5647 @item @emph{Syntax}:
5648 @code{RESULT = LLT(STRING_A, STRING_B)}
5650 @item @emph{Arguments}:
5651 @multitable @columnfractions .15 .80
5652 @item @var{STRING_A} @tab Shall be of default @code{CHARACTER} type.
5653 @item @var{STRING_B} @tab Shall be of default @code{CHARACTER} type.
5656 @item @emph{Return value}:
5657 Returns @code{.TRUE.} if @code{STRING_A < STRING_B}, and @code{.FALSE.}
5658 otherwise, based on the ASCII ordering.
5660 @item @emph{See also}:
5661 @ref{LGE}, @ref{LGT}, @ref{LLE}
5667 @section @code{LNBLNK} --- Index of the last non-blank character in a string
5668 @cindex @code{LNBLNK} intrinsic
5671 @item @emph{Description}:
5672 Returns the length of a character string, ignoring any trailing blanks.
5673 This is identical to the standard @code{LEN_TRIM} intrinsic, and is only
5674 included for backwards compatibility.
5676 @item @emph{Standard}:
5682 @item @emph{Syntax}:
5683 @code{RESULT = LNBLNK(STRING)}
5685 @item @emph{Arguments}:
5686 @multitable @columnfractions .15 .80
5687 @item @var{STRING} @tab Shall be a scalar of type @code{CHARACTER(*)},
5688 with @code{INTENT(IN)}
5691 @item @emph{Return value}:
5692 The return value is of @code{INTEGER(kind=4)} type.
5694 @item @emph{See also}:
5695 @ref{INDEX}, @ref{LEN_TRIM}
5701 @section @code{LOC} --- Returns the address of a variable
5702 @cindex @code{LOC} intrinsic
5703 @cindex location of a variable in memory
5706 @item @emph{Description}:
5707 @code{LOC(X)} returns the address of @var{X} as an integer.
5709 @item @emph{Standard}:
5715 @item @emph{Syntax}:
5716 @code{RESULT = LOC(X)}
5718 @item @emph{Arguments}:
5719 @multitable @columnfractions .15 .80
5720 @item @var{X} @tab Variable of any type.
5723 @item @emph{Return value}:
5724 The return value is of type @code{INTEGER}, with a @code{KIND}
5725 corresponding to the size (in bytes) of a memory address on the target
5728 @item @emph{Example}:
5735 end program test_loc
5742 @section @code{LOG} --- Logarithm function
5743 @cindex @code{LOG} intrinsic
5744 @cindex @code{ALOG} intrinsic
5745 @cindex @code{DLOG} intrinsic
5746 @cindex @code{CLOG} intrinsic
5747 @cindex @code{ZLOG} intrinsic
5748 @cindex @code{CDLOG} intrinsic
5752 @item @emph{Description}:
5753 @code{LOG(X)} computes the logarithm of @var{X}.
5755 @item @emph{Standard}:
5761 @item @emph{Syntax}:
5762 @code{RESULT = LOG(X)}
5764 @item @emph{Arguments}:
5765 @multitable @columnfractions .15 .80
5766 @item @var{X} @tab The type shall be @code{REAL(*)} or
5770 @item @emph{Return value}:
5771 The return value is of type @code{REAL(*)} or @code{COMPLEX(*)}.
5772 The kind type parameter is the same as @var{X}.
5774 @item @emph{Example}:
5777 real(8) :: x = 1.0_8
5778 complex :: z = (1.0, 2.0)
5781 end program test_log
5784 @item @emph{Specific names}:
5785 @multitable @columnfractions .20 .20 .20 .40
5786 @item Name @tab Argument @tab Return type @tab Standard
5787 @item @code{ALOG(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab f95, gnu
5788 @item @code{DLOG(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
5789 @item @code{CLOG(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab f95, gnu
5790 @item @code{ZLOG(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
5791 @item @code{CDLOG(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
5798 @section @code{LOG10} --- Base 10 logarithm function
5799 @cindex @code{LOG10} intrinsic
5800 @cindex @code{ALOG10} intrinsic
5801 @cindex @code{DLOG10} intrinsic
5805 @item @emph{Description}:
5806 @code{LOG10(X)} computes the base 10 logarithm of @var{X}.
5808 @item @emph{Standard}:
5814 @item @emph{Syntax}:
5815 @code{RESULT = LOG10(X)}
5817 @item @emph{Arguments}:
5818 @multitable @columnfractions .15 .80
5819 @item @var{X} @tab The type shall be @code{REAL(*)} or
5823 @item @emph{Return value}:
5824 The return value is of type @code{REAL(*)} or @code{COMPLEX(*)}.
5825 The kind type parameter is the same as @var{X}.
5827 @item @emph{Example}:
5830 real(8) :: x = 10.0_8
5832 end program test_log10
5835 @item @emph{Specific names}:
5836 @multitable @columnfractions .20 .20 .20 .40
5837 @item Name @tab Argument @tab Return type @tab Standard
5838 @item @code{ALOG10(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab F95 and later
5839 @item @code{DLOG10(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
5846 @section @code{LOGICAL} --- Convert to logical type
5847 @cindex @code{LOGICAL} intrinsic
5848 @cindex conversion function (logical)
5851 @item @emph{Description}:
5852 Converts one kind of @code{LOGICAL} variable to another.
5854 @item @emph{Standard}:
5860 @item @emph{Syntax}:
5861 @code{RESULT = LOGICAL(L [, KIND])}
5863 @item @emph{Arguments}:
5864 @multitable @columnfractions .15 .80
5865 @item @var{L} @tab The type shall be @code{LOGICAL(*)}.
5866 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
5867 expression indicating the kind parameter of
5871 @item @emph{Return value}:
5872 The return value is a @code{LOGICAL} value equal to @var{L}, with a
5873 kind corresponding to @var{KIND}, or of the default logical kind if
5874 @var{KIND} is not given.
5876 @item @emph{See also}:
5877 @ref{INT}, @ref{REAL}, @ref{CMPLX}
5884 @section @code{LSHIFT} --- Left shift bits
5885 @cindex @code{LSHIFT} intrinsic
5886 @cindex bit operations
5889 @item @emph{Description}:
5890 @code{LSHIFT} returns a value corresponding to @var{I} with all of the
5891 bits shifted left by @var{SHIFT} places. If the absolute value of
5892 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
5893 Bits shifted out from the left end are lost; zeros are shifted in from
5896 This function has been superceded by the @code{ISHFT} intrinsic, which
5897 is standard in Fortran 95 and later.
5899 @item @emph{Standard}:
5905 @item @emph{Syntax}:
5906 @code{RESULT = LSHIFT(I, SHIFT)}
5908 @item @emph{Arguments}:
5909 @multitable @columnfractions .15 .80
5910 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
5911 @item @var{SHIFT} @tab The type shall be @code{INTEGER(*)}.
5914 @item @emph{Return value}:
5915 The return value is of type @code{INTEGER(*)} and of the same kind as
5918 @item @emph{See also}:
5919 @ref{ISHFT}, @ref{ISHFTC}, @ref{RSHIFT}
5925 @section @code{LSTAT} --- Get file status
5926 @cindex @code{LSTAT} intrinsic
5927 @cindex file system operations
5930 @item @emph{Description}:
5931 @code{LSTAT} is identical to @ref{STAT}, except that if path is a symbolic link,
5932 then the link itself is statted, not the file that it refers to.
5934 The elements in @code{BUFF} are the same as described by @ref{STAT}.
5936 @item @emph{Standard}:
5940 Non-elemental subroutine
5942 @item @emph{Syntax}:
5943 @code{CALL LSTAT(FILE, BUFF [, STATUS])}
5945 @item @emph{Arguments}:
5946 @multitable @columnfractions .15 .80
5947 @item @var{FILE} @tab The type shall be @code{CHARACTER(*)}, a valid path within the file system.
5948 @item @var{BUFF} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
5949 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0
5950 on success and a system specific error code otherwise.
5953 @item @emph{Example}:
5954 See @ref{STAT} for an example.
5956 @item @emph{See also}:
5957 To stat an open file: @ref{FSTAT}, to stat a file: @ref{STAT}
5963 @section @code{LTIME} --- Convert time to local time info
5964 @cindex @code{LTIME} intrinsic
5965 @cindex time, conversion function
5968 @item @emph{Description}:
5969 Given a system time value @var{STIME} (as provided by the @code{TIME8()}
5970 intrinsic), fills @var{TARRAY} with values extracted from it appropriate
5971 to the local time zone using @code{localtime(3)}.
5973 @item @emph{Standard}:
5979 @item @emph{Syntax}:
5980 @code{CALL LTIME(STIME, TARRAY)}
5982 @item @emph{Arguments}:
5983 @multitable @columnfractions .15 .80
5984 @item @var{STIME} @tab An @code{INTEGER(*)} scalar expression
5985 corresponding to a system time, with
5987 @item @var{TARRAY} @tab A default @code{INTEGER} array with 9 elements,
5988 with @code{INTENT(OUT)}.
5991 @item @emph{Return value}:
5992 The elements of @var{TARRAY} are assigned as follows:
5994 @item Seconds after the minute, range 0--59 or 0--61 to allow for leap
5996 @item Minutes after the hour, range 0--59
5997 @item Hours past midnight, range 0--23
5998 @item Day of month, range 0--31
5999 @item Number of months since January, range 0--12
6000 @item Years since 1900
6001 @item Number of days since Sunday, range 0--6
6002 @item Days since January 1
6003 @item Daylight savings indicator: positive if daylight savings is in
6004 effect, zero if not, and negative if the information is not
6008 @item @emph{See also}:
6009 @ref{CTIME}, @ref{GMTIME}, @ref{TIME}, @ref{TIME8}
6016 @section @code{MALLOC} --- Allocate dynamic memory
6017 @cindex @code{MALLOC} intrinsic
6018 @cindex Cray pointers
6021 @item @emph{Description}:
6022 @code{MALLOC(SIZE)} allocates @var{SIZE} bytes of dynamic memory and
6023 returns the address of the allocated memory. The @code{MALLOC} intrinsic
6024 is an extension intended to be used with Cray pointers, and is provided
6025 in GNU Fortran to allow the user to compile legacy code. For new code
6026 using Fortran 95 pointers, the memory allocation intrinsic is
6029 @item @emph{Standard}:
6033 non-elemental function
6035 @item @emph{Syntax}:
6036 @code{PTR = MALLOC(SIZE)}
6038 @item @emph{Arguments}:
6039 @multitable @columnfractions .15 .80
6040 @item @var{SIZE} @tab The type shall be @code{INTEGER(*)}.
6043 @item @emph{Return value}:
6044 The return value is of type @code{INTEGER(K)}, with @var{K} such that
6045 variables of type @code{INTEGER(K)} have the same size as
6046 C pointers (@code{sizeof(void *)}).
6048 @item @emph{Example}:
6049 The following example demonstrates the use of @code{MALLOC} and
6050 @code{FREE} with Cray pointers. This example is intended to run on
6051 32-bit systems, where the default integer kind is suitable to store
6052 pointers; on 64-bit systems, ptr_x would need to be declared as
6053 @code{integer(kind=8)}.
6062 ptr_x = malloc(20*8)
6064 x(i) = sqrt(1.0d0 / i)
6072 end program test_malloc
6075 @item @emph{See also}:
6082 @section @code{MATMUL} --- matrix multiplication
6083 @cindex @code{MATMUL} intrinsic
6084 @cindex matrix operations
6087 @item @emph{Description}:
6088 Performs a matrix multiplication on numeric or logical arguments.
6090 @item @emph{Standard}:
6094 Transformational function
6096 @item @emph{Syntax}:
6097 @code{RESULT = MATMUL(MATRIX_A, MATRIX_B)}
6099 @item @emph{Arguments}:
6100 @multitable @columnfractions .15 .80
6101 @item @var{MATRIX_A} @tab An array of @code{INTEGER(*)},
6102 @code{REAL(*)}, @code{COMPLEX(*)}, or
6103 @code{LOGICAL(*)} type, with a rank of
6105 @item @var{MATRIX_B} @tab An array of @code{INTEGER(*)},
6106 @code{REAL(*)}, or @code{COMPLEX(*)} type if
6107 @var{MATRIX_A} is of a numeric type;
6108 otherwise, an array of @code{LOGICAL(*)}
6109 type. The rank shall be one or two, and the
6110 first (or only) dimension of @var{MATRIX_B}
6111 shall be equal to the last (or only)
6112 dimension of @var{MATRIX_A}.
6115 @item @emph{Return value}:
6116 The matrix product of @var{MATRIX_A} and @var{MATRIX_B}. The type and
6117 kind of the result follow the usual type and kind promotion rules, as
6118 for the @code{*} or @code{.AND.} operators.
6120 @item @emph{See also}:
6126 @section @code{MAX} --- Maximum value of an argument list
6127 @cindex @code{MAX} intrinsic
6130 @item @emph{Description}:
6131 Returns the argument with the largest (most positive) value.
6133 @item @emph{Standard}:
6139 @item @emph{Syntax}:
6140 @code{RESULT = MAX(A1, A2 [, A3 [, ...]])}
6142 @item @emph{Arguments}:
6143 @multitable @columnfractions .15 .80
6144 @item @var{A1} @tab The type shall be @code{INTEGER(*)} or
6146 @item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
6147 as @var{A1}. (As a GNU extension,
6148 arguments of different kinds are
6152 @item @emph{Return value}:
6153 The return value corresponds to the maximum value among the arguments,
6154 and has the same type and kind as the first argument.
6156 @item @emph{Specific names}:
6157 @multitable @columnfractions .20 .20 .20 .40
6158 @item Name @tab Argument @tab Return type @tab Standard
6159 @item @code{MAX0(I)} @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)} @tab F77 and later
6160 @item @code{AMAX0(I)} @tab @code{INTEGER(4) I} @tab @code{REAL(MAX(X))} @tab F77 and later
6161 @item @code{MAX1(X)} @tab @code{REAL(*) X} @tab @code{INT(MAX(X))} @tab F77 and later
6162 @item @code{AMAX1(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab F77 and later
6163 @item @code{DMAX1(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
6166 @item @emph{See also}:
6167 @ref{MAXLOC} @ref{MAXVAL}, @ref{MIN}
6174 @section @code{MAXEXPONENT} --- Maximum exponent of a real kind
6175 @cindex @code{MAXEXPONENT} intrinsic
6176 @cindex maximum exponent
6177 @cindex exponent, maximum
6180 @item @emph{Description}:
6181 @code{MAXEXPONENT(X)} returns the maximum exponent in the model of the
6184 @item @emph{Standard}:
6190 @item @emph{Syntax}:
6191 @code{RESULT = MAXEXPONENT(X)}
6193 @item @emph{Arguments}:
6194 @multitable @columnfractions .15 .80
6195 @item @var{X} @tab shall be of type @code{REAL}.
6198 @item @emph{Return value}:
6199 The return value is of type @code{INTEGER} and of the default integer
6202 @item @emph{Example}:
6208 print *, minexponent(x), maxexponent(x)
6209 print *, minexponent(y), maxexponent(y)
6210 end program exponents
6217 @section @code{MAXLOC} --- Location of the maximum value within an array
6218 @cindex @code{MAXLOC} intrinsic
6221 @item @emph{Description}:
6222 Determines the location of the element in the array with the maximum
6223 value, or, if the @var{DIM} argument is supplied, determines the
6224 locations of the maximum element along each row of the array in the
6225 @var{DIM} direction. If @var{MASK} is present, only the elements for
6226 which @var{MASK} is @code{.TRUE.} are considered. If more than one
6227 element in the array has the maximum value, the location returned is
6228 that of the first such element in array element order. If the array has
6229 zero size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
6230 the result is an array of zeroes. Similarly, if @var{DIM} is supplied
6231 and all of the elements of @var{MASK} along a given row are zero, the
6232 result value for that row is zero.
6234 @item @emph{Standard}:
6238 Transformational function
6240 @item @emph{Syntax}:
6241 @multitable @columnfractions .80
6242 @item @code{RESULT = MAXLOC(ARRAY, DIM [, MASK])}
6243 @item @code{RESULT = MAXLOC(ARRAY [, MASK])}
6246 @item @emph{Arguments}:
6247 @multitable @columnfractions .15 .80
6248 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER(*)},
6249 @code{REAL(*)}, or @code{CHARACTER(*)}.
6250 @item @var{DIM} @tab (Optional) Shall be a scalar of type
6251 @code{INTEGER(*)}, with a value between one
6252 and the rank of @var{ARRAY}, inclusive. It
6253 may not be an optional dummy argument.
6254 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL(*)},
6255 and conformable with @var{ARRAY}.
6258 @item @emph{Return value}:
6259 If @var{DIM} is absent, the result is a rank-one array with a length
6260 equal to the rank of @var{ARRAY}. If @var{DIM} is present, the result
6261 is an array with a rank one less than the rank of @var{ARRAY}, and a
6262 size corresponding to the size of @var{ARRAY} with the @var{DIM}
6263 dimension removed. If @var{DIM} is present and @var{ARRAY} has a rank
6264 of one, the result is a scalar. In all cases, the result is of default
6265 @code{INTEGER} type.
6267 @item @emph{See also}:
6268 @ref{MAX}, @ref{MAXVAL}
6275 @section @code{MAXVAL} --- Maximum value of an array
6276 @cindex @code{MAXVAL} intrinsic
6279 @item @emph{Description}:
6280 Determines the maximum value of the elements in an array value, or, if
6281 the @var{DIM} argument is supplied, determines the maximum value along
6282 each row of the array in the @var{DIM} direction. If @var{MASK} is
6283 present, only the elements for which @var{MASK} is @code{.TRUE.} are
6284 considered. If the array has zero size, or all of the elements of
6285 @var{MASK} are @code{.FALSE.}, then the result is the most negative
6286 number of the type and kind of @var{ARRAY} if @var{ARRAY} is numeric, or
6287 a string of nulls if @var{ARRAY} is of character type.
6289 @item @emph{Standard}:
6293 Transformational function
6295 @item @emph{Syntax}:
6296 @multitable @columnfractions .80
6297 @item @code{RESULT = MAXVAL(ARRAY, DIM [, MASK])}
6298 @item @code{RESULT = MAXVAL(ARRAY [, MASK])}
6301 @item @emph{Arguments}:
6302 @multitable @columnfractions .15 .80
6303 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER(*)},
6304 @code{REAL(*)}, or @code{CHARACTER(*)}.
6305 @item @var{DIM} @tab (Optional) Shall be a scalar of type
6306 @code{INTEGER(*)}, with a value between one
6307 and the rank of @var{ARRAY}, inclusive. It
6308 may not be an optional dummy argument.
6309 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL(*)},
6310 and conformable with @var{ARRAY}.
6313 @item @emph{Return value}:
6314 If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
6315 is a scalar. If @var{DIM} is present, the result is an array with a
6316 rank one less than the rank of @var{ARRAY}, and a size corresponding to
6317 the size of @var{ARRAY} with the @var{DIM} dimension removed. In all
6318 cases, the result is of the same type and kind as @var{ARRAY}.
6320 @item @emph{See also}:
6321 @ref{MAX}, @ref{MAXLOC}
6327 @section @code{MERGE} --- Merge variables
6328 @cindex @code{MERGE} intrinsic
6331 @item @emph{Description}:
6332 Select values from two arrays according to a logical mask. The result
6333 is equal to @var{TSOURCE} if @var{MASK} is @code{.TRUE.}, or equal to
6334 @var{FSOURCE} if it is @code{.FALSE.}.
6336 @item @emph{Standard}:
6342 @item @emph{Syntax}:
6343 @code{RESULT = MERGE(TSOURCE, FSOURCE, MASK)}
6345 @item @emph{Arguments}:
6346 @multitable @columnfractions .15 .80
6347 @item @var{TSOURCE} @tab May be of any type.
6348 @item @var{FSOURCE} @tab Shall be of the same type and type parameters
6350 @item @var{MASK} @tab Shall be of type @code{LOGICAL(*)}.
6353 @item @emph{Return value}:
6354 The result is of the same type and type parameters as @var{TSOURCE}.
6361 @section @code{MIN} --- Minimum value of an argument list
6362 @cindex @code{MIN} intrinsic
6365 @item @emph{Description}:
6366 Returns the argument with the smallest (most negative) value.
6368 @item @emph{Standard}:
6374 @item @emph{Syntax}:
6375 @code{RESULT = MIN(A1, A2 [, A3, ...])}
6377 @item @emph{Arguments}:
6378 @multitable @columnfractions .15 .80
6379 @item @var{A1} @tab The type shall be @code{INTEGER(*)} or
6381 @item @var{A2}, @var{A3}, ... @tab An expression of the same type and kind
6382 as @var{A1}. (As a GNU extension,
6383 arguments of different kinds are
6387 @item @emph{Return value}:
6388 The return value corresponds to the maximum value among the arguments,
6389 and has the same type and kind as the first argument.
6391 @item @emph{Specific names}:
6392 @multitable @columnfractions .20 .20 .20 .40
6393 @item Name @tab Argument @tab Return type @tab Standard
6394 @item @code{MIN0(I)} @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)} @tab F77 and later
6395 @item @code{AMIN0(I)} @tab @code{INTEGER(4) I} @tab @code{REAL(MIN(X))} @tab F77 and later
6396 @item @code{MIN1(X)} @tab @code{REAL(*) X} @tab @code{INT(MIN(X))} @tab F77 and later
6397 @item @code{AMIN1(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab F77 and later
6398 @item @code{DMIN1(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
6401 @item @emph{See also}:
6402 @ref{MAX}, @ref{MINLOC}, @ref{MINVAL}
6406 @section @code{MINEXPONENT} --- Minimum exponent of a real kind
6407 @cindex @code{MINEXPONENT} intrinsic
6408 @cindex minimum exponent
6409 @cindex exponent, minimum
6412 @item @emph{Description}:
6413 @code{MINEXPONENT(X)} returns the minimum exponent in the model of the
6416 @item @emph{Standard}:
6422 @item @emph{Syntax}:
6423 @code{RESULT = MINEXPONENT(X)}
6425 @item @emph{Arguments}:
6426 @multitable @columnfractions .15 .80
6427 @item @var{X} @tab shall be of type @code{REAL}.
6430 @item @emph{Return value}:
6431 The return value is of type @code{INTEGER} and of the default integer
6434 @item @emph{Example}:
6435 See @code{MAXEXPONENT} for an example.
6441 @section @code{MINLOC} --- Location of the minimum value within an array
6442 @cindex @code{MINLOC} intrinsic
6445 @item @emph{Description}:
6446 Determines the location of the element in the array with the minimum
6447 value, or, if the @var{DIM} argument is supplied, determines the
6448 locations of the minimum element along each row of the array in the
6449 @var{DIM} direction. If @var{MASK} is present, only the elements for
6450 which @var{MASK} is @code{.TRUE.} are considered. If more than one
6451 element in the array has the minimum value, the location returned is
6452 that of the first such element in array element order. If the array has
6453 zero size, or all of the elements of @var{MASK} are @code{.FALSE.}, then
6454 the result is an array of zeroes. Similarly, if @var{DIM} is supplied
6455 and all of the elements of @var{MASK} along a given row are zero, the
6456 result value for that row is zero.
6458 @item @emph{Standard}:
6462 Transformational function
6464 @item @emph{Syntax}:
6465 @multitable @columnfractions .80
6466 @item @code{RESULT = MINLOC(ARRAY, DIM [, MASK])}
6467 @item @code{RESULT = MINLOC(ARRAY [, MASK])}
6470 @item @emph{Arguments}:
6471 @multitable @columnfractions .15 .80
6472 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER(*)},
6473 @code{REAL(*)}, or @code{CHARACTER(*)}.
6474 @item @var{DIM} @tab (Optional) Shall be a scalar of type
6475 @code{INTEGER(*)}, with a value between one
6476 and the rank of @var{ARRAY}, inclusive. It
6477 may not be an optional dummy argument.
6478 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL(*)},
6479 and conformable with @var{ARRAY}.
6482 @item @emph{Return value}:
6483 If @var{DIM} is absent, the result is a rank-one array with a length
6484 equal to the rank of @var{ARRAY}. If @var{DIM} is present, the result
6485 is an array with a rank one less than the rank of @var{ARRAY}, and a
6486 size corresponding to the size of @var{ARRAY} with the @var{DIM}
6487 dimension removed. If @var{DIM} is present and @var{ARRAY} has a rank
6488 of one, the result is a scalar. In all cases, the result is of default
6489 @code{INTEGER} type.
6491 @item @emph{See also}:
6492 @ref{MIN}, @ref{MINVAL}
6499 @section @code{MINVAL} --- Minimum value of an array
6500 @cindex @code{MINVAL} intrinsic
6503 @item @emph{Description}:
6504 Determines the minimum value of the elements in an array value, or, if
6505 the @var{DIM} argument is supplied, determines the minimum value along
6506 each row of the array in the @var{DIM} direction. If @var{MASK} is
6507 present, only the elements for which @var{MASK} is @code{.TRUE.} are
6508 considered. If the array has zero size, or all of the elements of
6509 @var{MASK} are @code{.FALSE.}, then the result is @code{HUGE(ARRAY)} if
6510 @var{ARRAY} is numeric, or a string of @code{CHAR(255)} characters if
6511 @var{ARRAY} is of character type.
6513 @item @emph{Standard}:
6517 Transformational function
6519 @item @emph{Syntax}:
6520 @multitable @columnfractions .80
6521 @item @code{RESULT = MINVAL(ARRAY, DIM [, MASK])}
6522 @item @code{RESULT = MINVAL(ARRAY [, MASK])}
6525 @item @emph{Arguments}:
6526 @multitable @columnfractions .15 .80
6527 @item @var{ARRAY} @tab Shall be an array of type @code{INTEGER(*)},
6528 @code{REAL(*)}, or @code{CHARACTER(*)}.
6529 @item @var{DIM} @tab (Optional) Shall be a scalar of type
6530 @code{INTEGER(*)}, with a value between one
6531 and the rank of @var{ARRAY}, inclusive. It
6532 may not be an optional dummy argument.
6533 @item @var{MASK} @tab Shall be an array of type @code{LOGICAL(*)},
6534 and conformable with @var{ARRAY}.
6537 @item @emph{Return value}:
6538 If @var{DIM} is absent, or if @var{ARRAY} has a rank of one, the result
6539 is a scalar. If @var{DIM} is present, the result is an array with a
6540 rank one less than the rank of @var{ARRAY}, and a size corresponding to
6541 the size of @var{ARRAY} with the @var{DIM} dimension removed. In all
6542 cases, the result is of the same type and kind as @var{ARRAY}.
6544 @item @emph{See also}:
6545 @ref{MIN}, @ref{MINLOC}
6552 @section @code{MOD} --- Remainder function
6553 @cindex @code{MOD} intrinsic
6554 @cindex @code{AMOD} intrinsic
6555 @cindex @code{DMOD} intrinsic
6559 @item @emph{Description}:
6560 @code{MOD(A,P)} computes the remainder of the division of A by P. It is
6561 calculated as @code{A - (INT(A/P) * P)}.
6563 @item @emph{Standard}:
6569 @item @emph{Syntax}:
6570 @code{RESULT = MOD(A, P)}
6572 @item @emph{Arguments}:
6573 @multitable @columnfractions .15 .80
6574 @item @var{A} @tab shall be a scalar of type @code{INTEGER} or @code{REAL}
6575 @item @var{P} @tab shall be a scalar of the same type as @var{A} and not
6579 @item @emph{Return value}:
6580 The kind of the return value is the result of cross-promoting
6581 the kinds of the arguments.
6583 @item @emph{Example}:
6587 print *, mod(17.5,5.5)
6588 print *, mod(17.5d0,5.5)
6589 print *, mod(17.5,5.5d0)
6592 print *, mod(-17.5,5.5)
6593 print *, mod(-17.5d0,5.5)
6594 print *, mod(-17.5,5.5d0)
6597 print *, mod(17.5,-5.5)
6598 print *, mod(17.5d0,-5.5)
6599 print *, mod(17.5,-5.5d0)
6600 end program test_mod
6603 @item @emph{Specific names}:
6604 @multitable @columnfractions .20 .20 .20 .40
6605 @item Name @tab Arguments @tab Return type @tab Standard
6606 @item @code{AMOD(A,P)} @tab @code{REAL(4)} @tab @code{REAL(4)} @tab F95 and later
6607 @item @code{DMOD(A,P)} @tab @code{REAL(8)} @tab @code{REAL(8)} @tab F95 and later
6614 @section @code{MODULO} --- Modulo function
6615 @cindex @code{MODULO} intrinsic
6619 @item @emph{Description}:
6620 @code{MODULO(A,P)} computes the @var{A} modulo @var{P}.
6622 @item @emph{Standard}:
6628 @item @emph{Syntax}:
6629 @code{RESULT = MODULO(A, P)}
6631 @item @emph{Arguments}:
6632 @multitable @columnfractions .15 .80
6633 @item @var{A} @tab shall be a scalar of type @code{INTEGER} or @code{REAL}
6634 @item @var{P} @tab shall be a scalar of the same type and kind as @var{A}
6637 @item @emph{Return value}:
6638 The type and kind of the result are those of the arguments.
6640 @item If @var{A} and @var{P} are of type @code{INTEGER}:
6641 @code{MODULO(A,P)} has the value @var{R} such that @code{A=Q*P+R}, where
6642 @var{Q} is an integer and @var{R} is between 0 (inclusive) and @var{P}
6644 @item If @var{A} and @var{P} are of type @code{REAL}:
6645 @code{MODULO(A,P)} has the value of @code{A - FLOOR (A / P) * P}.
6647 In all cases, if @var{P} is zero the result is processor-dependent.
6649 @item @emph{Example}:
6652 print *, modulo(17,3)
6653 print *, modulo(17.5,5.5)
6655 print *, modulo(-17,3)
6656 print *, modulo(-17.5,5.5)
6658 print *, modulo(17,-3)
6659 print *, modulo(17.5,-5.5)
6660 end program test_mod
6668 @section @code{MOVE_ALLOC} --- Move allocation from one object to another
6669 @cindex @code{MOVE_ALLOC} intrinsic
6670 @cindex moving allocation
6671 @cindex allocation, moving
6674 @item @emph{Description}:
6675 @code{MOVE_ALLOC(SRC, DEST)} moves the allocation from @var{SRC} to
6676 @var{DEST}. @var{SRC} will become deallocated in the process.
6678 @item @emph{Standard}:
6684 @item @emph{Syntax}:
6685 @code{CALL MOVE_ALLOC(SRC, DEST)}
6687 @item @emph{Arguments}:
6688 @multitable @columnfractions .15 .80
6689 @item @var{SRC} @tab @code{ALLOCATABLE}, @code{INTENT(INOUT)}, may be
6690 of any type and kind.
6691 @item @var{DEST} @tab @code{ALLOCATABLE}, @code{INTENT(OUT)}, shall be
6692 of the same type, kind and rank as @var{SRC}
6695 @item @emph{Return value}:
6698 @item @emph{Example}:
6700 program test_move_alloc
6701 integer, allocatable :: a(:), b(:)
6705 call move_alloc(a, b)
6706 print *, allocated(a), allocated(b)
6708 end program test_move_alloc
6715 @section @code{MVBITS} --- Move bits from one integer to another
6716 @cindex @code{MVBITS} intrinsic
6717 @cindex bit operations
6720 @item @emph{Description}:
6721 Moves @var{LEN} bits from positions @var{FROMPOS} through
6722 @code{FROMPOS+LEN-1} of @var{FROM} to positions @var{TOPOS} through
6723 @code{TOPOS+LEN-1} of @var{TO}. The portion of argument @var{TO} not
6724 affected by the movement of bits is unchanged. The values of
6725 @code{FROMPOS+LEN-1} and @code{TOPOS+LEN-1} must be less than
6726 @code{BIT_SIZE(FROM)}.
6728 @item @emph{Standard}:
6734 @item @emph{Syntax}:
6735 @code{RESULT = MVBITS(FROM, FROMPOS, LEN, TO, TOPOS)}
6737 @item @emph{Arguments}:
6738 @multitable @columnfractions .15 .80
6739 @item @var{FROM} @tab The type shall be @code{INTEGER(*)}.
6740 @item @var{FROMPOS} @tab The type shall be @code{INTEGER(*)}.
6741 @item @var{LEN} @tab The type shall be @code{INTEGER(*)}.
6742 @item @var{TO} @tab The type shall be @code{INTEGER(*)}, of the
6743 same kind as @var{FROM}.
6744 @item @var{TOPOS} @tab The type shall be @code{INTEGER(*)}.
6747 @item @emph{Return value}:
6748 The return value is of type @code{INTEGER(*)} and of the same kind as
6751 @item @emph{See also}:
6752 @ref{IBCLR}, @ref{IBSET}, @ref{IBITS}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
6759 @section @code{NEAREST} --- Nearest representable number
6760 @cindex @code{NEAREST} intrinsic
6761 @cindex processor-representable number
6764 @item @emph{Description}:
6765 @code{NEAREST(X, S)} returns the processor-representable number nearest
6766 to @code{X} in the direction indicated by the sign of @code{S}.
6768 @item @emph{Standard}:
6774 @item @emph{Syntax}:
6775 @code{RESULT = NEAREST(X, S)}
6777 @item @emph{Arguments}:
6778 @multitable @columnfractions .15 .80
6779 @item @var{X} @tab shall be of type @code{REAL}.
6780 @item @var{S} @tab (Optional) shall be of type @code{REAL} and
6784 @item @emph{Return value}:
6785 The return value is of the same type as @code{X}. If @code{S} is
6786 positive, @code{NEAREST} returns the processor-representable number
6787 greater than @code{X} and nearest to it. If @code{S} is negative,
6788 @code{NEAREST} returns the processor-representable number smaller than
6789 @code{X} and nearest to it.
6791 @item @emph{Example}:
6793 program test_nearest
6795 x = nearest(42.0, 1.0)
6796 y = nearest(42.0, -1.0)
6797 write (*,"(3(G20.15))") x, y, x - y
6798 end program test_nearest
6805 @section @code{NEW_LINE} --- New line character
6806 @cindex @code{NEW_LINE} intrinsic
6807 @cindex @code{NEW_LINE} intrinsic
6810 @item @emph{Description}:
6811 @code{NEW_LINE(C)} returns the new-line character.
6813 @item @emph{Standard}:
6819 @item @emph{Syntax}:
6820 @code{RESULT = NEW_LINE(C)}
6822 @item @emph{Arguments}:
6823 @multitable @columnfractions .15 .80
6824 @item @var{C} @tab The argument shall be a scalar or array of the
6825 type @code{CHARACTER}.
6828 @item @emph{Return value}:
6829 Returns a @var{CHARACTER} scalar of length one with the new-line character of
6830 the same kind as parameter @var{C}.
6832 @item @emph{Example}:
6836 write(*,'(A)') 'This is record 1.'//NEW_LINE('A')//'This is record 2.'
6844 @section @code{NINT} --- Nearest whole number
6845 @cindex @code{NINT} intrinsic
6846 @cindex @code{IDNINT} intrinsic
6847 @cindex whole number
6850 @item @emph{Description}:
6851 @code{NINT(X)} rounds its argument to the nearest whole number.
6853 @item @emph{Standard}:
6859 @item @emph{Syntax}:
6860 @code{RESULT = NINT(X)}
6862 @item @emph{Arguments}:
6863 @multitable @columnfractions .15 .80
6864 @item @var{X} @tab The type of the argument shall be @code{REAL}.
6867 @item @emph{Return value}:
6868 Returns @var{A} with the fractional portion of its magnitude eliminated by
6869 rounding to the nearest whole number and with its sign preserved,
6870 converted to an @code{INTEGER} of the default kind.
6872 @item @emph{Example}:
6879 print *, nint(x4), idnint(x8)
6880 end program test_nint
6883 @item @emph{Specific names}:
6884 @multitable @columnfractions .33 .33 .33
6885 @item Name @tab Argument @tab Standard
6886 @item @code{IDNINT(X)} @tab @code{REAL(8)} @tab F95 and later
6889 @item @emph{See also}:
6890 @ref{CEILING}, @ref{FLOOR}
6896 @section @code{NOT} --- Logical negation
6897 @cindex @code{NOT} intrinsic
6898 @cindex bit operations
6901 @item @emph{Description}:
6902 @code{NOT} returns the bitwise boolean inverse of @var{I}.
6904 @item @emph{Standard}:
6910 @item @emph{Syntax}:
6911 @code{RESULT = NOT(I)}
6913 @item @emph{Arguments}:
6914 @multitable @columnfractions .15 .80
6915 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
6918 @item @emph{Return value}:
6919 The return type is @code{INTEGER(*)}, of the same kind as the
6922 @item @emph{See also}:
6923 @ref{IAND}, @ref{IEOR}, @ref{IOR}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR}
6931 @section @code{NULL} --- Function that returns an disassociated pointer
6932 @cindex @code{NULL} intrinsic
6933 @cindex undocumented intrinsic
6935 Intrinsic implemented, documentation pending.
6938 @item @emph{Description}:
6939 @item @emph{Standard}:
6943 Transformational function
6945 @item @emph{Syntax}:
6946 @item @emph{Arguments}:
6947 @item @emph{Return value}:
6948 @item @emph{Example}:
6949 @item @emph{See also}:
6957 @section @code{OR} --- Bitwise logical OR
6958 @cindex @code{OR} intrinsic
6959 @cindex bit operations
6962 @item @emph{Description}:
6963 Bitwise logical @code{OR}.
6965 This intrinsic routine is provided for backwards compatibility with
6966 GNU Fortran 77. For integer arguments, programmers should consider
6967 the use of the @ref{IOR} intrinsic defined by the Fortran standard.
6969 @item @emph{Standard}:
6973 Non-elemental function
6975 @item @emph{Syntax}:
6976 @code{RESULT = OR(X, Y)}
6978 @item @emph{Arguments}:
6979 @multitable @columnfractions .15 .80
6980 @item @var{X} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
6981 @item @var{Y} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
6984 @item @emph{Return value}:
6985 The return type is either @code{INTEGER(*)} or @code{LOGICAL}
6986 after cross-promotion of the arguments.
6988 @item @emph{Example}:
6991 LOGICAL :: T = .TRUE., F = ..FALSE.
6993 DATA a / Z'F' /, b / Z'3' /
6995 WRITE (*,*) OR(T, T), OR(T, F), OR(F, T), OR(F, F)
6996 WRITE (*,*) OR(a, b)
7000 @item @emph{See also}:
7001 F95 elemental function: @ref{IOR}
7008 @section @code{PACK} --- Pack an array into an array of rank one
7009 @cindex @code{PACK} intrinsic
7010 @cindex undocumented intrinsic
7012 Intrinsic implemented, documentation pending.
7015 @item @emph{Description}:
7016 @item @emph{Standard}:
7020 Transformational function
7022 @item @emph{Syntax}:
7023 @item @emph{Arguments}:
7024 @item @emph{Return value}:
7025 @item @emph{Example}:
7026 @item @emph{Specific names}:
7027 @item @emph{See also}:
7034 @section @code{PERROR} --- Print system error message
7035 @cindex @code{PERROR} intrinsic
7038 @item @emph{Description}:
7039 Prints (on the C @code{stderr} stream) a newline-terminated error
7040 message corresponding to the last system error. This is prefixed by
7041 @var{STRING}, a colon and a space. See @code{perror(3)}.
7043 @item @emph{Standard}:
7049 @item @emph{Syntax}:
7050 @code{CALL PERROR(STRING)}
7052 @item @emph{Arguments}:
7053 @multitable @columnfractions .15 .80
7054 @item @var{STRING} @tab A scalar of default @code{CHARACTER} type.
7057 @item @emph{See also}:
7064 @section @code{PRECISION} --- Decimal precision of a real kind
7065 @cindex @code{PRECISION} intrinsic
7066 @cindex precision of a real variable
7069 @item @emph{Description}:
7070 @code{PRECISION(X)} returns the decimal precision in the model of the
7073 @item @emph{Standard}:
7079 @item @emph{Syntax}:
7080 @code{RESULT = PRECISION(X)}
7082 @item @emph{Arguments}:
7083 @multitable @columnfractions .15 .80
7084 @item @var{X} @tab shall be of type @code{REAL} or @code{COMPLEX}.
7087 @item @emph{Return value}:
7088 The return value is of type @code{INTEGER} and of the default integer
7091 @item @emph{Example}:
7093 program prec_and_range
7094 real(kind=4) :: x(2)
7095 complex(kind=8) :: y
7097 print *, precision(x), range(x)
7098 print *, precision(y), range(y)
7099 end program prec_and_range
7106 @section @code{PRESENT} --- Determine whether an optional argument is specified
7107 @cindex @code{PRESENT} intrinsic
7108 @cindex undocumented intrinsic
7110 Intrinsic implemented, documentation pending.
7113 @item @emph{Description}:
7114 @item @emph{Standard}:
7120 @item @emph{Syntax}:
7121 @item @emph{Arguments}:
7122 @item @emph{Return value}:
7123 @item @emph{Example}:
7124 @item @emph{See also}:
7130 @section @code{PRODUCT} --- Product of array elements
7131 @cindex @code{PRODUCT} intrinsic
7132 @cindex undocumented intrinsic
7134 Intrinsic implemented, documentation pending.
7137 @item @emph{Description}:
7138 @item @emph{Standard}:
7142 Transformational function
7144 @item @emph{Syntax}:
7145 @item @emph{Arguments}:
7146 @item @emph{Return value}:
7147 @item @emph{Example}:
7148 @item @emph{Specific names}:
7149 @item @emph{See also}:
7156 @section @code{RADIX} --- Base of a model number
7157 @cindex @code{RADIX} intrinsic
7161 @item @emph{Description}:
7162 @code{RADIX(X)} returns the base of the model representing the entity @var{X}.
7164 @item @emph{Standard}:
7170 @item @emph{Syntax}:
7171 @code{RESULT = RADIX(X)}
7173 @item @emph{Arguments}:
7174 @multitable @columnfractions .15 .80
7175 @item @var{X} @tab Shall be of type @code{INTEGER} or @code{REAL}
7178 @item @emph{Return value}:
7179 The return value is a scalar of type @code{INTEGER} and of the default
7182 @item @emph{Example}:
7185 print *, "The radix for the default integer kind is", radix(0)
7186 print *, "The radix for the default real kind is", radix(0.0)
7187 end program test_radix
7195 @section @code{RAN} --- Real pseudo-random number
7196 @cindex @code{RAN} intrinsic
7197 @cindex random numbers
7200 @item @emph{Description}:
7201 For compatibility with HP FORTRAN 77/iX, the @code{RAN} intrinsic is
7202 provided as an alias for @code{RAND}. See @ref{RAND} for complete
7205 @item @emph{Standard}:
7209 Non-elemental function
7211 @item @emph{See also}:
7212 @ref{RAND}, @ref{RANDOM_NUMBER}
7218 @section @code{RAND} --- Real pseudo-random number
7219 @cindex @code{RAND} intrinsic
7220 @cindex random numbers
7223 @item @emph{Description}:
7224 @code{RAND(FLAG)} returns a pseudo-random number from a uniform
7225 distribution between 0 and 1. If @var{FLAG} is 0, the next number
7226 in the current sequence is returned; if @var{FLAG} is 1, the generator
7227 is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
7228 it is used as a new seed with @code{SRAND}.
7230 @item @emph{Standard}:
7234 Non-elemental function
7236 @item @emph{Syntax}:
7237 @code{RESULT = RAND(FLAG)}
7239 @item @emph{Arguments}:
7240 @multitable @columnfractions .15 .80
7241 @item @var{FLAG} @tab shall be a scalar @code{INTEGER} of kind 4.
7244 @item @emph{Return value}:
7245 The return value is of @code{REAL} type and the default kind.
7247 @item @emph{Example}:
7250 integer,parameter :: seed = 86456
7253 print *, rand(), rand(), rand(), rand()
7254 print *, rand(seed), rand(), rand(), rand()
7255 end program test_rand
7258 @item @emph{See also}:
7259 @ref{SRAND}, @ref{RANDOM_NUMBER}
7266 @section @code{RANDOM_NUMBER} --- Pseudo-random number
7267 @cindex @code{RANDOM_NUMBER} intrinsic
7268 @cindex random numbers
7270 Intrinsic implemented, documentation pending.
7273 @item @emph{Description}:
7274 @item @emph{Standard}:
7278 Elemental subroutine
7280 @item @emph{Syntax}:
7281 @item @emph{Arguments}:
7282 @item @emph{Return value}:
7283 @item @emph{Example}:
7284 @item @emph{See also}:
7291 @section @code{RANDOM_SEED} --- Initialize a pseudo-random number sequence
7292 @cindex @code{RANDOM_SEED} intrinsic
7293 @cindex random numbers
7295 Intrinsic implemented, documentation pending.
7298 @item @emph{Description}:
7299 @item @emph{Standard}:
7305 @item @emph{Syntax}:
7306 @item @emph{Arguments}:
7307 @item @emph{Return value}:
7308 @item @emph{Example}:
7309 @item @emph{See also}:
7316 @section @code{RANGE} --- Decimal exponent range of a real kind
7317 @cindex @code{RANGE} intrinsic
7318 @cindex range of a real variable
7321 @item @emph{Description}:
7322 @code{RANGE(X)} returns the decimal exponent range in the model of the
7325 @item @emph{Standard}:
7331 @item @emph{Syntax}:
7332 @code{RESULT = RANGE(X)}
7334 @item @emph{Arguments}:
7335 @multitable @columnfractions .15 .80
7336 @item @var{X} @tab shall be of type @code{REAL} or @code{COMPLEX}.
7339 @item @emph{Return value}:
7340 The return value is of type @code{INTEGER} and of the default integer
7343 @item @emph{Example}:
7344 See @code{PRECISION} for an example.
7350 @section @code{REAL} --- Convert to real type
7351 @cindex @code{REAL} intrinsic
7352 @cindex @code{REALPART} intrinsic
7356 @item @emph{Description}:
7357 @code{REAL(X [, KIND])} converts its argument @var{X} to a real type. The
7358 @code{REALPART(X)} function is provided for compatibility with @command{g77},
7359 and its use is strongly discouraged.
7361 @item @emph{Standard}:
7367 @item @emph{Syntax}:
7368 @multitable @columnfractions .30 .80
7369 @item @code{RESULT = REAL(X [, KIND])}
7370 @item @code{RESULT = REALPART(Z)}
7373 @item @emph{Arguments}:
7374 @multitable @columnfractions .15 .80
7375 @item @var{X} @tab shall be @code{INTEGER(*)}, @code{REAL(*)}, or
7377 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
7378 expression indicating the kind parameter of
7382 @item @emph{Return value}:
7383 These functions return a @code{REAL(*)} variable or array under
7384 the following rules:
7388 @code{REAL(X)} is converted to a default real type if @var{X} is an
7389 integer or real variable.
7391 @code{REAL(X)} is converted to a real type with the kind type parameter
7392 of @var{X} if @var{X} is a complex variable.
7394 @code{REAL(X, KIND)} is converted to a real type with kind type
7395 parameter @var{KIND} if @var{X} is a complex, integer, or real
7399 @item @emph{Example}:
7402 complex :: x = (1.0, 2.0)
7403 print *, real(x), real(x,8), realpart(x)
7404 end program test_real
7407 @item @emph{See also}:
7408 @ref{DBLE}, @ref{DFLOAT}, @ref{FLOAT}
7415 @section @code{RENAME} --- Rename a file
7416 @cindex @code{RENAME} intrinsic
7417 @cindex file system operations
7420 @item @emph{Description}:
7421 Renames a file from file @var{PATH1} to @var{PATH2}. A null
7422 character (@code{CHAR(0)}) can be used to mark the end of the names in
7423 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
7424 names are ignored. If the @var{STATUS} argument is supplied, it
7425 contains 0 on success or a nonzero error code upon return; see
7428 @item @emph{Standard}:
7434 @item @emph{Syntax}:
7435 @code{CALL RENAME(PATH1, PATH2 [, STATUS])}
7437 @item @emph{Arguments}:
7438 @multitable @columnfractions .15 .80
7439 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
7440 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
7441 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
7444 @item @emph{See also}:
7452 @section @code{REPEAT} --- Repeated string concatenation
7453 @cindex @code{REPEAT} intrinsic
7454 @cindex string manipulation
7456 Intrinsic implemented, documentation pending.
7459 @item @emph{Description}:
7460 @item @emph{Standard}:
7464 Transformational function
7466 @item @emph{Syntax}:
7467 @item @emph{Arguments}:
7468 @item @emph{Return value}:
7469 @item @emph{Example}:
7470 @item @emph{See also}:
7477 @section @code{RESHAPE} --- Function to reshape an array
7478 @cindex @code{RESHAPE} intrinsic
7479 @cindex array manipulation
7481 Intrinsic implemented, documentation pending.
7484 @item @emph{Description}:
7485 @item @emph{Standard}:
7489 Transformational function
7491 @item @emph{Syntax}:
7492 @item @emph{Arguments}:
7493 @item @emph{Return value}:
7494 @item @emph{Example}:
7495 @item @emph{See also}:
7502 @section @code{RRSPACING} --- Reciprocal of the relative spacing
7503 @cindex @code{RRSPACING} intrinsic
7506 @item @emph{Description}:
7507 @code{RRSPACING(X)} returns the reciprocal of the relative spacing of
7508 model numbers near @var{X}.
7510 @item @emph{Standard}:
7516 @item @emph{Syntax}:
7517 @code{RESULT = RRSPACING(X)}
7519 @item @emph{Arguments}:
7520 @multitable @columnfractions .15 .80
7521 @item @var{X} @tab shall be of type @code{REAL}.
7524 @item @emph{Return value}:
7525 The return value is of the same type and kind as @var{X}.
7526 The value returned is equal to
7527 @code{ABS(FRACTION(X)) * FLOAT(RADIX(X))**DIGITS(X)}.
7534 @section @code{RSHIFT} --- Right shift bits
7535 @cindex @code{RSHIFT} intrinsic
7536 @cindex bit operations
7539 @item @emph{Description}:
7540 @code{RSHIFT} returns a value corresponding to @var{I} with all of the
7541 bits shifted right by @var{SHIFT} places. If the absolute value of
7542 @var{SHIFT} is greater than @code{BIT_SIZE(I)}, the value is undefined.
7543 Bits shifted out from the left end are lost; zeros are shifted in from
7546 This function has been superceded by the @code{ISHFT} intrinsic, which
7547 is standard in Fortran 95 and later.
7549 @item @emph{Standard}:
7555 @item @emph{Syntax}:
7556 @code{RESULT = RSHIFT(I, SHIFT)}
7558 @item @emph{Arguments}:
7559 @multitable @columnfractions .15 .80
7560 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
7561 @item @var{SHIFT} @tab The type shall be @code{INTEGER(*)}.
7564 @item @emph{Return value}:
7565 The return value is of type @code{INTEGER(*)} and of the same kind as
7568 @item @emph{See also}:
7569 @ref{ISHFT}, @ref{ISHFTC}, @ref{LSHIFT}
7576 @section @code{SCALE} --- Scale a real value
7577 @cindex @code{SCALE} intrinsic
7580 @item @emph{Description}:
7581 @code{SCALE(X,I)} returns @code{X * RADIX(X)**I}.
7583 @item @emph{Standard}:
7589 @item @emph{Syntax}:
7590 @code{RESULT = SCALE(X, I)}
7592 @item @emph{Arguments}:
7593 @multitable @columnfractions .15 .80
7594 @item @var{X} @tab The type of the argument shall be a @code{REAL}.
7595 @item @var{I} @tab The type of the argument shall be a @code{INTEGER}.
7598 @item @emph{Return value}:
7599 The return value is of the same type and kind as @var{X}.
7600 Its value is @code{X * RADIX(X)**I}.
7602 @item @emph{Example}:
7605 real :: x = 178.1387e-4
7607 print *, scale(x,i), x*radix(x)**i
7608 end program test_scale
7615 @section @code{SCAN} --- Scan a string for the presence of a set of characters
7616 @cindex @code{SCAN} intrinsic
7617 @cindex string manipulation
7619 Intrinsic implemented, documentation pending.
7622 @item @emph{Description}:
7623 @item @emph{Standard}:
7629 @item @emph{Syntax}:
7630 @item @emph{Arguments}:
7631 @item @emph{Return value}:
7632 @item @emph{Example}:
7633 @item @emph{See also}:
7640 @section @code{SECNDS} --- Time function
7641 @cindex @code{SECNDS} intrinsic
7642 @cindex time, current
7643 @cindex current time
7646 @item @emph{Description}:
7647 @code{SECNDS(X)} gets the time in seconds from the real-time system clock.
7648 @var{X} is a reference time, also in seconds. If this is zero, the time in
7649 seconds from midnight is returned. This function is non-standard and its
7652 @item @emph{Standard}:
7658 @item @emph{Syntax}:
7659 @code{RESULT = SECNDS (X)}
7661 @item @emph{Arguments}:
7662 @multitable @columnfractions .15 .80
7663 @item Name @tab Type
7664 @item @var{T} @tab REAL(4)
7665 @item @var{X} @tab REAL(4)
7668 @item @emph{Return value}:
7671 @item @emph{Example}:
7675 print *, secnds (0.0) ! seconds since midnight
7676 t1 = secnds (0.0) ! reference time
7677 do i = 1, 10000000 ! do something
7679 t2 = secnds (t1) ! elapsed time
7680 print *, "Something took ", t2, " seconds."
7681 end program test_secnds
7687 @node SELECTED_INT_KIND
7688 @section @code{SELECTED_INT_KIND} --- Choose integer kind
7689 @cindex @code{SELECTED_INT_KIND} intrinsic
7690 @cindex integer kind
7693 @item @emph{Description}:
7694 @code{SELECTED_INT_KIND(I)} return the kind value of the smallest integer
7695 type that can represent all values ranging from @math{-10^I} (exclusive)
7696 to @math{10^I} (exclusive). If there is no integer kind that accommodates
7697 this range, @code{SELECTED_INT_KIND} returns @math{-1}.
7699 @item @emph{Standard}:
7703 Transformational function
7705 @item @emph{Syntax}:
7706 @code{RESULT = SELECTED_INT_KIND(I)}
7708 @item @emph{Arguments}:
7709 @multitable @columnfractions .15 .80
7710 @item @var{I} @tab shall be a scalar and of type @code{INTEGER}.
7713 @item @emph{Example}:
7715 program large_integers
7716 integer,parameter :: k5 = selected_int_kind(5)
7717 integer,parameter :: k15 = selected_int_kind(15)
7718 integer(kind=k5) :: i5
7719 integer(kind=k15) :: i15
7721 print *, huge(i5), huge(i15)
7723 ! The following inequalities are always true
7724 print *, huge(i5) >= 10_k5**5-1
7725 print *, huge(i15) >= 10_k15**15-1
7726 end program large_integers
7732 @node SELECTED_REAL_KIND
7733 @section @code{SELECTED_REAL_KIND} --- Choose real kind
7734 @cindex @code{SELECTED_REAL_KIND} intrinsic
7738 @item @emph{Description}:
7739 @code{SELECTED_REAL_KIND(P,R)} return the kind value of a real data type
7740 with decimal precision greater of at least @code{P} digits and exponent
7741 range greater at least @code{R}.
7743 @item @emph{Standard}:
7747 Transformational function
7749 @item @emph{Syntax}:
7750 @code{RESULT = SELECTED_REAL_KIND(P, R)}
7752 @item @emph{Arguments}:
7753 @multitable @columnfractions .15 .80
7754 @item @var{P} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
7755 @item @var{R} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
7757 At least one argument shall be present.
7759 @item @emph{Return value}:
7761 @code{SELECTED_REAL_KIND} returns the value of the kind type parameter of
7762 a real data type with decimal precision of at least @code{P} digits and a
7763 decimal exponent range of at least @code{R}. If more than one real data
7764 type meet the criteria, the kind of the data type with the smallest
7765 decimal precision is returned. If no real data type matches the criteria,
7768 @item -1 if the processor does not support a real data type with a
7769 precision greater than or equal to @code{P}
7770 @item -2 if the processor does not support a real type with an exponent
7771 range greater than or equal to @code{R}
7772 @item -3 if neither is supported.
7775 @item @emph{Example}:
7778 integer,parameter :: p6 = selected_real_kind(6)
7779 integer,parameter :: p10r100 = selected_real_kind(10,100)
7780 integer,parameter :: r400 = selected_real_kind(r=400)
7782 real(kind=p10r100) :: y
7783 real(kind=r400) :: z
7785 print *, precision(x), range(x)
7786 print *, precision(y), range(y)
7787 print *, precision(z), range(z)
7788 end program real_kinds
7795 @section @code{SET_EXPONENT} --- Set the exponent of the model
7796 @cindex @code{SET_EXPONENT} intrinsic
7797 @cindex exponent part of a real number
7800 @item @emph{Description}:
7801 @code{SET_EXPONENT(X, I)} returns the real number whose fractional part
7802 is that that of @var{X} and whose exponent part is @var{I}.
7804 @item @emph{Standard}:
7810 @item @emph{Syntax}:
7811 @code{RESULT = SET_EXPONENT(X, I)}
7813 @item @emph{Arguments}:
7814 @multitable @columnfractions .15 .80
7815 @item @var{X} @tab shall be of type @code{REAL}.
7816 @item @var{I} @tab shall be of type @code{INTEGER}.
7819 @item @emph{Return value}:
7820 The return value is of the same type and kind as @var{X}.
7821 The real number whose fractional part
7822 is that that of @var{X} and whose exponent part if @var{I} is returned;
7823 it is @code{FRACTION(X) * RADIX(X)**I}.
7825 @item @emph{Example}:
7828 real :: x = 178.1387e-4
7830 print *, set_exponent(x), fraction(x) * radix(x)**i
7831 end program test_setexp
7839 @section @code{SHAPE} --- Determine the shape of an array
7840 @cindex @code{SHAPE} intrinsic
7841 @cindex array manipulation
7843 Intrinsic implemented, documentation pending.
7846 @item @emph{Description}:
7847 @item @emph{Standard}:
7853 @item @emph{Syntax}:
7854 @item @emph{Arguments}:
7855 @item @emph{Return value}:
7856 @item @emph{Example}:
7857 @item @emph{See also}:
7864 @section @code{SIGN} --- Sign copying function
7865 @cindex @code{SIGN} intrinsic
7866 @cindex @code{ISIGN} intrinsic
7867 @cindex @code{DSIGN} intrinsic
7868 @cindex sign copying
7871 @item @emph{Description}:
7872 @code{SIGN(A,B)} returns the value of @var{A} with the sign of @var{B}.
7874 @item @emph{Standard}:
7880 @item @emph{Syntax}:
7881 @code{RESULT = SIGN(A, B)}
7883 @item @emph{Arguments}:
7884 @multitable @columnfractions .15 .80
7885 @item @var{A} @tab shall be a scalar of type @code{INTEGER} or @code{REAL}
7886 @item @var{B} @tab shall be a scalar of the same type and kind as @var{A}
7889 @item @emph{Return value}:
7890 The kind of the return value is that of @var{A} and @var{B}.
7891 If @math{B\ge 0} then the result is @code{ABS(A)}, else
7892 it is @code{-ABS(A)}.
7894 @item @emph{Example}:
7897 print *, sign(-12,1)
7898 print *, sign(-12,0)
7899 print *, sign(-12,-1)
7901 print *, sign(-12.,1.)
7902 print *, sign(-12.,0.)
7903 print *, sign(-12.,-1.)
7904 end program test_sign
7907 @item @emph{Specific names}:
7908 @multitable @columnfractions .20 .20 .20 .40
7909 @item Name @tab Arguments @tab Return type @tab Standard
7910 @item @code{ISIGN(A,P)} @tab @code{INTEGER(4)} @tab @code{INTEGER(4)} @tab f95, gnu
7911 @item @code{DSIGN(A,P)} @tab @code{REAL(8)} @tab @code{REAL(8)} @tab f95, gnu
7918 @section @code{SIGNAL} --- Signal handling subroutine (or function)
7919 @cindex @code{SIGNAL} intrinsic
7920 @cindex signal handling
7923 @item @emph{Description}:
7924 @code{SIGNAL(NUMBER, HANDLER [, STATUS])} causes external subroutine
7925 @var{HANDLER} to be executed with a single integer argument when signal
7926 @var{NUMBER} occurs. If @var{HANDLER} is an integer, it can be used to
7927 turn off handling of signal @var{NUMBER} or revert to its default
7928 action. See @code{signal(2)}.
7930 If @code{SIGNAL} is called as a subroutine and the @var{STATUS} argument
7931 is supplied, it is set to the value returned by @code{signal(2)}.
7933 @item @emph{Standard}:
7937 subroutine, non-elemental function
7939 @item @emph{Syntax}:
7940 @multitable @columnfractions .80
7941 @item @code{CALL SIGNAL(NUMBER, HANDLER [, STATUS])}
7942 @item @code{STATUS = SIGNAL(NUMBER, HANDLER)}
7945 @item @emph{Arguments}:
7946 @multitable @columnfractions .15 .80
7947 @item @var{NUMBER} @tab shall be a scalar integer, with @code{INTENT(IN)}
7948 @item @var{HANDLER}@tab Signal handler (@code{INTEGER FUNCTION} or
7949 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar.
7950 @code{INTEGER}. It is @code{INTENT(IN)}.
7951 @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
7952 integer. It has @code{INTENT(OUT)}.
7955 @item @emph{Return value}:
7956 The @code{SIGNAL} function returns the value returned by @code{signal(2)}.
7958 @item @emph{Example}:
7962 external handler_print
7964 call signal (12, handler_print)
7968 end program test_signal
7975 @section @code{SIN} --- Sine function
7976 @cindex @code{SIN} intrinsic
7977 @cindex @code{DSIN} intrinsic
7978 @cindex @code{ZSIN} intrinsic
7979 @cindex @code{CDSIN} intrinsic
7980 @cindex trigonometric functions
7983 @item @emph{Description}:
7984 @code{SIN(X)} computes the sine of @var{X}.
7986 @item @emph{Standard}:
7992 @item @emph{Syntax}:
7993 @code{RESULT = SIN(X)}
7995 @item @emph{Arguments}:
7996 @multitable @columnfractions .15 .80
7997 @item @var{X} @tab The type shall be @code{REAL(*)} or
8001 @item @emph{Return value}:
8002 The return value has same type and kind as @var{X}.
8004 @item @emph{Example}:
8009 end program test_sin
8012 @item @emph{Specific names}:
8013 @multitable @columnfractions .20 .20 .20 .40
8014 @item Name @tab Argument @tab Return type @tab Standard
8015 @item @code{DSIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
8016 @item @code{CSIN(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab f95, gnu
8017 @item @code{ZSIN(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
8018 @item @code{CDSIN(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
8021 @item @emph{See also}:
8028 @section @code{SINH} --- Hyperbolic sine function
8029 @cindex @code{SINH} intrinsic
8030 @cindex @code{DSINH} intrinsic
8031 @cindex hyperbolic sine
8034 @item @emph{Description}:
8035 @code{SINH(X)} computes the hyperbolic sine of @var{X}.
8037 @item @emph{Standard}:
8043 @item @emph{Syntax}:
8044 @code{RESULT = SINH(X)}
8046 @item @emph{Arguments}:
8047 @multitable @columnfractions .15 .80
8048 @item @var{X} @tab The type shall be @code{REAL(*)}.
8051 @item @emph{Return value}:
8052 The return value is of type @code{REAL(*)}.
8054 @item @emph{Example}:
8057 real(8) :: x = - 1.0_8
8059 end program test_sinh
8062 @item @emph{Specific names}:
8063 @multitable @columnfractions .20 .20 .20 .40
8064 @item Name @tab Argument @tab Return type @tab Standard
8065 @item @code{DSINH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
8068 @item @emph{See also}:
8075 @section @code{SIZE} --- Determine the size of an array
8076 @cindex @code{SIZE} intrinsic
8077 @cindex array manipulation
8079 Intrinsic implemented, documentation pending.
8082 @item @emph{Description}:
8083 @item @emph{Standard}:
8089 @item @emph{Syntax}:
8090 @item @emph{Arguments}:
8091 @item @emph{Return value}:
8092 @item @emph{Example}:
8093 @item @emph{See also}:
8099 @section @code{SNGL} --- Convert double precision real to default real
8100 @cindex @code{SNGL} intrinsic
8101 @cindex conversion function (real)
8104 @item @emph{Description}:
8105 @code{SNGL(A)} converts the double precision real @var{A}
8106 to a default real value. This is an archaic form of @code{REAL}
8107 that is specific to one type for @var{A}.
8109 @item @emph{Standard}:
8115 @item @emph{Syntax}:
8116 @code{RESULT = SNGL(A)}
8118 @item @emph{Arguments}:
8119 @multitable @columnfractions .15 .80
8120 @item @var{A} @tab The type shall be a double precision @code{REAL}.
8123 @item @emph{Return value}:
8124 The return value is of type default @code{REAL}.
8126 @item @emph{See also}:
8133 @section @code{SPACING} --- Smallest distance between two numbers of a given type
8134 @cindex @code{SPACING} intrinsic
8135 @cindex undocumented intrinsic
8137 Intrinsic implemented, documentation pending.
8140 @item @emph{Description}:
8141 @item @emph{Standard}:
8147 @item @emph{Syntax}:
8148 @item @emph{Arguments}:
8149 @item @emph{Return value}:
8150 @item @emph{Example}:
8151 @item @emph{See also}:
8158 @section @code{SPREAD} --- Add a dimension to an array
8159 @cindex @code{SPREAD} intrinsic
8160 @cindex array manipulation
8162 Intrinsic implemented, documentation pending.
8165 @item @emph{Description}:
8166 @item @emph{Standard}:
8170 Transformational function
8172 @item @emph{Syntax}:
8173 @item @emph{Arguments}:
8174 @item @emph{Return value}:
8175 @item @emph{Example}:
8176 @item @emph{See also}:
8183 @section @code{SQRT} --- Square-root function
8184 @cindex @code{SQRT} intrinsic
8185 @cindex @code{DSQRT} intrinsic
8186 @cindex @code{CSQRT} intrinsic
8187 @cindex @code{ZSQRT} intrinsic
8188 @cindex @code{CDSQRT} intrinsic
8192 @item @emph{Description}:
8193 @code{SQRT(X)} computes the square root of @var{X}.
8195 @item @emph{Standard}:
8201 @item @emph{Syntax}:
8202 @code{RESULT = SQRT(X)}
8204 @item @emph{Arguments}:
8205 @multitable @columnfractions .15 .80
8206 @item @var{X} @tab The type shall be @code{REAL(*)} or
8210 @item @emph{Return value}:
8211 The return value is of type @code{REAL(*)} or @code{COMPLEX(*)}.
8212 The kind type parameter is the same as @var{X}.
8214 @item @emph{Example}:
8217 real(8) :: x = 2.0_8
8218 complex :: z = (1.0, 2.0)
8221 end program test_sqrt
8224 @item @emph{Specific names}:
8225 @multitable @columnfractions .20 .20 .20 .40
8226 @item Name @tab Argument @tab Return type @tab Standard
8227 @item @code{DSQRT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
8228 @item @code{CSQRT(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab F95 and later
8229 @item @code{ZSQRT(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
8230 @item @code{CDSQRT(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
8237 @section @code{SRAND} --- Reinitialize the random number generator
8238 @cindex @code{SRAND} intrinsic
8239 @cindex random numbers
8242 @item @emph{Description}:
8243 @code{SRAND} reinitializes the pseudo-random number generator
8244 called by @code{RAND} and @code{IRAND}. The new seed used by the
8245 generator is specified by the required argument @var{SEED}.
8247 @item @emph{Standard}:
8251 non-elemental subroutine
8253 @item @emph{Syntax}:
8254 @code{CALL SRAND(SEED)}
8256 @item @emph{Arguments}:
8257 @multitable @columnfractions .15 .80
8258 @item @var{SEED} @tab shall be a scalar @code{INTEGER(kind=4)}.
8261 @item @emph{Return value}:
8264 @item @emph{Example}:
8265 See @code{RAND} and @code{IRAND} for examples.
8268 The Fortran 2003 standard specifies the intrinsic @code{RANDOM_SEED} to
8269 initialize the pseudo-random numbers generator and @code{RANDOM_NUMBER}
8270 to generate pseudo-random numbers. Please note that in
8271 GNU Fortran, these two sets of intrinsics (@code{RAND},
8272 @code{IRAND} and @code{SRAND} on the one hand, @code{RANDOM_NUMBER} and
8273 @code{RANDOM_SEED} on the other hand) access two independent
8274 pseudo-random number generators.
8276 @item @emph{See also}:
8277 @ref{RAND}, @ref{RANDOM_SEED}, @ref{RANDOM_NUMBER}
8284 @section @code{STAT} --- Get file status
8285 @cindex @code{STAT} intrinsic
8286 @cindex file system operations
8289 @item @emph{Description}:
8290 This function returns information about a file. No permissions are required on
8291 the file itself, but execute (search) permission is required on all of the
8292 directories in path that lead to the file.
8294 The elements that are obtained and stored in the array @code{BUFF}:
8295 @multitable @columnfractions .15 .80
8296 @item @code{buff(1)} @tab Device ID
8297 @item @code{buff(2)} @tab Inode number
8298 @item @code{buff(3)} @tab File mode
8299 @item @code{buff(4)} @tab Number of links
8300 @item @code{buff(5)} @tab Owner's uid
8301 @item @code{buff(6)} @tab Owner's gid
8302 @item @code{buff(7)} @tab ID of device containing directory entry for file (0 if not available)
8303 @item @code{buff(8)} @tab File size (bytes)
8304 @item @code{buff(9)} @tab Last access time
8305 @item @code{buff(10)} @tab Last modification time
8306 @item @code{buff(11)} @tab Last file status change time
8307 @item @code{buff(12)} @tab Preferred I/O block size (-1 if not available)
8308 @item @code{buff(13)} @tab Number of blocks allocated (-1 if not available)
8311 Not all these elements are relevant on all systems.
8312 If an element is not relevant, it is returned as 0.
8315 @item @emph{Standard}:
8319 Non-elemental subroutine
8321 @item @emph{Syntax}:
8322 @code{CALL STAT(FILE,BUFF[,STATUS])}
8324 @item @emph{Arguments}:
8325 @multitable @columnfractions .15 .80
8326 @item @var{FILE} @tab The type shall be @code{CHARACTER(*)}, a valid path within the file system.
8327 @item @var{BUFF} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
8328 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0
8329 on success and a system specific error code otherwise.
8332 @item @emph{Example}:
8335 INTEGER, DIMENSION(13) :: buff
8338 CALL STAT("/etc/passwd", buff, status)
8340 IF (status == 0) THEN
8341 WRITE (*, FMT="('Device ID:', T30, I19)") buff(1)
8342 WRITE (*, FMT="('Inode number:', T30, I19)") buff(2)
8343 WRITE (*, FMT="('File mode (octal):', T30, O19)") buff(3)
8344 WRITE (*, FMT="('Number of links:', T30, I19)") buff(4)
8345 WRITE (*, FMT="('Owner''s uid:', T30, I19)") buff(5)
8346 WRITE (*, FMT="('Owner''s gid:', T30, I19)") buff(6)
8347 WRITE (*, FMT="('Device where located:', T30, I19)") buff(7)
8348 WRITE (*, FMT="('File size:', T30, I19)") buff(8)
8349 WRITE (*, FMT="('Last access time:', T30, A19)") CTIME(buff(9))
8350 WRITE (*, FMT="('Last modification time', T30, A19)") CTIME(buff(10))
8351 WRITE (*, FMT="('Last status change time:', T30, A19)") CTIME(buff(11))
8352 WRITE (*, FMT="('Preferred block size:', T30, I19)") buff(12)
8353 WRITE (*, FMT="('No. of blocks allocated:', T30, I19)") buff(13)
8358 @item @emph{See also}:
8359 To stat an open file: @ref{FSTAT}, to stat a link: @ref{LSTAT}
8365 @section @code{SUM} --- Sum of array elements
8366 @cindex @code{SUM} intrinsic
8367 @cindex array manipulation
8369 Intrinsic implemented, documentation pending.
8372 @item @emph{Description}:
8373 @item @emph{Standard}:
8377 Transformational function
8379 @item @emph{Syntax}:
8380 @item @emph{Arguments}:
8381 @item @emph{Return value}:
8382 @item @emph{Example}:
8383 @item @emph{See also}:
8390 @section @code{SYMLNK} --- Create a symbolic link
8391 @cindex @code{SYMLNK} intrinsic
8392 @cindex file system operations
8395 @item @emph{Description}:
8396 Makes a symbolic link from file @var{PATH1} to @var{PATH2}. A null
8397 character (@code{CHAR(0)}) can be used to mark the end of the names in
8398 @var{PATH1} and @var{PATH2}; otherwise, trailing blanks in the file
8399 names are ignored. If the @var{STATUS} argument is supplied, it
8400 contains 0 on success or a nonzero error code upon return; see
8401 @code{symlink(2)}. If the system does not supply @code{symlink(2)},
8402 @code{ENOSYS} is returned.
8404 @item @emph{Standard}:
8410 @item @emph{Syntax}:
8411 @code{CALL SYMLNK(PATH1, PATH2 [, STATUS])}
8413 @item @emph{Arguments}:
8414 @multitable @columnfractions .15 .80
8415 @item @var{PATH1} @tab Shall be of default @code{CHARACTER} type.
8416 @item @var{PATH2} @tab Shall be of default @code{CHARACTER} type.
8417 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
8420 @item @emph{See also}:
8421 @ref{LINK}, @ref{UNLINK}
8428 @section @code{SYSTEM} --- Execute a shell command
8429 @cindex @code{SYSTEM} intrinsic
8432 @item @emph{Description}:
8433 Passes the command @var{COMMAND} to a shell (see @code{system(3)}). If
8434 argument @var{STATUS} is present, it contains the value returned by
8435 @code{system(3)}, which is presumably 0 if the shell command succeeded.
8436 Note that which shell is used to invoke the command is system-dependent
8437 and environment-dependent.
8439 @item @emph{Standard}:
8445 @item @emph{Syntax}:
8446 @code{CALL SYSTEM(COMMAND [, STATUS])}
8448 @item @emph{Arguments}:
8449 @multitable @columnfractions .15 .80
8450 @item @var{COMMAND} @tab Shall be of default @code{CHARACTER} type.
8451 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
8454 @item @emph{See also}:
8460 @section @code{SYSTEM_CLOCK} --- Time function
8461 @cindex @code{SYSTEM_CLOCK} intrinsic
8462 @cindex time, current
8463 @cindex current time
8465 Intrinsic implemented, documentation pending.
8468 @item @emph{Description}:
8469 @item @emph{Standard}:
8475 @item @emph{Syntax}:
8476 @item @emph{Arguments}:
8477 @item @emph{Return value}:
8478 @item @emph{Example}:
8479 @item @emph{See also}:
8485 @section @code{TAN} --- Tangent function
8486 @cindex @code{TAN} intrinsic
8487 @cindex @code{DTAN} intrinsic
8488 @cindex trigonometric functions
8491 @item @emph{Description}:
8492 @code{TAN(X)} computes the tangent of @var{X}.
8494 @item @emph{Standard}:
8500 @item @emph{Syntax}:
8501 @code{RESULT = TAN(X)}
8503 @item @emph{Arguments}:
8504 @multitable @columnfractions .15 .80
8505 @item @var{X} @tab The type shall be @code{REAL(*)}.
8508 @item @emph{Return value}:
8509 The return value is of type @code{REAL(*)}. The kind type parameter is
8510 the same as @var{X}.
8512 @item @emph{Example}:
8515 real(8) :: x = 0.165_8
8517 end program test_tan
8520 @item @emph{Specific names}:
8521 @multitable @columnfractions .20 .20 .20 .40
8522 @item Name @tab Argument @tab Return type @tab Standard
8523 @item @code{DTAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
8526 @item @emph{See also}:
8533 @section @code{TANH} --- Hyperbolic tangent function
8534 @cindex @code{TANH} intrinsic
8535 @cindex @code{DTANH} intrinsic
8536 @cindex hyperbolic tangent
8539 @item @emph{Description}:
8540 @code{TANH(X)} computes the hyperbolic tangent of @var{X}.
8542 @item @emph{Standard}:
8548 @item @emph{Syntax}:
8551 @item @emph{Arguments}:
8552 @multitable @columnfractions .15 .80
8553 @item @var{X} @tab The type shall be @code{REAL(*)}.
8556 @item @emph{Return value}:
8557 The return value is of type @code{REAL(*)} and lies in the range
8558 @math{ - 1 \leq tanh(x) \leq 1 }.
8560 @item @emph{Example}:
8563 real(8) :: x = 2.1_8
8565 end program test_tanh
8568 @item @emph{Specific names}:
8569 @multitable @columnfractions .20 .20 .20 .40
8570 @item Name @tab Argument @tab Return type @tab Standard
8571 @item @code{DTANH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
8574 @item @emph{See also}:
8581 @section @code{TIME} --- Time function
8582 @cindex @code{TIME} intrinsic
8583 @cindex time, current
8584 @cindex current time
8587 @item @emph{Description}:
8588 Returns the current time encoded as an integer (in the manner of the
8589 UNIX function @code{time(3)}). This value is suitable for passing to
8590 @code{CTIME()}, @code{GMTIME()}, and @code{LTIME()}.
8592 This intrinsic is not fully portable, such as to systems with 32-bit
8593 @code{INTEGER} types but supporting times wider than 32 bits. Therefore,
8594 the values returned by this intrinsic might be, or become, negative, or
8595 numerically less than previous values, during a single run of the
8598 See @ref{TIME8}, for information on a similar intrinsic that might be
8599 portable to more GNU Fortran implementations, though to fewer Fortran
8602 @item @emph{Standard}:
8606 Non-elemental function
8608 @item @emph{Syntax}:
8609 @code{RESULT = TIME()}
8611 @item @emph{Return value}:
8612 The return value is a scalar of type @code{INTEGER(4)}.
8614 @item @emph{See also}:
8615 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{TIME8}
8622 @section @code{TIME8} --- Time function (64-bit)
8623 @cindex @code{TIME8} intrinsic
8624 @cindex time, current
8625 @cindex current time
8628 @item @emph{Description}:
8629 Returns the current time encoded as an integer (in the manner of the
8630 UNIX function @code{time(3)}). This value is suitable for passing to
8631 @code{CTIME()}, @code{GMTIME()}, and @code{LTIME()}.
8633 @emph{Warning:} this intrinsic does not increase the range of the timing
8634 values over that returned by @code{time(3)}. On a system with a 32-bit
8635 @code{time(3)}, @code{TIME8()} will return a 32-bit value, even though
8636 it is converted to a 64-bit @code{INTEGER(8)} value. That means
8637 overflows of the 32-bit value can still occur. Therefore, the values
8638 returned by this intrinsic might be or become negative or numerically
8639 less than previous values during a single run of the compiled program.
8641 @item @emph{Standard}:
8645 Non-elemental function
8647 @item @emph{Syntax}:
8648 @code{RESULT = TIME8()}
8650 @item @emph{Return value}:
8651 The return value is a scalar of type @code{INTEGER(8)}.
8653 @item @emph{See also}:
8654 @ref{CTIME}, @ref{GMTIME}, @ref{LTIME}, @ref{TIME}
8661 @section @code{TINY} --- Smallest positive number of a real kind
8662 @cindex @code{TINY} intrinsic
8666 @item @emph{Description}:
8667 @code{TINY(X)} returns the smallest positive (non zero) number
8668 in the model of the type of @code{X}.
8670 @item @emph{Standard}:
8676 @item @emph{Syntax}:
8677 @code{RESULT = TINY(X)}
8679 @item @emph{Arguments}:
8680 @multitable @columnfractions .15 .80
8681 @item @var{X} @tab shall be of type @code{REAL}.
8684 @item @emph{Return value}:
8685 The return value is of the same type and kind as @var{X}
8687 @item @emph{Example}:
8688 See @code{HUGE} for an example.
8694 @section @code{TRANSFER} --- Transfer bit patterns
8695 @cindex @code{TRANSFER} intrinsic
8696 @cindex bit operations
8698 Intrinsic implemented, documentation pending.
8701 @item @emph{Description}:
8702 @item @emph{Standard}:
8706 Transformational function
8708 @item @emph{Syntax}:
8709 @item @emph{Arguments}:
8710 @item @emph{Return value}:
8711 @item @emph{Example}:
8712 @item @emph{See also}:
8718 @section @code{TRANSPOSE} --- Transpose an array of rank two
8719 @cindex @code{TRANSPOSE} intrinsic
8720 @cindex matrix manipulation
8722 Intrinsic implemented, documentation pending.
8725 @item @emph{Description}:
8726 @item @emph{Standard}:
8730 Transformational function
8732 @item @emph{Syntax}:
8733 @item @emph{Arguments}:
8734 @item @emph{Return value}:
8735 @item @emph{Example}:
8736 @item @emph{See also}:
8742 @section @code{TRIM} --- Function to remove trailing blank characters of a string
8743 @cindex @code{TRIM} intrinsic
8744 @cindex string manipulation
8746 Intrinsic implemented, documentation pending.
8749 @item @emph{Description}:
8750 @item @emph{Standard}:
8754 Transformational function
8756 @item @emph{Syntax}:
8757 @item @emph{Arguments}:
8758 @item @emph{Return value}:
8759 @item @emph{Example}:
8760 @item @emph{See also}:
8766 @section @code{UBOUND} --- Upper dimension bounds of an array
8767 @cindex @code{UBOUND} intrinsic
8770 @item @emph{Description}:
8771 Returns the upper bounds of an array, or a single upper bound
8772 along the @var{DIM} dimension.
8773 @item @emph{Standard}:
8779 @item @emph{Syntax}:
8780 @code{RESULT = UBOUND(ARRAY [, DIM])}
8782 @item @emph{Arguments}:
8783 @multitable @columnfractions .15 .80
8784 @item @var{ARRAY} @tab Shall be an array, of any type.
8785 @item @var{DIM} @tab (Optional) Shall be a scalar @code{INTEGER(*)}.
8788 @item @emph{Return value}:
8789 If @var{DIM} is absent, the result is an array of the upper bounds of
8790 @var{ARRAY}. If @var{DIM} is present, the result is a scalar
8791 corresponding to the upper bound of the array along that dimension. If
8792 @var{ARRAY} is an expression rather than a whole array or array
8793 structure component, or if it has a zero extent along the relevant
8794 dimension, the upper bound is taken to be the number of elements along
8795 the relevant dimension.
8797 @item @emph{See also}:
8804 @section @code{UMASK} --- Set the file creation mask
8805 @cindex @code{UMASK} intrinsic
8806 @cindex file system operations
8809 @item @emph{Description}:
8810 Sets the file creation mask to @var{MASK} and returns the old value in
8811 argument @var{OLD} if it is supplied. See @code{umask(2)}.
8813 @item @emph{Standard}:
8819 @item @emph{Syntax}:
8820 @code{CALL UMASK(MASK [, OLD])}
8822 @item @emph{Arguments}:
8823 @multitable @columnfractions .15 .80
8824 @item @var{MASK} @tab Shall be a scalar of type @code{INTEGER(*)}.
8825 @item @var{MASK} @tab (Optional) Shall be a scalar of type
8834 @section @code{UNLINK} --- Remove a file from the file system
8835 @cindex @code{UNLINK} intrinsic
8836 @cindex file system operations
8839 @item @emph{Description}:
8840 Unlinks the file @var{PATH}. A null character (@code{CHAR(0)}) can be
8841 used to mark the end of the name in @var{PATH}; otherwise, trailing
8842 blanks in the file name are ignored. If the @var{STATUS} argument is
8843 supplied, it contains 0 on success or a nonzero error code upon return;
8844 see @code{unlink(2)}.
8846 @item @emph{Standard}:
8852 @item @emph{Syntax}:
8853 @code{CALL UNLINK(PATH [, STATUS])}
8855 @item @emph{Arguments}:
8856 @multitable @columnfractions .15 .80
8857 @item @var{PATH} @tab Shall be of default @code{CHARACTER} type.
8858 @item @var{STATUS} @tab (Optional) Shall be of default @code{INTEGER} type.
8861 @item @emph{See also}:
8862 @ref{LINK}, @ref{SYMLNK}
8868 @section @code{UNPACK} --- Unpack an array of rank one into an array
8869 @cindex @code{UNPACK} intrinsic
8870 @cindex array manipulation
8872 Intrinsic implemented, documentation pending.
8875 @item @emph{Description}:
8876 @item @emph{Standard}:
8880 Transformational function
8882 @item @emph{Syntax}:
8883 @item @emph{Arguments}:
8884 @item @emph{Return value}:
8885 @item @emph{Example}:
8887 @item @emph{See also}:
8894 @section @code{VERIFY} --- Scan a string for the absence of a set of characters
8895 @cindex @code{VERIFY} intrinsic
8896 @cindex string manipulation
8898 Intrinsic implemented, documentation pending.
8901 @item @emph{Description}:
8902 @item @emph{Standard}:
8908 @item @emph{Syntax}:
8909 @item @emph{Arguments}:
8910 @item @emph{Return value}:
8911 @item @emph{Example}:
8912 @item @emph{Specific names}:
8913 @item @emph{See also}:
8919 @section @code{XOR} --- Bitwise logical exclusive OR
8920 @cindex @code{XOR} intrinsic
8921 @cindex bit operations
8924 @item @emph{Description}:
8925 Bitwise logical exclusive or.
8927 This intrinsic routine is provided for backwards compatibility with
8928 GNU Fortran 77. For integer arguments, programmers should consider
8929 the use of the @ref{IEOR} intrinsic defined by the Fortran standard.
8931 @item @emph{Standard}:
8935 Non-elemental function
8937 @item @emph{Syntax}:
8938 @code{RESULT = XOR(X, Y)}
8940 @item @emph{Arguments}:
8941 @multitable @columnfractions .15 .80
8942 @item @var{X} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
8943 @item @var{Y} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
8946 @item @emph{Return value}:
8947 The return type is either @code{INTEGER(*)} or @code{LOGICAL}
8948 after cross-promotion of the arguments.
8950 @item @emph{Example}:
8953 LOGICAL :: T = .TRUE., F = .FALSE.
8955 DATA a / Z,'F' /, b / Z'3' /
8957 WRITE (*,*) XOR(T, T), XOR(T, F), XOR(F, T), XOR(F, F)
8958 WRITE (*,*) XOR(a, b)
8962 @item @emph{See also}:
8963 F95 elemental function: @ref{IEOR}