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{TINY}: TINY, Smallest positive number of a real kind
242 * @code{TRANSFER}: TRANSFER, Transfer bit patterns
243 * @code{TRANSPOSE}: TRANSPOSE, Transpose an array of rank two
244 * @code{TRIM}: TRIM, Function to remove trailing blank characters of a string
245 * @code{UBOUND}: UBOUND, Upper dimension bounds of an array
246 * @code{UMASK}: UMASK, Set the file creation mask
247 * @code{UNLINK}: UNLINK, Remove a file from the file system
248 * @code{UNMASK}: UNMASK, (?)
249 * @code{UNPACK}: UNPACK, Unpack an array of rank one into an array
250 * @code{VERIFY}: VERIFY, Scan a string for the absence of a set of characters
251 * @code{XOR}: XOR, Bitwise logical exclusive or
254 @node Introduction to Intrinsics
255 @section Introduction to intrinsic procedures
257 The intrinsic procedures provided by GNU Fortran include all of the
258 intrinsic procedures required by the Fortran 95 standard, a set of
259 intrinsic procedures for backwards compatibility with G77, and a small
260 selection of intrinsic procedures from the Fortran 2003 standard. Any
261 conflict between a description here and a description in either the
262 Fortran 95 standard or the Fortran 2003 standard is unintentional, and
263 the standard(s) should be considered authoritative.
265 The enumeration of the @code{KIND} type parameter is processor defined in
266 the Fortran 95 standard. GNU Fortran defines the default integer type and
267 default real type by @code{INTEGER(KIND=4)} and @code{REAL(KIND=4)},
268 respectively. The standard mandates that both data types shall have
269 another kind, which have more precision. On typical target architectures
270 supported by @command{gfortran}, this kind type parameter is @code{KIND=8}.
271 Hence, @code{REAL(KIND=8)} and @code{DOUBLE PRECISION} are equivalent.
272 In the description of generic intrinsic procedures, the kind type parameter
273 will be specified by @code{KIND=*}, and in the description of specific
274 names for an intrinsic procedure the kind type parameter will be explicitly
275 given (e.g., @code{REAL(KIND=4)} or @code{REAL(KIND=8)}). Finally, for
276 brevity the optional @code{KIND=} syntax will be omitted.
278 Many of the intrinsic procedures take one or more optional arguments.
279 This document follows the convention used in the Fortran 95 standard,
280 and denotes such arguments by square brackets.
282 GNU Fortran offers the @option{-std=f95} and @option{-std=gnu} options,
283 which can be used to restrict the set of intrinsic procedures to a
284 given standard. By default, @command{gfortran} sets the @option{-std=gnu}
285 option, and so all intrinsic procedures described here are accepted. There
286 is one caveat. For a select group of intrinsic procedures, @command{g77}
287 implemented both a function and a subroutine. Both classes
288 have been implemented in @command{gfortran} for backwards compatibility
289 with @command{g77}. It is noted here that these functions and subroutines
290 cannot be intermixed in a given subprogram. In the descriptions that follow,
291 the applicable 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
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{I = 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}:
466 @item @emph{Arguments}:
467 @multitable @columnfractions .15 .80
468 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
471 @item @emph{Return value}:
472 The return value is of type @code{CHARACTER} with a length of one. The
473 kind type parameter is the same as @code{KIND('A')}.
475 @item @emph{Example}:
480 end program test_achar
487 @section @code{ACOS} --- Arccosine function
488 @cindex @code{ACOS} intrinsic
489 @cindex @code{DACOS} intrinsic
490 @cindex trigonometric functions (inverse)
493 @item @emph{Description}:
494 @code{ACOS(X)} computes the arccosine of @var{X} (inverse of @code{COS(X)}).
496 @item @emph{Standard}:
505 @item @emph{Arguments}:
506 @multitable @columnfractions .15 .80
507 @item @var{X} @tab The type shall be @code{REAL(*)} with a magnitude that is
511 @item @emph{Return value}:
512 The return value is of type @code{REAL(*)} and it lies in the
513 range @math{ 0 \leq \acos(x) \leq \pi}. The kind type parameter
514 is the same as @var{X}.
516 @item @emph{Example}:
519 real(8) :: x = 0.866_8
521 end program test_acos
524 @item @emph{Specific names}:
525 @multitable @columnfractions .20 .20 .20 .40
526 @item Name @tab Argument @tab Return type @tab Standard
527 @item @code{DACOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
530 @item @emph{See also}:
531 Inverse function: @ref{COS}
537 @section @code{ACOSH} --- Hyperbolic arccosine function
538 @cindex @code{ACOSH} intrinsic
539 @cindex hyperbolic arccosine
540 @cindex hyperbolic cosine (inverse)
543 @item @emph{Description}:
544 @code{ACOSH(X)} computes the area hyperbolic cosine of @var{X} (inverse of @code{COSH(X)}).
546 @item @emph{Standard}:
555 @item @emph{Arguments}:
556 @multitable @columnfractions .15 .80
557 @item @var{X} @tab The type shall be @code{REAL(*)} with a magnitude that is
558 greater or equal to one.
561 @item @emph{Return value}:
562 The return value is of type @code{REAL(*)} and it lies in the
563 range @math{0 \leq \acosh (x) \leq \infty}.
565 @item @emph{Example}:
568 REAL(8), DIMENSION(3) :: x = (/ 1.0, 2.0, 3.0 /)
573 @item @emph{See also}:
574 Inverse function: @ref{COSH}
580 @section @code{ADJUSTL} --- Left adjust a string
581 @cindex @code{ADJUSTL} intrinsic
582 @cindex adjust string
585 @item @emph{Description}:
586 @code{ADJUSTL(STR)} will left adjust a string by removing leading spaces.
587 Spaces are inserted at the end of the string as needed.
589 @item @emph{Standard}:
596 @code{STR = ADJUSTL(STR)}
598 @item @emph{Arguments}:
599 @multitable @columnfractions .15 .80
600 @item @var{STR} @tab The type shall be @code{CHARACTER}.
603 @item @emph{Return value}:
604 The return value is of type @code{CHARACTER} where leading spaces
605 are removed and the same number of spaces are inserted on the end
608 @item @emph{Example}:
611 character(len=20) :: str = ' gfortran'
614 end program test_adjustl
621 @section @code{ADJUSTR} --- Right adjust a string
622 @cindex @code{ADJUSTR} intrinsic
623 @cindex adjust string
626 @item @emph{Description}:
627 @code{ADJUSTR(STR)} will right adjust a string by removing trailing spaces.
628 Spaces are inserted at the start of the string as needed.
630 @item @emph{Standard}:
637 @code{STR = ADJUSTR(STR)}
639 @item @emph{Arguments}:
640 @multitable @columnfractions .15 .80
641 @item @var{STR} @tab The type shall be @code{CHARACTER}.
644 @item @emph{Return value}:
645 The return value is of type @code{CHARACTER} where trailing spaces
646 are removed and the same number of spaces are inserted at the start
649 @item @emph{Example}:
652 character(len=20) :: str = 'gfortran'
655 end program test_adjustr
662 @section @code{AIMAG} --- Imaginary part of complex number
663 @cindex @code{AIMAG} intrinsic
664 @cindex @code{DIMAG} intrinsic
665 @cindex @code{IMAG} intrinsic
666 @cindex @code{IMAGPART} intrinsic
667 @cindex imaginary part of a complex number
670 @item @emph{Description}:
671 @code{AIMAG(Z)} yields the imaginary part of complex argument @code{Z}.
672 The @code{IMAG(Z)} and @code{IMAGPART(Z)} intrinsic functions are provided
673 for compatibility with @command{g77}, and their use in new code is
674 strongly discouraged.
676 @item @emph{Standard}:
677 F77 and later, has overloads that are GNU extensions
685 @item @emph{Arguments}:
686 @multitable @columnfractions .15 .80
687 @item @var{Z} @tab The type of the argument shall be @code{COMPLEX(*)}.
690 @item @emph{Return value}:
691 The return value is of type real with the
692 kind type parameter of the argument.
694 @item @emph{Example}:
699 z4 = cmplx(1.e0_4, 0.e0_4)
700 z8 = cmplx(0.e0_8, 1.e0_8)
701 print *, aimag(z4), dimag(z8)
702 end program test_aimag
705 @item @emph{Specific names}:
706 @multitable @columnfractions .20 .20 .20 .40
707 @item Name @tab Argument @tab Return type @tab Standard
708 @item @code{DIMAG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{REAL(8)} @tab GNU extension
709 @item @code{IMAG(Z)} @tab @code{COMPLEX(*) Z} @tab @code{REAL(*)} @tab GNU extension
710 @item @code{IMAGPART(Z)} @tab @code{COMPLEX(*) Z} @tab @code{REAL(*)} @tab GNU extension
717 @section @code{AINT} --- Truncate to a whole number
718 @cindex @code{AINT} intrinsic
719 @cindex @code{DINT} intrinsic
723 @item @emph{Description}:
724 @code{AINT(X [, KIND])} truncates its argument to a whole number.
726 @item @emph{Standard}:
733 @code{X = AINT(X [, KIND])}
735 @item @emph{Arguments}:
736 @multitable @columnfractions .15 .80
737 @item @var{X} @tab The type of the argument shall be @code{REAL(*)}.
738 @item @var{KIND} @tab (Optional) @var{KIND} shall be a scalar integer
739 initialization expression.
742 @item @emph{Return value}:
743 The return value is of type real with the kind type parameter of the
744 argument if the optional @var{KIND} is absent; otherwise, the kind
745 type parameter will be given by @var{KIND}. If the magnitude of
746 @var{X} is less than one, then @code{AINT(X)} returns zero. If the
747 magnitude is equal to or greater than one, then it returns the largest
748 whole number that does not exceed its magnitude. The sign is the same
749 as the sign of @var{X}.
751 @item @emph{Example}:
758 print *, aint(x4), dint(x8)
760 end program test_aint
763 @item @emph{Specific names}:
764 @multitable @columnfractions .20 .20 .20 .40
765 @item Name @tab Argument @tab Return type @tab Standard
766 @item @code{DINT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
773 @section @code{ALARM} --- Execute a routine after a given delay
774 @cindex @code{ALARM} intrinsic
777 @item @emph{Description}:
778 @code{ALARM(SECONDS, HANDLER [, STATUS])} causes external subroutine @var{HANDLER}
779 to be executed after a delay of @var{SECONDS} by using @code{alarm(1)} to
780 set up a signal and @code{signal(2)} to catch it. If @var{STATUS} is
781 supplied, it will be returned with the number of seconds remaining until
782 any previously scheduled alarm was due to be delivered, or zero if there
783 was no previously scheduled alarm.
785 @item @emph{Standard}:
792 @code{CALL ALARM(SECONDS, HANDLER [, STATUS])}
794 @item @emph{Arguments}:
795 @multitable @columnfractions .15 .80
796 @item @var{SECONDS} @tab The type of the argument shall be a scalar
797 @code{INTEGER}. It is @code{INTENT(IN)}.
798 @item @var{HANDLER} @tab Signal handler (@code{INTEGER FUNCTION} or
799 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar.
800 @code{INTEGER}. It is @code{INTENT(IN)}.
801 @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
802 @code{INTEGER} variable. It is @code{INTENT(OUT)}.
805 @item @emph{Example}:
808 external handler_print
810 call alarm (3, handler_print, i)
813 end program test_alarm
815 This will cause the external routine @var{handler_print} to be called
822 @section @code{ALL} --- All values in @var{MASK} along @var{DIM} are true
823 @cindex @code{ALL} intrinsic
827 @item @emph{Description}:
828 @code{ALL(MASK [, DIM])} determines if all the values are true in @var{MASK}
829 in the array along dimension @var{DIM}.
831 @item @emph{Standard}:
835 transformational function
838 @code{L = ALL(MASK [, DIM])}
840 @item @emph{Arguments}:
841 @multitable @columnfractions .15 .80
842 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL(*)} and
843 it shall not be scalar.
844 @item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer
845 with a value that lies between one and the rank of @var{MASK}.
848 @item @emph{Return value}:
849 @code{ALL(MASK)} returns a scalar value of type @code{LOGICAL(*)} where
850 the kind type parameter is the same as the kind type parameter of
851 @var{MASK}. If @var{DIM} is present, then @code{ALL(MASK, DIM)} returns
852 an array with the rank of @var{MASK} minus 1. The shape is determined from
853 the shape of @var{MASK} where the @var{DIM} dimension is elided.
857 @code{ALL(MASK)} is true if all elements of @var{MASK} are true.
858 It also is true if @var{MASK} has zero size; otherwise, it is false.
860 If the rank of @var{MASK} is one, then @code{ALL(MASK,DIM)} is equivalent
861 to @code{ALL(MASK)}. If the rank is greater than one, then @code{ALL(MASK,DIM)}
862 is determined by applying @code{ALL} to the array sections.
865 @item @emph{Example}:
869 l = all((/.true., .true., .true./))
874 integer a(2,3), b(2,3)
878 print *, all(a .eq. b, 1)
879 print *, all(a .eq. b, 2)
880 end subroutine section
888 @section @code{ALLOCATED} --- Status of an allocatable entity
889 @cindex @code{ALLOCATED} intrinsic
890 @cindex allocation status
893 @item @emph{Description}:
894 @code{ALLOCATED(X)} checks the status of whether @var{X} is allocated.
896 @item @emph{Standard}:
903 @code{L = ALLOCATED(X)}
905 @item @emph{Arguments}:
906 @multitable @columnfractions .15 .80
907 @item @var{X} @tab The argument shall be an @code{ALLOCATABLE} array.
910 @item @emph{Return value}:
911 The return value is a scalar @code{LOGICAL} with the default logical
912 kind type parameter. If @var{X} is allocated, @code{ALLOCATED(X)}
913 is @code{.TRUE.}; otherwise, it returns the @code{.TRUE.}
915 @item @emph{Example}:
917 program test_allocated
919 real(4), allocatable :: x(:)
920 if (allocated(x) .eqv. .false.) allocate(x(i))
921 end program test_allocated
927 @section @code{AND} --- Bitwise logical AND
928 @cindex @code{AND} intrinsic
929 @cindex bit operations
932 @item @emph{Description}:
933 Bitwise logical @code{AND}.
935 This intrinsic routine is provided for backwards compatibility with
936 GNU Fortran 77. For integer arguments, programmers should consider
937 the use of the @ref{IAND} intrinsic defined by the Fortran standard.
939 @item @emph{Standard}:
943 Non-elemental function
946 @code{RESULT = AND(X, Y)}
948 @item @emph{Arguments}:
949 @multitable @columnfractions .15 .80
950 @item @var{X} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
951 @item @var{Y} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
954 @item @emph{Return value}:
955 The return type is either @code{INTEGER(*)} or @code{LOGICAL} after
956 cross-promotion of the arguments.
958 @item @emph{Example}:
961 LOGICAL :: T = .TRUE., F = ..FALSE.
963 DATA a / Z'F' /, b / Z'3' /
965 WRITE (*,*) AND(T, T), AND(T, F), AND(F, T), AND(F, F)
966 WRITE (*,*) AND(a, b)
970 @item @emph{See also}:
971 F95 elemental function: @ref{IAND}
977 @section @code{ANINT} --- Nearest whole number
978 @cindex @code{ANINT} intrinsic
979 @cindex @code{DNINT} intrinsic
983 @item @emph{Description}:
984 @code{ANINT(X [, KIND])} rounds its argument to the nearest whole number.
986 @item @emph{Standard}:
994 @code{X = ANINT(X, KIND)}
996 @item @emph{Arguments}:
997 @multitable @columnfractions .15 .80
998 @item @var{X} @tab The type of the argument shall be @code{REAL(*)}.
999 @item @var{KIND} @tab (Optional) @var{KIND} shall be a scalar integer
1000 initialization expression.
1003 @item @emph{Return value}:
1004 The return value is of type real with the kind type parameter of the
1005 argument if the optional @var{KIND} is absent; otherwise, the kind
1006 type parameter will be given by @var{KIND}. If @var{X} is greater than
1007 zero, then @code{ANINT(X)} returns @code{AINT(X+0.5)}. If @var{X} is
1008 less than or equal to zero, then it returns @code{AINT(X-0.5)}.
1010 @item @emph{Example}:
1017 print *, anint(x4), dnint(x8)
1019 end program test_anint
1022 @item @emph{Specific names}:
1023 @multitable @columnfractions .20 .20 .20 .40
1024 @item Name @tab Argument @tab Return type @tab Standard
1025 @item @code{DNINT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1032 @section @code{ANY} --- Any value in @var{MASK} along @var{DIM} is true
1033 @cindex @code{ANY} intrinsic
1037 @item @emph{Description}:
1038 @code{ANY(MASK [, DIM])} determines if any of the values in the logical array
1039 @var{MASK} along dimension @var{DIM} are @code{.TRUE.}.
1041 @item @emph{Standard}:
1045 transformational function
1047 @item @emph{Syntax}:
1048 @code{L = ANY(MASK)}
1049 @code{L = ANY(MASK, DIM)}
1051 @item @emph{Arguments}:
1052 @multitable @columnfractions .15 .80
1053 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL(*)} and
1054 it shall not be scalar.
1055 @item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer
1056 with a value that lies between one and the rank of @var{MASK}.
1059 @item @emph{Return value}:
1060 @code{ANY(MASK)} returns a scalar value of type @code{LOGICAL(*)} where
1061 the kind type parameter is the same as the kind type parameter of
1062 @var{MASK}. If @var{DIM} is present, then @code{ANY(MASK, DIM)} returns
1063 an array with the rank of @var{MASK} minus 1. The shape is determined from
1064 the shape of @var{MASK} where the @var{DIM} dimension is elided.
1068 @code{ANY(MASK)} is true if any element of @var{MASK} is true;
1069 otherwise, it is false. It also is false if @var{MASK} has zero size.
1071 If the rank of @var{MASK} is one, then @code{ANY(MASK,DIM)} is equivalent
1072 to @code{ANY(MASK)}. If the rank is greater than one, then @code{ANY(MASK,DIM)}
1073 is determined by applying @code{ANY} to the array sections.
1076 @item @emph{Example}:
1080 l = any((/.true., .true., .true./))
1085 integer a(2,3), b(2,3)
1089 print *, any(a .eq. b, 1)
1090 print *, any(a .eq. b, 2)
1091 end subroutine section
1092 end program test_any
1099 @section @code{ASIN} --- Arcsine function
1100 @cindex @code{ASIN} intrinsic
1101 @cindex @code{DASIN} intrinsic
1102 @cindex trigonometric functions (inverse)
1105 @item @emph{Description}:
1106 @code{ASIN(X)} computes the arcsine of its @var{X} (inverse of @code{SIN(X)}).
1108 @item @emph{Standard}:
1114 @item @emph{Syntax}:
1117 @item @emph{Arguments}:
1118 @multitable @columnfractions .15 .80
1119 @item @var{X} @tab The type shall be @code{REAL(*)}, and a magnitude that is
1123 @item @emph{Return value}:
1124 The return value is of type @code{REAL(*)} and it lies in the
1125 range @math{-\pi / 2 \leq \asin (x) \leq \pi / 2}. The kind type
1126 parameter is the same as @var{X}.
1128 @item @emph{Example}:
1131 real(8) :: x = 0.866_8
1133 end program test_asin
1136 @item @emph{Specific names}:
1137 @multitable @columnfractions .20 .20 .20 .40
1138 @item Name @tab Argument @tab Return type @tab Standard
1139 @item @code{DASIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1142 @item @emph{See also}:
1143 Inverse function: @ref{SIN}
1149 @section @code{ASINH} --- Hyperbolic arcsine function
1150 @cindex @code{ASINH} intrinsic
1151 @cindex hyperbolic arcsine
1152 @cindex hyperbolic sine (inverse)
1155 @item @emph{Description}:
1156 @code{ASINH(X)} computes the area hyperbolic sine of @var{X} (inverse of @code{SINH(X)}).
1158 @item @emph{Standard}:
1164 @item @emph{Syntax}:
1167 @item @emph{Arguments}:
1168 @multitable @columnfractions .15 .80
1169 @item @var{X} @tab The type shall be @code{REAL(*)}, with @var{X} a real number.
1172 @item @emph{Return value}:
1173 The return value is of type @code{REAL(*)} and it lies in the
1174 range @math{-\infty \leq \asinh (x) \leq \infty}.
1176 @item @emph{Example}:
1179 REAL(8), DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1180 WRITE (*,*) ASINH(x)
1184 @item @emph{See also}:
1185 Inverse function: @ref{SINH}
1191 @section @code{ASSOCIATED} --- Status of a pointer or pointer/target pair
1192 @cindex @code{ASSOCIATED} intrinsic
1193 @cindex pointer status
1196 @item @emph{Description}:
1197 @code{ASSOCIATED(PTR [, TGT])} determines the status of the pointer @var{PTR}
1198 or if @var{PTR} is associated with the target @var{TGT}.
1200 @item @emph{Standard}:
1206 @item @emph{Syntax}:
1207 @code{L = ASSOCIATED(PTR)}
1208 @code{L = ASSOCIATED(PTR [, TGT])}
1210 @item @emph{Arguments}:
1211 @multitable @columnfractions .15 .80
1212 @item @var{PTR} @tab @var{PTR} shall have the @code{POINTER} attribute and
1213 it can be of any type.
1214 @item @var{TGT} @tab (Optional) @var{TGT} shall be a @code{POINTER} or
1215 a @code{TARGET}. It must have the same type, kind type parameter, and
1216 array rank as @var{PTR}.
1218 The status of neither @var{PTR} nor @var{TGT} can be undefined.
1220 @item @emph{Return value}:
1221 @code{ASSOCIATED(PTR)} returns a scalar value of type @code{LOGICAL(4)}.
1222 There are several cases:
1224 @item (A) If the optional @var{TGT} is not present, then @code{ASSOCIATED(PTR)}
1225 is true if @var{PTR} is associated with a target; otherwise, it returns false.
1226 @item (B) If @var{TGT} is present and a scalar target, the result is true if
1228 is not a 0 sized storage sequence and the target associated with @var{PTR}
1229 occupies the same storage units. If @var{PTR} is disassociated, then the
1231 @item (C) If @var{TGT} is present and an array target, the result is true if
1232 @var{TGT} and @var{PTR} have the same shape, are not 0 sized arrays, are
1233 arrays whose elements are not 0 sized storage sequences, and @var{TGT} and
1234 @var{PTR} occupy the same storage units in array element order.
1235 As in case(B), the result is false, if @var{PTR} is disassociated.
1236 @item (D) If @var{TGT} is present and an scalar pointer, the result is true if
1237 target associated with @var{PTR} and the target associated with @var{TGT}
1238 are not 0 sized storage sequences and occupy the same storage units.
1239 The result is false, if either @var{TGT} or @var{PTR} is disassociated.
1240 @item (E) If @var{TGT} is present and an array pointer, the result is true if
1241 target associated with @var{PTR} and the target associated with @var{TGT}
1242 have the same shape, are not 0 sized arrays, are arrays whose elements are
1243 not 0 sized storage sequences, and @var{TGT} and @var{PTR} occupy the same
1244 storage units in array element order.
1245 The result is false, if either @var{TGT} or @var{PTR} is disassociated.
1248 @item @emph{Example}:
1250 program test_associated
1252 real, target :: tgt(2) = (/1., 2./)
1253 real, pointer :: ptr(:)
1255 if (associated(ptr) .eqv. .false.) call abort
1256 if (associated(ptr,tgt) .eqv. .false.) call abort
1257 end program test_associated
1260 @item @emph{See also}:
1267 @section @code{ATAN} --- Arctangent function
1268 @cindex @code{ATAN} intrinsic
1269 @cindex @code{DATAN} intrinsic
1270 @cindex trigonometric functions (inverse)
1273 @item @emph{Description}:
1274 @code{ATAN(X)} computes the arctangent of @var{X}.
1276 @item @emph{Standard}:
1282 @item @emph{Syntax}:
1285 @item @emph{Arguments}:
1286 @multitable @columnfractions .15 .80
1287 @item @var{X} @tab The type shall be @code{REAL(*)}.
1290 @item @emph{Return value}:
1291 The return value is of type @code{REAL(*)} and it lies in the
1292 range @math{ - \pi / 2 \leq \atan (x) \leq \pi / 2}.
1294 @item @emph{Example}:
1297 real(8) :: x = 2.866_8
1299 end program test_atan
1302 @item @emph{Specific names}:
1303 @multitable @columnfractions .20 .20 .20 .40
1304 @item Name @tab Argument @tab Return type @tab Standard
1305 @item @code{DATAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1308 @item @emph{See also}:
1309 Inverse function: @ref{TAN}
1316 @section @code{ATAN2} --- Arctangent function
1317 @cindex @code{ATAN2} intrinsic
1318 @cindex @code{DATAN2} intrinsic
1319 @cindex trigonometric functions (inverse)
1322 @item @emph{Description}:
1323 @code{ATAN2(Y,X)} computes the arctangent of the complex number @math{X + i Y}.
1325 @item @emph{Standard}:
1331 @item @emph{Syntax}:
1332 @code{X = ATAN2(Y,X)}
1334 @item @emph{Arguments}:
1335 @multitable @columnfractions .15 .80
1336 @item @var{Y} @tab The type shall be @code{REAL(*)}.
1337 @item @var{X} @tab The type and kind type parameter shall be the same as @var{Y}.
1338 If @var{Y} is zero, then @var{X} must be nonzero.
1341 @item @emph{Return value}:
1342 The return value has the same type and kind type parameter as @var{Y}.
1343 It is the principal value of the complex number @math{X + i Y}. If
1344 @var{X} is nonzero, then it lies in the range @math{-\pi \le \atan (x) \leq \pi}.
1345 The sign is positive if @var{Y} is positive. If @var{Y} is zero, then
1346 the return value is zero if @var{X} is positive and @math{\pi} if @var{X}
1347 is negative. Finally, if @var{X} is zero, then the magnitude of the result
1350 @item @emph{Example}:
1353 real(4) :: x = 1.e0_4, y = 0.5e0_4
1355 end program test_atan2
1358 @item @emph{Specific names}:
1359 @multitable @columnfractions .20 .20 .20 .40
1360 @item Name @tab Argument @tab Return type @tab Standard
1361 @item @code{DATAN2(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1368 @section @code{ATANH} --- Hyperbolic arctangent function
1369 @cindex @code{ASINH} intrinsic
1370 @cindex hyperbolic arctangent
1371 @cindex hyperbolic tangent (inverse)
1374 @item @emph{Description}:
1375 @code{ATANH(X)} computes the area hyperbolic sine of @var{X} (inverse of @code{TANH(X)}).
1377 @item @emph{Standard}:
1383 @item @emph{Syntax}:
1386 @item @emph{Arguments}:
1387 @multitable @columnfractions .15 .80
1388 @item @var{X} @tab The type shall be @code{REAL(*)} with a magnitude
1389 that is less than or equal to one.
1392 @item @emph{Return value}:
1393 The return value is of type @code{REAL(*)} and it lies in the
1394 range @math{-\infty \leq \atanh(x) \leq \infty}.
1396 @item @emph{Example}:
1399 REAL, DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1400 WRITE (*,*) ATANH(x)
1404 @item @emph{See also}:
1405 Inverse function: @ref{TANH}
1412 @section @code{BESJ0} --- Bessel function of the first kind of order 0
1413 @cindex @code{BESJ0} intrinsic
1414 @cindex @code{DBESJ0} intrinsic
1418 @item @emph{Description}:
1419 @code{BESJ0(X)} computes the Bessel function of the first kind of order 0
1422 @item @emph{Standard}:
1428 @item @emph{Syntax}:
1431 @item @emph{Arguments}:
1432 @multitable @columnfractions .15 .80
1433 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1436 @item @emph{Return value}:
1437 The return value is of type @code{REAL(*)} and it lies in the
1438 range @math{ - 0.4027... \leq Bessel (0,x) \leq 1}.
1440 @item @emph{Example}:
1443 real(8) :: x = 0.0_8
1445 end program test_besj0
1448 @item @emph{Specific names}:
1449 @multitable @columnfractions .20 .20 .20 .40
1450 @item Name @tab Argument @tab Return type @tab Standard
1451 @item @code{DBESJ0(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1458 @section @code{BESJ1} --- Bessel function of the first kind of order 1
1459 @cindex @code{BESJ1} intrinsic
1460 @cindex @code{DBESJ1} intrinsic
1464 @item @emph{Description}:
1465 @code{BESJ1(X)} computes the Bessel function of the first kind of order 1
1468 @item @emph{Standard}:
1474 @item @emph{Syntax}:
1477 @item @emph{Arguments}:
1478 @multitable @columnfractions .15 .80
1479 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1482 @item @emph{Return value}:
1483 The return value is of type @code{REAL(*)} and it lies in the
1484 range @math{ - 0.5818... \leq Bessel (0,x) \leq 0.5818 }.
1486 @item @emph{Example}:
1489 real(8) :: x = 1.0_8
1491 end program test_besj1
1494 @item @emph{Specific names}:
1495 @multitable @columnfractions .20 .20 .20 .40
1496 @item Name @tab Argument @tab Return type @tab Standard
1497 @item @code{DBESJ1(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1504 @section @code{BESJN} --- Bessel function of the first kind
1505 @cindex @code{BESJN} intrinsic
1506 @cindex @code{DBESJN} intrinsic
1510 @item @emph{Description}:
1511 @code{BESJN(N, X)} computes the Bessel function of the first kind of order
1514 @item @emph{Standard}:
1520 @item @emph{Syntax}:
1521 @code{Y = BESJN(N, X)}
1523 @item @emph{Arguments}:
1524 @multitable @columnfractions .15 .80
1525 @item @var{N} @tab The type shall be @code{INTEGER(*)}, and it shall be scalar.
1526 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1529 @item @emph{Return value}:
1530 The return value is a scalar of type @code{REAL(*)}.
1532 @item @emph{Example}:
1535 real(8) :: x = 1.0_8
1537 end program test_besjn
1540 @item @emph{Specific names}:
1541 @multitable @columnfractions .20 .20 .20 .40
1542 @item Name @tab Argument @tab Return type @tab Standard
1543 @item @code{DBESJN(X)} @tab @code{INTEGER(*) N} @tab @code{REAL(8)} @tab GNU extension
1544 @item @tab @code{REAL(8) X} @tab @tab
1551 @section @code{BESY0} --- Bessel function of the second kind of order 0
1552 @cindex @code{BESY0} intrinsic
1553 @cindex @code{DBESY0} intrinsic
1557 @item @emph{Description}:
1558 @code{BESY0(X)} computes the Bessel function of the second kind of order 0
1561 @item @emph{Standard}:
1567 @item @emph{Syntax}:
1570 @item @emph{Arguments}:
1571 @multitable @columnfractions .15 .80
1572 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1575 @item @emph{Return value}:
1576 The return value is a scalar of type @code{REAL(*)}.
1578 @item @emph{Example}:
1581 real(8) :: x = 0.0_8
1583 end program test_besy0
1586 @item @emph{Specific names}:
1587 @multitable @columnfractions .20 .20 .20 .40
1588 @item Name @tab Argument @tab Return type @tab Standard
1589 @item @code{DBESY0(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1596 @section @code{BESY1} --- Bessel function of the second kind of order 1
1597 @cindex @code{BESY1} intrinsic
1598 @cindex @code{DBESY1} intrinsic
1602 @item @emph{Description}:
1603 @code{BESY1(X)} computes the Bessel function of the second kind of order 1
1606 @item @emph{Standard}:
1612 @item @emph{Syntax}:
1615 @item @emph{Arguments}:
1616 @multitable @columnfractions .15 .80
1617 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1620 @item @emph{Return value}:
1621 The return value is a scalar of type @code{REAL(*)}.
1623 @item @emph{Example}:
1626 real(8) :: x = 1.0_8
1628 end program test_besy1
1631 @item @emph{Specific names}:
1632 @multitable @columnfractions .20 .20 .20 .40
1633 @item Name @tab Argument @tab Return type @tab Standard
1634 @item @code{DBESY1(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1641 @section @code{BESYN} --- Bessel function of the second kind
1642 @cindex @code{BESYN} intrinsic
1643 @cindex @code{DBESYN} intrinsic
1647 @item @emph{Description}:
1648 @code{BESYN(N, X)} computes the Bessel function of the second kind of order
1651 @item @emph{Standard}:
1657 @item @emph{Syntax}:
1658 @code{Y = BESYN(N, X)}
1660 @item @emph{Arguments}:
1661 @multitable @columnfractions .15 .80
1662 @item @var{N} @tab The type shall be @code{INTEGER(*)}, and it shall be scalar.
1663 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1666 @item @emph{Return value}:
1667 The return value is a scalar of type @code{REAL(*)}.
1669 @item @emph{Example}:
1672 real(8) :: x = 1.0_8
1674 end program test_besyn
1677 @item @emph{Specific names}:
1678 @multitable @columnfractions .20 .20 .20 .40
1679 @item Name @tab Argument @tab Return type @tab Standard
1680 @item @code{DBESYN(N,X)} @tab @code{INTEGER(*) N} @tab @code{REAL(8)} @tab GNU extension
1681 @item @tab @code{REAL(8) X} @tab @tab
1688 @section @code{BIT_SIZE} --- Bit size inquiry function
1689 @cindex @code{BIT_SIZE} intrinsic
1690 @cindex bit size of a variable
1691 @cindex size of a variable, in bits
1694 @item @emph{Description}:
1695 @code{BIT_SIZE(I)} returns the number of bits (integer precision plus sign bit)
1696 represented by the type of @var{I}.
1698 @item @emph{Standard}:
1704 @item @emph{Syntax}:
1705 @code{I = BIT_SIZE(I)}
1707 @item @emph{Arguments}:
1708 @multitable @columnfractions .15 .80
1709 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1712 @item @emph{Return value}:
1713 The return value is of type @code{INTEGER(*)}
1715 @item @emph{Example}:
1717 program test_bit_size
1722 end program test_bit_size
1729 @section @code{BTEST} --- Bit test function
1730 @cindex @code{BTEST} intrinsic
1731 @cindex bit operations
1734 @item @emph{Description}:
1735 @code{BTEST(I,POS)} returns logical @code{.TRUE.} if the bit at @var{POS}
1738 @item @emph{Standard}:
1744 @item @emph{Syntax}:
1745 @code{I = BTEST(I,POS)}
1747 @item @emph{Arguments}:
1748 @multitable @columnfractions .15 .80
1749 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1750 @item @var{POS} @tab The type shall be @code{INTEGER(*)}.
1753 @item @emph{Return value}:
1754 The return value is of type @code{LOGICAL}
1756 @item @emph{Example}:
1759 integer :: i = 32768 + 1024 + 64
1763 bool = btest(i, pos)
1766 end program test_btest
1773 @section @code{CEILING} --- Integer ceiling function
1774 @cindex @code{CEILING} intrinsic
1778 @item @emph{Description}:
1779 @code{CEILING(X)} returns the least integer greater than or equal to @var{X}.
1781 @item @emph{Standard}:
1787 @item @emph{Syntax}:
1788 @code{I = CEILING(X[,KIND])}
1790 @item @emph{Arguments}:
1791 @multitable @columnfractions .15 .80
1792 @item @var{X} @tab The type shall be @code{REAL(*)}.
1793 @item @var{KIND} @tab (Optional) scalar integer initialization expression.
1796 @item @emph{Return value}:
1797 The return value is of type @code{INTEGER(KIND)}
1799 @item @emph{Example}:
1801 program test_ceiling
1804 print *, ceiling(x) ! returns 64
1805 print *, ceiling(y) ! returns -63
1806 end program test_ceiling
1809 @item @emph{See also}:
1810 @ref{FLOOR}, @ref{NINT}
1817 @section @code{CHAR} --- Character conversion function
1818 @cindex @code{CHAR} intrinsic
1819 @cindex conversion function (character)
1822 @item @emph{Description}:
1823 @code{CHAR(I,[KIND])} returns the character represented by the integer @var{I}.
1825 @item @emph{Standard}:
1831 @item @emph{Syntax}:
1832 @code{C = CHAR(I[,KIND])}
1834 @item @emph{Arguments}:
1835 @multitable @columnfractions .15 .80
1836 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1837 @item @var{KIND} @tab Optional scaler integer initialization expression.
1840 @item @emph{Return value}:
1841 The return value is of type @code{CHARACTER(1)}
1843 @item @emph{Example}:
1849 print *, i, c ! returns 'J'
1850 end program test_char
1853 @item @emph{See also}:
1854 @ref{ACHAR}, @ref{ICHAR}, @ref{IACHAR}
1860 @section @code{CHDIR} --- Change working directory
1861 @cindex @code{CHDIR} intrinsic
1862 @cindex file system operations
1865 @item @emph{Description}:
1866 Change current working directory to a specified @var{PATH}.
1868 @item @emph{Standard}:
1872 Non-elemental subroutine
1874 @item @emph{Syntax}:
1875 @code{CALL chdir(PATH[,STATUS])}
1877 @item @emph{Arguments}:
1878 @multitable @columnfractions .15 .80
1879 @item @var{PATH} @tab The type shall be @code{CHARACTER(*)} and shall
1880 specify a valid path within the file system.
1881 @item @var{STATUS} @tab (Optional) status flag. Returns 0 on success,
1882 a system specific and non-zero error code otherwise.
1885 @item @emph{Example}:
1888 CHARACTER(len=255) :: path
1890 WRITE(*,*) TRIM(path)
1893 WRITE(*,*) TRIM(path)
1897 @item @emph{See also}:
1904 @section @code{CHMOD} --- Change access permissions of files
1905 @cindex @code{CHMOD} intrinsic
1906 @cindex file system operations
1909 @item @emph{Description}:
1910 @code{CHMOD} changes the permissions of a file. This function invokes
1911 @code{/bin/chmod} and might therefore not work on all platforms.
1913 This intrinsic is provided in both subroutine and function forms; however,
1914 only one form can be used in any given program unit.
1916 @item @emph{Standard}:
1920 Subroutine, non-elemental function
1922 @item @emph{Syntax}:
1923 @multitable @columnfractions .80
1924 @item @code{CALL CHMOD(NAME, MODE[, STATUS])}
1925 @item @code{STATUS = CHMOD(NAME, MODE)}
1928 @item @emph{Arguments}:
1929 @multitable @columnfractions .15 .80
1930 @item @var{NAME} @tab Scalar @code{CHARACTER} with the file name.
1931 Trailing blanks are ignored unless the character @code{achar(0)} is
1932 present, then all characters up to and excluding @code{achar(0)} are
1933 used as the file name.
1935 @item @var{MODE} @tab Scalar @code{CHARACTER} giving the file permission.
1936 @var{MODE} uses the same syntax as the @var{MODE} argument of
1939 @item @var{STATUS} @tab (optional) scalar @code{INTEGER}, which is
1940 @code{0} on success and non-zero otherwise.
1943 @item @emph{Return value}:
1944 In either syntax, @var{STATUS} is set to @code{0} on success and non-zero
1947 @item @emph{Example}:
1948 @code{CHMOD} as subroutine
1953 call chmod('test.dat','u+x',status)
1954 print *, 'Status: ', status
1955 end program chmod_test
1957 @code{CHMOD} as non-elemental function:
1962 status = chmod('test.dat','u+x')
1963 print *, 'Status: ', status
1964 end program chmod_test
1966 @item @emph{Specific names}:
1967 @item @emph{See also}:
1973 @section @code{CMPLX} --- Complex conversion function
1974 @cindex @code{CMPLX} intrinsic
1975 @cindex complex numbers, conversion to
1978 @item @emph{Description}:
1979 @code{CMPLX(X[,Y[,KIND]])} returns a complex number where @var{X} is converted to
1980 the real component. If @var{Y} is present it is converted to the imaginary
1981 component. If @var{Y} is not present then the imaginary component is set to
1982 0.0. If @var{X} is complex then @var{Y} must not be present.
1984 @item @emph{Standard}:
1990 @item @emph{Syntax}:
1991 @code{C = CMPLX(X[,Y[,KIND]])}
1993 @item @emph{Arguments}:
1994 @multitable @columnfractions .15 .80
1995 @item @var{X} @tab The type may be @code{INTEGER(*)}, @code{REAL(*)},
1996 or @code{COMPLEX(*)}.
1997 @item @var{Y} @tab Optional, allowed if @var{X} is not
1998 @code{COMPLEX(*)}. May be @code{INTEGER(*)}
2000 @item @var{KIND} @tab Optional scaler integer initialization expression.
2003 @item @emph{Return value}:
2004 The return value is of type @code{COMPLEX(*)}
2006 @item @emph{Example}:
2013 print *, z, cmplx(x)
2014 end program test_cmplx
2020 @node COMMAND_ARGUMENT_COUNT
2021 @section @code{COMMAND_ARGUMENT_COUNT} --- Get number of command line arguments
2022 @cindex @code{COMMAND_ARGUMENT_COUNT} intrinsic
2023 @cindex command-line arguments, to program
2026 @item @emph{Description}:
2027 @code{COMMAND_ARGUMENT_COUNT()} returns the number of arguments passed on the
2028 command line when the containing program was invoked.
2030 @item @emph{Standard}:
2036 @item @emph{Syntax}:
2037 @code{I = COMMAND_ARGUMENT_COUNT()}
2039 @item @emph{Arguments}:
2040 @multitable @columnfractions .15 .80
2044 @item @emph{Return value}:
2045 The return value is of type @code{INTEGER(4)}
2047 @item @emph{Example}:
2049 program test_command_argument_count
2051 count = command_argument_count()
2053 end program test_command_argument_count
2056 @item @emph{See also}:
2057 @ref{GET_COMMAND}, @ref{GET_COMMAND_ARGUMENT}
2061 @section @code{CONJG} --- Complex conjugate function
2062 @cindex @code{CONJG} intrinsic
2063 @cindex @code{DCONJG} intrinsic
2064 @cindex complex conjugate
2066 @item @emph{Description}:
2067 @code{CONJG(Z)} returns the conjugate of @var{Z}. If @var{Z} is @code{(x, y)}
2068 then the result is @code{(x, -y)}
2070 @item @emph{Standard}:
2071 F77 and later, has overloads that are GNU extensions
2076 @item @emph{Syntax}:
2079 @item @emph{Arguments}:
2080 @multitable @columnfractions .15 .80
2081 @item @var{Z} @tab The type shall be @code{COMPLEX(*)}.
2084 @item @emph{Return value}:
2085 The return value is of type @code{COMPLEX(*)}.
2087 @item @emph{Example}:
2090 complex :: z = (2.0, 3.0)
2091 complex(8) :: dz = (2.71_8, -3.14_8)
2096 end program test_conjg
2099 @item @emph{Specific names}:
2100 @multitable @columnfractions .20 .20 .20 .40
2101 @item Name @tab Argument @tab Return type @tab Standard
2102 @item @code{DCONJG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
2109 @section @code{COS} --- Cosine function
2110 @cindex @code{COS} intrinsic
2111 @cindex @code{DCOS} intrinsic
2112 @cindex @code{ZCOS} intrinsic
2113 @cindex @code{CDCOS} intrinsic
2114 @cindex trigonometric functions
2117 @item @emph{Description}:
2118 @code{COS(X)} computes the cosine of @var{X}.
2120 @item @emph{Standard}:
2121 F77 and later, has overloads that are GNU extensions
2126 @item @emph{Syntax}:
2129 @item @emph{Arguments}:
2130 @multitable @columnfractions .15 .80
2131 @item @var{X} @tab The type shall be @code{REAL(*)} or
2135 @item @emph{Return value}:
2136 The return value is of type @code{REAL(*)} and it lies in the
2137 range @math{ -1 \leq \cos (x) \leq 1}. The kind type
2138 parameter is the same as @var{X}.
2140 @item @emph{Example}:
2145 end program test_cos
2148 @item @emph{Specific names}:
2149 @multitable @columnfractions .20 .20 .20 .40
2150 @item Name @tab Argument @tab Return type @tab Standard
2151 @item @code{DCOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
2152 @item @code{CCOS(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab F77 and later
2153 @item @code{ZCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
2154 @item @code{CDCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
2157 @item @emph{See also}:
2158 Inverse function: @ref{ACOS}
2165 @section @code{COSH} --- Hyperbolic cosine function
2166 @cindex @code{COSH} intrinsic
2167 @cindex @code{DCOSH} intrinsic
2168 @cindex hyperbolic cosine
2171 @item @emph{Description}:
2172 @code{COSH(X)} computes the hyperbolic cosine of @var{X}.
2174 @item @emph{Standard}:
2180 @item @emph{Syntax}:
2183 @item @emph{Arguments}:
2184 @multitable @columnfractions .15 .80
2185 @item @var{X} @tab The type shall be @code{REAL(*)}.
2188 @item @emph{Return value}:
2189 The return value is of type @code{REAL(*)} and it is positive
2190 (@math{ \cosh (x) \geq 0 }.
2192 @item @emph{Example}:
2195 real(8) :: x = 1.0_8
2197 end program test_cosh
2200 @item @emph{Specific names}:
2201 @multitable @columnfractions .20 .20 .20 .40
2202 @item Name @tab Argument @tab Return type @tab Standard
2203 @item @code{DCOSH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
2206 @item @emph{See also}:
2207 Inverse function: @ref{ACOSH}
2214 @section @code{COUNT} --- Count function
2215 @cindex @code{COUNT} intrinsic
2219 @item @emph{Description}:
2220 @code{COUNT(MASK[,DIM])} counts the number of @code{.TRUE.} elements of
2221 @var{MASK} along the dimension of @var{DIM}. If @var{DIM} is omitted it is
2222 taken to be @code{1}. @var{DIM} is a scaler of type @code{INTEGER} in the
2223 range of @math{1 /leq DIM /leq n)} where @math{n} is the rank of @var{MASK}.
2225 @item @emph{Standard}:
2229 transformational function
2231 @item @emph{Syntax}:
2232 @code{I = COUNT(MASK[,DIM])}
2234 @item @emph{Arguments}:
2235 @multitable @columnfractions .15 .80
2236 @item @var{MASK} @tab The type shall be @code{LOGICAL}.
2237 @item @var{DIM} @tab The type shall be @code{INTEGER}.
2240 @item @emph{Return value}:
2241 The return value is of type @code{INTEGER} with rank equal to that of
2244 @item @emph{Example}:
2247 integer, dimension(2,3) :: a, b
2248 logical, dimension(2,3) :: mask
2249 a = reshape( (/ 1, 2, 3, 4, 5, 6 /), (/ 2, 3 /))
2250 b = reshape( (/ 0, 7, 3, 4, 5, 8 /), (/ 2, 3 /))
2251 print '(3i3)', a(1,:)
2252 print '(3i3)', a(2,:)
2254 print '(3i3)', b(1,:)
2255 print '(3i3)', b(2,:)
2258 print '(3l3)', mask(1,:)
2259 print '(3l3)', mask(2,:)
2261 print '(3i3)', count(mask)
2263 print '(3i3)', count(mask, 1)
2265 print '(3i3)', count(mask, 2)
2266 end program test_count
2273 @section @code{CPU_TIME} --- CPU elapsed time in seconds
2274 @cindex @code{CPU_TIME} intrinsic
2275 @cindex time, elapsed
2276 @cindex elapsed time
2279 @item @emph{Description}:
2280 Returns a @code{REAL} value representing the elapsed CPU time in seconds. This
2281 is useful for testing segments of code to determine execution time.
2283 @item @emph{Standard}:
2289 @item @emph{Syntax}:
2292 @item @emph{Arguments}:
2293 @multitable @columnfractions .15 .80
2294 @item @var{X} @tab The type shall be @code{REAL} with @code{INTENT(OUT)}.
2297 @item @emph{Return value}:
2300 @item @emph{Example}:
2302 program test_cpu_time
2303 real :: start, finish
2304 call cpu_time(start)
2305 ! put code to test here
2306 call cpu_time(finish)
2307 print '("Time = ",f6.3," seconds.")',finish-start
2308 end program test_cpu_time
2315 @section @code{CSHIFT} --- Circular shift function
2316 @cindex @code{CSHIFT} intrinsic
2317 @cindex bit operations
2320 @item @emph{Description}:
2321 @code{CSHIFT(ARRAY, SHIFT[,DIM])} performs a circular shift on elements of
2322 @var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is omitted it is
2323 taken to be @code{1}. @var{DIM} is a scaler of type @code{INTEGER} in the
2324 range of @math{1 /leq DIM /leq n)} where @math{n} is the rank of @var{ARRAY}.
2325 If the rank of @var{ARRAY} is one, then all elements of @var{ARRAY} are shifted
2326 by @var{SHIFT} places. If rank is greater than one, then all complete rank one
2327 sections of @var{ARRAY} along the given dimension are shifted. Elements
2328 shifted out one end of each rank one section are shifted back in the other end.
2330 @item @emph{Standard}:
2334 transformational function
2336 @item @emph{Syntax}:
2337 @code{A = CSHIFT(A, SHIFT[,DIM])}
2339 @item @emph{Arguments}:
2340 @multitable @columnfractions .15 .80
2341 @item @var{ARRAY} @tab May be any type, not scaler.
2342 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
2343 @item @var{DIM} @tab The type shall be @code{INTEGER}.
2346 @item @emph{Return value}:
2347 Returns an array of same type and rank as the @var{ARRAY} argument.
2349 @item @emph{Example}:
2352 integer, dimension(3,3) :: a
2353 a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
2354 print '(3i3)', a(1,:)
2355 print '(3i3)', a(2,:)
2356 print '(3i3)', a(3,:)
2357 a = cshift(a, SHIFT=(/1, 2, -1/), DIM=2)
2359 print '(3i3)', a(1,:)
2360 print '(3i3)', a(2,:)
2361 print '(3i3)', a(3,:)
2362 end program test_cshift
2368 @section @code{CTIME} --- Convert a time into a string
2369 @cindex @code{CTIME} intrinsic
2370 @cindex time, conversion function
2373 @item @emph{Description}:
2374 @code{CTIME(T,S)} converts @var{T}, a system time value, such as returned
2375 by @code{TIME8()}, to a string of the form @samp{Sat Aug 19 18:13:14
2376 1995}, and returns that string into @var{S}.
2378 If @code{CTIME} is invoked as a function, it can not be invoked as a
2379 subroutine, and vice versa.
2381 @var{T} is an @code{INTENT(IN)} @code{INTEGER(KIND=8)} variable.
2382 @var{S} is an @code{INTENT(OUT)} @code{CHARACTER} variable.
2384 @item @emph{Standard}:
2390 @item @emph{Syntax}:
2391 @multitable @columnfractions .80
2392 @item @code{CALL CTIME(T,S)}.
2393 @item @code{S = CTIME(T)}, (not recommended).
2396 @item @emph{Arguments}:
2397 @multitable @columnfractions .15 .80
2398 @item @var{S}@tab The type shall be of type @code{CHARACTER}.
2399 @item @var{T}@tab The type shall be of type @code{INTEGER(KIND=8)}.
2402 @item @emph{Return value}:
2403 The converted date and time as a string.
2405 @item @emph{Example}:
2409 character(len=30) :: date
2412 ! Do something, main part of the program
2415 print *, 'Program was started on ', date
2416 end program test_ctime
2421 @section @code{DATE_AND_TIME} --- Date and time subroutine
2422 @cindex @code{DATE_AND_TIME} intrinsic
2423 @cindex date, current
2424 @cindex current date
2425 @cindex time, current
2426 @cindex current time
2429 @item @emph{Description}:
2430 @code{DATE_AND_TIME(DATE, TIME, ZONE, VALUES)} gets the corresponding date and
2431 time information from the real-time system clock. @var{DATE} is
2432 @code{INTENT(OUT)} and has form ccyymmdd. @var{TIME} is @code{INTENT(OUT)} and
2433 has form hhmmss.sss. @var{ZONE} is @code{INTENT(OUT)} and has form (+-)hhmm,
2434 representing the difference with respect to Coordinated Universal Time (UTC).
2435 Unavailable time and date parameters return blanks.
2437 @var{VALUES} is @code{INTENT(OUT)} and provides the following:
2439 @multitable @columnfractions .15 .30 .60
2440 @item @tab @code{VALUE(1)}: @tab The year
2441 @item @tab @code{VALUE(2)}: @tab The month
2442 @item @tab @code{VALUE(3)}: @tab The day of the month
2443 @item @tab @code{VALUE(4)}: @tab Time difference with UTC in minutes
2444 @item @tab @code{VALUE(5)}: @tab The hour of the day
2445 @item @tab @code{VALUE(6)}: @tab The minutes of the hour
2446 @item @tab @code{VALUE(7)}: @tab The seconds of the minute
2447 @item @tab @code{VALUE(8)}: @tab The milliseconds of the second
2450 @item @emph{Standard}:
2456 @item @emph{Syntax}:
2457 @code{CALL DATE_AND_TIME([DATE, TIME, ZONE, VALUES])}
2459 @item @emph{Arguments}:
2460 @multitable @columnfractions .15 .80
2461 @item @var{DATE} @tab (Optional) The type shall be @code{CHARACTER(8)} or larger.
2462 @item @var{TIME} @tab (Optional) The type shall be @code{CHARACTER(10)} or larger.
2463 @item @var{ZONE} @tab (Optional) The type shall be @code{CHARACTER(5)} or larger.
2464 @item @var{VALUES}@tab (Optional) The type shall be @code{INTEGER(8)}.
2467 @item @emph{Return value}:
2470 @item @emph{Example}:
2472 program test_time_and_date
2473 character(8) :: date
2474 character(10) :: time
2475 character(5) :: zone
2476 integer,dimension(8) :: values
2477 ! using keyword arguments
2478 call date_and_time(date,time,zone,values)
2479 call date_and_time(DATE=date,ZONE=zone)
2480 call date_and_time(TIME=time)
2481 call date_and_time(VALUES=values)
2482 print '(a,2x,a,2x,a)', date, time, zone
2483 print '(8i5))', values
2484 end program test_time_and_date
2491 @section @code{DBLE} --- Double conversion function
2492 @cindex @code{DBLE} intrinsic
2493 @cindex double conversion
2496 @item @emph{Description}:
2497 @code{DBLE(X)} Converts @var{X} to double precision real type.
2499 @item @emph{Standard}:
2505 @item @emph{Syntax}:
2508 @item @emph{Arguments}:
2509 @multitable @columnfractions .15 .80
2510 @item @var{X} @tab The type shall be @code{INTEGER(*)}, @code{REAL(*)},
2511 or @code{COMPLEX(*)}.
2514 @item @emph{Return value}:
2515 The return value is of type double precision real.
2517 @item @emph{Example}:
2522 complex :: z = (2.3,1.14)
2523 print *, dble(x), dble(i), dble(z)
2524 end program test_dble
2527 @item @emph{See also}:
2528 @ref{DFLOAT}, @ref{FLOAT}, @ref{REAL}
2534 @section @code{DCMPLX} --- Double complex conversion function
2535 @cindex @code{DCMPLX} intrinsic
2536 @cindex complex numbers, conversion to
2539 @item @emph{Description}:
2540 @code{DCMPLX(X [,Y])} returns a double complex number where @var{X} is
2541 converted to the real component. If @var{Y} is present it is converted to the
2542 imaginary component. If @var{Y} is not present then the imaginary component is
2543 set to 0.0. If @var{X} is complex then @var{Y} must not be present.
2545 @item @emph{Standard}:
2551 @item @emph{Syntax}:
2552 @code{C = DCMPLX(X)}
2553 @code{C = DCMPLX(X,Y)}
2555 @item @emph{Arguments}:
2556 @multitable @columnfractions .15 .80
2557 @item @var{X} @tab The type may be @code{INTEGER(*)}, @code{REAL(*)},
2558 or @code{COMPLEX(*)}.
2559 @item @var{Y} @tab Optional if @var{X} is not @code{COMPLEX(*)}. May be
2560 @code{INTEGER(*)} or @code{REAL(*)}.
2563 @item @emph{Return value}:
2564 The return value is of type @code{COMPLEX(8)}
2566 @item @emph{Example}:
2576 print *, dcmplx(x,i)
2577 end program test_dcmplx
2584 @section @code{DFLOAT} --- Double conversion function
2585 @cindex @code{DFLOAT} intrinsic
2586 @cindex double float conversion
2589 @item @emph{Description}:
2590 @code{DFLOAT(X)} Converts @var{X} to double precision real type.
2592 @item @emph{Standard}:
2598 @item @emph{Syntax}:
2599 @code{X = DFLOAT(X)}
2601 @item @emph{Arguments}:
2602 @multitable @columnfractions .15 .80
2603 @item @var{X} @tab The type shall be @code{INTEGER(*)}.
2606 @item @emph{Return value}:
2607 The return value is of type double precision real.
2609 @item @emph{Example}:
2614 end program test_dfloat
2617 @item @emph{See also}:
2618 @ref{DBLE}, @ref{FLOAT}, @ref{REAL}
2624 @section @code{DIGITS} --- Significant digits function
2625 @cindex @code{DIGITS} intrinsic
2626 @cindex digits, significant
2629 @item @emph{Description}:
2630 @code{DIGITS(X)} returns the number of significant digits of the internal model
2631 representation of @var{X}. For example, on a system using a 32-bit
2632 floating point representation, a default real number would likely return 24.
2634 @item @emph{Standard}:
2640 @item @emph{Syntax}:
2641 @code{C = DIGITS(X)}
2643 @item @emph{Arguments}:
2644 @multitable @columnfractions .15 .80
2645 @item @var{X} @tab The type may be @code{INTEGER(*)} or @code{REAL(*)}.
2648 @item @emph{Return value}:
2649 The return value is of type @code{INTEGER}.
2651 @item @emph{Example}:
2654 integer :: i = 12345
2660 end program test_digits
2667 @section @code{DIM} --- Dim function
2668 @cindex @code{DIM} intrinsic
2669 @cindex @code{IDIM} intrinsic
2670 @cindex @code{DDIM} intrinsic
2674 @item @emph{Description}:
2675 @code{DIM(X,Y)} returns the difference @code{X-Y} if the result is positive;
2676 otherwise returns zero.
2678 @item @emph{Standard}:
2684 @item @emph{Syntax}:
2687 @item @emph{Arguments}:
2688 @multitable @columnfractions .15 .80
2689 @item @var{X} @tab The type shall be @code{INTEGER(*)} or @code{REAL(*)}
2690 @item @var{Y} @tab The type shall be the same type and kind as @var{X}.
2693 @item @emph{Return value}:
2694 The return value is of type @code{INTEGER(*)} or @code{REAL(*)}.
2696 @item @emph{Example}:
2702 x = dim(4.345_8, 2.111_8)
2705 end program test_dim
2708 @item @emph{Specific names}:
2709 @multitable @columnfractions .20 .20 .20 .40
2710 @item Name @tab Argument @tab Return type @tab Standard
2711 @item @code{IDIM(X,Y)} @tab @code{INTEGER(4) X,Y} @tab @code{INTEGER(4)} @tab F77 and later
2712 @item @code{DDIM(X,Y)} @tab @code{REAL(8) X,Y} @tab @code{REAL(8)} @tab F77 and later
2719 @section @code{DOT_PRODUCT} --- Dot product function
2720 @cindex @code{DOT_PRODUCT} intrinsic
2724 @item @emph{Description}:
2725 @code{DOT_PRODUCT(X,Y)} computes the dot product multiplication of two vectors
2726 @var{X} and @var{Y}. The two vectors may be either numeric or logical
2727 and must be arrays of rank one and of equal size. If the vectors are
2728 @code{INTEGER(*)} or @code{REAL(*)}, the result is @code{SUM(X*Y)}. If the
2729 vectors are @code{COMPLEX(*)}, the result is @code{SUM(CONJG(X)*Y)}. If the
2730 vectors are @code{LOGICAL}, the result is @code{ANY(X.AND.Y)}.
2732 @item @emph{Standard}:
2736 transformational function
2738 @item @emph{Syntax}:
2739 @code{S = DOT_PRODUCT(X,Y)}
2741 @item @emph{Arguments}:
2742 @multitable @columnfractions .15 .80
2743 @item @var{X} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
2744 @item @var{Y} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
2747 @item @emph{Return value}:
2748 If the arguments are numeric, the return value is a scaler of numeric type,
2749 @code{INTEGER(*)}, @code{REAL(*)}, or @code{COMPLEX(*)}. If the arguments are
2750 @code{LOGICAL}, the return value is @code{.TRUE.} or @code{.FALSE.}.
2752 @item @emph{Example}:
2754 program test_dot_prod
2755 integer, dimension(3) :: a, b
2762 print *, dot_product(a,b)
2763 end program test_dot_prod
2770 @section @code{DPROD} --- Double product function
2771 @cindex @code{DPROD} intrinsic
2772 @cindex double-precision product
2775 @item @emph{Description}:
2776 @code{DPROD(X,Y)} returns the product @code{X*Y}.
2778 @item @emph{Standard}:
2784 @item @emph{Syntax}:
2785 @code{D = DPROD(X,Y)}
2787 @item @emph{Arguments}:
2788 @multitable @columnfractions .15 .80
2789 @item @var{X} @tab The type shall be @code{REAL}.
2790 @item @var{Y} @tab The type shall be @code{REAL}.
2793 @item @emph{Return value}:
2794 The return value is of type @code{REAL(8)}.
2796 @item @emph{Example}:
2805 end program test_dprod
2812 @section @code{DREAL} --- Double real part function
2813 @cindex @code{DREAL} intrinsic
2814 @cindex double-precision real part
2817 @item @emph{Description}:
2818 @code{DREAL(Z)} returns the real part of complex variable @var{Z}.
2820 @item @emph{Standard}:
2826 @item @emph{Syntax}:
2829 @item @emph{Arguments}:
2830 @multitable @columnfractions .15 .80
2831 @item @var{Z} @tab The type shall be @code{COMPLEX(8)}.
2834 @item @emph{Return value}:
2835 The return value is of type @code{REAL(8)}.
2837 @item @emph{Example}:
2840 complex(8) :: z = (1.3_8,7.2_8)
2842 end program test_dreal
2845 @item @emph{See also}:
2853 @section @code{DTIME} --- Execution time subroutine (or function)
2854 @cindex @code{DTIME} intrinsic
2855 @cindex time, elapsed
2856 @cindex elapsed time
2859 @item @emph{Description}:
2860 @code{DTIME(TARRAY, RESULT)} initially returns the number of seconds of runtime
2861 since the start of the process's execution in @var{RESULT}. @var{TARRAY}
2862 returns the user and system components of this time in @code{TARRAY(1)} and
2863 @code{TARRAY(2)} respectively. @var{RESULT} is equal to @code{TARRAY(1) +
2866 Subsequent invocations of @code{DTIME} return values accumulated since the
2867 previous invocation.
2869 On some systems, the underlying timings are represented using types with
2870 sufficiently small limits that overflows (wrap around) are possible, such as
2871 32-bit types. Therefore, the values returned by this intrinsic might be, or
2872 become, negative, or numerically less than previous values, during a single
2873 run of the compiled program.
2875 If @code{DTIME} is invoked as a function, it can not be invoked as a
2876 subroutine, and vice versa.
2878 @var{TARRAY} and @var{RESULT} are @code{INTENT(OUT)} and provide the following:
2880 @multitable @columnfractions .15 .30 .60
2881 @item @tab @code{TARRAY(1)}: @tab User time in seconds.
2882 @item @tab @code{TARRAY(2)}: @tab System time in seconds.
2883 @item @tab @code{RESULT}: @tab Run time since start in seconds.
2886 @item @emph{Standard}:
2892 @item @emph{Syntax}:
2893 @multitable @columnfractions .80
2894 @item @code{CALL DTIME(TARRAY, RESULT)}.
2895 @item @code{RESULT = DTIME(TARRAY)}, (not recommended).
2898 @item @emph{Arguments}:
2899 @multitable @columnfractions .15 .80
2900 @item @var{TARRAY}@tab The type shall be @code{REAL, DIMENSION(2)}.
2901 @item @var{RESULT}@tab The type shall be @code{REAL}.
2904 @item @emph{Return value}:
2905 Elapsed time in seconds since the start of program execution.
2907 @item @emph{Example}:
2911 real, dimension(2) :: tarray
2913 call dtime(tarray, result)
2917 do i=1,100000000 ! Just a delay
2920 call dtime(tarray, result)
2924 end program test_dtime
2931 @section @code{EOSHIFT} --- End-off shift function
2932 @cindex @code{EOSHIFT} intrinsic
2933 @cindex bit operations
2936 @item @emph{Description}:
2937 @code{EOSHIFT(ARRAY, SHIFT[,BOUNDARY, DIM])} performs an end-off shift on
2938 elements of @var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is
2939 omitted it is taken to be @code{1}. @var{DIM} is a scaler of type
2940 @code{INTEGER} in the range of @math{1 /leq DIM /leq n)} where @math{n} is the
2941 rank of @var{ARRAY}. If the rank of @var{ARRAY} is one, then all elements of
2942 @var{ARRAY} are shifted by @var{SHIFT} places. If rank is greater than one,
2943 then all complete rank one sections of @var{ARRAY} along the given dimension are
2944 shifted. Elements shifted out one end of each rank one section are dropped. If
2945 @var{BOUNDARY} is present then the corresponding value of from @var{BOUNDARY}
2946 is copied back in the other end. If @var{BOUNDARY} is not present then the
2947 following are copied in depending on the type of @var{ARRAY}.
2949 @multitable @columnfractions .15 .80
2950 @item @emph{Array Type} @tab @emph{Boundary Value}
2951 @item Numeric @tab 0 of the type and kind of @var{ARRAY}.
2952 @item Logical @tab @code{.FALSE.}.
2953 @item Character(@var{len}) @tab @var{len} blanks.
2956 @item @emph{Standard}:
2960 transformational function
2962 @item @emph{Syntax}:
2963 @code{A = EOSHIFT(A, SHIFT[,BOUNDARY, DIM])}
2965 @item @emph{Arguments}:
2966 @multitable @columnfractions .15 .80
2967 @item @var{ARRAY} @tab May be any type, not scaler.
2968 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
2969 @item @var{BOUNDARY} @tab Same type as @var{ARRAY}.
2970 @item @var{DIM} @tab The type shall be @code{INTEGER}.
2973 @item @emph{Return value}:
2974 Returns an array of same type and rank as the @var{ARRAY} argument.
2976 @item @emph{Example}:
2978 program test_eoshift
2979 integer, dimension(3,3) :: a
2980 a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
2981 print '(3i3)', a(1,:)
2982 print '(3i3)', a(2,:)
2983 print '(3i3)', a(3,:)
2984 a = EOSHIFT(a, SHIFT=(/1, 2, 1/), BOUNDARY=-5, DIM=2)
2986 print '(3i3)', a(1,:)
2987 print '(3i3)', a(2,:)
2988 print '(3i3)', a(3,:)
2989 end program test_eoshift
2996 @section @code{EPSILON} --- Epsilon function
2997 @cindex @code{EPSILON} intrinsic
2998 @cindex epsilon, significant
3001 @item @emph{Description}:
3002 @code{EPSILON(X)} returns a nearly negligible number relative to @code{1}.
3004 @item @emph{Standard}:
3010 @item @emph{Syntax}:
3011 @code{C = EPSILON(X)}
3013 @item @emph{Arguments}:
3014 @multitable @columnfractions .15 .80
3015 @item @var{X} @tab The type shall be @code{REAL(*)}.
3018 @item @emph{Return value}:
3019 The return value is of same type as the argument.
3021 @item @emph{Example}:
3023 program test_epsilon
3028 end program test_epsilon
3035 @section @code{ERF} --- Error function
3036 @cindex @code{ERF} intrinsic
3037 @cindex error function
3040 @item @emph{Description}:
3041 @code{ERF(X)} computes the error function of @var{X}.
3043 @item @emph{Standard}:
3049 @item @emph{Syntax}:
3052 @item @emph{Arguments}:
3053 @multitable @columnfractions .15 .80
3054 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
3057 @item @emph{Return value}:
3058 The return value is a scalar of type @code{REAL(*)} and it is positive
3059 (@math{ - 1 \leq erf (x) \leq 1 }.
3061 @item @emph{Example}:
3064 real(8) :: x = 0.17_8
3066 end program test_erf
3069 @item @emph{Specific names}:
3070 @multitable @columnfractions .20 .20 .20 .40
3071 @item Name @tab Argument @tab Return type @tab Standard
3072 @item @code{DERF(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
3079 @section @code{ERFC} --- Error function
3080 @cindex @code{ERFC} intrinsic
3081 @cindex error function
3084 @item @emph{Description}:
3085 @code{ERFC(X)} computes the complementary error function of @var{X}.
3087 @item @emph{Standard}:
3093 @item @emph{Syntax}:
3096 @item @emph{Arguments}:
3097 @multitable @columnfractions .15 .80
3098 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
3101 @item @emph{Return value}:
3102 The return value is a scalar of type @code{REAL(*)} and it is positive
3103 (@math{ 0 \leq erfc (x) \leq 2 }.
3105 @item @emph{Example}:
3108 real(8) :: x = 0.17_8
3110 end program test_erfc
3113 @item @emph{Specific names}:
3114 @multitable @columnfractions .20 .20 .20 .40
3115 @item Name @tab Argument @tab Return type @tab Standard
3116 @item @code{DERFC(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
3123 @section @code{ETIME} --- Execution time subroutine (or function)
3124 @cindex @code{ETIME} intrinsic
3125 @cindex time, elapsed
3128 @item @emph{Description}:
3129 @code{ETIME(TARRAY, RESULT)} returns the number of seconds of runtime
3130 since the start of the process's execution in @var{RESULT}. @var{TARRAY}
3131 returns the user and system components of this time in @code{TARRAY(1)} and
3132 @code{TARRAY(2)} respectively. @var{RESULT} is equal to @code{TARRAY(1) + TARRAY(2)}.
3134 On some systems, the underlying timings are represented using types with
3135 sufficiently small limits that overflows (wrap around) are possible, such as
3136 32-bit types. Therefore, the values returned by this intrinsic might be, or
3137 become, negative, or numerically less than previous values, during a single
3138 run of the compiled program.
3140 If @code{ETIME} is invoked as a function, it can not be invoked as a
3141 subroutine, and vice versa.
3143 @var{TARRAY} and @var{RESULT} are @code{INTENT(OUT)} and provide the following:
3145 @multitable @columnfractions .15 .30 .60
3146 @item @tab @code{TARRAY(1)}: @tab User time in seconds.
3147 @item @tab @code{TARRAY(2)}: @tab System time in seconds.
3148 @item @tab @code{RESULT}: @tab Run time since start in seconds.
3151 @item @emph{Standard}:
3157 @item @emph{Syntax}:
3158 @multitable @columnfractions .8
3159 @item @code{CALL ETIME(TARRAY, RESULT)}.
3160 @item @code{RESULT = ETIME(TARRAY)}, (not recommended).
3163 @item @emph{Arguments}:
3164 @multitable @columnfractions .15 .80
3165 @item @var{TARRAY}@tab The type shall be @code{REAL, DIMENSION(2)}.
3166 @item @var{RESULT}@tab The type shall be @code{REAL}.
3169 @item @emph{Return value}:
3170 Elapsed time in seconds since the start of program execution.
3172 @item @emph{Example}:
3176 real, dimension(2) :: tarray
3178 call ETIME(tarray, result)
3182 do i=1,100000000 ! Just a delay
3185 call ETIME(tarray, result)
3189 end program test_etime
3192 @item @emph{See also}:
3200 @section @code{EXIT} --- Exit the program with status.
3201 @cindex @code{EXIT} intrinsic
3202 @cindex exit program
3205 @item @emph{Description}:
3206 @code{EXIT} causes immediate termination of the program with status. If status
3207 is omitted it returns the canonical @emph{success} for the system. All Fortran
3208 I/O units are closed.
3210 @item @emph{Standard}:
3216 @item @emph{Syntax}:
3217 @code{CALL EXIT([STATUS])}
3219 @item @emph{Arguments}:
3220 @multitable @columnfractions .15 .80
3221 @item @var{STATUS} @tab The type of the argument shall be @code{INTEGER(*)}.
3224 @item @emph{Return value}:
3225 @code{STATUS} is passed to the parent process on exit.
3227 @item @emph{Example}:
3230 integer :: STATUS = 0
3231 print *, 'This program is going to exit.'
3233 end program test_exit
3236 @item @emph{See also}:
3237 @ref{ABORT}, @ref{KILL}
3243 @section @code{EXP} --- Exponential function
3244 @cindex @code{EXP} intrinsic
3245 @cindex @code{DEXP} intrinsic
3246 @cindex @code{ZEXP} intrinsic
3247 @cindex @code{CDEXP} intrinsic
3251 @item @emph{Description}:
3252 @code{EXP(X)} computes the base @math{e} exponential of @var{X}.
3254 @item @emph{Standard}:
3255 F77 and later, has overloads that are GNU extensions
3260 @item @emph{Syntax}:
3263 @item @emph{Arguments}:
3264 @multitable @columnfractions .15 .80
3265 @item @var{X} @tab The type shall be @code{REAL(*)} or
3269 @item @emph{Return value}:
3270 The return value has same type and kind as @var{X}.
3272 @item @emph{Example}:
3277 end program test_exp
3280 @item @emph{Specific names}:
3281 @multitable @columnfractions .20 .20 .20 .40
3282 @item Name @tab Argument @tab Return type @tab Standard
3283 @item @code{DEXP(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
3284 @item @code{CEXP(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab F77 and later
3285 @item @code{ZEXP(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
3286 @item @code{CDEXP(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
3293 @section @code{EXPONENT} --- Exponent function
3294 @cindex @code{EXPONENT} intrinsic
3295 @cindex exponent part of a real number
3298 @item @emph{Description}:
3299 @code{EXPONENT(X)} returns the value of the exponent part of @var{X}. If @var{X}
3300 is zero the value returned is zero.
3302 @item @emph{Standard}:
3308 @item @emph{Syntax}:
3309 @code{I = EXPONENT(X)}
3311 @item @emph{Arguments}:
3312 @multitable @columnfractions .15 .80
3313 @item @var{X} @tab The type shall be @code{REAL(*)}.
3316 @item @emph{Return value}:
3317 The return value is of type default @code{INTEGER}.
3319 @item @emph{Example}:
3321 program test_exponent
3326 print *, exponent(0.0)
3327 end program test_exponent
3333 @section @code{FDATE} --- Get the current time as a string
3334 @cindex @code{FDATE} intrinsic
3335 @cindex time, current
3336 @cindex current time
3337 @cindex date, current
3338 @cindex current date
3341 @item @emph{Description}:
3342 @code{FDATE(DATE)} returns the current date (using the same format as
3343 @code{CTIME}) in @var{DATE}. It is equivalent to @code{CALL CTIME(DATE,
3346 If @code{FDATE} is invoked as a function, it can not be invoked as a
3347 subroutine, and vice versa.
3349 @var{DATE} is an @code{INTENT(OUT)} @code{CHARACTER} variable.
3351 @item @emph{Standard}:
3357 @item @emph{Syntax}:
3358 @multitable @columnfractions .80
3359 @item @code{CALL FDATE(DATE)}.
3360 @item @code{DATE = FDATE()}, (not recommended).
3363 @item @emph{Arguments}:
3364 @multitable @columnfractions .15 .80
3365 @item @var{DATE}@tab The type shall be of type @code{CHARACTER}.
3368 @item @emph{Return value}:
3369 The current date as a string.
3371 @item @emph{Example}:
3375 character(len=30) :: date
3377 print *, 'Program started on ', date
3378 do i = 1, 100000000 ! Just a delay
3382 print *, 'Program ended on ', date
3383 end program test_fdate
3389 @section @code{FLOAT} --- Convert integer to default real
3390 @cindex @code{FLOAT} intrinsic
3391 @cindex conversion function (float)
3394 @item @emph{Description}:
3395 @code{FLOAT(I)} converts the integer @var{I} to a default real value.
3397 @item @emph{Standard}:
3403 @item @emph{Syntax}:
3406 @item @emph{Arguments}:
3407 @multitable @columnfractions .15 .80
3408 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
3411 @item @emph{Return value}:
3412 The return value is of type default @code{REAL}
3414 @item @emph{Example}:
3418 if (float(i) /= 1.) call abort
3419 end program test_float
3422 @item @emph{See also}:
3423 @ref{DBLE}, @ref{DFLOAT}, @ref{REAL}
3429 @section @code{FGET} --- Read a single character in stream mode from stdin
3430 @cindex @code{FGET} intrinsic
3431 @cindex file operations
3432 @cindex stream operations
3435 @item @emph{Description}:
3436 Read a single character in stream mode from stdin by bypassing normal
3437 formatted output. Stream I/O should not be mixed with normal record-oriented
3438 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
3440 This intrinsic routine is provided for backwards compatibility with
3441 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
3442 Programmers should consider the use of new stream IO feature in new code
3443 for future portability. See also @ref{Fortran 2003 status}.
3445 @item @emph{Standard}:
3449 Non-elemental subroutine
3451 @item @emph{Syntax}:
3452 @code{CALL FGET(C[,STATUS])}
3454 @item @emph{Arguments}:
3455 @multitable @columnfractions .15 .80
3456 @item @var{C} @tab The type shall be @code{CHARACTER}.
3457 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. Returns 0 on success,
3458 -1 on end-of-file and a system specific positive error code otherwise.
3461 @item @emph{Example}:
3464 INTEGER, PARAMETER :: strlen = 100
3465 INTEGER :: status, i = 1
3466 CHARACTER(len=strlen) :: str = ""
3468 WRITE (*,*) 'Enter text:'
3470 CALL fget(str(i:i), status)
3471 if (status /= 0 .OR. i > strlen) exit
3474 WRITE (*,*) TRIM(str)
3478 @item @emph{See also}:
3479 @ref{FGETC}, @ref{FPUT}, @ref{FPUTC}
3484 @section @code{FGETC} --- Read a single character in stream mode
3485 @cindex @code{FGETC} intrinsic
3486 @cindex file operations
3487 @cindex stream operations
3490 @item @emph{Description}:
3491 Read a single character in stream mode by bypassing normal formatted output.
3492 Stream I/O should not be mixed with normal record-oriented (formatted or
3493 unformatted) I/O on the same unit; the results are unpredictable.
3495 This intrinsic routine is provided for backwards compatibility with
3496 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
3497 Programmers should consider the use of new stream IO feature in new code
3498 for future portability. See also @ref{Fortran 2003 status}.
3500 @item @emph{Standard}:
3504 Non-elemental subroutine
3506 @item @emph{Syntax}:
3507 @code{CALL FGETC(UNIT,C[,STATUS])}
3509 @item @emph{Arguments}:
3510 @multitable @columnfractions .15 .80
3511 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
3512 @item @var{C} @tab The type shall be @code{CHARACTER}.
3513 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. Returns 0 on success,
3514 -1 on end-of-file and a system specific positive error code otherwise.
3517 @item @emph{Example}:
3520 INTEGER :: fd = 42, status
3523 OPEN(UNIT=fd, FILE="/etc/passwd", ACTION="READ", STATUS = "OLD")
3525 CALL fgetc(fd, c, status)
3526 IF (status /= 0) EXIT
3533 @item @emph{See also}:
3534 @ref{FGET}, @ref{FPUT}, @ref{FPUTC}
3540 @section @code{FLOOR} --- Integer floor function
3541 @cindex @code{FLOOR} intrinsic
3545 @item @emph{Description}:
3546 @code{FLOOR(X)} returns the greatest integer less than or equal to @var{X}.
3548 @item @emph{Standard}:
3554 @item @emph{Syntax}:
3555 @code{I = FLOOR(X[,KIND])}
3557 @item @emph{Arguments}:
3558 @multitable @columnfractions .15 .80
3559 @item @var{X} @tab The type shall be @code{REAL(*)}.
3560 @item @var{KIND} @tab Optional scaler integer initialization expression.
3563 @item @emph{Return value}:
3564 The return value is of type @code{INTEGER(KIND)}
3566 @item @emph{Example}:
3571 print *, floor(x) ! returns 63
3572 print *, floor(y) ! returns -64
3573 end program test_floor
3576 @item @emph{See also}:
3577 @ref{CEILING}, @ref{NINT}
3584 @section @code{FLUSH} --- Flush I/O unit(s)
3585 @cindex @code{FLUSH} intrinsic
3586 @cindex flush output files
3589 @item @emph{Description}:
3590 Flushes Fortran unit(s) currently open for output. Without the optional
3591 argument, all units are flushed, otherwise just the unit specified.
3593 @item @emph{Standard}:
3597 non-elemental subroutine
3599 @item @emph{Syntax}:
3600 @code{CALL FLUSH(UNIT)}
3602 @item @emph{Arguments}:
3603 @multitable @columnfractions .15 .80
3604 @item @var{UNIT} @tab (Optional) The type shall be @code{INTEGER}.
3608 Beginning with the Fortran 2003 standard, there is a @code{FLUSH}
3609 statement that should be preferred over the @code{FLUSH} intrinsic.
3616 @section @code{FNUM} --- File number function
3617 @cindex @code{FNUM} intrinsic
3621 @item @emph{Description}:
3622 @code{FNUM(UNIT)} returns the POSIX file descriptor number corresponding to the
3623 open Fortran I/O unit @code{UNIT}.
3625 @item @emph{Standard}:
3629 non-elemental function
3631 @item @emph{Syntax}:
3632 @code{I = FNUM(UNIT)}
3634 @item @emph{Arguments}:
3635 @multitable @columnfractions .15 .80
3636 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
3639 @item @emph{Return value}:
3640 The return value is of type @code{INTEGER}
3642 @item @emph{Example}:
3646 open (unit=10, status = "scratch")
3650 end program test_fnum
3657 @section @code{FPUT} --- Write a single character in stream mode to stdout
3658 @cindex @code{FPUT} intrinsic
3659 @cindex file operations
3660 @cindex stream operations
3663 @item @emph{Description}:
3664 Write a single character in stream mode to stdout by bypassing normal
3665 formatted output. Stream I/O should not be mixed with normal record-oriented
3666 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
3668 This intrinsic routine is provided for backwards compatibility with
3669 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
3670 Programmers should consider the use of new stream IO feature in new code
3671 for future portability. See also @ref{Fortran 2003 status}.
3673 @item @emph{Standard}:
3677 Non-elemental subroutine
3679 @item @emph{Syntax}:
3680 @code{CALL FPUT(C[,STATUS])}
3682 @item @emph{Arguments}:
3683 @multitable @columnfractions .15 .80
3684 @item @var{C} @tab The type shall be @code{CHARACTER}.
3685 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. Returns 0 on success,
3686 -1 on end-of-file and a system specific positive error code otherwise.
3689 @item @emph{Example}:
3692 CHARACTER(len=*) :: str = "gfortran"
3694 DO i = 1, len_trim(str)
3700 @item @emph{See also}:
3701 @ref{FPUTC}, @ref{FGET}, @ref{FGETC}
3707 @section @code{FPUTC} --- Write a single character in stream mode
3708 @cindex @code{FPUTC} intrinsic
3709 @cindex file operations
3710 @cindex stream operations
3713 @item @emph{Description}:
3714 Write a single character in stream mode by bypassing normal formatted
3715 output. Stream I/O should not be mixed with normal record-oriented
3716 (formatted or unformatted) I/O on the same unit; the results are unpredictable.
3718 This intrinsic routine is provided for backwards compatibility with
3719 @command{g77}. GNU Fortran provides the Fortran 2003 Stream facility.
3720 Programmers should consider the use of new stream IO feature in new code
3721 for future portability. See also @ref{Fortran 2003 status}.
3723 @item @emph{Standard}:
3727 Non-elemental subroutine
3729 @item @emph{Syntax}:
3730 @code{CALL FPUTC(UNIT,C[,STATUS])}
3732 @item @emph{Arguments}:
3733 @multitable @columnfractions .15 .80
3734 @item @var{UNIT} @tab The type shall be @code{INTEGER}.
3735 @item @var{C} @tab The type shall be @code{CHARACTER}.
3736 @item @var{STATUS} @tab (Optional) status flag of type @code{INTEGER}. Returns 0 on success,