2 Copyright (C) 2005, 2006
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 use.
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
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{TINY}: TINY, Smallest positive number of a real kind
242 * @code{TRANSFER}: TRANSFER, Transfer bit patterns
243 * @code{TRANSPOSE}: TRANSPOSE, Transpose an array of rank two
244 * @code{TRIM}: TRIM, Function to remove trailing blank characters of a string
245 * @code{UBOUND}: UBOUND, Upper dimension bounds of an array
246 * @code{UMASK}: UMASK, Set the file creation mask
247 * @code{UNLINK}: UNLINK, Remove a file from the file system
248 * @code{UNMASK}: UNMASK, (?)
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
255 @section Introduction to intrinsic procedures
257 GNU Fortran provides a rich set of intrinsic procedures that includes all
258 the intrinsic procedures required by the Fortran 95 standard, a set of
259 intrinsic procedures for backwards compatibility with Gnu Fortran 77
260 (i.e., @command{g77}), and a small selection of intrinsic procedures
261 from the Fortran 2003 standard. Any description here, which conflicts with a
262 description in either the Fortran 95 standard or the Fortran 2003 standard,
263 is unintentional and 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 intrinsics 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 option(s) is noted.
296 @section @code{ABORT} --- Abort the program
297 @findex @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}
334 @section @code{ABS} --- Absolute value
335 @findex @code{ABS} intrinsic
336 @findex @code{CABS} intrinsic
337 @findex @code{DABS} intrinsic
338 @findex @code{IABS} intrinsic
339 @findex @code{ZABS} intrinsic
340 @findex @code{CDABS} intrinsic
341 @cindex absolute value
344 @item @emph{Description}:
345 @code{ABS(X)} computes the absolute value of @code{X}.
347 @item @emph{Standard}:
348 F77 and later, has overloads that are GNU extensions
356 @item @emph{Arguments}:
357 @multitable @columnfractions .15 .80
358 @item @var{X} @tab The type of the argument shall be an @code{INTEGER(*)},
359 @code{REAL(*)}, or @code{COMPLEX(*)}.
362 @item @emph{Return value}:
363 The return value is of the same type and
364 kind as the argument except the return value is @code{REAL(*)} for a
365 @code{COMPLEX(*)} argument.
367 @item @emph{Example}:
372 complex :: z = (-1.e0,0.e0)
379 @item @emph{Specific names}:
380 @multitable @columnfractions .20 .20 .20 .40
381 @item Name @tab Argument @tab Return type @tab Standard
382 @item @code{CABS(Z)} @tab @code{COMPLEX(4) Z} @tab @code{REAL(4)} @tab F77 and later
383 @item @code{DABS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
384 @item @code{IABS(I)} @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)} @tab F77 and later
385 @item @code{ZABS(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
386 @item @code{CDABS(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
392 @section @code{ACCESS} --- Checks file access modes
393 @findex @code{ACCESS}
394 @cindex file system functions
397 @item @emph{Description}:
398 @code{ACCESS(NAME, MODE)} checks whether the file @var{NAME}
399 exists, is readable, writable or executable. Except for the
400 executable check, @code{ACCESS} can be replaced by
401 Fortran 95's @code{INQUIRE}.
403 @item @emph{Standard}:
410 @code{I = ACCESS(NAME, MODE)}
412 @item @emph{Arguments}:
413 @multitable @columnfractions .15 .80
414 @item @var{NAME} @tab Scalar @code{CHARACTER} with the file name.
415 Tailing blank are ignored unless the character @code{achar(0)} is
416 present, then all characters up to and excluding @code{achar(0)} are
418 @item @var{MODE} @tab Scalar @code{CHARACTER} with the file access mode,
419 may be any concatenation of @code{"r"} (readable), @code{"w"} (writable)
420 and @code{"x"} (executable), or @code{" "} to check for existence.
423 @item @emph{Return value}:
424 Returns a scalar @code{INTEGER}, which is @code{0} if the file is
425 accessable in the given mode; otherwise or if an invalid argument
426 has been given for @code{MODE} the value @code{1} is returned.
428 @item @emph{Example}:
432 character(len=*), parameter :: file = 'test.dat'
433 character(len=*), parameter :: file2 = 'test.dat '//achar(0)
434 if(access(file,' ') == 0) print *, trim(file),' is exists'
435 if(access(file,'r') == 0) print *, trim(file),' is readable'
436 if(access(file,'w') == 0) print *, trim(file),' is writable'
437 if(access(file,'x') == 0) print *, trim(file),' is executable'
438 if(access(file2,'rwx') == 0) &
439 print *, trim(file2),' is readable, writable and executable'
440 end program access_test
442 @item @emph{Specific names}:
443 @item @emph{See also}:
449 @section @code{ACHAR} --- Character in @acronym{ASCII} collating sequence
450 @findex @code{ACHAR} intrinsic
451 @cindex @acronym{ASCII} collating sequence
454 @item @emph{Description}:
455 @code{ACHAR(I)} returns the character located at position @code{I}
456 in the @acronym{ASCII} collating sequence.
458 @item @emph{Standard}:
467 @item @emph{Arguments}:
468 @multitable @columnfractions .15 .80
469 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
472 @item @emph{Return value}:
473 The return value is of type @code{CHARACTER} with a length of one. The
474 kind type parameter is the same as @code{KIND('A')}.
476 @item @emph{Example}:
481 end program test_achar
488 @section @code{ACOS} --- Arccosine function
489 @findex @code{ACOS} intrinsic
490 @findex @code{DACOS} intrinsic
491 @cindex trigonometric functions (inverse)
494 @item @emph{Description}:
495 @code{ACOS(X)} computes the arccosine of @var{X} (inverse of @code{COS(X)}).
497 @item @emph{Standard}:
506 @item @emph{Arguments}:
507 @multitable @columnfractions .15 .80
508 @item @var{X} @tab The type shall be @code{REAL(*)} with a magnitude that is
512 @item @emph{Return value}:
513 The return value is of type @code{REAL(*)} and it lies in the
514 range @math{ 0 \leq \acos(x) \leq \pi}. The kind type parameter
515 is the same as @var{X}.
517 @item @emph{Example}:
520 real(8) :: x = 0.866_8
522 end program test_acos
525 @item @emph{Specific names}:
526 @multitable @columnfractions .20 .20 .20 .40
527 @item Name @tab Argument @tab Return type @tab Standard
528 @item @code{DACOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
531 @item @emph{See also}:
532 Inverse function: @ref{COS}
538 @section @code{ACOSH} --- Hyperbolic arccosine function
539 @findex @code{ACOSH} intrinsic
540 @cindex hyperbolic arccosine
541 @cindex hyperbolic cosine (inverse)
544 @item @emph{Description}:
545 @code{ACOSH(X)} computes the area hyperbolic cosine of @var{X} (inverse of @code{COSH(X)}).
547 @item @emph{Standard}:
556 @item @emph{Arguments}:
557 @multitable @columnfractions .15 .80
558 @item @var{X} @tab The type shall be @code{REAL(*)} with a magnitude that is
559 greater or equal to one.
562 @item @emph{Return value}:
563 The return value is of type @code{REAL(*)} and it lies in the
564 range @math{0 \leq \acosh (x) \leq \infty}.
566 @item @emph{Example}:
569 REAL(8), DIMENSION(3) :: x = (/ 1.0, 2.0, 3.0 /)
574 @item @emph{See also}:
575 Inverse function: @ref{COSH}
581 @section @code{ADJUSTL} --- Left adjust a string
582 @findex @code{ADJUSTL} intrinsic
583 @cindex adjust string
586 @item @emph{Description}:
587 @code{ADJUSTL(STR)} will left adjust a string by removing leading spaces.
588 Spaces are inserted at the end of the string as needed.
590 @item @emph{Standard}:
597 @code{STR = ADJUSTL(STR)}
599 @item @emph{Arguments}:
600 @multitable @columnfractions .15 .80
601 @item @var{STR} @tab The type shall be @code{CHARACTER}.
604 @item @emph{Return value}:
605 The return value is of type @code{CHARACTER} where leading spaces
606 are removed and the same number of spaces are inserted on the end
609 @item @emph{Example}:
612 character(len=20) :: str = ' gfortran'
615 end program test_adjustl
622 @section @code{ADJUSTR} --- Right adjust a string
623 @findex @code{ADJUSTR} intrinsic
624 @cindex adjust string
627 @item @emph{Description}:
628 @code{ADJUSTR(STR)} will right adjust a string by removing trailing spaces.
629 Spaces are inserted at the start of the string as needed.
631 @item @emph{Standard}:
638 @code{STR = ADJUSTR(STR)}
640 @item @emph{Arguments}:
641 @multitable @columnfractions .15 .80
642 @item @var{STR} @tab The type shall be @code{CHARACTER}.
645 @item @emph{Return value}:
646 The return value is of type @code{CHARACTER} where trailing spaces
647 are removed and the same number of spaces are inserted at the start
650 @item @emph{Example}:
653 character(len=20) :: str = 'gfortran'
656 end program test_adjustr
663 @section @code{AIMAG} --- Imaginary part of complex number
664 @findex @code{AIMAG} intrinsic
665 @findex @code{DIMAG} intrinsic
666 @findex @code{IMAG} intrinsic
667 @findex @code{IMAGPART} intrinsic
668 @cindex Imaginary part
671 @item @emph{Description}:
672 @code{AIMAG(Z)} yields the imaginary part of complex argument @code{Z}.
673 The @code{IMAG(Z)} and @code{IMAGPART(Z)} intrinsic functions are provided
674 for compatibility with @command{g77}, and their use in new code is
675 strongly discouraged.
677 @item @emph{Standard}:
678 F77 and later, has overloads that are GNU extensions
686 @item @emph{Arguments}:
687 @multitable @columnfractions .15 .80
688 @item @var{Z} @tab The type of the argument shall be @code{COMPLEX(*)}.
691 @item @emph{Return value}:
692 The return value is of type real with the
693 kind type parameter of the argument.
695 @item @emph{Example}:
700 z4 = cmplx(1.e0_4, 0.e0_4)
701 z8 = cmplx(0.e0_8, 1.e0_8)
702 print *, aimag(z4), dimag(z8)
703 end program test_aimag
706 @item @emph{Specific names}:
707 @multitable @columnfractions .20 .20 .20 .40
708 @item Name @tab Argument @tab Return type @tab Standard
709 @item @code{DIMAG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{REAL(8)} @tab GNU extension
710 @item @code{IMAG(Z)} @tab @code{COMPLEX(*) Z} @tab @code{REAL(*)} @tab GNU extension
711 @item @code{IMAGPART(Z)} @tab @code{COMPLEX(*) Z} @tab @code{REAL(*)} @tab GNU extension
718 @section @code{AINT} --- Truncate to a whole number
719 @findex @code{AINT} intrinsic
720 @findex @code{DINT} intrinsic
724 @item @emph{Description}:
725 @code{AINT(X [, KIND])} truncates its argument to a whole number.
727 @item @emph{Standard}:
735 @code{X = AINT(X, KIND)}
737 @item @emph{Arguments}:
738 @multitable @columnfractions .15 .80
739 @item @var{X} @tab The type of the argument shall be @code{REAL(*)}.
740 @item @var{KIND} @tab (Optional) @var{KIND} shall be a scalar integer
741 initialization expression.
744 @item @emph{Return value}:
745 The return value is of type real with the kind type parameter of the
746 argument if the optional @var{KIND} is absent; otherwise, the kind
747 type parameter will be given by @var{KIND}. If the magnitude of
748 @var{X} is less than one, then @code{AINT(X)} returns zero. If the
749 magnitude is equal to or greater than one, then it returns the largest
750 whole number that does not exceed its magnitude. The sign is the same
751 as the sign of @var{X}.
753 @item @emph{Example}:
760 print *, aint(x4), dint(x8)
762 end program test_aint
765 @item @emph{Specific names}:
766 @multitable @columnfractions .20 .20 .20 .40
767 @item Name @tab Argument @tab Return type @tab Standard
768 @item @code{DINT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
775 @section @code{ALARM} --- Execute a routine after a given delay
776 @findex @code{ALARM} intrinsic
779 @item @emph{Description}:
780 @code{ALARM(SECONDS, HANDLER [, STATUS])} causes external subroutine @var{HANDLER}
781 to be executed after a delay of @var{SECONDS} by using @code{alarm(1)} to
782 set up a signal and @code{signal(2)} to catch it. If @var{STATUS} is
783 supplied, it will be returned with the number of seconds remaining until
784 any previously scheduled alarm was due to be delivered, or zero if there
785 was no previously scheduled alarm.
787 @item @emph{Standard}:
794 @code{CALL ALARM(SECONDS, HANDLER)}
795 @code{CALL ALARM(SECONDS, HANDLER, STATUS)}
797 @item @emph{Arguments}:
798 @multitable @columnfractions .15 .80
799 @item @var{SECONDS} @tab The type of the argument shall be a scalar
800 @code{INTEGER}. It is @code{INTENT(IN)}.
801 @item @var{HANDLER} @tab Signal handler (@code{INTEGER FUNCTION} or
802 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar.
803 @code{INTEGER}. It is @code{INTENT(IN)}.
804 @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
805 @code{INTEGER} variable. It is @code{INTENT(OUT)}.
808 @item @emph{Example}:
811 external handler_print
813 call alarm (3, handler_print, i)
816 end program test_alarm
818 This will cause the external routine @var{handler_print} to be called
825 @section @code{ALL} --- All values in @var{MASK} along @var{DIM} are true
826 @findex @code{ALL} intrinsic
830 @item @emph{Description}:
831 @code{ALL(MASK [, DIM])} determines if all the values are true in @var{MASK}
832 in the array along dimension @var{DIM}.
834 @item @emph{Standard}:
838 transformational function
842 @code{L = ALL(MASK, DIM)}
844 @item @emph{Arguments}:
845 @multitable @columnfractions .15 .80
846 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL(*)} and
847 it shall not be scalar.
848 @item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer
849 with a value that lies between one and the rank of @var{MASK}.
852 @item @emph{Return value}:
853 @code{ALL(MASK)} returns a scalar value of type @code{LOGICAL(*)} where
854 the kind type parameter is the same as the kind type parameter of
855 @var{MASK}. If @var{DIM} is present, then @code{ALL(MASK, DIM)} returns
856 an array with the rank of @var{MASK} minus 1. The shape is determined from
857 the shape of @var{MASK} where the @var{DIM} dimension is elided.
861 @code{ALL(MASK)} is true if all elements of @var{MASK} are true.
862 It also is true if @var{MASK} has zero size; otherwise, it is false.
864 If the rank of @var{MASK} is one, then @code{ALL(MASK,DIM)} is equivalent
865 to @code{ALL(MASK)}. If the rank is greater than one, then @code{ALL(MASK,DIM)}
866 is determined by applying @code{ALL} to the array sections.
869 @item @emph{Example}:
873 l = all((/.true., .true., .true./))
878 integer a(2,3), b(2,3)
882 print *, all(a .eq. b, 1)
883 print *, all(a .eq. b, 2)
884 end subroutine section
892 @section @code{ALLOCATED} --- Status of an allocatable entity
893 @findex @code{ALLOCATED} intrinsic
894 @cindex allocation status
897 @item @emph{Description}:
898 @code{ALLOCATED(X)} checks the status of whether @var{X} is allocated.
900 @item @emph{Standard}:
907 @code{L = ALLOCATED(X)}
909 @item @emph{Arguments}:
910 @multitable @columnfractions .15 .80
911 @item @var{X} @tab The argument shall be an @code{ALLOCATABLE} array.
914 @item @emph{Return value}:
915 The return value is a scalar @code{LOGICAL} with the default logical
916 kind type parameter. If @var{X} is allocated, @code{ALLOCATED(X)}
917 is @code{.TRUE.}; otherwise, it returns the @code{.TRUE.}
919 @item @emph{Example}:
921 program test_allocated
923 real(4), allocatable :: x(:)
924 if (allocated(x) .eqv. .false.) allocate(x(i))
925 end program test_allocated
931 @section @code{AND} --- Bitwise logical AND
932 @findex @code{AND} intrinsic
933 @cindex bit operations
936 @item @emph{Description}:
937 Bitwise logical @code{AND}.
939 This intrinsic routine is provided for backwards compatibility with
940 GNU Fortran 77. For integer arguments, programmers should consider
941 the use of the @ref{IAND} intrinsic defined by the Fortran standard.
943 @item @emph{Standard}:
947 Non-elemental function
950 @code{RESULT = AND(X, Y)}
952 @item @emph{Arguments}:
953 @multitable @columnfractions .15 .80
954 @item @var{X} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
955 @item @var{Y} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
958 @item @emph{Return value}:
959 The return type is either @code{INTEGER(*)} or @code{LOGICAL} after
960 cross-promotion of the arguments.
962 @item @emph{Example}:
965 LOGICAL :: T = .TRUE., F = ..FALSE.
967 DATA a / Z'F' /, b / Z'3' /
969 WRITE (*,*) AND(T, T), AND(T, F), AND(F, T), AND(F, F)
970 WRITE (*,*) AND(a, b)
974 @item @emph{See also}:
975 F95 elemental function: @ref{IAND}
981 @section @code{ANINT} --- Nearest whole number
982 @findex @code{ANINT} intrinsic
983 @findex @code{DNINT} intrinsic
987 @item @emph{Description}:
988 @code{ANINT(X [, KIND])} rounds its argument to the nearest whole number.
990 @item @emph{Standard}:
998 @code{X = ANINT(X, KIND)}
1000 @item @emph{Arguments}:
1001 @multitable @columnfractions .15 .80
1002 @item @var{X} @tab The type of the argument shall be @code{REAL(*)}.
1003 @item @var{KIND} @tab (Optional) @var{KIND} shall be a scalar integer
1004 initialization expression.
1007 @item @emph{Return value}:
1008 The return value is of type real with the kind type parameter of the
1009 argument if the optional @var{KIND} is absent; otherwise, the kind
1010 type parameter will be given by @var{KIND}. If @var{X} is greater than
1011 zero, then @code{ANINT(X)} returns @code{AINT(X+0.5)}. If @var{X} is
1012 less than or equal to zero, then it returns @code{AINT(X-0.5)}.
1014 @item @emph{Example}:
1021 print *, anint(x4), dnint(x8)
1023 end program test_anint
1026 @item @emph{Specific names}:
1027 @multitable @columnfractions .20 .20 .20 .40
1028 @item Name @tab Argument @tab Return type @tab Standard
1029 @item @code{DNINT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1036 @section @code{ANY} --- Any value in @var{MASK} along @var{DIM} is true
1037 @findex @code{ANY} intrinsic
1041 @item @emph{Description}:
1042 @code{ANY(MASK [, DIM])} determines if any of the values in the logical array
1043 @var{MASK} along dimension @var{DIM} are @code{.TRUE.}.
1045 @item @emph{Standard}:
1049 transformational function
1051 @item @emph{Syntax}:
1052 @code{L = ANY(MASK)}
1053 @code{L = ANY(MASK, DIM)}
1055 @item @emph{Arguments}:
1056 @multitable @columnfractions .15 .80
1057 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL(*)} and
1058 it shall not be scalar.
1059 @item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer
1060 with a value that lies between one and the rank of @var{MASK}.
1063 @item @emph{Return value}:
1064 @code{ANY(MASK)} returns a scalar value of type @code{LOGICAL(*)} where
1065 the kind type parameter is the same as the kind type parameter of
1066 @var{MASK}. If @var{DIM} is present, then @code{ANY(MASK, DIM)} returns
1067 an array with the rank of @var{MASK} minus 1. The shape is determined from
1068 the shape of @var{MASK} where the @var{DIM} dimension is elided.
1072 @code{ANY(MASK)} is true if any element of @var{MASK} is true;
1073 otherwise, it is false. It also is false if @var{MASK} has zero size.
1075 If the rank of @var{MASK} is one, then @code{ANY(MASK,DIM)} is equivalent
1076 to @code{ANY(MASK)}. If the rank is greater than one, then @code{ANY(MASK,DIM)}
1077 is determined by applying @code{ANY} to the array sections.
1080 @item @emph{Example}:
1084 l = any((/.true., .true., .true./))
1089 integer a(2,3), b(2,3)
1093 print *, any(a .eq. b, 1)
1094 print *, any(a .eq. b, 2)
1095 end subroutine section
1096 end program test_any
1103 @section @code{ASIN} --- Arcsine function
1104 @findex @code{ASIN} intrinsic
1105 @findex @code{DASIN} intrinsic
1106 @cindex trigonometric functions (inverse)
1109 @item @emph{Description}:
1110 @code{ASIN(X)} computes the arcsine of its @var{X} (inverse of @code{SIN(X)}).
1112 @item @emph{Standard}:
1118 @item @emph{Syntax}:
1121 @item @emph{Arguments}:
1122 @multitable @columnfractions .15 .80
1123 @item @var{X} @tab The type shall be @code{REAL(*)}, and a magnitude that is
1127 @item @emph{Return value}:
1128 The return value is of type @code{REAL(*)} and it lies in the
1129 range @math{-\pi / 2 \leq \asin (x) \leq \pi / 2}. The kind type
1130 parameter is the same as @var{X}.
1132 @item @emph{Example}:
1135 real(8) :: x = 0.866_8
1137 end program test_asin
1140 @item @emph{Specific names}:
1141 @multitable @columnfractions .20 .20 .20 .40
1142 @item Name @tab Argument @tab Return type @tab Standard
1143 @item @code{DASIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1146 @item @emph{See also}:
1147 Inverse function: @ref{SIN}
1153 @section @code{ASINH} --- Hyperbolic arcsine function
1154 @findex @code{ASINH} intrinsic
1155 @cindex hyperbolic arcsine
1156 @cindex hyperbolic sine (inverse)
1159 @item @emph{Description}:
1160 @code{ASINH(X)} computes the area hyperbolic sine of @var{X} (inverse of @code{SINH(X)}).
1162 @item @emph{Standard}:
1168 @item @emph{Syntax}:
1171 @item @emph{Arguments}:
1172 @multitable @columnfractions .15 .80
1173 @item @var{X} @tab The type shall be @code{REAL(*)}, with @var{X} a real number.
1176 @item @emph{Return value}:
1177 The return value is of type @code{REAL(*)} and it lies in the
1178 range @math{-\infty \leq \asinh (x) \leq \infty}.
1180 @item @emph{Example}:
1183 REAL(8), DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1184 WRITE (*,*) ASINH(x)
1188 @item @emph{See also}:
1189 Inverse function: @ref{SINH}
1195 @section @code{ASSOCIATED} --- Status of a pointer or pointer/target pair
1196 @findex @code{ASSOCIATED} intrinsic
1197 @cindex pointer status
1200 @item @emph{Description}:
1201 @code{ASSOCIATED(PTR [, TGT])} determines the status of the pointer @var{PTR}
1202 or if @var{PTR} is associated with the target @var{TGT}.
1204 @item @emph{Standard}:
1210 @item @emph{Syntax}:
1211 @code{L = ASSOCIATED(PTR)}
1212 @code{L = ASSOCIATED(PTR [, TGT])}
1214 @item @emph{Arguments}:
1215 @multitable @columnfractions .15 .80
1216 @item @var{PTR} @tab @var{PTR} shall have the @code{POINTER} attribute and
1217 it can be of any type.
1218 @item @var{TGT} @tab (Optional) @var{TGT} shall be a @code{POINTER} or
1219 a @code{TARGET}. It must have the same type, kind type parameter, and
1220 array rank as @var{PTR}.
1222 The status of neither @var{PTR} nor @var{TGT} can be undefined.
1224 @item @emph{Return value}:
1225 @code{ASSOCIATED(PTR)} returns a scalar value of type @code{LOGICAL(4)}.
1226 There are several cases:
1228 @item (A) If the optional @var{TGT} is not present, then @code{ASSOCIATED(PTR)}
1229 is true if @var{PTR} is associated with a target; otherwise, it returns false.
1230 @item (B) If @var{TGT} is present and a scalar target, the result is true if
1232 is not a 0 sized storage sequence and the target associated with @var{PTR}
1233 occupies the same storage units. If @var{PTR} is disassociated, then the
1235 @item (C) If @var{TGT} is present and an array target, the result is true if
1236 @var{TGT} and @var{PTR} have the same shape, are not 0 sized arrays, are
1237 arrays whose elements are not 0 sized storage sequences, and @var{TGT} and
1238 @var{PTR} occupy the same storage units in array element order.
1239 As in case(B), the result is false, if @var{PTR} is disassociated.
1240 @item (D) If @var{TGT} is present and an scalar pointer, the result is true if
1241 target associated with @var{PTR} and the target associated with @var{TGT}
1242 are not 0 sized storage sequences and occupy the same storage units.
1243 The result is false, if either @var{TGT} or @var{PTR} is disassociated.
1244 @item (E) If @var{TGT} is present and an array pointer, the result is true if
1245 target associated with @var{PTR} and the target associated with @var{TGT}
1246 have the same shape, are not 0 sized arrays, are arrays whose elements are
1247 not 0 sized storage sequences, and @var{TGT} and @var{PTR} occupy the same
1248 storage units in array element order.
1249 The result is false, if either @var{TGT} or @var{PTR} is disassociated.
1252 @item @emph{Example}:
1254 program test_associated
1256 real, target :: tgt(2) = (/1., 2./)
1257 real, pointer :: ptr(:)
1259 if (associated(ptr) .eqv. .false.) call abort
1260 if (associated(ptr,tgt) .eqv. .false.) call abort
1261 end program test_associated
1264 @item @emph{See also}:
1271 @section @code{ATAN} --- Arctangent function
1272 @findex @code{ATAN} intrinsic
1273 @findex @code{DATAN} intrinsic
1274 @cindex trigonometric functions (inverse)
1277 @item @emph{Description}:
1278 @code{ATAN(X)} computes the arctangent of @var{X}.
1280 @item @emph{Standard}:
1286 @item @emph{Syntax}:
1289 @item @emph{Arguments}:
1290 @multitable @columnfractions .15 .80
1291 @item @var{X} @tab The type shall be @code{REAL(*)}.
1294 @item @emph{Return value}:
1295 The return value is of type @code{REAL(*)} and it lies in the
1296 range @math{ - \pi / 2 \leq \atan (x) \leq \pi / 2}.
1298 @item @emph{Example}:
1301 real(8) :: x = 2.866_8
1303 end program test_atan
1306 @item @emph{Specific names}:
1307 @multitable @columnfractions .20 .20 .20 .40
1308 @item Name @tab Argument @tab Return type @tab Standard
1309 @item @code{DATAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1312 @item @emph{See also}:
1313 Inverse function: @ref{TAN}
1320 @section @code{ATAN2} --- Arctangent function
1321 @findex @code{ATAN2} intrinsic
1322 @findex @code{DATAN2} intrinsic
1323 @cindex trigonometric functions (inverse)
1326 @item @emph{Description}:
1327 @code{ATAN2(Y,X)} computes the arctangent of the complex number @math{X + i Y}.
1329 @item @emph{Standard}:
1335 @item @emph{Syntax}:
1336 @code{X = ATAN2(Y,X)}
1338 @item @emph{Arguments}:
1339 @multitable @columnfractions .15 .80
1340 @item @var{Y} @tab The type shall be @code{REAL(*)}.
1341 @item @var{X} @tab The type and kind type parameter shall be the same as @var{Y}.
1342 If @var{Y} is zero, then @var{X} must be nonzero.
1345 @item @emph{Return value}:
1346 The return value has the same type and kind type parameter as @var{Y}.
1347 It is the principal value of the complex number @math{X + i Y}. If
1348 @var{X} is nonzero, then it lies in the range @math{-\pi \le \atan (x) \leq \pi}.
1349 The sign is positive if @var{Y} is positive. If @var{Y} is zero, then
1350 the return value is zero if @var{X} is positive and @math{\pi} if @var{X}
1351 is negative. Finally, if @var{X} is zero, then the magnitude of the result
1354 @item @emph{Example}:
1357 real(4) :: x = 1.e0_4, y = 0.5e0_4
1359 end program test_atan2
1362 @item @emph{Specific names}:
1363 @multitable @columnfractions .20 .20 .20 .40
1364 @item Name @tab Argument @tab Return type @tab Standard
1365 @item @code{DATAN2(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1372 @section @code{ATANH} --- Hyperbolic arctangent function
1373 @findex @code{ASINH} intrinsic
1374 @cindex hyperbolic arctangent
1375 @cindex hyperbolic tangent (inverse)
1378 @item @emph{Description}:
1379 @code{ATANH(X)} computes the area hyperbolic sine of @var{X} (inverse of @code{TANH(X)}).
1381 @item @emph{Standard}:
1387 @item @emph{Syntax}:
1390 @item @emph{Arguments}:
1391 @multitable @columnfractions .15 .80
1392 @item @var{X} @tab The type shall be @code{REAL(*)} with a magnitude that is less than or equal to one.
1395 @item @emph{Return value}:
1396 The return value is of type @code{REAL(*)} and it lies in the
1397 range @math{-\infty \leq \atanh(x) \leq \infty}.
1399 @item @emph{Example}:
1402 REAL, DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1403 WRITE (*,*) ATANH(x)
1407 @item @emph{See also}:
1408 Inverse function: @ref{TANH}
1415 @section @code{BESJ0} --- Bessel function of the first kind of order 0
1416 @findex @code{BESJ0} intrinsic
1417 @findex @code{DBESJ0} intrinsic
1421 @item @emph{Description}:
1422 @code{BESJ0(X)} computes the Bessel function of the first kind of order 0
1425 @item @emph{Standard}:
1431 @item @emph{Syntax}:
1434 @item @emph{Arguments}:
1435 @multitable @columnfractions .15 .80
1436 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1439 @item @emph{Return value}:
1440 The return value is of type @code{REAL(*)} and it lies in the
1441 range @math{ - 0.4027... \leq Bessel (0,x) \leq 1}.
1443 @item @emph{Example}:
1446 real(8) :: x = 0.0_8
1448 end program test_besj0
1451 @item @emph{Specific names}:
1452 @multitable @columnfractions .20 .20 .20 .40
1453 @item Name @tab Argument @tab Return type @tab Standard
1454 @item @code{DBESJ0(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1461 @section @code{BESJ1} --- Bessel function of the first kind of order 1
1462 @findex @code{BESJ1} intrinsic
1463 @findex @code{DBESJ1} intrinsic
1467 @item @emph{Description}:
1468 @code{BESJ1(X)} computes the Bessel function of the first kind of order 1
1471 @item @emph{Standard}:
1477 @item @emph{Syntax}:
1480 @item @emph{Arguments}:
1481 @multitable @columnfractions .15 .80
1482 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1485 @item @emph{Return value}:
1486 The return value is of type @code{REAL(*)} and it lies in the
1487 range @math{ - 0.5818... \leq Bessel (0,x) \leq 0.5818 }.
1489 @item @emph{Example}:
1492 real(8) :: x = 1.0_8
1494 end program test_besj1
1497 @item @emph{Specific names}:
1498 @multitable @columnfractions .20 .20 .20 .40
1499 @item Name @tab Argument @tab Return type @tab Standard
1500 @item @code{DBESJ1(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1507 @section @code{BESJN} --- Bessel function of the first kind
1508 @findex @code{BESJN} intrinsic
1509 @findex @code{DBESJN} intrinsic
1513 @item @emph{Description}:
1514 @code{BESJN(N, X)} computes the Bessel function of the first kind of order
1517 @item @emph{Standard}:
1523 @item @emph{Syntax}:
1524 @code{Y = BESJN(N, X)}
1526 @item @emph{Arguments}:
1527 @multitable @columnfractions .15 .80
1528 @item @var{N} @tab The type shall be @code{INTEGER(*)}, and it shall be scalar.
1529 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1532 @item @emph{Return value}:
1533 The return value is a scalar of type @code{REAL(*)}.
1535 @item @emph{Example}:
1538 real(8) :: x = 1.0_8
1540 end program test_besjn
1543 @item @emph{Specific names}:
1544 @multitable @columnfractions .20 .20 .20 .40
1545 @item Name @tab Argument @tab Return type @tab Standard
1546 @item @code{DBESJN(X)} @tab @code{INTEGER(*) N} @tab @code{REAL(8)} @tab GNU extension
1547 @item @tab @code{REAL(8) X} @tab @tab
1554 @section @code{BESY0} --- Bessel function of the second kind of order 0
1555 @findex @code{BESY0} intrinsic
1556 @findex @code{DBESY0} intrinsic
1560 @item @emph{Description}:
1561 @code{BESY0(X)} computes the Bessel function of the second kind of order 0
1564 @item @emph{Standard}:
1570 @item @emph{Syntax}:
1573 @item @emph{Arguments}:
1574 @multitable @columnfractions .15 .80
1575 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1578 @item @emph{Return value}:
1579 The return value is a scalar of type @code{REAL(*)}.
1581 @item @emph{Example}:
1584 real(8) :: x = 0.0_8
1586 end program test_besy0
1589 @item @emph{Specific names}:
1590 @multitable @columnfractions .20 .20 .20 .40
1591 @item Name @tab Argument @tab Return type @tab Standard
1592 @item @code{DBESY0(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1599 @section @code{BESY1} --- Bessel function of the second kind of order 1
1600 @findex @code{BESY1} intrinsic
1601 @findex @code{DBESY1} intrinsic
1605 @item @emph{Description}:
1606 @code{BESY1(X)} computes the Bessel function of the second kind of order 1
1609 @item @emph{Standard}:
1615 @item @emph{Syntax}:
1618 @item @emph{Arguments}:
1619 @multitable @columnfractions .15 .80
1620 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1623 @item @emph{Return value}:
1624 The return value is a scalar of type @code{REAL(*)}.
1626 @item @emph{Example}:
1629 real(8) :: x = 1.0_8
1631 end program test_besy1
1634 @item @emph{Specific names}:
1635 @multitable @columnfractions .20 .20 .20 .40
1636 @item Name @tab Argument @tab Return type @tab Standard
1637 @item @code{DBESY1(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1644 @section @code{BESYN} --- Bessel function of the second kind
1645 @findex @code{BESYN} intrinsic
1646 @findex @code{DBESYN} intrinsic
1650 @item @emph{Description}:
1651 @code{BESYN(N, X)} computes the Bessel function of the second kind of order
1654 @item @emph{Standard}:
1660 @item @emph{Syntax}:
1661 @code{Y = BESYN(N, X)}
1663 @item @emph{Arguments}:
1664 @multitable @columnfractions .15 .80
1665 @item @var{N} @tab The type shall be @code{INTEGER(*)}, and it shall be scalar.
1666 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1669 @item @emph{Return value}:
1670 The return value is a scalar of type @code{REAL(*)}.
1672 @item @emph{Example}:
1675 real(8) :: x = 1.0_8
1677 end program test_besyn
1680 @item @emph{Specific names}:
1681 @multitable @columnfractions .20 .20 .20 .40
1682 @item Name @tab Argument @tab Return type @tab Standard
1683 @item @code{DBESYN(N,X)} @tab @code{INTEGER(*) N} @tab @code{REAL(8)} @tab GNU extension
1684 @item @tab @code{REAL(8) X} @tab @tab
1691 @section @code{BIT_SIZE} --- Bit size inquiry function
1692 @findex @code{BIT_SIZE} intrinsic
1696 @item @emph{Description}:
1697 @code{BIT_SIZE(I)} returns the number of bits (integer precision plus sign bit)
1698 represented by the type of @var{I}.
1700 @item @emph{Standard}:
1706 @item @emph{Syntax}:
1707 @code{I = BIT_SIZE(I)}
1709 @item @emph{Arguments}:
1710 @multitable @columnfractions .15 .80
1711 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1714 @item @emph{Return value}:
1715 The return value is of type @code{INTEGER(*)}
1717 @item @emph{Example}:
1719 program test_bit_size
1724 end program test_bit_size
1731 @section @code{BTEST} --- Bit test function
1732 @findex @code{BTEST} intrinsic
1733 @cindex bit operations
1736 @item @emph{Description}:
1737 @code{BTEST(I,POS)} returns logical @code{.TRUE.} if the bit at @var{POS}
1740 @item @emph{Standard}:
1746 @item @emph{Syntax}:
1747 @code{I = BTEST(I,POS)}
1749 @item @emph{Arguments}:
1750 @multitable @columnfractions .15 .80
1751 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1752 @item @var{POS} @tab The type shall be @code{INTEGER(*)}.
1755 @item @emph{Return value}:
1756 The return value is of type @code{LOGICAL}
1758 @item @emph{Example}:
1761 integer :: i = 32768 + 1024 + 64
1765 bool = btest(i, pos)
1768 end program test_btest
1775 @section @code{CEILING} --- Integer ceiling function
1776 @findex @code{CEILING} intrinsic
1780 @item @emph{Description}:
1781 @code{CEILING(X)} returns the least integer greater than or equal to @var{X}.
1783 @item @emph{Standard}:
1789 @item @emph{Syntax}:
1790 @code{I = CEILING(X[,KIND])}
1792 @item @emph{Arguments}:
1793 @multitable @columnfractions .15 .80
1794 @item @var{X} @tab The type shall be @code{REAL(*)}.
1795 @item @var{KIND} @tab (Optional) scalar integer initialization expression.
1798 @item @emph{Return value}:
1799 The return value is of type @code{INTEGER(KIND)}
1801 @item @emph{Example}:
1803 program test_ceiling
1806 print *, ceiling(x) ! returns 64
1807 print *, ceiling(y) ! returns -63
1808 end program test_ceiling
1811 @item @emph{See also}:
1812 @ref{FLOOR}, @ref{NINT}
1819 @section @code{CHAR} --- Character conversion function
1820 @findex @code{CHAR} intrinsic
1821 @cindex conversion function (character)
1824 @item @emph{Description}:
1825 @code{CHAR(I,[KIND])} returns the character represented by the integer @var{I}.
1827 @item @emph{Standard}:
1833 @item @emph{Syntax}:
1834 @code{C = CHAR(I[,KIND])}
1836 @item @emph{Arguments}:
1837 @multitable @columnfractions .15 .80
1838 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1839 @item @var{KIND} @tab Optional scaler integer initialization expression.
1842 @item @emph{Return value}:
1843 The return value is of type @code{CHARACTER(1)}
1845 @item @emph{Example}:
1851 print *, i, c ! returns 'J'
1852 end program test_char
1855 @item @emph{See also}:
1856 @ref{ACHAR}, @ref{ICHAR}, @ref{IACHAR}
1862 @section @code{CHDIR} --- Change working directory
1863 @findex @code{CHDIR} intrinsic
1864 @cindex file system functions
1867 @item @emph{Description}:
1868 Change current working directory to a specified @var{PATH}.
1870 @item @emph{Standard}:
1874 Non-elemental subroutine
1876 @item @emph{Syntax}:
1877 @code{CALL chdir(PATH[,STATUS])}
1879 @item @emph{Arguments}:
1880 @multitable @columnfractions .15 .80
1881 @item @var{PATH} @tab The type shall be @code{CHARACTER(*)} and shall specify a valid path within the file system.
1882 @item @var{STATUS} @tab (Optional) status flag. Returns 0 on success,
1883 a system specific and non-zero error code otherwise.
1886 @item @emph{Example}:
1889 CHARACTER(len=255) :: path
1891 WRITE(*,*) TRIM(path)
1894 WRITE(*,*) TRIM(path)
1898 @item @emph{See also}:
1905 @section @code{CHMOD} --- Change access permissions of files
1906 @findex @code{CHMOD}
1907 @cindex file system functions
1910 @item @emph{Description}:
1911 @code{CHMOD} changes the permissions of a file. This function invokes
1912 @code{/bin/chmod} and might therefore not work on all platforms.
1914 This intrinsic is provided in both subroutine and function forms; however,
1915 only one form can be used in any given program unit.
1917 @item @emph{Standard}:
1921 Subroutine, non-elemental function
1923 @item @emph{Syntax}:
1924 @multitable @columnfractions .80
1925 @item @code{CALL CHMOD(NAME, MODE[, STATUS])}
1926 @item @code{STATUS = CHMOD(NAME, MODE)}
1929 @item @emph{Arguments}:
1930 @multitable @columnfractions .15 .80
1931 @item @var{NAME} @tab Scalar @code{CHARACTER} with the file name.
1932 Trailing blanks are ignored unless the character @code{achar(0)} is
1933 present, then all characters up to and excluding @code{achar(0)} are
1934 used as the file name.
1936 @item @var{MODE} @tab Scalar @code{CHARACTER} giving the file permission.
1937 @var{MODE} uses the same syntax as the @var{MODE} argument of
1940 @item @var{STATUS} @tab (optional) scalar @code{INTEGER}, which is
1941 @code{0} on success and non-zero otherwise.
1944 @item @emph{Return value}:
1945 In either syntax, @var{STATUS} is set to @code{0} on success and non-zero
1948 @item @emph{Example}:
1949 @code{CHMOD} as subroutine
1954 call chmod('test.dat','u+x',status)
1955 print *, 'Status: ', status
1956 end program chmod_test
1958 @code{CHMOD} as non-elemental function:
1963 status = chmod('test.dat','u+x')
1964 print *, 'Status: ', status
1965 end program chmod_test
1967 @item @emph{Specific names}:
1968 @item @emph{See also}:
1974 @section @code{CMPLX} --- Complex conversion function
1975 @findex @code{CMPLX} intrinsic
1979 @item @emph{Description}:
1980 @code{CMPLX(X[,Y[,KIND]])} returns a complex number where @var{X} is converted to
1981 the real component. If @var{Y} is present it is converted to the imaginary
1982 component. If @var{Y} is not present then the imaginary component is set to
1983 0.0. If @var{X} is complex then @var{Y} must not be present.
1985 @item @emph{Standard}:
1991 @item @emph{Syntax}:
1992 @code{C = CMPLX(X[,Y[,KIND]])}
1994 @item @emph{Arguments}:
1995 @multitable @columnfractions .15 .80
1996 @item @var{X} @tab The type may be @code{INTEGER(*)}, @code{REAL(*)}, or @code{COMPLEX(*)}.
1997 @item @var{Y} @tab Optional, allowed if @var{X} is not @code{COMPLEX(*)}. May be @code{INTEGER(*)} or @code{REAL(*)}.
1998 @item @var{KIND} @tab Optional scaler integer initialization expression.
2001 @item @emph{Return value}:
2002 The return value is of type @code{COMPLEX(*)}
2004 @item @emph{Example}:
2011 print *, z, cmplx(x)
2012 end program test_cmplx
2018 @node COMMAND_ARGUMENT_COUNT
2019 @section @code{COMMAND_ARGUMENT_COUNT} --- Get number of command line arguments
2020 @findex @code{COMMAND_ARGUMENT_COUNT} intrinsic
2021 @cindex command line arguments
2025 @item @emph{Description}:
2026 @code{COMMAND_ARGUMENT_COUNT()} returns the number of arguments passed on the
2027 command line when the containing program was invoked.
2029 @item @emph{Standard}:
2035 @item @emph{Syntax}:
2036 @code{I = COMMAND_ARGUMENT_COUNT()}
2038 @item @emph{Arguments}:
2039 @multitable @columnfractions .15 .80
2043 @item @emph{Return value}:
2044 The return value is of type @code{INTEGER(4)}
2046 @item @emph{Example}:
2048 program test_command_argument_count
2050 count = command_argument_count()
2052 end program test_command_argument_count
2055 @item @emph{See also}:
2056 @ref{GET_COMMAND}, @ref{GET_COMMAND_ARGUMENT}
2060 @section @code{CONJG} --- Complex conjugate function
2061 @findex @code{CONJG} intrinsic
2062 @findex @code{DCONJG} intrinsic
2063 @cindex complex conjugate
2065 @item @emph{Description}:
2066 @code{CONJG(Z)} returns the conjugate of @var{Z}. If @var{Z} is @code{(x, y)}
2067 then the result is @code{(x, -y)}
2069 @item @emph{Standard}:
2070 F77 and later, has overloads that are GNU extensions
2075 @item @emph{Syntax}:
2078 @item @emph{Arguments}:
2079 @multitable @columnfractions .15 .80
2080 @item @var{Z} @tab The type shall be @code{COMPLEX(*)}.
2083 @item @emph{Return value}:
2084 The return value is of type @code{COMPLEX(*)}.
2086 @item @emph{Example}:
2089 complex :: z = (2.0, 3.0)
2090 complex(8) :: dz = (2.71_8, -3.14_8)
2095 end program test_conjg
2098 @item @emph{Specific names}:
2099 @multitable @columnfractions .20 .20 .20 .40
2100 @item Name @tab Argument @tab Return type @tab Standard
2101 @item @code{DCONJG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
2108 @section @code{COS} --- Cosine function
2109 @findex @code{COS} intrinsic
2110 @findex @code{DCOS} intrinsic
2111 @findex @code{ZCOS} intrinsic
2112 @findex @code{CDCOS} intrinsic
2113 @cindex trigonometric functions
2116 @item @emph{Description}:
2117 @code{COS(X)} computes the cosine of @var{X}.
2119 @item @emph{Standard}:
2120 F77 and later, has overloads that are GNU extensions
2125 @item @emph{Syntax}:
2128 @item @emph{Arguments}:
2129 @multitable @columnfractions .15 .80
2130 @item @var{X} @tab The type shall be @code{REAL(*)} or
2134 @item @emph{Return value}:
2135 The return value is of type @code{REAL(*)} and it lies in the
2136 range @math{ -1 \leq \cos (x) \leq 1}. The kind type
2137 parameter is the same as @var{X}.
2139 @item @emph{Example}:
2144 end program test_cos
2147 @item @emph{Specific names}:
2148 @multitable @columnfractions .20 .20 .20 .40
2149 @item Name @tab Argument @tab Return type @tab Standard
2150 @item @code{DCOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
2151 @item @code{CCOS(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab F77 and later
2152 @item @code{ZCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
2153 @item @code{CDCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
2156 @item @emph{See also}:
2157 Inverse function: @ref{ACOS}
2164 @section @code{COSH} --- Hyperbolic cosine function
2165 @findex @code{COSH} intrinsic
2166 @findex @code{DCOSH} intrinsic
2167 @cindex hyperbolic cosine
2170 @item @emph{Description}:
2171 @code{COSH(X)} computes the hyperbolic cosine of @var{X}.
2173 @item @emph{Standard}:
2179 @item @emph{Syntax}:
2182 @item @emph{Arguments}:
2183 @multitable @columnfractions .15 .80
2184 @item @var{X} @tab The type shall be @code{REAL(*)}.
2187 @item @emph{Return value}:
2188 The return value is of type @code{REAL(*)} and it is positive
2189 (@math{ \cosh (x) \geq 0 }.
2191 @item @emph{Example}:
2194 real(8) :: x = 1.0_8
2196 end program test_cosh
2199 @item @emph{Specific names}:
2200 @multitable @columnfractions .20 .20 .20 .40
2201 @item Name @tab Argument @tab Return type @tab Standard
2202 @item @code{DCOSH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
2205 @item @emph{See also}:
2206 Inverse function: @ref{ACOSH}
2213 @section @code{COUNT} --- Count function
2214 @findex @code{COUNT} intrinsic
2218 @item @emph{Description}:
2219 @code{COUNT(MASK[,DIM])} counts the number of @code{.TRUE.} elements of
2220 @var{MASK} along the dimension of @var{DIM}. If @var{DIM} is omitted it is
2221 taken to be @code{1}. @var{DIM} is a scaler of type @code{INTEGER} in the
2222 range of @math{1 /leq DIM /leq n)} where @math{n} is the rank of @var{MASK}.
2224 @item @emph{Standard}:
2228 transformational function
2230 @item @emph{Syntax}:
2231 @code{I = COUNT(MASK[,DIM])}
2233 @item @emph{Arguments}:
2234 @multitable @columnfractions .15 .80
2235 @item @var{MASK} @tab The type shall be @code{LOGICAL}.
2236 @item @var{DIM} @tab The type shall be @code{INTEGER}.
2239 @item @emph{Return value}:
2240 The return value is of type @code{INTEGER} with rank equal to that of
2243 @item @emph{Example}:
2246 integer, dimension(2,3) :: a, b
2247 logical, dimension(2,3) :: mask
2248 a = reshape( (/ 1, 2, 3, 4, 5, 6 /), (/ 2, 3 /))
2249 b = reshape( (/ 0, 7, 3, 4, 5, 8 /), (/ 2, 3 /))
2250 print '(3i3)', a(1,:)
2251 print '(3i3)', a(2,:)
2253 print '(3i3)', b(1,:)
2254 print '(3i3)', b(2,:)
2257 print '(3l3)', mask(1,:)
2258 print '(3l3)', mask(2,:)
2260 print '(3i3)', count(mask)
2262 print '(3i3)', count(mask, 1)
2264 print '(3i3)', count(mask, 2)
2265 end program test_count
2272 @section @code{CPU_TIME} --- CPU elapsed time in seconds
2273 @findex @code{CPU_TIME} intrinsic
2277 @item @emph{Description}:
2278 Returns a @code{REAL} value representing the elapsed CPU time in seconds. This
2279 is useful for testing segments of code to determine execution time.
2281 @item @emph{Standard}:
2287 @item @emph{Syntax}:
2290 @item @emph{Arguments}:
2291 @multitable @columnfractions .15 .80
2292 @item @var{X} @tab The type shall be @code{REAL} with @code{INTENT(OUT)}.
2295 @item @emph{Return value}:
2298 @item @emph{Example}:
2300 program test_cpu_time
2301 real :: start, finish
2302 call cpu_time(start)
2303 ! put code to test here
2304 call cpu_time(finish)
2305 print '("Time = ",f6.3," seconds.")',finish-start
2306 end program test_cpu_time
2313 @section @code{CSHIFT} --- Circular shift function
2314 @findex @code{CSHIFT} intrinsic
2315 @cindex bit manipulation
2318 @item @emph{Description}:
2319 @code{CSHIFT(ARRAY, SHIFT[,DIM])} performs a circular shift on elements of
2320 @var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is omitted it is
2321 taken to be @code{1}. @var{DIM} is a scaler of type @code{INTEGER} in the
2322 range of @math{1 /leq DIM /leq n)} where @math{n} is the rank of @var{ARRAY}.
2323 If the rank of @var{ARRAY} is one, then all elements of @var{ARRAY} are shifted
2324 by @var{SHIFT} places. If rank is greater than one, then all complete rank one
2325 sections of @var{ARRAY} along the given dimension are shifted. Elements
2326 shifted out one end of each rank one section are shifted back in the other end.
2328 @item @emph{Standard}:
2332 transformational function
2334 @item @emph{Syntax}:
2335 @code{A = CSHIFT(A, SHIFT[,DIM])}
2337 @item @emph{Arguments}:
2338 @multitable @columnfractions .15 .80
2339 @item @var{ARRAY} @tab May be any type, not scaler.
2340 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
2341 @item @var{DIM} @tab The type shall be @code{INTEGER}.
2344 @item @emph{Return value}:
2345 Returns an array of same type and rank as the @var{ARRAY} argument.
2347 @item @emph{Example}:
2350 integer, dimension(3,3) :: a
2351 a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
2352 print '(3i3)', a(1,:)
2353 print '(3i3)', a(2,:)
2354 print '(3i3)', a(3,:)
2355 a = cshift(a, SHIFT=(/1, 2, -1/), DIM=2)
2357 print '(3i3)', a(1,:)
2358 print '(3i3)', a(2,:)
2359 print '(3i3)', a(3,:)
2360 end program test_cshift
2366 @section @code{CTIME} --- Convert a time into a string
2367 @findex @code{CTIME} intrinsic
2368 @cindex ctime subroutine
2371 @item @emph{Description}:
2372 @code{CTIME(T,S)} converts @var{T}, a system time value, such as returned
2373 by @code{TIME8()}, to a string of the form @samp{Sat Aug 19 18:13:14
2374 1995}, and returns that string into @var{S}.
2376 If @code{CTIME} is invoked as a function, it can not be invoked as a
2377 subroutine, and vice versa.
2379 @var{T} is an @code{INTENT(IN)} @code{INTEGER(KIND=8)} variable.
2380 @var{S} is an @code{INTENT(OUT)} @code{CHARACTER} variable.
2382 @item @emph{Standard}:
2388 @item @emph{Syntax}:
2389 @multitable @columnfractions .80
2390 @item @code{CALL CTIME(T,S)}.
2391 @item @code{S = CTIME(T)}, (not recommended).
2394 @item @emph{Arguments}:
2395 @multitable @columnfractions .15 .80
2396 @item @var{S}@tab The type shall be of type @code{CHARACTER}.
2397 @item @var{T}@tab The type shall be of type @code{INTEGER(KIND=8)}.
2400 @item @emph{Return value}:
2401 The converted date and time as a string.
2403 @item @emph{Example}:
2407 character(len=30) :: date
2410 ! Do something, main part of the program
2413 print *, 'Program was started on ', date
2414 end program test_ctime
2419 @section @code{DATE_AND_TIME} --- Date and time subroutine
2420 @findex @code{DATE_AND_TIME} intrinsic
2421 @cindex DATE_AND_TIME
2424 @item @emph{Description}:
2425 @code{DATE_AND_TIME(DATE, TIME, ZONE, VALUES)} gets the corresponding date and
2426 time information from the real-time system clock. @var{DATE} is
2427 @code{INTENT(OUT)} and has form ccyymmdd. @var{TIME} is @code{INTENT(OUT)} and
2428 has form hhmmss.sss. @var{ZONE} is @code{INTENT(OUT)} and has form (+-)hhmm,
2429 representing the difference with respect to Coordinated Universal Time (UTC).
2430 Unavailable time and date parameters return blanks.
2432 @var{VALUES} is @code{INTENT(OUT)} and provides the following:
2434 @multitable @columnfractions .15 .30 .60
2435 @item @tab @code{VALUE(1)}: @tab The year
2436 @item @tab @code{VALUE(2)}: @tab The month
2437 @item @tab @code{VALUE(3)}: @tab The day of the month
2438 @item @tab @code{VALUE(4)}: @tab Time difference with UTC in minutes
2439 @item @tab @code{VALUE(5)}: @tab The hour of the day
2440 @item @tab @code{VALUE(6)}: @tab The minutes of the hour
2441 @item @tab @code{VALUE(7)}: @tab The seconds of the minute
2442 @item @tab @code{VALUE(8)}: @tab The milliseconds of the second
2445 @item @emph{Standard}:
2451 @item @emph{Syntax}:
2452 @code{CALL DATE_AND_TIME([DATE, TIME, ZONE, VALUES])}
2454 @item @emph{Arguments}:
2455 @multitable @columnfractions .15 .80
2456 @item @var{DATE} @tab (Optional) The type shall be @code{CHARACTER(8)} or larger.
2457 @item @var{TIME} @tab (Optional) The type shall be @code{CHARACTER(10)} or larger.
2458 @item @var{ZONE} @tab (Optional) The type shall be @code{CHARACTER(5)} or larger.
2459 @item @var{VALUES}@tab (Optional) The type shall be @code{INTEGER(8)}.
2462 @item @emph{Return value}:
2465 @item @emph{Example}:
2467 program test_time_and_date
2468 character(8) :: date
2469 character(10) :: time
2470 character(5) :: zone
2471 integer,dimension(8) :: values
2472 ! using keyword arguments
2473 call date_and_time(date,time,zone,values)
2474 call date_and_time(DATE=date,ZONE=zone)
2475 call date_and_time(TIME=time)
2476 call date_and_time(VALUES=values)
2477 print '(a,2x,a,2x,a)', date, time, zone
2478 print '(8i5))', values
2479 end program test_time_and_date
2486 @section @code{DBLE} --- Double conversion function
2487 @findex @code{DBLE} intrinsic
2488 @cindex double conversion
2491 @item @emph{Description}:
2492 @code{DBLE(X)} Converts @var{X} to double precision real type.
2494 @item @emph{Standard}:
2500 @item @emph{Syntax}:
2503 @item @emph{Arguments}:
2504 @multitable @columnfractions .15 .80
2505 @item @var{X} @tab The type shall be @code{INTEGER(*)}, @code{REAL(*)}, or @code{COMPLEX(*)}.
2508 @item @emph{Return value}:
2509 The return value is of type double precision real.
2511 @item @emph{Example}:
2516 complex :: z = (2.3,1.14)
2517 print *, dble(x), dble(i), dble(z)
2518 end program test_dble
2521 @item @emph{See also}:
2522 @ref{DFLOAT}, @ref{FLOAT}, @ref{REAL}
2528 @section @code{DCMPLX} --- Double complex conversion function
2529 @findex @code{DCMPLX} intrinsic
2533 @item @emph{Description}:
2534 @code{DCMPLX(X [,Y])} returns a double complex number where @var{X} is
2535 converted to the real component. If @var{Y} is present it is converted to the
2536 imaginary component. If @var{Y} is not present then the imaginary component is
2537 set to 0.0. If @var{X} is complex then @var{Y} must not be present.
2539 @item @emph{Standard}:
2545 @item @emph{Syntax}:
2546 @code{C = DCMPLX(X)}
2547 @code{C = DCMPLX(X,Y)}
2549 @item @emph{Arguments}:
2550 @multitable @columnfractions .15 .80
2551 @item @var{X} @tab The type may be @code{INTEGER(*)}, @code{REAL(*)}, or @code{COMPLEX(*)}.
2552 @item @var{Y} @tab Optional if @var{X} is not @code{COMPLEX(*)}. May be @code{INTEGER(*)} or @code{REAL(*)}.
2555 @item @emph{Return value}:
2556 The return value is of type @code{COMPLEX(8)}
2558 @item @emph{Example}:
2568 print *, dcmplx(x,i)
2569 end program test_dcmplx
2576 @section @code{DFLOAT} --- Double conversion function
2577 @findex @code{DFLOAT} intrinsic
2578 @cindex double float conversion
2581 @item @emph{Description}:
2582 @code{DFLOAT(X)} Converts @var{X} to double precision real type.
2584 @item @emph{Standard}:
2590 @item @emph{Syntax}:
2591 @code{X = DFLOAT(X)}
2593 @item @emph{Arguments}:
2594 @multitable @columnfractions .15 .80
2595 @item @var{X} @tab The type shall be @code{INTEGER(*)}.
2598 @item @emph{Return value}:
2599 The return value is of type double precision real.
2601 @item @emph{Example}:
2606 end program test_dfloat
2609 @item @emph{See also}:
2610 @ref{DBLE}, @ref{FLOAT}, @ref{REAL}
2616 @section @code{DIGITS} --- Significant digits function
2617 @findex @code{DIGITS} intrinsic
2618 @cindex digits, significant
2621 @item @emph{Description}:
2622 @code{DIGITS(X)} returns the number of significant digits of the internal model
2623 representation of @var{X}. For example, on a system using a 32-bit
2624 floating point representation, a default real number would likely return 24.
2626 @item @emph{Standard}:
2632 @item @emph{Syntax}:
2633 @code{C = DIGITS(X)}
2635 @item @emph{Arguments}:
2636 @multitable @columnfractions .15 .80
2637 @item @var{X} @tab The type may be @code{INTEGER(*)} or @code{REAL(*)}.
2640 @item @emph{Return value}:
2641 The return value is of type @code{INTEGER}.
2643 @item @emph{Example}:
2646 integer :: i = 12345
2652 end program test_digits
2659 @section @code{DIM} --- Dim function
2660 @findex @code{DIM} intrinsic
2661 @findex @code{IDIM} intrinsic
2662 @findex @code{DDIM} intrinsic
2666 @item @emph{Description}:
2667 @code{DIM(X,Y)} returns the difference @code{X-Y} if the result is positive;
2668 otherwise returns zero.
2670 @item @emph{Standard}:
2676 @item @emph{Syntax}:
2679 @item @emph{Arguments}:
2680 @multitable @columnfractions .15 .80
2681 @item @var{X} @tab The type shall be @code{INTEGER(*)} or @code{REAL(*)}
2682 @item @var{Y} @tab The type shall be the same type and kind as @var{X}.
2685 @item @emph{Return value}:
2686 The return value is of type @code{INTEGER(*)} or @code{REAL(*)}.
2688 @item @emph{Example}:
2694 x = dim(4.345_8, 2.111_8)
2697 end program test_dim
2700 @item @emph{Specific names}:
2701 @multitable @columnfractions .20 .20 .20 .40
2702 @item Name @tab Argument @tab Return type @tab Standard
2703 @item @code{IDIM(X,Y)} @tab @code{INTEGER(4) X,Y} @tab @code{INTEGER(4)} @tab F77 and later
2704 @item @code{DDIM(X,Y)} @tab @code{REAL(8) X,Y} @tab @code{REAL(8)} @tab F77 and later
2711 @section @code{DOT_PRODUCT} --- Dot product function
2712 @findex @code{DOT_PRODUCT} intrinsic
2716 @item @emph{Description}:
2717 @code{DOT_PRODUCT(X,Y)} computes the dot product multiplication of two vectors
2718 @var{X} and @var{Y}. The two vectors may be either numeric or logical
2719 and must be arrays of rank one and of equal size. If the vectors are
2720 @code{INTEGER(*)} or @code{REAL(*)}, the result is @code{SUM(X*Y)}. If the
2721 vectors are @code{COMPLEX(*)}, the result is @code{SUM(CONJG(X)*Y)}. If the
2722 vectors are @code{LOGICAL}, the result is @code{ANY(X.AND.Y)}.
2724 @item @emph{Standard}:
2728 transformational function
2730 @item @emph{Syntax}:
2731 @code{S = DOT_PRODUCT(X,Y)}
2733 @item @emph{Arguments}:
2734 @multitable @columnfractions .15 .80
2735 @item @var{X} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
2736 @item @var{Y} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
2739 @item @emph{Return value}:
2740 If the arguments are numeric, the return value is a scaler of numeric type,
2741 @code{INTEGER(*)}, @code{REAL(*)}, or @code{COMPLEX(*)}. If the arguments are
2742 @code{LOGICAL}, the return value is @code{.TRUE.} or @code{.FALSE.}.
2744 @item @emph{Example}:
2746 program test_dot_prod
2747 integer, dimension(3) :: a, b
2754 print *, dot_product(a,b)
2755 end program test_dot_prod
2762 @section @code{DPROD} --- Double product function
2763 @findex @code{DPROD} intrinsic
2764 @cindex Double product
2767 @item @emph{Description}:
2768 @code{DPROD(X,Y)} returns the product @code{X*Y}.
2770 @item @emph{Standard}:
2776 @item @emph{Syntax}:
2777 @code{D = DPROD(X,Y)}
2779 @item @emph{Arguments}:
2780 @multitable @columnfractions .15 .80
2781 @item @var{X} @tab The type shall be @code{REAL}.
2782 @item @var{Y} @tab The type shall be @code{REAL}.
2785 @item @emph{Return value}:
2786 The return value is of type @code{REAL(8)}.
2788 @item @emph{Example}:
2797 end program test_dprod
2804 @section @code{DREAL} --- Double real part function
2805 @findex @code{DREAL} intrinsic
2806 @cindex Double real part
2809 @item @emph{Description}:
2810 @code{DREAL(Z)} returns the real part of complex variable @var{Z}.
2812 @item @emph{Standard}:
2818 @item @emph{Syntax}:
2821 @item @emph{Arguments}:
2822 @multitable @columnfractions .15 .80
2823 @item @var{Z} @tab The type shall be @code{COMPLEX(8)}.
2826 @item @emph{Return value}:
2827 The return value is of type @code{REAL(8)}.
2829 @item @emph{Example}:
2832 complex(8) :: z = (1.3_8,7.2_8)
2834 end program test_dreal
2837 @item @emph{See also}:
2845 @section @code{DTIME} --- Execution time subroutine (or function)
2846 @findex @code{DTIME} intrinsic
2847 @cindex dtime subroutine
2850 @item @emph{Description}:
2851 @code{DTIME(TARRAY, RESULT)} initially returns the number of seconds of runtime
2852 since the start of the process's execution in @var{RESULT}. @var{TARRAY}
2853 returns the user and system components of this time in @code{TARRAY(1)} and
2854 @code{TARRAY(2)} respectively. @var{RESULT} is equal to @code{TARRAY(1) +
2857 Subsequent invocations of @code{DTIME} return values accumulated since the
2858 previous invocation.
2860 On some systems, the underlying timings are represented using types with
2861 sufficiently small limits that overflows (wrap around) are possible, such as
2862 32-bit types. Therefore, the values returned by this intrinsic might be, or
2863 become, negative, or numerically less than previous values, during a single
2864 run of the compiled program.
2866 If @code{DTIME} is invoked as a function, it can not be invoked as a
2867 subroutine, and vice versa.
2869 @var{TARRAY} and @var{RESULT} are @code{INTENT(OUT)} and provide the following:
2871 @multitable @columnfractions .15 .30 .60
2872 @item @tab @code{TARRAY(1)}: @tab User time in seconds.
2873 @item @tab @code{TARRAY(2)}: @tab System time in seconds.
2874 @item @tab @code{RESULT}: @tab Run time since start in seconds.
2877 @item @emph{Standard}:
2883 @item @emph{Syntax}:
2884 @multitable @columnfractions .80
2885 @item @code{CALL DTIME(TARRAY, RESULT)}.
2886 @item @code{RESULT = DTIME(TARRAY)}, (not recommended).
2889 @item @emph{Arguments}:
2890 @multitable @columnfractions .15 .80
2891 @item @var{TARRAY}@tab The type shall be @code{REAL, DIMENSION(2)}.
2892 @item @var{RESULT}@tab The type shall be @code{REAL}.
2895 @item @emph{Return value}:
2896 Elapsed time in seconds since the start of program execution.
2898 @item @emph{Example}:
2902 real, dimension(2) :: tarray
2904 call dtime(tarray, result)
2908 do i=1,100000000 ! Just a delay
2911 call dtime(tarray, result)
2915 end program test_dtime
2922 @section @code{EOSHIFT} --- End-off shift function
2923 @findex @code{EOSHIFT} intrinsic
2924 @cindex bit manipulation
2927 @item @emph{Description}:
2928 @code{EOSHIFT(ARRAY, SHIFT[,BOUNDARY, DIM])} performs an end-off shift on
2929 elements of @var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is
2930 omitted it is taken to be @code{1}. @var{DIM} is a scaler of type
2931 @code{INTEGER} in the range of @math{1 /leq DIM /leq n)} where @math{n} is the
2932 rank of @var{ARRAY}. If the rank of @var{ARRAY} is one, then all elements of
2933 @var{ARRAY} are shifted by @var{SHIFT} places. If rank is greater than one,
2934 then all complete rank one sections of @var{ARRAY} along the given dimension are
2935 shifted. Elements shifted out one end of each rank one section are dropped. If
2936 @var{BOUNDARY} is present then the corresponding value of from @var{BOUNDARY}
2937 is copied back in the other end. If @var{BOUNDARY} is not present then the
2938 following are copied in depending on the type of @var{ARRAY}.
2940 @multitable @columnfractions .15 .80
2941 @item @emph{Array Type} @tab @emph{Boundary Value}
2942 @item Numeric @tab 0 of the type and kind of @var{ARRAY}.
2943 @item Logical @tab @code{.FALSE.}.
2944 @item Character(@var{len}) @tab @var{len} blanks.
2947 @item @emph{Standard}:
2951 transformational function
2953 @item @emph{Syntax}:
2954 @code{A = EOSHIFT(A, SHIFT[,BOUNDARY, DIM])}
2956 @item @emph{Arguments}:
2957 @multitable @columnfractions .15 .80
2958 @item @var{ARRAY} @tab May be any type, not scaler.
2959 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
2960 @item @var{BOUNDARY} @tab Same type as @var{ARRAY}.
2961 @item @var{DIM} @tab The type shall be @code{INTEGER}.
2964 @item @emph{Return value}:
2965 Returns an array of same type and rank as the @var{ARRAY} argument.
2967 @item @emph{Example}:
2969 program test_eoshift
2970 integer, dimension(3,3) :: a
2971 a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
2972 print '(3i3)', a(1,:)
2973 print '(3i3)', a(2,:)
2974 print '(3i3)', a(3,:)
2975 a = EOSHIFT(a, SHIFT=(/1, 2, 1/), BOUNDARY=-5, DIM=2)
2977 print '(3i3)', a(1,:)
2978 print '(3i3)', a(2,:)
2979 print '(3i3)', a(3,:)
2980 end program test_eoshift
2987 @section @code{EPSILON} --- Epsilon function
2988 @findex @code{EPSILON} intrinsic
2989 @cindex epsilon, significant
2992 @item @emph{Description}:
2993 @code{EPSILON(X)} returns a nearly negligible number relative to @code{1}.
2995 @item @emph{Standard}:
3001 @item @emph{Syntax}:
3002 @code{C = EPSILON(X)}
3004 @item @emph{Arguments}:
3005 @multitable @columnfractions .15 .80
3006 @item @var{X} @tab The type shall be @code{REAL(*)}.
3009 @item @emph{Return value}:
3010 The return value is of same type as the argument.
3012 @item @emph{Example}:
3014 program test_epsilon
3019 end program test_epsilon
3026 @section @code{ERF} --- Error function
3027 @findex @code{ERF} intrinsic
3028 @cindex error function
3031 @item @emph{Description}:
3032 @code{ERF(X)} computes the error function of @var{X}.
3034 @item @emph{Standard}:
3040 @item @emph{Syntax}:
3043 @item @emph{Arguments}:
3044 @multitable @columnfractions .15 .80
3045 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
3048 @item @emph{Return value}:
3049 The return value is a scalar of type @code{REAL(*)} and it is positive
3050 (@math{ - 1 \leq erf (x) \leq 1 }.
3052 @item @emph{Example}:
3055 real(8) :: x = 0.17_8
3057 end program test_erf
3060 @item @emph{Specific names}:
3061 @multitable @columnfractions .20 .20 .20 .40
3062 @item Name @tab Argument @tab Return type @tab Standard
3063 @item @code{DERF(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
3070 @section @code{ERFC} --- Error function
3071 @findex @code{ERFC} intrinsic
3072 @cindex error function
3075 @item @emph{Description}:
3076 @code{ERFC(X)} computes the complementary error function of @var{X}.
3078 @item @emph{Standard}:
3084 @item @emph{Syntax}:
3087 @item @emph{Arguments}:
3088 @multitable @columnfractions .15 .80
3089 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
3092 @item @emph{Return value}:
3093 The return value is a scalar of type @code{REAL(*)} and it is positive
3094 (@math{ 0 \leq erfc (x) \leq 2 }.
3096 @item @emph{Example}:
3099 real(8) :: x = 0.17_8
3101 end program test_erfc
3104 @item @emph{Specific names}:
3105 @multitable @columnfractions .20 .20 .20 .40
3106 @item Name @tab Argument @tab Return type @tab Standard
3107 @item @code{DERFC(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
3114 @section @code{ETIME} --- Execution time subroutine (or function)
3115 @findex @code{ETIME} intrinsic
3116 @cindex time functions
3119 @item @emph{Description}:
3120 @code{ETIME(TARRAY, RESULT)} returns the number of seconds of runtime
3121 since the start of the process's execution in @var{RESULT}. @var{TARRAY}
3122 returns the user and system components of this time in @code{TARRAY(1)} and
3123 @code{TARRAY(2)} respectively. @var{RESULT} is equal to @code{TARRAY(1) + TARRAY(2)}.
3125 On some systems, the underlying timings are represented using types with
3126 sufficiently small limits that overflows (wrap around) are possible, such as
3127 32-bit types. Therefore, the values returned by this intrinsic might be, or
3128 become, negative, or numerically less than previous values, during a single
3129 run of the compiled program.
3131 If @code{ETIME} is invoked as a function, it can not be invoked as a
3132 subroutine, and vice versa.
3134 @var{TARRAY} and @var{RESULT} are @code{INTENT(OUT)} and provide the following:
3136 @multitable @columnfractions .15 .30 .60
3137 @item @tab @code{TARRAY(1)}: @tab User time in seconds.
3138 @item @tab @code{TARRAY(2)}: @tab System time in seconds.
3139 @item @tab @code{RESULT}: @tab Run time since start in seconds.
3142 @item @emph{Standard}:
3148 @item @emph{Syntax}:
3149 @multitable @columnfractions .8
3150 @item @code{CALL ETIME(TARRAY, RESULT)}.
3151 @item @code{RESULT = ETIME(TARRAY)}, (not recommended).
3154 @item @emph{Arguments}:
3155 @multitable @columnfractions .15 .80
3156 @item @var{TARRAY}@tab The type shall be @code{REAL, DIMENSION(2)}.
3157 @item @var{RESULT}@tab The type shall be @code{REAL}.
3160 @item @emph{Return value}:
3161 Elapsed time in seconds since the start of program execution.
3163 @item @emph{Example}:
3167 real, dimension(2) :: tarray
3169 call ETIME(tarray, result)
3173 do i=1,100000000 ! Just a delay
3176 call ETIME(tarray, result)
3180 end program test_etime
3183 @item @emph{See also}:
3191 @section @code{EXIT} --- Exit the program with status.
3196 @item @emph{Description}:
3197 @code{EXIT} causes immediate termination of the program with status. If status
3198 is omitted it returns the canonical @emph{success} for the system. All Fortran
3199 I/O units are closed.
3201 @item @emph{Standard}:
3207 @item @emph{Syntax}:
3208 @code{CALL EXIT([STATUS])}
3210 @item @emph{Arguments}:
3211 @multitable @columnfractions .15 .80
3212 @item @var{STATUS} @tab The type of the argument shall be @code{INTEGER(*)}.
3215 @item @emph{Return value}:
3216 @code{STATUS} is passed to the parent process on exit.
3218 @item @emph{Example}:
3221 integer :: STATUS = 0
3222 print *, 'This program is going to exit.'
3224 end program test_exit
3227 @item @emph{See also}:
3228 @ref{ABORT}, @ref{KILL}
3234 @section @code{EXP} --- Exponential function
3235 @findex @code{EXP} intrinsic
3236 @findex @code{DEXP} intrinsic
3237 @findex @code{ZEXP} intrinsic
3238 @findex @code{CDEXP} intrinsic
3242 @item @emph{Description}:
3243 @code{EXP(X)} computes the base @math{e} exponential of @var{X}.
3245 @item @emph{Standard}:
3246 F77 and later, has overloads that are GNU extensions
3251 @item @emph{Syntax}:
3254 @item @emph{Arguments}:
3255 @multitable @columnfractions .15 .80
3256 @item @var{X} @tab The type shall be @code{REAL(*)} or
3260 @item @emph{Return value}:
3261 The return value has same type and kind as @var{X}.
3263 @item @emph{Example}:
3268 end program test_exp
3271 @item @emph{Specific names}:
3272 @multitable @columnfractions .20 .20 .20 .40
3273 @item Name @tab Argument @tab Return type @tab Standard
3274 @item @code{DEXP(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
3275 @item @code{CEXP(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab F77 and later
3276 @item @code{ZEXP(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
3277 @item @code{CDEXP(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
3284 @section @code{EXPONENT} --- Exponent function
3285 @findex @code{EXPONENT} intrinsic
3286 @cindex exponent function
3289 @item @emph{Description}:
3290 @code{EXPONENT(X)} returns the value of the exponent part of @var{X}. If @var{X}
3291 is zero the value returned is zero.
3293 @item @emph{Standard}:
3299 @item @emph{Syntax}:
3300 @code{I = EXPONENT(X)}
3302 @item @emph{Arguments}:
3303 @multitable @columnfractions .15 .80
3304 @item @var{X} @tab The type shall be @code{REAL(*)}.
3307 @item @emph{Return value}:
3308 The return value is of type default @code{INTEGER}.
3310 @item @emph{Example}:
3312 program test_exponent
3317 print *, exponent(0.0)
3318 end program test_exponent
3324 @section @code{FDATE} --- Get the current time as a string
3325 @findex @code{FDATE} intrinsic
3326 @cindex fdate subroutine
3329 @item @emph{Description}:
3330 @code{FDATE(DATE)} returns the current date (using the same format as
3331 @code{CTIME}) in @var{DATE}. It is equivalent to @code{CALL CTIME(DATE,
3334 If @code{FDATE} is invoked as a function, it can not be invoked as a
3335 subroutine, and vice versa.
3337 @var{DATE} is an @code{INTENT(OUT)} @code{CHARACTER} variable.
3339 @item @emph{Standard}:
3345 @item @emph{Syntax}:
3346 @multitable @columnfractions .80
3347 @item @code{CALL FDATE(DATE)}.
3348 @item @code{DATE = FDATE()}, (not recommended).
3351 @item @emph{Arguments}:
3352 @multitable @columnfractions .15 .80
3353 @item @var{DATE}@tab The type shall be of type @code{CHARACTER}.
3356 @item @emph{Return value}:
3357 The current date and time as a string.
3359 @item @emph{Example}:
3363 character(len=30) :: date
3365 print *, 'Program started on ', date
3366 do i = 1, 100000000 ! Just a delay
3370 print *, 'Program ended on ', date
3371 end program test_fdate
3377 @section @code{FLOAT} --- Convert integer to default real
3378 @findex @code{FLOAT} intrinsic
3379 @cindex conversion function (float)
3382 @item @emph{Description}:
3383 @code{FLOAT(I)} converts the integer @var{I} to a default real value.
3385 @item @emph{Standard}:
3391 @item @emph{Syntax}:
3394 @item @emph{Arguments}:
3395 @multitable @columnfractions .15 .80
3396 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
3399 @item @emph{Return value}:
3400 The return value is of type default @code{REAL}
3402 @item @emph{Example}:
3406 if (float(i) /= 1.) call abort
3407 end program test_float
3410 @item @emph{See also}:
3411 @ref{DBLE}, @ref{DFLOAT}, @ref{REAL}
3417 @section @code{FGET} --- Read a single character in stream mode from stdin
3418 @findex @code{FGET} intrinsic
3419 @cindex file operations
3420 @cindex stream operations
3423 @item @emph{Description}:
3424 Read a single character in stream mode from stdin by bypassing normal
3425 formatted output. Stream I/O should not be mixed with normal record-oriented
3426 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
3428 This intrinsic routine is provided for backwards compatibility with
3429 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
3430 Programmers should consider the use of new stream IO feature in new code
3431 for future portability. See also @ref{Fortran 2003 status}.
3433 @item @emph{Standard}:
3437 Non-elemental subroutine
3439 @item @emph{Syntax}:
3440 @code{CALL fget(C[,STATUS])}
3442 @item @emph{Arguments}:
3443 @multitable @columnfractions .15 .80
3444 @item @var{C} @tab The type shall be @code{CHARACTER}.
3445 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. Returns 0 on success,
3446 -1 on end-of-file and a system specific positive error code otherwise.
3449 @item @emph{Example}:
3452 INTEGER, PARAMETER :: strlen = 100
3453 INTEGER :: status, i = 1
3454 CHARACTER(len=strlen) :: str = ""
3456 WRITE (*,*) 'Enter text:'
3458 CALL fget(str(i:i), status)
3459 if (status /= 0 .OR. i > strlen) exit
3462 WRITE (*,*) TRIM(str)
3466 @item @emph{See also}:
3467 @ref{FGETC}, @ref{FPUT}, @ref{FPUTC}
3472 @section @code{FGETC} --- Read a single character in stream mode
3473 @findex @code{FGETC} intrinsic
3474 @cindex file operations
3475 @cindex stream operations
3478 @item @emph{Description}:
3479 Read a single character in stream mode by bypassing normal formatted output.
3480 Stream I/O should not be mixed with normal record-oriented (formatted or
3481 unformatted) I/O on the same unit; the results are unpredictable.
3483 This intrinsic routine is provided for backwards compatibility with
3484 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
3485 Programmers should consider the use of new stream IO feature in new code
3486 for future portability. See also @ref{Fortran 2003 status}.
3488 @item @emph{Standard}:
3492 Non-elemental subroutine
3494 @item @emph{Syntax}:
3495 @code{CALL fgetc(UNIT,C[,STATUS])}
3497 @item @emph{Arguments}:
3498 @multitable @columnfractions .15 .80
3499 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
3500 @item @var{C} @tab The type shall be @code{CHARACTER}.
3501 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. Returns 0 on success,
3502 -1 on end-of-file and a system specific positive error code otherwise.
3505 @item @emph{Example}:
3508 INTEGER :: fd = 42, status
3511 OPEN(UNIT=fd, FILE="/etc/passwd", ACTION="READ", STATUS = "OLD")
3513 CALL fgetc(fd, c, status)
3514 IF (status /= 0) EXIT
3521 @item @emph{See also}:
3522 @ref{FGET}, @ref{FPUT}, @ref{FPUTC}
3528 @section @code{FLOOR} --- Integer floor function
3529 @findex @code{FLOOR} intrinsic
3533 @item @emph{Description}:
3534 @code{FLOOR(X)} returns the greatest integer less than or equal to @var{X}.
3536 @item @emph{Standard}:
3542 @item @emph{Syntax}:
3543 @code{I = FLOOR(X[,KIND])}
3545 @item @emph{Arguments}:
3546 @multitable @columnfractions .15 .80
3547 @item @var{X} @tab The type shall be @code{REAL(*)}.
3548 @item @var{KIND} @tab Optional scaler integer initialization expression.
3551 @item @emph{Return value}:
3552 The return value is of type @code{INTEGER(KIND)}
3554 @item @emph{Example}:
3559 print *, floor(x) ! returns 63
3560 print *, floor(y) ! returns -64
3561 end program test_floor
3564 @item @emph{See also}:
3565 @ref{CEILING}, @ref{NINT}
3572 @section @code{FLUSH} --- Flush I/O unit(s)
3573 @findex @code{FLUSH}
3577 @item @emph{Description}:
3578 Flushes Fortran unit(s) currently open for output. Without the optional
3579 argument, all units are flushed, otherwise just the unit specified.
3581 @item @emph{Standard}:
3585 non-elemental subroutine
3587 @item @emph{Syntax}:
3588 @code{CALL FLUSH(UNIT)}
3590 @item @emph{Arguments}:
3591 @multitable @columnfractions .15 .80
3592 @item @var{UNIT} @tab (Optional) The type shall be @code{INTEGER}.
3596 Beginning with the Fortran 2003 standard, there is a @code{FLUSH}
3597 statement that should be preferred over the @code{FLUSH} intrinsic.
3604 @section @code{FNUM} --- File number function
3605 @findex @code{FNUM} intrinsic
3609 @item @emph{Description}:
3610 @code{FNUM(UNIT)} returns the POSIX file descriptor number corresponding to the
3611 open Fortran I/O unit @code{UNIT}.
3613 @item @emph{Standard}:
3617 non-elemental function
3619 @item @emph{Syntax}:
3620 @code{I = FNUM(UNIT)}
3622 @item @emph{Arguments}:
3623 @multitable @columnfractions .15 .80
3624 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
3627 @item @emph{Return value}:
3628 The return value is of type @code{INTEGER}
3630 @item @emph{Example}:
3634 open (unit=10, status = "scratch")
3638 end program test_fnum
3645 @section @code{FPUT} --- Write a single character in stream mode to stdout
3646 @findex @code{FPUT} intrinsic
3647 @cindex file operations
3648 @cindex stream operations
3651 @item @emph{Description}:
3652 Write a single character in stream mode to stdout by bypassing normal
3653 formatted output. Stream I/O should not be mixed with normal record-oriented
3654 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
3656 This intrinsic routine is provided for backwards compatibility with
3657 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
3658 Programmers should consider the use of new stream IO feature in new code
3659 for future portability. See also @ref{Fortran 2003 status}.
3661 @item @emph{Standard}:
3665 Non-elemental subroutine
3667 @item @emph{Syntax}:
3668 @code{CALL fput(C[,STATUS])}
3670 @item @emph{Arguments}:
3671 @multitable @columnfractions .15 .80
3672 @item @var{C} @tab The type shall be @code{CHARACTER}.
3673 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. Returns 0 on success,
3674 -1 on end-of-file and a system specific positive error code otherwise.
3677 @item @emph{Example}:
3680 CHARACTER(len=*) :: str = "gfortran"
3682 DO i = 1, len_trim(str)
3688 @item @emph{See also}:
3689 @ref{FPUTC}, @ref{FGET}, @ref{FGETC}
3695 @section @code{FPUTC} --- Write a single character in stream mode
3696 @findex @code{FPUTC} intrinsic
3697 @cindex file operations
3698 @cindex stream operations
3701 @item @emph{Description}:
3702 Write a single character in stream mode by bypassing normal formatted
3703 output. Stream I/O should not be mixed with normal record-oriented
3704 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
3706 This intrinsic routine is provided for backwards compatibility with
3707 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
3708 Programmers should consider the use of new stream IO feature in new code
3709 for future portability. See also @ref{Fortran 2003 status}.
3711 @item @emph{Standard}:
3715 Non-elemental subroutine
3717 @item @emph{Syntax}:
3718 @code{CALL fputc(UNIT,C[,STATUS])}
3720 @item @emph{Arguments}:
3721 @multitable @columnfractions .15 .80
3722 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
3723 @item @var{C} @tab The type shall be @code{CHARACTER}.
3724 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. Returns 0 on success,
3725 -1 on end-of-file and a system specific positive error code otherwise.
3728 @item @emph{Example}:
3731 CHARACTER(len=*) :: str = "gfortran"
3732 INTEGER :: fd = 42, i
3734 OPEN(UNIT = fd, FILE = "out", ACTION = "WRITE", STATUS="NEW")
3735 DO i = 1, len_trim(str)
3736 CALL fputc(fd, str(i:i))
3742 @item @emph{See also}:
3743 @ref{FPUT}, @ref{FGET}, @ref{FGETC}
3749 @section @code{FRACTION} --- Fractional part of the model representation
3750 @findex @code{FRACTION} intrinsic
3751 @cindex fractional part
3754 @item @emph{Description}:
3755 @code{FRACTION(X)} returns the fractional part of the model
3756 representation of @code{X}.
3758 @item @emph{Standard}:
3764 @item @emph{Syntax}:
3765 @code{Y = FRACTION(X)}
3767 @item @emph{Arguments}:
3768 @multitable @columnfractions .15 .80
3769 @item @var{X} @tab The type of the argument shall be a @code{REAL}.
3772 @item @emph{Return value}:
3773 The return value is of the same type and kind as the argument.
3774 The fractional part of the model representation of @code{X} is returned;
3775 it is @code{X * RADIX(X)**(-EXPONENT(X))}.
3777 @item @emph{Example}:
3779 program test_fraction
3782 print *, fraction(x), x * radix(x)**(-exponent(x))
3783 end program test_fraction
3791 @section @code{FREE} --- Frees memory
3792 @findex @code{FREE} intrinsic
3796 @item @emph{Description}:
3797 Frees memory previously allocated by @code{MALLOC()}. The @code{FREE}
3798 intrinsic is an extension intended to be used with Cray pointers, and is
3799 provided in GNU Fortran to allow user to compile legacy code. For
3800 new code using Fortran 95 pointers, the memory de-allocation intrinsic is
3803 @item @emph{Standard}:
3809 @item @emph{Syntax}:
3812 @item @emph{Arguments}:
3813 @multitable @columnfractions .15 .80
3814 @item @var{PTR} @tab The type shall be @code{INTEGER}. It represents the
3815 location of the memory that should be de-allocated.
3818 @item @emph{Return value}:
3821 @item @emph{Example}:
3822 See @code{MALLOC} for an example.
3824 @item @emph{See also}:
3832 @section @code{FSTAT} --- Get file status
3833 @findex @code{FSTAT} intrinsic
3834 @cindex file system operations
3837 @item @emph{Description}:
3838 @code{FSTAT} is identical to @ref{STAT}, except that information about an
3839 already opened file is obtained.
3841 The elements in @code{BUFF} are the same as described by @ref{STAT}.
3843 @item @emph{Standard}:
3847 Non-elemental subroutine
3849 @item @emph{Syntax}:
3850 @code{CALL fstat(UNIT,BUFF[,STATUS])}
3852 @item @emph{Arguments}:
3853 @multitable @columnfractions .15 .80
3854 @item @var{UNIT} @tab An open I/O unit number of type @code{INTEGER}.
3855 @item @var{BUFF} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
3856 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0
3857 on success and a system specific error code otherwise.
3860 @item @emph{Example}:
3861 See @ref{STAT} for an example.
3863 @item @emph{See also}:
3864 To stat a link: @ref{LSTAT}, to stat a file: @ref{STAT}
3870 @section @code{FSEEK} --- Low level file positioning subroutine
3871 @findex @code{FSEEK}
3872 @cindex file system functions
3874 Not yet implemented in GNU Fortran.
3877 @item @emph{Description}:
3879 @item @emph{Standard}:
3885 @item @emph{Syntax}:
3886 @item @emph{Arguments}:
3887 @item @emph{Return value}:
3888 @item @emph{Example}:
3889 @item @emph{Specific names}:
3890 @item @emph{See also}:
3891 @uref{http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19292, g77 features lacking in gfortran}
3898 @section @code{FTELL} --- Current stream position
3899 @findex @code{FTELL} intrinsic
3902 @item @emph{Description}:
3903 Retrieves the current position within an open file.
3905 This intrinsic is provided in both subroutine and function forms; however,
3906 only one form can be used in any given program unit.
3908 @item @emph{Standard}:
3912 Subroutine, function
3914 @item @emph{Syntax}:
3915 @multitable @columnfractions .80
3916 @item @code{CALL FTELL(UNIT, OFFSET)}
3917 @item @code{OFFSET = FTELL(UNIT)}
3920 @item @emph{Arguments}:
3921 @multitable @columnfractions .15 .80
3922 @item @var{OFFSET} @tab Shall of type @code{INTEGER}.
3923 @item @var{UNIT} @tab Shall of type @code{INTEGER}.
3926 @item @emph{Return value}:
3927 In either syntax, @var{OFFSET} is set to the current offset of unit
3928 number @var{UNIT}, or to @math{-1} if the unit is not currently open.
3930 @item @emph{Example}:
3934 OPEN(10, FILE="temp.dat")
3940 @item @emph{See also}:
3947 @section @code{GETARG} --- Get command line arguments
3948 @findex @code{GETARG} intrinsic
3949 @cindex command line arguments
3953 @item @emph{Description}:
3954 Retrieve the @var{N}th argument that was passed on the
3955 command line when the containing program was invoked.
3957 This intrinsic routine is provided for backwards compatibility with
3958 GNU Fortran 77. In new code, programmers should consider the use of
3959 the @ref{GET_COMMAND_ARGUMENT} intrinsic defined by the Fortran 2003
3962 @item @emph{Standard}:
3968 @item @emph{Syntax}:
3969 @code{CALL GETARG(N,ARG)}
3971 @item @emph{Arguments}:
3972 @multitable @columnfractions .15 .80
3973 @item @var{N} @tab Shall of type @code{INTEGER(4)}, @math{@var{N} \geq 0}
3974 @item @var{ARG} @tab Shall be of type @code{CHARACTER(*)}.
3977 @item @emph{Return value}:
3978 After @code{GETARG} returns, the @var{ARG} argument holds the @var{N}th
3979 command line argument. If @var{ARG} can not hold the argument, it is
3980 truncated to fit the length of @var{ARG}. If there are less than @var{N}
3981 arguments specified at the command line, @var{ARG} will be filled with blanks.
3982 If @math{@var{N} = 0}, @var{ARG} is set to the name of the program (on systems
3983 that support this feature).
3985 @item @emph{Example}:
3989 CHARACTER(len=32) :: arg
3998 @item @emph{See also}:
3999 GNU Fortran 77 compatibility function: @ref{IARGC}
4001 F2003 functions and subroutines: @ref{GET_COMMAND}, @ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
4007 @section @code{GET_COMMAND} --- Get the entire command line
4008 @findex @code{GET_COMMAND} intrinsic
4009 @cindex command line arguments
4013 @item @emph{Description}:
4014 Retrieve the entire command line that was used to invoke the program.
4016 @item @emph{Standard}:
4022 @item @emph{Syntax}:
4023 @code{CALL GET_COMMAND(CMD)}
4025 @item @emph{Arguments}:
4026 @multitable @columnfractions .15 .80
4027 @item @var{CMD} @tab Shall be of type @code{CHARACTER(*)}.
4030 @item @emph{Return value}:
4031 Stores the entire command line that was used to invoke the program in @var{ARG}.
4032 If @var{ARG} is not large enough, the command will be truncated.
4034 @item @emph{Example}:
4036 PROGRAM test_get_command
4037 CHARACTER(len=255) :: cmd
4038 CALL get_command(cmd)
4039 WRITE (*,*) TRIM(cmd)
4043 @item @emph{See also}:
4044 @ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
4049 @node GET_COMMAND_ARGUMENT
4050 @section @code{GET_COMMAND_ARGUMENT} --- Get command line arguments
4051 @findex @code{GET_COMMAND_ARGUMENT} intrinsic
4052 @cindex command line arguments
4056 @item @emph{Description}:
4057 Retrieve the @var{N}th argument that was passed on the
4058 command line when the containing program was invoked.
4060 @item @emph{Standard}:
4066 @item @emph{Syntax}:
4067 @code{CALL GET_COMMAND_ARGUMENT(N,ARG)}
4069 @item @emph{Arguments}:
4070 @multitable @columnfractions .15 .80
4071 @item @var{N} @tab Shall of type @code{INTEGER(4)}, @math{@var{N} \geq 0}
4072 @item @var{ARG} @tab Shall be of type @code{CHARACTER(*)}.
4075 @item @emph{Return value}:
4076 After @code{GET_COMMAND_ARGUMENT} returns, the @var{ARG} argument holds the
4077 @var{N}th command line argument. If @var{ARG} can not hold the argument, it is
4078 truncated to fit the length of @var{ARG}. If there are less than @var{N}
4079 arguments specified at the command line, @var{ARG} will be filled with blanks.
4080 If @math{@var{N} = 0}, @var{ARG} is set to the name of the program (on systems
4081 that support this feature).
4083 @item @emph{Example}:
4085 PROGRAM test_get_command_argument
4087 CHARACTER(len=32) :: arg
4091 CALL get_command_argument(i, arg)
4092 IF (LEN_TRIM(arg) == 0) EXIT
4094 WRITE (*,*) TRIM(arg)
4100 @item @emph{See also}:
4101 @ref{GET_COMMAND}, @ref{COMMAND_ARGUMENT_COUNT}
4107 @section @code{GETCWD} --- Get current working directory
4108 @findex @code{GETCWD} intrinsic
4109 @cindex file system functions
4112 @item @emph{Description}:
4113 Get current working directory.
4115 @item @emph{Standard}:
4119 Non-elemental subroutine.
4121 @item @emph{Syntax}:
4122 @code{CALL getcwd(CWD[,STATUS])}
4124 @item @emph{Arguments}:
4125 @multitable @columnfractions .15 .80
4126 @item @var{CWD} @tab The type shall be @code{CHARACTER(*)}.
4127 @item @var{STATUS} @tab (Optional) status flag. Returns 0 on success,
4128 a system specific and non-zero error code otherwise.
4131 @item @emph{Example}:
4134 CHARACTER(len=255) :: cwd
4136 WRITE(*,*) TRIM(cwd)
4140 @item @emph{See also}:
4147 @section @code{GETENV} --- Get an environmental variable
4148 @findex @code{GETENV} intrinsic
4149 @cindex environment variable
4152 @item @emph{Description}:
4153 Get the @var{VALUE} of the environmental variable @var{ENVVAR}.
4155 This intrinsic routine is provided for backwards compatibility with
4156 GNU Fortran 77. In new code, programmers should consider the use of
4157 the @ref{GET_ENVIRONMENT_VARIABLE} intrinsic defined by the Fortran
4160 @item @emph{Standard}:
4166 @item @emph{Syntax}:
4167 @code{CALL GETENV(ENVVAR,VALUE)}
4169 @item @emph{Arguments}:
4170 @multitable @columnfractions .15 .80
4171 @item @var{ENVVAR} @tab Shall be of type @code{CHARACTER(*)}.
4172 @item @var{VALUE} @tab Shall be of type @code{CHARACTER(*)}.
4175 @item @emph{Return value}:
4176 Stores the value of @var{ENVVAR} in @var{VALUE}. If @var{VALUE} is
4177 not large enough to hold the data, it is truncated. If @var{ENVVAR}
4178 is not set, @var{VALUE} will be filled with blanks.
4180 @item @emph{Example}:
4183 CHARACTER(len=255) :: homedir
4184 CALL getenv("HOME", homedir)
4185 WRITE (*,*) TRIM(homedir)
4189 @item @emph{See also}:
4190 @ref{GET_ENVIRONMENT_VARIABLE}
4195 @node GET_ENVIRONMENT_VARIABLE
4196 @section @code{GET_ENVIRONMENT_VARIABLE} --- Get an environmental variable
4197 @findex @code{GET_ENVIRONMENT_VARIABLE} intrinsic
4198 @cindex environment variable
4201 @item @emph{Description}:
4202 Get the @var{VALUE} of the environmental variable @var{ENVVAR}.
4204 @item @emph{Standard}:
4210 @item @emph{Syntax}:
4211 @code{CALL GET_ENVIRONMENT_VARIABLE(ENVVAR,VALUE)}
4213 @item @emph{Arguments}:
4214 @multitable @columnfractions .15 .80
4215 @item @var{ENVVAR} @tab Shall be of type @code{CHARACTER(*)}.
4216 @item @var{VALUE} @tab Shall be of type @code{CHARACTER(*)}.
4219 @item @emph{Return value}:
4220 Stores the value of @var{ENVVAR} in @var{VALUE}. If @var{VALUE} is
4221 not large enough to hold the data, it is truncated. If @var{ENVVAR}
4222 is not set, @var{VALUE} will be filled with blanks.
4224 @item @emph{Example}:
4227 CHARACTER(len=255) :: homedir
4228 CALL get_environment_variable("HOME", homedir)
4229 WRITE (*,*) TRIM(homedir)
4237 @section @code{GETGID} --- Group ID function
4238 @findex @code{GETGID} intrinsic
4242 @item @emph{Description}:
4243 Returns the numerical group ID of the current process.
4245 @item @emph{Standard}:
4251 @item @emph{Syntax}:
4254 @item @emph{Return value}:
4255 The return value of @code{GETGID} is an @code{INTEGER} of the default
4259 @item @emph{Example}:
4260 See @code{GETPID} for an example.
4262 @item @emph{See also}:
4263 @ref{GETPID}, @ref{GETUID}
4269 @section @code{GETLOG} --- Get login name
4270 @findex @code{GETLOG} intrinsic
4273 @item @emph{Description}:
4274 Gets the username under which the program is running.
4276 @item @emph{Standard}:
4282 @item @emph{Syntax}:
4283 @code{CALL GETLOG(LOGIN)}
4285 @item @emph{Arguments}:
4286 @multitable @columnfractions .15 .80
4287 @item @var{LOGIN} @tab Shall be of type @code{CHARACTER(*)}.
4290 @item @emph{Return value}:
4291 Stores the current user name in @var{LOGIN}. (On systems where
4292 the @code{getlogin(3)} function is not implemented, this will
4293 return a blank string.)
4295 @item @emph{Example}:
4298 CHARACTER(32) :: login
4304 @item @emph{See also}:
4311 @section @code{GETPID} --- Process ID function
4312 @findex @code{GETPID} intrinsic
4316 @item @emph{Description}:
4317 Returns the numerical process identifier of the current process.
4319 @item @emph{Standard}:
4325 @item @emph{Syntax}:
4328 @item @emph{Return value}:
4329 The return value of @code{GETPID} is an @code{INTEGER} of the default
4333 @item @emph{Example}:
4336 print *, "The current process ID is ", getpid()
4337 print *, "Your numerical user ID is ", getuid()
4338 print *, "Your numerical group ID is ", getgid()
4342 @item @emph{See also}:
4343 @ref{GETGID}, @ref{GETUID}
4349 @section @code{GETUID} --- User ID function
4350 @findex @code{GETUID} intrinsic
4354 @item @emph{Description}:
4355 Returns the numerical user ID of the current process.
4357 @item @emph{Standard}:
4363 @item @emph{Syntax}:
4366 @item @emph{Return value}:
4367 The return value of @code{GETUID} is an @code{INTEGER} of the default
4371 @item @emph{Example}:
4372 See @code{GETPID} for an example.
4374 @item @emph{See also}:
4375 @ref{GETPID}, @ref{GETLOG}
4381 @section @code{GMTIME} --- Convert time to GMT info
4382 @findex @code{GMTIME}
4383 @cindex time function
4385 Not yet implemented in GNU Fortran.
4388 @item @emph{Description}:
4390 @item @emph{Standard}:
4396 @item @emph{Syntax}:
4397 @item @emph{Arguments}:
4398 @item @emph{Return value}:
4399 @item @emph{Example}:
4400 @item @emph{Specific names}:
4401 @item @emph{See also}:
4408 @section @code{HOSTNM} --- Get system host name
4409 @findex @code{HOSTNM} intrinsic
4412 @item @emph{Description}:
4413 Retrieves the host name of the system on which the program is running.
4415 This intrinsic is provided in both subroutine and function forms; however,
4416 only one form can be used in any given program unit.
4418 @item @emph{Standard}:
4422 Subroutine, function
4424 @item @emph{Syntax}:
4425 @multitable @columnfractions .80
4426 @item @code{CALL HOSTNM(NAME, STATUS)}
4427 @item @code{STATUS = HOSTNM(NAME)}
4430 @item @emph{Arguments}:
4431 @multitable @columnfractions .15 .80
4432 @item @var{NAME} @tab Shall of type @code{CHARACTER(*)}.
4433 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
4434 Returns 0 on success, or a system specific error
4438 @item @emph{Return value}:
4439 In either syntax, @var{NAME} is set to the current hostname if it can
4440 be obtained, or to a blank string otherwise.
4447 @section @code{HUGE} --- Largest number of a kind
4448 @findex @code{HUGE} intrinsic
4452 @item @emph{Description}:
4453 @code{HUGE(X)} returns the largest number that is not an infinity in
4454 the model of the type of @code{X}.
4456 @item @emph{Standard}:
4462 @item @emph{Syntax}:
4465 @item @emph{Arguments}:
4466 @multitable @columnfractions .15 .80
4467 @item @var{X} @tab shall be of type @code{REAL} or @code{INTEGER}.
4470 @item @emph{Return value}:
4471 The return value is of the same type and kind as @var{X}
4473 @item @emph{Example}:
4475 program test_huge_tiny
4476 print *, huge(0), huge(0.0), huge(0.0d0)
4477 print *, tiny(0.0), tiny(0.0d0)
4478 end program test_huge_tiny
4485 @section @code{IACHAR} --- Code in @acronym{ASCII} collating sequence
4486 @findex @code{IACHAR} intrinsic
4487 @cindex @acronym{ASCII} collating sequence
4488 @cindex conversion function (character)
4491 @item @emph{Description}:
4492 @code{IACHAR(C)} returns the code for the @acronym{ASCII} character
4493 in the first character position of @code{C}.
4495 @item @emph{Standard}:
4501 @item @emph{Syntax}:
4502 @code{I = IACHAR(C)}
4504 @item @emph{Arguments}:
4505 @multitable @columnfractions .15 .80
4506 @item @var{C} @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
4509 @item @emph{Return value}:
4510 The return value is of type @code{INTEGER} and of the default integer
4513 @item @emph{Example}:
4518 end program test_iachar
4521 @item @emph{See also}:
4522 @ref{CHAR},@ref{ICHAR}
4528 @section @code{IAND} --- Bitwise logical and
4529 @findex @code{IAND} intrinsic
4530 @cindex bit operations
4533 @item @emph{Description}:
4534 Bitwise logical @code{AND}.
4536 @item @emph{Standard}:
4542 @item @emph{Syntax}:
4543 @code{RESULT = IAND(X, Y)}
4545 @item @emph{Arguments}:
4546 @multitable @columnfractions .15 .80
4547 @item @var{X} @tab The type shall be @code{INTEGER(*)}.
4548 @item @var{Y} @tab The type shall be @code{INTEGER(*)}.
4551 @item @emph{Return value}:
4552 The return type is @code{INTEGER(*)} after cross-promotion of the arguments.
4554 @item @emph{Example}:
4558 DATA a / Z'F' /, b / Z'3' /
4559 WRITE (*,*) IAND(a, b)
4563 @item @emph{See also}:
4564 @ref{IOR}, @ref{IEOR}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR},
4570 @section @code{IARGC} --- Get the number of command line arguments
4571 @findex @code{IARGC} intrinsic
4572 @cindex command line arguments
4576 @item @emph{Description}:
4577 @code{IARGC()} returns the number of arguments passed on the
4578 command line when the containing program was invoked.
4580 This intrinsic routine is provided for backwards compatibility with
4581 GNU Fortran 77. In new code, programmers should consider the use of
4582 the @ref{COMMAND_ARGUMENT_COUNT} intrinsic defined by the Fortran 2003
4585 @item @emph{Standard}:
4589 Non-elemental Function
4591 @item @emph{Syntax}:
4594 @item @emph{Arguments}:
4597 @item @emph{Return value}:
4598 The number of command line arguments, type @code{INTEGER(4)}.
4600 @item @emph{Example}:
4603 @item @emph{See also}:
4604 GNU Fortran 77 compatibility subroutine: @ref{GETARG}
4606 F2003 functions and subroutines: @ref{GET_COMMAND}, @ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
4612 @section @code{IBCLR} --- Clear bit
4613 @findex @code{IBCLR} intrinsic
4614 @cindex bit operations
4616 Intrinsic implemented, documentation pending.
4619 @item @emph{Description}:
4620 @item @emph{Standard}:
4626 @item @emph{Syntax}:
4627 @item @emph{Arguments}:
4628 @item @emph{Return value}:
4629 @item @emph{Example}:
4630 @item @emph{Specific names}:
4632 @item @emph{See also}:
4633 @ref{IBITS}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
4640 @section @code{IBITS} --- Bit extraction
4641 @findex @code{IBITS} intrinsic
4642 @cindex bit operations
4644 Intrinsic implemented, documentation pending.
4647 @item @emph{Description}:
4648 @item @emph{Standard}:
4654 @item @emph{Syntax}:
4655 @item @emph{Arguments}:
4656 @item @emph{Return value}:
4657 @item @emph{Example}:
4658 @item @emph{Specific names}:
4659 @item @emph{See also}:
4660 @ref{IBCLR}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
4668 @section @code{IBSET} --- Set bit
4669 @findex @code{IBSET} intrinsic
4670 @cindex bit operations
4672 Intrinsic implemented, documentation pending.
4675 @item @emph{Description}:
4676 @item @emph{Standard}:
4682 @item @emph{Syntax}:
4683 @item @emph{Arguments}:
4684 @item @emph{Return value}:
4685 @item @emph{Example}:
4686 @item @emph{Specific names}:
4688 @item @emph{See also}:
4689 @ref{IBCLR}, @ref{IBITS}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
4696 @section @code{ICHAR} --- Character-to-integer conversion function
4697 @findex @code{ICHAR} intrinsic
4698 @cindex conversion function (character)
4701 @item @emph{Description}:
4702 @code{ICHAR(C)} returns the code for the character in the first character
4703 position of @code{C} in the system's native character set.
4704 The correspondence between characters and their codes is not necessarily
4705 the same across different GNU Fortran implementations.
4707 @item @emph{Standard}:
4713 @item @emph{Syntax}:
4716 @item @emph{Arguments}:
4717 @multitable @columnfractions .15 .80
4718 @item @var{C} @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
4721 @item @emph{Return value}:
4722 The return value is of type @code{INTEGER} and of the default integer
4725 @item @emph{Example}:
4730 end program test_ichar
4734 No intrinsic exists to convert a printable character string to a numerical
4735 value. For example, there is no intrinsic that, given the @code{CHARACTER}
4736 value 154, returns an @code{INTEGER} or @code{REAL} value with the
4739 Instead, you can use internal-file I/O to do this kind of conversion. For
4744 character(len=10) string
4747 read (string,'(I10)') value
4749 end program read_val
4754 @section @code{IDATE} --- Get current local time subroutine (day/month/year)
4755 @findex @code{IDATE} intrinsic
4758 @item @emph{Description}:
4759 @code{IDATE(TARRAY)} Fills @var{TARRAY} with the numerical values at the
4760 current local time. The day (in the range 1-31), month (in the range 1-12),
4761 and year appear in elements 1, 2, and 3 of @var{TARRAY}, respectively.
4762 The year has four significant digits.
4764 @item @emph{Standard}:
4770 @item @emph{Syntax}:
4771 @code{CALL IDATE(TARRAY)}
4773 @item @emph{Arguments}:
4774 @multitable @columnfractions .15 .80
4775 @item @var{TARRAY} @tab The type shall be @code{INTEGER, DIMENSION(3)} and
4776 the kind shall be the default integer kind.
4779 @item @emph{Return value}:
4782 @item @emph{Example}:
4785 integer, dimension(3) :: tarray
4790 end program test_idate
4797 @section @code{IEOR} --- Bitwise logical exclusive or
4798 @findex @code{IEOR} intrinsic
4799 @cindex bit operations
4801 Intrinsic implemented, documentation pending.
4804 @item @emph{Description}:
4805 @item @emph{Standard}:
4811 @item @emph{Syntax}:
4812 @item @emph{Arguments}:
4813 @item @emph{Return value}:
4814 @item @emph{Example}:
4815 @item @emph{Specific names}:
4817 @item @emph{See also}:
4818 @ref{IOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR},
4825 @section @code{IERRNO} --- Get the last system error number
4826 @findex @code{IERRNO} intrinsic
4827 @cindex undocumented intrinsic
4829 Intrinsic implemented, documentation pending.
4832 @item @emph{Description}:
4833 @item @emph{Standard}:
4837 @item @emph{Syntax}:
4838 @item @emph{Arguments}:
4839 @item @emph{Return value}:
4840 @item @emph{Example}:
4842 @item @emph{See also}:
4850 @section @code{INDEX} --- Position of a substring within a string
4851 @findex @code{INDEX} intrinsic
4852 @cindex undocumented intrinsic
4854 Intrinsic implemented, documentation pending.
4857 @item @emph{Description}:
4858 @item @emph{Standard}:
4864 @item @emph{Syntax}:
4865 @item @emph{Arguments}:
4866 @item @emph{Return value}:
4867 @item @emph{Example}:
4868 @item @emph{Specific names}:
4869 @item @emph{See also}:
4876 @section @code{INT} --- Convert to integer type
4877 @findex @code{INT} intrinsic
4878 @findex @code{IFIX} intrinsic
4879 @findex @code{IDINT} intrinsic
4880 @cindex conversion function (integer)
4883 @item @emph{Description}:
4884 Convert to integer type
4886 @item @emph{Standard}:
4892 @item @emph{Syntax}:
4893 @multitable @columnfractions .30 .80
4894 @item @code{X = INT(X)}
4895 @item @code{X = INT(X, KIND)}
4898 @item @emph{Arguments}:
4899 @multitable @columnfractions .15 .80
4900 @item @var{X} @tab shall be of type @code{INTEGER(*)}, @code{REAL(*)} or @code{COMPLEX(*)}
4901 @item @var{KIND} @tab (Optional) @var{KIND} shall be a scalar integer.
4904 @item @emph{Return value}:
4905 These functions return a @code{INTEGER(*)} variable or array under
4906 the following rules:
4910 If @var{X} is of type @code{INTEGER(*)}, @code{INT(X) = X}
4912 If @var{X} is of type @code{REAL(*)} and @math{|X| < 1} @code{INT(X)} equals @var{0}.
4913 If @math{|X| \geq 1}, then @code{INT(X)} equals the largest integer that does not exceed
4914 the range of @var{X} and whose sign is the same as the sign of @var{X}.
4916 If @var{X} is of type @code{COMPLEX(*)}, rule B is applied to the real part of X.
4919 @item @emph{Example}:
4923 complex :: z = (-3.7, 1.0)
4925 print *, int(z), int(z,8)
4929 @item @emph{Specific names}:
4930 @multitable @columnfractions .20 .20 .20 .40
4931 @item Name @tab Argument @tab Return type @tab Standard
4932 @item @code{IFIX(X)} @tab @code{REAL(4) X} @tab @code{INTEGER} @tab F77 and later
4933 @item @code{IDINT(X)} @tab @code{REAL(8) X} @tab @code{INTEGER} @tab F77 and later
4936 @comment @item @emph{See also}:
4943 @section @code{IOR} --- Bitwise logical or
4944 @findex @code{IOR} intrinsic
4945 @cindex bit operations
4947 Intrinsic implemented, documentation pending.
4950 @item @emph{Description}:
4951 @item @emph{Standard}:
4957 @item @emph{Syntax}:
4958 @item @emph{Arguments}:
4959 @item @emph{Return value}:
4960 @item @emph{Example}:
4961 @item @emph{Specific names}:
4963 @item @emph{See also}:
4964 @ref{IEOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR},
4971 @section @code{IRAND} --- Integer pseudo-random number
4972 @findex @code{IRAND} intrinsic
4973 @cindex random number
4976 @item @emph{Description}:
4977 @code{IRAND(FLAG)} returns a pseudo-random number from a uniform
4978 distribution between 0 and a system-dependent limit (which is in most
4979 cases 2147483647). If @var{FLAG} is 0, the next number
4980 in the current sequence is returned; if @var{FLAG} is 1, the generator
4981 is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
4982 it is used as a new seed with @code{SRAND}.
4984 @item @emph{Standard}:
4988 non-elemental function
4990 @item @emph{Syntax}:
4991 @code{I = IRAND(FLAG)}
4993 @item @emph{Arguments}:
4994 @multitable @columnfractions .15 .80
4995 @item @var{FLAG} @tab shall be a scalar @code{INTEGER} of kind 4.
4998 @item @emph{Return value}:
4999 The return value is of @code{INTEGER(kind=4)} type.
5001 @item @emph{Example}:
5004 integer,parameter :: seed = 86456
5007 print *, irand(), irand(), irand(), irand()
5008 print *, irand(seed), irand(), irand(), irand()
5009 end program test_irand
5017 @section @code{ISHFT} --- Shift bits
5018 @findex @code{ISHFT} intrinsic
5019 @cindex bit manipulation
5021 Intrinsic implemented, documentation pending.
5024 @item @emph{Description}:
5025 @item @emph{Standard}:
5031 @item @emph{Syntax}:
5032 @item @emph{Arguments}:
5033 @item @emph{Return value}:
5034 @item @emph{Example}:
5035 @item @emph{Specific names}:
5037 @item @emph{See also}:
5045 @section @code{ISHFTC} --- Shift bits circularly
5046 @findex @code{ISHFTC} intrinsic
5047 @cindex bit manipulation
5049 Intrinsic implemented, documentation pending.
5052 @item @emph{Description}:
5053 @item @emph{Standard}:
5059 @item @emph{Syntax}:
5060 @item @emph{Arguments}:
5061 @item @emph{Return value}:
5062 @item @emph{Example}:
5063 @item @emph{Specific names}:
5065 @item @emph{See also}:
5072 @section @code{ITIME} --- Get current local time subroutine (hour/minutes/seconds)
5073 @findex @code{ITIME} intrinsic
5076 @item @emph{Description}:
5077 @code{IDATE(TARRAY)} Fills @var{TARRAY} with the numerical values at the
5078 current local time. The hour (in the range 1-24), minute (in the range 1-60),
5079 and seconds (in the range 1-60) appear in elements 1, 2, and 3 of @var{TARRAY},
5082 @item @emph{Standard}:
5088 @item @emph{Syntax}:
5089 @code{CALL ITIME(TARRAY)}
5091 @item @emph{Arguments}:
5092 @multitable @columnfractions .15 .80
5093 @item @var{TARRAY} @tab The type shall be @code{INTEGER, DIMENSION(3)}
5094 and the kind shall be the default integer kind.
5097 @item @emph{Return value}:
5101 @item @emph{Example}:
5104 integer, dimension(3) :: tarray
5109 end program test_itime
5116 @section @code{KILL} --- Send a signal to a process
5117 @findex @code{KILL} intrinsic
5118 @cindex undocumented intrinsic
5120 Intrinsic implemented, documentation pending.
5123 @item @emph{Description}:
5124 @item @emph{Standard}:
5130 @item @emph{Syntax}:
5131 @item @emph{Arguments}:
5132 @item @emph{Return value}:
5133 @item @emph{Example}:
5134 @item @emph{Specific names}:
5136 @item @emph{See also}:
5137 @ref{ABORT}, @ref{EXIT}
5143 @section @code{KIND} --- Kind of an entity
5144 @findex @code{KIND} intrinsic
5147 @item @emph{Description}:
5148 @code{KIND(X)} returns the kind value of the entity @var{X}.
5150 @item @emph{Standard}:
5156 @item @emph{Syntax}:
5159 @item @emph{Arguments}:
5160 @multitable @columnfractions .15 .80
5161 @item @var{X} @tab Shall be of type @code{LOGICAL}, @code{INTEGER},
5162 @code{REAL}, @code{COMPLEX} or @code{CHARACTER}.
5165 @item @emph{Return value}:
5166 The return value is a scalar of type @code{INTEGER} and of the default
5169 @item @emph{Example}:
5172 integer,parameter :: kc = kind(' ')
5173 integer,parameter :: kl = kind(.true.)
5175 print *, "The default character kind is ", kc
5176 print *, "The default logical kind is ", kl
5177 end program test_kind
5185 @section @code{LBOUND} --- Lower dimension bounds of an array
5186 @findex @code{LBOUND} intrinsic
5187 @cindex undocumented intrinsic
5189 Intrinsic implemented, documentation pending.
5192 @item @emph{Description}:
5193 @item @emph{Standard}:
5199 @item @emph{Syntax}:
5200 @item @emph{Arguments}:
5201 @item @emph{Return value}:
5202 @item @emph{Example}:
5203 @item @emph{See also}:
5211 @section @code{LEN} --- Length of a character entity
5212 @findex @code{LEN} intrinsic
5213 @cindex undocumented intrinsic
5215 Intrinsic implemented, documentation pending.
5218 @item @emph{Description}:
5219 @item @emph{Standard}:
5225 @item @emph{Syntax}:
5226 @item @emph{Arguments}:
5227 @item @emph{Return value}:
5228 @item @emph{Example}:
5229 @item @emph{Specific names}:
5231 @item @emph{See also}:
5232 @ref{LEN_TRIM}, @ref{ADJUSTL}, @ref{ADJUSTR}
5239 @section @code{LEN_TRIM} --- Length of a character entity without trailing blank characters
5240 @findex @code{LEN_TRIM} intrinsic
5241 @cindex undocumented intrinsic
5243 Intrinsic implemented, documentation pending.
5246 @item @emph{Description}:
5247 @item @emph{Standard}:
5253 @item @emph{Syntax}:
5254 @item @emph{Arguments}:
5255 @item @emph{Return value}:
5256 @item @emph{Example}:
5258 @item @emph{See also}:
5259 @ref{LEN}, @ref{ADJUSTL}, @ref{ADJUSTR}
5266 @section @code{LGE} --- Lexical greater than or equal
5267 @findex @code{LGE} intrinsic
5268 @cindex comparison (lexical)
5270 Intrinsic implemented, documentation pending.
5273 @item @emph{Description}:
5274 @item @emph{Standard}:
5280 @item @emph{Syntax}:
5281 @item @emph{Arguments}:
5282 @item @emph{Return value}:
5283 @item @emph{Example}:
5285 @item @emph{See also}:
5286 @ref{LGT}, @ref{LLE}, @ref{LLT}
5293 @section @code{LGT} --- Lexical greater than
5294 @findex @code{LGT} intrinsic
5295 @cindex comparison (lexical)
5297 Intrinsic implemented, documentation pending.
5300 @item @emph{Description}:
5301 @item @emph{Standard}:
5307 @item @emph{Syntax}:
5308 @item @emph{Arguments}:
5309 @item @emph{Return value}:
5310 @item @emph{Example}:
5312 @item @emph{See also}:
5313 @ref{LGE}, @ref{LLE}, @ref{LLT}
5320 @section @code{LINK} --- Create a hard link
5321 @findex @code{LINK} intrinsic
5322 @cindex file system operations
5324 Intrinsic implemented, documentation pending.
5327 @item @emph{Description}:
5328 @item @emph{Standard}:
5334 @item @emph{Syntax}:
5335 @item @emph{Arguments}:
5336 @item @emph{Return value}:
5337 @item @emph{Example}:
5338 @item @emph{Specific names}:
5340 @item @emph{See also}:
5348 @section @code{LLE} --- Lexical less than or equal
5349 @findex @code{LLE} intrinsic
5350 @cindex comparison (lexical)
5352 Intrinsic implemented, documentation pending.
5355 @item @emph{Description}:
5356 @item @emph{Standard}:
5362 @item @emph{Syntax}:
5363 @item @emph{Arguments}:
5364 @item @emph{Return value}:
5365 @item @emph{Example}:
5367 @item @emph{See also}:
5368 @ref{LGE}, @ref{LGT}, @ref{LLT}
5375 @section @code{LLT} --- Lexical less than
5376 @findex @code{LLT} intrinsic
5377 @cindex comparison (lexical)
5379 Intrinsic implemented, documentation pending.
5382 @item @emph{Description}:
5383 @item @emph{Standard}:
5389 @item @emph{Syntax}:
5390 @item @emph{Arguments}:
5391 @item @emph{Return value}:
5392 @item @emph{Example}:
5394 @item @emph{See also}:
5395 @ref{LGE}, @ref{LGT}, @ref{LLE}
5402 @section @code{LNBLNK} --- Index of the last non-blank character in a string
5403 @findex @code{LNBLNK} intrinsic
5404 @cindex undocumented intrinsic
5406 Intrinsic implemented, documentation pending.
5409 @item @emph{Description}:
5410 @item @emph{Standard}:
5414 @item @emph{Syntax}:
5415 @item @emph{Arguments}:
5416 @item @emph{Return value}:
5417 @item @emph{Example}:
5418 @item @emph{Specific names}:
5420 @item @emph{See also}:
5428 @section @code{LOC} --- Returns the address of a variable
5429 @findex @code{LOC} intrinsic
5433 @item @emph{Description}:
5434 @code{LOC(X)} returns the address of @var{X} as an integer.
5436 @item @emph{Standard}:
5442 @item @emph{Syntax}:
5445 @item @emph{Arguments}:
5446 @multitable @columnfractions .15 .80
5447 @item @var{X} @tab Variable of any type.
5450 @item @emph{Return value}:
5451 The return value is of type @code{INTEGER(n)}, where @code{n} is the
5452 size (in bytes) of a memory address on the target machine.
5454 @item @emph{Example}:
5461 end program test_loc
5466 @section @code{LOG} --- Logarithm function
5467 @findex @code{LOG} intrinsic
5468 @findex @code{ALOG} intrinsic
5469 @findex @code{DLOG} intrinsic
5470 @findex @code{CLOG} intrinsic
5471 @findex @code{ZLOG} intrinsic
5472 @findex @code{CDLOG} intrinsic
5476 @item @emph{Description}:
5477 @code{LOG(X)} computes the logarithm of @var{X}.
5479 @item @emph{Standard}:
5485 @item @emph{Syntax}:
5488 @item @emph{Arguments}:
5489 @multitable @columnfractions .15 .80
5490 @item @var{X} @tab The type shall be @code{REAL(*)} or
5494 @item @emph{Return value}:
5495 The return value is of type @code{REAL(*)} or @code{COMPLEX(*)}.
5496 The kind type parameter is the same as @var{X}.
5498 @item @emph{Example}:
5501 real(8) :: x = 1.0_8
5502 complex :: z = (1.0, 2.0)
5505 end program test_log
5508 @item @emph{Specific names}:
5509 @multitable @columnfractions .20 .20 .20 .40
5510 @item Name @tab Argument @tab Return type @tab Standard
5511 @item @code{ALOG(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab f95, gnu
5512 @item @code{DLOG(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
5513 @item @code{CLOG(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab f95, gnu
5514 @item @code{ZLOG(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
5515 @item @code{CDLOG(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
5522 @section @code{LOG10} --- Base 10 logarithm function
5523 @findex @code{LOG10} intrinsic
5524 @findex @code{ALOG10} intrinsic
5525 @findex @code{DLOG10} intrinsic
5529 @item @emph{Description}:
5530 @code{LOG10(X)} computes the base 10 logarithm of @var{X}.
5532 @item @emph{Standard}:
5538 @item @emph{Syntax}:
5541 @item @emph{Arguments}:
5542 @multitable @columnfractions .15 .80
5543 @item @var{X} @tab The type shall be @code{REAL(*)} or
5547 @item @emph{Return value}:
5548 The return value is of type @code{REAL(*)} or @code{COMPLEX(*)}.
5549 The kind type parameter is the same as @var{X}.
5551 @item @emph{Example}:
5554 real(8) :: x = 10.0_8
5556 end program test_log10
5559 @item @emph{Specific names}:
5560 @multitable @columnfractions .20 .20 .20 .40
5561 @item Name @tab Argument @tab Return type @tab Standard
5562 @item @code{ALOG10(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab F95 and later
5563 @item @code{DLOG10(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
5569 @section @code{LOGICAL} --- Convert to logical type
5570 @findex @code{LOGICAL} intrinsic
5571 @cindex conversion function (logical)
5573 Intrinsic implemented, documentation pending.
5576 @item @emph{Description}:
5577 @item @emph{Standard}:
5583 @item @emph{Syntax}:
5584 @item @emph{Arguments}:
5585 @item @emph{Return value}:
5586 @item @emph{Example}:
5587 @item @emph{Specific names}:
5588 @item @emph{See also}:
5595 @section @code{LSHIFT} --- Left shift bits
5596 @findex @code{LSHIFT}
5597 @cindex bit manipulation
5599 Not yet implemented in GNU Fortran.
5602 @item @emph{Description}:
5604 @item @emph{Standard}:
5610 @item @emph{Syntax}:
5611 @item @emph{Arguments}:
5612 @item @emph{Return value}:
5613 @item @emph{Example}:
5614 @item @emph{Specific names}:
5615 @item @emph{See also}:
5621 @section @code{LSTAT} --- Get file status
5622 @findex @code{LSTAT} intrinsic
5623 @cindex file system operations
5626 @item @emph{Description}:
5627 @code{LSTAT} is identical to @ref{STAT}, except that if path is a symbolic link,
5628 then the link itself is statted, not the file that it refers to.
5630 The elements in @code{BUFF} are the same as described by @ref{STAT}.
5632 @item @emph{Standard}:
5636 Non-elemental subroutine
5638 @item @emph{Syntax}:
5639 @code{CALL LSTAT(FILE,BUFF[,STATUS])}
5641 @item @emph{Arguments}:
5642 @multitable @columnfractions .15 .80
5643 @item @var{FILE} @tab The type shall be @code{CHARACTER(*)}, a valid path within the file system.
5644 @item @var{BUFF} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
5645 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0
5646 on success and a system specific error code otherwise.
5649 @item @emph{Example}:
5650 See @ref{STAT} for an example.
5652 @item @emph{See also}:
5653 To stat an open file: @ref{FSTAT}, to stat a file: @ref{STAT}
5659 @section @code{LTIME} --- Convert time to local time info
5660 @findex @code{LTIME}
5661 @cindex time function
5663 Not yet implemented in GNU Fortran.
5666 @item @emph{Description}:
5668 @item @emph{Standard}:
5674 @item @emph{Syntax}:
5675 @item @emph{Arguments}:
5676 @item @emph{Return value}:
5677 @item @emph{Example}:
5678 @item @emph{Specific names}:
5679 @item @emph{See also}:
5686 @section @code{MALLOC} --- Allocate dynamic memory
5687 @findex @code{MALLOC} intrinsic
5691 @item @emph{Description}:
5692 @code{MALLOC(SIZE)} allocates @var{SIZE} bytes of dynamic memory and
5693 returns the address of the allocated memory. The @code{MALLOC} intrinsic
5694 is an extension intended to be used with Cray pointers, and is provided
5695 in GNU Fortran to allow the user to compile legacy code. For new code
5696 using Fortran 95 pointers, the memory allocation intrinsic is
5699 @item @emph{Standard}:
5703 non-elemental function
5705 @item @emph{Syntax}:
5706 @code{PTR = MALLOC(SIZE)}
5708 @item @emph{Arguments}:
5709 @multitable @columnfractions .15 .80
5710 @item @var{SIZE} @tab The type shall be @code{INTEGER(*)}.
5713 @item @emph{Return value}:
5714 The return value is of type @code{INTEGER(K)}, with @var{K} such that
5715 variables of type @code{INTEGER(K)} have the same size as
5716 C pointers (@code{sizeof(void *)}).
5718 @item @emph{Example}:
5719 The following example demonstrates the use of @code{MALLOC} and
5720 @code{FREE} with Cray pointers. This example is intended to run on
5721 32-bit systems, where the default integer kind is suitable to store
5722 pointers; on 64-bit systems, ptr_x would need to be declared as
5723 @code{integer(kind=8)}.
5732 ptr_x = malloc(20*8)
5734 x(i) = sqrt(1.0d0 / i)
5742 end program test_malloc
5745 @item @emph{See also}:
5751 @section @code{MATMUL} --- matrix multiplication
5752 @findex @code{MATMUL} intrinsic
5753 @cindex matrix operations
5755 Intrinsic implemented, documentation pending.
5758 @item @emph{Description}:
5759 @item @emph{Standard}:
5763 Transformational function
5765 @item @emph{Syntax}:
5766 @item @emph{Arguments}:
5767 @item @emph{Return value}:
5768 @item @emph{Example}:
5769 @item @emph{See also}:
5774 @section @code{MAX} --- Maximum value of an argument list
5775 @findex @code{MAX} intrinsic
5776 @cindex undocumented intrinsic
5778 Intrinsic implemented, documentation pending.
5781 @item @emph{Description}:
5782 @item @emph{Standard}:
5788 @item @emph{Syntax}:
5789 @item @emph{Arguments}:
5790 @item @emph{Return value}:
5791 @item @emph{Example}:
5793 @item @emph{Specific names}:
5794 @multitable @columnfractions .20 .20 .20 .40
5795 @item Name @tab Argument @tab Return type @tab Standard
5796 @item @code{MAX0(I)} @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)} @tab F77 and later
5797 @item @code{AMAX0(I)} @tab @code{INTEGER(4) I} @tab @code{REAL(MAX(X))} @tab F77 and later
5798 @item @code{MAX1(X)} @tab @code{REAL(*) X} @tab @code{INT(MAX(X))} @tab F77 and later
5799 @item @code{AMAX1(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab F77 and later
5800 @item @code{DMAX1(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
5803 @item @emph{See also}:
5804 @ref{MAXLOC} @ref{MAXVAL}
5809 @section @code{MAXEXPONENT} --- Maximum exponent of a real kind
5810 @findex @code{MAXEXPONENT} intrinsic
5814 @item @emph{Description}:
5815 @code{MAXEXPONENT(X)} returns the maximum exponent in the model of the
5818 @item @emph{Standard}:
5824 @item @emph{Syntax}:
5825 @code{I = MAXEXPONENT(X)}
5827 @item @emph{Arguments}:
5828 @multitable @columnfractions .15 .80
5829 @item @var{X} @tab shall be of type @code{REAL}.
5832 @item @emph{Return value}:
5833 The return value is of type @code{INTEGER} and of the default integer
5836 @item @emph{Example}:
5842 print *, minexponent(x), maxexponent(x)
5843 print *, minexponent(y), maxexponent(y)
5844 end program exponents
5850 @section @code{MAXLOC} --- Location of the maximum value within an array
5851 @findex @code{MAXLOC} intrinsic
5852 @cindex undocumented intrinsic
5854 Intrinsic implemented, documentation pending.
5857 @item @emph{Description}:
5858 @item @emph{Standard}:
5862 Transformational function
5864 @item @emph{Syntax}:
5865 @item @emph{Arguments}:
5866 @item @emph{Return value}:
5867 @item @emph{Example}:
5868 @item @emph{See also}:
5869 @ref{MAX}, @ref{MAXVAL}
5875 @section @code{MAXVAL} --- Maximum value of an array
5876 @findex @code{MAXVAL} intrinsic
5877 @cindex undocumented intrinsic
5879 Intrinsic implemented, documentation pending.
5882 @item @emph{Description}:
5883 @item @emph{Standard}:
5887 Transformational function
5889 @item @emph{Syntax}:
5890 @item @emph{Arguments}:
5891 @item @emph{Return value}:
5892 @item @emph{Example}:
5893 @item @emph{Specific names}:
5895 @item @emph{See also}:
5896 @ref{MAX}, @ref{MAXLOC}
5903 @section @code{MERGE} --- Merge arrays
5904 @findex @code{MERGE} intrinsic
5905 @cindex undocumented intrinsic
5907 Intrinsic implemented, documentation pending.
5910 @item @emph{Description}:
5911 @item @emph{Standard}:
5917 @item @emph{Syntax}:
5918 @item @emph{Arguments}:
5919 @item @emph{Return value}:
5920 @item @emph{Example}:
5921 @item @emph{Specific names}:
5922 @item @emph{See also}:
5927 @section @code{MIN} --- Minimum value of an argument list
5928 @findex @code{MIN} intrinsic
5929 @cindex undocumented intrinsic
5931 Intrinsic implemented, documentation pending.
5934 @item @emph{Description}:
5935 @item @emph{Standard}:
5941 @item @emph{Syntax}:
5942 @item @emph{Arguments}:
5943 @item @emph{Return value}:
5944 @item @emph{Example}:
5946 @item @emph{Specific names}:
5947 @multitable @columnfractions .20 .20 .20 .40
5948 @item Name @tab Argument @tab Return type @tab Standard
5949 @item @code{MIN0(I)} @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)} @tab F77 and later
5950 @item @code{AMIN0(I)} @tab @code{INTEGER(4) I} @tab @code{REAL(MIN(X))} @tab F77 and later
5951 @item @code{MIN1(X)} @tab @code{REAL(*) X} @tab @code{INT(MIN(X))} @tab F77 and later
5952 @item @code{AMIN1(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab F77 and later
5953 @item @code{DMIN1(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
5956 @item @emph{See also}:
5957 @ref{MINLOC}, @ref{MINVAL}
5961 @section @code{MINEXPONENT} --- Minimum exponent of a real kind
5962 @findex @code{MINEXPONENT} intrinsic
5966 @item @emph{Description}:
5967 @code{MINEXPONENT(X)} returns the minimum exponent in the model of the
5970 @item @emph{Standard}:
5976 @item @emph{Syntax}:
5977 @code{I = MINEXPONENT(X)}
5979 @item @emph{Arguments}:
5980 @multitable @columnfractions .15 .80
5981 @item @var{X} @tab shall be of type @code{REAL}.
5984 @item @emph{Return value}:
5985 The return value is of type @code{INTEGER} and of the default integer
5988 @item @emph{Example}:
5989 See @code{MAXEXPONENT} for an example.
5994 @section @code{MINLOC} --- Location of the minimum value within an array
5995 @findex @code{MINLOC} intrinsic
5996 @cindex undocumented intrinsic
5998 Intrinsic implemented, documentation pending.
6001 @item @emph{Description}:
6002 @item @emph{Standard}:
6006 Transformational function
6008 @item @emph{Syntax}:
6009 @item @emph{Arguments}:
6010 @item @emph{Return value}:
6011 @item @emph{Example}:
6013 @item @emph{See also}:
6014 @ref{MIN}, @ref{MINVAL}
6020 @section @code{MINVAL} --- Minimum value of an array
6021 @findex @code{MINVAL} intrinsic
6022 @cindex undocumented intrinsic
6024 Intrinsic implemented, documentation pending.
6027 @item @emph{Description}:
6028 @item @emph{Standard}:
6032 Transformational function
6034 @item @emph{Syntax}:
6035 @item @emph{Arguments}:
6036 @item @emph{Return value}:
6037 @item @emph{Example}:
6039 @item @emph{See also}:
6040 @ref{MIN}, @ref{MINLOC}
6047 @section @code{MOD} --- Remainder function
6048 @findex @code{MOD} intrinsic
6049 @findex @code{AMOD} intrinsic
6050 @findex @code{DMOD} intrinsic
6054 @item @emph{Description}:
6055 @code{MOD(A,P)} computes the remainder of the division of A by P. It is
6056 calculated as @code{A - (INT(A/P) * P)}.
6058 @item @emph{Standard}:
6064 @item @emph{Syntax}:
6067 @item @emph{Arguments}:
6068 @multitable @columnfractions .15 .80
6069 @item @var{A} @tab shall be a scalar of type @code{INTEGER} or @code{REAL}
6070 @item @var{P} @tab shall be a scalar of the same type as @var{A} and not
6074 @item @emph{Return value}:
6075 The kind of the return value is the result of cross-promoting
6076 the kinds of the arguments.
6078 @item @emph{Example}:
6082 print *, mod(17.5,5.5)
6083 print *, mod(17.5d0,5.5)
6084 print *, mod(17.5,5.5d0)
6087 print *, mod(-17.5,5.5)
6088 print *, mod(-17.5d0,5.5)
6089 print *, mod(-17.5,5.5d0)
6092 print *, mod(17.5,-5.5)
6093 print *, mod(17.5d0,-5.5)
6094 print *, mod(17.5,-5.5d0)
6095 end program test_mod
6098 @item @emph{Specific names}:
6099 @multitable @columnfractions .20 .20 .20 .40
6100 @item Name @tab Arguments @tab Return type @tab Standard
6101 @item @code{AMOD(A,P)} @tab @code{REAL(4)} @tab @code{REAL(4)} @tab F95 and later
6102 @item @code{DMOD(A,P)} @tab @code{REAL(8)} @tab @code{REAL(8)} @tab F95 and later
6109 @section @code{MODULO} --- Modulo function
6110 @findex @code{MODULO} intrinsic
6114 @item @emph{Description}:
6115 @code{MODULO(A,P)} computes the @var{A} modulo @var{P}.
6117 @item @emph{Standard}:
6123 @item @emph{Syntax}:
6124 @code{X = MODULO(A,P)}
6126 @item @emph{Arguments}:
6127 @multitable @columnfractions .15 .80
6128 @item @var{A} @tab shall be a scalar of type @code{INTEGER} or @code{REAL}
6129 @item @var{P} @tab shall be a scalar of the same type and kind as @var{A}
6132 @item @emph{Return value}:
6133 The type and kind of the result are those of the arguments.
6135 @item If @var{A} and @var{P} are of type @code{INTEGER}:
6136 @code{MODULO(A,P)} has the value @var{R} such that @code{A=Q*P+R}, where
6137 @var{Q} is an integer and @var{R} is between 0 (inclusive) and @var{P}
6139 @item If @var{A} and @var{P} are of type @code{REAL}:
6140 @code{MODULO(A,P)} has the value of @code{A - FLOOR (A / P) * P}.
6142 In all cases, if @var{P} is zero the result is processor-dependent.
6144 @item @emph{Example}:
6147 print *, modulo(17,3)
6148 print *, modulo(17.5,5.5)
6150 print *, modulo(-17,3)
6151 print *, modulo(-17.5,5.5)
6153 print *, modulo(17,-3)
6154 print *, modulo(17.5,-5.5)
6155 end program test_mod
6163 @section @code{MVBITS} --- Move bits from one integer to another
6164 @findex @code{MVBITS} intrinsic
6165 @cindex bit operations
6167 Intrinsic implemented, documentation pending.
6170 @item @emph{Description}:
6171 @item @emph{Standard}:
6175 Elemental subroutine
6177 @item @emph{Syntax}:
6178 @item @emph{Arguments}:
6179 @item @emph{Return value}:
6180 @item @emph{Example}:
6181 @item @emph{See also}:
6188 @section @code{MOVE_ALLOC} --- Move allocation from one object to another
6189 @findex @code{MOVE_ALLOC} intrinsic
6193 @item @emph{Description}:
6194 @code{MOVE_ALLOC(SRC, DEST)} moves the allocation from @var{SRC} to
6195 @var{DEST}. @var{SRC} will become deallocated in the process.
6197 @item @emph{Standard}:
6203 @item @emph{Syntax}:
6204 @code{CALL MOVE_ALLOC(SRC, DEST)}
6206 @item @emph{Arguments}:
6207 @multitable @columnfractions .15 .80
6208 @item @var{SRC} @tab @code{ALLOCATABLE}, @code{INTENT(INOUT)}, may be of any type and kind.
6209 @item @var{DEST} @tab @code{ALLOCATABLE}, @code{INTENT(OUT)}, shall be of the same type, kind and rank as @var{SRC}
6212 @item @emph{Return value}:
6215 @item @emph{Example}:
6217 program test_move_alloc
6218 integer, allocatable :: a(:), b(:)
6222 call move_alloc(a, b)
6223 print *, allocated(a), allocated(b)
6225 end program test_move_alloc
6232 @section @code{NEAREST} --- Nearest representable number
6233 @findex @code{NEAREST} intrinsic
6234 @cindex processor-representable number
6237 @item @emph{Description}:
6238 @code{NEAREST(X, S)} returns the processor-representable number nearest
6239 to @code{X} in the direction indicated by the sign of @code{S}.
6241 @item @emph{Standard}:
6247 @item @emph{Syntax}:
6248 @code{Y = NEAREST(X, S)}
6250 @item @emph{Arguments}:
6251 @multitable @columnfractions .15 .80
6252 @item @var{X} @tab shall be of type @code{REAL}.
6253 @item @var{S} @tab (Optional) shall be of type @code{REAL} and
6257 @item @emph{Return value}:
6258 The return value is of the same type as @code{X}. If @code{S} is
6259 positive, @code{NEAREST} returns the processor-representable number
6260 greater than @code{X} and nearest to it. If @code{S} is negative,
6261 @code{NEAREST} returns the processor-representable number smaller than
6262 @code{X} and nearest to it.
6264 @item @emph{Example}:
6266 program test_nearest
6268 x = nearest(42.0, 1.0)
6269 y = nearest(42.0, -1.0)
6270 write (*,"(3(G20.15))") x, y, x - y
6271 end program test_nearest
6278 @section @code{NEW_LINE} --- New line character
6279 @findex @code{NEW_LINE} intrinsic
6280 @findex @code{NEW_LINE} intrinsic
6283 @item @emph{Description}:
6284 @code{NEW_LINE(C)} returns the new-line character
6286 @item @emph{Standard}:
6292 @item @emph{Syntax}:
6293 @code{C = NEW_LINE(C)}
6295 @item @emph{Arguments}:
6296 @multitable @columnfractions .15 .80
6297 @item @var{C} @tab The argument shall be a scalar or array of the
6298 type @code{CHARACTER}.
6301 @item @emph{Return value}:
6302 Returns a @var{CHARACTER} scalar of length one with the new-line character of
6303 the same kind as parameter @var{C}.
6305 @item @emph{Example}:
6309 write(*,'(A)') 'This is record 1.'//NEW_LINE('A')//'This is record 2.'
6317 @section @code{NINT} --- Nearest whole number
6318 @findex @code{NINT} intrinsic
6319 @findex @code{IDNINT} intrinsic
6320 @cindex whole number
6323 @item @emph{Description}:
6324 @code{NINT(X)} rounds its argument to the nearest whole number.
6326 @item @emph{Standard}:
6332 @item @emph{Syntax}:
6335 @item @emph{Arguments}:
6336 @multitable @columnfractions .15 .80
6337 @item @var{X} @tab The type of the argument shall be @code{REAL}.
6340 @item @emph{Return value}:
6341 Returns @var{A} with the fractional portion of its magnitude eliminated by
6342 rounding to the nearest whole number and with its sign preserved,
6343 converted to an @code{INTEGER} of the default kind.
6345 @item @emph{Example}:
6352 print *, nint(x4), idnint(x8)
6353 end program test_nint
6356 @item @emph{Specific names}:
6357 @multitable @columnfractions .33 .33 .33
6358 @item Name @tab Argument @tab Standard
6359 @item @code{IDNINT(X)} @tab @code{REAL(8)} @tab F95 and later
6362 @item @emph{See also}:
6363 @ref{CEILING}, @ref{FLOOR}
6369 @section @code{NOT} --- Logical negation
6370 @findex @code{NOT} intrinsic
6371 @cindex logical operations
6373 Intrinsic implemented, documentation pending.
6376 @item @emph{Description}:
6377 @item @emph{Standard}:
6383 @item @emph{Syntax}:
6384 @item @emph{Arguments}:
6385 @item @emph{Return value}:
6386 @item @emph{Example}:
6387 @item @emph{See also}:
6394 @section @code{NULL} --- Function that returns an disassociated pointer
6395 @findex @code{NULL} intrinsic
6396 @cindex undocumented intrinsic
6398 Intrinsic implemented, documentation pending.
6401 @item @emph{Description}:
6402 @item @emph{Standard}:
6406 Transformational function
6408 @item @emph{Syntax}:
6409 @item @emph{Arguments}:
6410 @item @emph{Return value}:
6411 @item @emph{Example}:
6412 @item @emph{See also}:
6420 @section @code{OR} --- Bitwise logical OR
6421 @findex @code{OR} intrinsic
6422 @cindex bit operations
6425 @item @emph{Description}:
6426 Bitwise logical @code{OR}.
6428 This intrinsic routine is provided for backwards compatibility with
6429 GNU Fortran 77. For integer arguments, programmers should consider
6430 the use of the @ref{IOR} intrinsic defined by the Fortran standard.
6432 @item @emph{Standard}:
6436 Non-elemental function
6438 @item @emph{Syntax}:
6439 @code{RESULT = OR(X, Y)}
6441 @item @emph{Arguments}:
6442 @multitable @columnfractions .15 .80
6443 @item @var{X} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
6444 @item @var{Y} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
6447 @item @emph{Return value}:
6448 The return type is either @code{INTEGER(*)} or @code{LOGICAL}
6449 after cross-promotion of the arguments.
6451 @item @emph{Example}:
6454 LOGICAL :: T = .TRUE., F = ..FALSE.
6456 DATA a / Z'F' /, b / Z'3' /
6458 WRITE (*,*) OR(T, T), OR(T, F), OR(F, T), OR(F, F)
6459 WRITE (*,*) OR(a, b)
6463 @item @emph{See also}:
6464 F95 elemental function: @ref{IOR}
6471 @section @code{PACK} --- Pack an array into an array of rank one
6472 @findex @code{PACK} intrinsic
6473 @cindex undocumented intrinsic
6475 Intrinsic implemented, documentation pending.
6478 @item @emph{Description}:
6479 @item @emph{Standard}:
6483 Transformational function
6485 @item @emph{Syntax}:
6486 @item @emph{Arguments}:
6487 @item @emph{Return value}:
6488 @item @emph{Example}:
6489 @item @emph{Specific names}:
6490 @item @emph{See also}:
6498 @section @code{PERROR} --- Print system error message
6499 @findex @code{PERROR} intrinsic
6500 @cindex undocumented intrinsic
6502 Intrinsic implemented, documentation pending.
6505 @item @emph{Description}:
6506 @item @emph{Standard}:
6512 @item @emph{Syntax}:
6513 @item @emph{Arguments}:
6514 @item @emph{Return value}:
6515 @item @emph{Example}:
6516 @item @emph{Specific names}:
6517 @item @emph{See also}:
6525 @section @code{PRECISION} --- Decimal precision of a real kind
6526 @findex @code{PRECISION} intrinsic
6530 @item @emph{Description}:
6531 @code{PRECISION(X)} returns the decimal precision in the model of the
6534 @item @emph{Standard}:
6540 @item @emph{Syntax}:
6541 @code{I = PRECISION(X)}
6543 @item @emph{Arguments}:
6544 @multitable @columnfractions .15 .80
6545 @item @var{X} @tab shall be of type @code{REAL} or @code{COMPLEX}.
6548 @item @emph{Return value}:
6549 The return value is of type @code{INTEGER} and of the default integer
6552 @item @emph{Example}:
6554 program prec_and_range
6555 real(kind=4) :: x(2)
6556 complex(kind=8) :: y
6558 print *, precision(x), range(x)
6559 print *, precision(y), range(y)
6560 end program prec_and_range
6567 @section @code{PRESENT} --- Determine whether an optional argument is specified
6568 @findex @code{PRESENT} intrinsic
6569 @cindex undocumented intrinsic
6571 Intrinsic implemented, documentation pending.
6574 @item @emph{Description}:
6575 @item @emph{Standard}:
6581 @item @emph{Syntax}:
6582 @item @emph{Arguments}:
6583 @item @emph{Return value}:
6584 @item @emph{Example}:
6585 @item @emph{See also}:
6592 @section @code{PRODUCT} --- Product of array elements
6593 @findex @code{PRODUCT} intrinsic
6594 @cindex undocumented intrinsic
6596 Intrinsic implemented, documentation pending.
6599 @item @emph{Description}:
6600 @item @emph{Standard}:
6604 Transformational function
6606 @item @emph{Syntax}:
6607 @item @emph{Arguments}:
6608 @item @emph{Return value}:
6609 @item @emph{Example}:
6610 @item @emph{Specific names}:
6611 @item @emph{See also}:
6619 @section @code{RADIX} --- Base of a model number
6620 @findex @code{RADIX} intrinsic
6624 @item @emph{Description}:
6625 @code{RADIX(X)} returns the base of the model representing the entity @var{X}.
6627 @item @emph{Standard}:
6633 @item @emph{Syntax}:
6636 @item @emph{Arguments}:
6637 @multitable @columnfractions .15 .80
6638 @item @var{X} @tab Shall be of type @code{INTEGER} or @code{REAL}
6641 @item @emph{Return value}:
6642 The return value is a scalar of type @code{INTEGER} and of the default
6645 @item @emph{Example}:
6648 print *, "The radix for the default integer kind is", radix(0)
6649 print *, "The radix for the default real kind is", radix(0.0)
6650 end program test_radix
6658 @section @code{RANDOM_NUMBER} --- Pseudo-random number
6659 @findex @code{RANDOM_NUMBER} intrinsic
6660 @cindex random numbers
6662 Intrinsic implemented, documentation pending.
6665 @item @emph{Description}:
6666 @item @emph{Standard}:
6670 Elemental subroutine
6672 @item @emph{Syntax}:
6673 @item @emph{Arguments}:
6674 @item @emph{Return value}:
6675 @item @emph{Example}:
6676 @item @emph{See also}:
6684 @section @code{RANDOM_SEED} --- Initialize a pseudo-random number sequence
6685 @findex @code{RANDOM_SEED} intrinsic
6686 @cindex random numbers
6688 Intrinsic implemented, documentation pending.
6691 @item @emph{Description}:
6692 @item @emph{Standard}:
6698 @item @emph{Syntax}:
6699 @item @emph{Arguments}:
6700 @item @emph{Return value}:
6701 @item @emph{Example}:
6702 @item @emph{See also}:
6710 @section @code{RAND} --- Real pseudo-random number
6711 @findex @code{RAND} intrinsic
6712 @findex @code{RAN} intrinsic
6713 @cindex random number
6716 @item @emph{Description}:
6717 @code{RAND(FLAG)} returns a pseudo-random number from a uniform
6718 distribution between 0 and 1. If @var{FLAG} is 0, the next number
6719 in the current sequence is returned; if @var{FLAG} is 1, the generator
6720 is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
6721 it is used as a new seed with @code{SRAND}.
6723 @item @emph{Standard}:
6727 non-elemental function
6729 @item @emph{Syntax}:
6730 @code{X = RAND(FLAG)}
6732 @item @emph{Arguments}:
6733 @multitable @columnfractions .15 .80
6734 @item @var{FLAG} @tab shall be a scalar @code{INTEGER} of kind 4.
6737 @item @emph{Return value}:
6738 The return value is of @code{REAL} type and the default kind.
6740 @item @emph{Example}:
6743 integer,parameter :: seed = 86456
6746 print *, rand(), rand(), rand(), rand()
6747 print *, rand(seed), rand(), rand(), rand()
6748 end program test_rand
6752 For compatibility with HP FORTRAN 77/iX, the @code{RAN} intrinsic is
6753 provided as an alias for @code{RAND}.
6755 @item @emph{See also}:
6756 @ref{SRAND}, @ref{RANDOM_NUMBER}
6763 @section @code{RANGE} --- Decimal exponent range of a real kind
6764 @findex @code{RANGE} intrinsic
6768 @item @emph{Description}:
6769 @code{RANGE(X)} returns the decimal exponent range in the model of the
6772 @item @emph{Standard}:
6778 @item @emph{Syntax}:
6781 @item @emph{Arguments}:
6782 @multitable @columnfractions .15 .80
6783 @item @var{X} @tab shall be of type @code{REAL} or @code{COMPLEX}.
6786 @item @emph{Return value}:
6787 The return value is of type @code{INTEGER} and of the default integer
6790 @item @emph{Example}:
6791 See @code{PRECISION} for an example.
6797 @section @code{RAN} --- Real pseudo-random number
6798 @findex @code{RAN} intrinsic
6799 @cindex random number
6802 @item @emph{Standard}:
6805 @item @emph{See also}:
6806 @ref{RAND}, @ref{RANDOM_NUMBER}
6812 @section @code{REAL} --- Convert to real type
6813 @findex @code{REAL} intrinsic
6814 @findex @code{REALPART} intrinsic
6818 @item @emph{Description}:
6819 @code{REAL(X [, KIND])} converts its argument @var{X} to a real type. The
6820 @code{REALPART(X)} function is provided for compatibility with @command{g77},
6821 and its use is strongly discouraged.
6823 @item @emph{Standard}:
6829 @item @emph{Syntax}:
6830 @multitable @columnfractions .30 .80
6831 @item @code{X = REAL(X)}
6832 @item @code{X = REAL(X, KIND)}
6833 @item @code{X = REALPART(Z)}
6836 @item @emph{Arguments}:
6837 @multitable @columnfractions .15 .80
6838 @item @var{X} @tab shall be @code{INTEGER(*)}, @code{REAL(*)}, or
6840 @item @var{KIND} @tab (Optional) @var{KIND} shall be a scalar integer.
6843 @item @emph{Return value}:
6844 These functions return a @code{REAL(*)} variable or array under
6845 the following rules:
6849 @code{REAL(X)} is converted to a default real type if @var{X} is an
6850 integer or real variable.
6852 @code{REAL(X)} is converted to a real type with the kind type parameter
6853 of @var{X} if @var{X} is a complex variable.
6855 @code{REAL(X, KIND)} is converted to a real type with kind type
6856 parameter @var{KIND} if @var{X} is a complex, integer, or real
6860 @item @emph{Example}:
6863 complex :: x = (1.0, 2.0)
6864 print *, real(x), real(x,8), realpart(x)
6865 end program test_real
6868 @item @emph{See also}:
6869 @ref{DBLE}, @ref{DFLOAT}, @ref{FLOAT}
6875 @section @code{RENAME} --- Rename a file
6876 @findex @code{RENAME} intrinsic
6877 @cindex file system operations
6879 Intrinsic implemented, documentation pending.
6882 @item @emph{Description}:
6883 @item @emph{Standard}:
6889 @item @emph{Syntax}:
6890 @item @emph{Arguments}:
6891 @item @emph{Return value}:
6892 @item @emph{Example}:
6893 @item @emph{See also}:
6900 @section @code{REPEAT} --- Repeated string concatenation
6901 @findex @code{REPEAT} intrinsic
6902 @cindex string manipulation
6904 Intrinsic implemented, documentation pending.
6907 @item @emph{Description}:
6908 @item @emph{Standard}:
6912 Transformational function
6914 @item @emph{Syntax}:
6915 @item @emph{Arguments}:
6916 @item @emph{Return value}:
6917 @item @emph{Example}:
6918 @item @emph{See also}:
6925 @section @code{RESHAPE} --- Function to reshape an array
6926 @findex @code{RESHAPE} intrinsic
6927 @cindex array manipulation
6929 Intrinsic implemented, documentation pending.
6932 @item @emph{Description}:
6933 @item @emph{Standard}:
6937 Transformational function
6939 @item @emph{Syntax}:
6940 @item @emph{Arguments}:
6941 @item @emph{Return value}:
6942 @item @emph{Example}:
6943 @item @emph{See also}:
6950 @section @code{RRSPACING} --- Reciprocal of the relative spacing
6951 @findex @code{RRSPACING} intrinsic
6954 @item @emph{Description}:
6955 @code{RRSPACING(X)} returns the reciprocal of the relative spacing of
6956 model numbers near @var{X}.
6958 @item @emph{Standard}:
6964 @item @emph{Syntax}:
6965 @code{Y = RRSPACING(X)}
6967 @item @emph{Arguments}:
6968 @multitable @columnfractions .15 .80
6969 @item @var{X} @tab shall be of type @code{REAL}.
6972 @item @emph{Return value}:
6973 The return value is of the same type and kind as @var{X}.
6974 The value returned is equal to
6975 @code{ABS(FRACTION(X)) * FLOAT(RADIX(X))**DIGITS(X)}.
6982 @section @code{RSHIFT} --- Right shift bits
6983 @findex @code{RSHIFT}
6984 @cindex bit manipulation
6986 Not yet implemented in GNU Fortran.
6989 @item @emph{Description}:
6991 @item @emph{Standard}:
6997 @item @emph{Syntax}:
6998 @item @emph{Arguments}:
6999 @item @emph{Return value}:
7000 @item @emph{Example}:
7001 @item @emph{See also}:
7008 @section @code{SCALE} --- Scale a real value
7009 @findex @code{SCALE} intrinsic
7012 @item @emph{Description}:
7013 @code{SCALE(X,I)} returns @code{X * RADIX(X)**I}.
7015 @item @emph{Standard}:
7021 @item @emph{Syntax}:
7022 @code{Y = SCALE(X, I)}
7024 @item @emph{Arguments}:
7025 @multitable @columnfractions .15 .80
7026 @item @var{X} @tab The type of the argument shall be a @code{REAL}.
7027 @item @var{I} @tab The type of the argument shall be a @code{INTEGER}.
7030 @item @emph{Return value}:
7031 The return value is of the same type and kind as @var{X}.
7032 Its value is @code{X * RADIX(X)**I}.
7034 @item @emph{Example}:
7037 real :: x = 178.1387e-4
7039 print *, scale(x,i), x*radix(x)**i
7040 end program test_scale
7047 @section @code{SCAN} --- Scan a string for the presence of a set of characters
7048 @findex @code{SCAN} intrinsic
7049 @cindex string manipulation
7051 Intrinsic implemented, documentation pending.
7054 @item @emph{Description}:
7055 @item @emph{Standard}:
7061 @item @emph{Syntax}:
7062 @item @emph{Arguments}:
7063 @item @emph{Return value}:
7064 @item @emph{Example}:
7065 @item @emph{See also}:
7072 @section @code{SECNDS} --- Time function
7073 @findex @code{SECNDS} intrinsic
7077 @item @emph{Description}:
7078 @code{SECNDS(X)} gets the time in seconds from the real-time system clock.
7079 @var{X} is a reference time, also in seconds. If this is zero, the time in
7080 seconds from midnight is returned. This function is non-standard and its
7083 @item @emph{Standard}:
7089 @item @emph{Syntax}:
7090 @code{T = SECNDS (X)}
7092 @item @emph{Arguments}:
7093 @multitable @columnfractions .15 .80
7094 @item Name @tab Type
7095 @item @var{T} @tab REAL(4)
7096 @item @var{X} @tab REAL(4)
7099 @item @emph{Return value}:
7102 @item @emph{Example}:
7106 print *, secnds (0.0) ! seconds since midnight
7107 t1 = secnds (0.0) ! reference time
7108 do i = 1, 10000000 ! do something
7110 t2 = secnds (t1) ! elapsed time
7111 print *, "Something took ", t2, " seconds."
7112 end program test_secnds
7118 @node SELECTED_INT_KIND
7119 @section @code{SELECTED_INT_KIND} --- Choose integer kind
7120 @findex @code{SELECTED_INT_KIND} intrinsic
7121 @cindex integer kind
7124 @item @emph{Description}:
7125 @code{SELECTED_INT_KIND(I)} return the kind value of the smallest integer
7126 type that can represent all values ranging from @math{-10^I} (exclusive)
7127 to @math{10^I} (exclusive). If there is no integer kind that accommodates
7128 this range, @code{SELECTED_INT_KIND} returns @math{-1}.
7130 @item @emph{Standard}:
7134 Transformational function
7136 @item @emph{Syntax}:
7137 @multitable @columnfractions .30 .80
7138 @item @code{J = SELECTED_INT_KIND(I)}
7141 @item @emph{Arguments}:
7142 @multitable @columnfractions .15 .80
7143 @item @var{I} @tab shall be a scalar and of type @code{INTEGER}.
7146 @item @emph{Example}:
7148 program large_integers
7149 integer,parameter :: k5 = selected_int_kind(5)
7150 integer,parameter :: k15 = selected_int_kind(15)
7151 integer(kind=k5) :: i5
7152 integer(kind=k15) :: i15
7154 print *, huge(i5), huge(i15)
7156 ! The following inequalities are always true
7157 print *, huge(i5) >= 10_k5**5-1
7158 print *, huge(i15) >= 10_k15**15-1
7159 end program large_integers
7165 @node SELECTED_REAL_KIND
7166 @section @code{SELECTED_REAL_KIND} --- Choose real kind
7167 @findex @code{SELECTED_REAL_KIND} intrinsic
7171 @item @emph{Description}:
7172 @code{SELECTED_REAL_KIND(P,R)} return the kind value of a real data type
7173 with decimal precision greater of at least @code{P} digits and exponent
7174 range greater at least @code{R}.
7176 @item @emph{Standard}:
7180 Transformational function
7182 @item @emph{Syntax}:
7183 @multitable @columnfractions .30 .80
7184 @item @code{I = SELECTED_REAL_KIND(P,R)}
7187 @item @emph{Arguments}:
7188 @multitable @columnfractions .15 .80
7189 @item @var{P} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
7190 @item @var{R} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
7192 At least one argument shall be present.
7194 @item @emph{Return value}:
7196 @code{SELECTED_REAL_KIND} returns the value of the kind type parameter of
7197 a real data type with decimal precision of at least @code{P} digits and a
7198 decimal exponent range of at least @code{R}. If more than one real data
7199 type meet the criteria, the kind of the data type with the smallest
7200 decimal precision is returned. If no real data type matches the criteria,
7203 @item -1 if the processor does not support a real data type with a
7204 precision greater than or equal to @code{P}
7205 @item -2 if the processor does not support a real type with an exponent
7206 range greater than or equal to @code{R}
7207 @item -3 if neither is supported.
7210 @item @emph{Example}:
7213 integer,parameter :: p6 = selected_real_kind(6)
7214 integer,parameter :: p10r100 = selected_real_kind(10,100)
7215 integer,parameter :: r400 = selected_real_kind(r=400)
7217 real(kind=p10r100) :: y
7218 real(kind=r400) :: z
7220 print *, precision(x), range(x)
7221 print *, precision(y), range(y)
7222 print *, precision(z), range(z)
7223 end program real_kinds
7230 @section @code{SET_EXPONENT} --- Set the exponent of the model
7231 @findex @code{SET_EXPONENT} intrinsic
7235 @item @emph{Description}:
7236 @code{SET_EXPONENT(X, I)} returns the real number whose fractional part
7237 is that that of @var{X} and whose exponent part if @var{I}.
7239 @item @emph{Standard}:
7245 @item @emph{Syntax}:
7246 @code{Y = SET_EXPONENT(X, I)}
7248 @item @emph{Arguments}:
7249 @multitable @columnfractions .15 .80
7250 @item @var{X} @tab shall be of type @code{REAL}.
7251 @item @var{I} @tab shall be of type @code{INTEGER}.
7254 @item @emph{Return value}:
7255 The return value is of the same type and kind as @var{X}.
7256 The real number whose fractional part
7257 is that that of @var{X} and whose exponent part if @var{I} is returned;
7258 it is @code{FRACTION(X) * RADIX(X)**I}.
7260 @item @emph{Example}:
7263 real :: x = 178.1387e-4
7265 print *, set_exponent(x), fraction(x) * radix(x)**i
7266 end program test_setexp
7274 @section @code{SHAPE} --- Determine the shape of an array
7275 @findex @code{SHAPE} intrinsic
7276 @cindex array manipulation
7278 Intrinsic implemented, documentation pending.
7281 @item @emph{Description}:
7282 @item @emph{Standard}:
7288 @item @emph{Syntax}:
7289 @item @emph{Arguments}:
7290 @item @emph{Return value}:
7291 @item @emph{Example}:
7292 @item @emph{See also}:
7300 @section @code{SIGN} --- Sign copying function
7301 @findex @code{SIGN} intrinsic
7302 @findex @code{ISIGN} intrinsic
7303 @findex @code{DSIGN} intrinsic
7304 @cindex sign copying
7307 @item @emph{Description}:
7308 @code{SIGN(A,B)} returns the value of @var{A} with the sign of @var{B}.
7310 @item @emph{Standard}:
7316 @item @emph{Syntax}:
7317 @code{X = SIGN(A,B)}
7319 @item @emph{Arguments}:
7320 @multitable @columnfractions .15 .80
7321 @item @var{A} @tab shall be a scalar of type @code{INTEGER} or @code{REAL}
7322 @item @var{B} @tab shall be a scalar of the same type and kind as @var{A}
7325 @item @emph{Return value}:
7326 The kind of the return value is that of @var{A} and @var{B}.
7327 If @math{B\ge 0} then the result is @code{ABS(A)}, else
7328 it is @code{-ABS(A)}.
7330 @item @emph{Example}:
7333 print *, sign(-12,1)
7334 print *, sign(-12,0)
7335 print *, sign(-12,-1)
7337 print *, sign(-12.,1.)
7338 print *, sign(-12.,0.)
7339 print *, sign(-12.,-1.)
7340 end program test_sign
7343 @item @emph{Specific names}:
7344 @multitable @columnfractions .20 .20 .20 .40
7345 @item Name @tab Arguments @tab Return type @tab Standard
7346 @item @code{ISIGN(A,P)} @tab @code{INTEGER(4)} @tab @code{INTEGER(4)} @tab f95, gnu
7347 @item @code{DSIGN(A,P)} @tab @code{REAL(8)} @tab @code{REAL(8)} @tab f95, gnu
7354 @section @code{SIGNAL} --- Signal handling subroutine (or function)
7355 @findex @code{SIGNAL} intrinsic
7356 @cindex SIGNAL subroutine
7359 @item @emph{Description}:
7360 @code{SIGNAL(NUMBER, HANDLER [, STATUS])} causes external subroutine
7361 @var{HANDLER} to be executed with a single integer argument when signal
7362 @var{NUMBER} occurs. If @var{HANDLER} is an integer, it can be used to
7363 turn off handling of signal @var{NUMBER} or revert to its default
7364 action. See @code{signal(2)}.
7366 If @code{SIGNAL} is called as a subroutine and the @var{STATUS} argument
7367 is supplied, it is set to the value returned by @code{signal(2)}.
7369 @item @emph{Standard}:
7373 subroutine, non-elemental function
7375 @item @emph{Syntax}:
7376 @multitable @columnfractions .30 .80
7377 @item @code{CALL ALARM(NUMBER, HANDLER)}
7378 @item @code{CALL ALARM(NUMBER, HANDLER, STATUS)}
7379 @item @code{STATUS = ALARM(NUMBER, HANDLER)}
7382 @item @emph{Arguments}:
7383 @multitable @columnfractions .15 .80
7384 @item @var{NUMBER} @tab shall be a scalar integer, with @code{INTENT(IN)}
7385 @item @var{HANDLER}@tab Signal handler (@code{INTEGER FUNCTION} or
7386 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar.
7387 @code{INTEGER}. It is @code{INTENT(IN)}.
7388 @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
7389 integer. It has @code{INTENT(OUT)}.
7392 @item @emph{Return value}:
7393 The @code{SIGNAL} functions returns the value returned by @code{signal(2)}.
7395 @item @emph{Example}:
7399 external handler_print
7401 call signal (12, handler_print)
7405 end program test_signal
7413 @section @code{SIN} --- Sine function
7414 @findex @code{SIN} intrinsic
7415 @findex @code{DSIN} intrinsic
7416 @findex @code{ZSIN} intrinsic
7417 @findex @code{CDSIN} intrinsic
7418 @cindex trigonometric functions
7421 @item @emph{Description}:
7422 @code{SIN(X)} computes the sine of @var{X}.
7424 @item @emph{Standard}:
7430 @item @emph{Syntax}:
7433 @item @emph{Arguments}:
7434 @multitable @columnfractions .15 .80
7435 @item @var{X} @tab The type shall be @code{REAL(*)} or
7439 @item @emph{Return value}:
7440 The return value has same type and kind as @var{X}.
7442 @item @emph{Example}:
7447 end program test_sin
7450 @item @emph{Specific names}:
7451 @multitable @columnfractions .20 .20 .20 .40
7452 @item Name @tab Argument @tab Return type @tab Standard
7453 @item @code{DSIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
7454 @item @code{CSIN(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab f95, gnu
7455 @item @code{ZSIN(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
7456 @item @code{CDSIN(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
7459 @item @emph{See also}:
7466 @section @code{SINH} --- Hyperbolic sine function
7467 @findex @code{SINH} intrinsic
7468 @findex @code{DSINH} intrinsic
7469 @cindex hyperbolic sine
7472 @item @emph{Description}:
7473 @code{SINH(X)} computes the hyperbolic sine of @var{X}.
7475 @item @emph{Standard}:
7481 @item @emph{Syntax}:
7484 @item @emph{Arguments}:
7485 @multitable @columnfractions .15 .80
7486 @item @var{X} @tab The type shall be @code{REAL(*)}.
7489 @item @emph{Return value}:
7490 The return value is of type @code{REAL(*)}.
7492 @item @emph{Example}:
7495 real(8) :: x = - 1.0_8
7497 end program test_sinh
7500 @item @emph{Specific names}:
7501 @multitable @columnfractions .20 .20 .20 .40
7502 @item Name @tab Argument @tab Return type @tab Standard
7503 @item @code{DSINH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
7506 @item @emph{See also}:
7513 @section @code{SIZE} --- Determine the size of an array
7514 @findex @code{SIZE} intrinsic
7515 @cindex array manipulation
7517 Intrinsic implemented, documentation pending.
7520 @item @emph{Description}:
7521 @item @emph{Standard}:
7527 @item @emph{Syntax}:
7528 @item @emph{Arguments}:
7529 @item @emph{Return value}:
7530 @item @emph{Example}:
7531 @item @emph{See also}:
7537 @section @code{SNGL} --- Convert double precision real to default real
7538 @findex @code{SNGL} intrinsic
7539 @cindex conversion function (real)
7542 @item @emph{Description}:
7543 @code{SNGL(A)} converts the double precision real @var{A}
7544 to a default real value. This is an archaic form of @code{REAL}
7545 that is specific to one type for @var{A}.
7547 @item @emph{Standard}:
7553 @item @emph{Syntax}:
7556 @item @emph{Arguments}:
7557 @multitable @columnfractions .15 .80
7558 @item @var{A} @tab The type shall be a double precision @code{REAL}.
7561 @item @emph{Return value}:
7562 The return value is of type default @code{REAL}.
7564 @item @emph{See also}:
7571 @section @code{SPACING} --- Smallest distance between two numbers of a given type
7572 @findex @code{SPACING} intrinsic
7573 @cindex undocumented intrinsic
7575 Intrinsic implemented, documentation pending.
7578 @item @emph{Description}:
7579 @item @emph{Standard}:
7585 @item @emph{Syntax}:
7586 @item @emph{Arguments}:
7587 @item @emph{Return value}:
7588 @item @emph{Example}:
7589 @item @emph{See also}:
7596 @section @code{SPREAD} --- Add a dimension to an array
7597 @findex @code{SPREAD} intrinsic
7598 @cindex array manipulation
7600 Intrinsic implemented, documentation pending.
7603 @item @emph{Description}:
7604 @item @emph{Standard}:
7608 Transformational function
7610 @item @emph{Syntax}:
7611 @item @emph{Arguments}:
7612 @item @emph{Return value}:
7613 @item @emph{Example}:
7614 @item @emph{See also}:
7621 @section @code{SQRT} --- Square-root function
7622 @findex @code{SQRT} intrinsic
7623 @findex @code{DSQRT} intrinsic
7624 @findex @code{CSQRT} intrinsic
7625 @findex @code{ZSQRT} intrinsic
7626 @findex @code{CDSQRT} intrinsic
7630 @item @emph{Description}:
7631 @code{SQRT(X)} computes the square root of @var{X}.
7633 @item @emph{Standard}:
7639 @item @emph{Syntax}:
7642 @item @emph{Arguments}:
7643 @multitable @columnfractions .15 .80
7644 @item @var{X} @tab The type shall be @code{REAL(*)} or
7648 @item @emph{Return value}:
7649 The return value is of type @code{REAL(*)} or @code{COMPLEX(*)}.
7650 The kind type parameter is the same as @var{X}.
7652 @item @emph{Example}:
7655 real(8) :: x = 2.0_8
7656 complex :: z = (1.0, 2.0)
7659 end program test_sqrt
7662 @item @emph{Specific names}:
7663 @multitable @columnfractions .20 .20 .20 .40
7664 @item Name @tab Argument @tab Return type @tab Standard
7665 @item @code{DSQRT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
7666 @item @code{CSQRT(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab F95 and later
7667 @item @code{ZSQRT(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
7668 @item @code{CDSQRT(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
7675 @section @code{SRAND} --- Reinitialize the random number generator
7676 @findex @code{SRAND} intrinsic
7677 @cindex random number
7680 @item @emph{Description}:
7681 @code{SRAND} reinitializes the pseudo-random number generator
7682 called by @code{RAND} and @code{IRAND}. The new seed used by the
7683 generator is specified by the required argument @var{SEED}.
7685 @item @emph{Standard}:
7689 non-elemental subroutine
7691 @item @emph{Syntax}:
7692 @code{CALL SRAND(SEED)}
7694 @item @emph{Arguments}:
7695 @multitable @columnfractions .15 .80
7696 @item @var{SEED} @tab shall be a scalar @code{INTEGER(kind=4)}.
7699 @item @emph{Return value}:
7702 @item @emph{Example}:
7703 See @code{RAND} and @code{IRAND} for examples.
7706 The Fortran 2003 standard specifies the intrinsic @code{RANDOM_SEED} to
7707 initialize the pseudo-random numbers generator and @code{RANDOM_NUMBER}
7708 to generate pseudo-random numbers. Please note that in
7709 GNU Fortran, these two sets of intrinsics (@code{RAND},
7710 @code{IRAND} and @code{SRAND} on the one hand, @code{RANDOM_NUMBER} and
7711 @code{RANDOM_SEED} on the other hand) access two independent
7712 pseudo-random number generators.
7714 @item @emph{See also}:
7715 @ref{RAND}, @ref{RANDOM_SEED}, @ref{RANDOM_NUMBER}
7721 @section @code{STAT} --- Get file status
7722 @findex @code{STAT} intrinsic
7723 @cindex file system operations
7726 @item @emph{Description}:
7727 This function returns information about a file. No permissions are required on
7728 the file itself, but execute (search) permission is required on all of the
7729 directories in path that lead to the file.
7731 The elements that are obtained and stored in the array @code{BUFF}:
7732 @multitable @columnfractions .15 .80
7733 @item @code{buff(1)} @tab Device ID
7734 @item @code{buff(2)} @tab Inode number
7735 @item @code{buff(3)} @tab File mode
7736 @item @code{buff(4)} @tab Number of links
7737 @item @code{buff(5)} @tab Owner's uid
7738 @item @code{buff(6)} @tab Owner's gid
7739 @item @code{buff(7)} @tab ID of device containing directory entry for file (0 if not available)
7740 @item @code{buff(8)} @tab File size (bytes)
7741 @item @code{buff(9)} @tab Last access time
7742 @item @code{buff(10)} @tab Last modification time
7743 @item @code{buff(11)} @tab Last file status change time
7744 @item @code{buff(12)} @tab Preferred I/O block size (-1 if not available)
7745 @item @code{buff(13)} @tab Number of blocks allocated (-1 if not available)
7748 Not all these elements are relevant on all systems.
7749 If an element is not relevant, it is returned as 0.
7752 @item @emph{Standard}:
7756 Non-elemental subroutine
7758 @item @emph{Syntax}:
7759 @code{CALL STAT(FILE,BUFF[,STATUS])}
7761 @item @emph{Arguments}:
7762 @multitable @columnfractions .15 .80
7763 @item @var{FILE} @tab The type shall be @code{CHARACTER(*)}, a valid path within the file system.
7764 @item @var{BUFF} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
7765 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0
7766 on success and a system specific error code otherwise.
7769 @item @emph{Example}:
7772 INTEGER, DIMENSION(13) :: buff
7775 CALL STAT("/etc/passwd", buff, status)
7777 IF (status == 0) THEN
7778 WRITE (*, FMT="('Device ID:', T30, I19)") buff(1)
7779 WRITE (*, FMT="('Inode number:', T30, I19)") buff(2)
7780 WRITE (*, FMT="('File mode (octal):', T30, O19)") buff(3)
7781 WRITE (*, FMT="('Number of links:', T30, I19)") buff(4)
7782 WRITE (*, FMT="('Owner''s uid:', T30, I19)") buff(5)
7783 WRITE (*, FMT="('Owner''s gid:', T30, I19)") buff(6)
7784 WRITE (*, FMT="('Device where located:', T30, I19)") buff(7)
7785 WRITE (*, FMT="('File size:', T30, I19)") buff(8)
7786 WRITE (*, FMT="('Last access time:', T30, A19)") CTIME(buff(9))
7787 WRITE (*, FMT="('Last modification time', T30, A19)") CTIME(buff(10))
7788 WRITE (*, FMT="('Last status change time:', T30, A19)") CTIME(buff(11))
7789 WRITE (*, FMT="('Preferred block size:', T30, I19)") buff(12)
7790 WRITE (*, FMT="('No. of blocks allocated:', T30, I19)") buff(13)
7795 @item @emph{See also}:
7796 To stat an open file: @ref{FSTAT}, to stat a link: @ref{LSTAT}
7802 @section @code{SUM} --- Sum of array elements
7803 @findex @code{SUM} intrinsic
7804 @cindex array manipulation
7806 Intrinsic implemented, documentation pending.
7809 @item @emph{Description}:
7810 @item @emph{Standard}:
7814 Transformational function
7816 @item @emph{Syntax}:
7817 @item @emph{Arguments}:
7818 @item @emph{Return value}:
7819 @item @emph{Example}:
7820 @item @emph{See also}:
7828 @section @code{SYMLNK} --- Create a symbolic link
7829 @findex @code{SYMLNK} intrinsic
7830 @cindex file system operations
7832 Intrinsic implemented, documentation pending.
7835 @item @emph{Description}:
7836 @item @emph{Standard}:
7840 @item @emph{Syntax}:
7841 @item @emph{Arguments}:
7842 @item @emph{Return value}:
7843 @item @emph{Example}:
7844 @item @emph{See also}:
7851 @section @code{SYSTEM} --- Execute a shell command
7852 @findex @code{SYSTEM} intrinsic
7853 @cindex undocumented intrinsic
7855 Intrinsic implemented, documentation pending.
7858 @item @emph{Description}:
7859 @item @emph{Standard}:
7865 @item @emph{Syntax}:
7866 @item @emph{Arguments}:
7867 @item @emph{Return value}:
7868 @item @emph{Example}:
7869 @item @emph{See also}:
7876 @section @code{SYSTEM_CLOCK} --- Time function
7877 @findex @code{SYSTEM_CLOCK} intrinsic
7878 @cindex time functions
7880 Intrinsic implemented, documentation pending.
7883 @item @emph{Description}:
7884 @item @emph{Standard}:
7890 @item @emph{Syntax}:
7891 @item @emph{Arguments}:
7892 @item @emph{Return value}:
7893 @item @emph{Example}:
7894 @item @emph{See also}:
7900 @section @code{TAN} --- Tangent function
7901 @findex @code{TAN} intrinsic
7902 @findex @code{DTAN} intrinsic
7903 @cindex trigonometric functions
7906 @item @emph{Description}:
7907 @code{TAN(X)} computes the tangent of @var{X}.
7909 @item @emph{Standard}:
7915 @item @emph{Syntax}:
7918 @item @emph{Arguments}:
7919 @multitable @columnfractions .15 .80
7920 @item @var{X} @tab The type shall be @code{REAL(*)}.
7923 @item @emph{Return value}:
7924 The return value is of type @code{REAL(*)}. The kind type parameter is
7925 the same as @var{X}.
7927 @item @emph{Example}:
7930 real(8) :: x = 0.165_8
7932 end program test_tan
7935 @item @emph{Specific names}:
7936 @multitable @columnfractions .20 .20 .20 .40
7937 @item Name @tab Argument @tab Return type @tab Standard
7938 @item @code{DTAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
7941 @item @emph{See also}:
7948 @section @code{TANH} --- Hyperbolic tangent function
7949 @findex @code{TANH} intrinsic
7950 @findex @code{DTANH} intrinsic
7951 @cindex hyperbolic tangent
7954 @item @emph{Description}:
7955 @code{TANH(X)} computes the hyperbolic tangent of @var{X}.
7957 @item @emph{Standard}:
7963 @item @emph{Syntax}:
7966 @item @emph{Arguments}:
7967 @multitable @columnfractions .15 .80
7968 @item @var{X} @tab The type shall be @code{REAL(*)}.
7971 @item @emph{Return value}:
7972 The return value is of type @code{REAL(*)} and lies in the range
7973 @math{ - 1 \leq tanh(x) \leq 1 }.
7975 @item @emph{Example}:
7978 real(8) :: x = 2.1_8
7980 end program test_tanh
7983 @item @emph{Specific names}:
7984 @multitable @columnfractions .20 .20 .20 .40
7985 @item Name @tab Argument @tab Return type @tab Standard
7986 @item @code{DTANH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
7989 @item @emph{See also}:
7996 @section @code{TIME} --- Time function
7997 @findex @code{TIME} intrinsic
7998 @cindex time functions
8000 Intrinsic implemented, documentation pending.
8003 @item @emph{Description}:
8004 @item @emph{Standard}:
8008 Non-elemental function
8010 @item @emph{Syntax}:
8011 @item @emph{Arguments}:
8012 @item @emph{Return value}:
8013 @item @emph{Example}:
8014 @item @emph{See also}:
8020 @section @code{TINY} --- Smallest positive number of a real kind
8021 @findex @code{TINY} intrinsic
8025 @item @emph{Description}:
8026 @code{TINY(X)} returns the smallest positive (non zero) number
8027 in the model of the type of @code{X}.
8029 @item @emph{Standard}:
8035 @item @emph{Syntax}:
8038 @item @emph{Arguments}:
8039 @multitable @columnfractions .15 .80
8040 @item @var{X} @tab shall be of type @code{REAL}.
8043 @item @emph{Return value}:
8044 The return value is of the same type and kind as @var{X}
8046 @item @emph{Example}:
8047 See @code{HUGE} for an example.
8053 @section @code{TRANSFER} --- Transfer bit patterns
8054 @findex @code{TRANSFER} intrinsic
8055 @cindex bit manipulation
8057 Intrinsic implemented, documentation pending.
8060 @item @emph{Description}:
8061 @item @emph{Standard}:
8065 Transformational function
8067 @item @emph{Syntax}:
8068 @item @emph{Arguments}:
8069 @item @emph{Return value}:
8070 @item @emph{Example}:
8071 @item @emph{See also}:
8078 @section @code{TRANSPOSE} --- Transpose an array of rank two
8079 @findex @code{TRANSPOSE} intrinsic
8080 @cindex matrix manipulation
8082 Intrinsic implemented, documentation pending.
8085 @item @emph{Description}:
8086 @item @emph{Standard}:
8090 Transformational function
8092 @item @emph{Syntax}:
8093 @item @emph{Arguments}:
8094 @item @emph{Return value}:
8095 @item @emph{Example}:
8096 @item @emph{See also}:
8103 @section @code{TRIM} --- Function to remove trailing blank characters of a string
8104 @findex @code{TRIM} intrinsic
8105 @cindex string manipulation
8107 Intrinsic implemented, documentation pending.
8110 @item @emph{Description}:
8111 @item @emph{Standard}:
8115 Transformational function
8117 @item @emph{Syntax}:
8118 @item @emph{Arguments}:
8119 @item @emph{Return value}:
8120 @item @emph{Example}:
8121 @item @emph{See also}:
8128 @section @code{UBOUND} --- Upper dimension bounds of an array
8129 @findex @code{UBOUND} intrinsic
8130 @cindex undocumented intrinsic
8132 Intrinsic implemented, documentation pending.
8135 @item @emph{Description}:
8137 @item @emph{Standard}:
8143 @item @emph{Syntax}:
8144 @item @emph{Arguments}:
8145 @item @emph{Return value}:
8146 @item @emph{Example}:
8147 @item @emph{Specific names}:
8149 @item @emph{See also}:
8157 @section @code{UMASK} --- Set the file creation mask
8158 @findex @code{UMASK} intrinsic
8159 @cindex file system operations
8161 Intrinsic implemented, documentation pending.
8164 @item @emph{Description}:
8165 @item @emph{Standard}:
8171 @item @emph{Syntax}:
8172 @item @emph{Arguments}:
8173 @item @emph{Return value}:
8174 @item @emph{Example}:
8175 @item @emph{Specific names}:
8176 @item @emph{See also}:
8183 @section @code{UNLINK} --- Remove a file from the file system
8184 @findex @code{UNLINK} intrinsic
8185 @cindex file system operations
8187 Intrinsic implemented, documentation pending.
8190 @item @emph{Description}:
8191 @item @emph{Standard}:
8197 @item @emph{Syntax}:
8198 @item @emph{Arguments}:
8199 @item @emph{Return value}:
8200 @item @emph{Example}:
8202 @item @emph{See also}:
8210 @section @code{UNMASK} --- (?)
8211 @findex @code{UNMASK} intrinsic
8212 @cindex undocumented intrinsic
8214 Intrinsic implemented, documentation pending.
8217 @item @emph{Description}:
8218 @item @emph{Standard}:
8220 @item @emph{Syntax}:
8221 @item @emph{Arguments}:
8222 @item @emph{Return value}:
8223 @item @emph{Example}:
8224 @item @emph{Specific names}:
8225 @item @emph{See also}:
8232 @section @code{UNPACK} --- Unpack an array of rank one into an array
8233 @findex @code{UNPACK} intrinsic
8234 @cindex array manipulation
8236 Intrinsic implemented, documentation pending.
8239 @item @emph{Description}:
8240 @item @emph{Standard}:
8244 Transformational function
8246 @item @emph{Syntax}:
8247 @item @emph{Arguments}:
8248 @item @emph{Return value}:
8249 @item @emph{Example}:
8251 @item @emph{See also}:
8259 @section @code{VERIFY} --- Scan a string for the absence of a set of characters
8260 @findex @code{VERIFY} intrinsic
8261 @cindex string manipulation
8263 Intrinsic implemented, documentation pending.
8266 @item @emph{Description}:
8267 @item @emph{Standard}:
8273 @item @emph{Syntax}:
8274 @item @emph{Arguments}:
8275 @item @emph{Return value}:
8276 @item @emph{Example}:
8277 @item @emph{Specific names}:
8278 @item @emph{See also}:
8283 @section @code{XOR} --- Bitwise logical exclusive OR
8284 @findex @code{XOR} intrinsic
8285 @cindex bit operations
8288 @item @emph{Description}:
8289 Bitwise logical exclusive or.
8291 This intrinsic routine is provided for backwards compatibility with
8292 GNU Fortran 77. For integer arguments, programmers should consider
8293 the use of the @ref{IEOR} intrinsic defined by the Fortran standard.
8295 @item @emph{Standard}:
8299 Non-elemental function
8301 @item @emph{Syntax}:
8302 @code{RESULT = XOR(X, Y)}
8304 @item @emph{Arguments}:
8305 @multitable @columnfractions .15 .80
8306 @item @var{X} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
8307 @item @var{Y} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
8310 @item @emph{Return value}:
8311 The return type is either @code{INTEGER(*)} or @code{LOGICAL}
8312 after cross-promotion of the arguments.
8314 @item @emph{Example}:
8317 LOGICAL :: T = .TRUE., F = .FALSE.
8319 DATA a / Z,'F' /, b / Z'3' /
8321 WRITE (*,*) XOR(T, T), XOR(T, F), XOR(F, T), XOR(F, F)
8322 WRITE (*,*) XOR(a, b)
8326 @item @emph{See also}:
8327 F95 elemental function: @ref{IEOR}