2 Copyright (C) 2005, 2006, 2007
3 Free Software Foundation, Inc.
4 This is part of the GNU Fortran manual.
5 For copying conditions, see the file gfortran.texi.
7 Permission is granted to copy, distribute and/or modify this document
8 under the terms of the GNU Free Documentation License, Version 1.2 or
9 any later version published by the Free Software Foundation; with the
10 Invariant Sections being ``GNU General Public License'' and ``Funding
11 Free Software'', the Front-Cover texts being (a) (see below), and with
12 the Back-Cover Texts being (b) (see below). A copy of the license is
13 included in the gfdl(7) man page.
16 Some basic guidelines for editing this document:
18 (1) The intrinsic procedures are to be listed in alphabetical order.
19 (2) The generic name is to be used.
20 (3) The specific names are included in the function index and in a
21 table at the end of the node (See ABS entry).
22 (4) Try to maintain the same style for each entry.
28 \gdef\acos{\mathop{\rm acos}\nolimits}
29 \gdef\asin{\mathop{\rm asin}\nolimits}
30 \gdef\atan{\mathop{\rm atan}\nolimits}
31 \gdef\acosh{\mathop{\rm acosh}\nolimits}
32 \gdef\asinh{\mathop{\rm asinh}\nolimits}
33 \gdef\atanh{\mathop{\rm atanh}\nolimits}
37 @node Intrinsic Procedures
38 @chapter Intrinsic Procedures
39 @cindex intrinsic procedures
41 This portion of the document is incomplete and undergoing massive expansion
42 and editing. All contributions and corrections are strongly encouraged.
44 Implemented intrinsics are fully functional and available to the user to apply.
45 Some intrinsics have documentation yet to be completed as indicated by 'documentation pending'.
47 @comment Missing intrinsics (double check with #19292)
52 * Introduction: Introduction to Intrinsics
53 * @code{ABORT}: ABORT, Abort the program
54 * @code{ABS}: ABS, Absolute value
55 * @code{ACCESS}: ACCESS, Checks file access modes
56 * @code{ACHAR}: ACHAR, Character in @acronym{ASCII} collating sequence
57 * @code{ACOS}: ACOS, Arccosine function
58 * @code{ACOSH}: ACOSH, Hyperbolic arccosine function
59 * @code{ADJUSTL}: ADJUSTL, Left adjust a string
60 * @code{ADJUSTR}: ADJUSTR, Right adjust a string
61 * @code{AIMAG}: AIMAG, Imaginary part of complex number
62 * @code{AINT}: AINT, Truncate to a whole number
63 * @code{ALARM}: ALARM, Set an alarm clock
64 * @code{ALL}: ALL, Determine if all values are true
65 * @code{ALLOCATED}: ALLOCATED, Status of allocatable entity
66 * @code{AND}: AND, Bitwise logical AND
67 * @code{ANINT}: ANINT, Nearest whole number
68 * @code{ANY}: ANY, Determine if any values are true
69 * @code{ASIN}: ASIN, Arcsine function
70 * @code{ASINH}: ASINH, Hyperbolic arcsine function
71 * @code{ASSOCIATED}: ASSOCIATED, Status of a pointer or pointer/target pair
72 * @code{ATAN}: ATAN, Arctangent function
73 * @code{ATAN2}: ATAN2, Arctangent function
74 * @code{ATANH}: ATANH, Hyperbolic arctangent function
75 * @code{BESJ0}: BESJ0, Bessel function of the first kind of order 0
76 * @code{BESJ1}: BESJ1, Bessel function of the first kind of order 1
77 * @code{BESJN}: BESJN, Bessel function of the first kind
78 * @code{BESY0}: BESY0, Bessel function of the second kind of order 0
79 * @code{BESY1}: BESY1, Bessel function of the second kind of order 1
80 * @code{BESYN}: BESYN, Bessel function of the second kind
81 * @code{BIT_SIZE}: BIT_SIZE, Bit size inquiry function
82 * @code{BTEST}: BTEST, Bit test function
83 * @code{CEILING}: CEILING, Integer ceiling function
84 * @code{CHAR}: CHAR, Integer-to-character conversion function
85 * @code{CHDIR}: CHDIR, Change working directory
86 * @code{CHMOD}: CHMOD, Change access permissions of files
87 * @code{CMPLX}: CMPLX, Complex conversion function
88 * @code{COMMAND_ARGUMENT_COUNT}: COMMAND_ARGUMENT_COUNT, Get number of command line arguments
89 * @code{CONJG}: CONJG, Complex conjugate function
90 * @code{COS}: COS, Cosine function
91 * @code{COSH}: COSH, Hyperbolic cosine function
92 * @code{COUNT}: COUNT, Count occurrences of TRUE in an array
93 * @code{CPU_TIME}: CPU_TIME, CPU time subroutine
94 * @code{CSHIFT}: CSHIFT, Circular array shift function
95 * @code{CTIME}: CTIME, Subroutine (or function) to convert a time into a string
96 * @code{DATE_AND_TIME}: DATE_AND_TIME, Date and time subroutine
97 * @code{DBLE}: DBLE, Double precision conversion function
98 * @code{DCMPLX}: DCMPLX, Double complex conversion function
99 * @code{DFLOAT}: DFLOAT, Double precision conversion function
100 * @code{DIGITS}: DIGITS, Significant digits function
101 * @code{DIM}: DIM, Dim function
102 * @code{DOT_PRODUCT}: DOT_PRODUCT, Dot product function
103 * @code{DPROD}: DPROD, Double product function
104 * @code{DREAL}: DREAL, Double real part function
105 * @code{DTIME}: DTIME, Execution time subroutine (or function)
106 * @code{EOSHIFT}: EOSHIFT, End-off shift function
107 * @code{EPSILON}: EPSILON, Epsilon function
108 * @code{ERF}: ERF, Error function
109 * @code{ERFC}: ERFC, Complementary error function
110 * @code{ETIME}: ETIME, Execution time subroutine (or function)
111 * @code{EXIT}: EXIT, Exit the program with status.
112 * @code{EXP}: EXP, Exponential function
113 * @code{EXPONENT}: EXPONENT, Exponent function
114 * @code{FDATE}: FDATE, Subroutine (or function) to get the current time as a string
115 * @code{FGET}: FGET, Read a single character in stream mode from stdin
116 * @code{FGETC}: FGETC, Read a single character in stream mode
117 * @code{FLOAT}: FLOAT, Convert integer to default real
118 * @code{FLOOR}: FLOOR, Integer floor function
119 * @code{FLUSH}: FLUSH, Flush I/O unit(s)
120 * @code{FNUM}: FNUM, File number function
121 * @code{FPUT}: FPUT, Write a single character in stream mode to stdout
122 * @code{FPUTC}: FPUTC, Write a single character in stream mode
123 * @code{FRACTION}: FRACTION, Fractional part of the model representation
124 * @code{FREE}: FREE, Memory de-allocation subroutine
125 * @code{FSEEK}: FSEEK, Low level file positioning subroutine
126 * @code{FSTAT}: FSTAT, Get file status
127 * @code{FTELL}: FTELL, Current stream position
128 * @code{GETARG}: GETARG, Get command line arguments
129 * @code{GET_COMMAND}: GET_COMMAND, Get the entire command line
130 * @code{GET_COMMAND_ARGUMENT}: GET_COMMAND_ARGUMENT, Get command line arguments
131 * @code{GETCWD}: GETCWD, Get current working directory
132 * @code{GETENV}: GETENV, Get an environmental variable
133 * @code{GET_ENVIRONMENT_VARIABLE}: GET_ENVIRONMENT_VARIABLE, Get an environmental variable
134 * @code{GETGID}: GETGID, Group ID function
135 * @code{GETLOG}: GETLOG, Get login name
136 * @code{GETPID}: GETPID, Process ID function
137 * @code{GETUID}: GETUID, User ID function
138 * @code{GMTIME}: GMTIME, Convert time to GMT info
139 * @code{HOSTNM}: HOSTNM, Get system host name
140 * @code{HUGE}: HUGE, Largest number of a kind
141 * @code{IACHAR}: IACHAR, Code in @acronym{ASCII} collating sequence
142 * @code{IAND}: IAND, Bitwise logical and
143 * @code{IARGC}: IARGC, Get the number of command line arguments
144 * @code{IBCLR}: IBCLR, Clear bit
145 * @code{IBITS}: IBITS, Bit extraction
146 * @code{IBSET}: IBSET, Set bit
147 * @code{ICHAR}: ICHAR, Character-to-integer conversion function
148 * @code{IDATE}: IDATE, Current local time (day/month/year)
149 * @code{IEOR}: IEOR, Bitwise logical exclusive or
150 * @code{IERRNO}: IERRNO, Function to get the last system error number
151 * @code{INDEX}: INDEX, Position of a substring within a string
152 * @code{INT}: INT, Convert to integer type
153 * @code{IOR}: IOR, Bitwise logical or
154 * @code{IRAND}: IRAND, Integer pseudo-random number
155 * @code{ISHFT}: ISHFT, Shift bits
156 * @code{ISHFTC}: ISHFTC, Shift bits circularly
157 * @code{ITIME}: ITIME, Current local time (hour/minutes/seconds)
158 * @code{KILL}: KILL, Send a signal to a process
159 * @code{KIND}: KIND, Kind of an entity
160 * @code{LBOUND}: LBOUND, Lower dimension bounds of an array
161 * @code{LEN}: LEN, Length of a character entity
162 * @code{LEN_TRIM}: LEN_TRIM, Length of a character entity without trailing blank characters
163 * @code{LGE}: LGE, Lexical greater than or equal
164 * @code{LGT}: LGT, Lexical greater than
165 * @code{LINK}: LINK, Create a hard link
166 * @code{LLE}: LLE, Lexical less than or equal
167 * @code{LLT}: LLT, Lexical less than
168 * @code{LNBLNK}: LNBLNK, Index of the last non-blank character in a string
169 * @code{LOC}: LOC, Returns the address of a variable
170 * @code{LOG}: LOG, Logarithm function
171 * @code{LOG10}: LOG10, Base 10 logarithm function
172 * @code{LOGICAL}: LOGICAL, Convert to logical type
173 * @code{LSHIFT}: LSHIFT, Left shift bits
174 * @code{LSTAT}: LSTAT, Get file status
175 * @code{LTIME}: LTIME, Convert time to local time info
176 * @code{MALLOC}: MALLOC, Dynamic memory allocation function
177 * @code{MATMUL}: MATMUL, matrix multiplication
178 * @code{MAX}: MAX, Maximum value of an argument list
179 * @code{MAXEXPONENT}: MAXEXPONENT, Maximum exponent of a real kind
180 * @code{MAXLOC}: MAXLOC, Location of the maximum value within an array
181 * @code{MAXVAL}: MAXVAL, Maximum value of an array
182 * @code{MERGE}: MERGE, Merge arrays
183 * @code{MIN}: MIN, Minimum value of an argument list
184 * @code{MINEXPONENT}: MINEXPONENT, Minimum exponent of a real kind
185 * @code{MINLOC}: MINLOC, Location of the minimum value within an array
186 * @code{MINVAL}: MINVAL, Minimum value of an array
187 * @code{MOD}: MOD, Remainder function
188 * @code{MODULO}: MODULO, Modulo function
189 * @code{MOVE_ALLOC}: MOVE_ALLOC, Move allocation from one object to another
190 * @code{MVBITS}: MVBITS, Move bits from one integer to another
191 * @code{NEAREST}: NEAREST, Nearest representable number
192 * @code{NEW_LINE}: NEW_LINE, New line character
193 * @code{NINT}: NINT, Nearest whole number
194 * @code{NOT}: NOT, Logical negation
195 * @code{NULL}: NULL, Function that returns an disassociated pointer
196 * @code{OR}: OR, Bitwise logical OR
197 * @code{PACK}: PACK, Pack an array into an array of rank one
198 * @code{PERROR}: PERROR, Print system error message
199 * @code{PRECISION}: PRECISION, Decimal precision of a real kind
200 * @code{PRESENT}: PRESENT, Determine whether an optional argument is specified
201 * @code{PRODUCT}: PRODUCT, Product of array elements
202 * @code{RADIX}: RADIX, Base of a data model
203 * @code{RANDOM_NUMBER}: RANDOM_NUMBER, Pseudo-random number
204 * @code{RANDOM_SEED}: RANDOM_SEED, Initialize a pseudo-random number sequence
205 * @code{RAND}: RAND, Real pseudo-random number
206 * @code{RANGE}: RANGE, Decimal exponent range of a real kind
207 * @code{RAN}: RAN, Real pseudo-random number
208 * @code{REAL}: REAL, Convert to real type
209 * @code{RENAME}: RENAME, Rename a file
210 * @code{REPEAT}: REPEAT, Repeated string concatenation
211 * @code{RESHAPE}: RESHAPE, Function to reshape an array
212 * @code{RRSPACING}: RRSPACING, Reciprocal of the relative spacing
213 * @code{RSHIFT}: RSHIFT, Right shift bits
214 * @code{SCALE}: SCALE, Scale a real value
215 * @code{SCAN}: SCAN, Scan a string for the presence of a set of characters
216 * @code{SECNDS}: SECNDS, Time function
217 @comment * @code{SECOND}: SECOND, (?)
218 @comment * @code{SECONDS}: SECONDS, (?)
219 * @code{SELECTED_INT_KIND}: SELECTED_INT_KIND, Choose integer kind
220 * @code{SELECTED_REAL_KIND}: SELECTED_REAL_KIND, Choose real kind
221 * @code{SET_EXPONENT}: SET_EXPONENT, Set the exponent of the model
222 * @code{SHAPE}: SHAPE, Determine the shape of an array
223 * @code{SIGN}: SIGN, Sign copying function
224 * @code{SIGNAL}: SIGNAL, Signal handling subroutine (or function)
225 * @code{SIN}: SIN, Sine function
226 * @code{SINH}: SINH, Hyperbolic sine function
227 * @code{SIZE}: SIZE, Function to determine the size of an array
228 * @code{SNGL}: SNGL, Convert double precision real to default real
229 * @code{SPACING}: SPACING, Smallest distance between two numbers of a given type
230 * @code{SPREAD}: SPREAD, Add a dimension to an array
231 * @code{SQRT}: SQRT, Square-root function
232 * @code{SRAND}: SRAND, Reinitialize the random number generator
233 * @code{STAT}: STAT, Get file status
234 * @code{SUM}: SUM, Sum of array elements
235 * @code{SYMLNK}: SYMLNK, Create a symbolic link
236 * @code{SYSTEM}: SYSTEM, Execute a shell command
237 * @code{SYSTEM_CLOCK}: SYSTEM_CLOCK, Time function
238 * @code{TAN}: TAN, Tangent function
239 * @code{TANH}: TANH, Hyperbolic tangent function
240 * @code{TIME}: TIME, Time function
241 * @code{TIME8}: TIME8, Time function (64-bit)
242 * @code{TINY}: TINY, Smallest positive number of a real kind
243 * @code{TRANSFER}: TRANSFER, Transfer bit patterns
244 * @code{TRANSPOSE}: TRANSPOSE, Transpose an array of rank two
245 * @code{TRIM}: TRIM, Function to remove trailing blank characters of a string
246 * @code{UBOUND}: UBOUND, Upper dimension bounds of an array
247 * @code{UMASK}: UMASK, Set the file creation mask
248 * @code{UNLINK}: UNLINK, Remove a file from the file system
249 * @code{UNPACK}: UNPACK, Unpack an array of rank one into an array
250 * @code{VERIFY}: VERIFY, Scan a string for the absence of a set of characters
251 * @code{XOR}: XOR, Bitwise logical exclusive or
254 @node Introduction to Intrinsics
255 @section Introduction to intrinsic procedures
257 The intrinsic procedures provided by GNU Fortran include all of the
258 intrinsic procedures required by the Fortran 95 standard, a set of
259 intrinsic procedures for backwards compatibility with G77, and a small
260 selection of intrinsic procedures from the Fortran 2003 standard. Any
261 conflict between a description here and a description in either the
262 Fortran 95 standard or the Fortran 2003 standard is unintentional, and
263 the standard(s) should be considered authoritative.
265 The enumeration of the @code{KIND} type parameter is processor defined in
266 the Fortran 95 standard. GNU Fortran defines the default integer type and
267 default real type by @code{INTEGER(KIND=4)} and @code{REAL(KIND=4)},
268 respectively. The standard mandates that both data types shall have
269 another kind, which have more precision. On typical target architectures
270 supported by @command{gfortran}, this kind type parameter is @code{KIND=8}.
271 Hence, @code{REAL(KIND=8)} and @code{DOUBLE PRECISION} are equivalent.
272 In the description of generic intrinsic procedures, the kind type parameter
273 will be specified by @code{KIND=*}, and in the description of specific
274 names for an intrinsic procedure the kind type parameter will be explicitly
275 given (e.g., @code{REAL(KIND=4)} or @code{REAL(KIND=8)}). Finally, for
276 brevity the optional @code{KIND=} syntax will be omitted.
278 Many of the intrinsic procedures take one or more optional arguments.
279 This document follows the convention used in the Fortran 95 standard,
280 and denotes such arguments by square brackets.
282 GNU Fortran offers the @option{-std=f95} and @option{-std=gnu} options,
283 which can be used to restrict the set of intrinsic procedures to a
284 given standard. By default, @command{gfortran} sets the @option{-std=gnu}
285 option, and so all intrinsic procedures described here are accepted. There
286 is one caveat. For a select group of intrinsic procedures, @command{g77}
287 implemented both a function and a subroutine. Both classes
288 have been implemented in @command{gfortran} for backwards compatibility
289 with @command{g77}. It is noted here that these functions and subroutines
290 cannot be intermixed in a given subprogram. In the descriptions that follow,
291 the applicable standard for each intrinsic procedure is noted.
296 @section @code{ABORT} --- Abort the program
297 @cindex @code{ABORT} intrinsic
301 @item @emph{Description}:
302 @code{ABORT} causes immediate termination of the program. On operating
303 systems that support a core dump, @code{ABORT} will produce a core dump,
304 which is suitable for debugging purposes.
306 @item @emph{Standard}:
310 non-elemental subroutine
315 @item @emph{Return value}:
318 @item @emph{Example}:
321 integer :: i = 1, j = 2
322 if (i /= j) call abort
323 end program test_abort
326 @item @emph{See also}:
327 @ref{EXIT}, @ref{KILL}
333 @section @code{ABS} --- Absolute value
334 @cindex @code{ABS} intrinsic
335 @cindex @code{CABS} intrinsic
336 @cindex @code{DABS} intrinsic
337 @cindex @code{IABS} intrinsic
338 @cindex @code{ZABS} intrinsic
339 @cindex @code{CDABS} intrinsic
340 @cindex absolute value
343 @item @emph{Description}:
344 @code{ABS(X)} computes the absolute value of @code{X}.
346 @item @emph{Standard}:
347 F77 and later, has overloads that are GNU extensions
353 @code{RESULT = ABS(X)}
355 @item @emph{Arguments}:
356 @multitable @columnfractions .15 .80
357 @item @var{X} @tab The type of the argument shall be an @code{INTEGER(*)},
358 @code{REAL(*)}, or @code{COMPLEX(*)}.
361 @item @emph{Return value}:
362 The return value is of the same type and
363 kind as the argument except the return value is @code{REAL(*)} for a
364 @code{COMPLEX(*)} argument.
366 @item @emph{Example}:
371 complex :: z = (-1.e0,0.e0)
378 @item @emph{Specific names}:
379 @multitable @columnfractions .20 .20 .20 .40
380 @item Name @tab Argument @tab Return type @tab Standard
381 @item @code{CABS(Z)} @tab @code{COMPLEX(4) Z} @tab @code{REAL(4)} @tab F77 and later
382 @item @code{DABS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
383 @item @code{IABS(I)} @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)} @tab F77 and later
384 @item @code{ZABS(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
385 @item @code{CDABS(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
391 @section @code{ACCESS} --- Checks file access modes
392 @cindex @code{ACCESS}
393 @cindex file system operations
396 @item @emph{Description}:
397 @code{ACCESS(NAME, MODE)} checks whether the file @var{NAME}
398 exists, is readable, writable or executable. Except for the
399 executable check, @code{ACCESS} can be replaced by
400 Fortran 95's @code{INQUIRE}.
402 @item @emph{Standard}:
409 @code{RESULT = ACCESS(NAME, MODE)}
411 @item @emph{Arguments}:
412 @multitable @columnfractions .15 .80
413 @item @var{NAME} @tab Scalar @code{CHARACTER} with the file name.
414 Tailing blank are ignored unless the character @code{achar(0)} is
415 present, then all characters up to and excluding @code{achar(0)} are
417 @item @var{MODE} @tab Scalar @code{CHARACTER} with the file access mode,
418 may be any concatenation of @code{"r"} (readable), @code{"w"} (writable)
419 and @code{"x"} (executable), or @code{" "} to check for existence.
422 @item @emph{Return value}:
423 Returns a scalar @code{INTEGER}, which is @code{0} if the file is
424 accessable in the given mode; otherwise or if an invalid argument
425 has been given for @code{MODE} the value @code{1} is returned.
427 @item @emph{Example}:
431 character(len=*), parameter :: file = 'test.dat'
432 character(len=*), parameter :: file2 = 'test.dat '//achar(0)
433 if(access(file,' ') == 0) print *, trim(file),' is exists'
434 if(access(file,'r') == 0) print *, trim(file),' is readable'
435 if(access(file,'w') == 0) print *, trim(file),' is writable'
436 if(access(file,'x') == 0) print *, trim(file),' is executable'
437 if(access(file2,'rwx') == 0) &
438 print *, trim(file2),' is readable, writable and executable'
439 end program access_test
441 @item @emph{Specific names}:
442 @item @emph{See also}:
448 @section @code{ACHAR} --- Character in @acronym{ASCII} collating sequence
449 @cindex @code{ACHAR} intrinsic
450 @cindex @acronym{ASCII} collating sequence
453 @item @emph{Description}:
454 @code{ACHAR(I)} returns the character located at position @code{I}
455 in the @acronym{ASCII} collating sequence.
457 @item @emph{Standard}:
464 @code{RESULT = ACHAR(I)}
466 @item @emph{Arguments}:
467 @multitable @columnfractions .15 .80
468 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
471 @item @emph{Return value}:
472 The return value is of type @code{CHARACTER} with a length of one. The
473 kind type parameter is the same as @code{KIND('A')}.
475 @item @emph{Example}:
480 end program test_achar
483 @item @emph{See also}:
484 @ref{CHAR}, @ref{IACHAR}, @ref{ICHAR}
491 @section @code{ACOS} --- Arccosine function
492 @cindex @code{ACOS} intrinsic
493 @cindex @code{DACOS} intrinsic
494 @cindex trigonometric functions (inverse)
497 @item @emph{Description}:
498 @code{ACOS(X)} computes the arccosine of @var{X} (inverse of @code{COS(X)}).
500 @item @emph{Standard}:
507 @code{RESULT = ACOS(X)}
509 @item @emph{Arguments}:
510 @multitable @columnfractions .15 .80
511 @item @var{X} @tab The type shall be @code{REAL(*)} with a magnitude that is
515 @item @emph{Return value}:
516 The return value is of type @code{REAL(*)} and it lies in the
517 range @math{ 0 \leq \acos(x) \leq \pi}. The kind type parameter
518 is the same as @var{X}.
520 @item @emph{Example}:
523 real(8) :: x = 0.866_8
525 end program test_acos
528 @item @emph{Specific names}:
529 @multitable @columnfractions .20 .20 .20 .40
530 @item Name @tab Argument @tab Return type @tab Standard
531 @item @code{DACOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
534 @item @emph{See also}:
535 Inverse function: @ref{COS}
541 @section @code{ACOSH} --- Hyperbolic arccosine function
542 @cindex @code{ACOSH} intrinsic
543 @cindex hyperbolic arccosine
544 @cindex hyperbolic cosine (inverse)
547 @item @emph{Description}:
548 @code{ACOSH(X)} computes the area hyperbolic cosine of @var{X} (inverse of @code{COSH(X)}).
550 @item @emph{Standard}:
557 @code{RESULT = ACOSH(X)}
559 @item @emph{Arguments}:
560 @multitable @columnfractions .15 .80
561 @item @var{X} @tab The type shall be @code{REAL(*)} with a magnitude that is
562 greater or equal to one.
565 @item @emph{Return value}:
566 The return value is of type @code{REAL(*)} and it lies in the
567 range @math{0 \leq \acosh (x) \leq \infty}.
569 @item @emph{Example}:
572 REAL(8), DIMENSION(3) :: x = (/ 1.0, 2.0, 3.0 /)
577 @item @emph{See also}:
578 Inverse function: @ref{COSH}
584 @section @code{ADJUSTL} --- Left adjust a string
585 @cindex @code{ADJUSTL} intrinsic
586 @cindex adjust string
589 @item @emph{Description}:
590 @code{ADJUSTL(STR)} will left adjust a string by removing leading spaces.
591 Spaces are inserted at the end of the string as needed.
593 @item @emph{Standard}:
600 @code{RESULT = ADJUSTL(STR)}
602 @item @emph{Arguments}:
603 @multitable @columnfractions .15 .80
604 @item @var{STR} @tab The type shall be @code{CHARACTER}.
607 @item @emph{Return value}:
608 The return value is of type @code{CHARACTER} where leading spaces
609 are removed and the same number of spaces are inserted on the end
612 @item @emph{Example}:
615 character(len=20) :: str = ' gfortran'
618 end program test_adjustl
625 @section @code{ADJUSTR} --- Right adjust a string
626 @cindex @code{ADJUSTR} intrinsic
627 @cindex adjust string
630 @item @emph{Description}:
631 @code{ADJUSTR(STR)} will right adjust a string by removing trailing spaces.
632 Spaces are inserted at the start of the string as needed.
634 @item @emph{Standard}:
641 @code{RESULT = ADJUSTR(STR)}
643 @item @emph{Arguments}:
644 @multitable @columnfractions .15 .80
645 @item @var{STR} @tab The type shall be @code{CHARACTER}.
648 @item @emph{Return value}:
649 The return value is of type @code{CHARACTER} where trailing spaces
650 are removed and the same number of spaces are inserted at the start
653 @item @emph{Example}:
656 character(len=20) :: str = 'gfortran'
659 end program test_adjustr
666 @section @code{AIMAG} --- Imaginary part of complex number
667 @cindex @code{AIMAG} intrinsic
668 @cindex @code{DIMAG} intrinsic
669 @cindex @code{IMAG} intrinsic
670 @cindex @code{IMAGPART} intrinsic
671 @cindex imaginary part of a complex number
674 @item @emph{Description}:
675 @code{AIMAG(Z)} yields the imaginary part of complex argument @code{Z}.
676 The @code{IMAG(Z)} and @code{IMAGPART(Z)} intrinsic functions are provided
677 for compatibility with @command{g77}, and their use in new code is
678 strongly discouraged.
680 @item @emph{Standard}:
681 F77 and later, has overloads that are GNU extensions
687 @code{RESULT = AIMAG(Z)}
689 @item @emph{Arguments}:
690 @multitable @columnfractions .15 .80
691 @item @var{Z} @tab The type of the argument shall be @code{COMPLEX(*)}.
694 @item @emph{Return value}:
695 The return value is of type real with the
696 kind type parameter of the argument.
698 @item @emph{Example}:
703 z4 = cmplx(1.e0_4, 0.e0_4)
704 z8 = cmplx(0.e0_8, 1.e0_8)
705 print *, aimag(z4), dimag(z8)
706 end program test_aimag
709 @item @emph{Specific names}:
710 @multitable @columnfractions .20 .20 .20 .40
711 @item Name @tab Argument @tab Return type @tab Standard
712 @item @code{DIMAG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{REAL(8)} @tab GNU extension
713 @item @code{IMAG(Z)} @tab @code{COMPLEX(*) Z} @tab @code{REAL(*)} @tab GNU extension
714 @item @code{IMAGPART(Z)} @tab @code{COMPLEX(*) Z} @tab @code{REAL(*)} @tab GNU extension
721 @section @code{AINT} --- Truncate to a whole number
722 @cindex @code{AINT} intrinsic
723 @cindex @code{DINT} intrinsic
727 @item @emph{Description}:
728 @code{AINT(X [, KIND])} truncates its argument to a whole number.
730 @item @emph{Standard}:
737 @code{RESULT = AINT(X [, KIND])}
739 @item @emph{Arguments}:
740 @multitable @columnfractions .15 .80
741 @item @var{X} @tab The type of the argument shall be @code{REAL(*)}.
742 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
743 expression indicating the kind parameter of
747 @item @emph{Return value}:
748 The return value is of type real with the kind type parameter of the
749 argument if the optional @var{KIND} is absent; otherwise, the kind
750 type parameter will be given by @var{KIND}. If the magnitude of
751 @var{X} is less than one, then @code{AINT(X)} returns zero. If the
752 magnitude is equal to or greater than one, then it returns the largest
753 whole number that does not exceed its magnitude. The sign is the same
754 as the sign of @var{X}.
756 @item @emph{Example}:
763 print *, aint(x4), dint(x8)
765 end program test_aint
768 @item @emph{Specific names}:
769 @multitable @columnfractions .20 .20 .20 .40
770 @item Name @tab Argument @tab Return type @tab Standard
771 @item @code{DINT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
778 @section @code{ALARM} --- Execute a routine after a given delay
779 @cindex @code{ALARM} intrinsic
782 @item @emph{Description}:
783 @code{ALARM(SECONDS, HANDLER [, STATUS])} causes external subroutine @var{HANDLER}
784 to be executed after a delay of @var{SECONDS} by using @code{alarm(1)} to
785 set up a signal and @code{signal(2)} to catch it. If @var{STATUS} is
786 supplied, it will be returned with the number of seconds remaining until
787 any previously scheduled alarm was due to be delivered, or zero if there
788 was no previously scheduled alarm.
790 @item @emph{Standard}:
797 @code{CALL ALARM(SECONDS, HANDLER [, STATUS])}
799 @item @emph{Arguments}:
800 @multitable @columnfractions .15 .80
801 @item @var{SECONDS} @tab The type of the argument shall be a scalar
802 @code{INTEGER}. It is @code{INTENT(IN)}.
803 @item @var{HANDLER} @tab Signal handler (@code{INTEGER FUNCTION} or
804 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar.
805 @code{INTEGER}. It is @code{INTENT(IN)}.
806 @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
807 @code{INTEGER} variable. It is @code{INTENT(OUT)}.
810 @item @emph{Example}:
813 external handler_print
815 call alarm (3, handler_print, i)
818 end program test_alarm
820 This will cause the external routine @var{handler_print} to be called
827 @section @code{ALL} --- All values in @var{MASK} along @var{DIM} are true
828 @cindex @code{ALL} intrinsic
832 @item @emph{Description}:
833 @code{ALL(MASK [, DIM])} determines if all the values are true in @var{MASK}
834 in the array along dimension @var{DIM}.
836 @item @emph{Standard}:
840 transformational function
843 @code{RESULT = ALL(MASK [, DIM])}
845 @item @emph{Arguments}:
846 @multitable @columnfractions .15 .80
847 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL(*)} and
848 it shall not be scalar.
849 @item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer
850 with a value that lies between one and the rank of @var{MASK}.
853 @item @emph{Return value}:
854 @code{ALL(MASK)} returns a scalar value of type @code{LOGICAL(*)} where
855 the kind type parameter is the same as the kind type parameter of
856 @var{MASK}. If @var{DIM} is present, then @code{ALL(MASK, DIM)} returns
857 an array with the rank of @var{MASK} minus 1. The shape is determined from
858 the shape of @var{MASK} where the @var{DIM} dimension is elided.
862 @code{ALL(MASK)} is true if all elements of @var{MASK} are true.
863 It also is true if @var{MASK} has zero size; otherwise, it is false.
865 If the rank of @var{MASK} is one, then @code{ALL(MASK,DIM)} is equivalent
866 to @code{ALL(MASK)}. If the rank is greater than one, then @code{ALL(MASK,DIM)}
867 is determined by applying @code{ALL} to the array sections.
870 @item @emph{Example}:
874 l = all((/.true., .true., .true./))
879 integer a(2,3), b(2,3)
883 print *, all(a .eq. b, 1)
884 print *, all(a .eq. b, 2)
885 end subroutine section
893 @section @code{ALLOCATED} --- Status of an allocatable entity
894 @cindex @code{ALLOCATED} intrinsic
895 @cindex allocation status
898 @item @emph{Description}:
899 @code{ALLOCATED(X)} checks the status of whether @var{X} is allocated.
901 @item @emph{Standard}:
908 @code{RESULT = ALLOCATED(X)}
910 @item @emph{Arguments}:
911 @multitable @columnfractions .15 .80
912 @item @var{X} @tab The argument shall be an @code{ALLOCATABLE} array.
915 @item @emph{Return value}:
916 The return value is a scalar @code{LOGICAL} with the default logical
917 kind type parameter. If @var{X} is allocated, @code{ALLOCATED(X)}
918 is @code{.TRUE.}; otherwise, it returns the @code{.TRUE.}
920 @item @emph{Example}:
922 program test_allocated
924 real(4), allocatable :: x(:)
925 if (allocated(x) .eqv. .false.) allocate(x(i))
926 end program test_allocated
932 @section @code{AND} --- Bitwise logical AND
933 @cindex @code{AND} intrinsic
934 @cindex bit operations
937 @item @emph{Description}:
938 Bitwise logical @code{AND}.
940 This intrinsic routine is provided for backwards compatibility with
941 GNU Fortran 77. For integer arguments, programmers should consider
942 the use of the @ref{IAND} intrinsic defined by the Fortran standard.
944 @item @emph{Standard}:
948 Non-elemental function
951 @code{RESULT = AND(X, Y)}
953 @item @emph{Arguments}:
954 @multitable @columnfractions .15 .80
955 @item @var{X} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
956 @item @var{Y} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
959 @item @emph{Return value}:
960 The return type is either @code{INTEGER(*)} or @code{LOGICAL} after
961 cross-promotion of the arguments.
963 @item @emph{Example}:
966 LOGICAL :: T = .TRUE., F = ..FALSE.
968 DATA a / Z'F' /, b / Z'3' /
970 WRITE (*,*) AND(T, T), AND(T, F), AND(F, T), AND(F, F)
971 WRITE (*,*) AND(a, b)
975 @item @emph{See also}:
976 F95 elemental function: @ref{IAND}
982 @section @code{ANINT} --- Nearest whole number
983 @cindex @code{ANINT} intrinsic
984 @cindex @code{DNINT} intrinsic
988 @item @emph{Description}:
989 @code{ANINT(X [, KIND])} rounds its argument to the nearest whole number.
991 @item @emph{Standard}:
998 @code{RESULT = ANINT(X [, KIND])}
1000 @item @emph{Arguments}:
1001 @multitable @columnfractions .15 .80
1002 @item @var{X} @tab The type of the argument shall be @code{REAL(*)}.
1003 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
1004 expression indicating the kind parameter of
1008 @item @emph{Return value}:
1009 The return value is of type real with the kind type parameter of the
1010 argument if the optional @var{KIND} is absent; otherwise, the kind
1011 type parameter will be given by @var{KIND}. If @var{X} is greater than
1012 zero, then @code{ANINT(X)} returns @code{AINT(X+0.5)}. If @var{X} is
1013 less than or equal to zero, then it returns @code{AINT(X-0.5)}.
1015 @item @emph{Example}:
1022 print *, anint(x4), dnint(x8)
1024 end program test_anint
1027 @item @emph{Specific names}:
1028 @multitable @columnfractions .20 .20 .20 .40
1029 @item Name @tab Argument @tab Return type @tab Standard
1030 @item @code{DNINT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1037 @section @code{ANY} --- Any value in @var{MASK} along @var{DIM} is true
1038 @cindex @code{ANY} intrinsic
1042 @item @emph{Description}:
1043 @code{ANY(MASK [, DIM])} determines if any of the values in the logical array
1044 @var{MASK} along dimension @var{DIM} are @code{.TRUE.}.
1046 @item @emph{Standard}:
1050 transformational function
1052 @item @emph{Syntax}:
1053 @code{RESULT = ANY(MASK [, DIM])}
1055 @item @emph{Arguments}:
1056 @multitable @columnfractions .15 .80
1057 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL(*)} and
1058 it shall not be scalar.
1059 @item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer
1060 with a value that lies between one and the rank of @var{MASK}.
1063 @item @emph{Return value}:
1064 @code{ANY(MASK)} returns a scalar value of type @code{LOGICAL(*)} where
1065 the kind type parameter is the same as the kind type parameter of
1066 @var{MASK}. If @var{DIM} is present, then @code{ANY(MASK, DIM)} returns
1067 an array with the rank of @var{MASK} minus 1. The shape is determined from
1068 the shape of @var{MASK} where the @var{DIM} dimension is elided.
1072 @code{ANY(MASK)} is true if any element of @var{MASK} is true;
1073 otherwise, it is false. It also is false if @var{MASK} has zero size.
1075 If the rank of @var{MASK} is one, then @code{ANY(MASK,DIM)} is equivalent
1076 to @code{ANY(MASK)}. If the rank is greater than one, then @code{ANY(MASK,DIM)}
1077 is determined by applying @code{ANY} to the array sections.
1080 @item @emph{Example}:
1084 l = any((/.true., .true., .true./))
1089 integer a(2,3), b(2,3)
1093 print *, any(a .eq. b, 1)
1094 print *, any(a .eq. b, 2)
1095 end subroutine section
1096 end program test_any
1103 @section @code{ASIN} --- Arcsine function
1104 @cindex @code{ASIN} intrinsic
1105 @cindex @code{DASIN} intrinsic
1106 @cindex trigonometric functions (inverse)
1109 @item @emph{Description}:
1110 @code{ASIN(X)} computes the arcsine of its @var{X} (inverse of @code{SIN(X)}).
1112 @item @emph{Standard}:
1118 @item @emph{Syntax}:
1119 @code{RESULT = ASIN(X)}
1121 @item @emph{Arguments}:
1122 @multitable @columnfractions .15 .80
1123 @item @var{X} @tab The type shall be @code{REAL(*)}, and a magnitude that is
1127 @item @emph{Return value}:
1128 The return value is of type @code{REAL(*)} and it lies in the
1129 range @math{-\pi / 2 \leq \asin (x) \leq \pi / 2}. The kind type
1130 parameter is the same as @var{X}.
1132 @item @emph{Example}:
1135 real(8) :: x = 0.866_8
1137 end program test_asin
1140 @item @emph{Specific names}:
1141 @multitable @columnfractions .20 .20 .20 .40
1142 @item Name @tab Argument @tab Return type @tab Standard
1143 @item @code{DASIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1146 @item @emph{See also}:
1147 Inverse function: @ref{SIN}
1153 @section @code{ASINH} --- Hyperbolic arcsine function
1154 @cindex @code{ASINH} intrinsic
1155 @cindex hyperbolic arcsine
1156 @cindex hyperbolic sine (inverse)
1159 @item @emph{Description}:
1160 @code{ASINH(X)} computes the area hyperbolic sine of @var{X} (inverse of @code{SINH(X)}).
1162 @item @emph{Standard}:
1168 @item @emph{Syntax}:
1169 @code{RESULT = ASINH(X)}
1171 @item @emph{Arguments}:
1172 @multitable @columnfractions .15 .80
1173 @item @var{X} @tab The type shall be @code{REAL(*)}, with @var{X} a real number.
1176 @item @emph{Return value}:
1177 The return value is of type @code{REAL(*)} and it lies in the
1178 range @math{-\infty \leq \asinh (x) \leq \infty}.
1180 @item @emph{Example}:
1183 REAL(8), DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1184 WRITE (*,*) ASINH(x)
1188 @item @emph{See also}:
1189 Inverse function: @ref{SINH}
1195 @section @code{ASSOCIATED} --- Status of a pointer or pointer/target pair
1196 @cindex @code{ASSOCIATED} intrinsic
1197 @cindex pointer status
1200 @item @emph{Description}:
1201 @code{ASSOCIATED(PTR [, TGT])} determines the status of the pointer @var{PTR}
1202 or if @var{PTR} is associated with the target @var{TGT}.
1204 @item @emph{Standard}:
1210 @item @emph{Syntax}:
1211 @code{RESULT = ASSOCIATED(PTR [, TGT])}
1213 @item @emph{Arguments}:
1214 @multitable @columnfractions .15 .80
1215 @item @var{PTR} @tab @var{PTR} shall have the @code{POINTER} attribute and
1216 it can be of any type.
1217 @item @var{TGT} @tab (Optional) @var{TGT} shall be a @code{POINTER} or
1218 a @code{TARGET}. It must have the same type, kind type parameter, and
1219 array rank as @var{PTR}.
1221 The status of neither @var{PTR} nor @var{TGT} can be undefined.
1223 @item @emph{Return value}:
1224 @code{ASSOCIATED(PTR)} returns a scalar value of type @code{LOGICAL(4)}.
1225 There are several cases:
1227 @item (A) If the optional @var{TGT} is not present, then @code{ASSOCIATED(PTR)}
1228 is true if @var{PTR} is associated with a target; otherwise, it returns false.
1229 @item (B) If @var{TGT} is present and a scalar target, the result is true if
1231 is not a 0 sized storage sequence and the target associated with @var{PTR}
1232 occupies the same storage units. If @var{PTR} is disassociated, then the
1234 @item (C) If @var{TGT} is present and an array target, the result is true if
1235 @var{TGT} and @var{PTR} have the same shape, are not 0 sized arrays, are
1236 arrays whose elements are not 0 sized storage sequences, and @var{TGT} and
1237 @var{PTR} occupy the same storage units in array element order.
1238 As in case(B), the result is false, if @var{PTR} is disassociated.
1239 @item (D) If @var{TGT} is present and an scalar pointer, the result is true if
1240 target associated with @var{PTR} and the target associated with @var{TGT}
1241 are not 0 sized storage sequences and occupy the same storage units.
1242 The result is false, if either @var{TGT} or @var{PTR} is disassociated.
1243 @item (E) If @var{TGT} is present and an array pointer, the result is true if
1244 target associated with @var{PTR} and the target associated with @var{TGT}
1245 have the same shape, are not 0 sized arrays, are arrays whose elements are
1246 not 0 sized storage sequences, and @var{TGT} and @var{PTR} occupy the same
1247 storage units in array element order.
1248 The result is false, if either @var{TGT} or @var{PTR} is disassociated.
1251 @item @emph{Example}:
1253 program test_associated
1255 real, target :: tgt(2) = (/1., 2./)
1256 real, pointer :: ptr(:)
1258 if (associated(ptr) .eqv. .false.) call abort
1259 if (associated(ptr,tgt) .eqv. .false.) call abort
1260 end program test_associated
1263 @item @emph{See also}:
1270 @section @code{ATAN} --- Arctangent function
1271 @cindex @code{ATAN} intrinsic
1272 @cindex @code{DATAN} intrinsic
1273 @cindex trigonometric functions (inverse)
1276 @item @emph{Description}:
1277 @code{ATAN(X)} computes the arctangent of @var{X}.
1279 @item @emph{Standard}:
1285 @item @emph{Syntax}:
1286 @code{RESULT = ATAN(X)}
1288 @item @emph{Arguments}:
1289 @multitable @columnfractions .15 .80
1290 @item @var{X} @tab The type shall be @code{REAL(*)}.
1293 @item @emph{Return value}:
1294 The return value is of type @code{REAL(*)} and it lies in the
1295 range @math{ - \pi / 2 \leq \atan (x) \leq \pi / 2}.
1297 @item @emph{Example}:
1300 real(8) :: x = 2.866_8
1302 end program test_atan
1305 @item @emph{Specific names}:
1306 @multitable @columnfractions .20 .20 .20 .40
1307 @item Name @tab Argument @tab Return type @tab Standard
1308 @item @code{DATAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1311 @item @emph{See also}:
1312 Inverse function: @ref{TAN}
1319 @section @code{ATAN2} --- Arctangent function
1320 @cindex @code{ATAN2} intrinsic
1321 @cindex @code{DATAN2} intrinsic
1322 @cindex trigonometric functions (inverse)
1325 @item @emph{Description}:
1326 @code{ATAN2(Y,X)} computes the arctangent of the complex number @math{X + i Y}.
1328 @item @emph{Standard}:
1334 @item @emph{Syntax}:
1335 @code{RESULT = ATAN2(Y,X)}
1337 @item @emph{Arguments}:
1338 @multitable @columnfractions .15 .80
1339 @item @var{Y} @tab The type shall be @code{REAL(*)}.
1340 @item @var{X} @tab The type and kind type parameter shall be the same as @var{Y}.
1341 If @var{Y} is zero, then @var{X} must be nonzero.
1344 @item @emph{Return value}:
1345 The return value has the same type and kind type parameter as @var{Y}.
1346 It is the principal value of the complex number @math{X + i Y}. If
1347 @var{X} is nonzero, then it lies in the range @math{-\pi \le \atan (x) \leq \pi}.
1348 The sign is positive if @var{Y} is positive. If @var{Y} is zero, then
1349 the return value is zero if @var{X} is positive and @math{\pi} if @var{X}
1350 is negative. Finally, if @var{X} is zero, then the magnitude of the result
1353 @item @emph{Example}:
1356 real(4) :: x = 1.e0_4, y = 0.5e0_4
1358 end program test_atan2
1361 @item @emph{Specific names}:
1362 @multitable @columnfractions .20 .20 .20 .40
1363 @item Name @tab Argument @tab Return type @tab Standard
1364 @item @code{DATAN2(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1371 @section @code{ATANH} --- Hyperbolic arctangent function
1372 @cindex @code{ASINH} intrinsic
1373 @cindex hyperbolic arctangent
1374 @cindex hyperbolic tangent (inverse)
1377 @item @emph{Description}:
1378 @code{ATANH(X)} computes the area hyperbolic sine of @var{X} (inverse of @code{TANH(X)}).
1380 @item @emph{Standard}:
1386 @item @emph{Syntax}:
1387 @code{RESULT = ATANH(X)}
1389 @item @emph{Arguments}:
1390 @multitable @columnfractions .15 .80
1391 @item @var{X} @tab The type shall be @code{REAL(*)} with a magnitude
1392 that is less than or equal to one.
1395 @item @emph{Return value}:
1396 The return value is of type @code{REAL(*)} and it lies in the
1397 range @math{-\infty \leq \atanh(x) \leq \infty}.
1399 @item @emph{Example}:
1402 REAL, DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1403 WRITE (*,*) ATANH(x)
1407 @item @emph{See also}:
1408 Inverse function: @ref{TANH}
1415 @section @code{BESJ0} --- Bessel function of the first kind of order 0
1416 @cindex @code{BESJ0} intrinsic
1417 @cindex @code{DBESJ0} intrinsic
1421 @item @emph{Description}:
1422 @code{BESJ0(X)} computes the Bessel function of the first kind of order 0
1425 @item @emph{Standard}:
1431 @item @emph{Syntax}:
1432 @code{RESULT = BESJ0(X)}
1434 @item @emph{Arguments}:
1435 @multitable @columnfractions .15 .80
1436 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1439 @item @emph{Return value}:
1440 The return value is of type @code{REAL(*)} and it lies in the
1441 range @math{ - 0.4027... \leq Bessel (0,x) \leq 1}.
1443 @item @emph{Example}:
1446 real(8) :: x = 0.0_8
1448 end program test_besj0
1451 @item @emph{Specific names}:
1452 @multitable @columnfractions .20 .20 .20 .40
1453 @item Name @tab Argument @tab Return type @tab Standard
1454 @item @code{DBESJ0(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1461 @section @code{BESJ1} --- Bessel function of the first kind of order 1
1462 @cindex @code{BESJ1} intrinsic
1463 @cindex @code{DBESJ1} intrinsic
1467 @item @emph{Description}:
1468 @code{BESJ1(X)} computes the Bessel function of the first kind of order 1
1471 @item @emph{Standard}:
1477 @item @emph{Syntax}:
1478 @code{RESULT = BESJ1(X)}
1480 @item @emph{Arguments}:
1481 @multitable @columnfractions .15 .80
1482 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1485 @item @emph{Return value}:
1486 The return value is of type @code{REAL(*)} and it lies in the
1487 range @math{ - 0.5818... \leq Bessel (0,x) \leq 0.5818 }.
1489 @item @emph{Example}:
1492 real(8) :: x = 1.0_8
1494 end program test_besj1
1497 @item @emph{Specific names}:
1498 @multitable @columnfractions .20 .20 .20 .40
1499 @item Name @tab Argument @tab Return type @tab Standard
1500 @item @code{DBESJ1(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1507 @section @code{BESJN} --- Bessel function of the first kind
1508 @cindex @code{BESJN} intrinsic
1509 @cindex @code{DBESJN} intrinsic
1513 @item @emph{Description}:
1514 @code{BESJN(N, X)} computes the Bessel function of the first kind of order
1517 @item @emph{Standard}:
1523 @item @emph{Syntax}:
1524 @code{RESULT = BESJN(N, X)}
1526 @item @emph{Arguments}:
1527 @multitable @columnfractions .15 .80
1528 @item @var{N} @tab The type shall be @code{INTEGER(*)}, and it shall be scalar.
1529 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1532 @item @emph{Return value}:
1533 The return value is a scalar of type @code{REAL(*)}.
1535 @item @emph{Example}:
1538 real(8) :: x = 1.0_8
1540 end program test_besjn
1543 @item @emph{Specific names}:
1544 @multitable @columnfractions .20 .20 .20 .40
1545 @item Name @tab Argument @tab Return type @tab Standard
1546 @item @code{DBESJN(X)} @tab @code{INTEGER(*) N} @tab @code{REAL(8)} @tab GNU extension
1547 @item @tab @code{REAL(8) X} @tab @tab
1554 @section @code{BESY0} --- Bessel function of the second kind of order 0
1555 @cindex @code{BESY0} intrinsic
1556 @cindex @code{DBESY0} intrinsic
1560 @item @emph{Description}:
1561 @code{BESY0(X)} computes the Bessel function of the second kind of order 0
1564 @item @emph{Standard}:
1570 @item @emph{Syntax}:
1571 @code{RESULT = BESY0(X)}
1573 @item @emph{Arguments}:
1574 @multitable @columnfractions .15 .80
1575 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1578 @item @emph{Return value}:
1579 The return value is a scalar of type @code{REAL(*)}.
1581 @item @emph{Example}:
1584 real(8) :: x = 0.0_8
1586 end program test_besy0
1589 @item @emph{Specific names}:
1590 @multitable @columnfractions .20 .20 .20 .40
1591 @item Name @tab Argument @tab Return type @tab Standard
1592 @item @code{DBESY0(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1599 @section @code{BESY1} --- Bessel function of the second kind of order 1
1600 @cindex @code{BESY1} intrinsic
1601 @cindex @code{DBESY1} intrinsic
1605 @item @emph{Description}:
1606 @code{BESY1(X)} computes the Bessel function of the second kind of order 1
1609 @item @emph{Standard}:
1615 @item @emph{Syntax}:
1616 @code{RESULT = BESY1(X)}
1618 @item @emph{Arguments}:
1619 @multitable @columnfractions .15 .80
1620 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1623 @item @emph{Return value}:
1624 The return value is a scalar of type @code{REAL(*)}.
1626 @item @emph{Example}:
1629 real(8) :: x = 1.0_8
1631 end program test_besy1
1634 @item @emph{Specific names}:
1635 @multitable @columnfractions .20 .20 .20 .40
1636 @item Name @tab Argument @tab Return type @tab Standard
1637 @item @code{DBESY1(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1644 @section @code{BESYN} --- Bessel function of the second kind
1645 @cindex @code{BESYN} intrinsic
1646 @cindex @code{DBESYN} intrinsic
1650 @item @emph{Description}:
1651 @code{BESYN(N, X)} computes the Bessel function of the second kind of order
1654 @item @emph{Standard}:
1660 @item @emph{Syntax}:
1661 @code{RESULT = BESYN(N, X)}
1663 @item @emph{Arguments}:
1664 @multitable @columnfractions .15 .80
1665 @item @var{N} @tab The type shall be @code{INTEGER(*)}, and it shall be scalar.
1666 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1669 @item @emph{Return value}:
1670 The return value is a scalar of type @code{REAL(*)}.
1672 @item @emph{Example}:
1675 real(8) :: x = 1.0_8
1677 end program test_besyn
1680 @item @emph{Specific names}:
1681 @multitable @columnfractions .20 .20 .20 .40
1682 @item Name @tab Argument @tab Return type @tab Standard
1683 @item @code{DBESYN(N,X)} @tab @code{INTEGER(*) N} @tab @code{REAL(8)} @tab GNU extension
1684 @item @tab @code{REAL(8) X} @tab @tab
1691 @section @code{BIT_SIZE} --- Bit size inquiry function
1692 @cindex @code{BIT_SIZE} intrinsic
1693 @cindex bit size of a variable
1694 @cindex size of a variable, in bits
1697 @item @emph{Description}:
1698 @code{BIT_SIZE(I)} returns the number of bits (integer precision plus sign bit)
1699 represented by the type of @var{I}.
1701 @item @emph{Standard}:
1707 @item @emph{Syntax}:
1708 @code{RESULT = BIT_SIZE(I)}
1710 @item @emph{Arguments}:
1711 @multitable @columnfractions .15 .80
1712 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1715 @item @emph{Return value}:
1716 The return value is of type @code{INTEGER(*)}
1718 @item @emph{Example}:
1720 program test_bit_size
1725 end program test_bit_size
1732 @section @code{BTEST} --- Bit test function
1733 @cindex @code{BTEST} intrinsic
1734 @cindex bit operations
1737 @item @emph{Description}:
1738 @code{BTEST(I,POS)} returns logical @code{.TRUE.} if the bit at @var{POS}
1741 @item @emph{Standard}:
1747 @item @emph{Syntax}:
1748 @code{RESULT = BTEST(I, POS)}
1750 @item @emph{Arguments}:
1751 @multitable @columnfractions .15 .80
1752 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1753 @item @var{POS} @tab The type shall be @code{INTEGER(*)}.
1756 @item @emph{Return value}:
1757 The return value is of type @code{LOGICAL}
1759 @item @emph{Example}:
1762 integer :: i = 32768 + 1024 + 64
1766 bool = btest(i, pos)
1769 end program test_btest
1776 @section @code{CEILING} --- Integer ceiling function
1777 @cindex @code{CEILING} intrinsic
1781 @item @emph{Description}:
1782 @code{CEILING(X)} returns the least integer greater than or equal to @var{X}.
1784 @item @emph{Standard}:
1790 @item @emph{Syntax}:
1791 @code{RESULT = CEILING(X [, KIND])}
1793 @item @emph{Arguments}:
1794 @multitable @columnfractions .15 .80
1795 @item @var{X} @tab The type shall be @code{REAL(*)}.
1796 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
1797 expression indicating the kind parameter of
1801 @item @emph{Return value}:
1802 The return value is of type @code{INTEGER(KIND)}
1804 @item @emph{Example}:
1806 program test_ceiling
1809 print *, ceiling(x) ! returns 64
1810 print *, ceiling(y) ! returns -63
1811 end program test_ceiling
1814 @item @emph{See also}:
1815 @ref{FLOOR}, @ref{NINT}
1822 @section @code{CHAR} --- Character conversion function
1823 @cindex @code{CHAR} intrinsic
1824 @cindex conversion function (character)
1827 @item @emph{Description}:
1828 @code{CHAR(I [, KIND])} returns the character represented by the integer @var{I}.
1830 @item @emph{Standard}:
1836 @item @emph{Syntax}:
1837 @code{RESULT = CHAR(I [, KIND])}
1839 @item @emph{Arguments}:
1840 @multitable @columnfractions .15 .80
1841 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1842 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
1843 expression indicating the kind parameter of
1847 @item @emph{Return value}:
1848 The return value is of type @code{CHARACTER(1)}
1850 @item @emph{Example}:
1856 print *, i, c ! returns 'J'
1857 end program test_char
1860 @item @emph{See also}:
1861 @ref{ACHAR}, @ref{IACHAR}, @ref{ICHAR}
1867 @section @code{CHDIR} --- Change working directory
1868 @cindex @code{CHDIR} intrinsic
1869 @cindex file system operations
1872 @item @emph{Description}:
1873 Change current working directory to a specified @var{PATH}.
1875 @item @emph{Standard}:
1879 Non-elemental subroutine
1881 @item @emph{Syntax}:
1882 @code{CALL CHDIR(PATH [, STATUS])}
1884 @item @emph{Arguments}:
1885 @multitable @columnfractions .15 .80
1886 @item @var{PATH} @tab The type shall be @code{CHARACTER(*)} and shall
1887 specify a valid path within the file system.
1888 @item @var{STATUS} @tab (Optional) status flag. Returns 0 on success,
1889 a system specific and non-zero error code otherwise.
1892 @item @emph{Example}:
1895 CHARACTER(len=255) :: path
1897 WRITE(*,*) TRIM(path)
1900 WRITE(*,*) TRIM(path)
1904 @item @emph{See also}:
1911 @section @code{CHMOD} --- Change access permissions of files
1912 @cindex @code{CHMOD} intrinsic
1913 @cindex file system operations
1916 @item @emph{Description}:
1917 @code{CHMOD} changes the permissions of a file. This function invokes
1918 @code{/bin/chmod} and might therefore not work on all platforms.
1920 This intrinsic is provided in both subroutine and function forms; however,
1921 only one form can be used in any given program unit.
1923 @item @emph{Standard}:
1927 Subroutine, non-elemental function
1929 @item @emph{Syntax}:
1930 @multitable @columnfractions .80
1931 @item @code{CALL CHMOD(NAME, MODE[, STATUS])}
1932 @item @code{STATUS = CHMOD(NAME, MODE)}
1935 @item @emph{Arguments}:
1936 @multitable @columnfractions .15 .80
1937 @item @var{NAME} @tab Scalar @code{CHARACTER} with the file name.
1938 Trailing blanks are ignored unless the character @code{achar(0)} is
1939 present, then all characters up to and excluding @code{achar(0)} are
1940 used as the file name.
1942 @item @var{MODE} @tab Scalar @code{CHARACTER} giving the file permission.
1943 @var{MODE} uses the same syntax as the @var{MODE} argument of
1946 @item @var{STATUS} @tab (optional) scalar @code{INTEGER}, which is
1947 @code{0} on success and non-zero otherwise.
1950 @item @emph{Return value}:
1951 In either syntax, @var{STATUS} is set to @code{0} on success and non-zero
1954 @item @emph{Example}:
1955 @code{CHMOD} as subroutine
1960 call chmod('test.dat','u+x',status)
1961 print *, 'Status: ', status
1962 end program chmod_test
1964 @code{CHMOD} as non-elemental function:
1969 status = chmod('test.dat','u+x')
1970 print *, 'Status: ', status
1971 end program chmod_test
1973 @item @emph{Specific names}:
1974 @item @emph{See also}:
1980 @section @code{CMPLX} --- Complex conversion function
1981 @cindex @code{CMPLX} intrinsic
1982 @cindex complex numbers, conversion to
1985 @item @emph{Description}:
1986 @code{CMPLX(X [, Y [, KIND]])} returns a complex number where @var{X} is converted to
1987 the real component. If @var{Y} is present it is converted to the imaginary
1988 component. If @var{Y} is not present then the imaginary component is set to
1989 0.0. If @var{X} is complex then @var{Y} must not be present.
1991 @item @emph{Standard}:
1997 @item @emph{Syntax}:
1998 @code{RESULT = CMPLX(X [, Y [, KIND]])}
2000 @item @emph{Arguments}:
2001 @multitable @columnfractions .15 .80
2002 @item @var{X} @tab The type may be @code{INTEGER(*)}, @code{REAL(*)},
2003 or @code{COMPLEX(*)}.
2004 @item @var{Y} @tab (Optional; only allowed if @var{X} is not
2005 @code{COMPLEX(*)}.) May be @code{INTEGER(*)}
2007 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
2008 expression indicating the kind parameter of
2012 @item @emph{Return value}:
2013 The return value is of type @code{COMPLEX(*)}
2015 @item @emph{Example}:
2022 print *, z, cmplx(x)
2023 end program test_cmplx
2029 @node COMMAND_ARGUMENT_COUNT
2030 @section @code{COMMAND_ARGUMENT_COUNT} --- Get number of command line arguments
2031 @cindex @code{COMMAND_ARGUMENT_COUNT} intrinsic
2032 @cindex command-line arguments, to program
2035 @item @emph{Description}:
2036 @code{COMMAND_ARGUMENT_COUNT()} returns the number of arguments passed on the
2037 command line when the containing program was invoked.
2039 @item @emph{Standard}:
2045 @item @emph{Syntax}:
2046 @code{RESULT = COMMAND_ARGUMENT_COUNT()}
2048 @item @emph{Arguments}:
2049 @multitable @columnfractions .15 .80
2053 @item @emph{Return value}:
2054 The return value is of type @code{INTEGER(4)}
2056 @item @emph{Example}:
2058 program test_command_argument_count
2060 count = command_argument_count()
2062 end program test_command_argument_count
2065 @item @emph{See also}:
2066 @ref{GET_COMMAND}, @ref{GET_COMMAND_ARGUMENT}
2070 @section @code{CONJG} --- Complex conjugate function
2071 @cindex @code{CONJG} intrinsic
2072 @cindex @code{DCONJG} intrinsic
2073 @cindex complex conjugate
2075 @item @emph{Description}:
2076 @code{CONJG(Z)} returns the conjugate of @var{Z}. If @var{Z} is @code{(x, y)}
2077 then the result is @code{(x, -y)}
2079 @item @emph{Standard}:
2080 F77 and later, has overloads that are GNU extensions
2085 @item @emph{Syntax}:
2088 @item @emph{Arguments}:
2089 @multitable @columnfractions .15 .80
2090 @item @var{Z} @tab The type shall be @code{COMPLEX(*)}.
2093 @item @emph{Return value}:
2094 The return value is of type @code{COMPLEX(*)}.
2096 @item @emph{Example}:
2099 complex :: z = (2.0, 3.0)
2100 complex(8) :: dz = (2.71_8, -3.14_8)
2105 end program test_conjg
2108 @item @emph{Specific names}:
2109 @multitable @columnfractions .20 .20 .20 .40
2110 @item Name @tab Argument @tab Return type @tab Standard
2111 @item @code{DCONJG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
2118 @section @code{COS} --- Cosine function
2119 @cindex @code{COS} intrinsic
2120 @cindex @code{DCOS} intrinsic
2121 @cindex @code{ZCOS} intrinsic
2122 @cindex @code{CDCOS} intrinsic
2123 @cindex trigonometric functions
2126 @item @emph{Description}:
2127 @code{COS(X)} computes the cosine of @var{X}.
2129 @item @emph{Standard}:
2130 F77 and later, has overloads that are GNU extensions
2135 @item @emph{Syntax}:
2136 @code{RESULT = COS(X)}
2138 @item @emph{Arguments}:
2139 @multitable @columnfractions .15 .80
2140 @item @var{X} @tab The type shall be @code{REAL(*)} or
2144 @item @emph{Return value}:
2145 The return value is of type @code{REAL(*)} and it lies in the
2146 range @math{ -1 \leq \cos (x) \leq 1}. The kind type
2147 parameter is the same as @var{X}.
2149 @item @emph{Example}:
2154 end program test_cos
2157 @item @emph{Specific names}:
2158 @multitable @columnfractions .20 .20 .20 .40
2159 @item Name @tab Argument @tab Return type @tab Standard
2160 @item @code{DCOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
2161 @item @code{CCOS(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab F77 and later
2162 @item @code{ZCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
2163 @item @code{CDCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
2166 @item @emph{See also}:
2167 Inverse function: @ref{ACOS}
2174 @section @code{COSH} --- Hyperbolic cosine function
2175 @cindex @code{COSH} intrinsic
2176 @cindex @code{DCOSH} intrinsic
2177 @cindex hyperbolic cosine
2180 @item @emph{Description}:
2181 @code{COSH(X)} computes the hyperbolic cosine of @var{X}.
2183 @item @emph{Standard}:
2189 @item @emph{Syntax}:
2192 @item @emph{Arguments}:
2193 @multitable @columnfractions .15 .80
2194 @item @var{X} @tab The type shall be @code{REAL(*)}.
2197 @item @emph{Return value}:
2198 The return value is of type @code{REAL(*)} and it is positive
2199 (@math{ \cosh (x) \geq 0 }.
2201 @item @emph{Example}:
2204 real(8) :: x = 1.0_8
2206 end program test_cosh
2209 @item @emph{Specific names}:
2210 @multitable @columnfractions .20 .20 .20 .40
2211 @item Name @tab Argument @tab Return type @tab Standard
2212 @item @code{DCOSH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
2215 @item @emph{See also}:
2216 Inverse function: @ref{ACOSH}
2223 @section @code{COUNT} --- Count function
2224 @cindex @code{COUNT} intrinsic
2228 @item @emph{Description}:
2229 @code{COUNT(MASK [, DIM])} counts the number of @code{.TRUE.} elements of
2230 @var{MASK} along the dimension of @var{DIM}. If @var{DIM} is omitted it is
2231 taken to be @code{1}. @var{DIM} is a scaler of type @code{INTEGER} in the
2232 range of @math{1 /leq DIM /leq n)} where @math{n} is the rank of @var{MASK}.
2234 @item @emph{Standard}:
2238 transformational function
2240 @item @emph{Syntax}:
2241 @code{RESULT = COUNT(MASK [, DIM])}
2243 @item @emph{Arguments}:
2244 @multitable @columnfractions .15 .80
2245 @item @var{MASK} @tab The type shall be @code{LOGICAL}.
2246 @item @var{DIM} @tab The type shall be @code{INTEGER}.
2249 @item @emph{Return value}:
2250 The return value is of type @code{INTEGER} with rank equal to that of
2253 @item @emph{Example}:
2256 integer, dimension(2,3) :: a, b
2257 logical, dimension(2,3) :: mask
2258 a = reshape( (/ 1, 2, 3, 4, 5, 6 /), (/ 2, 3 /))
2259 b = reshape( (/ 0, 7, 3, 4, 5, 8 /), (/ 2, 3 /))
2260 print '(3i3)', a(1,:)
2261 print '(3i3)', a(2,:)
2263 print '(3i3)', b(1,:)
2264 print '(3i3)', b(2,:)
2267 print '(3l3)', mask(1,:)
2268 print '(3l3)', mask(2,:)
2270 print '(3i3)', count(mask)
2272 print '(3i3)', count(mask, 1)
2274 print '(3i3)', count(mask, 2)
2275 end program test_count
2282 @section @code{CPU_TIME} --- CPU elapsed time in seconds
2283 @cindex @code{CPU_TIME} intrinsic
2284 @cindex time, elapsed
2285 @cindex elapsed time
2288 @item @emph{Description}:
2289 Returns a @code{REAL} value representing the elapsed CPU time in seconds. This
2290 is useful for testing segments of code to determine execution time.
2292 @item @emph{Standard}:
2298 @item @emph{Syntax}:
2299 @code{CALL CPU_TIME(X)}
2301 @item @emph{Arguments}:
2302 @multitable @columnfractions .15 .80
2303 @item @var{X} @tab The type shall be @code{REAL} with @code{INTENT(OUT)}.
2306 @item @emph{Return value}:
2309 @item @emph{Example}:
2311 program test_cpu_time
2312 real :: start, finish
2313 call cpu_time(start)
2314 ! put code to test here
2315 call cpu_time(finish)
2316 print '("Time = ",f6.3," seconds.")',finish-start
2317 end program test_cpu_time
2324 @section @code{CSHIFT} --- Circular shift function
2325 @cindex @code{CSHIFT} intrinsic
2326 @cindex bit operations
2329 @item @emph{Description}:
2330 @code{CSHIFT(ARRAY, SHIFT [, DIM])} performs a circular shift on elements of
2331 @var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is omitted it is
2332 taken to be @code{1}. @var{DIM} is a scaler of type @code{INTEGER} in the
2333 range of @math{1 /leq DIM /leq n)} where @math{n} is the rank of @var{ARRAY}.
2334 If the rank of @var{ARRAY} is one, then all elements of @var{ARRAY} are shifted
2335 by @var{SHIFT} places. If rank is greater than one, then all complete rank one
2336 sections of @var{ARRAY} along the given dimension are shifted. Elements
2337 shifted out one end of each rank one section are shifted back in the other end.
2339 @item @emph{Standard}:
2343 transformational function
2345 @item @emph{Syntax}:
2346 @code{RESULT = CSHIFT(A, SHIFT [, DIM])}
2348 @item @emph{Arguments}:
2349 @multitable @columnfractions .15 .80
2350 @item @var{ARRAY} @tab May be any type, not scaler.
2351 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
2352 @item @var{DIM} @tab The type shall be @code{INTEGER}.
2355 @item @emph{Return value}:
2356 Returns an array of same type and rank as the @var{ARRAY} argument.
2358 @item @emph{Example}:
2361 integer, dimension(3,3) :: a
2362 a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
2363 print '(3i3)', a(1,:)
2364 print '(3i3)', a(2,:)
2365 print '(3i3)', a(3,:)
2366 a = cshift(a, SHIFT=(/1, 2, -1/), DIM=2)
2368 print '(3i3)', a(1,:)
2369 print '(3i3)', a(2,:)
2370 print '(3i3)', a(3,:)
2371 end program test_cshift
2377 @section @code{CTIME} --- Convert a time into a string
2378 @cindex @code{CTIME} intrinsic
2379 @cindex time, conversion function
2382 @item @emph{Description}:
2383 @code{CTIME(T,S)} converts @var{T}, a system time value, such as returned
2384 by @code{TIME8()}, to a string of the form @samp{Sat Aug 19 18:13:14
2385 1995}, and returns that string into @var{S}.
2387 If @code{CTIME} is invoked as a function, it can not be invoked as a
2388 subroutine, and vice versa.
2390 @var{T} is an @code{INTENT(IN)} @code{INTEGER(KIND=8)} variable.
2391 @var{S} is an @code{INTENT(OUT)} @code{CHARACTER} variable.
2393 @item @emph{Standard}:
2399 @item @emph{Syntax}:
2400 @multitable @columnfractions .80
2401 @item @code{CALL CTIME(T,S)}.
2402 @item @code{S = CTIME(T)}, (not recommended).
2405 @item @emph{Arguments}:
2406 @multitable @columnfractions .15 .80
2407 @item @var{S}@tab The type shall be of type @code{CHARACTER}.
2408 @item @var{T}@tab The type shall be of type @code{INTEGER(KIND=8)}.
2411 @item @emph{Return value}:
2412 The converted date and time as a string.
2414 @item @emph{Example}:
2418 character(len=30) :: date
2421 ! Do something, main part of the program
2424 print *, 'Program was started on ', date
2425 end program test_ctime
2428 @item @emph{See Also}:
2429 @ref{GMTIME}, @ref{LTIME}, @ref{TIME}, @ref{TIME8}
2436 @section @code{DATE_AND_TIME} --- Date and time subroutine
2437 @cindex @code{DATE_AND_TIME} intrinsic
2438 @cindex date, current
2439 @cindex current date
2440 @cindex time, current
2441 @cindex current time
2444 @item @emph{Description}:
2445 @code{DATE_AND_TIME(DATE, TIME, ZONE, VALUES)} gets the corresponding date and
2446 time information from the real-time system clock. @var{DATE} is
2447 @code{INTENT(OUT)} and has form ccyymmdd. @var{TIME} is @code{INTENT(OUT)} and
2448 has form hhmmss.sss. @var{ZONE} is @code{INTENT(OUT)} and has form (+-)hhmm,
2449 representing the difference with respect to Coordinated Universal Time (UTC).
2450 Unavailable time and date parameters return blanks.
2452 @var{VALUES} is @code{INTENT(OUT)} and provides the following:
2454 @multitable @columnfractions .15 .30 .60
2455 @item @tab @code{VALUE(1)}: @tab The year
2456 @item @tab @code{VALUE(2)}: @tab The month
2457 @item @tab @code{VALUE(3)}: @tab The day of the month
2458 @item @tab @code{VALUE(4)}: @tab Time difference with UTC in minutes
2459 @item @tab @code{VALUE(5)}: @tab The hour of the day
2460 @item @tab @code{VALUE(6)}: @tab The minutes of the hour
2461 @item @tab @code{VALUE(7)}: @tab The seconds of the minute
2462 @item @tab @code{VALUE(8)}: @tab The milliseconds of the second
2465 @item @emph{Standard}:
2471 @item @emph{Syntax}:
2472 @code{CALL DATE_AND_TIME([DATE, TIME, ZONE, VALUES])}
2474 @item @emph{Arguments}:
2475 @multitable @columnfractions .15 .80
2476 @item @var{DATE} @tab (Optional) The type shall be @code{CHARACTER(8)} or larger.
2477 @item @var{TIME} @tab (Optional) The type shall be @code{CHARACTER(10)} or larger.
2478 @item @var{ZONE} @tab (Optional) The type shall be @code{CHARACTER(5)} or larger.
2479 @item @var{VALUES}@tab (Optional) The type shall be @code{INTEGER(8)}.
2482 @item @emph{Return value}:
2485 @item @emph{Example}:
2487 program test_time_and_date
2488 character(8) :: date
2489 character(10) :: time
2490 character(5) :: zone
2491 integer,dimension(8) :: values
2492 ! using keyword arguments
2493 call date_and_time(date,time,zone,values)
2494 call date_and_time(DATE=date,ZONE=zone)
2495 call date_and_time(TIME=time)
2496 call date_and_time(VALUES=values)
2497 print '(a,2x,a,2x,a)', date, time, zone
2498 print '(8i5))', values
2499 end program test_time_and_date
2506 @section @code{DBLE} --- Double conversion function
2507 @cindex @code{DBLE} intrinsic
2508 @cindex double conversion
2511 @item @emph{Description}:
2512 @code{DBLE(X)} Converts @var{X} to double precision real type.
2514 @item @emph{Standard}:
2520 @item @emph{Syntax}:
2521 @code{RESULT = DBLE(X)}
2523 @item @emph{Arguments}:
2524 @multitable @columnfractions .15 .80
2525 @item @var{X} @tab The type shall be @code{INTEGER(*)}, @code{REAL(*)},
2526 or @code{COMPLEX(*)}.
2529 @item @emph{Return value}:
2530 The return value is of type double precision real.
2532 @item @emph{Example}:
2537 complex :: z = (2.3,1.14)
2538 print *, dble(x), dble(i), dble(z)
2539 end program test_dble
2542 @item @emph{See also}:
2543 @ref{DFLOAT}, @ref{FLOAT}, @ref{REAL}
2549 @section @code{DCMPLX} --- Double complex conversion function
2550 @cindex @code{DCMPLX} intrinsic
2551 @cindex complex numbers, conversion to
2554 @item @emph{Description}:
2555 @code{DCMPLX(X [,Y])} returns a double complex number where @var{X} is
2556 converted to the real component. If @var{Y} is present it is converted to the
2557 imaginary component. If @var{Y} is not present then the imaginary component is
2558 set to 0.0. If @var{X} is complex then @var{Y} must not be present.
2560 @item @emph{Standard}:
2566 @item @emph{Syntax}:
2567 @code{RESULT = DCMPLX(X [, Y])}
2569 @item @emph{Arguments}:
2570 @multitable @columnfractions .15 .80
2571 @item @var{X} @tab The type may be @code{INTEGER(*)}, @code{REAL(*)},
2572 or @code{COMPLEX(*)}.
2573 @item @var{Y} @tab (Optional if @var{X} is not @code{COMPLEX(*)}.) May be
2574 @code{INTEGER(*)} or @code{REAL(*)}.
2577 @item @emph{Return value}:
2578 The return value is of type @code{COMPLEX(8)}
2580 @item @emph{Example}:
2590 print *, dcmplx(x,i)
2591 end program test_dcmplx
2598 @section @code{DFLOAT} --- Double conversion function
2599 @cindex @code{DFLOAT} intrinsic
2600 @cindex double float conversion
2603 @item @emph{Description}:
2604 @code{DFLOAT(X)} Converts @var{X} to double precision real type.
2606 @item @emph{Standard}:
2612 @item @emph{Syntax}:
2613 @code{RESULT = DFLOAT(X)}
2615 @item @emph{Arguments}:
2616 @multitable @columnfractions .15 .80
2617 @item @var{X} @tab The type shall be @code{INTEGER(*)}.
2620 @item @emph{Return value}:
2621 The return value is of type double precision real.
2623 @item @emph{Example}:
2628 end program test_dfloat
2631 @item @emph{See also}:
2632 @ref{DBLE}, @ref{FLOAT}, @ref{REAL}
2638 @section @code{DIGITS} --- Significant digits function
2639 @cindex @code{DIGITS} intrinsic
2640 @cindex digits, significant
2643 @item @emph{Description}:
2644 @code{DIGITS(X)} returns the number of significant digits of the internal model
2645 representation of @var{X}. For example, on a system using a 32-bit
2646 floating point representation, a default real number would likely return 24.
2648 @item @emph{Standard}:
2654 @item @emph{Syntax}:
2655 @code{RESULT = DIGITS(X)}
2657 @item @emph{Arguments}:
2658 @multitable @columnfractions .15 .80
2659 @item @var{X} @tab The type may be @code{INTEGER(*)} or @code{REAL(*)}.
2662 @item @emph{Return value}:
2663 The return value is of type @code{INTEGER}.
2665 @item @emph{Example}:
2668 integer :: i = 12345
2674 end program test_digits
2681 @section @code{DIM} --- Dim function
2682 @cindex @code{DIM} intrinsic
2683 @cindex @code{IDIM} intrinsic
2684 @cindex @code{DDIM} intrinsic
2688 @item @emph{Description}:
2689 @code{DIM(X,Y)} returns the difference @code{X-Y} if the result is positive;
2690 otherwise returns zero.
2692 @item @emph{Standard}:
2698 @item @emph{Syntax}:
2699 @code{RESULT = DIM(X, Y)}
2701 @item @emph{Arguments}:
2702 @multitable @columnfractions .15 .80
2703 @item @var{X} @tab The type shall be @code{INTEGER(*)} or @code{REAL(*)}
2704 @item @var{Y} @tab The type shall be the same type and kind as @var{X}.
2707 @item @emph{Return value}:
2708 The return value is of type @code{INTEGER(*)} or @code{REAL(*)}.
2710 @item @emph{Example}:
2716 x = dim(4.345_8, 2.111_8)
2719 end program test_dim
2722 @item @emph{Specific names}:
2723 @multitable @columnfractions .20 .20 .20 .40
2724 @item Name @tab Argument @tab Return type @tab Standard
2725 @item @code{IDIM(X,Y)} @tab @code{INTEGER(4) X,Y} @tab @code{INTEGER(4)} @tab F77 and later
2726 @item @code{DDIM(X,Y)} @tab @code{REAL(8) X,Y} @tab @code{REAL(8)} @tab F77 and later
2733 @section @code{DOT_PRODUCT} --- Dot product function
2734 @cindex @code{DOT_PRODUCT} intrinsic
2738 @item @emph{Description}:
2739 @code{DOT_PRODUCT(X,Y)} computes the dot product multiplication of two vectors
2740 @var{X} and @var{Y}. The two vectors may be either numeric or logical
2741 and must be arrays of rank one and of equal size. If the vectors are
2742 @code{INTEGER(*)} or @code{REAL(*)}, the result is @code{SUM(X*Y)}. If the
2743 vectors are @code{COMPLEX(*)}, the result is @code{SUM(CONJG(X)*Y)}. If the
2744 vectors are @code{LOGICAL}, the result is @code{ANY(X.AND.Y)}.
2746 @item @emph{Standard}:
2750 transformational function
2752 @item @emph{Syntax}:
2753 @code{RESULT = DOT_PRODUCT(X, Y)}
2755 @item @emph{Arguments}:
2756 @multitable @columnfractions .15 .80
2757 @item @var{X} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
2758 @item @var{Y} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
2761 @item @emph{Return value}:
2762 If the arguments are numeric, the return value is a scaler of numeric type,
2763 @code{INTEGER(*)}, @code{REAL(*)}, or @code{COMPLEX(*)}. If the arguments are
2764 @code{LOGICAL}, the return value is @code{.TRUE.} or @code{.FALSE.}.
2766 @item @emph{Example}:
2768 program test_dot_prod
2769 integer, dimension(3) :: a, b
2776 print *, dot_product(a,b)
2777 end program test_dot_prod
2784 @section @code{DPROD} --- Double product function
2785 @cindex @code{DPROD} intrinsic
2786 @cindex double-precision product
2789 @item @emph{Description}:
2790 @code{DPROD(X,Y)} returns the product @code{X*Y}.
2792 @item @emph{Standard}:
2798 @item @emph{Syntax}:
2799 @code{RESULT = DPROD(X, Y)}
2801 @item @emph{Arguments}:
2802 @multitable @columnfractions .15 .80
2803 @item @var{X} @tab The type shall be @code{REAL}.
2804 @item @var{Y} @tab The type shall be @code{REAL}.
2807 @item @emph{Return value}:
2808 The return value is of type @code{REAL(8)}.
2810 @item @emph{Example}:
2819 end program test_dprod
2826 @section @code{DREAL} --- Double real part function
2827 @cindex @code{DREAL} intrinsic
2828 @cindex double-precision real part
2831 @item @emph{Description}:
2832 @code{DREAL(Z)} returns the real part of complex variable @var{Z}.
2834 @item @emph{Standard}:
2840 @item @emph{Syntax}:
2841 @code{RESULT = DREAL(Z)}
2843 @item @emph{Arguments}:
2844 @multitable @columnfractions .15 .80
2845 @item @var{Z} @tab The type shall be @code{COMPLEX(8)}.
2848 @item @emph{Return value}:
2849 The return value is of type @code{REAL(8)}.
2851 @item @emph{Example}:
2854 complex(8) :: z = (1.3_8,7.2_8)
2856 end program test_dreal
2859 @item @emph{See also}:
2867 @section @code{DTIME} --- Execution time subroutine (or function)
2868 @cindex @code{DTIME} intrinsic
2869 @cindex time, elapsed
2870 @cindex elapsed time
2873 @item @emph{Description}:
2874 @code{DTIME(TARRAY, RESULT)} initially returns the number of seconds of runtime
2875 since the start of the process's execution in @var{RESULT}. @var{TARRAY}
2876 returns the user and system components of this time in @code{TARRAY(1)} and
2877 @code{TARRAY(2)} respectively. @var{RESULT} is equal to @code{TARRAY(1) +
2880 Subsequent invocations of @code{DTIME} return values accumulated since the
2881 previous invocation.
2883 On some systems, the underlying timings are represented using types with
2884 sufficiently small limits that overflows (wrap around) are possible, such as
2885 32-bit types. Therefore, the values returned by this intrinsic might be, or
2886 become, negative, or numerically less than previous values, during a single
2887 run of the compiled program.
2889 If @code{DTIME} is invoked as a function, it can not be invoked as a
2890 subroutine, and vice versa.
2892 @var{TARRAY} and @var{RESULT} are @code{INTENT(OUT)} and provide the following:
2894 @multitable @columnfractions .15 .30 .60
2895 @item @tab @code{TARRAY(1)}: @tab User time in seconds.
2896 @item @tab @code{TARRAY(2)}: @tab System time in seconds.
2897 @item @tab @code{RESULT}: @tab Run time since start in seconds.
2900 @item @emph{Standard}:
2906 @item @emph{Syntax}:
2907 @multitable @columnfractions .80
2908 @item @code{CALL DTIME(TARRAY, RESULT)}.
2909 @item @code{RESULT = DTIME(TARRAY)}, (not recommended).
2912 @item @emph{Arguments}:
2913 @multitable @columnfractions .15 .80
2914 @item @var{TARRAY}@tab The type shall be @code{REAL, DIMENSION(2)}.
2915 @item @var{RESULT}@tab The type shall be @code{REAL}.
2918 @item @emph{Return value}:
2919 Elapsed time in seconds since the start of program execution.
2921 @item @emph{Example}:
2925 real, dimension(2) :: tarray
2927 call dtime(tarray, result)
2931 do i=1,100000000 ! Just a delay
2934 call dtime(tarray, result)
2938 end program test_dtime
2945 @section @code{EOSHIFT} --- End-off shift function
2946 @cindex @code{EOSHIFT} intrinsic
2947 @cindex bit operations
2950 @item @emph{Description}:
2951 @code{EOSHIFT(ARRAY, SHIFT[,BOUNDARY, DIM])} performs an end-off shift on
2952 elements of @var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is
2953 omitted it is taken to be @code{1}. @var{DIM} is a scaler of type
2954 @code{INTEGER} in the range of @math{1 /leq DIM /leq n)} where @math{n} is the
2955 rank of @var{ARRAY}. If the rank of @var{ARRAY} is one, then all elements of
2956 @var{ARRAY} are shifted by @var{SHIFT} places. If rank is greater than one,
2957 then all complete rank one sections of @var{ARRAY} along the given dimension are
2958 shifted. Elements shifted out one end of each rank one section are dropped. If
2959 @var{BOUNDARY} is present then the corresponding value of from @var{BOUNDARY}
2960 is copied back in the other end. If @var{BOUNDARY} is not present then the
2961 following are copied in depending on the type of @var{ARRAY}.
2963 @multitable @columnfractions .15 .80
2964 @item @emph{Array Type} @tab @emph{Boundary Value}
2965 @item Numeric @tab 0 of the type and kind of @var{ARRAY}.
2966 @item Logical @tab @code{.FALSE.}.
2967 @item Character(@var{len}) @tab @var{len} blanks.
2970 @item @emph{Standard}:
2974 transformational function
2976 @item @emph{Syntax}:
2977 @code{RESULT = EOSHIFT(A, SHIFT [, BOUNDARY, DIM])}
2979 @item @emph{Arguments}:
2980 @multitable @columnfractions .15 .80
2981 @item @var{ARRAY} @tab May be any type, not scaler.
2982 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
2983 @item @var{BOUNDARY} @tab Same type as @var{ARRAY}.
2984 @item @var{DIM} @tab The type shall be @code{INTEGER}.
2987 @item @emph{Return value}:
2988 Returns an array of same type and rank as the @var{ARRAY} argument.
2990 @item @emph{Example}:
2992 program test_eoshift
2993 integer, dimension(3,3) :: a
2994 a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
2995 print '(3i3)', a(1,:)
2996 print '(3i3)', a(2,:)
2997 print '(3i3)', a(3,:)
2998 a = EOSHIFT(a, SHIFT=(/1, 2, 1/), BOUNDARY=-5, DIM=2)
3000 print '(3i3)', a(1,:)
3001 print '(3i3)', a(2,:)
3002 print '(3i3)', a(3,:)
3003 end program test_eoshift
3010 @section @code{EPSILON} --- Epsilon function
3011 @cindex @code{EPSILON} intrinsic
3012 @cindex epsilon, significant
3015 @item @emph{Description}:
3016 @code{EPSILON(X)} returns a nearly negligible number relative to @code{1}.
3018 @item @emph{Standard}:
3024 @item @emph{Syntax}:
3025 @code{RESULT = EPSILON(X)}
3027 @item @emph{Arguments}:
3028 @multitable @columnfractions .15 .80
3029 @item @var{X} @tab The type shall be @code{REAL(*)}.
3032 @item @emph{Return value}:
3033 The return value is of same type as the argument.
3035 @item @emph{Example}:
3037 program test_epsilon
3042 end program test_epsilon
3049 @section @code{ERF} --- Error function
3050 @cindex @code{ERF} intrinsic
3051 @cindex error function
3054 @item @emph{Description}:
3055 @code{ERF(X)} computes the error function of @var{X}.
3057 @item @emph{Standard}:
3063 @item @emph{Syntax}:
3064 @code{RESULT = ERF(X)}
3066 @item @emph{Arguments}:
3067 @multitable @columnfractions .15 .80
3068 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
3071 @item @emph{Return value}:
3072 The return value is a scalar of type @code{REAL(*)} and it is positive
3073 (@math{ - 1 \leq erf (x) \leq 1 }.
3075 @item @emph{Example}:
3078 real(8) :: x = 0.17_8
3080 end program test_erf
3083 @item @emph{Specific names}:
3084 @multitable @columnfractions .20 .20 .20 .40
3085 @item Name @tab Argument @tab Return type @tab Standard
3086 @item @code{DERF(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
3093 @section @code{ERFC} --- Error function
3094 @cindex @code{ERFC} intrinsic
3095 @cindex error function
3098 @item @emph{Description}:
3099 @code{ERFC(X)} computes the complementary error function of @var{X}.
3101 @item @emph{Standard}:
3107 @item @emph{Syntax}:
3108 @code{RESULT = ERFC(X)}
3110 @item @emph{Arguments}:
3111 @multitable @columnfractions .15 .80
3112 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
3115 @item @emph{Return value}:
3116 The return value is a scalar of type @code{REAL(*)} and it is positive
3117 (@math{ 0 \leq erfc (x) \leq 2 }.
3119 @item @emph{Example}:
3122 real(8) :: x = 0.17_8
3124 end program test_erfc
3127 @item @emph{Specific names}:
3128 @multitable @columnfractions .20 .20 .20 .40
3129 @item Name @tab Argument @tab Return type @tab Standard
3130 @item @code{DERFC(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
3137 @section @code{ETIME} --- Execution time subroutine (or function)
3138 @cindex @code{ETIME} intrinsic
3139 @cindex time, elapsed
3142 @item @emph{Description}:
3143 @code{ETIME(TARRAY, RESULT)} returns the number of seconds of runtime
3144 since the start of the process's execution in @var{RESULT}. @var{TARRAY}
3145 returns the user and system components of this time in @code{TARRAY(1)} and
3146 @code{TARRAY(2)} respectively. @var{RESULT} is equal to @code{TARRAY(1) + TARRAY(2)}.
3148 On some systems, the underlying timings are represented using types with
3149 sufficiently small limits that overflows (wrap around) are possible, such as
3150 32-bit types. Therefore, the values returned by this intrinsic might be, or
3151 become, negative, or numerically less than previous values, during a single
3152 run of the compiled program.
3154 If @code{ETIME} is invoked as a function, it can not be invoked as a
3155 subroutine, and vice versa.
3157 @var{TARRAY} and @var{RESULT} are @code{INTENT(OUT)} and provide the following:
3159 @multitable @columnfractions .15 .30 .60
3160 @item @tab @code{TARRAY(1)}: @tab User time in seconds.
3161 @item @tab @code{TARRAY(2)}: @tab System time in seconds.
3162 @item @tab @code{RESULT}: @tab Run time since start in seconds.
3165 @item @emph{Standard}:
3171 @item @emph{Syntax}:
3172 @multitable @columnfractions .8
3173 @item @code{CALL ETIME(TARRAY, RESULT)}.
3174 @item @code{RESULT = ETIME(TARRAY)}, (not recommended).
3177 @item @emph{Arguments}:
3178 @multitable @columnfractions .15 .80
3179 @item @var{TARRAY}@tab The type shall be @code{REAL, DIMENSION(2)}.
3180 @item @var{RESULT}@tab The type shall be @code{REAL}.
3183 @item @emph{Return value}:
3184 Elapsed time in seconds since the start of program execution.
3186 @item @emph{Example}:
3190 real, dimension(2) :: tarray
3192 call ETIME(tarray, result)
3196 do i=1,100000000 ! Just a delay
3199 call ETIME(tarray, result)
3203 end program test_etime
3206 @item @emph{See also}:
3214 @section @code{EXIT} --- Exit the program with status.
3215 @cindex @code{EXIT} intrinsic
3216 @cindex exit program
3219 @item @emph{Description}:
3220 @code{EXIT} causes immediate termination of the program with status. If status
3221 is omitted it returns the canonical @emph{success} for the system. All Fortran
3222 I/O units are closed.
3224 @item @emph{Standard}:
3230 @item @emph{Syntax}:
3231 @code{CALL EXIT([STATUS])}
3233 @item @emph{Arguments}:
3234 @multitable @columnfractions .15 .80
3235 @item @var{STATUS} @tab The type of the argument shall be @code{INTEGER(*)}.
3238 @item @emph{Return value}:
3239 @code{STATUS} is passed to the parent process on exit.
3241 @item @emph{Example}:
3244 integer :: STATUS = 0
3245 print *, 'This program is going to exit.'
3247 end program test_exit
3250 @item @emph{See also}:
3251 @ref{ABORT}, @ref{KILL}
3257 @section @code{EXP} --- Exponential function
3258 @cindex @code{EXP} intrinsic
3259 @cindex @code{DEXP} intrinsic
3260 @cindex @code{ZEXP} intrinsic
3261 @cindex @code{CDEXP} intrinsic
3265 @item @emph{Description}:
3266 @code{EXP(X)} computes the base @math{e} exponential of @var{X}.
3268 @item @emph{Standard}:
3269 F77 and later, has overloads that are GNU extensions
3274 @item @emph{Syntax}:
3275 @code{RESULT = EXP(X)}
3277 @item @emph{Arguments}:
3278 @multitable @columnfractions .15 .80
3279 @item @var{X} @tab The type shall be @code{REAL(*)} or
3283 @item @emph{Return value}:
3284 The return value has same type and kind as @var{X}.
3286 @item @emph{Example}:
3291 end program test_exp
3294 @item @emph{Specific names}:
3295 @multitable @columnfractions .20 .20 .20 .40
3296 @item Name @tab Argument @tab Return type @tab Standard
3297 @item @code{DEXP(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
3298 @item @code{CEXP(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab F77 and later
3299 @item @code{ZEXP(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
3300 @item @code{CDEXP(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
3307 @section @code{EXPONENT} --- Exponent function
3308 @cindex @code{EXPONENT} intrinsic
3309 @cindex exponent part of a real number
3312 @item @emph{Description}:
3313 @code{EXPONENT(X)} returns the value of the exponent part of @var{X}. If @var{X}
3314 is zero the value returned is zero.
3316 @item @emph{Standard}:
3322 @item @emph{Syntax}:
3323 @code{RESULT = EXPONENT(X)}
3325 @item @emph{Arguments}:
3326 @multitable @columnfractions .15 .80
3327 @item @var{X} @tab The type shall be @code{REAL(*)}.
3330 @item @emph{Return value}:
3331 The return value is of type default @code{INTEGER}.
3333 @item @emph{Example}:
3335 program test_exponent
3340 print *, exponent(0.0)
3341 end program test_exponent
3347 @section @code{FDATE} --- Get the current time as a string
3348 @cindex @code{FDATE} intrinsic
3349 @cindex time, current
3350 @cindex current time
3351 @cindex date, current
3352 @cindex current date
3355 @item @emph{Description}:
3356 @code{FDATE(DATE)} returns the current date (using the same format as
3357 @code{CTIME}) in @var{DATE}. It is equivalent to @code{CALL CTIME(DATE,
3360 If @code{FDATE} is invoked as a function, it can not be invoked as a
3361 subroutine, and vice versa.
3363 @var{DATE} is an @code{INTENT(OUT)} @code{CHARACTER} variable.
3365 @item @emph{Standard}:
3371 @item @emph{Syntax}:
3372 @multitable @columnfractions .80
3373 @item @code{CALL FDATE(DATE)}.
3374 @item @code{DATE = FDATE()}, (not recommended).
3377 @item @emph{Arguments}:
3378 @multitable @columnfractions .15 .80
3379 @item @var{DATE}@tab The type shall be of type @code{CHARACTER}.
3382 @item @emph{Return value}:
3383 The current date as a string.
3385 @item @emph{Example}:
3389 character(len=30) :: date
3391 print *, 'Program started on ', date
3392 do i = 1, 100000000 ! Just a delay
3396 print *, 'Program ended on ', date
3397 end program test_fdate
3403 @section @code{FLOAT} --- Convert integer to default real
3404 @cindex @code{FLOAT} intrinsic
3405 @cindex conversion function (float)
3408 @item @emph{Description}:
3409 @code{FLOAT(I)} converts the integer @var{I} to a default real value.
3411 @item @emph{Standard}:
3417 @item @emph{Syntax}:
3418 @code{RESULT = FLOAT(I)}
3420 @item @emph{Arguments}:
3421 @multitable @columnfractions .15 .80
3422 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
3425 @item @emph{Return value}:
3426 The return value is of type default @code{REAL}.
3428 @item @emph{Example}:
3432 if (float(i) /= 1.) call abort
3433 end program test_float
3436 @item @emph{See also}:
3437 @ref{DBLE}, @ref{DFLOAT}, @ref{REAL}
3443 @section @code{FGET} --- Read a single character in stream mode from stdin
3444 @cindex @code{FGET} intrinsic
3445 @cindex file operations
3446 @cindex stream operations
3449 @item @emph{Description}:
3450 Read a single character in stream mode from stdin by bypassing normal
3451 formatted output. Stream I/O should not be mixed with normal record-oriented
3452 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
3454 This intrinsic routine is provided for backwards compatibility with
3455 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
3456 Programmers should consider the use of new stream IO feature in new code
3457 for future portability. See also @ref{Fortran 2003 status}.
3459 @item @emph{Standard}:
3463 Non-elemental subroutine
3465 @item @emph{Syntax}:
3466 @code{CALL FGET(C [, STATUS])}
3468 @item @emph{Arguments}:
3469 @multitable @columnfractions .15 .80
3470 @item @var{C} @tab The type shall be @code{CHARACTER}.
3471 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}.
3472 Returns 0 on success, -1 on end-of-file, and a
3473 system specific positive error code otherwise.
3476 @item @emph{Example}:
3479 INTEGER, PARAMETER :: strlen = 100
3480 INTEGER :: status, i = 1
3481 CHARACTER(len=strlen) :: str = ""
3483 WRITE (*,*) 'Enter text:'
3485 CALL fget(str(i:i), status)
3486 if (status /= 0 .OR. i > strlen) exit
3489 WRITE (*,*) TRIM(str)
3493 @item @emph{See also}:
3494 @ref{FGETC}, @ref{FPUT}, @ref{FPUTC}
3499 @section @code{FGETC} --- Read a single character in stream mode
3500 @cindex @code{FGETC} intrinsic
3501 @cindex file operations
3502 @cindex stream operations
3505 @item @emph{Description}:
3506 Read a single character in stream mode by bypassing normal formatted output.
3507 Stream I/O should not be mixed with normal record-oriented (formatted or
3508 unformatted) I/O on the same unit; the results are unpredictable.
3510 This intrinsic routine is provided for backwards compatibility with
3511 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
3512 Programmers should consider the use of new stream IO feature in new code
3513 for future portability. See also @ref{Fortran 2003 status}.
3515 @item @emph{Standard}:
3519 Non-elemental subroutine
3521 @item @emph{Syntax}:
3522 @code{CALL FGETC(UNIT, C [, STATUS])}
3524 @item @emph{Arguments}:
3525 @multitable @columnfractions .15 .80
3526 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
3527 @item @var{C} @tab The type shall be @code{CHARACTER}.
3528 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. Returns 0 on success,
3529 -1 on end-of-file and a system specific positive error code otherwise.
3532 @item @emph{Example}:
3535 INTEGER :: fd = 42, status
3538 OPEN(UNIT=fd, FILE="/etc/passwd", ACTION="READ", STATUS = "OLD")
3540 CALL fgetc(fd, c, status)
3541 IF (status /= 0) EXIT
3548 @item @emph{See also}:
3549 @ref{FGET}, @ref{FPUT}, @ref{FPUTC}
3555 @section @code{FLOOR} --- Integer floor function
3556 @cindex @code{FLOOR} intrinsic
3560 @item @emph{Description}:
3561 @code{FLOOR(X)} returns the greatest integer less than or equal to @var{X}.
3563 @item @emph{Standard}:
3569 @item @emph{Syntax}:
3570 @code{RESULT = FLOOR(X [, KIND])}
3572 @item @emph{Arguments}:
3573 @multitable @columnfractions .15 .80
3574 @item @var{X} @tab The type shall be @code{REAL(*)}.
3575 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
3576 expression indicating the kind parameter of
3580 @item @emph{Return value}:
3581 The return value is of type @code{INTEGER(KIND)}
3583 @item @emph{Example}:
3588 print *, floor(x) ! returns 63
3589 print *, floor(y) ! returns -64
3590 end program test_floor
3593 @item @emph{See also}:
3594 @ref{CEILING}, @ref{NINT}
3601 @section @code{FLUSH} --- Flush I/O unit(s)
3602 @cindex @code{FLUSH} intrinsic
3603 @cindex flush output files
3606 @item @emph{Description}:
3607 Flushes Fortran unit(s) currently open for output. Without the optional
3608 argument, all units are flushed, otherwise just the unit specified.
3610 @item @emph{Standard}:
3614 non-elemental subroutine
3616 @item @emph{Syntax}:
3617 @code{CALL FLUSH(UNIT)}
3619 @item @emph{Arguments}:
3620 @multitable @columnfractions .15 .80
3621 @item @var{UNIT} @tab (Optional) The type shall be @code{INTEGER}.
3625 Beginning with the Fortran 2003 standard, there is a @code{FLUSH}
3626 statement that should be preferred over the @code{FLUSH} intrinsic.
3633 @section @code{FNUM} --- File number function
3634 @cindex @code{FNUM} intrinsic
3638 @item @emph{Description}:
3639 @code{FNUM(UNIT)} returns the POSIX file descriptor number corresponding to the
3640 open Fortran I/O unit @code{UNIT}.
3642 @item @emph{Standard}:
3646 non-elemental function
3648 @item @emph{Syntax}:
3649 @code{RESULT = FNUM(UNIT)}
3651 @item @emph{Arguments}:
3652 @multitable @columnfractions .15 .80
3653 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
3656 @item @emph{Return value}:
3657 The return value is of type @code{INTEGER}
3659 @item @emph{Example}:
3663 open (unit=10, status = "scratch")
3667 end program test_fnum
3674 @section @code{FPUT} --- Write a single character in stream mode to stdout
3675 @cindex @code{FPUT} intrinsic
3676 @cindex file operations
3677 @cindex stream operations
3680 @item @emph{Description}:
3681 Write a single character in stream mode to stdout by bypassing normal
3682 formatted output. Stream I/O should not be mixed with normal record-oriented
3683 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
3685 This intrinsic routine is provided for backwards compatibility with
3686 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
3687 Programmers should consider the use of new stream IO feature in new code
3688 for future portability. See also @ref{Fortran 2003 status}.
3690 @item @emph{Standard}:
3694 Non-elemental subroutine
3696 @item @emph{Syntax}:
3697 @code{CALL FPUT(C [, STATUS])}
3699 @item @emph{Arguments}:
3700 @multitable @columnfractions .15 .80
3701 @item @var{C} @tab The type shall be @code{CHARACTER}.
3702 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. Returns 0 on success,
3703 -1 on end-of-file and a system specific positive error code otherwise.
3706 @item @emph{Example}:
3709 CHARACTER(len=*) :: str = "gfortran"
3711 DO i = 1, len_trim(str)
3717 @item @emph{See also}:
3718 @ref{FPUTC}, @ref{FGET}, @ref{FGETC}
3724 @section @code{FPUTC} --- Write a single character in stream mode
3725 @cindex @code{FPUTC} intrinsic
3726 @cindex file operations
3727 @cindex stream operations
3730 @item @emph{Description}: