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
42 * Introduction: Introduction to Intrinsics
43 * @code{ABORT}: ABORT, Abort the program
44 * @code{ABS}: ABS, Absolute value
45 * @code{ACCESS}: ACCESS, Checks file access modes
46 * @code{ACHAR}: ACHAR, Character in @acronym{ASCII} collating sequence
47 * @code{ACOS}: ACOS, Arccosine function
48 * @code{ACOSH}: ACOSH, Hyperbolic arccosine function
49 * @code{ADJUSTL}: ADJUSTL, Left adjust a string
50 * @code{ADJUSTR}: ADJUSTR, Right adjust a string
51 * @code{AIMAG}: AIMAG, Imaginary part of complex number
52 * @code{AINT}: AINT, Truncate to a whole number
53 * @code{ALARM}: ALARM, Set an alarm clock
54 * @code{ALL}: ALL, Determine if all values are true
55 * @code{ALLOCATED}: ALLOCATED, Status of allocatable entity
56 * @code{AND}: AND, Bitwise logical AND
57 * @code{ANINT}: ANINT, Nearest whole number
58 * @code{ANY}: ANY, Determine if any values are true
59 * @code{ASIN}: ASIN, Arcsine function
60 * @code{ASINH}: ASINH, Hyperbolic arcsine function
61 * @code{ASSOCIATED}: ASSOCIATED, Status of a pointer or pointer/target pair
62 * @code{ATAN}: ATAN, Arctangent function
63 * @code{ATAN2}: ATAN2, Arctangent function
64 * @code{ATANH}: ATANH, Hyperbolic arctangent function
65 * @code{BESJ0}: BESJ0, Bessel function of the first kind of order 0
66 * @code{BESJ1}: BESJ1, Bessel function of the first kind of order 1
67 * @code{BESJN}: BESJN, Bessel function of the first kind
68 * @code{BESY0}: BESY0, Bessel function of the second kind of order 0
69 * @code{BESY1}: BESY1, Bessel function of the second kind of order 1
70 * @code{BESYN}: BESYN, Bessel function of the second kind
71 * @code{BIT_SIZE}: BIT_SIZE, Bit size inquiry function
72 * @code{BTEST}: BTEST, Bit test function
73 * @code{C_ASSOCIATED}: C_ASSOCIATED, Status of a C pointer
74 * @code{C_F_POINTER}: C_F_POINTER, Convert C into Fortran pointer
75 * @code{C_F_PROCPOINTER}: C_F_PROCPOINTER, Convert C into Fortran procedure pointer
76 * @code{C_FUNLOC}: C_FUNLOC, Obtain the C address of a procedure
77 * @code{C_LOC}: C_LOC, Obtain the C address of an object
78 * @code{CEILING}: CEILING, Integer ceiling function
79 * @code{CHAR}: CHAR, Integer-to-character conversion function
80 * @code{CHDIR}: CHDIR, Change working directory
81 * @code{CHMOD}: CHMOD, Change access permissions of files
82 * @code{CMPLX}: CMPLX, Complex conversion function
83 * @code{COMMAND_ARGUMENT_COUNT}: COMMAND_ARGUMENT_COUNT, Get number of command line arguments
84 * @code{COMPLEX}: COMPLEX, Complex conversion function
85 * @code{CONJG}: CONJG, Complex conjugate function
86 * @code{COS}: COS, Cosine function
87 * @code{COSH}: COSH, Hyperbolic cosine function
88 * @code{COUNT}: COUNT, Count occurrences of TRUE in an array
89 * @code{CPU_TIME}: CPU_TIME, CPU time subroutine
90 * @code{CSHIFT}: CSHIFT, Circular shift elements of an array
91 * @code{CTIME}: CTIME, Subroutine (or function) to convert a time into a string
92 * @code{DATE_AND_TIME}: DATE_AND_TIME, Date and time subroutine
93 * @code{DBLE}: DBLE, Double precision conversion function
94 * @code{DCMPLX}: DCMPLX, Double complex conversion function
95 * @code{DFLOAT}: DFLOAT, Double precision conversion function
96 * @code{DIGITS}: DIGITS, Significant digits function
97 * @code{DIM}: DIM, Positive difference
98 * @code{DOT_PRODUCT}: DOT_PRODUCT, Dot product function
99 * @code{DPROD}: DPROD, Double product function
100 * @code{DREAL}: DREAL, Double real part function
101 * @code{DTIME}: DTIME, Execution time subroutine (or function)
102 * @code{EOSHIFT}: EOSHIFT, End-off shift elements of an array
103 * @code{EPSILON}: EPSILON, Epsilon function
104 * @code{ERF}: ERF, Error function
105 * @code{ERFC}: ERFC, Complementary error function
106 * @code{ETIME}: ETIME, Execution time subroutine (or function)
107 * @code{EXIT}: EXIT, Exit the program with status.
108 * @code{EXP}: EXP, Exponential function
109 * @code{EXPONENT}: EXPONENT, Exponent function
110 * @code{FDATE}: FDATE, Subroutine (or function) to get the current time as a string
111 * @code{FGET}: FGET, Read a single character in stream mode from stdin
112 * @code{FGETC}: FGETC, Read a single character in stream mode
113 * @code{FLOAT}: FLOAT, Convert integer to default real
114 * @code{FLOOR}: FLOOR, Integer floor function
115 * @code{FLUSH}: FLUSH, Flush I/O unit(s)
116 * @code{FNUM}: FNUM, File number function
117 * @code{FPUT}: FPUT, Write a single character in stream mode to stdout
118 * @code{FPUTC}: FPUTC, Write a single character in stream mode
119 * @code{FRACTION}: FRACTION, Fractional part of the model representation
120 * @code{FREE}: FREE, Memory de-allocation subroutine
121 * @code{FSEEK}: FSEEK, Low level file positioning subroutine
122 * @code{FSTAT}: FSTAT, Get file status
123 * @code{FTELL}: FTELL, Current stream position
124 * @code{GAMMA}: GAMMA, Gamma function
125 * @code{GERROR}: GERROR, Get last system error message
126 * @code{GETARG}: GETARG, Get command line arguments
127 * @code{GET_COMMAND}: GET_COMMAND, Get the entire command line
128 * @code{GET_COMMAND_ARGUMENT}: GET_COMMAND_ARGUMENT, Get command line arguments
129 * @code{GETCWD}: GETCWD, Get current working directory
130 * @code{GETENV}: GETENV, Get an environmental variable
131 * @code{GET_ENVIRONMENT_VARIABLE}: GET_ENVIRONMENT_VARIABLE, Get an environmental variable
132 * @code{GETGID}: GETGID, Group ID function
133 * @code{GETLOG}: GETLOG, Get login name
134 * @code{GETPID}: GETPID, Process ID function
135 * @code{GETUID}: GETUID, User ID function
136 * @code{GMTIME}: GMTIME, Convert time to GMT info
137 * @code{HOSTNM}: HOSTNM, Get system host name
138 * @code{HUGE}: HUGE, Largest number of a kind
139 * @code{IACHAR}: IACHAR, Code in @acronym{ASCII} collating sequence
140 * @code{IAND}: IAND, Bitwise logical and
141 * @code{IARGC}: IARGC, Get the number of command line arguments
142 * @code{IBCLR}: IBCLR, Clear bit
143 * @code{IBITS}: IBITS, Bit extraction
144 * @code{IBSET}: IBSET, Set bit
145 * @code{ICHAR}: ICHAR, Character-to-integer conversion function
146 * @code{IDATE}: IDATE, Current local time (day/month/year)
147 * @code{IEOR}: IEOR, Bitwise logical exclusive or
148 * @code{IERRNO}: IERRNO, Function to get the last system error number
149 * @code{INDEX}: INDEX, Position of a substring within a string
150 * @code{INT}: INT, Convert to integer type
151 * @code{INT2}: INT2, Convert to 16-bit integer type
152 * @code{INT8}: INT8, Convert to 64-bit integer type
153 * @code{IOR}: IOR, Bitwise logical or
154 * @code{IRAND}: IRAND, Integer pseudo-random number
155 * @code{IS_IOSTAT_END}: IS_IOSTAT_END, Test for end-of-file value
156 * @code{IS_IOSTAT_EOR}: IS_IOSTAT_EOR, Test for end-of-record value
157 * @code{ISATTY}: ISATTY, Whether a unit is a terminal device
158 * @code{ISHFT}: ISHFT, Shift bits
159 * @code{ISHFTC}: ISHFTC, Shift bits circularly
160 * @code{ISNAN}: ISNAN, Tests for a NaN
161 * @code{ITIME}: ITIME, Current local time (hour/minutes/seconds)
162 * @code{KILL}: KILL, Send a signal to a process
163 * @code{KIND}: KIND, Kind of an entity
164 * @code{LBOUND}: LBOUND, Lower dimension bounds of an array
165 * @code{LEN}: LEN, Length of a character entity
166 * @code{LEN_TRIM}: LEN_TRIM, Length of a character entity without trailing blank characters
167 * @code{LGAMMA}: LGAMMA, Logarithm of the Gamma function
168 * @code{LGE}: LGE, Lexical greater than or equal
169 * @code{LGT}: LGT, Lexical greater than
170 * @code{LINK}: LINK, Create a hard link
171 * @code{LLE}: LLE, Lexical less than or equal
172 * @code{LLT}: LLT, Lexical less than
173 * @code{LNBLNK}: LNBLNK, Index of the last non-blank character in a string
174 * @code{LOC}: LOC, Returns the address of a variable
175 * @code{LOG}: LOG, Logarithm function
176 * @code{LOG10}: LOG10, Base 10 logarithm function
177 * @code{LOGICAL}: LOGICAL, Convert to logical type
178 * @code{LONG}: LONG, Convert to integer type
179 * @code{LSHIFT}: LSHIFT, Left shift bits
180 * @code{LSTAT}: LSTAT, Get file status
181 * @code{LTIME}: LTIME, Convert time to local time info
182 * @code{MALLOC}: MALLOC, Dynamic memory allocation function
183 * @code{MATMUL}: MATMUL, matrix multiplication
184 * @code{MAX}: MAX, Maximum value of an argument list
185 * @code{MAXEXPONENT}: MAXEXPONENT, Maximum exponent of a real kind
186 * @code{MAXLOC}: MAXLOC, Location of the maximum value within an array
187 * @code{MAXVAL}: MAXVAL, Maximum value of an array
188 * @code{MCLOCK}: MCLOCK, Time function
189 * @code{MCLOCK8}: MCLOCK8, Time function (64-bit)
190 * @code{MERGE}: MERGE, Merge arrays
191 * @code{MIN}: MIN, Minimum value of an argument list
192 * @code{MINEXPONENT}: MINEXPONENT, Minimum exponent of a real kind
193 * @code{MINLOC}: MINLOC, Location of the minimum value within an array
194 * @code{MINVAL}: MINVAL, Minimum value of an array
195 * @code{MOD}: MOD, Remainder function
196 * @code{MODULO}: MODULO, Modulo function
197 * @code{MOVE_ALLOC}: MOVE_ALLOC, Move allocation from one object to another
198 * @code{MVBITS}: MVBITS, Move bits from one integer to another
199 * @code{NEAREST}: NEAREST, Nearest representable number
200 * @code{NEW_LINE}: NEW_LINE, New line character
201 * @code{NINT}: NINT, Nearest whole number
202 * @code{NOT}: NOT, Logical negation
203 * @code{NULL}: NULL, Function that returns an disassociated pointer
204 * @code{OR}: OR, Bitwise logical OR
205 * @code{PACK}: PACK, Pack an array into an array of rank one
206 * @code{PERROR}: PERROR, Print system error message
207 * @code{PRECISION}: PRECISION, Decimal precision of a real kind
208 * @code{PRESENT}: PRESENT, Determine whether an optional dummy argument is specified
209 * @code{PRODUCT}: PRODUCT, Product of array elements
210 * @code{RADIX}: RADIX, Base of a data model
211 * @code{RANDOM_NUMBER}: RANDOM_NUMBER, Pseudo-random number
212 * @code{RANDOM_SEED}: RANDOM_SEED, Initialize a pseudo-random number sequence
213 * @code{RAND}: RAND, Real pseudo-random number
214 * @code{RANGE}: RANGE, Decimal exponent range of a real kind
215 * @code{RAN}: RAN, Real pseudo-random number
216 * @code{REAL}: REAL, Convert to real type
217 * @code{RENAME}: RENAME, Rename a file
218 * @code{REPEAT}: REPEAT, Repeated string concatenation
219 * @code{RESHAPE}: RESHAPE, Function to reshape an array
220 * @code{RRSPACING}: RRSPACING, Reciprocal of the relative spacing
221 * @code{RSHIFT}: RSHIFT, Right shift bits
222 * @code{SCALE}: SCALE, Scale a real value
223 * @code{SCAN}: SCAN, Scan a string for the presence of a set of characters
224 * @code{SECNDS}: SECNDS, Time function
225 * @code{SECOND}: SECOND, CPU time function
226 * @code{SELECTED_INT_KIND}: SELECTED_INT_KIND, Choose integer kind
227 * @code{SELECTED_REAL_KIND}: SELECTED_REAL_KIND, Choose real kind
228 * @code{SET_EXPONENT}: SET_EXPONENT, Set the exponent of the model
229 * @code{SHAPE}: SHAPE, Determine the shape of an array
230 * @code{SIGN}: SIGN, Sign copying function
231 * @code{SIGNAL}: SIGNAL, Signal handling subroutine (or function)
232 * @code{SIN}: SIN, Sine function
233 * @code{SINH}: SINH, Hyperbolic sine function
234 * @code{SIZE}: SIZE, Function to determine the size of an array
235 * @code{SIZEOF}: SIZEOF, Determine the size in bytes of an expression
236 * @code{SLEEP}: SLEEP, Sleep for the specified number of seconds
237 * @code{SNGL}: SNGL, Convert double precision real to default real
238 * @code{SPACING}: SPACING, Smallest distance between two numbers of a given type
239 * @code{SPREAD}: SPREAD, Add a dimension to an array
240 * @code{SQRT}: SQRT, Square-root function
241 * @code{SRAND}: SRAND, Reinitialize the random number generator
242 * @code{STAT}: STAT, Get file status
243 * @code{SUM}: SUM, Sum of array elements
244 * @code{SYMLNK}: SYMLNK, Create a symbolic link
245 * @code{SYSTEM}: SYSTEM, Execute a shell command
246 * @code{SYSTEM_CLOCK}: SYSTEM_CLOCK, Time function
247 * @code{TAN}: TAN, Tangent function
248 * @code{TANH}: TANH, Hyperbolic tangent function
249 * @code{TIME}: TIME, Time function
250 * @code{TIME8}: TIME8, Time function (64-bit)
251 * @code{TINY}: TINY, Smallest positive number of a real kind
252 * @code{TRANSFER}: TRANSFER, Transfer bit patterns
253 * @code{TRANSPOSE}: TRANSPOSE, Transpose an array of rank two
254 * @code{TRIM}: TRIM, Remove trailing blank characters of a string
255 * @code{TTYNAM}: TTYNAM, Get the name of a terminal device.
256 * @code{UBOUND}: UBOUND, Upper dimension bounds of an array
257 * @code{UMASK}: UMASK, Set the file creation mask
258 * @code{UNLINK}: UNLINK, Remove a file from the file system
259 * @code{UNPACK}: UNPACK, Unpack an array of rank one into an array
260 * @code{VERIFY}: VERIFY, Scan a string for the absence of a set of characters
261 * @code{XOR}: XOR, Bitwise logical exclusive or
264 @node Introduction to Intrinsics
265 @section Introduction to intrinsic procedures
267 The intrinsic procedures provided by GNU Fortran include all of the
268 intrinsic procedures required by the Fortran 95 standard, a set of
269 intrinsic procedures for backwards compatibility with G77, and a small
270 selection of intrinsic procedures from the Fortran 2003 standard. Any
271 conflict between a description here and a description in either the
272 Fortran 95 standard or the Fortran 2003 standard is unintentional, and
273 the standard(s) should be considered authoritative.
275 The enumeration of the @code{KIND} type parameter is processor defined in
276 the Fortran 95 standard. GNU Fortran defines the default integer type and
277 default real type by @code{INTEGER(KIND=4)} and @code{REAL(KIND=4)},
278 respectively. The standard mandates that both data types shall have
279 another kind, which have more precision. On typical target architectures
280 supported by @command{gfortran}, this kind type parameter is @code{KIND=8}.
281 Hence, @code{REAL(KIND=8)} and @code{DOUBLE PRECISION} are equivalent.
282 In the description of generic intrinsic procedures, the kind type parameter
283 will be specified by @code{KIND=*}, and in the description of specific
284 names for an intrinsic procedure the kind type parameter will be explicitly
285 given (e.g., @code{REAL(KIND=4)} or @code{REAL(KIND=8)}). Finally, for
286 brevity the optional @code{KIND=} syntax will be omitted.
288 Many of the intrinsic procedures take one or more optional arguments.
289 This document follows the convention used in the Fortran 95 standard,
290 and denotes such arguments by square brackets.
292 GNU Fortran offers the @option{-std=f95} and @option{-std=gnu} options,
293 which can be used to restrict the set of intrinsic procedures to a
294 given standard. By default, @command{gfortran} sets the @option{-std=gnu}
295 option, and so all intrinsic procedures described here are accepted. There
296 is one caveat. For a select group of intrinsic procedures, @command{g77}
297 implemented both a function and a subroutine. Both classes
298 have been implemented in @command{gfortran} for backwards compatibility
299 with @command{g77}. It is noted here that these functions and subroutines
300 cannot be intermixed in a given subprogram. In the descriptions that follow,
301 the applicable standard for each intrinsic procedure is noted.
306 @section @code{ABORT} --- Abort the program
308 @cindex program termination, with core dump
309 @cindex terminate program, with core dump
313 @item @emph{Description}:
314 @code{ABORT} causes immediate termination of the program. On operating
315 systems that support a core dump, @code{ABORT} will produce a core dump,
316 which is suitable for debugging purposes.
318 @item @emph{Standard}:
327 @item @emph{Return value}:
330 @item @emph{Example}:
333 integer :: i = 1, j = 2
334 if (i /= j) call abort
335 end program test_abort
338 @item @emph{See also}:
339 @ref{EXIT}, @ref{KILL}
346 @section @code{ABS} --- Absolute value
353 @cindex absolute value
356 @item @emph{Description}:
357 @code{ABS(X)} computes the absolute value of @code{X}.
359 @item @emph{Standard}:
360 F77 and later, has overloads that are GNU extensions
366 @code{RESULT = ABS(X)}
368 @item @emph{Arguments}:
369 @multitable @columnfractions .15 .70
370 @item @var{X} @tab The type of the argument shall be an @code{INTEGER(*)},
371 @code{REAL(*)}, or @code{COMPLEX(*)}.
374 @item @emph{Return value}:
375 The return value is of the same type and
376 kind as the argument except the return value is @code{REAL(*)} for a
377 @code{COMPLEX(*)} argument.
379 @item @emph{Example}:
384 complex :: z = (-1.e0,0.e0)
391 @item @emph{Specific names}:
392 @multitable @columnfractions .20 .20 .20 .25
393 @item Name @tab Argument @tab Return type @tab Standard
394 @item @code{CABS(Z)} @tab @code{COMPLEX(4) Z} @tab @code{REAL(4)} @tab F77 and later
395 @item @code{DABS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
396 @item @code{IABS(I)} @tab @code{INTEGER(4) I} @tab @code{INTEGER(4)} @tab F77 and later
397 @item @code{ZABS(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
398 @item @code{CDABS(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
405 @section @code{ACCESS} --- Checks file access modes
407 @cindex file system, access mode
410 @item @emph{Description}:
411 @code{ACCESS(NAME, MODE)} checks whether the file @var{NAME}
412 exists, is readable, writable or executable. Except for the
413 executable check, @code{ACCESS} can be replaced by
414 Fortran 95's @code{INQUIRE}.
416 @item @emph{Standard}:
423 @code{RESULT = ACCESS(NAME, MODE)}
425 @item @emph{Arguments}:
426 @multitable @columnfractions .15 .70
427 @item @var{NAME} @tab Scalar @code{CHARACTER} with the file name.
428 Tailing blank are ignored unless the character @code{achar(0)} is
429 present, then all characters up to and excluding @code{achar(0)} are
431 @item @var{MODE} @tab Scalar @code{CHARACTER} with the file access mode,
432 may be any concatenation of @code{"r"} (readable), @code{"w"} (writable)
433 and @code{"x"} (executable), or @code{" "} to check for existence.
436 @item @emph{Return value}:
437 Returns a scalar @code{INTEGER}, which is @code{0} if the file is
438 accessible in the given mode; otherwise or if an invalid argument
439 has been given for @code{MODE} the value @code{1} is returned.
441 @item @emph{Example}:
445 character(len=*), parameter :: file = 'test.dat'
446 character(len=*), parameter :: file2 = 'test.dat '//achar(0)
447 if(access(file,' ') == 0) print *, trim(file),' is exists'
448 if(access(file,'r') == 0) print *, trim(file),' is readable'
449 if(access(file,'w') == 0) print *, trim(file),' is writable'
450 if(access(file,'x') == 0) print *, trim(file),' is executable'
451 if(access(file2,'rwx') == 0) &
452 print *, trim(file2),' is readable, writable and executable'
453 end program access_test
455 @item @emph{Specific names}:
456 @item @emph{See also}:
463 @section @code{ACHAR} --- Character in @acronym{ASCII} collating sequence
465 @cindex @acronym{ASCII} collating sequence
466 @cindex collating sequence, @acronym{ASCII}
469 @item @emph{Description}:
470 @code{ACHAR(I)} returns the character located at position @code{I}
471 in the @acronym{ASCII} collating sequence.
473 @item @emph{Standard}:
480 @code{RESULT = ACHAR(I)}
482 @item @emph{Arguments}:
483 @multitable @columnfractions .15 .70
484 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
487 @item @emph{Return value}:
488 The return value is of type @code{CHARACTER} with a length of one. The
489 kind type parameter is the same as @code{KIND('A')}.
491 @item @emph{Example}:
496 end program test_achar
500 See @ref{ICHAR} for a discussion of converting between numerical values
501 and formatted string representations.
503 @item @emph{See also}:
504 @ref{CHAR}, @ref{IACHAR}, @ref{ICHAR}
511 @section @code{ACOS} --- Arccosine function
514 @cindex trigonometric function, cosine, inverse
515 @cindex cosine, inverse
518 @item @emph{Description}:
519 @code{ACOS(X)} computes the arccosine of @var{X} (inverse of @code{COS(X)}).
521 @item @emph{Standard}:
528 @code{RESULT = ACOS(X)}
530 @item @emph{Arguments}:
531 @multitable @columnfractions .15 .70
532 @item @var{X} @tab The type shall be @code{REAL(*)} with a magnitude that is
536 @item @emph{Return value}:
537 The return value is of type @code{REAL(*)} and it lies in the
538 range @math{ 0 \leq \acos(x) \leq \pi}. The kind type parameter
539 is the same as @var{X}.
541 @item @emph{Example}:
544 real(8) :: x = 0.866_8
546 end program test_acos
549 @item @emph{Specific names}:
550 @multitable @columnfractions .20 .20 .20 .25
551 @item Name @tab Argument @tab Return type @tab Standard
552 @item @code{DACOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
555 @item @emph{See also}:
556 Inverse function: @ref{COS}
563 @section @code{ACOSH} --- Hyperbolic arccosine function
566 @cindex area hyperbolic cosine
567 @cindex hyperbolic arccosine
568 @cindex hyperbolic function, cosine, inverse
569 @cindex cosine, hyperbolic, inverse
572 @item @emph{Description}:
573 @code{ACOSH(X)} computes the hyperbolic arccosine of @var{X} (inverse of
576 @item @emph{Standard}:
583 @code{RESULT = ACOSH(X)}
585 @item @emph{Arguments}:
586 @multitable @columnfractions .15 .70
587 @item @var{X} @tab The type shall be @code{REAL(*)} with a magnitude that is
588 greater or equal to one.
591 @item @emph{Return value}:
592 The return value is of type @code{REAL(*)} and it lies in the
593 range @math{0 \leq \acosh (x) \leq \infty}.
595 @item @emph{Example}:
598 REAL(8), DIMENSION(3) :: x = (/ 1.0, 2.0, 3.0 /)
603 @item @emph{Specific names}:
604 @multitable @columnfractions .20 .20 .20 .25
605 @item Name @tab Argument @tab Return type @tab Standard
606 @item @code{DACOSH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
609 @item @emph{See also}:
610 Inverse function: @ref{COSH}
616 @section @code{ADJUSTL} --- Left adjust a string
618 @cindex string, adjust left
619 @cindex adjust string
622 @item @emph{Description}:
623 @code{ADJUSTL(STR)} will left adjust a string by removing leading spaces.
624 Spaces are inserted at the end of the string as needed.
626 @item @emph{Standard}:
633 @code{RESULT = ADJUSTL(STR)}
635 @item @emph{Arguments}:
636 @multitable @columnfractions .15 .70
637 @item @var{STR} @tab The type shall be @code{CHARACTER}.
640 @item @emph{Return value}:
641 The return value is of type @code{CHARACTER} where leading spaces
642 are removed and the same number of spaces are inserted on the end
645 @item @emph{Example}:
648 character(len=20) :: str = ' gfortran'
651 end program test_adjustl
654 @item @emph{See also}:
655 @ref{ADJUSTR}, @ref{TRIM}
661 @section @code{ADJUSTR} --- Right adjust a string
663 @cindex string, adjust right
664 @cindex adjust string
667 @item @emph{Description}:
668 @code{ADJUSTR(STR)} will right adjust a string by removing trailing spaces.
669 Spaces are inserted at the start of the string as needed.
671 @item @emph{Standard}:
678 @code{RESULT = ADJUSTR(STR)}
680 @item @emph{Arguments}:
681 @multitable @columnfractions .15 .70
682 @item @var{STR} @tab The type shall be @code{CHARACTER}.
685 @item @emph{Return value}:
686 The return value is of type @code{CHARACTER} where trailing spaces
687 are removed and the same number of spaces are inserted at the start
690 @item @emph{Example}:
693 character(len=20) :: str = 'gfortran'
696 end program test_adjustr
699 @item @emph{See also}:
700 @ref{ADJUSTL}, @ref{TRIM}
706 @section @code{AIMAG} --- Imaginary part of complex number
711 @cindex complex numbers, imaginary part
714 @item @emph{Description}:
715 @code{AIMAG(Z)} yields the imaginary part of complex argument @code{Z}.
716 The @code{IMAG(Z)} and @code{IMAGPART(Z)} intrinsic functions are provided
717 for compatibility with @command{g77}, and their use in new code is
718 strongly discouraged.
720 @item @emph{Standard}:
721 F77 and later, has overloads that are GNU extensions
727 @code{RESULT = AIMAG(Z)}
729 @item @emph{Arguments}:
730 @multitable @columnfractions .15 .70
731 @item @var{Z} @tab The type of the argument shall be @code{COMPLEX(*)}.
734 @item @emph{Return value}:
735 The return value is of type real with the
736 kind type parameter of the argument.
738 @item @emph{Example}:
743 z4 = cmplx(1.e0_4, 0.e0_4)
744 z8 = cmplx(0.e0_8, 1.e0_8)
745 print *, aimag(z4), dimag(z8)
746 end program test_aimag
749 @item @emph{Specific names}:
750 @multitable @columnfractions .20 .20 .20 .25
751 @item Name @tab Argument @tab Return type @tab Standard
752 @item @code{DIMAG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{REAL(8)} @tab GNU extension
753 @item @code{IMAG(Z)} @tab @code{COMPLEX(*) Z} @tab @code{REAL(*)} @tab GNU extension
754 @item @code{IMAGPART(Z)} @tab @code{COMPLEX(*) Z} @tab @code{REAL(*)} @tab GNU extension
761 @section @code{AINT} --- Truncate to a whole number
765 @cindex rounding, floor
768 @item @emph{Description}:
769 @code{AINT(X [, KIND])} truncates its argument to a whole number.
771 @item @emph{Standard}:
778 @code{RESULT = AINT(X [, KIND])}
780 @item @emph{Arguments}:
781 @multitable @columnfractions .15 .70
782 @item @var{X} @tab The type of the argument shall be @code{REAL(*)}.
783 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
784 expression indicating the kind parameter of
788 @item @emph{Return value}:
789 The return value is of type real with the kind type parameter of the
790 argument if the optional @var{KIND} is absent; otherwise, the kind
791 type parameter will be given by @var{KIND}. If the magnitude of
792 @var{X} is less than one, then @code{AINT(X)} returns zero. If the
793 magnitude is equal to or greater than one, then it returns the largest
794 whole number that does not exceed its magnitude. The sign is the same
795 as the sign of @var{X}.
797 @item @emph{Example}:
804 print *, aint(x4), dint(x8)
806 end program test_aint
809 @item @emph{Specific names}:
810 @multitable @columnfractions .20 .20 .20 .25
811 @item Name @tab Argument @tab Return type @tab Standard
812 @item @code{DINT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
819 @section @code{ALARM} --- Execute a routine after a given delay
821 @cindex delayed execution
824 @item @emph{Description}:
825 @code{ALARM(SECONDS, HANDLER [, STATUS])} causes external subroutine @var{HANDLER}
826 to be executed after a delay of @var{SECONDS} by using @code{alarm(2)} to
827 set up a signal and @code{signal(2)} to catch it. If @var{STATUS} is
828 supplied, it will be returned with the number of seconds remaining until
829 any previously scheduled alarm was due to be delivered, or zero if there
830 was no previously scheduled alarm.
832 @item @emph{Standard}:
839 @code{CALL ALARM(SECONDS, HANDLER [, STATUS])}
841 @item @emph{Arguments}:
842 @multitable @columnfractions .15 .70
843 @item @var{SECONDS} @tab The type of the argument shall be a scalar
844 @code{INTEGER}. It is @code{INTENT(IN)}.
845 @item @var{HANDLER} @tab Signal handler (@code{INTEGER FUNCTION} or
846 @code{SUBROUTINE}) or dummy/global @code{INTEGER} scalar. The scalar
847 values may be either @code{SIG_IGN=1} to ignore the alarm generated
848 or @code{SIG_DFL=0} to set the default action. It is @code{INTENT(IN)}.
849 @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
850 variable of the default @code{INTEGER} kind. It is @code{INTENT(OUT)}.
853 @item @emph{Example}:
856 external handler_print
858 call alarm (3, handler_print, i)
861 end program test_alarm
863 This will cause the external routine @var{handler_print} to be called
870 @section @code{ALL} --- All values in @var{MASK} along @var{DIM} are true
872 @cindex array, apply condition
873 @cindex array, condition testing
876 @item @emph{Description}:
877 @code{ALL(MASK [, DIM])} determines if all the values are true in @var{MASK}
878 in the array along dimension @var{DIM}.
880 @item @emph{Standard}:
884 Transformational function
887 @code{RESULT = ALL(MASK [, DIM])}
889 @item @emph{Arguments}:
890 @multitable @columnfractions .15 .70
891 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL(*)} and
892 it shall not be scalar.
893 @item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer
894 with a value that lies between one and the rank of @var{MASK}.
897 @item @emph{Return value}:
898 @code{ALL(MASK)} returns a scalar value of type @code{LOGICAL(*)} where
899 the kind type parameter is the same as the kind type parameter of
900 @var{MASK}. If @var{DIM} is present, then @code{ALL(MASK, DIM)} returns
901 an array with the rank of @var{MASK} minus 1. The shape is determined from
902 the shape of @var{MASK} where the @var{DIM} dimension is elided.
906 @code{ALL(MASK)} is true if all elements of @var{MASK} are true.
907 It also is true if @var{MASK} has zero size; otherwise, it is false.
909 If the rank of @var{MASK} is one, then @code{ALL(MASK,DIM)} is equivalent
910 to @code{ALL(MASK)}. If the rank is greater than one, then @code{ALL(MASK,DIM)}
911 is determined by applying @code{ALL} to the array sections.
914 @item @emph{Example}:
918 l = all((/.true., .true., .true./))
923 integer a(2,3), b(2,3)
927 print *, all(a .eq. b, 1)
928 print *, all(a .eq. b, 2)
929 end subroutine section
937 @section @code{ALLOCATED} --- Status of an allocatable entity
939 @cindex allocation, status
942 @item @emph{Description}:
943 @code{ALLOCATED(X)} checks the status of whether @var{X} is allocated.
945 @item @emph{Standard}:
952 @code{RESULT = ALLOCATED(X)}
954 @item @emph{Arguments}:
955 @multitable @columnfractions .15 .70
956 @item @var{X} @tab The argument shall be an @code{ALLOCATABLE} array.
959 @item @emph{Return value}:
960 The return value is a scalar @code{LOGICAL} with the default logical
961 kind type parameter. If @var{X} is allocated, @code{ALLOCATED(X)}
962 is @code{.TRUE.}; otherwise, it returns @code{.FALSE.}
964 @item @emph{Example}:
966 program test_allocated
968 real(4), allocatable :: x(:)
969 if (allocated(x) .eqv. .false.) allocate(x(i))
970 end program test_allocated
977 @section @code{AND} --- Bitwise logical AND
979 @cindex bitwise logical and
980 @cindex logical and, bitwise
983 @item @emph{Description}:
984 Bitwise logical @code{AND}.
986 This intrinsic routine is provided for backwards compatibility with
987 GNU Fortran 77. For integer arguments, programmers should consider
988 the use of the @ref{IAND} intrinsic defined by the Fortran standard.
990 @item @emph{Standard}:
997 @code{RESULT = AND(I, J)}
999 @item @emph{Arguments}:
1000 @multitable @columnfractions .15 .70
1001 @item @var{I} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
1002 @item @var{J} @tab The type shall be either @code{INTEGER(*)} or @code{LOGICAL}.
1005 @item @emph{Return value}:
1006 The return type is either @code{INTEGER(*)} or @code{LOGICAL} after
1007 cross-promotion of the arguments.
1009 @item @emph{Example}:
1012 LOGICAL :: T = .TRUE., F = .FALSE.
1014 DATA a / Z'F' /, b / Z'3' /
1016 WRITE (*,*) AND(T, T), AND(T, F), AND(F, T), AND(F, F)
1017 WRITE (*,*) AND(a, b)
1021 @item @emph{See also}:
1022 F95 elemental function: @ref{IAND}
1028 @section @code{ANINT} --- Nearest whole number
1032 @cindex rounding, ceiling
1035 @item @emph{Description}:
1036 @code{ANINT(X [, KIND])} rounds its argument to the nearest whole number.
1038 @item @emph{Standard}:
1044 @item @emph{Syntax}:
1045 @code{RESULT = ANINT(X [, KIND])}
1047 @item @emph{Arguments}:
1048 @multitable @columnfractions .15 .70
1049 @item @var{X} @tab The type of the argument shall be @code{REAL(*)}.
1050 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
1051 expression indicating the kind parameter of
1055 @item @emph{Return value}:
1056 The return value is of type real with the kind type parameter of the
1057 argument if the optional @var{KIND} is absent; otherwise, the kind
1058 type parameter will be given by @var{KIND}. If @var{X} is greater than
1059 zero, then @code{ANINT(X)} returns @code{AINT(X+0.5)}. If @var{X} is
1060 less than or equal to zero, then it returns @code{AINT(X-0.5)}.
1062 @item @emph{Example}:
1069 print *, anint(x4), dnint(x8)
1071 end program test_anint
1074 @item @emph{Specific names}:
1075 @multitable @columnfractions .20 .20 .20 .25
1076 @item Name @tab Argument @tab Return type @tab Standard
1077 @item @code{DNINT(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1084 @section @code{ANY} --- Any value in @var{MASK} along @var{DIM} is true
1086 @cindex array, apply condition
1087 @cindex array, condition testing
1090 @item @emph{Description}:
1091 @code{ANY(MASK [, DIM])} determines if any of the values in the logical array
1092 @var{MASK} along dimension @var{DIM} are @code{.TRUE.}.
1094 @item @emph{Standard}:
1098 Transformational function
1100 @item @emph{Syntax}:
1101 @code{RESULT = ANY(MASK [, DIM])}
1103 @item @emph{Arguments}:
1104 @multitable @columnfractions .15 .70
1105 @item @var{MASK} @tab The type of the argument shall be @code{LOGICAL(*)} and
1106 it shall not be scalar.
1107 @item @var{DIM} @tab (Optional) @var{DIM} shall be a scalar integer
1108 with a value that lies between one and the rank of @var{MASK}.
1111 @item @emph{Return value}:
1112 @code{ANY(MASK)} returns a scalar value of type @code{LOGICAL(*)} where
1113 the kind type parameter is the same as the kind type parameter of
1114 @var{MASK}. If @var{DIM} is present, then @code{ANY(MASK, DIM)} returns
1115 an array with the rank of @var{MASK} minus 1. The shape is determined from
1116 the shape of @var{MASK} where the @var{DIM} dimension is elided.
1120 @code{ANY(MASK)} is true if any element of @var{MASK} is true;
1121 otherwise, it is false. It also is false if @var{MASK} has zero size.
1123 If the rank of @var{MASK} is one, then @code{ANY(MASK,DIM)} is equivalent
1124 to @code{ANY(MASK)}. If the rank is greater than one, then @code{ANY(MASK,DIM)}
1125 is determined by applying @code{ANY} to the array sections.
1128 @item @emph{Example}:
1132 l = any((/.true., .true., .true./))
1137 integer a(2,3), b(2,3)
1141 print *, any(a .eq. b, 1)
1142 print *, any(a .eq. b, 2)
1143 end subroutine section
1144 end program test_any
1151 @section @code{ASIN} --- Arcsine function
1154 @cindex trigonometric function, sine, inverse
1155 @cindex sine, inverse
1158 @item @emph{Description}:
1159 @code{ASIN(X)} computes the arcsine of its @var{X} (inverse of @code{SIN(X)}).
1161 @item @emph{Standard}:
1167 @item @emph{Syntax}:
1168 @code{RESULT = ASIN(X)}
1170 @item @emph{Arguments}:
1171 @multitable @columnfractions .15 .70
1172 @item @var{X} @tab The type shall be @code{REAL(*)}, and a magnitude that is
1176 @item @emph{Return value}:
1177 The return value is of type @code{REAL(*)} and it lies in the
1178 range @math{-\pi / 2 \leq \asin (x) \leq \pi / 2}. The kind type
1179 parameter is the same as @var{X}.
1181 @item @emph{Example}:
1184 real(8) :: x = 0.866_8
1186 end program test_asin
1189 @item @emph{Specific names}:
1190 @multitable @columnfractions .20 .20 .20 .25
1191 @item Name @tab Argument @tab Return type @tab Standard
1192 @item @code{DASIN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1195 @item @emph{See also}:
1196 Inverse function: @ref{SIN}
1203 @section @code{ASINH} --- Hyperbolic arcsine function
1206 @cindex area hyperbolic sine
1207 @cindex hyperbolic arcsine
1208 @cindex hyperbolic function, sine, inverse
1209 @cindex sine, hyperbolic, inverse
1212 @item @emph{Description}:
1213 @code{ASINH(X)} computes the hyperbolic arcsine of @var{X} (inverse of @code{SINH(X)}).
1215 @item @emph{Standard}:
1221 @item @emph{Syntax}:
1222 @code{RESULT = ASINH(X)}
1224 @item @emph{Arguments}:
1225 @multitable @columnfractions .15 .70
1226 @item @var{X} @tab The type shall be @code{REAL(*)}, with @var{X} a real number.
1229 @item @emph{Return value}:
1230 The return value is of type @code{REAL(*)} and it lies in the
1231 range @math{-\infty \leq \asinh (x) \leq \infty}.
1233 @item @emph{Example}:
1236 REAL(8), DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1237 WRITE (*,*) ASINH(x)
1241 @item @emph{Specific names}:
1242 @multitable @columnfractions .20 .20 .20 .25
1243 @item Name @tab Argument @tab Return type @tab Standard
1244 @item @code{DASINH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension.
1247 @item @emph{See also}:
1248 Inverse function: @ref{SINH}
1254 @section @code{ASSOCIATED} --- Status of a pointer or pointer/target pair
1256 @cindex pointer, status
1257 @cindex association status
1260 @item @emph{Description}:
1261 @code{ASSOCIATED(PTR [, TGT])} determines the status of the pointer @var{PTR}
1262 or if @var{PTR} is associated with the target @var{TGT}.
1264 @item @emph{Standard}:
1270 @item @emph{Syntax}:
1271 @code{RESULT = ASSOCIATED(PTR [, TGT])}
1273 @item @emph{Arguments}:
1274 @multitable @columnfractions .15 .70
1275 @item @var{PTR} @tab @var{PTR} shall have the @code{POINTER} attribute and
1276 it can be of any type.
1277 @item @var{TGT} @tab (Optional) @var{TGT} shall be a @code{POINTER} or
1278 a @code{TARGET}. It must have the same type, kind type parameter, and
1279 array rank as @var{PTR}.
1281 The status of neither @var{PTR} nor @var{TGT} can be undefined.
1283 @item @emph{Return value}:
1284 @code{ASSOCIATED(PTR)} returns a scalar value of type @code{LOGICAL(4)}.
1285 There are several cases:
1287 @item (A) If the optional @var{TGT} is not present, then @code{ASSOCIATED(PTR)}
1288 is true if @var{PTR} is associated with a target; otherwise, it returns false.
1289 @item (B) If @var{TGT} is present and a scalar target, the result is true if
1291 is not a 0 sized storage sequence and the target associated with @var{PTR}
1292 occupies the same storage units. If @var{PTR} is disassociated, then the
1294 @item (C) If @var{TGT} is present and an array target, the result is true if
1295 @var{TGT} and @var{PTR} have the same shape, are not 0 sized arrays, are
1296 arrays whose elements are not 0 sized storage sequences, and @var{TGT} and
1297 @var{PTR} occupy the same storage units in array element order.
1298 As in case(B), the result is false, if @var{PTR} is disassociated.
1299 @item (D) If @var{TGT} is present and an scalar pointer, the result is true if
1300 target associated with @var{PTR} and the target associated with @var{TGT}
1301 are not 0 sized storage sequences and occupy the same storage units.
1302 The result is false, if either @var{TGT} or @var{PTR} is disassociated.
1303 @item (E) If @var{TGT} is present and an array pointer, the result is true if
1304 target associated with @var{PTR} and the target associated with @var{TGT}
1305 have the same shape, are not 0 sized arrays, are arrays whose elements are
1306 not 0 sized storage sequences, and @var{TGT} and @var{PTR} occupy the same
1307 storage units in array element order.
1308 The result is false, if either @var{TGT} or @var{PTR} is disassociated.
1311 @item @emph{Example}:
1313 program test_associated
1315 real, target :: tgt(2) = (/1., 2./)
1316 real, pointer :: ptr(:)
1318 if (associated(ptr) .eqv. .false.) call abort
1319 if (associated(ptr,tgt) .eqv. .false.) call abort
1320 end program test_associated
1323 @item @emph{See also}:
1330 @section @code{ATAN} --- Arctangent function
1333 @cindex trigonometric function, tangent, inverse
1334 @cindex tangent, inverse
1337 @item @emph{Description}:
1338 @code{ATAN(X)} computes the arctangent of @var{X}.
1340 @item @emph{Standard}:
1346 @item @emph{Syntax}:
1347 @code{RESULT = ATAN(X)}
1349 @item @emph{Arguments}:
1350 @multitable @columnfractions .15 .70
1351 @item @var{X} @tab The type shall be @code{REAL(*)}.
1354 @item @emph{Return value}:
1355 The return value is of type @code{REAL(*)} and it lies in the
1356 range @math{ - \pi / 2 \leq \atan (x) \leq \pi / 2}.
1358 @item @emph{Example}:
1361 real(8) :: x = 2.866_8
1363 end program test_atan
1366 @item @emph{Specific names}:
1367 @multitable @columnfractions .20 .20 .20 .25
1368 @item Name @tab Argument @tab Return type @tab Standard
1369 @item @code{DATAN(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1372 @item @emph{See also}:
1373 Inverse function: @ref{TAN}
1380 @section @code{ATAN2} --- Arctangent function
1383 @cindex trigonometric function, tangent, inverse
1384 @cindex tangent, inverse
1387 @item @emph{Description}:
1388 @code{ATAN2(Y,X)} computes the arctangent of the complex number
1391 @item @emph{Standard}:
1397 @item @emph{Syntax}:
1398 @code{RESULT = ATAN2(Y,X)}
1400 @item @emph{Arguments}:
1401 @multitable @columnfractions .15 .70
1402 @item @var{Y} @tab The type shall be @code{REAL(*)}.
1403 @item @var{X} @tab The type and kind type parameter shall be the same as @var{Y}.
1404 If @var{Y} is zero, then @var{X} must be nonzero.
1407 @item @emph{Return value}:
1408 The return value has the same type and kind type parameter as @var{Y}.
1409 It is the principal value of the complex number @math{X + i Y}. If
1410 @var{X} is nonzero, then it lies in the range @math{-\pi \le \atan (x) \leq \pi}.
1411 The sign is positive if @var{Y} is positive. If @var{Y} is zero, then
1412 the return value is zero if @var{X} is positive and @math{\pi} if @var{X}
1413 is negative. Finally, if @var{X} is zero, then the magnitude of the result
1416 @item @emph{Example}:
1419 real(4) :: x = 1.e0_4, y = 0.5e0_4
1421 end program test_atan2
1424 @item @emph{Specific names}:
1425 @multitable @columnfractions .20 .20 .20 .25
1426 @item Name @tab Argument @tab Return type @tab Standard
1427 @item @code{DATAN2(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
1434 @section @code{ATANH} --- Hyperbolic arctangent function
1437 @cindex area hyperbolic tangent
1438 @cindex hyperbolic arctangent
1439 @cindex hyperbolic function, tangent, inverse
1440 @cindex tangent, hyperbolic, inverse
1443 @item @emph{Description}:
1444 @code{ATANH(X)} computes the hyperbolic arctangent of @var{X} (inverse
1447 @item @emph{Standard}:
1453 @item @emph{Syntax}:
1454 @code{RESULT = ATANH(X)}
1456 @item @emph{Arguments}:
1457 @multitable @columnfractions .15 .70
1458 @item @var{X} @tab The type shall be @code{REAL(*)} with a magnitude
1459 that is less than or equal to one.
1462 @item @emph{Return value}:
1463 The return value is of type @code{REAL(*)} and it lies in the
1464 range @math{-\infty \leq \atanh(x) \leq \infty}.
1466 @item @emph{Example}:
1469 REAL, DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
1470 WRITE (*,*) ATANH(x)
1474 @item @emph{Specific names}:
1475 @multitable @columnfractions .20 .20 .20 .25
1476 @item Name @tab Argument @tab Return type @tab Standard
1477 @item @code{DATANH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1480 @item @emph{See also}:
1481 Inverse function: @ref{TANH}
1487 @section @code{BESJ0} --- Bessel function of the first kind of order 0
1490 @cindex Bessel function, first kind
1493 @item @emph{Description}:
1494 @code{BESJ0(X)} computes the Bessel function of the first kind of order 0
1497 @item @emph{Standard}:
1503 @item @emph{Syntax}:
1504 @code{RESULT = BESJ0(X)}
1506 @item @emph{Arguments}:
1507 @multitable @columnfractions .15 .70
1508 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1511 @item @emph{Return value}:
1512 The return value is of type @code{REAL(*)} and it lies in the
1513 range @math{ - 0.4027... \leq Bessel (0,x) \leq 1}.
1515 @item @emph{Example}:
1518 real(8) :: x = 0.0_8
1520 end program test_besj0
1523 @item @emph{Specific names}:
1524 @multitable @columnfractions .20 .20 .20 .25
1525 @item Name @tab Argument @tab Return type @tab Standard
1526 @item @code{DBESJ0(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1533 @section @code{BESJ1} --- Bessel function of the first kind of order 1
1536 @cindex Bessel function, first kind
1539 @item @emph{Description}:
1540 @code{BESJ1(X)} computes the Bessel function of the first kind of order 1
1543 @item @emph{Standard}:
1549 @item @emph{Syntax}:
1550 @code{RESULT = BESJ1(X)}
1552 @item @emph{Arguments}:
1553 @multitable @columnfractions .15 .70
1554 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1557 @item @emph{Return value}:
1558 The return value is of type @code{REAL(*)} and it lies in the
1559 range @math{ - 0.5818... \leq Bessel (0,x) \leq 0.5818 }.
1561 @item @emph{Example}:
1564 real(8) :: x = 1.0_8
1566 end program test_besj1
1569 @item @emph{Specific names}:
1570 @multitable @columnfractions .20 .20 .20 .25
1571 @item Name @tab Argument @tab Return type @tab Standard
1572 @item @code{DBESJ1(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1579 @section @code{BESJN} --- Bessel function of the first kind
1582 @cindex Bessel function, first kind
1585 @item @emph{Description}:
1586 @code{BESJN(N, X)} computes the Bessel function of the first kind of order
1589 If both arguments are arrays, their ranks and shapes shall conform.
1591 @item @emph{Standard}:
1597 @item @emph{Syntax}:
1598 @code{RESULT = BESJN(N, X)}
1600 @item @emph{Arguments}:
1601 @multitable @columnfractions .15 .70
1602 @item @var{N} @tab Shall be a scalar or an array of type @code{INTEGER(*)}.
1603 @item @var{X} @tab Shall be a scalar or an array of type @code{REAL(*)}.
1606 @item @emph{Return value}:
1607 The return value is a scalar of type @code{REAL(*)}.
1609 @item @emph{Example}:
1612 real(8) :: x = 1.0_8
1614 end program test_besjn
1617 @item @emph{Specific names}:
1618 @multitable @columnfractions .20 .20 .20 .25
1619 @item Name @tab Argument @tab Return type @tab Standard
1620 @item @code{DBESJN(X)} @tab @code{INTEGER(*) N} @tab @code{REAL(8)} @tab GNU extension
1621 @item @tab @code{REAL(8) X} @tab @tab
1628 @section @code{BESY0} --- Bessel function of the second kind of order 0
1631 @cindex Bessel function, second kind
1634 @item @emph{Description}:
1635 @code{BESY0(X)} computes the Bessel function of the second kind of order 0
1638 @item @emph{Standard}:
1644 @item @emph{Syntax}:
1645 @code{RESULT = BESY0(X)}
1647 @item @emph{Arguments}:
1648 @multitable @columnfractions .15 .70
1649 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1652 @item @emph{Return value}:
1653 The return value is a scalar of type @code{REAL(*)}.
1655 @item @emph{Example}:
1658 real(8) :: x = 0.0_8
1660 end program test_besy0
1663 @item @emph{Specific names}:
1664 @multitable @columnfractions .20 .20 .20 .25
1665 @item Name @tab Argument @tab Return type @tab Standard
1666 @item @code{DBESY0(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1673 @section @code{BESY1} --- Bessel function of the second kind of order 1
1676 @cindex Bessel function, second kind
1679 @item @emph{Description}:
1680 @code{BESY1(X)} computes the Bessel function of the second kind of order 1
1683 @item @emph{Standard}:
1689 @item @emph{Syntax}:
1690 @code{RESULT = BESY1(X)}
1692 @item @emph{Arguments}:
1693 @multitable @columnfractions .15 .70
1694 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
1697 @item @emph{Return value}:
1698 The return value is a scalar of type @code{REAL(*)}.
1700 @item @emph{Example}:
1703 real(8) :: x = 1.0_8
1705 end program test_besy1
1708 @item @emph{Specific names}:
1709 @multitable @columnfractions .20 .20 .20 .25
1710 @item Name @tab Argument @tab Return type @tab Standard
1711 @item @code{DBESY1(X)}@tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
1718 @section @code{BESYN} --- Bessel function of the second kind
1721 @cindex Bessel function, second kind
1724 @item @emph{Description}:
1725 @code{BESYN(N, X)} computes the Bessel function of the second kind of order
1728 If both arguments are arrays, their ranks and shapes shall conform.
1730 @item @emph{Standard}:
1736 @item @emph{Syntax}:
1737 @code{RESULT = BESYN(N, X)}
1739 @item @emph{Arguments}:
1740 @multitable @columnfractions .15 .70
1741 @item @var{N} @tab Shall be a scalar or an array of type @code{INTEGER(*)}.
1742 @item @var{X} @tab Shall be a scalar or an array of type @code{REAL(*)}.
1745 @item @emph{Return value}:
1746 The return value is a scalar of type @code{REAL(*)}.
1748 @item @emph{Example}:
1751 real(8) :: x = 1.0_8
1753 end program test_besyn
1756 @item @emph{Specific names}:
1757 @multitable @columnfractions .20 .20 .20 .25
1758 @item Name @tab Argument @tab Return type @tab Standard
1759 @item @code{DBESYN(N,X)} @tab @code{INTEGER(*) N} @tab @code{REAL(8)} @tab GNU extension
1760 @item @tab @code{REAL(8) X} @tab @tab
1767 @section @code{BIT_SIZE} --- Bit size inquiry function
1769 @cindex bits, number of
1770 @cindex size of a variable, in bits
1773 @item @emph{Description}:
1774 @code{BIT_SIZE(I)} returns the number of bits (integer precision plus sign bit)
1775 represented by the type of @var{I}.
1777 @item @emph{Standard}:
1783 @item @emph{Syntax}:
1784 @code{RESULT = BIT_SIZE(I)}
1786 @item @emph{Arguments}:
1787 @multitable @columnfractions .15 .70
1788 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1791 @item @emph{Return value}:
1792 The return value is of type @code{INTEGER(*)}
1794 @item @emph{Example}:
1796 program test_bit_size
1801 end program test_bit_size
1808 @section @code{BTEST} --- Bit test function
1810 @cindex bits, testing
1813 @item @emph{Description}:
1814 @code{BTEST(I,POS)} returns logical @code{.TRUE.} if the bit at @var{POS}
1817 @item @emph{Standard}:
1823 @item @emph{Syntax}:
1824 @code{RESULT = BTEST(I, POS)}
1826 @item @emph{Arguments}:
1827 @multitable @columnfractions .15 .70
1828 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
1829 @item @var{POS} @tab The type shall be @code{INTEGER(*)}.
1832 @item @emph{Return value}:
1833 The return value is of type @code{LOGICAL}
1835 @item @emph{Example}:
1838 integer :: i = 32768 + 1024 + 64
1842 bool = btest(i, pos)
1845 end program test_btest
1851 @section @code{C_ASSOCIATED} --- Status of a C pointer
1852 @fnindex C_ASSOCIATED
1853 @cindex association status, C pointer
1854 @cindex pointer, C association status
1857 @item @emph{Description}:
1858 @code{C_ASSOICATED(c_prt1[, c_ptr2])} determines the status of the C pointer @var{c_ptr1}
1859 or if @var{c_ptr1} is associated with the target @var{c_ptr2}.
1861 @item @emph{Standard}:
1867 @item @emph{Syntax}:
1868 @code{RESULT = C_ASSOICATED(c_prt1[, c_ptr2])}
1870 @item @emph{Arguments}:
1871 @multitable @columnfractions .15 .70
1872 @item @var{c_ptr1} @tab Scalar of the type @code{C_PTR} or @code{C_FUNPTR}.
1873 @item @var{c_ptr2} @tab (Optional) Scalar of the same type as @var{c_ptr1}.
1876 @item @emph{Return value}:
1877 The return value is of type @code{LOGICAL}; it is @code{.false.} if either
1878 @var{c_ptr1} is a C NULL pointer or if @var{c_ptr1} and @var{c_ptr2}
1879 point to different addresses.
1881 @item @emph{Example}:
1883 subroutine association_test(a,b)
1884 use iso_c_binding, only: c_associated, c_loc, c_ptr
1888 if(c_associated(b, c_loc(a))) &
1889 stop 'b and a do not point to same target'
1890 end subroutine association_test
1893 @item @emph{See also}:
1894 @ref{C_LOC}, @ref{C_FUNLOC}
1899 @section @code{C_FUNLOC} --- Obtain the C address of a procedure
1901 @cindex pointer, C address of procedures
1904 @item @emph{Description}:
1905 @code{C_FUNLOC(x)} determines the C address of the argument.
1907 @item @emph{Standard}:
1913 @item @emph{Syntax}:
1914 @code{RESULT = C_FUNLOC(x)}
1916 @item @emph{Arguments}:
1917 @multitable @columnfractions .15 .70
1918 @item @var{x} @tab Interoperable function or pointer to such function.
1921 @item @emph{Return value}:
1922 The return value is of type @code{C_FUNPTR} and contains the C address
1925 @item @emph{Example}:
1931 subroutine sub(a) bind(c)
1941 subroutine my_routine(p) bind(c,name='myC_func')
1943 type(c_funptr), intent(in) :: p
1946 call my_routine(c_funloc(sub))
1950 @item @emph{See also}:
1951 @ref{C_ASSOCIATED}, @ref{C_LOC}, @ref{C_F_POINTER}, @ref{C_F_PROCPOINTER}
1955 @node C_F_PROCPOINTER
1956 @section @code{C_F_PROCPOINTER} --- Convert C into Fortran procedure pointer
1957 @fnindex C_F_PROCPOINTER
1958 @cindex pointer, C address of pointers
1961 @item @emph{Description}:
1962 @code{C_F_PROCPOINTER(cptr, fptr)} Assign the target of the C function pointer
1963 @var{cptr} to the Fortran procedure pointer @var{fptr}.
1965 Note: Due to the currently lacking support of procedure pointers in GNU Fortran
1966 this function is not fully operable.
1968 @item @emph{Standard}:
1974 @item @emph{Syntax}:
1975 @code{CALL C_F_PROCPOINTER(cptr, fptr)}
1977 @item @emph{Arguments}:
1978 @multitable @columnfractions .15 .70
1979 @item @var{cptr} @tab scalar of the type @code{C_FUNPTR}. It is
1981 @item @var{fptr} @tab procedure pointer interoperable with @var{cptr}. It is
1985 @item @emph{Example}:
1993 real(c_float), intent(in) :: a
1994 real(c_float) :: func
1998 function getIterFunc() bind(c,name="getIterFunc")
2000 type(c_funptr) :: getIterFunc
2003 type(c_funptr) :: cfunptr
2004 procedure(func), pointer :: myFunc
2005 cfunptr = getIterFunc()
2006 call c_f_procpointer(cfunptr, myFunc)
2010 @item @emph{See also}:
2011 @ref{C_LOC}, @ref{C_F_POINTER}
2016 @section @code{C_F_POINTER} --- Convert C into Fortran pointer
2017 @fnindex C_F_POINTER
2018 @cindex pointer, convert C to Fortran
2021 @item @emph{Description}:
2022 @code{C_F_POINTER(cptr, fptr[, shape])} Assign the target the C pointer
2023 @var{cptr} to the Fortran pointer @var{fptr} and specify its
2026 @item @emph{Standard}:
2032 @item @emph{Syntax}:
2033 @code{CALL C_F_POINTER(cptr, fptr[, shape])}
2035 @item @emph{Arguments}:
2036 @multitable @columnfractions .15 .70
2037 @item @var{cptr} @tab scalar of the type @code{C_PTR}. It is
2039 @item @var{fptr} @tab pointer interoperable with @var{cptr}. It is
2041 @item @var{shape} @tab (Optional) Rank-one array of type @code{INTEGER}
2042 with @code{INTENT(IN)}. It shall be present
2043 if and only if @var{fptr} is an array. The size
2044 must be equal to the rank of @var{fptr}.
2047 @item @emph{Example}:
2053 subroutine my_routine(p) bind(c,name='myC_func')
2055 type(c_ptr), intent(out) :: p
2059 real,pointer :: a(:)
2060 call my_routine(cptr)
2061 call c_f_pointer(cptr, a, [12])
2065 @item @emph{See also}:
2066 @ref{C_LOC}, @ref{C_F_PROCPOINTER}
2071 @section @code{C_LOC} --- Obtain the C address of an object
2073 @cindex procedure pointer, convert C to Fortran
2076 @item @emph{Description}:
2077 @code{C_LOC(x)} determines the C address of the argument.
2079 @item @emph{Standard}:
2085 @item @emph{Syntax}:
2086 @code{RESULT = C_LOC(x)}
2088 @item @emph{Arguments}:
2089 @multitable @columnfractions .15 .70
2090 @item @var{x} @tab Associated scalar pointer or interoperable scalar
2091 or allocated allocatable variable with @code{TARGET}
2095 @item @emph{Return value}:
2096 The return value is of type @code{C_PTR} and contains the C address
2099 @item @emph{Example}:
2101 subroutine association_test(a,b)
2102 use iso_c_binding, only: c_associated, c_loc, c_ptr
2106 if(c_associated(b, c_loc(a))) &
2107 stop 'b and a do not point to same target'
2108 end subroutine association_test
2111 @item @emph{See also}:
2112 @ref{C_ASSOCIATED}, @ref{C_FUNLOC}, @ref{C_F_POINTER}, @ref{C_F_PROCPOINTER}
2117 @section @code{CEILING} --- Integer ceiling function
2120 @cindex rounding, ceiling
2123 @item @emph{Description}:
2124 @code{CEILING(X)} returns the least integer greater than or equal to @var{X}.
2126 @item @emph{Standard}:
2132 @item @emph{Syntax}:
2133 @code{RESULT = CEILING(X [, KIND])}
2135 @item @emph{Arguments}:
2136 @multitable @columnfractions .15 .70
2137 @item @var{X} @tab The type shall be @code{REAL(*)}.
2138 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
2139 expression indicating the kind parameter of
2143 @item @emph{Return value}:
2144 The return value is of type @code{INTEGER(KIND)}
2146 @item @emph{Example}:
2148 program test_ceiling
2151 print *, ceiling(x) ! returns 64
2152 print *, ceiling(y) ! returns -63
2153 end program test_ceiling
2156 @item @emph{See also}:
2157 @ref{FLOOR}, @ref{NINT}
2164 @section @code{CHAR} --- Character conversion function
2166 @cindex conversion, to character
2169 @item @emph{Description}:
2170 @code{CHAR(I [, KIND])} returns the character represented by the integer @var{I}.
2172 @item @emph{Standard}:
2178 @item @emph{Syntax}:
2179 @code{RESULT = CHAR(I [, KIND])}
2181 @item @emph{Arguments}:
2182 @multitable @columnfractions .15 .70
2183 @item @var{I} @tab The type shall be @code{INTEGER(*)}.
2184 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
2185 expression indicating the kind parameter of
2189 @item @emph{Return value}:
2190 The return value is of type @code{CHARACTER(1)}
2192 @item @emph{Example}:
2198 print *, i, c ! returns 'J'
2199 end program test_char
2203 See @ref{ICHAR} for a discussion of converting between numerical values
2204 and formatted string representations.
2206 @item @emph{See also}:
2207 @ref{ACHAR}, @ref{IACHAR}, @ref{ICHAR}
2214 @section @code{CHDIR} --- Change working directory
2216 @cindex system, working directory
2219 @item @emph{Description}:
2220 Change current working directory to a specified path.
2222 This intrinsic is provided in both subroutine and function forms; however,
2223 only one form can be used in any given program unit.
2225 @item @emph{Standard}:
2229 Subroutine, function
2231 @item @emph{Syntax}:
2232 @multitable @columnfractions .80
2233 @item @code{CALL CHDIR(NAME [, STATUS])}
2234 @item @code{STATUS = CHDIR(NAME)}
2237 @item @emph{Arguments}:
2238 @multitable @columnfractions .15 .70
2239 @item @var{NAME} @tab The type shall be @code{CHARACTER(*)} and shall
2240 specify a valid path within the file system.
2241 @item @var{STATUS} @tab (Optional) @code{INTEGER} status flag of the default
2242 kind. Returns 0 on success, and a system specific
2243 and nonzero error code otherwise.
2246 @item @emph{Example}:
2249 CHARACTER(len=255) :: path
2251 WRITE(*,*) TRIM(path)
2254 WRITE(*,*) TRIM(path)
2258 @item @emph{See also}:
2265 @section @code{CHMOD} --- Change access permissions of files
2267 @cindex file system, change access mode
2270 @item @emph{Description}:
2271 @code{CHMOD} changes the permissions of a file. This function invokes
2272 @code{/bin/chmod} and might therefore not work on all platforms.
2274 This intrinsic is provided in both subroutine and function forms; however,
2275 only one form can be used in any given program unit.
2277 @item @emph{Standard}:
2281 Subroutine, function
2283 @item @emph{Syntax}:
2284 @multitable @columnfractions .80
2285 @item @code{CALL CHMOD(NAME, MODE[, STATUS])}
2286 @item @code{STATUS = CHMOD(NAME, MODE)}
2289 @item @emph{Arguments}:
2290 @multitable @columnfractions .15 .70
2291 @item @var{NAME} @tab Scalar @code{CHARACTER} with the file name.
2292 Trailing blanks are ignored unless the character @code{achar(0)} is
2293 present, then all characters up to and excluding @code{achar(0)} are
2294 used as the file name.
2296 @item @var{MODE} @tab Scalar @code{CHARACTER} giving the file permission.
2297 @var{MODE} uses the same syntax as the @var{MODE} argument of
2300 @item @var{STATUS} @tab (optional) scalar @code{INTEGER}, which is
2301 @code{0} on success and nonzero otherwise.
2304 @item @emph{Return value}:
2305 In either syntax, @var{STATUS} is set to @code{0} on success and nonzero
2308 @item @emph{Example}:
2309 @code{CHMOD} as subroutine
2314 call chmod('test.dat','u+x',status)
2315 print *, 'Status: ', status
2316 end program chmod_test
2318 @code{CHMOD} as function:
2323 status = chmod('test.dat','u+x')
2324 print *, 'Status: ', status
2325 end program chmod_test
2333 @section @code{CMPLX} --- Complex conversion function
2335 @cindex complex numbers, conversion to
2336 @cindex conversion, to complex
2339 @item @emph{Description}:
2340 @code{CMPLX(X [, Y [, KIND]])} returns a complex number where @var{X} is converted to
2341 the real component. If @var{Y} is present it is converted to the imaginary
2342 component. If @var{Y} is not present then the imaginary component is set to
2343 0.0. If @var{X} is complex then @var{Y} must not be present.
2345 @item @emph{Standard}:
2351 @item @emph{Syntax}:
2352 @code{RESULT = CMPLX(X [, Y [, KIND]])}
2354 @item @emph{Arguments}:
2355 @multitable @columnfractions .15 .70
2356 @item @var{X} @tab The type may be @code{INTEGER(*)}, @code{REAL(*)},
2357 or @code{COMPLEX(*)}.
2358 @item @var{Y} @tab (Optional; only allowed if @var{X} is not
2359 @code{COMPLEX(*)}.) May be @code{INTEGER(*)}
2361 @item @var{KIND} @tab (Optional) An @code{INTEGER(*)} initialization
2362 expression indicating the kind parameter of
2366 @item @emph{Return value}:
2367 The return value is of @code{COMPLEX} type, with a kind equal to
2368 @var{KIND} if it is specified. If @var{KIND} is not specified, the
2369 result is of the default @code{COMPLEX} kind, regardless of the kinds of
2370 @var{X} and @var{Y}.
2372 @item @emph{Example}:
2379 print *, z, cmplx(x)
2380 end program test_cmplx
2383 @item @emph{See also}:
2389 @node COMMAND_ARGUMENT_COUNT
2390 @section @code{COMMAND_ARGUMENT_COUNT} --- Get number of command line arguments
2391 @fnindex COMMAND_ARGUMENT_COUNT
2392 @cindex command-line arguments
2393 @cindex command-line arguments, number of
2394 @cindex arguments, to program
2397 @item @emph{Description}:
2398 @code{COMMAND_ARGUMENT_COUNT()} returns the number of arguments passed on the
2399 command line when the containing program was invoked.
2401 @item @emph{Standard}:
2407 @item @emph{Syntax}:
2408 @code{RESULT = COMMAND_ARGUMENT_COUNT()}
2410 @item @emph{Arguments}:
2411 @multitable @columnfractions .15 .70
2415 @item @emph{Return value}:
2416 The return value is of type @code{INTEGER(4)}
2418 @item @emph{Example}:
2420 program test_command_argument_count
2422 count = command_argument_count()
2424 end program test_command_argument_count
2427 @item @emph{See also}:
2428 @ref{GET_COMMAND}, @ref{GET_COMMAND_ARGUMENT}
2434 @section @code{COMPLEX} --- Complex conversion function
2436 @cindex complex numbers, conversion to
2437 @cindex conversion, to complex
2440 @item @emph{Description}:
2441 @code{COMPLEX(X, Y)} returns a complex number where @var{X} is converted
2442 to the real component and @var{Y} is converted to the imaginary
2445 @item @emph{Standard}:
2451 @item @emph{Syntax}:
2452 @code{RESULT = COMPLEX(X, Y)}
2454 @item @emph{Arguments}:
2455 @multitable @columnfractions .15 .70
2456 @item @var{X} @tab The type may be @code{INTEGER(*)} or @code{REAL(*)}.
2457 @item @var{Y} @tab The type may be @code{INTEGER(*)} or @code{REAL(*)}.
2460 @item @emph{Return value}:
2461 If @var{X} and @var{Y} are both of @code{INTEGER} type, then the return
2462 value is of default @code{COMPLEX} type.
2464 If @var{X} and @var{Y} are of @code{REAL} type, or one is of @code{REAL}
2465 type and one is of @code{INTEGER} type, then the return value is of
2466 @code{COMPLEX} type with a kind equal to that of the @code{REAL}
2467 argument with the highest precision.
2469 @item @emph{Example}:
2471 program test_complex
2474 print *, complex(i, x)
2475 end program test_complex
2478 @item @emph{See also}:
2485 @section @code{CONJG} --- Complex conjugate function
2488 @cindex complex conjugate
2491 @item @emph{Description}:
2492 @code{CONJG(Z)} returns the conjugate of @var{Z}. If @var{Z} is @code{(x, y)}
2493 then the result is @code{(x, -y)}
2495 @item @emph{Standard}:
2496 F77 and later, has overloads that are GNU extensions
2501 @item @emph{Syntax}:
2504 @item @emph{Arguments}:
2505 @multitable @columnfractions .15 .70
2506 @item @var{Z} @tab The type shall be @code{COMPLEX(*)}.
2509 @item @emph{Return value}:
2510 The return value is of type @code{COMPLEX(*)}.
2512 @item @emph{Example}:
2515 complex :: z = (2.0, 3.0)
2516 complex(8) :: dz = (2.71_8, -3.14_8)
2521 end program test_conjg
2524 @item @emph{Specific names}:
2525 @multitable @columnfractions .20 .20 .20 .25
2526 @item Name @tab Argument @tab Return type @tab Standard
2527 @item @code{DCONJG(Z)} @tab @code{COMPLEX(8) Z} @tab @code{COMPLEX(8)} @tab GNU extension
2534 @section @code{COS} --- Cosine function
2540 @cindex trigonometric function, cosine
2544 @item @emph{Description}:
2545 @code{COS(X)} computes the cosine of @var{X}.
2547 @item @emph{Standard}:
2548 F77 and later, has overloads that are GNU extensions
2553 @item @emph{Syntax}:
2554 @code{RESULT = COS(X)}
2556 @item @emph{Arguments}:
2557 @multitable @columnfractions .15 .70
2558 @item @var{X} @tab The type shall be @code{REAL(*)} or
2562 @item @emph{Return value}:
2563 The return value is of type @code{REAL(*)} and it lies in the
2564 range @math{ -1 \leq \cos (x) \leq 1}. The kind type
2565 parameter is the same as @var{X}.
2567 @item @emph{Example}:
2572 end program test_cos
2575 @item @emph{Specific names}:
2576 @multitable @columnfractions .20 .20 .20 .25
2577 @item Name @tab Argument @tab Return type @tab Standard
2578 @item @code{DCOS(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
2579 @item @code{CCOS(X)} @tab @code{COMPLEX(4) X} @tab @code{COMPLEX(4)} @tab F77 and later
2580 @item @code{ZCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
2581 @item @code{CDCOS(X)} @tab @code{COMPLEX(8) X} @tab @code{COMPLEX(8)} @tab GNU extension
2584 @item @emph{See also}:
2585 Inverse function: @ref{ACOS}
2592 @section @code{COSH} --- Hyperbolic cosine function
2595 @cindex hyperbolic cosine
2596 @cindex hyperbolic function, cosine
2597 @cindex cosine, hyperbolic
2600 @item @emph{Description}:
2601 @code{COSH(X)} computes the hyperbolic cosine of @var{X}.
2603 @item @emph{Standard}:
2609 @item @emph{Syntax}:
2612 @item @emph{Arguments}:
2613 @multitable @columnfractions .15 .70
2614 @item @var{X} @tab The type shall be @code{REAL(*)}.
2617 @item @emph{Return value}:
2618 The return value is of type @code{REAL(*)} and it is positive
2619 (@math{ \cosh (x) \geq 0 }.
2621 @item @emph{Example}:
2624 real(8) :: x = 1.0_8
2626 end program test_cosh
2629 @item @emph{Specific names}:
2630 @multitable @columnfractions .20 .20 .20 .25
2631 @item Name @tab Argument @tab Return type @tab Standard
2632 @item @code{DCOSH(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab F77 and later
2635 @item @emph{See also}:
2636 Inverse function: @ref{ACOSH}
2643 @section @code{COUNT} --- Count function
2645 @cindex array, conditionally count elements
2646 @cindex array, element counting
2647 @cindex array, number of elements
2650 @item @emph{Description}:
2652 @code{COUNT(MASK [, DIM [, KIND]])} counts the number of @code{.TRUE.}
2653 elements of @var{MASK} along the dimension of @var{DIM}. If @var{DIM} is
2654 omitted it is taken to be @code{1}. @var{DIM} is a scaler of type
2655 @code{INTEGER} in the range of @math{1 /leq DIM /leq n)} where @math{n}
2656 is the rank of @var{MASK}.
2658 @item @emph{Standard}:
2662 Transformational function
2664 @item @emph{Syntax}:
2665 @code{RESULT = COUNT(MASK [, DIM [, KIND]])}
2667 @item @emph{Arguments}:
2668 @multitable @columnfractions .15 .70
2669 @item @var{MASK} @tab The type shall be @code{LOGICAL}.
2670 @item @var{DIM} @tab (Optional) The type shall be @code{INTEGER}.
2671 @item @var{KIND} @tab (Optional) An @code{INTEGER} initialization
2672 expression indicating the kind parameter of
2676 @item @emph{Return value}:
2677 The return value is of type @code{INTEGER} and of kind @var{KIND}. If
2678 @var{KIND} is absent, the return value is of default integer kind.
2679 The result has a rank equal to that of @var{MASK}.
2681 @item @emph{Example}:
2684 integer, dimension(2,3) :: a, b
2685 logical, dimension(2,3) :: mask
2686 a = reshape( (/ 1, 2, 3, 4, 5, 6 /), (/ 2, 3 /))
2687 b = reshape( (/ 0, 7, 3, 4, 5, 8 /), (/ 2, 3 /))
2688 print '(3i3)', a(1,:)
2689 print '(3i3)', a(2,:)
2691 print '(3i3)', b(1,:)
2692 print '(3i3)', b(2,:)
2695 print '(3l3)', mask(1,:)
2696 print '(3l3)', mask(2,:)
2698 print '(3i3)', count(mask)
2700 print '(3i3)', count(mask, 1)
2702 print '(3i3)', count(mask, 2)
2703 end program test_count
2710 @section @code{CPU_TIME} --- CPU elapsed time in seconds
2712 @cindex time, elapsed
2715 @item @emph{Description}:
2716 Returns a @code{REAL(*)} value representing the elapsed CPU time in
2717 seconds. This is useful for testing segments of code to determine
2720 If a time source is available, time will be reported with microsecond
2721 resolution. If no time source is available, @var{TIME} is set to
2724 Note that @var{TIME} may contain a, system dependent, arbitrary offset
2725 and may not start with @code{0.0}. For @code{CPU_TIME}, the absolute
2726 value is meaningless, only differences between subsequent calls to
2727 this subroutine, as shown in the example below, should be used.
2730 @item @emph{Standard}:
2736 @item @emph{Syntax}:
2737 @code{CALL CPU_TIME(TIME)}
2739 @item @emph{Arguments}:
2740 @multitable @columnfractions .15 .70
2741 @item @var{TIME} @tab The type shall be @code{REAL(*)} with @code{INTENT(OUT)}.
2744 @item @emph{Return value}:
2747 @item @emph{Example}:
2749 program test_cpu_time
2750 real :: start, finish
2751 call cpu_time(start)
2752 ! put code to test here
2753 call cpu_time(finish)
2754 print '("Time = ",f6.3," seconds.")',finish-start
2755 end program test_cpu_time
2758 @item @emph{See also}:
2759 @ref{SYSTEM_CLOCK}, @ref{DATE_AND_TIME}
2765 @section @code{CSHIFT} --- Circular shift elements of an array
2767 @cindex array, shift circularly
2768 @cindex array, permutation
2769 @cindex array, rotate
2772 @item @emph{Description}:
2773 @code{CSHIFT(ARRAY, SHIFT [, DIM])} performs a circular shift on elements of
2774 @var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is omitted it is
2775 taken to be @code{1}. @var{DIM} is a scaler of type @code{INTEGER} in the
2776 range of @math{1 /leq DIM /leq n)} where @math{n} is the rank of @var{ARRAY}.
2777 If the rank of @var{ARRAY} is one, then all elements of @var{ARRAY} are shifted
2778 by @var{SHIFT} places. If rank is greater than one, then all complete rank one
2779 sections of @var{ARRAY} along the given dimension are shifted. Elements
2780 shifted out one end of each rank one section are shifted back in the other end.
2782 @item @emph{Standard}:
2786 Transformational function
2788 @item @emph{Syntax}:
2789 @code{RESULT = CSHIFT(ARRAY, SHIFT [, DIM])}
2791 @item @emph{Arguments}:
2792 @multitable @columnfractions .15 .70
2793 @item @var{ARRAY} @tab Shall be an array of any type.
2794 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
2795 @item @var{DIM} @tab The type shall be @code{INTEGER}.
2798 @item @emph{Return value}:
2799 Returns an array of same type and rank as the @var{ARRAY} argument.
2801 @item @emph{Example}:
2804 integer, dimension(3,3) :: a
2805 a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
2806 print '(3i3)', a(1,:)
2807 print '(3i3)', a(2,:)
2808 print '(3i3)', a(3,:)
2809 a = cshift(a, SHIFT=(/1, 2, -1/), DIM=2)
2811 print '(3i3)', a(1,:)
2812 print '(3i3)', a(2,:)
2813 print '(3i3)', a(3,:)
2814 end program test_cshift
2821 @section @code{CTIME} --- Convert a time into a string
2823 @cindex time, conversion to string
2824 @cindex conversion, to string
2827 @item @emph{Description}:
2828 @code{CTIME} converts a system time value, such as returned by
2829 @code{TIME8()}, to a string of the form @samp{Sat Aug 19 18:13:14 1995}.
2831 This intrinsic is provided in both subroutine and function forms; however,
2832 only one form can be used in any given program unit.
2834 @item @emph{Standard}:
2838 Subroutine, function
2840 @item @emph{Syntax}:
2841 @multitable @columnfractions .80
2842 @item @code{CALL CTIME(TIME, RESULT)}.
2843 @item @code{RESULT = CTIME(TIME)}, (not recommended).
2846 @item @emph{Arguments}:
2847 @multitable @columnfractions .15 .70
2848 @item @var{TIME} @tab The type shall be of type @code{INTEGER(KIND=8)}.
2849 @item @var{RESULT} @tab The type shall be of type @code{CHARACTER}.
2852 @item @emph{Return value}:
2853 The converted date and time as a string.
2855 @item @emph{Example}:
2859 character(len=30) :: date
2862 ! Do something, main part of the program
2865 print *, 'Program was started on ', date
2866 end program test_ctime
2869 @item @emph{See Also}:
2870 @ref{GMTIME}, @ref{LTIME}, @ref{TIME}, @ref{TIME8}
2876 @section @code{DATE_AND_TIME} --- Date and time subroutine
2877 @fnindex DATE_AND_TIME
2878 @cindex date, current
2879 @cindex current date
2880 @cindex time, current
2881 @cindex current time
2884 @item @emph{Description}:
2885 @code{DATE_AND_TIME(DATE, TIME, ZONE, VALUES)} gets the corresponding date and
2886 time information from the real-time system clock. @var{DATE} is
2887 @code{INTENT(OUT)} and has form ccyymmdd. @var{TIME} is @code{INTENT(OUT)} and
2888 has form hhmmss.sss. @var{ZONE} is @code{INTENT(OUT)} and has form (+-)hhmm,
2889 representing the difference with respect to Coordinated Universal Time (UTC).
2890 Unavailable time and date parameters return blanks.
2892 @var{VALUES} is @code{INTENT(OUT)} and provides the following:
2894 @multitable @columnfractions .15 .30 .40
2895 @item @tab @code{VALUE(1)}: @tab The year
2896 @item @tab @code{VALUE(2)}: @tab The month
2897 @item @tab @code{VALUE(3)}: @tab The day of the month
2898 @item @tab @code{VALUE(4)}: @tab Time difference with UTC in minutes
2899 @item @tab @code{VALUE(5)}: @tab The hour of the day
2900 @item @tab @code{VALUE(6)}: @tab The minutes of the hour
2901 @item @tab @code{VALUE(7)}: @tab The seconds of the minute
2902 @item @tab @code{VALUE(8)}: @tab The milliseconds of the second
2905 @item @emph{Standard}:
2911 @item @emph{Syntax}:
2912 @code{CALL DATE_AND_TIME([DATE, TIME, ZONE, VALUES])}
2914 @item @emph{Arguments}:
2915 @multitable @columnfractions .15 .70
2916 @item @var{DATE} @tab (Optional) The type shall be @code{CHARACTER(8)} or larger.
2917 @item @var{TIME} @tab (Optional) The type shall be @code{CHARACTER(10)} or larger.
2918 @item @var{ZONE} @tab (Optional) The type shall be @code{CHARACTER(5)} or larger.
2919 @item @var{VALUES}@tab (Optional) The type shall be @code{INTEGER(8)}.
2922 @item @emph{Return value}:
2925 @item @emph{Example}:
2927 program test_time_and_date
2928 character(8) :: date
2929 character(10) :: time
2930 character(5) :: zone
2931 integer,dimension(8) :: values
2932 ! using keyword arguments
2933 call date_and_time(date,time,zone,values)
2934 call date_and_time(DATE=date,ZONE=zone)
2935 call date_and_time(TIME=time)
2936 call date_and_time(VALUES=values)
2937 print '(a,2x,a,2x,a)', date, time, zone
2938 print '(8i5))', values
2939 end program test_time_and_date
2942 @item @emph{See also}:
2943 @ref{CPU_TIME}, @ref{SYSTEM_CLOCK}
2949 @section @code{DBLE} --- Double conversion function
2951 @cindex conversion, to real
2954 @item @emph{Description}:
2955 @code{DBLE(X)} Converts @var{X} to double precision real type.
2957 @item @emph{Standard}:
2963 @item @emph{Syntax}:
2964 @code{RESULT = DBLE(X)}
2966 @item @emph{Arguments}:
2967 @multitable @columnfractions .15 .70
2968 @item @var{X} @tab The type shall be @code{INTEGER(*)}, @code{REAL(*)},
2969 or @code{COMPLEX(*)}.
2972 @item @emph{Return value}:
2973 The return value is of type double precision real.
2975 @item @emph{Example}:
2980 complex :: z = (2.3,1.14)
2981 print *, dble(x), dble(i), dble(z)
2982 end program test_dble
2985 @item @emph{See also}:
2986 @ref{DFLOAT}, @ref{FLOAT}, @ref{REAL}
2992 @section @code{DCMPLX} --- Double complex conversion function
2994 @cindex complex numbers, conversion to
2995 @cindex conversion, to complex
2998 @item @emph{Description}:
2999 @code{DCMPLX(X [,Y])} returns a double complex number where @var{X} is
3000 converted to the real component. If @var{Y} is present it is converted to the
3001 imaginary component. If @var{Y} is not present then the imaginary component is
3002 set to 0.0. If @var{X} is complex then @var{Y} must not be present.
3004 @item @emph{Standard}:
3010 @item @emph{Syntax}:
3011 @code{RESULT = DCMPLX(X [, Y])}
3013 @item @emph{Arguments}:
3014 @multitable @columnfractions .15 .70
3015 @item @var{X} @tab The type may be @code{INTEGER(*)}, @code{REAL(*)},
3016 or @code{COMPLEX(*)}.
3017 @item @var{Y} @tab (Optional if @var{X} is not @code{COMPLEX(*)}.) May be
3018 @code{INTEGER(*)} or @code{REAL(*)}.
3021 @item @emph{Return value}:
3022 The return value is of type @code{COMPLEX(8)}
3024 @item @emph{Example}:
3034 print *, dcmplx(x,i)
3035 end program test_dcmplx
3042 @section @code{DFLOAT} --- Double conversion function
3044 @cindex conversion, to real
3047 @item @emph{Description}:
3048 @code{DFLOAT(X)} Converts @var{X} to double precision real type.
3050 @item @emph{Standard}:
3056 @item @emph{Syntax}:
3057 @code{RESULT = DFLOAT(X)}
3059 @item @emph{Arguments}:
3060 @multitable @columnfractions .15 .70
3061 @item @var{X} @tab The type shall be @code{INTEGER(*)}.
3064 @item @emph{Return value}:
3065 The return value is of type double precision real.
3067 @item @emph{Example}:
3072 end program test_dfloat
3075 @item @emph{See also}:
3076 @ref{DBLE}, @ref{FLOAT}, @ref{REAL}
3082 @section @code{DIGITS} --- Significant digits function
3084 @cindex model representation, significant digits
3087 @item @emph{Description}:
3088 @code{DIGITS(X)} returns the number of significant digits of the internal model
3089 representation of @var{X}. For example, on a system using a 32-bit
3090 floating point representation, a default real number would likely return 24.
3092 @item @emph{Standard}:
3098 @item @emph{Syntax}:
3099 @code{RESULT = DIGITS(X)}
3101 @item @emph{Arguments}:
3102 @multitable @columnfractions .15 .70
3103 @item @var{X} @tab The type may be @code{INTEGER(*)} or @code{REAL(*)}.
3106 @item @emph{Return value}:
3107 The return value is of type @code{INTEGER}.
3109 @item @emph{Example}:
3112 integer :: i = 12345
3118 end program test_digits
3125 @section @code{DIM} --- Positive difference
3129 @cindex positive difference
3132 @item @emph{Description}:
3133 @code{DIM(X,Y)} returns the difference @code{X-Y} if the result is positive;
3134 otherwise returns zero.
3136 @item @emph{Standard}:
3142 @item @emph{Syntax}:
3143 @code{RESULT = DIM(X, Y)}
3145 @item @emph{Arguments}:
3146 @multitable @columnfractions .15 .70
3147 @item @var{X} @tab The type shall be @code{INTEGER(*)} or @code{REAL(*)}
3148 @item @var{Y} @tab The type shall be the same type and kind as @var{X}.
3151 @item @emph{Return value}:
3152 The return value is of type @code{INTEGER(*)} or @code{REAL(*)}.
3154 @item @emph{Example}:
3160 x = dim(4.345_8, 2.111_8)
3163 end program test_dim
3166 @item @emph{Specific names}:
3167 @multitable @columnfractions .20 .20 .20 .25
3168 @item Name @tab Argument @tab Return type @tab Standard
3169 @item @code{IDIM(X,Y)} @tab @code{INTEGER(4) X,Y} @tab @code{INTEGER(4)} @tab F77 and later
3170 @item @code{DDIM(X,Y)} @tab @code{REAL(8) X,Y} @tab @code{REAL(8)} @tab F77 and later
3177 @section @code{DOT_PRODUCT} --- Dot product function
3178 @fnindex DOT_PRODUCT
3180 @cindex vector product
3181 @cindex product, vector
3184 @item @emph{Description}:
3185 @code{DOT_PRODUCT(X,Y)} computes the dot product multiplication of two vectors
3186 @var{X} and @var{Y}. The two vectors may be either numeric or logical
3187 and must be arrays of rank one and of equal size. If the vectors are
3188 @code{INTEGER(*)} or @code{REAL(*)}, the result is @code{SUM(X*Y)}. If the
3189 vectors are @code{COMPLEX(*)}, the result is @code{SUM(CONJG(X)*Y)}. If the
3190 vectors are @code{LOGICAL}, the result is @code{ANY(X.AND.Y)}.
3192 @item @emph{Standard}:
3196 Transformational function
3198 @item @emph{Syntax}:
3199 @code{RESULT = DOT_PRODUCT(X, Y)}
3201 @item @emph{Arguments}:
3202 @multitable @columnfractions .15 .70
3203 @item @var{X} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
3204 @item @var{Y} @tab The type shall be numeric or @code{LOGICAL}, rank 1.
3207 @item @emph{Return value}:
3208 If the arguments are numeric, the return value is a scaler of numeric type,
3209 @code{INTEGER(*)}, @code{REAL(*)}, or @code{COMPLEX(*)}. If the arguments are
3210 @code{LOGICAL}, the return value is @code{.TRUE.} or @code{.FALSE.}.
3212 @item @emph{Example}:
3214 program test_dot_prod
3215 integer, dimension(3) :: a, b
3222 print *, dot_product(a,b)
3223 end program test_dot_prod
3230 @section @code{DPROD} --- Double product function
3232 @cindex product, double-precision
3235 @item @emph{Description}:
3236 @code{DPROD(X,Y)} returns the product @code{X*Y}.
3238 @item @emph{Standard}:
3244 @item @emph{Syntax}:
3245 @code{RESULT = DPROD(X, Y)}
3247 @item @emph{Arguments}:
3248 @multitable @columnfractions .15 .70
3249 @item @var{X} @tab The type shall be @code{REAL}.
3250 @item @var{Y} @tab The type shall be @code{REAL}.
3253 @item @emph{Return value}:
3254 The return value is of type @code{REAL(8)}.
3256 @item @emph{Example}:
3264 end program test_dprod
3271 @section @code{DREAL} --- Double real part function
3273 @cindex complex numbers, real part
3276 @item @emph{Description}:
3277 @code{DREAL(Z)} returns the real part of complex variable @var{Z}.
3279 @item @emph{Standard}:
3285 @item @emph{Syntax}:
3286 @code{RESULT = DREAL(Z)}
3288 @item @emph{Arguments}:
3289 @multitable @columnfractions .15 .70
3290 @item @var{Z} @tab The type shall be @code{COMPLEX(8)}.
3293 @item @emph{Return value}:
3294 The return value is of type @code{REAL(8)}.
3296 @item @emph{Example}:
3299 complex(8) :: z = (1.3_8,7.2_8)
3301 end program test_dreal
3304 @item @emph{See also}:
3312 @section @code{DTIME} --- Execution time subroutine (or function)
3314 @cindex time, elapsed
3315 @cindex elapsed time
3318 @item @emph{Description}:
3319 @code{DTIME(TARRAY, RESULT)} initially returns the number of seconds of runtime
3320 since the start of the process's execution in @var{RESULT}. @var{TARRAY}
3321 returns the user and system components of this time in @code{TARRAY(1)} and
3322 @code{TARRAY(2)} respectively. @var{RESULT} is equal to @code{TARRAY(1) +
3325 Subsequent invocations of @code{DTIME} return values accumulated since the
3326 previous invocation.
3328 On some systems, the underlying timings are represented using types with
3329 sufficiently small limits that overflows (wrap around) are possible, such as
3330 32-bit types. Therefore, the values returned by this intrinsic might be, or
3331 become, negative, or numerically less than previous values, during a single
3332 run of the compiled program.
3334 Please note, that this implementation is thread safe if used within OpenMP
3335 directives, i. e. its state will be consistent while called from multiple
3336 threads. However, if @code{DTIME} is called from multiple threads, the result
3337 is still the time since the last invocation. This may not give the intended
3338 results. If possible, use @code{CPU_TIME} instead.
3340 This intrinsic is provided in both subroutine and function forms; however,
3341 only one form can be used in any given program unit.
3343 @var{TARRAY} and @var{RESULT} are @code{INTENT(OUT)} and provide the following:
3345 @multitable @columnfractions .15 .30 .40
3346 @item @tab @code{TARRAY(1)}: @tab User time in seconds.
3347 @item @tab @code{TARRAY(2)}: @tab System time in seconds.
3348 @item @tab @code{RESULT}: @tab Run time since start in seconds.
3351 @item @emph{Standard}:
3355 Subroutine, function
3357 @item @emph{Syntax}:
3358 @multitable @columnfractions .80
3359 @item @code{CALL DTIME(TARRAY, RESULT)}.
3360 @item @code{RESULT = DTIME(TARRAY)}, (not recommended).
3363 @item @emph{Arguments}:
3364 @multitable @columnfractions .15 .70
3365 @item @var{TARRAY}@tab The type shall be @code{REAL, DIMENSION(2)}.
3366 @item @var{RESULT}@tab The type shall be @code{REAL}.
3369 @item @emph{Return value}:
3370 Elapsed time in seconds since the last invocation or since the start of program
3371 execution if not called before.
3373 @item @emph{Example}:
3377 real, dimension(2) :: tarray
3379 call dtime(tarray, result)
3383 do i=1,100000000 ! Just a delay
3386 call dtime(tarray, result)
3390 end program test_dtime
3393 @item @emph{See also}:
3401 @section @code{EOSHIFT} --- End-off shift elements of an array
3403 @cindex array, shift
3406 @item @emph{Description}:
3407 @code{EOSHIFT(ARRAY, SHIFT[,BOUNDARY, DIM])} performs an end-off shift on
3408 elements of @var{ARRAY} along the dimension of @var{DIM}. If @var{DIM} is
3409 omitted it is taken to be @code{1}. @var{DIM} is a scaler of type
3410 @code{INTEGER} in the range of @math{1 /leq DIM /leq n)} where @math{n} is the
3411 rank of @var{ARRAY}. If the rank of @var{ARRAY} is one, then all elements of
3412 @var{ARRAY} are shifted by @var{SHIFT} places. If rank is greater than one,
3413 then all complete rank one sections of @var{ARRAY} along the given dimension are
3414 shifted. Elements shifted out one end of each rank one section are dropped. If
3415 @var{BOUNDARY} is present then the corresponding value of from @var{BOUNDARY}
3416 is copied back in the other end. If @var{BOUNDARY} is not present then the
3417 following are copied in depending on the type of @var{ARRAY}.
3419 @multitable @columnfractions .15 .80
3420 @item @emph{Array Type} @tab @emph{Boundary Value}
3421 @item Numeric @tab 0 of the type and kind of @var{ARRAY}.
3422 @item Logical @tab @code{.FALSE.}.
3423 @item Character(@var{len}) @tab @var{len} blanks.
3426 @item @emph{Standard}:
3430 Transformational function
3432 @item @emph{Syntax}:
3433 @code{RESULT = EOSHIFT(ARRAY, SHIFT [, BOUNDARY, DIM])}
3435 @item @emph{Arguments}:
3436 @multitable @columnfractions .15 .70
3437 @item @var{ARRAY} @tab May be any type, not scaler.
3438 @item @var{SHIFT} @tab The type shall be @code{INTEGER}.
3439 @item @var{BOUNDARY} @tab Same type as @var{ARRAY}.
3440 @item @var{DIM} @tab The type shall be @code{INTEGER}.
3443 @item @emph{Return value}:
3444 Returns an array of same type and rank as the @var{ARRAY} argument.
3446 @item @emph{Example}:
3448 program test_eoshift
3449 integer, dimension(3,3) :: a
3450 a = reshape( (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /), (/ 3, 3 /))
3451 print '(3i3)', a(1,:)
3452 print '(3i3)', a(2,:)
3453 print '(3i3)', a(3,:)
3454 a = EOSHIFT(a, SHIFT=(/1, 2, 1/), BOUNDARY=-5, DIM=2)
3456 print '(3i3)', a(1,:)
3457 print '(3i3)', a(2,:)
3458 print '(3i3)', a(3,:)
3459 end program test_eoshift
3466 @section @code{EPSILON} --- Epsilon function
3468 @cindex model representation, epsilon
3471 @item @emph{Description}:
3472 @code{EPSILON(X)} returns a nearly negligible number relative to @code{1}.
3474 @item @emph{Standard}:
3480 @item @emph{Syntax}:
3481 @code{RESULT = EPSILON(X)}
3483 @item @emph{Arguments}:
3484 @multitable @columnfractions .15 .70
3485 @item @var{X} @tab The type shall be @code{REAL(*)}.
3488 @item @emph{Return value}:
3489 The return value is of same type as the argument.
3491 @item @emph{Example}:
3493 program test_epsilon
3498 end program test_epsilon
3505 @section @code{ERF} --- Error function
3507 @cindex error function
3510 @item @emph{Description}:
3511 @code{ERF(X)} computes the error function of @var{X}.
3513 @item @emph{Standard}:
3519 @item @emph{Syntax}:
3520 @code{RESULT = ERF(X)}
3522 @item @emph{Arguments}:
3523 @multitable @columnfractions .15 .70
3524 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
3527 @item @emph{Return value}:
3528 The return value is a scalar of type @code{REAL(*)} and it is positive
3529 (@math{ - 1 \leq erf (x) \leq 1 }.
3531 @item @emph{Example}:
3534 real(8) :: x = 0.17_8
3536 end program test_erf
3539 @item @emph{Specific names}:
3540 @multitable @columnfractions .20 .20 .20 .25
3541 @item Name @tab Argument @tab Return type @tab Standard
3542 @item @code{DERF(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
3549 @section @code{ERFC} --- Error function
3551 @cindex error function, complementary
3554 @item @emph{Description}:
3555 @code{ERFC(X)} computes the complementary error function of @var{X}.
3557 @item @emph{Standard}:
3563 @item @emph{Syntax}:
3564 @code{RESULT = ERFC(X)}
3566 @item @emph{Arguments}:
3567 @multitable @columnfractions .15 .70
3568 @item @var{X} @tab The type shall be @code{REAL(*)}, and it shall be scalar.
3571 @item @emph{Return value}:
3572 The return value is a scalar of type @code{REAL(*)} and it is positive
3573 (@math{ 0 \leq erfc (x) \leq 2 }.
3575 @item @emph{Example}:
3578 real(8) :: x = 0.17_8
3580 end program test_erfc
3583 @item @emph{Specific names}:
3584 @multitable @columnfractions .20 .20 .20 .25
3585 @item Name @tab Argument @tab Return type @tab Standard
3586 @item @code{DERFC(X)} @tab @code{REAL(8) X} @tab @code{REAL(8)} @tab GNU extension
3593 @section @code{ETIME} --- Execution time subroutine (or function)
3595 @cindex time, elapsed
3598 @item @emph{Description}:
3599 @code{ETIME(TARRAY, RESULT)} returns the number of seconds of runtime
3600 since the start of the process's execution in @var{RESULT}. @var{TARRAY}
3601 returns the user and system components of this time in @code{TARRAY(1)} and
3602 @code{TARRAY(2)} respectively. @var{RESULT} is equal to @code{TARRAY(1) + TARRAY(2)}.
3604 On some systems, the underlying timings are represented using types with
3605 sufficiently small limits that overflows (wrap around) are possible, such as
3606 32-bit types. Therefore, the values returned by this intrinsic might be, or
3607 become, negative, or numerically less than previous values, during a single
3608 run of the compiled program.
3610 This intrinsic is provided in both subroutine and function forms; however,
3611 only one form can be used in any given program unit.
3613 @var{TARRAY} and @var{RESULT} are @code{INTENT(OUT)} and provide the following:
3615 @multitable @columnfractions .15 .30 .60
3616 @item @tab @code{TARRAY(1)}: @tab User time in seconds.
3617 @item @tab @code{TARRAY(2)}: @tab System time in seconds.
3618 @item @tab @code{RESULT}: @tab Run time since start in seconds.
3621 @item @emph{Standard}:
3625 Subroutine, function
3627 @item @emph{Syntax}:
3628 @multitable @columnfractions .80
3629 @item @code{CALL ETIME(TARRAY, RESULT)}.
3630 @item @code{RESULT = ETIME(TARRAY)}, (not recommended).
3633 @item @emph{Arguments}:
3634 @multitable @columnfractions .15 .70
3635 @item @var{TARRAY}@tab The type shall be @code{REAL, DIMENSION(2)}.
3636 @item @var{RESULT}@tab The type shall be @code{REAL}.
3639 @item @emph{Return value}:
3640 Elapsed time in seconds since the start of program execution.
3642 @item @emph{Example}:
3646 real, dimension(2) :: tarray
3648 call ETIME(tarray, result)
3652 do i=1,100000000 ! Just a delay
3655 call ETIME(tarray, result)
3659 end program test_etime
3662 @item @emph{See also}:
3670 @section @code{EXIT} --- Exit the program with status.
3672 @cindex program termination
3673 @cindex terminate program
3676 @item @emph{Description}:
3677 @code{EXIT} causes immediate termination of the program with status. If status
3678 is omitted it returns the canonical @emph{success} for the system. All Fortran
3679 I/O units are closed.
3681 @item @emph{Standard}:
3687 @item @emph{Syntax}:
3688 @code{CALL EXIT([STATUS])}
3690 @item @emph{Arguments}:
3691 @multitable @columnfractions .15 .70
3692 @item @var{STATUS} @tab Shall be an @code{INTEGER} of the default kind.
3695 @item @emph{Return value}:
3696 @code{STATUS} is passed to the parent process on exit.
3698 @item @emph{Example}:
3701 integer :: STATUS = 0
3702 print *, 'This program is going to exit.'
3704 end program test_exit
3707 @item @emph{See also}:
3708 @ref{ABORT}, @ref{KILL}
3714 @section @code{EXP} --- Exponential function