2 Copyright (C) 2005, 2006, 2007
3 Free Software Foundation, Inc.
4 This is part of the GNU Fortran manual.
5 For copying conditions, see the file gfortran.texi.
7 Permission is granted to copy, distribute and/or modify this document
8 under the terms of the GNU Free Documentation License, Version 1.2 or
9 any later version published by the Free Software Foundation; with the
10 Invariant Sections being ``GNU General Public License'' and ``Funding
11 Free Software'', the Front-Cover texts being (a) (see below), and with
12 the Back-Cover Texts being (b) (see below). A copy of the license is
13 included in the gfdl(7) man page.
16 Some basic guidelines for editing this document:
18 (1) The intrinsic procedures are to be listed in alphabetical order.
19 (2) The generic name is to be 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 to Intrinsics
53 * @code{ABORT}: ABORT, Abort the program
54 * @code{ABS}: ABS, Absolute value
55 * @code{ACCESS}: ACCESS, Checks file access modes
56 * @code{ACHAR}: ACHAR, Character in @acronym{ASCII} collating sequence
57 * @code{ACOS}: ACOS, Arccosine function
58 * @code{ACOSH}: ACOSH, Hyperbolic arccosine function
59 * @code{ADJUSTL}: ADJUSTL, Left adjust a string
60 * @code{ADJUSTR}: ADJUSTR, Right adjust a string
61 * @code{AIMAG}: AIMAG, Imaginary part of complex number
62 * @code{AINT}: AINT, Truncate to a whole number
63 * @code{ALARM}: ALARM, Set an alarm clock
64 * @code{ALL}: ALL, Determine if all values are true
65 * @code{ALLOCATED}: ALLOCATED, Status of allocatable entity
66 * @code{AND}: AND, Bitwise logical AND
67 * @code{ANINT}: ANINT, Nearest whole number
68 * @code{ANY}: ANY, Determine if any values are true
69 * @code{ASIN}: ASIN, Arcsine function
70 * @code{ASINH}: ASINH, Hyperbolic arcsine function
71 * @code{ASSOCIATED}: ASSOCIATED, Status of a pointer or pointer/target pair
72 * @code{ATAN}: ATAN, Arctangent function
73 * @code{ATAN2}: ATAN2, Arctangent function
74 * @code{ATANH}: ATANH, Hyperbolic arctangent function
75 * @code{BESJ0}: BESJ0, Bessel function of the first kind of order 0
76 * @code{BESJ1}: BESJ1, Bessel function of the first kind of order 1
77 * @code{BESJN}: BESJN, Bessel function of the first kind
78 * @code{BESY0}: BESY0, Bessel function of the second kind of order 0
79 * @code{BESY1}: BESY1, Bessel function of the second kind of order 1
80 * @code{BESYN}: BESYN, Bessel function of the second kind
81 * @code{BIT_SIZE}: BIT_SIZE, Bit size inquiry function
82 * @code{BTEST}: BTEST, Bit test function
83 * @code{CEILING}: CEILING, Integer ceiling function
84 * @code{CHAR}: CHAR, Integer-to-character conversion function
85 * @code{CHDIR}: CHDIR, Change working directory
86 * @code{CHMOD}: CHMOD, Change access permissions of files
87 * @code{CMPLX}: CMPLX, Complex conversion function
88 * @code{COMMAND_ARGUMENT_COUNT}: COMMAND_ARGUMENT_COUNT, Get number of command line arguments
89 * @code{CONJG}: CONJG, Complex conjugate function
90 * @code{COS}: COS, Cosine function
91 * @code{COSH}: COSH, Hyperbolic cosine function
92 * @code{COUNT}: COUNT, Count occurrences of TRUE in an array
93 * @code{CPU_TIME}: CPU_TIME, CPU time subroutine
94 * @code{CSHIFT}: CSHIFT, Circular array shift function
95 * @code{CTIME}: CTIME, Subroutine (or function) to convert a time into a string
96 * @code{DATE_AND_TIME}: DATE_AND_TIME, Date and time subroutine
97 * @code{DBLE}: DBLE, Double precision conversion function
98 * @code{DCMPLX}: DCMPLX, Double complex conversion function
99 * @code{DFLOAT}: DFLOAT, Double precision conversion function
100 * @code{DIGITS}: DIGITS, Significant digits function
101 * @code{DIM}: DIM, Dim function
102 * @code{DOT_PRODUCT}: DOT_PRODUCT, Dot product function
103 * @code{DPROD}: DPROD, Double product function
104 * @code{DREAL}: DREAL, Double real part function
105 * @code{DTIME}: DTIME, Execution time subroutine (or function)
106 * @code{EOSHIFT}: EOSHIFT, End-off shift function
107 * @code{EPSILON}: EPSILON, Epsilon function
108 * @code{ERF}: ERF, Error function
109 * @code{ERFC}: ERFC, Complementary error function
110 * @code{ETIME}: ETIME, Execution time subroutine (or function)
111 * @code{EXIT}: EXIT, Exit the program with status.
112 * @code{EXP}: EXP, Exponential function
113 * @code{EXPONENT}: EXPONENT, Exponent function
114 * @code{FDATE}: FDATE, Subroutine (or function) to get the current time as a string
115 * @code{FGET}: FGET, Read a single character in stream mode from stdin
116 * @code{FGETC}: FGETC, Read a single character in stream mode
117 * @code{FLOAT}: FLOAT, Convert integer to default real
118 * @code{FLOOR}: FLOOR, Integer floor function
119 * @code{FLUSH}: FLUSH, Flush I/O unit(s)
120 * @code{FNUM}: FNUM, File number function
121 * @code{FPUT}: FPUT, Write a single character in stream mode to stdout
122 * @code{FPUTC}: FPUTC, Write a single character in stream mode
123 * @code{FRACTION}: FRACTION, Fractional part of the model representation
124 * @code{FREE}: FREE, Memory de-allocation subroutine
125 * @code{FSEEK}: FSEEK, Low level file positioning subroutine
126 * @code{FSTAT}: FSTAT, Get file status
127 * @code{FTELL}: FTELL, Current stream position
128 * @code{GETARG}: GETARG, Get command line arguments
129 * @code{GET_COMMAND}: GET_COMMAND, Get the entire command line
130 * @code{GET_COMMAND_ARGUMENT}: GET_COMMAND_ARGUMENT, Get command line arguments
131 * @code{GETCWD}: GETCWD, Get current working directory
132 * @code{GETENV}: GETENV, Get an environmental variable
133 * @code{GET_ENVIRONMENT_VARIABLE}: GET_ENVIRONMENT_VARIABLE, Get an environmental variable
134 * @code{GETGID}: GETGID, Group ID function
135 * @code{GETLOG}: GETLOG, Get login name
136 * @code{GETPID}: GETPID, Process ID function
137 * @code{GETUID}: GETUID, User ID function
138 * @code{GMTIME}: GMTIME, Convert time to GMT info
139 * @code{HOSTNM}: HOSTNM, Get system host name
140 * @code{HUGE}: HUGE, Largest number of a kind
141 * @code{IACHAR}: IACHAR, Code in @acronym{ASCII} collating sequence
142 * @code{IAND}: IAND, Bitwise logical and
143 * @code{IARGC}: IARGC, Get the number of command line arguments
144 * @code{IBCLR}: IBCLR, Clear bit
145 * @code{IBITS}: IBITS, Bit extraction
146 * @code{IBSET}: IBSET, Set bit
147 * @code{ICHAR}: ICHAR, Character-to-integer conversion function
148 * @code{IDATE}: IDATE, Current local time (day/month/year)
149 * @code{IEOR}: IEOR, Bitwise logical exclusive or
150 * @code{IERRNO}: IERRNO, Function to get the last system error number
151 * @code{INDEX}: INDEX, Position of a substring within a string
152 * @code{INT}: INT, Convert to integer type
153 * @code{IOR}: IOR, Bitwise logical or
154 * @code{IRAND}: IRAND, Integer pseudo-random number
155 * @code{ISHFT}: ISHFT, Shift bits
156 * @code{ISHFTC}: ISHFTC, Shift bits circularly
157 * @code{ITIME}: ITIME, Current local time (hour/minutes/seconds)
158 * @code{KILL}: KILL, Send a signal to a process
159 * @code{KIND}: KIND, Kind of an entity
160 * @code{LBOUND}: LBOUND, Lower dimension bounds of an array
161 * @code{LEN}: LEN, Length of a character entity
162 * @code{LEN_TRIM}: LEN_TRIM, Length of a character entity without trailing blank characters
163 * @code{LGE}: LGE, Lexical greater than or equal
164 * @code{LGT}: LGT, Lexical greater than
165 * @code{LINK}: LINK, Create a hard link
166 * @code{LLE}: LLE, Lexical less than or equal
167 * @code{LLT}: LLT, Lexical less than
168 * @code{LNBLNK}: LNBLNK, Index of the last non-blank character in a string
169 * @code{LOC}: LOC, Returns the address of a variable
170 * @code{LOG}: LOG, Logarithm function
171 * @code{LOG10}: LOG10, Base 10 logarithm function
172 * @code{LOGICAL}: LOGICAL, Convert to logical type
173 * @code{LSHIFT}: LSHIFT, Left shift bits
174 * @code{LSTAT}: LSTAT, Get file status
175 * @code{LTIME}: LTIME, Convert time to local time info
176 * @code{MALLOC}: MALLOC, Dynamic memory allocation function
177 * @code{MATMUL}: MATMUL, matrix multiplication
178 * @code{MAX}: MAX, Maximum value of an argument list
179 * @code{MAXEXPONENT}: MAXEXPONENT, Maximum exponent of a real kind
180 * @code{MAXLOC}: MAXLOC, Location of the maximum value within an array
181 * @code{MAXVAL}: MAXVAL, Maximum value of an array
182 * @code{MERGE}: MERGE, Merge arrays
183 * @code{MIN}: MIN, Minimum value of an argument list
184 * @code{MINEXPONENT}: MINEXPONENT, Minimum exponent of a real kind
185 * @code{MINLOC}: MINLOC, Location of the minimum value within an array
186 * @code{MINVAL}: MINVAL, Minimum value of an array
187 * @code{MOD}: MOD, Remainder function
188 * @code{MODULO}: MODULO, Modulo function
189 * @code{MOVE_ALLOC}: MOVE_ALLOC, Move allocation from one object to another
190 * @code{MVBITS}: MVBITS, Move bits from one integer to another
191 * @code{NEAREST}: NEAREST, Nearest representable number
192 * @code{NEW_LINE}: NEW_LINE, New line character
193 * @code{NINT}: NINT, Nearest whole number
194 * @code{NOT}: NOT, Logical negation
195 * @code{NULL}: NULL, Function that returns an disassociated pointer
196 * @code{OR}: OR, Bitwise logical OR
197 * @code{PACK}: PACK, Pack an array into an array of rank one
198 * @code{PERROR}: PERROR, Print system error message
199 * @code{PRECISION}: PRECISION, Decimal precision of a real kind
200 * @code{PRESENT}: PRESENT, Determine whether an optional argument is specified
201 * @code{PRODUCT}: PRODUCT, Product of array elements
202 * @code{RADIX}: RADIX, Base of a data model
203 * @code{RANDOM_NUMBER}: RANDOM_NUMBER, Pseudo-random number
204 * @code{RANDOM_SEED}: RANDOM_SEED, Initialize a pseudo-random number sequence
205 * @code{RAND}: RAND, Real pseudo-random number
206 * @code{RANGE}: RANGE, Decimal exponent range of a real kind
207 * @code{RAN}: RAN, Real pseudo-random number
208 * @code{REAL}: REAL, Convert to real type
209 * @code{RENAME}: RENAME, Rename a file
210 * @code{REPEAT}: REPEAT, Repeated string concatenation
211 * @code{RESHAPE}: RESHAPE, Function to reshape an array
212 * @code{RRSPACING}: RRSPACING, Reciprocal of the relative spacing
213 * @code{RSHIFT}: RSHIFT, Right shift bits
214 * @code{SCALE}: SCALE, Scale a real value
215 * @code{SCAN}: SCAN, Scan a string for the presence of a set of characters
216 * @code{SECNDS}: SECNDS, Time function
217 @comment * @code{SECOND}: SECOND, (?)
218 @comment * @code{SECONDS}: SECONDS, (?)
219 * @code{SELECTED_INT_KIND}: SELECTED_INT_KIND, Choose integer kind
220 * @code{SELECTED_REAL_KIND}: SELECTED_REAL_KIND, Choose real kind
221 * @code{SET_EXPONENT}: SET_EXPONENT, Set the exponent of the model
222 * @code{SHAPE}: SHAPE, Determine the shape of an array
223 * @code{SIGN}: SIGN, Sign copying function
224 * @code{SIGNAL}: SIGNAL, Signal handling subroutine (or function)
225 * @code{SIN}: SIN, Sine function
226 * @code{SINH}: SINH, Hyperbolic sine function
227 * @code{SIZE}: SIZE, Function to determine the size of an array
228 * @code{SNGL}: SNGL, Convert double precision real to default real
229 * @code{SPACING}: SPACING, Smallest distance between two numbers of a given type
230 * @code{SPREAD}: SPREAD, Add a dimension to an array
231 * @code{SQRT}: SQRT, Square-root function
232 * @code{SRAND}: SRAND, Reinitialize the random number generator
233 * @code{STAT}: STAT, Get file status
234 * @code{SUM}: SUM, Sum of array elements
235 * @code{SYMLNK}: SYMLNK, Create a symbolic link
236 * @code{SYSTEM}: SYSTEM, Execute a shell command
237 * @code{SYSTEM_CLOCK}: SYSTEM_CLOCK, Time function
238 * @code{TAN}: TAN, Tangent function
239 * @code{TANH}: TANH, Hyperbolic tangent function
240 * @code{TIME}: TIME, Time function
241 * @code{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
254 @node Introduction to Intrinsics
255 @section Introduction to intrinsic procedures
257 The intrinsic procedures provided by GNU Fortran include all of the
258 intrinsic procedures required by the Fortran 95 standard, a set of
259 intrinsic procedures for backwards compatibility with G77, and a small
260 selection of intrinsic procedures from the Fortran 2003 standard. Any
261 conflict between a description here and a description in either the
262 Fortran 95 standard or the Fortran 2003 standard is unintentional, and
263 the standard(s) should be considered authoritative.
265 The enumeration of the @code{KIND} type parameter is processor defined in
266 the Fortran 95 standard. GNU Fortran defines the default integer type and
267 default real type by @code{INTEGER(KIND=4)} and @code{REAL(KIND=4)},
268 respectively. The standard mandates that both data types shall have
269 another kind, which have more precision. On typical target architectures
270 supported by @command{gfortran}, this kind type parameter is @code{KIND=8}.
271 Hence, @code{REAL(KIND=8)} and @code{DOUBLE PRECISION} are equivalent.
272 In the description of generic intrinsic procedures, the kind type parameter
273 will be specified by @code{KIND=*}, and in the description of specific
274 names for an intrinsic procedure the kind type parameter will be explicitly
275 given (e.g., @code{REAL(KIND=4)} or @code{REAL(KIND=8)}). Finally, for
276 brevity the optional @code{KIND=} syntax will be omitted.
278 Many of the intrinsic procedures take one or more optional arguments.
279 This document follows the convention used in the Fortran 95 standard,
280 and denotes such arguments by square brackets.
282 GNU Fortran offers the @option{-std=f95} and @option{-std=gnu} options,
283 which can be used to restrict the set of intrinsic procedures to a
284 given standard. By default, @command{gfortran} sets the @option{-std=gnu}
285 option, and so all intrinsic procedures described here are accepted. There
286 is one caveat. For a select group of intrinsic procedures, @command{g77}
287 implemented both a function and a subroutine. Both classes
288 have been implemented in @command{gfortran} for backwards compatibility
289 with @command{g77}. It is noted here that these functions and subroutines
290 cannot be intermixed in a given subprogram. In the descriptions that follow,
291 the applicable option(s) is noted.
295 @section @code{ABORT} --- Abort the program
296 @cindex @code{ABORT} intrinsic
300 @item @emph{Description}:
301 @code{ABORT} causes immediate termination of the program. On operating
302 systems that support a core dump, @code{ABORT} will produce a core dump,
303 which is suitable for debugging purposes.
305 @item @emph{Standard}:
309 non-elemental subroutine
314 @item @emph{Return value}:
317 @item @emph{Example}:
320 integer :: i = 1, j = 2
321 if (i /= j) call abort
322 end program test_abort
325 @item @emph{See also}:
326 @ref{EXIT}, @ref{KILL}
332 @section @code{ABS} --- Absolute value
333 @cindex @code{ABS} intrinsic
334 @cindex @code{CABS} intrinsic
335 @cindex @code{DABS} intrinsic
336 @cindex @code{IABS} intrinsic
337 @cindex @code{ZABS} intrinsic
338 @cindex @code{CDABS} intrinsic
339 @cindex absolute value
342 @item @emph{Description}:
343 @code{ABS(X)} computes the absolute value of @code{X}.
345 @item @emph{Standard}:
346 F77 and later, has overloads that are GNU extensions
354 @item @emph{Arguments}:
355 @multitable @columnfractions .15 .80
356 @item @var{X} @tab The type of the argument shall be an @code{INTEGER(*)},
357 @code{REAL(*)}, or @code{COMPLEX(*)}.
360 @item @emph{Return value}:
361 The return value is of the same type and
362 kind as the argument except the return value is @code{REAL(*)} for a
363 @code{COMPLEX(*)} argument.
365 @item @emph{Example}:
370 complex :: z = (-1.e0,0.e0)
377 @item @emph{Specific names}:
378 @multitable @columnfractions .20 .20 .20 .40
379 @item Name @tab Argument @tab Return type @tab Standard
380 @item @code{CABS(Z)} @tab @code{COMPLEX(4) Z} @tab @code{REAL(4)} @tab F77 and later
381 @item @code{DABS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
382 @item @code{IABS(I)} @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)} @tab F77 and later
383 @item @code{ZABS(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
384 @item @code{CDABS(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
390 @section @code{ACCESS} --- Checks file access modes
391 @cindex @code{ACCESS}
392 @cindex file system operations
395 @item @emph{Description}:
396 @code{ACCESS(NAME, MODE)} checks whether the file @var{NAME}
397 exists, is readable, writable or executable. Except for the
398 executable check, @code{ACCESS} can be replaced by
399 Fortran 95's @code{INQUIRE}.
401 @item @emph{Standard}:
408 @code{I = ACCESS(NAME, MODE)}
410 @item @emph{Arguments}:
411 @multitable @columnfractions .15 .80
412 @item @var{NAME} @tab Scalar @code{CHARACTER} with the file name.
413 Tailing blank are ignored unless the character @code{achar(0)} is
414 present, then all characters up to and excluding @code{achar(0)} are
416 @item @var{MODE} @tab Scalar @code{CHARACTER} with the file access mode,
417 may be any concatenation of @code{"r"} (readable), @code{"w"} (writable)
418 and @code{"x"} (executable), or @code{" "} to check for existence.
421 @item @emph{Return value}:
422 Returns a scalar @code{INTEGER}, which is @code{0} if the file is
423 accessable in the given mode; otherwise or if an invalid argument
424 has been given for @code{MODE} the value @code{1} is returned.
426 @item @emph{Example}:
430 character(len=*), parameter :: file = 'test.dat'
431 character(len=*), parameter :: file2 = 'test.dat '//achar(0)
432 if(access(file,' ') == 0) print *, trim(file),' is exists'
433 if(access(file,'r') == 0) print *, trim(file),' is readable'
434 if(access(file,'w') == 0) print *, trim(file),' is writable'
435 if(access(file,'x') == 0) print *, trim(file),' is executable'
436 if(access(file2,'rwx') == 0) &
437 print *, trim(file2),' is readable, writable and executable'
438 end program access_test
440 @item @emph{Specific names}:
441 @item @emph{See also}:
447 @section @code{ACHAR} --- Character in @acronym{ASCII} collating sequence
448 @cindex @code{ACHAR} intrinsic
449 @cindex @acronym{ASCII} collating sequence
452 @item @emph{Description}:
453 @code{ACHAR(I)} returns the character located at position @code{I}
454 in the @acronym{ASCII} collating sequence.
456 @item @emph{Standard}:
465 @item @emph{Arguments}:
466 @multitable @columnfractions .15 .80
467 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
470 @item @emph{Return value}:
471 The return value is of type @code{CHARACTER} with a length of one. The
472 kind type parameter is the same as @code{KIND('A')}.
474 @item @emph{Example}:
479 end program test_achar
486 @section @code{ACOS} --- Arccosine function
487 @cindex @code{ACOS} intrinsic
488 @cindex @code{DACOS} intrinsic
489 @cindex trigonometric functions (inverse)
492 @item @emph{Description}:
493 @code{ACOS(X)} computes the arccosine of @var{X} (inverse of @code{COS(X)}).
495 @item @emph{Standard}:
504 @item @emph{Arguments}:
505 @multitable @columnfractions .15 .80
506 @item @var{X} @tab The type shall be @code{REAL(*)} with a magnitude that is
510 @item @emph{Return value}:
511 The return value is of type @code{REAL(*)} and it lies in the
512 range @math{ 0 \leq \acos(x) \leq \pi}. The kind type parameter
513 is the same as @var{X}.
515 @item @emph{Example}:
518 real(8) :: x = 0.866_8
520 end program test_acos
523 @item @emph{Specific names}:
524 @multitable @columnfractions .20 .20 .20 .40
525 @item Name @tab Argument @tab Return type @tab Standard
526 @item @code{DACOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
529 @item @emph{See also}:
530 Inverse function: @ref{COS}
536 @section @code{ACOSH} --- Hyperbolic arccosine function
537 @cindex @code{ACOSH} intrinsic
538 @cindex hyperbolic arccosine
539 @cindex hyperbolic cosine (inverse)
542 @item @emph{Description}:
543 @code{ACOSH(X)} computes the area hyperbolic cosine of @var{X} (inverse of @code{COSH(X)}).
545 @item @emph{Standard}:
554 @item @emph{Arguments}:
555 @multitable @columnfractions .15 .80
556 @item @var{X} @tab The type shall be @code{REAL(*)} with a magnitude that is
557 greater or equal to one.
560 @item @emph{Return value}:
561 The return value is of type @code{REAL(*)} and it lies in the
562 range @math{0 \leq \acosh (x) \leq \infty}.
564 @item @emph{Example}:
567 REAL(8), DIMENSION(3) :: x = (/ 1.0, 2.0, 3.0 /)
572 @item @emph{See also}:
573 Inverse function: @ref{COSH}
579 @section @code{ADJUSTL} --- Left adjust a string
580 @cindex @code{ADJUSTL} intrinsic
581 @cindex adjust string
584 @item @emph{Description}:
585 @code{ADJUSTL(STR)} will left adjust a string by removing leading spaces.
586 Spaces are inserted at the end of the string as needed.
588 @item @emph{Standard}:
595 @code{STR = ADJUSTL(STR)}
597 @item @emph{Arguments}:
598 @multitable @columnfractions .15 .80
599 @item @var{STR} @tab The type shall be @code{CHARACTER}.
602 @item @emph{Return value}:
603 The return value is of type @code{CHARACTER} where leading spaces
604 are removed and the same number of spaces are inserted on the end
607 @item @emph{Example}:
610 character(len=20) :: str = ' gfortran'
613 end program test_adjustl
620 @section @code{ADJUSTR} --- Right adjust a string
621 @cindex @code{ADJUSTR} intrinsic
622 @cindex adjust string
625 @item @emph{Description}:
626 @code{ADJUSTR(STR)} will right adjust a string by removing trailing spaces.
627 Spaces are inserted at the start of the string as needed.
629 @item @emph{Standard}:
636 @code{STR = ADJUSTR(STR)}
638 @item @emph{Arguments}:
639 @multitable @columnfractions .15 .80
640 @item @var{STR} @tab The type shall be @code{CHARACTER}.
643 @item @emph{Return value}:
644 The return value is of type @code{CHARACTER} where trailing spaces
645 are removed and the same number of spaces are inserted at the start
648 @item @emph{Example}:
651 character(len=20) :: str = 'gfortran'
654 end program test_adjustr
661 @section @code{AIMAG} --- Imaginary part of complex number
662 @cindex @code{AIMAG} intrinsic
663 @cindex @code{DIMAG} intrinsic
664 @cindex @code{IMAG} intrinsic
665 @cindex @code{IMAGPART} intrinsic
666 @cindex imaginary part of a complex number
669 @item @emph{Description}:
670 @code{AIMAG(Z)} yields the imaginary part of complex argument @code{Z}.
671 The @code{IMAG(Z)} and @code{IMAGPART(Z)} intrinsic functions are provided
672 for compatibility with @command{g77}, and their use in new code is
673 strongly discouraged.
675 @item @emph{Standard}:
676 F77 and later, has overloads that are GNU extensions
684 @item @emph{Arguments}:
685 @multitable @columnfractions .15 .80
686 @item @var{Z} @tab The type of the argument shall be @code{COMPLEX(*)}.
689 @item @emph{Return value}:
690 The return value is of type real with the
691 kind type parameter of the argument.
693 @item @emph{Example}:
698 z4 = cmplx(1.e0_4, 0.e0_4)
699 z8 = cmplx(0.e0_8, 1.e0_8)
700 print *, aimag(z4), dimag(z8)
701 end program test_aimag
704 @item @emph{Specific names}:
705 @multitable @columnfractions .20 .20 .20 .40
706 @item Name @tab Argument @tab Return type @tab Standard
707 @item @code{DIMAG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{REAL(8)} @tab GNU extension
708 @item @code{IMAG(Z)} @tab @code{COMPLEX(*) Z} @tab @code{REAL(*)} @tab GNU extension
709 @item @code{IMAGPART(Z)} @tab @code{COMPLEX(*) Z} @tab @code{REAL(*)} @tab GNU extension
716 @section @code{AINT} --- Truncate to a whole number
717 @cindex @code{AINT} intrinsic
718 @cindex @code{DINT} intrinsic
722 @item @emph{Description}:
723 @code{AINT(X [, KIND])} truncates its argument to a whole number.
725 @item @emph{Standard}:
732 @code{X = AINT(X [, KIND])}
734 @item @emph{Arguments}:
735 @multitable @columnfractions .15 .80
736 @item @var{X} @tab The type of the argument shall be @code{REAL(*)}.
737 @item @var{KIND} @tab (Optional) @var{KIND} shall be a scalar integer
738 initialization expression.
741 @item @emph{Return value}:
742 The return value is of type real with the kind type parameter of the
743 argument if the optional @var{KIND} is absent; otherwise, the kind
744 type parameter will be given by @var{KIND}. If the magnitude of
745 @var{X} is less than one, then @code{AINT(X)} returns zero. If the
746 magnitude is equal to or greater than one, then it returns the largest
747 whole number that does not exceed its magnitude. The sign is the same
748 as the sign of @var{X}.
750 @item @emph{Example}:
757 print *, aint(x4), dint(x8)
759 end program test_aint
762 @item @emph{Specific names}:
763 @multitable @columnfractions .20 .20 .20 .40
764 @item Name @tab Argument @tab Return type @tab Standard
765 @item @code{DINT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
772 @section @code{ALARM} --- Execute a routine after a given delay
773 @cindex @code{ALARM} intrinsic
776 @item @emph{Description}:
777 @code{ALARM(SECONDS, HANDLER [, STATUS])} causes external subroutine @var{HANDLER}
778 to be executed after a delay of @var{SECONDS} by using @code{alarm(1)} to
779 set up a signal and @code{signal(2)} to catch it. If @var{STATUS} is
780 supplied, it will be returned with the number of seconds remaining until
781 any previously scheduled alarm was due to be delivered, or zero if there
782 was no previously scheduled alarm.
784 @item @emph{Standard}:
791 @code{CALL ALARM(SECONDS, HANDLER [, STATUS])}
793 @item @emph{Arguments}:
794 @multitable @columnfractions .15 .80
795 @item @var{SECONDS} @tab The type of the argument shall be a scalar
796 @code{INTEGER}. It is @code{INTENT(IN)}.
797 @item @var{HANDLER} @tab Signal handler (@code{INTEGER FUNCTION} or
798 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar.
799 @code{INTEGER}. It is @code{INTENT(IN)}.
800 @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
801 @code{INTEGER} variable. It is @code{INTENT(OUT)}.
804 @item @emph{Example}:
807 external handler_print
809 call alarm (3, handler_print, i)
812 end program test_alarm
814 This will cause the external routine @var{handler_print} to be called
821 @section @code{ALL} --- All values in @var{MASK} along @var{DIM} are true
822 @cindex @code{ALL} intrinsic
826 @item @emph{Description}:
827 @code{ALL(MASK [, DIM])} determines if all the values are true in @var{MASK}
828 in the array along dimension @var{DIM}.
830 @item @emph{Standard}:
834 transformational function
837 @code{L = ALL(MASK [, DIM])}
839 @item @emph{Arguments}:
840 @multitable @columnfractions .15 .80
841 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL(*)} and
842 it shall not be scalar.
843 @item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer
844 with a value that lies between one and the rank of @var{MASK}.
847 @item @emph{Return value}:
848 @code{ALL(MASK)} returns a scalar value of type @code{LOGICAL(*)} where
849 the kind type parameter is the same as the kind type parameter of
850 @var{MASK}. If @var{DIM} is present, then @code{ALL(MASK, DIM)} returns
851 an array with the rank of @var{MASK} minus 1. The shape is determined from
852 the shape of @var{MASK} where the @var{DIM} dimension is elided.
856 @code{ALL(MASK)} is true if all elements of @var{MASK} are true.
857 It also is true if @var{MASK} has zero size; otherwise, it is false.
859 If the rank of @var{MASK} is one, then @code{ALL(MASK,DIM)} is equivalent
860 to @code{ALL(MASK)}. If the rank is greater than one, then @code{ALL(MASK,DIM)}
861 is determined by applying @code{ALL} to the array sections.
864 @item @emph{Example}:
868 l = all((/.true., .true., .true./))
873 integer a(2,3), b(2,3)
877 print *, all(a .eq. b, 1)
878 print *, all(a .eq. b, 2)
879 end subroutine section
887 @section @code{ALLOCATED} --- Status of an allocatable entity
888 @cindex @code{ALLOCATED} intrinsic
889 @cindex allocation status
892 @item @emph{Description}:
893 @code{ALLOCATED(X)} checks the status of whether @var{X} is allocated.
895 @item @emph{Standard}:
902 @code{L = ALLOCATED(X)}
904 @item @emph{Arguments}:
905 @multitable @columnfractions .15 .80
906 @item @var{X} @tab The argument shall be an @code{ALLOCATABLE} array.
909 @item @emph{Return value}:
910 The return value is a scalar @code{LOGICAL} with the default logical
911 kind type parameter. If @var{X} is allocated, @code{ALLOCATED(X)}
912 is @code{.TRUE.}; otherwise, it returns the @code{.TRUE.}
914 @item @emph{Example}:
916 program test_allocated
918 real(4), allocatable :: x(:)
919 if (allocated(x) .eqv. .false.) allocate(x(i))
920 end program test_allocated
926 @section @code{AND} --- Bitwise logical AND
927 @cindex @code{AND} intrinsic
928 @cindex bit operations
931 @item @emph{Description}:
932 Bitwise logical @code{AND}.
934 This intrinsic routine is provided for backwards compatibility with
935 GNU Fortran 77. For integer arguments, programmers should consider
936 the use of the @ref{IAND} intrinsic defined by the Fortran standard.
938 @item @emph{Standard}:
942 Non-elemental function
945 @code{RESULT = AND(X, Y)}
947 @item @emph{Arguments}:
948 @multitable @columnfractions .15 .80
949 @item @var{X} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
950 @item @var{Y} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
953 @item @emph{Return value}:
954 The return type is either @code{INTEGER(*)} or @code{LOGICAL} after
955 cross-promotion of the arguments.
957 @item @emph{Example}:
960 LOGICAL :: T = .TRUE., F = ..FALSE.
962 DATA a / Z'F' /, b / Z'3' /
964 WRITE (*,*) AND(T, T), AND(T, F), AND(F, T), AND(F, F)
965 WRITE (*,*) AND(a, b)
969 @item @emph{See also}:
970 F95 elemental function: @ref{IAND}
976 @section @code{ANINT} --- Nearest whole number
977 @cindex @code{ANINT} intrinsic
978 @cindex @code{DNINT} intrinsic
982 @item @emph{Description}:
983 @code{ANINT(X [, KIND])} rounds its argument to the nearest whole number.
985 @item @emph{Standard}:
993 @code{X = ANINT(X, KIND)}
995 @item @emph{Arguments}:
996 @multitable @columnfractions .15 .80
997 @item @var{X} @tab The type of the argument shall be @code{REAL(*)}.
998 @item @var{KIND} @tab (Optional) @var{KIND} shall be a scalar integer
999 initialization expression.
1002 @item @emph{Return value}:
1003 The return value is of type real with the kind type parameter of the
1004 argument if the optional @var{KIND} is absent; otherwise, the kind
1005 type parameter will be given by @var{KIND}. If @var{X} is greater than
1006 zero, then @code{ANINT(X)} returns @code{AINT(X+0.5)}. If @var{X} is
1007 less than or equal to zero, then it returns @code{AINT(X-0.5)}.
1009 @item @emph{Example}:
1016 print *, anint(x4), dnint(x8)
1018 end program test_anint
1021 @item @emph{Specific names}:
1022 @multitable @columnfractions .20 .20 .20 .40
1023 @item Name @tab Argument @tab Return type @tab Standard
1024 @item @code{DNINT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1031 @section @code{ANY} --- Any value in @var{MASK} along @var{DIM} is true
1032 @cindex @code{ANY} intrinsic
1036 @item @emph{Description}:
1037 @code{ANY(MASK [, DIM])} determines if any of the values in the logical array
1038 @var{MASK} along dimension @var{DIM} are @code{.TRUE.}.
1040 @item @emph{Standard}:
1044 transformational function
1046 @item @emph{Syntax}:
1047 @code{L = ANY(MASK)}
1048 @code{L = ANY(MASK, DIM)}
1050 @item @emph{Arguments}:
1051 @multitable @columnfractions .15 .80
1052 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL(*)} and
1053 it shall not be scalar.
1054 @item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer
1055 with a value that lies between one and the rank of @var{MASK}.
1058 @item @emph{Return value}:
1059 @code{ANY(MASK)} returns a scalar value of type @code{LOGICAL(*)} where
1060 the kind type parameter is the same as the kind type parameter of
1061 @var{MASK}. If @var{DIM} is present, then @code{ANY(MASK, DIM)} returns
1062 an array with the rank of @var{MASK} minus 1. The shape is determined from
1063 the shape of @var{MASK} where the @var{DIM} dimension is elided.
1067 @code{ANY(MASK)} is true if any element of @var{MASK} is true;
1068 otherwise, it is false. It also is false if @var{MASK} has zero size.
1070 If the rank of @var{MASK} is one, then @code{ANY(MASK,DIM)} is equivalent
1071 to @code{ANY(MASK)}. If the rank is greater than one, then @code{ANY(MASK,DIM)}
1072 is determined by applying @code{ANY} to the array sections.
1075 @item @emph{Example}:
1079 l = any((/.true., .true., .true./))
1084 integer a(2,3), b(2,3)
1088 print *, any(a .eq. b, 1)
1089 print *, any(a .eq. b, 2)
1090 end subroutine section
1091 end program test_any
1098 @section @code{ASIN} --- Arcsine function
1099 @cindex @code{ASIN} intrinsic
1100 @cindex @code{DASIN} intrinsic
1101 @cindex trigonometric functions (inverse)
1104 @item @emph{Description}:
1105 @code{ASIN(X)} computes the arcsine of its @var{X} (inverse of @code{SIN(X)}).
1107 @item @emph{Standard}:
1113 @item @emph{Syntax}:
1116 @item @emph{Arguments}:
1117 @multitable @columnfractions .15 .80
1118 @item @var{X} @tab The type shall be @code{REAL(*)}, and a magnitude that is
1122 @item @emph{Return value}:
1123 The return value is of type @code{REAL(*)} and it lies in the
1124 range @math{-\pi / 2 \leq \asin (x) \leq \pi / 2}. The kind type
1125 parameter is the same as @var{X}.
1127 @item @emph{Example}:
1130 real(8) :: x = 0.866_8
1132 end program test_asin
1135 @item @emph{Specific names}:
1136 @multitable @columnfractions .20 .20 .20 .40
1137 @item Name @tab Argument @tab Return type @tab Standard
1138 @item @code{DASIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1141 @item @emph{See also}:
1142 Inverse function: @ref{SIN}
1148 @section @code{ASINH} --- Hyperbolic arcsine function
1149 @cindex @code{ASINH} intrinsic
1150 @cindex hyperbolic arcsine
1151 @cindex hyperbolic sine (inverse)
1154 @item @emph{Description}:
1155 @code{ASINH(X)} computes the area hyperbolic sine of @var{X} (inverse of @code{SINH(X)}).
1157 @item @emph{Standard}:
1163 @item @emph{Syntax}:
1166 @item @emph{Arguments}:
1167 @multitable @columnfractions .15 .80
1168 @item @var{X} @tab The type shall be @code{REAL(*)}, with @var{X} a real number.
1171 @item @emph{Return value}:
1172 The return value is of type @code{REAL(*)} and it lies in the
1173 range @math{-\infty \leq \asinh (x) \leq \infty}.
1175 @item @emph{Example}:
1178 REAL(8), DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1179 WRITE (*,*) ASINH(x)
1183 @item @emph{See also}:
1184 Inverse function: @ref{SINH}
1190 @section @code{ASSOCIATED} --- Status of a pointer or pointer/target pair
1191 @cindex @code{ASSOCIATED} intrinsic
1192 @cindex pointer status
1195 @item @emph{Description}:
1196 @code{ASSOCIATED(PTR [, TGT])} determines the status of the pointer @var{PTR}
1197 or if @var{PTR} is associated with the target @var{TGT}.
1199 @item @emph{Standard}:
1205 @item @emph{Syntax}:
1206 @code{L = ASSOCIATED(PTR)}
1207 @code{L = ASSOCIATED(PTR [, TGT])}
1209 @item @emph{Arguments}:
1210 @multitable @columnfractions .15 .80
1211 @item @var{PTR} @tab @var{PTR} shall have the @code{POINTER} attribute and
1212 it can be of any type.
1213 @item @var{TGT} @tab (Optional) @var{TGT} shall be a @code{POINTER} or
1214 a @code{TARGET}. It must have the same type, kind type parameter, and
1215 array rank as @var{PTR}.
1217 The status of neither @var{PTR} nor @var{TGT} can be undefined.
1219 @item @emph{Return value}:
1220 @code{ASSOCIATED(PTR)} returns a scalar value of type @code{LOGICAL(4)}.
1221 There are several cases:
1223 @item (A) If the optional @var{TGT} is not present, then @code{ASSOCIATED(PTR)}
1224 is true if @var{PTR} is associated with a target; otherwise, it returns false.
1225 @item (B) If @var{TGT} is present and a scalar target, the result is true if
1227 is not a 0 sized storage sequence and the target associated with @var{PTR}
1228 occupies the same storage units. If @var{PTR} is disassociated, then the
1230 @item (C) If @var{TGT} is present and an array target, the result is true if
1231 @var{TGT} and @var{PTR} have the same shape, are not 0 sized arrays, are
1232 arrays whose elements are not 0 sized storage sequences, and @var{TGT} and
1233 @var{PTR} occupy the same storage units in array element order.
1234 As in case(B), the result is false, if @var{PTR} is disassociated.
1235 @item (D) If @var{TGT} is present and an scalar pointer, the result is true if
1236 target associated with @var{PTR} and the target associated with @var{TGT}
1237 are not 0 sized storage sequences and occupy the same storage units.
1238 The result is false, if either @var{TGT} or @var{PTR} is disassociated.
1239 @item (E) If @var{TGT} is present and an array pointer, the result is true if
1240 target associated with @var{PTR} and the target associated with @var{TGT}
1241 have the same shape, are not 0 sized arrays, are arrays whose elements are
1242 not 0 sized storage sequences, and @var{TGT} and @var{PTR} occupy the same
1243 storage units in array element order.
1244 The result is false, if either @var{TGT} or @var{PTR} is disassociated.
1247 @item @emph{Example}:
1249 program test_associated
1251 real, target :: tgt(2) = (/1., 2./)
1252 real, pointer :: ptr(:)
1254 if (associated(ptr) .eqv. .false.) call abort
1255 if (associated(ptr,tgt) .eqv. .false.) call abort
1256 end program test_associated
1259 @item @emph{See also}:
1266 @section @code{ATAN} --- Arctangent function
1267 @cindex @code{ATAN} intrinsic
1268 @cindex @code{DATAN} intrinsic
1269 @cindex trigonometric functions (inverse)
1272 @item @emph{Description}:
1273 @code{ATAN(X)} computes the arctangent of @var{X}.
1275 @item @emph{Standard}:
1281 @item @emph{Syntax}:
1284 @item @emph{Arguments}:
1285 @multitable @columnfractions .15 .80
1286 @item @var{X} @tab The type shall be @code{REAL(*)}.
1289 @item @emph{Return value}:
1290 The return value is of type @code{REAL(*)} and it lies in the
1291 range @math{ - \pi / 2 \leq \atan (x) \leq \pi / 2}.
1293 @item @emph{Example}:
1296 real(8) :: x = 2.866_8
1298 end program test_atan
1301 @item @emph{Specific names}:
1302 @multitable @columnfractions .20 .20 .20 .40
1303 @item Name @tab Argument @tab Return type @tab Standard
1304 @item @code{DATAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1307 @item @emph{See also}:
1308 Inverse function: @ref{TAN}
1315 @section @code{ATAN2} --- Arctangent function
1316 @cindex @code{ATAN2} intrinsic
1317 @cindex @code{DATAN2} intrinsic
1318 @cindex trigonometric functions (inverse)
1321 @item @emph{Description}:
1322 @code{ATAN2(Y,X)} computes the arctangent of the complex number @math{X + i Y}.
1324 @item @emph{Standard}:
1330 @item @emph{Syntax}:
1331 @code{X = ATAN2(Y,X)}
1333 @item @emph{Arguments}:
1334 @multitable @columnfractions .15 .80
1335 @item @var{Y} @tab The type shall be @code{REAL(*)}.
1336 @item @var{X} @tab The type and kind type parameter shall be the same as @var{Y}.
1337 If @var{Y} is zero, then @var{X} must be nonzero.
1340 @item @emph{Return value}:
1341 The return value has the same type and kind type parameter as @var{Y}.
1342 It is the principal value of the complex number @math{X + i Y}. If
1343 @var{X} is nonzero, then it lies in the range @math{-\pi \le \atan (x) \leq \pi}.
1344 The sign is positive if @var{Y} is positive. If @var{Y} is zero, then
1345 the return value is zero if @var{X} is positive and @math{\pi} if @var{X}
1346 is negative. Finally, if @var{X} is zero, then the magnitude of the result
1349 @item @emph{Example}:
1352 real(4) :: x = 1.e0_4, y = 0.5e0_4
1354 end program test_atan2
1357 @item @emph{Specific names}:
1358 @multitable @columnfractions .20 .20 .20 .40
1359 @item Name @tab Argument @tab Return type @tab Standard
1360 @item @code{DATAN2(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1367 @section @code{ATANH} --- Hyperbolic arctangent function
1368 @cindex @code{ASINH} intrinsic
1369 @cindex hyperbolic arctangent
1370 @cindex hyperbolic tangent (inverse)
1373 @item @emph{Description}:
1374 @code{ATANH(X)} computes the area hyperbolic sine of @var{X} (inverse of @code{TANH(X)}).
1376 @item @emph{Standard}:
1382 @item @emph{Syntax}:
1385 @item @emph{Arguments}:
1386 @multitable @columnfractions .15 .80
1387 @item @var{X} @tab The type shall be @code{REAL(*)} with a magnitude that is less than or equal to one.
1390 @item @emph{Return value}:
1391 The return value is of type @code{REAL(*)} and it lies in the
1392 range @math{-\infty \leq \atanh(x) \leq \infty}.
1394 @item @emph{Example}:
1397 REAL, DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1398 WRITE (*,*) ATANH(x)
1402 @item @emph{See also}:
1403 Inverse function: @ref{TANH}
1410 @section @code{BESJ0} --- Bessel function of the first kind of order 0
1411 @cindex @code{BESJ0} intrinsic
1412 @cindex @code{DBESJ0} intrinsic
1416 @item @emph{Description}:
1417 @code{BESJ0(X)} computes the Bessel function of the first kind of order 0
1420 @item @emph{Standard}:
1426 @item @emph{Syntax}:
1429 @item @emph{Arguments}:
1430 @multitable @columnfractions .15 .80
1431 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1434 @item @emph{Return value}:
1435 The return value is of type @code{REAL(*)} and it lies in the
1436 range @math{ - 0.4027... \leq Bessel (0,x) \leq 1}.
1438 @item @emph{Example}:
1441 real(8) :: x = 0.0_8
1443 end program test_besj0
1446 @item @emph{Specific names}:
1447 @multitable @columnfractions .20 .20 .20 .40
1448 @item Name @tab Argument @tab Return type @tab Standard
1449 @item @code{DBESJ0(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1456 @section @code{BESJ1} --- Bessel function of the first kind of order 1
1457 @cindex @code{BESJ1} intrinsic
1458 @cindex @code{DBESJ1} intrinsic
1462 @item @emph{Description}:
1463 @code{BESJ1(X)} computes the Bessel function of the first kind of order 1
1466 @item @emph{Standard}:
1472 @item @emph{Syntax}:
1475 @item @emph{Arguments}:
1476 @multitable @columnfractions .15 .80
1477 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1480 @item @emph{Return value}:
1481 The return value is of type @code{REAL(*)} and it lies in the
1482 range @math{ - 0.5818... \leq Bessel (0,x) \leq 0.5818 }.
1484 @item @emph{Example}:
1487 real(8) :: x = 1.0_8
1489 end program test_besj1
1492 @item @emph{Specific names}:
1493 @multitable @columnfractions .20 .20 .20 .40
1494 @item Name @tab Argument @tab Return type @tab Standard
1495 @item @code{DBESJ1(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1502 @section @code{BESJN} --- Bessel function of the first kind
1503 @cindex @code{BESJN} intrinsic
1504 @cindex @code{DBESJN} intrinsic
1508 @item @emph{Description}:
1509 @code{BESJN(N, X)} computes the Bessel function of the first kind of order
1512 @item @emph{Standard}:
1518 @item @emph{Syntax}:
1519 @code{Y = BESJN(N, X)}
1521 @item @emph{Arguments}:
1522 @multitable @columnfractions .15 .80
1523 @item @var{N} @tab The type shall be @code{INTEGER(*)}, and it shall be scalar.
1524 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1527 @item @emph{Return value}:
1528 The return value is a scalar of type @code{REAL(*)}.
1530 @item @emph{Example}:
1533 real(8) :: x = 1.0_8
1535 end program test_besjn
1538 @item @emph{Specific names}:
1539 @multitable @columnfractions .20 .20 .20 .40
1540 @item Name @tab Argument @tab Return type @tab Standard
1541 @item @code{DBESJN(X)} @tab @code{INTEGER(*) N} @tab @code{REAL(8)} @tab GNU extension
1542 @item @tab @code{REAL(8) X} @tab @tab
1549 @section @code{BESY0} --- Bessel function of the second kind of order 0
1550 @cindex @code{BESY0} intrinsic
1551 @cindex @code{DBESY0} intrinsic
1555 @item @emph{Description}:
1556 @code{BESY0(X)} computes the Bessel function of the second kind of order 0
1559 @item @emph{Standard}:
1565 @item @emph{Syntax}:
1568 @item @emph{Arguments}:
1569 @multitable @columnfractions .15 .80
1570 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1573 @item @emph{Return value}:
1574 The return value is a scalar of type @code{REAL(*)}.
1576 @item @emph{Example}:
1579 real(8) :: x = 0.0_8
1581 end program test_besy0
1584 @item @emph{Specific names}:
1585 @multitable @columnfractions .20 .20 .20 .40
1586 @item Name @tab Argument @tab Return type @tab Standard
1587 @item @code{DBESY0(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1594 @section @code{BESY1} --- Bessel function of the second kind of order 1
1595 @cindex @code{BESY1} intrinsic
1596 @cindex @code{DBESY1} intrinsic
1600 @item @emph{Description}:
1601 @code{BESY1(X)} computes the Bessel function of the second kind of order 1
1604 @item @emph{Standard}:
1610 @item @emph{Syntax}:
1613 @item @emph{Arguments}:
1614 @multitable @columnfractions .15 .80
1615 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1618 @item @emph{Return value}:
1619 The return value is a scalar of type @code{REAL(*)}.
1621 @item @emph{Example}:
1624 real(8) :: x = 1.0_8
1626 end program test_besy1
1629 @item @emph{Specific names}:
1630 @multitable @columnfractions .20 .20 .20 .40
1631 @item Name @tab Argument @tab Return type @tab Standard
1632 @item @code{DBESY1(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1639 @section @code{BESYN} --- Bessel function of the second kind
1640 @cindex @code{BESYN} intrinsic
1641 @cindex @code{DBESYN} intrinsic
1645 @item @emph{Description}:
1646 @code{BESYN(N, X)} computes the Bessel function of the second kind of order
1649 @item @emph{Standard}:
1655 @item @emph{Syntax}:
1656 @code{Y = BESYN(N, X)}
1658 @item @emph{Arguments}:
1659 @multitable @columnfractions .15 .80
1660 @item @var{N} @tab The type shall be @code{INTEGER(*)}, and it shall be scalar.
1661 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1664 @item @emph{Return value}:
1665 The return value is a scalar of type @code{REAL(*)}.
1667 @item @emph{Example}:
1670 real(8) :: x = 1.0_8
1672 end program test_besyn
1675 @item @emph{Specific names}:
1676 @multitable @columnfractions .20 .20 .20 .40
1677 @item Name @tab Argument @tab Return type @tab Standard
1678 @item @code{DBESYN(N,X)} @tab @code{INTEGER(*) N} @tab @code{REAL(8)} @tab GNU extension
1679 @item @tab @code{REAL(8) X} @tab @tab
1686 @section @code{BIT_SIZE} --- Bit size inquiry function
1687 @cindex @code{BIT_SIZE} intrinsic
1688 @cindex bit size of a variable
1689 @cindex size of a variable, in bits
1692 @item @emph{Description}:
1693 @code{BIT_SIZE(I)} returns the number of bits (integer precision plus sign bit)
1694 represented by the type of @var{I}.
1696 @item @emph{Standard}:
1702 @item @emph{Syntax}:
1703 @code{I = BIT_SIZE(I)}
1705 @item @emph{Arguments}:
1706 @multitable @columnfractions .15 .80
1707 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1710 @item @emph{Return value}:
1711 The return value is of type @code{INTEGER(*)}
1713 @item @emph{Example}:
1715 program test_bit_size
1720 end program test_bit_size
1727 @section @code{BTEST} --- Bit test function
1728 @cindex @code{BTEST} intrinsic
1729 @cindex bit operations
1732 @item @emph{Description}:
1733 @code{BTEST(I,POS)} returns logical @code{.TRUE.} if the bit at @var{POS}
1736 @item @emph{Standard}:
1742 @item @emph{Syntax}:
1743 @code{I = BTEST(I,POS)}
1745 @item @emph{Arguments}:
1746 @multitable @columnfractions .15 .80
1747 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1748 @item @var{POS} @tab The type shall be @code{INTEGER(*)}.
1751 @item @emph{Return value}:
1752 The return value is of type @code{LOGICAL}
1754 @item @emph{Example}:
1757 integer :: i = 32768 + 1024 + 64
1761 bool = btest(i, pos)
1764 end program test_btest
1771 @section @code{CEILING} --- Integer ceiling function
1772 @cindex @code{CEILING} intrinsic
1776 @item @emph{Description}:
1777 @code{CEILING(X)} returns the least integer greater than or equal to @var{X}.
1779 @item @emph{Standard}:
1785 @item @emph{Syntax}:
1786 @code{I = CEILING(X[,KIND])}
1788 @item @emph{Arguments}:
1789 @multitable @columnfractions .15 .80
1790 @item @var{X} @tab The type shall be @code{REAL(*)}.
1791 @item @var{KIND} @tab (Optional) scalar integer initialization expression.
1794 @item @emph{Return value}:
1795 The return value is of type @code{INTEGER(KIND)}
1797 @item @emph{Example}:
1799 program test_ceiling
1802 print *, ceiling(x) ! returns 64
1803 print *, ceiling(y) ! returns -63
1804 end program test_ceiling
1807 @item @emph{See also}:
1808 @ref{FLOOR}, @ref{NINT}
1815 @section @code{CHAR} --- Character conversion function
1816 @cindex @code{CHAR} intrinsic
1817 @cindex conversion function (character)
1820 @item @emph{Description}:
1821 @code{CHAR(I,[KIND])} returns the character represented by the integer @var{I}.
1823 @item @emph{Standard}:
1829 @item @emph{Syntax}:
1830 @code{C = CHAR(I[,KIND])}
1832 @item @emph{Arguments}:
1833 @multitable @columnfractions .15 .80
1834 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1835 @item @var{KIND} @tab Optional scaler integer initialization expression.
1838 @item @emph{Return value}:
1839 The return value is of type @code{CHARACTER(1)}
1841 @item @emph{Example}:
1847 print *, i, c ! returns 'J'
1848 end program test_char
1851 @item @emph{See also}:
1852 @ref{ACHAR}, @ref{ICHAR}, @ref{IACHAR}
1858 @section @code{CHDIR} --- Change working directory
1859 @cindex @code{CHDIR} intrinsic
1860 @cindex file system operations
1863 @item @emph{Description}:
1864 Change current working directory to a specified @var{PATH}.
1866 @item @emph{Standard}:
1870 Non-elemental subroutine
1872 @item @emph{Syntax}:
1873 @code{CALL chdir(PATH[,STATUS])}
1875 @item @emph{Arguments}:
1876 @multitable @columnfractions .15 .80
1877 @item @var{PATH} @tab The type shall be @code{CHARACTER(*)} and shall specify a valid path within the file system.
1878 @item @var{STATUS} @tab (Optional) status flag. Returns 0 on success,
1879 a system specific and non-zero error code otherwise.
1882 @item @emph{Example}:
1885 CHARACTER(len=255) :: path
1887 WRITE(*,*) TRIM(path)
1890 WRITE(*,*) TRIM(path)
1894 @item @emph{See also}:
1901 @section @code{CHMOD} --- Change access permissions of files
1902 @cindex @code{CHMOD} intrinsic
1903 @cindex file system operations
1906 @item @emph{Description}:
1907 @code{CHMOD} changes the permissions of a file. This function invokes
1908 @code{/bin/chmod} and might therefore not work on all platforms.
1910 This intrinsic is provided in both subroutine and function forms; however,
1911 only one form can be used in any given program unit.
1913 @item @emph{Standard}:
1917 Subroutine, non-elemental function
1919 @item @emph{Syntax}:
1920 @multitable @columnfractions .80
1921 @item @code{CALL CHMOD(NAME, MODE[, STATUS])}
1922 @item @code{STATUS = CHMOD(NAME, MODE)}
1925 @item @emph{Arguments}:
1926 @multitable @columnfractions .15 .80
1927 @item @var{NAME} @tab Scalar @code{CHARACTER} with the file name.
1928 Trailing blanks are ignored unless the character @code{achar(0)} is
1929 present, then all characters up to and excluding @code{achar(0)} are
1930 used as the file name.
1932 @item @var{MODE} @tab Scalar @code{CHARACTER} giving the file permission.
1933 @var{MODE} uses the same syntax as the @var{MODE} argument of
1936 @item @var{STATUS} @tab (optional) scalar @code{INTEGER}, which is
1937 @code{0} on success and non-zero otherwise.
1940 @item @emph{Return value}:
1941 In either syntax, @var{STATUS} is set to @code{0} on success and non-zero
1944 @item @emph{Example}:
1945 @code{CHMOD} as subroutine
1950 call chmod('test.dat','u+x',status)
1951 print *, 'Status: ', status
1952 end program chmod_test
1954 @code{CHMOD} as non-elemental function:
1959 status = chmod('test.dat','u+x')
1960 print *, 'Status: ', status
1961 end program chmod_test
1963 @item @emph{Specific names}:
1964 @item @emph{See also}:
1970 @section @code{CMPLX} --- Complex conversion function
1971 @cindex @code{CMPLX} intrinsic
1972 @cindex complex numbers, conversion to
1975 @item @emph{Description}:
1976 @code{CMPLX(X[,Y[,KIND]])} returns a complex number where @var{X} is converted to
1977 the real component. If @var{Y} is present it is converted to the imaginary
1978 component. If @var{Y} is not present then the imaginary component is set to
1979 0.0. If @var{X} is complex then @var{Y} must not be present.
1981 @item @emph{Standard}:
1987 @item @emph{Syntax}:
1988 @code{C = CMPLX(X[,Y[,KIND]])}
1990 @item @emph{Arguments}:
1991 @multitable @columnfractions .15 .80
1992 @item @var{X} @tab The type may be @code{INTEGER(*)}, @code{REAL(*)}, or @code{COMPLEX(*)}.
1993 @item @var{Y} @tab Optional, allowed if @var{X} is not @code{COMPLEX(*)}. May be @code{INTEGER(*)} or @code{REAL(*)}.
1994 @item @var{KIND} @tab Optional scaler integer initialization expression.
1997 @item @emph{Return value}:
1998 The return value is of type @code{COMPLEX(*)}
2000 @item @emph{Example}:
2007 print *, z, cmplx(x)
2008 end program test_cmplx
2014 @node COMMAND_ARGUMENT_COUNT
2015 @section @code{COMMAND_ARGUMENT_COUNT} --- Get number of command line arguments
2016 @cindex @code{COMMAND_ARGUMENT_COUNT} intrinsic
2017 @cindex command-line arguments, to program
2020 @item @emph{Description}:
2021 @code{COMMAND_ARGUMENT_COUNT()} returns the number of arguments passed on the
2022 command line when the containing program was invoked.
2024 @item @emph{Standard}:
2030 @item @emph{Syntax}:
2031 @code{I = COMMAND_ARGUMENT_COUNT()}
2033 @item @emph{Arguments}:
2034 @multitable @columnfractions .15 .80
2038 @item @emph{Return value}:
2039 The return value is of type @code{INTEGER(4)}
2041 @item @emph{Example}:
2043 program test_command_argument_count
2045 count = command_argument_count()
2047 end program test_command_argument_count
2050 @item @emph{See also}:
2051 @ref{GET_COMMAND}, @ref{GET_COMMAND_ARGUMENT}
2055 @section @code{CONJG} --- Complex conjugate function
2056 @cindex @code{CONJG} intrinsic
2057 @cindex @code{DCONJG} intrinsic
2058 @cindex complex conjugate
2060 @item @emph{Description}:
2061 @code{CONJG(Z)} returns the conjugate of @var{Z}. If @var{Z} is @code{(x, y)}
2062 then the result is @code{(x, -y)}
2064 @item @emph{Standard}:
2065 F77 and later, has overloads that are GNU extensions
2070 @item @emph{Syntax}:
2073 @item @emph{Arguments}:
2074 @multitable @columnfractions .15 .80
2075 @item @var{Z} @tab The type shall be @code{COMPLEX(*)}.
2078 @item @emph{Return value}:
2079 The return value is of type @code{COMPLEX(*)}.
2081 @item @emph{Example}:
2084 complex :: z = (2.0, 3.0)
2085 complex(8) :: dz = (2.71_8, -3.14_8)
2090 end program test_conjg
2093 @item @emph{Specific names}:
2094 @multitable @columnfractions .20 .20 .20 .40
2095 @item Name @tab Argument @tab Return type @tab Standard
2096 @item @code{DCONJG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
2103 @section @code{COS} --- Cosine function
2104 @cindex @code{COS} intrinsic
2105 @cindex @code{DCOS} intrinsic
2106 @cindex @code{ZCOS} intrinsic
2107 @cindex @code{CDCOS} intrinsic
2108 @cindex trigonometric functions
2111 @item @emph{Description}:
2112 @code{COS(X)} computes the cosine of @var{X}.
2114 @item @emph{Standard}:
2115 F77 and later, has overloads that are GNU extensions
2120 @item @emph{Syntax}:
2123 @item @emph{Arguments}:
2124 @multitable @columnfractions .15 .80
2125 @item @var{X} @tab The type shall be @code{REAL(*)} or
2129 @item @emph{Return value}:
2130 The return value is of type @code{REAL(*)} and it lies in the
2131 range @math{ -1 \leq \cos (x) \leq 1}. The kind type
2132 parameter is the same as @var{X}.
2134 @item @emph{Example}:
2139 end program test_cos
2142 @item @emph{Specific names}:
2143 @multitable @columnfractions .20 .20 .20 .40
2144 @item Name @tab Argument @tab Return type @tab Standard
2145 @item @code{DCOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
2146 @item @code{CCOS(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab F77 and later
2147 @item @code{ZCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
2148 @item @code{CDCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
2151 @item @emph{See also}:
2152 Inverse function: @ref{ACOS}
2159 @section @code{COSH} --- Hyperbolic cosine function
2160 @cindex @code{COSH} intrinsic
2161 @cindex @code{DCOSH} intrinsic
2162 @cindex hyperbolic cosine
2165 @item @emph{Description}:
2166 @code{COSH(X)} computes the hyperbolic cosine of @var{X}.
2168 @item @emph{Standard}:
2174 @item @emph{Syntax}:
2177 @item @emph{Arguments}:
2178 @multitable @columnfractions .15 .80
2179 @item @var{X} @tab The type shall be @code{REAL(*)}.
2182 @item @emph{Return value}:
2183 The return value is of type @code{REAL(*)} and it is positive
2184 (@math{ \cosh (x) \geq 0 }.
2186 @item @emph{Example}:
2189 real(8) :: x = 1.0_8
2191 end program test_cosh
2194 @item @emph{Specific names}:
2195 @multitable @columnfractions .20 .20 .20 .40
2196 @item Name @tab Argument @tab Return type @tab Standard
2197 @item @code{DCOSH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
2200 @item @emph{See also}:
2201 Inverse function: @ref{ACOSH}
2208 @section @code{COUNT} --- Count function
2209 @cindex @code{COUNT} intrinsic
2213 @item @emph{Description}:
2214 @code{COUNT(MASK[,DIM])} counts the number of @code{.TRUE.} elements of
2215 @var{MASK} along the dimension of @var{DIM}. If @var{DIM} is omitted it is
2216 taken to be @code{1}. @var{DIM} is a scaler of type @code{INTEGER} in the
2217 range of @math{1 /leq DIM /leq n)} where @math{n} is the rank of @var{MASK}.
2219 @item @emph{Standard}:
2223 transformational function
2225 @item @emph{Syntax}:
2226 @code{I = COUNT(MASK[,DIM])}
2228 @item @emph{Arguments}:
2229 @multitable @columnfractions .15 .80
2230 @item @var{MASK} @tab The type shall be @code{LOGICAL}.
2231 @item @var{DIM} @tab The type shall be @code{INTEGER}.
2234 @item @emph{Return value}:
2235 The return value is of type @code{INTEGER} with rank equal to that of
2238 @item @emph{Example}:
2241 integer, dimension(2,3) :: a, b
2242 logical, dimension(2,3) :: mask
2243 a = reshape( (/ 1, 2, 3, 4, 5, 6 /), (/ 2, 3 /))
2244 b = reshape( (/ 0, 7, 3, 4, 5, 8 /), (/ 2, 3 /))
2245 print '(3i3)', a(1,:)
2246 print '(3i3)', a(2,:)
2248 print '(3i3)', b(1,:)
2249 print '(3i3)', b(2,:)
2252 print '(3l3)', mask(1,:)
2253 print '(3l3)', mask(2,:)
2255 print '(3i3)', count(mask)
2257 print '(3i3)', count(mask, 1)
2259 print '(3i3)', count(mask, 2)
2260 end program test_count
2267 @section @code{CPU_TIME} --- CPU elapsed time in seconds
2268 @cindex @code{CPU_TIME} intrinsic
2269 @cindex time, elapsed
2270 @cindex elapsed time
2273 @item @emph{Description}:
2274 Returns a @code{REAL} value representing the elapsed CPU time in seconds. This
2275 is useful for testing segments of code to determine execution time.
2277 @item @emph{Standard}:
2283 @item @emph{Syntax}:
2286 @item @emph{Arguments}:
2287 @multitable @columnfractions .15 .80
2288 @item @var{X} @tab The type shall be @code{REAL} with @code{INTENT(OUT)}.
2291 @item @emph{Return value}:
2294 @item @emph{Example}:
2296 program test_cpu_time
2297 real :: start, finish
2298 call cpu_time(start)
2299 ! put code to test here
2300 call cpu_time(finish)
2301 print '("Time = ",f6.3," seconds.")',finish-start
2302 end program test_cpu_time
2309 @section @code{CSHIFT} --- Circular shift function
2310 @cindex @code{CSHIFT} intrinsic
2311 @cindex bit operations
2314 @item @emph{Description}:
2315 @code{CSHIFT(ARRAY, SHIFT[,DIM])} performs a circular shift on elements of
2316 @var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is omitted it is
2317 taken to be @code{1}. @var{DIM} is a scaler of type @code{INTEGER} in the
2318 range of @math{1 /leq DIM /leq n)} where @math{n} is the rank of @var{ARRAY}.
2319 If the rank of @var{ARRAY} is one, then all elements of @var{ARRAY} are shifted
2320 by @var{SHIFT} places. If rank is greater than one, then all complete rank one
2321 sections of @var{ARRAY} along the given dimension are shifted. Elements
2322 shifted out one end of each rank one section are shifted back in the other end.
2324 @item @emph{Standard}:
2328 transformational function
2330 @item @emph{Syntax}:
2331 @code{A = CSHIFT(A, SHIFT[,DIM])}
2333 @item @emph{Arguments}:
2334 @multitable @columnfractions .15 .80
2335 @item @var{ARRAY} @tab May be any type, not scaler.
2336 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
2337 @item @var{DIM} @tab The type shall be @code{INTEGER}.
2340 @item @emph{Return value}:
2341 Returns an array of same type and rank as the @var{ARRAY} argument.
2343 @item @emph{Example}:
2346 integer, dimension(3,3) :: a
2347 a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
2348 print '(3i3)', a(1,:)
2349 print '(3i3)', a(2,:)
2350 print '(3i3)', a(3,:)
2351 a = cshift(a, SHIFT=(/1, 2, -1/), DIM=2)
2353 print '(3i3)', a(1,:)
2354 print '(3i3)', a(2,:)
2355 print '(3i3)', a(3,:)
2356 end program test_cshift
2362 @section @code{CTIME} --- Convert a time into a string
2363 @cindex @code{CTIME} intrinsic
2364 @cindex time, conversion function
2367 @item @emph{Description}:
2368 @code{CTIME(T,S)} converts @var{T}, a system time value, such as returned
2369 by @code{TIME8()}, to a string of the form @samp{Sat Aug 19 18:13:14
2370 1995}, and returns that string into @var{S}.
2372 If @code{CTIME} is invoked as a function, it can not be invoked as a
2373 subroutine, and vice versa.
2375 @var{T} is an @code{INTENT(IN)} @code{INTEGER(KIND=8)} variable.
2376 @var{S} is an @code{INTENT(OUT)} @code{CHARACTER} variable.
2378 @item @emph{Standard}:
2384 @item @emph{Syntax}:
2385 @multitable @columnfractions .80
2386 @item @code{CALL CTIME(T,S)}.
2387 @item @code{S = CTIME(T)}, (not recommended).
2390 @item @emph{Arguments}:
2391 @multitable @columnfractions .15 .80
2392 @item @var{S}@tab The type shall be of type @code{CHARACTER}.
2393 @item @var{T}@tab The type shall be of type @code{INTEGER(KIND=8)}.
2396 @item @emph{Return value}:
2397 The converted date and time as a string.
2399 @item @emph{Example}:
2403 character(len=30) :: date
2406 ! Do something, main part of the program
2409 print *, 'Program was started on ', date
2410 end program test_ctime
2415 @section @code{DATE_AND_TIME} --- Date and time subroutine
2416 @cindex @code{DATE_AND_TIME} intrinsic
2417 @cindex date, current
2418 @cindex current date
2419 @cindex time, current
2420 @cindex current time
2423 @item @emph{Description}:
2424 @code{DATE_AND_TIME(DATE, TIME, ZONE, VALUES)} gets the corresponding date and
2425 time information from the real-time system clock. @var{DATE} is
2426 @code{INTENT(OUT)} and has form ccyymmdd. @var{TIME} is @code{INTENT(OUT)} and
2427 has form hhmmss.sss. @var{ZONE} is @code{INTENT(OUT)} and has form (+-)hhmm,
2428 representing the difference with respect to Coordinated Universal Time (UTC).
2429 Unavailable time and date parameters return blanks.
2431 @var{VALUES} is @code{INTENT(OUT)} and provides the following:
2433 @multitable @columnfractions .15 .30 .60
2434 @item @tab @code{VALUE(1)}: @tab The year
2435 @item @tab @code{VALUE(2)}: @tab The month
2436 @item @tab @code{VALUE(3)}: @tab The day of the month
2437 @item @tab @code{VALUE(4)}: @tab Time difference with UTC in minutes
2438 @item @tab @code{VALUE(5)}: @tab The hour of the day
2439 @item @tab @code{VALUE(6)}: @tab The minutes of the hour
2440 @item @tab @code{VALUE(7)}: @tab The seconds of the minute
2441 @item @tab @code{VALUE(8)}: @tab The milliseconds of the second
2444 @item @emph{Standard}:
2450 @item @emph{Syntax}:
2451 @code{CALL DATE_AND_TIME([DATE, TIME, ZONE, VALUES])}
2453 @item @emph{Arguments}:
2454 @multitable @columnfractions .15 .80
2455 @item @var{DATE} @tab (Optional) The type shall be @code{CHARACTER(8)} or larger.
2456 @item @var{TIME} @tab (Optional) The type shall be @code{CHARACTER(10)} or larger.
2457 @item @var{ZONE} @tab (Optional) The type shall be @code{CHARACTER(5)} or larger.
2458 @item @var{VALUES}@tab (Optional) The type shall be @code{INTEGER(8)}.
2461 @item @emph{Return value}:
2464 @item @emph{Example}:
2466 program test_time_and_date
2467 character(8) :: date
2468 character(10) :: time
2469 character(5) :: zone
2470 integer,dimension(8) :: values
2471 ! using keyword arguments
2472 call date_and_time(date,time,zone,values)
2473 call date_and_time(DATE=date,ZONE=zone)
2474 call date_and_time(TIME=time)
2475 call date_and_time(VALUES=values)
2476 print '(a,2x,a,2x,a)', date, time, zone
2477 print '(8i5))', values
2478 end program test_time_and_date
2485 @section @code{DBLE} --- Double conversion function
2486 @cindex @code{DBLE} intrinsic
2487 @cindex double conversion
2490 @item @emph{Description}:
2491 @code{DBLE(X)} Converts @var{X} to double precision real type.
2493 @item @emph{Standard}:
2499 @item @emph{Syntax}:
2502 @item @emph{Arguments}:
2503 @multitable @columnfractions .15 .80
2504 @item @var{X} @tab The type shall be @code{INTEGER(*)}, @code{REAL(*)}, or @code{COMPLEX(*)}.
2507 @item @emph{Return value}:
2508 The return value is of type double precision real.
2510 @item @emph{Example}:
2515 complex :: z = (2.3,1.14)
2516 print *, dble(x), dble(i), dble(z)
2517 end program test_dble
2520 @item @emph{See also}:
2521 @ref{DFLOAT}, @ref{FLOAT}, @ref{REAL}
2527 @section @code{DCMPLX} --- Double complex conversion function
2528 @cindex @code{DCMPLX} intrinsic
2529 @cindex complex numbers, conversion to
2532 @item @emph{Description}:
2533 @code{DCMPLX(X [,Y])} returns a double complex number where @var{X} is
2534 converted to the real component. If @var{Y} is present it is converted to the
2535 imaginary component. If @var{Y} is not present then the imaginary component is
2536 set to 0.0. If @var{X} is complex then @var{Y} must not be present.
2538 @item @emph{Standard}:
2544 @item @emph{Syntax}:
2545 @code{C = DCMPLX(X)}
2546 @code{C = DCMPLX(X,Y)}
2548 @item @emph{Arguments}:
2549 @multitable @columnfractions .15 .80
2550 @item @var{X} @tab The type may be @code{INTEGER(*)}, @code{REAL(*)}, or @code{COMPLEX(*)}.
2551 @item @var{Y} @tab Optional if @var{X} is not @code{COMPLEX(*)}. May be @code{INTEGER(*)} or @code{REAL(*)}.
2554 @item @emph{Return value}:
2555 The return value is of type @code{COMPLEX(8)}
2557 @item @emph{Example}:
2567 print *, dcmplx(x,i)
2568 end program test_dcmplx
2575 @section @code{DFLOAT} --- Double conversion function
2576 @cindex @code{DFLOAT} intrinsic
2577 @cindex double float conversion
2580 @item @emph{Description}:
2581 @code{DFLOAT(X)} Converts @var{X} to double precision real type.
2583 @item @emph{Standard}:
2589 @item @emph{Syntax}:
2590 @code{X = DFLOAT(X)}
2592 @item @emph{Arguments}:
2593 @multitable @columnfractions .15 .80
2594 @item @var{X} @tab The type shall be @code{INTEGER(*)}.
2597 @item @emph{Return value}:
2598 The return value is of type double precision real.
2600 @item @emph{Example}:
2605 end program test_dfloat
2608 @item @emph{See also}:
2609 @ref{DBLE}, @ref{FLOAT}, @ref{REAL}
2615 @section @code{DIGITS} --- Significant digits function
2616 @cindex @code{DIGITS} intrinsic
2617 @cindex digits, significant
2620 @item @emph{Description}:
2621 @code{DIGITS(X)} returns the number of significant digits of the internal model
2622 representation of @var{X}. For example, on a system using a 32-bit
2623 floating point representation, a default real number would likely return 24.
2625 @item @emph{Standard}:
2631 @item @emph{Syntax}:
2632 @code{C = DIGITS(X)}
2634 @item @emph{Arguments}:
2635 @multitable @columnfractions .15 .80
2636 @item @var{X} @tab The type may be @code{INTEGER(*)} or @code{REAL(*)}.
2639 @item @emph{Return value}:
2640 The return value is of type @code{INTEGER}.
2642 @item @emph{Example}:
2645 integer :: i = 12345
2651 end program test_digits
2658 @section @code{DIM} --- Dim function
2659 @cindex @code{DIM} intrinsic
2660 @cindex @code{IDIM} intrinsic
2661 @cindex @code{DDIM} intrinsic
2665 @item @emph{Description}:
2666 @code{DIM(X,Y)} returns the difference @code{X-Y} if the result is positive;
2667 otherwise returns zero.
2669 @item @emph{Standard}:
2675 @item @emph{Syntax}:
2678 @item @emph{Arguments}:
2679 @multitable @columnfractions .15 .80
2680 @item @var{X} @tab The type shall be @code{INTEGER(*)} or @code{REAL(*)}
2681 @item @var{Y} @tab The type shall be the same type and kind as @var{X}.
2684 @item @emph{Return value}:
2685 The return value is of type @code{INTEGER(*)} or @code{REAL(*)}.
2687 @item @emph{Example}:
2693 x = dim(4.345_8, 2.111_8)
2696 end program test_dim
2699 @item @emph{Specific names}:
2700 @multitable @columnfractions .20 .20 .20 .40
2701 @item Name @tab Argument @tab Return type @tab Standard
2702 @item @code{IDIM(X,Y)} @tab @code{INTEGER(4) X,Y} @tab @code{INTEGER(4)} @tab F77 and later
2703 @item @code{DDIM(X,Y)} @tab @code{REAL(8) X,Y} @tab @code{REAL(8)} @tab F77 and later
2710 @section @code{DOT_PRODUCT} --- Dot product function
2711 @cindex @code{DOT_PRODUCT} intrinsic
2715 @item @emph{Description}:
2716 @code{DOT_PRODUCT(X,Y)} computes the dot product multiplication of two vectors
2717 @var{X} and @var{Y}. The two vectors may be either numeric or logical
2718 and must be arrays of rank one and of equal size. If the vectors are
2719 @code{INTEGER(*)} or @code{REAL(*)}, the result is @code{SUM(X*Y)}. If the
2720 vectors are @code{COMPLEX(*)}, the result is @code{SUM(CONJG(X)*Y)}. If the
2721 vectors are @code{LOGICAL}, the result is @code{ANY(X.AND.Y)}.
2723 @item @emph{Standard}:
2727 transformational function
2729 @item @emph{Syntax}:
2730 @code{S = DOT_PRODUCT(X,Y)}
2732 @item @emph{Arguments}:
2733 @multitable @columnfractions .15 .80
2734 @item @var{X} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
2735 @item @var{Y} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
2738 @item @emph{Return value}:
2739 If the arguments are numeric, the return value is a scaler of numeric type,
2740 @code{INTEGER(*)}, @code{REAL(*)}, or @code{COMPLEX(*)}. If the arguments are
2741 @code{LOGICAL}, the return value is @code{.TRUE.} or @code{.FALSE.}.
2743 @item @emph{Example}:
2745 program test_dot_prod
2746 integer, dimension(3) :: a, b
2753 print *, dot_product(a,b)
2754 end program test_dot_prod
2761 @section @code{DPROD} --- Double product function
2762 @cindex @code{DPROD} intrinsic
2763 @cindex double-precision product
2766 @item @emph{Description}:
2767 @code{DPROD(X,Y)} returns the product @code{X*Y}.
2769 @item @emph{Standard}:
2775 @item @emph{Syntax}:
2776 @code{D = DPROD(X,Y)}
2778 @item @emph{Arguments}:
2779 @multitable @columnfractions .15 .80
2780 @item @var{X} @tab The type shall be @code{REAL}.
2781 @item @var{Y} @tab The type shall be @code{REAL}.
2784 @item @emph{Return value}:
2785 The return value is of type @code{REAL(8)}.
2787 @item @emph{Example}:
2796 end program test_dprod
2803 @section @code{DREAL} --- Double real part function
2804 @cindex @code{DREAL} intrinsic
2805 @cindex double-precision real part
2808 @item @emph{Description}:
2809 @code{DREAL(Z)} returns the real part of complex variable @var{Z}.
2811 @item @emph{Standard}:
2817 @item @emph{Syntax}:
2820 @item @emph{Arguments}:
2821 @multitable @columnfractions .15 .80
2822 @item @var{Z} @tab The type shall be @code{COMPLEX(8)}.
2825 @item @emph{Return value}:
2826 The return value is of type @code{REAL(8)}.
2828 @item @emph{Example}:
2831 complex(8) :: z = (1.3_8,7.2_8)
2833 end program test_dreal
2836 @item @emph{See also}:
2844 @section @code{DTIME} --- Execution time subroutine (or function)
2845 @cindex @code{DTIME} intrinsic
2846 @cindex time, elapsed
2847 @cindex elapsed time
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 @cindex @code{EOSHIFT} intrinsic
2924 @cindex bit operations
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 @cindex @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 @cindex @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 @cindex @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 @cindex @code{ETIME} intrinsic
3116 @cindex time, elapsed
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.
3192 @cindex @code{EXIT} intrinsic
3193 @cindex exit program
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 @cindex @code{EXP} intrinsic
3236 @cindex @code{DEXP} intrinsic
3237 @cindex @code{ZEXP} intrinsic
3238 @cindex @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 @cindex @code{EXPONENT} intrinsic
3286 @cindex exponent part of a real number
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 @cindex @code{FDATE} intrinsic
3326 @cindex time, current
3327 @cindex current time
3328 @cindex date, current
3329 @cindex current date
3332 @item @emph{Description}:
3333 @code{FDATE(DATE)} returns the current date (using the same format as
3334 @code{CTIME}) in @var{DATE}. It is equivalent to @code{CALL CTIME(DATE,
3337 If @code{FDATE} is invoked as a function, it can not be invoked as a
3338 subroutine, and vice versa.
3340 @var{DATE} is an @code{INTENT(OUT)} @code{CHARACTER} variable.
3342 @item @emph{Standard}:
3348 @item @emph{Syntax}:
3349 @multitable @columnfractions .80
3350 @item @code{CALL FDATE(DATE)}.
3351 @item @code{DATE = FDATE()}, (not recommended).
3354 @item @emph{Arguments}:
3355 @multitable @columnfractions .15 .80
3356 @item @var{DATE}@tab The type shall be of type @code{CHARACTER}.
3359 @item @emph{Return value}:
3360 The current date as a string.
3362 @item @emph{Example}:
3366 character(len=30) :: date
3368 print *, 'Program started on ', date
3369 do i = 1, 100000000 ! Just a delay
3373 print *, 'Program ended on ', date
3374 end program test_fdate
3380 @section @code{FLOAT} --- Convert integer to default real
3381 @cindex @code{FLOAT} intrinsic
3382 @cindex conversion function (float)
3385 @item @emph{Description}:
3386 @code{FLOAT(I)} converts the integer @var{I} to a default real value.
3388 @item @emph{Standard}:
3394 @item @emph{Syntax}:
3397 @item @emph{Arguments}:
3398 @multitable @columnfractions .15 .80
3399 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
3402 @item @emph{Return value}:
3403 The return value is of type default @code{REAL}
3405 @item @emph{Example}:
3409 if (float(i) /= 1.) call abort
3410 end program test_float
3413 @item @emph{See also}:
3414 @ref{DBLE}, @ref{DFLOAT}, @ref{REAL}
3420 @section @code{FGET} --- Read a single character in stream mode from stdin
3421 @cindex @code{FGET} intrinsic
3422 @cindex file operations
3423 @cindex stream operations
3426 @item @emph{Description}:
3427 Read a single character in stream mode from stdin by bypassing normal
3428 formatted output. Stream I/O should not be mixed with normal record-oriented
3429 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
3431 This intrinsic routine is provided for backwards compatibility with
3432 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
3433 Programmers should consider the use of new stream IO feature in new code
3434 for future portability. See also @ref{Fortran 2003 status}.
3436 @item @emph{Standard}:
3440 Non-elemental subroutine
3442 @item @emph{Syntax}:
3443 @code{CALL FGET(C[,STATUS])}
3445 @item @emph{Arguments}:
3446 @multitable @columnfractions .15 .80
3447 @item @var{C} @tab The type shall be @code{CHARACTER}.
3448 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. Returns 0 on success,
3449 -1 on end-of-file and a system specific positive error code otherwise.
3452 @item @emph{Example}:
3455 INTEGER, PARAMETER :: strlen = 100
3456 INTEGER :: status, i = 1
3457 CHARACTER(len=strlen) :: str = ""
3459 WRITE (*,*) 'Enter text:'
3461 CALL fget(str(i:i), status)
3462 if (status /= 0 .OR. i > strlen) exit
3465 WRITE (*,*) TRIM(str)
3469 @item @emph{See also}:
3470 @ref{FGETC}, @ref{FPUT}, @ref{FPUTC}
3475 @section @code{FGETC} --- Read a single character in stream mode
3476 @cindex @code{FGETC} intrinsic
3477 @cindex file operations
3478 @cindex stream operations
3481 @item @emph{Description}:
3482 Read a single character in stream mode by bypassing normal formatted output.
3483 Stream I/O should not be mixed with normal record-oriented (formatted or
3484 unformatted) I/O on the same unit; the results are unpredictable.
3486 This intrinsic routine is provided for backwards compatibility with
3487 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
3488 Programmers should consider the use of new stream IO feature in new code
3489 for future portability. See also @ref{Fortran 2003 status}.
3491 @item @emph{Standard}:
3495 Non-elemental subroutine
3497 @item @emph{Syntax}:
3498 @code{CALL FGETC(UNIT,C[,STATUS])}
3500 @item @emph{Arguments}:
3501 @multitable @columnfractions .15 .80
3502 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
3503 @item @var{C} @tab The type shall be @code{CHARACTER}.
3504 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. Returns 0 on success,
3505 -1 on end-of-file and a system specific positive error code otherwise.
3508 @item @emph{Example}:
3511 INTEGER :: fd = 42, status
3514 OPEN(UNIT=fd, FILE="/etc/passwd", ACTION="READ", STATUS = "OLD")
3516 CALL fgetc(fd, c, status)
3517 IF (status /= 0) EXIT
3524 @item @emph{See also}:
3525 @ref{FGET}, @ref{FPUT}, @ref{FPUTC}
3531 @section @code{FLOOR} --- Integer floor function
3532 @cindex @code{FLOOR} intrinsic
3536 @item @emph{Description}:
3537 @code{FLOOR(X)} returns the greatest integer less than or equal to @var{X}.
3539 @item @emph{Standard}:
3545 @item @emph{Syntax}:
3546 @code{I = FLOOR(X[,KIND])}
3548 @item @emph{Arguments}:
3549 @multitable @columnfractions .15 .80
3550 @item @var{X} @tab The type shall be @code{REAL(*)}.
3551 @item @var{KIND} @tab Optional scaler integer initialization expression.
3554 @item @emph{Return value}:
3555 The return value is of type @code{INTEGER(KIND)}
3557 @item @emph{Example}:
3562 print *, floor(x) ! returns 63
3563 print *, floor(y) ! returns -64
3564 end program test_floor
3567 @item @emph{See also}:
3568 @ref{CEILING}, @ref{NINT}
3575 @section @code{FLUSH} --- Flush I/O unit(s)
3576 @cindex @code{FLUSH} intrinsic
3577 @cindex flush output files
3580 @item @emph{Description}:
3581 Flushes Fortran unit(s) currently open for output. Without the optional
3582 argument, all units are flushed, otherwise just the unit specified.
3584 @item @emph{Standard}:
3588 non-elemental subroutine
3590 @item @emph{Syntax}:
3591 @code{CALL FLUSH(UNIT)}
3593 @item @emph{Arguments}:
3594 @multitable @columnfractions .15 .80
3595 @item @var{UNIT} @tab (Optional) The type shall be @code{INTEGER}.
3599 Beginning with the Fortran 2003 standard, there is a @code{FLUSH}
3600 statement that should be preferred over the @code{FLUSH} intrinsic.
3607 @section @code{FNUM} --- File number function
3608 @cindex @code{FNUM} intrinsic
3612 @item @emph{Description}:
3613 @code{FNUM(UNIT)} returns the POSIX file descriptor number corresponding to the
3614 open Fortran I/O unit @code{UNIT}.
3616 @item @emph{Standard}:
3620 non-elemental function
3622 @item @emph{Syntax}:
3623 @code{I = FNUM(UNIT)}
3625 @item @emph{Arguments}:
3626 @multitable @columnfractions .15 .80
3627 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
3630 @item @emph{Return value}:
3631 The return value is of type @code{INTEGER}
3633 @item @emph{Example}:
3637 open (unit=10, status = "scratch")
3641 end program test_fnum
3648 @section @code{FPUT} --- Write a single character in stream mode to stdout
3649 @cindex @code{FPUT} intrinsic
3650 @cindex file operations
3651 @cindex stream operations
3654 @item @emph{Description}:
3655 Write a single character in stream mode to stdout by bypassing normal
3656 formatted output. Stream I/O should not be mixed with normal record-oriented
3657 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
3659 This intrinsic routine is provided for backwards compatibility with
3660 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
3661 Programmers should consider the use of new stream IO feature in new code
3662 for future portability. See also @ref{Fortran 2003 status}.
3664 @item @emph{Standard}:
3668 Non-elemental subroutine
3670 @item @emph{Syntax}:
3671 @code{CALL FPUT(C[,STATUS])}
3673 @item @emph{Arguments}:
3674 @multitable @columnfractions .15 .80
3675 @item @var{C} @tab The type shall be @code{CHARACTER}.
3676 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. Returns 0 on success,
3677 -1 on end-of-file and a system specific positive error code otherwise.
3680 @item @emph{Example}:
3683 CHARACTER(len=*) :: str = "gfortran"
3685 DO i = 1, len_trim(str)
3691 @item @emph{See also}:
3692 @ref{FPUTC}, @ref{FGET}, @ref{FGETC}
3698 @section @code{FPUTC} --- Write a single character in stream mode
3699 @cindex @code{FPUTC} intrinsic
3700 @cindex file operations
3701 @cindex stream operations
3704 @item @emph{Description}:
3705 Write a single character in stream mode by bypassing normal formatted
3706 output. Stream I/O should not be mixed with normal record-oriented
3707 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
3709 This intrinsic routine is provided for backwards compatibility with
3710 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
3711 Programmers should consider the use of new stream IO feature in new code
3712 for future portability. See also @ref{Fortran 2003 status}.
3714 @item @emph{Standard}:
3718 Non-elemental subroutine
3720 @item @emph{Syntax}:
3721 @code{CALL FPUTC(UNIT,C[,STATUS])}
3723 @item @emph{Arguments}:
3724 @multitable @columnfractions .15 .80
3725 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
3726 @item @var{C} @tab The type shall be @code{CHARACTER}.
3727 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. Returns 0 on success,
3728 -1 on end-of-file and a system specific positive error code otherwise.
3731 @item @emph{Example}:
3734 CHARACTER(len=*) :: str = "gfortran"
3735 INTEGER :: fd = 42, i
3737 OPEN(UNIT = fd, FILE = "out", ACTION = "WRITE", STATUS="NEW")
3738 DO i = 1, len_trim(str)
3739 CALL fputc(fd, str(i:i))
3745 @item @emph{See also}:
3746 @ref{FPUT}, @ref{FGET}, @ref{FGETC}
3752 @section @code{FRACTION} --- Fractional part of the model representation
3753 @cindex @code{FRACTION} intrinsic
3754 @cindex fractional part
3757 @item @emph{Description}:
3758 @code{FRACTION(X)} returns the fractional part of the model
3759 representation of @code{X}.
3761 @item @emph{Standard}:
3767 @item @emph{Syntax}:
3768 @code{Y = FRACTION(X)}
3770 @item @emph{Arguments}:
3771 @multitable @columnfractions .15 .80
3772 @item @var{X} @tab The type of the argument shall be a @code{REAL}.
3775 @item @emph{Return value}:
3776 The return value is of the same type and kind as the argument.
3777 The fractional part of the model representation of @code{X} is returned;
3778 it is @code{X * RADIX(X)**(-EXPONENT(X))}.
3780 @item @emph{Example}:
3782 program test_fraction
3785 print *, fraction(x), x * radix(x)**(-exponent(x))
3786 end program test_fraction
3794 @section @code{FREE} --- Frees memory
3795 @cindex @code{FREE} intrinsic
3796 @cindex Cray pointers
3799 @item @emph{Description}:
3800 Frees memory previously allocated by @code{MALLOC()}. The @code{FREE}
3801 intrinsic is an extension intended to be used with Cray pointers, and is
3802 provided in GNU Fortran to allow user to compile legacy code. For
3803 new code using Fortran 95 pointers, the memory de-allocation intrinsic is
3806 @item @emph{Standard}:
3812 @item @emph{Syntax}:
3815 @item @emph{Arguments}:
3816 @multitable @columnfractions .15 .80
3817 @item @var{PTR} @tab The type shall be @code{INTEGER}. It represents the
3818 location of the memory that should be de-allocated.
3821 @item @emph{Return value}:
3824 @item @emph{Example}:
3825 See @code{MALLOC} for an example.
3827 @item @emph{See also}:
3835 @section @code{FSTAT} --- Get file status
3836 @cindex @code{FSTAT} intrinsic
3837 @cindex file system operations
3840 @item @emph{Description}:
3841 @code{FSTAT} is identical to @ref{STAT}, except that information about an
3842 already opened file is obtained.
3844 The elements in @code{BUFF} are the same as described by @ref{STAT}.
3846 @item @emph{Standard}:
3850 Non-elemental subroutine
3852 @item @emph{Syntax}:
3853 @code{CALL fstat(UNIT,BUFF[,STATUS])}
3855 @item @emph{Arguments}:
3856 @multitable @columnfractions .15 .80
3857 @item @var{UNIT} @tab An open I/O unit number of type @code{INTEGER}.
3858 @item @var{BUFF} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
3859 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0
3860 on success and a system specific error code otherwise.
3863 @item @emph{Example}:
3864 See @ref{STAT} for an example.
3866 @item @emph{See also}:
3867 To stat a link: @ref{LSTAT}, to stat a file: @ref{STAT}
3873 @section @code{FSEEK} --- Low level file positioning subroutine
3874 @cindex @code{FSEEK} intrinsic
3875 @cindex file system operations
3877 Not yet implemented in GNU Fortran.
3880 @item @emph{Description}:
3882 @item @emph{Standard}:
3888 @item @emph{Syntax}:
3889 @item @emph{Arguments}:
3890 @item @emph{Return value}:
3891 @item @emph{Example}:
3892 @item @emph{Specific names}:
3893 @item @emph{See also}:
3894 @uref{http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19292, g77 features lacking in gfortran}
3901 @section @code{FTELL} --- Current stream position
3902 @cindex @code{FTELL} intrinsic
3905 @item @emph{Description}:
3906 Retrieves the current position within an open file.
3908 This intrinsic is provided in both subroutine and function forms; however,
3909 only one form can be used in any given program unit.
3911 @item @emph{Standard}:
3915 Subroutine, function
3917 @item @emph{Syntax}:
3918 @multitable @columnfractions .80
3919 @item @code{CALL FTELL(UNIT, OFFSET)}
3920 @item @code{OFFSET = FTELL(UNIT)}
3923 @item @emph{Arguments}:
3924 @multitable @columnfractions .15 .80
3925 @item @var{OFFSET} @tab Shall of type @code{INTEGER}.
3926 @item @var{UNIT} @tab Shall of type @code{INTEGER}.
3929 @item @emph{Return value}:
3930 In either syntax, @var{OFFSET} is set to the current offset of unit
3931 number @var{UNIT}, or to @math{-1} if the unit is not currently open.
3933 @item @emph{Example}:
3937 OPEN(10, FILE="temp.dat")
3943 @item @emph{See also}:
3950 @section @code{GETARG} --- Get command line arguments
3951 @cindex @code{GETARG} intrinsic
3952 @cindex command-line arguments, to program
3955 @item @emph{Description}:
3956 Retrieve the @var{N}th argument that was passed on the
3957 command line when the containing program was invoked.
3959 This intrinsic routine is provided for backwards compatibility with
3960 GNU Fortran 77. In new code, programmers should consider the use of
3961 the @ref{GET_COMMAND_ARGUMENT} intrinsic defined by the Fortran 2003
3964 @item @emph{Standard}:
3970 @item @emph{Syntax}:
3971 @code{CALL GETARG(N,ARG)}
3973 @item @emph{Arguments}:
3974 @multitable @columnfractions .15 .80
3975 @item @var{N} @tab Shall of type @code{INTEGER(4)}, @math{@var{N} \geq 0}
3976 @item @var{ARG} @tab Shall be of type @code{CHARACTER(*)}.
3979 @item @emph{Return value}:
3980 After @code{GETARG} returns, the @var{ARG} argument holds the @var{N}th
3981 command line argument. If @var{ARG} can not hold the argument, it is
3982 truncated to fit the length of @var{ARG}. If there are less than @var{N}
3983 arguments specified at the command line, @var{ARG} will be filled with blanks.
3984 If @math{@var{N} = 0}, @var{ARG} is set to the name of the program (on systems
3985 that support this feature).
3987 @item @emph{Example}:
3991 CHARACTER(len=32) :: arg
4000 @item @emph{See also}:
4001 GNU Fortran 77 compatibility function: @ref{IARGC}
4003 F2003 functions and subroutines: @ref{GET_COMMAND}, @ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
4009 @section @code{GET_COMMAND} --- Get the entire command line
4010 @cindex @code{GET_COMMAND} intrinsic
4011 @cindex command-line arguments, to program
4014 @item @emph{Description}:
4015 Retrieve the entire command line that was used to invoke the program.
4017 @item @emph{Standard}:
4023 @item @emph{Syntax}:
4024 @code{CALL GET_COMMAND(CMD)}
4026 @item @emph{Arguments}:
4027 @multitable @columnfractions .15 .80
4028 @item @var{CMD} @tab Shall be of type @code{CHARACTER(*)}.
4031 @item @emph{Return value}:
4032 Stores the entire command line that was used to invoke the program in @var{ARG}.
4033 If @var{ARG} is not large enough, the command will be truncated.
4035 @item @emph{Example}:
4037 PROGRAM test_get_command
4038 CHARACTER(len=255) :: cmd
4039 CALL get_command(cmd)
4040 WRITE (*,*) TRIM(cmd)
4044 @item @emph{See also}:
4045 @ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
4050 @node GET_COMMAND_ARGUMENT
4051 @section @code{GET_COMMAND_ARGUMENT} --- Get command line arguments
4052 @cindex @code{GET_COMMAND_ARGUMENT} intrinsic
4053 @cindex command-line arguments, to program
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 @cindex @code{GETCWD} intrinsic
4109 @cindex file system operations
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 @cindex @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 @cindex @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 @cindex @code{GETGID} intrinsic
4239 @cindex file system operations
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 @cindex @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 @cindex @code{GETPID} intrinsic
4313 @cindex process ID, current
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 @cindex @code{GETUID} intrinsic
4351 @cindex user ID, current
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 @cindex @code{GMTIME} intrinsic
4383 @cindex time, conversion 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 @cindex @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 @cindex @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 @cindex @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 @cindex @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 @cindex @code{IARGC} intrinsic
4572 @cindex command-line arguments, to program
4575 @item @emph{Description}:
4576 @code{IARGC()} returns the number of arguments passed on the
4577 command line when the containing program was invoked.
4579 This intrinsic routine is provided for backwards compatibility with
4580 GNU Fortran 77. In new code, programmers should consider the use of
4581 the @ref{COMMAND_ARGUMENT_COUNT} intrinsic defined by the Fortran 2003
4584 @item @emph{Standard}:
4588 Non-elemental Function
4590 @item @emph{Syntax}:
4593 @item @emph{Arguments}:
4596 @item @emph{Return value}:
4597 The number of command line arguments, type @code{INTEGER(4)}.
4599 @item @emph{Example}:
4602 @item @emph{See also}:
4603 GNU Fortran 77 compatibility subroutine: @ref{GETARG}
4605 F2003 functions and subroutines: @ref{GET_COMMAND}, @ref{GET_COMMAND_ARGUMENT}, @ref{COMMAND_ARGUMENT_COUNT}
4611 @section @code{IBCLR} --- Clear bit
4612 @cindex @code{IBCLR} intrinsic
4613 @cindex bit operations
4615 Intrinsic implemented, documentation pending.
4618 @item @emph{Description}:
4619 @item @emph{Standard}:
4625 @item @emph{Syntax}:
4626 @item @emph{Arguments}:
4627 @item @emph{Return value}:
4628 @item @emph{Example}:
4629 @item @emph{Specific names}:
4631 @item @emph{See also}:
4632 @ref{IBITS}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
4639 @section @code{IBITS} --- Bit extraction
4640 @cindex @code{IBITS} intrinsic
4641 @cindex bit operations
4643 Intrinsic implemented, documentation pending.
4646 @item @emph{Description}:
4647 @item @emph{Standard}:
4653 @item @emph{Syntax}:
4654 @item @emph{Arguments}:
4655 @item @emph{Return value}:
4656 @item @emph{Example}:
4657 @item @emph{Specific names}:
4658 @item @emph{See also}:
4659 @ref{IBCLR}, @ref{IBSET}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
4667 @section @code{IBSET} --- Set bit
4668 @cindex @code{IBSET} intrinsic
4669 @cindex bit operations
4671 Intrinsic implemented, documentation pending.
4674 @item @emph{Description}:
4675 @item @emph{Standard}:
4681 @item @emph{Syntax}:
4682 @item @emph{Arguments}:
4683 @item @emph{Return value}:
4684 @item @emph{Example}:
4685 @item @emph{Specific names}:
4687 @item @emph{See also}:
4688 @ref{IBCLR}, @ref{IBITS}, @ref{IAND}, @ref{IOR}, @ref{IEOR}
4695 @section @code{ICHAR} --- Character-to-integer conversion function
4696 @cindex @code{ICHAR} intrinsic
4697 @cindex conversion function (character)
4700 @item @emph{Description}:
4701 @code{ICHAR(C)} returns the code for the character in the first character
4702 position of @code{C} in the system's native character set.
4703 The correspondence between characters and their codes is not necessarily
4704 the same across different GNU Fortran implementations.
4706 @item @emph{Standard}:
4712 @item @emph{Syntax}:
4715 @item @emph{Arguments}:
4716 @multitable @columnfractions .15 .80
4717 @item @var{C} @tab Shall be a scalar @code{CHARACTER}, with @code{INTENT(IN)}
4720 @item @emph{Return value}:
4721 The return value is of type @code{INTEGER} and of the default integer
4724 @item @emph{Example}:
4729 end program test_ichar
4733 No intrinsic exists to convert a printable character string to a numerical
4734 value. For example, there is no intrinsic that, given the @code{CHARACTER}
4735 value 154, returns an @code{INTEGER} or @code{REAL} value with the
4738 Instead, you can use internal-file I/O to do this kind of conversion. For
4743 character(len=10) string
4746 read (string,'(I10)') value
4748 end program read_val
4753 @section @code{IDATE} --- Get current local time subroutine (day/month/year)
4754 @cindex @code{IDATE} intrinsic
4757 @item @emph{Description}:
4758 @code{IDATE(TARRAY)} Fills @var{TARRAY} with the numerical values at the
4759 current local time. The day (in the range 1-31), month (in the range 1-12),
4760 and year appear in elements 1, 2, and 3 of @var{TARRAY}, respectively.
4761 The year has four significant digits.
4763 @item @emph{Standard}:
4769 @item @emph{Syntax}:
4770 @code{CALL IDATE(TARRAY)}
4772 @item @emph{Arguments}:
4773 @multitable @columnfractions .15 .80
4774 @item @var{TARRAY} @tab The type shall be @code{INTEGER, DIMENSION(3)} and
4775 the kind shall be the default integer kind.
4778 @item @emph{Return value}:
4781 @item @emph{Example}:
4784 integer, dimension(3) :: tarray
4789 end program test_idate
4796 @section @code{IEOR} --- Bitwise logical exclusive or
4797 @cindex @code{IEOR} intrinsic
4798 @cindex bit operations
4800 Intrinsic implemented, documentation pending.
4803 @item @emph{Description}:
4804 @item @emph{Standard}:
4810 @item @emph{Syntax}:
4811 @item @emph{Arguments}:
4812 @item @emph{Return value}:
4813 @item @emph{Example}:
4814 @item @emph{Specific names}:
4816 @item @emph{See also}:
4817 @ref{IOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR},
4824 @section @code{IERRNO} --- Get the last system error number
4825 @cindex @code{IERRNO} intrinsic
4826 @cindex undocumented intrinsic
4828 Intrinsic implemented, documentation pending.
4831 @item @emph{Description}:
4832 @item @emph{Standard}:
4836 @item @emph{Syntax}:
4837 @item @emph{Arguments}:
4838 @item @emph{Return value}:
4839 @item @emph{Example}:
4841 @item @emph{See also}:
4849 @section @code{INDEX} --- Position of a substring within a string
4850 @cindex @code{INDEX} intrinsic
4851 @cindex undocumented intrinsic
4853 Intrinsic implemented, documentation pending.
4856 @item @emph{Description}:
4857 @item @emph{Standard}:
4863 @item @emph{Syntax}:
4864 @item @emph{Arguments}:
4865 @item @emph{Return value}:
4866 @item @emph{Example}:
4867 @item @emph{Specific names}:
4868 @item @emph{See also}:
4875 @section @code{INT} --- Convert to integer type
4876 @cindex @code{INT} intrinsic
4877 @cindex @code{IFIX} intrinsic
4878 @cindex @code{IDINT} intrinsic
4879 @cindex conversion function (integer)
4882 @item @emph{Description}:
4883 Convert to integer type
4885 @item @emph{Standard}:
4891 @item @emph{Syntax}:
4892 @multitable @columnfractions .30 .80
4893 @item @code{X = INT(X)}
4894 @item @code{X = INT(X, KIND)}
4897 @item @emph{Arguments}:
4898 @multitable @columnfractions .15 .80
4899 @item @var{X} @tab shall be of type @code{INTEGER(*)}, @code{REAL(*)} or @code{COMPLEX(*)}
4900 @item @var{KIND} @tab (Optional) @var{KIND} shall be a scalar integer.
4903 @item @emph{Return value}:
4904 These functions return a @code{INTEGER(*)} variable or array under
4905 the following rules:
4909 If @var{X} is of type @code{INTEGER(*)}, @code{INT(X) = X}
4911 If @var{X} is of type @code{REAL(*)} and @math{|X| < 1} @code{INT(X)} equals @var{0}.
4912 If @math{|X| \geq 1}, then @code{INT(X)} equals the largest integer that does not exceed
4913 the range of @var{X} and whose sign is the same as the sign of @var{X}.
4915 If @var{X} is of type @code{COMPLEX(*)}, rule B is applied to the real part of X.
4918 @item @emph{Example}:
4922 complex :: z = (-3.7, 1.0)
4924 print *, int(z), int(z,8)
4928 @item @emph{Specific names}:
4929 @multitable @columnfractions .20 .20 .20 .40
4930 @item Name @tab Argument @tab Return type @tab Standard
4931 @item @code{IFIX(X)} @tab @code{REAL(4) X} @tab @code{INTEGER} @tab F77 and later
4932 @item @code{IDINT(X)} @tab @code{REAL(8) X} @tab @code{INTEGER} @tab F77 and later
4935 @comment @item @emph{See also}:
4942 @section @code{IOR} --- Bitwise logical or
4943 @cindex @code{IOR} intrinsic
4944 @cindex bit operations
4946 Intrinsic implemented, documentation pending.
4949 @item @emph{Description}:
4950 @item @emph{Standard}:
4956 @item @emph{Syntax}:
4957 @item @emph{Arguments}:
4958 @item @emph{Return value}:
4959 @item @emph{Example}:
4960 @item @emph{Specific names}:
4962 @item @emph{See also}:
4963 @ref{IEOR}, @ref{IAND}, @ref{IBITS}, @ref{IBSET}, @ref{IBCLR},
4970 @section @code{IRAND} --- Integer pseudo-random number
4971 @cindex @code{IRAND} intrinsic
4972 @cindex random numbers
4975 @item @emph{Description}:
4976 @code{IRAND(FLAG)} returns a pseudo-random number from a uniform
4977 distribution between 0 and a system-dependent limit (which is in most
4978 cases 2147483647). If @var{FLAG} is 0, the next number
4979 in the current sequence is returned; if @var{FLAG} is 1, the generator
4980 is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
4981 it is used as a new seed with @code{SRAND}.
4983 @item @emph{Standard}:
4987 non-elemental function
4989 @item @emph{Syntax}:
4990 @code{I = IRAND(FLAG)}
4992 @item @emph{Arguments}:
4993 @multitable @columnfractions .15 .80
4994 @item @var{FLAG} @tab shall be a scalar @code{INTEGER} of kind 4.
4997 @item @emph{Return value}:
4998 The return value is of @code{INTEGER(kind=4)} type.
5000 @item @emph{Example}:
5003 integer,parameter :: seed = 86456
5006 print *, irand(), irand(), irand(), irand()
5007 print *, irand(seed), irand(), irand(), irand()
5008 end program test_irand
5016 @section @code{ISHFT} --- Shift bits
5017 @cindex @code{ISHFT} intrinsic
5018 @cindex bit operations
5020 Intrinsic implemented, documentation pending.
5023 @item @emph{Description}:
5024 @item @emph{Standard}:
5030 @item @emph{Syntax}:
5031 @item @emph{Arguments}:
5032 @item @emph{Return value}:
5033 @item @emph{Example}:
5034 @item @emph{Specific names}:
5036 @item @emph{See also}:
5044 @section @code{ISHFTC} --- Shift bits circularly
5045 @cindex @code{ISHFTC} intrinsic
5046 @cindex bit operations
5048 Intrinsic implemented, documentation pending.
5051 @item @emph{Description}:
5052 @item @emph{Standard}:
5058 @item @emph{Syntax}:
5059 @item @emph{Arguments}:
5060 @item @emph{Return value}:
5061 @item @emph{Example}:
5062 @item @emph{Specific names}:
5064 @item @emph{See also}:
5071 @section @code{ITIME} --- Get current local time subroutine (hour/minutes/seconds)
5072 @cindex @code{ITIME} intrinsic
5075 @item @emph{Description}:
5076 @code{IDATE(TARRAY)} Fills @var{TARRAY} with the numerical values at the
5077 current local time. The hour (in the range 1-24), minute (in the range 1-60),
5078 and seconds (in the range 1-60) appear in elements 1, 2, and 3 of @var{TARRAY},
5081 @item @emph{Standard}:
5087 @item @emph{Syntax}:
5088 @code{CALL ITIME(TARRAY)}
5090 @item @emph{Arguments}:
5091 @multitable @columnfractions .15 .80
5092 @item @var{TARRAY} @tab The type shall be @code{INTEGER, DIMENSION(3)}
5093 and the kind shall be the default integer kind.
5096 @item @emph{Return value}:
5100 @item @emph{Example}:
5103 integer, dimension(3) :: tarray
5108 end program test_itime
5115 @section @code{KILL} --- Send a signal to a process
5116 @cindex @code{KILL} intrinsic
5117 @cindex undocumented intrinsic
5119 Intrinsic implemented, documentation pending.
5122 @item @emph{Description}:
5123 @item @emph{Standard}:
5129 @item @emph{Syntax}:
5130 @item @emph{Arguments}:
5131 @item @emph{Return value}:
5132 @item @emph{Example}:
5133 @item @emph{Specific names}:
5135 @item @emph{See also}:
5136 @ref{ABORT}, @ref{EXIT}
5142 @section @code{KIND} --- Kind of an entity
5143 @cindex @code{KIND} intrinsic
5146 @item @emph{Description}:
5147 @code{KIND(X)} returns the kind value of the entity @var{X}.
5149 @item @emph{Standard}:
5155 @item @emph{Syntax}:
5158 @item @emph{Arguments}:
5159 @multitable @columnfractions .15 .80
5160 @item @var{X} @tab Shall be of type @code{LOGICAL}, @code{INTEGER},
5161 @code{REAL}, @code{COMPLEX} or @code{CHARACTER}.
5164 @item @emph{Return value}:
5165 The return value is a scalar of type @code{INTEGER} and of the default
5168 @item @emph{Example}:
5171 integer,parameter :: kc = kind(' ')
5172 integer,parameter :: kl = kind(.true.)
5174 print *, "The default character kind is ", kc
5175 print *, "The default logical kind is ", kl
5176 end program test_kind
5184 @section @code{LBOUND} --- Lower dimension bounds of an array
5185 @cindex @code{LBOUND} intrinsic
5186 @cindex undocumented intrinsic
5188 Intrinsic implemented, documentation pending.
5191 @item @emph{Description}:
5192 @item @emph{Standard}:
5198 @item @emph{Syntax}:
5199 @item @emph{Arguments}:
5200 @item @emph{Return value}:
5201 @item @emph{Example}:
5202 @item @emph{See also}:
5210 @section @code{LEN} --- Length of a character entity
5211 @cindex @code{LEN} intrinsic
5212 @cindex undocumented intrinsic
5214 Intrinsic implemented, documentation pending.
5217 @item @emph{Description}:
5218 @item @emph{Standard}:
5224 @item @emph{Syntax}:
5225 @item @emph{Arguments}:
5226 @item @emph{Return value}:
5227 @item @emph{Example}:
5228 @item @emph{Specific names}:
5230 @item @emph{See also}:
5231 @ref{LEN_TRIM}, @ref{ADJUSTL}, @ref{ADJUSTR}
5238 @section @code{LEN_TRIM} --- Length of a character entity without trailing blank characters
5239 @cindex @code{LEN_TRIM} intrinsic
5240 @cindex undocumented intrinsic
5242 Intrinsic implemented, documentation pending.
5245 @item @emph{Description}:
5246 @item @emph{Standard}:
5252 @item @emph{Syntax}:
5253 @item @emph{Arguments}:
5254 @item @emph{Return value}:
5255 @item @emph{Example}:
5257 @item @emph{See also}:
5258 @ref{LEN}, @ref{ADJUSTL}, @ref{ADJUSTR}
5265 @section @code{LGE} --- Lexical greater than or equal
5266 @cindex @code{LGE} intrinsic
5267 @cindex comparison (lexical)
5269 Intrinsic implemented, documentation pending.
5272 @item @emph{Description}:
5273 @item @emph{Standard}:
5279 @item @emph{Syntax}:
5280 @item @emph{Arguments}:
5281 @item @emph{Return value}:
5282 @item @emph{Example}:
5284 @item @emph{See also}:
5285 @ref{LGT}, @ref{LLE}, @ref{LLT}
5292 @section @code{LGT} --- Lexical greater than
5293 @cindex @code{LGT} intrinsic
5294 @cindex comparison (lexical)
5296 Intrinsic implemented, documentation pending.
5299 @item @emph{Description}:
5300 @item @emph{Standard}:
5306 @item @emph{Syntax}:
5307 @item @emph{Arguments}:
5308 @item @emph{Return value}:
5309 @item @emph{Example}:
5311 @item @emph{See also}:
5312 @ref{LGE}, @ref{LLE}, @ref{LLT}
5319 @section @code{LINK} --- Create a hard link
5320 @cindex @code{LINK} intrinsic
5321 @cindex file system operations
5323 Intrinsic implemented, documentation pending.
5326 @item @emph{Description}:
5327 @item @emph{Standard}:
5333 @item @emph{Syntax}:
5334 @item @emph{Arguments}:
5335 @item @emph{Return value}:
5336 @item @emph{Example}:
5337 @item @emph{Specific names}:
5339 @item @emph{See also}:
5347 @section @code{LLE} --- Lexical less than or equal
5348 @cindex @code{LLE} intrinsic
5349 @cindex comparison (lexical)
5351 Intrinsic implemented, documentation pending.
5354 @item @emph{Description}:
5355 @item @emph{Standard}:
5361 @item @emph{Syntax}:
5362 @item @emph{Arguments}:
5363 @item @emph{Return value}:
5364 @item @emph{Example}:
5366 @item @emph{See also}:
5367 @ref{LGE}, @ref{LGT}, @ref{LLT}
5374 @section @code{LLT} --- Lexical less than
5375 @cindex @code{LLT} intrinsic
5376 @cindex comparison (lexical)
5378 Intrinsic implemented, documentation pending.
5381 @item @emph{Description}:
5382 @item @emph{Standard}:
5388 @item @emph{Syntax}:
5389 @item @emph{Arguments}:
5390 @item @emph{Return value}:
5391 @item @emph{Example}:
5393 @item @emph{See also}:
5394 @ref{LGE}, @ref{LGT}, @ref{LLE}
5401 @section @code{LNBLNK} --- Index of the last non-blank character in a string
5402 @cindex @code{LNBLNK} intrinsic
5403 @cindex undocumented intrinsic
5405 Intrinsic implemented, documentation pending.
5408 @item @emph{Description}:
5409 @item @emph{Standard}:
5413 @item @emph{Syntax}:
5414 @item @emph{Arguments}:
5415 @item @emph{Return value}:
5416 @item @emph{Example}:
5417 @item @emph{Specific names}:
5419 @item @emph{See also}:
5420 @ref{INDEX}, @ref{LEN_TRIM}
5427 @section @code{LOC} --- Returns the address of a variable
5428 @cindex @code{LOC} intrinsic
5429 @cindex location of a variable in memory
5432 @item @emph{Description}:
5433 @code{LOC(X)} returns the address of @var{X} as an integer.
5435 @item @emph{Standard}:
5441 @item @emph{Syntax}:
5444 @item @emph{Arguments}:
5445 @multitable @columnfractions .15 .80
5446 @item @var{X} @tab Variable of any type.
5449 @item @emph{Return value}:
5450 The return value is of type @code{INTEGER}, with a @code{KIND}
5451 corresponding to the size (in bytes) of a memory address on the target
5454 @item @emph{Example}:
5461 end program test_loc
5466 @section @code{LOG} --- Logarithm function
5467 @cindex @code{LOG} intrinsic
5468 @cindex @code{ALOG} intrinsic
5469 @cindex @code{DLOG} intrinsic
5470 @cindex @code{CLOG} intrinsic
5471 @cindex @code{ZLOG} intrinsic
5472 @cindex @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 @cindex @code{LOG10} intrinsic
5524 @cindex @code{ALOG10} intrinsic
5525 @cindex @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 @cindex @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 @cindex @code{LSHIFT} intrinsic
5597 @cindex bit operations
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 @cindex @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 @cindex @code{LTIME} intrinsic
5661 @cindex time, conversion 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 @cindex @code{MALLOC} intrinsic
5688 @cindex Cray pointers
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 @cindex @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 @cindex @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 @cindex @code{MAXEXPONENT} intrinsic
5811 @cindex maximum exponent
5812 @cindex exponent, maximum
5815 @item @emph{Description}:
5816 @code{MAXEXPONENT(X)} returns the maximum exponent in the model of the
5819 @item @emph{Standard}:
5825 @item @emph{Syntax}:
5826 @code{I = MAXEXPONENT(X)}
5828 @item @emph{Arguments}:
5829 @multitable @columnfractions .15 .80
5830 @item @var{X} @tab shall be of type @code{REAL}.
5833 @item @emph{Return value}:
5834 The return value is of type @code{INTEGER} and of the default integer
5837 @item @emph{Example}:
5843 print *, minexponent(x), maxexponent(x)
5844 print *, minexponent(y), maxexponent(y)
5845 end program exponents
5851 @section @code{MAXLOC} --- Location of the maximum value within an array
5852 @cindex @code{MAXLOC} intrinsic
5853 @cindex undocumented intrinsic
5855 Intrinsic implemented, documentation pending.
5858 @item @emph{Description}:
5859 @item @emph{Standard}:
5863 Transformational function
5865 @item @emph{Syntax}:
5866 @item @emph{Arguments}:
5867 @item @emph{Return value}:
5868 @item @emph{Example}:
5869 @item @emph{See also}:
5870 @ref{MAX}, @ref{MAXVAL}
5876 @section @code{MAXVAL} --- Maximum value of an array
5877 @cindex @code{MAXVAL} intrinsic
5878 @cindex undocumented intrinsic
5880 Intrinsic implemented, documentation pending.
5883 @item @emph{Description}:
5884 @item @emph{Standard}:
5888 Transformational function
5890 @item @emph{Syntax}:
5891 @item @emph{Arguments}:
5892 @item @emph{Return value}:
5893 @item @emph{Example}:
5894 @item @emph{Specific names}:
5896 @item @emph{See also}:
5897 @ref{MAX}, @ref{MAXLOC}
5904 @section @code{MERGE} --- Merge arrays
5905 @cindex @code{MERGE} intrinsic
5906 @cindex undocumented intrinsic
5908 Intrinsic implemented, documentation pending.
5911 @item @emph{Description}:
5912 @item @emph{Standard}:
5918 @item @emph{Syntax}:
5919 @item @emph{Arguments}:
5920 @item @emph{Return value}:
5921 @item @emph{Example}:
5922 @item @emph{Specific names}:
5923 @item @emph{See also}:
5928 @section @code{MIN} --- Minimum value of an argument list
5929 @cindex @code{MIN} intrinsic
5930 @cindex undocumented intrinsic
5932 Intrinsic implemented, documentation pending.
5935 @item @emph{Description}:
5936 @item @emph{Standard}:
5942 @item @emph{Syntax}:
5943 @item @emph{Arguments}:
5944 @item @emph{Return value}:
5945 @item @emph{Example}:
5947 @item @emph{Specific names}:
5948 @multitable @columnfractions .20 .20 .20 .40
5949 @item Name @tab Argument @tab Return type @tab Standard
5950 @item @code{MIN0(I)} @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)} @tab F77 and later
5951 @item @code{AMIN0(I)} @tab @code{INTEGER(4) I} @tab @code{REAL(MIN(X))} @tab F77 and later
5952 @item @code{MIN1(X)} @tab @code{REAL(*) X} @tab @code{INT(MIN(X))} @tab F77 and later
5953 @item @code{AMIN1(X)} @tab @code{REAL(4) X} @tab @code{REAL(4)} @tab F77 and later
5954 @item @code{DMIN1(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
5957 @item @emph{See also}:
5958 @ref{MINLOC}, @ref{MINVAL}
5962 @section @code{MINEXPONENT} --- Minimum exponent of a real kind
5963 @cindex @code{MINEXPONENT} intrinsic
5964 @cindex minimum exponent
5965 @cindex exponent, minimum
5968 @item @emph{Description}:
5969 @code{MINEXPONENT(X)} returns the minimum exponent in the model of the
5972 @item @emph{Standard}:
5978 @item @emph{Syntax}:
5979 @code{I = MINEXPONENT(X)}
5981 @item @emph{Arguments}:
5982 @multitable @columnfractions .15 .80
5983 @item @var{X} @tab shall be of type @code{REAL}.
5986 @item @emph{Return value}:
5987 The return value is of type @code{INTEGER} and of the default integer
5990 @item @emph{Example}:
5991 See @code{MAXEXPONENT} for an example.
5996 @section @code{MINLOC} --- Location of the minimum value within an array
5997 @cindex @code{MINLOC} intrinsic
5998 @cindex undocumented intrinsic
6000 Intrinsic implemented, documentation pending.
6003 @item @emph{Description}:
6004 @item @emph{Standard}:
6008 Transformational function
6010 @item @emph{Syntax}:
6011 @item @emph{Arguments}:
6012 @item @emph{Return value}:
6013 @item @emph{Example}:
6015 @item @emph{See also}:
6016 @ref{MIN}, @ref{MINVAL}
6022 @section @code{MINVAL} --- Minimum value of an array
6023 @cindex @code{MINVAL} intrinsic
6024 @cindex undocumented intrinsic
6026 Intrinsic implemented, documentation pending.
6029 @item @emph{Description}:
6030 @item @emph{Standard}:
6034 Transformational function
6036 @item @emph{Syntax}:
6037 @item @emph{Arguments}:
6038 @item @emph{Return value}:
6039 @item @emph{Example}:
6041 @item @emph{See also}:
6042 @ref{MIN}, @ref{MINLOC}
6049 @section @code{MOD} --- Remainder function
6050 @cindex @code{MOD} intrinsic
6051 @cindex @code{AMOD} intrinsic
6052 @cindex @code{DMOD} intrinsic
6056 @item @emph{Description}:
6057 @code{MOD(A,P)} computes the remainder of the division of A by P. It is
6058 calculated as @code{A - (INT(A/P) * P)}.
6060 @item @emph{Standard}:
6066 @item @emph{Syntax}:
6069 @item @emph{Arguments}:
6070 @multitable @columnfractions .15 .80
6071 @item @var{A} @tab shall be a scalar of type @code{INTEGER} or @code{REAL}
6072 @item @var{P} @tab shall be a scalar of the same type as @var{A} and not
6076 @item @emph{Return value}:
6077 The kind of the return value is the result of cross-promoting
6078 the kinds of the arguments.
6080 @item @emph{Example}:
6084 print *, mod(17.5,5.5)
6085 print *, mod(17.5d0,5.5)
6086 print *, mod(17.5,5.5d0)
6089 print *, mod(-17.5,5.5)
6090 print *, mod(-17.5d0,5.5)
6091 print *, mod(-17.5,5.5d0)
6094 print *, mod(17.5,-5.5)
6095 print *, mod(17.5d0,-5.5)
6096 print *, mod(17.5,-5.5d0)
6097 end program test_mod
6100 @item @emph{Specific names}:
6101 @multitable @columnfractions .20 .20 .20 .40
6102 @item Name @tab Arguments @tab Return type @tab Standard
6103 @item @code{AMOD(A,P)} @tab @code{REAL(4)} @tab @code{REAL(4)} @tab F95 and later
6104 @item @code{DMOD(A,P)} @tab @code{REAL(8)} @tab @code{REAL(8)} @tab F95 and later
6111 @section @code{MODULO} --- Modulo function
6112 @cindex @code{MODULO} intrinsic
6116 @item @emph{Description}:
6117 @code{MODULO(A,P)} computes the @var{A} modulo @var{P}.
6119 @item @emph{Standard}:
6125 @item @emph{Syntax}:
6126 @code{X = MODULO(A,P)}
6128 @item @emph{Arguments}:
6129 @multitable @columnfractions .15 .80
6130 @item @var{A} @tab shall be a scalar of type @code{INTEGER} or @code{REAL}
6131 @item @var{P} @tab shall be a scalar of the same type and kind as @var{A}
6134 @item @emph{Return value}:
6135 The type and kind of the result are those of the arguments.
6137 @item If @var{A} and @var{P} are of type @code{INTEGER}:
6138 @code{MODULO(A,P)} has the value @var{R} such that @code{A=Q*P+R}, where
6139 @var{Q} is an integer and @var{R} is between 0 (inclusive) and @var{P}
6141 @item If @var{A} and @var{P} are of type @code{REAL}:
6142 @code{MODULO(A,P)} has the value of @code{A - FLOOR (A / P) * P}.
6144 In all cases, if @var{P} is zero the result is processor-dependent.
6146 @item @emph{Example}:
6149 print *, modulo(17,3)
6150 print *, modulo(17.5,5.5)
6152 print *, modulo(-17,3)
6153 print *, modulo(-17.5,5.5)
6155 print *, modulo(17,-3)
6156 print *, modulo(17.5,-5.5)
6157 end program test_mod
6165 @section @code{MVBITS} --- Move bits from one integer to another
6166 @cindex @code{MVBITS} intrinsic
6167 @cindex bit operations
6169 Intrinsic implemented, documentation pending.
6172 @item @emph{Description}:
6173 @item @emph{Standard}:
6177 Elemental subroutine
6179 @item @emph{Syntax}:
6180 @item @emph{Arguments}:
6181 @item @emph{Return value}:
6182 @item @emph{Example}:
6183 @item @emph{See also}:
6190 @section @code{MOVE_ALLOC} --- Move allocation from one object to another
6191 @cindex @code{MOVE_ALLOC} intrinsic
6192 @cindex moving allocation
6193 @cindex allocation, moving
6196 @item @emph{Description}:
6197 @code{MOVE_ALLOC(SRC, DEST)} moves the allocation from @var{SRC} to
6198 @var{DEST}. @var{SRC} will become deallocated in the process.
6200 @item @emph{Standard}:
6206 @item @emph{Syntax}:
6207 @code{CALL MOVE_ALLOC(SRC, DEST)}
6209 @item @emph{Arguments}:
6210 @multitable @columnfractions .15 .80
6211 @item @var{SRC} @tab @code{ALLOCATABLE}, @code{INTENT(INOUT)}, may be of any type and kind.
6212 @item @var{DEST} @tab @code{ALLOCATABLE}, @code{INTENT(OUT)}, shall be of the same type, kind and rank as @var{SRC}
6215 @item @emph{Return value}:
6218 @item @emph{Example}:
6220 program test_move_alloc
6221 integer, allocatable :: a(:), b(:)
6225 call move_alloc(a, b)
6226 print *, allocated(a), allocated(b)
6228 end program test_move_alloc
6235 @section @code{NEAREST} --- Nearest representable number
6236 @cindex @code{NEAREST} intrinsic
6237 @cindex processor-representable number
6240 @item @emph{Description}:
6241 @code{NEAREST(X, S)} returns the processor-representable number nearest
6242 to @code{X} in the direction indicated by the sign of @code{S}.
6244 @item @emph{Standard}:
6250 @item @emph{Syntax}:
6251 @code{Y = NEAREST(X, S)}
6253 @item @emph{Arguments}:
6254 @multitable @columnfractions .15 .80
6255 @item @var{X} @tab shall be of type @code{REAL}.
6256 @item @var{S} @tab (Optional) shall be of type @code{REAL} and
6260 @item @emph{Return value}:
6261 The return value is of the same type as @code{X}. If @code{S} is
6262 positive, @code{NEAREST} returns the processor-representable number
6263 greater than @code{X} and nearest to it. If @code{S} is negative,
6264 @code{NEAREST} returns the processor-representable number smaller than
6265 @code{X} and nearest to it.
6267 @item @emph{Example}:
6269 program test_nearest
6271 x = nearest(42.0, 1.0)
6272 y = nearest(42.0, -1.0)
6273 write (*,"(3(G20.15))") x, y, x - y
6274 end program test_nearest
6281 @section @code{NEW_LINE} --- New line character
6282 @cindex @code{NEW_LINE} intrinsic
6283 @cindex @code{NEW_LINE} intrinsic
6286 @item @emph{Description}:
6287 @code{NEW_LINE(C)} returns the new-line character
6289 @item @emph{Standard}:
6295 @item @emph{Syntax}:
6296 @code{C = NEW_LINE(C)}
6298 @item @emph{Arguments}:
6299 @multitable @columnfractions .15 .80
6300 @item @var{C} @tab The argument shall be a scalar or array of the
6301 type @code{CHARACTER}.
6304 @item @emph{Return value}:
6305 Returns a @var{CHARACTER} scalar of length one with the new-line character of
6306 the same kind as parameter @var{C}.
6308 @item @emph{Example}:
6312 write(*,'(A)') 'This is record 1.'//NEW_LINE('A')//'This is record 2.'
6320 @section @code{NINT} --- Nearest whole number
6321 @cindex @code{NINT} intrinsic
6322 @cindex @code{IDNINT} intrinsic
6323 @cindex whole number
6326 @item @emph{Description}:
6327 @code{NINT(X)} rounds its argument to the nearest whole number.
6329 @item @emph{Standard}:
6335 @item @emph{Syntax}:
6338 @item @emph{Arguments}:
6339 @multitable @columnfractions .15 .80
6340 @item @var{X} @tab The type of the argument shall be @code{REAL}.
6343 @item @emph{Return value}:
6344 Returns @var{A} with the fractional portion of its magnitude eliminated by
6345 rounding to the nearest whole number and with its sign preserved,
6346 converted to an @code{INTEGER} of the default kind.
6348 @item @emph{Example}:
6355 print *, nint(x4), idnint(x8)
6356 end program test_nint
6359 @item @emph{Specific names}:
6360 @multitable @columnfractions .33 .33 .33
6361 @item Name @tab Argument @tab Standard
6362 @item @code{IDNINT(X)} @tab @code{REAL(8)} @tab F95 and later
6365 @item @emph{See also}:
6366 @ref{CEILING}, @ref{FLOOR}
6372 @section @code{NOT} --- Logical negation
6373 @cindex @code{NOT} intrinsic
6374 @cindex logical operations
6376 Intrinsic implemented, documentation pending.
6379 @item @emph{Description}:
6380 @item @emph{Standard}:
6386 @item @emph{Syntax}:
6387 @item @emph{Arguments}:
6388 @item @emph{Return value}:
6389 @item @emph{Example}:
6390 @item @emph{See also}:
6397 @section @code{NULL} --- Function that returns an disassociated pointer
6398 @cindex @code{NULL} intrinsic
6399 @cindex undocumented intrinsic
6401 Intrinsic implemented, documentation pending.
6404 @item @emph{Description}:
6405 @item @emph{Standard}:
6409 Transformational function
6411 @item @emph{Syntax}:
6412 @item @emph{Arguments}:
6413 @item @emph{Return value}:
6414 @item @emph{Example}:
6415 @item @emph{See also}:
6423 @section @code{OR} --- Bitwise logical OR
6424 @cindex @code{OR} intrinsic
6425 @cindex bit operations
6428 @item @emph{Description}:
6429 Bitwise logical @code{OR}.
6431 This intrinsic routine is provided for backwards compatibility with
6432 GNU Fortran 77. For integer arguments, programmers should consider
6433 the use of the @ref{IOR} intrinsic defined by the Fortran standard.
6435 @item @emph{Standard}:
6439 Non-elemental function
6441 @item @emph{Syntax}:
6442 @code{RESULT = OR(X, Y)}
6444 @item @emph{Arguments}:
6445 @multitable @columnfractions .15 .80
6446 @item @var{X} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
6447 @item @var{Y} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
6450 @item @emph{Return value}:
6451 The return type is either @code{INTEGER(*)} or @code{LOGICAL}
6452 after cross-promotion of the arguments.
6454 @item @emph{Example}:
6457 LOGICAL :: T = .TRUE., F = ..FALSE.
6459 DATA a / Z'F' /, b / Z'3' /
6461 WRITE (*,*) OR(T, T), OR(T, F), OR(F, T), OR(F, F)
6462 WRITE (*,*) OR(a, b)
6466 @item @emph{See also}:
6467 F95 elemental function: @ref{IOR}
6474 @section @code{PACK} --- Pack an array into an array of rank one
6475 @cindex @code{PACK} intrinsic
6476 @cindex undocumented intrinsic
6478 Intrinsic implemented, documentation pending.
6481 @item @emph{Description}:
6482 @item @emph{Standard}:
6486 Transformational function
6488 @item @emph{Syntax}:
6489 @item @emph{Arguments}:
6490 @item @emph{Return value}:
6491 @item @emph{Example}:
6492 @item @emph{Specific names}:
6493 @item @emph{See also}:
6501 @section @code{PERROR} --- Print system error message
6502 @cindex @code{PERROR} intrinsic
6503 @cindex undocumented intrinsic
6505 Intrinsic implemented, documentation pending.
6508 @item @emph{Description}:
6509 @item @emph{Standard}:
6515 @item @emph{Syntax}:
6516 @item @emph{Arguments}:
6517 @item @emph{Return value}:
6518 @item @emph{Example}:
6519 @item @emph{Specific names}:
6520 @item @emph{See also}:
6528 @section @code{PRECISION} --- Decimal precision of a real kind
6529 @cindex @code{PRECISION} intrinsic
6530 @cindex precision of a real variable
6533 @item @emph{Description}:
6534 @code{PRECISION(X)} returns the decimal precision in the model of the
6537 @item @emph{Standard}:
6543 @item @emph{Syntax}:
6544 @code{I = PRECISION(X)}
6546 @item @emph{Arguments}:
6547 @multitable @columnfractions .15 .80
6548 @item @var{X} @tab shall be of type @code{REAL} or @code{COMPLEX}.
6551 @item @emph{Return value}:
6552 The return value is of type @code{INTEGER} and of the default integer
6555 @item @emph{Example}:
6557 program prec_and_range
6558 real(kind=4) :: x(2)
6559 complex(kind=8) :: y
6561 print *, precision(x), range(x)
6562 print *, precision(y), range(y)
6563 end program prec_and_range
6570 @section @code{PRESENT} --- Determine whether an optional argument is specified
6571 @cindex @code{PRESENT} intrinsic
6572 @cindex undocumented intrinsic
6574 Intrinsic implemented, documentation pending.
6577 @item @emph{Description}:
6578 @item @emph{Standard}:
6584 @item @emph{Syntax}:
6585 @item @emph{Arguments}:
6586 @item @emph{Return value}:
6587 @item @emph{Example}:
6588 @item @emph{See also}:
6595 @section @code{PRODUCT} --- Product of array elements
6596 @cindex @code{PRODUCT} intrinsic
6597 @cindex undocumented intrinsic
6599 Intrinsic implemented, documentation pending.
6602 @item @emph{Description}:
6603 @item @emph{Standard}:
6607 Transformational function
6609 @item @emph{Syntax}:
6610 @item @emph{Arguments}:
6611 @item @emph{Return value}:
6612 @item @emph{Example}:
6613 @item @emph{Specific names}:
6614 @item @emph{See also}:
6622 @section @code{RADIX} --- Base of a model number
6623 @cindex @code{RADIX} intrinsic
6627 @item @emph{Description}:
6628 @code{RADIX(X)} returns the base of the model representing the entity @var{X}.
6630 @item @emph{Standard}:
6636 @item @emph{Syntax}:
6639 @item @emph{Arguments}:
6640 @multitable @columnfractions .15 .80
6641 @item @var{X} @tab Shall be of type @code{INTEGER} or @code{REAL}
6644 @item @emph{Return value}:
6645 The return value is a scalar of type @code{INTEGER} and of the default
6648 @item @emph{Example}:
6651 print *, "The radix for the default integer kind is", radix(0)
6652 print *, "The radix for the default real kind is", radix(0.0)
6653 end program test_radix
6661 @section @code{RANDOM_NUMBER} --- Pseudo-random number
6662 @cindex @code{RANDOM_NUMBER} intrinsic
6663 @cindex random numbers
6665 Intrinsic implemented, documentation pending.
6668 @item @emph{Description}:
6669 @item @emph{Standard}:
6673 Elemental subroutine
6675 @item @emph{Syntax}:
6676 @item @emph{Arguments}:
6677 @item @emph{Return value}:
6678 @item @emph{Example}:
6679 @item @emph{See also}:
6687 @section @code{RANDOM_SEED} --- Initialize a pseudo-random number sequence
6688 @cindex @code{RANDOM_SEED} intrinsic
6689 @cindex random numbers
6691 Intrinsic implemented, documentation pending.
6694 @item @emph{Description}:
6695 @item @emph{Standard}:
6701 @item @emph{Syntax}:
6702 @item @emph{Arguments}:
6703 @item @emph{Return value}:
6704 @item @emph{Example}:
6705 @item @emph{See also}:
6713 @section @code{RAND} --- Real pseudo-random number
6714 @cindex @code{RAND} intrinsic
6715 @cindex @code{RAN} intrinsic
6716 @cindex random numbers
6719 @item @emph{Description}:
6720 @code{RAND(FLAG)} returns a pseudo-random number from a uniform
6721 distribution between 0 and 1. If @var{FLAG} is 0, the next number
6722 in the current sequence is returned; if @var{FLAG} is 1, the generator
6723 is restarted by @code{CALL SRAND(0)}; if @var{FLAG} has any other value,
6724 it is used as a new seed with @code{SRAND}.
6726 @item @emph{Standard}:
6730 non-elemental function
6732 @item @emph{Syntax}:
6733 @code{X = RAND(FLAG)}
6735 @item @emph{Arguments}:
6736 @multitable @columnfractions .15 .80
6737 @item @var{FLAG} @tab shall be a scalar @code{INTEGER} of kind 4.
6740 @item @emph{Return value}:
6741 The return value is of @code{REAL} type and the default kind.
6743 @item @emph{Example}:
6746 integer,parameter :: seed = 86456
6749 print *, rand(), rand(), rand(), rand()
6750 print *, rand(seed), rand(), rand(), rand()
6751 end program test_rand
6755 For compatibility with HP FORTRAN 77/iX, the @code{RAN} intrinsic is
6756 provided as an alias for @code{RAND}.
6758 @item @emph{See also}:
6759 @ref{SRAND}, @ref{RANDOM_NUMBER}
6766 @section @code{RANGE} --- Decimal exponent range of a real kind
6767 @cindex @code{RANGE} intrinsic
6768 @cindex range of a real variable
6771 @item @emph{Description}:
6772 @code{RANGE(X)} returns the decimal exponent range in the model of the
6775 @item @emph{Standard}:
6781 @item @emph{Syntax}:
6784 @item @emph{Arguments}:
6785 @multitable @columnfractions .15 .80
6786 @item @var{X} @tab shall be of type @code{REAL} or @code{COMPLEX}.
6789 @item @emph{Return value}:
6790 The return value is of type @code{INTEGER} and of the default integer
6793 @item @emph{Example}:
6794 See @code{PRECISION} for an example.
6800 @section @code{RAN} --- Real pseudo-random number
6801 @cindex @code{RAN} intrinsic
6802 @cindex random numbers
6805 @item @emph{Standard}:
6808 @item @emph{See also}:
6809 @ref{RAND}, @ref{RANDOM_NUMBER}
6815 @section @code{REAL} --- Convert to real type
6816 @cindex @code{REAL} intrinsic
6817 @cindex @code{REALPART} intrinsic
6821 @item @emph{Description}:
6822 @code{REAL(X [, KIND])} converts its argument @var{X} to a real type. The
6823 @code{REALPART(X)} function is provided for compatibility with @command{g77},
6824 and its use is strongly discouraged.
6826 @item @emph{Standard}:
6832 @item @emph{Syntax}:
6833 @multitable @columnfractions .30 .80
6834 @item @code{X = REAL(X)}
6835 @item @code{X = REAL(X, KIND)}
6836 @item @code{X = REALPART(Z)}
6839 @item @emph{Arguments}:
6840 @multitable @columnfractions .15 .80
6841 @item @var{X} @tab shall be @code{INTEGER(*)}, @code{REAL(*)}, or
6843 @item @var{KIND} @tab (Optional) @var{KIND} shall be a scalar integer.
6846 @item @emph{Return value}:
6847 These functions return a @code{REAL(*)} variable or array under
6848 the following rules:
6852 @code{REAL(X)} is converted to a default real type if @var{X} is an
6853 integer or real variable.
6855 @code{REAL(X)} is converted to a real type with the kind type parameter
6856 of @var{X} if @var{X} is a complex variable.
6858 @code{REAL(X, KIND)} is converted to a real type with kind type
6859 parameter @var{KIND} if @var{X} is a complex, integer, or real
6863 @item @emph{Example}:
6866 complex :: x = (1.0, 2.0)
6867 print *, real(x), real(x,8), realpart(x)
6868 end program test_real
6871 @item @emph{See also}:
6872 @ref{DBLE}, @ref{DFLOAT}, @ref{FLOAT}
6878 @section @code{RENAME} --- Rename a file
6879 @cindex @code{RENAME} intrinsic
6880 @cindex file system operations
6882 Intrinsic implemented, documentation pending.
6885 @item @emph{Description}:
6886 @item @emph{Standard}:
6892 @item @emph{Syntax}:
6893 @item @emph{Arguments}:
6894 @item @emph{Return value}:
6895 @item @emph{Example}:
6896 @item @emph{See also}:
6903 @section @code{REPEAT} --- Repeated string concatenation
6904 @cindex @code{REPEAT} intrinsic
6905 @cindex string manipulation
6907 Intrinsic implemented, documentation pending.
6910 @item @emph{Description}:
6911 @item @emph{Standard}:
6915 Transformational function
6917 @item @emph{Syntax}:
6918 @item @emph{Arguments}:
6919 @item @emph{Return value}:
6920 @item @emph{Example}:
6921 @item @emph{See also}:
6928 @section @code{RESHAPE} --- Function to reshape an array
6929 @cindex @code{RESHAPE} intrinsic
6930 @cindex array manipulation
6932 Intrinsic implemented, documentation pending.
6935 @item @emph{Description}:
6936 @item @emph{Standard}:
6940 Transformational function
6942 @item @emph{Syntax}:
6943 @item @emph{Arguments}:
6944 @item @emph{Return value}:
6945 @item @emph{Example}:
6946 @item @emph{See also}:
6953 @section @code{RRSPACING} --- Reciprocal of the relative spacing
6954 @cindex @code{RRSPACING} intrinsic
6957 @item @emph{Description}:
6958 @code{RRSPACING(X)} returns the reciprocal of the relative spacing of
6959 model numbers near @var{X}.
6961 @item @emph{Standard}:
6967 @item @emph{Syntax}:
6968 @code{Y = RRSPACING(X)}
6970 @item @emph{Arguments}:
6971 @multitable @columnfractions .15 .80
6972 @item @var{X} @tab shall be of type @code{REAL}.
6975 @item @emph{Return value}:
6976 The return value is of the same type and kind as @var{X}.
6977 The value returned is equal to
6978 @code{ABS(FRACTION(X)) * FLOAT(RADIX(X))**DIGITS(X)}.
6985 @section @code{RSHIFT} --- Right shift bits
6986 @cindex @code{RSHIFT} intrinsic
6987 @cindex bit operations
6989 Not yet implemented in GNU Fortran.
6992 @item @emph{Description}:
6994 @item @emph{Standard}:
7000 @item @emph{Syntax}:
7001 @item @emph{Arguments}:
7002 @item @emph{Return value}:
7003 @item @emph{Example}:
7004 @item @emph{See also}:
7011 @section @code{SCALE} --- Scale a real value
7012 @cindex @code{SCALE} intrinsic
7015 @item @emph{Description}:
7016 @code{SCALE(X,I)} returns @code{X * RADIX(X)**I}.
7018 @item @emph{Standard}:
7024 @item @emph{Syntax}:
7025 @code{Y = SCALE(X, I)}
7027 @item @emph{Arguments}:
7028 @multitable @columnfractions .15 .80
7029 @item @var{X} @tab The type of the argument shall be a @code{REAL}.
7030 @item @var{I} @tab The type of the argument shall be a @code{INTEGER}.
7033 @item @emph{Return value}:
7034 The return value is of the same type and kind as @var{X}.
7035 Its value is @code{X * RADIX(X)**I}.
7037 @item @emph{Example}:
7040 real :: x = 178.1387e-4
7042 print *, scale(x,i), x*radix(x)**i
7043 end program test_scale
7050 @section @code{SCAN} --- Scan a string for the presence of a set of characters
7051 @cindex @code{SCAN} intrinsic
7052 @cindex string manipulation
7054 Intrinsic implemented, documentation pending.
7057 @item @emph{Description}:
7058 @item @emph{Standard}:
7064 @item @emph{Syntax}:
7065 @item @emph{Arguments}:
7066 @item @emph{Return value}:
7067 @item @emph{Example}:
7068 @item @emph{See also}:
7075 @section @code{SECNDS} --- Time function
7076 @cindex @code{SECNDS} intrinsic
7077 @cindex time, current
7078 @cindex current time
7081 @item @emph{Description}:
7082 @code{SECNDS(X)} gets the time in seconds from the real-time system clock.
7083 @var{X} is a reference time, also in seconds. If this is zero, the time in
7084 seconds from midnight is returned. This function is non-standard and its
7087 @item @emph{Standard}:
7093 @item @emph{Syntax}:
7094 @code{T = SECNDS (X)}
7096 @item @emph{Arguments}:
7097 @multitable @columnfractions .15 .80
7098 @item Name @tab Type
7099 @item @var{T} @tab REAL(4)
7100 @item @var{X} @tab REAL(4)
7103 @item @emph{Return value}:
7106 @item @emph{Example}:
7110 print *, secnds (0.0) ! seconds since midnight
7111 t1 = secnds (0.0) ! reference time
7112 do i = 1, 10000000 ! do something
7114 t2 = secnds (t1) ! elapsed time
7115 print *, "Something took ", t2, " seconds."
7116 end program test_secnds
7122 @node SELECTED_INT_KIND
7123 @section @code{SELECTED_INT_KIND} --- Choose integer kind
7124 @cindex @code{SELECTED_INT_KIND} intrinsic
7125 @cindex integer kind
7128 @item @emph{Description}:
7129 @code{SELECTED_INT_KIND(I)} return the kind value of the smallest integer
7130 type that can represent all values ranging from @math{-10^I} (exclusive)
7131 to @math{10^I} (exclusive). If there is no integer kind that accommodates
7132 this range, @code{SELECTED_INT_KIND} returns @math{-1}.
7134 @item @emph{Standard}:
7138 Transformational function
7140 @item @emph{Syntax}:
7141 @multitable @columnfractions .30 .80
7142 @item @code{J = SELECTED_INT_KIND(I)}
7145 @item @emph{Arguments}:
7146 @multitable @columnfractions .15 .80
7147 @item @var{I} @tab shall be a scalar and of type @code{INTEGER}.
7150 @item @emph{Example}:
7152 program large_integers
7153 integer,parameter :: k5 = selected_int_kind(5)
7154 integer,parameter :: k15 = selected_int_kind(15)
7155 integer(kind=k5) :: i5
7156 integer(kind=k15) :: i15
7158 print *, huge(i5), huge(i15)
7160 ! The following inequalities are always true
7161 print *, huge(i5) >= 10_k5**5-1
7162 print *, huge(i15) >= 10_k15**15-1
7163 end program large_integers
7169 @node SELECTED_REAL_KIND
7170 @section @code{SELECTED_REAL_KIND} --- Choose real kind
7171 @cindex @code{SELECTED_REAL_KIND} intrinsic
7175 @item @emph{Description}:
7176 @code{SELECTED_REAL_KIND(P,R)} return the kind value of a real data type
7177 with decimal precision greater of at least @code{P} digits and exponent
7178 range greater at least @code{R}.
7180 @item @emph{Standard}:
7184 Transformational function
7186 @item @emph{Syntax}:
7187 @multitable @columnfractions .30 .80
7188 @item @code{I = SELECTED_REAL_KIND(P,R)}
7191 @item @emph{Arguments}:
7192 @multitable @columnfractions .15 .80
7193 @item @var{P} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
7194 @item @var{R} @tab (Optional) shall be a scalar and of type @code{INTEGER}.
7196 At least one argument shall be present.
7198 @item @emph{Return value}:
7200 @code{SELECTED_REAL_KIND} returns the value of the kind type parameter of
7201 a real data type with decimal precision of at least @code{P} digits and a
7202 decimal exponent range of at least @code{R}. If more than one real data
7203 type meet the criteria, the kind of the data type with the smallest
7204 decimal precision is returned. If no real data type matches the criteria,
7207 @item -1 if the processor does not support a real data type with a
7208 precision greater than or equal to @code{P}
7209 @item -2 if the processor does not support a real type with an exponent
7210 range greater than or equal to @code{R}
7211 @item -3 if neither is supported.
7214 @item @emph{Example}:
7217 integer,parameter :: p6 = selected_real_kind(6)
7218 integer,parameter :: p10r100 = selected_real_kind(10,100)
7219 integer,parameter :: r400 = selected_real_kind(r=400)
7221 real(kind=p10r100) :: y
7222 real(kind=r400) :: z
7224 print *, precision(x), range(x)
7225 print *, precision(y), range(y)
7226 print *, precision(z), range(z)
7227 end program real_kinds
7234 @section @code{SET_EXPONENT} --- Set the exponent of the model
7235 @cindex @code{SET_EXPONENT} intrinsic
7236 @cindex exponent part of a real number
7239 @item @emph{Description}:
7240 @code{SET_EXPONENT(X, I)} returns the real number whose fractional part
7241 is that that of @var{X} and whose exponent part is @var{I}.
7243 @item @emph{Standard}:
7249 @item @emph{Syntax}:
7250 @code{Y = SET_EXPONENT(X, I)}
7252 @item @emph{Arguments}:
7253 @multitable @columnfractions .15 .80
7254 @item @var{X} @tab shall be of type @code{REAL}.
7255 @item @var{I} @tab shall be of type @code{INTEGER}.
7258 @item @emph{Return value}:
7259 The return value is of the same type and kind as @var{X}.
7260 The real number whose fractional part
7261 is that that of @var{X} and whose exponent part if @var{I} is returned;
7262 it is @code{FRACTION(X) * RADIX(X)**I}.
7264 @item @emph{Example}:
7267 real :: x = 178.1387e-4
7269 print *, set_exponent(x), fraction(x) * radix(x)**i
7270 end program test_setexp
7278 @section @code{SHAPE} --- Determine the shape of an array
7279 @cindex @code{SHAPE} intrinsic
7280 @cindex array manipulation
7282 Intrinsic implemented, documentation pending.
7285 @item @emph{Description}:
7286 @item @emph{Standard}:
7292 @item @emph{Syntax}:
7293 @item @emph{Arguments}:
7294 @item @emph{Return value}:
7295 @item @emph{Example}:
7296 @item @emph{See also}:
7304 @section @code{SIGN} --- Sign copying function
7305 @cindex @code{SIGN} intrinsic
7306 @cindex @code{ISIGN} intrinsic
7307 @cindex @code{DSIGN} intrinsic
7308 @cindex sign copying
7311 @item @emph{Description}:
7312 @code{SIGN(A,B)} returns the value of @var{A} with the sign of @var{B}.
7314 @item @emph{Standard}:
7320 @item @emph{Syntax}:
7321 @code{X = SIGN(A,B)}
7323 @item @emph{Arguments}:
7324 @multitable @columnfractions .15 .80
7325 @item @var{A} @tab shall be a scalar of type @code{INTEGER} or @code{REAL}
7326 @item @var{B} @tab shall be a scalar of the same type and kind as @var{A}
7329 @item @emph{Return value}:
7330 The kind of the return value is that of @var{A} and @var{B}.
7331 If @math{B\ge 0} then the result is @code{ABS(A)}, else
7332 it is @code{-ABS(A)}.
7334 @item @emph{Example}:
7337 print *, sign(-12,1)
7338 print *, sign(-12,0)
7339 print *, sign(-12,-1)
7341 print *, sign(-12.,1.)
7342 print *, sign(-12.,0.)
7343 print *, sign(-12.,-1.)
7344 end program test_sign
7347 @item @emph{Specific names}:
7348 @multitable @columnfractions .20 .20 .20 .40
7349 @item Name @tab Arguments @tab Return type @tab Standard
7350 @item @code{ISIGN(A,P)} @tab @code{INTEGER(4)} @tab @code{INTEGER(4)} @tab f95, gnu
7351 @item @code{DSIGN(A,P)} @tab @code{REAL(8)} @tab @code{REAL(8)} @tab f95, gnu
7358 @section @code{SIGNAL} --- Signal handling subroutine (or function)
7359 @cindex @code{SIGNAL} intrinsic
7360 @cindex signal handling
7363 @item @emph{Description}:
7364 @code{SIGNAL(NUMBER, HANDLER [, STATUS])} causes external subroutine
7365 @var{HANDLER} to be executed with a single integer argument when signal
7366 @var{NUMBER} occurs. If @var{HANDLER} is an integer, it can be used to
7367 turn off handling of signal @var{NUMBER} or revert to its default
7368 action. See @code{signal(2)}.
7370 If @code{SIGNAL} is called as a subroutine and the @var{STATUS} argument
7371 is supplied, it is set to the value returned by @code{signal(2)}.
7373 @item @emph{Standard}:
7377 subroutine, non-elemental function
7379 @item @emph{Syntax}:
7380 @multitable @columnfractions .30 .80
7381 @item @code{CALL SIGNAL(NUMBER, HANDLER)}
7382 @item @code{CALL SIGNAL(NUMBER, HANDLER, STATUS)}
7383 @item @code{STATUS = SIGNAL(NUMBER, HANDLER)}
7386 @item @emph{Arguments}:
7387 @multitable @columnfractions .15 .80
7388 @item @var{NUMBER} @tab shall be a scalar integer, with @code{INTENT(IN)}
7389 @item @var{HANDLER}@tab Signal handler (@code{INTEGER FUNCTION} or
7390 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar.
7391 @code{INTEGER}. It is @code{INTENT(IN)}.
7392 @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
7393 integer. It has @code{INTENT(OUT)}.
7396 @item @emph{Return value}:
7397 The @code{SIGNAL} function returns the value returned by @code{signal(2)}.
7399 @item @emph{Example}:
7403 external handler_print
7405 call signal (12, handler_print)
7409 end program test_signal
7417 @section @code{SIN} --- Sine function
7418 @cindex @code{SIN} intrinsic
7419 @cindex @code{DSIN} intrinsic
7420 @cindex @code{ZSIN} intrinsic
7421 @cindex @code{CDSIN} intrinsic
7422 @cindex trigonometric functions
7425 @item @emph{Description}:
7426 @code{SIN(X)} computes the sine of @var{X}.
7428 @item @emph{Standard}:
7434 @item @emph{Syntax}:
7437 @item @emph{Arguments}:
7438 @multitable @columnfractions .15 .80
7439 @item @var{X} @tab The type shall be @code{REAL(*)} or
7443 @item @emph{Return value}:
7444 The return value has same type and kind as @var{X}.
7446 @item @emph{Example}:
7451 end program test_sin
7454 @item @emph{Specific names}:
7455 @multitable @columnfractions .20 .20 .20 .40
7456 @item Name @tab Argument @tab Return type @tab Standard
7457 @item @code{DSIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab f95, gnu
7458 @item @code{CSIN(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab f95, gnu
7459 @item @code{ZSIN(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
7460 @item @code{CDSIN(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab f95, gnu
7463 @item @emph{See also}:
7470 @section @code{SINH} --- Hyperbolic sine function
7471 @cindex @code{SINH} intrinsic
7472 @cindex @code{DSINH} intrinsic
7473 @cindex hyperbolic sine
7476 @item @emph{Description}:
7477 @code{SINH(X)} computes the hyperbolic sine of @var{X}.
7479 @item @emph{Standard}:
7485 @item @emph{Syntax}:
7488 @item @emph{Arguments}:
7489 @multitable @columnfractions .15 .80
7490 @item @var{X} @tab The type shall be @code{REAL(*)}.
7493 @item @emph{Return value}:
7494 The return value is of type @code{REAL(*)}.
7496 @item @emph{Example}:
7499 real(8) :: x = - 1.0_8
7501 end program test_sinh
7504 @item @emph{Specific names}:
7505 @multitable @columnfractions .20 .20 .20 .40
7506 @item Name @tab Argument @tab Return type @tab Standard
7507 @item @code{DSINH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
7510 @item @emph{See also}:
7517 @section @code{SIZE} --- Determine the size of an array
7518 @cindex @code{SIZE} intrinsic
7519 @cindex array manipulation
7521 Intrinsic implemented, documentation pending.
7524 @item @emph{Description}:
7525 @item @emph{Standard}:
7531 @item @emph{Syntax}:
7532 @item @emph{Arguments}:
7533 @item @emph{Return value}:
7534 @item @emph{Example}:
7535 @item @emph{See also}:
7541 @section @code{SNGL} --- Convert double precision real to default real
7542 @cindex @code{SNGL} intrinsic
7543 @cindex conversion function (real)
7546 @item @emph{Description}:
7547 @code{SNGL(A)} converts the double precision real @var{A}
7548 to a default real value. This is an archaic form of @code{REAL}
7549 that is specific to one type for @var{A}.
7551 @item @emph{Standard}:
7557 @item @emph{Syntax}:
7560 @item @emph{Arguments}:
7561 @multitable @columnfractions .15 .80
7562 @item @var{A} @tab The type shall be a double precision @code{REAL}.
7565 @item @emph{Return value}:
7566 The return value is of type default @code{REAL}.
7568 @item @emph{See also}:
7575 @section @code{SPACING} --- Smallest distance between two numbers of a given type
7576 @cindex @code{SPACING} intrinsic
7577 @cindex undocumented intrinsic
7579 Intrinsic implemented, documentation pending.
7582 @item @emph{Description}:
7583 @item @emph{Standard}:
7589 @item @emph{Syntax}:
7590 @item @emph{Arguments}:
7591 @item @emph{Return value}:
7592 @item @emph{Example}:
7593 @item @emph{See also}:
7600 @section @code{SPREAD} --- Add a dimension to an array
7601 @cindex @code{SPREAD} intrinsic
7602 @cindex array manipulation
7604 Intrinsic implemented, documentation pending.
7607 @item @emph{Description}:
7608 @item @emph{Standard}:
7612 Transformational function
7614 @item @emph{Syntax}:
7615 @item @emph{Arguments}:
7616 @item @emph{Return value}:
7617 @item @emph{Example}:
7618 @item @emph{See also}:
7625 @section @code{SQRT} --- Square-root function
7626 @cindex @code{SQRT} intrinsic
7627 @cindex @code{DSQRT} intrinsic
7628 @cindex @code{CSQRT} intrinsic
7629 @cindex @code{ZSQRT} intrinsic
7630 @cindex @code{CDSQRT} intrinsic
7634 @item @emph{Description}:
7635 @code{SQRT(X)} computes the square root of @var{X}.
7637 @item @emph{Standard}:
7643 @item @emph{Syntax}:
7646 @item @emph{Arguments}:
7647 @multitable @columnfractions .15 .80
7648 @item @var{X} @tab The type shall be @code{REAL(*)} or
7652 @item @emph{Return value}:
7653 The return value is of type @code{REAL(*)} or @code{COMPLEX(*)}.
7654 The kind type parameter is the same as @var{X}.
7656 @item @emph{Example}:
7659 real(8) :: x = 2.0_8
7660 complex :: z = (1.0, 2.0)
7663 end program test_sqrt
7666 @item @emph{Specific names}:
7667 @multitable @columnfractions .20 .20 .20 .40
7668 @item Name @tab Argument @tab Return type @tab Standard
7669 @item @code{DSQRT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
7670 @item @code{CSQRT(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab F95 and later
7671 @item @code{ZSQRT(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
7672 @item @code{CDSQRT(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
7679 @section @code{SRAND} --- Reinitialize the random number generator
7680 @cindex @code{SRAND} intrinsic
7681 @cindex random numbers
7684 @item @emph{Description}:
7685 @code{SRAND} reinitializes the pseudo-random number generator
7686 called by @code{RAND} and @code{IRAND}. The new seed used by the
7687 generator is specified by the required argument @var{SEED}.
7689 @item @emph{Standard}:
7693 non-elemental subroutine
7695 @item @emph{Syntax}:
7696 @code{CALL SRAND(SEED)}
7698 @item @emph{Arguments}:
7699 @multitable @columnfractions .15 .80
7700 @item @var{SEED} @tab shall be a scalar @code{INTEGER(kind=4)}.
7703 @item @emph{Return value}:
7706 @item @emph{Example}:
7707 See @code{RAND} and @code{IRAND} for examples.
7710 The Fortran 2003 standard specifies the intrinsic @code{RANDOM_SEED} to
7711 initialize the pseudo-random numbers generator and @code{RANDOM_NUMBER}
7712 to generate pseudo-random numbers. Please note that in
7713 GNU Fortran, these two sets of intrinsics (@code{RAND},
7714 @code{IRAND} and @code{SRAND} on the one hand, @code{RANDOM_NUMBER} and
7715 @code{RANDOM_SEED} on the other hand) access two independent
7716 pseudo-random number generators.
7718 @item @emph{See also}:
7719 @ref{RAND}, @ref{RANDOM_SEED}, @ref{RANDOM_NUMBER}
7725 @section @code{STAT} --- Get file status
7726 @cindex @code{STAT} intrinsic
7727 @cindex file system operations
7730 @item @emph{Description}:
7731 This function returns information about a file. No permissions are required on
7732 the file itself, but execute (search) permission is required on all of the
7733 directories in path that lead to the file.
7735 The elements that are obtained and stored in the array @code{BUFF}:
7736 @multitable @columnfractions .15 .80
7737 @item @code{buff(1)} @tab Device ID
7738 @item @code{buff(2)} @tab Inode number
7739 @item @code{buff(3)} @tab File mode
7740 @item @code{buff(4)} @tab Number of links
7741 @item @code{buff(5)} @tab Owner's uid
7742 @item @code{buff(6)} @tab Owner's gid
7743 @item @code{buff(7)} @tab ID of device containing directory entry for file (0 if not available)
7744 @item @code{buff(8)} @tab File size (bytes)
7745 @item @code{buff(9)} @tab Last access time
7746 @item @code{buff(10)} @tab Last modification time
7747 @item @code{buff(11)} @tab Last file status change time
7748 @item @code{buff(12)} @tab Preferred I/O block size (-1 if not available)
7749 @item @code{buff(13)} @tab Number of blocks allocated (-1 if not available)
7752 Not all these elements are relevant on all systems.
7753 If an element is not relevant, it is returned as 0.
7756 @item @emph{Standard}:
7760 Non-elemental subroutine
7762 @item @emph{Syntax}:
7763 @code{CALL STAT(FILE,BUFF[,STATUS])}
7765 @item @emph{Arguments}:
7766 @multitable @columnfractions .15 .80
7767 @item @var{FILE} @tab The type shall be @code{CHARACTER(*)}, a valid path within the file system.
7768 @item @var{BUFF} @tab The type shall be @code{INTEGER(4), DIMENSION(13)}.
7769 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER(4)}. Returns 0
7770 on success and a system specific error code otherwise.
7773 @item @emph{Example}:
7776 INTEGER, DIMENSION(13) :: buff
7779 CALL STAT("/etc/passwd", buff, status)
7781 IF (status == 0) THEN
7782 WRITE (*, FMT="('Device ID:', T30, I19)") buff(1)
7783 WRITE (*, FMT="('Inode number:', T30, I19)") buff(2)
7784 WRITE (*, FMT="('File mode (octal):', T30, O19)") buff(3)
7785 WRITE (*, FMT="('Number of links:', T30, I19)") buff(4)
7786 WRITE (*, FMT="('Owner''s uid:', T30, I19)") buff(5)
7787 WRITE (*, FMT="('Owner''s gid:', T30, I19)") buff(6)
7788 WRITE (*, FMT="('Device where located:', T30, I19)") buff(7)
7789 WRITE (*, FMT="('File size:', T30, I19)") buff(8)
7790 WRITE (*, FMT="('Last access time:', T30, A19)") CTIME(buff(9))
7791 WRITE (*, FMT="('Last modification time', T30, A19)") CTIME(buff(10))
7792 WRITE (*, FMT="('Last status change time:', T30, A19)") CTIME(buff(11))
7793 WRITE (*, FMT="('Preferred block size:', T30, I19)") buff(12)
7794 WRITE (*, FMT="('No. of blocks allocated:', T30, I19)") buff(13)
7799 @item @emph{See also}:
7800 To stat an open file: @ref{FSTAT}, to stat a link: @ref{LSTAT}
7806 @section @code{SUM} --- Sum of array elements
7807 @cindex @code{SUM} intrinsic
7808 @cindex array manipulation
7810 Intrinsic implemented, documentation pending.
7813 @item @emph{Description}:
7814 @item @emph{Standard}:
7818 Transformational function
7820 @item @emph{Syntax}:
7821 @item @emph{Arguments}:
7822 @item @emph{Return value}:
7823 @item @emph{Example}:
7824 @item @emph{See also}:
7832 @section @code{SYMLNK} --- Create a symbolic link
7833 @cindex @code{SYMLNK} intrinsic
7834 @cindex file system operations
7836 Intrinsic implemented, documentation pending.
7839 @item @emph{Description}:
7840 @item @emph{Standard}:
7844 @item @emph{Syntax}:
7845 @item @emph{Arguments}:
7846 @item @emph{Return value}:
7847 @item @emph{Example}:
7848 @item @emph{See also}:
7855 @section @code{SYSTEM} --- Execute a shell command
7856 @cindex @code{SYSTEM} intrinsic
7857 @cindex undocumented intrinsic
7859 Intrinsic implemented, documentation pending.
7862 @item @emph{Description}:
7863 @item @emph{Standard}:
7869 @item @emph{Syntax}:
7870 @item @emph{Arguments}:
7871 @item @emph{Return value}:
7872 @item @emph{Example}:
7873 @item @emph{See also}:
7880 @section @code{SYSTEM_CLOCK} --- Time function
7881 @cindex @code{SYSTEM_CLOCK} intrinsic
7882 @cindex time, current
7883 @cindex current time
7885 Intrinsic implemented, documentation pending.
7888 @item @emph{Description}:
7889 @item @emph{Standard}:
7895 @item @emph{Syntax}:
7896 @item @emph{Arguments}:
7897 @item @emph{Return value}:
7898 @item @emph{Example}:
7899 @item @emph{See also}:
7905 @section @code{TAN} --- Tangent function
7906 @cindex @code{TAN} intrinsic
7907 @cindex @code{DTAN} intrinsic
7908 @cindex trigonometric functions
7911 @item @emph{Description}:
7912 @code{TAN(X)} computes the tangent of @var{X}.
7914 @item @emph{Standard}:
7920 @item @emph{Syntax}:
7923 @item @emph{Arguments}:
7924 @multitable @columnfractions .15 .80
7925 @item @var{X} @tab The type shall be @code{REAL(*)}.
7928 @item @emph{Return value}:
7929 The return value is of type @code{REAL(*)}. The kind type parameter is
7930 the same as @var{X}.
7932 @item @emph{Example}:
7935 real(8) :: x = 0.165_8
7937 end program test_tan
7940 @item @emph{Specific names}:
7941 @multitable @columnfractions .20 .20 .20 .40
7942 @item Name @tab Argument @tab Return type @tab Standard
7943 @item @code{DTAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
7946 @item @emph{See also}:
7953 @section @code{TANH} --- Hyperbolic tangent function
7954 @cindex @code{TANH} intrinsic
7955 @cindex @code{DTANH} intrinsic
7956 @cindex hyperbolic tangent
7959 @item @emph{Description}:
7960 @code{TANH(X)} computes the hyperbolic tangent of @var{X}.
7962 @item @emph{Standard}:
7968 @item @emph{Syntax}:
7971 @item @emph{Arguments}:
7972 @multitable @columnfractions .15 .80
7973 @item @var{X} @tab The type shall be @code{REAL(*)}.
7976 @item @emph{Return value}:
7977 The return value is of type @code{REAL(*)} and lies in the range
7978 @math{ - 1 \leq tanh(x) \leq 1 }.
7980 @item @emph{Example}:
7983 real(8) :: x = 2.1_8
7985 end program test_tanh
7988 @item @emph{Specific names}:
7989 @multitable @columnfractions .20 .20 .20 .40
7990 @item Name @tab Argument @tab Return type @tab Standard
7991 @item @code{DTANH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F95 and later
7994 @item @emph{See also}:
8001 @section @code{TIME} --- Time function
8002 @cindex @code{TIME} intrinsic
8003 @cindex time, current
8004 @cindex current time
8006 Intrinsic implemented, documentation pending.
8009 @item @emph{Description}:
8010 @item @emph{Standard}:
8014 Non-elemental function
8016 @item @emph{Syntax}:
8017 @item @emph{Arguments}:
8018 @item @emph{Return value}:
8019 @item @emph{Example}:
8020 @item @emph{See also}:
8026 @section @code{TINY} --- Smallest positive number of a real kind
8027 @cindex @code{TINY} intrinsic
8031 @item @emph{Description}:
8032 @code{TINY(X)} returns the smallest positive (non zero) number
8033 in the model of the type of @code{X}.
8035 @item @emph{Standard}:
8041 @item @emph{Syntax}:
8044 @item @emph{Arguments}:
8045 @multitable @columnfractions .15 .80
8046 @item @var{X} @tab shall be of type @code{REAL}.
8049 @item @emph{Return value}:
8050 The return value is of the same type and kind as @var{X}
8052 @item @emph{Example}:
8053 See @code{HUGE} for an example.
8059 @section @code{TRANSFER} --- Transfer bit patterns
8060 @cindex @code{TRANSFER} intrinsic
8061 @cindex bit operations
8063 Intrinsic implemented, documentation pending.
8066 @item @emph{Description}:
8067 @item @emph{Standard}:
8071 Transformational function
8073 @item @emph{Syntax}:
8074 @item @emph{Arguments}:
8075 @item @emph{Return value}:
8076 @item @emph{Example}:
8077 @item @emph{See also}:
8084 @section @code{TRANSPOSE} --- Transpose an array of rank two
8085 @cindex @code{TRANSPOSE} intrinsic
8086 @cindex matrix manipulation
8088 Intrinsic implemented, documentation pending.
8091 @item @emph{Description}:
8092 @item @emph{Standard}:
8096 Transformational function
8098 @item @emph{Syntax}:
8099 @item @emph{Arguments}:
8100 @item @emph{Return value}:
8101 @item @emph{Example}:
8102 @item @emph{See also}:
8109 @section @code{TRIM} --- Function to remove trailing blank characters of a string
8110 @cindex @code{TRIM} intrinsic
8111 @cindex string manipulation
8113 Intrinsic implemented, documentation pending.
8116 @item @emph{Description}:
8117 @item @emph{Standard}:
8121 Transformational function
8123 @item @emph{Syntax}:
8124 @item @emph{Arguments}:
8125 @item @emph{Return value}:
8126 @item @emph{Example}:
8127 @item @emph{See also}:
8134 @section @code{UBOUND} --- Upper dimension bounds of an array
8135 @cindex @code{UBOUND} intrinsic
8136 @cindex undocumented intrinsic
8138 Intrinsic implemented, documentation pending.
8141 @item @emph{Description}:
8143 @item @emph{Standard}:
8149 @item @emph{Syntax}:
8150 @item @emph{Arguments}:
8151 @item @emph{Return value}:
8152 @item @emph{Example}:
8153 @item @emph{Specific names}:
8155 @item @emph{See also}:
8163 @section @code{UMASK} --- Set the file creation mask
8164 @cindex @code{UMASK} intrinsic
8165 @cindex file system operations
8167 Intrinsic implemented, documentation pending.
8170 @item @emph{Description}:
8171 @item @emph{Standard}:
8177 @item @emph{Syntax}:
8178 @item @emph{Arguments}:
8179 @item @emph{Return value}:
8180 @item @emph{Example}:
8181 @item @emph{Specific names}:
8182 @item @emph{See also}:
8189 @section @code{UNLINK} --- Remove a file from the file system
8190 @cindex @code{UNLINK} intrinsic
8191 @cindex file system operations
8193 Intrinsic implemented, documentation pending.
8196 @item @emph{Description}:
8197 @item @emph{Standard}:
8203 @item @emph{Syntax}:
8204 @item @emph{Arguments}:
8205 @item @emph{Return value}:
8206 @item @emph{Example}:
8208 @item @emph{See also}:
8216 @section @code{UNMASK} --- (?)
8217 @cindex @code{UNMASK} intrinsic
8218 @cindex undocumented intrinsic
8220 Intrinsic implemented, documentation pending.
8223 @item @emph{Description}:
8224 @item @emph{Standard}:
8226 @item @emph{Syntax}:
8227 @item @emph{Arguments}:
8228 @item @emph{Return value}:
8229 @item @emph{Example}:
8230 @item @emph{Specific names}:
8231 @item @emph{See also}:
8238 @section @code{UNPACK} --- Unpack an array of rank one into an array
8239 @cindex @code{UNPACK} intrinsic
8240 @cindex array manipulation
8242 Intrinsic implemented, documentation pending.
8245 @item @emph{Description}:
8246 @item @emph{Standard}:
8250 Transformational function
8252 @item @emph{Syntax}:
8253 @item @emph{Arguments}:
8254 @item @emph{Return value}:
8255 @item @emph{Example}:
8257 @item @emph{See also}:
8265 @section @code{VERIFY} --- Scan a string for the absence of a set of characters
8266 @cindex @code{VERIFY} intrinsic
8267 @cindex string manipulation
8269 Intrinsic implemented, documentation pending.
8272 @item @emph{Description}:
8273 @item @emph{Standard}:
8279 @item @emph{Syntax}:
8280 @item @emph{Arguments}:
8281 @item @emph{Return value}:
8282 @item @emph{Example}:
8283 @item @emph{Specific names}:
8284 @item @emph{See also}:
8289 @section @code{XOR} --- Bitwise logical exclusive OR
8290 @cindex @code{XOR} intrinsic
8291 @cindex bit operations
8294 @item @emph{Description}:
8295 Bitwise logical exclusive or.
8297 This intrinsic routine is provided for backwards compatibility with
8298 GNU Fortran 77. For integer arguments, programmers should consider
8299 the use of the @ref{IEOR} intrinsic defined by the Fortran standard.
8301 @item @emph{Standard}:
8305 Non-elemental function
8307 @item @emph{Syntax}:
8308 @code{RESULT = XOR(X, Y)}
8310 @item @emph{Arguments}:
8311 @multitable @columnfractions .15 .80
8312 @item @var{X} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
8313 @item @var{Y} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
8316 @item @emph{Return value}:
8317 The return type is either @code{INTEGER(*)} or @code{LOGICAL}
8318 after cross-promotion of the arguments.
8320 @item @emph{Example}:
8323 LOGICAL :: T = .TRUE., F = .FALSE.
8325 DATA a / Z,'F' /, b / Z'3' /
8327 WRITE (*,*) XOR(T, T), XOR(T, F), XOR(F, T), XOR(F, F)
8328 WRITE (*,*) XOR(a, b)
8332 @item @emph{See also}:
8333 F95 elemental function: @ref{IEOR}